summaryrefslogtreecommitdiff
path: root/sys/arch/hppa
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2017-04-20 13:57:31 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2017-04-20 13:57:31 +0000
commitda85a125dd7fd9af53b0919887129daaf4fa53bb (patch)
treea8a5d35dfd86d6f624f47c01ea1bd6c6ac4b32b6 /sys/arch/hppa
parent4718dfdd3c76a956f1a6022f2dbb3c240b27f3e2 (diff)
Hook up mutex(9) to witness(4).
Diffstat (limited to 'sys/arch/hppa')
-rw-r--r--sys/arch/hppa/hppa/mutex.c16
-rw-r--r--sys/arch/hppa/include/mutex.h26
2 files changed, 28 insertions, 14 deletions
diff --git a/sys/arch/hppa/hppa/mutex.c b/sys/arch/hppa/hppa/mutex.c
index 160337c1aa7..9da3224674d 100644
--- a/sys/arch/hppa/hppa/mutex.c
+++ b/sys/arch/hppa/hppa/mutex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mutex.c,v 1.15 2015/09/20 19:19:03 kettenis Exp $ */
+/* $OpenBSD: mutex.c,v 1.16 2017/04/20 13:57:29 visa Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -57,14 +57,14 @@ __mtx_init(struct mutex *mtx, int wantipl)
#ifdef MULTIPROCESSOR
void
-mtx_enter(struct mutex *mtx)
+__mtx_enter(struct mutex *mtx)
{
- while (mtx_enter_try(mtx) == 0)
+ while (__mtx_enter_try(mtx) == 0)
;
}
int
-mtx_enter_try(struct mutex *mtx)
+__mtx_enter_try(struct mutex *mtx)
{
struct cpu_info *ci = curcpu();
volatile int *lock = __mtx_lock(mtx);
@@ -104,7 +104,7 @@ mtx_enter_try(struct mutex *mtx)
}
#else
void
-mtx_enter(struct mutex *mtx)
+__mtx_enter(struct mutex *mtx)
{
struct cpu_info *ci = curcpu();
@@ -124,15 +124,15 @@ mtx_enter(struct mutex *mtx)
}
int
-mtx_enter_try(struct mutex *mtx)
+__mtx_enter_try(struct mutex *mtx)
{
- mtx_enter(mtx);
+ __mtx_enter(mtx);
return (1);
}
#endif
void
-mtx_leave(struct mutex *mtx)
+__mtx_leave(struct mutex *mtx)
{
#ifdef MULTIPROCESSOR
volatile int *lock = __mtx_lock(mtx);
diff --git a/sys/arch/hppa/include/mutex.h b/sys/arch/hppa/include/mutex.h
index 36be0577813..48eacedd33e 100644
--- a/sys/arch/hppa/include/mutex.h
+++ b/sys/arch/hppa/include/mutex.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mutex.h,v 1.6 2015/05/02 10:59:47 dlg Exp $ */
+/* $OpenBSD: mutex.h,v 1.7 2017/04/20 13:57:29 visa Exp $ */
/*
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
@@ -28,6 +28,8 @@
#ifndef _MACHINE_MUTEX_H_
#define _MACHINE_MUTEX_H_
+#include <sys/_lock.h>
+
#define MUTEX_UNLOCKED { 1, 1, 1, 1 }
/* Note: mtx_lock must be 16-byte aligned. */
@@ -38,6 +40,9 @@ struct mutex {
int mtx_wantipl;
int mtx_oldipl;
void *mtx_owner;
+#ifdef WITNESS
+ struct lock_object mtx_lock_obj;
+#endif
};
/*
@@ -50,14 +55,22 @@ struct mutex {
#ifdef MULTIPROCESSOR
#define __MUTEX_IPL(ipl) \
(((ipl) > IPL_NONE && (ipl) < IPL_AUDIO) ? IPL_AUDIO : (ipl))
-#define MUTEX_INITIALIZER(ipl) { MUTEX_UNLOCKED, __MUTEX_IPL((ipl)), 0, NULL }
-#else
+#ifdef WITNESS
+#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \
+ { MUTEX_UNLOCKED, __MUTEX_IPL((ipl)), 0, NULL, \
+ MTX_LO_INITIALIZER(name, flags) }
+#else /* WITNESS */
+#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \
+ { MUTEX_UNLOCKED, __MUTEX_IPL((ipl)), 0, NULL }
+#endif /* WITNESS */
+#else /* MULTIPROCESSOR */
#define __MUTEX_IPL(ipl) (ipl)
-#define MUTEX_INITIALIZER(ipl) { __MUTEX_IPL((ipl)), 0, NULL }
-#endif
+#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \
+ { __MUTEX_IPL((ipl)), 0, NULL }
+#endif /* MULTIPROCESSOR */
void __mtx_init(struct mutex *, int);
-#define mtx_init(mtx, ipl) __mtx_init((mtx), __MUTEX_IPL((ipl)))
+#define _mtx_init(mtx, ipl) __mtx_init((mtx), __MUTEX_IPL((ipl)))
#ifdef DIAGNOSTIC
#define MUTEX_ASSERT_LOCKED(mtx) do { \
@@ -74,6 +87,7 @@ void __mtx_init(struct mutex *, int);
#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