]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/locks.h
xnu-4570.51.1.tar.gz
[apple/xnu.git] / osfmk / i386 / locks.h
index 053de15779873d7857b744802721d40657756525..3d337a1c8c0a784df73add40d9c49ae92f645d7b 100644 (file)
@@ -37,6 +37,9 @@
 #include <i386/hw_lock_types.h>
 
 extern unsigned int    LcksOpts;
+#if DEVELOPMENT || DEBUG
+extern  unsigned int   LckDisablePreemptCheck;
+#endif
 
 #define enaLkDeb               0x00000001      /* Request debug in default attribute */
 #define enaLkStat              0x00000002      /* Request statistic in default attribute */
@@ -174,26 +177,52 @@ typedef struct __lck_mtx_ext_t__  lck_mtx_ext_t;
 
 #ifdef MACH_KERNEL_PRIVATE
 #pragma pack(1)                /* Make sure the structure stays as we defined it */
-typedef struct _lck_rw_t_internal_ {
-       volatile uint16_t       lck_rw_shared_count;    /* No. of accepted readers */
-       volatile uint8_t        lck_rw_interlock;       /* Interlock byte */
-       volatile uint8_t
-                               lck_rw_priv_excl:1,     /* Writers prioritized if set */
-                               lck_rw_want_upgrade:1,  /* Read-to-write upgrade waiting */
-                               lck_rw_want_write:1,    /* Writer waiting or locked for write */
-                               lck_r_waiting:1,        /* Reader is sleeping on lock */
-                               lck_w_waiting:1,        /* Writer is sleeping on lock */
-                               lck_rw_can_sleep:1,     /* Can attempts to lock go to sleep? */
-                               lck_rw_padb6:2;                 /* padding */
-
-       uint32_t                lck_rw_tag; /* This can be obsoleted when stats
-                                            * are in
-                                            */
-       uint32_t                lck_rw_pad8;
-       uint32_t                lck_rw_pad12;
+typedef union _lck_rw_t_internal_ {
+       struct {
+               volatile uint16_t       lck_rw_shared_count;    /* No. of accepted readers */
+               volatile uint8_t        lck_rw_interlock;       /* Interlock byte */
+               volatile uint8_t
+                                       lck_rw_priv_excl:1,     /* Writers prioritized if set */
+                                       lck_rw_want_upgrade:1,  /* Read-to-write upgrade waiting */
+                                       lck_rw_want_write:1,    /* Writer waiting or locked for write */
+                                       lck_r_waiting:1,        /* Reader is sleeping on lock */
+                                       lck_w_waiting:1,        /* Writer is sleeping on lock */
+                                       lck_rw_can_sleep:1,     /* Can attempts to lock go to sleep? */
+                                       lck_rw_padb6:2;         /* padding */
+               uint32_t                lck_rw_tag;             /* This can be obsoleted when stats are in */
+               thread_t                lck_rw_owner;           /* Unused */
+       };
+       struct {
+               uint32_t                data;                   /* Single word for count, ilk, and bitfields */
+               uint32_t                lck_rw_pad4;
+               uint32_t                lck_rw_pad8;
+               uint32_t                lck_rw_pad12;
+       };
 } lck_rw_t;
 #pragma pack()
 
+#define LCK_RW_SHARED_SHIFT     0
+#define LCK_RW_INTERLOCK_BIT   16
+#define LCK_RW_PRIV_EXCL_BIT   24
+#define LCK_RW_WANT_UPGRADE_BIT        25
+#define LCK_RW_WANT_EXCL_BIT   26
+#define LCK_RW_R_WAITING_BIT   27
+#define LCK_RW_W_WAITING_BIT   28
+#define LCK_RW_CAN_SLEEP_BIT   29
+
+#define LCK_RW_INTERLOCK       (1 << LCK_RW_INTERLOCK_BIT)
+#define LCK_RW_WANT_UPGRADE    (1 << LCK_RW_WANT_UPGRADE_BIT)
+#define LCK_RW_WANT_EXCL       (1 << LCK_RW_WANT_EXCL_BIT)
+#define LCK_RW_R_WAITING       (1 << LCK_RW_R_WAITING_BIT)
+#define LCK_RW_W_WAITING       (1 << LCK_RW_W_WAITING_BIT)
+#define LCK_RW_PRIV_EXCL       (1 << LCK_RW_PRIV_EXCL_BIT)
+#define LCK_RW_TAG_VALID       (1 << LCK_RW_TAG_VALID_BIT)
+#define LCK_RW_SHARED_MASK     (0xffff << LCK_RW_SHARED_SHIFT)
+#define LCK_RW_SHARED_READER   (1 << LCK_RW_SHARED_SHIFT)
+
+#define LCK_RW_WANT_WRITE      LCK_RW_WANT_EXCL
+
+
 #define        LCK_RW_ATTR_DEBUG       0x1
 #define        LCK_RW_ATTR_DEBUGb      0
 #define        LCK_RW_ATTR_STAT        0x2