semeventmulti-r0drv-linux.c revision e6c7f0916ea395e9211fe5a004cebe5934521694
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * IPRT - Multiple Release Event Semaphores, Ring-0 Driver, Linux.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * Copyright (C) 2006-2007 Oracle Corporation
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * available from http://www.virtualbox.org. This file is free software;
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * you can redistribute it and/or modify it under the terms of the GNU
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * General Public License (GPL) as published by the Free Software
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * The contents of this file may alternatively be used under the terms
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * of the Common Development and Distribution License Version 1.0
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * VirtualBox OSE distribution, in which case the provisions of the
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * CDDL are applicable instead of those of the GPL.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * You may elect to license modified versions of this file under the
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * terms and conditions of either the GPL or the CDDL or both.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync/*******************************************************************************
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync* Header Files *
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync*******************************************************************************/
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync/*******************************************************************************
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync* Structures and Typedefs *
8a7af14e45ca3f1aadcad537ddf79f68a830748cvboxsync*******************************************************************************/
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * Linux event semaphore.
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync /** Magic value (RTSEMEVENTMULTI_MAGIC). */
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync /** The object status - !0 when signaled and 0 when reset. */
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync /** The wait queue. */
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync} RTSEMEVENTMULTIINTERNAL, *PRTSEMEVENTMULTIINTERNAL;
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsyncRTDECL(int) RTSemEventMultiCreate(PRTSEMEVENTMULTI phEventMultiSem)
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync return RTSemEventMultiCreateEx(phEventMultiSem, 0 /*fFlags*/, NIL_RTLOCKVALCLASS, NULL);
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsyncRTDECL(int) RTSemEventMultiCreateEx(PRTSEMEVENTMULTI phEventMultiSem, uint32_t fFlags, RTLOCKVALCLASS hClass,
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync const char *pszNameFmt, ...)
9d508d63ddd8cbaa227c3e3176bb376ba98ffa53vboxsync AssertReturn(!(fFlags & ~RTSEMEVENTMULTI_FLAGS_NO_LOCK_VAL), VERR_INVALID_PARAMETER);
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync pThis = (PRTSEMEVENTMULTIINTERNAL)RTMemAlloc(sizeof(*pThis));
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsyncRTDECL(int) RTSemEventMultiDestroy(RTSEMEVENTMULTI hEventMultiSem)
7255e1c7174fd3b892a74dede74e72557f6cced9vboxsync * Validate input.
7255e1c7174fd3b892a74dede74e72557f6cced9vboxsync PRTSEMEVENTMULTIINTERNAL pThis = (PRTSEMEVENTMULTIINTERNAL)hEventMultiSem;
9d508d63ddd8cbaa227c3e3176bb376ba98ffa53vboxsync AssertMsgReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC, ("%p u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync * Invalidate it and signal the object just in case.
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync ASMAtomicWriteU32(&pThis->u32Magic, ~RTSEMEVENTMULTI_MAGIC);
return VINF_SUCCESS;
if (!pThis)
return VERR_INVALID_PARAMETER;
AssertMsgReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC, ("%p u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);
return VINF_SUCCESS;
if (!pThis)
return VERR_INVALID_PARAMETER;
AssertMsgReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC, ("%p u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);
return VINF_SUCCESS;
static int rtSemEventMultiWait(PRTSEMEVENTMULTIINTERNAL pThis, RTMSINTERVAL cMillies, bool fInterruptible)
#ifdef IPRT_DEBUG_SEMS
if (!lTimeout)
#ifdef IPRT_DEBUG_SEMS
return rc;
if (!pThis)
return VERR_INVALID_PARAMETER;
AssertMsgReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC, ("%p u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);
return VINF_SUCCESS;
if (!pThis)
return VERR_INVALID_PARAMETER;
AssertMsgReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC, ("%p u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);
return VINF_SUCCESS;