Initial revision
[gcc.git] / libio / libioP.h
index 2337071d396ba5886e4ba2f47eb74b9fa1f3afc0..629e4fd8cf656a56312cbe5f7f6dfaaed41223c0 100644 (file)
    other reasons why the executable file might be covered by the GNU
    General Public License.  */
 
+#ifndef _POSIX_SOURCE
+# define _POSIX_SOURCE
+#endif
+
 #include <errno.h>
 #ifndef __set_errno
 # define __set_errno(Val) errno = (Val)
 #endif
-#if defined __GLIBC__ && __GLIBC__ >= 2
-# include <bits/libc-lock.h>
-#else
+
+#ifdef _IO_MTSAFE_IO
+# if defined __GLIBC__ && __GLIBC__ >= 2
+#  if __GLIBC_MINOR__ > 0
+#   include <bits/libc-lock.h>
+#  else
+#   include <libc-lock.h>
+#  endif
+# else
 /*# include <comthread.h>*/
+# endif
 #endif
 
 #include "iolibio.h"
@@ -87,20 +98,20 @@ extern "C" {
 /* The 'finish' function does any final cleaning up of an _IO_FILE object.
    It does not delete (free) it, but does everything else to finalize it/
    It matches the streambuf::~streambuf virtual destructor.  */
-typedef void (*_IO_finish_t) __P ((_IO_FILE *, int)); /* finalize */
+typedef void (*_IO_finish_t) __PMT ((_IO_FILE *, int)); /* finalize */
 #define _IO_FINISH(FP) JUMP1 (__finish, FP, 0)
 
 /* The 'overflow' hook flushes the buffer.
    The second argument is a character, or EOF.
    It matches the streambuf::overflow virtual function. */
-typedef int (*_IO_overflow_t) __P ((_IO_FILE *, int));
+typedef int (*_IO_overflow_t) __PMT ((_IO_FILE *, int));
 #define _IO_OVERFLOW(FP, CH) JUMP1 (__overflow, FP, CH)
 
 /* The 'underflow' hook tries to fills the get buffer.
    It returns the next character (as an unsigned char) or EOF.  The next
    character remains in the get buffer, and the get position is not changed.
    It matches the streambuf::underflow virtual function. */
-typedef int (*_IO_underflow_t) __P ((_IO_FILE *));
+typedef int (*_IO_underflow_t) __PMT ((_IO_FILE *));
 #define _IO_UNDERFLOW(FP) JUMP0 (__underflow, FP)
 
 /* The 'uflow' hook returns the next character in the input stream
@@ -112,20 +123,20 @@ typedef int (*_IO_underflow_t) __P ((_IO_FILE *));
 
 /* The 'pbackfail' hook handles backing up.
    It matches the streambuf::pbackfail virtual function. */
-typedef int (*_IO_pbackfail_t) __P ((_IO_FILE *, int));
+typedef int (*_IO_pbackfail_t) __PMT ((_IO_FILE *, int));
 #define _IO_PBACKFAIL(FP, CH) JUMP1 (__pbackfail, FP, CH)
 
 /* The 'xsputn' hook writes upto N characters from buffer DATA.
    Returns the number of character actually written.
    It matches the streambuf::xsputn virtual function. */
-typedef _IO_size_t (*_IO_xsputn_t) __P ((_IO_FILE *FP, const void *DATA,
+typedef _IO_size_t (*_IO_xsputn_t) __PMT ((_IO_FILE *FP, const void *DATA,
                                         _IO_size_t N));
 #define _IO_XSPUTN(FP, DATA, N) JUMP2 (__xsputn, FP, DATA, N)
 
 /* The 'xsgetn' hook reads upto N characters into buffer DATA.
    Returns the number of character actually read.
    It matches the streambuf::xsgetn virtual function. */
-typedef _IO_size_t (*_IO_xsgetn_t) __P ((_IO_FILE *FP, void *DATA,
+typedef _IO_size_t (*_IO_xsgetn_t) __PMT ((_IO_FILE *FP, void *DATA,
                                         _IO_size_t N));
 #define _IO_XSGETN(FP, DATA, N) JUMP2 (__xsgetn, FP, DATA, N)
 
@@ -134,8 +145,13 @@ typedef _IO_size_t (*_IO_xsgetn_t) __P ((_IO_FILE *FP, void *DATA,
    (MODE==1), or the end of the file (MODE==2).
    It matches the streambuf::seekoff virtual function.
    It is also used for the ANSI fseek function. */
-typedef _IO_fpos_t (*_IO_seekoff_t) __P ((_IO_FILE *FP, _IO_off_t OFF,
+#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
+typedef _IO_fpos64_t (*_IO_seekoff_t) __PMT ((_IO_FILE *FP, _IO_off64_t OFF,
+                                         int DIR, int MODE));
+#else
+typedef _IO_fpos_t (*_IO_seekoff_t) __PMT ((_IO_FILE *FP, _IO_off_t OFF,
                                          int DIR, int MODE));
+#endif
 #define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3 (__seekoff, FP, OFF, DIR, MODE)
 
 /* The 'seekpos' hook also moves the stream position,
@@ -143,24 +159,28 @@ typedef _IO_fpos_t (*_IO_seekoff_t) __P ((_IO_FILE *FP, _IO_off_t OFF,
    It matches the streambuf::seekpos virtual function.
    It is also used for the ANSI fgetpos and fsetpos functions.  */
 /* The _IO_seek_cur and _IO_seek_end options are not allowed. */
-typedef _IO_fpos_t (*_IO_seekpos_t) __P ((_IO_FILE *, _IO_fpos_t, int));
+#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
+typedef _IO_fpos64_t (*_IO_seekpos_t) __PMT ((_IO_FILE *, _IO_fpos64_t, int));
+#else
+typedef _IO_fpos_t (*_IO_seekpos_t) __PMT ((_IO_FILE *, _IO_fpos_t, int));
+#endif
 #define _IO_SEEKPOS(FP, POS, FLAGS) JUMP2 (__seekpos, FP, POS, FLAGS)
 
 /* The 'setbuf' hook gives a buffer to the file.
    It matches the streambuf::setbuf virtual function. */
-typedef _IO_FILE* (*_IO_setbuf_t) __P ((_IO_FILE *, char *, _IO_ssize_t));
+typedef _IO_FILE* (*_IO_setbuf_t) __PMT ((_IO_FILE *, char *, _IO_ssize_t));
 #define _IO_SETBUF(FP, BUFFER, LENGTH) JUMP2 (__setbuf, FP, BUFFER, LENGTH)
 
 /* The 'sync' hook attempts to synchronize the internal data structures
    of the file with the external state.
    It matches the streambuf::sync virtual function. */
-typedef int (*_IO_sync_t) __P ((_IO_FILE *));
+typedef int (*_IO_sync_t) __PMT ((_IO_FILE *));
 #define _IO_SYNC(FP) JUMP0 (__sync, FP)
 
 /* The 'doallocate' hook is used to tell the file to allocate a buffer.
    It matches the streambuf::doallocate virtual function, which is not
    in the ANSI/ISO C++ standard, but is part traditional implementations. */
-typedef int (*_IO_doallocate_t) __P ((_IO_FILE *));
+typedef int (*_IO_doallocate_t) __PMT ((_IO_FILE *));
 #define _IO_DOALLOCATE(FP) JUMP0 (__doallocate, FP)
 
 /* The following four hooks (sysread, syswrite, sysclose, sysseek, and
@@ -178,37 +198,54 @@ typedef int (*_IO_doallocate_t) __P ((_IO_FILE *));
    an existing buffer.  It generalizes the Unix read(2) function.
    It matches the streambuf::sys_read virtual function, which is
    specific to this implementation. */
-typedef _IO_ssize_t (*_IO_read_t) __P ((_IO_FILE *, void *, _IO_ssize_t));
+typedef _IO_ssize_t (*_IO_read_t) __PMT ((_IO_FILE *, void *, _IO_ssize_t));
 #define _IO_SYSREAD(FP, DATA, LEN) JUMP2 (__read, FP, DATA, LEN)
 
 /* The 'syswrite' hook is used to write data from an existing buffer
    to an external file.  It generalizes the Unix write(2) function.
    It matches the streambuf::sys_write virtual function, which is
    specific to this implementation. */
-typedef _IO_ssize_t (*_IO_write_t) __P ((_IO_FILE *,const void *,_IO_ssize_t));
+typedef _IO_ssize_t (*_IO_write_t) __PMT ((_IO_FILE *,const void *,_IO_ssize_t));
 #define _IO_SYSWRITE(FP, DATA, LEN) JUMP2 (__write, FP, DATA, LEN)
 
 /* The 'sysseek' hook is used to re-position an external file.
    It generalizes the Unix lseek(2) function.
    It matches the streambuf::sys_seek virtual function, which is
    specific to this implementation. */
-typedef _IO_fpos_t (*_IO_seek_t) __P ((_IO_FILE *, _IO_off_t, int));
+#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
+typedef _IO_fpos64_t (*_IO_seek_t) __PMT ((_IO_FILE *, _IO_off64_t, int));
+#else
+typedef _IO_fpos_t (*_IO_seek_t) __PMT ((_IO_FILE *, _IO_off_t, int));
+#endif
 #define _IO_SYSSEEK(FP, OFFSET, MODE) JUMP2 (__seek, FP, OFFSET, MODE)
 
 /* The 'sysclose' hook is used to finalize (close, finish up) an
    external file.  It generalizes the Unix close(2) function.
    It matches the streambuf::sys_close virtual function, which is
    specific to this implementation. */
-typedef int (*_IO_close_t) __P ((_IO_FILE *)); /* finalize */
+typedef int (*_IO_close_t) __PMT ((_IO_FILE *)); /* finalize */
 #define _IO_SYSCLOSE(FP) JUMP0 (__close, FP)
 
 /* The 'sysstat' hook is used to get information about an external file
    into a struct stat buffer.  It generalizes the Unix fstat(2) call.
    It matches the streambuf::sys_stat virtual function, which is
    specific to this implementation. */
-typedef int (*_IO_stat_t) __P ((_IO_FILE *, void *));
+typedef int (*_IO_stat_t) __PMT ((_IO_FILE *, void *));
 #define _IO_SYSSTAT(FP, BUF) JUMP1 (__stat, FP, BUF)
 
+#if _G_IO_IO_FILE_VERSION == 0x20001
+/* The 'showmany' hook can be used to get an image how much input is
+   available.  In many cases the answer will be 0 which means unknown
+   but some cases one can provide real information.  */
+typedef int (*_IO_showmanyc_t) __PMT ((_IO_FILE *));
+#define _IO_SHOWMANYC(FP) JUMP0 (__showmanyc, FP)
+
+/* The 'imbue' hook is used to get information about the currently
+   installed locales.  */
+typedef void (*_IO_imbue_t) __PMT ((_IO_FILE *, void *));
+#define _IO_IMBUE(FP, LOCALE) JUMP1 (__imbue, FP, LOCALE)
+#endif
+
 
 #define _IO_CHAR_TYPE char /* unsigned char ? */
 #define _IO_INT_TYPE int
@@ -237,6 +274,10 @@ struct _IO_jump_t
     JUMP_FIELD(_IO_seek_t, __seek);
     JUMP_FIELD(_IO_close_t, __close);
     JUMP_FIELD(_IO_stat_t, __stat);
+#if _G_IO_IO_FILE_VERSION == 0x20001
+    JUMP_FIELD(_IO_showmanyc_t, __showmanyc);
+    JUMP_FIELD(_IO_imbue_t, __imbue);
+#endif
 #if 0
     get_column;
     set_column;
@@ -256,8 +297,13 @@ struct _IO_FILE_plus
 
 /* Generic functions */
 
+#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
+extern _IO_fpos64_t _IO_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
+extern _IO_fpos64_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos64_t, int));
+#else
 extern _IO_fpos_t _IO_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
 extern _IO_fpos_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos_t, int));
+#endif
 
 extern void _IO_switch_to_main_get_area __P ((_IO_FILE *));
 extern void _IO_switch_to_backup_area __P ((_IO_FILE *));
@@ -293,13 +339,24 @@ extern _IO_FILE* _IO_default_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t));
 extern _IO_size_t _IO_default_xsputn __P ((_IO_FILE *, const void *,
                                           _IO_size_t));
 extern _IO_size_t _IO_default_xsgetn __P ((_IO_FILE *, void *, _IO_size_t));
+#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
+extern _IO_fpos64_t _IO_default_seekoff __P ((_IO_FILE *,
+                                             _IO_off64_t, int, int));
+extern _IO_fpos64_t _IO_default_seekpos __P ((_IO_FILE *,
+                                             _IO_fpos64_t, int));
+#else
 extern _IO_fpos_t _IO_default_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
 extern _IO_fpos_t _IO_default_seekpos __P ((_IO_FILE *, _IO_fpos_t, int));
+#endif
 extern _IO_ssize_t _IO_default_write __P ((_IO_FILE *, const void *,
                                           _IO_ssize_t));
 extern _IO_ssize_t _IO_default_read __P ((_IO_FILE *, void *, _IO_ssize_t));
 extern int _IO_default_stat __P ((_IO_FILE *, void *));
+#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
+extern _IO_fpos64_t _IO_default_seek __P ((_IO_FILE *, _IO_off64_t, int));
+#else
 extern _IO_fpos_t _IO_default_seek __P ((_IO_FILE *, _IO_off_t, int));
+#endif
 extern int _IO_default_sync __P ((_IO_FILE *));
 #define _IO_default_close ((_IO_close_t) _IO_default_sync)
 
@@ -331,7 +388,13 @@ extern void _IO_flush_all_linebuffered __P ((void));
 
 extern int _IO_file_doallocate __P ((_IO_FILE *));
 extern _IO_FILE* _IO_file_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t));
+#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
+extern _IO_fpos64_t _IO_file_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
+extern _IO_fpos64_t _IO_file_seek __P ((_IO_FILE *, _IO_off64_t, int));
+#else
 extern _IO_fpos_t _IO_file_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
+extern _IO_fpos_t _IO_file_seek __P ((_IO_FILE *, _IO_off_t, int));
+#endif
 extern _IO_size_t _IO_file_xsputn __P ((_IO_FILE *, const void *, _IO_size_t));
 extern int _IO_file_stat __P ((_IO_FILE *, void *));
 extern int _IO_file_close __P ((_IO_FILE *));
@@ -340,13 +403,19 @@ extern int _IO_file_overflow __P ((_IO_FILE *, int));
 #define _IO_file_is_open(__fp) ((__fp)->_fileno >= 0)
 extern void _IO_file_init __P ((_IO_FILE *));
 extern _IO_FILE* _IO_file_attach __P ((_IO_FILE *, int));
+extern _IO_FILE* _IO_file_open __P ((_IO_FILE *, const char *, int, int,
+                                    int, int));
+#if _G_IO_IO_FILE_VERSION == 0x20001
+extern _IO_FILE* _IO_file_fopen __P ((_IO_FILE *, const char *, const char *,
+                                     int));
+#else
 extern _IO_FILE* _IO_file_fopen __P ((_IO_FILE *, const char *, const char *));
+#endif
 extern _IO_ssize_t _IO_file_write __P ((_IO_FILE *, const void *,
                                        _IO_ssize_t));
 extern _IO_ssize_t _IO_file_read __P ((_IO_FILE *, void *, _IO_ssize_t));
 extern int _IO_file_sync __P ((_IO_FILE *));
 extern int _IO_file_close_it __P ((_IO_FILE *));
-extern _IO_fpos_t _IO_file_seek __P ((_IO_FILE *, _IO_off_t, int));
 extern void _IO_file_finish __P ((_IO_FILE *, int));
 
 /* Jumptable functions for proc_files. */
@@ -357,7 +426,11 @@ extern int _IO_proc_close __P ((_IO_FILE *));
 extern int _IO_str_underflow __P ((_IO_FILE *));
 extern int _IO_str_overflow __P ((_IO_FILE *, int));
 extern int _IO_str_pbackfail __P ((_IO_FILE *, int));
+#if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
+extern _IO_fpos64_t _IO_str_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
+#else
 extern _IO_fpos_t _IO_str_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
+#endif
 extern void _IO_str_finish __P ((_IO_FILE *, int));
 
 /* Other strfile functions */
@@ -373,6 +446,8 @@ extern int _IO_vsnprintf __P ((char *string, _IO_size_t maxlen,
 
 
 extern _IO_size_t _IO_getline __P ((_IO_FILE *,char *, _IO_size_t, int, int));
+extern _IO_size_t _IO_getline_info __P ((_IO_FILE *,char *, _IO_size_t,
+                                        int, int, int *));
 extern _IO_ssize_t _IO_getdelim __P ((char **, _IO_size_t *, int, _IO_FILE *));
 extern double _IO_strtod __P ((const char *, char **));
 extern char *_IO_dtoa __P ((double __d, int __mode, int __ndigits,
@@ -382,7 +457,7 @@ extern int _IO_outfloat __P ((double __value, _IO_FILE *__sb, int __type,
                              int __sign_mode, int __fill));
 
 extern _IO_FILE *_IO_list_all;
-extern void (*_IO_cleanup_registration_needed) __P ((void));
+extern void (*_IO_cleanup_registration_needed) __PMT ((void));
 
 #ifndef EOF
 # define EOF (-1)
@@ -471,11 +546,19 @@ extern int _IO_vscanf __P ((const char *, _IO_va_list));
 
 /* _IO_pos_BAD is an _IO_fpos_t value indicating error, unknown, or EOF. */
 #ifndef _IO_pos_BAD
-# define _IO_pos_BAD ((_IO_fpos_t) -1)
+# if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
+#  define _IO_pos_BAD ((_IO_fpos64_t) -1)
+# else
+#  define _IO_pos_BAD ((_IO_fpos_t) -1)
+# endif
 #endif
 /* _IO_pos_as_off converts an _IO_fpos_t value to an _IO_off_t value. */
 #ifndef _IO_pos_as_off
-# define _IO_pos_as_off(__pos) ((_IO_off_t) (__pos))
+# if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
+#  define _IO_pos_as_off(__pos) ((_IO_off64_t) (__pos))
+# else
+#  define _IO_pos_as_off(__pos) ((_IO_off_t) (__pos))
+# endif
 #endif
 /* _IO_pos_adjust adjust an _IO_fpos_t by some number of bytes. */
 #ifndef _IO_pos_adjust
@@ -483,7 +566,11 @@ extern int _IO_vscanf __P ((const char *, _IO_va_list));
 #endif
 /* _IO_pos_0 is an _IO_fpos_t value indicating beginning of file. */
 #ifndef _IO_pos_0
-# define _IO_pos_0 ((_IO_fpos_t) 0)
+# if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001
+#  define _IO_pos_0 ((_IO_fpos64_t) 0)
+# else
+#  define _IO_pos_0 ((_IO_fpos_t) 0)
+# endif
 #endif
 
 #ifdef __cplusplus