adding missed HURD adoptions
authorCarsten Schoenert <c.schoenert@t-online.de>
Sun, 24 Apr 2016 18:49:46 +0000 (20:49 +0200)
committerCarsten Schoenert <c.schoenert@t-online.de>
Fri, 8 Apr 2022 15:33:51 +0000 (16:33 +0100)
Based on https://lists.alioth.debian.org/pipermail/pkg-mozilla-maintainers/2016-April/027634.html

Gbp-Pq: Topic porting-kfreebsd-hurd
Gbp-Pq: Name adding-missed-HURD-adoptions.patch

ipc/chromium/src/base/platform_thread.h
ipc/chromium/src/base/platform_thread_posix.cc
ipc/chromium/src/base/port.h
ipc/chromium/src/base/process_util.h
ipc/chromium/src/base/process_util_posix.cc
security/nss/gtests/google_test/gtest/include/gtest/internal/gtest-port.h
security/sandbox/chromium/build/build_config.h
third_party/libwebrtc/webrtc/build/build_config.h
third_party/sipcc/cpr_types.h

index 42f48651439f5dc71f6f4d104ff2b4439b1b52c6..41e84dca6735e0c816c9a09328b1fbfe5a603196 100644 (file)
@@ -25,7 +25,7 @@ typedef void* PlatformThreadHandle;  // HANDLE
 #  include <pthread.h>
 typedef pthread_t PlatformThreadHandle;
 #  if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_SOLARIS) || \
-      defined(__GLIBC__)
+      defined(__GLIBC__) || defined(OS_HURD)
 #    include <unistd.h>
 typedef pid_t PlatformThreadId;
 #  elif defined(OS_BSD)
