1 |
281 |
jeremybenn |
------------------------------------------------------------------------------
|
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-2009 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 3, 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. --
|
17 |
|
|
-- --
|
18 |
|
|
-- As a special exception under Section 7 of GPL version 3, you are granted --
|
19 |
|
|
-- additional permissions described in the GCC Runtime Library Exception, --
|
20 |
|
|
-- version 3.1, as published by the Free Software Foundation. --
|
21 |
|
|
-- --
|
22 |
|
|
-- You should have received a copy of the GNU General Public License and --
|
23 |
|
|
-- a copy of the GCC Runtime Library Exception along with this program; --
|
24 |
|
|
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
|
25 |
|
|
-- <http://www.gnu.org/licenses/>. --
|
26 |
|
|
-- --
|
27 |
|
|
-- GNARL was developed by the GNARL team at Florida State University. --
|
28 |
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
29 |
|
|
-- --
|
30 |
|
|
-- The GNARL files that were developed for RTEMS are maintained by On-Line --
|
31 |
|
|
-- Applications Research Corporation (http://www.oarcorp.com) in coopera- --
|
32 |
|
|
-- tion with Ada Core Technologies Inc. and Florida State University. --
|
33 |
|
|
-- --
|
34 |
|
|
------------------------------------------------------------------------------
|
35 |
|
|
|
36 |
|
|
-- This is the RTEMS version of this package.
|
37 |
|
|
--
|
38 |
|
|
-- RTEMS target names are of the form CPU-rtems.
|
39 |
|
|
-- This implementation is designed to work on ALL RTEMS targets.
|
40 |
|
|
-- The RTEMS implementation is primarily based upon the POSIX threads
|
41 |
|
|
-- API but there are also bindings to GNAT/RTEMS support routines
|
42 |
|
|
-- to insulate this code from C API specific details and, in some
|
43 |
|
|
-- cases, obtain target architecture and BSP specific information
|
44 |
|
|
-- that is unavailable at the time this package is built.
|
45 |
|
|
|
46 |
|
|
-- This package encapsulates all direct interfaces to OS services
|
47 |
|
|
-- that are needed by children of System.
|
48 |
|
|
|
49 |
|
|
-- PLEASE DO NOT add any with-clauses to this package
|
50 |
|
|
-- or remove the pragma Preelaborate.
|
51 |
|
|
-- It is designed to be a bottom-level (leaf) package.
|
52 |
|
|
|
53 |
|
|
with Interfaces.C;
|
54 |
|
|
package System.OS_Interface is
|
55 |
|
|
pragma Preelaborate;
|
56 |
|
|
|
57 |
|
|
-- This interface assumes that "unsigned" is a 32-bit entity. This
|
58 |
|
|
-- will correspond to RTEMS object ids.
|
59 |
|
|
|
60 |
|
|
subtype rtems_id is Interfaces.C.unsigned;
|
61 |
|
|
|
62 |
|
|
subtype int is Interfaces.C.int;
|
63 |
|
|
subtype short is Interfaces.C.short;
|
64 |
|
|
subtype long is Interfaces.C.long;
|
65 |
|
|
subtype unsigned is Interfaces.C.unsigned;
|
66 |
|
|
subtype unsigned_short is Interfaces.C.unsigned_short;
|
67 |
|
|
subtype unsigned_long is Interfaces.C.unsigned_long;
|
68 |
|
|
subtype unsigned_char is Interfaces.C.unsigned_char;
|
69 |
|
|
subtype plain_char is Interfaces.C.plain_char;
|
70 |
|
|
subtype size_t is Interfaces.C.size_t;
|
71 |
|
|
|
72 |
|
|
-----------
|
73 |
|
|
-- Errno --
|
74 |
|
|
-----------
|
75 |
|
|
|
76 |
|
|
function errno return int;
|
77 |
|
|
pragma Import (C, errno, "__get_errno");
|
78 |
|
|
|
79 |
|
|
EAGAIN : constant := 11;
|
80 |
|
|
EINTR : constant := 4;
|
81 |
|
|
EINVAL : constant := 22;
|
82 |
|
|
ENOMEM : constant := 12;
|
83 |
|
|
ETIMEDOUT : constant := 116;
|
84 |
|
|
|
85 |
|
|
-------------
|
86 |
|
|
-- Signals --
|
87 |
|
|
-------------
|
88 |
|
|
|
89 |
|
|
Num_HW_Interrupts : constant := 256;
|
90 |
|
|
|
91 |
|
|
Max_HW_Interrupt : constant := Num_HW_Interrupts - 1;
|
92 |
|
|
type HW_Interrupt is new int range 0 .. Max_HW_Interrupt;
|
93 |
|
|
|
94 |
|
|
Max_Interrupt : constant := Max_HW_Interrupt;
|
95 |
|
|
|
96 |
|
|
type Signal is new int range 0 .. Max_Interrupt;
|
97 |
|
|
|
98 |
|
|
SIGXCPU : constant := 0; -- XCPU
|
99 |
|
|
SIGHUP : constant := 1; -- hangup
|
100 |
|
|
SIGINT : constant := 2; -- interrupt (rubout)
|
101 |
|
|
SIGQUIT : constant := 3; -- quit (ASCD FS)
|
102 |
|
|
SIGILL : constant := 4; -- illegal instruction (not reset)
|
103 |
|
|
SIGTRAP : constant := 5; -- trace trap (not reset)
|
104 |
|
|
SIGIOT : constant := 6; -- IOT instruction
|
105 |
|
|
SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
|
106 |
|
|
SIGEMT : constant := 7; -- EMT instruction
|
107 |
|
|
SIGFPE : constant := 8; -- floating point exception
|
108 |
|
|
SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
|
109 |
|
|
SIGBUS : constant := 10; -- bus error
|
110 |
|
|
SIGSEGV : constant := 11; -- segmentation violation
|
111 |
|
|
SIGSYS : constant := 12; -- bad argument to system call
|
112 |
|
|
SIGPIPE : constant := 13; -- write on a pipe with no one to read it
|
113 |
|
|
SIGALRM : constant := 14; -- alarm clock
|
114 |
|
|
SIGTERM : constant := 15; -- software termination signal from kill
|
115 |
|
|
SIGUSR1 : constant := 16; -- user defined signal 1
|
116 |
|
|
SIGUSR2 : constant := 17; -- user defined signal 2
|
117 |
|
|
|
118 |
|
|
SIGADAABORT : constant := SIGABRT;
|
119 |
|
|
|
120 |
|
|
type Signal_Set is array (Natural range <>) of Signal;
|
121 |
|
|
|
122 |
|
|
Unmasked : constant Signal_Set := (SIGTRAP, SIGALRM, SIGEMT);
|
123 |
|
|
Reserved : constant Signal_Set := (1 .. 1 => SIGKILL);
|
124 |
|
|
|
125 |
|
|
type sigset_t is private;
|
126 |
|
|
|
127 |
|
|
function sigaddset (set : access sigset_t; sig : Signal) return int;
|
128 |
|
|
pragma Import (C, sigaddset, "sigaddset");
|
129 |
|
|
|
130 |
|
|
function sigdelset (set : access sigset_t; sig : Signal) return int;
|
131 |
|
|
pragma Import (C, sigdelset, "sigdelset");
|
132 |
|
|
|
133 |
|
|
function sigfillset (set : access sigset_t) return int;
|
134 |
|
|
pragma Import (C, sigfillset, "sigfillset");
|
135 |
|
|
|
136 |
|
|
function sigismember (set : access sigset_t; sig : Signal) return int;
|
137 |
|
|
pragma Import (C, sigismember, "sigismember");
|
138 |
|
|
|
139 |
|
|
function sigemptyset (set : access sigset_t) return int;
|
140 |
|
|
pragma Import (C, sigemptyset, "sigemptyset");
|
141 |
|
|
|
142 |
|
|
type struct_sigaction is record
|
143 |
|
|
sa_flags : int;
|
144 |
|
|
sa_mask : sigset_t;
|
145 |
|
|
sa_handler : System.Address;
|
146 |
|
|
end record;
|
147 |
|
|
pragma Convention (C, struct_sigaction);
|
148 |
|
|
type struct_sigaction_ptr is access all struct_sigaction;
|
149 |
|
|
|
150 |
|
|
SA_SIGINFO : constant := 16#02#;
|
151 |
|
|
|
152 |
|
|
SA_ONSTACK : constant := 16#00#;
|
153 |
|
|
-- SA_ONSTACK is not defined on RTEMS, but it is referred to in the POSIX
|
154 |
|
|
-- implementation of System.Interrupt_Management. Therefore we define a
|
155 |
|
|
-- dummy value of zero here so that setting this flag is a nop.
|
156 |
|
|
|
157 |
|
|
SIG_BLOCK : constant := 1;
|
158 |
|
|
SIG_UNBLOCK : constant := 2;
|
159 |
|
|
SIG_SETMASK : constant := 3;
|
160 |
|
|
|
161 |
|
|
SIG_DFL : constant := 0;
|
162 |
|
|
SIG_IGN : constant := 1;
|
163 |
|
|
|
164 |
|
|
function sigaction
|
165 |
|
|
(sig : Signal;
|
166 |
|
|
act : struct_sigaction_ptr;
|
167 |
|
|
oact : struct_sigaction_ptr) return int;
|
168 |
|
|
pragma Import (C, sigaction, "sigaction");
|
169 |
|
|
|
170 |
|
|
----------
|
171 |
|
|
-- Time --
|
172 |
|
|
----------
|
173 |
|
|
|
174 |
|
|
Time_Slice_Supported : constant Boolean := True;
|
175 |
|
|
-- Indicates whether time slicing is supported (i.e SCHED_RR is supported)
|
176 |
|
|
|
177 |
|
|
type timespec is private;
|
178 |
|
|
|
179 |
|
|
type clockid_t is private;
|
180 |
|
|
|
181 |
|
|
CLOCK_REALTIME : constant clockid_t;
|
182 |
|
|
|
183 |
|
|
function clock_gettime
|
184 |
|
|
(clock_id : clockid_t;
|
185 |
|
|
tp : access timespec) return int;
|
186 |
|
|
pragma Import (C, clock_gettime, "clock_gettime");
|
187 |
|
|
|
188 |
|
|
function To_Duration (TS : timespec) return Duration;
|
189 |
|
|
pragma Inline (To_Duration);
|
190 |
|
|
|
191 |
|
|
function To_Timespec (D : Duration) return timespec;
|
192 |
|
|
pragma Inline (To_Timespec);
|
193 |
|
|
|
194 |
|
|
-------------------------
|
195 |
|
|
-- Priority Scheduling --
|
196 |
|
|
-------------------------
|
197 |
|
|
|
198 |
|
|
SCHED_FIFO : constant := 1;
|
199 |
|
|
SCHED_RR : constant := 2;
|
200 |
|
|
SCHED_OTHER : constant := 0;
|
201 |
|
|
|
202 |
|
|
function To_Target_Priority
|
203 |
|
|
(Prio : System.Any_Priority) return Interfaces.C.int;
|
204 |
|
|
-- Maps System.Any_Priority to a POSIX priority
|
205 |
|
|
|
206 |
|
|
-------------
|
207 |
|
|
-- Process --
|
208 |
|
|
-------------
|
209 |
|
|
|
210 |
|
|
type pid_t is private;
|
211 |
|
|
|
212 |
|
|
function kill (pid : pid_t; sig : Signal) return int;
|
213 |
|
|
pragma Import (C, kill, "kill");
|
214 |
|
|
|
215 |
|
|
function getpid return pid_t;
|
216 |
|
|
pragma Import (C, getpid, "getpid");
|
217 |
|
|
|
218 |
|
|
---------
|
219 |
|
|
-- LWP --
|
220 |
|
|
---------
|
221 |
|
|
|
222 |
|
|
function lwp_self return System.Address;
|
223 |
|
|
-- lwp_self does not exist on this thread library, revert to pthread_self
|
224 |
|
|
-- which is the closest approximation (with getpid). This function is
|
225 |
|
|
-- needed to share 7staprop.adb across POSIX-like targets.
|
226 |
|
|
pragma Import (C, lwp_self, "pthread_self");
|
227 |
|
|
|
228 |
|
|
-------------
|
229 |
|
|
-- Threads --
|
230 |
|
|
-------------
|
231 |
|
|
|
232 |
|
|
type Thread_Body is access
|
233 |
|
|
function (arg : System.Address) return System.Address;
|
234 |
|
|
pragma Convention (C, Thread_Body);
|
235 |
|
|
|
236 |
|
|
type pthread_t is private;
|
237 |
|
|
subtype Thread_Id is pthread_t;
|
238 |
|
|
|
239 |
|
|
type pthread_mutex_t is limited private;
|
240 |
|
|
type pthread_cond_t is limited private;
|
241 |
|
|
type pthread_attr_t is limited private;
|
242 |
|
|
type pthread_mutexattr_t is limited private;
|
243 |
|
|
type pthread_condattr_t is limited private;
|
244 |
|
|
type pthread_key_t is private;
|
245 |
|
|
|
246 |
|
|
No_Key : constant pthread_key_t;
|
247 |
|
|
|
248 |
|
|
PTHREAD_CREATE_DETACHED : constant := 0;
|
249 |
|
|
|
250 |
|
|
PTHREAD_SCOPE_PROCESS : constant := 0;
|
251 |
|
|
PTHREAD_SCOPE_SYSTEM : constant := 1;
|
252 |
|
|
|
253 |
|
|
-----------
|
254 |
|
|
-- Stack --
|
255 |
|
|
-----------
|
256 |
|
|
|
257 |
|
|
type stack_t is record
|
258 |
|
|
ss_sp : System.Address;
|
259 |
|
|
ss_flags : int;
|
260 |
|
|
ss_size : size_t;
|
261 |
|
|
end record;
|
262 |
|
|
pragma Convention (C, stack_t);
|
263 |
|
|
|
264 |
|
|
function sigaltstack
|
265 |
|
|
(ss : not null access stack_t;
|
266 |
|
|
oss : access stack_t) return int;
|
267 |
|
|
|
268 |
|
|
Alternate_Stack : aliased System.Address;
|
269 |
|
|
-- This is a dummy definition, never used (Alternate_Stack_Size is null)
|
270 |
|
|
|
271 |
|
|
Alternate_Stack_Size : constant := 0;
|
272 |
|
|
-- No alternate signal stack is used on this platform
|
273 |
|
|
|
274 |
|
|
Stack_Base_Available : constant Boolean := False;
|
275 |
|
|
-- Indicates whether the stack base is available on this target.
|
276 |
|
|
-- This allows us to share s-osinte.adb between all the FSU/RTEMS
|
277 |
|
|
-- run time.
|
278 |
|
|
-- Note that this value can only be true if pthread_t has a complete
|
279 |
|
|
-- definition that corresponds exactly to the C header files.
|
280 |
|
|
|
281 |
|
|
function Get_Stack_Base (thread : pthread_t) return Address;
|
282 |
|
|
pragma Inline (Get_Stack_Base);
|
283 |
|
|
-- returns the stack base of the specified thread.
|
284 |
|
|
-- Only call this function when Stack_Base_Available is True.
|
285 |
|
|
|
286 |
|
|
-- These two functions are only needed to share s-taprop.adb with
|
287 |
|
|
-- FSU threads.
|
288 |
|
|
|
289 |
|
|
function Get_Page_Size return size_t;
|
290 |
|
|
function Get_Page_Size return Address;
|
291 |
|
|
pragma Import (C, Get_Page_Size, "getpagesize");
|
292 |
|
|
-- Returns the size of a page
|
293 |
|
|
|
294 |
|
|
PROT_ON : constant := 0;
|
295 |
|
|
PROT_OFF : constant := 0;
|
296 |
|
|
|
297 |
|
|
function mprotect (addr : Address; len : size_t; prot : int) return int;
|
298 |
|
|
pragma Import (C, mprotect);
|
299 |
|
|
|
300 |
|
|
-----------------------------------------
|
301 |
|
|
-- Nonstandard Thread Initialization --
|
302 |
|
|
-----------------------------------------
|
303 |
|
|
|
304 |
|
|
procedure pthread_init;
|
305 |
|
|
-- FSU_THREADS requires pthread_init, which is nonstandard
|
306 |
|
|
-- and this should be invoked during the elaboration of s-taprop.adb
|
307 |
|
|
--
|
308 |
|
|
-- RTEMS does not require this so we provide an empty Ada body.
|
309 |
|
|
|
310 |
|
|
-------------------------
|
311 |
|
|
-- POSIX.1c Section 3 --
|
312 |
|
|
-------------------------
|
313 |
|
|
|
314 |
|
|
function sigwait
|
315 |
|
|
(set : access sigset_t;
|
316 |
|
|
sig : access Signal) return int;
|
317 |
|
|
pragma Import (C, sigwait, "sigwait");
|
318 |
|
|
|
319 |
|
|
function pthread_kill
|
320 |
|
|
(thread : pthread_t;
|
321 |
|
|
sig : Signal) return int;
|
322 |
|
|
pragma Import (C, pthread_kill, "pthread_kill");
|
323 |
|
|
|
324 |
|
|
function pthread_sigmask
|
325 |
|
|
(how : int;
|
326 |
|
|
set : access sigset_t;
|
327 |
|
|
oset : access sigset_t) return int;
|
328 |
|
|
pragma Import (C, pthread_sigmask, "pthread_sigmask");
|
329 |
|
|
|
330 |
|
|
----------------------------
|
331 |
|
|
-- POSIX.1c Section 11 --
|
332 |
|
|
----------------------------
|
333 |
|
|
|
334 |
|
|
function pthread_mutexattr_init
|
335 |
|
|
(attr : access pthread_mutexattr_t) return int;
|
336 |
|
|
pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
|
337 |
|
|
|
338 |
|
|
function pthread_mutexattr_destroy
|
339 |
|
|
(attr : access pthread_mutexattr_t) return int;
|
340 |
|
|
pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
|
341 |
|
|
|
342 |
|
|
function pthread_mutex_init
|
343 |
|
|
(mutex : access pthread_mutex_t;
|
344 |
|
|
attr : access pthread_mutexattr_t) return int;
|
345 |
|
|
pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
|
346 |
|
|
|
347 |
|
|
function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
|
348 |
|
|
pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
|
349 |
|
|
|
350 |
|
|
function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
|
351 |
|
|
pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
|
352 |
|
|
|
353 |
|
|
function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
|
354 |
|
|
pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
|
355 |
|
|
|
356 |
|
|
function pthread_condattr_init
|
357 |
|
|
(attr : access pthread_condattr_t) return int;
|
358 |
|
|
pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
|
359 |
|
|
|
360 |
|
|
function pthread_condattr_destroy
|
361 |
|
|
(attr : access pthread_condattr_t) return int;
|
362 |
|
|
pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
|
363 |
|
|
|
364 |
|
|
function pthread_cond_init
|
365 |
|
|
(cond : access pthread_cond_t;
|
366 |
|
|
attr : access pthread_condattr_t) return int;
|
367 |
|
|
pragma Import (C, pthread_cond_init, "pthread_cond_init");
|
368 |
|
|
|
369 |
|
|
function pthread_cond_destroy (cond : access pthread_cond_t) return int;
|
370 |
|
|
pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
|
371 |
|
|
|
372 |
|
|
function pthread_cond_signal (cond : access pthread_cond_t) return int;
|
373 |
|
|
pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
|
374 |
|
|
|
375 |
|
|
function pthread_cond_wait
|
376 |
|
|
(cond : access pthread_cond_t;
|
377 |
|
|
mutex : access pthread_mutex_t) return int;
|
378 |
|
|
pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
|
379 |
|
|
|
380 |
|
|
function pthread_cond_timedwait
|
381 |
|
|
(cond : access pthread_cond_t;
|
382 |
|
|
mutex : access pthread_mutex_t;
|
383 |
|
|
abstime : access timespec) return int;
|
384 |
|
|
pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
|
385 |
|
|
|
386 |
|
|
Relative_Timed_Wait : constant Boolean := False;
|
387 |
|
|
-- pthread_cond_timedwait requires an absolute delay time
|
388 |
|
|
|
389 |
|
|
--------------------------
|
390 |
|
|
-- POSIX.1c Section 13 --
|
391 |
|
|
--------------------------
|
392 |
|
|
|
393 |
|
|
PTHREAD_PRIO_NONE : constant := 0;
|
394 |
|
|
PTHREAD_PRIO_PROTECT : constant := 2;
|
395 |
|
|
PTHREAD_PRIO_INHERIT : constant := 1;
|
396 |
|
|
|
397 |
|
|
function pthread_mutexattr_setprotocol
|
398 |
|
|
(attr : access pthread_mutexattr_t;
|
399 |
|
|
protocol : int) return int;
|
400 |
|
|
pragma Import (C, pthread_mutexattr_setprotocol);
|
401 |
|
|
|
402 |
|
|
function pthread_mutexattr_setprioceiling
|
403 |
|
|
(attr : access pthread_mutexattr_t;
|
404 |
|
|
prioceiling : int) return int;
|
405 |
|
|
pragma Import
|
406 |
|
|
(C, pthread_mutexattr_setprioceiling,
|
407 |
|
|
"pthread_mutexattr_setprioceiling");
|
408 |
|
|
|
409 |
|
|
type struct_sched_param is record
|
410 |
|
|
sched_priority : int;
|
411 |
|
|
ss_low_priority : int;
|
412 |
|
|
ss_replenish_period : timespec;
|
413 |
|
|
ss_initial_budget : timespec;
|
414 |
|
|
end record;
|
415 |
|
|
pragma Convention (C, struct_sched_param);
|
416 |
|
|
|
417 |
|
|
function pthread_setschedparam
|
418 |
|
|
(thread : pthread_t;
|
419 |
|
|
policy : int;
|
420 |
|
|
param : access struct_sched_param) return int;
|
421 |
|
|
pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
|
422 |
|
|
|
423 |
|
|
function pthread_attr_setscope
|
424 |
|
|
(attr : access pthread_attr_t;
|
425 |
|
|
contentionscope : int) return int;
|
426 |
|
|
pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
|
427 |
|
|
|
428 |
|
|
function pthread_attr_setinheritsched
|
429 |
|
|
(attr : access pthread_attr_t;
|
430 |
|
|
inheritsched : int) return int;
|
431 |
|
|
pragma Import (C, pthread_attr_setinheritsched);
|
432 |
|
|
|
433 |
|
|
function pthread_attr_setschedpolicy
|
434 |
|
|
(attr : access pthread_attr_t;
|
435 |
|
|
policy : int) return int;
|
436 |
|
|
pragma Import (C, pthread_attr_setschedpolicy);
|
437 |
|
|
|
438 |
|
|
function pthread_attr_setschedparam
|
439 |
|
|
(attr : access pthread_attr_t;
|
440 |
|
|
sched_param : int) return int;
|
441 |
|
|
pragma Import (C, pthread_attr_setschedparam);
|
442 |
|
|
|
443 |
|
|
function sched_yield return int;
|
444 |
|
|
pragma Import (C, sched_yield, "sched_yield");
|
445 |
|
|
|
446 |
|
|
---------------------------
|
447 |
|
|
-- P1003.1c - Section 16 --
|
448 |
|
|
---------------------------
|
449 |
|
|
|
450 |
|
|
function pthread_attr_init (attributes : access pthread_attr_t) return int;
|
451 |
|
|
pragma Import (C, pthread_attr_init, "pthread_attr_init");
|
452 |
|
|
|
453 |
|
|
function pthread_attr_destroy
|
454 |
|
|
(attributes : access pthread_attr_t) return int;
|
455 |
|
|
pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
|
456 |
|
|
|
457 |
|
|
function pthread_attr_setdetachstate
|
458 |
|
|
(attr : access pthread_attr_t;
|
459 |
|
|
detachstate : int) return int;
|
460 |
|
|
pragma Import (C, pthread_attr_setdetachstate);
|
461 |
|
|
|
462 |
|
|
function pthread_attr_setstacksize
|
463 |
|
|
(attr : access pthread_attr_t;
|
464 |
|
|
stacksize : size_t) return int;
|
465 |
|
|
pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
|
466 |
|
|
|
467 |
|
|
function pthread_create
|
468 |
|
|
(thread : access pthread_t;
|
469 |
|
|
attributes : access pthread_attr_t;
|
470 |
|
|
start_routine : Thread_Body;
|
471 |
|
|
arg : System.Address) return int;
|
472 |
|
|
pragma Import (C, pthread_create, "pthread_create");
|
473 |
|
|
|
474 |
|
|
procedure pthread_exit (status : System.Address);
|
475 |
|
|
pragma Import (C, pthread_exit, "pthread_exit");
|
476 |
|
|
|
477 |
|
|
function pthread_self return pthread_t;
|
478 |
|
|
pragma Import (C, pthread_self, "pthread_self");
|
479 |
|
|
|
480 |
|
|
--------------------------
|
481 |
|
|
-- POSIX.1c Section 17 --
|
482 |
|
|
--------------------------
|
483 |
|
|
|
484 |
|
|
function pthread_setspecific
|
485 |
|
|
(key : pthread_key_t;
|
486 |
|
|
value : System.Address) return int;
|
487 |
|
|
pragma Import (C, pthread_setspecific, "pthread_setspecific");
|
488 |
|
|
|
489 |
|
|
function pthread_getspecific (key : pthread_key_t) return System.Address;
|
490 |
|
|
pragma Import (C, pthread_getspecific, "pthread_getspecific");
|
491 |
|
|
|
492 |
|
|
type destructor_pointer is access procedure (arg : System.Address);
|
493 |
|
|
pragma Convention (C, destructor_pointer);
|
494 |
|
|
|
495 |
|
|
function pthread_key_create
|
496 |
|
|
(key : access pthread_key_t;
|
497 |
|
|
destructor : destructor_pointer) return int;
|
498 |
|
|
pragma Import (C, pthread_key_create, "pthread_key_create");
|
499 |
|
|
|
500 |
|
|
------------------------------------------------------------
|
501 |
|
|
-- Binary Semaphore Wrapper to Support Interrupt Tasks --
|
502 |
|
|
------------------------------------------------------------
|
503 |
|
|
|
504 |
|
|
type Binary_Semaphore_Id is new rtems_id;
|
505 |
|
|
|
506 |
|
|
function Binary_Semaphore_Create return Binary_Semaphore_Id;
|
507 |
|
|
pragma Import (
|
508 |
|
|
C,
|
509 |
|
|
Binary_Semaphore_Create,
|
510 |
|
|
"__gnat_binary_semaphore_create");
|
511 |
|
|
|
512 |
|
|
function Binary_Semaphore_Delete (ID : Binary_Semaphore_Id) return int;
|
513 |
|
|
pragma Import (
|
514 |
|
|
C,
|
515 |
|
|
Binary_Semaphore_Delete,
|
516 |
|
|
"__gnat_binary_semaphore_delete");
|
517 |
|
|
|
518 |
|
|
function Binary_Semaphore_Obtain (ID : Binary_Semaphore_Id) return int;
|
519 |
|
|
pragma Import (
|
520 |
|
|
C,
|
521 |
|
|
Binary_Semaphore_Obtain,
|
522 |
|
|
"__gnat_binary_semaphore_obtain");
|
523 |
|
|
|
524 |
|
|
function Binary_Semaphore_Release (ID : Binary_Semaphore_Id) return int;
|
525 |
|
|
pragma Import (
|
526 |
|
|
C,
|
527 |
|
|
Binary_Semaphore_Release,
|
528 |
|
|
"__gnat_binary_semaphore_release");
|
529 |
|
|
|
530 |
|
|
function Binary_Semaphore_Flush (ID : Binary_Semaphore_Id) return int;
|
531 |
|
|
pragma Import (
|
532 |
|
|
C,
|
533 |
|
|
Binary_Semaphore_Flush,
|
534 |
|
|
"__gnat_binary_semaphore_flush");
|
535 |
|
|
|
536 |
|
|
------------------------------------------------------------
|
537 |
|
|
-- Hardware Interrupt Wrappers to Support Interrupt Tasks --
|
538 |
|
|
------------------------------------------------------------
|
539 |
|
|
|
540 |
|
|
type Interrupt_Handler is access procedure (parameter : System.Address);
|
541 |
|
|
pragma Convention (C, Interrupt_Handler);
|
542 |
|
|
type Interrupt_Vector is new System.Address;
|
543 |
|
|
|
544 |
|
|
function Interrupt_Connect
|
545 |
|
|
(vector : Interrupt_Vector;
|
546 |
|
|
handler : Interrupt_Handler;
|
547 |
|
|
parameter : System.Address := System.Null_Address) return int;
|
548 |
|
|
pragma Import (C, Interrupt_Connect, "__gnat_interrupt_connect");
|
549 |
|
|
-- Use this to set up an user handler. The routine installs a
|
550 |
|
|
-- a user handler which is invoked after RTEMS has saved enough
|
551 |
|
|
-- context for a high-level language routine to be safely invoked.
|
552 |
|
|
|
553 |
|
|
function Interrupt_Vector_Get
|
554 |
|
|
(Vector : Interrupt_Vector) return Interrupt_Handler;
|
555 |
|
|
pragma Import (C, Interrupt_Vector_Get, "__gnat_interrupt_get");
|
556 |
|
|
-- Use this to get the existing handler for later restoral.
|
557 |
|
|
|
558 |
|
|
procedure Interrupt_Vector_Set
|
559 |
|
|
(Vector : Interrupt_Vector;
|
560 |
|
|
Handler : Interrupt_Handler);
|
561 |
|
|
pragma Import (C, Interrupt_Vector_Set, "__gnat_interrupt_set");
|
562 |
|
|
-- Use this to restore a handler obtained using Interrupt_Vector_Get.
|
563 |
|
|
|
564 |
|
|
function Interrupt_Number_To_Vector (intNum : int) return Interrupt_Vector;
|
565 |
|
|
-- Convert a logical interrupt number to the hardware interrupt vector
|
566 |
|
|
-- number used to connect the interrupt.
|
567 |
|
|
pragma Import (
|
568 |
|
|
C,
|
569 |
|
|
Interrupt_Number_To_Vector,
|
570 |
|
|
"__gnat_interrupt_number_to_vector"
|
571 |
|
|
);
|
572 |
|
|
|
573 |
|
|
private
|
574 |
|
|
|
575 |
|
|
type sigset_t is new int;
|
576 |
|
|
|
577 |
|
|
type pid_t is new int;
|
578 |
|
|
|
579 |
|
|
type time_t is new long;
|
580 |
|
|
|
581 |
|
|
type timespec is record
|
582 |
|
|
tv_sec : time_t;
|
583 |
|
|
tv_nsec : long;
|
584 |
|
|
end record;
|
585 |
|
|
pragma Convention (C, timespec);
|
586 |
|
|
|
587 |
|
|
type clockid_t is new rtems_id;
|
588 |
|
|
CLOCK_REALTIME : constant clockid_t := 1;
|
589 |
|
|
|
590 |
|
|
type pthread_attr_t is record
|
591 |
|
|
is_initialized : int;
|
592 |
|
|
stackaddr : System.Address;
|
593 |
|
|
stacksize : int;
|
594 |
|
|
contentionscope : int;
|
595 |
|
|
inheritsched : int;
|
596 |
|
|
schedpolicy : int;
|
597 |
|
|
schedparam : struct_sched_param;
|
598 |
|
|
cputime_clocked_allowed : int;
|
599 |
|
|
detatchstate : int;
|
600 |
|
|
end record;
|
601 |
|
|
pragma Convention (C, pthread_attr_t);
|
602 |
|
|
|
603 |
|
|
type pthread_condattr_t is record
|
604 |
|
|
flags : int;
|
605 |
|
|
process_shared : int;
|
606 |
|
|
end record;
|
607 |
|
|
pragma Convention (C, pthread_condattr_t);
|
608 |
|
|
|
609 |
|
|
type pthread_mutexattr_t is record
|
610 |
|
|
is_initialized : int;
|
611 |
|
|
process_shared : int;
|
612 |
|
|
prio_ceiling : int;
|
613 |
|
|
protocol : int;
|
614 |
|
|
mutex_type : int;
|
615 |
|
|
recursive : int;
|
616 |
|
|
end record;
|
617 |
|
|
pragma Convention (C, pthread_mutexattr_t);
|
618 |
|
|
|
619 |
|
|
type pthread_t is new rtems_id;
|
620 |
|
|
|
621 |
|
|
type pthread_mutex_t is new rtems_id;
|
622 |
|
|
|
623 |
|
|
type pthread_cond_t is new rtems_id;
|
624 |
|
|
|
625 |
|
|
type pthread_key_t is new rtems_id;
|
626 |
|
|
|
627 |
|
|
No_Key : constant pthread_key_t := 0;
|
628 |
|
|
|
629 |
|
|
end System.OS_Interface;
|