aboutsummaryrefslogtreecommitdiff
path: root/libio
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@cygnus.com>1997-09-16 10:01:55 -0600
committerJeff Law <law@gcc.gnu.org>1997-09-16 10:01:55 -0600
commite693cc28bbfeb1c1728bec4392505d2eba2b1090 (patch)
tree6f133200943f818cad1e94da16393eadfe8dd250 /libio
parent610ce97e654a9f2ed5e103bddd936988c5768538 (diff)
downloadgcc-e693cc28bbfeb1c1728bec4392505d2eba2b1090.zip
gcc-e693cc28bbfeb1c1728bec4392505d2eba2b1090.tar.gz
gcc-e693cc28bbfeb1c1728bec4392505d2eba2b1090.tar.bz2
Uli's libio/libstdc++ patches.
From-SVN: r15486
Diffstat (limited to 'libio')
-rw-r--r--libio/ChangeLog62
-rw-r--r--libio/cleanup.c2
-rw-r--r--libio/config.shared5
-rw-r--r--libio/config/linux.mt36
-rw-r--r--libio/configure.in27
-rw-r--r--libio/depend142
-rw-r--r--libio/fileops.c56
-rw-r--r--libio/include/empty.h36
-rw-r--r--libio/ioignore.c5
-rw-r--r--libio/iolibio.h5
-rw-r--r--libio/ioperror.c4
-rw-r--r--libio/iopopen.c4
-rw-r--r--libio/ioprims.c27
-rw-r--r--libio/ioseekoff.c9
-rw-r--r--libio/ioseekpos.c8
-rw-r--r--libio/iostream.cc237
-rw-r--r--libio/iostream.h16
-rw-r--r--libio/iostrerror.c4
-rw-r--r--libio/iovfprintf.c17
-rw-r--r--libio/iovfscanf.c13
-rw-r--r--libio/libio.h163
-rw-r--r--libio/libioP.h462
-rw-r--r--libio/osform.cc14
-rw-r--r--libio/outfloat.c15
-rw-r--r--libio/stdio-lock.h1
-rw-r--r--libio/stdio/ChangeLog3
-rw-r--r--libio/stdio/feof.c53
-rw-r--r--libio/stdio/ferror.c41
-rw-r--r--libio/stdio/getc.c45
-rw-r--r--libio/stdio/putc.c38
-rw-r--r--libio/stdio/putchar.c2
-rw-r--r--libio/stdio/stdio.h42
-rw-r--r--libio/stdstrbufs.cc25
-rw-r--r--libio/streambuf.cc13
-rw-r--r--libio/strops.c4
-rw-r--r--libio/tests/tFile.cc16
36 files changed, 1072 insertions, 580 deletions
diff --git a/libio/ChangeLog b/libio/ChangeLog
index d9b9b8e..b05d4ea 100644
--- a/libio/ChangeLog
+++ b/libio/ChangeLog
@@ -1,3 +1,65 @@
+1997-09-15 02:37 Ulrich Drepper <drepper@cygnus.com>
+
+ * config/linux.mt: Rewrite for use with glibc 2.
+ * config/linuxlibc1.mt: Old content of linux.mt, fir libc4 and
+ libc5.
+
+ * config.shared (COMPILE.c): Allow new flags in MT_CFLAGS be
+ passed.
+ (COMPILE.cc): Likewise.
+
+ * configure.in (*-linux*): Remove goal. We now have...
+ (*-linux-gnulibc1): For libc4 and libc5. Emit warning.
+ (*-linux-gnu)): For glibc 2.
+ Create links to find headers for multi-threading if necessary.
+
+ * fileops.c: Make thread-safe by using _IO_cleanup_region_start
+ etc to handle cancelation. Acquire locks in functions which are
+ called directly.
+ (_IO_file_read, _IO_file_write): Remove dead code.
+
+ * include/empty.h: Define stub macros for locking.
+
+ * iolibio.h: Add prototypes for obstack printing functions.
+
+ * ioseekoff.c (_IO_seekoff): Lock stream before working.
+ * ioseekpos.c (_IO_seekpos): Likewise.
+
+ * iostream.cc: Add support for long double I/O.
+ Use __printf_fp from glibc is available.
+ Use _IO_cleanup_region_start to handle cancelation correctly.
+ * iostream.h (class ostream): Change opfx and osfx to lock/unlock
+ stream
+ (class istream): Likewise for ipfx, ipfx0, ipfx1, and isfx.
+ Declare new function lock and unlock for ostream and istream.
+ * osform.cc: Use _IO_cleanup_region_start to handle cancelation
+ correctly.
+
+ * libio.h: Update from glibc version. Pretty printing.
+ * libioP.h: Likewise.
+
+ * outfloat.c: Only compile if _IO_USE_DTOA is defined.
+
+ * stdio/feof.c: Make thread safe.
+ * stdio/ferror.c: Likewise.
+ * stdio/getc.c : Likewise.
+ * stdio/putc.c : Likewise.
+ * stdio/stdio.h: Declare function of thread-safe API.
+
+ * stdio/obprintf.c: New file.
+ * stdio/vasprintf.c: New file.
+
+ * stdio-lock.h: Removed.
+
+ * stdstrbufs.c: Add definitions for thread-safe streams.
+
+ * streambuf.cc: Initialize lock.
+
+ * strops.c (_IO_str_count): Undo last change.
+
+ * tests/tFile.cc: Support parallel builds by avoiding fixed
+ name for test file.
+
Thu Sep 11 18:43:56 1997 Jason Merrill <jason@yorick.cygnus.com>
* Makefile.in (iostream.list): Remove STDIO_WRAP_OBJECTS.
diff --git a/libio/cleanup.c b/libio/cleanup.c
index a0c5052..691fa83 100644
--- a/libio/cleanup.c
+++ b/libio/cleanup.c
@@ -5,7 +5,7 @@
typedef void (*voidfunc) __P((void));
static void
-DEFUN_VOID(_IO_register_cleanup)
+_IO_register_cleanup ()
{
atexit ((voidfunc)_IO_cleanup);
_IO_cleanup_registration_needed = 0;
diff --git a/libio/config.shared b/libio/config.shared
index 8c79350..009381a 100644
--- a/libio/config.shared
+++ b/libio/config.shared
@@ -254,7 +254,7 @@ else
fi
echo '.SUFFIXES: .o .C .cc .c'
-echo 'COMPILE.c = $(CC) -c $(XCFLAGS) $(CINCLUDES)'
+echo 'COMPILE.c = $(CC) -c $(XCFLAGS) $(CINCLUDES) $(MT_CFLAGS)'
echo '.c.o:'
if [ "${LIBDIR}" = "yes" ]; then
echo ' test -z "$(PICFLAG)" ||\'
@@ -262,7 +262,7 @@ echo ' $(COMPILE.c) $(PICFLAG) $< -o pic/$@'
fi
echo ' $(COMPILE.c) $<'
[ "${TOUCH_ON_COMPILE}" = "yes" ] && echo ' @touch stamp'
-echo 'COMPILE.cc = $(CXX) -c $(XCXXFLAGS) $(CXXINCLUDES)'
+echo 'COMPILE.cc = $(CXX) -c $(XCXXFLAGS) $(CXXINCLUDES) $(MT_CFLAGS)'
echo '.C.o:'
if [ "${LIBDIR}" = "yes" ]; then
echo ' test -z "$(PICFLAG)" ||\'
@@ -466,6 +466,7 @@ depend.new:
>depend.new
$(CXX) -M $(CXXINCLUDES) $(DEPEND_SOURCES) \
| sed -e 's|$(srcdir)/|$$(srcdir)/|g' \
+ -e 's| [^ ]_G_config.h| $$(_G_CONFIG_H)|g \
-e 's| /[^ ]*||g' \
-e '/^[ ]*\\$$/d' -e 's/^[ ]*$$//' \
| sed -e 's|$$(srcdir)/[.][.]|$$(srcdir)/$$(MULTISRCTOP)..|g' \
diff --git a/libio/config/linux.mt b/libio/config/linux.mt
index ffda172..4bb92b7 100644
--- a/libio/config/linux.mt
+++ b/libio/config/linux.mt
@@ -1,26 +1,30 @@
-# Since the Linux C library has libio, we have to be very careful.
+# Use the libio which comes with the local libc.
-# 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.
+# That is where we keep the g++ header files.
+gxx_includedir =$(prefix)/include/g++
# 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) stmp-stdio
-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 must not see the libio.h file from this library.
+LIBIO_INCLUDE=
# We have those in libc.a.
-# IO_OBJECTS=
-# STDIO_WRAP_OBJECTS=
-# OSPRIM_OBJECTS=
+IO_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
+
+# tell we want the mt-safe version
+MT_CFLAGS = -D_IO_MTSAFE_IO
diff --git a/libio/configure.in b/libio/configure.in
index b14c3b1..06c6fda 100644
--- a/libio/configure.in
+++ b/libio/configure.in
@@ -16,12 +16,13 @@ frags=
case "${target}" in
*-hpux*) frags=hpux.mt ;;
- *-linux*)
+ *-linux-gnulibc1)
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 ;;
+ frags=linuxlibc1.mt ;;
+ *-linux-gnu) frags=linux.mt ;;
*-sco3.2v[45]*) frags=sco4.mt ;;
*-isc*) frags=isc.mt ;;
*-netware*) frags=netware.mt ;;
@@ -43,6 +44,28 @@ if [ "${shared}" = "yes" ]; then
esac
fi
+# Make a link for the correct stdio-lock.h file.
+case "${target}" in
+ *-linux-gnu)
+ # We have a correct file in glibc but the libioP.h file is written
+ # with glibc 2.1 in mind which has the internals headers in special
+ # directory while glibc 2.0 has them in /usr/include. Create a wrapper
+ # if necessary.
+ (echo "#include <bits/libc-lock.h>" | ${CC-cc} -E -) >/dev/null 2>&1 ||
+ {
+ rm -fr bits
+ mkdir bits
+ echo "#include <libc-lock.h>" > bits/libc-lock.h
+ echo "#include <stdio-lock.h>" > bits/stdio-lock.h
+ }
+ ;;
+ *)
+ rm -fr bits
+ mkdir bits
+ ln -s ${srcdir}/include/empty.h bits/stdio-lock.h
+ ;;
+esac
+
for frag in ${frags}; do
frag=${srcdir}/config/$frag
if [ -f ${frag} ]; then
diff --git a/libio/depend b/libio/depend
index 171356c..b7335fd 100644
--- a/libio/depend
+++ b/libio/depend
@@ -5,24 +5,24 @@ PlotFile.o: PlotFile.cc \
$(srcdir)/fstream.h \
$(srcdir)/iostream.h \
$(srcdir)/streambuf.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
SFile.o: SFile.cc \
$(srcdir)/SFile.h \
$(srcdir)/fstream.h \
$(srcdir)/iostream.h \
$(srcdir)/streambuf.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
builtinbuf.o: builtinbuf.cc \
$(srcdir)/builtinbuf.h \
$(srcdir)/streambuf.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/iostreamP.h \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h
editbuf.o: editbuf.cc \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/editbuf.h \
$(srcdir)/fstream.h \
$(srcdir)/iostream.h \
@@ -30,14 +30,14 @@ editbuf.o: editbuf.cc \
filebuf.o: filebuf.cc \
$(srcdir)/iostreamP.h \
$(srcdir)/streambuf.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
$(srcdir)/builtinbuf.h
fstream.o: fstream.cc \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/fstream.h \
$(srcdir)/iostream.h \
$(srcdir)/streambuf.h
@@ -45,63 +45,63 @@ indstream.o: indstream.cc \
$(srcdir)/indstream.h \
$(srcdir)/iostream.h \
$(srcdir)/streambuf.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
ioassign.o: ioassign.cc \
$(srcdir)/iostream.h \
$(srcdir)/streambuf.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h
ioextend.o: ioextend.cc \
$(srcdir)/iostream.h \
$(srcdir)/streambuf.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iomanip.o: iomanip.cc \
$(srcdir)/iomanip.h \
$(srcdir)/iostream.h \
$(srcdir)/streambuf.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iostream.o: iostream.cc \
$(srcdir)/iostream.h \
$(srcdir)/streambuf.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
$(srcdir)/floatio.h
isgetline.o: isgetline.cc \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/iostream.h \
$(srcdir)/streambuf.h
isgetsb.o: isgetsb.cc \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/iostream.h \
$(srcdir)/streambuf.h
isscan.o: isscan.cc \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/iostream.h \
$(srcdir)/streambuf.h
osform.o: osform.cc \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/iostream.h \
$(srcdir)/streambuf.h
parsestream.o: parsestream.cc \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/parsestream.h \
$(srcdir)/streambuf.h
pfstream.o: pfstream.cc \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/pfstream.h \
$(srcdir)/fstream.h \
$(srcdir)/iostream.h \
@@ -110,45 +110,45 @@ pfstream.o: pfstream.cc \
procbuf.o: procbuf.cc \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/procbuf.h \
$(srcdir)/streambuf.h
sbform.o: sbform.cc \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/streambuf.h
sbgetline.o: sbgetline.cc \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/streambuf.h
sbscan.o: sbscan.cc \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/streambuf.h
stdiostream.o: stdiostream.cc \
$(srcdir)/stdiostream.h \
$(srcdir)/iostream.h \
$(srcdir)/streambuf.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h
stdstrbufs.o: stdstrbufs.cc \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
stdstreams.o: stdstreams.cc \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/streambuf.h \
$(srcdir)/iostream.h
stream.o: stream.cc \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/stream.h \
$(srcdir)/iostream.h \
$(srcdir)/streambuf.h \
@@ -157,13 +157,13 @@ stream.o: stream.cc \
streambuf.o: streambuf.cc \
$(srcdir)/iostreamP.h \
$(srcdir)/streambuf.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h
strstream.o: strstream.cc \
$(srcdir)/iostreamP.h \
$(srcdir)/streambuf.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
$(srcdir)/strstream.h \
@@ -172,181 +172,181 @@ strstream.o: strstream.cc \
cleanup.o: cleanup.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
filedoalloc.o: filedoalloc.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
fileops.o: fileops.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
floatconv.o: floatconv.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
genops.o: genops.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iofclose.o: iofclose.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iofdopen.o: iofdopen.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iofflush.o: iofflush.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iofgetpos.o: iofgetpos.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iofgets.o: iofgets.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iofopen.o: iofopen.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iofprintf.o: iofprintf.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iofputs.o: iofputs.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iofread.o: iofread.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iofscanf.o: iofscanf.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iofsetpos.o: iofsetpos.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
ioftell.o: ioftell.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iofwrite.o: iofwrite.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iogetdelim.o: iogetdelim.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iogetline.o: iogetline.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iogets.o: iogets.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
ioignore.o: ioignore.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iopadn.o: iopadn.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
ioperror.o: ioperror.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iopopen.o: iopopen.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
ioprims.o: ioprims.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
ioprintf.o: ioprintf.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
ioputs.o: ioputs.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
ioscanf.o: ioscanf.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
ioseekoff.o: ioseekoff.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
ioseekpos.o: ioseekpos.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iosetbuffer.o: iosetbuffer.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iosetvbuf.o: iosetvbuf.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iosprintf.o: iosprintf.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iosscanf.o: iosscanf.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iostrerror.o: iostrerror.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
ioungetc.o: ioungetc.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
iovfprintf.o: iovfprintf.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/floatio.h
iovfscanf.o: iovfscanf.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/floatio.h
iovsprintf.o: iovsprintf.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/strfile.h
iovsscanf.o: iovsscanf.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/strfile.h
outfloat.o: outfloat.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
stdfiles.o: stdfiles.c \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h \
- $(srcdir)/libio.h _G_config.h
+ $(srcdir)/libio.h $(_G_CONFIG_H)
strops.o: strops.c \
$(srcdir)/strfile.h \
- $(srcdir)/libio.h _G_config.h \
+ $(srcdir)/libio.h $(_G_CONFIG_H) \
$(srcdir)/libioP.h \
$(srcdir)/iolibio.h
diff --git a/libio/fileops.c b/libio/fileops.c
index b3a3a24..001794d 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -40,7 +40,12 @@ extern int errno;
#ifdef _LIBC
-# define open(Name, Flags, Prot) __open ((Name), (Flags), (Prot))
+# define open(Name, Flags, Prot) __open (Name, Flags, Prot)
+# define close(FD) __close (FD)
+# define fstat(FD, Statbuf) __fstat (FD, Statbuf)
+# define lseek(FD, Offset, Whence) __lseek (FD, Offset, Whence)
+# define read(FD, Buf, NBytes) __read (FD, Buf, NBytes)
+# define write(FD, Buf, NBytes) __write (FD, Buf, NBytes)
#endif
/* An fstream can be in at most one of put mode, get mode, or putback mode.
@@ -384,6 +389,10 @@ _IO_file_sync (fp)
_IO_FILE *fp;
{
_IO_size_t delta;
+ int retval = 0;
+
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_flockfile (fp);
/* char* ptr = cur_ptr(); */
if (fp->_IO_write_ptr > fp->_IO_write_base)
if (_IO_do_flush(fp)) return EOF;
@@ -402,12 +411,14 @@ _IO_file_sync (fp)
; /* Ignore error from unseekable devices. */
#endif
else
- return EOF;
+ retval = EOF;
}
- fp->_offset = _IO_pos_BAD;
+ if (retval != EOF)
+ fp->_offset = _IO_pos_BAD;
/* FIXME: Cleanup - can this be shared? */
/* setg(base(), ptr, ptr); */
- return 0;
+ _IO_cleanup_region_end (1);
+ return retval;
}
_IO_pos_t
@@ -575,19 +586,7 @@ _IO_file_read (fp, buf, size)
void *buf;
_IO_ssize_t size;
{
- for (;;)
- {
- _IO_ssize_t count = _IO_read (fp->_fileno, buf, size);
-#if 0 && defined EINTR
- /* We must not do this optimization since POSIX.1 explicitly
- requests that the stream operations must return with the
- error EINTR if this happens. There must be the possibility
- that stream operations time out. --drepper */
- if (count == -1 && errno == EINTR)
- continue;
-#endif
- return count;
- }
+ return read (fp->_fileno, buf, size);
}
_IO_pos_t
@@ -596,7 +595,7 @@ _IO_file_seek (fp, offset, dir)
_IO_off_t offset;
int dir;
{
- return _IO_lseek (fp->_fileno, offset, dir);
+ return lseek (fp->_fileno, offset, dir);
}
int
@@ -604,14 +603,14 @@ _IO_file_stat (fp, st)
_IO_FILE *fp;
void *st;
{
- return _IO_fstat (fp->_fileno, (struct stat *) st);
+ return fstat (fp->_fileno, (struct stat *) st);
}
int
_IO_file_close (fp)
_IO_FILE *fp;
{
- return _IO_close (fp->_fileno);
+ return close (fp->_fileno);
}
_IO_ssize_t
@@ -623,22 +622,11 @@ _IO_file_write (f, data, n)
_IO_ssize_t to_do = n;
while (to_do > 0)
{
- _IO_ssize_t count = _IO_write (f->_fileno, data, to_do);
+ _IO_ssize_t count = write (f->_fileno, data, to_do);
if (count == EOF)
{
-#if 0 && defined EINTR
- /* We must not do this optimization since POSIX.1 explicitly
- requests that the stream operations must return with the
- error EINTR if this happens. There must be the
- possibility that stream operations time out. --drepper */
- if (errno == EINTR)
- continue;
- else
-#endif
- {
- f->_flags |= _IO_ERR_SEEN;
- break;
- }
+ f->_flags |= _IO_ERR_SEEN;
+ break;
}
to_do -= count;
data = (void *) ((char *) data + count);
diff --git a/libio/include/empty.h b/libio/include/empty.h
index 42dc218..dcbf758 100644
--- a/libio/include/empty.h
+++ b/libio/include/empty.h
@@ -1 +1,37 @@
+/* Thread package specific definitions of stream lock type.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _LIBIO_LOCK_H
+#define _LIBIO_LOCK_H 1
+
+typedef void *_IO_lock_t;
+
+/* We need recursive (counting) mutexes. */
+#define _IO_lock_initializer NULL
+
+
+#define _IO_cleanup_region_start(_fct, _fp)
+#define _IO_cleanup_region_end(_doit)
+#define _IO_lock_init(_name)
+#define _IO_lock_fini(_name)
+#define _IO_lock_lock(_name)
+#define _IO_lock_unlock(_name)
+
+#endif /* libio-lock.h */
/* this will be used later*/
diff --git a/libio/ioignore.c b/libio/ioignore.c
index a7c2f28..ac0678e 100644
--- a/libio/ioignore.c
+++ b/libio/ioignore.c
@@ -25,8 +25,9 @@ the executable file might be covered by the GNU General Public License. */
#include "libioP.h"
int
-DEFUN(_IO_ignore, (fp, n),
- register _IO_FILE *fp AND _IO_size_t n)
+_IO_ignore (fp, n)
+ _IO_FILE *fp;
+ _IO_size_t n;
{
register _IO_size_t more = n;
for (;;)
diff --git a/libio/iolibio.h b/libio/iolibio.h
index e5de77e..6389678 100644
--- a/libio/iolibio.h
+++ b/libio/iolibio.h
@@ -32,6 +32,11 @@ extern int _IO_sprintf __P((char *, const char*, ...));
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
diff --git a/libio/ioperror.c b/libio/ioperror.c
index 55d822b..7ca72b0 100644
--- a/libio/ioperror.c
+++ b/libio/ioperror.c
@@ -10,8 +10,8 @@ extern char* _IO_strerror __P((int));
#endif
void
-DEFUN(_IO_perror, (s),
- const char *s)
+_IO_perror (s)
+ const char *s;
{
char *error = _IO_strerror (errno);
diff --git a/libio/iopopen.c b/libio/iopopen.c
index 4340086..59d4fc3 100644
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -68,6 +68,10 @@ extern int _IO_dup2 __P ((int fd, int fd2));
#define _IO__exit _exit
#endif
+#ifndef _IO_close
+#define _IO_close close
+#endif
+
struct _IO_proc_file
{
struct _IO_FILE_plus file;
diff --git a/libio/ioprims.c b/libio/ioprims.c
index faa69e0..5d31e07 100644
--- a/libio/ioprims.c
+++ b/libio/ioprims.c
@@ -37,36 +37,43 @@ the executable file might be covered by the GNU General Public License. */
#endif
_IO_ssize_t
-DEFUN(_IO_read, (fildes, buf, nbyte),
- int fildes AND void *buf AND _IO_size_t nbyte)
+_IO_read (fildes, buf, nbyte)
+ int fildes;
+ void *buf;
+ _IO_size_t nbyte;
{
return read (fildes, buf, nbyte);
}
_IO_ssize_t
-DEFUN(_IO_write, (fildes, buf, nbyte),
- int fildes AND const void *buf AND _IO_size_t nbyte)
+_IO_write (fildes, buf, nbyte)
+ int fildes;
+ const void *buf;
+ _IO_size_t nbyte;
{
return write (fildes, buf, nbyte);
}
_IO_off_t
-DEFUN(_IO_lseek, (fildes, offset, whence),
- int fildes AND _IO_off_t offset AND int whence)
+_IO_lseek (fildes, offset, whence)
+ int fildes;
+ _IO_off_t offset;
+ int whence;
{
return lseek (fildes, offset, whence);
}
int
-DEFUN(_IO_close, (fildes),
- int fildes)
+_IO_close (fildes)
+ int fildes;
{
return close (fildes);
}
int
-DEFUN(_IO_fstat, (fildes, buf),
- int fildes AND struct stat *buf)
+_IO_fstat (fildes, buf)
+ int fildes;
+ struct stat *buf;
{
return fstat (fildes, buf);
}
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index 8c64216..b1c4729 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -32,9 +32,14 @@ _IO_seekoff (fp, offset, dir, mode)
int dir;
int mode;
{
+ _IO_pos_t retval;
+
/* If we have a backup buffer, get rid of it, since the __seekoff
callback may not know to do the right thing about it.
This may be over-kill, but it'll do for now. TODO */
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_flockfile (fp);
+
if (_IO_have_backup (fp))
{
@@ -42,6 +47,8 @@ _IO_seekoff (fp, offset, dir, mode)
offset -= fp->_IO_read_end - fp->_IO_read_ptr;
_IO_free_backup_area (fp);
}
+ retval = _IO_SEEKOFF (fp, offset, dir, mode);
- return _IO_SEEKOFF (fp, offset, dir, mode);
+ _IO_cleanup_region_end (1);
+ return retval;
}
diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c
index 1ae88fb..2ce0c22 100644
--- a/libio/ioseekpos.c
+++ b/libio/ioseekpos.c
@@ -31,12 +31,18 @@ _IO_seekpos (fp, pos, mode)
_IO_pos_t pos;
int mode;
{
+ _IO_pos_t retval;
+
/* If we have a backup buffer, get rid of it, since the __seekoff
callback may not know to do the right thing about it.
This may be over-kill, but it'll do for now. TODO */
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_flockfile (fp);
if (_IO_have_backup (fp))
_IO_free_backup_area (fp);
+ retval = _IO_SEEKPOS (fp, pos, mode);
- return _IO_SEEKPOS (fp, pos, mode);
+ _IO_cleanup_region_end (1);
+ return retval;
}
diff --git a/libio/iostream.cc b/libio/iostream.cc
index 78b09cb..217b2e2 100644
--- a/libio/iostream.cc
+++ b/libio/iostream.cc
@@ -1,26 +1,27 @@
/* This is part of libio/iostream, providing -*- C++ -*- input/output.
-Copyright (C) 1993 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. */
+ Copyright (C) 1993, 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. */
/* Written by Per Bothner (bothner@cygnus.com). */
@@ -34,7 +35,14 @@ the executable file might be covered by the GNU General Public License. */
#include <ctype.h>
#include <string.h>
#include <limits.h>
+
+#if _G_HAVE_PRINTF_FP
+#include <printf.h>
+extern "C" int __printf_fp (_IO_FILE *, const struct printf_info *,
+ const void *const *);
+#else
#include "floatio.h"
+#endif
#define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */
@@ -133,7 +141,7 @@ istream::sync ()
if (sb == NULL)
return EOF;
if (sb->sync ()) // Later: pubsync
- {
+ {
setstate (ios::badbit);
return EOF;
}
@@ -321,7 +329,11 @@ READ_INT(bool)
istream& istream::operator>>(long double& x)
{
if (ipfx0())
+#if _G_HAVE_LONG_DOUBLE_IO
+ scan("%Lg", &x);
+#else
scan("%lg", &x);
+#endif
return *this;
}
@@ -362,10 +374,14 @@ istream& istream::operator>>(register streambuf* sbuf)
ostream& ostream::operator<<(char c)
{
if (opfx()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
#if 1
// This is what the cfront implementation does.
- if (_strbuf->sputc(c) == EOF)
- goto failed;
+ if (_strbuf->sputc(c) == EOF) {
+ set(ios::badbit);
+ goto failed;
+ }
#else
// This is what cfront documentation and current ANSI drafts say.
int w = width(0);
@@ -373,21 +389,23 @@ ostream& ostream::operator<<(char c)
register int padding = w > 0 ? w - 1 : 0;
register streambuf *sb = _strbuf;
if (!(flags() & ios::left) && padding) // Default adjustment.
- if (_IO_padn(sb, fill_char, padding) < padding)
+ if (_IO_padn(sb, fill_char, padding) < padding) {
+ set(ios::badbit);
goto failed;
- if (sb->sputc(c) == EOF)
+ }
+ if (sb->sputc(c) == EOF) {
+ set(ios::badbit);
goto failed;
+ }
if (flags() & ios::left && padding) // Left adjustment.
if (_IO_padn(sb, fill_char, padding) < padding)
- goto failed;
+ set(ios::badbit);
#endif
+ failed:
osfx();
+ _IO_cleanup_region_end (0);
}
return *this;
- failed:
- set(ios::badbit);
- osfx();
- return *this;
}
/* Write VAL on STREAM.
@@ -493,19 +511,26 @@ static void write_int(ostream& stream, unsigned LONGEST val, int sign)
ostream& ostream::operator<<(int n)
{
if (opfx()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
int sign = 1;
unsigned int abs_n = (unsigned)n;
if (n < 0 && (flags() & (ios::oct|ios::hex)) == 0)
abs_n = -((unsigned)n), sign = -1;
write_int(*this, abs_n, sign);
+ _IO_cleanup_region_end (0);
}
return *this;
}
ostream& ostream::operator<<(unsigned int n)
{
- if (opfx())
+ if (opfx()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
write_int(*this, n, 0);
+ _IO_cleanup_region_end (0);
+ }
return *this;
}
@@ -513,19 +538,26 @@ ostream& ostream::operator<<(unsigned int n)
ostream& ostream::operator<<(long n)
{
if (opfx()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
int sign = 1;
unsigned long abs_n = (unsigned long)n;
if (n < 0 && (flags() & (ios::oct|ios::hex)) == 0)
abs_n = -((unsigned long)n), sign = -1;
write_int(*this, abs_n, sign);
+ _IO_cleanup_region_end (0);
}
return *this;
}
ostream& ostream::operator<<(unsigned long n)
{
- if (opfx())
+ if (opfx()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
write_int(*this, n, 0);
+ _IO_cleanup_region_end (0);
+ }
return *this;
}
@@ -533,11 +565,14 @@ ostream& ostream::operator<<(unsigned long n)
ostream& ostream::operator<<(long long n)
{
if (opfx()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
int sign = 1;
unsigned long long abs_n = (unsigned long long)n;
if (n < 0 && (flags() & (ios::oct|ios::hex)) == 0)
abs_n = -((unsigned long long)n), sign = -1;
write_int(*this, abs_n, sign);
+ _IO_cleanup_region_end (0);
}
return *this;
}
@@ -545,8 +580,12 @@ ostream& ostream::operator<<(long long n)
ostream& ostream::operator<<(unsigned long long n)
{
- if (opfx())
+ if (opfx()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
write_int(*this, n, 0);
+ _IO_cleanup_region_end (0);
+ }
return *this;
}
#endif /*__GNUC__*/
@@ -554,6 +593,8 @@ ostream& ostream::operator<<(unsigned long long n)
ostream& ostream::operator<<(double n)
{
if (opfx()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
// Uses __cvt_double (renamed from static cvt), in Chris Torek's
// stdio implementation. The setup code uses the same logic
// as in __vsbprintf.C (also based on Torek's code).
@@ -570,7 +611,26 @@ ostream& ostream::operator<<(double n)
prec = 6; /* default */
// Do actual conversion.
-#ifdef _IO_USE_DTOA
+#ifdef _G_HAVE_PRINTF_FP
+ {
+ struct printf_info info = { prec: prec,
+ width: width(0),
+ spec: format_char,
+ is_long_double: 0,
+ is_short: 0,
+ is_long: 0,
+ alt: flags() & ios::showpoint,
+ space: 0,
+ left: ios::left,
+ showsign: flags() & ios::showpos,
+ group: 0,
+ pad: fill(),
+ extra: 0};
+ const void *ptr = &n;
+ if (__printf_fp (rdbuf(), &info, &ptr) < 0)
+ set(ios::badbit|ios::failbit);
+ }
+#elif defined _IO_USE_DTOA
if (_IO_outfloat(n, rdbuf(), format_char, width(0),
prec, flags(),
flags() & ios::showpos ? '+' : 0,
@@ -618,7 +678,7 @@ ostream& ostream::operator<<(double n)
sbuf->sputc(sign);
if (pad_kind == (ios::fmtflags)ios::internal)
for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
-
+
// Emit the actual concented field, followed by extra zeros.
_IO_sputn (sbuf, cp, size);
for (i = fpprec; --i >= 0; ) sbuf->sputc('0');
@@ -627,14 +687,66 @@ ostream& ostream::operator<<(double n)
for (i = padding; --i >= 0; ) sbuf->sputc(fill_char);
#endif
osfx();
+ _IO_cleanup_region_end (0);
}
return *this;
}
+#if _G_HAVE_LONG_DOUBLE_IO
+ostream& ostream::operator<<(long double n)
+{
+ if (opfx())
+ {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
+ 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 */
+
+#ifdef _G_HAVE_PRINTF_FP
+ // Do actual conversion.
+ struct printf_info info = { prec: prec,
+ width: width(0),
+ spec: format_char,
+ is_long_double: 1,
+ is_short: 0,
+ is_long: 0,
+ alt: flags() & ios::showpoint,
+ space: 0,
+ left: ios::left,
+ showsign: flags() & ios::showpos,
+ group: 0,
+ pad: fill(),
+ extra: 0};
+
+ const void *ptr = &n;
+
+ if (__printf_fp (rdbuf(), &info, &ptr) < 0)
+ set (ios::badbit|ios::failbit);
+#else
+# error "long double I/O using dtoa or cvt_double is not implemented"
+#endif
+ osfx();
+ _IO_cleanup_region_end (0);
+ }
+ return *this;
+}
+#endif
+
ostream& ostream::operator<<(const char *s)
{
if (opfx())
{
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
if (s == NULL)
s = "(null)";
int len = strlen(s);
@@ -645,19 +757,23 @@ ostream& ostream::operator<<(const char *s)
register int padding = w > len ? w - len : 0;
if (!(flags() & ios::left) && padding > 0) // Default adjustment.
if (_IO_padn(sbuf, fill_char, padding) != padding)
- goto failed;
+ {
+ set(ios::badbit);
+ goto failed;
+ }
if (_IO_sputn (sbuf, s, len) != len)
- goto failed;
+ {
+ set(ios::badbit);
+ goto failed;
+ }
if (flags() & ios::left && padding > 0) // Left adjustment.
if (_IO_padn(sbuf, fill_char, padding) != padding)
- goto failed;
+ set(ios::badbit);
osfx();
+ failed:
+ _IO_cleanup_region_end (0);
}
return *this;
- failed:
- set(ios::badbit);
- osfx();
- return *this;
}
#if 0
@@ -669,6 +785,8 @@ ostream& ostream::operator<<(register streambuf* sbuf)
{
if (opfx())
{
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
char buffer[_IO_BUFSIZ];
register streambuf* outbuf = _strbuf;
for (;;)
@@ -683,6 +801,7 @@ ostream& ostream::operator<<(register streambuf* sbuf)
}
}
osfx();
+ _IO_cleanup_region_end (0);
}
return *this;
}
@@ -735,11 +854,15 @@ ostream& flush(ostream& outs)
istream& ws(istream& ins)
{
if (ins.ipfx1()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ ins._strbuf);
int ch = skip_ws(ins._strbuf);
if (ch == EOF)
ins.set(ios::eofbit);
else
ins._strbuf->sputbackc(ch);
+ ins.isfx();
+ _IO_cleanup_region_end (0);
}
return ins;
}
@@ -772,11 +895,37 @@ ostream& endl(ostream& outs)
return flush(outs.put('\n'));
}
+istream& lock(istream& ins)
+{
+ _IO_flockfile (ins._strbuf);
+ return ins;
+}
+istream& unlock(istream& ins)
+{
+ _IO_funlockfile (ins._strbuf);
+ return ins;
+}
+ostream& lock(ostream& outs)
+{
+ _IO_flockfile (outs._strbuf);
+ return outs;
+}
+ostream& unlock(ostream& outs)
+{
+ _IO_funlockfile (outs._strbuf);
+ return outs;
+}
+
+
ostream& ostream::write(const char *s, streamsize n)
{
if (opfx()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
if (_IO_sputn(_strbuf, s, n) != n)
set(ios::failbit);
+ osfx();
+ _IO_cleanup_region_end (0);
}
return *this;
}
diff --git a/libio/iostream.h b/libio/iostream.h
index a6ede43..f3de363 100644
--- a/libio/iostream.h
+++ b/libio/iostream.h
@@ -49,8 +49,10 @@ class ostream : virtual public ios
ostream() { }
ostream(streambuf* sb, ostream* tied=NULL);
int opfx() {
- if (!good()) return 0; else { if (_tie) _tie->flush(); return 1;} }
- void osfx() { if (flags() & (ios::unitbuf|ios::stdio))
+ if (!good()) return 0;
+ else { if (_tie) _tie->flush(); _IO_flockfile(_strbuf); return 1;} }
+ void osfx() { _IO_funlockfile(_strbuf);
+ if (flags() & (ios::unitbuf|ios::stdio))
do_osfx(); }
ostream& flush();
ostream& put(char c) { _strbuf->sputc(c); return *this; }
@@ -144,6 +146,7 @@ protected:
int ipfx(int need = 0) {
if (!good()) { set(ios::failbit); return 0; }
else {
+ _IO_flockfile(_strbuf);
if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush();
if (!need && (flags() & ios::skipws)) return _skip_ws();
else return 1;
@@ -152,6 +155,7 @@ protected:
int ipfx0() { // Optimized version of ipfx(0).
if (!good()) { set(ios::failbit); return 0; }
else {
+ _IO_flockfile(_strbuf);
if (_tie) _tie->flush();
if (flags() & ios::skipws) return _skip_ws();
else return 1;
@@ -160,11 +164,12 @@ protected:
int ipfx1() { // Optimized version of ipfx(1).
if (!good()) { set(ios::failbit); return 0; }
else {
+ _IO_flockfile(_strbuf);
if (_tie && rdbuf()->in_avail() == 0) _tie->flush();
return 1;
}
}
- void isfx() { }
+ void isfx() { _IO_funlockfile(_strbuf); }
int get() { if (!ipfx1()) return EOF;
else { int ch = _strbuf->sbumpc();
if (ch == EOF) set(ios::eofbit);
@@ -249,6 +254,11 @@ __asm__ ("__IO_clog")
#endif
;
+extern istream& lock(istream& ins);
+extern istream& unlock(istream& ins);
+extern ostream& lock(ostream& outs);
+extern ostream& unlock(ostream& outs);
+
struct Iostream_init { } ; // Compatibility hack for AT&T library.
inline ios& dec(ios& i)
diff --git a/libio/iostrerror.c b/libio/iostrerror.c
index 65aa25d..348e095 100644
--- a/libio/iostrerror.c
+++ b/libio/iostrerror.c
@@ -5,8 +5,8 @@
extern char *strerror __P ((int));
char *
-DEFUN(_IO_strerror, (errnum),
- int errnum)
+_IO_strerror (errnum)
+ int errnum;
{
return strerror(errnum);
}
diff --git a/libio/iovfprintf.c b/libio/iovfprintf.c
index c41cbbf..755334c 100644
--- a/libio/iovfprintf.c
+++ b/libio/iovfprintf.c
@@ -84,8 +84,9 @@ struct helper_file
};
static int
-DEFUN(_IO_helper_overflow, (fp, c),
- _IO_FILE *fp AND int c)
+_IO_helper_overflow (fp, c)
+ _IO_FILE *fp;
+ int c;
{
_IO_FILE *target = ((struct helper_file*)fp)->_put_stream;
int used = fp->_IO_write_ptr - fp->_IO_write_base;
@@ -119,8 +120,10 @@ static struct _IO_jump_t _IO_helper_jumps = {
};
static int
-DEFUN(helper_vfprintf, (fp, fmt0, ap),
- register _IO_FILE* fp AND char const *fmt0 AND _IO_va_list ap)
+helper_vfprintf (fp, fmt0, ap)
+ _IO_FILE *fp;
+ char const *fmt0;
+ _IO_va_list ap;
{
char buf[_IO_BUFSIZ];
struct helper_file helper;
@@ -180,8 +183,10 @@ extern double modf __P((double, double*));
#define HEXPREFIX 0x40 /* add 0x or 0X prefix */
int
-DEFUN(_IO_vfprintf, (fp, fmt0, ap),
- register _IO_FILE* fp AND char const *fmt0 AND _IO_va_list ap)
+_IO_vfprintf (fp, fmt0, ap)
+ _IO_FILE *fp;
+ char const *fmt0;
+ _IO_va_list ap;
{
register const char *fmt; /* format string */
register int ch; /* character from fmt */
diff --git a/libio/iovfscanf.c b/libio/iovfscanf.c
index 1220e07..0631458 100644
--- a/libio/iovfscanf.c
+++ b/libio/iovfscanf.c
@@ -119,9 +119,11 @@ extern double atof();
*errp|=2 if we an invalid character. */
int
-DEFUN(_IO_vfscanf, (fp, fmt0, ap, errp),
- register _IO_FILE *fp AND char const *fmt0
- AND _IO_va_list ap AND int *errp)
+_IO_vfscanf (fp, fmt0, ap, errp)
+ _IO_FILE *fp;
+ char const *fmt0;
+ _IO_va_list ap;
+ int *errp;
{
register const u_char *fmt = (const u_char *)fmt0;
register int c; /* character from format, or conversion */
@@ -696,8 +698,9 @@ done:
* considered part of the scanset.
*/
static const u_char *
-DEFUN(__sccl, (tab, fmt),
- register char *tab AND register const u_char *fmt)
+__sccl (tab, fmt)
+ char *tab;
+ const u_char *fmt;
{
register int c, n, v;
diff --git a/libio/libio.h b/libio/libio.h
index 132a107..10fcfed 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -1,28 +1,28 @@
-/*
-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
@@ -42,60 +42,56 @@ the executable file might be covered by the GNU General Public License. */
#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 +105,7 @@ the executable file might be covered by the GNU General Public License. */
/* 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 +126,7 @@ the executable file might be covered by the GNU General Public License. */
#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 +145,21 @@ the executable file might be covered by the GNU General Public License. */
#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. */
#ifdef _IO_MTSAFE_IO
-# include <stdio-lock.h>
+# include <bits/stdio-lock.h>
#else
typedef void _IO_lock_t;
#endif
+/* A streammarker remembers a position in a buffer. */
+
struct _IO_marker {
struct _IO_marker *_next;
struct _IO_FILE *_sbuf;
@@ -181,11 +180,7 @@ struct _IO_marker {
};
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. */
@@ -256,22 +251,22 @@ struct _IO_cookie_file
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_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)
#define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)
@@ -301,15 +296,15 @@ extern int _IO_ftrylockfile __P ((_IO_FILE *));
#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
}
diff --git a/libio/libioP.h b/libio/libioP.h
index ea3f36e..8ea67de 100644
--- a/libio/libioP.h
+++ b/libio/libioP.h
@@ -24,36 +24,16 @@
General Public License. */
#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-#ifndef __set_errno
-/* This is a GNU libc special. Simply set errno to the given value here. */
+/* This is a hack until Uli gets me the real fix. */
#define __set_errno(Val) (errno = (Val))
+#if defined __GLIBC__ && __GLIBC__ >= 2
+# include <bits/libc-lock.h>
+#else
+/*# include <comthread.h>*/
#endif
-#include <stdio-lock.h>
#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
@@ -71,11 +51,11 @@ extern "C" {
* 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,107 +63,108 @@ extern "C" {
* 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.
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 */
-#define _IO_FINISH(FP) JUMP1(__finish, FP, 0)
+typedef void (*_IO_finish_t) __P ((_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));
-#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 +176,44 @@ typedef int (*_IO_doallocate_t) __P((_IO_FILE*));
/* 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,63 +247,69 @@ struct _IO_jump_t {
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;
};
/* Generic functions */
-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 int _IO_switch_to_get_mode __P((_IO_FILE*));
-extern void _IO_init __P((_IO_FILE*, int));
-extern int _IO_sputbackc __P((_IO_FILE*, int));
-extern int _IO_sungetc __P((_IO_FILE*));
-extern void _IO_un_link __P((_IO_FILE*));
-extern void _IO_link_in __P((_IO_FILE *));
-extern void _IO_doallocbuf __P((_IO_FILE*));
-extern void _IO_unsave_markers __P((_IO_FILE*));
-extern void _IO_setb __P((_IO_FILE*, char*, char*, int));
-extern unsigned _IO_adjust_column __P((unsigned, const char *, int));
-#define _IO_sputn(__fp, __s, __n) _IO_XSPUTN(__fp, __s, __n)
+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_switch_to_main_get_area __P ((_IO_FILE *));
+extern void _IO_switch_to_backup_area __P ((_IO_FILE *));
+extern int _IO_switch_to_get_mode __P ((_IO_FILE *));
+extern void _IO_init __P ((_IO_FILE *, int));
+extern int _IO_sputbackc __P ((_IO_FILE *, int));
+extern int _IO_sungetc __P ((_IO_FILE *));
+extern void _IO_un_link __P ((_IO_FILE *));
+extern void _IO_link_in __P ((_IO_FILE *));
+extern void _IO_doallocbuf __P ((_IO_FILE *));
+extern void _IO_unsave_markers __P ((_IO_FILE *));
+extern void _IO_setb __P ((_IO_FILE *, char *, char *, int));
+extern unsigned _IO_adjust_column __P ((unsigned, const char *, int));
+#define _IO_sputn(__fp, __s, __n) _IO_XSPUTN (__fp, __s, __n)
/* 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. */
-extern int _IO_default_underflow __P((_IO_FILE*));
-extern int _IO_default_uflow __P((_IO_FILE*));
-extern int _IO_default_doallocate __P((_IO_FILE*));
-extern void _IO_default_finish __P((_IO_FILE *, int));
-extern int _IO_default_pbackfail __P((_IO_FILE*, int));
-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));
-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));
-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*));
-extern _IO_fpos_t _IO_default_seek __P((_IO_FILE*, _IO_off_t, int));
-extern int _IO_default_sync __P((_IO_FILE*));
-#define _IO_default_close ((_IO_close_t)_IO_default_sync)
+extern int _IO_default_underflow __P ((_IO_FILE *));
+extern int _IO_default_uflow __P ((_IO_FILE *));
+extern int _IO_default_doallocate __P ((_IO_FILE *));
+extern void _IO_default_finish __P ((_IO_FILE *, int));
+extern int _IO_default_pbackfail __P ((_IO_FILE *, int));
+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));
+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));
+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 *));
+extern _IO_fpos_t _IO_default_seek __P ((_IO_FILE *, _IO_off_t, int));
+extern int _IO_default_sync __P ((_IO_FILE *));
+#define _IO_default_close ((_IO_close_t) _IO_default_sync)
extern struct _IO_jump_t _IO_file_jumps;
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,42 +328,41 @@ extern void _IO_flush_all_linebuffered __P((void));
/* 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*));
-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));
-
-/* Other file functions. */
-extern _IO_FILE* _IO_file_attach __P((_IO_FILE *, int));
+extern void _IO_file_init __P ((_IO_FILE *));
+extern _IO_FILE* _IO_file_attach __P ((_IO_FILE *, int));
+extern _IO_FILE* _IO_file_fopen __P ((_IO_FILE *, const char *, const char *));
+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. */
-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*));
-extern int _IO_str_overflow __P((_IO_FILE *, int));
-extern int _IO_str_pbackfail __P((_IO_FILE*, int));
-extern _IO_fpos_t _IO_str_seekoff __P((_IO_FILE*,_IO_off_t,int,int));
-extern void _IO_str_finish __P ((_IO_FILE*, int));
+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));
+extern _IO_fpos_t _IO_str_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
+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));
@@ -384,89 +371,97 @@ extern int _IO_vsnprintf __P ((char *string, _IO_size_t maxlen,
__const char *format, _IO_va_list args));
-extern _IO_size_t _IO_getline __P((_IO_FILE*,char*,_IO_size_t,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,
- int *__decpt, int *__sign, char **__rve));
-extern int _IO_outfloat __P((double __value, _IO_FILE *__sb, int __type,
- int __width, int __precision, int __flags,
- int __sign_mode, int __fill));
+extern _IO_size_t _IO_getline __P ((_IO_FILE *,char *, _IO_size_t, 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,
+ int *__decpt, int *__sign, char **__rve));
+extern int _IO_outfloat __P ((double __value, _IO_FILE *__sb, int __type,
+ int __width, int __precision, int __flags,
+ int __sign_mode, int __fill));
extern _IO_FILE *_IO_list_all;
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
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <sys/param.h>
+# include <unistd.h>
+# include <fcntl.h>
+# include <sys/mman.h>
+# include <sys/param.h>
-#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
-#define MAP_ANONYMOUS MAP_ANON
-#endif
+# if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
+# define MAP_ANONYMOUS MAP_ANON
+# endif
-#if !defined(MAP_ANONYMOUS) || !defined(EXEC_PAGESIZE)
-#undef _G_HAVE_MMAP
-#define _G_HAVE_MMAP 0
-#endif
+# if !defined(MAP_ANONYMOUS) || !defined(EXEC_PAGESIZE)
+# undef _G_HAVE_MMAP
+# define _G_HAVE_MMAP 0
+# endif
#endif /* _G_HAVE_MMAP */
#if _G_HAVE_MMAP
-#define ROUND_TO_PAGE(_S) \
+# ifdef _LIBC
+/* When using this code in the GNU libc we must not pollute the name space. */
+# define mmap __mmap
+# define munmap __munmap
+# endif
+
+# define ROUND_TO_PAGE(_S) \
(((_S) + EXEC_PAGESIZE - 1) & ~(EXEC_PAGESIZE - 1))
-#define FREE_BUF(_B, _S) \
+# define FREE_BUF(_B, _S) \
munmap ((_B), ROUND_TO_PAGE (_S))
-#define ALLOC_BUF(_B, _S, _R) \
+# define ALLOC_BUF(_B, _S, _R) \
do { \
- (_B) = (char *) mmap (0, ROUND_TO_PAGE (_S), \
- PROT_READ | PROT_WRITE, \
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \
- if ((_B) == (char *) -1) \
- return _R; \
+ (_B) = (char *) mmap (0, ROUND_TO_PAGE (_S), \
+ PROT_READ | PROT_WRITE, \
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \
+ if ((_B) == (char *) -1) \
+ return (_R); \
} while (0)
#else /* _G_HAVE_MMAP */
-#define FREE_BUF(_B, _S) \
+# define FREE_BUF(_B, _S) \
free(_B)
-#define ALLOC_BUF(_B, _S, _R) \
+# define ALLOC_BUF(_B, _S, _R) \
do { \
- (_B) = (char*)malloc(_S); \
- if ((_B) == NULL) \
- return _R; \
+ (_B) = (char*)malloc(_S); \
+ if ((_B) == NULL) \
+ return (_R); \
} while (0)
#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,19 +470,19 @@ extern int _IO_fstat __P((int, struct stat *));
/* _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
@@ -496,71 +491,70 @@ extern int _IO_fstat __P((int, struct stat *));
#ifdef _IO_MTSAFE_IO
/* check following! */
-#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, \
- 0, 0, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock }
+# 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, \
+ 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}
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, FD }
#endif
/* 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)
+# define MAYBE_SET_EINVAL __set_errno (EINVAL)
#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
diff --git a/libio/osform.cc b/libio/osform.cc
index 8c00117..f08f2ef 100644
--- a/libio/osform.cc
+++ b/libio/osform.cc
@@ -29,26 +29,38 @@ the executable file might be covered by the GNU General Public License. */
ostream& ostream::form(const char *format ...)
{
if (opfx()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
va_list ap;
va_start(ap, format);
_IO_vfprintf(rdbuf(), format, ap);
va_end(ap);
+ osfx();
+ _IO_cleanup_region_end (0);
}
return *this;
}
ostream& ostream::vform(const char *format, _IO_va_list args)
{
- if (opfx())
+ if (opfx()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
_IO_vfprintf(rdbuf(), format, args);
+ osfx();
+ _IO_cleanup_region_end (0);
+ }
return *this;
}
ostream& ostream::operator<<(const void *p)
{
if (opfx()) {
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _strbuf);
form("%p", p);
osfx();
+ _IO_cleanup_region_end (0);
}
return *this;
}
diff --git a/libio/outfloat.c b/libio/outfloat.c
index a74b1a2..5cbb6c9 100644
--- a/libio/outfloat.c
+++ b/libio/outfloat.c
@@ -24,6 +24,7 @@ the executable file might be covered by the GNU General Public License. */
#include "libioP.h"
+#ifdef _IO_USE_DTOA
/* Format floating-point number and print them.
Return number of chars printed, or EOF on error.
@@ -33,10 +34,15 @@ the executable file might be covered by the GNU General Public License. */
*/
int
-DEFUN(_IO_outfloat, (value, sb, type, width, precision, flags,
- sign_mode, fill),
- double value AND _IO_FILE *sb AND int type AND int width
- AND int precision AND int flags AND int sign_mode AND int fill)
+_IO_outfloat (value, sb, type, width, precision, flags, sign_mode, fill)
+ double value;
+ _IO_FILE *sb;
+ int type;
+ int width;
+ int precision;
+ int flags;
+ int sign_mode;
+ int fill;
{
int count = 0;
#define PUT(x) do {if (_IO_putc(x, sb) < 0) goto error; count++;} while (0)
@@ -202,3 +208,4 @@ DEFUN(_IO_outfloat, (value, sb, type, width, precision, flags,
error:
return EOF;
}
+#endif
diff --git a/libio/stdio-lock.h b/libio/stdio-lock.h
deleted file mode 100644
index 42dc218..0000000
--- a/libio/stdio-lock.h
+++ /dev/null
@@ -1 +0,0 @@
-/* this will be used later*/
diff --git a/libio/stdio/ChangeLog b/libio/stdio/ChangeLog
index 788c055..f98baec 100644
--- a/libio/stdio/ChangeLog
+++ b/libio/stdio/ChangeLog
@@ -65,7 +65,7 @@ Wed May 10 03:05:53 1995 Jason Merrill <jason@python.cygnus.com>
Tue Oct 18 17:15:09 1994 Per Bothner <bothner@kalessin.cygnus.com>
* getline.c, snprintf.c, vsnprintf.c: New files, providing
- functionality of the GNU C C library.
+ functionality of the GNU C library.
* Makefile.in (STDIO_OBJECTS), configure.in: Add new files.
* stdio.h: Add new functions.
@@ -131,4 +131,3 @@ Fri Aug 20 00:28:28 1993 Per Bothner (bothner@kalessin.cygnus.com)
* configure.in (stdio_renamed): Removed feof.
Added sprintf sscanf vsscanf.
* ChangeLog.old: Copy of old libg++/iostream/stdio/ChangeLog.
-
diff --git a/libio/stdio/feof.c b/libio/stdio/feof.c
index bd30c17..d06de044 100644
--- a/libio/stdio/feof.c
+++ b/libio/stdio/feof.c
@@ -1,34 +1,43 @@
-/*
-Copyright (C) 1993 Free Software Foundation
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
-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 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.
+ 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.
+ 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. */
+ 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 "stdio.h"
int
-feof(fp)
+_IO_feof (fp)
_IO_FILE* fp;
{
- CHECK_FILE(fp, EOF);
- return _IO_feof(fp);
+ int result;
+ CHECK_FILE (fp, EOF);
+ _IO_flockfile (fp);
+ result = _IO_feof_unlocked (fp);
+ _IO_funlockfile (fp);
+ return result;
}
+
+#ifdef weak_alias
+weak_alias (_IO_feof, feof)
+#endif
diff --git a/libio/stdio/ferror.c b/libio/stdio/ferror.c
index ef95d7c..855627a 100644
--- a/libio/stdio/ferror.c
+++ b/libio/stdio/ferror.c
@@ -1,10 +1,43 @@
+/* Copyright (C) 1993, 1995, 1996, 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 "stdio.h"
int
-ferror(fp)
- FILE* fp;
+_IO_ferror (fp)
+ _IO_FILE* fp;
{
- CHECK_FILE(fp, EOF);
- return _IO_ferror(fp);
+ int result;
+ CHECK_FILE (fp, EOF);
+ _IO_flockfile (fp);
+ result = _IO_ferror_unlocked (fp);
+ _IO_funlockfile (fp);
+ return result;
}
+
+#ifdef weak_alias
+weak_alias (_IO_ferror, ferror)
+#endif
diff --git a/libio/stdio/getc.c b/libio/stdio/getc.c
index 9db0987..1dc53b5 100644
--- a/libio/stdio/getc.c
+++ b/libio/stdio/getc.c
@@ -1,11 +1,48 @@
+/* Copyright (C) 1993, 1995, 1996, 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 "stdio.h"
-#undef getc
+#undef _IO_getc
int
-getc(stream)
- FILE *stream;
+_IO_getc (fp)
+ FILE *fp;
{
- return _IO_getc (stream);
+ int result;
+ CHECK_FILE (fp, EOF);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_flockfile (fp);
+ result = _IO_getc_unlocked (fp);
+ _IO_cleanup_region_end (1);
+ return result;
}
+
+#undef getc
+
+#ifdef weak_alias
+weak_alias (_IO_getc, getc)
+#endif
diff --git a/libio/stdio/putc.c b/libio/stdio/putc.c
index 2a3dcc3..3c35c36 100644
--- a/libio/stdio/putc.c
+++ b/libio/stdio/putc.c
@@ -1,12 +1,42 @@
+/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
#include "libioP.h"
#include "stdio.h"
-#undef putc
+#undef _IO_putc
int
-putc(c, stream)
+_IO_putc (c, fp)
int c;
- FILE *stream;
+ _IO_FILE *fp;
{
- return _IO_putc(c, stream);
+ int result;
+ CHECK_FILE (fp, EOF);
+ _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+ _IO_flockfile (fp);
+ result = _IO_putc_unlocked (c, fp);
+ _IO_cleanup_region_end (1);
+ return result;
}
+
+#undef putc
+
+#ifdef weak_alias
+weak_alias (_IO_putc, putc)
+#endif
diff --git a/libio/stdio/putchar.c b/libio/stdio/putchar.c
index f97af04..1e1dd13 100644
--- a/libio/stdio/putchar.c
+++ b/libio/stdio/putchar.c
@@ -27,7 +27,7 @@ putchar (c)
{
int result;
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
- _IO_stdout);
+ _IO_stdout);
_IO_flockfile (_IO_stdout);
result = _IO_putc_unlocked (c, _IO_stdout);
_IO_cleanup_region_end (1);
diff --git a/libio/stdio/stdio.h b/libio/stdio/stdio.h
index d1c4130..30065ac 100644
--- a/libio/stdio/stdio.h
+++ b/libio/stdio/stdio.h
@@ -169,10 +169,48 @@ extern int vsnprintf __P ((char *, size_t, const char *, _IO_va_list));
extern int __underflow __P((struct _IO_FILE*));
extern int __overflow __P((struct _IO_FILE*, int));
+/* Handle locking of streams. */
+#if defined _REENTRANT || defined _THREAD_SAFE
+extern void clearerr_locked __P ((FILE *));
+extern void clearerr_unlocked __P ((FILE *));
+extern int feof_locked __P ((FILE *));
+extern int feof_unlocked __P ((FILE *));
+extern int ferror_locked __P ((FILE*));
+extern int ferror_unlocked __P ((FILE*));
+extern int fileno_locked __P ((FILE *));
+extern int fileno_unlocked __P ((FILE *));
+extern void flockfile __P ((FILE *));
+extern void funlockfile __P ((FILE *));
+extern int ftrylockfile __P ((FILE *));
+extern int fclose_unlocked __P ((FILE *));
+extern int fflush_locked __P ((FILE *));
+extern int fflush_unlocked __P ((FILE *));
+extern size_t fread_unlocked __P ((void *, size_t, size_t, FILE *));
+extern size_t fwrite_unlocked __P ((const void *, size_t, size_t, FILE *));
+
+extern int fputc_locked __P ((int, FILE*));
+extern int fputc_unlocked __P ((int, FILE*));
+extern int getc_locked __P ((FILE *));
+extern int getc_unlocked __P ((FILE *));
+extern int getchar_locked __P ((void));
+extern int getchar_unlocked __P ((void));
+extern int putc_locked __P ((int, FILE *));
+extern int putc_unlocked __P ((int, FILE *));
+extern int putchar_locked __P ((int));
+extern int putchar_unlocked __P ((int));
+
+# define getc_unlocked(fp) _IO_getc_unlocked (fp)
+# define getc_locked(fp) _IO_getc (fp)
+# define getchar_unlocked() _IO_getc_unlocked (stdin)
+# define getchar_locked() _IO_getc (stdin)
+# define putchar_unlocked(c) _IO_putc_unlocked (c, stdout)
+# define putchar_locked(c) _IO_putc (c, stdout)
+#endif /* __USE_REENTRANT */
+
#define getc(fp) _IO_getc(fp)
#define putc(c, fp) _IO_putc(c, fp)
-#define putchar(c) putc(c, stdout)
-#define getchar() getc(stdin)
+#define putchar(c) _IO_putc(c, stdout)
+#define getchar() _IO_getc(stdin)
#ifdef __cplusplus
}
diff --git a/libio/stdstrbufs.cc b/libio/stdstrbufs.cc
index 8af2599..3f8102f 100644
--- a/libio/stdstrbufs.cc
+++ b/libio/stdstrbufs.cc
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (C) 1994 Free Software Foundation
This file is part of the GNU IO Library. This library is free
@@ -54,8 +54,15 @@ extern char filebuf_vtable[];
#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);
@@ -95,17 +102,21 @@ extern struct _IO_jump_t stdiobuf_vtable;
#endif /* !__GNUC__ */
#endif /* !stdiobuf_vtable */
-#if _IO_UNIFIED_JUMPTABLES
-#define JUMP_PTR /* Nothing */
+#ifdef _IO_MTSAFE_IO
+#define DEF_STDIOFILE(NAME, FD, FILE, FLAGS, CHAIN) \
+ static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
+ struct _IO_fake_stdiobuf NAME = \
+ {{{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+_IO_UNBUFFERED+FLAGS, \
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, FD, \
+ 0, 0, 0, 0, { 0 }, _IO_stdfile_##FD##_lock},\
+ &stdiobuf_vtable}, FILE}
#else
-#define JUMP_PTR &_IO_streambuf_jumps,
-#endif
-
#define DEF_STDIOFILE(NAME, FD, FILE, FLAGS, CHAIN) \
struct _IO_fake_stdiobuf NAME = \
{{{ _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+_IO_UNBUFFERED+FLAGS, \
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, JUMP_PTR FD},\
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, FD}, \
&stdiobuf_vtable}, FILE}
+#endif
DEF_STDIOFILE(_IO_stdin_buf, 0, stdin, _IO_NO_WRITES, &_IO_stderr_.file);
DEF_STDIOFILE(_IO_stdout_buf, 1, stdout, _IO_NO_READS, &_IO_stdin_buf.s.file);
diff --git a/libio/streambuf.cc b/libio/streambuf.cc
index 8f7908b..e87590f 100644
--- a/libio/streambuf.cc
+++ b/libio/streambuf.cc
@@ -162,7 +162,7 @@ static _IO_pos_t _IO_sb_seekpos(_IO_FILE *fp, _IO_pos_t pos, int mode)
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 @@ struct _IO_jump_t _IO_streambuf_jumps = {
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*/)
diff --git a/libio/strops.c b/libio/strops.c
index a9f812e..f7c2262 100644
--- a/libio/strops.c
+++ b/libio/strops.c
@@ -200,8 +200,8 @@ _IO_ssize_t
_IO_str_count (fp)
_IO_FILE *fp;
{
- return ((fp->_IO_write_ptr > fp->_IO_read_end
- ? fp->_IO_write_ptr : fp->_IO_read_end)
+ return ((fp->_IO_write_end > fp->_IO_read_end
+ ? fp->_IO_write_end : fp->_IO_read_end)
- fp->_IO_read_base);
}
diff --git a/libio/tests/tFile.cc b/libio/tests/tFile.cc
index d8a1ee3..df82104 100644
--- a/libio/tests/tFile.cc
+++ b/libio/tests/tFile.cc
@@ -43,6 +43,8 @@ the executable file might be covered by the GNU General Public License. */
#include <string.h>
#include <assert.h>
+const char *tempfile;
+
class record
{
public:
@@ -160,9 +162,9 @@ void t4()
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 @@ void t4()
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 @@ void t4()
tf << s;
assert(tf.good());
tf.close();
- tf.open("tempfile", ios::in);
+ tf.open(tempfile, ios::in);
#endif
tf.raw();
assert(tf.good());
@@ -512,6 +514,8 @@ t12 ()
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 @@ main(int argc, char **argv)
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();