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