diff options
51 files changed, 1677 insertions, 247 deletions
@@ -1,3 +1,147 @@ +Tue Jan 21 04:05:20 1997 Ulrich Drepper <drepper@cygnus.com> + + * version.h (VERSION): Bump to 1.101. + + Implement -d and -r option to `ldd' to check relocations. + * elf/dl-error.c: Add another method to intercept errors. + (_dl_receive_error): New function. Install user defined handler. + (receiver): New variable. Contains pointer to user provided handler. + (_dl_signal_error): If user provided handler is installed call this. + * elf/dl-load.c (_dl_map_object): When shared object is not found in + trace mode initialize a few more fields so that lookup can actually + happen but always fails. + * elf/ldd.sh.in: Rewrite argument handling. Recognize new arguments + to trigger reloation test. Return with appropriate error code if + a file wasn't found. Print warning if object is not executable. + * elf/ldd.bash.in: Likewise. + * elf/link.h (receiver_fct): New type. Used in _dl_receive_error. + (_dl_sysdep_error): New prototype. + (_dl_receive_error): New prototype. + (_dl_signal_error): Remove __attribute__ ((__noreturn__)). + * elf/rtld.c (dl_main): Rewrite argument handling. More than + one argument allowed. Recognize --data-relocs and --function-relocs + arguments. + Don't determine `lazy' mode from LD_BIND_NOW environment variable + when in trace mode. + If in trace mode and either --data-relocs or --function-relocs is + given perform relocation. Report errors using print_unresolved + function. + (print_unresolved): New function. Print information about missing + symbol on stderr. + * sysdeps/generic/dl-sysdep.c (_dl_sysdep_error): New function. + Like _dl_sysdep_message but print to stderr. + * sysdeps/mach/hurd/dl-sysdep.c: Likewise. + + * sysdeps/generic/sockaddrcom.h: Add definition of sa_family_t. + Reported by Andreas Schwab. + (__SOCKADDR_COMMON): Use sa_family_t for family member. + * sysdeps/unix/bsd/bsd4.4/sockaddrcom.h: Likewise. + + Linux/Sparc support by Miguel de Icaza. + * sysdeps/sparc/fpu_control.h: New file. + * sysdeps/unix/sysv/linux/sparc/__sigtrampoline.S: New file. + * sysdeps/unix/sysv/linux/sparc/brk.c: New file. + * sysdeps/unix/sysv/linux/sparc/profil-counter.h: New file. + * sysdeps/unix/sysv/linux/sparc/sigaction.c: New file. + * sysdeps/unix/sysv/linux/sparc/socket.S: New file. + * sysdeps/unix/sysv/linux/sparc/syscall.S: New file. + * sysdeps/unix/sysv/linux/sparc/sysdep.h: New file. + * sysdeps/unix/sysv/linux/sparc/Dist: New file. + * sysdeps/unix/sysv/linux/sparc/Makefile: New file. + + * sysdeps/unix/sysv/linux/net/if_arp.h: Don't use kernel header. + Provide own definition based on 4.4BSD and Linux. + * sysdeps/unix/sysv/linux/net/ppp_defs.h: Define __u32 before + including <linux/ppp_defs.h>. + * sysdeps/unix/sysv/linux/sys/msq_buf.h (struct msqid_ds): Don't + use __pid_t since the kernel might have a different size. + * sysdeps/unix/sysv/linux/sys/shm_buf.h (struct shmid_ds): Likewise. + Reported by Andreas Schwab. + + * time/asctime.c: Update copyright. + * time/dysize.c: Likewise. + * time/gmtime.c: Likewise. + * time/timegm.c: Likewise. + * time/offtime.c: Likewise. De-ANSI-declfy. + + * time/tzset.c (__tzset_internal): When TZ envvar does not name a + DST timezone don't default to offset -1. + + * sysdeps/unix/sysv/linux/net/route.h: Don't use kernel header. + Reported by a sun <asun@zoology.washington.edu>. + + * resolv/Makefile: Correct spelling: subdirs-dirs -> subdir-dirs. + + * sysdeps/stub/sysv_signal.c: New file. Stub implementation. + + * Makefile (distribute): Add mcheck.h. + + * nis/Makefile (distribute): Add nss-nis.h. + + * libio/Makefile (routines): Change vdprintf to iovdprintf to prevent + dist problem. + + * nss/Makefile (distribute): Add digits_dots.c. + + * sysdeps/unix/sysv/linux/Dist: Add kernel_sigaction.h. + * sysdeps/unix/sysv/linux/alpha/Dist: Add sys/procfs.h. + * sysdeps/unix/sysv/linux/sparc/Dist: Add clone.S. + * new-malloc/Makefile (distribute): Add mcheck-init.c and mcheck.h. + +Mon Jan 20 17:54:28 1997 Sven Verdoolaege <skimo@breughel.ufsia.ac.be> + + * manual/filesys.texi: Fix little problem (reentrant->readdir). + +Fri Jan 17 19:07:07 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * configure.in [$elf=yes]: Check for support of .previous and + .popsection in the assembler. + * config.h.in: Add HAVE_ASM_PREVIOUS_DIRECTIVE and + HAVE_ASM_POPSECTION_DIRECTIVE. + * libc-symbols.h (__make_section_unallocated) [HAVE_ELF]: Define + appropriate if either .previous or .popsection is supported. + (libc_warning) [HAVE_ELF]: Use it here. + +Sat Jan 18 22:15:26 1997 Richard Henderson <rth@tamu.edu> + + * Makeconfig (CFLAGS-.so): Add -fno-common to prevent odd sorts of + errors that can occur when linking libc.so. + +Mon Jan 20 05:20:49 1997 Ulrich Drepper <drepper@cygnus.com> + + * elf/dl-load.c (open_path): When running setuid don't try + a directory if it is not given with the full name. + + * elf/Makefile (before-compile): New variable. Mention trusted-dirs.h. + (trusted-dirs.h): Construct file from $(default-rpath) and + $(user-defined-trusted-dirs) variables. + * elf/dl-load.c (_dl_map_object): Pass additional argument to open_path + which is NULL except for the LD_LIBRARY_PATH pass in which case it + is a pointer to the list of directories from the trusted-dirs.h + file. + (open_path): Accept additional argument with list of trusted dirs. + When running setuid and a list of trusted dirs is given only use + those which are mentioned in the list. + + * elf/rtld.c (dl_main): Don't reject whole LD_LIBRARY_PATH when + running setuid. Instead accept entries which do not contain a '/'. + + * Makeconfig: Correct comment about +(default_cflags). + +Mon Jan 20 05:11:14 1997 Hrvoje Niksic <hniksic@srce.hr> + + * time/strptime.c (recursive): Use && not || to test for valid + argument. + +Mon Jan 20 05:06:50 1997 Ulrich Drepper <drepper@cygnus.com> + + * elf/ldd.sh.in: Exit with value 1 if an error occured. + * elf/ldd.bash.in: Likewise. + + * elf/rtld.c (dl_main): Do not always ignore LD_PRELOAD when the + binary runs setuid. It is save to use those entries which do not + contain a '/'. This is compatible with Solaris-2. + Mon Jan 20 03:02:50 1997 Ulrich Drepper <drepper@cygnus.com> * Make-dist: Update and reformat copyright. diff --git a/Makeconfig b/Makeconfig index 3c658bfcad..37d5f62173 100644 --- a/Makeconfig +++ b/Makeconfig @@ -421,7 +421,7 @@ ifdef CFLAGS endif # CFLAGS endif # +cflags -# If none of the above worked, default to "-g". +# If none of the above worked, default to "-g -O". ifeq "$(strip $(+cflags))" "" +cflags := $(default_cflags) endif # $(+cflags) == "" @@ -470,7 +470,7 @@ ifeq (yes,$(build-shared)) # The PIC object files are named foo.so. object-suffixes += .so CPPFLAGS-.so = -DPIC -CFLAGS-.so = -fPIC +CFLAGS-.so = -fPIC -fno-common libtype.so := lib%_pic.a endif ifeq (yes,$(build-profile)) @@ -295,7 +295,8 @@ distribute := README INSTALL FAQ NOTES NEWS PROJECTS \ config.h.in config.make.in config-name.in Makefile.in \ autolock.sh rellns-sh munch-tmpl.c munch.awk interp.c \ sysdep.h set-hooks.h libc-symbols.h version.h shlib-versions \ - rpm/Makefile rpm/template rpm/rpmrc nsswitch.h netgroup.h + rpm/Makefile rpm/template rpm/rpmrc nsswitch.h netgroup.h \ + mcheck.h distribute := $(strip $(distribute)) generated := $(generated) stubs.h version-info.h @@ -1,4 +1,4 @@ -This directory contains the version 1.96 test release of the GNU C Library. +This directory contains the version 1.101 test release of the GNU C Library. Many bugs have been fixed since the last release. Some bugs surely remain. @@ -46,7 +46,7 @@ provides the Unix `crypt' function, plus some other entry points. Because of the United States export restriction on DES implementations, we are distributing this code separately from the rest of the C library. There is an extra distribution tar file just for crypt; it is -called `glibc-1.96-crypt.tar.gz'. You can just unpack the crypt +called `glibc-1.101-crypt.tar.gz'. You can just unpack the crypt distribution along with the rest of the C library and build; you can also build the library without getting crypt. Users outside the USA can get the crypt distribution via anonymous FTP from ftp.uni-c.dk diff --git a/config.h.in b/config.h.in index a02094a599..e928eacecf 100644 --- a/config.h.in +++ b/config.h.in @@ -35,6 +35,14 @@ This is defined by configure under --enable-libio. */ #undef USE_IN_LIBIO +/* Define if using ELF and the assembler supports the `.previous' + directive. */ +#undef HAVE_ASM_PREVIOUS_DIRECTIVE + +/* Define if using ELF and the assembler supports the `.popsection' + directive. */ +#undef HAVE_ASM_POPSECTION_DIRECTIVE + /* */ @@ -1604,14 +1604,66 @@ EOF fi +if test $elf = yes; then + echo $ac_n "checking for .previous assembler directive""... $ac_c" 1>&6 +echo "configure:1610: checking for .previous assembler directive" >&5 +if eval "test \"`echo '$''{'libc_cv_asm_previous_directive'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.s <<EOF +.section foo_section +.previous +EOF + if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:1618: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then + libc_cv_asm_previous_directive=yes + else + libc_cv_asm_previous_directive=no + fi + rm -f conftest* +fi + +echo "$ac_t""$libc_cv_asm_previous_directive" 1>&6 + if test $libc_cv_asm_previous_directive = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_ASM_PREVIOUS_DIRECTIVE 1 +EOF + + else + echo $ac_n "checking for .popsection assembler directive""... $ac_c" 1>&6 +echo "configure:1634: checking for .popsection assembler directive" >&5 +if eval "test \"`echo '$''{'libc_cv_asm_popsection_directive'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.s <<EOF +.pushsection foo_section +.popsection +EOF + if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:1642: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then + libc_cv_asm_popsection_directive=yes + else + libc_cv_asm_popsection_directive=no + fi + rm -f conftest* +fi + +echo "$ac_t""$libc_cv_asm_popsection_directive" 1>&6 + if test $libc_cv_asm_popsection_directive = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_ASM_POPSECTION_DIRECTIVE 1 +EOF + + fi + fi +fi + if test $elf != yes; then echo $ac_n "checking for .init and .fini sections""... $ac_c" 1>&6 -echo "configure:1610: checking for .init and .fini sections" >&5 +echo "configure:1662: checking for .init and .fini sections" >&5 if eval "test \"`echo '$''{'libc_cv_have_initfini'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1615 "configure" +#line 1667 "configure" #include "confdefs.h" int main() { @@ -1620,7 +1672,7 @@ asm (".section .init"); asm (".text"); ; return 0; } EOF -if { (eval echo configure:1624: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1676: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* libc_cv_have_initfini=yes else @@ -1645,19 +1697,19 @@ if test $elf = yes; then libc_cv_asm_underscores=no else echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6 -echo "configure:1649: checking for _ prefix on C symbol names" >&5 +echo "configure:1701: checking for _ prefix on C symbol names" >&5 if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1654 "configure" +#line 1706 "configure" #include "confdefs.h" asm ("_glibc_foobar:"); int main() { glibc_foobar (); ; return 0; } EOF -if { (eval echo configure:1661: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1713: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* libc_cv_asm_underscores=yes else @@ -1684,7 +1736,7 @@ if test $elf = yes; then libc_cv_asm_weakext_directive=no else echo $ac_n "checking for assembler .weak directive""... $ac_c" 1>&6 -echo "configure:1688: checking for assembler .weak directive" >&5 +echo "configure:1740: checking for assembler .weak directive" >&5 if eval "test \"`echo '$''{'libc_cv_asm_weak_directive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1707,7 +1759,7 @@ echo "$ac_t""$libc_cv_asm_weak_directive" 1>&6 if test $libc_cv_asm_weak_directive = no; then echo $ac_n "checking for assembler .weakext directive""... $ac_c" 1>&6 -echo "configure:1711: checking for assembler .weakext directive" >&5 +echo "configure:1763: checking for assembler .weakext directive" >&5 if eval "test \"`echo '$''{'libc_cv_asm_weakext_directive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1744,7 +1796,7 @@ EOF fi echo $ac_n "checking for ld --no-whole-archive""... $ac_c" 1>&6 -echo "configure:1748: checking for ld --no-whole-archive" >&5 +echo "configure:1800: checking for ld --no-whole-archive" >&5 if eval "test \"`echo '$''{'libc_cv_ld_no_whole_archive'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1755,7 +1807,7 @@ __throw () {} EOF if { ac_try='${CC-cc} $CFLAGS -nostdlib -nostartfiles -Wl,--no-whole-archive - -o conftest conftest.c'; { (eval echo configure:1759: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then + -o conftest conftest.c'; { (eval echo configure:1811: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then libc_cv_ld_no_whole_archive=yes else libc_cv_ld_no_whole_archive=no @@ -1766,7 +1818,7 @@ fi echo "$ac_t""$libc_cv_ld_no_whole_archive" 1>&6 echo $ac_n "checking for gcc -fno-exceptions""... $ac_c" 1>&6 -echo "configure:1770: checking for gcc -fno-exceptions" >&5 +echo "configure:1822: checking for gcc -fno-exceptions" >&5 if eval "test \"`echo '$''{'libc_cv_gcc_no_exceptions'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1777,7 +1829,7 @@ __throw () {} EOF if { ac_try='${CC-cc} $CFLAGS -nostdlib -nostartfiles -fno-exceptions - -o conftest conftest.c'; { (eval echo configure:1781: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then + -o conftest conftest.c'; { (eval echo configure:1833: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then libc_cv_gcc_no_exceptions=yes else libc_cv_gcc_no_exceptions=no @@ -1829,7 +1881,7 @@ if test "$uname" = generic; then fi echo $ac_n "checking OS release for uname""... $ac_c" 1>&6 -echo "configure:1833: checking OS release for uname" >&5 +echo "configure:1885: checking OS release for uname" >&5 if eval "test \"`echo '$''{'libc_cv_uname_release'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1851,7 +1903,7 @@ echo "$ac_t""$libc_cv_uname_release" 1>&6 uname_release="$libc_cv_uname_release" echo $ac_n "checking OS version for uname""... $ac_c" 1>&6 -echo "configure:1855: checking OS version for uname" >&5 +echo "configure:1907: checking OS version for uname" >&5 if eval "test \"`echo '$''{'libc_cv_uname_version'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1873,7 +1925,7 @@ else fi echo $ac_n "checking stdio selection""... $ac_c" 1>&6 -echo "configure:1877: checking stdio selection" >&5 +echo "configure:1929: checking stdio selection" >&5 case $stdio in libio) cat >> confdefs.h <<\EOF @@ -1885,7 +1937,7 @@ esac echo "$ac_t""$stdio" 1>&6 echo $ac_n "checking malloc selection""... $ac_c" 1>&6 -echo "configure:1889: checking malloc selection" >&5 +echo "configure:1941: checking malloc selection" >&5 case $malloc in new-malloc) USE_NEW_MALLOC=-DUSE_NEW_MALLOC ;; diff --git a/configure.in b/configure.in index 7280c7a4ec..6cd3291bf1 100644 --- a/configure.in +++ b/configure.in @@ -496,6 +496,40 @@ if test $libc_cv_asm_set_directive = yes; then AC_DEFINE(HAVE_ASM_SET_DIRECTIVE) fi +if test $elf = yes; then + AC_CACHE_CHECK(for .previous assembler directive, + libc_cv_asm_previous_directive, [dnl + cat > conftest.s <<EOF +.section foo_section +.previous +EOF + if AC_TRY_COMMAND(${CC-cc} -c $CFLAGS conftest.s 1>&AC_FD_CC); then + libc_cv_asm_previous_directive=yes + else + libc_cv_asm_previous_directive=no + fi + rm -f conftest*]) + if test $libc_cv_asm_previous_directive = yes; then + AC_DEFINE(HAVE_ASM_PREVIOUS_DIRECTIVE) + else + AC_CACHE_CHECK(for .popsection assembler directive, + libc_cv_asm_popsection_directive, [dnl + cat > conftest.s <<EOF +.pushsection foo_section +.popsection +EOF + if AC_TRY_COMMAND(${CC-cc} -c $CFLAGS conftest.s 1>&AC_FD_CC); then + libc_cv_asm_popsection_directive=yes + else + libc_cv_asm_popsection_directive=no + fi + rm -f conftest*]) + if test $libc_cv_asm_popsection_directive = yes; then + AC_DEFINE(HAVE_ASM_POPSECTION_DIRECTIVE) + fi + fi +fi + if test $elf != yes; then AC_CACHE_CHECK(for .init and .fini sections, libc_cv_have_initfini, [AC_TRY_COMPILE(, [asm (".section .init"); diff --git a/elf/Makefile b/elf/Makefile index 8f98cb8406..87f2d0d67d 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -41,6 +41,8 @@ extra-libs = libdl extra-libs-others = $(extra-libs) libdl-routines := dlopen dlclose dlsym dlerror dladdr +before-compile = $(objpfx)trusted-dirs.h + all: # Make this the default target; it will be defined in Rules. @@ -92,6 +94,17 @@ $(objpfx)$(rtld-installed-name): $(objpfx)ld.so ln -s $(<F) $@ endif +# Build a file mentioning all trustworthy directories to look for shared +# libraries when using LD_LIBRARY_PATH in a setuid program. The user can +# add directories to the list by defining $(user-defined-trusted-dirs) +# before starting make. +$(objpfx)trusted-dirs.h: Makefile + (for dir in `echo "$(default-rpath) $(user-defined-trusted-dirs)" | \ + sed 's/:/ /g'`; do \ + echo " \"$$dir\","; \ + done;) > $@T + mv -f $@T $@ +CFLAGS-dl-load.c = -I$(objdir)/$(subdir) # Specify the dependencies of libdl.so; its commands come from the generic # rule to build a shared library. diff --git a/elf/dl-error.c b/elf/dl-error.c index 52eb577eb0..a19ccff626 100644 --- a/elf/dl-error.c +++ b/elf/dl-error.c @@ -37,6 +37,11 @@ struct catch this is null. */ static struct catch *catch; +/* This points to a function which is called when an error is + received. Unlike the handling of `catch' this function may return. + The arguments will be the `errstring' and `objname'. */ +static receiver_fct receiver; + void _dl_signal_error (int errcode, @@ -58,6 +63,13 @@ _dl_signal_error (int errcode, catch->objname = objname; longjmp (catch->env, errcode ?: -1); } + else if (receiver) + { + /* We are inside _dl_receive_error. Call the user supplied + handler and resume the work. The receiver will still + installed. */ + (*receiver) (errstring, objname); + } else { /* Lossage while resolving the program's own symbols is always fatal. */ @@ -77,6 +89,8 @@ _dl_catch_error (char **errstring, { int errcode; struct catch *old, c = { errstring: NULL, objname: NULL }; + /* We need not handle `receiver' since setting a `catch' is handle + before it. */ old = catch; errcode = setjmp (c.env); @@ -96,3 +110,22 @@ _dl_catch_error (char **errstring, *objname = c.objname; return errcode == -1 ? 0 : errcode; } + +void +_dl_receive_error (receiver_fct fct, void (*operate) (void)) +{ + struct catch *old_catch; + receiver_fct old_receiver; + + old_catch = catch; + old_receiver = receiver; + + /* Set the new values. */ + catch = NULL; + receiver = fct; + + (*operate) (); + + catch = old_catch; + receiver = old_receiver; +} diff --git a/elf/dl-load.c b/elf/dl-load.c index 7dc6d91a02..6a3d919976 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -1,5 +1,5 @@ /* _dl_map_object -- Map in a shared object's segments from the file. - Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -409,7 +409,8 @@ _dl_map_object_from_fd (char *name, int fd, char *realname, static int open_path (const char *name, size_t namelen, const char *dirpath, - char **realname) + char **realname, + const char *trusted_dirs[]) { char *buf; const char *p; @@ -426,13 +427,42 @@ open_path (const char *name, size_t namelen, do { size_t buflen; + size_t this_len; dirpath = p; p = strpbrk (dirpath, ":;"); if (p == NULL) p = strchr (dirpath, '\0'); - if (p == dirpath) + this_len = p - dirpath; + + /* When we run a setuid program we do not accept any directory. */ + if (__libc_enable_secure) + { + /* All trusted directory must be complete name. */ + if (dirpath[0] != '/') + continue; + + /* If we got a list of trusted directories only accept one + of these. */ + if (trusted_dirs != NULL) + { + const char **trust = trusted_dirs; + + while (*trust != NULL) + if (memcmp (dirpath, *trust, this_len) == 0 + && (*trust)[this_len] == '\0') + break; + else + ++trust; + + /* If directory is not trusted, ignore this directory. */ + if (*trust == NULL) + continue; + } + } + + if (this_len == 0) { /* Two adjacent colons, or a colon at the beginning or the end of the path means to search the current directory. */ @@ -442,10 +472,10 @@ open_path (const char *name, size_t namelen, else { /* Construct the pathname to try. */ - (void) memcpy (buf, dirpath, p - dirpath); - buf[p - dirpath] = '/'; - (void) memcpy (&buf[(p - dirpath) + 1], name, namelen); - buflen = p - dirpath + 1 + namelen; + (void) memcpy (buf, dirpath, this_len); + buf[this_len] = '/'; + (void) memcpy (&buf[this_len + 1], name, namelen); + buflen = this_len + 1 + namelen; } fd = __open (buf, O_RDONLY); @@ -508,9 +538,9 @@ _dl_map_object (struct link_map *loader, const char *name, int type, size_t namelen = strlen (name) + 1; - inline void trypath (const char *dirpath) + inline void trypath (const char *dirpath, const char *trusted[]) { - fd = open_path (name, namelen, dirpath, &realname); + fd = open_path (name, namelen, dirpath, &realname, trusted); } fd = -1; @@ -521,16 +551,24 @@ _dl_map_object (struct link_map *loader, const char *name, int type, if (l && l->l_info[DT_RPATH]) trypath ((const char *) (l->l_addr + l->l_info[DT_STRTAB]->d_un.d_ptr + - l->l_info[DT_RPATH]->d_un.d_val)); + l->l_info[DT_RPATH]->d_un.d_val), NULL); /* If dynamically linked, try the DT_RPATH of the executable itself. */ l = _dl_loaded; if (fd == -1 && l && l->l_type != lt_loaded && l->l_info[DT_RPATH]) trypath ((const char *) (l->l_addr + l->l_info[DT_STRTAB]->d_un.d_ptr + - l->l_info[DT_RPATH]->d_un.d_val)); + l->l_info[DT_RPATH]->d_un.d_val), NULL); /* Try an environment variable (unless setuid). */ if (fd == -1 && ! __libc_enable_secure) - trypath (getenv ("LD_LIBRARY_PATH")); + { + static const char *trusted_dirs[] = + { +#include "trusted-dirs.h" + NULL + }; + + trypath (getenv ("LD_LIBRARY_PATH"), trusted_dirs); + } if (fd == -1) { /* Check the list of libraries in the file /etc/ld.so.cache, @@ -555,7 +593,7 @@ _dl_map_object (struct link_map *loader, const char *name, int type, if (fd == -1) { extern const char *_dl_rpath; /* Set in rtld.c. */ - trypath (_dl_rpath); + trypath (_dl_rpath, NULL); } } else @@ -590,6 +628,7 @@ _dl_map_object (struct link_map *loader, const char *name, int type, are only interested in the list of libraries this isn't so severe. Fake an entry with all the information we have (in fact only the name). */ + static const ElfW(Symndx) dummy_bucket = STN_UNDEF; /* Enter the new object in the list of loaded objects. */ if ((name_copy = local_strdup (name)) == NULL @@ -599,6 +638,11 @@ _dl_map_object (struct link_map *loader, const char *name, int type, /* We use an opencount of 0 as a sign for the faked entry. */ l->l_opencount = 0; l->l_reserved = 0; + l->l_buckets = &dummy_bucket; + l->l_nbuckets = 1; + l->l_relocated = 1; + + return l; } else _dl_signal_error (errno, name, "cannot open shared object file"); diff --git a/elf/ldd.bash.in b/elf/ldd.bash.in index 6e2b51591a..d174709380 100644 --- a/elf/ldd.bash.in +++ b/elf/ldd.bash.in @@ -29,23 +29,39 @@ TEXTDOMAIN=libc TEXTDOMAINDIR=@TEXTDOMAINDIR@ RTLD=@RTLD@ +RELOCS= while test $# -gt 0; do case "$1" in - --v*) + --v | --ve | --ver | --vers | --versi | --versio | --version) echo $"ldd (GNU libc) @VERSION@ Copyright (C) 1996, 1997 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." exit 0 ;; - --h*) + --h | --he | --hel | --help) echo $"ldd [OPTION]... FILE... - --help print this help and exit - --version print version information and exit + --help print this help and exit + --version print version information and exit + -d, --data-relocs process data relocations + -r, --function-relocs process data and function relocations Report bugs using the \`glibcbug' script to <bugs@gnu.ai.mit.edu>." exit 0 ;; + -d | --d | --da | --dat | --data | --data- | --data-r | --data-re | \ + --data-rel | --data-relo | --data-reloc | --data-relocs) + RELOCS='--data-relocs' + shift ;; + -r | --f | --fu | --fun | --func | --funct | --functi | --functio | \ + --function | --function- | --function-r | --function-re | --function-rel | \ + --function-relo | --function-reloc | --function-relocs) + RELOCS='--function-relocs' + shift ;; --) # Stop option processing. shift; break ;; + -*) + echo >&2 $"ldd: unrecognized option" "\`$1'" + echo >&2 $"Try \`ldd --help' for more information." + exit 1 ;; *) break ;; esac @@ -53,9 +69,8 @@ done case $# in 0) - echo >&2 $"\ -ldd: missing file arguments -Try \`ldd --help' for more information." + echo >&2 $"ldd: missing file arguments" + echo >&2 $"Try \`ldd --help' for more information." exit 1 ;; 1) # We don't list the file name when there is only one. @@ -65,14 +80,21 @@ Try \`ldd --help' for more information." esac if test ! -f "$file"; then echo "${file}:" $"no such file" - elif ${RTLD} --verify "$file"; then - LD_TRACE_LOADED_OBJECTS=1 exec ${RTLD} "$file" && exit 1 + exit 1 else - echo $" not a dynamic executable" + test -x "$file" || + echo $"warning: you do not have execution permission for" "\`$file'" + if ${RTLD} --verify "$file"; then + LD_TRACE_LOADED_OBJECTS=1 exec ${RTLD} ${RELOCS} "$file" || exit 1 + else + echo $" not a dynamic executable" + exit 1 + fi fi exit ;; *) set -e # Bail out immediately if ${RTLD} loses on any argument. + result=0 for file; do echo "${file}:" case "$file" in @@ -80,16 +102,22 @@ Try \`ldd --help' for more information." *) file="./$file" ;; esac if test ! -f "$file"; then - echo "$file:" $"no such file" - elif ${RTLD} --verify "$file"; then - LD_TRACE_LOADED_OBJECTS=1 ${RTLD} "$file" + echo "${file}:" $"no such file" + result=1 else - echo $" not a dynamic executable" + test -x "$file" || + echo $"warning: you do not have execution permission for" "\`$file'" + if ${RTLD} --verify "$file"; then + LD_TRACE_LOADED_OBJECTS=1 ${RTLD} ${RELOCS} "$file" || result=1 + else + echo $" not a dynamic executable" + result=1 + fi fi done esac -exit 0 +exit $result # Local Variables: # mode:ksh # End: diff --git a/elf/ldd.sh.in b/elf/ldd.sh.in index 5b6cc3a75d..4351578b6d 100644 --- a/elf/ldd.sh.in +++ b/elf/ldd.sh.in @@ -25,23 +25,40 @@ # variable LD_TRACE_LOADED_OBJECTS to a non-empty value. RTLD=@RTLD@ +RELOCS= while test $# -gt 0; do case "$1" in - --v*) + --v | --ve | --ver | --vers | --versi | --versio | --version) echo 'ldd (GNU libc) @VERSION@ Copyright (C) 1996, 1997 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.' exit 0 ;; - --h*) + --h | --he | --hel | --help) echo "ldd [OPTION]... FILE... - --help print this help and exit - --version print version information and exit + --help print this help and exit + --version print version information and exit + -d, --data-relocs process data relocations + -r, --function-relocs process data and function relocations Report bugs using the \`glibcbug' script to <bugs@gnu.ai.mit.edu>." exit 0 ;; + -d | --d | --da | --dat | --data | --data- | --data-r | --data-re | \ + --data-rel | --data-relo | --data-reloc | --data-relocs) + RELOCS='--data-relocs' + shift ;; + -r | --f | --fu | --fun | --func | --funct | --functi | --functio | \ + --function | --function- | --function-r | --function-re | --function-rel | \ + --function-relo | --function-reloc | --function-relocs) + RELOCS='--function-relocs' + shift ;; --) # Stop option processing. shift; break ;; + -*) + echo >&2 "\ +ldd: unrecognized option \`$1' +Try \`ldd --help' for more information." + exit 1 ;; *) break ;; esac @@ -61,14 +78,21 @@ Try \`ldd --help' for more information." esac if test ! -f "$file"; then echo "${file}: no such file" - elif ${RTLD} --verify "$file"; then - LD_TRACE_LOADED_OBJECTS=1 exec ${RTLD} "$file" && exit 1 + exit 1 else - echo ' not a dynamic executable' + test -x "$file" || + echo "warning: you do not have execution permission for \`$file'" + if ${RTLD} --verify "$file"; then + LD_TRACE_LOADED_OBJECTS=1 exec ${RTLD} ${RELOCS} "$file" || exit 1 + else + echo ' not a dynamic executable' + exit 1 + fi fi exit ;; *) set -e # Bail out immediately if ${RTLD} loses on any argument. + result=0 for file; do echo "${file}:" case "$file" in @@ -76,13 +100,19 @@ Try \`ldd --help' for more information." *) file="./$file" ;; esac if test ! -f "$file"; then - echo "$file: no such file" - elif ${RTLD} --verify "$file"; then - LD_TRACE_LOADED_OBJECTS=1 ${RTLD} "$file" + echo "${file}: no such file" + result=1 else - echo ' not a dynamic executable' + test -x "$file" || + echo "warning: you do not have execution permission for \`$file'" + if ${RTLD} --verify "$file"; then + LD_TRACE_LOADED_OBJECTS=1 ${RTLD} ${RELOCS} "$file" || result=1 + else + echo ' not a dynamic executable' + result=1 + fi fi done esac -exit 0 +exit $result diff --git a/elf/link.h b/elf/link.h index 7e0b60793f..95d8f0912d 100644 --- a/elf/link.h +++ b/elf/link.h @@ -137,6 +137,12 @@ struct link_map unsigned int l_global:1; /* Nonzero if object in _dl_global_scope. */ unsigned int l_reserved:2; /* Reserved for internal use. */ }; + + +/* Function used as argument for `_dl_receive_error' function. The + arguments are the error string and the objname the error occurred + in. */ +typedef void (*receiver_fct) (const char *, const char *); /* Internal functions of the run-time dynamic linker. These can be accessed if you link again the dynamic linker @@ -161,6 +167,11 @@ extern int _dl_sysdep_open_zero_fill (void); /* dl-sysdep.c */ are concatenated to form the message to print. */ extern void _dl_sysdep_message (const char *string, ...); +/* OS-dependent function to write a message on the standard error. + All arguments are `const char *'; args until a null pointer + are concatenated to form the message to print. */ +extern void _dl_sysdep_error (const char *string, ...); + /* OS-dependent function to give a fatal error message and exit when the dynamic linker fails before the program is fully linked. All arguments are `const char *'; args until a null pointer @@ -177,11 +188,9 @@ extern int _dl_secure; zero; OBJECT is the name of the problematical shared object, or null if it is a general problem; ERRSTRING is a string describing the specific problem. */ - extern void _dl_signal_error (int errcode, const char *object, - const char *errstring) - __attribute__ ((__noreturn__)); + const char *errstring); /* Call OPERATE, catching errors from `dl_signal_error'. If there is no error, *ERRSTRING is set to null. If there is an error, *ERRSTRING and @@ -192,6 +201,11 @@ extern int _dl_catch_error (char **errstring, const char **object, void (*operate) (void)); +/* Call OPERATE, receiving errors from `dl_signal_error'. Unlike + `_dl_catch_error' the operation is resumed after the OPERATE + function returns. */ +extern void _dl_receive_error (receiver_fct fct, void (*operate) (void)); + /* Helper function for <dlfcn.h> functions. Runs the OPERATE function via _dl_catch_error. Returns zero for success, nonzero for failure; and diff --git a/elf/rtld.c b/elf/rtld.c index 39435f8243..f9a2cd3d03 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -44,6 +44,10 @@ extern void *_dl_sysdep_read_whole_file (const char *filename, size_t *filesize_ptr, int mmap_prot); +/* Helper function to handle errors while resolving symbols. */ +static void print_unresolved (const char *errstring, const char *objname); + + int _dl_argc; char **_dl_argv; const char *_dl_rpath; @@ -142,11 +146,19 @@ dl_main (const ElfW(Phdr) *phdr, enum { normal, list, verify, trace } mode; struct link_map **preloads; unsigned int npreloads; + const char *preloadlist; size_t file_size; char *file; mode = getenv ("LD_TRACE_LOADED_OBJECTS") != NULL ? trace : normal; + /* LAZY is determined by the parameters --datadeps and --function-deps + if we trace the binary. */ + if (mode == trace) + lazy = -1; + else + lazy = !__libc_enable_secure && *(getenv ("LD_BIND_NOW") ?: "") == '\0'; + /* Set up a flag which tells we are just starting. */ _dl_starting_up = 1; @@ -186,22 +198,44 @@ of this helper program; chances are you did not intend to run this program.\n", /* Note the place where the dynamic linker actually came from. */ _dl_rtld_map.l_name = _dl_argv[0]; - if (! strcmp (_dl_argv[1], "--list")) - { - mode = list; + while (_dl_argc > 1) + if (! strcmp (_dl_argv[1], "--list")) + { + mode = list; + lazy = -1; /* This means do no dependency analysis. */ - ++_dl_skip_args; - --_dl_argc; - ++_dl_argv; - } - else if (! strcmp (_dl_argv[1], "--verify")) - { - mode = verify; + ++_dl_skip_args; + --_dl_argc; + ++_dl_argv; + } + else if (! strcmp (_dl_argv[1], "--verify")) + { + mode = verify; - ++_dl_skip_args; - --_dl_argc; - ++_dl_argv; - } + ++_dl_skip_args; + --_dl_argc; + ++_dl_argv; + } + else if (! strcmp (_dl_argv[1], "--data-relocs")) + { + mode = trace; + lazy = 1; /* This means do only data relocation analysis. */ + + ++_dl_skip_args; + --_dl_argc; + ++_dl_argv; + } + else if (! strcmp (_dl_argv[1], "--function-relocs")) + { + mode = trace; + lazy = 0; /* This means do also function relocation analysis. */ + + ++_dl_skip_args; + --_dl_argc; + ++_dl_argv; + } + else + break; ++_dl_skip_args; --_dl_argc; @@ -311,23 +345,22 @@ of this helper program; chances are you did not intend to run this program.\n", preloads = NULL; npreloads = 0; - if (! __libc_enable_secure) + preloadlist = getenv ("LD_PRELOAD"); + if (preloadlist) { - const char *preloadlist = getenv ("LD_PRELOAD"); - if (preloadlist) - { - /* The LD_PRELOAD environment variable gives a white space - separated list of libraries that are loaded before the - executable's dependencies and prepended to the global - scope list. */ - char *list = strdupa (preloadlist); - char *p; - while ((p = strsep (&list, " ")) != NULL) - { - (void) _dl_map_object (NULL, p, lt_library, 0); - ++npreloads; - } - } + /* The LD_PRELOAD environment variable gives a white space + separated list of libraries that are loaded before the + executable's dependencies and prepended to the global scope + list. If the binary is running setuid all elements + containing a '/' are ignored since it is insecure. */ + char *list = strdupa (preloadlist); + char *p; + while ((p = strsep (&list, " ")) != NULL) + if (! __libc_enable_secure || strchr (p, '/') == NULL) + { + (void) _dl_map_object (NULL, p, lt_library, 0); + ++npreloads; + } } /* Read the contents of the file. */ @@ -496,12 +529,31 @@ of this helper program; chances are you did not intend to run this program.\n", *--bp = '0'; _dl_sysdep_message (" in object at 0x", bp, "\n", NULL); } + else if (lazy >= 0) + { + /* We have to do symbol dependency testing. */ + void doit (void) + { + _dl_relocate_object (l, _dl_object_relocation_scope (l), lazy); + } + + l = _dl_loaded; + while (l->l_next) + l = l->l_next; + do + { + if (l != &_dl_rtld_map && l->l_opencount > 0) + { + _dl_receive_error (print_unresolved, doit); + *_dl_global_scope_end = NULL; + } + l = l->l_prev; + } while (l); + } _exit (0); } - lazy = !__libc_enable_secure && *(getenv ("LD_BIND_NOW") ?: "") == '\0'; - { /* Now we have all the objects loaded. Relocate them all except for the dynamic linker itself. We do this in reverse order so that copy @@ -573,3 +625,11 @@ of this helper program; chances are you did not intend to run this program.\n", /* Once we return, _dl_sysdep_start will invoke the DT_INIT functions and then *USER_ENTRY. */ } + +/* This is a little helper function for resolving symbols while + tracing the binary. */ +static void +print_unresolved (const char *errstring, const char *objname) +{ + _dl_sysdep_error (errstring, " (", objname, ")\n", NULL); +} diff --git a/libc-symbols.h b/libc-symbols.h index b583f33133..07a35f1b53 100644 --- a/libc-symbols.h +++ b/libc-symbols.h @@ -224,8 +224,20 @@ extern const char _libc_intl_domainname[]; warning message MSG. */ #ifdef HAVE_GNU_LD #ifdef HAVE_ELF + +/* We want the .gnu.warning.SYMBOL section to be unallocated. */ +#ifdef HAVE_ASM_PREVIOUS_DIRECTIVE +#define __make_section_unallocated(section_string) \ + asm(".section " section_string "; .previous"); +#elif defined (HAVE_ASM_POPSECTION_DIRECTIVE) +#define __make_section_unallocated(section_string) \ + asm(".pushsection " section_string "; .popsection"); +#else +#define __make_section_unallocated(section_string) +#endif + #define link_warning(symbol, msg) \ - asm(".section .gnu.warning." #symbol "; .previous"); \ + __make_section_unallocated (".gnu.warning." #symbol) \ static const char __evoke_link_warning_##symbol[] \ __attribute__ ((section (".gnu.warning." #symbol))) = msg; #else diff --git a/libio/Makefile b/libio/Makefile index 00eeb54fee..e24e6ff66a 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1995, 1996 Free Software Foundation, Inc. +# Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -32,7 +32,7 @@ routines := \ \ clearerr feof ferror fgetc fileno fputc freopen fseek getc getchar \ memstream pclose putc putchar rewind setbuf setlinebuf vasprintf \ - vdprintf vscanf vsnprintf obprintf fcloseall \ + iovdprintf vscanf vsnprintf obprintf fcloseall \ \ libc_fatal diff --git a/libio/vdprintf.c b/libio/iovdprintf.c index b4b1cc337c..b4b1cc337c 100644 --- a/libio/vdprintf.c +++ b/libio/iovdprintf.c diff --git a/malloc/Makefile b/malloc/Makefile index c98bea686c..449e45e6f6 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc. +# Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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 @@ -27,7 +27,7 @@ dist-headers := malloc.h headers := $(dist-headers) obstack.h tests := mallocbug -distribute = thread-m.h mtrace.awk +distribute = thread-m.h mtrace.awk mcheck-init.c mcheck.h # Things which get pasted together into gmalloc.c. gmalloc-routines := malloc morecore diff --git a/manual/filesys.texi b/manual/filesys.texi index 54ea99cfd4..f5d94b9732 100644 --- a/manual/filesys.texi +++ b/manual/filesys.texi @@ -336,7 +336,7 @@ value. Use @code{readdir_r} when this is critical. @comment dirent.h @comment GNU @deftypefun int readdir_r (DIR *@var{dirstream}, struct *@var{entry}, struct **@var{result}) -This function is the reentrant version of @code{reentrant}. Like +This function is the reentrant version of @code{readdir}. Like @code{readdir} it returns the next entry from the directory. But to prevent conflicts for simultaneously running threads the result is not stored in some internal memory. Instead the argument @var{entry} has to diff --git a/nss/Makefile b/nss/Makefile index a39f631b6c..6f555af469 100644 --- a/nss/Makefile +++ b/nss/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1996 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -24,7 +24,7 @@ subdir := nss headers := nss.h distribute := nsswitch.h XXX-lookup.c getXXbyYY.c getXXbyYY_r.c \ getXXent.c getXXent_r.c databases.def \ - nsswitch.conf db-Makefile + nsswitch.conf db-Makefile digits_dots.c # This is the trivial part which goes into libc itself. routines = nsswitch $(addsuffix -lookup,$(databases)) diff --git a/resolv/Makefile b/resolv/Makefile index 4590f267e8..41623cd067 100644 --- a/resolv/Makefile +++ b/resolv/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -33,7 +33,7 @@ libresolv-routines := gethnamaddr res_comp res_debug \ res_data res_mkquery res_query res_send \ inet_net_ntop inet_net_pton inet_neta base64 -subdirs-dirs = nss_dns +subdir-dirs = nss_dns vpath %.c nss_dns libnss_dns-routines := dns-host dns-network diff --git a/sysdeps/generic/dl-sysdep.c b/sysdeps/generic/dl-sysdep.c index 0dfb499d52..32697e782a 100644 --- a/sysdeps/generic/dl-sysdep.c +++ b/sysdeps/generic/dl-sysdep.c @@ -1,21 +1,21 @@ /* Operating system support for run-time dynamic linker. Generic Unix version. -Copyright (C) 1995, 96 Free Software Foundation, Inc. -This file is part of the GNU C Library. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library is 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. + 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. */ + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include <elf.h> #include <sys/types.h> @@ -193,6 +193,22 @@ _dl_sysdep_fatal (const char *msg, ...) void +_dl_sysdep_error (const char *msg, ...) +{ + va_list ap; + + va_start (ap, msg); + do + { + size_t len = strlen (msg); + __write (STDERR_FILENO, msg, len); + msg = va_arg (ap, const char *); + } while (msg); + va_end (ap); +} + + +void _dl_sysdep_message (const char *msg, ...) { va_list ap; diff --git a/sysdeps/generic/sockaddrcom.h b/sysdeps/generic/sockaddrcom.h index a4e7698987..8b1de11c15 100644 --- a/sysdeps/generic/sockaddrcom.h +++ b/sysdeps/generic/sockaddrcom.h @@ -1,5 +1,5 @@ /* Definition of `struct sockaddr_*' common members. Generic/4.2 BSD version. - Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -21,12 +21,15 @@ #define _SOCKADDRCOM_H 1 +/* POSIX.1g specifies this type name for the `sa_family' member. */ +typedef unsigned short int sa_family_t; + /* This macro is used to declare the initial common members of the data types used for socket addresses, `struct sockaddr', `struct sockaddr_in', `struct sockaddr_un', etc. */ #define __SOCKADDR_COMMON(sa_prefix) \ - unsigned short int sa_prefix##family + sa_family_t sa_prefix##family #define __SOCKADDR_COMMON_SIZE (sizeof (unsigned short int)) diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index f8d82a3cf7..bf1462a899 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -1,5 +1,5 @@ /* Operating system support for run-time dynamic linker. Hurd version. - Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -239,6 +239,29 @@ _dl_sysdep_fatal (const char *msg, ...) void +_dl_sysdep_error (const char *msg, ...) +{ + va_list ap; + + va_start (ap, msg); + do + { + size_t len = strlen (msg); + mach_msg_type_number_t nwrote; + do + { + if (__io_write (_hurd_init_dtable[2], msg, len, -1, &nwrote)) + break; + len -= nwrote; + msg += nwrote; + } while (nwrote > 0); + msg = va_arg (ap, const char *); + } while (msg); + va_end (ap); +} + + +void _dl_sysdep_message (const char *msg, ...) { va_list ap; diff --git a/sysdeps/sparc/fpu_control.h b/sysdeps/sparc/fpu_control.h new file mode 100644 index 0000000000..a8015abc29 --- /dev/null +++ b/sysdeps/sparc/fpu_control.h @@ -0,0 +1,86 @@ +/* FPU control word bits. SPARC version. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Miguel de Icaza + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _FPU_CONTROL_H +#define _FPU_CONTROL_H 1 + + +#include <features.h> + +/* precision control */ +#define _FPU_EXTENDED 0x00000000 /* RECOMMENDED */ +#define _FPU_DOUBLE 0x20000000 +#define _FPU_80BIT 0x30000000 +#define _FPU_SINGLE 0x10000000 /* DO NOT USE */ + +/* rounding control / Sparc */ +#define _FPU_RC_NEAREST 0x0 /* RECOMMENDED */ +#define _FPU_RC_DOWN 0x80000000 +#define _FPU_RC_UP 0xc0000000 +#define _FPU_RC_ZERO 0x40000000 + +#define _FPU_RESERVED 0x300000 /* Reserved bits in cw */ + + +/* Now two recommended cw */ + +/* Linux default: + - extended precision + - rounding to nearest + - exceptions on overflow, zero divide and NaN */ +#define _FPU_DEFAULT 0x1f + +/* IEEE: same as above, but exceptions */ +#define _FPU_IEEE 0x0 + +/* private namespace. It should only be used by crt0.o. */ +extern unsigned short __fpu_control; + +__BEGIN_DECLS + +/* called by crt0.o. It can be used to manipulate 387 control word. */ +extern void __setfpucw __P ((unsigned short)); + +__END_DECLS + +/* Type of the control word. */ +typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__))); + +#define _FPU_GETCW(cw) __asm__ ("st %%fsr,%0" : "=m" (*&cw)) +#define _FPU_SETCW(cw) __asm__ ("ld %0,%%fsr" : "=m" (*&cw)) + +#if 0 +/* The intel original macros */ +/* Macros for accessing the hardware control word. */ +#define _FPU_GETCW(cw) __asm__ ("fnstcw %0" : "=m" (*&cw)) +#define _FPU_SETCW(cw) __asm__ ("fldcw %0" : : "m" (*&cw)) +#endif + +/* Default control word set at startup. */ +extern fpu_control_t __fpu_control; + +__BEGIN_DECLS + +/* Called at startup. It can be used to manipulate fpu control register. */ +extern void __setfpucw __P ((fpu_control_t)); + +__END_DECLS + +#endif /* fpu_control.h */ diff --git a/sysdeps/stub/sysv_signal.c b/sysdeps/stub/sysv_signal.c new file mode 100644 index 0000000000..4d3e15aad0 --- /dev/null +++ b/sysdeps/stub/sysv_signal.c @@ -0,0 +1,42 @@ +/* Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <signal.h> + +/* Set the handler for the signal SIG to HANDLER, + returning the old handler, or SIG_ERR on error. */ +__sighandler_t +__sysv_signal (sig, handler) + int sig; + __sighandler_t handler; +{ + /* Check signal extents to protect __sigismember. */ + if (handler == SIG_ERR || sig < 1 || sig >= NSIG) + { + __set_errno (EINVAL); + return SIG_ERR; + } + + __set_errno (ENOSYS); + + return SIG_ERR; +} +weak_alias (__sysv_signal, sysv_signal) + +stub_warning (sysv_signal) diff --git a/sysdeps/unix/bsd/bsd4.4/sockaddrcom.h b/sysdeps/unix/bsd/bsd4.4/sockaddrcom.h index a99573c6ee..87da37df90 100644 --- a/sysdeps/unix/bsd/bsd4.4/sockaddrcom.h +++ b/sysdeps/unix/bsd/bsd4.4/sockaddrcom.h @@ -1,5 +1,5 @@ /* Definition of `struct sockaddr_*' common members. 4.4 BSD version. - Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -21,13 +21,16 @@ #define _SOCKADDRCOM_H 1 +/* POSIX.1g specifies this type name for the `sa_family' member. */ +typedef unsigned char sa_family_t; + /* This macro is used to declare the initial common members of the data types used for socket addresses, `struct sockaddr', `struct sockaddr_in', `struct sockaddr_un', etc. */ #define __SOCKADDR_COMMON(sa_prefix) \ unsigned char sa_prefix##len; \ - unsigned char sa_prefix##family + sa_family_t sa_prefix##family #define __SOCKADDR_COMMON_SIZE (2 * sizeof (unsigned char)) diff --git a/sysdeps/unix/sysv/linux/Dist b/sysdeps/unix/sysv/linux/Dist index 766d96a110..b96d1dfcf6 100644 --- a/sysdeps/unix/sysv/linux/Dist +++ b/sysdeps/unix/sysv/linux/Dist @@ -1,4 +1,5 @@ init-first.h +kernel_sigaction.h kernel_termios.h llseek.c siglist.h diff --git a/sysdeps/unix/sysv/linux/alpha/Dist b/sysdeps/unix/sysv/linux/alpha/Dist index a15f181ff6..368b49066d 100644 --- a/sysdeps/unix/sysv/linux/alpha/Dist +++ b/sysdeps/unix/sysv/linux/alpha/Dist @@ -6,3 +6,4 @@ clone.S sys/io.h kernel_termios.h sys/acct.h +sys/procfs.h diff --git a/sysdeps/unix/sysv/linux/net/if_arp.h b/sysdeps/unix/sysv/linux/net/if_arp.h index a25f1b4759..ae0e799fb6 100644 --- a/sysdeps/unix/sysv/linux/net/if_arp.h +++ b/sysdeps/unix/sysv/linux/net/if_arp.h @@ -1 +1,146 @@ -#include <linux/if_arp.h> +/* Definitions for Address Resolution Protocol. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* Based on the 4.4BSD and Linux version of this file. */ + +#ifndef _NET_IF_ARP_H + +#define _NET_IF_ARP_H 1 +#include <sys/cdefs.h> + +#include <sys/types.h> + +__BEGIN_DECLS + +/* This structure defines an ethernet arp header. */ + +/* ARP protocol opcodes. */ +#define ARPOP_REQUEST 1 /* ARP request. */ +#define ARPOP_REPLY 2 /* ARP reply. */ +#define ARPOP_RREQUEST 3 /* RARP request. */ +#define ARPOP_RREPLY 4 /* RARP reply. */ + +/* See RFC 826 for protocol description. ARP packets are variable + in size; the arphdr structure defines the fixed-length portion. + Protocol type values are the same as those for 10 Mb/s Ethernet. + It is followed by the variable-sized fields ar_sha, arp_spa, + arp_tha and arp_tpa in that order, according to the lengths + specified. Field names used correspond to RFC 826. */ + +struct arphdr + { + unsigned short int ar_hrd; /* Format of hardware address. */ + unsigned short int ar_pro; /* Format of protocol address. */ + unsigned char ar_hln; /* Length of hardware address. */ + unsigned char ar_pln; /* Length of protocol address. */ + unsigned short int ar_op; /* ARP opcode (command). */ +#if 0 + /* Ethernet looks like this : This bit is variable sized + however... */ + unsigned char __ar_sha[ETH_ALEN]; /* Sender hardware address. */ + unsigned char __ar_sip[4]; /* Sender IP address. */ + unsigned char __ar_tha[ETH_ALEN]; /* Target hardware address. */ + unsigned char __ar_tip[4]; /* Target IP address. */ +#endif + }; + + +/* ARP protocol HARDWARE identifiers. */ +#define ARPHRD_NETROM 0 /* From KA9Q: NET/ROM pseudo. */ +#define ARPHRD_ETHER 1 /* Ethernet 10Mbps. */ +#define ARPHRD_EETHER 2 /* Experimental Ethernet. */ +#define ARPHRD_AX25 3 /* AX.25 Level 2. */ +#define ARPHRD_PRONET 4 /* PROnet token ring. */ +#define ARPHRD_CHAOS 5 /* Chaosnet. */ +#define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB. */ +#define ARPHRD_ARCNET 7 /* ARCnet. */ +#define ARPHRD_APPLETLK 8 /* APPLEtalk. */ +#define ARPHRD_DLCI 15 /* Frame Relay DLCI. */ +#define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id). */ + +/* Dummy types for non ARP hardware */ +#define ARPHRD_SLIP 256 +#define ARPHRD_CSLIP 257 +#define ARPHRD_SLIP6 258 +#define ARPHRD_CSLIP6 259 +#define ARPHRD_RSRVD 260 /* Notional KISS type. */ +#define ARPHRD_ADAPT 264 +#define ARPHRD_ROSE 270 +#define ARPHRD_X25 271 /* CCITT X.25. */ +#define ARPHRD_PPP 512 + +#define ARPHRD_TUNNEL 768 /* IPIP tunnel. */ +#define ARPHRD_TUNNEL6 769 /* IPIP6 tunnel. */ +#define ARPHRD_FRAD 770 /* Frame Relay Access Device. */ +#define ARPHRD_SKIP 771 /* SKIP vif. */ +#define ARPHRD_LOOPBACK 772 /* Loopback device. */ +#define ARPHRD_LOCALTLK 773 /* Localtalk device. */ +#define ARPHRD_FDDI 774 /* Fiber Distributed Data Interface. */ +#define ARPHRD_BIF 775 /* AP1000 BIF. */ +#define ARPHRD_SIT 776 /* sit0 device - IPv6-in-IPv4. */ + + +/* ARP ioctl request. */ +struct arpreq + { + struct sockaddr arp_pa; /* Protocol address. */ + struct sockaddr arp_ha; /* Hardware address. */ + int arp_flags; /* Flags. */ + struct sockaddr arp_netmask; /* Netmask (only for proxy arps). */ + char arp_dev[16]; + }; + +struct arpreq_old + { + struct sockaddr arp_pa; /* Protocol address. */ + struct sockaddr arp_ha; /* Hardware address. */ + int arp_flags; /* Flags. */ + struct sockaddr arp_netmask; /* Netmask (only for proxy arps). */ + }; + +/* ARP Flag values. */ +#define ATF_COM 0x02 /* Completed entry (ha valid). */ +#define ATF_PERM 0x04 /* Permanent entry. */ +#define ATF_PUBL 0x08 /* Publish entry. */ +#define ATF_USETRAILERS 0x10 /* Has requested trailers. */ +#define ATF_NETMASK 0x20 /* Want to use a netmask (only + for proxy entries). */ +#define ATF_DONTPUB 0x40 /* Don't answer this addresses. */ +#define ATF_MAGIC 0x80 /* Automatically added entry. */ + + +/* Support for the user space arp daemon, arpd. */ +#define ARPD_UPDATE 0x01 +#define ARPD_LOOKUP 0x02 +#define ARPD_FLUSH 0x03 + +struct arpd_request + { + unsigned short int req; /* Request type. */ + u_int32_t ip; /* IP address of entry. */ + unsigned long int dev; /* Device entry is tied to. */ + unsigned long int stamp; + unsigned long int updated; + unsigned char ha[MAX_ADDR_LEN]; /* Hardware address. */ + }; + +__END_DECLS + +#endif /* net/if_arp.h */ diff --git a/sysdeps/unix/sysv/linux/net/ppp_defs.h b/sysdeps/unix/sysv/linux/net/ppp_defs.h index e51dba7dea..21a33b20a3 100644 --- a/sysdeps/unix/sysv/linux/net/ppp_defs.h +++ b/sysdeps/unix/sysv/linux/net/ppp_defs.h @@ -1 +1,3 @@ +#include <sys/types.h> +typedef u_int32_t __u32; #include <linux/ppp_defs.h> diff --git a/sysdeps/unix/sysv/linux/net/route.h b/sysdeps/unix/sysv/linux/net/route.h index a60df24c0a..531b069d12 100644 --- a/sysdeps/unix/sysv/linux/net/route.h +++ b/sysdeps/unix/sysv/linux/net/route.h @@ -1 +1,125 @@ -#include <linux/route.h> +/* Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* Based on the 4.4BSD and Linux version of this file. */ + +#ifndef _NET_ROUTE_H + +#define _NET_ROUTE_H 1 +#include <features.h> + +#include <sys/socket.h> +#include <sys/types.h> + + +/* This structure gets passed by the SIOCADDRT and SIOCDELRT calls. */ +struct rtentry + { + unsigned long int rt_pad1; + struct sockaddr rt_dst; /* Target address. */ + struct sockaddr rt_gateway; /* Gateway addr (RTF_GATEWAY). */ + struct sockaddr rt_genmask; /* Target network mask (IP). */ + unsigned short int rt_flags; + short int rt_pad2; + unsigned long int rt_pad3; + unsigned char rt_tos; + unsigned char rt_class; + short int rt_pad4; + short int rt_metric; /* +1 for binary compatibility! */ + char *rt_dev; /* Forcing the device at add. */ + unsigned long int rt_mtu; /* Per route MTU/Window. */ + unsigned long int rt_window; /* Window clamping. */ + unsigned short int rt_irtt; /* Initial RTT. */ + }; +/* Compatibility hack. */ +#define rt_mss rt_mtu + + +#define RTF_UP 0x0001 /* Route usable. */ +#define RTF_GATEWAY 0x0002 /* Destination is a gateway. */ + +#define RTF_HOST 0x0004 /* Host entry (net otherwise). */ +#define RTF_REINSTATE 0x0008 /* Reinstate route after timeout. */ +#define RTF_DYNAMIC 0x0010 /* Created dyn. (by redirect). */ +#define RTF_MODIFIED 0x0020 /* Modified dyn. (by redirect). */ +#define RTF_MTU 0x0040 /* Specific MTU for this route. */ +#define RTF_MSS RTF_MTU /* Compatibility. */ +#define RTF_WINDOW 0x0080 /* Per route window clamping. */ +#define RTF_IRTT 0x0100 /* Initial round trip time. */ +#define RTF_REJECT 0x0200 /* Reject route. */ +#define RTF_STATIC 0x0400 /* Manually injected route. */ +#define RTF_XRESOLVE 0x0800 /* External resolver. */ +#define RTF_NOFORWARD 0x1000 /* Forwarding inhibited. */ +#define RTF_THROW 0x2000 /* Go to next class. */ +#define RTF_NOPMTUDISC 0x4000 /* Do not send packets with DF. */ + +/* Bad idea. IPv6 should not use broken IPv4 interface. */ + +#define RTF_ADDRCONF 0x0800 /* Announced on link prefix. */ +#define RTF_INVALID 0x1000 +#define RTF_DCACHE 0x2000 +#define RTF_DEFAULT 0x4000 /* Route is a default route. */ +#define RTF_NEXTHOP 0x8000 /* Non gateway route with nexthop. */ + + +#define RTF_MAGIC 0x10000 /* Route added/deleted authomatically, + when interface changes its state. */ + +#define RTCF_VALVE 0x00200000 +#define RTCF_MASQ 0x00400000 +#define RTCF_NAT 0x00800000 +#define RTCF_DOREDIRECT 0x01000000 +#define RTCF_LOG 0x02000000 +#define RTCF_DIRECTSRC 0x04000000 + +#define RTF_LOCAL 0x80000000 +#define RTF_INTERFACE 0x40000000 +#define RTF_MULTICAST 0x20000000 +#define RTF_BROADCAST 0x10000000 +#define RTF_NAT 0x08000000 + +#define RTF_ADDRCLASSMASK 0xF8000000 +#define RT_ADDRCLASS(flags) ((__u_int32_t) flags >> 23) + +#define RT_TOS(tos) ((tos) & IPTOS_TOS_MASK) + +#define RT_LOCALADDR(flags) ((flags & RTF_ADDRCLASSMASK) \ + == (RTF_LOCAL|RTF_INTERFACE)) + +#define RT_CLASS_UNSPEC 0 +#define RT_CLASS_DEFAULT 253 + +#define RT_CLASS_MAIN 254 +#define RT_CLASS_LOCAL 255 +#define RT_CLASS_MAX 255 + + +#define RTMSG_ACK NLMSG_ACK +#define RTMSG_OVERRUN NLMSG_OVERRUN + +#define RTMSG_NEWDEVICE 0x11 +#define RTMSG_DELDEVICE 0x12 +#define RTMSG_NEWROUTE 0x21 +#define RTMSG_DELROUTE 0x22 +#define RTMSG_NEWRULE 0x31 +#define RTMSG_DELRULE 0x32 +#define RTMSG_CONTROL 0x40 + +#define RTMSG_AR_FAILED 0x51 /* Address Resolution failed. */ + +#endif /* net/route.h */ diff --git a/sysdeps/unix/sysv/linux/sparc/Dist b/sysdeps/unix/sysv/linux/sparc/Dist new file mode 100644 index 0000000000..6134c6056d --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/Dist @@ -0,0 +1,2 @@ +__sigtrampoline.S +clone.S diff --git a/sysdeps/unix/sysv/linux/sparc/Makefile b/sysdeps/unix/sysv/linux/sparc/Makefile new file mode 100644 index 0000000000..629e6b37df --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/Makefile @@ -0,0 +1,3 @@ +ifeq ($(subdir),signal) +sysdep_routines += __sigtrampoline +endif diff --git a/sysdeps/unix/sysv/linux/sparc/__sigtrampoline.S b/sysdeps/unix/sysv/linux/sparc/__sigtrampoline.S new file mode 100644 index 0000000000..d0fe760270 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/__sigtrampoline.S @@ -0,0 +1,142 @@ +/* Userland trampoline code for sigaction on Linux/SPARC */ +/* (C) 1996, 1997 Free Software Foundation, Inc. */ +/* This file is part of the GNU C Library. */ +/* Contributed by Miguel de Icaza (miguel@gnu.ai.mit.edu) */ +/* Many thanks go to David Miller for explaining all this to me */ +/* miguel@nuclecu.unam.mx */ +/* Sources: David Miller, 4.4BSD/SPARC code */ + +#include <sysdep.h> + +/* For REGWIN_SZ */ +#include <asm/ptrace.h> +#include <asm/psr.h> + +/* The C compiler frame size */ +#define CCFSZ 96 + + .text + +ENTRY(____sparc_signal_trampoline) + .global SYMBOL_NAME(____sig_table) + + /* Make room for 32 %f registers + %fsr + * this is 132 bytes + alignement = 136 + * 96 is the C frame size + */ + save %sp,-136-CCFSZ,%sp + + /* save regular registers */ + mov %g2,%l2 + mov %g3,%l3 + mov %g4,%l4 + mov %g5,%l5 + mov %g6,%l6 + mov %g7,%l7 + + /* save fpu registers */ + ld [%fp+64+16+20],%l0 /* load the psr from sigcontext */ + sethi %hi(PSR_EF),%l1 + andcc %l0,%l1,%l0 /* is floating point enabled? */ + be 1f + rd %y,%l1 /* save y anyways */ + + /* save fpu registers */ + st %fsr, [%sp + CCFSZ + 0] + std %f0, [%sp + CCFSZ + 8] + std %f2, [%sp + CCFSZ + 16] + std %f4, [%sp + CCFSZ + 24] + std %f6, [%sp + CCFSZ + 32] + std %f8, [%sp + CCFSZ + 40] + std %f10, [%sp + CCFSZ + 48] + std %f12, [%sp + CCFSZ + 56] + std %f14, [%sp + CCFSZ + 64] + std %f16, [%sp + CCFSZ + 72] + std %f18, [%sp + CCFSZ + 80] + std %f20, [%sp + CCFSZ + 88] + std %f22, [%sp + CCFSZ + 96] + std %f24, [%sp + CCFSZ + 104] + std %f26, [%sp + CCFSZ + 112] + std %f28, [%sp + CCFSZ + 120] + std %f30, [%sp + CCFSZ + 128] + +1: + /* Load signal number */ + ld [%fp + REGWIN_SZ],%o0 + mov %fp,%o1 + mov 0xfea,%o2 + + /* Sanity check */ + cmp %o0,33 + bl 1f + or %g0,%g0,%g1 /*Call sys_setup */ + t 0x10 +1: +#ifdef __PIC__ + /* Save return address */ + mov %o7,%o4 +___sxx: + call ___syy + nop +___syy: + sethi %hi(_GLOBAL_OFFSET_TABLE_-(___sxx-.)),%o5 + or %o5,%lo(_GLOBAL_OFFSET_TABLE_-(___sxx-.)),%o5 + add %o7,%o5,%o5 + /* restore return address */ + mov %o4,%o7 + mov %o5,%o4 + /* o4 has the GOT pointer */ +#endif + sethi %hi(SYMBOL_NAME(____sig_table)),%o5 + or %o5,%lo(SYMBOL_NAME(____sig_table)),%o5 +#ifdef __PIC__ + add %o5,%o4,%o4 + ld [%o4],%o5 +#endif + sll %o0,2,%o4 + add %o5,%o4,%o4 + ld [%o4],%o4 + ld [%fp + REGWIN_SZ + 4],%o1 /* Load subcode */ + ld [%fp + REGWIN_SZ + 8],%o2 /* pointer to sigcontext */ + call %o4 + ld [%fp + REGWIN_SZ + 12],%o3 /* Address where signal ocurred */ + + /* handler returned, restore state */ + tst %l0 + be 1f + wr %l1,%g0,%y + + /* fpu restoration */ + ld [%sp + CCFSZ + 0], %fsr + ldd [%sp + CCFSZ + 8], %f0 + ldd [%sp + CCFSZ + 16], %f2 + ldd [%sp + CCFSZ + 24], %f4 + ldd [%sp + CCFSZ + 32], %f6 + ldd [%sp + CCFSZ + 40], %f8 + ldd [%sp + CCFSZ + 48], %f10 + ldd [%sp + CCFSZ + 56], %f12 + ldd [%sp + CCFSZ + 64], %f14 + ldd [%sp + CCFSZ + 72], %f16 + ldd [%sp + CCFSZ + 80], %f18 + ldd [%sp + CCFSZ + 88], %f20 + ldd [%sp + CCFSZ + 96], %f22 + ldd [%sp + CCFSZ + 104], %f24 + ldd [%sp + CCFSZ + 112], %f26 + ldd [%sp + CCFSZ + 120], %f28 + ldd [%sp + CCFSZ + 128], %f30 + +1: + mov %l2,%g2 + mov %l3,%g3 + mov %l4,%g4 + mov %l5,%g5 + mov %l6,%g6 + mov %l7,%g7 + + /* call sigreturn */ + restore %g0,SYS_sigreturn,%g1 /* register back and set syscall */ + add %sp,64+16,%o0 + t 0x10 + /* if we return, sysreturn failed */ + mov SYS_exit,%g1 + t 0x10 diff --git a/sysdeps/unix/sysv/linux/sparc/brk.c b/sysdeps/unix/sysv/linux/sparc/brk.c new file mode 100644 index 0000000000..13bcb0459b --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/brk.c @@ -0,0 +1,56 @@ +/* brk system call for Linux/SPARC. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Miguel de Icaza (miguel@nuclecu.unam.mx) + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <unistd.h> +#include <sysdep.h> + +/* This must be initialized data because commons can't have aliases. */ +void *__curbrk = 0; + +/* Old braindamage in GCC's crtstuff.c requires this symbol in an attempt + to work around different old braindamage in the old Linux ELF dynamic + linker. */ +weak_alias (__curbrk, ___brk_addr) + +int +__brk (void *addr) +{ + void *newbrk, *scratch; + + asm ("mov %1, %%g1\n\t" + "mov %2, %%o0\n\t" + "t 0x10\n\t" + "mov %%o0, %0\n\t" + : "=r" (newbrk) + : "0" (SYS_brk), "r" (addr) + : "g1", "o0"); + + __curbrk = newbrk; + + if (newbrk < addr) + { + __set_errno (ENOMEM); + return -1; + } + + return 0; +} +weak_alias (__brk, brk) diff --git a/sysdeps/unix/sysv/linux/sparc/profil-counter.h b/sysdeps/unix/sysv/linux/sparc/profil-counter.h new file mode 100644 index 0000000000..1998c34ed5 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/profil-counter.h @@ -0,0 +1,35 @@ +/* Low-level statistical profiling support function. Linux/SPARC version. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <sigcontext.h> + +void +profil_counter (int signo, __siginfo_t si) +{ + extern int __sparc_old_signals; + + if (__sparc_old_signals) + { + struct sigcontext_struct *s = (void *) &si; + + profil_count ((void *) s->sigc_pc); + } + else + profil_count ((void *) si.si_regs.pc); +} diff --git a/sysdeps/unix/sysv/linux/sparc/sigaction.c b/sysdeps/unix/sysv/linux/sparc/sigaction.c new file mode 100644 index 0000000000..e7bda77de2 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sigaction.c @@ -0,0 +1,127 @@ +/* POSIX.1 sigaction call for Linux/SPARC. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Miguel de Icaza (miguel@nuclecu.unam.mx), 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <syscall.h> +#include <sys/signal.h> +#include <errno.h> + +/* The kernel will deliver signals in the old way if the signal + number is a positive number. The kernel will deliver a signal + with the new stack layout if the signal number is a negative number. + + Our sigaction code takes care of selecting the type of kernel we are + using at runtime. */ + +extern void ____sparc_signal_trampoline (int); +long ____sig_table [NSIG]; + +int +__trampoline_sigaction (int sig, struct sigaction *new, struct sigaction *old) +{ + int ret; + int need_to_hide_trick = 0; + __sighandler_t old_sh; + + if (new) + { + if (new->sa_handler != SIG_DFL && new->sa_handler != SIG_IGN) + { + old_sh = ____sig_table[sig]; + ____sig_table[sig] = (long int) new->sa_handler; + new->sa_handler = ____sparc_signal_trampoline; + need_to_hide_trick = 1; + } + } + __asm__("or %%g0,%0,%%g1\n\t" + "or %%g0,%1,%%o0\n\t" + "or %%g0,%2,%%o1\n\t" + "or %%g0,%3,%%o2\n\t" + "t 0x10\n\t" + "bcc 1f\n\t" + "or %%o0, %%g0, %0\n\t" + "sub %%g0, %%o0, %0\n\t" + "1:" + : "=r" (ret), "=r" ((long int) sig), "=r" ((long int) new), + "=r" ((long int) old) + : "0" (SYS_sigaction), "1" (sig), "2" (new), "3" (old) + : "g1", "o0", "o1", "o2"); + + if (ret >= 0) + { + if (old && old->sa_handler == ____sparc_signal_trampoline) + { + if (need_to_hide_trick) + old->sa_handler = old_sh; + else + old->sa_handler = ____sig_table[sig]; + } + if (need_to_hide_trick) + new->sa_handler = ____sig_table[sig]; + return 0; + } + __set_errno (-ret); + return -1; +} + +int +__new_sigaction (int sig, struct sigaction *new, struct sigaction *old) +{ + int ret; + + sig = -sig; + + __asm__("or %%g0,%0,%%g1\n\t" + "or %%g0,%1,%%o0\n\t" + "or %%g0,%2,%%o1\n\t" + "or %%g0,%3,%%o2\n\t" + "t 0x10\n\t" + "bcc 1f\n\t" + "or %%o0, %%g0, %0\n\t" + "sub %%g0,%%o0,%0\n\t" + "1:" + : "=r" (ret), "=r" ((long int) sig), "=r" ((long int) new), + "=r" ((long int) old) + : "0" (SYS_sigaction), "1" (sig), "2" (new), "3" (old) + : "g1", "o0", "o1", "o2"); + if (ret >= 0) + return 0; + __set_errno (-ret); + return -1; +} + +int +__sigaction (int sig, struct sigaction *new, struct sigaction *old) +{ + static (*sigact_routine) (int, struct sigaction *, struct sigaction *); + int ret; + struct sigaction sa; + + if (sigact_routine) + return (*sigact_routine) (sig, new, old); + + ret = __new_sigaction (1, NULL, &sa); + if (ret == -1) + sigact_routine = __trampoline_sigaction; + else + sigact_routine = __new_sigaction; + + return __sigaction (sig, new, old); +} +weak_alias (__sigaction, sigaction); diff --git a/sysdeps/unix/sysv/linux/sparc/socket.S b/sysdeps/unix/sysv/linux/sparc/socket.S new file mode 100644 index 0000000000..f8075201db --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/socket.S @@ -0,0 +1,58 @@ +/* Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Miguel de Icaza <miguel@gnu.ai.mit.edu>, 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <sysdep.h> +#include <sys/socketcall.h> + +#define P(a, b) P2(a, b) +#define P2(a, b) a##b + + .text +/* The socket-oriented system calls are handled unusally in Linux. + They are all gated through the single `socketcall' system call number. + `socketcall' takes two arguments: the first is the subcode, specifying + which socket function is being called; and the second is a pointer to + the arguments to the specific function. + + The .S files for the other calls just #define socket and #include this. */ + +.globl P(__,socket) +ENTRY (P(__,socket)) + mov SYS_ify(socketcall), %g1 /* System call number */ + + /* Use ## so `socket' is a separate token that might be #define'd. */ + mov P(SOCKOP_,socket), %o0 /* Subcode is first arg to syscall. */ + mov %i0,%o1 /* args pointer is second arg to syscall */ + + t 0x10 + bcc,a 1 + nop + save %sp,96,%sp + call __errno_location + nop + st %i0,[%o0] + restore + retl + mov -1,%o0 +1: + ret + +PSEUDO_END (P(__,socket)) + +weak_alias (P(__,socket), socket) diff --git a/sysdeps/unix/sysv/linux/sparc/syscall.S b/sysdeps/unix/sysv/linux/sparc/syscall.S new file mode 100644 index 0000000000..4166e4231b --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/syscall.S @@ -0,0 +1,30 @@ +/* Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#define DONT_LOAD_G1 +#include <sysdep.h> +ENTRY (__libc_syscall) + or %o0,%g0,%g1 + or %o1,%g0,%o0 + or %o2,%g0,%o1 + or %o3,%g0,%o2 + or %o4,%g0,%o3 + or %o5,%g0,%o4 +PSEUDO_NOENT(__libc_syscall, syscall, 5) + ret +SYSCALL__POST(syscall,5) diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h new file mode 100644 index 0000000000..0251a1f014 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h @@ -0,0 +1,57 @@ +/* Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Miguel de Icaza <miguel@gnu.ai.mit.edu>, January 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _LINUX_SPARC_SYSDEP_H +#define _LINUX_SPARC_SYSDEP_H 1 + +#include <sysdeps/unix/sparc/sysdep.h> + +#undef SYS_ify +#define SYS_ify(syscall_name) __NR_##syscall_name + +#ifdef ASSEMBLER + +#ifdef DONT_LOAD_G1 +# define LOADSYSCALL(x) +#else +# define LOADSYSCALL(x) mov SYS_##n, %g1 +#endif + +/* Linux/SPARC uses a different trap number and uses __errno_location always */ +#undef PSEUDO + +#define PSEUDO(name, syscall_name, args) \ + .text; \ + ENTRY(name); \ + LOADSYSCALL(syscall_name); \ + ta 0x10; \ + bcc,a 1f; \ + nop; \ + save %sp,96,%sp; \ + call __errno_location; \ + nop; \ + st %i0,[%o0]; \ + restore; \ + retl; \ + mov -1,%o0; \ +1: + +#endif /* ASSEMBLER */ + +#endif /* linux/sparc/sysdep.h */ diff --git a/sysdeps/unix/sysv/linux/sys/msq_buf.h b/sysdeps/unix/sysv/linux/sys/msq_buf.h index e885bd9c2f..0abc10f6e5 100644 --- a/sysdeps/unix/sysv/linux/sys/msq_buf.h +++ b/sysdeps/unix/sysv/linux/sys/msq_buf.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1996 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. @@ -46,8 +46,8 @@ struct msqid_ds unsigned short int __msg_cbytes;/* current number of bytes on queue */ unsigned short int msg_qnum; /* number of messages currently on queue */ unsigned short int msg_qbytes;/* max number of bytes allowed on queue */ - __pid_t msg_lspid; /* pid of last msgsnd() */ - __pid_t msg_lrpid; /* pid of last msgrcv() */ + int msg_lspid; /* pid of last msgsnd() */ + int msg_lrpid; /* pid of last msgrcv() */ }; #ifdef __USE_MISC diff --git a/sysdeps/unix/sysv/linux/sys/shm_buf.h b/sysdeps/unix/sysv/linux/sys/shm_buf.h index f6d853744f..642b7bd191 100644 --- a/sysdeps/unix/sysv/linux/sys/shm_buf.h +++ b/sysdeps/unix/sysv/linux/sys/shm_buf.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1996 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. @@ -48,8 +48,8 @@ struct shmid_ds __time_t shm_atime; /* time of last shmat() */ __time_t shm_dtime; /* time of last shmdt() */ __time_t shm_ctime; /* time of last change by shmctl() */ - __pid_t shm_cpid; /* pid of creator */ - __pid_t shm_lpid; /* pid of last shmop */ + int shm_cpid; /* pid of creator */ + int shm_lpid; /* pid of last shmop */ unsigned short int shm_nattch; /* number of current attaches */ unsigned short int __shm_npages; /* size of segment (pages) */ unsigned long int *__shm_pages; /* array of ptrs to frames -> SHMMAX */ diff --git a/time/asctime.c b/time/asctime.c index 25bc9de04c..82e9f72f3f 100644 --- a/time/asctime.c +++ b/time/asctime.c @@ -1,20 +1,20 @@ -/* Copyright (C) 1991, 1993, 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 -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. */ +/* Copyright (C) 1991, 1993, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "../locale/localeinfo.h" #include <errno.h> diff --git a/time/dysize.c b/time/dysize.c index 1f8f624556..a53ec7ba07 100644 --- a/time/dysize.c +++ b/time/dysize.c @@ -1,20 +1,20 @@ -/* Copyright (C) 1994 Free Software Foundation, Inc. -This file is part of the GNU C Library. +/* Copyright (C) 1994, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library is 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. + 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. */ + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include <time.h> diff --git a/time/gmtime.c b/time/gmtime.c index 364b4c9262..f9627e7b62 100644 --- a/time/gmtime.c +++ b/time/gmtime.c @@ -1,20 +1,20 @@ -/* Copyright (C) 1991, 1993, 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 -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. */ +/* Copyright (C) 1991, 1993, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include <stddef.h> #include <time.h> diff --git a/time/offtime.c b/time/offtime.c index 4e062df0d3..1469029bc0 100644 --- a/time/offtime.c +++ b/time/offtime.c @@ -1,26 +1,25 @@ -/* Copyright (C) 1991, 1993 Free Software Foundation, Inc. -This file is part of the GNU C Library. +/* Copyright (C) 1991, 1993, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library is 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. + 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. */ + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ -#include <ansidecl.h> #include <time.h> /* Defined in mktime.c. */ -extern CONST unsigned short int __mon_yday[2][13]; +extern const unsigned short int __mon_yday[2][13]; #define SECS_PER_HOUR (60 * 60) #define SECS_PER_DAY (SECS_PER_HOUR * 24) @@ -29,11 +28,13 @@ extern CONST unsigned short int __mon_yday[2][13]; offset OFFSET seconds east of UTC, and store year, yday, mon, mday, wday, hour, min, sec into *TP. */ void -DEFUN(__offtime, (t, offset, tp), - CONST time_t *t AND long int offset AND struct tm *tp) +__offtime (t, offset, tp) + const time_t *t; + long int offset; + struct tm *tp; { register long int days, rem, y; - register CONST unsigned short int *ip; + register const unsigned short int *ip; days = *t / SECS_PER_DAY; rem = *t % SECS_PER_DAY; @@ -58,7 +59,7 @@ DEFUN(__offtime, (t, offset, tp), tp->tm_wday += 7; y = 1970; -# define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400) +#define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400) while (days < 0 || days >= (__isleap (y) ? 366 : 365)) { diff --git a/time/strptime.c b/time/strptime.c index ce3f4e3877..3340b4317c 100644 --- a/time/strptime.c +++ b/time/strptime.c @@ -129,7 +129,7 @@ localtime_r (t, tp) #endif #define recursive(new_fmt) \ (*(new_fmt) != '\0' \ - || strptime_internal (rp, (new_fmt), tm, decided) != NULL) + && strptime_internal (rp, (new_fmt), tm, decided) != NULL) #ifdef _LIBC diff --git a/time/timegm.c b/time/timegm.c index 4dd87f46d2..288065a7e5 100644 --- a/time/timegm.c +++ b/time/timegm.c @@ -1,20 +1,20 @@ -/* Copyright (C) 1994 Free Software Foundation, Inc. -This file is part of the GNU C Library. +/* Copyright (C) 1994, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library is 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. + 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. */ + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include <time.h> diff --git a/time/tzset.c b/time/tzset.c index 8d8be34405..87dc6d6337 100644 --- a/time/tzset.c +++ b/time/tzset.c @@ -229,41 +229,41 @@ __tzset_internal (always) tz += l; } + + /* Figure out the DST offset from GMT. */ + if (*tz == '-' || *tz == '+') + tz_rules[1].offset = *tz++ == '-' ? 1L : -1L; + else + tz_rules[1].offset = -1L; + + switch (sscanf (tz, "%hu:%hu:%hu", &hh, &mm, &ss)) + { + default: + /* Default to one hour later than standard time. */ + tz_rules[1].offset = tz_rules[0].offset + (60 * 60); + break; + + case 1: + mm = 0; + case 2: + ss = 0; + case 3: + tz_rules[1].offset *= (min (ss, 59) + (min (mm, 59) * 60) + + (min (hh, 23) * (60 * 60))); + break; + } + for (l = 0; l < 3; ++l) + { + while (isdigit (*tz)) + ++tz; + if (l < 2 && *tz == ':') + ++tz; + } } else /* There is no DST. */ tz_rules[1].name = tz_rules[0].name; - /* Figure out the DST offset from GMT. */ - if (*tz == '-' || *tz == '+') - tz_rules[1].offset = *tz++ == '-' ? 1L : -1L; - else - tz_rules[1].offset = -1L; - - switch (sscanf (tz, "%hu:%hu:%hu", &hh, &mm, &ss)) - { - default: - /* Default to one hour later than standard time. */ - tz_rules[1].offset = tz_rules[0].offset + (60 * 60); - break; - - case 1: - mm = 0; - case 2: - ss = 0; - case 3: - tz_rules[1].offset *= (min (ss, 59) + (min (mm, 59) * 60) + - (min (hh, 23) * (60 * 60))); - break; - } - for (l = 0; l < 3; ++l) - { - while (isdigit (*tz)) - ++tz; - if (l < 2 && *tz == ':') - ++tz; - } - done_names: if (*tz == '\0' || (tz[0] == ',' && tz[1] == '\0')) @@ -1,4 +1,4 @@ /* This file just defines the current version number of libc. */ #define RELEASE "alpha" -#define VERSION "1.100" +#define VERSION "1.101" |