1 --- gcc/ada/a-exetim-posix.adb.orig
2 +++ gcc/ada/a-exetim-posix.adb
4 -- Time is equal to Duration (although it is a private type) and
5 -- CPU_Time is equal to Time.
7 - function clock_gettime
8 + function clock_gettime_int
9 (clock_id : Interfaces.C.int;
12 - pragma Import (C, clock_gettime, "clock_gettime");
13 + pragma Import (C, clock_gettime_int, "clock_gettime");
14 -- Function from the POSIX.1b Realtime Extensions library
21 - Result := clock_gettime
22 + Result := clock_gettime_int
23 (clock_id => CLOCK_THREAD_CPUTIME_ID, tp => TS'Unchecked_Access);
24 pragma Assert (Result = 0);
27 +++ gcc/ada/a-intnam-dragonfly.ads
29 +------------------------------------------------------------------------------
31 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
33 +-- A D A . I N T E R R U P T S . N A M E S --
37 +-- Copyright (C) 1991-2011, Free Software Foundation, Inc. --
39 +-- GNARL is free software; you can redistribute it and/or modify it under --
40 +-- terms of the GNU General Public License as published by the Free Soft- --
41 +-- ware Foundation; either version 3, or (at your option) any later ver- --
42 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
43 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
44 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
46 +-- As a special exception under Section 7 of GPL version 3, you are granted --
47 +-- additional permissions described in the GCC Runtime Library Exception, --
48 +-- version 3.1, as published by the Free Software Foundation. --
50 +-- You should have received a copy of the GNU General Public License and --
51 +-- a copy of the GCC Runtime Library Exception along with this program; --
52 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
53 +-- <http://www.gnu.org/licenses/>. --
55 +-- GNARL was developed by the GNARL team at Florida State University. --
56 +-- Extensive contributions were provided by Ada Core Technologies, Inc. --
58 +------------------------------------------------------------------------------
60 +-- This is the DragonFly BSD THREADS version of this package
62 +with System.OS_Interface;
64 +package Ada.Interrupts.Names is
66 + -- All identifiers in this unit are implementation defined
68 + pragma Implementation_Defined;
70 + -- Beware that the mapping of names to signals may be many-to-one. There
71 + -- may be aliases. Also, for all signal names that are not supported on
72 + -- the current system the value of the corresponding constant will be zero.
74 + SIGHUP : constant Interrupt_ID :=
75 + System.OS_Interface.SIGHUP; -- hangup
77 + SIGINT : constant Interrupt_ID :=
78 + System.OS_Interface.SIGINT; -- interrupt (rubout)
80 + SIGQUIT : constant Interrupt_ID :=
81 + System.OS_Interface.SIGQUIT; -- quit (ASCD FS)
83 + SIGILL : constant Interrupt_ID :=
84 + System.OS_Interface.SIGILL; -- illegal instruction (not reset)
86 + SIGTRAP : constant Interrupt_ID :=
87 + System.OS_Interface.SIGTRAP; -- trace trap (not reset)
89 + SIGIOT : constant Interrupt_ID :=
90 + System.OS_Interface.SIGIOT; -- IOT instruction
92 + SIGABRT : constant Interrupt_ID := -- used by abort,
93 + System.OS_Interface.SIGABRT; -- replace SIGIOT in the future
95 + SIGFPE : constant Interrupt_ID :=
96 + System.OS_Interface.SIGFPE; -- floating point exception
98 + SIGKILL : constant Interrupt_ID :=
99 + System.OS_Interface.SIGKILL; -- kill (cannot be caught or ignored)
101 + SIGBUS : constant Interrupt_ID :=
102 + System.OS_Interface.SIGBUS; -- bus error
104 + SIGSEGV : constant Interrupt_ID :=
105 + System.OS_Interface.SIGSEGV; -- segmentation violation
107 + SIGPIPE : constant Interrupt_ID := -- write on a pipe with
108 + System.OS_Interface.SIGPIPE; -- no one to read it
110 + SIGALRM : constant Interrupt_ID :=
111 + System.OS_Interface.SIGALRM; -- alarm clock
113 + SIGTERM : constant Interrupt_ID :=
114 + System.OS_Interface.SIGTERM; -- software termination signal from kill
116 + SIGURG : constant Interrupt_ID :=
117 + System.OS_Interface.SIGURG; -- urgent condition on IO channel
119 + SIGSTOP : constant Interrupt_ID :=
120 + System.OS_Interface.SIGSTOP; -- stop (cannot be caught or ignored)
122 + SIGTSTP : constant Interrupt_ID :=
123 + System.OS_Interface.SIGTSTP; -- user stop requested from tty
125 + SIGCONT : constant Interrupt_ID :=
126 + System.OS_Interface.SIGCONT; -- stopped process has been continued
128 + SIGCHLD : constant Interrupt_ID :=
129 + System.OS_Interface.SIGCHLD; -- 4.3BSD's/POSIX name for SIGCLD
131 + SIGCLD : constant Interrupt_ID :=
132 + System.OS_Interface.SIGCLD; -- child status change
134 + SIGTTIN : constant Interrupt_ID :=
135 + System.OS_Interface.SIGTTIN; -- background tty read attempted
137 + SIGTTOU : constant Interrupt_ID :=
138 + System.OS_Interface.SIGTTOU; -- background tty write attempted
140 + SIGIO : constant Interrupt_ID := -- input/output possible,
141 + System.OS_Interface.SIGIO; -- SIGPOLL alias (Solaris)
143 + SIGXCPU : constant Interrupt_ID :=
144 + System.OS_Interface.SIGXCPU; -- CPU time limit exceeded
146 + SIGXFSZ : constant Interrupt_ID :=
147 + System.OS_Interface.SIGXFSZ; -- filesize limit exceeded
149 + SIGVTALRM : constant Interrupt_ID :=
150 + System.OS_Interface.SIGVTALRM; -- virtual timer expired
152 + SIGPROF : constant Interrupt_ID :=
153 + System.OS_Interface.SIGPROF; -- profiling timer expired
155 + SIGWINCH : constant Interrupt_ID :=
156 + System.OS_Interface.SIGWINCH; -- window size change
158 + SIGUSR1 : constant Interrupt_ID :=
159 + System.OS_Interface.SIGUSR1; -- user defined signal 1
161 + SIGUSR2 : constant Interrupt_ID :=
162 + System.OS_Interface.SIGUSR2; -- user defined signal 2
164 +end Ada.Interrupts.Names;
166 +++ gcc/ada/a-intnam-netbsd.ads
168 +------------------------------------------------------------------------------
170 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
172 +-- A D A . I N T E R R U P T S . N A M E S --
176 +-- Copyright (C) 1991-2011, Free Software Foundation, Inc. --
178 +-- GNARL is free software; you can redistribute it and/or modify it under --
179 +-- terms of the GNU General Public License as published by the Free Soft- --
180 +-- ware Foundation; either version 3, or (at your option) any later ver- --
181 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
182 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
183 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
185 +-- As a special exception under Section 7 of GPL version 3, you are granted --
186 +-- additional permissions described in the GCC Runtime Library Exception, --
187 +-- version 3.1, as published by the Free Software Foundation. --
189 +-- You should have received a copy of the GNU General Public License and --
190 +-- a copy of the GCC Runtime Library Exception along with this program; --
191 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
192 +-- <http://www.gnu.org/licenses/>. --
194 +-- GNARL was developed by the GNARL team at Florida State University. --
195 +-- Extensive contributions were provided by Ada Core Technologies, Inc. --
197 +------------------------------------------------------------------------------
199 +-- This is the NetBSD THREADS version of this package
201 +with System.OS_Interface;
203 +package Ada.Interrupts.Names is
205 + -- All identifiers in this unit are implementation defined
207 + pragma Implementation_Defined;
209 + -- Beware that the mapping of names to signals may be many-to-one. There
210 + -- may be aliases. Also, for all signal names that are not supported on
211 + -- the current system the value of the corresponding constant will be zero.
213 + SIGHUP : constant Interrupt_ID :=
214 + System.OS_Interface.SIGHUP; -- hangup
216 + SIGINT : constant Interrupt_ID :=
217 + System.OS_Interface.SIGINT; -- interrupt (rubout)
219 + SIGQUIT : constant Interrupt_ID :=
220 + System.OS_Interface.SIGQUIT; -- quit (ASCD FS)
222 + SIGILL : constant Interrupt_ID :=
223 + System.OS_Interface.SIGILL; -- illegal instruction (not reset)
225 + SIGTRAP : constant Interrupt_ID :=
226 + System.OS_Interface.SIGTRAP; -- trace trap (not reset)
228 + SIGIOT : constant Interrupt_ID :=
229 + System.OS_Interface.SIGIOT; -- IOT instruction
231 + SIGABRT : constant Interrupt_ID := -- used by abort,
232 + System.OS_Interface.SIGABRT; -- replace SIGIOT in the future
234 + SIGFPE : constant Interrupt_ID :=
235 + System.OS_Interface.SIGFPE; -- floating point exception
237 + SIGKILL : constant Interrupt_ID :=
238 + System.OS_Interface.SIGKILL; -- kill (cannot be caught or ignored)
240 + SIGBUS : constant Interrupt_ID :=
241 + System.OS_Interface.SIGBUS; -- bus error
243 + SIGSEGV : constant Interrupt_ID :=
244 + System.OS_Interface.SIGSEGV; -- segmentation violation
246 + SIGPIPE : constant Interrupt_ID := -- write on a pipe with
247 + System.OS_Interface.SIGPIPE; -- no one to read it
249 + SIGALRM : constant Interrupt_ID :=
250 + System.OS_Interface.SIGALRM; -- alarm clock
252 + SIGTERM : constant Interrupt_ID :=
253 + System.OS_Interface.SIGTERM; -- software termination signal from kill
255 + SIGURG : constant Interrupt_ID :=
256 + System.OS_Interface.SIGURG; -- urgent condition on IO channel
258 + SIGSTOP : constant Interrupt_ID :=
259 + System.OS_Interface.SIGSTOP; -- stop (cannot be caught or ignored)
261 + SIGTSTP : constant Interrupt_ID :=
262 + System.OS_Interface.SIGTSTP; -- user stop requested from tty
264 + SIGCONT : constant Interrupt_ID :=
265 + System.OS_Interface.SIGCONT; -- stopped process has been continued
267 + SIGCHLD : constant Interrupt_ID :=
268 + System.OS_Interface.SIGCHLD; -- 4.3BSD's/POSIX name for SIGCLD
270 + SIGCLD : constant Interrupt_ID :=
271 + System.OS_Interface.SIGCLD; -- child status change
273 + SIGTTIN : constant Interrupt_ID :=
274 + System.OS_Interface.SIGTTIN; -- background tty read attempted
276 + SIGTTOU : constant Interrupt_ID :=
277 + System.OS_Interface.SIGTTOU; -- background tty write attempted
279 + SIGIO : constant Interrupt_ID := -- input/output possible,
280 + System.OS_Interface.SIGIO; -- SIGPOLL alias (Solaris)
282 + SIGXCPU : constant Interrupt_ID :=
283 + System.OS_Interface.SIGXCPU; -- CPU time limit exceeded
285 + SIGXFSZ : constant Interrupt_ID :=
286 + System.OS_Interface.SIGXFSZ; -- filesize limit exceeded
288 + SIGVTALRM : constant Interrupt_ID :=
289 + System.OS_Interface.SIGVTALRM; -- virtual timer expired
291 + SIGPROF : constant Interrupt_ID :=
292 + System.OS_Interface.SIGPROF; -- profiling timer expired
294 + SIGWINCH : constant Interrupt_ID :=
295 + System.OS_Interface.SIGWINCH; -- window size change
297 + SIGUSR1 : constant Interrupt_ID :=
298 + System.OS_Interface.SIGUSR1; -- user defined signal 1
300 + SIGUSR2 : constant Interrupt_ID :=
301 + System.OS_Interface.SIGUSR2; -- user defined signal 2
303 + SIGPWR : constant Interrupt_ID :=
304 + System.OS_Interface.SIGPWR; -- power fail/restart
306 +end Ada.Interrupts.Names;
308 +++ gcc/ada/a-intnam-openbsd.ads
310 +------------------------------------------------------------------------------
312 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
314 +-- A D A . I N T E R R U P T S . N A M E S --
318 +-- Copyright (C) 1991-2011, Free Software Foundation, Inc. --
320 +-- GNARL is free software; you can redistribute it and/or modify it under --
321 +-- terms of the GNU General Public License as published by the Free Soft- --
322 +-- ware Foundation; either version 3, or (at your option) any later ver- --
323 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
324 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
325 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
327 +-- As a special exception under Section 7 of GPL version 3, you are granted --
328 +-- additional permissions described in the GCC Runtime Library Exception, --
329 +-- version 3.1, as published by the Free Software Foundation. --
331 +-- You should have received a copy of the GNU General Public License and --
332 +-- a copy of the GCC Runtime Library Exception along with this program; --
333 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
334 +-- <http://www.gnu.org/licenses/>. --
336 +-- GNARL was developed by the GNARL team at Florida State University. --
337 +-- Extensive contributions were provided by Ada Core Technologies, Inc. --
339 +------------------------------------------------------------------------------
341 +-- This is the OpenBSD THREADS version of this package
343 +with System.OS_Interface;
345 +package Ada.Interrupts.Names is
347 + -- All identifiers in this unit are implementation defined
349 + pragma Implementation_Defined;
351 + -- Beware that the mapping of names to signals may be many-to-one. There
352 + -- may be aliases. Also, for all signal names that are not supported on
353 + -- the current system the value of the corresponding constant will be zero.
355 + SIGHUP : constant Interrupt_ID :=
356 + System.OS_Interface.SIGHUP; -- hangup
358 + SIGINT : constant Interrupt_ID :=
359 + System.OS_Interface.SIGINT; -- interrupt (rubout)
361 + SIGQUIT : constant Interrupt_ID :=
362 + System.OS_Interface.SIGQUIT; -- quit (ASCD FS)
364 + SIGILL : constant Interrupt_ID :=
365 + System.OS_Interface.SIGILL; -- illegal instruction (not reset)
367 + SIGTRAP : constant Interrupt_ID :=
368 + System.OS_Interface.SIGTRAP; -- trace trap (not reset)
370 + SIGIOT : constant Interrupt_ID :=
371 + System.OS_Interface.SIGIOT; -- IOT instruction
373 + SIGABRT : constant Interrupt_ID := -- used by abort,
374 + System.OS_Interface.SIGABRT; -- replace SIGIOT in the future
376 + SIGFPE : constant Interrupt_ID :=
377 + System.OS_Interface.SIGFPE; -- floating point exception
379 + SIGKILL : constant Interrupt_ID :=
380 + System.OS_Interface.SIGKILL; -- kill (cannot be caught or ignored)
382 + SIGBUS : constant Interrupt_ID :=
383 + System.OS_Interface.SIGBUS; -- bus error
385 + SIGSEGV : constant Interrupt_ID :=
386 + System.OS_Interface.SIGSEGV; -- segmentation violation
388 + SIGPIPE : constant Interrupt_ID := -- write on a pipe with
389 + System.OS_Interface.SIGPIPE; -- no one to read it
391 + SIGALRM : constant Interrupt_ID :=
392 + System.OS_Interface.SIGALRM; -- alarm clock
394 + SIGTERM : constant Interrupt_ID :=
395 + System.OS_Interface.SIGTERM; -- software termination signal from kill
397 + SIGURG : constant Interrupt_ID :=
398 + System.OS_Interface.SIGURG; -- urgent condition on IO channel
400 + SIGSTOP : constant Interrupt_ID :=
401 + System.OS_Interface.SIGSTOP; -- stop (cannot be caught or ignored)
403 + SIGTSTP : constant Interrupt_ID :=
404 + System.OS_Interface.SIGTSTP; -- user stop requested from tty
406 + SIGCONT : constant Interrupt_ID :=
407 + System.OS_Interface.SIGCONT; -- stopped process has been continued
409 + SIGCHLD : constant Interrupt_ID :=
410 + System.OS_Interface.SIGCHLD; -- 4.3BSD's/POSIX name for SIGCLD
412 + SIGCLD : constant Interrupt_ID :=
413 + System.OS_Interface.SIGCLD; -- child status change
415 + SIGTTIN : constant Interrupt_ID :=
416 + System.OS_Interface.SIGTTIN; -- background tty read attempted
418 + SIGTTOU : constant Interrupt_ID :=
419 + System.OS_Interface.SIGTTOU; -- background tty write attempted
421 + SIGIO : constant Interrupt_ID := -- input/output possible,
422 + System.OS_Interface.SIGIO; -- SIGPOLL alias (Solaris)
424 + SIGXCPU : constant Interrupt_ID :=
425 + System.OS_Interface.SIGXCPU; -- CPU time limit exceeded
427 + SIGXFSZ : constant Interrupt_ID :=
428 + System.OS_Interface.SIGXFSZ; -- filesize limit exceeded
430 + SIGVTALRM : constant Interrupt_ID :=
431 + System.OS_Interface.SIGVTALRM; -- virtual timer expired
433 + SIGPROF : constant Interrupt_ID :=
434 + System.OS_Interface.SIGPROF; -- profiling timer expired
436 + SIGWINCH : constant Interrupt_ID :=
437 + System.OS_Interface.SIGWINCH; -- window size change
439 + SIGUSR1 : constant Interrupt_ID :=
440 + System.OS_Interface.SIGUSR1; -- user defined signal 1
442 + SIGUSR2 : constant Interrupt_ID :=
443 + System.OS_Interface.SIGUSR2; -- user defined signal 2
445 +end Ada.Interrupts.Names;
446 --- gcc/ada/adaint.c.orig
448 @@ -1077,6 +1077,7 @@
449 strcpy (path, "GNAT-XXXXXX");
451 #if (defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) \
452 + || defined (DragonFly) \
453 || defined (linux) || defined(__GLIBC__)) && !defined (__vxworks)
454 return mkstemp (path);
455 #elif defined (__Lynx__)
456 @@ -1227,7 +1228,49 @@
460 +#elif defined (__ANDROID__)
463 + * ext2 /ext3/ext4/fat16/fat32 have no path limits
464 + * /data/local/tmp normally requires rooted devices, if it even exists
465 + * /sdcard is the standard location for external storage. Nativeactivity
466 + * manifest needs to authorize its use, otherwise it might not have the
467 + * proper permissions.
471 + char *datadir = getenv ("ANDROID_DATA");
473 + if (datadir == NULL)
474 + strcpy (tmp_filename, "/data/local/tmp/gnat-XXXXXX");
476 + sprintf (tmp_filename, "%s/local/tmp/gnat-XXXXXX", datadir);
478 + testfd = mkstemp (tmp_filename);
485 + char *sdcard = getenv ("EXTERNAL_STORAGE");
487 + if (sdcard == NULL)
488 + strcpy (tmp_filename, "/sdcard/gnat-XXXXXX");
490 + sprintf (tmp_filename, "%s/gnat-XXXXXX", sdcard);
492 + testfd = mkstemp (tmp_filename);
499 + tmpnam (tmp_filename);
501 #elif defined (linux) || defined (__FreeBSD__) || defined (__NetBSD__) \
502 + || defined (__DragonFly__) \
503 || defined (__OpenBSD__) || defined(__GLIBC__)
504 #define MAX_SAFE_PATH 1000
505 char *tmpdir = getenv ("TMPDIR");
506 @@ -2468,6 +2511,8 @@
509 #if defined (linux) || defined (sun) || defined (AIX) \
510 + || defined (__FreeBSD__) || defined (__DragonFly__) \
511 + || defined (__OpenBSD__) || defined (__NetBSD__) \
512 || (defined (__alpha__) && defined (_osf_)) || defined (__APPLE__)
513 cores = (int) sysconf (_SC_NPROCESSORS_ONLN);
515 @@ -3530,26 +3575,214 @@
519 -#if defined (IS_CROSS) \
520 - || (! ((defined (sparc) || defined (i386)) && defined (sun) \
521 - && defined (__SVR4)) \
522 - && ! (defined (linux) && (defined (i386) || defined (__x86_64__))) \
523 - && ! (defined (linux) && defined (__ia64__)) \
524 - && ! (defined (linux) && defined (powerpc)) \
525 - && ! defined (__FreeBSD__) \
526 - && ! defined (__Lynx__) \
527 - && ! defined (__hpux__) \
528 - && ! defined (__APPLE__) \
529 - && ! defined (_AIX) \
530 - && ! (defined (__alpha__) && defined (__osf__)) \
531 - && ! defined (VMS) \
532 - && ! defined (__MINGW32__) \
533 - && ! (defined (__mips) && defined (__sgi)))
535 -/* Dummy function to satisfy g-trasym.o. See the preprocessor conditional
536 - just above for a list of native platforms that provide a non-dummy
537 - version of this procedure in libaddr2line.a. */
538 +/* run-time symbolic traceback support */
539 +#if defined (__DragonFly__) \
540 + || defined (__FreeBSD__) \
541 + || defined (__OpenBSD__) \
542 + || defined (__NetBSD__) \
543 + || (defined (__sun__) && defined (__i386__) && defined (__SVR4))
545 +/* The above platforms use the external program /usr/bin/addr2line */
546 +#define EXTERNAL_SYMTRACE
548 +#elif defined (VMS) \
549 + || defined (_AIX) \
550 + || defined (__Lynx__) \
551 + || defined (__hpux__) \
552 + || defined (__APPLE__) \
553 + || defined (__MINGW32__) \
554 + || (defined (__mips) && defined (__sgi)) \
555 + || (defined (__alpha__) && defined (__osf__)) \
556 + || (defined (linux) && defined (i386)) \
557 + || (defined (linux) && defined (powerpc)) \
558 + || (defined (linux) && defined (__ia64__)) \
559 + || (defined (linux) && defined (__x86_64__)) \
560 + || (defined (__SVR4) && defined (__sun__) && defined (sparc))
562 +/* The above platforms use the system library libaddr2line.a */
563 +#define NATIVE_SYMTRACE
566 +#if defined (EXTERNAL_SYMTRACE) && !defined (IS_CROSS)
569 + Copyright (C) 1999 by Juergen Pfeifer <juergen.pfeifer@gmx.net>
570 + Ada for Linux Team (ALT)
571 + Heavily modified by John Marino <http://www.dragonlace.net>
573 + Permission is hereby granted, free of charge, to any person obtaining a
574 + copy of this software and associated documentation files (the
575 + "Software"), to deal in the Software without restriction, including
576 + without limitation the rights to use, copy, modify, merge, publish,
577 + distribute, distribute with modifications, sublicense, and/or sell
578 + copies of the Software, and to permit persons to whom the Software is
579 + furnished to do so, subject to the following conditions:
581 + The above copyright notice and this permission notice shall be included
582 + in all copies or substantial portions of the Software.
584 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
585 + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
586 + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
587 + IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
588 + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
589 + OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
590 + THE USE OR OTHER DEALINGS IN THE SOFTWARE.
592 + Except as contained in this notice, the name(s) of the above copyright
593 + holders shall not be used in advertising or otherwise to promote the
594 + sale, use or other dealings in this Software without prior written
598 +#include <sys/types.h>
604 +#define CLOSE_SENDPIPE close(sendpipe[0]); close(sendpipe[1])
605 +#define CLOSE_READPIPE close(readpipe[0]); close(readpipe[1])
606 +#define DUP2CLOSE(oldfd, newfd) dup2(oldfd, newfd); close(oldfd);
607 +#define RESTSIG sigaction(SIGPIPE,&oact,NULL)
609 +#define MAX_LINE 1024
610 +#define PARENT_READ readpipe[0]
611 +#define CHILD_WRITE readpipe[1]
612 +#define CHILD_READ sendpipe[0]
613 +#define PARENT_WRITE sendpipe[1]
615 +#if defined (__sun__)
616 +#define ADDR2LINE_PROG "/usr/gnu/bin/addr2line"
618 +#define ADDR2LINE_PROG "/usr/bin/addr2line"
622 +convert_addresses (const char *file_name,
628 + int max_len = *len;
631 + struct sigaction act, oact;
633 + int sendpipe[2] = {-1,-1}, /* parent -> child */
634 + readpipe[2] = {-1,-1}; /* parent <- child */
637 + act.sa_handler = SIG_IGN;
638 + sigemptyset(&act.sa_mask);
640 + if (sigaction(SIGPIPE,&act,&oact) < 0)
643 + if (pipe(sendpipe) < 0) { RESTSIG; return; }
644 + if (pipe(readpipe) < 0) { CLOSE_SENDPIPE; RESTSIG; return; }
645 + if ((childpid = fork()) < 0) {
652 + if (childpid == 0) { /* child process */
653 + close(PARENT_WRITE);
654 + close(PARENT_READ);
655 + if ((CHILD_READ != STDIN_FILENO) && (CHILD_WRITE != STDOUT_FILENO)) {
656 + if ((CHILD_READ == STDOUT_FILENO) && (CHILD_WRITE == STDIN_FILENO)) {
657 + const int temp_fd = dup(CHILD_WRITE);
658 + close (CHILD_WRITE);
659 + DUP2CLOSE (CHILD_READ, STDIN_FILENO);
660 + DUP2CLOSE (temp_fd, STDOUT_FILENO);
662 + else if ((CHILD_READ == STDIN_FILENO) && (CHILD_WRITE > 1)) {
663 + DUP2CLOSE (CHILD_WRITE, STDOUT_FILENO);
665 + else if ((CHILD_READ > 1) && (CHILD_WRITE == STDOUT_FILENO)) {
666 + DUP2CLOSE (CHILD_READ, STDIN_FILENO);
668 + else if ((CHILD_READ > 1) && (CHILD_WRITE == STDIN_FILENO)) {
669 + DUP2CLOSE (CHILD_WRITE, STDOUT_FILENO);
670 + DUP2CLOSE (CHILD_READ, STDIN_FILENO);
673 + /* CHILD_READ >= 1 and CHILD_WRITE > 1 */
674 + DUP2CLOSE (CHILD_READ, STDIN_FILENO);
675 + DUP2CLOSE (CHILD_WRITE, STDOUT_FILENO);
678 + /* As pointed out by Florian Weimer to JP, it is a security threat to call
679 + the script with a user defined environment and using the path. That
680 + would be Trojans pleasure. Therefore the absolute path to addr2line
681 + and an empty environment is used. That should be safe.
683 + char *const argv[] = { "addr2line",
689 + char *const envp[] = { NULL };
690 + if (execve(ADDR2LINE_PROG, argv, envp) < 0) {
691 + close (CHILD_WRITE);
692 + close (CHILD_READ);
698 + /* Below this line is parent process */
701 + char line[MAX_LINE + 1];
704 + long *trace_address = addrs;
706 + close(CHILD_WRITE);
709 + for(i=0; i < n_addr; i++) {
710 + snprintf(hex,sizeof(hex),"%#lx\n",*trace_address);
711 + write(PARENT_WRITE,hex,strlen(hex));
712 + n = read(PARENT_READ,line,MAX_LINE);
717 + /* We have approx. 16 additional chars for "%#lx in " clause.
718 + We use this info to prevent a buffer overrun. */
719 + if (n + 16 + (*len) > max_len)
722 + p = strchr(line,'\n');
726 + *len += snprintf(s, (max_len - (*len)), "%#lx in %s at %s",
727 + *trace_address, line, p+1);
730 + *len += snprintf(s, (max_len - (*len)), "%#lx at %s",
731 + *trace_address, line);
735 + trace_address += 1;
737 + close (PARENT_WRITE);
738 + close (PARENT_READ);
742 +#elif defined (IS_CROSS) || !defined (NATIVE_SYMTRACE)
744 +/* run-time symbolic traceback support
745 + Dummy function to satisfy g-trasym.o. */
747 convert_addresses (const char *file_name ATTRIBUTE_UNUSED,
748 void *addrs ATTRIBUTE_UNUSED,
749 --- gcc/ada/cio.c.orig
753 /* Don't use macros on GNU/Linux since they cause incompatible changes between
756 +/* Android is The exception because it uses the BIONIC library */
757 +#if defined(linux) && !defined(__ANDROID__)
761 --- gcc/ada/cstreams.c.orig
762 +++ gcc/ada/cstreams.c
768 +#if defined(linux) && !defined(__ANDROID__)
769 /* Don't use macros on GNU/Linux since they cause incompatible changes between
771 +/* Android is The exception because it uses the BIONIC library */
779 -#elif defined (sgi) || defined (__FreeBSD__)
780 +#elif defined (sgi) \
781 + || defined (__FreeBSD__) \
782 + || defined (__DragonFly__) \
783 + || defined (__OpenBSD__)
785 /* Use realpath function which resolves links and references to . and ..
786 on those Unix systems that support it. Note that GNU/Linux provides it but
787 --- gcc/ada/env.c.orig
793 -#elif (defined (__vxworks) && defined (__RTP__)) || defined (__APPLE__)
794 +#elif (defined (__vxworks) && defined (__RTP__)) \
795 + || defined (__APPLE__) \
796 + || defined (__OpenBSD__)
797 setenv (name, value, 1);
802 #elif defined (__MINGW32__) || defined (__FreeBSD__) || defined (__APPLE__) \
803 || (defined (__vxworks) && defined (__RTP__)) || defined (__CYGWIN__) \
804 + || defined (__DragonFly__) \
805 || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__rtems__)
806 /* On Windows, FreeBSD and MacOS there is no function to clean all the
807 environment but there is a "clean" way to unset a variable. So go
808 --- gcc/ada/errno.c.orig
813 #define _SGI_MP_SOURCE
814 +#define GNAT_SET_ERRNO
824 +/* The ANDROID errno.h file also defines __set_errno as an external variable
825 + for use with syscalls. It should not be referenced directly, but we are
826 + going to do it anyway because the alternative solution is to rename all
827 + uses of __set_errno in GNAT. */
829 +#undef GNAT_SET_ERRNO
840 +#ifdef GNAT_SET_ERRNO
847 --- gcc/ada/g-comlin.adb.orig
848 +++ gcc/ada/g-comlin.adb
851 Index_In_Switches := 0;
853 + Param := Parameter_None;
855 -- Remove all leading spaces first to make sure that Index points
856 -- at the start of the first switch.
857 --- gcc/ada/g-expect.adb.orig
858 +++ gcc/ada/g-expect.adb
859 @@ -1332,15 +1332,20 @@
861 -- The following commands are not executed on Unix systems, and are only
862 -- required for Windows systems. We are now in the parent process.
863 + -- Although the if-statement is redundant, it's here so the compiler
864 + -- doesn't complain about uninitialized variables.
866 - -- Restore the old descriptors
867 + if No_Fork_On_Target then
869 - Dup2 (Input, GNAT.OS_Lib.Standin);
870 - Dup2 (Output, GNAT.OS_Lib.Standout);
871 - Dup2 (Error, GNAT.OS_Lib.Standerr);
875 + -- Restore the old descriptors
877 + Dup2 (Input, GNAT.OS_Lib.Standin);
878 + Dup2 (Output, GNAT.OS_Lib.Standout);
879 + Dup2 (Error, GNAT.OS_Lib.Standerr);
884 end Set_Up_Child_Communications;
886 ---------------------------
888 +++ gcc/ada/g-socthi-bsd.adb
890 +------------------------------------------------------------------------------
892 +-- GNAT COMPILER COMPONENTS --
894 +-- G N A T . S O C K E T S . T H I N --
898 +-- Copyright (C) 2001-2010, AdaCore --
900 +-- GNAT is free software; you can redistribute it and/or modify it under --
901 +-- terms of the GNU General Public License as published by the Free Soft- --
902 +-- ware Foundation; either version 3, or (at your option) any later ver- --
903 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
904 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
905 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
907 +-- As a special exception under Section 7 of GPL version 3, you are granted --
908 +-- additional permissions described in the GCC Runtime Library Exception, --
909 +-- version 3.1, as published by the Free Software Foundation. --
911 +-- You should have received a copy of the GNU General Public License and --
912 +-- a copy of the GCC Runtime Library Exception along with this program; --
913 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
914 +-- <http://www.gnu.org/licenses/>. --
916 +-- GNAT was originally developed by the GNAT team at New York University. --
917 +-- Extensive contributions were provided by Ada Core Technologies Inc. --
919 +------------------------------------------------------------------------------
921 +-- This package provides a target dependent thin interface to the sockets
922 +-- layer for use by the GNAT.Sockets package (g-socket.ads). This package
923 +-- should not be directly with'ed by an applications program.
925 +-- This is the *BSD version which uses fcntl rather than ioctl
926 +-- The constant SCON.Thread_Blocking_IO is always true (for all platforms, not
927 +-- just *BSD), so this binding is significantly simpler than the standard
930 +with GNAT.OS_Lib; use GNAT.OS_Lib;
932 +with Interfaces.C; use Interfaces.C;
934 +package body GNAT.Sockets.Thin is
936 + Unknown_System_Error : constant C.Strings.chars_ptr :=
937 + C.Strings.New_String ("Unknown system error");
939 + function Syscall_Accept
941 + Addr : System.Address;
942 + Addrlen : not null access C.int) return C.int;
943 + pragma Import (C, Syscall_Accept, "accept");
944 + -- The accept() function accepts a connection on a socket. An incoming
945 + -- connection is acknowledged and associated with an immediately created
946 + -- socket. The original socket is returned to the listening state.
948 + function Syscall_Connect
950 + Name : System.Address;
951 + Namelen : C.int) return C.int;
952 + pragma Import (C, Syscall_Connect, "connect");
953 + -- The connect() system call initiates a connection on a socket. If the
954 + -- parameter S is of type SOCK_DGRAM then connect() permanently specifies
955 + -- the peer to which datagrams are to be sent. If S is type SOCK_STREAM
956 + -- then connect() attempts to make a connection with another socket, which
957 + -- is identified by the parameter Name.
959 + function Syscall_Recv
961 + Msg : System.Address;
963 + Flags : C.int) return C.int;
964 + pragma Import (C, Syscall_Recv, "recv");
965 + -- The recv() function receives a message from a socket. The call can be
966 + -- used on a connection mode socket or a bound, connectionless socket. If
967 + -- no messages are available at the socket, the recv() call waits for a
968 + -- message to arrive unless the socket is non-blocking. If a socket is
969 + -- non-blocking, the call returns a -1 and ERRNO is set to EWOULDBLOCK.
971 + function Syscall_Recvfrom
973 + Msg : System.Address;
976 + From : System.Address;
977 + Fromlen : not null access C.int) return C.int;
978 + pragma Import (C, Syscall_Recvfrom, "recvfrom");
979 + -- The recvfrom() system call receives a message from a socket and captures
980 + -- the address from which the data was sent. It can be used to receive
981 + -- data on an unconnected socket as well. If no messages are available,
982 + -- the call waits for a message to arrive on blocking sockets. For
983 + -- non-blocking sockets without messages, -1 is returned and ERRNO is set
984 + -- to EAGAIN or EWOULDBLOCK.
986 + function Syscall_Recvmsg
988 + Msg : System.Address;
989 + Flags : C.int) return System.CRTL.ssize_t;
990 + pragma Import (C, Syscall_Recvmsg, "recvmsg");
991 + -- The recvmsg call receives a message from a socket, and can be used to
992 + -- receive data on an unconnected socket as well. If no messages are
993 + -- available, the call waits for a message to arrive on blocking sockets.
994 + -- For non-blocking sockets without messages, -1 is returned and ERRNO is
995 + -- set to EAGAIN or EWOULDBLOCK.
997 + function Syscall_Sendmsg
999 + Msg : System.Address;
1000 + Flags : C.int) return System.CRTL.ssize_t;
1001 + pragma Import (C, Syscall_Sendmsg, "sendmsg");
1002 + -- The sendmsg() function sends a message to a socket, and can be used with
1003 + -- unconnected sockets as well (the msg is ignored in this case). The
1004 + -- function returns the number of bytes sent when successful, otherwise it
1005 + -- returns -1 and ERRNO is set (many possible values).
1007 + function Syscall_Sendto
1009 + Msg : System.Address;
1012 + To : System.Address;
1013 + Tolen : C.int) return C.int;
1014 + pragma Import (C, Syscall_Sendto, "sendto");
1015 + -- The sendto() function only works for connected sockets and it initiates
1016 + -- the transmission of a message. A successful call returns the numbers of
1017 + -- bytes sent, and a failure returns a -1 and ERRNO is set.
1019 + function Syscall_Socket
1022 + Protocol : C.int) return C.int;
1023 + pragma Import (C, Syscall_Socket, "socket");
1024 + -- The socket() function is used to create an unbound socket and returns a
1025 + -- file descriptor that can be used with other socket functions. Upon
1026 + -- failure, a -1 is returned and ERRNO is set.
1028 + procedure Disable_SIGPIPE (S : C.int);
1029 + pragma Import (C, Disable_SIGPIPE, "__gnat_disable_sigpipe");
1031 + procedure Disable_All_SIGPIPEs;
1032 + pragma Import (C, Disable_All_SIGPIPEs, "__gnat_disable_all_sigpipes");
1033 + -- Sets the process to ignore all SIGPIPE signals on platforms that
1034 + -- don't support Disable_SIGPIPE for particular streams.
1039 + Val : C.int) return C.int;
1040 + pragma Import (C, C_Fcntl, "fcntl");
1041 + -- The ioctl of 64-bit DragonFlyBSD, OpenBSD, and NetBSD does not support
1042 + -- setting a socket in non-blocking mode. fcntl must be used instead.
1050 + Addr : System.Address;
1051 + Addrlen : not null access C.int) return C.int
1053 + Res : constant C.int := Syscall_Accept (S, Addr, Addrlen);
1056 + Disable_SIGPIPE (Res);
1065 + function C_Connect
1067 + Name : System.Address;
1068 + Namelen : C.int) return C.int
1072 + return Syscall_Connect (S, Name, Namelen);
1076 + ------------------
1077 + -- Socket_Ioctl --
1078 + ------------------
1080 + function Socket_Ioctl
1083 + Arg : access C.int) return C.int
1085 + -- Currently all requests are of the FIONBIO type, so always calc flags
1087 + flags : constant Unsigned_32 :=
1088 + Unsigned_32 (C_Fcntl (S, SOSC.F_GETFL, 0));
1089 + nonblock : constant Unsigned_32 := Unsigned_32 (SOSC.FNDELAY);
1090 + enabled : constant Boolean := Arg.all = 1;
1093 + if Req = SOSC.FIONBIO then
1095 + newval := C.int (flags or nonblock);
1096 + elsif (flags and nonblock) > 0 then
1097 + newval := C.int (flags - nonblock);
1099 + newval := C.int (flags);
1101 + return C_Fcntl (Fd => S, Cmd => SOSC.F_SETFL, Val => newval);
1103 + return C_Ioctl (Fd => S, Req => Req, Arg => Arg);
1113 + Msg : System.Address;
1115 + Flags : C.int) return C.int
1119 + return Syscall_Recv (S, Msg, Len, Flags);
1127 + function C_Recvfrom
1129 + Msg : System.Address;
1132 + From : System.Address;
1133 + Fromlen : not null access C.int) return C.int
1137 + return Syscall_Recvfrom (S, Msg, Len, Flags, From, Fromlen);
1145 + function C_Recvmsg
1147 + Msg : System.Address;
1148 + Flags : C.int) return System.CRTL.ssize_t
1152 + return Syscall_Recvmsg (S, Msg, Flags);
1160 + function C_Sendmsg
1162 + Msg : System.Address;
1163 + Flags : C.int) return System.CRTL.ssize_t
1167 + return Syscall_Sendmsg (S, Msg, Flags);
1177 + Msg : System.Address;
1180 + To : System.Address;
1181 + Tolen : C.int) return C.int
1185 + return Syscall_Sendto (S, Msg, Len, Flags, To, Tolen);
1196 + Protocol : C.int) return C.int
1198 + Res : constant C.int := Syscall_Socket (Domain, Typ, Protocol);
1201 + Disable_SIGPIPE (Res);
1210 + procedure Finalize is
1215 + -------------------------
1216 + -- Host_Error_Messages --
1217 + -------------------------
1219 + package body Host_Error_Messages is separate;
1225 + procedure Initialize is
1227 + Disable_All_SIGPIPEs;
1230 + --------------------
1231 + -- Signalling_Fds --
1232 + --------------------
1234 + package body Signalling_Fds is
1236 + -- In this default implementation, we use a C version of these
1237 + -- subprograms provided by socket.c.
1239 + function C_Create (Fds : not null access Fd_Pair) return C.int;
1240 + function C_Read (Rsig : C.int) return C.int;
1241 + function C_Write (Wsig : C.int) return C.int;
1242 + procedure C_Close (Sig : C.int);
1244 + pragma Import (C, C_Create, "__gnat_create_signalling_fds");
1245 + pragma Import (C, C_Read, "__gnat_read_signalling_fd");
1246 + pragma Import (C, C_Write, "__gnat_write_signalling_fd");
1247 + pragma Import (C, C_Close, "__gnat_close_signalling_fd");
1250 + (Fds : not null access Fd_Pair) return C.int renames C_Create;
1251 + function Read (Rsig : C.int) return C.int renames C_Read;
1252 + function Write (Wsig : C.int) return C.int renames C_Write;
1253 + procedure Close (Sig : C.int) renames C_Close;
1255 + end Signalling_Fds;
1257 + --------------------------
1258 + -- Socket_Error_Message --
1259 + --------------------------
1261 + function Socket_Error_Message
1262 + (Errno : Integer) return C.Strings.chars_ptr
1265 +end GNAT.Sockets.Thin;
1267 +++ gcc/ada/g-socthi-netbsd.adb
1269 +------------------------------------------------------------------------------
1271 +-- GNAT COMPILER COMPONENTS --
1273 +-- G N A T . S O C K E T S . T H I N --
1277 +-- Copyright (C) 2001-2010, AdaCore --
1279 +-- GNAT is free software; you can redistribute it and/or modify it under --
1280 +-- terms of the GNU General Public License as published by the Free Soft- --
1281 +-- ware Foundation; either version 3, or (at your option) any later ver- --
1282 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
1283 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
1284 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
1286 +-- As a special exception under Section 7 of GPL version 3, you are granted --
1287 +-- additional permissions described in the GCC Runtime Library Exception, --
1288 +-- version 3.1, as published by the Free Software Foundation. --
1290 +-- You should have received a copy of the GNU General Public License and --
1291 +-- a copy of the GCC Runtime Library Exception along with this program; --
1292 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
1293 +-- <http://www.gnu.org/licenses/>. --
1295 +-- GNAT was originally developed by the GNAT team at New York University. --
1296 +-- Extensive contributions were provided by Ada Core Technologies Inc. --
1298 +------------------------------------------------------------------------------
1300 +-- This package provides a target dependent thin interface to the sockets
1301 +-- layer for use by the GNAT.Sockets package (g-socket.ads). This package
1302 +-- should not be directly with'ed by an applications program.
1304 +-- This is the NetBSD version which uses fcntl rather than ioctl
1305 +-- The constant SCON.Thread_Blocking_IO is always true (for all platforms, not
1306 +-- just *BSD), so this binding is significantly simpler than the standard
1307 +-- one it replaces.
1308 +-- NetBSD uses binary compatibility functions that are forcing the use of
1309 +-- their own files rather than sharing the *BSD versions.
1311 +with GNAT.OS_Lib; use GNAT.OS_Lib;
1313 +with Interfaces.C; use Interfaces.C;
1315 +package body GNAT.Sockets.Thin is
1317 + Unknown_System_Error : constant C.Strings.chars_ptr :=
1318 + C.Strings.New_String ("Unknown system error");
1320 + function Syscall_Accept
1322 + Addr : System.Address;
1323 + Addrlen : not null access C.int) return C.int;
1324 + pragma Import (C, Syscall_Accept, "accept");
1325 + -- The accept() function accepts a connection on a socket. An incoming
1326 + -- connection is acknowledged and associated with an immediately created
1327 + -- socket. The original socket is returned to the listening state.
1329 + function Syscall_Connect
1331 + Name : System.Address;
1332 + Namelen : C.int) return C.int;
1333 + pragma Import (C, Syscall_Connect, "connect");
1334 + -- The connect() system call initiates a connection on a socket. If the
1335 + -- parameter S is of type SOCK_DGRAM then connect() permanently specifies
1336 + -- the peer to which datagrams are to be sent. If S is type SOCK_STREAM
1337 + -- then connect() attempts to make a connection with another socket, which
1338 + -- is identified by the parameter Name.
1340 + function Syscall_Recv
1342 + Msg : System.Address;
1344 + Flags : C.int) return C.int;
1345 + pragma Import (C, Syscall_Recv, "recv");
1346 + -- The recv() function receives a message from a socket. The call can be
1347 + -- used on a connection mode socket or a bound, connectionless socket. If
1348 + -- no messages are available at the socket, the recv() call waits for a
1349 + -- message to arrive unless the socket is non-blocking. If a socket is
1350 + -- non-blocking, the call returns a -1 and ERRNO is set to EWOULDBLOCK.
1352 + function Syscall_Recvfrom
1354 + Msg : System.Address;
1357 + From : System.Address;
1358 + Fromlen : not null access C.int) return C.int;
1359 + pragma Import (C, Syscall_Recvfrom, "recvfrom");
1360 + -- The recvfrom() system call receives a message from a socket and captures
1361 + -- the address from which the data was sent. It can be used to receive
1362 + -- data on an unconnected socket as well. If no messages are available,
1363 + -- the call waits for a message to arrive on blocking sockets. For
1364 + -- non-blocking sockets without messages, -1 is returned and ERRNO is set
1365 + -- to EAGAIN or EWOULDBLOCK.
1367 + function Syscall_Recvmsg
1369 + Msg : System.Address;
1370 + Flags : C.int) return System.CRTL.ssize_t;
1371 + pragma Import (C, Syscall_Recvmsg, "recvmsg");
1372 + -- The recvmsg call receives a message from a socket, and can be used to
1373 + -- receive data on an unconnected socket as well. If no messages are
1374 + -- available, the call waits for a message to arrive on blocking sockets.
1375 + -- For non-blocking sockets without messages, -1 is returned and ERRNO is
1376 + -- set to EAGAIN or EWOULDBLOCK.
1378 + function Syscall_Sendmsg
1380 + Msg : System.Address;
1381 + Flags : C.int) return System.CRTL.ssize_t;
1382 + pragma Import (C, Syscall_Sendmsg, "sendmsg");
1383 + -- The sendmsg() function sends a message to a socket, and can be used with
1384 + -- unconnected sockets as well (the msg is ignored in this case). The
1385 + -- function returns the number of bytes sent when successful, otherwise it
1386 + -- returns -1 and ERRNO is set (many possible values).
1388 + function Syscall_Sendto
1390 + Msg : System.Address;
1393 + To : System.Address;
1394 + Tolen : C.int) return C.int;
1395 + pragma Import (C, Syscall_Sendto, "sendto");
1396 + -- The sendto() function only works for connected sockets and it initiates
1397 + -- the transmission of a message. A successful call returns the numbers of
1398 + -- bytes sent, and a failure returns a -1 and ERRNO is set.
1400 + function Syscall_Socket
1403 + Protocol : C.int) return C.int;
1404 + pragma Import (C, Syscall_Socket, "__socket30");
1405 + -- The socket() function is used to create an unbound socket and returns a
1406 + -- file descriptor that can be used with other socket functions. Upon
1407 + -- failure, a -1 is returned and ERRNO is set.
1409 + procedure Disable_SIGPIPE (S : C.int);
1410 + pragma Import (C, Disable_SIGPIPE, "__gnat_disable_sigpipe");
1412 + procedure Disable_All_SIGPIPEs;
1413 + pragma Import (C, Disable_All_SIGPIPEs, "__gnat_disable_all_sigpipes");
1414 + -- Sets the process to ignore all SIGPIPE signals on platforms that
1415 + -- don't support Disable_SIGPIPE for particular streams.
1420 + Val : C.int) return C.int;
1421 + pragma Import (C, C_Fcntl, "fcntl");
1422 + -- The ioctl of 64-bit DragonFlyBSD, OpenBSD, and NetBSD does not support
1423 + -- setting a socket in non-blocking mode. fcntl must be used instead.
1431 + Addr : System.Address;
1432 + Addrlen : not null access C.int) return C.int
1434 + Res : constant C.int := Syscall_Accept (S, Addr, Addrlen);
1437 + Disable_SIGPIPE (Res);
1446 + function C_Connect
1448 + Name : System.Address;
1449 + Namelen : C.int) return C.int
1453 + return Syscall_Connect (S, Name, Namelen);
1457 + ------------------
1458 + -- Socket_Ioctl --
1459 + ------------------
1461 + function Socket_Ioctl
1464 + Arg : access C.int) return C.int
1466 + -- Currently all requests are of the FIONBIO type, so always calc flags
1468 + flags : constant Unsigned_32 :=
1469 + Unsigned_32 (C_Fcntl (S, SOSC.F_GETFL, 0));
1470 + nonblock : constant Unsigned_32 := Unsigned_32 (SOSC.FNDELAY);
1471 + enabled : constant Boolean := Arg.all = 1;
1474 + if Req = SOSC.FIONBIO then
1476 + newval := C.int (flags or nonblock);
1477 + elsif (flags and nonblock) > 0 then
1478 + newval := C.int (flags - nonblock);
1480 + newval := C.int (flags);
1482 + return C_Fcntl (Fd => S, Cmd => SOSC.F_SETFL, Val => newval);
1484 + return C_Ioctl (Fd => S, Req => Req, Arg => Arg);
1494 + Msg : System.Address;
1496 + Flags : C.int) return C.int
1500 + return Syscall_Recv (S, Msg, Len, Flags);
1508 + function C_Recvfrom
1510 + Msg : System.Address;
1513 + From : System.Address;
1514 + Fromlen : not null access C.int) return C.int
1518 + return Syscall_Recvfrom (S, Msg, Len, Flags, From, Fromlen);
1526 + function C_Recvmsg
1528 + Msg : System.Address;
1529 + Flags : C.int) return System.CRTL.ssize_t
1533 + return Syscall_Recvmsg (S, Msg, Flags);
1541 + function C_Sendmsg
1543 + Msg : System.Address;
1544 + Flags : C.int) return System.CRTL.ssize_t
1548 + return Syscall_Sendmsg (S, Msg, Flags);
1558 + Msg : System.Address;
1561 + To : System.Address;
1562 + Tolen : C.int) return C.int
1566 + return Syscall_Sendto (S, Msg, Len, Flags, To, Tolen);
1577 + Protocol : C.int) return C.int
1579 + Res : constant C.int := Syscall_Socket (Domain, Typ, Protocol);
1582 + Disable_SIGPIPE (Res);
1591 + procedure Finalize is
1596 + -------------------------
1597 + -- Host_Error_Messages --
1598 + -------------------------
1600 + package body Host_Error_Messages is separate;
1606 + procedure Initialize is
1608 + Disable_All_SIGPIPEs;
1611 + --------------------
1612 + -- Signalling_Fds --
1613 + --------------------
1615 + package body Signalling_Fds is
1617 + -- In this default implementation, we use a C version of these
1618 + -- subprograms provided by socket.c.
1620 + function C_Create (Fds : not null access Fd_Pair) return C.int;
1621 + function C_Read (Rsig : C.int) return C.int;
1622 + function C_Write (Wsig : C.int) return C.int;
1623 + procedure C_Close (Sig : C.int);
1625 + pragma Import (C, C_Create, "__gnat_create_signalling_fds");
1626 + pragma Import (C, C_Read, "__gnat_read_signalling_fd");
1627 + pragma Import (C, C_Write, "__gnat_write_signalling_fd");
1628 + pragma Import (C, C_Close, "__gnat_close_signalling_fd");
1631 + (Fds : not null access Fd_Pair) return C.int renames C_Create;
1632 + function Read (Rsig : C.int) return C.int renames C_Read;
1633 + function Write (Wsig : C.int) return C.int renames C_Write;
1634 + procedure Close (Sig : C.int) renames C_Close;
1636 + end Signalling_Fds;
1638 + --------------------------
1639 + -- Socket_Error_Message --
1640 + --------------------------
1642 + function Socket_Error_Message
1643 + (Errno : Integer) return C.Strings.chars_ptr
1646 +end GNAT.Sockets.Thin;
1648 +++ gcc/ada/g-socthi-netbsd6.ads
1650 +------------------------------------------------------------------------------
1652 +-- GNAT COMPILER COMPONENTS --
1654 +-- G N A T . S O C K E T S . T H I N --
1658 +-- Copyright (C) 2001-2010, AdaCore --
1660 +-- GNAT is free software; you can redistribute it and/or modify it under --
1661 +-- terms of the GNU General Public License as published by the Free Soft- --
1662 +-- ware Foundation; either version 3, or (at your option) any later ver- --
1663 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
1664 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
1665 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
1667 +-- As a special exception under Section 7 of GPL version 3, you are granted --
1668 +-- additional permissions described in the GCC Runtime Library Exception, --
1669 +-- version 3.1, as published by the Free Software Foundation. --
1671 +-- You should have received a copy of the GNU General Public License and --
1672 +-- a copy of the GCC Runtime Library Exception along with this program; --
1673 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
1674 +-- <http://www.gnu.org/licenses/>. --
1676 +-- GNAT was originally developed by the GNAT team at New York University. --
1677 +-- Extensive contributions were provided by Ada Core Technologies Inc. --
1679 +------------------------------------------------------------------------------
1681 +-- This package provides a target dependent thin interface to the sockets
1682 +-- layer for use by the GNAT.Sockets package (g-socket.ads). This package
1683 +-- should not be directly with'ed by an applications program.
1685 +-- This is the NetBSD 6+ version
1687 +with Interfaces.C.Strings;
1690 +with GNAT.Sockets.Thin_Common;
1695 +package GNAT.Sockets.Thin is
1697 + -- This package is intended for hosts implementing BSD sockets with a
1698 + -- standard interface. It will be used as a default for all the platforms
1699 + -- that do not have a specific version of this file.
1703 + package C renames Interfaces.C;
1705 + use type System.CRTL.ssize_t;
1707 + function Socket_Errno return Integer renames GNAT.OS_Lib.Errno;
1708 + -- Returns last socket error number
1710 + function Socket_Error_Message (Errno : Integer) return C.Strings.chars_ptr;
1711 + -- Returns the error message string for the error number Errno. If Errno is
1712 + -- not known, returns "Unknown system error".
1714 + function Host_Errno return Integer;
1715 + pragma Import (C, Host_Errno, "__gnat_get_h_errno");
1716 + -- Returns last host error number
1718 + package Host_Error_Messages is
1720 + function Host_Error_Message
1721 + (H_Errno : Integer) return C.Strings.chars_ptr;
1722 + -- Returns the error message string for the host error number H_Errno.
1723 + -- If H_Errno is not known, returns "Unknown system error".
1725 + end Host_Error_Messages;
1727 + --------------------------------
1728 + -- Standard library functions --
1729 + --------------------------------
1733 + Addr : System.Address;
1734 + Addrlen : not null access C.int) return C.int;
1738 + Name : System.Address;
1739 + Namelen : C.int) return C.int;
1742 + (Fd : C.int) return C.int;
1744 + function C_Connect
1746 + Name : System.Address;
1747 + Namelen : C.int) return C.int;
1749 + function C_Gethostname
1750 + (Name : System.Address;
1751 + Namelen : C.int) return C.int;
1753 + function C_Getpeername
1755 + Name : System.Address;
1756 + Namelen : not null access C.int) return C.int;
1758 + function C_Getsockname
1760 + Name : System.Address;
1761 + Namelen : not null access C.int) return C.int;
1763 + function C_Getsockopt
1767 + Optval : System.Address;
1768 + Optlen : not null access C.int) return C.int;
1770 + function Socket_Ioctl
1773 + Arg : access C.int) return C.int;
1777 + Backlog : C.int) return C.int;
1781 + Msg : System.Address;
1783 + Flags : C.int) return C.int;
1785 + function C_Recvfrom
1787 + Msg : System.Address;
1790 + From : System.Address;
1791 + Fromlen : not null access C.int) return C.int;
1793 + function C_Recvmsg
1795 + Msg : System.Address;
1796 + Flags : C.int) return System.CRTL.ssize_t;
1800 + Readfds : access Fd_Set;
1801 + Writefds : access Fd_Set;
1802 + Exceptfds : access Fd_Set;
1803 + Timeout : Timeval_Access) return C.int;
1805 + function C_Sendmsg
1807 + Msg : System.Address;
1808 + Flags : C.int) return System.CRTL.ssize_t;
1812 + Msg : System.Address;
1815 + To : System.Address;
1816 + Tolen : C.int) return C.int;
1818 + function C_Setsockopt
1822 + Optval : System.Address;
1823 + Optlen : C.int) return C.int;
1825 + function C_Shutdown
1827 + How : C.int) return C.int;
1832 + Protocol : C.int) return C.int;
1835 + (Command : System.Address) return C.int;
1837 + -------------------------------------------------------
1838 + -- Signalling file descriptors for selector abortion --
1839 + -------------------------------------------------------
1841 + package Signalling_Fds is
1843 + function Create (Fds : not null access Fd_Pair) return C.int;
1844 + pragma Convention (C, Create);
1845 + -- Create a pair of connected descriptors suitable for use with C_Select
1846 + -- (used for signalling in Selector objects).
1848 + function Read (Rsig : C.int) return C.int;
1849 + pragma Convention (C, Read);
1850 + -- Read one byte of data from rsig, the read end of a pair of signalling
1851 + -- fds created by Create_Signalling_Fds.
1853 + function Write (Wsig : C.int) return C.int;
1854 + pragma Convention (C, Write);
1855 + -- Write one byte of data to wsig, the write end of a pair of signalling
1856 + -- fds created by Create_Signalling_Fds.
1858 + procedure Close (Sig : C.int);
1859 + pragma Convention (C, Close);
1860 + -- Close one end of a pair of signalling fds (ignoring any error)
1862 + end Signalling_Fds;
1864 + -------------------------------------------
1865 + -- Nonreentrant network databases access --
1866 + -------------------------------------------
1868 + -- The following are used only on systems that have nonreentrant
1869 + -- getXXXbyYYY functions, and do NOT have corresponding getXXXbyYYY_
1870 + -- functions. Currently, LynxOS is the only such system.
1872 + function Nonreentrant_Gethostbyname
1873 + (Name : C.char_array) return Hostent_Access;
1875 + function Nonreentrant_Gethostbyaddr
1876 + (Addr : System.Address;
1878 + Addr_Type : C.int) return Hostent_Access;
1880 + function Nonreentrant_Getservbyname
1881 + (Name : C.char_array;
1882 + Proto : C.char_array) return Servent_Access;
1884 + function Nonreentrant_Getservbyport
1886 + Proto : C.char_array) return Servent_Access;
1888 + procedure Initialize;
1889 + procedure Finalize;
1892 + pragma Import (C, C_Bind, "bind");
1893 + pragma Import (C, C_Close, "close");
1894 + pragma Import (C, C_Gethostname, "gethostname");
1895 + pragma Import (C, C_Getpeername, "getpeername");
1896 + pragma Import (C, C_Getsockname, "getsockname");
1897 + pragma Import (C, C_Getsockopt, "getsockopt");
1898 + pragma Import (C, C_Listen, "listen");
1899 + pragma Import (C, C_Select, "__select50");
1900 + pragma Import (C, C_Setsockopt, "setsockopt");
1901 + pragma Import (C, C_Shutdown, "shutdown");
1902 + pragma Import (C, C_System, "system");
1904 + pragma Import (C, Nonreentrant_Gethostbyname, "gethostbyname");
1905 + pragma Import (C, Nonreentrant_Gethostbyaddr, "gethostbyaddr");
1906 + pragma Import (C, Nonreentrant_Getservbyname, "getservbyname");
1907 + pragma Import (C, Nonreentrant_Getservbyport, "getservbyport");
1909 +end GNAT.Sockets.Thin;
1911 +++ gcc/ada/g-trasym-bsd.adb
1913 +------------------------------------------------------------------------------
1915 +-- GNAT RUN-TIME COMPONENTS --
1917 +-- G N A T . T R A C E B A C K . S Y M B O L I C --
1921 +-- Copyright (C) 1999-2009, AdaCore --
1923 +-- GNAT is free software; you can redistribute it and/or modify it under --
1924 +-- terms of the GNU General Public License as published by the Free Soft- --
1925 +-- ware Foundation; either version 2, or (at your option) any later ver- --
1926 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
1927 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
1928 +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
1929 +-- for more details. You should have received a copy of the GNU General --
1930 +-- Public License distributed with GNAT; see file COPYING. If not, write --
1931 +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
1932 +-- Boston, MA 02110-1301, USA. --
1934 +-- As a special exception, if other files instantiate generics from this --
1935 +-- unit, or you link this unit with other files to produce an executable, --
1936 +-- this unit does not by itself cause the resulting executable to be --
1937 +-- covered by the GNU General Public License. This exception does not --
1938 +-- however invalidate any other reasons why the executable file might be --
1939 +-- covered by the GNU Public License. --
1941 +-- GNAT was originally developed by the GNAT team at New York University. --
1942 +-- Extensive contributions were provided by Ada Core Technologies Inc. --
1944 +------------------------------------------------------------------------------
1946 +-- Run-time symbolic traceback support
1947 +-- This file is based on the work by Juergen Pfiefer which is still used
1948 +-- today to provide symbolic traceback support for gnu/kFreeBSD.
1949 +-- Incorporated in GNAT-AUX by John Marino <http://www.dragonlace.net>
1951 +with System.Soft_Links;
1952 +with Ada.Exceptions.Traceback; use Ada.Exceptions.Traceback;
1954 +package body GNAT.Traceback.Symbolic is
1956 + package TSL renames System.Soft_Links;
1958 + -- To perform the raw addresses to symbolic form translation we rely on a
1959 + -- libaddr2line symbolizer which examines debug info from a provided
1960 + -- executable file name, and an absolute path is needed to ensure the file
1961 + -- is always found. This is "__gnat_locate_exec_on_path (gnat_argv [0])"
1962 + -- for our executable file, a fairly heavy operation so we cache the
1965 + Exename : System.Address;
1966 + -- Pointer to the name of the executable file to be used on all
1967 + -- invocations of the libaddr2line symbolization service.
1969 + Exename_Resolved : Boolean := False;
1970 + -- Flag to indicate whether we have performed the executable file name
1971 + -- resolution already. Relying on a not null Exename for this purpose
1972 + -- would be potentially inefficient as this is what we will get if the
1973 + -- resolution attempt fails.
1975 + ------------------------
1976 + -- Symbolic_Traceback --
1977 + ------------------------
1979 + function Symbolic_Traceback (Traceback : Tracebacks_Array) return String is
1981 + procedure convert_addresses
1982 + (filename : System.Address;
1983 + addrs : System.Address;
1984 + n_addrs : Integer;
1985 + buf : System.Address;
1986 + len : System.Address);
1987 + pragma Import (C, convert_addresses, "convert_addresses");
1988 + -- This is the procedure version of the Ada-aware addr2line. It places
1989 + -- in BUF a string representing the symbolic translation of the N_ADDRS
1990 + -- raw addresses provided in ADDRS, looked up in debug information from
1991 + -- FILENAME. LEN points to an integer which contains the size of the
1992 + -- BUF buffer at input and the result length at output.
1994 + -- Note that this procedure is *not* thread-safe.
1996 + type Argv_Array is array (0 .. 0) of System.Address;
1997 + gnat_argv : access Argv_Array;
1998 + pragma Import (C, gnat_argv, "gnat_argv");
2000 + function locate_exec_on_path
2001 + (c_exename : System.Address) return System.Address;
2002 + pragma Import (C, locate_exec_on_path, "__gnat_locate_exec_on_path");
2004 + B_Size : constant Integer := 256 * Traceback'Length;
2005 + Len : Integer := B_Size;
2006 + Res : String (1 .. B_Size);
2008 + use type System.Address;
2011 + -- The symbolic translation of an empty set of addresses is an empty
2014 + if Traceback'Length = 0 then
2018 + -- If our input set of raw addresses is not empty, resort to the
2019 + -- libaddr2line service to symbolize it all.
2021 + -- Compute, cache and provide the absolute path to our executable file
2022 + -- name as the binary file where the relevant debug information is to be
2023 + -- found. If the executable file name resolution fails, we have no
2024 + -- sensible basis to invoke the symbolizer at all.
2026 + -- Protect all this against concurrent accesses explicitly, as the
2027 + -- underlying services are potentially thread unsafe.
2029 + TSL.Lock_Task.all;
2031 + if not Exename_Resolved then
2032 + Exename := locate_exec_on_path (gnat_argv (0));
2033 + Exename_Resolved := True;
2036 + if Exename /= System.Null_Address then
2037 + Len := Res'Length;
2039 + (Exename, Traceback'Address, Traceback'Length,
2040 + Res (1)'Address, Len'Address);
2043 + TSL.Unlock_Task.all;
2045 + -- Return what the addr2line symbolizer has produced if we have called
2046 + -- it (the executable name resolution succeeded), or an empty string
2049 + if Exename /= System.Null_Address then
2050 + return Res (1 .. Len);
2055 + end Symbolic_Traceback;
2057 + function Symbolic_Traceback (E : Exception_Occurrence) return String is
2059 + return Symbolic_Traceback (Tracebacks (E));
2060 + end Symbolic_Traceback;
2062 +end GNAT.Traceback.Symbolic;
2063 --- gcc/ada/gnatchop.adb.orig
2064 +++ gcc/ada/gnatchop.adb
2066 Config_File_Name : constant String_Access := new String'("gnat.adc");
2067 -- The name of the file holding the GNAT configuration pragmas
2069 - Gcc : String_Access := new String'("gcc");
2070 + Gcc : String_Access := new String'("ada");
2071 -- May be modified by switch --GCC=
2073 Gcc_Set : Boolean := False;
2074 --- gcc/ada/gnatlink.adb.orig
2075 +++ gcc/ada/gnatlink.adb
2077 -- This table collects the arguments to be passed to compile the binder
2080 - Gcc : String_Access := Program_Name ("gcc", "gnatlink");
2081 + Gcc : String_Access := Program_Name ("ada", "gnatlink");
2083 Read_Mode : constant String := "r" & ASCII.NUL;
2085 --- gcc/ada/gsocket.h.orig
2086 +++ gcc/ada/gsocket.h
2087 @@ -203,8 +203,19 @@
2091 -#if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || \
2092 - defined (__osf__) || defined (_WIN32) || defined (__APPLE__)
2093 +#if defined(__ANDROID__)
2094 +#include <sys/select.h>
2097 +#if defined (_AIX) \
2098 + || defined (__FreeBSD__) \
2099 + || defined (__DragonFly__) \
2100 + || defined (__NetBSD__) \
2101 + || defined (__OpenBSD__) \
2102 + || defined (__hpux__) \
2103 + || defined (__osf__) \
2104 + || defined (_WIN32) \
2105 + || defined (__APPLE__)
2106 # define HAVE_THREAD_SAFE_GETxxxBYyyy 1
2108 #elif defined (sgi) || defined (linux) || defined (__GLIBC__) || \
2109 @@ -236,7 +247,13 @@
2113 -#if defined (__FreeBSD__) || defined (__vxworks) || defined(__rtems__)
2114 +#if defined (__FreeBSD__) \
2115 + || defined (__DragonFly__) \
2116 + || defined (__OpenBSD__) \
2117 + || defined (__NetBSD__) \
2118 + || defined (__ANDROID__) \
2119 + || defined (__vxworks) \
2120 + || defined(__rtems__)
2121 # define Has_Sockaddr_Len 1
2123 # define Has_Sockaddr_Len 0
2124 --- gcc/ada/init.c.orig
2127 /* GNU/Linux Section */
2128 /*********************/
2130 -#elif defined (linux)
2131 +#elif defined (linux) && !defined(__ANDROID__)
2135 @@ -1787,7 +1787,7 @@
2136 /* FreeBSD Section */
2137 /*******************/
2139 -#elif defined (__FreeBSD__)
2140 +#elif defined (__FreeBSD__) || defined (__DragonFly__)
2143 #include <sys/ucontext.h>
2144 @@ -1832,7 +1832,7 @@
2148 -__gnat_install_handler ()
2149 +__gnat_install_handler (void)
2151 struct sigaction act;
2153 @@ -1854,6 +1854,77 @@
2156 /*******************/
2157 +/* Android Section */
2158 +/*******************/
2160 +#elif defined(__ANDROID__)
2162 +#include <signal.h>
2165 +__gnat_error_handler (int sig,
2166 + struct siginfo *si ATTRIBUTE_UNUSED,
2167 + void *ucontext ATTRIBUTE_UNUSED)
2169 + struct Exception_Data *exception;
2175 + exception = &constraint_error;
2180 + exception = &constraint_error;
2185 + exception = &storage_error;
2186 + msg = "stack overflow or erroneous memory access";
2190 + exception = &constraint_error;
2195 + exception = &program_error;
2196 + msg = "unhandled signal";
2199 + Raise_From_Signal_Handler (exception, msg);
2203 +__gnat_install_handler (void)
2205 + struct sigaction act;
2207 + act.sa_sigaction = __gnat_error_handler;
2208 + act.sa_flags = SA_NODEFER | SA_RESTART | SA_SIGINFO;
2209 + sigemptyset (&act.sa_mask);
2211 + /* Do not install handlers if interrupt state is "System". */
2212 + if (__gnat_get_interrupt_state (SIGABRT) != 's')
2213 + sigaction (SIGABRT, &act, NULL);
2214 + if (__gnat_get_interrupt_state (SIGFPE) != 's')
2215 + sigaction (SIGFPE, &act, NULL);
2216 + if (__gnat_get_interrupt_state (SIGILL) != 's')
2217 + sigaction (SIGILL, &act, NULL);
2218 + if (__gnat_get_interrupt_state (SIGBUS) != 's')
2219 + sigaction (SIGBUS, &act, NULL);
2220 + if (__gnat_get_interrupt_state (SIGSEGV) != 's')
2221 + sigaction (SIGSEGV, &act, NULL);
2223 + __gnat_handler_installed = 1;
2227 +/*******************/
2228 /* VxWorks Section */
2229 /*******************/
2231 @@ -2416,9 +2487,13 @@
2232 initialization of the FP processor. This version is used under INTERIX
2235 -#if defined (_WIN32) || defined (__INTERIX) \
2236 - || defined (__Lynx__) || defined(__NetBSD__) || defined(__FreeBSD__) \
2237 - || defined (__OpenBSD__)
2238 +#if defined (_WIN32) \
2239 + || defined (__INTERIX) \
2240 + || defined (__Lynx__) \
2241 + || defined (__NetBSD__) \
2242 + || defined (__FreeBSD__) \
2243 + || defined (__DragonFly__) \
2244 + || defined (__OpenBSD__)
2246 #define HAVE_GNAT_INIT_FLOAT
2248 --- gcc/ada/initialize.c.orig
2249 +++ gcc/ada/initialize.c
2250 @@ -257,8 +257,11 @@
2251 /* __gnat_initialize (init_float version) */
2252 /******************************************/
2254 -#elif defined (__Lynx__) || defined (__FreeBSD__) || defined(__NetBSD__) \
2255 - || defined (__OpenBSD__)
2256 +#elif defined (__Lynx__) \
2257 + || defined (__FreeBSD__) \
2258 + || defined (__DragonFly__) \
2259 + || defined (__NetBSD__) \
2260 + || defined (__OpenBSD__)
2262 extern void __gnat_init_float (void);
2264 --- gcc/ada/link.c.orig
2266 @@ -133,7 +133,10 @@
2267 unsigned char __gnat_separate_run_path_options = 0;
2268 const char *__gnat_default_libgcc_subdir = "lib";
2270 -#elif defined (__FreeBSD__)
2271 +#elif defined (__FreeBSD__) \
2272 + || defined (__DragonFly__) \
2273 + || defined (__OpenBSD__) \
2274 + || defined (__NetBSD__)
2275 const char *__gnat_object_file_option = "-Wl,@";
2276 const char *__gnat_run_path_option = "-Wl,-rpath,";
2277 char __gnat_shared_libgnat_default = STATIC;
2278 --- gcc/ada/make.adb.orig
2279 +++ gcc/ada/make.adb
2281 -- Compiler, Binder & Linker Data and Subprograms --
2282 ----------------------------------------------------
2284 - Gcc : String_Access := Program_Name ("gcc", "gnatmake");
2285 + Gcc : String_Access := Program_Name ("ada", "gnatmake");
2286 Original_Gcc : constant String_Access := Gcc;
2287 -- Original_Gcc is used to check if Gcc has been modified by a switch
2288 -- --GCC=, so that for VM platforms, it is not modified again, as it can
2289 --- gcc/ada/mlib-prj.adb.orig
2290 +++ gcc/ada/mlib-prj.adb
2291 @@ -339,6 +339,11 @@
2293 Foreign_Sources : Boolean;
2295 + Rpath_Disabled : Boolean := False;
2296 + -- If -R is passed through the library options for the linker, it will
2297 + -- prevent the implemented libraries portion of the rpath switch from
2298 + -- being built, even if the linker is capable of supporting rpath.
2300 Rpath : String_Access := null;
2301 -- Allocated only if Path Option is supported
2304 Opts.Table (Opts.Last) :=
2305 new String'("-L" & Name_Buffer (1 .. Name_Len));
2307 - if Path_Option /= null then
2308 + if not Rpath_Disabled and then Path_Option /= null then
2309 Add_Rpath (Name_Buffer (1 .. Name_Len));
2312 @@ -1323,9 +1328,13 @@
2313 Get_Name_String (Element.Value);
2315 if Name_Len /= 0 then
2316 - Opts.Increment_Last;
2317 - Opts.Table (Opts.Last) :=
2318 - new String'(Name_Buffer (1 .. Name_Len));
2319 + if Name_Buffer (1 .. Name_Len) = "-R" then
2320 + Rpath_Disabled := True;
2322 + Opts.Increment_Last;
2323 + Opts.Table (Opts.Last) :=
2324 + new String'(Name_Buffer (1 .. Name_Len));
2328 Current := Element.Next;
2329 --- gcc/ada/mlib-utl.adb.orig
2330 +++ gcc/ada/mlib-utl.adb
2332 if Driver_Name = No_Name then
2333 if Gcc_Exec = null then
2334 if Gcc_Name = null then
2335 - Gcc_Name := Osint.Program_Name ("gcc", "gnatmake");
2336 + Gcc_Name := Osint.Program_Name ("ada", "gnatmake");
2339 Gcc_Exec := Locate_Exec_On_Path (Gcc_Name.all);
2340 --- gcc/ada/prj-makr.adb.orig
2341 +++ gcc/ada/prj-makr.adb
2344 procedure Dup2 (Old_Fd, New_Fd : File_Descriptor);
2346 - Gcc : constant String := "gcc";
2347 + Gcc : constant String := "ada";
2348 Gcc_Path : String_Access := null;
2350 Non_Empty_Node : constant Project_Node_Id := 1;
2351 --- gcc/ada/s-fileio.adb.orig
2352 +++ gcc/ada/s-fileio.adb
2354 Close_Status : int := 0;
2355 Dup_Strm : Boolean := False;
2356 File : AFCB_Ptr renames File_Ptr.all;
2358 + Errno : Integer := 0;
2361 -- Take a task lock, to protect the global data value Open_Files
2363 +++ gcc/ada/s-osinte-android.ads
2365 +------------------------------------------------------------------------------
2367 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
2369 +-- S Y S T E M . O S _ I N T E R F A C E --
2373 +-- Copyright (C) 1991-1994, Florida State University --
2374 +-- Copyright (C) 1995-2010, Free Software Foundation, Inc. --
2376 +-- GNARL is free software; you can redistribute it and/or modify it under --
2377 +-- terms of the GNU General Public License as published by the Free Soft- --
2378 +-- ware Foundation; either version 2, or (at your option) any later ver- --
2379 +-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
2380 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
2381 +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
2382 +-- for more details. You should have received a copy of the GNU General --
2383 +-- Public License distributed with GNARL; see file COPYING. If not, write --
2384 +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
2385 +-- Boston, MA 02110-1301, USA. --
2387 +-- As a special exception, if other files instantiate generics from this --
2388 +-- unit, or you link this unit with other files to produce an executable, --
2389 +-- this unit does not by itself cause the resulting executable to be --
2390 +-- covered by the GNU General Public License. This exception does not --
2391 +-- however invalidate any other reasons why the executable file might be --
2392 +-- covered by the GNU Public License. --
2394 +-- GNARL was developed by the GNARL team at Florida State University. --
2395 +-- Extensive contributions were provided by Ada Core Technologies, Inc. --
2397 +------------------------------------------------------------------------------
2399 +-- This is a GNU/Linux (GNU/LinuxThreads) version of this package
2401 +-- This package encapsulates all direct interfaces to OS services
2402 +-- that are needed by the tasking run-time (libgnarl).
2404 +-- PLEASE DO NOT add any with-clauses to this package or remove the pragma
2405 +-- Preelaborate. This package is designed to be a bottom-level (leaf) package.
2407 +with Ada.Unchecked_Conversion;
2411 +package System.OS_Interface is
2412 + pragma Preelaborate;
2414 + subtype int is Interfaces.C.int;
2415 + subtype char is Interfaces.C.char;
2416 + subtype short is Interfaces.C.short;
2417 + subtype long is Interfaces.C.long;
2418 + subtype unsigned is Interfaces.C.unsigned;
2419 + subtype unsigned_short is Interfaces.C.unsigned_short;
2420 + subtype unsigned_long is Interfaces.C.unsigned_long;
2421 + subtype unsigned_char is Interfaces.C.unsigned_char;
2422 + subtype plain_char is Interfaces.C.plain_char;
2423 + subtype size_t is Interfaces.C.size_t;
2429 + function errno return int;
2430 + pragma Import (C, errno, "__get_errno");
2432 + EAGAIN : constant := System.Linux.EAGAIN;
2433 + EINTR : constant := System.Linux.EINTR;
2434 + EINVAL : constant := System.Linux.EINVAL;
2435 + ENOMEM : constant := System.Linux.ENOMEM;
2436 + EPERM : constant := System.Linux.EPERM;
2437 + ETIMEDOUT : constant := System.Linux.ETIMEDOUT;
2443 + Max_Interrupt : constant := 63;
2444 + type Signal is new int range 0 .. Max_Interrupt;
2445 + for Signal'Size use int'Size;
2447 + SIGHUP : constant := System.Linux.SIGHUP;
2448 + SIGINT : constant := System.Linux.SIGINT;
2449 + SIGQUIT : constant := System.Linux.SIGQUIT;
2450 + SIGILL : constant := System.Linux.SIGILL;
2451 + SIGTRAP : constant := System.Linux.SIGTRAP;
2452 + SIGIOT : constant := System.Linux.SIGIOT;
2453 + SIGABRT : constant := System.Linux.SIGABRT;
2454 + SIGFPE : constant := System.Linux.SIGFPE;
2455 + SIGKILL : constant := System.Linux.SIGKILL;
2456 + SIGBUS : constant := System.Linux.SIGBUS;
2457 + SIGSEGV : constant := System.Linux.SIGSEGV;
2458 + SIGPIPE : constant := System.Linux.SIGPIPE;
2459 + SIGALRM : constant := System.Linux.SIGALRM;
2460 + SIGTERM : constant := System.Linux.SIGTERM;
2461 + SIGUSR1 : constant := System.Linux.SIGUSR1;
2462 + SIGUSR2 : constant := System.Linux.SIGUSR2;
2463 + SIGCLD : constant := System.Linux.SIGCLD;
2464 + SIGCHLD : constant := System.Linux.SIGCHLD;
2465 + SIGPWR : constant := System.Linux.SIGPWR;
2466 + SIGWINCH : constant := System.Linux.SIGWINCH;
2467 + SIGURG : constant := System.Linux.SIGURG;
2468 + SIGPOLL : constant := System.Linux.SIGPOLL;
2469 + SIGIO : constant := System.Linux.SIGIO;
2470 + SIGLOST : constant := System.Linux.SIGLOST;
2471 + SIGSTOP : constant := System.Linux.SIGSTOP;
2472 + SIGTSTP : constant := System.Linux.SIGTSTP;
2473 + SIGCONT : constant := System.Linux.SIGCONT;
2474 + SIGTTIN : constant := System.Linux.SIGTTIN;
2475 + SIGTTOU : constant := System.Linux.SIGTTOU;
2476 + SIGVTALRM : constant := System.Linux.SIGVTALRM;
2477 + SIGPROF : constant := System.Linux.SIGPROF;
2478 + SIGXCPU : constant := System.Linux.SIGXCPU;
2479 + SIGXFSZ : constant := System.Linux.SIGXFSZ;
2480 + SIGUNUSED : constant := System.Linux.SIGUNUSED;
2481 + SIGSTKFLT : constant := System.Linux.SIGSTKFLT;
2482 + SIGLTHRRES : constant := System.Linux.SIGLTHRRES;
2483 + SIGLTHRCAN : constant := System.Linux.SIGLTHRCAN;
2484 + SIGLTHRDBG : constant := System.Linux.SIGLTHRDBG;
2486 + SIGADAABORT : constant := SIGABRT;
2487 + -- Change this if you want to use another signal for task abort.
2488 + -- SIGTERM might be a good one.
2490 + type Signal_Set is array (Natural range <>) of Signal;
2492 + Unmasked : constant Signal_Set := (
2494 + -- To enable debugging on multithreaded applications, mark SIGTRAP to
2495 + -- be kept unmasked.
2499 + SIGTTIN, SIGTTOU, SIGTSTP,
2500 + -- Keep these three signals unmasked so that background processes
2501 + -- and IO behaves as normal "C" applications
2504 + -- To avoid confusing the profiler
2507 + -- These two signals actually cannot be masked;
2508 + -- POSIX simply won't allow it.
2510 + SIGLTHRRES, SIGLTHRCAN, SIGLTHRDBG);
2511 + -- These three signals are used by GNU/LinuxThreads starting from
2512 + -- glibc 2.1 (future 2.2).
2514 + Reserved : constant Signal_Set :=
2515 + -- I am not sure why the following two signals are reserved.
2516 + -- I guess they are not supported by this version of GNU/Linux.
2517 + (SIGVTALRM, SIGUNUSED);
2519 + type sigset_t is private;
2521 + function sigaddset (set : access sigset_t; sig : Signal) return int;
2522 + pragma Import (C, sigaddset, "sigaddset");
2524 + function sigdelset (set : access sigset_t; sig : Signal) return int;
2525 + pragma Import (C, sigdelset, "sigdelset");
2527 + function sigfillset (set : access sigset_t) return int;
2528 + pragma Import (C, sigfillset, "sigfillset");
2530 + function sigismember (set : access sigset_t; sig : Signal) return int;
2531 + pragma Import (C, sigismember, "sigismember");
2533 + function sigemptyset (set : access sigset_t) return int;
2534 + pragma Import (C, sigemptyset, "sigemptyset");
2536 + type union_type_3 is new String (1 .. 116);
2537 + type siginfo_t is record
2541 + X_data : union_type_3;
2543 + pragma Convention (C, siginfo_t);
2545 + type struct_sigaction is record
2546 + sa_handler : System.Address;
2547 + sa_mask : sigset_t;
2548 + sa_flags : Interfaces.C.unsigned_long;
2549 + sa_restorer : System.Address;
2551 + pragma Convention (C, struct_sigaction);
2553 + type struct_sigaction_ptr is access all struct_sigaction;
2555 + type Machine_State is record
2556 + eip : unsigned_long;
2557 + ebx : unsigned_long;
2558 + esp : unsigned_long;
2559 + ebp : unsigned_long;
2560 + esi : unsigned_long;
2561 + edi : unsigned_long;
2563 + type Machine_State_Ptr is access all Machine_State;
2565 + SA_SIGINFO : constant := System.Linux.SA_SIGINFO;
2566 + SA_ONSTACK : constant := System.Linux.SA_ONSTACK;
2568 + SIG_BLOCK : constant := 0;
2569 + SIG_UNBLOCK : constant := 1;
2570 + SIG_SETMASK : constant := 2;
2572 + SIG_DFL : constant := 0;
2573 + SIG_IGN : constant := 1;
2575 + function sigaction
2577 + act : struct_sigaction_ptr;
2578 + oact : struct_sigaction_ptr) return int;
2579 + pragma Import (C, sigaction, "sigaction");
2585 + type timespec is private;
2587 + function To_Duration (TS : timespec) return Duration;
2588 + pragma Inline (To_Duration);
2590 + function To_Timespec (D : Duration) return timespec;
2591 + pragma Inline (To_Timespec);
2593 + function sysconf (name : int) return long;
2594 + pragma Import (C, sysconf);
2596 + SC_CLK_TCK : constant := 2;
2597 + SC_NPROCESSORS_ONLN : constant := 84;
2599 + -------------------------
2600 + -- Priority Scheduling --
2601 + -------------------------
2603 + SCHED_OTHER : constant := 0;
2604 + SCHED_FIFO : constant := 1;
2605 + SCHED_RR : constant := 2;
2607 + function To_Target_Priority
2608 + (Prio : System.Any_Priority) return Interfaces.C.int;
2609 + -- Maps System.Any_Priority to a POSIX priority
2615 + type pid_t is private;
2617 + function kill (pid : pid_t; sig : Signal) return int;
2618 + pragma Import (C, kill, "kill");
2620 + function getpid return pid_t;
2621 + pragma Import (C, getpid, "getpid");
2627 + type Thread_Body is access
2628 + function (arg : System.Address) return System.Address;
2629 + pragma Convention (C, Thread_Body);
2631 + function Thread_Body_Access is new
2632 + Ada.Unchecked_Conversion (System.Address, Thread_Body);
2634 + type pthread_t is new unsigned_long;
2635 + subtype Thread_Id is pthread_t;
2637 + function To_pthread_t is new Ada.Unchecked_Conversion
2638 + (unsigned_long, pthread_t);
2640 + type pthread_mutex_t is limited private;
2641 + type pthread_cond_t is limited private;
2642 + type pthread_attr_t is limited private;
2643 + type pthread_mutexattr_t is limited private;
2644 + type pthread_condattr_t is limited private;
2645 + type pthread_key_t is private;
2647 + PTHREAD_CREATE_DETACHED : constant := 1;
2653 + type stack_t is record
2654 + ss_sp : System.Address;
2658 + pragma Convention (C, stack_t);
2660 + function sigaltstack
2661 + (ss : not null access stack_t;
2662 + oss : access stack_t) return int;
2663 + pragma Import (C, sigaltstack, "sigaltstack");
2665 + Alternate_Stack : aliased System.Address;
2666 + pragma Import (C, Alternate_Stack, "__gnat_alternate_stack");
2667 + -- The alternate signal stack for stack overflows
2669 + Alternate_Stack_Size : constant := 16 * 1024;
2670 + -- This must be in keeping with init.c:__gnat_alternate_stack
2672 + function Get_Stack_Base (thread : pthread_t) return Address;
2673 + pragma Inline (Get_Stack_Base);
2674 + -- This is a dummy procedure to share some GNULLI files
2676 + ---------------------------------------
2677 + -- Nonstandard Thread Initialization --
2678 + ---------------------------------------
2680 + procedure pthread_init;
2681 + pragma Inline (pthread_init);
2682 + -- This is a dummy procedure to share some GNULLI files
2684 + -------------------------
2685 + -- POSIX.1c Section 3 --
2686 + -------------------------
2688 + function sigwait (set : access sigset_t; sig : access Signal) return int;
2689 + pragma Import (C, sigwait, "sigwait");
2691 + function pthread_kill (thread : pthread_t; sig : Signal) return int;
2692 + pragma Import (C, pthread_kill, "pthread_kill");
2694 + function pthread_sigmask
2696 + set : access sigset_t;
2697 + oset : access sigset_t) return int;
2698 + pragma Import (C, pthread_sigmask, "pthread_sigmask");
2700 + --------------------------
2701 + -- POSIX.1c Section 11 --
2702 + --------------------------
2704 + function pthread_mutexattr_init
2705 + (attr : access pthread_mutexattr_t) return int;
2706 + pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
2708 + function pthread_mutexattr_destroy
2709 + (attr : access pthread_mutexattr_t) return int;
2710 + pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
2712 + function pthread_mutex_init
2713 + (mutex : access pthread_mutex_t;
2714 + attr : access pthread_mutexattr_t) return int;
2715 + pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
2717 + function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
2718 + pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
2720 + function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
2721 + pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
2723 + function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
2724 + pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
2726 + function pthread_condattr_init
2727 + (attr : access pthread_condattr_t) return int;
2728 + pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
2730 + function pthread_condattr_destroy
2731 + (attr : access pthread_condattr_t) return int;
2732 + pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
2734 + function pthread_cond_init
2735 + (cond : access pthread_cond_t;
2736 + attr : access pthread_condattr_t) return int;
2737 + pragma Import (C, pthread_cond_init, "pthread_cond_init");
2739 + function pthread_cond_destroy (cond : access pthread_cond_t) return int;
2740 + pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
2742 + function pthread_cond_signal (cond : access pthread_cond_t) return int;
2743 + pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
2745 + function pthread_cond_wait
2746 + (cond : access pthread_cond_t;
2747 + mutex : access pthread_mutex_t) return int;
2748 + pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
2750 + function pthread_cond_timedwait
2751 + (cond : access pthread_cond_t;
2752 + mutex : access pthread_mutex_t;
2753 + abstime : access timespec) return int;
2754 + pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
2756 + --------------------------
2757 + -- POSIX.1c Section 13 --
2758 + --------------------------
2760 + type struct_sched_param is record
2761 + sched_priority : int; -- scheduling priority
2763 + pragma Convention (C, struct_sched_param);
2765 + function pthread_setschedparam
2766 + (thread : pthread_t;
2768 + param : access struct_sched_param) return int;
2769 + pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
2771 + function pthread_attr_setschedpolicy
2772 + (attr : access pthread_attr_t;
2773 + policy : int) return int;
2775 + (C, pthread_attr_setschedpolicy, "pthread_attr_setschedpolicy");
2777 + function sched_yield return int;
2778 + pragma Import (C, sched_yield, "sched_yield");
2780 + ---------------------------
2781 + -- P1003.1c - Section 16 --
2782 + ---------------------------
2784 + function pthread_attr_init
2785 + (attributes : access pthread_attr_t) return int;
2786 + pragma Import (C, pthread_attr_init, "pthread_attr_init");
2788 + function pthread_attr_destroy
2789 + (attributes : access pthread_attr_t) return int;
2790 + pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
2792 + function pthread_attr_setdetachstate
2793 + (attr : access pthread_attr_t;
2794 + detachstate : int) return int;
2796 + (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
2798 + function pthread_attr_setstacksize
2799 + (attr : access pthread_attr_t;
2800 + stacksize : size_t) return int;
2801 + pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
2803 + function pthread_create
2804 + (thread : access pthread_t;
2805 + attributes : access pthread_attr_t;
2806 + start_routine : Thread_Body;
2807 + arg : System.Address) return int;
2808 + pragma Import (C, pthread_create, "pthread_create");
2810 + procedure pthread_exit (status : System.Address);
2811 + pragma Import (C, pthread_exit, "pthread_exit");
2813 + function pthread_self return pthread_t;
2814 + pragma Import (C, pthread_self, "pthread_self");
2816 + function lwp_self return System.Address;
2817 + pragma Import (C, lwp_self, "__gnat_lwp_self");
2819 + --------------------------
2820 + -- POSIX.1c Section 17 --
2821 + --------------------------
2823 + function pthread_setspecific
2824 + (key : pthread_key_t;
2825 + value : System.Address) return int;
2826 + pragma Import (C, pthread_setspecific, "pthread_setspecific");
2828 + function pthread_getspecific (key : pthread_key_t) return System.Address;
2829 + pragma Import (C, pthread_getspecific, "pthread_getspecific");
2831 + type destructor_pointer is access procedure (arg : System.Address);
2832 + pragma Convention (C, destructor_pointer);
2834 + function pthread_key_create
2835 + (key : access pthread_key_t;
2836 + destructor : destructor_pointer) return int;
2837 + pragma Import (C, pthread_key_create, "pthread_key_create");
2839 + CPU_SETSIZE : constant := 1_024;
2841 + type bit_field is array (1 .. CPU_SETSIZE) of Boolean;
2842 + for bit_field'Size use CPU_SETSIZE;
2843 + pragma Pack (bit_field);
2844 + pragma Convention (C, bit_field);
2846 + type cpu_set_t is record
2849 + pragma Convention (C, cpu_set_t);
2851 + function pthread_setaffinity_np
2852 + (thread : pthread_t;
2853 + cpusetsize : size_t;
2854 + cpuset : access cpu_set_t) return int;
2855 + pragma Import (C, pthread_setaffinity_np, "pthread_setaffinity_np");
2856 + pragma Weak_External (pthread_setaffinity_np);
2857 + -- Use a weak symbol because this function may be available or not,
2858 + -- depending on the version of the system.
2860 + function pthread_attr_setaffinity_np
2861 + (attr : access pthread_attr_t;
2862 + cpusetsize : size_t;
2863 + cpuset : access cpu_set_t) return int;
2864 + pragma Import (C, pthread_attr_setaffinity_np,
2865 + "pthread_attr_setaffinity_np");
2866 + pragma Weak_External (pthread_attr_setaffinity_np);
2867 + -- Use a weak symbol because this function may be available or not,
2868 + -- depending on the version of the system.
2872 + type sigset_t is array (0 .. 127) of unsigned_char;
2873 + pragma Convention (C, sigset_t);
2874 + for sigset_t'Alignment use Interfaces.C.unsigned_long'Alignment;
2876 + pragma Warnings (Off);
2877 + for struct_sigaction use record
2878 + sa_handler at Linux.sa_handler_pos range 0 .. Standard'Address_Size - 1;
2879 + sa_mask at Linux.sa_mask_pos range 0 .. 1023;
2880 + sa_flags at Linux.sa_flags_pos range 0 .. Standard'Address_Size - 1;
2882 + -- We intentionally leave sa_restorer unspecified and let the compiler
2883 + -- append it after the last field, so disable corresponding warning.
2884 + pragma Warnings (On);
2886 + type pid_t is new int;
2888 + type time_t is new long;
2890 + type timespec is record
2894 + pragma Convention (C, timespec);
2896 + type pthread_attr_t is record
2897 + detachstate : int;
2898 + schedpolicy : int;
2899 + schedparam : struct_sched_param;
2900 + inheritsched : int;
2902 + guardsize : size_t;
2903 + stackaddr_set : int;
2904 + stackaddr : System.Address;
2905 + stacksize : size_t;
2907 + pragma Convention (C, pthread_attr_t);
2909 + type pthread_condattr_t is record
2912 + pragma Convention (C, pthread_condattr_t);
2914 + type pthread_mutexattr_t is record
2917 + pragma Convention (C, pthread_mutexattr_t);
2919 + type pthread_mutex_t is new System.Linux.pthread_mutex_t;
2921 + type unsigned_long_long_t is mod 2 ** 64;
2922 + -- Interfaces.C.Extensions isn't preelaborated so cannot be with-ed
2924 + type pthread_cond_t is array (0 .. 47) of unsigned_char;
2925 + pragma Convention (C, pthread_cond_t);
2926 + for pthread_cond_t'Alignment use unsigned_long_long_t'Alignment;
2928 + type pthread_key_t is new unsigned;
2930 +end System.OS_Interface;
2932 +++ gcc/ada/s-osinte-dragonfly.adb
2934 +------------------------------------------------------------------------------
2936 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
2938 +-- S Y S T E M . O S _ I N T E R F A C E --
2942 +-- Copyright (C) 1991-2009, Free Software Foundation, Inc. --
2944 +-- GNARL is free software; you can redistribute it and/or modify it under --
2945 +-- terms of the GNU General Public License as published by the Free Soft- --
2946 +-- ware Foundation; either version 3, or (at your option) any later ver- --
2947 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
2948 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
2949 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
2951 +-- As a special exception under Section 7 of GPL version 3, you are granted --
2952 +-- additional permissions described in the GCC Runtime Library Exception, --
2953 +-- version 3.1, as published by the Free Software Foundation. --
2955 +-- You should have received a copy of the GNU General Public License and --
2956 +-- a copy of the GCC Runtime Library Exception along with this program; --
2957 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
2958 +-- <http://www.gnu.org/licenses/>. --
2960 +-- GNARL was developed by the GNARL team at Florida State University. It is --
2961 +-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
2962 +-- State University (http://www.gnat.com). --
2964 +------------------------------------------------------------------------------
2966 +-- This is the DragonFly THREADS version of this package
2968 +with Interfaces.C; use Interfaces.C;
2970 +package body System.OS_Interface is
2976 + function Errno return int is
2977 + type int_ptr is access all int;
2979 + function internal_errno return int_ptr;
2980 + pragma Import (C, internal_errno, "__get_errno");
2983 + return (internal_errno.all);
2986 + --------------------
2987 + -- Get_Stack_Base --
2988 + --------------------
2990 + function Get_Stack_Base (thread : pthread_t) return Address is
2991 + pragma Unreferenced (thread);
2993 + return Null_Address;
2994 + end Get_Stack_Base;
2996 + ------------------
2997 + -- pthread_init --
2998 + ------------------
3000 + procedure pthread_init is
3009 + function To_Duration (TS : timespec) return Duration is
3011 + return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
3014 + ------------------------
3015 + -- To_Target_Priority --
3016 + ------------------------
3018 + function To_Target_Priority
3019 + (Prio : System.Any_Priority) return Interfaces.C.int
3022 + return Interfaces.C.int (Prio);
3023 + end To_Target_Priority;
3029 + function To_Timespec (D : Duration) return timespec is
3034 + S := time_t (Long_Long_Integer (D));
3035 + F := D - Duration (S);
3037 + -- If F has negative value due to a round-up, adjust for positive F
3045 + return timespec'(tv_sec => S,
3046 + tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
3049 +end System.OS_Interface;
3051 +++ gcc/ada/s-osinte-dragonfly.ads
3053 +------------------------------------------------------------------------------
3055 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
3057 +-- S Y S T E M . O S _ I N T E R F A C E --
3061 +-- Copyright (C) 1991-1994, Florida State University --
3062 +-- Copyright (C) 1995-2011, Free Software Foundation, Inc. --
3064 +-- GNAT is free software; you can redistribute it and/or modify it under --
3065 +-- terms of the GNU General Public License as published by the Free Soft- --
3066 +-- ware Foundation; either version 3, or (at your option) any later ver- --
3067 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
3068 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
3069 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
3071 +-- As a special exception under Section 7 of GPL version 3, you are granted --
3072 +-- additional permissions described in the GCC Runtime Library Exception, --
3073 +-- version 3.1, as published by the Free Software Foundation. --
3075 +-- You should have received a copy of the GNU General Public License and --
3076 +-- a copy of the GCC Runtime Library Exception along with this program; --
3077 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
3078 +-- <http://www.gnu.org/licenses/>. --
3080 +-- GNARL was developed by the GNARL team at Florida State University. It is --
3081 +-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
3082 +-- State University (http://www.gnat.com). --
3084 +------------------------------------------------------------------------------
3086 +-- This is the DragonFly BSD PTHREADS version of this package
3088 +-- This package encapsulates all direct interfaces to OS services
3089 +-- that are needed by the tasking run-time (libgnarl).
3091 +-- PLEASE DO NOT add any with-clauses to this package or remove the pragma
3092 +-- Preelaborate. This package is designed to be a bottom-level (leaf) package.
3094 +with Ada.Unchecked_Conversion;
3098 +package System.OS_Interface is
3099 + pragma Preelaborate;
3101 + pragma Linker_Options ("-pthread");
3103 + subtype int is Interfaces.C.int;
3104 + subtype short is Interfaces.C.short;
3105 + subtype long is Interfaces.C.long;
3106 + subtype unsigned is Interfaces.C.unsigned;
3107 + subtype unsigned_short is Interfaces.C.unsigned_short;
3108 + subtype unsigned_long is Interfaces.C.unsigned_long;
3109 + subtype unsigned_char is Interfaces.C.unsigned_char;
3110 + subtype plain_char is Interfaces.C.plain_char;
3111 + subtype size_t is Interfaces.C.size_t;
3117 + function Errno return int;
3118 + pragma Inline (Errno);
3120 + EAGAIN : constant := 35;
3121 + EINTR : constant := 4;
3122 + EINVAL : constant := 22;
3123 + ENOMEM : constant := 12;
3124 + ETIMEDOUT : constant := 60;
3130 + Max_Interrupt : constant := 31;
3131 + type Signal is new int range 0 .. Max_Interrupt;
3132 + for Signal'Size use int'Size;
3134 + SIGHUP : constant := 1; -- hangup
3135 + SIGINT : constant := 2; -- interrupt (rubout)
3136 + SIGQUIT : constant := 3; -- quit (ASCD FS)
3137 + SIGILL : constant := 4; -- illegal instruction (not reset)
3138 + SIGTRAP : constant := 5; -- trace trap (not reset)
3139 + SIGIOT : constant := 6; -- IOT instruction
3140 + SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
3141 + SIGEMT : constant := 7; -- EMT instruction
3142 + SIGFPE : constant := 8; -- floating point exception
3143 + SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
3144 + SIGBUS : constant := 10; -- bus error
3145 + SIGSEGV : constant := 11; -- segmentation violation
3146 + SIGSYS : constant := 12; -- bad argument to system call
3147 + SIGPIPE : constant := 13; -- write on a pipe with no one to read it
3148 + SIGALRM : constant := 14; -- alarm clock
3149 + SIGTERM : constant := 15; -- software termination signal from kill
3150 + SIGURG : constant := 16; -- urgent condition on IO channel
3151 + SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
3152 + SIGTSTP : constant := 18; -- user stop requested from tty
3153 + SIGCONT : constant := 19; -- stopped process has been continued
3154 + SIGCLD : constant := 20; -- alias for SIGCHLD
3155 + SIGCHLD : constant := 20; -- child status change
3156 + SIGTTIN : constant := 21; -- background tty read attempted
3157 + SIGTTOU : constant := 22; -- background tty write attempted
3158 + SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias)
3159 + SIGXCPU : constant := 24; -- CPU time limit exceeded
3160 + SIGXFSZ : constant := 25; -- filesize limit exceeded
3161 + SIGVTALRM : constant := 26; -- virtual timer expired
3162 + SIGPROF : constant := 27; -- profiling timer expired
3163 + SIGWINCH : constant := 28; -- window size change
3164 + SIGINFO : constant := 29; -- information request (BSD)
3165 + SIGUSR1 : constant := 30; -- user defined signal 1
3166 + SIGUSR2 : constant := 31; -- user defined signal 2
3168 + SIGADAABORT : constant := SIGABRT;
3169 + -- Change this if you want to use another signal for task abort.
3170 + -- SIGTERM might be a good one.
3172 + type Signal_Set is array (Natural range <>) of Signal;
3174 + -- Interrupts that must be unmasked at all times. DragonFlyBSD
3175 + -- pthreads will not allow an application to mask out any
3176 + -- interrupt needed by the threads library.
3177 + Unmasked : constant Signal_Set :=
3178 + (SIGTRAP, SIGBUS, SIGTTIN, SIGTTOU, SIGTSTP);
3180 + -- DragonFlyBSD will uses SIGPROF for timing. Do not allow a
3181 + -- handler to attach to this signal.
3182 + Reserved : constant Signal_Set := (0 .. 0 => SIGPROF);
3184 + type sigset_t is private;
3186 + function sigaddset
3187 + (set : access sigset_t;
3188 + sig : Signal) return int;
3189 + pragma Import (C, sigaddset, "sigaddset");
3191 + function sigdelset
3192 + (set : access sigset_t;
3193 + sig : Signal) return int;
3194 + pragma Import (C, sigdelset, "sigdelset");
3196 + function sigfillset (set : access sigset_t) return int;
3197 + pragma Import (C, sigfillset, "sigfillset");
3199 + function sigismember
3200 + (set : access sigset_t;
3201 + sig : Signal) return int;
3202 + pragma Import (C, sigismember, "sigismember");
3204 + function sigemptyset (set : access sigset_t) return int;
3205 + pragma Import (C, sigemptyset, "sigemptyset");
3207 + -- sigcontext is architecture dependent, so define it private
3208 + type struct_sigcontext is private;
3210 + type old_struct_sigaction is record
3211 + sa_handler : System.Address;
3212 + sa_mask : sigset_t;
3215 + pragma Convention (C, old_struct_sigaction);
3217 + type new_struct_sigaction is record
3218 + sa_handler : System.Address;
3220 + sa_mask : sigset_t;
3222 + pragma Convention (C, new_struct_sigaction);
3224 + subtype struct_sigaction is new_struct_sigaction;
3225 + type struct_sigaction_ptr is access all struct_sigaction;
3227 + SIG_BLOCK : constant := 1;
3228 + SIG_UNBLOCK : constant := 2;
3229 + SIG_SETMASK : constant := 3;
3231 + SIG_DFL : constant := 0;
3232 + SIG_IGN : constant := 1;
3234 + SA_SIGINFO : constant := 16#0040#;
3235 + SA_ONSTACK : constant := 16#0001#;
3237 + function sigaction
3239 + act : struct_sigaction_ptr;
3240 + oact : struct_sigaction_ptr) return int;
3241 + pragma Import (C, sigaction, "sigaction");
3247 + Time_Slice_Supported : constant Boolean := True;
3248 + -- Indicates whether time slicing is supported (i.e SCHED_RR is supported)
3250 + type timespec is private;
3252 + function nanosleep (rqtp, rmtp : access timespec) return int;
3253 + pragma Import (C, nanosleep, "nanosleep");
3255 + type clockid_t is new unsigned_long;
3257 + function clock_gettime
3258 + (clock_id : clockid_t;
3259 + tp : access timespec)
3261 + pragma Import (C, clock_gettime, "clock_gettime");
3263 + function To_Duration (TS : timespec) return Duration;
3264 + pragma Inline (To_Duration);
3266 + function To_Timespec (D : Duration) return timespec;
3267 + pragma Inline (To_Timespec);
3269 + type struct_timezone is record
3270 + tz_minuteswest : int;
3273 + pragma Convention (C, struct_timezone);
3275 + procedure usleep (useconds : unsigned_long);
3276 + pragma Import (C, usleep, "usleep");
3278 + -------------------------
3279 + -- Priority Scheduling --
3280 + -------------------------
3282 + SCHED_FIFO : constant := 1;
3283 + SCHED_OTHER : constant := 2;
3284 + SCHED_RR : constant := 3;
3286 + function To_Target_Priority
3287 + (Prio : System.Any_Priority) return Interfaces.C.int;
3288 + -- Maps System.Any_Priority to a POSIX priority
3294 + type pid_t is private;
3296 + function kill (pid : pid_t; sig : Signal) return int;
3297 + pragma Import (C, kill, "kill");
3299 + function getpid return pid_t;
3300 + pragma Import (C, getpid, "getpid");
3306 + function lwp_self return System.Address;
3307 + -- lwp_self does not exist on this thread library, revert to pthread_self
3308 + -- which is the closest approximation (with getpid). This function is
3309 + -- needed to share 7staprop.adb across POSIX-like targets.
3310 + pragma Import (C, lwp_self, "pthread_self");
3316 + type Thread_Body is access
3317 + function (arg : System.Address) return System.Address;
3318 + pragma Convention (C, Thread_Body);
3320 + function Thread_Body_Access is new
3321 + Ada.Unchecked_Conversion (System.Address, Thread_Body);
3323 + type pthread_t is private;
3324 + subtype Thread_Id is pthread_t;
3326 + type pthread_mutex_t is limited private;
3327 + type pthread_cond_t is limited private;
3328 + type pthread_attr_t is limited private;
3329 + type pthread_mutexattr_t is limited private;
3330 + type pthread_condattr_t is limited private;
3331 + type pthread_key_t is private;
3333 + PTHREAD_CREATE_DETACHED : constant := 1;
3334 + PTHREAD_CREATE_JOINABLE : constant := 0;
3336 + PTHREAD_SCOPE_PROCESS : constant := 0;
3337 + PTHREAD_SCOPE_SYSTEM : constant := 2;
3339 + -- Read/Write lock not supported on DragonFly. To add support both types
3340 + -- pthread_rwlock_t and pthread_rwlockattr_t must properly be defined
3341 + -- with the associated routines pthread_rwlock_[init/destroy] and
3342 + -- pthread_rwlock_[rdlock/wrlock/unlock].
3344 + subtype pthread_rwlock_t is pthread_mutex_t;
3345 + subtype pthread_rwlockattr_t is pthread_mutexattr_t;
3351 + type stack_t is record
3352 + ss_sp : System.Address;
3356 + pragma Convention (C, stack_t);
3358 + function sigaltstack
3359 + (ss : not null access stack_t;
3360 + oss : access stack_t) return int;
3361 + pragma Import (C, sigaltstack, "sigaltstack");
3363 + Alternate_Stack : aliased System.Address;
3364 + -- This is a dummy definition, never used (Alternate_Stack_Size is null)
3366 + Alternate_Stack_Size : constant := 0;
3367 + -- No alternate signal stack is used on this platform
3369 + Stack_Base_Available : constant Boolean := False;
3370 + -- Indicates whether the stack base is available on this target. This
3371 + -- allows us to share s-osinte.adb between all the FSU run time. Note that
3372 + -- this value can only be true if pthread_t has a complete definition that
3373 + -- corresponds exactly to the C header files.
3375 + function Get_Stack_Base (thread : pthread_t) return Address;
3376 + pragma Inline (Get_Stack_Base);
3377 + -- returns the stack base of the specified thread. Only call this function
3378 + -- when Stack_Base_Available is True.
3380 + function Get_Page_Size return size_t;
3381 + function Get_Page_Size return Address;
3382 + pragma Import (C, Get_Page_Size, "getpagesize");
3383 + -- Returns the size of a page
3385 + PROT_NONE : constant := 0;
3386 + PROT_READ : constant := 1;
3387 + PROT_WRITE : constant := 2;
3388 + PROT_EXEC : constant := 4;
3389 + PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
3390 + PROT_ON : constant := PROT_NONE;
3391 + PROT_OFF : constant := PROT_ALL;
3393 + function mprotect (addr : Address; len : size_t; prot : int) return int;
3394 + pragma Import (C, mprotect);
3396 + ---------------------------------------
3397 + -- Nonstandard Thread Initialization --
3398 + ---------------------------------------
3400 + -- FSU_THREADS requires pthread_init, which is nonstandard and this should
3401 + -- be invoked during the elaboration of s-taprop.adb.
3403 + -- DragonFlyBSD does not require this so we provide an empty Ada body
3405 + procedure pthread_init;
3407 + -------------------------
3408 + -- POSIX.1c Section 3 --
3409 + -------------------------
3412 + (set : access sigset_t;
3413 + sig : access Signal) return int;
3414 + pragma Import (C, sigwait, "sigwait");
3416 + function pthread_kill
3417 + (thread : pthread_t;
3418 + sig : Signal) return int;
3419 + pragma Import (C, pthread_kill, "pthread_kill");
3421 + function pthread_sigmask
3423 + set : access sigset_t;
3424 + oset : access sigset_t) return int;
3425 + pragma Import (C, pthread_sigmask, "pthread_sigmask");
3427 + --------------------------
3428 + -- POSIX.1c Section 11 --
3429 + --------------------------
3431 + function pthread_mutexattr_init
3432 + (attr : access pthread_mutexattr_t) return int;
3433 + pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
3435 + function pthread_mutexattr_destroy
3436 + (attr : access pthread_mutexattr_t) return int;
3437 + pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
3439 + function pthread_mutex_init
3440 + (mutex : access pthread_mutex_t;
3441 + attr : access pthread_mutexattr_t) return int;
3442 + pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
3444 + function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
3445 + pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
3447 + function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
3448 + pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
3450 + function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
3451 + pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
3453 + function pthread_condattr_init
3454 + (attr : access pthread_condattr_t) return int;
3455 + pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
3457 + function pthread_condattr_destroy
3458 + (attr : access pthread_condattr_t) return int;
3459 + pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
3461 + function pthread_cond_init
3462 + (cond : access pthread_cond_t;
3463 + attr : access pthread_condattr_t) return int;
3464 + pragma Import (C, pthread_cond_init, "pthread_cond_init");
3466 + function pthread_cond_destroy (cond : access pthread_cond_t) return int;
3467 + pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
3469 + function pthread_cond_signal (cond : access pthread_cond_t) return int;
3470 + pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
3472 + function pthread_cond_wait
3473 + (cond : access pthread_cond_t;
3474 + mutex : access pthread_mutex_t) return int;
3475 + pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
3477 + function pthread_cond_timedwait
3478 + (cond : access pthread_cond_t;
3479 + mutex : access pthread_mutex_t;
3480 + abstime : access timespec) return int;
3481 + pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
3483 + Relative_Timed_Wait : constant Boolean := False;
3484 + -- pthread_cond_timedwait requires an absolute delay time
3486 + --------------------------
3487 + -- POSIX.1c Section 13 --
3488 + --------------------------
3490 + PTHREAD_PRIO_NONE : constant := 0;
3491 + PTHREAD_PRIO_PROTECT : constant := 2;
3492 + PTHREAD_PRIO_INHERIT : constant := 1;
3494 + function pthread_mutexattr_setprotocol
3495 + (attr : access pthread_mutexattr_t;
3496 + protocol : int) return int;
3498 + (C, pthread_mutexattr_setprotocol, "pthread_mutexattr_setprotocol");
3500 + function pthread_mutexattr_getprotocol
3501 + (attr : access pthread_mutexattr_t;
3502 + protocol : access int) return int;
3504 + (C, pthread_mutexattr_getprotocol, "pthread_mutexattr_getprotocol");
3506 + function pthread_mutexattr_setprioceiling
3507 + (attr : access pthread_mutexattr_t;
3508 + prioceiling : int) return int;
3510 + (C, pthread_mutexattr_setprioceiling,
3511 + "pthread_mutexattr_setprioceiling");
3513 + function pthread_mutexattr_getprioceiling
3514 + (attr : access pthread_mutexattr_t;
3515 + prioceiling : access int) return int;
3517 + (C, pthread_mutexattr_getprioceiling,
3518 + "pthread_mutexattr_getprioceiling");
3520 + type struct_sched_param is record
3521 + sched_priority : int;
3523 + pragma Convention (C, struct_sched_param);
3525 + function pthread_getschedparam
3526 + (thread : pthread_t;
3527 + policy : access int;
3528 + param : access struct_sched_param) return int;
3529 + pragma Import (C, pthread_getschedparam, "pthread_getschedparam");
3531 + function pthread_setschedparam
3532 + (thread : pthread_t;
3534 + param : access struct_sched_param) return int;
3535 + pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
3537 + function pthread_attr_setscope
3538 + (attr : access pthread_attr_t;
3539 + contentionscope : int) return int;
3540 + pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
3542 + function pthread_attr_getscope
3543 + (attr : access pthread_attr_t;
3544 + contentionscope : access int) return int;
3545 + pragma Import (C, pthread_attr_getscope, "pthread_attr_getscope");
3547 + function pthread_attr_setinheritsched
3548 + (attr : access pthread_attr_t;
3549 + inheritsched : int) return int;
3551 + (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
3553 + function pthread_attr_getinheritsched
3554 + (attr : access pthread_attr_t;
3555 + inheritsched : access int) return int;
3557 + (C, pthread_attr_getinheritsched, "pthread_attr_getinheritsched");
3559 + function pthread_attr_setschedpolicy
3560 + (attr : access pthread_attr_t;
3561 + policy : int) return int;
3562 + pragma Import (C, pthread_attr_setschedpolicy,
3563 + "pthread_attr_setschedpolicy");
3565 + function pthread_attr_getschedpolicy
3566 + (attr : access pthread_attr_t;
3567 + policy : access int) return int;
3568 + pragma Import (C, pthread_attr_getschedpolicy,
3569 + "pthread_attr_getschedpolicy");
3571 + function pthread_attr_setschedparam
3572 + (attr : access pthread_attr_t;
3573 + sched_param : int) return int;
3574 + pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
3576 + function pthread_attr_getschedparam
3577 + (attr : access pthread_attr_t;
3578 + sched_param : access int) return int;
3579 + pragma Import (C, pthread_attr_getschedparam, "pthread_attr_getschedparam");
3581 + function sched_yield return int;
3582 + pragma Import (C, sched_yield, "pthread_yield");
3584 + --------------------------
3585 + -- P1003.1c Section 16 --
3586 + --------------------------
3588 + function pthread_attr_init (attributes : access pthread_attr_t) return int;
3589 + pragma Import (C, pthread_attr_init, "pthread_attr_init");
3591 + function pthread_attr_destroy
3592 + (attributes : access pthread_attr_t) return int;
3593 + pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
3595 + function pthread_attr_setdetachstate
3596 + (attr : access pthread_attr_t;
3597 + detachstate : int) return int;
3599 + (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
3601 + function pthread_attr_getdetachstate
3602 + (attr : access pthread_attr_t;
3603 + detachstate : access int) return int;
3605 + (C, pthread_attr_getdetachstate, "pthread_attr_getdetachstate");
3607 + function pthread_attr_getstacksize
3608 + (attr : access pthread_attr_t;
3609 + stacksize : access size_t) return int;
3611 + (C, pthread_attr_getstacksize, "pthread_attr_getstacksize");
3613 + function pthread_attr_setstacksize
3614 + (attr : access pthread_attr_t;
3615 + stacksize : size_t) return int;
3617 + (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
3619 + function pthread_create
3620 + (thread : access pthread_t;
3621 + attributes : access pthread_attr_t;
3622 + start_routine : Thread_Body;
3623 + arg : System.Address) return int;
3624 + pragma Import (C, pthread_create, "pthread_create");
3626 + function pthread_detach (thread : pthread_t) return int;
3627 + pragma Import (C, pthread_detach, "pthread_detach");
3629 + procedure pthread_exit (status : System.Address);
3630 + pragma Import (C, pthread_exit, "pthread_exit");
3632 + function pthread_self return pthread_t;
3633 + pragma Import (C, pthread_self, "pthread_self");
3635 + --------------------------
3636 + -- POSIX.1c Section 17 --
3637 + --------------------------
3639 + function pthread_setspecific
3640 + (key : pthread_key_t;
3641 + value : System.Address) return int;
3642 + pragma Import (C, pthread_setspecific, "pthread_setspecific");
3644 + function pthread_getspecific (key : pthread_key_t) return System.Address;
3645 + pragma Import (C, pthread_getspecific, "pthread_getspecific");
3647 + type destructor_pointer is access procedure (arg : System.Address);
3648 + pragma Convention (C, destructor_pointer);
3650 + function pthread_key_create
3651 + (key : access pthread_key_t;
3652 + destructor : destructor_pointer) return int;
3653 + pragma Import (C, pthread_key_create, "pthread_key_create");
3655 + ------------------------------------
3656 + -- Non-portable Pthread Functions --
3657 + ------------------------------------
3659 + function pthread_set_name_np
3660 + (thread : pthread_t;
3661 + name : System.Address) return int;
3662 + pragma Import (C, pthread_set_name_np, "pthread_set_name_np");
3666 + type sigset_t is array (1 .. 4) of unsigned;
3668 + -- In DragonFlyBSD the component sa_handler turns out to
3669 + -- be one a union type, and the selector is a macro:
3670 + -- #define sa_handler __sigaction_u._handler
3671 + -- #define sa_sigaction __sigaction_u._sigaction
3673 + -- Should we add a signal_context type here ???
3674 + -- How could it be done independent of the CPU architecture ???
3675 + -- sigcontext type is opaque, so it is architecturally neutral.
3676 + -- It is always passed as an access type, so define it as an empty record
3677 + -- since the contents are not used anywhere.
3679 + type struct_sigcontext is null record;
3680 + pragma Convention (C, struct_sigcontext);
3682 + type pid_t is new int;
3684 + type time_t is new long;
3686 + type timespec is record
3690 + pragma Convention (C, timespec);
3692 + type pthread_t is new System.Address;
3693 + type pthread_attr_t is new System.Address;
3694 + type pthread_mutex_t is new System.Address;
3695 + type pthread_mutexattr_t is new System.Address;
3696 + type pthread_cond_t is new System.Address;
3697 + type pthread_condattr_t is new System.Address;
3698 + type pthread_key_t is new int;
3700 +end System.OS_Interface;
3701 --- gcc/ada/s-osinte-freebsd.adb.orig
3702 +++ gcc/ada/s-osinte-freebsd.adb
3704 type int_ptr is access all int;
3706 function internal_errno return int_ptr;
3707 - pragma Import (C, internal_errno, "__error");
3708 + pragma Import (C, internal_errno, "__get_errno");
3711 return (internal_errno.all);
3713 function Get_Stack_Base (thread : pthread_t) return Address is
3714 pragma Unreferenced (thread);
3717 + return Null_Address;
3723 function To_Duration (TS : timespec) return Duration is
3725 - return Duration (TS.ts_sec) + Duration (TS.ts_nsec) / 10#1#E9;
3726 + return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
3729 ------------------------
3734 - return timespec'(ts_sec => S,
3735 - ts_nsec => long (Long_Long_Integer (F * 10#1#E9)));
3736 + return timespec'(tv_sec => S,
3737 + tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
3740 end System.OS_Interface;
3742 +++ gcc/ada/s-osinte-freebsd32.ads
3744 +------------------------------------------------------------------------------
3746 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
3748 +-- S Y S T E M . O S _ I N T E R F A C E --
3752 +-- Copyright (C) 1991-1994, Florida State University --
3753 +-- Copyright (C) 1995-2011, Free Software Foundation, Inc. --
3755 +-- GNAT is free software; you can redistribute it and/or modify it under --
3756 +-- terms of the GNU General Public License as published by the Free Soft- --
3757 +-- ware Foundation; either version 3, or (at your option) any later ver- --
3758 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
3759 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
3760 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
3762 +-- As a special exception under Section 7 of GPL version 3, you are granted --
3763 +-- additional permissions described in the GCC Runtime Library Exception, --
3764 +-- version 3.1, as published by the Free Software Foundation. --
3766 +-- You should have received a copy of the GNU General Public License and --
3767 +-- a copy of the GCC Runtime Library Exception along with this program; --
3768 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
3769 +-- <http://www.gnu.org/licenses/>. --
3771 +-- GNARL was developed by the GNARL team at Florida State University. It is --
3772 +-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
3773 +-- State University (http://www.gnat.com). --
3775 +------------------------------------------------------------------------------
3777 +-- This is the FreeBSD PTHREADS version of this package
3779 +-- This package encapsulates all direct interfaces to OS services
3780 +-- that are needed by the tasking run-time (libgnarl).
3782 +-- PLEASE DO NOT add any with-clauses to this package or remove the pragma
3783 +-- Preelaborate. This package is designed to be a bottom-level (leaf) package.
3785 +with Ada.Unchecked_Conversion;
3789 +package System.OS_Interface is
3790 + pragma Preelaborate;
3792 + pragma Linker_Options ("-pthread");
3794 + subtype int is Interfaces.C.int;
3795 + subtype short is Interfaces.C.short;
3796 + subtype long is Interfaces.C.long;
3797 + subtype unsigned is Interfaces.C.unsigned;
3798 + subtype unsigned_short is Interfaces.C.unsigned_short;
3799 + subtype unsigned_long is Interfaces.C.unsigned_long;
3800 + subtype unsigned_char is Interfaces.C.unsigned_char;
3801 + subtype plain_char is Interfaces.C.plain_char;
3802 + subtype size_t is Interfaces.C.size_t;
3808 + function Errno return int;
3809 + pragma Inline (Errno);
3811 + EAGAIN : constant := 35;
3812 + EINTR : constant := 4;
3813 + EINVAL : constant := 22;
3814 + ENOMEM : constant := 12;
3815 + ETIMEDOUT : constant := 60;
3821 + Max_Interrupt : constant := 31;
3822 + type Signal is new int range 0 .. Max_Interrupt;
3823 + for Signal'Size use int'Size;
3825 + SIGHUP : constant := 1; -- hangup
3826 + SIGINT : constant := 2; -- interrupt (rubout)
3827 + SIGQUIT : constant := 3; -- quit (ASCD FS)
3828 + SIGILL : constant := 4; -- illegal instruction (not reset)
3829 + SIGTRAP : constant := 5; -- trace trap (not reset)
3830 + SIGIOT : constant := 6; -- IOT instruction
3831 + SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
3832 + SIGEMT : constant := 7; -- EMT instruction
3833 + SIGFPE : constant := 8; -- floating point exception
3834 + SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
3835 + SIGBUS : constant := 10; -- bus error
3836 + SIGSEGV : constant := 11; -- segmentation violation
3837 + SIGSYS : constant := 12; -- bad argument to system call
3838 + SIGPIPE : constant := 13; -- write on a pipe with no one to read it
3839 + SIGALRM : constant := 14; -- alarm clock
3840 + SIGTERM : constant := 15; -- software termination signal from kill
3841 + SIGURG : constant := 16; -- urgent condition on IO channel
3842 + SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
3843 + SIGTSTP : constant := 18; -- user stop requested from tty
3844 + SIGCONT : constant := 19; -- stopped process has been continued
3845 + SIGCLD : constant := 20; -- alias for SIGCHLD
3846 + SIGCHLD : constant := 20; -- child status change
3847 + SIGTTIN : constant := 21; -- background tty read attempted
3848 + SIGTTOU : constant := 22; -- background tty write attempted
3849 + SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias)
3850 + SIGXCPU : constant := 24; -- CPU time limit exceeded
3851 + SIGXFSZ : constant := 25; -- filesize limit exceeded
3852 + SIGVTALRM : constant := 26; -- virtual timer expired
3853 + SIGPROF : constant := 27; -- profiling timer expired
3854 + SIGWINCH : constant := 28; -- window size change
3855 + SIGINFO : constant := 29; -- information request (BSD)
3856 + SIGUSR1 : constant := 30; -- user defined signal 1
3857 + SIGUSR2 : constant := 31; -- user defined signal 2
3859 + SIGADAABORT : constant := SIGABRT;
3860 + -- Change this if you want to use another signal for task abort.
3861 + -- SIGTERM might be a good one.
3863 + type Signal_Set is array (Natural range <>) of Signal;
3865 + -- Interrupts that must be unmasked at all times. FreeBSD
3866 + -- pthreads will not allow an application to mask out any
3867 + -- interrupt needed by the threads library.
3868 + Unmasked : constant Signal_Set :=
3869 + (SIGTRAP, SIGBUS, SIGTTIN, SIGTTOU, SIGTSTP);
3871 + -- FreeBSD will uses SIGPROF for timing. Do not allow a
3872 + -- handler to attach to this signal.
3873 + Reserved : constant Signal_Set := (0 .. 0 => SIGPROF);
3875 + type sigset_t is private;
3877 + function sigaddset
3878 + (set : access sigset_t;
3879 + sig : Signal) return int;
3880 + pragma Import (C, sigaddset, "sigaddset");
3882 + function sigdelset
3883 + (set : access sigset_t;
3884 + sig : Signal) return int;
3885 + pragma Import (C, sigdelset, "sigdelset");
3887 + function sigfillset (set : access sigset_t) return int;
3888 + pragma Import (C, sigfillset, "sigfillset");
3890 + function sigismember
3891 + (set : access sigset_t;
3892 + sig : Signal) return int;
3893 + pragma Import (C, sigismember, "sigismember");
3895 + function sigemptyset (set : access sigset_t) return int;
3896 + pragma Import (C, sigemptyset, "sigemptyset");
3898 + -- sigcontext is architecture dependent, so define it private
3899 + type struct_sigcontext is private;
3901 + type old_struct_sigaction is record
3902 + sa_handler : System.Address;
3903 + sa_mask : sigset_t;
3906 + pragma Convention (C, old_struct_sigaction);
3908 + type new_struct_sigaction is record
3909 + sa_handler : System.Address;
3911 + sa_mask : sigset_t;
3913 + pragma Convention (C, new_struct_sigaction);
3915 + subtype struct_sigaction is new_struct_sigaction;
3916 + type struct_sigaction_ptr is access all struct_sigaction;
3918 + SIG_BLOCK : constant := 1;
3919 + SIG_UNBLOCK : constant := 2;
3920 + SIG_SETMASK : constant := 3;
3922 + SIG_DFL : constant := 0;
3923 + SIG_IGN : constant := 1;
3925 + SA_SIGINFO : constant := 16#0040#;
3926 + SA_ONSTACK : constant := 16#0001#;
3928 + function sigaction
3930 + act : struct_sigaction_ptr;
3931 + oact : struct_sigaction_ptr) return int;
3932 + pragma Import (C, sigaction, "sigaction");
3938 + Time_Slice_Supported : constant Boolean := True;
3939 + -- Indicates whether time slicing is supported (i.e SCHED_RR is supported)
3941 + type timespec is private;
3943 + function nanosleep (rqtp, rmtp : access timespec) return int;
3944 + pragma Import (C, nanosleep, "nanosleep");
3946 + type clockid_t is new int;
3948 + function clock_gettime
3949 + (clock_id : clockid_t;
3950 + tp : access timespec)
3952 + pragma Import (C, clock_gettime, "clock_gettime");
3954 + function To_Duration (TS : timespec) return Duration;
3955 + pragma Inline (To_Duration);
3957 + function To_Timespec (D : Duration) return timespec;
3958 + pragma Inline (To_Timespec);
3960 + type struct_timezone is record
3961 + tz_minuteswest : int;
3964 + pragma Convention (C, struct_timezone);
3966 + procedure usleep (useconds : unsigned_long);
3967 + pragma Import (C, usleep, "usleep");
3969 + -------------------------
3970 + -- Priority Scheduling --
3971 + -------------------------
3973 + SCHED_FIFO : constant := 1;
3974 + SCHED_OTHER : constant := 2;
3975 + SCHED_RR : constant := 3;
3977 + function To_Target_Priority
3978 + (Prio : System.Any_Priority) return Interfaces.C.int;
3979 + -- Maps System.Any_Priority to a POSIX priority
3985 + type pid_t is private;
3987 + function kill (pid : pid_t; sig : Signal) return int;
3988 + pragma Import (C, kill, "kill");
3990 + function getpid return pid_t;
3991 + pragma Import (C, getpid, "getpid");
3997 + function lwp_self return System.Address;
3998 + -- lwp_self does not exist on this thread library, revert to pthread_self
3999 + -- which is the closest approximation (with getpid). This function is
4000 + -- needed to share 7staprop.adb across POSIX-like targets.
4001 + pragma Import (C, lwp_self, "pthread_self");
4007 + type Thread_Body is access
4008 + function (arg : System.Address) return System.Address;
4009 + pragma Convention (C, Thread_Body);
4011 + function Thread_Body_Access is new
4012 + Ada.Unchecked_Conversion (System.Address, Thread_Body);
4014 + type pthread_t is private;
4015 + subtype Thread_Id is pthread_t;
4017 + type pthread_mutex_t is limited private;
4018 + type pthread_cond_t is limited private;
4019 + type pthread_attr_t is limited private;
4020 + type pthread_mutexattr_t is limited private;
4021 + type pthread_condattr_t is limited private;
4022 + type pthread_key_t is private;
4024 + PTHREAD_CREATE_DETACHED : constant := 1;
4025 + PTHREAD_CREATE_JOINABLE : constant := 0;
4027 + PTHREAD_SCOPE_PROCESS : constant := 0;
4028 + PTHREAD_SCOPE_SYSTEM : constant := 2;
4030 + -- Read/Write lock not supported on freebsd. To add support both types
4031 + -- pthread_rwlock_t and pthread_rwlockattr_t must properly be defined
4032 + -- with the associated routines pthread_rwlock_[init/destroy] and
4033 + -- pthread_rwlock_[rdlock/wrlock/unlock].
4035 + subtype pthread_rwlock_t is pthread_mutex_t;
4036 + subtype pthread_rwlockattr_t is pthread_mutexattr_t;
4042 + type stack_t is record
4043 + ss_sp : System.Address;
4047 + pragma Convention (C, stack_t);
4049 + function sigaltstack
4050 + (ss : not null access stack_t;
4051 + oss : access stack_t) return int;
4052 + pragma Import (C, sigaltstack, "sigaltstack");
4054 + Alternate_Stack : aliased System.Address;
4055 + -- This is a dummy definition, never used (Alternate_Stack_Size is null)
4057 + Alternate_Stack_Size : constant := 0;
4058 + -- No alternate signal stack is used on this platform
4060 + Stack_Base_Available : constant Boolean := False;
4061 + -- Indicates whether the stack base is available on this target. This
4062 + -- allows us to share s-osinte.adb between all the FSU run time. Note that
4063 + -- this value can only be true if pthread_t has a complete definition that
4064 + -- corresponds exactly to the C header files.
4066 + function Get_Stack_Base (thread : pthread_t) return Address;
4067 + pragma Inline (Get_Stack_Base);
4068 + -- returns the stack base of the specified thread. Only call this function
4069 + -- when Stack_Base_Available is True.
4071 + function Get_Page_Size return size_t;
4072 + function Get_Page_Size return Address;
4073 + pragma Import (C, Get_Page_Size, "getpagesize");
4074 + -- Returns the size of a page
4076 + PROT_NONE : constant := 0;
4077 + PROT_READ : constant := 1;
4078 + PROT_WRITE : constant := 2;
4079 + PROT_EXEC : constant := 4;
4080 + PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
4081 + PROT_ON : constant := PROT_NONE;
4082 + PROT_OFF : constant := PROT_ALL;
4084 + function mprotect (addr : Address; len : size_t; prot : int) return int;
4085 + pragma Import (C, mprotect);
4087 + ---------------------------------------
4088 + -- Nonstandard Thread Initialization --
4089 + ---------------------------------------
4091 + -- FSU_THREADS requires pthread_init, which is nonstandard and this should
4092 + -- be invoked during the elaboration of s-taprop.adb.
4094 + -- FreeBSD does not require this so we provide an empty Ada body
4096 + procedure pthread_init;
4098 + -------------------------
4099 + -- POSIX.1c Section 3 --
4100 + -------------------------
4103 + (set : access sigset_t;
4104 + sig : access Signal) return int;
4105 + pragma Import (C, sigwait, "sigwait");
4107 + function pthread_kill
4108 + (thread : pthread_t;
4109 + sig : Signal) return int;
4110 + pragma Import (C, pthread_kill, "pthread_kill");
4112 + function pthread_sigmask
4114 + set : access sigset_t;
4115 + oset : access sigset_t) return int;
4116 + pragma Import (C, pthread_sigmask, "pthread_sigmask");
4118 + --------------------------
4119 + -- POSIX.1c Section 11 --
4120 + --------------------------
4122 + function pthread_mutexattr_init
4123 + (attr : access pthread_mutexattr_t) return int;
4124 + pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
4126 + function pthread_mutexattr_destroy
4127 + (attr : access pthread_mutexattr_t) return int;
4128 + pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
4130 + function pthread_mutex_init
4131 + (mutex : access pthread_mutex_t;
4132 + attr : access pthread_mutexattr_t) return int;
4133 + pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
4135 + function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
4136 + pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
4138 + function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
4139 + pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
4141 + function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
4142 + pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
4144 + function pthread_condattr_init
4145 + (attr : access pthread_condattr_t) return int;
4146 + pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
4148 + function pthread_condattr_destroy
4149 + (attr : access pthread_condattr_t) return int;
4150 + pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
4152 + function pthread_cond_init
4153 + (cond : access pthread_cond_t;
4154 + attr : access pthread_condattr_t) return int;
4155 + pragma Import (C, pthread_cond_init, "pthread_cond_init");
4157 + function pthread_cond_destroy (cond : access pthread_cond_t) return int;
4158 + pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
4160 + function pthread_cond_signal (cond : access pthread_cond_t) return int;
4161 + pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
4163 + function pthread_cond_wait
4164 + (cond : access pthread_cond_t;
4165 + mutex : access pthread_mutex_t) return int;
4166 + pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
4168 + function pthread_cond_timedwait
4169 + (cond : access pthread_cond_t;
4170 + mutex : access pthread_mutex_t;
4171 + abstime : access timespec) return int;
4172 + pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
4174 + Relative_Timed_Wait : constant Boolean := False;
4175 + -- pthread_cond_timedwait requires an absolute delay time
4177 + --------------------------
4178 + -- POSIX.1c Section 13 --
4179 + --------------------------
4181 + PTHREAD_PRIO_NONE : constant := 0;
4182 + PTHREAD_PRIO_PROTECT : constant := 2;
4183 + PTHREAD_PRIO_INHERIT : constant := 1;
4185 + function pthread_mutexattr_setprotocol
4186 + (attr : access pthread_mutexattr_t;
4187 + protocol : int) return int;
4189 + (C, pthread_mutexattr_setprotocol, "pthread_mutexattr_setprotocol");
4191 + function pthread_mutexattr_getprotocol
4192 + (attr : access pthread_mutexattr_t;
4193 + protocol : access int) return int;
4195 + (C, pthread_mutexattr_getprotocol, "pthread_mutexattr_getprotocol");
4197 + function pthread_mutexattr_setprioceiling
4198 + (attr : access pthread_mutexattr_t;
4199 + prioceiling : int) return int;
4201 + (C, pthread_mutexattr_setprioceiling,
4202 + "pthread_mutexattr_setprioceiling");
4204 + function pthread_mutexattr_getprioceiling
4205 + (attr : access pthread_mutexattr_t;
4206 + prioceiling : access int) return int;
4208 + (C, pthread_mutexattr_getprioceiling,
4209 + "pthread_mutexattr_getprioceiling");
4211 + type struct_sched_param is record
4212 + sched_priority : int;
4214 + pragma Convention (C, struct_sched_param);
4216 + function pthread_getschedparam
4217 + (thread : pthread_t;
4218 + policy : access int;
4219 + param : access struct_sched_param) return int;
4220 + pragma Import (C, pthread_getschedparam, "pthread_getschedparam");
4222 + function pthread_setschedparam
4223 + (thread : pthread_t;
4225 + param : access struct_sched_param) return int;
4226 + pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
4228 + function pthread_attr_setscope
4229 + (attr : access pthread_attr_t;
4230 + contentionscope : int) return int;
4231 + pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
4233 + function pthread_attr_getscope
4234 + (attr : access pthread_attr_t;
4235 + contentionscope : access int) return int;
4236 + pragma Import (C, pthread_attr_getscope, "pthread_attr_getscope");
4238 + function pthread_attr_setinheritsched
4239 + (attr : access pthread_attr_t;
4240 + inheritsched : int) return int;
4242 + (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
4244 + function pthread_attr_getinheritsched
4245 + (attr : access pthread_attr_t;
4246 + inheritsched : access int) return int;
4248 + (C, pthread_attr_getinheritsched, "pthread_attr_getinheritsched");
4250 + function pthread_attr_setschedpolicy
4251 + (attr : access pthread_attr_t;
4252 + policy : int) return int;
4253 + pragma Import (C, pthread_attr_setschedpolicy,
4254 + "pthread_attr_setschedpolicy");
4256 + function pthread_attr_getschedpolicy
4257 + (attr : access pthread_attr_t;
4258 + policy : access int) return int;
4259 + pragma Import (C, pthread_attr_getschedpolicy,
4260 + "pthread_attr_getschedpolicy");
4262 + function pthread_attr_setschedparam
4263 + (attr : access pthread_attr_t;
4264 + sched_param : int) return int;
4265 + pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
4267 + function pthread_attr_getschedparam
4268 + (attr : access pthread_attr_t;
4269 + sched_param : access int) return int;
4270 + pragma Import (C, pthread_attr_getschedparam, "pthread_attr_getschedparam");
4272 + function sched_yield return int;
4273 + pragma Import (C, sched_yield, "pthread_yield");
4275 + --------------------------
4276 + -- P1003.1c Section 16 --
4277 + --------------------------
4279 + function pthread_attr_init (attributes : access pthread_attr_t) return int;
4280 + pragma Import (C, pthread_attr_init, "pthread_attr_init");
4282 + function pthread_attr_destroy
4283 + (attributes : access pthread_attr_t) return int;
4284 + pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
4286 + function pthread_attr_setdetachstate
4287 + (attr : access pthread_attr_t;
4288 + detachstate : int) return int;
4290 + (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
4292 + function pthread_attr_getdetachstate
4293 + (attr : access pthread_attr_t;
4294 + detachstate : access int) return int;
4296 + (C, pthread_attr_getdetachstate, "pthread_attr_getdetachstate");
4298 + function pthread_attr_getstacksize
4299 + (attr : access pthread_attr_t;
4300 + stacksize : access size_t) return int;
4302 + (C, pthread_attr_getstacksize, "pthread_attr_getstacksize");
4304 + function pthread_attr_setstacksize
4305 + (attr : access pthread_attr_t;
4306 + stacksize : size_t) return int;
4308 + (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
4310 + function pthread_create
4311 + (thread : access pthread_t;
4312 + attributes : access pthread_attr_t;
4313 + start_routine : Thread_Body;
4314 + arg : System.Address) return int;
4315 + pragma Import (C, pthread_create, "pthread_create");
4317 + function pthread_detach (thread : pthread_t) return int;
4318 + pragma Import (C, pthread_detach, "pthread_detach");
4320 + procedure pthread_exit (status : System.Address);
4321 + pragma Import (C, pthread_exit, "pthread_exit");
4323 + function pthread_self return pthread_t;
4324 + pragma Import (C, pthread_self, "pthread_self");
4326 + --------------------------
4327 + -- POSIX.1c Section 17 --
4328 + --------------------------
4330 + function pthread_setspecific
4331 + (key : pthread_key_t;
4332 + value : System.Address) return int;
4333 + pragma Import (C, pthread_setspecific, "pthread_setspecific");
4335 + function pthread_getspecific (key : pthread_key_t) return System.Address;
4336 + pragma Import (C, pthread_getspecific, "pthread_getspecific");
4338 + type destructor_pointer is access procedure (arg : System.Address);
4339 + pragma Convention (C, destructor_pointer);
4341 + function pthread_key_create
4342 + (key : access pthread_key_t;
4343 + destructor : destructor_pointer) return int;
4344 + pragma Import (C, pthread_key_create, "pthread_key_create");
4346 + ------------------------------------
4347 + -- Non-portable Pthread Functions --
4348 + ------------------------------------
4350 + function pthread_set_name_np
4351 + (thread : pthread_t;
4352 + name : System.Address) return int;
4353 + pragma Import (C, pthread_set_name_np, "pthread_set_name_np");
4357 + type sigset_t is array (1 .. 4) of unsigned;
4359 + -- In FreeBSD the component sa_handler turns out to
4360 + -- be one a union type, and the selector is a macro:
4361 + -- #define sa_handler __sigaction_u._handler
4362 + -- #define sa_sigaction __sigaction_u._sigaction
4364 + -- Should we add a signal_context type here ???
4365 + -- How could it be done independent of the CPU architecture ???
4366 + -- sigcontext type is opaque, so it is architecturally neutral.
4367 + -- It is always passed as an access type, so define it as an empty record
4368 + -- since the contents are not used anywhere.
4370 + type struct_sigcontext is null record;
4371 + pragma Convention (C, struct_sigcontext);
4373 + type pid_t is new int;
4375 + type time_t is new int;
4377 + type timespec is record
4381 + pragma Convention (C, timespec);
4383 + type pthread_t is new System.Address;
4384 + type pthread_attr_t is new System.Address;
4385 + type pthread_mutex_t is new System.Address;
4386 + type pthread_mutexattr_t is new System.Address;
4387 + type pthread_cond_t is new System.Address;
4388 + type pthread_condattr_t is new System.Address;
4389 + type pthread_key_t is new int;
4391 +end System.OS_Interface;
4393 +++ gcc/ada/s-osinte-freebsd64.ads
4395 +------------------------------------------------------------------------------
4397 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
4399 +-- S Y S T E M . O S _ I N T E R F A C E --
4403 +-- Copyright (C) 1991-1994, Florida State University --
4404 +-- Copyright (C) 1995-2011, Free Software Foundation, Inc. --
4406 +-- GNAT is free software; you can redistribute it and/or modify it under --
4407 +-- terms of the GNU General Public License as published by the Free Soft- --
4408 +-- ware Foundation; either version 3, or (at your option) any later ver- --
4409 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
4410 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
4411 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
4413 +-- As a special exception under Section 7 of GPL version 3, you are granted --
4414 +-- additional permissions described in the GCC Runtime Library Exception, --
4415 +-- version 3.1, as published by the Free Software Foundation. --
4417 +-- You should have received a copy of the GNU General Public License and --
4418 +-- a copy of the GCC Runtime Library Exception along with this program; --
4419 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
4420 +-- <http://www.gnu.org/licenses/>. --
4422 +-- GNARL was developed by the GNARL team at Florida State University. It is --
4423 +-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
4424 +-- State University (http://www.gnat.com). --
4426 +------------------------------------------------------------------------------
4428 +-- This is the FreeBSD PTHREADS version of this package
4430 +-- This package encapsulates all direct interfaces to OS services
4431 +-- that are needed by the tasking run-time (libgnarl).
4433 +-- PLEASE DO NOT add any with-clauses to this package or remove the pragma
4434 +-- Preelaborate. This package is designed to be a bottom-level (leaf) package.
4436 +with Ada.Unchecked_Conversion;
4440 +package System.OS_Interface is
4441 + pragma Preelaborate;
4443 + pragma Linker_Options ("-pthread");
4445 + subtype int is Interfaces.C.int;
4446 + subtype short is Interfaces.C.short;
4447 + subtype long is Interfaces.C.long;
4448 + subtype unsigned is Interfaces.C.unsigned;
4449 + subtype unsigned_short is Interfaces.C.unsigned_short;
4450 + subtype unsigned_long is Interfaces.C.unsigned_long;
4451 + subtype unsigned_char is Interfaces.C.unsigned_char;
4452 + subtype plain_char is Interfaces.C.plain_char;
4453 + subtype size_t is Interfaces.C.size_t;
4454 + subtype int64_t is Interfaces.Integer_64;
4460 + function Errno return int;
4461 + pragma Inline (Errno);
4463 + EAGAIN : constant := 35;
4464 + EINTR : constant := 4;
4465 + EINVAL : constant := 22;
4466 + ENOMEM : constant := 12;
4467 + ETIMEDOUT : constant := 60;
4473 + Max_Interrupt : constant := 31;
4474 + type Signal is new int range 0 .. Max_Interrupt;
4475 + for Signal'Size use int'Size;
4477 + SIGHUP : constant := 1; -- hangup
4478 + SIGINT : constant := 2; -- interrupt (rubout)
4479 + SIGQUIT : constant := 3; -- quit (ASCD FS)
4480 + SIGILL : constant := 4; -- illegal instruction (not reset)
4481 + SIGTRAP : constant := 5; -- trace trap (not reset)
4482 + SIGIOT : constant := 6; -- IOT instruction
4483 + SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
4484 + SIGEMT : constant := 7; -- EMT instruction
4485 + SIGFPE : constant := 8; -- floating point exception
4486 + SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
4487 + SIGBUS : constant := 10; -- bus error
4488 + SIGSEGV : constant := 11; -- segmentation violation
4489 + SIGSYS : constant := 12; -- bad argument to system call
4490 + SIGPIPE : constant := 13; -- write on a pipe with no one to read it
4491 + SIGALRM : constant := 14; -- alarm clock
4492 + SIGTERM : constant := 15; -- software termination signal from kill
4493 + SIGURG : constant := 16; -- urgent condition on IO channel
4494 + SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
4495 + SIGTSTP : constant := 18; -- user stop requested from tty
4496 + SIGCONT : constant := 19; -- stopped process has been continued
4497 + SIGCLD : constant := 20; -- alias for SIGCHLD
4498 + SIGCHLD : constant := 20; -- child status change
4499 + SIGTTIN : constant := 21; -- background tty read attempted
4500 + SIGTTOU : constant := 22; -- background tty write attempted
4501 + SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias)
4502 + SIGXCPU : constant := 24; -- CPU time limit exceeded
4503 + SIGXFSZ : constant := 25; -- filesize limit exceeded
4504 + SIGVTALRM : constant := 26; -- virtual timer expired
4505 + SIGPROF : constant := 27; -- profiling timer expired
4506 + SIGWINCH : constant := 28; -- window size change
4507 + SIGINFO : constant := 29; -- information request (BSD)
4508 + SIGUSR1 : constant := 30; -- user defined signal 1
4509 + SIGUSR2 : constant := 31; -- user defined signal 2
4511 + SIGADAABORT : constant := SIGABRT;
4512 + -- Change this if you want to use another signal for task abort.
4513 + -- SIGTERM might be a good one.
4515 + type Signal_Set is array (Natural range <>) of Signal;
4517 + -- Interrupts that must be unmasked at all times. FreeBSD
4518 + -- pthreads will not allow an application to mask out any
4519 + -- interrupt needed by the threads library.
4520 + Unmasked : constant Signal_Set :=
4521 + (SIGTRAP, SIGBUS, SIGTTIN, SIGTTOU, SIGTSTP);
4523 + -- FreeBSD will uses SIGPROF for timing. Do not allow a
4524 + -- handler to attach to this signal.
4525 + Reserved : constant Signal_Set := (0 .. 0 => SIGPROF);
4527 + type sigset_t is private;
4529 + function sigaddset
4530 + (set : access sigset_t;
4531 + sig : Signal) return int;
4532 + pragma Import (C, sigaddset, "sigaddset");
4534 + function sigdelset
4535 + (set : access sigset_t;
4536 + sig : Signal) return int;
4537 + pragma Import (C, sigdelset, "sigdelset");
4539 + function sigfillset (set : access sigset_t) return int;
4540 + pragma Import (C, sigfillset, "sigfillset");
4542 + function sigismember
4543 + (set : access sigset_t;
4544 + sig : Signal) return int;
4545 + pragma Import (C, sigismember, "sigismember");
4547 + function sigemptyset (set : access sigset_t) return int;
4548 + pragma Import (C, sigemptyset, "sigemptyset");
4550 + -- sigcontext is architecture dependent, so define it private
4551 + type struct_sigcontext is private;
4553 + type old_struct_sigaction is record
4554 + sa_handler : System.Address;
4555 + sa_mask : sigset_t;
4558 + pragma Convention (C, old_struct_sigaction);
4560 + type new_struct_sigaction is record
4561 + sa_handler : System.Address;
4563 + sa_mask : sigset_t;
4565 + pragma Convention (C, new_struct_sigaction);
4567 + subtype struct_sigaction is new_struct_sigaction;
4568 + type struct_sigaction_ptr is access all struct_sigaction;
4570 + SIG_BLOCK : constant := 1;
4571 + SIG_UNBLOCK : constant := 2;
4572 + SIG_SETMASK : constant := 3;
4574 + SIG_DFL : constant := 0;
4575 + SIG_IGN : constant := 1;
4577 + SA_SIGINFO : constant := 16#0040#;
4578 + SA_ONSTACK : constant := 16#0001#;
4580 + function sigaction
4582 + act : struct_sigaction_ptr;
4583 + oact : struct_sigaction_ptr) return int;
4584 + pragma Import (C, sigaction, "sigaction");
4590 + Time_Slice_Supported : constant Boolean := True;
4591 + -- Indicates whether time slicing is supported (i.e SCHED_RR is supported)
4593 + type timespec is private;
4595 + function nanosleep (rqtp, rmtp : access timespec) return int;
4596 + pragma Import (C, nanosleep, "nanosleep");
4598 + type clockid_t is new int;
4600 + function clock_gettime
4601 + (clock_id : clockid_t;
4602 + tp : access timespec)
4604 + pragma Import (C, clock_gettime, "clock_gettime");
4606 + function To_Duration (TS : timespec) return Duration;
4607 + pragma Inline (To_Duration);
4609 + function To_Timespec (D : Duration) return timespec;
4610 + pragma Inline (To_Timespec);
4612 + type struct_timezone is record
4613 + tz_minuteswest : int;
4616 + pragma Convention (C, struct_timezone);
4618 + procedure usleep (useconds : unsigned_long);
4619 + pragma Import (C, usleep, "usleep");
4621 + -------------------------
4622 + -- Priority Scheduling --
4623 + -------------------------
4625 + SCHED_FIFO : constant := 1;
4626 + SCHED_OTHER : constant := 2;
4627 + SCHED_RR : constant := 3;
4629 + function To_Target_Priority
4630 + (Prio : System.Any_Priority) return Interfaces.C.int;
4631 + -- Maps System.Any_Priority to a POSIX priority
4637 + type pid_t is private;
4639 + function kill (pid : pid_t; sig : Signal) return int;
4640 + pragma Import (C, kill, "kill");
4642 + function getpid return pid_t;
4643 + pragma Import (C, getpid, "getpid");
4649 + function lwp_self return System.Address;
4650 + -- lwp_self does not exist on this thread library, revert to pthread_self
4651 + -- which is the closest approximation (with getpid). This function is
4652 + -- needed to share 7staprop.adb across POSIX-like targets.
4653 + pragma Import (C, lwp_self, "pthread_self");
4659 + type Thread_Body is access
4660 + function (arg : System.Address) return System.Address;
4661 + pragma Convention (C, Thread_Body);
4663 + function Thread_Body_Access is new
4664 + Ada.Unchecked_Conversion (System.Address, Thread_Body);
4666 + type pthread_t is private;
4667 + subtype Thread_Id is pthread_t;
4669 + type pthread_mutex_t is limited private;
4670 + type pthread_cond_t is limited private;
4671 + type pthread_attr_t is limited private;
4672 + type pthread_mutexattr_t is limited private;
4673 + type pthread_condattr_t is limited private;
4674 + type pthread_key_t is private;
4676 + PTHREAD_CREATE_DETACHED : constant := 1;
4677 + PTHREAD_CREATE_JOINABLE : constant := 0;
4679 + PTHREAD_SCOPE_PROCESS : constant := 0;
4680 + PTHREAD_SCOPE_SYSTEM : constant := 2;
4682 + -- Read/Write lock not supported on freebsd. To add support both types
4683 + -- pthread_rwlock_t and pthread_rwlockattr_t must properly be defined
4684 + -- with the associated routines pthread_rwlock_[init/destroy] and
4685 + -- pthread_rwlock_[rdlock/wrlock/unlock].
4687 + subtype pthread_rwlock_t is pthread_mutex_t;
4688 + subtype pthread_rwlockattr_t is pthread_mutexattr_t;
4694 + type stack_t is record
4695 + ss_sp : System.Address;
4699 + pragma Convention (C, stack_t);
4701 + function sigaltstack
4702 + (ss : not null access stack_t;
4703 + oss : access stack_t) return int;
4704 + pragma Import (C, sigaltstack, "sigaltstack");
4706 + Alternate_Stack : aliased System.Address;
4707 + -- This is a dummy definition, never used (Alternate_Stack_Size is null)
4709 + Alternate_Stack_Size : constant := 0;
4710 + -- No alternate signal stack is used on this platform
4712 + Stack_Base_Available : constant Boolean := False;
4713 + -- Indicates whether the stack base is available on this target. This
4714 + -- allows us to share s-osinte.adb between all the FSU run time. Note that
4715 + -- this value can only be true if pthread_t has a complete definition that
4716 + -- corresponds exactly to the C header files.
4718 + function Get_Stack_Base (thread : pthread_t) return Address;
4719 + pragma Inline (Get_Stack_Base);
4720 + -- returns the stack base of the specified thread. Only call this function
4721 + -- when Stack_Base_Available is True.
4723 + function Get_Page_Size return size_t;
4724 + function Get_Page_Size return Address;
4725 + pragma Import (C, Get_Page_Size, "getpagesize");
4726 + -- Returns the size of a page
4728 + PROT_NONE : constant := 0;
4729 + PROT_READ : constant := 1;
4730 + PROT_WRITE : constant := 2;
4731 + PROT_EXEC : constant := 4;
4732 + PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
4733 + PROT_ON : constant := PROT_NONE;
4734 + PROT_OFF : constant := PROT_ALL;
4736 + function mprotect (addr : Address; len : size_t; prot : int) return int;
4737 + pragma Import (C, mprotect);
4739 + ---------------------------------------
4740 + -- Nonstandard Thread Initialization --
4741 + ---------------------------------------
4743 + -- FSU_THREADS requires pthread_init, which is nonstandard and this should
4744 + -- be invoked during the elaboration of s-taprop.adb.
4746 + -- FreeBSD does not require this so we provide an empty Ada body
4748 + procedure pthread_init;
4750 + -------------------------
4751 + -- POSIX.1c Section 3 --
4752 + -------------------------
4755 + (set : access sigset_t;
4756 + sig : access Signal) return int;
4757 + pragma Import (C, sigwait, "sigwait");
4759 + function pthread_kill
4760 + (thread : pthread_t;
4761 + sig : Signal) return int;
4762 + pragma Import (C, pthread_kill, "pthread_kill");
4764 + function pthread_sigmask
4766 + set : access sigset_t;
4767 + oset : access sigset_t) return int;
4768 + pragma Import (C, pthread_sigmask, "pthread_sigmask");
4770 + --------------------------
4771 + -- POSIX.1c Section 11 --
4772 + --------------------------
4774 + function pthread_mutexattr_init
4775 + (attr : access pthread_mutexattr_t) return int;
4776 + pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
4778 + function pthread_mutexattr_destroy
4779 + (attr : access pthread_mutexattr_t) return int;
4780 + pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
4782 + function pthread_mutex_init
4783 + (mutex : access pthread_mutex_t;
4784 + attr : access pthread_mutexattr_t) return int;
4785 + pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
4787 + function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
4788 + pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
4790 + function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
4791 + pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
4793 + function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
4794 + pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
4796 + function pthread_condattr_init
4797 + (attr : access pthread_condattr_t) return int;
4798 + pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
4800 + function pthread_condattr_destroy
4801 + (attr : access pthread_condattr_t) return int;
4802 + pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
4804 + function pthread_cond_init
4805 + (cond : access pthread_cond_t;
4806 + attr : access pthread_condattr_t) return int;
4807 + pragma Import (C, pthread_cond_init, "pthread_cond_init");
4809 + function pthread_cond_destroy (cond : access pthread_cond_t) return int;
4810 + pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
4812 + function pthread_cond_signal (cond : access pthread_cond_t) return int;
4813 + pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
4815 + function pthread_cond_wait
4816 + (cond : access pthread_cond_t;
4817 + mutex : access pthread_mutex_t) return int;
4818 + pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
4820 + function pthread_cond_timedwait
4821 + (cond : access pthread_cond_t;
4822 + mutex : access pthread_mutex_t;
4823 + abstime : access timespec) return int;
4824 + pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
4826 + Relative_Timed_Wait : constant Boolean := False;
4827 + -- pthread_cond_timedwait requires an absolute delay time
4829 + --------------------------
4830 + -- POSIX.1c Section 13 --
4831 + --------------------------
4833 + PTHREAD_PRIO_NONE : constant := 0;
4834 + PTHREAD_PRIO_PROTECT : constant := 2;
4835 + PTHREAD_PRIO_INHERIT : constant := 1;
4837 + function pthread_mutexattr_setprotocol
4838 + (attr : access pthread_mutexattr_t;
4839 + protocol : int) return int;
4841 + (C, pthread_mutexattr_setprotocol, "pthread_mutexattr_setprotocol");
4843 + function pthread_mutexattr_getprotocol
4844 + (attr : access pthread_mutexattr_t;
4845 + protocol : access int) return int;
4847 + (C, pthread_mutexattr_getprotocol, "pthread_mutexattr_getprotocol");
4849 + function pthread_mutexattr_setprioceiling
4850 + (attr : access pthread_mutexattr_t;
4851 + prioceiling : int) return int;
4853 + (C, pthread_mutexattr_setprioceiling,
4854 + "pthread_mutexattr_setprioceiling");
4856 + function pthread_mutexattr_getprioceiling
4857 + (attr : access pthread_mutexattr_t;
4858 + prioceiling : access int) return int;
4860 + (C, pthread_mutexattr_getprioceiling,
4861 + "pthread_mutexattr_getprioceiling");
4863 + type struct_sched_param is record
4864 + sched_priority : int;
4866 + pragma Convention (C, struct_sched_param);
4868 + function pthread_getschedparam
4869 + (thread : pthread_t;
4870 + policy : access int;
4871 + param : access struct_sched_param) return int;
4872 + pragma Import (C, pthread_getschedparam, "pthread_getschedparam");
4874 + function pthread_setschedparam
4875 + (thread : pthread_t;
4877 + param : access struct_sched_param) return int;
4878 + pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
4880 + function pthread_attr_setscope
4881 + (attr : access pthread_attr_t;
4882 + contentionscope : int) return int;
4883 + pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
4885 + function pthread_attr_getscope
4886 + (attr : access pthread_attr_t;
4887 + contentionscope : access int) return int;
4888 + pragma Import (C, pthread_attr_getscope, "pthread_attr_getscope");
4890 + function pthread_attr_setinheritsched
4891 + (attr : access pthread_attr_t;
4892 + inheritsched : int) return int;
4894 + (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
4896 + function pthread_attr_getinheritsched
4897 + (attr : access pthread_attr_t;
4898 + inheritsched : access int) return int;
4900 + (C, pthread_attr_getinheritsched, "pthread_attr_getinheritsched");
4902 + function pthread_attr_setschedpolicy
4903 + (attr : access pthread_attr_t;
4904 + policy : int) return int;
4905 + pragma Import (C, pthread_attr_setschedpolicy,
4906 + "pthread_attr_setschedpolicy");
4908 + function pthread_attr_getschedpolicy
4909 + (attr : access pthread_attr_t;
4910 + policy : access int) return int;
4911 + pragma Import (C, pthread_attr_getschedpolicy,
4912 + "pthread_attr_getschedpolicy");
4914 + function pthread_attr_setschedparam
4915 + (attr : access pthread_attr_t;
4916 + sched_param : int) return int;
4917 + pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
4919 + function pthread_attr_getschedparam
4920 + (attr : access pthread_attr_t;
4921 + sched_param : access int) return int;
4922 + pragma Import (C, pthread_attr_getschedparam, "pthread_attr_getschedparam");
4924 + function sched_yield return int;
4925 + pragma Import (C, sched_yield, "pthread_yield");
4927 + --------------------------
4928 + -- P1003.1c Section 16 --
4929 + --------------------------
4931 + function pthread_attr_init (attributes : access pthread_attr_t) return int;
4932 + pragma Import (C, pthread_attr_init, "pthread_attr_init");
4934 + function pthread_attr_destroy
4935 + (attributes : access pthread_attr_t) return int;
4936 + pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
4938 + function pthread_attr_setdetachstate
4939 + (attr : access pthread_attr_t;
4940 + detachstate : int) return int;
4942 + (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
4944 + function pthread_attr_getdetachstate
4945 + (attr : access pthread_attr_t;
4946 + detachstate : access int) return int;
4948 + (C, pthread_attr_getdetachstate, "pthread_attr_getdetachstate");
4950 + function pthread_attr_getstacksize
4951 + (attr : access pthread_attr_t;
4952 + stacksize : access size_t) return int;
4954 + (C, pthread_attr_getstacksize, "pthread_attr_getstacksize");
4956 + function pthread_attr_setstacksize
4957 + (attr : access pthread_attr_t;
4958 + stacksize : size_t) return int;
4960 + (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
4962 + function pthread_create
4963 + (thread : access pthread_t;
4964 + attributes : access pthread_attr_t;
4965 + start_routine : Thread_Body;
4966 + arg : System.Address) return int;
4967 + pragma Import (C, pthread_create, "pthread_create");
4969 + function pthread_detach (thread : pthread_t) return int;
4970 + pragma Import (C, pthread_detach, "pthread_detach");
4972 + procedure pthread_exit (status : System.Address);
4973 + pragma Import (C, pthread_exit, "pthread_exit");
4975 + function pthread_self return pthread_t;
4976 + pragma Import (C, pthread_self, "pthread_self");
4978 + --------------------------
4979 + -- POSIX.1c Section 17 --
4980 + --------------------------
4982 + function pthread_setspecific
4983 + (key : pthread_key_t;
4984 + value : System.Address) return int;
4985 + pragma Import (C, pthread_setspecific, "pthread_setspecific");
4987 + function pthread_getspecific (key : pthread_key_t) return System.Address;
4988 + pragma Import (C, pthread_getspecific, "pthread_getspecific");
4990 + type destructor_pointer is access procedure (arg : System.Address);
4991 + pragma Convention (C, destructor_pointer);
4993 + function pthread_key_create
4994 + (key : access pthread_key_t;
4995 + destructor : destructor_pointer) return int;
4996 + pragma Import (C, pthread_key_create, "pthread_key_create");
4998 + ------------------------------------
4999 + -- Non-portable Pthread Functions --
5000 + ------------------------------------
5002 + function pthread_set_name_np
5003 + (thread : pthread_t;
5004 + name : System.Address) return int;
5005 + pragma Import (C, pthread_set_name_np, "pthread_set_name_np");
5009 + type sigset_t is array (1 .. 4) of unsigned;
5011 + -- In FreeBSD the component sa_handler turns out to
5012 + -- be one a union type, and the selector is a macro:
5013 + -- #define sa_handler __sigaction_u._handler
5014 + -- #define sa_sigaction __sigaction_u._sigaction
5016 + -- Should we add a signal_context type here ???
5017 + -- How could it be done independent of the CPU architecture ???
5018 + -- sigcontext type is opaque, so it is architecturally neutral.
5019 + -- It is always passed as an access type, so define it as an empty record
5020 + -- since the contents are not used anywhere.
5022 + type struct_sigcontext is null record;
5023 + pragma Convention (C, struct_sigcontext);
5025 + type pid_t is new int;
5027 + type time_t is new int64_t;
5029 + type timespec is record
5033 + pragma Convention (C, timespec);
5035 + type pthread_t is new System.Address;
5036 + type pthread_attr_t is new System.Address;
5037 + type pthread_mutex_t is new System.Address;
5038 + type pthread_mutexattr_t is new System.Address;
5039 + type pthread_cond_t is new System.Address;
5040 + type pthread_condattr_t is new System.Address;
5041 + type pthread_key_t is new int;
5043 +end System.OS_Interface;
5045 +++ gcc/ada/s-osinte-netbsd.adb
5047 +------------------------------------------------------------------------------
5049 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
5051 +-- S Y S T E M . O S _ I N T E R F A C E --
5055 +-- Copyright (C) 1991-2009, Free Software Foundation, Inc. --
5057 +-- GNARL is free software; you can redistribute it and/or modify it under --
5058 +-- terms of the GNU General Public License as published by the Free Soft- --
5059 +-- ware Foundation; either version 3, or (at your option) any later ver- --
5060 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
5061 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
5062 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
5064 +-- As a special exception under Section 7 of GPL version 3, you are granted --
5065 +-- additional permissions described in the GCC Runtime Library Exception, --
5066 +-- version 3.1, as published by the Free Software Foundation. --
5068 +-- You should have received a copy of the GNU General Public License and --
5069 +-- a copy of the GCC Runtime Library Exception along with this program; --
5070 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
5071 +-- <http://www.gnu.org/licenses/>. --
5073 +-- GNARL was developed by the GNARL team at Florida State University. It is --
5074 +-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
5075 +-- State University (http://www.gnat.com). --
5077 +------------------------------------------------------------------------------
5079 +-- This is the NetBSD THREADS version of this package
5081 +with Interfaces.C; use Interfaces.C;
5083 +package body System.OS_Interface is
5089 + function Errno return int is
5090 + type int_ptr is access all int;
5092 + function internal_errno return int_ptr;
5093 + pragma Import (C, internal_errno, "__errno");
5096 + return (internal_errno.all);
5099 + --------------------
5100 + -- Get_Stack_Base --
5101 + --------------------
5103 + function Get_Stack_Base (thread : pthread_t) return Address is
5104 + pragma Unreferenced (thread);
5106 + return Null_Address;
5107 + end Get_Stack_Base;
5109 + ------------------
5110 + -- pthread_init --
5111 + ------------------
5113 + procedure pthread_init is
5118 + -----------------------------------
5119 + -- pthread_mutexattr_setprotocol --
5120 + -----------------------------------
5122 + function pthread_mutexattr_setprotocol
5123 + (attr : access pthread_mutexattr_t;
5124 + protocol : int) return int is
5125 + pragma Unreferenced (attr, protocol);
5128 + end pthread_mutexattr_setprotocol;
5130 + --------------------------------------
5131 + -- pthread_mutexattr_setprioceiling --
5132 + --------------------------------------
5134 + function pthread_mutexattr_setprioceiling
5135 + (attr : access pthread_mutexattr_t;
5136 + prioceiling : int) return int is
5137 + pragma Unreferenced (attr, prioceiling);
5140 + end pthread_mutexattr_setprioceiling;
5146 + function To_Duration (TS : timespec) return Duration is
5148 + return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
5151 + ------------------------
5152 + -- To_Target_Priority --
5153 + ------------------------
5155 + function To_Target_Priority
5156 + (Prio : System.Any_Priority) return Interfaces.C.int
5159 + return Interfaces.C.int (Prio);
5160 + end To_Target_Priority;
5166 + function To_Timespec (D : Duration) return timespec is
5171 + S := time_t (Long_Long_Integer (D));
5172 + F := D - Duration (S);
5174 + -- If F has negative value due to a round-up, adjust for positive F
5182 + return timespec'(tv_sec => S,
5183 + tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
5186 +end System.OS_Interface;
5188 +++ gcc/ada/s-osinte-netbsd.ads
5190 +------------------------------------------------------------------------------
5192 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
5194 +-- S Y S T E M . O S _ I N T E R F A C E --
5198 +-- Copyright (C) 1991-1994, Florida State University --
5199 +-- Copyright (C) 1995-2011, Free Software Foundation, Inc. --
5201 +-- GNAT is free software; you can redistribute it and/or modify it under --
5202 +-- terms of the GNU General Public License as published by the Free Soft- --
5203 +-- ware Foundation; either version 3, or (at your option) any later ver- --
5204 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
5205 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
5206 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
5208 +-- As a special exception under Section 7 of GPL version 3, you are granted --
5209 +-- additional permissions described in the GCC Runtime Library Exception, --
5210 +-- version 3.1, as published by the Free Software Foundation. --
5212 +-- You should have received a copy of the GNU General Public License and --
5213 +-- a copy of the GCC Runtime Library Exception along with this program; --
5214 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
5215 +-- <http://www.gnu.org/licenses/>. --
5217 +-- GNARL was developed by the GNARL team at Florida State University. It is --
5218 +-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
5219 +-- State University (http://www.gnat.com). --
5221 +------------------------------------------------------------------------------
5223 +-- This is the NetBSD PTHREADS version of this package.
5224 +-- It is based off of the FreeBSD PTHREADS as of 4.2.3.
5226 +-- This package encapsulates all direct interfaces to OS services
5227 +-- that are needed by the tasking run-time (libgnarl).
5229 +-- PLEASE DO NOT add any with-clauses to this package or remove the pragma
5230 +-- Preelaborate. This package is designed to be a bottom-level (leaf) package.
5232 +with Ada.Unchecked_Conversion;
5236 +package System.OS_Interface is
5237 + pragma Preelaborate;
5239 + pragma Linker_Options ("-pthread");
5241 + subtype int is Interfaces.C.int;
5242 + subtype short is Interfaces.C.short;
5243 + subtype long is Interfaces.C.long;
5244 + subtype unsigned is Interfaces.C.unsigned;
5245 + subtype unsigned_short is Interfaces.C.unsigned_short;
5246 + subtype unsigned_long is Interfaces.C.unsigned_long;
5247 + subtype unsigned_char is Interfaces.C.unsigned_char;
5248 + subtype plain_char is Interfaces.C.plain_char;
5249 + subtype size_t is Interfaces.C.size_t;
5255 + function Errno return int;
5256 + pragma Inline (Errno);
5258 + EAGAIN : constant := 35;
5259 + EINTR : constant := 4;
5260 + EINVAL : constant := 22;
5261 + ENOMEM : constant := 12;
5262 + ETIMEDOUT : constant := 60;
5268 + Max_Interrupt : constant := 63;
5269 + type Signal is new int range 0 .. Max_Interrupt;
5270 + for Signal'Size use int'Size;
5272 + SIGHUP : constant := 1; -- hangup
5273 + SIGINT : constant := 2; -- interrupt (rubout)
5274 + SIGQUIT : constant := 3; -- quit (ASCD FS)
5275 + SIGILL : constant := 4; -- illegal instruction (not reset)
5276 + SIGTRAP : constant := 5; -- trace trap (not reset)
5277 + SIGIOT : constant := 6; -- IOT instruction
5278 + SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
5279 + SIGEMT : constant := 7; -- EMT instruction
5280 + SIGFPE : constant := 8; -- floating point exception
5281 + SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
5282 + SIGBUS : constant := 10; -- bus error
5283 + SIGSEGV : constant := 11; -- segmentation violation
5284 + SIGSYS : constant := 12; -- bad argument to system call
5285 + SIGPIPE : constant := 13; -- write on a pipe with no one to read it
5286 + SIGALRM : constant := 14; -- alarm clock
5287 + SIGTERM : constant := 15; -- software termination signal from kill
5288 + SIGURG : constant := 16; -- urgent condition on IO channel
5289 + SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
5290 + SIGTSTP : constant := 18; -- user stop requested from tty
5291 + SIGCONT : constant := 19; -- stopped process has been continued
5292 + SIGCLD : constant := 20; -- alias for SIGCHLD
5293 + SIGCHLD : constant := 20; -- child status change
5294 + SIGTTIN : constant := 21; -- background tty read attempted
5295 + SIGTTOU : constant := 22; -- background tty write attempted
5296 + SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias)
5297 + SIGXCPU : constant := 24; -- CPU time limit exceeded
5298 + SIGXFSZ : constant := 25; -- filesize limit exceeded
5299 + SIGVTALRM : constant := 26; -- virtual timer expired
5300 + SIGPROF : constant := 27; -- profiling timer expired
5301 + SIGWINCH : constant := 28; -- window size change
5302 + SIGINFO : constant := 29; -- information request (BSD)
5303 + SIGUSR1 : constant := 30; -- user defined signal 1
5304 + SIGUSR2 : constant := 31; -- user defined signal 2
5305 + SIGPWR : constant := 32; -- power fail/restart (not reset when caught)
5307 + SIGADAABORT : constant := SIGABRT;
5308 + -- Change this if you want to use another signal for task abort.
5309 + -- SIGTERM might be a good one.
5311 + type Signal_Set is array (Natural range <>) of Signal;
5313 + -- Interrupts that must be unmasked at all times. NetBSD
5314 + -- pthreads will not allow an application to mask out any
5315 + -- interrupt needed by the threads library.
5316 + Unmasked : constant Signal_Set :=
5317 + (SIGTRAP, SIGBUS, SIGTTIN, SIGTTOU, SIGTSTP);
5319 + -- NetBSD will uses SIGPROF for timing. Do not allow a
5320 + -- handler to attach to this signal.
5321 + Reserved : constant Signal_Set := (0 .. 0 => SIGPROF);
5323 + type sigset_t is private;
5325 + function sigaddset
5326 + (set : access sigset_t;
5327 + sig : Signal) return int;
5328 + pragma Import (C, sigaddset, "__sigaddset14");
5330 + function sigdelset
5331 + (set : access sigset_t;
5332 + sig : Signal) return int;
5333 + pragma Import (C, sigdelset, "__sigdelset14");
5335 + function sigfillset (set : access sigset_t) return int;
5336 + pragma Import (C, sigfillset, "__sigfillset14");
5338 + function sigismember
5339 + (set : access sigset_t;
5340 + sig : Signal) return int;
5341 + pragma Import (C, sigismember, "__sigismember14");
5343 + function sigemptyset (set : access sigset_t) return int;
5344 + pragma Import (C, sigemptyset, "__sigemptyset14");
5346 + -- sigcontext is architecture dependent, so define it private
5347 + type struct_sigcontext is private;
5349 + type old_struct_sigaction is record
5350 + sa_handler : System.Address;
5351 + sa_mask : sigset_t;
5354 + pragma Convention (C, old_struct_sigaction);
5356 + type new_struct_sigaction is record
5357 + sa_handler : System.Address;
5359 + sa_mask : sigset_t;
5361 + pragma Convention (C, new_struct_sigaction);
5363 + subtype struct_sigaction is new_struct_sigaction;
5364 + type struct_sigaction_ptr is access all struct_sigaction;
5366 + SIG_BLOCK : constant := 1;
5367 + SIG_UNBLOCK : constant := 2;
5368 + SIG_SETMASK : constant := 3;
5370 + SIG_DFL : constant := 0;
5371 + SIG_IGN : constant := 1;
5372 + SIG_ERR : constant := -1;
5373 + SIG_HOLD : constant := 3;
5375 + SA_SIGINFO : constant := 16#0040#;
5376 + SA_ONSTACK : constant := 16#0001#;
5378 + function sigaction
5380 + act : struct_sigaction_ptr;
5381 + oact : struct_sigaction_ptr) return int;
5382 + pragma Import (C, sigaction, "__sigaction14");
5388 + Time_Slice_Supported : constant Boolean := True;
5389 + -- Indicates whether time slicing is supported (i.e SCHED_RR is supported)
5391 + type timespec is private;
5393 + function nanosleep (rqtp, rmtp : access timespec) return int;
5394 + pragma Import (C, nanosleep, "nanosleep");
5396 + type clockid_t is new int;
5398 + function clock_gettime
5399 + (clock_id : clockid_t;
5400 + tp : access timespec)
5402 + pragma Import (C, clock_gettime, "clock_gettime");
5404 + function To_Duration (TS : timespec) return Duration;
5405 + pragma Inline (To_Duration);
5407 + function To_Timespec (D : Duration) return timespec;
5408 + pragma Inline (To_Timespec);
5410 + type struct_timezone is record
5411 + tz_minuteswest : int;
5414 + pragma Convention (C, struct_timezone);
5416 + -------------------------
5417 + -- Priority Scheduling --
5418 + -------------------------
5420 + SCHED_FIFO : constant := 1;
5421 + SCHED_OTHER : constant := 2;
5422 + SCHED_RR : constant := 3;
5424 + function To_Target_Priority
5425 + (Prio : System.Any_Priority) return Interfaces.C.int;
5426 + -- Maps System.Any_Priority to a POSIX priority
5432 + type pid_t is private;
5434 + function kill (pid : pid_t; sig : Signal) return int;
5435 + pragma Import (C, kill, "kill");
5437 + function getpid return pid_t;
5438 + pragma Import (C, getpid, "getpid");
5444 + function lwp_self return System.Address;
5445 + -- lwp_self does not exist on this thread library, revert to pthread_self
5446 + -- which is the closest approximation (with getpid). This function is
5447 + -- needed to share 7staprop.adb across POSIX-like targets.
5448 + pragma Import (C, lwp_self, "pthread_self");
5454 + type Thread_Body is access
5455 + function (arg : System.Address) return System.Address;
5456 + pragma Convention (C, Thread_Body);
5458 + function Thread_Body_Access is new
5459 + Ada.Unchecked_Conversion (System.Address, Thread_Body);
5461 + type pthread_t is private;
5462 + subtype Thread_Id is pthread_t;
5464 + type pthread_mutex_t is limited private;
5465 + type pthread_cond_t is limited private;
5466 + type pthread_attr_t is limited private;
5467 + type pthread_mutexattr_t is limited private;
5468 + type pthread_condattr_t is limited private;
5469 + type pthread_key_t is private;
5471 + PTHREAD_CREATE_DETACHED : constant := 1;
5472 + PTHREAD_CREATE_JOINABLE : constant := 0;
5474 + PTHREAD_SCOPE_PROCESS : constant := 0;
5475 + PTHREAD_SCOPE_SYSTEM : constant := 2;
5477 + -- Read/Write lock not supported on OpenBSD. To add support both types
5478 + -- pthread_rwlock_t and pthread_rwlockattr_t must properly be defined
5479 + -- with the associated routines pthread_rwlock_[init/destroy] and
5480 + -- pthread_rwlock_[rdlock/wrlock/unlock].
5482 + subtype pthread_rwlock_t is pthread_mutex_t;
5483 + subtype pthread_rwlockattr_t is pthread_mutexattr_t;
5489 + type stack_t is record
5490 + ss_sp : System.Address;
5494 + pragma Convention (C, stack_t);
5496 + function sigaltstack
5497 + (ss : not null access stack_t;
5498 + oss : access stack_t) return int;
5499 + pragma Import (C, sigaltstack, "sigaltstack");
5501 + Alternate_Stack : aliased System.Address;
5502 + -- This is a dummy definition, never used (Alternate_Stack_Size is null)
5504 + Alternate_Stack_Size : constant := 0;
5505 + -- No alternate signal stack is used on this platform
5507 + Stack_Base_Available : constant Boolean := False;
5508 + -- Indicates whether the stack base is available on this target. This
5509 + -- allows us to share s-osinte.adb between all the FSU run time. Note that
5510 + -- this value can only be true if pthread_t has a complete definition that
5511 + -- corresponds exactly to the C header files.
5513 + function Get_Stack_Base (thread : pthread_t) return Address;
5514 + pragma Inline (Get_Stack_Base);
5515 + -- returns the stack base of the specified thread. Only call this function
5516 + -- when Stack_Base_Available is True.
5518 + function Get_Page_Size return size_t;
5519 + function Get_Page_Size return Address;
5520 + pragma Import (C, Get_Page_Size, "getpagesize");
5521 + -- Returns the size of a page
5523 + PROT_NONE : constant := 0;
5524 + PROT_READ : constant := 1;
5525 + PROT_WRITE : constant := 2;
5526 + PROT_EXEC : constant := 4;
5527 + PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
5528 + PROT_ON : constant := PROT_NONE;
5529 + PROT_OFF : constant := PROT_ALL;
5531 + function mprotect (addr : Address; len : size_t; prot : int) return int;
5532 + pragma Import (C, mprotect);
5534 + ---------------------------------------
5535 + -- Nonstandard Thread Initialization --
5536 + ---------------------------------------
5538 + -- FSU_THREADS requires pthread_init, which is nonstandard and this should
5539 + -- be invoked during the elaboration of s-taprop.adb.
5541 + -- NetBSD does not require this so we provide an empty Ada body
5543 + procedure pthread_init;
5545 + -------------------------
5546 + -- POSIX.1c Section 3 --
5547 + -------------------------
5550 + (set : access sigset_t;
5551 + sig : access Signal) return int;
5552 + pragma Import (C, sigwait, "sigwait");
5554 + function pthread_kill
5555 + (thread : pthread_t;
5556 + sig : Signal) return int;
5557 + pragma Import (C, pthread_kill, "pthread_kill");
5559 + function pthread_sigmask
5561 + set : access sigset_t;
5562 + oset : access sigset_t) return int;
5563 + pragma Import (C, pthread_sigmask, "pthread_sigmask");
5565 + --------------------------
5566 + -- POSIX.1c Section 11 --
5567 + --------------------------
5569 + function pthread_mutexattr_init
5570 + (attr : access pthread_mutexattr_t) return int;
5571 + pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
5573 + function pthread_mutexattr_destroy
5574 + (attr : access pthread_mutexattr_t) return int;
5575 + pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
5577 + function pthread_mutex_init
5578 + (mutex : access pthread_mutex_t;
5579 + attr : access pthread_mutexattr_t) return int;
5580 + pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
5582 + function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
5583 + pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
5585 + function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
5586 + pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
5588 + function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
5589 + pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
5591 + function pthread_condattr_init
5592 + (attr : access pthread_condattr_t) return int;
5593 + pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
5595 + function pthread_condattr_destroy
5596 + (attr : access pthread_condattr_t) return int;
5597 + pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
5599 + function pthread_cond_init
5600 + (cond : access pthread_cond_t;
5601 + attr : access pthread_condattr_t) return int;
5602 + pragma Import (C, pthread_cond_init, "pthread_cond_init");
5604 + function pthread_cond_destroy (cond : access pthread_cond_t) return int;
5605 + pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
5607 + function pthread_cond_signal (cond : access pthread_cond_t) return int;
5608 + pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
5610 + function pthread_cond_wait
5611 + (cond : access pthread_cond_t;
5612 + mutex : access pthread_mutex_t) return int;
5613 + pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
5615 + function pthread_cond_timedwait
5616 + (cond : access pthread_cond_t;
5617 + mutex : access pthread_mutex_t;
5618 + abstime : access timespec) return int;
5619 + pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
5621 + Relative_Timed_Wait : constant Boolean := False;
5622 + -- pthread_cond_timedwait requires an absolute delay time
5624 + --------------------------
5625 + -- POSIX.1c Section 13 --
5626 + --------------------------
5628 + PTHREAD_PRIO_NONE : constant := 0;
5629 + PTHREAD_PRIO_PROTECT : constant := 2;
5630 + PTHREAD_PRIO_INHERIT : constant := 1;
5632 + function pthread_mutexattr_setprotocol
5633 + (attr : access pthread_mutexattr_t;
5634 + protocol : int) return int;
5636 + function pthread_mutexattr_setprioceiling
5637 + (attr : access pthread_mutexattr_t;
5638 + prioceiling : int) return int;
5640 + type struct_sched_param is record
5641 + sched_priority : int;
5643 + pragma Convention (C, struct_sched_param);
5645 + function pthread_getschedparam
5646 + (thread : pthread_t;
5647 + policy : access int;
5648 + param : access struct_sched_param) return int;
5649 + pragma Import (C, pthread_getschedparam, "pthread_getschedparam");
5651 + function pthread_setschedparam
5652 + (thread : pthread_t;
5654 + param : access struct_sched_param) return int;
5655 + pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
5657 + function pthread_attr_setscope
5658 + (attr : access pthread_attr_t;
5659 + contentionscope : int) return int;
5660 + pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
5662 + function pthread_attr_getscope
5663 + (attr : access pthread_attr_t;
5664 + contentionscope : access int) return int;
5665 + pragma Import (C, pthread_attr_getscope, "pthread_attr_getscope");
5667 + function pthread_attr_setinheritsched
5668 + (attr : access pthread_attr_t;
5669 + inheritsched : int) return int;
5671 + (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
5673 + function pthread_attr_getinheritsched
5674 + (attr : access pthread_attr_t;
5675 + inheritsched : access int) return int;
5677 + (C, pthread_attr_getinheritsched, "pthread_attr_getinheritsched");
5679 + function pthread_attr_setschedpolicy
5680 + (attr : access pthread_attr_t;
5681 + policy : int) return int;
5682 + pragma Import (C, pthread_attr_setschedpolicy,
5683 + "pthread_attr_setschedpolicy");
5685 + function pthread_attr_getschedpolicy
5686 + (attr : access pthread_attr_t;
5687 + policy : access int) return int;
5688 + pragma Import (C, pthread_attr_getschedpolicy,
5689 + "pthread_attr_getschedpolicy");
5691 + function pthread_attr_setschedparam
5692 + (attr : access pthread_attr_t;
5693 + sched_param : int) return int;
5694 + pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
5696 + function pthread_attr_getschedparam
5697 + (attr : access pthread_attr_t;
5698 + sched_param : access int) return int;
5699 + pragma Import (C, pthread_attr_getschedparam, "pthread_attr_getschedparam");
5701 + function sched_yield return int;
5702 + pragma Import (C, sched_yield, "sched_yield");
5704 + --------------------------
5705 + -- P1003.1c Section 16 --
5706 + --------------------------
5708 + function pthread_attr_init (attributes : access pthread_attr_t) return int;
5709 + pragma Import (C, pthread_attr_init, "pthread_attr_init");
5711 + function pthread_attr_destroy
5712 + (attributes : access pthread_attr_t) return int;
5713 + pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
5715 + function pthread_attr_setdetachstate
5716 + (attr : access pthread_attr_t;
5717 + detachstate : int) return int;
5719 + (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
5721 + function pthread_attr_getdetachstate
5722 + (attr : access pthread_attr_t;
5723 + detachstate : access int) return int;
5725 + (C, pthread_attr_getdetachstate, "pthread_attr_getdetachstate");
5727 + function pthread_attr_getstacksize
5728 + (attr : access pthread_attr_t;
5729 + stacksize : access size_t) return int;
5731 + (C, pthread_attr_getstacksize, "pthread_attr_getstacksize");
5733 + function pthread_attr_setstacksize
5734 + (attr : access pthread_attr_t;
5735 + stacksize : size_t) return int;
5737 + (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
5739 + function pthread_create
5740 + (thread : access pthread_t;
5741 + attributes : access pthread_attr_t;
5742 + start_routine : Thread_Body;
5743 + arg : System.Address) return int;
5744 + pragma Import (C, pthread_create, "pthread_create");
5746 + function pthread_detach (thread : pthread_t) return int;
5747 + pragma Import (C, pthread_detach, "pthread_detach");
5749 + procedure pthread_exit (status : System.Address);
5750 + pragma Import (C, pthread_exit, "pthread_exit");
5752 + function pthread_self return pthread_t;
5753 + pragma Import (C, pthread_self, "pthread_self");
5755 + --------------------------
5756 + -- POSIX.1c Section 17 --
5757 + --------------------------
5759 + function pthread_setspecific
5760 + (key : pthread_key_t;
5761 + value : System.Address) return int;
5762 + pragma Import (C, pthread_setspecific, "pthread_setspecific");
5764 + function pthread_getspecific (key : pthread_key_t) return System.Address;
5765 + pragma Import (C, pthread_getspecific, "pthread_getspecific");
5767 + type destructor_pointer is access procedure (arg : System.Address);
5768 + pragma Convention (C, destructor_pointer);
5770 + function pthread_key_create
5771 + (key : access pthread_key_t;
5772 + destructor : destructor_pointer) return int;
5773 + pragma Import (C, pthread_key_create, "pthread_key_create");
5775 + ------------------------------------
5776 + -- Non-portable Pthread Functions --
5777 + ------------------------------------
5779 + function pthread_set_name_np
5780 + (thread : pthread_t;
5781 + name : System.Address) return int;
5782 + pragma Import (C, pthread_set_name_np, "pthread_set_name_np");
5786 + type sigset_t is array (1 .. 4) of unsigned;
5788 + -- In NetBSD the component sa_handler turns out to
5789 + -- be one a union type, and the selector is a macro:
5790 + -- #define sa_handler __sigaction_u._handler
5791 + -- #define sa_sigaction __sigaction_u._sigaction
5793 + -- Should we add a signal_context type here ???
5794 + -- How could it be done independent of the CPU architecture ???
5795 + -- sigcontext type is opaque, so it is architecturally neutral.
5796 + -- It is always passed as an access type, so define it as an empty record
5797 + -- since the contents are not used anywhere.
5799 + type struct_sigcontext is null record;
5800 + pragma Convention (C, struct_sigcontext);
5802 + type pid_t is new int;
5804 + type time_t is new int;
5806 + type timespec is record
5810 + pragma Convention (C, timespec);
5812 + type pthread_t is new System.Address;
5813 + type pthread_attr_t is record
5814 + Pta_Magic : unsigned;
5816 + Pta_Private : System.Address;
5818 + pragma Convention (C, pthread_attr_t);
5820 + -- PORT NOTE: The size of pthread_spin_t is defined in
5821 + -- /src/sys/arch/*/include/types.h
5822 + type pthread_spin_t is new unsigned_char;
5824 + type pthread_queue_t is record
5825 + Pthqh_First : pthread_t;
5826 + Pthqh_Last : System.Address;
5828 + pragma Convention (C, pthread_queue_t);
5830 + type pthread_mutex_t is record
5831 + Ptm_Majic : unsigned;
5832 + Ptm_Lock : pthread_spin_t;
5833 + Ptm_Interlock : pthread_spin_t;
5834 + Ptm_Owner : pthread_t;
5835 + Ptm_Block : pthread_queue_t;
5836 + Ptm_Private : System.Address;
5838 + pragma Convention (C, pthread_mutex_t);
5840 + type pthread_mutexattr_t is record
5841 + Ptma_Majic : unsigned;
5842 + Ptma_Private : System.Address;
5844 + pragma Convention (C, pthread_mutexattr_t);
5846 + type pthread_cond_t is record
5847 + Ptc_Magic : unsigned;
5848 + Ptc_Lock : pthread_spin_t;
5849 + Ptc_Waiters : pthread_queue_t;
5850 + Ptc_Mutex : pthread_mutex_t;
5851 + Ptc_Private : System.Address;
5853 + pragma Convention (C, pthread_cond_t);
5855 + type pthread_condattr_t is record
5856 + Ptca_Magic : unsigned;
5857 + Ptca_Private : System.Address;
5859 + pragma Convention (C, pthread_condattr_t);
5861 + type pthread_key_t is new int;
5863 +end System.OS_Interface;
5865 +++ gcc/ada/s-osinte-netbsd6.ads
5867 +------------------------------------------------------------------------------
5869 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
5871 +-- S Y S T E M . O S _ I N T E R F A C E --
5875 +-- Copyright (C) 1991-1994, Florida State University --
5876 +-- Copyright (C) 1995-2011, Free Software Foundation, Inc. --
5878 +-- GNAT is free software; you can redistribute it and/or modify it under --
5879 +-- terms of the GNU General Public License as published by the Free Soft- --
5880 +-- ware Foundation; either version 3, or (at your option) any later ver- --
5881 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
5882 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
5883 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
5885 +-- As a special exception under Section 7 of GPL version 3, you are granted --
5886 +-- additional permissions described in the GCC Runtime Library Exception, --
5887 +-- version 3.1, as published by the Free Software Foundation. --
5889 +-- You should have received a copy of the GNU General Public License and --
5890 +-- a copy of the GCC Runtime Library Exception along with this program; --
5891 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
5892 +-- <http://www.gnu.org/licenses/>. --
5894 +-- GNARL was developed by the GNARL team at Florida State University. It is --
5895 +-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
5896 +-- State University (http://www.gnat.com). --
5898 +------------------------------------------------------------------------------
5900 +-- This is the NetBSD 6+ PTHREADS version of this package.
5901 +-- It is based off of the FreeBSD PTHREADS as of 4.2.3.
5903 +-- This package encapsulates all direct interfaces to OS services
5904 +-- that are needed by the tasking run-time (libgnarl).
5906 +-- PLEASE DO NOT add any with-clauses to this package or remove the pragma
5907 +-- Preelaborate. This package is designed to be a bottom-level (leaf) package.
5909 +with Ada.Unchecked_Conversion;
5913 +package System.OS_Interface is
5914 + pragma Preelaborate;
5916 + pragma Linker_Options ("-pthread");
5918 + subtype int is Interfaces.C.int;
5919 + subtype short is Interfaces.C.short;
5920 + subtype long is Interfaces.C.long;
5921 + subtype unsigned is Interfaces.C.unsigned;
5922 + subtype unsigned_short is Interfaces.C.unsigned_short;
5923 + subtype unsigned_long is Interfaces.C.unsigned_long;
5924 + subtype unsigned_char is Interfaces.C.unsigned_char;
5925 + subtype plain_char is Interfaces.C.plain_char;
5926 + subtype size_t is Interfaces.C.size_t;
5927 + subtype int64_t is Interfaces.Integer_64;
5933 + function Errno return int;
5934 + pragma Inline (Errno);
5936 + EAGAIN : constant := 35;
5937 + EINTR : constant := 4;
5938 + EINVAL : constant := 22;
5939 + ENOMEM : constant := 12;
5940 + ETIMEDOUT : constant := 60;
5946 + Max_Interrupt : constant := 63;
5947 + type Signal is new int range 0 .. Max_Interrupt;
5948 + for Signal'Size use int'Size;
5950 + SIGHUP : constant := 1; -- hangup
5951 + SIGINT : constant := 2; -- interrupt (rubout)
5952 + SIGQUIT : constant := 3; -- quit (ASCD FS)
5953 + SIGILL : constant := 4; -- illegal instruction (not reset)
5954 + SIGTRAP : constant := 5; -- trace trap (not reset)
5955 + SIGIOT : constant := 6; -- IOT instruction
5956 + SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
5957 + SIGEMT : constant := 7; -- EMT instruction
5958 + SIGFPE : constant := 8; -- floating point exception
5959 + SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
5960 + SIGBUS : constant := 10; -- bus error
5961 + SIGSEGV : constant := 11; -- segmentation violation
5962 + SIGSYS : constant := 12; -- bad argument to system call
5963 + SIGPIPE : constant := 13; -- write on a pipe with no one to read it
5964 + SIGALRM : constant := 14; -- alarm clock
5965 + SIGTERM : constant := 15; -- software termination signal from kill
5966 + SIGURG : constant := 16; -- urgent condition on IO channel
5967 + SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
5968 + SIGTSTP : constant := 18; -- user stop requested from tty
5969 + SIGCONT : constant := 19; -- stopped process has been continued
5970 + SIGCLD : constant := 20; -- alias for SIGCHLD
5971 + SIGCHLD : constant := 20; -- child status change
5972 + SIGTTIN : constant := 21; -- background tty read attempted
5973 + SIGTTOU : constant := 22; -- background tty write attempted
5974 + SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias)
5975 + SIGXCPU : constant := 24; -- CPU time limit exceeded
5976 + SIGXFSZ : constant := 25; -- filesize limit exceeded
5977 + SIGVTALRM : constant := 26; -- virtual timer expired
5978 + SIGPROF : constant := 27; -- profiling timer expired
5979 + SIGWINCH : constant := 28; -- window size change
5980 + SIGINFO : constant := 29; -- information request (BSD)
5981 + SIGUSR1 : constant := 30; -- user defined signal 1
5982 + SIGUSR2 : constant := 31; -- user defined signal 2
5983 + SIGPWR : constant := 32; -- power fail/restart (not reset when caught)
5985 + SIGADAABORT : constant := SIGABRT;
5986 + -- Change this if you want to use another signal for task abort.
5987 + -- SIGTERM might be a good one.
5989 + type Signal_Set is array (Natural range <>) of Signal;
5991 + -- Interrupts that must be unmasked at all times. NetBSD
5992 + -- pthreads will not allow an application to mask out any
5993 + -- interrupt needed by the threads library.
5994 + Unmasked : constant Signal_Set :=
5995 + (SIGTRAP, SIGBUS, SIGTTIN, SIGTTOU, SIGTSTP);
5997 + -- NetBSD will uses SIGPROF for timing. Do not allow a
5998 + -- handler to attach to this signal.
5999 + Reserved : constant Signal_Set := (0 .. 0 => SIGPROF);
6001 + type sigset_t is private;
6003 + function sigaddset
6004 + (set : access sigset_t;
6005 + sig : Signal) return int;
6006 + pragma Import (C, sigaddset, "__sigaddset14");
6008 + function sigdelset
6009 + (set : access sigset_t;
6010 + sig : Signal) return int;
6011 + pragma Import (C, sigdelset, "__sigdelset14");
6013 + function sigfillset (set : access sigset_t) return int;
6014 + pragma Import (C, sigfillset, "__sigfillset14");
6016 + function sigismember
6017 + (set : access sigset_t;
6018 + sig : Signal) return int;
6019 + pragma Import (C, sigismember, "__sigismember14");
6021 + function sigemptyset (set : access sigset_t) return int;
6022 + pragma Import (C, sigemptyset, "__sigemptyset14");
6024 + -- sigcontext is architecture dependent, so define it private
6025 + type struct_sigcontext is private;
6027 + type old_struct_sigaction is record
6028 + sa_handler : System.Address;
6029 + sa_mask : sigset_t;
6032 + pragma Convention (C, old_struct_sigaction);
6034 + type new_struct_sigaction is record
6035 + sa_handler : System.Address;
6037 + sa_mask : sigset_t;
6039 + pragma Convention (C, new_struct_sigaction);
6041 + subtype struct_sigaction is new_struct_sigaction;
6042 + type struct_sigaction_ptr is access all struct_sigaction;
6044 + SIG_BLOCK : constant := 1;
6045 + SIG_UNBLOCK : constant := 2;
6046 + SIG_SETMASK : constant := 3;
6048 + SIG_DFL : constant := 0;
6049 + SIG_IGN : constant := 1;
6050 + SIG_ERR : constant := -1;
6051 + SIG_HOLD : constant := 3;
6053 + SA_SIGINFO : constant := 16#0040#;
6054 + SA_ONSTACK : constant := 16#0001#;
6056 + function sigaction
6058 + act : struct_sigaction_ptr;
6059 + oact : struct_sigaction_ptr) return int;
6060 + pragma Import (C, sigaction, "__sigaction14");
6066 + Time_Slice_Supported : constant Boolean := True;
6067 + -- Indicates whether time slicing is supported (i.e SCHED_RR is supported)
6069 + type timespec is private;
6071 + function nanosleep (rqtp, rmtp : access timespec) return int;
6072 + pragma Import (C, nanosleep, "__nanosleep50");
6074 + type clockid_t is new int;
6076 + function clock_gettime
6077 + (clock_id : clockid_t;
6078 + tp : access timespec)
6080 + pragma Import (C, clock_gettime, "__clock_gettime50");
6082 + function To_Duration (TS : timespec) return Duration;
6083 + pragma Inline (To_Duration);
6085 + function To_Timespec (D : Duration) return timespec;
6086 + pragma Inline (To_Timespec);
6088 + type struct_timezone is record
6089 + tz_minuteswest : int;
6092 + pragma Convention (C, struct_timezone);
6094 + -------------------------
6095 + -- Priority Scheduling --
6096 + -------------------------
6098 + SCHED_FIFO : constant := 1;
6099 + SCHED_OTHER : constant := 2;
6100 + SCHED_RR : constant := 3;
6102 + function To_Target_Priority
6103 + (Prio : System.Any_Priority) return Interfaces.C.int;
6104 + -- Maps System.Any_Priority to a POSIX priority
6110 + type pid_t is private;
6112 + function kill (pid : pid_t; sig : Signal) return int;
6113 + pragma Import (C, kill, "kill");
6115 + function getpid return pid_t;
6116 + pragma Import (C, getpid, "getpid");
6122 + function lwp_self return System.Address;
6123 + -- lwp_self does not exist on this thread library, revert to pthread_self
6124 + -- which is the closest approximation (with getpid). This function is
6125 + -- needed to share 7staprop.adb across POSIX-like targets.
6126 + pragma Import (C, lwp_self, "pthread_self");
6132 + type Thread_Body is access
6133 + function (arg : System.Address) return System.Address;
6134 + pragma Convention (C, Thread_Body);
6136 + function Thread_Body_Access is new
6137 + Ada.Unchecked_Conversion (System.Address, Thread_Body);
6139 + type pthread_t is private;
6140 + subtype Thread_Id is pthread_t;
6142 + type pthread_mutex_t is limited private;
6143 + type pthread_cond_t is limited private;
6144 + type pthread_attr_t is limited private;
6145 + type pthread_mutexattr_t is limited private;
6146 + type pthread_condattr_t is limited private;
6147 + type pthread_key_t is private;
6149 + PTHREAD_CREATE_DETACHED : constant := 1;
6150 + PTHREAD_CREATE_JOINABLE : constant := 0;
6152 + PTHREAD_SCOPE_PROCESS : constant := 0;
6153 + PTHREAD_SCOPE_SYSTEM : constant := 2;
6155 + -- Read/Write lock not supported on freebsd. To add support both types
6156 + -- pthread_rwlock_t and pthread_rwlockattr_t must properly be defined
6157 + -- with the associated routines pthread_rwlock_[init/destroy] and
6158 + -- pthread_rwlock_[rdlock/wrlock/unlock].
6160 + subtype pthread_rwlock_t is pthread_mutex_t;
6161 + subtype pthread_rwlockattr_t is pthread_mutexattr_t;
6167 + type stack_t is record
6168 + ss_sp : System.Address;
6172 + pragma Convention (C, stack_t);
6174 + function sigaltstack
6175 + (ss : not null access stack_t;
6176 + oss : access stack_t) return int;
6177 + pragma Import (C, sigaltstack, "sigaltstack");
6179 + Alternate_Stack : aliased System.Address;
6180 + -- This is a dummy definition, never used (Alternate_Stack_Size is null)
6182 + Alternate_Stack_Size : constant := 0;
6183 + -- No alternate signal stack is used on this platform
6185 + Stack_Base_Available : constant Boolean := False;
6186 + -- Indicates whether the stack base is available on this target. This
6187 + -- allows us to share s-osinte.adb between all the FSU run time. Note that
6188 + -- this value can only be true if pthread_t has a complete definition that
6189 + -- corresponds exactly to the C header files.
6191 + function Get_Stack_Base (thread : pthread_t) return Address;
6192 + pragma Inline (Get_Stack_Base);
6193 + -- returns the stack base of the specified thread. Only call this function
6194 + -- when Stack_Base_Available is True.
6196 + function Get_Page_Size return size_t;
6197 + function Get_Page_Size return Address;
6198 + pragma Import (C, Get_Page_Size, "getpagesize");
6199 + -- Returns the size of a page
6201 + PROT_NONE : constant := 0;
6202 + PROT_READ : constant := 1;
6203 + PROT_WRITE : constant := 2;
6204 + PROT_EXEC : constant := 4;
6205 + PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
6206 + PROT_ON : constant := PROT_NONE;
6207 + PROT_OFF : constant := PROT_ALL;
6209 + function mprotect (addr : Address; len : size_t; prot : int) return int;
6210 + pragma Import (C, mprotect);
6212 + ---------------------------------------
6213 + -- Nonstandard Thread Initialization --
6214 + ---------------------------------------
6216 + -- FSU_THREADS requires pthread_init, which is nonstandard and this should
6217 + -- be invoked during the elaboration of s-taprop.adb.
6219 + -- NetBSD does not require this so we provide an empty Ada body
6221 + procedure pthread_init;
6223 + -------------------------
6224 + -- POSIX.1c Section 3 --
6225 + -------------------------
6228 + (set : access sigset_t;
6229 + sig : access Signal) return int;
6230 + pragma Import (C, sigwait, "sigwait");
6232 + function pthread_kill
6233 + (thread : pthread_t;
6234 + sig : Signal) return int;
6235 + pragma Import (C, pthread_kill, "pthread_kill");
6237 + function pthread_sigmask
6239 + set : access sigset_t;
6240 + oset : access sigset_t) return int;
6241 + pragma Import (C, pthread_sigmask, "pthread_sigmask");
6243 + --------------------------
6244 + -- POSIX.1c Section 11 --
6245 + --------------------------
6247 + function pthread_mutexattr_init
6248 + (attr : access pthread_mutexattr_t) return int;
6249 + pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
6251 + function pthread_mutexattr_destroy
6252 + (attr : access pthread_mutexattr_t) return int;
6253 + pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
6255 + function pthread_mutex_init
6256 + (mutex : access pthread_mutex_t;
6257 + attr : access pthread_mutexattr_t) return int;
6258 + pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
6260 + function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
6261 + pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
6263 + function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
6264 + pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
6266 + function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
6267 + pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
6269 + function pthread_condattr_init
6270 + (attr : access pthread_condattr_t) return int;
6271 + pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
6273 + function pthread_condattr_destroy
6274 + (attr : access pthread_condattr_t) return int;
6275 + pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
6277 + function pthread_cond_init
6278 + (cond : access pthread_cond_t;
6279 + attr : access pthread_condattr_t) return int;
6280 + pragma Import (C, pthread_cond_init, "pthread_cond_init");
6282 + function pthread_cond_destroy (cond : access pthread_cond_t) return int;
6283 + pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
6285 + function pthread_cond_signal (cond : access pthread_cond_t) return int;
6286 + pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
6288 + function pthread_cond_wait
6289 + (cond : access pthread_cond_t;
6290 + mutex : access pthread_mutex_t) return int;
6291 + pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
6293 + function pthread_cond_timedwait
6294 + (cond : access pthread_cond_t;
6295 + mutex : access pthread_mutex_t;
6296 + abstime : access timespec) return int;
6297 + pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
6299 + Relative_Timed_Wait : constant Boolean := False;
6300 + -- pthread_cond_timedwait requires an absolute delay time
6302 + --------------------------
6303 + -- POSIX.1c Section 13 --
6304 + --------------------------
6306 + PTHREAD_PRIO_NONE : constant := 0;
6307 + PTHREAD_PRIO_PROTECT : constant := 2;
6308 + PTHREAD_PRIO_INHERIT : constant := 1;
6310 + function pthread_mutexattr_setprotocol
6311 + (attr : access pthread_mutexattr_t;
6312 + protocol : int) return int;
6314 + function pthread_mutexattr_setprioceiling
6315 + (attr : access pthread_mutexattr_t;
6316 + prioceiling : int) return int;
6318 + type struct_sched_param is record
6319 + sched_priority : int;
6321 + pragma Convention (C, struct_sched_param);
6323 + function pthread_getschedparam
6324 + (thread : pthread_t;
6325 + policy : access int;
6326 + param : access struct_sched_param) return int;
6327 + pragma Import (C, pthread_getschedparam, "pthread_getschedparam");
6329 + function pthread_setschedparam
6330 + (thread : pthread_t;
6332 + param : access struct_sched_param) return int;
6333 + pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
6335 + function pthread_attr_setscope
6336 + (attr : access pthread_attr_t;
6337 + contentionscope : int) return int;
6338 + pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
6340 + function pthread_attr_getscope
6341 + (attr : access pthread_attr_t;
6342 + contentionscope : access int) return int;
6343 + pragma Import (C, pthread_attr_getscope, "pthread_attr_getscope");
6345 + function pthread_attr_setinheritsched
6346 + (attr : access pthread_attr_t;
6347 + inheritsched : int) return int;
6349 + (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
6351 + function pthread_attr_getinheritsched
6352 + (attr : access pthread_attr_t;
6353 + inheritsched : access int) return int;
6355 + (C, pthread_attr_getinheritsched, "pthread_attr_getinheritsched");
6357 + function pthread_attr_setschedpolicy
6358 + (attr : access pthread_attr_t;
6359 + policy : int) return int;
6360 + pragma Import (C, pthread_attr_setschedpolicy,
6361 + "pthread_attr_setschedpolicy");
6363 + function pthread_attr_getschedpolicy
6364 + (attr : access pthread_attr_t;
6365 + policy : access int) return int;
6366 + pragma Import (C, pthread_attr_getschedpolicy,
6367 + "pthread_attr_getschedpolicy");
6369 + function pthread_attr_setschedparam
6370 + (attr : access pthread_attr_t;
6371 + sched_param : int) return int;
6372 + pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
6374 + function pthread_attr_getschedparam
6375 + (attr : access pthread_attr_t;
6376 + sched_param : access int) return int;
6377 + pragma Import (C, pthread_attr_getschedparam, "pthread_attr_getschedparam");
6379 + function sched_yield return int;
6380 + pragma Import (C, sched_yield, "sched_yield");
6382 + --------------------------
6383 + -- P1003.1c Section 16 --
6384 + --------------------------
6386 + function pthread_attr_init (attributes : access pthread_attr_t) return int;
6387 + pragma Import (C, pthread_attr_init, "pthread_attr_init");
6389 + function pthread_attr_destroy
6390 + (attributes : access pthread_attr_t) return int;
6391 + pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
6393 + function pthread_attr_setdetachstate
6394 + (attr : access pthread_attr_t;
6395 + detachstate : int) return int;
6397 + (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
6399 + function pthread_attr_getdetachstate
6400 + (attr : access pthread_attr_t;
6401 + detachstate : access int) return int;
6403 + (C, pthread_attr_getdetachstate, "pthread_attr_getdetachstate");
6405 + function pthread_attr_getstacksize
6406 + (attr : access pthread_attr_t;
6407 + stacksize : access size_t) return int;
6409 + (C, pthread_attr_getstacksize, "pthread_attr_getstacksize");
6411 + function pthread_attr_setstacksize
6412 + (attr : access pthread_attr_t;
6413 + stacksize : size_t) return int;
6415 + (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
6417 + function pthread_create
6418 + (thread : access pthread_t;
6419 + attributes : access pthread_attr_t;
6420 + start_routine : Thread_Body;
6421 + arg : System.Address) return int;
6422 + pragma Import (C, pthread_create, "pthread_create");
6424 + function pthread_detach (thread : pthread_t) return int;
6425 + pragma Import (C, pthread_detach, "pthread_detach");
6427 + procedure pthread_exit (status : System.Address);
6428 + pragma Import (C, pthread_exit, "pthread_exit");
6430 + function pthread_self return pthread_t;
6431 + pragma Import (C, pthread_self, "pthread_self");
6433 + --------------------------
6434 + -- POSIX.1c Section 17 --
6435 + --------------------------
6437 + function pthread_setspecific
6438 + (key : pthread_key_t;
6439 + value : System.Address) return int;
6440 + pragma Import (C, pthread_setspecific, "pthread_setspecific");
6442 + function pthread_getspecific (key : pthread_key_t) return System.Address;
6443 + pragma Import (C, pthread_getspecific, "pthread_getspecific");
6445 + type destructor_pointer is access procedure (arg : System.Address);
6446 + pragma Convention (C, destructor_pointer);
6448 + function pthread_key_create
6449 + (key : access pthread_key_t;
6450 + destructor : destructor_pointer) return int;
6451 + pragma Import (C, pthread_key_create, "pthread_key_create");
6453 + ------------------------------------
6454 + -- Non-portable Pthread Functions --
6455 + ------------------------------------
6457 + function pthread_set_name_np
6458 + (thread : pthread_t;
6459 + name : System.Address) return int;
6460 + pragma Import (C, pthread_set_name_np, "pthread_set_name_np");
6464 + type sigset_t is array (1 .. 4) of unsigned;
6466 + -- In NetBSD the component sa_handler turns out to
6467 + -- be one a union type, and the selector is a macro:
6468 + -- #define sa_handler __sigaction_u._handler
6469 + -- #define sa_sigaction __sigaction_u._sigaction
6471 + -- Should we add a signal_context type here ???
6472 + -- How could it be done independent of the CPU architecture ???
6473 + -- sigcontext type is opaque, so it is architecturally neutral.
6474 + -- It is always passed as an access type, so define it as an empty record
6475 + -- since the contents are not used anywhere.
6477 + type struct_sigcontext is null record;
6478 + pragma Convention (C, struct_sigcontext);
6480 + type pid_t is new int;
6482 + type time_t is new int64_t;
6484 + type timespec is record
6488 + pragma Convention (C, timespec);
6490 + type pthread_t is new System.Address;
6491 + type pthread_attr_t is record
6492 + Pta_Magic : unsigned;
6494 + Pta_Private : System.Address;
6496 + pragma Convention (C, pthread_attr_t);
6498 + -- PORT NOTE: The size of pthread_spin_t is defined in
6499 + -- /src/sys/arch/*/include/types.h
6500 + type pthread_spin_t is new unsigned_char;
6502 + type pthread_queue_t is record
6503 + Pthqh_First : pthread_t;
6504 + Pthqh_Last : System.Address;
6506 + pragma Convention (C, pthread_queue_t);
6508 + type pthread_mutex_t is record
6509 + Ptm_Majic : unsigned;
6510 + Ptm_Lock : pthread_spin_t;
6511 + Ptm_Interlock : pthread_spin_t;
6512 + Ptm_Owner : pthread_t;
6513 + Ptm_Block : pthread_queue_t;
6514 + Ptm_Private : System.Address;
6516 + pragma Convention (C, pthread_mutex_t);
6518 + type pthread_mutexattr_t is record
6519 + Ptma_Majic : unsigned;
6520 + Ptma_Private : System.Address;
6522 + pragma Convention (C, pthread_mutexattr_t);
6524 + type pthread_cond_t is record
6525 + Ptc_Magic : unsigned;
6526 + Ptc_Lock : pthread_spin_t;
6527 + Ptc_Waiters : pthread_queue_t;
6528 + Ptc_Mutex : pthread_mutex_t;
6529 + Ptc_Private : System.Address;
6531 + pragma Convention (C, pthread_cond_t);
6533 + type pthread_condattr_t is record
6534 + Ptca_Magic : unsigned;
6535 + Ptca_Private : System.Address;
6537 + pragma Convention (C, pthread_condattr_t);
6539 + type pthread_key_t is new int;
6541 +end System.OS_Interface;
6543 +++ gcc/ada/s-osinte-openbsd.adb
6545 +------------------------------------------------------------------------------
6547 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
6549 +-- S Y S T E M . O S _ I N T E R F A C E --
6553 +-- Copyright (C) 1991-2009, Free Software Foundation, Inc. --
6555 +-- GNARL is free software; you can redistribute it and/or modify it under --
6556 +-- terms of the GNU General Public License as published by the Free Soft- --
6557 +-- ware Foundation; either version 3, or (at your option) any later ver- --
6558 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
6559 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
6560 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
6562 +-- As a special exception under Section 7 of GPL version 3, you are granted --
6563 +-- additional permissions described in the GCC Runtime Library Exception, --
6564 +-- version 3.1, as published by the Free Software Foundation. --
6566 +-- You should have received a copy of the GNU General Public License and --
6567 +-- a copy of the GCC Runtime Library Exception along with this program; --
6568 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
6569 +-- <http://www.gnu.org/licenses/>. --
6571 +-- GNARL was developed by the GNARL team at Florida State University. It is --
6572 +-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
6573 +-- State University (http://www.gnat.com). --
6575 +------------------------------------------------------------------------------
6577 +-- This is the OpenBSD THREADS version of this package
6579 +with Interfaces.C; use Interfaces.C;
6581 +package body System.OS_Interface is
6587 + function Errno return int is
6588 + type int_ptr is access all int;
6590 + function internal_errno return int_ptr;
6591 + pragma Import (C, internal_errno, "__errno");
6594 + return (internal_errno.all);
6597 + --------------------
6598 + -- Get_Stack_Base --
6599 + --------------------
6601 + function Get_Stack_Base (thread : pthread_t) return Address is
6602 + pragma Unreferenced (thread);
6604 + return Null_Address;
6605 + end Get_Stack_Base;
6607 + ------------------
6608 + -- pthread_init --
6609 + ------------------
6611 + procedure pthread_init is
6620 + function To_Duration (TS : timespec) return Duration is
6622 + return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
6625 + ------------------------
6626 + -- To_Target_Priority --
6627 + ------------------------
6629 + function To_Target_Priority
6630 + (Prio : System.Any_Priority) return Interfaces.C.int
6633 + return Interfaces.C.int (Prio);
6634 + end To_Target_Priority;
6640 + function To_Timespec (D : Duration) return timespec is
6645 + S := time_t (Long_Long_Integer (D));
6646 + F := D - Duration (S);
6648 + -- If F has negative value due to a round-up, adjust for positive F
6656 + return timespec'(tv_sec => S,
6657 + tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
6660 +end System.OS_Interface;
6662 +++ gcc/ada/s-osinte-openbsd.ads
6664 +------------------------------------------------------------------------------
6666 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
6668 +-- S Y S T E M . O S _ I N T E R F A C E --
6672 +-- Copyright (C) 1991-1994, Florida State University --
6673 +-- Copyright (C) 1995-2011, Free Software Foundation, Inc. --
6675 +-- GNAT is free software; you can redistribute it and/or modify it under --
6676 +-- terms of the GNU General Public License as published by the Free Soft- --
6677 +-- ware Foundation; either version 3, or (at your option) any later ver- --
6678 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
6679 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
6680 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
6682 +-- As a special exception under Section 7 of GPL version 3, you are granted --
6683 +-- additional permissions described in the GCC Runtime Library Exception, --
6684 +-- version 3.1, as published by the Free Software Foundation. --
6686 +-- You should have received a copy of the GNU General Public License and --
6687 +-- a copy of the GCC Runtime Library Exception along with this program; --
6688 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
6689 +-- <http://www.gnu.org/licenses/>. --
6691 +-- GNARL was developed by the GNARL team at Florida State University. It is --
6692 +-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
6693 +-- State University (http://www.gnat.com). --
6695 +------------------------------------------------------------------------------
6697 +-- This is the OpenBSD PTHREADS version of this package
6699 +-- This package encapsulates all direct interfaces to OS services
6700 +-- that are needed by the tasking run-time (libgnarl).
6702 +-- PLEASE DO NOT add any with-clauses to this package or remove the pragma
6703 +-- Preelaborate. This package is designed to be a bottom-level (leaf) package.
6705 +with Ada.Unchecked_Conversion;
6709 +package System.OS_Interface is
6710 + pragma Preelaborate;
6712 + pragma Linker_Options ("-pthread");
6714 + subtype int is Interfaces.C.int;
6715 + subtype short is Interfaces.C.short;
6716 + subtype long is Interfaces.C.long;
6717 + subtype unsigned is Interfaces.C.unsigned;
6718 + subtype unsigned_short is Interfaces.C.unsigned_short;
6719 + subtype unsigned_long is Interfaces.C.unsigned_long;
6720 + subtype unsigned_char is Interfaces.C.unsigned_char;
6721 + subtype plain_char is Interfaces.C.plain_char;
6722 + subtype size_t is Interfaces.C.size_t;
6728 + function Errno return int;
6729 + pragma Inline (Errno);
6731 + EAGAIN : constant := 35;
6732 + EINTR : constant := 4;
6733 + EINVAL : constant := 22;
6734 + ENOMEM : constant := 12;
6735 + ETIMEDOUT : constant := 60;
6741 + Max_Interrupt : constant := 31;
6742 + type Signal is new int range 0 .. Max_Interrupt;
6743 + for Signal'Size use int'Size;
6745 + SIGHUP : constant := 1; -- hangup
6746 + SIGINT : constant := 2; -- interrupt (rubout)
6747 + SIGQUIT : constant := 3; -- quit (ASCD FS)
6748 + SIGILL : constant := 4; -- illegal instruction (not reset)
6749 + SIGTRAP : constant := 5; -- trace trap (not reset)
6750 + SIGIOT : constant := 6; -- IOT instruction
6751 + SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
6752 + SIGEMT : constant := 7; -- EMT instruction
6753 + SIGFPE : constant := 8; -- floating point exception
6754 + SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
6755 + SIGBUS : constant := 10; -- bus error
6756 + SIGSEGV : constant := 11; -- segmentation violation
6757 + SIGSYS : constant := 12; -- bad argument to system call
6758 + SIGPIPE : constant := 13; -- write on a pipe with no one to read it
6759 + SIGALRM : constant := 14; -- alarm clock
6760 + SIGTERM : constant := 15; -- software termination signal from kill
6761 + SIGURG : constant := 16; -- urgent condition on IO channel
6762 + SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
6763 + SIGTSTP : constant := 18; -- user stop requested from tty
6764 + SIGCONT : constant := 19; -- stopped process has been continued
6765 + SIGCLD : constant := 20; -- alias for SIGCHLD
6766 + SIGCHLD : constant := 20; -- child status change
6767 + SIGTTIN : constant := 21; -- background tty read attempted
6768 + SIGTTOU : constant := 22; -- background tty write attempted
6769 + SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias)
6770 + SIGXCPU : constant := 24; -- CPU time limit exceeded
6771 + SIGXFSZ : constant := 25; -- filesize limit exceeded
6772 + SIGVTALRM : constant := 26; -- virtual timer expired
6773 + SIGPROF : constant := 27; -- profiling timer expired
6774 + SIGWINCH : constant := 28; -- window size change
6775 + SIGINFO : constant := 29; -- information request (BSD)
6776 + SIGUSR1 : constant := 30; -- user defined signal 1
6777 + SIGUSR2 : constant := 31; -- user defined signal 2
6779 + SIGADAABORT : constant := SIGABRT;
6780 + -- Change this if you want to use another signal for task abort.
6781 + -- SIGTERM might be a good one.
6783 + type Signal_Set is array (Natural range <>) of Signal;
6785 + -- Interrupts that must be unmasked at all times. OpenBSD
6786 + -- pthreads will not allow an application to mask out any
6787 + -- interrupt needed by the threads library.
6788 + Unmasked : constant Signal_Set :=
6789 + (SIGTRAP, SIGBUS, SIGTTIN, SIGTTOU, SIGTSTP);
6791 + -- OpenBSD will uses SIGPROF for timing. Do not allow a
6792 + -- handler to attach to this signal.
6793 + Reserved : constant Signal_Set := (0 .. 0 => SIGPROF);
6795 + type sigset_t is private;
6797 + function sigaddset
6798 + (set : access sigset_t;
6799 + sig : Signal) return int;
6800 + pragma Import (C, sigaddset, "sigaddset");
6802 + function sigdelset
6803 + (set : access sigset_t;
6804 + sig : Signal) return int;
6805 + pragma Import (C, sigdelset, "sigdelset");
6807 + function sigfillset (set : access sigset_t) return int;
6808 + pragma Import (C, sigfillset, "sigfillset");
6810 + function sigismember
6811 + (set : access sigset_t;
6812 + sig : Signal) return int;
6813 + pragma Import (C, sigismember, "sigismember");
6815 + function sigemptyset (set : access sigset_t) return int;
6816 + pragma Import (C, sigemptyset, "sigemptyset");
6818 + -- sigcontext is architecture dependent, so define it private
6819 + type struct_sigcontext is private;
6821 + type old_struct_sigaction is record
6822 + sa_handler : System.Address;
6823 + sa_mask : sigset_t;
6826 + pragma Convention (C, old_struct_sigaction);
6828 + type new_struct_sigaction is record
6829 + sa_handler : System.Address;
6831 + sa_mask : sigset_t;
6833 + pragma Convention (C, new_struct_sigaction);
6835 + subtype struct_sigaction is new_struct_sigaction;
6836 + type struct_sigaction_ptr is access all struct_sigaction;
6838 + SIG_BLOCK : constant := 1;
6839 + SIG_UNBLOCK : constant := 2;
6840 + SIG_SETMASK : constant := 3;
6842 + SIG_DFL : constant := 0;
6843 + SIG_IGN : constant := 1;
6845 + SA_SIGINFO : constant := 16#0040#;
6846 + SA_ONSTACK : constant := 16#0001#;
6848 + function sigaction
6850 + act : struct_sigaction_ptr;
6851 + oact : struct_sigaction_ptr) return int;
6852 + pragma Import (C, sigaction, "sigaction");
6858 + Time_Slice_Supported : constant Boolean := True;
6859 + -- Indicates whether time slicing is supported (i.e SCHED_RR is supported)
6861 + type timespec is private;
6863 + function nanosleep (rqtp, rmtp : access timespec) return int;
6864 + pragma Import (C, nanosleep, "nanosleep");
6866 + type clockid_t is new int;
6868 + function clock_gettime
6869 + (clock_id : clockid_t;
6870 + tp : access timespec)
6872 + pragma Import (C, clock_gettime, "clock_gettime");
6874 + function To_Duration (TS : timespec) return Duration;
6875 + pragma Inline (To_Duration);
6877 + function To_Timespec (D : Duration) return timespec;
6878 + pragma Inline (To_Timespec);
6880 + type struct_timezone is record
6881 + tz_minuteswest : int;
6884 + pragma Convention (C, struct_timezone);
6886 + procedure usleep (useconds : unsigned_long);
6887 + pragma Import (C, usleep, "usleep");
6889 + -------------------------
6890 + -- Priority Scheduling --
6891 + -------------------------
6893 + SCHED_FIFO : constant := 1;
6894 + SCHED_OTHER : constant := 2;
6895 + SCHED_RR : constant := 3;
6897 + function To_Target_Priority
6898 + (Prio : System.Any_Priority) return Interfaces.C.int;
6899 + -- Maps System.Any_Priority to a POSIX priority
6905 + type pid_t is private;
6907 + function kill (pid : pid_t; sig : Signal) return int;
6908 + pragma Import (C, kill, "kill");
6910 + function getpid return pid_t;
6911 + pragma Import (C, getpid, "getpid");
6917 + function lwp_self return System.Address;
6918 + -- lwp_self does not exist on this thread library, revert to pthread_self
6919 + -- which is the closest approximation (with getpid). This function is
6920 + -- needed to share 7staprop.adb across POSIX-like targets.
6921 + pragma Import (C, lwp_self, "pthread_self");
6927 + type Thread_Body is access
6928 + function (arg : System.Address) return System.Address;
6929 + pragma Convention (C, Thread_Body);
6931 + function Thread_Body_Access is new
6932 + Ada.Unchecked_Conversion (System.Address, Thread_Body);
6934 + type pthread_t is private;
6935 + subtype Thread_Id is pthread_t;
6937 + type pthread_mutex_t is limited private;
6938 + type pthread_cond_t is limited private;
6939 + type pthread_attr_t is limited private;
6940 + type pthread_mutexattr_t is limited private;
6941 + type pthread_condattr_t is limited private;
6942 + type pthread_key_t is private;
6944 + PTHREAD_CREATE_DETACHED : constant := 1;
6945 + PTHREAD_CREATE_JOINABLE : constant := 0;
6947 + PTHREAD_SCOPE_PROCESS : constant := 0;
6948 + PTHREAD_SCOPE_SYSTEM : constant := 2;
6950 + -- Read/Write lock not supported on freebsd. To add support both types
6951 + -- pthread_rwlock_t and pthread_rwlockattr_t must properly be defined
6952 + -- with the associated routines pthread_rwlock_[init/destroy] and
6953 + -- pthread_rwlock_[rdlock/wrlock/unlock].
6955 + subtype pthread_rwlock_t is pthread_mutex_t;
6956 + subtype pthread_rwlockattr_t is pthread_mutexattr_t;
6962 + type stack_t is record
6963 + ss_sp : System.Address;
6967 + pragma Convention (C, stack_t);
6969 + function sigaltstack
6970 + (ss : not null access stack_t;
6971 + oss : access stack_t) return int;
6972 + pragma Import (C, sigaltstack, "sigaltstack");
6974 + Alternate_Stack : aliased System.Address;
6975 + -- This is a dummy definition, never used (Alternate_Stack_Size is null)
6977 + Alternate_Stack_Size : constant := 0;
6978 + -- No alternate signal stack is used on this platform
6980 + Stack_Base_Available : constant Boolean := False;
6981 + -- Indicates whether the stack base is available on this target. This
6982 + -- allows us to share s-osinte.adb between all the FSU run time. Note that
6983 + -- this value can only be true if pthread_t has a complete definition that
6984 + -- corresponds exactly to the C header files.
6986 + function Get_Stack_Base (thread : pthread_t) return Address;
6987 + pragma Inline (Get_Stack_Base);
6988 + -- returns the stack base of the specified thread. Only call this function
6989 + -- when Stack_Base_Available is True.
6991 + function Get_Page_Size return size_t;
6992 + function Get_Page_Size return Address;
6993 + pragma Import (C, Get_Page_Size, "getpagesize");
6994 + -- Returns the size of a page
6996 + PROT_NONE : constant := 0;
6997 + PROT_READ : constant := 1;
6998 + PROT_WRITE : constant := 2;
6999 + PROT_EXEC : constant := 4;
7000 + PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
7001 + PROT_ON : constant := PROT_NONE;
7002 + PROT_OFF : constant := PROT_ALL;
7004 + function mprotect (addr : Address; len : size_t; prot : int) return int;
7005 + pragma Import (C, mprotect);
7007 + ---------------------------------------
7008 + -- Nonstandard Thread Initialization --
7009 + ---------------------------------------
7011 + -- FSU_THREADS requires pthread_init, which is nonstandard and this should
7012 + -- be invoked during the elaboration of s-taprop.adb.
7014 + -- OpenBSD does not require this so we provide an empty Ada body
7016 + procedure pthread_init;
7018 + -------------------------
7019 + -- POSIX.1c Section 3 --
7020 + -------------------------
7023 + (set : access sigset_t;
7024 + sig : access Signal) return int;
7025 + pragma Import (C, sigwait, "sigwait");
7027 + function pthread_kill
7028 + (thread : pthread_t;
7029 + sig : Signal) return int;
7030 + pragma Import (C, pthread_kill, "pthread_kill");
7032 + function pthread_sigmask
7034 + set : access sigset_t;
7035 + oset : access sigset_t) return int;
7036 + pragma Import (C, pthread_sigmask, "pthread_sigmask");
7038 + --------------------------
7039 + -- POSIX.1c Section 11 --
7040 + --------------------------
7042 + function pthread_mutexattr_init
7043 + (attr : access pthread_mutexattr_t) return int;
7044 + pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
7046 + function pthread_mutexattr_destroy
7047 + (attr : access pthread_mutexattr_t) return int;
7048 + pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
7050 + function pthread_mutex_init
7051 + (mutex : access pthread_mutex_t;
7052 + attr : access pthread_mutexattr_t) return int;
7053 + pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
7055 + function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
7056 + pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
7058 + function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
7059 + pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
7061 + function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
7062 + pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
7064 + function pthread_condattr_init
7065 + (attr : access pthread_condattr_t) return int;
7066 + pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
7068 + function pthread_condattr_destroy
7069 + (attr : access pthread_condattr_t) return int;
7070 + pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
7072 + function pthread_cond_init
7073 + (cond : access pthread_cond_t;
7074 + attr : access pthread_condattr_t) return int;
7075 + pragma Import (C, pthread_cond_init, "pthread_cond_init");
7077 + function pthread_cond_destroy (cond : access pthread_cond_t) return int;
7078 + pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
7080 + function pthread_cond_signal (cond : access pthread_cond_t) return int;
7081 + pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
7083 + function pthread_cond_wait
7084 + (cond : access pthread_cond_t;
7085 + mutex : access pthread_mutex_t) return int;
7086 + pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
7088 + function pthread_cond_timedwait
7089 + (cond : access pthread_cond_t;
7090 + mutex : access pthread_mutex_t;
7091 + abstime : access timespec) return int;
7092 + pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
7094 + Relative_Timed_Wait : constant Boolean := False;
7095 + -- pthread_cond_timedwait requires an absolute delay time
7097 + --------------------------
7098 + -- POSIX.1c Section 13 --
7099 + --------------------------
7101 + PTHREAD_PRIO_NONE : constant := 0;
7102 + PTHREAD_PRIO_PROTECT : constant := 2;
7103 + PTHREAD_PRIO_INHERIT : constant := 1;
7105 + function pthread_mutexattr_setprotocol
7106 + (attr : access pthread_mutexattr_t;
7107 + protocol : int) return int;
7109 + (C, pthread_mutexattr_setprotocol, "pthread_mutexattr_setprotocol");
7111 + function pthread_mutexattr_getprotocol
7112 + (attr : access pthread_mutexattr_t;
7113 + protocol : access int) return int;
7115 + (C, pthread_mutexattr_getprotocol, "pthread_mutexattr_getprotocol");
7117 + function pthread_mutexattr_setprioceiling
7118 + (attr : access pthread_mutexattr_t;
7119 + prioceiling : int) return int;
7121 + (C, pthread_mutexattr_setprioceiling,
7122 + "pthread_mutexattr_setprioceiling");
7124 + function pthread_mutexattr_getprioceiling
7125 + (attr : access pthread_mutexattr_t;
7126 + prioceiling : access int) return int;
7128 + (C, pthread_mutexattr_getprioceiling,
7129 + "pthread_mutexattr_getprioceiling");
7131 + type struct_sched_param is record
7132 + sched_priority : int;
7134 + pragma Convention (C, struct_sched_param);
7136 + function pthread_getschedparam
7137 + (thread : pthread_t;
7138 + policy : access int;
7139 + param : access struct_sched_param) return int;
7140 + pragma Import (C, pthread_getschedparam, "pthread_getschedparam");
7142 + function pthread_setschedparam
7143 + (thread : pthread_t;
7145 + param : access struct_sched_param) return int;
7146 + pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
7148 + function pthread_attr_setscope
7149 + (attr : access pthread_attr_t;
7150 + contentionscope : int) return int;
7151 + pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
7153 + function pthread_attr_getscope
7154 + (attr : access pthread_attr_t;
7155 + contentionscope : access int) return int;
7156 + pragma Import (C, pthread_attr_getscope, "pthread_attr_getscope");
7158 + function pthread_attr_setinheritsched
7159 + (attr : access pthread_attr_t;
7160 + inheritsched : int) return int;
7162 + (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
7164 + function pthread_attr_getinheritsched
7165 + (attr : access pthread_attr_t;
7166 + inheritsched : access int) return int;
7168 + (C, pthread_attr_getinheritsched, "pthread_attr_getinheritsched");
7170 + function pthread_attr_setschedpolicy
7171 + (attr : access pthread_attr_t;
7172 + policy : int) return int;
7173 + pragma Import (C, pthread_attr_setschedpolicy,
7174 + "pthread_attr_setschedpolicy");
7176 + function pthread_attr_getschedpolicy
7177 + (attr : access pthread_attr_t;
7178 + policy : access int) return int;
7179 + pragma Import (C, pthread_attr_getschedpolicy,
7180 + "pthread_attr_getschedpolicy");
7182 + function pthread_attr_setschedparam
7183 + (attr : access pthread_attr_t;
7184 + sched_param : int) return int;
7185 + pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
7187 + function pthread_attr_getschedparam
7188 + (attr : access pthread_attr_t;
7189 + sched_param : access int) return int;
7190 + pragma Import (C, pthread_attr_getschedparam, "pthread_attr_getschedparam");
7192 + function sched_yield return int;
7193 + pragma Import (C, sched_yield, "pthread_yield");
7195 + --------------------------
7196 + -- P1003.1c Section 16 --
7197 + --------------------------
7199 + function pthread_attr_init (attributes : access pthread_attr_t) return int;
7200 + pragma Import (C, pthread_attr_init, "pthread_attr_init");
7202 + function pthread_attr_destroy
7203 + (attributes : access pthread_attr_t) return int;
7204 + pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
7206 + function pthread_attr_setdetachstate
7207 + (attr : access pthread_attr_t;
7208 + detachstate : int) return int;
7210 + (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
7212 + function pthread_attr_getdetachstate
7213 + (attr : access pthread_attr_t;
7214 + detachstate : access int) return int;
7216 + (C, pthread_attr_getdetachstate, "pthread_attr_getdetachstate");
7218 + function pthread_attr_getstacksize
7219 + (attr : access pthread_attr_t;
7220 + stacksize : access size_t) return int;
7222 + (C, pthread_attr_getstacksize, "pthread_attr_getstacksize");
7224 + function pthread_attr_setstacksize
7225 + (attr : access pthread_attr_t;
7226 + stacksize : size_t) return int;
7228 + (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
7230 + function pthread_create
7231 + (thread : access pthread_t;
7232 + attributes : access pthread_attr_t;
7233 + start_routine : Thread_Body;
7234 + arg : System.Address) return int;
7235 + pragma Import (C, pthread_create, "pthread_create");
7237 + function pthread_detach (thread : pthread_t) return int;
7238 + pragma Import (C, pthread_detach, "pthread_detach");
7240 + procedure pthread_exit (status : System.Address);
7241 + pragma Import (C, pthread_exit, "pthread_exit");
7243 + function pthread_self return pthread_t;
7244 + pragma Import (C, pthread_self, "pthread_self");
7246 + --------------------------
7247 + -- POSIX.1c Section 17 --
7248 + --------------------------
7250 + function pthread_setspecific
7251 + (key : pthread_key_t;
7252 + value : System.Address) return int;
7253 + pragma Import (C, pthread_setspecific, "pthread_setspecific");
7255 + function pthread_getspecific (key : pthread_key_t) return System.Address;
7256 + pragma Import (C, pthread_getspecific, "pthread_getspecific");
7258 + type destructor_pointer is access procedure (arg : System.Address);
7259 + pragma Convention (C, destructor_pointer);
7261 + function pthread_key_create
7262 + (key : access pthread_key_t;
7263 + destructor : destructor_pointer) return int;
7264 + pragma Import (C, pthread_key_create, "pthread_key_create");
7266 + ------------------------------------
7267 + -- Non-portable Pthread Functions --
7268 + ------------------------------------
7270 + function pthread_set_name_np
7271 + (thread : pthread_t;
7272 + name : System.Address) return int;
7273 + pragma Import (C, pthread_set_name_np, "pthread_set_name_np");
7277 + type sigset_t is array (1 .. 4) of unsigned;
7279 + -- In OpenBSD the component sa_handler turns out to
7280 + -- be one a union type, and the selector is a macro:
7281 + -- #define sa_handler __sigaction_u._handler
7282 + -- #define sa_sigaction __sigaction_u._sigaction
7284 + -- Should we add a signal_context type here ???
7285 + -- How could it be done independent of the CPU architecture ???
7286 + -- sigcontext type is opaque, so it is architecturally neutral.
7287 + -- It is always passed as an access type, so define it as an empty record
7288 + -- since the contents are not used anywhere.
7290 + type struct_sigcontext is null record;
7291 + pragma Convention (C, struct_sigcontext);
7293 + type pid_t is new int;
7295 + type time_t is new int;
7297 + type timespec is record
7301 + pragma Convention (C, timespec);
7303 + type pthread_t is new System.Address;
7304 + type pthread_attr_t is new System.Address;
7305 + type pthread_mutex_t is new System.Address;
7306 + type pthread_mutexattr_t is new System.Address;
7307 + type pthread_cond_t is new System.Address;
7308 + type pthread_condattr_t is new System.Address;
7309 + type pthread_key_t is new int;
7311 +end System.OS_Interface;
7313 +++ gcc/ada/s-osprim-bsd32.adb
7315 +------------------------------------------------------------------------------
7317 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
7319 +-- S Y S T E M . O S _ P R I M I T I V E S --
7323 +-- Copyright (C) 1998-2009, Free Software Foundation, Inc. --
7325 +-- GNARL is free software; you can redistribute it and/or modify it under --
7326 +-- terms of the GNU General Public License as published by the Free Soft- --
7327 +-- ware Foundation; either version 3, or (at your option) any later ver- --
7328 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
7329 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
7330 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
7332 +-- As a special exception under Section 7 of GPL version 3, you are granted --
7333 +-- additional permissions described in the GCC Runtime Library Exception, --
7334 +-- version 3.1, as published by the Free Software Foundation. --
7336 +-- You should have received a copy of the GNU General Public License and --
7337 +-- a copy of the GCC Runtime Library Exception along with this program; --
7338 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
7339 +-- <http://www.gnu.org/licenses/>. --
7341 +-- GNARL was developed by the GNARL team at Florida State University. --
7342 +-- Extensive contributions were provided by Ada Core Technologies, Inc. --
7344 +-- Copyright (C) 2010, 2011 John Marino <www.dragonlace.net> --
7345 +------------------------------------------------------------------------------
7347 +-- This version is for BSD operating systems using 32-bit time types.
7351 +package body System.OS_Primitives is
7353 + -- ??? These definitions are duplicated from System.OS_Interface
7354 + -- because we don't want to depend on any package. Consider removing
7355 + -- these declarations in System.OS_Interface and move these ones in
7358 + subtype int is Interfaces.C.int;
7359 + subtype long is Interfaces.C.long;
7361 + type time_t is new int;
7363 + type timespec is record
7367 + pragma Convention (C, timespec);
7369 + type timezone is record
7370 + tz_minuteswest : int;
7373 + pragma Convention (C, timezone);
7375 + function nanosleep (rqtp, rmtp : access timespec) return int;
7376 + pragma Import (C, nanosleep, "nanosleep");
7382 + function Clock return Duration is
7383 + type timeval is array (1 .. 2) of Long_Integer;
7384 + tzresult : aliased timezone;
7386 + procedure timeval_to_duration
7387 + (T : not null access timeval;
7388 + sec : not null access Long_Integer;
7389 + usec : not null access Long_Integer);
7390 + pragma Import (C, timeval_to_duration, "__gnat_timeval_to_duration");
7392 + Micro : constant := 10**6;
7393 + sec : aliased Long_Integer;
7394 + usec : aliased Long_Integer;
7395 + TV : aliased timeval;
7398 + function gettimeofday
7399 + (Tv : access timeval;
7400 + Tz : access timezone) return int;
7401 + pragma Import (C, gettimeofday, "gettimeofday");
7403 + pragma Unreferenced (Result);
7405 + -- The return codes for gettimeofday are as follows (from man pages):
7406 + -- EPERM settimeofday is called by someone other than the superuser
7407 + -- EINVAL Timezone (or something else) is invalid
7408 + -- EFAULT One of tv or tz pointed outside accessible address space
7410 + -- None of these codes signal a potential clock skew, hence the return
7411 + -- value is never checked.
7413 + Result := gettimeofday (TV'Access, tzresult'Access);
7414 + timeval_to_duration (TV'Access, sec'Access, usec'Access);
7415 + return Duration (sec) + Duration (usec) / Micro;
7418 + ---------------------
7419 + -- Monotonic_Clock --
7420 + ---------------------
7422 + function Monotonic_Clock return Duration renames Clock;
7428 + function To_Timespec (D : Duration) return timespec;
7430 + function To_Timespec (D : Duration) return timespec is
7435 + S := time_t (Long_Long_Integer (D));
7436 + F := D - Duration (S);
7438 + -- If F has negative value due to a round-up, adjust for positive F
7447 + timespec'(tv_sec => S,
7448 + tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
7455 + procedure Timed_Delay
7459 + Request : aliased timespec;
7460 + Remaind : aliased timespec;
7461 + Rel_Time : Duration;
7462 + Abs_Time : Duration;
7463 + Base_Time : constant Duration := Clock;
7464 + Check_Time : Duration := Base_Time;
7467 + pragma Unreferenced (Result);
7470 + if Mode = Relative then
7472 + Abs_Time := Time + Check_Time;
7474 + Rel_Time := Time - Check_Time;
7478 + if Rel_Time > 0.0 then
7480 + Request := To_Timespec (Rel_Time);
7481 + Result := nanosleep (Request'Access, Remaind'Access);
7482 + Check_Time := Clock;
7484 + exit when Abs_Time <= Check_Time or else Check_Time < Base_Time;
7486 + Rel_Time := Abs_Time - Check_Time;
7495 + procedure Initialize is
7500 +end System.OS_Primitives;
7502 +++ gcc/ada/s-osprim-bsd64.adb
7504 +------------------------------------------------------------------------------
7506 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
7508 +-- S Y S T E M . O S _ P R I M I T I V E S --
7512 +-- Copyright (C) 1998-2009, Free Software Foundation, Inc. --
7514 +-- GNARL is free software; you can redistribute it and/or modify it under --
7515 +-- terms of the GNU General Public License as published by the Free Soft- --
7516 +-- ware Foundation; either version 3, or (at your option) any later ver- --
7517 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
7518 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
7519 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
7521 +-- As a special exception under Section 7 of GPL version 3, you are granted --
7522 +-- additional permissions described in the GCC Runtime Library Exception, --
7523 +-- version 3.1, as published by the Free Software Foundation. --
7525 +-- You should have received a copy of the GNU General Public License and --
7526 +-- a copy of the GCC Runtime Library Exception along with this program; --
7527 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
7528 +-- <http://www.gnu.org/licenses/>. --
7530 +-- GNARL was developed by the GNARL team at Florida State University. --
7531 +-- Extensive contributions were provided by Ada Core Technologies, Inc. --
7533 +-- Copyright (C) 2010, 2011 John Marino <www.dragonlace.net> --
7534 +------------------------------------------------------------------------------
7536 +-- This version is for BSD operating systems using 64-bit time types.
7540 +package body System.OS_Primitives is
7542 + -- ??? These definitions are duplicated from System.OS_Interface
7543 + -- because we don't want to depend on any package. Consider removing
7544 + -- these declarations in System.OS_Interface and move these ones in
7547 + subtype int is Interfaces.C.int;
7548 + subtype long is Interfaces.C.long;
7549 + subtype int64_t is Interfaces.Integer_64;
7551 + type time_t is new int64_t;
7553 + type timespec is record
7557 + pragma Convention (C, timespec);
7559 + type timezone is record
7560 + tz_minuteswest : int;
7563 + pragma Convention (C, timezone);
7565 + type timeval is record
7567 + tv_usec : long; -- Not for NetBSD! FreeBSD/DragonFly
7569 + pragma Convention (C, timeval);
7571 + function nanosleep (rqtp, rmtp : access timespec) return int;
7572 + pragma Import (C, nanosleep, "nanosleep");
7578 + function Clock return Duration is
7580 + procedure timeval_to_duration
7581 + (T : not null access timeval;
7582 + sec : not null access Long_Integer;
7583 + usec : not null access Long_Integer);
7584 + pragma Import (C, timeval_to_duration, "__gnat_timeval_to_duration");
7586 + Micro : constant := 10**6;
7587 + sec : aliased Long_Integer;
7588 + usec : aliased Long_Integer;
7589 + TV : aliased timeval;
7590 + tzresult : aliased timezone;
7593 + function gettimeofday
7594 + (Tv : access timeval;
7595 + Tz : access timezone) return int;
7596 + pragma Import (C, gettimeofday, "gettimeofday");
7598 + pragma Unreferenced (Result);
7600 + -- The return codes for gettimeofday are as follows (from man pages):
7601 + -- EPERM settimeofday is called by someone other than the superuser
7602 + -- EINVAL Timezone (or something else) is invalid
7603 + -- EFAULT One of tv or tz pointed outside accessible address space
7605 + -- None of these codes signal a potential clock skew, hence the return
7606 + -- value is never checked.
7608 + Result := gettimeofday (TV'Access, tzresult'Access);
7609 + timeval_to_duration (TV'Access, sec'Access, usec'Access);
7610 + return Duration (sec) + Duration (usec) / Micro;
7613 + ---------------------
7614 + -- Monotonic_Clock --
7615 + ---------------------
7617 + function Monotonic_Clock return Duration renames Clock;
7623 + function To_Timespec (D : Duration) return timespec;
7625 + function To_Timespec (D : Duration) return timespec is
7630 + S := time_t (Long_Long_Integer (D));
7631 + F := D - Duration (S);
7633 + -- If F has negative value due to a round-up, adjust for positive F
7642 + timespec'(tv_sec => S,
7643 + tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
7650 + procedure Timed_Delay
7654 + Request : aliased timespec;
7655 + Remaind : aliased timespec;
7656 + Rel_Time : Duration;
7657 + Abs_Time : Duration;
7658 + Base_Time : constant Duration := Clock;
7659 + Check_Time : Duration := Base_Time;
7662 + pragma Unreferenced (Result);
7665 + if Mode = Relative then
7667 + Abs_Time := Time + Check_Time;
7669 + Rel_Time := Time - Check_Time;
7673 + if Rel_Time > 0.0 then
7675 + Request := To_Timespec (Rel_Time);
7676 + Result := nanosleep (Request'Access, Remaind'Access);
7677 + Check_Time := Clock;
7679 + exit when Abs_Time <= Check_Time or else Check_Time < Base_Time;
7681 + Rel_Time := Abs_Time - Check_Time;
7690 + procedure Initialize is
7695 +end System.OS_Primitives;
7697 +++ gcc/ada/s-osprim-bsdn6.adb
7699 +------------------------------------------------------------------------------
7701 +-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
7703 +-- S Y S T E M . O S _ P R I M I T I V E S --
7707 +-- Copyright (C) 1998-2009, Free Software Foundation, Inc. --
7709 +-- GNARL is free software; you can redistribute it and/or modify it under --
7710 +-- terms of the GNU General Public License as published by the Free Soft- --
7711 +-- ware Foundation; either version 3, or (at your option) any later ver- --
7712 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
7713 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
7714 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
7716 +-- As a special exception under Section 7 of GPL version 3, you are granted --
7717 +-- additional permissions described in the GCC Runtime Library Exception, --
7718 +-- version 3.1, as published by the Free Software Foundation. --
7720 +-- You should have received a copy of the GNU General Public License and --
7721 +-- a copy of the GCC Runtime Library Exception along with this program; --
7722 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
7723 +-- <http://www.gnu.org/licenses/>. --
7725 +-- GNARL was developed by the GNARL team at Florida State University. --
7726 +-- Extensive contributions were provided by Ada Core Technologies, Inc. --
7728 +-- Copyright (C) 2010, 2011 John Marino <www.dragonlace.net> --
7729 +------------------------------------------------------------------------------
7731 +-- This version is for NetBSD 6.0+
7732 +-- It switches time type to 64 bits and uses compatibility functions
7736 +package body System.OS_Primitives is
7738 + -- ??? These definitions are duplicated from System.OS_Interface
7739 + -- because we don't want to depend on any package. Consider removing
7740 + -- these declarations in System.OS_Interface and move these ones in
7743 + subtype int is Interfaces.C.int;
7744 + subtype long is Interfaces.C.long;
7745 + subtype int64_t is Interfaces.Integer_64;
7747 + type time_t is new int64_t;
7749 + type timespec is record
7753 + pragma Convention (C, timespec);
7755 + type timezone is record
7756 + tz_minuteswest : int;
7759 + pragma Convention (C, timezone);
7761 + type timeval is record
7765 + pragma Convention (C, timeval);
7767 + function nanosleep (rqtp, rmtp : access timespec) return int;
7768 + pragma Import (C, nanosleep, "__nanosleep50");
7774 + function Clock return Duration is
7776 + procedure timeval_to_duration
7777 + (T : not null access timeval;
7778 + sec : not null access Long_Integer;
7779 + usec : not null access Long_Integer);
7780 + pragma Import (C, timeval_to_duration, "__gnat_timeval_to_duration");
7782 + Micro : constant := 10**6;
7783 + sec : aliased Long_Integer;
7784 + usec : aliased Long_Integer;
7785 + TV : aliased timeval;
7786 + tzresult : aliased timezone;
7789 + function gettimeofday
7790 + (Tv : access timeval;
7791 + Tz : access timezone) return int;
7792 + pragma Import (C, gettimeofday, "__gettimeofday50");
7794 + pragma Unreferenced (Result);
7796 + -- The return codes for gettimeofday are as follows (from man pages):
7797 + -- EPERM settimeofday is called by someone other than the superuser
7798 + -- EINVAL Timezone (or something else) is invalid
7799 + -- EFAULT One of tv or tz pointed outside accessible address space
7801 + -- None of these codes signal a potential clock skew, hence the return
7802 + -- value is never checked.
7804 + Result := gettimeofday (TV'Access, tzresult'Access);
7805 + timeval_to_duration (TV'Access, sec'Access, usec'Access);
7806 + return Duration (sec) + Duration (usec) / Micro;
7809 + ---------------------
7810 + -- Monotonic_Clock --
7811 + ---------------------
7813 + function Monotonic_Clock return Duration renames Clock;
7819 + function To_Timespec (D : Duration) return timespec;
7821 + function To_Timespec (D : Duration) return timespec is
7826 + S := time_t (Long_Long_Integer (D));
7827 + F := D - Duration (S);
7829 + -- If F has negative value due to a round-up, adjust for positive F
7838 + timespec'(tv_sec => S,
7839 + tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
7846 + procedure Timed_Delay
7850 + Request : aliased timespec;
7851 + Remaind : aliased timespec;
7852 + Rel_Time : Duration;
7853 + Abs_Time : Duration;
7854 + Base_Time : constant Duration := Clock;
7855 + Check_Time : Duration := Base_Time;
7858 + pragma Unreferenced (Result);
7861 + if Mode = Relative then
7863 + Abs_Time := Time + Check_Time;
7865 + Rel_Time := Time - Check_Time;
7869 + if Rel_Time > 0.0 then
7871 + Request := To_Timespec (Rel_Time);
7872 + Result := nanosleep (Request'Access, Remaind'Access);
7873 + Check_Time := Clock;
7875 + exit when Abs_Time <= Check_Time or else Check_Time < Base_Time;
7877 + Rel_Time := Abs_Time - Check_Time;
7886 + procedure Initialize is
7891 +end System.OS_Primitives;
7892 --- gcc/ada/s-rannum.adb.orig
7893 +++ gcc/ada/s-rannum.adb
7895 X : Real; -- Scaled mantissa
7896 R : Unsigned_32; -- Supply of random bits
7897 R_Bits : Natural; -- Number of bits left in R
7898 - K : Bit_Count; -- Next decrement to exponent
7899 + K : Bit_Count := 0; -- Next decrement to exponent
7902 Mantissa := Random (Gen) / 2**Extra_Bits;
7904 +++ gcc/ada/signal_android.c
7907 + * Copyright (C) 2008 The Android Open Source Project
7908 + * All rights reserved.
7910 + * Redistribution and use in source and binary forms, with or without
7911 + * modification, are permitted provided that the following conditions
7913 + * * Redistributions of source code must retain the above copyright
7914 + * notice, this list of conditions and the following disclaimer.
7915 + * * Redistributions in binary form must reproduce the above copyright
7916 + * notice, this list of conditions and the following disclaimer in
7917 + * the documentation and/or other materials provided with the
7920 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
7921 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7922 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
7923 + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
7924 + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
7925 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
7926 + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
7927 + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
7928 + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
7929 + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
7930 + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7933 +#include <limits.h> /* For LONG_BIT */
7934 +#include <string.h> /* For memset() */
7936 +typedef unsigned long sigset_t;
7940 +sigismember(sigset_t *set, int signum)
7942 + unsigned long *local_set = (unsigned long *)set;
7944 + return (int)((local_set[signum/LONG_BIT] >> (signum%LONG_BIT)) & 1);
7949 +sigaddset(sigset_t *set, int signum)
7951 + unsigned long *local_set = (unsigned long *)set;
7953 + local_set[signum/LONG_BIT] |= 1UL << (signum%LONG_BIT);
7959 +sigdelset(sigset_t *set, int signum)
7961 + unsigned long *local_set = (unsigned long *)set;
7963 + local_set[signum/LONG_BIT] &= ~(1UL << (signum%LONG_BIT));
7969 +sigemptyset(sigset_t *set)
7971 + memset(set, 0, sizeof *set);
7977 +sigfillset(sigset_t *set)
7979 + memset(set, ~0, sizeof *set);
7983 --- gcc/ada/sysdep.c.orig
7984 +++ gcc/ada/sysdep.c
7986 || defined (__MACHTEN__) || defined (__hpux__) || defined (_AIX) \
7987 || (defined (__svr4__) && defined (i386)) || defined (__Lynx__) \
7988 || defined (__CYGWIN__) || defined (__FreeBSD__) || defined (__OpenBSD__) \
7989 + || defined (__DragonFly__) \
7990 || defined (__GLIBC__) || defined (__APPLE__)
7994 || defined (__CYGWIN32__) || defined (__MACHTEN__) || defined (__hpux__) \
7995 || defined (_AIX) || (defined (__svr4__) && defined (i386)) \
7996 || defined (__Lynx__) || defined (__FreeBSD__) || defined (__OpenBSD__) \
7997 + || defined (__DragonFly__) \
7998 || defined (__GLIBC__) || defined (__APPLE__)
8002 || defined (__osf__) || defined (__MACHTEN__) || defined (__hpux__) \
8003 || defined (_AIX) || (defined (__svr4__) && defined (i386)) \
8004 || defined (__Lynx__) || defined (__FreeBSD__) || defined (__OpenBSD__) \
8005 + || defined (__DragonFly__) \
8006 || defined (__GLIBC__) || defined (__APPLE__)
8007 eof_ch = termios_rec.c_cc[VEOF];
8009 @@ -845,8 +848,12 @@
8010 /* Darwin, Free BSD, Linux, Tru64, where component tm_gmtoff is present in
8013 -#elif defined (__APPLE__) || defined (__FreeBSD__) || defined (linux) ||\
8014 - (defined (__alpha__) && defined (__osf__)) || defined (__GLIBC__)
8015 +#elif defined (__APPLE__) \
8016 + || defined (__FreeBSD__) \
8017 + || defined (__DragonFly__) \
8018 + || defined (linux) \
8019 + || (defined (__alpha__) && defined (__osf__)) \
8020 + || defined (__GLIBC__)
8022 localtime_r (timer, &tp);
8023 *off = tp.tm_gmtoff;
8025 +++ gcc/ada/system-dragonfly-x86.ads
8027 +------------------------------------------------------------------------------
8029 +-- GNAT RUN-TIME COMPONENTS --
8034 +-- (DragonFly BSD/x86 Version) --
8036 +-- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
8038 +-- This specification is derived from the Ada Reference Manual for use with --
8039 +-- GNAT. The copyright notice above, and the license provisions that follow --
8040 +-- apply solely to the contents of the part following the private keyword. --
8042 +-- GNAT is free software; you can redistribute it and/or modify it under --
8043 +-- terms of the GNU General Public License as published by the Free Soft- --
8044 +-- ware Foundation; either version 3, or (at your option) any later ver- --
8045 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
8046 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
8047 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
8049 +-- As a special exception under Section 7 of GPL version 3, you are granted --
8050 +-- additional permissions described in the GCC Runtime Library Exception, --
8051 +-- version 3.1, as published by the Free Software Foundation. --
8053 +-- You should have received a copy of the GNU General Public License and --
8054 +-- a copy of the GCC Runtime Library Exception along with this program; --
8055 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
8056 +-- <http://www.gnu.org/licenses/>. --
8058 +-- GNAT was originally developed by the GNAT team at New York University. --
8059 +-- Extensive contributions were provided by Ada Core Technologies Inc. --
8061 +------------------------------------------------------------------------------
8065 + -- Note that we take advantage of the implementation permission to make
8066 + -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
8067 + -- 2005, this is Pure in any case (AI-362).
8069 + type Name is (SYSTEM_NAME_GNAT);
8070 + System_Name : constant Name := SYSTEM_NAME_GNAT;
8072 + -- System-Dependent Named Numbers
8074 + Min_Int : constant := Long_Long_Integer'First;
8075 + Max_Int : constant := Long_Long_Integer'Last;
8077 + Max_Binary_Modulus : constant := 2 ** Long_Long_Integer'Size;
8078 + Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
8080 + Max_Base_Digits : constant := Long_Long_Float'Digits;
8081 + Max_Digits : constant := Long_Long_Float'Digits;
8083 + Max_Mantissa : constant := 63;
8084 + Fine_Delta : constant := 2.0 ** (-Max_Mantissa);
8086 + Tick : constant := 0.000_001;
8088 + -- Storage-related Declarations
8090 + type Address is private;
8091 + pragma Preelaborable_Initialization (Address);
8092 + Null_Address : constant Address;
8094 + Storage_Unit : constant := 8;
8095 + Word_Size : constant := 32;
8096 + Memory_Size : constant := 2 ** 32;
8098 + -- Address comparison
8100 + function "<" (Left, Right : Address) return Boolean;
8101 + function "<=" (Left, Right : Address) return Boolean;
8102 + function ">" (Left, Right : Address) return Boolean;
8103 + function ">=" (Left, Right : Address) return Boolean;
8104 + function "=" (Left, Right : Address) return Boolean;
8106 + pragma Import (Intrinsic, "<");
8107 + pragma Import (Intrinsic, "<=");
8108 + pragma Import (Intrinsic, ">");
8109 + pragma Import (Intrinsic, ">=");
8110 + pragma Import (Intrinsic, "=");
8112 + -- Other System-Dependent Declarations
8114 + type Bit_Order is (High_Order_First, Low_Order_First);
8115 + Default_Bit_Order : constant Bit_Order := Low_Order_First;
8116 + pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
8118 + -- Priority-related Declarations (RM D.1)
8120 + Max_Priority : constant Positive := 30;
8121 + Max_Interrupt_Priority : constant Positive := 31;
8123 + subtype Any_Priority is Integer range 0 .. 31;
8124 + subtype Priority is Any_Priority range 0 .. 30;
8125 + subtype Interrupt_Priority is Any_Priority range 31 .. 31;
8127 + Default_Priority : constant Priority := 15;
8131 + type Address is mod Memory_Size;
8132 + Null_Address : constant Address := 0;
8134 + --------------------------------------
8135 + -- System Implementation Parameters --
8136 + --------------------------------------
8138 + -- These parameters provide information about the target that is used
8139 + -- by the compiler. They are in the private part of System, where they
8140 + -- can be accessed using the special circuitry in the Targparm unit
8141 + -- whose source should be consulted for more detailed descriptions
8142 + -- of the individual switch values.
8144 + Backend_Divide_Checks : constant Boolean := False;
8145 + Backend_Overflow_Checks : constant Boolean := True;
8146 + Command_Line_Args : constant Boolean := True;
8147 + Configurable_Run_Time : constant Boolean := False;
8148 + Denorm : constant Boolean := True;
8149 + Duration_32_Bits : constant Boolean := False;
8150 + Exit_Status_Supported : constant Boolean := True;
8151 + Fractional_Fixed_Ops : constant Boolean := False;
8152 + Frontend_Layout : constant Boolean := False;
8153 + Machine_Overflows : constant Boolean := False;
8154 + Machine_Rounds : constant Boolean := True;
8155 + Preallocated_Stacks : constant Boolean := False;
8156 + Signed_Zeros : constant Boolean := True;
8157 + Stack_Check_Default : constant Boolean := False;
8158 + Stack_Check_Probes : constant Boolean := True;
8159 + Stack_Check_Limits : constant Boolean := False;
8160 + Support_Aggregates : constant Boolean := True;
8161 + Support_Composite_Assign : constant Boolean := True;
8162 + Support_Composite_Compare : constant Boolean := True;
8163 + Support_Long_Shifts : constant Boolean := True;
8164 + Always_Compatible_Rep : constant Boolean := False;
8165 + Suppress_Standard_Library : constant Boolean := False;
8166 + Use_Ada_Main_Program_Name : constant Boolean := False;
8167 + ZCX_By_Default : constant Boolean := True;
8171 +++ gcc/ada/system-dragonfly-x86_64.ads
8173 +------------------------------------------------------------------------------
8175 +-- GNAT RUN-TIME COMPONENTS --
8180 +-- (DragonFly BSD/x86_64 Version) --
8182 +-- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
8184 +-- This specification is derived from the Ada Reference Manual for use with --
8185 +-- GNAT. The copyright notice above, and the license provisions that follow --
8186 +-- apply solely to the contents of the part following the private keyword. --
8188 +-- GNAT is free software; you can redistribute it and/or modify it under --
8189 +-- terms of the GNU General Public License as published by the Free Soft- --
8190 +-- ware Foundation; either version 3, or (at your option) any later ver- --
8191 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
8192 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
8193 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
8195 +-- As a special exception under Section 7 of GPL version 3, you are granted --
8196 +-- additional permissions described in the GCC Runtime Library Exception, --
8197 +-- version 3.1, as published by the Free Software Foundation. --
8199 +-- You should have received a copy of the GNU General Public License and --
8200 +-- a copy of the GCC Runtime Library Exception along with this program; --
8201 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
8202 +-- <http://www.gnu.org/licenses/>. --
8204 +-- GNAT was originally developed by the GNAT team at New York University. --
8205 +-- Extensive contributions were provided by Ada Core Technologies Inc. --
8207 +------------------------------------------------------------------------------
8211 + -- Note that we take advantage of the implementation permission to make
8212 + -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
8213 + -- 2005, this is Pure in any case (AI-362).
8215 + type Name is (SYSTEM_NAME_GNAT);
8216 + System_Name : constant Name := SYSTEM_NAME_GNAT;
8218 + -- System-Dependent Named Numbers
8220 + Min_Int : constant := Long_Long_Integer'First;
8221 + Max_Int : constant := Long_Long_Integer'Last;
8223 + Max_Binary_Modulus : constant := 2 ** Long_Long_Integer'Size;
8224 + Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
8226 + Max_Base_Digits : constant := Long_Long_Float'Digits;
8227 + Max_Digits : constant := Long_Long_Float'Digits;
8229 + Max_Mantissa : constant := 63;
8230 + Fine_Delta : constant := 2.0 ** (-Max_Mantissa);
8232 + Tick : constant := 0.000_001;
8234 + -- Storage-related Declarations
8236 + type Address is private;
8237 + pragma Preelaborable_Initialization (Address);
8238 + Null_Address : constant Address;
8240 + Storage_Unit : constant := 8;
8241 + Word_Size : constant := 64;
8242 + Memory_Size : constant := 2 ** 64;
8244 + -- Address comparison
8246 + function "<" (Left, Right : Address) return Boolean;
8247 + function "<=" (Left, Right : Address) return Boolean;
8248 + function ">" (Left, Right : Address) return Boolean;
8249 + function ">=" (Left, Right : Address) return Boolean;
8250 + function "=" (Left, Right : Address) return Boolean;
8252 + pragma Import (Intrinsic, "<");
8253 + pragma Import (Intrinsic, "<=");
8254 + pragma Import (Intrinsic, ">");
8255 + pragma Import (Intrinsic, ">=");
8256 + pragma Import (Intrinsic, "=");
8258 + -- Other System-Dependent Declarations
8260 + type Bit_Order is (High_Order_First, Low_Order_First);
8261 + Default_Bit_Order : constant Bit_Order := Low_Order_First;
8262 + pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
8264 + -- Priority-related Declarations (RM D.1)
8266 + Max_Priority : constant Positive := 30;
8267 + Max_Interrupt_Priority : constant Positive := 31;
8269 + subtype Any_Priority is Integer range 0 .. 31;
8270 + subtype Priority is Any_Priority range 0 .. 30;
8271 + subtype Interrupt_Priority is Any_Priority range 31 .. 31;
8273 + Default_Priority : constant Priority := 15;
8277 + type Address is mod Memory_Size;
8278 + Null_Address : constant Address := 0;
8280 + --------------------------------------
8281 + -- System Implementation Parameters --
8282 + --------------------------------------
8284 + -- These parameters provide information about the target that is used
8285 + -- by the compiler. They are in the private part of System, where they
8286 + -- can be accessed using the special circuitry in the Targparm unit
8287 + -- whose source should be consulted for more detailed descriptions
8288 + -- of the individual switch values.
8290 + Backend_Divide_Checks : constant Boolean := False;
8291 + Backend_Overflow_Checks : constant Boolean := True;
8292 + Command_Line_Args : constant Boolean := True;
8293 + Configurable_Run_Time : constant Boolean := False;
8294 + Denorm : constant Boolean := True;
8295 + Duration_32_Bits : constant Boolean := False;
8296 + Exit_Status_Supported : constant Boolean := True;
8297 + Fractional_Fixed_Ops : constant Boolean := False;
8298 + Frontend_Layout : constant Boolean := False;
8299 + Machine_Overflows : constant Boolean := False;
8300 + Machine_Rounds : constant Boolean := True;
8301 + Preallocated_Stacks : constant Boolean := False;
8302 + Signed_Zeros : constant Boolean := True;
8303 + Stack_Check_Default : constant Boolean := False;
8304 + Stack_Check_Probes : constant Boolean := True;
8305 + Stack_Check_Limits : constant Boolean := False;
8306 + Support_Aggregates : constant Boolean := True;
8307 + Support_Composite_Assign : constant Boolean := True;
8308 + Support_Composite_Compare : constant Boolean := True;
8309 + Support_Long_Shifts : constant Boolean := True;
8310 + Always_Compatible_Rep : constant Boolean := False;
8311 + Suppress_Standard_Library : constant Boolean := False;
8312 + Use_Ada_Main_Program_Name : constant Boolean := False;
8313 + ZCX_By_Default : constant Boolean := True;
8317 +++ gcc/ada/system-netbsd-x86.ads
8319 +------------------------------------------------------------------------------
8321 +-- GNAT RUN-TIME COMPONENTS --
8326 +-- (NetBSD/x86 Version) --
8328 +-- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
8330 +-- This specification is derived from the Ada Reference Manual for use with --
8331 +-- GNAT. The copyright notice above, and the license provisions that follow --
8332 +-- apply solely to the contents of the part following the private keyword. --
8334 +-- GNAT is free software; you can redistribute it and/or modify it under --
8335 +-- terms of the GNU General Public License as published by the Free Soft- --
8336 +-- ware Foundation; either version 3, or (at your option) any later ver- --
8337 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
8338 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
8339 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
8341 +-- As a special exception under Section 7 of GPL version 3, you are granted --
8342 +-- additional permissions described in the GCC Runtime Library Exception, --
8343 +-- version 3.1, as published by the Free Software Foundation. --
8345 +-- You should have received a copy of the GNU General Public License and --
8346 +-- a copy of the GCC Runtime Library Exception along with this program; --
8347 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
8348 +-- <http://www.gnu.org/licenses/>. --
8350 +-- GNAT was originally developed by the GNAT team at New York University. --
8351 +-- Extensive contributions were provided by Ada Core Technologies Inc. --
8353 +------------------------------------------------------------------------------
8357 + -- Note that we take advantage of the implementation permission to make
8358 + -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
8359 + -- 2005, this is Pure in any case (AI-362).
8361 + type Name is (SYSTEM_NAME_GNAT);
8362 + System_Name : constant Name := SYSTEM_NAME_GNAT;
8364 + -- System-Dependent Named Numbers
8366 + Min_Int : constant := Long_Long_Integer'First;
8367 + Max_Int : constant := Long_Long_Integer'Last;
8369 + Max_Binary_Modulus : constant := 2 ** Long_Long_Integer'Size;
8370 + Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
8372 + Max_Base_Digits : constant := Long_Long_Float'Digits;
8373 + Max_Digits : constant := Long_Long_Float'Digits;
8375 + Max_Mantissa : constant := 63;
8376 + Fine_Delta : constant := 2.0 ** (-Max_Mantissa);
8378 + Tick : constant := 0.000_001;
8380 + -- Storage-related Declarations
8382 + type Address is private;
8383 + pragma Preelaborable_Initialization (Address);
8384 + Null_Address : constant Address;
8386 + Storage_Unit : constant := 8;
8387 + Word_Size : constant := 32;
8388 + Memory_Size : constant := 2 ** 32;
8390 + -- Address comparison
8392 + function "<" (Left, Right : Address) return Boolean;
8393 + function "<=" (Left, Right : Address) return Boolean;
8394 + function ">" (Left, Right : Address) return Boolean;
8395 + function ">=" (Left, Right : Address) return Boolean;
8396 + function "=" (Left, Right : Address) return Boolean;
8398 + pragma Import (Intrinsic, "<");
8399 + pragma Import (Intrinsic, "<=");
8400 + pragma Import (Intrinsic, ">");
8401 + pragma Import (Intrinsic, ">=");
8402 + pragma Import (Intrinsic, "=");
8404 + -- Other System-Dependent Declarations
8406 + type Bit_Order is (High_Order_First, Low_Order_First);
8407 + Default_Bit_Order : constant Bit_Order := Low_Order_First;
8408 + pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
8410 + -- Priority-related Declarations (RM D.1)
8412 + Max_Priority : constant Positive := 30;
8413 + Max_Interrupt_Priority : constant Positive := 31;
8415 + subtype Any_Priority is Integer range 0 .. 31;
8416 + subtype Priority is Any_Priority range 0 .. 30;
8417 + subtype Interrupt_Priority is Any_Priority range 31 .. 31;
8419 + Default_Priority : constant Priority := 15;
8423 + type Address is mod Memory_Size;
8424 + Null_Address : constant Address := 0;
8426 + --------------------------------------
8427 + -- System Implementation Parameters --
8428 + --------------------------------------
8430 + -- These parameters provide information about the target that is used
8431 + -- by the compiler. They are in the private part of System, where they
8432 + -- can be accessed using the special circuitry in the Targparm unit
8433 + -- whose source should be consulted for more detailed descriptions
8434 + -- of the individual switch values.
8436 + Backend_Divide_Checks : constant Boolean := False;
8437 + Backend_Overflow_Checks : constant Boolean := True;
8438 + Command_Line_Args : constant Boolean := True;
8439 + Configurable_Run_Time : constant Boolean := False;
8440 + Denorm : constant Boolean := True;
8441 + Duration_32_Bits : constant Boolean := False;
8442 + Exit_Status_Supported : constant Boolean := True;
8443 + Fractional_Fixed_Ops : constant Boolean := False;
8444 + Frontend_Layout : constant Boolean := False;
8445 + Machine_Overflows : constant Boolean := False;
8446 + Machine_Rounds : constant Boolean := True;
8447 + Preallocated_Stacks : constant Boolean := False;
8448 + Signed_Zeros : constant Boolean := True;
8449 + Stack_Check_Default : constant Boolean := False;
8450 + Stack_Check_Probes : constant Boolean := True;
8451 + Stack_Check_Limits : constant Boolean := False;
8452 + Support_Aggregates : constant Boolean := True;
8453 + Support_Composite_Assign : constant Boolean := True;
8454 + Support_Composite_Compare : constant Boolean := True;
8455 + Support_Long_Shifts : constant Boolean := True;
8456 + Always_Compatible_Rep : constant Boolean := False;
8457 + Suppress_Standard_Library : constant Boolean := False;
8458 + Use_Ada_Main_Program_Name : constant Boolean := False;
8459 + ZCX_By_Default : constant Boolean := True;
8463 +++ gcc/ada/system-netbsd-x86_64.ads
8465 +------------------------------------------------------------------------------
8467 +-- GNAT RUN-TIME COMPONENTS --
8472 +-- (NetBSD/x86_64 Version) --
8474 +-- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
8476 +-- This specification is derived from the Ada Reference Manual for use with --
8477 +-- GNAT. The copyright notice above, and the license provisions that follow --
8478 +-- apply solely to the contents of the part following the private keyword. --
8480 +-- GNAT is free software; you can redistribute it and/or modify it under --
8481 +-- terms of the GNU General Public License as published by the Free Soft- --
8482 +-- ware Foundation; either version 3, or (at your option) any later ver- --
8483 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
8484 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
8485 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
8487 +-- As a special exception under Section 7 of GPL version 3, you are granted --
8488 +-- additional permissions described in the GCC Runtime Library Exception, --
8489 +-- version 3.1, as published by the Free Software Foundation. --
8491 +-- You should have received a copy of the GNU General Public License and --
8492 +-- a copy of the GCC Runtime Library Exception along with this program; --
8493 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
8494 +-- <http://www.gnu.org/licenses/>. --
8496 +-- GNAT was originally developed by the GNAT team at New York University. --
8497 +-- Extensive contributions were provided by Ada Core Technologies Inc. --
8499 +------------------------------------------------------------------------------
8503 + -- Note that we take advantage of the implementation permission to make
8504 + -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
8505 + -- 2005, this is Pure in any case (AI-362).
8507 + type Name is (SYSTEM_NAME_GNAT);
8508 + System_Name : constant Name := SYSTEM_NAME_GNAT;
8510 + -- System-Dependent Named Numbers
8512 + Min_Int : constant := Long_Long_Integer'First;
8513 + Max_Int : constant := Long_Long_Integer'Last;
8515 + Max_Binary_Modulus : constant := 2 ** Long_Long_Integer'Size;
8516 + Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
8518 + Max_Base_Digits : constant := Long_Long_Float'Digits;
8519 + Max_Digits : constant := Long_Long_Float'Digits;
8521 + Max_Mantissa : constant := 63;
8522 + Fine_Delta : constant := 2.0 ** (-Max_Mantissa);
8524 + Tick : constant := 0.000_001;
8526 + -- Storage-related Declarations
8528 + type Address is private;
8529 + pragma Preelaborable_Initialization (Address);
8530 + Null_Address : constant Address;
8532 + Storage_Unit : constant := 8;
8533 + Word_Size : constant := 64;
8534 + Memory_Size : constant := 2 ** 64;
8536 + -- Address comparison
8538 + function "<" (Left, Right : Address) return Boolean;
8539 + function "<=" (Left, Right : Address) return Boolean;
8540 + function ">" (Left, Right : Address) return Boolean;
8541 + function ">=" (Left, Right : Address) return Boolean;
8542 + function "=" (Left, Right : Address) return Boolean;
8544 + pragma Import (Intrinsic, "<");
8545 + pragma Import (Intrinsic, "<=");
8546 + pragma Import (Intrinsic, ">");
8547 + pragma Import (Intrinsic, ">=");
8548 + pragma Import (Intrinsic, "=");
8550 + -- Other System-Dependent Declarations
8552 + type Bit_Order is (High_Order_First, Low_Order_First);
8553 + Default_Bit_Order : constant Bit_Order := Low_Order_First;
8554 + pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
8556 + -- Priority-related Declarations (RM D.1)
8558 + Max_Priority : constant Positive := 30;
8559 + Max_Interrupt_Priority : constant Positive := 31;
8561 + subtype Any_Priority is Integer range 0 .. 31;
8562 + subtype Priority is Any_Priority range 0 .. 30;
8563 + subtype Interrupt_Priority is Any_Priority range 31 .. 31;
8565 + Default_Priority : constant Priority := 15;
8569 + type Address is mod Memory_Size;
8570 + Null_Address : constant Address := 0;
8572 + --------------------------------------
8573 + -- System Implementation Parameters --
8574 + --------------------------------------
8576 + -- These parameters provide information about the target that is used
8577 + -- by the compiler. They are in the private part of System, where they
8578 + -- can be accessed using the special circuitry in the Targparm unit
8579 + -- whose source should be consulted for more detailed descriptions
8580 + -- of the individual switch values.
8582 + Backend_Divide_Checks : constant Boolean := False;
8583 + Backend_Overflow_Checks : constant Boolean := True;
8584 + Command_Line_Args : constant Boolean := True;
8585 + Configurable_Run_Time : constant Boolean := False;
8586 + Denorm : constant Boolean := True;
8587 + Duration_32_Bits : constant Boolean := False;
8588 + Exit_Status_Supported : constant Boolean := True;
8589 + Fractional_Fixed_Ops : constant Boolean := False;
8590 + Frontend_Layout : constant Boolean := False;
8591 + Machine_Overflows : constant Boolean := False;
8592 + Machine_Rounds : constant Boolean := True;
8593 + Preallocated_Stacks : constant Boolean := False;
8594 + Signed_Zeros : constant Boolean := True;
8595 + Stack_Check_Default : constant Boolean := False;
8596 + Stack_Check_Probes : constant Boolean := True;
8597 + Stack_Check_Limits : constant Boolean := False;
8598 + Support_Aggregates : constant Boolean := True;
8599 + Support_Composite_Assign : constant Boolean := True;
8600 + Support_Composite_Compare : constant Boolean := True;
8601 + Support_Long_Shifts : constant Boolean := True;
8602 + Always_Compatible_Rep : constant Boolean := False;
8603 + Suppress_Standard_Library : constant Boolean := False;
8604 + Use_Ada_Main_Program_Name : constant Boolean := False;
8605 + ZCX_By_Default : constant Boolean := True;
8609 +++ gcc/ada/system-openbsd-x86.ads
8611 +------------------------------------------------------------------------------
8613 +-- GNAT RUN-TIME COMPONENTS --
8618 +-- (OpenBSD/x86 Version) --
8620 +-- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
8622 +-- This specification is derived from the Ada Reference Manual for use with --
8623 +-- GNAT. The copyright notice above, and the license provisions that follow --
8624 +-- apply solely to the contents of the part following the private keyword. --
8626 +-- GNAT is free software; you can redistribute it and/or modify it under --
8627 +-- terms of the GNU General Public License as published by the Free Soft- --
8628 +-- ware Foundation; either version 3, or (at your option) any later ver- --
8629 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
8630 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
8631 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
8633 +-- As a special exception under Section 7 of GPL version 3, you are granted --
8634 +-- additional permissions described in the GCC Runtime Library Exception, --
8635 +-- version 3.1, as published by the Free Software Foundation. --
8637 +-- You should have received a copy of the GNU General Public License and --
8638 +-- a copy of the GCC Runtime Library Exception along with this program; --
8639 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
8640 +-- <http://www.gnu.org/licenses/>. --
8642 +-- GNAT was originally developed by the GNAT team at New York University. --
8643 +-- Extensive contributions were provided by Ada Core Technologies Inc. --
8645 +------------------------------------------------------------------------------
8649 + -- Note that we take advantage of the implementation permission to make
8650 + -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
8651 + -- 2005, this is Pure in any case (AI-362).
8653 + type Name is (SYSTEM_NAME_GNAT);
8654 + System_Name : constant Name := SYSTEM_NAME_GNAT;
8656 + -- System-Dependent Named Numbers
8658 + Min_Int : constant := Long_Long_Integer'First;
8659 + Max_Int : constant := Long_Long_Integer'Last;
8661 + Max_Binary_Modulus : constant := 2 ** Long_Long_Integer'Size;
8662 + Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
8664 + Max_Base_Digits : constant := Long_Long_Float'Digits;
8665 + Max_Digits : constant := Long_Long_Float'Digits;
8667 + Max_Mantissa : constant := 63;
8668 + Fine_Delta : constant := 2.0 ** (-Max_Mantissa);
8670 + Tick : constant := 0.000_001;
8672 + -- Storage-related Declarations
8674 + type Address is private;
8675 + pragma Preelaborable_Initialization (Address);
8676 + Null_Address : constant Address;
8678 + Storage_Unit : constant := 8;
8679 + Word_Size : constant := 32;
8680 + Memory_Size : constant := 2 ** 32;
8682 + -- Address comparison
8684 + function "<" (Left, Right : Address) return Boolean;
8685 + function "<=" (Left, Right : Address) return Boolean;
8686 + function ">" (Left, Right : Address) return Boolean;
8687 + function ">=" (Left, Right : Address) return Boolean;
8688 + function "=" (Left, Right : Address) return Boolean;
8690 + pragma Import (Intrinsic, "<");
8691 + pragma Import (Intrinsic, "<=");
8692 + pragma Import (Intrinsic, ">");
8693 + pragma Import (Intrinsic, ">=");
8694 + pragma Import (Intrinsic, "=");
8696 + -- Other System-Dependent Declarations
8698 + type Bit_Order is (High_Order_First, Low_Order_First);
8699 + Default_Bit_Order : constant Bit_Order := Low_Order_First;
8700 + pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
8702 + -- Priority-related Declarations (RM D.1)
8704 + Max_Priority : constant Positive := 30;
8705 + Max_Interrupt_Priority : constant Positive := 31;
8707 + subtype Any_Priority is Integer range 0 .. 31;
8708 + subtype Priority is Any_Priority range 0 .. 30;
8709 + subtype Interrupt_Priority is Any_Priority range 31 .. 31;
8711 + Default_Priority : constant Priority := 15;
8715 + type Address is mod Memory_Size;
8716 + Null_Address : constant Address := 0;
8718 + --------------------------------------
8719 + -- System Implementation Parameters --
8720 + --------------------------------------
8722 + -- These parameters provide information about the target that is used
8723 + -- by the compiler. They are in the private part of System, where they
8724 + -- can be accessed using the special circuitry in the Targparm unit
8725 + -- whose source should be consulted for more detailed descriptions
8726 + -- of the individual switch values.
8728 + Backend_Divide_Checks : constant Boolean := False;
8729 + Backend_Overflow_Checks : constant Boolean := True;
8730 + Command_Line_Args : constant Boolean := True;
8731 + Configurable_Run_Time : constant Boolean := False;
8732 + Denorm : constant Boolean := True;
8733 + Duration_32_Bits : constant Boolean := False;
8734 + Exit_Status_Supported : constant Boolean := True;
8735 + Fractional_Fixed_Ops : constant Boolean := False;
8736 + Frontend_Layout : constant Boolean := False;
8737 + Machine_Overflows : constant Boolean := False;
8738 + Machine_Rounds : constant Boolean := True;
8739 + Preallocated_Stacks : constant Boolean := False;
8740 + Signed_Zeros : constant Boolean := True;
8741 + Stack_Check_Default : constant Boolean := False;
8742 + Stack_Check_Probes : constant Boolean := True;
8743 + Stack_Check_Limits : constant Boolean := False;
8744 + Support_Aggregates : constant Boolean := True;
8745 + Support_Composite_Assign : constant Boolean := True;
8746 + Support_Composite_Compare : constant Boolean := True;
8747 + Support_Long_Shifts : constant Boolean := True;
8748 + Always_Compatible_Rep : constant Boolean := True;
8749 + Suppress_Standard_Library : constant Boolean := False;
8750 + Use_Ada_Main_Program_Name : constant Boolean := False;
8751 + ZCX_By_Default : constant Boolean := False;
8755 +++ gcc/ada/system-openbsd-x86_64.ads
8757 +------------------------------------------------------------------------------
8759 +-- GNAT RUN-TIME COMPONENTS --
8764 +-- (OpenBSD/x86_64 Version) --
8766 +-- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
8768 +-- This specification is derived from the Ada Reference Manual for use with --
8769 +-- GNAT. The copyright notice above, and the license provisions that follow --
8770 +-- apply solely to the contents of the part following the private keyword. --
8772 +-- GNAT is free software; you can redistribute it and/or modify it under --
8773 +-- terms of the GNU General Public License as published by the Free Soft- --
8774 +-- ware Foundation; either version 3, or (at your option) any later ver- --
8775 +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
8776 +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
8777 +-- or FITNESS FOR A PARTICULAR PURPOSE. --
8779 +-- As a special exception under Section 7 of GPL version 3, you are granted --
8780 +-- additional permissions described in the GCC Runtime Library Exception, --
8781 +-- version 3.1, as published by the Free Software Foundation. --
8783 +-- You should have received a copy of the GNU General Public License and --
8784 +-- a copy of the GCC Runtime Library Exception along with this program; --
8785 +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
8786 +-- <http://www.gnu.org/licenses/>. --
8788 +-- GNAT was originally developed by the GNAT team at New York University. --
8789 +-- Extensive contributions were provided by Ada Core Technologies Inc. --
8791 +------------------------------------------------------------------------------
8795 + -- Note that we take advantage of the implementation permission to make
8796 + -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
8797 + -- 2005, this is Pure in any case (AI-362).
8799 + type Name is (SYSTEM_NAME_GNAT);
8800 + System_Name : constant Name := SYSTEM_NAME_GNAT;
8802 + -- System-Dependent Named Numbers
8804 + Min_Int : constant := Long_Long_Integer'First;
8805 + Max_Int : constant := Long_Long_Integer'Last;
8807 + Max_Binary_Modulus : constant := 2 ** Long_Long_Integer'Size;
8808 + Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
8810 + Max_Base_Digits : constant := Long_Long_Float'Digits;
8811 + Max_Digits : constant := Long_Long_Float'Digits;
8813 + Max_Mantissa : constant := 63;
8814 + Fine_Delta : constant := 2.0 ** (-Max_Mantissa);
8816 + Tick : constant := 0.000_001;
8818 + -- Storage-related Declarations
8820 + type Address is private;
8821 + pragma Preelaborable_Initialization (Address);
8822 + Null_Address : constant Address;
8824 + Storage_Unit : constant := 8;
8825 + Word_Size : constant := 64;
8826 + Memory_Size : constant := 2 ** 64;
8828 + -- Address comparison
8830 + function "<" (Left, Right : Address) return Boolean;
8831 + function "<=" (Left, Right : Address) return Boolean;
8832 + function ">" (Left, Right : Address) return Boolean;
8833 + function ">=" (Left, Right : Address) return Boolean;
8834 + function "=" (Left, Right : Address) return Boolean;
8836 + pragma Import (Intrinsic, "<");
8837 + pragma Import (Intrinsic, "<=");
8838 + pragma Import (Intrinsic, ">");
8839 + pragma Import (Intrinsic, ">=");
8840 + pragma Import (Intrinsic, "=");
8842 + -- Other System-Dependent Declarations
8844 + type Bit_Order is (High_Order_First, Low_Order_First);
8845 + Default_Bit_Order : constant Bit_Order := Low_Order_First;
8846 + pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
8848 + -- Priority-related Declarations (RM D.1)
8850 + Max_Priority : constant Positive := 30;
8851 + Max_Interrupt_Priority : constant Positive := 31;
8853 + subtype Any_Priority is Integer range 0 .. 31;
8854 + subtype Priority is Any_Priority range 0 .. 30;
8855 + subtype Interrupt_Priority is Any_Priority range 31 .. 31;
8857 + Default_Priority : constant Priority := 15;
8861 + type Address is mod Memory_Size;
8862 + Null_Address : constant Address := 0;
8864 + --------------------------------------
8865 + -- System Implementation Parameters --
8866 + --------------------------------------
8868 + -- These parameters provide information about the target that is used
8869 + -- by the compiler. They are in the private part of System, where they
8870 + -- can be accessed using the special circuitry in the Targparm unit
8871 + -- whose source should be consulted for more detailed descriptions
8872 + -- of the individual switch values.
8874 + Backend_Divide_Checks : constant Boolean := False;
8875 + Backend_Overflow_Checks : constant Boolean := True;
8876 + Command_Line_Args : constant Boolean := True;
8877 + Configurable_Run_Time : constant Boolean := False;
8878 + Denorm : constant Boolean := True;
8879 + Duration_32_Bits : constant Boolean := False;
8880 + Exit_Status_Supported : constant Boolean := True;
8881 + Fractional_Fixed_Ops : constant Boolean := False;
8882 + Frontend_Layout : constant Boolean := False;
8883 + Machine_Overflows : constant Boolean := False;
8884 + Machine_Rounds : constant Boolean := True;
8885 + Preallocated_Stacks : constant Boolean := False;
8886 + Signed_Zeros : constant Boolean := True;
8887 + Stack_Check_Default : constant Boolean := False;
8888 + Stack_Check_Probes : constant Boolean := True;
8889 + Stack_Check_Limits : constant Boolean := False;
8890 + Support_Aggregates : constant Boolean := True;
8891 + Support_Composite_Assign : constant Boolean := True;
8892 + Support_Composite_Compare : constant Boolean := True;
8893 + Support_Long_Shifts : constant Boolean := True;
8894 + Always_Compatible_Rep : constant Boolean := True;
8895 + Suppress_Standard_Library : constant Boolean := False;
8896 + Use_Ada_Main_Program_Name : constant Boolean := False;
8897 + ZCX_By_Default : constant Boolean := False;
8900 --- gcc/ada/tracebak.c.orig
8901 +++ gcc/ada/tracebak.c
8902 @@ -217,6 +217,23 @@
8903 #error Unhandled darwin architecture.
8906 +/*---------------------------- x86 *BSD --------------------------------*/
8908 +#elif defined (__i386__) && \
8909 + ( defined (__NetBSD__) \
8910 + || defined (__FreeBSD__) \
8911 + || defined (__OpenBSD__) \
8912 + || defined (__DragonFly__) )
8914 +#define USE_GCC_UNWINDER
8915 +/* The generic unwinder is not used for this target because the default
8916 + implementation doesn't unwind on the BSD platforms. AMD64 targets use the
8917 + gcc unwinder for all platforms, so let's keep i386 consistent with that.
8920 +#define PC_ADJUST -2
8921 +/* The minimum size of call instructions on this architecture is 2 bytes */
8923 /*------------------------ PPC AIX/Older Darwin -------------------------*/
8924 #elif ((defined (_POWER) && defined (_AIX)) || \
8925 (defined (__ppc__) && defined (__APPLE__)))
8926 --- gcc/ada/gcc-interface/Makefile.in.orig
8927 +++ gcc/ada/gcc-interface/Makefile.in
8928 @@ -1037,6 +1037,7 @@
8929 ifeq ($(strip $(filter-out %86 %x86_64 solaris2%,$(arch) $(osys))),)
8930 LIBGNAT_TARGET_PAIRS_COMMON = \
8931 a-intnam.ads<a-intnam-solaris.ads \
8932 + g-trasym.adb<g-trasym-bsd.adb \
8933 s-inmaop.adb<s-inmaop-posix.adb \
8934 s-intman.adb<s-intman-solaris.adb \
8935 s-mudido.adb<s-mudido-affinity.adb \
8936 @@ -1205,14 +1206,21 @@
8937 LIBRARY_VERSION := $(LIB_VERSION)
8942 ifeq ($(strip $(filter-out %86 freebsd%,$(arch) $(osys))),)
8943 LIBGNAT_TARGET_PAIRS = \
8944 + a-exetim.adb<a-exetim-posix.adb \
8945 + a-exetim.ads<a-exetim-default.ads \
8946 a-intnam.ads<a-intnam-freebsd.ads \
8947 + g-socthi.adb<g-socthi-bsd.adb \
8948 + g-trasym.adb<g-trasym-bsd.adb \
8949 s-inmaop.adb<s-inmaop-posix.adb \
8950 s-intman.adb<s-intman-posix.adb \
8951 + s-mudido.adb<s-mudido-affinity.adb \
8952 s-osinte.adb<s-osinte-freebsd.adb \
8953 - s-osinte.ads<s-osinte-freebsd.ads \
8954 - s-osprim.adb<s-osprim-posix.adb \
8955 + s-osinte.ads<s-osinte-freebsd32.ads \
8956 + s-osprim.adb<s-osprim-bsd32.adb \
8957 s-taprop.adb<s-taprop-posix.adb \
8958 s-taspri.ads<s-taspri-posix.ads \
8959 s-tpopsp.adb<s-tpopsp-posix.adb \
8960 @@ -1220,10 +1228,11 @@
8961 $(X86_TARGET_PAIRS) \
8962 system.ads<system-freebsd-x86.ads
8964 - TOOLS_TARGET_PAIRS = \
8965 - mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb
8966 GNATLIB_SHARED = gnatlib-shared-dual
8968 + EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
8969 + EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
8972 THREADSLIB= -lpthread
8974 @@ -1231,26 +1240,101 @@
8978 -ifeq ($(strip $(filter-out %86_64 freebsd%,$(arch) $(osys))),)
8981 +ifeq ($(strip $(filter-out x86_64 freebsd%,$(arch) $(osys))),)
8982 LIBGNAT_TARGET_PAIRS = \
8983 + a-exetim.adb<a-exetim-posix.adb \
8984 + a-exetim.ads<a-exetim-default.ads \
8985 a-intnam.ads<a-intnam-freebsd.ads \
8986 + g-socthi.adb<g-socthi-bsd.adb \
8987 + g-trasym.adb<g-trasym-bsd.adb \
8988 s-inmaop.adb<s-inmaop-posix.adb \
8989 s-intman.adb<s-intman-posix.adb \
8990 + s-mudido.adb<s-mudido-affinity.adb \
8991 s-osinte.adb<s-osinte-freebsd.adb \
8992 - s-osinte.ads<s-osinte-freebsd.ads \
8993 - s-osprim.adb<s-osprim-posix.adb \
8994 + s-osinte.ads<s-osinte-freebsd64.ads \
8995 + s-osprim.adb<s-osprim-bsd64.adb \
8996 s-taprop.adb<s-taprop-posix.adb \
8997 s-taspri.ads<s-taspri-posix.ads \
8998 s-tpopsp.adb<s-tpopsp-posix.adb \
8999 - g-trasym.adb<g-trasym-dwarf.adb \
9000 $(ATOMICS_TARGET_PAIRS) \
9001 $(X86_64_TARGET_PAIRS) \
9002 system.ads<system-freebsd-x86_64.ads
9004 - TOOLS_TARGET_PAIRS = \
9005 - mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb
9006 GNATLIB_SHARED = gnatlib-shared-dual
9008 + EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
9009 + EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
9012 + THREADSLIB= -lpthread
9013 + GMEM_LIB = gmemlib
9014 + LIBRARY_VERSION := $(LIB_VERSION)
9020 +ifeq ($(strip $(filter-out %86 dragonfly%,$(arch) $(osys))),)
9021 + LIBGNAT_TARGET_PAIRS = \
9022 + a-exetim.adb<a-exetim-posix.adb \
9023 + a-exetim.ads<a-exetim-default.ads \
9024 + a-intnam.ads<a-intnam-dragonfly.ads \
9025 + g-socthi.adb<g-socthi-bsd.adb \
9026 + g-trasym.adb<g-trasym-bsd.adb \
9027 + s-inmaop.adb<s-inmaop-posix.adb \
9028 + s-intman.adb<s-intman-posix.adb \
9029 + s-mudido.adb<s-mudido-affinity.adb \
9030 + s-osinte.adb<s-osinte-dragonfly.adb \
9031 + s-osinte.ads<s-osinte-dragonfly.ads \
9032 + s-osprim.adb<s-osprim-posix.adb \
9033 + s-taprop.adb<s-taprop-posix.adb \
9034 + s-taspri.ads<s-taspri-posix.ads \
9035 + s-tpopsp.adb<s-tpopsp-posix.adb \
9036 + $(ATOMICS_TARGET_PAIRS) \
9037 + $(X86_TARGET_PAIRS) \
9038 + system.ads<system-dragonfly-x86.ads
9040 + GNATLIB_SHARED = gnatlib-shared-dual
9042 + EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
9043 + EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
9046 + THREADSLIB= -lpthread
9047 + GMEM_LIB = gmemlib
9048 + LIBRARY_VERSION := $(LIB_VERSION)
9054 +ifeq ($(strip $(filter-out x86_64 dragonfly%,$(arch) $(osys))),)
9055 + LIBGNAT_TARGET_PAIRS = \
9056 + a-exetim.adb<a-exetim-posix.adb \
9057 + a-exetim.ads<a-exetim-default.ads \
9058 + a-intnam.ads<a-intnam-dragonfly.ads \
9059 + g-socthi.adb<g-socthi-bsd.adb \
9060 + g-trasym.adb<g-trasym-bsd.adb \
9061 + s-inmaop.adb<s-inmaop-posix.adb \
9062 + s-intman.adb<s-intman-posix.adb \
9063 + s-mudido.adb<s-mudido-affinity.adb \
9064 + s-osinte.adb<s-osinte-dragonfly.adb \
9065 + s-osinte.ads<s-osinte-dragonfly.ads \
9066 + s-osprim.adb<s-osprim-posix.adb \
9067 + s-taprop.adb<s-taprop-posix.adb \
9068 + s-taspri.ads<s-taspri-posix.ads \
9069 + s-tpopsp.adb<s-tpopsp-posix.adb \
9070 + $(ATOMICS_TARGET_PAIRS) \
9071 + $(X86_64_TARGET_PAIRS) \
9072 + system.ads<system-dragonfly-x86_64.ads
9074 + GNATLIB_SHARED = gnatlib-shared-dual
9076 + EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
9077 + EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
9080 THREADSLIB= -lpthread
9082 @@ -1258,6 +1342,200 @@
9088 +ifeq ($(strip $(filter-out %86 openbsd%,$(arch) $(osys))),)
9089 + LIBGNAT_TARGET_PAIRS = \
9090 + a-exetim.adb<a-exetim-posix.adb \
9091 + a-exetim.ads<a-exetim-default.ads \
9092 + a-intnam.ads<a-intnam-openbsd.ads \
9093 + g-socthi.adb<g-socthi-bsd.adb \
9094 + g-trasym.adb<g-trasym-bsd.adb \
9095 + s-inmaop.adb<s-inmaop-posix.adb \
9096 + s-intman.adb<s-intman-posix.adb \
9097 + s-mudido.adb<s-mudido-affinity.adb \
9098 + s-osinte.adb<s-osinte-openbsd.adb \
9099 + s-osinte.ads<s-osinte-openbsd.ads \
9100 + s-osprim.adb<s-osprim-bsd32.adb \
9101 + s-taprop.adb<s-taprop-posix.adb \
9102 + s-taspri.ads<s-taspri-posix.ads \
9103 + s-tpopsp.adb<s-tpopsp-posix.adb \
9104 + $(ATOMICS_TARGET_PAIRS) \
9105 + $(X86_TARGET_PAIRS) \
9106 + system.ads<system-openbsd-x86.ads
9108 + GNATLIB_SHARED = gnatlib-shared-dual
9110 + EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
9111 + EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
9114 + THREADSLIB= -lpthread
9116 + LIBRARY_VERSION := $(LIB_VERSION)
9122 +ifeq ($(strip $(filter-out x86_64 openbsd%,$(arch) $(osys))),)
9123 + LIBGNAT_TARGET_PAIRS = \
9124 + a-exetim.adb<a-exetim-posix.adb \
9125 + a-exetim.ads<a-exetim-default.ads \
9126 + a-intnam.ads<a-intnam-openbsd.ads \
9127 + g-socthi.adb<g-socthi-bsd.adb \
9128 + g-trasym.adb<g-trasym-bsd.adb \
9129 + s-inmaop.adb<s-inmaop-posix.adb \
9130 + s-intman.adb<s-intman-posix.adb \
9131 + s-mudido.adb<s-mudido-affinity.adb \
9132 + s-osinte.adb<s-osinte-openbsd.adb \
9133 + s-osinte.ads<s-osinte-openbsd.ads \
9134 + s-osprim.adb<s-osprim-bsd32.adb \
9135 + s-taprop.adb<s-taprop-posix.adb \
9136 + s-taspri.ads<s-taspri-posix.ads \
9137 + s-tpopsp.adb<s-tpopsp-posix.adb \
9138 + $(ATOMICS_TARGET_PAIRS) \
9139 + $(X86_64_TARGET_PAIRS) \
9140 + system.ads<system-openbsd-x86_64.ads
9142 + GNATLIB_SHARED = gnatlib-shared-dual
9144 + EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
9145 + EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
9148 + THREADSLIB= -lpthread
9149 + GMEM_LIB = gmemlib
9150 + LIBRARY_VERSION := $(LIB_VERSION)
9155 +# NETBSD i386 (5+ only)
9156 +ifeq ($(strip $(filter-out %86 netbsd%,$(arch) $(osys))),)
9157 + LIBGNAT_TARGET_PAIRS = \
9158 + a-exetim.adb<a-exetim-posix.adb \
9159 + a-exetim.ads<a-exetim-default.ads \
9160 + a-intnam.ads<a-intnam-netbsd.ads \
9161 + g-socthi.adb<g-socthi-netbsd.adb \
9162 + g-trasym.adb<g-trasym-bsd.adb \
9163 + s-inmaop.adb<s-inmaop-posix.adb \
9164 + s-intman.adb<s-intman-posix.adb \
9165 + s-mudido.adb<s-mudido-affinity.adb \
9166 + s-osinte.adb<s-osinte-netbsd.adb \
9167 + s-taprop.adb<s-taprop-posix.adb \
9168 + s-taspri.ads<s-taspri-posix.ads \
9169 + s-tpopsp.adb<s-tpopsp-posix.adb \
9170 + $(ATOMICS_TARGET_PAIRS) \
9171 + $(X86_TARGET_PAIRS) \
9172 + system.ads<system-netbsd-x86.ads
9174 + ifeq ($(strip $(filter-out %86 netbsdelf5%,$(arch) $(osys))),)
9175 + LIBGNAT_TARGET_PAIRS+= \
9176 + s-osinte.ads<s-osinte-netbsd.ads \
9177 + s-osprim.adb<s-osprim-bsd32.adb
9179 + LIBGNAT_TARGET_PAIRS+= \
9180 + g-socthi.ads<g-socthi-netbsd6.ads \
9181 + s-osinte.ads<s-osinte-netbsd6.ads \
9182 + s-osprim.adb<s-osprim-bsdn6.adb
9185 + GNATLIB_SHARED = gnatlib-shared-dual
9187 + EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
9188 + EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
9191 + THREADSLIB= -lpthread
9192 + GMEM_LIB = gmemlib
9193 + LIBRARY_VERSION := $(LIB_VERSION)
9198 +# NETBSD AMD64 (5+ only)
9199 +ifeq ($(strip $(filter-out x86_64 netbsd%,$(arch) $(osys))),)
9200 + LIBGNAT_TARGET_PAIRS = \
9201 + a-exetim.adb<a-exetim-posix.adb \
9202 + a-exetim.ads<a-exetim-default.ads \
9203 + a-intnam.ads<a-intnam-netbsd.ads \
9204 + g-socthi.adb<g-socthi-netbsd.adb \
9205 + g-trasym.adb<g-trasym-bsd.adb \
9206 + s-inmaop.adb<s-inmaop-posix.adb \
9207 + s-intman.adb<s-intman-posix.adb \
9208 + s-mudido.adb<s-mudido-affinity.adb \
9209 + s-osinte.adb<s-osinte-netbsd.adb \
9210 + s-taprop.adb<s-taprop-posix.adb \
9211 + s-taspri.ads<s-taspri-posix.ads \
9212 + s-tpopsp.adb<s-tpopsp-posix.adb \
9213 + $(ATOMICS_TARGET_PAIRS) \
9214 + $(X86_64_TARGET_PAIRS) \
9215 + system.ads<system-netbsd-x86_64.ads
9217 + ifeq ($(strip $(filter-out x86_64 netbsd5%,$(arch) $(osys))),)
9218 + LIBGNAT_TARGET_PAIRS+= \
9219 + s-osinte.ads<s-osinte-netbsd.ads \
9220 + s-osprim.adb<s-osprim-bsd32.adb
9222 + LIBGNAT_TARGET_PAIRS+= \
9223 + g-socthi.ads<g-socthi-netbsd6.ads \
9224 + s-osinte.ads<s-osinte-netbsd6.ads \
9225 + s-osprim.adb<s-osprim-bsdn6.adb
9228 + GNATLIB_SHARED = gnatlib-shared-dual
9230 + EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
9231 + EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
9234 + THREADSLIB= -lpthread
9235 + GMEM_LIB = gmemlib
9236 + LIBRARY_VERSION := $(LIB_VERSION)
9242 +ifeq ($(strip $(filter-out arm% android eabi,$(targ))),)
9243 + LIBGNAT_TARGET_PAIRS = \
9244 + a-intnam.ads<a-intnam-linux.ads \
9245 + g-trasym.ads<g-trasym-unimplemented.ads \
9246 + g-trasym.adb<g-trasym-unimplemented.adb \
9247 + s-inmaop.adb<s-inmaop-posix.adb \
9248 + s-intman.adb<s-intman-posix.adb \
9249 + s-linux.ads<s-linux.ads \
9250 + s-osinte.adb<s-osinte-posix.adb \
9251 + s-mudido.adb<s-mudido-affinity.adb \
9252 + s-osinte.ads<s-osinte-android.ads \
9253 + s-osprim.adb<s-osprim-posix.adb \
9254 + s-taprop.adb<s-taprop-linux.adb \
9255 + s-tasinf.ads<s-tasinf-linux.ads \
9256 + s-tasinf.adb<s-tasinf-linux.adb \
9257 + s-taspri.ads<s-taspri-posix-noaltstack.ads \
9258 + s-tpopsp.adb<s-tpopsp-posix-foreign.adb
9260 + ifeq ($(strip $(filter-out arm%b,$(arch))),)
9261 + LIBGNAT_TARGET_PAIRS += \
9262 + system.ads<system-linux-armeb.ads
9264 + LIBGNAT_TARGET_PAIRS += \
9265 + system.ads<system-linux-armel.ads
9268 + EXTRA_LIBGNAT_SRCS+= signal_android.c
9269 + EXTRA_LIBGNAT_OBJS+= signal_android.o
9270 + EXTRA_GNATRTL_TASKING_OBJS= s-linux.o
9274 + GNATLIB_SHARED= gnatlib-shared-dual
9276 + LIBRARY_VERSION:= $(LIB_VERSION)
9280 ifeq ($(strip $(filter-out s390% linux%,$(arch) $(osys))),)
9281 LIBGNAT_TARGET_PAIRS_COMMON = \
9282 a-intnam.ads<a-intnam-linux.ads \
9283 @@ -2597,7 +2875,7 @@
9284 $(MAKE) $(FLAGS_TO_PASS) \
9285 GNATLIBFLAGS="$(GNATLIBFLAGS)" \
9286 GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(PICFLAG_FOR_TARGET)" \
9287 - GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
9288 + GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C) $(PICFLAG_FOR_TARGET)" \
9289 MULTISUBDIR="$(MULTISUBDIR)" \
9290 THREAD_KIND="$(THREAD_KIND)" \
9292 --- gnattools/configure.orig
9293 +++ gnattools/configure
9294 @@ -2058,7 +2058,27 @@
9296 TOOLS_TARGET_PAIRS="mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb"
9299 + *86-*-freebsd* | x86_64-*-freebsd*)
9300 + TOOLS_TARGET_PAIRS="\
9301 + mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
9302 + indepsw.adb<indepsw-gnu.adb"
9304 + *86-*-dragonfly* | x86_64-*-dragonfly*)
9305 + TOOLS_TARGET_PAIRS="\
9306 + mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
9307 + indepsw.adb<indepsw-gnu.adb"
9309 + *86-*-openbsd* | x86_64-*-openbsd*)
9310 + TOOLS_TARGET_PAIRS="\
9311 + mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
9312 + indepsw.adb<indepsw-gnu.adb"
9314 + *86-*-netbsdelf* | x86_64-*-netbsd*)
9315 + TOOLS_TARGET_PAIRS="\
9316 + mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
9317 + indepsw.adb<indepsw-gnu.adb"
9319 + arm*-android-eabi)
9320 TOOLS_TARGET_PAIRS="\
9321 mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
9322 indepsw.adb<indepsw-gnu.adb"
9323 --- gnattools/configure.ac.orig
9324 +++ gnattools/configure.ac
9327 TOOLS_TARGET_PAIRS="mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb"
9330 + *86-*-freebsd* | x86_64-*-freebsd*)
9331 TOOLS_TARGET_PAIRS="\
9332 mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
9333 indepsw.adb<indepsw-gnu.adb"
9335 + *86-*-dragonfly* | x86_64-*-dragonfly*)
9336 + TOOLS_TARGET_PAIRS="\
9337 + mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
9338 + indepsw.adb<indepsw-gnu.adb"
9340 + *86-*-openbsd* | x86_64-*-openbsd*)
9341 + TOOLS_TARGET_PAIRS="\
9342 + mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
9343 + indepsw.adb<indepsw-gnu.adb"
9345 + *86-*-netbsdelf* | x86_64-*-netbsd*)
9346 + TOOLS_TARGET_PAIRS="\
9347 + mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
9348 + indepsw.adb<indepsw-gnu.adb"
9350 + arm*-android-eabi)
9351 + TOOLS_TARGET_PAIRS="\
9352 + mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
9353 + indepsw.adb<indepsw-gnu.adb"
9356 TOOLS_TARGET_PAIRS="mlib-tgt-specific.adb<mlib-tgt-specific-irix.adb"
9358 --- gcc/ada/gcc-interface/Make-lang.in.orig
9359 +++ gcc/ada/gcc-interface/Make-lang.in
9363 # Language-independent object files.
9364 -ADA_BACKEND = $(BACKEND) attribs.o
9365 +ADA_BACKEND = $(BACKEND2) attribs.o
9367 # List of target dependent sources, overridden below as necessary