libm: remove int_WRAPPER_C99 macro, add test which checks that I did not break it
[uclibc-ng.git] / include / stdio.h
blob3c86f256b47b294d1c22c73c6eceaad690bf640f
1 /*
2 Copyright (C) 1991,1994-2002,2003,2004 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
21 * ISO C99 Standard: 7.19 Input/output <stdio.h>
24 #ifndef _STDIO_H
26 #if !defined __need_FILE && !defined __need___FILE
27 # define _STDIO_H 1
28 # include <features.h>
30 __BEGIN_DECLS
32 # define __need_size_t
33 # define __need_NULL
34 # include <stddef.h>
36 # include <bits/types.h>
37 # define __need_FILE
38 # define __need___FILE
39 #endif /* Don't need FILE. */
42 #if !defined __FILE_defined && defined __need_FILE
44 __BEGIN_NAMESPACE_STD
45 /* The opaque type of streams. This is the definition used elsewhere. */
46 typedef struct __STDIO_FILE_STRUCT FILE;
47 __END_NAMESPACE_STD
48 #if defined __USE_LARGEFILE64 || defined __USE_SVID || defined __USE_POSIX \
49 || defined __USE_BSD || defined __USE_ISOC99 || defined __USE_XOPEN \
50 || defined __USE_POSIX2
51 __USING_NAMESPACE_STD(FILE)
52 #endif
54 # define __FILE_defined 1
55 #endif /* FILE not defined. */
56 #undef __need_FILE
59 #if !defined ____FILE_defined && defined __need___FILE
61 /* The opaque type of streams. This is the definition used elsewhere. */
62 typedef struct __STDIO_FILE_STRUCT __FILE;
64 # define ____FILE_defined 1
65 #endif /* __FILE not defined. */
66 #undef __need___FILE
69 #ifdef _STDIO_H
70 #undef _STDIO_USES_IOSTREAM
72 #include <bits/uClibc_stdio.h>
74 /* This define avoids name pollution if we're using GNU stdarg.h */
75 # define __need___va_list
76 #include <stdarg.h>
78 /* The type of the second argument to `fgetpos' and `fsetpos'. */
79 __BEGIN_NAMESPACE_STD
80 #ifndef __USE_FILE_OFFSET64
81 typedef __STDIO_fpos_t fpos_t;
82 #else
83 typedef __STDIO_fpos64_t fpos_t;
84 #endif
85 __END_NAMESPACE_STD
86 #ifdef __USE_LARGEFILE64
87 typedef __STDIO_fpos64_t fpos64_t;
88 #endif
90 /* The possibilities for the third argument to `setvbuf'. */
91 #define _IOFBF __STDIO_IOFBF /* Fully buffered. */
92 #define _IOLBF __STDIO_IOLBF /* Line buffered. */
93 #define _IONBF __STDIO_IONBF /* No buffering. */
96 /* Default buffer size. */
97 #ifndef BUFSIZ
98 # define BUFSIZ __STDIO_BUFSIZ
99 #endif
102 /* End of file character.
103 Some things throughout the library rely on this being -1. */
104 #ifndef EOF
105 # define EOF (-1)
106 #endif
109 /* The possibilities for the third argument to `fseek'.
110 These values should not be changed. */
111 #define SEEK_SET 0 /* Seek from beginning of file. */
112 #define SEEK_CUR 1 /* Seek from current position. */
113 #define SEEK_END 2 /* Seek from end of file. */
116 #if defined __USE_SVID || defined __USE_XOPEN
117 /* Default path prefix for `tempnam' and `tmpnam'. */
118 # define P_tmpdir "/tmp"
119 #endif
122 /* Get the values:
123 L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
124 TMP_MAX The minimum number of unique filenames generated by tmpnam
125 (and tempnam when it uses tmpnam's name space),
126 or tempnam (the two are separate).
127 L_ctermid How long an array to pass to `ctermid'.
128 L_cuserid How long an array to pass to `cuserid'.
129 FOPEN_MAX Minimum number of files that can be open at once.
130 FILENAME_MAX Maximum length of a filename. */
131 #include <bits/stdio_lim.h>
134 /* Standard streams. */
135 extern FILE *stdin; /* Standard input stream. */
136 extern FILE *stdout; /* Standard output stream. */
137 extern FILE *stderr; /* Standard error output stream. */
138 /* C89/C99 say they're macros. Make them happy. */
139 #define stdin stdin
140 #define stdout stdout
141 #define stderr stderr
143 __BEGIN_NAMESPACE_STD
144 /* Remove file FILENAME. */
145 extern int remove (__const char *__filename) __THROW;
146 libc_hidden_proto(remove)
147 /* Rename file OLD to NEW. */
148 extern int rename (__const char *__old, __const char *__new) __THROW;
149 __END_NAMESPACE_STD
151 #ifdef __USE_ATFILE
152 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
153 extern int renameat (int __oldfd, __const char *__old, int __newfd,
154 __const char *__new) __THROW;
155 #endif
157 __BEGIN_NAMESPACE_STD
158 /* Create a temporary file and open it read/write.
160 This function is a possible cancellation points and therefore not
161 marked with __THROW. */
162 #ifndef __USE_FILE_OFFSET64
163 extern FILE *tmpfile (void) __wur;
164 #else
165 # ifdef __REDIRECT
166 extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
167 # else
168 # define tmpfile tmpfile64
169 # endif
170 #endif
172 #ifdef __USE_LARGEFILE64
173 extern FILE *tmpfile64 (void) __wur;
174 #endif
176 /* Generate a temporary filename. */
177 extern char *tmpnam (char *__s) __THROW __wur;
178 __END_NAMESPACE_STD
180 #ifdef __USE_MISC
181 /* This is the reentrant variant of `tmpnam'. The only difference is
182 that it does not allow S to be NULL. */
183 extern char *tmpnam_r (char *__s) __THROW __wur;
184 #endif
187 #if defined __USE_SVID || defined __USE_XOPEN
188 /* Generate a unique temporary filename using up to five characters of PFX
189 if it is not NULL. The directory to put this file in is searched for
190 as follows: First the environment variable "TMPDIR" is checked.
191 If it contains the name of a writable directory, that directory is used.
192 If not and if DIR is not NULL, that value is checked. If that fails,
193 P_tmpdir is tried and finally "/tmp". The storage for the filename
194 is allocated by `malloc'. */
195 extern char *tempnam (__const char *__dir, __const char *__pfx)
196 __THROW __attribute_malloc__ __wur;
197 #endif
200 __BEGIN_NAMESPACE_STD
201 /* Close STREAM.
203 This function is a possible cancellation point and therefore not
204 marked with __THROW. */
205 extern int fclose (FILE *__stream);
206 libc_hidden_proto(fclose)
207 /* Flush STREAM, or all streams if STREAM is NULL.
209 This function is a possible cancellation point and therefore not
210 marked with __THROW. */
211 extern int fflush (FILE *__stream);
212 libc_hidden_proto(fflush)
213 __END_NAMESPACE_STD
215 #ifdef __USE_MISC
216 /* Faster versions when locking is not required.
218 This function is not part of POSIX and therefore no official
219 cancellation point. But due to similarity with an POSIX interface
220 or due to the implementation it is a cancellation point and
221 therefore not marked with __THROW. */
222 extern int fflush_unlocked (FILE *__stream);
223 libc_hidden_proto(fflush_unlocked)
224 #endif
226 #ifdef __USE_GNU
227 /* Close all streams.
229 This function is not part of POSIX and therefore no official
230 cancellation point. But due to similarity with an POSIX interface
231 or due to the implementation it is a cancellation point and
232 therefore not marked with __THROW. */
233 extern int fcloseall (void);
234 #endif
237 __BEGIN_NAMESPACE_STD
238 #ifndef __USE_FILE_OFFSET64
239 /* Open a file and create a new stream for it.
241 This function is a possible cancellation point and therefore not
242 marked with __THROW. */
243 extern FILE *fopen (__const char *__restrict __filename,
244 __const char *__restrict __modes) __wur;
245 libc_hidden_proto(fopen)
246 /* Open a file, replacing an existing stream with it.
248 This function is a possible cancellation point and therefore not
249 marked with __THROW. */
250 extern FILE *freopen (__const char *__restrict __filename,
251 __const char *__restrict __modes,
252 FILE *__restrict __stream) __wur;
253 #else
254 # ifdef __REDIRECT
255 extern FILE *__REDIRECT (fopen, (__const char *__restrict __filename,
256 __const char *__restrict __modes), fopen64)
257 __wur;
258 extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
259 __const char *__restrict __modes,
260 FILE *__restrict __stream), freopen64)
261 __wur;
262 # else
263 # define fopen fopen64
264 # define freopen freopen64
265 # endif
266 #endif
267 __END_NAMESPACE_STD
268 #ifdef __USE_LARGEFILE64
269 extern FILE *fopen64 (__const char *__restrict __filename,
270 __const char *__restrict __modes) __wur;
271 libc_hidden_proto(fopen64)
272 extern FILE *freopen64 (__const char *__restrict __filename,
273 __const char *__restrict __modes,
274 FILE *__restrict __stream) __wur;
275 #endif
277 #ifdef __USE_POSIX
278 /* Create a new stream that refers to an existing system file descriptor. */
279 extern FILE *fdopen (int __fd, __const char *__modes) __THROW __wur;
280 libc_hidden_proto(fdopen)
281 #endif
283 #ifdef __USE_GNU
284 #ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
285 /* Create a new stream that refers to the given magic cookie,
286 and uses the given functions for input and output. */
287 extern FILE *fopencookie (void *__restrict __magic_cookie,
288 __const char *__restrict __modes,
289 _IO_cookie_io_functions_t __io_funcs) __THROW __wur;
290 libc_hidden_proto(fopencookie)
292 /* Create a new stream that refers to a memory buffer. */
293 extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes)
294 __THROW __wur;
296 /* Open a stream that writes into a malloc'd buffer that is expanded as
297 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
298 and the number of characters written on fflush or fclose. */
299 extern FILE *open_memstream (char **__restrict __bufloc,
300 size_t *__restrict __sizeloc) __THROW __wur;
301 libc_hidden_proto(open_memstream)
302 #endif
303 #endif
306 __BEGIN_NAMESPACE_STD
307 /* If BUF is NULL, make STREAM unbuffered.
308 Else make it use buffer BUF, of size BUFSIZ. */
309 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
310 /* Make STREAM use buffering mode MODE.
311 If BUF is not NULL, use N bytes of it for buffering;
312 else allocate an internal buffer N bytes long. */
313 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
314 int __modes, size_t __n) __THROW;
315 libc_hidden_proto(setvbuf)
316 __END_NAMESPACE_STD
318 #ifdef __USE_BSD
319 /* If BUF is NULL, make STREAM unbuffered.
320 Else make it use SIZE bytes of BUF for buffering. */
321 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
322 size_t __size) __THROW;
324 /* Make STREAM line-buffered. */
325 extern void setlinebuf (FILE *__stream) __THROW;
326 #endif
329 __BEGIN_NAMESPACE_STD
330 /* Write formatted output to STREAM.
332 This function is a possible cancellation point and therefore not
333 marked with __THROW. */
334 extern int fprintf (FILE *__restrict __stream,
335 __const char *__restrict __format, ...);
336 libc_hidden_proto(fprintf)
337 /* Write formatted output to stdout.
339 This function is a possible cancellation point and therefore not
340 marked with __THROW. */
341 extern int printf (__const char *__restrict __format, ...);
342 libc_hidden_proto(printf)
343 /* Write formatted output to S. */
344 extern int sprintf (char *__restrict __s,
345 __const char *__restrict __format, ...)
346 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
347 libc_hidden_proto(sprintf)
349 /* Write formatted output to S from argument list ARG.
351 This function is a possible cancellation point and therefore not
352 marked with __THROW. */
353 extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
354 __gnuc_va_list __arg);
355 libc_hidden_proto(vfprintf)
356 /* Write formatted output to stdout from argument list ARG.
358 This function is a possible cancellation point and therefore not
359 marked with __THROW. */
360 extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg);
361 /* Write formatted output to S from argument list ARG. */
362 extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
363 __gnuc_va_list __arg)
364 __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
365 __END_NAMESPACE_STD
367 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
368 __BEGIN_NAMESPACE_C99
369 /* Maximum chars of output to write in MAXLEN. */
370 extern int snprintf (char *__restrict __s, size_t __maxlen,
371 __const char *__restrict __format, ...)
372 __THROW __attribute__ ((__format__ (__printf__, 3, 4)));
373 libc_hidden_proto(snprintf)
375 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
376 __const char *__restrict __format, __gnuc_va_list __arg)
377 __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
378 libc_hidden_proto(vsnprintf)
379 __END_NAMESPACE_C99
380 #endif
382 #ifdef __USE_GNU
383 /* Write formatted output to a string dynamically allocated with `malloc'.
384 Store the address of the string in *PTR. */
385 extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f,
386 __gnuc_va_list __arg)
387 __THROW __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
388 libc_hidden_proto(vasprintf)
389 #if 0 /* uClibc: disabled */
390 extern int __asprintf (char **__restrict __ptr,
391 __const char *__restrict __fmt, ...)
392 __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
393 #endif
394 extern int asprintf (char **__restrict __ptr,
395 __const char *__restrict __fmt, ...)
396 __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
397 libc_hidden_proto(asprintf)
399 /* Write formatted output to a file descriptor.
401 These functions are not part of POSIX and therefore no official
402 cancellation point. But due to similarity with an POSIX interface
403 or due to the implementation they are cancellation points and
404 therefore not marked with __THROW. */
405 extern int vdprintf (int __fd, __const char *__restrict __fmt,
406 __gnuc_va_list __arg)
407 __attribute__ ((__format__ (__printf__, 2, 0)));
408 libc_hidden_proto(vdprintf)
409 extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
410 __attribute__ ((__format__ (__printf__, 2, 3)));
411 #endif
414 __BEGIN_NAMESPACE_STD
415 /* Read formatted input from STREAM.
417 This function is a possible cancellation point and therefore not
418 marked with __THROW. */
419 extern int fscanf (FILE *__restrict __stream,
420 __const char *__restrict __format, ...)
421 __attribute__ ((__format__ (__scanf__, 2, 3))) __wur;
422 libc_hidden_proto(fscanf)
423 /* Read formatted input from stdin.
425 This function is a possible cancellation point and therefore not
426 marked with __THROW. */
427 extern int scanf (__const char *__restrict __format, ...)
428 __attribute__ ((__format__ (__scanf__, 1, 2))) __wur;
429 /* Read formatted input from S. */
430 extern int sscanf (__const char *__restrict __s,
431 __const char *__restrict __format, ...)
432 __THROW __attribute__ ((__format__ (__scanf__, 2, 3)));
433 libc_hidden_proto(sscanf)
434 __END_NAMESPACE_STD
436 #ifdef __USE_ISOC99
437 __BEGIN_NAMESPACE_C99
438 /* Read formatted input from S into argument list ARG.
440 This function is a possible cancellation point and therefore not
441 marked with __THROW. */
442 extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
443 __gnuc_va_list __arg)
444 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
445 libc_hidden_proto(vfscanf)
447 /* Read formatted input from stdin into argument list ARG.
449 This function is a possible cancellation point and therefore not
450 marked with __THROW. */
451 extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg)
452 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
453 libc_hidden_proto(vscanf)
455 /* Read formatted input from S into argument list ARG. */
456 extern int vsscanf (__const char *__restrict __s,
457 __const char *__restrict __format, __gnuc_va_list __arg)
458 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
459 libc_hidden_proto(vsscanf)
460 __END_NAMESPACE_C99
461 #endif /* Use ISO C9x. */
464 __BEGIN_NAMESPACE_STD
465 /* Read a character from STREAM.
467 These functions are possible cancellation points and therefore not
468 marked with __THROW. */
469 extern int fgetc (FILE *__stream);
470 libc_hidden_proto(fgetc)
471 extern int getc (FILE *__stream);
473 /* Read a character from stdin.
475 This function is a possible cancellation point and therefore not
476 marked with __THROW. */
477 extern int getchar (void);
478 __END_NAMESPACE_STD
480 /* The C standard explicitly says this is a macro, so we always do the
481 optimization for it. */
482 #define getc(_fp) __GETC(_fp)
484 #if defined __USE_POSIX || defined __USE_MISC
485 /* These are defined in POSIX.1:1996.
487 These functions are possible cancellation points and therefore not
488 marked with __THROW. */
489 extern int getc_unlocked (FILE *__stream);
490 libc_hidden_proto(getc_unlocked)
491 extern int getchar_unlocked (void);
492 libc_hidden_proto(getchar_unlocked)
494 /* SUSv3 allows getc_unlocked to be a macro */
495 #define getc_unlocked(_fp) __GETC_UNLOCKED(_fp)
496 #endif /* Use POSIX or MISC. */
498 #ifdef __USE_MISC
499 /* Faster version when locking is not necessary.
501 This function is not part of POSIX and therefore no official
502 cancellation point. But due to similarity with an POSIX interface
503 or due to the implementation it is a cancellation point and
504 therefore not marked with __THROW. */
505 extern int fgetc_unlocked (FILE *__stream);
506 libc_hidden_proto(fgetc_unlocked)
507 #endif /* Use MISC. */
510 __BEGIN_NAMESPACE_STD
511 /* Write a character to STREAM.
513 These functions are possible cancellation points and therefore not
514 marked with __THROW.
516 These functions is a possible cancellation point and therefore not
517 marked with __THROW. */
518 extern int fputc (int __c, FILE *__stream);
519 libc_hidden_proto(fputc)
520 extern int putc (int __c, FILE *__stream);
521 libc_hidden_proto(putc)
523 /* Write a character to stdout.
525 This function is a possible cancellation point and therefore not
526 marked with __THROW. */
527 extern int putchar (int __c);
528 __END_NAMESPACE_STD
530 /* The C standard explicitly says this can be a macro,
531 so we always do the optimization for it. */
532 #define putc(_ch, _fp) __PUTC(_ch, _fp)
534 #ifdef __USE_MISC
535 /* Faster version when locking is not necessary.
537 This function is not part of POSIX and therefore no official
538 cancellation point. But due to similarity with an POSIX interface
539 or due to the implementation it is a cancellation point and
540 therefore not marked with __THROW. */
541 extern int fputc_unlocked (int __c, FILE *__stream);
542 libc_hidden_proto(fputc_unlocked)
543 #endif /* Use MISC. */
545 #if defined __USE_POSIX || defined __USE_MISC
546 /* These are defined in POSIX.1:1996.
548 These functions are possible cancellation points and therefore not
549 marked with __THROW. */
550 extern int putc_unlocked (int __c, FILE *__stream);
551 libc_hidden_proto(putc_unlocked)
552 extern int putchar_unlocked (int __c);
554 /* SUSv3 allows putc_unlocked to be a macro */
555 #define putc_unlocked(_ch, _fp) __PUTC_UNLOCKED(_ch, _fp)
556 #endif /* Use POSIX or MISC. */
559 #if defined __USE_SVID || defined __USE_MISC \
560 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
561 /* Get a word (int) from STREAM. */
562 extern int getw (FILE *__stream);
564 /* Write a word (int) to STREAM. */
565 extern int putw (int __w, FILE *__stream);
566 #endif
569 __BEGIN_NAMESPACE_STD
570 /* Get a newline-terminated string of finite length from STREAM.
572 This function is a possible cancellation point and therefore not
573 marked with __THROW. */
574 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
575 __wur;
576 libc_hidden_proto(fgets)
578 /* Get a newline-terminated string from stdin, removing the newline.
579 DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
581 This function is a possible cancellation point and therefore not
582 marked with __THROW. */
583 extern char *gets (char *__s) __wur;
584 __END_NAMESPACE_STD
586 #ifdef __USE_GNU
587 /* This function does the same as `fgets' but does not lock the stream.
589 This function is not part of POSIX and therefore no official
590 cancellation point. But due to similarity with an POSIX interface
591 or due to the implementation it is a cancellation point and
592 therefore not marked with __THROW. */
593 extern char *fgets_unlocked (char *__restrict __s, int __n,
594 FILE *__restrict __stream) __wur;
595 libc_hidden_proto(fgets_unlocked)
596 #endif
599 #ifdef __USE_GNU
600 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
601 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
602 NULL), pointing to *N characters of space. It is realloc'd as
603 necessary. Returns the number of characters read (not including the
604 null terminator), or -1 on error or EOF.
606 These functions are not part of POSIX and therefore no official
607 cancellation point. But due to similarity with an POSIX interface
608 or due to the implementation they are cancellation points and
609 therefore not marked with __THROW. */
610 #if 0 /* uClibc: disabled */
611 extern __ssize_t __getdelim (char **__restrict __lineptr,
612 size_t *__restrict __n, int __delimiter,
613 FILE *__restrict __stream) __wur;
614 #endif
615 extern __ssize_t getdelim (char **__restrict __lineptr,
616 size_t *__restrict __n, int __delimiter,
617 FILE *__restrict __stream) __wur;
618 libc_hidden_proto(getdelim)
620 /* Like `getdelim', but reads up to a newline.
622 This function is not part of POSIX and therefore no official
623 cancellation point. But due to similarity with an POSIX interface
624 or due to the implementation it is a cancellation point and
625 therefore not marked with __THROW. */
626 extern __ssize_t getline (char **__restrict __lineptr,
627 size_t *__restrict __n,
628 FILE *__restrict __stream) __wur;
629 libc_hidden_proto(getline)
630 #endif
633 __BEGIN_NAMESPACE_STD
634 /* Write a string to STREAM.
636 This function is a possible cancellation points and therefore not
637 marked with __THROW. */
638 extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);
639 libc_hidden_proto(fputs)
641 /* Write a string, followed by a newline, to stdout.
643 This function is a possible cancellation points and therefore not
644 marked with __THROW. */
645 extern int puts (__const char *__s);
648 /* Push a character back onto the input buffer of STREAM.
650 This function is a possible cancellation points and therefore not
651 marked with __THROW. */
652 extern int ungetc (int __c, FILE *__stream);
653 libc_hidden_proto(ungetc)
656 /* Read chunks of generic data from STREAM.
658 This function is a possible cancellation points and therefore not
659 marked with __THROW. */
660 extern size_t fread (void *__restrict __ptr, size_t __size,
661 size_t __n, FILE *__restrict __stream) __wur;
662 libc_hidden_proto(fread)
663 /* Write chunks of generic data to STREAM.
665 This function is a possible cancellation points and therefore not
666 marked with __THROW. */
667 extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
668 size_t __n, FILE *__restrict __s) __wur;
669 libc_hidden_proto(fwrite)
670 __END_NAMESPACE_STD
672 #ifdef __USE_GNU
673 /* This function does the same as `fputs' but does not lock the stream.
675 This function is not part of POSIX and therefore no official
676 cancellation point. But due to similarity with an POSIX interface
677 or due to the implementation it is a cancellation point and
678 therefore not marked with __THROW. */
679 extern int fputs_unlocked (__const char *__restrict __s,
680 FILE *__restrict __stream);
681 libc_hidden_proto(fputs_unlocked)
682 #endif
684 #ifdef __USE_MISC
685 /* Faster versions when locking is not necessary.
687 These functions are not part of POSIX and therefore no official
688 cancellation point. But due to similarity with an POSIX interface
689 or due to the implementation they are cancellation points and
690 therefore not marked with __THROW. */
691 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
692 size_t __n, FILE *__restrict __stream) __wur;
693 libc_hidden_proto(fread_unlocked)
694 extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
695 size_t __n, FILE *__restrict __stream) __wur;
696 libc_hidden_proto(fwrite_unlocked)
697 #endif
700 __BEGIN_NAMESPACE_STD
701 /* Seek to a certain position on STREAM.
703 This function is a possible cancellation point and therefore not
704 marked with __THROW. */
705 extern int fseek (FILE *__stream, long int __off, int __whence);
706 libc_hidden_proto(fseek)
707 /* Return the current position of STREAM.
709 This function is a possible cancellation point and therefore not
710 marked with __THROW. */
711 extern long int ftell (FILE *__stream) __wur;
712 libc_hidden_proto(ftell)
713 /* Rewind to the beginning of STREAM.
715 This function is a possible cancellation point and therefore not
716 marked with __THROW. */
717 extern void rewind (FILE *__stream);
718 libc_hidden_proto(rewind)
719 __END_NAMESPACE_STD
721 /* The Single Unix Specification, Version 2, specifies an alternative,
722 more adequate interface for the two functions above which deal with
723 file offset. `long int' is not the right type. These definitions
724 are originally defined in the Large File Support API. */
726 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
727 # ifndef __USE_FILE_OFFSET64
728 /* Seek to a certain position on STREAM.
730 This function is a possible cancellation point and therefore not
731 marked with __THROW. */
732 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
733 /* Return the current position of STREAM.
735 This function is a possible cancellation point and therefore not
736 marked with __THROW. */
737 extern __off_t ftello (FILE *__stream) __wur;
738 # else
739 # ifdef __REDIRECT
740 extern int __REDIRECT (fseeko,
741 (FILE *__stream, __off64_t __off, int __whence),
742 fseeko64);
743 extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
744 # else
745 # define fseeko fseeko64
746 # define ftello ftello64
747 # endif
748 # endif
749 #endif
751 __BEGIN_NAMESPACE_STD
752 #ifndef __USE_FILE_OFFSET64
753 /* Get STREAM's position.
755 This function is a possible cancellation point and therefore not
756 marked with __THROW. */
757 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
758 /* Set STREAM's position.
760 This function is a possible cancellation point and therefore not
761 marked with __THROW. */
762 extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
763 #else
764 # ifdef __REDIRECT
765 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
766 fpos_t *__restrict __pos), fgetpos64);
767 extern int __REDIRECT (fsetpos,
768 (FILE *__stream, __const fpos_t *__pos), fsetpos64);
769 # else
770 # define fgetpos fgetpos64
771 # define fsetpos fsetpos64
772 # endif
773 #endif
774 __END_NAMESPACE_STD
776 #ifdef __USE_LARGEFILE64
777 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
778 libc_hidden_proto(fseeko64)
779 extern __off64_t ftello64 (FILE *__stream) __wur;
780 libc_hidden_proto(ftello64)
781 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
782 extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos);
783 #endif
785 __BEGIN_NAMESPACE_STD
786 /* Clear the error and EOF indicators for STREAM. */
787 extern void clearerr (FILE *__stream) __THROW;
788 /* Return the EOF indicator for STREAM. */
789 extern int feof (FILE *__stream) __THROW __wur;
790 /* Return the error indicator for STREAM. */
791 extern int ferror (FILE *__stream) __THROW __wur;
792 __END_NAMESPACE_STD
794 #ifdef __USE_MISC
795 /* Faster versions when locking is not required. */
796 extern void clearerr_unlocked (FILE *__stream) __THROW;
797 extern int feof_unlocked (FILE *__stream) __THROW __wur;
798 extern int ferror_unlocked (FILE *__stream) __THROW __wur;
799 #endif
802 __BEGIN_NAMESPACE_STD
803 /* Print a message describing the meaning of the value of errno.
805 This function is a possible cancellation point and therefore not
806 marked with __THROW. */
807 extern void perror (__const char *__s);
808 libc_hidden_proto(perror)
809 __END_NAMESPACE_STD
811 #ifdef __UCLIBC_HAS_SYS_ERRLIST__
812 /* These variables normally should not be used directly. The `strerror'
813 function provides all the needed functionality. */
814 #ifdef __USE_BSD
815 extern int sys_nerr;
816 extern __const char *__const sys_errlist[];
817 #endif
818 #endif /* __UCLIBC_HAS_SYS_ERRLIST__ */
821 #ifdef __USE_POSIX
822 /* Return the system file descriptor for STREAM. */
823 extern int fileno (FILE *__stream) __THROW __wur;
824 libc_hidden_proto(fileno)
825 #endif /* Use POSIX. */
827 #ifdef __USE_MISC
828 /* Faster version when locking is not required. */
829 extern int fileno_unlocked (FILE *__stream) __THROW __wur;
830 libc_hidden_proto(fileno_unlocked)
831 #endif
834 #if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
835 defined __USE_MISC)
836 /* Create a new stream connected to a pipe running the given command.
838 This function is a possible cancellation point and therefore not
839 marked with __THROW. */
840 extern FILE *popen (__const char *__command, __const char *__modes) __wur;
842 /* Close a stream opened by popen and return the status of its child.
844 This function is a possible cancellation point and therefore not
845 marked with __THROW. */
846 extern int pclose (FILE *__stream);
847 #endif
850 #ifdef __USE_POSIX
851 /* Return the name of the controlling terminal. */
852 extern char *ctermid (char *__s) __THROW;
853 #endif /* Use POSIX. */
856 #ifdef __USE_XOPEN
857 /* Return the name of the current user. */
858 extern char *cuserid (char *__s);
859 #endif /* Use X/Open, but not issue 6. */
862 #if 0 /* def __USE_GNU uClibc note: not supported */
863 struct obstack; /* See <obstack.h>. */
865 /* Write formatted output to an obstack. */
866 extern int obstack_printf (struct obstack *__restrict __obstack,
867 __const char *__restrict __format, ...)
868 __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
869 extern int obstack_vprintf (struct obstack *__restrict __obstack,
870 __const char *__restrict __format,
871 __gnuc_va_list __args)
872 __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
873 #endif /* Use GNU. */
876 #if defined __USE_POSIX || defined __USE_MISC
877 /* These are defined in POSIX.1:1996. */
879 /* Acquire ownership of STREAM. */
880 extern void flockfile (FILE *__stream) __THROW;
882 /* Try to acquire ownership of STREAM but do not block if it is not
883 possible. */
884 extern int ftrylockfile (FILE *__stream) __THROW __wur;
886 /* Relinquish the ownership granted for STREAM. */
887 extern void funlockfile (FILE *__stream) __THROW;
888 #endif /* POSIX || misc */
890 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
891 /* The X/Open standard requires some functions and variables to be
892 declared here which do not belong into this header. But we have to
893 follow. In GNU mode we don't do this nonsense. */
894 # define __need_getopt
895 # include <bits/getopt.h>
896 #endif /* X/Open, but not issue 6 and not for GNU. */
898 /* If we are compiling with optimizing read this file. It contains
899 several optimizing inline functions and macros. */
900 #define fgetc(_fp) __FGETC(_fp)
901 #define fputc(_ch, _fp) __FPUTC(_ch, _fp)
903 #ifdef __USE_MISC
904 #define fgetc_unlocked(_fp) __FGETC_UNLOCKED(_fp)
905 #define fputc_unlocked(_ch, _fp) __FPUTC_UNLOCKED(_ch, _fp)
906 #endif
908 #ifndef __STDIO_GETC_MACRO
909 #define __stdin stdin
910 #endif
911 #define getchar() __GETC(__stdin)
913 #ifndef __STDIO_PUTC_MACRO
914 #define __stdout stdout
915 #endif
916 #define putchar(_ch) __PUTC((_ch), __stdout)
918 #if defined __USE_POSIX || defined __USE_MISC
919 #define getchar_unlocked() __GETC_UNLOCKED(__stdin)
920 #define putchar_unlocked(_ch) __PUTC_UNLOCKED((_ch), __stdout)
921 #endif
923 /* Clear the error and EOF indicators for STREAM. */
924 #define clearerr(_fp) __CLEARERR(_fp)
925 #define feof(_fp) __FEOF(_fp)
926 #define ferror(_fp) __FERROR(_fp)
928 #ifdef __USE_MISC
929 #define clearerr_unlocked(_fp) __CLEARERR_UNLOCKED(_fp)
930 #define feof_unlocked(_fp) __FEOF_UNLOCKED(_fp)
931 #define ferror_unlocked(_fp) __FERROR_UNLOCKED(_fp)
932 #endif
934 __END_DECLS
936 #endif /* <stdio.h> included. */
938 #endif /* !_STDIO_H */