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 --
9 -- Copyright (C) 1993-1998 Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 with Interfaces
.OS2Lib
.Threads
;
36 package Interfaces
.OS2Lib
.Synchronization
is
37 pragma Preelaborate
(Synchronization
);
39 package IC
renames Interfaces
.C
;
40 package IOT
renames Interfaces
.OS2Lib
.Threads
;
41 package S
renames System
;
43 -- Semaphore Attributes
45 DC_SEM_SHARED
: constant := 16#
01#
;
46 -- DosCreateMutex, DosCreateEvent, and DosCreateMuxWait use it to indicate
47 -- whether the semaphore is shared or private when the PSZ is null
49 SEM_INDEFINITE_WAIT
: constant ULONG
:= -1;
50 SEM_IMMEDIATE_RETURN
: constant ULONG
:= 0;
52 type HSEM
is new LHANDLE
;
53 type PHSEM
is access all HSEM
;
55 type SEMRECORD
is record
60 type PSEMRECORD
is access all SEMRECORD
;
62 -- Quad word structure
64 -- Originally QWORD is defined as a record containing two ULONGS,
65 -- the first containing low word and the second for the high word,
66 -- but it is cleaner to define it as follows:
68 type QWORD
is delta 1.0 range -2.0**63 .. 2.0**63 - 1.0;
69 type PQWORD
is access all QWORD
;
72 type PHEV
is access all HEV
;
74 type HMTX
is new HSEM
;
75 type PHMTX
is access all HMTX
;
77 type HMUX
is new HSEM
;
78 type PHMUX
is access all HMUX
;
80 type HTIMER
is new LHANDLE
;
81 type PHTIMER
is access all HTIMER
;
83 -----------------------
84 -- Critical sections --
85 -----------------------
87 function DosEnterCritSec
return APIRET
;
88 pragma Import
(C
, DosEnterCritSec
, "DosEnterCritSec");
90 function DosExitCritSec
return APIRET
;
91 pragma Import
(C
, DosExitCritSec
, "DosExitCritSec");
97 function DosCreateEventSem
103 pragma Import
(C
, DosCreateEventSem
, "DosCreateEventSem");
105 function DosOpenEventSem
109 pragma Import
(C
, DosOpenEventSem
, "DosOpenEventSem");
111 function DosCloseEventSem
114 pragma Import
(C
, DosCloseEventSem
, "DosCloseEventSem");
116 function DosResetEventSem
120 pragma Import
(C
, DosResetEventSem
, "DosResetEventSem");
122 function DosPostEventSem
125 pragma Import
(C
, DosPostEventSem
, "DosPostEventSem");
127 function DosWaitEventSem
131 pragma Import
(C
, DosWaitEventSem
, "DosWaitEventSem");
133 function DosQueryEventSem
137 pragma Import
(C
, DosQueryEventSem
, "DosQueryEventSem");
143 function DosCreateMutexSem
149 pragma Import
(C
, DosCreateMutexSem
, "DosCreateMutexSem");
151 function DosOpenMutexSem
155 pragma Import
(C
, DosOpenMutexSem
, "DosOpenMutexSem");
157 function DosCloseMutexSem
160 pragma Import
(C
, DosCloseMutexSem
, "DosCloseMutexSem");
162 function DosRequestMutexSem
166 pragma Import
(C
, DosRequestMutexSem
, "DosRequestMutexSem");
168 function DosReleaseMutexSem
171 pragma Import
(C
, DosReleaseMutexSem
, "DosReleaseMutexSem");
173 function DosQueryMutexSem
179 pragma Import
(C
, DosQueryMutexSem
, "DosQueryMutexSem");
185 function DosCreateMuxWaitSem
189 pSemRec
: PSEMRECORD
;
192 pragma Import
(C
, DosCreateMuxWaitSem
, "DosCreateMuxWaitSem");
194 DCMW_WAIT_ANY
: constant := 16#
02#
; -- wait on any event/mutex to occur
195 DCMW_WAIT_ALL
: constant := 16#
04#
; -- wait on all events/mutexes to occur
196 -- Values for "flAttr" parameter in DosCreateMuxWaitSem call
198 function DosOpenMuxWaitSem
202 pragma Import
(C
, DosOpenMuxWaitSem
, "DosOpenMuxWaitSem");
204 function DosCloseMuxWaitSem
207 pragma Import
(C
, DosCloseMuxWaitSem
, "DosCloseMuxWaitSem");
209 function DosWaitMuxWaitSem
214 pragma Import
(C
, DosWaitMuxWaitSem
, "DosWaitMuxWaitSem");
216 function DosAddMuxWaitSem
218 pSemRec
: PSEMRECORD
)
220 pragma Import
(C
, DosAddMuxWaitSem
, "DosAddMuxWaitSem");
222 function DosDeleteMuxWaitSem
226 pragma Import
(C
, DosDeleteMuxWaitSem
, "DosDeleteMuxWaitSem");
228 function DosQueryMuxWaitSem
231 pSemRec
: PSEMRECORD
;
234 pragma Import
(C
, DosQueryMuxWaitSem
, "DosQueryMuxWaitSem");
240 function DosAsyncTimer
245 pragma Import
(C
, DosAsyncTimer
, "DosAsyncTimer");
247 function DosStartTimer
252 pragma Import
(C
, DosStartTimer
, "DosStartTimer");
254 function DosStopTimer
257 pragma Import
(C
, DosStopTimer
, "DosStopTimer");
259 -- DosTmrQueryTime provides a snapshot of the time
260 -- from the IRQ0 high resolution timer (Intel 8254)
262 function DosTmrQueryTime
263 (pqwTmrTime
: access QWORD
) -- Time in 8254 ticks (1_192_755.2 Hz)
265 pragma Import
(C
, DosTmrQueryTime
, "DosTmrQueryTime");
267 end Interfaces
.OS2Lib
.Synchronization
;