|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 /* |
|
7 * OS/2-specific semaphore handling code. |
|
8 * |
|
9 */ |
|
10 |
|
11 #include "primpl.h" |
|
12 |
|
13 |
|
14 void |
|
15 _PR_MD_NEW_SEM(_MDSemaphore *md, PRUintn value) |
|
16 { |
|
17 int rv; |
|
18 |
|
19 /* Our Sems don't support a value > 1 */ |
|
20 PR_ASSERT(value <= 1); |
|
21 |
|
22 rv = DosCreateEventSem(NULL, &md->sem, 0, 0); |
|
23 PR_ASSERT(rv == NO_ERROR); |
|
24 } |
|
25 |
|
26 void |
|
27 _PR_MD_DESTROY_SEM(_MDSemaphore *md) |
|
28 { |
|
29 int rv; |
|
30 rv = DosCloseEventSem(md->sem); |
|
31 PR_ASSERT(rv == NO_ERROR); |
|
32 |
|
33 } |
|
34 |
|
35 PRStatus |
|
36 _PR_MD_TIMED_WAIT_SEM(_MDSemaphore *md, PRIntervalTime ticks) |
|
37 { |
|
38 int rv; |
|
39 rv = DosWaitEventSem(md->sem, PR_IntervalToMilliseconds(ticks)); |
|
40 |
|
41 if (rv == NO_ERROR) |
|
42 return PR_SUCCESS; |
|
43 else |
|
44 return PR_FAILURE; |
|
45 } |
|
46 |
|
47 PRStatus |
|
48 _PR_MD_WAIT_SEM(_MDSemaphore *md) |
|
49 { |
|
50 return _PR_MD_TIMED_WAIT_SEM(md, PR_INTERVAL_NO_TIMEOUT); |
|
51 } |
|
52 |
|
53 void |
|
54 _PR_MD_POST_SEM(_MDSemaphore *md) |
|
55 { |
|
56 int rv; |
|
57 rv = DosPostEventSem(md->sem); |
|
58 PR_ASSERT(rv == NO_ERROR); |
|
59 } |
|
60 |
|
61 |