* sh.h (REG_CLASS_FROM_LETTER): Change to:
[official-gcc.git] / gcc / ada / 5wosinte.ads
blobcf9aee5a35bf1a1c2c56af41710471480d37f5a2
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- S Y S T E M . O S _ I N T E R F A C E --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1997-2003, Free Software Foundation, Inc. --
10 -- --
11 -- GNARL 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. GNARL 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 GNARL; 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 -- GNARL was developed by the GNARL team at Florida State University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 -- This is a NT (native) version of this package.
36 -- This package encapsulates all direct interfaces to OS services
37 -- that are needed by children of System.
39 -- PLEASE DO NOT add any with-clauses to this package
40 -- or remove the pragma Elaborate_Body.
41 -- It is designed to be a bottom-level (leaf) package.
43 with Interfaces.C;
44 with Interfaces.C.Strings;
46 package System.OS_Interface is
47 pragma Preelaborate;
49 subtype int is Interfaces.C.int;
50 subtype long is Interfaces.C.long;
52 -------------------
53 -- General Types --
54 -------------------
56 type DWORD is new Interfaces.C.unsigned_long;
57 type WORD is new Interfaces.C.unsigned_short;
59 -- The LARGE_INTEGER type is actually a fixed point type
60 -- that only can represent integers. The reason for this is
61 -- easier conversion to Duration or other fixed point types.
62 -- (See Operations.Clock)
64 type LARGE_INTEGER is delta 1.0 range -2.0**63 .. 2.0**63 - 1.0;
66 subtype PSZ is Interfaces.C.Strings.chars_ptr;
67 subtype PCHAR is Interfaces.C.Strings.chars_ptr;
68 subtype PVOID is System.Address;
69 Null_Void : constant PVOID := System.Null_Address;
71 type PLONG is access all Interfaces.C.long;
72 type PDWORD is access all DWORD;
74 type BOOL is new Boolean;
75 for BOOL'Size use Interfaces.C.unsigned_long'Size;
77 -------------------------
78 -- Handles for objects --
79 -------------------------
81 type HANDLE is new Interfaces.C.long;
82 type PHANDLE is access all HANDLE;
84 subtype Thread_Id is HANDLE;
86 -----------
87 -- Errno --
88 -----------
90 NO_ERROR : constant := 0;
91 FUNC_ERR : constant := -1;
93 -------------
94 -- Signals --
95 -------------
97 Max_Interrupt : constant := 31;
98 type Signal is new int range 0 .. Max_Interrupt;
99 for Signal'Size use int'Size;
101 SIGINT : constant := 2; -- interrupt (Ctrl-C)
102 SIGILL : constant := 4; -- illegal instruction (not reset)
103 SIGFPE : constant := 8; -- floating point exception
104 SIGSEGV : constant := 11; -- segmentation violation
105 SIGTERM : constant := 15; -- software termination signal from kill
106 SIGBREAK : constant := 21; -- break (Ctrl-Break)
107 SIGABRT : constant := 22; -- used by abort, replace SIGIOT in the future
109 type sigset_t is private;
111 type isr_address is access procedure (sig : int);
113 function intr_attach (sig : int; handler : isr_address) return long;
114 pragma Import (C, intr_attach, "signal");
116 Intr_Attach_Reset : constant Boolean := True;
117 -- True if intr_attach is reset after an interrupt handler is called
119 procedure kill (sig : Signal);
120 pragma Import (C, kill, "raise");
122 ---------------------
123 -- Time Management --
124 ---------------------
126 procedure Sleep (dwMilliseconds : DWORD);
127 pragma Import (Stdcall, Sleep, External_Name => "Sleep");
129 type SYSTEMTIME is record
130 wYear : WORD;
131 wMonth : WORD;
132 wDayOfWeek : WORD;
133 wDay : WORD;
134 wHour : WORD;
135 wMinute : WORD;
136 wSecond : WORD;
137 wMilliseconds : WORD;
138 end record;
140 procedure GetSystemTime (pSystemTime : access SYSTEMTIME);
141 pragma Import (Stdcall, GetSystemTime, "GetSystemTime");
143 procedure GetSystemTimeAsFileTime (lpFileTime : access Long_Long_Integer);
144 pragma Import (Stdcall, GetSystemTimeAsFileTime, "GetSystemTimeAsFileTime");
146 function SetSystemTime (pSystemTime : access SYSTEMTIME) return BOOL;
147 pragma Import (Stdcall, SetSystemTime, "SetSystemTime");
149 function FileTimeToSystemTime
150 (lpFileTime : access Long_Long_Integer;
151 lpSystemTime : access SYSTEMTIME) return BOOL;
152 pragma Import (Stdcall, FileTimeToSystemTime, "FileTimeToSystemTime");
154 function SystemTimeToFileTime
155 (lpSystemTime : access SYSTEMTIME;
156 lpFileTime : access Long_Long_Integer) return BOOL;
157 pragma Import (Stdcall, SystemTimeToFileTime, "SystemTimeToFileTime");
159 function FileTimeToLocalFileTime
160 (lpFileTime : access Long_Long_Integer;
161 lpLocalFileTime : access Long_Long_Integer) return BOOL;
162 pragma Import (Stdcall, FileTimeToLocalFileTime, "FileTimeToLocalFileTime");
164 function LocalFileTimeToFileTime
165 (lpFileTime : access Long_Long_Integer;
166 lpLocalFileTime : access Long_Long_Integer) return BOOL;
167 pragma Import (Stdcall, LocalFileTimeToFileTime, "LocalFileTimeToFileTime");
169 function QueryPerformanceCounter
170 (lpPerformanceCount : access LARGE_INTEGER) return BOOL;
171 pragma Import
172 (Stdcall, QueryPerformanceCounter, "QueryPerformanceCounter");
174 function QueryPerformanceFrequency
175 (lpFrequency : access LARGE_INTEGER) return BOOL;
176 pragma Import
177 (Stdcall, QueryPerformanceFrequency, "QueryPerformanceFrequency");
179 -------------
180 -- Threads --
181 -------------
183 type Thread_Body is access
184 function (arg : System.Address) return System.Address;
186 procedure SwitchToThread;
187 pragma Import (Stdcall, SwitchToThread, "SwitchToThread");
189 -----------------------
190 -- Critical sections --
191 -----------------------
193 type CRITICAL_SECTION is private;
194 type PCRITICAL_SECTION is access all CRITICAL_SECTION;
196 procedure InitializeCriticalSection (pCriticalSection : PCRITICAL_SECTION);
197 pragma Import
198 (Stdcall, InitializeCriticalSection, "InitializeCriticalSection");
200 procedure EnterCriticalSection (pCriticalSection : PCRITICAL_SECTION);
201 pragma Import (Stdcall, EnterCriticalSection, "EnterCriticalSection");
203 procedure LeaveCriticalSection (pCriticalSection : PCRITICAL_SECTION);
204 pragma Import (Stdcall, LeaveCriticalSection, "LeaveCriticalSection");
206 procedure DeleteCriticalSection (pCriticalSection : PCRITICAL_SECTION);
207 pragma Import (Stdcall, DeleteCriticalSection, "DeleteCriticalSection");
209 -------------------------------------------------------------
210 -- Thread Creation, Activation, Suspension And Termination --
211 -------------------------------------------------------------
213 type PTHREAD_START_ROUTINE is access function
214 (pThreadParameter : PVOID) return DWORD;
215 pragma Convention (Stdcall, PTHREAD_START_ROUTINE);
217 type SECURITY_ATTRIBUTES is record
218 nLength : DWORD;
219 pSecurityDescriptor : PVOID;
220 bInheritHandle : BOOL;
221 end record;
223 type PSECURITY_ATTRIBUTES is access all SECURITY_ATTRIBUTES;
225 function CreateThread
226 (pThreadAttributes : PSECURITY_ATTRIBUTES;
227 dwStackSize : DWORD;
228 pStartAddress : PTHREAD_START_ROUTINE;
229 pParameter : PVOID;
230 dwCreationFlags : DWORD;
231 pThreadId : PDWORD) return HANDLE;
232 pragma Import (Stdcall, CreateThread, "CreateThread");
234 function BeginThreadEx
235 (pThreadAttributes : PSECURITY_ATTRIBUTES;
236 dwStackSize : DWORD;
237 pStartAddress : PTHREAD_START_ROUTINE;
238 pParameter : PVOID;
239 dwCreationFlags : DWORD;
240 pThreadId : PDWORD) return HANDLE;
241 pragma Import (C, BeginThreadEx, "_beginthreadex");
243 Debug_Process : constant := 16#00000001#;
244 Debug_Only_This_Process : constant := 16#00000002#;
245 Create_Suspended : constant := 16#00000004#;
246 Detached_Process : constant := 16#00000008#;
247 Create_New_Console : constant := 16#00000010#;
249 Create_New_Process_Group : constant := 16#00000200#;
251 Create_No_window : constant := 16#08000000#;
253 Profile_User : constant := 16#10000000#;
254 Profile_Kernel : constant := 16#20000000#;
255 Profile_Server : constant := 16#40000000#;
257 function GetExitCodeThread
258 (hThread : HANDLE;
259 pExitCode : PDWORD) return BOOL;
260 pragma Import (Stdcall, GetExitCodeThread, "GetExitCodeThread");
262 function ResumeThread (hThread : HANDLE) return DWORD;
263 pragma Import (Stdcall, ResumeThread, "ResumeThread");
265 function SuspendThread (hThread : HANDLE) return DWORD;
266 pragma Import (Stdcall, SuspendThread, "SuspendThread");
268 procedure ExitThread (dwExitCode : DWORD);
269 pragma Import (Stdcall, ExitThread, "ExitThread");
271 procedure EndThreadEx (dwExitCode : DWORD);
272 pragma Import (C, EndThreadEx, "_endthreadex");
274 function TerminateThread
275 (hThread : HANDLE;
276 dwExitCode : DWORD) return BOOL;
277 pragma Import (Stdcall, TerminateThread, "TerminateThread");
279 function GetCurrentThread return HANDLE;
280 pragma Import (Stdcall, GetCurrentThread, "GetCurrentThread");
282 function GetCurrentProcess return HANDLE;
283 pragma Import (Stdcall, GetCurrentProcess, "GetCurrentProcess");
285 function GetCurrentThreadId return DWORD;
286 pragma Import (Stdcall, GetCurrentThreadId, "GetCurrentThreadId");
288 function TlsAlloc return DWORD;
289 pragma Import (Stdcall, TlsAlloc, "TlsAlloc");
291 function TlsGetValue (dwTlsIndex : DWORD) return PVOID;
292 pragma Import (Stdcall, TlsGetValue, "TlsGetValue");
294 function TlsSetValue (dwTlsIndex : DWORD; pTlsValue : PVOID) return BOOL;
295 pragma Import (Stdcall, TlsSetValue, "TlsSetValue");
297 function TlsFree (dwTlsIndex : DWORD) return BOOL;
298 pragma Import (Stdcall, TlsFree, "TlsFree");
300 TLS_Nothing : constant := DWORD'Last;
302 procedure ExitProcess (uExitCode : Interfaces.C.unsigned);
303 pragma Import (Stdcall, ExitProcess, "ExitProcess");
305 function WaitForSingleObject
306 (hHandle : HANDLE;
307 dwMilliseconds : DWORD) return DWORD;
308 pragma Import (Stdcall, WaitForSingleObject, "WaitForSingleObject");
310 function WaitForSingleObjectEx
311 (hHandle : HANDLE;
312 dwMilliseconds : DWORD;
313 fAlertable : BOOL) return DWORD;
314 pragma Import (Stdcall, WaitForSingleObjectEx, "WaitForSingleObjectEx");
316 Wait_Infinite : constant := DWORD'Last;
317 WAIT_TIMEOUT : constant := 16#0000_0102#;
318 WAIT_FAILED : constant := 16#FFFF_FFFF#;
320 ------------------------------------
321 -- Semaphores, Events and Mutexes --
322 ------------------------------------
324 function CloseHandle (hObject : HANDLE) return BOOL;
325 pragma Import (Stdcall, CloseHandle, "CloseHandle");
327 function CreateSemaphore
328 (pSemaphoreAttributes : PSECURITY_ATTRIBUTES;
329 lInitialCount : Interfaces.C.long;
330 lMaximumCount : Interfaces.C.long;
331 pName : PSZ) return HANDLE;
332 pragma Import (Stdcall, CreateSemaphore, "CreateSemaphoreA");
334 function OpenSemaphore
335 (dwDesiredAccess : DWORD;
336 bInheritHandle : BOOL;
337 pName : PSZ) return HANDLE;
338 pragma Import (Stdcall, OpenSemaphore, "OpenSemaphoreA");
340 function ReleaseSemaphore
341 (hSemaphore : HANDLE;
342 lReleaseCount : Interfaces.C.long;
343 pPreviousCount : PLONG) return BOOL;
344 pragma Import (Stdcall, ReleaseSemaphore, "ReleaseSemaphore");
346 function CreateEvent
347 (pEventAttributes : PSECURITY_ATTRIBUTES;
348 bManualReset : BOOL;
349 bInitialState : BOOL;
350 pName : PSZ) return HANDLE;
351 pragma Import (Stdcall, CreateEvent, "CreateEventA");
353 function OpenEvent
354 (dwDesiredAccess : DWORD;
355 bInheritHandle : BOOL;
356 pName : PSZ) return HANDLE;
357 pragma Import (Stdcall, OpenEvent, "OpenEventA");
359 function SetEvent (hEvent : HANDLE) return BOOL;
360 pragma Import (Stdcall, SetEvent, "SetEvent");
362 function ResetEvent (hEvent : HANDLE) return BOOL;
363 pragma Import (Stdcall, ResetEvent, "ResetEvent");
365 function PulseEvent (hEvent : HANDLE) return BOOL;
366 pragma Import (Stdcall, PulseEvent, "PulseEvent");
368 function CreateMutex
369 (pMutexAttributes : PSECURITY_ATTRIBUTES;
370 bInitialOwner : BOOL;
371 pName : PSZ) return HANDLE;
372 pragma Import (Stdcall, CreateMutex, "CreateMutexA");
374 function OpenMutex
375 (dwDesiredAccess : DWORD;
376 bInheritHandle : BOOL;
377 pName : PSZ) return HANDLE;
378 pragma Import (Stdcall, OpenMutex, "OpenMutexA");
380 function ReleaseMutex (hMutex : HANDLE) return BOOL;
381 pragma Import (Stdcall, ReleaseMutex, "ReleaseMutex");
383 ---------------------------------------------------
384 -- Accessing properties of Threads and Processes --
385 ---------------------------------------------------
387 -----------------
388 -- Priorities --
389 -----------------
391 function SetThreadPriority
392 (hThread : HANDLE;
393 nPriority : Interfaces.C.int) return BOOL;
394 pragma Import (Stdcall, SetThreadPriority, "SetThreadPriority");
396 function GetThreadPriority (hThread : HANDLE) return Interfaces.C.int;
397 pragma Import (Stdcall, GetThreadPriority, "GetThreadPriority");
399 function SetPriorityClass
400 (hProcess : HANDLE;
401 dwPriorityClass : DWORD) return BOOL;
402 pragma Import (Stdcall, SetPriorityClass, "SetPriorityClass");
404 procedure SetThreadPriorityBoost
405 (hThread : HANDLE;
406 DisablePriorityBoost : BOOL);
407 pragma Import (Stdcall, SetThreadPriorityBoost, "SetThreadPriorityBoost");
409 Normal_Priority_Class : constant := 16#00000020#;
410 Idle_Priority_Class : constant := 16#00000040#;
411 High_Priority_Class : constant := 16#00000080#;
412 Realtime_Priority_Class : constant := 16#00000100#;
414 Thread_Priority_Idle : constant := -15;
415 Thread_Priority_Lowest : constant := -2;
416 Thread_Priority_Below_Normal : constant := -1;
417 Thread_Priority_Normal : constant := 0;
418 Thread_Priority_Above_Normal : constant := 1;
419 Thread_Priority_Highest : constant := 2;
420 Thread_Priority_Time_Critical : constant := 15;
421 Thread_Priority_Error_Return : constant := Interfaces.C.long'Last;
423 function GetLastError return DWORD;
424 pragma Import (Stdcall, GetLastError, "GetLastError");
426 private
428 type sigset_t is new Interfaces.C.unsigned_long;
430 type CRITICAL_SECTION is record
431 DebugInfo : System.Address;
432 -- The following three fields control entering and
433 -- exiting the critical section for the resource
434 LockCount : Long_Integer;
435 RecursionCount : Long_Integer;
436 OwningThread : HANDLE;
437 LockSemaphore : HANDLE;
438 Reserved : DWORD;
439 end record;
441 end System.OS_Interface;