Commit 0fe315c9 authored by Matthew Bauer's avatar Matthew Bauer
Browse files

treewide: remove old patches for macOS

These shouldn’t be needed now that we are on macOS 10.12.
parent 5fad67d3
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -153,15 +153,9 @@ stdenv.mkDerivation rec {
  ]
  ++ lib.optionals (!isTorBrowserLike) [
    "-I${nss.dev}/include/nss"
  ]
  ++ lib.optional stdenv.isDarwin [
    "-isystem ${llvmPackages.libcxx}/include/c++/v1"
    "-DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_10"
  ];

  postPatch = lib.optionalString stdenv.isDarwin ''
    substituteInPlace js/src/jsmath.cpp --replace 'defined(HAVE___SINCOS)' 0
  '' + lib.optionalString (lib.versionAtLeast ffversion "63.0" && !isTorBrowserLike) ''
  postPatch = lib.optionalString (lib.versionAtLeast ffversion "63.0" && !isTorBrowserLike) ''
    substituteInPlace third_party/prio/prio/rand.c --replace 'nspr/prinit.h' 'prinit.h'
  '';

+0 −74
Original line number Diff line number Diff line
commit f00c7bccf7955b7dfbb4859fd9019e9eb3349f2d
Author: Tobias Mayer <tobim@fastmail.fm>
Date:   Wed Feb 13 12:44:17 2019 +0100

    Provide clock_gettime for xray on macos < 10.12

diff --git a/lib/xray/xray_basic_logging.cc b/lib/xray/xray_basic_logging.cc
index a46c151af..38aea6932 100644
--- a/lib/xray/xray_basic_logging.cc
+++ b/lib/xray/xray_basic_logging.cc
@@ -36,6 +36,29 @@
 #include "xray_tsc.h"
 #include "xray_utils.h"
 
