semmutex-win.cpp revision c58f1213e628a545081c70e26c6b67a841cff880
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest * IPRT - Mutex Semaphores, Windows.
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest * Copyright (C) 2006-2010 Oracle Corporation
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest * This file is part of VirtualBox Open Source Edition (OSE), as
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest * available from http://www.virtualbox.org. This file is free software;
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest * you can redistribute it and/or modify it under the terms of the GNU
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest * General Public License (GPL) as published by the Free Software
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest * Foundation, in version 2 as it comes in the "COPYING" file of the
f58fb92a804b356de679ca0ad458d59d95dc3af2Andrew Forrest * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest * The contents of this file may alternatively be used under the terms
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest * of the Common Development and Distribution License Version 1.0
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest * VirtualBox OSE distribution, in which case the provisions of the
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest * CDDL are applicable instead of those of the GPL.
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest * You may elect to license modified versions of this file under the
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest * terms and conditions of either the GPL or the CDDL or both.
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest/*******************************************************************************
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest* Header Files *
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest*******************************************************************************/
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest/*******************************************************************************
b59db10c9e545a767806dc5cfea3bc7b05408401Andrew Forrest* Defined Constants And Macros *
f58fb92a804b356de679ca0ad458d59d95dc3af2Andrew Forrest*******************************************************************************/
f58fb92a804b356de679ca0ad458d59d95dc3af2Andrew Forrest/** Posix internal representation of a Mutex semaphore. */
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest /** Magic value (RTSEMMUTEX_MAGIC). */
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest /** Recursion count. */
8c87dc0aa16e17b16a878d07afcbae32f122d693Andrew Forrest /** The owner thread. */
6202ba4d983650b484ebe9607707003fef5e09c6Andrew Forrest /** The mutex handle. */
d2ccc2b0b2e8d1c82c1ed9f0cf456eabbd814347Andrew Forrest /** Lock validator record associated with this mutex. */
return RTSemMutexCreateEx(phMutexSem, 0 /*fFlags*/, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, NULL);
int rc;
if (hMtx)
if (pThis)
#ifdef RTSEMMUTEX_STRICT
if (!pszNameFmt)
return VINF_SUCCESS;
return rc;
return VINF_SUCCESS;
AssertReturn(ASMAtomicCmpXchgU32(&pThis->u32Magic, RTSEMMUTEX_MAGIC_DEAD, RTSEMMUTEX_MAGIC), VERR_INVALID_HANDLE);
#ifdef RTSEMMUTEX_STRICT
return rc;
#ifdef RTSEMMUTEX_STRICT
return RTLOCKVAL_SUB_CLASS_INVALID;
DECL_FORCE_INLINE(int) rtSemMutexRequestNoResume(RTSEMMUTEX hMutexSem, RTMSINTERVAL cMillies, PCRTLOCKVALSRCPOS pSrcPos)
#ifdef RTSEMMUTEX_STRICT
return rc9;
return VINF_SUCCESS;
if (cMillies > 0)
#ifdef RTSEMMUTEX_STRICT
int rc9 = RTLockValidatorRecExclCheckOrderAndBlocking(&pThis->ValidatorRec, hThreadSelf, pSrcPos, true,
return rc9;
switch (rc)
case WAIT_OBJECT_0:
#ifdef RTSEMMUTEX_STRICT
return VINF_SUCCESS;
case WAIT_FAILED:
AssertMsgFailed(("Wait on hMutexSem %p failed, rc=%d lasterr=%d\n", hMutexSem, rc, GetLastError()));
return rc2;
return VERR_INTERNAL_ERROR;
#ifndef RTSEMMUTEX_STRICT
RTDECL(int) RTSemMutexRequestNoResumeDebug(RTSEMMUTEX hMutexSem, RTMSINTERVAL cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
return VERR_NOT_OWNER;
#ifdef RTSEMMUTEX_STRICT
return rc9;
return VINF_SUCCESS;
#ifdef RTSEMMUTEX_STRICT
return rc9;
return VINF_SUCCESS;
return rc;