This source file includes following definitions.
- test_and_set
- smp_initlock
- smp_lock
- smp_unlock
1
2
3
4
5
6
7
8
9
10 #ifndef __SPARC_SMPPRIM_H
11 #define __SPARC_SMPPRIM_H
12
13
14
15
16
17
18 extern inline volatile char test_and_set(void *addr)
19 {
20 char state = 0;
21
22 __asm__ __volatile__("ldstub [%0], %1 ! test_and_set\n\t"
23 "=r" (addr), "=r" (state) :
24 "0" (addr), "1" (state) : "memory");
25
26 return state;
27 }
28
29
30 extern inline volatile smp_initlock(void *spinlock)
31 {
32
33 *((unsigned char *) spinlock) = 0;
34
35 return;
36 }
37
38
39 extern inline volatile smp_lock(void *addr)
40 {
41 while(test_and_set(addr) == 0xff)
42 ;
43
44
45 return;
46 }
47
48
49 extern inline volatile smp_unlock(void *addr)
50 {
51 *((unsigned char *) addr) = 0;
52 }
53
54 #endif