1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- I N T E R F A C E S . O S 2 L I B . S Y N C H R O N I Z A T I O N --
10 -- Copyright (C) 1993-1998 Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
30 -- GNAT was originally developed by the GNAT team at New York University. --
31 -- Extensive contributions were provided by Ada Core Technologies Inc. --
33 ------------------------------------------------------------------------------
35 with Interfaces
.OS2Lib
.Threads
;
37 package Interfaces
.OS2Lib
.Synchronization
is
38 pragma Preelaborate
(Synchronization
);
40 package IC
renames Interfaces
.C
;
41 package IOT
renames Interfaces
.OS2Lib
.Threads
;
42 package S
renames System
;
44 -- Semaphore Attributes
46 DC_SEM_SHARED
: constant := 16#
01#
;
47 -- DosCreateMutex, DosCreateEvent, and DosCreateMuxWait use it to indicate
48 -- whether the semaphore is shared or private when the PSZ is null
50 SEM_INDEFINITE_WAIT
: constant ULONG
:= -1;
51 SEM_IMMEDIATE_RETURN
: constant ULONG
:= 0;
53 type HSEM
is new LHANDLE
;
54 type PHSEM
is access all HSEM
;
56 type SEMRECORD
is record
61 type PSEMRECORD
is access all SEMRECORD
;
63 -- Quad word structure
65 -- Originally QWORD is defined as a record containing two ULONGS,
66 -- the first containing low word and the second for the high word,
67 -- but it is cleaner to define it as follows:
69 type QWORD
is delta 1.0 range -2.0**63 .. 2.0**63 - 1.0;
70 type PQWORD
is access all QWORD
;
73 type PHEV
is access all HEV
;
75 type HMTX
is new HSEM
;
76 type PHMTX
is access all HMTX
;
78 type HMUX
is new HSEM
;
79 type PHMUX
is access all HMUX
;
81 type HTIMER
is new LHANDLE
;
82 type PHTIMER
is access all HTIMER
;
84 -----------------------
85 -- Critical sections --
86 -----------------------
88 function DosEnterCritSec
return APIRET
;
89 pragma Import
(C
, DosEnterCritSec
, "DosEnterCritSec");
91 function DosExitCritSec
return APIRET
;
92 pragma Import
(C
, DosExitCritSec
, "DosExitCritSec");
98 function DosCreateEventSem
104 pragma Import
(C
, DosCreateEventSem
, "DosCreateEventSem");
106 function DosOpenEventSem
110 pragma Import
(C
, DosOpenEventSem
, "DosOpenEventSem");
112 function DosCloseEventSem
115 pragma Import
(C
, DosCloseEventSem
, "DosCloseEventSem");
117 function DosResetEventSem
121 pragma Import
(C
, DosResetEventSem
, "DosResetEventSem");
123 function DosPostEventSem
126 pragma Import
(C
, DosPostEventSem
, "DosPostEventSem");
128 function DosWaitEventSem
132 pragma Import
(C
, DosWaitEventSem
, "DosWaitEventSem");
134 function DosQueryEventSem
138 pragma Import
(C
, DosQueryEventSem
, "DosQueryEventSem");
144 function DosCreateMutexSem
150 pragma Import
(C
, DosCreateMutexSem
, "DosCreateMutexSem");
152 function DosOpenMutexSem
156 pragma Import
(C
, DosOpenMutexSem
, "DosOpenMutexSem");
158 function DosCloseMutexSem
161 pragma Import
(C
, DosCloseMutexSem
, "DosCloseMutexSem");
163 function DosRequestMutexSem
167 pragma Import
(C
, DosRequestMutexSem
, "DosRequestMutexSem");
169 function DosReleaseMutexSem
172 pragma Import
(C
, DosReleaseMutexSem
, "DosReleaseMutexSem");
174 function DosQueryMutexSem
180 pragma Import
(C
, DosQueryMutexSem
, "DosQueryMutexSem");
186 function DosCreateMuxWaitSem
190 pSemRec
: PSEMRECORD
;
193 pragma Import
(C
, DosCreateMuxWaitSem
, "DosCreateMuxWaitSem");
195 DCMW_WAIT_ANY
: constant := 16#
02#
; -- wait on any event/mutex to occur
196 DCMW_WAIT_ALL
: constant := 16#
04#
; -- wait on all events/mutexes to occur
197 -- Values for "flAttr" parameter in DosCreateMuxWaitSem call
199 function DosOpenMuxWaitSem
203 pragma Import
(C
, DosOpenMuxWaitSem
, "DosOpenMuxWaitSem");
205 function DosCloseMuxWaitSem
208 pragma Import
(C
, DosCloseMuxWaitSem
, "DosCloseMuxWaitSem");
210 function DosWaitMuxWaitSem
215 pragma Import
(C
, DosWaitMuxWaitSem
, "DosWaitMuxWaitSem");
217 function DosAddMuxWaitSem
219 pSemRec
: PSEMRECORD
)
221 pragma Import
(C
, DosAddMuxWaitSem
, "DosAddMuxWaitSem");
223 function DosDeleteMuxWaitSem
227 pragma Import
(C
, DosDeleteMuxWaitSem
, "DosDeleteMuxWaitSem");
229 function DosQueryMuxWaitSem
232 pSemRec
: PSEMRECORD
;
235 pragma Import
(C
, DosQueryMuxWaitSem
, "DosQueryMuxWaitSem");
241 function DosAsyncTimer
246 pragma Import
(C
, DosAsyncTimer
, "DosAsyncTimer");
248 function DosStartTimer
253 pragma Import
(C
, DosStartTimer
, "DosStartTimer");
255 function DosStopTimer
258 pragma Import
(C
, DosStopTimer
, "DosStopTimer");
260 -- DosTmrQueryTime provides a snapshot of the time
261 -- from the IRQ0 high resolution timer (Intel 8254)
263 function DosTmrQueryTime
264 (pqwTmrTime
: access QWORD
) -- Time in 8254 ticks (1_192_755.2 Hz)
266 pragma Import
(C
, DosTmrQueryTime
, "DosTmrQueryTime");
268 end Interfaces
.OS2Lib
.Synchronization
;