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