libio patch

H.J. Lu hjl@lucon.org
Mon Sep 8 14:32:00 GMT 1997


> 
> 	> I can't get egcs-970904 to build on linux/glibc-2.0.5.  Libio has
> 	> trouble due to conflicts with headers from glibc.
> 
> 	As I said many times, it won't work as is. I will make a new
> 	libio/libstdcc++ patch in a day or 2 after cleaning up my code.
> 
> You are getting your versions confused here.  egcs-970904 has the old libio
> that will not work under linux/glibc2.  egcs-970907 has the new libio that
> should work under linux/glibc2.
> 
> We have already fixed the problems that you have complained about so many
> times by merging in the new libio code.  If there is some reason why the
> new libio code does not work, then please explain what the problem is.
> 
> Jim
> 

There are many problems in the current libio in egcs.

1. The libio is too old. Ulrich, I have sent you a patch for
libio in glibc 2.1 a few days ago. I can resend them to you
if you want. My patch supports libc 5, libg++, egcs, glibc 2.0
and glibc 2.1.
2. _G_HAVE_LONG_DOUBLE_IO is checked, but not defined. I
changed it to _G_HAVE_GLIBC since I only implemented long
double output using glibc.
3. linux doesn't need stdfiles.o.
4. Not all ar likes

# ar rc libio.a

5. We have to support libio in libc which has an incompatible
vtable thunks support with g++. That means we have to provide
the incompatible part of libio.
6. iostream has no MT-safe support. Applications with glibc
many dump core because of it.
7. There is no parallel make support in dbz and tests.

My patch fixes all of them. If you have more questions, pelase
let me know.

Thanks.


-- 
H.J. Lu (hjl@gnu.ai.mit.edu)
---
Mon Sep  8 07:58:23 1997  H.J. Lu  (hjl@gnu.ai.mit.edu)

	* Makefile.in (STDIO_OBJECTS): New. Defined as stdfiles.o.
	(LIBIO_OBJECTS): Add $(STDIO_OBJECTS).
	(empty.c): New target for an empty C file.
	(libio.a): Also depend on empty.o. If $(LIBIO_OBJECTS) is
	empty, create libio.a with empty.o.

	* config.shared (DISTCLEAN): Add target-mkfrag.

	* configure.in (*-linux*): Remove warning. Check vtable thunks
	in libc and compiler. Add mtsafe.mt/libio.mt to frags when
	appropriate.
	(ALL): Remove $(_G_CONFIG_H).
	(EXTRA_DISTCLEAN): New. set to dummy.c.

	* gen-params (sigset_t): Don't generate.
	(_G_ullong): Also check unsigned long long int.
	(_G_llong): Also check long long int.
	(HAVE_FEATURES): Set to 1 if  <features.h> exists.
	(_G_HAVE_GLIBC, _G_HAVE_LIBIO_IN_LIBC, _G_HAVE_LONG_DOUBLE_IO):
	New.

	* genops.c (__dummy): New if _IO_USE_LIBC is defined. Used to
	get the incompatible functions in libio.

	* iofclose.c (fclose): Make it weak alias of _IO_fclose if
	_IO_USE_LIBC is defined.

	* iofdopen.c (fdopen): Make it weak alias of _IO_fdopen if
	_IO_USE_LIBC is defined.

	* iofflush.c (fflush): Make it weak alias of _IO_fflush if
	_IO_USE_LIBC is defined.

	* iofopen.c (fopen): Make it weak alias of _IO_fopen if
	_IO_USE_LIBC is defined.

	* iofputs.c (fputs): Make it weak alias of _IO_fputs if
	_IO_USE_LIBC is defined.

	* iofwrite.c (fwrite): Make it weak alias of _IO_fwrite if
	_IO_USE_LIBC is defined.

	* iopopen.c (popen): Make it alias of _IO_popen if
	_IO_USE_LIBC is defined.

	* ioputs.c (puts): Make it weak alias of _IO_puts if
	_IO_USE_LIBC is defined.

	* iosetbuffer.c (setbuffer): Make it weak alias of _IO_setbuffer
	if _IO_USE_LIBC is defined.

	* iosetvbuf.c (setvbuf): Make it weak alias of _IO_setvbuf if
	_IO_USE_LIBC is defined.

	* iovfprintf.c (__cvt_double): Declared.
	(vfprintf): Make it alias of _IO_vfprintf if _IO_USE_LIBC is
	defined.

	* iovfscanf.c (__vfscanf): New. Defined if _IO_USE_LIBC is
	defined.

	* iovsprintf.c (vsprintf): Make it weak alias of _IO_vsprintf
	if _IO_USE_LIBC is defined.

	* iovsscanf.c (vsscanf, __vsscanf): Make them weak alias of
	_IO_vsscanf if _IO_USE_LIBC is defined.

	* iolibio.h, libio.h, libioP.h: Update from glibc 2.1.

	* iovasprintf.c: New. Copied from glibc, libio/vasprintf.c.

	* iovsnprintf.c: New. Copied from glibc, libio/vsnprintf.c.

	* outfloat.c: Define only if _IO_USE_DTOA is defined.

	* iostream.cc (__cvt_double, __printf_fp): Declared when
	appropriate.
	(istream& istream::operator>>(long double& x),
	ostream& ostream::operator<<(long double n)): Use long
	double in libio in glibc when appropriate.
	(ostream& ostream::operator<<(double n)): Use in libio in glibc
	when appropriate.

	* iostream.h (ostream& ostream::operator<<(long double n)):
	Don't inline if _G_HAVE_GLIBC is 1, not _G_HAVE_LONG_DOUBLE_IO.

	* stdstrbufs.cc: Include "_G_config.h".
	(DEF_STDFILE): Initialize lock if _IO_MTSAFE_IO is defined.

	* streambuf.cc (_IO_sb_finish): Add dummy int arg.
	(streambuf::streambuf(int flags)): Allocate a lock if
	_IO_MTSAFE_IO is defined.
	(streambuf::~streambuf()): Delete the lock if _IO_MTSAFE_IO is
	defined.

	* streambuf.h (_G_NEED_STDARG_H): Changed from
	_IO_NEED_STDARG_H.

	* config/linux.mt: Update.

	* config/libio.mt, config/mtsafe.mt: New.

	* dbz/Makefile.in (check): Support make -j.

	* tests/tFile.cc (tempfile): Use the different tmp filename for
	different runs to support make -j.
Index: libio/Makefile.in
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/Makefile.in,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 Makefile.in
--- libio/Makefile.in	1997/09/08 01:01:00	1.1.1.2
+++ libio/Makefile.in	1997/09/08 02:04:05
@@ -32,6 +32,8 @@
   outfloat.o strops.o iofclose.o iopopen.o ioungetc.o peekc.o iogetc.o \
   ioputc.o iofeof.o ioferror.o
 
+STDIO_OBJECTS = stdfiles.o
+
 # These emulate stdio functionality, but with a different name (_IO_ungetc
 # instead of ungetc), and using _IO_FILE instead of FILE.
 # They are not needed for C++ iostream, nor stdio, though some stdio
@@ -56,7 +58,8 @@
 OSPRIM_OBJECTS = ioprims.o iostrerror.o cleanup.o
 
 LIBIOSTREAM_OBJECTS = $(IO_OBJECTS) $(IOSTREAM_OBJECTS) $(OSPRIM_OBJECTS)
-LIBIO_OBJECTS = $(IO_OBJECTS) $(STDIO_WRAP_OBJECTS) $(OSPRIM_OBJECTS) stdfiles.o
+LIBIO_OBJECTS = $(IO_OBJECTS) $(STDIO_OBJECTS) $(STDIO_WRAP_OBJECTS) \
+		$(OSPRIM_OBJECTS)
 
 LIBIOSTREAM_DEP = $(LIBIOSTREAM_OBJECTS)
 LIBIOSTREAM_USE = $(LIBIOSTREAM_OBJECTS)
@@ -66,10 +69,14 @@
 #### package, host, target, and site dependent Makefile fragments come in here.
 ##
 
-libio.a: $(_G_CONFIG_H) $(LIBIO_OBJECTS)
+libio.a: $(_G_CONFIG_H) $(LIBIO_OBJECTS) empty.o
 	-rm -rf libio.a
-	$(AR) $(AR_FLAGS) libio.a $(LIBIO_OBJECTS)
+	$(AR) $(AR_FLAGS) libio.a $(LIBIO_OBJECTS) \
+	  `test x = x"$(LIBIO_OBJECTS)" && echo empty.o`
 	$(RANLIB) libio.a
+
+empty.c: Makefile
+	echo '/* empty file */' > empty.c
 
 libiostream.a: $(_G_CONFIG_H) $(LIBIOSTREAM_DEP)
 	-rm -rf libiostream.a
Index: libio/config.shared
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/config.shared,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 config.shared
--- libio/config.shared	1997/08/26 00:21:26	1.1.1.1
+++ libio/config.shared	1997/08/26 01:42:20
@@ -395,7 +395,7 @@
 
 MOSTLYCLEAN="${MOSTLYCLEAN-*.o pic stamp-picdir core ${EXTRA_MOSTLYCLEAN}} `if test -n "${TOUCH_ON_COMPILE}"; then echo stamp; else true; fi`"
 CLEAN="${CLEAN-${TARGETPROG} ${TARGETLIB}}"
-DISTCLEAN="${DISTCLEAN-config.status Makefile *~ Make.pack multilib.out ${EXTRA_DISTCLEAN-}}"
+DISTCLEAN="${DISTCLEAN-config.status Makefile *~ Make.pack target-mkfrag multilib.out ${EXTRA_DISTCLEAN-}}"
 REALCLEAN="${REALCLEAN-depend *.info*}"
 
 
Index: libio/configure.in
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/configure.in,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 configure.in
--- libio/configure.in	1997/09/08 01:01:01	1.1.1.2
+++ libio/configure.in	1997/09/08 02:06:30
@@ -15,17 +15,111 @@
 frags=
 
 case "${target}" in
