annotate gcc/ada/libgnarl/s-osinte__android.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S Y S T E M . O S _ I N T E R F A C E --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1995-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNARL was developed by the GNARL team at Florida State University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This is an Android version of this package which is based on the
kono
parents:
diff changeset
33 -- GNU/Linux version
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 -- This package encapsulates all direct interfaces to OS services
kono
parents:
diff changeset
36 -- that are needed by the tasking run-time (libgnarl).
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 -- PLEASE DO NOT add any with-clauses to this package or remove the pragma
kono
parents:
diff changeset
39 -- Preelaborate. This package is designed to be a bottom-level (leaf) package.
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 with Ada.Unchecked_Conversion;
kono
parents:
diff changeset
42 with Interfaces.C;
kono
parents:
diff changeset
43 with System.Linux;
kono
parents:
diff changeset
44 with System.OS_Constants;
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 package System.OS_Interface is
kono
parents:
diff changeset
47 pragma Preelaborate;
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 subtype int is Interfaces.C.int;
kono
parents:
diff changeset
50 subtype char is Interfaces.C.char;
kono
parents:
diff changeset
51 subtype short is Interfaces.C.short;
kono
parents:
diff changeset
52 subtype long is Interfaces.C.long;
kono
parents:
diff changeset
53 subtype unsigned is Interfaces.C.unsigned;
kono
parents:
diff changeset
54 subtype unsigned_short is Interfaces.C.unsigned_short;
kono
parents:
diff changeset
55 subtype unsigned_long is Interfaces.C.unsigned_long;
kono
parents:
diff changeset
56 subtype unsigned_char is Interfaces.C.unsigned_char;
kono
parents:
diff changeset
57 subtype plain_char is Interfaces.C.plain_char;
kono
parents:
diff changeset
58 subtype size_t is Interfaces.C.size_t;
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 -----------
kono
parents:
diff changeset
61 -- Errno --
kono
parents:
diff changeset
62 -----------
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 function errno return int;
kono
parents:
diff changeset
65 pragma Import (C, errno, "__get_errno");
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 EAGAIN : constant := System.Linux.EAGAIN;
kono
parents:
diff changeset
68 EINTR : constant := System.Linux.EINTR;
kono
parents:
diff changeset
69 EINVAL : constant := System.Linux.EINVAL;
kono
parents:
diff changeset
70 ENOMEM : constant := System.Linux.ENOMEM;
kono
parents:
diff changeset
71 EPERM : constant := System.Linux.EPERM;
kono
parents:
diff changeset
72 ETIMEDOUT : constant := System.Linux.ETIMEDOUT;
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 -------------
kono
parents:
diff changeset
75 -- Signals --
kono
parents:
diff changeset
76 -------------
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 Max_Interrupt : constant := 31;
kono
parents:
diff changeset
79 type Signal is new int range 0 .. Max_Interrupt;
kono
parents:
diff changeset
80 for Signal'Size use int'Size;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 SIGHUP : constant := System.Linux.SIGHUP;
kono
parents:
diff changeset
83 SIGINT : constant := System.Linux.SIGINT;
kono
parents:
diff changeset
84 SIGQUIT : constant := System.Linux.SIGQUIT;
kono
parents:
diff changeset
85 SIGILL : constant := System.Linux.SIGILL;
kono
parents:
diff changeset
86 SIGTRAP : constant := System.Linux.SIGTRAP;
kono
parents:
diff changeset
87 SIGIOT : constant := System.Linux.SIGIOT;
kono
parents:
diff changeset
88 SIGABRT : constant := System.Linux.SIGABRT;
kono
parents:
diff changeset
89 SIGFPE : constant := System.Linux.SIGFPE;
kono
parents:
diff changeset
90 SIGKILL : constant := System.Linux.SIGKILL;
kono
parents:
diff changeset
91 SIGBUS : constant := System.Linux.SIGBUS;
kono
parents:
diff changeset
92 SIGSEGV : constant := System.Linux.SIGSEGV;
kono
parents:
diff changeset
93 SIGPIPE : constant := System.Linux.SIGPIPE;
kono
parents:
diff changeset
94 SIGALRM : constant := System.Linux.SIGALRM;
kono
parents:
diff changeset
95 SIGTERM : constant := System.Linux.SIGTERM;
kono
parents:
diff changeset
96 SIGUSR1 : constant := System.Linux.SIGUSR1;
kono
parents:
diff changeset
97 SIGUSR2 : constant := System.Linux.SIGUSR2;
kono
parents:
diff changeset
98 SIGCLD : constant := System.Linux.SIGCLD;
kono
parents:
diff changeset
99 SIGCHLD : constant := System.Linux.SIGCHLD;
kono
parents:
diff changeset
100 SIGPWR : constant := System.Linux.SIGPWR;
kono
parents:
diff changeset
101 SIGWINCH : constant := System.Linux.SIGWINCH;
kono
parents:
diff changeset
102 SIGURG : constant := System.Linux.SIGURG;
kono
parents:
diff changeset
103 SIGPOLL : constant := System.Linux.SIGPOLL;
kono
parents:
diff changeset
104 SIGIO : constant := System.Linux.SIGIO;
kono
parents:
diff changeset
105 SIGLOST : constant := System.Linux.SIGLOST;
kono
parents:
diff changeset
106 SIGSTOP : constant := System.Linux.SIGSTOP;
kono
parents:
diff changeset
107 SIGTSTP : constant := System.Linux.SIGTSTP;
kono
parents:
diff changeset
108 SIGCONT : constant := System.Linux.SIGCONT;
kono
parents:
diff changeset
109 SIGTTIN : constant := System.Linux.SIGTTIN;
kono
parents:
diff changeset
110 SIGTTOU : constant := System.Linux.SIGTTOU;
kono
parents:
diff changeset
111 SIGVTALRM : constant := System.Linux.SIGVTALRM;
kono
parents:
diff changeset
112 SIGPROF : constant := System.Linux.SIGPROF;
kono
parents:
diff changeset
113 SIGXCPU : constant := System.Linux.SIGXCPU;
kono
parents:
diff changeset
114 SIGXFSZ : constant := System.Linux.SIGXFSZ;
kono
parents:
diff changeset
115 SIGUNUSED : constant := System.Linux.SIGUNUSED;
kono
parents:
diff changeset
116 SIGSTKFLT : constant := System.Linux.SIGSTKFLT;
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 SIGADAABORT : constant := SIGABRT;
kono
parents:
diff changeset
119 -- Change this to use another signal for task abort. SIGTERM might be a
kono
parents:
diff changeset
120 -- good one.
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 type Signal_Set is array (Natural range <>) of Signal;
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 Unmasked : constant Signal_Set := (
kono
parents:
diff changeset
125 SIGTRAP,
kono
parents:
diff changeset
126 -- To enable debugging on multithreaded applications, mark SIGTRAP to
kono
parents:
diff changeset
127 -- be kept unmasked.
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 SIGBUS,
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 SIGTTIN, SIGTTOU, SIGTSTP,
kono
parents:
diff changeset
132 -- Keep these three signals unmasked so that background processes and IO
kono
parents:
diff changeset
133 -- behaves as normal "C" applications
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 SIGPROF,
kono
parents:
diff changeset
136 -- To avoid confusing the profiler
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 SIGKILL, SIGSTOP);
kono
parents:
diff changeset
139 -- These two signals actually can't be masked (POSIX won't allow it)
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 Reserved : constant Signal_Set := (SIGVTALRM, SIGUNUSED);
kono
parents:
diff changeset
142 -- Not clear why these two signals are reserved. Perhaps they are not
kono
parents:
diff changeset
143 -- supported by this version of GNU/Linux ???
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 type sigset_t is private;
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 function sigaddset (set : access sigset_t; sig : Signal) return int;
kono
parents:
diff changeset
148 pragma Import (C, sigaddset, "_sigaddset");
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 function sigdelset (set : access sigset_t; sig : Signal) return int;
kono
parents:
diff changeset
151 pragma Import (C, sigdelset, "_sigdelset");
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 function sigfillset (set : access sigset_t) return int;
kono
parents:
diff changeset
154 pragma Import (C, sigfillset, "_sigfillset");
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 function sigismember (set : access sigset_t; sig : Signal) return int;
kono
parents:
diff changeset
157 pragma Import (C, sigismember, "_sigismember");
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 function sigemptyset (set : access sigset_t) return int;
kono
parents:
diff changeset
160 pragma Import (C, sigemptyset, "_sigemptyset");
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 type union_type_3 is new String (1 .. 116);
kono
parents:
diff changeset
163 type siginfo_t is record
kono
parents:
diff changeset
164 si_signo : int;
kono
parents:
diff changeset
165 si_code : int;
kono
parents:
diff changeset
166 si_errno : int;
kono
parents:
diff changeset
167 X_data : union_type_3;
kono
parents:
diff changeset
168 end record;
kono
parents:
diff changeset
169 pragma Convention (C, siginfo_t);
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 type struct_sigaction is record
kono
parents:
diff changeset
172 sa_handler : System.Address;
kono
parents:
diff changeset
173 sa_mask : sigset_t;
kono
parents:
diff changeset
174 sa_flags : Interfaces.C.unsigned_long;
kono
parents:
diff changeset
175 sa_restorer : System.Address;
kono
parents:
diff changeset
176 end record;
kono
parents:
diff changeset
177 pragma Convention (C, struct_sigaction);
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 type struct_sigaction_ptr is access all struct_sigaction;
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 SA_SIGINFO : constant := System.Linux.SA_SIGINFO;
kono
parents:
diff changeset
182 SA_ONSTACK : constant := System.Linux.SA_ONSTACK;
kono
parents:
diff changeset
183 SA_NODEFER : constant := System.Linux.SA_NODEFER;
kono
parents:
diff changeset
184 SA_RESTART : constant := System.Linux.SA_RESTART;
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 SIG_BLOCK : constant := 0;
kono
parents:
diff changeset
187 SIG_UNBLOCK : constant := 1;
kono
parents:
diff changeset
188 SIG_SETMASK : constant := 2;
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 SIG_DFL : constant := 0;
kono
parents:
diff changeset
191 SIG_IGN : constant := 1;
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 function sigaction
kono
parents:
diff changeset
194 (sig : Signal;
kono
parents:
diff changeset
195 act : struct_sigaction_ptr;
kono
parents:
diff changeset
196 oact : struct_sigaction_ptr) return int;
kono
parents:
diff changeset
197 pragma Import (C, sigaction, "sigaction");
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 ----------
kono
parents:
diff changeset
200 -- Time --
kono
parents:
diff changeset
201 ----------
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 Time_Slice_Supported : constant Boolean := True;
kono
parents:
diff changeset
204 -- Indicates whether time slicing is supported
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 type timespec is private;
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 type clockid_t is new int;
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 function clock_gettime
kono
parents:
diff changeset
211 (clock_id : clockid_t; tp : access timespec) return int;
kono
parents:
diff changeset
212 pragma Import (C, clock_gettime, "clock_gettime");
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 function clock_getres
kono
parents:
diff changeset
215 (clock_id : clockid_t;
kono
parents:
diff changeset
216 res : access timespec) return int;
kono
parents:
diff changeset
217 pragma Import (C, clock_getres, "clock_getres");
kono
parents:
diff changeset
218
kono
parents:
diff changeset
219 function To_Duration (TS : timespec) return Duration;
kono
parents:
diff changeset
220 pragma Inline (To_Duration);
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 function To_Timespec (D : Duration) return timespec;
kono
parents:
diff changeset
223 pragma Inline (To_Timespec);
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 function sysconf (name : int) return long;
kono
parents:
diff changeset
226 pragma Import (C, sysconf);
kono
parents:
diff changeset
227
kono
parents:
diff changeset
228 SC_CLK_TCK : constant := 2;
kono
parents:
diff changeset
229 SC_NPROCESSORS_ONLN : constant := 84;
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 -------------------------
kono
parents:
diff changeset
232 -- Priority Scheduling --
kono
parents:
diff changeset
233 -------------------------
kono
parents:
diff changeset
234
kono
parents:
diff changeset
235 SCHED_OTHER : constant := 0;
kono
parents:
diff changeset
236 SCHED_FIFO : constant := 1;
kono
parents:
diff changeset
237 SCHED_RR : constant := 2;
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 function To_Target_Priority
kono
parents:
diff changeset
240 (Prio : System.Any_Priority)
kono
parents:
diff changeset
241 return Interfaces.C.int is (Interfaces.C.int (Prio));
kono
parents:
diff changeset
242 -- Maps System.Any_Priority to a POSIX priority
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 -------------
kono
parents:
diff changeset
245 -- Process --
kono
parents:
diff changeset
246 -------------
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 type pid_t is private;
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 function kill (pid : pid_t; sig : Signal) return int;
kono
parents:
diff changeset
251 pragma Import (C, kill, "kill");
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 function getpid return pid_t;
kono
parents:
diff changeset
254 pragma Import (C, getpid, "getpid");
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 -------------
kono
parents:
diff changeset
257 -- Threads --
kono
parents:
diff changeset
258 -------------
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260 type Thread_Body is access
kono
parents:
diff changeset
261 function (arg : System.Address) return System.Address;
kono
parents:
diff changeset
262 pragma Convention (C, Thread_Body);
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 function Thread_Body_Access is new
kono
parents:
diff changeset
265 Ada.Unchecked_Conversion (System.Address, Thread_Body);
kono
parents:
diff changeset
266
kono
parents:
diff changeset
267 type pthread_t is new unsigned_long;
kono
parents:
diff changeset
268 subtype Thread_Id is pthread_t;
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 function To_pthread_t is
kono
parents:
diff changeset
271 new Ada.Unchecked_Conversion (unsigned_long, pthread_t);
kono
parents:
diff changeset
272
kono
parents:
diff changeset
273 type pthread_mutex_t is limited private;
kono
parents:
diff changeset
274 type pthread_cond_t is limited private;
kono
parents:
diff changeset
275 type pthread_attr_t is limited private;
kono
parents:
diff changeset
276 type pthread_mutexattr_t is limited private;
kono
parents:
diff changeset
277 type pthread_condattr_t is limited private;
kono
parents:
diff changeset
278 type pthread_key_t is private;
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 PTHREAD_CREATE_DETACHED : constant := 1;
kono
parents:
diff changeset
281
kono
parents:
diff changeset
282 PTHREAD_SCOPE_PROCESS : constant := 1;
kono
parents:
diff changeset
283 PTHREAD_SCOPE_SYSTEM : constant := 0;
kono
parents:
diff changeset
284
kono
parents:
diff changeset
285 -- Read/Write lock not supported on Android.
kono
parents:
diff changeset
286
kono
parents:
diff changeset
287 subtype pthread_rwlock_t is pthread_mutex_t;
kono
parents:
diff changeset
288 subtype pthread_rwlockattr_t is pthread_mutexattr_t;
kono
parents:
diff changeset
289
kono
parents:
diff changeset
290 -----------
kono
parents:
diff changeset
291 -- Stack --
kono
parents:
diff changeset
292 -----------
kono
parents:
diff changeset
293
kono
parents:
diff changeset
294 type stack_t is record
kono
parents:
diff changeset
295 ss_sp : System.Address;
kono
parents:
diff changeset
296 ss_flags : int;
kono
parents:
diff changeset
297 ss_size : size_t;
kono
parents:
diff changeset
298 end record;
kono
parents:
diff changeset
299 pragma Convention (C, stack_t);
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 function sigaltstack
kono
parents:
diff changeset
302 (ss : not null access stack_t;
kono
parents:
diff changeset
303 oss : access stack_t) return int;
kono
parents:
diff changeset
304 pragma Import (C, sigaltstack, "sigaltstack");
kono
parents:
diff changeset
305
kono
parents:
diff changeset
306 Alternate_Stack : aliased System.Address;
kono
parents:
diff changeset
307 pragma Import (C, Alternate_Stack, "__gnat_alternate_stack");
kono
parents:
diff changeset
308 -- The alternate signal stack for stack overflows
kono
parents:
diff changeset
309
kono
parents:
diff changeset
310 Alternate_Stack_Size : constant := 16 * 1024;
kono
parents:
diff changeset
311 -- This must be in keeping with init.c:__gnat_alternate_stack
kono
parents:
diff changeset
312
kono
parents:
diff changeset
313 Stack_Base_Available : constant Boolean := False;
kono
parents:
diff changeset
314 -- Indicates whether the stack base is available on this target
kono
parents:
diff changeset
315
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
316 function Get_Stack_Base (ignored_thread : pthread_t)
111
kono
parents:
diff changeset
317 return Address is (Null_Address);
kono
parents:
diff changeset
318 -- This is a dummy procedure to share some GNULLI files
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 function Get_Page_Size return int;
kono
parents:
diff changeset
321 pragma Import (C, Get_Page_Size, "_getpagesize");
kono
parents:
diff changeset
322 -- Returns the size of a page
kono
parents:
diff changeset
323
kono
parents:
diff changeset
324 PROT_NONE : constant := 0;
kono
parents:
diff changeset
325 PROT_READ : constant := 1;
kono
parents:
diff changeset
326 PROT_WRITE : constant := 2;
kono
parents:
diff changeset
327 PROT_EXEC : constant := 4;
kono
parents:
diff changeset
328 PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
kono
parents:
diff changeset
329 PROT_ON : constant := PROT_READ;
kono
parents:
diff changeset
330 PROT_OFF : constant := PROT_ALL;
kono
parents:
diff changeset
331
kono
parents:
diff changeset
332 function mprotect (addr : Address; len : size_t; prot : int) return int;
kono
parents:
diff changeset
333 pragma Import (C, mprotect);
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 ---------------------------------------
kono
parents:
diff changeset
336 -- Nonstandard Thread Initialization --
kono
parents:
diff changeset
337 ---------------------------------------
kono
parents:
diff changeset
338
kono
parents:
diff changeset
339 procedure pthread_init is null;
kono
parents:
diff changeset
340 -- This is a dummy procedure to share some GNULLI files
kono
parents:
diff changeset
341
kono
parents:
diff changeset
342 -------------------------
kono
parents:
diff changeset
343 -- POSIX.1c Section 3 --
kono
parents:
diff changeset
344 -------------------------
kono
parents:
diff changeset
345
kono
parents:
diff changeset
346 function sigwait (set : access sigset_t; sig : access Signal) return int;
kono
parents:
diff changeset
347 pragma Import (C, sigwait, "sigwait");
kono
parents:
diff changeset
348
kono
parents:
diff changeset
349 function pthread_kill (thread : pthread_t; sig : Signal) return int;
kono
parents:
diff changeset
350 pragma Import (C, pthread_kill, "pthread_kill");
kono
parents:
diff changeset
351
kono
parents:
diff changeset
352 function pthread_sigmask
kono
parents:
diff changeset
353 (how : int;
kono
parents:
diff changeset
354 set : access sigset_t;
kono
parents:
diff changeset
355 oset : access sigset_t) return int;
kono
parents:
diff changeset
356 pragma Import (C, pthread_sigmask, "sigprocmask");
kono
parents:
diff changeset
357 -- pthread_sigmask maybe be broken due to mismatch between sigset_t and
kono
parents:
diff changeset
358 -- kernel_sigset_t, substitute sigprocmask temporarily. ???
kono
parents:
diff changeset
359 -- pragma Import (C, pthread_sigmask, "pthread_sigmask");
kono
parents:
diff changeset
360
kono
parents:
diff changeset
361 --------------------------
kono
parents:
diff changeset
362 -- POSIX.1c Section 11 --
kono
parents:
diff changeset
363 --------------------------
kono
parents:
diff changeset
364
kono
parents:
diff changeset
365 function pthread_mutexattr_init
kono
parents:
diff changeset
366 (attr : access pthread_mutexattr_t) return int;
kono
parents:
diff changeset
367 pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
kono
parents:
diff changeset
368
kono
parents:
diff changeset
369 function pthread_mutexattr_destroy
kono
parents:
diff changeset
370 (attr : access pthread_mutexattr_t) return int;
kono
parents:
diff changeset
371 pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
kono
parents:
diff changeset
372
kono
parents:
diff changeset
373 function pthread_mutex_init
kono
parents:
diff changeset
374 (mutex : access pthread_mutex_t;
kono
parents:
diff changeset
375 attr : access pthread_mutexattr_t) return int;
kono
parents:
diff changeset
376 pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
kono
parents:
diff changeset
377
kono
parents:
diff changeset
378 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
kono
parents:
diff changeset
379 pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
kono
parents:
diff changeset
380
kono
parents:
diff changeset
381 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
kono
parents:
diff changeset
382 pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
kono
parents:
diff changeset
383
kono
parents:
diff changeset
384 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
kono
parents:
diff changeset
385 pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
kono
parents:
diff changeset
386
kono
parents:
diff changeset
387 function pthread_condattr_init
kono
parents:
diff changeset
388 (attr : access pthread_condattr_t) return int;
kono
parents:
diff changeset
389 pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
kono
parents:
diff changeset
390
kono
parents:
diff changeset
391 function pthread_condattr_destroy
kono
parents:
diff changeset
392 (attr : access pthread_condattr_t) return int;
kono
parents:
diff changeset
393 pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
kono
parents:
diff changeset
394
kono
parents:
diff changeset
395 function pthread_cond_init
kono
parents:
diff changeset
396 (cond : access pthread_cond_t;
kono
parents:
diff changeset
397 attr : access pthread_condattr_t) return int;
kono
parents:
diff changeset
398 pragma Import (C, pthread_cond_init, "pthread_cond_init");
kono
parents:
diff changeset
399
kono
parents:
diff changeset
400 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
kono
parents:
diff changeset
401 pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
kono
parents:
diff changeset
402
kono
parents:
diff changeset
403 function pthread_cond_signal (cond : access pthread_cond_t) return int;
kono
parents:
diff changeset
404 pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
kono
parents:
diff changeset
405
kono
parents:
diff changeset
406 function pthread_cond_wait
kono
parents:
diff changeset
407 (cond : access pthread_cond_t;
kono
parents:
diff changeset
408 mutex : access pthread_mutex_t) return int;
kono
parents:
diff changeset
409 pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
kono
parents:
diff changeset
410
kono
parents:
diff changeset
411 function pthread_cond_timedwait
kono
parents:
diff changeset
412 (cond : access pthread_cond_t;
kono
parents:
diff changeset
413 mutex : access pthread_mutex_t;
kono
parents:
diff changeset
414 abstime : access timespec) return int;
kono
parents:
diff changeset
415 pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
kono
parents:
diff changeset
416
kono
parents:
diff changeset
417 --------------------------
kono
parents:
diff changeset
418 -- POSIX.1c Section 13 --
kono
parents:
diff changeset
419 --------------------------
kono
parents:
diff changeset
420
kono
parents:
diff changeset
421 PTHREAD_PRIO_PROTECT : constant := 0;
kono
parents:
diff changeset
422 PTHREAD_PRIO_INHERIT : constant := 1;
kono
parents:
diff changeset
423
kono
parents:
diff changeset
424 function pthread_mutexattr_setprotocol
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
425 (ignored_attr : access pthread_mutexattr_t;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
426 ignored_protocol : int) return int is (0);
111
kono
parents:
diff changeset
427
kono
parents:
diff changeset
428 function pthread_mutexattr_setprioceiling
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
429 (ignored_attr : access pthread_mutexattr_t;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
430 ignored_prioceiling : int) return int is (0);
111
kono
parents:
diff changeset
431
kono
parents:
diff changeset
432 type struct_sched_param is record
kono
parents:
diff changeset
433 sched_priority : int; -- scheduling priority
kono
parents:
diff changeset
434 end record;
kono
parents:
diff changeset
435 pragma Convention (C, struct_sched_param);
kono
parents:
diff changeset
436
kono
parents:
diff changeset
437 function pthread_setschedparam
kono
parents:
diff changeset
438 (thread : pthread_t;
kono
parents:
diff changeset
439 policy : int;
kono
parents:
diff changeset
440 param : access struct_sched_param) return int;
kono
parents:
diff changeset
441 pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
kono
parents:
diff changeset
442
kono
parents:
diff changeset
443 function pthread_attr_setscope
kono
parents:
diff changeset
444 (attr : access pthread_attr_t;
kono
parents:
diff changeset
445 scope : int) return int;
kono
parents:
diff changeset
446 pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
kono
parents:
diff changeset
447
kono
parents:
diff changeset
448 function pthread_attr_setschedpolicy
kono
parents:
diff changeset
449 (attr : access pthread_attr_t;
kono
parents:
diff changeset
450 policy : int) return int;
kono
parents:
diff changeset
451 pragma Import
kono
parents:
diff changeset
452 (C, pthread_attr_setschedpolicy, "pthread_attr_setschedpolicy");
kono
parents:
diff changeset
453
kono
parents:
diff changeset
454 function sched_yield return int;
kono
parents:
diff changeset
455 pragma Import (C, sched_yield, "sched_yield");
kono
parents:
diff changeset
456
kono
parents:
diff changeset
457 ---------------------------
kono
parents:
diff changeset
458 -- P1003.1c - Section 16 --
kono
parents:
diff changeset
459 ---------------------------
kono
parents:
diff changeset
460
kono
parents:
diff changeset
461 function pthread_attr_init
kono
parents:
diff changeset
462 (attributes : access pthread_attr_t) return int;
kono
parents:
diff changeset
463 pragma Import (C, pthread_attr_init, "pthread_attr_init");
kono
parents:
diff changeset
464
kono
parents:
diff changeset
465 function pthread_attr_destroy
kono
parents:
diff changeset
466 (attributes : access pthread_attr_t) return int;
kono
parents:
diff changeset
467 pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
kono
parents:
diff changeset
468
kono
parents:
diff changeset
469 function pthread_attr_setdetachstate
kono
parents:
diff changeset
470 (attr : access pthread_attr_t;
kono
parents:
diff changeset
471 detachstate : int) return int;
kono
parents:
diff changeset
472 pragma Import
kono
parents:
diff changeset
473 (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
kono
parents:
diff changeset
474
kono
parents:
diff changeset
475 function pthread_attr_setstacksize
kono
parents:
diff changeset
476 (attr : access pthread_attr_t;
kono
parents:
diff changeset
477 stacksize : size_t) return int;
kono
parents:
diff changeset
478 pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
kono
parents:
diff changeset
479
kono
parents:
diff changeset
480 function pthread_create
kono
parents:
diff changeset
481 (thread : access pthread_t;
kono
parents:
diff changeset
482 attributes : access pthread_attr_t;
kono
parents:
diff changeset
483 start_routine : Thread_Body;
kono
parents:
diff changeset
484 arg : System.Address) return int;
kono
parents:
diff changeset
485 pragma Import (C, pthread_create, "pthread_create");
kono
parents:
diff changeset
486
kono
parents:
diff changeset
487 procedure pthread_exit (status : System.Address);
kono
parents:
diff changeset
488 pragma Import (C, pthread_exit, "pthread_exit");
kono
parents:
diff changeset
489
kono
parents:
diff changeset
490 function pthread_self return pthread_t;
kono
parents:
diff changeset
491 pragma Import (C, pthread_self, "pthread_self");
kono
parents:
diff changeset
492
kono
parents:
diff changeset
493 function lwp_self return System.Address;
kono
parents:
diff changeset
494 pragma Import (C, lwp_self, "__gnat_lwp_self");
kono
parents:
diff changeset
495
kono
parents:
diff changeset
496 --------------------------
kono
parents:
diff changeset
497 -- POSIX.1c Section 17 --
kono
parents:
diff changeset
498 --------------------------
kono
parents:
diff changeset
499
kono
parents:
diff changeset
500 function pthread_setspecific
kono
parents:
diff changeset
501 (key : pthread_key_t;
kono
parents:
diff changeset
502 value : System.Address) return int;
kono
parents:
diff changeset
503 pragma Import (C, pthread_setspecific, "pthread_setspecific");
kono
parents:
diff changeset
504
kono
parents:
diff changeset
505 function pthread_getspecific (key : pthread_key_t) return System.Address;
kono
parents:
diff changeset
506 pragma Import (C, pthread_getspecific, "pthread_getspecific");
kono
parents:
diff changeset
507
kono
parents:
diff changeset
508 type destructor_pointer is access procedure (arg : System.Address);
kono
parents:
diff changeset
509 pragma Convention (C, destructor_pointer);
kono
parents:
diff changeset
510
kono
parents:
diff changeset
511 function pthread_key_create
kono
parents:
diff changeset
512 (key : access pthread_key_t;
kono
parents:
diff changeset
513 destructor : destructor_pointer) return int;
kono
parents:
diff changeset
514 pragma Import (C, pthread_key_create, "pthread_key_create");
kono
parents:
diff changeset
515
kono
parents:
diff changeset
516 CPU_SETSIZE : constant := 1_024;
kono
parents:
diff changeset
517 -- Size of the cpu_set_t mask on most linux systems (SUSE 11 uses 4_096).
kono
parents:
diff changeset
518 -- This is kept for backward compatibility (System.Task_Info uses it), but
kono
parents:
diff changeset
519 -- the run-time library does no longer rely on static masks, using
kono
parents:
diff changeset
520 -- dynamically allocated masks instead.
kono
parents:
diff changeset
521
kono
parents:
diff changeset
522 type bit_field is array (1 .. CPU_SETSIZE) of Boolean;
kono
parents:
diff changeset
523 for bit_field'Size use CPU_SETSIZE;
kono
parents:
diff changeset
524 pragma Pack (bit_field);
kono
parents:
diff changeset
525 pragma Convention (C, bit_field);
kono
parents:
diff changeset
526
kono
parents:
diff changeset
527 type cpu_set_t is record
kono
parents:
diff changeset
528 bits : bit_field;
kono
parents:
diff changeset
529 end record;
kono
parents:
diff changeset
530 pragma Convention (C, cpu_set_t);
kono
parents:
diff changeset
531
kono
parents:
diff changeset
532 type cpu_set_t_ptr is access all cpu_set_t;
kono
parents:
diff changeset
533 -- In the run-time library we use this pointer because the size of type
kono
parents:
diff changeset
534 -- cpu_set_t varies depending on the glibc version. Hence, objects of type
kono
parents:
diff changeset
535 -- cpu_set_t are allocated dynamically using the number of processors
kono
parents:
diff changeset
536 -- available in the target machine (value obtained at execution time).
kono
parents:
diff changeset
537
kono
parents:
diff changeset
538 function CPU_ALLOC (count : size_t) return cpu_set_t_ptr;
kono
parents:
diff changeset
539 pragma Import (C, CPU_ALLOC, "__gnat_cpu_alloc");
kono
parents:
diff changeset
540 -- Wrapper around the CPU_ALLOC C macro
kono
parents:
diff changeset
541
kono
parents:
diff changeset
542 function CPU_ALLOC_SIZE (count : size_t) return size_t;
kono
parents:
diff changeset
543 pragma Import (C, CPU_ALLOC_SIZE, "__gnat_cpu_alloc_size");
kono
parents:
diff changeset
544 -- Wrapper around the CPU_ALLOC_SIZE C macro
kono
parents:
diff changeset
545
kono
parents:
diff changeset
546 procedure CPU_FREE (cpuset : cpu_set_t_ptr);
kono
parents:
diff changeset
547 pragma Import (C, CPU_FREE, "__gnat_cpu_free");
kono
parents:
diff changeset
548 -- Wrapper around the CPU_FREE C macro
kono
parents:
diff changeset
549
kono
parents:
diff changeset
550 procedure CPU_ZERO (count : size_t; cpuset : cpu_set_t_ptr);
kono
parents:
diff changeset
551 pragma Import (C, CPU_ZERO, "__gnat_cpu_zero");
kono
parents:
diff changeset
552 -- Wrapper around the CPU_ZERO_S C macro
kono
parents:
diff changeset
553
kono
parents:
diff changeset
554 procedure CPU_SET (cpu : int; count : size_t; cpuset : cpu_set_t_ptr);
kono
parents:
diff changeset
555 pragma Import (C, CPU_SET, "__gnat_cpu_set");
kono
parents:
diff changeset
556 -- Wrapper around the CPU_SET_S C macro
kono
parents:
diff changeset
557
kono
parents:
diff changeset
558 function pthread_setaffinity_np
kono
parents:
diff changeset
559 (thread : pthread_t;
kono
parents:
diff changeset
560 cpusetsize : size_t;
kono
parents:
diff changeset
561 cpuset : cpu_set_t_ptr) return int;
kono
parents:
diff changeset
562 pragma Import (C, pthread_setaffinity_np, "pthread_setaffinity_np");
kono
parents:
diff changeset
563 pragma Weak_External (pthread_setaffinity_np);
kono
parents:
diff changeset
564 -- Use a weak symbol because this function may be available or not,
kono
parents:
diff changeset
565 -- depending on the version of the system.
kono
parents:
diff changeset
566
kono
parents:
diff changeset
567 function pthread_attr_setaffinity_np
kono
parents:
diff changeset
568 (attr : access pthread_attr_t;
kono
parents:
diff changeset
569 cpusetsize : size_t;
kono
parents:
diff changeset
570 cpuset : cpu_set_t_ptr) return int;
kono
parents:
diff changeset
571 pragma Import (C, pthread_attr_setaffinity_np,
kono
parents:
diff changeset
572 "pthread_attr_setaffinity_np");
kono
parents:
diff changeset
573 pragma Weak_External (pthread_attr_setaffinity_np);
kono
parents:
diff changeset
574 -- Use a weak symbol because this function may be available or not,
kono
parents:
diff changeset
575 -- depending on the version of the system.
kono
parents:
diff changeset
576
kono
parents:
diff changeset
577 private
kono
parents:
diff changeset
578
kono
parents:
diff changeset
579 type sigset_t is new Interfaces.C.unsigned_long;
kono
parents:
diff changeset
580 pragma Convention (C, sigset_t);
kono
parents:
diff changeset
581 for sigset_t'Alignment use Interfaces.C.unsigned_long'Alignment;
kono
parents:
diff changeset
582
kono
parents:
diff changeset
583 pragma Warnings (Off);
kono
parents:
diff changeset
584 for struct_sigaction use record
kono
parents:
diff changeset
585 sa_handler at Linux.sa_handler_pos range 0 .. Standard'Address_Size - 1;
kono
parents:
diff changeset
586 sa_mask at Linux.sa_mask_pos range 0 .. sigset_t'Size - 1;
kono
parents:
diff changeset
587 sa_flags at Linux.sa_flags_pos
kono
parents:
diff changeset
588 range 0 .. Interfaces.C.unsigned_long'Size - 1;
kono
parents:
diff changeset
589 end record;
kono
parents:
diff changeset
590 -- We intentionally leave sa_restorer unspecified and let the compiler
kono
parents:
diff changeset
591 -- append it after the last field, so disable corresponding warning.
kono
parents:
diff changeset
592 pragma Warnings (On);
kono
parents:
diff changeset
593
kono
parents:
diff changeset
594 type pid_t is new int;
kono
parents:
diff changeset
595
kono
parents:
diff changeset
596 type time_t is new long;
kono
parents:
diff changeset
597
kono
parents:
diff changeset
598 type timespec is record
kono
parents:
diff changeset
599 tv_sec : time_t;
kono
parents:
diff changeset
600 tv_nsec : long;
kono
parents:
diff changeset
601 end record;
kono
parents:
diff changeset
602 pragma Convention (C, timespec);
kono
parents:
diff changeset
603
kono
parents:
diff changeset
604 type unsigned_long_long_t is mod 2 ** 64;
kono
parents:
diff changeset
605 -- Local type only used to get the alignment of this type below
kono
parents:
diff changeset
606
kono
parents:
diff changeset
607 subtype char_array is Interfaces.C.char_array;
kono
parents:
diff changeset
608
kono
parents:
diff changeset
609 type pthread_attr_t is record
kono
parents:
diff changeset
610 Data : char_array (1 .. OS_Constants.PTHREAD_ATTR_SIZE);
kono
parents:
diff changeset
611 end record;
kono
parents:
diff changeset
612 pragma Convention (C, pthread_attr_t);
kono
parents:
diff changeset
613 for pthread_attr_t'Alignment use Interfaces.C.unsigned_long'Alignment;
kono
parents:
diff changeset
614
kono
parents:
diff changeset
615 type pthread_condattr_t is record
kono
parents:
diff changeset
616 Data : char_array (1 .. OS_Constants.PTHREAD_CONDATTR_SIZE);
kono
parents:
diff changeset
617 end record;
kono
parents:
diff changeset
618 pragma Convention (C, pthread_condattr_t);
kono
parents:
diff changeset
619 for pthread_condattr_t'Alignment use Interfaces.C.int'Alignment;
kono
parents:
diff changeset
620
kono
parents:
diff changeset
621 type pthread_mutexattr_t is record
kono
parents:
diff changeset
622 Data : char_array (1 .. OS_Constants.PTHREAD_MUTEXATTR_SIZE);
kono
parents:
diff changeset
623 end record;
kono
parents:
diff changeset
624 pragma Convention (C, pthread_mutexattr_t);
kono
parents:
diff changeset
625 for pthread_mutexattr_t'Alignment use Interfaces.C.int'Alignment;
kono
parents:
diff changeset
626
kono
parents:
diff changeset
627 type pthread_mutex_t is record
kono
parents:
diff changeset
628 Data : char_array (1 .. OS_Constants.PTHREAD_MUTEX_SIZE);
kono
parents:
diff changeset
629 end record;
kono
parents:
diff changeset
630 pragma Convention (C, pthread_mutex_t);
kono
parents:
diff changeset
631 for pthread_mutex_t'Alignment use Interfaces.C.unsigned_long'Alignment;
kono
parents:
diff changeset
632
kono
parents:
diff changeset
633 type pthread_cond_t is record
kono
parents:
diff changeset
634 Data : char_array (1 .. OS_Constants.PTHREAD_COND_SIZE);
kono
parents:
diff changeset
635 end record;
kono
parents:
diff changeset
636 pragma Convention (C, pthread_cond_t);
kono
parents:
diff changeset
637 for pthread_cond_t'Alignment use unsigned_long_long_t'Alignment;
kono
parents:
diff changeset
638
kono
parents:
diff changeset
639 type pthread_key_t is new unsigned;
kono
parents:
diff changeset
640
kono
parents:
diff changeset
641 end System.OS_Interface;