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