summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/base.gyp5
-rw-r--r--base/base.gypi10
-rw-r--r--base/file_util_posix.cc4
-rw-r--r--base/linux_util.cc1
-rw-r--r--base/sys_info_freebsd.cc7
-rw-r--r--base/sys_info_linux.cc23
-rw-r--r--base/sys_info_openbsd.cc14
7 files changed, 52 insertions, 12 deletions
diff --git a/base/base.gyp b/base/base.gyp
index 7fbba40..3003ec8 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -410,6 +410,11 @@
'test/scoped_locale.h',
],
}],
+ ['OS=="openbsd"', {
+ 'sources!': [
+ 'test/test_file_util_linux.cc',
+ ],
+ }],
],
'sources': [
'perftimer.cc',
diff --git a/base/base.gypi b/base/base.gypi
index e2f0a7d..668516e 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -426,7 +426,7 @@
'sources!' : [ 'message_pump_gtk.cc', ],
'sources/' : [ [ 'include', 'message_pump_x.cc', ] ],
}],
- [ 'OS != "linux"', {
+ [ 'OS != "linux" and OS != "openbsd"', {
'sources!': [
# Not automatically excluded by the *linux.cc rules.
'linux_util.cc',
@@ -501,9 +501,11 @@
}],
[ 'OS == "openbsd"', {
'sources/': [
- ['include', '^base_paths_linux\\.cc$'],
- ['include', '^native_library_linux\\.cc$'],
- ['include', '^sys_string_conversions_linux\\.cc$'],
+ ['exclude', '^files/file_path_watcher_linux\\.cc$'],
+ ['exclude', '^file_util_linux\\.cc$'],
+ ['exclude', '^process_linux\\.cc$'],
+ ['exclude', '^process_util_linux\\.cc$'],
+ ['exclude', '^sys_info_linux\\.cc$'],
],
}],
],
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index bb9977e..8d9fb29 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -912,8 +912,12 @@ bool GetTempDir(FilePath* path) {
#if !defined(OS_ANDROID)
bool GetShmemTempDir(FilePath* path) {
+#if defined(OS_LINUX)
*path = FilePath("/dev/shm");
return true;
+#else
+ return GetTempDir(path);
+#endif
}
#endif
diff --git a/base/linux_util.cc b/base/linux_util.cc
index a24f311..c0757fa 100644
--- a/base/linux_util.cc
+++ b/base/linux_util.cc
@@ -171,6 +171,7 @@ std::string GetLinuxDistro() {
}
#else
NOTIMPLEMENTED();
+ return "Unknown";
#endif
}
diff --git a/base/sys_info_freebsd.cc b/base/sys_info_freebsd.cc
index 66ab23b..832b3598 100644
--- a/base/sys_info_freebsd.cc
+++ b/base/sys_info_freebsd.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -26,7 +26,10 @@ int64 SysInfo::AmountOfPhysicalMemory() {
size_t SysInfo::MaxSharedMemorySize() {
size_t limit;
size_t size = sizeof(limit);
- sysctlbyname("kern.ipc.shmmax", &limit, &size, NULL, 0);
+ if (sysctlbyname("kern.ipc.shmmax", &limit, &size, NULL, 0) < 0) {
+ NOTREACHED();
+ return 0;
+ }
return limit;
}
diff --git a/base/sys_info_linux.cc b/base/sys_info_linux.cc
index 67bfe5a6..03fdac2 100644
--- a/base/sys_info_linux.cc
+++ b/base/sys_info_linux.cc
@@ -1,11 +1,14 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/sys_info.h"
+#include <limits>
+
#include "base/file_util.h"
#include "base/logging.h"
+#include "base/string_number_conversions.h"
namespace base {
@@ -22,15 +25,25 @@ int64 SysInfo::AmountOfPhysicalMemory() {
// static
size_t SysInfo::MaxSharedMemorySize() {
- static size_t limit;
+ static int64 limit;
static bool limit_valid = false;
if (!limit_valid) {
std::string contents;
file_util::ReadFileToString(FilePath("/proc/sys/kernel/shmmax"), &contents);
- limit = strtoul(contents.c_str(), NULL, 0);
- limit_valid = true;
+ DCHECK(!contents.empty());
+ if (!contents.empty() && contents[contents.length() - 1] == '\n') {
+ contents.erase(contents.length() - 1);
+ }
+ if (base::StringToInt64(contents, &limit)) {
+ DCHECK(limit >= 0);
+ DCHECK(static_cast<uint64>(limit) <= std::numeric_limits<size_t>::max());
+ limit_valid = true;
+ } else {
+ NOTREACHED();
+ return 0;
+ }
}
- return limit;
+ return static_cast<size_t>(limit);
}
} // namespace base
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 <sys/param.h>
+#include <sys/shm.h>
#include <sys/sysctl.h>
#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<int64>(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