fixing pr42337
[official-gcc.git] / gcc / ada / cio.c
blob277af096547d33c752a94183b1d1aea9a12d8818
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * C I O *
6 * *
7 * C Implementation File *
8 * *
9 * Copyright (C) 1992-2009, 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 #ifdef IN_RTS
33 #include "tconfig.h"
34 #include "tsystem.h"
35 #include <sys/stat.h>
36 #else
37 #include "config.h"
38 #include "system.h"
39 #endif
41 #include "adaint.h"
43 /* Don't use macros on GNU/Linux since they cause incompatible changes between
44 glibc 2.0 and 2.1 */
45 #ifdef linux
46 #undef putchar
47 #undef getchar
48 #undef fputc
49 #undef stderr
50 #undef stdout
51 #endif
53 #ifdef VTHREADS
54 #undef putchar
55 #undef getchar
56 #endif
58 #ifdef RTX
59 #include <windows.h>
60 #include <Rtapi.h>
61 #endif
63 int
64 get_char (void)
66 #ifdef VMS
67 return decc$getchar();
68 #else
69 return getchar ();
70 #endif
73 int
74 get_int (void)
76 int x;
78 scanf (" %d", &x);
79 return x;
82 void
83 put_int (int x)
85 #ifdef RTX
86 RtPrintf ("%d", x);
87 #else
88 /* Use fprintf rather than printf, since the latter is unbuffered
89 on vxworks */
90 fprintf (stdout, "%d", x);
91 #endif
94 void
95 put_int_stderr (int x)
97 #ifdef RTX
98 RtPrintf ("%d", x);
99 #else
100 fprintf (stderr, "%d", x);
101 #endif
104 void
105 put_char (int c)
107 #ifdef RTX
108 RtPrintf ("%c", c);
109 #else
110 putchar (c);
111 #endif
114 void
115 put_char_stderr (int c)
117 #ifdef RTX
118 RtPrintf ("%c", c);
119 #else
120 fputc (c, stderr);
121 #endif
124 #ifdef __vxworks
126 char *
127 mktemp (char *template)
129 return tmpnam (NULL);
131 #endif