Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bitops_32.h
Go to the documentation of this file.
1 /*
2  * bitops.h: Bit string operations on the Sparc.
3  *
4  * Copyright 1995 David S. Miller ([email protected])
5  * Copyright 1996 Eddie C. Dost ([email protected])
6  * Copyright 2001 Anton Blanchard ([email protected])
7  */
8 
9 #ifndef _SPARC_BITOPS_H
10 #define _SPARC_BITOPS_H
11 
12 #include <linux/compiler.h>
13 #include <asm/byteorder.h>
14 
15 #ifdef __KERNEL__
16 
17 #ifndef _LINUX_BITOPS_H
18 #error only <linux/bitops.h> can be included directly
19 #endif
20 
21 extern unsigned long ___set_bit(unsigned long *addr, unsigned long mask);
22 extern unsigned long ___clear_bit(unsigned long *addr, unsigned long mask);
23 extern unsigned long ___change_bit(unsigned long *addr, unsigned long mask);
24 
25 /*
26  * Set bit 'nr' in 32-bit quantity at address 'addr' where bit '0'
27  * is in the highest of the four bytes and bit '31' is the high bit
28  * within the first byte. Sparc is BIG-Endian. Unless noted otherwise
29  * all bit-ops return 0 if bit was previously clear and != 0 otherwise.
30  */
31 static inline int test_and_set_bit(unsigned long nr, volatile unsigned long *addr)
32 {
33  unsigned long *ADDR, mask;
34 
35  ADDR = ((unsigned long *) addr) + (nr >> 5);
36  mask = 1 << (nr & 31);
37 
38  return ___set_bit(ADDR, mask) != 0;
39 }
40 
41 static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
42 {
43  unsigned long *ADDR, mask;
44 
45  ADDR = ((unsigned long *) addr) + (nr >> 5);
46  mask = 1 << (nr & 31);
47 
48  (void) ___set_bit(ADDR, mask);
49 }
50 
51 static inline int test_and_clear_bit(unsigned long nr, volatile unsigned long *addr)
52 {
53  unsigned long *ADDR, mask;
54 
55  ADDR = ((unsigned long *) addr) + (nr >> 5);
56  mask = 1 << (nr & 31);
57 
58  return ___clear_bit(ADDR, mask) != 0;
59 }
60 
61 static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
62 {
63  unsigned long *ADDR, mask;
64 
65  ADDR = ((unsigned long *) addr) + (nr >> 5);
66  mask = 1 << (nr & 31);
67 
68  (void) ___clear_bit(ADDR, mask);
69 }
70 
71 static inline int test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
72 {
73  unsigned long *ADDR, mask;
74 
75  ADDR = ((unsigned long *) addr) + (nr >> 5);
76  mask = 1 << (nr & 31);
77 
78  return ___change_bit(ADDR, mask) != 0;
79 }
80 
81 static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
82 {
83  unsigned long *ADDR, mask;
84 
85  ADDR = ((unsigned long *) addr) + (nr >> 5);
86  mask = 1 << (nr & 31);
87 
88  (void) ___change_bit(ADDR, mask);
89 }
90 
92 
93 #define smp_mb__before_clear_bit() do { } while(0)
94 #define smp_mb__after_clear_bit() do { } while(0)
95 
96 #include <asm-generic/bitops/ffz.h>
99 #include <asm-generic/bitops/ffs.h>
100 #include <asm-generic/bitops/fls.h>
104 #include <asm-generic/bitops/lock.h>
105 #include <asm-generic/bitops/find.h>
106 #include <asm-generic/bitops/le.h>
108 
109 #endif /* __KERNEL__ */
110 
111 #endif /* defined(_SPARC_BITOPS_H) */