- @abstract Sleep with mutex unlock and relock
-@discussion Prepare to sleep,unlock the mutex, and re-acquire it on wakeup.Results are undefined if the caller has not locked the mutex. This function may block and so should not be called from interrupt level or while a simple lock is held.
- @param lock Pointer to the locked lock.
- @param event The event to sleep on.
- @param interType How can the sleep be interrupted.
- @result The wait-result value indicating how the thread was awakened.*/
-static __inline__
-int IOLockSleep( IOLock * lock, void *event, UInt32 interType)
-{
- return thread_sleep_mutex((event_t) event, lock, (int) interType);
-}
-
-static __inline__
-int IOLockSleepDeadline( IOLock * lock, void *event,
- AbsoluteTime deadline, UInt32 interType)
-{
- return thread_sleep_mutex_deadline((event_t) event, lock,
- __OSAbsoluteTime(deadline), (int) interType);
-}
-
-static __inline__
-void IOLockWakeup(IOLock * lock, void *event, bool oneThread)
-{
- thread_wakeup_prim((event_t) event, oneThread, THREAD_AWAKENED);
-}
+ * @abstract Sleep with mutex unlock and relock
+ * @discussion Prepare to sleep,unlock the mutex, and re-acquire it on wakeup. Results are undefined if the caller has not locked the mutex. This function may block and so should not be called from interrupt level or while a spin lock is held.
+ * @param lock Pointer to the locked lock.
+ * @param event The event to sleep on. Must be non-NULL.
+ * @param interType How can the sleep be interrupted.
+ * @result The wait-result value indicating how the thread was awakened.*/
+int IOLockSleep( IOLock * lock, void *event, UInt32 interType) __DARWIN14_ALIAS(IOLockSleep);
+
+int IOLockSleepDeadline( IOLock * lock, void *event,
+ AbsoluteTime deadline, UInt32 interType) __DARWIN14_ALIAS(IOLockSleepDeadline);
+
+void IOLockWakeup(IOLock * lock, void *event, bool oneThread) __DARWIN14_ALIAS(IOLockWakeup);
+
+#ifdef XNU_KERNEL_PRIVATE
+/*! @enum IOLockAssertState
+ * @abstract Used with IOLockAssert to assert the state of a lock.
+ */
+typedef enum {
+ kIOLockAssertOwned = LCK_ASSERT_OWNED,
+ kIOLockAssertNotOwned = LCK_ASSERT_NOTOWNED
+} IOLockAssertState;
+
+#ifdef IOLOCKS_INLINE
+#define IOLockAssert(l, type) LCK_MTX_ASSERT(l, type)
+#else
+/*! @function IOLockAssert
+ * @abstract Assert that lock is either held or not held by current thread.
+ * @discussion Call with either kIOLockAssertOwned or kIOLockAssertNotOwned.
+ * Panics the kernel if the lock is not owned if called with kIOLockAssertOwned,
+ * and vice-versa.
+ */
+void IOLockAssert(IOLock * lock, IOLockAssertState type);
+#endif /* !IOLOCKS_INLINE */
+#endif /* !XNU_KERNEL_PRIVATE */