X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=include%2Fasm-i386%2Fbitops.h;fp=include%2Fasm-i386%2Fbitops.h;h=88e6ca248cd74f0a2a17f033a34c98d80df5e0f6;hb=64ba3f394c830ec48a1c31b53dcae312c56f1604;hp=1c780fa1e762e966a6f6255dbf0e5bbf4a326e65;hpb=be1e6109ac94a859551f8e1774eb9a8469fe055c;p=linux-2.6.git diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h index 1c780fa1e..88e6ca248 100644 --- a/include/asm-i386/bitops.h +++ b/include/asm-i386/bitops.h @@ -5,8 +5,8 @@ * Copyright 1992, Linus Torvalds. */ +#include #include -#include /* * These have to be done with inline assembly: that way the bit-setting @@ -16,6 +16,12 @@ * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). */ +#ifdef CONFIG_SMP +#define LOCK_PREFIX "lock ; " +#else +#define LOCK_PREFIX "" +#endif + #define ADDR (*(volatile long *) addr) /** @@ -361,9 +367,28 @@ static inline unsigned long ffz(unsigned long word) return word; } +#define fls64(x) generic_fls64(x) + #ifdef __KERNEL__ -#include +/* + * Every architecture must define this function. It's the fastest + * way of searching a 140-bit bitmap where the first 100 bits are + * unlikely to be set. It's guaranteed that at least one of the 140 + * bits is cleared. + */ +static inline int sched_find_first_bit(const unsigned long *b) +{ + if (unlikely(b[0])) + return __ffs(b[0]); + if (unlikely(b[1])) + return __ffs(b[1]) + 32; + if (unlikely(b[2])) + return __ffs(b[2]) + 64; + if (b[3]) + return __ffs(b[3]) + 96; + return __ffs(b[4]) + 128; +} /** * ffs - find first bit set @@ -401,22 +426,42 @@ static inline int fls(int x) return r+1; } -#include +/** + * hweightN - returns the hamming weight of a N-bit word + * @x: the word to weigh + * + * The Hamming Weight of a number is the total number of bits set in it. + */ -#endif /* __KERNEL__ */ +#define hweight32(x) generic_hweight32(x) +#define hweight16(x) generic_hweight16(x) +#define hweight8(x) generic_hweight8(x) -#include +#endif /* __KERNEL__ */ #ifdef __KERNEL__ -#include - +#define ext2_set_bit(nr,addr) \ + __test_and_set_bit((nr),(unsigned long*)addr) #define ext2_set_bit_atomic(lock,nr,addr) \ test_and_set_bit((nr),(unsigned long*)addr) +#define ext2_clear_bit(nr, addr) \ + __test_and_clear_bit((nr),(unsigned long*)addr) #define ext2_clear_bit_atomic(lock,nr, addr) \ test_and_clear_bit((nr),(unsigned long*)addr) - -#include +#define ext2_test_bit(nr, addr) test_bit((nr),(unsigned long*)addr) +#define ext2_find_first_zero_bit(addr, size) \ + find_first_zero_bit((unsigned long*)addr, size) +#define ext2_find_next_zero_bit(addr, size, off) \ + find_next_zero_bit((unsigned long*)addr, size, off) + +/* Bitmap functions for the minix filesystem. */ +#define minix_test_and_set_bit(nr,addr) __test_and_set_bit(nr,(void*)addr) +#define minix_set_bit(nr,addr) __set_bit(nr,(void*)addr) +#define minix_test_and_clear_bit(nr,addr) __test_and_clear_bit(nr,(void*)addr) +#define minix_test_bit(nr,addr) test_bit(nr,(void*)addr) +#define minix_find_first_zero_bit(addr,size) \ + find_first_zero_bit((void*)addr,size) #endif /* __KERNEL__ */