Date: Mon, 23 Jul 2012 22:39:41 GMT From: svn-freebsd-gecko@chruetertee.ch To: freebsd-gecko@freebsd.org Subject: [SVN-Commit] r887 - in branches/experimental: mail/thunderbird mail/thunderbird-esr mail/thunderbird-esr/files mail/thunderbird/files www/firefox www/firefox-esr www/firefox-esr/files www/firefox/files www/libxul www/libxul/files www/seamonkey www/seamonkey/files Message-ID: <201207232239.q6NMdf2T064243@trillian.chruetertee.ch>
next in thread | raw e-mail | index | archive | help
Author: jbeich Date: Mon Jul 23 22:39:41 2012 New Revision: 887 Log: [merge r838] switch to bsdipc on releases Suggested by: flo Added: branches/experimental/mail/thunderbird-esr/files/patch-bug753046 branches/experimental/mail/thunderbird/files/patch-bug753046 branches/experimental/www/firefox-esr/files/patch-bug753046 branches/experimental/www/firefox/files/patch-bug753046 branches/experimental/www/libxul/files/patch-bug753046 branches/experimental/www/seamonkey/files/patch-bug753046 Deleted: branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-base-file_util_posix.cc branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-base-platform_thread_posix.cc branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-build-build_config.h branches/experimental/mail/thunderbird-esr/files/patch-mozilla-ipc-chromium-src-base-dir_reader_linux.h branches/experimental/mail/thunderbird-esr/files/patch-mozilla-toolkit-library-Makefile.in branches/experimental/mail/thunderbird/files/patch-ipc-chromium-src-base-file_util_linux.cc branches/experimental/mail/thunderbird/files/patch-ipc-chromium-src-base-file_util_posix.cc branches/experimental/mail/thunderbird/files/patch-ipc-chromium-src-base-platform_thread_posix.cc branches/experimental/mail/thunderbird/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h branches/experimental/mail/thunderbird/files/patch-ipc-chromium-src-build-build_config.h branches/experimental/mail/thunderbird/files/patch-mozilla-ipc-chromium-src-base-dir_reader_linux.h branches/experimental/mail/thunderbird/files/patch-mozilla-toolkit-library-Makefile.in branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-dir_reader_linux.h branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-file_util_posix.cc branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-platform_thread_posix.cc branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-build-build_config.h branches/experimental/www/firefox-esr/files/patch-toolkit_library_Makefile.in branches/experimental/www/firefox/files/patch-ipc-chromium-src-base-dir_reader_linux.h branches/experimental/www/firefox/files/patch-ipc-chromium-src-base-file_util_linux.cc branches/experimental/www/firefox/files/patch-ipc-chromium-src-base-file_util_posix.cc branches/experimental/www/firefox/files/patch-ipc-chromium-src-base-platform_thread_posix.cc branches/experimental/www/firefox/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h branches/experimental/www/firefox/files/patch-ipc-chromium-src-build-build_config.h branches/experimental/www/firefox/files/patch-toolkit_library_Makefile.in branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-dir_reader_linux.h branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-file_util_posix.cc branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-platform_thread_posix.cc branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h branches/experimental/www/libxul/files/patch-ipc-chromium-src-build-build_config.h branches/experimental/www/libxul/files/patch-toolkit_library_Makefile.in branches/experimental/www/seamonkey/files/patch-ipc-chromium-src-base-file_util_linux.cc branches/experimental/www/seamonkey/files/patch-ipc-chromium-src-base-file_util_posix.cc branches/experimental/www/seamonkey/files/patch-ipc-chromium-src-base-platform_thread_posix.cc branches/experimental/www/seamonkey/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h branches/experimental/www/seamonkey/files/patch-ipc-chromium-src-build-build_config.h branches/experimental/www/seamonkey/files/patch-mozilla-ipc-chromium-src-base-dir_reader_linux.h branches/experimental/www/seamonkey/files/patch-mozilla-toolkit-library-Makefile.in Modified: branches/experimental/mail/thunderbird-esr/Makefile branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-base-file_util_linux.cc branches/experimental/mail/thunderbird/Makefile branches/experimental/www/firefox-esr/Makefile branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-file_util_linux.cc branches/experimental/www/firefox/Makefile branches/experimental/www/libxul/Makefile branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-file_util_linux.cc branches/experimental/www/seamonkey/Makefile Modified: branches/experimental/mail/thunderbird-esr/Makefile ============================================================================== --- branches/experimental/mail/thunderbird-esr/Makefile Mon Jul 23 13:52:35 2012 (r886) +++ branches/experimental/mail/thunderbird-esr/Makefile Mon Jul 23 22:39:41 2012 (r887) @@ -20,7 +20,6 @@ sqlite3>=3.7.7.1:${PORTSDIR}/databases/sqlite3 \ cairo>=1.10.2_1,1:${PORTSDIR}/graphics/cairo \ unzip:${PORTSDIR}/archivers/unzip -LIB_DEPENDS= execinfo.1:${PORTSDIR}/devel/libexecinfo CONFLICTS_BUILD= spidermonkey-* @@ -98,9 +97,6 @@ <${FILESDIR}/thunderbird.desktop.in >${WRKDIR}/${MOZILLA_EXEC_NAME}.desktop post-patch: - @${GREP} -Flr \"/proc ${MOZSRC}/ipc/chromium/src/base | ${XARGS} ${REINPLACE_CMD} \ - -e 's|/proc/self/fd|/dev/fd|' \ - -e 's|/proc["/]|/compat/linux&|' @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \ ${WRKSRC}/mail/app/nsMailApp.cpp Added: branches/experimental/mail/thunderbird-esr/files/patch-bug753046 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/experimental/mail/thunderbird-esr/files/patch-bug753046 Mon Jul 23 22:39:41 2012 (r887) @@ -0,0 +1,1256 @@ +# Bug 753046 - Add support for DragonFly/NetBSD + +$NetBSD: patch-dom_plugins_ipc_PluginModuleChild.cpp,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/dom/plugins/ipc/PluginModuleChild.cpp.orig 2011-12-20 23:28:14.000000000 +0000 ++++ mozilla/dom/plugins/ipc/PluginModuleChild.cpp +@@ -33,6 +33,8 @@ + #include "nsPluginsDir.h" + #include "nsXULAppAPI.h" + ++#include <unistd.h> ++ + #ifdef MOZ_X11 + # include "mozilla/X11Util.h" + #endif +@@ -228,7 +228,7 @@ PluginModuleChild::Init(const std::strin + + // TODO: use PluginPRLibrary here + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + mShutdownFunc = + (NP_PLUGINSHUTDOWN) PR_FindFunctionSymbol(mLibrary, "NP_Shutdown"); + +@@ -1790,7 +1790,7 @@ PluginModuleChild::AnswerNP_GetEntryPoin + PLUGIN_LOG_DEBUG_METHOD; + AssertPluginThread(); + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + return true; + #elif defined(OS_WIN) || defined(OS_MACOSX) + *_retval = mGetEntryPointsFunc(&mFunctions); +@@ -1823,7 +1823,7 @@ PluginModuleChild::AnswerNP_Initialize(N + SendBackUpXResources(FileDescriptor(xSocketFd, false/*don't close*/)); + #endif + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + *_retval = mInitializeFunc(&sBrowserFuncs, &mFunctions); + return true; + #elif defined(OS_WIN) || defined(OS_MACOSX) +$NetBSD: patch-dom_plugins_ipc_PluginModuleChild.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/dom/plugins/ipc/PluginModuleChild.h.orig 2011-12-20 23:28:14.000000000 +0000 ++++ mozilla/dom/plugins/ipc/PluginModuleChild.h +@@ -340,7 +340,7 @@ private: + + // we get this from the plugin + NP_PLUGINSHUTDOWN mShutdownFunc; +-#ifdef OS_LINUX ++#if defined(OS_LINUX) || defined(OS_BSD) + NP_PLUGINUNIXINIT mInitializeFunc; + #elif defined(OS_WIN) || defined(OS_MACOSX) + NP_PLUGININIT mInitializeFunc; +$NetBSD: patch-ipc_chromium_Makefile.in,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/Makefile.in.orig 2012-02-16 06:40:33.000000000 +0000 ++++ mozilla/ipc/chromium/Makefile.in +@@ -278,6 +278,34 @@ endif + + endif # } OS_LINUX + ++ifdef OS_BSD # { ++ ++CPPSRCS += \ ++ atomicops_internals_x86_gcc.cc \ ++ file_util_bsd.cc \ ++ process_util_bsd.cc \ ++ time_posix.cc \ ++ $(NULL) ++ ++ifdef MOZ_ENABLE_GTK2 ++CPPSRCS += \ ++ message_pump_glib.cc \ ++ $(NULL) ++endif ++ ++ifdef MOZ_ENABLE_QT ++MOCSRCS = \ ++ moc_message_pump_qt.cc \ ++ $(NULL) ++ ++CPPSRCS += \ ++ $(MOCSRCS) \ ++ message_pump_qt.cc \ ++ $(NULL) ++endif ++ ++endif # } OS_BSD ++ + # libevent + + ifndef MOZ_NATIVE_LIBEVENT # { +$NetBSD: patch-ipc_chromium_chromium-config.mk,v 1.2 2012/03/15 08:30:06 ryoon Exp $ + +--- mozilla/ipc/chromium/chromium-config.mk.orig 2012-02-16 07:40:33.000000000 +0100 ++++ mozilla/ipc/chromium/chromium-config.mk 2012-03-11 11:05:40.397182000 +0100 +@@ -56,17 +56,6 @@ + -I$(DEPTH)/ipc/ipdl/_ipdlheaders \ + $(NULL) + +-ifeq ($(OS_ARCH),Darwin) # { +- +-OS_MACOSX = 1 +-OS_POSIX = 1 +- +-DEFINES += \ +- -DOS_MACOSX=1 \ +- -DOS_POSIX=1 \ +- $(NULL) +- +-else # } { + ifeq ($(OS_ARCH),WINNT) # { + OS_LIBS += $(call EXPAND_LIBNAME,psapi shell32 dbghelp) + +@@ -93,13 +82,64 @@ + endif + + else # } { +- +-OS_LINUX = 1 + OS_POSIX = 1 ++DEFINES += -DOS_POSIX=1 ++ ++ifeq ($(OS_ARCH),Darwin) # { ++ ++OS_MACOSX = 1 ++DEFINES += \ ++ -DOS_MACOSX=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),DragonFly) # { ++ ++OS_DRAGONFLY = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_DRAGONFLY=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),FreeBSD) # { ++ ++OS_FREEBSD = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_FREEBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) + ++else # } { ++ifeq ($(OS_ARCH),NetBSD) # { ++ ++OS_NETBSD = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_NETBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),OpenBSD) # { ++ ++OS_OPENBSD = 1 ++OS_BSD = 1 ++DEFINES += \ ++ -DOS_OPENBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ ++OS_LINUX = 1 + DEFINES += \ + -DOS_LINUX=1 \ +- -DOS_POSIX=1 \ + $(NULL) + + # NB: to stop gcc warnings about exporting template instantiation +@@ -107,4 +147,8 @@ + + endif # } + endif # } ++endif # } ++endif # } ++endif # } ++endif # } + +$NetBSD: patch-ipc_chromium_src_base_base__paths.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/base_paths.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/base_paths.h +@@ -13,7 +13,7 @@ + #include "base/base_paths_win.h" + #elif defined(OS_MACOSX) + #include "base/base_paths_mac.h" +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_BSD) + #include "base/base_paths_linux.h" + #endif + #include "base/path_service.h" +$NetBSD: patch-ipc_chromium_src_base_debug__util__posic.cc,v 1.3 2012/04/01 15:18:45 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/debug_util_posix.cc.orig 2012-03-13 01:36:53.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/debug_util_posix.cc +@@ -5,7 +5,7 @@ + #include "build/build_config.h" + #include "base/debug_util.h" + +-#define MOZ_HAVE_EXECINFO_H (!defined(ANDROID) && !defined(__OpenBSD__)) ++#define MOZ_HAVE_EXECINFO_H (defined(OS_LINUX) && !defined(ANDROID)) + + #include <errno.h> + #include <fcntl.h> +@@ -17,8 +17,13 @@ + #include <unistd.h> + #if MOZ_HAVE_EXECINFO_H + #include <execinfo.h> +-#include <sys/sysctl.h> + #endif ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++#include <sys/user.h> ++#elif defined(OS_FREEBSD) ++#include <sys/proc.h> ++#endif ++#include <sys/sysctl.h> + + #include "base/basictypes.h" + #include "base/eintr_wrapper.h" +@@ -32,7 +37,7 @@ bool DebugUtil::SpawnDebuggerOnProcess(u + return false; + } + +-#if defined(OS_MACOSX) ++#if defined(OS_MACOSX) || defined(OS_BSD) + + // Based on Apple's recommended method as described in + // http://developer.apple.com/qa/qa2004/qa1361.html +@@ -71,7 +76,13 @@ bool DebugUtil::BeingDebugged() { + + // This process is being debugged if the P_TRACED flag is set. + is_set = true; ++#if defined(OS_DRAGONFLY) ++ being_debugged = (info.kp_flags & P_TRACED) != 0; ++#elif defined(OS_FREEBSD) ++ being_debugged = (info.ki_flag & P_TRACED) != 0; ++#else + being_debugged = (info.kp_proc.p_flag & P_TRACED) != 0; ++#endif + return being_debugged; + } + +diff --git ipc/chromium/src/base/dir_reader_bsd.h ipc/chromium/src/base/dir_reader_bsd.h +new file mode 100644 +index 0000000..3fc1a87 +--- /dev/null ++++ mozilla/ipc/chromium/src/base/dir_reader_bsd.h +@@ -0,0 +1,98 @@ ++// Copyright (c) 2010 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. ++ ++// derived from dir_reader_linux.h ++ ++#ifndef BASE_DIR_READER_BSD_H_ ++#define BASE_DIR_READER_BSD_H_ ++#pragma once ++ ++#include <dirent.h> ++#include <errno.h> ++#include <fcntl.h> ++#include <stdint.h> ++#include <unistd.h> ++ ++#include "base/logging.h" ++#include "base/eintr_wrapper.h" ++ ++// See the comments in dir_reader_posix.h about this. ++ ++namespace base { ++ ++class DirReaderBSD { ++ public: ++ explicit DirReaderBSD(const char* directory_path) ++#ifdef O_DIRECTORY ++ : fd_(open(directory_path, O_RDONLY | O_DIRECTORY)), ++#else ++ : fd_(open(directory_path, O_RDONLY)), ++#endif ++ offset_(0), ++ size_(0) { ++ memset(buf_, 0, sizeof(buf_)); ++ } ++ ++ ~DirReaderBSD() { ++ if (fd_ >= 0) { ++ if (HANDLE_EINTR(close(fd_))) ++ DLOG(ERROR) << "Failed to close directory handle"; ++ } ++ } ++ ++ bool IsValid() const { ++ return fd_ >= 0; ++ } ++ ++ // Move to the next entry returning false if the iteration is complete. ++ bool Next() { ++ if (size_) { ++ struct dirent* dirent = reinterpret_cast<struct dirent*>(&buf_[offset_]); ++ offset_ += dirent->d_reclen; ++ } ++ ++ if (offset_ != size_) ++ return true; ++ ++ const int r = getdirentries(fd_, buf_, sizeof(buf_), basep_); ++ if (r == 0) ++ return false; ++ if (r == -1) { ++ DLOG(ERROR) << "getdirentries returned an error: " << errno; ++ return false; ++ } ++ size_ = r; ++ offset_ = 0; ++ return true; ++ } ++ ++ const char* name() const { ++ if (!size_) ++ return NULL; ++ ++ const struct dirent* dirent = ++ reinterpret_cast<const struct dirent*>(&buf_[offset_]); ++ return dirent->d_name; ++ } ++ ++ int fd() const { ++ return fd_; ++ } ++ ++ static bool IsFallback() { ++ return false; ++ } ++ ++ private: ++ const int fd_; ++ char buf_[512]; ++ long *basep_; ++ size_t offset_, size_; ++ ++ DISALLOW_COPY_AND_ASSIGN(DirReaderBSD); ++}; ++ ++} // namespace base ++ ++#endif // BASE_DIR_READER_BSD_H_ +diff --git ipc/chromium/src/base/dir_reader_posix.h ipc/chromium/src/base/dir_reader_posix.h +index 9a34492..62b280c 100644 +--- mozilla/ipc/chromium/src/base/dir_reader_posix.h ++++ mozilla/ipc/chromium/src/base/dir_reader_posix.h +@@ -18,6 +18,8 @@ + + #if defined(OS_LINUX) + #include "base/dir_reader_linux.h" ++#elif defined(OS_BSD) ++#include "base/dir_reader_bsd.h" + #else + #include "base/dir_reader_fallback.h" + #endif +@@ -26,6 +28,8 @@ + + #if defined(OS_LINUX) + typedef DirReaderLinux DirReaderPosix; ++#elif defined(OS_BSD) ++typedef DirReaderBSD DirReaderPosix; + #else + typedef DirReaderFallback DirReaderPosix; + #endif +$NetBSD: patch-ipc_chromium_src_base_file__util.h,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/file_util.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/file_util.h +@@ -16,8 +16,8 @@ + #include <sys/stat.h> + #elif defined(OS_POSIX) + #include <sys/types.h> +-#include <fts.h> + #include <sys/stat.h> ++#include <fts.h> + #endif + + #include <stdio.h> +$NetBSD: patch-ipc_chromium_src_base_file__util__bsd.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/file_util_bsd.cc.orig 2012-01-07 18:21:18.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/file_util_bsd.cc +@@ -0,0 +1,80 @@ ++// Copyright (c) 2006-2008 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. ++ ++// this is a derivative of file_util_linux.cc ++ ++#include "base/file_util.h" ++ ++#include <fcntl.h> ++#include <unistd.h> ++ ++#include <string> ++#include <vector> ++ ++#include "base/eintr_wrapper.h" ++#include "base/file_path.h" ++#include "base/string_util.h" ++ ++namespace file_util { ++ ++bool GetTempDir(FilePath* path) { ++ const char* tmp = getenv("TMPDIR"); ++ if (tmp) ++ *path = FilePath(tmp); ++ else ++ *path = FilePath("/tmp"); ++ return true; ++} ++ ++bool GetShmemTempDir(FilePath* path) { ++ return GetTempDir(path); ++} ++ ++bool CopyFile(const FilePath& from_path, const FilePath& to_path) { ++ int infile = open(from_path.value().c_str(), O_RDONLY); ++ if (infile < 0) ++ return false; ++ ++ int outfile = creat(to_path.value().c_str(), 0666); ++ if (outfile < 0) { ++ close(infile); ++ return false; ++ } ++ ++ const size_t kBufferSize = 32768; ++ std::vector<char> buffer(kBufferSize); ++ bool result = true; ++ ++ while (result) { ++ ssize_t bytes_read = HANDLE_EINTR(read(infile, &buffer[0], buffer.size())); ++ if (bytes_read < 0) { ++ result = false; ++ break; ++ } ++ if (bytes_read == 0) ++ break; ++ // Allow for partial writes ++ ssize_t bytes_written_per_read = 0; ++ do { ++ ssize_t bytes_written_partial = HANDLE_EINTR(write( ++ outfile, ++ &buffer[bytes_written_per_read], ++ bytes_read - bytes_written_per_read)); ++ if (bytes_written_partial < 0) { ++ result = false; ++ break; ++ } ++ bytes_written_per_read += bytes_written_partial; ++ } while (bytes_written_per_read < bytes_read); ++ } ++ ++ if (HANDLE_EINTR(close(infile)) < 0) ++ result = false; ++ if (HANDLE_EINTR(close(outfile)) < 0) ++ result = false; ++ ++ return result; ++} ++ ++} // namespace file_util +$NetBSD: patch-ipc_chromium_src_base_file__util__posix.cc,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/file_util_posix.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/file_util_posix.cc +@@ -31,7 +31,7 @@ + #include "base/time.h" + + // FreeBSD/OpenBSD lacks stat64, but its stat handles files >2GB just fine +-#if defined(OS_FREEBSD) || defined(OS_OPENBSD) ++#ifndef OS_LINUX + #define stat64 stat + #endif + +$NetBSD: patch-ipc_chromium_src_base_message__loop.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/message_loop.cc.orig 2012-02-16 07:40:33.000000000 +0100 ++++ mozilla/ipc/chromium/src/base/message_loop.cc 2012-02-21 21:24:41.000000000 +0100 +@@ -19,7 +19,7 @@ + #if defined(OS_POSIX) + #include "base/message_pump_libevent.h" + #endif +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + #ifdef MOZ_WIDGET_GTK2 + #include "base/message_pump_glib.h" + #endif +@@ -119,7 +119,7 @@ + if (type_ == TYPE_UI) { + #if defined(OS_MACOSX) + pump_ = base::MessagePumpMac::Create(); +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_BSD) + pump_ = new base::MessagePumpForUI(); + #endif // OS_LINUX + } else if (type_ == TYPE_IO) { +$NetBSD: patch-ipc_chromium_src_base_platform__file__posix.cc,v 1.1 2011/07/12 15:12:36 tnn Exp $ + +--- mozilla/ipc/chromium/src/base/platform_file_posix.cc.orig 2011-06-15 21:57:27.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/platform_file_posix.cc +@@ -9,6 +9,7 @@ + #ifdef ANDROID + #include <linux/stat.h> + #endif ++#include <sys/stat.h> /* for S_IRUSR */ + + #include "base/logging.h" + #include "base/string_util.h" +$NetBSD: patch-ipc_chromium_src_base_platform__thread.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/platform_thread.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/platform_thread.h +@@ -25,6 +25,8 @@ typedef pthread_t PlatformThreadHandle; + #if defined(OS_LINUX) + #include <unistd.h> + typedef pid_t PlatformThreadId; ++#elif defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined (OS_NETBSD) ++typedef lwpid_t PlatformThreadId; + #elif defined(OS_MACOSX) + #include <mach/mach.h> + typedef mach_port_t PlatformThreadId; +$NetBSD: patch-ipc_chromium_src_base_platform__thread__posix.cc,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/platform_thread_posix.cc.orig 2012-03-13 01:36:53.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/platform_thread_posix.cc +@@ -9,9 +9,18 @@ + + #if defined(OS_MACOSX) + #include <mach/mach.h> ++#elif defined(OS_NETBSD) ++#include <lwp.h> + #elif defined(OS_LINUX) + #include <sys/syscall.h> + #include <unistd.h> ++#elif defined(OS_DRAGONFLY) ++#include <unistd.h> ++#elif defined(OS_FREEBSD) ++_Pragma("GCC visibility push(default)") ++extern "C" int thr_self(long *); // XXX #include <sys/thr.h> ++_Pragma("GCC visibility pop") ++#include <pthread_np.h> + #endif + + #if defined(OS_MACOSX) +@@ -38,7 +45,19 @@ + // into the kernel. + #if defined(OS_MACOSX) + return mach_thread_self(); +-#elif defined (__OpenBSD__) ++#elif defined(OS_NETBSD) ++ return _lwp_self(); ++#elif defined(OS_DRAGONFLY) ++ return lwp_gettid(); ++#elif defined(OS_FREEBSD) ++# if __FreeBSD_version > 900030 ++ return pthread_getthreadid_np(); ++# else ++ long lwpid; ++ thr_self(&lwpid); ++ return lwpid; ++# endif ++#elif defined(OS_OPENBSD) + // TODO(BSD): find a better thread ID + return (intptr_t)(pthread_self()); + #elif defined(OS_LINUX) +$NetBSD: patch-ipc_chromium_src_base_process__util.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/process_util.h.orig 2011-12-21 00:28:19.000000000 +0100 ++++ mozilla/ipc/chromium/src/base/process_util.h 2012-01-31 13:14:54.000000000 +0100 +@@ -280,6 +280,7 @@ class NamedProcessIterator { + const ProcessEntry* NextProcessEntry(); + + private: ++#if !defined(OS_BSD) + // Determines whether there's another process (regardless of executable) + // left in the list of all processes. Returns true and sets entry_ to + // that process's info if there is one, false otherwise. +@@ -292,18 +292,24 @@ + void InitProcessEntry(ProcessEntry* entry); + + std::wstring executable_name_; ++#endif + + #if defined(OS_WIN) + HANDLE snapshot_; + bool started_iteration_; + #elif defined(OS_LINUX) + DIR *procfs_dir_; ++#elif defined(OS_BSD) ++ std::vector<ProcessEntry> content; ++ size_t nextEntry; + #elif defined(OS_MACOSX) + std::vector<kinfo_proc> kinfo_procs_; + size_t index_of_kinfo_proc_; + #endif ++#if !defined(OS_BSD) + ProcessEntry entry_; + const ProcessFilter* filter_; ++#endif + + DISALLOW_EVIL_CONSTRUCTORS(NamedProcessIterator); + }; +$NetBSD: patch-ipc_chromium_src_base_process__util__bsd.cc,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/process_util_bsd.cc.orig 2012-04-01 00:04:28.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/process_util_bsd.cc +@@ -0,0 +1,326 @@ ++// Copyright (c) 2008 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. ++ ++// derived from process_util_linux.cc and process_util_mac.cc ++ ++#include "base/process_util.h" ++ ++#include <ctype.h> ++#include <fcntl.h> ++#include <unistd.h> ++#include <string> ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++/* DragonFly, as of v3.0.1, and FreeBSD 9.0-RELEASE do not explicitly mark symbols public */ ++#define PRE_SYS_INCLUDE _Pragma("GCC visibility push(default)") ++#define POST_SYS_INCLUDE _Pragma("GCC visibility pop") ++#else ++#define PRE_SYS_INCLUDE ++#define POST_SYS_INCLUDE ++#endif ++PRE_SYS_INCLUDE ++#include <kvm.h> ++POST_SYS_INCLUDE ++#include <sys/sysctl.h> ++#include <sys/types.h> ++#include <sys/wait.h> ++#if defined(OS_DRAGONFLY) ++PRE_SYS_INCLUDE ++#include <sys/user.h> ++POST_SYS_INCLUDE ++#define HAVE_POSIX_SPAWN 1 ++#endif ++#if defined(OS_FREEBSD) ++PRE_SYS_INCLUDE ++#include <sys/user.h> ++POST_SYS_INCLUDE ++#endif ++ ++#include "base/debug_util.h" ++#include "base/eintr_wrapper.h" ++#include "base/file_util.h" ++#include "base/logging.h" ++#include "base/string_tokenizer.h" ++#include "base/string_util.h" ++ ++#if defined(OS_NETBSD) ++#include <sys/param.h> ++#if __NetBSD_Version__ >= 600000000 ++#define HAVE_POSIX_SPAWN 1 ++#endif ++#endif ++ ++#ifdef HAVE_POSIX_SPAWN ++PRE_SYS_INCLUDE ++#include <spawn.h> ++POST_SYS_INCLUDE ++extern "C" char **environ __dso_public; ++#endif ++ ++namespace { ++ ++enum ParsingState { ++ KEY_NAME, ++ KEY_VALUE ++}; ++ ++static mozilla::EnvironmentLog gProcessLog("MOZ_PROCESS_LOG"); ++ ++} // namespace ++ ++namespace base { ++ ++#ifdef HAVE_POSIX_SPAWN ++ ++void FreeEnvVarsArray(char* array[], int length) ++{ ++ for (int i = 0; i < length; i++) { ++ free(array[i]); ++ } ++ delete[] array; ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ bool wait, ProcessHandle* process_handle) { ++ return LaunchApp(argv, fds_to_remap, environment_map(), ++ wait, process_handle); ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ const environment_map& env_vars_to_set, ++ bool wait, ProcessHandle* process_handle, ++ ProcessArchitecture arch) { ++ bool retval = true; ++ ++ char* argv_copy[argv.size() + 1]; ++ for (size_t i = 0; i < argv.size(); i++) { ++ argv_copy[i] = const_cast<char*>(argv[i].c_str()); ++ } ++ argv_copy[argv.size()] = NULL; ++ ++ // Make sure we don't leak any FDs to the child process by marking all FDs ++ // as close-on-exec. ++ SetAllFDsToCloseOnExec(); ++ ++ // Copy environment to a new char array and add the variables ++ // in env_vars_to_set. ++ // Existing variables are overwritten by env_vars_to_set. ++ int pos = 0; ++ environment_map combined_env_vars = env_vars_to_set; ++ while(environ[pos] != NULL) { ++ std::string varString = environ[pos]; ++ std::string varName = varString.substr(0, varString.find_first_of('=')); ++ std::string varValue = varString.substr(varString.find_first_of('=') + 1); ++ if (combined_env_vars.find(varName) == combined_env_vars.end()) { ++ combined_env_vars[varName] = varValue; ++ } ++ pos++; ++ } ++ int varsLen = combined_env_vars.size() + 1; ++ ++ char** vars = new char*[varsLen]; ++ int i = 0; ++ for (environment_map::const_iterator it = combined_env_vars.begin(); ++ it != combined_env_vars.end(); ++it) { ++ std::string entry(it->first); ++ entry += "="; ++ entry += it->second; ++ vars[i] = strdup(entry.c_str()); ++ i++; ++ } ++ vars[i] = NULL; ++ ++ posix_spawn_file_actions_t file_actions; ++ if (posix_spawn_file_actions_init(&file_actions) != 0) { ++ FreeEnvVarsArray(vars, varsLen); ++ return false; ++ } ++ ++ // Turn fds_to_remap array into a set of dup2 calls. ++ for (file_handle_mapping_vector::const_iterator it = fds_to_remap.begin(); ++ it != fds_to_remap.end(); ++ ++it) { ++ int src_fd = it->first; ++ int dest_fd = it->second; ++ ++ if (src_fd == dest_fd) { ++ int flags = fcntl(src_fd, F_GETFD); ++ if (flags != -1) { ++ fcntl(src_fd, F_SETFD, flags & ~FD_CLOEXEC); ++ } ++ } else { ++ if (posix_spawn_file_actions_adddup2(&file_actions, src_fd, dest_fd) != 0) { ++ posix_spawn_file_actions_destroy(&file_actions); ++ FreeEnvVarsArray(vars, varsLen); ++ return false; ++ } ++ } ++ } ++ ++ pid_t pid = 0; ++ int spawn_succeeded = (posix_spawnp(&pid, ++ argv_copy[0], ++ &file_actions, ++ NULL, ++ argv_copy, ++ vars) == 0); ++ ++ FreeEnvVarsArray(vars, varsLen); ++ ++ posix_spawn_file_actions_destroy(&file_actions); ++ ++ bool process_handle_valid = pid > 0; ++ if (!spawn_succeeded || !process_handle_valid) { ++ retval = false; ++ } else { ++ if (wait) ++ HANDLE_EINTR(waitpid(pid, 0, 0)); ++ ++ if (process_handle) ++ *process_handle = pid; ++ } ++ ++ return retval; ++} ++ ++bool LaunchApp(const CommandLine& cl, ++ bool wait, bool start_hidden, ProcessHandle* process_handle) { ++ // TODO(playmobil): Do we need to respect the start_hidden flag? ++ file_handle_mapping_vector no_files; ++ return LaunchApp(cl.argv(), no_files, wait, process_handle); ++} ++ ++#else // no posix_spawn, use fork/exec ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ bool wait, ProcessHandle* process_handle) { ++ return LaunchApp(argv, fds_to_remap, environment_map(), ++ wait, process_handle); ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ const environment_map& env_vars_to_set, ++ bool wait, ProcessHandle* process_handle, ++ ProcessArchitecture arch) { ++ scoped_array<char*> argv_cstr(new char*[argv.size() + 1]); ++ // Illegal to allocate memory after fork and before execvp ++ InjectiveMultimap fd_shuffle1, fd_shuffle2; ++ fd_shuffle1.reserve(fds_to_remap.size()); ++ fd_shuffle2.reserve(fds_to_remap.size()); ++ ++ pid_t pid = fork(); ++ if (pid < 0) ++ return false; ++ ++ if (pid == 0) { ++ for (file_handle_mapping_vector::const_iterator ++ it = fds_to_remap.begin(); it != fds_to_remap.end(); ++it) { ++ fd_shuffle1.push_back(InjectionArc(it->first, it->second, false)); ++ fd_shuffle2.push_back(InjectionArc(it->first, it->second, false)); ++ } ++ ++ if (!ShuffleFileDescriptors(&fd_shuffle1)) ++ _exit(127); ++ ++ CloseSuperfluousFds(fd_shuffle2); ++ ++ for (environment_map::const_iterator it = env_vars_to_set.begin(); ++ it != env_vars_to_set.end(); ++it) { ++ if (setenv(it->first.c_str(), it->second.c_str(), 1/*overwrite*/)) ++ _exit(127); ++ } ++ ++ for (size_t i = 0; i < argv.size(); i++) ++ argv_cstr[i] = const_cast<char*>(argv[i].c_str()); ++ argv_cstr[argv.size()] = NULL; ++ execvp(argv_cstr[0], argv_cstr.get()); ++ // if we get here, we're in serious trouble and should complain loudly ++ DLOG(ERROR) << "FAILED TO exec() CHILD PROCESS, path: " << argv_cstr[0]; ++ exit(127); ++ } else { ++ gProcessLog.print("==> process %d launched child process %d\n", ++ GetCurrentProcId(), pid); ++ if (wait) ++ HANDLE_EINTR(waitpid(pid, 0, 0)); ++ ++ if (process_handle) ++ *process_handle = pid; ++ } ++ ++ return true; ++} ++ ++bool LaunchApp(const CommandLine& cl, ++ bool wait, bool start_hidden, ++ ProcessHandle* process_handle) { ++ file_handle_mapping_vector no_files; ++ return LaunchApp(cl.argv(), no_files, wait, process_handle); ++} ++ ++#endif ++ ++NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name, ++ const ProcessFilter* filter) ++{ ++ int numEntries; ++ kvm_t *kvm; ++ std::string exe(WideToASCII(executable_name)); ++ ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++ kvm = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL); ++ struct kinfo_proc* procs = kvm_getprocs(kvm, KERN_PROC_UID, getuid(), &numEntries); ++ if (procs != NULL && numEntries > 0) { ++ for (int i = 0; i < numEntries; i++) { ++# if defined(OS_DRAGONFLY) ++ if (exe != procs[i].kp_comm) continue; ++ if (filter && !filter->Includes(procs[i].kp_pid, procs[i].kp_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].kp_pid; ++ e.ppid = procs[i].kp_ppid; ++ strlcpy(e.szExeFile, procs[i].kp_comm, sizeof e.szExeFile); ++ content.push_back(e); ++# elif defined(OS_FREEBSD) ++ if (exe != procs[i].ki_comm) continue; ++ if (filter && !filter->Includes(procs[i].ki_pid, procs[i].ki_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].ki_pid; ++ e.ppid = procs[i].ki_ppid; ++ strlcpy(e.szExeFile, procs[i].ki_comm, sizeof e.szExeFile); ++ content.push_back(e); ++# endif ++#else ++ kvm = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL); ++ struct kinfo_proc2* procs = kvm_getproc2(kvm, KERN_PROC_UID, getuid(), sizeof(struct kinfo_proc2), &numEntries); ++ if (procs != NULL && numEntries > 0) { ++ for (int i = 0; i < numEntries; i++) { ++ if (exe != procs[i].p_comm) continue; ++ if (filter && !filter->Includes(procs[i].p_pid, procs[i].p_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].p_pid; ++ e.ppid = procs[i].p_ppid; ++ strlcpy(e.szExeFile, procs[i].p_comm, sizeof e.szExeFile); ++ content.push_back(e); ++#endif ++ } ++ } ++ nextEntry = 0; ++ kvm_close(kvm); ++} ++ ++NamedProcessIterator::~NamedProcessIterator() { ++} ++ ++const ProcessEntry* NamedProcessIterator::NextProcessEntry() { ++ if (nextEntry >= content.size()) return NULL; ++ return &content[nextEntry++]; ++} ++ ++bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { ++ return false; ++} ++ ++} // namespace base +$NetBSD: patch-ipc_chromium_src_base_process__util__posix.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/process_util_posix.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/process_util_posix.cc +@@ -116,6 +116,11 @@ void CloseSuperfluousFds(const base::Inj + #elif defined(OS_MACOSX) + static const rlim_t kSystemDefaultMaxFds = 256; + static const char kFDDir[] = "/dev/fd"; ++#elif defined(OS_BSD) ++ // the getrlimit below should never fail, so whatever .. ++ static const rlim_t kSystemDefaultMaxFds = 1024; ++ // at least /dev/fd will exist ++ static const char kFDDir[] = "/dev/fd"; + #endif + + // Get the maximum number of FDs possible. +@@ -199,7 +204,7 @@ void CloseSuperfluousFds(const base::Inj + void SetAllFDsToCloseOnExec() { + #if defined(OS_LINUX) + const char fd_dir[] = "/proc/self/fd"; +-#elif defined(OS_MACOSX) ++#elif defined(OS_MACOSX) || defined(OS_BSD) + const char fd_dir[] = "/dev/fd"; + #endif + ScopedDIR dir_closer(opendir(fd_dir)); +$NetBSD: patch-ipc_chromium_src_base_sys__info__posix.cc,v 1.2 2011/11/27 13:09:00 tnn Exp $ + +--- mozilla/ipc/chromium/src/base/sys_info_posix.cc.orig 2011-11-04 21:34:00.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/sys_info_posix.cc +@@ -18,6 +18,11 @@ + #include <mach/mach_init.h> + #endif + ++#if defined(OS_NETBSD) ++#include <sys/param.h> ++#include <sys/sysctl.h> ++#endif ++ + #include "base/logging.h" + #include "base/string_util.h" + +@@ -26,7 +31,11 @@ namespace base { + int SysInfo::NumberOfProcessors() { + // It seems that sysconf returns the number of "logical" processors on both + // mac and linux. So we get the number of "online logical" processors. ++#ifdef _SC_NPROCESSORS_ONLN + static long res = sysconf(_SC_NPROCESSORS_ONLN); ++#else ++ static long res = 1; ++#endif + if (res == -1) { + NOTREACHED(); + return 1; +@@ -52,6 +61,20 @@ int64 SysInfo::AmountOfPhysicalMemory() + } + + return static_cast<int64>(hostinfo.max_mem); ++#elif defined(OS_NETBSD) ++ int mib[2]; ++ int rc; ++ int64_t memSize; ++ size_t len = sizeof(memSize); ++ ++ mib[0] = CTL_HW; ++ mib[1] = HW_PHYSMEM64; ++ rc = sysctl( mib, 2, &memSize, &len, NULL, 0 ); ++ if (-1 != rc) { ++ return memSize; ++ } ++ return 0; ++ + #else + long pages = sysconf(_SC_PHYS_PAGES); + long page_size = sysconf(_SC_PAGE_SIZE); +$NetBSD: patch-ipc_chromium_src_base_third__party_nspr_prcpucfg.h,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/third_party/nspr/prcpucfg.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/third_party/nspr/prcpucfg.h +@@ -34,7 +34,7 @@ + #include "base/third_party/nspr/prcpucfg_win.h" + #elif defined(__APPLE__) + #include "base/third_party/nspr/prcpucfg_mac.h" +-#elif defined(__linux__) || defined(ANDROID) ++#elif defined(__linux__) || defined(ANDROID) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) + #include "base/third_party/nspr/prcpucfg_linux.h" + #elif defined(__OpenBSD__) + #include "base/third_party/nspr/prcpucfg_openbsd.h" +$NetBSD: patch-ipc_chromium_src_base_third__party_nspr_prtime.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/third_party/nspr/prtime.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/third_party/nspr/prtime.cc +@@ -212,7 +212,7 @@ PR_ImplodeTime(const PRExplodedTime *exp + LL_ADD(retVal, retVal, temp); + + return retVal; +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_DRAGONFLY) + struct tm exp_tm = {0}; + exp_tm.tm_sec = exploded->tm_sec; + exp_tm.tm_min = exploded->tm_min; +@@ -245,6 +245,24 @@ PR_ImplodeTime(const PRExplodedTime *exp + result *= kSecondsToMicroseconds; + result += exploded->tm_usec; + return result; ++#elif defined(OS_FREEBSD) || defined(OS_NETBSD) ++ struct tm exp_tm = {0}; ++ exp_tm.tm_sec = exploded->tm_sec; ++ exp_tm.tm_min = exploded->tm_min; ++ exp_tm.tm_hour = exploded->tm_hour; ++ exp_tm.tm_mday = exploded->tm_mday; ++ exp_tm.tm_mon = exploded->tm_month; ++ exp_tm.tm_year = exploded->tm_year - 1900; ++ ++ // time_t is 64bit ++ time_t absolute_time = timegm(&exp_tm); ++ ++ PRTime result = static_cast<PRTime>(absolute_time); ++ result -= exploded->tm_params.tp_gmt_offset + ++ exploded->tm_params.tp_dst_offset; ++ result *= kSecondsToMicroseconds; ++ result += exploded->tm_usec; ++ return result; + #else + #error No PR_ImplodeTime implemented on your platform. + #endif +diff --git ipc/chromium/src/base/time_posix.cc ipc/chromium/src/base/time_posix.cc +index abf2a56..48791f6 100644 +--- mozilla/ipc/chromium/src/base/time_posix.cc ++++ mozilla/ipc/chromium/src/base/time_posix.cc +@@ -167,7 +167,7 @@ TimeTicks TimeTicks::Now() { + // With numer and denom = 1 (the expected case), the 64-bit absolute time + // reported in nanoseconds is enough to last nearly 585 years. + +-#elif defined(__OpenBSD__) || defined(OS_POSIX) && \ ++#elif defined(OS_OPENBSD) || defined(OS_POSIX) && \ + defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 + + struct timespec ts; +$NetBSD: patch-ipc_chromium_src_build_build__config.h,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- mozilla/ipc/chromium/src/build/build_config.h.orig 2012-03-13 01:36:53.000000000 +0000 ++++ mozilla/ipc/chromium/src/build/build_config.h +@@ -19,17 +19,23 @@ + #define OS_MACOSX 1 + #elif defined(__linux__) || defined(ANDROID) + #define OS_LINUX 1 ++#elif defined(__NetBSD__) ++#define OS_NETBSD 1 ++#elif defined(__DragonFly__) ++#define OS_DRAGONFLY 1 + #elif defined(__OpenBSD__) + #define OS_OPENBSD 1 + #elif defined(_WIN32) + #define OS_WIN 1 ++#elif defined(__FreeBSD__) ++#define OS_FREEBSD 1 + #else + #error Please add support for your platform in build/build_config.h + #endif + + // For access to standard POSIX features, use OS_POSIX instead of a more + // specific macro. +-#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_OPENBSD) ++#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_BSD) + #define OS_POSIX 1 + #endif + +diff --git ipc/chromium/src/chrome/common/ipc_channel_posix.cc ipc/chromium/src/chrome/common/ipc_channel_posix.cc +index bd866ee..2ea5b19 100644 +--- mozilla/ipc/chromium/src/chrome/common/ipc_channel_posix.cc ++++ mozilla/ipc/chromium/src/chrome/common/ipc_channel_posix.cc +@@ -7,6 +7,7 @@ + #include <errno.h> + #include <fcntl.h> + #include <stddef.h> ++#include <unistd.h> + #include <sys/types.h> + #include <sys/socket.h> + #include <sys/stat.h> +$NetBSD: patch-ipc_chromium_src_chrome_common_ipc__channel__posix.h,v 1.1 2011/07/11 12:46:14 tnn Exp $ + +--- mozilla/ipc/chromium/src/chrome/common/ipc_channel_posix.h.orig 2011-06-15 21:57:27.000000000 +0000 ++++ mozilla/ipc/chromium/src/chrome/common/ipc_channel_posix.h +@@ -92,7 +92,7 @@ class Channel::ChannelImpl : public Mess + }; + + // This is a control message buffer large enough to hold kMaxReadFDs +-#if defined(OS_MACOSX) ++#if defined(OS_MACOSX) || defined(OS_NETBSD) + // TODO(agl): OSX appears to have non-constant CMSG macros! + char input_cmsg_buf_[1024]; + #else +$NetBSD: patch-ipc_chromium_src_chrome_common_ipc__message__utils.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/chrome/common/ipc_message_utils.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/chrome/common/ipc_message_utils.h +@@ -195,7 +195,7 @@ + }; + #endif + +-#if !(defined(OS_MACOSX) || defined(OS_OPENBSD) || defined(OS_WIN) || (defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)) || defined(ARCH_CPU_S390)) ++#if !(defined(OS_MACOSX) || defined(OS_OPENBSD) || defined(OS_WIN) || ((defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined(OS_NETBSD) || defined(OS_LINUX)) && defined(ARCH_CPU_64_BITS)) || defined(ARCH_CPU_S390)) + // There size_t is a synonym for |unsigned long| ... + template <> + struct ParamTraits<size_t> { +@@ -248,7 +248,7 @@ + }; + #endif // defined(OS_MACOSX) + +-#if !(defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)) ++#if !((defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined(OS_NETBSD) || defined(OS_LINUX)) && defined(ARCH_CPU_64_BITS)) + // int64 is |long int| on 64-bit systems, uint64 is |unsigned long| + template <> + struct ParamTraits<int64> { +$NetBSD: patch-ipc_chromium_src_chrome_common_transport__dib.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/chrome/common/transport_dib.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/chrome/common/transport_dib.h +@@ -7,7 +7,7 @@ + + #include "base/basictypes.h" + +-#if defined(OS_WIN) || defined(OS_MACOSX) ++#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + #include "base/shared_memory.h" + #endif + +@@ -66,7 +66,7 @@ class TransportDIB { + uint32 sequence_num; + }; + typedef HandleAndSequenceNum Id; +-#elif defined(OS_MACOSX) ++#elif defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + typedef base::SharedMemoryHandle Handle; + // On Mac, the inode number of the backing file is used as an id. + typedef base::SharedMemoryId Id; +@@ -108,7 +108,7 @@ class TransportDIB { + + private: + TransportDIB(); +-#if defined(OS_WIN) || defined(OS_MACOSX) ++#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + explicit TransportDIB(base::SharedMemoryHandle dib); + base::SharedMemory shared_memory_; + uint32 sequence_num_; +$NetBSD: patch-ipc_glue_GeckoChildProcessHost.cpp,v 1.2 2012/03/15 08:30:06 ryoon Exp $ + +--- mozilla/ipc/glue/GeckoChildProcessHost.cpp.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/glue/GeckoChildProcessHost.cpp +@@ -430,7 +430,7 @@ + // and passing wstrings from one config to the other is unsafe. So + // we split the logic here. + +-#if defined(OS_LINUX) || defined(OS_MACOSX) ++#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD) + base::environment_map newEnvVars; + // XPCOM may not be initialized in some subprocesses. We don't want + // to initialize XPCOM just for the directory service, especially +@@ -445,8 +445,8 @@ + if (NS_SUCCEEDED(rv)) { + nsCString path; + greDir->GetNativePath(path); +-# ifdef OS_LINUX +-# ifdef ANDROID ++# if defined(OS_LINUX) || defined(OS_BSD) ++# if defined(ANDROID) || defined(OS_BSD) + path += "/lib"; + # endif // ANDROID + const char *ld_library_path = PR_GetEnv("LD_LIBRARY_PATH"); +@@ -557,7 +557,7 @@ + childArgv.push_back(pidstring); + + #if defined(MOZ_CRASHREPORTER) +-# if defined(OS_LINUX) ++# if defined(OS_LINUX) || defined(OS_BSD) + int childCrashFd, childCrashRemapFd; + if (!CrashReporter::CreateNotificationPipeForChild( + &childCrashFd, &childCrashRemapFd)) +@@ -594,7 +594,7 @@ + #endif + + base::LaunchApp(childArgv, mFileMap, +-#if defined(OS_LINUX) || defined(OS_MACOSX) ++#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD) + newEnvVars, + #endif + false, &process, arch); +$NetBSD: patch-mm,v 1.13 2012/06/05 18:09:21 ryoon Exp $ + +--- mozilla/toolkit/library/Makefile.in.orig 2012-05-23 18:57:09.000000000 +0000 ++++ mozilla/toolkit/library/Makefile.in +@@ -534,6 +538,10 @@ EXTRA_DSO_LDOPTS += -lelf -ldemangle + endif + endif + ++ifneq (,$(filter DragonFly FreeBSD NetBSD,$(OS_ARCH))) ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++endif ++ + ifeq ($(OS_ARCH),WINNT) + OS_LIBS += $(call EXPAND_LIBNAME,shell32 ole32 version winspool comdlg32 imm32 msimg32 shlwapi psapi ws2_32 dbghelp rasapi32 rasdlg iphlpapi uxtheme setupapi secur32 sensorsapi portabledeviceguids windowscodecs wininet) + ifdef ACCESSIBILITY Modified: branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-base-file_util_linux.cc ============================================================================== --- branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-base-file_util_linux.cc Mon Jul 23 13:52:35 2012 (r886) +++ branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-base-file_util_linux.cc Mon Jul 23 22:39:41 2012 (r887) @@ -6,14 +6,3 @@ #include <fcntl.h> +#include <unistd.h> - #include <string> - #include <vector> -@@ -28,7 +29,7 @@ bool GetShmemTempDir(FilePath* path) { - #ifdef ANDROID - return GetTempDir(path); - #else -- *path = FilePath("/dev/shm"); -+ *path = FilePath("/tmp"); - return true; - #endif - } Deleted: branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-base-file_util_posix.cc ============================================================================== --- branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-base-file_util_posix.cc Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- mozilla/ipc/chromium/src/base/file_util_posix.cc~ -+++ mozilla/ipc/chromium/src/base/file_util_posix.cc -@@ -31,7 +31,7 @@ - #include "base/time.h" - - // FreeBSD/OpenBSD lacks stat64, but its stat handles files >2GB just fine --#if defined(OS_FREEBSD) || defined(OS_OPENBSD) -+#if defined(__FreeBSD__) || defined(OS_OPENBSD) - #define stat64 stat - #endif - Deleted: branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-base-platform_thread_posix.cc ============================================================================== --- branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-base-platform_thread_posix.cc Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,12 +0,0 @@ ---- mozilla/ipc/chromium/src/base/platform_thread_posix.cc.orig 2011-04-27 09:34:28.000000000 +0200 -+++ mozilla/ipc/chromium/src/base/platform_thread_posix.cc 2011-04-27 19:47:36.344446266 +0200 -@@ -34,7 +33,8 @@ - #if defined(OS_MACOSX) - return mach_thread_self(); - #elif defined(OS_LINUX) -- return syscall(__NR_gettid); -+ // TODO(BSD): find a better thread ID -+ return reinterpret_cast<int64>(pthread_self()); - #endif - } - Deleted: branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h ============================================================================== --- branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- mozilla/ipc/chromium/src/base/third_party/nspr/prcpucfg.h~ -+++ mozilla/ipc/chromium/src/base/third_party/nspr/prcpucfg.h -@@ -34,7 +34,7 @@ - #include "base/third_party/nspr/prcpucfg_win.h" - #elif defined(__APPLE__) - #include "base/third_party/nspr/prcpucfg_mac.h" --#elif defined(__linux__) || defined(ANDROID) -+#elif defined(__FreeBSD__) || defined(ANDROID) - #include "base/third_party/nspr/prcpucfg_linux.h" - #else - #error Provide a prcpucfg.h appropriate for your platform Deleted: branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-build-build_config.h ============================================================================== --- branches/experimental/mail/thunderbird-esr/files/patch-ipc-chromium-src-build-build_config.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- mozilla/ipc/chromium/src/build/build_config.h~ -+++ mozilla/ipc/chromium/src/build/build_config.h -@@ -17,7 +17,7 @@ - // A set of macros to use for platform detection. - #if defined(__APPLE__) - #define OS_MACOSX 1 --#elif defined(__linux__) || defined(ANDROID) -+#elif defined(__linux__) || defined(ANDROID) || defined(__FreeBSD__) - #define OS_LINUX 1 - #elif defined(__OpenBSD__) - #define OS_OPENBSD 1 Deleted: branches/experimental/mail/thunderbird-esr/files/patch-mozilla-ipc-chromium-src-base-dir_reader_linux.h ============================================================================== --- branches/experimental/mail/thunderbird-esr/files/patch-mozilla-ipc-chromium-src-base-dir_reader_linux.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,52 +0,0 @@ ---- mozilla/ipc/chromium/src/base/dir_reader_linux.h~ -+++ mozilla/ipc/chromium/src/base/dir_reader_linux.h -@@ -12,6 +12,10 @@ - #include <sys/syscall.h> - #include <unistd.h> - -+#if defined(__FreeBSD__) -+#include <sys/dirent.h> -+#endif -+ - #include "base/logging.h" - #include "base/eintr_wrapper.h" - -@@ -19,6 +23,9 @@ - - namespace base { - -+#if defined(__FreeBSD__) -+#define linux_dirent struct dirent -+#else - struct linux_dirent { - uint64_t d_ino; - int64_t d_off; -@@ -26,11 +33,16 @@ struct linux_dirent { - unsigned char d_type; - char d_name[0]; - }; -+#endif - - class DirReaderLinux { - public: - explicit DirReaderLinux(const char* directory_path) -+#ifdef O_DIRECTORY - : fd_(open(directory_path, O_RDONLY | O_DIRECTORY)), -+#else -+ : fd_(open(directory_path, O_RDONLY)), -+#endif - offset_(0), - size_(0) { - memset(buf_, 0, sizeof(buf_)); -@@ -57,7 +69,11 @@ class DirReaderLinux { - if (offset_ != size_) - return true; - -+#if !defined(__FreeBSD__) - const int r = syscall(__NR_getdents64, fd_, buf_, sizeof(buf_)); -+#else -+ const int r = syscall(SYS_getdents, fd_, buf_, sizeof(buf_)); -+#endif - if (r == 0) - return false; - if (r == -1) { Deleted: branches/experimental/mail/thunderbird-esr/files/patch-mozilla-toolkit-library-Makefile.in ============================================================================== --- branches/experimental/mail/thunderbird-esr/files/patch-mozilla-toolkit-library-Makefile.in Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,12 +0,0 @@ ---- mozilla/toolkit/library/Makefile.in.orig 2010-01-11 12:13:08.000000000 -0500 -+++ mozilla/toolkit/library/Makefile.in 2010-01-11 12:15:05.000000000 -0500 -@@ -181,7 +181,7 @@ - export:: $(RDF_UTIL_SRC_CPPSRCS) $(INTL_UNICHARUTIL_UTIL_CPPSRCS) - $(INSTALL) $^ . - --EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(EXTRA_DSO_LIBS) -+EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(EXTRA_DSO_LIBS) -lexecinfo - - ifdef MOZ_ENABLE_LIBXUL - include $(srcdir)/libxul-rules.mk - Modified: branches/experimental/mail/thunderbird/Makefile ============================================================================== --- branches/experimental/mail/thunderbird/Makefile Mon Jul 23 13:52:35 2012 (r886) +++ branches/experimental/mail/thunderbird/Makefile Mon Jul 23 22:39:41 2012 (r887) @@ -20,7 +20,6 @@ sqlite3>=3.7.11:${PORTSDIR}/databases/sqlite3 \ cairo>=1.10.2_1,1:${PORTSDIR}/graphics/cairo \ unzip:${PORTSDIR}/archivers/unzip -LIB_DEPENDS= execinfo.1:${PORTSDIR}/devel/libexecinfo CONFLICTS_BUILD= spidermonkey-* @@ -98,9 +97,6 @@ <${FILESDIR}/thunderbird.desktop.in >${WRKDIR}/${MOZILLA_EXEC_NAME}.desktop post-patch: - @${GREP} -Flr \"/proc ${MOZSRC}/ipc/chromium/src/base | ${XARGS} ${REINPLACE_CMD} \ - -e 's|/proc/self/fd|/dev/fd|' \ - -e 's|/proc["/]|/compat/linux&|' @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \ ${WRKSRC}/mail/app/nsMailApp.cpp Added: branches/experimental/mail/thunderbird/files/patch-bug753046 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/experimental/mail/thunderbird/files/patch-bug753046 Mon Jul 23 22:39:41 2012 (r887) @@ -0,0 +1,1261 @@ +# Bug 753046 - Add support for DragonFly/NetBSD + +$NetBSD: patch-dom_plugins_ipc_PluginModuleChild.cpp,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/dom/plugins/ipc/PluginModuleChild.cpp.orig 2011-12-20 23:28:14.000000000 +0000 ++++ mozilla/dom/plugins/ipc/PluginModuleChild.cpp +@@ -33,6 +33,8 @@ + #include "nsPluginsDir.h" + #include "nsXULAppAPI.h" + ++#include <unistd.h> ++ + #ifdef MOZ_X11 + # include "mozilla/X11Util.h" + #endif +@@ -228,7 +228,7 @@ PluginModuleChild::Init(const std::strin + + // TODO: use PluginPRLibrary here + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + mShutdownFunc = + (NP_PLUGINSHUTDOWN) PR_FindFunctionSymbol(mLibrary, "NP_Shutdown"); + +@@ -1790,7 +1790,7 @@ PluginModuleChild::AnswerNP_GetEntryPoin + PLUGIN_LOG_DEBUG_METHOD; + AssertPluginThread(); + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + return true; + #elif defined(OS_WIN) || defined(OS_MACOSX) + *_retval = mGetEntryPointsFunc(&mFunctions); +@@ -1823,7 +1823,7 @@ PluginModuleChild::AnswerNP_Initialize(N + SendBackUpXResources(FileDescriptor(xSocketFd, false/*don't close*/)); + #endif + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + *_retval = mInitializeFunc(&sBrowserFuncs, &mFunctions); + return true; + #elif defined(OS_WIN) || defined(OS_MACOSX) +$NetBSD: patch-dom_plugins_ipc_PluginModuleChild.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/dom/plugins/ipc/PluginModuleChild.h.orig 2011-12-20 23:28:14.000000000 +0000 ++++ mozilla/dom/plugins/ipc/PluginModuleChild.h +@@ -340,7 +340,7 @@ private: + + // we get this from the plugin + NP_PLUGINSHUTDOWN mShutdownFunc; +-#ifdef OS_LINUX ++#if defined(OS_LINUX) || defined(OS_BSD) + NP_PLUGINUNIXINIT mInitializeFunc; + #elif defined(OS_WIN) || defined(OS_MACOSX) + NP_PLUGININIT mInitializeFunc; +$NetBSD: patch-ipc_chromium_Makefile.in,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/Makefile.in.orig 2012-02-16 06:40:33.000000000 +0000 ++++ mozilla/ipc/chromium/Makefile.in +@@ -278,6 +278,34 @@ endif + + endif # } OS_LINUX + ++ifdef OS_BSD # { ++ ++CPPSRCS += \ ++ atomicops_internals_x86_gcc.cc \ ++ file_util_bsd.cc \ ++ process_util_bsd.cc \ ++ time_posix.cc \ ++ $(NULL) ++ ++ifdef MOZ_ENABLE_GTK2 ++CPPSRCS += \ ++ message_pump_glib.cc \ ++ $(NULL) ++endif ++ ++ifdef MOZ_ENABLE_QT ++MOCSRCS = \ ++ moc_message_pump_qt.cc \ ++ $(NULL) ++ ++CPPSRCS += \ ++ $(MOCSRCS) \ ++ message_pump_qt.cc \ ++ $(NULL) ++endif ++ ++endif # } OS_BSD ++ + # libevent + + ifndef MOZ_NATIVE_LIBEVENT # { +$NetBSD: patch-ipc_chromium_chromium-config.mk,v 1.2 2012/03/15 08:30:06 ryoon Exp $ + +--- mozilla/ipc/chromium/chromium-config.mk.orig 2012-02-16 07:40:33.000000000 +0100 ++++ mozilla/ipc/chromium/chromium-config.mk 2012-03-11 11:05:40.397182000 +0100 +@@ -56,17 +56,6 @@ + -I$(DEPTH)/ipc/ipdl/_ipdlheaders \ + $(NULL) + +-ifeq ($(OS_ARCH),Darwin) # { +- +-OS_MACOSX = 1 +-OS_POSIX = 1 +- +-DEFINES += \ +- -DOS_MACOSX=1 \ +- -DOS_POSIX=1 \ +- $(NULL) +- +-else # } { + ifeq ($(OS_ARCH),WINNT) # { + OS_LIBS += $(call EXPAND_LIBNAME,psapi shell32 dbghelp) + +@@ -93,13 +82,64 @@ + endif + + else # } { +- +-OS_LINUX = 1 + OS_POSIX = 1 ++DEFINES += -DOS_POSIX=1 ++ ++ifeq ($(OS_ARCH),Darwin) # { ++ ++OS_MACOSX = 1 ++DEFINES += \ ++ -DOS_MACOSX=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),DragonFly) # { ++ ++OS_DRAGONFLY = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_DRAGONFLY=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),FreeBSD) # { ++ ++OS_FREEBSD = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_FREEBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) + ++else # } { ++ifeq ($(OS_ARCH),NetBSD) # { ++ ++OS_NETBSD = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_NETBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),OpenBSD) # { ++ ++OS_OPENBSD = 1 ++OS_BSD = 1 ++DEFINES += \ ++ -DOS_OPENBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ ++OS_LINUX = 1 + DEFINES += \ + -DOS_LINUX=1 \ +- -DOS_POSIX=1 \ + $(NULL) + + # NB: to stop gcc warnings about exporting template instantiation +@@ -107,4 +147,8 @@ + + endif # } + endif # } ++endif # } ++endif # } ++endif # } ++endif # } + +$NetBSD: patch-ipc_chromium_src_base_base__paths.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/base_paths.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/base_paths.h +@@ -13,7 +13,7 @@ + #include "base/base_paths_win.h" + #elif defined(OS_MACOSX) + #include "base/base_paths_mac.h" +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_BSD) + #include "base/base_paths_linux.h" + #endif + #include "base/path_service.h" +$NetBSD: patch-ipc_chromium_src_base_debug__util__posic.cc,v 1.3 2012/04/01 15:18:45 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/debug_util_posix.cc.orig 2012-03-13 01:36:53.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/debug_util_posix.cc +@@ -5,7 +5,7 @@ + #include "build/build_config.h" + #include "base/debug_util.h" + +-#define MOZ_HAVE_EXECINFO_H (!defined(ANDROID) && !defined(__OpenBSD__)) ++#define MOZ_HAVE_EXECINFO_H (defined(OS_LINUX) && !defined(ANDROID)) + + #include <errno.h> + #include <fcntl.h> +@@ -17,8 +17,13 @@ + #include <unistd.h> + #if MOZ_HAVE_EXECINFO_H + #include <execinfo.h> +-#include <sys/sysctl.h> + #endif ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++#include <sys/user.h> ++#elif defined(OS_FREEBSD) ++#include <sys/proc.h> ++#endif ++#include <sys/sysctl.h> + + #include "base/basictypes.h" + #include "base/eintr_wrapper.h" +@@ -32,7 +37,7 @@ bool DebugUtil::SpawnDebuggerOnProcess(u + return false; + } + +-#if defined(OS_MACOSX) ++#if defined(OS_MACOSX) || defined(OS_BSD) + + // Based on Apple's recommended method as described in + // http://developer.apple.com/qa/qa2004/qa1361.html +@@ -71,7 +76,13 @@ bool DebugUtil::BeingDebugged() { + + // This process is being debugged if the P_TRACED flag is set. + is_set = true; ++#if defined(OS_DRAGONFLY) ++ being_debugged = (info.kp_flags & P_TRACED) != 0; ++#elif defined(OS_FREEBSD) ++ being_debugged = (info.ki_flag & P_TRACED) != 0; ++#else + being_debugged = (info.kp_proc.p_flag & P_TRACED) != 0; ++#endif + return being_debugged; + } + +diff --git ipc/chromium/src/base/dir_reader_bsd.h ipc/chromium/src/base/dir_reader_bsd.h +new file mode 100644 +index 0000000..3fc1a87 +--- /dev/null ++++ mozilla/ipc/chromium/src/base/dir_reader_bsd.h +@@ -0,0 +1,98 @@ ++// Copyright (c) 2010 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. ++ ++// derived from dir_reader_linux.h ++ ++#ifndef BASE_DIR_READER_BSD_H_ ++#define BASE_DIR_READER_BSD_H_ ++#pragma once ++ ++#include <dirent.h> ++#include <errno.h> ++#include <fcntl.h> ++#include <stdint.h> ++#include <unistd.h> ++ ++#include "base/logging.h" ++#include "base/eintr_wrapper.h" ++ ++// See the comments in dir_reader_posix.h about this. ++ ++namespace base { ++ ++class DirReaderBSD { ++ public: ++ explicit DirReaderBSD(const char* directory_path) ++#ifdef O_DIRECTORY ++ : fd_(open(directory_path, O_RDONLY | O_DIRECTORY)), ++#else ++ : fd_(open(directory_path, O_RDONLY)), ++#endif ++ offset_(0), ++ size_(0) { ++ memset(buf_, 0, sizeof(buf_)); ++ } ++ ++ ~DirReaderBSD() { ++ if (fd_ >= 0) { ++ if (HANDLE_EINTR(close(fd_))) ++ DLOG(ERROR) << "Failed to close directory handle"; ++ } ++ } ++ ++ bool IsValid() const { ++ return fd_ >= 0; ++ } ++ ++ // Move to the next entry returning false if the iteration is complete. ++ bool Next() { ++ if (size_) { ++ struct dirent* dirent = reinterpret_cast<struct dirent*>(&buf_[offset_]); ++ offset_ += dirent->d_reclen; ++ } ++ ++ if (offset_ != size_) ++ return true; ++ ++ const int r = getdirentries(fd_, buf_, sizeof(buf_), basep_); ++ if (r == 0) ++ return false; ++ if (r == -1) { ++ DLOG(ERROR) << "getdirentries returned an error: " << errno; ++ return false; ++ } ++ size_ = r; ++ offset_ = 0; ++ return true; ++ } ++ ++ const char* name() const { ++ if (!size_) ++ return NULL; ++ ++ const struct dirent* dirent = ++ reinterpret_cast<const struct dirent*>(&buf_[offset_]); ++ return dirent->d_name; ++ } ++ ++ int fd() const { ++ return fd_; ++ } ++ ++ static bool IsFallback() { ++ return false; ++ } ++ ++ private: ++ const int fd_; ++ char buf_[512]; ++ long *basep_; ++ size_t offset_, size_; ++ ++ DISALLOW_COPY_AND_ASSIGN(DirReaderBSD); ++}; ++ ++} // namespace base ++ ++#endif // BASE_DIR_READER_BSD_H_ +diff --git ipc/chromium/src/base/dir_reader_posix.h ipc/chromium/src/base/dir_reader_posix.h +index 9a34492..62b280c 100644 +--- mozilla/ipc/chromium/src/base/dir_reader_posix.h ++++ mozilla/ipc/chromium/src/base/dir_reader_posix.h +@@ -18,16 +18,20 @@ + // seems worse than falling back to enumerating all file descriptors so we will + // probably never implement this on the Mac. + +-#if defined(OS_LINUX) && !defined(OS_OPENBSD) ++#if defined(OS_LINUX) + #include "base/dir_reader_linux.h" ++#elif defined(OS_BSD) ++#include "base/dir_reader_bsd.h" + #else + #include "base/dir_reader_fallback.h" + #endif + + namespace base { + +-#if defined(OS_LINUX) && !defined(OS_OPENBSD) ++#if defined(OS_LINUX) + typedef DirReaderLinux DirReaderPosix; ++#elif defined(OS_BSD) ++typedef DirReaderBSD DirReaderPosix; + #else + typedef DirReaderFallback DirReaderPosix; + #endif +$NetBSD: patch-ipc_chromium_src_base_file__util.h,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/file_util.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/file_util.h +@@ -16,8 +16,8 @@ + #include <sys/stat.h> + #elif defined(OS_POSIX) + #include <sys/types.h> +-#include <fts.h> + #include <sys/stat.h> ++#include <fts.h> + #endif + + #include <stdio.h> +$NetBSD: patch-ipc_chromium_src_base_file__util__bsd.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/file_util_bsd.cc.orig 2012-01-07 18:21:18.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/file_util_bsd.cc +@@ -0,0 +1,80 @@ ++// Copyright (c) 2006-2008 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. ++ ++// this is a derivative of file_util_linux.cc ++ ++#include "base/file_util.h" ++ ++#include <fcntl.h> ++#include <unistd.h> ++ ++#include <string> ++#include <vector> ++ ++#include "base/eintr_wrapper.h" ++#include "base/file_path.h" ++#include "base/string_util.h" ++ ++namespace file_util { ++ ++bool GetTempDir(FilePath* path) { ++ const char* tmp = getenv("TMPDIR"); ++ if (tmp) ++ *path = FilePath(tmp); ++ else ++ *path = FilePath("/tmp"); ++ return true; ++} ++ ++bool GetShmemTempDir(FilePath* path) { ++ return GetTempDir(path); ++} ++ ++bool CopyFile(const FilePath& from_path, const FilePath& to_path) { ++ int infile = open(from_path.value().c_str(), O_RDONLY); ++ if (infile < 0) ++ return false; ++ ++ int outfile = creat(to_path.value().c_str(), 0666); ++ if (outfile < 0) { ++ close(infile); ++ return false; ++ } ++ ++ const size_t kBufferSize = 32768; ++ std::vector<char> buffer(kBufferSize); ++ bool result = true; ++ ++ while (result) { ++ ssize_t bytes_read = HANDLE_EINTR(read(infile, &buffer[0], buffer.size())); ++ if (bytes_read < 0) { ++ result = false; ++ break; ++ } ++ if (bytes_read == 0) ++ break; ++ // Allow for partial writes ++ ssize_t bytes_written_per_read = 0; ++ do { ++ ssize_t bytes_written_partial = HANDLE_EINTR(write( ++ outfile, ++ &buffer[bytes_written_per_read], ++ bytes_read - bytes_written_per_read)); ++ if (bytes_written_partial < 0) { ++ result = false; ++ break; ++ } ++ bytes_written_per_read += bytes_written_partial; ++ } while (bytes_written_per_read < bytes_read); ++ } ++ ++ if (HANDLE_EINTR(close(infile)) < 0) ++ result = false; ++ if (HANDLE_EINTR(close(outfile)) < 0) ++ result = false; ++ ++ return result; ++} ++ ++} // namespace file_util +$NetBSD: patch-ipc_chromium_src_base_file__util__posix.cc,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/file_util_posix.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/file_util_posix.cc +@@ -31,7 +31,7 @@ + #include "base/time.h" + + // FreeBSD/OpenBSD lacks stat64, but its stat handles files >2GB just fine +-#if defined(OS_FREEBSD) || defined(OS_OPENBSD) ++#ifndef OS_LINUX + #define stat64 stat + #endif + +$NetBSD: patch-ipc_chromium_src_base_message__loop.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/message_loop.cc.orig 2012-02-16 07:40:33.000000000 +0100 ++++ mozilla/ipc/chromium/src/base/message_loop.cc 2012-02-21 21:24:41.000000000 +0100 +@@ -19,7 +19,7 @@ + #if defined(OS_POSIX) + #include "base/message_pump_libevent.h" + #endif +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + #ifdef MOZ_WIDGET_GTK2 + #include "base/message_pump_glib.h" + #endif +@@ -119,7 +119,7 @@ + if (type_ == TYPE_UI) { + #if defined(OS_MACOSX) + pump_ = base::MessagePumpMac::Create(); +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_BSD) + pump_ = new base::MessagePumpForUI(); + #endif // OS_LINUX + } else if (type_ == TYPE_IO) { +$NetBSD: patch-ipc_chromium_src_base_platform__file__posix.cc,v 1.1 2011/07/12 15:12:36 tnn Exp $ + +--- mozilla/ipc/chromium/src/base/platform_file_posix.cc.orig 2011-06-15 21:57:27.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/platform_file_posix.cc +@@ -9,6 +9,7 @@ + #ifdef ANDROID + #include <linux/stat.h> + #endif ++#include <sys/stat.h> /* for S_IRUSR */ + + #include "base/logging.h" + #include "base/string_util.h" +$NetBSD: patch-ipc_chromium_src_base_platform__thread.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/platform_thread.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/platform_thread.h +@@ -25,6 +25,8 @@ typedef pthread_t PlatformThreadHandle; + #if defined(OS_LINUX) + #include <unistd.h> + typedef pid_t PlatformThreadId; ++#elif defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined (OS_NETBSD) ++typedef lwpid_t PlatformThreadId; + #elif defined(OS_MACOSX) + #include <mach/mach.h> + typedef mach_port_t PlatformThreadId; +$NetBSD: patch-ipc_chromium_src_base_platform__thread__posix.cc,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/platform_thread_posix.cc.orig 2012-03-13 01:36:53.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/platform_thread_posix.cc +@@ -9,9 +9,18 @@ + + #if defined(OS_MACOSX) + #include <mach/mach.h> ++#elif defined(OS_NETBSD) ++#include <lwp.h> + #elif defined(OS_LINUX) + #include <sys/syscall.h> + #include <unistd.h> ++#elif defined(OS_DRAGONFLY) ++#include <unistd.h> ++#elif defined(OS_FREEBSD) ++_Pragma("GCC visibility push(default)") ++extern "C" int thr_self(long *); // XXX #include <sys/thr.h> ++_Pragma("GCC visibility pop") ++#include <pthread_np.h> + #endif + + #if defined(OS_MACOSX) +@@ -38,7 +45,19 @@ + // into the kernel. + #if defined(OS_MACOSX) + return mach_thread_self(); +-#elif defined (__OpenBSD__) ++#elif defined(OS_NETBSD) ++ return _lwp_self(); ++#elif defined(OS_DRAGONFLY) ++ return lwp_gettid(); ++#elif defined(OS_FREEBSD) ++# if __FreeBSD_version > 900030 ++ return pthread_getthreadid_np(); ++# else ++ long lwpid; ++ thr_self(&lwpid); ++ return lwpid; ++# endif ++#elif defined(OS_OPENBSD) + // TODO(BSD): find a better thread ID + return (intptr_t)(pthread_self()); + #elif defined(OS_LINUX) +$NetBSD: patch-ipc_chromium_src_base_process__util.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/process_util.h.orig 2011-12-21 00:28:19.000000000 +0100 ++++ mozilla/ipc/chromium/src/base/process_util.h 2012-01-31 13:14:54.000000000 +0100 +@@ -280,6 +280,7 @@ class NamedProcessIterator { + const ProcessEntry* NextProcessEntry(); + + private: ++#if !defined(OS_BSD) + // Determines whether there's another process (regardless of executable) + // left in the list of all processes. Returns true and sets entry_ to + // that process's info if there is one, false otherwise. +@@ -292,18 +292,24 @@ + void InitProcessEntry(ProcessEntry* entry); + + std::wstring executable_name_; ++#endif + + #if defined(OS_WIN) + HANDLE snapshot_; + bool started_iteration_; + #elif defined(OS_LINUX) + DIR *procfs_dir_; ++#elif defined(OS_BSD) ++ std::vector<ProcessEntry> content; ++ size_t nextEntry; + #elif defined(OS_MACOSX) + std::vector<kinfo_proc> kinfo_procs_; + size_t index_of_kinfo_proc_; + #endif ++#if !defined(OS_BSD) + ProcessEntry entry_; + const ProcessFilter* filter_; ++#endif + + DISALLOW_EVIL_CONSTRUCTORS(NamedProcessIterator); + }; +$NetBSD: patch-ipc_chromium_src_base_process__util__bsd.cc,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/process_util_bsd.cc.orig 2012-04-01 00:04:28.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/process_util_bsd.cc +@@ -0,0 +1,326 @@ ++// Copyright (c) 2008 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. ++ ++// derived from process_util_linux.cc and process_util_mac.cc ++ ++#include "base/process_util.h" ++ ++#include <ctype.h> ++#include <fcntl.h> ++#include <unistd.h> ++#include <string> ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++/* DragonFly, as of v3.0.1, and FreeBSD 9.0-RELEASE do not explicitly mark symbols public */ ++#define PRE_SYS_INCLUDE _Pragma("GCC visibility push(default)") ++#define POST_SYS_INCLUDE _Pragma("GCC visibility pop") ++#else ++#define PRE_SYS_INCLUDE ++#define POST_SYS_INCLUDE ++#endif ++PRE_SYS_INCLUDE ++#include <kvm.h> ++POST_SYS_INCLUDE ++#include <sys/sysctl.h> ++#include <sys/types.h> ++#include <sys/wait.h> ++#if defined(OS_DRAGONFLY) ++PRE_SYS_INCLUDE ++#include <sys/user.h> ++POST_SYS_INCLUDE ++#define HAVE_POSIX_SPAWN 1 ++#endif ++#if defined(OS_FREEBSD) ++PRE_SYS_INCLUDE ++#include <sys/user.h> ++POST_SYS_INCLUDE ++#endif ++ ++#include "base/debug_util.h" ++#include "base/eintr_wrapper.h" ++#include "base/file_util.h" ++#include "base/logging.h" ++#include "base/string_tokenizer.h" ++#include "base/string_util.h" ++ ++#if defined(OS_NETBSD) ++#include <sys/param.h> ++#if __NetBSD_Version__ >= 600000000 ++#define HAVE_POSIX_SPAWN 1 ++#endif ++#endif ++ ++#ifdef HAVE_POSIX_SPAWN ++PRE_SYS_INCLUDE ++#include <spawn.h> ++POST_SYS_INCLUDE ++extern "C" char **environ __dso_public; ++#endif ++ ++namespace { ++ ++enum ParsingState { ++ KEY_NAME, ++ KEY_VALUE ++}; ++ ++static mozilla::EnvironmentLog gProcessLog("MOZ_PROCESS_LOG"); ++ ++} // namespace ++ ++namespace base { ++ ++#ifdef HAVE_POSIX_SPAWN ++ ++void FreeEnvVarsArray(char* array[], int length) ++{ ++ for (int i = 0; i < length; i++) { ++ free(array[i]); ++ } ++ delete[] array; ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ bool wait, ProcessHandle* process_handle) { ++ return LaunchApp(argv, fds_to_remap, environment_map(), ++ wait, process_handle); ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ const environment_map& env_vars_to_set, ++ bool wait, ProcessHandle* process_handle, ++ ProcessArchitecture arch) { ++ bool retval = true; ++ ++ char* argv_copy[argv.size() + 1]; ++ for (size_t i = 0; i < argv.size(); i++) { ++ argv_copy[i] = const_cast<char*>(argv[i].c_str()); ++ } ++ argv_copy[argv.size()] = NULL; ++ ++ // Make sure we don't leak any FDs to the child process by marking all FDs ++ // as close-on-exec. ++ SetAllFDsToCloseOnExec(); ++ ++ // Copy environment to a new char array and add the variables ++ // in env_vars_to_set. ++ // Existing variables are overwritten by env_vars_to_set. ++ int pos = 0; ++ environment_map combined_env_vars = env_vars_to_set; ++ while(environ[pos] != NULL) { ++ std::string varString = environ[pos]; ++ std::string varName = varString.substr(0, varString.find_first_of('=')); ++ std::string varValue = varString.substr(varString.find_first_of('=') + 1); ++ if (combined_env_vars.find(varName) == combined_env_vars.end()) { ++ combined_env_vars[varName] = varValue; ++ } ++ pos++; ++ } ++ int varsLen = combined_env_vars.size() + 1; ++ ++ char** vars = new char*[varsLen]; ++ int i = 0; ++ for (environment_map::const_iterator it = combined_env_vars.begin(); ++ it != combined_env_vars.end(); ++it) { ++ std::string entry(it->first); ++ entry += "="; ++ entry += it->second; ++ vars[i] = strdup(entry.c_str()); ++ i++; ++ } ++ vars[i] = NULL; ++ ++ posix_spawn_file_actions_t file_actions; ++ if (posix_spawn_file_actions_init(&file_actions) != 0) { ++ FreeEnvVarsArray(vars, varsLen); ++ return false; ++ } ++ ++ // Turn fds_to_remap array into a set of dup2 calls. ++ for (file_handle_mapping_vector::const_iterator it = fds_to_remap.begin(); ++ it != fds_to_remap.end(); ++ ++it) { ++ int src_fd = it->first; ++ int dest_fd = it->second; ++ ++ if (src_fd == dest_fd) { ++ int flags = fcntl(src_fd, F_GETFD); ++ if (flags != -1) { ++ fcntl(src_fd, F_SETFD, flags & ~FD_CLOEXEC); ++ } ++ } else { ++ if (posix_spawn_file_actions_adddup2(&file_actions, src_fd, dest_fd) != 0) { ++ posix_spawn_file_actions_destroy(&file_actions); ++ FreeEnvVarsArray(vars, varsLen); ++ return false; ++ } ++ } ++ } ++ ++ pid_t pid = 0; ++ int spawn_succeeded = (posix_spawnp(&pid, ++ argv_copy[0], ++ &file_actions, ++ NULL, ++ argv_copy, ++ vars) == 0); ++ ++ FreeEnvVarsArray(vars, varsLen); ++ ++ posix_spawn_file_actions_destroy(&file_actions); ++ ++ bool process_handle_valid = pid > 0; ++ if (!spawn_succeeded || !process_handle_valid) { ++ retval = false; ++ } else { ++ if (wait) ++ HANDLE_EINTR(waitpid(pid, 0, 0)); ++ ++ if (process_handle) ++ *process_handle = pid; ++ } ++ ++ return retval; ++} ++ ++bool LaunchApp(const CommandLine& cl, ++ bool wait, bool start_hidden, ProcessHandle* process_handle) { ++ // TODO(playmobil): Do we need to respect the start_hidden flag? ++ file_handle_mapping_vector no_files; ++ return LaunchApp(cl.argv(), no_files, wait, process_handle); ++} ++ ++#else // no posix_spawn, use fork/exec ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ bool wait, ProcessHandle* process_handle) { ++ return LaunchApp(argv, fds_to_remap, environment_map(), ++ wait, process_handle); ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ const environment_map& env_vars_to_set, ++ bool wait, ProcessHandle* process_handle, ++ ProcessArchitecture arch) { ++ scoped_array<char*> argv_cstr(new char*[argv.size() + 1]); ++ // Illegal to allocate memory after fork and before execvp ++ InjectiveMultimap fd_shuffle1, fd_shuffle2; ++ fd_shuffle1.reserve(fds_to_remap.size()); ++ fd_shuffle2.reserve(fds_to_remap.size()); ++ ++ pid_t pid = fork(); ++ if (pid < 0) ++ return false; ++ ++ if (pid == 0) { ++ for (file_handle_mapping_vector::const_iterator ++ it = fds_to_remap.begin(); it != fds_to_remap.end(); ++it) { ++ fd_shuffle1.push_back(InjectionArc(it->first, it->second, false)); ++ fd_shuffle2.push_back(InjectionArc(it->first, it->second, false)); ++ } ++ ++ if (!ShuffleFileDescriptors(&fd_shuffle1)) ++ _exit(127); ++ ++ CloseSuperfluousFds(fd_shuffle2); ++ ++ for (environment_map::const_iterator it = env_vars_to_set.begin(); ++ it != env_vars_to_set.end(); ++it) { ++ if (setenv(it->first.c_str(), it->second.c_str(), 1/*overwrite*/)) ++ _exit(127); ++ } ++ ++ for (size_t i = 0; i < argv.size(); i++) ++ argv_cstr[i] = const_cast<char*>(argv[i].c_str()); ++ argv_cstr[argv.size()] = NULL; ++ execvp(argv_cstr[0], argv_cstr.get()); ++ // if we get here, we're in serious trouble and should complain loudly ++ DLOG(ERROR) << "FAILED TO exec() CHILD PROCESS, path: " << argv_cstr[0]; ++ exit(127); ++ } else { ++ gProcessLog.print("==> process %d launched child process %d\n", ++ GetCurrentProcId(), pid); ++ if (wait) ++ HANDLE_EINTR(waitpid(pid, 0, 0)); ++ ++ if (process_handle) ++ *process_handle = pid; ++ } ++ ++ return true; ++} ++ ++bool LaunchApp(const CommandLine& cl, ++ bool wait, bool start_hidden, ++ ProcessHandle* process_handle) { ++ file_handle_mapping_vector no_files; ++ return LaunchApp(cl.argv(), no_files, wait, process_handle); ++} ++ ++#endif ++ ++NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name, ++ const ProcessFilter* filter) ++{ ++ int numEntries; ++ kvm_t *kvm; ++ std::string exe(WideToASCII(executable_name)); ++ ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++ kvm = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL); ++ struct kinfo_proc* procs = kvm_getprocs(kvm, KERN_PROC_UID, getuid(), &numEntries); ++ if (procs != NULL && numEntries > 0) { ++ for (int i = 0; i < numEntries; i++) { ++# if defined(OS_DRAGONFLY) ++ if (exe != procs[i].kp_comm) continue; ++ if (filter && !filter->Includes(procs[i].kp_pid, procs[i].kp_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].kp_pid; ++ e.ppid = procs[i].kp_ppid; ++ strlcpy(e.szExeFile, procs[i].kp_comm, sizeof e.szExeFile); ++ content.push_back(e); ++# elif defined(OS_FREEBSD) ++ if (exe != procs[i].ki_comm) continue; ++ if (filter && !filter->Includes(procs[i].ki_pid, procs[i].ki_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].ki_pid; ++ e.ppid = procs[i].ki_ppid; ++ strlcpy(e.szExeFile, procs[i].ki_comm, sizeof e.szExeFile); ++ content.push_back(e); ++# endif ++#else ++ kvm = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL); ++ struct kinfo_proc2* procs = kvm_getproc2(kvm, KERN_PROC_UID, getuid(), sizeof(struct kinfo_proc2), &numEntries); ++ if (procs != NULL && numEntries > 0) { ++ for (int i = 0; i < numEntries; i++) { ++ if (exe != procs[i].p_comm) continue; ++ if (filter && !filter->Includes(procs[i].p_pid, procs[i].p_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].p_pid; ++ e.ppid = procs[i].p_ppid; ++ strlcpy(e.szExeFile, procs[i].p_comm, sizeof e.szExeFile); ++ content.push_back(e); ++#endif ++ } ++ } ++ nextEntry = 0; ++ kvm_close(kvm); ++} ++ ++NamedProcessIterator::~NamedProcessIterator() { ++} ++ ++const ProcessEntry* NamedProcessIterator::NextProcessEntry() { ++ if (nextEntry >= content.size()) return NULL; ++ return &content[nextEntry++]; ++} ++ ++bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { ++ return false; ++} ++ ++} // namespace base +$NetBSD: patch-ipc_chromium_src_base_process__util__posix.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/process_util_posix.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/process_util_posix.cc +@@ -116,6 +116,11 @@ void CloseSuperfluousFds(const base::Inj + #elif defined(OS_MACOSX) + static const rlim_t kSystemDefaultMaxFds = 256; + static const char kFDDir[] = "/dev/fd"; ++#elif defined(OS_BSD) ++ // the getrlimit below should never fail, so whatever .. ++ static const rlim_t kSystemDefaultMaxFds = 1024; ++ // at least /dev/fd will exist ++ static const char kFDDir[] = "/dev/fd"; + #endif + + // Get the maximum number of FDs possible. +@@ -199,7 +204,7 @@ void CloseSuperfluousFds(const base::Inj + void SetAllFDsToCloseOnExec() { + #if defined(OS_LINUX) + const char fd_dir[] = "/proc/self/fd"; +-#elif defined(OS_MACOSX) ++#elif defined(OS_MACOSX) || defined(OS_BSD) + const char fd_dir[] = "/dev/fd"; + #endif + ScopedDIR dir_closer(opendir(fd_dir)); +$NetBSD: patch-ipc_chromium_src_base_sys__info__posix.cc,v 1.2 2011/11/27 13:09:00 tnn Exp $ + +--- mozilla/ipc/chromium/src/base/sys_info_posix.cc.orig 2011-11-04 21:34:00.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/sys_info_posix.cc +@@ -18,6 +18,11 @@ + #include <mach/mach_init.h> + #endif + ++#if defined(OS_NETBSD) ++#include <sys/param.h> ++#include <sys/sysctl.h> ++#endif ++ + #include "base/logging.h" + #include "base/string_util.h" + +@@ -26,7 +31,11 @@ namespace base { + int SysInfo::NumberOfProcessors() { + // It seems that sysconf returns the number of "logical" processors on both + // mac and linux. So we get the number of "online logical" processors. ++#ifdef _SC_NPROCESSORS_ONLN + static long res = sysconf(_SC_NPROCESSORS_ONLN); ++#else ++ static long res = 1; ++#endif + if (res == -1) { + NOTREACHED(); + return 1; +@@ -52,6 +61,20 @@ int64 SysInfo::AmountOfPhysicalMemory() + } + + return static_cast<int64>(hostinfo.max_mem); ++#elif defined(OS_NETBSD) ++ int mib[2]; ++ int rc; ++ int64_t memSize; ++ size_t len = sizeof(memSize); ++ ++ mib[0] = CTL_HW; ++ mib[1] = HW_PHYSMEM64; ++ rc = sysctl( mib, 2, &memSize, &len, NULL, 0 ); ++ if (-1 != rc) { ++ return memSize; ++ } ++ return 0; ++ + #else + long pages = sysconf(_SC_PHYS_PAGES); + long page_size = sysconf(_SC_PAGE_SIZE); +$NetBSD: patch-ipc_chromium_src_base_third__party_nspr_prcpucfg.h,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/third_party/nspr/prcpucfg.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/third_party/nspr/prcpucfg.h +@@ -34,7 +34,7 @@ + #include "base/third_party/nspr/prcpucfg_win.h" + #elif defined(__APPLE__) + #include "base/third_party/nspr/prcpucfg_mac.h" +-#elif defined(__linux__) || defined(ANDROID) ++#elif defined(__linux__) || defined(ANDROID) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) + #include "base/third_party/nspr/prcpucfg_linux.h" + #elif defined(__OpenBSD__) + #include "base/third_party/nspr/prcpucfg_openbsd.h" +$NetBSD: patch-ipc_chromium_src_base_third__party_nspr_prtime.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/third_party/nspr/prtime.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/third_party/nspr/prtime.cc +@@ -212,7 +212,7 @@ PR_ImplodeTime(const PRExplodedTime *exp + LL_ADD(retVal, retVal, temp); + + return retVal; +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_DRAGONFLY) + struct tm exp_tm = {0}; + exp_tm.tm_sec = exploded->tm_sec; + exp_tm.tm_min = exploded->tm_min; +@@ -245,6 +245,24 @@ PR_ImplodeTime(const PRExplodedTime *exp + result *= kSecondsToMicroseconds; + result += exploded->tm_usec; + return result; ++#elif defined(OS_FREEBSD) || defined(OS_NETBSD) ++ struct tm exp_tm = {0}; ++ exp_tm.tm_sec = exploded->tm_sec; ++ exp_tm.tm_min = exploded->tm_min; ++ exp_tm.tm_hour = exploded->tm_hour; ++ exp_tm.tm_mday = exploded->tm_mday; ++ exp_tm.tm_mon = exploded->tm_month; ++ exp_tm.tm_year = exploded->tm_year - 1900; ++ ++ // time_t is 64bit ++ time_t absolute_time = timegm(&exp_tm); ++ ++ PRTime result = static_cast<PRTime>(absolute_time); ++ result -= exploded->tm_params.tp_gmt_offset + ++ exploded->tm_params.tp_dst_offset; ++ result *= kSecondsToMicroseconds; ++ result += exploded->tm_usec; ++ return result; + #else + #error No PR_ImplodeTime implemented on your platform. + #endif +diff --git ipc/chromium/src/base/time_posix.cc ipc/chromium/src/base/time_posix.cc +index abf2a56..48791f6 100644 +--- mozilla/ipc/chromium/src/base/time_posix.cc ++++ mozilla/ipc/chromium/src/base/time_posix.cc +@@ -167,7 +167,7 @@ TimeTicks TimeTicks::Now() { + // With numer and denom = 1 (the expected case), the 64-bit absolute time + // reported in nanoseconds is enough to last nearly 585 years. + +-#elif defined(__OpenBSD__) || defined(OS_POSIX) && \ ++#elif defined(OS_OPENBSD) || defined(OS_POSIX) && \ + defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 + + struct timespec ts; +$NetBSD: patch-ipc_chromium_src_build_build__config.h,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- mozilla/ipc/chromium/src/build/build_config.h.orig 2012-03-13 01:36:53.000000000 +0000 ++++ mozilla/ipc/chromium/src/build/build_config.h +@@ -19,17 +19,23 @@ + #define OS_MACOSX 1 + #elif defined(__linux__) || defined(ANDROID) + #define OS_LINUX 1 ++#elif defined(__NetBSD__) ++#define OS_NETBSD 1 ++#elif defined(__DragonFly__) ++#define OS_DRAGONFLY 1 + #elif defined(__OpenBSD__) + #define OS_OPENBSD 1 + #elif defined(_WIN32) + #define OS_WIN 1 ++#elif defined(__FreeBSD__) ++#define OS_FREEBSD 1 + #else + #error Please add support for your platform in build/build_config.h + #endif + + // For access to standard POSIX features, use OS_POSIX instead of a more + // specific macro. +-#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_OPENBSD) ++#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_BSD) + #define OS_POSIX 1 + #endif + +diff --git ipc/chromium/src/chrome/common/ipc_channel_posix.cc ipc/chromium/src/chrome/common/ipc_channel_posix.cc +index bd866ee..2ea5b19 100644 +--- mozilla/ipc/chromium/src/chrome/common/ipc_channel_posix.cc ++++ mozilla/ipc/chromium/src/chrome/common/ipc_channel_posix.cc +@@ -7,6 +7,7 @@ + #include <errno.h> + #include <fcntl.h> + #include <stddef.h> ++#include <unistd.h> + #include <sys/types.h> + #include <sys/socket.h> + #include <sys/stat.h> +$NetBSD: patch-ipc_chromium_src_chrome_common_ipc__channel__posix.h,v 1.1 2011/07/11 12:46:14 tnn Exp $ + +--- mozilla/ipc/chromium/src/chrome/common/ipc_channel_posix.h.orig 2011-06-15 21:57:27.000000000 +0000 ++++ mozilla/ipc/chromium/src/chrome/common/ipc_channel_posix.h +@@ -92,7 +92,7 @@ class Channel::ChannelImpl : public Mess + }; + + // This is a control message buffer large enough to hold kMaxReadFDs +-#if defined(OS_MACOSX) ++#if defined(OS_MACOSX) || defined(OS_NETBSD) + // TODO(agl): OSX appears to have non-constant CMSG macros! + char input_cmsg_buf_[1024]; + #else +$NetBSD: patch-ipc_chromium_src_chrome_common_ipc__message__utils.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/chrome/common/ipc_message_utils.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/chrome/common/ipc_message_utils.h +@@ -195,7 +195,7 @@ + }; + #endif + +-#if !(defined(OS_MACOSX) || defined(OS_OPENBSD) || defined(OS_WIN) || (defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)) || defined(ARCH_CPU_S390)) ++#if !(defined(OS_MACOSX) || defined(OS_OPENBSD) || defined(OS_WIN) || ((defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined(OS_NETBSD) || defined(OS_LINUX)) && defined(ARCH_CPU_64_BITS)) || defined(ARCH_CPU_S390)) + // There size_t is a synonym for |unsigned long| ... + template <> + struct ParamTraits<size_t> { +@@ -248,7 +248,7 @@ + }; + #endif // defined(OS_MACOSX) + +-#if !(defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)) ++#if !((defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined(OS_NETBSD) || defined(OS_LINUX)) && defined(ARCH_CPU_64_BITS)) + // int64 is |long int| on 64-bit systems, uint64 is |unsigned long| + template <> + struct ParamTraits<int64> { +$NetBSD: patch-ipc_chromium_src_chrome_common_transport__dib.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/chrome/common/transport_dib.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/chrome/common/transport_dib.h +@@ -7,7 +7,7 @@ + + #include "base/basictypes.h" + +-#if defined(OS_WIN) || defined(OS_MACOSX) ++#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + #include "base/shared_memory.h" + #endif + +@@ -66,7 +66,7 @@ class TransportDIB { + uint32 sequence_num; + }; + typedef HandleAndSequenceNum Id; +-#elif defined(OS_MACOSX) ++#elif defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + typedef base::SharedMemoryHandle Handle; + // On Mac, the inode number of the backing file is used as an id. + typedef base::SharedMemoryId Id; +@@ -108,7 +108,7 @@ class TransportDIB { + + private: + TransportDIB(); +-#if defined(OS_WIN) || defined(OS_MACOSX) ++#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + explicit TransportDIB(base::SharedMemoryHandle dib); + base::SharedMemory shared_memory_; + uint32 sequence_num_; +$NetBSD: patch-ipc_glue_GeckoChildProcessHost.cpp,v 1.2 2012/03/15 08:30:06 ryoon Exp $ + +--- mozilla/ipc/glue/GeckoChildProcessHost.cpp.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/glue/GeckoChildProcessHost.cpp +@@ -430,7 +430,7 @@ + // and passing wstrings from one config to the other is unsafe. So + // we split the logic here. + +-#if defined(OS_LINUX) || defined(OS_MACOSX) ++#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD) + base::environment_map newEnvVars; + // XPCOM may not be initialized in some subprocesses. We don't want + // to initialize XPCOM just for the directory service, especially +@@ -445,8 +445,8 @@ + if (NS_SUCCEEDED(rv)) { + nsCString path; + greDir->GetNativePath(path); +-# ifdef OS_LINUX +-# ifdef MOZ_WIDGET_ANDROID ++# if defined(OS_LINUX) || defined(OS_BSD) ++# if defined(MOZ_WIDGET_ANDROID) || defined(OS_BSD) + path += "/lib"; + # endif // MOZ_WIDGET_ANDROID + const char *ld_library_path = PR_GetEnv("LD_LIBRARY_PATH"); +@@ -557,7 +557,7 @@ + childArgv.push_back(pidstring); + + #if defined(MOZ_CRASHREPORTER) +-# if defined(OS_LINUX) ++# if defined(OS_LINUX) || defined(OS_BSD) + int childCrashFd, childCrashRemapFd; + if (!CrashReporter::CreateNotificationPipeForChild( + &childCrashFd, &childCrashRemapFd)) +@@ -594,7 +594,7 @@ + #endif + + base::LaunchApp(childArgv, mFileMap, +-#if defined(OS_LINUX) || defined(OS_MACOSX) ++#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD) + newEnvVars, + #endif + false, &process, arch); +$NetBSD: patch-mm,v 1.13 2012/06/05 18:09:21 ryoon Exp $ + +--- mozilla/toolkit/library/Makefile.in.orig 2012-05-23 18:57:09.000000000 +0000 ++++ mozilla/toolkit/library/Makefile.in +@@ -534,6 +538,10 @@ EXTRA_DSO_LDOPTS += -lelf -ldemangle + endif + endif + ++ifneq (,$(filter DragonFly FreeBSD NetBSD,$(OS_ARCH))) ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++endif ++ + ifeq ($(OS_ARCH),WINNT) + OS_LIBS += $(call EXPAND_LIBNAME,shell32 ole32 version winspool comdlg32 imm32 msimg32 shlwapi psapi ws2_32 dbghelp rasapi32 rasdlg iphlpapi uxtheme setupapi secur32 sensorsapi portabledeviceguids windowscodecs wininet) + ifdef ACCESSIBILITY Deleted: branches/experimental/mail/thunderbird/files/patch-ipc-chromium-src-base-file_util_linux.cc ============================================================================== --- branches/experimental/mail/thunderbird/files/patch-ipc-chromium-src-base-file_util_linux.cc Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- mozilla/ipc/chromium/src/base/file_util_linux.cc~ -+++ mozilla/ipc/chromium/src/base/file_util_linux.cc -@@ -28,7 +29,7 @@ bool GetShmemTempDir(FilePath* path) { - #ifdef ANDROID - return GetTempDir(path); - #else -- *path = FilePath("/dev/shm"); -+ *path = FilePath("/tmp"); - return true; - #endif - } Deleted: branches/experimental/mail/thunderbird/files/patch-ipc-chromium-src-base-file_util_posix.cc ============================================================================== --- branches/experimental/mail/thunderbird/files/patch-ipc-chromium-src-base-file_util_posix.cc Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- mozilla/ipc/chromium/src/base/file_util_posix.cc~ -+++ mozilla/ipc/chromium/src/base/file_util_posix.cc -@@ -31,7 +31,7 @@ - #include "base/time.h" - - // FreeBSD/OpenBSD lacks stat64, but its stat handles files >2GB just fine --#if defined(OS_FREEBSD) || defined(OS_OPENBSD) -+#if defined(__FreeBSD__) || defined(OS_OPENBSD) - #define stat64 stat - #endif - Deleted: branches/experimental/mail/thunderbird/files/patch-ipc-chromium-src-base-platform_thread_posix.cc ============================================================================== --- branches/experimental/mail/thunderbird/files/patch-ipc-chromium-src-base-platform_thread_posix.cc Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,12 +0,0 @@ ---- mozilla/ipc/chromium/src/base/platform_thread_posix.cc.orig 2011-04-27 09:34:28.000000000 +0200 -+++ mozilla/ipc/chromium/src/base/platform_thread_posix.cc 2011-04-27 19:47:36.344446266 +0200 -@@ -34,7 +33,8 @@ - #if defined(OS_MACOSX) - return mach_thread_self(); - #elif defined(OS_LINUX) -- return syscall(__NR_gettid); -+ // TODO(BSD): find a better thread ID -+ return reinterpret_cast<int64>(pthread_self()); - #endif - } - Deleted: branches/experimental/mail/thunderbird/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h ============================================================================== --- branches/experimental/mail/thunderbird/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- mozilla/ipc/chromium/src/base/third_party/nspr/prcpucfg.h~ -+++ mozilla/ipc/chromium/src/base/third_party/nspr/prcpucfg.h -@@ -34,7 +34,7 @@ - #include "base/third_party/nspr/prcpucfg_win.h" - #elif defined(__APPLE__) - #include "base/third_party/nspr/prcpucfg_mac.h" --#elif defined(__linux__) || defined(ANDROID) -+#elif defined(__FreeBSD__) || defined(ANDROID) - #include "base/third_party/nspr/prcpucfg_linux.h" - #else - #error Provide a prcpucfg.h appropriate for your platform Deleted: branches/experimental/mail/thunderbird/files/patch-ipc-chromium-src-build-build_config.h ============================================================================== --- branches/experimental/mail/thunderbird/files/patch-ipc-chromium-src-build-build_config.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- mozilla/ipc/chromium/src/build/build_config.h~ -+++ mozilla/ipc/chromium/src/build/build_config.h -@@ -17,7 +17,7 @@ - // A set of macros to use for platform detection. - #if defined(__APPLE__) - #define OS_MACOSX 1 --#elif defined(__linux__) || defined(ANDROID) -+#elif defined(__linux__) || defined(ANDROID) || defined(__FreeBSD__) - #define OS_LINUX 1 - #elif defined(__OpenBSD__) - #define OS_OPENBSD 1 Deleted: branches/experimental/mail/thunderbird/files/patch-mozilla-ipc-chromium-src-base-dir_reader_linux.h ============================================================================== --- branches/experimental/mail/thunderbird/files/patch-mozilla-ipc-chromium-src-base-dir_reader_linux.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,52 +0,0 @@ ---- mozilla/ipc/chromium/src/base/dir_reader_linux.h~ -+++ mozilla/ipc/chromium/src/base/dir_reader_linux.h -@@ -12,6 +12,10 @@ - #include <sys/syscall.h> - #include <unistd.h> - -+#if defined(__FreeBSD__) -+#include <sys/dirent.h> -+#endif -+ - #include "base/logging.h" - #include "base/eintr_wrapper.h" - -@@ -19,6 +23,9 @@ - - namespace base { - -+#if defined(__FreeBSD__) -+#define linux_dirent struct dirent -+#else - struct linux_dirent { - uint64_t d_ino; - int64_t d_off; -@@ -26,11 +33,16 @@ struct linux_dirent { - unsigned char d_type; - char d_name[0]; - }; -+#endif - - class DirReaderLinux { - public: - explicit DirReaderLinux(const char* directory_path) -+#ifdef O_DIRECTORY - : fd_(open(directory_path, O_RDONLY | O_DIRECTORY)), -+#else -+ : fd_(open(directory_path, O_RDONLY)), -+#endif - offset_(0), - size_(0) { - memset(buf_, 0, sizeof(buf_)); -@@ -57,7 +69,11 @@ class DirReaderLinux { - if (offset_ != size_) - return true; - -+#if !defined(__FreeBSD__) - const int r = syscall(__NR_getdents64, fd_, buf_, sizeof(buf_)); -+#else -+ const int r = syscall(SYS_getdents, fd_, buf_, sizeof(buf_)); -+#endif - if (r == 0) - return false; - if (r == -1) { Deleted: branches/experimental/mail/thunderbird/files/patch-mozilla-toolkit-library-Makefile.in ============================================================================== --- branches/experimental/mail/thunderbird/files/patch-mozilla-toolkit-library-Makefile.in Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,12 +0,0 @@ ---- mozilla/toolkit/library/Makefile.in.orig 2010-01-11 12:13:08.000000000 -0500 -+++ mozilla/toolkit/library/Makefile.in 2010-01-11 12:15:05.000000000 -0500 -@@ -181,7 +181,7 @@ - export:: $(RDF_UTIL_SRC_CPPSRCS) $(INTL_UNICHARUTIL_UTIL_CPPSRCS) - $(INSTALL) $^ . - --EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(EXTRA_DSO_LIBS) -+EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(EXTRA_DSO_LIBS) -lexecinfo - - ifdef MOZ_ENABLE_LIBXUL - include $(srcdir)/libxul-rules.mk - Modified: branches/experimental/www/firefox-esr/Makefile ============================================================================== --- branches/experimental/www/firefox-esr/Makefile Mon Jul 23 13:52:35 2012 (r886) +++ branches/experimental/www/firefox-esr/Makefile Mon Jul 23 22:39:41 2012 (r887) @@ -21,7 +21,6 @@ sqlite3>=3.7.7.1:${PORTSDIR}/databases/sqlite3 \ cairo>=1.10.2_1,1:${PORTSDIR}/graphics/cairo \ unzip:${PORTSDIR}/archivers/unzip -LIB_DEPENDS= execinfo.1:${PORTSDIR}/devel/libexecinfo CONFLICTS_BUILD= spidermonkey-* @@ -110,9 +109,6 @@ <${FILESDIR}/firefox.desktop.in >${WRKDIR}/${MOZILLA}.desktop post-patch: - @${GREP} -Flr \"/proc ${WRKSRC}/ipc/chromium/src/base | ${XARGS} ${REINPLACE_CMD} \ - -e 's|/proc/self/fd|/dev/fd|' \ - -e 's|/proc["/]|/compat/linux&|' @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \ ${WRKSRC}/browser/app/nsBrowserApp.cpp Added: branches/experimental/www/firefox-esr/files/patch-bug753046 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/experimental/www/firefox-esr/files/patch-bug753046 Mon Jul 23 22:39:41 2012 (r887) @@ -0,0 +1,1256 @@ +# Bug 753046 - Add support for DragonFly/NetBSD + +$NetBSD: patch-dom_plugins_ipc_PluginModuleChild.cpp,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- dom/plugins/ipc/PluginModuleChild.cpp.orig 2011-12-20 23:28:14.000000000 +0000 ++++ dom/plugins/ipc/PluginModuleChild.cpp +@@ -33,6 +33,8 @@ + #include "nsPluginsDir.h" + #include "nsXULAppAPI.h" + ++#include <unistd.h> ++ + #ifdef MOZ_X11 + # include "mozilla/X11Util.h" + #endif +@@ -228,7 +228,7 @@ PluginModuleChild::Init(const std::strin + + // TODO: use PluginPRLibrary here + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + mShutdownFunc = + (NP_PLUGINSHUTDOWN) PR_FindFunctionSymbol(mLibrary, "NP_Shutdown"); + +@@ -1790,7 +1790,7 @@ PluginModuleChild::AnswerNP_GetEntryPoin + PLUGIN_LOG_DEBUG_METHOD; + AssertPluginThread(); + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + return true; + #elif defined(OS_WIN) || defined(OS_MACOSX) + *_retval = mGetEntryPointsFunc(&mFunctions); +@@ -1823,7 +1823,7 @@ PluginModuleChild::AnswerNP_Initialize(N + SendBackUpXResources(FileDescriptor(xSocketFd, false/*don't close*/)); + #endif + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + *_retval = mInitializeFunc(&sBrowserFuncs, &mFunctions); + return true; + #elif defined(OS_WIN) || defined(OS_MACOSX) +$NetBSD: patch-dom_plugins_ipc_PluginModuleChild.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- dom/plugins/ipc/PluginModuleChild.h.orig 2011-12-20 23:28:14.000000000 +0000 ++++ dom/plugins/ipc/PluginModuleChild.h +@@ -340,7 +340,7 @@ private: + + // we get this from the plugin + NP_PLUGINSHUTDOWN mShutdownFunc; +-#ifdef OS_LINUX ++#if defined(OS_LINUX) || defined(OS_BSD) + NP_PLUGINUNIXINIT mInitializeFunc; + #elif defined(OS_WIN) || defined(OS_MACOSX) + NP_PLUGININIT mInitializeFunc; +$NetBSD: patch-ipc_chromium_Makefile.in,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/Makefile.in.orig 2012-02-16 06:40:33.000000000 +0000 ++++ ipc/chromium/Makefile.in +@@ -278,6 +278,34 @@ endif + + endif # } OS_LINUX + ++ifdef OS_BSD # { ++ ++CPPSRCS += \ ++ atomicops_internals_x86_gcc.cc \ ++ file_util_bsd.cc \ ++ process_util_bsd.cc \ ++ time_posix.cc \ ++ $(NULL) ++ ++ifdef MOZ_ENABLE_GTK2 ++CPPSRCS += \ ++ message_pump_glib.cc \ ++ $(NULL) ++endif ++ ++ifdef MOZ_ENABLE_QT ++MOCSRCS = \ ++ moc_message_pump_qt.cc \ ++ $(NULL) ++ ++CPPSRCS += \ ++ $(MOCSRCS) \ ++ message_pump_qt.cc \ ++ $(NULL) ++endif ++ ++endif # } OS_BSD ++ + # libevent + + ifndef MOZ_NATIVE_LIBEVENT # { +$NetBSD: patch-ipc_chromium_chromium-config.mk,v 1.2 2012/03/15 08:30:06 ryoon Exp $ + +--- ipc/chromium/chromium-config.mk.orig 2012-02-16 07:40:33.000000000 +0100 ++++ ipc/chromium/chromium-config.mk 2012-03-11 11:05:40.397182000 +0100 +@@ -56,17 +56,6 @@ + -I$(DEPTH)/ipc/ipdl/_ipdlheaders \ + $(NULL) + +-ifeq ($(OS_ARCH),Darwin) # { +- +-OS_MACOSX = 1 +-OS_POSIX = 1 +- +-DEFINES += \ +- -DOS_MACOSX=1 \ +- -DOS_POSIX=1 \ +- $(NULL) +- +-else # } { + ifeq ($(OS_ARCH),WINNT) # { + OS_LIBS += $(call EXPAND_LIBNAME,psapi shell32 dbghelp) + +@@ -93,13 +82,64 @@ + endif + + else # } { +- +-OS_LINUX = 1 + OS_POSIX = 1 ++DEFINES += -DOS_POSIX=1 ++ ++ifeq ($(OS_ARCH),Darwin) # { ++ ++OS_MACOSX = 1 ++DEFINES += \ ++ -DOS_MACOSX=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),DragonFly) # { ++ ++OS_DRAGONFLY = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_DRAGONFLY=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),FreeBSD) # { ++ ++OS_FREEBSD = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_FREEBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) + ++else # } { ++ifeq ($(OS_ARCH),NetBSD) # { ++ ++OS_NETBSD = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_NETBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),OpenBSD) # { ++ ++OS_OPENBSD = 1 ++OS_BSD = 1 ++DEFINES += \ ++ -DOS_OPENBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ ++OS_LINUX = 1 + DEFINES += \ + -DOS_LINUX=1 \ +- -DOS_POSIX=1 \ + $(NULL) + + # NB: to stop gcc warnings about exporting template instantiation +@@ -107,4 +147,8 @@ + + endif # } + endif # } ++endif # } ++endif # } ++endif # } ++endif # } + +$NetBSD: patch-ipc_chromium_src_base_base__paths.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/base_paths.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/base_paths.h +@@ -13,7 +13,7 @@ + #include "base/base_paths_win.h" + #elif defined(OS_MACOSX) + #include "base/base_paths_mac.h" +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_BSD) + #include "base/base_paths_linux.h" + #endif + #include "base/path_service.h" +$NetBSD: patch-ipc_chromium_src_base_debug__util__posic.cc,v 1.3 2012/04/01 15:18:45 ryoon Exp $ + +--- ipc/chromium/src/base/debug_util_posix.cc.orig 2012-03-13 01:36:53.000000000 +0000 ++++ ipc/chromium/src/base/debug_util_posix.cc +@@ -5,7 +5,7 @@ + #include "build/build_config.h" + #include "base/debug_util.h" + +-#define MOZ_HAVE_EXECINFO_H (!defined(ANDROID) && !defined(__OpenBSD__)) ++#define MOZ_HAVE_EXECINFO_H (defined(OS_LINUX) && !defined(ANDROID)) + + #include <errno.h> + #include <fcntl.h> +@@ -17,8 +17,13 @@ + #include <unistd.h> + #if MOZ_HAVE_EXECINFO_H + #include <execinfo.h> +-#include <sys/sysctl.h> + #endif ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++#include <sys/user.h> ++#elif defined(OS_FREEBSD) ++#include <sys/proc.h> ++#endif ++#include <sys/sysctl.h> + + #include "base/basictypes.h" + #include "base/eintr_wrapper.h" +@@ -32,7 +37,7 @@ bool DebugUtil::SpawnDebuggerOnProcess(u + return false; + } + +-#if defined(OS_MACOSX) ++#if defined(OS_MACOSX) || defined(OS_BSD) + + // Based on Apple's recommended method as described in + // http://developer.apple.com/qa/qa2004/qa1361.html +@@ -71,7 +76,13 @@ bool DebugUtil::BeingDebugged() { + + // This process is being debugged if the P_TRACED flag is set. + is_set = true; ++#if defined(OS_DRAGONFLY) ++ being_debugged = (info.kp_flags & P_TRACED) != 0; ++#elif defined(OS_FREEBSD) ++ being_debugged = (info.ki_flag & P_TRACED) != 0; ++#else + being_debugged = (info.kp_proc.p_flag & P_TRACED) != 0; ++#endif + return being_debugged; + } + +diff --git ipc/chromium/src/base/dir_reader_bsd.h ipc/chromium/src/base/dir_reader_bsd.h +new file mode 100644 +index 0000000..3fc1a87 +--- /dev/null ++++ ipc/chromium/src/base/dir_reader_bsd.h +@@ -0,0 +1,98 @@ ++// Copyright (c) 2010 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. ++ ++// derived from dir_reader_linux.h ++ ++#ifndef BASE_DIR_READER_BSD_H_ ++#define BASE_DIR_READER_BSD_H_ ++#pragma once ++ ++#include <dirent.h> ++#include <errno.h> ++#include <fcntl.h> ++#include <stdint.h> ++#include <unistd.h> ++ ++#include "base/logging.h" ++#include "base/eintr_wrapper.h" ++ ++// See the comments in dir_reader_posix.h about this. ++ ++namespace base { ++ ++class DirReaderBSD { ++ public: ++ explicit DirReaderBSD(const char* directory_path) ++#ifdef O_DIRECTORY ++ : fd_(open(directory_path, O_RDONLY | O_DIRECTORY)), ++#else ++ : fd_(open(directory_path, O_RDONLY)), ++#endif ++ offset_(0), ++ size_(0) { ++ memset(buf_, 0, sizeof(buf_)); ++ } ++ ++ ~DirReaderBSD() { ++ if (fd_ >= 0) { ++ if (HANDLE_EINTR(close(fd_))) ++ DLOG(ERROR) << "Failed to close directory handle"; ++ } ++ } ++ ++ bool IsValid() const { ++ return fd_ >= 0; ++ } ++ ++ // Move to the next entry returning false if the iteration is complete. ++ bool Next() { ++ if (size_) { ++ struct dirent* dirent = reinterpret_cast<struct dirent*>(&buf_[offset_]); ++ offset_ += dirent->d_reclen; ++ } ++ ++ if (offset_ != size_) ++ return true; ++ ++ const int r = getdirentries(fd_, buf_, sizeof(buf_), basep_); ++ if (r == 0) ++ return false; ++ if (r == -1) { ++ DLOG(ERROR) << "getdirentries returned an error: " << errno; ++ return false; ++ } ++ size_ = r; ++ offset_ = 0; ++ return true; ++ } ++ ++ const char* name() const { ++ if (!size_) ++ return NULL; ++ ++ const struct dirent* dirent = ++ reinterpret_cast<const struct dirent*>(&buf_[offset_]); ++ return dirent->d_name; ++ } ++ ++ int fd() const { ++ return fd_; ++ } ++ ++ static bool IsFallback() { ++ return false; ++ } ++ ++ private: ++ const int fd_; ++ char buf_[512]; ++ long *basep_; ++ size_t offset_, size_; ++ ++ DISALLOW_COPY_AND_ASSIGN(DirReaderBSD); ++}; ++ ++} // namespace base ++ ++#endif // BASE_DIR_READER_BSD_H_ +diff --git ipc/chromium/src/base/dir_reader_posix.h ipc/chromium/src/base/dir_reader_posix.h +index 9a34492..62b280c 100644 +--- ipc/chromium/src/base/dir_reader_posix.h ++++ ipc/chromium/src/base/dir_reader_posix.h +@@ -18,6 +18,8 @@ + + #if defined(OS_LINUX) + #include "base/dir_reader_linux.h" ++#elif defined(OS_BSD) ++#include "base/dir_reader_bsd.h" + #else + #include "base/dir_reader_fallback.h" + #endif +@@ -26,6 +28,8 @@ + + #if defined(OS_LINUX) + typedef DirReaderLinux DirReaderPosix; ++#elif defined(OS_BSD) ++typedef DirReaderBSD DirReaderPosix; + #else + typedef DirReaderFallback DirReaderPosix; + #endif +$NetBSD: patch-ipc_chromium_src_base_file__util.h,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/file_util.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/file_util.h +@@ -16,8 +16,8 @@ + #include <sys/stat.h> + #elif defined(OS_POSIX) + #include <sys/types.h> +-#include <fts.h> + #include <sys/stat.h> ++#include <fts.h> + #endif + + #include <stdio.h> +$NetBSD: patch-ipc_chromium_src_base_file__util__bsd.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/file_util_bsd.cc.orig 2012-01-07 18:21:18.000000000 +0000 ++++ ipc/chromium/src/base/file_util_bsd.cc +@@ -0,0 +1,80 @@ ++// Copyright (c) 2006-2008 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. ++ ++// this is a derivative of file_util_linux.cc ++ ++#include "base/file_util.h" ++ ++#include <fcntl.h> ++#include <unistd.h> ++ ++#include <string> ++#include <vector> ++ ++#include "base/eintr_wrapper.h" ++#include "base/file_path.h" ++#include "base/string_util.h" ++ ++namespace file_util { ++ ++bool GetTempDir(FilePath* path) { ++ const char* tmp = getenv("TMPDIR"); ++ if (tmp) ++ *path = FilePath(tmp); ++ else ++ *path = FilePath("/tmp"); ++ return true; ++} ++ ++bool GetShmemTempDir(FilePath* path) { ++ return GetTempDir(path); ++} ++ ++bool CopyFile(const FilePath& from_path, const FilePath& to_path) { ++ int infile = open(from_path.value().c_str(), O_RDONLY); ++ if (infile < 0) ++ return false; ++ ++ int outfile = creat(to_path.value().c_str(), 0666); ++ if (outfile < 0) { ++ close(infile); ++ return false; ++ } ++ ++ const size_t kBufferSize = 32768; ++ std::vector<char> buffer(kBufferSize); ++ bool result = true; ++ ++ while (result) { ++ ssize_t bytes_read = HANDLE_EINTR(read(infile, &buffer[0], buffer.size())); ++ if (bytes_read < 0) { ++ result = false; ++ break; ++ } ++ if (bytes_read == 0) ++ break; ++ // Allow for partial writes ++ ssize_t bytes_written_per_read = 0; ++ do { ++ ssize_t bytes_written_partial = HANDLE_EINTR(write( ++ outfile, ++ &buffer[bytes_written_per_read], ++ bytes_read - bytes_written_per_read)); ++ if (bytes_written_partial < 0) { ++ result = false; ++ break; ++ } ++ bytes_written_per_read += bytes_written_partial; ++ } while (bytes_written_per_read < bytes_read); ++ } ++ ++ if (HANDLE_EINTR(close(infile)) < 0) ++ result = false; ++ if (HANDLE_EINTR(close(outfile)) < 0) ++ result = false; ++ ++ return result; ++} ++ ++} // namespace file_util +$NetBSD: patch-ipc_chromium_src_base_file__util__posix.cc,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/file_util_posix.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/file_util_posix.cc +@@ -31,7 +31,7 @@ + #include "base/time.h" + + // FreeBSD/OpenBSD lacks stat64, but its stat handles files >2GB just fine +-#if defined(OS_FREEBSD) || defined(OS_OPENBSD) ++#ifndef OS_LINUX + #define stat64 stat + #endif + +$NetBSD: patch-ipc_chromium_src_base_message__loop.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/message_loop.cc.orig 2012-02-16 07:40:33.000000000 +0100 ++++ ipc/chromium/src/base/message_loop.cc 2012-02-21 21:24:41.000000000 +0100 +@@ -19,7 +19,7 @@ + #if defined(OS_POSIX) + #include "base/message_pump_libevent.h" + #endif +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + #ifdef MOZ_WIDGET_GTK2 + #include "base/message_pump_glib.h" + #endif +@@ -119,7 +119,7 @@ + if (type_ == TYPE_UI) { + #if defined(OS_MACOSX) + pump_ = base::MessagePumpMac::Create(); +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_BSD) + pump_ = new base::MessagePumpForUI(); + #endif // OS_LINUX + } else if (type_ == TYPE_IO) { +$NetBSD: patch-ipc_chromium_src_base_platform__file__posix.cc,v 1.1 2011/07/12 15:12:36 tnn Exp $ + +--- ipc/chromium/src/base/platform_file_posix.cc.orig 2011-06-15 21:57:27.000000000 +0000 ++++ ipc/chromium/src/base/platform_file_posix.cc +@@ -9,6 +9,7 @@ + #ifdef ANDROID + #include <linux/stat.h> + #endif ++#include <sys/stat.h> /* for S_IRUSR */ + + #include "base/logging.h" + #include "base/string_util.h" +$NetBSD: patch-ipc_chromium_src_base_platform__thread.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/platform_thread.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/platform_thread.h +@@ -25,6 +25,8 @@ typedef pthread_t PlatformThreadHandle; + #if defined(OS_LINUX) + #include <unistd.h> + typedef pid_t PlatformThreadId; ++#elif defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined (OS_NETBSD) ++typedef lwpid_t PlatformThreadId; + #elif defined(OS_MACOSX) + #include <mach/mach.h> + typedef mach_port_t PlatformThreadId; +$NetBSD: patch-ipc_chromium_src_base_platform__thread__posix.cc,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- ipc/chromium/src/base/platform_thread_posix.cc.orig 2012-03-13 01:36:53.000000000 +0000 ++++ ipc/chromium/src/base/platform_thread_posix.cc +@@ -9,9 +9,18 @@ + + #if defined(OS_MACOSX) + #include <mach/mach.h> ++#elif defined(OS_NETBSD) ++#include <lwp.h> + #elif defined(OS_LINUX) + #include <sys/syscall.h> + #include <unistd.h> ++#elif defined(OS_DRAGONFLY) ++#include <unistd.h> ++#elif defined(OS_FREEBSD) ++_Pragma("GCC visibility push(default)") ++extern "C" int thr_self(long *); // XXX #include <sys/thr.h> ++_Pragma("GCC visibility pop") ++#include <pthread_np.h> + #endif + + #if defined(OS_MACOSX) +@@ -38,7 +45,19 @@ + // into the kernel. + #if defined(OS_MACOSX) + return mach_thread_self(); +-#elif defined (__OpenBSD__) ++#elif defined(OS_NETBSD) ++ return _lwp_self(); ++#elif defined(OS_DRAGONFLY) ++ return lwp_gettid(); ++#elif defined(OS_FREEBSD) ++# if __FreeBSD_version > 900030 ++ return pthread_getthreadid_np(); ++# else ++ long lwpid; ++ thr_self(&lwpid); ++ return lwpid; ++# endif ++#elif defined(OS_OPENBSD) + // TODO(BSD): find a better thread ID + return (intptr_t)(pthread_self()); + #elif defined(OS_LINUX) +$NetBSD: patch-ipc_chromium_src_base_process__util.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/process_util.h.orig 2011-12-21 00:28:19.000000000 +0100 ++++ ipc/chromium/src/base/process_util.h 2012-01-31 13:14:54.000000000 +0100 +@@ -280,6 +280,7 @@ class NamedProcessIterator { + const ProcessEntry* NextProcessEntry(); + + private: ++#if !defined(OS_BSD) + // Determines whether there's another process (regardless of executable) + // left in the list of all processes. Returns true and sets entry_ to + // that process's info if there is one, false otherwise. +@@ -292,18 +292,24 @@ + void InitProcessEntry(ProcessEntry* entry); + + std::wstring executable_name_; ++#endif + + #if defined(OS_WIN) + HANDLE snapshot_; + bool started_iteration_; + #elif defined(OS_LINUX) + DIR *procfs_dir_; ++#elif defined(OS_BSD) ++ std::vector<ProcessEntry> content; ++ size_t nextEntry; + #elif defined(OS_MACOSX) + std::vector<kinfo_proc> kinfo_procs_; + size_t index_of_kinfo_proc_; + #endif ++#if !defined(OS_BSD) + ProcessEntry entry_; + const ProcessFilter* filter_; ++#endif + + DISALLOW_EVIL_CONSTRUCTORS(NamedProcessIterator); + }; +$NetBSD: patch-ipc_chromium_src_base_process__util__bsd.cc,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- ipc/chromium/src/base/process_util_bsd.cc.orig 2012-04-01 00:04:28.000000000 +0000 ++++ ipc/chromium/src/base/process_util_bsd.cc +@@ -0,0 +1,326 @@ ++// Copyright (c) 2008 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. ++ ++// derived from process_util_linux.cc and process_util_mac.cc ++ ++#include "base/process_util.h" ++ ++#include <ctype.h> ++#include <fcntl.h> ++#include <unistd.h> ++#include <string> ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++/* DragonFly, as of v3.0.1, and FreeBSD 9.0-RELEASE do not explicitly mark symbols public */ ++#define PRE_SYS_INCLUDE _Pragma("GCC visibility push(default)") ++#define POST_SYS_INCLUDE _Pragma("GCC visibility pop") ++#else ++#define PRE_SYS_INCLUDE ++#define POST_SYS_INCLUDE ++#endif ++PRE_SYS_INCLUDE ++#include <kvm.h> ++POST_SYS_INCLUDE ++#include <sys/sysctl.h> ++#include <sys/types.h> ++#include <sys/wait.h> ++#if defined(OS_DRAGONFLY) ++PRE_SYS_INCLUDE ++#include <sys/user.h> ++POST_SYS_INCLUDE ++#define HAVE_POSIX_SPAWN 1 ++#endif ++#if defined(OS_FREEBSD) ++PRE_SYS_INCLUDE ++#include <sys/user.h> ++POST_SYS_INCLUDE ++#endif ++ ++#include "base/debug_util.h" ++#include "base/eintr_wrapper.h" ++#include "base/file_util.h" ++#include "base/logging.h" ++#include "base/string_tokenizer.h" ++#include "base/string_util.h" ++ ++#if defined(OS_NETBSD) ++#include <sys/param.h> ++#if __NetBSD_Version__ >= 600000000 ++#define HAVE_POSIX_SPAWN 1 ++#endif ++#endif ++ ++#ifdef HAVE_POSIX_SPAWN ++PRE_SYS_INCLUDE ++#include <spawn.h> ++POST_SYS_INCLUDE ++extern "C" char **environ __dso_public; ++#endif ++ ++namespace { ++ ++enum ParsingState { ++ KEY_NAME, ++ KEY_VALUE ++}; ++ ++static mozilla::EnvironmentLog gProcessLog("MOZ_PROCESS_LOG"); ++ ++} // namespace ++ ++namespace base { ++ ++#ifdef HAVE_POSIX_SPAWN ++ ++void FreeEnvVarsArray(char* array[], int length) ++{ ++ for (int i = 0; i < length; i++) { ++ free(array[i]); ++ } ++ delete[] array; ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ bool wait, ProcessHandle* process_handle) { ++ return LaunchApp(argv, fds_to_remap, environment_map(), ++ wait, process_handle); ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ const environment_map& env_vars_to_set, ++ bool wait, ProcessHandle* process_handle, ++ ProcessArchitecture arch) { ++ bool retval = true; ++ ++ char* argv_copy[argv.size() + 1]; ++ for (size_t i = 0; i < argv.size(); i++) { ++ argv_copy[i] = const_cast<char*>(argv[i].c_str()); ++ } ++ argv_copy[argv.size()] = NULL; ++ ++ // Make sure we don't leak any FDs to the child process by marking all FDs ++ // as close-on-exec. ++ SetAllFDsToCloseOnExec(); ++ ++ // Copy environment to a new char array and add the variables ++ // in env_vars_to_set. ++ // Existing variables are overwritten by env_vars_to_set. ++ int pos = 0; ++ environment_map combined_env_vars = env_vars_to_set; ++ while(environ[pos] != NULL) { ++ std::string varString = environ[pos]; ++ std::string varName = varString.substr(0, varString.find_first_of('=')); ++ std::string varValue = varString.substr(varString.find_first_of('=') + 1); ++ if (combined_env_vars.find(varName) == combined_env_vars.end()) { ++ combined_env_vars[varName] = varValue; ++ } ++ pos++; ++ } ++ int varsLen = combined_env_vars.size() + 1; ++ ++ char** vars = new char*[varsLen]; ++ int i = 0; ++ for (environment_map::const_iterator it = combined_env_vars.begin(); ++ it != combined_env_vars.end(); ++it) { ++ std::string entry(it->first); ++ entry += "="; ++ entry += it->second; ++ vars[i] = strdup(entry.c_str()); ++ i++; ++ } ++ vars[i] = NULL; ++ ++ posix_spawn_file_actions_t file_actions; ++ if (posix_spawn_file_actions_init(&file_actions) != 0) { ++ FreeEnvVarsArray(vars, varsLen); ++ return false; ++ } ++ ++ // Turn fds_to_remap array into a set of dup2 calls. ++ for (file_handle_mapping_vector::const_iterator it = fds_to_remap.begin(); ++ it != fds_to_remap.end(); ++ ++it) { ++ int src_fd = it->first; ++ int dest_fd = it->second; ++ ++ if (src_fd == dest_fd) { ++ int flags = fcntl(src_fd, F_GETFD); ++ if (flags != -1) { ++ fcntl(src_fd, F_SETFD, flags & ~FD_CLOEXEC); ++ } ++ } else { ++ if (posix_spawn_file_actions_adddup2(&file_actions, src_fd, dest_fd) != 0) { ++ posix_spawn_file_actions_destroy(&file_actions); ++ FreeEnvVarsArray(vars, varsLen); ++ return false; ++ } ++ } ++ } ++ ++ pid_t pid = 0; ++ int spawn_succeeded = (posix_spawnp(&pid, ++ argv_copy[0], ++ &file_actions, ++ NULL, ++ argv_copy, ++ vars) == 0); ++ ++ FreeEnvVarsArray(vars, varsLen); ++ ++ posix_spawn_file_actions_destroy(&file_actions); ++ ++ bool process_handle_valid = pid > 0; ++ if (!spawn_succeeded || !process_handle_valid) { ++ retval = false; ++ } else { ++ if (wait) ++ HANDLE_EINTR(waitpid(pid, 0, 0)); ++ ++ if (process_handle) ++ *process_handle = pid; ++ } ++ ++ return retval; ++} ++ ++bool LaunchApp(const CommandLine& cl, ++ bool wait, bool start_hidden, ProcessHandle* process_handle) { ++ // TODO(playmobil): Do we need to respect the start_hidden flag? ++ file_handle_mapping_vector no_files; ++ return LaunchApp(cl.argv(), no_files, wait, process_handle); ++} ++ ++#else // no posix_spawn, use fork/exec ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ bool wait, ProcessHandle* process_handle) { ++ return LaunchApp(argv, fds_to_remap, environment_map(), ++ wait, process_handle); ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ const environment_map& env_vars_to_set, ++ bool wait, ProcessHandle* process_handle, ++ ProcessArchitecture arch) { ++ scoped_array<char*> argv_cstr(new char*[argv.size() + 1]); ++ // Illegal to allocate memory after fork and before execvp ++ InjectiveMultimap fd_shuffle1, fd_shuffle2; ++ fd_shuffle1.reserve(fds_to_remap.size()); ++ fd_shuffle2.reserve(fds_to_remap.size()); ++ ++ pid_t pid = fork(); ++ if (pid < 0) ++ return false; ++ ++ if (pid == 0) { ++ for (file_handle_mapping_vector::const_iterator ++ it = fds_to_remap.begin(); it != fds_to_remap.end(); ++it) { ++ fd_shuffle1.push_back(InjectionArc(it->first, it->second, false)); ++ fd_shuffle2.push_back(InjectionArc(it->first, it->second, false)); ++ } ++ ++ if (!ShuffleFileDescriptors(&fd_shuffle1)) ++ _exit(127); ++ ++ CloseSuperfluousFds(fd_shuffle2); ++ ++ for (environment_map::const_iterator it = env_vars_to_set.begin(); ++ it != env_vars_to_set.end(); ++it) { ++ if (setenv(it->first.c_str(), it->second.c_str(), 1/*overwrite*/)) ++ _exit(127); ++ } ++ ++ for (size_t i = 0; i < argv.size(); i++) ++ argv_cstr[i] = const_cast<char*>(argv[i].c_str()); ++ argv_cstr[argv.size()] = NULL; ++ execvp(argv_cstr[0], argv_cstr.get()); ++ // if we get here, we're in serious trouble and should complain loudly ++ DLOG(ERROR) << "FAILED TO exec() CHILD PROCESS, path: " << argv_cstr[0]; ++ exit(127); ++ } else { ++ gProcessLog.print("==> process %d launched child process %d\n", ++ GetCurrentProcId(), pid); ++ if (wait) ++ HANDLE_EINTR(waitpid(pid, 0, 0)); ++ ++ if (process_handle) ++ *process_handle = pid; ++ } ++ ++ return true; ++} ++ ++bool LaunchApp(const CommandLine& cl, ++ bool wait, bool start_hidden, ++ ProcessHandle* process_handle) { ++ file_handle_mapping_vector no_files; ++ return LaunchApp(cl.argv(), no_files, wait, process_handle); ++} ++ ++#endif ++ ++NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name, ++ const ProcessFilter* filter) ++{ ++ int numEntries; ++ kvm_t *kvm; ++ std::string exe(WideToASCII(executable_name)); ++ ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++ kvm = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL); ++ struct kinfo_proc* procs = kvm_getprocs(kvm, KERN_PROC_UID, getuid(), &numEntries); ++ if (procs != NULL && numEntries > 0) { ++ for (int i = 0; i < numEntries; i++) { ++# if defined(OS_DRAGONFLY) ++ if (exe != procs[i].kp_comm) continue; ++ if (filter && !filter->Includes(procs[i].kp_pid, procs[i].kp_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].kp_pid; ++ e.ppid = procs[i].kp_ppid; ++ strlcpy(e.szExeFile, procs[i].kp_comm, sizeof e.szExeFile); ++ content.push_back(e); ++# elif defined(OS_FREEBSD) ++ if (exe != procs[i].ki_comm) continue; ++ if (filter && !filter->Includes(procs[i].ki_pid, procs[i].ki_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].ki_pid; ++ e.ppid = procs[i].ki_ppid; ++ strlcpy(e.szExeFile, procs[i].ki_comm, sizeof e.szExeFile); ++ content.push_back(e); ++# endif ++#else ++ kvm = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL); ++ struct kinfo_proc2* procs = kvm_getproc2(kvm, KERN_PROC_UID, getuid(), sizeof(struct kinfo_proc2), &numEntries); ++ if (procs != NULL && numEntries > 0) { ++ for (int i = 0; i < numEntries; i++) { ++ if (exe != procs[i].p_comm) continue; ++ if (filter && !filter->Includes(procs[i].p_pid, procs[i].p_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].p_pid; ++ e.ppid = procs[i].p_ppid; ++ strlcpy(e.szExeFile, procs[i].p_comm, sizeof e.szExeFile); ++ content.push_back(e); ++#endif ++ } ++ } ++ nextEntry = 0; ++ kvm_close(kvm); ++} ++ ++NamedProcessIterator::~NamedProcessIterator() { ++} ++ ++const ProcessEntry* NamedProcessIterator::NextProcessEntry() { ++ if (nextEntry >= content.size()) return NULL; ++ return &content[nextEntry++]; ++} ++ ++bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { ++ return false; ++} ++ ++} // namespace base +$NetBSD: patch-ipc_chromium_src_base_process__util__posix.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/process_util_posix.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/process_util_posix.cc +@@ -116,6 +116,11 @@ void CloseSuperfluousFds(const base::Inj + #elif defined(OS_MACOSX) + static const rlim_t kSystemDefaultMaxFds = 256; + static const char kFDDir[] = "/dev/fd"; ++#elif defined(OS_BSD) ++ // the getrlimit below should never fail, so whatever .. ++ static const rlim_t kSystemDefaultMaxFds = 1024; ++ // at least /dev/fd will exist ++ static const char kFDDir[] = "/dev/fd"; + #endif + + // Get the maximum number of FDs possible. +@@ -199,7 +204,7 @@ void CloseSuperfluousFds(const base::Inj + void SetAllFDsToCloseOnExec() { + #if defined(OS_LINUX) + const char fd_dir[] = "/proc/self/fd"; +-#elif defined(OS_MACOSX) ++#elif defined(OS_MACOSX) || defined(OS_BSD) + const char fd_dir[] = "/dev/fd"; + #endif + ScopedDIR dir_closer(opendir(fd_dir)); +$NetBSD: patch-ipc_chromium_src_base_sys__info__posix.cc,v 1.2 2011/11/27 13:09:00 tnn Exp $ + +--- ipc/chromium/src/base/sys_info_posix.cc.orig 2011-11-04 21:34:00.000000000 +0000 ++++ ipc/chromium/src/base/sys_info_posix.cc +@@ -18,6 +18,11 @@ + #include <mach/mach_init.h> + #endif + ++#if defined(OS_NETBSD) ++#include <sys/param.h> ++#include <sys/sysctl.h> ++#endif ++ + #include "base/logging.h" + #include "base/string_util.h" + +@@ -26,7 +31,11 @@ namespace base { + int SysInfo::NumberOfProcessors() { + // It seems that sysconf returns the number of "logical" processors on both + // mac and linux. So we get the number of "online logical" processors. ++#ifdef _SC_NPROCESSORS_ONLN + static long res = sysconf(_SC_NPROCESSORS_ONLN); ++#else ++ static long res = 1; ++#endif + if (res == -1) { + NOTREACHED(); + return 1; +@@ -52,6 +61,20 @@ int64 SysInfo::AmountOfPhysicalMemory() + } + + return static_cast<int64>(hostinfo.max_mem); ++#elif defined(OS_NETBSD) ++ int mib[2]; ++ int rc; ++ int64_t memSize; ++ size_t len = sizeof(memSize); ++ ++ mib[0] = CTL_HW; ++ mib[1] = HW_PHYSMEM64; ++ rc = sysctl( mib, 2, &memSize, &len, NULL, 0 ); ++ if (-1 != rc) { ++ return memSize; ++ } ++ return 0; ++ + #else + long pages = sysconf(_SC_PHYS_PAGES); + long page_size = sysconf(_SC_PAGE_SIZE); +$NetBSD: patch-ipc_chromium_src_base_third__party_nspr_prcpucfg.h,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/third_party/nspr/prcpucfg.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/third_party/nspr/prcpucfg.h +@@ -34,7 +34,7 @@ + #include "base/third_party/nspr/prcpucfg_win.h" + #elif defined(__APPLE__) + #include "base/third_party/nspr/prcpucfg_mac.h" +-#elif defined(__linux__) || defined(ANDROID) ++#elif defined(__linux__) || defined(ANDROID) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) + #include "base/third_party/nspr/prcpucfg_linux.h" + #elif defined(__OpenBSD__) + #include "base/third_party/nspr/prcpucfg_openbsd.h" +$NetBSD: patch-ipc_chromium_src_base_third__party_nspr_prtime.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/third_party/nspr/prtime.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/third_party/nspr/prtime.cc +@@ -212,7 +212,7 @@ PR_ImplodeTime(const PRExplodedTime *exp + LL_ADD(retVal, retVal, temp); + + return retVal; +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_DRAGONFLY) + struct tm exp_tm = {0}; + exp_tm.tm_sec = exploded->tm_sec; + exp_tm.tm_min = exploded->tm_min; +@@ -245,6 +245,24 @@ PR_ImplodeTime(const PRExplodedTime *exp + result *= kSecondsToMicroseconds; + result += exploded->tm_usec; + return result; ++#elif defined(OS_FREEBSD) || defined(OS_NETBSD) ++ struct tm exp_tm = {0}; ++ exp_tm.tm_sec = exploded->tm_sec; ++ exp_tm.tm_min = exploded->tm_min; ++ exp_tm.tm_hour = exploded->tm_hour; ++ exp_tm.tm_mday = exploded->tm_mday; ++ exp_tm.tm_mon = exploded->tm_month; ++ exp_tm.tm_year = exploded->tm_year - 1900; ++ ++ // time_t is 64bit ++ time_t absolute_time = timegm(&exp_tm); ++ ++ PRTime result = static_cast<PRTime>(absolute_time); ++ result -= exploded->tm_params.tp_gmt_offset + ++ exploded->tm_params.tp_dst_offset; ++ result *= kSecondsToMicroseconds; ++ result += exploded->tm_usec; ++ return result; + #else + #error No PR_ImplodeTime implemented on your platform. + #endif +diff --git ipc/chromium/src/base/time_posix.cc ipc/chromium/src/base/time_posix.cc +index abf2a56..48791f6 100644 +--- ipc/chromium/src/base/time_posix.cc ++++ ipc/chromium/src/base/time_posix.cc +@@ -167,7 +167,7 @@ TimeTicks TimeTicks::Now() { + // With numer and denom = 1 (the expected case), the 64-bit absolute time + // reported in nanoseconds is enough to last nearly 585 years. + +-#elif defined(__OpenBSD__) || defined(OS_POSIX) && \ ++#elif defined(OS_OPENBSD) || defined(OS_POSIX) && \ + defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 + + struct timespec ts; +$NetBSD: patch-ipc_chromium_src_build_build__config.h,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- ipc/chromium/src/build/build_config.h.orig 2012-03-13 01:36:53.000000000 +0000 ++++ ipc/chromium/src/build/build_config.h +@@ -19,17 +19,23 @@ + #define OS_MACOSX 1 + #elif defined(__linux__) || defined(ANDROID) + #define OS_LINUX 1 ++#elif defined(__NetBSD__) ++#define OS_NETBSD 1 ++#elif defined(__DragonFly__) ++#define OS_DRAGONFLY 1 + #elif defined(__OpenBSD__) + #define OS_OPENBSD 1 + #elif defined(_WIN32) + #define OS_WIN 1 ++#elif defined(__FreeBSD__) ++#define OS_FREEBSD 1 + #else + #error Please add support for your platform in build/build_config.h + #endif + + // For access to standard POSIX features, use OS_POSIX instead of a more + // specific macro. +-#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_OPENBSD) ++#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_BSD) + #define OS_POSIX 1 + #endif + +diff --git ipc/chromium/src/chrome/common/ipc_channel_posix.cc ipc/chromium/src/chrome/common/ipc_channel_posix.cc +index bd866ee..2ea5b19 100644 +--- ipc/chromium/src/chrome/common/ipc_channel_posix.cc ++++ ipc/chromium/src/chrome/common/ipc_channel_posix.cc +@@ -7,6 +7,7 @@ + #include <errno.h> + #include <fcntl.h> + #include <stddef.h> ++#include <unistd.h> + #include <sys/types.h> + #include <sys/socket.h> + #include <sys/stat.h> +$NetBSD: patch-ipc_chromium_src_chrome_common_ipc__channel__posix.h,v 1.1 2011/07/11 12:46:14 tnn Exp $ + +--- ipc/chromium/src/chrome/common/ipc_channel_posix.h.orig 2011-06-15 21:57:27.000000000 +0000 ++++ ipc/chromium/src/chrome/common/ipc_channel_posix.h +@@ -92,7 +92,7 @@ class Channel::ChannelImpl : public Mess + }; + + // This is a control message buffer large enough to hold kMaxReadFDs +-#if defined(OS_MACOSX) ++#if defined(OS_MACOSX) || defined(OS_NETBSD) + // TODO(agl): OSX appears to have non-constant CMSG macros! + char input_cmsg_buf_[1024]; + #else +$NetBSD: patch-ipc_chromium_src_chrome_common_ipc__message__utils.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/chrome/common/ipc_message_utils.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/chrome/common/ipc_message_utils.h +@@ -195,7 +195,7 @@ + }; + #endif + +-#if !(defined(OS_MACOSX) || defined(OS_OPENBSD) || defined(OS_WIN) || (defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)) || defined(ARCH_CPU_S390)) ++#if !(defined(OS_MACOSX) || defined(OS_OPENBSD) || defined(OS_WIN) || ((defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined(OS_NETBSD) || defined(OS_LINUX)) && defined(ARCH_CPU_64_BITS)) || defined(ARCH_CPU_S390)) + // There size_t is a synonym for |unsigned long| ... + template <> + struct ParamTraits<size_t> { +@@ -248,7 +248,7 @@ + }; + #endif // defined(OS_MACOSX) + +-#if !(defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)) ++#if !((defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined(OS_NETBSD) || defined(OS_LINUX)) && defined(ARCH_CPU_64_BITS)) + // int64 is |long int| on 64-bit systems, uint64 is |unsigned long| + template <> + struct ParamTraits<int64> { +$NetBSD: patch-ipc_chromium_src_chrome_common_transport__dib.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/chrome/common/transport_dib.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/chrome/common/transport_dib.h +@@ -7,7 +7,7 @@ + + #include "base/basictypes.h" + +-#if defined(OS_WIN) || defined(OS_MACOSX) ++#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + #include "base/shared_memory.h" + #endif + +@@ -66,7 +66,7 @@ class TransportDIB { + uint32 sequence_num; + }; + typedef HandleAndSequenceNum Id; +-#elif defined(OS_MACOSX) ++#elif defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + typedef base::SharedMemoryHandle Handle; + // On Mac, the inode number of the backing file is used as an id. + typedef base::SharedMemoryId Id; +@@ -108,7 +108,7 @@ class TransportDIB { + + private: + TransportDIB(); +-#if defined(OS_WIN) || defined(OS_MACOSX) ++#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + explicit TransportDIB(base::SharedMemoryHandle dib); + base::SharedMemory shared_memory_; + uint32 sequence_num_; +$NetBSD: patch-ipc_glue_GeckoChildProcessHost.cpp,v 1.2 2012/03/15 08:30:06 ryoon Exp $ + +--- ipc/glue/GeckoChildProcessHost.cpp.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/glue/GeckoChildProcessHost.cpp +@@ -430,7 +430,7 @@ + // and passing wstrings from one config to the other is unsafe. So + // we split the logic here. + +-#if defined(OS_LINUX) || defined(OS_MACOSX) ++#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD) + base::environment_map newEnvVars; + // XPCOM may not be initialized in some subprocesses. We don't want + // to initialize XPCOM just for the directory service, especially +@@ -445,8 +445,8 @@ + if (NS_SUCCEEDED(rv)) { + nsCString path; + greDir->GetNativePath(path); +-# ifdef OS_LINUX +-# ifdef ANDROID ++# if defined(OS_LINUX) || defined(OS_BSD) ++# if defined(ANDROID) || defined(OS_BSD) + path += "/lib"; + # endif // ANDROID + const char *ld_library_path = PR_GetEnv("LD_LIBRARY_PATH"); +@@ -557,7 +557,7 @@ + childArgv.push_back(pidstring); + + #if defined(MOZ_CRASHREPORTER) +-# if defined(OS_LINUX) ++# if defined(OS_LINUX) || defined(OS_BSD) + int childCrashFd, childCrashRemapFd; + if (!CrashReporter::CreateNotificationPipeForChild( + &childCrashFd, &childCrashRemapFd)) +@@ -594,7 +594,7 @@ + #endif + + base::LaunchApp(childArgv, mFileMap, +-#if defined(OS_LINUX) || defined(OS_MACOSX) ++#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD) + newEnvVars, + #endif + false, &process, arch); +$NetBSD: patch-mm,v 1.13 2012/06/05 18:09:21 ryoon Exp $ + +--- toolkit/library/Makefile.in.orig 2012-05-23 18:57:09.000000000 +0000 ++++ toolkit/library/Makefile.in +@@ -534,6 +538,10 @@ EXTRA_DSO_LDOPTS += -lelf -ldemangle + endif + endif + ++ifneq (,$(filter DragonFly FreeBSD NetBSD,$(OS_ARCH))) ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++endif ++ + ifeq ($(OS_ARCH),WINNT) + OS_LIBS += $(call EXPAND_LIBNAME,shell32 ole32 version winspool comdlg32 imm32 msimg32 shlwapi psapi ws2_32 dbghelp rasapi32 rasdlg iphlpapi uxtheme setupapi secur32 sensorsapi portabledeviceguids windowscodecs wininet) + ifdef ACCESSIBILITY Deleted: branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-dir_reader_linux.h ============================================================================== --- branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-dir_reader_linux.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,52 +0,0 @@ ---- ipc/chromium/src/base/dir_reader_linux.h~ -+++ ipc/chromium/src/base/dir_reader_linux.h -@@ -12,6 +12,10 @@ - #include <sys/syscall.h> - #include <unistd.h> - -+#if defined(__FreeBSD__) -+#include <sys/dirent.h> -+#endif -+ - #include "base/logging.h" - #include "base/eintr_wrapper.h" - -@@ -19,6 +23,9 @@ - - namespace base { - -+#if defined(__FreeBSD__) -+#define linux_dirent struct dirent -+#else - struct linux_dirent { - uint64_t d_ino; - int64_t d_off; -@@ -26,11 +33,16 @@ struct linux_dirent { - unsigned char d_type; - char d_name[0]; - }; -+#endif - - class DirReaderLinux { - public: - explicit DirReaderLinux(const char* directory_path) -+#ifdef O_DIRECTORY - : fd_(open(directory_path, O_RDONLY | O_DIRECTORY)), -+#else -+ : fd_(open(directory_path, O_RDONLY)), -+#endif - offset_(0), - size_(0) { - memset(buf_, 0, sizeof(buf_)); -@@ -57,7 +69,11 @@ class DirReaderLinux { - if (offset_ != size_) - return true; - -+#if !defined(__FreeBSD__) - const int r = syscall(__NR_getdents64, fd_, buf_, sizeof(buf_)); -+#else -+ const int r = syscall(SYS_getdents, fd_, buf_, sizeof(buf_)); -+#endif - if (r == 0) - return false; - if (r == -1) { Modified: branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-file_util_linux.cc ============================================================================== --- branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-file_util_linux.cc Mon Jul 23 13:52:35 2012 (r886) +++ branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-file_util_linux.cc Mon Jul 23 22:39:41 2012 (r887) @@ -6,14 +6,3 @@ #include <fcntl.h> +#include <unistd.h> - #include <string> - #include <vector> -@@ -28,7 +29,7 @@ bool GetShmemTempDir(FilePath* path) { - #ifdef ANDROID - return GetTempDir(path); - #else -- *path = FilePath("/dev/shm"); -+ *path = FilePath("/tmp"); - return true; - #endif - } Deleted: branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-file_util_posix.cc ============================================================================== --- branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-file_util_posix.cc Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- ipc/chromium/src/base/file_util_posix.cc~ -+++ ipc/chromium/src/base/file_util_posix.cc -@@ -31,7 +31,7 @@ - #include "base/time.h" - - // FreeBSD/OpenBSD lacks stat64, but its stat handles files >2GB just fine --#if defined(OS_FREEBSD) || defined(OS_OPENBSD) -+#if defined(__FreeBSD__) || defined(OS_OPENBSD) - #define stat64 stat - #endif - Deleted: branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-platform_thread_posix.cc ============================================================================== --- branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-platform_thread_posix.cc Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,25 +0,0 @@ ---- ipc/chromium/src/base/platform_thread_posix.cc~ -+++ ipc/chromium/src/base/platform_thread_posix.cc -@@ -11,6 +11,7 @@ - #include <mach/mach.h> - #elif defined(OS_LINUX) - #include <sys/syscall.h> -+#include <pthread_np.h> - #include <unistd.h> - #endif - -@@ -34,7 +35,13 @@ PlatformThreadId PlatformThread::Current - #if defined(OS_MACOSX) - return mach_thread_self(); - #elif defined(OS_LINUX) -- return syscall(__NR_gettid); -+#if __FreeBSD_version > 900030 -+ return pthread_getthreadid_np(); -+#else -+ long tid; -+ syscall(SYS_thr_self, &tid); -+ return tid; -+#endif - #endif - } - Deleted: branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h ============================================================================== --- branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- ipc/chromium/src/base/third_party/nspr/prcpucfg.h~ -+++ ipc/chromium/src/base/third_party/nspr/prcpucfg.h -@@ -34,7 +34,7 @@ - #include "base/third_party/nspr/prcpucfg_win.h" - #elif defined(__APPLE__) - #include "base/third_party/nspr/prcpucfg_mac.h" --#elif defined(__linux__) || defined(ANDROID) -+#elif defined(__FreeBSD__) || defined(ANDROID) - #include "base/third_party/nspr/prcpucfg_linux.h" - #else - #error Provide a prcpucfg.h appropriate for your platform Deleted: branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-build-build_config.h ============================================================================== --- branches/experimental/www/firefox-esr/files/patch-ipc-chromium-src-build-build_config.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- ipc/chromium/src/build/build_config.h~ -+++ ipc/chromium/src/build/build_config.h -@@ -17,7 +17,7 @@ - // A set of macros to use for platform detection. - #if defined(__APPLE__) - #define OS_MACOSX 1 --#elif defined(__linux__) || defined(ANDROID) -+#elif defined(__linux__) || defined(ANDROID) || defined(__FreeBSD__) - #define OS_LINUX 1 - #elif defined(__OpenBSD__) - #define OS_OPENBSD 1 Deleted: branches/experimental/www/firefox-esr/files/patch-toolkit_library_Makefile.in ============================================================================== --- branches/experimental/www/firefox-esr/files/patch-toolkit_library_Makefile.in Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- toolkit/library/Makefile.in.orig 2010-01-11 12:13:08.000000000 -0500 -+++ toolkit/library/Makefile.in 2010-01-11 12:15:05.000000000 -0500 -@@ -181,7 +181,7 @@ - export:: $(RDF_UTIL_SRC_CPPSRCS) $(INTL_UNICHARUTIL_UTIL_CPPSRCS) - $(INSTALL) $^ . - --EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(EXTRA_DSO_LIBS) -+EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(EXTRA_DSO_LIBS) -lexecinfo - - ifdef MOZ_ENABLE_LIBXUL - include $(srcdir)/libxul-rules.mk Modified: branches/experimental/www/firefox/Makefile ============================================================================== --- branches/experimental/www/firefox/Makefile Mon Jul 23 13:52:35 2012 (r886) +++ branches/experimental/www/firefox/Makefile Mon Jul 23 22:39:41 2012 (r887) @@ -21,7 +21,6 @@ sqlite3>=3.7.11:${PORTSDIR}/databases/sqlite3 \ cairo>=1.10.2_1,1:${PORTSDIR}/graphics/cairo \ unzip:${PORTSDIR}/archivers/unzip -LIB_DEPENDS= execinfo.1:${PORTSDIR}/devel/libexecinfo CONFLICTS_BUILD= spidermonkey-* @@ -106,9 +105,6 @@ <${FILESDIR}/firefox.desktop.in >${WRKDIR}/${MOZILLA}.desktop post-patch: - @${GREP} -Flr \"/proc ${WRKSRC}/ipc/chromium/src/base | ${XARGS} ${REINPLACE_CMD} \ - -e 's|/proc/self/fd|/dev/fd|' \ - -e 's|/proc["/]|/compat/linux&|' @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \ ${WRKSRC}/browser/app/nsBrowserApp.cpp Added: branches/experimental/www/firefox/files/patch-bug753046 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/experimental/www/firefox/files/patch-bug753046 Mon Jul 23 22:39:41 2012 (r887) @@ -0,0 +1,1261 @@ +# Bug 753046 - Add support for DragonFly/NetBSD + +$NetBSD: patch-dom_plugins_ipc_PluginModuleChild.cpp,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- dom/plugins/ipc/PluginModuleChild.cpp.orig 2011-12-20 23:28:14.000000000 +0000 ++++ dom/plugins/ipc/PluginModuleChild.cpp +@@ -33,6 +33,8 @@ + #include "nsPluginsDir.h" + #include "nsXULAppAPI.h" + ++#include <unistd.h> ++ + #ifdef MOZ_X11 + # include "mozilla/X11Util.h" + #endif +@@ -228,7 +228,7 @@ PluginModuleChild::Init(const std::strin + + // TODO: use PluginPRLibrary here + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + mShutdownFunc = + (NP_PLUGINSHUTDOWN) PR_FindFunctionSymbol(mLibrary, "NP_Shutdown"); + +@@ -1790,7 +1790,7 @@ PluginModuleChild::AnswerNP_GetEntryPoin + PLUGIN_LOG_DEBUG_METHOD; + AssertPluginThread(); + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + return true; + #elif defined(OS_WIN) || defined(OS_MACOSX) + *_retval = mGetEntryPointsFunc(&mFunctions); +@@ -1823,7 +1823,7 @@ PluginModuleChild::AnswerNP_Initialize(N + SendBackUpXResources(FileDescriptor(xSocketFd, false/*don't close*/)); + #endif + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + *_retval = mInitializeFunc(&sBrowserFuncs, &mFunctions); + return true; + #elif defined(OS_WIN) || defined(OS_MACOSX) +$NetBSD: patch-dom_plugins_ipc_PluginModuleChild.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- dom/plugins/ipc/PluginModuleChild.h.orig 2011-12-20 23:28:14.000000000 +0000 ++++ dom/plugins/ipc/PluginModuleChild.h +@@ -340,7 +340,7 @@ private: + + // we get this from the plugin + NP_PLUGINSHUTDOWN mShutdownFunc; +-#ifdef OS_LINUX ++#if defined(OS_LINUX) || defined(OS_BSD) + NP_PLUGINUNIXINIT mInitializeFunc; + #elif defined(OS_WIN) || defined(OS_MACOSX) + NP_PLUGININIT mInitializeFunc; +$NetBSD: patch-ipc_chromium_Makefile.in,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/Makefile.in.orig 2012-02-16 06:40:33.000000000 +0000 ++++ ipc/chromium/Makefile.in +@@ -278,6 +278,34 @@ endif + + endif # } OS_LINUX + ++ifdef OS_BSD # { ++ ++CPPSRCS += \ ++ atomicops_internals_x86_gcc.cc \ ++ file_util_bsd.cc \ ++ process_util_bsd.cc \ ++ time_posix.cc \ ++ $(NULL) ++ ++ifdef MOZ_ENABLE_GTK2 ++CPPSRCS += \ ++ message_pump_glib.cc \ ++ $(NULL) ++endif ++ ++ifdef MOZ_ENABLE_QT ++MOCSRCS = \ ++ moc_message_pump_qt.cc \ ++ $(NULL) ++ ++CPPSRCS += \ ++ $(MOCSRCS) \ ++ message_pump_qt.cc \ ++ $(NULL) ++endif ++ ++endif # } OS_BSD ++ + # libevent + + ifndef MOZ_NATIVE_LIBEVENT # { +$NetBSD: patch-ipc_chromium_chromium-config.mk,v 1.2 2012/03/15 08:30:06 ryoon Exp $ + +--- ipc/chromium/chromium-config.mk.orig 2012-02-16 07:40:33.000000000 +0100 ++++ ipc/chromium/chromium-config.mk 2012-03-11 11:05:40.397182000 +0100 +@@ -56,17 +56,6 @@ + -I$(DEPTH)/ipc/ipdl/_ipdlheaders \ + $(NULL) + +-ifeq ($(OS_ARCH),Darwin) # { +- +-OS_MACOSX = 1 +-OS_POSIX = 1 +- +-DEFINES += \ +- -DOS_MACOSX=1 \ +- -DOS_POSIX=1 \ +- $(NULL) +- +-else # } { + ifeq ($(OS_ARCH),WINNT) # { + OS_LIBS += $(call EXPAND_LIBNAME,psapi shell32 dbghelp) + +@@ -93,13 +82,64 @@ + endif + + else # } { +- +-OS_LINUX = 1 + OS_POSIX = 1 ++DEFINES += -DOS_POSIX=1 ++ ++ifeq ($(OS_ARCH),Darwin) # { ++ ++OS_MACOSX = 1 ++DEFINES += \ ++ -DOS_MACOSX=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),DragonFly) # { ++ ++OS_DRAGONFLY = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_DRAGONFLY=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),FreeBSD) # { ++ ++OS_FREEBSD = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_FREEBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) + ++else # } { ++ifeq ($(OS_ARCH),NetBSD) # { ++ ++OS_NETBSD = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_NETBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),OpenBSD) # { ++ ++OS_OPENBSD = 1 ++OS_BSD = 1 ++DEFINES += \ ++ -DOS_OPENBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ ++OS_LINUX = 1 + DEFINES += \ + -DOS_LINUX=1 \ +- -DOS_POSIX=1 \ + $(NULL) + + # NB: to stop gcc warnings about exporting template instantiation +@@ -107,4 +147,8 @@ + + endif # } + endif # } ++endif # } ++endif # } ++endif # } ++endif # } + +$NetBSD: patch-ipc_chromium_src_base_base__paths.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/base_paths.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/base_paths.h +@@ -13,7 +13,7 @@ + #include "base/base_paths_win.h" + #elif defined(OS_MACOSX) + #include "base/base_paths_mac.h" +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_BSD) + #include "base/base_paths_linux.h" + #endif + #include "base/path_service.h" +$NetBSD: patch-ipc_chromium_src_base_debug__util__posic.cc,v 1.3 2012/04/01 15:18:45 ryoon Exp $ + +--- ipc/chromium/src/base/debug_util_posix.cc.orig 2012-03-13 01:36:53.000000000 +0000 ++++ ipc/chromium/src/base/debug_util_posix.cc +@@ -5,7 +5,7 @@ + #include "build/build_config.h" + #include "base/debug_util.h" + +-#define MOZ_HAVE_EXECINFO_H (!defined(ANDROID) && !defined(__OpenBSD__)) ++#define MOZ_HAVE_EXECINFO_H (defined(OS_LINUX) && !defined(ANDROID)) + + #include <errno.h> + #include <fcntl.h> +@@ -17,8 +17,13 @@ + #include <unistd.h> + #if MOZ_HAVE_EXECINFO_H + #include <execinfo.h> +-#include <sys/sysctl.h> + #endif ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++#include <sys/user.h> ++#elif defined(OS_FREEBSD) ++#include <sys/proc.h> ++#endif ++#include <sys/sysctl.h> + + #include "base/basictypes.h" + #include "base/eintr_wrapper.h" +@@ -32,7 +37,7 @@ bool DebugUtil::SpawnDebuggerOnProcess(u + return false; + } + +-#if defined(OS_MACOSX) ++#if defined(OS_MACOSX) || defined(OS_BSD) + + // Based on Apple's recommended method as described in + // http://developer.apple.com/qa/qa2004/qa1361.html +@@ -71,7 +76,13 @@ bool DebugUtil::BeingDebugged() { + + // This process is being debugged if the P_TRACED flag is set. + is_set = true; ++#if defined(OS_DRAGONFLY) ++ being_debugged = (info.kp_flags & P_TRACED) != 0; ++#elif defined(OS_FREEBSD) ++ being_debugged = (info.ki_flag & P_TRACED) != 0; ++#else + being_debugged = (info.kp_proc.p_flag & P_TRACED) != 0; ++#endif + return being_debugged; + } + +diff --git ipc/chromium/src/base/dir_reader_bsd.h ipc/chromium/src/base/dir_reader_bsd.h +new file mode 100644 +index 0000000..3fc1a87 +--- /dev/null ++++ ipc/chromium/src/base/dir_reader_bsd.h +@@ -0,0 +1,98 @@ ++// Copyright (c) 2010 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. ++ ++// derived from dir_reader_linux.h ++ ++#ifndef BASE_DIR_READER_BSD_H_ ++#define BASE_DIR_READER_BSD_H_ ++#pragma once ++ ++#include <dirent.h> ++#include <errno.h> ++#include <fcntl.h> ++#include <stdint.h> ++#include <unistd.h> ++ ++#include "base/logging.h" ++#include "base/eintr_wrapper.h" ++ ++// See the comments in dir_reader_posix.h about this. ++ ++namespace base { ++ ++class DirReaderBSD { ++ public: ++ explicit DirReaderBSD(const char* directory_path) ++#ifdef O_DIRECTORY ++ : fd_(open(directory_path, O_RDONLY | O_DIRECTORY)), ++#else ++ : fd_(open(directory_path, O_RDONLY)), ++#endif ++ offset_(0), ++ size_(0) { ++ memset(buf_, 0, sizeof(buf_)); ++ } ++ ++ ~DirReaderBSD() { ++ if (fd_ >= 0) { ++ if (HANDLE_EINTR(close(fd_))) ++ DLOG(ERROR) << "Failed to close directory handle"; ++ } ++ } ++ ++ bool IsValid() const { ++ return fd_ >= 0; ++ } ++ ++ // Move to the next entry returning false if the iteration is complete. ++ bool Next() { ++ if (size_) { ++ struct dirent* dirent = reinterpret_cast<struct dirent*>(&buf_[offset_]); ++ offset_ += dirent->d_reclen; ++ } ++ ++ if (offset_ != size_) ++ return true; ++ ++ const int r = getdirentries(fd_, buf_, sizeof(buf_), basep_); ++ if (r == 0) ++ return false; ++ if (r == -1) { ++ DLOG(ERROR) << "getdirentries returned an error: " << errno; ++ return false; ++ } ++ size_ = r; ++ offset_ = 0; ++ return true; ++ } ++ ++ const char* name() const { ++ if (!size_) ++ return NULL; ++ ++ const struct dirent* dirent = ++ reinterpret_cast<const struct dirent*>(&buf_[offset_]); ++ return dirent->d_name; ++ } ++ ++ int fd() const { ++ return fd_; ++ } ++ ++ static bool IsFallback() { ++ return false; ++ } ++ ++ private: ++ const int fd_; ++ char buf_[512]; ++ long *basep_; ++ size_t offset_, size_; ++ ++ DISALLOW_COPY_AND_ASSIGN(DirReaderBSD); ++}; ++ ++} // namespace base ++ ++#endif // BASE_DIR_READER_BSD_H_ +diff --git ipc/chromium/src/base/dir_reader_posix.h ipc/chromium/src/base/dir_reader_posix.h +index 9a34492..62b280c 100644 +--- ipc/chromium/src/base/dir_reader_posix.h ++++ ipc/chromium/src/base/dir_reader_posix.h +@@ -18,16 +18,20 @@ + // seems worse than falling back to enumerating all file descriptors so we will + // probably never implement this on the Mac. + +-#if defined(OS_LINUX) && !defined(OS_OPENBSD) ++#if defined(OS_LINUX) + #include "base/dir_reader_linux.h" ++#elif defined(OS_BSD) ++#include "base/dir_reader_bsd.h" + #else + #include "base/dir_reader_fallback.h" + #endif + + namespace base { + +-#if defined(OS_LINUX) && !defined(OS_OPENBSD) ++#if defined(OS_LINUX) + typedef DirReaderLinux DirReaderPosix; ++#elif defined(OS_BSD) ++typedef DirReaderBSD DirReaderPosix; + #else + typedef DirReaderFallback DirReaderPosix; + #endif +$NetBSD: patch-ipc_chromium_src_base_file__util.h,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/file_util.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/file_util.h +@@ -16,8 +16,8 @@ + #include <sys/stat.h> + #elif defined(OS_POSIX) + #include <sys/types.h> +-#include <fts.h> + #include <sys/stat.h> ++#include <fts.h> + #endif + + #include <stdio.h> +$NetBSD: patch-ipc_chromium_src_base_file__util__bsd.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/file_util_bsd.cc.orig 2012-01-07 18:21:18.000000000 +0000 ++++ ipc/chromium/src/base/file_util_bsd.cc +@@ -0,0 +1,80 @@ ++// Copyright (c) 2006-2008 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. ++ ++// this is a derivative of file_util_linux.cc ++ ++#include "base/file_util.h" ++ ++#include <fcntl.h> ++#include <unistd.h> ++ ++#include <string> ++#include <vector> ++ ++#include "base/eintr_wrapper.h" ++#include "base/file_path.h" ++#include "base/string_util.h" ++ ++namespace file_util { ++ ++bool GetTempDir(FilePath* path) { ++ const char* tmp = getenv("TMPDIR"); ++ if (tmp) ++ *path = FilePath(tmp); ++ else ++ *path = FilePath("/tmp"); ++ return true; ++} ++ ++bool GetShmemTempDir(FilePath* path) { ++ return GetTempDir(path); ++} ++ ++bool CopyFile(const FilePath& from_path, const FilePath& to_path) { ++ int infile = open(from_path.value().c_str(), O_RDONLY); ++ if (infile < 0) ++ return false; ++ ++ int outfile = creat(to_path.value().c_str(), 0666); ++ if (outfile < 0) { ++ close(infile); ++ return false; ++ } ++ ++ const size_t kBufferSize = 32768; ++ std::vector<char> buffer(kBufferSize); ++ bool result = true; ++ ++ while (result) { ++ ssize_t bytes_read = HANDLE_EINTR(read(infile, &buffer[0], buffer.size())); ++ if (bytes_read < 0) { ++ result = false; ++ break; ++ } ++ if (bytes_read == 0) ++ break; ++ // Allow for partial writes ++ ssize_t bytes_written_per_read = 0; ++ do { ++ ssize_t bytes_written_partial = HANDLE_EINTR(write( ++ outfile, ++ &buffer[bytes_written_per_read], ++ bytes_read - bytes_written_per_read)); ++ if (bytes_written_partial < 0) { ++ result = false; ++ break; ++ } ++ bytes_written_per_read += bytes_written_partial; ++ } while (bytes_written_per_read < bytes_read); ++ } ++ ++ if (HANDLE_EINTR(close(infile)) < 0) ++ result = false; ++ if (HANDLE_EINTR(close(outfile)) < 0) ++ result = false; ++ ++ return result; ++} ++ ++} // namespace file_util +$NetBSD: patch-ipc_chromium_src_base_file__util__posix.cc,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/file_util_posix.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/file_util_posix.cc +@@ -31,7 +31,7 @@ + #include "base/time.h" + + // FreeBSD/OpenBSD lacks stat64, but its stat handles files >2GB just fine +-#if defined(OS_FREEBSD) || defined(OS_OPENBSD) ++#ifndef OS_LINUX + #define stat64 stat + #endif + +$NetBSD: patch-ipc_chromium_src_base_message__loop.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/message_loop.cc.orig 2012-02-16 07:40:33.000000000 +0100 ++++ ipc/chromium/src/base/message_loop.cc 2012-02-21 21:24:41.000000000 +0100 +@@ -19,7 +19,7 @@ + #if defined(OS_POSIX) + #include "base/message_pump_libevent.h" + #endif +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + #ifdef MOZ_WIDGET_GTK2 + #include "base/message_pump_glib.h" + #endif +@@ -119,7 +119,7 @@ + if (type_ == TYPE_UI) { + #if defined(OS_MACOSX) + pump_ = base::MessagePumpMac::Create(); +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_BSD) + pump_ = new base::MessagePumpForUI(); + #endif // OS_LINUX + } else if (type_ == TYPE_IO) { +$NetBSD: patch-ipc_chromium_src_base_platform__file__posix.cc,v 1.1 2011/07/12 15:12:36 tnn Exp $ + +--- ipc/chromium/src/base/platform_file_posix.cc.orig 2011-06-15 21:57:27.000000000 +0000 ++++ ipc/chromium/src/base/platform_file_posix.cc +@@ -9,6 +9,7 @@ + #ifdef ANDROID + #include <linux/stat.h> + #endif ++#include <sys/stat.h> /* for S_IRUSR */ + + #include "base/logging.h" + #include "base/string_util.h" +$NetBSD: patch-ipc_chromium_src_base_platform__thread.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/platform_thread.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/platform_thread.h +@@ -25,6 +25,8 @@ typedef pthread_t PlatformThreadHandle; + #if defined(OS_LINUX) + #include <unistd.h> + typedef pid_t PlatformThreadId; ++#elif defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined (OS_NETBSD) ++typedef lwpid_t PlatformThreadId; + #elif defined(OS_MACOSX) + #include <mach/mach.h> + typedef mach_port_t PlatformThreadId; +$NetBSD: patch-ipc_chromium_src_base_platform__thread__posix.cc,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- ipc/chromium/src/base/platform_thread_posix.cc.orig 2012-03-13 01:36:53.000000000 +0000 ++++ ipc/chromium/src/base/platform_thread_posix.cc +@@ -9,9 +9,18 @@ + + #if defined(OS_MACOSX) + #include <mach/mach.h> ++#elif defined(OS_NETBSD) ++#include <lwp.h> + #elif defined(OS_LINUX) + #include <sys/syscall.h> + #include <unistd.h> ++#elif defined(OS_DRAGONFLY) ++#include <unistd.h> ++#elif defined(OS_FREEBSD) ++_Pragma("GCC visibility push(default)") ++extern "C" int thr_self(long *); // XXX #include <sys/thr.h> ++_Pragma("GCC visibility pop") ++#include <pthread_np.h> + #endif + + #if defined(OS_MACOSX) +@@ -38,7 +45,19 @@ + // into the kernel. + #if defined(OS_MACOSX) + return mach_thread_self(); +-#elif defined (__OpenBSD__) ++#elif defined(OS_NETBSD) ++ return _lwp_self(); ++#elif defined(OS_DRAGONFLY) ++ return lwp_gettid(); ++#elif defined(OS_FREEBSD) ++# if __FreeBSD_version > 900030 ++ return pthread_getthreadid_np(); ++# else ++ long lwpid; ++ thr_self(&lwpid); ++ return lwpid; ++# endif ++#elif defined(OS_OPENBSD) + // TODO(BSD): find a better thread ID + return (intptr_t)(pthread_self()); + #elif defined(OS_LINUX) +$NetBSD: patch-ipc_chromium_src_base_process__util.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/process_util.h.orig 2011-12-21 00:28:19.000000000 +0100 ++++ ipc/chromium/src/base/process_util.h 2012-01-31 13:14:54.000000000 +0100 +@@ -280,6 +280,7 @@ class NamedProcessIterator { + const ProcessEntry* NextProcessEntry(); + + private: ++#if !defined(OS_BSD) + // Determines whether there's another process (regardless of executable) + // left in the list of all processes. Returns true and sets entry_ to + // that process's info if there is one, false otherwise. +@@ -292,18 +292,24 @@ + void InitProcessEntry(ProcessEntry* entry); + + std::wstring executable_name_; ++#endif + + #if defined(OS_WIN) + HANDLE snapshot_; + bool started_iteration_; + #elif defined(OS_LINUX) + DIR *procfs_dir_; ++#elif defined(OS_BSD) ++ std::vector<ProcessEntry> content; ++ size_t nextEntry; + #elif defined(OS_MACOSX) + std::vector<kinfo_proc> kinfo_procs_; + size_t index_of_kinfo_proc_; + #endif ++#if !defined(OS_BSD) + ProcessEntry entry_; + const ProcessFilter* filter_; ++#endif + + DISALLOW_EVIL_CONSTRUCTORS(NamedProcessIterator); + }; +$NetBSD: patch-ipc_chromium_src_base_process__util__bsd.cc,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- ipc/chromium/src/base/process_util_bsd.cc.orig 2012-04-01 00:04:28.000000000 +0000 ++++ ipc/chromium/src/base/process_util_bsd.cc +@@ -0,0 +1,326 @@ ++// Copyright (c) 2008 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. ++ ++// derived from process_util_linux.cc and process_util_mac.cc ++ ++#include "base/process_util.h" ++ ++#include <ctype.h> ++#include <fcntl.h> ++#include <unistd.h> ++#include <string> ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++/* DragonFly, as of v3.0.1, and FreeBSD 9.0-RELEASE do not explicitly mark symbols public */ ++#define PRE_SYS_INCLUDE _Pragma("GCC visibility push(default)") ++#define POST_SYS_INCLUDE _Pragma("GCC visibility pop") ++#else ++#define PRE_SYS_INCLUDE ++#define POST_SYS_INCLUDE ++#endif ++PRE_SYS_INCLUDE ++#include <kvm.h> ++POST_SYS_INCLUDE ++#include <sys/sysctl.h> ++#include <sys/types.h> ++#include <sys/wait.h> ++#if defined(OS_DRAGONFLY) ++PRE_SYS_INCLUDE ++#include <sys/user.h> ++POST_SYS_INCLUDE ++#define HAVE_POSIX_SPAWN 1 ++#endif ++#if defined(OS_FREEBSD) ++PRE_SYS_INCLUDE ++#include <sys/user.h> ++POST_SYS_INCLUDE ++#endif ++ ++#include "base/debug_util.h" ++#include "base/eintr_wrapper.h" ++#include "base/file_util.h" ++#include "base/logging.h" ++#include "base/string_tokenizer.h" ++#include "base/string_util.h" ++ ++#if defined(OS_NETBSD) ++#include <sys/param.h> ++#if __NetBSD_Version__ >= 600000000 ++#define HAVE_POSIX_SPAWN 1 ++#endif ++#endif ++ ++#ifdef HAVE_POSIX_SPAWN ++PRE_SYS_INCLUDE ++#include <spawn.h> ++POST_SYS_INCLUDE ++extern "C" char **environ __dso_public; ++#endif ++ ++namespace { ++ ++enum ParsingState { ++ KEY_NAME, ++ KEY_VALUE ++}; ++ ++static mozilla::EnvironmentLog gProcessLog("MOZ_PROCESS_LOG"); ++ ++} // namespace ++ ++namespace base { ++ ++#ifdef HAVE_POSIX_SPAWN ++ ++void FreeEnvVarsArray(char* array[], int length) ++{ ++ for (int i = 0; i < length; i++) { ++ free(array[i]); ++ } ++ delete[] array; ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ bool wait, ProcessHandle* process_handle) { ++ return LaunchApp(argv, fds_to_remap, environment_map(), ++ wait, process_handle); ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ const environment_map& env_vars_to_set, ++ bool wait, ProcessHandle* process_handle, ++ ProcessArchitecture arch) { ++ bool retval = true; ++ ++ char* argv_copy[argv.size() + 1]; ++ for (size_t i = 0; i < argv.size(); i++) { ++ argv_copy[i] = const_cast<char*>(argv[i].c_str()); ++ } ++ argv_copy[argv.size()] = NULL; ++ ++ // Make sure we don't leak any FDs to the child process by marking all FDs ++ // as close-on-exec. ++ SetAllFDsToCloseOnExec(); ++ ++ // Copy environment to a new char array and add the variables ++ // in env_vars_to_set. ++ // Existing variables are overwritten by env_vars_to_set. ++ int pos = 0; ++ environment_map combined_env_vars = env_vars_to_set; ++ while(environ[pos] != NULL) { ++ std::string varString = environ[pos]; ++ std::string varName = varString.substr(0, varString.find_first_of('=')); ++ std::string varValue = varString.substr(varString.find_first_of('=') + 1); ++ if (combined_env_vars.find(varName) == combined_env_vars.end()) { ++ combined_env_vars[varName] = varValue; ++ } ++ pos++; ++ } ++ int varsLen = combined_env_vars.size() + 1; ++ ++ char** vars = new char*[varsLen]; ++ int i = 0; ++ for (environment_map::const_iterator it = combined_env_vars.begin(); ++ it != combined_env_vars.end(); ++it) { ++ std::string entry(it->first); ++ entry += "="; ++ entry += it->second; ++ vars[i] = strdup(entry.c_str()); ++ i++; ++ } ++ vars[i] = NULL; ++ ++ posix_spawn_file_actions_t file_actions; ++ if (posix_spawn_file_actions_init(&file_actions) != 0) { ++ FreeEnvVarsArray(vars, varsLen); ++ return false; ++ } ++ ++ // Turn fds_to_remap array into a set of dup2 calls. ++ for (file_handle_mapping_vector::const_iterator it = fds_to_remap.begin(); ++ it != fds_to_remap.end(); ++ ++it) { ++ int src_fd = it->first; ++ int dest_fd = it->second; ++ ++ if (src_fd == dest_fd) { ++ int flags = fcntl(src_fd, F_GETFD); ++ if (flags != -1) { ++ fcntl(src_fd, F_SETFD, flags & ~FD_CLOEXEC); ++ } ++ } else { ++ if (posix_spawn_file_actions_adddup2(&file_actions, src_fd, dest_fd) != 0) { ++ posix_spawn_file_actions_destroy(&file_actions); ++ FreeEnvVarsArray(vars, varsLen); ++ return false; ++ } ++ } ++ } ++ ++ pid_t pid = 0; ++ int spawn_succeeded = (posix_spawnp(&pid, ++ argv_copy[0], ++ &file_actions, ++ NULL, ++ argv_copy, ++ vars) == 0); ++ ++ FreeEnvVarsArray(vars, varsLen); ++ ++ posix_spawn_file_actions_destroy(&file_actions); ++ ++ bool process_handle_valid = pid > 0; ++ if (!spawn_succeeded || !process_handle_valid) { ++ retval = false; ++ } else { ++ if (wait) ++ HANDLE_EINTR(waitpid(pid, 0, 0)); ++ ++ if (process_handle) ++ *process_handle = pid; ++ } ++ ++ return retval; ++} ++ ++bool LaunchApp(const CommandLine& cl, ++ bool wait, bool start_hidden, ProcessHandle* process_handle) { ++ // TODO(playmobil): Do we need to respect the start_hidden flag? ++ file_handle_mapping_vector no_files; ++ return LaunchApp(cl.argv(), no_files, wait, process_handle); ++} ++ ++#else // no posix_spawn, use fork/exec ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ bool wait, ProcessHandle* process_handle) { ++ return LaunchApp(argv, fds_to_remap, environment_map(), ++ wait, process_handle); ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ const environment_map& env_vars_to_set, ++ bool wait, ProcessHandle* process_handle, ++ ProcessArchitecture arch) { ++ scoped_array<char*> argv_cstr(new char*[argv.size() + 1]); ++ // Illegal to allocate memory after fork and before execvp ++ InjectiveMultimap fd_shuffle1, fd_shuffle2; ++ fd_shuffle1.reserve(fds_to_remap.size()); ++ fd_shuffle2.reserve(fds_to_remap.size()); ++ ++ pid_t pid = fork(); ++ if (pid < 0) ++ return false; ++ ++ if (pid == 0) { ++ for (file_handle_mapping_vector::const_iterator ++ it = fds_to_remap.begin(); it != fds_to_remap.end(); ++it) { ++ fd_shuffle1.push_back(InjectionArc(it->first, it->second, false)); ++ fd_shuffle2.push_back(InjectionArc(it->first, it->second, false)); ++ } ++ ++ if (!ShuffleFileDescriptors(&fd_shuffle1)) ++ _exit(127); ++ ++ CloseSuperfluousFds(fd_shuffle2); ++ ++ for (environment_map::const_iterator it = env_vars_to_set.begin(); ++ it != env_vars_to_set.end(); ++it) { ++ if (setenv(it->first.c_str(), it->second.c_str(), 1/*overwrite*/)) ++ _exit(127); ++ } ++ ++ for (size_t i = 0; i < argv.size(); i++) ++ argv_cstr[i] = const_cast<char*>(argv[i].c_str()); ++ argv_cstr[argv.size()] = NULL; ++ execvp(argv_cstr[0], argv_cstr.get()); ++ // if we get here, we're in serious trouble and should complain loudly ++ DLOG(ERROR) << "FAILED TO exec() CHILD PROCESS, path: " << argv_cstr[0]; ++ exit(127); ++ } else { ++ gProcessLog.print("==> process %d launched child process %d\n", ++ GetCurrentProcId(), pid); ++ if (wait) ++ HANDLE_EINTR(waitpid(pid, 0, 0)); ++ ++ if (process_handle) ++ *process_handle = pid; ++ } ++ ++ return true; ++} ++ ++bool LaunchApp(const CommandLine& cl, ++ bool wait, bool start_hidden, ++ ProcessHandle* process_handle) { ++ file_handle_mapping_vector no_files; ++ return LaunchApp(cl.argv(), no_files, wait, process_handle); ++} ++ ++#endif ++ ++NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name, ++ const ProcessFilter* filter) ++{ ++ int numEntries; ++ kvm_t *kvm; ++ std::string exe(WideToASCII(executable_name)); ++ ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++ kvm = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL); ++ struct kinfo_proc* procs = kvm_getprocs(kvm, KERN_PROC_UID, getuid(), &numEntries); ++ if (procs != NULL && numEntries > 0) { ++ for (int i = 0; i < numEntries; i++) { ++# if defined(OS_DRAGONFLY) ++ if (exe != procs[i].kp_comm) continue; ++ if (filter && !filter->Includes(procs[i].kp_pid, procs[i].kp_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].kp_pid; ++ e.ppid = procs[i].kp_ppid; ++ strlcpy(e.szExeFile, procs[i].kp_comm, sizeof e.szExeFile); ++ content.push_back(e); ++# elif defined(OS_FREEBSD) ++ if (exe != procs[i].ki_comm) continue; ++ if (filter && !filter->Includes(procs[i].ki_pid, procs[i].ki_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].ki_pid; ++ e.ppid = procs[i].ki_ppid; ++ strlcpy(e.szExeFile, procs[i].ki_comm, sizeof e.szExeFile); ++ content.push_back(e); ++# endif ++#else ++ kvm = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL); ++ struct kinfo_proc2* procs = kvm_getproc2(kvm, KERN_PROC_UID, getuid(), sizeof(struct kinfo_proc2), &numEntries); ++ if (procs != NULL && numEntries > 0) { ++ for (int i = 0; i < numEntries; i++) { ++ if (exe != procs[i].p_comm) continue; ++ if (filter && !filter->Includes(procs[i].p_pid, procs[i].p_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].p_pid; ++ e.ppid = procs[i].p_ppid; ++ strlcpy(e.szExeFile, procs[i].p_comm, sizeof e.szExeFile); ++ content.push_back(e); ++#endif ++ } ++ } ++ nextEntry = 0; ++ kvm_close(kvm); ++} ++ ++NamedProcessIterator::~NamedProcessIterator() { ++} ++ ++const ProcessEntry* NamedProcessIterator::NextProcessEntry() { ++ if (nextEntry >= content.size()) return NULL; ++ return &content[nextEntry++]; ++} ++ ++bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { ++ return false; ++} ++ ++} // namespace base +$NetBSD: patch-ipc_chromium_src_base_process__util__posix.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/process_util_posix.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/process_util_posix.cc +@@ -116,6 +116,11 @@ void CloseSuperfluousFds(const base::Inj + #elif defined(OS_MACOSX) + static const rlim_t kSystemDefaultMaxFds = 256; + static const char kFDDir[] = "/dev/fd"; ++#elif defined(OS_BSD) ++ // the getrlimit below should never fail, so whatever .. ++ static const rlim_t kSystemDefaultMaxFds = 1024; ++ // at least /dev/fd will exist ++ static const char kFDDir[] = "/dev/fd"; + #endif + + // Get the maximum number of FDs possible. +@@ -199,7 +204,7 @@ void CloseSuperfluousFds(const base::Inj + void SetAllFDsToCloseOnExec() { + #if defined(OS_LINUX) + const char fd_dir[] = "/proc/self/fd"; +-#elif defined(OS_MACOSX) ++#elif defined(OS_MACOSX) || defined(OS_BSD) + const char fd_dir[] = "/dev/fd"; + #endif + ScopedDIR dir_closer(opendir(fd_dir)); +$NetBSD: patch-ipc_chromium_src_base_sys__info__posix.cc,v 1.2 2011/11/27 13:09:00 tnn Exp $ + +--- ipc/chromium/src/base/sys_info_posix.cc.orig 2011-11-04 21:34:00.000000000 +0000 ++++ ipc/chromium/src/base/sys_info_posix.cc +@@ -18,6 +18,11 @@ + #include <mach/mach_init.h> + #endif + ++#if defined(OS_NETBSD) ++#include <sys/param.h> ++#include <sys/sysctl.h> ++#endif ++ + #include "base/logging.h" + #include "base/string_util.h" + +@@ -26,7 +31,11 @@ namespace base { + int SysInfo::NumberOfProcessors() { + // It seems that sysconf returns the number of "logical" processors on both + // mac and linux. So we get the number of "online logical" processors. ++#ifdef _SC_NPROCESSORS_ONLN + static long res = sysconf(_SC_NPROCESSORS_ONLN); ++#else ++ static long res = 1; ++#endif + if (res == -1) { + NOTREACHED(); + return 1; +@@ -52,6 +61,20 @@ int64 SysInfo::AmountOfPhysicalMemory() + } + + return static_cast<int64>(hostinfo.max_mem); ++#elif defined(OS_NETBSD) ++ int mib[2]; ++ int rc; ++ int64_t memSize; ++ size_t len = sizeof(memSize); ++ ++ mib[0] = CTL_HW; ++ mib[1] = HW_PHYSMEM64; ++ rc = sysctl( mib, 2, &memSize, &len, NULL, 0 ); ++ if (-1 != rc) { ++ return memSize; ++ } ++ return 0; ++ + #else + long pages = sysconf(_SC_PHYS_PAGES); + long page_size = sysconf(_SC_PAGE_SIZE); +$NetBSD: patch-ipc_chromium_src_base_third__party_nspr_prcpucfg.h,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/third_party/nspr/prcpucfg.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/third_party/nspr/prcpucfg.h +@@ -34,7 +34,7 @@ + #include "base/third_party/nspr/prcpucfg_win.h" + #elif defined(__APPLE__) + #include "base/third_party/nspr/prcpucfg_mac.h" +-#elif defined(__linux__) || defined(ANDROID) ++#elif defined(__linux__) || defined(ANDROID) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) + #include "base/third_party/nspr/prcpucfg_linux.h" + #elif defined(__OpenBSD__) + #include "base/third_party/nspr/prcpucfg_openbsd.h" +$NetBSD: patch-ipc_chromium_src_base_third__party_nspr_prtime.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/third_party/nspr/prtime.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/third_party/nspr/prtime.cc +@@ -212,7 +212,7 @@ PR_ImplodeTime(const PRExplodedTime *exp + LL_ADD(retVal, retVal, temp); + + return retVal; +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_DRAGONFLY) + struct tm exp_tm = {0}; + exp_tm.tm_sec = exploded->tm_sec; + exp_tm.tm_min = exploded->tm_min; +@@ -245,6 +245,24 @@ PR_ImplodeTime(const PRExplodedTime *exp + result *= kSecondsToMicroseconds; + result += exploded->tm_usec; + return result; ++#elif defined(OS_FREEBSD) || defined(OS_NETBSD) ++ struct tm exp_tm = {0}; ++ exp_tm.tm_sec = exploded->tm_sec; ++ exp_tm.tm_min = exploded->tm_min; ++ exp_tm.tm_hour = exploded->tm_hour; ++ exp_tm.tm_mday = exploded->tm_mday; ++ exp_tm.tm_mon = exploded->tm_month; ++ exp_tm.tm_year = exploded->tm_year - 1900; ++ ++ // time_t is 64bit ++ time_t absolute_time = timegm(&exp_tm); ++ ++ PRTime result = static_cast<PRTime>(absolute_time); ++ result -= exploded->tm_params.tp_gmt_offset + ++ exploded->tm_params.tp_dst_offset; ++ result *= kSecondsToMicroseconds; ++ result += exploded->tm_usec; ++ return result; + #else + #error No PR_ImplodeTime implemented on your platform. + #endif +diff --git ipc/chromium/src/base/time_posix.cc ipc/chromium/src/base/time_posix.cc +index abf2a56..48791f6 100644 +--- ipc/chromium/src/base/time_posix.cc ++++ ipc/chromium/src/base/time_posix.cc +@@ -167,7 +167,7 @@ TimeTicks TimeTicks::Now() { + // With numer and denom = 1 (the expected case), the 64-bit absolute time + // reported in nanoseconds is enough to last nearly 585 years. + +-#elif defined(__OpenBSD__) || defined(OS_POSIX) && \ ++#elif defined(OS_OPENBSD) || defined(OS_POSIX) && \ + defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 + + struct timespec ts; +$NetBSD: patch-ipc_chromium_src_build_build__config.h,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- ipc/chromium/src/build/build_config.h.orig 2012-03-13 01:36:53.000000000 +0000 ++++ ipc/chromium/src/build/build_config.h +@@ -19,17 +19,23 @@ + #define OS_MACOSX 1 + #elif defined(__linux__) || defined(ANDROID) + #define OS_LINUX 1 ++#elif defined(__NetBSD__) ++#define OS_NETBSD 1 ++#elif defined(__DragonFly__) ++#define OS_DRAGONFLY 1 + #elif defined(__OpenBSD__) + #define OS_OPENBSD 1 + #elif defined(_WIN32) + #define OS_WIN 1 ++#elif defined(__FreeBSD__) ++#define OS_FREEBSD 1 + #else + #error Please add support for your platform in build/build_config.h + #endif + + // For access to standard POSIX features, use OS_POSIX instead of a more + // specific macro. +-#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_OPENBSD) ++#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_BSD) + #define OS_POSIX 1 + #endif + +diff --git ipc/chromium/src/chrome/common/ipc_channel_posix.cc ipc/chromium/src/chrome/common/ipc_channel_posix.cc +index bd866ee..2ea5b19 100644 +--- ipc/chromium/src/chrome/common/ipc_channel_posix.cc ++++ ipc/chromium/src/chrome/common/ipc_channel_posix.cc +@@ -7,6 +7,7 @@ + #include <errno.h> + #include <fcntl.h> + #include <stddef.h> ++#include <unistd.h> + #include <sys/types.h> + #include <sys/socket.h> + #include <sys/stat.h> +$NetBSD: patch-ipc_chromium_src_chrome_common_ipc__channel__posix.h,v 1.1 2011/07/11 12:46:14 tnn Exp $ + +--- ipc/chromium/src/chrome/common/ipc_channel_posix.h.orig 2011-06-15 21:57:27.000000000 +0000 ++++ ipc/chromium/src/chrome/common/ipc_channel_posix.h +@@ -92,7 +92,7 @@ class Channel::ChannelImpl : public Mess + }; + + // This is a control message buffer large enough to hold kMaxReadFDs +-#if defined(OS_MACOSX) ++#if defined(OS_MACOSX) || defined(OS_NETBSD) + // TODO(agl): OSX appears to have non-constant CMSG macros! + char input_cmsg_buf_[1024]; + #else +$NetBSD: patch-ipc_chromium_src_chrome_common_ipc__message__utils.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/chrome/common/ipc_message_utils.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/chrome/common/ipc_message_utils.h +@@ -195,7 +195,7 @@ + }; + #endif + +-#if !(defined(OS_MACOSX) || defined(OS_OPENBSD) || defined(OS_WIN) || (defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)) || defined(ARCH_CPU_S390)) ++#if !(defined(OS_MACOSX) || defined(OS_OPENBSD) || defined(OS_WIN) || ((defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined(OS_NETBSD) || defined(OS_LINUX)) && defined(ARCH_CPU_64_BITS)) || defined(ARCH_CPU_S390)) + // There size_t is a synonym for |unsigned long| ... + template <> + struct ParamTraits<size_t> { +@@ -248,7 +248,7 @@ + }; + #endif // defined(OS_MACOSX) + +-#if !(defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)) ++#if !((defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined(OS_NETBSD) || defined(OS_LINUX)) && defined(ARCH_CPU_64_BITS)) + // int64 is |long int| on 64-bit systems, uint64 is |unsigned long| + template <> + struct ParamTraits<int64> { +$NetBSD: patch-ipc_chromium_src_chrome_common_transport__dib.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/chrome/common/transport_dib.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/chrome/common/transport_dib.h +@@ -7,7 +7,7 @@ + + #include "base/basictypes.h" + +-#if defined(OS_WIN) || defined(OS_MACOSX) ++#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + #include "base/shared_memory.h" + #endif + +@@ -66,7 +66,7 @@ class TransportDIB { + uint32 sequence_num; + }; + typedef HandleAndSequenceNum Id; +-#elif defined(OS_MACOSX) ++#elif defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + typedef base::SharedMemoryHandle Handle; + // On Mac, the inode number of the backing file is used as an id. + typedef base::SharedMemoryId Id; +@@ -108,7 +108,7 @@ class TransportDIB { + + private: + TransportDIB(); +-#if defined(OS_WIN) || defined(OS_MACOSX) ++#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + explicit TransportDIB(base::SharedMemoryHandle dib); + base::SharedMemory shared_memory_; + uint32 sequence_num_; +$NetBSD: patch-ipc_glue_GeckoChildProcessHost.cpp,v 1.2 2012/03/15 08:30:06 ryoon Exp $ + +--- ipc/glue/GeckoChildProcessHost.cpp.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/glue/GeckoChildProcessHost.cpp +@@ -430,7 +430,7 @@ + // and passing wstrings from one config to the other is unsafe. So + // we split the logic here. + +-#if defined(OS_LINUX) || defined(OS_MACOSX) ++#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD) + base::environment_map newEnvVars; + // XPCOM may not be initialized in some subprocesses. We don't want + // to initialize XPCOM just for the directory service, especially +@@ -445,8 +445,8 @@ + if (NS_SUCCEEDED(rv)) { + nsCString path; + greDir->GetNativePath(path); +-# ifdef OS_LINUX +-# ifdef MOZ_WIDGET_ANDROID ++# if defined(OS_LINUX) || defined(OS_BSD) ++# if defined(MOZ_WIDGET_ANDROID) || defined(OS_BSD) + path += "/lib"; + # endif // MOZ_WIDGET_ANDROID + const char *ld_library_path = PR_GetEnv("LD_LIBRARY_PATH"); +@@ -557,7 +557,7 @@ + childArgv.push_back(pidstring); + + #if defined(MOZ_CRASHREPORTER) +-# if defined(OS_LINUX) ++# if defined(OS_LINUX) || defined(OS_BSD) + int childCrashFd, childCrashRemapFd; + if (!CrashReporter::CreateNotificationPipeForChild( + &childCrashFd, &childCrashRemapFd)) +@@ -594,7 +594,7 @@ + #endif + + base::LaunchApp(childArgv, mFileMap, +-#if defined(OS_LINUX) || defined(OS_MACOSX) ++#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD) + newEnvVars, + #endif + false, &process, arch); +$NetBSD: patch-mm,v 1.13 2012/06/05 18:09:21 ryoon Exp $ + +--- toolkit/library/Makefile.in.orig 2012-05-23 18:57:09.000000000 +0000 ++++ toolkit/library/Makefile.in +@@ -534,6 +538,10 @@ EXTRA_DSO_LDOPTS += -lelf -ldemangle + endif + endif + ++ifneq (,$(filter DragonFly FreeBSD NetBSD,$(OS_ARCH))) ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++endif ++ + ifeq ($(OS_ARCH),WINNT) + OS_LIBS += $(call EXPAND_LIBNAME,shell32 ole32 version winspool comdlg32 imm32 msimg32 shlwapi psapi ws2_32 dbghelp rasapi32 rasdlg iphlpapi uxtheme setupapi secur32 sensorsapi portabledeviceguids windowscodecs wininet) + ifdef ACCESSIBILITY Deleted: branches/experimental/www/firefox/files/patch-ipc-chromium-src-base-dir_reader_linux.h ============================================================================== --- branches/experimental/www/firefox/files/patch-ipc-chromium-src-base-dir_reader_linux.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,52 +0,0 @@ ---- ipc/chromium/src/base/dir_reader_linux.h~ -+++ ipc/chromium/src/base/dir_reader_linux.h -@@ -12,6 +12,10 @@ - #include <sys/syscall.h> - #include <unistd.h> - -+#if defined(__FreeBSD__) -+#include <sys/dirent.h> -+#endif -+ - #include "base/logging.h" - #include "base/eintr_wrapper.h" - -@@ -19,6 +23,9 @@ - - namespace base { - -+#if defined(__FreeBSD__) -+#define linux_dirent struct dirent -+#else - struct linux_dirent { - uint64_t d_ino; - int64_t d_off; -@@ -26,11 +33,16 @@ struct linux_dirent { - unsigned char d_type; - char d_name[0]; - }; -+#endif - - class DirReaderLinux { - public: - explicit DirReaderLinux(const char* directory_path) -+#ifdef O_DIRECTORY - : fd_(open(directory_path, O_RDONLY | O_DIRECTORY)), -+#else -+ : fd_(open(directory_path, O_RDONLY)), -+#endif - offset_(0), - size_(0) { - memset(buf_, 0, sizeof(buf_)); -@@ -57,7 +69,11 @@ class DirReaderLinux { - if (offset_ != size_) - return true; - -+#if !defined(__FreeBSD__) - const int r = syscall(__NR_getdents64, fd_, buf_, sizeof(buf_)); -+#else -+ const int r = syscall(SYS_getdents, fd_, buf_, sizeof(buf_)); -+#endif - if (r == 0) - return false; - if (r == -1) { Deleted: branches/experimental/www/firefox/files/patch-ipc-chromium-src-base-file_util_linux.cc ============================================================================== --- branches/experimental/www/firefox/files/patch-ipc-chromium-src-base-file_util_linux.cc Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- ipc/chromium/src/base/file_util_linux.cc~ -+++ ipc/chromium/src/base/file_util_linux.cc -@@ -28,7 +29,7 @@ bool GetShmemTempDir(FilePath* path) { - #ifdef ANDROID - return GetTempDir(path); - #else -- *path = FilePath("/dev/shm"); -+ *path = FilePath("/tmp"); - return true; - #endif - } Deleted: branches/experimental/www/firefox/files/patch-ipc-chromium-src-base-file_util_posix.cc ============================================================================== --- branches/experimental/www/firefox/files/patch-ipc-chromium-src-base-file_util_posix.cc Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- ipc/chromium/src/base/file_util_posix.cc~ -+++ ipc/chromium/src/base/file_util_posix.cc -@@ -31,7 +31,7 @@ - #include "base/time.h" - - // FreeBSD/OpenBSD lacks stat64, but its stat handles files >2GB just fine --#if defined(OS_FREEBSD) || defined(OS_OPENBSD) -+#if defined(__FreeBSD__) || defined(OS_OPENBSD) - #define stat64 stat - #endif - Deleted: branches/experimental/www/firefox/files/patch-ipc-chromium-src-base-platform_thread_posix.cc ============================================================================== --- branches/experimental/www/firefox/files/patch-ipc-chromium-src-base-platform_thread_posix.cc Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,25 +0,0 @@ ---- ipc/chromium/src/base/platform_thread_posix.cc~ -+++ ipc/chromium/src/base/platform_thread_posix.cc -@@ -11,6 +11,7 @@ - #include <mach/mach.h> - #elif defined(OS_LINUX) - #include <sys/syscall.h> -+#include <pthread_np.h> - #include <unistd.h> - #endif - -@@ -34,7 +35,13 @@ PlatformThreadId PlatformThread::Current - #if defined(OS_MACOSX) - return mach_thread_self(); - #elif defined(OS_LINUX) -- return syscall(__NR_gettid); -+#if __FreeBSD_version > 900030 -+ return pthread_getthreadid_np(); -+#else -+ long tid; -+ syscall(SYS_thr_self, &tid); -+ return tid; -+#endif - #endif - } - Deleted: branches/experimental/www/firefox/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h ============================================================================== --- branches/experimental/www/firefox/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- ipc/chromium/src/base/third_party/nspr/prcpucfg.h~ -+++ ipc/chromium/src/base/third_party/nspr/prcpucfg.h -@@ -34,7 +34,7 @@ - #include "base/third_party/nspr/prcpucfg_win.h" - #elif defined(__APPLE__) - #include "base/third_party/nspr/prcpucfg_mac.h" --#elif defined(__linux__) || defined(ANDROID) -+#elif defined(__FreeBSD__) || defined(ANDROID) - #include "base/third_party/nspr/prcpucfg_linux.h" - #else - #error Provide a prcpucfg.h appropriate for your platform Deleted: branches/experimental/www/firefox/files/patch-ipc-chromium-src-build-build_config.h ============================================================================== --- branches/experimental/www/firefox/files/patch-ipc-chromium-src-build-build_config.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- ipc/chromium/src/build/build_config.h~ -+++ ipc/chromium/src/build/build_config.h -@@ -17,7 +17,7 @@ - // A set of macros to use for platform detection. - #if defined(__APPLE__) - #define OS_MACOSX 1 --#elif defined(__linux__) || defined(ANDROID) -+#elif defined(__linux__) || defined(ANDROID) || defined(__FreeBSD__) - #define OS_LINUX 1 - #elif defined(__OpenBSD__) - #define OS_OPENBSD 1 Deleted: branches/experimental/www/firefox/files/patch-toolkit_library_Makefile.in ============================================================================== --- branches/experimental/www/firefox/files/patch-toolkit_library_Makefile.in Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- toolkit/library/Makefile.in.orig 2010-01-11 12:13:08.000000000 -0500 -+++ toolkit/library/Makefile.in 2010-01-11 12:15:05.000000000 -0500 -@@ -181,7 +181,7 @@ - export:: $(RDF_UTIL_SRC_CPPSRCS) $(INTL_UNICHARUTIL_UTIL_CPPSRCS) - $(INSTALL) $^ . - --EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(EXTRA_DSO_LIBS) -+EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(EXTRA_DSO_LIBS) -lexecinfo - - ifdef MOZ_ENABLE_LIBXUL - include $(srcdir)/libxul-rules.mk Modified: branches/experimental/www/libxul/Makefile ============================================================================== --- branches/experimental/www/libxul/Makefile Mon Jul 23 13:52:35 2012 (r886) +++ branches/experimental/www/libxul/Makefile Mon Jul 23 22:39:41 2012 (r887) @@ -20,7 +20,6 @@ sqlite3>=3.7.7.1:${PORTSDIR}/databases/sqlite3 \ cairo>=1.10.2_1,1:${PORTSDIR}/graphics/cairo \ unzip:${PORTSDIR}/archivers/unzip -LIB_DEPENDS= execinfo.1:${PORTSDIR}/devel/libexecinfo WRKSRC= ${WRKDIR}/mozilla-esr10 CONFLICTS= mozilla-[0-9]* libxul-1.9.* @@ -75,9 +74,6 @@ .endif post-patch: - @${GREP} -Flr \"/proc ${WRKSRC}/ipc/chromium/src/base | ${XARGS} ${REINPLACE_CMD} \ - -e 's|/proc/self/fd|/dev/fd|' \ - -e 's|/proc["/]|/compat/linux&|' @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \ ${WRKSRC}/xulrunner/stub/nsXULStub.cpp Added: branches/experimental/www/libxul/files/patch-bug753046 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/experimental/www/libxul/files/patch-bug753046 Mon Jul 23 22:39:41 2012 (r887) @@ -0,0 +1,1261 @@ +# Bug 753046 - Add support for DragonFly/NetBSD + +$NetBSD: patch-dom_plugins_ipc_PluginModuleChild.cpp,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- dom/plugins/ipc/PluginModuleChild.cpp.orig 2011-12-20 23:28:14.000000000 +0000 ++++ dom/plugins/ipc/PluginModuleChild.cpp +@@ -33,6 +33,8 @@ + #include "nsPluginsDir.h" + #include "nsXULAppAPI.h" + ++#include <unistd.h> ++ + #ifdef MOZ_X11 + # include "mozilla/X11Util.h" + #endif +@@ -228,7 +228,7 @@ PluginModuleChild::Init(const std::strin + + // TODO: use PluginPRLibrary here + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + mShutdownFunc = + (NP_PLUGINSHUTDOWN) PR_FindFunctionSymbol(mLibrary, "NP_Shutdown"); + +@@ -1790,7 +1790,7 @@ PluginModuleChild::AnswerNP_GetEntryPoin + PLUGIN_LOG_DEBUG_METHOD; + AssertPluginThread(); + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + return true; + #elif defined(OS_WIN) || defined(OS_MACOSX) + *_retval = mGetEntryPointsFunc(&mFunctions); +@@ -1823,7 +1823,7 @@ PluginModuleChild::AnswerNP_Initialize(N + SendBackUpXResources(FileDescriptor(xSocketFd, false/*don't close*/)); + #endif + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + *_retval = mInitializeFunc(&sBrowserFuncs, &mFunctions); + return true; + #elif defined(OS_WIN) || defined(OS_MACOSX) +$NetBSD: patch-dom_plugins_ipc_PluginModuleChild.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- dom/plugins/ipc/PluginModuleChild.h.orig 2011-12-20 23:28:14.000000000 +0000 ++++ dom/plugins/ipc/PluginModuleChild.h +@@ -340,7 +340,7 @@ private: + + // we get this from the plugin + NP_PLUGINSHUTDOWN mShutdownFunc; +-#ifdef OS_LINUX ++#if defined(OS_LINUX) || defined(OS_BSD) + NP_PLUGINUNIXINIT mInitializeFunc; + #elif defined(OS_WIN) || defined(OS_MACOSX) + NP_PLUGININIT mInitializeFunc; +$NetBSD: patch-ipc_chromium_Makefile.in,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/Makefile.in.orig 2012-02-16 06:40:33.000000000 +0000 ++++ ipc/chromium/Makefile.in +@@ -278,6 +278,34 @@ endif + + endif # } OS_LINUX + ++ifdef OS_BSD # { ++ ++CPPSRCS += \ ++ atomicops_internals_x86_gcc.cc \ ++ file_util_bsd.cc \ ++ process_util_bsd.cc \ ++ time_posix.cc \ ++ $(NULL) ++ ++ifdef MOZ_ENABLE_GTK2 ++CPPSRCS += \ ++ message_pump_glib.cc \ ++ $(NULL) ++endif ++ ++ifdef MOZ_ENABLE_QT ++MOCSRCS = \ ++ moc_message_pump_qt.cc \ ++ $(NULL) ++ ++CPPSRCS += \ ++ $(MOCSRCS) \ ++ message_pump_qt.cc \ ++ $(NULL) ++endif ++ ++endif # } OS_BSD ++ + # libevent + + ifndef MOZ_NATIVE_LIBEVENT # { +$NetBSD: patch-ipc_chromium_chromium-config.mk,v 1.2 2012/03/15 08:30:06 ryoon Exp $ + +--- ipc/chromium/chromium-config.mk.orig 2012-02-16 07:40:33.000000000 +0100 ++++ ipc/chromium/chromium-config.mk 2012-03-11 11:05:40.397182000 +0100 +@@ -56,17 +56,6 @@ + -I$(DEPTH)/ipc/ipdl/_ipdlheaders \ + $(NULL) + +-ifeq ($(OS_ARCH),Darwin) # { +- +-OS_MACOSX = 1 +-OS_POSIX = 1 +- +-DEFINES += \ +- -DOS_MACOSX=1 \ +- -DOS_POSIX=1 \ +- $(NULL) +- +-else # } { + ifeq ($(OS_ARCH),WINNT) # { + OS_LIBS += $(call EXPAND_LIBNAME,psapi shell32 dbghelp) + +@@ -93,13 +82,64 @@ + endif + + else # } { +- +-OS_LINUX = 1 + OS_POSIX = 1 ++DEFINES += -DOS_POSIX=1 ++ ++ifeq ($(OS_ARCH),Darwin) # { ++ ++OS_MACOSX = 1 ++DEFINES += \ ++ -DOS_MACOSX=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),DragonFly) # { ++ ++OS_DRAGONFLY = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_DRAGONFLY=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),FreeBSD) # { ++ ++OS_FREEBSD = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_FREEBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) + ++else # } { ++ifeq ($(OS_ARCH),NetBSD) # { ++ ++OS_NETBSD = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_NETBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),OpenBSD) # { ++ ++OS_OPENBSD = 1 ++OS_BSD = 1 ++DEFINES += \ ++ -DOS_OPENBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ ++OS_LINUX = 1 + DEFINES += \ + -DOS_LINUX=1 \ +- -DOS_POSIX=1 \ + $(NULL) + + # NB: to stop gcc warnings about exporting template instantiation +@@ -107,4 +147,8 @@ + + endif # } + endif # } ++endif # } ++endif # } ++endif # } ++endif # } + +$NetBSD: patch-ipc_chromium_src_base_base__paths.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/base_paths.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/base_paths.h +@@ -13,7 +13,7 @@ + #include "base/base_paths_win.h" + #elif defined(OS_MACOSX) + #include "base/base_paths_mac.h" +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_BSD) + #include "base/base_paths_linux.h" + #endif + #include "base/path_service.h" +$NetBSD: patch-ipc_chromium_src_base_debug__util__posic.cc,v 1.3 2012/04/01 15:18:45 ryoon Exp $ + +--- ipc/chromium/src/base/debug_util_posix.cc.orig 2012-03-13 01:36:53.000000000 +0000 ++++ ipc/chromium/src/base/debug_util_posix.cc +@@ -5,7 +5,7 @@ + #include "build/build_config.h" + #include "base/debug_util.h" + +-#define MOZ_HAVE_EXECINFO_H (!defined(ANDROID) && !defined(__OpenBSD__)) ++#define MOZ_HAVE_EXECINFO_H (defined(OS_LINUX) && !defined(ANDROID)) + + #include <errno.h> + #include <fcntl.h> +@@ -17,8 +17,13 @@ + #include <unistd.h> + #if MOZ_HAVE_EXECINFO_H + #include <execinfo.h> +-#include <sys/sysctl.h> + #endif ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++#include <sys/user.h> ++#elif defined(OS_FREEBSD) ++#include <sys/proc.h> ++#endif ++#include <sys/sysctl.h> + + #include "base/basictypes.h" + #include "base/eintr_wrapper.h" +@@ -32,7 +37,7 @@ bool DebugUtil::SpawnDebuggerOnProcess(u + return false; + } + +-#if defined(OS_MACOSX) ++#if defined(OS_MACOSX) || defined(OS_BSD) + + // Based on Apple's recommended method as described in + // http://developer.apple.com/qa/qa2004/qa1361.html +@@ -71,7 +76,13 @@ bool DebugUtil::BeingDebugged() { + + // This process is being debugged if the P_TRACED flag is set. + is_set = true; ++#if defined(OS_DRAGONFLY) ++ being_debugged = (info.kp_flags & P_TRACED) != 0; ++#elif defined(OS_FREEBSD) ++ being_debugged = (info.ki_flag & P_TRACED) != 0; ++#else + being_debugged = (info.kp_proc.p_flag & P_TRACED) != 0; ++#endif + return being_debugged; + } + +diff --git ipc/chromium/src/base/dir_reader_bsd.h ipc/chromium/src/base/dir_reader_bsd.h +new file mode 100644 +index 0000000..3fc1a87 +--- /dev/null ++++ ipc/chromium/src/base/dir_reader_bsd.h +@@ -0,0 +1,98 @@ ++// Copyright (c) 2010 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. ++ ++// derived from dir_reader_linux.h ++ ++#ifndef BASE_DIR_READER_BSD_H_ ++#define BASE_DIR_READER_BSD_H_ ++#pragma once ++ ++#include <dirent.h> ++#include <errno.h> ++#include <fcntl.h> ++#include <stdint.h> ++#include <unistd.h> ++ ++#include "base/logging.h" ++#include "base/eintr_wrapper.h" ++ ++// See the comments in dir_reader_posix.h about this. ++ ++namespace base { ++ ++class DirReaderBSD { ++ public: ++ explicit DirReaderBSD(const char* directory_path) ++#ifdef O_DIRECTORY ++ : fd_(open(directory_path, O_RDONLY | O_DIRECTORY)), ++#else ++ : fd_(open(directory_path, O_RDONLY)), ++#endif ++ offset_(0), ++ size_(0) { ++ memset(buf_, 0, sizeof(buf_)); ++ } ++ ++ ~DirReaderBSD() { ++ if (fd_ >= 0) { ++ if (HANDLE_EINTR(close(fd_))) ++ DLOG(ERROR) << "Failed to close directory handle"; ++ } ++ } ++ ++ bool IsValid() const { ++ return fd_ >= 0; ++ } ++ ++ // Move to the next entry returning false if the iteration is complete. ++ bool Next() { ++ if (size_) { ++ struct dirent* dirent = reinterpret_cast<struct dirent*>(&buf_[offset_]); ++ offset_ += dirent->d_reclen; ++ } ++ ++ if (offset_ != size_) ++ return true; ++ ++ const int r = getdirentries(fd_, buf_, sizeof(buf_), basep_); ++ if (r == 0) ++ return false; ++ if (r == -1) { ++ DLOG(ERROR) << "getdirentries returned an error: " << errno; ++ return false; ++ } ++ size_ = r; ++ offset_ = 0; ++ return true; ++ } ++ ++ const char* name() const { ++ if (!size_) ++ return NULL; ++ ++ const struct dirent* dirent = ++ reinterpret_cast<const struct dirent*>(&buf_[offset_]); ++ return dirent->d_name; ++ } ++ ++ int fd() const { ++ return fd_; ++ } ++ ++ static bool IsFallback() { ++ return false; ++ } ++ ++ private: ++ const int fd_; ++ char buf_[512]; ++ long *basep_; ++ size_t offset_, size_; ++ ++ DISALLOW_COPY_AND_ASSIGN(DirReaderBSD); ++}; ++ ++} // namespace base ++ ++#endif // BASE_DIR_READER_BSD_H_ +diff --git ipc/chromium/src/base/dir_reader_posix.h ipc/chromium/src/base/dir_reader_posix.h +index 9a34492..62b280c 100644 +--- ipc/chromium/src/base/dir_reader_posix.h ++++ ipc/chromium/src/base/dir_reader_posix.h +@@ -18,16 +18,20 @@ + // seems worse than falling back to enumerating all file descriptors so we will + // probably never implement this on the Mac. + +-#if defined(OS_LINUX) && !defined(OS_OPENBSD) ++#if defined(OS_LINUX) + #include "base/dir_reader_linux.h" ++#elif defined(OS_BSD) ++#include "base/dir_reader_bsd.h" + #else + #include "base/dir_reader_fallback.h" + #endif + + namespace base { + +-#if defined(OS_LINUX) && !defined(OS_OPENBSD) ++#if defined(OS_LINUX) + typedef DirReaderLinux DirReaderPosix; ++#elif defined(OS_BSD) ++typedef DirReaderBSD DirReaderPosix; + #else + typedef DirReaderFallback DirReaderPosix; + #endif +$NetBSD: patch-ipc_chromium_src_base_file__util.h,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/file_util.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/file_util.h +@@ -16,8 +16,8 @@ + #include <sys/stat.h> + #elif defined(OS_POSIX) + #include <sys/types.h> +-#include <fts.h> + #include <sys/stat.h> ++#include <fts.h> + #endif + + #include <stdio.h> +$NetBSD: patch-ipc_chromium_src_base_file__util__bsd.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/file_util_bsd.cc.orig 2012-01-07 18:21:18.000000000 +0000 ++++ ipc/chromium/src/base/file_util_bsd.cc +@@ -0,0 +1,80 @@ ++// Copyright (c) 2006-2008 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. ++ ++// this is a derivative of file_util_linux.cc ++ ++#include "base/file_util.h" ++ ++#include <fcntl.h> ++#include <unistd.h> ++ ++#include <string> ++#include <vector> ++ ++#include "base/eintr_wrapper.h" ++#include "base/file_path.h" ++#include "base/string_util.h" ++ ++namespace file_util { ++ ++bool GetTempDir(FilePath* path) { ++ const char* tmp = getenv("TMPDIR"); ++ if (tmp) ++ *path = FilePath(tmp); ++ else ++ *path = FilePath("/tmp"); ++ return true; ++} ++ ++bool GetShmemTempDir(FilePath* path) { ++ return GetTempDir(path); ++} ++ ++bool CopyFile(const FilePath& from_path, const FilePath& to_path) { ++ int infile = open(from_path.value().c_str(), O_RDONLY); ++ if (infile < 0) ++ return false; ++ ++ int outfile = creat(to_path.value().c_str(), 0666); ++ if (outfile < 0) { ++ close(infile); ++ return false; ++ } ++ ++ const size_t kBufferSize = 32768; ++ std::vector<char> buffer(kBufferSize); ++ bool result = true; ++ ++ while (result) { ++ ssize_t bytes_read = HANDLE_EINTR(read(infile, &buffer[0], buffer.size())); ++ if (bytes_read < 0) { ++ result = false; ++ break; ++ } ++ if (bytes_read == 0) ++ break; ++ // Allow for partial writes ++ ssize_t bytes_written_per_read = 0; ++ do { ++ ssize_t bytes_written_partial = HANDLE_EINTR(write( ++ outfile, ++ &buffer[bytes_written_per_read], ++ bytes_read - bytes_written_per_read)); ++ if (bytes_written_partial < 0) { ++ result = false; ++ break; ++ } ++ bytes_written_per_read += bytes_written_partial; ++ } while (bytes_written_per_read < bytes_read); ++ } ++ ++ if (HANDLE_EINTR(close(infile)) < 0) ++ result = false; ++ if (HANDLE_EINTR(close(outfile)) < 0) ++ result = false; ++ ++ return result; ++} ++ ++} // namespace file_util +$NetBSD: patch-ipc_chromium_src_base_file__util__posix.cc,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/file_util_posix.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/file_util_posix.cc +@@ -31,7 +31,7 @@ + #include "base/time.h" + + // FreeBSD/OpenBSD lacks stat64, but its stat handles files >2GB just fine +-#if defined(OS_FREEBSD) || defined(OS_OPENBSD) ++#ifndef OS_LINUX + #define stat64 stat + #endif + +$NetBSD: patch-ipc_chromium_src_base_message__loop.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/message_loop.cc.orig 2012-02-16 07:40:33.000000000 +0100 ++++ ipc/chromium/src/base/message_loop.cc 2012-02-21 21:24:41.000000000 +0100 +@@ -19,7 +19,7 @@ + #if defined(OS_POSIX) + #include "base/message_pump_libevent.h" + #endif +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + #ifdef MOZ_WIDGET_GTK2 + #include "base/message_pump_glib.h" + #endif +@@ -119,7 +119,7 @@ + if (type_ == TYPE_UI) { + #if defined(OS_MACOSX) + pump_ = base::MessagePumpMac::Create(); +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_BSD) + pump_ = new base::MessagePumpForUI(); + #endif // OS_LINUX + } else if (type_ == TYPE_IO) { +$NetBSD: patch-ipc_chromium_src_base_platform__file__posix.cc,v 1.1 2011/07/12 15:12:36 tnn Exp $ + +--- ipc/chromium/src/base/platform_file_posix.cc.orig 2011-06-15 21:57:27.000000000 +0000 ++++ ipc/chromium/src/base/platform_file_posix.cc +@@ -9,6 +9,7 @@ + #ifdef ANDROID + #include <linux/stat.h> + #endif ++#include <sys/stat.h> /* for S_IRUSR */ + + #include "base/logging.h" + #include "base/string_util.h" +$NetBSD: patch-ipc_chromium_src_base_platform__thread.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/platform_thread.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/platform_thread.h +@@ -25,6 +25,8 @@ typedef pthread_t PlatformThreadHandle; + #if defined(OS_LINUX) + #include <unistd.h> + typedef pid_t PlatformThreadId; ++#elif defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined (OS_NETBSD) ++typedef lwpid_t PlatformThreadId; + #elif defined(OS_MACOSX) + #include <mach/mach.h> + typedef mach_port_t PlatformThreadId; +$NetBSD: patch-ipc_chromium_src_base_platform__thread__posix.cc,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- ipc/chromium/src/base/platform_thread_posix.cc.orig 2012-03-13 01:36:53.000000000 +0000 ++++ ipc/chromium/src/base/platform_thread_posix.cc +@@ -9,9 +9,18 @@ + + #if defined(OS_MACOSX) + #include <mach/mach.h> ++#elif defined(OS_NETBSD) ++#include <lwp.h> + #elif defined(OS_LINUX) + #include <sys/syscall.h> + #include <unistd.h> ++#elif defined(OS_DRAGONFLY) ++#include <unistd.h> ++#elif defined(OS_FREEBSD) ++_Pragma("GCC visibility push(default)") ++extern "C" int thr_self(long *); // XXX #include <sys/thr.h> ++_Pragma("GCC visibility pop") ++#include <pthread_np.h> + #endif + + #if defined(OS_MACOSX) +@@ -38,7 +45,19 @@ + // into the kernel. + #if defined(OS_MACOSX) + return mach_thread_self(); +-#elif defined (__OpenBSD__) ++#elif defined(OS_NETBSD) ++ return _lwp_self(); ++#elif defined(OS_DRAGONFLY) ++ return lwp_gettid(); ++#elif defined(OS_FREEBSD) ++# if __FreeBSD_version > 900030 ++ return pthread_getthreadid_np(); ++# else ++ long lwpid; ++ thr_self(&lwpid); ++ return lwpid; ++# endif ++#elif defined(OS_OPENBSD) + // TODO(BSD): find a better thread ID + return (intptr_t)(pthread_self()); + #elif defined(OS_LINUX) +$NetBSD: patch-ipc_chromium_src_base_process__util.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/process_util.h.orig 2011-12-21 00:28:19.000000000 +0100 ++++ ipc/chromium/src/base/process_util.h 2012-01-31 13:14:54.000000000 +0100 +@@ -280,6 +280,7 @@ class NamedProcessIterator { + const ProcessEntry* NextProcessEntry(); + + private: ++#if !defined(OS_BSD) + // Determines whether there's another process (regardless of executable) + // left in the list of all processes. Returns true and sets entry_ to + // that process's info if there is one, false otherwise. +@@ -292,18 +292,24 @@ + void InitProcessEntry(ProcessEntry* entry); + + std::wstring executable_name_; ++#endif + + #if defined(OS_WIN) + HANDLE snapshot_; + bool started_iteration_; + #elif defined(OS_LINUX) + DIR *procfs_dir_; ++#elif defined(OS_BSD) ++ std::vector<ProcessEntry> content; ++ size_t nextEntry; + #elif defined(OS_MACOSX) + std::vector<kinfo_proc> kinfo_procs_; + size_t index_of_kinfo_proc_; + #endif ++#if !defined(OS_BSD) + ProcessEntry entry_; + const ProcessFilter* filter_; ++#endif + + DISALLOW_EVIL_CONSTRUCTORS(NamedProcessIterator); + }; +$NetBSD: patch-ipc_chromium_src_base_process__util__bsd.cc,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- ipc/chromium/src/base/process_util_bsd.cc.orig 2012-04-01 00:04:28.000000000 +0000 ++++ ipc/chromium/src/base/process_util_bsd.cc +@@ -0,0 +1,326 @@ ++// Copyright (c) 2008 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. ++ ++// derived from process_util_linux.cc and process_util_mac.cc ++ ++#include "base/process_util.h" ++ ++#include <ctype.h> ++#include <fcntl.h> ++#include <unistd.h> ++#include <string> ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++/* DragonFly, as of v3.0.1, and FreeBSD 9.0-RELEASE do not explicitly mark symbols public */ ++#define PRE_SYS_INCLUDE _Pragma("GCC visibility push(default)") ++#define POST_SYS_INCLUDE _Pragma("GCC visibility pop") ++#else ++#define PRE_SYS_INCLUDE ++#define POST_SYS_INCLUDE ++#endif ++PRE_SYS_INCLUDE ++#include <kvm.h> ++POST_SYS_INCLUDE ++#include <sys/sysctl.h> ++#include <sys/types.h> ++#include <sys/wait.h> ++#if defined(OS_DRAGONFLY) ++PRE_SYS_INCLUDE ++#include <sys/user.h> ++POST_SYS_INCLUDE ++#define HAVE_POSIX_SPAWN 1 ++#endif ++#if defined(OS_FREEBSD) ++PRE_SYS_INCLUDE ++#include <sys/user.h> ++POST_SYS_INCLUDE ++#endif ++ ++#include "base/debug_util.h" ++#include "base/eintr_wrapper.h" ++#include "base/file_util.h" ++#include "base/logging.h" ++#include "base/string_tokenizer.h" ++#include "base/string_util.h" ++ ++#if defined(OS_NETBSD) ++#include <sys/param.h> ++#if __NetBSD_Version__ >= 600000000 ++#define HAVE_POSIX_SPAWN 1 ++#endif ++#endif ++ ++#ifdef HAVE_POSIX_SPAWN ++PRE_SYS_INCLUDE ++#include <spawn.h> ++POST_SYS_INCLUDE ++extern "C" char **environ __dso_public; ++#endif ++ ++namespace { ++ ++enum ParsingState { ++ KEY_NAME, ++ KEY_VALUE ++}; ++ ++static mozilla::EnvironmentLog gProcessLog("MOZ_PROCESS_LOG"); ++ ++} // namespace ++ ++namespace base { ++ ++#ifdef HAVE_POSIX_SPAWN ++ ++void FreeEnvVarsArray(char* array[], int length) ++{ ++ for (int i = 0; i < length; i++) { ++ free(array[i]); ++ } ++ delete[] array; ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ bool wait, ProcessHandle* process_handle) { ++ return LaunchApp(argv, fds_to_remap, environment_map(), ++ wait, process_handle); ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ const environment_map& env_vars_to_set, ++ bool wait, ProcessHandle* process_handle, ++ ProcessArchitecture arch) { ++ bool retval = true; ++ ++ char* argv_copy[argv.size() + 1]; ++ for (size_t i = 0; i < argv.size(); i++) { ++ argv_copy[i] = const_cast<char*>(argv[i].c_str()); ++ } ++ argv_copy[argv.size()] = NULL; ++ ++ // Make sure we don't leak any FDs to the child process by marking all FDs ++ // as close-on-exec. ++ SetAllFDsToCloseOnExec(); ++ ++ // Copy environment to a new char array and add the variables ++ // in env_vars_to_set. ++ // Existing variables are overwritten by env_vars_to_set. ++ int pos = 0; ++ environment_map combined_env_vars = env_vars_to_set; ++ while(environ[pos] != NULL) { ++ std::string varString = environ[pos]; ++ std::string varName = varString.substr(0, varString.find_first_of('=')); ++ std::string varValue = varString.substr(varString.find_first_of('=') + 1); ++ if (combined_env_vars.find(varName) == combined_env_vars.end()) { ++ combined_env_vars[varName] = varValue; ++ } ++ pos++; ++ } ++ int varsLen = combined_env_vars.size() + 1; ++ ++ char** vars = new char*[varsLen]; ++ int i = 0; ++ for (environment_map::const_iterator it = combined_env_vars.begin(); ++ it != combined_env_vars.end(); ++it) { ++ std::string entry(it->first); ++ entry += "="; ++ entry += it->second; ++ vars[i] = strdup(entry.c_str()); ++ i++; ++ } ++ vars[i] = NULL; ++ ++ posix_spawn_file_actions_t file_actions; ++ if (posix_spawn_file_actions_init(&file_actions) != 0) { ++ FreeEnvVarsArray(vars, varsLen); ++ return false; ++ } ++ ++ // Turn fds_to_remap array into a set of dup2 calls. ++ for (file_handle_mapping_vector::const_iterator it = fds_to_remap.begin(); ++ it != fds_to_remap.end(); ++ ++it) { ++ int src_fd = it->first; ++ int dest_fd = it->second; ++ ++ if (src_fd == dest_fd) { ++ int flags = fcntl(src_fd, F_GETFD); ++ if (flags != -1) { ++ fcntl(src_fd, F_SETFD, flags & ~FD_CLOEXEC); ++ } ++ } else { ++ if (posix_spawn_file_actions_adddup2(&file_actions, src_fd, dest_fd) != 0) { ++ posix_spawn_file_actions_destroy(&file_actions); ++ FreeEnvVarsArray(vars, varsLen); ++ return false; ++ } ++ } ++ } ++ ++ pid_t pid = 0; ++ int spawn_succeeded = (posix_spawnp(&pid, ++ argv_copy[0], ++ &file_actions, ++ NULL, ++ argv_copy, ++ vars) == 0); ++ ++ FreeEnvVarsArray(vars, varsLen); ++ ++ posix_spawn_file_actions_destroy(&file_actions); ++ ++ bool process_handle_valid = pid > 0; ++ if (!spawn_succeeded || !process_handle_valid) { ++ retval = false; ++ } else { ++ if (wait) ++ HANDLE_EINTR(waitpid(pid, 0, 0)); ++ ++ if (process_handle) ++ *process_handle = pid; ++ } ++ ++ return retval; ++} ++ ++bool LaunchApp(const CommandLine& cl, ++ bool wait, bool start_hidden, ProcessHandle* process_handle) { ++ // TODO(playmobil): Do we need to respect the start_hidden flag? ++ file_handle_mapping_vector no_files; ++ return LaunchApp(cl.argv(), no_files, wait, process_handle); ++} ++ ++#else // no posix_spawn, use fork/exec ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ bool wait, ProcessHandle* process_handle) { ++ return LaunchApp(argv, fds_to_remap, environment_map(), ++ wait, process_handle); ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ const environment_map& env_vars_to_set, ++ bool wait, ProcessHandle* process_handle, ++ ProcessArchitecture arch) { ++ scoped_array<char*> argv_cstr(new char*[argv.size() + 1]); ++ // Illegal to allocate memory after fork and before execvp ++ InjectiveMultimap fd_shuffle1, fd_shuffle2; ++ fd_shuffle1.reserve(fds_to_remap.size()); ++ fd_shuffle2.reserve(fds_to_remap.size()); ++ ++ pid_t pid = fork(); ++ if (pid < 0) ++ return false; ++ ++ if (pid == 0) { ++ for (file_handle_mapping_vector::const_iterator ++ it = fds_to_remap.begin(); it != fds_to_remap.end(); ++it) { ++ fd_shuffle1.push_back(InjectionArc(it->first, it->second, false)); ++ fd_shuffle2.push_back(InjectionArc(it->first, it->second, false)); ++ } ++ ++ if (!ShuffleFileDescriptors(&fd_shuffle1)) ++ _exit(127); ++ ++ CloseSuperfluousFds(fd_shuffle2); ++ ++ for (environment_map::const_iterator it = env_vars_to_set.begin(); ++ it != env_vars_to_set.end(); ++it) { ++ if (setenv(it->first.c_str(), it->second.c_str(), 1/*overwrite*/)) ++ _exit(127); ++ } ++ ++ for (size_t i = 0; i < argv.size(); i++) ++ argv_cstr[i] = const_cast<char*>(argv[i].c_str()); ++ argv_cstr[argv.size()] = NULL; ++ execvp(argv_cstr[0], argv_cstr.get()); ++ // if we get here, we're in serious trouble and should complain loudly ++ DLOG(ERROR) << "FAILED TO exec() CHILD PROCESS, path: " << argv_cstr[0]; ++ exit(127); ++ } else { ++ gProcessLog.print("==> process %d launched child process %d\n", ++ GetCurrentProcId(), pid); ++ if (wait) ++ HANDLE_EINTR(waitpid(pid, 0, 0)); ++ ++ if (process_handle) ++ *process_handle = pid; ++ } ++ ++ return true; ++} ++ ++bool LaunchApp(const CommandLine& cl, ++ bool wait, bool start_hidden, ++ ProcessHandle* process_handle) { ++ file_handle_mapping_vector no_files; ++ return LaunchApp(cl.argv(), no_files, wait, process_handle); ++} ++ ++#endif ++ ++NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name, ++ const ProcessFilter* filter) ++{ ++ int numEntries; ++ kvm_t *kvm; ++ std::string exe(WideToASCII(executable_name)); ++ ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++ kvm = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL); ++ struct kinfo_proc* procs = kvm_getprocs(kvm, KERN_PROC_UID, getuid(), &numEntries); ++ if (procs != NULL && numEntries > 0) { ++ for (int i = 0; i < numEntries; i++) { ++# if defined(OS_DRAGONFLY) ++ if (exe != procs[i].kp_comm) continue; ++ if (filter && !filter->Includes(procs[i].kp_pid, procs[i].kp_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].kp_pid; ++ e.ppid = procs[i].kp_ppid; ++ strlcpy(e.szExeFile, procs[i].kp_comm, sizeof e.szExeFile); ++ content.push_back(e); ++# elif defined(OS_FREEBSD) ++ if (exe != procs[i].ki_comm) continue; ++ if (filter && !filter->Includes(procs[i].ki_pid, procs[i].ki_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].ki_pid; ++ e.ppid = procs[i].ki_ppid; ++ strlcpy(e.szExeFile, procs[i].ki_comm, sizeof e.szExeFile); ++ content.push_back(e); ++# endif ++#else ++ kvm = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL); ++ struct kinfo_proc2* procs = kvm_getproc2(kvm, KERN_PROC_UID, getuid(), sizeof(struct kinfo_proc2), &numEntries); ++ if (procs != NULL && numEntries > 0) { ++ for (int i = 0; i < numEntries; i++) { ++ if (exe != procs[i].p_comm) continue; ++ if (filter && !filter->Includes(procs[i].p_pid, procs[i].p_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].p_pid; ++ e.ppid = procs[i].p_ppid; ++ strlcpy(e.szExeFile, procs[i].p_comm, sizeof e.szExeFile); ++ content.push_back(e); ++#endif ++ } ++ } ++ nextEntry = 0; ++ kvm_close(kvm); ++} ++ ++NamedProcessIterator::~NamedProcessIterator() { ++} ++ ++const ProcessEntry* NamedProcessIterator::NextProcessEntry() { ++ if (nextEntry >= content.size()) return NULL; ++ return &content[nextEntry++]; ++} ++ ++bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { ++ return false; ++} ++ ++} // namespace base +$NetBSD: patch-ipc_chromium_src_base_process__util__posix.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/process_util_posix.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/process_util_posix.cc +@@ -116,6 +116,11 @@ void CloseSuperfluousFds(const base::Inj + #elif defined(OS_MACOSX) + static const rlim_t kSystemDefaultMaxFds = 256; + static const char kFDDir[] = "/dev/fd"; ++#elif defined(OS_BSD) ++ // the getrlimit below should never fail, so whatever .. ++ static const rlim_t kSystemDefaultMaxFds = 1024; ++ // at least /dev/fd will exist ++ static const char kFDDir[] = "/dev/fd"; + #endif + + // Get the maximum number of FDs possible. +@@ -199,7 +204,7 @@ void CloseSuperfluousFds(const base::Inj + void SetAllFDsToCloseOnExec() { + #if defined(OS_LINUX) + const char fd_dir[] = "/proc/self/fd"; +-#elif defined(OS_MACOSX) ++#elif defined(OS_MACOSX) || defined(OS_BSD) + const char fd_dir[] = "/dev/fd"; + #endif + ScopedDIR dir_closer(opendir(fd_dir)); +$NetBSD: patch-ipc_chromium_src_base_sys__info__posix.cc,v 1.2 2011/11/27 13:09:00 tnn Exp $ + +--- ipc/chromium/src/base/sys_info_posix.cc.orig 2011-11-04 21:34:00.000000000 +0000 ++++ ipc/chromium/src/base/sys_info_posix.cc +@@ -18,6 +18,11 @@ + #include <mach/mach_init.h> + #endif + ++#if defined(OS_NETBSD) ++#include <sys/param.h> ++#include <sys/sysctl.h> ++#endif ++ + #include "base/logging.h" + #include "base/string_util.h" + +@@ -26,7 +31,11 @@ namespace base { + int SysInfo::NumberOfProcessors() { + // It seems that sysconf returns the number of "logical" processors on both + // mac and linux. So we get the number of "online logical" processors. ++#ifdef _SC_NPROCESSORS_ONLN + static long res = sysconf(_SC_NPROCESSORS_ONLN); ++#else ++ static long res = 1; ++#endif + if (res == -1) { + NOTREACHED(); + return 1; +@@ -52,6 +61,20 @@ int64 SysInfo::AmountOfPhysicalMemory() + } + + return static_cast<int64>(hostinfo.max_mem); ++#elif defined(OS_NETBSD) ++ int mib[2]; ++ int rc; ++ int64_t memSize; ++ size_t len = sizeof(memSize); ++ ++ mib[0] = CTL_HW; ++ mib[1] = HW_PHYSMEM64; ++ rc = sysctl( mib, 2, &memSize, &len, NULL, 0 ); ++ if (-1 != rc) { ++ return memSize; ++ } ++ return 0; ++ + #else + long pages = sysconf(_SC_PHYS_PAGES); + long page_size = sysconf(_SC_PAGE_SIZE); +$NetBSD: patch-ipc_chromium_src_base_third__party_nspr_prcpucfg.h,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/third_party/nspr/prcpucfg.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/third_party/nspr/prcpucfg.h +@@ -34,7 +34,7 @@ + #include "base/third_party/nspr/prcpucfg_win.h" + #elif defined(__APPLE__) + #include "base/third_party/nspr/prcpucfg_mac.h" +-#elif defined(__linux__) || defined(ANDROID) ++#elif defined(__linux__) || defined(ANDROID) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) + #include "base/third_party/nspr/prcpucfg_linux.h" + #elif defined(__OpenBSD__) + #include "base/third_party/nspr/prcpucfg_openbsd.h" +$NetBSD: patch-ipc_chromium_src_base_third__party_nspr_prtime.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/base/third_party/nspr/prtime.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/base/third_party/nspr/prtime.cc +@@ -212,7 +212,7 @@ PR_ImplodeTime(const PRExplodedTime *exp + LL_ADD(retVal, retVal, temp); + + return retVal; +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_DRAGONFLY) + struct tm exp_tm = {0}; + exp_tm.tm_sec = exploded->tm_sec; + exp_tm.tm_min = exploded->tm_min; +@@ -245,6 +245,24 @@ PR_ImplodeTime(const PRExplodedTime *exp + result *= kSecondsToMicroseconds; + result += exploded->tm_usec; + return result; ++#elif defined(OS_FREEBSD) || defined(OS_NETBSD) ++ struct tm exp_tm = {0}; ++ exp_tm.tm_sec = exploded->tm_sec; ++ exp_tm.tm_min = exploded->tm_min; ++ exp_tm.tm_hour = exploded->tm_hour; ++ exp_tm.tm_mday = exploded->tm_mday; ++ exp_tm.tm_mon = exploded->tm_month; ++ exp_tm.tm_year = exploded->tm_year - 1900; ++ ++ // time_t is 64bit ++ time_t absolute_time = timegm(&exp_tm); ++ ++ PRTime result = static_cast<PRTime>(absolute_time); ++ result -= exploded->tm_params.tp_gmt_offset + ++ exploded->tm_params.tp_dst_offset; ++ result *= kSecondsToMicroseconds; ++ result += exploded->tm_usec; ++ return result; + #else + #error No PR_ImplodeTime implemented on your platform. + #endif +diff --git ipc/chromium/src/base/time_posix.cc ipc/chromium/src/base/time_posix.cc +index abf2a56..48791f6 100644 +--- ipc/chromium/src/base/time_posix.cc ++++ ipc/chromium/src/base/time_posix.cc +@@ -167,7 +167,7 @@ TimeTicks TimeTicks::Now() { + // With numer and denom = 1 (the expected case), the 64-bit absolute time + // reported in nanoseconds is enough to last nearly 585 years. + +-#elif defined(__OpenBSD__) || defined(OS_POSIX) && \ ++#elif defined(OS_OPENBSD) || defined(OS_POSIX) && \ + defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 + + struct timespec ts; +$NetBSD: patch-ipc_chromium_src_build_build__config.h,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- ipc/chromium/src/build/build_config.h.orig 2012-03-13 01:36:53.000000000 +0000 ++++ ipc/chromium/src/build/build_config.h +@@ -19,17 +19,23 @@ + #define OS_MACOSX 1 + #elif defined(__linux__) || defined(ANDROID) + #define OS_LINUX 1 ++#elif defined(__NetBSD__) ++#define OS_NETBSD 1 ++#elif defined(__DragonFly__) ++#define OS_DRAGONFLY 1 + #elif defined(__OpenBSD__) + #define OS_OPENBSD 1 + #elif defined(_WIN32) + #define OS_WIN 1 ++#elif defined(__FreeBSD__) ++#define OS_FREEBSD 1 + #else + #error Please add support for your platform in build/build_config.h + #endif + + // For access to standard POSIX features, use OS_POSIX instead of a more + // specific macro. +-#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_OPENBSD) ++#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_BSD) + #define OS_POSIX 1 + #endif + +diff --git ipc/chromium/src/chrome/common/ipc_channel_posix.cc ipc/chromium/src/chrome/common/ipc_channel_posix.cc +index bd866ee..2ea5b19 100644 +--- ipc/chromium/src/chrome/common/ipc_channel_posix.cc ++++ ipc/chromium/src/chrome/common/ipc_channel_posix.cc +@@ -7,6 +7,7 @@ + #include <errno.h> + #include <fcntl.h> + #include <stddef.h> ++#include <unistd.h> + #include <sys/types.h> + #include <sys/socket.h> + #include <sys/stat.h> +$NetBSD: patch-ipc_chromium_src_chrome_common_ipc__channel__posix.h,v 1.1 2011/07/11 12:46:14 tnn Exp $ + +--- ipc/chromium/src/chrome/common/ipc_channel_posix.h.orig 2011-06-15 21:57:27.000000000 +0000 ++++ ipc/chromium/src/chrome/common/ipc_channel_posix.h +@@ -92,7 +92,7 @@ class Channel::ChannelImpl : public Mess + }; + + // This is a control message buffer large enough to hold kMaxReadFDs +-#if defined(OS_MACOSX) ++#if defined(OS_MACOSX) || defined(OS_NETBSD) + // TODO(agl): OSX appears to have non-constant CMSG macros! + char input_cmsg_buf_[1024]; + #else +$NetBSD: patch-ipc_chromium_src_chrome_common_ipc__message__utils.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/chrome/common/ipc_message_utils.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/chrome/common/ipc_message_utils.h +@@ -195,7 +195,7 @@ + }; + #endif + +-#if !(defined(OS_MACOSX) || defined(OS_OPENBSD) || defined(OS_WIN) || (defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)) || defined(ARCH_CPU_S390)) ++#if !(defined(OS_MACOSX) || defined(OS_OPENBSD) || defined(OS_WIN) || ((defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined(OS_NETBSD) || defined(OS_LINUX)) && defined(ARCH_CPU_64_BITS)) || defined(ARCH_CPU_S390)) + // There size_t is a synonym for |unsigned long| ... + template <> + struct ParamTraits<size_t> { +@@ -248,7 +248,7 @@ + }; + #endif // defined(OS_MACOSX) + +-#if !(defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)) ++#if !((defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined(OS_NETBSD) || defined(OS_LINUX)) && defined(ARCH_CPU_64_BITS)) + // int64 is |long int| on 64-bit systems, uint64 is |unsigned long| + template <> + struct ParamTraits<int64> { +$NetBSD: patch-ipc_chromium_src_chrome_common_transport__dib.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- ipc/chromium/src/chrome/common/transport_dib.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/chromium/src/chrome/common/transport_dib.h +@@ -7,7 +7,7 @@ + + #include "base/basictypes.h" + +-#if defined(OS_WIN) || defined(OS_MACOSX) ++#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + #include "base/shared_memory.h" + #endif + +@@ -66,7 +66,7 @@ class TransportDIB { + uint32 sequence_num; + }; + typedef HandleAndSequenceNum Id; +-#elif defined(OS_MACOSX) ++#elif defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + typedef base::SharedMemoryHandle Handle; + // On Mac, the inode number of the backing file is used as an id. + typedef base::SharedMemoryId Id; +@@ -108,7 +108,7 @@ class TransportDIB { + + private: + TransportDIB(); +-#if defined(OS_WIN) || defined(OS_MACOSX) ++#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + explicit TransportDIB(base::SharedMemoryHandle dib); + base::SharedMemory shared_memory_; + uint32 sequence_num_; +$NetBSD: patch-ipc_glue_GeckoChildProcessHost.cpp,v 1.2 2012/03/15 08:30:06 ryoon Exp $ + +--- ipc/glue/GeckoChildProcessHost.cpp.orig 2011-12-20 23:28:19.000000000 +0000 ++++ ipc/glue/GeckoChildProcessHost.cpp +@@ -430,7 +430,7 @@ + // and passing wstrings from one config to the other is unsafe. So + // we split the logic here. + +-#if defined(OS_LINUX) || defined(OS_MACOSX) ++#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD) + base::environment_map newEnvVars; + // XPCOM may not be initialized in some subprocesses. We don't want + // to initialize XPCOM just for the directory service, especially +@@ -445,8 +445,8 @@ + if (NS_SUCCEEDED(rv)) { + nsCString path; + greDir->GetNativePath(path); +-# ifdef OS_LINUX +-# ifdef MOZ_WIDGET_ANDROID ++# if defined(OS_LINUX) || defined(OS_BSD) ++# if defined(MOZ_WIDGET_ANDROID) || defined(OS_BSD) + path += "/lib"; + # endif // MOZ_WIDGET_ANDROID + const char *ld_library_path = PR_GetEnv("LD_LIBRARY_PATH"); +@@ -557,7 +557,7 @@ + childArgv.push_back(pidstring); + + #if defined(MOZ_CRASHREPORTER) +-# if defined(OS_LINUX) ++# if defined(OS_LINUX) || defined(OS_BSD) + int childCrashFd, childCrashRemapFd; + if (!CrashReporter::CreateNotificationPipeForChild( + &childCrashFd, &childCrashRemapFd)) +@@ -594,7 +594,7 @@ + #endif + + base::LaunchApp(childArgv, mFileMap, +-#if defined(OS_LINUX) || defined(OS_MACOSX) ++#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD) + newEnvVars, + #endif + false, &process, arch); +$NetBSD: patch-mm,v 1.13 2012/06/05 18:09:21 ryoon Exp $ + +--- toolkit/library/Makefile.in.orig 2012-05-23 18:57:09.000000000 +0000 ++++ toolkit/library/Makefile.in +@@ -534,6 +538,10 @@ EXTRA_DSO_LDOPTS += -lelf -ldemangle + endif + endif + ++ifneq (,$(filter DragonFly FreeBSD NetBSD,$(OS_ARCH))) ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++endif ++ + ifeq ($(OS_ARCH),WINNT) + OS_LIBS += $(call EXPAND_LIBNAME,shell32 ole32 version winspool comdlg32 imm32 msimg32 shlwapi psapi ws2_32 dbghelp rasapi32 rasdlg iphlpapi uxtheme setupapi secur32 sensorsapi portabledeviceguids windowscodecs wininet) + ifdef ACCESSIBILITY Deleted: branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-dir_reader_linux.h ============================================================================== --- branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-dir_reader_linux.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,52 +0,0 @@ ---- ipc/chromium/src/base/dir_reader_linux.h~ -+++ ipc/chromium/src/base/dir_reader_linux.h -@@ -12,6 +12,10 @@ - #include <sys/syscall.h> - #include <unistd.h> - -+#if defined(__FreeBSD__) -+#include <sys/dirent.h> -+#endif -+ - #include "base/logging.h" - #include "base/eintr_wrapper.h" - -@@ -19,6 +23,9 @@ - - namespace base { - -+#if defined(__FreeBSD__) -+#define linux_dirent struct dirent -+#else - struct linux_dirent { - uint64_t d_ino; - int64_t d_off; -@@ -26,11 +33,16 @@ struct linux_dirent { - unsigned char d_type; - char d_name[0]; - }; -+#endif - - class DirReaderLinux { - public: - explicit DirReaderLinux(const char* directory_path) -+#ifdef O_DIRECTORY - : fd_(open(directory_path, O_RDONLY | O_DIRECTORY)), -+#else -+ : fd_(open(directory_path, O_RDONLY)), -+#endif - offset_(0), - size_(0) { - memset(buf_, 0, sizeof(buf_)); -@@ -57,7 +69,11 @@ class DirReaderLinux { - if (offset_ != size_) - return true; - -+#if !defined(__FreeBSD__) - const int r = syscall(__NR_getdents64, fd_, buf_, sizeof(buf_)); -+#else -+ const int r = syscall(SYS_getdents, fd_, buf_, sizeof(buf_)); -+#endif - if (r == 0) - return false; - if (r == -1) { Modified: branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-file_util_linux.cc ============================================================================== --- branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-file_util_linux.cc Mon Jul 23 13:52:35 2012 (r886) +++ branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-file_util_linux.cc Mon Jul 23 22:39:41 2012 (r887) @@ -6,14 +6,3 @@ #include <fcntl.h> +#include <unistd.h> - #include <string> - #include <vector> -@@ -28,7 +29,7 @@ bool GetShmemTempDir(FilePath* path) { - #ifdef ANDROID - return GetTempDir(path); - #else -- *path = FilePath("/dev/shm"); -+ *path = FilePath("/tmp"); - return true; - #endif - } Deleted: branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-file_util_posix.cc ============================================================================== --- branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-file_util_posix.cc Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- ipc/chromium/src/base/file_util_posix.cc~ -+++ ipc/chromium/src/base/file_util_posix.cc -@@ -31,7 +31,7 @@ - #include "base/time.h" - - // FreeBSD/OpenBSD lacks stat64, but its stat handles files >2GB just fine --#if defined(OS_FREEBSD) || defined(OS_OPENBSD) -+#if defined(__FreeBSD__) || defined(OS_OPENBSD) - #define stat64 stat - #endif - Deleted: branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-platform_thread_posix.cc ============================================================================== --- branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-platform_thread_posix.cc Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,25 +0,0 @@ ---- ipc/chromium/src/base/platform_thread_posix.cc~ -+++ ipc/chromium/src/base/platform_thread_posix.cc -@@ -11,6 +11,7 @@ - #include <mach/mach.h> - #elif defined(OS_LINUX) - #include <sys/syscall.h> -+#include <pthread_np.h> - #include <unistd.h> - #endif - -@@ -34,7 +35,13 @@ PlatformThreadId PlatformThread::Current - #if defined(OS_MACOSX) - return mach_thread_self(); - #elif defined(OS_LINUX) -- return syscall(__NR_gettid); -+#if __FreeBSD_version > 900030 -+ return pthread_getthreadid_np(); -+#else -+ long tid; -+ syscall(SYS_thr_self, &tid); -+ return tid; -+#endif - #endif - } - Deleted: branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h ============================================================================== --- branches/experimental/www/libxul/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- ipc/chromium/src/base/third_party/nspr/prcpucfg.h~ -+++ ipc/chromium/src/base/third_party/nspr/prcpucfg.h -@@ -34,7 +34,7 @@ - #include "base/third_party/nspr/prcpucfg_win.h" - #elif defined(__APPLE__) - #include "base/third_party/nspr/prcpucfg_mac.h" --#elif defined(__linux__) || defined(ANDROID) -+#elif defined(__FreeBSD__) || defined(ANDROID) - #include "base/third_party/nspr/prcpucfg_linux.h" - #else - #error Provide a prcpucfg.h appropriate for your platform Deleted: branches/experimental/www/libxul/files/patch-ipc-chromium-src-build-build_config.h ============================================================================== --- branches/experimental/www/libxul/files/patch-ipc-chromium-src-build-build_config.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- ipc/chromium/src/build/build_config.h~ -+++ ipc/chromium/src/build/build_config.h -@@ -17,7 +17,7 @@ - // A set of macros to use for platform detection. - #if defined(__APPLE__) - #define OS_MACOSX 1 --#elif defined(__linux__) || defined(ANDROID) -+#elif defined(__linux__) || defined(ANDROID) || defined(__FreeBSD__) - #define OS_LINUX 1 - #elif defined(__OpenBSD__) - #define OS_OPENBSD 1 Deleted: branches/experimental/www/libxul/files/patch-toolkit_library_Makefile.in ============================================================================== --- branches/experimental/www/libxul/files/patch-toolkit_library_Makefile.in Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- toolkit/library/Makefile.in.orig 2010-01-11 12:13:08.000000000 -0500 -+++ toolkit/library/Makefile.in 2010-01-11 12:15:05.000000000 -0500 -@@ -181,7 +181,7 @@ - export:: $(RDF_UTIL_SRC_CPPSRCS) $(INTL_UNICHARUTIL_UTIL_CPPSRCS) - $(INSTALL) $^ . - --EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(EXTRA_DSO_LIBS) -+EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(EXTRA_DSO_LIBS) -lexecinfo - - ifdef MOZ_ENABLE_LIBXUL - include $(srcdir)/libxul-rules.mk Modified: branches/experimental/www/seamonkey/Makefile ============================================================================== --- branches/experimental/www/seamonkey/Makefile Mon Jul 23 13:52:35 2012 (r886) +++ branches/experimental/www/seamonkey/Makefile Mon Jul 23 22:39:41 2012 (r887) @@ -19,7 +19,6 @@ nss>=3.13.2:${PORTSDIR}/security/nss \ sqlite3>=3.7.11:${PORTSDIR}/databases/sqlite3 \ unzip:${PORTSDIR}/archivers/unzip -LIB_DEPENDS= execinfo.1:${PORTSDIR}/devel/libexecinfo USE_AUTOTOOLS= autoconf213:env CONFLICTS_BUILD= spidermonkey-1.[0-7]* Added: branches/experimental/www/seamonkey/files/patch-bug753046 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/experimental/www/seamonkey/files/patch-bug753046 Mon Jul 23 22:39:41 2012 (r887) @@ -0,0 +1,1261 @@ +# Bug 753046 - Add support for DragonFly/NetBSD + +$NetBSD: patch-dom_plugins_ipc_PluginModuleChild.cpp,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/dom/plugins/ipc/PluginModuleChild.cpp.orig 2011-12-20 23:28:14.000000000 +0000 ++++ mozilla/dom/plugins/ipc/PluginModuleChild.cpp +@@ -33,6 +33,8 @@ + #include "nsPluginsDir.h" + #include "nsXULAppAPI.h" + ++#include <unistd.h> ++ + #ifdef MOZ_X11 + # include "mozilla/X11Util.h" + #endif +@@ -228,7 +228,7 @@ PluginModuleChild::Init(const std::strin + + // TODO: use PluginPRLibrary here + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + mShutdownFunc = + (NP_PLUGINSHUTDOWN) PR_FindFunctionSymbol(mLibrary, "NP_Shutdown"); + +@@ -1790,7 +1790,7 @@ PluginModuleChild::AnswerNP_GetEntryPoin + PLUGIN_LOG_DEBUG_METHOD; + AssertPluginThread(); + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + return true; + #elif defined(OS_WIN) || defined(OS_MACOSX) + *_retval = mGetEntryPointsFunc(&mFunctions); +@@ -1823,7 +1823,7 @@ PluginModuleChild::AnswerNP_Initialize(N + SendBackUpXResources(FileDescriptor(xSocketFd, false/*don't close*/)); + #endif + +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + *_retval = mInitializeFunc(&sBrowserFuncs, &mFunctions); + return true; + #elif defined(OS_WIN) || defined(OS_MACOSX) +$NetBSD: patch-dom_plugins_ipc_PluginModuleChild.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/dom/plugins/ipc/PluginModuleChild.h.orig 2011-12-20 23:28:14.000000000 +0000 ++++ mozilla/dom/plugins/ipc/PluginModuleChild.h +@@ -340,7 +340,7 @@ private: + + // we get this from the plugin + NP_PLUGINSHUTDOWN mShutdownFunc; +-#ifdef OS_LINUX ++#if defined(OS_LINUX) || defined(OS_BSD) + NP_PLUGINUNIXINIT mInitializeFunc; + #elif defined(OS_WIN) || defined(OS_MACOSX) + NP_PLUGININIT mInitializeFunc; +$NetBSD: patch-ipc_chromium_Makefile.in,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/Makefile.in.orig 2012-02-16 06:40:33.000000000 +0000 ++++ mozilla/ipc/chromium/Makefile.in +@@ -278,6 +278,34 @@ endif + + endif # } OS_LINUX + ++ifdef OS_BSD # { ++ ++CPPSRCS += \ ++ atomicops_internals_x86_gcc.cc \ ++ file_util_bsd.cc \ ++ process_util_bsd.cc \ ++ time_posix.cc \ ++ $(NULL) ++ ++ifdef MOZ_ENABLE_GTK2 ++CPPSRCS += \ ++ message_pump_glib.cc \ ++ $(NULL) ++endif ++ ++ifdef MOZ_ENABLE_QT ++MOCSRCS = \ ++ moc_message_pump_qt.cc \ ++ $(NULL) ++ ++CPPSRCS += \ ++ $(MOCSRCS) \ ++ message_pump_qt.cc \ ++ $(NULL) ++endif ++ ++endif # } OS_BSD ++ + # libevent + + ifndef MOZ_NATIVE_LIBEVENT # { +$NetBSD: patch-ipc_chromium_chromium-config.mk,v 1.2 2012/03/15 08:30:06 ryoon Exp $ + +--- mozilla/ipc/chromium/chromium-config.mk.orig 2012-02-16 07:40:33.000000000 +0100 ++++ mozilla/ipc/chromium/chromium-config.mk 2012-03-11 11:05:40.397182000 +0100 +@@ -56,17 +56,6 @@ + -I$(DEPTH)/ipc/ipdl/_ipdlheaders \ + $(NULL) + +-ifeq ($(OS_ARCH),Darwin) # { +- +-OS_MACOSX = 1 +-OS_POSIX = 1 +- +-DEFINES += \ +- -DOS_MACOSX=1 \ +- -DOS_POSIX=1 \ +- $(NULL) +- +-else # } { + ifeq ($(OS_ARCH),WINNT) # { + OS_LIBS += $(call EXPAND_LIBNAME,psapi shell32 dbghelp) + +@@ -93,13 +82,64 @@ + endif + + else # } { +- +-OS_LINUX = 1 + OS_POSIX = 1 ++DEFINES += -DOS_POSIX=1 ++ ++ifeq ($(OS_ARCH),Darwin) # { ++ ++OS_MACOSX = 1 ++DEFINES += \ ++ -DOS_MACOSX=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),DragonFly) # { ++ ++OS_DRAGONFLY = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_DRAGONFLY=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),FreeBSD) # { ++ ++OS_FREEBSD = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_FREEBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) + ++else # } { ++ifeq ($(OS_ARCH),NetBSD) # { ++ ++OS_NETBSD = 1 ++OS_BSD = 1 ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++DEFINES += \ ++ -DOS_NETBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ifeq ($(OS_ARCH),OpenBSD) # { ++ ++OS_OPENBSD = 1 ++OS_BSD = 1 ++DEFINES += \ ++ -DOS_OPENBSD=1 \ ++ -DOS_BSD=1 \ ++ $(NULL) ++ ++else # } { ++ ++OS_LINUX = 1 + DEFINES += \ + -DOS_LINUX=1 \ +- -DOS_POSIX=1 \ + $(NULL) + + # NB: to stop gcc warnings about exporting template instantiation +@@ -107,4 +147,8 @@ + + endif # } + endif # } ++endif # } ++endif # } ++endif # } ++endif # } + +$NetBSD: patch-ipc_chromium_src_base_base__paths.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/base_paths.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/base_paths.h +@@ -13,7 +13,7 @@ + #include "base/base_paths_win.h" + #elif defined(OS_MACOSX) + #include "base/base_paths_mac.h" +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_BSD) + #include "base/base_paths_linux.h" + #endif + #include "base/path_service.h" +$NetBSD: patch-ipc_chromium_src_base_debug__util__posic.cc,v 1.3 2012/04/01 15:18:45 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/debug_util_posix.cc.orig 2012-03-13 01:36:53.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/debug_util_posix.cc +@@ -5,7 +5,7 @@ + #include "build/build_config.h" + #include "base/debug_util.h" + +-#define MOZ_HAVE_EXECINFO_H (!defined(ANDROID) && !defined(__OpenBSD__)) ++#define MOZ_HAVE_EXECINFO_H (defined(OS_LINUX) && !defined(ANDROID)) + + #include <errno.h> + #include <fcntl.h> +@@ -17,8 +17,13 @@ + #include <unistd.h> + #if MOZ_HAVE_EXECINFO_H + #include <execinfo.h> +-#include <sys/sysctl.h> + #endif ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++#include <sys/user.h> ++#elif defined(OS_FREEBSD) ++#include <sys/proc.h> ++#endif ++#include <sys/sysctl.h> + + #include "base/basictypes.h" + #include "base/eintr_wrapper.h" +@@ -32,7 +37,7 @@ bool DebugUtil::SpawnDebuggerOnProcess(u + return false; + } + +-#if defined(OS_MACOSX) ++#if defined(OS_MACOSX) || defined(OS_BSD) + + // Based on Apple's recommended method as described in + // http://developer.apple.com/qa/qa2004/qa1361.html +@@ -71,7 +76,13 @@ bool DebugUtil::BeingDebugged() { + + // This process is being debugged if the P_TRACED flag is set. + is_set = true; ++#if defined(OS_DRAGONFLY) ++ being_debugged = (info.kp_flags & P_TRACED) != 0; ++#elif defined(OS_FREEBSD) ++ being_debugged = (info.ki_flag & P_TRACED) != 0; ++#else + being_debugged = (info.kp_proc.p_flag & P_TRACED) != 0; ++#endif + return being_debugged; + } + +diff --git ipc/chromium/src/base/dir_reader_bsd.h ipc/chromium/src/base/dir_reader_bsd.h +new file mode 100644 +index 0000000..3fc1a87 +--- /dev/null ++++ mozilla/ipc/chromium/src/base/dir_reader_bsd.h +@@ -0,0 +1,98 @@ ++// Copyright (c) 2010 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. ++ ++// derived from dir_reader_linux.h ++ ++#ifndef BASE_DIR_READER_BSD_H_ ++#define BASE_DIR_READER_BSD_H_ ++#pragma once ++ ++#include <dirent.h> ++#include <errno.h> ++#include <fcntl.h> ++#include <stdint.h> ++#include <unistd.h> ++ ++#include "base/logging.h" ++#include "base/eintr_wrapper.h" ++ ++// See the comments in dir_reader_posix.h about this. ++ ++namespace base { ++ ++class DirReaderBSD { ++ public: ++ explicit DirReaderBSD(const char* directory_path) ++#ifdef O_DIRECTORY ++ : fd_(open(directory_path, O_RDONLY | O_DIRECTORY)), ++#else ++ : fd_(open(directory_path, O_RDONLY)), ++#endif ++ offset_(0), ++ size_(0) { ++ memset(buf_, 0, sizeof(buf_)); ++ } ++ ++ ~DirReaderBSD() { ++ if (fd_ >= 0) { ++ if (HANDLE_EINTR(close(fd_))) ++ DLOG(ERROR) << "Failed to close directory handle"; ++ } ++ } ++ ++ bool IsValid() const { ++ return fd_ >= 0; ++ } ++ ++ // Move to the next entry returning false if the iteration is complete. ++ bool Next() { ++ if (size_) { ++ struct dirent* dirent = reinterpret_cast<struct dirent*>(&buf_[offset_]); ++ offset_ += dirent->d_reclen; ++ } ++ ++ if (offset_ != size_) ++ return true; ++ ++ const int r = getdirentries(fd_, buf_, sizeof(buf_), basep_); ++ if (r == 0) ++ return false; ++ if (r == -1) { ++ DLOG(ERROR) << "getdirentries returned an error: " << errno; ++ return false; ++ } ++ size_ = r; ++ offset_ = 0; ++ return true; ++ } ++ ++ const char* name() const { ++ if (!size_) ++ return NULL; ++ ++ const struct dirent* dirent = ++ reinterpret_cast<const struct dirent*>(&buf_[offset_]); ++ return dirent->d_name; ++ } ++ ++ int fd() const { ++ return fd_; ++ } ++ ++ static bool IsFallback() { ++ return false; ++ } ++ ++ private: ++ const int fd_; ++ char buf_[512]; ++ long *basep_; ++ size_t offset_, size_; ++ ++ DISALLOW_COPY_AND_ASSIGN(DirReaderBSD); ++}; ++ ++} // namespace base ++ ++#endif // BASE_DIR_READER_BSD_H_ +diff --git ipc/chromium/src/base/dir_reader_posix.h ipc/chromium/src/base/dir_reader_posix.h +index 9a34492..62b280c 100644 +--- mozilla/ipc/chromium/src/base/dir_reader_posix.h ++++ mozilla/ipc/chromium/src/base/dir_reader_posix.h +@@ -18,16 +18,20 @@ + // seems worse than falling back to enumerating all file descriptors so we will + // probably never implement this on the Mac. + +-#if defined(OS_LINUX) && !defined(OS_OPENBSD) ++#if defined(OS_LINUX) + #include "base/dir_reader_linux.h" ++#elif defined(OS_BSD) ++#include "base/dir_reader_bsd.h" + #else + #include "base/dir_reader_fallback.h" + #endif + + namespace base { + +-#if defined(OS_LINUX) && !defined(OS_OPENBSD) ++#if defined(OS_LINUX) + typedef DirReaderLinux DirReaderPosix; ++#elif defined(OS_BSD) ++typedef DirReaderBSD DirReaderPosix; + #else + typedef DirReaderFallback DirReaderPosix; + #endif +$NetBSD: patch-ipc_chromium_src_base_file__util.h,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/file_util.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/file_util.h +@@ -16,8 +16,8 @@ + #include <sys/stat.h> + #elif defined(OS_POSIX) + #include <sys/types.h> +-#include <fts.h> + #include <sys/stat.h> ++#include <fts.h> + #endif + + #include <stdio.h> +$NetBSD: patch-ipc_chromium_src_base_file__util__bsd.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/file_util_bsd.cc.orig 2012-01-07 18:21:18.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/file_util_bsd.cc +@@ -0,0 +1,80 @@ ++// Copyright (c) 2006-2008 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. ++ ++// this is a derivative of file_util_linux.cc ++ ++#include "base/file_util.h" ++ ++#include <fcntl.h> ++#include <unistd.h> ++ ++#include <string> ++#include <vector> ++ ++#include "base/eintr_wrapper.h" ++#include "base/file_path.h" ++#include "base/string_util.h" ++ ++namespace file_util { ++ ++bool GetTempDir(FilePath* path) { ++ const char* tmp = getenv("TMPDIR"); ++ if (tmp) ++ *path = FilePath(tmp); ++ else ++ *path = FilePath("/tmp"); ++ return true; ++} ++ ++bool GetShmemTempDir(FilePath* path) { ++ return GetTempDir(path); ++} ++ ++bool CopyFile(const FilePath& from_path, const FilePath& to_path) { ++ int infile = open(from_path.value().c_str(), O_RDONLY); ++ if (infile < 0) ++ return false; ++ ++ int outfile = creat(to_path.value().c_str(), 0666); ++ if (outfile < 0) { ++ close(infile); ++ return false; ++ } ++ ++ const size_t kBufferSize = 32768; ++ std::vector<char> buffer(kBufferSize); ++ bool result = true; ++ ++ while (result) { ++ ssize_t bytes_read = HANDLE_EINTR(read(infile, &buffer[0], buffer.size())); ++ if (bytes_read < 0) { ++ result = false; ++ break; ++ } ++ if (bytes_read == 0) ++ break; ++ // Allow for partial writes ++ ssize_t bytes_written_per_read = 0; ++ do { ++ ssize_t bytes_written_partial = HANDLE_EINTR(write( ++ outfile, ++ &buffer[bytes_written_per_read], ++ bytes_read - bytes_written_per_read)); ++ if (bytes_written_partial < 0) { ++ result = false; ++ break; ++ } ++ bytes_written_per_read += bytes_written_partial; ++ } while (bytes_written_per_read < bytes_read); ++ } ++ ++ if (HANDLE_EINTR(close(infile)) < 0) ++ result = false; ++ if (HANDLE_EINTR(close(outfile)) < 0) ++ result = false; ++ ++ return result; ++} ++ ++} // namespace file_util +$NetBSD: patch-ipc_chromium_src_base_file__util__posix.cc,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/file_util_posix.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/file_util_posix.cc +@@ -31,7 +31,7 @@ + #include "base/time.h" + + // FreeBSD/OpenBSD lacks stat64, but its stat handles files >2GB just fine +-#if defined(OS_FREEBSD) || defined(OS_OPENBSD) ++#ifndef OS_LINUX + #define stat64 stat + #endif + +$NetBSD: patch-ipc_chromium_src_base_message__loop.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/message_loop.cc.orig 2012-02-16 07:40:33.000000000 +0100 ++++ mozilla/ipc/chromium/src/base/message_loop.cc 2012-02-21 21:24:41.000000000 +0100 +@@ -19,7 +19,7 @@ + #if defined(OS_POSIX) + #include "base/message_pump_libevent.h" + #endif +-#if defined(OS_LINUX) ++#if defined(OS_LINUX) || defined(OS_BSD) + #ifdef MOZ_WIDGET_GTK2 + #include "base/message_pump_glib.h" + #endif +@@ -119,7 +119,7 @@ + if (type_ == TYPE_UI) { + #if defined(OS_MACOSX) + pump_ = base::MessagePumpMac::Create(); +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_BSD) + pump_ = new base::MessagePumpForUI(); + #endif // OS_LINUX + } else if (type_ == TYPE_IO) { +$NetBSD: patch-ipc_chromium_src_base_platform__file__posix.cc,v 1.1 2011/07/12 15:12:36 tnn Exp $ + +--- mozilla/ipc/chromium/src/base/platform_file_posix.cc.orig 2011-06-15 21:57:27.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/platform_file_posix.cc +@@ -9,6 +9,7 @@ + #ifdef ANDROID + #include <linux/stat.h> + #endif ++#include <sys/stat.h> /* for S_IRUSR */ + + #include "base/logging.h" + #include "base/string_util.h" +$NetBSD: patch-ipc_chromium_src_base_platform__thread.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/platform_thread.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/platform_thread.h +@@ -25,6 +25,8 @@ typedef pthread_t PlatformThreadHandle; + #if defined(OS_LINUX) + #include <unistd.h> + typedef pid_t PlatformThreadId; ++#elif defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined (OS_NETBSD) ++typedef lwpid_t PlatformThreadId; + #elif defined(OS_MACOSX) + #include <mach/mach.h> + typedef mach_port_t PlatformThreadId; +$NetBSD: patch-ipc_chromium_src_base_platform__thread__posix.cc,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/platform_thread_posix.cc.orig 2012-03-13 01:36:53.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/platform_thread_posix.cc +@@ -9,9 +9,18 @@ + + #if defined(OS_MACOSX) + #include <mach/mach.h> ++#elif defined(OS_NETBSD) ++#include <lwp.h> + #elif defined(OS_LINUX) + #include <sys/syscall.h> + #include <unistd.h> ++#elif defined(OS_DRAGONFLY) ++#include <unistd.h> ++#elif defined(OS_FREEBSD) ++_Pragma("GCC visibility push(default)") ++extern "C" int thr_self(long *); // XXX #include <sys/thr.h> ++_Pragma("GCC visibility pop") ++#include <pthread_np.h> + #endif + + #if defined(OS_MACOSX) +@@ -38,7 +45,19 @@ + // into the kernel. + #if defined(OS_MACOSX) + return mach_thread_self(); +-#elif defined (__OpenBSD__) ++#elif defined(OS_NETBSD) ++ return _lwp_self(); ++#elif defined(OS_DRAGONFLY) ++ return lwp_gettid(); ++#elif defined(OS_FREEBSD) ++# if __FreeBSD_version > 900030 ++ return pthread_getthreadid_np(); ++# else ++ long lwpid; ++ thr_self(&lwpid); ++ return lwpid; ++# endif ++#elif defined(OS_OPENBSD) + // TODO(BSD): find a better thread ID + return (intptr_t)(pthread_self()); + #elif defined(OS_LINUX) +$NetBSD: patch-ipc_chromium_src_base_process__util.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/process_util.h.orig 2011-12-21 00:28:19.000000000 +0100 ++++ mozilla/ipc/chromium/src/base/process_util.h 2012-01-31 13:14:54.000000000 +0100 +@@ -280,6 +280,7 @@ class NamedProcessIterator { + const ProcessEntry* NextProcessEntry(); + + private: ++#if !defined(OS_BSD) + // Determines whether there's another process (regardless of executable) + // left in the list of all processes. Returns true and sets entry_ to + // that process's info if there is one, false otherwise. +@@ -292,18 +292,24 @@ + void InitProcessEntry(ProcessEntry* entry); + + std::wstring executable_name_; ++#endif + + #if defined(OS_WIN) + HANDLE snapshot_; + bool started_iteration_; + #elif defined(OS_LINUX) + DIR *procfs_dir_; ++#elif defined(OS_BSD) ++ std::vector<ProcessEntry> content; ++ size_t nextEntry; + #elif defined(OS_MACOSX) + std::vector<kinfo_proc> kinfo_procs_; + size_t index_of_kinfo_proc_; + #endif ++#if !defined(OS_BSD) + ProcessEntry entry_; + const ProcessFilter* filter_; ++#endif + + DISALLOW_EVIL_CONSTRUCTORS(NamedProcessIterator); + }; +$NetBSD: patch-ipc_chromium_src_base_process__util__bsd.cc,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/process_util_bsd.cc.orig 2012-04-01 00:04:28.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/process_util_bsd.cc +@@ -0,0 +1,326 @@ ++// Copyright (c) 2008 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. ++ ++// derived from process_util_linux.cc and process_util_mac.cc ++ ++#include "base/process_util.h" ++ ++#include <ctype.h> ++#include <fcntl.h> ++#include <unistd.h> ++#include <string> ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++/* DragonFly, as of v3.0.1, and FreeBSD 9.0-RELEASE do not explicitly mark symbols public */ ++#define PRE_SYS_INCLUDE _Pragma("GCC visibility push(default)") ++#define POST_SYS_INCLUDE _Pragma("GCC visibility pop") ++#else ++#define PRE_SYS_INCLUDE ++#define POST_SYS_INCLUDE ++#endif ++PRE_SYS_INCLUDE ++#include <kvm.h> ++POST_SYS_INCLUDE ++#include <sys/sysctl.h> ++#include <sys/types.h> ++#include <sys/wait.h> ++#if defined(OS_DRAGONFLY) ++PRE_SYS_INCLUDE ++#include <sys/user.h> ++POST_SYS_INCLUDE ++#define HAVE_POSIX_SPAWN 1 ++#endif ++#if defined(OS_FREEBSD) ++PRE_SYS_INCLUDE ++#include <sys/user.h> ++POST_SYS_INCLUDE ++#endif ++ ++#include "base/debug_util.h" ++#include "base/eintr_wrapper.h" ++#include "base/file_util.h" ++#include "base/logging.h" ++#include "base/string_tokenizer.h" ++#include "base/string_util.h" ++ ++#if defined(OS_NETBSD) ++#include <sys/param.h> ++#if __NetBSD_Version__ >= 600000000 ++#define HAVE_POSIX_SPAWN 1 ++#endif ++#endif ++ ++#ifdef HAVE_POSIX_SPAWN ++PRE_SYS_INCLUDE ++#include <spawn.h> ++POST_SYS_INCLUDE ++extern "C" char **environ __dso_public; ++#endif ++ ++namespace { ++ ++enum ParsingState { ++ KEY_NAME, ++ KEY_VALUE ++}; ++ ++static mozilla::EnvironmentLog gProcessLog("MOZ_PROCESS_LOG"); ++ ++} // namespace ++ ++namespace base { ++ ++#ifdef HAVE_POSIX_SPAWN ++ ++void FreeEnvVarsArray(char* array[], int length) ++{ ++ for (int i = 0; i < length; i++) { ++ free(array[i]); ++ } ++ delete[] array; ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ bool wait, ProcessHandle* process_handle) { ++ return LaunchApp(argv, fds_to_remap, environment_map(), ++ wait, process_handle); ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ const environment_map& env_vars_to_set, ++ bool wait, ProcessHandle* process_handle, ++ ProcessArchitecture arch) { ++ bool retval = true; ++ ++ char* argv_copy[argv.size() + 1]; ++ for (size_t i = 0; i < argv.size(); i++) { ++ argv_copy[i] = const_cast<char*>(argv[i].c_str()); ++ } ++ argv_copy[argv.size()] = NULL; ++ ++ // Make sure we don't leak any FDs to the child process by marking all FDs ++ // as close-on-exec. ++ SetAllFDsToCloseOnExec(); ++ ++ // Copy environment to a new char array and add the variables ++ // in env_vars_to_set. ++ // Existing variables are overwritten by env_vars_to_set. ++ int pos = 0; ++ environment_map combined_env_vars = env_vars_to_set; ++ while(environ[pos] != NULL) { ++ std::string varString = environ[pos]; ++ std::string varName = varString.substr(0, varString.find_first_of('=')); ++ std::string varValue = varString.substr(varString.find_first_of('=') + 1); ++ if (combined_env_vars.find(varName) == combined_env_vars.end()) { ++ combined_env_vars[varName] = varValue; ++ } ++ pos++; ++ } ++ int varsLen = combined_env_vars.size() + 1; ++ ++ char** vars = new char*[varsLen]; ++ int i = 0; ++ for (environment_map::const_iterator it = combined_env_vars.begin(); ++ it != combined_env_vars.end(); ++it) { ++ std::string entry(it->first); ++ entry += "="; ++ entry += it->second; ++ vars[i] = strdup(entry.c_str()); ++ i++; ++ } ++ vars[i] = NULL; ++ ++ posix_spawn_file_actions_t file_actions; ++ if (posix_spawn_file_actions_init(&file_actions) != 0) { ++ FreeEnvVarsArray(vars, varsLen); ++ return false; ++ } ++ ++ // Turn fds_to_remap array into a set of dup2 calls. ++ for (file_handle_mapping_vector::const_iterator it = fds_to_remap.begin(); ++ it != fds_to_remap.end(); ++ ++it) { ++ int src_fd = it->first; ++ int dest_fd = it->second; ++ ++ if (src_fd == dest_fd) { ++ int flags = fcntl(src_fd, F_GETFD); ++ if (flags != -1) { ++ fcntl(src_fd, F_SETFD, flags & ~FD_CLOEXEC); ++ } ++ } else { ++ if (posix_spawn_file_actions_adddup2(&file_actions, src_fd, dest_fd) != 0) { ++ posix_spawn_file_actions_destroy(&file_actions); ++ FreeEnvVarsArray(vars, varsLen); ++ return false; ++ } ++ } ++ } ++ ++ pid_t pid = 0; ++ int spawn_succeeded = (posix_spawnp(&pid, ++ argv_copy[0], ++ &file_actions, ++ NULL, ++ argv_copy, ++ vars) == 0); ++ ++ FreeEnvVarsArray(vars, varsLen); ++ ++ posix_spawn_file_actions_destroy(&file_actions); ++ ++ bool process_handle_valid = pid > 0; ++ if (!spawn_succeeded || !process_handle_valid) { ++ retval = false; ++ } else { ++ if (wait) ++ HANDLE_EINTR(waitpid(pid, 0, 0)); ++ ++ if (process_handle) ++ *process_handle = pid; ++ } ++ ++ return retval; ++} ++ ++bool LaunchApp(const CommandLine& cl, ++ bool wait, bool start_hidden, ProcessHandle* process_handle) { ++ // TODO(playmobil): Do we need to respect the start_hidden flag? ++ file_handle_mapping_vector no_files; ++ return LaunchApp(cl.argv(), no_files, wait, process_handle); ++} ++ ++#else // no posix_spawn, use fork/exec ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ bool wait, ProcessHandle* process_handle) { ++ return LaunchApp(argv, fds_to_remap, environment_map(), ++ wait, process_handle); ++} ++ ++bool LaunchApp(const std::vector<std::string>& argv, ++ const file_handle_mapping_vector& fds_to_remap, ++ const environment_map& env_vars_to_set, ++ bool wait, ProcessHandle* process_handle, ++ ProcessArchitecture arch) { ++ scoped_array<char*> argv_cstr(new char*[argv.size() + 1]); ++ // Illegal to allocate memory after fork and before execvp ++ InjectiveMultimap fd_shuffle1, fd_shuffle2; ++ fd_shuffle1.reserve(fds_to_remap.size()); ++ fd_shuffle2.reserve(fds_to_remap.size()); ++ ++ pid_t pid = fork(); ++ if (pid < 0) ++ return false; ++ ++ if (pid == 0) { ++ for (file_handle_mapping_vector::const_iterator ++ it = fds_to_remap.begin(); it != fds_to_remap.end(); ++it) { ++ fd_shuffle1.push_back(InjectionArc(it->first, it->second, false)); ++ fd_shuffle2.push_back(InjectionArc(it->first, it->second, false)); ++ } ++ ++ if (!ShuffleFileDescriptors(&fd_shuffle1)) ++ _exit(127); ++ ++ CloseSuperfluousFds(fd_shuffle2); ++ ++ for (environment_map::const_iterator it = env_vars_to_set.begin(); ++ it != env_vars_to_set.end(); ++it) { ++ if (setenv(it->first.c_str(), it->second.c_str(), 1/*overwrite*/)) ++ _exit(127); ++ } ++ ++ for (size_t i = 0; i < argv.size(); i++) ++ argv_cstr[i] = const_cast<char*>(argv[i].c_str()); ++ argv_cstr[argv.size()] = NULL; ++ execvp(argv_cstr[0], argv_cstr.get()); ++ // if we get here, we're in serious trouble and should complain loudly ++ DLOG(ERROR) << "FAILED TO exec() CHILD PROCESS, path: " << argv_cstr[0]; ++ exit(127); ++ } else { ++ gProcessLog.print("==> process %d launched child process %d\n", ++ GetCurrentProcId(), pid); ++ if (wait) ++ HANDLE_EINTR(waitpid(pid, 0, 0)); ++ ++ if (process_handle) ++ *process_handle = pid; ++ } ++ ++ return true; ++} ++ ++bool LaunchApp(const CommandLine& cl, ++ bool wait, bool start_hidden, ++ ProcessHandle* process_handle) { ++ file_handle_mapping_vector no_files; ++ return LaunchApp(cl.argv(), no_files, wait, process_handle); ++} ++ ++#endif ++ ++NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name, ++ const ProcessFilter* filter) ++{ ++ int numEntries; ++ kvm_t *kvm; ++ std::string exe(WideToASCII(executable_name)); ++ ++#if defined(OS_DRAGONFLY) || defined(OS_FREEBSD) ++ kvm = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL); ++ struct kinfo_proc* procs = kvm_getprocs(kvm, KERN_PROC_UID, getuid(), &numEntries); ++ if (procs != NULL && numEntries > 0) { ++ for (int i = 0; i < numEntries; i++) { ++# if defined(OS_DRAGONFLY) ++ if (exe != procs[i].kp_comm) continue; ++ if (filter && !filter->Includes(procs[i].kp_pid, procs[i].kp_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].kp_pid; ++ e.ppid = procs[i].kp_ppid; ++ strlcpy(e.szExeFile, procs[i].kp_comm, sizeof e.szExeFile); ++ content.push_back(e); ++# elif defined(OS_FREEBSD) ++ if (exe != procs[i].ki_comm) continue; ++ if (filter && !filter->Includes(procs[i].ki_pid, procs[i].ki_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].ki_pid; ++ e.ppid = procs[i].ki_ppid; ++ strlcpy(e.szExeFile, procs[i].ki_comm, sizeof e.szExeFile); ++ content.push_back(e); ++# endif ++#else ++ kvm = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL); ++ struct kinfo_proc2* procs = kvm_getproc2(kvm, KERN_PROC_UID, getuid(), sizeof(struct kinfo_proc2), &numEntries); ++ if (procs != NULL && numEntries > 0) { ++ for (int i = 0; i < numEntries; i++) { ++ if (exe != procs[i].p_comm) continue; ++ if (filter && !filter->Includes(procs[i].p_pid, procs[i].p_ppid)) continue; ++ ProcessEntry e; ++ e.pid = procs[i].p_pid; ++ e.ppid = procs[i].p_ppid; ++ strlcpy(e.szExeFile, procs[i].p_comm, sizeof e.szExeFile); ++ content.push_back(e); ++#endif ++ } ++ } ++ nextEntry = 0; ++ kvm_close(kvm); ++} ++ ++NamedProcessIterator::~NamedProcessIterator() { ++} ++ ++const ProcessEntry* NamedProcessIterator::NextProcessEntry() { ++ if (nextEntry >= content.size()) return NULL; ++ return &content[nextEntry++]; ++} ++ ++bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { ++ return false; ++} ++ ++} // namespace base +$NetBSD: patch-ipc_chromium_src_base_process__util__posix.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/process_util_posix.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/process_util_posix.cc +@@ -116,6 +116,11 @@ void CloseSuperfluousFds(const base::Inj + #elif defined(OS_MACOSX) + static const rlim_t kSystemDefaultMaxFds = 256; + static const char kFDDir[] = "/dev/fd"; ++#elif defined(OS_BSD) ++ // the getrlimit below should never fail, so whatever .. ++ static const rlim_t kSystemDefaultMaxFds = 1024; ++ // at least /dev/fd will exist ++ static const char kFDDir[] = "/dev/fd"; + #endif + + // Get the maximum number of FDs possible. +@@ -199,7 +204,7 @@ void CloseSuperfluousFds(const base::Inj + void SetAllFDsToCloseOnExec() { + #if defined(OS_LINUX) + const char fd_dir[] = "/proc/self/fd"; +-#elif defined(OS_MACOSX) ++#elif defined(OS_MACOSX) || defined(OS_BSD) + const char fd_dir[] = "/dev/fd"; + #endif + ScopedDIR dir_closer(opendir(fd_dir)); +$NetBSD: patch-ipc_chromium_src_base_sys__info__posix.cc,v 1.2 2011/11/27 13:09:00 tnn Exp $ + +--- mozilla/ipc/chromium/src/base/sys_info_posix.cc.orig 2011-11-04 21:34:00.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/sys_info_posix.cc +@@ -18,6 +18,11 @@ + #include <mach/mach_init.h> + #endif + ++#if defined(OS_NETBSD) ++#include <sys/param.h> ++#include <sys/sysctl.h> ++#endif ++ + #include "base/logging.h" + #include "base/string_util.h" + +@@ -26,7 +31,11 @@ namespace base { + int SysInfo::NumberOfProcessors() { + // It seems that sysconf returns the number of "logical" processors on both + // mac and linux. So we get the number of "online logical" processors. ++#ifdef _SC_NPROCESSORS_ONLN + static long res = sysconf(_SC_NPROCESSORS_ONLN); ++#else ++ static long res = 1; ++#endif + if (res == -1) { + NOTREACHED(); + return 1; +@@ -52,6 +61,20 @@ int64 SysInfo::AmountOfPhysicalMemory() + } + + return static_cast<int64>(hostinfo.max_mem); ++#elif defined(OS_NETBSD) ++ int mib[2]; ++ int rc; ++ int64_t memSize; ++ size_t len = sizeof(memSize); ++ ++ mib[0] = CTL_HW; ++ mib[1] = HW_PHYSMEM64; ++ rc = sysctl( mib, 2, &memSize, &len, NULL, 0 ); ++ if (-1 != rc) { ++ return memSize; ++ } ++ return 0; ++ + #else + long pages = sysconf(_SC_PHYS_PAGES); + long page_size = sysconf(_SC_PAGE_SIZE); +$NetBSD: patch-ipc_chromium_src_base_third__party_nspr_prcpucfg.h,v 1.2 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/third_party/nspr/prcpucfg.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/third_party/nspr/prcpucfg.h +@@ -34,7 +34,7 @@ + #include "base/third_party/nspr/prcpucfg_win.h" + #elif defined(__APPLE__) + #include "base/third_party/nspr/prcpucfg_mac.h" +-#elif defined(__linux__) || defined(ANDROID) ++#elif defined(__linux__) || defined(ANDROID) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) + #include "base/third_party/nspr/prcpucfg_linux.h" + #elif defined(__OpenBSD__) + #include "base/third_party/nspr/prcpucfg_openbsd.h" +$NetBSD: patch-ipc_chromium_src_base_third__party_nspr_prtime.cc,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/base/third_party/nspr/prtime.cc.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/base/third_party/nspr/prtime.cc +@@ -212,7 +212,7 @@ PR_ImplodeTime(const PRExplodedTime *exp + LL_ADD(retVal, retVal, temp); + + return retVal; +-#elif defined(OS_LINUX) ++#elif defined(OS_LINUX) || defined(OS_DRAGONFLY) + struct tm exp_tm = {0}; + exp_tm.tm_sec = exploded->tm_sec; + exp_tm.tm_min = exploded->tm_min; +@@ -245,6 +245,24 @@ PR_ImplodeTime(const PRExplodedTime *exp + result *= kSecondsToMicroseconds; + result += exploded->tm_usec; + return result; ++#elif defined(OS_FREEBSD) || defined(OS_NETBSD) ++ struct tm exp_tm = {0}; ++ exp_tm.tm_sec = exploded->tm_sec; ++ exp_tm.tm_min = exploded->tm_min; ++ exp_tm.tm_hour = exploded->tm_hour; ++ exp_tm.tm_mday = exploded->tm_mday; ++ exp_tm.tm_mon = exploded->tm_month; ++ exp_tm.tm_year = exploded->tm_year - 1900; ++ ++ // time_t is 64bit ++ time_t absolute_time = timegm(&exp_tm); ++ ++ PRTime result = static_cast<PRTime>(absolute_time); ++ result -= exploded->tm_params.tp_gmt_offset + ++ exploded->tm_params.tp_dst_offset; ++ result *= kSecondsToMicroseconds; ++ result += exploded->tm_usec; ++ return result; + #else + #error No PR_ImplodeTime implemented on your platform. + #endif +diff --git ipc/chromium/src/base/time_posix.cc ipc/chromium/src/base/time_posix.cc +index abf2a56..48791f6 100644 +--- mozilla/ipc/chromium/src/base/time_posix.cc ++++ mozilla/ipc/chromium/src/base/time_posix.cc +@@ -167,7 +167,7 @@ TimeTicks TimeTicks::Now() { + // With numer and denom = 1 (the expected case), the 64-bit absolute time + // reported in nanoseconds is enough to last nearly 585 years. + +-#elif defined(__OpenBSD__) || defined(OS_POSIX) && \ ++#elif defined(OS_OPENBSD) || defined(OS_POSIX) && \ + defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 + + struct timespec ts; +$NetBSD: patch-ipc_chromium_src_build_build__config.h,v 1.4 2012/04/01 15:18:45 ryoon Exp $ + +--- mozilla/ipc/chromium/src/build/build_config.h.orig 2012-03-13 01:36:53.000000000 +0000 ++++ mozilla/ipc/chromium/src/build/build_config.h +@@ -19,17 +19,23 @@ + #define OS_MACOSX 1 + #elif defined(__linux__) || defined(ANDROID) + #define OS_LINUX 1 ++#elif defined(__NetBSD__) ++#define OS_NETBSD 1 ++#elif defined(__DragonFly__) ++#define OS_DRAGONFLY 1 + #elif defined(__OpenBSD__) + #define OS_OPENBSD 1 + #elif defined(_WIN32) + #define OS_WIN 1 ++#elif defined(__FreeBSD__) ++#define OS_FREEBSD 1 + #else + #error Please add support for your platform in build/build_config.h + #endif + + // For access to standard POSIX features, use OS_POSIX instead of a more + // specific macro. +-#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_OPENBSD) ++#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_BSD) + #define OS_POSIX 1 + #endif + +diff --git ipc/chromium/src/chrome/common/ipc_channel_posix.cc ipc/chromium/src/chrome/common/ipc_channel_posix.cc +index bd866ee..2ea5b19 100644 +--- mozilla/ipc/chromium/src/chrome/common/ipc_channel_posix.cc ++++ mozilla/ipc/chromium/src/chrome/common/ipc_channel_posix.cc +@@ -7,6 +7,7 @@ + #include <errno.h> + #include <fcntl.h> + #include <stddef.h> ++#include <unistd.h> + #include <sys/types.h> + #include <sys/socket.h> + #include <sys/stat.h> +$NetBSD: patch-ipc_chromium_src_chrome_common_ipc__channel__posix.h,v 1.1 2011/07/11 12:46:14 tnn Exp $ + +--- mozilla/ipc/chromium/src/chrome/common/ipc_channel_posix.h.orig 2011-06-15 21:57:27.000000000 +0000 ++++ mozilla/ipc/chromium/src/chrome/common/ipc_channel_posix.h +@@ -92,7 +92,7 @@ class Channel::ChannelImpl : public Mess + }; + + // This is a control message buffer large enough to hold kMaxReadFDs +-#if defined(OS_MACOSX) ++#if defined(OS_MACOSX) || defined(OS_NETBSD) + // TODO(agl): OSX appears to have non-constant CMSG macros! + char input_cmsg_buf_[1024]; + #else +$NetBSD: patch-ipc_chromium_src_chrome_common_ipc__message__utils.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/chrome/common/ipc_message_utils.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/chrome/common/ipc_message_utils.h +@@ -195,7 +195,7 @@ + }; + #endif + +-#if !(defined(OS_MACOSX) || defined(OS_OPENBSD) || defined(OS_WIN) || (defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)) || defined(ARCH_CPU_S390)) ++#if !(defined(OS_MACOSX) || defined(OS_OPENBSD) || defined(OS_WIN) || ((defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined(OS_NETBSD) || defined(OS_LINUX)) && defined(ARCH_CPU_64_BITS)) || defined(ARCH_CPU_S390)) + // There size_t is a synonym for |unsigned long| ... + template <> + struct ParamTraits<size_t> { +@@ -248,7 +248,7 @@ + }; + #endif // defined(OS_MACOSX) + +-#if !(defined(OS_LINUX) && defined(ARCH_CPU_64_BITS)) ++#if !((defined(OS_FREEBSD) || defined(OS_DRAGONFLY) || defined(OS_NETBSD) || defined(OS_LINUX)) && defined(ARCH_CPU_64_BITS)) + // int64 is |long int| on 64-bit systems, uint64 is |unsigned long| + template <> + struct ParamTraits<int64> { +$NetBSD: patch-ipc_chromium_src_chrome_common_transport__dib.h,v 1.1 2012/03/06 12:34:09 ryoon Exp $ + +--- mozilla/ipc/chromium/src/chrome/common/transport_dib.h.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/chromium/src/chrome/common/transport_dib.h +@@ -7,7 +7,7 @@ + + #include "base/basictypes.h" + +-#if defined(OS_WIN) || defined(OS_MACOSX) ++#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + #include "base/shared_memory.h" + #endif + +@@ -66,7 +66,7 @@ class TransportDIB { + uint32 sequence_num; + }; + typedef HandleAndSequenceNum Id; +-#elif defined(OS_MACOSX) ++#elif defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + typedef base::SharedMemoryHandle Handle; + // On Mac, the inode number of the backing file is used as an id. + typedef base::SharedMemoryId Id; +@@ -108,7 +108,7 @@ class TransportDIB { + + private: + TransportDIB(); +-#if defined(OS_WIN) || defined(OS_MACOSX) ++#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_BSD) + explicit TransportDIB(base::SharedMemoryHandle dib); + base::SharedMemory shared_memory_; + uint32 sequence_num_; +$NetBSD: patch-ipc_glue_GeckoChildProcessHost.cpp,v 1.2 2012/03/15 08:30:06 ryoon Exp $ + +--- mozilla/ipc/glue/GeckoChildProcessHost.cpp.orig 2011-12-20 23:28:19.000000000 +0000 ++++ mozilla/ipc/glue/GeckoChildProcessHost.cpp +@@ -430,7 +430,7 @@ + // and passing wstrings from one config to the other is unsafe. So + // we split the logic here. + +-#if defined(OS_LINUX) || defined(OS_MACOSX) ++#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD) + base::environment_map newEnvVars; + // XPCOM may not be initialized in some subprocesses. We don't want + // to initialize XPCOM just for the directory service, especially +@@ -445,8 +445,8 @@ + if (NS_SUCCEEDED(rv)) { + nsCString path; + greDir->GetNativePath(path); +-# ifdef OS_LINUX +-# ifdef MOZ_WIDGET_ANDROID ++# if defined(OS_LINUX) || defined(OS_BSD) ++# if defined(MOZ_WIDGET_ANDROID) || defined(OS_BSD) + path += "/lib"; + # endif // MOZ_WIDGET_ANDROID + const char *ld_library_path = PR_GetEnv("LD_LIBRARY_PATH"); +@@ -557,7 +557,7 @@ + childArgv.push_back(pidstring); + + #if defined(MOZ_CRASHREPORTER) +-# if defined(OS_LINUX) ++# if defined(OS_LINUX) || defined(OS_BSD) + int childCrashFd, childCrashRemapFd; + if (!CrashReporter::CreateNotificationPipeForChild( + &childCrashFd, &childCrashRemapFd)) +@@ -594,7 +594,7 @@ + #endif + + base::LaunchApp(childArgv, mFileMap, +-#if defined(OS_LINUX) || defined(OS_MACOSX) ++#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_BSD) + newEnvVars, + #endif + false, &process, arch); +$NetBSD: patch-mm,v 1.13 2012/06/05 18:09:21 ryoon Exp $ + +--- mozilla/toolkit/library/Makefile.in.orig 2012-05-23 18:57:09.000000000 +0000 ++++ mozilla/toolkit/library/Makefile.in +@@ -534,6 +538,10 @@ EXTRA_DSO_LDOPTS += -lelf -ldemangle + endif + endif + ++ifneq (,$(filter DragonFly FreeBSD NetBSD,$(OS_ARCH))) ++OS_LIBS += $(call EXPAND_LIBNAME,kvm) ++endif ++ + ifeq ($(OS_ARCH),WINNT) + OS_LIBS += $(call EXPAND_LIBNAME,shell32 ole32 version winspool comdlg32 imm32 msimg32 shlwapi psapi ws2_32 dbghelp rasapi32 rasdlg iphlpapi uxtheme setupapi secur32 sensorsapi portabledeviceguids windowscodecs wininet) + ifdef ACCESSIBILITY Deleted: branches/experimental/www/seamonkey/files/patch-ipc-chromium-src-base-file_util_linux.cc ============================================================================== --- branches/experimental/www/seamonkey/files/patch-ipc-chromium-src-base-file_util_linux.cc Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- mozilla/ipc/chromium/src/base/file_util_linux.cc~ -+++ mozilla/ipc/chromium/src/base/file_util_linux.cc -@@ -28,7 +29,7 @@ bool GetShmemTempDir(FilePath* path) { - #ifdef ANDROID - return GetTempDir(path); - #else -- *path = FilePath("/dev/shm"); -+ *path = FilePath("/tmp"); - return true; - #endif - } Deleted: branches/experimental/www/seamonkey/files/patch-ipc-chromium-src-base-file_util_posix.cc ============================================================================== --- branches/experimental/www/seamonkey/files/patch-ipc-chromium-src-base-file_util_posix.cc Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- mozilla/ipc/chromium/src/base/file_util_posix.cc~ -+++ mozilla/ipc/chromium/src/base/file_util_posix.cc -@@ -31,7 +31,7 @@ - #include "base/time.h" - - // FreeBSD/OpenBSD lacks stat64, but its stat handles files >2GB just fine --#if defined(OS_FREEBSD) || defined(OS_OPENBSD) -+#if defined(__FreeBSD__) || defined(OS_OPENBSD) - #define stat64 stat - #endif - Deleted: branches/experimental/www/seamonkey/files/patch-ipc-chromium-src-base-platform_thread_posix.cc ============================================================================== --- branches/experimental/www/seamonkey/files/patch-ipc-chromium-src-base-platform_thread_posix.cc Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,12 +0,0 @@ ---- mozilla/ipc/chromium/src/base/platform_thread_posix.cc.orig 2011-04-27 09:34:28.000000000 +0200 -+++ mozilla/ipc/chromium/src/base/platform_thread_posix.cc 2011-04-27 19:47:36.344446266 +0200 -@@ -34,7 +33,8 @@ - #if defined(OS_MACOSX) - return mach_thread_self(); - #elif defined(OS_LINUX) -- return syscall(__NR_gettid); -+ // TODO(BSD): find a better thread ID -+ return reinterpret_cast<int64>(pthread_self()); - #endif - } - Deleted: branches/experimental/www/seamonkey/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h ============================================================================== --- branches/experimental/www/seamonkey/files/patch-ipc-chromium-src-base-third_party-nspr-prcpucfg.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- mozilla/ipc/chromium/src/base/third_party/nspr/prcpucfg.h~ -+++ mozilla/ipc/chromium/src/base/third_party/nspr/prcpucfg.h -@@ -34,7 +34,7 @@ - #include "base/third_party/nspr/prcpucfg_win.h" - #elif defined(__APPLE__) - #include "base/third_party/nspr/prcpucfg_mac.h" --#elif defined(__linux__) || defined(ANDROID) -+#elif defined(__FreeBSD__) || defined(ANDROID) - #include "base/third_party/nspr/prcpucfg_linux.h" - #else - #error Provide a prcpucfg.h appropriate for your platform Deleted: branches/experimental/www/seamonkey/files/patch-ipc-chromium-src-build-build_config.h ============================================================================== --- branches/experimental/www/seamonkey/files/patch-ipc-chromium-src-build-build_config.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- mozilla/ipc/chromium/src/build/build_config.h~ -+++ mozilla/ipc/chromium/src/build/build_config.h -@@ -17,7 +17,7 @@ - // A set of macros to use for platform detection. - #if defined(__APPLE__) - #define OS_MACOSX 1 --#elif defined(__linux__) || defined(ANDROID) -+#elif defined(__linux__) || defined(ANDROID) || defined(__FreeBSD__) - #define OS_LINUX 1 - #elif defined(__OpenBSD__) - #define OS_OPENBSD 1 Deleted: branches/experimental/www/seamonkey/files/patch-mozilla-ipc-chromium-src-base-dir_reader_linux.h ============================================================================== --- branches/experimental/www/seamonkey/files/patch-mozilla-ipc-chromium-src-base-dir_reader_linux.h Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,52 +0,0 @@ ---- mozilla/ipc/chromium/src/base/dir_reader_linux.h~ -+++ mozilla/ipc/chromium/src/base/dir_reader_linux.h -@@ -12,6 +12,10 @@ - #include <sys/syscall.h> - #include <unistd.h> - -+#if defined(__FreeBSD__) -+#include <sys/dirent.h> -+#endif -+ - #include "base/logging.h" - #include "base/eintr_wrapper.h" - -@@ -19,6 +23,9 @@ - - namespace base { - -+#if defined(__FreeBSD__) -+#define linux_dirent struct dirent -+#else - struct linux_dirent { - uint64_t d_ino; - int64_t d_off; -@@ -26,11 +33,16 @@ struct linux_dirent { - unsigned char d_type; - char d_name[0]; - }; -+#endif - - class DirReaderLinux { - public: - explicit DirReaderLinux(const char* directory_path) -+#ifdef O_DIRECTORY - : fd_(open(directory_path, O_RDONLY | O_DIRECTORY)), -+#else -+ : fd_(open(directory_path, O_RDONLY)), -+#endif - offset_(0), - size_(0) { - memset(buf_, 0, sizeof(buf_)); -@@ -57,7 +69,11 @@ class DirReaderLinux { - if (offset_ != size_) - return true; - -+#if !defined(__FreeBSD__) - const int r = syscall(__NR_getdents64, fd_, buf_, sizeof(buf_)); -+#else -+ const int r = syscall(SYS_getdents, fd_, buf_, sizeof(buf_)); -+#endif - if (r == 0) - return false; - if (r == -1) { Deleted: branches/experimental/www/seamonkey/files/patch-mozilla-toolkit-library-Makefile.in ============================================================================== --- branches/experimental/www/seamonkey/files/patch-mozilla-toolkit-library-Makefile.in Mon Jul 23 22:39:41 2012 (r886) +++ /dev/null 00:00:00 1970 (deleted) @@ -1,11 +0,0 @@ ---- mozilla/toolkit/library/Makefile.in.orig 2012-06-15 14:04:29.000000000 +0200 -+++ mozilla/toolkit/library/Makefile.in 2012-06-19 20:48:15.000000000 +0200 -@@ -438,7 +443,7 @@ - endif - endif - --EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(EXTRA_DSO_LIBS) -+EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(EXTRA_DSO_LIBS) -lexecinfo - - DEFINES += -DIMPL_XREAPI -
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207232239.q6NMdf2T064243>