11 #define __NEED___isoc_va_list
14 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
15 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
16 || defined(_BSD_SOURCE)
17 #define __NEED_ssize_t
19 #define __NEED_va_list
22 #include <bits/alltypes.h>
24 #ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
28 #define NULL ((void*)0)
38 #ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
46 #include <__header_unistd.h>
54 #define FILENAME_MAX 4096
55 #define FOPEN_MAX 1000
56 #ifdef __wasilibc_unmodified_upstream /* WASI has no tmpnam */
61 typedef union _G_fpos64_t
{
67 extern FILE *const stdin
;
68 extern FILE *const stdout
;
69 extern FILE *const stderr
;
72 #define stdout (stdout)
73 #define stderr (stderr)
75 FILE *fopen(const char *__restrict
, const char *__restrict
);
76 FILE *freopen(const char *__restrict
, const char *__restrict
, FILE *__restrict
);
79 int remove(const char *);
80 int rename(const char *, const char *);
85 void clearerr(FILE *);
87 int fseek(FILE *, long, int);
91 int fgetpos(FILE *__restrict
, fpos_t *__restrict
);
92 int fsetpos(FILE *, const fpos_t *);
94 size_t fread(void *__restrict
, size_t, size_t, FILE *__restrict
);
95 size_t fwrite(const void *__restrict
, size_t, size_t, FILE *__restrict
);
100 int ungetc(int, FILE *);
102 int fputc(int, FILE *);
103 int putc(int, FILE *);
106 char *fgets(char *__restrict
, int, FILE *__restrict
);
107 #if __STDC_VERSION__ < 201112L
108 #ifdef __wasilibc_unmodified_upstream /* gets is obsolete */
111 char *gets(char *) __attribute__((__deprecated__("gets is not defined on WASI")));
115 int fputs(const char *__restrict
, FILE *__restrict
);
116 int puts(const char *);
118 int printf(const char *__restrict
, ...);
119 int fprintf(FILE *__restrict
, const char *__restrict
, ...);
120 int sprintf(char *__restrict
, const char *__restrict
, ...);
121 int snprintf(char *__restrict
, size_t, const char *__restrict
, ...);
123 int vprintf(const char *__restrict
, __isoc_va_list
);
124 int vfprintf(FILE *__restrict
, const char *__restrict
, __isoc_va_list
);
125 int vsprintf(char *__restrict
, const char *__restrict
, __isoc_va_list
);
126 int vsnprintf(char *__restrict
, size_t, const char *__restrict
, __isoc_va_list
);
128 int scanf(const char *__restrict
, ...);
129 int fscanf(FILE *__restrict
, const char *__restrict
, ...);
130 int sscanf(const char *__restrict
, const char *__restrict
, ...);
131 int vscanf(const char *__restrict
, __isoc_va_list
);
132 int vfscanf(FILE *__restrict
, const char *__restrict
, __isoc_va_list
);
133 int vsscanf(const char *__restrict
, const char *__restrict
, __isoc_va_list
);
135 void perror(const char *);
137 int setvbuf(FILE *__restrict
, char *__restrict
, int, size_t);
138 void setbuf(FILE *__restrict
, char *__restrict
);
140 #ifdef __wasilibc_unmodified_upstream /* WASI has no tmpnam or tmpfile */
141 char *tmpnam(char *);
144 char *tmpnam(char *) __attribute__((__deprecated__("tmpnam is not defined on WASI")));
145 FILE *tmpfile(void) __attribute__((__deprecated__("tmpfile is not defined on WASI")));
148 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
149 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
150 || defined(_BSD_SOURCE)
151 FILE *fmemopen(void *__restrict
, size_t, const char *__restrict
);
152 FILE *open_memstream(char **, size_t *);
153 FILE *fdopen(int, const char *);
154 FILE *popen(const char *, const char *);
157 int fseeko(FILE *, off_t
, int);
158 off_t
ftello(FILE *);
159 int dprintf(int, const char *__restrict
, ...);
160 int vdprintf(int, const char *__restrict
, __isoc_va_list
);
161 void flockfile(FILE *);
162 int ftrylockfile(FILE *);
163 void funlockfile(FILE *);
164 int getc_unlocked(FILE *);
165 int getchar_unlocked(void);
166 int putc_unlocked(int, FILE *);
167 int putchar_unlocked(int);
168 ssize_t
getdelim(char **__restrict
, size_t *__restrict
, int, FILE *__restrict
);
169 ssize_t
getline(char **__restrict
, size_t *__restrict
, FILE *__restrict
);
170 int renameat(int, const char *, int, const char *);
171 char *ctermid(char *);
176 #ifdef __wasilibc_unmodified_upstream /* WASI has no tempnam */
177 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
178 || defined(_BSD_SOURCE)
179 #define P_tmpdir "/tmp"
180 char *tempnam(const char *, const char *);
184 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
186 char *cuserid(char *);
187 void setlinebuf(FILE *);
188 void setbuffer(FILE *, char *, size_t);
189 int fgetc_unlocked(FILE *);
190 int fputc_unlocked(int, FILE *);
191 int fflush_unlocked(FILE *);
192 size_t fread_unlocked(void *, size_t, size_t, FILE *);
193 size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
194 void clearerr_unlocked(FILE *);
195 int feof_unlocked(FILE *);
196 int ferror_unlocked(FILE *);
197 int fileno_unlocked(FILE *);
199 int putw(int, FILE *);
200 char *fgetln(FILE *, size_t *);
201 int asprintf(char **, const char *, ...);
202 int vasprintf(char **, const char *, __isoc_va_list
);
206 char *fgets_unlocked(char *, int, FILE *);
207 int fputs_unlocked(const char *, FILE *);
209 typedef ssize_t (cookie_read_function_t
)(void *, char *, size_t);
210 typedef ssize_t (cookie_write_function_t
)(void *, const char *, size_t);
211 typedef int (cookie_seek_function_t
)(void *, off_t
*, int);
212 typedef int (cookie_close_function_t
)(void *);
214 typedef struct _IO_cookie_io_functions_t
{
215 cookie_read_function_t
*read
;
216 cookie_write_function_t
*write
;
217 cookie_seek_function_t
*seek
;
218 cookie_close_function_t
*close
;
219 } cookie_io_functions_t
;
221 FILE *fopencookie(void *, const char *, cookie_io_functions_t
);
224 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
225 #define tmpfile64 tmpfile
226 #define fopen64 fopen
227 #define freopen64 freopen
228 #define fseeko64 fseeko
229 #define ftello64 ftello
230 #define fgetpos64 fgetpos
231 #define fsetpos64 fsetpos
232 #define fpos64_t fpos_t
233 #define off64_t off_t