Skip to content

Commit

Permalink
Changes to base/ from a combination of FreeBSD and OpenBSD patches.
Browse files Browse the repository at this point in the history
Review URL: http://codereview.chromium.org/495002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35321 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
evan@chromium.org committed Dec 29, 2009
1 parent a672cb9 commit e43eddf
Show file tree
Hide file tree
Showing 29 changed files with 99 additions and 68 deletions.
2 changes: 1 addition & 1 deletion base/allocator/allocator.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
'<(tcmalloc_dir)/src/profiler.cc',
],
}],
['OS=="linux"', {
['OS=="linux" or OS=="freebsd"', {
'sources!': [
'<(tcmalloc_dir)/src/system-alloc.h',
'<(tcmalloc_dir)/src/windows/port.cc',
Expand Down
19 changes: 13 additions & 6 deletions base/base.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,14 @@
},
},
],
[ 'OS == "linux"', {
'link_settings': {
'libraries': [
# We need rt for clock_gettime().
'-lrt',
],
},
}],
],
'dependencies': [
'../build/util/build_util.gyp:lastchange',
Expand All @@ -386,12 +394,6 @@
'cflags': [
'-Wno-write-strings',
],
'link_settings': {
'libraries': [
# We need rt for clock_gettime().
'-lrt',
],
},
'export_dependent_settings': [
'../build/linux/system.gyp:gtk',
],
Expand All @@ -403,6 +405,11 @@
'sources': [
'directory_watcher_stub.cc',
],
'link_settings': {
'libraries': [
'-L/usr/local/lib -lexecinfo',
],
},
},
],
[ 'OS == "mac"', {
Expand Down
2 changes: 1 addition & 1 deletion base/command_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void CommandLine::Init(int argc, const char* const* argv) {
#endif
}

#if defined(OS_LINUX) || defined(OS_FREEBSD)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// static
void CommandLine::SetProcTitle() {
// Build a single string which consists of all the arguments separated
Expand Down
2 changes: 1 addition & 1 deletion base/command_line.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class CommandLine {
// line, but it still must be called to set up the command line.
static void Init(int argc, const char* const* argv);

#if defined(OS_LINUX) || defined(OS_FREEBSD)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// Sets the current process' arguments that show in "ps" etc. to those
// in |current_process_commandline_|. Used by the zygote host so that
// renderers show up with --type=renderer.
Expand Down
10 changes: 9 additions & 1 deletion base/debug_util_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,15 @@ bool DebugUtil::BeingDebugged() {
return pid_index < status.size() && status[pid_index] != '0';
}

#endif // OS_LINUX
#elif defined(OS_FREEBSD)

bool DebugUtil::BeingDebugged() {
// TODO(benl): can we determine this under FreeBSD?
NOTIMPLEMENTED();
return false;
}

#endif

// static
void DebugUtil::BreakDebugger() {
Expand Down
9 changes: 5 additions & 4 deletions base/file_util_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ int CountFilesCreatedAfter(const FilePath& path,
DIR* dir = opendir(path.value().c_str());
if (dir) {
#if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_FREEBSD)
#error Depending on the definition of struct dirent, additional space for \
pathname may be needed
#error Port warning: depending on the definition of struct dirent, \
additional space for pathname may be needed
#endif
struct dirent ent_buf;
struct dirent* ent;
Expand Down Expand Up @@ -635,9 +635,10 @@ bool FileEnumerator::ReadDirectory(std::vector<DirectoryEntryInfo>* entries,
return false;

#if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_FREEBSD)
#error Depending on the definition of struct dirent, additional space for \
pathname may be needed
#error Port warning: depending on the definition of struct dirent, \
additional space for pathname may be needed
#endif

struct dirent dent_buf;
struct dirent* dent;
while (readdir_r(dir, &dent_buf, &dent) == 0 && dent) {
Expand Down
10 changes: 5 additions & 5 deletions base/file_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1373,19 +1373,19 @@ TEST_F(FileUtilTest, Contains) {
EXPECT_FALSE(file_util::ContainsPath(foo, foobar));
EXPECT_FALSE(file_util::ContainsPath(foo, foo));

// Platform-specific concerns
// Platform-specific concerns.
FilePath foo_caps(data_dir.Append(FILE_PATH_LITERAL("FOO")));
#if defined(OS_WIN)
EXPECT_TRUE(file_util::ContainsPath(foo,
foo_caps.Append(FILE_PATH_LITERAL("bar.txt"))));
EXPECT_TRUE(file_util::ContainsPath(foo,
FilePath(foo.value() + FILE_PATH_LITERAL("/bar.txt"))));
#elif defined(OS_LINUX)
#elif defined(OS_MACOSX)
// We can't really do this test on OS X since the case-sensitivity of the
// filesystem is configurable.
#elif defined(OS_POSIX)
EXPECT_FALSE(file_util::ContainsPath(foo,
foo_caps.Append(FILE_PATH_LITERAL("bar.txt"))));
#else
// We can't really do this test on osx since the case-sensitivity of the
// filesystem is configurable.
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion base/file_version_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class FileVersionInfo {
explicit FileVersionInfo(NSBundle *bundle);

NSBundle *bundle_;
#elif defined(OS_LINUX)
#elif defined(OS_POSIX)
FileVersionInfo();
#endif

Expand Down
14 changes: 7 additions & 7 deletions base/gfx/rect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <windows.h>
#elif defined(OS_MACOSX)
#include <CoreGraphics/CGGeometry.h>
#elif defined(OS_LINUX)
#elif defined(OS_POSIX)
#include <gdk/gdk.h>
#endif

Expand Down Expand Up @@ -76,7 +76,7 @@ Rect& Rect::operator=(const CGRect& r) {
set_height(r.size.height);
return *this;
}
#elif defined(OS_LINUX)
#elif defined(OS_POSIX)
Rect::Rect(const GdkRectangle& r)
: origin_(r.x, r.y) {
set_width(r.width);
Expand Down Expand Up @@ -128,15 +128,15 @@ RECT Rect::ToRECT() const {
r.bottom = bottom();
return r;
}
#elif defined(OS_LINUX)
GdkRectangle Rect::ToGdkRectangle() const {
GdkRectangle r = {x(), y(), width(), height()};
return r;
}
#elif defined(OS_MACOSX)
CGRect Rect::ToCGRect() const {
return CGRectMake(x(), y(), width(), height());
}
#elif defined(OS_POSIX)
GdkRectangle Rect::ToGdkRectangle() const {
GdkRectangle r = {x(), y(), width(), height()};
return r;
}
#endif

bool Rect::Contains(int point_x, int point_y) const {
Expand Down
2 changes: 1 addition & 1 deletion base/i18n/file_util_icu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void ReplaceIllegalCharactersInPath(FilePath::StringType* file_name,
// Windows uses UTF-16 encoding for filenames.
U16_NEXT(file_name->data(), cursor, static_cast<int>(file_name->length()),
code_point);
#elif defined(OS_LINUX)
#elif defined(OS_POSIX)
// Linux doesn't actually define an encoding. It basically allows anything
// except for a few special ASCII characters.
unsigned char cur_char = static_cast<unsigned char>((*file_name)[cursor++]);
Expand Down
2 changes: 1 addition & 1 deletion base/i18n/file_util_icu_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FileUtilICUTest : public PlatformTest {
FilePath test_dir_;
};

#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)

// Linux disallows some evil ASCII characters, but passes all non-ASCII.
static const struct goodbad_pair {
Expand Down
2 changes: 1 addition & 1 deletion base/i18n/icu_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_SHARED
#elif defined(OS_MACOSX)
#define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_STATIC
#elif defined(OS_LINUX)
#elif defined(OS_POSIX)
#define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_FILE
#endif

Expand Down
9 changes: 6 additions & 3 deletions base/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ typedef HANDLE MutexHandle;
#include <mach/mach.h>
#include <mach/mach_time.h>
#include <mach-o/dyld.h>
#elif defined(OS_LINUX)
#elif defined(OS_POSIX)
#include <sys/syscall.h>
#include <time.h>
#endif
Expand Down Expand Up @@ -137,6 +137,9 @@ int32 CurrentThreadId() {
return mach_thread_self();
#elif defined(OS_LINUX)
return syscall(__NR_gettid);
#elif defined(OS_FREEBSD)
// TODO(BSD): find a better thread ID
return reinterpret_cast<int64>(pthread_self());
#endif
}

Expand All @@ -145,7 +148,7 @@ uint64 TickCount() {
return GetTickCount();
#elif defined(OS_MACOSX)
return mach_absolute_time();
#elif defined(OS_LINUX)
#elif defined(OS_POSIX)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);

Expand Down Expand Up @@ -226,7 +229,7 @@ bool InitializeLogFileHandle() {
return true;
}

#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
int GetLoggingFileDescriptor() {
// No locking needed, since this is only called by the zygote server,
// which is single-threaded.
Expand Down
2 changes: 1 addition & 1 deletion base/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void SetMinLogLevel(int level);
// Gets the current log level.
int GetMinLogLevel();

#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// Get the file descriptor used for logging.
// Returns -1 if none open.
// Needed by ZygoteManager.
Expand Down
14 changes: 7 additions & 7 deletions base/message_loop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "base/message_pump_libevent.h"
#include "base/third_party/valgrind/valgrind.h"
#endif
#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
#include "base/message_pump_glib.h"
#endif

Expand Down Expand Up @@ -99,9 +99,9 @@ MessageLoop::MessageLoop(Type type)
if (type_ == TYPE_UI) {
#if defined(OS_MACOSX)
pump_ = base::MessagePumpMac::Create();
#elif defined(OS_LINUX)
#else
pump_ = new base::MessagePumpForUI();
#endif // OS_LINUX
#endif
} else if (type_ == TYPE_IO) {
pump_ = new base::MessagePumpLibevent();
} else {
Expand Down Expand Up @@ -194,7 +194,7 @@ void MessageLoop::RunInternal() {

StartHistogrammer();

#if defined(OS_WIN) || defined(OS_LINUX)
#if !defined(OS_MACOSX)
if (state_->dispatcher && type() == TYPE_UI) {
static_cast<base::MessagePumpForUI*>(pump_.get())->
RunWithDispatcher(this, state_->dispatcher);
Expand Down Expand Up @@ -487,7 +487,7 @@ MessageLoop::AutoRunState::AutoRunState(MessageLoop* loop) : loop_(loop) {

// Initialize the other fields:
quit_received = false;
#if defined(OS_WIN) || defined(OS_LINUX)
#if !defined(OS_MACOSX)
dispatcher = NULL;
#endif
}
Expand Down Expand Up @@ -588,7 +588,7 @@ void MessageLoopForUI::PumpOutPendingPaintMessages() {

#endif // defined(OS_WIN)

#if defined(OS_LINUX) || defined(OS_WIN)
#if !defined(OS_MACOSX)
void MessageLoopForUI::AddObserver(Observer* observer) {
pump_ui()->AddObserver(observer);
}
Expand All @@ -602,7 +602,7 @@ void MessageLoopForUI::Run(Dispatcher* dispatcher) {
state_->dispatcher = dispatcher;
RunHandler();
}
#endif // defined(OS_LINUX) || defined(OS_WIN)
#endif // !defined(OS_MACOSX)

//------------------------------------------------------------------------------
// MessageLoopForIO
Expand Down
12 changes: 6 additions & 6 deletions base/message_loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include "base/message_pump_win.h"
#elif defined(OS_POSIX)
#include "base/message_pump_libevent.h"
#endif
#if defined(OS_LINUX)
#if !defined(OS_MACOSX)
#include "base/message_pump_glib.h"
#endif
#endif

// A MessageLoop is used to process events for a particular thread. There is
// at most one MessageLoop instance per thread.
Expand Down Expand Up @@ -254,7 +254,7 @@ class MessageLoop : public base::MessagePump::Delegate {
#if defined(OS_WIN)
typedef base::MessagePumpWin::Dispatcher Dispatcher;
typedef base::MessagePumpWin::Observer Observer;
#elif defined(OS_LINUX)
#elif !defined(OS_MACOSX)
typedef base::MessagePumpForUI::Dispatcher Dispatcher;
typedef base::MessagePumpForUI::Observer Observer;
#endif
Expand All @@ -269,7 +269,7 @@ class MessageLoop : public base::MessagePump::Delegate {
// once it becomes idle.
bool quit_received;

#if defined(OS_WIN) || defined(OS_LINUX)
#if !defined(OS_MACOSX)
Dispatcher* dispatcher;
#endif
};
Expand Down Expand Up @@ -457,7 +457,7 @@ class MessageLoopForUI : public MessageLoop {
void PumpOutPendingPaintMessages();
#endif

#if defined(OS_WIN) || defined(OS_LINUX)
#if !defined(OS_MACOSX)
// Please see message_pump_win/message_pump_glib for definitions of these
// methods.
void AddObserver(Observer* observer);
Expand All @@ -469,7 +469,7 @@ class MessageLoopForUI : public MessageLoop {
base::MessagePumpForUI* pump_ui() {
return static_cast<base::MessagePumpForUI*>(pump_.get());
}
#endif // defined(OS_WIN) || defined(OS_LINUX)
#endif // defined(OS_MACOSX)
};

// Do not add any member variables to MessageLoopForUI! This is important b/c
Expand Down
2 changes: 1 addition & 1 deletion base/message_loop_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1502,4 +1502,4 @@ TEST(MessageLoopTest, FileDescriptorWatcherDoubleStop) {
close(pipefds[1]);
}

#endif // defined(OS_LINUX)
#endif // defined(OS_POSIX)
2 changes: 1 addition & 1 deletion base/mime_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ std::string GetFileMimeType(const FilePath& filepath);
// Get the mime type for a byte vector.
std::string GetDataMimeType(const std::string& data);

#if defined(OS_LINUX)
#if defined(TOOLKIT_GTK)
// This detects the current GTK theme by calling gtk_settings_get_default().
// It should only be executed on the UI thread and must be called before
// GetMimeIcon().
Expand Down
2 changes: 1 addition & 1 deletion base/native_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct NativeLibraryStruct {
};
};
typedef NativeLibraryStruct* NativeLibrary;
#elif defined(OS_LINUX) || defined(OS_FREEBSD)
#elif defined(OS_POSIX)
typedef void* NativeLibrary;
#endif // OS_*

Expand Down
Loading

0 comments on commit e43eddf

Please sign in to comment.