Lines Matching refs: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_untracked(refcount_t *rc)
74 refcount_create(rc);
75 rc->rc_tracked = B_FALSE;
79 refcount_destroy_many(refcount_t *rc, uint64_t number)
83 ASSERT(rc->rc_count == number);
84 while (ref = list_head(&rc->rc_list)) {
85 list_remove(&rc->rc_list, ref);
88 list_destroy(&rc->rc_list);
90 while (ref = list_head(&rc->rc_removed)) {
91 list_remove(&rc->rc_removed, ref);
95 list_destroy(&rc->rc_removed);
96 mutex_destroy(&rc->rc_mtx);
100 refcount_destroy(refcount_t *rc)
102 refcount_destroy_many(rc, 0);
106 refcount_is_zero(refcount_t *rc)
108 return (rc->rc_count == 0);
112 refcount_count(refcount_t *rc)
114 return (rc->rc_count);
118 refcount_add_many(refcount_t *rc, uint64_t number, void *holder)
123 if (rc->rc_tracked) {
128 mutex_enter(&rc->rc_mtx);
129 ASSERT(rc->rc_count >= 0);
130 if (rc->rc_tracked)
131 list_insert_head(&rc->rc_list, ref);
132 rc->rc_count += number;
133 count = rc->rc_count;
134 mutex_exit(&rc->rc_mtx);
140 refcount_add(refcount_t *rc, void *holder)
142 return (refcount_add_many(rc, 1, holder));
146 refcount_remove_many(refcount_t *rc, uint64_t number, void *holder)
151 mutex_enter(&rc->rc_mtx);
152 ASSERT(rc->rc_count >= number);
154 if (!rc->rc_tracked) {
155 rc->rc_count -= number;
156 count = rc->rc_count;
157 mutex_exit(&rc->rc_mtx);
161 for (ref = list_head(&rc->rc_list); ref;
162 ref = list_next(&rc->rc_list, ref)) {
164 list_remove(&rc->rc_list, ref);
169 list_insert_head(&rc->rc_removed, ref);
170 rc->rc_removed_count++;
171 if (rc->rc_removed_count > reference_history) {
172 ref = list_tail(&rc->rc_removed);
173 list_remove(&rc->rc_removed, ref);
177 rc->rc_removed_count--;
182 rc->rc_count -= number;
183 count = rc->rc_count;
184 mutex_exit(&rc->rc_mtx);
189 (u_longlong_t)(uintptr_t)rc);
194 refcount_remove(refcount_t *rc, void *holder)
196 return (refcount_remove_many(rc, 1, holder));