]>
Commit | Line | Data |
---|---|---|
0ecb606c | 1 | /* Copyright (C) 1991-1995,1997-2005,2006 Free Software Foundation, Inc. |
41bdb6e2 | 2 | This file is part of the GNU C Library. |
40a55d20 UD |
3 | Written by Per Bothner <bothner@cygnus.com>. |
4 | ||
41bdb6e2 AJ |
5 | The GNU C Library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
40a55d20 | 9 | |
41bdb6e2 AJ |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
40a55d20 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
41bdb6e2 | 13 | Lesser General Public License for more details. |
40a55d20 | 14 | |
41bdb6e2 AJ |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, write to the Free | |
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | 02111-1307 USA. | |
40a55d20 | 19 | |
41bdb6e2 AJ |
20 | As a special exception, if you link the code in this file with |
21 | files compiled with a GNU compiler to produce an executable, | |
22 | that does not cause the resulting executable to be covered by | |
23 | the GNU Lesser General Public License. This exception does not | |
24 | however invalidate any other reasons why the executable file | |
25 | might be covered by the GNU Lesser General Public License. | |
26 | This exception applies to code released by its copyright holders | |
27 | in files containing the exception. */ | |
96aa2d94 RM |
28 | |
29 | #ifndef _IO_STDIO_H | |
30 | #define _IO_STDIO_H | |
31 | ||
32 | #include <_G_config.h> | |
319d719d | 33 | /* ALL of these should be defined in _G_config.h */ |
96aa2d94 RM |
34 | #define _IO_pos_t _G_fpos_t /* obsolete */ |
35 | #define _IO_fpos_t _G_fpos_t | |
dfd2257a | 36 | #define _IO_fpos64_t _G_fpos64_t |
96aa2d94 RM |
37 | #define _IO_size_t _G_size_t |
38 | #define _IO_ssize_t _G_ssize_t | |
39 | #define _IO_off_t _G_off_t | |
dfd2257a | 40 | #define _IO_off64_t _G_off64_t |
96aa2d94 RM |
41 | #define _IO_pid_t _G_pid_t |
42 | #define _IO_uid_t _G_uid_t | |
d64b6ad0 | 43 | #define _IO_iconv_t _G_iconv_t |
96aa2d94 RM |
44 | #define _IO_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT |
45 | #define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE | |
46 | #define _IO_BUFSIZ _G_BUFSIZ | |
47 | #define _IO_va_list _G_va_list | |
d64b6ad0 | 48 | #define _IO_wint_t _G_wint_t |
96aa2d94 RM |
49 | |
50 | #ifdef _G_NEED_STDARG_H | |
51 | /* This define avoids name pollution if we're using GNU stdarg.h */ | |
40a55d20 UD |
52 | # define __need___va_list |
53 | # include <stdarg.h> | |
54 | # ifdef __GNUC_VA_LIST | |
55 | # undef _IO_va_list | |
56 | # define _IO_va_list __gnuc_va_list | |
57 | # endif /* __GNUC_VA_LIST */ | |
96aa2d94 RM |
58 | #endif |
59 | ||
60 | #ifndef __P | |
40a55d20 UD |
61 | # if _G_HAVE_SYS_CDEFS |
62 | # include <sys/cdefs.h> | |
63 | # else | |
64 | # ifdef __STDC__ | |
cc3fa755 | 65 | # define __P(p) p |
fdacb17d | 66 | # define __PMT(p) p |
40a55d20 | 67 | # else |
cc3fa755 | 68 | # define __P(p) () |
fdacb17d | 69 | # define __PMT(p) () |
40a55d20 UD |
70 | # endif |
71 | # endif | |
96aa2d94 RM |
72 | #endif /*!__P*/ |
73 | ||
74 | /* For backward compatibility */ | |
75 | #ifndef _PARAMS | |
40a55d20 | 76 | # define _PARAMS(protos) __P(protos) |
96aa2d94 RM |
77 | #endif /*!_PARAMS*/ |
78 | ||
79 | #ifndef __STDC__ | |
999b2f6b UD |
80 | # ifndef const |
81 | # define const | |
82 | # endif | |
96aa2d94 RM |
83 | #endif |
84 | #define _IO_UNIFIED_JUMPTABLES 1 | |
2604afb1 UD |
85 | #ifndef _G_HAVE_PRINTF_FP |
86 | # define _IO_USE_DTOA 1 | |
87 | #endif | |
96aa2d94 | 88 | |
96aa2d94 | 89 | #ifndef EOF |
40a55d20 | 90 | # define EOF (-1) |
96aa2d94 RM |
91 | #endif |
92 | #ifndef NULL | |
40a55d20 | 93 | # if defined __GNUG__ && \ |
f8b87ef0 | 94 | (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) |
40a55d20 UD |
95 | # define NULL (__null) |
96 | # else | |
97 | # if !defined(__cplusplus) | |
98 | # define NULL ((void*)0) | |
99 | # else | |
100 | # define NULL (0) | |
101 | # endif | |
102 | # endif | |
f65fd747 | 103 | #endif |
96aa2d94 RM |
104 | |
105 | #define _IOS_INPUT 1 | |
106 | #define _IOS_OUTPUT 2 | |
107 | #define _IOS_ATEND 4 | |
108 | #define _IOS_APPEND 8 | |
109 | #define _IOS_TRUNC 16 | |
110 | #define _IOS_NOCREATE 32 | |
111 | #define _IOS_NOREPLACE 64 | |
112 | #define _IOS_BIN 128 | |
113 | ||
114 | /* Magic numbers and bits for the _flags field. | |
115 | The magic numbers use the high-order bits of _flags; | |
2c6fe0bd | 116 | the remaining bits are available for variable flags. |
96aa2d94 RM |
117 | Note: The magic numbers must all be negative if stdio |
118 | emulation is desired. */ | |
119 | ||
120 | #define _IO_MAGIC 0xFBAD0000 /* Magic number */ | |
121 | #define _OLD_STDIO_MAGIC 0xFABC0000 /* Emulate old stdio. */ | |
122 | #define _IO_MAGIC_MASK 0xFFFF0000 | |
123 | #define _IO_USER_BUF 1 /* User owns buffer; don't delete it on close. */ | |
124 | #define _IO_UNBUFFERED 2 | |
125 | #define _IO_NO_READS 4 /* Reading not allowed */ | |
126 | #define _IO_NO_WRITES 8 /* Writing not allowd */ | |
127 | #define _IO_EOF_SEEN 0x10 | |
128 | #define _IO_ERR_SEEN 0x20 | |
129 | #define _IO_DELETE_DONT_CLOSE 0x40 /* Don't call close(_fileno) on cleanup. */ | |
130 | #define _IO_LINKED 0x80 /* Set if linked (using _chain) to streambuf::_list_all.*/ | |
131 | #define _IO_IN_BACKUP 0x100 | |
132 | #define _IO_LINE_BUF 0x200 | |
133 | #define _IO_TIED_PUT_GET 0x400 /* Set if put and get pointer logicly tied. */ | |
134 | #define _IO_CURRENTLY_PUTTING 0x800 | |
135 | #define _IO_IS_APPENDING 0x1000 | |
136 | #define _IO_IS_FILEBUF 0x2000 | |
f671aeab | 137 | #define _IO_BAD_SEEN 0x4000 |
a91d3cd3 | 138 | #define _IO_USER_LOCK 0x8000 |
96aa2d94 | 139 | |
dd0ee2e1 | 140 | #define _IO_FLAGS2_MMAP 1 |
ee8449f7 | 141 | #define _IO_FLAGS2_NOTCANCEL 2 |
b5cc329c | 142 | #ifdef _LIBC |
fb67e07d | 143 | # define _IO_FLAGS2_FORTIFY 4 |
b5cc329c | 144 | #endif |
0ecb606c | 145 | #define _IO_FLAGS2_USER_WBUF 8 |
dd0ee2e1 | 146 | |
96aa2d94 RM |
147 | /* These are "formatting flags" matching the iostream fmtflags enum values. */ |
148 | #define _IO_SKIPWS 01 | |
149 | #define _IO_LEFT 02 | |
150 | #define _IO_RIGHT 04 | |
151 | #define _IO_INTERNAL 010 | |
152 | #define _IO_DEC 020 | |
153 | #define _IO_OCT 040 | |
154 | #define _IO_HEX 0100 | |
155 | #define _IO_SHOWBASE 0200 | |
156 | #define _IO_SHOWPOINT 0400 | |
157 | #define _IO_UPPERCASE 01000 | |
158 | #define _IO_SHOWPOS 02000 | |
159 | #define _IO_SCIENTIFIC 04000 | |
160 | #define _IO_FIXED 010000 | |
161 | #define _IO_UNITBUF 020000 | |
162 | #define _IO_STDIO 040000 | |
163 | #define _IO_DONT_CLOSE 0100000 | |
f671aeab | 164 | #define _IO_BOOLALPHA 0200000 |
96aa2d94 RM |
165 | |
166 | ||
167 | struct _IO_jump_t; struct _IO_FILE; | |
168 | ||
7c713e28 RM |
169 | /* Handle lock. */ |
170 | #ifdef _IO_MTSAFE_IO | |
a2b08ee5 UD |
171 | # if defined __GLIBC__ && __GLIBC__ >= 2 |
172 | # include <bits/stdio-lock.h> | |
173 | # else | |
174 | /*# include <comthread.h>*/ | |
175 | # endif | |
7c713e28 RM |
176 | #else |
177 | typedef void _IO_lock_t; | |
178 | #endif | |
96aa2d94 | 179 | |
96aa2d94 RM |
180 | |
181 | /* A streammarker remembers a position in a buffer. */ | |
182 | ||
183 | struct _IO_marker { | |
184 | struct _IO_marker *_next; | |
185 | struct _IO_FILE *_sbuf; | |
186 | /* If _pos >= 0 | |
187 | it points to _buf->Gbase()+_pos. FIXME comment */ | |
188 | /* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */ | |
189 | int _pos; | |
190 | #if 0 | |
191 | void set_streampos(streampos sp) { _spos = sp; } | |
192 | void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); } | |
193 | public: | |
194 | streammarker(streambuf *sb); | |
195 | ~streammarker(); | |
196 | int saving() { return _spos == -2; } | |
197 | int delta(streammarker&); | |
198 | int delta(); | |
199 | #endif | |
200 | }; | |
201 | ||
d64b6ad0 UD |
202 | /* This is the structure from the libstdc++ codecvt class. */ |
203 | enum __codecvt_result | |
204 | { | |
205 | __codecvt_ok, | |
206 | __codecvt_partial, | |
207 | __codecvt_error, | |
208 | __codecvt_noconv | |
209 | }; | |
210 | ||
319d719d | 211 | #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T |
d64b6ad0 UD |
212 | /* The order of the elements in the following struct must match the order |
213 | of the virtual functions in the libstdc++ codecvt class. */ | |
214 | struct _IO_codecvt | |
215 | { | |
c1422e5b UD |
216 | void (*__codecvt_destr) (struct _IO_codecvt *); |
217 | enum __codecvt_result (*__codecvt_do_out) (struct _IO_codecvt *, | |
218 | __mbstate_t *, | |
219 | const wchar_t *, | |
220 | const wchar_t *, | |
221 | const wchar_t **, char *, | |
222 | char *, char **); | |
223 | enum __codecvt_result (*__codecvt_do_unshift) (struct _IO_codecvt *, | |
224 | __mbstate_t *, char *, | |
225 | char *, char **); | |
226 | enum __codecvt_result (*__codecvt_do_in) (struct _IO_codecvt *, | |
227 | __mbstate_t *, | |
228 | const char *, const char *, | |
229 | const char **, wchar_t *, | |
230 | wchar_t *, wchar_t **); | |
231 | int (*__codecvt_do_encoding) (struct _IO_codecvt *); | |
232 | int (*__codecvt_do_always_noconv) (struct _IO_codecvt *); | |
233 | int (*__codecvt_do_length) (struct _IO_codecvt *, __mbstate_t *, | |
234 | const char *, const char *, _IO_size_t); | |
235 | int (*__codecvt_do_max_length) (struct _IO_codecvt *); | |
d64b6ad0 UD |
236 | |
237 | _IO_iconv_t __cd_in; | |
238 | _IO_iconv_t __cd_out; | |
239 | }; | |
240 | ||
241 | /* Extra data for wide character streams. */ | |
242 | struct _IO_wide_data | |
243 | { | |
244 | wchar_t *_IO_read_ptr; /* Current read pointer */ | |
245 | wchar_t *_IO_read_end; /* End of get area. */ | |
246 | wchar_t *_IO_read_base; /* Start of putback+get area. */ | |
247 | wchar_t *_IO_write_base; /* Start of put area. */ | |
248 | wchar_t *_IO_write_ptr; /* Current put pointer. */ | |
249 | wchar_t *_IO_write_end; /* End of put area. */ | |
250 | wchar_t *_IO_buf_base; /* Start of reserve area. */ | |
251 | wchar_t *_IO_buf_end; /* End of reserve area. */ | |
252 | /* The following fields are used to support backing up and undo. */ | |
253 | wchar_t *_IO_save_base; /* Pointer to start of non-current get area. */ | |
254 | wchar_t *_IO_backup_base; /* Pointer to first valid character of | |
255 | backup area */ | |
256 | wchar_t *_IO_save_end; /* Pointer to end of non-current get area. */ | |
257 | ||
258 | __mbstate_t _IO_state; | |
259 | __mbstate_t _IO_last_state; | |
260 | struct _IO_codecvt _codecvt; | |
261 | ||
262 | wchar_t _shortbuf[1]; | |
263 | ||
b2637a22 | 264 | const struct _IO_jump_t *_wide_vtable; |
d64b6ad0 | 265 | }; |
319d719d | 266 | #endif |
d64b6ad0 | 267 | |
96aa2d94 RM |
268 | struct _IO_FILE { |
269 | int _flags; /* High-order word is _IO_MAGIC; rest is flags. */ | |
270 | #define _IO_file_flags _flags | |
271 | ||
272 | /* The following pointers correspond to the C++ streambuf protocol. */ | |
f65fd747 | 273 | /* Note: Tk uses the _IO_read_ptr and _IO_read_end fields directly. */ |
96aa2d94 RM |
274 | char* _IO_read_ptr; /* Current read pointer */ |
275 | char* _IO_read_end; /* End of get area. */ | |
276 | char* _IO_read_base; /* Start of putback+get area. */ | |
277 | char* _IO_write_base; /* Start of put area. */ | |
278 | char* _IO_write_ptr; /* Current put pointer. */ | |
279 | char* _IO_write_end; /* End of put area. */ | |
280 | char* _IO_buf_base; /* Start of reserve area. */ | |
281 | char* _IO_buf_end; /* End of reserve area. */ | |
282 | /* The following fields are used to support backing up and undo. */ | |
283 | char *_IO_save_base; /* Pointer to start of non-current get area. */ | |
284 | char *_IO_backup_base; /* Pointer to first valid character of backup area */ | |
285 | char *_IO_save_end; /* Pointer to end of non-current get area. */ | |
286 | ||
287 | struct _IO_marker *_markers; | |
288 | ||
73c115ed | 289 | struct _IO_FILE *_chain; |
96aa2d94 | 290 | |
96aa2d94 | 291 | int _fileno; |
dd0ee2e1 | 292 | #if 0 |
96aa2d94 | 293 | int _blksize; |
dd0ee2e1 UD |
294 | #else |
295 | int _flags2; | |
296 | #endif | |
1ea89a40 | 297 | _IO_off_t _old_offset; /* This used to be _offset but it's too small. */ |
96aa2d94 RM |
298 | |
299 | #define __HAVE_COLUMN /* temporary */ | |
300 | /* 1+column number of pbase(); 0 is unknown. */ | |
301 | unsigned short _cur_column; | |
bd355af0 | 302 | signed char _vtable_offset; |
96aa2d94 RM |
303 | char _shortbuf[1]; |
304 | ||
305 | /* char* _save_gptr; char* _save_egptr; */ | |
306 | ||
7c713e28 | 307 | _IO_lock_t *_lock; |
bd355af0 UD |
308 | #ifdef _IO_USE_OLD_IO_FILE |
309 | }; | |
310 | ||
311 | struct _IO_FILE_complete | |
312 | { | |
313 | struct _IO_FILE _file; | |
314 | #endif | |
315 | #if defined _G_IO_IO_FILE_VERSION && _G_IO_IO_FILE_VERSION == 0x20001 | |
316 | _IO_off64_t _offset; | |
319d719d | 317 | # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T |
d64b6ad0 UD |
318 | /* Wide character stream stuff. */ |
319 | struct _IO_codecvt *_codecvt; | |
320 | struct _IO_wide_data *_wide_data; | |
0ecb606c JJ |
321 | struct _IO_FILE *_freeres_list; |
322 | void *_freeres_buf; | |
323 | size_t _freeres_size; | |
319d719d UD |
324 | # else |
325 | void *__pad1; | |
326 | void *__pad2; | |
0ecb606c JJ |
327 | void *__pad3; |
328 | void *__pad4; | |
329 | size_t __pad5; | |
319d719d | 330 | # endif |
d64b6ad0 | 331 | int _mode; |
00bc5db0 | 332 | /* Make sure we don't get into trouble again. */ |
0ecb606c | 333 | char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)]; |
bd355af0 | 334 | #endif |
96aa2d94 RM |
335 | }; |
336 | ||
337 | #ifndef __cplusplus | |
338 | typedef struct _IO_FILE _IO_FILE; | |
339 | #endif | |
340 | ||
73c115ed GM |
341 | struct _IO_FILE_plus; |
342 | ||
bd355af0 UD |
343 | extern struct _IO_FILE_plus _IO_2_1_stdin_; |
344 | extern struct _IO_FILE_plus _IO_2_1_stdout_; | |
345 | extern struct _IO_FILE_plus _IO_2_1_stderr_; | |
6973fc01 UD |
346 | #ifndef _LIBC |
347 | #define _IO_stdin ((_IO_FILE*)(&_IO_2_1_stdin_)) | |
348 | #define _IO_stdout ((_IO_FILE*)(&_IO_2_1_stdout_)) | |
349 | #define _IO_stderr ((_IO_FILE*)(&_IO_2_1_stderr_)) | |
350 | #else | |
100351c3 UD |
351 | extern _IO_FILE *_IO_stdin attribute_hidden; |
352 | extern _IO_FILE *_IO_stdout attribute_hidden; | |
353 | extern _IO_FILE *_IO_stderr attribute_hidden; | |
6973fc01 | 354 | #endif |
96aa2d94 | 355 | |
fa0bc87c | 356 | |
542f5e01 UD |
357 | /* Functions to do I/O and file management for a stream. */ |
358 | ||
359 | /* Read NBYTES bytes from COOKIE into a buffer pointed to by BUF. | |
360 | Return number of bytes read. */ | |
c1422e5b | 361 | typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes); |
542f5e01 UD |
362 | |
363 | /* Write N bytes pointed to by BUF to COOKIE. Write all N bytes | |
364 | unless there is an error. Return number of bytes written, or -1 if | |
365 | there is an error without writing anything. If the file has been | |
366 | opened for append (__mode.__append set), then set the file pointer | |
367 | to the end of the file and then do the write; if not, just write at | |
368 | the current file pointer. */ | |
c1422e5b UD |
369 | typedef __ssize_t __io_write_fn (void *__cookie, __const char *__buf, |
370 | size_t __n); | |
542f5e01 UD |
371 | |
372 | /* Move COOKIE's file position to *POS bytes from the | |
373 | beginning of the file (if W is SEEK_SET), | |
374 | the current position (if W is SEEK_CUR), | |
375 | or the end of the file (if W is SEEK_END). | |
376 | Set *POS to the new file position. | |
377 | Returns zero if successful, nonzero if not. */ | |
b4e54243 | 378 | typedef int __io_seek_fn (void *__cookie, _IO_off64_t *__pos, int __w); |
542f5e01 UD |
379 | |
380 | /* Close COOKIE. */ | |
c1422e5b | 381 | typedef int __io_close_fn (void *__cookie); |
542f5e01 UD |
382 | |
383 | ||
9d1efe33 | 384 | #ifdef _GNU_SOURCE |
542f5e01 UD |
385 | /* User-visible names for the above. */ |
386 | typedef __io_read_fn cookie_read_function_t; | |
387 | typedef __io_write_fn cookie_write_function_t; | |
388 | typedef __io_seek_fn cookie_seek_function_t; | |
389 | typedef __io_close_fn cookie_close_function_t; | |
390 | ||
391 | /* The structure with the cookie function pointers. */ | |
1228ed5c UD |
392 | typedef struct |
393 | { | |
542f5e01 UD |
394 | __io_read_fn *read; /* Read bytes. */ |
395 | __io_write_fn *write; /* Write bytes. */ | |
396 | __io_seek_fn *seek; /* Seek/tell file position. */ | |
397 | __io_close_fn *close; /* Close file. */ | |
1228ed5c | 398 | } _IO_cookie_io_functions_t; |
542f5e01 | 399 | typedef _IO_cookie_io_functions_t cookie_io_functions_t; |
1228ed5c | 400 | |
2ca8b1ee | 401 | struct _IO_cookie_file; |
b4e54243 RM |
402 | |
403 | /* Initialize one of those. */ | |
404 | extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write, | |
405 | void *__cookie, _IO_cookie_io_functions_t __fns); | |
9d1efe33 | 406 | #endif |
fa0bc87c RM |
407 | |
408 | ||
96aa2d94 RM |
409 | #ifdef __cplusplus |
410 | extern "C" { | |
411 | #endif | |
412 | ||
0ecb606c JJ |
413 | extern int __underflow (_IO_FILE *); |
414 | extern int __uflow (_IO_FILE *); | |
415 | extern int __overflow (_IO_FILE *, int); | |
416 | extern _IO_wint_t __wunderflow (_IO_FILE *); | |
417 | extern _IO_wint_t __wuflow (_IO_FILE *); | |
418 | extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t); | |
96aa2d94 | 419 | |
63b8eae4 | 420 | #if __GNUC__ >= 3 |
0ecb606c | 421 | # define _IO_BE(expr, res) __builtin_expect ((expr), res) |
63b8eae4 UD |
422 | #else |
423 | # define _IO_BE(expr, res) (expr) | |
424 | #endif | |
425 | ||
7c713e28 | 426 | #define _IO_getc_unlocked(_fp) \ |
63b8eae4 UD |
427 | (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \ |
428 | ? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++) | |
7c713e28 | 429 | #define _IO_peekc_unlocked(_fp) \ |
63b8eae4 | 430 | (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \ |
40a55d20 UD |
431 | && __underflow (_fp) == EOF ? EOF \ |
432 | : *(unsigned char *) (_fp)->_IO_read_ptr) | |
bfcd44c3 | 433 | #define _IO_putc_unlocked(_ch, _fp) \ |
63b8eae4 | 434 | (_IO_BE ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end, 0) \ |
40a55d20 | 435 | ? __overflow (_fp, (unsigned char) (_ch)) \ |
bfcd44c3 | 436 | : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch))) |
96aa2d94 | 437 | |
d64b6ad0 | 438 | #define _IO_getwc_unlocked(_fp) \ |
63b8eae4 UD |
439 | (_IO_BE ((_fp)->_wide_data->_IO_read_ptr >= (_fp)->_wide_data->_IO_read_end,\ |
440 | 0) \ | |
d64b6ad0 UD |
441 | ? __wuflow (_fp) : (_IO_wint_t) *(_fp)->_wide_data->_IO_read_ptr++) |
442 | #define _IO_putwc_unlocked(_wch, _fp) \ | |
63b8eae4 UD |
443 | (_IO_BE ((_fp)->_wide_data->_IO_write_ptr \ |
444 | >= (_fp)->_wide_data->_IO_write_end, 0) \ | |
d64b6ad0 UD |
445 | ? __woverflow (_fp, _wch) \ |
446 | : (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch))) | |
447 | ||
7c713e28 RM |
448 | #define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0) |
449 | #define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0) | |
96aa2d94 | 450 | |
0ecb606c JJ |
451 | extern int _IO_getc (_IO_FILE *__fp); |
452 | extern int _IO_putc (int __c, _IO_FILE *__fp); | |
c1422e5b UD |
453 | extern int _IO_feof (_IO_FILE *__fp) __THROW; |
454 | extern int _IO_ferror (_IO_FILE *__fp) __THROW; | |
d41c6f61 | 455 | |
0ecb606c | 456 | extern int _IO_peekc_locked (_IO_FILE *__fp); |
d41c6f61 | 457 | |
96aa2d94 RM |
458 | /* This one is for Emacs. */ |
459 | #define _IO_PENDING_OUTPUT_COUNT(_fp) \ | |
460 | ((_fp)->_IO_write_ptr - (_fp)->_IO_write_base) | |
461 | ||
c1422e5b UD |
462 | extern void _IO_flockfile (_IO_FILE *) __THROW; |
463 | extern void _IO_funlockfile (_IO_FILE *) __THROW; | |
464 | extern int _IO_ftrylockfile (_IO_FILE *) __THROW; | |
7c713e28 | 465 | |
a2b08ee5 UD |
466 | #ifdef _IO_MTSAFE_IO |
467 | # define _IO_peekc(_fp) _IO_peekc_locked (_fp) | |
a8e58aa9 | 468 | # define _IO_flockfile(_fp) \ |
aebb1faa | 469 | if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_flockfile (_fp) |
a8e58aa9 | 470 | # define _IO_funlockfile(_fp) \ |
aebb1faa | 471 | if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_funlockfile (_fp) |
a2b08ee5 UD |
472 | #else |
473 | # define _IO_peekc(_fp) _IO_peekc_unlocked (_fp) | |
d41c6f61 UD |
474 | # define _IO_flockfile(_fp) /**/ |
475 | # define _IO_funlockfile(_fp) /**/ | |
476 | # define _IO_ftrylockfile(_fp) /**/ | |
68dbb3a6 UD |
477 | # define _IO_cleanup_region_start(_fct, _fp) /**/ |
478 | # define _IO_cleanup_region_end(_Doit) /**/ | |
edf5b2d7 | 479 | #endif /* !_IO_MTSAFE_IO */ |
7c713e28 | 480 | |
c1422e5b | 481 | extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict, |
0ecb606c | 482 | _IO_va_list, int *__restrict); |
c1422e5b | 483 | extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict, |
0ecb606c JJ |
484 | _IO_va_list); |
485 | extern _IO_ssize_t _IO_padn (_IO_FILE *, int, _IO_ssize_t); | |
486 | extern _IO_size_t _IO_sgetn (_IO_FILE *, void *, _IO_size_t); | |
c1422e5b | 487 | |
0ecb606c JJ |
488 | extern _IO_off64_t _IO_seekoff (_IO_FILE *, _IO_off64_t, int, int); |
489 | extern _IO_off64_t _IO_seekpos (_IO_FILE *, _IO_off64_t, int); | |
c1422e5b UD |
490 | |
491 | extern void _IO_free_backup_area (_IO_FILE *) __THROW; | |
319d719d UD |
492 | |
493 | #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T | |
0ecb606c JJ |
494 | extern _IO_wint_t _IO_getwc (_IO_FILE *__fp); |
495 | extern _IO_wint_t _IO_putwc (wchar_t __wc, _IO_FILE *__fp); | |
319d719d UD |
496 | extern int _IO_fwide (_IO_FILE *__fp, int __mode) __THROW; |
497 | # if __GNUC__ >= 2 | |
8bfae061 UD |
498 | /* While compiling glibc we have to handle compatibility with very old |
499 | versions. */ | |
500 | # if defined _LIBC && defined SHARED | |
501 | # include <shlib-compat.h> | |
502 | # if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) | |
503 | # define _IO_fwide_maybe_incompatible \ | |
504 | (__builtin_expect (&_IO_stdin_used == NULL, 0)) | |
505 | extern const int _IO_stdin_used; | |
506 | weak_extern (_IO_stdin_used); | |
507 | # endif | |
508 | # endif | |
509 | # ifndef _IO_fwide_maybe_incompatible | |
510 | # define _IO_fwide_maybe_incompatible (0) | |
511 | # endif | |
319d719d UD |
512 | /* A special optimized version of the function above. It optimizes the |
513 | case of initializing an unoriented byte stream. */ | |
514 | # define _IO_fwide(__fp, __mode) \ | |
515 | ({ int __result = (__mode); \ | |
8bfae061 | 516 | if (__result < 0 && ! _IO_fwide_maybe_incompatible) \ |
319d719d UD |
517 | { \ |
518 | if ((__fp)->_mode == 0) \ | |
519 | /* We know that all we have to do is to set the flag. */ \ | |
520 | (__fp)->_mode = -1; \ | |
521 | __result = (__fp)->_mode; \ | |
522 | } \ | |
84446801 | 523 | else if (__builtin_constant_p (__mode) && (__mode) == 0) \ |
1c8c5277 | 524 | __result = _IO_fwide_maybe_incompatible ? -1 : (__fp)->_mode; \ |
319d719d UD |
525 | else \ |
526 | __result = _IO_fwide (__fp, __result); \ | |
527 | __result; }) | |
528 | # endif | |
529 | ||
530 | extern int _IO_vfwscanf (_IO_FILE * __restrict, const wchar_t * __restrict, | |
0ecb606c | 531 | _IO_va_list, int *__restrict); |
319d719d | 532 | extern int _IO_vfwprintf (_IO_FILE *__restrict, const wchar_t *__restrict, |
0ecb606c JJ |
533 | _IO_va_list); |
534 | extern _IO_ssize_t _IO_wpadn (_IO_FILE *, wint_t, _IO_ssize_t); | |
c1422e5b | 535 | extern void _IO_free_wbackup_area (_IO_FILE *) __THROW; |
319d719d | 536 | #endif |
96aa2d94 | 537 | |
0ecb606c JJ |
538 | #ifdef __LDBL_COMPAT |
539 | # include <bits/libio-ldbl.h> | |
540 | #endif | |
541 | ||
96aa2d94 RM |
542 | #ifdef __cplusplus |
543 | } | |
544 | #endif | |
545 | ||
546 | #endif /* _IO_STDIO_H */ |