From 167ec827dfdc84e4bf6edb4f7b4921fec844920d Mon Sep 17 00:00:00 2001 From: "robert.nagy@gmail.com" Date: Mon, 24 Oct 2011 22:05:27 +0000 Subject: OpenBSD patches for base and build, part 2 base/base.gyp: - exclude test/test_file_util_linux.cc on OpenBSD because of missing fdatasync() base/base.gypi: - include linux_util.cc on OpenBSD too - exclude some linux specific files from the OpenBSD build because the openbsd implementation is different base/file_util_posix.cc: - Use file_util::GetTempDir directly to get the shm dir on !linux base/sys_info_freebsd.cc: - return 0 and do a NOTREACHED() in case sysctlbyname() fails base/sys_info_openbsd.cc: - cleanup includes - use arraysize() in the sysctl() call - implement SysInfo::MaxSharedMemorySize() build/common.gypi: - -Wno-deprecated is C++ only flag so move it to cflags_cc - Do not exclude linux specific files, dirs on OpenBSD since 90% of it is sharable base/sys_info_linux.cc: - DCHECK if the read string is empty - Use base::StringToInt64() to convert the string to an int64 - DCHECK if the returned int64 is okay for a size_t - call NOTREACHED() and return 0 if fails BUG= TEST=runs on linux? Review URL: http://codereview.chromium.org/8382001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106984 0039d316-1c4b-4281-b951-d872f2087c98 --- base/sys_info_openbsd.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'base/sys_info_openbsd.cc') diff --git a/base/sys_info_openbsd.cc b/base/sys_info_openbsd.cc index 2d1b390..b9aec20 100644 --- a/base/sys_info_openbsd.cc +++ b/base/sys_info_openbsd.cc @@ -5,6 +5,7 @@ #include "base/sys_info.h" #include +#include #include #include "base/logging.h" @@ -15,7 +16,7 @@ int SysInfo::NumberOfProcessors() { int mib[] = { CTL_HW, HW_NCPU }; int ncpu; size_t size = sizeof(ncpu); - if (sysctl(mib, 2, &ncpu, &size, NULL, 0) == -1) { + if (sysctl(mib, arraysize(mib), &ncpu, &size, NULL, 0) == -1) { NOTREACHED(); return 1; } @@ -33,4 +34,15 @@ int64 SysInfo::AmountOfPhysicalMemory() { return static_cast(pages) * page_size; } +size_t SysInfo::MaxSharedMemorySize() { + int mib[] = { CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX }; + size_t limit; + size_t size = sizeof(limit); + if (sysctl(mib, arraysize(mib), &limit, &size, NULL, 0) < 0) { + NOTREACHED(); + return 0; + } + return limit; +} + } // namespace base -- cgit v1.1