This source file includes following definitions.
- simple_lock_init
- simple_lock_init
- simple_lock
- simple_lock_try
- simple_unlock
1
2
3 #ifndef _SIMPLELOCK_H_
4 #define _SIMPLELOCK_H_
5
6 #ifdef MULTIPROCESSOR
7 #include <machine/lock.h>
8 #endif
9
10
11
12
13
14
15
16
17
18
19 struct simplelock {
20 #ifdef MULTIPROCESSOR
21 __cpu_simple_lock_t lock_data;
22 #else
23 int lock_data;
24 #endif
25 };
26
27 #ifdef _KERNEL
28
29
30
31
32 #if defined(MULTIPROCESSOR) && defined(LOCKDEBUG)
33 #undef LOCKDEBUG
34 #endif
35
36 #if !defined(MULTIPROCESSOR) || 1
37
38 #define SLOCK_LOCKED 1
39 #define SLOCK_UNLOCKED 0
40
41 #ifndef LOCKDEBUG
42
43 #define simple_lock(lkp)
44 #define simple_lock_try(lkp) (1)
45 #define simple_unlock(lkp)
46 #define simple_lock_assert(lkp)
47
48 static __inline void simple_lock_init(struct simplelock *lkp)
49 {
50
51 lkp->lock_data = SLOCK_UNLOCKED;
52 }
53
54 #else
55
56 void _simple_unlock(__volatile struct simplelock *, const char *, int);
57 int _simple_lock_try(__volatile struct simplelock *, const char *, int);
58 void _simple_lock(__volatile struct simplelock *, const char *, int);
59 void _simple_lock_assert(__volatile struct simplelock *, int, const char *, int);
60
61 void simple_lock_init(struct simplelock *);
62 #define simple_unlock(lkp) _simple_unlock(lkp, __FILE__, __LINE__)
63 #define simple_lock_try(lkp) _simple_lock_try(lkp, __FILE__, __LINE__)
64 #define simple_lock(lkp) _simple_lock(lkp, __FILE__, __LINE__)
65 #define simple_lock_assert(lkp, state) _simple_lock_assert(lkp, state, __FILE__, __LINE__)
66
67 #endif
68
69 #else
70
71
72
73
74
75
76
77
78
79
80 static __inline void simple_lock_init(struct simplelock *lkp)
81 {
82 __cpu_simple_lock_init(&lkp->lock_data);
83 }
84
85 static __inline void simple_lock(__volatile struct simplelock *lkp)
86 {
87 __cpu_simple_lock(&lkp->lock_data);
88 }
89
90 static __inline int simple_lock_try(__volatile struct simplelock *lkp)
91 {
92 return (__cpu_simple_lock_try(&lkp->lock_data));
93 }
94
95 static __inline void simple_unlock(__volatile struct simplelock *lkp)
96 {
97 __cpu_simple_unlock(&lkp->lock_data);
98 }
99 #endif
100
101 #endif
102
103 #endif