This source file includes following definitions.
- __set_bit
- __clear_bit
- __change_bit
- __test_and_set_bit
- __test_and_clear_bit
- __test_and_change_bit
- test_bit
1
2 #ifndef _ASM_GENERIC_BITOPS_NON_ATOMIC_H_
3 #define _ASM_GENERIC_BITOPS_NON_ATOMIC_H_
4
5 #include <asm/types.h>
6
7
8
9
10
11
12
13
14
15
16 static inline void __set_bit(int nr, volatile unsigned long *addr)
17 {
18 unsigned long mask = BIT_MASK(nr);
19 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
20
21 *p |= mask;
22 }
23
24 static inline void __clear_bit(int nr, volatile unsigned long *addr)
25 {
26 unsigned long mask = BIT_MASK(nr);
27 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
28
29 *p &= ~mask;
30 }
31
32
33
34
35
36
37
38
39
40
41 static inline void __change_bit(int nr, volatile unsigned long *addr)
42 {
43 unsigned long mask = BIT_MASK(nr);
44 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
45
46 *p ^= mask;
47 }
48
49
50
51
52
53
54
55
56
57
58 static inline int __test_and_set_bit(int nr, volatile unsigned long *addr)
59 {
60 unsigned long mask = BIT_MASK(nr);
61 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
62 unsigned long old = *p;
63
64 *p = old | mask;
65 return (old & mask) != 0;
66 }
67
68
69
70
71
72
73
74
75
76
77 static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr)
78 {
79 unsigned long mask = BIT_MASK(nr);
80 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
81 unsigned long old = *p;
82
83 *p = old & ~mask;
84 return (old & mask) != 0;
85 }
86
87
88 static inline int __test_and_change_bit(int nr,
89 volatile unsigned long *addr)
90 {
91 unsigned long mask = BIT_MASK(nr);
92 unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
93 unsigned long old = *p;
94
95 *p = old ^ mask;
96 return (old & mask) != 0;
97 }
98
99
100
101
102
103
104 static inline int test_bit(int nr, const volatile unsigned long *addr)
105 {
106 return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
107 }
108
109 #endif