diff options
author | Dan Peebles <thetypesaretoobig@gmail.com> | 2015-02-08 01:53:52 -0500 |
---|---|---|
committer | Dan Peebles <thetypesaretoobig@gmail.com> | 2015-02-08 01:53:52 -0500 |
commit | 29f265dfd28ce5567106a7a1df3bd6c1fbd8406f (patch) | |
tree | 3973e0a11ae1737f8d307ec07651cf5c12498210 /pkgs/os-specific/darwin/apple-source-releases/objc4/spinlocks.patch | |
parent | f43c324cee6ed5fdbe679b70b71caaca1c4629a8 (diff) | |
download | nixlib-29f265dfd28ce5567106a7a1df3bd6c1fbd8406f.tar nixlib-29f265dfd28ce5567106a7a1df3bd6c1fbd8406f.tar.gz nixlib-29f265dfd28ce5567106a7a1df3bd6c1fbd8406f.tar.bz2 nixlib-29f265dfd28ce5567106a7a1df3bd6c1fbd8406f.tar.lz nixlib-29f265dfd28ce5567106a7a1df3bd6c1fbd8406f.tar.xz nixlib-29f265dfd28ce5567106a7a1df3bd6c1fbd8406f.tar.zst nixlib-29f265dfd28ce5567106a7a1df3bd6c1fbd8406f.zip |
Add a big bundle of packages from apple source releases. Many of them only provide headers or stubs, but are what's needed for the upcoming pure-darwin stdenv, and don't do any harm for now.
Diffstat (limited to 'pkgs/os-specific/darwin/apple-source-releases/objc4/spinlocks.patch')
-rw-r--r-- | pkgs/os-specific/darwin/apple-source-releases/objc4/spinlocks.patch | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/pkgs/os-specific/darwin/apple-source-releases/objc4/spinlocks.patch b/pkgs/os-specific/darwin/apple-source-releases/objc4/spinlocks.patch new file mode 100644 index 000000000000..50c6a983fe4d --- /dev/null +++ b/pkgs/os-specific/darwin/apple-source-releases/objc4/spinlocks.patch @@ -0,0 +1,107 @@ +--- objc4-551.1/runtime/objc-os.h 2013-06-10 21:16:15.000000000 -0400 ++++ ../objc4-551.1/runtime/objc-os.h 2015-01-19 01:01:36.000000000 -0500 +@@ -77,27 +77,72 @@ + # include <mach-o/getsect.h> + # include <mach-o/dyld_priv.h> + # include <malloc/malloc.h> +-# include <os/lock_private.h> + # include <libkern/OSAtomic.h> + # include <libkern/OSCacheControl.h> +-# include <System/pthread_machdep.h> + # include "objc-probes.h" // generated dtrace probe definitions. + ++#define __PTK_FRAMEWORK_OBJC_KEY5 45 ++#define __PTK_FRAMEWORK_OBJC_KEY6 46 ++#define __PTK_FRAMEWORK_OBJC_KEY7 47 ++#define __PTK_FRAMEWORK_OBJC_KEY8 48 ++#define __PTK_FRAMEWORK_OBJC_KEY9 49 ++ ++extern "C" int pthread_key_init_np(int, void (*)(void *)); ++ + // Some libc functions call objc_msgSend() + // so we can't use them without deadlocks. + void syslog(int, const char *, ...) UNAVAILABLE_ATTRIBUTE; + void vsyslog(int, const char *, va_list) UNAVAILABLE_ATTRIBUTE; + ++#if defined(__i386__) || defined(__x86_64__) ++ ++// Inlined spinlock. ++// Not for arm on iOS because it hurts uniprocessor performance. ++ ++#define ARR_SPINLOCK_INIT 0 ++// XXX -- Careful: OSSpinLock isn't volatile, but should be ++typedef volatile int ARRSpinLock; ++__attribute__((always_inline)) ++static inline void ARRSpinLockLock(ARRSpinLock *l) ++{ ++ unsigned y; ++again: ++ if (__builtin_expect(__sync_lock_test_and_set(l, 1), 0) == 0) { ++ return; ++ } ++ for (y = 1000; y; y--) { ++#if defined(__i386__) || defined(__x86_64__) ++ asm("pause"); ++#endif ++ if (*l == 0) goto again; ++ } ++ thread_switch(THREAD_NULL, SWITCH_OPTION_DEPRESS, 1); ++ goto again; ++} ++__attribute__((always_inline)) ++static inline void ARRSpinLockUnlock(ARRSpinLock *l) ++{ ++ __sync_lock_release(l); ++} ++__attribute__((always_inline)) ++static inline int ARRSpinLockTry(ARRSpinLock *l) ++{ ++ return __sync_bool_compare_and_swap(l, 0, 1); ++} ++ ++#define spinlock_t ARRSpinLock ++#define spinlock_trylock(l) ARRSpinLockTry(l) ++#define spinlock_lock(l) ARRSpinLockLock(l) ++#define spinlock_unlock(l) ARRSpinLockUnlock(l) ++#define SPINLOCK_INITIALIZER ARR_SPINLOCK_INIT + +-#define spinlock_t os_lock_handoff_s +-#define spinlock_trylock(l) os_lock_trylock(l) +-#define spinlock_lock(l) os_lock_lock(l) +-#define spinlock_unlock(l) os_lock_unlock(l) +-#define SPINLOCK_INITIALIZER OS_LOCK_HANDOFF_INIT ++#endif + + + #if !TARGET_OS_IPHONE +-# include <CrashReporterClient.h> ++#define CRSetCrashLogMessage(msg) ++#define CRGetCrashLogMessage() 0 ++#define CRSetCrashLogMessage2(msg) + #else + // CrashReporterClient not yet available on iOS + __BEGIN_DECLS +@@ -594,21 +639,13 @@ + { + assert(is_valid_direct_key(k)); + +- if (_pthread_has_direct_tsd()) { +- return _pthread_getspecific_direct(k); +- } else { +- return pthread_getspecific(k); +- } ++ return pthread_getspecific(k); + } + static inline void tls_set_direct(tls_key_t k, void *value) + { + assert(is_valid_direct_key(k)); + +- if (_pthread_has_direct_tsd()) { +- _pthread_setspecific_direct(k, value); +- } else { +- pthread_setspecific(k, value); +- } ++ pthread_setspecific(k, value); + } + + // not arm |