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