]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/locks.h
xnu-3789.51.2.tar.gz
[apple/xnu.git] / osfmk / i386 / locks.h
index 47a808c3fdd4262ef85ab3f1162c334d4060bf9a..053de15779873d7857b744802721d40657756525 100644 (file)
@@ -143,7 +143,8 @@ typedef struct _lck_mtx_ext_ {
 #define        LCK_MTX_ATTR_STAT       0x2
 #define        LCK_MTX_ATTR_STATb      1
 
 #define        LCK_MTX_ATTR_STAT       0x2
 #define        LCK_MTX_ATTR_STATb      1
 
-#define LCK_MTX_EVENT(lck) ((event_t)(((unsigned int*)lck)+(sizeof(lck_mtx_t)-1)/sizeof(unsigned int)))
+#define LCK_MTX_EVENT(lck)        ((event_t)(((unsigned int*)(lck))+(sizeof(lck_mtx_t)-1)/sizeof(unsigned int)))
+#define LCK_EVENT_TO_MUTEX(event) ((lck_mtx_t *)(uintptr_t)(((unsigned int *)(event)) - ((sizeof(lck_mtx_t)-1)/sizeof(unsigned int))))
 
 #else /* MACH_KERNEL_PRIVATE */
 #ifdef XNU_KERNEL_PRIVATE
 
 #else /* MACH_KERNEL_PRIVATE */
 #ifdef XNU_KERNEL_PRIVATE
@@ -206,6 +207,11 @@ typedef struct _lck_rw_t_internal_ {
 
 #define        LCK_RW_TAG_DESTROYED            0x00002007      /* lock marked as Destroyed */
 
 
 #define        LCK_RW_TAG_DESTROYED            0x00002007      /* lock marked as Destroyed */
 
+#define RW_LOCK_READER_EVENT(x)   ((event_t) (((unsigned char*) (x)) + (offsetof(lck_rw_t, lck_rw_tag))))
+#define RW_LOCK_WRITER_EVENT(x)   ((event_t) (((unsigned char*) (x)) + (offsetof(lck_rw_t, lck_rw_pad8))))
+#define READ_EVENT_TO_RWLOCK(x)   ((lck_rw_t *)(((unsigned char*)(x) - (offsetof(lck_rw_t, lck_rw_tag)))))
+#define WRITE_EVENT_TO_RWLOCK(x)  ((lck_rw_t *)(((unsigned char*)(x) - (offsetof(lck_rw_t, lck_rw_pad8)))))
+
 #if LOCK_PRIVATE
 
 #define disable_preemption_for_thread(t) ((cpu_data_t GS_RELATIVE *)0UL)->cpu_preemption_level++
 #if LOCK_PRIVATE
 
 #define disable_preemption_for_thread(t) ((cpu_data_t GS_RELATIVE *)0UL)->cpu_preemption_level++