fix constraint violation in ftw
[musl] / include / stdio.h
1 #ifndef _STDIO_H
2 #define _STDIO_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #if __STDC_VERSION__ >= 199901L
9 #define __restrict restrict
10 #elif !defined(__GNUC__)
11 #define __restrict
12 #endif
13
14 #define __NEED_FILE
15 #define __NEED_va_list
16 #define __NEED_size_t
17
18 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
19  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
20  || defined(_BSD_SOURCE)
21 #define __NEED_ssize_t
22 #define __NEED_off_t
23 #endif
24
25 #include <bits/alltypes.h>
26
27 #undef NULL
28 #ifdef __cplusplus
29 #define NULL 0
30 #else
31 #define NULL ((void*)0)
32 #endif
33
34 #undef EOF
35 #define EOF (-1)
36
37 #undef SEEK_SET
38 #undef SEEK_CUR
39 #undef SEEK_END
40 #define SEEK_SET 0
41 #define SEEK_CUR 1
42 #define SEEK_END 2
43
44 #define _IOFBF 0
45 #define _IOLBF 1
46 #define _IONBF 2
47
48 #define BUFSIZ 1024
49 #define FILENAME_MAX 4095
50 #define FOPEN_MAX 1000
51 #define TMP_MAX 10000
52 #define L_tmpnam 20
53
54 typedef union {
55         char __opaque[16];
56         double __align;
57 } fpos_t;
58
59 extern FILE *const stdin;
60 extern FILE *const stdout;
61 extern FILE *const stderr;
62
63 #define stdin  (stdin)
64 #define stdout (stdout)
65 #define stderr (stderr)
66
67 FILE *fopen(const char *__restrict, const char *__restrict);
68 FILE *freopen(const char *__restrict, const char *__restrict, FILE *__restrict);
69 int fclose(FILE *);
70
71 int remove(const char *);
72 int rename(const char *, const char *);
73
74 int feof(FILE *);
75 int ferror(FILE *);
76 int fflush(FILE *);
77 void clearerr(FILE *);
78
79 int fseek(FILE *, long, int);
80 long ftell(FILE *);
81 void rewind(FILE *);
82
83 int fgetpos(FILE *__restrict, fpos_t *__restrict);
84 int fsetpos(FILE *, const fpos_t *);
85
86 size_t fread(void *__restrict, size_t, size_t, FILE *__restrict);
87 size_t fwrite(const void *__restrict, size_t, size_t, FILE *__restrict);
88
89 int fgetc(FILE *);
90 int getc(FILE *);
91 int getchar(void);
92 int ungetc(int, FILE *);
93
94 int fputc(int, FILE *);
95 int putc(int, FILE *);
96 int putchar(int);
97
98 char *fgets(char *__restrict, int, FILE *__restrict);
99 #if __STDC_VERSION__ < 201112L
100 char *gets(char *);
101 #endif
102
103 int fputs(const char *__restrict, FILE *__restrict);
104 int puts(const char *);
105
106 int printf(const char *__restrict, ...);
107 int fprintf(FILE *__restrict, const char *__restrict, ...);
108 int sprintf(char *__restrict, const char *__restrict, ...);
109 int snprintf(char *__restrict, size_t, const char *__restrict, ...);
110
111 int vprintf(const char *__restrict, va_list);
112 int vfprintf(FILE *__restrict, const char *__restrict, va_list);
113 int vsprintf(char *__restrict, const char *__restrict, va_list);
114 int vsnprintf(char *__restrict, size_t, const char *__restrict, va_list);
115
116 int scanf(const char *__restrict, ...);
117 int fscanf(FILE *__restrict, const char *__restrict, ...);
118 int sscanf(const char *__restrict, const char *__restrict, ...);
119 int vscanf(const char *__restrict, va_list);
120 int vfscanf(FILE *__restrict, const char *__restrict, va_list);
121 int vsscanf(const char *__restrict, const char *__restrict, va_list);
122
123 void perror(const char *);
124
125 int setvbuf(FILE *__restrict, char *__restrict, int, size_t);
126 void setbuf(FILE *__restrict, char *__restrict);
127
128 char *tmpnam(char *);
129 FILE *tmpfile(void);
130
131 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
132  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
133  || defined(_BSD_SOURCE)
134 FILE *fmemopen(void *__restrict, size_t, const char *__restrict);
135 FILE *open_memstream(char **, size_t *);
136 FILE *fdopen(int, const char *);
137 FILE *popen(const char *, const char *);
138 int pclose(FILE *);
139 int fileno(FILE *);
140 int fseeko(FILE *, off_t, int);
141 off_t ftello(FILE *);
142 int dprintf(int, const char *__restrict, ...);
143 int vdprintf(int, const char *__restrict, va_list);
144 void flockfile(FILE *);
145 int ftrylockfile(FILE *);
146 void funlockfile(FILE *);
147 int getc_unlocked(FILE *);
148 int getchar_unlocked(void);
149 int putc_unlocked(int, FILE *);
150 int putchar_unlocked(int);
151 ssize_t getdelim(char **__restrict, size_t *__restrict, int, FILE *__restrict);
152 ssize_t getline(char **__restrict, size_t *__restrict, FILE *__restrict);
153 int renameat(int, const char *, int, const char *);
154 char *ctermid(char *);
155 #define L_ctermid 20
156 #endif
157
158
159 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
160  || defined(_BSD_SOURCE)
161 #define P_tmpdir "/tmp"
162 char *tempnam(const char *, const char *);
163 #endif
164
165 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
166 #define L_cuserid 20
167 char *cuserid(char *);
168 void setlinebuf(FILE *);
169 void setbuffer(FILE *, char *, size_t);
170 int fgetc_unlocked(FILE *);
171 int fputc_unlocked(int, FILE *);
172 int fflush_unlocked(FILE *);
173 size_t fread_unlocked(void *, size_t, size_t, FILE *);
174 size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
175 void clearerr_unlocked(FILE *);
176 int feof_unlocked(FILE *);
177 int ferror_unlocked(FILE *);
178 int fileno_unlocked(FILE *);
179 int getw(FILE *);
180 int putw(int, FILE *);
181 #endif
182
183 #ifdef _BSD_SOURCE
184 char *fgetln(FILE *, size_t *);
185 #endif
186
187 #ifdef _GNU_SOURCE
188 int asprintf(char **, const char *, ...);
189 int vasprintf(char **, const char *, va_list);
190 char *fgets_unlocked(char *, int, FILE *);
191 int fputs_unlocked(const char *, FILE *);
192 #endif
193
194 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
195 #define tmpfile64 tmpfile
196 #define fopen64 fopen
197 #define freopen64 freopen
198 #define fseeko64 fseeko
199 #define ftello64 ftello
200 #define fgetpos64 fgetpos
201 #define fsetpos64 fsetpos
202 #define fpos64_t fpos_t
203 #define off64_t off_t
204 #endif
205
206 #ifdef __cplusplus
207 }
208 #endif
209
210 #endif