-  *-hpux*)       frags=hpux.mt ;;
-  *-linux*)      
-	echo "WARNING:  The I/O implementation in FSF libg++ 2.8.x is not"
-	echo "  compatible with Linux libc through 5.2.x."
-	echo "  See libg++/README for more information."
-	echo "  YOU ARE ON YOUR OWN!"
-		 frags=linux.mt ;;
-  *-sco3.2v[45]*)   frags=sco4.mt ;;
-  *-isc*)        frags=isc.mt ;;
-  *-netware*)    frags=netware.mt ;;
-  *)             frags=${target_cpu}.mt ;;
+  *-hpux*)
+    frags=hpux.mt
+    ;;
+  *-linux*aout*)
+    frags=linux.mt
+    ;;
+  *-linux*)
+    case "${target}" in
+      *-linux*gnulibc1) gnulibc1=yes;;
+    esac
+    frags=linux.mt
+cat > dummy.c <<EOF
+extern int _libio_using_thunks;
+main ()
+{
+  return _libio_using_thunks;
+}
+EOF
+    if ${CC-cc} -o dummy dummy.c > /dev/null 2>&1; then
+      libc_thunks=yes
+    else
+      libc_thunks=no
+    fi
+cat > dummy.cc <<EOF
+class B
+{
+public:
+  virtual ~B () {};
+};
+
+class A : virtual B
+{
+public:
+  A() {}
+  ~A ();
+};
+
+A::~A ()
+{
+}
+
+main ()
+{
+  A os;
+}
+EOF
+    if ${CXX-c++} -c dummy.cc > /dev/null 2>&1; then
+      ${NM-nm} dummy.o | grep thunk > /dev/null 2>&1
+      if [ $? = 0 ]; then
+	cxx_thunks=yes
+      else
+	cxx_thunks=no
+      fi
+    else
+      cxx_thunks=no
+    fi
+    rm -f dummy.o dummy.c dummy.cc dummy
+    if [ $cxx_thunks != $libc_thunks ]; then
+      if [ x$gnulibc1 = xyes ]; then
+	echo "WARNING: The vtable thunks is enabled in your GNU C++"
+	echo "  compiler, which is not 100% compatible with the I/O"
+	echo "  implementation in the Linux C library 5.x.x. The"
+	echo "  resulting libg++ is not binary compatible with other"
+	echo "  libg++ 2.8.x for libc 5.x.x. Please disable vtable"
+	echo "  thunks in your GNU C++ compiler!"
+      fi
+      frags="$frags libio.mt"
+    else
+      if [ x$gnulibc1 != xyes ]; then
+	frags="$frags mtsafe.mt"
+      fi
+    fi
+    if [ x$gnulibc1 != xyes ]; then
+      if [  $cxx_thunks = no  ]; then
+	echo "WARNING: The vtable thunks is disabled in your GNU C++"
+	echo "  compiler, which may not be 100% compatible with the"
+	echo "  I/O implementation in GNU C library 2. The resulting"
+	echo "  libg++ may not thread safe, less efficient and the"
+	echo "  shared libg++ libraries are not binary compatible with"
+	echo "  other libg++ 2.8.x for glibc 2. Please enable vtable"
+	echo "  thunks in your GNU C++ compiler!"
+      fi
+      if [ $libc_thunks = no ]; then
+	echo "WARNING: Your GNU C library 2 does not support vtable"
+	echo "  thunks, which may not be 100% compatible with the"
+	echo "  I/O in this libg++. The resulting libg++ may not be"
+	echo "  thread safe, less efficient and the shared libg++"
+	echo "  libraries are not binary compatible with other libg++"
+	echo "  2.8.x for glibc 2. Please update your GNU C library"
+	echo "  for the vtable thunks support!"
+      fi
+    fi
+    ;;
+  *-sco3.2v[45]*)
+    frags=sco4.mt
+    ;;
+  *-isc*)
+    frags=isc.mt
+    ;;
+  *-netware*)
+    frags=netware.mt
+    ;;
+  *)
+    frags=${target_cpu}.mt
+    ;;
 esac
 
 case "${enable_shared}" in
@@ -61,6 +155,7 @@
 XCINCLUDES='-I. -I$(srcdir)'
 XCXXINCLUDES='-I. -I$(srcdir)'
 MOSTLYCLEAN='*.o pic stamp-picdir core iostream.list'
+EXTRA_DISTCLEAN=dummy.c
 DISTCLEAN='config.status Makefile *~ Make.pack target-mkfrag multilib.out'
 CLEAN='_G_config.h *.a'
 INFO_FILES=iostream
Index: libio/gen-params
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/gen-params,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 gen-params
--- libio/gen-params	1997/08/26 00:21:27	1.1.1.1
+++ libio/gen-params	1997/09/08 15:31:54
@@ -268,6 +268,18 @@
 #ifdef LONG_LONG_MAX
 long XLONG_LONG_MAX=LONG_LONG_MAX;
 #endif
+#ifdef _IO_MAGIC
+long XHAVE_LIBIO_IN_LIBC=1;
+#else
+long XHAVE_LIBIO_IN_LIBC=0;
+#endif
+#if defined(__GLIBC__) || defined(__GNU_LIBRARY__)
+long XHAVE_LONG_DOUBLE_IO=1;
+long XHAVE_GLIBC=1;
+#else
+long XHAVE_LONG_DOUBLE_IO=0;
+long XHAVE_GLIBC=0;
+#endif
 !EOF!
 
 if ${CPP} dummy.c -DWCHAR=$wchar -DWCTYPE=$wctype >TMP ; then true
@@ -276,7 +288,7 @@
 fi
 tr '	' ' ' <TMP >dummy.out
 
-for TYPE in dev_t clock_t fpos_t gid_t ino_t mode_t nlink_t off_t pid_t ptrdiff_t sigset_t size_t ssize_t time_t uid_t va_list wchar_t wint_t int16_t uint16_t int32_t uint_32_t u_int16_t u_int32_t; do
+for TYPE in dev_t clock_t fpos_t gid_t ino_t mode_t nlink_t off_t pid_t ptrdiff_t size_t ssize_t time_t uid_t va_list wchar_t wint_t int16_t uint16_t int32_t uint_32_t u_int16_t u_int32_t; do
     IMPORTED=`eval 'echo $'"$TYPE"`
     if [ -n "${IMPORTED}" ] ; then
 	eval "$TYPE='$IMPORTED'"
@@ -288,6 +300,8 @@
 	for iteration in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
 	    # Search dummy.out for a typedef for X*$t.
 	    sed_script="
+		s/unsigned long long int/_G_ullong/g
+		s/long long int/_G_llong/g
 		s/unsigned long long/_G_ullong/g
 		s/long long/_G_llong/g
 		/.*typedef  *\\(.*[^ ]\\)  *X*$t *;.*/{s||\1|;p;q;}
@@ -331,7 +345,7 @@
 done
 
 # These macros must be numerical constants; strip any trailing 'L's.
-for NAME in SHRT_MAX INT_MAX LONG_MAX LONG_LONG_MAX; do
+for NAME in SHRT_MAX INT_MAX LONG_MAX LONG_LONG_MAX HAVE_LIBIO_IN_LIBC HAVE_LONG_DOUBLE_IO HAVE_GLIBC; do
     IMPORTED=`eval 'echo $'"$NAME"`
     if [ -n "${IMPORTED}" ] ; then
 	eval "$NAME='$IMPORTED /* specified */"
@@ -540,6 +554,20 @@
 
 # *** Check for presence of certain include files ***
 
+# check for features.h
+
+if test -n "${HAVE_FEATURES}" ; then
+ echo "#define ${macro_prefix}HAVE_FEATURES ${HAVE_FEATURES}"
+else
+  echo '#include <features.h>' >dummy.c
+  echo 'extern int myfunc __P((int, int));' >>dummy.c
+  if ${CC} -c dummy.c >/dev/null 2>&1 ; then
+    echo "#define ${macro_prefix}HAVE_FEATURES 1"
+  else
+    echo "#define ${macro_prefix}HAVE_FEATURES 0"
+  fi
+fi
+
 # check for sys/resource.h
 
 if test -n "${HAVE_SYS_RESOURCE}" ; then
@@ -689,6 +717,11 @@
 if test -n "${USE_INT32_FLAGS}" ; then
     echo "#define ${macro_prefix}USE_INT32_FLAGS 1"
 fi
+
+echo ""
+echo "#define ${macro_prefix}HAVE_GLIBC ${HAVE_GLIBC}"
+echo "#define ${macro_prefix}HAVE_LIBIO_IN_LIBC ${HAVE_GLIBC}"
+echo "#define ${macro_prefix}HAVE_LONG_DOUBLE_IO ${HAVE_GLIBC}"
 
 # Uncomment the following line if you don't have working templates.
 # echo "#define ${macro_prefix}NO_TEMPLATES"
Index: libio/genops.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/genops.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 genops.c
--- libio/genops.c	1997/09/08 01:01:02	1.1.1.2
+++ libio/genops.c	1997/09/08 02:07:40
@@ -935,6 +935,118 @@
 
 #endif /* TODO */
 
+#ifdef _IO_USE_LIBC
+/* We only include those files which are not compatible with
+   libio in libc. We need to make sure our version is always
+   used during linking. */
+extern int vfprintf ();
+extern _IO_FILE * popen ();
+static const void * const __dummy [] =
+{
+  &_IO_file_doallocate,
+  &_IO_dtoa,
+  &_IO_strtod,
+  &_IO_adjust_column,
+  &_IO_cleanup,
+  &_IO_default_doallocate,
+  &_IO_default_finish,
+  &_IO_default_pbackfail,
+  &_IO_default_read,
+  &_IO_default_seek,
+  &_IO_default_seekoff,
+  &_IO_default_seekpos,
+  &_IO_default_setbuf,
+  &_IO_default_stat,
+  &_IO_default_sync,
+  &_IO_default_uflow,
+  &_IO_default_underflow,
+  &_IO_default_write,
+  &_IO_default_xsgetn,
+  &_IO_default_xsputn,
+  &_IO_doallocbuf,
+  &_IO_flush_all,
+  &_IO_flush_all_linebuffered,
+  &_IO_free_backup_area,
+  &_IO_get_column,
+  &_IO_init,
+  &_IO_init_marker,
+  &_IO_least_marker,
+  &_IO_link_in,
+  &_IO_marker_delta,
+  &_IO_marker_difference,
+  &_IO_nobackup_pbackfail,
+  &_IO_remove_marker,
+  &_IO_seekmark,
+  &_IO_set_column,
+  &_IO_setb,
+  &_IO_sgetn,
+  &_IO_sputbackc,
+  &_IO_sungetc,
+  &_IO_switch_to_backup_area,
+  &_IO_switch_to_get_mode,
+  &_IO_switch_to_main_get_area,
+  &_IO_sync,
+  &_IO_un_link,
+  &_IO_unbuffer_all,
+  &_IO_unsave_markers,
+  &__overflow,
+  &__uflow,
+  &__underflow,
+  &_IO_do_write,
+  &_IO_file_attach,
+  &_IO_file_close,
+  &_IO_file_close_it,
+  &_IO_file_finish,
+  &_IO_file_fopen,
+  &_IO_file_init,
+  &_IO_file_jumps,
+  &_IO_file_overflow,
+  &_IO_file_read,
+  &_IO_file_seek,
+  &_IO_file_seekoff,
+  &_IO_file_setbuf,
+  &_IO_file_stat,
+  &_IO_file_sync,
+  &_IO_file_underflow,
+  &_IO_file_write,
+  &_IO_file_xsputn,
+  &_IO_vfprintf,
+  &vfprintf,
+  &_IO_vfscanf,
+  &_IO_padn,
+  &_IO_seekoff,
+  &_IO_seekpos,
+  &_IO_outfloat,
+  &_IO_str_count,
+  &_IO_str_finish,
+  &_IO_str_init_readonly,
+  &_IO_str_init_static,
+  &_IO_str_jumps,
+  &_IO_str_overflow,
+  &_IO_str_pbackfail,
+  &_IO_str_seekoff,
+  &_IO_str_underflow,
+  &_IO_fclose,
+  &_IO_popen,
+  &popen,
+  &_IO_proc_close,
+  &_IO_proc_jumps,
+  &_IO_proc_open,
+  &_IO_fdopen,
+  &_IO_fflush,
+  &_IO_fopen,
+  &_IO_fputs,
+  &_IO_fwrite,
+  &_IO_puts,
+  &_IO_setbuffer,
+  &_IO_setvbuf,
+  &_IO_vsprintf,
+  &_IO_vsscanf,
+  &_IO_vasprintf,
+  &_IO_vsnprintf
+};
+#endif
+
 #ifdef weak_alias
 weak_alias (_IO_cleanup, _cleanup)
 #endif
Index: libio/iofclose.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iofclose.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 iofclose.c
--- libio/iofclose.c	1997/09/08 01:01:02	1.1.1.2
+++ libio/iofclose.c	1997/09/08 02:08:12
@@ -55,4 +55,8 @@
 
 #ifdef weak_alias
 weak_alias (_IO_fclose, fclose)
+#else
+#if defined(__ELF__) && defined(_IO_USE_LIBC)
+#pragma weak fclose = _IO_fclose
+#endif
 #endif
Index: libio/iofdopen.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iofdopen.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 iofdopen.c
--- libio/iofdopen.c	1997/09/08 01:01:02	1.1.1.2
+++ libio/iofdopen.c	1997/09/08 02:08:29
@@ -131,4 +131,8 @@
 
 #ifdef weak_alias
 weak_alias (_IO_fdopen, fdopen)
+#else
+#if defined(__ELF__) && defined(_IO_USE_LIBC)
+#pragma weak fdopen = _IO_fdopen
+#endif
 #endif
Index: libio/iofflush.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iofflush.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 iofflush.c
--- libio/iofflush.c	1997/09/08 01:01:02	1.1.1.2
+++ libio/iofflush.c	1997/09/08 02:08:42
@@ -46,4 +46,8 @@
 
 #ifdef weak_alias
 weak_alias (_IO_fflush, fflush)
+#else
+#if defined(__ELF__) && defined(_IO_USE_LIBC)
+#pragma weak fflush = _IO_fflush
+#endif
 #endif
Index: libio/iofopen.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iofopen.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 iofopen.c
--- libio/iofopen.c	1997/09/08 01:01:02	1.1.1.2
+++ libio/iofopen.c	1997/09/08 02:08:56
@@ -61,4 +61,8 @@
 
 #ifdef weak_alias
 weak_alias (_IO_fopen, fopen)
+#else
+#if defined(__ELF__) && defined(_IO_USE_LIBC)
+#pragma weak fopen = _IO_fopen
+#endif
 #endif
Index: libio/iofputs.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iofputs.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 iofputs.c
--- libio/iofputs.c	1997/09/08 01:01:02	1.1.1.2
+++ libio/iofputs.c	1997/09/08 02:09:47
@@ -46,4 +46,8 @@
 
 #ifdef weak_alias
 weak_alias (_IO_fputs, fputs)
+#else
+#if defined(__ELF__) && defined(_IO_USE_LIBC)
+#pragma weak fputs = _IO_fputs
+#endif
 #endif
Index: libio/iofwrite.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iofwrite.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 iofwrite.c
--- libio/iofwrite.c	1997/09/08 01:01:03	1.1.1.2
+++ libio/iofwrite.c	1997/09/08 02:10:03
@@ -51,4 +51,8 @@
 
 #ifdef weak_alias
 weak_alias (_IO_fwrite, fwrite)
+#else
+#if defined(__ELF__) && defined(_IO_USE_LIBC)
+#pragma weak fwrite = _IO_fwrite
+#endif
 #endif
Index: libio/iolibio.h
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iolibio.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 iolibio.h
--- libio/iolibio.h	1997/08/26 00:21:27	1.1.1.1
+++ libio/iolibio.h	1997/09/08 15:37:05
@@ -32,6 +32,11 @@
 extern int _IO_ungetc __P((int, _IO_FILE*));
 extern int _IO_vsscanf __P((const char *, const char *, _IO_va_list));
 extern int _IO_vsprintf __P((char*, const char*, _IO_va_list));
+
+struct obstack;
+extern int _IO_obstack_vprintf __P ((struct obstack *, const char *,
+				     _IO_va_list));
+extern int _IO_obstack_printf __P ((struct obstack *, const char *, ...));
 #ifndef _IO_pos_BAD
 #define _IO_pos_BAD ((_IO_fpos_t)(-1))
 #endif
@@ -50,4 +55,25 @@
 
 #ifdef __cplusplus
 }
+#endif
+
+#ifdef _G_HAVE_GLIBC
+#define _IO_open	__open
+#define _IO_close	__close
+#define	_IO_fork	__fork
+#define	_IO_fcntl	__fcntl
+#define _IO__exit	_exit
+#define _IO_read	__read
+#define _IO_write	__write
+#define _IO_lseek	__lseek
+#define	_IO_getdtablesize	__getdtablesize
+#define _IO_pipe	__pipe
+#define _IO_dup2	__dup2
+#define _IO_execl	execl
+#define _IO_waitpid	__waitpid
+#define _IO_stat        __stat
+#define _IO_getpid      __getpid
+#define _IO_geteuid     __geteuid
+#define _IO_getegid     __getegid
+#define _IO_fstat	__fstat
 #endif
Index: libio/iopopen.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iopopen.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 iopopen.c
--- libio/iopopen.c	1997/09/08 01:01:04	1.1.1.2
+++ libio/iopopen.c	1997/09/08 01:08:21
@@ -245,3 +245,7 @@
   JUMP_INIT(close, _IO_proc_close),
   JUMP_INIT(stat, _IO_file_stat)
 };
+
+#if defined(__ELF__) && defined(_IO_USE_LIBC) && defined (__GNUC__)
+__asm__(".globl popen; popen = _IO_popen");
+#endif
Index: libio/ioputs.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/ioputs.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 ioputs.c
--- libio/ioputs.c	1997/09/08 01:01:04	1.1.1.2
+++ libio/ioputs.c	1997/09/08 02:10:14
@@ -46,4 +46,8 @@
 
 #ifdef weak_alias
 weak_alias (_IO_puts, puts)
+#else
+#if defined(__ELF__) && defined(_IO_USE_LIBC)
+#pragma weak puts = _IO_puts
+#endif
 #endif
Index: libio/iosetbuffer.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iosetbuffer.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 iosetbuffer.c
--- libio/iosetbuffer.c	1997/09/08 01:01:05	1.1.1.2
+++ libio/iosetbuffer.c	1997/09/08 02:10:23
@@ -43,4 +43,8 @@
 
 #ifdef weak_alias
 weak_alias (_IO_setbuffer, setbuffer)
+#else
+#if defined(__ELF__) && defined(_IO_USE_LIBC)
+#pragma weak setbuffer = _IO_setbuffer
+#endif
 #endif
Index: libio/iosetvbuf.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iosetvbuf.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 iosetvbuf.c
--- libio/iosetvbuf.c	1997/09/08 01:01:05	1.1.1.2
+++ libio/iosetvbuf.c	1997/09/08 02:10:34
@@ -97,4 +97,8 @@
 
 #ifdef weak_alias
 weak_alias (_IO_setvbuf, setvbuf)
+#else
+#if defined(__ELF__) && defined(_IO_USE_LIBC)
+#pragma weak setvbuf = _IO_setvbuf
+#endif
 #endif
Index: libio/iostream.cc
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iostream.cc,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 iostream.cc
--- libio/iostream.cc	1997/08/26 00:21:27	1.1.1.1
+++ libio/iostream.cc	1997/09/08 15:56:46
@@ -35,6 +35,15 @@
 #include <string.h>
 #include <limits.h>
 #include "floatio.h"
+#if _G_HAVE_GLIBC && !defined(_IO_USE_DTOA)
+#include <printf.h>
+extern "C" int __printf_fp __P ((FILE *,
+				const struct printf_info *,
+				const void *const*));
+#else
+extern "C" int __cvt_double (double, int, int, int *, int,
+			     char *, char *);
+#endif
 
 #define	BUF		(MAXEXP+MAXFRACT+1)	/* + decimal point */
 
@@ -321,7 +330,15 @@
 istream& istream::operator>>(long double& x)
 {
     if (ipfx0())
-	scan("%lg", &x);
+      {
+#if _G_HAVE_LONG_DOUBLE_IO && !defined(_IO_USE_DTOA)
+	scan("%Lg", &x);
+#else
+	double y;
+	scan("%lg", &y);
+	x = y;
+#endif
+      }
     return *this;
 }
 
@@ -551,6 +568,57 @@
 }
 #endif /*__GNUC__*/
 
+#if _G_HAVE_GLIBC
+ostream& ostream::operator<<(long double n)
+{
+    if (opfx()) {
+	int format_char;
+	if ((flags() & ios::floatfield) == ios::fixed)
+	    format_char = 'f';
+	else if ((flags() & ios::floatfield) == ios::scientific)
+	    format_char = flags() & ios::uppercase ? 'E' : 'e';
+	else
+	    format_char = flags() & ios::uppercase ? 'G' : 'g';
+
+	int prec = precision();
+	if (prec <= 0 && !(flags() & ios::fixed))
+	  prec = 6; /* default */
+
+	// Do actual conversion.
+	struct printf_info info;
+
+#if 1
+	// Not all printf_info's have the extra field.
+	memset (&info, 0, sizeof (info));
+#else
+	info.is_short = 0;
+	info.is_long = 0;
+	info.space = 0;
+	info.group = 0;
+	info.extra = 0;
+#endif
+	info.prec = prec;
+	info.width = width (0);
+	info.spec = format_char;
+	info.is_long_double = 1;
+	info.alt = (flags() & ios::showpoint) != 0;
+	info.left = (flags() & ios::left) != 0;
+	info.showsign = (flags() & ios::showpos) != 0;
+	info.pad = fill();
+
+#if 0
+	_IO_va_list p = (_IO_va_list) &n;
+#else
+	const void *p = (const void *) &n;
+#endif
+	if (__printf_fp (rdbuf(), &info, &p) < 0)
+	    set(ios::badbit|ios::failbit); // ??
+	osfx();
+    }
+    return *this;
+}
+#endif
+
 ostream& ostream::operator<<(double n)
 {
     if (opfx()) {
@@ -570,6 +638,37 @@
 	  prec = 6; /* default */
 
 	// Do actual conversion.
+#if _G_HAVE_GLIBC && !defined(_IO_USE_DTOA)
+	struct printf_info info;
+
+#if 1
+	// Not all printf_info's have the extra field.
+	memset (&info, 0, sizeof (info));
+#else
+	info.is_long_double = 0;
+	info.is_short = 0;
+	info.is_long = 0;
+	info.space = 0;
+	info.group = 0;
+	info.extra = 0;
+#endif
+	info.prec = prec;
+	info.width = width (0);
+	info.spec = format_char;
+	info.alt = (flags() & ios::showpoint) != 0;
+	info.left = (flags() & ios::left) != 0;
+	info.showsign = (flags() & ios::showpos) != 0;
+	info.pad = fill();
+
+#if 0
+	_IO_va_list p = (_IO_va_list) &n;
+#else
+	const void *p = (const void *) &n;
+#endif
+
+	if (__printf_fp (rdbuf(), &info, &p) < 0)
+	    set(ios::badbit|ios::failbit); // ??
+#else
 #ifdef _IO_USE_DTOA
 	if (_IO_outfloat(n, rdbuf(), format_char, width(0),
 			 prec, flags(),
@@ -625,6 +724,7 @@
 
 	if (pad_kind == (ios::fmtflags)ios::left) // Left adjustment
 	    for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
+#endif
 #endif
 	osfx();
     }
Index: libio/iostream.h
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iostream.h,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 iostream.h
--- libio/iostream.h	1997/09/08 01:01:05	1.1.1.2
+++ libio/iostream.h	1997/09/08 15:58:03
@@ -96,7 +96,7 @@
 #endif
     ostream& operator<<(double n);
     ostream& operator<<(float n) { return operator<<((double)n); }
-#if _G_HAVE_LONG_DOUBLE_IO
+#if _G_HAVE_GLIBC
     ostream& operator<<(long double n);
 #else
     ostream& operator<<(long double n) { return operator<<((double)n); }
Index: libio/iovfprintf.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iovfprintf.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 iovfprintf.c
--- libio/iovfprintf.c	1997/08/26 00:21:27	1.1.1.1
+++ libio/iovfprintf.c	1997/08/26 01:42:20
@@ -72,6 +72,11 @@
 
 /* end of configuration stuff */
 
+#ifdef __STDC__
+int __cvt_double (double, int, int, int *, int, char *, char *);
+#else
+int __cvt_double ();
+#endif
 
 /*
  * Helper "class" for `fprintf to unbuffered': creates a
@@ -883,3 +888,7 @@
 }
 
 #endif /* defined(FLOATING_POINT) && !defined(_IO_USE_DTOA) */
+
+#if defined(__ELF__) && defined(_IO_USE_LIBC) && defined (__GNUC__)
+__asm__(".globl vfprintf; vfprintf  = _IO_vfprintf");
+#endif
Index: libio/iovfscanf.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iovfscanf.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 iovfscanf.c
--- libio/iovfscanf.c	1997/08/26 00:21:27	1.1.1.1
+++ libio/iovfscanf.c	1997/08/26 01:42:20
@@ -785,3 +785,15 @@
 	}
 	/* NOTREACHED */
 }
+
+#ifdef _IO_USE_LIBC
+int
+__vfscanf (_IO_FILE *s, const char *format, _IO_va_list argptr)
+{
+  return _IO_vfscanf (s, format, argptr, NULL);
+}
+
+#ifdef __ELF__
+#pragma weak vfscanf = __vfscanf
+#endif
+#endif
Index: libio/iovsprintf.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iovsprintf.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 iovsprintf.c
--- libio/iovsprintf.c	1997/09/08 01:01:05	1.1.1.2
+++ libio/iovsprintf.c	1997/09/08 02:11:41
@@ -54,4 +54,8 @@
 
 #ifdef weak_alias
 weak_alias (_IO_vsprintf, vsprintf)
+#else
+#if defined(__ELF__) && defined(_IO_USE_LIBC)
+#pragma weak vsprintf = _IO_vsprintf
+#endif
 #endif
Index: libio/iovsscanf.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/iovsscanf.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 iovsscanf.c
--- libio/iovsscanf.c	1997/09/08 01:01:05	1.1.1.2
+++ libio/iovsscanf.c	1997/09/08 02:11:52
@@ -51,4 +51,9 @@
 #ifdef weak_alias
 weak_alias (_IO_vsscanf, __vsscanf)
 weak_alias (_IO_vsscanf, vsscanf)
+#else
+#if defined(__ELF__) && defined(_IO_USE_LIBC)
+#pragma weak vsscanf = _IO_vsscanf
+#pragma weak __vsscanf = _IO_vsscanf
+#endif
 #endif
Index: libio/libio.h
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/libio.h,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 libio.h
--- libio/libio.h	1997/09/08 01:01:06	1.1.1.2
+++ libio/libio.h	1997/09/08 02:41:15
@@ -1,33 +1,37 @@
-/*
-Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation
-
-This file is part of the GNU IO Library.  This library is free
-software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this library; see the file COPYING.  If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-As a special exception, if you link this library with files
-compiled with a GNU compiler to produce an executable, this does not cause
-the resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why
-the executable file might be covered by the GNU General Public License. */
-
-/* This is part of the iostream library.  Written by Per Bothner. */
+/* Copyright (C) 1991, 92, 93, 94, 95, 97 Free Software Foundation, Inc.
+   This file is part of the GNU IO Library.
+   Written by Per Bothner <bothner@cygnus.com>.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This library is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this library; see the file COPYING.  If not, write to
+   the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   As a special exception, if you link this library with files
+   compiled with a GNU compiler to produce an executable, this does
+   not cause the resulting executable to be covered by the GNU General
+   Public License.  This exception does not however invalidate any
+   other reasons why the executable file might be covered by the GNU
+   General Public License.  */
 
 #ifndef _IO_STDIO_H
 #define _IO_STDIO_H
-
 #include <_G_config.h>
+
+#if _G_HAVE_FEATURES
+#include <features.h>
+#endif
+
 #define _IO_pos_t _G_fpos_t /* obsolete */
 #define _IO_fpos_t _G_fpos_t
 #define _IO_size_t _G_size_t
@@ -42,60 +46,56 @@
 
 #ifdef _G_NEED_STDARG_H
 /* This define avoids name pollution if we're using GNU stdarg.h */
-#define __need___va_list
-#include <stdarg.h>
-#ifdef __GNUC_VA_LIST
-#undef _IO_va_list
-#define _IO_va_list __gnuc_va_list
-#endif /* __GNUC_VA_LIST */
+# define __need___va_list
+# include <stdarg.h>
+# ifdef __GNUC_VA_LIST
+#  undef _IO_va_list
+#  define _IO_va_list __gnuc_va_list
+# endif /* __GNUC_VA_LIST */
 #endif
 
 #ifndef __P
-#if _G_HAVE_SYS_CDEFS
-#include <sys/cdefs.h>
-#else
-#ifdef __STDC__
-#define __P(protos) protos
-#else
-#define __P(protos) ()
-#endif
-#endif
+# if _G_HAVE_SYS_CDEFS
+#  include <sys/cdefs.h>
+# else
+#  ifdef __STDC__
+#   define __P(protos) protos
+#  else
+#   define __P(protos) ()
+#  endif
+# endif
 #endif /*!__P*/
 
 /* For backward compatibility */
 #ifndef _PARAMS
-#define _PARAMS(protos) __P(protos)
+# define _PARAMS(protos) __P(protos)
 #endif /*!_PARAMS*/
 
 #ifndef __STDC__
-#define const
-#endif
-#ifndef _G_NO_USE_DTOA
-#define _IO_USE_DTOA
-#else
-#undef _IO_USE_DTOA
+# define const
 #endif
 #define _IO_UNIFIED_JUMPTABLES 1
 
 #if 0
-#ifdef _IO_NEED_STDARG_H
-#include <stdarg.h>
-#endif
+# ifdef _IO_NEED_STDARG_H
+#  include <stdarg.h>
+# endif
 #endif
 
 #ifndef EOF
-#define EOF (-1)
+# define EOF (-1)
 #endif
 #ifndef NULL
-#ifdef __GNUG__
-#define NULL (__null)
-#else
-#if !defined(__cplusplus)
-#define NULL ((void*)0)
-#else
-#define NULL (0)
-#endif
-#endif
+# if defined __GNUG__ && \
+    (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#  define NULL (__null)
+# else
+#  if !defined(__cplusplus)
+#   define NULL ((void*)0)
+#  else
+#   define NULL (0)
+#  endif
+# endif
 #endif
 
 #define _IOS_INPUT	1
@@ -109,7 +109,7 @@
 
 /* Magic numbers and bits for the _flags field.
    The magic numbers use the high-order bits of _flags;
-   the remaining bits are abailable for variable flags.
+   the remaining bits are available for variable flags.
    Note: The magic numbers must all be negative if stdio
    emulation is desired. */
 
@@ -130,6 +130,7 @@
 #define _IO_CURRENTLY_PUTTING 0x800
 #define _IO_IS_APPENDING 0x1000
 #define _IO_IS_FILEBUF 0x2000
+#define _IO_BAD_SEEN 0x4000
 
 /* These are "formatting flags" matching the iostream fmtflags enum values. */
 #define _IO_SKIPWS 01
@@ -148,19 +149,35 @@
 #define _IO_UNITBUF 020000
 #define _IO_STDIO 040000
 #define _IO_DONT_CLOSE 0100000
+#define _IO_BOOLALPHA 0200000
 
-/* A streammarker remembers a position in a buffer. */
 
 struct _IO_jump_t;  struct _IO_FILE;
 
 /* Handle lock.  */
+#if defined(__GLIBC__) && __GLIBC__ >= 2
 #ifdef _IO_MTSAFE_IO
-# include <stdio-lock.h>
+# if __GLIBC_MINOR__ >= 1
+#  include <bits/stdio-lock.h>
+# else
+#  include <stdio-lock.h>
+# endif
 #else
 typedef void _IO_lock_t;
 #endif
+#else
+#ifdef __linux__
+struct _IO_lock_t {
+  void *ptr;
+  short int field1;
+  short int field2;
+};
+#endif
+#endif
 
 
+/* A streammarker remembers a position in a buffer. */
+
 struct _IO_marker {
   struct _IO_marker *_next;
   struct _IO_FILE *_sbuf;
@@ -181,11 +198,7 @@
 };
 
 struct _IO_FILE {
-#if _G_USE_INT32_FLAGS
-  _G_int32_t _flags;	/* High-order word is _IO_MAGIC; rest is flags. */
-#else
-  int	     _flags;
-#endif
+  int _flags;		/* High-order word is _IO_MAGIC; rest is flags. */
 #define _IO_file_flags _flags
 
   /* The following pointers correspond to the C++ streambuf protocol. */
@@ -219,7 +232,13 @@
 
   /*  char* _save_gptr;  char* _save_egptr; */
 
+#if defined(__GLIBC__) && __GLIBC__ >= 2
   _IO_lock_t *_lock;
+#else
+#ifdef __linux__
+  struct _IO_lock_t _lock;
+#endif
+#endif
 };
 
 #ifndef __cplusplus
@@ -256,24 +275,24 @@
 extern "C" {
 #endif
 
-extern int __underflow __P((_IO_FILE*));
-extern int __uflow __P((_IO_FILE*));
-extern int __overflow __P((_IO_FILE*, int));
+extern int __underflow __P ((_IO_FILE *));
+extern int __uflow __P ((_IO_FILE *));
+extern int __overflow __P ((_IO_FILE *, int));
 
 #define _IO_getc_unlocked(_fp) \
-       ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end ? __uflow(_fp) \
-	: *(unsigned char*)(_fp)->_IO_read_ptr++)
+       ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end ? __uflow (_fp) \
+	: *(unsigned char *) (_fp)->_IO_read_ptr++)
 #define _IO_peekc_unlocked(_fp) \
        ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end \
-	  && __underflow(_fp) == EOF ? EOF \
-	: *(unsigned char*)(_fp)->_IO_read_ptr)
+	  && __underflow (_fp) == EOF ? EOF \
+	: *(unsigned char *) (_fp)->_IO_read_ptr)
 
 #define _IO_putc_unlocked(_ch, _fp) \
    (((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \
-    ? __overflow(_fp, (unsigned char)(_ch)) \
-    : (unsigned char)(*(_fp)->_IO_write_ptr++ = (_ch)))
+    ? __overflow (_fp, (unsigned char) (_ch)) \
+    : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
 
-#define _IO_feof_unclocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)
+#define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)
 #define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)
 
 extern int _IO_getc __P ((_IO_FILE *__fp));
@@ -291,7 +310,10 @@
 extern void _IO_funlockfile __P ((_IO_FILE *));
 extern int _IO_ftrylockfile __P ((_IO_FILE *));
 
-#ifndef _IO_MTSAFE_IO
+#ifdef _IO_MTSAFE_IO
+# define _IO_peekc(_fp) _IO_peekc_locked (_fp)
+#else
+# define _IO_peekc(_fp) _IO_peekc_unlocked (_fp)
 # define _IO_flockfile(_fp) /**/
 # define _IO_funlockfile(_fp) /**/
 # define _IO_ftrylockfile(_fp) /**/
@@ -299,17 +321,15 @@
 # define _IO_cleanup_region_end(_Doit) /**/
 #endif /* !_IO_MTSAFE_IO */
 
-#define _IO_peekc(_fp) _IO_peekc_locked (_fp)
-
-extern int _IO_vfscanf __P((_IO_FILE*, const char*, _IO_va_list, int*));
-extern int _IO_vfprintf __P((_IO_FILE*, const char*, _IO_va_list));
-extern _IO_ssize_t _IO_padn __P((_IO_FILE *, int, _IO_ssize_t));
-extern _IO_size_t _IO_sgetn __P((_IO_FILE *, void*, _IO_size_t));
+extern int _IO_vfscanf __P ((_IO_FILE *, const char *, _IO_va_list, int *));
+extern int _IO_vfprintf __P ((_IO_FILE *, const char *, _IO_va_list));
+extern _IO_ssize_t _IO_padn __P ((_IO_FILE *, int, _IO_ssize_t));
+extern _IO_size_t _IO_sgetn __P ((_IO_FILE *, void *, _IO_size_t));
 
-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));
+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));
 
