]>
Commit | Line | Data |
---|---|---|
b2637a22 | 1 | /* Copyright (C) 1993, 1997-2003, 2004 Free Software Foundation, Inc. |
41bdb6e2 | 2 | This file is part of the GNU C Library. |
40a55d20 | 3 | |
41bdb6e2 AJ |
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. | |
40a55d20 | 8 | |
41bdb6e2 AJ |
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 | |
40a55d20 | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
41bdb6e2 AJ |
12 | Lesser General Public License for more details. |
13 | ||
14 | You should have received a copy of the GNU Lesser General Public | |
15 | License along with the GNU C Library; if not, write to the Free | |
16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
17 | 02111-1307 USA. | |
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. */ | |
96aa2d94 RM |
27 | |
28 | #include <errno.h> | |
a2b08ee5 UD |
29 | #ifndef __set_errno |
30 | # define __set_errno(Val) errno = (Val) | |
31 | #endif | |
32 | #if defined __GLIBC__ && __GLIBC__ >= 2 | |
33 | # include <bits/libc-lock.h> | |
34 | #else | |
35 | /*# include <comthread.h>*/ | |
36 | #endif | |
96aa2d94 RM |
37 | |
38 | #include "iolibio.h" | |
39 | ||
77fe0b9c UD |
40 | /* Control of exported symbols. Used in glibc. By default we don't |
41 | do anything. */ | |
42 | #ifndef INTUSE | |
43 | # define INTUSE(name) name | |
44 | #endif | |
45 | #ifndef INTDEF | |
46 | # define INTDEF(name) | |
47 | #endif | |
48 | #ifndef INTDEF2 | |
49 | # define INTDEF2(name) | |
50 | #endif | |
37ba7d66 UD |
51 | #ifndef libc_hidden_proto |
52 | # define libc_hidden_proto(name) | |
53 | #endif | |
54 | #ifndef libc_hidden_def | |
55 | # define libc_hidden_def(name) | |
56 | #endif | |
57 | #ifndef libc_hidden_weak | |
58 | # define libc_hidden_weak(name) | |
59 | #endif | |
60 | ||
4547c1a4 UD |
61 | #ifdef __cplusplus |
62 | extern "C" { | |
63 | #endif | |
96aa2d94 RM |
64 | |
65 | #define _IO_seek_set 0 | |
66 | #define _IO_seek_cur 1 | |
67 | #define _IO_seek_end 2 | |
68 | ||
f65fd747 UD |
69 | /* THE JUMPTABLE FUNCTIONS. |
70 | ||
71 | * The _IO_FILE type is used to implement the FILE type in GNU libc, | |
72 | * as well as the streambuf class in GNU iostreams for C++. | |
73 | * These are all the same, just used differently. | |
74 | * An _IO_FILE (or FILE) object is allows followed by a pointer to | |
75 | * a jump table (of pointers to functions). The pointer is accessed | |
76 | * with the _IO_JUMPS macro. The jump table has a eccentric format, | |
77 | * so as to be compatible with the layout of a C++ virtual function table. | |
6d52618b | 78 | * (as implemented by g++). When a pointer to a streambuf object is |
f65fd747 UD |
79 | * coerced to an (_IO_FILE*), then _IO_JUMPS on the result just |
80 | * happens to point to the virtual function table of the streambuf. | |
81 | * Thus the _IO_JUMPS function table used for C stdio/libio does | |
6d52618b | 82 | * double duty as the virtual function table for C++ streambuf. |
f65fd747 UD |
83 | * |
84 | * The entries in the _IO_JUMPS function table (and hence also the | |
85 | * virtual functions of a streambuf) are described below. | |
86 | * The first parameter of each function entry is the _IO_FILE/streambuf | |
87 | * object being acted on (i.e. the 'this' parameter). | |
88 | */ | |
96aa2d94 | 89 | |
00404a96 RM |
90 | #ifdef _LIBC |
91 | # include <shlib-compat.h> | |
92 | # if !SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) | |
93 | /* Setting this macro disables the use of the _vtable_offset | |
94 | bias in _IO_JUMPS_FUNCS, below. That is only needed if we | |
95 | want to support old binaries (see oldfileops.c). */ | |
96 | # define _G_IO_NO_BACKWARD_COMPAT 1 | |
97 | # endif | |
98 | #endif | |
99 | ||
bd355af0 UD |
100 | #if (!defined _IO_USE_OLD_IO_FILE \ |
101 | && (!defined _G_IO_NO_BACKWARD_COMPAT || _G_IO_NO_BACKWARD_COMPAT == 0)) | |
102 | # define _IO_JUMPS_OFFSET 1 | |
103 | #endif | |
104 | ||
2ca8b1ee | 105 | #define _IO_JUMPS(THIS) (THIS)->vtable |
d64b6ad0 | 106 | #define _IO_WIDE_JUMPS(THIS) ((struct _IO_FILE *) (THIS))->_wide_data->_wide_vtable |
7163e69e UD |
107 | #define _IO_CHECK_WIDE(THIS) (((struct _IO_FILE *) (THIS))->_wide_data != NULL) |
108 | ||
bd355af0 UD |
109 | #if _IO_JUMPS_OFFSET |
110 | # define _IO_JUMPS_FUNC(THIS) \ | |
2ca8b1ee | 111 | (*(struct _IO_jump_t **) ((void *) &_IO_JUMPS ((struct _IO_FILE_plus *) (THIS)) \ |
bd355af0 | 112 | + (THIS)->_vtable_offset)) |
bbdef797 | 113 | # define _IO_vtable_offset(THIS) (THIS)->_vtable_offset |
bd355af0 | 114 | #else |
2ca8b1ee | 115 | # define _IO_JUMPS_FUNC(THIS) _IO_JUMPS ((struct _IO_FILE_plus *) (THIS)) |
bbdef797 | 116 | # define _IO_vtable_offset(THIS) 0 |
bd355af0 | 117 | #endif |
6e06ae59 | 118 | #define _IO_WIDE_JUMPS_FUNC(THIS) _IO_WIDE_JUMPS(THIS) |
f65fd747 | 119 | #ifdef _G_USING_THUNKS |
40a55d20 | 120 | # define JUMP_FIELD(TYPE, NAME) TYPE NAME |
6b87a564 UD |
121 | # define JUMP0(FUNC, THIS) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS) |
122 | # define JUMP1(FUNC, THIS, X1) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1) | |
123 | # define JUMP2(FUNC, THIS, X1, X2) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2) | |
124 | # define JUMP3(FUNC, THIS, X1,X2,X3) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3) | |
40a55d20 UD |
125 | # define JUMP_INIT(NAME, VALUE) VALUE |
126 | # define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT (dummy2, 0) | |
6e06ae59 | 127 | |
6b87a564 UD |
128 | # define WJUMP0(FUNC, THIS) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS) |
129 | # define WJUMP1(FUNC, THIS, X1) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1) | |
130 | # define WJUMP2(FUNC, THIS, X1, X2) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2) | |
131 | # define WJUMP3(FUNC, THIS, X1,X2,X3) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3) | |
96aa2d94 | 132 | #else |
f65fd747 | 133 | /* These macros will change when we re-implement vtables to use "thunks"! */ |
40a55d20 | 134 | # define JUMP_FIELD(TYPE, NAME) struct { short delta1, delta2; TYPE pfn; } NAME |
bd355af0 UD |
135 | # define JUMP0(FUNC, THIS) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS) |
136 | # define JUMP1(FUNC, THIS, X1) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1) | |
137 | # define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1, X2) | |
138 | # define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1,X2,X3) | |
40a55d20 UD |
139 | # define JUMP_INIT(NAME, VALUE) {0, 0, VALUE} |
140 | # define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0) | |
6e06ae59 UD |
141 | |
142 | # define WJUMP0(FUNC, THIS) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS) | |
143 | # define WJUMP1(FUNC, THIS, X1) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1) | |
144 | # define WJUMP2(FUNC, THIS, X1, X2) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1, X2) | |
145 | # define WJUMP3(FUNC, THIS, X1,X2,X3) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1,X2,X3) | |
f65fd747 | 146 | #endif |
96aa2d94 | 147 | |
f65fd747 | 148 | /* The 'finish' function does any final cleaning up of an _IO_FILE object. |
110215a9 | 149 | It does not delete (free) it, but does everything else to finalize it. |
f65fd747 | 150 | It matches the streambuf::~streambuf virtual destructor. */ |
79937577 | 151 | typedef void (*_IO_finish_t) (_IO_FILE *, int); /* finalize */ |
40a55d20 | 152 | #define _IO_FINISH(FP) JUMP1 (__finish, FP, 0) |
6e06ae59 | 153 | #define _IO_WFINISH(FP) WJUMP1 (__finish, FP, 0) |
f65fd747 UD |
154 | |
155 | /* The 'overflow' hook flushes the buffer. | |
156 | The second argument is a character, or EOF. | |
157 | It matches the streambuf::overflow virtual function. */ | |
79937577 | 158 | typedef int (*_IO_overflow_t) (_IO_FILE *, int); |
40a55d20 | 159 | #define _IO_OVERFLOW(FP, CH) JUMP1 (__overflow, FP, CH) |
6e06ae59 | 160 | #define _IO_WOVERFLOW(FP, CH) WJUMP1 (__overflow, FP, CH) |
f65fd747 UD |
161 | |
162 | /* The 'underflow' hook tries to fills the get buffer. | |
163 | It returns the next character (as an unsigned char) or EOF. The next | |
6d52618b | 164 | character remains in the get buffer, and the get position is not changed. |
f65fd747 | 165 | It matches the streambuf::underflow virtual function. */ |
79937577 | 166 | typedef int (*_IO_underflow_t) (_IO_FILE *); |
40a55d20 | 167 | #define _IO_UNDERFLOW(FP) JUMP0 (__underflow, FP) |
6e06ae59 | 168 | #define _IO_WUNDERFLOW(FP) WJUMP0 (__underflow, FP) |
f65fd747 UD |
169 | |
170 | /* The 'uflow' hook returns the next character in the input stream | |
171 | (cast to unsigned char), and increments the read position; | |
172 | EOF is returned on failure. | |
173 | It matches the streambuf::uflow virtual function, which is not in the | |
174 | cfront implementation, but was added to C++ by the ANSI/ISO committee. */ | |
40a55d20 | 175 | #define _IO_UFLOW(FP) JUMP0 (__uflow, FP) |
6e06ae59 | 176 | #define _IO_WUFLOW(FP) WJUMP0 (__uflow, FP) |
f65fd747 UD |
177 | |
178 | /* The 'pbackfail' hook handles backing up. | |
179 | It matches the streambuf::pbackfail virtual function. */ | |
79937577 | 180 | typedef int (*_IO_pbackfail_t) (_IO_FILE *, int); |
40a55d20 | 181 | #define _IO_PBACKFAIL(FP, CH) JUMP1 (__pbackfail, FP, CH) |
6e06ae59 | 182 | #define _IO_WPBACKFAIL(FP, CH) WJUMP1 (__pbackfail, FP, CH) |
f65fd747 UD |
183 | |
184 | /* The 'xsputn' hook writes upto N characters from buffer DATA. | |
185 | Returns the number of character actually written. | |
186 | It matches the streambuf::xsputn virtual function. */ | |
79937577 UD |
187 | typedef _IO_size_t (*_IO_xsputn_t) (_IO_FILE *FP, const void *DATA, |
188 | _IO_size_t N); | |
40a55d20 | 189 | #define _IO_XSPUTN(FP, DATA, N) JUMP2 (__xsputn, FP, DATA, N) |
6e06ae59 | 190 | #define _IO_WXSPUTN(FP, DATA, N) WJUMP2 (__xsputn, FP, DATA, N) |
f65fd747 UD |
191 | |
192 | /* The 'xsgetn' hook reads upto N characters into buffer DATA. | |
193 | Returns the number of character actually read. | |
194 | It matches the streambuf::xsgetn virtual function. */ | |
79937577 | 195 | typedef _IO_size_t (*_IO_xsgetn_t) (_IO_FILE *FP, void *DATA, _IO_size_t N); |
40a55d20 | 196 | #define _IO_XSGETN(FP, DATA, N) JUMP2 (__xsgetn, FP, DATA, N) |
6e06ae59 | 197 | #define _IO_WXSGETN(FP, DATA, N) WJUMP2 (__xsgetn, FP, DATA, N) |
f65fd747 UD |
198 | |
199 | /* The 'seekoff' hook moves the stream position to a new position | |
200 | relative to the start of the file (if DIR==0), the current position | |
201 | (MODE==1), or the end of the file (MODE==2). | |
202 | It matches the streambuf::seekoff virtual function. | |
203 | It is also used for the ANSI fseek function. */ | |
79937577 UD |
204 | typedef _IO_off64_t (*_IO_seekoff_t) (_IO_FILE *FP, _IO_off64_t OFF, int DIR, |
205 | int MODE); | |
40a55d20 | 206 | #define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3 (__seekoff, FP, OFF, DIR, MODE) |
6e06ae59 | 207 | #define _IO_WSEEKOFF(FP, OFF, DIR, MODE) WJUMP3 (__seekoff, FP, OFF, DIR, MODE) |
f65fd747 UD |
208 | |
209 | /* The 'seekpos' hook also moves the stream position, | |
dfd2257a | 210 | but to an absolute position given by a fpos64_t (seekpos). |
f65fd747 UD |
211 | It matches the streambuf::seekpos virtual function. |
212 | It is also used for the ANSI fgetpos and fsetpos functions. */ | |
213 | /* The _IO_seek_cur and _IO_seek_end options are not allowed. */ | |
79937577 | 214 | typedef _IO_off64_t (*_IO_seekpos_t) (_IO_FILE *, _IO_off64_t, int); |
40a55d20 | 215 | #define _IO_SEEKPOS(FP, POS, FLAGS) JUMP2 (__seekpos, FP, POS, FLAGS) |
6e06ae59 | 216 | #define _IO_WSEEKPOS(FP, POS, FLAGS) WJUMP2 (__seekpos, FP, POS, FLAGS) |
f65fd747 UD |
217 | |
218 | /* The 'setbuf' hook gives a buffer to the file. | |
219 | It matches the streambuf::setbuf virtual function. */ | |
79937577 | 220 | typedef _IO_FILE* (*_IO_setbuf_t) (_IO_FILE *, char *, _IO_ssize_t); |
40a55d20 | 221 | #define _IO_SETBUF(FP, BUFFER, LENGTH) JUMP2 (__setbuf, FP, BUFFER, LENGTH) |
6e06ae59 | 222 | #define _IO_WSETBUF(FP, BUFFER, LENGTH) WJUMP2 (__setbuf, FP, BUFFER, LENGTH) |
f65fd747 UD |
223 | |
224 | /* The 'sync' hook attempts to synchronize the internal data structures | |
225 | of the file with the external state. | |
226 | It matches the streambuf::sync virtual function. */ | |
79937577 | 227 | typedef int (*_IO_sync_t) (_IO_FILE *); |
40a55d20 | 228 | #define _IO_SYNC(FP) JUMP0 (__sync, FP) |
6e06ae59 | 229 | #define _IO_WSYNC(FP) WJUMP0 (__sync, FP) |
f65fd747 UD |
230 | |
231 | /* The 'doallocate' hook is used to tell the file to allocate a buffer. | |
232 | It matches the streambuf::doallocate virtual function, which is not | |
233 | in the ANSI/ISO C++ standard, but is part traditional implementations. */ | |
79937577 | 234 | typedef int (*_IO_doallocate_t) (_IO_FILE *); |
40a55d20 | 235 | #define _IO_DOALLOCATE(FP) JUMP0 (__doallocate, FP) |
6e06ae59 | 236 | #define _IO_WDOALLOCATE(FP) WJUMP0 (__doallocate, FP) |
f65fd747 UD |
237 | |
238 | /* The following four hooks (sysread, syswrite, sysclose, sysseek, and | |
239 | sysstat) are low-level hooks specific to this implementation. | |
6d52618b | 240 | There is no correspondence in the ANSI/ISO C++ standard library. |
f65fd747 UD |
241 | The hooks basically correspond to the Unix system functions |
242 | (read, write, close, lseek, and stat) except that a _IO_FILE* | |
243 | parameter is used instead of a integer file descriptor; the default | |
244 | implementation used for normal files just calls those functions. | |
245 | The advantage of overriding these functions instead of the higher-level | |
246 | ones (underflow, overflow etc) is that you can leave all the buffering | |
247 | higher-level functions. */ | |
248 | ||
249 | /* The 'sysread' hook is used to read data from the external file into | |
250 | an existing buffer. It generalizes the Unix read(2) function. | |
251 | It matches the streambuf::sys_read virtual function, which is | |
6d52618b | 252 | specific to this implementation. */ |
79937577 | 253 | typedef _IO_ssize_t (*_IO_read_t) (_IO_FILE *, void *, _IO_ssize_t); |
40a55d20 | 254 | #define _IO_SYSREAD(FP, DATA, LEN) JUMP2 (__read, FP, DATA, LEN) |
6e06ae59 | 255 | #define _IO_WSYSREAD(FP, DATA, LEN) WJUMP2 (__read, FP, DATA, LEN) |
f65fd747 UD |
256 | |
257 | /* The 'syswrite' hook is used to write data from an existing buffer | |
258 | to an external file. It generalizes the Unix write(2) function. | |
259 | It matches the streambuf::sys_write virtual function, which is | |
6d52618b | 260 | specific to this implementation. */ |
79937577 | 261 | typedef _IO_ssize_t (*_IO_write_t) (_IO_FILE *, const void *, _IO_ssize_t); |
40a55d20 | 262 | #define _IO_SYSWRITE(FP, DATA, LEN) JUMP2 (__write, FP, DATA, LEN) |
6e06ae59 | 263 | #define _IO_WSYSWRITE(FP, DATA, LEN) WJUMP2 (__write, FP, DATA, LEN) |
f65fd747 UD |
264 | |
265 | /* The 'sysseek' hook is used to re-position an external file. | |
266 | It generalizes the Unix lseek(2) function. | |
267 | It matches the streambuf::sys_seek virtual function, which is | |
6d52618b | 268 | specific to this implementation. */ |
79937577 | 269 | typedef _IO_off64_t (*_IO_seek_t) (_IO_FILE *, _IO_off64_t, int); |
40a55d20 | 270 | #define _IO_SYSSEEK(FP, OFFSET, MODE) JUMP2 (__seek, FP, OFFSET, MODE) |
6e06ae59 | 271 | #define _IO_WSYSSEEK(FP, OFFSET, MODE) WJUMP2 (__seek, FP, OFFSET, MODE) |
f65fd747 UD |
272 | |
273 | /* The 'sysclose' hook is used to finalize (close, finish up) an | |
274 | external file. It generalizes the Unix close(2) function. | |
275 | It matches the streambuf::sys_close virtual function, which is | |
276 | specific to this implementation. */ | |
79937577 | 277 | typedef int (*_IO_close_t) (_IO_FILE *); /* finalize */ |
40a55d20 | 278 | #define _IO_SYSCLOSE(FP) JUMP0 (__close, FP) |
6e06ae59 | 279 | #define _IO_WSYSCLOSE(FP) WJUMP0 (__close, FP) |
f65fd747 UD |
280 | |
281 | /* The 'sysstat' hook is used to get information about an external file | |
282 | into a struct stat buffer. It generalizes the Unix fstat(2) call. | |
283 | It matches the streambuf::sys_stat virtual function, which is | |
6d52618b | 284 | specific to this implementation. */ |
79937577 | 285 | typedef int (*_IO_stat_t) (_IO_FILE *, void *); |
40a55d20 | 286 | #define _IO_SYSSTAT(FP, BUF) JUMP1 (__stat, FP, BUF) |
6e06ae59 | 287 | #define _IO_WSYSSTAT(FP, BUF) WJUMP1 (__stat, FP, BUF) |
96aa2d94 | 288 | |
dfd2257a UD |
289 | /* The 'showmany' hook can be used to get an image how much input is |
290 | available. In many cases the answer will be 0 which means unknown | |
291 | but some cases one can provide real information. */ | |
79937577 | 292 | typedef int (*_IO_showmanyc_t) (_IO_FILE *); |
dfd2257a | 293 | #define _IO_SHOWMANYC(FP) JUMP0 (__showmanyc, FP) |
6e06ae59 | 294 | #define _IO_WSHOWMANYC(FP) WJUMP0 (__showmanyc, FP) |
dfd2257a UD |
295 | |
296 | /* The 'imbue' hook is used to get information about the currently | |
297 | installed locales. */ | |
79937577 | 298 | typedef void (*_IO_imbue_t) (_IO_FILE *, void *); |
dfd2257a | 299 | #define _IO_IMBUE(FP, LOCALE) JUMP1 (__imbue, FP, LOCALE) |
6e06ae59 | 300 | #define _IO_WIMBUE(FP, LOCALE) WJUMP1 (__imbue, FP, LOCALE) |
dfd2257a | 301 | |
f65fd747 | 302 | |
96aa2d94 RM |
303 | #define _IO_CHAR_TYPE char /* unsigned char ? */ |
304 | #define _IO_INT_TYPE int | |
305 | ||
40a55d20 UD |
306 | struct _IO_jump_t |
307 | { | |
96aa2d94 | 308 | JUMP_FIELD(_G_size_t, __dummy); |
f65fd747 UD |
309 | #ifdef _G_USING_THUNKS |
310 | JUMP_FIELD(_G_size_t, __dummy2); | |
311 | #endif | |
96aa2d94 RM |
312 | JUMP_FIELD(_IO_finish_t, __finish); |
313 | JUMP_FIELD(_IO_overflow_t, __overflow); | |
314 | JUMP_FIELD(_IO_underflow_t, __underflow); | |
315 | JUMP_FIELD(_IO_underflow_t, __uflow); | |
316 | JUMP_FIELD(_IO_pbackfail_t, __pbackfail); | |
317 | /* showmany */ | |
318 | JUMP_FIELD(_IO_xsputn_t, __xsputn); | |
319 | JUMP_FIELD(_IO_xsgetn_t, __xsgetn); | |
320 | JUMP_FIELD(_IO_seekoff_t, __seekoff); | |
321 | JUMP_FIELD(_IO_seekpos_t, __seekpos); | |
322 | JUMP_FIELD(_IO_setbuf_t, __setbuf); | |
323 | JUMP_FIELD(_IO_sync_t, __sync); | |
324 | JUMP_FIELD(_IO_doallocate_t, __doallocate); | |
325 | JUMP_FIELD(_IO_read_t, __read); | |
326 | JUMP_FIELD(_IO_write_t, __write); | |
327 | JUMP_FIELD(_IO_seek_t, __seek); | |
328 | JUMP_FIELD(_IO_close_t, __close); | |
329 | JUMP_FIELD(_IO_stat_t, __stat); | |
dfd2257a UD |
330 | JUMP_FIELD(_IO_showmanyc_t, __showmanyc); |
331 | JUMP_FIELD(_IO_imbue_t, __imbue); | |
96aa2d94 RM |
332 | #if 0 |
333 | get_column; | |
334 | set_column; | |
335 | #endif | |
336 | }; | |
337 | ||
338 | /* We always allocate an extra word following an _IO_FILE. | |
f65fd747 | 339 | This contains a pointer to the function jump table used. |
96aa2d94 RM |
340 | This is for compatibility with C++ streambuf; the word can |
341 | be used to smash to a pointer to a virtual function table. */ | |
342 | ||
40a55d20 UD |
343 | struct _IO_FILE_plus |
344 | { | |
96aa2d94 | 345 | _IO_FILE file; |
96aa2d94 | 346 | const struct _IO_jump_t *vtable; |
96aa2d94 RM |
347 | }; |
348 | ||
7ea11363 UD |
349 | #ifdef _IO_USE_OLD_IO_FILE |
350 | /* This structure is used by the compatibility code as if it were an | |
351 | _IO_FILE_plus, but has enough space to initialize the _mode argument | |
352 | of an _IO_FILE_complete. */ | |
353 | struct _IO_FILE_complete_plus | |
354 | { | |
355 | struct _IO_FILE_complete file; | |
356 | const struct _IO_jump_t *vtable; | |
357 | }; | |
358 | #endif | |
359 | ||
2ca8b1ee GM |
360 | /* Special file type for fopencookie function. */ |
361 | struct _IO_cookie_file | |
362 | { | |
363 | struct _IO_FILE_plus __fp; | |
364 | void *__cookie; | |
365 | _IO_cookie_io_functions_t __io_functions; | |
366 | }; | |
367 | ||
c9fc9559 RM |
368 | _IO_FILE *_IO_fopencookie (void *cookie, const char *mode, |
369 | _IO_cookie_io_functions_t io_functions); | |
370 | ||
371 | ||
3fc9ca4e UD |
372 | /* Iterator type for walking global linked list of _IO_FILE objects. */ |
373 | ||
73c115ed | 374 | typedef struct _IO_FILE *_IO_ITER; |
3fc9ca4e | 375 | |
96aa2d94 RM |
376 | /* Generic functions */ |
377 | ||
79937577 UD |
378 | extern void _IO_switch_to_main_get_area (_IO_FILE *) __THROW; |
379 | extern void _IO_switch_to_backup_area (_IO_FILE *) __THROW; | |
380 | extern int _IO_switch_to_get_mode (_IO_FILE *) __THROW; | |
381 | extern void _IO_init (_IO_FILE *, int) __THROW; | |
382 | extern int _IO_sputbackc (_IO_FILE *, int) __THROW; | |
383 | extern int _IO_sungetc (_IO_FILE *) __THROW; | |
384 | extern void _IO_un_link (struct _IO_FILE_plus *) __THROW; | |
385 | extern void _IO_link_in (struct _IO_FILE_plus *) __THROW; | |
386 | extern void _IO_doallocbuf (_IO_FILE *) __THROW; | |
387 | extern void _IO_unsave_markers (_IO_FILE *) __THROW; | |
388 | extern void _IO_setb (_IO_FILE *, char *, char *, int) __THROW; | |
389 | extern unsigned _IO_adjust_column (unsigned, const char *, int) __THROW; | |
40a55d20 | 390 | #define _IO_sputn(__fp, __s, __n) _IO_XSPUTN (__fp, __s, __n) |
96aa2d94 | 391 | |
79937577 UD |
392 | extern void _IO_switch_to_main_wget_area (_IO_FILE *) __THROW; |
393 | extern void _IO_switch_to_wbackup_area (_IO_FILE *) __THROW; | |
394 | extern int _IO_switch_to_wget_mode (_IO_FILE *) __THROW; | |
395 | extern void _IO_wsetb (_IO_FILE *, wchar_t *, wchar_t *, int) __THROW; | |
396 | extern wint_t _IO_sputbackwc (_IO_FILE *, wint_t) __THROW; | |
397 | extern wint_t _IO_sungetwc (_IO_FILE *) __THROW; | |
398 | extern void _IO_wdoallocbuf (_IO_FILE *) __THROW; | |
399 | extern void _IO_unsave_wmarkers (_IO_FILE *) __THROW; | |
400 | extern unsigned _IO_adjust_wcolumn (unsigned, const wchar_t *, int) __THROW; | |
d64b6ad0 | 401 | |
96aa2d94 RM |
402 | /* Marker-related function. */ |
403 | ||
79937577 UD |
404 | extern void _IO_init_marker (struct _IO_marker *, _IO_FILE *) __THROW; |
405 | extern void _IO_init_wmarker (struct _IO_marker *, _IO_FILE *) __THROW; | |
406 | extern void _IO_remove_marker (struct _IO_marker *) __THROW; | |
407 | extern int _IO_marker_difference (struct _IO_marker *, struct _IO_marker *) | |
408 | __THROW; | |
409 | extern int _IO_marker_delta (struct _IO_marker *) __THROW; | |
410 | extern int _IO_wmarker_delta (struct _IO_marker *) __THROW; | |
411 | extern int _IO_seekmark (_IO_FILE *, struct _IO_marker *, int) __THROW; | |
412 | extern int _IO_seekwmark (_IO_FILE *, struct _IO_marker *, int) __THROW; | |
96aa2d94 | 413 | |
79937577 | 414 | /* Functions for iterating global list and dealing with its lock */ |
3fc9ca4e | 415 | |
79937577 | 416 | extern _IO_ITER _IO_iter_begin (void) __THROW; |
1d2b6e0c | 417 | libc_hidden_proto (_IO_iter_begin) |
79937577 | 418 | extern _IO_ITER _IO_iter_end (void) __THROW; |
1d2b6e0c | 419 | libc_hidden_proto (_IO_iter_end) |
79937577 | 420 | extern _IO_ITER _IO_iter_next (_IO_ITER) __THROW; |
1d2b6e0c | 421 | libc_hidden_proto (_IO_iter_next) |
79937577 | 422 | extern _IO_FILE *_IO_iter_file (_IO_ITER) __THROW; |
1d2b6e0c | 423 | libc_hidden_proto (_IO_iter_file) |
79937577 | 424 | extern void _IO_list_lock (void) __THROW; |
245eab02 | 425 | libc_hidden_proto (_IO_list_lock) |
79937577 | 426 | extern void _IO_list_unlock (void) __THROW; |
245eab02 | 427 | libc_hidden_proto (_IO_list_unlock) |
79937577 | 428 | extern void _IO_list_resetlock (void) __THROW; |
245eab02 | 429 | libc_hidden_proto (_IO_list_resetlock) |
3fc9ca4e | 430 | |
96aa2d94 RM |
431 | /* Default jumptable functions. */ |
432 | ||
79937577 UD |
433 | extern int _IO_default_underflow (_IO_FILE *) __THROW; |
434 | extern int _IO_default_uflow (_IO_FILE *) __THROW; | |
435 | extern wint_t _IO_wdefault_uflow (_IO_FILE *) __THROW; | |
436 | extern int _IO_default_doallocate (_IO_FILE *) __THROW; | |
437 | extern int _IO_wdefault_doallocate (_IO_FILE *) __THROW; | |
438 | extern void _IO_default_finish (_IO_FILE *, int) __THROW; | |
439 | extern void _IO_wdefault_finish (_IO_FILE *, int) __THROW; | |
440 | extern int _IO_default_pbackfail (_IO_FILE *, int) __THROW; | |
441 | extern wint_t _IO_wdefault_pbackfail (_IO_FILE *, wint_t) __THROW; | |
442 | extern _IO_FILE* _IO_default_setbuf (_IO_FILE *, char *, _IO_ssize_t) __THROW; | |
102070bc UD |
443 | extern _IO_size_t _IO_default_xsputn (_IO_FILE *, const void *, _IO_size_t); |
444 | extern _IO_size_t _IO_wdefault_xsputn (_IO_FILE *, const void *, _IO_size_t); | |
445 | extern _IO_size_t _IO_default_xsgetn (_IO_FILE *, void *, _IO_size_t); | |
446 | extern _IO_size_t _IO_wdefault_xsgetn (_IO_FILE *, void *, _IO_size_t); | |
79937577 UD |
447 | extern _IO_off64_t _IO_default_seekoff (_IO_FILE *, _IO_off64_t, int, int) |
448 | __THROW; | |
449 | extern _IO_off64_t _IO_default_seekpos (_IO_FILE *, _IO_off64_t, int) __THROW; | |
102070bc UD |
450 | extern _IO_ssize_t _IO_default_write (_IO_FILE *, const void *, _IO_ssize_t); |
451 | extern _IO_ssize_t _IO_default_read (_IO_FILE *, void *, _IO_ssize_t); | |
79937577 UD |
452 | extern int _IO_default_stat (_IO_FILE *, void *) __THROW; |
453 | extern _IO_off64_t _IO_default_seek (_IO_FILE *, _IO_off64_t, int) __THROW; | |
454 | extern int _IO_default_sync (_IO_FILE *) __THROW; | |
40a55d20 | 455 | #define _IO_default_close ((_IO_close_t) _IO_default_sync) |
79937577 UD |
456 | extern int _IO_default_showmanyc (_IO_FILE *) __THROW; |
457 | extern void _IO_default_imbue (_IO_FILE *, void *) __THROW; | |
96aa2d94 | 458 | |
b2637a22 | 459 | extern const struct _IO_jump_t _IO_file_jumps; |
15a686af | 460 | libc_hidden_proto (_IO_file_jumps) |
b2637a22 UD |
461 | extern const struct _IO_jump_t _IO_file_jumps_mmap attribute_hidden; |
462 | extern const struct _IO_jump_t _IO_file_jumps_maybe_mmap attribute_hidden; | |
463 | extern const struct _IO_jump_t _IO_wfile_jumps; | |
15a686af | 464 | libc_hidden_proto (_IO_wfile_jumps) |
b2637a22 UD |
465 | extern const struct _IO_jump_t _IO_wfile_jumps_mmap attribute_hidden; |
466 | extern const struct _IO_jump_t _IO_wfile_jumps_maybe_mmap attribute_hidden; | |
467 | extern const struct _IO_jump_t _IO_old_file_jumps attribute_hidden; | |
468 | extern const struct _IO_jump_t _IO_streambuf_jumps; | |
469 | extern const struct _IO_jump_t _IO_old_proc_jumps attribute_hidden; | |
470 | extern const struct _IO_jump_t _IO_str_jumps attribute_hidden; | |
471 | extern const struct _IO_jump_t _IO_wstr_jumps attribute_hidden; | |
ab26a24a | 472 | extern struct _IO_codecvt __libio_codecvt attribute_hidden; |
79937577 UD |
473 | extern int _IO_do_write (_IO_FILE *, const char *, _IO_size_t) __THROW; |
474 | extern int _IO_new_do_write (_IO_FILE *, const char *, _IO_size_t) __THROW; | |
475 | extern int _IO_old_do_write (_IO_FILE *, const char *, _IO_size_t) __THROW; | |
476 | extern int _IO_wdo_write (_IO_FILE *, const wchar_t *, _IO_size_t) __THROW; | |
477 | extern int _IO_flush_all_lockp (int) __THROW; | |
478 | extern int _IO_flush_all (void) __THROW; | |
479 | extern int _IO_cleanup (void) __THROW; | |
480 | extern void _IO_flush_all_linebuffered (void) __THROW; | |
481 | extern int _IO_new_fgetpos (_IO_FILE *, _IO_fpos_t *) __THROW; | |
482 | extern int _IO_old_fgetpos (_IO_FILE *, _IO_fpos_t *) __THROW; | |
483 | extern int _IO_new_fsetpos (_IO_FILE *, const _IO_fpos_t *) __THROW; | |
484 | extern int _IO_old_fsetpos (_IO_FILE *, const _IO_fpos_t *) __THROW; | |
485 | extern int _IO_new_fgetpos64 (_IO_FILE *, _IO_fpos64_t *) __THROW; | |
486 | extern int _IO_old_fgetpos64 (_IO_FILE *, _IO_fpos64_t *) __THROW; | |
487 | extern int _IO_new_fsetpos64 (_IO_FILE *, const _IO_fpos64_t *) __THROW; | |
488 | extern int _IO_old_fsetpos64 (_IO_FILE *, const _IO_fpos64_t *) __THROW; | |
489 | extern void _IO_old_init (_IO_FILE *fp, int flags) __THROW; | |
d64b6ad0 | 490 | |
96aa2d94 | 491 | |
319d719d UD |
492 | #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T |
493 | # define _IO_do_flush(_f) \ | |
d64b6ad0 | 494 | ((_f)->_mode <= 0 \ |
77fe0b9c UD |
495 | ? INTUSE(_IO_do_write)(_f, (_f)->_IO_write_base, \ |
496 | (_f)->_IO_write_ptr-(_f)->_IO_write_base) \ | |
497 | : INTUSE(_IO_wdo_write)(_f, (_f)->_wide_data->_IO_write_base, \ | |
498 | ((_f)->_wide_data->_IO_write_ptr \ | |
499 | - (_f)->_wide_data->_IO_write_base))) | |
319d719d UD |
500 | #else |
501 | # define _IO_do_flush(_f) \ | |
77fe0b9c UD |
502 | INTUSE(_IO_do_write)(_f, (_f)->_IO_write_base, \ |
503 | (_f)->_IO_write_ptr-(_f)->_IO_write_base) | |
319d719d | 504 | #endif |
6973fc01 UD |
505 | #define _IO_old_do_flush(_f) \ |
506 | _IO_old_do_write(_f, (_f)->_IO_write_base, \ | |
507 | (_f)->_IO_write_ptr-(_f)->_IO_write_base) | |
96aa2d94 RM |
508 | #define _IO_in_put_mode(_fp) ((_fp)->_flags & _IO_CURRENTLY_PUTTING) |
509 | #define _IO_mask_flags(fp, f, mask) \ | |
510 | ((fp)->_flags = ((fp)->_flags & ~(mask)) | ((f) & (mask))) | |
511 | #define _IO_setg(fp, eb, g, eg) ((fp)->_IO_read_base = (eb),\ | |
512 | (fp)->_IO_read_ptr = (g), (fp)->_IO_read_end = (eg)) | |
d64b6ad0 UD |
513 | #define _IO_wsetg(fp, eb, g, eg) ((fp)->_wide_data->_IO_read_base = (eb),\ |
514 | (fp)->_wide_data->_IO_read_ptr = (g), \ | |
515 | (fp)->_wide_data->_IO_read_end = (eg)) | |
96aa2d94 | 516 | #define _IO_setp(__fp, __p, __ep) \ |
d64b6ad0 UD |
517 | ((__fp)->_IO_write_base = (__fp)->_IO_write_ptr \ |
518 | = __p, (__fp)->_IO_write_end = (__ep)) | |
519 | #define _IO_wsetp(__fp, __p, __ep) \ | |
520 | ((__fp)->_wide_data->_IO_write_base \ | |
521 | = (__fp)->_wide_data->_IO_write_ptr = __p, \ | |
522 | (__fp)->_wide_data->_IO_write_end = (__ep)) | |
96aa2d94 | 523 | #define _IO_have_backup(fp) ((fp)->_IO_save_base != NULL) |
d64b6ad0 | 524 | #define _IO_have_wbackup(fp) ((fp)->_wide_data->_IO_save_base != NULL) |
96aa2d94 RM |
525 | #define _IO_in_backup(fp) ((fp)->_flags & _IO_IN_BACKUP) |
526 | #define _IO_have_markers(fp) ((fp)->_markers != NULL) | |
f65fd747 | 527 | #define _IO_blen(fp) ((fp)->_IO_buf_end - (fp)->_IO_buf_base) |
d64b6ad0 UD |
528 | #define _IO_wblen(fp) ((fp)->_wide_data->_IO_buf_end \ |
529 | - (fp)->_wide_data->_IO_buf_base) | |
96aa2d94 RM |
530 | |
531 | /* Jumptable functions for files. */ | |
532 | ||
79937577 UD |
533 | extern int _IO_file_doallocate (_IO_FILE *) __THROW; |
534 | extern _IO_FILE* _IO_file_setbuf (_IO_FILE *, char *, _IO_ssize_t) __THROW; | |
535 | extern _IO_off64_t _IO_file_seekoff (_IO_FILE *, _IO_off64_t, int, int) | |
536 | __THROW; | |
537 | extern _IO_off64_t _IO_file_seekoff_mmap (_IO_FILE *, _IO_off64_t, int, int) | |
538 | __THROW; | |
539 | extern _IO_size_t _IO_file_xsputn (_IO_FILE *, const void *, _IO_size_t) | |
540 | __THROW; | |
541 | extern _IO_size_t _IO_file_xsgetn (_IO_FILE *, void *, _IO_size_t) __THROW; | |
542 | extern int _IO_file_stat (_IO_FILE *, void *) __THROW; | |
543 | extern int _IO_file_close (_IO_FILE *) __THROW; | |
544 | extern int _IO_file_close_mmap (_IO_FILE *) __THROW; | |
545 | extern int _IO_file_underflow (_IO_FILE *) __THROW; | |
546 | extern int _IO_file_underflow_mmap (_IO_FILE *) __THROW; | |
547 | extern int _IO_file_underflow_maybe_mmap (_IO_FILE *) __THROW; | |
548 | extern int _IO_file_overflow (_IO_FILE *, int) __THROW; | |
110215a9 | 549 | #define _IO_file_is_open(__fp) ((__fp)->_fileno != -1) |
79937577 UD |
550 | extern void _IO_file_init (struct _IO_FILE_plus *) __THROW; |
551 | extern _IO_FILE* _IO_file_attach (_IO_FILE *, int) __THROW; | |
552 | extern _IO_FILE* _IO_file_open (_IO_FILE *, const char *, int, int, int, int) | |
553 | __THROW; | |
ee2a5ae8 | 554 | libc_hidden_proto (_IO_file_open) |
79937577 UD |
555 | extern _IO_FILE* _IO_file_fopen (_IO_FILE *, const char *, const char *, int) |
556 | __THROW; | |
557 | extern _IO_ssize_t _IO_file_write (_IO_FILE *, const void *, _IO_ssize_t) | |
558 | __THROW; | |
559 | extern _IO_ssize_t _IO_file_read (_IO_FILE *, void *, _IO_ssize_t) __THROW; | |
560 | extern int _IO_file_sync (_IO_FILE *) __THROW; | |
561 | extern int _IO_file_close_it (_IO_FILE *) __THROW; | |
562 | extern _IO_off64_t _IO_file_seek (_IO_FILE *, _IO_off64_t, int) __THROW; | |
563 | extern void _IO_file_finish (_IO_FILE *, int) __THROW; | |
564 | ||
565 | extern _IO_FILE* _IO_new_file_attach (_IO_FILE *, int) __THROW; | |
566 | extern int _IO_new_file_close_it (_IO_FILE *) __THROW; | |
567 | extern void _IO_new_file_finish (_IO_FILE *, int) __THROW; | |
568 | extern _IO_FILE* _IO_new_file_fopen (_IO_FILE *, const char *, const char *, | |
569 | int) __THROW; | |
570 | extern void _IO_no_init (_IO_FILE *, int, int, struct _IO_wide_data *, | |
571 | const struct _IO_jump_t *) __THROW; | |
572 | extern void _IO_new_file_init (struct _IO_FILE_plus *) __THROW; | |
573 | extern _IO_FILE* _IO_new_file_setbuf (_IO_FILE *, char *, _IO_ssize_t) __THROW; | |
574 | extern _IO_FILE* _IO_file_setbuf_mmap (_IO_FILE *, char *, _IO_ssize_t) | |
575 | __THROW; | |
576 | extern int _IO_new_file_sync (_IO_FILE *) __THROW; | |
577 | extern int _IO_new_file_underflow (_IO_FILE *) __THROW; | |
578 | extern int _IO_new_file_overflow (_IO_FILE *, int) __THROW; | |
579 | extern _IO_off64_t _IO_new_file_seekoff (_IO_FILE *, _IO_off64_t, int, int) | |
580 | __THROW; | |
581 | extern _IO_ssize_t _IO_new_file_write (_IO_FILE *, const void *, _IO_ssize_t) | |
582 | __THROW; | |
583 | extern _IO_size_t _IO_new_file_xsputn (_IO_FILE *, const void *, _IO_size_t) | |
584 | __THROW; | |
585 | ||
586 | extern _IO_FILE* _IO_old_file_setbuf (_IO_FILE *, char *, _IO_ssize_t) __THROW; | |
587 | extern _IO_off64_t _IO_old_file_seekoff (_IO_FILE *, _IO_off64_t, int, int) | |
588 | __THROW; | |
589 | extern _IO_size_t _IO_old_file_xsputn (_IO_FILE *, const void *, _IO_size_t) | |
590 | __THROW; | |
591 | extern int _IO_old_file_underflow (_IO_FILE *) __THROW; | |
592 | extern int _IO_old_file_overflow (_IO_FILE *, int) __THROW; | |
593 | extern void _IO_old_file_init (struct _IO_FILE_plus *) __THROW; | |
594 | extern _IO_FILE* _IO_old_file_attach (_IO_FILE *, int) __THROW; | |
595 | extern _IO_FILE* _IO_old_file_fopen (_IO_FILE *, const char *, const char *) | |
596 | __THROW; | |
597 | extern _IO_ssize_t _IO_old_file_write (_IO_FILE *, const void *, _IO_ssize_t) | |
598 | __THROW; | |
599 | extern int _IO_old_file_sync (_IO_FILE *) __THROW; | |
600 | extern int _IO_old_file_close_it (_IO_FILE *) __THROW; | |
601 | extern void _IO_old_file_finish (_IO_FILE *, int) __THROW; | |
602 | ||
603 | extern int _IO_wfile_doallocate (_IO_FILE *) __THROW; | |
604 | extern _IO_size_t _IO_wfile_xsputn (_IO_FILE *, const void *, _IO_size_t) | |
605 | __THROW; | |
606 | extern _IO_FILE* _IO_wfile_setbuf (_IO_FILE *, wchar_t *, _IO_ssize_t) __THROW; | |
607 | extern wint_t _IO_wfile_sync (_IO_FILE *) __THROW; | |
608 | extern wint_t _IO_wfile_underflow (_IO_FILE *) __THROW; | |
609 | extern wint_t _IO_wfile_overflow (_IO_FILE *, wint_t) __THROW; | |
610 | extern _IO_off64_t _IO_wfile_seekoff (_IO_FILE *, _IO_off64_t, int, int) | |
611 | __THROW; | |
d64b6ad0 | 612 | |
96aa2d94 | 613 | /* Jumptable functions for proc_files. */ |
79937577 UD |
614 | extern _IO_FILE* _IO_proc_open (_IO_FILE *, const char *, const char *) |
615 | __THROW; | |
616 | extern _IO_FILE* _IO_new_proc_open (_IO_FILE *, const char *, const char *) | |
617 | __THROW; | |
618 | extern _IO_FILE* _IO_old_proc_open (_IO_FILE *, const char *, const char *) | |
619 | __THROW; | |
620 | extern int _IO_proc_close (_IO_FILE *) __THROW; | |
621 | extern int _IO_new_proc_close (_IO_FILE *) __THROW; | |
622 | extern int _IO_old_proc_close (_IO_FILE *) __THROW; | |
96aa2d94 RM |
623 | |
624 | /* Jumptable functions for strfiles. */ | |
79937577 UD |
625 | extern int _IO_str_underflow (_IO_FILE *) __THROW; |
626 | extern int _IO_str_overflow (_IO_FILE *, int) __THROW; | |
627 | extern int _IO_str_pbackfail (_IO_FILE *, int) __THROW; | |
628 | extern _IO_off64_t _IO_str_seekoff (_IO_FILE *, _IO_off64_t, int, int) __THROW; | |
629 | extern void _IO_str_finish (_IO_FILE *, int) __THROW; | |
96aa2d94 RM |
630 | |
631 | /* Other strfile functions */ | |
2ca8b1ee | 632 | struct _IO_strfile_; |
79937577 UD |
633 | extern void _IO_str_init_static (struct _IO_strfile_ *, char *, int, char *) |
634 | __THROW; | |
635 | extern void _IO_str_init_readonly (struct _IO_strfile_ *, const char *, int) | |
636 | __THROW; | |
637 | extern _IO_ssize_t _IO_str_count (_IO_FILE *) __THROW; | |
96aa2d94 | 638 | |
d64b6ad0 | 639 | /* And the wide character versions. */ |
79937577 UD |
640 | extern void _IO_wstr_init_static (_IO_FILE *, wchar_t *, _IO_size_t, wchar_t *) |
641 | __THROW; | |
642 | extern _IO_ssize_t _IO_wstr_count (_IO_FILE *) __THROW; | |
643 | extern _IO_wint_t _IO_wstr_overflow (_IO_FILE *, _IO_wint_t) __THROW; | |
644 | extern _IO_wint_t _IO_wstr_underflow (_IO_FILE *) __THROW; | |
645 | extern _IO_off64_t _IO_wstr_seekoff (_IO_FILE *, _IO_off64_t, int, int) | |
646 | __THROW; | |
647 | extern _IO_wint_t _IO_wstr_pbackfail (_IO_FILE *, _IO_wint_t) __THROW; | |
648 | extern void _IO_wstr_finish (_IO_FILE *, int) __THROW; | |
649 | ||
650 | extern int _IO_vasprintf (char **result_ptr, __const char *format, | |
651 | _IO_va_list args) __THROW; | |
652 | extern int _IO_vdprintf (int d, __const char *format, _IO_va_list arg) __THROW; | |
653 | extern int _IO_vsnprintf (char *string, _IO_size_t maxlen, | |
654 | __const char *format, _IO_va_list args) __THROW; | |
655 | ||
656 | ||
102070bc | 657 | extern _IO_size_t _IO_getline (_IO_FILE *,char *, _IO_size_t, int, int); |
79937577 | 658 | extern _IO_size_t _IO_getline_info (_IO_FILE *,char *, _IO_size_t, |
102070bc | 659 | int, int, int *); |
79937577 UD |
660 | extern _IO_ssize_t _IO_getdelim (char **, _IO_size_t *, int, _IO_FILE *) |
661 | __THROW; | |
102070bc | 662 | extern _IO_size_t _IO_getwline (_IO_FILE *,wchar_t *, _IO_size_t, wint_t, int); |
79937577 | 663 | extern _IO_size_t _IO_getwline_info (_IO_FILE *,wchar_t *, _IO_size_t, |
102070bc | 664 | wint_t, int, wint_t *); |
79937577 UD |
665 | extern double _IO_strtod (const char *, char **) __THROW; |
666 | extern char *_IO_dtoa (double __d, int __mode, int __ndigits, | |
667 | int *__decpt, int *__sign, char **__rve) __THROW; | |
668 | extern int _IO_outfloat (double __value, _IO_FILE *__sb, int __type, | |
669 | int __width, int __precision, int __flags, | |
670 | int __sign_mode, int __fill) __THROW; | |
96aa2d94 | 671 | |
2ca8b1ee | 672 | extern struct _IO_FILE_plus *_IO_list_all; |
79937577 | 673 | extern void (*_IO_cleanup_registration_needed) (void); |
96aa2d94 | 674 | |
77fe0b9c | 675 | /* Prototype for functions with alternative entry point. */ |
79937577 UD |
676 | extern int _IO_flush_all_internal (void) __THROW; |
677 | extern unsigned _IO_adjust_column_internal (unsigned, const char *, int) | |
678 | __THROW; | |
679 | ||
680 | extern int _IO_default_uflow_internal (_IO_FILE *) __THROW; | |
681 | extern void _IO_default_finish_internal (_IO_FILE *, int) __THROW; | |
682 | extern int _IO_default_pbackfail_internal (_IO_FILE *, int) __THROW; | |
683 | extern _IO_size_t _IO_default_xsputn_internal (_IO_FILE *, const void *, | |
684 | _IO_size_t) __THROW; | |
685 | extern _IO_size_t _IO_default_xsgetn_internal (_IO_FILE *, void *, _IO_size_t) | |
686 | __THROW; | |
687 | extern int _IO_default_doallocate_internal (_IO_FILE *) __THROW; | |
688 | extern void _IO_wdefault_finish_internal (_IO_FILE *, int) __THROW; | |
689 | extern wint_t _IO_wdefault_pbackfail_internal (_IO_FILE *, wint_t) __THROW; | |
690 | extern _IO_size_t _IO_wdefault_xsputn_internal (_IO_FILE *, const void *, | |
691 | _IO_size_t) __THROW; | |
692 | extern _IO_size_t _IO_wdefault_xsgetn_internal (_IO_FILE *, void *, | |
693 | _IO_size_t) __THROW; | |
694 | extern int _IO_wdefault_doallocate_internal (_IO_FILE *) __THROW; | |
695 | extern wint_t _IO_wdefault_uflow_internal (_IO_FILE *) __THROW; | |
696 | ||
697 | extern int _IO_file_doallocate_internal (_IO_FILE *) __THROW; | |
698 | extern _IO_FILE* _IO_file_setbuf_internal (_IO_FILE *, char *, _IO_ssize_t) | |
699 | __THROW; | |
700 | extern _IO_off64_t _IO_file_seekoff_internal (_IO_FILE *, _IO_off64_t, | |
701 | int, int) __THROW; | |
702 | extern _IO_size_t _IO_file_xsputn_internal (_IO_FILE *, const void *, | |
703 | _IO_size_t) __THROW; | |
704 | extern _IO_size_t _IO_file_xsgetn_internal (_IO_FILE *, void *, _IO_size_t) | |
705 | __THROW; | |
706 | extern int _IO_file_stat_internal (_IO_FILE *, void *) __THROW; | |
707 | extern int _IO_file_close_internal (_IO_FILE *) __THROW; | |
708 | extern int _IO_file_close_it_internal (_IO_FILE *) __THROW; | |
709 | extern int _IO_file_underflow_internal (_IO_FILE *) __THROW; | |
710 | extern int _IO_file_overflow_internal (_IO_FILE *, int) __THROW; | |
711 | extern void _IO_file_init_internal (struct _IO_FILE_plus *) __THROW; | |
712 | extern _IO_FILE* _IO_file_attach_internal (_IO_FILE *, int) __THROW; | |
713 | extern _IO_FILE* _IO_file_fopen_internal (_IO_FILE *, const char *, | |
714 | const char *, int) __THROW; | |
715 | extern _IO_ssize_t _IO_file_read_internal (_IO_FILE *, void *, | |
102070bc | 716 | _IO_ssize_t); |
79937577 UD |
717 | extern int _IO_file_sync_internal (_IO_FILE *) __THROW; |
718 | extern _IO_off64_t _IO_file_seek_internal (_IO_FILE *, _IO_off64_t, int) | |
719 | __THROW; | |
720 | extern void _IO_file_finish_internal (_IO_FILE *, int) __THROW; | |
721 | ||
722 | extern _IO_size_t _IO_wfile_xsputn_internal (_IO_FILE *, const void *, | |
723 | _IO_size_t) __THROW; | |
724 | extern _IO_off64_t _IO_wfile_seekoff_internal (_IO_FILE *, _IO_off64_t, | |
725 | int, int) __THROW; | |
726 | extern wint_t _IO_wfile_sync_internal (_IO_FILE *) __THROW; | |
727 | ||
728 | extern int _IO_str_underflow_internal (_IO_FILE *) __THROW; | |
729 | extern int _IO_str_overflow_internal (_IO_FILE *, int) __THROW; | |
730 | extern int _IO_str_pbackfail_internal (_IO_FILE *, int) __THROW; | |
731 | extern _IO_off64_t _IO_str_seekoff_internal (_IO_FILE *, _IO_off64_t, | |
732 | int, int) __THROW; | |
733 | extern void _IO_str_init_static_internal (struct _IO_strfile_ *, char *, | |
734 | _IO_size_t, char *) __THROW; | |
77fe0b9c | 735 | |
100351c3 UD |
736 | extern struct _IO_jump_t _IO_file_jumps_internal attribute_hidden; |
737 | extern struct _IO_jump_t _IO_wfile_jumps_internal attribute_hidden; | |
77fe0b9c | 738 | |
100351c3 | 739 | extern struct _IO_FILE_plus *_IO_list_all_internal attribute_hidden; |
77fe0b9c | 740 | |
79937577 UD |
741 | extern void _IO_link_in_internal (struct _IO_FILE_plus *) __THROW; |
742 | extern int _IO_sputbackc_internal (_IO_FILE *, int) __THROW; | |
743 | extern void _IO_wdoallocbuf_internal (_IO_FILE *) __THROW; | |
744 | ||
102070bc | 745 | extern _IO_size_t _IO_sgetn_internal (_IO_FILE *, void *, _IO_size_t); |
79937577 UD |
746 | extern void _IO_flush_all_linebuffered_internal (void) __THROW; |
747 | extern int _IO_switch_to_wget_mode_internal (_IO_FILE *) __THROW; | |
748 | extern void _IO_unsave_markers_internal (_IO_FILE *) __THROW; | |
749 | extern void _IO_switch_to_main_wget_area_internal (_IO_FILE *) __THROW; | |
102070bc UD |
750 | extern int _IO_wdo_write_internal (_IO_FILE *, const wchar_t *, _IO_size_t); |
751 | extern int _IO_do_write_internal (_IO_FILE *, const char *, _IO_size_t); | |
79937577 UD |
752 | extern _IO_ssize_t _IO_padn_internal (_IO_FILE *, int, _IO_ssize_t) __THROW; |
753 | extern _IO_size_t _IO_getline_info_internal (_IO_FILE *,char *, _IO_size_t, | |
102070bc | 754 | int, int, int *); |
79937577 | 755 | extern _IO_size_t _IO_getline_internal (_IO_FILE *, char *, _IO_size_t, int, |
102070bc | 756 | int); |
79937577 UD |
757 | extern void _IO_free_wbackup_area_internal (_IO_FILE *) __THROW; |
758 | extern void _IO_free_backup_area_internal (_IO_FILE *) __THROW; | |
759 | extern void _IO_switch_to_wbackup_area_internal (_IO_FILE *) __THROW; | |
760 | extern void _IO_setb_internal (_IO_FILE *, char *, char *, int) __THROW; | |
761 | extern wint_t _IO_sputbackwc_internal (_IO_FILE *, wint_t) __THROW; | |
762 | extern int _IO_switch_to_get_mode_internal (_IO_FILE *) __THROW; | |
77fe0b9c UD |
763 | extern int _IO_vfscanf_internal (_IO_FILE * __restrict, |
764 | const char * __restrict, | |
765 | _IO_va_list, int *__restrict); | |
766 | extern int _IO_vfprintf_internal (_IO_FILE *__restrict, const char *__restrict, | |
102070bc | 767 | _IO_va_list); |
79937577 UD |
768 | extern void _IO_doallocbuf_internal (_IO_FILE *) __THROW; |
769 | extern void _IO_wsetb_internal (_IO_FILE *, wchar_t *, wchar_t *, int) | |
770 | __THROW; | |
52a16e58 | 771 | extern _IO_off64_t _IO_seekoff_unlocked (_IO_FILE *, _IO_off64_t, int, int) |
79937577 | 772 | attribute_hidden __THROW; |
52a16e58 | 773 | extern _IO_off64_t _IO_seekpos_unlocked (_IO_FILE *, _IO_off64_t, int) |
79937577 | 774 | attribute_hidden __THROW; |
102070bc | 775 | extern int _IO_putc_internal (int __c, _IO_FILE *__fp); |
79937577 UD |
776 | extern void _IO_init_internal (_IO_FILE *, int) __THROW; |
777 | extern void _IO_un_link_internal (struct _IO_FILE_plus *) __THROW; | |
77fe0b9c | 778 | |
96aa2d94 | 779 | #ifndef EOF |
40a55d20 | 780 | # define EOF (-1) |
96aa2d94 RM |
781 | #endif |
782 | #ifndef NULL | |
40a55d20 | 783 | # if defined __GNUG__ && \ |
f8b87ef0 | 784 | (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) |
40a55d20 UD |
785 | # define NULL (__null) |
786 | # else | |
787 | # if !defined(__cplusplus) | |
788 | # define NULL ((void*)0) | |
789 | # else | |
790 | # define NULL (0) | |
791 | # endif | |
792 | # endif | |
f65fd747 | 793 | #endif |
96aa2d94 | 794 | |
f8b87ef0 UD |
795 | #if _G_HAVE_MMAP |
796 | ||
40a55d20 UD |
797 | # include <unistd.h> |
798 | # include <fcntl.h> | |
799 | # include <sys/mman.h> | |
800 | # include <sys/param.h> | |
f8b87ef0 | 801 | |
40a55d20 UD |
802 | # if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) |
803 | # define MAP_ANONYMOUS MAP_ANON | |
804 | # endif | |
f8b87ef0 | 805 | |
40a55d20 UD |
806 | # if !defined(MAP_ANONYMOUS) || !defined(EXEC_PAGESIZE) |
807 | # undef _G_HAVE_MMAP | |
808 | # define _G_HAVE_MMAP 0 | |
809 | # endif | |
f8b87ef0 UD |
810 | |
811 | #endif /* _G_HAVE_MMAP */ | |
812 | ||
813 | #if _G_HAVE_MMAP | |
814 | ||
40a55d20 | 815 | # ifdef _LIBC |
10dc2a90 | 816 | /* When using this code in the GNU libc we must not pollute the name space. */ |
40a55d20 UD |
817 | # define mmap __mmap |
818 | # define munmap __munmap | |
dfd2257a | 819 | # define ftruncate __ftruncate |
40a55d20 | 820 | # endif |
10dc2a90 | 821 | |
40a55d20 | 822 | # define ROUND_TO_PAGE(_S) \ |
f8b87ef0 UD |
823 | (((_S) + EXEC_PAGESIZE - 1) & ~(EXEC_PAGESIZE - 1)) |
824 | ||
40a55d20 | 825 | # define FREE_BUF(_B, _S) \ |
f8b87ef0 | 826 | munmap ((_B), ROUND_TO_PAGE (_S)) |
40a55d20 | 827 | # define ALLOC_BUF(_B, _S, _R) \ |
f8b87ef0 UD |
828 | do { \ |
829 | (_B) = (char *) mmap (0, ROUND_TO_PAGE (_S), \ | |
830 | PROT_READ | PROT_WRITE, \ | |
831 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \ | |
d64b6ad0 UD |
832 | if ((_B) == (char *) MAP_FAILED) \ |
833 | return (_R); \ | |
834 | } while (0) | |
835 | # define ALLOC_WBUF(_B, _S, _R) \ | |
836 | do { \ | |
837 | (_B) = (wchar_t *) mmap (0, ROUND_TO_PAGE (_S), \ | |
838 | PROT_READ | PROT_WRITE, \ | |
839 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \ | |
840 | if ((_B) == (wchar_t *) MAP_FAILED) \ | |
f8b87ef0 UD |
841 | return (_R); \ |
842 | } while (0) | |
843 | ||
844 | #else /* _G_HAVE_MMAP */ | |
845 | ||
40a55d20 | 846 | # define FREE_BUF(_B, _S) \ |
f8b87ef0 | 847 | free(_B) |
40a55d20 | 848 | # define ALLOC_BUF(_B, _S, _R) \ |
f8b87ef0 UD |
849 | do { \ |
850 | (_B) = (char*)malloc(_S); \ | |
851 | if ((_B) == NULL) \ | |
852 | return (_R); \ | |
853 | } while (0) | |
af507979 UD |
854 | # define ALLOC_WBUF(_B, _S, _R) \ |
855 | do { \ | |
856 | (_B) = (wchar_t *)malloc(_S); \ | |
857 | if ((_B) == NULL) \ | |
858 | return (_R); \ | |
859 | } while (0) | |
f8b87ef0 UD |
860 | |
861 | #endif /* _G_HAVE_MMAP */ | |
96aa2d94 RM |
862 | |
863 | #ifndef OS_FSTAT | |
40a55d20 | 864 | # define OS_FSTAT fstat |
96aa2d94 RM |
865 | #endif |
866 | struct stat; | |
102070bc UD |
867 | extern _IO_ssize_t _IO_read (int, void *, _IO_size_t); |
868 | extern _IO_ssize_t _IO_write (int, const void *, _IO_size_t); | |
79937577 | 869 | extern _IO_off64_t _IO_lseek (int, _IO_off64_t, int) __THROW; |
102070bc | 870 | extern int _IO_close (int); |
79937577 UD |
871 | extern int _IO_fstat (int, struct stat *) __THROW; |
872 | extern int _IO_vscanf (const char *, _IO_va_list) __THROW; | |
96aa2d94 | 873 | |
d64b6ad0 | 874 | /* _IO_pos_BAD is an _IO_off64_t value indicating error, unknown, or EOF. */ |
96aa2d94 | 875 | #ifndef _IO_pos_BAD |
d64b6ad0 | 876 | # define _IO_pos_BAD ((_IO_off64_t) -1) |
96aa2d94 | 877 | #endif |
d64b6ad0 | 878 | /* _IO_pos_adjust adjust an _IO_off64_t by some number of bytes. */ |
96aa2d94 | 879 | #ifndef _IO_pos_adjust |
d64b6ad0 | 880 | # define _IO_pos_adjust(pos, delta) ((pos) += (delta)) |
96aa2d94 | 881 | #endif |
d64b6ad0 | 882 | /* _IO_pos_0 is an _IO_off64_t value indicating beginning of file. */ |
96aa2d94 | 883 | #ifndef _IO_pos_0 |
d64b6ad0 | 884 | # define _IO_pos_0 ((_IO_off64_t) 0) |
96aa2d94 RM |
885 | #endif |
886 | ||
4547c1a4 UD |
887 | #ifdef __cplusplus |
888 | } | |
889 | #endif | |
96aa2d94 | 890 | |
499e7464 | 891 | #ifdef _IO_MTSAFE_IO |
96aa2d94 | 892 | /* check following! */ |
1ddf537f | 893 | # ifdef _IO_USE_OLD_IO_FILE |
d64b6ad0 | 894 | # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ |
96aa2d94 | 895 | { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ |
319d719d | 896 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ |
73c115ed | 897 | 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock } |
1ddf537f | 898 | # else |
319d719d UD |
899 | # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T |
900 | # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ | |
1ddf537f | 901 | { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ |
319d719d | 902 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ |
d64b6ad0 UD |
903 | 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\ |
904 | NULL, WDP, 0 } | |
319d719d UD |
905 | # else |
906 | # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ | |
907 | { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ | |
908 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ | |
909 | 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\ | |
910 | 0 } | |
911 | # endif | |
1ddf537f | 912 | # endif |
499e7464 | 913 | #else |
1ddf537f | 914 | # ifdef _IO_USE_OLD_IO_FILE |
b4e3df5d | 915 | # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ |
499e7464 | 916 | { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ |
73c115ed GM |
917 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ |
918 | 0, _IO_pos_BAD } | |
1ddf537f | 919 | # else |
319d719d UD |
920 | # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T |
921 | # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ | |
1ddf537f | 922 | { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ |
319d719d | 923 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ |
d64b6ad0 UD |
924 | 0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \ |
925 | NULL, WDP, 0 } | |
319d719d UD |
926 | # else |
927 | # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \ | |
928 | { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ | |
929 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \ | |
930 | 0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \ | |
931 | 0 } | |
932 | # endif | |
1ddf537f | 933 | # endif |
499e7464 | 934 | #endif |
96aa2d94 RM |
935 | |
936 | /* VTABLE_LABEL defines NAME as of the CLASS class. | |
937 | CNLENGTH is strlen(#CLASS). */ | |
938 | #ifdef __GNUC__ | |
40a55d20 UD |
939 | # if _G_VTABLE_LABEL_HAS_LENGTH |
940 | # define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \ | |
96aa2d94 | 941 | extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CNLENGTH #CLASS); |
40a55d20 UD |
942 | # else |
943 | # define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \ | |
96aa2d94 | 944 | extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CLASS); |
40a55d20 | 945 | # endif |
96aa2d94 RM |
946 | #endif /* __GNUC__ */ |
947 | ||
948 | #if !defined(builtinbuf_vtable) && defined(__cplusplus) | |
40a55d20 | 949 | # ifdef __GNUC__ |
96aa2d94 | 950 | VTABLE_LABEL(builtinbuf_vtable, builtinbuf, 10) |
40a55d20 UD |
951 | # else |
952 | # if _G_VTABLE_LABEL_HAS_LENGTH | |
953 | # define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##10builtinbuf | |
954 | # else | |
955 | # define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##builtinbuf | |
956 | # endif | |
957 | # endif | |
96aa2d94 RM |
958 | #endif /* !defined(builtinbuf_vtable) && defined(__cplusplus) */ |
959 | ||
960 | #if defined(__STDC__) || defined(__cplusplus) | |
40a55d20 | 961 | # define _IO_va_start(args, last) va_start(args, last) |
96aa2d94 | 962 | #else |
40a55d20 | 963 | # define _IO_va_start(args, last) va_start(args) |
96aa2d94 RM |
964 | #endif |
965 | ||
966 | extern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf; | |
967 | ||
968 | #if 1 | |
40a55d20 | 969 | # define COERCE_FILE(FILE) /* Nothing */ |
96aa2d94 RM |
970 | #else |
971 | /* This is part of the kludge for binary compatibility with old stdio. */ | |
40a55d20 | 972 | # define COERCE_FILE(FILE) \ |
96aa2d94 RM |
973 | (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) == _OLD_MAGIC_MASK \ |
974 | && (FILE) = *(FILE**)&((int*)fp)[1]) | |
975 | #endif | |
976 | ||
977 | #ifdef EINVAL | |
40a55d20 | 978 | # define MAYBE_SET_EINVAL __set_errno (EINVAL) |
96aa2d94 | 979 | #else |
40a55d20 | 980 | # define MAYBE_SET_EINVAL /* nothing */ |
96aa2d94 RM |
981 | #endif |
982 | ||
f65fd747 | 983 | #ifdef IO_DEBUG |
40a55d20 | 984 | # define CHECK_FILE(FILE, RET) \ |
96aa2d94 RM |
985 | if ((FILE) == NULL) { MAYBE_SET_EINVAL; return RET; } \ |
986 | else { COERCE_FILE(FILE); \ | |
987 | if (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \ | |
68dbb3a6 | 988 | { MAYBE_SET_EINVAL; return RET; }} |
96aa2d94 | 989 | #else |
40a55d20 | 990 | # define CHECK_FILE(FILE, RET) COERCE_FILE (FILE) |
96aa2d94 | 991 | #endif |
eef80cf8 UD |
992 | |
993 | static inline void | |
994 | __attribute__ ((__always_inline__)) | |
995 | _IO_acquire_lock_fct (_IO_FILE **p) | |
996 | { | |
997 | _IO_FILE *fp = *p; | |
998 | if ((fp->_flags & _IO_USER_LOCK) == 0) | |
999 | _IO_funlockfile (fp); | |
1000 | } |