Upload upstream chromium 69.0.3497
[platform/framework/web/chromium-efl.git] / base / sys_info_freebsd.cc
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/sys_info.h"
6
7 #include <stddef.h>
8 #include <stdint.h>
9 #include <sys/sysctl.h>
10
11 #include "base/logging.h"
12
13 namespace base {
14
15 int64_t SysInfo::AmountOfPhysicalMemoryImpl() {
16   int pages, page_size;
17   size_t size = sizeof(pages);
18   sysctlbyname("vm.stats.vm.v_page_count", &pages, &size, NULL, 0);
19   sysctlbyname("vm.stats.vm.v_page_size", &page_size, &size, NULL, 0);
20   if (pages == -1 || page_size == -1) {
21     NOTREACHED();
22     return 0;
23   }
24   return static_cast<int64_t>(pages) * page_size;
25 }
26
27 // static
28 uint64_t SysInfo::MaxSharedMemorySize() {
29   size_t limit;
30   size_t size = sizeof(limit);
31   if (sysctlbyname("kern.ipc.shmmax", &limit, &size, NULL, 0) < 0) {
32     NOTREACHED();
33     return 0;
34   }
35   return static_cast<uint64_t>(limit);
36 }
37
38 }  // namespace base