]>
Commit | Line | Data |
---|---|---|
09b414e8 | 1 | #ifndef _SPL_CALLB_H |
2 | #define _SPL_CALLB_H | |
f1ca4da6 | 3 | |
4 | #ifdef __cplusplus | |
5 | extern "C" { | |
6 | #endif | |
7 | ||
f1b59d26 | 8 | #include <linux/module.h> |
f4b37741 | 9 | #include <sys/mutex.h> |
f1ca4da6 | 10 | |
11 | #define DEBUG_CALLB | |
12 | ||
13 | #ifndef DEBUG_CALLB | |
14 | #define CALLB_CPR_ASSERT(cp) BUG_ON(!(MUTEX_HELD((cp)->cc_lockp))); | |
15 | #else | |
16 | #define CALLB_CPR_ASSERT(cp) | |
17 | #endif | |
18 | ||
19 | ||
20 | typedef struct callb_cpr { | |
21 | kmutex_t *cc_lockp; | |
22 | } callb_cpr_t; | |
23 | ||
24 | #define CALLB_CPR_INIT(cp, lockp, func, name) { \ | |
25 | (cp)->cc_lockp = lockp; \ | |
26 | } | |
27 | ||
28 | #define CALLB_CPR_SAFE_BEGIN(cp) { \ | |
29 | CALLB_CPR_ASSERT(cp); \ | |
30 | } | |
31 | ||
32 | #define CALLB_CPR_SAFE_END(cp, lockp) { \ | |
33 | CALLB_CPR_ASSERT(cp); \ | |
34 | } | |
35 | ||
36 | #define CALLB_CPR_EXIT(cp) { \ | |
37 | ASSERT(MUTEX_HELD((cp)->cc_lockp)); \ | |
38 | mutex_exit((cp)->cc_lockp); \ | |
39 | } | |
40 | ||
41 | #ifdef __cplusplus | |
42 | } | |
43 | #endif | |
44 | ||
09b414e8 | 45 | #endif /* _SPL_CALLB_H */ |
f1ca4da6 | 46 |