Improve ChangeLog entry for x86_64 strncmp-ssse3.S
[glibc.git] / libio / libioP.h
bloba2800524ec1d04568a59dca6978a0ea2d4f18269
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. */
28 #include <errno.h>
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
38 #include <math_ldbl_opt.h>
40 #include "iolibio.h"
42 /* Control of exported symbols. Used in glibc. By default we don't
43 do anything. */
44 #ifndef libc_hidden_proto
45 # define libc_hidden_proto(name)
46 #endif
47 #ifndef libc_hidden_def
48 # define libc_hidden_def(name)
49 #endif
50 #ifndef libc_hidden_weak
51 # define libc_hidden_weak(name)
52 #endif
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
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).
83 #ifdef _LIBC
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
90 # endif
91 #endif
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
96 #endif
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)
102 #if _IO_JUMPS_OFFSET
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
107 #else
108 # define _IO_JUMPS_FUNC(THIS) _IO_JUMPS ((struct _IO_FILE_plus *) (THIS))
109 # define _IO_vtable_offset(THIS) 0
110 #endif
111 #define _IO_WIDE_JUMPS_FUNC(THIS) _IO_WIDE_JUMPS(THIS)
112 #define JUMP_FIELD(TYPE, NAME) TYPE NAME
113 #define JUMP0(FUNC, THIS) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS)
114 #define JUMP1(FUNC, THIS, X1) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1)
115 #define JUMP2(FUNC, THIS, X1, X2) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2)
116 #define JUMP3(FUNC, THIS, X1,X2,X3) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3)
117 #define JUMP_INIT(NAME, VALUE) VALUE
118 #define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT (dummy2, 0)
120 #define WJUMP0(FUNC, THIS) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS)
121 #define WJUMP1(FUNC, THIS, X1) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1)
122 #define WJUMP2(FUNC, THIS, X1, X2) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2)
123 #define WJUMP3(FUNC, THIS, X1,X2,X3) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3)
125 /* The 'finish' function does any final cleaning up of an _IO_FILE object.
126 It does not delete (free) it, but does everything else to finalize it.
127 It matches the streambuf::~streambuf virtual destructor. */
128 typedef void (*_IO_finish_t) (_IO_FILE *, int); /* finalize */
129 #define _IO_FINISH(FP) JUMP1 (__finish, FP, 0)
130 #define _IO_WFINISH(FP) WJUMP1 (__finish, FP, 0)
132 /* The 'overflow' hook flushes the buffer.
133 The second argument is a character, or EOF.
134 It matches the streambuf::overflow virtual function. */
135 typedef int (*_IO_overflow_t) (_IO_FILE *, int);
136 #define _IO_OVERFLOW(FP, CH) JUMP1 (__overflow, FP, CH)
137 #define _IO_WOVERFLOW(FP, CH) WJUMP1 (__overflow, FP, CH)
139 /* The 'underflow' hook tries to fills the get buffer.
140 It returns the next character (as an unsigned char) or EOF. The next
141 character remains in the get buffer, and the get position is not changed.
142 It matches the streambuf::underflow virtual function. */
143 typedef int (*_IO_underflow_t) (_IO_FILE *);
144 #define _IO_UNDERFLOW(FP) JUMP0 (__underflow, FP)
145 #define _IO_WUNDERFLOW(FP) WJUMP0 (__underflow, FP)
147 /* The 'uflow' hook returns the next character in the input stream
148 (cast to unsigned char), and increments the read position;
149 EOF is returned on failure.
150 It matches the streambuf::uflow virtual function, which is not in the
151 cfront implementation, but was added to C++ by the ANSI/ISO committee. */
152 #define _IO_UFLOW(FP) JUMP0 (__uflow, FP)
153 #define _IO_WUFLOW(FP) WJUMP0 (__uflow, FP)
155 /* The 'pbackfail' hook handles backing up.
156 It matches the streambuf::pbackfail virtual function. */
157 typedef int (*_IO_pbackfail_t) (_IO_FILE *, int);
158 #define _IO_PBACKFAIL(FP, CH) JUMP1 (__pbackfail, FP, CH)
159 #define _IO_WPBACKFAIL(FP, CH) WJUMP1 (__pbackfail, FP, CH)
161 /* The 'xsputn' hook writes upto N characters from buffer DATA.
162 Returns the number of character actually written.
163 It matches the streambuf::xsputn virtual function. */
164 typedef _IO_size_t (*_IO_xsputn_t) (_IO_FILE *FP, const void *DATA,
165 _IO_size_t N);
166 #define _IO_XSPUTN(FP, DATA, N) JUMP2 (__xsputn, FP, DATA, N)
167 #define _IO_WXSPUTN(FP, DATA, N) WJUMP2 (__xsputn, FP, DATA, N)
169 /* The 'xsgetn' hook reads upto N characters into buffer DATA.
170 Returns the number of character actually read.
171 It matches the streambuf::xsgetn virtual function. */
172 typedef _IO_size_t (*_IO_xsgetn_t) (_IO_FILE *FP, void *DATA, _IO_size_t N);
173 #define _IO_XSGETN(FP, DATA, N) JUMP2 (__xsgetn, FP, DATA, N)
174 #define _IO_WXSGETN(FP, DATA, N) WJUMP2 (__xsgetn, FP, DATA, N)
176 /* The 'seekoff' hook moves the stream position to a new position
177 relative to the start of the file (if DIR==0), the current position
178 (MODE==1), or the end of the file (MODE==2).
179 It matches the streambuf::seekoff virtual function.
180 It is also used for the ANSI fseek function. */
181 typedef _IO_off64_t (*_IO_seekoff_t) (_IO_FILE *FP, _IO_off64_t OFF, int DIR,
182 int MODE);
183 #define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3 (__seekoff, FP, OFF, DIR, MODE)
184 #define _IO_WSEEKOFF(FP, OFF, DIR, MODE) WJUMP3 (__seekoff, FP, OFF, DIR, MODE)
186 /* The 'seekpos' hook also moves the stream position,
187 but to an absolute position given by a fpos64_t (seekpos).
188 It matches the streambuf::seekpos virtual function.
189 It is also used for the ANSI fgetpos and fsetpos functions. */
190 /* The _IO_seek_cur and _IO_seek_end options are not allowed. */
191 typedef _IO_off64_t (*_IO_seekpos_t) (_IO_FILE *, _IO_off64_t, int);
192 #define _IO_SEEKPOS(FP, POS, FLAGS) JUMP2 (__seekpos, FP, POS, FLAGS)
193 #define _IO_WSEEKPOS(FP, POS, FLAGS) WJUMP2 (__seekpos, FP, POS, FLAGS)
195 /* The 'setbuf' hook gives a buffer to the file.
196 It matches the streambuf::setbuf virtual function. */
197 typedef _IO_FILE* (*_IO_setbuf_t) (_IO_FILE *, char *, _IO_ssize_t);
198 #define _IO_SETBUF(FP, BUFFER, LENGTH) JUMP2 (__setbuf, FP, BUFFER, LENGTH)
199 #define _IO_WSETBUF(FP, BUFFER, LENGTH) WJUMP2 (__setbuf, FP, BUFFER, LENGTH)
201 /* The 'sync' hook attempts to synchronize the internal data structures
202 of the file with the external state.
203 It matches the streambuf::sync virtual function. */
204 typedef int (*_IO_sync_t) (_IO_FILE *);
205 #define _IO_SYNC(FP) JUMP0 (__sync, FP)
206 #define _IO_WSYNC(FP) WJUMP0 (__sync, FP)
208 /* The 'doallocate' hook is used to tell the file to allocate a buffer.
209 It matches the streambuf::doallocate virtual function, which is not
210 in the ANSI/ISO C++ standard, but is part traditional implementations. */
211 typedef int (*_IO_doallocate_t) (_IO_FILE *);
212 #define _IO_DOALLOCATE(FP) JUMP0 (__doallocate, FP)
213 #define _IO_WDOALLOCATE(FP) WJUMP0 (__doallocate, FP)
215 /* The following four hooks (sysread, syswrite, sysclose, sysseek, and
216 sysstat) are low-level hooks specific to this implementation.
217 There is no correspondence in the ANSI/ISO C++ standard library.
218 The hooks basically correspond to the Unix system functions
219 (read, write, close, lseek, and stat) except that a _IO_FILE*
220 parameter is used instead of a integer file descriptor; the default
221 implementation used for normal files just calls those functions.
222 The advantage of overriding these functions instead of the higher-level
223 ones (underflow, overflow etc) is that you can leave all the buffering
224 higher-level functions. */
226 /* The 'sysread' hook is used to read data from the external file into
227 an existing buffer. It generalizes the Unix read(2) function.
228 It matches the streambuf::sys_read virtual function, which is
229 specific to this implementation. */
230 typedef _IO_ssize_t (*_IO_read_t) (_IO_FILE *, void *, _IO_ssize_t);
231 #define _IO_SYSREAD(FP, DATA, LEN) JUMP2 (__read, FP, DATA, LEN)
232 #define _IO_WSYSREAD(FP, DATA, LEN) WJUMP2 (__read, FP, DATA, LEN)
234 /* The 'syswrite' hook is used to write data from an existing buffer
235 to an external file. It generalizes the Unix write(2) function.
236 It matches the streambuf::sys_write virtual function, which is
237 specific to this implementation. */
238 typedef _IO_ssize_t (*_IO_write_t) (_IO_FILE *, const void *, _IO_ssize_t);
239 #define _IO_SYSWRITE(FP, DATA, LEN) JUMP2 (__write, FP, DATA, LEN)
240 #define _IO_WSYSWRITE(FP, DATA, LEN) WJUMP2 (__write, FP, DATA, LEN)
242 /* The 'sysseek' hook is used to re-position an external file.
243 It generalizes the Unix lseek(2) function.
244 It matches the streambuf::sys_seek virtual function, which is
245 specific to this implementation. */
246 typedef _IO_off64_t (*_IO_seek_t) (_IO_FILE *, _IO_off64_t, int);
247 #define _IO_SYSSEEK(FP, OFFSET, MODE) JUMP2 (__seek, FP, OFFSET, MODE)
248 #define _IO_WSYSSEEK(FP, OFFSET, MODE) WJUMP2 (__seek, FP, OFFSET, MODE)
250 /* The 'sysclose' hook is used to finalize (close, finish up) an
251 external file. It generalizes the Unix close(2) function.
252 It matches the streambuf::sys_close virtual function, which is
253 specific to this implementation. */
254 typedef int (*_IO_close_t) (_IO_FILE *); /* finalize */
255 #define _IO_SYSCLOSE(FP) JUMP0 (__close, FP)
256 #define _IO_WSYSCLOSE(FP) WJUMP0 (__close, FP)
258 /* The 'sysstat' hook is used to get information about an external file
259 into a struct stat buffer. It generalizes the Unix fstat(2) call.
260 It matches the streambuf::sys_stat virtual function, which is
261 specific to this implementation. */
262 typedef int (*_IO_stat_t) (_IO_FILE *, void *);
263 #define _IO_SYSSTAT(FP, BUF) JUMP1 (__stat, FP, BUF)
264 #define _IO_WSYSSTAT(FP, BUF) WJUMP1 (__stat, FP, BUF)
266 /* The 'showmany' hook can be used to get an image how much input is
267 available. In many cases the answer will be 0 which means unknown
268 but some cases one can provide real information. */
269 typedef int (*_IO_showmanyc_t) (_IO_FILE *);
270 #define _IO_SHOWMANYC(FP) JUMP0 (__showmanyc, FP)
271 #define _IO_WSHOWMANYC(FP) WJUMP0 (__showmanyc, FP)
273 /* The 'imbue' hook is used to get information about the currently
274 installed locales. */
275 typedef void (*_IO_imbue_t) (_IO_FILE *, void *);
276 #define _IO_IMBUE(FP, LOCALE) JUMP1 (__imbue, FP, LOCALE)
277 #define _IO_WIMBUE(FP, LOCALE) WJUMP1 (__imbue, FP, LOCALE)
280 #define _IO_CHAR_TYPE char /* unsigned char ? */
281 #define _IO_INT_TYPE int
283 struct _IO_jump_t
285 JUMP_FIELD(size_t, __dummy);
286 JUMP_FIELD(size_t, __dummy2);
287 JUMP_FIELD(_IO_finish_t, __finish);
288 JUMP_FIELD(_IO_overflow_t, __overflow);
289 JUMP_FIELD(_IO_underflow_t, __underflow);
290 JUMP_FIELD(_IO_underflow_t, __uflow);
291 JUMP_FIELD(_IO_pbackfail_t, __pbackfail);
292 /* showmany */
293 JUMP_FIELD(_IO_xsputn_t, __xsputn);
294 JUMP_FIELD(_IO_xsgetn_t, __xsgetn);
295 JUMP_FIELD(_IO_seekoff_t, __seekoff);
296 JUMP_FIELD(_IO_seekpos_t, __seekpos);
297 JUMP_FIELD(_IO_setbuf_t, __setbuf);
298 JUMP_FIELD(_IO_sync_t, __sync);
299 JUMP_FIELD(_IO_doallocate_t, __doallocate);
300 JUMP_FIELD(_IO_read_t, __read);
301 JUMP_FIELD(_IO_write_t, __write);
302 JUMP_FIELD(_IO_seek_t, __seek);
303 JUMP_FIELD(_IO_close_t, __close);
304 JUMP_FIELD(_IO_stat_t, __stat);
305 JUMP_FIELD(_IO_showmanyc_t, __showmanyc);
306 JUMP_FIELD(_IO_imbue_t, __imbue);
307 #if 0
308 get_column;
309 set_column;
310 #endif
313 /* We always allocate an extra word following an _IO_FILE.
314 This contains a pointer to the function jump table used.
315 This is for compatibility with C++ streambuf; the word can
316 be used to smash to a pointer to a virtual function table. */
318 struct _IO_FILE_plus
320 _IO_FILE file;
321 const struct _IO_jump_t *vtable;
324 #ifdef _IO_USE_OLD_IO_FILE
325 /* This structure is used by the compatibility code as if it were an
326 _IO_FILE_plus, but has enough space to initialize the _mode argument
327 of an _IO_FILE_complete. */
328 struct _IO_FILE_complete_plus
330 struct _IO_FILE_complete file;
331 const struct _IO_jump_t *vtable;
333 #endif
335 /* Special file type for fopencookie function. */
336 struct _IO_cookie_file
338 struct _IO_FILE_plus __fp;
339 void *__cookie;
340 _IO_cookie_io_functions_t __io_functions;
343 _IO_FILE *_IO_fopencookie (void *cookie, const char *mode,
344 _IO_cookie_io_functions_t io_functions);
347 /* Iterator type for walking global linked list of _IO_FILE objects. */
349 typedef struct _IO_FILE *_IO_ITER;
351 /* Generic functions */
353 extern void _IO_switch_to_main_get_area (_IO_FILE *) __THROW;
354 extern void _IO_switch_to_backup_area (_IO_FILE *) __THROW;
355 extern int _IO_switch_to_get_mode (_IO_FILE *);
356 libc_hidden_proto (_IO_switch_to_get_mode)
357 extern void _IO_init (_IO_FILE *, int) __THROW;
358 libc_hidden_proto (_IO_init)
359 extern int _IO_sputbackc (_IO_FILE *, int) __THROW;
360 libc_hidden_proto (_IO_sputbackc)
361 extern int _IO_sungetc (_IO_FILE *) __THROW;
362 extern void _IO_un_link (struct _IO_FILE_plus *) __THROW;
363 libc_hidden_proto (_IO_un_link)
364 extern void _IO_link_in (struct _IO_FILE_plus *) __THROW;
365 libc_hidden_proto (_IO_link_in)
366 extern void _IO_doallocbuf (_IO_FILE *) __THROW;
367 libc_hidden_proto (_IO_doallocbuf)
368 extern void _IO_unsave_markers (_IO_FILE *) __THROW;
369 libc_hidden_proto (_IO_unsave_markers)
370 extern void _IO_setb (_IO_FILE *, char *, char *, int) __THROW;
371 libc_hidden_proto (_IO_setb)
372 extern unsigned _IO_adjust_column (unsigned, const char *, int) __THROW;
373 libc_hidden_proto (_IO_adjust_column)
374 #define _IO_sputn(__fp, __s, __n) _IO_XSPUTN (__fp, __s, __n)
376 _IO_ssize_t _IO_least_wmarker (_IO_FILE *, wchar_t *) __THROW;
377 libc_hidden_proto (_IO_least_wmarker)
378 extern void _IO_switch_to_main_wget_area (_IO_FILE *) __THROW;
379 libc_hidden_proto (_IO_switch_to_main_wget_area)
380 extern void _IO_switch_to_wbackup_area (_IO_FILE *) __THROW;
381 libc_hidden_proto (_IO_switch_to_wbackup_area)
382 extern int _IO_switch_to_wget_mode (_IO_FILE *);
383 libc_hidden_proto (_IO_switch_to_wget_mode)
384 extern void _IO_wsetb (_IO_FILE *, wchar_t *, wchar_t *, int) __THROW;
385 libc_hidden_proto (_IO_wsetb)
386 extern wint_t _IO_sputbackwc (_IO_FILE *, wint_t) __THROW;
387 libc_hidden_proto (_IO_sputbackwc)
388 extern wint_t _IO_sungetwc (_IO_FILE *) __THROW;
389 extern void _IO_wdoallocbuf (_IO_FILE *) __THROW;
390 libc_hidden_proto (_IO_wdoallocbuf)
391 extern void _IO_unsave_wmarkers (_IO_FILE *) __THROW;
392 extern unsigned _IO_adjust_wcolumn (unsigned, const wchar_t *, int) __THROW;
394 /* Marker-related function. */
396 extern void _IO_init_marker (struct _IO_marker *, _IO_FILE *);
397 extern void _IO_init_wmarker (struct _IO_marker *, _IO_FILE *);
398 extern void _IO_remove_marker (struct _IO_marker *) __THROW;
399 extern int _IO_marker_difference (struct _IO_marker *, struct _IO_marker *)
400 __THROW;
401 extern int _IO_marker_delta (struct _IO_marker *) __THROW;
402 extern int _IO_wmarker_delta (struct _IO_marker *) __THROW;
403 extern int _IO_seekmark (_IO_FILE *, struct _IO_marker *, int) __THROW;
404 extern int _IO_seekwmark (_IO_FILE *, struct _IO_marker *, int) __THROW;
406 /* Functions for iterating global list and dealing with its lock */
408 extern _IO_ITER _IO_iter_begin (void) __THROW;
409 libc_hidden_proto (_IO_iter_begin)
410 extern _IO_ITER _IO_iter_end (void) __THROW;
411 libc_hidden_proto (_IO_iter_end)
412 extern _IO_ITER _IO_iter_next (_IO_ITER) __THROW;
413 libc_hidden_proto (_IO_iter_next)
414 extern _IO_FILE *_IO_iter_file (_IO_ITER) __THROW;
415 libc_hidden_proto (_IO_iter_file)
416 extern void _IO_list_lock (void) __THROW;
417 libc_hidden_proto (_IO_list_lock)
418 extern void _IO_list_unlock (void) __THROW;
419 libc_hidden_proto (_IO_list_unlock)
420 extern void _IO_list_resetlock (void) __THROW;
421 libc_hidden_proto (_IO_list_resetlock)
423 /* Default jumptable functions. */
425 extern int _IO_default_underflow (_IO_FILE *) __THROW;
426 extern int _IO_default_uflow (_IO_FILE *);
427 libc_hidden_proto (_IO_default_uflow)
428 extern wint_t _IO_wdefault_uflow (_IO_FILE *);
429 libc_hidden_proto (_IO_wdefault_uflow)
430 extern int _IO_default_doallocate (_IO_FILE *) __THROW;
431 libc_hidden_proto (_IO_default_doallocate)
432 extern int _IO_wdefault_doallocate (_IO_FILE *) __THROW;
433 libc_hidden_proto (_IO_wdefault_doallocate)
434 extern void _IO_default_finish (_IO_FILE *, int) __THROW;
435 libc_hidden_proto (_IO_default_finish)
436 extern void _IO_wdefault_finish (_IO_FILE *, int) __THROW;
437 libc_hidden_proto (_IO_wdefault_finish)
438 extern int _IO_default_pbackfail (_IO_FILE *, int) __THROW;
439 libc_hidden_proto (_IO_default_pbackfail)
440 extern wint_t _IO_wdefault_pbackfail (_IO_FILE *, wint_t) __THROW;
441 libc_hidden_proto (_IO_wdefault_pbackfail)
442 extern _IO_FILE* _IO_default_setbuf (_IO_FILE *, char *, _IO_ssize_t);
443 extern _IO_size_t _IO_default_xsputn (_IO_FILE *, const void *, _IO_size_t);
444 libc_hidden_proto (_IO_default_xsputn)
445 extern _IO_size_t _IO_wdefault_xsputn (_IO_FILE *, const void *, _IO_size_t);
446 libc_hidden_proto (_IO_wdefault_xsputn)
447 extern _IO_size_t _IO_default_xsgetn (_IO_FILE *, void *, _IO_size_t);
448 libc_hidden_proto (_IO_default_xsgetn)
449 extern _IO_size_t _IO_wdefault_xsgetn (_IO_FILE *, void *, _IO_size_t);
450 libc_hidden_proto (_IO_wdefault_xsgetn)
451 extern _IO_off64_t _IO_default_seekoff (_IO_FILE *, _IO_off64_t, int, int)
452 __THROW;
453 extern _IO_off64_t _IO_default_seekpos (_IO_FILE *, _IO_off64_t, int);
454 extern _IO_ssize_t _IO_default_write (_IO_FILE *, const void *, _IO_ssize_t);
455 extern _IO_ssize_t _IO_default_read (_IO_FILE *, void *, _IO_ssize_t);
456 extern int _IO_default_stat (_IO_FILE *, void *) __THROW;
457 extern _IO_off64_t _IO_default_seek (_IO_FILE *, _IO_off64_t, int) __THROW;
458 extern int _IO_default_sync (_IO_FILE *) __THROW;
459 #define _IO_default_close ((_IO_close_t) _IO_default_sync)
460 extern int _IO_default_showmanyc (_IO_FILE *) __THROW;
461 extern void _IO_default_imbue (_IO_FILE *, void *) __THROW;
463 extern const struct _IO_jump_t _IO_file_jumps;
464 libc_hidden_proto (_IO_file_jumps)
465 extern const struct _IO_jump_t _IO_file_jumps_mmap attribute_hidden;
466 extern const struct _IO_jump_t _IO_file_jumps_maybe_mmap attribute_hidden;
467 extern const struct _IO_jump_t _IO_wfile_jumps;
468 libc_hidden_proto (_IO_wfile_jumps)
469 extern const struct _IO_jump_t _IO_wfile_jumps_mmap attribute_hidden;
470 extern const struct _IO_jump_t _IO_wfile_jumps_maybe_mmap attribute_hidden;
471 extern const struct _IO_jump_t _IO_old_file_jumps attribute_hidden;
472 extern const struct _IO_jump_t _IO_streambuf_jumps;
473 extern const struct _IO_jump_t _IO_old_proc_jumps attribute_hidden;
474 extern const struct _IO_jump_t _IO_str_jumps attribute_hidden;
475 extern const struct _IO_jump_t _IO_wstr_jumps attribute_hidden;
476 extern const struct _IO_codecvt __libio_codecvt attribute_hidden;
477 extern int _IO_do_write (_IO_FILE *, const char *, _IO_size_t);
478 libc_hidden_proto (_IO_do_write)
479 extern int _IO_new_do_write (_IO_FILE *, const char *, _IO_size_t);
480 extern int _IO_old_do_write (_IO_FILE *, const char *, _IO_size_t);
481 extern int _IO_wdo_write (_IO_FILE *, const wchar_t *, _IO_size_t);
482 libc_hidden_proto (_IO_wdo_write)
483 extern int _IO_flush_all_lockp (int);
484 extern int _IO_flush_all (void);
485 libc_hidden_proto (_IO_flush_all)
486 extern int _IO_cleanup (void);
487 extern void _IO_flush_all_linebuffered (void);
488 libc_hidden_proto (_IO_flush_all_linebuffered)
489 extern int _IO_new_fgetpos (_IO_FILE *, _IO_fpos_t *);
490 extern int _IO_old_fgetpos (_IO_FILE *, _IO_fpos_t *);
491 extern int _IO_new_fsetpos (_IO_FILE *, const _IO_fpos_t *);
492 extern int _IO_old_fsetpos (_IO_FILE *, const _IO_fpos_t *);
493 extern int _IO_new_fgetpos64 (_IO_FILE *, _IO_fpos64_t *);
494 extern int _IO_old_fgetpos64 (_IO_FILE *, _IO_fpos64_t *);
495 extern int _IO_new_fsetpos64 (_IO_FILE *, const _IO_fpos64_t *);
496 extern int _IO_old_fsetpos64 (_IO_FILE *, const _IO_fpos64_t *);
497 extern void _IO_old_init (_IO_FILE *fp, int flags) __THROW;
500 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
501 # define _IO_do_flush(_f) \
502 ((_f)->_mode <= 0 \
503 ? _IO_do_write(_f, (_f)->_IO_write_base, \
504 (_f)->_IO_write_ptr-(_f)->_IO_write_base) \
505 : _IO_wdo_write(_f, (_f)->_wide_data->_IO_write_base, \
506 ((_f)->_wide_data->_IO_write_ptr \
507 - (_f)->_wide_data->_IO_write_base)))
508 #else
509 # define _IO_do_flush(_f) \
510 _IO_do_write(_f, (_f)->_IO_write_base, \
511 (_f)->_IO_write_ptr-(_f)->_IO_write_base)
512 #endif
513 #define _IO_old_do_flush(_f) \
514 _IO_old_do_write(_f, (_f)->_IO_write_base, \
515 (_f)->_IO_write_ptr-(_f)->_IO_write_base)
516 #define _IO_in_put_mode(_fp) ((_fp)->_flags & _IO_CURRENTLY_PUTTING)
517 #define _IO_mask_flags(fp, f, mask) \
518 ((fp)->_flags = ((fp)->_flags & ~(mask)) | ((f) & (mask)))
519 #define _IO_setg(fp, eb, g, eg) ((fp)->_IO_read_base = (eb),\
520 (fp)->_IO_read_ptr = (g), (fp)->_IO_read_end = (eg))
521 #define _IO_wsetg(fp, eb, g, eg) ((fp)->_wide_data->_IO_read_base = (eb),\
522 (fp)->_wide_data->_IO_read_ptr = (g), \
523 (fp)->_wide_data->_IO_read_end = (eg))
524 #define _IO_setp(__fp, __p, __ep) \
525 ((__fp)->_IO_write_base = (__fp)->_IO_write_ptr \
526 = __p, (__fp)->_IO_write_end = (__ep))
527 #define _IO_wsetp(__fp, __p, __ep) \
528 ((__fp)->_wide_data->_IO_write_base \
529 = (__fp)->_wide_data->_IO_write_ptr = __p, \
530 (__fp)->_wide_data->_IO_write_end = (__ep))
531 #define _IO_have_backup(fp) ((fp)->_IO_save_base != NULL)
532 #define _IO_have_wbackup(fp) ((fp)->_wide_data->_IO_save_base != NULL)
533 #define _IO_in_backup(fp) ((fp)->_flags & _IO_IN_BACKUP)
534 #define _IO_have_markers(fp) ((fp)->_markers != NULL)
535 #define _IO_blen(fp) ((fp)->_IO_buf_end - (fp)->_IO_buf_base)
536 #define _IO_wblen(fp) ((fp)->_wide_data->_IO_buf_end \
537 - (fp)->_wide_data->_IO_buf_base)
539 /* Jumptable functions for files. */
541 extern int _IO_file_doallocate (_IO_FILE *) __THROW;
542 libc_hidden_proto (_IO_file_doallocate)
543 extern _IO_FILE* _IO_file_setbuf (_IO_FILE *, char *, _IO_ssize_t);
544 libc_hidden_proto (_IO_file_setbuf)
545 extern _IO_off64_t _IO_file_seekoff (_IO_FILE *, _IO_off64_t, int, int);
546 libc_hidden_proto (_IO_file_seekoff)
547 extern _IO_off64_t _IO_file_seekoff_mmap (_IO_FILE *, _IO_off64_t, int, int)
548 __THROW;
549 extern _IO_size_t _IO_file_xsputn (_IO_FILE *, const void *, _IO_size_t);
550 libc_hidden_proto (_IO_file_xsputn)
551 extern _IO_size_t _IO_file_xsgetn (_IO_FILE *, void *, _IO_size_t);
552 libc_hidden_proto (_IO_file_xsgetn)
553 extern int _IO_file_stat (_IO_FILE *, void *) __THROW;
554 libc_hidden_proto (_IO_file_stat)
555 extern int _IO_file_close (_IO_FILE *) __THROW;
556 libc_hidden_proto (_IO_file_close)
557 extern int _IO_file_close_mmap (_IO_FILE *) __THROW;
558 extern int _IO_file_underflow (_IO_FILE *);
559 libc_hidden_proto (_IO_file_underflow)
560 extern int _IO_file_underflow_mmap (_IO_FILE *);
561 extern int _IO_file_underflow_maybe_mmap (_IO_FILE *);
562 extern int _IO_file_overflow (_IO_FILE *, int);
563 libc_hidden_proto (_IO_file_overflow)
564 #define _IO_file_is_open(__fp) ((__fp)->_fileno != -1)
565 extern void _IO_file_init (struct _IO_FILE_plus *) __THROW;
566 libc_hidden_proto (_IO_file_init)
567 extern _IO_FILE* _IO_file_attach (_IO_FILE *, int);
568 libc_hidden_proto (_IO_file_attach)
569 extern _IO_FILE* _IO_file_open (_IO_FILE *, const char *, int, int, int, int);
570 libc_hidden_proto (_IO_file_open)
571 extern _IO_FILE* _IO_file_fopen (_IO_FILE *, const char *, const char *, int);
572 libc_hidden_proto (_IO_file_fopen)
573 extern _IO_ssize_t _IO_file_write (_IO_FILE *, const void *, _IO_ssize_t);
574 extern _IO_ssize_t _IO_file_read (_IO_FILE *, void *, _IO_ssize_t);
575 libc_hidden_proto (_IO_file_read)
576 extern int _IO_file_sync (_IO_FILE *);
577 libc_hidden_proto (_IO_file_sync)
578 extern int _IO_file_close_it (_IO_FILE *);
579 libc_hidden_proto (_IO_file_close_it)
580 extern _IO_off64_t _IO_file_seek (_IO_FILE *, _IO_off64_t, int) __THROW;
581 libc_hidden_proto (_IO_file_seek)
582 extern void _IO_file_finish (_IO_FILE *, int);
583 libc_hidden_proto (_IO_file_finish)
585 extern _IO_FILE* _IO_new_file_attach (_IO_FILE *, int);
586 extern int _IO_new_file_close_it (_IO_FILE *);
587 extern void _IO_new_file_finish (_IO_FILE *, int);
588 extern _IO_FILE* _IO_new_file_fopen (_IO_FILE *, const char *, const char *,
589 int);
590 extern void _IO_no_init (_IO_FILE *, int, int, struct _IO_wide_data *,
591 const struct _IO_jump_t *) __THROW;
592 extern void _IO_new_file_init (struct _IO_FILE_plus *) __THROW;
593 extern _IO_FILE* _IO_new_file_setbuf (_IO_FILE *, char *, _IO_ssize_t);
594 extern _IO_FILE* _IO_file_setbuf_mmap (_IO_FILE *, char *, _IO_ssize_t);
595 extern int _IO_new_file_sync (_IO_FILE *);
596 extern int _IO_new_file_underflow (_IO_FILE *);
597 extern int _IO_new_file_overflow (_IO_FILE *, int);
598 extern _IO_off64_t _IO_new_file_seekoff (_IO_FILE *, _IO_off64_t, int, int);
599 extern _IO_ssize_t _IO_new_file_write (_IO_FILE *, const void *, _IO_ssize_t);
600 extern _IO_size_t _IO_new_file_xsputn (_IO_FILE *, const void *, _IO_size_t);
602 extern _IO_FILE* _IO_old_file_setbuf (_IO_FILE *, char *, _IO_ssize_t);
603 extern _IO_off64_t _IO_old_file_seekoff (_IO_FILE *, _IO_off64_t, int, int);
604 extern _IO_size_t _IO_old_file_xsputn (_IO_FILE *, const void *, _IO_size_t);
605 extern int _IO_old_file_underflow (_IO_FILE *);
606 extern int _IO_old_file_overflow (_IO_FILE *, int);
607 extern void _IO_old_file_init (struct _IO_FILE_plus *) __THROW;
608 extern _IO_FILE* _IO_old_file_attach (_IO_FILE *, int);
609 extern _IO_FILE* _IO_old_file_fopen (_IO_FILE *, const char *, const char *);
610 extern _IO_ssize_t _IO_old_file_write (_IO_FILE *, const void *, _IO_ssize_t);
611 extern int _IO_old_file_sync (_IO_FILE *);
612 extern int _IO_old_file_close_it (_IO_FILE *);
613 extern void _IO_old_file_finish (_IO_FILE *, int);
615 extern int _IO_wfile_doallocate (_IO_FILE *) __THROW;
616 extern _IO_size_t _IO_wfile_xsputn (_IO_FILE *, const void *, _IO_size_t);
617 libc_hidden_proto (_IO_wfile_xsputn)
618 extern _IO_FILE* _IO_wfile_setbuf (_IO_FILE *, wchar_t *, _IO_ssize_t);
619 extern wint_t _IO_wfile_sync (_IO_FILE *);
620 libc_hidden_proto (_IO_wfile_sync)
621 extern wint_t _IO_wfile_underflow (_IO_FILE *);
622 libc_hidden_proto (_IO_wfile_underflow)
623 extern wint_t _IO_wfile_overflow (_IO_FILE *, wint_t);
624 libc_hidden_proto (_IO_wfile_overflow)
625 extern _IO_off64_t _IO_wfile_seekoff (_IO_FILE *, _IO_off64_t, int, int);
626 libc_hidden_proto (_IO_wfile_seekoff)
628 /* Jumptable functions for proc_files. */
629 extern _IO_FILE* _IO_proc_open (_IO_FILE *, const char *, const char *)
630 __THROW;
631 extern _IO_FILE* _IO_new_proc_open (_IO_FILE *, const char *, const char *)
632 __THROW;
633 extern _IO_FILE* _IO_old_proc_open (_IO_FILE *, const char *, const char *);
634 extern int _IO_proc_close (_IO_FILE *) __THROW;
635 extern int _IO_new_proc_close (_IO_FILE *) __THROW;
636 extern int _IO_old_proc_close (_IO_FILE *);
638 /* Jumptable functions for strfiles. */
639 extern int _IO_str_underflow (_IO_FILE *) __THROW;
640 libc_hidden_proto (_IO_str_underflow)
641 extern int _IO_str_overflow (_IO_FILE *, int) __THROW;
642 libc_hidden_proto (_IO_str_overflow)
643 extern int _IO_str_pbackfail (_IO_FILE *, int) __THROW;
644 libc_hidden_proto (_IO_str_pbackfail)
645 extern _IO_off64_t _IO_str_seekoff (_IO_FILE *, _IO_off64_t, int, int) __THROW;
646 libc_hidden_proto (_IO_str_seekoff)
647 extern void _IO_str_finish (_IO_FILE *, int) __THROW;
649 /* Other strfile functions */
650 struct _IO_strfile_;
651 extern void _IO_str_init_static (struct _IO_strfile_ *, char *, int, char *)
652 __THROW;
653 extern void _IO_str_init_readonly (struct _IO_strfile_ *, const char *, int)
654 __THROW;
655 extern _IO_ssize_t _IO_str_count (_IO_FILE *) __THROW;
657 /* And the wide character versions. */
658 extern void _IO_wstr_init_static (_IO_FILE *, wchar_t *, _IO_size_t, wchar_t *)
659 __THROW;
660 extern _IO_ssize_t _IO_wstr_count (_IO_FILE *) __THROW;
661 extern _IO_wint_t _IO_wstr_overflow (_IO_FILE *, _IO_wint_t) __THROW;
662 extern _IO_wint_t _IO_wstr_underflow (_IO_FILE *) __THROW;
663 extern _IO_off64_t _IO_wstr_seekoff (_IO_FILE *, _IO_off64_t, int, int)
664 __THROW;
665 extern _IO_wint_t _IO_wstr_pbackfail (_IO_FILE *, _IO_wint_t) __THROW;
666 extern void _IO_wstr_finish (_IO_FILE *, int) __THROW;
668 extern int _IO_vasprintf (char **result_ptr, const char *format,
669 _IO_va_list args) __THROW;
670 extern int _IO_vdprintf (int d, const char *format, _IO_va_list arg);
671 extern int _IO_vsnprintf (char *string, _IO_size_t maxlen,
672 const char *format, _IO_va_list args) __THROW;
675 extern _IO_size_t _IO_getline (_IO_FILE *,char *, _IO_size_t, int, int);
676 libc_hidden_proto (_IO_getline)
677 extern _IO_size_t _IO_getline_info (_IO_FILE *,char *, _IO_size_t,
678 int, int, int *);
679 libc_hidden_proto (_IO_getline_info)
680 extern _IO_ssize_t _IO_getdelim (char **, _IO_size_t *, int, _IO_FILE *);
681 extern _IO_size_t _IO_getwline (_IO_FILE *,wchar_t *, _IO_size_t, wint_t, int);
682 extern _IO_size_t _IO_getwline_info (_IO_FILE *,wchar_t *, _IO_size_t,
683 wint_t, int, wint_t *);
685 extern struct _IO_FILE_plus *_IO_list_all;
686 libc_hidden_proto (_IO_list_all)
687 extern void (*_IO_cleanup_registration_needed) (void);
689 extern void _IO_str_init_static_internal (struct _IO_strfile_ *, char *,
690 _IO_size_t, char *) __THROW;
691 extern _IO_off64_t _IO_seekoff_unlocked (_IO_FILE *, _IO_off64_t, int, int)
692 attribute_hidden;
693 extern _IO_off64_t _IO_seekpos_unlocked (_IO_FILE *, _IO_off64_t, int)
694 attribute_hidden;
696 #ifndef EOF
697 # define EOF (-1)
698 #endif
699 #ifndef NULL
700 # if defined __GNUG__ && \
701 (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
702 # define NULL (__null)
703 # else
704 # if !defined(__cplusplus)
705 # define NULL ((void*)0)
706 # else
707 # define NULL (0)
708 # endif
709 # endif
710 #endif
712 #if _G_HAVE_MMAP
714 # include <unistd.h>
715 # include <fcntl.h>
716 # include <sys/mman.h>
717 # include <sys/param.h>
719 # if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
720 # define MAP_ANONYMOUS MAP_ANON
721 # endif
723 # if !defined(MAP_ANONYMOUS) || !defined(EXEC_PAGESIZE)
724 # undef _G_HAVE_MMAP
725 # define _G_HAVE_MMAP 0
726 # endif
728 #endif /* _G_HAVE_MMAP */
730 #if _G_HAVE_MMAP
732 # ifdef _LIBC
733 /* When using this code in the GNU libc we must not pollute the name space. */
734 # define mmap __mmap
735 # define munmap __munmap
736 # define ftruncate __ftruncate
737 # endif
739 # define ROUND_TO_PAGE(_S) \
740 (((_S) + EXEC_PAGESIZE - 1) & ~(EXEC_PAGESIZE - 1))
742 # define FREE_BUF(_B, _S) \
743 munmap ((_B), ROUND_TO_PAGE (_S))
744 # define ALLOC_BUF(_B, _S, _R) \
745 do { \
746 (_B) = (char *) mmap (0, ROUND_TO_PAGE (_S), \
747 PROT_READ | PROT_WRITE, \
748 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \
749 if ((_B) == (char *) MAP_FAILED) \
750 return (_R); \
751 } while (0)
752 # define ALLOC_WBUF(_B, _S, _R) \
753 do { \
754 (_B) = (wchar_t *) mmap (0, ROUND_TO_PAGE (_S), \
755 PROT_READ | PROT_WRITE, \
756 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \
757 if ((_B) == (wchar_t *) MAP_FAILED) \
758 return (_R); \
759 } while (0)
761 #else /* _G_HAVE_MMAP */
763 # define FREE_BUF(_B, _S) \
764 free(_B)
765 # define ALLOC_BUF(_B, _S, _R) \
766 do { \
767 (_B) = (char*)malloc(_S); \
768 if ((_B) == NULL) \
769 return (_R); \
770 } while (0)
771 # define ALLOC_WBUF(_B, _S, _R) \
772 do { \
773 (_B) = (wchar_t *)malloc(_S); \
774 if ((_B) == NULL) \
775 return (_R); \
776 } while (0)
778 #endif /* _G_HAVE_MMAP */
780 #ifndef OS_FSTAT
781 # define OS_FSTAT fstat
782 #endif
783 extern int _IO_vscanf (const char *, _IO_va_list) __THROW;
785 /* _IO_pos_BAD is an _IO_off64_t value indicating error, unknown, or EOF. */
786 #ifndef _IO_pos_BAD
787 # define _IO_pos_BAD ((_IO_off64_t) -1)
788 #endif
789 /* _IO_pos_adjust adjust an _IO_off64_t by some number of bytes. */
790 #ifndef _IO_pos_adjust
791 # define _IO_pos_adjust(pos, delta) ((pos) += (delta))
792 #endif
793 /* _IO_pos_0 is an _IO_off64_t value indicating beginning of file. */
794 #ifndef _IO_pos_0
795 # define _IO_pos_0 ((_IO_off64_t) 0)
796 #endif
798 #ifdef __cplusplus
800 #endif
802 #ifdef _IO_MTSAFE_IO
803 /* check following! */
804 # ifdef _IO_USE_OLD_IO_FILE
805 # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
806 { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
807 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
808 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock }
809 # else
810 # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
811 # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
812 { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
813 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
814 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\
815 NULL, WDP, 0 }
816 # else
817 # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
818 { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
819 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
820 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\
822 # endif
823 # endif
824 #else
825 # ifdef _IO_USE_OLD_IO_FILE
826 # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
827 { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
828 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
829 0, _IO_pos_BAD }
830 # else
831 # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
832 # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
833 { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
834 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
835 0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \
836 NULL, WDP, 0 }
837 # else
838 # define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
839 { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
840 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
841 0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \
843 # endif
844 # endif
845 #endif
847 #define _IO_va_start(args, last) va_start(args, last)
849 extern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf;
851 #if 1
852 # define COERCE_FILE(FILE) /* Nothing */
853 #else
854 /* This is part of the kludge for binary compatibility with old stdio. */
855 # define COERCE_FILE(FILE) \
856 (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) == _OLD_MAGIC_MASK \
857 && (FILE) = *(FILE**)&((int*)fp)[1])
858 #endif
860 #ifdef EINVAL
861 # define MAYBE_SET_EINVAL __set_errno (EINVAL)
862 #else
863 # define MAYBE_SET_EINVAL /* nothing */
864 #endif
866 #ifdef IO_DEBUG
867 # define CHECK_FILE(FILE, RET) \
868 if ((FILE) == NULL) { MAYBE_SET_EINVAL; return RET; } \
869 else { COERCE_FILE(FILE); \
870 if (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \
871 { MAYBE_SET_EINVAL; return RET; }}
872 #else
873 # define CHECK_FILE(FILE, RET) COERCE_FILE (FILE)
874 #endif
876 static inline void
877 __attribute__ ((__always_inline__))
878 _IO_acquire_lock_fct (_IO_FILE **p)
880 _IO_FILE *fp = *p;
881 if ((fp->_flags & _IO_USER_LOCK) == 0)
882 _IO_funlockfile (fp);
885 static inline void
886 __attribute__ ((__always_inline__))
887 _IO_acquire_lock_clear_flags2_fct (_IO_FILE **p)
889 _IO_FILE *fp = *p;
890 fp->_flags2 &= ~(_IO_FLAGS2_FORTIFY | _IO_FLAGS2_SCANF_STD);
891 if ((fp->_flags & _IO_USER_LOCK) == 0)
892 _IO_funlockfile (fp);
895 #if !defined _IO_MTSAFE_IO && !defined NOT_IN_libc
896 # define _IO_acquire_lock(_fp) \
897 do { \
898 _IO_FILE *_IO_acquire_lock_file = NULL
899 # define _IO_acquire_lock_clear_flags2(_fp) \
900 do { \
901 _IO_FILE *_IO_acquire_lock_file = (_fp)
902 # define _IO_release_lock(_fp) \
903 if (_IO_acquire_lock_file != NULL) \
904 _IO_acquire_lock_file->_flags2 &= ~(_IO_FLAGS2_FORTIFY \
905 | _IO_FLAGS2_SCANF_STD); \
906 } while (0)
907 #endif