semmutex-win.cpp revision 7f22d63b8c416918f318efcd1b28b883d934e84d
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * IPRT - Mutex Semaphores, Windows.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Copyright (C) 2006-2009 Sun Microsystems, Inc.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * available from http://www.virtualbox.org. This file is free software;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * you can redistribute it and/or modify it under the terms of the GNU
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * General Public License (GPL) as published by the Free Software
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The contents of this file may alternatively be used under the terms
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * of the Common Development and Distribution License Version 1.0
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * VirtualBox OSE distribution, in which case the provisions of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL are applicable instead of those of the GPL.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * You may elect to license modified versions of this file under the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * terms and conditions of either the GPL or the CDDL or both.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * additional information or have any questions.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*******************************************************************************
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync* Header Files *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync*******************************************************************************/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*******************************************************************************
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync* Defined Constants And Macros *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync*******************************************************************************/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/** Posix internal representation of a Mutex semaphore. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** Magic value (RTSEMMUTEX_MAGIC). */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** Recursion count. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** The owner thread. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** The mutex handle. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** Lock validator record associated with this mutex. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/* Undefine debug mappings. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Create the semaphore.
if (hMtx)
if (pThis)
#ifdef RTSEMMUTEX_STRICT
RTLockValidatorRecExclInit(&pThis->ValidatorRec, NIL_RTLOCKVALIDATORCLASS, RTLOCKVALIDATOR_SUB_CLASS_NONE, "RTSemMutex", pThis);
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;
DECL_FORCE_INLINE(int) rtSemMutexRequestNoResume(RTSEMMUTEX MutexSem, unsigned 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,
RTTHREADSTATE_MUTEX, true);
return rc9;
switch (rc)
case WAIT_OBJECT_0:
#ifdef RTSEMMUTEX_STRICT
return VINF_SUCCESS;
case WAIT_FAILED:
return rc2;
return VERR_INTERNAL_ERROR;
#ifndef RTSEMMUTEX_STRICT
RTDECL(int) RTSemMutexRequestNoResumeDebug(RTSEMMUTEX MutexSem, unsigned 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;