index 31b1592cd8deadfa6fcb885bdd0ccd6a1bf349a1..609260e6a18c2f1658cd47b134c9d381f6b69e5b 100644 (file)
@@ -56,7 +56,7 @@ PlatformThreadId PlatformThread::CurrentId() {
 #else
    return getpid();
 #endif
-#elif defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(__GLIBC__)
+#elif defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(__GLIBC__) || defined(OS_HURD)
   return (intptr_t)(pthread_self());
 #elif defined(OS_NETBSD)
   return _lwp_self();
index 9d78f52cb6df26f8a3ce87c197c44365d7a7993d..d6176c8cb1b646a8302532b68c0a15edd118d681 100644 (file)
@@ -58,7 +58,7 @@ namespace base {
 // Define an OS-neutral wrapper for shared library entry points
 #if defined(OS_WIN)
 #  define API_CALL __stdcall
-#elif defined(OS_LINUX) || defined(OS_MACOSX)
+#elif defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_HURD)
 #  define API_CALL
 #endif
 
index 8876d79936f68c40a3c4408c93a61d93b3541444..572b328213f4261d7b05d2fa703310ff33c87bdc 100644 (file)
@@ -16,7 +16,7 @@
 #  include "mozilla/ipc/EnvironmentMap.h"
 #  include <windows.h>
 #  include <tlhelp32.h>
-#elif defined(OS_LINUX) || defined(__GLIBC__)
+#elif defined(OS_LINUX) || defined(__GLIBC__) || defined(OS_HURD)
 #  include <dirent.h>
 #  include <limits.h>
 #  include <sys/types.h>
index 1680fb531bda2151008c1dda445bf158d2b38bf1..18e958ee7791ac32ec905bbbe86468f47cbcc25f 100644 (file)
@@ -144,6 +144,10 @@ void CloseSuperfluousFds(void* aCtx, bool (*aShouldPreserve)(void*, int)) {
   static const rlim_t kSystemDefaultMaxFds = 1024;
   // at least /dev/fd will exist
   static const char kFDDir[] = "/dev/fd";
+#elif defined(OS_HURD)
+  static const rlim_t kSystemDefaultMaxFds = 1024;
+  // Currently always empty, but it exists
+  static const char kFDDir[] = "/dev/fd";
 #endif
 
   // Get the maximum number of FDs possible.
@@ -206,6 +210,40 @@ void CloseSuperfluousFds(void* aCtx, bool (*aShouldPreserve)(void*, int)) {
   }
 }
 
+// Sets all file descriptors to close on exec except for stdin, stdout
+// and stderr.
+// TODO(agl): Remove this function. It's fundamentally broken for multithreaded
+// apps.
+void SetAllFDsToCloseOnExec() {
+#if defined(OS_LINUX) || defined(OS_SOLARIS)
+  const char fd_dir[] = "/proc/self/fd";
+#elif defined(OS_MACOSX) || defined(OS_BSD) || defined(OS_HURD)
+  const char fd_dir[] = "/dev/fd";
+#endif
+  ScopedDIR dir_closer(opendir(fd_dir));
+  DIR *dir = dir_closer.get();
+  if (NULL == dir) {
+    DLOG(ERROR) << "Unable to open " << fd_dir;
+    return;
+  }
+
+  struct dirent *ent;
+  while ((ent = readdir(dir))) {
+    // Skip . and .. entries.
+    if (ent->d_name[0] == '.')
+      continue;
+    int i = atoi(ent->d_name);
+    // We don't close stdin, stdout or stderr.
+    if (i <= STDERR_FILENO)
+      continue;
+
+    int flags = fcntl(i, F_GETFD);
+    if ((flags == -1) || (fcntl(i, F_SETFD, flags | FD_CLOEXEC) == -1)) {
+      DLOG(ERROR) << "fcntl failure.";
+    }
+  }
+}
+
 bool DidProcessCrash(bool* child_exited, ProcessHandle handle) {
 #ifdef MOZ_ENABLE_FORKSERVER
   // We only know if a process exists, but not if it has crashed.
index d7f16c919bdc43fdd446c607739e299296403802..cbd72d14f6535d6f35eab62af19fa744275f5963 100644 (file)
   (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
 #endif  // __GNUC__
 
+// Determines the platform on which Google Test is compiled.
+#ifdef __CYGWIN__
+# define GTEST_OS_CYGWIN 1
+#elif defined __SYMBIAN32__
+# define GTEST_OS_SYMBIAN 1
+#elif defined _WIN32
+# define GTEST_OS_WINDOWS 1
+# ifdef _WIN32_WCE
+#  define GTEST_OS_WINDOWS_MOBILE 1
+# elif defined(__MINGW__) || defined(__MINGW32__)
+#  define GTEST_OS_WINDOWS_MINGW 1
+# elif defined(WINAPI_FAMILY)
+#  include <winapifamily.h>
+#  if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#   define GTEST_OS_WINDOWS_DESKTOP 1
+#  elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
+#   define GTEST_OS_WINDOWS_PHONE 1
+#  elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+#   define GTEST_OS_WINDOWS_RT 1
+#  else
+    // WINAPI_FAMILY defined but no known partition matched.
+    // Default to desktop.
+#   define GTEST_OS_WINDOWS_DESKTOP 1
+#  endif
+# else
+#  define GTEST_OS_WINDOWS_DESKTOP 1
+# endif  // _WIN32_WCE
+#elif defined __APPLE__
+# define GTEST_OS_MAC 1
+# if TARGET_OS_IPHONE
+#  define GTEST_OS_IOS 1
+#  if TARGET_IPHONE_SIMULATOR
+#   define GTEST_OS_IOS_SIMULATOR 1
+#  endif
+# endif
+#elif defined __linux__
+# define GTEST_OS_LINUX 1
+# if defined __ANDROID__
+#  define GTEST_OS_LINUX_ANDROID 1
+# endif
+#elif defined __MVS__
+# define GTEST_OS_ZOS 1
+#elif defined(__sun) && defined(__SVR4)
+# define GTEST_OS_SOLARIS 1
+#elif defined(_AIX)
+# define GTEST_OS_AIX 1
+#elif defined(__hpux)
+# define GTEST_OS_HPUX 1
+#elif defined __native_client__
+# define GTEST_OS_NACL 1
+#elif defined __OpenBSD__
+# define GTEST_OS_OPENBSD 1
+#elif defined __QNX__
+# define GTEST_OS_QNX 1
+#elif defined(__GNU__)
+# define GTEST_OS_HURD 1
+#endif  // __CYGWIN__
+
 // Macros for disabling Microsoft Visual C++ warnings.
 //
 //   GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385)
@@ -532,7 +590,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
   (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX ||          \
    GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \
    GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_OPENBSD ||          \
-   GTEST_OS_HAIKU)
+   GTEST_OS_HAIKU || GTEST_OS_HURD)
 #endif  // GTEST_HAS_PTHREAD
 
 #if GTEST_HAS_PTHREAD
index 48109c4d46af3bf6440c34ead9b58950731cf177..1bcdb30ab317260ae4a2c99012d08f382a857f3c 100644 (file)
@@ -47,6 +47,8 @@
 // we really are using glibc, not uClibc pretending to be glibc
 #define LIBC_GLIBC 1
 #endif
+#elif defined(__GNU__)
+#define OS_HURD 1
 #elif defined(_WIN32)
 #define OS_WIN 1
 #elif defined(__Fuchsia__)
@@ -82,7 +84,7 @@
 #if defined(OS_AIX) || defined(OS_ANDROID) || defined(OS_ASMJS) ||    \
     defined(OS_FREEBSD) || defined(OS_LINUX) || defined(OS_MACOSX) || \
     defined(OS_NACL) || defined(OS_NETBSD) || defined(OS_OPENBSD) ||  \
-    defined(OS_QNX) || defined(OS_SOLARIS)
+    defined(OS_QNX) || defined(OS_SOLARIS) || defined(OS_HURD)
 #define OS_POSIX 1
 #endif
 
index bc84890511429b90eed62ad5d1d6a3c34dff3a5f..22fc1c0b5590f094ec0266862c9dbf57fcdb6103 100644 (file)
@@ -37,6 +37,9 @@
 #elif defined(_WIN32)
 #define OS_WIN 1
 #define TOOLKIT_VIEWS 1
+#elif defined(__GNU__)
+#define OS_HURD 1
+#define TOOLKIT_GTK
 #elif defined(__DragonFly__)
 #define OS_DRAGONFLY 1
 #define TOOLKIT_GTK
@@ -70,7 +73,8 @@
 // For access to standard POSIXish features, use OS_POSIX instead of a
 // more specific macro.
 #if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_BSD) ||      \
-    defined(OS_SOLARIS) || defined(OS_ANDROID) || defined(OS_NACL)
+    defined(OS_SOLARIS) || defined(OS_ANDROID) || defined(OS_NACL) ||   \
+    defined(OS_HURD)
 #define OS_POSIX 1
 #endif
 
index f048e72be1cffb8050a4b8302c4b7c891e1fe047..8bb0b596f53975085bd671b98ecfc2a7b88a3f10 100644 (file)
@@ -7,7 +7,7 @@
 
 #include <inttypes.h>
 
-#if defined SIP_OS_LINUX
+#if defined SIP_OS_LINUX || defined(SIP_OS_HURD)
 #include "cpr_linux_types.h"
 #elif defined SIP_OS_WINDOWS
 #include "cpr_win_types.h"