aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-generic/bitops/non-atomic.h
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2007-10-19 02:40:31 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-19 14:53:42 -0400
commitd05be13bcc6ec615fb2e9556a9b85d52800669b6 (patch)
treee75cee7b28e2a22d94f29fdd44746ea14f4fc6b8 /include/asm-generic/bitops/non-atomic.h
parent5159f40742508e03aed4273a9b3ef06f4e71929f (diff)
define first set of BIT* macros
define first set of BIT* macros - move BITOP_MASK and BITOP_WORD from asm-generic/bitops/atomic.h to include/linux/bitops.h and rename it to BIT_MASK and BIT_WORD - move BITS_TO_LONGS and BITS_PER_BYTE to bitops.h too and allow easily define another BITS_TO_something (e.g. in event.c) by BITS_TO_TYPE macro Remaining (and common) BIT macro will be defined after all occurences and conflicts will be sorted out in the patches. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-generic/bitops/non-atomic.h')
-rw-r--r--include/asm-generic/bitops/non-atomic.h29
1 files changed, 13 insertions, 16 deletions
diff --git a/include/asm-generic/bitops/non-atomic.h b/include/asm-generic/bitops/non-atomic.h
index 46a825cf2ae1..697cc2b7e0f0 100644
--- a/include/asm-generic/bitops/non-atomic.h
+++ b/include/asm-generic/bitops/non-atomic.h
@@ -3,9 +3,6 @@
3 3
4#include <asm/types.h> 4#include <asm/types.h>
5 5
6#define BITOP_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
7#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG)
8
9/** 6/**
10 * __set_bit - Set a bit in memory 7 * __set_bit - Set a bit in memory
11 * @nr: the bit to set 8 * @nr: the bit to set
@@ -17,16 +14,16 @@
17 */ 14 */
18static inline void __set_bit(int nr, volatile unsigned long *addr) 15static inline void __set_bit(int nr, volatile unsigned long *addr)
19{ 16{
20 unsigned long mask = BITOP_MASK(nr); 17 unsigned long mask = BIT_MASK(nr);
21 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); 18 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
22 19
23 *p |= mask; 20 *p |= mask;
24} 21}
25 22
26static inline void __clear_bit(int nr, volatile unsigned long *addr) 23static inline void __clear_bit(int nr, volatile unsigned long *addr)
27{ 24{
28 unsigned long mask = BITOP_MASK(nr); 25 unsigned long mask = BIT_MASK(nr);
29 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); 26 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
30 27
31 *p &= ~mask; 28 *p &= ~mask;
32} 29}
@@ -42,8 +39,8 @@ static inline void __clear_bit(int nr, volatile unsigned long *addr)
42 */ 39 */
43static inline void __change_bit(int nr, volatile unsigned long *addr) 40static inline void __change_bit(int nr, volatile unsigned long *addr)
44{ 41{
45 unsigned long mask = BITOP_MASK(nr); 42 unsigned long mask = BIT_MASK(nr);
46 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); 43 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
47 44
48 *p ^= mask; 45 *p ^= mask;
49} 46}
@@ -59,8 +56,8 @@ static inline void __change_bit(int nr, volatile unsigned long *addr)
59 */ 56 */
60static inline int __test_and_set_bit(int nr, volatile unsigned long *addr) 57static inline int __test_and_set_bit(int nr, volatile unsigned long *addr)
61{ 58{
62 unsigned long mask = BITOP_MASK(nr); 59 unsigned long mask = BIT_MASK(nr);
63 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); 60 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
64 unsigned long old = *p; 61 unsigned long old = *p;
65 62
66 *p = old | mask; 63 *p = old | mask;
@@ -78,8 +75,8 @@ static inline int __test_and_set_bit(int nr, volatile unsigned long *addr)
78 */ 75 */
79static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr) 76static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr)
80{ 77{
81 unsigned long mask = BITOP_MASK(nr); 78 unsigned long mask = BIT_MASK(nr);
82 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); 79 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
83 unsigned long old = *p; 80 unsigned long old = *p;
84 81
85 *p = old & ~mask; 82 *p = old & ~mask;
@@ -90,8 +87,8 @@ static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr)
90static inline int __test_and_change_bit(int nr, 87static inline int __test_and_change_bit(int nr,
91 volatile unsigned long *addr) 88 volatile unsigned long *addr)
92{ 89{
93 unsigned long mask = BITOP_MASK(nr); 90 unsigned long mask = BIT_MASK(nr);
94 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); 91 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
95 unsigned long old = *p; 92 unsigned long old = *p;
96 93
97 *p = old ^ mask; 94 *p = old ^ mask;
@@ -105,7 +102,7 @@ static inline int __test_and_change_bit(int nr,
105 */ 102 */
106static inline int test_bit(int nr, const volatile unsigned long *addr) 103static inline int test_bit(int nr, const volatile unsigned long *addr)
107{ 104{
108 return 1UL & (addr[BITOP_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); 105 return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
109} 106}
110 107
111#endif /* _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ */ 108#endif /* _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ */