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