1 #ifndef __XFS_SUPPORT_SPIN_H__
2 #define __XFS_SUPPORT_SPIN_H__
3 
4 #include <sys/param.h>
5 #include <sys/types.h>
6 #include <sys/lock.h>
7 #include <sys/mutex.h>
8 
9 #define SPLDECL(s)	register_t s
10 
11 /*
12  * Map the spinlocks from IRIX to FreeBSD
13  */
14 #define spinlock_init(lock, name)	mtx_init(lock, name, NULL, MTX_DEF)
15 #define spinlock_destroy(lock)		mtx_destroy(lock)
16 
17 /*
18  * Map lock_t from IRIX to FreeBSD mutexes
19  */
20 typedef struct mtx lock_t;
21 
22 #define nested_spinunlock(lock)		mtx_unlock(lock)
23 #define nested_spinlock(lock)		mtx_lock(lock)
24 #define nested_spintrylock(lock)	mtx_trylock(lock)
25 
26 #define spin_lock(lock)			mtx_lock(lock)
27 #define spin_unlock(lock)		mtx_unlock(lock)
28 
29 #if LOCK_DEBUG > 0
30 #define mutex_spinlock(lock)		(spin_lock(lock),0)
31 #else
32 static __inline register_t
mutex_spinlock(lock_t * lock)33 mutex_spinlock(lock_t *lock)		{ mtx_lock(lock); return 0; }
34 #endif
35 
36 #define mutex_spinunlock(lock, s) \
37 	do { \
38 		spin_unlock(lock); \
39 		if (s != 0) {} \
40 	} while (0)
41 
42 #endif /* __XFS_SUPPORT_SPIN_H__ */
43