Skip to content
Snippets Groups Projects
Commit b3d5d96c authored by Walter Poxon's avatar Walter Poxon
Browse files

revert bz-14390 commit which is causing build failures on buffalo.

parent 90d3d3d6
No related merge requests found
...@@ -28,24 +28,24 @@ typedef struct { ...@@ -28,24 +28,24 @@ typedef struct {
unsigned long data[0]; unsigned long data[0];
} bitmap_t; } bitmap_t;
#define CFS_BITMAP_SIZE(nbits) \ #define BITMAP_SIZE(nbits) (((nbits/BITS_PER_LONG)+1)*sizeof(long)+sizeof(bitmap_t))
(((nbits/BITS_PER_LONG)+1)*sizeof(long)+sizeof(bitmap_t))
static inline static inline
bitmap_t *ALLOCATE_BITMAP(int size) bitmap_t *ALLOCATE_BITMAP(int size)
{ {
bitmap_t *ptr; bitmap_t *ptr;
OBD_ALLOC(ptr, CFS_BITMAP_SIZE(size)); OBD_ALLOC(ptr, BITMAP_SIZE(size));
if (ptr == NULL) if (ptr == NULL)
RETURN(ptr); RETURN(ptr);
ptr->size = size; ptr->size = size;
memset(ptr->data, 0, BITMAP_SIZE(size));
RETURN (ptr); 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 static inline
void bitmap_set(bitmap_t *bitmap, int nbit) void bitmap_set(bitmap_t *bitmap, int nbit)
...@@ -62,7 +62,8 @@ void bitmap_clear(bitmap_t *bitmap, int nbit) ...@@ -62,7 +62,8 @@ void bitmap_clear(bitmap_t *bitmap, int nbit)
static inline static inline
int bitmap_check(bitmap_t *bitmap, int nbit) 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 */ /* return 0 is bitmap has none set bits */
......
...@@ -26,75 +26,11 @@ ...@@ -26,75 +26,11 @@
#ifndef __LIBCFS_USER_BITOPS_H__ #ifndef __LIBCFS_USER_BITOPS_H__
#define __LIBCFS_USER_BITOPS_H__ #define __LIBCFS_USER_BITOPS_H__
/* test if bit nr is set in bitmap addr; returns previous value of bit nr */ unsigned long find_next_bit(const unsigned int *addr,
static __inline__ int set_bit(int nr, long * addr) unsigned long size, unsigned long offset);
{
long mask;
addr += nr / BITS_PER_LONG; unsigned long find_next_zero_bit(const unsigned int *addr,
mask = 1UL << (nr & (BITS_PER_LONG - 1)); unsigned long size, unsigned long offset);
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);
#define find_first_bit(addr,size) (find_next_bit((addr),(size),0)) #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)) #define find_first_zero_bit(addr,size) (find_next_zero_bit((addr),(size),0))
......
...@@ -23,72 +23,74 @@ ...@@ -23,72 +23,74 @@
#include <libcfs/libcfs.h> #include <libcfs/libcfs.h>
#include <libcfs/kp30.h> #include <libcfs/kp30.h>
#include <libcfs/user-bitops.h>
#define OFF_BY_START(start) ((start)/BITS_PER_LONG) #include <string.h> /* for ffs - confirm POSIX */
unsigned long find_next_bit(unsigned long *addr, #define BITS_PER_WORD 32
unsigned long size, unsigned long offset) #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; uint32_t *word, *last;
unsigned long first_bit, bit, base; unsigned int first_bit, bit, base;
word = addr + OFF_BY_START(offset); word = addr + OFF_BY_START(offset);
last = addr + OFF_BY_START(size-1); last = addr + OFF_BY_START(size-1);
first_bit = offset % BITS_PER_LONG; first_bit = offset % BITS_PER_WORD;
base = offset - first_bit; base = offset - first_bit;
if (offset >= size) if (offset >= size)
return size; return size;
if (first_bit != 0) { if (first_bit != 0) {
int tmp = (*word++) & (~0UL << first_bit); int tmp = (*word++) & (~0UL << first_bit);
bit = __ffs(tmp); bit = ffs(tmp);
if (bit < BITS_PER_LONG) if (bit < BITS_PER_WORD)
goto found; goto found;
word++; word++;
base += BITS_PER_LONG; base += BITS_PER_WORD;
} }
while (word <= last) { while (word <= last) {
if (*word != 0UL) { if (*word != 0ul) {
bit = __ffs(*word); bit = ffs(*word);
goto found; goto found;
} }
word++; word++;
base += BITS_PER_LONG; base += BITS_PER_WORD;
} }
return size; return size;
found: found:
return base + bit; return base + bit;
} }
unsigned long find_next_zero_bit(unsigned long *addr, unsigned long find_next_zero_bit(const unsigned int *addr,
unsigned long size, unsigned long offset) unsigned long size, unsigned long offset)
{ {
unsigned long *word, *last; uint32_t *word, *last;
unsigned long first_bit, bit, base; unsigned int first_bit, bit, base;
word = addr + OFF_BY_START(offset); word = addr + OFF_BY_START(offset);
last = addr + OFF_BY_START(size-1); last = addr + OFF_BY_START(size-1);
first_bit = offset % BITS_PER_LONG; first_bit = offset % BITS_PER_WORD;
base = offset - first_bit; base = offset - first_bit;
if (offset >= size) if (offset >= size)
return size; return size;
if (first_bit != 0) { if (first_bit != 0) {
int tmp = (*word++) & (~0UL << first_bit); int tmp = (*word++) & (~0UL << first_bit);
bit = __ffz(tmp); bit = ffs(~tmp);
if (bit < BITS_PER_LONG) if (bit < BITS_PER_WORD)
goto found; goto found;
word++; word++;
base += BITS_PER_LONG; base += BITS_PER_WORD;
} }
while (word <= last) { while (word <= last) {
if (*word != ~0UL) { if (*word != ~0ul) {
bit = __ffz(*word); bit = ffs(*word);
goto found; goto found;
} }
word++; word++;
base += BITS_PER_LONG; base += BITS_PER_WORD;
} }
return size; return size;
found: found:
......
...@@ -276,6 +276,13 @@ void cfs_mem_cache_free(cfs_mem_cache_t *c, void *addr) ...@@ -276,6 +276,13 @@ void cfs_mem_cache_free(cfs_mem_cache_t *c, void *addr)
cfs_free(addr); cfs_free(addr);
} }
/*
* This uses user-visible declarations from <linux/kdev_t.h>
*/
#ifdef __linux__
#include <linux/kdev_t.h>
#endif
void cfs_enter_debugger(void) void cfs_enter_debugger(void)
{ {
/* /*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment