remove ancient clang workaround from powerpc pthread_arch.h asm
[musl.git] / include / stdio.h
blobafadd9124a847dfdf6b407049c7e0a32d9f389f4
1 #ifndef _STDIO_H
2 #define _STDIO_H
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
8 #include <features.h>
10 #define __NEED_FILE
11 #define __NEED___isoc_va_list
12 #define __NEED_size_t
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 #define __NEED_va_list
20 #endif
22 #include <bits/alltypes.h>
24 #ifdef __cplusplus
25 #define NULL 0L
26 #else
27 #define NULL ((void*)0)
28 #endif
30 #undef EOF
31 #define EOF (-1)
33 #undef SEEK_SET
34 #undef SEEK_CUR
35 #undef SEEK_END
36 #define SEEK_SET 0
37 #define SEEK_CUR 1
38 #define SEEK_END 2
40 #define _IOFBF 0
41 #define _IOLBF 1
42 #define _IONBF 2
44 #define BUFSIZ 1024
45 #define FILENAME_MAX 4096
46 #define FOPEN_MAX 1000
47 #define TMP_MAX 10000
48 #define L_tmpnam 20
50 typedef union _G_fpos64_t {
51 char __opaque[16];
52 long long __lldata;
53 double __align;
54 } fpos_t;
56 extern FILE *const stdin;
57 extern FILE *const stdout;
58 extern FILE *const stderr;
60 #define stdin (stdin)
61 #define stdout (stdout)
62 #define stderr (stderr)
64 FILE *fopen(const char *__restrict, const char *__restrict);
65 FILE *freopen(const char *__restrict, const char *__restrict, FILE *__restrict);
66 int fclose(FILE *);
68 int remove(const char *);
69 int rename(const char *, const char *);
71 int feof(FILE *);
72 int ferror(FILE *);
73 int fflush(FILE *);
74 void clearerr(FILE *);
76 int fseek(FILE *, long, int);
77 long ftell(FILE *);
78 void rewind(FILE *);
80 int fgetpos(FILE *__restrict, fpos_t *__restrict);
81 int fsetpos(FILE *, const fpos_t *);
83 size_t fread(void *__restrict, size_t, size_t, FILE *__restrict);
84 size_t fwrite(const void *__restrict, size_t, size_t, FILE *__restrict);
86 int fgetc(FILE *);
87 int getc(FILE *);
88 int getchar(void);
89 int ungetc(int, FILE *);
91 int fputc(int, FILE *);
92 int putc(int, FILE *);
93 int putchar(int);
95 char *fgets(char *__restrict, int, FILE *__restrict);
96 #if __STDC_VERSION__ < 201112L
97 char *gets(char *);
98 #endif
100 int fputs(const char *__restrict, FILE *__restrict);
101 int puts(const char *);
103 int printf(const char *__restrict, ...);
104 int fprintf(FILE *__restrict, const char *__restrict, ...);
105 int sprintf(char *__restrict, const char *__restrict, ...);
106 int snprintf(char *__restrict, size_t, const char *__restrict, ...);
108 int vprintf(const char *__restrict, __isoc_va_list);
109 int vfprintf(FILE *__restrict, const char *__restrict, __isoc_va_list);
110 int vsprintf(char *__restrict, const char *__restrict, __isoc_va_list);
111 int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list);
113 int scanf(const char *__restrict, ...);
114 int fscanf(FILE *__restrict, const char *__restrict, ...);
115 int sscanf(const char *__restrict, const char *__restrict, ...);
116 int vscanf(const char *__restrict, __isoc_va_list);
117 int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list);
118 int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list);
120 void perror(const char *);
122 int setvbuf(FILE *__restrict, char *__restrict, int, size_t);
123 void setbuf(FILE *__restrict, char *__restrict);
125 char *tmpnam(char *);
126 FILE *tmpfile(void);
128 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
129 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
130 || defined(_BSD_SOURCE)
131 FILE *fmemopen(void *__restrict, size_t, const char *__restrict);
132 FILE *open_memstream(char **, size_t *);
133 FILE *fdopen(int, const char *);
134 FILE *popen(const char *, const char *);
135 int pclose(FILE *);
136 int fileno(FILE *);
137 int fseeko(FILE *, off_t, int);
138 off_t ftello(FILE *);
139 int dprintf(int, const char *__restrict, ...);
140 int vdprintf(int, const char *__restrict, __isoc_va_list);
141 void flockfile(FILE *);
142 int ftrylockfile(FILE *);
143 void funlockfile(FILE *);
144 int getc_unlocked(FILE *);
145 int getchar_unlocked(void);
146 int putc_unlocked(int, FILE *);
147 int putchar_unlocked(int);
148 ssize_t getdelim(char **__restrict, size_t *__restrict, int, FILE *__restrict);
149 ssize_t getline(char **__restrict, size_t *__restrict, FILE *__restrict);
150 int renameat(int, const char *, int, const char *);
151 char *ctermid(char *);
152 #define L_ctermid 20
153 #endif
156 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
157 || defined(_BSD_SOURCE)
158 #define P_tmpdir "/tmp"
159 char *tempnam(const char *, const char *);
160 #endif
162 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
163 #define L_cuserid 20
164 char *cuserid(char *);
165 void setlinebuf(FILE *);
166 void setbuffer(FILE *, char *, size_t);
167 int fgetc_unlocked(FILE *);
168 int fputc_unlocked(int, FILE *);
169 int fflush_unlocked(FILE *);
170 size_t fread_unlocked(void *, size_t, size_t, FILE *);
171 size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
172 void clearerr_unlocked(FILE *);
173 int feof_unlocked(FILE *);
174 int ferror_unlocked(FILE *);
175 int fileno_unlocked(FILE *);
176 int getw(FILE *);
177 int putw(int, FILE *);
178 char *fgetln(FILE *, size_t *);
179 int asprintf(char **, const char *, ...);
180 int vasprintf(char **, const char *, __isoc_va_list);
181 #endif
183 #ifdef _GNU_SOURCE
184 char *fgets_unlocked(char *, int, FILE *);
185 int fputs_unlocked(const char *, FILE *);
187 typedef ssize_t (cookie_read_function_t)(void *, char *, size_t);
188 typedef ssize_t (cookie_write_function_t)(void *, const char *, size_t);
189 typedef int (cookie_seek_function_t)(void *, off_t *, int);
190 typedef int (cookie_close_function_t)(void *);
192 typedef struct _IO_cookie_io_functions_t {
193 cookie_read_function_t *read;
194 cookie_write_function_t *write;
195 cookie_seek_function_t *seek;
196 cookie_close_function_t *close;
197 } cookie_io_functions_t;
199 FILE *fopencookie(void *, const char *, cookie_io_functions_t);
200 #endif
202 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
203 #define tmpfile64 tmpfile
204 #define fopen64 fopen
205 #define freopen64 freopen
206 #define fseeko64 fseeko
207 #define ftello64 ftello
208 #define fgetpos64 fgetpos
209 #define fsetpos64 fsetpos
210 #define fpos64_t fpos_t
211 #define off64_t off_t
212 #endif
214 #ifdef __cplusplus
216 #endif
218 #endif