From edf5b2d7168982e1725f41e142b77e5ec88d7bf2 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 7 Sep 1996 04:10:57 +0000 Subject: update from main archive 960906 Sat Sep 7 05:15:45 1996 Ulrich Drepper * libio/iofdopen: Initialize _lock field only if _IO_MTSAFE_IO. * libio/iofopen: Likewise. * libio/iofopncook.c: Likewise. * libio/iopopen.c: Likewise. * libio/iovsprintf.c: Likewise. * libio/iovsscanf.c: Likewise. * libio/memstream.c: Likewise. * libio/vasprintf.c: Likewise. * libio/vdprintf.c: Likewise. * libio/vsnprintf.c: Likewise. Sat Sep 7 03:55:47 1996 Ulrich Drepper * Makeconfig (soversions.mk): Also use shlib-versions files in add-on directories. * config.make.in (config-defines): Remove. Not used anymore. (defines): New variable. Initiliazed by @DEFINES@. * configure.in: Add AC_SUBST(DEFINES). * libio/Makefile (routines): When compiling reentrant libc add clearerr_u, feof_u, ferror_u, fputc_u, getc_u, getchar_u, iofflush_u, putc_u, putchar_u, ioflockfile. (CPPFLAGS): Add -D_IO_MTSAFE_IO for reentrant libc. * sysdeps/stub/libc-lock.h: Add stubs for __libc_cleanup_region_start and __libc_cleanup_region_end. * sysdeps/unix/i386/sysdep.S [_LIBC_REENTRANT]: Set errno using __errno_location function. * sysdeps/unix/sysv/linux/i386/sysdep.S [_LIBC_REENTRANT]: Set errno using __errno_location function. (__errno_location): New function. * sysdeps/unix/sysv/linux/i386/sysdep.h [PIC]: Add second syscall_error handler for reentrant libc. * sysdeps/unix/opendir.c: Remove unneeded `;'. * libio.h [_IO_MTSAFE_IO]: Include . [!_IO_MTSAFE_IO]: Define _IO_flockfile and _IO_funlockfile as empty macros. * libioP.h: Include . * libio/stdio.h: Add prototypes for *_locked and *_unlocked functions. * libio/clearerr.c: Use _IO_ protected versions of flockfile and funlockfile to be namespace clean. * libio/genops.c: Use __libc_lock_* macros for handling lock. * libio/iofdopen: Add initialization of _lock in _IO_FILE. * libio/iofopen: Likewise. * libio/iofopncook.c: Likewise. * libio/iopopen.c: Likewise. * libio/iovsprintf.c: Likewise. * libio/iovsscanf.c: Likewise. * libio/memstream.c: Likewise. * libio/vasprintf.c: Likewise. * libio/vdprintf.c: Likewise. * libio/vsnprintf.c: Likewise. * libio/fgetc.c: Use __libc_cleanup_region_* macros instead of flockfile etc. * libio/fputc.c: Likewise. * libio/freopen.c: Likewise. * libio/fseek.c: Likewise. * libio/getc.c: Likewise. * libio/getchar.c: Likewise. * libio/iofclose.c: Likewise. * libio/iofflush.c: Likewise. * libio/iofgetpos.c: Likewise. * libio/iofgets.c: Likewise. * libio/iofputs.c: Likewise. * libio/iofread.c: Likewise. * libio/iofsetpos.c: Likewise. * libio/ioftell.c: Likewise. * libio/iofwrite.c: Likewise. * libio/iogetdelim.c: Likewise. * libio/iogets.c: Likewise. * libio/ioputs.c: Likewise. * libio/iosetbuffer.c: Likewise. * libio/iosetvbuf.c: Likewise. * libio/ioungetc.c: Likewise. * libio/putc.c: Likewise. * libio/putchar.c: Likewise. * libio/rewind.c: Likewise. * stdio-common/vfprintf.c: Likewise. * stdio-common/vfscanf.c: Likewise. * libio/clearerr_u.c: Correct alias name. * libio/ferror_u.c: Likewise. * libio/fileno.c: Likewise. * libio/fputc_u.c: Likewise. * libio/getc.c: Likewise. * libio/getc_u.c: Likewise. * libio/getchar.c: Likewise. * libio/getchar_u.c: Likewise. * libio/putc.c: Likewise. * libio/putchar.c: Likewise. * libio/feof_u.c: Undefine macro with name of function before definition of function itself. * libio/ioflockfile.c: New file. Implementation of flockfile and funlockfile. * libio/putchar_u.c: Fix typo. Use stdout instead of fp. * malloc/malloc.h: Don't include and don't declare _malloc_loc. * malloc/free.c: Include . * malloc/realloc.c: Likewise. * malloc/malloc-find.c: Likewise. * malloc/malloc-size.c: Likewise. * malloc/malloc-walk.c: Likewise. * malloc/memalign.c: Likewise. * malloc/malloc.c: Likewise. * sysdeps/i386/dl-machine.h: Correct clearing of _dl_starting_up. Fri Sep 6 19:38:49 1996 Ulrich Drepper * sysdeps/stub/libc-lock.h: Define __libc_lock_critical_start and __libc_lock_critical_end as empty macros. * malloc/malloc.h: Don't include and don't declare __libc_malloc_lock. * malloc/free.c: Include . * malloc/malloc-find.c: Likewise. * malloc/malloc-size.c: Likewise. * malloc/malloc-walk.c: Likewise. * malloc/malloc.c: Likewise. * malloc/memalign.c: Likewise. * malloc/realloc.c: Likewise. * Makefile: Undo change from Mon Sep 2 22:15:14 1996. No more extra_solibs pass. * Rules: Likewise. * extra-lib.mk: Likewise. * manual/Makefile: Likewise. * db/Makefile (makedb): Choose dependecies based on build-shared. Patch by Andres Schwab. * sysdeps/posix/sysconf.c: Don't use PTHREAD_DESTRUCTOR_ITERATIONS but _POSIX_THREAD_DESTRUCTOR_ITERATIONS. * sysdeps/unix/sysv/linux/errnos.h: New file. * sysdeps/unix/sysv/linux/schedbits.h: New file. * sysdeps/unix/sysv/linux/waitflags.h: New file. * sysdeps/unix/sysv/linux/gnu/types.h: Add definition of `key_t'. Fri Sep 6 08:26:31 1996 Andreas Schwab * rpm/template: Fix typo in %build section. Fri Sep 6 03:31:07 1996 Ulrich Drepper * sysdeps/unix/sysv/linux/errnos.h: Don't define errno macro when building libc without thread support. * resolv/netdb.h: Likewise for h_errno macro. Thu Sep 5 23:01:48 1996 Ulrich Drepper * libc-symbols.h: Add new macro weak_const_function. It's like weak_function, but the function is additionally marked as const. * features.h: Only include if !__ASSEMBLER__. Thu Sep 5 22:55:49 1996 Richard Henderson * inet/herrno.c (__h_errno_location): New function. (h_errno): Make strong_alias __h_errno so that we can access the variable even if `h_errno' is a macro. * resolv/netdb.h: Define macro h_errno to access thread specific version of h_errno variable. Declare alias __h_errno for h_errno. * resolv/res_query (h_errno): Remove definition. * sysdeps/unix/sysv/linux/errnos.h [!__ASSEMBLER__ && __USE_REENTRANT]: Add macro `errno' to get thread specific variable. * sysdeps/unix/alpha/sysdep.S [_LIBC_REENTRANT]: Set errno using __errno_location function. (__errno_location): New function. Thu Sep 5 21:08:44 1996 Ulrich Drepper * posix/gnu/types.h: Remove definition of key_t. * sysdeps/generic/gnu/types.h: Move it to here. * sysdeps/unix/sysv/linux/gnu/types.h: Add Linux specific definition of key_t. * sysdeps/unix/sysv/linux/waitflags.h: New file. Linux specific definitions. * sysdeps/unix/sysv/linux/schedbits.h: New file. Include clone prototypes and associated flags. Thu Sep 5 08:58:47 1996 Richard Henderson * sysdeps/alpha/elf/start.S: Make _start global again. hertz. here. Wed Sep 4 16:16:13 1996 Ulrich Drepper * sysdeps/mach/hurd/send.c (__send): De-ANSI-fy. * sysdeps/mach/hurd/sendto.c (sendto): Likewise. --- ChangeLog | 212 +++++++++++++++++++++++++++++++++- Makeconfig | 26 +++-- Makefile | 8 +- Rules | 3 +- config.make.in | 2 +- configure | 3 + configure.in | 2 + db/Makefile | 6 +- extra-lib.mk | 4 +- features.h | 2 + inet/herrno.c | 14 ++- libc-symbols.h | 2 + libio/Makefile | 9 ++ libio/clearerr.c | 4 +- libio/clearerr_u.c | 2 +- libio/feof_u.c | 2 + libio/ferror_u.c | 2 + libio/fgetc.c | 5 +- libio/fileno.c | 4 +- libio/fputc.c | 5 +- libio/fputc_u.c | 2 +- libio/freopen.c | 5 +- libio/fseek.c | 9 +- libio/genops.c | 4 +- libio/getc.c | 5 +- libio/getc_u.c | 2 +- libio/getchar.c | 5 +- libio/getchar_u.c | 2 +- libio/iofclose.c | 3 +- libio/iofdopen.c | 33 +++--- libio/iofflush.c | 7 +- libio/iofgetpos.c | 5 +- libio/iofgets.c | 3 +- libio/ioflockfile.c | 43 +++++++ libio/iofopen.c | 27 +++-- libio/iofopncook.c | 28 +++-- libio/iofputs.c | 3 +- libio/iofread.c | 3 +- libio/iofsetpos.c | 3 +- libio/ioftell.c | 5 +- libio/iofwrite.c | 5 +- libio/iogetdelim.c | 5 +- libio/iogets.c | 5 +- libio/iopopen.c | 16 ++- libio/ioputs.c | 5 +- libio/iosetbuffer.c | 3 +- libio/iosetvbuf.c | 5 +- libio/ioungetc.c | 3 +- libio/iovsprintf.c | 3 + libio/iovsscanf.c | 2 + libio/libio.h | 5 +- libio/libioP.h | 1 + libio/memstream.c | 32 ++--- libio/putc.c | 5 +- libio/putchar.c | 5 +- libio/putchar_u.c | 4 +- libio/rewind.c | 5 +- libio/stdio.h | 36 ++++-- libio/vasprintf.c | 2 + libio/vdprintf.c | 2 + libio/vsnprintf.c | 2 + manual/Makefile | 2 +- posix/sys/types.h | 6 - resolv/netdb.h | 11 ++ resolv/res_query.c | 2 +- rpm/template | 2 +- stdio-common/vfprintf.c | 29 +++-- stdio-common/vfscanf.c | 22 +++- sysdeps/alpha/elf/start.S | 1 + sysdeps/generic/gnu/types.h | 3 + sysdeps/generic/prof-freq.c | 57 +++++++++ sysdeps/i386/dl-machine.h | 7 +- sysdeps/mach/hurd/prof-freq.c | 2 + sysdeps/posix/sysconf.c | 4 +- sysdeps/stub/libc-lock.h | 6 + sysdeps/unix/alpha/sysdep.S | 56 ++++++++- sysdeps/unix/i386/sysdep.S | 27 ++++- sysdeps/unix/opendir.c | 2 +- sysdeps/unix/sysv/linux/errnos.h | 32 +++++ sysdeps/unix/sysv/linux/gnu/types.h | 4 + sysdeps/unix/sysv/linux/i386/sysdep.S | 32 ++++- sysdeps/unix/sysv/linux/i386/sysdep.h | 31 ++++- sysdeps/unix/sysv/linux/schedbits.h | 51 ++++++++ sysdeps/unix/sysv/linux/waitflags.h | 30 +++++ 84 files changed, 886 insertions(+), 198 deletions(-) create mode 100644 libio/ioflockfile.c create mode 100644 sysdeps/unix/sysv/linux/schedbits.h create mode 100644 sysdeps/unix/sysv/linux/waitflags.h diff --git a/ChangeLog b/ChangeLog index 5169639b0e..dbec91baea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,204 @@ +Sat Sep 7 05:15:45 1996 Ulrich Drepper + + * libio/iofdopen: Initialize _lock field only if _IO_MTSAFE_IO. + * libio/iofopen: Likewise. + * libio/iofopncook.c: Likewise. + * libio/iopopen.c: Likewise. + * libio/iovsprintf.c: Likewise. + * libio/iovsscanf.c: Likewise. + * libio/memstream.c: Likewise. + * libio/vasprintf.c: Likewise. + * libio/vdprintf.c: Likewise. + * libio/vsnprintf.c: Likewise. + +Sat Sep 7 03:55:47 1996 Ulrich Drepper + + * Makeconfig (soversions.mk): Also use shlib-versions files + in add-on directories. + * config.make.in (config-defines): Remove. Not used anymore. + (defines): New variable. Initiliazed by @DEFINES@. + * configure.in: Add AC_SUBST(DEFINES). + + * libio/Makefile (routines): When compiling reentrant libc add + clearerr_u, feof_u, ferror_u, fputc_u, getc_u, getchar_u, + iofflush_u, putc_u, putchar_u, ioflockfile. + (CPPFLAGS): Add -D_IO_MTSAFE_IO for reentrant libc. + + * sysdeps/stub/libc-lock.h: Add stubs for __libc_cleanup_region_start + and __libc_cleanup_region_end. + + * sysdeps/unix/i386/sysdep.S [_LIBC_REENTRANT]: Set errno + using __errno_location function. + * sysdeps/unix/sysv/linux/i386/sysdep.S [_LIBC_REENTRANT]: Set errno + using __errno_location function. + (__errno_location): New function. + * sysdeps/unix/sysv/linux/i386/sysdep.h [PIC]: Add second + syscall_error handler for reentrant libc. + + * sysdeps/unix/opendir.c: Remove unneeded `;'. + + * libio.h [_IO_MTSAFE_IO]: Include . + [!_IO_MTSAFE_IO]: Define _IO_flockfile and _IO_funlockfile + as empty macros. + * libioP.h: Include . + * libio/stdio.h: Add prototypes for *_locked and *_unlocked + functions. + + * libio/clearerr.c: Use _IO_ protected versions of flockfile + and funlockfile to be namespace clean. + + * libio/genops.c: Use __libc_lock_* macros for handling lock. + + * libio/iofdopen: Add initialization of _lock in _IO_FILE. + * libio/iofopen: Likewise. + * libio/iofopncook.c: Likewise. + * libio/iopopen.c: Likewise. + * libio/iovsprintf.c: Likewise. + * libio/iovsscanf.c: Likewise. + * libio/memstream.c: Likewise. + * libio/vasprintf.c: Likewise. + * libio/vdprintf.c: Likewise. + * libio/vsnprintf.c: Likewise. + + * libio/fgetc.c: Use __libc_cleanup_region_* macros instead + of flockfile etc. + * libio/fputc.c: Likewise. + * libio/freopen.c: Likewise. + * libio/fseek.c: Likewise. + * libio/getc.c: Likewise. + * libio/getchar.c: Likewise. + * libio/iofclose.c: Likewise. + * libio/iofflush.c: Likewise. + * libio/iofgetpos.c: Likewise. + * libio/iofgets.c: Likewise. + * libio/iofputs.c: Likewise. + * libio/iofread.c: Likewise. + * libio/iofsetpos.c: Likewise. + * libio/ioftell.c: Likewise. + * libio/iofwrite.c: Likewise. + * libio/iogetdelim.c: Likewise. + * libio/iogets.c: Likewise. + * libio/ioputs.c: Likewise. + * libio/iosetbuffer.c: Likewise. + * libio/iosetvbuf.c: Likewise. + * libio/ioungetc.c: Likewise. + * libio/putc.c: Likewise. + * libio/putchar.c: Likewise. + * libio/rewind.c: Likewise. + * stdio-common/vfprintf.c: Likewise. + * stdio-common/vfscanf.c: Likewise. + + * libio/clearerr_u.c: Correct alias name. + * libio/ferror_u.c: Likewise. + * libio/fileno.c: Likewise. + * libio/fputc_u.c: Likewise. + * libio/getc.c: Likewise. + * libio/getc_u.c: Likewise. + * libio/getchar.c: Likewise. + * libio/getchar_u.c: Likewise. + * libio/putc.c: Likewise. + * libio/putchar.c: Likewise. + + * libio/feof_u.c: Undefine macro with name of function before + definition of function itself. + + * libio/ioflockfile.c: New file. Implementation of flockfile and + funlockfile. + + * libio/putchar_u.c: Fix typo. Use stdout instead of fp. + + * malloc/malloc.h: Don't include and don't declare + _malloc_loc. + + * malloc/free.c: Include . + * malloc/realloc.c: Likewise. + * malloc/malloc-find.c: Likewise. + * malloc/malloc-size.c: Likewise. + * malloc/malloc-walk.c: Likewise. + * malloc/memalign.c: Likewise. + * malloc/malloc.c: Likewise. + + * sysdeps/i386/dl-machine.h: Correct clearing of _dl_starting_up. + +Fri Sep 6 19:38:49 1996 Ulrich Drepper + + * sysdeps/stub/libc-lock.h: Define __libc_lock_critical_start + and __libc_lock_critical_end as empty macros. + + * malloc/malloc.h: Don't include and don't declare + __libc_malloc_lock. + * malloc/free.c: Include . + * malloc/malloc-find.c: Likewise. + * malloc/malloc-size.c: Likewise. + * malloc/malloc-walk.c: Likewise. + * malloc/malloc.c: Likewise. + * malloc/memalign.c: Likewise. + * malloc/realloc.c: Likewise. + + * Makefile: Undo change from Mon Sep 2 22:15:14 1996. No more + extra_solibs pass. + * Rules: Likewise. + * extra-lib.mk: Likewise. + * manual/Makefile: Likewise. + + * db/Makefile (makedb): Choose dependecies based on build-shared. + Patch by Andres Schwab. + + * sysdeps/posix/sysconf.c: Don't use PTHREAD_DESTRUCTOR_ITERATIONS + but _POSIX_THREAD_DESTRUCTOR_ITERATIONS. + + * sysdeps/unix/sysv/linux/errnos.h: New file. + * sysdeps/unix/sysv/linux/schedbits.h: New file. + * sysdeps/unix/sysv/linux/waitflags.h: New file. + + * sysdeps/unix/sysv/linux/gnu/types.h: Add definition of `key_t'. + +Fri Sep 6 08:26:31 1996 Andreas Schwab + + * rpm/template: Fix typo in %build section. + +Fri Sep 6 03:31:07 1996 Ulrich Drepper + + * sysdeps/unix/sysv/linux/errnos.h: Don't define errno macro when + building libc without thread support. + * resolv/netdb.h: Likewise for h_errno macro. + +Thu Sep 5 23:01:48 1996 Ulrich Drepper + + * libc-symbols.h: Add new macro weak_const_function. It's like + weak_function, but the function is additionally marked as const. + * features.h: Only include if !__ASSEMBLER__. + +Thu Sep 5 22:55:49 1996 Richard Henderson + + * inet/herrno.c (__h_errno_location): New function. + (h_errno): Make strong_alias __h_errno so that we can access + the variable even if `h_errno' is a macro. + * resolv/netdb.h: Define macro h_errno to access thread specific + version of h_errno variable. Declare alias __h_errno for h_errno. + * resolv/res_query (h_errno): Remove definition. + * sysdeps/unix/sysv/linux/errnos.h [!__ASSEMBLER__ && __USE_REENTRANT]: + Add macro `errno' to get thread specific variable. + * sysdeps/unix/alpha/sysdep.S [_LIBC_REENTRANT]: Set errno using + __errno_location function. + (__errno_location): New function. + +Thu Sep 5 21:08:44 1996 Ulrich Drepper + + * posix/gnu/types.h: Remove definition of key_t. + * sysdeps/generic/gnu/types.h: Move it to here. + * sysdeps/unix/sysv/linux/gnu/types.h: Add Linux specific + definition of key_t. + + * sysdeps/unix/sysv/linux/waitflags.h: New file. Linux specific + definitions. + * sysdeps/unix/sysv/linux/schedbits.h: New file. Include + clone prototypes and associated flags. + +Thu Sep 5 08:58:47 1996 Richard Henderson + + * sysdeps/alpha/elf/start.S: Make _start global again. + Thu Sep 5 13:18:25 1996 Thomas Bushnell, n/BSG * sysdeps/mach/hurd/i386/init-first.c (__libc_argc, __libc_argv): @@ -7,7 +208,7 @@ Thu Sep 5 13:18:25 1996 Thomas Bushnell, n/BSG available, pass __libc_argv in call to __proc_set_arg_locations. * gmon/gmon.c (write_hist): Call __profile_frequency instead of - hertz. + hertz. (hertz): Delete function. * gmon/Makefile (routines): Add `prof-freq'. * sysdeps/generic/prof-freq.c: New file. @@ -22,10 +223,10 @@ Thu Sep 5 13:18:25 1996 Thomas Bushnell, n/BSG * Rules (generated): Restore reference to $(generated). * mach/Machrules (mig.uh, mig.__h): Don't include $(user-MIGFLAGS) - here. + here. * malloc/free.c (free): __lib_malloc_lock -> __libc_malloc_lock. - + * malloc/free.c: Provide extern decl of __libc_malloc_lock. * malloc/realloc.c: Likewise. * malloc/malloc-find.c: Likewise. @@ -162,6 +363,11 @@ Sat Aug 31 03:07:39 1996 Ulrich Drepper * intl/l10nflist.c (_nl_normalize_codeset): We convert to lower case, so don't prepend uppercase `ISO' for only numeric arg. +Wed Sep 4 16:16:13 1996 Ulrich Drepper + + * sysdeps/mach/hurd/send.c (__send): De-ANSI-fy. + * sysdeps/mach/hurd/sendto.c (sendto): Likewise. + Tue Sep 3 11:16:07 1996 Thomas Bushnell/ n/BSG * shadow/lckpwdf.c (__ulckpwdf): Don't take address of LOCK in diff --git a/Makeconfig b/Makeconfig index e62608da45..38589e7ebe 100644 --- a/Makeconfig +++ b/Makeconfig @@ -523,17 +523,23 @@ ifeq (yes, $(build-shared)) # version numbers to use when we install shared objects on this system. -include $(common-objpfx)soversions.mk $(common-objpfx)soversions.mk: $(..)shlib-versions $(..)Makeconfig \ + $(wildcard $(patsubst %, $(..)%/shlib-versions,\ + $(add-ons))) \ $(common-objpfx)config.make - sed 's/#.*$$//' $< | while read conf versions; do \ - test -n "$$versions" || continue; \ - case '$(config-machine)-$(config-vendor)-$(config-os)' in $$conf)\ - for v in $$versions; do \ - lib=`echo $$v | sed 's/=.*$$//'`; \ - if eval "test -z \"\$$vers_lib$$lib\""; then \ - eval vers_lib$${lib}=yes; \ - echo $$v | sed "s/^.*=/$$lib.so-version=./"; \ - fi; \ - done ;; esac; done > $@T; exit 0 + (file="$(..)shlib-versions \ + $(wildcard $(patsubst %,$(..)%/shlib-versions,$(add-ons)))"; \ + for f in $$file; do \ + sed 's/#.*$$//' $$f | while read conf versions; do \ + test -n "$$versions" || continue; \ + case '$(config-machine)-$(config-vendor)-$(config-os)' in $$conf)\ + for v in $$versions; do \ + lib=`echo $$v | sed 's/=.*$$//'`; \ + if eval "test -z \"\$$vers_lib$$lib\""; then \ + eval vers_lib$${lib}=yes; \ + echo $$v | sed "s/^.*=/$$lib.so-version=./"; \ + fi; \ + done ;; esac; done; \ + done;) > $@T; exit 0 mv -f $@T $@ # Get $(version) defined with the release version number. diff --git a/Makefile b/Makefile index b502895f09..039e3c90bd 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ endif # This is the default target; it makes everything except the tests. .PHONY: all -all: lib extra_solibs others +all: lib others define autoconf-it @-rm -f $@.new @@ -73,9 +73,9 @@ subdirs := $(filter mach,$(subdirs)) $(filter hurd,$(subdirs)) \ # These are the targets that are made by making them in each subdirectory. -+subdir_targets := subdir_lib extra_solibs objects objs others \ - subdir_mostlyclean subdir_clean subdir_distclean \ - subdir_realclean tests subdir_lint.out \ ++subdir_targets := subdir_lib objects objs others subdir_mostlyclean \ + subdir_clean subdir_distclean subdir_realclean \ + tests subdir_lint.out \ subdir_distinfo \ subdir_echo-headers subdir_echo-distinfo \ subdir_install \ diff --git a/Rules b/Rules index 8984967947..b6215f59e0 100644 --- a/Rules +++ b/Rules @@ -107,14 +107,13 @@ $(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence. endif # tests .PHONY: distclean realclean subdir_distclean subdir_realclean \ - subdir_clean subdir_mostlyclean extra_solibs + subdir_clean subdir_mostlyclean subdir_mostlyclean: mostlyclean subdir_clean: clean subdir_distclean: distclean subdir_realclean: realclean realclean: distclean distclean: clean -extra_solibs: .PHONY: subdir_echo-headers subdir_echo-headers: echo-headers diff --git a/config.make.in b/config.make.in index 614d1d2ae5..c52910ea85 100644 --- a/config.make.in +++ b/config.make.in @@ -13,7 +13,7 @@ config-vendor = @host_vendor@ config-os = @host_os@ config-sysdirs = @sysnames@ -config-defines = @DEFS@ +defines = @DEFINES@ elf = @elf@ have-initfini = @libc_cv_have_initfini@ diff --git a/configure b/configure index 68aa0d7053..d2f0c3c569 100755 --- a/configure +++ b/configure @@ -1754,6 +1754,8 @@ fi + + if test "`(cd $srcdir; pwd)`" = "`pwd`"; then config_makefile= else @@ -1912,6 +1914,7 @@ s%@elf@%$elf%g s%@shared@%$shared%g s%@profile@%$profile%g s%@omitfp@%$omitfp%g +s%@DEFINES@%$DEFINES%g CEOF EOF diff --git a/configure.in b/configure.in index d5370f897e..ce9f61d967 100644 --- a/configure.in +++ b/configure.in @@ -668,6 +668,8 @@ fi AC_SUBST(profile) AC_SUBST(omitfp) +AC_SUBST(DEFINES) + if test "`(cd $srcdir; pwd)`" = "`pwd`"; then config_makefile= else diff --git a/db/Makefile b/db/Makefile index 9613c2e370..37dc282893 100644 --- a/db/Makefile +++ b/db/Makefile @@ -39,4 +39,8 @@ CFLAGS-hash_func.c := -Wno-unused # The db code outsmarts the compiler frequently. override CFLAGS += -Wno-uninitialized -LDLIBS-makedb := db/libdb +ifeq ($(build_shared),yes) +$(objpfx)makedb: $(objpfx)libdb.so$(libdb.so-version) +else +$(objpfx)makedb: $(objpfx)libdb.a +endif diff --git a/extra-lib.mk b/extra-lib.mk index 1db7520a34..e6088943e2 100644 --- a/extra-lib.mk +++ b/extra-lib.mk @@ -28,7 +28,7 @@ alltypes-$(lib) := $(foreach o,$(object-suffixes-$(lib)),\ ifeq (,$(filter $(lib),$(extra-libs-others))) lib-noranlib: $(alltypes-$(lib)) ifeq (yes,$(build-shared)) -extra_solibs: $(objpfx)$(lib).so$($(lib).so-version) +lib-noranlib: $(objpfx)$(lib).so$($(lib).so-version) endif else others: $(alltypes-$(lib)) @@ -37,7 +37,7 @@ endif # The linked shared library is never a dependent of lib-noranlib, # because linking it will depend on libc.so already being built. ifneq (,$(filter .so,$(object-suffixes-$(lib)))) -extra_solibs: $(objpfx)$(lib).so +others: $(objpfx)$(lib).so endif diff --git a/features.h b/features.h index 4aee806ba8..47a4124502 100644 --- a/features.h +++ b/features.h @@ -160,7 +160,9 @@ Cambridge, MA 02139, USA. */ /* This is here only because every header file already includes this one. */ +#ifndef __ASSEMBLER__ #include +#endif /* This is here only because every header file already includes this one. */ #ifndef _LIBC diff --git a/inet/herrno.c b/inet/herrno.c index 7e413adf7a..312760e81d 100644 --- a/inet/herrno.c +++ b/inet/herrno.c @@ -16,7 +16,19 @@ 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 + /* We need to have the error status variable of the resolver accessible in the libc. */ -int h_errno; +int __h_errno; +strong_alias (__h_errno, h_errno) +/* When threaded, h_errno may be a per-process variable. */ +#ifdef __USE_REENTRANT +int +weak_const_function +__h_errno_location (void) +{ + return &__h_errno; +} +#endif diff --git a/libc-symbols.h b/libc-symbols.h index 2f72d5fa7a..c64d8826f7 100644 --- a/libc-symbols.h +++ b/libc-symbols.h @@ -202,6 +202,7 @@ extern const char _libc_intl_domainname[]; /* This comes between the return type and function name in a function definition to make that definition weak. */ #define weak_function __attribute__ ((weak)) +#define weak_const_function __attribute__ ((weak, __const__)) #endif /* HAVE_WEAK_SYMBOLS. */ #endif /* Not ASSEMBLER, and GCC 2.7 or later. */ @@ -213,6 +214,7 @@ extern const char _libc_intl_domainname[]; directive for the function symbol, and a `.weak' directive in addition will produce an error from the assembler. */ #define weak_function /* empty */ +#define weak_const_function /* empty */ #endif diff --git a/libio/Makefile b/libio/Makefile index e4df6b545e..355a79a0e5 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -36,6 +36,15 @@ routines := \ \ libc_fatal +include ../Makeconfig + +ifneq (,$(filter %REENTRANT, $(defines))) +routines += clearerr_u feof_u ferror_u fputc_u getc_u getchar_u \ + iofflush_u putc_u putchar_u ioflockfile + +CPPFLAGS += -D_IO_MTSAFE_IO +endif + aux := \ cleanup fileops genops stdfiles stdio strops diff --git a/libio/clearerr.c b/libio/clearerr.c index 669a9b0d74..9dfdb11530 100644 --- a/libio/clearerr.c +++ b/libio/clearerr.c @@ -24,9 +24,9 @@ clearerr (fp) FILE *fp; { CHECK_FILE (fp, /*nothing*/); - flockfile (fp); + _IO_flockfile (fp); _IO_clearerr (fp); - funlockfile (fp); + _IO_funlockfile (fp); } #ifdef _IO_MTSAFE_IO diff --git a/libio/clearerr_u.c b/libio/clearerr_u.c index 83ed65d8b1..4c8b6c29bd 100644 --- a/libio/clearerr_u.c +++ b/libio/clearerr_u.c @@ -27,4 +27,4 @@ __clearerr_unlocked (fp) _IO_clearerr (fp); } -weak_alias (clearerr_unlocked, __clearerr_unlocked) +weak_alias (__clearerr_unlocked, clearerr_unlocked) diff --git a/libio/feof_u.c b/libio/feof_u.c index 5ce5583613..6ed8b7d4fe 100644 --- a/libio/feof_u.c +++ b/libio/feof_u.c @@ -24,6 +24,8 @@ the executable file might be covered by the GNU General Public License. */ #include "libioP.h" #include "stdio.h" +#undef feof_unlocked + int feof_unlocked (fp) _IO_FILE* fp; diff --git a/libio/ferror_u.c b/libio/ferror_u.c index bee668d6d9..df550d9d4d 100644 --- a/libio/ferror_u.c +++ b/libio/ferror_u.c @@ -24,6 +24,8 @@ the executable file might be covered by the GNU General Public License. */ #include "libioP.h" #include "stdio.h" +#undef ferror_unlocked + int ferror_unlocked (fp) _IO_FILE* fp; diff --git a/libio/fgetc.c b/libio/fgetc.c index 2aaea05cfe..07fd89a516 100644 --- a/libio/fgetc.c +++ b/libio/fgetc.c @@ -31,8 +31,9 @@ fgetc (fp) { int result; CHECK_FILE (fp, EOF); - flockfile (fp); + __libc_cleanup_region_start (_IO_funlockfile, fp); + _IO_flockfile (fp); result = _IO_getc_unlocked (fp); - funlockfile (fp); + __libc_cleanup_region_end (1); return result; } diff --git a/libio/fileno.c b/libio/fileno.c index 2dc67149c8..08e657b970 100644 --- a/libio/fileno.c +++ b/libio/fileno.c @@ -42,6 +42,6 @@ fileno (fp) it only accesses once a single variable and this is already atomic (at least at thread level). */ -weak_alias (fileno_unlocked, fileno) -weak_alias (fileno_locked, fileno) +weak_alias (fileno, fileno_unlocked) +weak_alias (fileno, fileno_locked) #endif diff --git a/libio/fputc.c b/libio/fputc.c index 339861119f..bd871ab047 100644 --- a/libio/fputc.c +++ b/libio/fputc.c @@ -32,8 +32,11 @@ fputc (c, fp) { int result; CHECK_FILE (fp, EOF); + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); result = _IO_putc_unlocked (c, fp); - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); return result; } + +weak_alias (fputc, fputc_locked) diff --git a/libio/fputc_u.c b/libio/fputc_u.c index 211e206605..97e4d94eb3 100644 --- a/libio/fputc_u.c +++ b/libio/fputc_u.c @@ -36,4 +36,4 @@ __fputc_unlocked (c, fp) return _IO_putc_unlocked (c, fp); } -weak_alias (fputc_unlocked, __fputc_unlocked) +weak_alias (__fputc_unlocked, fputc_unlocked) diff --git a/libio/freopen.c b/libio/freopen.c index 829af31dc1..5821e84c6f 100644 --- a/libio/freopen.c +++ b/libio/freopen.c @@ -35,8 +35,9 @@ freopen (filename, mode, fp) CHECK_FILE (fp, NULL); if (!(fp->_flags & _IO_IS_FILEBUF)) return NULL; - flockfile (fp); + __libc_cleanup_region_start (&_IO_funlockfile, fp); + _IO_flockfile (fp); result = _IO_freopen (filename, mode, fp); - funlockfile (fp); + __libc_cleanup_region_end (1); return result; } diff --git a/libio/fseek.c b/libio/fseek.c index 5255e9defe..c33927a95f 100644 --- a/libio/fseek.c +++ b/libio/fseek.c @@ -1,5 +1,5 @@ /* -Copyright (C) 1993, 1995 Free Software Foundation +Copyright (C) 1993, 1995, 1996 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 @@ -22,8 +22,8 @@ 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 "stdio.h" #include "libioP.h" +#include "stdio.h" int fseek (fp, offset, whence) @@ -33,8 +33,9 @@ fseek (fp, offset, whence) { int result; CHECK_FILE (fp, -1); - flockfile (fp); + __libc_cleanup_region_start (&_IO_funlockfile, fp); + _IO_flockfile (fp); result = _IO_fseek (fp, offset, whence); - funlockfile (fp); + __libc_cleanup_region_end (1); return result; } diff --git a/libio/genops.c b/libio/genops.c index 98eef94b58..818e740851 100644 --- a/libio/genops.c +++ b/libio/genops.c @@ -466,7 +466,7 @@ DEFUN(_IO_init, (fp, flags), fp->_markers = NULL; fp->_cur_column = 0; #ifdef _IO_MTSAFE_IO - _IO_mutex_init (fp->_lock); + __libc_lock_init (fp->_lock); #endif } @@ -501,7 +501,7 @@ DEFUN(_IO_default_finish, (fp), } #ifdef _IO_MTSAFE_IO - _IO_mutex_destroy (fp->_lock); + __libc_lock_fini (fp->_lock); #endif _IO_un_link(fp); diff --git a/libio/getc.c b/libio/getc.c index 89abc0dac0..82e5756ad3 100644 --- a/libio/getc.c +++ b/libio/getc.c @@ -33,14 +33,15 @@ getc (fp) { int result; CHECK_FILE (fp, EOF); + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); result = _IO_getc_unlocked (fp); - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); return result; } #ifdef _IO_MTSAFE_IO # undef getc_locked -weak_alias (getc_locked, getc) +weak_alias (getc, getc_locked) #endif diff --git a/libio/getc_u.c b/libio/getc_u.c index e6491bb944..4aa5cd5ccd 100644 --- a/libio/getc_u.c +++ b/libio/getc_u.c @@ -35,4 +35,4 @@ __getc_unlocked (fp) return _IO_getc_unlocked (fp); } -weak_alias (getc_unlocked, __getc_unlocked) +weak_alias (__getc_unlocked, getc_unlocked) diff --git a/libio/getchar.c b/libio/getchar.c index fa5c11f731..e7a236cf2e 100644 --- a/libio/getchar.c +++ b/libio/getchar.c @@ -31,14 +31,15 @@ int getchar () { int result; + __libc_cleanup_region_start (&_IO_funlockfile, stdin); _IO_flockfile (stdin); result = _IO_getc_unlocked (stdin); - _IO_funlockfile (stdin); + __libc_cleanup_region_end (1); return result; } #ifdef _IO_MTSAFE_IO # undef getchar_locked -weak_alias (getchar_locked, getchar) +weak_alias (getchar, getchar_locked) #endif diff --git a/libio/getchar_u.c b/libio/getchar_u.c index 40cfbf6625..0430f8119c 100644 --- a/libio/getchar_u.c +++ b/libio/getchar_u.c @@ -33,4 +33,4 @@ __getchar_unlocked () return _IO_getc_unlocked (stdin); } -weak_alias (getchar_unlocked, __getchar_unlocked) +weak_alias (__getchar_unlocked, getchar_unlocked) diff --git a/libio/iofclose.c b/libio/iofclose.c index e5cae966fd..9d537377a4 100644 --- a/libio/iofclose.c +++ b/libio/iofclose.c @@ -35,6 +35,7 @@ _IO_fclose (fp) CHECK_FILE(fp, EOF); + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); if (fp->_IO_file_flags & _IO_IS_FILEBUF) status = _IO_file_close_it (fp); @@ -46,7 +47,7 @@ _IO_fclose (fp) fp->_IO_file_flags = 0; free(fp); } - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); return status; } diff --git a/libio/iofdopen.c b/libio/iofdopen.c index 6bb19fa214..c49387b1a0 100644 --- a/libio/iofdopen.c +++ b/libio/iofdopen.c @@ -39,7 +39,11 @@ _IO_fdopen (fd, mode) { int read_write; int posix_mode = 0; - struct _IO_FILE_plus *fp; + struct locked_FILE + { + struct _IO_FILE_plus fp; + _IO_lock_t lock; + } *new_f; int fd_flags; switch (*mode++) @@ -97,28 +101,29 @@ _IO_fdopen (fd, mode) } #endif - fp = (struct _IO_FILE_plus *) malloc (sizeof (struct _IO_FILE_plus)); - if (fp == NULL) + new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE)); + if (new_f == NULL) return NULL; - _IO_init (&fp->file, 0); - _IO_JUMPS (&fp->file) = &_IO_file_jumps; - _IO_file_init (&fp->file); + new_f->fp.file._lock = &new_f->lock; + _IO_init (&new_f->fp.file, 0); + _IO_JUMPS (&new_f->fp.file) = &_IO_file_jumps; + _IO_file_init (&new_f->fp.file); #if !_IO_UNIFIED_JUMPTABLES - fp->vtable = NULL; + new_f->fp.vtable = NULL; #endif - if (_IO_file_attach (&fp->file, fd) == NULL) + if (_IO_file_attach (&new_f->fp.file, fd) == NULL) { - _IO_un_link (&fp->file); - free (fp); + _IO_un_link (&new_f->fp.file); + free (new_f); return NULL; } - fp->file._flags &= ~_IO_DELETE_DONT_CLOSE; + new_f->fp.file._flags &= ~_IO_DELETE_DONT_CLOSE; - fp->file._IO_file_flags = - _IO_mask_flags (&fp->file, read_write, + new_f->fp.file._IO_file_flags = + _IO_mask_flags (&new_f->fp.file, read_write, _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING); - return (_IO_FILE *) fp; + return (_IO_FILE *) &new_f->fp; } weak_alias (_IO_fdopen, fdopen) diff --git a/libio/iofflush.c b/libio/iofflush.c index 6fe2d5262d..cbc5b1f6d7 100644 --- a/libio/iofflush.c +++ b/libio/iofflush.c @@ -1,5 +1,5 @@ /* -Copyright (C) 1993, 1995 Free Software Foundation +Copyright (C) 1993, 1995, 1996 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 @@ -33,10 +33,11 @@ _IO_fflush (fp) else { int result; - _IO_flockfile (fp); CHECK_FILE (fp, EOF); + __libc_cleanup_region_start (&_IO_funlockfile, fp); + _IO_flockfile (fp); result = _IO_SYNC (fp) ? EOF : 0; - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); return result; } } diff --git a/libio/iofgetpos.c b/libio/iofgetpos.c index 50014765f9..c45cfacb06 100644 --- a/libio/iofgetpos.c +++ b/libio/iofgetpos.c @@ -1,5 +1,5 @@ /* -Copyright (C) 1993, 1995 Free Software Foundation +Copyright (C) 1993, 1995, 1996 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 @@ -33,9 +33,10 @@ _IO_fgetpos (fp, posp) { _IO_fpos_t pos; CHECK_FILE (fp, EOF); + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); pos = _IO_seekoff (fp, 0, _IO_seek_cur, 0); - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); if (pos == _IO_pos_BAD) { #ifdef EIO diff --git a/libio/iofgets.c b/libio/iofgets.c index 88d4bd518e..369251f22a 100644 --- a/libio/iofgets.c +++ b/libio/iofgets.c @@ -35,6 +35,7 @@ _IO_fgets (buf, n, fp) CHECK_FILE (fp, NULL); if (n <= 0) return NULL; + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); count = _IO_getline (fp, buf, n - 1, '\n', 1); if (count == 0 || (fp->_IO_file_flags & _IO_ERR_SEEN)) @@ -44,7 +45,7 @@ _IO_fgets (buf, n, fp) buf[count] = '\0'; result = buf; } - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); return result; } diff --git a/libio/ioflockfile.c b/libio/ioflockfile.c new file mode 100644 index 0000000000..a68f4b662d --- /dev/null +++ b/libio/ioflockfile.c @@ -0,0 +1,43 @@ +/* +Copyright (C) 1996 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. */ + +#include "libioP.h" +#include + +void +_IO_flockfile (s) + _IO_FILE *s; +{ + __libc_lock_lock (s->_lock); +} +weak_alias (_IO_flockfile, flockfile) + + +void +_IO_funlockfile (s) + _IO_FILE *s; +{ + __libc_lock_unlock (s->_lock); +} +weak_alias (_IO_funlockfile, funlockfile) diff --git a/libio/iofopen.c b/libio/iofopen.c index 14cce5336a..334df4652a 100644 --- a/libio/iofopen.c +++ b/libio/iofopen.c @@ -32,20 +32,25 @@ _IO_fopen (filename, mode) const char *filename; const char *mode; { - struct _IO_FILE_plus *fp = - (struct _IO_FILE_plus *) malloc (sizeof (struct _IO_FILE_plus)); - if (fp == NULL) + struct locked_FILE + { + struct _IO_FILE_plus fp; + _IO_lock_t lock; + } *new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE)); + + if (new_f == NULL) return NULL; - _IO_init (&fp->file, 0); - _IO_JUMPS (&fp->file) = &_IO_file_jumps; - _IO_file_init (&fp->file); + new_f->fp.file._lock = &new_f->lock; + _IO_init (&new_f->fp.file, 0); + _IO_JUMPS (&new_f->fp.file) = &_IO_file_jumps; + _IO_file_init (&new_f->fp.file); #if !_IO_UNIFIED_JUMPTABLES - fp->vtable = NULL; + new_f->fp.vtable = NULL; #endif - if (_IO_file_fopen (&fp->file, filename, mode) != NULL) - return (_IO_FILE *) fp; - _IO_un_link (&fp->file); - free (fp); + if (_IO_file_fopen (&new_f->fp.file, filename, mode) != NULL) + return (_IO_FILE *) &new_f->fp; + _IO_un_link (&new_f->fp.file); + free (new_f); return NULL; } diff --git a/libio/iofopncook.c b/libio/iofopncook.c index 989f6d6fe7..4193c2447d 100644 --- a/libio/iofopncook.c +++ b/libio/iofopncook.c @@ -128,7 +128,11 @@ fopencookie (cookie, mode, io_functions) _IO_cookie_io_functions_t io_functions; { int read_write; - struct _IO_cookie_file *cfile; + struct locked_FILE + { + struct _IO_cookie_file cfile; + _IO_lock_t lock; + } *new_f; switch (*mode++) { @@ -147,21 +151,21 @@ fopencookie (cookie, mode, io_functions) if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+')) read_write &= _IO_IS_APPENDING; - cfile = (struct _IO_cookie_file *) malloc (sizeof (struct _IO_cookie_file)); - if (cfile == NULL) + new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE)); + if (new_f == NULL) return NULL; + new_f->cfile.file._lock = &new_f->lock; - _IO_init (&cfile->file, 0); - _IO_JUMPS (&cfile->file) = &_IO_cookie_jumps; - cfile->cookie = cookie; - cfile->io_functions = io_functions; + _IO_init (&new_f->cfile.file, 0); + _IO_JUMPS (&new_f->cfile.file) = &_IO_cookie_jumps; + new_f->cfile.cookie = cookie; + new_f->cfile.io_functions = io_functions; - _IO_file_init(&cfile->file); + _IO_file_init(&new_f->cfile.file); - cfile->file._IO_file_flags = - _IO_mask_flags (&cfile->file, read_write, + new_f->cfile.file._IO_file_flags = + _IO_mask_flags (&new_f->cfile.file, read_write, _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING); - return &cfile->file; + return &new_f->cfile.file; } - diff --git a/libio/iofputs.c b/libio/iofputs.c index 3359515ac8..a9fd5f29a3 100644 --- a/libio/iofputs.c +++ b/libio/iofputs.c @@ -33,12 +33,13 @@ _IO_fputs (str, fp) _IO_size_t len = strlen (str); int result; CHECK_FILE (fp, EOF); + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); if (_IO_sputn (fp, str, len) != len) result = EOF; else result = 1; - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); return result; } diff --git a/libio/iofread.c b/libio/iofread.c index bad94ca17b..af6bc33f24 100644 --- a/libio/iofread.c +++ b/libio/iofread.c @@ -36,9 +36,10 @@ _IO_fread (buf, size, count, fp) CHECK_FILE (fp, 0); if (bytes_requested == 0) return 0; + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); bytes_read = _IO_sgetn (fp, (char *) buf, bytes_requested); - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); return bytes_requested == bytes_read ? count : bytes_read / size; } weak_alias (_IO_fread, fread) diff --git a/libio/iofsetpos.c b/libio/iofsetpos.c index c8897522d6..96c3a7a2a0 100644 --- a/libio/iofsetpos.c +++ b/libio/iofsetpos.c @@ -32,6 +32,7 @@ _IO_fsetpos (fp, posp) { int result; CHECK_FILE (fp, EOF); + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); if (_IO_seekpos (fp, *posp, _IOS_INPUT|_IOS_OUTPUT) == _IO_pos_BAD) { @@ -44,7 +45,7 @@ _IO_fsetpos (fp, posp) } else result = 0; - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); return result; } diff --git a/libio/ioftell.c b/libio/ioftell.c index d49f8c3553..12b90b37f5 100644 --- a/libio/ioftell.c +++ b/libio/ioftell.c @@ -1,5 +1,5 @@ /* -Copyright (C) 1993, 1995 Free Software Foundation +Copyright (C) 1993, 1995, 1996 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 @@ -32,9 +32,10 @@ _IO_ftell (fp) { _IO_pos_t pos; CHECK_FILE (fp, -1L); + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); pos = _IO_seekoff (fp, 0, _IO_seek_cur, 0); - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); if (pos == _IO_pos_BAD) { #ifdef EIO diff --git a/libio/iofwrite.c b/libio/iofwrite.c index 0bbeef2646..4ee489d2b1 100644 --- a/libio/iofwrite.c +++ b/libio/iofwrite.c @@ -1,5 +1,5 @@ /* -Copyright (C) 1993 Free Software Foundation +Copyright (C) 1993, 1996 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 @@ -36,9 +36,10 @@ _IO_fwrite (buf, size, count, fp) CHECK_FILE (fp, 0); if (request == 0) return 0; + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); written = _IO_sputn (fp, (const char *) buf, request); - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); /* Many traditional implementations return 0 if size==0 && count > 0, but ANSI seems to require us to return count in this case. */ if (written == request) diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c index 1d14551615..0acd76e6c5 100644 --- a/libio/iogetdelim.c +++ b/libio/iogetdelim.c @@ -1,5 +1,5 @@ /* -Copyright (C) 1994 Free Software Foundation +Copyright (C) 1994, 1996 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 @@ -54,6 +54,7 @@ _IO_getdelim (lineptr, n, delimiter, fp) return -1; } CHECK_FILE (fp, -1); + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); if (_IO_ferror_unlocked (fp)) { @@ -115,7 +116,7 @@ _IO_getdelim (lineptr, n, delimiter, fp) result = cur_len; unlock_return: - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); return result; } diff --git a/libio/iogets.c b/libio/iogets.c index 352e80244b..8fdc4350a9 100644 --- a/libio/iogets.c +++ b/libio/iogets.c @@ -1,5 +1,5 @@ /* -Copyright (C) 1993 Free Software Foundation +Copyright (C) 1993, 1996 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 @@ -32,6 +32,7 @@ _IO_gets (buf) _IO_size_t count; int ch; + __libc_cleanup_region_start (&_IO_funlockfile, _IO_stdin); _IO_flockfile (_IO_stdin); ch = _IO_getc_unlocked (_IO_stdin); if (ch == EOF) @@ -45,7 +46,7 @@ _IO_gets (buf) if (_IO_stdin->_IO_file_flags & _IO_ERR_SEEN) return NULL; } - _IO_funlockfile (_IO_stdin); + __libc_cleanup_region_end (1); buf[count] = 0; return buf; } diff --git a/libio/iopopen.c b/libio/iopopen.c index 5b9bd4844d..ca2a18edac 100644 --- a/libio/iopopen.c +++ b/libio/iopopen.c @@ -149,10 +149,18 @@ _IO_FILE * DEFUN(_IO_popen, (command, mode), const char *command AND const char *mode) { - _IO_proc_file *fpx = (_IO_proc_file*)malloc(sizeof(_IO_proc_file)); - _IO_FILE *fp = (_IO_FILE*)fpx; - if (fp == NULL) + struct locked_FILE + { + struct _IO_proc_file fpx; + _IO_lock_t lock; + } *new_f; + _IO_FILE *fp; + + new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE)); + if (new_f == NULL) return NULL; + new_f->fpx.file.file._lock = &new_f->lock; + fp = (_IO_FILE*)&new_f->fpx; _IO_init(fp, 0); _IO_JUMPS(fp) = &_IO_proc_jumps; _IO_file_init(fp); @@ -161,7 +169,7 @@ DEFUN(_IO_popen, (command, mode), #endif if (_IO_proc_open (fp, command, mode) != NULL) return fp; - free (fpx); + free (new_f); return NULL; } diff --git a/libio/ioputs.c b/libio/ioputs.c index 6c52f7521c..2770ab2935 100644 --- a/libio/ioputs.c +++ b/libio/ioputs.c @@ -30,13 +30,14 @@ _IO_puts (str) { int result; _IO_size_t len = strlen (str); - _IO_flockfile (fp); + __libc_cleanup_region_start (&_IO_funlockfile, _IO_stdout); + _IO_flockfile (_IO_stdout); if (_IO_sputn (_IO_stdout, str, len) == len && _IO_putc_unlocked ('\n', _IO_stdout) != EOF) result = len + 1; else result = EOF; - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); return result; } weak_alias (_IO_puts, puts) diff --git a/libio/iosetbuffer.c b/libio/iosetbuffer.c index d3fc7e5917..e44f33962f 100644 --- a/libio/iosetbuffer.c +++ b/libio/iosetbuffer.c @@ -31,12 +31,13 @@ _IO_setbuffer (fp, buf, size) _IO_size_t size; { CHECK_FILE (fp, ); + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); fp->_flags &= ~_IO_LINE_BUF; if (!buf) size = 0; (void) _IO_SETBUF (fp, buf, size); - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); } weak_alias (_IO_setbuffer, setbuffer) diff --git a/libio/iosetvbuf.c b/libio/iosetvbuf.c index 6d4bcff2bc..e9dccae529 100644 --- a/libio/iosetvbuf.c +++ b/libio/iosetvbuf.c @@ -1,5 +1,5 @@ /* -Copyright (C) 1993 Free Software Foundation +Copyright (C) 1993, 1996 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 @@ -37,6 +37,7 @@ _IO_setvbuf (fp, buf, mode, size) { int result; CHECK_FILE (fp, EOF); + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); switch (mode) { @@ -88,7 +89,7 @@ _IO_setvbuf (fp, buf, mode, size) } result = _IO_SETBUF (fp, buf, size) == NULL ? EOF : 0; unlock_return: - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); return result; } diff --git a/libio/ioungetc.c b/libio/ioungetc.c index c1237b5f9b..cc414083f8 100644 --- a/libio/ioungetc.c +++ b/libio/ioungetc.c @@ -33,9 +33,10 @@ _IO_ungetc (c, fp) CHECK_FILE (fp, EOF); if (c == EOF) return EOF; + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); result = _IO_sputbackc (fp, (unsigned char) c); - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); return result; } diff --git a/libio/iovsprintf.c b/libio/iovsprintf.c index 2c5d77503d..916804f63d 100644 --- a/libio/iovsprintf.c +++ b/libio/iovsprintf.c @@ -32,7 +32,10 @@ _IO_vsprintf (string, format, args) _IO_va_list args; { _IO_strfile sf; + _IO_lock_t lock; int ret; + + sf._f._lock = &lock; _IO_init ((_IO_FILE *) &sf, 0); _IO_JUMPS ((_IO_FILE *) &sf) = &_IO_str_jumps; _IO_str_init_static ((_IO_FILE *) &sf, string, -1, string); diff --git a/libio/iovsscanf.c b/libio/iovsscanf.c index dcd3e92902..5b4c790517 100644 --- a/libio/iovsscanf.c +++ b/libio/iovsscanf.c @@ -30,6 +30,8 @@ DEFUN(_IO_vsscanf, (string, format, args), const char *string AND const char *format AND _IO_va_list args) { _IO_strfile sf; + _IO_lock_t lock; + sf._f._lock = &lock; _IO_init((_IO_FILE*)&sf, 0); _IO_JUMPS((_IO_FILE*)&sf) = &_IO_str_jumps; _IO_str_init_static ((_IO_FILE*)&sf, (char*)string, 0, NULL); diff --git a/libio/libio.h b/libio/libio.h index b498f125eb..17cef91121 100644 --- a/libio/libio.h +++ b/libio/libio.h @@ -150,6 +150,7 @@ typedef struct /* Handle lock. */ #ifdef _IO_MTSAFE_IO +#include typedef pthread_mutex_t _IO_lock_t; #else typedef void _IO_lock_t; @@ -272,10 +273,10 @@ extern int _IO_putc_locked __P ((int, _IO_FILE *)); extern void _IO_flockfile __P ((_IO_FILE *)); extern void _IO_funlockfile __P ((_IO_FILE *)); -#if !defined(_REENTRANT) && !defined(_THREAD_SAFE) +#ifndef _IO_MTSAFE_IO # define _IO_flockfile(FILE) /**/ # define _IO_funlockfile(FILE) /**/ -#endif /* _REENTRANT || _THREAD_SAFE */ +#endif /* !_IO_MTSAFE_IO */ extern int _IO_vfscanf __P((_IO_FILE*, const char*, _IO_va_list, int*)); diff --git a/libio/libioP.h b/libio/libioP.h index 8525b71827..ac4df17ce8 100644 --- a/libio/libioP.h +++ b/libio/libioP.h @@ -26,6 +26,7 @@ the executable file might be covered by the GNU General Public License. */ #ifndef errno extern int errno; #endif +#include #include "iolibio.h" diff --git a/libio/memstream.c b/libio/memstream.c index a2fe8447cb..1a4f4b9e96 100644 --- a/libio/memstream.c +++ b/libio/memstream.c @@ -16,8 +16,8 @@ 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 "strfile.h" #include "libioP.h" +#include "strfile.h" #include #include @@ -64,26 +64,30 @@ open_memstream (bufloc, sizeloc) char **bufloc; _IO_size_t *sizeloc; { - struct _IO_FILE_memstream *fp; + struct locked_FILE + { + struct _IO_FILE_memstream fp; + _IO_lock_t lock; + } *new_f; char *buf; - fp = (struct _IO_FILE_memstream *) - malloc (sizeof (struct _IO_FILE_memstream)); - if (fp == NULL) + new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE)); + if (new_f == NULL) return NULL; + new_f->fp._sf._f._lock = &new_f->lock; buf = ALLOC_BUF (_IO_BUFSIZ); - _IO_init (&fp->_sf._f, 0); - _IO_JUMPS (&fp->_sf._f) = &_IO_mem_jumps; - _IO_str_init_static (&fp->_sf._f, buf, _IO_BUFSIZ, buf); - fp->_sf._f._flags &= ~_IO_USER_BUF; - fp->_sf._s._allocate_buffer = (_IO_alloc_type) malloc; - fp->_sf._s._free_buffer = (_IO_free_type) free; + _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; + new_f->fp._sf._s._allocate_buffer = (_IO_alloc_type) malloc; + new_f->fp._sf._s._free_buffer = (_IO_free_type) free; - fp->bufloc = bufloc; - fp->sizeloc = sizeloc; + new_f->fp.bufloc = bufloc; + new_f->fp.sizeloc = sizeloc; - return &fp->_sf._f; + return &new_f->fp._sf._f; } diff --git a/libio/putc.c b/libio/putc.c index 23595ab7b5..5dff3de304 100644 --- a/libio/putc.c +++ b/libio/putc.c @@ -28,14 +28,15 @@ putc (c, fp) { int result; CHECK_FILE (fp, EOF); + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); result = _IO_putc_unlocked (c, fp); - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); return result; } #ifdef _IO_MTSAFE_IO # undef putc_locked -weak_alias (putc_locked, putc) +weak_alias (putc, putc_locked) #endif diff --git a/libio/putchar.c b/libio/putchar.c index d4d52f60d2..a7891a5a2a 100644 --- a/libio/putchar.c +++ b/libio/putchar.c @@ -26,14 +26,15 @@ putchar (c) int c; { int result; + __libc_cleanup_region_start (&_IO_funlockfile, _IO_stdout); _IO_flockfile (_IO_stdout); result = _IO_putc_unlocked (c, _IO_stdout); - _IO_funlockfile (_IO_stdout); + __libc_cleanup_region_end (1); return result; } #ifdef _IO_MTSAFE_IO # undef putchar_locked -weak_alias (putchar_locked, putchar) +weak_alias (putchar, putchar_locked) #endif diff --git a/libio/putchar_u.c b/libio/putchar_u.c index d29652aadc..4c52d638b7 100644 --- a/libio/putchar_u.c +++ b/libio/putchar_u.c @@ -25,6 +25,6 @@ int putchar_unlocked (c) int c; { - CHECK_FILE (fp, EOF); - return _IO_putc_unlocked (c, fp); + CHECK_FILE (stdout, EOF); + return _IO_putc_unlocked (c, stdout); } diff --git a/libio/rewind.c b/libio/rewind.c index 2f57e0de83..d30233e17e 100644 --- a/libio/rewind.c +++ b/libio/rewind.c @@ -21,15 +21,16 @@ 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 "stdio.h" #include "libioP.h" +#include "stdio.h" void rewind (fp) _IO_FILE* fp; { CHECK_FILE (fp, ); + __libc_cleanup_region_start (&_IO_funlockfile, fp); _IO_flockfile (fp); _IO_rewind (fp); - _IO_funlockfile (fp); + __libc_cleanup_region_end (1); } diff --git a/libio/stdio.h b/libio/stdio.h index 048a11d60c..0d6c5e6741 100644 --- a/libio/stdio.h +++ b/libio/stdio.h @@ -206,39 +206,51 @@ extern const char *const _sys_errlist[]; #endif /* Handle locking of streams. */ -#if defined(_REENTRANT) || defined(_THREAD_SAFE) +#ifdef __USE_REENTRANT +extern void clearerr_locked __P ((FILE *)); extern void clearerr_unlocked __P ((FILE *)); -extern void fileno_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 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_fgetc (fp) +# define getc_locked(fp) fgetc (fp) # define getchar_unlocked() getc_unlocked (stdin) # define getchar_locked() getc_locked (stdin) # define getc(fp) getc_locked (fp) -# define putc_unlocked(c, fp) _IO_putc_unlocked (c, fp) -# define putc_locked(c, fp) _IO_putc_locked (c, fp) +# define putc_unlocked(c, fp) putc_unlocked (c, fp) +# define putc_locked(c, fp) putc_locked (c, fp) # define putchar_unlocked(c) putc_unlocked (c, stdout) # define putchar_locked(c) putc_locked (c, stdout) # define putc(c, fp) putc_locked (c, fp) -# define feof_unlocked(fp) _IO_feof_unlocked (fp) -# define ferror_unlocked(fp) _IO_ferror_unlocked (fp) - #else # define getc(fp) _IO_getc_unlocked (fp) # define putc(c, fp) _IO_putc_unlocked (c, fp) -#endif /* _REENTRANT || _THREAD_SAFE */ - -#define flockfile(FILE) _IO_flockfile (FILE) -#define funlockfile(FILE) _IO_funlockfile (FILE) +#endif /* __USE_REENTRANT */ #define putchar(c) putc (c, stdout) #define getchar() getc (stdin) diff --git a/libio/vasprintf.c b/libio/vasprintf.c index ee92f83b1c..cf50603f0d 100644 --- a/libio/vasprintf.c +++ b/libio/vasprintf.c @@ -38,10 +38,12 @@ _IO_vasprintf (result_ptr, format, args) const _IO_size_t init_string_size = 100; char *string; _IO_strfile sf; + _IO_lock_t lock; int ret; string = ALLOC_BUF(init_string_size); if (string == NULL) return -1; + sf._f._lock = &lock; _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); diff --git a/libio/vdprintf.c b/libio/vdprintf.c index b92251eada..8c5833ccbf 100644 --- a/libio/vdprintf.c +++ b/libio/vdprintf.c @@ -32,8 +32,10 @@ _IO_vdprintf (d, format, arg) _IO_va_list arg; { struct _IO_FILE_plus tmpfil; + _IO_lock_t lock; int done; + tmpfil.file._lock = &lock; _IO_init (&tmpfil.file, 0); _IO_JUMPS (&tmpfil.file) = &_IO_file_jumps; _IO_file_init (&tmpfil.file); diff --git a/libio/vsnprintf.c b/libio/vsnprintf.c index 38f91c9c07..174640daac 100644 --- a/libio/vsnprintf.c +++ b/libio/vsnprintf.c @@ -33,7 +33,9 @@ _IO_vsnprintf (string, maxlen, format, args) _IO_va_list args; { _IO_strfile sf; + _IO_lock_t lock; int ret; + sf._f._lock = &lock; _IO_init ((_IO_FILE *) &sf, 0); _IO_JUMPS ((_IO_FILE *) &sf) = &_IO_str_jumps; _IO_str_init_static ((_IO_FILE *) &sf, string, maxlen - 1, string); diff --git a/manual/Makefile b/manual/Makefile index f8bd1cd87c..c0a5782ea7 100644 --- a/manual/Makefile +++ b/manual/Makefile @@ -155,7 +155,7 @@ subdir_%: ; # ../Rules defines them for code subdirectories; for us, they are no-ops. # None of these should be `subdir_TARGET'; those targets are transformed # by the implicit rule above into `TARGET' deps. -glibc-targets := lib extra_solibs objects objs others tests lint.out \ +glibc-targets := lib objects objs others tests lint.out \ echo-headers echo-distinfo stubs .PHONY: $(glibc-targets) $(glibc-targets): diff --git a/posix/sys/types.h b/posix/sys/types.h index e8d382d64d..55b6fd0f80 100644 --- a/posix/sys/types.h +++ b/posix/sys/types.h @@ -114,12 +114,6 @@ typedef int register_t __attribute__ ((__mode__ (__word__))); #endif -#ifdef __USE_SVID -/* Data type for key value used in System V IPC functions. */ -typedef long int key_t; -#endif - - #ifdef __USE_BSD /* In BSD is expected to define BYTE_ORDER. */ #include diff --git a/resolv/netdb.h b/resolv/netdb.h index cca3060826..1269443cb9 100644 --- a/resolv/netdb.h +++ b/resolv/netdb.h @@ -43,6 +43,17 @@ __BEGIN_DECLS /* Error status for non-reentrant lookup functions. */ extern int h_errno; +#if defined __USE_REENTRANT && (!defined _LIBC || defined _LIBC_REENTRANT) +/* Function to access thread specific `h_errno' variable. */ +extern int *__h_errno_location __P ((void)) __attribute__ ((__const__)); + +/* An alias name for above variable. */ +extern int __h_errno; + +/* Use a macro to access always the thread specific `h_errno' variable. */ +#define h_errno (*__h_errno_location ()) +#endif + /* Possible values left in `h_errno'. */ #define NETDB_INTERNAL -1 /* See errno. */ #define NETDB_SUCCESS 0 /* No problem. */ diff --git a/resolv/res_query.c b/resolv/res_query.c index 7ee6be7663..135c6aa5c0 100644 --- a/resolv/res_query.c +++ b/resolv/res_query.c @@ -87,7 +87,7 @@ static char rcsid[] = "$Id$"; #endif char *__hostalias __P((const char *)); -int h_errno; + /* * Formulate a normal query, send, and await answer. diff --git a/rpm/template b/rpm/template index 7b03ed5ab2..7b24ac1d82 100644 --- a/rpm/template +++ b/rpm/template @@ -11,7 +11,7 @@ Source: glibc-@VERSION@.tar.gz %build configure --prefix=@prefix@ -if test x@prefix@ = /usr; then +if test x@prefix@ = x/usr; then cat >configparms <_IO_file_flags & _IO_UNBUFFERED) +# define flockfile(S) _IO_flockfile (S) +/* This macro must be without parameter! Don't change it. */ +# define funlockfile _IO_funlockfile #else /* ! USE_IN_LIBIO */ /* This code is for use in the GNU C library. */ # include @@ -398,7 +401,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap) #define process_arg(fspec) \ - /* Start real work. We know about all flag and modifiers and \ + /* Start real work. We know about all flags and modifiers and \ now process the wanted format specifier. */ \ LABEL (form_percent): \ /* Write a literal "%". */ \ @@ -846,6 +849,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap) f = lead_str_end = find_spec (format, &mbstate); /* Lock stream. */ + __libc_cleanup_region_start ((void (*) (void *)) &funlockfile, s); flockfile (s); /* Write the literal text before the first format. */ @@ -854,10 +858,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap) /* If we only have to print a simple string, return now. */ if (*f == L_('\0')) - { - funlockfile (s); - return done; - } + goto all_done; /* Process whole format string. */ do @@ -1025,8 +1026,8 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap) if (spec == L_('\0')) { /* The format string ended before the specifier is complete. */ - funlockfile (s); - return -1; + done = -1; + goto all_done; } /* If we are in the fast loop force entering the complicated @@ -1042,11 +1043,8 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap) } while (*f != L_('\0')); - /* Unlock stream. */ - funlockfile (s); - - /* We processed the whole format without any positional parameters. */ - return done; + /* Unlock stream and return. */