This source file includes following definitions.
- set_bit
- clear_bit
- test_bit
1 #ifndef _SPARC_BITOPS_H
2 #define _SPARC_BITOPS_H
3
4
5
6
7
8
9
10
11
12
13
14
15 extern __inline__ unsigned int set_bit(unsigned int nr, void *addr)
16 {
17
18 __asm__ __volatile__(
19 "or %g0, %g0, %o2\n\t"
20 "or %g0, %g0, %o3\n\t"
21 "or %g0, %o0, %o4\n\t"
22 "srl %o4, 0x5, %o4\n\t"
23 "add %o1, %o4, %o1\n\t"
24 "or %g0, 0x1, %o5"
25 "or %g0, 0x1f, %o6"
26 "and %o6, %o5, %o6"
27 "sll %o5, %o6, %o2"
28 "ld [%o1], %o5\n\t"
29 "and %o5, %o2, %o0"
30 "or %o5, %o2, %o5"
31 "st %o5, [%o1]");
32
33 return nr;
34
35 }
36
37 extern __inline__ unsigned int clear_bit(unsigned int nr, void *addr)
38 {
39 __asm__ __volatile__(
40 "or %g0, %g0, %o2\n\t"
41 "or %g0, %g0, %o3\n\t"
42 "or %g0, %o0, %o4\n\t"
43 "srl %o4, 0x5, %o4\n\t"
44 "add %o1, %o4, %o1\n\t"
45 "or %g0, 0x1, %o5"
46 "or %g0, 0x1f, %o6"
47 "and %o6, %o5, %o6"
48 "sll %o5, %o6, %o2"
49 "ld [%o1], %o5\n\t"
50 "and %o5, %o2, %o0\n\t"
51 "xnor %g0, %o2, %o2\n\t"
52 "and %o5, %o2, %o5\n\t"
53 "st %o5, [%o1]\n\t");
54
55 return nr;
56
57 }
58
59 extern __inline__ unsigned int test_bit(int nr, int *addr)
60 {
61 __asm__ __volatile__(
62 "or %g0, %o0, %o3\n\t"
63 "srl %o3, 0x5, %o3\n\t"
64 "add %o1, %o3, %o1\n\t"
65 "and %o0, 0x1f, %o0\n\t"
66 "or %g0, 0x1, %o2\n\t"
67 "sll %o2, %o0, %o0"
68 "ld [%o1], %o2\n\t"
69 "and %o0, %o2, %o0\n\t");
70
71 return nr;
72
73 }
74
75 #endif