RTSemEventWait-2-ex-generic.cpp revision c7814cf6e1240a519cbec0441e033d0e2470ed00
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/* $Id$ */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/** @file
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * IPRT - RTSemEventWait, implementation based on RTSemEventWaitEx.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Copyright (C) 2010-2011 Oracle Corporation
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * This file is part of VirtualBox Open Source Edition (OSE), as
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * available from http://www.virtualbox.org. This file is free software;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * you can redistribute it and/or modify it under the terms of the GNU
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * General Public License (GPL) as published by the Free Software
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Foundation, in version 2 as it comes in the "COPYING" file of the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * The contents of this file may alternatively be used under the terms
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * of the Common Development and Distribution License Version 1.0
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * VirtualBox OSE distribution, in which case the provisions of the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CDDL are applicable instead of those of the GPL.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *
c93c462eec9d46f84d567abf52eb29a27c2e134bCheng Sean Ye * You may elect to license modified versions of this file under the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * terms and conditions of either the GPL or the CDDL or both.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye/*******************************************************************************
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi* Header Files *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi*******************************************************************************/
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm#define LOG_GROUP RTLOGGROUP_SEM
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#define RTSEMEVENT_WITHOUT_REMAPPING
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <iprt/semaphore.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include "internal/iprt.h"
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <iprt/err.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <iprt/assert.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiRTDECL(int) RTSemEventWait(RTSEMEVENT hEventSem, RTMSINTERVAL cMillies)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi int rc;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (cMillies == RT_INDEFINITE_WAIT)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi rc = RTSemEventWaitEx(hEventSem, RTSEMWAIT_FLAGS_RESUME | RTSEMWAIT_FLAGS_INDEFINITE, 0);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi else
8a40a695ee676a322b094e9afe5375567bfb51e3gavinm rc = RTSemEventWaitEx(hEventSem,
20c794b39650d115e17a15983b6b82e46238cf45gavinm RTSEMWAIT_FLAGS_RESUME | RTSEMWAIT_FLAGS_RELATIVE | RTSEMWAIT_FLAGS_MILLISECS,
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye cMillies);
e4b86885570d77af552e9cf94f142f4d744fb8c8Cheng Sean Ye Assert(rc != VERR_INTERRUPTED);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return rc;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiRT_EXPORT_SYMBOL(RTSemEventWait);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
bac580724643c7779231d57696e30d2b4056d372gavinm