Lines Matching defs:rc

59 refcount_create(refcount_t *rc)
61 mutex_init(&rc->rc_mtx, NULL, MUTEX_DEFAULT, NULL);
62 list_create(&rc->rc_list, sizeof (reference_t),
64 list_create(&rc->rc_removed, sizeof (reference_t),
66 rc->rc_count = 0;
67 rc->rc_removed_count = 0;
68 rc->rc_tracked = reference_tracking_enable;
72 refcount_create_tracked(refcount_t *rc)
74 refcount_create(rc);
75 rc->rc_tracked = B_TRUE;
79 refcount_create_untracked(refcount_t *rc)
81 refcount_create(rc);
82 rc->rc_tracked = B_FALSE;
86 refcount_destroy_many(refcount_t *rc, uint64_t number)
90 ASSERT(rc->rc_count == number);
91 while (ref = list_head(&rc->rc_list)) {
92 list_remove(&rc->rc_list, ref);
95 list_destroy(&rc->rc_list);
97 while (ref = list_head(&rc->rc_removed)) {
98 list_remove(&rc->rc_removed, ref);
102 list_destroy(&rc->rc_removed);
103 mutex_destroy(&rc->rc_mtx);
107 refcount_destroy(refcount_t *rc)
109 refcount_destroy_many(rc, 0);
113 refcount_is_zero(refcount_t *rc)
115 return (rc->rc_count == 0);
119 refcount_count(refcount_t *rc)
121 return (rc->rc_count);
125 refcount_add_many(refcount_t *rc, uint64_t number, void *holder)
130 if (rc->rc_tracked) {
135 mutex_enter(&rc->rc_mtx);
136 ASSERT(rc->rc_count >= 0);
137 if (rc->rc_tracked)
138 list_insert_head(&rc->rc_list, ref);
139 rc->rc_count += number;
140 count = rc->rc_count;
141 mutex_exit(&rc->rc_mtx);
147 refcount_add(refcount_t *rc, void *holder)
149 return (refcount_add_many(rc, 1, holder));
153 refcount_remove_many(refcount_t *rc, uint64_t number, void *holder)
158 mutex_enter(&rc->rc_mtx);
159 ASSERT(rc->rc_count >= number);
161 if (!rc->rc_tracked) {
162 rc->rc_count -= number;
163 count = rc->rc_count;
164 mutex_exit(&rc->rc_mtx);
168 for (ref = list_head(&rc->rc_list); ref;
169 ref = list_next(&rc->rc_list, ref)) {
171 list_remove(&rc->rc_list, ref);
176 list_insert_head(&rc->rc_removed, ref);
177 rc->rc_removed_count++;
178 if (rc->rc_removed_count > reference_history) {
179 ref = list_tail(&rc->rc_removed);
180 list_remove(&rc->rc_removed, ref);
184 rc->rc_removed_count--;
189 rc->rc_count -= number;
190 count = rc->rc_count;
191 mutex_exit(&rc->rc_mtx);
196 (u_longlong_t)(uintptr_t)rc);
201 refcount_remove(refcount_t *rc, void *holder)
203 return (refcount_remove_many(rc, 1, holder));
238 refcount_transfer_ownership(refcount_t *rc, void *current_holder,
244 mutex_enter(&rc->rc_mtx);
245 if (!rc->rc_tracked) {
246 mutex_exit(&rc->rc_mtx);
250 for (ref = list_head(&rc->rc_list); ref;
251 ref = list_next(&rc->rc_list, ref)) {
259 mutex_exit(&rc->rc_mtx);
268 refcount_held(refcount_t *rc, void *holder)
272 mutex_enter(&rc->rc_mtx);
274 if (!rc->rc_tracked) {
275 mutex_exit(&rc->rc_mtx);
276 return (rc->rc_count > 0);
279 for (ref = list_head(&rc->rc_list); ref;
280 ref = list_next(&rc->rc_list, ref)) {
282 mutex_exit(&rc->rc_mtx);
286 mutex_exit(&rc->rc_mtx);
296 refcount_not_held(refcount_t *rc, void *holder)
300 mutex_enter(&rc->rc_mtx);
302 if (!rc->rc_tracked) {
303 mutex_exit(&rc->rc_mtx);
307 for (ref = list_head(&rc->rc_list); ref;
308 ref = list_next(&rc->rc_list, ref)) {
310 mutex_exit(&rc->rc_mtx);
314 mutex_exit(&rc->rc_mtx);