]>
Commit | Line | Data |
---|---|---|
6796bc80 | 1 | #ifndef _STDIO_H |
a4fea3f2 ZW |
2 | # if !defined _ISOMAC && defined _IO_MTSAFE_IO |
3 | # include <stdio-lock.h> | |
4 | # endif | |
86005fdb PM |
5 | |
6 | /* Workaround PR90731 with GCC 9 when using ldbl redirects in C++. */ | |
7 | # include <bits/floatn.h> | |
e2239af3 | 8 | # if defined __cplusplus && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 |
86005fdb PM |
9 | # if __GNUC_PREREQ (9, 0) && !__GNUC_PREREQ (9, 3) |
10 | # pragma GCC system_header | |
11 | # endif | |
12 | # endif | |
13 | ||
199fc19d ZW |
14 | # include <libio/stdio.h> |
15 | # ifndef _ISOMAC | |
86005fdb | 16 | |
a4fea3f2 | 17 | # define _LIBC_STDIO_H 1 |
6c6c962a | 18 | # include <libio/libio.h> |
bdbf022d UD |
19 | |
20 | /* Now define the internal interfaces. */ | |
b15549e6 | 21 | |
45ae17dd PM |
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. */ | |
e2239af3 | 25 | # if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 && IS_IN (libc) |
45ae17dd PM |
26 | # define stdio_hidden_ldbl_proto(p, f) \ |
27 | extern __typeof (p ## f) p ## f __asm (__ASMNAME ("___ieee128_" #f)); | |
e2239af3 | 28 | # elif __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 |
45ae17dd PM |
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 | ||
d4b45863 FW |
34 | /* Set the error indicator on FP. */ |
35 | static inline void | |
36 | fseterr_unlocked (FILE *fp) | |
37 | { | |
38 | fp->_flags |= _IO_ERR_SEEN; | |
39 | } | |
40 | ||
2e0a6909 | 41 | extern int __fcloseall (void) attribute_hidden; |
aaa8d85c | 42 | extern int __snprintf (char *__restrict __s, size_t __maxlen, |
a784e502 | 43 | const char *__restrict __format, ...) |
bdbf022d | 44 | __attribute__ ((__format__ (__printf__, 3, 4))); |
45ae17dd PM |
45 | stdio_hidden_ldbl_proto (__, snprintf) |
46 | ||
aaa8d85c | 47 | extern int __vfscanf (FILE *__restrict __s, |
a784e502 | 48 | const char *__restrict __format, |
63fb8f9a | 49 | __gnuc_va_list __arg) |
bdbf022d | 50 | __attribute__ ((__format__ (__scanf__, 2, 0))); |
a20d8dbe | 51 | libc_hidden_proto (__vfscanf) |
a784e502 | 52 | extern int __vscanf (const char *__restrict __format, |
63fb8f9a | 53 | __gnuc_va_list __arg) |
bdbf022d | 54 | __attribute__ ((__format__ (__scanf__, 1, 0))); |
9964a145 ZW |
55 | extern __ssize_t __getline (char **__lineptr, size_t *__n, |
56 | FILE *__stream) attribute_hidden; | |
a784e502 UD |
57 | extern int __vsscanf (const char *__restrict __s, |
58 | const char *__restrict __format, | |
63fb8f9a | 59 | __gnuc_va_list __arg) |
bfce746a | 60 | __attribute__ ((__format__ (__scanf__, 2, 0))); |
bdbf022d | 61 | |
b5cc329c UD |
62 | extern int __sprintf_chk (char *, int, size_t, const char *, ...) __THROW; |
63 | extern int __snprintf_chk (char *, size_t, int, size_t, const char *, ...) | |
64 | __THROW; | |
65 | extern int __vsprintf_chk (char *, int, size_t, const char *, | |
63fb8f9a | 66 | __gnuc_va_list) __THROW; |
b5cc329c | 67 | extern int __vsnprintf_chk (char *, size_t, int, size_t, const char *, |
63fb8f9a | 68 | __gnuc_va_list) __THROW; |
b5cc329c UD |
69 | extern int __printf_chk (int, const char *, ...); |
70 | extern int __fprintf_chk (FILE *, int, const char *, ...); | |
63fb8f9a ZW |
71 | extern int __vprintf_chk (int, const char *, __gnuc_va_list); |
72 | extern int __vfprintf_chk (FILE *, int, const char *, __gnuc_va_list); | |
553cc5f9 UD |
73 | extern char *__fgets_unlocked_chk (char *buf, size_t size, int n, FILE *fp); |
74 | extern char *__fgets_chk (char *buf, size_t size, int n, FILE *fp); | |
dff37515 | 75 | extern int __asprintf_chk (char **, int, const char *, ...) __THROW; |
63fb8f9a | 76 | extern int __vasprintf_chk (char **, int, const char *, __gnuc_va_list) __THROW; |
dff37515 | 77 | extern int __dprintf_chk (int, int, const char *, ...); |
63fb8f9a | 78 | extern int __vdprintf_chk (int, int, const char *, __gnuc_va_list); |
dff37515 UD |
79 | extern int __obstack_printf_chk (struct obstack *, int, const char *, ...) |
80 | __THROW; | |
81 | extern int __obstack_vprintf_chk (struct obstack *, int, const char *, | |
63fb8f9a | 82 | __gnuc_va_list) __THROW; |
b5cc329c | 83 | |
874aa523 | 84 | extern int __isoc99_fscanf (FILE *__restrict __stream, |
a784e502 UD |
85 | const char *__restrict __format, ...) __wur; |
86 | extern int __isoc99_scanf (const char *__restrict __format, ...) __wur; | |
87 | extern int __isoc99_sscanf (const char *__restrict __s, | |
88 | const char *__restrict __format, ...) __THROW; | |
874aa523 | 89 | extern int __isoc99_vfscanf (FILE *__restrict __s, |
a784e502 | 90 | const char *__restrict __format, |
63fb8f9a | 91 | __gnuc_va_list __arg) __wur; |
a784e502 | 92 | extern int __isoc99_vscanf (const char *__restrict __format, |
63fb8f9a | 93 | __gnuc_va_list __arg) __wur; |
a784e502 UD |
94 | extern int __isoc99_vsscanf (const char *__restrict __s, |
95 | const char *__restrict __format, | |
63fb8f9a | 96 | __gnuc_va_list __arg) __THROW; |
45ae17dd | 97 | |
03992356 | 98 | libc_hidden_proto (__isoc99_sscanf) |
874aa523 UD |
99 | libc_hidden_proto (__isoc99_vsscanf) |
100 | libc_hidden_proto (__isoc99_vfscanf) | |
101 | ||
03992356 ZW |
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. */ | |
45ae17dd | 106 | # if !__GLIBC_USE (DEPRECATED_SCANF) |
03992356 ZW |
107 | # undef sscanf |
108 | # define sscanf __isoc99_sscanf | |
109 | # endif | |
110 | ||
e2239af3 | 111 | # if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 && IS_IN (libc) |
45ae17dd PM |
112 | /* These are implemented as redirects to other public API. |
113 | Therefore, the usual redirection fails to avoid PLT. */ | |
114 | extern __typeof (__isoc99_sscanf) ___ieee128_isoc99_sscanf __THROW; | |
115 | extern __typeof (__isoc99_vsscanf) ___ieee128_isoc99_vsscanf __THROW; | |
116 | extern __typeof (__isoc99_vfscanf) ___ieee128_isoc99_vfscanf __THROW; | |
117 | libc_hidden_proto (___ieee128_isoc99_sscanf) | |
118 | libc_hidden_proto (___ieee128_isoc99_vsscanf) | |
119 | libc_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 | ||
ed073f0e AJ |
125 | /* Prototypes for compatibility functions. */ |
126 | extern FILE *__new_tmpfile (void); | |
127 | extern FILE *__old_tmpfile (void); | |
128 | ||
ab58d620 UD |
129 | # define __need_size_t |
130 | # include <stddef.h> | |
199fc19d ZW |
131 | |
132 | # include <bits/types/wint_t.h> | |
133 | ||
992af677 | 134 | /* Generate a unique file name (and possibly open it). */ |
aaa8d85c | 135 | extern int __path_search (char *__tmpl, size_t __tmpl_len, |
a784e502 | 136 | const char *__dir, const char *__pfx, |
2e0a6909 | 137 | int __try_tempdir) attribute_hidden; |
992af677 | 138 | |
7f3146e7 | 139 | extern int __gen_tempname (char *__tmpl, int __suffixlen, int __flags, |
2e0a6909 | 140 | int __kind) attribute_hidden; |
2e65ca2b | 141 | /* The __kind argument to __gen_tempname may be one of: */ |
ab58d620 | 142 | # define __GT_FILE 0 /* create a file */ |
d7e23b02 UD |
143 | # define __GT_DIR 1 /* create a directory */ |
144 | # define __GT_NOCREATE 2 /* just find a name not currently in use */ | |
992af677 | 145 | |
ed421fca L |
146 | enum __libc_message_action |
147 | { | |
148 | do_message = 0, /* Print message. */ | |
149 | do_abort = 1 << 0, /* Abort. */ | |
ed421fca L |
150 | }; |
151 | ||
a6e8926f PP |
152 | /* Print out MESSAGE (which should end with a newline) on the error output |
153 | and abort. */ | |
a784e502 | 154 | extern void __libc_fatal (const char *__message) |
992af677 | 155 | __attribute__ ((__noreturn__)); |
ed421fca | 156 | extern void __libc_message (enum __libc_message_action action, |
2e0a6909 | 157 | const char *__fnt, ...) attribute_hidden; |
1b0bfc69 | 158 | extern void __fortify_fail (const char *msg) __attribute__ ((__noreturn__)); |
3a50811c | 159 | libc_hidden_proto (__fortify_fail) |
992af677 | 160 | |
d4b0774f | 161 | /* Acquire ownership of STREAM. */ |
2e0a6909 | 162 | extern void __flockfile (FILE *__stream) attribute_hidden; |
d4b0774f AJ |
163 | |
164 | /* Relinquish the ownership granted for STREAM. */ | |
2e0a6909 | 165 | extern void __funlockfile (FILE *__stream) attribute_hidden; |
d1646309 | 166 | |
dd040747 AJ |
167 | /* Try to acquire ownership of STREAM but do not block if it is not |
168 | possible. */ | |
169 | extern int __ftrylockfile (FILE *__stream); | |
170 | ||
30ac923d | 171 | extern int __getc_unlocked (FILE *__fp) attribute_hidden; |
03bac9ac AJ |
172 | extern wint_t __getwc_unlocked (FILE *__fp); |
173 | ||
8a259a23 | 174 | extern int __fxprintf (FILE *__fp, const char *__fmt, ...) |
2e0a6909 | 175 | __attribute__ ((__format__ (__printf__, 2, 3))) attribute_hidden; |
544ce845 | 176 | extern int __fxprintf_nocancel (FILE *__fp, const char *__fmt, ...) |
2e0a6909 | 177 | __attribute__ ((__format__ (__printf__, 2, 3))) attribute_hidden; |
f43b8dd5 GG |
178 | int __vfxprintf (FILE *__fp, const char *__fmt, __gnuc_va_list, |
179 | unsigned int) | |
fdb16de3 | 180 | attribute_hidden; |
03bac9ac | 181 | |
a784e502 | 182 | extern const char *const _sys_errlist_internal[] attribute_hidden; |
f13d2601 | 183 | extern const char *__get_errlist (int) attribute_hidden; |
325081b9 | 184 | extern const char *__get_errname (int) attribute_hidden; |
77fe0b9c | 185 | |
45ae17dd PM |
186 | libc_hidden_ldbl_proto (__asprintf) |
187 | ||
4f41c682 | 188 | # if IS_IN (libc) |
9964a145 | 189 | extern FILE *_IO_new_fopen (const char*, const char*); |
3ba06713 | 190 | # define fopen(fname, mode) _IO_new_fopen (fname, mode) |
9964a145 | 191 | extern FILE *_IO_new_fdopen (int, const char*); |
3ba06713 | 192 | # define fdopen(fd, mode) _IO_new_fdopen (fd, mode) |
9964a145 | 193 | extern int _IO_new_fclose (FILE*); |
3ba06713 | 194 | # define fclose(fp) _IO_new_fclose (fp) |
9964a145 | 195 | extern int _IO_fputs (const char*, FILE*); |
3ba06713 | 196 | libc_hidden_proto (_IO_fputs) |
499b3153 JM |
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. */ | |
200 | libc_hidden_proto (fputs) | |
3ba06713 | 201 | # define fputs(str, fp) _IO_fputs (str, fp) |
9964a145 | 202 | extern int _IO_new_fsetpos (FILE *, const __fpos_t *); |
3ba06713 | 203 | # define fsetpos(fp, posp) _IO_new_fsetpos (fp, posp) |
9964a145 | 204 | extern int _IO_new_fgetpos (FILE *, __fpos_t *); |
3ba06713 | 205 | # define fgetpos(fp, posp) _IO_new_fgetpos (fp, posp) |
6b87a564 UD |
206 | # endif |
207 | ||
be7dc2b7 JM |
208 | extern __typeof (dprintf) __dprintf |
209 | __attribute__ ((__format__ (__printf__, 2, 3))); | |
45ae17dd PM |
210 | stdio_hidden_ldbl_proto (__, dprintf) |
211 | libc_hidden_ldbl_proto (dprintf) | |
212 | libc_hidden_ldbl_proto (fprintf) | |
213 | libc_hidden_ldbl_proto (vfprintf) | |
214 | libc_hidden_ldbl_proto (sprintf) | |
b9b91868 RM |
215 | libc_hidden_proto (fwrite) |
216 | libc_hidden_proto (perror) | |
217 | libc_hidden_proto (remove) | |
218 | libc_hidden_proto (rewind) | |
3ba06713 | 219 | libc_hidden_proto (fileno) |
5a6fa4d7 JM |
220 | extern __typeof (fileno) __fileno; |
221 | libc_hidden_proto (__fileno) | |
3ba06713 UD |
222 | libc_hidden_proto (fwrite) |
223 | libc_hidden_proto (fseek) | |
5a6fa4d7 JM |
224 | extern __typeof (ftello) __ftello; |
225 | libc_hidden_proto (__ftello) | |
3f5e3f5d FW |
226 | extern __typeof (fseeko64) __fseeko64; |
227 | libc_hidden_proto (__fseeko64) | |
228 | extern __typeof (ftello64) __ftello64; | |
229 | libc_hidden_proto (__ftello64) | |
5182cbc5 | 230 | libc_hidden_proto (fflush) |
3ba06713 | 231 | libc_hidden_proto (fflush_unlocked) |
eb1fae6a JM |
232 | extern __typeof (fflush_unlocked) __fflush_unlocked; |
233 | libc_hidden_proto (__fflush_unlocked) | |
5a6fa4d7 JM |
234 | extern __typeof (fread_unlocked) __fread_unlocked; |
235 | libc_hidden_proto (__fread_unlocked) | |
3ba06713 UD |
236 | libc_hidden_proto (fwrite_unlocked) |
237 | libc_hidden_proto (fgets_unlocked) | |
c4eae752 JM |
238 | extern __typeof (fgets_unlocked) __fgets_unlocked; |
239 | libc_hidden_proto (__fgets_unlocked) | |
3ba06713 | 240 | libc_hidden_proto (fputs_unlocked) |
3164bf09 JM |
241 | extern __typeof (fputs_unlocked) __fputs_unlocked; |
242 | libc_hidden_proto (__fputs_unlocked) | |
7fc03cf3 JM |
243 | libc_hidden_proto (feof_unlocked) |
244 | extern __typeof (feof_unlocked) __feof_unlocked attribute_hidden; | |
ec481ad8 JM |
245 | libc_hidden_proto (ferror_unlocked) |
246 | extern __typeof (ferror_unlocked) __ferror_unlocked attribute_hidden; | |
30ac923d | 247 | libc_hidden_proto (getc_unlocked) |
039c721a JM |
248 | libc_hidden_proto (fputc_unlocked) |
249 | libc_hidden_proto (putc_unlocked) | |
250 | extern __typeof (putc_unlocked) __putc_unlocked attribute_hidden; | |
a99e59d7 | 251 | libc_hidden_proto (fmemopen) |
711f67a7 | 252 | /* The prototype needs repeating instead of using __typeof to use |
3ac3ff32 | 253 | __THROW in C++ tests. */ |
711f67a7 JM |
254 | extern FILE *__open_memstream (char **, size_t *) __THROW __wur; |
255 | libc_hidden_proto (__open_memstream) | |
9d79e037 | 256 | libc_hidden_proto (__libc_fatal) |
2193ce87 | 257 | rtld_hidden_proto (__libc_fatal) |
b5cc329c | 258 | libc_hidden_proto (__vsprintf_chk) |
b15549e6 | 259 | |
fdb7d390 AZ |
260 | extern FILE * __fmemopen (void *buf, size_t len, const char *mode); |
261 | libc_hidden_proto (__fmemopen) | |
262 | ||
e0d2eb5a AZ |
263 | extern int __gen_tempfd (int flags); |
264 | libc_hidden_proto (__gen_tempfd) | |
265 | ||
7fc03cf3 JM |
266 | # ifdef __USE_EXTERN_INLINES |
267 | __extern_inline int | |
268 | __NTH (__feof_unlocked (FILE *__stream)) | |
269 | { | |
270 | return __feof_unlocked_body (__stream); | |
271 | } | |
ec481ad8 JM |
272 | |
273 | __extern_inline int | |
274 | __NTH (__ferror_unlocked (FILE *__stream)) | |
275 | { | |
276 | return __ferror_unlocked_body (__stream); | |
277 | } | |
30ac923d JM |
278 | |
279 | __extern_inline int | |
280 | __getc_unlocked (FILE *__fp) | |
281 | { | |
282 | return __getc_unlocked_body (__fp); | |
283 | } | |
039c721a JM |
284 | |
285 | __extern_inline int | |
286 | __putc_unlocked (int __c, FILE *__stream) | |
287 | { | |
288 | return __putc_unlocked_body (__c, __stream); | |
289 | } | |
7fc03cf3 JM |
290 | # endif |
291 | ||
d6da5cb6 FW |
292 | extern __typeof (renameat) __renameat; |
293 | libc_hidden_proto (__renameat) | |
1b218417 ST |
294 | extern __typeof (renameat2) __renameat2; |
295 | libc_hidden_proto (__renameat2) | |
d6da5cb6 | 296 | |
199fc19d ZW |
297 | # endif /* not _ISOMAC */ |
298 | #endif /* stdio.h */ |