-extern void _IO_free_backup_area __P((_IO_FILE*));
+extern void _IO_free_backup_area __P ((_IO_FILE *));
 
 #ifdef __cplusplus
 }
Index: libio/libioP.h
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/libioP.h,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 libioP.h
--- libio/libioP.h	1997/09/08 01:01:06	1.1.1.2
+++ libio/libioP.h	1997/09/08 02:18:31
@@ -24,8 +24,8 @@
    General Public License.  */
 
 #include <errno.h>
-#ifndef errno
-extern int errno;
+#ifdef _LIBC
+#include <bits/libc-lock.h>
 #endif
 #ifndef __set_errno
 /* This is a GNU libc special.  Simply set errno to the  given value here.  */
@@ -35,28 +35,7 @@
 
 #include "iolibio.h"
 
-#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(__cplusplus)
-/* All known AIX compilers implement these things (but don't always
-   define __STDC__).  The RISC/OS MIPS compiler defines these things
-   in SVR4 mode, but does not define __STDC__.  */
-
-#define	AND		,
-#define	DEFUN(name, arglist, args)	name(args)
-#define	DEFUN_VOID(name)		name(void)
-
-#else	/* Not ANSI C.  */
-
-#define	AND		;
-#ifndef const /* some systems define it in header files for non-ansi mode */
-#define	const
-#endif
-#define	DEFUN(name, arglist, args)	name arglist args;
-#define	DEFUN_VOID(name)		name()
-#endif	/* ANSI C.  */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+__BEGIN_DECLS
 
 #define _IO_seek_set 0
 #define _IO_seek_cur 1
@@ -71,11 +50,11 @@
  * a jump table (of pointers to functions).  The pointer is accessed
  * with the _IO_JUMPS macro.  The jump table has a eccentric format,
  * so as to be compatible with the layout of a C++ virtual function table.
- * (as implemented by g++).  When a pointer to a steambuf object is
+ * (as implemented by g++).  When a pointer to a streambuf object is
  * coerced to an (_IO_FILE*), then _IO_JUMPS on the result just
  * happens to point to the virtual function table of the streambuf.
  * Thus the _IO_JUMPS function table used for C stdio/libio does
- * double duty as the virtual functiuon table for C++ streambuf.
+ * double duty as the virtual function table for C++ streambuf.
  *
  * The entries in the _IO_JUMPS function table (and hence also the
  * virtual functions of a streambuf) are described below.
@@ -83,24 +62,24 @@
  * object being acted on (i.e. the 'this' parameter).
  */
 
-#define _IO_JUMPS(THIS) ((struct _IO_FILE_plus*)(THIS))->vtable
+#define _IO_JUMPS(THIS) ((struct _IO_FILE_plus *) (THIS))->vtable
 #ifdef _G_USING_THUNKS
-#define JUMP_FIELD(TYPE, NAME) TYPE NAME
-#define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC(THIS)
-#define JUMP1(FUNC, THIS, X1) _IO_JUMPS(THIS)->FUNC(THIS, X1)
-#define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS(THIS)->FUNC(THIS, X1, X2)
-#define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC(THIS, X1,X2, X3)
-#define JUMP_INIT(NAME, VALUE) VALUE
-#define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT(dummy2, 0)
+# define JUMP_FIELD(TYPE, NAME) TYPE NAME
+# define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC (THIS)
+# define JUMP1(FUNC, THIS, X1) _IO_JUMPS(THIS)->FUNC (THIS, X1)
+# define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS(THIS)->FUNC (THIS, X1, X2)
+# define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC (THIS, X1,X2, X3)
+# define JUMP_INIT(NAME, VALUE) VALUE
+# define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT (dummy2, 0)
 #else
 /* These macros will change when we re-implement vtables to use "thunks"! */
-#define JUMP_FIELD(TYPE, NAME) struct { short delta1, delta2; TYPE pfn; } NAME
-#define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC.pfn(THIS)
-#define JUMP1(FUNC, THIS, X1) _IO_JUMPS(THIS)->FUNC.pfn(THIS, X1)
-#define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS(THIS)->FUNC.pfn(THIS, X1, X2)
-#define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC.pfn(THIS, X1,X2, X3)
-#define JUMP_INIT(NAME, VALUE) {0, 0, VALUE}
-#define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0)
+# define JUMP_FIELD(TYPE, NAME) struct { short delta1, delta2; TYPE pfn; } NAME
+# define JUMP0(FUNC, THIS) _IO_JUMPS(THIS)->FUNC.pfn (THIS)
+# define JUMP1(FUNC, THIS, X1) _IO_JUMPS(THIS)->FUNC.pfn (THIS, X1)
+# define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS(THIS)->FUNC.pfn (THIS, X1, X2)
+# define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS(THIS)->FUNC.pfn (THIS, X1,X2,X3)
+# define JUMP_INIT(NAME, VALUE) {0, 0, VALUE}
+# define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0)
 #endif
 
 /* The 'finish' function does any final cleaning up of an _IO_FILE object.
@@ -112,78 +91,79 @@
 /* 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));
-#define _IO_OVERFLOW(FP, CH) JUMP1(__overflow, FP, CH)
+typedef int (*_IO_overflow_t) __P ((_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 postion is not changed.
+   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*));
-#define _IO_UNDERFLOW(FP) JUMP0(__underflow, FP)
+typedef int (*_IO_underflow_t) __P ((_IO_FILE *));
+#define _IO_UNDERFLOW(FP) JUMP0 (__underflow, FP)
 
 /* The 'uflow' hook returns the next character in the input stream
    (cast to unsigned char), and increments the read position;
    EOF is returned on failure.
    It matches the streambuf::uflow virtual function, which is not in the
    cfront implementation, but was added to C++ by the ANSI/ISO committee. */
-#define _IO_UFLOW(FP) JUMP0(__uflow, FP)
+#define _IO_UFLOW(FP) JUMP0 (__uflow, FP)
 
 /* The 'pbackfail' hook handles backing up.
    It matches the streambuf::pbackfail virtual function. */
