- * void hw_lock_init(hw_lock_t)
- *
- * Initialize a hardware lock.
- */
-LEAF_ENTRY(hw_lock_init)
- LOAD_HW_LOCK_REGISTER /* fetch lock pointer */
- HW_LOCK_MOV_WORD $0, (HW_LOCK_REGISTER) /* clear the lock */
- LEAF_RET
-
-
-/*
- * void hw_lock_byte_init(uint8_t *)
- *
- * Initialize a hardware byte lock.
- */
-LEAF_ENTRY(hw_lock_byte_init)
- LOAD_HW_LOCK_REGISTER /* fetch lock pointer */
- movb $0, (HW_LOCK_REGISTER) /* clear the lock */
- LEAF_RET
-
-/*
- * void hw_lock_lock(hw_lock_t)
- *
- * Acquire lock, spinning until it becomes available.
- * MACH_RT: also return with preemption disabled.
- */
-LEAF_ENTRY(hw_lock_lock)
- LOAD_HW_LOCK_REGISTER /* fetch lock pointer */
- LOAD_HW_LOCK_THREAD_REGISTER /* get thread pointer */
-
- PREEMPTION_DISABLE
-1:
- mov (HW_LOCK_REGISTER), HW_LOCK_EXAM_REGISTER
- test HW_LOCK_EXAM_REGISTER,HW_LOCK_EXAM_REGISTER /* lock locked? */
- jne 3f /* branch if so */
- lock; cmpxchg HW_LOCK_THREAD_REGISTER,(HW_LOCK_REGISTER) /* try to acquire the HW lock */
- jne 3f
- movl $1,%eax /* In case this was a timeout call */
- LEAF_RET /* if yes, then nothing left to do */
-3:
- PAUSE /* pause for hyper-threading */
- jmp 1b /* try again */
-
-/*
- * void hw_lock_byte_lock(uint8_t *lock_byte)
- *
- * Acquire byte sized lock operand, spinning until it becomes available.
- * MACH_RT: also return with preemption disabled.
- */
-
-LEAF_ENTRY(hw_lock_byte_lock)
- LOAD_HW_LOCK_REGISTER /* Load lock pointer */
- PREEMPTION_DISABLE
- movl $1, %ecx /* Set lock value */
-1:
- movb (HW_LOCK_REGISTER), %al /* Load byte at address */
- testb %al,%al /* lock locked? */
- jne 3f /* branch if so */
- lock; cmpxchg %cl,(HW_LOCK_REGISTER) /* attempt atomic compare exchange */
- jne 3f
- LEAF_RET /* if yes, then nothing left to do */
-3:
- PAUSE /* pause for hyper-threading */
- jmp 1b /* try again */
-
-/*
- * unsigned int hw_lock_to(hw_lock_t, unsigned int)
- *
- * Acquire lock, spinning until it becomes available or timeout.
- * MACH_RT: also return with preemption disabled.
- */
-LEAF_ENTRY(hw_lock_to)
-1:
- LOAD_HW_LOCK_REGISTER /* fetch lock pointer */
- LOAD_HW_LOCK_THREAD_REGISTER
-
- /*
- * Attempt to grab the lock immediately
- * - fastpath without timeout nonsense.
- */
- PREEMPTION_DISABLE
-
- mov (HW_LOCK_REGISTER), HW_LOCK_EXAM_REGISTER
- test HW_LOCK_EXAM_REGISTER,HW_LOCK_EXAM_REGISTER /* lock locked? */
- jne 2f /* branch if so */
- lock; cmpxchg HW_LOCK_THREAD_REGISTER,(HW_LOCK_REGISTER) /* try to acquire the HW lock */
- jne 2f /* branch on failure */
- movl $1,%eax
- LEAF_RET
-
-2:
-#define INNER_LOOP_COUNT 1000
- /*
- * Failed to get the lock so set the timeout
- * and then spin re-checking the lock but pausing
- * every so many (INNER_LOOP_COUNT) spins to check for timeout.
- */
-#if __i386__
- movl L_ARG1,%ecx /* fetch timeout */
- push %edi
- push %ebx
- mov %edx,%edi
-
- lfence
- rdtsc /* read cyclecount into %edx:%eax */
- lfence
- addl %ecx,%eax /* fetch and timeout */
- adcl $0,%edx /* add carry */
- mov %edx,%ecx
- mov %eax,%ebx /* %ecx:%ebx is the timeout expiry */
- mov %edi, %edx /* load lock back into %edx */
-#else
- push %r9
- lfence
- rdtsc /* read cyclecount into %edx:%eax */
- lfence
- shlq $32, %rdx
- orq %rdx, %rax /* load 64-bit quantity into %rax */
- addq %rax, %rsi /* %rsi is the timeout expiry */
-#endif
-
-4:
- /*
- * The inner-loop spin to look for the lock being freed.
- */
-#if __i386__
- mov $(INNER_LOOP_COUNT),%edi
-#else
- mov $(INNER_LOOP_COUNT),%r9
-#endif
-5:
- PAUSE /* pause for hyper-threading */
- mov (HW_LOCK_REGISTER),HW_LOCK_EXAM_REGISTER /* spin checking lock value in cache */
- test HW_LOCK_EXAM_REGISTER,HW_LOCK_EXAM_REGISTER
- je 6f /* zero => unlocked, try to grab it */
-#if __i386__
- decl %edi /* decrement inner loop count */
-#else
- decq %r9 /* decrement inner loop count */
-#endif
- jnz 5b /* time to check for timeout? */
-
- /*
- * Here after spinning INNER_LOOP_COUNT times, check for timeout
- */
-#if __i386__
- mov %edx,%edi /* Save %edx */
- lfence
- rdtsc /* cyclecount into %edx:%eax */
- lfence
- xchg %edx,%edi /* cyclecount into %edi:%eax */
- cmpl %ecx,%edi /* compare high-order 32-bits */
- jb 4b /* continue spinning if less, or */
- cmpl %ebx,%eax /* compare low-order 32-bits */
- jb 4b /* continue if less, else bail */
- xor %eax,%eax /* with 0 return value */
- pop %ebx
- pop %edi
-#else
- lfence
- rdtsc /* cyclecount into %edx:%eax */
- lfence
- shlq $32, %rdx
- orq %rdx, %rax /* load 64-bit quantity into %rax */
- cmpq %rsi, %rax /* compare to timeout */
- jb 4b /* continue spinning if less, or */
- xor %rax,%rax /* with 0 return value */
- pop %r9
-#endif
- LEAF_RET
-
-6:
- /*
- * Here to try to grab the lock that now appears to be free
- * after contention.
- */
- LOAD_HW_LOCK_THREAD_REGISTER
- lock; cmpxchg HW_LOCK_THREAD_REGISTER,(HW_LOCK_REGISTER) /* try to acquire the HW lock */
- jne 4b /* no - spin again */
- movl $1,%eax /* yes */
-#if __i386__
- pop %ebx
- pop %edi
-#else
- pop %r9
-#endif
- LEAF_RET
-
-/*
- * void hw_lock_unlock(hw_lock_t)
- *
- * Unconditionally release lock.
- * MACH_RT: release preemption level.
- */
-LEAF_ENTRY(hw_lock_unlock)
- LOAD_HW_LOCK_REGISTER /* fetch lock pointer */
- HW_LOCK_MOV_WORD $0, (HW_LOCK_REGISTER) /* clear the lock */
- PREEMPTION_ENABLE
- LEAF_RET
-
-/*
- * void hw_lock_byte_unlock(uint8_t *lock_byte)
- *
- * Unconditionally release byte sized lock operand.
- * MACH_RT: release preemption level.
- */
-
-LEAF_ENTRY(hw_lock_byte_unlock)
- LOAD_HW_LOCK_REGISTER /* Load lock pointer */
- movb $0, (HW_LOCK_REGISTER) /* Clear the lock byte */
- PREEMPTION_ENABLE
- LEAF_RET
-
-/*
- * unsigned int hw_lock_try(hw_lock_t)
- * MACH_RT: returns with preemption disabled on success.
- */
-LEAF_ENTRY(hw_lock_try)
- LOAD_HW_LOCK_REGISTER /* fetch lock pointer */
- LOAD_HW_LOCK_THREAD_REGISTER
- PREEMPTION_DISABLE
-
- mov (HW_LOCK_REGISTER),HW_LOCK_EXAM_REGISTER
- test HW_LOCK_EXAM_REGISTER,HW_LOCK_EXAM_REGISTER
- jne 1f
- lock; cmpxchg HW_LOCK_THREAD_REGISTER,(HW_LOCK_REGISTER) /* try to acquire the HW lock */
- jne 1f
-
- movl $1,%eax /* success */
- LEAF_RET
-
-1:
- PREEMPTION_ENABLE /* failure: release preemption... */
- xorl %eax,%eax /* ...and return failure */
- LEAF_RET
-
-/*
- * unsigned int hw_lock_held(hw_lock_t)
- * MACH_RT: doesn't change preemption state.
- * N.B. Racy, of course.
- */
-LEAF_ENTRY(hw_lock_held)
- LOAD_HW_LOCK_REGISTER /* fetch lock pointer */
- mov (HW_LOCK_REGISTER),HW_LOCK_EXAM_REGISTER /* check lock value */
- test HW_LOCK_EXAM_REGISTER,HW_LOCK_EXAM_REGISTER
- movl $1,%ecx
- cmovne %ecx,%eax /* 0 => unlocked, 1 => locked */
- LEAF_RET
-
-
-/*
- * Reader-writer lock fastpaths. These currently exist for the
- * shared lock acquire, the exclusive lock acquire, the shared to
- * exclusive upgrade and the release paths (where they reduce overhead
- * considerably) -- these are by far the most frequently used routines
- *
- * The following should reflect the layout of the bitfield embedded within
- * the lck_rw_t structure (see i386/locks.h).
- */
-#define LCK_RW_INTERLOCK (0x1 << 16)
-
-#define LCK_RW_PRIV_EXCL (0x1 << 24)
-#define LCK_RW_WANT_UPGRADE (0x2 << 24)
-#define LCK_RW_WANT_WRITE (0x4 << 24)
-#define LCK_R_WAITING (0x8 << 24)
-#define LCK_W_WAITING (0x10 << 24)
-
-#define LCK_RW_SHARED_MASK (0xffff)
-
-/*
- * For most routines, the lck_rw_t pointer is loaded into a
- * register initially, and the flags bitfield loaded into another
- * register and examined
- */
-
-#if defined(__i386__)
-#define LCK_RW_REGISTER %edx
-#define LOAD_LCK_RW_REGISTER mov S_ARG0, LCK_RW_REGISTER
-#define LCK_RW_FLAGS_REGISTER %eax
-#define LOAD_LCK_RW_FLAGS_REGISTER mov (LCK_RW_REGISTER), LCK_RW_FLAGS_REGISTER
-#elif defined(__x86_64__)
-#define LCK_RW_REGISTER %rdi
-#define LOAD_LCK_RW_REGISTER
-#define LCK_RW_FLAGS_REGISTER %eax
-#define LOAD_LCK_RW_FLAGS_REGISTER mov (LCK_RW_REGISTER), LCK_RW_FLAGS_REGISTER
-#else
-#error Unsupported architecture
-#endif
-
-#define RW_LOCK_SHARED_MASK (LCK_RW_INTERLOCK | LCK_RW_WANT_UPGRADE | LCK_RW_WANT_WRITE)
-/*
- * void lck_rw_lock_shared(lck_rw_t *)
- *
- */
-Entry(lck_rw_lock_shared)
- LOAD_LCK_RW_REGISTER
-1:
- LOAD_LCK_RW_FLAGS_REGISTER /* Load state bitfield and interlock */
- testl $(RW_LOCK_SHARED_MASK), %eax /* Eligible for fastpath? */
- jne 3f
-
- movl %eax, %ecx /* original value in %eax for cmpxchgl */
- incl %ecx /* Increment reader refcount */
- lock
- cmpxchgl %ecx, (LCK_RW_REGISTER) /* Attempt atomic exchange */
- jne 2f
-
-#if CONFIG_DTRACE
- /*
- * Dtrace lockstat event: LS_LCK_RW_LOCK_SHARED_ACQUIRE
- * Implemented by swapping between return and no-op instructions.
- * See bsd/dev/dtrace/lockstat.c.
- */
- LOCKSTAT_LABEL(_lck_rw_lock_shared_lockstat_patch_point)
- ret
- /*
- Fall thru when patched, counting on lock pointer in LCK_RW_REGISTER
- */
- LOCKSTAT_RECORD(LS_LCK_RW_LOCK_SHARED_ACQUIRE, LCK_RW_REGISTER)
-#endif
- ret
-2:
- PAUSE
- jmp 1b
-3:
- jmp EXT(lck_rw_lock_shared_gen)
-
-
-
-#define RW_TRY_LOCK_SHARED_MASK (LCK_RW_WANT_UPGRADE | LCK_RW_WANT_WRITE)
-/*
- * void lck_rw_try_lock_shared(lck_rw_t *)
- *
- */
-Entry(lck_rw_try_lock_shared)
- LOAD_LCK_RW_REGISTER
-1:
- LOAD_LCK_RW_FLAGS_REGISTER /* Load state bitfield and interlock */
- testl $(LCK_RW_INTERLOCK), %eax
- jne 2f
- testl $(RW_TRY_LOCK_SHARED_MASK), %eax
- jne 3f /* lock is busy */
-
- movl %eax, %ecx /* original value in %eax for cmpxchgl */
- incl %ecx /* Increment reader refcount */
- lock
- cmpxchgl %ecx, (LCK_RW_REGISTER) /* Attempt atomic exchange */
- jne 2f
-
-#if CONFIG_DTRACE
- movl $1, %eax
- /*
- * Dtrace lockstat event: LS_LCK_RW_TRY_LOCK_SHARED_ACQUIRE
- * Implemented by swapping between return and no-op instructions.
- * See bsd/dev/dtrace/lockstat.c.
- */
- LOCKSTAT_LABEL(_lck_rw_try_lock_shared_lockstat_patch_point)
- ret
- /* Fall thru when patched, counting on lock pointer in LCK_RW_REGISTER */
- LOCKSTAT_RECORD(LS_LCK_RW_LOCK_SHARED_ACQUIRE, LCK_RW_REGISTER)
-#endif
- movl $1, %eax /* return TRUE */
- ret
-2:
- PAUSE
- jmp 1b
-3:
- xorl %eax, %eax
- ret
-
-
-#define RW_LOCK_EXCLUSIVE_HELD (LCK_RW_WANT_WRITE | LCK_RW_WANT_UPGRADE)
-/*
- * int lck_rw_grab_shared(lck_rw_t *)
- *
- */
-Entry(lck_rw_grab_shared)
- LOAD_LCK_RW_REGISTER
-1:
- LOAD_LCK_RW_FLAGS_REGISTER /* Load state bitfield and interlock */
- testl $(LCK_RW_INTERLOCK), %eax
- jne 5f
- testl $(RW_LOCK_EXCLUSIVE_HELD), %eax
- jne 3f
-2:
- movl %eax, %ecx /* original value in %eax for cmpxchgl */
- incl %ecx /* Increment reader refcount */
- lock
- cmpxchgl %ecx, (LCK_RW_REGISTER) /* Attempt atomic exchange */
- jne 4f
-
- movl $1, %eax /* return success */
- ret
-3:
- testl $(LCK_RW_SHARED_MASK), %eax
- je 4f
- testl $(LCK_RW_PRIV_EXCL), %eax
- je 2b
-4:
- xorl %eax, %eax /* return failure */
- ret
-5:
- PAUSE
- jmp 1b
-
-
-
-#define RW_LOCK_EXCLUSIVE_MASK (LCK_RW_SHARED_MASK | LCK_RW_INTERLOCK | \
- LCK_RW_WANT_UPGRADE | LCK_RW_WANT_WRITE)
-/*
- * void lck_rw_lock_exclusive(lck_rw_t*)
- *
- */
-Entry(lck_rw_lock_exclusive)
- LOAD_LCK_RW_REGISTER
-1:
- LOAD_LCK_RW_FLAGS_REGISTER /* Load state bitfield, interlock and shared count */
- testl $(RW_LOCK_EXCLUSIVE_MASK), %eax /* Eligible for fastpath? */
- jne 3f /* no, go slow */
-
- movl %eax, %ecx /* original value in %eax for cmpxchgl */
- orl $(LCK_RW_WANT_WRITE), %ecx
- lock
- cmpxchgl %ecx, (LCK_RW_REGISTER) /* Attempt atomic exchange */
- jne 2f
-
-#if CONFIG_DTRACE
- /*
- * Dtrace lockstat event: LS_LCK_RW_LOCK_EXCL_ACQUIRE
- * Implemented by swapping between return and no-op instructions.
- * See bsd/dev/dtrace/lockstat.c.
- */
- LOCKSTAT_LABEL(_lck_rw_lock_exclusive_lockstat_patch_point)
- ret
- /* Fall thru when patched, counting on lock pointer in LCK_RW_REGISTER */
- LOCKSTAT_RECORD(LS_LCK_RW_LOCK_SHARED_ACQUIRE, LCK_RW_REGISTER)
-#endif
- ret
-2:
- PAUSE
- jmp 1b
-3:
- jmp EXT(lck_rw_lock_exclusive_gen)
-
-
-
-#define RW_TRY_LOCK_EXCLUSIVE_MASK (LCK_RW_SHARED_MASK | LCK_RW_WANT_UPGRADE | LCK_RW_WANT_WRITE)
-/*
- * void lck_rw_try_lock_exclusive(lck_rw_t *)
- *
- * Tries to get a write lock.
- *
- * Returns FALSE if the lock is not held on return.
- */
-Entry(lck_rw_try_lock_exclusive)
- LOAD_LCK_RW_REGISTER
-1:
- LOAD_LCK_RW_FLAGS_REGISTER /* Load state bitfield, interlock and shared count */
- testl $(LCK_RW_INTERLOCK), %eax
- jne 2f
- testl $(RW_TRY_LOCK_EXCLUSIVE_MASK), %eax
- jne 3f /* can't get it */
-
- movl %eax, %ecx /* original value in %eax for cmpxchgl */
- orl $(LCK_RW_WANT_WRITE), %ecx
- lock
- cmpxchgl %ecx, (LCK_RW_REGISTER) /* Attempt atomic exchange */
- jne 2f
-
-#if CONFIG_DTRACE
- movl $1, %eax
- /*
- * Dtrace lockstat event: LS_LCK_RW_TRY_LOCK_EXCL_ACQUIRE
- * Implemented by swapping between return and no-op instructions.
- * See bsd/dev/dtrace/lockstat.c.
- */
- LOCKSTAT_LABEL(_lck_rw_try_lock_exclusive_lockstat_patch_point)
- ret
- /* Fall thru when patched, counting on lock pointer in LCK_RW_REGISTER */
- LOCKSTAT_RECORD(LS_LCK_RW_LOCK_SHARED_ACQUIRE, LCK_RW_REGISTER)
-#endif
- movl $1, %eax /* return TRUE */
- ret
-2:
- PAUSE
- jmp 1b
-3:
- xorl %eax, %eax /* return FALSE */
- ret
-
-
-
-/*
- * void lck_rw_lock_shared_to_exclusive(lck_rw_t*)
- *
- * fastpath can be taken if
- * the current rw_shared_count == 1
- * AND the interlock is clear
- * AND RW_WANT_UPGRADE is not set
- *
- * note that RW_WANT_WRITE could be set, but will not
- * be indicative of an exclusive hold since we have
- * a read count on the lock that we have not yet released
- * we can blow by that state since the lck_rw_lock_exclusive
- * function will block until rw_shared_count == 0 and
- * RW_WANT_UPGRADE is clear... it does this check behind
- * the interlock which we are also checking for
- *
- * to make the transition we must be able to atomically
- * set RW_WANT_UPGRADE and get rid of the read count we hold
- */
-Entry(lck_rw_lock_shared_to_exclusive)
- LOAD_LCK_RW_REGISTER
-1:
- LOAD_LCK_RW_FLAGS_REGISTER /* Load state bitfield, interlock and shared count */
- testl $(LCK_RW_INTERLOCK), %eax
- jne 7f
- testl $(LCK_RW_WANT_UPGRADE), %eax
- jne 2f
-
- movl %eax, %ecx /* original value in %eax for cmpxchgl */
- orl $(LCK_RW_WANT_UPGRADE), %ecx /* ask for WANT_UPGRADE */
- decl %ecx /* and shed our read count */
- lock
- cmpxchgl %ecx, (LCK_RW_REGISTER) /* Attempt atomic exchange */
- jne 7f
- /* we now own the WANT_UPGRADE */
- testl $(LCK_RW_SHARED_MASK), %ecx /* check to see if all of the readers are drained */
- jne 8f /* if not, we need to go wait */
-
-#if CONFIG_DTRACE
- movl $1, %eax
- /*
- * Dtrace lockstat event: LS_LCK_RW_LOCK_SHARED_TO_EXCL_UPGRADE
- * Implemented by swapping between return and no-op instructions.
- * See bsd/dev/dtrace/lockstat.c.
- */
- LOCKSTAT_LABEL(_lck_rw_lock_shared_to_exclusive_lockstat_patch_point)
- ret
- /* Fall thru when patched, counting on lock pointer in LCK_RW_REGISTER */
- LOCKSTAT_RECORD(LS_LCK_RW_LOCK_SHARED_ACQUIRE, LCK_RW_REGISTER)
-#endif
- movl $1, %eax /* return success */
- ret
-
-2: /* someone else already holds WANT_UPGRADE */
- movl %eax, %ecx /* original value in %eax for cmpxchgl */
- decl %ecx /* shed our read count */
- testl $(LCK_RW_SHARED_MASK), %ecx
- jne 3f /* we were the last reader */
- andl $(~LCK_W_WAITING), %ecx /* so clear the wait indicator */
-3:
- lock
- cmpxchgl %ecx, (LCK_RW_REGISTER) /* Attempt atomic exchange */
- jne 7f
-
-#if __i386__
- pushl %eax /* go check to see if we need to */
- push %edx /* wakeup anyone */
- call EXT(lck_rw_lock_shared_to_exclusive_failure)
- addl $8, %esp
-#else
- mov %eax, %esi /* put old flags as second arg */
- /* lock is alread in %rdi */
- call EXT(lck_rw_lock_shared_to_exclusive_failure)
-#endif
- ret /* and pass the failure return along */
-7:
- PAUSE
- jmp 1b
-8:
- jmp EXT(lck_rw_lock_shared_to_exclusive_success)
-
-
-
- .cstring
-rwl_release_error_str:
- .asciz "Releasing non-exclusive RW lock without a reader refcount!"
- .text
-
-/*
- * lck_rw_type_t lck_rw_done(lck_rw_t *)
- *
- */
-Entry(lck_rw_done)
- LOAD_LCK_RW_REGISTER
-1:
- LOAD_LCK_RW_FLAGS_REGISTER /* Load state bitfield, interlock and reader count */
- testl $(LCK_RW_INTERLOCK), %eax
- jne 7f /* wait for interlock to clear */
-
- movl %eax, %ecx /* keep original value in %eax for cmpxchgl */
- testl $(LCK_RW_SHARED_MASK), %ecx /* if reader count == 0, must be exclusive lock */
- je 2f
- decl %ecx /* Decrement reader count */
- testl $(LCK_RW_SHARED_MASK), %ecx /* if reader count has now gone to 0, check for waiters */
- je 4f
- jmp 6f
-2:
- testl $(LCK_RW_WANT_UPGRADE), %ecx
- je 3f
- andl $(~LCK_RW_WANT_UPGRADE), %ecx
- jmp 4f
-3:
- testl $(LCK_RW_WANT_WRITE), %ecx
- je 8f /* lock is not 'owned', go panic */
- andl $(~LCK_RW_WANT_WRITE), %ecx
-4:
- /*
- * test the original values to match what
- * lck_rw_done_gen is going to do to determine
- * which wakeups need to happen...
- *
- * if !(fake_lck->lck_rw_priv_excl && fake_lck->lck_w_waiting)
- */
- testl $(LCK_W_WAITING), %eax
- je 5f
- andl $(~LCK_W_WAITING), %ecx
-
- testl $(LCK_RW_PRIV_EXCL), %eax
- jne 6f
-5:
- andl $(~LCK_R_WAITING), %ecx
-6:
- lock
- cmpxchgl %ecx, (LCK_RW_REGISTER) /* Attempt atomic exchange */
- jne 7f
-
-#if __i386__
- pushl %eax
- push %edx
- call EXT(lck_rw_done_gen)
- addl $8, %esp
-#else
- mov %eax,%esi /* old flags in %rsi */
- /* lock is in %rdi already */
- call EXT(lck_rw_done_gen)
-#endif
- ret
-7:
- PAUSE
- jmp 1b
-8:
- ALIGN_STACK()
- LOAD_STRING_ARG0(rwl_release_error_str)
- CALL_PANIC()
-
-
-
-/*
- * lck_rw_type_t lck_rw_lock_exclusive_to_shared(lck_rw_t *)