Print this page
remove support for non-ANSI compilation
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/iso/stdio_iso.h
+++ new/usr/src/head/iso/stdio_iso.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 + *
23 25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 26 * Use is subject to license terms.
25 27 */
26 28
27 29 /* Copyright (c) 1988 AT&T */
28 30 /* All Rights Reserved */
29 31
30 32 /*
31 33 * An application should not include this header directly. Instead it
32 34 * should be included only through the inclusion of other Sun headers.
33 35 *
34 36 * The contents of this header is limited to identifiers specified in the
35 37 * C Standard. Any new identifiers specified in future amendments to the
36 38 * C Standard must be placed in this header. If these new identifiers
37 39 * are required to also be in the C++ Standard "std" namespace, then for
38 40 * anything other than macro definitions, corresponding "using" directives
39 41 * must also be added to <stdio.h>.
40 42 */
41 43
42 44 /*
43 45 * User-visible pieces of the ANSI C standard I/O package.
44 46 */
45 47
46 48 #ifndef _ISO_STDIO_ISO_H
47 49 #define _ISO_STDIO_ISO_H
48 50
49 51 #include <sys/feature_tests.h>
50 52 #include <sys/va_list.h>
51 53 #include <stdio_tag.h>
52 54 #include <stdio_impl.h>
53 55
54 56 /*
55 57 * If feature test macros are set that enable interfaces that use types
56 58 * defined in <sys/types.h>, get those types by doing the include.
57 59 *
58 60 * Note that in asking for the interfaces associated with this feature test
59 61 * macro one also asks for definitions of the POSIX types.
60 62 */
61 63
62 64 #ifdef __cplusplus
63 65 extern "C" {
64 66 #endif
65 67
66 68 #if !defined(_LP64) && (_FILE_OFFSET_BITS == 64 || defined(_LARGEFILE64_SOURCE))
67 69 /*
68 70 * The following typedefs are adopted from ones in <sys/types.h> (with leading
69 71 * underscores added to avoid polluting the ANSI C name space). See the
70 72 * commentary there for further explanation.
71 73 */
72 74 #if defined(_LONGLONG_TYPE)
73 75 typedef long long __longlong_t;
74 76 #else
75 77 /* used to reserve space and generate alignment */
76 78 typedef union {
77 79 double _d;
78 80 int _l[2];
79 81 } __longlong_t;
80 82 #endif
81 83 #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 || defined(_LARGEFILE64_SOURCE) */
82 84
83 85 #if __cplusplus >= 199711L
84 86 namespace std {
85 87 #endif
86 88
87 89 #if !defined(_FILEDEFED) || __cplusplus >= 199711L
88 90 #define _FILEDEFED
89 91 typedef __FILE FILE;
90 92 #endif
91 93
92 94 #if !defined(_SIZE_T) || __cplusplus >= 199711L
93 95 #define _SIZE_T
94 96 #if defined(_LP64) || defined(_I32LPx)
95 97 typedef unsigned long size_t; /* size of something in bytes */
96 98 #else
97 99 typedef unsigned int size_t; /* (historical version) */
98 100 #endif
99 101 #endif /* !_SIZE_T */
100 102
101 103 #if defined(_LP64) || _FILE_OFFSET_BITS == 32
102 104 typedef long fpos_t;
103 105 #else
104 106 typedef __longlong_t fpos_t;
105 107 #endif
106 108
107 109 #if __cplusplus >= 199711L
108 110 }
109 111 #endif /* end of namespace std */
110 112
111 113 #ifndef NULL
112 114 #if defined(_LP64)
113 115 #define NULL 0L
114 116 #else
115 117 #define NULL 0
116 118 #endif
117 119 #endif
118 120
119 121 #define BUFSIZ 1024
120 122
121 123 /*
122 124 * The value of _NFILE is defined in the Processor Specific ABI. The value
123 125 * is chosen for historical reasons rather than for truly processor related
124 126 * attribute. Note that the SPARC Processor Specific ABI uses the common
125 127 * UNIX historical value of 20 so it is allowed to fall through.
126 128 */
127 129 #if defined(__i386)
128 130 #define _NFILE 60 /* initial number of streams: Intel x86 ABI */
129 131 #else
130 132 #define _NFILE 20 /* initial number of streams: SPARC ABI and default */
131 133 #endif
132 134
133 135 #define _SBFSIZ 8 /* compatibility with shared libs */
134 136
135 137 #define _IOFBF 0000 /* full buffered */
136 138 #define _IOLBF 0100 /* line buffered */
137 139 #define _IONBF 0004 /* not buffered */
138 140 #define _IOEOF 0020 /* EOF reached on read */
139 141 #define _IOERR 0040 /* I/O error from system */
140 142
141 143 #define _IOREAD 0001 /* currently reading */
142 144 #define _IOWRT 0002 /* currently writing */
143 145 #define _IORW 0200 /* opened for reading and writing */
144 146 #define _IOMYBUF 0010 /* stdio malloc()'d buffer */
145 147
146 148 #ifndef EOF
147 149 #define EOF (-1)
148 150 #endif
149 151
↓ open down ↓ |
117 lines elided |
↑ open up ↑ |
150 152 #define FOPEN_MAX _NFILE
151 153 #define FILENAME_MAX 1024 /* max # of characters in a path name */
152 154
153 155 #define SEEK_SET 0
154 156 #define SEEK_CUR 1
155 157 #define SEEK_END 2
156 158 #define TMP_MAX 17576 /* 26 * 26 * 26 */
157 159
158 160 #define L_tmpnam 25 /* (sizeof(P_tmpdir) + 15) */
159 161
160 -#if defined(__STDC__)
161 162 extern __FILE __iob[_NFILE];
162 163 #define stdin (&__iob[0])
163 164 #define stdout (&__iob[1])
164 165 #define stderr (&__iob[2])
165 -#else
166 -extern __FILE _iob[_NFILE];
167 -#define stdin (&_iob[0])
168 -#define stdout (&_iob[1])
169 -#define stderr (&_iob[2])
170 -#endif /* __STDC__ */
171 166
172 167 #if __cplusplus >= 199711L
173 168 namespace std {
174 169 #endif
175 170
176 171 #if !defined(_LP64) && !defined(_LONGLONG_TYPE)
177 172
178 173 #ifdef __PRAGMA_REDEFINE_EXTNAME
179 174 #pragma redefine_extname fprintf _fprintf_c89
180 175 #pragma redefine_extname printf _printf_c89
181 176 #pragma redefine_extname sprintf _sprintf_c89
182 177 #pragma redefine_extname vfprintf _vfprintf_c89
183 178 #pragma redefine_extname vprintf _vprintf_c89
184 179 #pragma redefine_extname vsprintf _vsprintf_c89
185 180 #pragma redefine_extname fscanf _fscanf_c89
186 181 #pragma redefine_extname scanf _scanf_c89
187 182 #pragma redefine_extname sscanf _sscanf_c89
188 183 #else
189 184 #define fprintf _fprintf_c89
190 185 #define printf _printf_c89
191 186 #define sprintf _sprintf_c89
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
192 187 #define vfprintf _vfprintf_c89
193 188 #define vprintf _vprintf_c89
194 189 #define vsprintf _vsprintf_c89
195 190 #define fscanf _fscanf_c89
196 191 #define scanf _scanf_c89
197 192 #define sscanf _sscanf_c89
198 193 #endif
199 194
200 195 #endif /* !defined(_LP64) && !defined(_LONGLONG_TYPE) */
201 196
202 -#if defined(__STDC__)
203 -
204 197 extern int remove(const char *);
205 198 extern int rename(const char *, const char *);
206 199 extern FILE *tmpfile(void);
207 200 extern char *tmpnam(char *);
208 201 extern int fclose(FILE *);
209 202 extern int fflush(FILE *);
210 203 extern FILE *fopen(const char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
211 204 extern FILE *freopen(const char *_RESTRICT_KYWD,
212 205 const char *_RESTRICT_KYWD, FILE *_RESTRICT_KYWD);
213 206 extern void setbuf(FILE *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
214 207 extern int setvbuf(FILE *_RESTRICT_KYWD, char *_RESTRICT_KYWD, int,
215 208 size_t);
216 209 /* PRINTFLIKE2 */
217 210 extern int fprintf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...);
218 211 /* SCANFLIKE2 */
219 212 extern int fscanf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...);
220 213 /* PRINTFLIKE1 */
221 214 extern int printf(const char *_RESTRICT_KYWD, ...);
222 215 /* SCANFLIKE1 */
223 216 extern int scanf(const char *_RESTRICT_KYWD, ...);
224 217 /* PRINTFLIKE2 */
225 218 extern int sprintf(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, ...);
226 219 /* SCANFLIKE2 */
227 220 extern int sscanf(const char *_RESTRICT_KYWD,
228 221 const char *_RESTRICT_KYWD, ...);
229 222 extern int vfprintf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
230 223 __va_list);
231 224 extern int vprintf(const char *_RESTRICT_KYWD, __va_list);
232 225 extern int vsprintf(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
233 226 __va_list);
234 227 extern int fgetc(FILE *);
235 228 extern char *fgets(char *_RESTRICT_KYWD, int, FILE *_RESTRICT_KYWD);
236 229 extern int fputc(int, FILE *);
237 230 extern int fputs(const char *_RESTRICT_KYWD, FILE *_RESTRICT_KYWD);
238 231 #if (__cplusplus >= 199711L && (defined(_LP64) || defined(_REENTRANT))) || \
239 232 __cplusplus < 199711L
240 233 extern int getc(FILE *);
241 234 extern int putc(int, FILE *);
242 235 #endif
243 236 #if (__cplusplus >= 199711L && defined(_REENTRANT)) || \
244 237 __cplusplus < 199711L
245 238 extern int getchar(void);
246 239 extern int putchar(int);
247 240 #endif
248 241 extern char *gets(char *);
249 242 extern int puts(const char *);
250 243 extern int ungetc(int, FILE *);
251 244 extern size_t fread(void *_RESTRICT_KYWD, size_t, size_t,
252 245 FILE *_RESTRICT_KYWD);
253 246 extern size_t fwrite(const void *_RESTRICT_KYWD, size_t, size_t,
254 247 FILE *_RESTRICT_KYWD);
255 248 #if !defined(__lint) || defined(_LP64) || _FILE_OFFSET_BITS == 32
256 249 extern int fgetpos(FILE *_RESTRICT_KYWD, fpos_t *_RESTRICT_KYWD);
257 250 extern int fsetpos(FILE *, const fpos_t *);
258 251 #endif
259 252 extern int fseek(FILE *, long, int);
260 253 extern long ftell(FILE *);
261 254 extern void rewind(FILE *);
262 255 #if (__cplusplus >= 199711L && (defined(_LP64) || defined(_REENTRANT))) || \
263 256 __cplusplus < 199711L
264 257 extern void clearerr(FILE *);
↓ open down ↓ |
51 lines elided |
↑ open up ↑ |
265 258 extern int feof(FILE *);
266 259 extern int ferror(FILE *);
267 260 #endif
268 261 extern void perror(const char *);
269 262
270 263 #ifndef _LP64
271 264 extern int __filbuf(FILE *);
272 265 extern int __flsbuf(int, FILE *);
273 266 #endif /* _LP64 */
274 267
275 -#else /* !defined __STDC__ */
276 -
277 -extern int remove();
278 -extern int rename();
279 -extern FILE *tmpfile();
280 -extern char *tmpnam();
281 -extern int fclose();
282 -extern int fflush();
283 -extern FILE *fopen();
284 -extern FILE *freopen();
285 -extern void setbuf();
286 -extern int setvbuf();
287 -extern int fprintf();
288 -extern int fscanf();
289 -extern int printf();
290 -extern int scanf();
291 -extern int sprintf();
292 -extern int sscanf();
293 -extern int vfprintf();
294 -extern int vprintf();
295 -extern int vsprintf();
296 -extern int fgetc();
297 -extern char *fgets();
298 -extern int fputc();
299 -extern int fputs();
300 -extern int getc();
301 -extern int getchar();
302 -extern char *gets();
303 -extern int putc();
304 -extern int putchar();
305 -extern int puts();
306 -extern int ungetc();
307 -extern size_t fread();
308 -extern size_t fwrite();
309 -extern int fgetpos();
310 -extern int fseek();
311 -extern int fsetpos();
312 -extern long ftell();
313 -extern void rewind();
314 -extern void clearerr();
315 -extern int feof();
316 -extern int ferror();
317 -extern void perror();
318 -
319 -#ifndef _LP64
320 -extern int _filbuf();
321 -extern int _flsbuf();
322 -#endif /* _LP64 */
323 -
324 -#endif /* __STDC__ */
325 -
326 268 #if __cplusplus >= 199711L
327 269 }
328 270 #endif /* end of namespace std */
329 271
330 272 #if !defined(__lint)
331 273
332 274 #if !defined(_REENTRANT) && !defined(_LP64)
333 275
334 -#ifdef __STDC__
335 276 #if __cplusplus >= 199711L
336 277 namespace std {
337 278 inline int getc(FILE *_p) {
338 279 return (--_p->_cnt < 0 ? __filbuf(_p) : (int)*_p->_ptr++); }
339 280 inline int putc(int _x, FILE *_p) {
340 281 return (--_p->_cnt < 0 ? __flsbuf(_x, _p)
341 282 : (int)(*_p->_ptr++ = (unsigned char) _x)); }
342 283 }
343 284 #else /* __cplusplus >= 199711L */
344 285 #define getc(p) (--(p)->_cnt < 0 ? __filbuf(p) : (int)*(p)->_ptr++)
345 286 #define putc(x, p) (--(p)->_cnt < 0 ? __flsbuf((x), (p)) \
346 287 : (int)(*(p)->_ptr++ = (unsigned char) (x)))
347 288 #endif /* __cplusplus >= 199711L */
348 -#else /* __STDC__ */
349 -#define getc(p) (--(p)->_cnt < 0 ? _filbuf(p) : (int)*(p)->_ptr++)
350 -#define putc(x, p) (--(p)->_cnt < 0 ? _flsbuf((x), (p)) : \
351 - (int)(*(p)->_ptr++ = (unsigned char) (x)))
352 -#endif /* __STDC__ */
353 289
354 290 #endif /* !defined(_REENTRANT) && !defined(_LP64) */
355 291
356 292 #ifndef _REENTRANT
357 293
358 294 #if __cplusplus >= 199711L
359 295 namespace std {
360 296 inline int getchar() { return getc(stdin); }
361 297 inline int putchar(int _x) { return putc(_x, stdout); }
362 298 }
363 299 #else
364 300 #define getchar() getc(stdin)
365 301 #define putchar(x) putc((x), stdout)
366 302 #endif /* __cplusplus >= 199711L */
367 303
368 304 #ifndef _LP64
369 305 #if __cplusplus >= 199711L
370 306 namespace std {
371 307 inline void clearerr(FILE *_p) { _p->_flag &= ~(_IOERR | _IOEOF); }
372 308 inline int feof(FILE *_p) { return _p->_flag & _IOEOF; }
373 309 inline int ferror(FILE *_p) { return _p->_flag & _IOERR; }
374 310 }
375 311 #else /* __cplusplus >= 199711L */
376 312 #define clearerr(p) ((void)((p)->_flag &= ~(_IOERR | _IOEOF)))
377 313 #define feof(p) ((p)->_flag & _IOEOF)
378 314 #define ferror(p) ((p)->_flag & _IOERR)
379 315 #endif /* __cplusplus >= 199711L */
380 316 #endif /* _LP64 */
381 317
382 318 #endif /* _REENTRANT */
383 319
384 320 #endif /* !defined(__lint) */
385 321
386 322 #ifdef __cplusplus
387 323 }
388 324 #endif
389 325
390 326 #endif /* _ISO_STDIO_ISO_H */
↓ open down ↓ |
28 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX