comparison gcc/ada/cio.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * C I O *
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 ****************************************************************************/
31
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
40
41 #include "adaint.h"
42
43 /* We need L_tmpnam definition */
44 #include <stdio.h>
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50 /* Don't use macros on GNU/Linux since they cause incompatible changes between
51 glibc 2.0 and 2.1 */
52 #ifdef __linux__
53 #undef putchar
54 #undef getchar
55 #undef fputc
56 #undef stderr
57 #undef stdout
58 #endif
59
60 /* Don't use macros versions of this functions on VxWorks since they cause
61 imcompatible changes in some VxWorks versions */
62 #ifdef __vxworks
63 #undef getchar
64 #undef putchar
65 #undef feof
66 #undef ferror
67 #undef fileno
68 #endif
69
70 #ifdef RTX
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