1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- I N T E R F A C E S . O S 2 L I B . T H R E A D S --
9 -- Copyright (C) 1993-2005, 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, 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 ------------------------------------------------------------------------------
36 package Interfaces
.OS2Lib
.Threads
is
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
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");
94 DCWW_WAIT
: constant := 0;
95 DCWW_NOWAIT
: constant := 1;
96 -- Values for "Option" parameter in DosWaitThread call
98 ---------------------------------------------------
99 -- Accessing properties of Threads and Processes --
100 ---------------------------------------------------
102 -- Structures translated from BSETIB.H
104 -- Thread Information Block (TIB)
105 -- Need documentation clarifying distinction between TIB, TIB2 ???
107 -- GB970409: Changed TIB2 structure, because the tib2_ulprio field
108 -- is not the actual priority but contains two byte fields
109 -- that hold the priority class and rank respectively.
110 -- A proper Ada style record with explicit representation
111 -- avoids this kind of errors.
117 Version
: ULONG
; -- Version number for this structure
118 Must_Complete_Count
: USHORT
; -- Must Complete count
119 Must_Complete_Force
: USHORT
; -- Must Complete force flag
122 type PTIB2
is access all TIB2
;
124 -- Thread Information Block (TIB)
127 tib_pexchain
: PVOID
; -- Head of exception handler chain
128 tib_pstack
: PVOID
; -- Pointer to base of stack
129 tib_pstacklimit
: PVOID
; -- Pointer to end of stack
130 System
: PTIB2
; -- Pointer to system specific TIB
131 tib_version
: ULONG
; -- Version number for this TIB structure
132 tib_ordinal
: ULONG
; -- Thread ordinal number
135 type PTIB
is access all TIB
;
137 -- Process Information Block (PIB)
140 pib_ulpid
: ULONG
; -- Process I.D.
141 pib_ulppid
: ULONG
; -- Parent process I.D.
142 pib_hmte
: ULONG
; -- Program (.EXE) module handle
143 pib_pchcmd
: PCHAR
; -- Command line pointer
144 pib_pchenv
: PCHAR
; -- Environment pointer
145 pib_flstatus
: ULONG
; -- Process' status bits
146 pib_ultype
: ULONG
; -- Process' type code
149 type PPIB
is access all PIB
;
151 function DosGetInfoBlocks
152 (Pptib
: access PTIB
;
153 Pppib
: access PPIB
) return APIRET
;
154 pragma Import
(C
, DosGetInfoBlocks
, "DosGetInfoBlocks");
156 -- Thread local memory
158 -- This function allocates a block of memory that is unique, or local, to
161 function DosAllocThreadLocalMemory
162 (cb
: ULONG
; -- Number of 4-byte DWORDs to allocate
163 p
: access PVOID
) -- Address of the memory block
164 return APIRET
; -- Return Code (rc)
167 Entity
=> DosAllocThreadLocalMemory
,
168 Link_Name
=> "_DosAllocThreadLocalMemory");
174 function DosSetPriority
178 PorTid
: TID
) return APIRET
;
179 pragma Import
(C
, DosSetPriority
, "DosSetPriority");
181 PRTYS_PROCESS
: constant := 0;
182 PRTYS_PROCESSTREE
: constant := 1;
183 PRTYS_THREAD
: constant := 2;
184 -- Values for "Scope" parameter in DosSetPriority call
186 PRTYC_NOCHANGE
: constant := 0;
187 PRTYC_IDLETIME
: constant := 1;
188 PRTYC_REGULAR
: constant := 2;
189 PRTYC_TIMECRITICAL
: constant := 3;
190 PRTYC_FOREGROUNDSERVER
: constant := 4;
191 -- Values for "class" parameter in DosSetPriority call
193 end Interfaces
.OS2Lib
.Threads
;