FSF GCC merge 02/23/03
[official-gcc.git] / gcc / ada / i-os2syn.ads
blob4c686d5da8eeed937acee75dbc4accbd8b5278c8
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
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 --
6 -- --
7 -- S p e c --
8 -- --
9 -- --
10 -- Copyright (C) 1993-1998 Free Software Foundation, Inc. --
11 -- --
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. --
22 -- --
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. --
29 -- --
30 -- GNAT was originally developed by the GNAT team at New York University. --
31 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 -- --
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
57 hsemCur : HSEM;
58 ulUser : ULONG;
59 end 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;
72 type HEV is new HSEM;
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");
94 --------------
95 -- EventSem --
96 --------------
98 function DosCreateEventSem
99 (pszName : PSZ;
100 f_phev : PHEV;
101 flAttr : ULONG;
102 fState : BOOL32)
103 return APIRET;
104 pragma Import (C, DosCreateEventSem, "DosCreateEventSem");
106 function DosOpenEventSem
107 (pszName : PSZ;
108 F_phev : PHEV)
109 return APIRET;
110 pragma Import (C, DosOpenEventSem, "DosOpenEventSem");
112 function DosCloseEventSem
113 (F_hev : HEV)
114 return APIRET;
115 pragma Import (C, DosCloseEventSem, "DosCloseEventSem");
117 function DosResetEventSem
118 (F_hev : HEV;
119 pulPostCt : PULONG)
120 return APIRET;
121 pragma Import (C, DosResetEventSem, "DosResetEventSem");
123 function DosPostEventSem
124 (F_hev : HEV)
125 return APIRET;
126 pragma Import (C, DosPostEventSem, "DosPostEventSem");
128 function DosWaitEventSem
129 (F_hev : HEV;
130 ulTimeout : ULONG)
131 return APIRET;
132 pragma Import (C, DosWaitEventSem, "DosWaitEventSem");
134 function DosQueryEventSem
135 (F_hev : HEV;
136 pulPostCt : PULONG)
137 return APIRET;
138 pragma Import (C, DosQueryEventSem, "DosQueryEventSem");
140 --------------
141 -- MutexSem --
142 --------------
144 function DosCreateMutexSem
145 (pszName : PSZ;
146 F_phmtx : PHMTX;
147 flAttr : ULONG;
148 fState : BOOL32)
149 return APIRET;
150 pragma Import (C, DosCreateMutexSem, "DosCreateMutexSem");
152 function DosOpenMutexSem
153 (pszName : PSZ;
154 F_phmtx : PHMTX)
155 return APIRET;
156 pragma Import (C, DosOpenMutexSem, "DosOpenMutexSem");
158 function DosCloseMutexSem
159 (F_hmtx : HMTX)
160 return APIRET;
161 pragma Import (C, DosCloseMutexSem, "DosCloseMutexSem");
163 function DosRequestMutexSem
164 (F_hmtx : HMTX;
165 ulTimeout : ULONG)
166 return APIRET;
167 pragma Import (C, DosRequestMutexSem, "DosRequestMutexSem");
169 function DosReleaseMutexSem
170 (F_hmtx : HMTX)
171 return APIRET;
172 pragma Import (C, DosReleaseMutexSem, "DosReleaseMutexSem");
174 function DosQueryMutexSem
175 (F_hmtx : HMTX;
176 F_ppid : IOT.PPID;
177 F_ptid : IOT.PTID;
178 pulCount : PULONG)
179 return APIRET;
180 pragma Import (C, DosQueryMutexSem, "DosQueryMutexSem");
182 ----------------
183 -- MuxWaitSem --
184 ----------------
186 function DosCreateMuxWaitSem
187 (pszName : PSZ;
188 F_phmux : PHMUX;
189 cSemRec : ULONG;
190 pSemRec : PSEMRECORD;
191 flAttr : ULONG)
192 return APIRET;
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
200 (pszName : PSZ;
201 F_phmux : PHMUX)
202 return APIRET;
203 pragma Import (C, DosOpenMuxWaitSem, "DosOpenMuxWaitSem");
205 function DosCloseMuxWaitSem
206 (F_hmux : HMUX)
207 return APIRET;
208 pragma Import (C, DosCloseMuxWaitSem, "DosCloseMuxWaitSem");
210 function DosWaitMuxWaitSem
211 (F_hmux : HMUX;
212 ulTimeout : ULONG;
213 pulUser : PULONG)
214 return APIRET;
215 pragma Import (C, DosWaitMuxWaitSem, "DosWaitMuxWaitSem");
217 function DosAddMuxWaitSem
218 (F_hmux : HMUX;
219 pSemRec : PSEMRECORD)
220 return APIRET;
221 pragma Import (C, DosAddMuxWaitSem, "DosAddMuxWaitSem");
223 function DosDeleteMuxWaitSem
224 (F_hmux : HMUX;
225 F_hsem : HSEM)
226 return APIRET;
227 pragma Import (C, DosDeleteMuxWaitSem, "DosDeleteMuxWaitSem");
229 function DosQueryMuxWaitSem
230 (F_hmux : HMUX;
231 pcSemRec : PULONG;
232 pSemRec : PSEMRECORD;
233 pflAttr : PULONG)
234 return APIRET;
235 pragma Import (C, DosQueryMuxWaitSem, "DosQueryMuxWaitSem");
237 -----------
238 -- Timer --
239 -----------
241 function DosAsyncTimer
242 (msec : ULONG;
243 F_hsem : HSEM;
244 F_phtimer : PHTIMER)
245 return APIRET;
246 pragma Import (C, DosAsyncTimer, "DosAsyncTimer");
248 function DosStartTimer
249 (msec : ULONG;
250 F_hsem : HSEM;
251 F_phtimer : PHTIMER)
252 return APIRET;
253 pragma Import (C, DosStartTimer, "DosStartTimer");
255 function DosStopTimer
256 (F_htimer : HTIMER)
257 return APIRET;
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)
265 return APIRET;
266 pragma Import (C, DosTmrQueryTime, "DosTmrQueryTime");
268 end Interfaces.OS2Lib.Synchronization;