Back to index

glibc  2.9
libioP.h
Go to the documentation of this file.
00001 /* Copyright (C) 1993, 1997-2003,2004,2005,2006,2007
00002        Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.
00019 
00020    As a special exception, if you link the code in this file with
00021    files compiled with a GNU compiler to produce an executable,
00022    that does not cause the resulting executable to be covered by
00023    the GNU Lesser General Public License.  This exception does not
00024    however invalidate any other reasons why the executable file
00025    might be covered by the GNU Lesser General Public License.
00026    This exception applies to code released by its copyright holders
00027    in files containing the exception.  */
00028 
00029 #include <errno.h>
00030 #ifndef __set_errno
00031 # define __set_errno(Val) errno = (Val)
00032 #endif
00033 #if defined __GLIBC__ && __GLIBC__ >= 2
00034 # include <bits/libc-lock.h>
00035 #else
00036 /*# include <comthread.h>*/
00037 #endif
00038 
00039 #include <math_ldbl_opt.h>
00040 
00041 #include "iolibio.h"
00042 
00043 /* Control of exported symbols.  Used in glibc.  By default we don't
00044    do anything.  */
00045 #ifndef INTUSE
00046 # define INTUSE(name) name
00047 #endif
00048 #ifndef INTDEF
00049 # define INTDEF(name)
00050 #endif
00051 #ifndef INTDEF2
00052 # define INTDEF2(name)
00053 #endif
00054 #ifndef libc_hidden_proto
00055 # define libc_hidden_proto(name)
00056 #endif
00057 #ifndef libc_hidden_def
00058 # define libc_hidden_def(name)
00059 #endif
00060 #ifndef libc_hidden_weak
00061 # define libc_hidden_weak(name)
00062 #endif
00063 
00064 #ifdef __cplusplus
00065 extern "C" {
00066 #endif
00067 
00068 #define _IO_seek_set 0
00069 #define _IO_seek_cur 1
00070 #define _IO_seek_end 2
00071 
00072 /* THE JUMPTABLE FUNCTIONS.
00073 
00074  * The _IO_FILE type is used to implement the FILE type in GNU libc,
00075  * as well as the streambuf class in GNU iostreams for C++.
00076  * These are all the same, just used differently.
00077  * An _IO_FILE (or FILE) object is allows followed by a pointer to
00078  * a jump table (of pointers to functions).  The pointer is accessed
00079  * with the _IO_JUMPS macro.  The jump table has a eccentric format,
00080  * so as to be compatible with the layout of a C++ virtual function table.
00081  * (as implemented by g++).  When a pointer to a streambuf object is
00082  * coerced to an (_IO_FILE*), then _IO_JUMPS on the result just
00083  * happens to point to the virtual function table of the streambuf.
00084  * Thus the _IO_JUMPS function table used for C stdio/libio does
00085  * double duty as the virtual function table for C++ streambuf.
00086  *
00087  * The entries in the _IO_JUMPS function table (and hence also the
00088  * virtual functions of a streambuf) are described below.
00089  * The first parameter of each function entry is the _IO_FILE/streambuf
00090  * object being acted on (i.e. the 'this' parameter).
00091  */
00092 
00093 #ifdef _LIBC
00094 # include <shlib-compat.h>
00095 # if !SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
00096    /* Setting this macro disables the use of the _vtable_offset
00097       bias in _IO_JUMPS_FUNCS, below.  That is only needed if we
00098       want to support old binaries (see oldfileops.c).  */
00099 #  define _G_IO_NO_BACKWARD_COMPAT 1
00100 # endif
00101 #endif
00102 
00103 #if (!defined _IO_USE_OLD_IO_FILE \
00104      && (!defined _G_IO_NO_BACKWARD_COMPAT || _G_IO_NO_BACKWARD_COMPAT == 0))
00105 # define _IO_JUMPS_OFFSET 1
00106 #endif
00107 
00108 #define _IO_JUMPS(THIS) (THIS)->vtable
00109 #define _IO_WIDE_JUMPS(THIS) ((struct _IO_FILE *) (THIS))->_wide_data->_wide_vtable
00110 #define _IO_CHECK_WIDE(THIS) (((struct _IO_FILE *) (THIS))->_wide_data != NULL)
00111 
00112 #if _IO_JUMPS_OFFSET
00113 # define _IO_JUMPS_FUNC(THIS) \
00114  (*(struct _IO_jump_t **) ((void *) &_IO_JUMPS ((struct _IO_FILE_plus *) (THIS)) \
00115                         + (THIS)->_vtable_offset))
00116 # define _IO_vtable_offset(THIS) (THIS)->_vtable_offset
00117 #else
00118 # define _IO_JUMPS_FUNC(THIS) _IO_JUMPS ((struct _IO_FILE_plus *) (THIS))
00119 # define _IO_vtable_offset(THIS) 0
00120 #endif
00121 #define _IO_WIDE_JUMPS_FUNC(THIS) _IO_WIDE_JUMPS(THIS)
00122 #ifdef _G_USING_THUNKS
00123 # define JUMP_FIELD(TYPE, NAME) TYPE NAME
00124 # define JUMP0(FUNC, THIS) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS)
00125 # define JUMP1(FUNC, THIS, X1) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1)
00126 # define JUMP2(FUNC, THIS, X1, X2) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2)
00127 # define JUMP3(FUNC, THIS, X1,X2,X3) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3)
00128 # define JUMP_INIT(NAME, VALUE) VALUE
00129 # define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT (dummy2, 0)
00130 
00131 # define WJUMP0(FUNC, THIS) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS)
00132 # define WJUMP1(FUNC, THIS, X1) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1)
00133 # define WJUMP2(FUNC, THIS, X1, X2) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2)
00134 # define WJUMP3(FUNC, THIS, X1,X2,X3) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3)
00135 #else
00136 /* These macros will change when we re-implement vtables to use "thunks"! */
00137 # define JUMP_FIELD(TYPE, NAME) struct { short delta1, delta2; TYPE pfn; } NAME
00138 # define JUMP0(FUNC, THIS) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS)
00139 # define JUMP1(FUNC, THIS, X1) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1)
00140 # define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1, X2)
00141 # define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1,X2,X3)
00142 # define JUMP_INIT(NAME, VALUE) {0, 0, VALUE}
00143 # define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0)
00144 
00145 # define WJUMP0(FUNC, THIS) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS)
00146 # define WJUMP1(FUNC, THIS, X1) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1)
00147 # define WJUMP2(FUNC, THIS, X1, X2) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1, X2)
00148 # define WJUMP3(FUNC, THIS, X1,X2,X3) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1,X2,X3)
00149 #endif
00150 
00151 /* The 'finish' function does any final cleaning up of an _IO_FILE object.
00152    It does not delete (free) it, but does everything else to finalize it.
00153    It matches the streambuf::~streambuf virtual destructor.  */
00154 typedef void (*_IO_finish_t) (_IO_FILE *, int); /* finalize */
00155 #define _IO_FINISH(FP) JUMP1 (__finish, FP, 0)
00156 #define _IO_WFINISH(FP) WJUMP1 (__finish, FP, 0)
00157 
00158 /* The 'overflow' hook flushes the buffer.
00159    The second argument is a character, or EOF.
00160    It matches the streambuf::overflow virtual function. */
00161 typedef int (*_IO_overflow_t) (_IO_FILE *, int);
00162 #define _IO_OVERFLOW(FP, CH) JUMP1 (__overflow, FP, CH)
00163 #define _IO_WOVERFLOW(FP, CH) WJUMP1 (__overflow, FP, CH)
00164 
00165 /* The 'underflow' hook tries to fills the get buffer.
00166    It returns the next character (as an unsigned char) or EOF.  The next
00167    character remains in the get buffer, and the get position is not changed.
00168    It matches the streambuf::underflow virtual function. */
00169 typedef int (*_IO_underflow_t) (_IO_FILE *);
00170 #define _IO_UNDERFLOW(FP) JUMP0 (__underflow, FP)
00171 #define _IO_WUNDERFLOW(FP) WJUMP0 (__underflow, FP)
00172 
00173 /* The 'uflow' hook returns the next character in the input stream
00174    (cast to unsigned char), and increments the read position;
00175    EOF is returned on failure.
00176    It matches the streambuf::uflow virtual function, which is not in the
00177    cfront implementation, but was added to C++ by the ANSI/ISO committee. */
00178 #define _IO_UFLOW(FP) JUMP0 (__uflow, FP)
00179 #define _IO_WUFLOW(FP) WJUMP0 (__uflow, FP)
00180 
00181 /* The 'pbackfail' hook handles backing up.
00182    It matches the streambuf::pbackfail virtual function. */
00183 typedef int (*_IO_pbackfail_t) (_IO_FILE *, int);
00184 #define _IO_PBACKFAIL(FP, CH) JUMP1 (__pbackfail, FP, CH)
00185 #define _IO_WPBACKFAIL(FP, CH) WJUMP1 (__pbackfail, FP, CH)
00186 
00187 /* The 'xsputn' hook writes upto N characters from buffer DATA.
00188    Returns the number of character actually written.
00189    It matches the streambuf::xsputn virtual function. */
00190 typedef _IO_size_t (*_IO_xsputn_t) (_IO_FILE *FP, const void *DATA,
00191                                 _IO_size_t N);
00192 #define _IO_XSPUTN(FP, DATA, N) JUMP2 (__xsputn, FP, DATA, N)
00193 #define _IO_WXSPUTN(FP, DATA, N) WJUMP2 (__xsputn, FP, DATA, N)
00194 
00195 /* The 'xsgetn' hook reads upto N characters into buffer DATA.
00196    Returns the number of character actually read.
00197    It matches the streambuf::xsgetn virtual function. */
00198 typedef _IO_size_t (*_IO_xsgetn_t) (_IO_FILE *FP, void *DATA, _IO_size_t N);
00199 #define _IO_XSGETN(FP, DATA, N) JUMP2 (__xsgetn, FP, DATA, N)
00200 #define _IO_WXSGETN(FP, DATA, N) WJUMP2 (__xsgetn, FP, DATA, N)
00201 
00202 /* The 'seekoff' hook moves the stream position to a new position
00203    relative to the start of the file (if DIR==0), the current position
00204    (MODE==1), or the end of the file (MODE==2).
00205    It matches the streambuf::seekoff virtual function.
00206    It is also used for the ANSI fseek function. */
00207 typedef _IO_off64_t (*_IO_seekoff_t) (_IO_FILE *FP, _IO_off64_t OFF, int DIR,
00208                                   int MODE);
00209 #define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3 (__seekoff, FP, OFF, DIR, MODE)
00210 #define _IO_WSEEKOFF(FP, OFF, DIR, MODE) WJUMP3 (__seekoff, FP, OFF, DIR, MODE)
00211 
00212 /* The 'seekpos' hook also moves the stream position,
00213    but to an absolute position given by a fpos64_t (seekpos).
00214    It matches the streambuf::seekpos virtual function.
00215    It is also used for the ANSI fgetpos and fsetpos functions.  */
00216 /* The _IO_seek_cur and _IO_seek_end options are not allowed. */
00217 typedef _IO_off64_t (*_IO_seekpos_t) (_IO_FILE *, _IO_off64_t, int);
00218 #define _IO_SEEKPOS(FP, POS, FLAGS) JUMP2 (__seekpos, FP, POS, FLAGS)
00219 #define _IO_WSEEKPOS(FP, POS, FLAGS) WJUMP2 (__seekpos, FP, POS, FLAGS)
00220 
00221 /* The 'setbuf' hook gives a buffer to the file.
00222    It matches the streambuf::setbuf virtual function. */
00223 typedef _IO_FILE* (*_IO_setbuf_t) (_IO_FILE *, char *, _IO_ssize_t);
00224 #define _IO_SETBUF(FP, BUFFER, LENGTH) JUMP2 (__setbuf, FP, BUFFER, LENGTH)
00225 #define _IO_WSETBUF(FP, BUFFER, LENGTH) WJUMP2 (__setbuf, FP, BUFFER, LENGTH)
00226 
00227 /* The 'sync' hook attempts to synchronize the internal data structures
00228    of the file with the external state.
00229    It matches the streambuf::sync virtual function. */
00230 typedef int (*_IO_sync_t) (_IO_FILE *);
00231 #define _IO_SYNC(FP) JUMP0 (__sync, FP)
00232 #define _IO_WSYNC(FP) WJUMP0 (__sync, FP)
00233 
00234 /* The 'doallocate' hook is used to tell the file to allocate a buffer.
00235    It matches the streambuf::doallocate virtual function, which is not
00236    in the ANSI/ISO C++ standard, but is part traditional implementations. */
00237 typedef int (*_IO_doallocate_t) (_IO_FILE *);
00238 #define _IO_DOALLOCATE(FP) JUMP0 (__doallocate, FP)
00239 #define _IO_WDOALLOCATE(FP) WJUMP0 (__doallocate, FP)
00240 
00241 /* The following four hooks (sysread, syswrite, sysclose, sysseek, and
00242    sysstat) are low-level hooks specific to this implementation.
00243    There is no correspondence in the ANSI/ISO C++ standard library.
00244    The hooks basically correspond to the Unix system functions
00245    (read, write, close, lseek, and stat) except that a _IO_FILE*
00246    parameter is used instead of a integer file descriptor;  the default
00247    implementation used for normal files just calls those functions.
00248    The advantage of overriding these functions instead of the higher-level
00249    ones (underflow, overflow etc) is that you can leave all the buffering
00250    higher-level functions.  */
00251 
00252 /* The 'sysread' hook is used to read data from the external file into
00253    an existing buffer.  It generalizes the Unix read(2) function.
00254    It matches the streambuf::sys_read virtual function, which is
00255    specific to this implementation. */
00256 typedef _IO_ssize_t (*_IO_read_t) (_IO_FILE *, void *, _IO_ssize_t);
00257 #define _IO_SYSREAD(FP, DATA, LEN) JUMP2 (__read, FP, DATA, LEN)
00258 #define _IO_WSYSREAD(FP, DATA, LEN) WJUMP2 (__read, FP, DATA, LEN)
00259 
00260 /* The 'syswrite' hook is used to write data from an existing buffer
00261    to an external file.  It generalizes the Unix write(2) function.
00262    It matches the streambuf::sys_write virtual function, which is
00263    specific to this implementation. */
00264 typedef _IO_ssize_t (*_IO_write_t) (_IO_FILE *, const void *, _IO_ssize_t);
00265 #define _IO_SYSWRITE(FP, DATA, LEN) JUMP2 (__write, FP, DATA, LEN)
00266 #define _IO_WSYSWRITE(FP, DATA, LEN) WJUMP2 (__write, FP, DATA, LEN)
00267 
00268 /* The 'sysseek' hook is used to re-position an external file.
00269    It generalizes the Unix lseek(2) function.
00270    It matches the streambuf::sys_seek virtual function, which is
00271    specific to this implementation. */
00272 typedef _IO_off64_t (*_IO_seek_t) (_IO_FILE *, _IO_off64_t, int);
00273 #define _IO_SYSSEEK(FP, OFFSET, MODE) JUMP2 (__seek, FP, OFFSET, MODE)
00274 #define _IO_WSYSSEEK(FP, OFFSET, MODE) WJUMP2 (__seek, FP, OFFSET, MODE)
00275 
00276 /* The 'sysclose' hook is used to finalize (close, finish up) an
00277    external file.  It generalizes the Unix close(2) function.
00278    It matches the streambuf::sys_close virtual function, which is
00279    specific to this implementation. */
00280 typedef int (*_IO_close_t) (_IO_FILE *); /* finalize */
00281 #define _IO_SYSCLOSE(FP) JUMP0 (__close, FP)
00282 #define _IO_WSYSCLOSE(FP) WJUMP0 (__close, FP)
00283 
00284 /* The 'sysstat' hook is used to get information about an external file
00285    into a struct stat buffer.  It generalizes the Unix fstat(2) call.
00286    It matches the streambuf::sys_stat virtual function, which is
00287    specific to this implementation. */
00288 typedef int (*_IO_stat_t) (_IO_FILE *, void *);
00289 #define _IO_SYSSTAT(FP, BUF) JUMP1 (__stat, FP, BUF)
00290 #define _IO_WSYSSTAT(FP, BUF) WJUMP1 (__stat, FP, BUF)
00291 
00292 /* The 'showmany' hook can be used to get an image how much input is
00293    available.  In many cases the answer will be 0 which means unknown
00294    but some cases one can provide real information.  */
00295 typedef int (*_IO_showmanyc_t) (_IO_FILE *);
00296 #define _IO_SHOWMANYC(FP) JUMP0 (__showmanyc, FP)
00297 #define _IO_WSHOWMANYC(FP) WJUMP0 (__showmanyc, FP)
00298 
00299 /* The 'imbue' hook is used to get information about the currently
00300    installed locales.  */
00301 typedef void (*_IO_imbue_t) (_IO_FILE *, void *);
00302 #define _IO_IMBUE(FP, LOCALE) JUMP1 (__imbue, FP, LOCALE)
00303 #define _IO_WIMBUE(FP, LOCALE) WJUMP1 (__imbue, FP, LOCALE)
00304 
00305 
00306 #define _IO_CHAR_TYPE char /* unsigned char ? */
00307 #define _IO_INT_TYPE int
00308 
00309 struct _IO_jump_t
00310 {
00311     JUMP_FIELD(_G_size_t, __dummy);
00312 #ifdef _G_USING_THUNKS
00313     JUMP_FIELD(_G_size_t, __dummy2);
00314 #endif
00315     JUMP_FIELD(_IO_finish_t, __finish);
00316     JUMP_FIELD(_IO_overflow_t, __overflow);
00317     JUMP_FIELD(_IO_underflow_t, __underflow);
00318     JUMP_FIELD(_IO_underflow_t, __uflow);
00319     JUMP_FIELD(_IO_pbackfail_t, __pbackfail);
00320     /* showmany */
00321     JUMP_FIELD(_IO_xsputn_t, __xsputn);
00322     JUMP_FIELD(_IO_xsgetn_t, __xsgetn);
00323     JUMP_FIELD(_IO_seekoff_t, __seekoff);
00324     JUMP_FIELD(_IO_seekpos_t, __seekpos);
00325     JUMP_FIELD(_IO_setbuf_t, __setbuf);
00326     JUMP_FIELD(_IO_sync_t, __sync);
00327     JUMP_FIELD(_IO_doallocate_t, __doallocate);
00328     JUMP_FIELD(_IO_read_t, __read);
00329     JUMP_FIELD(_IO_write_t, __write);
00330     JUMP_FIELD(_IO_seek_t, __seek);
00331     JUMP_FIELD(_IO_close_t, __close);
00332     JUMP_FIELD(_IO_stat_t, __stat);
00333     JUMP_FIELD(_IO_showmanyc_t, __showmanyc);
00334     JUMP_FIELD(_IO_imbue_t, __imbue);
00335 #if 0
00336     get_column;
00337     set_column;
00338 #endif
00339 };
00340 
00341 /* We always allocate an extra word following an _IO_FILE.
00342    This contains a pointer to the function jump table used.
00343    This is for compatibility with C++ streambuf; the word can
00344    be used to smash to a pointer to a virtual function table. */
00345 
00346 struct _IO_FILE_plus
00347 {
00348   _IO_FILE file;
00349   const struct _IO_jump_t *vtable;
00350 };
00351 
00352 #ifdef _IO_USE_OLD_IO_FILE
00353 /* This structure is used by the compatibility code as if it were an
00354    _IO_FILE_plus, but has enough space to initialize the _mode argument
00355    of an _IO_FILE_complete.  */
00356 struct _IO_FILE_complete_plus
00357 {
00358   struct _IO_FILE_complete file;
00359   const struct _IO_jump_t *vtable;
00360 };
00361 #endif
00362 
00363 /* Special file type for fopencookie function.  */
00364 struct _IO_cookie_file
00365 {
00366   struct _IO_FILE_plus __fp;
00367   void *__cookie;
00368   _IO_cookie_io_functions_t __io_functions;
00369 };
00370 
00371 _IO_FILE *_IO_fopencookie (void *cookie, const char *mode,
00372                         _IO_cookie_io_functions_t io_functions);
00373 
00374 
00375 /* Iterator type for walking global linked list of _IO_FILE objects. */
00376 
00377 typedef struct _IO_FILE *_IO_ITER;
00378 
00379 /* Generic functions */
00380 
00381 extern void _IO_switch_to_main_get_area (_IO_FILE *) __THROW;
00382 extern void _IO_switch_to_backup_area (_IO_FILE *) __THROW;
00383 extern int _IO_switch_to_get_mode (_IO_FILE *);
00384 extern void _IO_init (_IO_FILE *, int) __THROW;
00385 extern int _IO_sputbackc (_IO_FILE *, int) __THROW;
00386 extern int _IO_sungetc (_IO_FILE *) __THROW;
00387 extern void _IO_un_link (struct _IO_FILE_plus *) __THROW;
00388 extern void _IO_link_in (struct _IO_FILE_plus *) __THROW;
00389 extern void _IO_doallocbuf (_IO_FILE *) __THROW;
00390 extern void _IO_unsave_markers (_IO_FILE *) __THROW;
00391 extern void _IO_setb (_IO_FILE *, char *, char *, int) __THROW;
00392 extern unsigned _IO_adjust_column (unsigned, const char *, int) __THROW;
00393 #define _IO_sputn(__fp, __s, __n) _IO_XSPUTN (__fp, __s, __n)
00394 
00395 extern void _IO_switch_to_main_wget_area (_IO_FILE *) __THROW;
00396 extern void _IO_switch_to_wbackup_area (_IO_FILE *) __THROW;
00397 extern int _IO_switch_to_wget_mode (_IO_FILE *);
00398 extern void _IO_wsetb (_IO_FILE *, wchar_t *, wchar_t *, int) __THROW;
00399 extern wint_t _IO_sputbackwc (_IO_FILE *, wint_t) __THROW;
00400 extern wint_t _IO_sungetwc (_IO_FILE *) __THROW;
00401 extern void _IO_wdoallocbuf (_IO_FILE *) __THROW;
00402 extern void _IO_unsave_wmarkers (_IO_FILE *) __THROW;
00403 extern unsigned _IO_adjust_wcolumn (unsigned, const wchar_t *, int) __THROW;
00404 
00405 /* Marker-related function. */
00406 
00407 extern void _IO_init_marker (struct _IO_marker *, _IO_FILE *);
00408 extern void _IO_init_wmarker (struct _IO_marker *, _IO_FILE *);
00409 extern void _IO_remove_marker (struct _IO_marker *) __THROW;
00410 extern int _IO_marker_difference (struct _IO_marker *, struct _IO_marker *)
00411      __THROW;
00412 extern int _IO_marker_delta (struct _IO_marker *) __THROW;
00413 extern int _IO_wmarker_delta (struct _IO_marker *) __THROW;
00414 extern int _IO_seekmark (_IO_FILE *, struct _IO_marker *, int) __THROW;
00415 extern int _IO_seekwmark (_IO_FILE *, struct _IO_marker *, int) __THROW;
00416 
00417 /* Functions for iterating global list and dealing with its lock */
00418 
00419 extern _IO_ITER _IO_iter_begin (void) __THROW;
00420 libc_hidden_proto (_IO_iter_begin)
00421 extern _IO_ITER _IO_iter_end (void) __THROW;
00422 libc_hidden_proto (_IO_iter_end)
00423 extern _IO_ITER _IO_iter_next (_IO_ITER) __THROW;
00424 libc_hidden_proto (_IO_iter_next)
00425 extern _IO_FILE *_IO_iter_file (_IO_ITER) __THROW;
00426 libc_hidden_proto (_IO_iter_file)
00427 extern void _IO_list_lock (void) __THROW;
00428 libc_hidden_proto (_IO_list_lock)
00429 extern void _IO_list_unlock (void) __THROW;
00430 libc_hidden_proto (_IO_list_unlock)
00431 extern void _IO_list_resetlock (void) __THROW;
00432 libc_hidden_proto (_IO_list_resetlock)
00433 
00434 /* Default jumptable functions. */
00435 
00436 extern int _IO_default_underflow (_IO_FILE *) __THROW;
00437 extern int _IO_default_uflow (_IO_FILE *);
00438 extern wint_t _IO_wdefault_uflow (_IO_FILE *);
00439 extern int _IO_default_doallocate (_IO_FILE *) __THROW;
00440 extern int _IO_wdefault_doallocate (_IO_FILE *) __THROW;
00441 extern void _IO_default_finish (_IO_FILE *, int) __THROW;
00442 extern void _IO_wdefault_finish (_IO_FILE *, int) __THROW;
00443 extern int _IO_default_pbackfail (_IO_FILE *, int) __THROW;
00444 extern wint_t _IO_wdefault_pbackfail (_IO_FILE *, wint_t) __THROW;
00445 extern _IO_FILE* _IO_default_setbuf (_IO_FILE *, char *, _IO_ssize_t);
00446 extern _IO_size_t _IO_default_xsputn (_IO_FILE *, const void *, _IO_size_t);
00447 extern _IO_size_t _IO_wdefault_xsputn (_IO_FILE *, const void *, _IO_size_t);
00448 extern _IO_size_t _IO_default_xsgetn (_IO_FILE *, void *, _IO_size_t);
00449 extern _IO_size_t _IO_wdefault_xsgetn (_IO_FILE *, void *, _IO_size_t);
00450 extern _IO_off64_t _IO_default_seekoff (_IO_FILE *, _IO_off64_t, int, int)
00451      __THROW;
00452 extern _IO_off64_t _IO_default_seekpos (_IO_FILE *, _IO_off64_t, int);
00453 extern _IO_ssize_t _IO_default_write (_IO_FILE *, const void *, _IO_ssize_t);
00454 extern _IO_ssize_t _IO_default_read (_IO_FILE *, void *, _IO_ssize_t);
00455 extern int _IO_default_stat (_IO_FILE *, void *) __THROW;
00456 extern _IO_off64_t _IO_default_seek (_IO_FILE *, _IO_off64_t, int) __THROW;
00457 extern int _IO_default_sync (_IO_FILE *) __THROW;
00458 #define _IO_default_close ((_IO_close_t) _IO_default_sync)
00459 extern int _IO_default_showmanyc (_IO_FILE *) __THROW;
00460 extern void _IO_default_imbue (_IO_FILE *, void *) __THROW;
00461 
00462 extern const struct _IO_jump_t _IO_file_jumps;
00463 libc_hidden_proto (_IO_file_jumps)
00464 extern const struct _IO_jump_t _IO_file_jumps_mmap attribute_hidden;
00465 extern const struct _IO_jump_t _IO_file_jumps_maybe_mmap attribute_hidden;
00466 extern const struct _IO_jump_t _IO_wfile_jumps;
00467 libc_hidden_proto (_IO_wfile_jumps)
00468 extern const struct _IO_jump_t _IO_wfile_jumps_mmap attribute_hidden;
00469 extern const struct _IO_jump_t _IO_wfile_jumps_maybe_mmap attribute_hidden;
00470 extern const struct _IO_jump_t _IO_old_file_jumps attribute_hidden;
00471 extern const struct _IO_jump_t _IO_streambuf_jumps;
00472 extern const struct _IO_jump_t _IO_old_proc_jumps attribute_hidden;
00473 extern const struct _IO_jump_t _IO_str_jumps attribute_hidden;
00474 extern const struct _IO_jump_t _IO_wstr_jumps attribute_hidden;
00475 extern const struct _IO_codecvt __libio_codecvt attribute_hidden;
00476 extern int _IO_do_write (_IO_FILE *, const char *, _IO_size_t);
00477 extern int _IO_new_do_write (_IO_FILE *, const char *, _IO_size_t);
00478 extern int _IO_old_do_write (_IO_FILE *, const char *, _IO_size_t);
00479 extern int _IO_wdo_write (_IO_FILE *, const wchar_t *, _IO_size_t);
00480 extern int _IO_flush_all_lockp (int);
00481 extern int _IO_flush_all (void);
00482 extern int _IO_cleanup (void);
00483 extern void _IO_flush_all_linebuffered (void);
00484 extern int _IO_new_fgetpos (_IO_FILE *, _IO_fpos_t *);
00485 extern int _IO_old_fgetpos (_IO_FILE *, _IO_fpos_t *);
00486 extern int _IO_new_fsetpos (_IO_FILE *, const _IO_fpos_t *);
00487 extern int _IO_old_fsetpos (_IO_FILE *, const _IO_fpos_t *);
00488 extern int _IO_new_fgetpos64 (_IO_FILE *, _IO_fpos64_t *);
00489 extern int _IO_old_fgetpos64 (_IO_FILE *, _IO_fpos64_t *);
00490 extern int _IO_new_fsetpos64 (_IO_FILE *, const _IO_fpos64_t *);
00491 extern int _IO_old_fsetpos64 (_IO_FILE *, const _IO_fpos64_t *);
00492 extern void _IO_old_init (_IO_FILE *fp, int flags) __THROW;
00493 
00494 
00495 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
00496 # define _IO_do_flush(_f) \
00497   ((_f)->_mode <= 0                                                  \
00498    ? INTUSE(_IO_do_write)(_f, (_f)->_IO_write_base,                         \
00499                        (_f)->_IO_write_ptr-(_f)->_IO_write_base)            \
00500    : INTUSE(_IO_wdo_write)(_f, (_f)->_wide_data->_IO_write_base,            \
00501                         ((_f)->_wide_data->_IO_write_ptr                    \
00502                          - (_f)->_wide_data->_IO_write_base)))
00503 #else
00504 # define _IO_do_flush(_f) \
00505    INTUSE(_IO_do_write)(_f, (_f)->_IO_write_base,                           \
00506                      (_f)->_IO_write_ptr-(_f)->_IO_write_base)
00507 #endif
00508 #define _IO_old_do_flush(_f) \
00509   _IO_old_do_write(_f, (_f)->_IO_write_base, \
00510                  (_f)->_IO_write_ptr-(_f)->_IO_write_base)
00511 #define _IO_in_put_mode(_fp) ((_fp)->_flags & _IO_CURRENTLY_PUTTING)
00512 #define _IO_mask_flags(fp, f, mask) \
00513        ((fp)->_flags = ((fp)->_flags & ~(mask)) | ((f) & (mask)))
00514 #define _IO_setg(fp, eb, g, eg)  ((fp)->_IO_read_base = (eb),\
00515        (fp)->_IO_read_ptr = (g), (fp)->_IO_read_end = (eg))
00516 #define _IO_wsetg(fp, eb, g, eg)  ((fp)->_wide_data->_IO_read_base = (eb),\
00517        (fp)->_wide_data->_IO_read_ptr = (g), \
00518        (fp)->_wide_data->_IO_read_end = (eg))
00519 #define _IO_setp(__fp, __p, __ep) \
00520        ((__fp)->_IO_write_base = (__fp)->_IO_write_ptr \
00521        = __p, (__fp)->_IO_write_end = (__ep))
00522 #define _IO_wsetp(__fp, __p, __ep) \
00523        ((__fp)->_wide_data->_IO_write_base \
00524        = (__fp)->_wide_data->_IO_write_ptr = __p, \
00525        (__fp)->_wide_data->_IO_write_end = (__ep))
00526 #define _IO_have_backup(fp) ((fp)->_IO_save_base != NULL)
00527 #define _IO_have_wbackup(fp) ((fp)->_wide_data->_IO_save_base != NULL)
00528 #define _IO_in_backup(fp) ((fp)->_flags & _IO_IN_BACKUP)
00529 #define _IO_have_markers(fp) ((fp)->_markers != NULL)
00530 #define _IO_blen(fp) ((fp)->_IO_buf_end - (fp)->_IO_buf_base)
00531 #define _IO_wblen(fp) ((fp)->_wide_data->_IO_buf_end \
00532                      - (fp)->_wide_data->_IO_buf_base)
00533 
00534 /* Jumptable functions for files. */
00535 
00536 extern int _IO_file_doallocate (_IO_FILE *) __THROW;
00537 extern _IO_FILE* _IO_file_setbuf (_IO_FILE *, char *, _IO_ssize_t);
00538 extern _IO_off64_t _IO_file_seekoff (_IO_FILE *, _IO_off64_t, int, int);
00539 extern _IO_off64_t _IO_file_seekoff_mmap (_IO_FILE *, _IO_off64_t, int, int)
00540      __THROW;
00541 extern _IO_size_t _IO_file_xsputn (_IO_FILE *, const void *, _IO_size_t);
00542 extern _IO_size_t _IO_file_xsgetn (_IO_FILE *, void *, _IO_size_t);
00543 extern int _IO_file_stat (_IO_FILE *, void *) __THROW;
00544 extern int _IO_file_close (_IO_FILE *) __THROW;
00545 extern int _IO_file_close_mmap (_IO_FILE *) __THROW;
00546 extern int _IO_file_underflow (_IO_FILE *);
00547 extern int _IO_file_underflow_mmap (_IO_FILE *);
00548 extern int _IO_file_underflow_maybe_mmap (_IO_FILE *);
00549 extern int _IO_file_overflow (_IO_FILE *, int);
00550 #define _IO_file_is_open(__fp) ((__fp)->_fileno != -1)
00551 extern void _IO_file_init (struct _IO_FILE_plus *) __THROW;
00552 extern _IO_FILE* _IO_file_attach (_IO_FILE *, int);
00553 extern _IO_FILE* _IO_file_open (_IO_FILE *, const char *, int, int, int, int);
00554 libc_hidden_proto (_IO_file_open)
00555 extern _IO_FILE* _IO_file_fopen (_IO_FILE *, const char *, const char *, int);
00556 extern _IO_ssize_t _IO_file_write (_IO_FILE *, const void *, _IO_ssize_t);
00557 extern _IO_ssize_t _IO_file_read (_IO_FILE *, void *, _IO_ssize_t);
00558 extern int _IO_file_sync (_IO_FILE *);
00559 extern int _IO_file_close_it (_IO_FILE *);
00560 extern _IO_off64_t _IO_file_seek (_IO_FILE *, _IO_off64_t, int) __THROW;
00561 extern void _IO_file_finish (_IO_FILE *, int);
00562 
00563 extern _IO_FILE* _IO_new_file_attach (_IO_FILE *, int);
00564 extern int _IO_new_file_close_it (_IO_FILE *);
00565 extern void _IO_new_file_finish (_IO_FILE *, int);
00566 extern _IO_FILE* _IO_new_file_fopen (_IO_FILE *, const char *, const char *,
00567                                  int);
00568 extern void _IO_no_init (_IO_FILE *, int, int, struct _IO_wide_data *,
00569                       const struct _IO_jump_t *) __THROW;
00570 extern void _IO_new_file_init (struct _IO_FILE_plus *) __THROW;
00571 extern _IO_FILE* _IO_new_file_setbuf (_IO_FILE *, char *, _IO_ssize_t);
00572 extern _IO_FILE* _IO_file_setbuf_mmap (_IO_FILE *, char *, _IO_ssize_t);
00573 extern int _IO_new_file_sync (_IO_FILE *);
00574 extern int _IO_new_file_underflow (_IO_FILE *);
00575 extern int _IO_new_file_overflow (_IO_FILE *, int);
00576 extern _IO_off64_t _IO_new_file_seekoff (_IO_FILE *, _IO_off64_t, int, int);
00577 extern _IO_ssize_t _IO_new_file_write (_IO_FILE *, const void *, _IO_ssize_t);
00578 extern _IO_size_t _IO_new_file_xsputn (_IO_FILE *, const void *, _IO_size_t);
00579 
00580 extern _IO_FILE* _IO_old_file_setbuf (_IO_FILE *, char *, _IO_ssize_t);
00581 extern _IO_off64_t _IO_old_file_seekoff (_IO_FILE *, _IO_off64_t, int, int);
00582 extern _IO_size_t _IO_old_file_xsputn (_IO_FILE *, const void *, _IO_size_t);
00583 extern int _IO_old_file_underflow (_IO_FILE *);
00584 extern int _IO_old_file_overflow (_IO_FILE *, int);
00585 extern void _IO_old_file_init (struct _IO_FILE_plus *) __THROW;
00586 extern _IO_FILE* _IO_old_file_attach (_IO_FILE *, int);
00587 extern _IO_FILE* _IO_old_file_fopen (_IO_FILE *, const char *, const char *);
00588 extern _IO_ssize_t _IO_old_file_write (_IO_FILE *, const void *, _IO_ssize_t);
00589 extern int _IO_old_file_sync (_IO_FILE *);
00590 extern int _IO_old_file_close_it (_IO_FILE *);
00591 extern void _IO_old_file_finish (_IO_FILE *, int);
00592 
00593 extern int _IO_wfile_doallocate (_IO_FILE *) __THROW;
00594 extern _IO_size_t _IO_wfile_xsputn (_IO_FILE *, const void *, _IO_size_t);
00595 extern _IO_FILE* _IO_wfile_setbuf (_IO_FILE *, wchar_t *, _IO_ssize_t);
00596 extern wint_t _IO_wfile_sync (_IO_FILE *);
00597 extern wint_t _IO_wfile_underflow (_IO_FILE *);
00598 extern wint_t _IO_wfile_overflow (_IO_FILE *, wint_t);
00599 extern _IO_off64_t _IO_wfile_seekoff (_IO_FILE *, _IO_off64_t, int, int);
00600 
00601 /* Jumptable functions for proc_files. */
00602 extern _IO_FILE* _IO_proc_open (_IO_FILE *, const char *, const char *)
00603      __THROW;
00604 extern _IO_FILE* _IO_new_proc_open (_IO_FILE *, const char *, const char *)
00605      __THROW;
00606 extern _IO_FILE* _IO_old_proc_open (_IO_FILE *, const char *, const char *);
00607 extern int _IO_proc_close (_IO_FILE *) __THROW;
00608 extern int _IO_new_proc_close (_IO_FILE *) __THROW;
00609 extern int _IO_old_proc_close (_IO_FILE *);
00610 
00611 /* Jumptable functions for strfiles. */
00612 extern int _IO_str_underflow (_IO_FILE *) __THROW;
00613 extern int _IO_str_overflow (_IO_FILE *, int) __THROW;
00614 extern int _IO_str_pbackfail (_IO_FILE *, int) __THROW;
00615 extern _IO_off64_t _IO_str_seekoff (_IO_FILE *, _IO_off64_t, int, int) __THROW;
00616 extern void _IO_str_finish (_IO_FILE *, int) __THROW;
00617 
00618 /* Other strfile functions */
00619 struct _IO_strfile_;
00620 extern void _IO_str_init_static (struct _IO_strfile_ *, char *, int, char *)
00621      __THROW;
00622 extern void _IO_str_init_readonly (struct _IO_strfile_ *, const char *, int)
00623      __THROW;
00624 extern _IO_ssize_t _IO_str_count (_IO_FILE *) __THROW;
00625 
00626 /* And the wide character versions.  */
00627 extern void _IO_wstr_init_static (_IO_FILE *, wchar_t *, _IO_size_t, wchar_t *)
00628      __THROW;
00629 extern _IO_ssize_t _IO_wstr_count (_IO_FILE *) __THROW;
00630 extern _IO_wint_t _IO_wstr_overflow (_IO_FILE *, _IO_wint_t) __THROW;
00631 extern _IO_wint_t _IO_wstr_underflow (_IO_FILE *) __THROW;
00632 extern _IO_off64_t _IO_wstr_seekoff (_IO_FILE *, _IO_off64_t, int, int)
00633      __THROW;
00634 extern _IO_wint_t _IO_wstr_pbackfail (_IO_FILE *, _IO_wint_t) __THROW;
00635 extern void _IO_wstr_finish (_IO_FILE *, int) __THROW;
00636 
00637 extern int _IO_vasprintf (char **result_ptr, __const char *format,
00638                        _IO_va_list args) __THROW;
00639 extern int _IO_vdprintf (int d, __const char *format, _IO_va_list arg);
00640 extern int _IO_vsnprintf (char *string, _IO_size_t maxlen,
00641                        __const char *format, _IO_va_list args) __THROW;
00642 
00643 
00644 extern _IO_size_t _IO_getline (_IO_FILE *,char *, _IO_size_t, int, int);
00645 extern _IO_size_t _IO_getline_info (_IO_FILE *,char *, _IO_size_t,
00646                                 int, int, int *);
00647 extern _IO_ssize_t _IO_getdelim (char **, _IO_size_t *, int, _IO_FILE *);
00648 extern _IO_size_t _IO_getwline (_IO_FILE *,wchar_t *, _IO_size_t, wint_t, int);
00649 extern _IO_size_t _IO_getwline_info (_IO_FILE *,wchar_t *, _IO_size_t,
00650                                  wint_t, int, wint_t *);
00651 
00652 extern struct _IO_FILE_plus *_IO_list_all;
00653 extern void (*_IO_cleanup_registration_needed) (void);
00654 
00655 /* Prototype for functions with alternative entry point.  */
00656 extern int _IO_flush_all_internal (void);
00657 extern unsigned _IO_adjust_column_internal (unsigned, const char *, int);
00658 
00659 extern int _IO_default_uflow_internal (_IO_FILE *);
00660 extern void _IO_default_finish_internal (_IO_FILE *, int) __THROW;
00661 extern int _IO_default_pbackfail_internal (_IO_FILE *, int) __THROW;
00662 extern _IO_size_t _IO_default_xsputn_internal (_IO_FILE *, const void *,
00663                                           _IO_size_t);
00664 extern _IO_size_t _IO_default_xsgetn_internal (_IO_FILE *, void *, _IO_size_t);
00665 extern int _IO_default_doallocate_internal (_IO_FILE *) __THROW;
00666 extern void _IO_wdefault_finish_internal (_IO_FILE *, int) __THROW;
00667 extern wint_t _IO_wdefault_pbackfail_internal (_IO_FILE *, wint_t) __THROW;
00668 extern _IO_size_t _IO_wdefault_xsputn_internal (_IO_FILE *, const void *,
00669                                           _IO_size_t);
00670 extern _IO_size_t _IO_wdefault_xsgetn_internal (_IO_FILE *, void *,
00671                                           _IO_size_t);
00672 extern int _IO_wdefault_doallocate_internal (_IO_FILE *) __THROW;
00673 extern wint_t _IO_wdefault_uflow_internal (_IO_FILE *);
00674 
00675 extern int _IO_file_doallocate_internal (_IO_FILE *) __THROW;
00676 extern _IO_FILE* _IO_file_setbuf_internal (_IO_FILE *, char *, _IO_ssize_t);
00677 extern _IO_off64_t _IO_file_seekoff_internal (_IO_FILE *, _IO_off64_t,
00678                                          int, int);
00679 extern _IO_size_t _IO_file_xsputn_internal (_IO_FILE *, const void *,
00680                                        _IO_size_t);
00681 extern _IO_size_t _IO_file_xsgetn_internal (_IO_FILE *, void *, _IO_size_t);
00682 extern int _IO_file_stat_internal (_IO_FILE *, void *) __THROW;
00683 extern int _IO_file_close_internal (_IO_FILE *) __THROW;
00684 extern int _IO_file_close_it_internal (_IO_FILE *);
00685 extern int _IO_file_underflow_internal (_IO_FILE *);
00686 extern int _IO_file_overflow_internal (_IO_FILE *, int);
00687 extern void _IO_file_init_internal (struct _IO_FILE_plus *) __THROW;
00688 extern _IO_FILE* _IO_file_attach_internal (_IO_FILE *, int);
00689 extern _IO_FILE* _IO_file_fopen_internal (_IO_FILE *, const char *,
00690                                      const char *, int);
00691 extern _IO_ssize_t _IO_file_read_internal (_IO_FILE *, void *,
00692                                       _IO_ssize_t);
00693 extern int _IO_file_sync_internal (_IO_FILE *);
00694 extern _IO_off64_t _IO_file_seek_internal (_IO_FILE *, _IO_off64_t, int)
00695      __THROW;
00696 extern void _IO_file_finish_internal (_IO_FILE *, int);
00697 
00698 extern _IO_size_t _IO_wfile_xsputn_internal (_IO_FILE *, const void *,
00699                                         _IO_size_t);
00700 extern _IO_off64_t _IO_wfile_seekoff_internal (_IO_FILE *, _IO_off64_t,
00701                                           int, int);
00702 extern wint_t _IO_wfile_sync_internal (_IO_FILE *);
00703 
00704 extern int _IO_str_underflow_internal (_IO_FILE *) __THROW;
00705 extern int _IO_str_overflow_internal (_IO_FILE *, int) __THROW;
00706 extern int _IO_str_pbackfail_internal (_IO_FILE *, int) __THROW;
00707 extern _IO_off64_t _IO_str_seekoff_internal (_IO_FILE *, _IO_off64_t,
00708                                         int, int) __THROW;
00709 extern void _IO_str_init_static_internal (struct _IO_strfile_ *, char *,
00710                                      _IO_size_t, char *) __THROW;
00711 
00712 extern struct _IO_jump_t _IO_file_jumps_internal attribute_hidden;
00713 extern struct _IO_jump_t _IO_wfile_jumps_internal attribute_hidden;
00714 
00715 extern struct _IO_FILE_plus *_IO_list_all_internal attribute_hidden;
00716 
00717 extern void _IO_link_in_internal (struct _IO_FILE_plus *) __THROW;
00718 extern int _IO_sputbackc_internal (_IO_FILE *, int) __THROW;
00719 extern void _IO_wdoallocbuf_internal (_IO_FILE *) __THROW;
00720 
00721 extern _IO_size_t _IO_sgetn_internal (_IO_FILE *, void *, _IO_size_t);
00722 extern void _IO_flush_all_linebuffered_internal (void) __THROW;
00723 extern int _IO_switch_to_wget_mode_internal (_IO_FILE *);
00724 extern void _IO_unsave_markers_internal (_IO_FILE *) __THROW;
00725 extern void _IO_switch_to_main_wget_area_internal (_IO_FILE *) __THROW;
00726 extern int _IO_wdo_write_internal (_IO_FILE *, const wchar_t *, _IO_size_t);
00727 extern int _IO_do_write_internal (_IO_FILE *, const char *, _IO_size_t);
00728 extern _IO_ssize_t _IO_padn_internal (_IO_FILE *, int, _IO_ssize_t);
00729 extern _IO_size_t _IO_getline_info_internal (_IO_FILE *,char *, _IO_size_t,
00730                                         int, int, int *);
00731 extern _IO_size_t _IO_getline_internal (_IO_FILE *, char *, _IO_size_t, int,
00732                                    int);
00733 extern void _IO_free_wbackup_area_internal (_IO_FILE *) __THROW;
00734 extern void _IO_free_backup_area_internal (_IO_FILE *) __THROW;
00735 extern void _IO_switch_to_wbackup_area_internal (_IO_FILE *) __THROW;
00736 extern void _IO_setb_internal (_IO_FILE *, char *, char *, int) __THROW;
00737 extern wint_t _IO_sputbackwc_internal (_IO_FILE *, wint_t) __THROW;
00738 extern int _IO_switch_to_get_mode_internal (_IO_FILE *);
00739 extern int _IO_vfscanf_internal (_IO_FILE * __restrict,
00740                              const char * __restrict,
00741                              _IO_va_list, int *__restrict);
00742 extern int _IO_vfprintf_internal (_IO_FILE *__restrict, const char *__restrict,
00743                               _IO_va_list);
00744 extern void _IO_doallocbuf_internal (_IO_FILE *) __THROW;
00745 extern void _IO_wsetb_internal (_IO_FILE *, wchar_t *, wchar_t *, int)
00746      __THROW;
00747 extern _IO_off64_t _IO_seekoff_unlocked (_IO_FILE *, _IO_off64_t, int, int)
00748      attribute_hidden;
00749 extern _IO_off64_t _IO_seekpos_unlocked (_IO_FILE *, _IO_off64_t, int)
00750      attribute_hidden;
00751 extern int _IO_putc_internal (int __c, _IO_FILE *__fp);
00752 extern void _IO_init_internal (_IO_FILE *, int) __THROW;
00753 extern void _IO_un_link_internal (struct _IO_FILE_plus *) __THROW;
00754 
00755 #ifndef EOF
00756 # define EOF (-1)
00757 #endif
00758 #ifndef NULL
00759 # if defined __GNUG__ && \
00760     (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
00761 #  define NULL (__null)
00762 # else
00763 #  if !defined(__cplusplus)
00764 #   define NULL ((void*)0)
00765 #  else
00766 #   define NULL (0)
00767 #  endif
00768 # endif
00769 #endif
00770 
00771 #if _G_HAVE_MMAP
00772 
00773 # include <unistd.h>
00774 # include <fcntl.h>
00775 # include <sys/mman.h>
00776 # include <sys/param.h>
00777 
00778 # if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
00779 #  define MAP_ANONYMOUS MAP_ANON
00780 # endif
00781 
00782 # if !defined(MAP_ANONYMOUS) || !defined(EXEC_PAGESIZE)
00783 #  undef _G_HAVE_MMAP
00784 #  define _G_HAVE_MMAP 0
00785 # endif
00786 
00787 #endif /* _G_HAVE_MMAP */
00788 
00789 #if _G_HAVE_MMAP
00790 
00791 # ifdef _LIBC
00792 /* When using this code in the GNU libc we must not pollute the name space.  */
00793 #  define mmap __mmap
00794 #  define munmap __munmap
00795 #  define ftruncate __ftruncate
00796 # endif
00797 
00798 # define ROUND_TO_PAGE(_S) \
00799        (((_S) + EXEC_PAGESIZE - 1) & ~(EXEC_PAGESIZE - 1))
00800 
00801 # define FREE_BUF(_B, _S) \
00802        munmap ((_B), ROUND_TO_PAGE (_S))
00803 # define ALLOC_BUF(_B, _S, _R) \
00804        do {                                                          \
00805          (_B) = (char *) mmap (0, ROUND_TO_PAGE (_S),                       \
00806                             PROT_READ | PROT_WRITE,                         \
00807                             MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);            \
00808          if ((_B) == (char *) MAP_FAILED)                            \
00809            return (_R);                                              \
00810        } while (0)
00811 # define ALLOC_WBUF(_B, _S, _R) \
00812        do {                                                          \
00813          (_B) = (wchar_t *) mmap (0, ROUND_TO_PAGE (_S),                    \
00814                                PROT_READ | PROT_WRITE,               \
00815                                MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);         \
00816          if ((_B) == (wchar_t *) MAP_FAILED)                                \
00817            return (_R);                                              \
00818        } while (0)
00819 
00820 #else /* _G_HAVE_MMAP */
00821 
00822 # define FREE_BUF(_B, _S) \
00823        free(_B)
00824 # define ALLOC_BUF(_B, _S, _R) \
00825        do {                                                          \
00826          (_B) = (char*)malloc(_S);                                   \
00827          if ((_B) == NULL)                                           \
00828            return (_R);                                              \
00829        } while (0)
00830 # define ALLOC_WBUF(_B, _S, _R) \
00831        do {                                                          \
00832          (_B) = (wchar_t *)malloc(_S);                                      \
00833          if ((_B) == NULL)                                           \
00834            return (_R);                                              \
00835        } while (0)
00836 
00837 #endif /* _G_HAVE_MMAP */
00838 
00839 #ifndef OS_FSTAT
00840 # define OS_FSTAT fstat
00841 #endif
00842 extern int _IO_vscanf (const char *, _IO_va_list) __THROW;
00843 
00844 /* _IO_pos_BAD is an _IO_off64_t value indicating error, unknown, or EOF. */
00845 #ifndef _IO_pos_BAD
00846 # define _IO_pos_BAD ((_IO_off64_t) -1)
00847 #endif
00848 /* _IO_pos_adjust adjust an _IO_off64_t by some number of bytes. */
00849 #ifndef _IO_pos_adjust
00850 # define _IO_pos_adjust(pos, delta) ((pos) += (delta))
00851 #endif
00852 /* _IO_pos_0 is an _IO_off64_t value indicating beginning of file. */
00853 #ifndef _IO_pos_0
00854 # define _IO_pos_0 ((_IO_off64_t) 0)
00855 #endif
00856 
00857 #ifdef __cplusplus
00858 }
00859 #endif
00860 
00861 #ifdef _IO_MTSAFE_IO
00862 /* check following! */
00863 # ifdef _IO_USE_OLD_IO_FILE
00864 #  define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
00865        { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
00866         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
00867         0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock }
00868 # else
00869 #  if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
00870 #   define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
00871        { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
00872         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
00873         0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\
00874         NULL, WDP, 0 }
00875 #  else
00876 #   define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
00877        { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
00878         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
00879         0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\
00880         0 }
00881 #  endif
00882 # endif
00883 #else
00884 # ifdef _IO_USE_OLD_IO_FILE
00885 #  define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
00886        { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
00887         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
00888         0, _IO_pos_BAD }
00889 # else
00890 #  if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
00891 #   define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
00892        { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
00893         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
00894         0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \
00895         NULL, WDP, 0 }
00896 #  else
00897 #   define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
00898        { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
00899         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
00900         0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \
00901         0 }
00902 #  endif
00903 # endif
00904 #endif
00905 
00906 /* VTABLE_LABEL defines NAME as of the CLASS class.
00907    CNLENGTH is strlen(#CLASS).  */
00908 #ifdef __GNUC__
00909 # if _G_VTABLE_LABEL_HAS_LENGTH
00910 #  define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \
00911   extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CNLENGTH #CLASS);
00912 # else
00913 #  define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \
00914   extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CLASS);
00915 # endif
00916 #endif /* __GNUC__ */
00917 
00918 #if !defined(builtinbuf_vtable) && defined(__cplusplus)
00919 # ifdef __GNUC__
00920 VTABLE_LABEL(builtinbuf_vtable, builtinbuf, 10)
00921 # else
00922 #  if _G_VTABLE_LABEL_HAS_LENGTH
00923 #   define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##10builtinbuf
00924 #  else
00925 #   define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##builtinbuf
00926 #  endif
00927 # endif
00928 #endif /* !defined(builtinbuf_vtable) && defined(__cplusplus) */
00929 
00930 #if defined(__STDC__) || defined(__cplusplus)
00931 # define _IO_va_start(args, last) va_start(args, last)
00932 #else
00933 # define _IO_va_start(args, last) va_start(args)
00934 #endif
00935 
00936 extern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf;
00937 
00938 #if 1
00939 # define COERCE_FILE(FILE) /* Nothing */
00940 #else
00941 /* This is part of the kludge for binary compatibility with old stdio. */
00942 # define COERCE_FILE(FILE) \
00943   (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) == _OLD_MAGIC_MASK \
00944     && (FILE) = *(FILE**)&((int*)fp)[1])
00945 #endif
00946 
00947 #ifdef EINVAL
00948 # define MAYBE_SET_EINVAL __set_errno (EINVAL)
00949 #else
00950 # define MAYBE_SET_EINVAL /* nothing */
00951 #endif
00952 
00953 #ifdef IO_DEBUG
00954 # define CHECK_FILE(FILE, RET) \
00955        if ((FILE) == NULL) { MAYBE_SET_EINVAL; return RET; } \
00956        else { COERCE_FILE(FILE); \
00957               if (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \
00958          { MAYBE_SET_EINVAL; return RET; }}
00959 #else
00960 # define CHECK_FILE(FILE, RET) COERCE_FILE (FILE)
00961 #endif
00962 
00963 static inline void
00964 __attribute__ ((__always_inline__))
00965 _IO_acquire_lock_fct (_IO_FILE **p)
00966 {
00967   _IO_FILE *fp = *p;
00968   if ((fp->_flags & _IO_USER_LOCK) == 0)
00969     _IO_funlockfile (fp);
00970 }
00971 
00972 static inline void
00973 __attribute__ ((__always_inline__))
00974 _IO_acquire_lock_clear_flags2_fct (_IO_FILE **p)
00975 {
00976   _IO_FILE *fp = *p;
00977   fp->_flags2 &= ~(_IO_FLAGS2_FORTIFY | _IO_FLAGS2_SCANF_STD);
00978   if ((fp->_flags & _IO_USER_LOCK) == 0)
00979     _IO_funlockfile (fp);
00980 }