mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-29 10:23:29 +00:00
108 lines
3.1 KiB
Diff
108 lines
3.1 KiB
Diff
--- 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
|