* libgfortran.h (support_fpu_underflow_control,
[official-gcc.git] / gcc / ada / sysdep.c
blob4c4ec49d8c95ffa18de3ae983a4a91624fc7f801
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * S Y S D E P *
6 * *
7 * C Implementation File *
8 * *
9 * Copyright (C) 1992-2013, Free Software Foundation, Inc. *
10 * *
11 * GNAT is free software; you can redistribute it and/or modify it under *
12 * terms of the GNU General Public License as published by the Free Soft- *
13 * ware Foundation; either version 3, or (at your option) any later ver- *
14 * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
15 * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
16 * or FITNESS FOR A PARTICULAR PURPOSE. *
17 * *
18 * As a special exception under Section 7 of GPL version 3, you are granted *
19 * additional permissions described in the GCC Runtime Library Exception, *
20 * version 3.1, as published by the Free Software Foundation. *
21 * *
22 * You should have received a copy of the GNU General Public License and *
23 * a copy of the GCC Runtime Library Exception along with this program; *
24 * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see *
25 * <http://www.gnu.org/licenses/>. *
26 * *
27 * GNAT was originally developed by the GNAT team at New York University. *
28 * Extensive contributions were provided by Ada Core Technologies Inc. *
29 * *
30 ****************************************************************************/
32 /* This file contains system dependent symbols that are referenced in the
33 GNAT Run Time Library */
35 #ifdef __vxworks
36 #include "ioLib.h"
37 #if ! defined (VTHREADS)
38 #include "dosFsLib.h"
39 #endif
40 #if ! defined (__RTP__) && (! defined (VTHREADS) || defined (__VXWORKSMILS__))
41 # include "nfsLib.h"
42 #endif
43 #include "selectLib.h"
44 #include "vxWorks.h"
45 #if defined (__RTP__)
46 # include "vwModNum.h"
47 #endif /* __RTP__ */
48 #endif
50 #ifdef __ANDROID__
51 #undef linux
52 #endif
54 #ifdef IN_RTS
55 #define POSIX
56 #include "tconfig.h"
57 #include "tsystem.h"
58 #include <fcntl.h>
59 #include <sys/stat.h>
60 #ifdef VMS
61 #include <unixio.h>
62 #endif
63 #else
64 #include "config.h"
65 #include "system.h"
66 #endif
68 #include <time.h>
69 #include <errno.h>
71 #if defined (sun) && defined (__SVR4) && !defined (__vxworks)
72 /* The declaration is present in <time.h> but conditionalized
73 on a couple of macros we don't define. */
74 extern struct tm *localtime_r(const time_t *, struct tm *);
75 #endif
77 #include "adaint.h"
79 /* Don't use macros versions of this functions on VxWorks since they cause
80 imcompatible changes in some VxWorks versions */
81 #ifdef __vxworks
82 #undef getchar
83 #undef putchar
84 #undef feof
85 #undef ferror
86 #undef fileno
87 #endif
90 Notes:
92 (1) Opening a file with read mode fails if the file does not exist or
93 cannot be read.
95 (2) Opening a file with append mode causes all subsequent writes to the
96 file to be forced to the then current end-of-file, regardless of
97 intervening calls to the fseek function.
99 (3) When a file is opened with update mode, both input and output may be
100 performed on the associated stream. However, output may not be directly
101 followed by input without an intervening call to the fflush function or
102 to a file positioning function (fseek, fsetpos, or rewind), and input
103 may not be directly followed by output without an intervening call to a
104 file positioning function, unless the input operation encounters
105 end-of-file.
107 The other target dependent declarations here are for the two functions
108 __gnat_set_binary_mode and __gnat_set_text_mode:
110 void __gnat_set_binary_mode (int handle);
111 void __gnat_set_text_mode (int handle);
113 These functions have no effect in Unix (or similar systems where there is
114 no distinction between binary and text files), but in DOS (and similar
115 systems where text mode does CR/LF translation), these functions allow
116 the mode of the stream with the given handle (fileno can be used to get
117 the handle of a stream) to be changed dynamically. The returned result
118 is 0 if no error occurs and -1 if an error occurs.
120 Finally there is a boolean (character) variable
122 char __gnat_text_translation_required;
124 which is zero (false) in Unix mode, and one (true) in DOS mode, with a
125 true value indicating that text translation is required on text files
126 and that fopen supports the trailing t and b modifiers.
130 #if defined (WINNT) || defined (__CYGWIN__)
132 const char __gnat_text_translation_required = 1;
134 #ifdef __CYGWIN__
135 #define WIN_SETMODE setmode
136 #include <io.h>
137 #else
138 #define WIN_SETMODE _setmode
139 #endif
141 void
142 __gnat_set_binary_mode (int handle)
144 WIN_SETMODE (handle, O_BINARY);
147 void
148 __gnat_set_text_mode (int handle)
150 WIN_SETMODE (handle, O_TEXT);
153 #ifdef __CYGWIN__
155 char *
156 __gnat_ttyname (int filedes)
158 extern char *ttyname (int);
160 return ttyname (filedes);
163 #endif /* __CYGWIN__ */
165 #if defined (__CYGWIN__) || defined (__MINGW32__)
166 #include <windows.h>
168 #ifndef RTX
170 int __gnat_is_windows_xp (void);
173 __gnat_is_windows_xp (void)
175 static int is_win_xp=0, is_win_xp_checked=0;
177 if (!is_win_xp_checked)
179 OSVERSIONINFO version;
181 is_win_xp_checked = 1;
183 memset (&version, 0, sizeof (version));
184 version.dwOSVersionInfoSize = sizeof (version);
186 is_win_xp = GetVersionEx (&version)
187 && version.dwPlatformId == VER_PLATFORM_WIN32_NT
188 && (version.dwMajorVersion > 5
189 || (version.dwMajorVersion == 5 && version.dwMinorVersion >= 1));
191 return is_win_xp;
194 #endif /* !RTX */
196 /* Get the bounds of the stack. The stack pointer is supposed to be
197 initialized to BASE when a thread is created and the stack can be extended
198 to LIMIT before reaching a guard page.
199 Note: for the main thread, the system automatically extend the stack, so
200 LIMIT is only the current limit. */
202 void
203 __gnat_get_stack_bounds (void **base, void **limit)
205 NT_TIB *tib;
207 /* We know that the first field of the TEB is the TIB. */
208 tib = (NT_TIB *)NtCurrentTeb ();
210 *base = tib->StackBase;
211 *limit = tib->StackLimit;
214 #endif /* __CYGWIN__ || __MINGW32__ */
216 #ifdef __MINGW32__
218 /* Return the name of the tty. Under windows there is no name for
219 the tty, so this function, if connected to a tty, returns the generic name
220 "console". */
222 char *
223 __gnat_ttyname (int filedes)
225 if (isatty (filedes))
226 return "console";
227 else
228 return NULL;
231 #endif /* __MINGW32__ */
233 #else
235 const char __gnat_text_translation_required = 0;
237 /* These functions do nothing in non-DOS systems. */
239 void
240 __gnat_set_binary_mode (int handle ATTRIBUTE_UNUSED)
244 void
245 __gnat_set_text_mode (int handle ATTRIBUTE_UNUSED)
248 char *
249 __gnat_ttyname (int filedes)
251 #if defined (__vxworks) || defined (__nucleus)
252 return "";
253 #else
254 extern char *ttyname (int);
256 return ttyname (filedes);
257 #endif /* defined (__vxworks) || defined (__nucleus) */
259 #endif
261 #if defined (linux) || defined (sun) \
262 || defined (WINNT) \
263 || defined (__MACHTEN__) || defined (__hpux__) || defined (_AIX) \
264 || (defined (__svr4__) && defined (i386)) || defined (__Lynx__) \
265 || defined (__CYGWIN__) || defined (__FreeBSD__) || defined (__OpenBSD__) \
266 || defined (__GLIBC__) || defined (__APPLE__)
268 # ifdef __MINGW32__
269 # if OLD_MINGW
270 # include <termios.h>
271 # else
272 # include <conio.h> /* for getch(), kbhit() */
273 # endif
274 # else
275 # include <termios.h>
276 # endif
278 #else
279 # if defined (VMS)
280 extern char *decc$ga_stdscr;
281 static int initted = 0;
282 # endif
283 #endif
285 /* Implements the common processing for getc_immediate and
286 getc_immediate_nowait. */
288 extern void getc_immediate (FILE *, int *, int *);
289 extern void getc_immediate_nowait (FILE *, int *, int *, int *);
290 extern void getc_immediate_common (FILE *, int *, int *, int *, int);
292 /* Called by Get_Immediate (Foo); */
294 void
295 getc_immediate (FILE *stream, int *ch, int *end_of_file)
297 int avail;
299 getc_immediate_common (stream, ch, end_of_file, &avail, 1);
302 /* Called by Get_Immediate (Foo, Available); */
304 void
305 getc_immediate_nowait (FILE *stream, int *ch, int *end_of_file, int *avail)
307 getc_immediate_common (stream, ch, end_of_file, avail, 0);
310 /* Called by getc_immediate () and getc_immediate_nowait () */
312 void
313 getc_immediate_common (FILE *stream,
314 int *ch,
315 int *end_of_file,
316 int *avail,
317 int waiting)
319 #if defined (linux) || defined (sun) \
320 || defined (__CYGWIN32__) || defined (__MACHTEN__) || defined (__hpux__) \
321 || defined (_AIX) || (defined (__svr4__) && defined (i386)) \
322 || defined (__Lynx__) || defined (__FreeBSD__) || defined (__OpenBSD__) \
323 || defined (__GLIBC__) || defined (__APPLE__)
324 char c;
325 int nread;
326 int good_one = 0;
327 int eof_ch = 4; /* Ctrl-D */
328 int fd = fileno (stream);
329 struct termios otermios_rec, termios_rec;
331 if (isatty (fd))
333 tcgetattr (fd, &termios_rec);
334 memcpy (&otermios_rec, &termios_rec, sizeof (struct termios));
336 /* Set RAW mode, with no echo */
337 termios_rec.c_lflag = termios_rec.c_lflag & ~ICANON & ~ECHO;
339 #if defined(linux) || defined (sun) \
340 || defined (__MACHTEN__) || defined (__hpux__) \
341 || defined (_AIX) || (defined (__svr4__) && defined (i386)) \
342 || defined (__Lynx__) || defined (__FreeBSD__) || defined (__OpenBSD__) \
343 || defined (__GLIBC__) || defined (__APPLE__)
344 eof_ch = termios_rec.c_cc[VEOF];
346 /* If waiting (i.e. Get_Immediate (Char)), set MIN = 1 and wait for
347 a character forever. This doesn't seem to effect Ctrl-Z or
348 Ctrl-C processing.
349 If not waiting (i.e. Get_Immediate (Char, Available)),
350 don't wait for anything but timeout immediately. */
351 termios_rec.c_cc[VMIN] = waiting;
352 termios_rec.c_cc[VTIME] = 0;
353 #endif
354 tcsetattr (fd, TCSANOW, &termios_rec);
356 while (! good_one)
358 /* Read is used here instead of fread, because fread doesn't
359 work on Solaris5 and Sunos4 in this situation. Maybe because we
360 are mixing calls that use file descriptors and streams. */
361 nread = read (fd, &c, 1);
362 if (nread > 0)
364 /* On Unix terminals, Ctrl-D (EOT) is an End of File. */
365 if (c == eof_ch)
367 *avail = 0;
368 *end_of_file = 1;
369 good_one = 1;
372 /* Everything else is ok */
373 else if (c != eof_ch)
375 *avail = 1;
376 *end_of_file = 0;
377 good_one = 1;
381 else if (! waiting)
383 *avail = 0;
384 *end_of_file = 0;
385 good_one = 1;
387 else
388 good_one = 0;
391 tcsetattr (fd, TCSANOW, &otermios_rec);
392 *ch = c;
395 else
396 #elif defined (VMS)
397 int fd = fileno (stream);
399 if (isatty (fd))
401 if (initted == 0)
403 decc$bsd_initscr ();
404 initted = 1;
407 decc$bsd_cbreak ();
408 *ch = decc$bsd_wgetch (decc$ga_stdscr);
410 if (*ch == 4)
411 *end_of_file = 1;
412 else
413 *end_of_file = 0;
415 *avail = 1;
416 decc$bsd_nocbreak ();
418 else
419 #elif defined (__MINGW32__)
420 int fd = fileno (stream);
421 int char_waiting;
422 int eot_ch = 4; /* Ctrl-D */
424 if (isatty (fd))
426 if (waiting)
428 *ch = getch ();
430 if (*ch == eot_ch)
431 *end_of_file = 1;
432 else
433 *end_of_file = 0;
435 *avail = 1;
437 else /* ! waiting */
439 char_waiting = kbhit();
441 if (char_waiting == 1)
443 *avail = 1;
444 *ch = getch ();
446 if (*ch == eot_ch)
447 *end_of_file = 1;
448 else
449 *end_of_file = 0;
451 else
453 *avail = 0;
454 *end_of_file = 0;
458 else
459 #elif defined (__vxworks)
460 /* Bit masks of file descriptors to read from. */
461 struct fd_set readFds;
462 /* Timeout before select returns if nothing can be read. */
463 struct timeval timeOut;
464 char c;
465 int fd = fileno (stream);
466 int nread;
467 int option;
468 int readable;
469 int status;
470 int width;
472 if (isatty (fd))
474 /* If we do not want to wait, we have to set up fd in RAW mode. This
475 should be done outside this function as setting fd in RAW mode under
476 vxWorks flushes the buffer of fd. If the RAW mode was set here, the
477 buffer would be empty and we would always return that no character
478 is available */
479 if (! waiting)
481 /* Initialization of timeOut for its use with select. */
482 timeOut.tv_sec = 0;
483 timeOut.tv_usec = 0;
485 /* Initialization of readFds for its use with select;
486 FD is the only file descriptor to be monitored */
487 FD_ZERO (&readFds);
488 FD_SET (fd, &readFds);
489 width = 2;
491 /* We do all this processing to emulate a non blocking read. */
492 readable = select (width, &readFds, NULL, NULL, &timeOut);
493 if (readable == ERROR)
494 *avail = -1, *end_of_file = -1;
495 /* No character available in input. */
496 else if (readable == 0)
497 *avail = 0, *end_of_file = 0;
498 else
500 nread = read (fd, &c, 1);
501 if (nread > 0)
502 *avail = 1, *end_of_file = 0;
503 /* End Of File. */
504 else if (nread == 0)
505 *avail = 0, *end_of_file = 1;
506 /* Error. */
507 else
508 *avail = -1, *end_of_file = -1;
512 /* We have to wait until we get a character */
513 else
515 *avail = -1;
516 *end_of_file = -1;
518 /* Save the current mode of FD. */
519 option = ioctl (fd, FIOGETOPTIONS, 0);
521 /* Set FD in RAW mode. */
522 status = ioctl (fd, FIOSETOPTIONS, OPT_RAW);
523 if (status != -1)
525 nread = read (fd, &c, 1);
526 if (nread > 0)
527 *avail = 1, *end_of_file = 0;
528 /* End of file. */
529 else if (nread == 0)
530 *avail = 0, *end_of_file = 1;
531 /* Else there is an ERROR. */
534 /* Revert FD to its previous mode. */
535 status = ioctl (fd, FIOSETOPTIONS, option);
538 *ch = c;
540 else
541 #endif
543 /* If we're not on a terminal, then we don't need any fancy processing.
544 Also this is the only thing that's left if we're not on one of the
545 supported systems; which means that for non supported systems,
546 get_immediate may wait for a carriage return on terminals. */
547 *ch = fgetc (stream);
548 if (feof (stream))
550 *end_of_file = 1;
551 *avail = 0;
553 else
555 *end_of_file = 0;
556 *avail = 1;
561 /* The following definitions are provided in NT to support Windows based
562 Ada programs. */
564 #ifdef WINNT
565 #include <windows.h>
567 /* Provide functions to echo the values passed to WinMain (windows bindings
568 will want to import these). We use the same names as the routines used
569 by AdaMagic for compatibility. */
571 char *rts_get_hInstance (void);
572 char *rts_get_hPrevInstance (void);
573 char *rts_get_lpCommandLine (void);
574 int rts_get_nShowCmd (void);
576 char *
577 rts_get_hInstance (void)
579 return (char *)GetModuleHandleA (0);
582 char *
583 rts_get_hPrevInstance (void)
585 return 0;
588 char *
589 rts_get_lpCommandLine (void)
591 return GetCommandLineA ();
595 rts_get_nShowCmd (void)
597 return 1;
600 #endif /* WINNT */
601 #ifdef VMS
603 /* This gets around a problem with using the old threads library on VMS 7.0. */
605 extern long get_gmtoff (void);
607 long
608 get_gmtoff (void)
610 time_t t;
611 struct tm *ts;
613 t = time ((time_t) 0);
614 ts = localtime (&t);
615 return ts->tm_gmtoff;
617 #endif
619 /* This value is returned as the time zone offset when a valid value
620 cannot be determined. It is simply a bizarre value that will never
621 occur. It is 3 days plus 73 seconds (offset is in seconds). */
623 long __gnat_invalid_tzoff = 259273;
625 /* Definition of __gnat_localtime_r used by a-calend.adb */
627 #if defined (__MINGW32__)
629 #ifdef CERT
631 /* For the Cert run times on native Windows we use dummy functions
632 for locking and unlocking tasks since we do not support multiple
633 threads on this configuration (Cert run time on native Windows). */
635 void dummy (void) {}
637 void (*Lock_Task) () = &dummy;
638 void (*Unlock_Task) () = &dummy;
640 #else
642 #define Lock_Task system__soft_links__lock_task
643 extern void (*Lock_Task) (void);
645 #define Unlock_Task system__soft_links__unlock_task
646 extern void (*Unlock_Task) (void);
648 #endif
650 /* Reentrant localtime for Windows. */
652 extern void
653 __gnat_localtime_tzoff (const time_t *, const int *, long *);
655 static const unsigned long long w32_epoch_offset = 11644473600ULL;
656 void
657 __gnat_localtime_tzoff (const time_t *timer, const int *is_historic, long *off)
659 TIME_ZONE_INFORMATION tzi;
661 BOOL rtx_active;
662 DWORD tzi_status;
664 #ifdef RTX
665 rtx_active = 1;
666 #else
667 rtx_active = 0;
668 #endif
670 (*Lock_Task) ();
672 tzi_status = GetTimeZoneInformation (&tzi);
674 /* Processing for RTX targets or cases where we simply want to extract the
675 offset of the current time zone, regardless of the date. A value of "0"
676 for flag "is_historic" signifies that the date is NOT historic, see the
677 body of Ada.Calendar.UTC_Time_Offset. */
679 if (rtx_active || *is_historic == 0) {
680 *off = tzi.Bias;
682 /* The system is operating in the range covered by the StandardDate
683 member. */
684 if (tzi_status == TIME_ZONE_ID_STANDARD) {
685 *off = *off + tzi.StandardBias;
688 /* The system is operating in the range covered by the DaylightDate
689 member. */
690 else if (tzi_status == TIME_ZONE_ID_DAYLIGHT) {
691 *off = *off + tzi.DaylightBias;
694 *off = *off * -60;
697 /* Time zone offset calculations for a historic or future date */
699 else {
700 union
702 FILETIME ft_time;
703 unsigned long long ull_time;
704 } utc_time, local_time;
706 SYSTEMTIME utc_sys_time, local_sys_time;
707 BOOL status;
709 /* First convert unix time_t structure to windows FILETIME format. */
710 utc_time.ull_time = ((unsigned long long) *timer + w32_epoch_offset)
711 * 10000000ULL;
713 /* If GetTimeZoneInformation does not return a value between 0 and 2 then
714 it means that we were not able to retrieve timezone informations. Note
715 that we cannot use here FileTimeToLocalFileTime as Windows will use in
716 always in this case the current timezone setting. As suggested on MSDN
717 we use the following three system calls to get the right information.
718 Note also that starting with Windows Vista new functions are provided
719 to get timezone settings that depend on the year. We cannot use them as
720 we still support Windows XP and Windows 2003. */
722 status = (tzi_status >= 0 && tzi_status <= 2)
723 && FileTimeToSystemTime (&utc_time.ft_time, &utc_sys_time)
724 && SystemTimeToTzSpecificLocalTime (&tzi, &utc_sys_time, &local_sys_time)
725 && SystemTimeToFileTime (&local_sys_time, &local_time.ft_time);
727 /* An error has occurred, return invalid_tzoff */
729 if (!status) {
730 *off = __gnat_invalid_tzoff;
732 else {
733 if (local_time.ull_time > utc_time.ull_time) {
734 *off = (long) ((local_time.ull_time - utc_time.ull_time)
735 / 10000000ULL);
737 else {
738 *off = - (long) ((utc_time.ull_time - local_time.ull_time)
739 / 10000000ULL);
744 (*Unlock_Task) ();
747 #else
749 /* On Lynx, all time values are treated in GMT */
751 #if defined (__Lynx__)
753 /* As of LynxOS 3.1.0a patch level 040, LynuxWorks changes the
754 prototype to the C library function localtime_r from the POSIX.4
755 Draft 9 to the POSIX 1.c version. Before this change the following
756 spec is required. Only use when ___THREADS_POSIX4ad4__ is defined,
757 the Lynx convention when building against the legacy API. */
759 extern void
760 __gnat_localtime_tzoff (const time_t *, const int *, long *);
762 void
763 __gnat_localtime_tzoff (const time_t *timer, const int *is_historic, long *off)
765 *off = 0;
768 #else
770 /* VMS does not need __gnat_localtime_tzoff */
772 #if defined (VMS)
774 /* Other targets except Lynx, VMS and Windows provide a standard localtime_r */
776 #else
778 #define Lock_Task system__soft_links__lock_task
779 extern void (*Lock_Task) (void);
781 #define Unlock_Task system__soft_links__unlock_task
782 extern void (*Unlock_Task) (void);
784 extern void
785 __gnat_localtime_tzoff (const time_t *, const int *, long *);
787 void
788 __gnat_localtime_tzoff (const time_t *timer, const int *is_historic, long *off)
790 struct tm tp;
792 /* AIX, HPUX, Sun Solaris */
793 #if defined (_AIX) || defined (__hpux__) || defined (sun)
795 (*Lock_Task) ();
797 localtime_r (timer, &tp);
798 *off = (long) -timezone;
800 (*Unlock_Task) ();
802 /* Correct the offset if Daylight Saving Time is in effect */
804 if (tp.tm_isdst > 0)
805 *off = *off + 3600;
808 /* VxWorks */
809 #elif defined (__vxworks)
810 #include <stdlib.h>
812 (*Lock_Task) ();
814 localtime_r (timer, &tp);
816 /* Try to read the environment variable TIMEZONE. The variable may not have
817 been initialize, in that case return an offset of zero (0) for UTC. */
819 char *tz_str = getenv ("TIMEZONE");
821 if ((tz_str == NULL) || (*tz_str == '\0'))
822 *off = 0;
823 else
825 char *tz_start, *tz_end;
827 /* The format of the data contained in TIMEZONE is N::U:S:E where N is the
828 name of the time zone, U are the minutes difference from UTC, S is the
829 start of DST in mmddhh and E is the end of DST in mmddhh. Extracting
830 the value of U involves setting two pointers, one at the beginning and
831 one at the end of the value. The end pointer is then set to null in
832 order to delimit a string slice for atol to process. */
834 tz_start = index (tz_str, ':') + 2;
835 tz_end = index (tz_start, ':');
836 tz_end = '\0';
838 /* The Ada layer expects an offset in seconds. Note that we must reverse
839 the sign of the result since west is positive and east is negative on
840 VxWorks targets. */
842 *off = -atol (tz_start) * 60;
844 /* Correct the offset if Daylight Saving Time is in effect */
846 if (tp.tm_isdst > 0)
847 *off = *off + 3600;
850 (*Unlock_Task) ();
853 /* Darwin, Free BSD, Linux, where component tm_gmtoff is present in
854 struct tm */
856 #elif defined (__APPLE__) || defined (__FreeBSD__) || defined (linux) ||\
857 defined (__GLIBC__)
859 localtime_r (timer, &tp);
860 *off = tp.tm_gmtoff;
863 /* Default: treat all time values in GMT */
865 #else
866 *off = 0;
868 #endif
871 #endif
872 #endif
873 #endif
875 #ifdef __vxworks
877 #include <taskLib.h>
879 /* __gnat_get_task_options is used by s-taprop.adb only for VxWorks. This
880 function returns the options to be set when creating a new task. It fetches
881 the options assigned to the current task (parent), so offering some user
882 level control over the options for a task hierarchy. It forces VX_FP_TASK
883 because it is almost always required. On processors with the SPE
884 category, VX_SPE_TASK should be used instead to enable the SPE. */
885 extern int __gnat_get_task_options (void);
888 __gnat_get_task_options (void)
890 int options;
892 /* Get the options for the task creator */
893 taskOptionsGet (taskIdSelf (), &options);
895 /* Force VX_FP_TASK or VX_SPE_TASK as needed */
896 #if defined (__SPE__)
897 options |= VX_SPE_TASK;
898 #else
899 options |= VX_FP_TASK;
900 #endif
902 /* Mask those bits that are not under user control */
903 #ifdef VX_USR_TASK_OPTIONS
904 return options & VX_USR_TASK_OPTIONS;
905 #else
906 return options;
907 #endif
910 #endif
913 __gnat_is_file_not_found_error (int errno_val) {
914 switch (errno_val) {
915 case ENOENT:
916 #ifdef __vxworks
917 /* In the case of VxWorks, we also have to take into account various
918 * filesystem-specific variants of this error.
920 #if ! defined (VTHREADS)
921 case S_dosFsLib_FILE_NOT_FOUND:
922 #endif
923 #if ! defined (__RTP__) && (! defined (VTHREADS) || defined (__VXWORKSMILS__))
924 case S_nfsLib_NFSERR_NOENT:
925 #endif
926 #if defined (__RTP__)
927 /* An RTP can return an NFS file not found, and the NFS bits must
928 first be masked on to check the errno. */
929 case M_nfsStat | ENOENT:
930 #endif
931 #endif
932 return 1;
934 default:
935 return 0;
939 #ifdef __ANDROID__
941 /* Provide extern symbols for sig* as needed by the tasking run-time, instead
942 of static inline functions. */
944 #include <signal.h>
947 _sigismember (sigset_t *set, int signum)
949 return sigismember (set, signum);
953 _sigaddset (sigset_t *set, int signum)
955 return sigaddset (set, signum);
959 _sigdelset (sigset_t *set, int signum)
961 return sigdelset (set, signum);
965 _sigemptyset (sigset_t *set)
967 return sigemptyset (set);
971 _sigfillset (sigset_t *set)
973 return sigfillset (set);
976 #include <unistd.h>
978 _getpagesize (void)
980 return getpagesize ();
982 #endif