-/* $OpenBSD: kern_fork.c,v 1.172 2014/07/12 18:43:32 tedu Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.173 2014/07/13 15:46:21 uebayasi Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
__mp_unlock(&sched_lock);
spl0();
SCHED_ASSERT_UNLOCKED();
- KASSERT(__mp_lock_held(&kernel_lock) == 0);
+ KERNEL_ASSERT_UNLOCKED();
KERNEL_LOCK();
}
-/* $OpenBSD: kern_ktrace.c,v 1.68 2014/07/13 15:00:40 tedu Exp $ */
+/* $OpenBSD: kern_ktrace.c,v 1.69 2014/07/13 15:46:21 uebayasi Exp $ */
/* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */
/*
void *buf;
size_t buflen;
-#ifdef MULTIPROCESSOR
- KASSERT(__mp_lock_held(&kernel_lock) > 0);
-#endif
+ KERNEL_ASSERT_LOCKED();
atomic_setbits_int(&p->p_flag, P_INKTR);
ktrinitheader(&kth, p, KTR_STRUCT);
-/* $OpenBSD: kern_lock.c,v 1.44 2014/07/09 13:32:00 guenther Exp $ */
+/* $OpenBSD: kern_lock.c,v 1.45 2014/07/13 15:46:21 uebayasi Exp $ */
/*
* Copyright (c) 1995
{
__mp_unlock(&kernel_lock);
}
+
+int
+_kernel_lock_held(void)
+{
+ return (__mp_lock_held(&kernel_lock));
+}
#endif /* MULTIPROCESSOR */
-/* $OpenBSD: kern_sig.c,v 1.171 2014/07/12 21:21:19 matthew Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.172 2014/07/13 15:46:21 uebayasi Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
struct proc *q;
int error;
-#ifdef MULTIPROCESSOR
- KASSERT(__mp_lock_held(&kernel_lock));
-#endif
+ KERNEL_ASSERT_LOCKED();
if ((error = single_thread_check(p, deep)))
return error;
struct proc *q;
KASSERT(pr->ps_single == p);
-#ifdef MULTIPROCESSOR
- KASSERT(__mp_lock_held(&kernel_lock));
-#endif
+ KERNEL_ASSERT_LOCKED();
pr->ps_single = NULL;
atomic_clearbits_int(&pr->ps_flags, PS_SINGLEUNWIND | PS_SINGLEEXIT);
-/* $OpenBSD: systm.h,v 1.100 2013/06/11 18:15:54 deraadt Exp $ */
+/* $OpenBSD: systm.h,v 1.101 2014/07/13 15:46:21 uebayasi Exp $ */
/* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */
/*-
void _kernel_lock_init(void);
void _kernel_lock(void);
void _kernel_unlock(void);
+int _kernel_lock_held(void);
#define KERNEL_LOCK_INIT() _kernel_lock_init()
#define KERNEL_LOCK() _kernel_lock()
#define KERNEL_UNLOCK() _kernel_unlock()
+#define KERNEL_ASSERT_LOCKED() KASSERT(_kernel_lock_held())
+#define KERNEL_ASSERT_UNLOCKED() KASSERT(!_kernel_lock_held())
#else /* ! MULTIPROCESSOR */
#define KERNEL_LOCK_INIT() /* nothing */
#define KERNEL_LOCK() /* nothing */
#define KERNEL_UNLOCK() /* nothing */
+#define KERNEL_ASSERT_LOCKED() /* nothing */
+#define KERNEL_ASSERT_UNLOCKED() /* nothing */
#endif /* MULTIPROCESSOR */