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

Annotation of sys/arch/m88k/include/mutex.h, Revision 1.1.1.1

1.1       nbrk        1: #ifndef _M88K_MUTEX_H_
                      2: #define _M88K_MUTEX_H_
                      3: /*     $OpenBSD: mutex.h,v 1.1 2005/12/03 19:01:14 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: struct mutex {
                     31:        volatile int mtx_lock;  /* mutex.S relies upon this field being first */
                     32:        int mtx_wantipl;
                     33:        int mtx_oldipl;
                     34:        void *mtx_cpu;
                     35: };
                     36:
                     37: #define        MUTEX_INITIALIZER(ipl)          { 0, (ipl), IPL_NONE, NULL }
                     38:
                     39: #ifdef DIAGNOSTIC
                     40:
                     41: #define        MUTEX_ASSERT_LOCKED(mtx)                                        \
                     42: do {                                                                   \
                     43:        if ((mtx)->mtx_lock == 0 || (mtx)->mtx_cpu != curcpu())         \
                     44:                panic("mutex %p not held in %s", (mtx), __func__);      \
                     45: } while (0)
                     46:
                     47: #define        MUTEX_ASSERT_UNLOCKED(mtx)                                      \
                     48: do {                                                                   \
                     49:        if ((mtx)->mtx_lock != 0)                                       \
                     50:                panic("mutex %p held in %s", (mtx), __func__);          \
                     51: } while (0)
                     52:
                     53: #else
                     54:
                     55: #define        MUTEX_ASSERT_LOCKED(mtx)        do { /* nothing */ } while (0)
                     56: #define        MUTEX_ASSERT_UNLOCKED(mtx)      do { /* nothing */ } while (0)
                     57:
                     58: #endif
                     59:
                     60: #define MUTEX_OLDIPL(mtx)      (mtx)->mtx_oldipl
                     61:
                     62: #endif /* _M88K_MUTEX_H_ */

CVSweb