summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2018-01-12 09:19:34 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2018-01-12 09:19:34 +0000
commit232ebb0e4586a4e5926456b6f768b7907a45837a (patch)
tree78adbda9f7c4d8d7d7ff015292d9a85f598148dd /sys
parentf32909dcdc7cfe1cdf7bdb1974edbbd35ea2a126 (diff)
Unify <machine/mutex.h> a bit further.
`mtx_owner' becomes the first field of 'struct mutex' on i386/amd64/arm64. ok visa@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/include/mutex.h16
-rw-r--r--sys/arch/arm64/include/mutex.h16
-rw-r--r--sys/arch/i386/include/mutex.h16
-rw-r--r--sys/arch/mips64/include/mutex.h4
-rw-r--r--sys/arch/powerpc/include/mutex.h15
-rw-r--r--sys/arch/sparc64/include/mutex.h8
6 files changed, 47 insertions, 28 deletions
diff --git a/sys/arch/amd64/include/mutex.h b/sys/arch/amd64/include/mutex.h
index 69685e53443..bb4c9d39aa4 100644
--- a/sys/arch/amd64/include/mutex.h
+++ b/sys/arch/amd64/include/mutex.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mutex.h,v 1.8 2017/04/20 13:57:29 visa Exp $ */
+/* $OpenBSD: mutex.h,v 1.9 2018/01/12 09:19:32 mpi Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -24,15 +24,16 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#ifndef _MACHINE_MUTEX_H_
#define _MACHINE_MUTEX_H_
#include <sys/_lock.h>
struct mutex {
+ volatile void *mtx_owner;
int mtx_wantipl;
int mtx_oldipl;
- volatile void *mtx_owner;
#ifdef WITNESS
struct lock_object mtx_lock_obj;
#endif
@@ -54,15 +55,16 @@ struct mutex {
#ifdef WITNESS
#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \
- { __MUTEX_IPL((ipl)), 0, NULL, MTX_LO_INITIALIZER(name, flags) }
+ { NULL, __MUTEX_IPL((ipl)), IPL_NONE, MTX_LO_INITIALIZER(name, flags) }
#else
#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \
- { __MUTEX_IPL((ipl)), 0, NULL }
+ { NULL, __MUTEX_IPL((ipl)), IPL_NONE }
#endif
void __mtx_init(struct mutex *, int);
#define _mtx_init(mtx, ipl) __mtx_init((mtx), __MUTEX_IPL((ipl)))
+#ifdef DIAGNOSTIC
#define MUTEX_ASSERT_LOCKED(mtx) do { \
if ((mtx)->mtx_owner != curcpu()) \
panic("mutex %p not held in %s", (mtx), __func__); \
@@ -72,8 +74,12 @@ void __mtx_init(struct mutex *, int);
if ((mtx)->mtx_owner == curcpu()) \
panic("mutex %p held in %s", (mtx), __func__); \
} while (0)
+#else
+#define MUTEX_ASSERT_LOCKED(mtx) do { } while (0)
+#define MUTEX_ASSERT_UNLOCKED(mtx) do { } while (0)
+#endif
#define MUTEX_LOCK_OBJECT(mtx) (&(mtx)->mtx_lock_obj)
#define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl
-#endif
+#endif /* _MACHINE_MUTEX_H_ */
diff --git a/sys/arch/arm64/include/mutex.h b/sys/arch/arm64/include/mutex.h
index 5fec6284c91..c42ef1cf233 100644
--- a/sys/arch/arm64/include/mutex.h
+++ b/sys/arch/arm64/include/mutex.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mutex.h,v 1.2 2017/04/20 13:57:29 visa Exp $ */
+/* $OpenBSD: mutex.h,v 1.3 2018/01/12 09:19:33 mpi Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -24,15 +24,16 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#ifndef _MACHINE_MUTEX_H_
#define _MACHINE_MUTEX_H_
#include <sys/_lock.h>
struct mutex {
+ volatile void *mtx_owner;
int mtx_wantipl;
int mtx_oldipl;
- volatile void *mtx_owner;
#ifdef WITNESS
struct lock_object mtx_lock_obj;
#endif
@@ -54,15 +55,16 @@ struct mutex {
#ifdef WITNESS
#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \
- { __MUTEX_IPL((ipl)), 0, NULL, MTX_LO_INITIALIZER(name, flags) }
+ { NULL, __MUTEX_IPL((ipl)), IPL_NONE, MTX_LO_INITIALIZER(name, flags) }
#else
#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \
- { __MUTEX_IPL((ipl)), 0, NULL }
+ { NULL, __MUTEX_IPL((ipl)), IPL_NONE }
#endif
void __mtx_init(struct mutex *, int);
#define _mtx_init(mtx, ipl) __mtx_init((mtx), __MUTEX_IPL((ipl)))
+#ifdef DIAGNOSTIC
#define MUTEX_ASSERT_LOCKED(mtx) do { \
if ((mtx)->mtx_owner != curcpu()) \
panic("mutex %p not held in %s", (mtx), __func__); \
@@ -72,8 +74,12 @@ void __mtx_init(struct mutex *, int);
if ((mtx)->mtx_owner == curcpu()) \
panic("mutex %p held in %s", (mtx), __func__); \
} while (0)
+#else
+#define MUTEX_ASSERT_LOCKED(mtx) do { } while (0)
+#define MUTEX_ASSERT_UNLOCKED(mtx) do { } while (0)
+#endif
#define MUTEX_LOCK_OBJECT(mtx) (&(mtx)->mtx_lock_obj)
#define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl
-#endif
+#endif /* _MACHINE_MUTEX_H_ */
diff --git a/sys/arch/i386/include/mutex.h b/sys/arch/i386/include/mutex.h
index 0f2d542de04..96db30e8ad6 100644
--- a/sys/arch/i386/include/mutex.h
+++ b/sys/arch/i386/include/mutex.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mutex.h,v 1.10 2018/01/04 11:03:48 mpi Exp $ */
+/* $OpenBSD: mutex.h,v 1.11 2018/01/12 09:19:33 mpi Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -24,15 +24,16 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#ifndef _MACHINE_MUTEX_H_
#define _MACHINE_MUTEX_H_
#include <sys/_lock.h>
struct mutex {
+ volatile void *mtx_owner;
int mtx_wantipl;
int mtx_oldipl;
- volatile void *mtx_owner;
#ifdef WITNESS
struct lock_object mtx_lock_obj;
#endif
@@ -54,15 +55,16 @@ struct mutex {
#ifdef WITNESS
#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \
- { __MUTEX_IPL((ipl)), 0, NULL, MTX_LO_INITIALIZER(name, flags) }
+ { NULL, __MUTEX_IPL((ipl)), IPL_NONE, MTX_LO_INITIALIZER(name, flags) }
#else
#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \
- { __MUTEX_IPL((ipl)), 0, NULL }
+ { NULL, __MUTEX_IPL((ipl)), IPL_NONE }
#endif
void __mtx_init(struct mutex *, int);
#define _mtx_init(mtx, ipl) __mtx_init((mtx), __MUTEX_IPL((ipl)))
+#ifdef DIAGNOSTIC
#define MUTEX_ASSERT_LOCKED(mtx) do { \
if ((mtx)->mtx_owner != curcpu()) \
panic("mutex %p not held in %s", (mtx), __func__); \
@@ -72,8 +74,12 @@ void __mtx_init(struct mutex *, int);
if ((mtx)->mtx_owner == curcpu()) \
panic("mutex %p held in %s", (mtx), __func__); \
} while (0)
+#else
+#define MUTEX_ASSERT_LOCKED(mtx) do { } while (0)
+#define MUTEX_ASSERT_UNLOCKED(mtx) do { } while (0)
+#endif
#define MUTEX_LOCK_OBJECT(mtx) (&(mtx)->mtx_lock_obj)
#define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl
-#endif
+#endif /* _MACHINE_MUTEX_H_ */
diff --git a/sys/arch/mips64/include/mutex.h b/sys/arch/mips64/include/mutex.h
index 8ba5052d530..a77a60eadc3 100644
--- a/sys/arch/mips64/include/mutex.h
+++ b/sys/arch/mips64/include/mutex.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mutex.h,v 1.3 2018/01/04 11:03:48 mpi Exp $ */
+/* $OpenBSD: mutex.h,v 1.4 2018/01/12 09:19:33 mpi Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -82,4 +82,4 @@ void __mtx_init(struct mutex *, int);
#define MUTEX_LOCK_OBJECT(mtx) (&(mtx)->mtx_lock_obj)
#define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl
-#endif
+#endif /* _MACHINE_MUTEX_H_ */
diff --git a/sys/arch/powerpc/include/mutex.h b/sys/arch/powerpc/include/mutex.h
index 2826ebd6f08..07ea7601c82 100644
--- a/sys/arch/powerpc/include/mutex.h
+++ b/sys/arch/powerpc/include/mutex.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mutex.h,v 1.6 2017/04/20 13:57:30 visa Exp $ */
+/* $OpenBSD: mutex.h,v 1.7 2018/01/12 09:19:33 mpi Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -24,8 +24,9 @@
* 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_
+
+#ifndef _MACHINE_MUTEX_H_
+#define _MACHINE_MUTEX_H_
#include <sys/_lock.h>
@@ -54,10 +55,10 @@ struct mutex {
#ifdef WITNESS
#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \
- { NULL, __MUTEX_IPL(ipl), IPL_NONE, MTX_LO_INITIALIZER(name, flags) }
+ { NULL, __MUTEX_IPL((ipl)), IPL_NONE, MTX_LO_INITIALIZER(name, flags) }
#else
#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \
- { NULL, __MUTEX_IPL(ipl), IPL_NONE }
+ { NULL, __MUTEX_IPL((ipl)), IPL_NONE }
#endif
void __mtx_init(struct mutex *, int);
@@ -79,6 +80,6 @@ void __mtx_init(struct mutex *, int);
#endif
#define MUTEX_LOCK_OBJECT(mtx) (&(mtx)->mtx_lock_obj)
-#define MUTEX_OLDIPL(mtx) ((mtx)->mtx_oldipl)
+#define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl
-#endif
+#endif /* _MACHINE_MUTEX_H_ */
diff --git a/sys/arch/sparc64/include/mutex.h b/sys/arch/sparc64/include/mutex.h
index c022930143f..bfa1c698af0 100644
--- a/sys/arch/sparc64/include/mutex.h
+++ b/sys/arch/sparc64/include/mutex.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mutex.h,v 1.5 2017/04/20 13:57:30 visa Exp $ */
+/* $OpenBSD: mutex.h,v 1.6 2018/01/12 09:19:33 mpi Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -55,10 +55,10 @@ struct mutex {
#ifdef WITNESS
#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \
- { NULL, __MUTEX_IPL((ipl)), 0, MTX_LO_INITIALIZER(name, flags) }
+ { NULL, __MUTEX_IPL((ipl)), IPL_NONE, MTX_LO_INITIALIZER(name, flags) }
#else
#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \
- { NULL, __MUTEX_IPL((ipl)), 0 }
+ { NULL, __MUTEX_IPL((ipl)), IPL_NONE }
#endif
void __mtx_init(struct mutex *, int);
@@ -82,4 +82,4 @@ void __mtx_init(struct mutex *, int);
#define MUTEX_LOCK_OBJECT(mtx) (&(mtx)->mtx_lock_obj)
#define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl
-#endif
+#endif /* _MACHINE_MUTEX_H_ */