PR tree-optimization/19853
[official-gcc.git] / gcc / ada / i-os2thr.ads
blob0c3f3aa55030ac184e6e642651b300774f72cf4b
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- I N T E R F A C E S . O S 2 L I B . T H R E A D S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1993-2004 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.C;
36 package Interfaces.OS2Lib.Threads is
37 pragma Preelaborate (Threads);
39 package IC renames Interfaces.C;
41 type PID is new IC.unsigned_long;
42 type PPID is access all PID;
43 -- Process ID, and pointer to process ID
45 type TID is new IC.unsigned_long;
46 type PTID is access all TID;
47 -- Thread ID, and pointer to thread ID
49 -------------------------------------------------------------
50 -- Thread Creation, Activation, Suspension And Termination --
51 -------------------------------------------------------------
53 -- Note: <bsedos.h> defines the "Informations" and "param" parameter below
54 -- as a ULONG, but everyone knows that in general an address will be passed
55 -- to it. We declared it here with type PVOID (which it should have had)
56 -- because Ada is a bit more sensitive to mixing integers and addresses.
58 type PFNTHREAD is access procedure (Informations : System.Address);
59 -- TBSL should use PVOID instead of Address as per above node ???
61 function DosCreateThread
62 (F_ptid : PTID;
63 pfn : PFNTHREAD;
64 param : PVOID;
65 flag : ULONG;
66 cbStack : ULONG) return APIRET;
67 pragma Import (C, DosCreateThread, "DosCreateThread");
69 Block_Child : constant := 1;
70 No_Block_Child : constant := 0;
71 Commit_Stack : constant := 2;
72 No_Commit_Stack : constant := 0;
73 -- Values for "flag" parameter in DosCreateThread call
75 procedure DosExit (Action : ULONG; Result : ULONG);
76 pragma Import (C, DosExit, "DosExit");
78 EXIT_THREAD : constant := 0;
79 EXIT_PROCESS : constant := 1;
80 -- Values for "Action" parameter in Dos_Exit call
82 function DosResumeThread (Id : TID) return APIRET;
83 pragma Import (C, DosResumeThread, "DosResumeThread");
85 function DosSuspendThread (Id : TID) return APIRET;
86 pragma Import (C, DosSuspendThread, "DosSuspendThread");
88 procedure DosWaitThread (Thread_Ptr : PTID; Option : ULONG);
89 pragma Import (C, DosWaitThread, "DosWaitThread");
91 function DosKillThread (Id : TID) return APIRET;
92 pragma Import (C, DosKillThread, "DosKillThread");
95 DCWW_WAIT : constant := 0;
96 DCWW_NOWAIT : constant := 1;
97 -- Values for "Option" parameter in DosWaitThread call
99 ---------------------------------------------------
100 -- Accessing properties of Threads and Processes --
101 ---------------------------------------------------
103 -- Structures translated from BSETIB.H
105 -- Thread Information Block (TIB)
106 -- Need documentation clarifying distinction between TIB, TIB2 ???
108 -- GB970409: Changed TIB2 structure, because the tib2_ulprio field
109 -- is not the actual priority but contains two byte fields
110 -- that hold the priority class and rank respectively.
111 -- A proper Ada style record with explicit representation
112 -- avoids this kind of errors.
114 type TIB2 is record
115 Thread_ID : TID;
116 Prio_Rank : UCHAR;
117 Prio_Class : UCHAR;
118 Version : ULONG; -- Version number for this structure
119 Must_Complete_Count : USHORT; -- Must Complete count
120 Must_Complete_Force : USHORT; -- Must Complete force flag
121 end record;
123 type PTIB2 is access all TIB2;
125 -- Thread Information Block (TIB)
127 type TIB is record
128 tib_pexchain : PVOID; -- Head of exception handler chain
129 tib_pstack : PVOID; -- Pointer to base of stack
130 tib_pstacklimit : PVOID; -- Pointer to end of stack
131 System : PTIB2; -- Pointer to system specific TIB
132 tib_version : ULONG; -- Version number for this TIB structure
133 tib_ordinal : ULONG; -- Thread ordinal number
134 end record;
136 type PTIB is access all TIB;
138 -- Process Information Block (PIB)
140 type PIB is record
141 pib_ulpid : ULONG; -- Process I.D.
142 pib_ulppid : ULONG; -- Parent process I.D.
143 pib_hmte : ULONG; -- Program (.EXE) module handle
144 pib_pchcmd : PCHAR; -- Command line pointer
145 pib_pchenv : PCHAR; -- Environment pointer
146 pib_flstatus : ULONG; -- Process' status bits
147 pib_ultype : ULONG; -- Process' type code
148 end record;
150 type PPIB is access all PIB;
152 function DosGetInfoBlocks
153 (Pptib : access PTIB;
154 Pppib : access PPIB) return APIRET;
155 pragma Import (C, DosGetInfoBlocks, "DosGetInfoBlocks");
157 -- Thread local memory
159 -- This function allocates a block of memory that is unique, or local, to
160 -- a thread.
162 function DosAllocThreadLocalMemory
163 (cb : ULONG; -- Number of 4-byte DWORDs to allocate
164 p : access PVOID) -- Address of the memory block
165 return APIRET; -- Return Code (rc)
166 pragma Import
167 (Convention => C,
168 Entity => DosAllocThreadLocalMemory,
169 Link_Name => "_DosAllocThreadLocalMemory");
171 ----------------
172 -- Priorities --
173 ----------------
175 function DosSetPriority
176 (Scope : ULONG;
177 Class : ULONG;
178 Delta_P : IC.long;
179 PorTid : TID) return APIRET;
180 pragma Import (C, DosSetPriority, "DosSetPriority");
182 PRTYS_PROCESS : constant := 0;
183 PRTYS_PROCESSTREE : constant := 1;
184 PRTYS_THREAD : constant := 2;
185 -- Values for "Scope" parameter in DosSetPriority call
187 PRTYC_NOCHANGE : constant := 0;
188 PRTYC_IDLETIME : constant := 1;
189 PRTYC_REGULAR : constant := 2;
190 PRTYC_TIMECRITICAL : constant := 3;
191 PRTYC_FOREGROUNDSERVER : constant := 4;
192 -- Values for "class" parameter in DosSetPriority call
194 end Interfaces.OS2Lib.Threads;