semfastmutex-r0drv-solaris.c revision 3d59d33c965d3a9a7c51df3762c9081c5f1d51a3
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * innotek Portable Runtime - Fast Mutex Semaphores, Ring-0 Driver, Solaris.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Copyright (C) 2006-2007 innotek GmbH
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * This file is part of VirtualBox Open Source Edition (OSE), as
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * available from http://www.virtualbox.org. This file is free software;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * you can redistribute it and/or modify it under the terms of the GNU
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * General Public License as published by the Free Software Foundation,
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * distribution. VirtualBox OSE is distributed in the hope that it will
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * be useful, but WITHOUT ANY WARRANTY of any kind.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * If you received this file as part of a commercial VirtualBox
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * distribution, then only the terms of your commercial VirtualBox
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * license agreement apply instead of the previous paragraph.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster/*******************************************************************************
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster* Header Files *
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster*******************************************************************************/
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna/*******************************************************************************
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster* Structures and Typedefs *
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster*******************************************************************************/
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Wrapper for the FreeBSD (sleep) mutex.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster /** Magic value (RTSEMFASTMUTEX_MAGIC). */
c4329510051cce0c6b3efc1fae122ec4c5d61efaDavid Luna /** The Solaris mutex. */
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster} RTSEMFASTMUTEXINTERNAL, *PRTSEMFASTMUTEXINTERNAL;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan FosterRTDECL(int) RTSemFastMutexCreate(PRTSEMFASTMUTEX pMutexSem)
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster AssertCompile(sizeof(RTSEMFASTMUTEXINTERNAL) > sizeof(void *));
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster AssertPtrReturn(pMutexSem, VERR_INVALID_POINTER);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster PRTSEMFASTMUTEXINTERNAL pFastInt = (PRTSEMFASTMUTEXINTERNAL)RTMemAlloc(sizeof(*pFastInt));
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster mutex_init (&pFastInt->Mtx, "IPRT Fast Mutex Semaphore", MUTEX_DEFAULT, NULL);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan FosterRTDECL(int) RTSemFastMutexDestroy(RTSEMFASTMUTEX MutexSem)
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster PRTSEMFASTMUTEXINTERNAL pFastInt = (PRTSEMFASTMUTEXINTERNAL)MutexSem;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster AssertPtrReturn(pFastInt, VERR_INVALID_PARAMETER);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster AssertMsgReturn(pFastInt->u32Magic == RTSEMFASTMUTEX_MAGIC,
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster ("pFastInt->u32Magic=%RX32 pFastInt=%p\n", pFastInt->u32Magic, pFastInt),
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster ASMAtomicXchgU32(&pFastInt->u32Magic, RTSEMFASTMUTEX_MAGIC_DEAD);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan FosterRTDECL(int) RTSemFastMutexRequest(RTSEMFASTMUTEX MutexSem)
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster PRTSEMFASTMUTEXINTERNAL pFastInt = (PRTSEMFASTMUTEXINTERNAL)MutexSem;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster AssertPtrReturn(pFastInt, VERR_INVALID_PARAMETER);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster AssertMsgReturn(pFastInt->u32Magic == RTSEMFASTMUTEX_MAGIC,
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster ("pFastInt->u32Magic=%RX32 pFastInt=%p\n", pFastInt->u32Magic, pFastInt),
5c099afa7c9361afc2f4477fec0e3018588d7840Allan FosterRTDECL(int) RTSemFastMutexRelease(RTSEMFASTMUTEX MutexSem)
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster PRTSEMFASTMUTEXINTERNAL pFastInt = (PRTSEMFASTMUTEXINTERNAL)MutexSem;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster AssertPtrReturn(pFastInt, VERR_INVALID_PARAMETER);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster AssertMsgReturn(pFastInt->u32Magic == RTSEMFASTMUTEX_MAGIC,
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster ("pFastInt->u32Magic=%RX32 pFastInt=%p\n", pFastInt->u32Magic, pFastInt),