Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 24195
b: refs/heads/master
c: f51a05c
h: refs/heads/master
i:
  24193: e8be151
  24191: ab7fad1
v: v3
  • Loading branch information
Akinobu Mita authored and Linus Torvalds committed Mar 26, 2006
1 parent c4e71db commit a0cb124
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 64 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d4337aa5281a7357666f713339211fcd278f4e7a
refs/heads/master: f51a05c16d3d051f5e000c50bccc4be91fe5f9f3
76 changes: 13 additions & 63 deletions trunk/include/asm-generic/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,77 +5,27 @@
* For the benefit of those who are trying to port Linux to another
* architecture, here are some C-language equivalents. You should
* 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
*/

extern __inline__ int set_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 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)
#include <asm-generic/bitops/atomic.h>
#include <asm-generic/bitops/non-atomic.h>
#include <asm-generic/bitops/__ffs.h>
#include <asm-generic/bitops/ffz.h>
#include <asm-generic/bitops/fls.h>
#include <asm-generic/bitops/fls64.h>
#include <asm-generic/bitops/find.h>

#ifdef __KERNEL__

/*
* ffs: find first bit set. This is defined the same way as
* the libc and compiler builtin ffs routines, therefore
* 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
*/
#include <asm-generic/bitops/sched.h>
#include <asm-generic/bitops/ffs.h>
#include <asm-generic/bitops/hweight.h>

#define hweight32(x) generic_hweight32(x)
#define hweight16(x) generic_hweight16(x)
#define hweight8(x) generic_hweight8(x)
#include <asm-generic/bitops/ext2-non-atomic.h>
#include <asm-generic/bitops/ext2-atomic.h>
#include <asm-generic/bitops/minix.h>

#endif /* __KERNEL__ */

Expand Down

0 comments on commit a0cb124

Please sign in to comment.