Print this page
remove support for non-ANSI compilation
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/stdio.h
+++ new/usr/src/head/stdio.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 (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
23 24 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24 25 */
25 26
26 27 /* Copyright (c) 1988 AT&T */
27 28 /* All Rights Reserved */
28 29
29 30 /*
30 31 * User-visible pieces of the ANSI C standard I/O package.
31 32 */
32 33
33 34 #ifndef _STDIO_H
34 35 #define _STDIO_H
35 36
36 37 #include <sys/feature_tests.h>
37 38
38 39 #ifdef __cplusplus
39 40 extern "C" {
40 41 #endif
41 42
42 43 /*
43 44 * Do all of our 'redefine_extname' processing before
44 45 * declarations of the associated functions are seen.
45 46 * This is necessary to keep gcc happy.
46 47 */
47 48 #if defined(__PRAGMA_REDEFINE_EXTNAME)
48 49
49 50 /* large file compilation environment setup */
50 51 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
51 52 #pragma redefine_extname fopen fopen64
52 53 #pragma redefine_extname freopen freopen64
53 54 #pragma redefine_extname tmpfile tmpfile64
54 55 #pragma redefine_extname fgetpos fgetpos64
55 56 #pragma redefine_extname fsetpos fsetpos64
56 57 #if defined(_LARGEFILE_SOURCE)
57 58 #pragma redefine_extname fseeko fseeko64
58 59 #pragma redefine_extname ftello ftello64
59 60 #endif /* _LARGEFILE_SOURCE */
60 61 #endif /* !defined(_LP64) && _FILE_OFFSET_BITS == 64 */
61 62
62 63 /* In the LP64 compilation environment, all APIs are already large file */
63 64 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
64 65 #pragma redefine_extname fopen64 fopen
65 66 #pragma redefine_extname freopen64 freopen
66 67 #pragma redefine_extname tmpfile64 tmpfile
67 68 #pragma redefine_extname fgetpos64 fgetpos
68 69 #pragma redefine_extname fsetpos64 fsetpos
69 70 #if defined(_LARGEFILE_SOURCE)
70 71 #pragma redefine_extname fseeko64 fseeko
71 72 #pragma redefine_extname ftello64 ftello
72 73 #endif /* _LARGEFILE_SOURCE */
73 74 #endif /* defined(_LP64) && defined(_LARGEFILE64_SOURCE) */
74 75
75 76 #endif /* __PRAGMA_REDEFINE_EXTNAME */
76 77
77 78 #ifdef __cplusplus
78 79 }
79 80 #endif
80 81
81 82 #include <iso/stdio_iso.h>
82 83
83 84 /*
84 85 * If feature test macros are set that enable interfaces that use types
85 86 * defined in <sys/types.h>, get those types by doing the include.
86 87 *
87 88 * Note that in asking for the interfaces associated with this feature test
88 89 * macro one also asks for definitions of the POSIX types.
89 90 */
90 91
91 92 /*
92 93 * Allow global visibility for symbols defined in
93 94 * C++ "std" namespace in <iso/stdio_iso.h>.
94 95 */
95 96 #if __cplusplus >= 199711L
96 97 using std::FILE;
97 98 using std::size_t;
98 99 using std::fpos_t;
99 100 using std::remove;
100 101 using std::rename;
101 102 using std::tmpfile;
102 103 using std::tmpnam;
103 104 using std::fclose;
104 105 using std::fflush;
105 106 using std::fopen;
106 107 using std::freopen;
107 108 using std::setbuf;
108 109 using std::setvbuf;
109 110 using std::fprintf;
110 111 using std::fscanf;
111 112 using std::printf;
112 113 using std::scanf;
113 114 using std::sprintf;
114 115 using std::sscanf;
115 116 using std::vfprintf;
116 117 using std::vprintf;
117 118 using std::vsprintf;
118 119 using std::fgetc;
119 120 using std::fgets;
120 121 using std::fputc;
121 122 using std::fputs;
122 123 using std::getc;
123 124 using std::getchar;
124 125 using std::gets;
125 126 using std::putc;
126 127 using std::putchar;
127 128 using std::puts;
128 129 using std::ungetc;
129 130 using std::fread;
130 131 using std::fwrite;
131 132 using std::fgetpos;
132 133 using std::fseek;
133 134 using std::fsetpos;
134 135 using std::ftell;
135 136 using std::rewind;
136 137 using std::clearerr;
137 138 using std::feof;
138 139 using std::ferror;
139 140 using std::perror;
140 141 #ifndef _LP64
141 142 using std::__filbuf;
142 143 using std::__flsbuf;
143 144 #endif /* _LP64 */
144 145 #endif /* __cplusplus >= 199711L */
145 146
146 147 /*
147 148 * This header needs to be included here because it relies on the global
148 149 * visibility of FILE and size_t in the C++ environment.
149 150 */
150 151 #include <iso/stdio_c99.h>
151 152
152 153 #ifdef __cplusplus
153 154 extern "C" {
154 155 #endif
155 156
156 157 #if defined(_LARGEFILE_SOURCE) || defined(_XPG5)
157 158 #ifndef _OFF_T
158 159 #define _OFF_T
159 160 #if defined(_LP64) || _FILE_OFFSET_BITS == 32
160 161 typedef long off_t;
161 162 #else
162 163 typedef __longlong_t off_t;
163 164 #endif
164 165 #ifdef _LARGEFILE64_SOURCE
165 166 #ifdef _LP64
166 167 typedef off_t off64_t;
167 168 #else
168 169 typedef __longlong_t off64_t;
169 170 #endif
170 171 #endif /* _LARGEFILE64_SOURCE */
171 172 #endif /* _OFF_T */
172 173 #endif /* _LARGEFILE_SOURCE */
173 174
174 175 #ifdef _LARGEFILE64_SOURCE
175 176 #ifdef _LP64
176 177 typedef fpos_t fpos64_t;
177 178 #else
178 179 typedef __longlong_t fpos64_t;
179 180 #endif
180 181 #endif /* _LARGEFILE64_SOURCE */
181 182
182 183 /*
183 184 * XPG4 requires that va_list be defined in <stdio.h> "as described in
184 185 * <stdarg.h>". ANSI-C and POSIX require that the namespace of <stdio.h>
185 186 * not be polluted with this name.
186 187 */
187 188 #if defined(_XPG4) && !defined(_VA_LIST)
188 189 #define _VA_LIST
189 190 typedef __va_list va_list;
190 191 #endif /* defined(_XPG4 && !defined(_VA_LIST) */
191 192
192 193 #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
193 194 defined(__XOPEN_OR_POSIX)
194 195
195 196 #define L_ctermid 9
196 197
197 198 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
198 199 #if !defined(_XPG6) || defined(__EXTENSIONS__)
199 200 #define L_cuserid 9
200 201 #endif
201 202
202 203 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
203 204
204 205 #if defined(__EXTENSIONS__) || \
205 206 (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
206 207 defined(_XOPEN_SOURCE)
207 208
↓ open down ↓ |
175 lines elided |
↑ open up ↑ |
208 209 #define P_tmpdir "/var/tmp/"
209 210 #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */
210 211
211 212 #ifndef _STDIO_ALLOCATE
212 213 extern unsigned char _sibuf[], _sobuf[];
213 214 #endif
214 215
215 216 /* large file compilation environment setup */
216 217 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
217 218 #if !defined(__PRAGMA_REDEFINE_EXTNAME)
218 -#if defined(__STDC__)
219 219 extern FILE *fopen64(const char *, const char *);
220 220 extern FILE *freopen64(const char *, const char *, FILE *);
221 221 extern FILE *tmpfile64(void);
222 222 extern int fgetpos64(FILE *, fpos_t *);
223 223 extern int fsetpos64(FILE *, const fpos_t *);
224 -#else /* defined(__STDC__) */
225 -extern FILE *fopen64();
226 -extern FILE *freopen64();
227 -extern FILE *tmpfile64();
228 -extern int fgetpos64();
229 -extern int fsetpos64();
230 -#endif /* defined(__STDC__) */
231 224 #define fopen fopen64
232 225 #define freopen freopen64
233 226 #define tmpfile tmpfile64
234 227 #define fgetpos fgetpos64
235 228 #define fsetpos fsetpos64
236 229 #ifdef _LARGEFILE_SOURCE
237 230 #define fseeko fseeko64
238 231 #define ftello ftello64
239 232 #endif
240 233 #endif /* !__PRAGMA_REDEFINE_EXTNAME */
241 234 #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
242 235
243 236 #ifndef _LP64
244 237 extern unsigned char *_bufendtab[];
245 238 extern FILE *_lastbuf;
246 239 #endif
247 240
248 241 /* In the LP64 compilation environment, all APIs are already large file */
249 242 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
250 243 #if !defined(__PRAGMA_REDEFINE_EXTNAME)
251 244 #define fopen64 fopen
252 245 #define freopen64 freopen
253 246 #define tmpfile64 tmpfile
254 247 #define fgetpos64 fgetpos
255 248 #define fsetpos64 fsetpos
256 249 #ifdef _LARGEFILE_SOURCE
257 250 #define fseeko64 fseeko
258 251 #define ftello64 ftello
259 252 #endif
260 253 #endif /* !__PRAGMA_REDEFINE_EXTNAME */
261 254 #endif /* _LP64 && _LARGEFILE64_SOURCE */
↓ open down ↓ |
21 lines elided |
↑ open up ↑ |
262 255
263 256 #ifndef _SSIZE_T
264 257 #define _SSIZE_T
265 258 #if defined(_LP64) || defined(_I32LPx)
266 259 typedef long ssize_t; /* size of something in bytes or -1 */
267 260 #else
268 261 typedef int ssize_t; /* (historical version) */
269 262 #endif
270 263 #endif /* !_SSIZE_T */
271 264
272 -#if defined(__STDC__)
273 -
274 265 #if defined(__EXTENSIONS__) || \
275 266 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
276 267 defined(_REENTRANT)
277 268 extern char *tmpnam_r(char *);
278 269 #endif
279 270
280 271 #if defined(__EXTENSIONS__) || \
281 272 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
282 273 extern int fcloseall(void);
283 274 extern void setbuffer(FILE *, char *, size_t);
284 275 extern int setlinebuf(FILE *);
285 276 /* PRINTFLIKE2 */
286 277 extern int asprintf(char **, const char *, ...);
287 278 /* PRINTFLIKE2 */
288 279 extern int vasprintf(char **, const char *, __va_list);
289 280 #endif
290 281
291 282 #if defined(__EXTENSIONS__) || \
292 283 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
293 284 /* || defined(_XPG7) */
294 285 extern ssize_t getdelim(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD,
295 286 int, FILE *_RESTRICT_KYWD);
296 287 extern ssize_t getline(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD,
297 288 FILE *_RESTRICT_KYWD);
298 289 #endif /* __EXTENSIONS__ ... */
299 290
300 291 /*
301 292 * The following are known to POSIX and XOPEN, but not to ANSI-C.
302 293 */
303 294 #if defined(__EXTENSIONS__) || \
304 295 !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX)
305 296
306 297 extern FILE *fdopen(int, const char *);
307 298 extern char *ctermid(char *);
308 299 extern int fileno(FILE *);
309 300
310 301 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
311 302
312 303 /*
313 304 * The following are known to POSIX.1c, but not to ANSI-C or XOPEN.
314 305 */
315 306 #if defined(__EXTENSIONS__) || defined(_REENTRANT) || \
316 307 (_POSIX_C_SOURCE - 0 >= 199506L)
317 308 extern void flockfile(FILE *);
318 309 extern int ftrylockfile(FILE *);
319 310 extern void funlockfile(FILE *);
320 311 extern int getc_unlocked(FILE *);
321 312 extern int getchar_unlocked(void);
322 313 extern int putc_unlocked(int, FILE *);
323 314 extern int putchar_unlocked(int);
324 315
325 316 #endif /* defined(__EXTENSIONS__) || defined(_REENTRANT).. */
326 317
327 318 /*
328 319 * The following are known to XOPEN, but not to ANSI-C or POSIX.
329 320 */
330 321 #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
331 322 defined(_XOPEN_SOURCE)
332 323 extern FILE *popen(const char *, const char *);
333 324 extern char *tempnam(const char *, const char *);
334 325 extern int pclose(FILE *);
335 326 #if !defined(_XOPEN_SOURCE)
336 327 extern int getsubopt(char **, char *const *, char **);
337 328 #endif /* !defined(_XOPEN_SOURCE) */
338 329
339 330 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
340 331 #if !defined(_XPG6) || defined(__EXTENSIONS__)
341 332 extern char *cuserid(char *);
342 333 extern int getopt(int, char *const *, const char *);
343 334 extern char *optarg;
344 335 extern int optind, opterr, optopt;
345 336 extern int getw(FILE *);
346 337 extern int putw(int, FILE *);
347 338 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
348 339
349 340 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
350 341
351 342 /*
352 343 * The following are defined as part of the Large File Summit interfaces.
353 344 */
354 345 #if defined(_LARGEFILE_SOURCE) || defined(_XPG5)
355 346 extern int fseeko(FILE *, off_t, int);
356 347 extern off_t ftello(FILE *);
357 348 #endif
358 349
359 350 /*
360 351 * The following are defined as part of the transitional Large File Summit
361 352 * interfaces.
362 353 */
363 354 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
↓ open down ↓ |
80 lines elided |
↑ open up ↑ |
364 355 !defined(__PRAGMA_REDEFINE_EXTNAME))
365 356 extern FILE *fopen64(const char *, const char *);
366 357 extern FILE *freopen64(const char *, const char *, FILE *);
367 358 extern FILE *tmpfile64(void);
368 359 extern int fgetpos64(FILE *, fpos64_t *);
369 360 extern int fsetpos64(FILE *, const fpos64_t *);
370 361 extern int fseeko64(FILE *, off64_t, int);
371 362 extern off64_t ftello64(FILE *);
372 363 #endif
373 364
374 -#else /* !defined __STDC__ */
375 -
376 -#ifndef _LP64
377 -#define _bufend(p) ((fileno(p) < _NFILE) ? _bufendtab[fileno(p)] : \
378 - (unsigned char *)_realbufend(p))
379 -#define _bufsiz(p) (_bufend(p) - (p)->_base)
380 -#endif /* _LP64 */
381 -
382 -#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
383 - defined(_REENTRANT)
384 -extern char *tmpnam_r();
385 -#endif
386 -
387 -#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
388 -extern int fcloseall();
389 -extern void setbuffer();
390 -extern int setlinebuf();
391 -extern int asprintf();
392 -extern int vasprintf();
393 -#endif
394 -
395 -#if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
396 - /* || defined(_XPG7) */
397 -extern ssize_t getdelim();
398 -extern ssize_t getline();
399 -#endif /* __EXTENSIONS__ ... */
400 -
401 -#if defined(__EXTENSIONS__) || defined(__XOPEN_OR_POSIX)
402 -extern FILE *fdopen();
403 -extern char *ctermid();
404 -extern int fileno();
405 -#endif /* defined(__EXTENSIONS__) || defined(__XOPEN_OR_POSIX) */
406 -
407 -#if defined(__EXTENSIONS__) || defined(_REENTRANT) || \
408 - (_POSIX_C_SOURCE - 0 >= 199506L)
409 -extern void flockfile();
410 -extern int ftrylockfile();
411 -extern void funlockfile();
412 -extern int getc_unlocked();
413 -extern int getchar_unlocked();
414 -extern int putc_unlocked();
415 -extern int putchar_unlocked();
416 -#endif /* defined(__EXTENSIONS__) || defined(_REENTRANT).. */
417 -
418 -#if defined(__EXTENSIONS__) || defined(_XOPEN_SOURCE)
419 -extern FILE *popen();
420 -extern char *tempnam();
421 -extern int pclose();
422 -
423 -#if !defined(_XOPEN_SOURCE)
424 -extern int getsubopt();
425 -#endif /* !defined(_XOPEN_SOURCE) */
426 -
427 -#if !defined(_XPG6) || defined(__EXTENSIONS__)
428 -extern char *cuserid();
429 -extern int getopt();
430 -extern char *optarg;
431 -extern int optind, opterr, optopt;
432 -extern int getw();
433 -extern int putw();
434 -#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
435 -
436 -#endif /* defined(__EXTENSIONS__) || defined(_XOPEN_SOURCE) */
437 -
438 -#if defined(_LARGEFILE_SOURCE) || defined(_XPG5)
439 -extern int fseeko();
440 -extern off_t ftello();
441 -#endif
442 -
443 -#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
444 - !defined(__PRAGMA_REDEFINE_EXTNAME))
445 -extern FILE *fopen64();
446 -extern FILE *freopen64();
447 -extern FILE *tmpfile64();
448 -extern int fgetpos64();
449 -extern int fsetpos64();
450 -extern int fseeko64();
451 -extern off64_t ftello64();
452 -#endif
453 -
454 -#endif /* __STDC__ */
455 -
456 365 #if !defined(__lint)
457 366
458 367 #if defined(__EXTENSIONS__) || defined(_REENTRANT) || \
459 368 (_POSIX_C_SOURCE - 0 >= 199506L)
460 369 #ifndef _LP64
461 -#ifdef __STDC__
462 370 #define getc_unlocked(p) (--(p)->_cnt < 0 \
463 371 ? __filbuf(p) \
464 372 : (int)*(p)->_ptr++)
465 373 #define putc_unlocked(x, p) (--(p)->_cnt < 0 \
466 374 ? __flsbuf((x), (p)) \
467 375 : (int)(*(p)->_ptr++ = \
468 376 (unsigned char) (x)))
469 -#else
470 -#define getc_unlocked(p) (--(p)->_cnt < 0 \
471 - ? _filbuf(p) \
472 - : (int)*(p)->_ptr++)
473 -#define putc_unlocked(x, p) (--(p)->_cnt < 0 \
474 - ? _flsbuf((x), (p)) \
475 - : (int)(*(p)->_ptr++ = \
476 - (unsigned char) (x)))
477 -#endif /* __STDC__ */
478 377 #endif /* _LP64 */
479 378 #define getchar_unlocked() getc_unlocked(stdin)
480 379 #define putchar_unlocked(x) putc_unlocked((x), stdout)
481 380 #endif /* defined(__EXTENSIONS__) || defined(_REENTRANT).. */
482 381
483 382 #endif /* !defined(__lint) */
484 383
485 384 #ifdef __cplusplus
486 385 }
487 386 #endif
488 387
489 388 #endif /* _STDIO_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX