diff options
author | Jason Evans <jasone@canonware.com> | 2016-11-02 18:09:45 -0700 |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2016-11-02 19:35:12 -0700 |
commit | 3f2b8d9cfaebdf0565da3f1ea6e8af11874eae8f (patch) | |
tree | 091fba49d02fc6e119abe95b8d838db48e2b9ebb /test | |
parent | a99e0fa2d21917cbcefd8b7a9a2128ae0399d88f (diff) | |
download | jemalloc-3f2b8d9cfaebdf0565da3f1ea6e8af11874eae8f.tar.gz |
Add os_unfair_lock support.
OS X 10.12 deprecated OSSpinLock; os_unfair_lock is the recommended
replacement.
Diffstat (limited to 'test')
-rw-r--r-- | test/include/test/mtx.h | 2 | ||||
-rw-r--r-- | test/src/mtx.c | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/test/include/test/mtx.h b/test/include/test/mtx.h index bbe822f..58afbc3 100644 --- a/test/include/test/mtx.h +++ b/test/include/test/mtx.h @@ -8,6 +8,8 @@ typedef struct { #ifdef _WIN32 CRITICAL_SECTION lock; +#elif (defined(JEMALLOC_OS_UNFAIR_LOCK)) + os_unfair_lock lock; #elif (defined(JEMALLOC_OSSPIN)) OSSpinLock lock; #else diff --git a/test/src/mtx.c b/test/src/mtx.c index 73bd02f..8a5dfdd 100644 --- a/test/src/mtx.c +++ b/test/src/mtx.c @@ -11,6 +11,8 @@ mtx_init(mtx_t *mtx) #ifdef _WIN32 if (!InitializeCriticalSectionAndSpinCount(&mtx->lock, _CRT_SPINCOUNT)) return (true); +#elif (defined(JEMALLOC_OS_UNFAIR_LOCK)) + mtx->lock = OS_UNFAIR_LOCK_INIT; #elif (defined(JEMALLOC_OSSPIN)) mtx->lock = 0; #else @@ -33,6 +35,7 @@ mtx_fini(mtx_t *mtx) { #ifdef _WIN32 +#elif (defined(JEMALLOC_OS_UNFAIR_LOCK)) #elif (defined(JEMALLOC_OSSPIN)) #else pthread_mutex_destroy(&mtx->lock); @@ -45,6 +48,8 @@ mtx_lock(mtx_t *mtx) #ifdef _WIN32 EnterCriticalSection(&mtx->lock); +#elif (defined(JEMALLOC_OS_UNFAIR_LOCK)) + os_unfair_lock_lock(&mtx->lock); #elif (defined(JEMALLOC_OSSPIN)) OSSpinLockLock(&mtx->lock); #else @@ -58,6 +63,8 @@ mtx_unlock(mtx_t *mtx) #ifdef _WIN32 LeaveCriticalSection(&mtx->lock); +#elif (defined(JEMALLOC_OS_UNFAIR_LOCK)) + os_unfair_lock_unlock(&mtx->lock); #elif (defined(JEMALLOC_OSSPIN)) OSSpinLockUnlock(&mtx->lock); #else |