This source file includes following definitions.
- set_bit
- change_bit
- clear_bit
- test_bit
1 #ifndef _ASM_PPC_BITOPS_H_
2 #define _ASM_PPC_BITOPS_H_
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include "asm/system.h"
20
21 #define BIT(n) 1<<(n&0x1F)
22 typedef unsigned long BITFIELD;
23
24 extern __inline__ int set_bit(int nr, void * add)
25
26 {
27 int mask, oldbit;
28 BITFIELD *addr = add;
29
30 int s = _disable_interrupts();
31 addr += nr >> 5;
32 mask = BIT(nr);
33 oldbit = (mask & *addr) != 0;
34 *addr |= mask;
35 _enable_interrupts(s);
36
37
38 return oldbit;
39 }
40
41
42
43 extern __inline__ int change_bit(int nr, void *add)
44 {
45 BITFIELD *addr = add;
46 int mask, retval;
47 int s = _disable_interrupts();
48 addr += nr >> 5;
49 mask = BIT(nr);
50 retval = (mask & *addr) != 0;
51 *addr ^= mask;
52 _enable_interrupts(s);
53 return retval;
54 }
55
56
57
58 extern __inline__ int clear_bit(int nr, void *add)
59 {
60 BITFIELD *addr = add;
61 int mask, retval;
62 int s = _disable_interrupts();
63 addr += nr >> 5;
64 mask = BIT(nr);
65 retval = (mask & *addr) != 0;
66 *addr &= ~mask;
67 _enable_interrupts(s);
68 return retval;
69 }
70
71 extern __inline__ int test_bit(int nr, void *add)
72
73 {
74 int mask;
75 BITFIELD *addr = add;
76
77 addr += nr >> 5;
78 mask = BIT(nr);
79 return ((mask & *addr) != 0);
80 }
81
82 #endif
83
84