Commit 917b3bd7 authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds

[PATCH] set_bit takes a long

Finally, this changes set_bit et al. to take a "unsigned long *" on
ppc and i386.  This will make the world a better place.

Please forward patches for any warnings which crop up in random code
to trivial@rustcorp.com.au.
parent 86a94161
......@@ -34,7 +34,7 @@
* Note that @nr may be almost arbitrarily large; this function is not
* restricted to acting on a single-word quantity.
*/
static __inline__ void set_bit(int nr, volatile void * addr)
static __inline__ void set_bit(int nr, volatile unsigned long * addr)
{
__asm__ __volatile__( LOCK_PREFIX
"btsl %1,%0"
......@@ -51,7 +51,7 @@ static __inline__ void set_bit(int nr, volatile void * addr)
* If it's called on the same region of memory simultaneously, the effect
* may be that only one operation succeeds.
*/
static __inline__ void __set_bit(int nr, volatile void * addr)
static __inline__ void __set_bit(int nr, volatile unsigned long * addr)
{
__asm__(
"btsl %1,%0"
......@@ -69,7 +69,7 @@ static __inline__ void __set_bit(int nr, volatile void * addr)
* you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
* in order to ensure changes are visible on other processors.
*/
static __inline__ void clear_bit(int nr, volatile void * addr)
static __inline__ void clear_bit(int nr, volatile unsigned long * addr)
{
__asm__ __volatile__( LOCK_PREFIX
"btrl %1,%0"
......@@ -77,7 +77,7 @@ static __inline__ void clear_bit(int nr, volatile void * addr)
:"Ir" (nr));
}
static __inline__ void __clear_bit(int nr, volatile void * addr)
static __inline__ void __clear_bit(int nr, volatile unsigned long * addr)
{
__asm__ __volatile__(
"btrl %1,%0"
......@@ -96,7 +96,7 @@ static __inline__ void __clear_bit(int nr, volatile void * addr)
* If it's called on the same region of memory simultaneously, the effect
* may be that only one operation succeeds.
*/
static __inline__ void __change_bit(int nr, volatile void * addr)
static __inline__ void __change_bit(int nr, volatile unsigned long * addr)
{
__asm__ __volatile__(
"btcl %1,%0"
......@@ -113,7 +113,7 @@ static __inline__ void __change_bit(int nr, volatile void * addr)
* Note that @nr may be almost arbitrarily large; this function is not
* restricted to acting on a single-word quantity.
*/
static __inline__ void change_bit(int nr, volatile void * addr)
static __inline__ void change_bit(int nr, volatile unsigned long * addr)
{
__asm__ __volatile__( LOCK_PREFIX
"btcl %1,%0"
......@@ -129,7 +129,7 @@ static __inline__ void change_bit(int nr, volatile void * addr)
* This operation is atomic and cannot be reordered.
* It also implies a memory barrier.
*/
static __inline__ int test_and_set_bit(int nr, volatile void * addr)
static __inline__ int test_and_set_bit(int nr, volatile unsigned long * addr)
{
int oldbit;
......@@ -149,7 +149,7 @@ static __inline__ int test_and_set_bit(int nr, volatile void * addr)
* If two examples of this operation race, one can appear to succeed
* but actually fail. You must protect multiple accesses with a lock.
*/
static __inline__ int __test_and_set_bit(int nr, volatile void * addr)
static __inline__ int __test_and_set_bit(int nr, volatile unsigned long * addr)
{
int oldbit;
......@@ -168,7 +168,7 @@ static __inline__ int __test_and_set_bit(int nr, volatile void * addr)
* This operation is atomic and cannot be reordered.
* It also implies a memory barrier.
*/
static __inline__ int test_and_clear_bit(int nr, volatile void * addr)
static __inline__ int test_and_clear_bit(int nr, volatile unsigned long * addr)
{
int oldbit;
......@@ -188,7 +188,7 @@ static __inline__ int test_and_clear_bit(int nr, volatile void * addr)
* If two examples of this operation race, one can appear to succeed
* but actually fail. You must protect multiple accesses with a lock.
*/
static __inline__ int __test_and_clear_bit(int nr, volatile void * addr)
static __inline__ int __test_and_clear_bit(int nr, volatile unsigned long *addr)
{
int oldbit;
......@@ -200,7 +200,7 @@ static __inline__ int __test_and_clear_bit(int nr, volatile void * addr)
}
/* WARNING: non atomic and it can be reordered! */
static __inline__ int __test_and_change_bit(int nr, volatile void * addr)
static __inline__ int __test_and_change_bit(int nr, volatile unsigned long *addr)
{
int oldbit;
......@@ -219,7 +219,7 @@ static __inline__ int __test_and_change_bit(int nr, volatile void * addr)
* This operation is atomic and cannot be reordered.
* It also implies a memory barrier.
*/
static __inline__ int test_and_change_bit(int nr, volatile void * addr)
static __inline__ int test_and_change_bit(int nr, volatile unsigned long* addr)
{
int oldbit;
......@@ -239,12 +239,12 @@ static __inline__ int test_and_change_bit(int nr, volatile void * addr)
static int test_bit(int nr, const volatile void * addr);
#endif
static __inline__ int constant_test_bit(int nr, const volatile void * addr)
static __inline__ int constant_test_bit(int nr, const volatile unsigned long * addr)
{
return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
}
static __inline__ int variable_test_bit(int nr, volatile void * addr)
static __inline__ int variable_test_bit(int nr, volatile unsigned long * addr)
{
int oldbit;
......@@ -268,7 +268,7 @@ static __inline__ int variable_test_bit(int nr, volatile void * addr)
* Returns the bit-number of the first zero bit, not the number of the byte
* containing a bit.
*/
static __inline__ int find_first_zero_bit(void * addr, unsigned size)
static __inline__ int find_first_zero_bit(unsigned long * addr, unsigned size)
{
int d0, d1, d2;
int res;
......@@ -300,7 +300,7 @@ static __inline__ int find_first_zero_bit(void * addr, unsigned size)
* Returns the bit-number of the first set bit, not the number of the byte
* containing a bit.
*/
static __inline__ int find_first_bit(void * addr, unsigned size)
static __inline__ int find_first_bit(unsigned long * addr, unsigned size)
{
int d0, d1;
int res;
......@@ -326,7 +326,7 @@ static __inline__ int find_first_bit(void * addr, unsigned size)
* @offset: The bitnumber to start searching at
* @size: The maximum size to search
*/
static __inline__ int find_next_zero_bit (void * addr, int size, int offset)
static __inline__ int find_next_zero_bit(unsigned long * addr, int size, int offset)
{
unsigned long * p = ((unsigned long *) addr) + (offset >> 5);
int set = 0, bit = offset & 31, res;
......@@ -359,9 +359,9 @@ static __inline__ int find_next_zero_bit (void * addr, int size, int offset)
* @offset: The bitnumber to start searching at
* @size: The maximum size to search
*/
static __inline__ int find_next_bit(void * addr, int size, int offset)
static __inline__ int find_next_bit(unsigned long *addr, int size, int offset)
{
unsigned long * p = ((unsigned long *) addr) + (offset >> 5);
unsigned long * p = addr + (offset >> 5);
int set = 0, bit = offset & 31, res;
if (bit) {
......@@ -382,7 +382,7 @@ static __inline__ int find_next_bit(void * addr, int size, int offset)
/*
* No set bit yet, search remaining full words for a bit
*/
res = find_first_bit (p, size - 32 * (p - (unsigned long *) addr));
res = find_first_bit (p, size - 32 * (p - addr));
return (offset + set + res);
}
......
......@@ -30,7 +30,7 @@
* These used to be if'd out here because using : "cc" as a constraint
* resulted in errors from egcs. Things appear to be OK with gcc-2.95.
*/
static __inline__ void set_bit(int nr, volatile void * addr)
static __inline__ void set_bit(int nr, volatile unsigned long * addr)
{
unsigned long old;
unsigned long mask = 1 << (nr & 0x1f);
......@@ -50,7 +50,7 @@ static __inline__ void set_bit(int nr, volatile void * addr)
/*
* non-atomic version
*/
static __inline__ void __set_bit(int nr, volatile void *addr)
static __inline__ void __set_bit(int nr, volatile unsigned long *addr)
{
unsigned long mask = 1 << (nr & 0x1f);
unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
......@@ -64,7 +64,7 @@ static __inline__ void __set_bit(int nr, volatile void *addr)
#define smp_mb__before_clear_bit() smp_mb()
#define smp_mb__after_clear_bit() smp_mb()
static __inline__ void clear_bit(int nr, volatile void *addr)
static __inline__ void clear_bit(int nr, volatile unsigned long *addr)
{
unsigned long old;
unsigned long mask = 1 << (nr & 0x1f);
......@@ -84,7 +84,7 @@ static __inline__ void clear_bit(int nr, volatile void *addr)
/*
* non-atomic version
*/
static __inline__ void __clear_bit(int nr, volatile void *addr)
static __inline__ void __clear_bit(int nr, volatile unsigned long *addr)
{
unsigned long mask = 1 << (nr & 0x1f);
unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
......@@ -92,7 +92,7 @@ static __inline__ void __clear_bit(int nr, volatile void *addr)
*p &= ~mask;
}
static __inline__ void change_bit(int nr, volatile void *addr)
static __inline__ void change_bit(int nr, volatile unsigned long *addr)
{
unsigned long old;
unsigned long mask = 1 << (nr & 0x1f);
......@@ -112,7 +112,7 @@ static __inline__ void change_bit(int nr, volatile void *addr)
/*
* non-atomic version
*/
static __inline__ void __change_bit(int nr, volatile void *addr)
static __inline__ void __change_bit(int nr, volatile unsigned long *addr)
{
unsigned long mask = 1 << (nr & 0x1f);
unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
......@@ -123,7 +123,7 @@ static __inline__ void __change_bit(int nr, volatile void *addr)
/*
* test_and_*_bit do imply a memory barrier (?)
*/
static __inline__ int test_and_set_bit(int nr, volatile void *addr)
static __inline__ int test_and_set_bit(int nr, volatile unsigned long *addr)
{
unsigned int old, t;
unsigned int mask = 1 << (nr & 0x1f);
......@@ -146,7 +146,7 @@ static __inline__ int test_and_set_bit(int nr, volatile void *addr)
/*
* non-atomic version
*/
static __inline__ int __test_and_set_bit(int nr, volatile void *addr)
static __inline__ int __test_and_set_bit(int nr, volatile unsigned long *addr)
{
unsigned long mask = 1 << (nr & 0x1f);
unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
......@@ -156,7 +156,7 @@ static __inline__ int __test_and_set_bit(int nr, volatile void *addr)
return (old & mask) != 0;
}
static __inline__ int test_and_clear_bit(int nr, volatile void *addr)
static __inline__ int test_and_clear_bit(int nr, volatile unsigned long *addr)
{
unsigned int old, t;
unsigned int mask = 1 << (nr & 0x1f);
......@@ -179,7 +179,7 @@ static __inline__ int test_and_clear_bit(int nr, volatile void *addr)
/*
* non-atomic version
*/
static __inline__ int __test_and_clear_bit(int nr, volatile void *addr)
static __inline__ int __test_and_clear_bit(int nr, volatile unsigned long *addr)
{
unsigned long mask = 1 << (nr & 0x1f);
unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
......@@ -189,7 +189,7 @@ static __inline__ int __test_and_clear_bit(int nr, volatile void *addr)
return (old & mask) != 0;
}
static __inline__ int test_and_change_bit(int nr, volatile void *addr)
static __inline__ int test_and_change_bit(int nr, volatile unsigned long *addr)
{
unsigned int old, t;
unsigned int mask = 1 << (nr & 0x1f);
......@@ -212,7 +212,7 @@ static __inline__ int test_and_change_bit(int nr, volatile void *addr)
/*
* non-atomic version
*/
static __inline__ int __test_and_change_bit(int nr, volatile void *addr)
static __inline__ int __test_and_change_bit(int nr, volatile unsigned long *addr)
{
unsigned long mask = 1 << (nr & 0x1f);
unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
......@@ -222,7 +222,7 @@ static __inline__ int __test_and_change_bit(int nr, volatile void *addr)
return (old & mask) != 0;
}
static __inline__ int test_bit(int nr, __const__ volatile void *addr)
static __inline__ int test_bit(int nr, __const__ volatile unsigned long *addr)
{
__const__ unsigned int *p = (__const__ unsigned int *) addr;
......@@ -230,7 +230,7 @@ static __inline__ int test_bit(int nr, __const__ volatile void *addr)
}
/* Return the bit position of the most significant 1 bit in a word */
static __inline__ int __ilog2(unsigned int x)
static __inline__ int __ilog2(unsigned long x)
{
int lz;
......@@ -238,7 +238,7 @@ static __inline__ int __ilog2(unsigned int x)
return 31 - lz;
}
static __inline__ int ffz(unsigned int x)
static __inline__ int ffz(unsigned long x)
{
if ((x = ~x) == 0)
return 32;
......@@ -296,7 +296,7 @@ static inline int sched_find_first_bit(unsigned long *b)
* @offset: The bitnumber to start searching at
* @size: The maximum size to search
*/
static __inline__ unsigned long find_next_bit(void *addr,
static __inline__ unsigned long find_next_bit(unsigned long *addr,
unsigned long size, unsigned long offset)
{
unsigned int *p = ((unsigned int *) addr) + (offset >> 5);
......@@ -353,7 +353,7 @@ static __inline__ unsigned long find_next_bit(void *addr,
#define find_first_zero_bit(addr, size) \
find_next_zero_bit((addr), (size), 0)
static __inline__ unsigned long find_next_zero_bit(void * addr,
static __inline__ unsigned long find_next_zero_bit(unsigned long * addr,
unsigned long size, unsigned long offset)
{
unsigned int * p = ((unsigned int *) addr) + (offset >> 5);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment