From: walter Date: Fri, 21 Dec 2007 04:45:14 +0000 (+0000) Subject: revert bz-14390 commit which is causing build failures on buffalo. X-Git-Tag: v1_7_0_51~373 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=b3d5d96caee1cc67a9b79fe5e617a5e583b13593 revert bz-14390 commit which is causing build failures on buffalo. --- diff --git a/lnet/include/libcfs/bitmap.h b/lnet/include/libcfs/bitmap.h index 64ee0e3..b9e6e18 100644 --- a/lnet/include/libcfs/bitmap.h +++ b/lnet/include/libcfs/bitmap.h @@ -28,24 +28,24 @@ typedef struct { unsigned long data[0]; } bitmap_t; -#define CFS_BITMAP_SIZE(nbits) \ - (((nbits/BITS_PER_LONG)+1)*sizeof(long)+sizeof(bitmap_t)) +#define BITMAP_SIZE(nbits) (((nbits/BITS_PER_LONG)+1)*sizeof(long)+sizeof(bitmap_t)) static inline bitmap_t *ALLOCATE_BITMAP(int size) { bitmap_t *ptr; - OBD_ALLOC(ptr, CFS_BITMAP_SIZE(size)); + OBD_ALLOC(ptr, BITMAP_SIZE(size)); if (ptr == NULL) RETURN(ptr); ptr->size = size; + memset(ptr->data, 0, BITMAP_SIZE(size)); RETURN (ptr); } -#define FREE_BITMAP(ptr) OBD_FREE(ptr, CFS_BITMAP_SIZE(ptr->size)) +#define FREE_BITMAP(ptr) OBD_FREE(ptr, BITMAP_SIZE(ptr->size)) static inline void bitmap_set(bitmap_t *bitmap, int nbit) @@ -62,7 +62,8 @@ void bitmap_clear(bitmap_t *bitmap, int nbit) static inline int bitmap_check(bitmap_t *bitmap, int nbit) { - return test_bit(nbit, bitmap->data); + int pos = nbit % BITS_PER_LONG; + return test_bit(pos, bitmap->data+(nbit/BITS_PER_LONG)); } /* return 0 is bitmap has none set bits */ diff --git a/lnet/include/libcfs/user-bitops.h b/lnet/include/libcfs/user-bitops.h index 272bcf2..f6034c3 100644 --- a/lnet/include/libcfs/user-bitops.h +++ b/lnet/include/libcfs/user-bitops.h @@ -26,75 +26,11 @@ #ifndef __LIBCFS_USER_BITOPS_H__ #define __LIBCFS_USER_BITOPS_H__ -/* test if bit nr is set in bitmap addr; returns previous value of bit nr */ -static __inline__ int set_bit(int nr, long * addr) -{ - long mask; +unsigned long find_next_bit(const unsigned int *addr, + unsigned long size, unsigned long offset); - addr += nr / BITS_PER_LONG; - mask = 1UL << (nr & (BITS_PER_LONG - 1)); - nr = (mask & *addr) != 0; - *addr |= mask; - return nr; -} - -/* clear bit nr in bitmap addr; returns previous value of bit nr*/ -static __inline__ int clear_bit(int nr, long * addr) -{ - long mask; - - addr += nr / BITS_PER_LONG; - mask = 1UL << (nr & (BITS_PER_LONG - 1)); - nr = (mask & *addr) != 0; - *addr &= ~mask; - return nr; -} - -static __inline__ int test_bit(int nr, long * addr) -{ - return ((1UL << (nr & (BITS_PER_LONG - 1))) & ((addr)[nr / BITS_PER_LONG])) != 0; -} - -/* using binary seach */ -static __inline__ unsigned long __ffs(long data) -{ - int pos = 0; - -#if BITS_PER_LONG == 64 - if ((data & 0xFFFFFFFF) == 0) { - pos += 32; - data >>= 32; - } -#endif - if ((data & 0xFFFF) == 0) { - pos += 16; - data >>= 16; - } - if ((data & 0xFF) == 0) { - pos += 8; - data >>= 8; - } - if ((data & 0xF) == 0) { - pos += 4; - data >>= 4; - } - if ((data & 0x3) == 0) { - pos += 2; - data >>= 2; - } - if ((data & 0x1) == 0) - pos += 1; - - return pos; -} - -#define __ffz(x) __ffs(~(x)) - -unsigned long find_next_bit(unsigned long *addr, - unsigned long size, unsigned long offset); - -unsigned long find_next_zero_bit(unsigned long *addr, - unsigned long size, unsigned long offset); +unsigned long find_next_zero_bit(const unsigned int *addr, + unsigned long size, unsigned long offset); #define find_first_bit(addr,size) (find_next_bit((addr),(size),0)) #define find_first_zero_bit(addr,size) (find_next_zero_bit((addr),(size),0)) diff --git a/lnet/libcfs/user-bitops.c b/lnet/libcfs/user-bitops.c index 8f94593..2c252e8 100644 --- a/lnet/libcfs/user-bitops.c +++ b/lnet/libcfs/user-bitops.c @@ -23,72 +23,74 @@ #include #include -#include -#define OFF_BY_START(start) ((start)/BITS_PER_LONG) +#include /* for ffs - confirm POSIX */ -unsigned long find_next_bit(unsigned long *addr, - unsigned long size, unsigned long offset) +#define BITS_PER_WORD 32 +#define OFF_BY_START(start) ((start)/BITS_PER_WORD) + +unsigned long find_next_bit(const unsigned int *addr, + unsigned long size, unsigned long offset) { - unsigned long *word, *last; - unsigned long first_bit, bit, base; + uint32_t *word, *last; + unsigned int first_bit, bit, base; word = addr + OFF_BY_START(offset); last = addr + OFF_BY_START(size-1); - first_bit = offset % BITS_PER_LONG; + first_bit = offset % BITS_PER_WORD; base = offset - first_bit; if (offset >= size) return size; if (first_bit != 0) { int tmp = (*word++) & (~0UL << first_bit); - bit = __ffs(tmp); - if (bit < BITS_PER_LONG) + bit = ffs(tmp); + if (bit < BITS_PER_WORD) goto found; word++; - base += BITS_PER_LONG; + base += BITS_PER_WORD; } while (word <= last) { - if (*word != 0UL) { - bit = __ffs(*word); + if (*word != 0ul) { + bit = ffs(*word); goto found; } word++; - base += BITS_PER_LONG; + base += BITS_PER_WORD; } return size; found: return base + bit; } -unsigned long find_next_zero_bit(unsigned long *addr, - unsigned long size, unsigned long offset) +unsigned long find_next_zero_bit(const unsigned int *addr, + unsigned long size, unsigned long offset) { - unsigned long *word, *last; - unsigned long first_bit, bit, base; + uint32_t *word, *last; + unsigned int first_bit, bit, base; word = addr + OFF_BY_START(offset); last = addr + OFF_BY_START(size-1); - first_bit = offset % BITS_PER_LONG; + first_bit = offset % BITS_PER_WORD; base = offset - first_bit; if (offset >= size) return size; if (first_bit != 0) { int tmp = (*word++) & (~0UL << first_bit); - bit = __ffz(tmp); - if (bit < BITS_PER_LONG) + bit = ffs(~tmp); + if (bit < BITS_PER_WORD) goto found; word++; - base += BITS_PER_LONG; + base += BITS_PER_WORD; } while (word <= last) { - if (*word != ~0UL) { - bit = __ffz(*word); + if (*word != ~0ul) { + bit = ffs(*word); goto found; } word++; - base += BITS_PER_LONG; + base += BITS_PER_WORD; } return size; found: diff --git a/lnet/libcfs/user-prim.c b/lnet/libcfs/user-prim.c index 2dad1b3..d363718 100644 --- a/lnet/libcfs/user-prim.c +++ b/lnet/libcfs/user-prim.c @@ -276,6 +276,13 @@ void cfs_mem_cache_free(cfs_mem_cache_t *c, void *addr) cfs_free(addr); } +/* + * This uses user-visible declarations from + */ +#ifdef __linux__ +#include +#endif + void cfs_enter_debugger(void) { /*