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 --
10 -- Copyright (C) 1993-1997 Free Software Foundation, Inc. --
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. --
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. --
30 -- GNAT was originally developed by the GNAT team at New York University. --
31 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
33 ------------------------------------------------------------------------------
37 package Interfaces
.OS2Lib
.Threads
is
38 pragma Preelaborate
(Threads
);
40 package IC
renames Interfaces
.C
;
42 type PID
is new IC
.unsigned_long
;
43 type PPID
is access all PID
;
44 -- Process ID, and pointer to process ID
46 type TID
is new IC
.unsigned_long
;
47 type PTID
is access all TID
;
48 -- Thread ID, and pointer to thread ID
50 -------------------------------------------------------------
51 -- Thread Creation, Activation, Suspension And Termination --
52 -------------------------------------------------------------
54 -- Note: <bsedos.h> defines the "Informations" and "param" parameter below
55 -- as a ULONG, but everyone knows that in general an address will be passed
56 -- to it. We declared it here with type PVOID (which it should have had)
57 -- because Ada is a bit more sensitive to mixing integers and addresses.
59 type PFNTHREAD
is access procedure (Informations
: System
.Address
);
60 -- TBSL should use PVOID instead of Address as per above node ???
62 function DosCreateThread
69 pragma Import
(C
, DosCreateThread
, "DosCreateThread");
71 Block_Child
: constant := 1;
72 No_Block_Child
: constant := 0;
73 Commit_Stack
: constant := 2;
74 No_Commit_Stack
: constant := 0;
75 -- Values for "flag" parameter in DosCreateThread call
77 procedure DosExit
(Action
: ULONG
; Result
: ULONG
);
78 pragma Import
(C
, DosExit
, "DosExit");
80 EXIT_THREAD
: constant := 0;
81 EXIT_PROCESS
: constant := 1;
82 -- Values for "Action" parameter in Dos_Exit call
84 function DosResumeThread
(Id
: TID
) return APIRET
;
85 pragma Import
(C
, DosResumeThread
, "DosResumeThread");
87 function DosSuspendThread
(Id
: TID
) return APIRET
;
88 pragma Import
(C
, DosSuspendThread
, "DosSuspendThread");
90 procedure DosWaitThread
(Thread_Ptr
: PTID
; Option
: ULONG
);
91 pragma Import
(C
, DosWaitThread
, "DosWaitThread");
93 function DosKillThread
(Id
: TID
) return APIRET
;
94 pragma Import
(C
, DosKillThread
, "DosKillThread");
97 DCWW_WAIT
: constant := 0;
98 DCWW_NOWAIT
: constant := 1;
99 -- Values for "Option" parameter in DosWaitThread call
101 ---------------------------------------------------
102 -- Accessing properties of Threads and Processes --
103 ---------------------------------------------------
105 -- Structures translated from BSETIB.H
107 -- Thread Information Block (TIB)
108 -- Need documentation clarifying distinction between TIB, TIB2 ???
110 -- GB970409: Changed TIB2 structure, because the tib2_ulprio field
111 -- is not the actual priority but contains two byte fields
112 -- that hold the priority class and rank respectively.
113 -- A proper Ada style record with explicit representation
114 -- avoids this kind of errors.
120 Version
: ULONG
; -- Version number for this structure
121 Must_Complete_Count
: USHORT
; -- Must Complete count
122 Must_Complete_Force
: USHORT
; -- Must Complete force flag
125 type PTIB2
is access all TIB2
;
127 -- Thread Information Block (TIB)
130 tib_pexchain
: PVOID
; -- Head of exception handler chain
131 tib_pstack
: PVOID
; -- Pointer to base of stack
132 tib_pstacklimit
: PVOID
; -- Pointer to end of stack
133 System
: PTIB2
; -- Pointer to system specific TIB
134 tib_version
: ULONG
; -- Version number for this TIB structure
135 tib_ordinal
: ULONG
; -- Thread ordinal number
138 type PTIB
is access all TIB
;
140 -- Process Information Block (PIB)
143 pib_ulpid
: ULONG
; -- Process I.D.
144 pib_ulppid
: ULONG
; -- Parent process I.D.
145 pib_hmte
: ULONG
; -- Program (.EXE) module handle
146 pib_pchcmd
: PCHAR
; -- Command line pointer
147 pib_pchenv
: PCHAR
; -- Environment pointer
148 pib_flstatus
: ULONG
; -- Process' status bits
149 pib_ultype
: ULONG
; -- Process' type code
152 type PPIB
is access all PIB
;
154 function DosGetInfoBlocks
155 (Pptib
: access PTIB
;
158 pragma Import
(C
, DosGetInfoBlocks
, "DosGetInfoBlocks");
160 -- Thread local memory
162 -- This function allocates a block of memory that is unique, or local, to
165 function DosAllocThreadLocalMemory
166 (cb
: ULONG
; -- Number of 4-byte DWORDs to allocate
167 p
: access PVOID
) -- Address of the memory block
169 APIRET
; -- Return Code (rc)
172 Entity
=> DosAllocThreadLocalMemory
,
173 Link_Name
=> "_DosAllocThreadLocalMemory");
179 function DosSetPriority
185 pragma Import
(C
, DosSetPriority
, "DosSetPriority");
187 PRTYS_PROCESS
: constant := 0;
188 PRTYS_PROCESSTREE
: constant := 1;
189 PRTYS_THREAD
: constant := 2;
190 -- Values for "Scope" parameter in DosSetPriority call
192 PRTYC_NOCHANGE
: constant := 0;
193 PRTYC_IDLETIME
: constant := 1;
194 PRTYC_REGULAR
: constant := 2;
195 PRTYC_TIMECRITICAL
: constant := 3;
196 PRTYC_FOREGROUNDSERVER
: constant := 4;
197 -- Values for "class" parameter in DosSetPriority call
199 end Interfaces
.OS2Lib
.Threads
;