Commit e693cc28 by Ulrich Drepper Committed by Jeff Law

Uli's libio/libstdc++ patches.

From-SVN: r15486
parent 610ce97e
1997-09-15 02:37 Ulrich Drepper <drepper@cygnus.com>
* config/mt-linux: Define CXXFLAGS to make sure -fvtable-thunks is
used.
* configure.in: Name Linux target fragment.
* configure: Rewrite so that project Makefile fragment is inserted
first and appears last in the resulting Makefile.
Thu Sep 11 16:40:46 1997 H.J. Lu (hjl@gnu.ai.mit.edu)
* Makefile.in (local-distclean): Also remove mh-frag mt-frag.
......
......@@ -81,7 +81,7 @@ subdirs=
target_alias=NOTARGET
target_makefile_frag=
undefs=NOUNDEFS
version="$Revision: 1.244 $"
version="$Revision: 1.1.1.1 $"
x11=default
### we might need to use some other shell than /bin/sh for running subshells
......@@ -1045,78 +1045,77 @@ EOF
if [ -f ${srcdir}/${subdir}/${Makefile_in} ] ; then
# Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
rm -f ${subdir}/Makefile.tem
case "${site}" in
# Conditionalize the makefile for this package from "Makefile.in" (or whatever it's called) into Makefile.tem.
rm -f ${subdir}/${Makefile}.tem
case "${package_makefile_frag}" in
"") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
*)
if [ ! -f ${package_makefile_frag} ] ; then
package_makefile_frag=${srcdir}/${package_makefile_frag}
fi
if [ -f ${package_makefile_frag} ] ; then
sed -e "/^####/ r ${package_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} > ${Makefile}.tem
else
echo '***' Expected package makefile fragment \"${package_makefile_frag}\" 1>&2
echo '***' is missing in ${PWD=`pwd`}. 1>&2
cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
fi
esac
# working copy now in ${Makefile}.tem
# Conditionalize for this site.
rm -f ${Makefile}
case "${site}" in
"") mv ${subdir}/Makefile.tem ${Makefile} ;;
*)
site_makefile_frag=${srcdir}/config/ms-${site}
if [ -f ${site_makefile_frag} ] ; then
sed -e "/^####/ r ${site_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} \
> ${subdir}/Makefile.tem
sed -e "/^####/ r ${site_makefile_frag}" ${subdir}/Makefile.tem \
> ${Makefile}
else
cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
mv ${subdir}/Makefile.tem ${Makefile}
site_makefile_frag=
fi
;;
esac
# working copy now in ${subdir}/Makefile.tem
# working copy now in ${Makefile}
# Conditionalize the makefile for this host.
rm -f ${Makefile}
rm -f ${subdir}/Makefile.tem
case "${host_makefile_frag}" in
"") mv ${subdir}/Makefile.tem ${Makefile} ;;
"") mv ${Makefile} ${subdir}/Makefile.tem ;;
*)
if [ ! -f ${host_makefile_frag} ] ; then
host_makefile_frag=${srcdir}/${host_makefile_frag}
fi
if [ -f ${host_makefile_frag} ] ; then
sed -e "/^####/ r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
sed -e "/^####/ r ${host_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
else
echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
echo '***' is missing in ${PWD=`pwd`}. 1>&2
mv ${subdir}/Makefile.tem ${Makefile}
mv ${Makefile} ${subdir}/Makefile.tem
fi
esac
# working copy now in ${Makefile}
# working copy now in ${subdir)/Makefile.tem
# Conditionalize the makefile for this target.
rm -f ${subdir}/Makefile.tem
rm -f ${Makefile}
case "${target_makefile_frag}" in
"") mv ${Makefile} ${subdir}/Makefile.tem ;;
"") mv ${subdir}/Makefile.tem ${Makefile} ;;
*)
if [ ! -f ${target_makefile_frag} ] ; then
target_makefile_frag=${srcdir}/${target_makefile_frag}
fi
if [ -f ${target_makefile_frag} ] ; then
sed -e "/^####/ r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
sed -e "/^####/ r ${target_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
else
mv ${Makefile} ${subdir}/Makefile.tem
mv ${subdir}/Makefile.tem ${Makefile}
target_makefile_frag=
fi
;;
esac
# real copy now in ${subdir}/Makefile.tem
# Conditionalize the makefile for this package.
rm -f ${Makefile}
case "${package_makefile_frag}" in
"") mv ${subdir}/Makefile.tem ${Makefile} ;;
*)
if [ ! -f ${package_makefile_frag} ] ; then
package_makefile_frag=${srcdir}/${package_makefile_frag}
fi
if [ -f ${package_makefile_frag} ] ; then
sed -e "/^####/ r ${package_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
rm -f ${subdir}/Makefile.tem
else
echo '***' Expected package makefile fragment \"${package_makefile_frag}\" 1>&2
echo '***' is missing in ${PWD=`pwd`}. 1>&2
mv ${subdir}/Makefile.tem ${Makefile}
fi
esac
# working copy now in ${Makefile}
# real copy now in ${Makefile}
mv ${Makefile} ${subdir}/Makefile.tem
......
......@@ -212,6 +212,7 @@ case "${target}" in
v810*) target_makefile_frag=config/mt-v810 ;;
i[3456]86-*-netware*) target_makefile_frag=config/mt-netware ;;
powerpc-*-netware*) target_makefile_frag=config/mt-netware ;;
*-*-linux-gnu) target_makefile_frag=config/mt-linux ;;
esac
skipdirs=
......
Tue Sep 16 00:40:23 1997 Jeffrey A Law (law@cygnus.com)
Tue Sep 16 09:18:52 1997 Jason Merrill (jason@cygnus.com)
* version.c: Bump for snapshot.
* expr.c (expand_expr, case TARGET_EXPR): Call mark_addressable
again for the slot after we give it RTL.
Tue Sep 16 00:13:20 1997 Nick Clifton <nickc@cygnus.com>
......
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.
......
......@@ -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;
......
......@@ -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' \
......
# 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
......@@ -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
......
......@@ -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);
......
/* 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*/
......@@ -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 (;;)
......
......@@ -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
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
}
......@@ -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;
}
......@@ -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;
}
......@@ -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)
......
......@@ -5,8 +5,8 @@
extern char *strerror __P ((int));
char *
DEFUN(_IO_strerror, (errnum),
int errnum)
_IO_strerror (errnum)
int errnum;
{
return strerror(errnum);
}
......@@ -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 */
......
......@@ -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;
......
/*
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
}
......
......@@ -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;
}
......@@ -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
/* this will be used later*/
......@@ -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.
/*
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
/* 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
/* 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
/* 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
......@@ -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);
......
......@@ -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
}
......
/*
/*
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);
......
......@@ -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*/)
......
......@@ -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);
}
......
......@@ -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();
......
1997-09-15 02:37 Ulrich Drepper <drepper@cygnus.com>
* config/linux.mt: New file. Make sure _PTHREADS is defined
if necessary.
* configure.in: Find linux.mt file.
Thu Sep 11 15:03:20 1997 Jason Merrill <jason@yorick.cygnus.com>
* std/bastring.h (class basic_string): Add global scope to
......
......@@ -41,6 +41,11 @@ if [ "${shared}" = "yes" ]; then
esac
fi
# Make sure the right flags are defined for multi-threading.
case "${target}" in
*-*-linux-gnu) frags="${frags} linux.mt" ;;
esac
for frag in ${frags}; do
frag=${srcdir}/config/$frag
if [ -f ${frag} ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment