Fixup fromcvs/togit conversion
[pkgsrcv2.git] / lang / gcc-aux / files / diff-ada
1 --- gcc/ada/a-exetim-posix.adb.orig
2 +++ gcc/ada/a-exetim-posix.adb
3 @@ -106,11 +106,11 @@
4        --  Time is equal to Duration (although it is a private type) and
5        --  CPU_Time is equal to Time.
6  
7 -      function clock_gettime
8 +      function clock_gettime_int
9          (clock_id : Interfaces.C.int;
10           tp       : access timespec)
11           return 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
15  
16     begin
17 @@ -118,7 +118,7 @@
18           raise Program_Error;
19        end if;
20  
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);
25  
26 --- /dev/null
27 +++ gcc/ada/a-intnam-dragonfly.ads
28 @@ -0,0 +1,136 @@
29 +------------------------------------------------------------------------------
30 +--                                                                          --
31 +--                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
32 +--                                                                          --
33 +--                   A D A . I N T E R R U P T S . N A M E S                --
34 +--                                                                          --
35 +--                                  S p e c                                 --
36 +--                                                                          --
37 +--          Copyright (C) 1991-2011, Free Software Foundation, Inc.         --
38 +--                                                                          --
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.                                     --
45 +--                                                                          --
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.               --
49 +--                                                                          --
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/>.                                          --
54 +--                                                                          --
55 +-- GNARL was developed by the GNARL team at Florida State University.       --
56 +-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
57 +--                                                                          --
58 +------------------------------------------------------------------------------
59 +
60 +--  This is the DragonFly BSD THREADS version of this package
61 +
62 +with System.OS_Interface;
63 +
64 +package Ada.Interrupts.Names is
65 +
66 +   --  All identifiers in this unit are implementation defined
67 +
68 +   pragma Implementation_Defined;
69 +
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.
73 +
74 +   SIGHUP : constant Interrupt_ID :=
75 +     System.OS_Interface.SIGHUP;      --  hangup
76 +
77 +   SIGINT : constant Interrupt_ID :=
78 +     System.OS_Interface.SIGINT;      --  interrupt (rubout)
79 +
80 +   SIGQUIT : constant Interrupt_ID :=
81 +     System.OS_Interface.SIGQUIT;     --  quit (ASCD FS)
82 +
83 +   SIGILL : constant Interrupt_ID :=
84 +     System.OS_Interface.SIGILL;      --  illegal instruction (not reset)
85 +
86 +   SIGTRAP : constant Interrupt_ID :=
87 +     System.OS_Interface.SIGTRAP;     --  trace trap (not reset)
88 +
89 +   SIGIOT : constant Interrupt_ID :=
90 +     System.OS_Interface.SIGIOT;      --  IOT instruction
91 +
92 +   SIGABRT : constant Interrupt_ID := --  used by abort,
93 +     System.OS_Interface.SIGABRT;     --  replace SIGIOT in the  future
94 +
95 +   SIGFPE : constant Interrupt_ID :=
96 +     System.OS_Interface.SIGFPE;      --  floating point exception
97 +
98 +   SIGKILL : constant Interrupt_ID :=
99 +     System.OS_Interface.SIGKILL;     --  kill (cannot be caught or ignored)
100 +
101 +   SIGBUS : constant Interrupt_ID :=
102 +     System.OS_Interface.SIGBUS;      --  bus error
103 +
104 +   SIGSEGV : constant Interrupt_ID :=
105 +     System.OS_Interface.SIGSEGV;     --  segmentation violation
106 +
107 +   SIGPIPE : constant Interrupt_ID := --  write on a pipe with
108 +     System.OS_Interface.SIGPIPE;     --  no one to read it
109 +
110 +   SIGALRM : constant Interrupt_ID :=
111 +     System.OS_Interface.SIGALRM;     --  alarm clock
112 +
113 +   SIGTERM : constant Interrupt_ID :=
114 +     System.OS_Interface.SIGTERM;     --  software termination signal from kill
115 +
116 +   SIGURG : constant Interrupt_ID :=
117 +     System.OS_Interface.SIGURG;      --  urgent condition on IO channel
118 +
119 +   SIGSTOP : constant Interrupt_ID :=
120 +     System.OS_Interface.SIGSTOP;     --  stop (cannot be caught or ignored)
121 +
122 +   SIGTSTP : constant Interrupt_ID :=
123 +     System.OS_Interface.SIGTSTP;     --  user stop requested from tty
124 +
125 +   SIGCONT : constant Interrupt_ID :=
126 +     System.OS_Interface.SIGCONT;     --  stopped process has been continued
127 +
128 +   SIGCHLD : constant Interrupt_ID :=
129 +     System.OS_Interface.SIGCHLD;     --  4.3BSD's/POSIX name for SIGCLD
130 +
131 +   SIGCLD : constant Interrupt_ID :=
132 +     System.OS_Interface.SIGCLD;      --  child status change
133 +
134 +   SIGTTIN : constant Interrupt_ID :=
135 +     System.OS_Interface.SIGTTIN;     --  background tty read attempted
136 +
137 +   SIGTTOU : constant Interrupt_ID :=
138 +     System.OS_Interface.SIGTTOU;     --  background tty write attempted
139 +
140 +   SIGIO : constant Interrupt_ID :=   --  input/output possible,
141 +     System.OS_Interface.SIGIO;       --  SIGPOLL alias (Solaris)
142 +
143 +   SIGXCPU : constant Interrupt_ID :=
144 +     System.OS_Interface.SIGXCPU;     --  CPU time limit exceeded
145 +
146 +   SIGXFSZ : constant Interrupt_ID :=
147 +     System.OS_Interface.SIGXFSZ;     --  filesize limit exceeded
148 +
149 +   SIGVTALRM : constant Interrupt_ID :=
150 +     System.OS_Interface.SIGVTALRM;   --  virtual timer expired
151 +
152 +   SIGPROF : constant Interrupt_ID :=
153 +     System.OS_Interface.SIGPROF;     --  profiling timer expired
154 +
155 +   SIGWINCH : constant Interrupt_ID :=
156 +     System.OS_Interface.SIGWINCH;    --  window size change
157 +
158 +   SIGUSR1 : constant Interrupt_ID :=
159 +     System.OS_Interface.SIGUSR1;     --  user defined signal 1
160 +
161 +   SIGUSR2 : constant Interrupt_ID :=
162 +     System.OS_Interface.SIGUSR2;     --  user defined signal 2
163 +
164 +end Ada.Interrupts.Names;
165 --- /dev/null
166 +++ gcc/ada/a-intnam-netbsd.ads
167 @@ -0,0 +1,139 @@
168 +------------------------------------------------------------------------------
169 +--                                                                          --
170 +--                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
171 +--                                                                          --
172 +--                   A D A . I N T E R R U P T S . N A M E S                --
173 +--                                                                          --
174 +--                                  S p e c                                 --
175 +--                                                                          --
176 +--          Copyright (C) 1991-2011, Free Software Foundation, Inc.         --
177 +--                                                                          --
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.                                     --
184 +--                                                                          --
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.               --
188 +--                                                                          --
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/>.                                          --
193 +--                                                                          --
194 +-- GNARL was developed by the GNARL team at Florida State University.       --
195 +-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
196 +--                                                                          --
197 +------------------------------------------------------------------------------
198 +
199 +--  This is the NetBSD THREADS version of this package
200 +
201 +with System.OS_Interface;
202 +
203 +package Ada.Interrupts.Names is
204 +
205 +   --  All identifiers in this unit are implementation defined
206 +
207 +   pragma Implementation_Defined;
208 +
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.
212 +
213 +   SIGHUP : constant Interrupt_ID :=
214 +     System.OS_Interface.SIGHUP;      --  hangup
215 +
216 +   SIGINT : constant Interrupt_ID :=
217 +     System.OS_Interface.SIGINT;      --  interrupt (rubout)
218 +
219 +   SIGQUIT : constant Interrupt_ID :=
220 +     System.OS_Interface.SIGQUIT;     --  quit (ASCD FS)
221 +
222 +   SIGILL : constant Interrupt_ID :=
223 +     System.OS_Interface.SIGILL;      --  illegal instruction (not reset)
224 +
225 +   SIGTRAP : constant Interrupt_ID :=
226 +     System.OS_Interface.SIGTRAP;     --  trace trap (not reset)
227 +
228 +   SIGIOT : constant Interrupt_ID :=
229 +     System.OS_Interface.SIGIOT;      --  IOT instruction
230 +
231 +   SIGABRT : constant Interrupt_ID := --  used by abort,
232 +     System.OS_Interface.SIGABRT;     --  replace SIGIOT in the  future
233 +
234 +   SIGFPE : constant Interrupt_ID :=
235 +     System.OS_Interface.SIGFPE;      --  floating point exception
236 +
237 +   SIGKILL : constant Interrupt_ID :=
238 +     System.OS_Interface.SIGKILL;     --  kill (cannot be caught or ignored)
239 +
240 +   SIGBUS : constant Interrupt_ID :=
241 +     System.OS_Interface.SIGBUS;      --  bus error
242 +
243 +   SIGSEGV : constant Interrupt_ID :=
244 +     System.OS_Interface.SIGSEGV;     --  segmentation violation
245 +
246 +   SIGPIPE : constant Interrupt_ID := --  write on a pipe with
247 +     System.OS_Interface.SIGPIPE;     --  no one to read it
248 +
249 +   SIGALRM : constant Interrupt_ID :=
250 +     System.OS_Interface.SIGALRM;     --  alarm clock
251 +
252 +   SIGTERM : constant Interrupt_ID :=
253 +     System.OS_Interface.SIGTERM;     --  software termination signal from kill
254 +
255 +   SIGURG : constant Interrupt_ID :=
256 +     System.OS_Interface.SIGURG;      --  urgent condition on IO channel
257 +
258 +   SIGSTOP : constant Interrupt_ID :=
259 +     System.OS_Interface.SIGSTOP;     --  stop (cannot be caught or ignored)
260 +
261 +   SIGTSTP : constant Interrupt_ID :=
262 +     System.OS_Interface.SIGTSTP;     --  user stop requested from tty
263 +
264 +   SIGCONT : constant Interrupt_ID :=
265 +     System.OS_Interface.SIGCONT;     --  stopped process has been continued
266 +
267 +   SIGCHLD : constant Interrupt_ID :=
268 +     System.OS_Interface.SIGCHLD;     --  4.3BSD's/POSIX name for SIGCLD
269 +
270 +   SIGCLD : constant Interrupt_ID :=
271 +     System.OS_Interface.SIGCLD;      --  child status change
272 +
273 +   SIGTTIN : constant Interrupt_ID :=
274 +     System.OS_Interface.SIGTTIN;     --  background tty read attempted
275 +
276 +   SIGTTOU : constant Interrupt_ID :=
277 +     System.OS_Interface.SIGTTOU;     --  background tty write attempted
278 +
279 +   SIGIO : constant Interrupt_ID :=   --  input/output possible,
280 +     System.OS_Interface.SIGIO;       --  SIGPOLL alias (Solaris)
281 +
282 +   SIGXCPU : constant Interrupt_ID :=
283 +     System.OS_Interface.SIGXCPU;     --  CPU time limit exceeded
284 +
285 +   SIGXFSZ : constant Interrupt_ID :=
286 +     System.OS_Interface.SIGXFSZ;     --  filesize limit exceeded
287 +
288 +   SIGVTALRM : constant Interrupt_ID :=
289 +     System.OS_Interface.SIGVTALRM;   --  virtual timer expired
290 +
291 +   SIGPROF : constant Interrupt_ID :=
292 +     System.OS_Interface.SIGPROF;     --  profiling timer expired
293 +
294 +   SIGWINCH : constant Interrupt_ID :=
295 +     System.OS_Interface.SIGWINCH;    --  window size change
296 +
297 +   SIGUSR1 : constant Interrupt_ID :=
298 +     System.OS_Interface.SIGUSR1;     --  user defined signal 1
299 +
300 +   SIGUSR2 : constant Interrupt_ID :=
301 +     System.OS_Interface.SIGUSR2;     --  user defined signal 2
302 +
303 +   SIGPWR : constant Interrupt_ID :=
304 +     System.OS_Interface.SIGPWR;      --  power fail/restart
305 +
306 +end Ada.Interrupts.Names;
307 --- /dev/null
308 +++ gcc/ada/a-intnam-openbsd.ads
309 @@ -0,0 +1,136 @@
310 +------------------------------------------------------------------------------
311 +--                                                                          --
312 +--                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
313 +--                                                                          --
314 +--                   A D A . I N T E R R U P T S . N A M E S                --
315 +--                                                                          --
316 +--                                  S p e c                                 --
317 +--                                                                          --
318 +--          Copyright (C) 1991-2011, Free Software Foundation, Inc.         --
319 +--                                                                          --
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.                                     --
326 +--                                                                          --
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.               --
330 +--                                                                          --
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/>.                                          --
335 +--                                                                          --
336 +-- GNARL was developed by the GNARL team at Florida State University.       --
337 +-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
338 +--                                                                          --
339 +------------------------------------------------------------------------------
340 +
341 +--  This is the OpenBSD THREADS version of this package
342 +
343 +with System.OS_Interface;
344 +
345 +package Ada.Interrupts.Names is
346 +
347 +   --  All identifiers in this unit are implementation defined
348 +
349 +   pragma Implementation_Defined;
350 +
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.
354 +
355 +   SIGHUP : constant Interrupt_ID :=
356 +     System.OS_Interface.SIGHUP;      --  hangup
357 +
358 +   SIGINT : constant Interrupt_ID :=
359 +     System.OS_Interface.SIGINT;      --  interrupt (rubout)
360 +
361 +   SIGQUIT : constant Interrupt_ID :=
362 +     System.OS_Interface.SIGQUIT;     --  quit (ASCD FS)
363 +
364 +   SIGILL : constant Interrupt_ID :=
365 +     System.OS_Interface.SIGILL;      --  illegal instruction (not reset)
366 +
367 +   SIGTRAP : constant Interrupt_ID :=
368 +     System.OS_Interface.SIGTRAP;     --  trace trap (not reset)
369 +
370 +   SIGIOT : constant Interrupt_ID :=
371 +     System.OS_Interface.SIGIOT;      --  IOT instruction
372 +
373 +   SIGABRT : constant Interrupt_ID := --  used by abort,
374 +     System.OS_Interface.SIGABRT;     --  replace SIGIOT in the  future
375 +
376 +   SIGFPE : constant Interrupt_ID :=
377 +     System.OS_Interface.SIGFPE;      --  floating point exception
378 +
379 +   SIGKILL : constant Interrupt_ID :=
380 +     System.OS_Interface.SIGKILL;     --  kill (cannot be caught or ignored)
381 +
382 +   SIGBUS : constant Interrupt_ID :=
383 +     System.OS_Interface.SIGBUS;      --  bus error
384 +
385 +   SIGSEGV : constant Interrupt_ID :=
386 +     System.OS_Interface.SIGSEGV;     --  segmentation violation
387 +
388 +   SIGPIPE : constant Interrupt_ID := --  write on a pipe with
389 +     System.OS_Interface.SIGPIPE;     --  no one to read it
390 +
391 +   SIGALRM : constant Interrupt_ID :=
392 +     System.OS_Interface.SIGALRM;     --  alarm clock
393 +
394 +   SIGTERM : constant Interrupt_ID :=
395 +     System.OS_Interface.SIGTERM;     --  software termination signal from kill
396 +
397 +   SIGURG : constant Interrupt_ID :=
398 +     System.OS_Interface.SIGURG;      --  urgent condition on IO channel
399 +
400 +   SIGSTOP : constant Interrupt_ID :=
401 +     System.OS_Interface.SIGSTOP;     --  stop (cannot be caught or ignored)
402 +
403 +   SIGTSTP : constant Interrupt_ID :=
404 +     System.OS_Interface.SIGTSTP;     --  user stop requested from tty
405 +
406 +   SIGCONT : constant Interrupt_ID :=
407 +     System.OS_Interface.SIGCONT;     --  stopped process has been continued
408 +
409 +   SIGCHLD : constant Interrupt_ID :=
410 +     System.OS_Interface.SIGCHLD;     --  4.3BSD's/POSIX name for SIGCLD
411 +
412 +   SIGCLD : constant Interrupt_ID :=
413 +     System.OS_Interface.SIGCLD;      --  child status change
414 +
415 +   SIGTTIN : constant Interrupt_ID :=
416 +     System.OS_Interface.SIGTTIN;     --  background tty read attempted
417 +
418 +   SIGTTOU : constant Interrupt_ID :=
419 +     System.OS_Interface.SIGTTOU;     --  background tty write attempted
420 +
421 +   SIGIO : constant Interrupt_ID :=   --  input/output possible,
422 +     System.OS_Interface.SIGIO;       --  SIGPOLL alias (Solaris)
423 +
424 +   SIGXCPU : constant Interrupt_ID :=
425 +     System.OS_Interface.SIGXCPU;     --  CPU time limit exceeded
426 +
427 +   SIGXFSZ : constant Interrupt_ID :=
428 +     System.OS_Interface.SIGXFSZ;     --  filesize limit exceeded
429 +
430 +   SIGVTALRM : constant Interrupt_ID :=
431 +     System.OS_Interface.SIGVTALRM;   --  virtual timer expired
432 +
433 +   SIGPROF : constant Interrupt_ID :=
434 +     System.OS_Interface.SIGPROF;     --  profiling timer expired
435 +
436 +   SIGWINCH : constant Interrupt_ID :=
437 +     System.OS_Interface.SIGWINCH;    --  window size change
438 +
439 +   SIGUSR1 : constant Interrupt_ID :=
440 +     System.OS_Interface.SIGUSR1;     --  user defined signal 1
441 +
442 +   SIGUSR2 : constant Interrupt_ID :=
443 +     System.OS_Interface.SIGUSR2;     --  user defined signal 2
444 +
445 +end Ada.Interrupts.Names;
446 --- gcc/ada/adaint.c.orig
447 +++ gcc/ada/adaint.c
448 @@ -1077,6 +1077,7 @@
449    strcpy (path, "GNAT-XXXXXX");
450  
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 @@
457      free (pname);
458    }
459  
460 +#elif defined (__ANDROID__)
461 +
462 +  /*
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.
468 +   */
469 +
470 +  int testfd;
471 +  char *datadir = getenv ("ANDROID_DATA");
472 +
473 +  if (datadir == NULL)
474 +    strcpy (tmp_filename, "/data/local/tmp/gnat-XXXXXX");
475 +  else
476 +    sprintf (tmp_filename, "%s/local/tmp/gnat-XXXXXX", datadir);
477 +
478 +  testfd = mkstemp (tmp_filename);
479 +  if (testfd != -1)
480 +    {
481 +      close (testfd);
482 +      return;
483 +    }
484 +
485 +  char *sdcard = getenv ("EXTERNAL_STORAGE");
486 +
487 +  if (sdcard == NULL)
488 +    strcpy (tmp_filename, "/sdcard/gnat-XXXXXX");
489 +  else
490 +    sprintf (tmp_filename, "%s/gnat-XXXXXX", sdcard);
491 +
492 +  testfd = mkstemp (tmp_filename);
493 +  if (testfd != -1)
494 +    {
495 +      close (testfd);
496 +      return;
497 +    }
498 +
499 +  tmpnam (tmp_filename);
500 +
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 @@
507    int cores = 1;
508  
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);
514  
515 @@ -3530,26 +3575,214 @@
516  }
517  #endif
518  
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)))
534 -
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))
544 +
545 +/* The above platforms use the external program /usr/bin/addr2line */
546 +#define EXTERNAL_SYMTRACE
547 +
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))
561 +
562 +/* The above platforms use the system library libaddr2line.a */
563 +#define NATIVE_SYMTRACE
564 +#endif
565 +
566 +#if defined (EXTERNAL_SYMTRACE) && !defined (IS_CROSS)
567 +
568 +/*
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>
572 +
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:
580 +
581 +  The above copyright notice and this permission notice shall be included
582 +  in all copies or substantial portions of the Software.
583 +
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.
591 +
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
595 +  authorization.
596 +*/
597 +
598 +#include <sys/types.h>
599 +#include <stdlib.h>
600 +#include <unistd.h>
601 +#include <string.h>
602 +#include <signal.h>
603 +
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)
608 +
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]
614 +
615 +#if defined (__sun__)
616 +#define ADDR2LINE_PROG "/usr/gnu/bin/addr2line"
617 +#else
618 +#define ADDR2LINE_PROG "/usr/bin/addr2line"
619 +#endif
620 +
621 +void
622 +convert_addresses (const char *file_name,
623 +                  void *addrs,
624 +                  int   n_addr,
625 +                  void *buf,
626 +                  int  *len)
627 +{
628 +  int max_len = *len;
629 +  pid_t childpid;
630 +
631 +  struct sigaction act, oact;
632 +
633 +  int sendpipe[2] = {-1,-1},   /* parent -> child */
634 +      readpipe[2] = {-1,-1};   /* parent <- child */
635 +
636 +  *len = 0;
637 +  act.sa_handler = SIG_IGN;
638 +  sigemptyset(&act.sa_mask);
639 +  act.sa_flags = 0;
640 +  if (sigaction(SIGPIPE,&act,&oact) < 0)
641 +    return;
642 +
643 +  if (pipe(sendpipe) < 0) { RESTSIG; return; }
644 +  if (pipe(readpipe) < 0) { CLOSE_SENDPIPE; RESTSIG; return; }
645 +  if ((childpid = fork()) < 0) {
646 +    CLOSE_READPIPE;
647 +    CLOSE_SENDPIPE;
648 +    RESTSIG;
649 +    return;
650 +  }
651 +
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);
661 +      }
662 +      else if ((CHILD_READ == STDIN_FILENO) && (CHILD_WRITE > 1)) {
663 +        DUP2CLOSE (CHILD_WRITE, STDOUT_FILENO);
664 +      }
665 +      else if ((CHILD_READ > 1) && (CHILD_WRITE == STDOUT_FILENO)) {
666 +        DUP2CLOSE (CHILD_READ, STDIN_FILENO);
667 +      }
668 +      else if ((CHILD_READ > 1) && (CHILD_WRITE == STDIN_FILENO)) {
669 +        DUP2CLOSE (CHILD_WRITE, STDOUT_FILENO);
670 +        DUP2CLOSE (CHILD_READ,  STDIN_FILENO);
671 +      }
672 +      else {
673 +        /* CHILD_READ >= 1 and CHILD_WRITE > 1 */
674 +        DUP2CLOSE (CHILD_READ,  STDIN_FILENO);
675 +        DUP2CLOSE (CHILD_WRITE, STDOUT_FILENO);
676 +      }
677 +    }
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.
682 +    */
683 +    char *const argv[] = { "addr2line",
684 +                           "-e", file_name,
685 +                           "--demangle=gnat",
686 +                           "--functions",
687 +                           "--basenames",
688 +                           NULL };
689 +    char *const envp[] = { NULL };
690 +    if (execve(ADDR2LINE_PROG, argv, envp) < 0) {
691 +      close (CHILD_WRITE);
692 +      close (CHILD_READ);
693 +      RESTSIG;
694 +      exit (1);
695 +    }
696 +  }
697 +
698 +  /* Below this line is parent process */
699 +  int i, n;
700 +  char hex[16];
701 +  char line[MAX_LINE + 1];
702 +  char *p;
703 +  char *s = buf;
704 +  long *trace_address = addrs;
705 +
706 +  close(CHILD_WRITE);
707 +  close(CHILD_READ);
708 +
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);
713 +    if (n<=0)
714 +      break;
715 +
716 +    line[n]=0;
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)
720 +      break;
721 +
722 +    p = strchr(line,'\n');
723 +    if (p) {
724 +      if (*(p+1)) {
725 +        *p = 0;
726 +        *len += snprintf(s, (max_len - (*len)), "%#lx in %s at %s",
727 +                         *trace_address, line, p+1);
728 +      }
729 +      else {
730 +        *len += snprintf(s, (max_len - (*len)), "%#lx at %s",
731 +                         *trace_address, line);
732 +      }
733 +      s = buf + (*len);
734 +    }
735 +    trace_address += 1;
736 +  }
737 +  close (PARENT_WRITE);
738 +  close (PARENT_READ);
739 +  RESTSIG;
740 +}
741 +
742 +#elif defined (IS_CROSS) || !defined (NATIVE_SYMTRACE)
743  
744 +/* run-time symbolic traceback support
745 +   Dummy function to satisfy g-trasym.o. */
746  void
747  convert_addresses (const char *file_name ATTRIBUTE_UNUSED,
748                    void *addrs ATTRIBUTE_UNUSED,
749 --- gcc/ada/cio.c.orig
750 +++ gcc/ada/cio.c
751 @@ -46,7 +46,8 @@
752  
753  /* Don't use macros on GNU/Linux since they cause incompatible changes between
754     glibc 2.0 and 2.1 */
755 -#ifdef linux
756 +/* Android is The exception because it uses the BIONIC library */
757 +#if defined(linux) && !defined(__ANDROID__)
758  #undef putchar
759  #undef getchar
760  #undef fputc
761 --- gcc/ada/cstreams.c.orig
762 +++ gcc/ada/cstreams.c
763 @@ -54,9 +54,10 @@
764  #include <unixlib.h>
765  #endif
766  
767 -#ifdef linux
768 +#if defined(linux) && !defined(__ANDROID__)
769  /* Don't use macros on GNU/Linux since they cause incompatible changes between
770     glibc 2.0 and 2.1 */
771 +/* Android is The exception because it uses the BIONIC library */
772  
773  #ifdef stderr
774  #  undef stderr
775 @@ -187,7 +188,10 @@
776           *p = '\\';
777      }
778  
779 -#elif defined (sgi) || defined (__FreeBSD__)
780 +#elif defined (sgi) \
781 +  || defined (__FreeBSD__) \
782 +  || defined (__DragonFly__) \
783 +  || defined (__OpenBSD__)
784  
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
788 +++ gcc/ada/env.c
789 @@ -188,7 +188,9 @@
790        LIB$SIGNAL (status);
791    }
792  
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);
798  
799  #else
800 @@ -310,6 +312,7 @@
801    }
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
809 +++ gcc/ada/errno.c
810 @@ -39,6 +39,7 @@
811  #define _REENTRANT
812  #define _THREAD_SAFE
813  #define _SGI_MP_SOURCE
814 +#define GNAT_SET_ERRNO
815  
816  #ifdef MaRTE
817  
818 @@ -52,6 +53,17 @@
819  
820  #endif
821  
822 +#ifdef __ANDROID__
823 +
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. */
828 +
829 +#undef GNAT_SET_ERRNO   
830 +#endif
831 +
832 +
833  #include <errno.h>
834  int
835  __get_errno(void)
836 @@ -59,8 +71,10 @@
837    return errno;
838  }
839  
840 +#ifdef GNAT_SET_ERRNO
841  void
842  __set_errno(int err)
843  {
844    errno = err;
845  }
846 +#endif
847 --- gcc/ada/g-comlin.adb.orig
848 +++ gcc/ada/g-comlin.adb
849 @@ -514,6 +514,7 @@
850     begin
851        Index_In_Switches := 0;
852        Switch_Length     := 0;
853 +      Param             := Parameter_None;
854  
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 @@
860  
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.
865  
866 -      --  Restore the old descriptors
867 +      if No_Fork_On_Target then
868  
869 -      Dup2 (Input,  GNAT.OS_Lib.Standin);
870 -      Dup2 (Output, GNAT.OS_Lib.Standout);
871 -      Dup2 (Error,  GNAT.OS_Lib.Standerr);
872 -      Close (Input);
873 -      Close (Output);
874 -      Close (Error);
875 +         --  Restore the old descriptors
876 +
877 +         Dup2 (Input,  GNAT.OS_Lib.Standin);
878 +         Dup2 (Output, GNAT.OS_Lib.Standout);
879 +         Dup2 (Error,  GNAT.OS_Lib.Standerr);
880 +         Close (Input);
881 +         Close (Output);
882 +         Close (Error);
883 +      end if;
884     end Set_Up_Child_Communications;
885  
886     ---------------------------
887 --- /dev/null
888 +++ gcc/ada/g-socthi-bsd.adb
889 @@ -0,0 +1,376 @@
890 +------------------------------------------------------------------------------
891 +--                                                                          --
892 +--                         GNAT COMPILER COMPONENTS                         --
893 +--                                                                          --
894 +--                    G N A T . S O C K E T S . T H I N                     --
895 +--                                                                          --
896 +--                                 B o d y                                  --
897 +--                                                                          --
898 +--                     Copyright (C) 2001-2010, AdaCore                     --
899 +--                                                                          --
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.                                     --
906 +--                                                                          --
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.               --
910 +--                                                                          --
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/>.                                          --
915 +--                                                                          --
916 +-- GNAT was originally developed  by the GNAT team at  New York University. --
917 +-- Extensive contributions were provided by Ada Core Technologies Inc.      --
918 +--                                                                          --
919 +------------------------------------------------------------------------------
920 +
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.
924 +
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
928 +--  one it replaces.
929 +
930 +with GNAT.OS_Lib; use GNAT.OS_Lib;
931 +
932 +with Interfaces.C; use Interfaces.C;
933 +
934 +package body GNAT.Sockets.Thin is
935 +
936 +   Unknown_System_Error : constant C.Strings.chars_ptr :=
937 +                            C.Strings.New_String ("Unknown system error");
938 +
939 +   function Syscall_Accept
940 +     (S       : C.int;
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.
947 +
948 +   function Syscall_Connect
949 +     (S       : C.int;
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.
958 +
959 +   function Syscall_Recv
960 +     (S     : C.int;
961 +      Msg   : System.Address;
962 +      Len   : C.int;
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.
970 +
971 +   function Syscall_Recvfrom
972 +     (S       : C.int;
973 +      Msg     : System.Address;
974 +      Len     : C.int;
975 +      Flags   : C.int;
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.
985 +
986 +   function Syscall_Recvmsg
987 +     (S     : C.int;
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.
996 +
997 +   function Syscall_Sendmsg
998 +     (S     : C.int;
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).
1006 +
1007 +   function Syscall_Sendto
1008 +     (S     : C.int;
1009 +      Msg   : System.Address;
1010 +      Len   : C.int;
1011 +      Flags : C.int;
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.
1018 +
1019 +   function Syscall_Socket
1020 +     (Domain   : C.int;
1021 +      Typ      : C.int;
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.
1027 +
1028 +   procedure Disable_SIGPIPE (S : C.int);
1029 +   pragma Import (C, Disable_SIGPIPE, "__gnat_disable_sigpipe");
1030 +
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.
1035 +
1036 +   function C_Fcntl
1037 +     (Fd  : C.int;
1038 +      Cmd : C.int;
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.
1043 +
1044 +   --------------
1045 +   -- C_Accept --
1046 +   --------------
1047 +
1048 +   function C_Accept
1049 +     (S       : C.int;
1050 +      Addr    : System.Address;
1051 +      Addrlen : not null access C.int) return C.int
1052 +   is
1053 +      Res : constant C.int := Syscall_Accept (S, Addr, Addrlen);
1054 +   begin
1055 +
1056 +      Disable_SIGPIPE (Res);
1057 +      return Res;
1058 +
1059 +   end C_Accept;
1060 +
1061 +   ---------------
1062 +   -- C_Connect --
1063 +   ---------------
1064 +
1065 +   function C_Connect
1066 +     (S       : C.int;
1067 +      Name    : System.Address;
1068 +      Namelen : C.int) return C.int
1069 +   is
1070 +   begin
1071 +
1072 +      return Syscall_Connect (S, Name, Namelen);
1073 +
1074 +   end C_Connect;
1075 +
1076 +   ------------------
1077 +   -- Socket_Ioctl --
1078 +   ------------------
1079 +
1080 +   function Socket_Ioctl
1081 +     (S   : C.int;
1082 +      Req : C.int;
1083 +      Arg : access C.int) return C.int
1084 +   is
1085 +      --  Currently all requests are of the FIONBIO type, so always calc flags
1086 +      use Interfaces;
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;
1091 +      newval   : C.int;
1092 +   begin
1093 +      if Req = SOSC.FIONBIO then
1094 +         if enabled then
1095 +            newval := C.int (flags or nonblock);
1096 +         elsif (flags and nonblock) > 0 then
1097 +            newval := C.int (flags - nonblock);
1098 +         else
1099 +            newval := C.int (flags);
1100 +         end if;
1101 +         return C_Fcntl (Fd => S, Cmd => SOSC.F_SETFL, Val => newval);
1102 +      else
1103 +         return C_Ioctl (Fd => S, Req => Req, Arg => Arg);
1104 +      end if;
1105 +   end Socket_Ioctl;
1106 +
1107 +   ------------
1108 +   -- C_Recv --
1109 +   ------------
1110 +
1111 +   function C_Recv
1112 +     (S     : C.int;
1113 +      Msg   : System.Address;
1114 +      Len   : C.int;
1115 +      Flags : C.int) return C.int
1116 +   is
1117 +   begin
1118 +
1119 +      return Syscall_Recv (S, Msg, Len, Flags);
1120 +
1121 +   end C_Recv;
1122 +
1123 +   ----------------
1124 +   -- C_Recvfrom --
1125 +   ----------------
1126 +
1127 +   function C_Recvfrom
1128 +     (S       : C.int;
1129 +      Msg     : System.Address;
1130 +      Len     : C.int;
1131 +      Flags   : C.int;
1132 +      From    : System.Address;
1133 +      Fromlen : not null access C.int) return C.int
1134 +   is
1135 +   begin
1136 +
1137 +      return Syscall_Recvfrom (S, Msg, Len, Flags, From, Fromlen);
1138 +
1139 +   end C_Recvfrom;
1140 +
1141 +   ---------------
1142 +   -- C_Recvmsg --
1143 +   ---------------
1144 +
1145 +   function C_Recvmsg
1146 +     (S     : C.int;
1147 +      Msg   : System.Address;
1148 +      Flags : C.int) return System.CRTL.ssize_t
1149 +   is
1150 +   begin
1151 +
1152 +      return  Syscall_Recvmsg (S, Msg, Flags);
1153 +
1154 +   end C_Recvmsg;
1155 +
1156 +   ---------------
1157 +   -- C_Sendmsg --
1158 +   ---------------
1159 +
1160 +   function C_Sendmsg
1161 +     (S     : C.int;
1162 +      Msg   : System.Address;
1163 +      Flags : C.int) return System.CRTL.ssize_t
1164 +   is
1165 +   begin
1166 +
1167 +      return Syscall_Sendmsg (S, Msg, Flags);
1168 +
1169 +   end C_Sendmsg;
1170 +
1171 +   --------------
1172 +   -- C_Sendto --
1173 +   --------------
1174 +
1175 +   function C_Sendto
1176 +     (S     : C.int;
1177 +      Msg   : System.Address;
1178 +      Len   : C.int;
1179 +      Flags : C.int;
1180 +      To    : System.Address;
1181 +      Tolen : C.int) return C.int
1182 +   is
1183 +   begin
1184 +
1185 +      return Syscall_Sendto (S, Msg, Len, Flags, To, Tolen);
1186 +
1187 +   end C_Sendto;
1188 +
1189 +   --------------
1190 +   -- C_Socket --
1191 +   --------------
1192 +
1193 +   function C_Socket
1194 +     (Domain   : C.int;
1195 +      Typ      : C.int;
1196 +      Protocol : C.int) return C.int
1197 +   is
1198 +      Res : constant C.int := Syscall_Socket (Domain, Typ, Protocol);
1199 +   begin
1200 +
1201 +      Disable_SIGPIPE (Res);
1202 +      return Res;
1203 +
1204 +   end C_Socket;
1205 +
1206 +   --------------
1207 +   -- Finalize --
1208 +   --------------
1209 +
1210 +   procedure Finalize is
1211 +   begin
1212 +      null;
1213 +   end Finalize;
1214 +
1215 +   -------------------------
1216 +   -- Host_Error_Messages --
1217 +   -------------------------
1218 +
1219 +   package body Host_Error_Messages is separate;
1220 +
1221 +   ----------------
1222 +   -- Initialize --
1223 +   ----------------
1224 +
1225 +   procedure Initialize is
1226 +   begin
1227 +      Disable_All_SIGPIPEs;
1228 +   end Initialize;
1229 +
1230 +   --------------------
1231 +   -- Signalling_Fds --
1232 +   --------------------
1233 +
1234 +   package body Signalling_Fds is
1235 +
1236 +      --  In this default implementation, we use a C version of these
1237 +      --  subprograms provided by socket.c.
1238 +
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);
1243 +
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");
1248 +
1249 +      function Create
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;
1254 +
1255 +   end Signalling_Fds;
1256 +
1257 +   --------------------------
1258 +   -- Socket_Error_Message --
1259 +   --------------------------
1260 +
1261 +   function Socket_Error_Message
1262 +     (Errno : Integer) return C.Strings.chars_ptr
1263 +   is separate;
1264 +
1265 +end GNAT.Sockets.Thin;
1266 --- /dev/null
1267 +++ gcc/ada/g-socthi-netbsd.adb
1268 @@ -0,0 +1,378 @@
1269 +------------------------------------------------------------------------------
1270 +--                                                                          --
1271 +--                         GNAT COMPILER COMPONENTS                         --
1272 +--                                                                          --
1273 +--                    G N A T . S O C K E T S . T H I N                     --
1274 +--                                                                          --
1275 +--                                 B o d y                                  --
1276 +--                                                                          --
1277 +--                     Copyright (C) 2001-2010, AdaCore                     --
1278 +--                                                                          --
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.                                     --
1285 +--                                                                          --
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.               --
1289 +--                                                                          --
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/>.                                          --
1294 +--                                                                          --
1295 +-- GNAT was originally developed  by the GNAT team at  New York University. --
1296 +-- Extensive contributions were provided by Ada Core Technologies Inc.      --
1297 +--                                                                          --
1298 +------------------------------------------------------------------------------
1299 +
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.
1303 +
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.
1310 +
1311 +with GNAT.OS_Lib; use GNAT.OS_Lib;
1312 +
1313 +with Interfaces.C; use Interfaces.C;
1314 +
1315 +package body GNAT.Sockets.Thin is
1316 +
1317 +   Unknown_System_Error : constant C.Strings.chars_ptr :=
1318 +                            C.Strings.New_String ("Unknown system error");
1319 +
1320 +   function Syscall_Accept
1321 +     (S       : C.int;
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.
1328 +
1329 +   function Syscall_Connect
1330 +     (S       : C.int;
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.
1339 +
1340 +   function Syscall_Recv
1341 +     (S     : C.int;
1342 +      Msg   : System.Address;
1343 +      Len   : C.int;
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.
1351 +
1352 +   function Syscall_Recvfrom
1353 +     (S       : C.int;
1354 +      Msg     : System.Address;
1355 +      Len     : C.int;
1356 +      Flags   : C.int;
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.
1366 +
1367 +   function Syscall_Recvmsg
1368 +     (S     : C.int;
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.
1377 +
1378 +   function Syscall_Sendmsg
1379 +     (S     : C.int;
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).
1387 +
1388 +   function Syscall_Sendto
1389 +     (S     : C.int;
1390 +      Msg   : System.Address;
1391 +      Len   : C.int;
1392 +      Flags : C.int;
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.
1399 +
1400 +   function Syscall_Socket
1401 +     (Domain   : C.int;
1402 +      Typ      : C.int;
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.
1408 +
1409 +   procedure Disable_SIGPIPE (S : C.int);
1410 +   pragma Import (C, Disable_SIGPIPE, "__gnat_disable_sigpipe");
1411 +
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.
1416 +
1417 +   function C_Fcntl
1418 +     (Fd  : C.int;
1419 +      Cmd : C.int;
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.
1424 +
1425 +   --------------
1426 +   -- C_Accept --
1427 +   --------------
1428 +
1429 +   function C_Accept
1430 +     (S       : C.int;
1431 +      Addr    : System.Address;
1432 +      Addrlen : not null access C.int) return C.int
1433 +   is
1434 +      Res : constant C.int := Syscall_Accept (S, Addr, Addrlen);
1435 +   begin
1436 +
1437 +      Disable_SIGPIPE (Res);
1438 +      return Res;
1439 +
1440 +   end C_Accept;
1441 +
1442 +   ---------------
1443 +   -- C_Connect --
1444 +   ---------------
1445 +
1446 +   function C_Connect
1447 +     (S       : C.int;
1448 +      Name    : System.Address;
1449 +      Namelen : C.int) return C.int
1450 +   is
1451 +   begin
1452 +
1453 +      return Syscall_Connect (S, Name, Namelen);
1454 +
1455 +   end C_Connect;
1456 +
1457 +   ------------------
1458 +   -- Socket_Ioctl --
1459 +   ------------------
1460 +
1461 +   function Socket_Ioctl
1462 +     (S   : C.int;
1463 +      Req : C.int;
1464 +      Arg : access C.int) return C.int
1465 +   is
1466 +      --  Currently all requests are of the FIONBIO type, so always calc flags
1467 +      use Interfaces;
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;
1472 +      newval   : C.int;
1473 +   begin
1474 +      if Req = SOSC.FIONBIO then
1475 +         if enabled then
1476 +            newval := C.int (flags or nonblock);
1477 +         elsif (flags and nonblock) > 0 then
1478 +            newval := C.int (flags - nonblock);
1479 +         else
1480 +            newval := C.int (flags);
1481 +         end if;
1482 +         return C_Fcntl (Fd => S, Cmd => SOSC.F_SETFL, Val => newval);
1483 +      else
1484 +         return C_Ioctl (Fd => S, Req => Req, Arg => Arg);
1485 +      end if;
1486 +   end Socket_Ioctl;
1487 +
1488 +   ------------
1489 +   -- C_Recv --
1490 +   ------------
1491 +
1492 +   function C_Recv
1493 +     (S     : C.int;
1494 +      Msg   : System.Address;
1495 +      Len   : C.int;
1496 +      Flags : C.int) return C.int
1497 +   is
1498 +   begin
1499 +
1500 +      return Syscall_Recv (S, Msg, Len, Flags);
1501 +
1502 +   end C_Recv;
1503 +
1504 +   ----------------
1505 +   -- C_Recvfrom --
1506 +   ----------------
1507 +
1508 +   function C_Recvfrom
1509 +     (S       : C.int;
1510 +      Msg     : System.Address;
1511 +      Len     : C.int;
1512 +      Flags   : C.int;
1513 +      From    : System.Address;
1514 +      Fromlen : not null access C.int) return C.int
1515 +   is
1516 +   begin
1517 +
1518 +      return Syscall_Recvfrom (S, Msg, Len, Flags, From, Fromlen);
1519 +
1520 +   end C_Recvfrom;
1521 +
1522 +   ---------------
1523 +   -- C_Recvmsg --
1524 +   ---------------
1525 +
1526 +   function C_Recvmsg
1527 +     (S     : C.int;
1528 +      Msg   : System.Address;
1529 +      Flags : C.int) return System.CRTL.ssize_t
1530 +   is
1531 +   begin
1532 +
1533 +      return  Syscall_Recvmsg (S, Msg, Flags);
1534 +
1535 +   end C_Recvmsg;
1536 +
1537 +   ---------------
1538 +   -- C_Sendmsg --
1539 +   ---------------
1540 +
1541 +   function C_Sendmsg
1542 +     (S     : C.int;
1543 +      Msg   : System.Address;
1544 +      Flags : C.int) return System.CRTL.ssize_t
1545 +   is
1546 +   begin
1547 +
1548 +      return Syscall_Sendmsg (S, Msg, Flags);
1549 +
1550 +   end C_Sendmsg;
1551 +
1552 +   --------------
1553 +   -- C_Sendto --
1554 +   --------------
1555 +
1556 +   function C_Sendto
1557 +     (S     : C.int;
1558 +      Msg   : System.Address;
1559 +      Len   : C.int;
1560 +      Flags : C.int;
1561 +      To    : System.Address;
1562 +      Tolen : C.int) return C.int
1563 +   is
1564 +   begin
1565 +
1566 +      return Syscall_Sendto (S, Msg, Len, Flags, To, Tolen);
1567 +
1568 +   end C_Sendto;
1569 +
1570 +   --------------
1571 +   -- C_Socket --
1572 +   --------------
1573 +
1574 +   function C_Socket
1575 +     (Domain   : C.int;
1576 +      Typ      : C.int;
1577 +      Protocol : C.int) return C.int
1578 +   is
1579 +      Res : constant C.int := Syscall_Socket (Domain, Typ, Protocol);
1580 +   begin
1581 +
1582 +      Disable_SIGPIPE (Res);
1583 +      return Res;
1584 +
1585 +   end C_Socket;
1586 +
1587 +   --------------
1588 +   -- Finalize --
1589 +   --------------
1590 +
1591 +   procedure Finalize is
1592 +   begin
1593 +      null;
1594 +   end Finalize;
1595 +
1596 +   -------------------------
1597 +   -- Host_Error_Messages --
1598 +   -------------------------
1599 +
1600 +   package body Host_Error_Messages is separate;
1601 +
1602 +   ----------------
1603 +   -- Initialize --
1604 +   ----------------
1605 +
1606 +   procedure Initialize is
1607 +   begin
1608 +      Disable_All_SIGPIPEs;
1609 +   end Initialize;
1610 +
1611 +   --------------------
1612 +   -- Signalling_Fds --
1613 +   --------------------
1614 +
1615 +   package body Signalling_Fds is
1616 +
1617 +      --  In this default implementation, we use a C version of these
1618 +      --  subprograms provided by socket.c.
1619 +
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);
1624 +
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");
1629 +
1630 +      function Create
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;
1635 +
1636 +   end Signalling_Fds;
1637 +
1638 +   --------------------------
1639 +   -- Socket_Error_Message --
1640 +   --------------------------
1641 +
1642 +   function Socket_Error_Message
1643 +     (Errno : Integer) return C.Strings.chars_ptr
1644 +   is separate;
1645 +
1646 +end GNAT.Sockets.Thin;
1647 --- /dev/null
1648 +++ gcc/ada/g-socthi-netbsd6.ads
1649 @@ -0,0 +1,260 @@
1650 +------------------------------------------------------------------------------
1651 +--                                                                          --
1652 +--                         GNAT COMPILER COMPONENTS                         --
1653 +--                                                                          --
1654 +--                    G N A T . S O C K E T S . T H I N                     --
1655 +--                                                                          --
1656 +--                                 S p e c                                  --
1657 +--                                                                          --
1658 +--                     Copyright (C) 2001-2010, AdaCore                     --
1659 +--                                                                          --
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.                                     --
1666 +--                                                                          --
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.               --
1670 +--                                                                          --
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/>.                                          --
1675 +--                                                                          --
1676 +-- GNAT was originally developed  by the GNAT team at  New York University. --
1677 +-- Extensive contributions were provided by Ada Core Technologies Inc.      --
1678 +--                                                                          --
1679 +------------------------------------------------------------------------------
1680 +
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.
1684 +
1685 +--  This is the NetBSD 6+ version
1686 +
1687 +with Interfaces.C.Strings;
1688 +
1689 +with GNAT.OS_Lib;
1690 +with GNAT.Sockets.Thin_Common;
1691 +
1692 +with System;
1693 +with System.CRTL;
1694 +
1695 +package GNAT.Sockets.Thin is
1696 +
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.
1700 +
1701 +   use Thin_Common;
1702 +
1703 +   package C renames Interfaces.C;
1704 +
1705 +   use type System.CRTL.ssize_t;
1706 +
1707 +   function Socket_Errno return Integer renames GNAT.OS_Lib.Errno;
1708 +   --  Returns last socket error number
1709 +
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".
1713 +
1714 +   function Host_Errno return Integer;
1715 +   pragma Import (C, Host_Errno, "__gnat_get_h_errno");
1716 +   --  Returns last host error number
1717 +
1718 +   package Host_Error_Messages is
1719 +
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".
1724 +
1725 +   end Host_Error_Messages;
1726 +
1727 +   --------------------------------
1728 +   -- Standard library functions --
1729 +   --------------------------------
1730 +
1731 +   function C_Accept
1732 +     (S       : C.int;
1733 +      Addr    : System.Address;
1734 +      Addrlen : not null access C.int) return C.int;
1735 +
1736 +   function C_Bind
1737 +     (S       : C.int;
1738 +      Name    : System.Address;
1739 +      Namelen : C.int) return C.int;
1740 +
1741 +   function C_Close
1742 +     (Fd : C.int) return C.int;
1743 +
1744 +   function C_Connect
1745 +     (S       : C.int;
1746 +      Name    : System.Address;
1747 +      Namelen : C.int) return C.int;
1748 +
1749 +   function C_Gethostname
1750 +     (Name    : System.Address;
1751 +      Namelen : C.int) return C.int;
1752 +
1753 +   function C_Getpeername
1754 +     (S       : C.int;
1755 +      Name    : System.Address;
1756 +      Namelen : not null access C.int) return C.int;
1757 +
1758 +   function C_Getsockname
1759 +     (S       : C.int;
1760 +      Name    : System.Address;
1761 +      Namelen : not null access C.int) return C.int;
1762 +
1763 +   function C_Getsockopt
1764 +     (S       : C.int;
1765 +      Level   : C.int;
1766 +      Optname : C.int;
1767 +      Optval  : System.Address;
1768 +      Optlen  : not null access C.int) return C.int;
1769 +
1770 +   function Socket_Ioctl
1771 +     (S   : C.int;
1772 +      Req : C.int;
1773 +      Arg : access C.int) return C.int;
1774 +
1775 +   function C_Listen
1776 +     (S       : C.int;
1777 +      Backlog : C.int) return C.int;
1778 +
1779 +   function C_Recv
1780 +     (S     : C.int;
1781 +      Msg   : System.Address;
1782 +      Len   : C.int;
1783 +      Flags : C.int) return C.int;
1784 +
1785 +   function C_Recvfrom
1786 +     (S       : C.int;
1787 +      Msg     : System.Address;
1788 +      Len     : C.int;
1789 +      Flags   : C.int;
1790 +      From    : System.Address;
1791 +      Fromlen : not null access C.int) return C.int;
1792 +
1793 +   function C_Recvmsg
1794 +     (S     : C.int;
1795 +      Msg   : System.Address;
1796 +      Flags : C.int) return System.CRTL.ssize_t;
1797 +
1798 +   function C_Select
1799 +     (Nfds      : C.int;
1800 +      Readfds   : access Fd_Set;
1801 +      Writefds  : access Fd_Set;
1802 +      Exceptfds : access Fd_Set;
1803 +      Timeout   : Timeval_Access) return C.int;
1804 +
1805 +   function C_Sendmsg
1806 +     (S     : C.int;
1807 +      Msg   : System.Address;
1808 +      Flags : C.int) return System.CRTL.ssize_t;
1809 +
1810 +   function C_Sendto
1811 +     (S     : C.int;
1812 +      Msg   : System.Address;
1813 +      Len   : C.int;
1814 +      Flags : C.int;
1815 +      To    : System.Address;
1816 +      Tolen : C.int) return C.int;
1817 +
1818 +   function C_Setsockopt
1819 +     (S       : C.int;
1820 +      Level   : C.int;
1821 +      Optname : C.int;
1822 +      Optval  : System.Address;
1823 +      Optlen  : C.int) return C.int;
1824 +
1825 +   function C_Shutdown
1826 +     (S   : C.int;
1827 +      How : C.int) return C.int;
1828 +
1829 +   function C_Socket
1830 +     (Domain   : C.int;
1831 +      Typ      : C.int;
1832 +      Protocol : C.int) return C.int;
1833 +
1834 +   function C_System
1835 +     (Command : System.Address) return C.int;
1836 +
1837 +   -------------------------------------------------------
1838 +   -- Signalling file descriptors for selector abortion --
1839 +   -------------------------------------------------------
1840 +
1841 +   package Signalling_Fds is
1842 +
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).
1847 +
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.
1852 +
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.
1857 +
1858 +      procedure Close (Sig : C.int);
1859 +      pragma Convention (C, Close);
1860 +      --  Close one end of a pair of signalling fds (ignoring any error)
1861 +
1862 +   end Signalling_Fds;
1863 +
1864 +   -------------------------------------------
1865 +   -- Nonreentrant network databases access --
1866 +   -------------------------------------------
1867 +
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.
1871 +
1872 +   function Nonreentrant_Gethostbyname
1873 +     (Name : C.char_array) return Hostent_Access;
1874 +
1875 +   function Nonreentrant_Gethostbyaddr
1876 +     (Addr      : System.Address;
1877 +      Addr_Len  : C.int;
1878 +      Addr_Type : C.int) return Hostent_Access;
1879 +
1880 +   function Nonreentrant_Getservbyname
1881 +     (Name  : C.char_array;
1882 +      Proto : C.char_array) return Servent_Access;
1883 +
1884 +   function Nonreentrant_Getservbyport
1885 +     (Port  : C.int;
1886 +      Proto : C.char_array) return Servent_Access;
1887 +
1888 +   procedure Initialize;
1889 +   procedure Finalize;
1890 +
1891 +private
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");
1903 +
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");
1908 +
1909 +end GNAT.Sockets.Thin;
1910 --- /dev/null
1911 +++ gcc/ada/g-trasym-bsd.adb
1912 @@ -0,0 +1,150 @@
1913 +------------------------------------------------------------------------------
1914 +--                                                                          --
1915 +--                         GNAT RUN-TIME COMPONENTS                         --
1916 +--                                                                          --
1917 +--             G N A T . T R A C E B A C K . S Y M B O L I C                --
1918 +--                                                                          --
1919 +--                                 B o d y                                  --
1920 +--                                                                          --
1921 +--                     Copyright (C) 1999-2009, AdaCore                     --
1922 +--                                                                          --
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.                                              --
1933 +--                                                                          --
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.                                      --
1940 +--                                                                          --
1941 +-- GNAT was originally developed  by the GNAT team at  New York University. --
1942 +-- Extensive contributions were provided by Ada Core Technologies Inc.      --
1943 +--                                                                          --
1944 +------------------------------------------------------------------------------
1945 +
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>
1950 +
1951 +with System.Soft_Links;
1952 +with Ada.Exceptions.Traceback; use Ada.Exceptions.Traceback;
1953 +
1954 +package body GNAT.Traceback.Symbolic is
1955 +
1956 +   package TSL renames System.Soft_Links;
1957 +
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
1963 +   --  result.
1964 +
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.
1968 +
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.
1974 +
1975 +   ------------------------
1976 +   -- Symbolic_Traceback --
1977 +   ------------------------
1978 +
1979 +   function Symbolic_Traceback (Traceback : Tracebacks_Array) return String is
1980 +
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.
1993 +      --
1994 +      --  Note that this procedure is *not* thread-safe.
1995 +
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");
1999 +
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");
2003 +
2004 +      B_Size : constant Integer := 256 * Traceback'Length;
2005 +      Len    : Integer := B_Size;
2006 +      Res    : String (1 .. B_Size);
2007 +
2008 +      use type System.Address;
2009 +
2010 +   begin
2011 +      --  The symbolic translation of an empty set of addresses is an empty
2012 +      --  string.
2013 +
2014 +      if Traceback'Length = 0 then
2015 +         return "";
2016 +      end if;
2017 +
2018 +      --  If our input set of raw addresses is not empty, resort to the
2019 +      --  libaddr2line service to symbolize it all.
2020 +
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.
2025 +
2026 +      --  Protect all this against concurrent accesses explicitly, as the
2027 +      --  underlying services are potentially thread unsafe.
2028 +
2029 +      TSL.Lock_Task.all;
2030 +
2031 +      if not Exename_Resolved then
2032 +         Exename := locate_exec_on_path (gnat_argv (0));
2033 +         Exename_Resolved := True;
2034 +      end if;
2035 +
2036 +      if Exename /= System.Null_Address then
2037 +         Len := Res'Length;
2038 +         convert_addresses
2039 +           (Exename, Traceback'Address, Traceback'Length,
2040 +            Res (1)'Address, Len'Address);
2041 +      end if;
2042 +
2043 +      TSL.Unlock_Task.all;
2044 +
2045 +      --  Return what the addr2line symbolizer has produced if we have called
2046 +      --  it (the executable name resolution succeeded), or an empty string
2047 +      --  otherwise.
2048 +
2049 +      if Exename /= System.Null_Address then
2050 +         return Res (1 .. Len);
2051 +      else
2052 +         return "";
2053 +      end if;
2054 +
2055 +   end Symbolic_Traceback;
2056 +
2057 +   function Symbolic_Traceback (E : Exception_Occurrence) return String is
2058 +   begin
2059 +      return Symbolic_Traceback (Tracebacks (E));
2060 +   end Symbolic_Traceback;
2061 +
2062 +end GNAT.Traceback.Symbolic;
2063 --- gcc/ada/gnatchop.adb.orig
2064 +++ gcc/ada/gnatchop.adb
2065 @@ -45,7 +45,7 @@
2066     Config_File_Name : constant String_Access := new String'("gnat.adc");
2067     --  The name of the file holding the GNAT configuration pragmas
2068  
2069 -   Gcc : String_Access := new String'("gcc");
2070 +   Gcc : String_Access := new String'("ada");
2071     --  May be modified by switch --GCC=
2072  
2073     Gcc_Set : Boolean := False;
2074 --- gcc/ada/gnatlink.adb.orig
2075 +++ gcc/ada/gnatlink.adb
2076 @@ -137,7 +137,7 @@
2077     --  This table collects the arguments to be passed to compile the binder
2078     --  generated file.
2079  
2080 -   Gcc : String_Access := Program_Name ("gcc", "gnatlink");
2081 +   Gcc : String_Access := Program_Name ("ada", "gnatlink");
2082  
2083     Read_Mode : constant String := "r" & ASCII.NUL;
2084  
2085 --- gcc/ada/gsocket.h.orig
2086 +++ gcc/ada/gsocket.h
2087 @@ -203,8 +203,19 @@
2088  #include <netdb.h>
2089  #endif
2090  
2091 -#if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || \
2092 -    defined (__osf__) || defined (_WIN32) || defined (__APPLE__)
2093 +#if defined(__ANDROID__)
2094 +#include <sys/select.h>
2095 +#endif
2096 +
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
2107  
2108  #elif defined (sgi) || defined (linux) || defined (__GLIBC__) || \
2109 @@ -236,7 +247,13 @@
2110  # endif
2111  #endif
2112  
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
2122  #else
2123  # define Has_Sockaddr_Len 0
2124 --- gcc/ada/init.c.orig
2125 +++ gcc/ada/init.c
2126 @@ -536,7 +536,7 @@
2127  /* GNU/Linux Section */
2128  /*********************/
2129  
2130 -#elif defined (linux)
2131 +#elif defined (linux) && !defined(__ANDROID__)
2132  
2133  #include <signal.h>
2134  
2135 @@ -1787,7 +1787,7 @@
2136  /* FreeBSD Section */
2137  /*******************/
2138  
2139 -#elif defined (__FreeBSD__)
2140 +#elif defined (__FreeBSD__)  || defined (__DragonFly__)
2141  
2142  #include <signal.h>
2143  #include <sys/ucontext.h>
2144 @@ -1832,7 +1832,7 @@
2145  }
2146  
2147  void
2148 -__gnat_install_handler ()
2149 +__gnat_install_handler (void)
2150  {
2151    struct sigaction act;
2152  
2153 @@ -1854,6 +1854,77 @@
2154  }
2155  
2156  /*******************/
2157 +/* Android Section */
2158 +/*******************/
2159 +
2160 +#elif defined(__ANDROID__)
2161 +
2162 +#include <signal.h>
2163 +
2164 +static void
2165 +__gnat_error_handler (int             sig,
2166 +                     struct siginfo *si          ATTRIBUTE_UNUSED,
2167 +                     void           *ucontext    ATTRIBUTE_UNUSED)
2168 +{
2169 +  struct Exception_Data *exception;
2170 +  const char *msg;
2171 +
2172 +  switch (sig)
2173 +    {
2174 +    case SIGFPE:
2175 +      exception = &constraint_error;
2176 +      msg = "SIGFPE";
2177 +      break;
2178 +
2179 +    case SIGILL:
2180 +      exception = &constraint_error;
2181 +      msg = "SIGILL";
2182 +      break;
2183 +      
2184 +    case SIGSEGV:
2185 +      exception = &storage_error;
2186 +      msg = "stack overflow or erroneous memory access";
2187 +      break;
2188 +
2189 +    case SIGBUS:
2190 +      exception = &constraint_error;
2191 +      msg = "SIGBUS";
2192 +      break;
2193 +
2194 +    default:
2195 +      exception = &program_error;
2196 +      msg = "unhandled signal";
2197 +    }
2198 +
2199 +  Raise_From_Signal_Handler (exception, msg);
2200 +}
2201 +
2202 +void
2203 +__gnat_install_handler (void)
2204 +{
2205 +  struct sigaction act;
2206 +
2207 +  act.sa_sigaction = __gnat_error_handler;
2208 +  act.sa_flags = SA_NODEFER | SA_RESTART | SA_SIGINFO;
2209 +  sigemptyset (&act.sa_mask);
2210 +
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);
2222 +
2223 +  __gnat_handler_installed = 1;
2224 +}
2225 +
2226 +
2227 +/*******************/
2228  /* VxWorks Section */
2229  /*******************/
2230  
2231 @@ -2416,9 +2487,13 @@
2232     initialization of the FP processor.  This version is used under INTERIX
2233     and WIN32.  */
2234  
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__)
2245  
2246  #define HAVE_GNAT_INIT_FLOAT
2247  
2248 --- gcc/ada/initialize.c.orig
2249 +++ gcc/ada/initialize.c
2250 @@ -257,8 +257,11 @@
2251  /* __gnat_initialize (init_float version) */
2252  /******************************************/
2253  
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__)
2261  
2262  extern void __gnat_init_float (void);
2263  
2264 --- gcc/ada/link.c.orig
2265 +++ gcc/ada/link.c
2266 @@ -133,7 +133,10 @@
2267  unsigned char __gnat_separate_run_path_options = 0;
2268  const char *__gnat_default_libgcc_subdir = "lib";
2269  
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
2280 @@ -669,7 +669,7 @@
2281     -- Compiler, Binder & Linker Data and Subprograms --
2282     ----------------------------------------------------
2283  
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 @@
2292  
2293        Foreign_Sources : Boolean;
2294  
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.
2299 +
2300        Rpath : String_Access := null;
2301        --  Allocated only if Path Option is supported
2302  
2303 @@ -782,7 +787,7 @@
2304              Opts.Table (Opts.Last) :=
2305                new String'("-L" & Name_Buffer (1 .. Name_Len));
2306  
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));
2310              end if;
2311  
2312 @@ -1323,9 +1328,13 @@
2313                    Get_Name_String (Element.Value);
2314  
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;
2321 +                     else
2322 +                        Opts.Increment_Last;
2323 +                        Opts.Table (Opts.Last) :=
2324 +                          new String'(Name_Buffer (1 .. Name_Len));
2325 +                     end if;
2326                    end if;
2327  
2328                    Current := Element.Next;
2329 --- gcc/ada/mlib-utl.adb.orig
2330 +++ gcc/ada/mlib-utl.adb
2331 @@ -433,7 +433,7 @@
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");
2337              end if;
2338  
2339              Gcc_Exec := Locate_Exec_On_Path (Gcc_Name.all);
2340 --- gcc/ada/prj-makr.adb.orig
2341 +++ gcc/ada/prj-makr.adb
2342 @@ -114,7 +114,7 @@
2343  
2344     procedure Dup2 (Old_Fd, New_Fd : File_Descriptor);
2345  
2346 -   Gcc      : constant String := "gcc";
2347 +   Gcc      : constant String := "ada";
2348     Gcc_Path : String_Access := null;
2349  
2350     Non_Empty_Node : constant Project_Node_Id := 1;
2351 --- gcc/ada/s-fileio.adb.orig
2352 +++ gcc/ada/s-fileio.adb
2353 @@ -231,7 +231,7 @@
2354        Close_Status : int := 0;
2355        Dup_Strm     : Boolean := False;
2356        File         : AFCB_Ptr renames File_Ptr.all;
2357 -      Errno        : Integer;
2358 +      Errno        : Integer := 0;
2359  
2360     begin
2361        --  Take a task lock, to protect the global data value Open_Files
2362 --- /dev/null
2363 +++ gcc/ada/s-osinte-android.ads
2364 @@ -0,0 +1,566 @@
2365 +------------------------------------------------------------------------------
2366 +--                                                                          --
2367 +--                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
2368 +--                                                                          --
2369 +--                   S Y S T E M . O S _ I N T E R F A C E                  --
2370 +--                                                                          --
2371 +--                                  S p e c                                 --
2372 +--                                                                          --
2373 +--             Copyright (C) 1991-1994, Florida State University            --
2374 +--          Copyright (C) 1995-2010, Free Software Foundation, Inc.         --
2375 +--                                                                          --
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.                                              --
2386 +--                                                                          --
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.                                      --
2393 +--                                                                          --
2394 +-- GNARL was developed by the GNARL team at Florida State University.       --
2395 +-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
2396 +--                                                                          --
2397 +------------------------------------------------------------------------------
2398 +
2399 +--  This is a GNU/Linux (GNU/LinuxThreads) version of this package
2400 +
2401 +--  This package encapsulates all direct interfaces to OS services
2402 +--  that are needed by the tasking run-time (libgnarl).
2403 +
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.
2406 +
2407 +with Ada.Unchecked_Conversion;
2408 +with Interfaces.C;
2409 +with System.Linux;
2410 +
2411 +package System.OS_Interface is
2412 +   pragma Preelaborate;
2413 +
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;
2424 +
2425 +   -----------
2426 +   -- Errno --
2427 +   -----------
2428 +
2429 +   function errno return int;
2430 +   pragma Import (C, errno, "__get_errno");
2431 +
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;
2438 +
2439 +   -------------
2440 +   -- Signals --
2441 +   -------------
2442 +
2443 +   Max_Interrupt : constant := 63;
2444 +   type Signal is new int range 0 .. Max_Interrupt;
2445 +   for Signal'Size use int'Size;
2446 +
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;
2485 +
2486 +   SIGADAABORT : constant := SIGABRT;
2487 +   --  Change this if you want to use another signal for task abort.
2488 +   --  SIGTERM might be a good one.
2489 +
2490 +   type Signal_Set is array (Natural range <>) of Signal;
2491 +
2492 +   Unmasked    : constant Signal_Set := (
2493 +      SIGTRAP,
2494 +      --  To enable debugging on multithreaded applications, mark SIGTRAP to
2495 +      --  be kept unmasked.
2496 +
2497 +      SIGBUS,
2498 +
2499 +      SIGTTIN, SIGTTOU, SIGTSTP,
2500 +      --  Keep these three signals unmasked so that background processes
2501 +      --  and IO behaves as normal "C" applications
2502 +
2503 +      SIGPROF,
2504 +      --  To avoid confusing the profiler
2505 +
2506 +      SIGKILL, SIGSTOP,
2507 +      --  These two signals actually cannot be masked;
2508 +      --  POSIX simply won't allow it.
2509 +
2510 +      SIGLTHRRES, SIGLTHRCAN, SIGLTHRDBG);
2511 +      --  These three signals are used by GNU/LinuxThreads starting from
2512 +      --  glibc 2.1 (future 2.2).
2513 +
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);
2518 +
2519 +   type sigset_t is private;
2520 +
2521 +   function sigaddset (set : access sigset_t; sig : Signal) return int;
2522 +   pragma Import (C, sigaddset, "sigaddset");
2523 +
2524 +   function sigdelset (set : access sigset_t; sig : Signal) return int;
2525 +   pragma Import (C, sigdelset, "sigdelset");
2526 +
2527 +   function sigfillset (set : access sigset_t) return int;
2528 +   pragma Import (C, sigfillset, "sigfillset");
2529 +
2530 +   function sigismember (set : access sigset_t; sig : Signal) return int;
2531 +   pragma Import (C, sigismember, "sigismember");
2532 +
2533 +   function sigemptyset (set : access sigset_t) return int;
2534 +   pragma Import (C, sigemptyset, "sigemptyset");
2535 +
2536 +   type union_type_3 is new String (1 .. 116);
2537 +   type siginfo_t is record
2538 +      si_signo : int;
2539 +      si_code  : int;
2540 +      si_errno : int;
2541 +      X_data   : union_type_3;
2542 +   end record;
2543 +   pragma Convention (C, siginfo_t);
2544 +
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;
2550 +   end record;
2551 +   pragma Convention (C, struct_sigaction);
2552 +
2553 +   type struct_sigaction_ptr is access all struct_sigaction;
2554 +
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;
2562 +   end record;
2563 +   type Machine_State_Ptr is access all Machine_State;
2564 +
2565 +   SA_SIGINFO : constant := System.Linux.SA_SIGINFO;
2566 +   SA_ONSTACK : constant := System.Linux.SA_ONSTACK;
2567 +
2568 +   SIG_BLOCK   : constant := 0;
2569 +   SIG_UNBLOCK : constant := 1;
2570 +   SIG_SETMASK : constant := 2;
2571 +
2572 +   SIG_DFL : constant := 0;
2573 +   SIG_IGN : constant := 1;
2574 +
2575 +   function sigaction
2576 +     (sig  : Signal;
2577 +      act  : struct_sigaction_ptr;
2578 +      oact : struct_sigaction_ptr) return int;
2579 +   pragma Import (C, sigaction, "sigaction");
2580 +
2581 +   ----------
2582 +   -- Time --
2583 +   ----------
2584 +
2585 +   type timespec is private;
2586 +
2587 +   function To_Duration (TS : timespec) return Duration;
2588 +   pragma Inline (To_Duration);
2589 +
2590 +   function To_Timespec (D : Duration) return timespec;
2591 +   pragma Inline (To_Timespec);
2592 +
2593 +   function sysconf (name : int) return long;
2594 +   pragma Import (C, sysconf);
2595 +
2596 +   SC_CLK_TCK          : constant := 2;
2597 +   SC_NPROCESSORS_ONLN : constant := 84;
2598 +
2599 +   -------------------------
2600 +   -- Priority Scheduling --
2601 +   -------------------------
2602 +
2603 +   SCHED_OTHER : constant := 0;
2604 +   SCHED_FIFO  : constant := 1;
2605 +   SCHED_RR    : constant := 2;
2606 +
2607 +   function To_Target_Priority
2608 +     (Prio : System.Any_Priority) return Interfaces.C.int;
2609 +   --  Maps System.Any_Priority to a POSIX priority
2610 +
2611 +   -------------
2612 +   -- Process --
2613 +   -------------
2614 +
2615 +   type pid_t is private;
2616 +
2617 +   function kill (pid : pid_t; sig : Signal) return int;
2618 +   pragma Import (C, kill, "kill");
2619 +
2620 +   function getpid return pid_t;
2621 +   pragma Import (C, getpid, "getpid");
2622 +
2623 +   -------------
2624 +   -- Threads --
2625 +   -------------
2626 +
2627 +   type Thread_Body is access
2628 +     function (arg : System.Address) return System.Address;
2629 +   pragma Convention (C, Thread_Body);
2630 +
2631 +   function Thread_Body_Access is new
2632 +     Ada.Unchecked_Conversion (System.Address, Thread_Body);
2633 +
2634 +   type pthread_t is new unsigned_long;
2635 +   subtype Thread_Id        is pthread_t;
2636 +
2637 +   function To_pthread_t is new Ada.Unchecked_Conversion
2638 +     (unsigned_long, pthread_t);
2639 +
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;
2646 +
2647 +   PTHREAD_CREATE_DETACHED : constant := 1;
2648 +
2649 +   -----------
2650 +   -- Stack --
2651 +   -----------
2652 +
2653 +   type stack_t is record
2654 +      ss_sp    : System.Address;
2655 +      ss_flags : int;
2656 +      ss_size  : size_t;
2657 +   end record;
2658 +   pragma Convention (C, stack_t);
2659 +
2660 +   function sigaltstack
2661 +     (ss  : not null access stack_t;
2662 +      oss : access stack_t) return int;
2663 +   pragma Import (C, sigaltstack, "sigaltstack");
2664 +
2665 +   Alternate_Stack : aliased System.Address;
2666 +   pragma Import (C, Alternate_Stack, "__gnat_alternate_stack");
2667 +   --  The alternate signal stack for stack overflows
2668 +
2669 +   Alternate_Stack_Size : constant := 16 * 1024;
2670 +   --  This must be in keeping with init.c:__gnat_alternate_stack
2671 +
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
2675 +
2676 +   ---------------------------------------
2677 +   -- Nonstandard Thread Initialization --
2678 +   ---------------------------------------
2679 +
2680 +   procedure pthread_init;
2681 +   pragma Inline (pthread_init);
2682 +   --  This is a dummy procedure to share some GNULLI files
2683 +
2684 +   -------------------------
2685 +   -- POSIX.1c  Section 3 --
2686 +   -------------------------
2687 +
2688 +   function sigwait (set : access sigset_t; sig : access Signal) return int;
2689 +   pragma Import (C, sigwait, "sigwait");
2690 +
2691 +   function pthread_kill (thread : pthread_t; sig : Signal) return int;
2692 +   pragma Import (C, pthread_kill, "pthread_kill");
2693 +
2694 +   function pthread_sigmask
2695 +     (how  : int;
2696 +      set  : access sigset_t;
2697 +      oset : access sigset_t) return int;
2698 +   pragma Import (C, pthread_sigmask, "pthread_sigmask");
2699 +
2700 +   --------------------------
2701 +   -- POSIX.1c  Section 11 --
2702 +   --------------------------
2703 +
2704 +   function pthread_mutexattr_init
2705 +     (attr : access pthread_mutexattr_t) return int;
2706 +   pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
2707 +
2708 +   function pthread_mutexattr_destroy
2709 +     (attr : access pthread_mutexattr_t) return int;
2710 +   pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
2711 +
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");
2716 +
2717 +   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
2718 +   pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
2719 +
2720 +   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
2721 +   pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
2722 +
2723 +   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
2724 +   pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
2725 +
2726 +   function pthread_condattr_init
2727 +     (attr : access pthread_condattr_t) return int;
2728 +   pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
2729 +
2730 +   function pthread_condattr_destroy
2731 +     (attr : access pthread_condattr_t) return int;
2732 +   pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
2733 +
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");
2738 +
2739 +   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
2740 +   pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
2741 +
2742 +   function pthread_cond_signal (cond : access pthread_cond_t) return int;
2743 +   pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
2744 +
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");
2749 +
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");
2755 +
2756 +   --------------------------
2757 +   -- POSIX.1c  Section 13 --
2758 +   --------------------------
2759 +
2760 +   type struct_sched_param is record
2761 +      sched_priority : int;  --  scheduling priority
2762 +   end record;
2763 +   pragma Convention (C, struct_sched_param);
2764 +
2765 +   function pthread_setschedparam
2766 +     (thread : pthread_t;
2767 +      policy : int;
2768 +      param  : access struct_sched_param) return int;
2769 +   pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
2770 +
2771 +   function pthread_attr_setschedpolicy
2772 +     (attr   : access pthread_attr_t;
2773 +      policy : int) return int;
2774 +   pragma Import
2775 +     (C, pthread_attr_setschedpolicy, "pthread_attr_setschedpolicy");
2776 +
2777 +   function sched_yield return int;
2778 +   pragma Import (C, sched_yield, "sched_yield");
2779 +
2780 +   ---------------------------
2781 +   -- P1003.1c - Section 16 --
2782 +   ---------------------------
2783 +
2784 +   function pthread_attr_init
2785 +     (attributes : access pthread_attr_t) return int;
2786 +   pragma Import (C, pthread_attr_init, "pthread_attr_init");
2787 +
2788 +   function pthread_attr_destroy
2789 +     (attributes : access pthread_attr_t) return int;
2790 +   pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
2791 +
2792 +   function pthread_attr_setdetachstate
2793 +     (attr        : access pthread_attr_t;
2794 +      detachstate : int) return int;
2795 +   pragma Import
2796 +     (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
2797 +
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");
2802 +
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");
2809 +
2810 +   procedure pthread_exit (status : System.Address);
2811 +   pragma Import (C, pthread_exit, "pthread_exit");
2812 +
2813 +   function pthread_self return pthread_t;
2814 +   pragma Import (C, pthread_self, "pthread_self");
2815 +
2816 +   function lwp_self return System.Address;
2817 +   pragma Import (C, lwp_self, "__gnat_lwp_self");
2818 +
2819 +   --------------------------
2820 +   -- POSIX.1c  Section 17 --
2821 +   --------------------------
2822 +
2823 +   function pthread_setspecific
2824 +     (key   : pthread_key_t;
2825 +      value : System.Address) return int;
2826 +   pragma Import (C, pthread_setspecific, "pthread_setspecific");
2827 +
2828 +   function pthread_getspecific (key : pthread_key_t) return System.Address;
2829 +   pragma Import (C, pthread_getspecific, "pthread_getspecific");
2830 +
2831 +   type destructor_pointer is access procedure (arg : System.Address);
2832 +   pragma Convention (C, destructor_pointer);
2833 +
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");
2838 +
2839 +   CPU_SETSIZE : constant := 1_024;
2840 +
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);
2845 +
2846 +   type cpu_set_t is record
2847 +      bits : bit_field;
2848 +   end record;
2849 +   pragma Convention (C, cpu_set_t);
2850 +
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.
2859 +
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.
2869 +
2870 +private
2871 +
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;
2875 +
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;
2881 +   end record;
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);
2885 +
2886 +   type pid_t is new int;
2887 +
2888 +   type time_t is new long;
2889 +
2890 +   type timespec is record
2891 +      tv_sec  : time_t;
2892 +      tv_nsec : long;
2893 +   end record;
2894 +   pragma Convention (C, timespec);
2895 +
2896 +   type pthread_attr_t is record
2897 +      detachstate   : int;
2898 +      schedpolicy   : int;
2899 +      schedparam    : struct_sched_param;
2900 +      inheritsched  : int;
2901 +      scope         : int;
2902 +      guardsize     : size_t;
2903 +      stackaddr_set : int;
2904 +      stackaddr     : System.Address;
2905 +      stacksize     : size_t;
2906 +   end record;
2907 +   pragma Convention (C, pthread_attr_t);
2908 +
2909 +   type pthread_condattr_t is record
2910 +      dummy : int;
2911 +   end record;
2912 +   pragma Convention (C, pthread_condattr_t);
2913 +
2914 +   type pthread_mutexattr_t is record
2915 +      mutexkind : int;
2916 +   end record;
2917 +   pragma Convention (C, pthread_mutexattr_t);
2918 +
2919 +   type pthread_mutex_t is new System.Linux.pthread_mutex_t;
2920 +
2921 +   type unsigned_long_long_t is mod 2 ** 64;
2922 +   --  Interfaces.C.Extensions isn't preelaborated so cannot be with-ed
2923 +
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;
2927 +
2928 +   type pthread_key_t is new unsigned;
2929 +
2930 +end System.OS_Interface;
2931 --- /dev/null
2932 +++ gcc/ada/s-osinte-dragonfly.adb
2933 @@ -0,0 +1,116 @@
2934 +------------------------------------------------------------------------------
2935 +--                                                                          --
2936 +--                  GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                --
2937 +--                                                                          --
2938 +--                   S Y S T E M . O S _ I N T E R F A C E                  --
2939 +--                                                                          --
2940 +--                                   B o d y                                --
2941 +--                                                                          --
2942 +--          Copyright (C) 1991-2009, Free Software Foundation, Inc.         --
2943 +--                                                                          --
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.                                     --
2950 +--                                                                          --
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.               --
2954 +--                                                                          --
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/>.                                          --
2959 +--                                                                          --
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).                                  --
2963 +--                                                                          --
2964 +------------------------------------------------------------------------------
2965 +
2966 +--  This is the DragonFly THREADS version of this package
2967 +
2968 +with Interfaces.C; use Interfaces.C;
2969 +
2970 +package body System.OS_Interface is
2971 +
2972 +   -----------
2973 +   -- Errno --
2974 +   -----------
2975 +
2976 +   function Errno return int is
2977 +      type int_ptr is access all int;
2978 +
2979 +      function internal_errno return int_ptr;
2980 +      pragma Import (C, internal_errno, "__get_errno");
2981 +
2982 +   begin
2983 +      return (internal_errno.all);
2984 +   end Errno;
2985 +
2986 +   --------------------
2987 +   -- Get_Stack_Base --
2988 +   --------------------
2989 +
2990 +   function Get_Stack_Base (thread : pthread_t) return Address is
2991 +      pragma Unreferenced (thread);
2992 +   begin
2993 +      return Null_Address;
2994 +   end Get_Stack_Base;
2995 +
2996 +   ------------------
2997 +   -- pthread_init --
2998 +   ------------------
2999 +
3000 +   procedure pthread_init is
3001 +   begin
3002 +      null;
3003 +   end pthread_init;
3004 +
3005 +   -----------------
3006 +   -- To_Duration --
3007 +   -----------------
3008 +
3009 +   function To_Duration (TS : timespec) return Duration is
3010 +   begin
3011 +      return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
3012 +   end To_Duration;
3013 +
3014 +   ------------------------
3015 +   -- To_Target_Priority --
3016 +   ------------------------
3017 +
3018 +   function To_Target_Priority
3019 +     (Prio : System.Any_Priority) return Interfaces.C.int
3020 +   is
3021 +   begin
3022 +      return Interfaces.C.int (Prio);
3023 +   end To_Target_Priority;
3024 +
3025 +   -----------------
3026 +   -- To_Timespec --
3027 +   -----------------
3028 +
3029 +   function To_Timespec (D : Duration) return timespec is
3030 +      S : time_t;
3031 +      F : Duration;
3032 +
3033 +   begin
3034 +      S := time_t (Long_Long_Integer (D));
3035 +      F := D - Duration (S);
3036 +
3037 +      --  If F has negative value due to a round-up, adjust for positive F
3038 +      --  value.
3039 +
3040 +      if F < 0.0 then
3041 +         S := S - 1;
3042 +         F := F + 1.0;
3043 +      end if;
3044 +
3045 +      return timespec'(tv_sec => S,
3046 +                       tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
3047 +   end To_Timespec;
3048 +
3049 +end System.OS_Interface;
3050 --- /dev/null
3051 +++ gcc/ada/s-osinte-dragonfly.ads
3052 @@ -0,0 +1,648 @@
3053 +------------------------------------------------------------------------------
3054 +--                                                                          --
3055 +--                  GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                --
3056 +--                                                                          --
3057 +--                   S Y S T E M . O S _ I N T E R F A C E                  --
3058 +--                                                                          --
3059 +--                                   S p e c                                --
3060 +--                                                                          --
3061 +--             Copyright (C) 1991-1994, Florida State University            --
3062 +--          Copyright (C) 1995-2011, Free Software Foundation, Inc.         --
3063 +--                                                                          --
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.                                     --
3070 +--                                                                          --
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.               --
3074 +--                                                                          --
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/>.                                          --
3079 +--                                                                          --
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).                                  --
3083 +--                                                                          --
3084 +------------------------------------------------------------------------------
3085 +
3086 +--  This is the DragonFly BSD PTHREADS version of this package
3087 +
3088 +--  This package encapsulates all direct interfaces to OS services
3089 +--  that are needed by the tasking run-time (libgnarl).
3090 +
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.
3093 +
3094 +with Ada.Unchecked_Conversion;
3095 +
3096 +with Interfaces.C;
3097 +
3098 +package System.OS_Interface is
3099 +   pragma Preelaborate;
3100 +
3101 +   pragma Linker_Options ("-pthread");
3102 +
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;
3112 +
3113 +   -----------
3114 +   -- Errno --
3115 +   -----------
3116 +
3117 +   function Errno return int;
3118 +   pragma Inline (Errno);
3119 +
3120 +   EAGAIN    : constant := 35;
3121 +   EINTR     : constant := 4;
3122 +   EINVAL    : constant := 22;
3123 +   ENOMEM    : constant := 12;
3124 +   ETIMEDOUT : constant := 60;
3125 +
3126 +   -------------
3127 +   -- Signals --
3128 +   -------------
3129 +
3130 +   Max_Interrupt : constant := 31;
3131 +   type Signal is new int range 0 .. Max_Interrupt;
3132 +   for Signal'Size use int'Size;
3133 +
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
3167 +
3168 +   SIGADAABORT : constant := SIGABRT;
3169 +   --  Change this if you want to use another signal for task abort.
3170 +   --  SIGTERM might be a good one.
3171 +
3172 +   type Signal_Set is array (Natural range <>) of Signal;
3173 +
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);
3179 +
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);
3183 +
3184 +   type sigset_t is private;
3185 +
3186 +   function sigaddset
3187 +     (set : access sigset_t;
3188 +      sig : Signal) return int;
3189 +   pragma Import (C, sigaddset, "sigaddset");
3190 +
3191 +   function sigdelset
3192 +     (set : access sigset_t;
3193 +      sig : Signal) return int;
3194 +   pragma Import (C, sigdelset, "sigdelset");
3195 +
3196 +   function sigfillset (set : access sigset_t) return int;
3197 +   pragma Import (C, sigfillset, "sigfillset");
3198 +
3199 +   function sigismember
3200 +     (set : access sigset_t;
3201 +      sig : Signal) return int;
3202 +   pragma Import (C, sigismember, "sigismember");
3203 +
3204 +   function sigemptyset (set : access sigset_t) return int;
3205 +   pragma Import (C, sigemptyset, "sigemptyset");
3206 +
3207 +   --  sigcontext is architecture dependent, so define it private
3208 +   type struct_sigcontext is private;
3209 +
3210 +   type old_struct_sigaction is record
3211 +      sa_handler : System.Address;
3212 +      sa_mask    : sigset_t;
3213 +      sa_flags   : int;
3214 +   end record;
3215 +   pragma Convention (C, old_struct_sigaction);
3216 +
3217 +   type new_struct_sigaction is record
3218 +      sa_handler : System.Address;
3219 +      sa_flags   : int;
3220 +      sa_mask    : sigset_t;
3221 +   end record;
3222 +   pragma Convention (C, new_struct_sigaction);
3223 +
3224 +   subtype struct_sigaction is new_struct_sigaction;
3225 +   type struct_sigaction_ptr is access all struct_sigaction;
3226 +
3227 +   SIG_BLOCK   : constant := 1;
3228 +   SIG_UNBLOCK : constant := 2;
3229 +   SIG_SETMASK : constant := 3;
3230 +
3231 +   SIG_DFL : constant := 0;
3232 +   SIG_IGN : constant := 1;
3233 +
3234 +   SA_SIGINFO : constant := 16#0040#;
3235 +   SA_ONSTACK : constant := 16#0001#;
3236 +
3237 +   function sigaction
3238 +     (sig  : Signal;
3239 +      act  : struct_sigaction_ptr;
3240 +      oact : struct_sigaction_ptr) return int;
3241 +   pragma Import (C, sigaction, "sigaction");
3242 +
3243 +   ----------
3244 +   -- Time --
3245 +   ----------
3246 +
3247 +   Time_Slice_Supported : constant Boolean := True;
3248 +   --  Indicates whether time slicing is supported (i.e SCHED_RR is supported)
3249 +
3250 +   type timespec is private;
3251 +
3252 +   function nanosleep (rqtp, rmtp : access timespec)  return int;
3253 +   pragma Import (C, nanosleep, "nanosleep");
3254 +
3255 +   type clockid_t is new unsigned_long;
3256 +
3257 +   function clock_gettime
3258 +     (clock_id : clockid_t;
3259 +      tp       : access timespec)
3260 +      return int;
3261 +   pragma Import (C, clock_gettime, "clock_gettime");
3262 +
3263 +   function To_Duration (TS : timespec) return Duration;
3264 +   pragma Inline (To_Duration);
3265 +
3266 +   function To_Timespec (D : Duration) return timespec;
3267 +   pragma Inline (To_Timespec);
3268 +
3269 +   type struct_timezone is record
3270 +      tz_minuteswest : int;
3271 +      tz_dsttime     : int;
3272 +   end record;
3273 +   pragma Convention (C, struct_timezone);
3274 +
3275 +   procedure usleep (useconds : unsigned_long);
3276 +   pragma Import (C, usleep, "usleep");
3277 +
3278 +   -------------------------
3279 +   -- Priority Scheduling --
3280 +   -------------------------
3281 +
3282 +   SCHED_FIFO  : constant := 1;
3283 +   SCHED_OTHER : constant := 2;
3284 +   SCHED_RR    : constant := 3;
3285 +
3286 +   function To_Target_Priority
3287 +     (Prio : System.Any_Priority) return Interfaces.C.int;
3288 +   --  Maps System.Any_Priority to a POSIX priority
3289 +
3290 +   -------------
3291 +   -- Process --
3292 +   -------------
3293 +
3294 +   type pid_t is private;
3295 +
3296 +   function kill (pid : pid_t; sig : Signal) return int;
3297 +   pragma Import (C, kill, "kill");
3298 +
3299 +   function getpid return pid_t;
3300 +   pragma Import (C, getpid, "getpid");
3301 +
3302 +   ---------
3303 +   -- LWP --
3304 +   ---------
3305 +
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");
3311 +
3312 +   -------------
3313 +   -- Threads --
3314 +   -------------
3315 +
3316 +   type Thread_Body is access
3317 +     function (arg : System.Address) return System.Address;
3318 +   pragma Convention (C, Thread_Body);
3319 +
3320 +   function Thread_Body_Access is new
3321 +     Ada.Unchecked_Conversion (System.Address, Thread_Body);
3322 +
3323 +   type pthread_t           is private;
3324 +   subtype Thread_Id        is pthread_t;
3325 +
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;
3332 +
3333 +   PTHREAD_CREATE_DETACHED : constant := 1;
3334 +   PTHREAD_CREATE_JOINABLE : constant := 0;
3335 +
3336 +   PTHREAD_SCOPE_PROCESS : constant := 0;
3337 +   PTHREAD_SCOPE_SYSTEM  : constant := 2;
3338 +
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].
3343 +
3344 +   subtype pthread_rwlock_t     is pthread_mutex_t;
3345 +   subtype pthread_rwlockattr_t is pthread_mutexattr_t;
3346 +
3347 +   -----------
3348 +   -- Stack --
3349 +   -----------
3350 +
3351 +   type stack_t is record
3352 +      ss_sp    : System.Address;
3353 +      ss_size  : size_t;
3354 +      ss_flags : int;
3355 +   end record;
3356 +   pragma Convention (C, stack_t);
3357 +
3358 +   function sigaltstack
3359 +     (ss  : not null access stack_t;
3360 +      oss : access stack_t) return int;
3361 +   pragma Import (C, sigaltstack, "sigaltstack");
3362 +
3363 +   Alternate_Stack : aliased System.Address;
3364 +   --  This is a dummy definition, never used (Alternate_Stack_Size is null)
3365 +
3366 +   Alternate_Stack_Size : constant := 0;
3367 +   --  No alternate signal stack is used on this platform
3368 +
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.
3374 +
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.
3379 +
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
3384 +
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;
3392 +
3393 +   function mprotect (addr : Address; len : size_t; prot : int) return int;
3394 +   pragma Import (C, mprotect);
3395 +
3396 +   ---------------------------------------
3397 +   -- Nonstandard Thread Initialization --
3398 +   ---------------------------------------
3399 +
3400 +   --  FSU_THREADS requires pthread_init, which is nonstandard and this should
3401 +   --  be invoked during the elaboration of s-taprop.adb.
3402 +
3403 +   --  DragonFlyBSD does not require this so we provide an empty Ada body
3404 +
3405 +   procedure pthread_init;
3406 +
3407 +   -------------------------
3408 +   -- POSIX.1c  Section 3 --
3409 +   -------------------------
3410 +
3411 +   function sigwait
3412 +     (set : access sigset_t;
3413 +      sig : access Signal) return int;
3414 +   pragma Import (C, sigwait, "sigwait");
3415 +
3416 +   function pthread_kill
3417 +     (thread : pthread_t;
3418 +      sig    : Signal) return int;
3419 +   pragma Import (C, pthread_kill, "pthread_kill");
3420 +
3421 +   function pthread_sigmask
3422 +     (how  : int;
3423 +      set  : access sigset_t;
3424 +      oset : access sigset_t) return int;
3425 +   pragma Import (C, pthread_sigmask, "pthread_sigmask");
3426 +
3427 +   --------------------------
3428 +   -- POSIX.1c  Section 11 --
3429 +   --------------------------
3430 +
3431 +   function pthread_mutexattr_init
3432 +     (attr : access pthread_mutexattr_t) return int;
3433 +   pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
3434 +
3435 +   function pthread_mutexattr_destroy
3436 +     (attr : access pthread_mutexattr_t) return int;
3437 +   pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
3438 +
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");
3443 +
3444 +   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
3445 +   pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
3446 +
3447 +   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
3448 +   pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
3449 +
3450 +   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
3451 +   pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
3452 +
3453 +   function pthread_condattr_init
3454 +     (attr : access pthread_condattr_t) return int;
3455 +   pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
3456 +
3457 +   function pthread_condattr_destroy
3458 +     (attr : access pthread_condattr_t) return int;
3459 +   pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
3460 +
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");
3465 +
3466 +   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
3467 +   pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
3468 +
3469 +   function pthread_cond_signal (cond : access pthread_cond_t) return int;
3470 +   pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
3471 +
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");
3476 +
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");
3482 +
3483 +   Relative_Timed_Wait : constant Boolean := False;
3484 +   --  pthread_cond_timedwait requires an absolute delay time
3485 +
3486 +   --------------------------
3487 +   -- POSIX.1c  Section 13 --
3488 +   --------------------------
3489 +
3490 +   PTHREAD_PRIO_NONE    : constant := 0;
3491 +   PTHREAD_PRIO_PROTECT : constant := 2;
3492 +   PTHREAD_PRIO_INHERIT : constant := 1;
3493 +
3494 +   function pthread_mutexattr_setprotocol
3495 +     (attr     : access pthread_mutexattr_t;
3496 +      protocol : int) return int;
3497 +   pragma Import
3498 +      (C, pthread_mutexattr_setprotocol, "pthread_mutexattr_setprotocol");
3499 +
3500 +   function pthread_mutexattr_getprotocol
3501 +     (attr     : access pthread_mutexattr_t;
3502 +      protocol : access int) return int;
3503 +   pragma Import
3504 +     (C, pthread_mutexattr_getprotocol, "pthread_mutexattr_getprotocol");
3505 +
3506 +   function pthread_mutexattr_setprioceiling
3507 +     (attr     : access pthread_mutexattr_t;
3508 +      prioceiling : int) return int;
3509 +   pragma Import
3510 +     (C, pthread_mutexattr_setprioceiling,
3511 +      "pthread_mutexattr_setprioceiling");
3512 +
3513 +   function pthread_mutexattr_getprioceiling
3514 +     (attr     : access pthread_mutexattr_t;
3515 +      prioceiling : access int) return int;
3516 +   pragma Import
3517 +     (C, pthread_mutexattr_getprioceiling,
3518 +      "pthread_mutexattr_getprioceiling");
3519 +
3520 +   type struct_sched_param is record
3521 +      sched_priority : int;
3522 +   end record;
3523 +   pragma Convention (C, struct_sched_param);
3524 +
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");
3530 +
3531 +   function pthread_setschedparam
3532 +     (thread : pthread_t;
3533 +      policy : int;
3534 +      param  : access struct_sched_param) return int;
3535 +   pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
3536 +
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");
3541 +
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");
3546 +
3547 +   function pthread_attr_setinheritsched
3548 +     (attr            : access pthread_attr_t;
3549 +      inheritsched : int) return int;
3550 +   pragma Import
3551 +     (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
3552 +
3553 +   function pthread_attr_getinheritsched
3554 +     (attr         : access pthread_attr_t;
3555 +      inheritsched : access int) return int;
3556 +   pragma Import
3557 +     (C, pthread_attr_getinheritsched, "pthread_attr_getinheritsched");
3558 +
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");
3564 +
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");
3570 +
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");
3575 +
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");
3580 +
3581 +   function sched_yield return int;
3582 +   pragma Import (C, sched_yield, "pthread_yield");
3583 +
3584 +   --------------------------
3585 +   -- P1003.1c  Section 16 --
3586 +   --------------------------
3587 +
3588 +   function pthread_attr_init (attributes : access pthread_attr_t) return int;
3589 +   pragma Import (C, pthread_attr_init, "pthread_attr_init");
3590 +
3591 +   function pthread_attr_destroy
3592 +     (attributes : access pthread_attr_t) return int;
3593 +   pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
3594 +
3595 +   function pthread_attr_setdetachstate
3596 +     (attr        : access pthread_attr_t;
3597 +      detachstate : int) return int;
3598 +   pragma Import
3599 +     (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
3600 +
3601 +   function pthread_attr_getdetachstate
3602 +     (attr        : access pthread_attr_t;
3603 +      detachstate : access int) return int;
3604 +   pragma Import
3605 +     (C, pthread_attr_getdetachstate, "pthread_attr_getdetachstate");
3606 +
3607 +   function pthread_attr_getstacksize
3608 +     (attr      : access pthread_attr_t;
3609 +      stacksize : access size_t) return int;
3610 +   pragma Import
3611 +     (C, pthread_attr_getstacksize, "pthread_attr_getstacksize");
3612 +
3613 +   function pthread_attr_setstacksize
3614 +     (attr      : access pthread_attr_t;
3615 +      stacksize : size_t) return int;
3616 +   pragma Import
3617 +     (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
3618 +
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");
3625 +
3626 +   function pthread_detach (thread : pthread_t) return int;
3627 +   pragma Import (C, pthread_detach, "pthread_detach");
3628 +
3629 +   procedure pthread_exit (status : System.Address);
3630 +   pragma Import (C, pthread_exit, "pthread_exit");
3631 +
3632 +   function pthread_self return pthread_t;
3633 +   pragma Import (C, pthread_self, "pthread_self");
3634 +
3635 +   --------------------------
3636 +   -- POSIX.1c  Section 17 --
3637 +   --------------------------
3638 +
3639 +   function pthread_setspecific
3640 +     (key   : pthread_key_t;
3641 +      value : System.Address) return  int;
3642 +   pragma Import (C, pthread_setspecific, "pthread_setspecific");
3643 +
3644 +   function pthread_getspecific (key : pthread_key_t) return System.Address;
3645 +   pragma Import (C, pthread_getspecific, "pthread_getspecific");
3646 +
3647 +   type destructor_pointer is access procedure (arg : System.Address);
3648 +   pragma Convention (C, destructor_pointer);
3649 +
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");
3654 +
3655 +   ------------------------------------
3656 +   -- Non-portable Pthread Functions --
3657 +   ------------------------------------
3658 +
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");
3663 +
3664 +private
3665 +
3666 +   type sigset_t is array (1 .. 4) of unsigned;
3667 +
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
3672 +
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.
3678 +
3679 +   type struct_sigcontext is null record;
3680 +   pragma Convention (C, struct_sigcontext);
3681 +
3682 +   type pid_t is new int;
3683 +
3684 +   type time_t is new long;
3685 +
3686 +   type timespec is record
3687 +      tv_sec  : time_t;
3688 +      tv_nsec : long;
3689 +   end record;
3690 +   pragma Convention (C, timespec);
3691 +
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;
3699 +
3700 +end System.OS_Interface;
3701 --- gcc/ada/s-osinte-freebsd.adb.orig
3702 +++ gcc/ada/s-osinte-freebsd.adb
3703 @@ -44,7 +44,7 @@
3704        type int_ptr is access all int;
3705  
3706        function internal_errno return int_ptr;
3707 -      pragma Import (C, internal_errno, "__error");
3708 +      pragma Import (C, internal_errno, "__get_errno");
3709  
3710     begin
3711        return (internal_errno.all);
3712 @@ -57,7 +57,7 @@
3713     function Get_Stack_Base (thread : pthread_t) return Address is
3714        pragma Unreferenced (thread);
3715     begin
3716 -      return (0);
3717 +      return Null_Address;
3718     end Get_Stack_Base;
3719  
3720     ------------------
3721 @@ -75,7 +75,7 @@
3722  
3723     function To_Duration (TS : timespec) return Duration is
3724     begin
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;
3727     end To_Duration;
3728  
3729     ------------------------
3730 @@ -108,8 +108,8 @@
3731           F := F + 1.0;
3732        end if;
3733  
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)));
3738     end To_Timespec;
3739  
3740  end System.OS_Interface;
3741 --- /dev/null
3742 +++ gcc/ada/s-osinte-freebsd32.ads
3743 @@ -0,0 +1,648 @@
3744 +------------------------------------------------------------------------------
3745 +--                                                                          --
3746 +--                  GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                --
3747 +--                                                                          --
3748 +--                   S Y S T E M . O S _ I N T E R F A C E                  --
3749 +--                                                                          --
3750 +--                                   S p e c                                --
3751 +--                                                                          --
3752 +--             Copyright (C) 1991-1994, Florida State University            --
3753 +--          Copyright (C) 1995-2011, Free Software Foundation, Inc.         --
3754 +--                                                                          --
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.                                     --
3761 +--                                                                          --
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.               --
3765 +--                                                                          --
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/>.                                          --
3770 +--                                                                          --
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).                                  --
3774 +--                                                                          --
3775 +------------------------------------------------------------------------------
3776 +
3777 +--  This is the FreeBSD PTHREADS version of this package
3778 +
3779 +--  This package encapsulates all direct interfaces to OS services
3780 +--  that are needed by the tasking run-time (libgnarl).
3781 +
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.
3784 +
3785 +with Ada.Unchecked_Conversion;
3786 +
3787 +with Interfaces.C;
3788 +
3789 +package System.OS_Interface is
3790 +   pragma Preelaborate;
3791 +
3792 +   pragma Linker_Options ("-pthread");
3793 +
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;
3803 +
3804 +   -----------
3805 +   -- Errno --
3806 +   -----------
3807 +
3808 +   function Errno return int;
3809 +   pragma Inline (Errno);
3810 +
3811 +   EAGAIN    : constant := 35;
3812 +   EINTR     : constant := 4;
3813 +   EINVAL    : constant := 22;
3814 +   ENOMEM    : constant := 12;
3815 +   ETIMEDOUT : constant := 60;
3816 +
3817 +   -------------
3818 +   -- Signals --
3819 +   -------------
3820 +
3821 +   Max_Interrupt : constant := 31;
3822 +   type Signal is new int range 0 .. Max_Interrupt;
3823 +   for Signal'Size use int'Size;
3824 +
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
3858 +
3859 +   SIGADAABORT : constant := SIGABRT;
3860 +   --  Change this if you want to use another signal for task abort.
3861 +   --  SIGTERM might be a good one.
3862 +
3863 +   type Signal_Set is array (Natural range <>) of Signal;
3864 +
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);
3870 +
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);
3874 +
3875 +   type sigset_t is private;
3876 +
3877 +   function sigaddset
3878 +     (set : access sigset_t;
3879 +      sig : Signal) return int;
3880 +   pragma Import (C, sigaddset, "sigaddset");
3881 +
3882 +   function sigdelset
3883 +     (set : access sigset_t;
3884 +      sig : Signal) return int;
3885 +   pragma Import (C, sigdelset, "sigdelset");
3886 +
3887 +   function sigfillset (set : access sigset_t) return int;
3888 +   pragma Import (C, sigfillset, "sigfillset");
3889 +
3890 +   function sigismember
3891 +     (set : access sigset_t;
3892 +      sig : Signal) return int;
3893 +   pragma Import (C, sigismember, "sigismember");
3894 +
3895 +   function sigemptyset (set : access sigset_t) return int;
3896 +   pragma Import (C, sigemptyset, "sigemptyset");
3897 +
3898 +   --  sigcontext is architecture dependent, so define it private
3899 +   type struct_sigcontext is private;
3900 +
3901 +   type old_struct_sigaction is record
3902 +      sa_handler : System.Address;
3903 +      sa_mask    : sigset_t;
3904 +      sa_flags   : int;
3905 +   end record;
3906 +   pragma Convention (C, old_struct_sigaction);
3907 +
3908 +   type new_struct_sigaction is record
3909 +      sa_handler : System.Address;
3910 +      sa_flags   : int;
3911 +      sa_mask    : sigset_t;
3912 +   end record;
3913 +   pragma Convention (C, new_struct_sigaction);
3914 +
3915 +   subtype struct_sigaction is new_struct_sigaction;
3916 +   type struct_sigaction_ptr is access all struct_sigaction;
3917 +
3918 +   SIG_BLOCK   : constant := 1;
3919 +   SIG_UNBLOCK : constant := 2;
3920 +   SIG_SETMASK : constant := 3;
3921 +
3922 +   SIG_DFL : constant := 0;
3923 +   SIG_IGN : constant := 1;
3924 +
3925 +   SA_SIGINFO : constant := 16#0040#;
3926 +   SA_ONSTACK : constant := 16#0001#;
3927 +
3928 +   function sigaction
3929 +     (sig  : Signal;
3930 +      act  : struct_sigaction_ptr;
3931 +      oact : struct_sigaction_ptr) return int;
3932 +   pragma Import (C, sigaction, "sigaction");
3933 +
3934 +   ----------
3935 +   -- Time --
3936 +   ----------
3937 +
3938 +   Time_Slice_Supported : constant Boolean := True;
3939 +   --  Indicates whether time slicing is supported (i.e SCHED_RR is supported)
3940 +
3941 +   type timespec is private;
3942 +
3943 +   function nanosleep (rqtp, rmtp : access timespec)  return int;
3944 +   pragma Import (C, nanosleep, "nanosleep");
3945 +
3946 +   type clockid_t is new int;
3947 +
3948 +   function clock_gettime
3949 +     (clock_id : clockid_t;
3950 +      tp       : access timespec)
3951 +      return int;
3952 +   pragma Import (C, clock_gettime, "clock_gettime");
3953 +
3954 +   function To_Duration (TS : timespec) return Duration;
3955 +   pragma Inline (To_Duration);
3956 +
3957 +   function To_Timespec (D : Duration) return timespec;
3958 +   pragma Inline (To_Timespec);
3959 +
3960 +   type struct_timezone is record
3961 +      tz_minuteswest : int;
3962 +      tz_dsttime     : int;
3963 +   end record;
3964 +   pragma Convention (C, struct_timezone);
3965 +
3966 +   procedure usleep (useconds : unsigned_long);
3967 +   pragma Import (C, usleep, "usleep");
3968 +
3969 +   -------------------------
3970 +   -- Priority Scheduling --
3971 +   -------------------------
3972 +
3973 +   SCHED_FIFO  : constant := 1;
3974 +   SCHED_OTHER : constant := 2;
3975 +   SCHED_RR    : constant := 3;
3976 +
3977 +   function To_Target_Priority
3978 +     (Prio : System.Any_Priority) return Interfaces.C.int;
3979 +   --  Maps System.Any_Priority to a POSIX priority
3980 +
3981 +   -------------
3982 +   -- Process --
3983 +   -------------
3984 +
3985 +   type pid_t is private;
3986 +
3987 +   function kill (pid : pid_t; sig : Signal) return int;
3988 +   pragma Import (C, kill, "kill");
3989 +
3990 +   function getpid return pid_t;
3991 +   pragma Import (C, getpid, "getpid");
3992 +
3993 +   ---------
3994 +   -- LWP --
3995 +   ---------
3996 +
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");
4002 +
4003 +   -------------
4004 +   -- Threads --
4005 +   -------------
4006 +
4007 +   type Thread_Body is access
4008 +     function (arg : System.Address) return System.Address;
4009 +   pragma Convention (C, Thread_Body);
4010 +
4011 +   function Thread_Body_Access is new
4012 +     Ada.Unchecked_Conversion (System.Address, Thread_Body);
4013 +
4014 +   type pthread_t           is private;
4015 +   subtype Thread_Id        is pthread_t;
4016 +
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;
4023 +
4024 +   PTHREAD_CREATE_DETACHED : constant := 1;
4025 +   PTHREAD_CREATE_JOINABLE : constant := 0;
4026 +
4027 +   PTHREAD_SCOPE_PROCESS : constant := 0;
4028 +   PTHREAD_SCOPE_SYSTEM  : constant := 2;
4029 +
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].
4034 +
4035 +   subtype pthread_rwlock_t     is pthread_mutex_t;
4036 +   subtype pthread_rwlockattr_t is pthread_mutexattr_t;
4037 +
4038 +   -----------
4039 +   -- Stack --
4040 +   -----------
4041 +
4042 +   type stack_t is record
4043 +      ss_sp    : System.Address;
4044 +      ss_size  : size_t;
4045 +      ss_flags : int;
4046 +   end record;
4047 +   pragma Convention (C, stack_t);
4048 +
4049 +   function sigaltstack
4050 +     (ss  : not null access stack_t;
4051 +      oss : access stack_t) return int;
4052 +   pragma Import (C, sigaltstack, "sigaltstack");
4053 +
4054 +   Alternate_Stack : aliased System.Address;
4055 +   --  This is a dummy definition, never used (Alternate_Stack_Size is null)
4056 +
4057 +   Alternate_Stack_Size : constant := 0;
4058 +   --  No alternate signal stack is used on this platform
4059 +
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.
4065 +
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.
4070 +
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
4075 +
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;
4083 +
4084 +   function mprotect (addr : Address; len : size_t; prot : int) return int;
4085 +   pragma Import (C, mprotect);
4086 +
4087 +   ---------------------------------------
4088 +   -- Nonstandard Thread Initialization --
4089 +   ---------------------------------------
4090 +
4091 +   --  FSU_THREADS requires pthread_init, which is nonstandard and this should
4092 +   --  be invoked during the elaboration of s-taprop.adb.
4093 +
4094 +   --  FreeBSD does not require this so we provide an empty Ada body
4095 +
4096 +   procedure pthread_init;
4097 +
4098 +   -------------------------
4099 +   -- POSIX.1c  Section 3 --
4100 +   -------------------------
4101 +
4102 +   function sigwait
4103 +     (set : access sigset_t;
4104 +      sig : access Signal) return int;
4105 +   pragma Import (C, sigwait, "sigwait");
4106 +
4107 +   function pthread_kill
4108 +     (thread : pthread_t;
4109 +      sig    : Signal) return int;
4110 +   pragma Import (C, pthread_kill, "pthread_kill");
4111 +
4112 +   function pthread_sigmask
4113 +     (how  : int;
4114 +      set  : access sigset_t;
4115 +      oset : access sigset_t) return int;
4116 +   pragma Import (C, pthread_sigmask, "pthread_sigmask");
4117 +
4118 +   --------------------------
4119 +   -- POSIX.1c  Section 11 --
4120 +   --------------------------
4121 +
4122 +   function pthread_mutexattr_init
4123 +     (attr : access pthread_mutexattr_t) return int;
4124 +   pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
4125 +
4126 +   function pthread_mutexattr_destroy
4127 +     (attr : access pthread_mutexattr_t) return int;
4128 +   pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
4129 +
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");
4134 +
4135 +   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
4136 +   pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
4137 +
4138 +   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
4139 +   pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
4140 +
4141 +   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
4142 +   pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
4143 +
4144 +   function pthread_condattr_init
4145 +     (attr : access pthread_condattr_t) return int;
4146 +   pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
4147 +
4148 +   function pthread_condattr_destroy
4149 +     (attr : access pthread_condattr_t) return int;
4150 +   pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
4151 +
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");
4156 +
4157 +   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
4158 +   pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
4159 +
4160 +   function pthread_cond_signal (cond : access pthread_cond_t) return int;
4161 +   pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
4162 +
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");
4167 +
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");
4173 +
4174 +   Relative_Timed_Wait : constant Boolean := False;
4175 +   --  pthread_cond_timedwait requires an absolute delay time
4176 +
4177 +   --------------------------
4178 +   -- POSIX.1c  Section 13 --
4179 +   --------------------------
4180 +
4181 +   PTHREAD_PRIO_NONE    : constant := 0;
4182 +   PTHREAD_PRIO_PROTECT : constant := 2;
4183 +   PTHREAD_PRIO_INHERIT : constant := 1;
4184 +
4185 +   function pthread_mutexattr_setprotocol
4186 +     (attr     : access pthread_mutexattr_t;
4187 +      protocol : int) return int;
4188 +   pragma Import
4189 +      (C, pthread_mutexattr_setprotocol, "pthread_mutexattr_setprotocol");
4190 +
4191 +   function pthread_mutexattr_getprotocol
4192 +     (attr     : access pthread_mutexattr_t;
4193 +      protocol : access int) return int;
4194 +   pragma Import
4195 +     (C, pthread_mutexattr_getprotocol, "pthread_mutexattr_getprotocol");
4196 +
4197 +   function pthread_mutexattr_setprioceiling
4198 +     (attr     : access pthread_mutexattr_t;
4199 +      prioceiling : int) return int;
4200 +   pragma Import
4201 +     (C, pthread_mutexattr_setprioceiling,
4202 +      "pthread_mutexattr_setprioceiling");
4203 +
4204 +   function pthread_mutexattr_getprioceiling
4205 +     (attr     : access pthread_mutexattr_t;
4206 +      prioceiling : access int) return int;
4207 +   pragma Import
4208 +     (C, pthread_mutexattr_getprioceiling,
4209 +      "pthread_mutexattr_getprioceiling");
4210 +
4211 +   type struct_sched_param is record
4212 +      sched_priority : int;
4213 +   end record;
4214 +   pragma Convention (C, struct_sched_param);
4215 +
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");
4221 +
4222 +   function pthread_setschedparam
4223 +     (thread : pthread_t;
4224 +      policy : int;
4225 +      param  : access struct_sched_param) return int;
4226 +   pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
4227 +
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");
4232 +
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");
4237 +
4238 +   function pthread_attr_setinheritsched
4239 +     (attr            : access pthread_attr_t;
4240 +      inheritsched : int) return int;
4241 +   pragma Import
4242 +     (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
4243 +
4244 +   function pthread_attr_getinheritsched
4245 +     (attr         : access pthread_attr_t;
4246 +      inheritsched : access int) return int;
4247 +   pragma Import
4248 +     (C, pthread_attr_getinheritsched, "pthread_attr_getinheritsched");
4249 +
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");
4255 +
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");
4261 +
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");
4266 +
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");
4271 +
4272 +   function sched_yield return int;
4273 +   pragma Import (C, sched_yield, "pthread_yield");
4274 +
4275 +   --------------------------
4276 +   -- P1003.1c  Section 16 --
4277 +   --------------------------
4278 +
4279 +   function pthread_attr_init (attributes : access pthread_attr_t) return int;
4280 +   pragma Import (C, pthread_attr_init, "pthread_attr_init");
4281 +
4282 +   function pthread_attr_destroy
4283 +     (attributes : access pthread_attr_t) return int;
4284 +   pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
4285 +
4286 +   function pthread_attr_setdetachstate
4287 +     (attr        : access pthread_attr_t;
4288 +      detachstate : int) return int;
4289 +   pragma Import
4290 +     (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
4291 +
4292 +   function pthread_attr_getdetachstate
4293 +     (attr        : access pthread_attr_t;
4294 +      detachstate : access int) return int;
4295 +   pragma Import
4296 +     (C, pthread_attr_getdetachstate, "pthread_attr_getdetachstate");
4297 +
4298 +   function pthread_attr_getstacksize
4299 +     (attr      : access pthread_attr_t;
4300 +      stacksize : access size_t) return int;
4301 +   pragma Import
4302 +     (C, pthread_attr_getstacksize, "pthread_attr_getstacksize");
4303 +
4304 +   function pthread_attr_setstacksize
4305 +     (attr      : access pthread_attr_t;
4306 +      stacksize : size_t) return int;
4307 +   pragma Import
4308 +     (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
4309 +
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");
4316 +
4317 +   function pthread_detach (thread : pthread_t) return int;
4318 +   pragma Import (C, pthread_detach, "pthread_detach");
4319 +
4320 +   procedure pthread_exit (status : System.Address);
4321 +   pragma Import (C, pthread_exit, "pthread_exit");
4322 +
4323 +   function pthread_self return pthread_t;
4324 +   pragma Import (C, pthread_self, "pthread_self");
4325 +
4326 +   --------------------------
4327 +   -- POSIX.1c  Section 17 --
4328 +   --------------------------
4329 +
4330 +   function pthread_setspecific
4331 +     (key   : pthread_key_t;
4332 +      value : System.Address) return  int;
4333 +   pragma Import (C, pthread_setspecific, "pthread_setspecific");
4334 +
4335 +   function pthread_getspecific (key : pthread_key_t) return System.Address;
4336 +   pragma Import (C, pthread_getspecific, "pthread_getspecific");
4337 +
4338 +   type destructor_pointer is access procedure (arg : System.Address);
4339 +   pragma Convention (C, destructor_pointer);
4340 +
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");
4345 +
4346 +   ------------------------------------
4347 +   -- Non-portable Pthread Functions --
4348 +   ------------------------------------
4349 +
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");
4354 +
4355 +private
4356 +
4357 +   type sigset_t is array (1 .. 4) of unsigned;
4358 +
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
4363 +
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.
4369 +
4370 +   type struct_sigcontext is null record;
4371 +   pragma Convention (C, struct_sigcontext);
4372 +
4373 +   type pid_t is new int;
4374 +
4375 +   type time_t is new int;
4376 +
4377 +   type timespec is record
4378 +      tv_sec  : time_t;
4379 +      tv_nsec : long;
4380 +   end record;
4381 +   pragma Convention (C, timespec);
4382 +
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;
4390 +
4391 +end System.OS_Interface;
4392 --- /dev/null
4393 +++ gcc/ada/s-osinte-freebsd64.ads
4394 @@ -0,0 +1,649 @@
4395 +------------------------------------------------------------------------------
4396 +--                                                                          --
4397 +--                  GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                --
4398 +--                                                                          --
4399 +--                   S Y S T E M . O S _ I N T E R F A C E                  --
4400 +--                                                                          --
4401 +--                                   S p e c                                --
4402 +--                                                                          --
4403 +--             Copyright (C) 1991-1994, Florida State University            --
4404 +--          Copyright (C) 1995-2011, Free Software Foundation, Inc.         --
4405 +--                                                                          --
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.                                     --
4412 +--                                                                          --
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.               --
4416 +--                                                                          --
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/>.                                          --
4421 +--                                                                          --
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).                                  --
4425 +--                                                                          --
4426 +------------------------------------------------------------------------------
4427 +
4428 +--  This is the FreeBSD PTHREADS version of this package
4429 +
4430 +--  This package encapsulates all direct interfaces to OS services
4431 +--  that are needed by the tasking run-time (libgnarl).
4432 +
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.
4435 +
4436 +with Ada.Unchecked_Conversion;
4437 +
4438 +with Interfaces.C;
4439 +
4440 +package System.OS_Interface is
4441 +   pragma Preelaborate;
4442 +
4443 +   pragma Linker_Options ("-pthread");
4444 +
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;
4455 +
4456 +   -----------
4457 +   -- Errno --
4458 +   -----------
4459 +
4460 +   function Errno return int;
4461 +   pragma Inline (Errno);
4462 +
4463 +   EAGAIN    : constant := 35;
4464 +   EINTR     : constant := 4;
4465 +   EINVAL    : constant := 22;
4466 +   ENOMEM    : constant := 12;
4467 +   ETIMEDOUT : constant := 60;
4468 +
4469 +   -------------
4470 +   -- Signals --
4471 +   -------------
4472 +
4473 +   Max_Interrupt : constant := 31;
4474 +   type Signal is new int range 0 .. Max_Interrupt;
4475 +   for Signal'Size use int'Size;
4476 +
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
4510 +
4511 +   SIGADAABORT : constant := SIGABRT;
4512 +   --  Change this if you want to use another signal for task abort.
4513 +   --  SIGTERM might be a good one.
4514 +
4515 +   type Signal_Set is array (Natural range <>) of Signal;
4516 +
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);
4522 +
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);
4526 +
4527 +   type sigset_t is private;
4528 +
4529 +   function sigaddset
4530 +     (set : access sigset_t;
4531 +      sig : Signal) return int;
4532 +   pragma Import (C, sigaddset, "sigaddset");
4533 +
4534 +   function sigdelset
4535 +     (set : access sigset_t;
4536 +      sig : Signal) return int;
4537 +   pragma Import (C, sigdelset, "sigdelset");
4538 +
4539 +   function sigfillset (set : access sigset_t) return int;
4540 +   pragma Import (C, sigfillset, "sigfillset");
4541 +
4542 +   function sigismember
4543 +     (set : access sigset_t;
4544 +      sig : Signal) return int;
4545 +   pragma Import (C, sigismember, "sigismember");
4546 +
4547 +   function sigemptyset (set : access sigset_t) return int;
4548 +   pragma Import (C, sigemptyset, "sigemptyset");
4549 +
4550 +   --  sigcontext is architecture dependent, so define it private
4551 +   type struct_sigcontext is private;
4552 +
4553 +   type old_struct_sigaction is record
4554 +      sa_handler : System.Address;
4555 +      sa_mask    : sigset_t;
4556 +      sa_flags   : int;
4557 +   end record;
4558 +   pragma Convention (C, old_struct_sigaction);
4559 +
4560 +   type new_struct_sigaction is record
4561 +      sa_handler : System.Address;
4562 +      sa_flags   : int;
4563 +      sa_mask    : sigset_t;
4564 +   end record;
4565 +   pragma Convention (C, new_struct_sigaction);
4566 +
4567 +   subtype struct_sigaction is new_struct_sigaction;
4568 +   type struct_sigaction_ptr is access all struct_sigaction;
4569 +
4570 +   SIG_BLOCK   : constant := 1;
4571 +   SIG_UNBLOCK : constant := 2;
4572 +   SIG_SETMASK : constant := 3;
4573 +
4574 +   SIG_DFL : constant := 0;
4575 +   SIG_IGN : constant := 1;
4576 +
4577 +   SA_SIGINFO : constant := 16#0040#;
4578 +   SA_ONSTACK : constant := 16#0001#;
4579 +
4580 +   function sigaction
4581 +     (sig  : Signal;
4582 +      act  : struct_sigaction_ptr;
4583 +      oact : struct_sigaction_ptr) return int;
4584 +   pragma Import (C, sigaction, "sigaction");
4585 +
4586 +   ----------
4587 +   -- Time --
4588 +   ----------
4589 +
4590 +   Time_Slice_Supported : constant Boolean := True;
4591 +   --  Indicates whether time slicing is supported (i.e SCHED_RR is supported)
4592 +
4593 +   type timespec is private;
4594 +
4595 +   function nanosleep (rqtp, rmtp : access timespec)  return int;
4596 +   pragma Import (C, nanosleep, "nanosleep");
4597 +
4598 +   type clockid_t is new int;
4599 +
4600 +   function clock_gettime
4601 +     (clock_id : clockid_t;
4602 +      tp       : access timespec)
4603 +      return int;
4604 +   pragma Import (C, clock_gettime, "clock_gettime");
4605 +
4606 +   function To_Duration (TS : timespec) return Duration;
4607 +   pragma Inline (To_Duration);
4608 +
4609 +   function To_Timespec (D : Duration) return timespec;
4610 +   pragma Inline (To_Timespec);
4611 +
4612 +   type struct_timezone is record
4613 +      tz_minuteswest : int;
4614 +      tz_dsttime     : int;
4615 +   end record;
4616 +   pragma Convention (C, struct_timezone);
4617 +
4618 +   procedure usleep (useconds : unsigned_long);
4619 +   pragma Import (C, usleep, "usleep");
4620 +
4621 +   -------------------------
4622 +   -- Priority Scheduling --
4623 +   -------------------------
4624 +
4625 +   SCHED_FIFO  : constant := 1;
4626 +   SCHED_OTHER : constant := 2;
4627 +   SCHED_RR    : constant := 3;
4628 +
4629 +   function To_Target_Priority
4630 +     (Prio : System.Any_Priority) return Interfaces.C.int;
4631 +   --  Maps System.Any_Priority to a POSIX priority
4632 +
4633 +   -------------
4634 +   -- Process --
4635 +   -------------
4636 +
4637 +   type pid_t is private;
4638 +
4639 +   function kill (pid : pid_t; sig : Signal) return int;
4640 +   pragma Import (C, kill, "kill");
4641 +
4642 +   function getpid return pid_t;
4643 +   pragma Import (C, getpid, "getpid");
4644 +
4645 +   ---------
4646 +   -- LWP --
4647 +   ---------
4648 +
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");
4654 +
4655 +   -------------
4656 +   -- Threads --
4657 +   -------------
4658 +
4659 +   type Thread_Body is access
4660 +     function (arg : System.Address) return System.Address;
4661 +   pragma Convention (C, Thread_Body);
4662 +
4663 +   function Thread_Body_Access is new
4664 +     Ada.Unchecked_Conversion (System.Address, Thread_Body);
4665 +
4666 +   type pthread_t           is private;
4667 +   subtype Thread_Id        is pthread_t;
4668 +
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;
4675 +
4676 +   PTHREAD_CREATE_DETACHED : constant := 1;
4677 +   PTHREAD_CREATE_JOINABLE : constant := 0;
4678 +
4679 +   PTHREAD_SCOPE_PROCESS : constant := 0;
4680 +   PTHREAD_SCOPE_SYSTEM  : constant := 2;
4681 +
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].
4686 +
4687 +   subtype pthread_rwlock_t     is pthread_mutex_t;
4688 +   subtype pthread_rwlockattr_t is pthread_mutexattr_t;
4689 +
4690 +   -----------
4691 +   -- Stack --
4692 +   -----------
4693 +
4694 +   type stack_t is record
4695 +      ss_sp    : System.Address;
4696 +      ss_size  : size_t;
4697 +      ss_flags : int;
4698 +   end record;
4699 +   pragma Convention (C, stack_t);
4700 +
4701 +   function sigaltstack
4702 +     (ss  : not null access stack_t;
4703 +      oss : access stack_t) return int;
4704 +   pragma Import (C, sigaltstack, "sigaltstack");
4705 +
4706 +   Alternate_Stack : aliased System.Address;
4707 +   --  This is a dummy definition, never used (Alternate_Stack_Size is null)
4708 +
4709 +   Alternate_Stack_Size : constant := 0;
4710 +   --  No alternate signal stack is used on this platform
4711 +
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.
4717 +
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.
4722 +
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
4727 +
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;
4735 +
4736 +   function mprotect (addr : Address; len : size_t; prot : int) return int;
4737 +   pragma Import (C, mprotect);
4738 +
4739 +   ---------------------------------------
4740 +   -- Nonstandard Thread Initialization --
4741 +   ---------------------------------------
4742 +
4743 +   --  FSU_THREADS requires pthread_init, which is nonstandard and this should
4744 +   --  be invoked during the elaboration of s-taprop.adb.
4745 +
4746 +   --  FreeBSD does not require this so we provide an empty Ada body
4747 +
4748 +   procedure pthread_init;
4749 +
4750 +   -------------------------
4751 +   -- POSIX.1c  Section 3 --
4752 +   -------------------------
4753 +
4754 +   function sigwait
4755 +     (set : access sigset_t;
4756 +      sig : access Signal) return int;
4757 +   pragma Import (C, sigwait, "sigwait");
4758 +
4759 +   function pthread_kill
4760 +     (thread : pthread_t;
4761 +      sig    : Signal) return int;
4762 +   pragma Import (C, pthread_kill, "pthread_kill");
4763 +
4764 +   function pthread_sigmask
4765 +     (how  : int;
4766 +      set  : access sigset_t;
4767 +      oset : access sigset_t) return int;
4768 +   pragma Import (C, pthread_sigmask, "pthread_sigmask");
4769 +
4770 +   --------------------------
4771 +   -- POSIX.1c  Section 11 --
4772 +   --------------------------
4773 +
4774 +   function pthread_mutexattr_init
4775 +     (attr : access pthread_mutexattr_t) return int;
4776 +   pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
4777 +
4778 +   function pthread_mutexattr_destroy
4779 +     (attr : access pthread_mutexattr_t) return int;
4780 +   pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
4781 +
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");
4786 +
4787 +   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
4788 +   pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
4789 +
4790 +   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
4791 +   pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
4792 +
4793 +   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
4794 +   pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
4795 +
4796 +   function pthread_condattr_init
4797 +     (attr : access pthread_condattr_t) return int;
4798 +   pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
4799 +
4800 +   function pthread_condattr_destroy
4801 +     (attr : access pthread_condattr_t) return int;
4802 +   pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
4803 +
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");
4808 +
4809 +   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
4810 +   pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
4811 +
4812 +   function pthread_cond_signal (cond : access pthread_cond_t) return int;
4813 +   pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
4814 +
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");
4819 +
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");
4825 +
4826 +   Relative_Timed_Wait : constant Boolean := False;
4827 +   --  pthread_cond_timedwait requires an absolute delay time
4828 +
4829 +   --------------------------
4830 +   -- POSIX.1c  Section 13 --
4831 +   --------------------------
4832 +
4833 +   PTHREAD_PRIO_NONE    : constant := 0;
4834 +   PTHREAD_PRIO_PROTECT : constant := 2;
4835 +   PTHREAD_PRIO_INHERIT : constant := 1;
4836 +
4837 +   function pthread_mutexattr_setprotocol
4838 +     (attr     : access pthread_mutexattr_t;
4839 +      protocol : int) return int;
4840 +   pragma Import
4841 +      (C, pthread_mutexattr_setprotocol, "pthread_mutexattr_setprotocol");
4842 +
4843 +   function pthread_mutexattr_getprotocol
4844 +     (attr     : access pthread_mutexattr_t;
4845 +      protocol : access int) return int;
4846 +   pragma Import
4847 +     (C, pthread_mutexattr_getprotocol, "pthread_mutexattr_getprotocol");
4848 +
4849 +   function pthread_mutexattr_setprioceiling
4850 +     (attr     : access pthread_mutexattr_t;
4851 +      prioceiling : int) return int;
4852 +   pragma Import
4853 +     (C, pthread_mutexattr_setprioceiling,
4854 +      "pthread_mutexattr_setprioceiling");
4855 +
4856 +   function pthread_mutexattr_getprioceiling
4857 +     (attr     : access pthread_mutexattr_t;
4858 +      prioceiling : access int) return int;
4859 +   pragma Import
4860 +     (C, pthread_mutexattr_getprioceiling,
4861 +      "pthread_mutexattr_getprioceiling");
4862 +
4863 +   type struct_sched_param is record
4864 +      sched_priority : int;
4865 +   end record;
4866 +   pragma Convention (C, struct_sched_param);
4867 +
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");
4873 +
4874 +   function pthread_setschedparam
4875 +     (thread : pthread_t;
4876 +      policy : int;
4877 +      param  : access struct_sched_param) return int;
4878 +   pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
4879 +
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");
4884 +
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");
4889 +
4890 +   function pthread_attr_setinheritsched
4891 +     (attr            : access pthread_attr_t;
4892 +      inheritsched : int) return int;
4893 +   pragma Import
4894 +     (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
4895 +
4896 +   function pthread_attr_getinheritsched
4897 +     (attr         : access pthread_attr_t;
4898 +      inheritsched : access int) return int;
4899 +   pragma Import
4900 +     (C, pthread_attr_getinheritsched, "pthread_attr_getinheritsched");
4901 +
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");
4907 +
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");
4913 +
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");
4918 +
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");
4923 +
4924 +   function sched_yield return int;
4925 +   pragma Import (C, sched_yield, "pthread_yield");
4926 +
4927 +   --------------------------
4928 +   -- P1003.1c  Section 16 --
4929 +   --------------------------
4930 +
4931 +   function pthread_attr_init (attributes : access pthread_attr_t) return int;
4932 +   pragma Import (C, pthread_attr_init, "pthread_attr_init");
4933 +
4934 +   function pthread_attr_destroy
4935 +     (attributes : access pthread_attr_t) return int;
4936 +   pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
4937 +
4938 +   function pthread_attr_setdetachstate
4939 +     (attr        : access pthread_attr_t;
4940 +      detachstate : int) return int;
4941 +   pragma Import
4942 +     (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
4943 +
4944 +   function pthread_attr_getdetachstate
4945 +     (attr        : access pthread_attr_t;
4946 +      detachstate : access int) return int;
4947 +   pragma Import
4948 +     (C, pthread_attr_getdetachstate, "pthread_attr_getdetachstate");
4949 +
4950 +   function pthread_attr_getstacksize
4951 +     (attr      : access pthread_attr_t;
4952 +      stacksize : access size_t) return int;
4953 +   pragma Import
4954 +     (C, pthread_attr_getstacksize, "pthread_attr_getstacksize");
4955 +
4956 +   function pthread_attr_setstacksize
4957 +     (attr      : access pthread_attr_t;
4958 +      stacksize : size_t) return int;
4959 +   pragma Import
4960 +     (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
4961 +
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");
4968 +
4969 +   function pthread_detach (thread : pthread_t) return int;
4970 +   pragma Import (C, pthread_detach, "pthread_detach");
4971 +
4972 +   procedure pthread_exit (status : System.Address);
4973 +   pragma Import (C, pthread_exit, "pthread_exit");
4974 +
4975 +   function pthread_self return pthread_t;
4976 +   pragma Import (C, pthread_self, "pthread_self");
4977 +
4978 +   --------------------------
4979 +   -- POSIX.1c  Section 17 --
4980 +   --------------------------
4981 +
4982 +   function pthread_setspecific
4983 +     (key   : pthread_key_t;
4984 +      value : System.Address) return  int;
4985 +   pragma Import (C, pthread_setspecific, "pthread_setspecific");
4986 +
4987 +   function pthread_getspecific (key : pthread_key_t) return System.Address;
4988 +   pragma Import (C, pthread_getspecific, "pthread_getspecific");
4989 +
4990 +   type destructor_pointer is access procedure (arg : System.Address);
4991 +   pragma Convention (C, destructor_pointer);
4992 +
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");
4997 +
4998 +   ------------------------------------
4999 +   -- Non-portable Pthread Functions --
5000 +   ------------------------------------
5001 +
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");
5006 +
5007 +private
5008 +
5009 +   type sigset_t is array (1 .. 4) of unsigned;
5010 +
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
5015 +
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.
5021 +
5022 +   type struct_sigcontext is null record;
5023 +   pragma Convention (C, struct_sigcontext);
5024 +
5025 +   type pid_t is new int;
5026 +
5027 +   type time_t is new int64_t;
5028 +
5029 +   type timespec is record
5030 +      tv_sec  : time_t;
5031 +      tv_nsec : long;
5032 +   end record;
5033 +   pragma Convention (C, timespec);
5034 +
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;
5042 +
5043 +end System.OS_Interface;
5044 --- /dev/null
5045 +++ gcc/ada/s-osinte-netbsd.adb
5046 @@ -0,0 +1,140 @@
5047 +------------------------------------------------------------------------------
5048 +--                                                                          --
5049 +--                  GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                --
5050 +--                                                                          --
5051 +--                   S Y S T E M . O S _ I N T E R F A C E                  --
5052 +--                                                                          --
5053 +--                                   B o d y                                --
5054 +--                                                                          --
5055 +--          Copyright (C) 1991-2009, Free Software Foundation, Inc.         --
5056 +--                                                                          --
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.                                     --
5063 +--                                                                          --
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.               --
5067 +--                                                                          --
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/>.                                          --
5072 +--                                                                          --
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).                                  --
5076 +--                                                                          --
5077 +------------------------------------------------------------------------------
5078 +
5079 +--  This is the NetBSD THREADS version of this package
5080 +
5081 +with Interfaces.C; use Interfaces.C;
5082 +
5083 +package body System.OS_Interface is
5084 +
5085 +   -----------
5086 +   -- Errno --
5087 +   -----------
5088 +
5089 +   function Errno return int is
5090 +      type int_ptr is access all int;
5091 +
5092 +      function internal_errno return int_ptr;
5093 +      pragma Import (C, internal_errno, "__errno");
5094 +
5095 +   begin
5096 +      return (internal_errno.all);
5097 +   end Errno;
5098 +
5099 +   --------------------
5100 +   -- Get_Stack_Base --
5101 +   --------------------
5102 +
5103 +   function Get_Stack_Base (thread : pthread_t) return Address is
5104 +      pragma Unreferenced (thread);
5105 +   begin
5106 +      return Null_Address;
5107 +   end Get_Stack_Base;
5108 +
5109 +   ------------------
5110 +   -- pthread_init --
5111 +   ------------------
5112 +
5113 +   procedure pthread_init is
5114 +   begin
5115 +      null;
5116 +   end pthread_init;
5117 +
5118 +   -----------------------------------
5119 +   -- pthread_mutexattr_setprotocol --
5120 +   -----------------------------------
5121 +
5122 +   function pthread_mutexattr_setprotocol
5123 +     (attr     : access pthread_mutexattr_t;
5124 +      protocol : int) return int is
5125 +      pragma Unreferenced (attr, protocol);
5126 +   begin
5127 +      return 0;
5128 +   end pthread_mutexattr_setprotocol;
5129 +
5130 +   --------------------------------------
5131 +   -- pthread_mutexattr_setprioceiling --
5132 +   --------------------------------------
5133 +
5134 +   function pthread_mutexattr_setprioceiling
5135 +     (attr     : access pthread_mutexattr_t;
5136 +      prioceiling : int) return int is
5137 +      pragma Unreferenced (attr, prioceiling);
5138 +   begin
5139 +      return 0;
5140 +   end pthread_mutexattr_setprioceiling;
5141 +
5142 +   -----------------
5143 +   -- To_Duration --
5144 +   -----------------
5145 +
5146 +   function To_Duration (TS : timespec) return Duration is
5147 +   begin
5148 +      return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
5149 +   end To_Duration;
5150 +
5151 +   ------------------------
5152 +   -- To_Target_Priority --
5153 +   ------------------------
5154 +
5155 +   function To_Target_Priority
5156 +     (Prio : System.Any_Priority) return Interfaces.C.int
5157 +   is
5158 +   begin
5159 +      return Interfaces.C.int (Prio);
5160 +   end To_Target_Priority;
5161 +
5162 +   -----------------
5163 +   -- To_Timespec --
5164 +   -----------------
5165 +
5166 +   function To_Timespec (D : Duration) return timespec is
5167 +      S : time_t;
5168 +      F : Duration;
5169 +
5170 +   begin
5171 +      S := time_t (Long_Long_Integer (D));
5172 +      F := D - Duration (S);
5173 +
5174 +      --  If F has negative value due to a round-up, adjust for positive F
5175 +      --  value.
5176 +
5177 +      if F < 0.0 then
5178 +         S := S - 1;
5179 +         F := F + 1.0;
5180 +      end if;
5181 +
5182 +      return timespec'(tv_sec => S,
5183 +                       tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
5184 +   end To_Timespec;
5185 +
5186 +end System.OS_Interface;
5187 --- /dev/null
5188 +++ gcc/ada/s-osinte-netbsd.ads
5189 @@ -0,0 +1,674 @@
5190 +------------------------------------------------------------------------------
5191 +--                                                                          --
5192 +--                  GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                --
5193 +--                                                                          --
5194 +--                   S Y S T E M . O S _ I N T E R F A C E                  --
5195 +--                                                                          --
5196 +--                                   S p e c                                --
5197 +--                                                                          --
5198 +--             Copyright (C) 1991-1994, Florida State University            --
5199 +--          Copyright (C) 1995-2011, Free Software Foundation, Inc.         --
5200 +--                                                                          --
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.                                     --
5207 +--                                                                          --
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.               --
5211 +--                                                                          --
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/>.                                          --
5216 +--                                                                          --
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).                                  --
5220 +--                                                                          --
5221 +------------------------------------------------------------------------------
5222 +
5223 +--  This is the NetBSD PTHREADS version of this package.
5224 +--  It is based off of the FreeBSD PTHREADS as of 4.2.3.
5225 +
5226 +--  This package encapsulates all direct interfaces to OS services
5227 +--  that are needed by the tasking run-time (libgnarl).
5228 +
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.
5231 +
5232 +with Ada.Unchecked_Conversion;
5233 +
5234 +with Interfaces.C;
5235 +
5236 +package System.OS_Interface is
5237 +   pragma Preelaborate;
5238 +
5239 +   pragma Linker_Options ("-pthread");
5240 +
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;
5250 +
5251 +   -----------
5252 +   -- Errno --
5253 +   -----------
5254 +
5255 +   function Errno return int;
5256 +   pragma Inline (Errno);
5257 +
5258 +   EAGAIN    : constant := 35;
5259 +   EINTR     : constant := 4;
5260 +   EINVAL    : constant := 22;
5261 +   ENOMEM    : constant := 12;
5262 +   ETIMEDOUT : constant := 60;
5263 +
5264 +   -------------
5265 +   -- Signals --
5266 +   -------------
5267 +
5268 +   Max_Interrupt : constant := 63;
5269 +   type Signal is new int range 0 .. Max_Interrupt;
5270 +   for Signal'Size use int'Size;
5271 +
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)
5306 +
5307 +   SIGADAABORT : constant := SIGABRT;
5308 +   --  Change this if you want to use another signal for task abort.
5309 +   --  SIGTERM might be a good one.
5310 +
5311 +   type Signal_Set is array (Natural range <>) of Signal;
5312 +
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);
5318 +
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);
5322 +
5323 +   type sigset_t is private;
5324 +
5325 +   function sigaddset
5326 +     (set : access sigset_t;
5327 +      sig : Signal) return int;
5328 +   pragma Import (C, sigaddset, "__sigaddset14");
5329 +
5330 +   function sigdelset
5331 +     (set : access sigset_t;
5332 +      sig : Signal) return int;
5333 +   pragma Import (C, sigdelset, "__sigdelset14");
5334 +
5335 +   function sigfillset (set : access sigset_t) return int;
5336 +   pragma Import (C, sigfillset, "__sigfillset14");
5337 +
5338 +   function sigismember
5339 +     (set : access sigset_t;
5340 +      sig : Signal) return int;
5341 +   pragma Import (C, sigismember, "__sigismember14");
5342 +
5343 +   function sigemptyset (set : access sigset_t) return int;
5344 +   pragma Import (C, sigemptyset, "__sigemptyset14");
5345 +
5346 +   --  sigcontext is architecture dependent, so define it private
5347 +   type struct_sigcontext is private;
5348 +
5349 +   type old_struct_sigaction is record
5350 +      sa_handler : System.Address;
5351 +      sa_mask    : sigset_t;
5352 +      sa_flags   : int;
5353 +   end record;
5354 +   pragma Convention (C, old_struct_sigaction);
5355 +
5356 +   type new_struct_sigaction is record
5357 +      sa_handler : System.Address;
5358 +      sa_flags   : int;
5359 +      sa_mask    : sigset_t;
5360 +   end record;
5361 +   pragma Convention (C, new_struct_sigaction);
5362 +
5363 +   subtype struct_sigaction is new_struct_sigaction;
5364 +   type struct_sigaction_ptr is access all struct_sigaction;
5365 +
5366 +   SIG_BLOCK   : constant := 1;
5367 +   SIG_UNBLOCK : constant := 2;
5368 +   SIG_SETMASK : constant := 3;
5369 +
5370 +   SIG_DFL  : constant := 0;
5371 +   SIG_IGN  : constant := 1;
5372 +   SIG_ERR  : constant := -1;
5373 +   SIG_HOLD : constant := 3;
5374 +
5375 +   SA_SIGINFO : constant := 16#0040#;
5376 +   SA_ONSTACK : constant := 16#0001#;
5377 +
5378 +   function sigaction
5379 +     (sig  : Signal;
5380 +      act  : struct_sigaction_ptr;
5381 +      oact : struct_sigaction_ptr) return int;
5382 +   pragma Import (C, sigaction, "__sigaction14");
5383 +
5384 +   ----------
5385 +   -- Time --
5386 +   ----------
5387 +
5388 +   Time_Slice_Supported : constant Boolean := True;
5389 +   --  Indicates whether time slicing is supported (i.e SCHED_RR is supported)
5390 +
5391 +   type timespec is private;
5392 +
5393 +   function nanosleep (rqtp, rmtp : access timespec)  return int;
5394 +   pragma Import (C, nanosleep, "nanosleep");
5395 +
5396 +   type clockid_t is new int;
5397 +
5398 +   function clock_gettime
5399 +     (clock_id : clockid_t;
5400 +      tp       : access timespec)
5401 +      return int;
5402 +   pragma Import (C, clock_gettime, "clock_gettime");
5403 +
5404 +   function To_Duration (TS : timespec) return Duration;
5405 +   pragma Inline (To_Duration);
5406 +
5407 +   function To_Timespec (D : Duration) return timespec;
5408 +   pragma Inline (To_Timespec);
5409 +
5410 +   type struct_timezone is record
5411 +      tz_minuteswest : int;
5412 +      tz_dsttime     : int;
5413 +   end record;
5414 +   pragma Convention (C, struct_timezone);
5415 +
5416 +   -------------------------
5417 +   -- Priority Scheduling --
5418 +   -------------------------
5419 +
5420 +   SCHED_FIFO  : constant := 1;
5421 +   SCHED_OTHER : constant := 2;
5422 +   SCHED_RR    : constant := 3;
5423 +
5424 +   function To_Target_Priority
5425 +     (Prio : System.Any_Priority) return Interfaces.C.int;
5426 +   --  Maps System.Any_Priority to a POSIX priority
5427 +
5428 +   -------------
5429 +   -- Process --
5430 +   -------------
5431 +
5432 +   type pid_t is private;
5433 +
5434 +   function kill (pid : pid_t; sig : Signal) return int;
5435 +   pragma Import (C, kill, "kill");
5436 +
5437 +   function getpid return pid_t;
5438 +   pragma Import (C, getpid, "getpid");
5439 +
5440 +   ---------
5441 +   -- LWP --
5442 +   ---------
5443 +
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");
5449 +
5450 +   -------------
5451 +   -- Threads --
5452 +   -------------
5453 +
5454 +   type Thread_Body is access
5455 +     function (arg : System.Address) return System.Address;
5456 +   pragma Convention (C, Thread_Body);
5457 +
5458 +   function Thread_Body_Access is new
5459 +     Ada.Unchecked_Conversion (System.Address, Thread_Body);
5460 +
5461 +   type pthread_t           is private;
5462 +   subtype Thread_Id        is pthread_t;
5463 +
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;
5470 +
5471 +   PTHREAD_CREATE_DETACHED : constant := 1;
5472 +   PTHREAD_CREATE_JOINABLE : constant := 0;
5473 +
5474 +   PTHREAD_SCOPE_PROCESS : constant := 0;
5475 +   PTHREAD_SCOPE_SYSTEM  : constant := 2;
5476 +
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].
5481 +
5482 +   subtype pthread_rwlock_t     is pthread_mutex_t;
5483 +   subtype pthread_rwlockattr_t is pthread_mutexattr_t;
5484 +
5485 +   -----------
5486 +   -- Stack --
5487 +   -----------
5488 +
5489 +   type stack_t is record
5490 +      ss_sp    : System.Address;
5491 +      ss_size  : size_t;
5492 +      ss_flags : int;
5493 +   end record;
5494 +   pragma Convention (C, stack_t);
5495 +
5496 +   function sigaltstack
5497 +     (ss  : not null access stack_t;
5498 +      oss : access stack_t) return int;
5499 +   pragma Import (C, sigaltstack, "sigaltstack");
5500 +
5501 +   Alternate_Stack : aliased System.Address;
5502 +   --  This is a dummy definition, never used (Alternate_Stack_Size is null)
5503 +
5504 +   Alternate_Stack_Size : constant := 0;
5505 +   --  No alternate signal stack is used on this platform
5506 +
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.
5512 +
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.
5517 +
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
5522 +
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;
5530 +
5531 +   function mprotect (addr : Address; len : size_t; prot : int) return int;
5532 +   pragma Import (C, mprotect);
5533 +
5534 +   ---------------------------------------
5535 +   -- Nonstandard Thread Initialization --
5536 +   ---------------------------------------
5537 +
5538 +   --  FSU_THREADS requires pthread_init, which is nonstandard and this should
5539 +   --  be invoked during the elaboration of s-taprop.adb.
5540 +
5541 +   --  NetBSD does not require this so we provide an empty Ada body
5542 +
5543 +   procedure pthread_init;
5544 +
5545 +   -------------------------
5546 +   -- POSIX.1c  Section 3 --
5547 +   -------------------------
5548 +
5549 +   function sigwait
5550 +     (set : access sigset_t;
5551 +      sig : access Signal) return int;
5552 +   pragma Import (C, sigwait, "sigwait");
5553 +
5554 +   function pthread_kill
5555 +     (thread : pthread_t;
5556 +      sig    : Signal) return int;
5557 +   pragma Import (C, pthread_kill, "pthread_kill");
5558 +
5559 +   function pthread_sigmask
5560 +     (how  : int;
5561 +      set  : access sigset_t;
5562 +      oset : access sigset_t) return int;
5563 +   pragma Import (C, pthread_sigmask, "pthread_sigmask");
5564 +
5565 +   --------------------------
5566 +   -- POSIX.1c  Section 11 --
5567 +   --------------------------
5568 +
5569 +   function pthread_mutexattr_init
5570 +     (attr : access pthread_mutexattr_t) return int;
5571 +   pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
5572 +
5573 +   function pthread_mutexattr_destroy
5574 +     (attr : access pthread_mutexattr_t) return int;
5575 +   pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
5576 +
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");
5581 +
5582 +   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
5583 +   pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
5584 +
5585 +   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
5586 +   pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
5587 +
5588 +   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
5589 +   pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
5590 +
5591 +   function pthread_condattr_init
5592 +     (attr : access pthread_condattr_t) return int;
5593 +   pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
5594 +
5595 +   function pthread_condattr_destroy
5596 +     (attr : access pthread_condattr_t) return int;
5597 +   pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
5598 +
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");
5603 +
5604 +   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
5605 +   pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
5606 +
5607 +   function pthread_cond_signal (cond : access pthread_cond_t) return int;
5608 +   pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
5609 +
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");
5614 +
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");
5620 +
5621 +   Relative_Timed_Wait : constant Boolean := False;
5622 +   --  pthread_cond_timedwait requires an absolute delay time
5623 +
5624 +   --------------------------
5625 +   -- POSIX.1c  Section 13 --
5626 +   --------------------------
5627 +
5628 +   PTHREAD_PRIO_NONE    : constant := 0;
5629 +   PTHREAD_PRIO_PROTECT : constant := 2;
5630 +   PTHREAD_PRIO_INHERIT : constant := 1;
5631 +
5632 +   function pthread_mutexattr_setprotocol
5633 +     (attr     : access pthread_mutexattr_t;
5634 +      protocol : int) return int;
5635 +
5636 +   function pthread_mutexattr_setprioceiling
5637 +     (attr     : access pthread_mutexattr_t;
5638 +      prioceiling : int) return int;
5639 +
5640 +   type struct_sched_param is record
5641 +      sched_priority : int;
5642 +   end record;
5643 +   pragma Convention (C, struct_sched_param);
5644 +
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");
5650 +
5651 +   function pthread_setschedparam
5652 +     (thread : pthread_t;
5653 +      policy : int;
5654 +      param  : access struct_sched_param) return int;
5655 +   pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
5656 +
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");
5661 +
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");
5666 +
5667 +   function pthread_attr_setinheritsched
5668 +     (attr            : access pthread_attr_t;
5669 +      inheritsched : int) return int;
5670 +   pragma Import
5671 +     (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
5672 +
5673 +   function pthread_attr_getinheritsched
5674 +     (attr         : access pthread_attr_t;
5675 +      inheritsched : access int) return int;
5676 +   pragma Import
5677 +     (C, pthread_attr_getinheritsched, "pthread_attr_getinheritsched");
5678 +
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");
5684 +
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");
5690 +
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");
5695 +
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");
5700 +
5701 +   function sched_yield return int;
5702 +   pragma Import (C, sched_yield, "sched_yield");
5703 +
5704 +   --------------------------
5705 +   -- P1003.1c  Section 16 --
5706 +   --------------------------
5707 +
5708 +   function pthread_attr_init (attributes : access pthread_attr_t) return int;
5709 +   pragma Import (C, pthread_attr_init, "pthread_attr_init");
5710 +
5711 +   function pthread_attr_destroy
5712 +     (attributes : access pthread_attr_t) return int;
5713 +   pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
5714 +
5715 +   function pthread_attr_setdetachstate
5716 +     (attr        : access pthread_attr_t;
5717 +      detachstate : int) return int;
5718 +   pragma Import
5719 +     (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
5720 +
5721 +   function pthread_attr_getdetachstate
5722 +     (attr        : access pthread_attr_t;
5723 +      detachstate : access int) return int;
5724 +   pragma Import
5725 +     (C, pthread_attr_getdetachstate, "pthread_attr_getdetachstate");
5726 +
5727 +   function pthread_attr_getstacksize
5728 +     (attr      : access pthread_attr_t;
5729 +      stacksize : access size_t) return int;
5730 +   pragma Import
5731 +     (C, pthread_attr_getstacksize, "pthread_attr_getstacksize");
5732 +
5733 +   function pthread_attr_setstacksize
5734 +     (attr      : access pthread_attr_t;
5735 +      stacksize : size_t) return int;
5736 +   pragma Import
5737 +     (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
5738 +
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");
5745 +
5746 +   function pthread_detach (thread : pthread_t) return int;
5747 +   pragma Import (C, pthread_detach, "pthread_detach");
5748 +
5749 +   procedure pthread_exit (status : System.Address);
5750 +   pragma Import (C, pthread_exit, "pthread_exit");
5751 +
5752 +   function pthread_self return pthread_t;
5753 +   pragma Import (C, pthread_self, "pthread_self");
5754 +
5755 +   --------------------------
5756 +   -- POSIX.1c  Section 17 --
5757 +   --------------------------
5758 +
5759 +   function pthread_setspecific
5760 +     (key   : pthread_key_t;
5761 +      value : System.Address) return  int;
5762 +   pragma Import (C, pthread_setspecific, "pthread_setspecific");
5763 +
5764 +   function pthread_getspecific (key : pthread_key_t) return System.Address;
5765 +   pragma Import (C, pthread_getspecific, "pthread_getspecific");
5766 +
5767 +   type destructor_pointer is access procedure (arg : System.Address);
5768 +   pragma Convention (C, destructor_pointer);
5769 +
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");
5774 +
5775 +   ------------------------------------
5776 +   -- Non-portable Pthread Functions --
5777 +   ------------------------------------
5778 +
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");
5783 +
5784 +private
5785 +
5786 +   type sigset_t is array (1 .. 4) of unsigned;
5787 +
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
5792 +
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.
5798 +
5799 +   type struct_sigcontext is null record;
5800 +   pragma Convention (C, struct_sigcontext);
5801 +
5802 +   type pid_t is new int;
5803 +
5804 +   type time_t is new int;
5805 +
5806 +   type timespec is record
5807 +      tv_sec  : time_t;
5808 +      tv_nsec : long;
5809 +   end record;
5810 +   pragma Convention (C, timespec);
5811 +
5812 +   type pthread_t           is new System.Address;
5813 +   type pthread_attr_t      is record
5814 +      Pta_Magic   : unsigned;
5815 +      Pta_Flags   : int;
5816 +      Pta_Private : System.Address;
5817 +   end record;
5818 +   pragma Convention (C, pthread_attr_t);
5819 +
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;
5823 +
5824 +   type pthread_queue_t is record
5825 +      Pthqh_First : pthread_t;
5826 +      Pthqh_Last  : System.Address;
5827 +   end record;
5828 +   pragma Convention (C, pthread_queue_t);
5829 +
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;
5837 +   end record;
5838 +   pragma Convention (C, pthread_mutex_t);
5839 +
5840 +   type pthread_mutexattr_t is record
5841 +      Ptma_Majic   : unsigned;
5842 +      Ptma_Private : System.Address;
5843 +   end record;
5844 +   pragma Convention (C, pthread_mutexattr_t);
5845 +
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;
5852 +   end record;
5853 +   pragma Convention (C, pthread_cond_t);
5854 +
5855 +   type pthread_condattr_t  is record
5856 +      Ptca_Magic   : unsigned;
5857 +      Ptca_Private : System.Address;
5858 +   end record;
5859 +   pragma Convention (C, pthread_condattr_t);
5860 +
5861 +   type pthread_key_t       is new int;
5862 +
5863 +end System.OS_Interface;
5864 --- /dev/null
5865 +++ gcc/ada/s-osinte-netbsd6.ads
5866 @@ -0,0 +1,675 @@
5867 +------------------------------------------------------------------------------
5868 +--                                                                          --
5869 +--                  GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                --
5870 +--                                                                          --
5871 +--                   S Y S T E M . O S _ I N T E R F A C E                  --
5872 +--                                                                          --
5873 +--                                   S p e c                                --
5874 +--                                                                          --
5875 +--             Copyright (C) 1991-1994, Florida State University            --
5876 +--          Copyright (C) 1995-2011, Free Software Foundation, Inc.         --
5877 +--                                                                          --
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.                                     --
5884 +--                                                                          --
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.               --
5888 +--                                                                          --
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/>.                                          --
5893 +--                                                                          --
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).                                  --
5897 +--                                                                          --
5898 +------------------------------------------------------------------------------
5899 +
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.
5902 +
5903 +--  This package encapsulates all direct interfaces to OS services
5904 +--  that are needed by the tasking run-time (libgnarl).
5905 +
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.
5908 +
5909 +with Ada.Unchecked_Conversion;
5910 +
5911 +with Interfaces.C;
5912 +
5913 +package System.OS_Interface is
5914 +   pragma Preelaborate;
5915 +
5916 +   pragma Linker_Options ("-pthread");
5917 +
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;
5928 +
5929 +   -----------
5930 +   -- Errno --
5931 +   -----------
5932 +
5933 +   function Errno return int;
5934 +   pragma Inline (Errno);
5935 +
5936 +   EAGAIN    : constant := 35;
5937 +   EINTR     : constant := 4;
5938 +   EINVAL    : constant := 22;
5939 +   ENOMEM    : constant := 12;
5940 +   ETIMEDOUT : constant := 60;
5941 +
5942 +   -------------
5943 +   -- Signals --
5944 +   -------------
5945 +
5946 +   Max_Interrupt : constant := 63;
5947 +   type Signal is new int range 0 .. Max_Interrupt;
5948 +   for Signal'Size use int'Size;
5949 +
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)
5984 +
5985 +   SIGADAABORT : constant := SIGABRT;
5986 +   --  Change this if you want to use another signal for task abort.
5987 +   --  SIGTERM might be a good one.
5988 +
5989 +   type Signal_Set is array (Natural range <>) of Signal;
5990 +
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);
5996 +
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);
6000 +
6001 +   type sigset_t is private;
6002 +
6003 +   function sigaddset
6004 +     (set : access sigset_t;
6005 +      sig : Signal) return int;
6006 +   pragma Import (C, sigaddset, "__sigaddset14");
6007 +
6008 +   function sigdelset
6009 +     (set : access sigset_t;
6010 +      sig : Signal) return int;
6011 +   pragma Import (C, sigdelset, "__sigdelset14");
6012 +
6013 +   function sigfillset (set : access sigset_t) return int;
6014 +   pragma Import (C, sigfillset, "__sigfillset14");
6015 +
6016 +   function sigismember
6017 +     (set : access sigset_t;
6018 +      sig : Signal) return int;
6019 +   pragma Import (C, sigismember, "__sigismember14");
6020 +
6021 +   function sigemptyset (set : access sigset_t) return int;
6022 +   pragma Import (C, sigemptyset, "__sigemptyset14");
6023 +
6024 +   --  sigcontext is architecture dependent, so define it private
6025 +   type struct_sigcontext is private;
6026 +
6027 +   type old_struct_sigaction is record
6028 +      sa_handler : System.Address;
6029 +      sa_mask    : sigset_t;
6030 +      sa_flags   : int;
6031 +   end record;
6032 +   pragma Convention (C, old_struct_sigaction);
6033 +
6034 +   type new_struct_sigaction is record
6035 +      sa_handler : System.Address;
6036 +      sa_flags   : int;
6037 +      sa_mask    : sigset_t;
6038 +   end record;
6039 +   pragma Convention (C, new_struct_sigaction);
6040 +
6041 +   subtype struct_sigaction is new_struct_sigaction;
6042 +   type struct_sigaction_ptr is access all struct_sigaction;
6043 +
6044 +   SIG_BLOCK   : constant := 1;
6045 +   SIG_UNBLOCK : constant := 2;
6046 +   SIG_SETMASK : constant := 3;
6047 +
6048 +   SIG_DFL  : constant := 0;
6049 +   SIG_IGN  : constant := 1;
6050 +   SIG_ERR  : constant := -1;
6051 +   SIG_HOLD : constant := 3;
6052 +
6053 +   SA_SIGINFO : constant := 16#0040#;
6054 +   SA_ONSTACK : constant := 16#0001#;
6055 +
6056 +   function sigaction
6057 +     (sig  : Signal;
6058 +      act  : struct_sigaction_ptr;
6059 +      oact : struct_sigaction_ptr) return int;
6060 +   pragma Import (C, sigaction, "__sigaction14");
6061 +
6062 +   ----------
6063 +   -- Time --
6064 +   ----------
6065 +
6066 +   Time_Slice_Supported : constant Boolean := True;
6067 +   --  Indicates whether time slicing is supported (i.e SCHED_RR is supported)
6068 +
6069 +   type timespec is private;
6070 +
6071 +   function nanosleep (rqtp, rmtp : access timespec)  return int;
6072 +   pragma Import (C, nanosleep, "__nanosleep50");
6073 +
6074 +   type clockid_t is new int;
6075 +
6076 +   function clock_gettime
6077 +     (clock_id : clockid_t;
6078 +      tp       : access timespec)
6079 +      return int;
6080 +   pragma Import (C, clock_gettime, "__clock_gettime50");
6081 +
6082 +   function To_Duration (TS : timespec) return Duration;
6083 +   pragma Inline (To_Duration);
6084 +
6085 +   function To_Timespec (D : Duration) return timespec;
6086 +   pragma Inline (To_Timespec);
6087 +
6088 +   type struct_timezone is record
6089 +      tz_minuteswest : int;
6090 +      tz_dsttime     : int;
6091 +   end record;
6092 +   pragma Convention (C, struct_timezone);
6093 +
6094 +   -------------------------
6095 +   -- Priority Scheduling --
6096 +   -------------------------
6097 +
6098 +   SCHED_FIFO  : constant := 1;
6099 +   SCHED_OTHER : constant := 2;
6100 +   SCHED_RR    : constant := 3;
6101 +
6102 +   function To_Target_Priority
6103 +     (Prio : System.Any_Priority) return Interfaces.C.int;
6104 +   --  Maps System.Any_Priority to a POSIX priority
6105 +
6106 +   -------------
6107 +   -- Process --
6108 +   -------------
6109 +
6110 +   type pid_t is private;
6111 +
6112 +   function kill (pid : pid_t; sig : Signal) return int;
6113 +   pragma Import (C, kill, "kill");
6114 +
6115 +   function getpid return pid_t;
6116 +   pragma Import (C, getpid, "getpid");
6117 +
6118 +   ---------
6119 +   -- LWP --
6120 +   ---------
6121 +
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");
6127 +
6128 +   -------------
6129 +   -- Threads --
6130 +   -------------
6131 +
6132 +   type Thread_Body is access
6133 +     function (arg : System.Address) return System.Address;
6134 +   pragma Convention (C, Thread_Body);
6135 +
6136 +   function Thread_Body_Access is new
6137 +     Ada.Unchecked_Conversion (System.Address, Thread_Body);
6138 +
6139 +   type pthread_t           is private;
6140 +   subtype Thread_Id        is pthread_t;
6141 +
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;
6148 +
6149 +   PTHREAD_CREATE_DETACHED : constant := 1;
6150 +   PTHREAD_CREATE_JOINABLE : constant := 0;
6151 +
6152 +   PTHREAD_SCOPE_PROCESS : constant := 0;
6153 +   PTHREAD_SCOPE_SYSTEM  : constant := 2;
6154 +
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].
6159 +
6160 +   subtype pthread_rwlock_t     is pthread_mutex_t;
6161 +   subtype pthread_rwlockattr_t is pthread_mutexattr_t;
6162 +
6163 +   -----------
6164 +   -- Stack --
6165 +   -----------
6166 +
6167 +   type stack_t is record
6168 +      ss_sp    : System.Address;
6169 +      ss_size  : size_t;
6170 +      ss_flags : int;
6171 +   end record;
6172 +   pragma Convention (C, stack_t);
6173 +
6174 +   function sigaltstack
6175 +     (ss  : not null access stack_t;
6176 +      oss : access stack_t) return int;
6177 +   pragma Import (C, sigaltstack, "sigaltstack");
6178 +
6179 +   Alternate_Stack : aliased System.Address;
6180 +   --  This is a dummy definition, never used (Alternate_Stack_Size is null)
6181 +
6182 +   Alternate_Stack_Size : constant := 0;
6183 +   --  No alternate signal stack is used on this platform
6184 +
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.
6190 +
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.
6195 +
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
6200 +
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;
6208 +
6209 +   function mprotect (addr : Address; len : size_t; prot : int) return int;
6210 +   pragma Import (C, mprotect);
6211 +
6212 +   ---------------------------------------
6213 +   -- Nonstandard Thread Initialization --
6214 +   ---------------------------------------
6215 +
6216 +   --  FSU_THREADS requires pthread_init, which is nonstandard and this should
6217 +   --  be invoked during the elaboration of s-taprop.adb.
6218 +
6219 +   --  NetBSD does not require this so we provide an empty Ada body
6220 +
6221 +   procedure pthread_init;
6222 +
6223 +   -------------------------
6224 +   -- POSIX.1c  Section 3 --
6225 +   -------------------------
6226 +
6227 +   function sigwait
6228 +     (set : access sigset_t;
6229 +      sig : access Signal) return int;
6230 +   pragma Import (C, sigwait, "sigwait");
6231 +
6232 +   function pthread_kill
6233 +     (thread : pthread_t;
6234 +      sig    : Signal) return int;
6235 +   pragma Import (C, pthread_kill, "pthread_kill");
6236 +
6237 +   function pthread_sigmask
6238 +     (how  : int;
6239 +      set  : access sigset_t;
6240 +      oset : access sigset_t) return int;
6241 +   pragma Import (C, pthread_sigmask, "pthread_sigmask");
6242 +
6243 +   --------------------------
6244 +   -- POSIX.1c  Section 11 --
6245 +   --------------------------
6246 +
6247 +   function pthread_mutexattr_init
6248 +     (attr : access pthread_mutexattr_t) return int;
6249 +   pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
6250 +
6251 +   function pthread_mutexattr_destroy
6252 +     (attr : access pthread_mutexattr_t) return int;
6253 +   pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
6254 +
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");
6259 +
6260 +   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
6261 +   pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
6262 +
6263 +   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
6264 +   pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
6265 +
6266 +   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
6267 +   pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
6268 +
6269 +   function pthread_condattr_init
6270 +     (attr : access pthread_condattr_t) return int;
6271 +   pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
6272 +
6273 +   function pthread_condattr_destroy
6274 +     (attr : access pthread_condattr_t) return int;
6275 +   pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
6276 +
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");
6281 +
6282 +   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
6283 +   pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
6284 +
6285 +   function pthread_cond_signal (cond : access pthread_cond_t) return int;
6286 +   pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
6287 +
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");
6292 +
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");
6298 +
6299 +   Relative_Timed_Wait : constant Boolean := False;
6300 +   --  pthread_cond_timedwait requires an absolute delay time
6301 +
6302 +   --------------------------
6303 +   -- POSIX.1c  Section 13 --
6304 +   --------------------------
6305 +
6306 +   PTHREAD_PRIO_NONE    : constant := 0;
6307 +   PTHREAD_PRIO_PROTECT : constant := 2;
6308 +   PTHREAD_PRIO_INHERIT : constant := 1;
6309 +
6310 +   function pthread_mutexattr_setprotocol
6311 +     (attr     : access pthread_mutexattr_t;
6312 +      protocol : int) return int;
6313 +
6314 +   function pthread_mutexattr_setprioceiling
6315 +     (attr     : access pthread_mutexattr_t;
6316 +      prioceiling : int) return int;
6317 +
6318 +   type struct_sched_param is record
6319 +      sched_priority : int;
6320 +   end record;
6321 +   pragma Convention (C, struct_sched_param);
6322 +
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");
6328 +
6329 +   function pthread_setschedparam
6330 +     (thread : pthread_t;
6331 +      policy : int;
6332 +      param  : access struct_sched_param) return int;
6333 +   pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
6334 +
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");
6339 +
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");
6344 +
6345 +   function pthread_attr_setinheritsched
6346 +     (attr            : access pthread_attr_t;
6347 +      inheritsched : int) return int;
6348 +   pragma Import
6349 +     (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
6350 +
6351 +   function pthread_attr_getinheritsched
6352 +     (attr         : access pthread_attr_t;
6353 +      inheritsched : access int) return int;
6354 +   pragma Import
6355 +     (C, pthread_attr_getinheritsched, "pthread_attr_getinheritsched");
6356 +
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");
6362 +
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");
6368 +
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");
6373 +
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");
6378 +
6379 +   function sched_yield return int;
6380 +   pragma Import (C, sched_yield, "sched_yield");
6381 +
6382 +   --------------------------
6383 +   -- P1003.1c  Section 16 --
6384 +   --------------------------
6385 +
6386 +   function pthread_attr_init (attributes : access pthread_attr_t) return int;
6387 +   pragma Import (C, pthread_attr_init, "pthread_attr_init");
6388 +
6389 +   function pthread_attr_destroy
6390 +     (attributes : access pthread_attr_t) return int;
6391 +   pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
6392 +
6393 +   function pthread_attr_setdetachstate
6394 +     (attr        : access pthread_attr_t;
6395 +      detachstate : int) return int;
6396 +   pragma Import
6397 +     (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
6398 +
6399 +   function pthread_attr_getdetachstate
6400 +     (attr        : access pthread_attr_t;
6401 +      detachstate : access int) return int;
6402 +   pragma Import
6403 +     (C, pthread_attr_getdetachstate, "pthread_attr_getdetachstate");
6404 +
6405 +   function pthread_attr_getstacksize
6406 +     (attr      : access pthread_attr_t;
6407 +      stacksize : access size_t) return int;
6408 +   pragma Import
6409 +     (C, pthread_attr_getstacksize, "pthread_attr_getstacksize");
6410 +
6411 +   function pthread_attr_setstacksize
6412 +     (attr      : access pthread_attr_t;
6413 +      stacksize : size_t) return int;
6414 +   pragma Import
6415 +     (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
6416 +
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");
6423 +
6424 +   function pthread_detach (thread : pthread_t) return int;
6425 +   pragma Import (C, pthread_detach, "pthread_detach");
6426 +
6427 +   procedure pthread_exit (status : System.Address);
6428 +   pragma Import (C, pthread_exit, "pthread_exit");
6429 +
6430 +   function pthread_self return pthread_t;
6431 +   pragma Import (C, pthread_self, "pthread_self");
6432 +
6433 +   --------------------------
6434 +   -- POSIX.1c  Section 17 --
6435 +   --------------------------
6436 +
6437 +   function pthread_setspecific
6438 +     (key   : pthread_key_t;
6439 +      value : System.Address) return  int;
6440 +   pragma Import (C, pthread_setspecific, "pthread_setspecific");
6441 +
6442 +   function pthread_getspecific (key : pthread_key_t) return System.Address;
6443 +   pragma Import (C, pthread_getspecific, "pthread_getspecific");
6444 +
6445 +   type destructor_pointer is access procedure (arg : System.Address);
6446 +   pragma Convention (C, destructor_pointer);
6447 +
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");
6452 +
6453 +   ------------------------------------
6454 +   -- Non-portable Pthread Functions --
6455 +   ------------------------------------
6456 +
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");
6461 +
6462 +private
6463 +
6464 +   type sigset_t is array (1 .. 4) of unsigned;
6465 +
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
6470 +
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.
6476 +
6477 +   type struct_sigcontext is null record;
6478 +   pragma Convention (C, struct_sigcontext);
6479 +
6480 +   type pid_t is new int;
6481 +
6482 +   type time_t is new int64_t;
6483 +
6484 +   type timespec is record
6485 +      tv_sec  : time_t;
6486 +      tv_nsec : long;
6487 +   end record;
6488 +   pragma Convention (C, timespec);
6489 +
6490 +   type pthread_t           is new System.Address;
6491 +   type pthread_attr_t      is record
6492 +      Pta_Magic   : unsigned;
6493 +      Pta_Flags   : int;
6494 +      Pta_Private : System.Address;
6495 +   end record;
6496 +   pragma Convention (C, pthread_attr_t);
6497 +
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;
6501 +
6502 +   type pthread_queue_t is record
6503 +      Pthqh_First : pthread_t;
6504 +      Pthqh_Last  : System.Address;
6505 +   end record;
6506 +   pragma Convention (C, pthread_queue_t);
6507 +
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;
6515 +   end record;
6516 +   pragma Convention (C, pthread_mutex_t);
6517 +
6518 +   type pthread_mutexattr_t is record
6519 +      Ptma_Majic   : unsigned;
6520 +      Ptma_Private : System.Address;
6521 +   end record;
6522 +   pragma Convention (C, pthread_mutexattr_t);
6523 +
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;
6530 +   end record;
6531 +   pragma Convention (C, pthread_cond_t);
6532 +
6533 +   type pthread_condattr_t  is record
6534 +      Ptca_Magic   : unsigned;
6535 +      Ptca_Private : System.Address;
6536 +   end record;
6537 +   pragma Convention (C, pthread_condattr_t);
6538 +
6539 +   type pthread_key_t       is new int;
6540 +
6541 +end System.OS_Interface;
6542 --- /dev/null
6543 +++ gcc/ada/s-osinte-openbsd.adb
6544 @@ -0,0 +1,116 @@
6545 +------------------------------------------------------------------------------
6546 +--                                                                          --
6547 +--                  GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                --
6548 +--                                                                          --
6549 +--                   S Y S T E M . O S _ I N T E R F A C E                  --
6550 +--                                                                          --
6551 +--                                   B o d y                                --
6552 +--                                                                          --
6553 +--          Copyright (C) 1991-2009, Free Software Foundation, Inc.         --
6554 +--                                                                          --
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.                                     --
6561 +--                                                                          --
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.               --
6565 +--                                                                          --
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/>.                                          --
6570 +--                                                                          --
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).                                  --
6574 +--                                                                          --
6575 +------------------------------------------------------------------------------
6576 +
6577 +--  This is the OpenBSD THREADS version of this package
6578 +
6579 +with Interfaces.C; use Interfaces.C;
6580 +
6581 +package body System.OS_Interface is
6582 +
6583 +   -----------
6584 +   -- Errno --
6585 +   -----------
6586 +
6587 +   function Errno return int is
6588 +      type int_ptr is access all int;
6589 +
6590 +      function internal_errno return int_ptr;
6591 +      pragma Import (C, internal_errno, "__errno");
6592 +
6593 +   begin
6594 +      return (internal_errno.all);
6595 +   end Errno;
6596 +
6597 +   --------------------
6598 +   -- Get_Stack_Base --
6599 +   --------------------
6600 +
6601 +   function Get_Stack_Base (thread : pthread_t) return Address is
6602 +      pragma Unreferenced (thread);
6603 +   begin
6604 +      return Null_Address;
6605 +   end Get_Stack_Base;
6606 +
6607 +   ------------------
6608 +   -- pthread_init --
6609 +   ------------------
6610 +
6611 +   procedure pthread_init is
6612 +   begin
6613 +      null;
6614 +   end pthread_init;
6615 +
6616 +   -----------------
6617 +   -- To_Duration --
6618 +   -----------------
6619 +
6620 +   function To_Duration (TS : timespec) return Duration is
6621 +   begin
6622 +      return Duration (TS.tv_sec) + Duration (TS.tv_nsec) / 10#1#E9;
6623 +   end To_Duration;
6624 +
6625 +   ------------------------
6626 +   -- To_Target_Priority --
6627 +   ------------------------
6628 +
6629 +   function To_Target_Priority
6630 +     (Prio : System.Any_Priority) return Interfaces.C.int
6631 +   is
6632 +   begin
6633 +      return Interfaces.C.int (Prio);
6634 +   end To_Target_Priority;
6635 +
6636 +   -----------------
6637 +   -- To_Timespec --
6638 +   -----------------
6639 +
6640 +   function To_Timespec (D : Duration) return timespec is
6641 +      S : time_t;
6642 +      F : Duration;
6643 +
6644 +   begin
6645 +      S := time_t (Long_Long_Integer (D));
6646 +      F := D - Duration (S);
6647 +
6648 +      --  If F has negative value due to a round-up, adjust for positive F
6649 +      --  value.
6650 +
6651 +      if F < 0.0 then
6652 +         S := S - 1;
6653 +         F := F + 1.0;
6654 +      end if;
6655 +
6656 +      return timespec'(tv_sec => S,
6657 +                       tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
6658 +   end To_Timespec;
6659 +
6660 +end System.OS_Interface;
6661 --- /dev/null
6662 +++ gcc/ada/s-osinte-openbsd.ads
6663 @@ -0,0 +1,648 @@
6664 +------------------------------------------------------------------------------
6665 +--                                                                          --
6666 +--                  GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                --
6667 +--                                                                          --
6668 +--                   S Y S T E M . O S _ I N T E R F A C E                  --
6669 +--                                                                          --
6670 +--                                   S p e c                                --
6671 +--                                                                          --
6672 +--             Copyright (C) 1991-1994, Florida State University            --
6673 +--          Copyright (C) 1995-2011, Free Software Foundation, Inc.         --
6674 +--                                                                          --
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.                                     --
6681 +--                                                                          --
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.               --
6685 +--                                                                          --
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/>.                                          --
6690 +--                                                                          --
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).                                  --
6694 +--                                                                          --
6695 +------------------------------------------------------------------------------
6696 +
6697 +--  This is the OpenBSD PTHREADS version of this package
6698 +
6699 +--  This package encapsulates all direct interfaces to OS services
6700 +--  that are needed by the tasking run-time (libgnarl).
6701 +
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.
6704 +
6705 +with Ada.Unchecked_Conversion;
6706 +
6707 +with Interfaces.C;
6708 +
6709 +package System.OS_Interface is
6710 +   pragma Preelaborate;
6711 +
6712 +   pragma Linker_Options ("-pthread");
6713 +
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;
6723 +
6724 +   -----------
6725 +   -- Errno --
6726 +   -----------
6727 +
6728 +   function Errno return int;
6729 +   pragma Inline (Errno);
6730 +
6731 +   EAGAIN    : constant := 35;
6732 +   EINTR     : constant := 4;
6733 +   EINVAL    : constant := 22;
6734 +   ENOMEM    : constant := 12;
6735 +   ETIMEDOUT : constant := 60;
6736 +
6737 +   -------------
6738 +   -- Signals --
6739 +   -------------
6740 +
6741 +   Max_Interrupt : constant := 31;
6742 +   type Signal is new int range 0 .. Max_Interrupt;
6743 +   for Signal'Size use int'Size;
6744 +
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
6778 +
6779 +   SIGADAABORT : constant := SIGABRT;
6780 +   --  Change this if you want to use another signal for task abort.
6781 +   --  SIGTERM might be a good one.
6782 +
6783 +   type Signal_Set is array (Natural range <>) of Signal;
6784 +
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);
6790 +
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);
6794 +
6795 +   type sigset_t is private;
6796 +
6797 +   function sigaddset
6798 +     (set : access sigset_t;
6799 +      sig : Signal) return int;
6800 +   pragma Import (C, sigaddset, "sigaddset");
6801 +
6802 +   function sigdelset
6803 +     (set : access sigset_t;
6804 +      sig : Signal) return int;
6805 +   pragma Import (C, sigdelset, "sigdelset");
6806 +
6807 +   function sigfillset (set : access sigset_t) return int;
6808 +   pragma Import (C, sigfillset, "sigfillset");
6809 +
6810 +   function sigismember
6811 +     (set : access sigset_t;
6812 +      sig : Signal) return int;
6813 +   pragma Import (C, sigismember, "sigismember");
6814 +
6815 +   function sigemptyset (set : access sigset_t) return int;
6816 +   pragma Import (C, sigemptyset, "sigemptyset");
6817 +
6818 +   --  sigcontext is architecture dependent, so define it private
6819 +   type struct_sigcontext is private;
6820 +
6821 +   type old_struct_sigaction is record
6822 +      sa_handler : System.Address;
6823 +      sa_mask    : sigset_t;
6824 +      sa_flags   : int;
6825 +   end record;
6826 +   pragma Convention (C, old_struct_sigaction);
6827 +
6828 +   type new_struct_sigaction is record
6829 +      sa_handler : System.Address;
6830 +      sa_flags   : int;
6831 +      sa_mask    : sigset_t;
6832 +   end record;
6833 +   pragma Convention (C, new_struct_sigaction);
6834 +
6835 +   subtype struct_sigaction is new_struct_sigaction;
6836 +   type struct_sigaction_ptr is access all struct_sigaction;
6837 +
6838 +   SIG_BLOCK   : constant := 1;
6839 +   SIG_UNBLOCK : constant := 2;
6840 +   SIG_SETMASK : constant := 3;
6841 +
6842 +   SIG_DFL : constant := 0;
6843 +   SIG_IGN : constant := 1;
6844 +
6845 +   SA_SIGINFO : constant := 16#0040#;
6846 +   SA_ONSTACK : constant := 16#0001#;
6847 +
6848 +   function sigaction
6849 +     (sig  : Signal;
6850 +      act  : struct_sigaction_ptr;
6851 +      oact : struct_sigaction_ptr) return int;
6852 +   pragma Import (C, sigaction, "sigaction");
6853 +
6854 +   ----------
6855 +   -- Time --
6856 +   ----------
6857 +
6858 +   Time_Slice_Supported : constant Boolean := True;
6859 +   --  Indicates whether time slicing is supported (i.e SCHED_RR is supported)
6860 +
6861 +   type timespec is private;
6862 +
6863 +   function nanosleep (rqtp, rmtp : access timespec)  return int;
6864 +   pragma Import (C, nanosleep, "nanosleep");
6865 +
6866 +   type clockid_t is new int;
6867 +
6868 +   function clock_gettime
6869 +     (clock_id : clockid_t;
6870 +      tp       : access timespec)
6871 +      return int;
6872 +   pragma Import (C, clock_gettime, "clock_gettime");
6873 +
6874 +   function To_Duration (TS : timespec) return Duration;
6875 +   pragma Inline (To_Duration);
6876 +
6877 +   function To_Timespec (D : Duration) return timespec;
6878 +   pragma Inline (To_Timespec);
6879 +
6880 +   type struct_timezone is record
6881 +      tz_minuteswest : int;
6882 +      tz_dsttime     : int;
6883 +   end record;
6884 +   pragma Convention (C, struct_timezone);
6885 +
6886 +   procedure usleep (useconds : unsigned_long);
6887 +   pragma Import (C, usleep, "usleep");
6888 +
6889 +   -------------------------
6890 +   -- Priority Scheduling --
6891 +   -------------------------
6892 +
6893 +   SCHED_FIFO  : constant := 1;
6894 +   SCHED_OTHER : constant := 2;
6895 +   SCHED_RR    : constant := 3;
6896 +
6897 +   function To_Target_Priority
6898 +     (Prio : System.Any_Priority) return Interfaces.C.int;
6899 +   --  Maps System.Any_Priority to a POSIX priority
6900 +
6901 +   -------------
6902 +   -- Process --
6903 +   -------------
6904 +
6905 +   type pid_t is private;
6906 +
6907 +   function kill (pid : pid_t; sig : Signal) return int;
6908 +   pragma Import (C, kill, "kill");
6909 +
6910 +   function getpid return pid_t;
6911 +   pragma Import (C, getpid, "getpid");
6912 +
6913 +   ---------
6914 +   -- LWP --
6915 +   ---------
6916 +
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");
6922 +
6923 +   -------------
6924 +   -- Threads --
6925 +   -------------
6926 +
6927 +   type Thread_Body is access
6928 +     function (arg : System.Address) return System.Address;
6929 +   pragma Convention (C, Thread_Body);
6930 +
6931 +   function Thread_Body_Access is new
6932 +     Ada.Unchecked_Conversion (System.Address, Thread_Body);
6933 +
6934 +   type pthread_t           is private;
6935 +   subtype Thread_Id        is pthread_t;
6936 +
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;
6943 +
6944 +   PTHREAD_CREATE_DETACHED : constant := 1;
6945 +   PTHREAD_CREATE_JOINABLE : constant := 0;
6946 +
6947 +   PTHREAD_SCOPE_PROCESS : constant := 0;
6948 +   PTHREAD_SCOPE_SYSTEM  : constant := 2;
6949 +
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].
6954 +
6955 +   subtype pthread_rwlock_t     is pthread_mutex_t;
6956 +   subtype pthread_rwlockattr_t is pthread_mutexattr_t;
6957 +
6958 +   -----------
6959 +   -- Stack --
6960 +   -----------
6961 +
6962 +   type stack_t is record
6963 +      ss_sp    : System.Address;
6964 +      ss_size  : size_t;
6965 +      ss_flags : int;
6966 +   end record;
6967 +   pragma Convention (C, stack_t);
6968 +
6969 +   function sigaltstack
6970 +     (ss  : not null access stack_t;
6971 +      oss : access stack_t) return int;
6972 +   pragma Import (C, sigaltstack, "sigaltstack");
6973 +
6974 +   Alternate_Stack : aliased System.Address;
6975 +   --  This is a dummy definition, never used (Alternate_Stack_Size is null)
6976 +
6977 +   Alternate_Stack_Size : constant := 0;
6978 +   --  No alternate signal stack is used on this platform
6979 +
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.
6985 +
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.
6990 +
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
6995 +
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;
7003 +
7004 +   function mprotect (addr : Address; len : size_t; prot : int) return int;
7005 +   pragma Import (C, mprotect);
7006 +
7007 +   ---------------------------------------
7008 +   -- Nonstandard Thread Initialization --
7009 +   ---------------------------------------
7010 +
7011 +   --  FSU_THREADS requires pthread_init, which is nonstandard and this should
7012 +   --  be invoked during the elaboration of s-taprop.adb.
7013 +
7014 +   --  OpenBSD does not require this so we provide an empty Ada body
7015 +
7016 +   procedure pthread_init;
7017 +
7018 +   -------------------------
7019 +   -- POSIX.1c  Section 3 --
7020 +   -------------------------
7021 +
7022 +   function sigwait
7023 +     (set : access sigset_t;
7024 +      sig : access Signal) return int;
7025 +   pragma Import (C, sigwait, "sigwait");
7026 +
7027 +   function pthread_kill
7028 +     (thread : pthread_t;
7029 +      sig    : Signal) return int;
7030 +   pragma Import (C, pthread_kill, "pthread_kill");
7031 +
7032 +   function pthread_sigmask
7033 +     (how  : int;
7034 +      set  : access sigset_t;
7035 +      oset : access sigset_t) return int;
7036 +   pragma Import (C, pthread_sigmask, "pthread_sigmask");
7037 +
7038 +   --------------------------
7039 +   -- POSIX.1c  Section 11 --
7040 +   --------------------------
7041 +
7042 +   function pthread_mutexattr_init
7043 +     (attr : access pthread_mutexattr_t) return int;
7044 +   pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
7045 +
7046 +   function pthread_mutexattr_destroy
7047 +     (attr : access pthread_mutexattr_t) return int;
7048 +   pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
7049 +
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");
7054 +
7055 +   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
7056 +   pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
7057 +
7058 +   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
7059 +   pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
7060 +
7061 +   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
7062 +   pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
7063 +
7064 +   function pthread_condattr_init
7065 +     (attr : access pthread_condattr_t) return int;
7066 +   pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
7067 +
7068 +   function pthread_condattr_destroy
7069 +     (attr : access pthread_condattr_t) return int;
7070 +   pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
7071 +
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");
7076 +
7077 +   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
7078 +   pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
7079 +
7080 +   function pthread_cond_signal (cond : access pthread_cond_t) return int;
7081 +   pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
7082 +
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");
7087 +
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");
7093 +
7094 +   Relative_Timed_Wait : constant Boolean := False;
7095 +   --  pthread_cond_timedwait requires an absolute delay time
7096 +
7097 +   --------------------------
7098 +   -- POSIX.1c  Section 13 --
7099 +   --------------------------
7100 +
7101 +   PTHREAD_PRIO_NONE    : constant := 0;
7102 +   PTHREAD_PRIO_PROTECT : constant := 2;
7103 +   PTHREAD_PRIO_INHERIT : constant := 1;
7104 +
7105 +   function pthread_mutexattr_setprotocol
7106 +     (attr     : access pthread_mutexattr_t;
7107 +      protocol : int) return int;
7108 +   pragma Import
7109 +      (C, pthread_mutexattr_setprotocol, "pthread_mutexattr_setprotocol");
7110 +
7111 +   function pthread_mutexattr_getprotocol
7112 +     (attr     : access pthread_mutexattr_t;
7113 +      protocol : access int) return int;
7114 +   pragma Import
7115 +     (C, pthread_mutexattr_getprotocol, "pthread_mutexattr_getprotocol");
7116 +
7117 +   function pthread_mutexattr_setprioceiling
7118 +     (attr     : access pthread_mutexattr_t;
7119 +      prioceiling : int) return int;
7120 +   pragma Import
7121 +     (C, pthread_mutexattr_setprioceiling,
7122 +      "pthread_mutexattr_setprioceiling");
7123 +
7124 +   function pthread_mutexattr_getprioceiling
7125 +     (attr     : access pthread_mutexattr_t;
7126 +      prioceiling : access int) return int;
7127 +   pragma Import
7128 +     (C, pthread_mutexattr_getprioceiling,
7129 +      "pthread_mutexattr_getprioceiling");
7130 +
7131 +   type struct_sched_param is record
7132 +      sched_priority : int;
7133 +   end record;
7134 +   pragma Convention (C, struct_sched_param);
7135 +
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");
7141 +
7142 +   function pthread_setschedparam
7143 +     (thread : pthread_t;
7144 +      policy : int;
7145 +      param  : access struct_sched_param) return int;
7146 +   pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
7147 +
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");
7152 +
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");
7157 +
7158 +   function pthread_attr_setinheritsched
7159 +     (attr            : access pthread_attr_t;
7160 +      inheritsched : int) return int;
7161 +   pragma Import
7162 +     (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
7163 +
7164 +   function pthread_attr_getinheritsched
7165 +     (attr         : access pthread_attr_t;
7166 +      inheritsched : access int) return int;
7167 +   pragma Import
7168 +     (C, pthread_attr_getinheritsched, "pthread_attr_getinheritsched");
7169 +
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");
7175 +
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");
7181 +
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");
7186 +
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");
7191 +
7192 +   function sched_yield return int;
7193 +   pragma Import (C, sched_yield, "pthread_yield");
7194 +
7195 +   --------------------------
7196 +   -- P1003.1c  Section 16 --
7197 +   --------------------------
7198 +
7199 +   function pthread_attr_init (attributes : access pthread_attr_t) return int;
7200 +   pragma Import (C, pthread_attr_init, "pthread_attr_init");
7201 +
7202 +   function pthread_attr_destroy
7203 +     (attributes : access pthread_attr_t) return int;
7204 +   pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
7205 +
7206 +   function pthread_attr_setdetachstate
7207 +     (attr        : access pthread_attr_t;
7208 +      detachstate : int) return int;
7209 +   pragma Import
7210 +     (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
7211 +
7212 +   function pthread_attr_getdetachstate
7213 +     (attr        : access pthread_attr_t;
7214 +      detachstate : access int) return int;
7215 +   pragma Import
7216 +     (C, pthread_attr_getdetachstate, "pthread_attr_getdetachstate");
7217 +
7218 +   function pthread_attr_getstacksize
7219 +     (attr      : access pthread_attr_t;
7220 +      stacksize : access size_t) return int;
7221 +   pragma Import
7222 +     (C, pthread_attr_getstacksize, "pthread_attr_getstacksize");
7223 +
7224 +   function pthread_attr_setstacksize
7225 +     (attr      : access pthread_attr_t;
7226 +      stacksize : size_t) return int;
7227 +   pragma Import
7228 +     (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
7229 +
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");
7236 +
7237 +   function pthread_detach (thread : pthread_t) return int;
7238 +   pragma Import (C, pthread_detach, "pthread_detach");
7239 +
7240 +   procedure pthread_exit (status : System.Address);
7241 +   pragma Import (C, pthread_exit, "pthread_exit");
7242 +
7243 +   function pthread_self return pthread_t;
7244 +   pragma Import (C, pthread_self, "pthread_self");
7245 +
7246 +   --------------------------
7247 +   -- POSIX.1c  Section 17 --
7248 +   --------------------------
7249 +
7250 +   function pthread_setspecific
7251 +     (key   : pthread_key_t;
7252 +      value : System.Address) return  int;
7253 +   pragma Import (C, pthread_setspecific, "pthread_setspecific");
7254 +
7255 +   function pthread_getspecific (key : pthread_key_t) return System.Address;
7256 +   pragma Import (C, pthread_getspecific, "pthread_getspecific");
7257 +
7258 +   type destructor_pointer is access procedure (arg : System.Address);
7259 +   pragma Convention (C, destructor_pointer);
7260 +
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");
7265 +
7266 +   ------------------------------------
7267 +   -- Non-portable Pthread Functions --
7268 +   ------------------------------------
7269 +
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");
7274 +
7275 +private
7276 +
7277 +   type sigset_t is array (1 .. 4) of unsigned;
7278 +
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
7283 +
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.
7289 +
7290 +   type struct_sigcontext is null record;
7291 +   pragma Convention (C, struct_sigcontext);
7292 +
7293 +   type pid_t is new int;
7294 +
7295 +   type time_t is new int;
7296 +
7297 +   type timespec is record
7298 +      tv_sec  : time_t;
7299 +      tv_nsec : long;
7300 +   end record;
7301 +   pragma Convention (C, timespec);
7302 +
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;
7310 +
7311 +end System.OS_Interface;
7312 --- /dev/null
7313 +++ gcc/ada/s-osprim-bsd32.adb
7314 @@ -0,0 +1,186 @@
7315 +------------------------------------------------------------------------------
7316 +--                                                                          --
7317 +--                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
7318 +--                                                                          --
7319 +--                  S Y S T E M . O S _ P R I M I T I V E S                 --
7320 +--                                                                          --
7321 +--                                  B o d y                                 --
7322 +--                                                                          --
7323 +--          Copyright (C) 1998-2009, Free Software Foundation, Inc.         --
7324 +--                                                                          --
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.                                     --
7331 +--                                                                          --
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.               --
7335 +--                                                                          --
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/>.                                          --
7340 +--                                                                          --
7341 +-- GNARL was developed by the GNARL team at Florida State University.       --
7342 +-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
7343 +--                                                                          --
7344 +-- Copyright (C) 2010, 2011 John Marino <www.dragonlace.net>                --
7345 +------------------------------------------------------------------------------
7346 +
7347 +--  This version is for BSD operating systems using 32-bit time types.
7348 +
7349 +with Interfaces.C;
7350 +
7351 +package body System.OS_Primitives is
7352 +
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
7356 +   --  the spec.
7357 +
7358 +   subtype int  is Interfaces.C.int;
7359 +   subtype long is Interfaces.C.long;
7360 +
7361 +   type time_t is new int;
7362 +
7363 +   type timespec is record
7364 +      tv_sec  : time_t;
7365 +      tv_nsec : long;
7366 +   end record;
7367 +   pragma Convention (C, timespec);
7368 +
7369 +   type timezone is record
7370 +      tz_minuteswest : int;
7371 +      tz_dsttime     : int;
7372 +   end record;
7373 +   pragma Convention (C, timezone);
7374 +
7375 +   function nanosleep (rqtp, rmtp : access timespec)  return int;
7376 +   pragma Import (C, nanosleep, "nanosleep");
7377 +
7378 +   -----------
7379 +   -- Clock --
7380 +   -----------
7381 +
7382 +   function Clock return Duration is
7383 +      type timeval is array (1 .. 2) of Long_Integer;
7384 +      tzresult : aliased timezone;
7385 +
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");
7391 +
7392 +      Micro  : constant := 10**6;
7393 +      sec    : aliased Long_Integer;
7394 +      usec   : aliased Long_Integer;
7395 +      TV     : aliased timeval;
7396 +      Result : int;
7397 +
7398 +      function gettimeofday
7399 +        (Tv : access timeval;
7400 +         Tz : access timezone) return int;
7401 +      pragma Import (C, gettimeofday, "gettimeofday");
7402 +
7403 +      pragma Unreferenced (Result);
7404 +   begin
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
7409 +
7410 +      --  None of these codes signal a potential clock skew, hence the return
7411 +      --  value is never checked.
7412 +
7413 +      Result := gettimeofday (TV'Access, tzresult'Access);
7414 +      timeval_to_duration (TV'Access, sec'Access, usec'Access);
7415 +      return Duration (sec) + Duration (usec) / Micro;
7416 +   end Clock;
7417 +
7418 +   ---------------------
7419 +   -- Monotonic_Clock --
7420 +   ---------------------
7421 +
7422 +   function Monotonic_Clock return Duration renames Clock;
7423 +
7424 +   -----------------
7425 +   -- To_Timespec --
7426 +   -----------------
7427 +
7428 +   function To_Timespec (D : Duration) return timespec;
7429 +
7430 +   function To_Timespec (D : Duration) return timespec is
7431 +      S : time_t;
7432 +      F : Duration;
7433 +
7434 +   begin
7435 +      S := time_t (Long_Long_Integer (D));
7436 +      F := D - Duration (S);
7437 +
7438 +      --  If F has negative value due to a round-up, adjust for positive F
7439 +      --  value.
7440 +
7441 +      if F < 0.0 then
7442 +         S := S - 1;
7443 +         F := F + 1.0;
7444 +      end if;
7445 +
7446 +      return
7447 +        timespec'(tv_sec  => S,
7448 +                  tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
7449 +   end To_Timespec;
7450 +
7451 +   -----------------
7452 +   -- Timed_Delay --
7453 +   -----------------
7454 +
7455 +   procedure Timed_Delay
7456 +     (Time : Duration;
7457 +      Mode : Integer)
7458 +   is
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;
7465 +
7466 +      Result     : int;
7467 +      pragma Unreferenced (Result);
7468 +
7469 +   begin
7470 +      if Mode = Relative then
7471 +         Rel_Time := Time;
7472 +         Abs_Time := Time + Check_Time;
7473 +      else
7474 +         Rel_Time := Time - Check_Time;
7475 +         Abs_Time := Time;
7476 +      end if;
7477 +
7478 +      if Rel_Time > 0.0 then
7479 +         loop
7480 +            Request := To_Timespec (Rel_Time);
7481 +            Result := nanosleep (Request'Access, Remaind'Access);
7482 +            Check_Time := Clock;
7483 +
7484 +            exit when Abs_Time <= Check_Time or else Check_Time < Base_Time;
7485 +
7486 +            Rel_Time := Abs_Time - Check_Time;
7487 +         end loop;
7488 +      end if;
7489 +   end Timed_Delay;
7490 +
7491 +   ----------------
7492 +   -- Initialize --
7493 +   ----------------
7494 +
7495 +   procedure Initialize is
7496 +   begin
7497 +      null;
7498 +   end Initialize;
7499 +
7500 +end System.OS_Primitives;
7501 --- /dev/null
7502 +++ gcc/ada/s-osprim-bsd64.adb
7503 @@ -0,0 +1,192 @@
7504 +------------------------------------------------------------------------------
7505 +--                                                                          --
7506 +--                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
7507 +--                                                                          --
7508 +--                  S Y S T E M . O S _ P R I M I T I V E S                 --
7509 +--                                                                          --
7510 +--                                  B o d y                                 --
7511 +--                                                                          --
7512 +--          Copyright (C) 1998-2009, Free Software Foundation, Inc.         --
7513 +--                                                                          --
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.                                     --
7520 +--                                                                          --
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.               --
7524 +--                                                                          --
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/>.                                          --
7529 +--                                                                          --
7530 +-- GNARL was developed by the GNARL team at Florida State University.       --
7531 +-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
7532 +--                                                                          --
7533 +-- Copyright (C) 2010, 2011 John Marino <www.dragonlace.net>                --
7534 +------------------------------------------------------------------------------
7535 +
7536 +--  This version is for BSD operating systems using 64-bit time types.
7537 +
7538 +with Interfaces.C;
7539 +
7540 +package body System.OS_Primitives is
7541 +
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
7545 +   --  the spec.
7546 +
7547 +   subtype int     is Interfaces.C.int;
7548 +   subtype long    is Interfaces.C.long;
7549 +   subtype int64_t is Interfaces.Integer_64;
7550 +
7551 +   type time_t is new int64_t;
7552 +
7553 +   type timespec is record
7554 +      tv_sec  : time_t;
7555 +      tv_nsec : long;
7556 +   end record;
7557 +   pragma Convention (C, timespec);
7558 +
7559 +   type timezone is record
7560 +      tz_minuteswest : int;
7561 +      tz_dsttime     : int;
7562 +   end record;
7563 +   pragma Convention (C, timezone);
7564 +
7565 +   type timeval is record
7566 +      tv_sec  : time_t;
7567 +      tv_usec : long;   --  Not for NetBSD! FreeBSD/DragonFly
7568 +   end record;
7569 +   pragma Convention (C, timeval);
7570 +
7571 +   function nanosleep (rqtp, rmtp : access timespec)  return int;
7572 +   pragma Import (C, nanosleep, "nanosleep");
7573 +
7574 +   -----------
7575 +   -- Clock --
7576 +   -----------
7577 +
7578 +   function Clock return Duration is
7579 +
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");
7585 +
7586 +      Micro    : constant := 10**6;
7587 +      sec      : aliased Long_Integer;
7588 +      usec     : aliased Long_Integer;
7589 +      TV       : aliased timeval;
7590 +      tzresult : aliased timezone;
7591 +      Result   : int;
7592 +
7593 +      function gettimeofday
7594 +        (Tv : access timeval;
7595 +         Tz : access timezone) return int;
7596 +      pragma Import (C, gettimeofday, "gettimeofday");
7597 +
7598 +      pragma Unreferenced (Result);
7599 +   begin
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
7604 +
7605 +      --  None of these codes signal a potential clock skew, hence the return
7606 +      --  value is never checked.
7607 +
7608 +      Result := gettimeofday (TV'Access, tzresult'Access);
7609 +      timeval_to_duration (TV'Access, sec'Access, usec'Access);
7610 +      return Duration (sec) + Duration (usec) / Micro;
7611 +   end Clock;
7612 +
7613 +   ---------------------
7614 +   -- Monotonic_Clock --
7615 +   ---------------------
7616 +
7617 +   function Monotonic_Clock return Duration renames Clock;
7618 +
7619 +   -----------------
7620 +   -- To_Timespec --
7621 +   -----------------
7622 +
7623 +   function To_Timespec (D : Duration) return timespec;
7624 +
7625 +   function To_Timespec (D : Duration) return timespec is
7626 +      S : time_t;
7627 +      F : Duration;
7628 +
7629 +   begin
7630 +      S := time_t (Long_Long_Integer (D));
7631 +      F := D - Duration (S);
7632 +
7633 +      --  If F has negative value due to a round-up, adjust for positive F
7634 +      --  value.
7635 +
7636 +      if F < 0.0 then
7637 +         S := S - 1;
7638 +         F := F + 1.0;
7639 +      end if;
7640 +
7641 +      return
7642 +        timespec'(tv_sec  => S,
7643 +                  tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
7644 +   end To_Timespec;
7645 +
7646 +   -----------------
7647 +   -- Timed_Delay --
7648 +   -----------------
7649 +
7650 +   procedure Timed_Delay
7651 +     (Time : Duration;
7652 +      Mode : Integer)
7653 +   is
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;
7660 +
7661 +      Result     : int;
7662 +      pragma Unreferenced (Result);
7663 +
7664 +   begin
7665 +      if Mode = Relative then
7666 +         Rel_Time := Time;
7667 +         Abs_Time := Time + Check_Time;
7668 +      else
7669 +         Rel_Time := Time - Check_Time;
7670 +         Abs_Time := Time;
7671 +      end if;
7672 +
7673 +      if Rel_Time > 0.0 then
7674 +         loop
7675 +            Request := To_Timespec (Rel_Time);
7676 +            Result := nanosleep (Request'Access, Remaind'Access);
7677 +            Check_Time := Clock;
7678 +
7679 +            exit when Abs_Time <= Check_Time or else Check_Time < Base_Time;
7680 +
7681 +            Rel_Time := Abs_Time - Check_Time;
7682 +         end loop;
7683 +      end if;
7684 +   end Timed_Delay;
7685 +
7686 +   ----------------
7687 +   -- Initialize --
7688 +   ----------------
7689 +
7690 +   procedure Initialize is
7691 +   begin
7692 +      null;
7693 +   end Initialize;
7694 +
7695 +end System.OS_Primitives;
7696 --- /dev/null
7697 +++ gcc/ada/s-osprim-bsdn6.adb
7698 @@ -0,0 +1,193 @@
7699 +------------------------------------------------------------------------------
7700 +--                                                                          --
7701 +--                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
7702 +--                                                                          --
7703 +--                  S Y S T E M . O S _ P R I M I T I V E S                 --
7704 +--                                                                          --
7705 +--                                  B o d y                                 --
7706 +--                                                                          --
7707 +--          Copyright (C) 1998-2009, Free Software Foundation, Inc.         --
7708 +--                                                                          --
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.                                     --
7715 +--                                                                          --
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.               --
7719 +--                                                                          --
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/>.                                          --
7724 +--                                                                          --
7725 +-- GNARL was developed by the GNARL team at Florida State University.       --
7726 +-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
7727 +--                                                                          --
7728 +-- Copyright (C) 2010, 2011 John Marino <www.dragonlace.net>                --
7729 +------------------------------------------------------------------------------
7730 +
7731 +--  This version is for NetBSD 6.0+
7732 +--  It switches time type to 64 bits and uses compatibility functions
7733 +
7734 +with Interfaces.C;
7735 +
7736 +package body System.OS_Primitives is
7737 +
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
7741 +   --  the spec.
7742 +
7743 +   subtype int     is Interfaces.C.int;
7744 +   subtype long    is Interfaces.C.long;
7745 +   subtype int64_t is Interfaces.Integer_64;
7746 +
7747 +   type time_t is new int64_t;
7748 +
7749 +   type timespec is record
7750 +      tv_sec  : time_t;
7751 +      tv_nsec : long;
7752 +   end record;
7753 +   pragma Convention (C, timespec);
7754 +
7755 +   type timezone is record
7756 +      tz_minuteswest : int;
7757 +      tz_dsttime     : int;
7758 +   end record;
7759 +   pragma Convention (C, timezone);
7760 +
7761 +   type timeval is record
7762 +      tv_sec  : time_t;
7763 +      tv_usec : int;
7764 +   end record;
7765 +   pragma Convention (C, timeval);
7766 +
7767 +   function nanosleep (rqtp, rmtp : access timespec)  return int;
7768 +   pragma Import (C, nanosleep, "__nanosleep50");
7769 +
7770 +   -----------
7771 +   -- Clock --
7772 +   -----------
7773 +
7774 +   function Clock return Duration is
7775 +
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");
7781 +
7782 +      Micro    : constant := 10**6;
7783 +      sec      : aliased Long_Integer;
7784 +      usec     : aliased Long_Integer;
7785 +      TV       : aliased timeval;
7786 +      tzresult : aliased timezone;
7787 +      Result   : int;
7788 +
7789 +      function gettimeofday
7790 +        (Tv : access timeval;
7791 +         Tz : access timezone) return int;
7792 +      pragma Import (C, gettimeofday, "__gettimeofday50");
7793 +
7794 +      pragma Unreferenced (Result);
7795 +   begin
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
7800 +
7801 +      --  None of these codes signal a potential clock skew, hence the return
7802 +      --  value is never checked.
7803 +
7804 +      Result := gettimeofday (TV'Access, tzresult'Access);
7805 +      timeval_to_duration (TV'Access, sec'Access, usec'Access);
7806 +      return Duration (sec) + Duration (usec) / Micro;
7807 +   end Clock;
7808 +
7809 +   ---------------------
7810 +   -- Monotonic_Clock --
7811 +   ---------------------
7812 +
7813 +   function Monotonic_Clock return Duration renames Clock;
7814 +
7815 +   -----------------
7816 +   -- To_Timespec --
7817 +   -----------------
7818 +
7819 +   function To_Timespec (D : Duration) return timespec;
7820 +
7821 +   function To_Timespec (D : Duration) return timespec is
7822 +      S : time_t;
7823 +      F : Duration;
7824 +
7825 +   begin
7826 +      S := time_t (Long_Long_Integer (D));
7827 +      F := D - Duration (S);
7828 +
7829 +      --  If F has negative value due to a round-up, adjust for positive F
7830 +      --  value.
7831 +
7832 +      if F < 0.0 then
7833 +         S := S - 1;
7834 +         F := F + 1.0;
7835 +      end if;
7836 +
7837 +      return
7838 +        timespec'(tv_sec  => S,
7839 +                  tv_nsec => long (Long_Long_Integer (F * 10#1#E9)));
7840 +   end To_Timespec;
7841 +
7842 +   -----------------
7843 +   -- Timed_Delay --
7844 +   -----------------
7845 +
7846 +   procedure Timed_Delay
7847 +     (Time : Duration;
7848 +      Mode : Integer)
7849 +   is
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;
7856 +
7857 +      Result     : int;
7858 +      pragma Unreferenced (Result);
7859 +
7860 +   begin
7861 +      if Mode = Relative then
7862 +         Rel_Time := Time;
7863 +         Abs_Time := Time + Check_Time;
7864 +      else
7865 +         Rel_Time := Time - Check_Time;
7866 +         Abs_Time := Time;
7867 +      end if;
7868 +
7869 +      if Rel_Time > 0.0 then
7870 +         loop
7871 +            Request := To_Timespec (Rel_Time);
7872 +            Result := nanosleep (Request'Access, Remaind'Access);
7873 +            Check_Time := Clock;
7874 +
7875 +            exit when Abs_Time <= Check_Time or else Check_Time < Base_Time;
7876 +
7877 +            Rel_Time := Abs_Time - Check_Time;
7878 +         end loop;
7879 +      end if;
7880 +   end Timed_Delay;
7881 +
7882 +   ----------------
7883 +   -- Initialize --
7884 +   ----------------
7885 +
7886 +   procedure Initialize is
7887 +   begin
7888 +      null;
7889 +   end Initialize;
7890 +
7891 +end System.OS_Primitives;
7892 --- gcc/ada/s-rannum.adb.orig
7893 +++ gcc/ada/s-rannum.adb
7894 @@ -290,7 +290,7 @@
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
7900  
7901           begin
7902              Mantissa := Random (Gen) / 2**Extra_Bits;
7903 --- /dev/null
7904 +++ gcc/ada/signal_android.c
7905 @@ -0,0 +1,77 @@
7906 +/*
7907 + * Copyright (C) 2008 The Android Open Source Project
7908 + * All rights reserved.
7909 + *
7910 + * Redistribution and use in source and binary forms, with or without
7911 + * modification, are permitted provided that the following conditions
7912 + * are met:
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
7918 + *    distribution.
7919 + *
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
7931 + * SUCH DAMAGE.
7932 + */
7933 +#include <limits.h>            /* For LONG_BIT */
7934 +#include <string.h>            /* For memset() */
7935 +
7936 +typedef unsigned long sigset_t;
7937 +
7938 +
7939 +int
7940 +sigismember(sigset_t *set, int signum)
7941 +{
7942 +    unsigned long *local_set = (unsigned long *)set;
7943 +    signum--;
7944 +    return (int)((local_set[signum/LONG_BIT] >> (signum%LONG_BIT)) & 1);
7945 +}
7946 +
7947 +
7948 +int
7949 +sigaddset(sigset_t *set, int signum)
7950 +{
7951 +    unsigned long *local_set = (unsigned long *)set;
7952 +    signum--;
7953 +    local_set[signum/LONG_BIT] |= 1UL << (signum%LONG_BIT);
7954 +    return 0;
7955 +}
7956 +
7957 +
7958 +int
7959 +sigdelset(sigset_t *set, int signum)
7960 +{
7961 +    unsigned long *local_set = (unsigned long *)set;
7962 +    signum--;
7963 +    local_set[signum/LONG_BIT] &= ~(1UL << (signum%LONG_BIT));
7964 +    return 0;
7965 +}
7966 +
7967 +
7968 +int
7969 +sigemptyset(sigset_t *set)
7970 +{
7971 +    memset(set, 0, sizeof *set);
7972 +    return 0;
7973 +}
7974 +
7975 +
7976 +int
7977 +sigfillset(sigset_t *set)
7978 +{
7979 +    memset(set, ~0, sizeof *set);
7980 +    return 0;
7981 +}
7982 +
7983 --- gcc/ada/sysdep.c.orig
7984 +++ gcc/ada/sysdep.c
7985 @@ -256,6 +256,7 @@
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__)
7991  
7992  #ifdef __MINGW32__
7993 @@ -314,6 +315,7 @@
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__)
7999    char c;
8000    int nread;
8001 @@ -334,6 +336,7 @@
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];
8008  
8009 @@ -845,8 +848,12 @@
8010  /* Darwin, Free BSD, Linux, Tru64, where component tm_gmtoff is present in
8011     struct tm */
8012  
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__)
8021  {
8022    localtime_r (timer, &tp);
8023    *off = tp.tm_gmtoff;
8024 --- /dev/null
8025 +++ gcc/ada/system-dragonfly-x86.ads
8026 @@ -0,0 +1,143 @@
8027 +------------------------------------------------------------------------------
8028 +--                                                                          --
8029 +--                        GNAT RUN-TIME COMPONENTS                          --
8030 +--                                                                          --
8031 +--                               S Y S T E M                                --
8032 +--                                                                          --
8033 +--                                 S p e c                                  --
8034 +--                       (DragonFly BSD/x86 Version)                        --
8035 +--                                                                          --
8036 +--          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
8037 +--                                                                          --
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. --
8041 +--                                                                          --
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.                                     --
8048 +--                                                                          --
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.               --
8052 +--                                                                          --
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/>.                                          --
8057 +--                                                                          --
8058 +-- GNAT was originally developed  by the GNAT team at  New York University. --
8059 +-- Extensive contributions were provided by Ada Core Technologies Inc.      --
8060 +--                                                                          --
8061 +------------------------------------------------------------------------------
8062 +
8063 +package System is
8064 +   pragma Pure;
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).
8068 +
8069 +   type Name is (SYSTEM_NAME_GNAT);
8070 +   System_Name : constant Name := SYSTEM_NAME_GNAT;
8071 +
8072 +   --  System-Dependent Named Numbers
8073 +
8074 +   Min_Int               : constant := Long_Long_Integer'First;
8075 +   Max_Int               : constant := Long_Long_Integer'Last;
8076 +
8077 +   Max_Binary_Modulus    : constant := 2 ** Long_Long_Integer'Size;
8078 +   Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
8079 +
8080 +   Max_Base_Digits       : constant := Long_Long_Float'Digits;
8081 +   Max_Digits            : constant := Long_Long_Float'Digits;
8082 +
8083 +   Max_Mantissa          : constant := 63;
8084 +   Fine_Delta            : constant := 2.0 ** (-Max_Mantissa);
8085 +
8086 +   Tick                  : constant := 0.000_001;
8087 +
8088 +   --  Storage-related Declarations
8089 +
8090 +   type Address is private;
8091 +   pragma Preelaborable_Initialization (Address);
8092 +   Null_Address : constant Address;
8093 +
8094 +   Storage_Unit : constant := 8;
8095 +   Word_Size    : constant := 32;
8096 +   Memory_Size  : constant := 2 ** 32;
8097 +
8098 +   --  Address comparison
8099 +
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;
8105 +
8106 +   pragma Import (Intrinsic, "<");
8107 +   pragma Import (Intrinsic, "<=");
8108 +   pragma Import (Intrinsic, ">");
8109 +   pragma Import (Intrinsic, ">=");
8110 +   pragma Import (Intrinsic, "=");
8111 +
8112 +   --  Other System-Dependent Declarations
8113 +
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
8117 +
8118 +   --  Priority-related Declarations (RM D.1)
8119 +
8120 +   Max_Priority           : constant Positive := 30;
8121 +   Max_Interrupt_Priority : constant Positive := 31;
8122 +
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;
8126 +
8127 +   Default_Priority : constant Priority := 15;
8128 +
8129 +private
8130 +
8131 +   type Address is mod Memory_Size;
8132 +   Null_Address : constant Address := 0;
8133 +
8134 +   --------------------------------------
8135 +   -- System Implementation Parameters --
8136 +   --------------------------------------
8137 +
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.
8143 +
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;
8168 +
8169 +end System;
8170 --- /dev/null
8171 +++ gcc/ada/system-dragonfly-x86_64.ads
8172 @@ -0,0 +1,143 @@
8173 +------------------------------------------------------------------------------
8174 +--                                                                          --
8175 +--                        GNAT RUN-TIME COMPONENTS                          --
8176 +--                                                                          --
8177 +--                               S Y S T E M                                --
8178 +--                                                                          --
8179 +--                                 S p e c                                  --
8180 +--                     (DragonFly BSD/x86_64 Version)                       --
8181 +--                                                                          --
8182 +--          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
8183 +--                                                                          --
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. --
8187 +--                                                                          --
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.                                     --
8194 +--                                                                          --
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.               --
8198 +--                                                                          --
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/>.                                          --
8203 +--                                                                          --
8204 +-- GNAT was originally developed  by the GNAT team at  New York University. --
8205 +-- Extensive contributions were provided by Ada Core Technologies Inc.      --
8206 +--                                                                          --
8207 +------------------------------------------------------------------------------
8208 +
8209 +package System is
8210 +   pragma Pure;
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).
8214 +
8215 +   type Name is (SYSTEM_NAME_GNAT);
8216 +   System_Name : constant Name := SYSTEM_NAME_GNAT;
8217 +
8218 +   --  System-Dependent Named Numbers
8219 +
8220 +   Min_Int               : constant := Long_Long_Integer'First;
8221 +   Max_Int               : constant := Long_Long_Integer'Last;
8222 +
8223 +   Max_Binary_Modulus    : constant := 2 ** Long_Long_Integer'Size;
8224 +   Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
8225 +
8226 +   Max_Base_Digits       : constant := Long_Long_Float'Digits;
8227 +   Max_Digits            : constant := Long_Long_Float'Digits;
8228 +
8229 +   Max_Mantissa          : constant := 63;
8230 +   Fine_Delta            : constant := 2.0 ** (-Max_Mantissa);
8231 +
8232 +   Tick                  : constant := 0.000_001;
8233 +
8234 +   --  Storage-related Declarations
8235 +
8236 +   type Address is private;
8237 +   pragma Preelaborable_Initialization (Address);
8238 +   Null_Address : constant Address;
8239 +
8240 +   Storage_Unit : constant := 8;
8241 +   Word_Size    : constant := 64;
8242 +   Memory_Size  : constant := 2 ** 64;
8243 +
8244 +   --  Address comparison
8245 +
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;
8251 +
8252 +   pragma Import (Intrinsic, "<");
8253 +   pragma Import (Intrinsic, "<=");
8254 +   pragma Import (Intrinsic, ">");
8255 +   pragma Import (Intrinsic, ">=");
8256 +   pragma Import (Intrinsic, "=");
8257 +
8258 +   --  Other System-Dependent Declarations
8259 +
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
8263 +
8264 +   --  Priority-related Declarations (RM D.1)
8265 +
8266 +   Max_Priority           : constant Positive := 30;
8267 +   Max_Interrupt_Priority : constant Positive := 31;
8268 +
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;
8272 +
8273 +   Default_Priority : constant Priority := 15;
8274 +
8275 +private
8276 +
8277 +   type Address is mod Memory_Size;
8278 +   Null_Address : constant Address := 0;
8279 +
8280 +   --------------------------------------
8281 +   -- System Implementation Parameters --
8282 +   --------------------------------------
8283 +
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.
8289 +
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;
8314 +
8315 +end System;
8316 --- /dev/null
8317 +++ gcc/ada/system-netbsd-x86.ads
8318 @@ -0,0 +1,143 @@
8319 +------------------------------------------------------------------------------
8320 +--                                                                          --
8321 +--                        GNAT RUN-TIME COMPONENTS                          --
8322 +--                                                                          --
8323 +--                               S Y S T E M                                --
8324 +--                                                                          --
8325 +--                                 S p e c                                  --
8326 +--                           (NetBSD/x86 Version)                           --
8327 +--                                                                          --
8328 +--          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
8329 +--                                                                          --
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. --
8333 +--                                                                          --
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.                                     --
8340 +--                                                                          --
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.               --
8344 +--                                                                          --
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/>.                                          --
8349 +--                                                                          --
8350 +-- GNAT was originally developed  by the GNAT team at  New York University. --
8351 +-- Extensive contributions were provided by Ada Core Technologies Inc.      --
8352 +--                                                                          --
8353 +------------------------------------------------------------------------------
8354 +
8355 +package System is
8356 +   pragma Pure;
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).
8360 +
8361 +   type Name is (SYSTEM_NAME_GNAT);
8362 +   System_Name : constant Name := SYSTEM_NAME_GNAT;
8363 +
8364 +   --  System-Dependent Named Numbers
8365 +
8366 +   Min_Int               : constant := Long_Long_Integer'First;
8367 +   Max_Int               : constant := Long_Long_Integer'Last;
8368 +
8369 +   Max_Binary_Modulus    : constant := 2 ** Long_Long_Integer'Size;
8370 +   Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
8371 +
8372 +   Max_Base_Digits       : constant := Long_Long_Float'Digits;
8373 +   Max_Digits            : constant := Long_Long_Float'Digits;
8374 +
8375 +   Max_Mantissa          : constant := 63;
8376 +   Fine_Delta            : constant := 2.0 ** (-Max_Mantissa);
8377 +
8378 +   Tick                  : constant := 0.000_001;
8379 +
8380 +   --  Storage-related Declarations
8381 +
8382 +   type Address is private;
8383 +   pragma Preelaborable_Initialization (Address);
8384 +   Null_Address : constant Address;
8385 +
8386 +   Storage_Unit : constant := 8;
8387 +   Word_Size    : constant := 32;
8388 +   Memory_Size  : constant := 2 ** 32;
8389 +
8390 +   --  Address comparison
8391 +
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;
8397 +
8398 +   pragma Import (Intrinsic, "<");
8399 +   pragma Import (Intrinsic, "<=");
8400 +   pragma Import (Intrinsic, ">");
8401 +   pragma Import (Intrinsic, ">=");
8402 +   pragma Import (Intrinsic, "=");
8403 +
8404 +   --  Other System-Dependent Declarations
8405 +
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
8409 +
8410 +   --  Priority-related Declarations (RM D.1)
8411 +
8412 +   Max_Priority           : constant Positive := 30;
8413 +   Max_Interrupt_Priority : constant Positive := 31;
8414 +
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;
8418 +
8419 +   Default_Priority : constant Priority := 15;
8420 +
8421 +private
8422 +
8423 +   type Address is mod Memory_Size;
8424 +   Null_Address : constant Address := 0;
8425 +
8426 +   --------------------------------------
8427 +   -- System Implementation Parameters --
8428 +   --------------------------------------
8429 +
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.
8435 +
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;
8460 +
8461 +end System;
8462 --- /dev/null
8463 +++ gcc/ada/system-netbsd-x86_64.ads
8464 @@ -0,0 +1,143 @@
8465 +------------------------------------------------------------------------------
8466 +--                                                                          --
8467 +--                        GNAT RUN-TIME COMPONENTS                          --
8468 +--                                                                          --
8469 +--                               S Y S T E M                                --
8470 +--                                                                          --
8471 +--                                 S p e c                                  --
8472 +--                         (NetBSD/x86_64 Version)                          --
8473 +--                                                                          --
8474 +--          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
8475 +--                                                                          --
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. --
8479 +--                                                                          --
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.                                     --
8486 +--                                                                          --
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.               --
8490 +--                                                                          --
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/>.                                          --
8495 +--                                                                          --
8496 +-- GNAT was originally developed  by the GNAT team at  New York University. --
8497 +-- Extensive contributions were provided by Ada Core Technologies Inc.      --
8498 +--                                                                          --
8499 +------------------------------------------------------------------------------
8500 +
8501 +package System is
8502 +   pragma Pure;
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).
8506 +
8507 +   type Name is (SYSTEM_NAME_GNAT);
8508 +   System_Name : constant Name := SYSTEM_NAME_GNAT;
8509 +
8510 +   --  System-Dependent Named Numbers
8511 +
8512 +   Min_Int               : constant := Long_Long_Integer'First;
8513 +   Max_Int               : constant := Long_Long_Integer'Last;
8514 +
8515 +   Max_Binary_Modulus    : constant := 2 ** Long_Long_Integer'Size;
8516 +   Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
8517 +
8518 +   Max_Base_Digits       : constant := Long_Long_Float'Digits;
8519 +   Max_Digits            : constant := Long_Long_Float'Digits;
8520 +
8521 +   Max_Mantissa          : constant := 63;
8522 +   Fine_Delta            : constant := 2.0 ** (-Max_Mantissa);
8523 +
8524 +   Tick                  : constant := 0.000_001;
8525 +
8526 +   --  Storage-related Declarations
8527 +
8528 +   type Address is private;
8529 +   pragma Preelaborable_Initialization (Address);
8530 +   Null_Address : constant Address;
8531 +
8532 +   Storage_Unit : constant := 8;
8533 +   Word_Size    : constant := 64;
8534 +   Memory_Size  : constant := 2 ** 64;
8535 +
8536 +   --  Address comparison
8537 +
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;
8543 +
8544 +   pragma Import (Intrinsic, "<");
8545 +   pragma Import (Intrinsic, "<=");
8546 +   pragma Import (Intrinsic, ">");
8547 +   pragma Import (Intrinsic, ">=");
8548 +   pragma Import (Intrinsic, "=");
8549 +
8550 +   --  Other System-Dependent Declarations
8551 +
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
8555 +
8556 +   --  Priority-related Declarations (RM D.1)
8557 +
8558 +   Max_Priority           : constant Positive := 30;
8559 +   Max_Interrupt_Priority : constant Positive := 31;
8560 +
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;
8564 +
8565 +   Default_Priority : constant Priority := 15;
8566 +
8567 +private
8568 +
8569 +   type Address is mod Memory_Size;
8570 +   Null_Address : constant Address := 0;
8571 +
8572 +   --------------------------------------
8573 +   -- System Implementation Parameters --
8574 +   --------------------------------------
8575 +
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.
8581 +
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;
8606 +
8607 +end System;
8608 --- /dev/null
8609 +++ gcc/ada/system-openbsd-x86.ads
8610 @@ -0,0 +1,143 @@
8611 +------------------------------------------------------------------------------
8612 +--                                                                          --
8613 +--                        GNAT RUN-TIME COMPONENTS                          --
8614 +--                                                                          --
8615 +--                               S Y S T E M                                --
8616 +--                                                                          --
8617 +--                                 S p e c                                  --
8618 +--                          (OpenBSD/x86 Version)                        --
8619 +--                                                                          --
8620 +--          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
8621 +--                                                                          --
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. --
8625 +--                                                                          --
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.                                     --
8632 +--                                                                          --
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.               --
8636 +--                                                                          --
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/>.                                          --
8641 +--                                                                          --
8642 +-- GNAT was originally developed  by the GNAT team at  New York University. --
8643 +-- Extensive contributions were provided by Ada Core Technologies Inc.      --
8644 +--                                                                          --
8645 +------------------------------------------------------------------------------
8646 +
8647 +package System is
8648 +   pragma Pure;
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).
8652 +
8653 +   type Name is (SYSTEM_NAME_GNAT);
8654 +   System_Name : constant Name := SYSTEM_NAME_GNAT;
8655 +
8656 +   --  System-Dependent Named Numbers
8657 +
8658 +   Min_Int               : constant := Long_Long_Integer'First;
8659 +   Max_Int               : constant := Long_Long_Integer'Last;
8660 +
8661 +   Max_Binary_Modulus    : constant := 2 ** Long_Long_Integer'Size;
8662 +   Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
8663 +
8664 +   Max_Base_Digits       : constant := Long_Long_Float'Digits;
8665 +   Max_Digits            : constant := Long_Long_Float'Digits;
8666 +
8667 +   Max_Mantissa          : constant := 63;
8668 +   Fine_Delta            : constant := 2.0 ** (-Max_Mantissa);
8669 +
8670 +   Tick                  : constant := 0.000_001;
8671 +
8672 +   --  Storage-related Declarations
8673 +
8674 +   type Address is private;
8675 +   pragma Preelaborable_Initialization (Address);
8676 +   Null_Address : constant Address;
8677 +
8678 +   Storage_Unit : constant := 8;
8679 +   Word_Size    : constant := 32;
8680 +   Memory_Size  : constant := 2 ** 32;
8681 +
8682 +   --  Address comparison
8683 +
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;
8689 +
8690 +   pragma Import (Intrinsic, "<");
8691 +   pragma Import (Intrinsic, "<=");
8692 +   pragma Import (Intrinsic, ">");
8693 +   pragma Import (Intrinsic, ">=");
8694 +   pragma Import (Intrinsic, "=");
8695 +
8696 +   --  Other System-Dependent Declarations
8697 +
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
8701 +
8702 +   --  Priority-related Declarations (RM D.1)
8703 +
8704 +   Max_Priority           : constant Positive := 30;
8705 +   Max_Interrupt_Priority : constant Positive := 31;
8706 +
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;
8710 +
8711 +   Default_Priority : constant Priority := 15;
8712 +
8713 +private
8714 +
8715 +   type Address is mod Memory_Size;
8716 +   Null_Address : constant Address := 0;
8717 +
8718 +   --------------------------------------
8719 +   -- System Implementation Parameters --
8720 +   --------------------------------------
8721 +
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.
8727 +
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;
8752 +
8753 +end System;
8754 --- /dev/null
8755 +++ gcc/ada/system-openbsd-x86_64.ads
8756 @@ -0,0 +1,143 @@
8757 +------------------------------------------------------------------------------
8758 +--                                                                          --
8759 +--                        GNAT RUN-TIME COMPONENTS                          --
8760 +--                                                                          --
8761 +--                               S Y S T E M                                --
8762 +--                                                                          --
8763 +--                                 S p e c                                  --
8764 +--                        (OpenBSD/x86_64 Version)                       --
8765 +--                                                                          --
8766 +--          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
8767 +--                                                                          --
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. --
8771 +--                                                                          --
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.                                     --
8778 +--                                                                          --
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.               --
8782 +--                                                                          --
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/>.                                          --
8787 +--                                                                          --
8788 +-- GNAT was originally developed  by the GNAT team at  New York University. --
8789 +-- Extensive contributions were provided by Ada Core Technologies Inc.      --
8790 +--                                                                          --
8791 +------------------------------------------------------------------------------
8792 +
8793 +package System is
8794 +   pragma Pure;
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).
8798 +
8799 +   type Name is (SYSTEM_NAME_GNAT);
8800 +   System_Name : constant Name := SYSTEM_NAME_GNAT;
8801 +
8802 +   --  System-Dependent Named Numbers
8803 +
8804 +   Min_Int               : constant := Long_Long_Integer'First;
8805 +   Max_Int               : constant := Long_Long_Integer'Last;
8806 +
8807 +   Max_Binary_Modulus    : constant := 2 ** Long_Long_Integer'Size;
8808 +   Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
8809 +
8810 +   Max_Base_Digits       : constant := Long_Long_Float'Digits;
8811 +   Max_Digits            : constant := Long_Long_Float'Digits;
8812 +
8813 +   Max_Mantissa          : constant := 63;
8814 +   Fine_Delta            : constant := 2.0 ** (-Max_Mantissa);
8815 +
8816 +   Tick                  : constant := 0.000_001;
8817 +
8818 +   --  Storage-related Declarations
8819 +
8820 +   type Address is private;
8821 +   pragma Preelaborable_Initialization (Address);
8822 +   Null_Address : constant Address;
8823 +
8824 +   Storage_Unit : constant := 8;
8825 +   Word_Size    : constant := 64;
8826 +   Memory_Size  : constant := 2 ** 64;
8827 +
8828 +   --  Address comparison
8829 +
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;
8835 +
8836 +   pragma Import (Intrinsic, "<");
8837 +   pragma Import (Intrinsic, "<=");
8838 +   pragma Import (Intrinsic, ">");
8839 +   pragma Import (Intrinsic, ">=");
8840 +   pragma Import (Intrinsic, "=");
8841 +
8842 +   --  Other System-Dependent Declarations
8843 +
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
8847 +
8848 +   --  Priority-related Declarations (RM D.1)
8849 +
8850 +   Max_Priority           : constant Positive := 30;
8851 +   Max_Interrupt_Priority : constant Positive := 31;
8852 +
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;
8856 +
8857 +   Default_Priority : constant Priority := 15;
8858 +
8859 +private
8860 +
8861 +   type Address is mod Memory_Size;
8862 +   Null_Address : constant Address := 0;
8863 +
8864 +   --------------------------------------
8865 +   -- System Implementation Parameters --
8866 +   --------------------------------------
8867 +
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.
8873 +
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;
8898 +
8899 +end System;
8900 --- gcc/ada/tracebak.c.orig
8901 +++ gcc/ada/tracebak.c
8902 @@ -217,6 +217,23 @@
8903  #error Unhandled darwin architecture.
8904  #endif
8905  
8906 +/*---------------------------- x86 *BSD --------------------------------*/
8907 +
8908 +#elif defined (__i386__) &&   \
8909 +    ( defined (__NetBSD__)    \
8910 +   || defined (__FreeBSD__)   \
8911 +   || defined (__OpenBSD__)   \
8912 +   || defined (__DragonFly__) )
8913 +  
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.
8918 +*/
8919 +
8920 +#define PC_ADJUST -2
8921 +/* The minimum size of call instructions on this architecture is 2 bytes */
8922 +
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)
8938  endif
8939  
8940 +
8941 +# FREEBSD i386
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
8963  
8964 -  TOOLS_TARGET_PAIRS = \
8965 -  mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb
8966    GNATLIB_SHARED = gnatlib-shared-dual
8967  
8968 +  EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
8969 +  EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
8970 +
8971    EH_MECHANISM=-gcc
8972    THREADSLIB= -lpthread
8973    GMEM_LIB = gmemlib
8974 @@ -1231,26 +1240,101 @@
8975    MISCLIB = -lutil
8976  endif
8977  
8978 -ifeq ($(strip $(filter-out %86_64 freebsd%,$(arch) $(osys))),)
8979 +
8980 +# FREEBSD AMD64
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
9003  
9004 -  TOOLS_TARGET_PAIRS = \
9005 -  mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb
9006    GNATLIB_SHARED = gnatlib-shared-dual
9007  
9008 +  EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
9009 +  EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
9010 +
9011 +  EH_MECHANISM=-gcc
9012 +  THREADSLIB= -lpthread
9013 +  GMEM_LIB = gmemlib
9014 +  LIBRARY_VERSION := $(LIB_VERSION)
9015 +  MISCLIB = -lutil
9016 +endif
9017 +
9018 +
9019 +# DRAGONFLY i386
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
9039 +
9040 +  GNATLIB_SHARED = gnatlib-shared-dual
9041 +
9042 +  EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
9043 +  EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
9044 +
9045 +  EH_MECHANISM=-gcc
9046 +  THREADSLIB= -lpthread
9047 +  GMEM_LIB = gmemlib
9048 +  LIBRARY_VERSION := $(LIB_VERSION)
9049 +  MISCLIB = -lutil
9050 +endif
9051 +
9052 +
9053 +# DRAGONFLY AMD64
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
9073 +
9074 +  GNATLIB_SHARED = gnatlib-shared-dual
9075 +
9076 +  EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
9077 +  EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
9078 +
9079    EH_MECHANISM=-gcc
9080    THREADSLIB= -lpthread
9081    GMEM_LIB = gmemlib
9082 @@ -1258,6 +1342,200 @@
9083    MISCLIB = -lutil
9084  endif
9085  
9086 +
9087 +# OPENBSD i386
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
9107 +
9108 +  GNATLIB_SHARED = gnatlib-shared-dual
9109 +
9110 +  EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
9111 +  EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
9112 +
9113 +  EH_MECHANISM=
9114 +  THREADSLIB= -lpthread
9115 +  GMEM_LIB =
9116 +  LIBRARY_VERSION := $(LIB_VERSION)
9117 +  MISCLIB = -lutil
9118 +endif
9119 +
9120 +
9121 +# OPENBSD AMD64
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
9141 +
9142 +  GNATLIB_SHARED = gnatlib-shared-dual
9143 +
9144 +  EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
9145 +  EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
9146 +
9147 +  EH_MECHANISM=-gcc
9148 +  THREADSLIB= -lpthread
9149 +  GMEM_LIB = gmemlib
9150 +  LIBRARY_VERSION := $(LIB_VERSION)
9151 +  MISCLIB = -lutil
9152 +endif
9153 +
9154 +
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
9173 +
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
9178 +  else
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
9183 +  endif
9184 +
9185 +  GNATLIB_SHARED = gnatlib-shared-dual
9186 +
9187 +  EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
9188 +  EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
9189 +
9190 +  EH_MECHANISM=-gcc
9191 +  THREADSLIB= -lpthread
9192 +  GMEM_LIB = gmemlib
9193 +  LIBRARY_VERSION := $(LIB_VERSION)
9194 +  MISCLIB = -lutil
9195 +endif
9196 +
9197 +
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
9216 +
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
9221 +  else
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
9226 +  endif
9227 +
9228 +  GNATLIB_SHARED = gnatlib-shared-dual
9229 +
9230 +  EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
9231 +  EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
9232 +
9233 +  EH_MECHANISM=-gcc
9234 +  THREADSLIB= -lpthread
9235 +  GMEM_LIB = gmemlib
9236 +  LIBRARY_VERSION := $(LIB_VERSION)
9237 +  MISCLIB = -lutil
9238 +endif
9239 +
9240 +
9241 +# ANDROID (ARM)
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
9259 +
9260 +  ifeq ($(strip $(filter-out arm%b,$(arch))),)
9261 +    LIBGNAT_TARGET_PAIRS += \
9262 +    system.ads<system-linux-armeb.ads
9263 +  else
9264 +    LIBGNAT_TARGET_PAIRS += \
9265 +    system.ads<system-linux-armel.ads
9266 +  endif
9267 +
9268 +  EXTRA_LIBGNAT_SRCS+=         signal_android.c
9269 +  EXTRA_LIBGNAT_OBJS+=         signal_android.o
9270 +  EXTRA_GNATRTL_TASKING_OBJS=  s-linux.o
9271 +  EH_MECHANISM=
9272 +  THREADSLIB=
9273 +  MISCLIB=
9274 +  GNATLIB_SHARED=              gnatlib-shared-dual
9275 +  GMEM_LIB=                    gmemlib
9276 +  LIBRARY_VERSION:=            $(LIB_VERSION)
9277 +endif
9278 +
9279 +
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)" \
9291               gnatlib
9292 --- gnattools/configure.orig
9293 +++ gnattools/configure
9294 @@ -2058,7 +2058,27 @@
9295    s390*-*-linux*)
9296      TOOLS_TARGET_PAIRS="mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb"
9297      ;;
9298 -  *86-*-freebsd*)
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"
9303 +    ;;
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"
9308 +    ;;
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"
9313 +    ;;
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"
9318 +    ;;
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
9325 @@ -98,11 +98,31 @@
9326    s390*-*-linux*)
9327      TOOLS_TARGET_PAIRS="mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb"
9328      ;;
9329 -  *86-*-freebsd*)
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"
9334      ;;
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"
9339 +    ;;
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"
9344 +    ;;
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"
9349 +    ;;
9350 +  arm*-android-eabi)
9351 +     TOOLS_TARGET_PAIRS="\
9352 +     mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
9353 +     indepsw.adb<indepsw-gnu.adb"
9354 +    ;;
9355    mips-sgi-irix*)
9356      TOOLS_TARGET_PAIRS="mlib-tgt-specific.adb<mlib-tgt-specific-irix.adb"
9357      ;;
9358 --- gcc/ada/gcc-interface/Make-lang.in.orig
9359 +++ gcc/ada/gcc-interface/Make-lang.in
9360 @@ -541,7 +541,7 @@
9361   ada/widechar.o
9362  
9363  # Language-independent object files.
9364 -ADA_BACKEND = $(BACKEND) attribs.o
9365 +ADA_BACKEND = $(BACKEND2) attribs.o
9366  
9367  # List of target dependent sources, overridden below as necessary
9368  TARGET_ADA_SRCS =