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

Annotation of sys/arch/vax/include/lock.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: lock.h,v 1.1 2007/05/01 18:56:31 miod Exp $   */
                      2:
                      3: /* public domain */
                      4:
                      5: #ifndef        _VAX_LOCK_H_
                      6: #define        _VAX_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:                   ("\tmovl\t$1, %1\n"          /* _SPLINLOCK_LOCKED */
                     28:                    "\tbbssi\t$0, %0, 1f\n"
                     29:                    "\tmovl\t$0, %1\n"          /* _SPLINLOCK_UNLOCKED */
                     30:                    "1:\n" : "=m" (*l), "=r" (old) : "0" (*l));
                     31:        } while (old != __SIMPLELOCK_UNLOCKED);
                     32: }
                     33:
                     34: static __inline__ int
                     35: __cpu_simple_lock_try(__cpu_simple_lock_t *l)
                     36: {
                     37:        __cpu_simple_lock_t old = __SIMPLELOCK_LOCKED;
                     38:
                     39:        __asm__ __volatile__
                     40:           ("\tmovl\t$1, %1\n"          /* _SPLINLOCK_LOCKED */
                     41:            "\tbbssi\t$0, %0, 1f\n"
                     42:            "\tmovl\t$0, %1\n"          /* _SPLINLOCK_UNLOCKED */
                     43:            "1:\n" : "=m" (*l), "=r" (old) : "0" (*l));
                     44:
                     45:        return (old == __SIMPLELOCK_UNLOCKED);
                     46: }
                     47:
                     48: static __inline__ void
                     49: __cpu_simple_unlock(__cpu_simple_lock_t *l)
                     50: {
                     51:        *l = __SIMPLELOCK_UNLOCKED;
                     52: }
                     53:
                     54: #endif /* _VAX_LOCK_H_ */

CVSweb