mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-19 17:01:15 +03:00
Add os_unfair_lock support.
OS X 10.12 deprecated OSSpinLock; os_unfair_lock is the recommended replacement.
This commit is contained in:
parent
a99e0fa2d2
commit
3f2b8d9cfa
7 changed files with 42 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue