8 #include <linux/module.h>
9 #include <linux/hardirq.h>
10 #include <sys/types.h>
15 #define MUTEX_DEFAULT 0
17 #define MUTEX_ADAPTIVE 2
19 #define MUTEX_ENTER_TOTAL 0
20 #define MUTEX_ENTER_NOT_HELD 1
21 #define MUTEX_ENTER_SPIN 2
22 #define MUTEX_ENTER_SLEEP 3
23 #define MUTEX_TRYENTER_TOTAL 4
24 #define MUTEX_TRYENTER_NOT_HELD 5
25 #define MUTEX_STATS_SIZE 6
27 #define KM_MAGIC 0x42424242
28 #define KM_POISON 0x84
35 struct task_struct
*km_owner
;
36 struct semaphore
*km_sem
;
39 struct list_head km_list
;
43 extern int mutex_spin_max
;
46 extern int mutex_stats
[MUTEX_STATS_SIZE
];
47 extern spinlock_t mutex_stats_lock
;
48 extern struct list_head mutex_stats_list
;
49 #define MUTEX_STAT_INC(stats, stat) ((stats)[stat]++)
51 #define MUTEX_STAT_INC(stats, stat)
54 int spl_mutex_init(void);
55 void spl_mutex_fini(void);
57 extern void __spl_mutex_init(kmutex_t
*mp
, char *name
, int type
, void *ibc
);
58 extern void __spl_mutex_destroy(kmutex_t
*mp
);
59 extern int __mutex_tryenter(kmutex_t
*mp
);
60 extern void __mutex_enter(kmutex_t
*mp
);
61 extern void __mutex_exit(kmutex_t
*mp
);
62 extern int __mutex_owned(kmutex_t
*mp
);
63 extern kthread_t
*__spl_mutex_owner(kmutex_t
*mp
);
68 #define mutex_init(mp, name, type, ibc) \
71 __spl_mutex_init(mp, #mp, type, ibc); \
73 __spl_mutex_init(mp, name, type, ibc); \
75 #define mutex_destroy(mp) __spl_mutex_destroy(mp)
76 #define mutex_tryenter(mp) __mutex_tryenter(mp)
77 #define mutex_enter(mp) __mutex_enter(mp)
78 #define mutex_exit(mp) __mutex_exit(mp)
79 #define mutex_owned(mp) __mutex_owned(mp)
80 #define mutex_owner(mp) __spl_mutex_owner(mp)
81 #define MUTEX_HELD(mp) mutex_owned(mp)
87 #endif /* _SPL_MUTEX_H */