diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-03-22 19:26:29 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-03-22 19:26:29 +0000 |
commit | f9328a9d729c2c45cf9206acbd704286d906629e (patch) | |
tree | 2d3c92ac279f5e6884f2becbd6a8094b900be389 /sys/arch/powerpc/include | |
parent | 35dd6c7fe34fb7c7f20c55d57f526f32ac9d412f (diff) |
Move powerpc to __HAVE_MUTEX. With help from drahn@. Tested by nick@, xsa@,
deraadt@.
"reads right" deraadt@
Diffstat (limited to 'sys/arch/powerpc/include')
-rw-r--r-- | sys/arch/powerpc/include/_types.h | 3 | ||||
-rw-r--r-- | sys/arch/powerpc/include/mutex.h | 52 |
2 files changed, 54 insertions, 1 deletions
diff --git a/sys/arch/powerpc/include/_types.h b/sys/arch/powerpc/include/_types.h index d8cc81d4506..2704dabf203 100644 --- a/sys/arch/powerpc/include/_types.h +++ b/sys/arch/powerpc/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.3 2007/03/20 20:59:53 kettenis Exp $ */ +/* $OpenBSD: _types.h,v 1.4 2007/03/22 19:26:28 kettenis Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -117,5 +117,6 @@ typedef void * __wctype_t; /* Feature test macros */ #define __HAVE_CPUINFO +#define __HAVE_MUTEX #endif /* _POWERPC__TYPES_H_ */ diff --git a/sys/arch/powerpc/include/mutex.h b/sys/arch/powerpc/include/mutex.h new file mode 100644 index 00000000000..5c7b60e9764 --- /dev/null +++ b/sys/arch/powerpc/include/mutex.h @@ -0,0 +1,52 @@ +/* $OpenBSD: mutex.h,v 1.1 2007/03/22 19:26:28 kettenis Exp $ */ + +/* + * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _POWERPC_MUTEX_H_ +#define _POWERPC_MUTEX_H_ + +struct mutex { + int mtx_wantipl; + int mtx_oldcpl; + __volatile void *mtx_owner; +}; + +#define MUTEX_INITIALIZER(ipl) { (ipl), 0, NULL } + +#define MUTEX_ASSERT_LOCKED(mtx) do { \ + if ((mtx)->mtx_owner != curcpu()) \ + panic("mutex %p not held in %s", (mtx), __func__); \ +} while (0) + +#define MUTEX_ASSERT_UNLOCKED(mtx) do { \ + if ((mtx)->mtx_owner == curcpu()) \ + panic("mutex %p held in %s", (mtx), __func__); \ +} while (0) + +#if 0 +#define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl +#endif + +#endif |