1#ifndef _STDIO_H
2# if !defined _ISOMAC && defined _IO_MTSAFE_IO
3# include <stdio-lock.h>
4# endif
5
6/* Workaround PR90731 with GCC 9 when using ldbl redirects in C++. */
7# include <bits/floatn.h>
8# if defined __cplusplus && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
9# if __GNUC_PREREQ (9, 0) && !__GNUC_PREREQ (9, 3)
10# pragma GCC system_header
11# endif
12# endif
13
14# include <libio/stdio.h>
15# ifndef _ISOMAC
16
17# define _LIBC_STDIO_H 1
18# include <libio/libio.h>
19
20/* Now define the internal interfaces. */
21
22/* Some libc_hidden_ldbl_proto's do not map to a unique symbol when
23 redirecting ldouble to _Float128 variants. We can therefore safely
24 directly alias them to their internal name. */
25# if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 && IS_IN (libc)
26# define stdio_hidden_ldbl_proto(p, f) \
27 extern __typeof (p ## f) p ## f __asm (__ASMNAME ("___ieee128_" #f));
28# elif __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
29# define stdio_hidden_ldbl_proto(p,f) __LDBL_REDIR1_DECL (p ## f, p ## f ## ieee128)
30# else
31# define stdio_hidden_ldbl_proto(p,f) libc_hidden_proto (p ## f)
32# endif
33
34/* Set the error indicator on FP. */
35static inline void
36fseterr_unlocked (FILE *fp)
37{
38 fp->_flags |= _IO_ERR_SEEN;
39}
40
41extern int __fcloseall (void) attribute_hidden;
42extern int __snprintf (char *__restrict __s, size_t __maxlen,
43 const char *__restrict __format, ...)
44 __attribute__ ((__format__ (__printf__, 3, 4)));
45stdio_hidden_ldbl_proto (__, snprintf)
46
47extern int __vfscanf (FILE *__restrict __s,
48 const char *__restrict __format,
49 __gnuc_va_list __arg)
50 __attribute__ ((__format__ (__scanf__, 2, 0)));
51libc_hidden_proto (__vfscanf)
52extern int __vscanf (const char *__restrict __format,
53 __gnuc_va_list __arg)
54 __attribute__ ((__format__ (__scanf__, 1, 0)));
55extern __ssize_t __getline (char **__lineptr, size_t *__n,
56 FILE *__stream) attribute_hidden;
57extern int __vsscanf (const char *__restrict __s,
58 const char *__restrict __format,
59 __gnuc_va_list __arg)
60 __attribute__ ((__format__ (__scanf__, 2, 0)));
61
62extern int __sprintf_chk (char *, int, size_t, const char *, ...) __THROW;
63extern int __snprintf_chk (char *, size_t, int, size_t, const char *, ...)
64 __THROW;
65extern int __vsprintf_chk (char *, int, size_t, const char *,
66 __gnuc_va_list) __THROW;
67extern int __vsnprintf_chk (char *, size_t, int, size_t, const char *,
68 __gnuc_va_list) __THROW;
69extern int __printf_chk (int, const char *, ...);
70extern int __fprintf_chk (FILE *, int, const char *, ...);
71extern int __vprintf_chk (int, const char *, __gnuc_va_list);
72extern int __vfprintf_chk (FILE *, int, const char *, __gnuc_va_list);
73extern char *__fgets_unlocked_chk (char *buf, size_t size, int n, FILE *fp);
74extern char *__fgets_chk (char *buf, size_t size, int n, FILE *fp);
75extern int __asprintf_chk (char **, int, const char *, ...) __THROW;
76extern int __vasprintf_chk (char **, int, const char *, __gnuc_va_list) __THROW;
77extern int __dprintf_chk (int, int, const char *, ...);
78extern int __vdprintf_chk (int, int, const char *, __gnuc_va_list);
79extern int __obstack_printf_chk (struct obstack *, int, const char *, ...)
80 __THROW;
81extern int __obstack_vprintf_chk (struct obstack *, int, const char *,
82 __gnuc_va_list) __THROW;
83
84extern int __isoc99_fscanf (FILE *__restrict __stream,
85 const char *__restrict __format, ...) __wur;
86extern int __isoc99_scanf (const char *__restrict __format, ...) __wur;
87extern int __isoc99_sscanf (const char *__restrict __s,
88 const char *__restrict __format, ...) __THROW;
89extern int __isoc99_vfscanf (FILE *__restrict __s,
90 const char *__restrict __format,
91 __gnuc_va_list __arg) __wur;
92extern int __isoc99_vscanf (const char *__restrict __format,
93 __gnuc_va_list __arg) __wur;
94extern int __isoc99_vsscanf (const char *__restrict __s,
95 const char *__restrict __format,
96 __gnuc_va_list __arg) __THROW;
97
98libc_hidden_proto (__isoc99_sscanf)
99libc_hidden_proto (__isoc99_vsscanf)
100libc_hidden_proto (__isoc99_vfscanf)
101
102/* Internal uses of sscanf should call the C99-compliant version.
103 Unfortunately, symbol redirection is not transitive, so the
104 __REDIRECT in the public header does not link up with the above
105 libc_hidden_proto. Bridge the gap with a macro. */
106# if !__GLIBC_USE (DEPRECATED_SCANF)
107# undef sscanf
108# define sscanf __isoc99_sscanf
109# endif
110
111# if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 && IS_IN (libc)
112/* These are implemented as redirects to other public API.
113 Therefore, the usual redirection fails to avoid PLT. */
114extern __typeof (__isoc99_sscanf) ___ieee128_isoc99_sscanf __THROW;
115extern __typeof (__isoc99_vsscanf) ___ieee128_isoc99_vsscanf __THROW;
116extern __typeof (__isoc99_vfscanf) ___ieee128_isoc99_vfscanf __THROW;
117libc_hidden_proto (___ieee128_isoc99_sscanf)
118libc_hidden_proto (___ieee128_isoc99_vsscanf)
119libc_hidden_proto (___ieee128_isoc99_vfscanf)
120#define __isoc99_sscanf ___ieee128_isoc99_sscanf
121#define __isoc99_vsscanf ___ieee128_isoc99_vsscanf
122#define __isoc99_vfscanf ___ieee128_isoc99_vfscanf
123# endif
124
125/* Prototypes for compatibility functions. */
126extern FILE *__new_tmpfile (void);
127extern FILE *__old_tmpfile (void);
128
129# define __need_size_t
130# include <stddef.h>
131
132# include <bits/types/wint_t.h>
133
134/* Generate a unique file name (and possibly open it). */
135extern int __path_search (char *__tmpl, size_t __tmpl_len,
136 const char *__dir, const char *__pfx,
137 int __try_tempdir) attribute_hidden;
138
139extern int __gen_tempname (char *__tmpl, int __suffixlen, int __flags,
140 int __kind) attribute_hidden;
141/* The __kind argument to __gen_tempname may be one of: */
142# define __GT_FILE 0 /* create a file */
143# define __GT_DIR 1 /* create a directory */
144# define __GT_NOCREATE 2 /* just find a name not currently in use */
145
146enum __libc_message_action
147{
148 do_message = 0, /* Print message. */
149 do_abort = 1 << 0, /* Abort. */
150};
151
152/* Print out MESSAGE (which should end with a newline) on the error output
153 and abort. */
154extern void __libc_fatal (const char *__message)
155 __attribute__ ((__noreturn__));
156extern void __libc_message (enum __libc_message_action action,
157 const char *__fnt, ...) attribute_hidden;
158extern void __fortify_fail (const char *msg) __attribute__ ((__noreturn__));
159libc_hidden_proto (__fortify_fail)
160
161/* Acquire ownership of STREAM. */
162extern void __flockfile (FILE *__stream) attribute_hidden;
163
164/* Relinquish the ownership granted for STREAM. */
165extern void __funlockfile (FILE *__stream) attribute_hidden;
166
167/* Try to acquire ownership of STREAM but do not block if it is not
168 possible. */
169extern int __ftrylockfile (FILE *__stream);
170
171extern int __getc_unlocked (FILE *__fp) attribute_hidden;
172extern wint_t __getwc_unlocked (FILE *__fp);
173
174extern int __fxprintf (FILE *__fp, const char *__fmt, ...)
175 __attribute__ ((__format__ (__printf__, 2, 3))) attribute_hidden;
176extern int __fxprintf_nocancel (FILE *__fp, const char *__fmt, ...)
177 __attribute__ ((__format__ (__printf__, 2, 3))) attribute_hidden;
178int __vfxprintf (FILE *__fp, const char *__fmt, __gnuc_va_list,
179 unsigned int)
180 attribute_hidden;
181
182extern const char *const _sys_errlist_internal[] attribute_hidden;
183extern const char *__get_errlist (int) attribute_hidden;
184extern const char *__get_errname (int) attribute_hidden;
185
186libc_hidden_ldbl_proto (__asprintf)
187
188# if IS_IN (libc)
189extern FILE *_IO_new_fopen (const char*, const char*);
190# define fopen(fname, mode) _IO_new_fopen (fname, mode)
191extern FILE *_IO_new_fdopen (int, const char*);
192# define fdopen(fd, mode) _IO_new_fdopen (fd, mode)
193extern int _IO_new_fclose (FILE*);
194# define fclose(fp) _IO_new_fclose (fp)
195extern int _IO_fputs (const char*, FILE*);
196libc_hidden_proto (_IO_fputs)
197/* The compiler may optimize calls to fprintf into calls to fputs.
198 Use libc_hidden_proto to ensure that those calls, not redirected by
199 the fputs macro, also do not go through the PLT. */
200libc_hidden_proto (fputs)
201# define fputs(str, fp) _IO_fputs (str, fp)
202extern int _IO_new_fsetpos (FILE *, const __fpos_t *);
203# define fsetpos(fp, posp) _IO_new_fsetpos (fp, posp)
204extern int _IO_new_fgetpos (FILE *, __fpos_t *);
205# define fgetpos(fp, posp) _IO_new_fgetpos (fp, posp)
206# endif
207
208extern __typeof (dprintf) __dprintf
209 __attribute__ ((__format__ (__printf__, 2, 3)));
210stdio_hidden_ldbl_proto (__, dprintf)
211libc_hidden_ldbl_proto (dprintf)
212libc_hidden_ldbl_proto (fprintf)
213libc_hidden_ldbl_proto (vfprintf)
214libc_hidden_ldbl_proto (sprintf)
215libc_hidden_proto (ungetc)
216libc_hidden_proto (__getdelim)
217libc_hidden_proto (fwrite)
218libc_hidden_proto (perror)
219libc_hidden_proto (remove)
220libc_hidden_proto (rewind)
221libc_hidden_proto (fileno)
222extern __typeof (fileno) __fileno;
223libc_hidden_proto (__fileno)
224libc_hidden_proto (fwrite)
225libc_hidden_proto (fseek)
226extern __typeof (ftello) __ftello;
227libc_hidden_proto (__ftello)
228extern __typeof (fseeko64) __fseeko64;
229libc_hidden_proto (__fseeko64)
230extern __typeof (ftello64) __ftello64;
231libc_hidden_proto (__ftello64)
232libc_hidden_proto (fflush)
233libc_hidden_proto (fflush_unlocked)
234extern __typeof (fflush_unlocked) __fflush_unlocked;
235libc_hidden_proto (__fflush_unlocked)
236extern __typeof (fread_unlocked) __fread_unlocked;
237libc_hidden_proto (__fread_unlocked)
238libc_hidden_proto (fwrite_unlocked)
239libc_hidden_proto (fgets_unlocked)
240extern __typeof (fgets_unlocked) __fgets_unlocked;
241libc_hidden_proto (__fgets_unlocked)
242libc_hidden_proto (fputs_unlocked)
243extern __typeof (fputs_unlocked) __fputs_unlocked;
244libc_hidden_proto (__fputs_unlocked)
245libc_hidden_proto (feof_unlocked)
246extern __typeof (feof_unlocked) __feof_unlocked attribute_hidden;
247libc_hidden_proto (ferror_unlocked)
248extern __typeof (ferror_unlocked) __ferror_unlocked attribute_hidden;
249libc_hidden_proto (getc_unlocked)
250libc_hidden_proto (fputc_unlocked)
251libc_hidden_proto (putc_unlocked)
252extern __typeof (putc_unlocked) __putc_unlocked attribute_hidden;
253libc_hidden_proto (fmemopen)
254/* The prototype needs repeating instead of using __typeof to use
255 __THROW in C++ tests. */
256extern FILE *__open_memstream (char **, size_t *) __THROW __wur;
257libc_hidden_proto (__open_memstream)
258libc_hidden_proto (__libc_fatal)
259rtld_hidden_proto (__libc_fatal)
260libc_hidden_proto (__vsprintf_chk)
261
262extern FILE * __fmemopen (void *buf, size_t len, const char *mode);
263libc_hidden_proto (__fmemopen)
264
265extern int __gen_tempfd (int flags);
266libc_hidden_proto (__gen_tempfd)
267
268# ifdef __USE_EXTERN_INLINES
269__extern_inline int
270__NTH (__feof_unlocked (FILE *__stream))
271{
272 return __feof_unlocked_body (__stream);
273}
274
275__extern_inline int
276__NTH (__ferror_unlocked (FILE *__stream))
277{
278 return __ferror_unlocked_body (__stream);
279}
280
281__extern_inline int
282__getc_unlocked (FILE *__fp)
283{
284 return __getc_unlocked_body (__fp);
285}
286
287__extern_inline int
288__putc_unlocked (int __c, FILE *__stream)
289{
290 return __putc_unlocked_body (__c, __stream);
291}
292# endif
293
294extern __typeof (renameat) __renameat;
295libc_hidden_proto (__renameat)
296extern __typeof (renameat2) __renameat2;
297libc_hidden_proto (__renameat2)
298
299# endif /* not _ISOMAC */
300#endif /* stdio.h */
301

source code of glibc/include/stdio.h