gcc/ChangeLog:
[official-gcc.git] / gcc / ada / sysdep.c
blob465007eb15df437103bef085c794ae63cb904cfa
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * S Y S D E P *
6 * *
7 * C Implementation File *
8 * *
9 * Copyright (C) 1992-2015, 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 #include "version.h"
46 #if defined (__RTP__)
47 # include "vwModNum.h"
48 #endif /* __RTP__ */
49 #endif
51 #ifdef __ANDROID__
52 #undef __linux__
53 #endif
55 #ifdef IN_RTS
56 #define POSIX
57 #include "tconfig.h"
58 #include "tsystem.h"
59 #include <fcntl.h>
60 #include <sys/stat.h>
61 #else
62 #include "config.h"
63 #include "system.h"
64 #endif
66 #include <time.h>
67 #include <errno.h>
69 #if defined (__sun__) && !defined (__vxworks)
70 /* The declaration is present in <time.h> but conditionalized
71 on a couple of macros we don't define. */
72 extern struct tm *localtime_r(const time_t *, struct tm *);
73 #endif
75 #include "adaint.h"
77 /* Don't use macros versions of this functions on VxWorks since they cause
78 imcompatible changes in some VxWorks versions */
79 #ifdef __vxworks
80 #undef getchar
81 #undef putchar
82 #undef feof
83 #undef ferror
84 #undef fileno
85 #endif
88 Notes:
90 (1) Opening a file with read mode fails if the file does not exist or
91 cannot be read.
93 (2) Opening a file with append mode causes all subsequent writes to the
94 file to be forced to the then current end-of-file, regardless of
95 intervening calls to the fseek function.
97 (3) When a file is opened with update mode, both input and output may be
98 performed on the associated stream. However, output may not be directly
99 followed by input without an intervening call to the fflush function or
100 to a file positioning function (fseek, fsetpos, or rewind), and input
101 may not be directly followed by output without an intervening call to a
102 file positioning function, unless the input operation encounters
103 end-of-file.
105 The other target dependent declarations here are for the three functions
106 __gnat_set_binary_mode, __gnat_set_text_mode and __gnat_set_mode:
108 void __gnat_set_binary_mode (int handle);
109 void __gnat_set_text_mode (int handle);
110 void __gnat_set_mode (int handle, int mode);
112 These functions have no effect in Unix (or similar systems where there is
113 no distinction between binary and text files), but in DOS (and similar
114 systems where text mode does CR/LF translation), these functions allow
115 the mode of the stream with the given handle (fileno can be used to get
116 the handle of a stream) to be changed dynamically. The returned result
117 is 0 if no error occurs and -1 if an error occurs.
119 Finally there is a boolean (character) variable
121 char __gnat_text_translation_required;
123 which is zero (false) in Unix mode, and one (true) in DOS mode, with a
124 true value indicating that text translation is required on text files
125 and that fopen supports the trailing t and b modifiers.
129 #if defined (WINNT) || defined (__CYGWIN__)
131 const char __gnat_text_translation_required = 1;
133 #ifdef __CYGWIN__
134 #define WIN_SETMODE setmode
135 #include <io.h>
136 #else
137 #define WIN_SETMODE _setmode
138 #endif
140 void
141 __gnat_set_binary_mode (int handle)
143 WIN_SETMODE (handle, O_BINARY);
146 void
147 __gnat_set_text_mode (int handle)
149 WIN_SETMODE (handle, O_TEXT);
152 void
153 __gnat_set_mode (int handle, int mode)
155 /* the values here must be synchronized with
156 System.File_Control_Block.Content_Encodding:
158 None = 0
159 Default_Text = 1
160 Text = 2
161 U8text = 3
162 Wtext = 4
163 U16text = 5 */
165 switch (mode) {
166 case 0 : WIN_SETMODE (handle, _O_BINARY); break;
167 case 1 : WIN_SETMODE (handle, CurrentCCSEncoding); break;
168 case 2 : WIN_SETMODE (handle, _O_TEXT); break;
169 case 3 : WIN_SETMODE (handle, _O_U8TEXT); break;
170 case 4 : WIN_SETMODE (handle, _O_WTEXT); break;
171 case 5 : WIN_SETMODE (handle, _O_U16TEXT); break;
175 #ifdef __CYGWIN__
177 char *
178 __gnat_ttyname (int filedes)
180 extern char *ttyname (int);
182 return ttyname (filedes);
185 #endif /* __CYGWIN__ */
187 #if defined (__CYGWIN__) || defined (__MINGW32__)
188 #include <windows.h>
190 int __gnat_is_windows_xp (void);
193 __gnat_is_windows_xp (void)
195 static int is_win_xp=0, is_win_xp_checked=0;
197 if (!is_win_xp_checked)
199 OSVERSIONINFO version;
201 is_win_xp_checked = 1;
203 memset (&version, 0, sizeof (version));
204 version.dwOSVersionInfoSize = sizeof (version);
206 is_win_xp = GetVersionEx (&version)
207 && version.dwPlatformId == VER_PLATFORM_WIN32_NT
208 && (version.dwMajorVersion > 5
209 || (version.dwMajorVersion == 5 && version.dwMinorVersion >= 1));
211 return is_win_xp;
214 /* Get the bounds of the stack. The stack pointer is supposed to be
215 initialized to BASE when a thread is created and the stack can be extended
216 to LIMIT before reaching a guard page.
217 Note: for the main thread, the system automatically extend the stack, so
218 LIMIT is only the current limit. */
220 void
221 __gnat_get_stack_bounds (void **base, void **limit)
223 NT_TIB *tib;
225 /* We know that the first field of the TEB is the TIB. */
226 tib = (NT_TIB *)NtCurrentTeb ();
228 *base = tib->StackBase;
229 *limit = tib->StackLimit;
232 #endif /* __CYGWIN__ || __MINGW32__ */
234 #ifdef __MINGW32__
236 /* Return the name of the tty. Under windows there is no name for
237 the tty, so this function, if connected to a tty, returns the generic name
238 "console". */
240 char *
241 __gnat_ttyname (int filedes)
243 if (isatty (filedes))
244 return "console";
245 else
246 return NULL;
249 #endif /* __MINGW32__ */
251 #else
253 const char __gnat_text_translation_required = 0;
255 /* These functions do nothing in non-DOS systems. */
257 void
258 __gnat_set_binary_mode (int handle ATTRIBUTE_UNUSED)
262 void
263 __gnat_set_text_mode (int handle ATTRIBUTE_UNUSED)
267 void
268 __gnat_set_mode (int handle ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
272 char *
273 __gnat_ttyname (int filedes)
275 #if defined (__vxworks)
276 return "";
277 #else
278 extern char *ttyname (int);
280 return ttyname (filedes);
281 #endif /* defined (__vxworks) */
283 #endif
285 #if defined (__linux__) || defined (__sun__) \
286 || defined (WINNT) \
287 || defined (__MACHTEN__) || defined (__hpux__) || defined (_AIX) \
288 || (defined (__svr4__) && defined (__i386__)) || defined (__Lynx__) \
289 || defined (__CYGWIN__) || defined (__FreeBSD__) || defined (__OpenBSD__) \
290 || defined (__GLIBC__) || defined (__APPLE__) || defined (__DragonFly__)
292 # ifdef __MINGW32__
293 # if OLD_MINGW
294 # include <termios.h>
295 # else
296 # include <conio.h> /* for getch(), kbhit() */
297 # endif
298 # else
299 # include <termios.h>
300 # endif
302 #endif
304 /* Implements the common processing for getc_immediate and
305 getc_immediate_nowait. */
307 extern void getc_immediate (FILE *, int *, int *);
308 extern void getc_immediate_nowait (FILE *, int *, int *, int *);
309 extern void getc_immediate_common (FILE *, int *, int *, int *, int);
311 /* Called by Get_Immediate (Foo); */
313 void
314 getc_immediate (FILE *stream, int *ch, int *end_of_file)
316 int avail;
318 getc_immediate_common (stream, ch, end_of_file, &avail, 1);
321 /* Called by Get_Immediate (Foo, Available); */
323 void
324 getc_immediate_nowait (FILE *stream, int *ch, int *end_of_file, int *avail)
326 getc_immediate_common (stream, ch, end_of_file, avail, 0);
329 /* Called by getc_immediate () and getc_immediate_nowait () */
331 void
332 getc_immediate_common (FILE *stream,
333 int *ch,
334 int *end_of_file,
335 int *avail,
336 int waiting ATTRIBUTE_UNUSED)
338 #if defined (__linux__) || defined (__sun__) \
339 || defined (__CYGWIN32__) || defined (__MACHTEN__) || defined (__hpux__) \
340 || defined (_AIX) || (defined (__svr4__) && defined (__i386__)) \
341 || defined (__Lynx__) || defined (__FreeBSD__) || defined (__OpenBSD__) \
342 || defined (__GLIBC__) || defined (__APPLE__) || defined (__DragonFly__)
343 char c;
344 int nread;
345 int good_one = 0;
346 int eof_ch = 4; /* Ctrl-D */
347 int fd = fileno (stream);
348 struct termios otermios_rec, termios_rec;
350 if (isatty (fd))
352 tcgetattr (fd, &termios_rec);
353 memcpy (&otermios_rec, &termios_rec, sizeof (struct termios));
355 /* Set RAW mode, with no echo */
356 termios_rec.c_lflag = termios_rec.c_lflag & ~ICANON & ~ECHO;
358 #if defined (__linux__) || defined (__sun__) \
359 || defined (__MACHTEN__) || defined (__hpux__) \
360 || defined (_AIX) || (defined (__svr4__) && defined (__i386__)) \
361 || defined (__Lynx__) || defined (__FreeBSD__) || defined (__OpenBSD__) \
362 || defined (__GLIBC__) || defined (__APPLE__) || defined (__DragonFly__)
363 eof_ch = termios_rec.c_cc[VEOF];
365 /* If waiting (i.e. Get_Immediate (Char)), set MIN = 1 and wait for
366 a character forever. This doesn't seem to effect Ctrl-Z or
367 Ctrl-C processing.
368 If not waiting (i.e. Get_Immediate (Char, Available)),
369 don't wait for anything but timeout immediately. */
370 termios_rec.c_cc[VMIN] = waiting;
371 termios_rec.c_cc[VTIME] = 0;
372 #endif
373 tcsetattr (fd, TCSANOW, &termios_rec);
375 while (! good_one)
377 /* Read is used here instead of fread, because fread doesn't
378 work on Solaris5 and Sunos4 in this situation. Maybe because we
379 are mixing calls that use file descriptors and streams. */
380 nread = read (fd, &c, 1);
381 if (nread > 0)
383 /* On Unix terminals, Ctrl-D (EOT) is an End of File. */
384 if (c == eof_ch)
386 *avail = 0;
387 *end_of_file = 1;
388 good_one = 1;
391 /* Everything else is ok */
392 else if (c != eof_ch)
394 *avail = 1;
395 *end_of_file = 0;
396 good_one = 1;
400 else if (! waiting)
402 *avail = 0;
403 *end_of_file = 0;
404 good_one = 1;
406 else
407 good_one = 0;
410 tcsetattr (fd, TCSANOW, &otermios_rec);
411 *ch = c;
414 else
415 #elif defined (__MINGW32__)
416 int fd = fileno (stream);
417 int char_waiting;
418 int eot_ch = 4; /* Ctrl-D */
420 if (isatty (fd))
422 if (waiting)
424 *ch = getch ();
426 if (*ch == eot_ch)
427 *end_of_file = 1;
428 else
429 *end_of_file = 0;
431 *avail = 1;
433 else /* ! waiting */
435 char_waiting = kbhit();
437 if (char_waiting == 1)
439 *avail = 1;
440 *ch = getch ();
442 if (*ch == eot_ch)
443 *end_of_file = 1;
444 else
445 *end_of_file = 0;
447 else
449 *avail = 0;
450 *end_of_file = 0;
454 else
455 #elif defined (__vxworks)
456 /* Bit masks of file descriptors to read from. */
457 struct fd_set readFds;
458 /* Timeout before select returns if nothing can be read. */
459 struct timeval timeOut;
460 char c;
461 int fd = fileno (stream);
462 int nread;
463 int option;
464 int readable;
465 int status;
466 int width;
468 if (isatty (fd))
470 /* If we do not want to wait, we have to set up fd in RAW mode. This
471 should be done outside this function as setting fd in RAW mode under
472 vxWorks flushes the buffer of fd. If the RAW mode was set here, the
473 buffer would be empty and we would always return that no character
474 is available */
475 if (! waiting)
477 /* Initialization of timeOut for its use with select. */
478 timeOut.tv_sec = 0;
479 timeOut.tv_usec = 0;
481 /* Initialization of readFds for its use with select;
482 FD is the only file descriptor to be monitored */
483 FD_ZERO (&readFds);
484 FD_SET (fd, &readFds);
485 width = 2;
487 /* We do all this processing to emulate a non blocking read. */
488 readable = select (width, &readFds, NULL, NULL, &timeOut);
489 if (readable == ERROR)
490 *avail = -1, *end_of_file = -1;
491 /* No character available in input. */
492 else if (readable == 0)
493 *avail = 0, *end_of_file = 0;
494 else
496 nread = read (fd, &c, 1);
497 if (nread > 0)
498 *avail = 1, *end_of_file = 0;
499 /* End Of File. */
500 else if (nread == 0)
501 *avail = 0, *end_of_file = 1;
502 /* Error. */
503 else
504 *avail = -1, *end_of_file = -1;
508 /* We have to wait until we get a character */
509 else
511 *avail = -1;
512 *end_of_file = -1;
514 /* Save the current mode of FD. */
515 option = ioctl (fd, FIOGETOPTIONS, 0);
517 /* Set FD in RAW mode. */
518 status = ioctl (fd, FIOSETOPTIONS, OPT_RAW);
519 if (status != -1)
521 nread = read (fd, &c, 1);
522 if (nread > 0)
523 *avail = 1, *end_of_file = 0;
524 /* End of file. */
525 else if (nread == 0)
526 *avail = 0, *end_of_file = 1;
527 /* Else there is an ERROR. */
530 /* Revert FD to its previous mode. */
531 status = ioctl (fd, FIOSETOPTIONS, option);
534 *ch = c;
536 else
537 #endif
539 /* If we're not on a terminal, then we don't need any fancy processing.
540 Also this is the only thing that's left if we're not on one of the
541 supported systems; which means that for non supported systems,
542 get_immediate may wait for a carriage return on terminals. */
543 *ch = fgetc (stream);
544 if (feof (stream))
546 *end_of_file = 1;
547 *avail = 0;
549 else
551 *end_of_file = 0;
552 *avail = 1;
557 /* The following definitions are provided in NT to support Windows based
558 Ada programs. */
560 #ifdef WINNT
561 #include <windows.h>
563 /* Provide functions to echo the values passed to WinMain (windows bindings
564 will want to import these). We use the same names as the routines used
565 by AdaMagic for compatibility. */
567 char *rts_get_hInstance (void);
568 char *rts_get_hPrevInstance (void);
569 char *rts_get_lpCommandLine (void);
570 int rts_get_nShowCmd (void);
572 char *
573 rts_get_hInstance (void)
575 return (char *)GetModuleHandleA (0);
578 char *
579 rts_get_hPrevInstance (void)
581 return 0;
584 char *
585 rts_get_lpCommandLine (void)
587 return GetCommandLineA ();
591 rts_get_nShowCmd (void)
593 return 1;
596 #endif /* WINNT */
598 /* This value is returned as the time zone offset when a valid value
599 cannot be determined. It is simply a bizarre value that will never
600 occur. It is 3 days plus 73 seconds (offset is in seconds). */
602 long __gnat_invalid_tzoff = 259273;
604 /* Definition of __gnat_localtime_r used by a-calend.adb */
606 #if defined (__MINGW32__)
608 /* Reentrant localtime for Windows. */
610 extern void
611 __gnat_localtime_tzoff (const time_t *, const int *, long *);
613 static const unsigned long long w32_epoch_offset = 11644473600ULL;
614 void
615 __gnat_localtime_tzoff (const time_t *timer, const int *is_historic, long *off)
617 TIME_ZONE_INFORMATION tzi;
619 DWORD tzi_status;
621 tzi_status = GetTimeZoneInformation (&tzi);
623 /* Cases where we simply want to extract the offset of the current time
624 zone, regardless of the date. A value of "0" for flag "is_historic"
625 signifies that the date is NOT historic, see the
626 body of Ada.Calendar.UTC_Time_Offset. */
628 if (*is_historic == 0) {
629 *off = tzi.Bias;
631 /* The system is operating in the range covered by the StandardDate
632 member. */
633 if (tzi_status == TIME_ZONE_ID_STANDARD) {
634 *off = *off + tzi.StandardBias;
637 /* The system is operating in the range covered by the DaylightDate
638 member. */
639 else if (tzi_status == TIME_ZONE_ID_DAYLIGHT) {
640 *off = *off + tzi.DaylightBias;
643 *off = *off * -60;
646 /* Time zone offset calculations for a historic or future date */
648 else {
649 union
651 FILETIME ft_time;
652 unsigned long long ull_time;
653 } utc_time, local_time;
655 SYSTEMTIME utc_sys_time, local_sys_time;
656 BOOL status;
658 /* First convert unix time_t structure to windows FILETIME format. */
659 utc_time.ull_time = ((unsigned long long) *timer + w32_epoch_offset)
660 * 10000000ULL;
662 /* If GetTimeZoneInformation does not return a value between 0 and 2 then
663 it means that we were not able to retrieve timezone information. Note
664 that we cannot use here FileTimeToLocalFileTime as Windows will use in
665 always in this case the current timezone setting. As suggested on MSDN
666 we use the following three system calls to get the right information.
667 Note also that starting with Windows Vista new functions are provided
668 to get timezone settings that depend on the year. We cannot use them as
669 we still support Windows XP and Windows 2003. */
671 status = (tzi_status >= 0 && tzi_status <= 2)
672 && FileTimeToSystemTime (&utc_time.ft_time, &utc_sys_time)
673 && SystemTimeToTzSpecificLocalTime (&tzi, &utc_sys_time, &local_sys_time)
674 && SystemTimeToFileTime (&local_sys_time, &local_time.ft_time);
676 /* An error has occurred, return invalid_tzoff */
678 if (!status) {
679 *off = __gnat_invalid_tzoff;
681 else {
682 if (local_time.ull_time > utc_time.ull_time) {
683 *off = (long) ((local_time.ull_time - utc_time.ull_time)
684 / 10000000ULL);
686 else {
687 *off = - (long) ((utc_time.ull_time - local_time.ull_time)
688 / 10000000ULL);
694 #elif defined (__Lynx__)
696 /* On Lynx, all time values are treated in GMT */
698 /* As of LynxOS 3.1.0a patch level 040, LynuxWorks changes the
699 prototype to the C library function localtime_r from the POSIX.4
700 Draft 9 to the POSIX 1.c version. Before this change the following
701 spec is required. Only use when ___THREADS_POSIX4ad4__ is defined,
702 the Lynx convention when building against the legacy API. */
704 extern void
705 __gnat_localtime_tzoff (const time_t *, const int *, long *);
707 void
708 __gnat_localtime_tzoff (const time_t *timer, const int *is_historic, long *off)
710 *off = 0;
713 #else
715 /* Other targets except Lynx and Windows provide a standard localtime_r */
717 #define Lock_Task system__soft_links__lock_task
718 extern void (*Lock_Task) (void);
720 #define Unlock_Task system__soft_links__unlock_task
721 extern void (*Unlock_Task) (void);
723 extern void
724 __gnat_localtime_tzoff (const time_t *, const int *, long *);
726 void
727 __gnat_localtime_tzoff (const time_t *timer ATTRIBUTE_UNUSED,
728 const int *is_historic ATTRIBUTE_UNUSED,
729 long *off ATTRIBUTE_UNUSED)
731 struct tm tp ATTRIBUTE_UNUSED;
733 /* AIX, HPUX, Sun Solaris */
734 #if defined (_AIX) || defined (__hpux__) || defined (__sun__)
736 (*Lock_Task) ();
738 localtime_r (timer, &tp);
739 *off = (long) -timezone;
741 (*Unlock_Task) ();
743 /* Correct the offset if Daylight Saving Time is in effect */
745 if (tp.tm_isdst > 0)
746 *off = *off + 3600;
749 /* VxWorks */
750 #elif defined (__vxworks)
751 #include <stdlib.h>
753 (*Lock_Task) ();
755 localtime_r (timer, &tp);
757 /* Try to read the environment variable TIMEZONE. The variable may not have
758 been initialize, in that case return an offset of zero (0) for UTC. */
760 char *tz_str = getenv ("TIMEZONE");
762 if ((tz_str == NULL) || (*tz_str == '\0'))
763 *off = 0;
764 else
766 char *tz_start, *tz_end;
768 /* The format of the data contained in TIMEZONE is N::U:S:E where N is the
769 name of the time zone, U are the minutes difference from UTC, S is the
770 start of DST in mmddhh and E is the end of DST in mmddhh. Extracting
771 the value of U involves setting two pointers, one at the beginning and
772 one at the end of the value. The end pointer is then set to null in
773 order to delimit a string slice for atol to process. */
775 tz_start = index (tz_str, ':') + 2;
776 tz_end = index (tz_start, ':');
777 *tz_end = '\0';
779 /* The Ada layer expects an offset in seconds. Note that we must reverse
780 the sign of the result since west is positive and east is negative on
781 VxWorks targets. */
783 *off = -atol (tz_start) * 60;
785 /* Correct the offset if Daylight Saving Time is in effect */
787 if (tp.tm_isdst > 0)
788 *off = *off + 3600;
791 (*Unlock_Task) ();
794 /* Darwin, Free BSD, Linux, where component tm_gmtoff is present in
795 struct tm */
797 #elif defined (__APPLE__) || defined (__FreeBSD__) || defined (__linux__) \
798 || defined (__GLIBC__) || defined (__DragonFly__) || defined (__OpenBSD__)
800 localtime_r (timer, &tp);
801 *off = tp.tm_gmtoff;
804 /* Default: treat all time values in GMT */
806 #else
807 *off = 0;
809 #endif /* defined(_AIX) ... */
812 #endif
814 #ifdef __vxworks
816 #include <taskLib.h>
818 /* __gnat_get_task_options is used by s-taprop.adb only for VxWorks. This
819 function returns the options to be set when creating a new task. It fetches
820 the options assigned to the current task (parent), so offering some user
821 level control over the options for a task hierarchy. It forces VX_FP_TASK
822 because it is almost always required. On processors with the SPE
823 category, VX_SPE_TASK should be used instead to enable the SPE. */
824 extern int __gnat_get_task_options (void);
827 __gnat_get_task_options (void)
829 int options;
831 /* Get the options for the task creator */
832 taskOptionsGet (taskIdSelf (), &options);
834 /* Force VX_FP_TASK or VX_SPE_TASK as needed */
835 #if defined (__SPE__)
836 options |= VX_SPE_TASK;
837 #else
838 options |= VX_FP_TASK;
839 #endif
841 /* Mask those bits that are not under user control */
842 #ifdef VX_USR_TASK_OPTIONS
843 /* O810-007, TSR 00043679:
844 Workaround a bug in Vx-7 where VX_DEALLOC_TCB == VX_PRIVATE_UMASK and:
845 - VX_DEALLOC_TCB is an internal option not to be used by users
846 - VX_PRIVATE_UMASK as a user-definable option
847 This leads to VX_USR_TASK_OPTIONS allowing 0x8000 as VX_PRIVATE_UMASK but
848 taskCreate refusing this option (VX_DEALLOC_TCB is not allowed)
850 Note that the same error occurs in both RTP and Kernel mode, but
851 VX_DEALLOC_TCB is not defined in the RTP headers, so we need to
852 explicitely check if VX_PRIVATE_UMASK has value 0x8000
854 # if defined (VX_PRIVATE_UMASK) && (0x8000 == VX_PRIVATE_UMASK)
855 options &= ~VX_PRIVATE_UMASK;
856 # endif
857 options &= VX_USR_TASK_OPTIONS;
858 #endif
859 return options;
862 #endif
865 __gnat_is_file_not_found_error (int errno_val) {
866 switch (errno_val) {
867 case ENOENT:
868 #ifdef __vxworks
869 /* In the case of VxWorks, we also have to take into account various
870 * filesystem-specific variants of this error.
872 #if ! defined (VTHREADS) && (_WRS_VXWORKS_MAJOR < 7)
873 case S_dosFsLib_FILE_NOT_FOUND:
874 #endif
875 #if ! defined (__RTP__) && (! defined (VTHREADS) || defined (__VXWORKSMILS__))
876 case S_nfsLib_NFSERR_NOENT:
877 #endif
878 #if defined (__RTP__)
879 /* An RTP can return an NFS file not found, and the NFS bits must
880 first be masked on to check the errno. */
881 case M_nfsStat | ENOENT:
882 #endif
883 #endif
884 return 1;
886 default:
887 return 0;
891 #ifdef __ANDROID__
893 /* Provide extern symbols for sig* as needed by the tasking run-time, instead
894 of static inline functions. */
896 #include <signal.h>
899 _sigismember (sigset_t *set, int signum)
901 return sigismember (set, signum);
905 _sigaddset (sigset_t *set, int signum)
907 return sigaddset (set, signum);
911 _sigdelset (sigset_t *set, int signum)
913 return sigdelset (set, signum);
917 _sigemptyset (sigset_t *set)
919 return sigemptyset (set);
923 _sigfillset (sigset_t *set)
925 return sigfillset (set);
928 #include <unistd.h>
930 _getpagesize (void)
932 return getpagesize ();
934 #endif