From f65fd747b440ae2d8a7481ecc50e668c5e4d0cc9 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 8 Dec 1996 08:01:13 +0000 Subject: update from main archive 961207 Sun Dec 8 06:56:49 1996 Ulrich Drepper * io/getwd.c: Use PATH_MAX not LOCAL_PATH_MAX. Fix typo in comment. * stdlib/canonicalize.c: Correct bugs in last change. Patch by HJ Lu. * libio/Makefile (routines): Remove ioprims. (aux): Remove cleanup. Add IO_DEBUG option for .o files. * libio/cleanups.c: Removed. * libio/ioprims.c: Removed. * libio/filedoalloc.c: More updates from libg++-2.8b5. * libio/fileops.c: Likewise. * libio/genops.c: Likewise. * libio/iolibio.h: Likewise. * libio/iopopen.c: Likewise. * libio/iovsprintf.c: Likewise. * libio/iovsscanf.c: Likewise. * libio/libio.h: Likewise. * libio/libioP.h: Likewise. * libio/memstream.c: Likewise. * libio/strfile.h: Likewise. * libio/vasprintf.c: Likewise. * libio/vsnprintf.c: Likewise. * libio/stdio.h: Define P_tmpdir only is __USE_SVID. * manual/arith.texi: Change references to ANSI C to ISO C. * manual/conf.texi: Likewise. * manual/creature.texi: Likewise. * manual/ctype.texi: Likewise. * manual/errno.texi: Likewise. * manual/filesys.texi: Likewise. * manual/intro.texi. Likewise. * manual/io.texi: Likewise. * manual/lang.texi: Likewise. * manual/libc.texinfo: Likewise. * manual/locale.texi: Likewise. * manual/maint.texi: Likewise. * manual/mbyte.texi: Likewise. * manual/memory.texi: Likewise. * manual/process.texi: Likewise. * manual/process.texi: Likewise. * manual/search.texi: Likewise. * manual/setjmp.texi: Likewise. * manual/signal.texi: Likewise. * manual/startup.texi: Likewise. * manual/stdio.texi: Likewise. * manual/string.texi: Likewise. * manual/time.texi: Likewise. * manual/locale.texi: Remove description of LC_RESPONSE and add LC_MESSAGES. * Makefile (subdirs): Change malloc in $(malloc). * config.make.in: Add variable malloc which is initialized from @malloc@. * configure.in: Add new option --enable-new-malloc to use new malloc. This is the default on Linux. * sysdeps/unix/sysv/linux/configure.in: Define malloc to new-malloc by default. * new-malloc/Makefile: New file. Improved malloc implementation. * new-malloc/malloc.c: Likewise. * new-malloc/malloc.h: Likewise. * new-malloc/mallocbug.c: Likewise. * new-malloc/obstack.c: Likewise. * new-malloc/obstack.h: Likewise. * new-malloc/thread-m.h: Likewise. * time/Makefile: Compile ap.c with NO_MCHECK flag for now. * time/ap.c: Don't call mcheck if NO_MCHECK is defined. * resolv/Makefile: Add rule to rebuiild libresolv.so when libc.so changed. * stdio/feof.c: Update copyright. * stdio/stdio.h: Add field for lock to FILE structure. Add cast to *MAGIC constants to prevent warnings. * stdio-common/bug7.c: Correct test. Stream must not be closed twice. * stdlib/Makefile (routines): Add secure-getenv. * stdlib/secure-getenv.c: New file. __secure_getenv function moved to here from sysdeps/generic/getenv.c. Otherwise an application cannot replace the getenv function in the libc. * sysdeps/generic/getenv.c: Remove __secure_getenv function. * sysdeps/stub/getenv.c: Remove __secure_getenv alias. * sysdeps/mach/libc-lock.h: Define__libc_mutex_lock to __mutex_lock. * sysdeps/posix/fdopen.c: Update copyright. Don't use EXFUN. * time/test-tz.c: Comment fifth test out. PROBLEM. * time/tzset.c: De-ANSI-declfy. (__tzset): Don't increment pointer tz when no DST information is given. Sat Dec 7 23:47:54 1996 Ulrich Drepper * sysdeps/mach/libc-lock.h [_LIBC]: Add definition of __libc_mutex_lock. Patch by Thomas Bushnell. * sysdeps/unix/sysv/linux/timebits.h: Load only if __USE_MISC. * sysdeps/unix/sysv/linux/Dist: Add llseek.c. Sat Dec 7 12:18:56 1996 Ulrich Drepper * time/strftime (%c format): Remove %Z from default string. Reported by Paul Eggert * io/getwd.c: Don't apply getcwd on user supplied buffer. --- ChangeLog | 117 +- Makefile | 2 +- config.make.in | 1 + configure | 112 +- configure.in | 20 + io/getwd.c | 4 +- libio/Makefile | 12 +- libio/filedoalloc.c | 2 + libio/fileops.c | 8 +- libio/genops.c | 4 + libio/iolibio.h | 19 + libio/iopopen.c | 2 +- libio/iovsprintf.c | 2 +- libio/iovsscanf.c | 2 +- libio/libio.h | 15 +- libio/libioP.h | 185 +- libio/memstream.c | 12 +- libio/stdio.h | 3 + libio/strfile.h | 20 +- libio/vasprintf.c | 12 +- libio/vsnprintf.c | 2 +- login/endutent.c | 31 - login/endutent_r.c | 33 - login/pututline.c | 34 - login/pututline_r.c | 133 -- login/setutent.c | 31 - login/setutent_r.c | 76 - malloc/Makefile | 40 + malloc/malloc.c | 3443 ++++++++++++++++++++++++++++++++++ malloc/malloc.h | 169 ++ malloc/mallocbug.c | 67 + malloc/obstack.c | 551 ++++++ malloc/obstack.h | 575 ++++++ malloc/thread-m.h | 176 ++ manual/=float.texinfo | 72 +- manual/=limits.texinfo | 106 +- manual/=process.texinfo | 46 +- manual/=stdarg.texi | 26 +- manual/=stddef.texi | 18 +- manual/arith.texi | 40 +- manual/conf.texi | 10 +- manual/creature.texi | 12 +- manual/ctype.texi | 30 +- manual/errno.texi | 14 +- manual/filesys.texi | 16 +- manual/intro.texi | 56 +- manual/io.texi | 20 +- manual/lang.texi | 118 +- manual/libc.texinfo | 9 +- manual/locale.texi | 81 +- manual/maint.texi | 8 +- manual/math.texi | 54 +- manual/mbyte.texi | 22 +- manual/memory.texi | 23 +- manual/process.texi | 12 +- manual/search.texi | 12 +- manual/setjmp.texi | 11 +- manual/signal.texi | 87 +- manual/startup.texi | 14 +- manual/stdio.texi | 110 +- manual/string.texi | 52 +- manual/time.texi | 32 +- resolv/Makefile | 11 +- stdio-common/bug7.c | 4 + stdio/feof.c | 32 +- stdio/stdio.h | 9 +- stdlib/Makefile | 8 +- stdlib/canonicalize.c | 20 +- stdlib/secure-getenv.c | 30 + sysdeps/generic/getenv.c | 37 +- sysdeps/mach/libc-lock.h | 6 + sysdeps/posix/fdopen.c | 28 +- sysdeps/stub/getenv.c | 27 +- sysdeps/unix/sysv/linux/alpha/Dist | 1 - sysdeps/unix/sysv/linux/configure | 35 +- sysdeps/unix/sysv/linux/configure.in | 3 + sysdeps/unix/sysv/linux/timebits.h | 8 +- time/Makefile | 4 + time/ap.c | 33 +- time/strftime.c | 2 +- time/test-tz.c | 3 +- time/tzset.c | 89 +- 82 files changed, 6247 insertions(+), 1169 deletions(-) delete mode 100644 login/endutent.c delete mode 100644 login/endutent_r.c delete mode 100644 login/pututline.c delete mode 100644 login/pututline_r.c delete mode 100644 login/setutent.c delete mode 100644 login/setutent_r.c create mode 100644 malloc/Makefile create mode 100644 malloc/malloc.c create mode 100644 malloc/malloc.h create mode 100644 malloc/mallocbug.c create mode 100644 malloc/obstack.c create mode 100644 malloc/obstack.h create mode 100644 malloc/thread-m.h create mode 100644 stdlib/secure-getenv.c diff --git a/ChangeLog b/ChangeLog index 573b618221..47494122c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,124 @@ +Sun Dec 8 06:56:49 1996 Ulrich Drepper + + * io/getwd.c: Use PATH_MAX not LOCAL_PATH_MAX. Fix typo in + comment. + * stdlib/canonicalize.c: Correct bugs in last change. + Patch by HJ Lu. + + * libio/Makefile (routines): Remove ioprims. + (aux): Remove cleanup. + Add IO_DEBUG option for .o files. + * libio/cleanups.c: Removed. + * libio/ioprims.c: Removed. + * libio/filedoalloc.c: More updates from libg++-2.8b5. + * libio/fileops.c: Likewise. + * libio/genops.c: Likewise. + * libio/iolibio.h: Likewise. + * libio/iopopen.c: Likewise. + * libio/iovsprintf.c: Likewise. + * libio/iovsscanf.c: Likewise. + * libio/libio.h: Likewise. + * libio/libioP.h: Likewise. + * libio/memstream.c: Likewise. + * libio/strfile.h: Likewise. + * libio/vasprintf.c: Likewise. + * libio/vsnprintf.c: Likewise. + + * libio/stdio.h: Define P_tmpdir only is __USE_SVID. + + * manual/arith.texi: Change references to ANSI C to ISO C. + * manual/conf.texi: Likewise. + * manual/creature.texi: Likewise. + * manual/ctype.texi: Likewise. + * manual/errno.texi: Likewise. + * manual/filesys.texi: Likewise. + * manual/intro.texi. Likewise. + * manual/io.texi: Likewise. + * manual/lang.texi: Likewise. + * manual/libc.texinfo: Likewise. + * manual/locale.texi: Likewise. + * manual/maint.texi: Likewise. + * manual/mbyte.texi: Likewise. + * manual/memory.texi: Likewise. + * manual/process.texi: Likewise. + * manual/process.texi: Likewise. + * manual/search.texi: Likewise. + * manual/setjmp.texi: Likewise. + * manual/signal.texi: Likewise. + * manual/startup.texi: Likewise. + * manual/stdio.texi: Likewise. + * manual/string.texi: Likewise. + * manual/time.texi: Likewise. + + * manual/locale.texi: Remove description of LC_RESPONSE and add + LC_MESSAGES. + + * Makefile (subdirs): Change malloc in $(malloc). + * config.make.in: Add variable malloc which is initialized from + @malloc@. + * configure.in: Add new option --enable-new-malloc to use new + malloc. This is the default on Linux. + * sysdeps/unix/sysv/linux/configure.in: Define malloc to new-malloc + by default. + * new-malloc/Makefile: New file. Improved malloc implementation. + * new-malloc/malloc.c: Likewise. + * new-malloc/malloc.h: Likewise. + * new-malloc/mallocbug.c: Likewise. + * new-malloc/obstack.c: Likewise. + * new-malloc/obstack.h: Likewise. + * new-malloc/thread-m.h: Likewise. + * time/Makefile: Compile ap.c with NO_MCHECK flag for now. + * time/ap.c: Don't call mcheck if NO_MCHECK is defined. + + * resolv/Makefile: Add rule to rebuiild libresolv.so when libc.so + changed. + + * stdio/feof.c: Update copyright. + * stdio/stdio.h: Add field for lock to FILE structure. + Add cast to *MAGIC constants to prevent warnings. + + * stdio-common/bug7.c: Correct test. Stream must not be closed + twice. + + * stdlib/Makefile (routines): Add secure-getenv. + * stdlib/secure-getenv.c: New file. __secure_getenv function + moved to here from sysdeps/generic/getenv.c. Otherwise an + application cannot replace the getenv function in the libc. + * sysdeps/generic/getenv.c: Remove __secure_getenv function. + * sysdeps/stub/getenv.c: Remove __secure_getenv alias. + + * sysdeps/mach/libc-lock.h: Define__libc_mutex_lock to __mutex_lock. + + * sysdeps/posix/fdopen.c: Update copyright. Don't use EXFUN. + + * time/test-tz.c: Comment fifth test out. PROBLEM. + + * time/tzset.c: De-ANSI-declfy. + (__tzset): Don't increment pointer tz when no DST information is + given. + +Sat Dec 7 23:47:54 1996 Ulrich Drepper + + * sysdeps/mach/libc-lock.h [_LIBC]: Add definition of + __libc_mutex_lock. + Patch by Thomas Bushnell. + + * sysdeps/unix/sysv/linux/timebits.h: Load only + if __USE_MISC. + + * sysdeps/unix/sysv/linux/Dist: Add llseek.c. + +Sat Dec 7 12:18:56 1996 Ulrich Drepper + + * time/strftime (%c format): Remove %Z from default string. + Reported by Paul Eggert + Sat Dec 7 03:24:36 1996 Ulrich Drepper * configure.in: Discard error message from test in test for bash-2.0. - * io/getpw.c: Don't apply getcwd on user supplied buffer. + * io/getwd.c: Don't apply getcwd on user supplied buffer. Instead always use temporary buffer and only copy the result. Patch by HJ Lu. * stdlib/canonicalize.c: Likewise. diff --git a/Makefile b/Makefile index cd253734a6..7ebd3b7bd1 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,7 @@ endif # These are the subdirectories containing the library source. subdirs = csu assert ctype db locale intl catgets math setjmp signal stdlib \ - stdio-common $(stdio) malloc string wcsmbs time dirent grp pwd\ + stdio-common $(stdio) $(malloc) string wcsmbs time dirent grp pwd \ posix io termios resource misc login socket sysvipc gmon gnulib \ wctype manual shadow crypt $(sysdep-subdirs) nss elf po $(add-ons) export subdirs := $(subdirs) # Benign, useless in GNU make before 3.63. diff --git a/config.make.in b/config.make.in index f4c70caead..401289270b 100644 --- a/config.make.in +++ b/config.make.in @@ -31,6 +31,7 @@ build-shared = @shared@ build-profile = @profile@ build-omitfp = @omitfp@ stdio = @stdio@ +malloc = @malloc@ add-ons = @subdirs@ # Build tools. diff --git a/configure b/configure index ea10dce407..67948b6516 100755 --- a/configure +++ b/configure @@ -2,7 +2,7 @@ # From configure.in CVSid # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.11.2 +# Generated automatically using autoconf version 2.12 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -28,6 +28,9 @@ ac_help="$ac_help --with-elf if using the ELF object format" ac_help="$ac_help --enable-libio build in GNU libio instead of GNU stdio" +ac_help="$ac_help + --enable-new-malloc use the new malloc implementation. This is the + default for Linux, others use the old malloc." ac_help="$ac_help --disable-sanity-checks really do not use threads (should not be used except in special situations) [default=yes]" @@ -360,7 +363,7 @@ EOF verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.11.2" + echo "configure generated by autoconf version 2.12" exit 0 ;; -with-* | --with-*) @@ -643,6 +646,19 @@ else fi +# Check whether --enable-new-malloc or --disable-new-malloc was given. +if test "${enable_new_malloc+set}" = set; then + enableval="$enable_new_malloc" + if test $enableval = yes; then + malloc=new-malloc + else + malloc=malloc + fi +else + malloc=default +fi + + # Check whether --enable-sanity-checks or --disable-sanity-checks was given. if test "${enable_sanity_checks+set}" = set; then enableval="$enable_sanity_checks" @@ -720,7 +736,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:724: checking host system type" >&5 +echo "configure:740: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -800,7 +816,7 @@ esac # This can take a while to compute. sysdep_dir=$srcdir/sysdeps echo $ac_n "checking sysdep dirs""... $ac_c" 1>&6 -echo "configure:804: checking sysdep dirs" >&5 +echo "configure:820: checking sysdep dirs" >&5 # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1. os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`" @@ -1001,7 +1017,7 @@ echo "$ac_t""sysdeps/generic sysdeps/stub" 1>&6 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1005: checking for a BSD compatible install" >&5 +echo "configure:1021: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1055,7 +1071,7 @@ if test "$INSTALL" = "${srcdir}/install-sh -c"; then INSTALL='$(..)./install-sh -c' fi echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:1059: checking whether ln -s works" >&5 +echo "configure:1075: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1080,7 +1096,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1084: checking for $ac_word" >&5 +echo "configure:1100: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_MSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1111,7 +1127,7 @@ test -n "$MSGFMT" || MSGFMT=":" echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:1115: checking build system type" >&5 +echo "configure:1131: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -1137,7 +1153,7 @@ fi # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1141: checking for $ac_word" >&5 +echo "configure:1157: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1169,7 +1185,7 @@ if test $host != $build; then # Extract the first word of "gcc cc", so it can be a program name with args. set dummy gcc cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1173: checking for $ac_word" >&5 +echo "configure:1189: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_BUILD_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1196,7 +1212,7 @@ fi fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1200: checking how to run the C preprocessor" >&5 +echo "configure:1216: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1211,13 +1227,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1221: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1237: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then : @@ -1228,13 +1244,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1238: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1254: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then : @@ -1259,7 +1275,7 @@ echo "$ac_t""$CPP" 1>&6 # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1263: checking for $ac_word" >&5 +echo "configure:1279: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1290,7 +1306,7 @@ fi # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1294: checking for $ac_word" >&5 +echo "configure:1310: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1321,7 +1337,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1325: checking for $ac_word" >&5 +echo "configure:1341: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1356,7 +1372,7 @@ fi # Extract the first word of "bash", so it can be a program name with args. set dummy bash; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1360: checking for $ac_word" >&5 +echo "configure:1376: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_BASH'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1394,7 +1410,7 @@ fi echo $ac_n "checking for signed size_t type""... $ac_c" 1>&6 -echo "configure:1398: checking for signed size_t type" >&5 +echo "configure:1414: checking for signed size_t type" >&5 if eval "test \"`echo '$''{'libc_cv_signed_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1418,12 +1434,12 @@ EOF fi echo $ac_n "checking for libc-friendly stddef.h""... $ac_c" 1>&6 -echo "configure:1422: checking for libc-friendly stddef.h" >&5 +echo "configure:1438: checking for libc-friendly stddef.h" >&5 if eval "test \"`echo '$''{'libc_cv_friendly_stddef'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1458: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* libc_cv_friendly_stddef=yes else @@ -1457,7 +1473,7 @@ override stddef.h = # The installed seems to be libc-friendly." fi echo $ac_n "checking whether we need to use -P to assemble .S files""... $ac_c" 1>&6 -echo "configure:1461: checking whether we need to use -P to assemble .S files" >&5 +echo "configure:1477: checking whether we need to use -P to assemble .S files" >&5 if eval "test \"`echo '$''{'libc_cv_need_minus_P'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1480,7 +1496,7 @@ asm-CPPFLAGS = -P # The assembler can't grok cpp's # line directives." fi echo $ac_n "checking for assembler global-symbol directive""... $ac_c" 1>&6 -echo "configure:1484: checking for assembler global-symbol directive" >&5 +echo "configure:1500: checking for assembler global-symbol directive" >&5 if eval "test \"`echo '$''{'libc_cv_asm_global_directive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1510,7 +1526,7 @@ EOF fi echo $ac_n "checking for .set assembler directive""... $ac_c" 1>&6 -echo "configure:1514: checking for .set assembler directive" >&5 +echo "configure:1530: checking for .set assembler directive" >&5 if eval "test \"`echo '$''{'libc_cv_asm_set_directive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1545,12 +1561,12 @@ fi if test $elf != yes; then echo $ac_n "checking for .init and .fini sections""... $ac_c" 1>&6 -echo "configure:1549: checking for .init and .fini sections" >&5 +echo "configure:1565: checking for .init and .fini sections" >&5 if eval "test \"`echo '$''{'libc_cv_have_initfini'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1579: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* libc_cv_have_initfini=yes else @@ -1584,19 +1600,19 @@ if test $elf = yes; then libc_cv_asm_underscores=no else echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6 -echo "configure:1588: checking for _ prefix on C symbol names" >&5 +echo "configure:1604: checking for _ prefix on C symbol names" >&5 if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1616: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* libc_cv_asm_underscores=yes else @@ -1623,7 +1639,7 @@ if test $elf = yes; then libc_cv_asm_weakext_directive=no else echo $ac_n "checking for assembler .weak directive""... $ac_c" 1>&6 -echo "configure:1627: checking for assembler .weak directive" >&5 +echo "configure:1643: checking for assembler .weak directive" >&5 if eval "test \"`echo '$''{'libc_cv_asm_weak_directive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1646,7 +1662,7 @@ echo "$ac_t""$libc_cv_asm_weak_directive" 1>&6 if test $libc_cv_asm_weak_directive = no; then echo $ac_n "checking for assembler .weakext directive""... $ac_c" 1>&6 -echo "configure:1650: checking for assembler .weakext directive" >&5 +echo "configure:1666: checking for assembler .weakext directive" >&5 if eval "test \"`echo '$''{'libc_cv_asm_weakext_directive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1683,7 +1699,7 @@ EOF fi echo $ac_n "checking for ld --no-whole-archive""... $ac_c" 1>&6 -echo "configure:1687: checking for ld --no-whole-archive" >&5 +echo "configure:1703: checking for ld --no-whole-archive" >&5 if eval "test \"`echo '$''{'libc_cv_ld_no_whole_archive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1694,7 +1710,7 @@ __throw () {} EOF if { ac_try='${CC-cc} $CFLAGS -nostdlib -nostartfiles -Wl,--no-whole-archive - -o conftest conftest.c'; { (eval echo configure:1698: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then + -o conftest conftest.c'; { (eval echo configure:1714: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then libc_cv_ld_no_whole_archive=yes else libc_cv_ld_no_whole_archive=no @@ -1705,7 +1721,7 @@ fi echo "$ac_t""$libc_cv_ld_no_whole_archive" 1>&6 echo $ac_n "checking for gcc -fno-exceptions""... $ac_c" 1>&6 -echo "configure:1709: checking for gcc -fno-exceptions" >&5 +echo "configure:1725: checking for gcc -fno-exceptions" >&5 if eval "test \"`echo '$''{'libc_cv_gcc_no_exceptions'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1716,7 +1732,7 @@ __throw () {} EOF if { ac_try='${CC-cc} $CFLAGS -nostdlib -nostartfiles -fno-exceptions - -o conftest conftest.c'; { (eval echo configure:1720: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then + -o conftest conftest.c'; { (eval echo configure:1736: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then libc_cv_gcc_no_exceptions=yes else libc_cv_gcc_no_exceptions=no @@ -1768,7 +1784,7 @@ if test "$uname" = generic; then fi echo $ac_n "checking OS release for uname""... $ac_c" 1>&6 -echo "configure:1772: checking OS release for uname" >&5 +echo "configure:1788: checking OS release for uname" >&5 if eval "test \"`echo '$''{'libc_cv_uname_release'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1790,7 +1806,7 @@ echo "$ac_t""$libc_cv_uname_release" 1>&6 uname_release="$libc_cv_uname_release" echo $ac_n "checking OS version for uname""... $ac_c" 1>&6 -echo "configure:1794: checking OS version for uname" >&5 +echo "configure:1810: checking OS version for uname" >&5 if eval "test \"`echo '$''{'libc_cv_uname_version'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1812,7 +1828,7 @@ else fi echo $ac_n "checking stdio selection""... $ac_c" 1>&6 -echo "configure:1816: checking stdio selection" >&5 +echo "configure:1832: checking stdio selection" >&5 case $stdio in libio) cat >> confdefs.h <<\EOF @@ -1823,6 +1839,13 @@ default) stdio=stdio ;; esac echo "$ac_t""$stdio" 1>&6 +echo $ac_n "checking malloc selection""... $ac_c" 1>&6 +echo "configure:1844: checking malloc selection" >&5 + +test $malloc = default && malloc=malloc +echo "$ac_t""$malloc" 1>&6 + + @@ -1850,6 +1873,10 @@ fi if test $shared = default; then if test $gnu_ld = yes; then shared=$elf + else + # For now we do not assume shared libs are available. In future more + # tests might become available. + shared=no fi fi @@ -1953,7 +1980,7 @@ do echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.11.2" + echo "$CONFIG_STATUS generated by autoconf version 2.12" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -2025,6 +2052,7 @@ s%@uname_sysname@%$uname_sysname%g s%@uname_release@%$uname_release%g s%@uname_version@%$uname_version%g s%@stdio@%$stdio%g +s%@malloc@%$malloc%g s%@libc_cv_slibdir@%$libc_cv_slibdir%g s%@libc_cv_sysconfdir@%$libc_cv_sysconfdir%g s%@gnu_ld@%$gnu_ld%g diff --git a/configure.in b/configure.in index 3a4d200e71..70d62b41c0 100644 --- a/configure.in +++ b/configure.in @@ -59,6 +59,16 @@ AC_ARG_ENABLE(libio, dnl fi], stdio=default) +AC_ARG_ENABLE(new-malloc, dnl +[ --enable-new-malloc use the new malloc implementation. This is the + default for Linux, others use the old malloc.], + [if test $enableval = yes; then + malloc=new-malloc + else + malloc=malloc + fi], + malloc=default) + AC_ARG_ENABLE(sanity-checks, dnl [ --disable-sanity-checks really do not use threads (should not be used except in special situations) [default=yes]], @@ -677,6 +687,12 @@ default) stdio=stdio ;; esac AC_MSG_RESULT($stdio) +AC_MSG_CHECKING(malloc selection) +AC_SUBST(malloc) +test $malloc = default && malloc=malloc +AC_MSG_RESULT($malloc) + + AC_SUBST(libc_cv_slibdir) AC_SUBST(libc_cv_sysconfdir) @@ -695,6 +711,10 @@ AC_SUBST(shared) if test $shared = default; then if test $gnu_ld = yes; then shared=$elf + else + # For now we do not assume shared libs are available. In future more + # tests might become available. + shared=no fi fi AC_SUBST(profile) diff --git a/io/getwd.c b/io/getwd.c index 510a681d78..506aac8472 100644 --- a/io/getwd.c +++ b/io/getwd.c @@ -38,10 +38,10 @@ getwd (buf) return NULL; } - if (getcwd (tmpbuf, LOCAL_PATH_MAX) == NULL) + if (getcwd (tmpbuf, PATH_MAX) == NULL) { /* We use 1024 here since it should really be enough and because - this is a save value. */ + this is a safe value. */ __strerror_r (errno, buf, 1024); return NULL; } diff --git a/libio/Makefile b/libio/Makefile index 4266ad4e59..53a1d7d843 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -12,9 +12,9 @@ # 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., 675 Mass Ave, -# Cambridge, MA 02139, USA. +# 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. # # Specific makefile for libio. @@ -26,7 +26,7 @@ headers := stdio.h libio.h _G_config.h routines := \ filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen \ iofopncook iofprintf iofputs iofread iofsetpos ioftell \ - iofwrite iogetdelim iogetline iogets iopadn iopopen ioprims ioputs \ + iofwrite iogetdelim iogetline iogets iopadn iopopen ioputs \ ioseekoff ioseekpos iosetbuffer iosetvbuf iosprintf ioungetc \ iovsprintf iovsscanf \ \ @@ -40,6 +40,8 @@ all: # Make this the default target; it will be defined in Rules. include ../Makeconfig +CPPFLAGS-.o += -DIO_DEBUG + ifneq (,$(filter %REENTRANT, $(defines))) routines += clearerr_u feof_u ferror_u fputc_u getc_u getchar_u \ iofflush_u putc_u putchar_u peekc @@ -48,7 +50,7 @@ CPPFLAGS += -D_IO_MTSAFE_IO endif aux := \ - cleanup fileops genops stdfiles stdio strops + fileops genops stdfiles stdio strops distribute := iolibio.h libioP.h strfile.h Banner diff --git a/libio/filedoalloc.c b/libio/filedoalloc.c index 045bff697d..eee489b825 100644 --- a/libio/filedoalloc.c +++ b/libio/filedoalloc.c @@ -71,12 +71,14 @@ DEFUN(_IO_file_doallocate, (fp), register char *p; struct stat st; +#ifndef _LIBC /* If _IO_cleanup_registration_needed is non-zero, we should call the function it points to. This is to make sure _IO_cleanup gets called on exit. We call it from _IO_file_doallocate, since that is likely to get called by any program that does buffered I/O. */ if (_IO_cleanup_registration_needed) (*_IO_cleanup_registration_needed)(); +#endif if (fp->_fileno < 0 || _IO_SYSSTAT (fp, &st) < 0) { diff --git a/libio/fileops.c b/libio/fileops.c index d3f4831e2d..ce0e2bb524 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -47,7 +47,6 @@ extern int errno; The position in the buffer that corresponds to the position in external file system is normally _IO_read_end, except in putback mode, when it is _IO_save_end. - when it is _IO_save_end. If the field _fb._offset is >= 0, it gives the offset in the file as a whole corresponding to eGptr(). (?) @@ -185,7 +184,7 @@ DEFUN(_IO_file_fopen, (fp, filename, mode), _IO_mask_flags(fp, read_write,_IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING); if (read_write & _IO_IS_APPENDING) if (_IO_SEEKOFF (fp, (_IO_off_t)0, _IO_seek_end, _IOS_INPUT|_IOS_OUTPUT) - == _IO_pos_BAD) + == _IO_pos_BAD && errno != ESPIPE) return NULL; _IO_link_in(fp); return fp; @@ -200,7 +199,12 @@ DEFUN(_IO_file_attach, (fp, fd), fp->_fileno = fd; fp->_flags &= ~(_IO_NO_READS+_IO_NO_WRITES); fp->_flags |= _IO_DELETE_DONT_CLOSE; + /* Get the current position of the file. */ + /* We have to do that since that may be junk. */ fp->_offset = _IO_pos_BAD; + if (_IO_SEEKOFF (fp, (_IO_off_t)0, _IO_seek_cur, _IOS_INPUT|_IOS_OUTPUT) + == _IO_pos_BAD && errno != ESPIPE) + return NULL; return fp; } diff --git a/libio/genops.c b/libio/genops.c index fc4c61d9a4..3a58cd2eaf 100644 --- a/libio/genops.c +++ b/libio/genops.c @@ -861,3 +861,7 @@ __io_defs io_defs__; #ifdef weak_alias weak_alias (_IO_cleanup, _cleanup) #endif + +#ifdef text_set_element +text_set_element(__libc_atexit, _cleanup); +#endif diff --git a/libio/iolibio.h b/libio/iolibio.h index 92df6a6fd2..ca863b51b3 100644 --- a/libio/iolibio.h +++ b/libio/iolibio.h @@ -56,3 +56,22 @@ extern _IO_FILE* _IO_popen __P((const char*, const char*)); #ifdef __cplusplus } #endif + +#define _IO_open __open +#define _IO_close __close +#define _IO_fork __fork +#define _IO_fcntl __fcntl +#define _IO__exit _exit +#define _IO_read __read +#define _IO_write __write +#define _IO_lseek __lseek +#define _IO_getdtablesize __getdtablesize +#define _IO_pipe __pipe +#define _IO_dup2 __dup2 +#define _IO_execl execl +#define _IO_waitpid __waitpid +#define _IO_stat __stat +#define _IO_getpid __getpid +#define _IO_geteuid __geteuid +#define _IO_getegid __getegid +#define _IO_fstat __fstat diff --git a/libio/iopopen.c b/libio/iopopen.c index dc1e74d3eb..5703c99d47 100644 --- a/libio/iopopen.c +++ b/libio/iopopen.c @@ -123,7 +123,7 @@ DEFUN(_IO_proc_open, (fp, command, mode), proc_file_chain = proc_file_chain->next; } - _IO_execl("/bin/sh", "sh", "-c", command, NULL); + _IO_execl("/bin/sh", "sh", "-c", command, (char *) 0); _IO__exit(127); } _IO_close(child_end); diff --git a/libio/iovsprintf.c b/libio/iovsprintf.c index b2e8b67a96..f0c9889724 100644 --- a/libio/iovsprintf.c +++ b/libio/iovsprintf.c @@ -38,7 +38,7 @@ _IO_vsprintf (string, format, args) int ret; #ifdef _IO_MTSAFE_IO - sf._f._lock = &lock; + sf._sbf._f._lock = &lock; #endif _IO_init ((_IO_FILE *) &sf, 0); _IO_JUMPS ((_IO_FILE *) &sf) = &_IO_str_jumps; diff --git a/libio/iovsscanf.c b/libio/iovsscanf.c index 6e7d8c59e2..473b714f21 100644 --- a/libio/iovsscanf.c +++ b/libio/iovsscanf.c @@ -32,7 +32,7 @@ DEFUN(_IO_vsscanf, (string, format, args), _IO_strfile sf; #ifdef _IO_MTSAFE_IO _IO_lock_t lock; - sf._f._lock = &lock; + sf._sbf._f._lock = &lock; #endif _IO_init((_IO_FILE*)&sf, 0); _IO_JUMPS((_IO_FILE*)&sf) = &_IO_str_jumps; diff --git a/libio/libio.h b/libio/libio.h index 7dd47db9fa..acc34c0d7a 100644 --- a/libio/libio.h +++ b/libio/libio.h @@ -52,11 +52,15 @@ the executable file might be covered by the GNU General Public License. */ #endif #ifndef __P +#if _G_HAVE_SYS_CDEFS +#include +#else #ifdef __STDC__ #define __P(protos) protos #else #define __P(protos) () #endif +#endif #endif /*!__P*/ /* For backward compatibility */ @@ -79,12 +83,16 @@ the executable file might be covered by the GNU General Public License. */ #define EOF (-1) #endif #ifndef NULL -#if !defined(__cplusplus) || defined(__GNUC__) +#ifdef __GNUG__ +#define NULL (__null) +#else +#if !defined(__cplusplus) #define NULL ((void*)0) #else #define NULL (0) #endif #endif +#endif #define _IOS_INPUT 1 #define _IOS_OUTPUT 2 @@ -183,6 +191,7 @@ struct _IO_FILE { #define _IO_file_flags _flags /* The following pointers correspond to the C++ streambuf protocol. */ + /* Note: Tk uses the _IO_read_ptr and _IO_read_end fields directly. */ char* _IO_read_ptr; /* Current read pointer */ char* _IO_read_end; /* End of get area. */ char* _IO_read_base; /* Start of putback+get area. */ @@ -200,10 +209,6 @@ struct _IO_FILE { struct _IO_FILE *_chain; -#if !_IO_UNIFIED_JUMPTABLES - struct _IO_jump_t *_jumps; /* Jump table */ -#endif - int _fileno; int _blksize; _IO_off_t _offset; diff --git a/libio/libioP.h b/libio/libioP.h index d3c871fbeb..008f9b7edf 100644 --- a/libio/libioP.h +++ b/libio/libioP.h @@ -57,71 +57,180 @@ extern "C" { #define _IO_seek_cur 1 #define _IO_seek_end 2 -typedef int (*_IO_overflow_t) __P((_IO_FILE*, int)); -typedef int (*_IO_underflow_t) __P((_IO_FILE*)); -typedef _IO_size_t (*_IO_xsputn_t) __P((_IO_FILE*,const void*,_IO_size_t)); -typedef _IO_size_t (*_IO_xsgetn_t) __P((_IO_FILE*, void*, _IO_size_t)); -typedef _IO_ssize_t (*_IO_read_t) __P((_IO_FILE*, void*, _IO_ssize_t)); -typedef _IO_ssize_t (*_IO_write_t) __P((_IO_FILE*,const void*,_IO_ssize_t)); -typedef int (*_IO_stat_t) __P((_IO_FILE*, void*)); -typedef _IO_fpos_t (*_IO_seek_t) __P((_IO_FILE*, _IO_off_t, int)); -typedef int (*_IO_doallocate_t) __P((_IO_FILE*)); -typedef int (*_IO_pbackfail_t) __P((_IO_FILE*, int)); -typedef _IO_FILE* (*_IO_setbuf_t) __P((_IO_FILE*, char *, _IO_ssize_t)); -typedef int (*_IO_sync_t) __P((_IO_FILE*)); -typedef void (*_IO_finish_t) __P((_IO_FILE*)); /* finalize */ -typedef int (*_IO_close_t) __P((_IO_FILE*)); /* finalize */ -typedef _IO_fpos_t (*_IO_seekoff_t) __P((_IO_FILE*, _IO_off_t, int, int)); - -/* 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)); +/* THE JUMPTABLE FUNCTIONS. + + * The _IO_FILE type is used to implement the FILE type in GNU libc, + * as well as the streambuf class in GNU iostreams for C++. + * These are all the same, just used differently. + * An _IO_FILE (or FILE) object is allows followed by a pointer to + * 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 + * 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. + * + * The entries in the _IO_JUMPS function table (and hence also the + * virtual functions of a streambuf) are described below. + * The first parameter of each function entry is the _IO_FILE/streambuf + * object being acted on (i.e. the 'this' parameter). + */ -#if !_IO_UNIFIED_JUMPTABLES -#define _IO_JUMPS(THIS) (THIS)->_jumps -#else #define _IO_JUMPS(THIS) ((struct _IO_FILE_plus*)(THIS))->vtable -#endif - -#if !_IO_UNIFIED_JUMPTABLES +#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 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} -#endif #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*)); /* finalize */ #define _IO_FINISH(FP) JUMP0(__finish, FP) + +/* 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) + +/* 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. + It matches the streambuf::underflow virtual function. */ +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) + +/* 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) + +/* 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) + +/* 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) + +/* 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) + +/* 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) + +/* 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) + +/* 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) + +/* 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) + +/* 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. + 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 + implementation used for normal files just calls those functions. + The advantage of overriding these functions instead of the higher-level + ones (underflow, overflow etc) is that you can leave all the buffering + higher-level functions. */ + +/* 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) + +/* 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) + +/* 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) + +/* 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) + +/* 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) + #define _IO_CHAR_TYPE char /* unsigned char ? */ #define _IO_INT_TYPE int struct _IO_jump_t { JUMP_FIELD(_G_size_t, __dummy); +#ifdef _G_USING_THUNKS + JUMP_FIELD(_G_size_t, __dummy2); +#endif JUMP_FIELD(_IO_finish_t, __finish); JUMP_FIELD(_IO_overflow_t, __overflow); JUMP_FIELD(_IO_underflow_t, __underflow); @@ -147,16 +256,13 @@ struct _IO_jump_t { }; /* We always allocate an extra word following an _IO_FILE. + This contains a pointer to the function jump table used. 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 { _IO_FILE file; -#if _IO_UNIFIED_JUMPTABLES const struct _IO_jump_t *vtable; -#else - const void *vtable; -#endif }; /* Generic functions */ @@ -225,7 +331,7 @@ extern void _IO_flush_all_linebuffered __P((void)); #define _IO_have_backup(fp) ((fp)->_IO_save_base != NULL) #define _IO_in_backup(fp) ((fp)->_flags & _IO_IN_BACKUP) #define _IO_have_markers(fp) ((fp)->_markers != NULL) -#define _IO_blen(p) ((fp)->_IO_buf_end - (fp)->_IO_buf_base) +#define _IO_blen(fp) ((fp)->_IO_buf_end - (fp)->_IO_buf_base) /* Jumptable functions for files. */ @@ -290,12 +396,16 @@ extern void (*_IO_cleanup_registration_needed) __P ((void)); #define EOF (-1) #endif #ifndef NULL -#if !defined(__cplusplus) || defined(__GNUC__) +#ifdef __GNUG__ +#define NULL (__null) +#else +#if !defined(__cplusplus) #define NULL ((void*)0) #else #define NULL (0) #endif #endif +#endif #define FREE_BUF(_B) free(_B) #define ALLOC_BUF(_S) (char*)malloc(_S) @@ -337,22 +447,17 @@ extern int _IO_vscanf __P((const char *, _IO_va_list)); } #endif -#if _IO_UNIFIED_JUMPTABLES -#define _IO_FJUMP /* nothing */ -#else -#define _IO_FJUMP &_IO_file_jumps, -#endif #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, _IO_FJUMP FD, \ + 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) \ { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, _IO_FJUMP 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. @@ -402,7 +507,7 @@ extern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf; #define MAYBE_SET_EINVAL /* nothing */ #endif -#ifdef DEBUG +#ifdef IO_DEBUG #define CHECK_FILE(FILE,RET) \ if ((FILE) == NULL) { MAYBE_SET_EINVAL; return RET; } \ else { COERCE_FILE(FILE); \ diff --git a/libio/memstream.c b/libio/memstream.c index 8f9c8ac92c..ddcce676cb 100644 --- a/libio/memstream.c +++ b/libio/memstream.c @@ -77,21 +77,21 @@ open_memstream (bufloc, sizeloc) if (new_f == NULL) return NULL; #ifdef _IO_MTSAFE_IO - new_f->fp._sf._f._lock = &new_f->lock; + new_f->fp._sf._sbf._f._lock = &new_f->lock; #endif buf = ALLOC_BUF (_IO_BUFSIZ); - _IO_init (&new_f->fp._sf._f, 0); - _IO_JUMPS (&new_f->fp._sf._f) = &_IO_mem_jumps; - _IO_str_init_static (&new_f->fp._sf._f, buf, _IO_BUFSIZ, buf); - new_f->fp._sf._f._flags &= ~_IO_USER_BUF; + _IO_init (&new_f->fp._sf._sbf._f, 0); + _IO_JUMPS (&new_f->fp._sf._sbf._f) = &_IO_mem_jumps; + _IO_str_init_static (&new_f->fp._sf._sbf._f, buf, _IO_BUFSIZ, buf); + new_f->fp._sf._sbf._f._flags &= ~_IO_USER_BUF; new_f->fp._sf._s._allocate_buffer = (_IO_alloc_type) malloc; new_f->fp._sf._s._free_buffer = (_IO_free_type) free; new_f->fp.bufloc = bufloc; new_f->fp.sizeloc = sizeloc; - return &new_f->fp._sf._f; + return &new_f->fp._sf._sbf._f; } diff --git a/libio/stdio.h b/libio/stdio.h index 75d22f94c0..ba5fa5438e 100644 --- a/libio/stdio.h +++ b/libio/stdio.h @@ -73,7 +73,10 @@ typedef _IO_fpos_t fpos_t; #include +#ifdef __USE_SVID +/* Default path prefix for `tempnam' and `tmpnam'. */ #define P_tmpdir "/tmp" +#endif /* For use by debuggers. These are linked in if printf or fprintf are used. */ extern FILE *stdin, *stdout, *stderr; /* TODO */ diff --git a/libio/strfile.h b/libio/strfile.h index 4934a06e3c..76044f8927 100644 --- a/libio/strfile.h +++ b/libio/strfile.h @@ -36,9 +36,27 @@ struct _IO_str_fields _IO_free_type _free_buffer; }; -typedef struct _IO_strfile_ +/* This is needed for the Irix6 N32 ABI, which has a 64 bit off_t type, + but a 32 bit pointer type. In this case, we get 4 bytes of padding + after the vtable pointer. Putting them in a structure together solves + this problem. */ + +struct _IO_streambuf { struct _IO_FILE _f; const void *_vtable; +}; + +typedef struct _IO_strfile_ +{ + struct _IO_streambuf _sbf; struct _IO_str_fields _s; } _IO_strfile; + +/* dynamic: set when the array object is allocated (or reallocated) as + necessary to hold a character sequence that can change in length. */ +#define _IO_STR_DYNAMIC(FP) ((FP)->_s._allocate_buffer != (_IO_alloc_type)0) + +/* frozen: set when the program has requested that the array object not + be altered, reallocated, or freed. */ +#define _IO_STR_FROZEN(FP) ((FP)->_f._IO_file_flags & _IO_USER_BUF) diff --git a/libio/vasprintf.c b/libio/vasprintf.c index 57a3b08eba..f8dba80c38 100644 --- a/libio/vasprintf.c +++ b/libio/vasprintf.c @@ -46,22 +46,22 @@ _IO_vasprintf (result_ptr, format, args) if (string == NULL) return -1; #ifdef _IO_MTSAFE_IO - sf._f._lock = &lock; + sf._sbf._f._lock = &lock; #endif _IO_init((_IO_FILE*)&sf, 0); _IO_JUMPS((_IO_FILE*)&sf) = &_IO_str_jumps; _IO_str_init_static ((_IO_FILE*)&sf, string, init_string_size, string); - sf._f._flags &= ~_IO_USER_BUF; + sf._sbf._f._flags &= ~_IO_USER_BUF; sf._s._allocate_buffer = (_IO_alloc_type)malloc; sf._s._free_buffer = (_IO_free_type)free; ret = _IO_vfprintf((_IO_FILE*)&sf, format, args); if (ret < 0) return ret; - *result_ptr = (char*)realloc(sf._f._IO_buf_base, - (sf._f._IO_write_ptr - sf._f._IO_write_base) +1); + *result_ptr = (char*)realloc(sf._sbf._f._IO_buf_base, + (sf._sbf._f._IO_write_ptr - sf._sbf._f._IO_write_base) +1); if (*result_ptr == NULL) - *result_ptr = sf._f._IO_buf_base; - (*result_ptr)[sf._f._IO_write_ptr-sf._f._IO_write_base] = '\0'; + *result_ptr = sf._sbf._f._IO_buf_base; + (*result_ptr)[sf._sbf._f._IO_write_ptr-sf._sbf._f._IO_write_base] = '\0'; return ret; } weak_alias (_IO_vasprintf, vasprintf) diff --git a/libio/vsnprintf.c b/libio/vsnprintf.c index 9f767b5b06..9ec06914c0 100644 --- a/libio/vsnprintf.c +++ b/libio/vsnprintf.c @@ -36,7 +36,7 @@ _IO_vsnprintf (string, maxlen, format, args) int ret; #ifdef _IO_MTSAFE_IO _IO_lock_t lock; - sf._f._lock = &lock; + sf._sbf._f._lock = &lock; #endif _IO_init ((_IO_FILE *) &sf, 0); _IO_JUMPS ((_IO_FILE *) &sf) = &_IO_str_jumps; diff --git a/login/endutent.c b/login/endutent.c deleted file mode 100644 index 3df95bef93..0000000000 --- a/login/endutent.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (C) 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. -Contributed by Ulrich Drepper , 1996. - -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 - - -/* The global data defined in setutent.c. */ -extern struct utmp_data __utmp_data; - - -void -endutent (void) -{ - __endutent_r (&__utmp_data); -} diff --git a/login/endutent_r.c b/login/endutent_r.c deleted file mode 100644 index a531054a2a..0000000000 --- a/login/endutent_r.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. -Contributed by Ulrich Drepper , 1996. - -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 -#include - - -void -__endutent_r (struct utmp_data *utmp_data) -{ - if (utmp_data->ut_fd != -1) - { - close (utmp_data->ut_fd); - utmp_data->ut_fd = -1; - } -} -weak_alias (__endutent_r, endutent_r) diff --git a/login/pututline.c b/login/pututline.c deleted file mode 100644 index 7af3efbb46..0000000000 --- a/login/pututline.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. -Contributed by Ulrich Drepper , 1996. - -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 - - -/* The global data defined in setutent.c. */ -extern struct utmp_data __utmp_data; - - -struct utmp * -pututline (const struct utmp *utmp) -{ - if (__pututline_r (utmp, &__utmp_data) < 0) - return NULL; - - return (struct utmp *) utmp; -} diff --git a/login/pututline_r.c b/login/pututline_r.c deleted file mode 100644 index 33ba96f461..0000000000 --- a/login/pututline_r.c +++ /dev/null @@ -1,133 +0,0 @@ -/* Copyright (C) 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. -Contributed by Ulrich Drepper , 1996. - -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 -#include -#include -#include -#include -#include -#include -#include - - -/* XXX An alternative solution would be to call a SUID root program - which write the new value. */ - -int -__pututline_r (const struct utmp *id, struct utmp_data *utmp_data) -{ - struct stat st; - int result = 0; - -#if _HAVE_UT_TYPE - 0 - /* Test whether ID has any of the legal types because we have to - prevent illegal entries. */ - if (id->ut_type != RUN_LVL && id->ut_type != BOOT_TIME - && id->ut_type != OLD_TIME && id->ut_type != NEW_TIME - && id->ut_type != INIT_PROCESS && id->ut_type != LOGIN_PROCESS - && id->ut_type != USER_PROCESS && id->ut_type != DEAD_PROCESS) - /* No, using '<' and '>' for the test is not possible. */ - { - __set_errno (EINVAL); - return -1; - } -#endif - - /* Open utmp file if not already done. */ - if (utmp_data->ut_fd == -1) - { - setutent_r (utmp_data); - if (utmp_data->ut_fd == -1) - return -1; - } - -#if _HAVE_UT_ID - 0 - /* Check whether we need to reposition. Repositioning is necessary - either if the data in UTMP_DATA is not valid or if the ids don't - match: */ - if (id->ut_id[0] - && (utmp_data->loc_utmp < (off_t) sizeof (struct utmp) - || strncmp (utmp_data->ubuf.ut_id, id->ut_id, - sizeof (id->ut_id)) != 0)) - { - /* We must not overwrite the data in UTMP_DATA since ID may be - aliasing it. */ - struct utmp_data *data_tmp = alloca (sizeof (*data_tmp)); - struct utmp *dummy; - - *data_tmp = *utmp_data; - utmp_data = data_tmp; - - if (getutid_r (id, &dummy, utmp_data) < 0 && errno != ESRCH) - return -1; - } -#endif - - /* Try to lock the file. */ - if (flock (utmp_data->ut_fd, LOCK_EX | LOCK_NB) < 0 && errno != ENOSYS) - { - /* Oh, oh. The file is already locked. Wait a bit and try again. */ - sleep (1); - - /* This time we ignore the error. */ - (void) flock (utmp_data->ut_fd, LOCK_EX | LOCK_NB); - } - - /* Find out how large the file is. */ - result = fstat (utmp_data->ut_fd, &st); - - if (result >= 0) - /* Position file correctly. */ - if (utmp_data->loc_utmp < (off_t) sizeof (struct utmp) - || (off_t) (utmp_data->loc_utmp - sizeof (struct utmp)) > st.st_size) - /* Not located at any valid entry. Add at the end. */ - { - result = lseek (utmp_data->ut_fd, 0L, SEEK_END); - if (result >= 0) - /* Where we'll be if the write succeeds. */ - utmp_data->loc_utmp = st.st_size + sizeof (struct utmp); - } - else - result = - lseek (utmp_data->ut_fd, utmp_data->loc_utmp - sizeof (struct utmp), - SEEK_SET); - - if (result >= 0) - /* Write the new data. */ - if (write (utmp_data->ut_fd, id, sizeof (struct utmp)) - != sizeof (struct utmp)) - { - /* If we appended a new record this is only partially written. - Remove it. */ - if (utmp_data->loc_utmp > st.st_size) - { - (void) ftruncate (utmp_data->ut_fd, st.st_size); - utmp_data->loc_utmp = st.st_size; - } - - result = -1; - } - - /* And unlock the file. */ - (void) flock (utmp_data->ut_fd, LOCK_UN); - - return result; -} -weak_alias (__pututline_r, pututline_r) diff --git a/login/setutent.c b/login/setutent.c deleted file mode 100644