+#if __MACH__
+#include <mach/clock.h>
+#include <mach/mach.h>
+enum clockid_t {
+    CLOCK_MONOTONIC = REALTIME_CLOCK,
+    CLOCK_REALTIME = REALTIME_CLOCK
+};
+
+int clock_gettime(clockid_t clock_id, struct timespec *ts) {
+  if (ts != NULL) {
+      clock_serv_t cclock;
+      mach_timespec_t mts;
+      host_get_clock_service(mach_host_self(), clock_id, &cclock);
+      clock_get_time(cclock, &mts);
+      mach_port_deallocate(mach_task_self(), cclock);
+      ts->tv_sec = mts.tv_sec;
+      ts->tv_nsec = mts.tv_nsec;
+      return 0;
+  }
+  return -1;
+}
+#endif
+
 namespace __xray {
 
 SpinMutex LogMutex;
diff --git a/lib/xray/xray_fdr_logging.cc b/lib/xray/xray_fdr_logging.cc
index 4b308b27f..1d044c8fd 100644
--- a/lib/xray/xray_fdr_logging.cc
+++ b/lib/xray/xray_fdr_logging.cc
@@ -38,6 +38,29 @@
 #include "xray_tsc.h"
 #include "xray_utils.h"
 
+#if __MACH__
+#include <mach/clock.h>
+#include <mach/mach.h>
+enum clockid_t {
+    CLOCK_MONOTONIC = REALTIME_CLOCK,
+    CLOCK_REALTIME = REALTIME_CLOCK
+};
+
+int clock_gettime(clockid_t clock_id, struct timespec *ts) {
+  if (ts != NULL) {
+      clock_serv_t cclock;
+      mach_timespec_t mts;
+      host_get_clock_service(mach_host_self(), clock_id, &cclock);
+      clock_get_time(cclock, &mts);
+      mach_port_deallocate(mach_task_self(), cclock);
+      ts->tv_sec = mts.tv_sec;
+      ts->tv_nsec = mts.tv_nsec;
+      return 0;
+  }
+  return -1;
+}
+#endif
+
 namespace __xray {
 
 atomic_sint32_t LoggingStatus = {XRayLogInitStatus::XRAY_LOG_UNINITIALIZED};
+2 −3
Original line number Diff line number Diff line
@@ -26,9 +26,8 @@ stdenv.mkDerivation rec {

  patches = [
    ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
  ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
    ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) ./crtbegin-and-end.patch
    ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin ./compiler-rt-clock_gettime.patch;
  ] ++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) ./crtbegin-and-end.patch
    ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch;

  # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
  # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
+0 −5
Original line number Diff line number Diff line
@@ -14,17 +14,12 @@ stdenv.mkDerivation rec {
  buildInputs = [ libpthreadstubs libpciaccess valgrind-light ];
    # libdrm as of 2.4.70 does not actually do anything with udev.

  patches = stdenv.lib.optional stdenv.isDarwin ./libdrm-apple.patch;

  postPatch = ''
    for a in */*-symbol-check ; do
      patchShebangs $a
    done
  '';

  preConfigure = stdenv.lib.optionalString stdenv.isDarwin
    "echo : \\\${ac_cv_func_clock_gettime=\'yes\'} > config.cache";

  configureFlags = [ "--enable-install-test-programs" ]
    ++ stdenv.lib.optionals (stdenv.isAarch32 || stdenv.isAarch64)
      [ "--enable-tegra-experimental-api" "--enable-etnaviv-experimental-api" ]
+0 −88
Original line number Diff line number Diff line
diff -Naur libdrm-2.4.26-orig/intel/intel_bufmgr_gem.c libdrm-2.4.26/intel/intel_bufmgr_gem.c
--- libdrm-2.4.26-orig/intel/intel_bufmgr_gem.c	2011-04-01 10:30:51.000000000 -0400
+++ libdrm-2.4.26/intel/intel_bufmgr_gem.c	2011-08-29 02:17:20.000000000 -0400
@@ -51,6 +51,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <stdbool.h>
+#include <sys/time.h>
 
 #include "errno.h"
 #include "libdrm_lists.h"
@@ -987,9 +988,9 @@
 	if (atomic_dec_and_test(&bo_gem->refcount)) {
 		drm_intel_bufmgr_gem *bufmgr_gem =
 		    (drm_intel_bufmgr_gem *) bo->bufmgr;
-		struct timespec time;
+		struct timeval time;
 
-		clock_gettime(CLOCK_MONOTONIC, &time);
+		gettimeofday(&time, NULL);
 
 		pthread_mutex_lock(&bufmgr_gem->lock);
 		drm_intel_gem_bo_unreference_final(bo, time.tv_sec);
diff -Naur libdrm-2.4.26-orig/xf86drm.c libdrm-2.4.26/xf86drm.c
--- libdrm-2.4.26-orig/xf86drm.c	2011-03-21 09:39:24.000000000 -0400
+++ libdrm-2.4.26/xf86drm.c	2011-08-29 02:17:49.000000000 -0400
@@ -51,6 +51,9 @@
 #include <sys/mman.h>
 #include <sys/time.h>
 #include <stdarg.h>
+#if defined(__APPLE__) && defined(__MACH__)
+#include <mach/mach_time.h>
+#endif
 
 /* Not all systems have MAP_FAILED defined */
 #ifndef MAP_FAILED
@@ -1941,20 +1944,43 @@
  */
 int drmWaitVBlank(int fd, drmVBlankPtr vbl)
 {
+#if defined(__APPLE__) && defined(__MACH__)
+    uint64_t start, end, elapsed, elapsedNano;
+    static const uint64_t maxElapsed = 2000000000;
+    static mach_timebase_info_data_t timebaseInfo;
+    if ( timebaseInfo.denom == 0 ) {
+	(void) mach_timebase_info(&timebaseInfo);
+    }
+#else
     struct timespec timeout, cur;
+#endif
     int ret;
 
+#if defined(__APPLE__) && defined(__MACH__)
+    start = mach_absolute_time();
+#else
     ret = clock_gettime(CLOCK_MONOTONIC, &timeout);
     if (ret < 0) {
 	fprintf(stderr, "clock_gettime failed: %s\n", strerror(ret));
 	goto out;
     }
     timeout.tv_sec++;
+#endif
 
     do {
        ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl);
        vbl->request.type &= ~DRM_VBLANK_RELATIVE;
        if (ret && errno == EINTR) {
+#if defined(__APPLE__) && defined(__MACH__)
+	       end = mach_absolute_time();
+	       elapsed = end - start;
+	       elapsedNano = elapsed * timebaseInfo.numer / timebaseInfo.denom;
+	       if (elapsedNano > maxElapsed) {
+		   errno = EBUSY;
+		   ret = -1;
+		   break;
+	       }
+#else
 	       clock_gettime(CLOCK_MONOTONIC, &cur);
 	       /* Timeout after 1s */
 	       if (cur.tv_sec > timeout.tv_sec + 1 ||
@@ -1964,6 +1990,7 @@
 		       ret = -1;
 		       break;
 	       }
+#endif
        }
     } while (ret && errno == EINTR);
 
Loading