Lines Matching refs:rc

64 refcount_create(refcount_t *rc)
66 mutex_init(&rc->rc_mtx, NULL, MUTEX_DEFAULT, NULL);
67 list_create(&rc->rc_list, sizeof (reference_t),
69 list_create(&rc->rc_removed, sizeof (reference_t),
71 rc->rc_count = 0;
72 rc->rc_removed_count = 0;
73 rc->rc_tracked = reference_tracking_enable;
77 refcount_create_tracked(refcount_t *rc)
79 refcount_create(rc);
80 rc->rc_tracked = B_TRUE;
84 refcount_create_untracked(refcount_t *rc)
86 refcount_create(rc);
87 rc->rc_tracked = B_FALSE;
91 refcount_destroy_many(refcount_t *rc, uint64_t number)
95 ASSERT(rc->rc_count == number);
96 while (ref = list_head(&rc->rc_list)) {
97 list_remove(&rc->rc_list, ref);
100 list_destroy(&rc->rc_list);
102 while (ref = list_head(&rc->rc_removed)) {
103 list_remove(&rc->rc_removed, ref);
107 list_destroy(&rc->rc_removed);
108 mutex_destroy(&rc->rc_mtx);
112 refcount_destroy(refcount_t *rc)
114 refcount_destroy_many(rc, 0);
118 refcount_is_zero(refcount_t *rc)
120 return (rc->rc_count == 0);
124 refcount_count(refcount_t *rc)
126 return (rc->rc_count);
130 refcount_add_many(refcount_t *rc, uint64_t number, void *holder)
135 if (rc->rc_tracked) {
140 mutex_enter(&rc->rc_mtx);
141 ASSERT(rc->rc_count >= 0);
142 if (rc->rc_tracked)
143 list_insert_head(&rc->rc_list, ref);
144 rc->rc_count += number;
145 count = rc->rc_count;
146 mutex_exit(&rc->rc_mtx);
152 refcount_add(refcount_t *rc, void *holder)
154 return (refcount_add_many(rc, 1, holder));
158 refcount_remove_many(refcount_t *rc, uint64_t number, void *holder)
163 mutex_enter(&rc->rc_mtx);
164 ASSERT(rc->rc_count >= number);
166 if (!rc->rc_tracked) {
167 rc->rc_count -= number;
168 count = rc->rc_count;
169 mutex_exit(&rc->rc_mtx);
173 for (ref = list_head(&rc->rc_list); ref;
174 ref = list_next(&rc->rc_list, ref)) {
176 list_remove(&rc->rc_list, ref);
181 list_insert_head(&rc->rc_removed, ref);
182 rc->rc_removed_count++;
183 if (rc->rc_removed_count > reference_history) {
184 ref = list_tail(&rc->rc_removed);
185 list_remove(&rc->rc_removed, ref);
189 rc->rc_removed_count--;
194 rc->rc_count -= number;
195 count = rc->rc_count;
196 mutex_exit(&rc->rc_mtx);
201 (u_longlong_t)(uintptr_t)rc);
206 refcount_remove(refcount_t *rc, void *holder)
208 return (refcount_remove_many(rc, 1, holder));
243 refcount_transfer_ownership(refcount_t *rc, void *current_holder,
249 mutex_enter(&rc->rc_mtx);
250 if (!rc->rc_tracked) {
251 mutex_exit(&rc->rc_mtx);
255 for (ref = list_head(&rc->rc_list); ref;
256 ref = list_next(&rc->rc_list, ref)) {
264 mutex_exit(&rc->rc_mtx);
273 refcount_held(refcount_t *rc, void *holder)
277 mutex_enter(&rc->rc_mtx);
279 if (!rc->rc_tracked) {
280 mutex_exit(&rc->rc_mtx);
281 return (rc->rc_count > 0);
284 for (ref = list_head(&rc->rc_list); ref;
285 ref = list_next(&rc->rc_list, ref)) {
287 mutex_exit(&rc->rc_mtx);
291 mutex_exit(&rc->rc_mtx);
301 refcount_not_held(refcount_t *rc, void *holder)
305 mutex_enter(&rc->rc_mtx);
307 if (!rc->rc_tracked) {
308 mutex_exit(&rc->rc_mtx);
312 for (ref = list_head(&rc->rc_list); ref;
313 ref = list_next(&rc->rc_list, ref)) {
315 mutex_exit(&rc->rc_mtx);
319 mutex_exit(&rc->rc_mtx);