[BACK]Return to lock.h CVS log [TXT][DIR] Up to [local] / sys / arch / m68k / include

Annotation of sys/arch/m68k/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        _M68K_LOCK_H_
                      6: #define        _M68K_LOCK_H_
                      7:
                      8: typedef volatile u_int __cpu_simple_lock_t;
                      9:
                     10: #define        __SIMPLELOCK_LOCKED     1
                     11: #define        __SIMPLELOCK_UNLOCKED   0
                     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:                    ("casl %0, %2, %1" : "+d" (old), "=m" (*l) : "d" (*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:            ("casl %0, %2, %1" : "+d" (old), "=m" (*l) : "d" (*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 /* _M68K_LOCK_H_ */

CVSweb