summaryrefslogtreecommitdiffstats
path: root/sys/gnu/fs/xfs/FreeBSD/support/spin.h
diff options
context:
space:
mode:
Diffstat (limited to 'sys/gnu/fs/xfs/FreeBSD/support/spin.h')
-rw-r--r--sys/gnu/fs/xfs/FreeBSD/support/spin.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/sys/gnu/fs/xfs/FreeBSD/support/spin.h b/sys/gnu/fs/xfs/FreeBSD/support/spin.h
new file mode 100644
index 0000000..2b09be4
--- /dev/null
+++ b/sys/gnu/fs/xfs/FreeBSD/support/spin.h
@@ -0,0 +1,42 @@
+#ifndef __XFS_SUPPORT_SPIN_H__
+#define __XFS_SUPPORT_SPIN_H__
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+
+#define SPLDECL(s) register_t s
+
+/*
+ * Map the spinlocks from IRIX to FreeBSD
+ */
+#define spinlock_init(lock, name) mtx_init(lock, name, NULL, MTX_DEF)
+#define spinlock_destroy(lock) mtx_destroy(lock)
+
+/*
+ * Map lock_t from IRIX to FreeBSD mutexes
+ */
+typedef struct mtx lock_t;
+
+#define nested_spinunlock(lock) mtx_unlock(lock)
+#define nested_spinlock(lock) mtx_lock(lock)
+#define nested_spintrylock(lock) mtx_trylock(lock)
+
+#define spin_lock(lock) mtx_lock(lock)
+#define spin_unlock(lock) mtx_unlock(lock)
+
+#if LOCK_DEBUG > 0
+#define mutex_spinlock(lock) (spin_lock(lock),0)
+#else
+static __inline register_t
+mutex_spinlock(lock_t *lock) { mtx_lock(lock); return 0; }
+#endif
+
+#define mutex_spinunlock(lock,s) \
+ do { \
+ spin_unlock(lock); \
+ if (&s) {} \
+ } while (0)
+
+#endif /* __XFS_SUPPORT_SPIN_H__ */
OpenPOWER on IntegriCloud