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

Annotation of sys/arch/mips64/include/lock.h, Revision 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        _MIPS64_LOCK_H_
        !             6: #define        _MIPS64_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, new;
        !            23:
        !            24:        do {
        !            25:                new = __SIMPLELOCK_LOCKED;
        !            26:                __asm__ __volatile__
        !            27:                   ("1:\tll\t%0, %1\n"
        !            28:                    "\tsc\t%2, %1\n"
        !            29:                    "\tbeqz\t%2, 1b\n"
        !            30:                    "\t nop" : "=r" (old) : "m" (*l), "r" (new));
        !            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, new = __SIMPLELOCK_LOCKED;
        !            38:
        !            39:        __asm__ __volatile__
        !            40:           ("1:\tll\t%0, %1\n"
        !            41:            "\tsc\t%2, %1\n"
        !            42:            "\tbeqz\t%2, 1b\n"
        !            43:            "\t nop" : "=r" (old) : "m" (*l), "r" (new));
        !            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 /* _MIPS64_LOCK_H_ */

CVSweb