11 #define __NEED___isoc_va_list
14 #ifdef __wasilibc_unmodified_upstream /* WASI doesn't need to define FILE as a complete type */
15 #if __STDC_VERSION__ < 201112L
16 #define __NEED_struct__IO_FILE
20 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
21 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
22 || defined(_BSD_SOURCE)
23 #define __NEED_ssize_t
25 #define __NEED_va_list
28 #include <bits/alltypes.h>
30 #ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
31 #if __cplusplus >= 201103L
33 #elif defined(__cplusplus)
36 #define NULL ((void*)0)
46 #ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
62 #define FILENAME_MAX 4096
63 #define FOPEN_MAX 1000
64 #ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
69 typedef union _G_fpos64_t
{
75 extern FILE *const stdin
;
76 extern FILE *const stdout
;
77 extern FILE *const stderr
;
80 #define stdout (stdout)
81 #define stderr (stderr)
83 FILE *fopen(const char *__restrict
, const char *__restrict
);
84 FILE *freopen(const char *__restrict
, const char *__restrict
, FILE *__restrict
);
87 int remove(const char *);
88 int rename(const char *, const char *);
93 void clearerr(FILE *);
95 int fseek(FILE *, long, int);
99 int fgetpos(FILE *__restrict
, fpos_t *__restrict
);
100 int fsetpos(FILE *, const fpos_t *);
102 size_t fread(void *__restrict
, size_t, size_t, FILE *__restrict
);
103 size_t fwrite(const void *__restrict
, size_t, size_t, FILE *__restrict
);
108 int ungetc(int, FILE *);
110 int fputc(int, FILE *);
111 int putc(int, FILE *);
114 char *fgets(char *__restrict
, int, FILE *__restrict
);
115 #if __STDC_VERSION__ < 201112L
116 #ifdef __wasilibc_unmodified_upstream /* gets is obsolete */
119 char *gets(char *) __attribute__((__deprecated__("gets is not defined on WASI")));
123 int fputs(const char *__restrict
, FILE *__restrict
);
124 int puts(const char *);
126 int printf(const char *__restrict
, ...);
127 int fprintf(FILE *__restrict
, const char *__restrict
, ...);
128 int sprintf(char *__restrict
, const char *__restrict
, ...);
129 int snprintf(char *__restrict
, size_t, const char *__restrict
, ...);
131 int vprintf(const char *__restrict
, __isoc_va_list
);
132 int vfprintf(FILE *__restrict
, const char *__restrict
, __isoc_va_list
);
133 int vsprintf(char *__restrict
, const char *__restrict
, __isoc_va_list
);
134 int vsnprintf(char *__restrict
, size_t, const char *__restrict
, __isoc_va_list
);
136 int scanf(const char *__restrict
, ...);
137 int fscanf(FILE *__restrict
, const char *__restrict
, ...);
138 int sscanf(const char *__restrict
, const char *__restrict
, ...);
139 int vscanf(const char *__restrict
, __isoc_va_list
);
140 int vfscanf(FILE *__restrict
, const char *__restrict
, __isoc_va_list
);
141 int vsscanf(const char *__restrict
, const char *__restrict
, __isoc_va_list
);
143 void perror(const char *);
145 int setvbuf(FILE *__restrict
, char *__restrict
, int, size_t);
146 void setbuf(FILE *__restrict
, char *__restrict
);
148 #ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
149 char *tmpnam(char *);
152 char *tmpnam(char *) __attribute__((__deprecated__("tmpnam is not defined on WASI")));
153 FILE *tmpfile(void) __attribute__((__deprecated__("tmpfile is not defined on WASI")));
156 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
157 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
158 || defined(_BSD_SOURCE)
159 FILE *fmemopen(void *__restrict
, size_t, const char *__restrict
);
160 FILE *open_memstream(char **, size_t *);
161 FILE *fdopen(int, const char *);
162 #ifdef __wasilibc_unmodified_upstream /* WASI has no popen */
163 FILE *popen(const char *, const char *);
167 int fseeko(FILE *, off_t
, int);
168 off_t
ftello(FILE *);
169 int dprintf(int, const char *__restrict
, ...);
170 int vdprintf(int, const char *__restrict
, __isoc_va_list
);
171 #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
172 void flockfile(FILE *);
173 int ftrylockfile(FILE *);
174 void funlockfile(FILE *);
176 int getc_unlocked(FILE *);
177 int getchar_unlocked(void);
178 int putc_unlocked(int, FILE *);
179 int putchar_unlocked(int);
180 ssize_t
getdelim(char **__restrict
, size_t *__restrict
, int, FILE *__restrict
);
181 ssize_t
getline(char **__restrict
, size_t *__restrict
, FILE *__restrict
);
182 int renameat(int, const char *, int, const char *);
183 char *ctermid(char *);
188 #ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
189 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
190 || defined(_BSD_SOURCE)
191 #define P_tmpdir "/tmp"
192 char *tempnam(const char *, const char *);
196 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
198 char *cuserid(char *);
199 void setlinebuf(FILE *);
200 void setbuffer(FILE *, char *, size_t);
201 int fgetc_unlocked(FILE *);
202 int fputc_unlocked(int, FILE *);
203 int fflush_unlocked(FILE *);
204 size_t fread_unlocked(void *, size_t, size_t, FILE *);
205 size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
206 void clearerr_unlocked(FILE *);
207 int feof_unlocked(FILE *);
208 int ferror_unlocked(FILE *);
209 int fileno_unlocked(FILE *);
211 int putw(int, FILE *);
212 char *fgetln(FILE *, size_t *);
213 int asprintf(char **, const char *, ...);
214 int vasprintf(char **, const char *, __isoc_va_list
);
218 char *fgets_unlocked(char *, int, FILE *);
219 int fputs_unlocked(const char *, FILE *);
221 typedef ssize_t (cookie_read_function_t
)(void *, char *, size_t);
222 typedef ssize_t (cookie_write_function_t
)(void *, const char *, size_t);
223 typedef int (cookie_seek_function_t
)(void *, off_t
*, int);
224 typedef int (cookie_close_function_t
)(void *);
226 typedef struct _IO_cookie_io_functions_t
{
227 cookie_read_function_t
*read
;
228 cookie_write_function_t
*write
;
229 cookie_seek_function_t
*seek
;
230 cookie_close_function_t
*close
;
231 } cookie_io_functions_t
;
233 FILE *fopencookie(void *, const char *, cookie_io_functions_t
);
236 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
237 #ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
238 #define tmpfile64 tmpfile
240 #define fopen64 fopen
241 #define freopen64 freopen
242 #define fseeko64 fseeko
243 #define ftello64 ftello
244 #define fgetpos64 fgetpos
245 #define fsetpos64 fsetpos
246 #define fpos64_t fpos_t
247 #define off64_t off_t