]>
git.ipfire.org Git - thirdparty/glibc.git/blob - libio/bits/types/struct_FILE.h
1 /* Copyright (C) 1991-2023 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
18 #ifndef __struct_FILE_defined
19 #define __struct_FILE_defined 1
21 /* Caution: The contents of this file are not part of the official
22 stdio.h API. However, much of it is part of the official *binary*
23 interface, and therefore cannot be changed. */
25 #if defined _IO_USE_OLD_IO_FILE && !defined _LIBC
26 # error "_IO_USE_OLD_IO_FILE should only be defined when building libc itself"
29 #if defined _IO_lock_t_defined && !defined _LIBC
30 # error "_IO_lock_t_defined should only be defined when building libc itself"
33 #include <bits/types.h>
40 /* During the build of glibc itself, _IO_lock_t will already have been
41 defined by internal headers. */
42 #ifndef _IO_lock_t_defined
43 typedef void _IO_lock_t
;
46 /* The tag name of this struct is _IO_FILE to preserve historic
47 C++ mangled names for functions taking FILE* arguments.
48 That name should not be used in new code. */
51 int _flags
; /* High-order word is _IO_MAGIC; rest is flags. */
53 /* The following pointers correspond to the C++ streambuf protocol. */
54 char *_IO_read_ptr
; /* Current read pointer */
55 char *_IO_read_end
; /* End of get area. */
56 char *_IO_read_base
; /* Start of putback+get area. */
57 char *_IO_write_base
; /* Start of put area. */
58 char *_IO_write_ptr
; /* Current put pointer. */
59 char *_IO_write_end
; /* End of put area. */
60 char *_IO_buf_base
; /* Start of reserve area. */
61 char *_IO_buf_end
; /* End of reserve area. */
63 /* The following fields are used to support backing up and undo. */
64 char *_IO_save_base
; /* Pointer to start of non-current get area. */
65 char *_IO_backup_base
; /* Pointer to first valid character of backup area */
66 char *_IO_save_end
; /* Pointer to end of non-current get area. */
68 struct _IO_marker
*_markers
;
70 struct _IO_FILE
*_chain
;
74 __off_t _old_offset
; /* This used to be _offset but it's too small. */
76 /* 1+column number of pbase(); 0 is unknown. */
77 unsigned short _cur_column
;
78 signed char _vtable_offset
;
82 #ifdef _IO_USE_OLD_IO_FILE
85 struct _IO_FILE_complete
87 struct _IO_FILE _file
;
90 /* Wide character stream stuff. */
91 struct _IO_codecvt
*_codecvt
;
92 struct _IO_wide_data
*_wide_data
;
93 struct _IO_FILE
*_freeres_list
;
97 /* Make sure we don't get into trouble again. */
98 char _unused2
[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
101 /* These macros are used by bits/stdio.h and internal headers. */
102 #define __getc_unlocked_body(_fp) \
103 (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end) \
104 ? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
106 #define __putc_unlocked_body(_ch, _fp) \
107 (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \
108 ? __overflow (_fp, (unsigned char) (_ch)) \
109 : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
111 #define _IO_EOF_SEEN 0x0010
112 #define __feof_unlocked_body(_fp) (((_fp)->_flags & _IO_EOF_SEEN) != 0)
114 #define _IO_ERR_SEEN 0x0020
115 #define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0)
117 #define _IO_USER_LOCK 0x8000
118 /* Many more flag bits are defined internally. */