X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/0b4e3aa066abc0728aacb4bbeb86f53f9737156e..55e303ae13a4cf49d70f2294092726f2fffb9ef2:/iokit/IOKit/IOLocks.h diff --git a/iokit/IOKit/IOLocks.h b/iokit/IOKit/IOLocks.h index 4e2e9c22c..69bd12794 100644 --- a/iokit/IOKit/IOLocks.h +++ b/iokit/IOKit/IOLocks.h @@ -1,21 +1,24 @@ /* - * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1998-2002 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -30,9 +33,7 @@ #error IOLocks.h is for kernel use only #endif -#ifndef IOKIT_DEPRECATED -#define IOKIT_DEPRECATED 1 -#endif +#include #include @@ -45,6 +46,7 @@ extern "C" { #include #include +#include #include /* @@ -101,13 +103,40 @@ void IOLockUnlock( IOLock * lock) mutex_unlock(lock); } -#if IOKIT_DEPRECATED +/*! @function IOLockSleep + @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); +} + +#ifdef __APPLE_API_OBSOLETE /* The following API is deprecated */ typedef enum { kIOLockStateUnlocked = 0, - kIOLockStateLocked = 1, + kIOLockStateLocked = 1 } IOLockState; void IOLockInitWithState( IOLock * lock, IOLockState state); @@ -117,7 +146,7 @@ static __inline__ void IOTakeLock( IOLock * lock) { IOLockLock(lock); } static __inline__ boolean_t IOTryLock( IOLock * lock) { return(IOLockTryLock(lock)); } static __inline__ void IOUnlock( IOLock * lock) { IOLockUnlock(lock); } -#endif /* IOKIT_DEPRECATED */ +#endif /* __APPLE_API_OBSOLETE */ /* * Recursive lock operations @@ -227,7 +256,7 @@ void IORWLockUnlock( IORWLock * lock) lock_done( lock); } -#if IOKIT_DEPRECATED +#ifdef __APPLE_API_OBSOLETE /* The following API is deprecated */ @@ -235,7 +264,7 @@ static __inline__ void IOReadLock( IORWLock * lock) { IORWLockRead(lock); } static __inline__ void IOWriteLock( IORWLock * lock) { IORWLockWrite(lock); } static __inline__ void IORWUnlock( IORWLock * lock) { IORWLockUnlock(lock); } -#endif /* IOKIT_DEPRECATED */ +#endif /* __APPLE_API_OBSOLETE */ /*