Lines Matching refs:rc

63 refcount_create(refcount_t *rc)
65 mutex_init(&rc->rc_mtx, NULL, MUTEX_DEFAULT, NULL);
66 list_create(&rc->rc_list, sizeof (reference_t),
68 list_create(&rc->rc_removed, sizeof (reference_t),
70 rc->rc_count = 0;
71 rc->rc_removed_count = 0;
72 rc->rc_tracked = reference_tracking_enable;
76 refcount_create_tracked(refcount_t *rc)
78 refcount_create(rc);
79 rc->rc_tracked = B_TRUE;
83 refcount_create_untracked(refcount_t *rc)
85 refcount_create(rc);
86 rc->rc_tracked = B_FALSE;
90 refcount_destroy_many(refcount_t *rc, uint64_t number)
94 ASSERT(rc->rc_count == number);
95 while (ref = list_head(&rc->rc_list)) {
96 list_remove(&rc->rc_list, ref);
99 list_destroy(&rc->rc_list);
101 while (ref = list_head(&rc->rc_removed)) {
102 list_remove(&rc->rc_removed, ref);
106 list_destroy(&rc->rc_removed);
107 mutex_destroy(&rc->rc_mtx);
111 refcount_destroy(refcount_t *rc)
113 refcount_destroy_many(rc, 0);
117 refcount_is_zero(refcount_t *rc)
119 return (rc->rc_count == 0);
123 refcount_count(refcount_t *rc)
125 return (rc->rc_count);
129 refcount_add_many(refcount_t *rc, uint64_t number, void *holder)
134 if (rc->rc_tracked) {
139 mutex_enter(&rc->rc_mtx);
140 ASSERT(rc->rc_count >= 0);
141 if (rc->rc_tracked)
142 list_insert_head(&rc->rc_list, ref);
143 rc->rc_count += number;
144 count = rc->rc_count;
145 mutex_exit(&rc->rc_mtx);
151 refcount_add(refcount_t *rc, void *holder)
153 return (refcount_add_many(rc, 1, holder));
157 refcount_remove_many(refcount_t *rc, uint64_t number, void *holder)
162 mutex_enter(&rc->rc_mtx);
163 ASSERT(rc->rc_count >= number);
165 if (!rc->rc_tracked) {
166 rc->rc_count -= number;
167 count = rc->rc_count;
168 mutex_exit(&rc->rc_mtx);
172 for (ref = list_head(&rc->rc_list); ref;
173 ref = list_next(&rc->rc_list, ref)) {
175 list_remove(&rc->rc_list, ref);
180 list_insert_head(&rc->rc_removed, ref);
181 rc->rc_removed_count++;
182 if (rc->rc_removed_count > reference_history) {
183 ref = list_tail(&rc->rc_removed);
184 list_remove(&rc->rc_removed, ref);
188 rc->rc_removed_count--;
193 rc->rc_count -= number;
194 count = rc->rc_count;
195 mutex_exit(&rc->rc_mtx);
200 (u_longlong_t)(uintptr_t)rc);
205 refcount_remove(refcount_t *rc, void *holder)
207 return (refcount_remove_many(rc, 1, holder));
242 refcount_transfer_ownership(refcount_t *rc, void *current_holder,
248 mutex_enter(&rc->rc_mtx);
249 if (!rc->rc_tracked) {
250 mutex_exit(&rc->rc_mtx);
254 for (ref = list_head(&rc->rc_list); ref;
255 ref = list_next(&rc->rc_list, ref)) {
263 mutex_exit(&rc->rc_mtx);
272 refcount_held(refcount_t *rc, void *holder)
276 mutex_enter(&rc->rc_mtx);
278 if (!rc->rc_tracked) {
279 mutex_exit(&rc->rc_mtx);
280 return (rc->rc_count > 0);
283 for (ref = list_head(&rc->rc_list); ref;
284 ref = list_next(&rc->rc_list, ref)) {
286 mutex_exit(&rc->rc_mtx);
290 mutex_exit(&rc->rc_mtx);
300 refcount_not_held(refcount_t *rc, void *holder)
304 mutex_enter(&rc->rc_mtx);
306 if (!rc->rc_tracked) {
307 mutex_exit(&rc->rc_mtx);
311 for (ref = list_head(&rc->rc_list); ref;
312 ref = list_next(&rc->rc_list, ref)) {
314 mutex_exit(&rc->rc_mtx);
318 mutex_exit(&rc->rc_mtx);