// max_index is the 0-based position of the most significant bit that is // allowed to be set. DISPATCH_ALWAYS_INLINE_NDEBUG static unsigned int bitmap_set_first_unset_bit_upto_index(volatile bitmap_t *bitmap, unsigned int max_index) { // No barriers needed in acquire path: the just-allocated // continuation is "uninitialized", so the caller shouldn't // load from it before storing, so we don't need to guard // against reordering those loads. #if defined(__x86_64__) // TODO rdar://problem/11477843 dispatch_assert(sizeof(*bitmap) == sizeof(uint64_t)); return dispatch_atomic_set_first_bit((volatile uint64_t *)bitmap,max_index); #else dispatch_assert(sizeof(*bitmap) == sizeof(uint32_t)); return dispatch_atomic_set_first_bit((volatile uint32_t *)bitmap,max_index); #endif }
// max_index is the 0-based position of the most significant bit that is // allowed to be set. DISPATCH_ALWAYS_INLINE_NDEBUG static unsigned int bitmap_set_first_unset_bit_upto_index(volatile bitmap_t *bitmap, unsigned int max_index) { // No barriers needed in acquire path: the just-allocated // continuation is "uninitialized", so the caller shouldn't // load from it before storing, so we don't need to guard // against reordering those loads. dispatch_assert(sizeof(*bitmap) == sizeof(unsigned long)); return dispatch_atomic_set_first_bit(bitmap,max_index); }