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

Annotation of sys/arch/m88k/include/lock.h, Revision 1.1

1.1     ! nbrk        1: #ifndef        _M88K_LOCK_H_
        !             2: #define        _M88K_LOCK_H_
        !             3: /*     $OpenBSD: lock.h,v 1.3 2007/05/19 16:58:43 miod Exp $   */
        !             4:
        !             5: /*
        !             6:  * Copyright (c) 2005, Miodrag Vallat.
        !             7:  *
        !             8:  * Redistribution and use in source and binary forms, with or without
        !             9:  * modification, are permitted provided that the following conditions
        !            10:  * are met:
        !            11:  * 1. Redistributions of source code must retain the above copyright
        !            12:  *    notice, this list of conditions and the following disclaimer.
        !            13:  * 2. Redistributions in binary form must reproduce the above copyright
        !            14:  *    notice, this list of conditions and the following disclaimer in the
        !            15:  *    documentation and/or other materials provided with the distribution.
        !            16:  *
        !            17:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            18:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        !            19:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        !            20:  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
        !            21:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
        !            22:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        !            23:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            24:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
        !            25:  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
        !            26:  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            27:  * POSSIBILITY OF SUCH DAMAGE.
        !            28:  */
        !            29:
        !            30: #include <m88k/asm.h>
        !            31:
        !            32: typedef volatile u_int __cpu_simple_lock_t;
        !            33:
        !            34: /* do not change these - code below assumes r0 == __SIMPLELOCK_UNLOCKED */
        !            35: #define        __SIMPLELOCK_LOCKED     1
        !            36: #define        __SIMPLELOCK_UNLOCKED   0
        !            37:
        !            38: static __inline__ void
        !            39: __cpu_simple_lock_init(__cpu_simple_lock_t *l)
        !            40: {
        !            41:        *l = __SIMPLELOCK_UNLOCKED;
        !            42: }
        !            43:
        !            44: static __inline__ void
        !            45: __cpu_simple_lock(__cpu_simple_lock_t *l)
        !            46: {
        !            47:        __cpu_simple_lock_t old;
        !            48:
        !            49:        do {
        !            50:                old = __SIMPLELOCK_LOCKED;
        !            51:                __asm__ __volatile__
        !            52:                    ("xmem %0, %1, r0" : "+r" (old) : "r" (l));
        !            53:        } while (old != __SIMPLELOCK_UNLOCKED);
        !            54: }
        !            55:
        !            56: static __inline__ int
        !            57: __cpu_simple_lock_try(__cpu_simple_lock_t *l)
        !            58: {
        !            59:        __cpu_simple_lock_t old = __SIMPLELOCK_LOCKED;
        !            60:
        !            61:        __asm__ __volatile__
        !            62:            ("xmem %0, %1, r0" : "+r" (old) : "r" (l));
        !            63:
        !            64:        return (old == __SIMPLELOCK_UNLOCKED);
        !            65: }
        !            66:
        !            67: static __inline__ void
        !            68: __cpu_simple_unlock(__cpu_simple_lock_t *l)
        !            69: {
        !            70:        *l = __SIMPLELOCK_UNLOCKED;
        !            71: }
        !            72:
        !            73: #endif /* _M88K_LOCK_H_ */

CVSweb