]> git.proxmox.com Git - wasi-libc.git/blame - libc-top-half/musl/include/stdio.h
bump version to 0.0~git20240411.9e8c542-3~bpo12+pve1
[wasi-libc.git] / libc-top-half / musl / include / stdio.h
CommitLineData
320054e8
DG
1#ifndef _STDIO_H
2#define _STDIO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_FILE
11#define __NEED___isoc_va_list
12#define __NEED_size_t
13
f41256b6
DG
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
17#endif
18#endif
19
320054e8
DG
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
24#define __NEED_off_t
25#define __NEED_va_list
26#endif
27
28#include <bits/alltypes.h>
29
e5f14be3 30#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
5d8a1409
DG
31#if __cplusplus >= 201103L
32#define NULL nullptr
33#elif defined(__cplusplus)
320054e8
DG
34#define NULL 0L
35#else
36#define NULL ((void*)0)
37#endif
38#else
39#define __need_NULL
40#include <stddef.h>
41#endif
42
43#undef EOF
44#define EOF (-1)
45
e5f14be3 46#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
320054e8
DG
47#undef SEEK_SET
48#undef SEEK_CUR
49#undef SEEK_END
50#define SEEK_SET 0
51#define SEEK_CUR 1
52#define SEEK_END 2
53#else
60cba39d 54#include <__seek.h>
320054e8
DG
55#endif
56
57#define _IOFBF 0
58#define _IOLBF 1
59#define _IONBF 2
60
61#define BUFSIZ 1024
62#define FILENAME_MAX 4096
63#define FOPEN_MAX 1000
9f0d8e85 64#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
320054e8
DG
65#define TMP_MAX 10000
66#define L_tmpnam 20
67#endif
68
69typedef union _G_fpos64_t {
70 char __opaque[16];
71 long long __lldata;
72 double __align;
73} fpos_t;
74
75extern FILE *const stdin;
76extern FILE *const stdout;
77extern FILE *const stderr;
78
79#define stdin (stdin)
80#define stdout (stdout)
81#define stderr (stderr)
82
83FILE *fopen(const char *__restrict, const char *__restrict);
84FILE *freopen(const char *__restrict, const char *__restrict, FILE *__restrict);
85int fclose(FILE *);
86
87int remove(const char *);
88int rename(const char *, const char *);
89
90int feof(FILE *);
91int ferror(FILE *);
92int fflush(FILE *);
93void clearerr(FILE *);
94
95int fseek(FILE *, long, int);
96long ftell(FILE *);
97void rewind(FILE *);
98
99int fgetpos(FILE *__restrict, fpos_t *__restrict);
100int fsetpos(FILE *, const fpos_t *);
101
102size_t fread(void *__restrict, size_t, size_t, FILE *__restrict);
103size_t fwrite(const void *__restrict, size_t, size_t, FILE *__restrict);
104
105int fgetc(FILE *);
106int getc(FILE *);
107int getchar(void);
108int ungetc(int, FILE *);
109
110int fputc(int, FILE *);
111int putc(int, FILE *);
112int putchar(int);
113
114char *fgets(char *__restrict, int, FILE *__restrict);
115#if __STDC_VERSION__ < 201112L
e5f14be3 116#ifdef __wasilibc_unmodified_upstream /* gets is obsolete */
320054e8
DG
117char *gets(char *);
118#else
119char *gets(char *) __attribute__((__deprecated__("gets is not defined on WASI")));
120#endif
121#endif
122
123int fputs(const char *__restrict, FILE *__restrict);
124int puts(const char *);
125
126int printf(const char *__restrict, ...);
127int fprintf(FILE *__restrict, const char *__restrict, ...);
128int sprintf(char *__restrict, const char *__restrict, ...);
129int snprintf(char *__restrict, size_t, const char *__restrict, ...);
130
131int vprintf(const char *__restrict, __isoc_va_list);
132int vfprintf(FILE *__restrict, const char *__restrict, __isoc_va_list);
133int vsprintf(char *__restrict, const char *__restrict, __isoc_va_list);
134int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list);
135
136int scanf(const char *__restrict, ...);
137int fscanf(FILE *__restrict, const char *__restrict, ...);
138int sscanf(const char *__restrict, const char *__restrict, ...);
139int vscanf(const char *__restrict, __isoc_va_list);
140int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list);
141int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list);
142
143void perror(const char *);
144
145int setvbuf(FILE *__restrict, char *__restrict, int, size_t);
146void setbuf(FILE *__restrict, char *__restrict);
147
9f0d8e85 148#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
320054e8
DG
149char *tmpnam(char *);
150FILE *tmpfile(void);
151#else
152char *tmpnam(char *) __attribute__((__deprecated__("tmpnam is not defined on WASI")));
153FILE *tmpfile(void) __attribute__((__deprecated__("tmpfile is not defined on WASI")));
154#endif
155
156#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
157 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
158 || defined(_BSD_SOURCE)
159FILE *fmemopen(void *__restrict, size_t, const char *__restrict);
160FILE *open_memstream(char **, size_t *);
161FILE *fdopen(int, const char *);
eee6ee75 162#ifdef __wasilibc_unmodified_upstream /* WASI has no popen */
320054e8
DG
163FILE *popen(const char *, const char *);
164int pclose(FILE *);
eee6ee75 165#endif
320054e8
DG
166int fileno(FILE *);
167int fseeko(FILE *, off_t, int);
168off_t ftello(FILE *);
169int dprintf(int, const char *__restrict, ...);
170int vdprintf(int, const char *__restrict, __isoc_va_list);
24f6fe1c 171#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
320054e8
DG
172void flockfile(FILE *);
173int ftrylockfile(FILE *);
174void funlockfile(FILE *);
24f6fe1c 175#endif
320054e8
DG
176int getc_unlocked(FILE *);
177int getchar_unlocked(void);
178int putc_unlocked(int, FILE *);
179int putchar_unlocked(int);
180ssize_t getdelim(char **__restrict, size_t *__restrict, int, FILE *__restrict);
181ssize_t getline(char **__restrict, size_t *__restrict, FILE *__restrict);
182int renameat(int, const char *, int, const char *);
183char *ctermid(char *);
184#define L_ctermid 20
185#endif
186
187
9f0d8e85 188#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
320054e8
DG
189#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
190 || defined(_BSD_SOURCE)
191#define P_tmpdir "/tmp"
192char *tempnam(const char *, const char *);
193#endif
194#endif
195
196#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
197#define L_cuserid 20
198char *cuserid(char *);
199void setlinebuf(FILE *);
200void setbuffer(FILE *, char *, size_t);
201int fgetc_unlocked(FILE *);
202int fputc_unlocked(int, FILE *);
203int fflush_unlocked(FILE *);
204size_t fread_unlocked(void *, size_t, size_t, FILE *);
205size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
206void clearerr_unlocked(FILE *);
207int feof_unlocked(FILE *);
208int ferror_unlocked(FILE *);
209int fileno_unlocked(FILE *);
210int getw(FILE *);
211int putw(int, FILE *);
212char *fgetln(FILE *, size_t *);
213int asprintf(char **, const char *, ...);
214int vasprintf(char **, const char *, __isoc_va_list);
215#endif
216
217#ifdef _GNU_SOURCE
218char *fgets_unlocked(char *, int, FILE *);
219int fputs_unlocked(const char *, FILE *);
220
221typedef ssize_t (cookie_read_function_t)(void *, char *, size_t);
222typedef ssize_t (cookie_write_function_t)(void *, const char *, size_t);
223typedef int (cookie_seek_function_t)(void *, off_t *, int);
224typedef int (cookie_close_function_t)(void *);
225
226typedef 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;
232
233FILE *fopencookie(void *, const char *, cookie_io_functions_t);
234#endif
235
236#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
9f0d8e85 237#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
320054e8 238#define tmpfile64 tmpfile
9f0d8e85 239#endif
320054e8
DG
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
248#endif
249
250#ifdef __cplusplus
251}
252#endif
253
254#endif