Commit f51a05c1 authored by Akinobu Mita's avatar Akinobu Mita Committed by Linus Torvalds

[PATCH] bitops: update include/asm-generic/bitops.h

Currently include/asm-generic/bitops.h is not referenced from anywhere.  But
it will be the benefit of those who are trying to port Linux to another
architecture.

So update it by same manner
Signed-off-by: default avatarAkinobu Mita <mita@miraclelinux.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent d4337aa5
...@@ -5,77 +5,27 @@ ...@@ -5,77 +5,27 @@
* For the benefit of those who are trying to port Linux to another * For the benefit of those who are trying to port Linux to another
* architecture, here are some C-language equivalents. You should * architecture, here are some C-language equivalents. You should
* recode these in the native assembly language, if at all possible. * recode these in the native assembly language, if at all possible.
* To guarantee atomicity, these routines call cli() and sti() to
* disable interrupts while they operate. (You have to provide inline
* routines to cli() and sti().)
*
* Also note, these routines assume that you have 32 bit longs.
* You will have to change this if you are trying to port Linux to the
* Alpha architecture or to a Cray. :-)
* *
* C language equivalents written by Theodore Ts'o, 9/26/92 * C language equivalents written by Theodore Ts'o, 9/26/92
*/ */
extern __inline__ int set_bit(int nr,long * addr) #include <asm-generic/bitops/atomic.h>
{ #include <asm-generic/bitops/non-atomic.h>
int mask, retval; #include <asm-generic/bitops/__ffs.h>
#include <asm-generic/bitops/ffz.h>
addr += nr >> 5; #include <asm-generic/bitops/fls.h>
mask = 1 << (nr & 0x1f); #include <asm-generic/bitops/fls64.h>
cli(); #include <asm-generic/bitops/find.h>
retval = (mask & *addr) != 0;
*addr |= mask;
sti();
return retval;
}
extern __inline__ int clear_bit(int nr, long * addr)
{
int mask, retval;
addr += nr >> 5;
mask = 1 << (nr & 0x1f);
cli();
retval = (mask & *addr) != 0;
*addr &= ~mask;
sti();
return retval;
}
extern __inline__ int test_bit(int nr, const unsigned long * addr)
{
int mask;
addr += nr >> 5;
mask = 1 << (nr & 0x1f);
return ((mask & *addr) != 0);
}
/*
* fls: find last bit set.
*/
#define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)
#ifdef __KERNEL__ #ifdef __KERNEL__
/* #include <asm-generic/bitops/sched.h>
* ffs: find first bit set. This is defined the same way as #include <asm-generic/bitops/ffs.h>
* the libc and compiler builtin ffs routines, therefore #include <asm-generic/bitops/hweight.h>
* differs in spirit from the above ffz (man ffs).
*/
#define ffs(x) generic_ffs(x)
/*
* hweightN: returns the hamming weight (i.e. the number
* of bits set) of a N-bit word
*/
#define hweight32(x) generic_hweight32(x) #include <asm-generic/bitops/ext2-non-atomic.h>
#define hweight16(x) generic_hweight16(x) #include <asm-generic/bitops/ext2-atomic.h>
#define hweight8(x) generic_hweight8(x) #include <asm-generic/bitops/minix.h>
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
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