-typedef int (*_IO_pbackfail_t) __P((_IO_FILE*, int));
-#define _IO_PBACKFAIL(FP, CH) JUMP1(__pbackfail, FP, CH)
+typedef int (*_IO_pbackfail_t) __P ((_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, _IO_size_t N));
-#define _IO_XSPUTN(FP, DATA, N) JUMP2(__xsputn, FP, DATA, N)
+typedef _IO_size_t (*_IO_xsputn_t) __P ((_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, _IO_size_t N));
-#define _IO_XSGETN(FP, DATA, N) JUMP2(__xsgetn, FP, DATA, N)
+typedef _IO_size_t (*_IO_xsgetn_t) __P ((_IO_FILE *FP, void *DATA,
+					 _IO_size_t N));
+#define _IO_XSGETN(FP, DATA, N) JUMP2 (__xsgetn, FP, DATA, N)
 
 /* The 'seekoff' hook moves the stream position to a new position
    relative to the start of the file (if DIR==0), the current position
    (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, int DIR, int MODE));
-#define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3(__seekoff, FP, OFF, DIR, MODE)
+typedef _IO_fpos_t (*_IO_seekoff_t) __P ((_IO_FILE *FP, _IO_off_t OFF,
+					  int DIR, int MODE));
+#define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3 (__seekoff, FP, OFF, DIR, MODE)
 
 /* The 'seekpos' hook also moves the stream position,
    but to an absolute position given by a fpos_t (seekpos).
    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));
-#define _IO_SEEKPOS(FP, POS, FLAGS) JUMP2(__seekpos, FP, POS, FLAGS)
+typedef _IO_fpos_t (*_IO_seekpos_t) __P ((_IO_FILE *, _IO_fpos_t, int));
+#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));
-#define _IO_SETBUF(FP, BUFFER, LENGTH) JUMP2(__setbuf, FP, BUFFER, LENGTH)
+typedef _IO_FILE* (*_IO_setbuf_t) __P ((_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*));
-#define _IO_SYNC(FP) JUMP0(__sync, FP)
+typedef int (*_IO_sync_t) __P ((_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*));
-#define _IO_DOALLOCATE(FP) JUMP0(__doallocate, FP)
+typedef int (*_IO_doallocate_t) __P ((_IO_FILE *));
+#define _IO_DOALLOCATE(FP) JUMP0 (__doallocate, FP)
 
 /* The following four hooks (sysread, syswrite, sysclose, sysseek, and
    sysstat) are low-level hooks specific to this implementation.
-   There is no correspondance in the ANSI/ISO C++ standard library.
+   There is no correspondence in the ANSI/ISO C++ standard library.
    The hooks basically correspond to the Unix system functions
    (read, write, close, lseek, and stat) except that a _IO_FILE*
    parameter is used instead of a integer file descriptor;  the default
@@ -195,43 +175,44 @@
 /* The 'sysread' hook is used to read data from the external file into
    an existing buffer.  It generalizes the Unix read(2) function.
    It matches the streambuf::sys_read virtual function, which is
-   specific to this implementaion. */
-typedef _IO_ssize_t (*_IO_read_t) __P((_IO_FILE*, void*, _IO_ssize_t));
-#define _IO_SYSREAD(FP, DATA, LEN) JUMP2(__read, FP, DATA, LEN)
+   specific to this implementation. */
+typedef _IO_ssize_t (*_IO_read_t) __P ((_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 implementaion. */
-typedef _IO_ssize_t (*_IO_write_t) __P((_IO_FILE*,const void*,_IO_ssize_t));
-#define _IO_SYSWRITE(FP, DATA, LEN) JUMP2(__write, FP, DATA, LEN)
+   specific to this implementation. */
+typedef _IO_ssize_t (*_IO_write_t) __P ((_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 implementaion. */
-typedef _IO_fpos_t (*_IO_seek_t) __P((_IO_FILE*, _IO_off_t, int));
-#define _IO_SYSSEEK(FP, OFFSET, MODE) JUMP2(__seek, FP, OFFSET, MODE)
+   specific to this implementation. */
+typedef _IO_fpos_t (*_IO_seek_t) __P ((_IO_FILE *, _IO_off_t, int));
+#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 */
-#define _IO_SYSCLOSE(FP) JUMP0(__close, FP)
+typedef int (*_IO_close_t) __P ((_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 implementaion. */
-typedef int (*_IO_stat_t) __P((_IO_FILE*, void*));
-#define _IO_SYSSTAT(FP, BUF) JUMP1(__stat, FP, BUF)
+   specific to this implementation. */
+typedef int (*_IO_stat_t) __P ((_IO_FILE *, void *));
+#define _IO_SYSSTAT(FP, BUF) JUMP1 (__stat, FP, BUF)
 
 
 #define _IO_CHAR_TYPE char /* unsigned char ? */
 #define _IO_INT_TYPE int
 
-struct _IO_jump_t {
+struct _IO_jump_t
+{
     JUMP_FIELD(_G_size_t, __dummy);
 #ifdef _G_USING_THUNKS
     JUMP_FIELD(_G_size_t, __dummy2);
@@ -265,7 +246,8 @@
    This is for compatibility with C++ streambuf; the word can
    be used to smash to a pointer to a virtual function table. */
 
-struct _IO_FILE_plus {
+struct _IO_FILE_plus
+{
   _IO_FILE file;
   const struct _IO_jump_t *vtable;
 };
@@ -289,11 +271,12 @@
 
 /* Marker-related function. */
 
-extern void _IO_init_marker __P((struct _IO_marker *, _IO_FILE *));
-extern void _IO_remove_marker __P((struct _IO_marker*));
-extern int _IO_marker_difference __P((struct _IO_marker *, struct _IO_marker *));
-extern int _IO_marker_delta __P((struct _IO_marker *));
-extern int _IO_seekmark __P((_IO_FILE *, struct _IO_marker *, int));
+extern void _IO_init_marker __P ((struct _IO_marker *, _IO_FILE *));
+extern void _IO_remove_marker __P ((struct _IO_marker *));
+extern int _IO_marker_difference __P ((struct _IO_marker *,
+				       struct _IO_marker *));
+extern int _IO_marker_delta __P ((struct _IO_marker *));
+extern int _IO_seekmark __P ((_IO_FILE *, struct _IO_marker *, int));
 
 /* Default jumptable functions. */
 
@@ -318,10 +301,10 @@
 extern struct _IO_jump_t _IO_streambuf_jumps;
 extern struct _IO_jump_t _IO_proc_jumps;
 extern struct _IO_jump_t _IO_str_jumps;
-extern int _IO_do_write __P((_IO_FILE*, const char*, _IO_size_t));
-extern int _IO_flush_all __P((void));
-extern void _IO_cleanup __P((void));
-extern void _IO_flush_all_linebuffered __P((void));
+extern int _IO_do_write __P ((_IO_FILE *, const char *, _IO_size_t));
+extern int _IO_flush_all __P ((void));
+extern void _IO_cleanup __P ((void));
+extern void _IO_flush_all_linebuffered __P ((void));
 
 #define _IO_do_flush(_f) \
   _IO_do_write(_f, (_f)->_IO_write_base, \
@@ -340,14 +323,14 @@
 
 /* Jumptable functions for files. */
 
-extern int _IO_file_doallocate __P((_IO_FILE*));
-extern _IO_FILE* _IO_file_setbuf __P((_IO_FILE *, char*, _IO_ssize_t));
-extern _IO_fpos_t _IO_file_seekoff __P((_IO_FILE*, _IO_off_t, int, int));
-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*));
-extern int _IO_file_underflow __P((_IO_FILE *));
-extern int _IO_file_overflow __P((_IO_FILE *, int));
+extern int _IO_file_doallocate __P ((_IO_FILE *));
+extern _IO_FILE* _IO_file_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t));
+extern _IO_fpos_t _IO_file_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
+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 *));
+extern int _IO_file_underflow __P ((_IO_FILE *));
+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_fopen __P((_IO_FILE*, const char*, const char*));
@@ -362,8 +345,8 @@
 extern _IO_FILE* _IO_file_attach __P((_IO_FILE *, int));
 
 /* Jumptable functions for proc_files. */
-extern _IO_FILE* _IO_proc_open __P((_IO_FILE*, const char*, const char *));
-extern int _IO_proc_close __P((_IO_FILE*));
+extern _IO_FILE* _IO_proc_open __P ((_IO_FILE *, const char *, const char *));
+extern int _IO_proc_close __P ((_IO_FILE *));
 
 /* Jumptable functions for strfiles. */
 extern int _IO_str_underflow __P((_IO_FILE*));
@@ -373,9 +356,9 @@
 extern void _IO_str_finish __P ((_IO_FILE*, int));
 
 /* Other strfile functions */
-extern void _IO_str_init_static __P((_IO_FILE *, char*, int, char*));
-extern void _IO_str_init_readonly __P((_IO_FILE *, const char*, int));
-extern _IO_ssize_t _IO_str_count __P ((_IO_FILE*));
+extern void _IO_str_init_static __P ((_IO_FILE *, char *, int, char *));
+extern void _IO_str_init_readonly __P ((_IO_FILE *, const char *, int));
+extern _IO_ssize_t _IO_str_count __P ((_IO_FILE *));
 
 extern int _IO_vasprintf __P ((char **result_ptr, __const char *format,
 			       _IO_va_list args));
@@ -397,18 +380,19 @@
 extern void (*_IO_cleanup_registration_needed) __P ((void));
 
 #ifndef EOF
-#define EOF (-1)
+# define EOF (-1)
 #endif
 #ifndef NULL
-#ifdef __GNUG__
-#define NULL (__null)
-#else
-#if !defined(__cplusplus)
-#define NULL ((void*)0)
-#else
-#define NULL (0)
-#endif
-#endif
+# if defined __GNUG__ && \
+    (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#  define NULL (__null)
+# else
+#  if !defined(__cplusplus)
+#   define NULL ((void*)0)
+#  else
+#   define NULL (0)
+#  endif
+# endif
 #endif
 
 #if _G_HAVE_MMAP
@@ -459,14 +443,15 @@
 #endif /* _G_HAVE_MMAP */
 
 #ifndef OS_FSTAT
-#define OS_FSTAT fstat
+# define OS_FSTAT fstat
 #endif
 struct stat;
-extern _IO_ssize_t _IO_read __P((int, void*, _IO_size_t));
-extern _IO_ssize_t _IO_write __P((int, const void*, _IO_size_t));
-extern _IO_off_t _IO_lseek __P((int, _IO_off_t, int));
-extern int _IO_close __P((int));
-extern int _IO_fstat __P((int, struct stat *));
+extern _IO_ssize_t _IO_read __P ((int, void *, _IO_size_t));
+extern _IO_ssize_t _IO_write __P ((int, const void *, _IO_size_t));
+extern _IO_off_t _IO_lseek __P ((int, _IO_off_t, int));
+extern int _IO_close __P ((int));
+extern int _IO_fstat __P ((int, struct stat *));
+extern int _IO_vscanf __P ((const char *, _IO_va_list));
 
 /* Operations on _IO_fpos_t.
    Normally, these are trivial, but we provide hooks for configurations
@@ -475,24 +460,22 @@
 
 /* _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))
+# define _IO_pos_BAD ((_IO_fpos_t) -1)
 #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))
+# define _IO_pos_as_off(__pos) ((_IO_off_t) (__pos))
 #endif
 /* _IO_pos_adjust adjust an _IO_fpos_t by some number of bytes. */
 #ifndef _IO_pos_adjust
-#define _IO_pos_adjust(__pos, __delta) ((__pos) += (__delta))
+# define _IO_pos_adjust(__pos, __delta) ((__pos) += (__delta))
 #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)
+# define _IO_pos_0 ((_IO_fpos_t) 0)
 #endif
 
-#ifdef __cplusplus
-}
-#endif
+__END_DECLS
 
 #ifdef _IO_MTSAFE_IO
 /* check following! */
@@ -502,7 +485,7 @@
 	  0, 0, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock }
 #else
 /* check following! */
-#define FILEBUF_LITERAL(CHAIN, FLAGS, FD) \
+# define FILEBUF_LITERAL(CHAIN, FLAGS, FD) \
        { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, FD}
 #endif
@@ -510,57 +493,60 @@
 /* VTABLE_LABEL defines NAME as of the CLASS class.
    CNLENGTH is strlen(#CLASS).  */
 #ifdef __GNUC__
-#if _G_VTABLE_LABEL_HAS_LENGTH
-#define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \
+# if _G_VTABLE_LABEL_HAS_LENGTH
+#  define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \
   extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CNLENGTH #CLASS);
-#else
-#define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \
+# else
+#  define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \
   extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CLASS);
-#endif
+# endif
 #endif /* __GNUC__ */
 
 #if !defined(builtinbuf_vtable) && defined(__cplusplus)
-#ifdef __GNUC__
+# ifdef __GNUC__
 VTABLE_LABEL(builtinbuf_vtable, builtinbuf, 10)
-#else
-#if _G_VTABLE_LABEL_HAS_LENGTH
-#define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##10builtinbuf
-#else
-#define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##builtinbuf
-#endif
-#endif
+# else
+#  if _G_VTABLE_LABEL_HAS_LENGTH
+#   define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##10builtinbuf
+#  else
+#   define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##builtinbuf
+#  endif
+# endif
 #endif /* !defined(builtinbuf_vtable) && defined(__cplusplus) */
 
 #if defined(__STDC__) || defined(__cplusplus)
-#define _IO_va_start(args, last) va_start(args, last)
+# define _IO_va_start(args, last) va_start(args, last)
 #else
-#define _IO_va_start(args, last) va_start(args)
+# define _IO_va_start(args, last) va_start(args)
 #endif
 
 extern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf;
 
 #if 1
-#define COERCE_FILE(FILE) /* Nothing */
+# define COERCE_FILE(FILE) /* Nothing */
 #else
 /* This is part of the kludge for binary compatibility with old stdio. */
-#define COERCE_FILE(FILE) \
+# define COERCE_FILE(FILE) \
   (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) == _OLD_MAGIC_MASK \
     && (FILE) = *(FILE**)&((int*)fp)[1])
 #endif
 
 #ifdef EINVAL
-#define MAYBE_SET_EINVAL __set_errno (EINVAL)
+# if defined(__GLIBC__) && __GLIBC__ >= 2 
+#  define MAYBE_SET_EINVAL __set_errno (EINVAL)
+# else
+#  define MAYBE_SET_EINVAL errno = EINVAL
+# endif
 #else
-#define MAYBE_SET_EINVAL /* nothing */
+# define MAYBE_SET_EINVAL /* nothing */
 #endif
 
-#ifdef DEBUG
-#define CHECK_FILE(FILE,RET) \
+#ifdef IO_DEBUG
+# define CHECK_FILE(FILE, RET) \
 	if ((FILE) == NULL) { MAYBE_SET_EINVAL; return RET; } \
 	else { COERCE_FILE(FILE); \
 	       if (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \
 	  { MAYBE_SET_EINVAL; return RET; }}
 #else
-#define CHECK_FILE(FILE,RET) \
-	COERCE_FILE(FILE)
+# define CHECK_FILE(FILE, RET) COERCE_FILE (FILE)
 #endif
Index: libio/outfloat.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/outfloat.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 outfloat.c
--- libio/outfloat.c	1997/08/26 00:21:27	1.1.1.1
+++ libio/outfloat.c	1997/08/26 01:42:20
@@ -24,6 +24,7 @@
 
 #include "libioP.h"
 
+#ifdef _IO_USE_DTOA
 /* Format floating-point number and print them.
    Return number of chars printed, or EOF on error.
 
@@ -202,3 +203,4 @@
  error:
   return EOF;
 }
+#endif
Index: libio/stdstrbufs.cc
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/stdstrbufs.cc,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 stdstrbufs.cc
--- libio/stdstrbufs.cc	1997/08/26 00:21:27	1.1.1.1
+++ libio/stdstrbufs.cc	1997/08/26 01:42:20
@@ -29,6 +29,7 @@
    point to builtinbuf's vtable, so the objects are effectively
    of class builtinbuf.) */
 
+#include "_G_config.h"
 #include "libioP.h"
 #include <stdio.h>
 
@@ -54,8 +55,15 @@
 #define STD_VTABLE (const struct _IO_jump_t *)filebuf_vtable
 #endif
 
+#ifdef _IO_MTSAFE_IO
+#define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
+  static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
+  struct _IO_FILE_plus NAME \
+    = {FILEBUF_LITERAL(CHAIN, FLAGS, FD), &_IO_file_jumps}
+#else
 #define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
   struct _IO_FILE_plus NAME = {FILEBUF_LITERAL(CHAIN, FLAGS, FD), STD_VTABLE}
+#endif
 
 DEF_STDFILE(_IO_stdin_, 0, 0, _IO_NO_WRITES);
 DEF_STDFILE(_IO_stdout_, 1, &_IO_stdin_.file, _IO_NO_READS);
Index: libio/streambuf.cc
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/streambuf.cc,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 streambuf.cc
--- libio/streambuf.cc	1997/09/08 01:01:07	1.1.1.2
+++ libio/streambuf.cc	1997/09/08 02:18:51
@@ -162,7 +162,7 @@
 
 static int _IO_sb_pbackfail(_IO_FILE *fp, int ch)
 { return ((streambuf*)fp)->pbackfail(ch); }
-static void _IO_sb_finish(_IO_FILE *fp)
+static void _IO_sb_finish(_IO_FILE *fp, int)
 { ((streambuf*)fp)->~streambuf(); }
 static _IO_ssize_t _IO_sb_read(_IO_FILE *fp, void *buf, _IO_ssize_t n)
 { return ((streambuf*)fp)->sys_read((char*)buf, n); }
@@ -207,13 +207,22 @@
 
 streambuf::streambuf(int flags)
 {
+#ifdef _IO_MTSAFE_IO
+  _lock = new _IO_lock_t;
+#endif
   _IO_init(this, flags);
 #if !_IO_UNIFIED_JUMPTABLES
   _jumps = &_IO_streambuf_jumps;
 #endif
 }
 
-streambuf::~streambuf() { _IO_default_finish(this,0); }
+streambuf::~streambuf()
+{
+  _IO_default_finish(this, 0);
+#ifdef _IO_MTSAFE_IO
+  delete _lock;
+#endif
+}
 
 streampos
 streambuf::seekoff(streamoff, _seek_dir, int /*=ios::in|ios::out*/)
Index: libio/streambuf.h
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/streambuf.h,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 streambuf.h
--- libio/streambuf.h	1997/09/08 01:01:07	1.1.1.2
+++ libio/streambuf.h	1997/09/08 01:08:22
@@ -36,7 +36,7 @@
 #include <libio.h>
 }
 //#include <_G_config.h>
-#ifdef _IO_NEED_STDARG_H
+#ifdef _G_NEED_STDARG_H
 #include <stdarg.h>
 #endif
 #ifndef _IO_va_list
Index: libio/config/linux.mt
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/config/linux.mt,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 linux.mt
--- libio/config/linux.mt	1997/08/26 00:21:27	1.1.1.1
+++ libio/config/linux.mt	1997/08/26 01:42:20
@@ -1,26 +1,30 @@
 # Since the Linux C library has libio, we have to be very careful.
 
+# That is where we keep the g++ header files.
+gxx_includedir =$(prefix)/include/g++
+
 # By default, we build libio and use it.  If someone wants to not
 # build it, let them go to extra work.  The reason is that the user
 # may want a newer, bug fixed libio, also on a linux 1.0.8 system
 # things just won't build with the bottom section uncommented.
 
 # Comment this out to avoid including the stdio functions in libiostream.a:
-LIBIOSTREAM_OBJECTS = $(IO_OBJECTS) $(IOSTREAM_OBJECTS) $(STDIO_WRAP_OBJECTS) $(OSPRIM_OBJECTS)
-LIBIOSTREAM_DEP = $(LIBIOSTREAM_OBJECTS) stdio.list
-LIBIOSTREAM_USE = $(LIBIOSTREAM_OBJECTS) `cat stdio.list`
+# LIBIOSTREAM_OBJECTS = $(IO_OBJECTS) $(IOSTREAM_OBJECTS) $(STDIO_WRAP_OBJECTS) $(OSPRIM_OBJECTS)
+# LIBIOSTREAM_DEP = $(LIBIOSTREAM_OBJECTS) stdio.list
+# LIBIOSTREAM_USE = $(LIBIOSTREAM_OBJECTS) `cat stdio.list`
 
 # Comment the above and uncomment the below to use the code in the Linux libc:
 # We have _G_config.h in /usr/include.
-# _G_CONFIG_H=
+_G_CONFIG_H=
 
 # We have those in libc.a.
-# IO_OBJECTS=
-# STDIO_WRAP_OBJECTS=
-# OSPRIM_OBJECTS=
+IO_OBJECTS=
+STDIO_OBJECTS=
+STDIO_WRAP_OBJECTS=
+OSPRIM_OBJECTS=
 
 # We have the rest in /usr/include.
-# USER_INCLUDES=PlotFile.h SFile.h builtinbuf.h editbuf.h fstream.h \
-# 	indstream.h iomanip.h iostream.h istream.h ostream.h \
-# 	parsestream.h pfstream.h procbuf.h stdiostream.h stream.h \
-# 	streambuf.h strfile.h strstream.h
+USER_INCLUDES=PlotFile.h SFile.h builtinbuf.h editbuf.h fstream.h \
+	indstream.h iomanip.h iostream.h istream.h ostream.h \
+	parsestream.h pfstream.h procbuf.h stdiostream.h stream.h \
+	streambuf.h strfile.h strstream.h
Index: libio/dbz/Makefile.in
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/dbz/Makefile.in,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Makefile.in
--- libio/dbz/Makefile.in	1997/08/26 00:21:27	1.1.1.1
+++ libio/dbz/Makefile.in	1997/08/26 01:42:20
@@ -37,7 +37,8 @@
 install-info:
 info:
 
-check: r rclean
+check: r
+	$(MAKE) rclean
 
 bininstall:	dbz
 	cp dbz $(NEWSBIN)
Index: libio/tests/tFile.cc
===================================================================
RCS file: /home/work/cvs/gnu/egcs/libio/tests/tFile.cc,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 tFile.cc
--- libio/tests/tFile.cc	1997/08/26 00:21:28	1.1.1.1
+++ libio/tests/tFile.cc	1997/08/26 01:42:20
@@ -43,6 +43,8 @@
 #include <string.h>
 #include <assert.h>
 
+const char *tempfile;
+
 class record
 {
 public:
@@ -160,9 +162,9 @@
 
   cout << "\nMaking File tf ... "; 
 #ifdef _OLD_STREAMS
-  File tf("tempfile", io_readwrite, a_create);
+  File tf(tempfile, io_readwrite, a_create);
 #else
-  fstream tf("tempfile", ios::in|ios::out|ios::trunc);
+  fstream tf(tempfile, ios::in|ios::out|ios::trunc);
 #endif
   assert(tf.good());
   assert(tf.is_open());
@@ -190,7 +192,7 @@
   tf.open(tf.name(), io_appendonly, a_use);
 #else
   tf.close();
-  tf.open("tempfile", ios::app);
+  tf.open(tempfile, ios::app);
 #endif
   assert(tf.good());
   assert(tf.is_open());
@@ -204,7 +206,7 @@
   tf << s;
   assert(tf.good());
   tf.close();
-  tf.open("tempfile", ios::in);
+  tf.open(tempfile, ios::in);
 #endif
   tf.raw();
   assert(tf.good());
@@ -223,7 +225,7 @@
   tf.remove();
 #else
   tf.close();
-  unlink("tempfile");
+  unlink(tempfile);
 #endif
   assert(!tf.is_open());
 }
@@ -512,6 +514,8 @@
 
 main(int argc, char **argv)
 {
+ char temp [1024] = "tempfile";
+
  if (argc > 1 && strncmp(argv[1], "-b", 2) == 0) {
      streambuf *sb = cout.rdbuf();
      streambuf *ret;
@@ -522,7 +526,11 @@
 	 ret = sb->setbuf(new char[buffer_size], buffer_size);
      if (ret != sb)
 	 cerr << "Warning: cout.rdbuf()->setbuf failed!\n";
+     
+      strncpy (&temp [8], &argv[1][2], 1000);
+      temp [1008] = '\0';
   }
+  tempfile = temp;
   t1();
   t2();
   t3();
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ libio/iovasprintf.c	Mon Aug 25 18:12:32 1997
@@ -0,0 +1,76 @@
+/* Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU IO Library.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This library is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this library; see the file COPYING.  If not, write to
+   the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   As a special exception, if you link this library with files
+   compiled with a GNU compiler to produce an executable, this does
+   not cause the resulting executable to be covered by the GNU General
+   Public License.  This exception does not however invalidate any
+   other reasons why the executable file might be covered by the GNU
+   General Public License.  */
+
+#include <malloc.h>
+#include "libioP.h"
+#include "stdio.h"
+#include "strfile.h"
+
+int
+_IO_vasprintf (result_ptr, format, args)
+     char **result_ptr;
+     const char *format;
+     _IO_va_list args;
+{
+  /* Initial size of the buffer to be used.  Will be doubled each time an
+     overflow occurs.  */
+  const _IO_size_t init_string_size = 100;
+  char *string;
+  _IO_strfile sf;
+#ifdef _IO_MTSAFE_IO
+  _IO_lock_t lock;
+#endif
+  int ret;
+  string = (char *) malloc (init_string_size);
+  if (string == NULL)
+    return -1;
+#ifdef _IO_MTSAFE_IO
+  sf._sbf._f._lock = &lock;
+#endif
+  _IO_init ((_IO_FILE *) &sf, 0);
+  _IO_JUMPS ((_IO_FILE *) &sf) = &_IO_str_jumps;
+  _IO_str_init_static ((_IO_FILE *) &sf, string, init_string_size, string);
+  sf._sbf._f._flags &= ~_IO_USER_BUF;
+  sf._s._allocate_buffer = (_IO_alloc_type) malloc;
+  sf._s._free_buffer = (_IO_free_type) free;
+  ret = _IO_vfprintf ((_IO_FILE *) &sf, format, args);
+  if (ret < 0)
+    return ret;
+  *result_ptr = (char *) realloc (sf._sbf._f._IO_buf_base,
+				  (sf._sbf._f._IO_write_ptr
+				   - sf._sbf._f._IO_write_base) +1);
+  if (*result_ptr == NULL)
+    *result_ptr = sf._sbf._f._IO_buf_base;
+  (*result_ptr)[sf._sbf._f._IO_write_ptr-sf._sbf._f._IO_write_base] = '\0';
+  return ret;
+}
+
+#ifdef weak_alias
+weak_alias (_IO_vasprintf, vasprintf)
+#else
+#if defined(__ELF__) && defined(_IO_USE_LIBC)
+#pragma weak vasprintf = _IO_vasprintf
+#endif
+#endif
--- /dev/null	Wed Dec 31 16:00:00 1969
+++ libio/iovsnprintf.c	Mon Aug 25 18:15:43 1997
@@ -0,0 +1,140 @@
+/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU IO Library.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This library is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this library; see the file COPYING.  If not, write to
+   the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   As a special exception, if you link this library with files
+   compiled with a GNU compiler to produce an executable, this does
+   not cause the resulting executable to be covered by the GNU General
+   Public License.  This exception does not however invalidate any
+   other reasons why the executable file might be covered by the GNU
+   General Public License.  */
+
+#include "libioP.h"
+#include "strfile.h"
+
+
+typedef struct
+{
+  _IO_strfile f;
+  /* This is used for the characters which do not fit in the buffer
+     provided by the user.  */
+  char overflow_buf[64];
+} _IO_strnfile;
+
+
+static int _IO_strn_overflow __P ((_IO_FILE *fp, int c));
+
+static int
+_IO_strn_overflow (fp, c)
+     _IO_FILE *fp;
+     int c;
+{
+  /* When we come to here this means the user supplied buffer is
+     filled.  But since we must return the number of characters which
+     would have been written in total we must provide a buffer for
+     further use.  We can do this by writing on and on in the overflow
+     buffer in the _IO_strnfile structure.  */
+  _IO_strnfile *snf = (_IO_strnfile *) fp;
+
+  if (fp->_IO_buf_base != snf->overflow_buf)
+    {
+      /* Terminate the string.  We know that there is room for at
+	 least one more character since we initialized the stream with
+	 a size to make this possible.  */
+      *fp->_IO_write_ptr = '\0';
+
+      _IO_setb (fp, snf->overflow_buf,
+		snf->overflow_buf + sizeof (snf->overflow_buf), 0);
+
+      fp->_IO_write_base = snf->overflow_buf;
+      fp->_IO_read_base = snf->overflow_buf;
+      fp->_IO_read_ptr = snf->overflow_buf;
+      fp->_IO_read_end = snf->overflow_buf + sizeof (snf->overflow_buf);
+    }
+
+  fp->_IO_write_ptr = snf->overflow_buf;
+  fp->_IO_write_end = snf->overflow_buf;
+
+  /* Since we are not really interested in storing the characters
+     which do not fit in the buffer we simply ignore it.  */
+  return c;
+}
+
+
+static struct _IO_jump_t _IO_strn_jumps =
+{
+  JUMP_INIT_DUMMY,
+  JUMP_INIT(finish, _IO_str_finish),
+  JUMP_INIT(overflow, _IO_strn_overflow),
+  JUMP_INIT(underflow, _IO_str_underflow),
+  JUMP_INIT(uflow, _IO_default_uflow),
+  JUMP_INIT(pbackfail, _IO_str_pbackfail),
+  JUMP_INIT(xsputn, _IO_default_xsputn),
+  JUMP_INIT(xsgetn, _IO_default_xsgetn),
+  JUMP_INIT(seekoff, _IO_str_seekoff),
+  JUMP_INIT(seekpos, _IO_default_seekpos),
+  JUMP_INIT(setbuf, _IO_default_setbuf),
+  JUMP_INIT(sync, _IO_default_sync),
+  JUMP_INIT(doallocate, _IO_default_doallocate),
+  JUMP_INIT(read, _IO_default_read),
+  JUMP_INIT(write, _IO_default_write),
+  JUMP_INIT(seek, _IO_default_seek),
+  JUMP_INIT(close, _IO_default_close),
+  JUMP_INIT(stat, _IO_default_stat)
+};
+
+
+int
+_IO_vsnprintf (string, maxlen, format, args)
+     char *string;
+     _IO_size_t maxlen;
+     const char *format;
+     _IO_va_list args;
+{
+  _IO_strnfile sf;
+  int ret;
+#ifdef _IO_MTSAFE_IO
+  _IO_lock_t lock;
+  sf.f._sbf._f._lock = &lock;
+#endif
+
+  /* We need to handle the special case where MAXLEN is 0.  Use the
+     overflow buffer right from the start.  */
+  if (maxlen == 0)
+    {
+      string = sf.overflow_buf;
+      maxlen = sizeof (sf.overflow_buf);
+    }
+
+  _IO_init ((_IO_FILE *) &sf, 0);
+  _IO_JUMPS ((_IO_FILE *) &sf) = &_IO_strn_jumps;
+  _IO_str_init_static ((_IO_FILE *) &sf, string, maxlen - 1, string);
+  ret = _IO_vfprintf ((_IO_FILE *) &sf, format, args);
+
+  if (sf.f._sbf._f._IO_buf_base != sf.overflow_buf)
+    *sf.f._sbf._f._IO_write_ptr = '\0';
+  return ret;
+}
+
+#ifdef weak_alias
+weak_alias (_IO_vsnprintf, __vsnprintf)
+weak_alias (_IO_vsnprintf, vsnprintf)
+#if defined(__ELF__) && defined(_IO_USE_LIBC)
+#pragma weak vsnprintf = _IO_vsnprintf
+#pragma weak __vsnprintf = _IO_vsnprintf
+#endif
+#endif



More information about the Gcc mailing list