]> git.proxmox.com Git - rustc.git/blob - src/jemalloc/test/include/test/mtx.h
New upstream version 1.22.1+dfsg1
[rustc.git] / src / jemalloc / test / include / test / mtx.h
1 /*
2 * mtx is a slightly simplified version of malloc_mutex. This code duplication
3 * is unfortunate, but there are allocator bootstrapping considerations that
4 * would leak into the test infrastructure if malloc_mutex were used directly
5 * in tests.
6 */
7
8 typedef struct {
9 #ifdef _WIN32
10 CRITICAL_SECTION lock;
11 #elif (defined(JEMALLOC_OS_UNFAIR_LOCK))
12 os_unfair_lock lock;
13 #elif (defined(JEMALLOC_OSSPIN))
14 OSSpinLock lock;
15 #else
16 pthread_mutex_t lock;
17 #endif
18 } mtx_t;
19
20 bool mtx_init(mtx_t *mtx);
21 void mtx_fini(mtx_t *mtx);
22 void mtx_lock(mtx_t *mtx);
23 void mtx_unlock(mtx_t *mtx);