-#define LOCK_MAX_NAME 64
-#define mtx_init(mp, name, type, opts) do { \
- (mp)->mtx_grp = lck_grp_alloc_init(name, LCK_GRP_ATTR_NULL); \
- (mp)->mtx_lock = lck_mtx_alloc_init((mp)->mtx_grp, \
- LCK_ATTR_NULL); \
-} while(0)
-#define mtx_lock(mp) lck_mtx_lock((mp)->mtx_lock)
-#define mtx_unlock(mp) lck_mtx_unlock((mp)->mtx_lock)
-#define mtx_destroy(mp) do { \
- if ((mp)->mtx_lock) { \
- lck_mtx_free((mp)->mtx_lock, (mp)->mtx_grp); \
- (mp)->mtx_lock = 0; \
- } \
- if ((mp)->mtx_grp) { \
- lck_grp_free((mp)->mtx_grp); \
- (mp)->mtx_grp = 0; \
- } \
-} while (0)
+void _audit_mtx_init(struct mtx *mp, const char *name);
+void _audit_mtx_destroy(struct mtx *mp);
+#define mtx_init(mp, name, type, opts) \
+ _audit_mtx_init(mp, name)
+#define mtx_lock(mp) lck_mtx_lock((mp)->mtx_lock)
+#define mtx_unlock(mp) lck_mtx_unlock((mp)->mtx_lock)
+#define mtx_destroy(mp) _audit_mtx_destroy(mp)
+#define mtx_yield(mp) lck_mtx_yield((mp)->mtx_lock)