summaryrefslogtreecommitdiff
path: root/src/include/mutex.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/mutex.h')
-rw-r--r--src/include/mutex.h32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/include/mutex.h b/src/include/mutex.h
index 66591d97e65..3942452545e 100644
--- a/src/include/mutex.h
+++ b/src/include/mutex.h
@@ -165,21 +165,29 @@ struct __wt_rwlock {
#define WT_SPINLOCK volatile int
-#define WT_SPINLOCK_INIT(t) do { \
- *(t) = 0; \
-} while (0)
+static inline void
+__wt_spin_init(WT_SESSION_IMPL *session, WT_SPINLOCK *t)
+{
+ WT_UNUSED(session);
+
+ *(t) = 0;
+}
static inline void
-__wt_spin_lock(WT_SPINLOCK *t)
+__wt_spin_lock(WT_SESSION_IMPL *session, WT_SPINLOCK *t)
{
+ WT_UNUSED(session);
+
while (__sync_lock_test_and_set(t, 1))
while (*t)
WT_PAUSE();
}
static inline void
-__wt_spin_unlock(WT_SPINLOCK *t)
+__wt_spin_unlock(WT_SESSION_IMPL *session, WT_SPINLOCK *t)
{
+ WT_UNUSED(session);
+
__sync_lock_release(t);
}
@@ -187,19 +195,25 @@ __wt_spin_unlock(WT_SPINLOCK *t)
#define WT_SPINLOCK pthread_mutex_t
-#define WT_SPINLOCK_INIT(t) do { \
+static inline void
+__wt_spin_init(WT_SESSION_IMPL *session, WT_SPINLOCK *t)
+{
+ WT_UNUSED(session);
+
(void)pthread_mutex_init(t, NULL); \
-} while (0)
+}
static inline void
-__wt_spin_lock(WT_SPINLOCK *t)
+__wt_spin_lock(WT_SESSION_IMPL *session, WT_SPINLOCK *t)
{
+ WT_UNUSED(session);
pthread_mutex_lock(t);
}
static inline void
-__wt_spin_unlock(WT_SPINLOCK *t)
+__wt_spin_unlock(WT_SESSION_IMPL *session, WT_SPINLOCK *t)
{
+ WT_UNUSED(session);
pthread_mutex_unlock(t);
}