154 * Low order bit is 0, high order bit is 31.
155 */
156 extern int highbit(ulong_t);
157 extern int highbit64(uint64_t);
158 extern int lowbit(ulong_t);
159 extern int bt_getlowbit(ulong_t *bitmap, size_t start, size_t stop);
160 extern void bt_copy(ulong_t *, ulong_t *, ulong_t);
161
162 /*
163 * find the parity
164 */
165 extern int odd_parity(ulong_t);
166
167 /*
168 * Atomically set/clear bits
169 * Atomic exclusive operations will set "result" to "-1"
170 * if the bit is already set/cleared. "result" will be set
171 * to 0 otherwise.
172 */
173 #define BT_ATOMIC_SET(bitmap, bitindex) \
174 { atomic_or_long(&(BT_WIM(bitmap, bitindex)), BT_BIW(bitindex)); }
175 #define BT_ATOMIC_CLEAR(bitmap, bitindex) \
176 { atomic_and_long(&(BT_WIM(bitmap, bitindex)), ~BT_BIW(bitindex)); }
177
178 #define BT_ATOMIC_SET_EXCL(bitmap, bitindex, result) \
179 { result = atomic_set_long_excl(&(BT_WIM(bitmap, bitindex)), \
180 (bitindex) % BT_NBIPUL); }
181 #define BT_ATOMIC_CLEAR_EXCL(bitmap, bitindex, result) \
182 { result = atomic_clear_long_excl(&(BT_WIM(bitmap, bitindex)), \
183 (bitindex) % BT_NBIPUL); }
184
185 /*
186 * Extracts bits between index h (high, inclusive) and l (low, exclusive) from
187 * u, which must be an unsigned integer.
188 */
189 #define BITX(u, h, l) (((u) >> (l)) & ((1LU << ((h) - (l) + 1LU)) - 1LU))
190
191 #endif /* _KERNEL && !_ASM */
192
193 #ifdef __cplusplus
194 }
195 #endif
196
|
154 * Low order bit is 0, high order bit is 31.
155 */
156 extern int highbit(ulong_t);
157 extern int highbit64(uint64_t);
158 extern int lowbit(ulong_t);
159 extern int bt_getlowbit(ulong_t *bitmap, size_t start, size_t stop);
160 extern void bt_copy(ulong_t *, ulong_t *, ulong_t);
161
162 /*
163 * find the parity
164 */
165 extern int odd_parity(ulong_t);
166
167 /*
168 * Atomically set/clear bits
169 * Atomic exclusive operations will set "result" to "-1"
170 * if the bit is already set/cleared. "result" will be set
171 * to 0 otherwise.
172 */
173 #define BT_ATOMIC_SET(bitmap, bitindex) \
174 { atomic_or_ulong(&(BT_WIM(bitmap, bitindex)), BT_BIW(bitindex)); }
175 #define BT_ATOMIC_CLEAR(bitmap, bitindex) \
176 { atomic_and_ulong(&(BT_WIM(bitmap, bitindex)), ~BT_BIW(bitindex)); }
177
178 #define BT_ATOMIC_SET_EXCL(bitmap, bitindex, result) \
179 { result = atomic_set_long_excl(&(BT_WIM(bitmap, bitindex)), \
180 (bitindex) % BT_NBIPUL); }
181 #define BT_ATOMIC_CLEAR_EXCL(bitmap, bitindex, result) \
182 { result = atomic_clear_long_excl(&(BT_WIM(bitmap, bitindex)), \
183 (bitindex) % BT_NBIPUL); }
184
185 /*
186 * Extracts bits between index h (high, inclusive) and l (low, exclusive) from
187 * u, which must be an unsigned integer.
188 */
189 #define BITX(u, h, l) (((u) >> (l)) & ((1LU << ((h) - (l) + 1LU)) - 1LU))
190
191 #endif /* _KERNEL && !_ASM */
192
193 #ifdef __cplusplus
194 }
195 #endif
196
|