diff options
author | Igor Sysoev <igor@sysoev.ru> | 2018-09-17 16:37:17 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2018-09-17 16:37:17 +0300 |
commit | 4bb45250314ad0c26ce7f5578a173340007276de (patch) | |
tree | 488c08c6a7eda1d72967d3d21f967bc25a996954 | |
parent | 74b69f5e95ce6a3fea4bbe0f681afcc4b8ecdec9 (diff) | |
download | unit-4bb45250314ad0c26ce7f5578a173340007276de.tar.gz unit-4bb45250314ad0c26ce7f5578a173340007276de.tar.bz2 |
Removed deprecated MacOSX OSSpinLockLock().
-rw-r--r-- | auto/threads | 23 | ||||
-rw-r--r-- | src/nxt_spinlock.c | 44 | ||||
-rw-r--r-- | src/nxt_spinlock.h | 15 |
3 files changed, 2 insertions, 80 deletions
diff --git a/auto/threads b/auto/threads index d6efc7cd..ff33eaac 100644 --- a/auto/threads +++ b/auto/threads @@ -123,29 +123,6 @@ if [ $nxt_found = yes ]; then fi -if [ $nxt_found = no ]; then - - # MacOSX spinlock(3). - - nxt_feature="MacOSX spinlock" - nxt_feature_name=NXT_HAVE_MACOSX_SPINLOCK - nxt_feature_run=yes - nxt_feature_incs= - nxt_feature_libs=$NXT_PTHREAD - nxt_feature_test="#include <libkern/OSAtomic.h> - - int main() { - OSSpinLock lock = 0; - - if (OSSpinLockTry(&lock) == 0) - return 1; - OSSpinLockUnlock(&lock); - return 0; - }" - . auto/feature -fi - - nxt_feature="sem_timedwait()" nxt_feature_name=NXT_HAVE_SEM_TIMEDWAIT nxt_feature_run=yes diff --git a/src/nxt_spinlock.c b/src/nxt_spinlock.c index 0348ae23..940be724 100644 --- a/src/nxt_spinlock.c +++ b/src/nxt_spinlock.c @@ -15,11 +15,8 @@ * FreeBSD 5.2 and Solaris 10 support pthread spinlocks. Spinlock is a * structure and uses mutex implementation so it must be initialized by * by pthread_spin_init() and destroyed by pthread_spin_destroy(). - */ - -#if (NXT_HAVE_MACOSX_SPINLOCK) - -/* + * + * MacOSX supported OSSpinLockLock(), it was deprecated in 10.12 (Sierra). * OSSpinLockLock() tries to acquire a lock atomically. If the lock is * busy, on SMP system it tests the lock 1000 times in a tight loop with * "pause" instruction. If the lock has been released, OSSpinLockLock() @@ -29,41 +26,6 @@ * with depressed (the lowest) priority. */ -void -nxt_thread_spin_lock(nxt_thread_spinlock_t *lock) -{ - nxt_thread_log_debug("OSSpinLockLock(%p) enter", lock); - - OSSpinLockLock(lock); -} - - -nxt_bool_t -nxt_thread_spin_trylock(nxt_thread_spinlock_t *lock) -{ - nxt_thread_log_debug("OSSpinLockTry(%p) enter", lock); - - if (OSSpinLockTry(lock)) { - return 1; - } - - nxt_thread_log_debug("OSSpinLockTry(%p) failed", lock); - - return 0; -} - - -void -nxt_thread_spin_unlock(nxt_thread_spinlock_t *lock) -{ - OSSpinLockUnlock(lock); - - nxt_thread_log_debug("OSSpinLockUnlock(%p) exit", lock); -} - - -#else - /* It should be adjusted with the "spinlock_count" directive. */ static nxt_uint_t nxt_spinlock_count = 1000; @@ -148,5 +110,3 @@ nxt_thread_spin_unlock(nxt_thread_spinlock_t *lock) nxt_thread_log_debug("spin_unlock(%p) exit", lock); } - -#endif diff --git a/src/nxt_spinlock.h b/src/nxt_spinlock.h index 072e001d..28e05445 100644 --- a/src/nxt_spinlock.h +++ b/src/nxt_spinlock.h @@ -8,24 +8,9 @@ #define _NXT_UNIX_SPINLOCK_H_INCLUDED_ -#if (NXT_HAVE_MACOSX_SPINLOCK) - -#include <libkern/OSAtomic.h> - -typedef OSSpinLock nxt_thread_spinlock_t; - -#define \ -nxt_thread_spin_init(ncpu, count) - -#else - typedef nxt_atomic_t nxt_thread_spinlock_t; NXT_EXPORT void nxt_thread_spin_init(nxt_uint_t ncpu, nxt_uint_t count); - -#endif - - NXT_EXPORT void nxt_thread_spin_lock(nxt_thread_spinlock_t *lock); NXT_EXPORT nxt_bool_t nxt_thread_spin_trylock(nxt_thread_spinlock_t *lock); NXT_EXPORT void nxt_thread_spin_unlock(nxt_thread_spinlock_t *lock); |