BSD port changes for base/ (OS_POSIX/GTK instead of OS_LINUX
where applicable, missing includes, etc)
Review URL: http://codereview.chromium.org/774001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41143 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/base/base.gypi b/base/base.gypi
index b6bca90..c9d2e081 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -372,7 +372,7 @@
},
# Conditions that are not relevant for Win64 build
'conditions': [
- [ 'OS == "linux" or OS == "freebsd"', {
+ [ 'OS == "linux" or OS == "freebsd" or OS == "openbsd"', {
'conditions': [
[ 'chromeos==1', {
'sources/': [ ['include', '_chromeos\\.cc$'] ]
@@ -417,7 +417,7 @@
'../build/linux/system.gyp:gtk',
],
},],
- [ 'OS == "freebsd"', {
+ [ 'OS == "freebsd" or OS == "openbsd"', {
'sources!': [
'file_watcher_inotify.cc',
],
@@ -602,7 +602,7 @@
},
],
}],
- [ 'OS == "linux" or OS == "freebsd"', {
+ [ 'OS == "linux" or OS == "freebsd" or OS == "openbsd"', {
'targets': [
{
'target_name': 'symbolize',
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index c6069e6..9ab25a3 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -39,7 +39,7 @@
namespace file_util {
-#if defined(OS_FREEBSD) || \
+#if defined(OS_OPENBSD) || defined(OS_FREEBSD) || \
(defined(OS_MACOSX) && \
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
typedef struct stat stat_wrapper_t;
diff --git a/base/linux_util.cc b/base/linux_util.cc
index 8ac2e495..14c355e8 100644
--- a/base/linux_util.cc
+++ b/base/linux_util.cc
@@ -201,7 +201,7 @@
std::string GetLinuxDistro() {
#if defined(OS_CHROMEOS)
return linux_distro;
-#else // if defined(OS_LINUX)
+#elif defined(OS_LINUX)
LinuxDistroHelper* distro_state_singleton = LinuxDistroHelper::Get();
LinuxDistroState state = distro_state_singleton->State();
if (STATE_DID_NOT_CHECK == state) {
@@ -231,6 +231,8 @@
// In STATE_CHECK_FINISHED, no more writing to |linux_distro|.
return linux_distro;
}
+#else
+ NOTIMPLEMENTED();
#endif
}
diff --git a/base/process_posix.cc b/base/process_posix.cc
index 29166b9..904884a5 100644
--- a/base/process_posix.cc
+++ b/base/process_posix.cc
@@ -2,9 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/process.h"
+
+#include <sys/types.h>
+#include <sys/time.h>
#include <sys/resource.h>
-#include "base/process.h"
#include "base/process_util.h"
namespace base {
diff --git a/base/process_util.h b/base/process_util.h
index a368698..cf4bd017 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -478,16 +478,14 @@
int64 last_time_;
int64 last_system_time_;
-#if defined(OS_LINUX)
- // Jiffie count at the last_time_ we updated.
- int last_cpu_;
-#endif
-
#if defined(OS_MACOSX)
// Queries the port provider if it's set.
mach_port_t TaskForPid(ProcessHandle process) const;
PortProvider* port_provider_;
+#elif defined(OS_POSIX)
+ // Jiffie count at the last_time_ we updated.
+ int last_cpu_;
#endif
DISALLOW_EVIL_CONSTRUCTORS(ProcessMetrics);
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index cca07dd..fdac7a2 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -269,7 +269,8 @@
void SetAllFDsToCloseOnExec() {
#if defined(OS_LINUX)
const char fd_dir[] = "/proc/self/fd";
-#elif defined(OS_MACOSX) || defined(OS_FREEBSD) || defined(OS_SOLARIS)
+#elif defined(OS_MACOSX) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || \
+ defined(OS_SOLARIS)
const char fd_dir[] = "/dev/fd";
#endif
ScopedDIR dir_closer(opendir(fd_dir));
@@ -479,10 +480,10 @@
: process_(process),
last_time_(0),
last_system_time_(0)
-#if defined(OS_LINUX)
- , last_cpu_(0)
-#elif defined(OS_MACOSX)
+#if defined(OS_MACOSX)
, port_provider_(port_provider)
+#elif defined(OS_POSIX)
+ , last_cpu_(0)
#endif
{
processor_count_ = base::SysInfo::NumberOfProcessors();
diff --git a/base/sys_info_openbsd.cc b/base/sys_info_openbsd.cc
index 5f85888..8877222 100644
--- a/base/sys_info_openbsd.cc
+++ b/base/sys_info_openbsd.cc
@@ -4,6 +4,9 @@
#include "base/sys_info.h"
+#include <sys/param.h>
+#include <sys/sysctl.h>
+
#include "base/logging.h"
namespace base {
diff --git a/base/time_posix.cc b/base/time_posix.cc
index 60771af..2490315 100644
--- a/base/time_posix.cc
+++ b/base/time_posix.cc
@@ -147,7 +147,7 @@
// FreeBSD 6 has CLOCK_MONOLITHIC but defines _POSIX_MONOTONIC_CLOCK to -1.
#if (defined(OS_POSIX) && \
defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0) || \
- defined(OS_FREEBSD)
+ defined(OS_FREEBSD) || defined(OS_OPENBSD)
// static
TimeTicks TimeTicks::Now() {