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_untracked(refcount_t *rc)
78 refcount_create(rc);
79 rc->rc_tracked = B_FALSE;
83 refcount_destroy_many(refcount_t *rc, uint64_t number)
87 ASSERT(rc->rc_count == number);
88 while (ref = list_head(&rc->rc_list)) {
89 list_remove(&rc->rc_list, ref);
92 list_destroy(&rc->rc_list);
94 while (ref = list_head(&rc->rc_removed)) {
95 list_remove(&rc->rc_removed, ref);
99 list_destroy(&rc->rc_removed);
100 mutex_destroy(&rc->rc_mtx);
104 refcount_destroy(refcount_t *rc)
106 refcount_destroy_many(rc, 0);
110 refcount_is_zero(refcount_t *rc)
112 return (rc->rc_count == 0);
116 refcount_count(refcount_t *rc)
118 return (rc->rc_count);
122 refcount_add_many(refcount_t *rc, uint64_t number, void *holder)
127 if (rc->rc_tracked) {
132 mutex_enter(&rc->rc_mtx);
133 ASSERT(rc->rc_count >= 0);
134 if (rc->rc_tracked)
135 list_insert_head(&rc->rc_list, ref);
136 rc->rc_count += number;
137 count = rc->rc_count;
138 mutex_exit(&rc->rc_mtx);
144 refcount_add(refcount_t *rc, void *holder)
146 return (refcount_add_many(rc, 1, holder));
150 refcount_remove_many(refcount_t *rc, uint64_t number, void *holder)
155 mutex_enter(&rc->rc_mtx);
156 ASSERT(rc->rc_count >= number);
158 if (!rc->rc_tracked) {
159 rc->rc_count -= number;
160 count = rc->rc_count;
161 mutex_exit(&rc->rc_mtx);
165 for (ref = list_head(&rc->rc_list); ref;
166 ref = list_next(&rc->rc_list, ref)) {
168 list_remove(&rc->rc_list, ref);
173 list_insert_head(&rc->rc_removed, ref);
174 rc->rc_removed_count++;
175 if (rc->rc_removed_count > reference_history) {
176 ref = list_tail(&rc->rc_removed);
177 list_remove(&rc->rc_removed, ref);
181 rc->rc_removed_count--;
186 rc->rc_count -= number;
187 count = rc->rc_count;
188 mutex_exit(&rc->rc_mtx);
193 (u_longlong_t)(uintptr_t)rc);
198 refcount_remove(refcount_t *rc, void *holder)
200 return (refcount_remove_many(rc, 1, holder));