Lines Matching defs:zrl

50 zrl_init(zrlock_t *zrl)
52 mutex_init(&zrl->zr_mtx, NULL, MUTEX_DEFAULT, NULL);
53 zrl->zr_refcount = 0;
54 cv_init(&zrl->zr_cv, NULL, CV_DEFAULT, NULL);
56 zrl->zr_owner = NULL;
57 zrl->zr_caller = NULL;
62 zrl_destroy(zrlock_t *zrl)
64 ASSERT0(zrl->zr_refcount);
66 mutex_destroy(&zrl->zr_mtx);
67 zrl->zr_refcount = ZRL_DESTROYED;
68 cv_destroy(&zrl->zr_cv);
72 zrl_add_impl(zrlock_t *zrl, const char *zc)
74 uint32_t n = (uint32_t)zrl->zr_refcount;
78 (uint32_t *)&zrl->zr_refcount, n, n + 1);
82 if (zrl->zr_owner == curthread) {
84 zrlock_t *, zrl, uint32_t, n);
86 zrl->zr_owner = curthread;
87 zrl->zr_caller = zc;
94 mutex_enter(&zrl->zr_mtx);
95 while (zrl->zr_refcount == ZRL_LOCKED) {
96 cv_wait(&zrl->zr_cv, &zrl->zr_mtx);
98 ASSERT3S(zrl->zr_refcount, >=, 0);
99 zrl->zr_refcount++;
101 zrl->zr_owner = curthread;
102 zrl->zr_caller = zc;
104 mutex_exit(&zrl->zr_mtx);
108 zrl_remove(zrlock_t *zrl)
113 if (zrl->zr_owner == curthread) {
114 zrl->zr_owner = NULL;
115 zrl->zr_caller = NULL;
118 n = atomic_dec_32_nv((uint32_t *)&zrl->zr_refcount);
123 zrl_tryenter(zrlock_t *zrl)
125 uint32_t n = (uint32_t)zrl->zr_refcount;
129 (uint32_t *)&zrl->zr_refcount, 0, ZRL_LOCKED);
132 ASSERT3P(zrl->zr_owner, ==, NULL);
133 zrl->zr_owner = curthread;
145 zrl_exit(zrlock_t *zrl)
147 ASSERT3S(zrl->zr_refcount, ==, ZRL_LOCKED);
149 mutex_enter(&zrl->zr_mtx);
151 ASSERT3P(zrl->zr_owner, ==, curthread);
152 zrl->zr_owner = NULL;
155 zrl->zr_refcount = 0;
156 cv_broadcast(&zrl->zr_cv);
157 mutex_exit(&zrl->zr_mtx);
161 zrl_refcount(zrlock_t *zrl)
163 ASSERT3S(zrl->zr_refcount, >, ZRL_DESTROYED);
165 int n = (int)zrl->zr_refcount;
170 zrl_is_zero(zrlock_t *zrl)
172 ASSERT3S(zrl->zr_refcount, >, ZRL_DESTROYED);
174 return (zrl->zr_refcount <= 0);
178 zrl_is_locked(zrlock_t *zrl)
180 ASSERT3S(zrl->zr_refcount, >, ZRL_DESTROYED);
182 return (zrl->zr_refcount == ZRL_LOCKED);
187 zrl_owner(zrlock_t *zrl)
189 return (zrl->zr_owner);