1 /* Copyright (C) 1993, 1997-2003,2004,2005,2006,2007,2012
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>.
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. */
30 # define __set_errno(Val) errno = (Val)
32 #if defined __GLIBC__ && __GLIBC__ >= 2
33 # include <bits/libc-lock.h>
35 /*# include <comthread.h>*/
38 #include <math_ldbl_opt.h>
42 /* Control of exported symbols. Used in glibc. By default we don't
44 #ifndef libc_hidden_proto
45 # define libc_hidden_proto(name)
47 #ifndef libc_hidden_def
48 # define libc_hidden_def(name)
50 #ifndef libc_hidden_weak
51 # define libc_hidden_weak(name)
58 #define _IO_seek_set 0
59 #define _IO_seek_cur 1
60 #define _IO_seek_end 2
62 /* THE JUMPTABLE FUNCTIONS.
64 * The _IO_FILE type is used to implement the FILE type in GNU libc,
65 * as well as the streambuf class in GNU iostreams for C++.
66 * These are all the same, just used differently.
67 * An _IO_FILE (or FILE) object is allows followed by a pointer to
68 * a jump table (of pointers to functions). The pointer is accessed
69 * with the _IO_JUMPS macro. The jump table has a eccentric format,
70 * so as to be compatible with the layout of a C++ virtual function table.
71 * (as implemented by g++). When a pointer to a streambuf object is
72 * coerced to an (_IO_FILE*), then _IO_JUMPS on the result just
73 * happens to point to the virtual function table of the streambuf.
74 * Thus the _IO_JUMPS function table used for C stdio/libio does
75 * double duty as the virtual function table for C++ streambuf.
77 * The entries in the _IO_JUMPS function table (and hence also the
78 * virtual functions of a streambuf) are described below.
79 * The first parameter of each function entry is the _IO_FILE/streambuf
80 * object being acted on (i.e. the 'this' parameter).
84 # include <shlib-compat.h>
85 # if !SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
86 /* Setting this macro disables the use of the _vtable_offset
87 bias in _IO_JUMPS_FUNCS, below. That is only needed if we
88 want to support old binaries (see oldfileops.c). */
89 # define _G_IO_NO_BACKWARD_COMPAT 1
93 #if (!defined _IO_USE_OLD_IO_FILE \
94 && (!defined _G_IO_NO_BACKWARD_COMPAT || _G_IO_NO_BACKWARD_COMPAT == 0))
95 # define _IO_JUMPS_OFFSET 1
98 #define _IO_JUMPS(THIS) (THIS)->vtable
99 #define _IO_WIDE_JUMPS(THIS) ((struct _IO_FILE *) (THIS))->_wide_data->_wide_vtable
100 #define _IO_CHECK_WIDE(THIS) (((struct _IO_FILE *) (THIS))->_wide_data != NULL)
103 # define _IO_JUMPS_FUNC(THIS) \
104 (*(struct _IO_jump_t **) ((void *) &_IO_JUMPS ((struct _IO_FILE_plus *) (THIS)) \
105 + (THIS)->_vtable_offset))
106 # define _IO_vtable_offset(THIS) (THIS)->_vtable_offset
108 # define _IO_JUMPS_FUNC(THIS) _IO_JUMPS ((struct _IO_FILE_plus *) (THIS))
109 # define _IO_vtable_offset(THIS) 0
111 #define _IO_WIDE_JUMPS_FUNC(THIS) _IO_WIDE_JUMPS(THIS)
112 #ifdef _G_USING_THUNKS
113 # define JUMP_FIELD(TYPE, NAME) TYPE NAME
114 # define JUMP0(FUNC, THIS) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS)
115 # define JUMP1(FUNC, THIS, X1) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1)
116 # define JUMP2(FUNC, THIS, X1, X2) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2)
117 # define JUMP3(FUNC, THIS, X1,X2,X3) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3)
118 # define JUMP_INIT(NAME, VALUE) VALUE
119 # define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT (dummy2, 0)
121 # define WJUMP0(FUNC, THIS) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS)
122 # define WJUMP1(FUNC, THIS, X1) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1)
123 # define WJUMP2(FUNC, THIS, X1, X2) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2)
124 # define WJUMP3(FUNC, THIS, X1,X2,X3) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3)
126 /* These macros will change when we re-implement vtables to use "thunks"! */
127 # define JUMP_FIELD(TYPE, NAME) struct { short delta1, delta2; TYPE pfn; } NAME
128 # define JUMP0(FUNC, THIS) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS)
129 # define JUMP1(FUNC, THIS, X1) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1)
130 # define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1, X2)
131 # define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1,X2,X3)
132 # define JUMP_INIT(NAME, VALUE) {0, 0, VALUE}
133 # define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0)
135 # define WJUMP0(FUNC, THIS) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS)
136 # define WJUMP1(FUNC, THIS, X1) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1)
137 # define WJUMP2(FUNC, THIS, X1, X2) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1, X2)
138 # define WJUMP3(FUNC, THIS, X1,X2,X3) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1,X2,X3)
141 /* The 'finish' function does any final cleaning up of an _IO_FILE object.
142 It does not delete (free) it, but does everything else to finalize it.
143 It matches the streambuf::~streambuf virtual destructor. */
144 typedef void (*_IO_finish_t) (_IO_FILE *, int); /* finalize */
145 #define _IO_FINISH(FP) JUMP1 (__finish, FP, 0)
146 #define _IO_WFINISH(FP) WJUMP1 (__finish, FP, 0)
148 /* The 'overflow' hook flushes the buffer.
149 The second argument is a character, or EOF.
150 It matches the streambuf::overflow virtual function. */
151 typedef int (*_IO_overflow_t) (_IO_FILE *, int);
152 #define _IO_OVERFLOW(FP, CH) JUMP1 (__overflow, FP, CH)
153 #define _IO_WOVERFLOW(FP, CH) WJUMP1 (__overflow, FP, CH)
155 /* The 'underflow' hook tries to fills the get buffer.
156 It returns the next character (as an unsigned char) or EOF. The next
157 character remains in the get buffer, and the get position is not changed.
158 It matches the streambuf::underflow virtual function. */
159 typedef int (*_IO_underflow_t) (_IO_FILE *);
160 #define _IO_UNDERFLOW(FP) JUMP0 (__underflow, FP)
161 #define _IO_WUNDERFLOW(FP) WJUMP0 (__underflow, FP)
163 /* The 'uflow' hook returns the next character in the input stream
164 (cast to unsigned char), and increments the read position;
165 EOF is returned on failure.
166 It matches the streambuf::uflow virtual function, which is not in the
167 cfront implementation, but was added to C++ by the ANSI/ISO committee. */
168 #define _IO_UFLOW(FP) JUMP0 (__uflow, FP)
169 #define _IO_WUFLOW(FP) WJUMP0 (__uflow, FP)
171 /* The 'pbackfail' hook handles backing up.
172 It matches the streambuf::pbackfail virtual function. */
173 typedef int (*_IO_pbackfail_t) (_IO_FILE *, int);
174 #define _IO_PBACKFAIL(FP, CH) JUMP1 (__pbackfail, FP, CH)
175 #define _IO_WPBACKFAIL(FP, CH) WJUMP1 (__pbackfail, FP, CH)
177 /* The 'xsputn' hook writes upto N characters from buffer DATA.
178 Returns the number of character actually written.
179 It matches the streambuf::xsputn virtual function. */
180 typedef _IO_size_t (*_IO_xsputn_t) (_IO_FILE *FP, const void *DATA,
182 #define _IO_XSPUTN(FP, DATA, N) JUMP2 (__xsputn, FP, DATA, N)
183 #define _IO_WXSPUTN(FP, DATA, N) WJUMP2 (__xsputn, FP, DATA, N)
185 /* The 'xsgetn' hook reads upto N characters into buffer DATA.
186 Returns the number of character actually read.
187 It matches the streambuf::xsgetn virtual function. */
188 typedef _IO_size_t (*_IO_xsgetn_t) (_IO_FILE *FP, void *DATA, _IO_size_t N);
189 #define _IO_XSGETN(FP, DATA, N) JUMP2 (__xsgetn, FP, DATA, N)
190 #define _IO_WXSGETN(FP, DATA, N) WJUMP2 (__xsgetn, FP, DATA, N)
192 /* The 'seekoff' hook moves the stream position to a new position
193 relative to the start of the file (if DIR==0), the current position
194 (MODE==1), or the end of the file (MODE==2).
195 It matches the streambuf::seekoff virtual function.
196 It is also used for the ANSI fseek function. */
197 typedef _IO_off64_t (*_IO_seekoff_t) (_IO_FILE *FP, _IO_off64_t OFF, int DIR,
199 #define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3 (__seekoff, FP, OFF, DIR, MODE)
200 #define _IO_WSEEKOFF(FP, OFF, DIR, MODE) WJUMP3 (__seekoff, FP, OFF, DIR, MODE)
202 /* The 'seekpos' hook also moves the stream position,
203 but to an absolute position given by a fpos64_t (seekpos).
204 It matches the streambuf::seekpos virtual function.
205 It is also used for the ANSI fgetpos and fsetpos functions. */
206 /* The _IO_seek_cur and _IO_seek_end options are not allowed. */
207 typedef _IO_off64_t (*_IO_seekpos_t) (_IO_FILE *, _IO_off64_t, int);
208 #define _IO_SEEKPOS(FP, POS, FLAGS) JUMP2 (__seekpos, FP, POS, FLAGS)
209 #define _IO_WSEEKPOS(FP, POS, FLAGS) WJUMP2 (__seekpos, FP, POS, FLAGS)
211 /* The 'setbuf' hook gives a buffer to the file.
212 It matches the streambuf::setbuf virtual function. */
213 typedef _IO_FILE* (*_IO_setbuf_t) (_IO_FILE *, char *, _IO_ssize_t);
214 #define _IO_SETBUF(FP, BUFFER, LENGTH) JUMP2 (__setbuf, FP, BUFFER, LENGTH)
215 #define _IO_WSETBUF(FP, BUFFER, LENGTH) WJUMP2 (__setbuf, FP, BUFFER, LENGTH)
217 /* The 'sync' hook attempts to synchronize the internal data structures
218 of the file with the external state.
219 It matches the streambuf::sync virtual function. */
220 typedef int (*_IO_sync_t) (_IO_FILE *);
221 #define _IO_SYNC(FP) JUMP0 (__sync, FP)
222 #define _IO_WSYNC(FP) WJUMP0 (__sync, FP)
224 /* The 'doallocate' hook is used to tell the file to allocate a buffer.
225 It matches the streambuf::doallocate virtual function, which is not
226 in the ANSI/ISO C++ standard, but is part traditional implementations. */
227 typedef int (*_IO_doallocate_t) (_IO_FILE *);
228 #define _IO_DOALLOCATE(FP) JUMP0 (__doallocate, FP)
229 #define _IO_WDOALLOCATE(FP) WJUMP0 (__doallocate, FP)
231 /* The following four hooks (sysread, syswrite, sysclose, sysseek, and
232 sysstat) are low-level hooks specific to this implementation.
233 There is no correspondence in the ANSI/ISO C++ standard library.
234 The hooks basically correspond to the Unix system functions
235 (read, write, close, lseek, and stat) except that a _IO_FILE*
236 parameter is used instead of a integer file descriptor; the default
237 implementation used for normal files just calls those functions.
238 The advantage of overriding these functions instead of the higher-level
239 ones (underflow, overflow etc) is that you can leave all the buffering
240 higher-level functions. */
242 /* The 'sysread' hook is used to read data from the external file into
243 an existing buffer. It generalizes the Unix read(2) function.
244 It matches the streambuf::sys_read virtual function, which is
245 specific to this implementation. */
246 typedef _IO_ssize_t (*_IO_read_t) (_IO_FILE *, void *, _IO_ssize_t);
247 #define _IO_SYSREAD(FP, DATA, LEN) JUMP2 (__read, FP, DATA, LEN)
248 #define _IO_WSYSREAD(FP, DATA, LEN) WJUMP2 (__read, FP, DATA, LEN)
250 /* The 'syswrite' hook is used to write data from an existing buffer
251 to an external file. It generalizes the Unix write(2) function.
252 It matches the streambuf::sys_write virtual function, which is
253 specific to this implementation. */
254 typedef _IO_ssize_t (*_IO_write_t) (_IO_FILE *, const void *, _IO_ssize_t);
255 #define _IO_SYSWRITE(FP, DATA, LEN) JUMP2 (__write, FP, DATA, LEN)
256 #define _IO_WSYSWRITE(FP, DATA, LEN) WJUMP2 (__write, FP, DATA, LEN)
258 /* The 'sysseek' hook is used to re-position an external file.
259 It generalizes the Unix lseek(2) function.
260 It matches the streambuf::sys_seek virtual function, which is
261 specific to this implementation. */
262 typedef _IO_off64_t (*_IO_seek_t) (_IO_FILE *, _IO_off64_t, int);
263 #define _IO_SYSSEEK(FP, OFFSET, MODE) JUMP2 (__seek, FP, OFFSET, MODE)
264 #define _IO_WSYSSEEK(FP, OFFSET, MODE) WJUMP2 (__seek, FP, OFFSET, MODE)
266 /* The 'sysclose' hook is used to finalize (close, finish up) an
267 external file. It generalizes the Unix close(2) function.
268 It matches the streambuf::sys_close virtual function, which is
269 specific to this implementation. */
270 typedef int (*_IO_close_t) (_IO_FILE *); /* finalize */
271 #define _IO_SYSCLOSE(FP) JUMP0 (__close, FP)
272 #define _IO_WSYSCLOSE(FP) WJUMP0 (__close, FP)
274 /* The 'sysstat' hook is used to get information about an external file
275 into a struct stat buffer. It generalizes the Unix fstat(2) call.
276 It matches the streambuf::sys_stat virtual function, which is
277 specific to this implementation. */
278 typedef int (*_IO_stat_t) (_IO_FILE *, void *);
279 #define _IO_SYSSTAT(FP, BUF) JUMP1 (__stat, FP, BUF)
280 #define _IO_WSYSSTAT(FP, BUF) WJUMP1 (__stat, FP, BUF)
282 /* The 'showmany' hook can be used to get an image how much input is
283 available. In many cases the answer will be 0 which means unknown
284 but some cases one can provide real information. */
285 typedef int (*_IO_showmanyc_t) (_IO_FILE *);
286 #define _IO_SHOWMANYC(FP) JUMP0 (__showmanyc, FP)
287 #define _IO_WSHOWMANYC(FP) WJUMP0 (__showmanyc, FP)
289 /* The 'imbue' hook is used to get information about the currently
290 installed locales. */
291 typedef void (*_IO_imbue_t) (_IO_FILE *, void *);
292 #define _IO_IMBUE(FP, LOCALE) JUMP1 (__imbue, FP, LOCALE)
293 #define _IO_WIMBUE(FP, LOCALE) WJUMP1 (__imbue, FP, LOCALE)
296 #define _IO_CHAR_TYPE char /* unsigned char ? */
297 #define _IO_INT_TYPE int
301 JUMP_FIELD(_G_size_t, __dummy);
302 #ifdef _G_USING_THUNKS
303 JUMP_FIELD(_G_size_t, __dummy2);
305 JUMP_FIELD(_IO_finish_t, __finish);
306 JUMP_FIELD(_IO_overflow_t, __overflow);
307 JUMP_FIELD(_IO_underflow_t, __underflow);
308 JUMP_FIELD(_IO_underflow_t, __uflow);
309 JUMP_FIELD(_IO_pbackfail_t, __pbackfail);
311 JUMP_FIELD(_IO_xsputn_t, __xsputn);
312 JUMP_FIELD(_IO_xsgetn_t, __xsgetn);
313 JUMP_FIELD(_IO_seekoff_t, __seekoff);
314 JUMP_FIELD(_IO_seekpos_t, __seekpos);
315 JUMP_FIELD(_IO_setbuf_t, __setbuf);
316 JUMP_FIELD(_IO_sync_t, __sync);
317 JUMP_FIELD(_IO_doallocate_t, __doallocate);
318 JUMP_FIELD(_IO_read_t, __read);
319 JUMP_FIELD(_IO_write_t, __write);
320 JUMP_FIELD(_IO_seek_t, __seek);
321 JUMP_FIELD(_IO_close_t, __close);
322 JUMP_FIELD(_IO_stat_t, __stat);
323 JUMP_FIELD(_IO_showmanyc_t, __showmanyc);
324 JUMP_FIELD(_IO_imbue_t, __imbue);
331 /* We always allocate an extra word following an _IO_FILE.
332 This contains a pointer to the function jump table used.
333 This is for compatibility with C++ streambuf; the word can
334 be used to smash to a pointer to a virtual function table. */
339 const struct _IO_jump_t *vtable;
342 #ifdef _IO_USE_OLD_IO_FILE
343 /* This structure is used by the compatibility code as if it were an
344 _IO_FILE_plus, but has enough space to initialize the _mode argument
345 of an _IO_FILE_complete. */
346 struct _IO_FILE_complete_plus
348 struct _IO_FILE_complete file;
349 const struct _IO_jump_t *vtable;
353 /* Special file type for fopencookie function. */
354 struct _IO_cookie_file
356 struct _IO_FILE_plus __fp;
358 _IO_cookie_io_functions_t __io_functions;
361 _IO_FILE *_IO_fopencookie (void *cookie, const char *mode,
362 _IO_cookie_io_functions_t io_functions);
365 /* Iterator type for walking global linked list of _IO_FILE objects. */
367 typedef struct _IO_FILE *_IO_ITER;
369 /* Generic functions */
371 extern void _IO_switch_to_main_get_area (_IO_FILE *) __THROW;
372 extern void _IO_switch_to_backup_area (_IO_FILE *) __THROW;
373 extern int _IO_switch_to_get_mode (_IO_FILE *);
374 libc_hidden_proto (_IO_switch_to_get_mode)
375 extern void _IO_init (_IO_FILE *, int) __THROW;
376 libc_hidden_proto (_IO_init)
377 extern int _IO_sputbackc (_IO_FILE *, int) __THROW;
378 libc_hidden_proto (_IO_sputbackc)
379 extern int _IO_sungetc (_IO_FILE *) __THROW;
380 extern void _IO_un_link (struct _IO_FILE_plus *) __THROW;
381 libc_hidden_proto (_IO_un_link)
382 extern void _IO_link_in (struct _IO_FILE_plus *) __THROW;
383 libc_hidden_proto (_IO_link_in)
384 extern void _IO_doallocbuf (_IO_FILE *) __THROW;
385 libc_hidden_proto (_IO_doallocbuf)
386 extern void _IO_unsave_markers (_IO_FILE *) __THROW;
387 libc_hidden_proto (_IO_unsave_markers)
388 extern void _IO_setb (_IO_FILE *, char *, char *, int) __THROW;
389 libc_hidden_proto (_IO_setb)
390 extern unsigned _IO_adjust_column (unsigned, const char *, int) __THROW;
391 libc_hidden_proto (_IO_adjust_column)
392 #define _IO_sputn(__fp, __s, __n) _IO_XSPUTN (__fp, __s, __n)
394 _IO_ssize_t _IO_least_wmarker (_IO_FILE *, wchar_t *) __THROW;
395 libc_hidden_proto (_IO_least_wmarker)
396 extern void _IO_switch_to_main_wget_area (_IO_FILE *) __THROW;
397 libc_hidden_proto (_IO_switch_to_main_wget_area)
398 extern void _IO_switch_to_wbackup_area (_IO_FILE *) __THROW;
399 libc_hidden_proto (_IO_switch_to_wbackup_area)
400 extern int _IO_switch_to_wget_mode (_IO_FILE *);
401 libc_hidden_proto (_IO_switch_to_wget_mode)
402 extern void _IO_wsetb (_IO_FILE *, wchar_t *, wchar_t *, int) __THROW;
403 libc_hidden_proto (_IO_wsetb)
404 extern wint_t _IO_sputbackwc (_IO_FILE *, wint_t) __THROW;
405 libc_hidden_proto (_IO_sputbackwc)
406 extern wint_t _IO_sungetwc (_IO_FILE *) __THROW;
407 extern void _IO_wdoallocbuf (_IO_FILE *) __THROW;
408 libc_hidden_proto (_IO_wdoallocbuf)
409 extern void _IO_unsave_wmarkers (_IO_FILE *) __THROW;
410 extern unsigned _IO_adjust_wcolumn (unsigned, const wchar_t *, int) __THROW;
412 /* Marker-related function. */
414 extern void _IO_init_marker (struct _IO_marker *, _IO_FILE *);
415 extern void _IO_init_wmarker (struct _IO_marker *, _IO_FILE *);
416 extern void _IO_remove_marker (struct _IO_marker *) __THROW;
417 extern int _IO_marker_difference (struct _IO_marker *, struct _IO_marker *)
419 extern int _IO_marker_delta (struct _IO_marker *) __THROW;
420 extern int _IO_wmarker_delta (struct _IO_marker *) __THROW;
421 extern int _IO_seekmark (_IO_FILE *, struct _IO_marker *, int) __THROW;
422 extern int _IO_seekwmark (_IO_FILE *, struct _IO_marker *, int) __THROW;
424 /* Functions for iterating global list and dealing with its lock */
426 extern _IO_ITER _IO_iter_begin (void) __THROW;
427 libc_hidden_proto (_IO_iter_begin)
428 extern _IO_ITER _IO_iter_end (void) __THROW;
429 libc_hidden_proto (_IO_iter_end)
430 extern _IO_ITER _IO_iter_next (_IO_ITER) __THROW;
431 libc_hidden_proto (_IO_iter_next)
432 extern _IO_FILE *_IO_iter_file (_IO_ITER) __THROW;
433 libc_hidden_proto (_IO_iter_file)
434 extern void _IO_list_lock (void) __THROW;
435 libc_hidden_proto (_IO_list_lock)
436 extern void _IO_list_unlock (void) __THROW;
437 libc_hidden_proto (_IO_list_unlock)
438 extern void _IO_list_resetlock (void) __THROW;
439 libc_hidden_proto (_IO_list_resetlock)
441 /* Default jumptable functions. */
443 extern int _IO_default_underflow (_IO_FILE *) __THROW;
444 extern int _IO_default_uflow (_IO_FILE *);
445 libc_hidden_proto (_IO_default_uflow)
446 extern wint_t _IO_wdefault_uflow (_IO_FILE *);
447 libc_hidden_proto (_IO_wdefault_uflow)
448 extern int _IO_default_doallocate (_IO_FILE *) __THROW;
449 libc_hidden_proto (_IO_default_doallocate)
450 extern int _IO_wdefault_doallocate (_IO_FILE *) __THROW;
451 libc_hidden_proto (_IO_wdefault_doallocate)
452 extern void _IO_default_finish (_IO_FILE *, int) __THROW;
453 libc_hidden_proto (_IO_default_finish)
454 extern void _IO_wdefault_finish (_IO_FILE *, int) __THROW;
455 libc_hidden_proto (_IO_wdefault_finish)
456 extern int _IO_default_pbackfail (_IO_FILE *, int) __THROW;
457 libc_hidden_proto (_IO_default_pbackfail)
458 extern wint_t _IO_wdefault_pbackfail (_IO_FILE *, wint_t) __THROW;
459 libc_hidden_proto (_IO_wdefault_pbackfail)
460 extern _IO_FILE* _IO_default_setbuf (_IO_FILE *, char *, _IO_ssize_t);
461 extern _IO_size_t _IO_default_xsputn (_IO_FILE *, const void *, _IO_size_t);
462 libc_hidden_proto (_IO_default_xsputn)
463 extern _IO_size_t _IO_wdefault_xsputn (_IO_FILE *, const void *, _IO_size_t);
464 libc_hidden_proto (_IO_wdefault_xsputn)
465 extern _IO_size_t _IO_default_xsgetn (_IO_FILE *, void *, _IO_size_t);
466 libc_hidden_proto (_IO_default_xsgetn)
467 extern _IO_size_t _IO_wdefault_xsgetn (_IO_FILE *, void *, _IO_size_t);
468 libc_hidden_proto (_IO_wdefault_xsgetn)
469 extern _IO_off64_t _IO_default_seekoff (_IO_FILE *, _IO_off64_t, int, int)
471 extern _IO_off64_t _IO_default_seekpos (_IO_FILE *, _IO_off64_t, int);
472 extern _IO_ssize_t _IO_default_write (_IO_FILE *, const void *, _IO_ssize_t);
473 extern _IO_ssize_t _IO_default_read (_IO_FILE *, void *, _IO_ssize_t);
474 extern int _IO_default_stat (_IO_FILE *, void *) __THROW;
475 extern _IO_off64_t _IO_default_seek (_IO_FILE *, _IO_off64_t, int) __THROW;
476 extern int _IO_default_sync (_IO_FILE *) __THROW;
477 #define _IO_default_close ((_IO_close_t) _IO_default_sync)
478 extern int _IO_default_showmanyc (_IO_FILE *) __THROW;
479 extern void _IO_default_imbue (_IO_FILE *, void *) __THROW;
481 extern const struct _IO_jump_t _IO_file_jumps;
482 libc_hidden_proto (_IO_file_jumps)
483 extern const struct _IO_jump_t _IO_file_jumps_mmap attribute_hidden;
484 extern const struct _IO_jump_t _IO_file_jumps_maybe_mmap attribute_hidden;
485 extern const struct _IO_jump_t _IO_wfile_jumps;
486 libc_hidden_proto (_IO_wfile_jumps)
487 extern const struct _IO_jump_t _IO_wfile_jumps_mmap attribute_hidden;
488 extern const struct _IO_jump_t _IO_wfile_jumps_maybe_mmap attribute_hidden;
489 extern const struct _IO_jump_t _IO_old_file_jumps attribute_hidden;
490 extern const struct _IO_jump_t _IO_streambuf_jumps;
491 extern const struct _IO_jump_t _IO_old_proc_jumps attribute_hidden;
492 extern const struct _IO_jump_t _IO_str_jumps attribute_hidden;
493 extern const struct _IO_jump_t _IO_wstr_jumps attribute_hidden;
494 extern const struct _IO_codecvt __libio_codecvt attribute_hidden;
495 extern int _IO_do_write (_IO_FILE *, const char *, _IO_size_t);
496 libc_hidden_proto (_IO_do_write)
497 extern int _IO_new_do_write (_IO_FILE *, const char *, _IO_size_t);
498 extern int _IO_old_do_write (_IO_FILE *, const char *, _IO_size_t);
499 extern int _IO_wdo_write (_IO_FILE *, const wchar_t *, _IO_size_t);
500 libc_hidden_proto (_IO_wdo_write)
501 extern int _IO_flush_all_lockp (int);
502 extern int _IO_flush_all (void);
503 libc_hidden_proto (_IO_flush_all)
504 extern int _IO_cleanup (void);
505 extern void _IO_flush_all_linebuffered (void);
506 libc_hidden_proto (_IO_flush_all_linebuffered)
507 extern int _IO_new_fgetpos (_IO_FILE *, _IO_fpos_t *);
508 extern int _IO_old_fgetpos (_IO_FILE *, _IO_fpos_t *);
509 extern int _IO_new_fsetpos (_IO_FILE *, const _IO_fpos_t *);
510 extern int _IO_old_fsetpos (_IO_FILE *, const _IO_fpos_t *);
511 extern int _IO_new_fgetpos64 (_IO_FILE *, _IO_fpos64_t *);
512 extern int _IO_old_fgetpos64 (_IO_FILE *, _IO_fpos64_t *);
513 extern int _IO_new_fsetpos64 (_IO_FILE *, const _IO_fpos64_t *);
514 extern int _IO_old_fsetpos64 (_IO_FILE *, const _IO_fpos64_t *);
515 extern void _IO_old_init (_IO_FILE *fp, int flags) __THROW;
518 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
519 # define _IO_do_flush(_f) \
521 ? _IO_do_write(_f, (_f)->_IO_write_base, \
522 (_f)->_IO_write_ptr-(_f)->_IO_write_base) \
523 : _IO_wdo_write(_f, (_f)->_wide_data->_IO_write_base, \
524 ((_f)->_wide_data->_IO_write_ptr \
525 - (_f)->_wide_data->_IO_write_base)))
527 # define _IO_do_flush(_f) \
528 _IO_do_write(_f, (_f)->_IO_write_base, \
529 (_f)->_IO_write_ptr-(_f)->_IO_write_base)
531 #define _IO_old_do_flush(_f) \
532 _IO_old_do_write(_f, (_f)->_IO_write_base, \
533 (_f)->_IO_write_ptr-(_f)->_IO_write_base)
534 #define _IO_in_put_mode(_fp) ((_fp)->_flags & _IO_CURRENTLY_PUTTING)
535 #define _IO_mask_flags(fp, f, mask) \
536 ((fp)->_flags = ((fp)->_flags & ~(mask)) | ((f) & (mask)))
537 #define _IO_setg(fp, eb, g, eg) ((fp)->_IO_read_base = (eb),\
538 (fp)->_IO_read_ptr = (g), (fp)->_IO_read_end = (eg))
539 #define _IO_wsetg(fp, eb, g, eg) ((fp)->_wide_data->_IO_read_base = (eb),\
540 (fp)->_wide_data->_IO_read_ptr = (g), \
541 (fp)->_wide_data->_IO_read_end = (eg))
542 #define _IO_setp(__fp, __p, __ep) \
543 ((__fp)->_IO_write_base = (__fp)->_IO_write_ptr \
544 = __p, (__fp)->_IO_write_end = (__ep))
545 #define _IO_wsetp(__fp, __p, __ep) \
546 ((__fp)->_wide_data->_IO_write_base \
547 = (__fp)->_wide_data->_IO_write_ptr = __p, \
548 (__fp)->_wide_data->_IO_write_end = (__ep))
549 #define _IO_have_backup(fp) ((fp)->_IO_save_base != NULL)
550 #define _IO_have_wbackup(fp) ((fp)->_wide_data->_IO_save_base != NULL)
551 #define _IO_in_backup(fp) ((fp)->_flags & _IO_IN_BACKUP)
552 #define _IO_have_markers(fp) ((fp)->_markers != NULL)
553 #define _IO_blen(fp) ((fp)->_IO_buf_end - (fp)->_IO_buf_base)
554 #define _IO_wblen(fp) ((fp)->_wide_data->_IO_buf_end \
555 - (fp)->_wide_data->_IO_buf_base)
557 /* Jumptable functions for files. */
559 extern int _IO_file_doallocate (_IO_FILE *) __THROW;
560 libc_hidden_proto (_IO_file_doallocate)
561 extern _IO_FILE* _IO_file_setbuf (_IO_FILE *, char *, _IO_ssize_t);
562 libc_hidden_proto (_IO_file_setbuf)
563 extern _IO_off64_t _IO_file_seekoff (_IO_FILE *, _IO_off64_t, int, int);
564 libc_hidden_proto (_IO_file_seekoff)
565 extern _IO_off64_t _IO_file_seekoff_mmap (_IO_FILE *, _IO_off64_t, int, int)
567 extern _IO_size_t _IO_file_xsputn (_IO_FILE *, const void *, _IO_size_t);
568 libc_hidden_proto (_IO_file_xsputn)
569 extern _IO_size_t _IO_file_xsgetn (_IO_FILE *, void *, _IO_size_t);
570 libc_hidden_proto (_IO_file_xsgetn)
571 extern int _IO_file_stat (_IO_FILE *, void *) __THROW;
572 libc_hidden_proto (_IO_file_stat)
573 extern int _IO_file_close (_IO_FILE *) __THROW;
574 libc_hidden_proto (_IO_file_close)
575 extern int _IO_file_close_mmap (_IO_FILE *) __THROW;
576 extern int _IO_file_underflow (_IO_FILE *);
577 libc_hidden_proto (_IO_file_underflow)
578 extern int _IO_file_underflow_mmap (_IO_FILE *);
579 extern int _IO_file_underflow_maybe_mmap (_IO_FILE *);
580 extern int _IO_file_overflow (_IO_FILE *, int);
581 libc_hidden_proto (_IO_file_overflow)
582 #define _IO_file_is_open(__fp) ((__fp)->_fileno != -1)
583 extern void _IO_file_init (struct _IO_FILE_plus *) __THROW;
584 libc_hidden_proto (_IO_file_init)
585 extern _IO_FILE* _IO_file_attach (_IO_FILE *, int);
586 libc_hidden_proto (_IO_file_attach)
587 extern _IO_FILE* _IO_file_open (_IO_FILE *, const char *, int, int, int, int);
588 libc_hidden_proto (_IO_file_open)
589 extern _IO_FILE* _IO_file_fopen (_IO_FILE *, const char *, const char *, int);
590 libc_hidden_proto (_IO_file_fopen)
591 extern _IO_ssize_t _IO_file_write (_IO_FILE *, const void *, _IO_ssize_t);
592 extern _IO_ssize_t _IO_file_read (_IO_FILE *, void *, _IO_ssize_t);
593 libc_hidden_proto (_IO_file_read)
594 extern int _IO_file_sync (_IO_FILE *);
595 libc_hidden_proto (_IO_file_sync)
596 extern int _IO_file_close_it (_IO_FILE *);
597 libc_hidden_proto (_IO_file_close_it)
598 extern _IO_off64_t _IO_file_seek (_IO_FILE *, _IO_off64_t, int) __THROW;
599 libc_hidden_proto (_IO_file_seek)
600 extern void _IO_file_finish (_IO_FILE *, int);
601 libc_hidden_proto (_IO_file_finish)
603 extern _IO_FILE* _IO_new_file_attach (_IO_FILE *, int);
604 extern int _IO_new_file_close_it (_IO_FILE *);
605 extern void _IO_new_file_finish (_IO_FILE *, int);
606 extern _IO_FILE* _IO_new_file_fopen (_IO_FILE *, const char *, const char *,
608 extern void _IO_no_init (_IO_FILE *, int, int, struct _IO_wide_data *,
609 const struct _IO_jump_t *) __THROW;
610 extern void _IO_new_file_init (struct _IO_FILE_plus *) __THROW;
611 extern _IO_FILE* _IO_new_file_setbuf (_IO_FILE *, char *, _IO_ssize_t);
612 extern _IO_FILE* _IO_file_setbuf_mmap (_IO_FILE *, char *, _IO_ssize_t);
613 extern int _IO_new_file_sync (_IO_FILE *);
614 extern int _IO_new_file_underflow (_IO_FILE *);
615 extern int _IO_new_file_overflow (_IO_FILE *, int);
616 extern _IO_off64_t _IO_new_file_seekoff (_IO_FILE *, _IO_off64_t, int, int);
617 extern _IO_ssize_t _IO_new_file_write (_IO_FILE *, const void *, _IO_ssize_t);
618 extern _IO_size_t _IO_new_file_xsputn (_IO_FILE *, const void *, _IO_size_t);
620 extern _IO_FILE* _IO_old_file_setbuf (_IO_FILE *, char *, _IO_ssize_t);
621 extern _IO_off64_t _IO_old_file_seekoff (_IO_FILE *, _IO_off64_t, int, int);
622 extern _IO_size_t _IO_old_file_xsputn (_IO_FILE *, const void *, _IO_size_t);
623 extern int _IO_old_file_underflow (_IO_FILE *);
624 extern int _IO_old_file_overflow (_IO_FILE *, int);
625 extern void _IO_old_file_init (struct _IO_FILE_plus *) __THROW;
626 extern _IO_FILE* _IO_old_file_attach (_IO_FILE *, int);
627 extern _IO_FILE* _IO_old_file_fopen (_IO_FILE *, const char *, const char *);
628 extern _IO_ssize_t _IO_old_file_write (_IO_FILE *, const void *, _IO_ssize_t);
629 extern int _IO_old_file_sync (_IO_FILE *);
630 extern int _IO_old_file_close_it (_IO_FILE *);
631 extern void _IO_old_file_finish (_IO_FILE *, int);
633 extern int _IO_wfile_doallocate (_IO_FILE *) __THROW;
634 extern _IO_size_t _IO_wfile_xsputn (_IO_FILE *, const void *, _IO_size_t);
635 libc_hidden_proto (_IO_wfile_xsputn)
636 extern _IO_FILE* _IO_wfile_setbuf (_IO_FILE *, wchar_t *, _IO_ssize_t);
637 extern wint_t _IO_wfile_sync (_IO_FILE *);
638 libc_hidden_proto (_IO_wfile_sync)
639 extern wint_t _IO_wfile_underflow (_IO_FILE *);
640 libc_hidden_proto (_IO_wfile_underflow)
641 extern wint_t _IO_wfile_overflow (_IO_FILE *, wint_t);
642 libc_hidden_proto (_IO_wfile_overflow)
643 extern _IO_off64_t _IO_wfile_seekoff (_IO_FILE *, _IO_off64_t, int, int);
644 libc_hidden_proto (_IO_wfile_seekoff)
646 /* Jumptable functions for proc_files. */
647 extern _IO_FILE* _IO_proc_open (_IO_FILE *, const char *, const char *)
649 extern _IO_FILE* _IO_new_proc_open (_IO_FILE *, const char *, const char *)
651 extern _IO_FILE* _IO_old_proc_open (_IO_FILE *, const char *, const char *);
652 extern int _IO_proc_close (_IO_FILE *) __THROW;
653 extern int _IO_new_proc_close (_IO_FILE *) __THROW;
654 extern int _IO_old_proc_close (_IO_FILE *);
656 /* Jumptable functions for strfiles. */
657 extern int _IO_str_underflow (_IO_FILE *) __THROW;
658 libc_hidden_proto (_IO_str_underflow)
659 extern int _IO_str_overflow (_IO_FILE *, int) __THROW;
660 libc_hidden_proto (_IO_str_overflow)
661 extern int _IO_str_pbackfail (_IO_FILE *, int) __THROW;
662 libc_hidden_proto (_IO_str_pbackfail)
663 extern _IO_off64_t _IO_str_seekoff (_IO_FILE *, _IO_off64_t, int, int) __THROW;
664 libc_hidden_proto (_IO_str_seekoff)
665 extern void _IO_str_finish (_IO_FILE *, int) __THROW;
667 /* Other strfile functions */
669 extern void _IO_str_init_static (struct _IO_strfile_ *, char *, int, char *)
671 extern void _IO_str_init_readonly (struct _IO_strfile_ *, const char *, int)
673 extern _IO_ssize_t _IO_str_count (_IO_FILE *) __THROW;
675 /* And the wide character versions. */
676 extern void _IO_wstr_init_static (_IO_FILE *, wchar_t *, _IO_size_t, wchar_t *)
678 extern _IO_ssize_t _IO_wstr_count (_IO_FILE *) __THROW;
679 extern _IO_wint_t _IO_wstr_overflow (_IO_FILE *, _IO_wint_t) __THROW;
680 extern _IO_wint_t _IO_wstr_underflow (_IO_FILE *) __THROW;
681 extern _IO_off64_t _IO_wstr_seekoff (_IO_FILE *, _IO_off64_t, int, int)
683 extern _IO_wint_t _IO_wstr_pbackfail (_IO_FILE *, _IO_wint_t) __THROW;
684 extern void _IO_wstr_finish (_IO_FILE *, int) __THROW;
686 extern int _IO_vasprintf (char **result_ptr, const char *format,
687 _IO_va_list args) __THROW;
688 extern int _IO_vdprintf (int d, const char *format, _IO_va_list arg);
689 extern int _IO_vsnprintf (char *string, _IO_size_t maxlen,
690 const char *format, _IO_va_list args) __THROW;
693 extern _IO_size_t _IO_getline (_IO_FILE *,char *, _IO_size_t, int, int);
694 libc_hidden_proto (_IO_getline)
695 extern _IO_size_t _IO_getline_info (_IO_FILE *,char *, _IO_size_t,
697 libc_hidden_proto (_IO_getline_info)
698 extern _IO_ssize_t _IO_getdelim (char **, _IO_size_t *, int, _IO_FILE *);
699 extern _IO_size_t _IO_getwline (_IO_FILE *,wchar_t *, _IO_size_t, wint_t, int);
700 extern _IO_size_t _IO_getwline_info (_IO_FILE *,wchar_t *, _IO_size_t,
701 wint_t, int, wint_t *);
703 extern struct _IO_FILE_plus *_IO_list_all;
704 libc_hidden_proto (_IO_list_all)
705 extern void (*_IO_cleanup_registration_needed) (void);
707 extern void _IO_str_init_static_internal (struct _IO_strfile_ *, char *,
708 _IO_size_t, char *) __THROW;
709 extern _IO_off64_t _IO_seekoff_unlocked (_IO_FILE *, _IO_off64_t, int, int)
711 extern _IO_off64_t _IO_seekpos_unlocked (_IO_FILE *, _IO_off64_t, int)
718 # if defined __GNUG__ && \
719 (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
720 # define NULL (__null)
722 # if !defined(__cplusplus)
723 # define NULL ((void*)0)
734 # include <sys/mman.h>
735 # include <sys/param.h>
737 # if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
738 # define MAP_ANONYMOUS MAP_ANON
741 # if !defined(MAP_ANONYMOUS) || !defined(EXEC_PAGESIZE)
743 # define _G_HAVE_MMAP 0
746 #endif /* _G_HAVE_MMAP */
751 /* When using this code in the GNU libc we must not pollute the name space. */
753 # define munmap __munmap
754 # define ftruncate __ftruncate
757 # define ROUND_TO_PAGE(_S) \
758 (((_S) + EXEC_PAGESIZE - 1) & ~(EXEC_PAGESIZE - 1))
760 # define FREE_BUF(_B, _S) \
761 munmap ((_B), ROUND_TO_PAGE (_S))
762 # define ALLOC_BUF(_B, _S, _R) \
764 (_B) = (char *) mmap (0, ROUND_TO_PAGE (_S), \
765 PROT_READ | PROT_WRITE, \
766 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \
767 if ((_B) == (char *) MAP_FAILED) \
770 # define ALLOC_WBUF(_B, _S, _R) \
772 (_B) = (wchar_t *) mmap (0, ROUND_TO_PAGE (_S), \
773 PROT_READ | PROT_WRITE, \
774 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \
775 if ((_B) == (wchar_t *) MAP_FAILED) \
779 #else /* _G_HAVE_MMAP */
781 # define FREE_BUF(_B, _S) \
783 # define ALLOC_BUF(_B, _S, _R) \
785 (_B) = (char*)malloc(_S); \
789 # define ALLOC_WBUF(_B, _S, _R) \
791 (_B) = (wchar_t *)malloc(_S); \
796 #endif /* _G_HAVE_MMAP */
799 # define OS_FSTAT fstat
801 extern int _IO_vscanf (const char *, _IO_va_list) __THROW;
803 /* _IO_pos_BAD is an _IO_off64_t value indicating error, unknown, or EOF. */
805 # define _IO_pos_BAD ((_IO_off64_t) -1)
807 /* _IO_pos_adjust adjust an _IO_off64_t by some number of bytes. */
808 #ifndef _IO_pos_adjust
809 # define _IO_pos_adjust(pos, delta) ((pos) += (delta))
811 /* _IO_pos_0 is an _IO_off64_t value indicating beginning of file. */
813 # define _IO_pos_0 ((_IO_off64_t) 0)
821 /* check following! */
822 # ifdef _IO_USE_OLD_IO_FILE
823 # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
824 { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
825 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
826 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock }
828 # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
829 # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
830 { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
831 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
832 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\
835 # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
836 { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
837 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
838 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\
843 # ifdef _IO_USE_OLD_IO_FILE
844 # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
845 { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
846 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
849 # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
850 # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
851 { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
852 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
853 0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \
856 # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
857 { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
858 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
859 0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \
865 #define _IO_va_start(args, last) va_start(args, last)
867 extern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf;
870 # define COERCE_FILE(FILE) /* Nothing */
872 /* This is part of the kludge for binary compatibility with old stdio. */
873 # define COERCE_FILE(FILE) \
874 (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) == _OLD_MAGIC_MASK \
875 && (FILE) = *(FILE**)&((int*)fp)[1])
879 # define MAYBE_SET_EINVAL __set_errno (EINVAL)
881 # define MAYBE_SET_EINVAL /* nothing */
885 # define CHECK_FILE(FILE, RET) \
886 if ((FILE) == NULL) { MAYBE_SET_EINVAL; return RET; } \
887 else { COERCE_FILE(FILE); \
888 if (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \
889 { MAYBE_SET_EINVAL; return RET; }}
891 # define CHECK_FILE(FILE, RET) COERCE_FILE (FILE)
895 __attribute__ ((__always_inline__))
896 _IO_acquire_lock_fct (_IO_FILE **p)
899 if ((fp->_flags & _IO_USER_LOCK) == 0)
900 _IO_funlockfile (fp);
904 __attribute__ ((__always_inline__))
905 _IO_acquire_lock_clear_flags2_fct (_IO_FILE **p)
908 fp->_flags2 &= ~(_IO_FLAGS2_FORTIFY | _IO_FLAGS2_SCANF_STD);
909 if ((fp->_flags & _IO_USER_LOCK) == 0)
910 _IO_funlockfile (fp);
913 #if !defined _IO_MTSAFE_IO && !defined NOT_IN_libc
914 # define _IO_acquire_lock(_fp) \
916 _IO_FILE *_IO_acquire_lock_file = NULL
917 # define _IO_acquire_lock_clear_flags2(_fp) \
919 _IO_FILE *_IO_acquire_lock_file = (_fp)
920 # define _IO_release_lock(_fp) \
921 if (_IO_acquire_lock_file != NULL) \
922 _IO_acquire_lock_file->_flags2 &= ~(_IO_FLAGS2_FORTIFY \
923 | _IO_FLAGS2_SCANF_STD); \