From de9d49a2b4c87b67a992da91b0860607f8d5e21b Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 12 Dec 2008 13:38:13 -0800 Subject: [PATCH] Minor mutex tweaks --- lib/libspl/include/thread.h | 13 ++++++++++--- lib/libzpool/include/sys/zfs_context.h | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/libspl/include/thread.h b/lib/libspl/include/thread.h index da7776abc1..5e8149611c 100644 --- a/lib/libspl/include/thread.h +++ b/lib/libspl/include/thread.h @@ -45,7 +45,7 @@ thr_create(void *stack_base, size_t stack_size, } static inline int -mutex_held(mutex_t *mp) +_mutex_held(mutex_t *mp) { int rc; @@ -56,15 +56,22 @@ mutex_held(mutex_t *mp) pthread_mutex_unlock(mp); return rc; } -#define MUTEX_HELD(mp) mutex_held(mp) -#define mutex_init(mp, type, arg) pthread_mutex_init(mp, NULL) +static inline void +_mutex_init(mutex_t *mp, int type, void *arg) +{ + pthread_mutex_init(mp, NULL); +} + + +#define mutex_init(mp, type, arg) _mutex_init(mp, type, arg) #define mutex_lock(mp) pthread_mutex_lock(mp) #define mutex_unlock(mp) pthread_mutex_unlock(mp) #define mutex_destroy(mp) pthread_mutex_destroy(mp) #define mutex_trylock(mp) pthread_mutex_trylock(mp) #define DEFAULTMUTEX PTHREAD_MUTEX_INITIALIZER #define DEFAULTCV PTHREAD_COND_INITIALIZER +#define MUTEX_HELD(mp) _mutex_held(mp) #define cond_init(c, type, arg) pthread_cond_init(c, NULL) #define cond_wait(c, m) pthread_cond_wait(c, m) diff --git a/lib/libzpool/include/sys/zfs_context.h b/lib/libzpool/include/sys/zfs_context.h index c27df1bc23..331c368908 100644 --- a/lib/libzpool/include/sys/zfs_context.h +++ b/lib/libzpool/include/sys/zfs_context.h @@ -213,7 +213,7 @@ typedef mutex_t kmutex_t; */ #ifdef mutex_init #undef mutex_init -#define mutex_init(mp, b, c, d) pthread_mutex_init(mp, NULL) +#define mutex_init(mp, name, type, args) _mutex_init(mp, type, args) #endif /*