| 1 |
/**************************************************************************** |
| 2 |
* * |
| 3 |
* GNAT COMPILER COMPONENTS * |
| 4 |
* * |
| 5 |
* C I O * |
| 6 |
* * |
| 7 |
* C Implementation File * |
| 8 |
* * |
| 9 |
* Copyright (C) 1992-2025, 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 |
****************************************************************************/ |
| 31 |
|
| 32 |
#ifdef IN_RTS |
| 33 |
#include "runtime.h" |
| 34 |
#include <sys/stat.h> |
| 35 |
#else |
| 36 |
#include "config.h" |
| 37 |
#include "system.h" |
| 38 |
#endif |
| 39 |
|
| 40 |
#include "adaint.h" |
| 41 |
|
| 42 |
/* We need L_tmpnam definition */ |
| 43 |
#include <stdio.h> |
| 44 |
|
| 45 |
#ifdef __cplusplus |
| 46 |
extern "C" { |
| 47 |
#endif |
| 48 |
|
| 49 |
/* Don't use macros on GNU/Linux since they cause incompatible changes between |
| 50 |
glibc 2.0 and 2.1 */ |
| 51 |
#ifdef __linux__ |
| 52 |
#undef putchar |
| 53 |
#undef getchar |
| 54 |
#undef fputc |
| 55 |
#undef stderr |
| 56 |
#undef stdout |
| 57 |
#endif |
| 58 |
|
| 59 |
/* Don't use macros versions of this functions on VxWorks since they cause |
| 60 |
imcompatible changes in some VxWorks versions */ |
| 61 |
#ifdef __vxworks |
| 62 |
#undef getchar |
| 63 |
#undef putchar |
| 64 |
#undef feof |
| 65 |
#undef ferror |
| 66 |
#undef fileno |
| 67 |
#endif |
| 68 |
|
| 69 |
#ifdef RTX |
| 70 |
#define WIN32_LEAN_AND_MEAN |
| 71 |
#include <windows.h> |
| 72 |
#include <Rtapi.h> |
| 73 |
#endif |
| 74 |
|
| 75 |
int |
| 76 |
get_char (void) |
| 77 |
{ |
| 78 |
#ifdef VMS |
| 79 |
return decc$getchar(); |
| 80 |
#else |
| 81 |
return getchar (); |
| 82 |
#endif |
| 83 |
} |
| 84 |
|
| 85 |
int |
| 86 |
get_int (void) |
| 87 |
{ |
| 88 |
int x; |
| 89 |
|
| 90 |
scanf (" %d", &x); |
| 91 |
return x; |
| 92 |
} |
| 93 |
|
| 94 |
void |
| 95 |
put_int (int x) |
| 96 |
{ |
| 97 |
#ifdef RTX |
| 98 |
RtPrintf ("%d", x); |
| 99 |
#else |
| 100 |
/* Use fprintf rather than printf, since the latter is unbuffered |
| 101 |
on vxworks */ |
| 102 |
fprintf (stdout, "%d", x); |
| 103 |
#endif |
| 104 |
} |
| 105 |
|
| 106 |
void |
| 107 |
put_int_stderr (int x) |
| 108 |
{ |
| 109 |
#ifdef RTX |
| 110 |
RtPrintf ("%d", x); |
| 111 |
#else |
| 112 |
fprintf (stderr, "%d", x); |
| 113 |
#endif |
| 114 |
} |
| 115 |
|
| 116 |
void |
| 117 |
put_char (int c) |
| 118 |
{ |
| 119 |
#ifdef RTX |
| 120 |
RtPrintf ("%c", c); |
| 121 |
#else |
| 122 |
putchar (c); |
| 123 |
#endif |
| 124 |
} |
| 125 |
|
| 126 |
void |
| 127 |
put_char_stderr (int c) |
| 128 |
{ |
| 129 |
#ifdef RTX |
| 130 |
RtPrintf ("%c", c); |
| 131 |
#else |
| 132 |
fputc (c, stderr); |
| 133 |
#endif |
| 134 |
} |
| 135 |
|
| 136 |
#ifdef __vxworks |
| 137 |
|
| 138 |
char * |
| 139 |
mktemp (char *template) |
| 140 |
{ |
| 141 |
#if !(defined (__RTP__) || defined (VTHREADS)) |
| 142 |
static char buf[L_tmpnam]; /* Internal buffer for name */ |
| 143 |
|
| 144 |
/* If parameter is NULL use internal buffer */ |
| 145 |
if (template == NULL) |
| 146 |
template = buf; |
| 147 |
|
| 148 |
__gnat_tmp_name (template); |
| 149 |
return template; |
| 150 |
#else |
| 151 |
return tmpnam (NULL); |
| 152 |
#endif |
| 153 |
} |
| 154 |
#endif |
| 155 |
|
| 156 |
#ifdef __cplusplus |
| 157 |
} |
| 158 |
#endif |