Lines Matching refs:zrl

51 zrl_init(zrlock_t *zrl)  in zrl_init()  argument
53 mutex_init(&zrl->zr_mtx, NULL, MUTEX_DEFAULT, NULL); in zrl_init()
54 zrl->zr_refcount = 0; in zrl_init()
55 cv_init(&zrl->zr_cv, NULL, CV_DEFAULT, NULL); in zrl_init()
57 zrl->zr_owner = NULL; in zrl_init()
58 zrl->zr_caller = NULL; in zrl_init()
63 zrl_destroy(zrlock_t *zrl) in zrl_destroy() argument
65 ASSERT0(zrl->zr_refcount); in zrl_destroy()
67 mutex_destroy(&zrl->zr_mtx); in zrl_destroy()
68 zrl->zr_refcount = ZRL_DESTROYED; in zrl_destroy()
69 cv_destroy(&zrl->zr_cv); in zrl_destroy()
73 zrl_add_impl(zrlock_t *zrl, const char *zc) in zrl_add_impl() argument
76 uint32_t n = (uint32_t)zrl->zr_refcount; in zrl_add_impl()
79 (uint32_t *)&zrl->zr_refcount, n, n + 1); in zrl_add_impl()
83 if (zrl->zr_owner == curthread) { in zrl_add_impl()
85 zrlock_t *, zrl, uint32_t, n); in zrl_add_impl()
87 zrl->zr_owner = curthread; in zrl_add_impl()
88 zrl->zr_caller = zc; in zrl_add_impl()
95 mutex_enter(&zrl->zr_mtx); in zrl_add_impl()
96 while (zrl->zr_refcount == ZRL_LOCKED) { in zrl_add_impl()
97 cv_wait(&zrl->zr_cv, &zrl->zr_mtx); in zrl_add_impl()
99 mutex_exit(&zrl->zr_mtx); in zrl_add_impl()
104 zrl_remove(zrlock_t *zrl) in zrl_remove() argument
109 if (zrl->zr_owner == curthread) { in zrl_remove()
110 zrl->zr_owner = NULL; in zrl_remove()
111 zrl->zr_caller = NULL; in zrl_remove()
114 n = atomic_dec_32_nv((uint32_t *)&zrl->zr_refcount); in zrl_remove()
119 zrl_tryenter(zrlock_t *zrl) in zrl_tryenter() argument
121 uint32_t n = (uint32_t)zrl->zr_refcount; in zrl_tryenter()
125 (uint32_t *)&zrl->zr_refcount, 0, ZRL_LOCKED); in zrl_tryenter()
128 ASSERT3P(zrl->zr_owner, ==, NULL); in zrl_tryenter()
129 zrl->zr_owner = curthread; in zrl_tryenter()
141 zrl_exit(zrlock_t *zrl) in zrl_exit() argument
143 ASSERT3S(zrl->zr_refcount, ==, ZRL_LOCKED); in zrl_exit()
145 mutex_enter(&zrl->zr_mtx); in zrl_exit()
147 ASSERT3P(zrl->zr_owner, ==, curthread); in zrl_exit()
148 zrl->zr_owner = NULL; in zrl_exit()
151 zrl->zr_refcount = 0; in zrl_exit()
152 cv_broadcast(&zrl->zr_cv); in zrl_exit()
153 mutex_exit(&zrl->zr_mtx); in zrl_exit()
157 zrl_refcount(zrlock_t *zrl) in zrl_refcount() argument
159 ASSERT3S(zrl->zr_refcount, >, ZRL_DESTROYED); in zrl_refcount()
161 int n = (int)zrl->zr_refcount; in zrl_refcount()
166 zrl_is_zero(zrlock_t *zrl) in zrl_is_zero() argument
168 ASSERT3S(zrl->zr_refcount, >, ZRL_DESTROYED); in zrl_is_zero()
170 return (zrl->zr_refcount <= 0); in zrl_is_zero()
174 zrl_is_locked(zrlock_t *zrl) in zrl_is_locked() argument
176 ASSERT3S(zrl->zr_refcount, >, ZRL_DESTROYED); in zrl_is_locked()
178 return (zrl->zr_refcount == ZRL_LOCKED); in zrl_is_locked()
183 zrl_owner(zrlock_t *zrl) in zrl_owner() argument
185 return (zrl->zr_owner); in zrl_owner()