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