| 5 | #endif |
| 6 | |
| 7 | bool |
| 8 | mtx_init(mtx_t *mtx) { |
| 9 | #ifdef _WIN32 |
| 10 | if (!InitializeCriticalSectionAndSpinCount(&mtx->lock, |
| 11 | _CRT_SPINCOUNT)) { |
| 12 | return true; |
| 13 | } |
| 14 | #elif (defined(JEMALLOC_OS_UNFAIR_LOCK)) |
| 15 | mtx->lock = OS_UNFAIR_LOCK_INIT; |
| 16 | #elif (defined(JEMALLOC_OSSPIN)) |
| 17 | mtx->lock = 0; |
| 18 | #else |
| 19 | pthread_mutexattr_t attr; |
| 20 | |
| 21 | if (pthread_mutexattr_init(&attr) != 0) { |
| 22 | return true; |
| 23 | } |
| 24 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_DEFAULT); |
| 25 | if (pthread_mutex_init(&mtx->lock, &attr) != 0) { |
| 26 | pthread_mutexattr_destroy(&attr); |
| 27 | return true; |
| 28 | } |
| 29 | pthread_mutexattr_destroy(&attr); |
| 30 | #endif |
| 31 | return false; |
| 32 | } |
| 33 | |
| 34 | void |
| 35 | mtx_fini(mtx_t *mtx) { |
no test coverage detected