OSDN Git Service

ldso: initialize stack_chk_guard after TLS is initialized
[uclinux-h8/uClibc.git] / include / stdio.h
1 /*
2    Copyright (C) 1991,1994-2002,2003,2004 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
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.
9
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.
14
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.  */
19
20 /*
21  *      ISO C99 Standard: 7.19 Input/output     <stdio.h>
22  */
23
24 #ifndef _STDIO_H
25
26 #if !defined __need_FILE && !defined __need___FILE
27 # define _STDIO_H       1
28 # include <features.h>
29
30 __BEGIN_DECLS
31
32 # define __need_size_t
33 # define __need_NULL
34 # include <stddef.h>
35
36 # include <bits/types.h>
37 # define __need_FILE
38 # define __need___FILE
39 #endif /* Don't need FILE.  */
40
41
42 #if !defined __FILE_defined && defined __need_FILE
43
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
53
54 # define __FILE_defined 1
55 #endif /* FILE not defined.  */
56 #undef  __need_FILE
57
58
59 #if !defined ____FILE_defined && defined __need___FILE
60
61 /* The opaque type of streams.  This is the definition used elsewhere.  */
62 typedef struct __STDIO_FILE_STRUCT __FILE;
63
64 # define ____FILE_defined       1
65 #endif /* __FILE not defined.  */
66 #undef  __need___FILE
67
68
69 #ifdef  _STDIO_H
70 #undef _STDIO_USES_IOSTREAM
71
72 #include <bits/uClibc_stdio.h>
73
74 /* This define avoids name pollution if we're using GNU stdarg.h */
75 # define __need___va_list
76 #include <stdarg.h>
77
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
89
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.  */
94
95
96 /* Default buffer size.  */
97 #ifndef BUFSIZ
98 # define BUFSIZ __STDIO_BUFSIZ
99 #endif
100
101
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
107
108
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.  */
114
115
116 #if defined __USE_SVID || defined __USE_XOPEN
117 /* Default path prefix for `tempnam' and `tmpnam'.  */
118 # define P_tmpdir       "/tmp"
119 #endif
120
121
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>
132
133
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
142
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
150
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
156
157 __BEGIN_NAMESPACE_STD
158 /* Create a temporary file and open it read/write.
159
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
171
172 #ifdef __USE_LARGEFILE64
173 extern FILE *tmpfile64 (void) __wur;
174 #endif
175
176 /* Generate a temporary filename.  */
177 extern char *tmpnam (char *__s) __THROW __wur;
178 __END_NAMESPACE_STD
179
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
185
186
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
198
199
200 __BEGIN_NAMESPACE_STD
201 /* Close STREAM.
202
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.
208
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
214
215 #ifdef __USE_MISC
216 /* Faster versions when locking is not required.
217
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
225
226 #ifdef __USE_GNU
227 /* Close all streams.
228
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
235
236
237 __BEGIN_NAMESPACE_STD
238 #ifndef __USE_FILE_OFFSET64
239 /* Open a file and create a new stream for it.
240
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.
247
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
276
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
282
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)
291
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;
295
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
304
305
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
317
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;
323
324 /* Make STREAM line-buffered.  */
325 extern void setlinebuf (FILE *__stream) __THROW;
326 #endif
327
328
329 __BEGIN_NAMESPACE_STD
330 /* Write formatted output to STREAM.
331
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.
338
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)
348
349 /* Write formatted output to S from argument list ARG.
350
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.
357
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
366
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)
374
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
381
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)
398
399 /* Write formatted output to a file descriptor.
400
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
412
413
414 __BEGIN_NAMESPACE_STD
415 /* Read formatted input from STREAM.
416
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.
424
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
435
436 #ifdef  __USE_ISOC99
437 __BEGIN_NAMESPACE_C99
438 /* Read formatted input from S into argument list ARG.
439
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)
446
447 /* Read formatted input from stdin into argument list ARG.
448
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)
454
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.  */
462
463
464 __BEGIN_NAMESPACE_STD
465 /* Read a character from STREAM.
466
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);
472
473 /* Read a character from stdin.
474
475    This function is a possible cancellation point and therefore not
476    marked with __THROW.  */
477 extern int getchar (void);
478 __END_NAMESPACE_STD
479
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)
483
484 #if defined __USE_POSIX || defined __USE_MISC
485 /* These are defined in POSIX.1:1996.
486
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)
493
494 /* SUSv3 allows getc_unlocked to be a macro */
495 #define getc_unlocked(_fp) __GETC_UNLOCKED(_fp)
496 #endif /* Use POSIX or MISC.  */
497
498 #ifdef __USE_MISC
499 /* Faster version when locking is not necessary.
500
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.  */
508
509
510 __BEGIN_NAMESPACE_STD
511 /* Write a character to STREAM.
512
513    These functions are possible cancellation points and therefore not
514    marked with __THROW.
515
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)
522
523 /* Write a character to stdout.
524
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
529
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)
533
534 #ifdef __USE_MISC
535 /* Faster version when locking is not necessary.
536
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.  */
544
545 #if defined __USE_POSIX || defined __USE_MISC
546 /* These are defined in POSIX.1:1996.
547
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);
553
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.  */
557
558
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);
563
564 /* Write a word (int) to STREAM.  */
565 extern int putw (int __w, FILE *__stream);
566 #endif
567
568
569 __BEGIN_NAMESPACE_STD
570 /* Get a newline-terminated string of finite length from STREAM.
571
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)
577
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.
580
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
585
586 #ifdef __USE_GNU
587 /* This function does the same as `fgets' but does not lock the stream.
588
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
597
598
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.
605
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)
619
620 /* Like `getdelim', but reads up to a newline.
621
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
631
632
633 __BEGIN_NAMESPACE_STD
634 /* Write a string to STREAM.
635
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)
640
641 /* Write a string, followed by a newline, to stdout.
642
643    This function is a possible cancellation points and therefore not
644    marked with __THROW.  */
645 extern int puts (__const char *__s);
646
647
648 /* Push a character back onto the input buffer of STREAM.
649
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)
654
655
656 /* Read chunks of generic data from STREAM.
657
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.
664
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
671
672 #ifdef __USE_GNU
673 /* This function does the same as `fputs' but does not lock the stream.
674
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
683
684 #ifdef __USE_MISC
685 /* Faster versions when locking is not necessary.
686
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
698
699
700 __BEGIN_NAMESPACE_STD
701 /* Seek to a certain position on STREAM.
702
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.
708
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.
714
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
720
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.  */
725
726 #if defined __USE_LARGEFILE || defined __USE_XOPEN2K
727 # ifndef __USE_FILE_OFFSET64
728 /* Seek to a certain position on STREAM.
729
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.
734
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
750
751 __BEGIN_NAMESPACE_STD
752 #ifndef __USE_FILE_OFFSET64
753 /* Get STREAM's position.
754
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.
759
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
775
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
784
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
793
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
800
801
802 __BEGIN_NAMESPACE_STD
803 /* Print a message describing the meaning of the value of errno.
804
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
810
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__ */
819
820
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.  */
826
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
832
833
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.
837
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;
841
842 /* Close a stream opened by popen and return the status of its child.
843
844    This function is a possible cancellation point and therefore not
845    marked with __THROW.  */
846 extern int pclose (FILE *__stream);
847 #endif
848
849
850 #ifdef  __USE_POSIX
851 /* Return the name of the controlling terminal.  */
852 extern char *ctermid (char *__s) __THROW;
853 #endif /* Use POSIX.  */
854
855
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.  */
860
861
862 #if 0 /* def    __USE_GNU uClibc note: not supported */
863 struct obstack;                 /* See <obstack.h>.  */
864
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.  */
874
875
876 #if defined __USE_POSIX || defined __USE_MISC
877 /* These are defined in POSIX.1:1996.  */
878
879 /* Acquire ownership of STREAM.  */
880 extern void flockfile (FILE *__stream) __THROW;
881
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;
885
886 /* Relinquish the ownership granted for STREAM.  */
887 extern void funlockfile (FILE *__stream) __THROW;
888 #endif /* POSIX || misc */
889
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.  */
897
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)
902
903 #ifdef __USE_MISC
904 #define fgetc_unlocked(_fp)          __FGETC_UNLOCKED(_fp)
905 #define fputc_unlocked(_ch, _fp)     __FPUTC_UNLOCKED(_ch, _fp)
906 #endif
907
908 #ifndef __STDIO_GETC_MACRO
909 #define __stdin stdin
910 #endif
911 #define getchar()                    __GETC(__stdin)
912
913 #ifndef __STDIO_PUTC_MACRO
914 #define __stdout stdout
915 #endif
916 #define putchar(_ch)                 __PUTC((_ch), __stdout)
917
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
922
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)
927
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
933
934 __END_DECLS
935
936 #endif /* <stdio.h> included.  */
937
938 #endif /* !_STDIO_H */