Annotation of sys/arch/hppa/include/lock.h, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: lock.h,v 1.1 2007/05/01 18:56:30 miod Exp $ */
2:
3: /* public domain */
4:
5: #ifndef _HPPA_LOCK_H_
6: #define _HPPA_LOCK_H_
7:
8: typedef volatile u_int __cpu_simple_lock_t __attribute__((__aligned__(16)));
9:
10: #define __SIMPLELOCK_LOCKED 0
11: #define __SIMPLELOCK_UNLOCKED 1
12:
13: static __inline__ void
14: __cpu_simple_lock_init(__cpu_simple_lock_t *l)
15: {
16: *l = __SIMPLELOCK_UNLOCKED;
17: }
18:
19: static __inline__ void
20: __cpu_simple_lock(__cpu_simple_lock_t *l)
21: {
22: __cpu_simple_lock_t old;
23:
24: do {
25: old = __SIMPLELOCK_LOCKED;
26: __asm__ __volatile__
27: ("ldcw %1, %0" : "=r" (old), "=m" (l) : "m" (l));
28: } while (old != __SIMPLELOCK_UNLOCKED);
29: }
30:
31: static __inline__ int
32: __cpu_simple_lock_try(__cpu_simple_lock_t *l)
33: {
34: __cpu_simple_lock_t old = __SIMPLELOCK_LOCKED;
35:
36: __asm__ __volatile__
37: ("ldcw %1, %0" : "=r" (old), "=m" (l) : "m" (l));
38:
39: return (old == __SIMPLELOCK_UNLOCKED);
40: }
41:
42: static __inline__ void
43: __cpu_simple_unlock(__cpu_simple_lock_t *l)
44: {
45: *l = __SIMPLELOCK_UNLOCKED;
46: }
47:
48: #endif /* _HPPA_LOCK_H_ */
CVSweb