]>
Commit | Line | Data |
---|---|---|
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. */ | |
35 | static inline void | |
36 | fseterr_unlocked (FILE *fp) | |
37 | { | |
38 | fp->_flags |= _IO_ERR_SEEN; | |
39 | } | |
40 | ||
41 | extern int __fcloseall (void) attribute_hidden; | |
42 | extern int __snprintf (char *__restrict __s, size_t __maxlen, | |
43 | const char *__restrict __format, ...) | |
44 | __attribute__ ((__format__ (__printf__, 3, 4))); | |
45 | stdio_hidden_ldbl_proto (__, snprintf) | |
46 | ||
47 | extern int __vfscanf (FILE *__restrict __s, | |
48 | const char *__restrict __format, | |
49 | __gnuc_va_list __arg) | |
50 | __attribute__ ((__format__ (__scanf__, 2, 0))); | |
51 | libc_hidden_proto (__vfscanf) | |
52 | extern int __vscanf (const char *__restrict __format, | |
53 | __gnuc_va_list __arg) | |
54 | __attribute__ ((__format__ (__scanf__, 1, 0))); | |
55 | extern __ssize_t __getline (char **__lineptr, size_t *__n, | |
56 | FILE *__stream) attribute_hidden; | |
57 | extern int __vsscanf (const char *__restrict __s, | |
58 | const char *__restrict __format, | |
59 | __gnuc_va_list __arg) | |
60 | __attribute__ ((__format__ (__scanf__, 2, 0))); | |
61 | ||
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 *, | |
66 | __gnuc_va_list) __THROW; | |
67 | extern int __vsnprintf_chk (char *, size_t, int, size_t, const char *, | |
68 | __gnuc_va_list) __THROW; | |
69 | extern int __printf_chk (int, const char *, ...); | |
70 | extern int __fprintf_chk (FILE *, int, const char *, ...); | |
71 | extern int __vprintf_chk (int, const char *, __gnuc_va_list); | |
72 | extern int __vfprintf_chk (FILE *, int, const char *, __gnuc_va_list); | |
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); | |
75 | extern int __asprintf_chk (char **, int, const char *, ...) __THROW; | |
76 | extern int __vasprintf_chk (char **, int, const char *, __gnuc_va_list) __THROW; | |
77 | extern int __dprintf_chk (int, int, const char *, ...); | |
78 | extern int __vdprintf_chk (int, int, const char *, __gnuc_va_list); | |
79 | extern int __obstack_printf_chk (struct obstack *, int, const char *, ...) | |
80 | __THROW; | |
81 | extern int __obstack_vprintf_chk (struct obstack *, int, const char *, | |
82 | __gnuc_va_list) __THROW; | |
83 | ||
84 | extern int __isoc99_fscanf (FILE *__restrict __stream, | |
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; | |
89 | extern int __isoc99_vfscanf (FILE *__restrict __s, | |
90 | const char *__restrict __format, | |
91 | __gnuc_va_list __arg) __wur; | |
92 | extern int __isoc99_vscanf (const char *__restrict __format, | |
93 | __gnuc_va_list __arg) __wur; | |
94 | extern int __isoc99_vsscanf (const char *__restrict __s, | |
95 | const char *__restrict __format, | |
96 | __gnuc_va_list __arg) __THROW; | |
97 | extern int __isoc23_fscanf (FILE *__restrict __stream, | |
98 | const char *__restrict __format, ...) __wur; | |
99 | extern int __isoc23_scanf (const char *__restrict __format, ...) __wur; | |
100 | extern int __isoc23_sscanf (const char *__restrict __s, | |
101 | const char *__restrict __format, ...) __THROW; | |
102 | extern int __isoc23_vfscanf (FILE *__restrict __s, | |
103 | const char *__restrict __format, | |
104 | __gnuc_va_list __arg) __wur; | |
105 | extern int __isoc23_vscanf (const char *__restrict __format, | |
106 | __gnuc_va_list __arg) __wur; | |
107 | extern int __isoc23_vsscanf (const char *__restrict __s, | |
108 | const char *__restrict __format, | |
109 | __gnuc_va_list __arg) __THROW; | |
110 | ||
111 | libc_hidden_proto (__isoc99_sscanf) | |
112 | libc_hidden_proto (__isoc99_vsscanf) | |
113 | libc_hidden_proto (__isoc99_vfscanf) | |
114 | libc_hidden_proto (__isoc23_sscanf) | |
115 | libc_hidden_proto (__isoc23_vsscanf) | |
116 | libc_hidden_proto (__isoc23_vfscanf) | |
117 | ||
118 | /* Internal uses of sscanf should call the C23-compliant version. | |
119 | Unfortunately, symbol redirection is not transitive, so the | |
120 | __REDIRECT in the public header does not link up with the above | |
121 | libc_hidden_proto. Bridge the gap with a macro. */ | |
122 | # if !__GLIBC_USE (DEPRECATED_SCANF) | |
123 | # undef sscanf | |
124 | # define sscanf __isoc23_sscanf | |
125 | # endif | |
126 | ||
127 | # if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 && IS_IN (libc) | |
128 | /* These are implemented as redirects to other public API. | |
129 | Therefore, the usual redirection fails to avoid PLT. */ | |
130 | extern __typeof (__isoc99_sscanf) ___ieee128_isoc99_sscanf __THROW; | |
131 | extern __typeof (__isoc99_vsscanf) ___ieee128_isoc99_vsscanf __THROW; | |
132 | extern __typeof (__isoc99_vfscanf) ___ieee128_isoc99_vfscanf __THROW; | |
133 | extern __typeof (__isoc23_sscanf) ___ieee128_isoc23_sscanf __THROW; | |
134 | extern __typeof (__isoc23_vsscanf) ___ieee128_isoc23_vsscanf __THROW; | |
135 | extern __typeof (__isoc23_vfscanf) ___ieee128_isoc23_vfscanf __THROW; | |
136 | libc_hidden_proto (___ieee128_isoc99_sscanf) | |
137 | libc_hidden_proto (___ieee128_isoc99_vsscanf) | |
138 | libc_hidden_proto (___ieee128_isoc99_vfscanf) | |
139 | libc_hidden_proto (___ieee128_isoc23_sscanf) | |
140 | libc_hidden_proto (___ieee128_isoc23_vsscanf) | |
141 | libc_hidden_proto (___ieee128_isoc23_vfscanf) | |
142 | #define __isoc99_sscanf ___ieee128_isoc99_sscanf | |
143 | #define __isoc99_vsscanf ___ieee128_isoc99_vsscanf | |
144 | #define __isoc99_vfscanf ___ieee128_isoc99_vfscanf | |
145 | #define __isoc23_sscanf ___ieee128_isoc23_sscanf | |
146 | #define __isoc23_vsscanf ___ieee128_isoc23_vsscanf | |
147 | #define __isoc23_vfscanf ___ieee128_isoc23_vfscanf | |
148 | # endif | |
149 | ||
150 | /* Prototypes for compatibility functions. */ | |
151 | extern FILE *__new_tmpfile (void); | |
152 | extern FILE *__old_tmpfile (void); | |
153 | ||
154 | # define __need_size_t | |
155 | # include <stddef.h> | |
156 | ||
157 | # include <bits/types/wint_t.h> | |
158 | ||
159 | extern int __gen_tempname (char *__tmpl, int __suffixlen, int __flags, | |
160 | int __kind) attribute_hidden; | |
161 | /* The __kind argument to __gen_tempname may be one of: */ | |
162 | # define __GT_FILE 0 /* create a file */ | |
163 | # define __GT_DIR 1 /* create a directory */ | |
164 | # define __GT_NOCREATE 2 /* just find a name not currently in use */ | |
165 | ||
166 | /* Print out MESSAGE (which should end with a newline) on the error output | |
167 | and abort. */ | |
168 | extern void __libc_fatal (const char *__message) | |
169 | __attribute__ ((__noreturn__)); | |
170 | extern void __fortify_fail (const char *msg) __attribute__ ((__noreturn__)); | |
171 | libc_hidden_proto (__fortify_fail) | |
172 | ||
173 | /* The maximum number of varargs allowed in a __libc_message format string */ | |
174 | #define LIBC_MESSAGE_MAX_ARGS 4 | |
175 | ||
176 | #define IOVEC_MAX_ERR_MSG "Fatal glibc error: Internal " \ | |
177 | "__libc_message error. Too many arguments.\n" | |
178 | #define IOVEC_MAX_ERR_MSG_LEN (sizeof (IOVEC_MAX_ERR_MSG) - 1) | |
179 | ||
180 | _Noreturn void __libc_message_impl (const char *__fnt, ...) attribute_hidden | |
181 | __attribute__ ((__format__ (__printf__, 1, 2))); | |
182 | ||
183 | #define __libc_message0(fmt) \ | |
184 | __libc_message_impl (fmt) | |
185 | #define __libc_message1(fmt, a1) \ | |
186 | __libc_message_impl (fmt, a1) | |
187 | #define __libc_message2(fmt, a1, a2) \ | |
188 | __libc_message_impl (fmt, a1, a2) | |
189 | #define __libc_message3(fmt, a1, a2, a3) \ | |
190 | __libc_message_impl (fmt, a1, a2, a3) | |
191 | #define __libc_message4(fmt, a1, a2, a3, a4) \ | |
192 | __libc_message_impl (fmt, a1, a2, a3, a4) | |
193 | ||
194 | #define __libc_message_concat_x(a,b) a##b | |
195 | #define __libc_message_concat(a,b) __libc_message_concat_x (a, b) | |
196 | ||
197 | #define __libc_message_nargs_x(a0,a1,a2,a3,a4,a5,a6,...) a6 | |
198 | #define __libc_message_nargs(b, ...) \ | |
199 | __libc_message_nargs_x (__VA_ARGS__,6,5,4,3,2,1,0,) | |
200 | #define __libc_message_disp(b, ...) \ | |
201 | __libc_message_concat (b, __libc_message_nargs (__VA_ARGS__))(__VA_ARGS__) | |
202 | #define __libc_message(...) \ | |
203 | __libc_message_disp (__libc_message, __VA_ARGS__) | |
204 | ||
205 | /* Acquire ownership of STREAM. */ | |
206 | extern void __flockfile (FILE *__stream) attribute_hidden; | |
207 | ||
208 | /* Relinquish the ownership granted for STREAM. */ | |
209 | extern void __funlockfile (FILE *__stream) attribute_hidden; | |
210 | ||
211 | /* Try to acquire ownership of STREAM but do not block if it is not | |
212 | possible. */ | |
213 | extern int __ftrylockfile (FILE *__stream); | |
214 | ||
215 | extern int __getc_unlocked (FILE *__fp) attribute_hidden; | |
216 | extern wint_t __getwc_unlocked (FILE *__fp); | |
217 | ||
218 | extern int __fxprintf (FILE *__fp, const char *__fmt, ...) | |
219 | __attribute__ ((__format__ (__printf__, 2, 3))) attribute_hidden; | |
220 | extern int __fxprintf_nocancel (FILE *__fp, const char *__fmt, ...) | |
221 | __attribute__ ((__format__ (__printf__, 2, 3))) attribute_hidden; | |
222 | int __vfxprintf (FILE *__fp, const char *__fmt, __gnuc_va_list, | |
223 | unsigned int) | |
224 | attribute_hidden; | |
225 | ||
226 | extern const char *const _sys_errlist_internal[] attribute_hidden; | |
227 | extern const size_t _sys_errlist_internal_len attribute_hidden; | |
228 | extern const char *__get_errlist (int) attribute_hidden; | |
229 | extern const char *__get_errname (int) attribute_hidden; | |
230 | ||
231 | libc_hidden_ldbl_proto (__asprintf) | |
232 | ||
233 | # if IS_IN (libc) | |
234 | extern FILE *_IO_new_fopen (const char*, const char*); | |
235 | # define fopen(fname, mode) _IO_new_fopen (fname, mode) | |
236 | extern FILE *_IO_new_fdopen (int, const char*); | |
237 | # define fdopen(fd, mode) _IO_new_fdopen (fd, mode) | |
238 | extern int _IO_new_fclose (FILE*); | |
239 | # define fclose(fp) _IO_new_fclose (fp) | |
240 | extern int _IO_fputs (const char*, FILE*); | |
241 | libc_hidden_proto (_IO_fputs) | |
242 | /* The compiler may optimize calls to fprintf into calls to fputs. | |
243 | Use libc_hidden_proto to ensure that those calls, not redirected by | |
244 | the fputs macro, also do not go through the PLT. */ | |
245 | libc_hidden_proto (fputs) | |
246 | # define fputs(str, fp) _IO_fputs (str, fp) | |
247 | extern int _IO_new_fsetpos (FILE *, const __fpos_t *); | |
248 | # define fsetpos(fp, posp) _IO_new_fsetpos (fp, posp) | |
249 | extern int _IO_new_fgetpos (FILE *, __fpos_t *); | |
250 | # define fgetpos(fp, posp) _IO_new_fgetpos (fp, posp) | |
251 | # endif | |
252 | ||
253 | extern __typeof (dprintf) __dprintf | |
254 | __attribute__ ((__format__ (__printf__, 2, 3))); | |
255 | stdio_hidden_ldbl_proto (__, dprintf) | |
256 | libc_hidden_ldbl_proto (dprintf) | |
257 | libc_hidden_ldbl_proto (fprintf) | |
258 | libc_hidden_ldbl_proto (vfprintf) | |
259 | libc_hidden_ldbl_proto (sprintf) | |
260 | libc_hidden_proto (ungetc) | |
261 | libc_hidden_proto (__getdelim) | |
262 | libc_hidden_proto (fwrite) | |
263 | libc_hidden_proto (perror) | |
264 | libc_hidden_proto (remove) | |
265 | libc_hidden_proto (rewind) | |
266 | libc_hidden_proto (fileno) | |
267 | extern __typeof (fileno) __fileno; | |
268 | libc_hidden_proto (__fileno) | |
269 | libc_hidden_proto (fwrite) | |
270 | libc_hidden_proto (fseek) | |
271 | extern __typeof (ftello) __ftello; | |
272 | libc_hidden_proto (__ftello) | |
273 | extern __typeof (fseeko64) __fseeko64; | |
274 | libc_hidden_proto (__fseeko64) | |
275 | extern __typeof (ftello64) __ftello64; | |
276 | libc_hidden_proto (__ftello64) | |
277 | libc_hidden_proto (fflush) | |
278 | libc_hidden_proto (fflush_unlocked) | |
279 | extern __typeof (fflush_unlocked) __fflush_unlocked; | |
280 | libc_hidden_proto (__fflush_unlocked) | |
281 | extern __typeof (fread_unlocked) __fread_unlocked; | |
282 | libc_hidden_proto (__fread_unlocked) | |
283 | libc_hidden_proto (fwrite_unlocked) | |
284 | libc_hidden_proto (fgets_unlocked) | |
285 | extern __typeof (fgets_unlocked) __fgets_unlocked; | |
286 | libc_hidden_proto (__fgets_unlocked) | |
287 | libc_hidden_proto (fputs_unlocked) | |
288 | extern __typeof (fputs_unlocked) __fputs_unlocked; | |
289 | libc_hidden_proto (__fputs_unlocked) | |
290 | libc_hidden_proto (feof_unlocked) | |
291 | extern __typeof (feof_unlocked) __feof_unlocked attribute_hidden; | |
292 | libc_hidden_proto (ferror_unlocked) | |
293 | extern __typeof (ferror_unlocked) __ferror_unlocked attribute_hidden; | |
294 | libc_hidden_proto (getc_unlocked) | |
295 | libc_hidden_proto (fputc_unlocked) | |
296 | libc_hidden_proto (putc_unlocked) | |
297 | extern __typeof (putc_unlocked) __putc_unlocked attribute_hidden; | |
298 | libc_hidden_proto (fmemopen) | |
299 | /* The prototype needs repeating instead of using __typeof to use | |
300 | __THROW in C++ tests. */ | |
301 | extern FILE *__open_memstream (char **, size_t *) __THROW __wur; | |
302 | libc_hidden_proto (__open_memstream) | |
303 | libc_hidden_proto (__libc_fatal) | |
304 | rtld_hidden_proto (__libc_fatal) | |
305 | ||
306 | libc_hidden_proto (__fgets_unlocked_chk) | |
307 | ||
308 | #if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 | |
309 | libc_hidden_ldbl_proto (__asprintf_chk) | |
310 | #else | |
311 | libc_hidden_proto (__asprintf_chk) | |
312 | #endif | |
313 | ||
314 | libc_hidden_ldbl_proto (__fprintf_chk) | |
315 | libc_hidden_ldbl_proto (__sprintf_chk) | |
316 | libc_hidden_ldbl_proto (__vsprintf_chk) | |
317 | ||
318 | extern FILE * __fmemopen (void *buf, size_t len, const char *mode); | |
319 | libc_hidden_proto (__fmemopen) | |
320 | ||
321 | extern int __gen_tempfd (int flags); | |
322 | libc_hidden_proto (__gen_tempfd) | |
323 | ||
324 | # ifdef __USE_EXTERN_INLINES | |
325 | __extern_inline int | |
326 | __NTH (__feof_unlocked (FILE *__stream)) | |
327 | { | |
328 | return __feof_unlocked_body (__stream); | |
329 | } | |
330 | ||
331 | __extern_inline int | |
332 | __NTH (__ferror_unlocked (FILE *__stream)) | |
333 | { | |
334 | return __ferror_unlocked_body (__stream); | |
335 | } | |
336 | ||
337 | __extern_inline int | |
338 | __getc_unlocked (FILE *__fp) | |
339 | { | |
340 | return __getc_unlocked_body (__fp); | |
341 | } | |
342 | ||
343 | __extern_inline int | |
344 | __putc_unlocked (int __c, FILE *__stream) | |
345 | { | |
346 | return __putc_unlocked_body (__c, __stream); | |
347 | } | |
348 | # endif | |
349 | ||
350 | extern __typeof (renameat) __renameat; | |
351 | libc_hidden_proto (__renameat) | |
352 | extern __typeof (renameat2) __renameat2; | |
353 | libc_hidden_proto (__renameat2) | |
354 | ||
355 | # endif /* not _ISOMAC */ | |
356 | #endif /* stdio.h */ |