From 0e3426bbcf2ff61d06d580fc9362fde79953a281 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 8 May 1996 02:07:47 +0000 Subject: Tue May 7 19:00:01 1996 Roland McGrath * string/argz-extract.c: Remove const from decl. * string/argz.h: Here too. * Makeconfig (version.mk): Fix regexp in sed cmd. Depend on $(..)Makeconfig. * GMP code updated from gmp-2.0 release. * stdlib/Makefile (mpn-routines): Removed add_1, added inlines. * sysdeps/generic/add_1.c: File removed. * stdlib/strtod.c: mp_limb is now mp_limb_t. * stdlib/fpioconst.c, stdlib/fpioconst.h: Likewise. * stdio-common/_itoa.c: Likewise. * stdio-common/printf_fp.c: Likewise. Don't include ansidecl.h. * sysdeps/mach/hurd/getcwd.c: Use io_identity instead of io_stat. * shlib-versions: New file. * Makerules (soversions.mk): New target, include file generated from shlib-versions. Moved shared library rules before installation rules. Rewrote shared library installation rules for versioned libraries. * math/Makefile (libm.so-version): Variable removed. * sysdeps/mach/hurd/i386/exc2signal.c: Use struct hurd_signal_detail. * hurd/report-wait.c (_S_msg_describe_ports): New function. * configure.in: Add AC_PROG_LN_S check. * config.make.in (LN_S): New variable. Sun May 5 03:10:44 1996 Ulrich Drepper * misc/efgcvt_r.c (ecvt_r): Work aroung gcc bug. gcc does not know about weak aliases now and optimizes necessary `if' statement away. * posix/unistd.h: Add swapoff prototype. * sysdeps/generic/confname.h: Add even more POSIX.4 symbols. * sysdeps/posix/fpathconf.c (__fpathconf): Get information for _PC_PATH_MAX from fstatfs function if available. * sysdeps/posix/sysconf.c: Add code to handle _SC_AIO_LISTIO_MAX, _SC_AIO_MAX, _SC_AIO_PRIO_DELTA_MAX, _SC_DELAYTIMER_MAX, _SC_MQ_OPEN_MAX, _SC_MQ_PRIO_MAX, _SC_RTSIG_MAX, _SC_SEM_NSEMS_MAX, _SC_SEM_VALUE_MAX, _SC_SIGQUEUE_MAX, and _SC_TIMER_MAX. * sysdeps/unix/sysv/sysv4/sysconf.c: Ditto. * sysdeps/stub/swapoff.c: New file. Stub version for swapoff function. * sysdeps/unix/syscalls.list: Add swapoff. * sysdeps/unix/sysv/linux/Dist: Add sys/acct.h. * sysdeps/unix/sysv/linux/Makefile [$(subdir) == misc] (sysdep_routines): Add mount, umount, llseek, setfsgid, setfsuid, sysinfo, and uselib. (headers): Add sys/sysinfo.h. * sysdeps/unix/sysv/linux/gethostid.c: Prevent warning. * sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) == misc] (sysdep_routines): Add ioperm, iopl, and vm86. (headers): Add sys/perm.h and sys/vm86.h. * sysdeps/unix/sysv/linux/i386/sys/perm.h: New file. Contains prototypes for iopl and ioperm. * sysdeps/unix/sysv/linux/i386/sys/vm86.h: New file. Contains prototype for vm86. * sysdeps/unix/sysv/linux/i386/syscalls.list: New file. Add vm86 system call. * sysdeps/unix/sysv/linux/sys/acct.h: New file. Contains prototypes for acct function. * sysdeps/unix/sysv/linux/sys/socket.h: Provide real header file with prototypes. * sysdeps/unix/sysv/linux/sys/sysinfo.h: New file. Contains prototype for sysinfo function. * sysdeps/unix/sysv/linux/syscalls.list: Add flock, ioperm, iopl, llseek, setfsgid, setfsuid, sysinfo, and uselib. * sysdeps/unix/sysv/linux/sysconf.c: Instead of duplicating posix/sysconf.c now only handle cases different to that implementation. Tue May 7 15:08:19 1996 Miles Bader * stdio/linewrap.c (__line_wrap_output): Renamed from lwoutput (all references changed). Now exported. * stdio/linewrap.c (struct data): Type deleted (moved to linewrap.h). (wrap_stream, unwrap_stream, lwclose, lwfileno, lwoutput, line_wrap_stream, line_unwrap_stream): Use struct line_wrap_data instead of struct data. (lwoutput, line_wrap_stream, line_unwrap_stream): Rename various occurences of `wrap' and `wrapmargin' to `wmargin'. (line_wrapped, line_wrap_lmargin, line_wrap_set_lmargin, line_wrap_rmargin, line_wrap_set_rmargin, line_wrap_wmargin, line_wrap_set_wmargin, line_wrap_point): New functions. * stdio/linewrap.h: New file. * stdio/Makefile (headers): Add linewrap.h. Tue May 7 14:19:12 1996 Roland McGrath * sysdeps/unix/sysv/linux/i386/Makefile: File removed. * stdio/stdio.h: Remove line_wrap_stream, line_unwap_stream decls. * sysdeps/unix/sysv/linux/schedbits.h: New file. Tue May 7 13:47:02 1996 Miles Bader * stdio/linewrap.c (struct data): Make margin fields not-pointers. (lwoutput): Adjust uses acordingly. * sysdeps/mach/hurd/fdatasync.c: New file. * sysdeps/mach/hurd/fsync.c: Pass new flag to file_sync. * sysdeps/mach/hurd/xmknod.c: Pass new flag to dir_link. * sysdeps/mach/hurd/symlink.c: Likewise. * sysdeps/mach/hurd/link.c: Likewise. * sysdeps/mach/hurd/bind.c: Likewise. * hurd/hurdsig.c (write_corefile): Likewise. * hurd/hurdsig.c (write_corefile): Pass cttyid port to crash server. * sysdeps/mach/hurd/fpathconf.c: RPC takes int pointer, not long int. * sysdeps/mach/hurd/_exit.c (_hurd_exit): Pass sigcode arg to proc_mark_exit. * sysdeps/mach/hurd/dl-sysdep.c (_exit): Likewise. * sysdeps/mach/hurd/wait4.c: Pass sigcode arg to proc_wait. * sysdeps/mach/hurd/rename.c: Pass new flag to dir_rename. * hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise): Use struct hurd_signal_detail. * hurd/catch-exc.c (_S_catch_exception_raise): Likewise. * hurd/hurd-raise.c (_hurd_raise_signal): Likewise. * sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): Likewise. * sysdeps/mach/hurd/setitimer.c (restart_itimer): Likewise. * hurd/hurd/signal.h: Fix _hurd_exception2signal prototype. * hurd/hurdsig.c (write_corefile): Take const struct hurd_signal_detail * arg. Pass all details to crash_dump_task. (_hurd_internal_post_signal): Pass DETAIL to write_corefile. (_hurd_internal_post_signal: suspend): Pass code and error to proc_mark_stop. * hurd/hurdprio.c (_hurd_priority_which_map): Pass flags arg to proc_getprocinfo by reference. --- ChangeLog | 165 ++++++++++++++++ Makeconfig | 6 +- Makerules | 164 +++++++++++----- config.make.in | 1 + configure.in | 3 +- hurd/catch-exc.c | 13 +- hurd/hurd-raise.c | 7 +- hurd/hurd/signal.h | 5 +- hurd/hurdfault.c | 12 +- hurd/hurdprio.c | 4 +- hurd/hurdsig.c | 34 ++-- hurd/report-wait.c | 25 +++ math/Makefile | 1 - misc/efgcvt_r.c | 4 +- posix/unistd.h | 3 + shlib-versions | 21 +++ stdio-common/_itoa.c | 72 +++---- stdio-common/printf_fp.c | 31 ++- stdio/linewrap.c | 183 ++++++++++++------ stdio/linewrap.h | 189 +++++++++++++++++++ stdio/stdio.h | 16 -- stdlib/Makefile | 2 +- stdlib/fpioconst.c | 56 +++--- stdlib/fpioconst.h | 2 +- stdlib/strtod.c | 90 ++++----- string/argz-extract.c | 2 +- string/argz.h | 4 +- sysdeps/generic/add_1.c | 61 ------ sysdeps/generic/confname.h | 22 +++ sysdeps/generic/inlines.c | 3 + sysdeps/mach/hurd/_exit.c | 6 +- sysdeps/mach/hurd/bind.c | 4 +- sysdeps/mach/hurd/dl-sysdep.c | 2 +- sysdeps/mach/hurd/fdatasync.c | 32 ++++ sysdeps/mach/hurd/fpathconf.c | 4 +- sysdeps/mach/hurd/fsync.c | 4 +- sysdeps/mach/hurd/getcwd.c | 59 +++--- sysdeps/mach/hurd/i386/exc2signal.c | 95 +++++----- sysdeps/mach/hurd/i386/trampoline.c | 4 +- sysdeps/mach/hurd/link.c | 4 +- sysdeps/mach/hurd/rename.c | 4 +- sysdeps/mach/hurd/setitimer.c | 3 +- sysdeps/mach/hurd/symlink.c | 8 +- sysdeps/mach/hurd/wait4.c | 5 +- sysdeps/mach/hurd/xmknod.c | 2 +- sysdeps/posix/fpathconf.c | 10 +- sysdeps/posix/sysconf.c | 77 ++++++++ sysdeps/stub/swapoff.c | 30 +++ sysdeps/unix/syscalls.list | 1 + sysdeps/unix/sysv/linux/Dist | 1 + sysdeps/unix/sysv/linux/Makefile | 5 +- sysdeps/unix/sysv/linux/gethostid.c | 6 +- sysdeps/unix/sysv/linux/i386/Makefile | 8 +- sysdeps/unix/sysv/linux/i386/sys/perm.h | 36 ++++ sysdeps/unix/sysv/linux/i386/sys/vm86.h | 34 ++++ sysdeps/unix/sysv/linux/i386/syscalls.list | 3 + sysdeps/unix/sysv/linux/schedbits.h | 1 + sysdeps/unix/sysv/linux/sys/acct.h | 34 ++++ sysdeps/unix/sysv/linux/sys/socket.h | 168 +++++++++++++++++ sysdeps/unix/sysv/linux/sys/sysinfo.h | 30 +++ sysdeps/unix/sysv/linux/syscalls.list | 10 +- sysdeps/unix/sysv/linux/sysconf.c | 294 ++--------------------------- sysdeps/unix/sysv/sysv4/sysconf.c | 77 ++++++++ 63 files changed, 1518 insertions(+), 744 deletions(-) create mode 100644 shlib-versions create mode 100644 stdio/linewrap.h delete mode 100644 sysdeps/generic/add_1.c create mode 100644 sysdeps/generic/inlines.c create mode 100644 sysdeps/mach/hurd/fdatasync.c create mode 100644 sysdeps/stub/swapoff.c create mode 100644 sysdeps/unix/sysv/linux/i386/sys/perm.h create mode 100644 sysdeps/unix/sysv/linux/i386/sys/vm86.h create mode 100644 sysdeps/unix/sysv/linux/i386/syscalls.list create mode 100644 sysdeps/unix/sysv/linux/schedbits.h create mode 100644 sysdeps/unix/sysv/linux/sys/acct.h create mode 100644 sysdeps/unix/sysv/linux/sys/sysinfo.h diff --git a/ChangeLog b/ChangeLog index be527d6ac2..866a3b44f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,170 @@ +Tue May 7 19:00:01 1996 Roland McGrath + + * string/argz-extract.c: Remove const from decl. + * string/argz.h: Here too. + + * Makeconfig (version.mk): Fix regexp in sed cmd. + Depend on $(..)Makeconfig. + + * GMP code updated from gmp-2.0 release. + * stdlib/Makefile (mpn-routines): Removed add_1, added inlines. + * sysdeps/generic/add_1.c: File removed. + * stdlib/strtod.c: mp_limb is now mp_limb_t. + * stdlib/fpioconst.c, stdlib/fpioconst.h: Likewise. + * stdio-common/_itoa.c: Likewise. + * stdio-common/printf_fp.c: Likewise. + Don't include ansidecl.h. + + * sysdeps/mach/hurd/getcwd.c: Use io_identity instead of io_stat. + + * shlib-versions: New file. + * Makerules (soversions.mk): New target, include file generated from + shlib-versions. Moved shared library rules before installation rules. + Rewrote shared library installation rules for versioned libraries. + * math/Makefile (libm.so-version): Variable removed. + + * sysdeps/mach/hurd/i386/exc2signal.c: Use struct hurd_signal_detail. + + * hurd/report-wait.c (_S_msg_describe_ports): New function. + + * configure.in: Add AC_PROG_LN_S check. + * config.make.in (LN_S): New variable. + +Sun May 5 03:10:44 1996 Ulrich Drepper + + * misc/efgcvt_r.c (ecvt_r): Work aroung gcc bug. gcc does + not know about weak aliases now and optimizes necessary `if' + statement away. + + * posix/unistd.h: Add swapoff prototype. + + * sysdeps/generic/confname.h: Add even more POSIX.4 symbols. + + * sysdeps/posix/fpathconf.c (__fpathconf): Get information + for _PC_PATH_MAX from fstatfs function if available. + + * sysdeps/posix/sysconf.c: Add code to handle _SC_AIO_LISTIO_MAX, + _SC_AIO_MAX, _SC_AIO_PRIO_DELTA_MAX, _SC_DELAYTIMER_MAX, + _SC_MQ_OPEN_MAX, _SC_MQ_PRIO_MAX, _SC_RTSIG_MAX, + _SC_SEM_NSEMS_MAX, _SC_SEM_VALUE_MAX, _SC_SIGQUEUE_MAX, and + _SC_TIMER_MAX. + * sysdeps/unix/sysv/sysv4/sysconf.c: Ditto. + + * sysdeps/stub/swapoff.c: New file. Stub version for swapoff + function. + + * sysdeps/unix/syscalls.list: Add swapoff. + + * sysdeps/unix/sysv/linux/Dist: Add sys/acct.h. + + * sysdeps/unix/sysv/linux/Makefile [$(subdir) == misc] + (sysdep_routines): Add mount, umount, llseek, setfsgid, setfsuid, + sysinfo, and uselib. + (headers): Add sys/sysinfo.h. + + * sysdeps/unix/sysv/linux/gethostid.c: Prevent warning. + + * sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) == misc] + (sysdep_routines): Add ioperm, iopl, and vm86. + (headers): Add sys/perm.h and sys/vm86.h. + + * sysdeps/unix/sysv/linux/i386/sys/perm.h: New file. Contains + prototypes for iopl and ioperm. + + * sysdeps/unix/sysv/linux/i386/sys/vm86.h: New file. Contains + prototype for vm86. + + * sysdeps/unix/sysv/linux/i386/syscalls.list: New file. Add + vm86 system call. + + * sysdeps/unix/sysv/linux/sys/acct.h: New file. Contains + prototypes for acct function. + + * sysdeps/unix/sysv/linux/sys/socket.h: Provide real header + file with prototypes. + + * sysdeps/unix/sysv/linux/sys/sysinfo.h: New file. Contains + prototype for sysinfo function. + + * sysdeps/unix/sysv/linux/syscalls.list: Add flock, ioperm, iopl, + llseek, setfsgid, setfsuid, sysinfo, and uselib. + + * sysdeps/unix/sysv/linux/sysconf.c: Instead of duplicating + posix/sysconf.c now only handle cases different to that + implementation. + +Tue May 7 15:08:19 1996 Miles Bader + + * stdio/linewrap.c (__line_wrap_output): Renamed from lwoutput + (all references changed). Now exported. + + * stdio/linewrap.c (struct data): Type deleted (moved to linewrap.h). + (wrap_stream, unwrap_stream, lwclose, lwfileno, lwoutput, + line_wrap_stream, line_unwrap_stream): Use struct line_wrap_data + instead of struct data. + (lwoutput, line_wrap_stream, line_unwrap_stream): Rename various + occurences of `wrap' and `wrapmargin' to `wmargin'. + (line_wrapped, line_wrap_lmargin, line_wrap_set_lmargin, + line_wrap_rmargin, line_wrap_set_rmargin, line_wrap_wmargin, + line_wrap_set_wmargin, line_wrap_point): New functions. + * stdio/linewrap.h: New file. + * stdio/Makefile (headers): Add linewrap.h. + +Tue May 7 14:19:12 1996 Roland McGrath + + * sysdeps/unix/sysv/linux/i386/Makefile: File removed. + + * stdio/stdio.h: Remove line_wrap_stream, line_unwap_stream decls. + + * sysdeps/unix/sysv/linux/schedbits.h: New file. + +Tue May 7 13:47:02 1996 Miles Bader + + * stdio/linewrap.c (struct data): Make margin fields not-pointers. + (lwoutput): Adjust uses acordingly. + Tue May 7 10:51:52 1996 Roland McGrath + * sysdeps/mach/hurd/fdatasync.c: New file. + * sysdeps/mach/hurd/fsync.c: Pass new flag to file_sync. + + * sysdeps/mach/hurd/xmknod.c: Pass new flag to dir_link. + * sysdeps/mach/hurd/symlink.c: Likewise. + * sysdeps/mach/hurd/link.c: Likewise. + * sysdeps/mach/hurd/bind.c: Likewise. + * hurd/hurdsig.c (write_corefile): Likewise. + + * hurd/hurdsig.c (write_corefile): Pass cttyid port to crash server. + + * sysdeps/mach/hurd/fpathconf.c: RPC takes int pointer, not long int. + + * sysdeps/mach/hurd/_exit.c (_hurd_exit): Pass sigcode arg to + proc_mark_exit. + * sysdeps/mach/hurd/dl-sysdep.c (_exit): Likewise. + + * sysdeps/mach/hurd/wait4.c: Pass sigcode arg to proc_wait. + + * sysdeps/mach/hurd/rename.c: Pass new flag to dir_rename. + + * hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise): Use struct + hurd_signal_detail. + * hurd/catch-exc.c (_S_catch_exception_raise): Likewise. + * hurd/hurd-raise.c (_hurd_raise_signal): Likewise. + * sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): + Likewise. + * sysdeps/mach/hurd/setitimer.c (restart_itimer): Likewise. + + * hurd/hurd/signal.h: Fix _hurd_exception2signal prototype. + + * hurd/hurdsig.c (write_corefile): Take const struct + hurd_signal_detail * arg. Pass all details to crash_dump_task. + (_hurd_internal_post_signal): Pass DETAIL to write_corefile. + (_hurd_internal_post_signal: suspend): Pass code and error to + proc_mark_stop. + + * hurd/hurdprio.c (_hurd_priority_which_map): Pass flags arg to + proc_getprocinfo by reference. + * wcsmbs/wcwidth.c, wcsmbs/wcswidth.c: Fixed typos. * sysdeps/unix/sysv/linux/sys/mman.h: Fixed typo. diff --git a/Makeconfig b/Makeconfig index e0522ab815..b9de4f3329 100644 --- a/Makeconfig +++ b/Makeconfig @@ -471,9 +471,9 @@ endif # Figure out the version numbers from version.h. -$(common-objpfx)version.mk: $(..)version.h - sed -n -e 's/^.*RELEASE.*\"\([^"]*\)";$$/release=\1/p' \ - -e 's/^.*VERSION.*\"\([^"]*\)";$$/version=\1/p' \ +$(common-objpfx)version.mk: $(..)version.h $(..)Makeconfig + sed -n -e 's/^.*RELEASE.*"\([^"]*\)".*$$/release=\1/p' \ + -e 's/^.*VERSION.*"\([^"]*\)".*$$/version=\1/p' \ < $< > $@-new mv -f $@-new $@ diff --git a/Makerules b/Makerules index 876134756f..47e5fb8b0f 100644 --- a/Makerules +++ b/Makerules @@ -428,6 +428,71 @@ $(AR) cru$(verbose) $(@:$(objpfx)%=%) \ $(RANLIB) $@ endef +# Shared library building. + +ifeq (yes,$(build-shared)) + +# Process the shlib-versions file, which tells us what shared library +# version numbers to use when we install shared objects on this system. +-include $(common-objpfx)soversions.mk +$(common-objpfx)soversions.mk: $(..)shlib-versions $(..)Makerules \ + $(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="$${v%%=*}"; if eval "test -z \"\$$vers_lib$$lib\""; then \ + eval vers_lib$${lib}=yes; \ + echo $$lib.so-version=.$${v##$$lib=}; fi; \ + done ;; esac; done > $@T + mv -f $@T $@ + +# Get $(version) defined with the release version number. +-include $(common-objpfx)version.mk + + +# Pattern rule to build a shared object from an archive of PIC objects. +# This must come after the installation rules so Make doesn't try to +# build shared libraries in place from the installed *_pic.a files. +# $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies +# on other shared objects. +lib%.so: lib%_pic.a; $(build-shlib) + +ifeq ($(have-no-whole-archive),yes) +no-whole-archive = -Wl,--no-whole-archive +else +no-whole-archive = +endif + +define build-shlib +$(LINK.o) -shared -o $@ $(sysdep-LDFLAGS) $(config-LDFLAGS) \ + -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \ + $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \ + -Wl,-rpath-link=$(common-objdir) \ + -Wl,--whole-archive $^ $(no-whole-archive) \ + $(LDLIBS-$(@F:lib%.so=%).so) +endef + +# Don't try to use -lc when making libc.so itself. +# Also omits crti.o and crtn.o, which we do not want +# since we define our own `.init' section specially. +LDFLAGS-c.so = -nostdlib -nostartfiles +# Give libc.so an entry point and make it directly runnable itself. +LDFLAGS-c.so += -e __libc_print_version +# Use our own special initializer and finalizer files for libc.so. +elfobjdir := $(firstword $(objdir) $(..)elf) +$(common-objpfx)libc.so: $(elfobjdir)/soinit.so \ + $(common-objpfx)libc_pic.a \ + $(elfobjdir)/sofini.so + $(build-shlib) + +ifdef libc.so-version +$(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so + rm -f $@ + ln -s $( libc.so.N (e.g. libc.so.6) +# libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so) + +$(slibdir)/libc.so: $(slibdir)/libc.so$(libc.so-version) + $(make-link) +$(slibdir)/libc.so$(libc.so-version): $(slibdir)/libc-$(version).so + $(make-link) +$(slibdir)/libc-$(version).so: $(common-objpfx)libc.so; $(do-install-program) +else +$(slibdir)/libc.so: $(common-objpfx)libc.so; $(do-install-program) +endif + + +ifneq (,$(versioned)) +# Produce three sets of rules as above for all the smaller versioned libraries. + +define o-iterator-doit +$$(libdir)/$o: $$(libdir)/$o$$($o-version); $$(make-link) +endef +object-suffixes-left := $(versioned) +include $(..)o-iterator.mk + +define o-iterator-doit +$$(libdir)/$o$$($o-version): $$(libdir)/$(o:.so=)-$$(version).so; $$(make-link) +endef +object-suffixes-left := $(versioned) +include $(..)o-iterator.mk + +define o-iterator-doit +$$(libdir)/$(o:.so=)-$$(version).so: $$(objpfx)$o; $$(do-install-program) +endef +object-suffixes-left := $(versioned) +include $(..)o-iterator.mk +endif define do-install-so $(do-install-program) @@ -561,50 +669,6 @@ install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\ install-others-nosubdir install-sbin-nosubdir install: install-no-libc.a-nosubdir -ifeq (yes,$(build-shared)) -# Pattern rule to build a shared object from an archive of PIC objects. -# This must come after the installation rules so Make doesn't try to -# build shared libraries in place from the installed *_pic.a files. -# $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies -# on other shared objects. -lib%.so: lib%_pic.a; $(build-shlib) - -ifeq ($(have-no-whole-archive),yes) -no-whole-archive = -Wl,--no-whole-archive -else -no-whole-archive = -endif - -define build-shlib -$(LINK.o) -shared -o $@ $(sysdep-LDFLAGS) $(config-LDFLAGS) \ - -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \ - $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \ - -Wl,-rpath-link=$(common-objdir) \ - -Wl,--whole-archive $^ $(no-whole-archive) \ - $(LDLIBS-$(@F:lib%.so=%).so) -endef - -# Don't try to use -lc when making libc.so itself. -# Also omits crti.o and crtn.o, which we do not want -# since we define our own `.init' section specially. -LDFLAGS-c.so = -nostdlib -nostartfiles -# Give libc.so an entry point and make it directly runnable itself. -LDFLAGS-c.so += -e __libc_print_version -# Use our own special initializer and finalizer files for libc.so. -elfobjdir := $(firstword $(objdir) $(..)elf) -$(common-objpfx)libc.so: $(elfobjdir)/soinit.so \ - $(common-objpfx)libc_pic.a \ - $(elfobjdir)/sofini.so - $(build-shlib) - -ifdef libc.so-version -$(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so - rm -f $@ - ln -s $(pending, signo); - ss->pending_data[signo].code = sigcode; - ss->pending_data[signo].error = sigerror; + ss->pending_data[signo] = *detail; __spin_unlock (&ss->lock); /* Send a message to the signal thread so it will wake up and check for pending signals. */ - __msg_sig_post (_hurd_msgport, signo, sigcode, __mach_task_self ()); + __msg_sig_post (_hurd_msgport, signo, detail->code, __mach_task_self ()); } diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h index 27349d3ed0..7dee18c1ed 100644 --- a/hurd/hurd/signal.h +++ b/hurd/hurd/signal.h @@ -233,7 +233,8 @@ extern void _hurd_raise_signal (struct hurd_sigstate *ss, int signo, /* Translate a Mach exception into a signal (machine-dependent). */ -extern void _hurd_exception2signal (struct hurd_signal_detail *); +extern void _hurd_exception2signal (struct hurd_signal_detail *detail, + int *signo); /* Make the thread described by SS take the signal described by SIGNO and @@ -259,7 +260,7 @@ extern void _hurd_internal_post_signal (struct hurd_sigstate *ss, struct machine_thread_all_state; extern struct sigcontext * _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler, - int signo, const struct hurd_signal_detail *detail, + int signo, struct hurd_signal_detail *detail, int rpc_wait, struct machine_thread_all_state *state); /* Function run by the signal thread to receive from the signal port. */ diff --git a/hurd/hurdfault.c b/hurd/hurdfault.c index bb6fa9576d..a8fe8fb07f 100644 --- a/hurd/hurdfault.c +++ b/hurd/hurdfault.c @@ -42,19 +42,21 @@ _hurdsig_fault_catch_exception_raise (mach_port_t port, int subcode) { int signo; - long int sigcode; - int sigerror; + struct hurd_signal_detail d; if (port != forward_sigexc || thread != _hurd_msgport_thread || task != __mach_task_self ()) return EPERM; /* Strange bogosity. */ + d.exc = exception; + d.exc_code = code; + d.exc_subcode = subcode; + /* Call the machine-dependent function to translate the Mach exception codes into a signal number and subcode. */ - _hurd_exception2signal (exception, code, subcode, - &signo, &sigcode, &sigerror); + _hurd_exception2signal (&d, &signo); - return HURD_PREEMPT_SIGNAL_P (&_hurdsig_fault_preempter, signo, sigcode) + return HURD_PREEMPT_SIGNAL_P (&_hurdsig_fault_preempter, signo, d.code) ? 0 : EGREGIOUS; } diff --git a/hurd/hurdprio.c b/hurd/hurdprio.c index bbbe317406..66ef41656d 100644 --- a/hurd/hurdprio.c +++ b/hurd/hurdprio.c @@ -1,5 +1,5 @@ /* Support code for dealing with priorities in the Hurd. -Copyright (C) 1994, 1995 Free Software Foundation, Inc. +Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -62,7 +62,7 @@ _hurd_priority_which_map (enum __priority_which which, int who, char *tw = 0; size_t twsz = 0; if (err = __USEPORT (PROC, __proc_getprocinfo (port, pids[i], - pi_flags, + &pi_flags, &pi, &pisize, &tw, &twsz))) continue; diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c index 2a517cfa5a..710d8d915a 100644 --- a/hurd/hurdsig.c +++ b/hurd/hurdsig.c @@ -130,7 +130,7 @@ int _hurd_core_limit; /* XXX */ /* Call the crash dump server to mummify us before we die. Returns nonzero if a core file was written. */ static int -write_corefile (int signo, long int sigcode, int sigerror) +write_corefile (int signo, const struct hurd_signal_detail *detail) { error_t err; mach_port_t coreserver; @@ -168,13 +168,16 @@ write_corefile (int signo, long int sigcode, int sigerror) /* Call the core dumping server to write the core file. */ err = __crash_dump_task (coreserver, __mach_task_self (), - file, _hurdsig_getenv ("GNUTARGET"), - signo, sigcode, sigerror); + file, + signo, detail->code, detail->error, + detail->exc, detail->exc_code, detail->exc_subcode, + _hurd_ports[INIT_PORT_CTTYID].port, + MACH_MSG_TYPE_COPY_SEND); __mach_port_deallocate (__mach_task_self (), coreserver); if (! err) /* The core dump into FILE succeeded, so now link it into the directory. */ - err = __dir_link (file, coredir, name); + err = __dir_link (file, coredir, name, 1); __mach_port_deallocate (__mach_task_self (), file); __mach_port_deallocate (__mach_task_self (), coredir); return !err; @@ -477,7 +480,7 @@ _hurd_internal_post_signal (struct hurd_sigstate *ss, __mutex_unlock (&_hurd_siglock); abort_all_rpcs (signo, &thread_state, 1); reply (); - __proc_mark_stop (port, signo); + __proc_mark_stop (port, signo, detail->code); })); _hurd_stopped = 1; } @@ -546,8 +549,8 @@ _hurd_internal_post_signal (struct hurd_sigstate *ss, { __mutex_lock (&_hurd_siglock); for (pe = _hurdsig_preempters; pe && handler == SIG_ERR; pe = pe->next) - if (HURD_PREEMPT_SIGNAL_P (pe, signo, sigcode)) - handler = (*pe->preempter) (pe, ss, &signo, &sigcode, &sigerror); + if (HURD_PREEMPT_SIGNAL_P (pe, signo, detail->code)) + handler = (*pe->preempter) (pe, ss, &signo, detail); __mutex_unlock (&_hurd_siglock); } @@ -664,7 +667,7 @@ _hurd_internal_post_signal (struct hurd_sigstate *ss, /* If we would ordinarily stop for a job control signal, but we are orphaned so noone would ever notice and continue us again, we just quietly die, alone and in the dark. */ - sigcode = signo; + detail->code = signo; signo = SIGKILL; act = term; } @@ -686,7 +689,8 @@ _hurd_internal_post_signal (struct hurd_sigstate *ss, /* We are already stopped, but receiving an untraced stop signal. Instead of resuming and suspending again, just notify the proc server of the new stop signal. */ - error_t err = __USEPORT (PROC, __proc_mark_stop (port, signo)); + error_t err = __USEPORT (PROC, __proc_mark_stop + (port, signo, detail->code)); assert_perror (err); } else @@ -701,7 +705,7 @@ _hurd_internal_post_signal (struct hurd_sigstate *ss, sigbomb: /* We got a fault setting up the stack frame for the handler. Nothing to do but die; BSD gets SIGILL in this case. */ - sigcode = signo; /* XXX ? */ + detail->code = signo; /* XXX ? */ signo = SIGILL; act = core; /* FALLTHROUGH */ @@ -721,7 +725,7 @@ _hurd_internal_post_signal (struct hurd_sigstate *ss, int status = W_EXITCODE (0, signo); /* Do a core dump if desired. Only set the wait status bit saying we in fact dumped core if the operation was actually successful. */ - if (act == core && write_corefile (signo, sigcode, sigerror)) + if (act == core && write_corefile (signo, detail)) status |= WCOREFLAG; /* Tell proc how we died and then stick the saber in the gut. */ _hurd_exit (status); @@ -808,8 +812,7 @@ _hurd_internal_post_signal (struct hurd_sigstate *ss, /* Call the machine-dependent function to set the thread up to run the signal handler, and preserve its old context. */ - scp = _hurd_setup_sighandler (ss, handler, - signo, sigcode, + scp = _hurd_setup_sighandler (ss, handler, signo, detail, wait_for_reply, &thread_state); if (scp == NULL) goto sigbomb; @@ -848,7 +851,7 @@ _hurd_internal_post_signal (struct hurd_sigstate *ss, } /* Backdoor extra argument to signal handler. */ - scp->sc_error = sigerror; + scp->sc_error = detail->error; /* Block SIGNO and requested signals while running the handler. */ scp->sc_mask = ss->blocked; @@ -897,8 +900,7 @@ _hurd_internal_post_signal (struct hurd_sigstate *ss, if (__sigismember (&pending, signo)) { __sigdelset (&ss->pending, signo); - sigcode = ss->pending_data[signo].code; - sigerror = ss->pending_data[signo].error; + *detail = ss->pending_data[signo]; __spin_unlock (&ss->lock); goto post_signal; } diff --git a/hurd/report-wait.c b/hurd/report-wait.c index 35cf7c1a61..7fc92935bf 100644 --- a/hurd/report-wait.c +++ b/hurd/report-wait.c @@ -149,3 +149,28 @@ _S_msg_report_wait (mach_port_t msgport, thread_t thread, __mach_port_deallocate (__mach_task_self (), thread); return 0; } + +kern_return_t +_S_msg_describe_ports (mach_port_t msgport, mach_port_t refport, + mach_port_t *ports, mach_msg_type_number_t nports, + char **desc, mach_msg_type_number_t *desclen) +{ + char *p, *end; + + if (__USEPORT (AUTH, msgport != port)) + return EPERM; + + end = *desc + *desclen; + p = *desc; + while (nports-- > 0) + { + char this[200]; + describe_port (this, *ports++); + p = __stpncpy (p, this, end - p); + if (p == end && p[-1] != '\0') + return ENOMEM; + } + + *desclen = p - *desc; + return 0; +} diff --git a/math/Makefile b/math/Makefile index 48652167ad..e1caa2908f 100644 --- a/math/Makefile +++ b/math/Makefile @@ -30,7 +30,6 @@ distribute := math_private.h machine/asm.h machine/endian.h # Build the -lm library. extra-libs := libm -libm.so-version := .0 libm-routines := e_acos e_acosf e_acosh e_acoshf e_asin e_asinf \ e_atan2 e_atan2f e_atanh e_atanhf e_cosh e_coshf \ e_exp e_expf e_fmod e_fmodf e_hypot e_hypotf e_j0 \ diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c index 3e33f660c6..1f99c64e48 100644 --- a/misc/efgcvt_r.c +++ b/misc/efgcvt_r.c @@ -69,7 +69,9 @@ ecvt_r (value, ndigit, decpt, sign, buf, len) char *buf; size_t len; { - if (&log10) + double (*log10_function) (double) = &log10; + + if (log10_function) { /* Use the reasonable code if -lm is included. */ ndigit -= (int) floor (log10 (fabs (value))); diff --git a/posix/unistd.h b/posix/unistd.h index b48f24b389..15c40c434d 100644 --- a/posix/unistd.h +++ b/posix/unistd.h @@ -650,6 +650,9 @@ extern int chroot __P ((__const char *__path)); This call is restricted to the super-user. */ extern int swapon __P ((__const char *__path)); +/* Stop using block special device PATH for swapping. */ +extern int swapoff __P ((__const char *__path)); + /* Reboot or halt the system. */ extern int reboot __P ((int __howto)); diff --git a/shlib-versions b/shlib-versions new file mode 100644 index 0000000000..7c899d4be9 --- /dev/null +++ b/shlib-versions @@ -0,0 +1,21 @@ +# This file defines the shared library version numbers we will install. + +# The following lines list filename patterns matching canonical configurations, +# and the associated versions to use for various libraries. The entire +# list processed, with earlier entries taking precedence over later entries. +# So loose patterns at the end of the list can give defaults. + +# Configuration Library versions +# ------------- ------- -------- + +# The interface to -lm depends only on cpu, not on operating system. +i?86-*-* libm=6 + +# We provide libc.so.6 for Linux kernel versions 1.3.95 and later. +i?86-*-linux* libc=6 + +# libmachuser.so.1 corresponds to mach/*.defs as of Utah's UK22 release. +*-*-gnu* libmachuser=1 + +# libhurduser.so.0.0 corresponds to hurd/*.defs as of 7 May 1996. +*-*-gnu* libhurduser=0.0 diff --git a/stdio-common/_itoa.c b/stdio-common/_itoa.c index 38d5367ba2..f85b15b030 100644 --- a/stdio-common/_itoa.c +++ b/stdio-common/_itoa.c @@ -49,7 +49,7 @@ Cambridge, MA 02139, USA. */ struct base_table_t { #if (UDIV_TIME > 2 * UMUL_TIME) - mp_limb base_multiplier; + mp_limb_t base_multiplier; #endif char flag; char post_shift; @@ -58,9 +58,9 @@ struct base_table_t { char normalization_steps; char ndigits; - mp_limb base PACK; + mp_limb_t base PACK; #if UDIV_TIME > 2 * UMUL_TIME - mp_limb base_ninv PACK; + mp_limb_t base_ninv PACK; #endif } big; #endif @@ -183,12 +183,12 @@ _itoa (value, buflim, base, upper_case) do \ { \ /* `unsigned long long int' always has 64 bits. */ \ - mp_limb work_hi = value >> (64 - BITS_PER_MP_LIMB); \ + mp_limb_t work_hi = value >> (64 - BITS_PER_MP_LIMB); \ \ if (BITS_PER_MP_LIMB == 32) \ if (work_hi != 0) \ { \ - mp_limb work_lo; \ + mp_limb_t work_lo; \ int cnt; \ \ work_lo = value & 0xfffffffful; \ @@ -228,11 +228,11 @@ _itoa (value, buflim, base, upper_case) default: { #if BITS_PER_MP_LIMB == 64 - mp_limb base_multiplier = brec->base_multiplier; + mp_limb_t base_multiplier = brec->base_multiplier; if (brec->flag) while (value != 0) { - mp_limb quo, rem, x, dummy; + mp_limb_t quo, rem, x, dummy; umul_ppmm (x, dummy, value, base_multiplier); quo = (x + ((value - x) >> 1)) >> (brec->post_shift - 1); @@ -243,7 +243,7 @@ _itoa (value, buflim, base, upper_case) else while (value != 0) { - mp_limb quo, rem, x, dummy; + mp_limb_t quo, rem, x, dummy; umul_ppmm (x, dummy, value, base_multiplier); quo = x >> brec->post_shift; @@ -253,36 +253,36 @@ _itoa (value, buflim, base, upper_case) } #endif #if BITS_PER_MP_LIMB == 32 - mp_limb t[3]; + mp_limb_t t[3]; int n; /* First convert x0 to 1-3 words in base s->big.base. Optimize for frequent cases of 32 bit numbers. */ - if ((mp_limb) (value >> 32) >= 1) + if ((mp_limb_t) (value >> 32) >= 1) { int big_normalization_steps = brec->big.normalization_steps; - mp_limb big_base_norm = brec->big.base << big_normalization_steps; + mp_limb_t big_base_norm = brec->big.base << big_normalization_steps; - if ((mp_limb) (value >> 32) >= brec->big.base) + if ((mp_limb_t) (value >> 32) >= brec->big.base) { - mp_limb x1hi, x1lo, r; + mp_limb_t x1hi, x1lo, r; /* If you want to optimize this, take advantage of that the quotient in the first udiv_qrnnd will always be very small. It might be faster just to subtract in a tight loop. */ #if UDIV_TIME > 2 * UMUL_TIME - mp_limb x, xh, xl; + mp_limb_t x, xh, xl; if (big_normalization_steps == 0) xh = 0; else - xh = (mp_limb) (value >> 64 - big_normalization_steps); - xl = (mp_limb) (value >> 32 - big_normalization_steps); + xh = (mp_limb_t) (value >> 64 - big_normalization_steps); + xl = (mp_limb_t) (value >> 32 - big_normalization_steps); udiv_qrnnd_preinv (x1hi, r, xh, xl, big_base_norm, brec->big.base_ninv); - xl = ((mp_limb) value) << big_normalization_steps; + xl = ((mp_limb_t) value) << big_normalization_steps; udiv_qrnnd_preinv (x1lo, x, r, xl, big_base_norm, big_normalization_steps); t[2] = x >> big_normalization_steps; @@ -297,16 +297,16 @@ _itoa (value, buflim, base, upper_case) big_normalization_steps); t[1] = x >> big_normalization_steps; #elif UDIV_NEEDS_NORMALIZATION - mp_limb x, xh, xl; + mp_limb_t x, xh, xl; if (big_normalization_steps == 0) xh = 0; else - xh = (mp_limb) (value >> 64 - big_normalization_steps); - xl = (mp_limb) (value >> 32 - big_normalization_steps); + xh = (mp_limb_t) (value >> 64 - big_normalization_steps); + xl = (mp_limb_t) (value >> 32 - big_normalization_steps); udiv_qrnnd (x1hi, r, xh, xl, big_base_norm); - xl = ((mp_limb) value) << big_normalization_steps; + xl = ((mp_limb_t) value) << big_normalization_steps; udiv_qrnnd (x1lo, x, r, xl, big_base_norm); t[2] = x >> big_normalization_steps; @@ -319,9 +319,9 @@ _itoa (value, buflim, base, upper_case) udiv_qrnnd (t[0], x, xh, xl, big_base_norm); t[1] = x >> big_normalization_steps; #else - udiv_qrnnd (x1hi, r, 0, (mp_limb) (value >> 32), + udiv_qrnnd (x1hi, r, 0, (mp_limb_t) (value >> 32), brec->big.base); - udiv_qrnnd (x1lo, t[2], r, (mp_limb) value, brec->big.base); + udiv_qrnnd (x1lo, t[2], r, (mp_limb_t) value, brec->big.base); udiv_qrnnd (t[0], t[1], x1hi, x1lo, brec->big.base); #endif n = 3; @@ -329,23 +329,23 @@ _itoa (value, buflim, base, upper_case) else { #if (UDIV_TIME > 2 * UMUL_TIME) - mp_limb x; + mp_limb_t x; value <<= brec->big.normalization_steps; - udiv_qrnnd_preinv (t[0], x, (mp_limb) (value >> 32), - (mp_limb) value, big_base_norm, + udiv_qrnnd_preinv (t[0], x, (mp_limb_t) (value >> 32), + (mp_limb_t) value, big_base_norm, brec->big.base_ninv); t[1] = x >> brec->big.normalization_steps; #elif UDIV_NEEDS_NORMALIZATION - mp_limb x; + mp_limb_t x; value <<= big_normalization_steps; - udiv_qrnnd (t[0], x, (mp_limb) (value >> 32), - (mp_limb) value, big_base_norm); + udiv_qrnnd (t[0], x, (mp_limb_t) (value >> 32), + (mp_limb_t) value, big_base_norm); t[1] = x >> big_normalization_steps; #else - udiv_qrnnd (t[0], t[1], (mp_limb) (value >> 32), - (mp_limb) value, brec->big.base); + udiv_qrnnd (t[0], t[1], (mp_limb_t) (value >> 32), + (mp_limb_t) value, brec->big.base); #endif n = 2; } @@ -359,15 +359,15 @@ _itoa (value, buflim, base, upper_case) /* Convert the 1-3 words in t[], word by word, to ASCII. */ do { - mp_limb ti = t[--n]; + mp_limb_t ti = t[--n]; int ndig_for_this_limb = 0; #if UDIV_TIME > 2 * UMUL_TIME - mp_limb base_multiplier = brec->base_multiplier; + mp_limb_t base_multiplier = brec->base_multiplier; if (brec->flag) while (ti != 0) { - mp_limb quo, rem, x, dummy; + mp_limb_t quo, rem, x, dummy; umul_ppmm (x, dummy, ti, base_multiplier); quo = (x + ((ti - x) >> 1)) >> (brec->post_shift - 1); @@ -379,7 +379,7 @@ _itoa (value, buflim, base, upper_case) else while (ti != 0) { - mp_limb quo, rem, x, dummy; + mp_limb_t quo, rem, x, dummy; umul_ppmm (x, dummy, ti, base_multiplier); quo = x >> brec->post_shift; @@ -391,7 +391,7 @@ _itoa (value, buflim, base, upper_case) #else while (ti != 0) { - mp_limb quo, rem; + mp_limb_t quo, rem; quo = ti / base; rem = ti % base; diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c index 4e6104a71b..237deb99a5 100644 --- a/stdio-common/printf_fp.c +++ b/stdio-common/printf_fp.c @@ -28,7 +28,6 @@ Cambridge, MA 02139, USA. */ # include #endif #include -#include #include #include #include @@ -69,7 +68,7 @@ ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */ #define outchar(ch) \ do \ { \ - register CONST int outc = (ch); \ + register const int outc = (ch); \ if (putc (outc, fp) == EOF) \ return -1; \ ++done; \ @@ -107,10 +106,10 @@ ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */ An MP variable occupies a varying number of entries in its array. We keep track of this number for efficiency reasons. Otherwise we would always have to process the whole array. */ -#define MPN_VAR(name) mp_limb *name; mp_size_t name##size +#define MPN_VAR(name) mp_limb_t *name; mp_size_t name##size #define MPN_ASSIGN(dst,src) \ - memcpy (dst, src, (dst##size = src##size) * sizeof (mp_limb)) + memcpy (dst, src, (dst##size = src##size) * sizeof (mp_limb_t)) #define MPN_GE(u,v) \ (u##size > v##size || (u##size == v##size && __mpn_cmp (u, v, u##size) >= 0)) @@ -139,7 +138,7 @@ __printf_fp (FILE *fp, union { double dbl; - LONG_DOUBLE ldbl; + __long_double_t ldbl; } fpnum; @@ -151,11 +150,11 @@ __printf_fp (FILE *fp, const char *grouping; /* "NaN" or "Inf" for the special cases. */ - CONST char *special = NULL; + const char *special = NULL; /* We need just a few limbs for the input before shifting to the right position. */ - mp_limb fp_input[(LDBL_MANT_DIG + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB]; + mp_limb_t fp_input[(LDBL_MANT_DIG + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB]; /* We need to shift the contents of fp_input by this amount of bits. */ int to_shift; @@ -184,11 +183,11 @@ __printf_fp (FILE *fp, int done = 0; /* General helper (carry limb). */ - mp_limb cy; + mp_limb_t cy; char hack_digit (void) { - mp_limb hi; + mp_limb_t hi; if (expsign != 0 && type == 'f' && exponent-- > 0) hi = 0; @@ -337,10 +336,10 @@ __printf_fp (FILE *fp, would be really big it could lead to memory problems. */ { mp_size_t bignum_size = ((ABS (exponent) + BITS_PER_MP_LIMB - 1) - / BITS_PER_MP_LIMB + 4) * sizeof (mp_limb); - frac = (mp_limb *) alloca (bignum_size); - tmp = (mp_limb *) alloca (bignum_size); - scale = (mp_limb *) alloca (bignum_size); + / BITS_PER_MP_LIMB + 4) * sizeof (mp_limb_t); + frac = (mp_limb_t *) alloca (bignum_size); + tmp = (mp_limb_t *) alloca (bignum_size); + scale = (mp_limb_t *) alloca (bignum_size); } /* We now have to distinguish between numbers with positive and negative @@ -515,7 +514,7 @@ __printf_fp (FILE *fp, if (exponent >= tens->m_expo) { int i, incr, cnt_h, cnt_l; - mp_limb topval[2]; + mp_limb_t topval[2]; /* The __mpn_mul function expects the first argument to be bigger than the second. */ @@ -545,11 +544,11 @@ __printf_fp (FILE *fp, { topval[0] = 0; topval[1] - = ((mp_limb) 10) << (BITS_PER_MP_LIMB - 4 - cnt_h); + = ((mp_limb_t) 10) << (BITS_PER_MP_LIMB - 4 - cnt_h); } else { - topval[0] = ((mp_limb) 10) << (BITS_PER_MP_LIMB - 4); + topval[0] = ((mp_limb_t) 10) << (BITS_PER_MP_LIMB - 4); topval[1] = 0; (void) __mpn_lshift (topval, topval, 2, BITS_PER_MP_LIMB - cnt_h); diff --git a/stdio/linewrap.c b/stdio/linewrap.c index e821cc3575..7f6576f29b 100644 --- a/stdio/linewrap.c +++ b/stdio/linewrap.c @@ -22,42 +22,27 @@ Cambridge, MA 02139, USA. */ #include #include -/* We keep this data for each line-wrapping stream. */ - -struct data - { - const size_t *lmargin, *rmargin; /* Left and right margins. */ - const size_t *wrapmargin; /* Margin to wrap to, or null to truncate. */ - size_t point; /* Current column of last chars flushed. */ - - /* Original cookie and hooks from the stream. */ - void *cookie; - void (*output) (FILE *, int); - __io_close_fn *close; - __io_fileno_fn *fileno; - __io_seek_fn *seek; - }; +#include + +void __line_wrap_output (FILE *, int); /* Install our hooks into a stream. */ - static inline void -wrap_stream (FILE *stream, struct data *d) +wrap_stream (FILE *stream, struct line_wrap_data *d) { - static void lwoutput (FILE *, int); static __io_close_fn lwclose; static __io_fileno_fn lwfileno; stream->__cookie = d; - stream->__room_funcs.__output = &lwoutput; + stream->__room_funcs.__output = &__line_wrap_output; stream->__io_funcs.__close = &lwclose; stream->__io_funcs.__fileno = &lwfileno; stream->__io_funcs.__seek = NULL; /* Cannot seek. */ } /* Restore a stream to its original state. */ - static inline void -unwrap_stream (FILE *stream, struct data *d) +unwrap_stream (FILE *stream, struct line_wrap_data *d) { stream->__cookie = d->cookie; stream->__room_funcs.__output = d->output; @@ -72,41 +57,40 @@ unwrap_stream (FILE *stream, struct data *d) static int lwclose (void *cookie) { - struct data *d = cookie; + struct line_wrap_data *d = cookie; return (*d->close) (d->cookie); } static int lwfileno (void *cookie) { - struct data *d = cookie; + struct line_wrap_data *d = cookie; return (*d->fileno) (d->cookie); } /* This function is called when STREAM must be flushed. C is EOF or a character to be appended to the buffer contents. */ - -static void -lwoutput (FILE *stream, int c) +void +__line_wrap_output (FILE *stream, int c) { char *buf, *nl; size_t len; /* Extract our data and restore the stream's original cookie and output function so writes we do really go out. */ - struct data *d = stream->__cookie; + struct line_wrap_data *d = stream->__cookie; unwrap_stream (stream, d); /* Scan the buffer for newlines. */ - for (buf = stream->__buffer; - (buf < stream->__bufp || (c != EOF && c != '\n')) && !stream->__error) + buf = stream->__buffer; + while ((buf < stream->__bufp || (c != EOF && c != '\n')) && !stream->__error) { size_t r; - if (d->point == 0 && d->lmargin && *d->lmargin != 0) + if (d->point == 0 && d->lmargin != 0) { /* We are starting a new line. Print spaces to the left margin. */ - const size_t pad = *d->lmargin; + const size_t pad = d->lmargin; if (stream->__bufp + pad < stream->__put_limit) { /* We can fit in them in the buffer by moving the @@ -141,8 +125,7 @@ lwoutput (FILE *stream, int c) { /* The buffer ends in a partial line. */ - if (!d->rmargin || - d->point + len + (c != EOF && c != '\n') <= d->rmargin) + if (d->point + len + (c != EOF && c != '\n') <= d->rmargin) { /* The remaining buffer text is a partial line and fits within the maximum line width. Advance point for the @@ -155,7 +138,7 @@ lwoutput (FILE *stream, int c) the end of the buffer. */ nl = stream->__bufp; } - else if (!d->rmargin || d->point + (nl - buf) <= d->rmargin) + else if (d->point + (nl - buf) <= d->rmargin) { /* The buffer contains a full line that fits within the maximum line width. Reset point and scan the next line. */ @@ -165,9 +148,9 @@ lwoutput (FILE *stream, int c) } /* This line is too long. */ - r = *d->rmargin; + r = d->rmargin; - if (! d->wrapmargin) + if (d->wmargin < 0) { /* Truncate the line by overwriting the excess with the newline and anything after it in the buffer. */ @@ -242,7 +225,7 @@ lwoutput (FILE *stream, int c) /* Temporarily reset bufp to include just the first line. */ stream->__bufp = nl; - if (nextline - (nl + 1) < d->wrap) + if (nextline - (nl + 1) < d->wmargin) /* The margin needs more blanks than we removed. Output the first line so we can use the space. */ (*d->output) (stream, '\n'); @@ -255,7 +238,7 @@ lwoutput (FILE *stream, int c) d->point = 0; /* Add blanks up to the wrap margin column. */ - for (i = 0; i < d->wrap; ++i) + for (i = 0; i < d->wmargin; ++i) *stream->__bufp++ = ' '; /* Copy the tail of the original buffer into the current buffer @@ -284,19 +267,16 @@ lwoutput (FILE *stream, int c) wrap_stream (stream, d); } -/* Modify STREAM so that it prefixes lines written on it with *LMARGIN - spaces and limits them to *RMARGIN columns total. If WRAP is not null, - words that extend past *RMARGIN are wrapped by replacing the whitespace - before them with a newline and *WRAP spaces. Otherwise, chars beyond - *RMARGIN are simply dropped until a newline. Returns STREAM after - modifying it, or NULL if there was an error. The pointers passed are - stored in the stream and so must remain valid until `line_unwrap_stream' - is called; the values pointed to can be changed between stdio calls. */ - +/* Modify STREAM so that it prefixes lines written on it with LMARGIN spaces + and limits them to RMARGIN columns total. If WMARGIN >= 0, words that + extend past RMARGIN are wrapped by replacing the whitespace before them + with a newline and WMARGIN spaces. Otherwise, chars beyond RMARGIN are + simply dropped until a newline. Returns STREAM after modifying it, or + NULL if there was an error. */ FILE * -line_wrap_stream (FILE *stream, size_t *lmargin, size_t *rmargin, size_t *wrap) +line_wrap_stream (FILE *stream, size_t lmargin, size_t rmargin, size_t wmargin) { - struct data *d = malloc (sizeof *d); + struct line_wrap_data *d = malloc (sizeof *d); if (!d) return NULL; @@ -321,25 +301,116 @@ line_wrap_stream (FILE *stream, size_t *lmargin, size_t *rmargin, size_t *wrap) to work if the stream is switched to full or no buffering. */ stream->__linebuf = 1; -#define ref(arg) d->arg = arg - ref (lmargin); - ref (rmargin); - ref (wrap); -#undef ref + d->lmargin = lmargin; + d->rmargin = rmargin; + d->wmargin = wmargin; return stream; } /* Remove the hooks placed in STREAM by `line_wrap_stream'. */ - void line_unwrap_stream (FILE *stream) { - struct data *d = stream->__cookie; + struct line_wrap_data *d = stream->__cookie; unwrap_stream (stream, d); free (d); } +/* Functions on wrapped streams. */ + +/* Returns true if STREAM is line wrapped. */ +inline int +line_wrapped (FILE *stream) +{ + return (stream->__room_funcs.__output == &__line_wrap_output); +} + +/* If STREAM is not line-wrapped return -1, else return its left margin. */ +size_t +line_wrap_lmargin (FILE *stream) +{ + if (! line_wrapped (stream)) + return -1; + return ((struct line_wrap_data *)stream->__cookie)->lmargin; +} + +/* If STREAM is not line-wrapped return -1, else set its left margin to + LMARGIN and return the old value. */ +size_t +line_wrap_set_lmargin (FILE *stream, size_t lmargin) +{ + if (! line_wrapped (stream)) + return -1; + else + { + struct line_wrap_data *d = stream->__cookie; + size_t old = d->lmargin; + d->lmargin = lmargin; + return old; + } +} + +/* If STREAM is not line-wrapped return -1, else return its left margin. */ +size_t +line_wrap_rmargin (FILE *stream) +{ + if (! line_wrapped (stream)) + return -1; + return ((struct line_wrap_data *)stream->__cookie)->rmargin; +} + +/* If STREAM is not line-wrapped return -1, else set its right margin to + RMARGIN and return the old value. */ +size_t +line_wrap_set_rmargin (FILE *stream, size_t rmargin) +{ + if (! line_wrapped (stream)) + return -1; + else + { + struct line_wrap_data *d = stream->__cookie; + size_t old = d->rmargin; + d->rmargin = rmargin; + return old; + } +} + +/* If STREAM is not line-wrapped return -1, else return its wrap margin. */ +size_t +line_wrap_wmargin (FILE *stream) +{ + if (! line_wrapped (stream)) + return -1; + return ((struct line_wrap_data *)stream->__cookie)->wmargin; +} + +/* If STREAM is not line-wrapped return -1, else set its left margin to + WMARGIN and return the old value. */ +size_t +line_wrap_set_wmargin (FILE *stream, size_t wmargin) +{ + if (! line_wrapped (stream)) + return -1; + else + { + struct line_wrap_data *d = stream->__cookie; + size_t old = d->wmargin; + d->wmargin = wmargin; + return old; + } +} + +/* If STREAM is not line-wrapped return -1, else return the column number of + the current output point. */ +size_t +line_wrap_point (FILE *stream) +{ + if (! line_wrapped (stream)) + return -1; + return ((struct line_wrap_data *)stream->__cookie)->point; +} + #ifdef TEST int main (int argc, char **argv) diff --git a/stdio/linewrap.h b/stdio/linewrap.h new file mode 100644 index 0000000000..7ba337fad2 --- /dev/null +++ b/stdio/linewrap.h @@ -0,0 +1,189 @@ +/* Word-wrapping and line-truncating streams. +Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#ifndef __LINEWRAP_H__ +#define __LINEWRAP_H__ + +#include +#include +#include + +#include + +#include /* Need size_t. */ + +__BEGIN_DECLS + +/* We keep this data for each line-wrapping stream. */ +struct line_wrap_data + { + size_t lmargin, rmargin; /* Left and right margins. */ + size_t wmargin; /* Margin to wrap to, or -1 to truncate. */ + size_t point; /* Current column of last chars flushed. */ + + /* Original cookie and hooks from the stream. */ + void *cookie; + void (*output) (FILE *, int); + __io_close_fn *close; + __io_fileno_fn *fileno; + __io_seek_fn *seek; + }; + +/* Modify STREAM so that it prefixes lines written on it with LMARGIN spaces + and limits them to RMARGIN columns total. If WMARGIN >= 0, words that + extend past RMARGIN are wrapped by replacing the whitespace before them + with a newline and WMARGIN spaces. Otherwise, chars beyond RMARGIN are + simply dropped until a newline. Returns STREAM after modifying it, or + NULL if there was an error. */ +FILE *line_wrap_stream (FILE *stream, + size_t lmargin, size_t rmargin, size_t wmargin); + +/* Remove the hooks placed in STREAM by `line_wrap_stream'. */ +void line_unwrap_stream (FILE *stream); + +/* Returns true if STREAM is line wrapped. */ +extern inline int line_wrapped (FILE *stream); + +/* If STREAM is not line-wrapped return -1, else return its left margin. */ +extern size_t line_wrap_lmargin (FILE *stream); + +/* If STREAM is not line-wrapped return -1, else set its left margin to + LMARGIN and return the old value. */ +extern size_t line_wrap_set_lmargin (FILE *stream, size_t lmargin); + +/* If STREAM is not line-wrapped return -1, else return its left margin. */ +extern size_t line_wrap_rmargin (FILE *stream); + +/* If STREAM is not line-wrapped return -1, else set its right margin to + RMARGIN and return the old value. */ +extern size_t line_wrap_set_rmargin (FILE *stream, size_t rmargin); + +/* If STREAM is not line-wrapped return -1, else return its wrap margin. */ +extern size_t line_wrap_wmargin (FILE *stream); + +/* If STREAM is not line-wrapped return -1, else set its left margin to + WMARGIN and return the old value. */ +extern size_t line_wrap_set_wmargin (FILE *stream, size_t wmargin); + +/* If STREAM is not line-wrapped return -1, else return the column number of + the current output point. */ +extern size_t line_wrap_point (FILE *stream); + + +#ifdef __OPTIMIZE__ + +extern void __line_wrap_output (FILE *, int); /* private */ + +/* Returns true if STREAM is line wrapped. */ +extern inline int +line_wrapped (FILE *stream) +{ + return (stream->__room_funcs.__output == &__line_wrap_output); +} + +/* If STREAM is not line-wrapped return -1, else return its left margin. */ +extern inline size_t +line_wrap_lmargin (FILE *stream) +{ + if (! line_wrapped (stream)) + return -1; + return ((struct line_wrap_data *)stream->__cookie)->lmargin; +} + +/* If STREAM is not line-wrapped return -1, else set its left margin to + LMARGIN and return the old value. */ +extern inline size_t +line_wrap_set_lmargin (FILE *stream, size_t lmargin) +{ + if (! line_wrapped (stream)) + return -1; + else + { + struct line_wrap_data *d = stream->__cookie; + size_t old = d->lmargin; + d->lmargin = lmargin; + return old; + } +} + +/* If STREAM is not line-wrapped return -1, else return its left margin. */ +extern inline size_t +line_wrap_rmargin (FILE *stream) +{ + if (! line_wrapped (stream)) + return -1; + return ((struct line_wrap_data *)stream->__cookie)->rmargin; +} + +/* If STREAM is not line-wrapped return -1, else set its right margin to + RMARGIN and return the old value. */ +extern inline size_t +line_wrap_set_rmargin (FILE *stream, size_t rmargin) +{ + if (! line_wrapped (stream)) + return -1; + else + { + struct line_wrap_data *d = stream->__cookie; + size_t old = d->rmargin; + d->rmargin = rmargin; + return old; + } +} + +/* If STREAM is not line-wrapped return -1, else return its wrap margin. */ +extern inline size_t +line_wrap_wmargin (FILE *stream) +{ + if (! line_wrapped (stream)) + return -1; + return ((struct line_wrap_data *)stream->__cookie)->wmargin; +} + +/* If STREAM is not line-wrapped return -1, else set its left margin to + WMARGIN and return the old value. */ +extern inline size_t +line_wrap_set_wmargin (FILE *stream, size_t wmargin) +{ + if (! line_wrapped (stream)) + return -1; + else + { + struct line_wrap_data *d = stream->__cookie; + size_t old = d->wmargin; + d->wmargin = wmargin; + return old; + } +} + +/* If STREAM is not line-wrapped return -1, else return the column number of + the current output point. */ +extern inline size_t +line_wrap_point (FILE *stream) +{ + if (! line_wrapped (stream)) + return -1; + return ((struct line_wrap_data *)stream->__cookie)->point; +} + +#endif /* Optimizing. */ + +__END_DECLS + +#endif /* __LINEWRAP_H__ */ diff --git a/stdio/stdio.h b/stdio/stdio.h index efaf2b95bf..38bfc148d7 100644 --- a/stdio/stdio.h +++ b/stdio/stdio.h @@ -353,22 +353,6 @@ extern FILE *fmemopen __P ((__ptr_t __s, size_t __len, __const char *__modes)); necessary. *BUFLOC and *SIZELOC are updated with the buffer's location and the number of characters written on fflush or fclose. */ extern FILE *open_memstream __P ((char **__bufloc, size_t *__sizeloc)); - - -/* Modify STREAM so that it prefixes lines written on it with *LMARGIN - spaces and limits them to *RMARGIN columns total. If WRAP is not null, - words that extend past *RMARGIN are wrapped by replacing the whitespace - before them with a newline and *WRAP spaces. Otherwise, chars beyond - *RMARGIN are simply dropped until a newline. Returns STREAM after - modifying it, or NULL if there was an error. The pointers passed are - stored in the stream and so must remain valid until `line_unwrap_stream' - is called; the values pointed to can be changed between stdio calls. */ -extern FILE *line_wrap_stream __P ((FILE *__stream, - size_t *__lmargin, size_t *__rmargin, - size_t *__wrap)); - -/* Remove the hooks placed in STREAM by `line_wrap_stream'. */ -extern void line_unwrap_stream __P ((FILE *__stream)); #endif diff --git a/stdlib/Makefile b/stdlib/Makefile index 1fdfb68bb4..212ea0a54b 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -49,7 +49,7 @@ tests := tst-strtol tst-strtod testmb testrand testsort testdiv # Several mpn functions from GNU MP are used by the strtod fun