]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/gnu/fs/xfs/FreeBSD/support/mrlock.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / gnu / fs / xfs / FreeBSD / support / mrlock.h
1 #ifndef __XFS_SUPPORT_MRLOCK_H__
2 #define __XFS_SUPPORT_MRLOCK_H__
3
4 #include <sys/types.h>
5 #include <sys/systm.h>
6 #include <sys/lock.h>
7 #include <sys/sx.h>
8
9 /*
10  * Implement mrlocks on FreeBSD that work for XFS.
11  * Map mrlock functions to corresponding equivalents in
12  * sx.
13  */
14 typedef struct sx mrlock_t;
15
16 #define MR_ACCESS       1
17 #define MR_UPDATE       2
18
19 /*
20  * Compatibility defines, not really used
21  */
22 #define MRLOCK_BARRIER          0x1
23 #define MRLOCK_ALLOW_EQUAL_PRI  0x8
24
25 #define mrlock_init(lock, type, name, seq) sx_init(lock, name)
26 #define mrtryaccess(lock)       sx_try_slock(lock)
27 #define mrtryupdate(lock)       sx_try_xlock(lock)
28 #define mraccess(lock)          sx_slock(lock)
29 #define mrupdate(lock)          sx_xlock(lock)
30 #define mrdemote(lock)          sx_downgrade(lock)
31 #define mrunlock(lock)          sx_unlock(lock)
32
33 #define mrfree(lock) do {               \
34         if (sx_xlocked(lock))           \
35                 sx_xunlock(lock);       \
36         sx_destroy(lock);               \
37 } while (0)
38
39 int ismrlocked(mrlock_t *mrp, int type);
40
41 #endif /* __XFS_SUPPORT_MRLOCK_H__ */