Bug 1835185 - Replace OS_*BSD with equivalent macros in ipc code. r=ipc-reviewers,mccr8

Differential Revision: https://phabricator.services.mozilla.com/D180049
This commit is contained in:
Mike Hommey 2023-06-06 21:05:34 +00:00
parent 55ec63d832
commit 6195df0b79
11 changed files with 38 additions and 30 deletions

View file

@ -49,7 +49,7 @@ class DirReaderBSD {
bool Next() { bool Next() {
if (size_) { if (size_) {
struct dirent* dirent = reinterpret_cast<struct dirent*>(&buf_[offset_]); struct dirent* dirent = reinterpret_cast<struct dirent*>(&buf_[offset_]);
#ifdef OS_DRAGONFLY #ifdef __DragonFly__
offset_ += _DIRENT_DIRSIZ(dirent); offset_ += _DIRENT_DIRSIZ(dirent);
#else #else
offset_ += dirent->d_reclen; offset_ += dirent->d_reclen;

View file

@ -22,7 +22,9 @@
#if defined(XP_LINUX) #if defined(XP_LINUX)
# include "base/dir_reader_linux.h" # include "base/dir_reader_linux.h"
#elif defined(OS_BSD) && !defined(__GLIBC__) #elif (defined(__DragonFly__) || defined(XP_FREEBSD) || defined(XP_NETBSD) || \
defined(XP_OPENBSD)) && \
!defined(__GLIBC__)
# include "base/dir_reader_bsd.h" # include "base/dir_reader_bsd.h"
#else #else
# include "base/dir_reader_fallback.h" # include "base/dir_reader_fallback.h"
@ -32,7 +34,9 @@ namespace base {
#if defined(XP_LINUX) #if defined(XP_LINUX)
typedef DirReaderLinux DirReaderPosix; typedef DirReaderLinux DirReaderPosix;
#elif defined(OS_BSD) && !defined(__GLIBC__) #elif (defined(__DragonFly__) || defined(XP_FREEBSD) || defined(XP_NETBSD) || \
defined(XP_OPENBSD)) && \
!defined(__GLIBC__)
typedef DirReaderBSD DirReaderPosix; typedef DirReaderBSD DirReaderPosix;
#else #else
typedef DirReaderFallback DirReaderPosix; typedef DirReaderFallback DirReaderPosix;

View file

@ -26,7 +26,8 @@
#if defined(XP_UNIX) #if defined(XP_UNIX)
# include "base/message_pump_libevent.h" # include "base/message_pump_libevent.h"
#endif #endif
#if defined(XP_LINUX) || defined(OS_BSD) #if defined(XP_LINUX) || defined(__DragonFly__) || defined(XP_FREEBSD) || \
defined(XP_NETBSD) || defined(XP_OPENBSD)
# if defined(MOZ_WIDGET_GTK) # if defined(MOZ_WIDGET_GTK)
# include "base/message_pump_glib.h" # include "base/message_pump_glib.h"
# endif # endif
@ -279,7 +280,8 @@ MessageLoop::MessageLoop(Type type, nsISerialEventTarget* aEventTarget)
if (type_ == TYPE_UI) { if (type_ == TYPE_UI) {
# if defined(XP_DARWIN) # if defined(XP_DARWIN)
pump_ = base::MessagePumpMac::Create(); pump_ = base::MessagePumpMac::Create();
# elif defined(XP_LINUX) || defined(OS_BSD) # elif defined(XP_LINUX) || defined(__DragonFly__) || defined(XP_FREEBSD) || \
defined(XP_NETBSD) || defined(XP_OPENBSD)
pump_ = new base::MessagePumpForUI(); pump_ = new base::MessagePumpForUI();
# endif // XP_LINUX # endif // XP_LINUX
} else if (type_ == TYPE_IO) { } else if (type_ == TYPE_IO) {

View file

@ -24,11 +24,11 @@ typedef void* PlatformThreadHandle; // HANDLE
#elif defined(XP_UNIX) #elif defined(XP_UNIX)
# include <pthread.h> # include <pthread.h>
typedef pthread_t PlatformThreadHandle; typedef pthread_t PlatformThreadHandle;
# if defined(XP_LINUX) || defined(OS_OPENBSD) || defined(XP_SOLARIS) || \ # if defined(XP_LINUX) || defined(XP_OPENBSD) || defined(XP_SOLARIS) || \
defined(__GLIBC__) defined(__GLIBC__)
# include <unistd.h> # include <unistd.h>
typedef pid_t PlatformThreadId; typedef pid_t PlatformThreadId;
# elif defined(OS_BSD) # elif defined(__DragonFly__) || defined(XP_FREEBSD) || defined(XP_NETBSD)
# include <sys/types.h> # include <sys/types.h>
typedef lwpid_t PlatformThreadId; typedef lwpid_t PlatformThreadId;
# elif defined(XP_DARWIN) # elif defined(XP_DARWIN)

View file

@ -11,7 +11,7 @@
#if defined(XP_DARWIN) #if defined(XP_DARWIN)
# include <mach/mach.h> # include <mach/mach.h>
#elif defined(OS_NETBSD) #elif defined(XP_NETBSD)
# include <lwp.h> # include <lwp.h>
#elif defined(XP_LINUX) #elif defined(XP_LINUX)
# include <sys/syscall.h> # include <sys/syscall.h>
@ -22,7 +22,8 @@
# include <unistd.h> # include <unistd.h>
#endif #endif
#if defined(OS_BSD) && !defined(OS_NETBSD) && !defined(__GLIBC__) #if (defined(__DragonFly__) || defined(XP_FREEBSD) || defined(XP_OPENBSD)) && \
!defined(__GLIBC__)
# include <pthread_np.h> # include <pthread_np.h>
#endif #endif
@ -51,13 +52,13 @@ PlatformThreadId PlatformThread::CurrentId() {
return port; return port;
#elif defined(XP_LINUX) #elif defined(XP_LINUX)
return syscall(__NR_gettid); return syscall(__NR_gettid);
#elif defined(OS_OPENBSD) || defined(XP_SOLARIS) || defined(__GLIBC__) #elif defined(XP_OPENBSD) || defined(XP_SOLARIS) || defined(__GLIBC__)
return (intptr_t)(pthread_self()); return (intptr_t)(pthread_self());
#elif defined(OS_NETBSD) #elif defined(XP_NETBSD)
return _lwp_self(); return _lwp_self();
#elif defined(OS_DRAGONFLY) #elif defined(__DragonFly__)
return lwp_gettid(); return lwp_gettid();
#elif defined(OS_FREEBSD) #elif defined(XP_FREEBSD)
return pthread_getthreadid_np(); return pthread_getthreadid_np();
#endif #endif
} }

View file

@ -127,7 +127,8 @@ void CloseSuperfluousFds(void* aCtx, bool (*aShouldPreserve)(void*, int)) {
#elif defined(XP_DARWIN) #elif defined(XP_DARWIN)
static const rlim_t kSystemDefaultMaxFds = 256; static const rlim_t kSystemDefaultMaxFds = 256;
static const char kFDDir[] = "/dev/fd"; static const char kFDDir[] = "/dev/fd";
#elif defined(OS_BSD) #elif defined(__DragonFly__) || defined(XP_FREEBSD) || defined(XP_NETBSD) || \
defined(XP_OPENBSD)
// the getrlimit below should never fail, so whatever .. // the getrlimit below should never fail, so whatever ..
static const rlim_t kSystemDefaultMaxFds = 1024; static const rlim_t kSystemDefaultMaxFds = 1024;
// at least /dev/fd will exist // at least /dev/fd will exist

View file

@ -176,7 +176,7 @@ TimeTicks TimeTicks::Now() {
// With numer and denom = 1 (the expected case), the 64-bit absolute time // With numer and denom = 1 (the expected case), the 64-bit absolute time
// reported in nanoseconds is enough to last nearly 585 years. // reported in nanoseconds is enough to last nearly 585 years.
#elif defined(OS_OPENBSD) || defined(XP_UNIX) && \ #elif defined(XP_OPENBSD) || defined(XP_UNIX) && \
defined(_POSIX_MONOTONIC_CLOCK) && \ defined(_POSIX_MONOTONIC_CLOCK) && \
_POSIX_MONOTONIC_CLOCK >= 0 _POSIX_MONOTONIC_CLOCK >= 0

View file

@ -16,7 +16,7 @@
# include "mozilla/UniquePtrExtensions.h" # include "mozilla/UniquePtrExtensions.h"
# include "chrome/common/mach_ipc_mac.h" # include "chrome/common/mach_ipc_mac.h"
#endif #endif
#if defined(XP_DARWIN) || defined(OS_NETBSD) #if defined(XP_DARWIN) || defined(XP_NETBSD)
# include <sched.h> # include <sched.h>
#endif #endif
#include <stddef.h> #include <stddef.h>
@ -692,7 +692,7 @@ bool Channel::ChannelImpl::ProcessOutgoingMessages() {
// Not an error; the sendmsg would have blocked, so return to the // Not an error; the sendmsg would have blocked, so return to the
// event loop and try again later. // event loop and try again later.
break; break;
#if defined(XP_DARWIN) || defined(OS_NETBSD) #if defined(XP_DARWIN) || defined(XP_NETBSD)
// (Note: this comment is copied from https://crrev.com/86c3d9ef4fdf6; // (Note: this comment is copied from https://crrev.com/86c3d9ef4fdf6;
// see also bug 1142693 comment #73.) // see also bug 1142693 comment #73.)
// //

View file

@ -13,7 +13,7 @@
#if defined(XP_WIN) #if defined(XP_WIN)
# include "mozilla/UniquePtrExtensions.h" # include "mozilla/UniquePtrExtensions.h"
#endif #endif
#if !defined(XP_WIN) && !defined(OS_NETBSD) && !defined(OS_OPENBSD) #if !defined(XP_WIN) && !defined(XP_NETBSD) && !defined(XP_OPENBSD)
# include <pthread.h> # include <pthread.h>
# include "mozilla/ipc/SharedMemoryBasic.h" # include "mozilla/ipc/SharedMemoryBasic.h"
# include "mozilla/Atomics.h" # include "mozilla/Atomics.h"
@ -38,7 +38,7 @@ struct ParamTraits;
namespace mozilla { namespace mozilla {
#if defined(XP_WIN) #if defined(XP_WIN)
typedef mozilla::UniqueFileHandle CrossProcessMutexHandle; typedef mozilla::UniqueFileHandle CrossProcessMutexHandle;
#elif !defined(OS_NETBSD) && !defined(OS_OPENBSD) #elif !defined(XP_NETBSD) && !defined(XP_OPENBSD)
typedef mozilla::ipc::SharedMemoryBasic::Handle CrossProcessMutexHandle; typedef mozilla::ipc::SharedMemoryBasic::Handle CrossProcessMutexHandle;
#else #else
// Stub for other platforms. We can't use uintptr_t here since different // Stub for other platforms. We can't use uintptr_t here since different
@ -103,7 +103,7 @@ class CrossProcessMutex {
#if defined(XP_WIN) #if defined(XP_WIN)
HANDLE mMutex; HANDLE mMutex;
#elif !defined(OS_NETBSD) && !defined(OS_OPENBSD) #elif !defined(XP_NETBSD) && !defined(XP_OPENBSD)
RefPtr<mozilla::ipc::SharedMemoryBasic> mSharedBuffer; RefPtr<mozilla::ipc::SharedMemoryBasic> mSharedBuffer;
pthread_mutex_t* mMutex; pthread_mutex_t* mMutex;
mozilla::Atomic<int32_t>* mCount; mozilla::Atomic<int32_t>* mCount;

View file

@ -1207,7 +1207,8 @@ Result<Ok, LaunchError> PosixProcessLauncher::DoSetup() {
MOZ_ASSERT(gGREBinPath); MOZ_ASSERT(gGREBinPath);
nsCString path; nsCString path;
NS_CopyUnicodeToNative(nsDependentString(gGREBinPath), path); NS_CopyUnicodeToNative(nsDependentString(gGREBinPath), path);
# if defined(XP_LINUX) || defined(OS_BSD) # if defined(XP_LINUX) || defined(__DragonFly__) || defined(XP_FREEBSD) || \
defined(XP_NETBSD) || defined(XP_OPENBSD)
const char* ld_library_path = PR_GetEnv("LD_LIBRARY_PATH"); const char* ld_library_path = PR_GetEnv("LD_LIBRARY_PATH");
nsCString new_ld_lib_path(path.get()); nsCString new_ld_lib_path(path.get());
@ -1217,7 +1218,7 @@ Result<Ok, LaunchError> PosixProcessLauncher::DoSetup() {
} }
mLaunchOptions->env_map["LD_LIBRARY_PATH"] = new_ld_lib_path.get(); mLaunchOptions->env_map["LD_LIBRARY_PATH"] = new_ld_lib_path.get();
# elif XP_DARWIN // defined(XP_LINUX) || defined(OS_BSD) # elif XP_DARWIN
// With signed production Mac builds, the dynamic linker (dyld) will // With signed production Mac builds, the dynamic linker (dyld) will
// ignore dyld environment variables preventing the use of variables // ignore dyld environment variables preventing the use of variables
// such as DYLD_LIBRARY_PATH and DYLD_INSERT_LIBRARIES. // such as DYLD_LIBRARY_PATH and DYLD_INSERT_LIBRARIES.
@ -1245,7 +1246,7 @@ Result<Ok, LaunchError> PosixProcessLauncher::DoSetup() {
mLaunchOptions->env_map["OS_ACTIVITY_MODE"] = "disable"; mLaunchOptions->env_map["OS_ACTIVITY_MODE"] = "disable";
} }
# endif // defined(MOZ_SANDBOX) # endif // defined(MOZ_SANDBOX)
# endif // defined(XP_LINUX) || defined(OS_BSD) # endif
} }
FilePath exePath; FilePath exePath;
@ -1304,7 +1305,9 @@ Result<Ok, LaunchError> PosixProcessLauncher::DoSetup() {
mChildArgv.push_back(mPidString); mChildArgv.push_back(mPidString);
if (!CrashReporter::IsDummy()) { if (!CrashReporter::IsDummy()) {
# if defined(XP_LINUX) || defined(OS_BSD) || defined(XP_SOLARIS) # if defined(MOZ_WIDGET_COCOA)
mChildArgv.push_back(CrashReporter::GetChildNotificationPipe());
# elif defined(XP_UNIX)
int childCrashFd, childCrashRemapFd; int childCrashFd, childCrashRemapFd;
if (NS_WARN_IF(!CrashReporter::CreateNotificationPipeForChild( if (NS_WARN_IF(!CrashReporter::CreateNotificationPipeForChild(
&childCrashFd, &childCrashRemapFd))) { &childCrashFd, &childCrashRemapFd))) {
@ -1320,10 +1323,7 @@ Result<Ok, LaunchError> PosixProcessLauncher::DoSetup() {
// "false" == crash reporting disabled // "false" == crash reporting disabled
mChildArgv.push_back("false"); mChildArgv.push_back("false");
} }
# elif defined(MOZ_WIDGET_COCOA) /* defined(XP_LINUX) || defined(OS_BSD) || \ # endif
defined(XP_SOLARIS) */
mChildArgv.push_back(CrashReporter::GetChildNotificationPipe());
# endif // defined(XP_LINUX) || defined(OS_BSD) || defined(XP_SOLARIS)
} }
int fd = PR_FileDesc2NativeHandle(mCrashAnnotationWritePipe); int fd = PR_FileDesc2NativeHandle(mCrashAnnotationWritePipe);

View file

@ -8,7 +8,7 @@
#include <pthread.h> #include <pthread.h>
#if !defined(OS_NETBSD) #if !defined(XP_NETBSD)
# include <pthread_np.h> # include <pthread_np.h>
#endif #endif
@ -16,7 +16,7 @@ namespace mozilla {
namespace ipc { namespace ipc {
void SetThisProcessName(const char* aName) { void SetThisProcessName(const char* aName) {
#if defined(OS_NETBSD) #if defined(XP_NETBSD)
pthread_setname_np(pthread_self(), "%s", (void*)aName); pthread_setname_np(pthread_self(), "%s", (void*)aName);
#else #else
pthread_set_name_np(pthread_self(), aName); pthread_set_name_np(pthread_self(), aName);