Benchtests: Remove simple_str(n)cmp
[glibc.git] / libio / stdio.h
blob857f02888d09189e36368eae5d23ff1fac55de27
1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991-2023 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, see
17 <https://www.gnu.org/licenses/>. */
20 * ISO C99 Standard: 7.19 Input/output <stdio.h>
23 #ifndef _STDIO_H
24 #define _STDIO_H 1
26 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
27 #include <bits/libc-header-start.h>
29 __BEGIN_DECLS
31 #define __need_size_t
32 #define __need_NULL
33 #include <stddef.h>
35 #define __need___va_list
36 #include <stdarg.h>
38 #include <bits/types.h>
39 #include <bits/types/__fpos_t.h>
40 #include <bits/types/__fpos64_t.h>
41 #include <bits/types/__FILE.h>
42 #include <bits/types/FILE.h>
43 #include <bits/types/struct_FILE.h>
45 #ifdef __USE_GNU
46 # include <bits/types/cookie_io_functions_t.h>
47 #endif
49 #if defined __USE_XOPEN || defined __USE_XOPEN2K8
50 # ifdef __GNUC__
51 # ifndef _VA_LIST_DEFINED
52 typedef __gnuc_va_list va_list;
53 # define _VA_LIST_DEFINED
54 # endif
55 # else
56 # include <stdarg.h>
57 # endif
58 #endif
60 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
61 # ifndef __off_t_defined
62 # ifndef __USE_FILE_OFFSET64
63 typedef __off_t off_t;
64 # else
65 typedef __off64_t off_t;
66 # endif
67 # define __off_t_defined
68 # endif
69 # if defined __USE_LARGEFILE64 && !defined __off64_t_defined
70 typedef __off64_t off64_t;
71 # define __off64_t_defined
72 # endif
73 #endif
75 #ifdef __USE_XOPEN2K8
76 # ifndef __ssize_t_defined
77 typedef __ssize_t ssize_t;
78 # define __ssize_t_defined
79 # endif
80 #endif
82 /* The type of the second argument to `fgetpos' and `fsetpos'. */
83 #ifndef __USE_FILE_OFFSET64
84 typedef __fpos_t fpos_t;
85 #else
86 typedef __fpos64_t fpos_t;
87 #endif
88 #ifdef __USE_LARGEFILE64
89 typedef __fpos64_t fpos64_t;
90 #endif
92 /* The possibilities for the third argument to `setvbuf'. */
93 #define _IOFBF 0 /* Fully buffered. */
94 #define _IOLBF 1 /* Line buffered. */
95 #define _IONBF 2 /* No buffering. */
98 /* Default buffer size. */
99 #define BUFSIZ 8192
102 /* The value returned by fgetc and similar functions to indicate the
103 end of the file. */
104 #define EOF (-1)
107 /* The possibilities for the third argument to `fseek'.
108 These values should not be changed. */
109 #define SEEK_SET 0 /* Seek from beginning of file. */
110 #define SEEK_CUR 1 /* Seek from current position. */
111 #define SEEK_END 2 /* Seek from end of file. */
112 #ifdef __USE_GNU
113 # define SEEK_DATA 3 /* Seek to next data. */
114 # define SEEK_HOLE 4 /* Seek to next hole. */
115 #endif
118 #if defined __USE_MISC || defined __USE_XOPEN
119 /* Default path prefix for `tempnam' and `tmpnam'. */
120 # define P_tmpdir "/tmp"
121 #endif
124 /* Get the values:
125 L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
126 TMP_MAX The minimum number of unique filenames generated by tmpnam
127 (and tempnam when it uses tmpnam's name space),
128 or tempnam (the two are separate).
129 L_ctermid How long an array to pass to `ctermid'.
130 L_cuserid How long an array to pass to `cuserid'.
131 FOPEN_MAX Minimum number of files that can be open at once.
132 FILENAME_MAX Maximum length of a filename. */
133 #include <bits/stdio_lim.h>
136 #if __GLIBC_USE (ISOC2X)
137 /* Maximum length of printf output for a NaN. */
138 # define _PRINTF_NAN_LEN_MAX 4
139 #endif
142 /* Standard streams. */
143 extern FILE *stdin; /* Standard input stream. */
144 extern FILE *stdout; /* Standard output stream. */
145 extern FILE *stderr; /* Standard error output stream. */
146 /* C89/C99 say they're macros. Make them happy. */
147 #define stdin stdin
148 #define stdout stdout
149 #define stderr stderr
151 /* Remove file FILENAME. */
152 extern int remove (const char *__filename) __THROW;
153 /* Rename file OLD to NEW. */
154 extern int rename (const char *__old, const char *__new) __THROW;
156 #ifdef __USE_ATFILE
157 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
158 extern int renameat (int __oldfd, const char *__old, int __newfd,
159 const char *__new) __THROW;
160 #endif
162 #ifdef __USE_GNU
163 /* Flags for renameat2. */
164 # define RENAME_NOREPLACE (1 << 0)
165 # define RENAME_EXCHANGE (1 << 1)
166 # define RENAME_WHITEOUT (1 << 2)
168 /* Rename file OLD relative to OLDFD to NEW relative to NEWFD, with
169 additional flags. */
170 extern int renameat2 (int __oldfd, const char *__old, int __newfd,
171 const char *__new, unsigned int __flags) __THROW;
172 #endif
174 /* Close STREAM.
176 This function is a possible cancellation point and therefore not
177 marked with __THROW. */
178 extern int fclose (FILE *__stream);
180 #undef __attr_dealloc_fclose
181 #define __attr_dealloc_fclose __attr_dealloc (fclose, 1)
183 /* Create a temporary file and open it read/write.
185 This function is a possible cancellation point and therefore not
186 marked with __THROW. */
187 #ifndef __USE_FILE_OFFSET64
188 extern FILE *tmpfile (void)
189 __attribute_malloc__ __attr_dealloc_fclose __wur;
190 #else
191 # ifdef __REDIRECT
192 extern FILE *__REDIRECT (tmpfile, (void), tmpfile64)
193 __attribute_malloc__ __attr_dealloc_fclose __wur;
194 # else
195 # define tmpfile tmpfile64
196 # endif
197 #endif
199 #ifdef __USE_LARGEFILE64
200 extern FILE *tmpfile64 (void)
201 __attribute_malloc__ __attr_dealloc_fclose __wur;
202 #endif
204 /* Generate a temporary filename. */
205 extern char *tmpnam (char[L_tmpnam]) __THROW __wur;
207 #ifdef __USE_MISC
208 /* This is the reentrant variant of `tmpnam'. The only difference is
209 that it does not allow S to be NULL. */
210 extern char *tmpnam_r (char __s[L_tmpnam]) __THROW __wur;
211 #endif
214 #if defined __USE_MISC || defined __USE_XOPEN
215 /* Generate a unique temporary filename using up to five characters of PFX
216 if it is not NULL. The directory to put this file in is searched for
217 as follows: First the environment variable "TMPDIR" is checked.
218 If it contains the name of a writable directory, that directory is used.
219 If not and if DIR is not NULL, that value is checked. If that fails,
220 P_tmpdir is tried and finally "/tmp". The storage for the filename
221 is allocated by `malloc'. */
222 extern char *tempnam (const char *__dir, const char *__pfx)
223 __THROW __attribute_malloc__ __wur __attr_dealloc_free;
224 #endif
226 /* Flush STREAM, or all streams if STREAM is NULL.
228 This function is a possible cancellation point and therefore not
229 marked with __THROW. */
230 extern int fflush (FILE *__stream);
232 #ifdef __USE_MISC
233 /* Faster versions when locking is not required.
235 This function is not part of POSIX and therefore no official
236 cancellation point. But due to similarity with an POSIX interface
237 or due to the implementation it is a cancellation point and
238 therefore not marked with __THROW. */
239 extern int fflush_unlocked (FILE *__stream);
240 #endif
242 #ifdef __USE_GNU
243 /* Close all streams.
245 This function is not part of POSIX and therefore no official
246 cancellation point. But due to similarity with an POSIX interface
247 or due to the implementation it is a cancellation point and
248 therefore not marked with __THROW. */
249 extern int fcloseall (void);
250 #endif
253 #ifndef __USE_FILE_OFFSET64
254 /* Open a file and create a new stream for it.
256 This function is a possible cancellation point and therefore not
257 marked with __THROW. */
258 extern FILE *fopen (const char *__restrict __filename,
259 const char *__restrict __modes)
260 __attribute_malloc__ __attr_dealloc_fclose __wur;
261 /* Open a file, replacing an existing stream with it.
263 This function is a possible cancellation point and therefore not
264 marked with __THROW. */
265 extern FILE *freopen (const char *__restrict __filename,
266 const char *__restrict __modes,
267 FILE *__restrict __stream) __wur;
268 #else
269 # ifdef __REDIRECT
270 extern FILE *__REDIRECT (fopen, (const char *__restrict __filename,
271 const char *__restrict __modes), fopen64)
272 __attribute_malloc__ __attr_dealloc_fclose __wur;
273 extern FILE *__REDIRECT (freopen, (const char *__restrict __filename,
274 const char *__restrict __modes,
275 FILE *__restrict __stream), freopen64)
276 __wur;
277 # else
278 # define fopen fopen64
279 # define freopen freopen64
280 # endif
281 #endif
282 #ifdef __USE_LARGEFILE64
283 extern FILE *fopen64 (const char *__restrict __filename,
284 const char *__restrict __modes)
285 __attribute_malloc__ __attr_dealloc_fclose __wur;
286 extern FILE *freopen64 (const char *__restrict __filename,
287 const char *__restrict __modes,
288 FILE *__restrict __stream) __wur;
289 #endif
291 #ifdef __USE_POSIX
292 /* Create a new stream that refers to an existing system file descriptor. */
293 extern FILE *fdopen (int __fd, const char *__modes) __THROW
294 __attribute_malloc__ __attr_dealloc_fclose __wur;
295 #endif
297 #ifdef __USE_GNU
298 /* Create a new stream that refers to the given magic cookie,
299 and uses the given functions for input and output. */
300 extern FILE *fopencookie (void *__restrict __magic_cookie,
301 const char *__restrict __modes,
302 cookie_io_functions_t __io_funcs) __THROW
303 __attribute_malloc__ __attr_dealloc_fclose __wur;
304 #endif
306 #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
307 /* Create a new stream that refers to a memory buffer. */
308 extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
309 __THROW __attribute_malloc__ __attr_dealloc_fclose __wur;
311 /* Open a stream that writes into a malloc'd buffer that is expanded as
312 necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
313 and the number of characters written on fflush or fclose. */
314 extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW
315 __attribute_malloc__ __attr_dealloc_fclose __wur;
317 #ifdef _WCHAR_H
318 /* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces
319 a wide character string. Declared here only to add attribute malloc
320 and only if <wchar.h> has been previously #included. */
321 extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW
322 __attribute_malloc__ __attr_dealloc_fclose;
323 # endif
324 #endif
326 /* If BUF is NULL, make STREAM unbuffered.
327 Else make it use buffer BUF, of size BUFSIZ. */
328 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
329 /* Make STREAM use buffering mode MODE.
330 If BUF is not NULL, use N bytes of it for buffering;
331 else allocate an internal buffer N bytes long. */
332 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
333 int __modes, size_t __n) __THROW;
335 #ifdef __USE_MISC
336 /* If BUF is NULL, make STREAM unbuffered.
337 Else make it use SIZE bytes of BUF for buffering. */
338 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
339 size_t __size) __THROW;
341 /* Make STREAM line-buffered. */
342 extern void setlinebuf (FILE *__stream) __THROW;
343 #endif
346 /* Write formatted output to STREAM.
348 This function is a possible cancellation point and therefore not
349 marked with __THROW. */
350 extern int fprintf (FILE *__restrict __stream,
351 const char *__restrict __format, ...);
352 /* Write formatted output to stdout.
354 This function is a possible cancellation point and therefore not
355 marked with __THROW. */
356 extern int printf (const char *__restrict __format, ...);
357 /* Write formatted output to S. */
358 extern int sprintf (char *__restrict __s,
359 const char *__restrict __format, ...) __THROWNL;
361 /* Write formatted output to S from argument list ARG.
363 This function is a possible cancellation point and therefore not
364 marked with __THROW. */
365 extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
366 __gnuc_va_list __arg);
367 /* Write formatted output to stdout from argument list ARG.
369 This function is a possible cancellation point and therefore not
370 marked with __THROW. */
371 extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);
372 /* Write formatted output to S from argument list ARG. */
373 extern int vsprintf (char *__restrict __s, const char *__restrict __format,
374 __gnuc_va_list __arg) __THROWNL;
376 #if defined __USE_ISOC99 || defined __USE_UNIX98
377 /* Maximum chars of output to write in MAXLEN. */
378 extern int snprintf (char *__restrict __s, size_t __maxlen,
379 const char *__restrict __format, ...)
380 __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
382 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
383 const char *__restrict __format, __gnuc_va_list __arg)
384 __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
385 #endif
387 #if __GLIBC_USE (LIB_EXT2)
388 /* Write formatted output to a string dynamically allocated with `malloc'.
389 Store the address of the string in *PTR. */
390 extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
391 __gnuc_va_list __arg)
392 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
393 extern int __asprintf (char **__restrict __ptr,
394 const char *__restrict __fmt, ...)
395 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
396 extern int asprintf (char **__restrict __ptr,
397 const char *__restrict __fmt, ...)
398 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
399 #endif
401 #ifdef __USE_XOPEN2K8
402 /* Write formatted output to a file descriptor. */
403 extern int vdprintf (int __fd, const char *__restrict __fmt,
404 __gnuc_va_list __arg)
405 __attribute__ ((__format__ (__printf__, 2, 0)));
406 extern int dprintf (int __fd, const char *__restrict __fmt, ...)
407 __attribute__ ((__format__ (__printf__, 2, 3)));
408 #endif
411 /* Read formatted input from STREAM.
413 This function is a possible cancellation point and therefore not
414 marked with __THROW. */
415 extern int fscanf (FILE *__restrict __stream,
416 const char *__restrict __format, ...) __wur;
417 /* Read formatted input from stdin.
419 This function is a possible cancellation point and therefore not
420 marked with __THROW. */
421 extern int scanf (const char *__restrict __format, ...) __wur;
422 /* Read formatted input from S. */
423 extern int sscanf (const char *__restrict __s,
424 const char *__restrict __format, ...) __THROW;
426 /* For historical reasons, the C99-compliant versions of the scanf
427 functions are at alternative names. When __LDBL_COMPAT or
428 __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI are in effect, this is handled in
429 bits/stdio-ldbl.h. */
430 #include <bits/floatn.h>
431 #if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
432 && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
433 # if __GLIBC_USE (C2X_STRTOL)
434 # ifdef __REDIRECT
435 extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
436 const char *__restrict __format, ...),
437 __isoc23_fscanf) __wur;
438 extern int __REDIRECT (scanf, (const char *__restrict __format, ...),
439 __isoc23_scanf) __wur;
440 extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,
441 const char *__restrict __format, ...),
442 __isoc23_sscanf);
443 # else
444 extern int __isoc23_fscanf (FILE *__restrict __stream,
445 const char *__restrict __format, ...) __wur;
446 extern int __isoc23_scanf (const char *__restrict __format, ...) __wur;
447 extern int __isoc23_sscanf (const char *__restrict __s,
448 const char *__restrict __format, ...) __THROW;
449 # define fscanf __isoc23_fscanf
450 # define scanf __isoc23_scanf
451 # define sscanf __isoc23_sscanf
452 # endif
453 # else
454 # ifdef __REDIRECT
455 extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
456 const char *__restrict __format, ...),
457 __isoc99_fscanf) __wur;
458 extern int __REDIRECT (scanf, (const char *__restrict __format, ...),
459 __isoc99_scanf) __wur;
460 extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,
461 const char *__restrict __format, ...),
462 __isoc99_sscanf);
463 # else
464 extern int __isoc99_fscanf (FILE *__restrict __stream,
465 const char *__restrict __format, ...) __wur;
466 extern int __isoc99_scanf (const char *__restrict __format, ...) __wur;
467 extern int __isoc99_sscanf (const char *__restrict __s,
468 const char *__restrict __format, ...) __THROW;
469 # define fscanf __isoc99_fscanf
470 # define scanf __isoc99_scanf
471 # define sscanf __isoc99_sscanf
472 # endif
473 # endif
474 #endif
476 #ifdef __USE_ISOC99
477 /* Read formatted input from S into argument list ARG.
479 This function is a possible cancellation point and therefore not
480 marked with __THROW. */
481 extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
482 __gnuc_va_list __arg)
483 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
485 /* Read formatted input from stdin into argument list ARG.
487 This function is a possible cancellation point and therefore not
488 marked with __THROW. */
489 extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
490 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
492 /* Read formatted input from S into argument list ARG. */
493 extern int vsscanf (const char *__restrict __s,
494 const char *__restrict __format, __gnuc_va_list __arg)
495 __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
497 /* Same redirection as above for the v*scanf family. */
498 # if !__GLIBC_USE (DEPRECATED_SCANF)
499 # if __GLIBC_USE (C2X_STRTOL)
500 # if defined __REDIRECT && !defined __LDBL_COMPAT \
501 && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
502 extern int __REDIRECT (vfscanf,
503 (FILE *__restrict __s,
504 const char *__restrict __format, __gnuc_va_list __arg),
505 __isoc23_vfscanf)
506 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
507 extern int __REDIRECT (vscanf, (const char *__restrict __format,
508 __gnuc_va_list __arg), __isoc23_vscanf)
509 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
510 extern int __REDIRECT_NTH (vsscanf,
511 (const char *__restrict __s,
512 const char *__restrict __format,
513 __gnuc_va_list __arg), __isoc23_vsscanf)
514 __attribute__ ((__format__ (__scanf__, 2, 0)));
515 # elif !defined __REDIRECT
516 extern int __isoc23_vfscanf (FILE *__restrict __s,
517 const char *__restrict __format,
518 __gnuc_va_list __arg) __wur;
519 extern int __isoc23_vscanf (const char *__restrict __format,
520 __gnuc_va_list __arg) __wur;
521 extern int __isoc23_vsscanf (const char *__restrict __s,
522 const char *__restrict __format,
523 __gnuc_va_list __arg) __THROW;
524 # define vfscanf __isoc23_vfscanf
525 # define vscanf __isoc23_vscanf
526 # define vsscanf __isoc23_vsscanf
527 # endif
528 # else
529 # if defined __REDIRECT && !defined __LDBL_COMPAT \
530 && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
531 extern int __REDIRECT (vfscanf,
532 (FILE *__restrict __s,
533 const char *__restrict __format, __gnuc_va_list __arg),
534 __isoc99_vfscanf)
535 __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
536 extern int __REDIRECT (vscanf, (const char *__restrict __format,
537 __gnuc_va_list __arg), __isoc99_vscanf)
538 __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
539 extern int __REDIRECT_NTH (vsscanf,
540 (const char *__restrict __s,
541 const char *__restrict __format,
542 __gnuc_va_list __arg), __isoc99_vsscanf)
543 __attribute__ ((__format__ (__scanf__, 2, 0)));
544 # elif !defined __REDIRECT
545 extern int __isoc99_vfscanf (FILE *__restrict __s,
546 const char *__restrict __format,
547 __gnuc_va_list __arg) __wur;
548 extern int __isoc99_vscanf (const char *__restrict __format,
549 __gnuc_va_list __arg) __wur;
550 extern int __isoc99_vsscanf (const char *__restrict __s,
551 const char *__restrict __format,
552 __gnuc_va_list __arg) __THROW;
553 # define vfscanf __isoc99_vfscanf
554 # define vscanf __isoc99_vscanf
555 # define vsscanf __isoc99_vsscanf
556 # endif
557 # endif
558 # endif
559 #endif /* Use ISO C9x. */
562 /* Read a character from STREAM.
564 These functions are possible cancellation points and therefore not
565 marked with __THROW. */
566 extern int fgetc (FILE *__stream);
567 extern int getc (FILE *__stream);
569 /* Read a character from stdin.
571 This function is a possible cancellation point and therefore not
572 marked with __THROW. */
573 extern int getchar (void);
575 #ifdef __USE_POSIX199506
576 /* These are defined in POSIX.1:1996.
578 These functions are possible cancellation points and therefore not
579 marked with __THROW. */
580 extern int getc_unlocked (FILE *__stream);
581 extern int getchar_unlocked (void);
582 #endif /* Use POSIX. */
584 #ifdef __USE_MISC
585 /* Faster version when locking is not necessary.
587 This function is not part of POSIX and therefore no official
588 cancellation point. But due to similarity with an POSIX interface
589 or due to the implementation it is a cancellation point and
590 therefore not marked with __THROW. */
591 extern int fgetc_unlocked (FILE *__stream);
592 #endif /* Use MISC. */
595 /* Write a character to STREAM.
597 These functions are possible cancellation points and therefore not
598 marked with __THROW.
600 These functions is a possible cancellation point and therefore not
601 marked with __THROW. */
602 extern int fputc (int __c, FILE *__stream);
603 extern int putc (int __c, FILE *__stream);
605 /* Write a character to stdout.
607 This function is a possible cancellation point and therefore not
608 marked with __THROW. */
609 extern int putchar (int __c);
611 #ifdef __USE_MISC
612 /* Faster version when locking is not necessary.
614 This function is not part of POSIX and therefore no official
615 cancellation point. But due to similarity with an POSIX interface
616 or due to the implementation it is a cancellation point and
617 therefore not marked with __THROW. */
618 extern int fputc_unlocked (int __c, FILE *__stream);
619 #endif /* Use MISC. */
621 #ifdef __USE_POSIX199506
622 /* These are defined in POSIX.1:1996.
624 These functions are possible cancellation points and therefore not
625 marked with __THROW. */
626 extern int putc_unlocked (int __c, FILE *__stream);
627 extern int putchar_unlocked (int __c);
628 #endif /* Use POSIX. */
631 #if defined __USE_MISC \
632 || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
633 /* Get a word (int) from STREAM. */
634 extern int getw (FILE *__stream);
636 /* Write a word (int) to STREAM. */
637 extern int putw (int __w, FILE *__stream);
638 #endif
641 /* Get a newline-terminated string of finite length from STREAM.
643 This function is a possible cancellation point and therefore not
644 marked with __THROW. */
645 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
646 __wur __fortified_attr_access (__write_only__, 1, 2);
648 #if __GLIBC_USE (DEPRECATED_GETS)
649 /* Get a newline-terminated string from stdin, removing the newline.
651 This function is impossible to use safely. It has been officially
652 removed from ISO C11 and ISO C++14, and we have also removed it
653 from the _GNU_SOURCE feature list. It remains available when
654 explicitly using an old ISO C, Unix, or POSIX standard.
656 This function is a possible cancellation point and therefore not
657 marked with __THROW. */
658 extern char *gets (char *__s) __wur __attribute_deprecated__;
659 #endif
661 #ifdef __USE_GNU
662 /* This function does the same as `fgets' but does not lock the stream.
664 This function is not part of POSIX and therefore no official
665 cancellation point. But due to similarity with an POSIX interface
666 or due to the implementation it is a cancellation point and
667 therefore not marked with __THROW. */
668 extern char *fgets_unlocked (char *__restrict __s, int __n,
669 FILE *__restrict __stream) __wur
670 __fortified_attr_access (__write_only__, 1, 2);
671 #endif
674 #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
675 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
676 (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
677 NULL), pointing to *N characters of space. It is realloc'd as
678 necessary. Returns the number of characters read (not including the
679 null terminator), or -1 on error or EOF.
681 These functions are not part of POSIX and therefore no official
682 cancellation point. But due to similarity with an POSIX interface
683 or due to the implementation they are cancellation points and
684 therefore not marked with __THROW. */
685 extern __ssize_t __getdelim (char **__restrict __lineptr,
686 size_t *__restrict __n, int __delimiter,
687 FILE *__restrict __stream) __wur;
688 extern __ssize_t getdelim (char **__restrict __lineptr,
689 size_t *__restrict __n, int __delimiter,
690 FILE *__restrict __stream) __wur;
692 /* Like `getdelim', but reads up to a newline.
694 This function is not part of POSIX and therefore no official
695 cancellation point. But due to similarity with an POSIX interface
696 or due to the implementation it is a cancellation point and
697 therefore not marked with __THROW. */
698 extern __ssize_t getline (char **__restrict __lineptr,
699 size_t *__restrict __n,
700 FILE *__restrict __stream) __wur;
701 #endif
704 /* Write a string to STREAM.
706 This function is a possible cancellation point and therefore not
707 marked with __THROW. */
708 extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
710 /* Write a string, followed by a newline, to stdout.
712 This function is a possible cancellation point and therefore not
713 marked with __THROW. */
714 extern int puts (const char *__s);
717 /* Push a character back onto the input buffer of STREAM.
719 This function is a possible cancellation point and therefore not
720 marked with __THROW. */
721 extern int ungetc (int __c, FILE *__stream);
724 /* Read chunks of generic data from STREAM.
726 This function is a possible cancellation point and therefore not
727 marked with __THROW. */
728 extern size_t fread (void *__restrict __ptr, size_t __size,
729 size_t __n, FILE *__restrict __stream) __wur;
730 /* Write chunks of generic data to STREAM.
732 This function is a possible cancellation point and therefore not
733 marked with __THROW. */
734 extern size_t fwrite (const void *__restrict __ptr, size_t __size,
735 size_t __n, FILE *__restrict __s);
737 #ifdef __USE_GNU
738 /* This function does the same as `fputs' but does not lock the stream.
740 This function is not part of POSIX and therefore no official
741 cancellation point. But due to similarity with an POSIX interface
742 or due to the implementation it is a cancellation point and
743 therefore not marked with __THROW. */
744 extern int fputs_unlocked (const char *__restrict __s,
745 FILE *__restrict __stream);
746 #endif
748 #ifdef __USE_MISC
749 /* Faster versions when locking is not necessary.
751 These functions are not part of POSIX and therefore no official
752 cancellation point. But due to similarity with an POSIX interface
753 or due to the implementation they are cancellation points and
754 therefore not marked with __THROW. */
755 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
756 size_t __n, FILE *__restrict __stream) __wur;
757 extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
758 size_t __n, FILE *__restrict __stream);
759 #endif
762 /* Seek to a certain position on STREAM.
764 This function is a possible cancellation point and therefore not
765 marked with __THROW. */
766 extern int fseek (FILE *__stream, long int __off, int __whence);
767 /* Return the current position of STREAM.
769 This function is a possible cancellation point and therefore not
770 marked with __THROW. */
771 extern long int ftell (FILE *__stream) __wur;
772 /* Rewind to the beginning of STREAM.
774 This function is a possible cancellation point and therefore not
775 marked with __THROW. */
776 extern void rewind (FILE *__stream);
778 /* The Single Unix Specification, Version 2, specifies an alternative,
779 more adequate interface for the two functions above which deal with
780 file offset. `long int' is not the right type. These definitions
781 are originally defined in the Large File Support API. */
783 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
784 # ifndef __USE_FILE_OFFSET64
785 /* Seek to a certain position on STREAM.
787 This function is a possible cancellation point and therefore not
788 marked with __THROW. */
789 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
790 /* Return the current position of STREAM.
792 This function is a possible cancellation point and therefore not
793 marked with __THROW. */
794 extern __off_t ftello (FILE *__stream) __wur;
795 # else
796 # ifdef __REDIRECT
797 extern int __REDIRECT (fseeko,
798 (FILE *__stream, __off64_t __off, int __whence),
799 fseeko64);
800 extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
801 # else
802 # define fseeko fseeko64
803 # define ftello ftello64
804 # endif
805 # endif
806 #endif
808 #ifndef __USE_FILE_OFFSET64
809 /* Get STREAM's position.
811 This function is a possible cancellation point and therefore not
812 marked with __THROW. */
813 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
814 /* Set STREAM's position.
816 This function is a possible cancellation point and therefore not
817 marked with __THROW. */
818 extern int fsetpos (FILE *__stream, const fpos_t *__pos);
819 #else
820 # ifdef __REDIRECT
821 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
822 fpos_t *__restrict __pos), fgetpos64);
823 extern int __REDIRECT (fsetpos,
824 (FILE *__stream, const fpos_t *__pos), fsetpos64);
825 # else
826 # define fgetpos fgetpos64
827 # define fsetpos fsetpos64
828 # endif
829 #endif
831 #ifdef __USE_LARGEFILE64
832 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
833 extern __off64_t ftello64 (FILE *__stream) __wur;
834 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
835 extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);
836 #endif
838 /* Clear the error and EOF indicators for STREAM. */
839 extern void clearerr (FILE *__stream) __THROW;
840 /* Return the EOF indicator for STREAM. */
841 extern int feof (FILE *__stream) __THROW __wur;
842 /* Return the error indicator for STREAM. */
843 extern int ferror (FILE *__stream) __THROW __wur;
845 #ifdef __USE_MISC
846 /* Faster versions when locking is not required. */
847 extern void clearerr_unlocked (FILE *__stream) __THROW;
848 extern int feof_unlocked (FILE *__stream) __THROW __wur;
849 extern int ferror_unlocked (FILE *__stream) __THROW __wur;
850 #endif
853 /* Print a message describing the meaning of the value of errno.
855 This function is a possible cancellation point and therefore not
856 marked with __THROW. */
857 extern void perror (const char *__s);
860 #ifdef __USE_POSIX
861 /* Return the system file descriptor for STREAM. */
862 extern int fileno (FILE *__stream) __THROW __wur;
863 #endif /* Use POSIX. */
865 #ifdef __USE_MISC
866 /* Faster version when locking is not required. */
867 extern int fileno_unlocked (FILE *__stream) __THROW __wur;
868 #endif
871 #ifdef __USE_POSIX2
872 /* Close a stream opened by popen and return the status of its child.
874 This function is a possible cancellation point and therefore not
875 marked with __THROW. */
876 extern int pclose (FILE *__stream);
878 /* Create a new stream connected to a pipe running the given command.
880 This function is a possible cancellation point and therefore not
881 marked with __THROW. */
882 extern FILE *popen (const char *__command, const char *__modes)
883 __attribute_malloc__ __attr_dealloc (pclose, 1) __wur;
885 #endif
888 #ifdef __USE_POSIX
889 /* Return the name of the controlling terminal. */
890 extern char *ctermid (char *__s) __THROW
891 __attr_access ((__write_only__, 1));
892 #endif /* Use POSIX. */
895 #if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU
896 /* Return the name of the current user. */
897 extern char *cuserid (char *__s)
898 __attr_access ((__write_only__, 1));
899 #endif /* Use X/Open, but not issue 6. */
902 #ifdef __USE_GNU
903 struct obstack; /* See <obstack.h>. */
905 /* Write formatted output to an obstack. */
906 extern int obstack_printf (struct obstack *__restrict __obstack,
907 const char *__restrict __format, ...)
908 __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));
909 extern int obstack_vprintf (struct obstack *__restrict __obstack,
910 const char *__restrict __format,
911 __gnuc_va_list __args)
912 __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));
913 #endif /* Use GNU. */
916 #ifdef __USE_POSIX199506
917 /* These are defined in POSIX.1:1996. */
919 /* Acquire ownership of STREAM. */
920 extern void flockfile (FILE *__stream) __THROW;
922 /* Try to acquire ownership of STREAM but do not block if it is not
923 possible. */
924 extern int ftrylockfile (FILE *__stream) __THROW __wur;
926 /* Relinquish the ownership granted for STREAM. */
927 extern void funlockfile (FILE *__stream) __THROW;
928 #endif /* POSIX */
930 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
931 /* X/Open Issues 1-5 required getopt to be declared in this
932 header. It was removed in Issue 6. GNU follows Issue 6. */
933 # include <bits/getopt_posix.h>
934 #endif
936 /* Slow-path routines used by the optimized inline functions in
937 bits/stdio.h. */
938 extern int __uflow (FILE *);
939 extern int __overflow (FILE *, int);
941 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
942 /* Declare all functions from bits/stdio2-decl.h first. */
943 # include <bits/stdio2-decl.h>
944 #endif
946 /* The following headers provide asm redirections. These redirections must
947 appear before the first usage of these functions, e.g. in bits/stdio.h. */
948 #if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
949 # include <bits/stdio-ldbl.h>
950 #endif
952 /* If we are compiling with optimizing read this file. It contains
953 several optimizing inline functions and macros. */
954 #ifdef __USE_EXTERN_INLINES
955 # include <bits/stdio.h>
956 #endif
957 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
958 /* Now include the function definitions and redirects too. */
959 # include <bits/stdio2.h>
960 #endif
962 __END_DECLS
964 #endif /* <stdio.h> included. */