PR target/16201
[official-gcc.git] / gcc / ada / i-os2syn.ads
blob2f44c89165464114c2464c771a0687ac39e92b8a
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 -- Copyright (C) 1993-1998 Free Software Foundation, Inc. --
10 -- --
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. --
21 -- --
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. --
28 -- --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
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
56 hsemCur : HSEM;
57 ulUser : ULONG;
58 end 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;
71 type HEV is new HSEM;
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");
93 --------------
94 -- EventSem --
95 --------------
97 function DosCreateEventSem
98 (pszName : PSZ;
99 f_phev : PHEV;
100 flAttr : ULONG;
101 fState : BOOL32)
102 return APIRET;
103 pragma Import (C, DosCreateEventSem, "DosCreateEventSem");
105 function DosOpenEventSem
106 (pszName : PSZ;
107 F_phev : PHEV)
108 return APIRET;
109 pragma Import (C, DosOpenEventSem, "DosOpenEventSem");
111 function DosCloseEventSem
112 (F_hev : HEV)
113 return APIRET;
114 pragma Import (C, DosCloseEventSem, "DosCloseEventSem");
116 function DosResetEventSem
117 (F_hev : HEV;
118 pulPostCt : PULONG)
119 return APIRET;
120 pragma Import (C, DosResetEventSem, "DosResetEventSem");
122 function DosPostEventSem
123 (F_hev : HEV)
124 return APIRET;
125 pragma Import (C, DosPostEventSem, "DosPostEventSem");
127 function DosWaitEventSem
128 (F_hev : HEV;
129 ulTimeout : ULONG)
130 return APIRET;
131 pragma Import (C, DosWaitEventSem, "DosWaitEventSem");
133 function DosQueryEventSem
134 (F_hev : HEV;
135 pulPostCt : PULONG)
136 return APIRET;
137 pragma Import (C, DosQueryEventSem, "DosQueryEventSem");
139 --------------
140 -- MutexSem --
141 --------------
143 function DosCreateMutexSem
144 (pszName : PSZ;
145 F_phmtx : PHMTX;
146 flAttr : ULONG;
147 fState : BOOL32)
148 return APIRET;
149 pragma Import (C, DosCreateMutexSem, "DosCreateMutexSem");
151 function DosOpenMutexSem
152 (pszName : PSZ;
153 F_phmtx : PHMTX)
154 return APIRET;
155 pragma Import (C, DosOpenMutexSem, "DosOpenMutexSem");
157 function DosCloseMutexSem
158 (F_hmtx : HMTX)
159 return APIRET;
160 pragma Import (C, DosCloseMutexSem, "DosCloseMutexSem");
162 function DosRequestMutexSem
163 (F_hmtx : HMTX;
164 ulTimeout : ULONG)
165 return APIRET;
166 pragma Import (C, DosRequestMutexSem, "DosRequestMutexSem");
168 function DosReleaseMutexSem
169 (F_hmtx : HMTX)
170 return APIRET;
171 pragma Import (C, DosReleaseMutexSem, "DosReleaseMutexSem");
173 function DosQueryMutexSem
174 (F_hmtx : HMTX;
175 F_ppid : IOT.PPID;
176 F_ptid : IOT.PTID;
177 pulCount : PULONG)
178 return APIRET;
179 pragma Import (C, DosQueryMutexSem, "DosQueryMutexSem");
181 ----------------
182 -- MuxWaitSem --
183 ----------------
185 function DosCreateMuxWaitSem
186 (pszName : PSZ;
187 F_phmux : PHMUX;
188 cSemRec : ULONG;
189 pSemRec : PSEMRECORD;
190 flAttr : ULONG)
191 return APIRET;
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
199 (pszName : PSZ;
200 F_phmux : PHMUX)
201 return APIRET;
202 pragma Import (C, DosOpenMuxWaitSem, "DosOpenMuxWaitSem");
204 function DosCloseMuxWaitSem
205 (F_hmux : HMUX)
206 return APIRET;
207 pragma Import (C, DosCloseMuxWaitSem, "DosCloseMuxWaitSem");
209 function DosWaitMuxWaitSem
210 (F_hmux : HMUX;
211 ulTimeout : ULONG;
212 pulUser : PULONG)
213 return APIRET;
214 pragma Import (C, DosWaitMuxWaitSem, "DosWaitMuxWaitSem");
216 function DosAddMuxWaitSem
217 (F_hmux : HMUX;
218 pSemRec : PSEMRECORD)
219 return APIRET;
220 pragma Import (C, DosAddMuxWaitSem, "DosAddMuxWaitSem");
222 function DosDeleteMuxWaitSem
223 (F_hmux : HMUX;
224 F_hsem : HSEM)
225 return APIRET;
226 pragma Import (C, DosDeleteMuxWaitSem, "DosDeleteMuxWaitSem");
228 function DosQueryMuxWaitSem
229 (F_hmux : HMUX;
230 pcSemRec : PULONG;
231 pSemRec : PSEMRECORD;
232 pflAttr : PULONG)
233 return APIRET;
234 pragma Import (C, DosQueryMuxWaitSem, "DosQueryMuxWaitSem");
236 -----------
237 -- Timer --
238 -----------
240 function DosAsyncTimer
241 (msec : ULONG;
242 F_hsem : HSEM;
243 F_phtimer : PHTIMER)
244 return APIRET;
245 pragma Import (C, DosAsyncTimer, "DosAsyncTimer");
247 function DosStartTimer
248 (msec : ULONG;
249 F_hsem : HSEM;
250 F_phtimer : PHTIMER)
251 return APIRET;
252 pragma Import (C, DosStartTimer, "DosStartTimer");
254 function DosStopTimer
255 (F_htimer : HTIMER)
256 return APIRET;
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)
264 return APIRET;
265 pragma Import (C, DosTmrQueryTime, "DosTmrQueryTime");
267 end Interfaces.OS2Lib.Synchronization;