1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/src/md/os2/os2sem.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * OS/2-specific semaphore handling code. 1.11 + * 1.12 + */ 1.13 + 1.14 +#include "primpl.h" 1.15 + 1.16 + 1.17 +void 1.18 +_PR_MD_NEW_SEM(_MDSemaphore *md, PRUintn value) 1.19 +{ 1.20 + int rv; 1.21 + 1.22 + /* Our Sems don't support a value > 1 */ 1.23 + PR_ASSERT(value <= 1); 1.24 + 1.25 + rv = DosCreateEventSem(NULL, &md->sem, 0, 0); 1.26 + PR_ASSERT(rv == NO_ERROR); 1.27 +} 1.28 + 1.29 +void 1.30 +_PR_MD_DESTROY_SEM(_MDSemaphore *md) 1.31 +{ 1.32 + int rv; 1.33 + rv = DosCloseEventSem(md->sem); 1.34 + PR_ASSERT(rv == NO_ERROR); 1.35 + 1.36 +} 1.37 + 1.38 +PRStatus 1.39 +_PR_MD_TIMED_WAIT_SEM(_MDSemaphore *md, PRIntervalTime ticks) 1.40 +{ 1.41 + int rv; 1.42 + rv = DosWaitEventSem(md->sem, PR_IntervalToMilliseconds(ticks)); 1.43 + 1.44 + if (rv == NO_ERROR) 1.45 + return PR_SUCCESS; 1.46 + else 1.47 + return PR_FAILURE; 1.48 +} 1.49 + 1.50 +PRStatus 1.51 +_PR_MD_WAIT_SEM(_MDSemaphore *md) 1.52 +{ 1.53 + return _PR_MD_TIMED_WAIT_SEM(md, PR_INTERVAL_NO_TIMEOUT); 1.54 +} 1.55 + 1.56 +void 1.57 +_PR_MD_POST_SEM(_MDSemaphore *md) 1.58 +{ 1.59 + int rv; 1.60 + rv = DosPostEventSem(md->sem); 1.61 + PR_ASSERT(rv == NO_ERROR); 1.62 +} 1.63 + 1.64 +