Lines Matching refs:mtx
75 simple_mtx_init(simple_mtx_t *mtx, ASSERTED int type)
79 mtx->val = 0;
81 HG(ANNOTATE_RWLOCK_CREATE(mtx));
85 simple_mtx_destroy(ASSERTED simple_mtx_t *mtx)
87 HG(ANNOTATE_RWLOCK_DESTROY(mtx));
89 mtx->val = _SIMPLE_MTX_INVALID_VALUE;
94 simple_mtx_lock(simple_mtx_t *mtx)
98 c = __sync_val_compare_and_swap(&mtx->val, 0, 1);
104 c = __sync_lock_test_and_set(&mtx->val, 2);
106 futex_wait(&mtx->val, 2, NULL);
107 c = __sync_lock_test_and_set(&mtx->val, 2);
111 HG(ANNOTATE_RWLOCK_ACQUIRED(mtx, 1));
115 simple_mtx_unlock(simple_mtx_t *mtx)
119 HG(ANNOTATE_RWLOCK_RELEASED(mtx, 1));
121 c = __sync_fetch_and_sub(&mtx->val, 1);
126 mtx->val = 0;
127 futex_wake(&mtx->val, 1);
132 simple_mtx_assert_locked(simple_mtx_t *mtx)
134 assert(mtx->val);
144 simple_mtx_init(simple_mtx_t *mtx, int type)
146 mtx_init(mtx, type);
150 simple_mtx_destroy(simple_mtx_t *mtx)
152 mtx_destroy(mtx);
156 simple_mtx_lock(simple_mtx_t *mtx)
158 mtx_lock(mtx);
162 simple_mtx_unlock(simple_mtx_t *mtx)
164 mtx_unlock(mtx);
168 simple_mtx_assert_locked(simple_mtx_t *mtx)
174 int ret = mtx_trylock(mtx);
177 mtx_unlock(mtx);
179 (void)mtx;