kernels/linux-2.4.0/include/asm-ia64/bitops.h
/*
 * Find next zero bit in a bitmap reasonably efficiently..
 */
Find next zero bit in a bitmap reasonably efficiently
Find next zero bit in a bitmap reasonably efficiently
static inline int
find_next_zero_bit (void *addr, unsigned long size, unsigned long offset)
{
	unsigned long *p = ((unsigned long *) addr) + (offset >> 6);
	unsigned long result = offset & ~63UL;
	unsigned long tmp;
	if (offset >= size)
		return size;
	size -= result;
	offset &= 63UL;
	if (offset) {
		tmp = *(p++);
		tmp |= ~0UL >> (64-offset);
		if (size < 64)
			goto found_first;
		if (~tmp)
			goto found_middle;
		size -= 64;
		result += 64;
	}
	while (size & ~63UL) {
		if (~(tmp = *(p++)))
			goto found_middle;
		result += 64;
		size -= 64;
	}
	if (!size)
		return result;
	tmp = *p;
found_first:
	tmp |= ~0UL << size;
found_middle:
	return result + ffz(tmp);
}
static inline int find_next_zero_bit ( void * addr , unsigned long size , unsigned long offset ) { unsigned long * p = ( ( unsigned long * ) addr ) + ( offset >> 6 ) ; unsigned long result = offset & ~ 63UL ; unsigned long tmp ; if ( offset >= size ) return size ; size -= result ; offset &= 63UL ; if ( offset ) { tmp = * ( p ++ ) ; tmp |= ~ 0UL >> ( 64 - offset ) ; if ( size < 64 ) goto found_first ; if ( ~ tmp ) goto found_middle ; size -= 64 ; result += 64 ; } while ( size & ~ 63UL ) { if ( ~ ( tmp = * ( p ++ ) ) ) goto found_middle ; result += 64 ; size -= 64 ; } if ( ! size ) return result ; tmp = * p ; found_first : tmp |= ~ 0UL << size ; found_middle : return result + ffz ( tmp ) ; }
Find next zero bit in a bitmap reasonably efficiently..
Find next zero bit in a bitmap reasonably efficiently ..