about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-06-21 02:59:26 +0000
committerUlrich Drepper <drepper@redhat.com>1997-06-21 02:59:26 +0000
commit5107cf1d7d27f17c6de68ec15a8e8d9dd5b471c1 (patch)
treedbe8fd6c6a69eac9e3e6f465ab6396d47f232e6f /sysdeps
parentd705269e75ff9846000abea981774b381b076482 (diff)
downloadglibc-5107cf1d7d27f17c6de68ec15a8e8d9dd5b471c1.tar.gz
glibc-5107cf1d7d27f17c6de68ec15a8e8d9dd5b471c1.tar.xz
glibc-5107cf1d7d27f17c6de68ec15a8e8d9dd5b471c1.zip
1997-06-21 02:48  Ulrich Drepper  <drepper@cygnus.com>

	* config.h.in: Add DO_STATIC_NSS.
	* config.make.in: Add build-static-nss.

	* elf/eval.c: Use __getdelim instead of __getline.

	* locale/programs/locale.c: Correct comment.

	* manual/libc.texinfo: Update copyright and date.
	Remove A4 option.

	* sysdeps/libm-ieee754/k_standard.c: Always return HUGE_VAL
	for gamma overflow.
	* sysdeps/libm-ieee754/w_gamma.c: Handle SVID and ISO C behaviour.
	* sysdeps/libm-ieee754/w_gammaf.c: Likewise.
	* sysdeps/libm-ieee754/w_gammalp.c: Likewise.

	* po/ko.po: Update.

1997-06-13 10:06  Richard Henderson  <rth@tamu.edu>

	The Great Bit File Move:
	* configure.in (AC_INIT): Look in include/ for features.h.
	(sysnames): Add include as the final search directory.
	(AC_OUTPUT): Create a bits directory in the build directory.
	* Makeconfig (CPPFLAGS): Look in include/ for libc-symbols.h.
	* Makefile: Make sure the target directory exists when installing
	<gnu/stubs.h> and <gnu/lib-names.h>.
	* csu/Makefile: Use $(compile.S) and $(compile.c) instead of
	invoking $(CC) directly, as the former have the full include path.

	* ansidecl.h: Removed.

	* aliases.h: Moved to include/.
	* alloca.h: Likewise.
	* argp.h: Likewise.
	* argz.h: Likewise.
	* arpa/ftp.h: Likewise.
	* arpa/inet.h: Likewise.
	* arpa/nameser.h: Likewise.
	* arpa/telnet.h: Likewise.
	* arpa/tftp.h: Likewise.
	* assert.h: Likewise.
	* ctype.h: Likewise.
	* db.h: Likewise.
	* dirent.h: Likewise.
	* dlfcn.h: Likewise.
	* elf.h: Likewise.
	* endian.h: Likewise.
	* envz.h: Likewise.
	* err.h: Likewise.
	* errno.h: Likewise.
	* error.h: Likewise.
	* fcntl.h: Likewise.
	* features.h: Likewise.
	* fnmatch.h: Likewise.
	* ftw.h: Likewise.
	* getopt.h: Likewise.
	* glob.h: Likewise.
	* gnu-versions.h: Likewise.
	* grp.h: Likewise.
	* langinfo.h: Likewise.
	* libc-symbols.h: Likewise.
	* libgen.h: Likewise.
	* libintl.h: Likewise.
	* limits.h: Likewise.
	* linewrap.h: Likewise.
	* link.h: Likewise.
	* locale.h: Likewise.
	* malloc.h: Likewise.
	* math.h: Likewise.
	* mathcalls.h: Likewise.
	* mcheck.h: Likewise.
	* memory.h: Likewise.
	* netdb.h: Likewise.
	* netgroup.h: Likewise.
	* netinet/ether.h: Likewise.
	* netinet/in.h: Likewise.
	* nlist.h: Likewise.
	* nss.h: Likewise.
	* nsswitch.h: Likewise.
	* obstack.h: Likewise.
	* poll.h: Likewise.
	* posix1_lim.h: Likewise.
	* posix2_lim.h: Likewise.
	* printf.h: Likewise.
	* protocols/routed.h: Likewise.
	* protocols/rwhod.h: Likewise.
	* protocols/talkd.h: Likewise.
	* protocols/timed.h: Likewise.
	* pwd.h: Likewise.
	* regex.h: Likewise.
	* resolv.h: Likewise.
	* rpc/auth_unix.h: Likewise.
	* rpc/clnt.h: Likewise.
	* rpc/netdb.h: Likewise.
	* rpc/pmap_clnt.h: Likewise.
	* rpc/pmap_prot.h: Likewise.
	* rpc/pmap_rmt.h: Likewise.
	* rpc/rpc.h: Likewise.
	* rpc/rpc_msg.h: Likewise.
	* rpc/svc.h: Likewise.
	* rpc/svc_auth.h: Likewise.
	* rpc/types.h: Likewise.
	* rpc/xdr.h: Likewise.
	* sched.h: Likewise.
	* search.h: Likewise.
	* set-hooks.h: Likewise.
	* setjmp.h: Likewise.
	* sgtty.h: Likewise.
	* shadow.h: Likewise.
	* signal.h: Likewise.
	* stab.def: Likewise.
	* stab.h: Likewise.
	* stdio.h: Likewise.
	* stdlib.h: Likewise.
	* string.h: Likewise.
	* strings.h: Likewise.
	* sys/bitypes.h: Likewise.
	* sys/cdefs.h: Likewise.
	* sys/dir.h: Likewise.
	* sys/errno.h: Likewise.
	* sys/fcntl.h: Likewise.
	* sys/file.h: Likewise.
	* sys/gmon.h: Likewise.
	* sys/ioctl.h: Likewise.
	* sys/ipc.h: Likewise.
	* sys/msg.h: Likewise.
	* sys/poll.h: Likewise.
	* sys/queue.h: Likewise.
	* sys/resource.h: Likewise.
	* sys/select.h: Likewise.
	* sys/sem.h: Likewise.
	* sys/shm.h: Likewise.
	* sys/signal.h: Likewise.
	* sys/socket.h: Likewise.
	* sys/stat.h: Likewise.
	* sys/statfs.h: Likewise.
	* sys/syslog.h: Likewise.
	* sys/termios.h: Likewise.
	* sys/time.h: Likewise.
	* sys/timeb.h: Likewise.
	* sys/times.h: Likewise.
	* sys/types.h: Likewise.
	* sys/uio.h: Likewise.
	* sys/un.h: Likewise.
	* sys/unistd.h: Likewise.
	* sys/utsname.h: Likewise.
	* sys/vlimit.h: Likewise.
	* sys/vtimes.h: Likewise.
	* sys/wait.h: Likewise.
	* syscall.h: Likewise.
	* syslog.h: Likewise.
	* tar.h: Likewise.
	* termios.h: Likewise.
	* time.h: Likewise.
	* ttyent.h: Likewise.
	* unistd.h: Likewise.
	* utime.h: Likewise.
	* utmp.h: Likewise.
	* values.h: Likewise.
	* wchar.h: Likewise.
	* wctype.h: Likewise.
	* wordexp.h: Likewise.
	* xlocale.h: Likewise.
	* xopen_lim.h: Likewise.

	* linuxthreads/sysdeps/alpha/semaphorebits.h: -> .../bits/semaphore.h.
	* linuxthreads/sysdeps/powerpc/semaphorebits.h: Likewise.
	* linuxthreads/sysdeps/pthread/cmpxchg/semaphorebits.h: Likewise.
	* linuxthreads/sysdeps/pthread/no-cmpxchg/semaphorebits.h: Likewise.
	* linuxthreads/sysdeps/pthread/libc-lock.h: -> bits/
	* sysdeps/mach/libc-lock.h: Likewise.
	* sysdeps/stub/libc-lock.h: Likewise.
	* linuxthreads/sysdeps/pthread/stdio-lock.h: Likewise.
	* linuxthreads/sysdeps/unix/sysv/linux/local_lim.h: Likewise.
	* sysdeps/mach/hurd/local_lim.h: Likewise.
	* sysdeps/stub/local_lim.h: Likewise.
	* sysdeps/unix/sysv/linux/local_lim.h: Likewise.
	* sysdeps/unix/sysv/local_lim.h: Likewise.
	* sysdeps/unix/sysv/sco3.2/local_lim.h: Likewise.
	* linuxthreads/sysdeps/unix/sysv/linux/posix_opt.h: Likewise.
	* sysdeps/mach/hurd/posix_opt.h: Likewise.
	* sysdeps/stub/posix_opt.h: Likewise.
	* sysdeps/unix/bsd/posix_opt.h: Likewise.
	* sysdeps/unix/bsd/ultrix4/posix_opt.h: Likewise.
	* sysdeps/unix/sysv/linux/posix_opt.h: Likewise.
	* math/cmathcalls.h: -> bits/
	* math/mathcalls.h: Likewise.
	* misc/stab.def: -> bits/
	* posix/posix1_lim.h: -> bits/
	* posix/posix2_lim.h: Likewise.
	* sysdeps/alpha/__math.h: -> .../fpu/bits/mathinline.h
	* sysdeps/i386/fpu/__math.h: Likewise.
	* sysdeps/m68k/fpu/__math.h: Likewise.
	* sysdeps/m68k/fpu/switch/__math.h: Likewise.
	* sysdeps/powerpc/__math.h: Likewise.
	* sysdeps/stub/__math.h: Likewise.
	* sysdeps/alpha/bytesex.h: -> .../bits/endian.h
	* sysdeps/arm/bytesex.h: Likewise.
	* sysdeps/i386/bytesex.h: Likewise.
	* sysdeps/m68k/bytesex.h: Likewise.
	* sysdeps/mips/bytesex.h: Likewise.
	* sysdeps/mips/dec/bytesex.h: Likewise.
	* sysdeps/mips/mipsel/bytesex.h: Likewise.
	* sysdeps/mips/p40/bytesex.h: Likewise.
	* sysdeps/sparc/bytesex.h: Likewise.
	* sysdeps/stub/bytesex.h: Likewise.
	* sysdeps/alpha/fpu/fenvbits.h: -> .../bits/fenv.h
	* sysdeps/i386/fpu/fenvbits.h: Likewise.
	* sysdeps/m68k/fpu/fenvbits.h: Likewise.
	* sysdeps/powerpc/fenvbits.h: Likewise.
	* sysdeps/stub/fenvbits.h: Likewise.
	* sysdeps/alpha/jmp_buf.h: -> .../bits/setenv.h
	* sysdeps/arm/jmp_buf.h: Likewise.
	* sysdeps/i386/jmp_buf.h: Likewise.
	* sysdeps/m68k/jmp_buf.h: Likewise.
	* sysdeps/mips/jmp_buf.h: Likewise.
	* sysdeps/sparc/jmp_buf.h: Likewise.
	* sysdeps/powerpc/jmp_buf.h: Likewise.
	* sysdeps/stub/jmp_buf.h: Likewise.
	* sysdeps/vax/jmp_buf.h: Likewise.
	* sysdeps/generic/confname.h: -> bits/
	* sysdeps/unix/sysv/irix4/confname.h: Likewise.
	* sysdeps/unix/sysv/sco3.2.4/confname.h: Likewise.
	* sysdeps/generic/gnu/types.h: -> ../bits/types.h
	* sysdeps/unix/sysv/linux/alpha/gnu/types.h: Likewise.
	* sysdeps/unix/sysv/linux/gnu/types.h: Likewise.
	* sysdeps/generic/ioctl-types.h: -> bits/
	* sysdeps/unix/sysv/linux/ioctl-types.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/ioctl-types.h: Likewise.
	* sysdeps/generic/iovec.h: -> .../bits/uio.h
	* sysdeps/unix/sysv/linux/iovec.h: Likewise.
	* sysdeps/generic/mathbits.h: -> .../bits/mathdef.h
	* sysdeps/i386/fpu/mathbits.h: Likewise.
	* sysdeps/m68k/fpu/mathbits.h: Likewise.
	* sysdeps/powerpc/mathbits.h: Likewise.
	* sysdeps/generic/resourcebits.h: -> .../bits/resource.h
	* sysdeps/unix/bsd/sun/sunos4/resourcebits.h: Likewise.
	* sysdeps/unix/sysv/linux/resourcebits.h: Likewise.
	* sysdeps/generic/schedbits.h: -> .../bits/sched.h
	* sysdeps/unix/sysv/linux/schedbits.h: Likewise.
	* sysdeps/generic/selectbits.h: -> .../bits/select.h
	* sysdeps/i386/selectbits.h: Likewise.
	* sysdeps/generic/sigaction.h: -> bits/
	* sysdeps/unix/bsd/osf/sigaction.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/sigaction.h: Likewise.
	* sysdeps/unix/sysv/linux/sigaction.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sigaction.h: Likewise.
	* sysdeps/unix/sysv/minix/sigaction.h: Likewise.
	* sysdeps/unix/sysv/sco3.2.4/sigaction.h: Likewise.
	* sysdeps/unix/sysv/sysv4/sigaction.h: Likewise.
	* sysdeps/generic/sigset.h: -> bits/
	* sysdeps/unix/sysv/linux/sigset.h: Likewise.
	* sysdeps/unix/sysv/sysv4/sigset.h: Likewise.
	* sysdeps/generic/sockaddrcom.h: -> .../bits/sockaddr.h
	* sysdeps/unix/bsd/bsd4.4/sockaddrcom.h: Likewise.
	* sysdeps/generic/socketbits.h: -> .../bits/socket.h
	* sysdeps/unix/sysv/linux/socketbits.h: Likewise.
	* sysdeps/generic/statfsbuf.h: -> .../bits/statfs.h
	* sysdeps/unix/sysv/linux/statfsbuf.h: Likewise.
	* sysdeps/generic/termbits.h: -> .../bits/termios.h
	* sysdeps/unix/bsd/sun/sunos4/termbits.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/termbits.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/termbits.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/termbits.h: Likewise.
	* sysdeps/unix/sysv/linux/termbits.h: Likewise.
	* sysdeps/generic/ustatbits.h: -> .../bits/ustat.h
	* sysdeps/unix/sysv/linux/ustatbits.h: Likewise.
	* sysdeps/generic/utmpbits.h: -> .../bits/utmp.h
	* sysdeps/gnu/utmpbits.h: Likewise.
	* sysdeps/unix/sysv/utmpbits.h: Likewise.
	* sysdeps/generic/utsnamelen.h: -> .../bits/utsname.h
	* sysdeps/unix/bsd/sun/sunos4/utsnamelen.h: Likewise.
	* sysdeps/unix/bsd/ultrix4/utsnamelen.h: Likewise.
	* sysdeps/unix/sysv/linux/utsnamelen.h: Likewise.
	* sysdeps/unix/sysv/sysv4/utsnamelen.h: Likewise.
	* sysdeps/unix/sysv/utsnamelen.h: Likewise.
	* sysdeps/generic/waitstatus.h: -> bits/
	* sysdeps/i386/huge_val.h: -> bits/
	* sysdeps/ieee754/huge_val.h: Likewise.
	* sysdeps/m68k/huge_val.h: Likewise.
	* sysdeps/stub/huge_val.h: Likewise.
	* sysdeps/vax/huge_val.h: Likewise.
	* sysdeps/ieee754/nan.h: Likewise.
	* sysdeps/stub/nan.h: Likewise.
	* sysdeps/mach/hurd/alpha/sigcontext.h: -> bits/
	* sysdeps/mach/hurd/hppa/sigcontext.h: Likewise.
	* sysdeps/mach/hurd/i386/sigcontext.h: Likewise.
	* sysdeps/mach/hurd/mips/sigcontext.h: Likewise.
	* sysdeps/stub/sigcontext.h: Likewise.
	* sysdeps/unix/bsd/sun/m68k/sigcontext.h: Likewise.
	* sysdeps/unix/bsd/sun/sparc/sigcontext.h: Likewise.
	* sysdeps/unix/bsd/ultrix4/mips/sigcontext.h: Likewise.
	* sysdeps/unix/sysv/linux/sigcontext.h: Likewise.
	* sysdeps/mach/hurd/errnos.h: -> .../bits/errno.h
	* sysdeps/standalone/arm/errnos.h: Likewise.
	* sysdeps/stub/errnos.h: Likewise.
	* sysdeps/unix/bsd/bsd4.4/errnos.h: Likewise.
	* sysdeps/unix/sysv/linux/errnos.h: Likewise.
	* sysdeps/mach/hurd/fcntlbits.h: -> .../bits/fcntl.h
	* sysdeps/stub/fcntlbits.h: Likewise.
	* sysdeps/unix/bsd/bsd4.4/fcntlbits.h: Likewise.
	* sysdeps/unix/bsd/fcntlbits.h: Likewise.
	* sysdeps/unix/bsd/sun/sunos4/fcntlbits.h: Likewise.
	* sysdeps/unix/bsd/ultrix4/fcntlbits.h: Likewise.
	* sysdeps/unix/common/fcntlbits.h: Likewise.
	* sysdeps/unix/sysv/fcntlbits.h: Likewise.
	* sysdeps/unix/sysv/irix4/fcntlbits.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/fcntlbits.h: Likewise.
	* sysdeps/unix/sysv/linux/fcntlbits.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/fcntlbits.h: Likewise.
	* sysdeps/mach/hurd/ioctls.h: -> bits/
	* sysdeps/stub/ioctls.h: Likewise.
	* sysdeps/unix/bsd/bsd4.4/ioctls.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/ioctls.h: Likewise.
	* sysdeps/unix/sysv/linux/ioctls.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/ioctls.h: Likewise.
	* sysdeps/mach/hurd/statbuf.h: -> .../bits/stat.h
	* sysdeps/stub/statbuf.h: Likewise.
	* sysdeps/unix/bsd/osf/alpha/statbuf.h: Likewise.
	* sysdeps/unix/bsd/statbuf.h: Likewise.
	* sysdeps/unix/sysv/irix4/statbuf.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/statbuf.h: Likewise.
	* sysdeps/unix/sysv/linux/statbuf.h: Likewise.
	* sysdeps/unix/sysv/statbuf.h: Likewise.
	* sysdeps/unix/sysv/sysv4/i386/statbuf.h: Likewise.
	* sysdeps/unix/sysv/sysv4/solaris2/statbuf.h: Likewise.
	* sysdeps/standalone/stdio_lim.h: -> bits/
	* sysdeps/stub/stdio_lim.h: Likewise.
	* sysdeps/stub/direntry.h: -> ../bits/dirent.h
	* sysdeps/unix/bsd/bsd4.4/direntry.h: Likewise.
	* sysdeps/unix/bsd/direntry.h: Likewise.
	* sysdeps/unix/common/direntry.h: Likewise.
	* sysdeps/unix/sysv/direntry.h: Likewise.
	* sysdeps/unix/sysv/linux/direntry.h: Likewise.
	* sysdeps/stub/elfclass.h: -> bits/
	* sysdeps/wordsize-32/elfclass.h: Likewise.
	* sysdeps/wordsize-64/elfclass.h: Likewise.
	* sysdeps/stub/signum.h: -> bits/
	* sysdeps/unix/bsd/signum.h: Likewise.
	* sysdeps/unix/bsd/sun/signum.h: Likewise.
	* sysdeps/unix/sysv/irix4/signum.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/signum.h: Likewise.
	* sysdeps/unix/sysv/linux/signum.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/signum.h: Likewise.
	* sysdeps/unix/sysv/signum.h: Likewise.
	* sysdeps/unix/sysv/sysv4/signum.h: Likewise.
	* sysdeps/unix/sysv/sysv4/solaris2/signum.h: Likewise.
	* sysdeps/stub/sys/ipc_buf.h: -> .../bits/ipc.h
	* sysdeps/unix/sysv/linux/alpha/sys/ipc_buf.h: Likewise.
	* sysdeps/unix/sysv/linux/sys/ipc_buf.h: Likewise.
	* sysdeps/stub/sys/msq_buf.h: -> .../bits/msq.h
	* sysdeps/unix/sysv/linux/sys/msq_buf.h: Likewise.
	* sysdeps/stub/sys/sem_buf.h: -> .../bits/sem.h
	* sysdeps/unix/sysv/linux/sys/sem_buf.h: Likewise.
	* sysdeps/stub/sys/shm_buf.h: -> .../bits/shm.h
	* sysdeps/unix/sysv/linux/sys/shm_buf.h: Likewise.
	* sysdeps/stub/timebits.h: -> .../bits/time.h
	* sysdeps/unix/sysv/linux/alpha/timebits.h: Likewise.
	* sysdeps/unix/sysv/linux/timebits.h: Likewise.
	* sysdeps/stub/waitflags.h: -> bits/
	* sysdeps/unix/bsd/waitflags.h: Likewise.
	* sysdeps/unix/sysv/linux/waitflags.h: Likewise.
	* sysdeps/unix/sysv/sysv4/waitflags.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/sys/kernel_termios.h: -> ../
	* sysdeps/unix/sysv/linux/powerpc/sys/kernel_termios.h: Likewise.
	* sysdeps/unix/sysv/linux/sys/kernel_termios.h: Likewise.
	* sysdeps/unix/sysv/linux/sys/socketcall.h: -> ../

	* argp/argp-fmtstream.h: Standardize the multiple-include protect.
	* argp/argp.h: Likewise.
	* catgets/nl_types.h: Likewise.
	* crypt/sysdeps/unix/crypt.h: Likewise.
	* ctype/ctype.h: Likewise.
	* db/db.h: Likewise.
	* db/mpool.h: Likewise.
	* db/ndbm.h: Likewise.
	* dirent/dirent.h: Likewise.
	* elf/dlfcn.h: Likewise.
	* elf/elf.h: Likewise.
	* elf/link.h: Likewise.
	* gmon/sys/gmon.h: Likewise.
	* gmon/sys/gmon_out.h: Likewise.
	* grp/grp.h: Likewise.
	* inet/aliases.h: Likewise.
	* inet/arpa/ftp.h: Likewise.
	* inet/arpa/inet.h: Likewise.
	* inet/arpa/telnet.h: Likewise.
	* inet/arpa/tftp.h: Likewise.
	* inet/netinet/ether.h: Likewise.
	* inet/netinet/icmp6.h: Likewise.
	* inet/netinet/in.h: Likewise.
	* inet/netinet/ip6.h: Likewise.
	* inet/protocols/routed.h: Likewise.
	* inet/protocols/rwhod.h: Likewise.
	* inet/protocols/talkd.h: Likewise.
	* inet/protocols/timed.h: Likewise.
	* intl/libintl.h: Likewise.
	* io/fcntl.h: Likewise.
	* io/fts.h: Likewise.
	* io/ftw.h: Likewise.
	* io/sys/poll.h: Likewise.
	* io/sys/stat.h: Likewise.
	* io/sys/statfs.h: Likewise.
	* io/utime.h: Likewise.
	* linuxthreads/semaphore.h: Likewise.
	* linuxthreads/sysdeps/pthread/pthread.h: Likewise.
	* locale/locale.h: Likewise.
	* login/pty.h: Likewise.
	* login/utmp.h: Likewise.
	* malloc/malloc.h: Likewise.
	* malloc/obstack.h: Likewise.
	* math/complex.h: Likewise.
	* math/fenv.h: Likewise.
	* math/math.h: Likewise.
	* md5-crypt/md5.h: Likewise.
	* misc/ar.h: Likewise.
	* misc/err.h: Likewise.
	* misc/error.h: Likewise.
	* misc/fstab.h: Likewise.
	* misc/libgen.h: Likewise.
	* misc/nlist.h: Likewise.
	* misc/sys/cdefs.h: Likewise.
	* misc/sys/file.h: Likewise.
	* misc/sys/ioctl.h: Likewise.
	* misc/sys/queue.h: Likewise.
	* misc/sys/select.h: Likewise.
	* misc/sys/syslog.h: Likewise.
	* misc/sys/uio.h: Likewise.
	* misc/sysexits.h: Likewise.
	* misc/ttyent.h: Likewise.
	* nss/nss.h: Likewise.
	* posix/fnmatch.h: Likewise.
	* posix/getopt.h: Likewise.
	* posix/glob.h: Likewise.
	* posix/regex.h: Likewise.
	* posix/sys/times.h: Likewise.
	* posix/sys/types.h: Likewise.
	* posix/sys/utsname.h: Likewise.
	* posix/sys/wait.h: Likewise.
	* posix/tar.h: Likewise.
	* posix/unistd.h: Likewise.
	* posix/wordexp.h: Likewise.
	* pwd/pwd.h: Likewise.
	* resolv/arpa/nameser.h: Likewise.
	* resolv/netdb.h: Likewise.
	* resolv/resolv.h: Likewise.
	* resource/sys/resource.h: Likewise.
	* resource/sys/vlimit.h: Likewise.
	* resource/sys/vtimes.h: Likewise.
	* setjmp/setjmp.h: Likewise.
	* shadow/shadow.h: Likewise.
	* socket/sys/socket.h: Likewise.
	* socket/sys/un.h: Likewise.
	* stdlib/exit.h: Likewise.
	* stdlib/fmtmsg.h: Likewise.
	* stdlib/monetary.h: Likewise.
	* stdlib/stdlib.h: Likewise.
	* string/argz.h: Likewise.
	* string/envz.h: Likewise.
	* string/memory.h: Likewise.
	* string/string.h: Likewise.
	* string/strings.h: Likewise.
	* sunrpc/rpc/rpc.h: Likewise.
	* sunrpc/rpc/svc.h: Likewise.
	* sunrpc/rpc/types.h: Likewise.
	* sunrpc/rpc/xdr.h: Likewise.
	* termios/sys/ttychars.h: Likewise.
	* termios/termios.h: Likewise.

	* argp/argp-parse.c: <foo.h> -> <bits/foo.h>.
	* crypt/sysdeps/unix/crypt_util.c: Likewise.
	* dirent/dirent.h: Likewise.
	* elf/link.h: Likewise.
	* grp/fgetgrent.c: Likewise.
	* grp/grp.h: Likewise.
	* hurd/hurd/ioctl.h: Likewise.
	* inet/getnameinfo.c: Likewise.
	* inet/getnetgrent_r.c: Likewise.
	* inet/inet_ntoa.c: Likewise.
	* inet/netinet/in.h: Likewise.
	* io/fcntl.h: Likewise.
	* io/ftw.h: Likewise.
	* io/sys/stat.h: Likewise.
	* io/sys/statfs.h: Likewise.
	* io/utime.h: Likewise.
	* libio/_G_config.h: Likewise.
	* libio/libio.h: Likewise.
	* libio/libioP.h: Likewise.
	* libio/stdio.h: Likewise.
	* linuxthreads/lockfile.c: Likewise.
	* linuxthreads/semaphore.h: Likewise.
	* locale/duplocale.c: Likewise.
	* locale/freelocale.c: Likewise.
	* locale/lc-time.c: Likewise.
	* locale/setlocale.c: Likewise.
	* login/getutent_r.c: Likewise.
	* login/getutid_r.c: Likewise.
	* login/getutline_r.c: Likewise.
	* login/lastlog.h: Likewise.
	* login/pty.h: Likewise.
	* login/utmp.h: Likewise.
	* login/utmpname.c: Likewise.
	* malloc/mtrace.c: Likewise.
	* malloc/thread-m.h: Likewise.
	* math/complex.h: Likewise.
	* math/fenv.h: Likewise.
	* math/libm-test.c: Likewise.
	* math/math.h: Likewise.
	* misc/sgtty.h: Likewise.
	* misc/stab.h: Likewise.
	* misc/sys/ioctl.h: Likewise.
	* misc/sys/select.h: Likewise.
	* misc/sys/uio.h: Likewise.
	* misc/sys/ustat.h: Likewise.
	* misc/syslog.c: Likewise.
	* nis/nss_compat/compat-grp.c: Likewise.
	* nis/nss_compat/compat-pwd.c: Likewise.
	* nis/nss_compat/compat-spwd.c: Likewise.
	* nis/nss_nis/nis-alias.c: Likewise.
	* nis/nss_nis/nis-ethers.c: Likewise.
	* nis/nss_nis/nis-grp.c: Likewise.
	* nis/nss_nis/nis-hosts.c: Likewise.
	* nis/nss_nis/nis-netgrp.c: Likewise.
	* nis/nss_nis/nis-network.c: Likewise.
	* nis/nss_nis/nis-proto.c: Likewise.
	* nis/nss_nis/nis-publickey.c: Likewise.
	* nis/nss_nis/nis-pwd.c: Likewise.
	* nis/nss_nis/nis-rpc.c: Likewise.
	* nis/nss_nis/nis-service.c: Likewise.
	* nis/nss_nis/nis-spwd.c: Likewise.
	* nss_nisplus/nisplus-alias.c: Likewise.
	* nis/nss_nisplus/nisplus-ethers.c: Likewise.
	* nis/nss_nisplus/nisplus-grp.c: Likewise.
	* nis/nss_nisplus/nisplus-hosts.c: Likewise.
	* nis/nss_nisplus/nisplus-netgrp.c: Likewise.
	* nis/nss_nisplus/nisplus-netgrp.c: Likewise.
	* nis/nss_nisplus/nisplus-proto.c: Likewise.
	* nis/nss_nisplus/nisplus-pwd.c: Likewise.
	* nis/nss_nisplus/nisplus-rpc.c: Likewise.
	* nis/nss_nisplus/nisplus-service.c: Likewise.
	* nis/nss_nisplus/nisplus-spwd.c: Likewise.
	* nis/ypclnt.c: Likewise.
	* nss/getXXbyYY.c: Likewise.
	* nss/getXXent.c: Likewise.
	* nss/getXXent_r.c: Likewise.
	* nss/nss_db/db-XXX.c: Likewise.
	* nss/nss_db/db-alias.c: Likewise.
	* nss/nss_db/db-netgrp.c: Likewise.
	* nss/nss_files/files-XXX.c: Likewise.
	* nss/nss_files/files-alias.c: Likewise.
	* nss/nsswitch.c: Likewise.
	* posix/sched.h: Likewise.
	* posix/sys/types.h: Likewise.
	* posix/sys/utsname.h: Likewise.
	* posix/sys/wait.h: Likewise.
	* posix/unistd.h: Likewise.
	* pwd/fgetpwent.c: Likewise.
	* pwd/pwd.h: Likewise.
	* resource/sys/resource.h: Likewise.
	* setjmp/setjmp.h: Likewise.
	* shadow/fgetspent.c: Likewise.
	* shadow/lckpwdf.c: Likewise.
	* shadow/sgetspent.c: Likewise.
	* signal/signal.h: Likewise.
	* signal/sigsetops.c: Likewise.
	* socket/sys/socket.h: Likewise.
	* socket/sys/un.h: Likewise.
	* stdio/stdio.h: Likewise.
	* stdio-common/vfprintf.c: Likewise.
	* stdio-common/vfscanf.c: Likewise.
	* stdlib/atexit.c: Likewise.
	* stdlib/fmtmsg.c: Likewise.
	* stdlib/random.c: Likewise.
	* string/endian.h: Likewise.
	* sysdeps/alpha/w_sqrt.S: Likewise.
	* sysdeps/arm/__longjmp.S: Likewise.
	* sysdeps/arm/setjmp.S: Likewise.
	* sysdeps/generic/abort.c: Likewise.
	* sysdeps/generic/netinet/ip.h: Likewise.
	* sysdeps/generic/setenv.c: Likewise.
	* generic/sys/mman.h: Likewise.
	* sysdeps/i386/__longjmp.S: Likewise.
	* sysdeps/i386/setjmp.S: Likewise.
	* sysdeps/mach/hurd/dirstream.h: Likewise.
	* sysdeps/mach/hurd/jmp-unwind.c: Likewise.
	* sysdeps/posix/mk-stdiolim.c: Likewise.
	* sysdeps/powerpc/__longjmp.S: Likewise.
	* sysdeps/powerpc/setjmp.S: Likewise.
	* sysdeps/sparc/__longjmp.S: Likewise.
	* sysdeps/sparc/setjmp.S: Likewise.
	* sysdeps/standalone/close.c: Likewise.
	* sysdeps/standalone/filedesc.h: Likewise.
	* sysdeps/standalone/open.c: Likewise.
	* sysdeps/unix/bsd/bsd4.4/tcsetattr.c: Likewise.
	* sysdeps/unix/bsd/m68k/sysdep.S: Likewise.
	* sysdeps/unix/bsd/osf/sys/mman.h: Likewise.
	* sysdeps/unix/bsd/sun/m68k/sethostid.S: Likewise.
	* sysdeps/unix/bsd/sun/sparc/sethostid.S: Likewise.
	* sysdeps/unix/bsd/sun/sunos4/sys/mman.h: Likewise.
	* sysdeps/unix/bsd/ultrix4/sys/mman.h: Likewise.
	* sysdeps/unix/bsd/vax/sysdep.S: Likewise.
	* sysdeps/unix/dirstream.h: Likewise.
	* sysdeps/unix/i386/sysdep.S: Likewise.
	* sysdeps/unix/mips/sysdep.S: Likewise.
	* sysdeps/unix/mk-local_lim.c: Likewise.
	* sysdeps/unix/sparc/sysdep.S: Likewise.
	* sysdeps/unix/sysv/irix4/sys/mman.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/brk.S: Likewise.
	* sysdeps/unix/sysv/linux/alpha/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/arm/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/m68k/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/netinet/ip.h: Likewise.
	* sysdeps/unix/sysv/linux/netinet/tcp.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/clone.S: Likewise.
	* sysdeps/unix/sysv/linux/sys/mman.h: Likewise.
	* sysdeps/unix/sysv/linux/sys/syscall.h: Likewise.
	* sysdeps/unix/sysv/linux/tcgetattr.c: Likewise.
	* sysdeps/unix/sysv/sco3.2.4/sysconf.S: Likewise.
	* sysdeps/unix/sysv/sysv4/i386/sysdep.h: Likewise.
	* sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.S: Likewise.
	* sysvipc/sys/ipc.h: Likewise.
	* sysvipc/sys/msg.h: Likewise.
	* sysvipc/sys/sem.h: Likewise.
	* sysvipc/sys/shm.h: Likewise.
	* termios/termios.h: Likewise.
	* time/localtime.c: Likewise.
	* time/sys/time.h: Likewise.
	* time/time.h: Likewise.
	* time/tzset.c: Likewise.

	* sysdeps/unix/sysv/linux/arm/socket.S: socketcall.h change.
	* sysdeps/unix/sysv/linux/i386/socket.S: Likewise.
	* sysdeps/unix/sysv/linux/m68k/socket.S: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/socket.S: Likewise.
	* sysdeps/unix/sysv/linux/sparc/socket.S: Likewise.

	* Makefile (headers): foo.h -> bits/foo.h.
	* dirent/Makefile: Likewise.
	* elf/Makefile: Likewise.
	* io/Makefile: Likewise.
	* linuxthreads/Makefile: Likewise.
	* linuxthreads/sysdeps/pthread/Makefile: Likewise.
	* login/Makefile: Likewise.
	* math/Makefile: Likewise.
	* misc/Makefile: Likewise.
	* posix/Makefile: Likewise.
	* resource/Makefile: Likewise.
	* setjmp/Makefile: Likewise.
	* signal/Makefile: Likewise.
	* socket/Makefile: Likewise.
	* stdio-common/Makefile: Likewise.
	* sysdeps/unix/sysv/linux/Makefile: Likewise.
	* sysvipc/Makefile: Likewise.
	* termios/Makefile: Likewise.
	* time/Makefile: Likewise.
	* sysdeps/generic/Makefile (make_siglist-CFLAGS): Likewise.
	* sysdeps/posix/Makefile: stdio_lim.h -> bits/stdio_lim.h
	* sysdeps/unix/Makefile: Likewise with local_lim.h, errnos.h,
	ioctls.h, termbits.h.

	* sysdeps/unix/sysv/linux/Dist: sys/kernel_termios.h
	-> kernel_termios.h, sys/socketcall.h -> socketcall.h

	* elf/elf.h: Use <inttypes.h> definitions instead of __attribute__
	for getting the proper length on the ELF types to be friendly to
	non-gcc compilers.
	* posix/sys/types.h: Notice when int8_t and friends are defined
	and don't redefine them.
	* sysdeps/wordsize-32/inttypes.h: Likewise.
	* sysdeps/wordsize-64/inttypes.h: Likewise.

	* sysdeps/unix/sysv/linux/arm/profil-counter.h: Get sigcontext
	via <signal.h> instead.
	* sysdeps/unix/sysv/linux/i386/profil-counter.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/profil-counter.h: Likewise.

1997-06-20 17:59  Kazumoto Kojima  <kkojima@kk.info.kanagawa-u.ac.jp>

	* hurd/intr-msg.c: More 64bit changes.
	* mach/msg-destroy.c: Likewise.
	* sysdeps/mach/hurd/ioctl.c: Likewise.
	* sysdeps/mach/hurd/ioctls.h: Likewise.
	* sysdeps/mach/hurd/select.c: Likewise.
	* sysdeps/mach/hurd/statbuf.h: Likewise.

	* sysdeps/mach/hurd/mips/dl-machine.c: Hurd/MIPS64 patches.
	* sysdeps/mach/hurd/mips/exc2signal.c: Likewise.
	* sysdeps/mach/hurd/mips/init-fault.c: Likewise.
	* sysdeps/mach/hurd/mips/init-first.c: Likewise.
	* sysdeps/mach/hurd/mips/intr-msg.h: Likewise.
	* sysdeps/mach/hurd/mips/longjmp-ctx.c: Likewise.
	* sysdeps/mach/hurd/mips/longjmp-ts.c: Likewise.
	* sysdeps/mach/hurd/mips/sigcontext.h: Likewise.
	* sysdeps/mach/hurd/mips/sigreturn.c: Likewise.
	* sysdeps/mach/hurd/mips/trampoline.c: Likewise.
	* sysdeps/mach/mips/cacheflush.c: Likewise.
	* sysdeps/mach/mips/machine-lock.h: Likewise.
	* sysdeps/mach/mips/machine-sp.h: Likewise.
	* sysdeps/mach/mips/syscall.S: Likewise.
	* sysdeps/mach/mips/sysdep.h: Likewise.
	* sysdeps/mach/mips/thread_state.h: Likewise.
	* sysdeps/mach/start.c: Likewise.

	* sysdeps/mips/dl-machine.h: MIPS changes.
	* sysdeps/mips/elf/start.S: Likewise.
	* sysdeps/mips/init-first.c: Likewise.
	* sysdeps/mips/fpu_control.h: Likewise.
	* sysdeps/mips/machine-gmon.h: Likewise.
	* sysdeps/mips/jmp_buf.h: Likewise.
	* sysdeps/mips/__longjmp.c: Likewise.
	* sysdeps/mips/bsd-_setjmp.S: Likewise.
	* sysdeps/mips/bsd-setjmp.S: Likewise.
	* sysdeps/mips/setjmp.S: Likewise.
	* sysdeps/mips/setjmp_aux.c: Likewise.
	* sysdeps/mips/mips64/gmp-mparam.h: Likewise.
	* sysdeps/mips/add_n.S: New file.
	* sysdeps/mips/addmul_1.S: Likewise.
	* sysdeps/mips/lshift.S: Likewise.
	* sysdeps/mips/mul_1.S: Likewise.
	* sysdeps/mips/rshift.S: Likewise.
	* sysdeps/mips/sub_n.S: Likewise.
	* sysdeps/mips/submul_1.S: Likewise.
	* sysdeps/mips/mips64/Implies: Likewise.
	* sysdeps/mips/mips64/add_n.S: Likewise.
	* sysdeps/mips/mips64/addmul_1.S: Likewise.
	* sysdeps/mips/mips64/lshift.S: Likewise.
	* sysdeps/mips/mips64/mul_1.S: Likewise.
	* sysdeps/mips/mips64/rshift.S: Likewise.
	* sysdeps/mips/mips64/sub_n.S: Likewise.
	* sysdeps/mips/mips64/submul_1.S: Likewise.
	* sysdeps/mips/add_n.S: Removed.
	* sysdeps/mips/addmul_1.S: Likewise.
	* sysdeps/mips/lshift.S: Likewise.
	* sysdeps/mips/mul_1.S: Likewise.
	* sysdeps/mips/rshift.S: Likewise.
	* sysdeps/mips/sub_n.S: Likewise.
	* sysdeps/mips/submul_1.S: Likewise.

	* nss/Makefile: Prepare for static NSS.
	* resolv/Makefile: Likewise.
	* nss/nsswitch.c: Add code for static NSS.
	* nss/function.def: Define functions for static NSS.

1997-06-19 11:10  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* libc.map: Add yet more symbols.

1997-06-19 20:33  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* elf/dl-lookup.c (_dl_lookup_versioned_symbol): Don't pass NULL
	as object name to _dl_signal_error.
	(do_lookup): Skip objects that could not be opened.

	* sysdeps/m68k/dl-machine.h (elf_machine_rela): Check that the
	symbol was found.
	* sysdeps/i386/dl-machine.h (elf_machine_rel): Likewise.
	* sysdeps/powerpc/dl-machine.h (elf_machine_rela): Likewise.

1997-06-20 03:13  Kazumoto Kojima  <kkojima@kk.info.kanagawa-u.ac.jp>

	* ctype/ctype-info.c: Use int32_t where `int' with 4 bytes is
	assumed.
	* ctype/ctype.h: Likewise.
	* math/math_private.h: Likewise.
	* inet/netinet/in.h: Likewise.
	* wctype/wctype.h: Likewise.

	* nss/Makefile: Only inhibit nss_files and nss_db modules if static
	NSS modules are not enabled.
	* resolv/Makefile: Likewise for nss_dns.
	* nss/function.def: New file.  List all available lookup functions
	for static NSS.
	* nss/nsswitch.c: Add code for static NSS.

1997-06-15 21:15  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* math/libm-test.c (gamma_test): Test for _SVID_ and for normal
	behaviour.

1997-06-15 20:32  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* math/libm.map: Add all necessary functions, correct existing entries.

1997-06-20 02:35  a sun  <asun@zoology.washington.edu>

	* sysdeps/unix/sysv/linux/netipx/ipx.h: Don't use kernel header.

1997-06-19 18:43  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* nis/nss_nisplus/nisplus-spwd.c (_nss_nisplus_parse_spent):
	Compare pointer with NULL.

	* login/logout.c (logout): Compare pututline result with NULL.

	* inet/rcmd.c: Correct a few typos.  Reported by Erik Troan.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/alpha/bits/endian.h (renamed from sysdeps/alpha/bytesex.h)0
-rw-r--r--sysdeps/alpha/bits/setjmp.h (renamed from sysdeps/alpha/jmp_buf.h)0
-rw-r--r--sysdeps/alpha/fpu/bits/fenv.h (renamed from sysdeps/alpha/fpu/fenvbits.h)9
-rw-r--r--sysdeps/alpha/fpu/bits/mathdef.h64
-rw-r--r--sysdeps/alpha/fpu/bits/mathinline.h (renamed from sysdeps/alpha/__math.h)0
-rw-r--r--sysdeps/alpha/w_sqrt.S2
-rw-r--r--sysdeps/arm/__longjmp.S2
-rw-r--r--sysdeps/arm/bits/endian.h (renamed from sysdeps/arm/bytesex.h)0
-rw-r--r--sysdeps/arm/bits/setjmp.h (renamed from sysdeps/arm/jmp_buf.h)0
-rw-r--r--sysdeps/arm/setjmp.S2
-rw-r--r--sysdeps/generic/Makefile2
-rw-r--r--sysdeps/generic/abort.c2
-rw-r--r--sysdeps/generic/bits/confname.h (renamed from sysdeps/generic/confname.h)0
-rw-r--r--sysdeps/generic/bits/ioctl-types.h (renamed from sysdeps/generic/ioctl-types.h)10
-rw-r--r--sysdeps/generic/bits/mathdef.h (renamed from sysdeps/generic/mathbits.h)8
-rw-r--r--sysdeps/generic/bits/resource.h (renamed from sysdeps/generic/resourcebits.h)0
-rw-r--r--sysdeps/generic/bits/sched.h35
-rw-r--r--sysdeps/generic/bits/select.h (renamed from sysdeps/generic/selectbits.h)8
-rw-r--r--sysdeps/generic/bits/sigaction.h (renamed from sysdeps/generic/sigaction.h)0
-rw-r--r--sysdeps/generic/bits/sigset.h (renamed from sysdeps/generic/sigset.h)0
-rw-r--r--sysdeps/generic/bits/sockaddr.h (renamed from sysdeps/generic/sockaddrcom.h)10
-rw-r--r--sysdeps/generic/bits/socket.h (renamed from sysdeps/generic/socketbits.h)10
-rw-r--r--sysdeps/generic/bits/statfs.h52
-rw-r--r--sysdeps/generic/bits/termios.h (renamed from sysdeps/generic/termbits.h)5
-rw-r--r--sysdeps/generic/bits/types.h (renamed from sysdeps/generic/gnu/types.h)19
-rw-r--r--sysdeps/generic/bits/uio.h32
-rw-r--r--sysdeps/generic/bits/ustat.h (renamed from sysdeps/generic/ustatbits.h)0
-rw-r--r--sysdeps/generic/bits/utmp.h (renamed from sysdeps/generic/utmpbits.h)10
-rw-r--r--sysdeps/generic/bits/utsname.h (renamed from sysdeps/generic/utsnamelen.h)0
-rw-r--r--sysdeps/generic/bits/waitstatus.h (renamed from sysdeps/generic/waitstatus.h)12
-rw-r--r--sysdeps/generic/iovec.h9
-rw-r--r--sysdeps/generic/netinet/ip.h2
-rw-r--r--sysdeps/generic/schedbits.h35
-rw-r--r--sysdeps/generic/setenv.c2
-rw-r--r--sysdeps/generic/statfsbuf.h49
-rw-r--r--sysdeps/generic/sys/mman.h2
-rw-r--r--sysdeps/gnu/bits/utmp.h (renamed from sysdeps/gnu/utmpbits.h)0
-rw-r--r--sysdeps/i386/__longjmp.S2
-rw-r--r--sysdeps/i386/bits/endian.h (renamed from sysdeps/i386/bytesex.h)0
-rw-r--r--sysdeps/i386/bits/huge_val.h (renamed from sysdeps/i386/huge_val.h)8
-rw-r--r--sysdeps/i386/bits/select.h (renamed from sysdeps/i386/selectbits.h)8
-rw-r--r--sysdeps/i386/bits/setjmp.h (renamed from sysdeps/i386/jmp_buf.h)0
-rw-r--r--sysdeps/i386/dl-machine.h4
-rw-r--r--sysdeps/i386/fpu/bits/fenv.h (renamed from sysdeps/i386/fpu/fenvbits.h)8
-rw-r--r--sysdeps/i386/fpu/bits/mathdef.h (renamed from sysdeps/i386/fpu/mathbits.h)8
-rw-r--r--sysdeps/i386/fpu/bits/mathinline.h (renamed from sysdeps/i386/fpu/__math.h)6
-rw-r--r--sysdeps/i386/setjmp.S2
-rw-r--r--sysdeps/ieee754/bits/huge_val.h (renamed from sysdeps/ieee754/huge_val.h)13
-rw-r--r--sysdeps/ieee754/bits/nan.h (renamed from sysdeps/ieee754/nan.h)33
-rw-r--r--sysdeps/libm-ieee754/k_standard.c88
-rw-r--r--sysdeps/libm-ieee754/w_gamma.c6
-rw-r--r--sysdeps/libm-ieee754/w_gammaf.c6
-rw-r--r--sysdeps/libm-ieee754/w_gammal.c6
-rw-r--r--sysdeps/m68k/bits/endian.h (renamed from sysdeps/m68k/bytesex.h)0
-rw-r--r--sysdeps/m68k/bits/huge_val.h (renamed from sysdeps/m68k/huge_val.h)26
-rw-r--r--sysdeps/m68k/bits/setjmp.h (renamed from sysdeps/m68k/jmp_buf.h)0
-rw-r--r--sysdeps/m68k/dl-machine.h4
-rw-r--r--sysdeps/m68k/fpu/bits/fenv.h (renamed from sysdeps/m68k/fpu/fenvbits.h)8
-rw-r--r--sysdeps/m68k/fpu/bits/mathdef.h (renamed from sysdeps/m68k/fpu/mathbits.h)8
-rw-r--r--sysdeps/m68k/fpu/bits/mathinline.h (renamed from sysdeps/m68k/fpu/__math.h)0
-rw-r--r--sysdeps/m68k/fpu/switch/bits/mathinline.h (renamed from sysdeps/m68k/fpu/switch/__math.h)0
-rw-r--r--sysdeps/mach/bits/libc-lock.h (renamed from sysdeps/mach/libc-lock.h)6
-rw-r--r--sysdeps/mach/hurd/alpha/bits/sigcontext.h (renamed from sysdeps/mach/hurd/alpha/sigcontext.h)0
-rw-r--r--sysdeps/mach/hurd/bits/errno.h (renamed from sysdeps/mach/hurd/errnos.h)0
-rw-r--r--sysdeps/mach/hurd/bits/fcntl.h (renamed from sysdeps/mach/hurd/fcntlbits.h)10
-rw-r--r--sysdeps/mach/hurd/bits/ioctls.h (renamed from sysdeps/mach/hurd/ioctls.h)44
-rw-r--r--sysdeps/mach/hurd/bits/local_lim.h (renamed from sysdeps/mach/hurd/local_lim.h)0
-rw-r--r--sysdeps/mach/hurd/bits/posix_opt.h (renamed from sysdeps/mach/hurd/posix_opt.h)0
-rw-r--r--sysdeps/mach/hurd/bits/stat.h (renamed from sysdeps/mach/hurd/statbuf.h)17
-rw-r--r--sysdeps/mach/hurd/dirstream.h2
-rw-r--r--sysdeps/mach/hurd/hppa/bits/sigcontext.h (renamed from sysdeps/mach/hurd/hppa/sigcontext.h)0
-rw-r--r--sysdeps/mach/hurd/i386/bits/sigcontext.h (renamed from sysdeps/mach/hurd/i386/sigcontext.h)0
-rw-r--r--sysdeps/mach/hurd/ioctl.c8
-rw-r--r--sysdeps/mach/hurd/jmp-unwind.c2
-rw-r--r--sysdeps/mach/hurd/mips/bits/sigcontext.h (renamed from sysdeps/mach/hurd/mips/sigcontext.h)0
-rw-r--r--sysdeps/mach/hurd/mips/dl-machine.c131
-rw-r--r--sysdeps/mach/hurd/mips/exc2signal.c65
-rw-r--r--sysdeps/mach/hurd/mips/init-fault.c41
-rw-r--r--sysdeps/mach/hurd/mips/init-first.c407
-rw-r--r--sysdeps/mach/hurd/mips/intr-msg.h127
-rw-r--r--sysdeps/mach/hurd/mips/longjmp-ctx.c41
-rw-r--r--sysdeps/mach/hurd/mips/longjmp-ts.c34
-rw-r--r--sysdeps/mach/hurd/mips/sigreturn.c100
-rw-r--r--sysdeps/mach/hurd/mips/trampoline.c217
-rw-r--r--sysdeps/mach/hurd/select.c2
-rw-r--r--sysdeps/mach/mips/cacheflush.c30
-rw-r--r--sysdeps/mach/mips/machine-lock.h63
-rw-r--r--sysdeps/mach/mips/machine-sp.h34
-rw-r--r--sysdeps/mach/mips/syscall.S57
-rw-r--r--sysdeps/mach/mips/sysdep.h58
-rw-r--r--sysdeps/mach/mips/thread_state.h33
-rw-r--r--sysdeps/mach/start.c3
-rw-r--r--sysdeps/mips/add_n.S121
-rw-r--r--sysdeps/mips/add_n.s120
-rw-r--r--sysdeps/mips/addmul_1.S98
-rw-r--r--sysdeps/mips/addmul_1.s97
-rw-r--r--sysdeps/mips/bits/endian.h (renamed from sysdeps/mips/bytesex.h)0
-rw-r--r--sysdeps/mips/bits/setjmp.h53
-rw-r--r--sysdeps/mips/bsd-_setjmp.S43
-rw-r--r--sysdeps/mips/bsd-setjmp.S39
-rw-r--r--sysdeps/mips/dec/bits/endian.h (renamed from sysdeps/mips/dec/bytesex.h)0
-rw-r--r--sysdeps/mips/dl-machine.h387
-rw-r--r--sysdeps/mips/elf/start.S181
-rw-r--r--sysdeps/mips/fpu_control.h96
-rw-r--r--sysdeps/mips/init-first.c64
-rw-r--r--sysdeps/mips/jmp_buf.h53
-rw-r--r--sysdeps/mips/lshift.S97
-rw-r--r--sysdeps/mips/lshift.s95
-rw-r--r--sysdeps/mips/machine-gmon.h57
-rw-r--r--sysdeps/mips/mips64/Implies1
-rw-r--r--sysdeps/mips/mips64/__longjmp.c85
-rw-r--r--sysdeps/mips/mips64/add_n.S129
-rw-r--r--sysdeps/mips/mips64/addmul_1.S106
-rw-r--r--sysdeps/mips/mips64/bits/setjmp.h54
-rw-r--r--sysdeps/mips/mips64/bsd-_setjmp.S36
-rw-r--r--sysdeps/mips/mips64/bsd-setjmp.S36
-rw-r--r--sysdeps/mips/mips64/gmp-mparam.h4
-rw-r--r--sysdeps/mips/mips64/lshift.S104
-rw-r--r--sysdeps/mips/mips64/mul_1.S94
-rw-r--r--sysdeps/mips/mips64/rshift.S101
-rw-r--r--sysdeps/mips/mips64/setjmp.S35
-rw-r--r--sysdeps/mips/mips64/setjmp_aux.c67
-rw-r--r--sysdeps/mips/mips64/sub_n.S129
-rw-r--r--sysdeps/mips/mips64/submul_1.S106
-rw-r--r--sysdeps/mips/mipsel/bits/endian.h (renamed from sysdeps/mips/mipsel/bytesex.h)0
-rw-r--r--sysdeps/mips/mul_1.S86
-rw-r--r--sysdeps/mips/mul_1.s85
-rw-r--r--sysdeps/mips/p40/bits/endian.h (renamed from sysdeps/mips/p40/bytesex.h)0
-rw-r--r--sysdeps/mips/rshift.S94
-rw-r--r--sysdeps/mips/rshift.s92
-rw-r--r--sysdeps/mips/setjmp.S43
-rw-r--r--sysdeps/mips/setjmp_aux.c27
-rw-r--r--sysdeps/mips/sub_n.S121
-rw-r--r--sysdeps/mips/sub_n.s120
-rw-r--r--sysdeps/mips/submul_1.S98
-rw-r--r--sysdeps/mips/submul_1.s97
-rw-r--r--sysdeps/posix/Makefile12
-rw-r--r--sysdeps/posix/mk-stdiolim.c8
-rw-r--r--sysdeps/powerpc/__longjmp.S2
-rw-r--r--sysdeps/powerpc/bits/fenv.h (renamed from sysdeps/powerpc/fenvbits.h)8
-rw-r--r--sysdeps/powerpc/bits/mathdef.h (renamed from sysdeps/powerpc/mathbits.h)8
-rw-r--r--sysdeps/powerpc/bits/mathinline.h (renamed from sysdeps/powerpc/__math.h)0
-rw-r--r--sysdeps/powerpc/bits/setjmp.h (renamed from sysdeps/powerpc/jmp_buf.h)2
-rw-r--r--sysdeps/powerpc/dl-machine.h4
-rw-r--r--sysdeps/powerpc/setjmp.S2
-rw-r--r--sysdeps/sparc/__longjmp.S30
-rw-r--r--sysdeps/sparc/bits/endian.h (renamed from sysdeps/sparc/bytesex.h)0
-rw-r--r--sysdeps/sparc/bits/setjmp.h (renamed from sysdeps/sparc/jmp_buf.h)0
-rw-r--r--sysdeps/sparc/setjmp.S2
-rw-r--r--sysdeps/standalone/arm/bits/errno.h (renamed from sysdeps/standalone/arm/errnos.h)0
-rw-r--r--sysdeps/standalone/bits/stdio_lim.h (renamed from sysdeps/standalone/stdio_lim.h)0
-rw-r--r--sysdeps/standalone/close.c2
-rw-r--r--sysdeps/standalone/filedesc.h2
-rw-r--r--sysdeps/standalone/open.c2
-rw-r--r--sysdeps/stub/bits/dirent.h (renamed from sysdeps/stub/direntry.h)0
-rw-r--r--sysdeps/stub/bits/elfclass.h (renamed from sysdeps/stub/elfclass.h)0
-rw-r--r--sysdeps/stub/bits/endian.h (renamed from sysdeps/stub/bytesex.h)4
-rw-r--r--sysdeps/stub/bits/errno.h (renamed from sysdeps/stub/errnos.h)0
-rw-r--r--sysdeps/stub/bits/fcntl.h (renamed from sysdeps/stub/fcntlbits.h)11
-rw-r--r--sysdeps/stub/bits/fenv.h (renamed from sysdeps/stub/fenvbits.h)8
-rw-r--r--sysdeps/stub/bits/huge_val.h (renamed from sysdeps/stub/huge_val.h)8
-rw-r--r--sysdeps/stub/bits/ioctls.h (renamed from sysdeps/stub/ioctls.h)0
-rw-r--r--sysdeps/stub/bits/ipc.h (renamed from sysdeps/stub/sys/ipc_buf.h)0
-rw-r--r--sysdeps/stub/bits/libc-lock.h (renamed from sysdeps/stub/libc-lock.h)6
-rw-r--r--sysdeps/stub/bits/local_lim.h (renamed from sysdeps/stub/local_lim.h)0
-rw-r--r--sysdeps/stub/bits/mathinline.h (renamed from sysdeps/stub/__math.h)0
-rw-r--r--sysdeps/stub/bits/msq.h47
-rw-r--r--sysdeps/stub/bits/nan.h5
-rw-r--r--sysdeps/stub/bits/posix_opt.h (renamed from sysdeps/stub/posix_opt.h)0
-rw-r--r--sysdeps/stub/bits/sem.h (renamed from sysdeps/stub/sys/sem_buf.h)10
-rw-r--r--sysdeps/stub/bits/setjmp.h (renamed from sysdeps/stub/jmp_buf.h)0
-rw-r--r--sysdeps/stub/bits/shm.h (renamed from sysdeps/stub/sys/shm_buf.h)10
-rw-r--r--sysdeps/stub/bits/sigcontext.h (renamed from sysdeps/stub/sigcontext.h)0
-rw-r--r--sysdeps/stub/bits/signum.h (renamed from sysdeps/stub/signum.h)0
-rw-r--r--sysdeps/stub/bits/stat.h (renamed from sysdeps/stub/statbuf.h)13
-rw-r--r--sysdeps/stub/bits/stdio_lim.h (renamed from sysdeps/stub/stdio_lim.h)0
-rw-r--r--sysdeps/stub/bits/time.h (renamed from sysdeps/stub/timebits.h)12
-rw-r--r--sysdeps/stub/bits/waitflags.h (renamed from sysdeps/stub/waitflags.h)9
-rw-r--r--sysdeps/stub/nan.h6
-rw-r--r--sysdeps/stub/sys/msq_buf.h47
-rw-r--r--sysdeps/unix/Makefile49
-rw-r--r--sysdeps/unix/bsd/bits/dirent.h (renamed from sysdeps/unix/bsd/direntry.h)0
-rw-r--r--sysdeps/unix/bsd/bits/fcntl.h (renamed from sysdeps/unix/bsd/fcntlbits.h)11
-rw-r--r--sysdeps/unix/bsd/bits/posix_opt.h (renamed from sysdeps/unix/bsd/posix_opt.h)0
-rw-r--r--sysdeps/unix/bsd/bits/signum.h (renamed from sysdeps/unix/bsd/signum.h)0
-rw-r--r--sysdeps/unix/bsd/bits/stat.h (renamed from sysdeps/unix/bsd/statbuf.h)11
-rw-r--r--sysdeps/unix/bsd/bits/waitflags.h (renamed from sysdeps/unix/bsd/waitflags.h)9
-rw-r--r--sysdeps/unix/bsd/bsd4.4/bits/dirent.h (renamed from sysdeps/unix/bsd/bsd4.4/direntry.h)0
-rw-r--r--sysdeps/unix/bsd/bsd4.4/bits/errno.h (renamed from sysdeps/unix/bsd/bsd4.4/errnos.h)0
-rw-r--r--sysdeps/unix/bsd/bsd4.4/bits/fcntl.h (renamed from sysdeps/unix/bsd/bsd4.4/fcntlbits.h)11
-rw-r--r--sysdeps/unix/bsd/bsd4.4/bits/ioctls.h (renamed from sysdeps/unix/bsd/bsd4.4/ioctls.h)0
-rw-r--r--sysdeps/unix/bsd/bsd4.4/bits/sockaddr.h (renamed from sysdeps/unix/bsd/bsd4.4/sockaddrcom.h)10
-rw-r--r--sysdeps/unix/bsd/bsd4.4/tcgetattr.c2
-rw-r--r--sysdeps/unix/bsd/bsd4.4/tcsetattr.c2
-rw-r--r--sysdeps/unix/bsd/m68k/sysdep.S2
-rw-r--r--sysdeps/unix/bsd/osf/alpha/bits/stat.h (renamed from sysdeps/unix/bsd/osf/alpha/statbuf.h)14
-rw-r--r--sysdeps/unix/bsd/osf/bits/sigaction.h (renamed from sysdeps/unix/bsd/osf/sigaction.h)0
-rw-r--r--sysdeps/unix/bsd/osf/sys/mman.h2
-rw-r--r--sysdeps/unix/bsd/sun/bits/signum.h (renamed from sysdeps/unix/bsd/sun/signum.h)0
-rw-r--r--sysdeps/unix/bsd/sun/m68k/bits/sigcontext.h (renamed from sysdeps/unix/bsd/sun/m68k/sigcontext.h)0
-rw-r--r--sysdeps/unix/bsd/sun/m68k/sethostid.S2
-rw-r--r--sysdeps/unix/bsd/sun/sparc/bits/sigcontext.h (renamed from sysdeps/unix/bsd/sun/sparc/sigcontext.h)0
-rw-r--r--sysdeps/unix/bsd/sun/sparc/sethostid.S4
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/bits/fcntl.h (renamed from sysdeps/unix/bsd/sun/sunos4/fcntlbits.h)11
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/bits/resource.h (renamed from sysdeps/unix/bsd/sun/sunos4/resourcebits.h)0
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/bits/termios.h (renamed from sysdeps/unix/bsd/sun/sunos4/termbits.h)0
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/bits/utsname.h (renamed from sysdeps/unix/bsd/sun/sunos4/utsnamelen.h)0
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/sys/mman.h2
-rw-r--r--sysdeps/unix/bsd/ultrix4/bits/fcntl.h (renamed from sysdeps/unix/bsd/ultrix4/fcntlbits.h)11
-rw-r--r--sysdeps/unix/bsd/ultrix4/bits/posix_opt.h (renamed from sysdeps/unix/bsd/ultrix4/posix_opt.h)0
-rw-r--r--sysdeps/unix/bsd/ultrix4/bits/utsname.h (renamed from sysdeps/unix/bsd/ultrix4/utsnamelen.h)0
-rw-r--r--sysdeps/unix/bsd/ultrix4/mips/bits/sigcontext.h (renamed from sysdeps/unix/bsd/ultrix4/mips/sigcontext.h)0
-rw-r--r--sysdeps/unix/bsd/ultrix4/sys/mman.h2
-rw-r--r--sysdeps/unix/bsd/vax/sysdep.S2
-rw-r--r--sysdeps/unix/common/bits/dirent.h (renamed from sysdeps/unix/common/direntry.h)0
-rw-r--r--sysdeps/unix/common/bits/fcntl.h (renamed from sysdeps/unix/common/fcntlbits.h)11
-rw-r--r--sysdeps/unix/dirstream.h2
-rw-r--r--sysdeps/unix/i386/sysdep.S2
-rw-r--r--sysdeps/unix/mips/sysdep.S2
-rw-r--r--sysdeps/unix/mk-local_lim.c3
-rw-r--r--sysdeps/unix/sparc/sysdep.S2
-rw-r--r--sysdeps/unix/sysv/bits/dirent.h (renamed from sysdeps/unix/sysv/direntry.h)0
-rw-r--r--sysdeps/unix/sysv/bits/fcntl.h (renamed from sysdeps/unix/sysv/fcntlbits.h)10
-rw-r--r--sysdeps/unix/sysv/bits/local_lim.h (renamed from sysdeps/unix/sysv/local_lim.h)0
-rw-r--r--sysdeps/unix/sysv/bits/signum.h (renamed from sysdeps/unix/sysv/signum.h)0
-rw-r--r--sysdeps/unix/sysv/bits/stat.h (renamed from sysdeps/unix/sysv/statbuf.h)12
-rw-r--r--sysdeps/unix/sysv/bits/utmp.h57
-rw-r--r--sysdeps/unix/sysv/bits/utsname.h (renamed from sysdeps/unix/sysv/utsnamelen.h)0
-rw-r--r--sysdeps/unix/sysv/irix4/bits/confname.h (renamed from sysdeps/unix/sysv/irix4/confname.h)0
-rw-r--r--sysdeps/unix/sysv/irix4/bits/fcntl.h (renamed from sysdeps/unix/sysv/irix4/fcntlbits.h)11
-rw-r--r--sysdeps/unix/sysv/irix4/bits/signum.h (renamed from sysdeps/unix/sysv/irix4/signum.h)0
-rw-r--r--sysdeps/unix/sysv/irix4/bits/stat.h (renamed from sysdeps/unix/sysv/irix4/statbuf.h)12
-rw-r--r--sysdeps/unix/sysv/irix4/sys/mman.h2
-rw-r--r--sysdeps/unix/sysv/linux/Dist4
-rw-r--r--sysdeps/unix/sysv/linux/Makefile4
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/fcntl.h (renamed from sysdeps/unix/sysv/linux/alpha/fcntlbits.h)8
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/ioctls.h (renamed from sysdeps/unix/sysv/linux/sparc/ioctls.h)12
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/ipc.h (renamed from sysdeps/unix/sysv/linux/alpha/sys/ipc_buf.h)0
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/sigaction.h (renamed from sysdeps/unix/sysv/linux/alpha/sigaction.h)0
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/signum.h (renamed from sysdeps/unix/sysv/linux/alpha/signum.h)0
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/stat.h (renamed from sysdeps/unix/sysv/linux/alpha/statbuf.h)10
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/termios.h (renamed from sysdeps/unix/sysv/linux/alpha/termbits.h)0
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/time.h (renamed from sysdeps/unix/sysv/linux/alpha/timebits.h)12
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/types.h (renamed from sysdeps/unix/sysv/linux/alpha/gnu/types.h)33
-rw-r--r--sysdeps/unix/sysv/linux/alpha/brk.S2
-rw-r--r--sysdeps/unix/sysv/linux/alpha/clone.S2
-rw-r--r--sysdeps/unix/sysv/linux/alpha/kernel_termios.h (renamed from sysdeps/unix/sysv/linux/powerpc/sys/kernel_termios.h)15
-rw-r--r--sysdeps/unix/sysv/linux/alpha/sys/kernel_termios.h25
-rw-r--r--sysdeps/unix/sysv/linux/arm/clone.S2
-rw-r--r--sysdeps/unix/sysv/linux/arm/profil-counter.h2
-rw-r--r--sysdeps/unix/sysv/linux/arm/socket.S2
-rw-r--r--sysdeps/unix/sysv/linux/bits/dirent.h (renamed from sysdeps/unix/sysv/linux/direntry.h)0
-rw-r--r--sysdeps/unix/sysv/linux/bits/errno.h (renamed from sysdeps/unix/sysv/linux/errnos.h)0
-rw-r--r--sysdeps/unix/sysv/linux/bits/fcntl.h (renamed from sysdeps/unix/sysv/linux/fcntlbits.h)8
-rw-r--r--sysdeps/unix/sysv/linux/bits/ioctl-types.h (renamed from sysdeps/unix/sysv/linux/ioctl-types.h)10
-rw-r--r--sysdeps/unix/sysv/linux/bits/ioctls.h (renamed from sysdeps/unix/sysv/linux/ioctls.h)10
-rw-r--r--sysdeps/unix/sysv/linux/bits/ipc.h (renamed from sysdeps/unix/sysv/linux/sys/ipc_buf.h)0
-rw-r--r--sysdeps/unix/sysv/linux/bits/local_lim.h (renamed from sysdeps/unix/sysv/linux/local_lim.h)0
-rw-r--r--sysdeps/unix/sysv/linux/bits/msq.h (renamed from sysdeps/unix/sysv/linux/sys/msq_buf.h)0
-rw-r--r--sysdeps/unix/sysv/linux/bits/posix_opt.h (renamed from sysdeps/unix/sysv/linux/posix_opt.h)10
-rw-r--r--sysdeps/unix/sysv/linux/bits/resource.h (renamed from sysdeps/unix/sysv/linux/resourcebits.h)0
-rw-r--r--sysdeps/unix/sysv/linux/bits/sched.h (renamed from sysdeps/unix/sysv/linux/schedbits.h)9
-rw-r--r--sysdeps/unix/sysv/linux/bits/sem.h (renamed from sysdeps/unix/sysv/linux/sys/sem_buf.h)0
-rw-r--r--sysdeps/unix/sysv/linux/bits/shm.h (renamed from sysdeps/unix/sysv/linux/sys/shm_buf.h)0
-rw-r--r--sysdeps/unix/sysv/linux/bits/sigaction.h (renamed from sysdeps/unix/sysv/linux/sigaction.h)0
-rw-r--r--sysdeps/unix/sysv/linux/bits/sigcontext.h (renamed from sysdeps/unix/sysv/linux/sigcontext.h)9
-rw-r--r--sysdeps/unix/sysv/linux/bits/signum.h (renamed from sysdeps/unix/sysv/linux/signum.h)0
-rw-r--r--sysdeps/unix/sysv/linux/bits/sigset.h (renamed from sysdeps/unix/sysv/linux/sigset.h)0
-rw-r--r--sysdeps/unix/sysv/linux/bits/socket.h (renamed from sysdeps/unix/sysv/linux/socketbits.h)10
-rw-r--r--sysdeps/unix/sysv/linux/bits/stat.h (renamed from sysdeps/unix/sysv/linux/statbuf.h)10
-rw-r--r--sysdeps/unix/sysv/linux/bits/statfs.h (renamed from sysdeps/unix/sysv/linux/statfsbuf.h)12
-rw-r--r--sysdeps/unix/sysv/linux/bits/termios.h (renamed from sysdeps/unix/sysv/linux/termbits.h)11
-rw-r--r--sysdeps/unix/sysv/linux/bits/time.h (renamed from sysdeps/unix/sysv/linux/timebits.h)10
-rw-r--r--sysdeps/unix/sysv/linux/bits/types.h (renamed from sysdeps/unix/sysv/linux/gnu/types.h)20
-rw-r--r--sysdeps/unix/sysv/linux/bits/uio.h (renamed from sysdeps/unix/sysv/linux/iovec.h)7
-rw-r--r--sysdeps/unix/sysv/linux/bits/ustat.h (renamed from sysdeps/unix/sysv/linux/ustatbits.h)0
-rw-r--r--sysdeps/unix/sysv/linux/bits/utsname.h (renamed from sysdeps/unix/sysv/linux/utsnamelen.h)0
-rw-r--r--sysdeps/unix/sysv/linux/bits/waitflags.h (renamed from sysdeps/unix/sysv/linux/waitflags.h)9
-rw-r--r--sysdeps/unix/sysv/linux/i386/clone.S2
-rw-r--r--sysdeps/unix/sysv/linux/i386/profil-counter.h2
-rw-r--r--sysdeps/unix/sysv/linux/i386/socket.S2
-rw-r--r--sysdeps/unix/sysv/linux/kernel_termios.h38
-rw-r--r--sysdeps/unix/sysv/linux/m68k/clone.S2
-rw-r--r--sysdeps/unix/sysv/linux/m68k/socket.S2
-rw-r--r--sysdeps/unix/sysv/linux/netinet/ip.h4
-rw-r--r--sysdeps/unix/sysv/linux/netinet/tcp.h2
-rw-r--r--sysdeps/unix/sysv/linux/netipx/ipx.h90
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/bits/ioctl-types.h (renamed from sysdeps/unix/sysv/linux/powerpc/ioctl-types.h)0
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/bits/termios.h (renamed from sysdeps/unix/sysv/linux/powerpc/termbits.h)0
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/clone.S2
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/kernel_termios.h26
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/socket.S2
-rw-r--r--sysdeps/unix/sysv/linux/socketcall.h (renamed from sysdeps/unix/sysv/linux/sys/socketcall.h)0
-rw-r--r--sysdeps/unix/sysv/linux/sparc/bits/fcntl.h (renamed from sysdeps/unix/sysv/linux/sparc/fcntlbits.h)0
-rw-r--r--sysdeps/unix/sysv/linux/sparc/bits/ioctls.h (renamed from sysdeps/unix/sysv/linux/alpha/ioctls.h)12
-rw-r--r--sysdeps/unix/sysv/linux/sparc/bits/sigaction.h (renamed from sysdeps/unix/sysv/linux/sparc/sigaction.h)0
-rw-r--r--sysdeps/unix/sysv/linux/sparc/bits/signum.h (renamed from sysdeps/unix/sysv/linux/sparc/signum.h)0
-rw-r--r--sysdeps/unix/sysv/linux/sparc/bits/termios.h (renamed from sysdeps/unix/sysv/linux/sparc/termbits.h)0
-rw-r--r--sysdeps/unix/sysv/linux/sparc/profil-counter.h2
-rw-r--r--sysdeps/unix/sysv/linux/sparc/socket.S2
-rw-r--r--sysdeps/unix/sysv/linux/sys/kernel_termios.h20
-rw-r--r--sysdeps/unix/sysv/linux/sys/mman.h2
-rw-r--r--sysdeps/unix/sysv/linux/sys/syscall.h4
-rw-r--r--sysdeps/unix/sysv/linux/tcgetattr.c2
-rw-r--r--sysdeps/unix/sysv/linux/tcsetattr.c2
-rw-r--r--sysdeps/unix/sysv/minix/bits/sigaction.h (renamed from sysdeps/unix/sysv/minix/sigaction.h)0
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/bits/confname.h (renamed from sysdeps/unix/sysv/sco3.2.4/confname.h)0
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/bits/sigaction.h (renamed from sysdeps/unix/sysv/sco3.2.4/sigaction.h)0
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/sysconf.S2
-rw-r--r--sysdeps/unix/sysv/sco3.2/bits/local_lim.h (renamed from sysdeps/unix/sysv/sco3.2/local_lim.h)6
-rw-r--r--sysdeps/unix/sysv/sysv4/bits/sigaction.h (renamed from sysdeps/unix/sysv/sysv4/sigaction.h)0
-rw-r--r--sysdeps/unix/sysv/sysv4/bits/signum.h (renamed from sysdeps/unix/sysv/sysv4/signum.h)0
-rw-r--r--sysdeps/unix/sysv/sysv4/bits/sigset.h (renamed from sysdeps/unix/sysv/sysv4/sigset.h)0
-rw-r--r--sysdeps/unix/sysv/sysv4/bits/utsname.h (renamed from sysdeps/unix/sysv/sysv4/utsnamelen.h)0
-rw-r--r--sysdeps/unix/sysv/sysv4/bits/waitflags.h (renamed from sysdeps/unix/sysv/sysv4/waitflags.h)9
-rw-r--r--sysdeps/unix/sysv/sysv4/i386/bits/stat.h (renamed from sysdeps/unix/sysv/sysv4/i386/statbuf.h)12
-rw-r--r--sysdeps/unix/sysv/sysv4/i386/sysdep.h2
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/bits/signum.h (renamed from sysdeps/unix/sysv/sysv4/solaris2/signum.h)0
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/bits/stat.h (renamed from sysdeps/unix/sysv/sysv4/solaris2/statbuf.h)14
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/sparc/bits/sigcontext.h1
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/sparc/sigcontext.h1
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.S2
-rw-r--r--sysdeps/unix/sysv/utmpbits.h58
-rw-r--r--sysdeps/vax/bits/huge_val.h (renamed from sysdeps/vax/huge_val.h)8
-rw-r--r--sysdeps/vax/bits/setjmp.h (renamed from sysdeps/vax/jmp_buf.h)0
-rw-r--r--sysdeps/wordsize-32/bits/elfclass.h (renamed from sysdeps/wordsize-32/elfclass.h)0
-rw-r--r--sysdeps/wordsize-32/inttypes.h5
-rw-r--r--sysdeps/wordsize-64/bits/elfclass.h (renamed from sysdeps/wordsize-64/elfclass.h)0
-rw-r--r--sysdeps/wordsize-64/inttypes.h5
329 files changed, 4920 insertions, 1986 deletions
diff --git a/sysdeps/alpha/bytesex.h b/sysdeps/alpha/bits/endian.h
index e873d2123c..e873d2123c 100644
--- a/sysdeps/alpha/bytesex.h
+++ b/sysdeps/alpha/bits/endian.h
diff --git a/sysdeps/alpha/jmp_buf.h b/sysdeps/alpha/bits/setjmp.h
index 6e6f6b4727..6e6f6b4727 100644
--- a/sysdeps/alpha/jmp_buf.h
+++ b/sysdeps/alpha/bits/setjmp.h
diff --git a/sysdeps/alpha/fpu/fenvbits.h b/sysdeps/alpha/fpu/bits/fenv.h
index 02414e4c30..7cb0e3e543 100644
--- a/sysdeps/alpha/fpu/fenvbits.h
+++ b/sysdeps/alpha/fpu/bits/fenv.h
@@ -17,10 +17,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-/* This file should never be included directly.  */
+#ifndef _FENV_H
+#error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
 
-#ifndef _FENVBITS_H
-#define _FENVBITS_H	1
 
 /* Define the bits representing the exception.
 
@@ -102,6 +102,3 @@ typedef unsigned long fenv_t;
 /* The system calls to talk to the kernel's FP code.  */
 extern unsigned long __ieee_get_fp_control(void);
 extern void __ieee_set_fp_control(unsigned long);
-
-
-#endif /* fenvbits.h */
diff --git a/sysdeps/alpha/fpu/bits/mathdef.h b/sysdeps/alpha/fpu/bits/mathdef.h
new file mode 100644
index 0000000000..0bc9c94ecc
--- /dev/null
+++ b/sysdeps/alpha/fpu/bits/mathdef.h
@@ -0,0 +1,64 @@
+/* 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.  */
+
+#ifndef _MATH_H
+#error "Never use <bits/mathdef.h> directly; include <math.h> instead"
+#endif
+
+/* FIXME! This file describes properties of the compiler, not the machine;
+   it should not be part of libc!  */
+
+#ifdef __GNUC__
+#if __STDC__ == 1
+
+/* In GNU or ANSI mode, gcc leaves `float' expressions as-is.  */
+typedef float float_t;
+typedef double double_t;
+
+/* Signal that types stay as they were declared.  */
+#define FLT_EVAL_METHOD	0
+
+/* Define `INFINITY' as value of type `float_t'.  */
+#define INFINITY	HUGE_VALF
+
+#else 
+
+/* For `gcc -traditional', `float' expressions are evaluated as `double'. */
+typedef double float_t;
+typedef double double_t;
+
+/* Signal that both types are `double'.  */
+#define FLT_EVAL_METHOD	1
+
+/* Define `INFINITY' as value of type `float_t'.  */
+#define INFINITY	HUGE_VAL
+
+#endif
+#else
+
+/* Wild guess at types for float_t and double_t. */
+typedef double float_t;
+typedef double double_t;
+
+/* Strange compiler, we don't know how it works.  */
+#define FLT_EVAL_METHOD	-1
+
+/* Define `INFINITY' as value of type `float_t'.  */
+#define INFINITY	HUGE_VAL
+
+#endif
diff --git a/sysdeps/alpha/__math.h b/sysdeps/alpha/fpu/bits/mathinline.h
index 0f76027317..0f76027317 100644
--- a/sysdeps/alpha/__math.h
+++ b/sysdeps/alpha/fpu/bits/mathinline.h
diff --git a/sysdeps/alpha/w_sqrt.S b/sysdeps/alpha/w_sqrt.S
index cf5ae097fd..32b06887d5 100644
--- a/sysdeps/alpha/w_sqrt.S
+++ b/sysdeps/alpha/w_sqrt.S
@@ -25,7 +25,7 @@
 #ifndef _IEEE_FP
 
 #define _ERRNO_H
-#include <errnos.h>
+#include <bits/errno.h>
 #include <sysdep.h>
 
 	.set noreorder
diff --git a/sysdeps/arm/__longjmp.S b/sysdeps/arm/__longjmp.S
index 5443761f0a..b027103d60 100644
--- a/sysdeps/arm/__longjmp.S
+++ b/sysdeps/arm/__longjmp.S
@@ -19,7 +19,7 @@
 
 #include <sysdep.h>
 #define _ASM
-#include <jmp_buf.h>
+#include <bits/setjmp.h>
 
 /* __longjmp(jmpbuf, val) */
 
diff --git a/sysdeps/arm/bytesex.h b/sysdeps/arm/bits/endian.h
index 32f8489df2..32f8489df2 100644
--- a/sysdeps/arm/bytesex.h
+++ b/sysdeps/arm/bits/endian.h
diff --git a/sysdeps/arm/jmp_buf.h b/sysdeps/arm/bits/setjmp.h
index 93b0f5f916..93b0f5f916 100644
--- a/sysdeps/arm/jmp_buf.h
+++ b/sysdeps/arm/bits/setjmp.h
diff --git a/sysdeps/arm/setjmp.S b/sysdeps/arm/setjmp.S
index 5891cb9dec..8f99e4fcb4 100644
--- a/sysdeps/arm/setjmp.S
+++ b/sysdeps/arm/setjmp.S
@@ -19,7 +19,7 @@
 
 #include <sysdep.h>
 #define _ASM
-#include <jmp_buf.h>
+#include <bits/setjmp.h>
 
 	/* Binary compatibility entry point.  */
 ENTRY (__setjmp)
diff --git a/sysdeps/generic/Makefile b/sysdeps/generic/Makefile
index 5513ca998c..110669ccb5 100644
--- a/sysdeps/generic/Makefile
+++ b/sysdeps/generic/Makefile
@@ -41,7 +41,7 @@ $(objpfx)siglist.c: $(objpfx)make_siglist
 	mv $@-tmp $@
 
 make_siglist-CFLAGS = -DSIGNUM_H=\"$(shell pwd)/$(firstword $(wildcard \
-				   $(+sysdep_dirs:%=%/signum.h)))\"
+				   $(+sysdep_dirs:%=%/bits/signum.h)))\"
 $(objpfx)make_siglist: $(sysdep_dir)/generic/make_siglist.c
 	$(native-compile)
 
diff --git a/sysdeps/generic/abort.c b/sysdeps/generic/abort.c
index c1969f4d1f..a38022a1a9 100644
--- a/sysdeps/generic/abort.c
+++ b/sysdeps/generic/abort.c
@@ -16,7 +16,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#include <libc-lock.h>
+#include <bits/libc-lock.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/sysdeps/generic/confname.h b/sysdeps/generic/bits/confname.h
index 5b5cf742b6..5b5cf742b6 100644
--- a/sysdeps/generic/confname.h
+++ b/sysdeps/generic/bits/confname.h
diff --git a/sysdeps/generic/ioctl-types.h b/sysdeps/generic/bits/ioctl-types.h
index 50fe19adcf..1d5c8a002f 100644
--- a/sysdeps/generic/ioctl-types.h
+++ b/sysdeps/generic/bits/ioctl-types.h
@@ -17,8 +17,12 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _IOCTL_TYPES_H
-#define _IOCTL_TYPES_H 1
+/*
+ * Never include this file directly; use <sys/ioctl.h> instead.
+ */
+
+#ifndef _BITS_IOCTL_TYPES_H
+#define _BITS_IOCTL_TYPES_H 1
 
 
 #if	defined(TIOCGETC) || defined(TIOCSETC)
@@ -114,4 +118,4 @@ struct ttysize
 #endif
 
 
-#endif /* ioctl-types.h */
+#endif /* bits/ioctl-types.h */
diff --git a/sysdeps/generic/mathbits.h b/sysdeps/generic/bits/mathdef.h
index b14b52d901..93b60bd25f 100644
--- a/sysdeps/generic/mathbits.h
+++ b/sysdeps/generic/bits/mathdef.h
@@ -16,8 +16,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _MATHBITS_H
-#define _MATHBITS_H	1
+#ifndef _MATH_H
+# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
+#endif
+
 
 /* Normally, there is no long double type and the `float' and `double'
    expressions are evaluated as `double'.  */
@@ -36,5 +38,3 @@ typedef double double_t;	/* `double' expressions are evaluated as
 /* The values returned by `ilogb' for 0 and NaN respectively.  */
 #define FP_ILOGB0	0x80000001
 #define FP_ILOGBNAN	0x7fffffff
-
-#endif /* mathbits.h */
diff --git a/sysdeps/generic/resourcebits.h b/sysdeps/generic/bits/resource.h
index 2c35c12a47..2c35c12a47 100644
--- a/sysdeps/generic/resourcebits.h
+++ b/sysdeps/generic/bits/resource.h
diff --git a/sysdeps/generic/bits/sched.h b/sysdeps/generic/bits/sched.h
new file mode 100644
index 0000000000..bb5da5676f
--- /dev/null
+++ b/sysdeps/generic/bits/sched.h
@@ -0,0 +1,35 @@
+/* Definitions of constants and data structure for POSIX 1003.1b-1993
+   scheduling interface.
+   Copyright (C) 1996 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, write to the Free Software Foundation, Inc., 59 Temple Place
+   Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef _SCHED_H
+#error "Never use <bits/sched.h> directly; include <sched.h> instead."
+#endif
+
+
+/* Scheduling algorithms.  */
+#define SCHED_OTHER	0
+#define SCHED_FIFO	1
+#define SCHED_RR	2
+
+/* Data structure to describe a process' schedulability.  */
+struct sched_param
+{
+  int sched_priority;
+};
diff --git a/sysdeps/generic/selectbits.h b/sysdeps/generic/bits/select.h
index e2bdf6049e..613919577c 100644
--- a/sysdeps/generic/selectbits.h
+++ b/sysdeps/generic/bits/select.h
@@ -16,8 +16,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _SELECTBITS_H
-#define _SELECTBITS_H	1
+#ifndef _SYS_SELECT_H
+#error "Never use <bits/select.h> directly; include <sys/select.h> instead."
+#endif
+
 
 /* This line MUST be split!  Otherwise m4 will not change it.  */
 #define __FD_ZERO(set)  \
@@ -25,5 +27,3 @@
 #define __FD_SET(d, set)	((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
 #define __FD_CLR(d, set)	((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
 #define __FD_ISSET(d, set)	((set)->fds_bits[__FDELT(d)] & __FDMASK(d))
-
-#endif /* selectbits.h */
diff --git a/sysdeps/generic/sigaction.h b/sysdeps/generic/bits/sigaction.h
index 1676b1ce8e..1676b1ce8e 100644
--- a/sysdeps/generic/sigaction.h
+++ b/sysdeps/generic/bits/sigaction.h
diff --git a/sysdeps/generic/sigset.h b/sysdeps/generic/bits/sigset.h
index 9fad4538d7..9fad4538d7 100644
--- a/sysdeps/generic/sigset.h
+++ b/sysdeps/generic/bits/sigset.h
diff --git a/sysdeps/generic/sockaddrcom.h b/sysdeps/generic/bits/sockaddr.h
index 8b1de11c15..73a0e26ec4 100644
--- a/sysdeps/generic/sockaddrcom.h
+++ b/sysdeps/generic/bits/sockaddr.h
@@ -17,8 +17,12 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _SOCKADDRCOM_H
-#define _SOCKADDRCOM_H	1
+/*
+ * Never include this file directly; use <sys/socket.h> instead.
+ */
+
+#ifndef _BITS_SOCKADDR_H
+#define _BITS_SOCKADDR_H	1
 
 
 /* POSIX.1g specifies this type name for the `sa_family' member.  */
@@ -34,4 +38,4 @@ typedef unsigned short int sa_family_t;
 #define __SOCKADDR_COMMON_SIZE	(sizeof (unsigned short int))
 
 
-#endif	/* sockaddrcom.h */
+#endif	/* bits/sockaddr.h */
diff --git a/sysdeps/generic/socketbits.h b/sysdeps/generic/bits/socket.h
index 5d85a8e079..d12d96cc14 100644
--- a/sysdeps/generic/socketbits.h
+++ b/sysdeps/generic/bits/socket.h
@@ -17,9 +17,11 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_SOCKETBITS_H
+#ifndef _SYS_SOCKET_H
+#error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
+#endif
+
 
-#define	_SOCKETBITS_H	1
 #include <features.h>
 
 __BEGIN_DECLS
@@ -114,7 +116,7 @@ enum __socket_type
 
 
 /* Get the definition of the macro to define the common sockaddr members.  */
-#include <sockaddrcom.h>
+#include <bits/sockaddr.h>
 
 /* Structure describing a generic socket address.  */
 struct sockaddr
@@ -196,5 +198,3 @@ struct linger
   };
 
 __END_DECLS
-
-#endif /* socketbits.h */
diff --git a/sysdeps/generic/bits/statfs.h b/sysdeps/generic/bits/statfs.h
new file mode 100644
index 0000000000..10bc0728b2
--- /dev/null
+++ b/sysdeps/generic/bits/statfs.h
@@ -0,0 +1,52 @@
+/* Definition of `struct statfs', information about a filesystem.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/*
+ * Never include this file directly; use <sys/statfs.h> instead.
+ */
+
+#ifndef	_BITS_STATFS_H
+#define	_BITS_STATFS_H	1
+
+#include <bits/types.h>
+
+/* GNU Hurd NOTE: The size of this structure (16 ints) is known in
+   <hurd/hurd_types.defs>, since it is used in the `file_statfs' RPC.  MiG
+   does not cope at all well with the passed C structure not being of the
+   expected size.  There are some filler words at the end to allow for
+   future expansion.  To increase the size of the structure used in the RPC
+   and retain binary compatibility, we would need to assign a new message
+   number.  */
+
+struct statfs
+  {
+    unsigned int f_type;
+    unsigned int f_bsize;
+    unsigned int f_blocks;
+    unsigned int f_bfree;
+    unsigned int f_bavail;
+    unsigned int f_files;
+    unsigned int f_ffree;
+    __fsid_t f_fsid;
+    unsigned int f_namelen;
+    unsigned int f_spare[6];
+  };
+
+
+#endif /* bits/statfs.h */
diff --git a/sysdeps/generic/termbits.h b/sysdeps/generic/bits/termios.h
index adf0ee2f75..9a6aed2bba 100644
--- a/sysdeps/generic/termbits.h
+++ b/sysdeps/generic/bits/termios.h
@@ -17,8 +17,9 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-/* These macros are also defined in some ioctls.h files (with numerically
-   identical values), but this serves to shut up cpp's complaining. */
+/* These macros are also defined in some <bits/ioctls.h> files (with
+   numerically identical values), but this serves to shut up cpp's
+   complaining. */
 #ifdef __USE_BSD
 
 #ifdef MDMBUF
diff --git a/sysdeps/generic/gnu/types.h b/sysdeps/generic/bits/types.h
index 85f17a4fb1..c264adc917 100644
--- a/sysdeps/generic/gnu/types.h
+++ b/sysdeps/generic/bits/types.h
@@ -16,9 +16,12 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_GNU_TYPES_H
+/*
+ * Never include this file directly; use <sys/types.h> instead.
+ */
 
-#define	_GNU_TYPES_H	1
+#ifndef	_BITS_TYPES_H
+#define	_BITS_TYPES_H	1
 
 
 /* Convenience types.  */
@@ -39,6 +42,16 @@ typedef struct
   __u_long __val[2];
 } __u_quad_t;
 #endif
+typedef signed char __int8_t;
+typedef unsigned char __uint8_t;
+typedef signed short int __int16_t;
+typedef unsigned short int __uint16_t;
+typedef signed int __int32_t;
+typedef unsigned int __uint32_t;
+#ifdef __GNUC__
+typedef signed long long int __int64_t;
+typedef unsigned long long int __uint64_t;
+#endif
 typedef __quad_t *__qaddr_t;
 typedef int __dev_t;		/* Type of device numbers.  */
 typedef unsigned int __uid_t;	/* Type of user identifications.  */
@@ -78,4 +91,4 @@ typedef struct
 
 typedef unsigned long int __fd_mask;
 
-#endif /* gnu/types.h */
+#endif /* bits/types.h */
diff --git a/sysdeps/generic/bits/uio.h b/sysdeps/generic/bits/uio.h
new file mode 100644
index 0000000000..1a12697008
--- /dev/null
+++ b/sysdeps/generic/bits/uio.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef _SYS_UIO_H
+#error "Never use <bits/uio.h> directly; include <sys/uio.h> instead."
+#endif
+
+
+/* `struct iovec' -- Structure describing a section of memory.  */
+
+struct iovec
+{
+  /* Starting address.  */
+  __ptr_t iov_base;
+  /* Length in bytes.  */
+  size_t iov_len;
+};
diff --git a/sysdeps/generic/ustatbits.h b/sysdeps/generic/bits/ustat.h
index aa5d493e63..aa5d493e63 100644
--- a/sysdeps/generic/ustatbits.h
+++ b/sysdeps/generic/bits/ustat.h
diff --git a/sysdeps/generic/utmpbits.h b/sysdeps/generic/bits/utmp.h
index cbd3457bd4..b8decb0598 100644
--- a/sysdeps/generic/utmpbits.h
+++ b/sysdeps/generic/bits/utmp.h
@@ -1,5 +1,5 @@
 /* The `struct utmp' type, describing entries in the utmp file.  Generic/BSDish
-   Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
 
    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
@@ -16,9 +16,11 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _UTMPBITS_H
+#ifndef _UTMP_H
+#error "Never use <bits/utmp.h> directly; include <utmp.h> instead."
+#endif
+
 
-#define _UTMPBITS_H	1
 #include <features.h>
 
 #include <paths.h>
@@ -49,5 +51,3 @@ struct utmp {
 
 
 __END_DECLS
-
-#endif /* utmpbits.h */
diff --git a/sysdeps/generic/utsnamelen.h b/sysdeps/generic/bits/utsname.h
index 5594bcc4da..5594bcc4da 100644
--- a/sysdeps/generic/utsnamelen.h
+++ b/sysdeps/generic/bits/utsname.h
diff --git a/sysdeps/generic/waitstatus.h b/sysdeps/generic/bits/waitstatus.h
index 4fbcbe87aa..8e97f2702c 100644
--- a/sysdeps/generic/waitstatus.h
+++ b/sysdeps/generic/bits/waitstatus.h
@@ -1,5 +1,5 @@
 /* Definitions of status bits for `wait' et al.
-   Copyright (C) 1992, 1994, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1992, 1994, 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
@@ -17,10 +17,13 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#ifndef _SYS_WAIT_H
+#error "Never use <bits/waitstatus.h> directly; include <sys/wait.h> instead."
+#endif
+
+
 /* Everything extant so far uses these same bits.  */
 
-#ifndef	_WAITSTATUS_H
-#define	_WAITSTATUS_H
 
 /* If WIFEXITED(STATUS), the low-order 8 bits of the status.  */
 #define	__WEXITSTATUS(status)	(((status) & 0xff00) >> 8)
@@ -99,6 +102,3 @@ union wait
 #define	w_stopval	__wait_stopped.__w_stopval
 
 #endif	/* Use BSD.  */
-
-
-#endif	/* waitstatus.h */
diff --git a/sysdeps/generic/iovec.h b/sysdeps/generic/iovec.h
deleted file mode 100644
index 307fc6a18a..0000000000
--- a/sysdeps/generic/iovec.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* `struct iovec' -- Structure describing a section of memory.  */
-
-struct iovec
-{
-  /* Starting address.  */
-  __ptr_t iov_base;
-  /* Length in bytes.  */
-  size_t iov_len;
-};
diff --git a/sysdeps/generic/netinet/ip.h b/sysdeps/generic/netinet/ip.h
index a119c629f7..84615a5714 100644
--- a/sysdeps/generic/netinet/ip.h
+++ b/sysdeps/generic/netinet/ip.h
@@ -36,7 +36,7 @@
 #ifndef _NETINET_IP_H
 #define _NETINET_IP_H
 
-#include <gnu/types.h>
+#include <bits/types.h>
 #include <endian.h>
 #include <netinet/in.h>
 
diff --git a/sysdeps/generic/schedbits.h b/sysdeps/generic/schedbits.h
deleted file mode 100644
index e2cb00e842..0000000000
--- a/sysdeps/generic/schedbits.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Definitions of constants and data structure for POSIX 1003.1b-1993
-   scheduling interface.
-Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
-#ifndef	_SCHEDBITS_H
-#define	_SCHEDBITS_H	1
-
-/* Scheduling algorithms.  */
-#define SCHED_OTHER	0
-#define SCHED_FIFO	1
-#define SCHED_RR	2
-
-/* Data structure to describe a process' schedulability.  */
-struct sched_param
-{
-  int sched_priority;
-};
-
-#endif /* schedbits.h */
diff --git a/sysdeps/generic/setenv.c b/sysdeps/generic/setenv.c
index 11b5906a9d..e740fa9eef 100644
--- a/sysdeps/generic/setenv.c
+++ b/sysdeps/generic/setenv.c
@@ -47,7 +47,7 @@ extern char **environ;
 
 #if _LIBC
 /* This lock protects against simultaneous modifications of `environ'.  */
-# include <libc-lock.h>
+# include <bits/libc-lock.h>
 __libc_lock_define_initialized (static, envlock)
 # define LOCK	__libc_lock_lock (envlock)
 # define UNLOCK	__libc_lock_unlock (envlock)
diff --git a/sysdeps/generic/statfsbuf.h b/sysdeps/generic/statfsbuf.h
deleted file mode 100644
index e5c2dd7f77..0000000000
--- a/sysdeps/generic/statfsbuf.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Definition of `struct statfs', information about a filesystem.
-Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.  */
-
-#ifndef	_STATFSBUF_H
-
-#define	_STATFSBUF_H	1
-
-#include <gnu/types.h>
-
-/* GNU Hurd NOTE: The size of this structure (16 ints) is known in
-   <hurd/hurd_types.defs>, since it is used in the `file_statfs' RPC.  MiG
-   does not cope at all well with the passed C structure not being of the
-   expected size.  There are some filler words at the end to allow for
-   future expansion.  To increase the size of the structure used in the RPC
-   and retain binary compatibility, we would need to assign a new message
-   number.  */
-
-struct statfs
-  {
-    unsigned int f_type;
-    unsigned int f_bsize;
-    unsigned int f_blocks;
-    unsigned int f_bfree;
-    unsigned int f_bavail;
-    unsigned int f_files;
-    unsigned int f_ffree;
-    __fsid_t f_fsid;
-    unsigned int f_namelen;
-    unsigned int f_spare[6];
-  };
-
-
-#endif /* statfsbuf.h */
diff --git a/sysdeps/generic/sys/mman.h b/sysdeps/generic/sys/mman.h
index 32b152e124..9c2a1b62ce 100644
--- a/sysdeps/generic/sys/mman.h
+++ b/sysdeps/generic/sys/mman.h
@@ -26,7 +26,7 @@
 #define	_SYS_MMAN_H	1
 #include <features.h>
 
-#include <gnu/types.h>
+#include <bits/types.h>
 #define __need_size_t
 #include <stddef.h>
 
diff --git a/sysdeps/gnu/utmpbits.h b/sysdeps/gnu/bits/utmp.h
index db49ac845c..db49ac845c 100644
--- a/sysdeps/gnu/utmpbits.h
+++ b/sysdeps/gnu/bits/utmp.h
diff --git a/sysdeps/i386/__longjmp.S b/sysdeps/i386/__longjmp.S
index f6331d496d..0ec5d26a38 100644
--- a/sysdeps/i386/__longjmp.S
+++ b/sysdeps/i386/__longjmp.S
@@ -19,7 +19,7 @@
 
 #include <sysdep.h>
 #define _ASM
-#include <jmp_buf.h>
+#include <bits/setjmp.h>
 
 ENTRY (__longjmp)
 	movl 4(%esp), %ecx	/* User's jmp_buf in %ecx.  */
diff --git a/sysdeps/i386/bytesex.h b/sysdeps/i386/bits/endian.h
index a5d6c5ea92..a5d6c5ea92 100644
--- a/sysdeps/i386/bytesex.h
+++ b/sysdeps/i386/bits/endian.h
diff --git a/sysdeps/i386/huge_val.h b/sysdeps/i386/bits/huge_val.h
index fa071452fb..65a06d8f3c 100644
--- a/sysdeps/i386/huge_val.h
+++ b/sysdeps/i386/bits/huge_val.h
@@ -18,8 +18,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	   _HUGE_VAL_H
-#define	   _HUGE_VAL_H	1
+#ifndef _MATH_H
+#error "Never use <bits/huge_val.h> directly; include <math.h> instead."
+#endif
+
 
 #include <features.h>
 #include <sys/cdefs.h>
@@ -66,5 +68,3 @@ static __huge_vall_t __huge_vall = { __HUGE_VALL_bytes };
 #endif	/* GCC.  */
 
 #endif	/* __USE_ISOC9X.  */
-
-#endif	   /* huge_val.h */
diff --git a/sysdeps/i386/selectbits.h b/sysdeps/i386/bits/select.h
index 973ecad58e..3912515a7f 100644
--- a/sysdeps/i386/selectbits.h
+++ b/sysdeps/i386/bits/select.h
@@ -16,8 +16,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _SELECTBITS_H
-#define _SELECTBITS_H	1
+#ifndef _SYS_SELECT_H
+#error "Never use <bits/select.h> directly; include <sys/select.h> instead."
+#endif
+
 
 #if defined __GNUC__ && __GNUC__ >= 2
 
@@ -53,5 +55,3 @@
 #define __FD_ISSET(d, set)	((set)->fds_bits[__FDELT(d)] & __FDMASK(d))
 
 #endif	/* GNU CC */
-
-#endif /* selectbits.h */
diff --git a/sysdeps/i386/jmp_buf.h b/sysdeps/i386/bits/setjmp.h
index 0c03073b36..0c03073b36 100644
--- a/sysdeps/i386/jmp_buf.h
+++ b/sysdeps/i386/bits/setjmp.h
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 6efa32bcd1..64d36ca1a9 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -263,6 +263,10 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
       switch (ELF32_R_TYPE (reloc->r_info))
 	{
 	case R_386_COPY:
+	  if (sym == NULL)
+	    /* This can happen in trace mode if an object could not be
+	       found.  */
+	    break;
 	  if (sym->st_size > refsym->st_size
 	      || (_dl_verbose && sym->st_size < refsym->st_size))
 	    {
diff --git a/sysdeps/i386/fpu/fenvbits.h b/sysdeps/i386/fpu/bits/fenv.h
index bea89a15b1..63f3e52958 100644
--- a/sysdeps/i386/fpu/fenvbits.h
+++ b/sysdeps/i386/fpu/bits/fenv.h
@@ -16,10 +16,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-/* This file should never be included directly.  */
+#ifndef _FENV_H
+#error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
 
-#ifndef _FENVBITS_H
-#define _FENVBITS_H	1
 
 /* Define bits representing the exception.  We use the bit positions
    of the appropriate bits in the FPU control word.  */
@@ -87,5 +87,3 @@ fenv_t;
 /* Floating-point environment where none of the exception is masked.  */
 # define FE_NOMASK_ENV	((fenv_t *) -2)
 #endif
-
-#endif /* fenvbits.h */
diff --git a/sysdeps/i386/fpu/mathbits.h b/sysdeps/i386/fpu/bits/mathdef.h
index f4a22c0757..2387a39510 100644
--- a/sysdeps/i386/fpu/mathbits.h
+++ b/sysdeps/i386/fpu/bits/mathdef.h
@@ -16,8 +16,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _MATHBITS_H
-#define _MATHBITS_H	1
+#ifndef _MATH_H
+# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
+#endif
+
 
 /* The ix87 FPUs evaluate all values in the 80 bit floating-point format
    which is also available for the user as `long double'.  Therefore
@@ -37,5 +39,3 @@ typedef long double double_t;	/* `double' expressions are evaluated as
 /* The values returned by `ilogb' for 0 and NaN respectively.  */
 #define FP_ILOGB0	0x80000000
 #define FP_ILOGBNAN	0x80000000
-
-#endif /* mathbits.h */
diff --git a/sysdeps/i386/fpu/__math.h b/sysdeps/i386/fpu/bits/mathinline.h
index 9e1c23cec0..d5c480a51a 100644
--- a/sysdeps/i386/fpu/__math.h
+++ b/sysdeps/i386/fpu/bits/mathinline.h
@@ -18,8 +18,8 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef __MATH_H
-#define __MATH_H	1
+#ifndef _BITS_MATHINLINE_H
+#define _BITS_MATHINLINE_H	1
 
 #if defined __GNUG__ && \
     (__GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ <= 7))
@@ -605,4 +605,4 @@ pow2 (double __x)
 #endif /* __NO_MATH_INLINES  */
 #endif /* __GNUC__  */
 
-#endif /* __MATH_H  */
+#endif /* _BITS_MATHINLINE_H  */
diff --git a/sysdeps/i386/setjmp.S b/sysdeps/i386/setjmp.S
index 203c2d16d0..1ba3fc5a75 100644
--- a/sysdeps/i386/setjmp.S
+++ b/sysdeps/i386/setjmp.S
@@ -19,7 +19,7 @@
 
 #include <sysdep.h>
 #define _ASM
-#include <jmp_buf.h>
+#include <bits/setjmp.h>
 
 	/* Binary compatibility entry point.  */
 ENTRY (__setjmp)
diff --git a/sysdeps/ieee754/huge_val.h b/sysdeps/ieee754/bits/huge_val.h
index a2520859e4..fe0144c734 100644
--- a/sysdeps/ieee754/huge_val.h
+++ b/sysdeps/ieee754/bits/huge_val.h
@@ -18,12 +18,12 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	   _HUGE_VAL_H
-#define	   _HUGE_VAL_H	1
+#ifndef _MATH_H
+#error "Never use <bits/huge_val.h> directly; include <math.h> instead."
+#endif
+
 
 #include <features.h>
-#include <sys/cdefs.h>
-#include <endian.h>
 
 /* IEEE positive infinity (-HUGE_VAL is negative infinity).  */
 
@@ -36,6 +36,9 @@
 
 #else /* not GCC */
 
+#include <sys/cdefs.h>
+#include <endian.h>
+
 typedef union { unsigned char __c[8]; double __d; } __huge_val_t;
 
 #if __BYTE_ORDER == __BIG_ENDIAN
@@ -84,5 +87,3 @@ static __huge_valf_t __huge_valf = { __HUGE_VALF_bytes };
 #define HUGE_VALL HUGE_VAL
 
 #endif /* __USE_ISOC9X.  */
-
-#endif /* huge_val.h */
diff --git a/sysdeps/ieee754/nan.h b/sysdeps/ieee754/bits/nan.h
index 499edbac8c..94988ced9c 100644
--- a/sysdeps/ieee754/nan.h
+++ b/sysdeps/ieee754/bits/nan.h
@@ -17,42 +17,43 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_NAN_H
+#ifndef _MATH_H
+# error "Never use <bits/nan.h> directly; include <math.h> instead."
+#endif
 
-#define	_NAN_H	1
 
 /* IEEE Not A Number.  */
 
 #ifdef	__GNUC__
 
-#define NAN                                                                 \
+# define NAN                                                                 \
   (__extension__                                                            \
    ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) \
     { __l: 0x7ff8000000000000ULL }).__d)
 
-#define NANF                                                                \
+# define NANF                                                                \
   (__extension__                                                            \
    ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; })  \
     { __l: 0x7fc00000UL }).__d)
 
 #else
 
-#include <endian.h>
+# include <endian.h>
 
-#if __BYTE_ORDER == __BIG_ENDIAN
-#define	__nan_bytes		{ 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 }
-#define	__nanf_bytes		{ 0x7f, 0xc0, 0, 0 }
-#endif
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define	__nan_bytes		{ 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }
-#define	__nanf_bytes		{ 0, 0, 0xc0, 0x7f }
-#endif
+# if __BYTE_ORDER == __BIG_ENDIAN
+#  define __nan_bytes		{ 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 }
+#  define __nanf_bytes		{ 0x7f, 0xc0, 0, 0 }
+# endif
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+#  define __nan_bytes		{ 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }
+#  define __nanf_bytes		{ 0, 0, 0xc0, 0x7f }
+# endif
 
 static union { unsigned char __c[8]; double __d; } __nan = { __nan_bytes };
-#define	NAN	(__nan.__d)
+# define NAN	(__nan.__d)
 
 static union { unsigned char __c[4]; double __d; } __nanf = { __nanf_bytes };
-#define	NANF	(__nanf.__d)
+# define NANF	(__nanf.__d)
 
 #endif	/* GCC.  */
 
@@ -60,5 +61,3 @@ static union { unsigned char __c[4]; double __d; } __nanf = { __nanf_bytes };
    same as `double'.  */
 
 #define NANL  NAN
-
-#endif	/* nan.h */
diff --git a/sysdeps/libm-ieee754/k_standard.c b/sysdeps/libm-ieee754/k_standard.c
index ada1df1a99..d1f82747f6 100644
--- a/sysdeps/libm-ieee754/k_standard.c
+++ b/sysdeps/libm-ieee754/k_standard.c
@@ -117,7 +117,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = NAN;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if(_LIB_VERSION == _SVID_) {
 		    (void) WRITE2("acos: DOMAIN error\n", 19);
 		  }
@@ -137,7 +137,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = NAN;
 		if(_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if(_LIB_VERSION == _SVID_) {
 		    	(void) WRITE2("asin: DOMAIN error\n", 19);
 		  }
@@ -157,7 +157,7 @@ static double zero = 0.0;	/* used as const */
 		exc.retval = HUGE;
 		if(_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if(_LIB_VERSION == _SVID_) {
 			(void) WRITE2("atan2: DOMAIN error\n", 20);
 		      }
@@ -177,7 +177,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 			__set_errno (ERANGE);
 		}
 		break;
@@ -194,7 +194,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 			__set_errno (ERANGE);
 		}
 		break;
@@ -211,7 +211,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 			__set_errno (ERANGE);
 		}
 		break;
@@ -225,7 +225,7 @@ static double zero = 0.0;	/* used as const */
 		exc.retval = zero;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 			__set_errno (ERANGE);
 		}
 		break;
@@ -241,7 +241,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = -HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("y0: DOMAIN error\n", 17);
 		      }
@@ -260,7 +260,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = -HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("y0: DOMAIN error\n", 17);
 		      }
@@ -279,7 +279,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = -HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("y1: DOMAIN error\n", 17);
 		      }
@@ -298,7 +298,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = -HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("y1: DOMAIN error\n", 17);
 		      }
@@ -317,7 +317,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = -HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("yn: DOMAIN error\n", 17);
 		      }
@@ -336,7 +336,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = -HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("yn: DOMAIN error\n", 17);
 		      }
@@ -356,7 +356,7 @@ static double zero = 0.0;	/* used as const */
                   exc.retval = HUGE_VAL;
                 if (_LIB_VERSION == _POSIX_)
 			__set_errno (ERANGE);
-                else if (!__matherr(&exc)) {
+                else if (!matherr(&exc)) {
                         __set_errno (ERANGE);
 		}
 		break;
@@ -373,7 +373,7 @@ static double zero = 0.0;	/* used as const */
                   exc.retval = HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("lgamma: SING error\n", 19);
 		      }
@@ -392,7 +392,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = -HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("log: SING error\n", 16);
 		      }
@@ -411,7 +411,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = NAN;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("log: DOMAIN error\n", 18);
 		      }
@@ -431,7 +431,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = -HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("log10: SING error\n", 18);
 		      }
@@ -451,7 +451,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = NAN;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("log10: DOMAIN error\n", 20);
 		      }
@@ -467,7 +467,7 @@ static double zero = 0.0;	/* used as const */
 		exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl");
 		exc.retval = zero;
 		if (_LIB_VERSION != _SVID_) exc.retval = 1.0;
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 			(void) WRITE2("pow(0,0): DOMAIN error\n", 23);
 			__set_errno (EDOM);
 		}
@@ -489,7 +489,7 @@ static double zero = 0.0;	/* used as const */
 		}
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 			__set_errno (ERANGE);
 		}
 		break;
@@ -502,7 +502,7 @@ static double zero = 0.0;	/* used as const */
 		exc.retval =  zero;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 			__set_errno (ERANGE);
 		}
 		break;
@@ -518,7 +518,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = -HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("pow(0,neg): DOMAIN error\n", 25);
 		      }
@@ -537,7 +537,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("pow(0,neg): DOMAIN error\n", 25);
 		      }
@@ -556,7 +556,7 @@ static double zero = 0.0;	/* used as const */
 		    exc.retval = zero/zero;	/* X/Open allow NaN */
 		if (_LIB_VERSION == _POSIX_)
 		   __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("neg**non-integral: DOMAIN error\n", 32);
 		      }
@@ -576,7 +576,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = ( (x>zero) ? HUGE_VAL : -HUGE_VAL);
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 			__set_errno (ERANGE);
 		}
 		break;
@@ -593,7 +593,7 @@ static double zero = 0.0;	/* used as const */
 		  exc.retval = zero/zero;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("sqrt: DOMAIN error\n", 19);
 		      }
@@ -613,7 +613,7 @@ static double zero = 0.0;	/* used as const */
 		    exc.retval = zero/zero;
                 if (_LIB_VERSION == _POSIX_)
                   __set_errno (EDOM);
-                else if (!__matherr(&exc)) {
+                else if (!matherr(&exc)) {
                   if (_LIB_VERSION == _SVID_) {
                     (void) WRITE2("fmod:  DOMAIN error\n", 20);
                   }
@@ -631,7 +631,7 @@ static double zero = 0.0;	/* used as const */
                 exc.retval = zero/zero;
                 if (_LIB_VERSION == _POSIX_)
                   __set_errno (EDOM);
-                else if (!__matherr(&exc)) {
+                else if (!matherr(&exc)) {
                   if (_LIB_VERSION == _SVID_) {
                     (void) WRITE2("remainder: DOMAIN error\n", 24);
                   }
@@ -648,7 +648,7 @@ static double zero = 0.0;	/* used as const */
                 exc.retval = zero/zero;
                 if (_LIB_VERSION == _POSIX_)
                   __set_errno (EDOM);
-                else if (!__matherr(&exc)) {
+                else if (!matherr(&exc)) {
                   if (_LIB_VERSION == _SVID_) {
                     (void) WRITE2("acosh: DOMAIN error\n", 20);
                   }
@@ -665,7 +665,7 @@ static double zero = 0.0;	/* used as const */
                 exc.retval = zero/zero;
                 if (_LIB_VERSION == _POSIX_)
                   __set_errno (EDOM);
-                else if (!__matherr(&exc)) {
+                else if (!matherr(&exc)) {
                   if (_LIB_VERSION == _SVID_) {
                     (void) WRITE2("atanh: DOMAIN error\n", 20);
                   }
@@ -682,7 +682,7 @@ static double zero = 0.0;	/* used as const */
 		exc.retval = x/zero;	/* sign(x)*inf */
                 if (_LIB_VERSION == _POSIX_)
                   __set_errno (EDOM);
-                else if (!__matherr(&exc)) {
+                else if (!matherr(&exc)) {
                   if (_LIB_VERSION == _SVID_) {
                     (void) WRITE2("atanh: SING error\n", 18);
                   }
@@ -699,7 +699,7 @@ static double zero = 0.0;	/* used as const */
 		exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 			__set_errno (ERANGE);
 		}
 		break;
@@ -713,7 +713,7 @@ static double zero = 0.0;	/* used as const */
 		exc.retval = __copysign(zero,x);
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 			__set_errno (ERANGE);
 		}
 		break;
@@ -726,7 +726,7 @@ static double zero = 0.0;	/* used as const */
                 exc.retval = zero;
                 if (_LIB_VERSION == _POSIX_)
                         __set_errno (ERANGE);
-                else if (!__matherr(&exc)) {
+                else if (!matherr(&exc)) {
                         if (_LIB_VERSION == _SVID_) {
                                 (void) WRITE2(exc.name, 2);
                                 (void) WRITE2(": TLOSS error\n", 14);
@@ -743,7 +743,7 @@ static double zero = 0.0;	/* used as const */
                 exc.retval = zero;
                 if (_LIB_VERSION == _POSIX_)
                         __set_errno (ERANGE);
-                else if (!__matherr(&exc)) {
+                else if (!matherr(&exc)) {
                         if (_LIB_VERSION == _SVID_) {
                                 (void) WRITE2(exc.name, 2);
                                 (void) WRITE2(": TLOSS error\n", 14);
@@ -760,7 +760,7 @@ static double zero = 0.0;	/* used as const */
                 exc.retval = zero;
                 if (_LIB_VERSION == _POSIX_)
                         __set_errno (ERANGE);
-                else if (!__matherr(&exc)) {
+                else if (!matherr(&exc)) {
                         if (_LIB_VERSION == _SVID_) {
                                 (void) WRITE2(exc.name, 2);
                                 (void) WRITE2(": TLOSS error\n", 14);
@@ -777,7 +777,7 @@ static double zero = 0.0;	/* used as const */
                 exc.retval = zero;
                 if (_LIB_VERSION == _POSIX_)
                         __set_errno (ERANGE);
-                else if (!__matherr(&exc)) {
+                else if (!matherr(&exc)) {
                         if (_LIB_VERSION == _SVID_) {
                                 (void) WRITE2(exc.name, 2);
                                 (void) WRITE2(": TLOSS error\n", 14);
@@ -794,7 +794,7 @@ static double zero = 0.0;	/* used as const */
                 exc.retval = zero;
                 if (_LIB_VERSION == _POSIX_)
                         __set_errno (ERANGE);
-                else if (!__matherr(&exc)) {
+                else if (!matherr(&exc)) {
                         if (_LIB_VERSION == _SVID_) {
                                 (void) WRITE2(exc.name, 2);
                                 (void) WRITE2(": TLOSS error\n", 14);
@@ -811,7 +811,7 @@ static double zero = 0.0;	/* used as const */
                 exc.retval = zero;
                 if (_LIB_VERSION == _POSIX_)
                         __set_errno (ERANGE);
-                else if (!__matherr(&exc)) {
+                else if (!matherr(&exc)) {
                         if (_LIB_VERSION == _SVID_) {
                                 (void) WRITE2(exc.name, 2);
                                 (void) WRITE2(": TLOSS error\n", 14);
@@ -832,7 +832,7 @@ static double zero = 0.0;	/* used as const */
                   exc.retval = HUGE_VAL;
                 if (_LIB_VERSION == _POSIX_)
 		  __set_errno (ERANGE);
-                else if (!__matherr(&exc)) {
+                else if (!matherr(&exc)) {
                   __set_errno (ERANGE);
                 }
 		break;
@@ -846,10 +846,10 @@ static double zero = 0.0;	/* used as const */
                 if (_LIB_VERSION == _SVID_)
                   exc.retval = HUGE;
                 else
-                  exc.retval = HUGE_VAL;
+                  exc.retval = NAN;
 		if (_LIB_VERSION == _POSIX_)
 		  __set_errno (EDOM);
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 		  if (_LIB_VERSION == _SVID_) {
 			(void) WRITE2("gamma: SING error\n", 18);
 		      }
@@ -866,7 +866,7 @@ static double zero = 0.0;	/* used as const */
 		exc.retval = x;
 		if (_LIB_VERSION == _IEEE_ ||
 		    _LIB_VERSION == _POSIX_) exc.retval = 1.0;
-		else if (!__matherr(&exc)) {
+		else if (!matherr(&exc)) {
 			__set_errno (EDOM);
 		}
 		break;
diff --git a/sysdeps/libm-ieee754/w_gamma.c b/sysdeps/libm-ieee754/w_gamma.c
index 87a3408c3f..5c3f27a8c1 100644
--- a/sysdeps/libm-ieee754/w_gamma.c
+++ b/sysdeps/libm-ieee754/w_gamma.c
@@ -29,14 +29,14 @@ static char rcsid[] = "$NetBSD: w_gamma.c,v 1.7 1995/11/20 22:06:43 jtc Exp $";
 	double x;
 #endif
 {
-	int signgam;
         double y;
 	if (_LIB_VERSION == _SVID_)
 	  y = __ieee754_lgamma_r(x,&signgam);
 	else
 	  {
-	    y = __ieee754_gamma_r(x,&signgam);
-	    if (signgam < 0) y = -y;
+	    int local_signgam;
+	    y = __ieee754_gamma_r(x,&local_signgam);
+	    if (local_signgam < 0) y = -y;
 #ifdef _IEEE_LIBM
 	    return y;
 #else
diff --git a/sysdeps/libm-ieee754/w_gammaf.c b/sysdeps/libm-ieee754/w_gammaf.c
index ecde183824..5988e54a60 100644
--- a/sysdeps/libm-ieee754/w_gammaf.c
+++ b/sysdeps/libm-ieee754/w_gammaf.c
@@ -27,14 +27,14 @@ static char rcsid[] = "$NetBSD: w_gammaf.c,v 1.4 1995/11/20 22:06:48 jtc Exp $";
 	float x;
 #endif
 {
-	int signgam;
         float y;
 	if (_LIB_VERSION == _SVID_)
 	  y = __ieee754_lgammaf_r(x,&signgam);
 	else
 	  {
-	    y = __ieee754_gammaf_r(x,&signgam);
-	    if (signgam < 0) y = -y;
+	    int local_signgam;
+	    y = __ieee754_gammaf_r(x,&local_signgam);
+	    if (local_signgam < 0) y = -y;
 #ifdef _IEEE_LIBM
 	    return y;
 #else
diff --git a/sysdeps/libm-ieee754/w_gammal.c b/sysdeps/libm-ieee754/w_gammal.c
index 605a4167c4..0107d551b7 100644
--- a/sysdeps/libm-ieee754/w_gammal.c
+++ b/sysdeps/libm-ieee754/w_gammal.c
@@ -33,13 +33,13 @@ static char rcsid[] = "$NetBSD: $";
 #endif
 {
         long double y;
-	int signgam;
 	if (_LIB_VERSION == _SVID_)
 	  y = __ieee754_lgammal_r(x,&signgam);
 	else
 	  {
-	    y = __ieee754_gammal_r(x,&signgam);
-	    if (signgam < 0) y = -y;
+	    int local_signgam;
+	    y = __ieee754_gammal_r(x,&local_signgam);
+	    if (local_signgam < 0) y = -y;
 #ifdef _IEEE_LIBM
 	    return y;
 #else
diff --git a/sysdeps/m68k/bytesex.h b/sysdeps/m68k/bits/endian.h
index 6f985293f2..6f985293f2 100644
--- a/sysdeps/m68k/bytesex.h
+++ b/sysdeps/m68k/bits/endian.h
diff --git a/sysdeps/m68k/huge_val.h b/sysdeps/m68k/bits/huge_val.h
index c71454e9a8..822b82930b 100644
--- a/sysdeps/m68k/huge_val.h
+++ b/sysdeps/m68k/bits/huge_val.h
@@ -18,8 +18,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	   _HUGE_VAL_H
-#define	   _HUGE_VAL_H	1
+#ifndef _MATH_H
+# error "Never use <bits/huge_val.h> directly; include <math.h> instead."
+#endif
+
 
 #include <features.h>
 #include <sys/cdefs.h>
@@ -28,7 +30,7 @@
 
 #ifdef	__GNUC__
 
-#define HUGE_VAL					\
+# define HUGE_VAL					\
   (__extension__					\
    ((union { unsigned long long __l; double __d; })	\
     { __l: 0x7ff0000000000000ULL }).__d)
@@ -37,7 +39,7 @@
 
 static union { unsigned char __c[8]; double __d; } __huge_val =
   { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } };
-#define	HUGE_VAL	(__huge_val.__d)
+# define HUGE_VAL	(__huge_val.__d)
 
 #endif	/* GCC.  */
 
@@ -46,30 +48,28 @@ static union { unsigned char __c[8]; double __d; } __huge_val =
 
 #ifdef __USE_ISOC9X
 
-#ifdef __GNUC__
+# ifdef __GNUC__
 
-#define HUGE_VALF					\
+#  define HUGE_VALF					\
   (__extension__					\
    ((union { unsigned long __l; float __f; })		\
     { __l: 0x7f800000UL }).__f)
 
-#define HUGE_VALL					\
+#  define HUGE_VALL					\
   (__extension__					\
    ((union { unsigned long __l[3]; long double __ld; })	\
     { __l: { 0x7fff0000UL, 0x80000000UL, 0UL } }).__ld)
 
-#else /* not GCC */
+# else /* not GCC */
 
 static union { unsigned char __c[4]; float __f; } __huge_valf =
   { { 0x7f, 0x80, 0, 0 } };
-#define	HUGE_VALF	(__huge_valf.__f)
+#  define HUGE_VALF	(__huge_valf.__f)
 
 static union { unsigned char __c[12]; long double __ld; } __huge_vall =
   { { 0x7f, 0xff, 0, 0, 0x80, 0, 0, 0, 0, 0, 0, 0 } };
-#define	HUGE_VALL	(__huge_vall.__ld)
+#  define HUGE_VALL	(__huge_vall.__ld)
 
-#endif	/* GCC.  */
+# endif	/* GCC.  */
 
 #endif	/* __USE_ISOC9X.  */
-
-#endif	   /* huge_val.h */
diff --git a/sysdeps/m68k/jmp_buf.h b/sysdeps/m68k/bits/setjmp.h
index 96240f0d8e..96240f0d8e 100644
--- a/sysdeps/m68k/jmp_buf.h
+++ b/sysdeps/m68k/bits/setjmp.h
diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h
index 1523ddb1c6..e50f773614 100644
--- a/sysdeps/m68k/dl-machine.h
+++ b/sysdeps/m68k/dl-machine.h
@@ -227,6 +227,10 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
       switch (ELF32_R_TYPE (reloc->r_info))
 	{
 	case R_68K_COPY:
+	  if (sym == NULL)
+	    /* This can happen in trace mode if an object could not be
+	       found.  */
+	    break;
 	  if (sym->st_size > refsym->st_size
 	      || (_dl_verbose && sym->st_size < refsym->st_size))
 	    {
diff --git a/sysdeps/m68k/fpu/fenvbits.h b/sysdeps/m68k/fpu/bits/fenv.h
index b653b1aafd..ce071b93ff 100644
--- a/sysdeps/m68k/fpu/fenvbits.h
+++ b/sysdeps/m68k/fpu/bits/fenv.h
@@ -16,10 +16,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-/* This file should never be included directly.  */
+#ifndef _FENV_H
+#error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
 
-#ifndef _FENVBITS_H
-#define _FENVBITS_H	1
 
 /* Define bits representing the exception.  We use the bit positions of
    the appropriate bits in the FPSR Accrued Exception Byte.  */
@@ -76,5 +76,3 @@ fenv_t;
 /* Floating-point environment where none of the exceptions are masked.  */
 # define FE_NOMASK_ENV	((fenv_t *) -2)
 #endif
-
-#endif /* fenvbits.h */
diff --git a/sysdeps/m68k/fpu/mathbits.h b/sysdeps/m68k/fpu/bits/mathdef.h
index 049662319a..4d07176405 100644
--- a/sysdeps/m68k/fpu/mathbits.h
+++ b/sysdeps/m68k/fpu/bits/mathdef.h
@@ -16,8 +16,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _MATHBITS_H
-#define _MATHBITS_H	1
+#ifndef _MATH_H
+#error "Never use <bits/mathdef.h> directly; include <math.h> instead"
+#endif
+
 
 /* The m68k FPUs evaluate all values in the 96 bit floating-point format
    which is also available for the user as `long double'.  Therefore we
@@ -32,5 +34,3 @@ typedef long double double_t;	/* `double' expressions are evaluated as
 
 /* Define `INFINITY' as value of type `float_t'.  */
 #define INFINITY	HUGE_VALL
-
-#endif /* mathbits.h */
diff --git a/sysdeps/m68k/fpu/__math.h b/sysdeps/m68k/fpu/bits/mathinline.h
index bdeaa9efb0..bdeaa9efb0 100644
--- a/sysdeps/m68k/fpu/__math.h
+++ b/sysdeps/m68k/fpu/bits/mathinline.h
diff --git a/sysdeps/m68k/fpu/switch/__math.h b/sysdeps/m68k/fpu/switch/bits/mathinline.h
index c0f6966981..c0f6966981 100644
--- a/sysdeps/m68k/fpu/switch/__math.h
+++ b/sysdeps/m68k/fpu/switch/bits/mathinline.h
diff --git a/sysdeps/mach/libc-lock.h b/sysdeps/mach/bits/libc-lock.h
index cfd176750a..f3ce23a88c 100644
--- a/sysdeps/mach/libc-lock.h
+++ b/sysdeps/mach/bits/libc-lock.h
@@ -17,8 +17,8 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _LIBC_LOCK_H
-#define _LIBC_LOCK_H 1
+#ifndef _BITS_LIBC_LOCK_H
+#define _BITS_LIBC_LOCK_H 1
 
 #ifdef _LIBC
 #include <cthreads.h>
@@ -87,4 +87,4 @@ typedef struct __libc_lock_opaque__ __libc_lock_t;
 #define __libc_lock_unlock_recursive __libc_lock_unlock
 #define __libc_lock_lock_recursive __libc_lock_lock
 
-#endif	/* libc-lock.h */
+#endif	/* bits/libc-lock.h */
diff --git a/sysdeps/mach/hurd/alpha/sigcontext.h b/sysdeps/mach/hurd/alpha/bits/sigcontext.h
index 32e0c94f98..32e0c94f98 100644
--- a/sysdeps/mach/hurd/alpha/sigcontext.h
+++ b/sysdeps/mach/hurd/alpha/bits/sigcontext.h
diff --git a/sysdeps/mach/hurd/errnos.h b/sysdeps/mach/hurd/bits/errno.h
index beb35ecd9a..beb35ecd9a 100644
--- a/sysdeps/mach/hurd/errnos.h
+++ b/sysdeps/mach/hurd/bits/errno.h
diff --git a/sysdeps/mach/hurd/fcntlbits.h b/sysdeps/mach/hurd/bits/fcntl.h
index 9906c97eb3..4983b338ae 100644
--- a/sysdeps/mach/hurd/fcntlbits.h
+++ b/sysdeps/mach/hurd/bits/fcntl.h
@@ -17,10 +17,9 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_FCNTLBITS_H
-
-#define	_FCNTLBITS_H	1
-
+#ifndef _FCNTL_H
+#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
 
 /* File access modes.  These are understood by io servers; they can be
    passed in `dir_lookup', and are returned by `io_get_openmodes'.
@@ -174,6 +173,3 @@ struct flock
 #define	F_RDLCK	1	/* Read lock.  */
 #define	F_WRLCK	2	/* Write lock.  */
 #define	F_UNLCK	3	/* Remove lock.  */
-
-
-#endif	/* fcntlbits.h */
diff --git a/sysdeps/mach/hurd/ioctls.h b/sysdeps/mach/hurd/bits/ioctls.h
index f6bb4b4ce7..b04438bcca 100644
--- a/sysdeps/mach/hurd/ioctls.h
+++ b/sysdeps/mach/hurd/bits/ioctls.h
@@ -1,26 +1,29 @@
-/* Copyright (C) 1992, 1993, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1992, 1993, 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.  */
 
-#ifndef	_IOCTLS_H
+/*
+ * Never include this file directly; use <sys/ioctl.h> instead.
+ */
 
-#define	_IOCTLS_H	1
+#ifndef	_BITS_IOCTLS_H
+#define	_BITS_IOCTLS_H	1
 
-/* These macros are also defined in termbits.h (with numerically 
+/* These macros are also defined in <bits/termios.h> (with numerically
    identical values) but this serves to shut up cpp's complaining. */
 #ifdef MDMBUF
 #undef MDMBUF
@@ -67,7 +70,7 @@ enum __ioctl_dir
     IOC_INOUT = (IOC_IN|IOC_OUT)
   };
 
-enum __ioctl_datum { IOC_8, IOC_16, IOC_32 };
+enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 };
 
 /* Construct an ioctl from constructed type plus other fields.  */
 #define	_IOC(inout, group, num, type) \
@@ -106,7 +109,8 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32 };
 #define	_IOWR(g, n, t)	_IOC (IOC_INOUT, (g), (n), _IOT_##t)
 
 /* Construct an individual type field for TYPE.  */
-#define _IOTS(type)		(sizeof (type) >> 1)
+#define _IOTS(type)	\
+  (sizeof (type) == 8 ? IOC_64 : (sizeof (type) >> 1))
 
 /* Construct a type information field for
    a single argument of the scalar TYPE.  */
@@ -346,4 +350,4 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32 };
 #endif /* USE_OLD_TTY */
 
 
-#endif /* ioctls.h */
+#endif /* bits/ioctls.h */
diff --git a/sysdeps/mach/hurd/local_lim.h b/sysdeps/mach/hurd/bits/local_lim.h
index e26aa248cb..e26aa248cb 100644
--- a/sysdeps/mach/hurd/local_lim.h
+++ b/sysdeps/mach/hurd/bits/local_lim.h
diff --git a/sysdeps/mach/hurd/posix_opt.h b/sysdeps/mach/hurd/bits/posix_opt.h
index 045b4b6666..045b4b6666 100644
--- a/sysdeps/mach/hurd/posix_opt.h
+++ b/sysdeps/mach/hurd/bits/posix_opt.h
diff --git a/sysdeps/mach/hurd/statbuf.h b/sysdeps/mach/hurd/bits/stat.h
index a8f92cb5ed..2110a73aae 100644
--- a/sysdeps/mach/hurd/statbuf.h
+++ b/sysdeps/mach/hurd/bits/stat.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1993, 1994, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1993, 1994, 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
@@ -16,11 +16,14 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_STATBUF_H
+/*
+ * Never include this file directly; use <sys/stat.h> instead.
+ */
 
-#define	_STATBUF_H	1
+#ifndef	_BITS_STAT_H
+#define	_BITS_STAT_H	1
 
-#include <gnu/types.h>
+#include <bits/types.h>
 
 /* NOTE: The size of this structure (32 ints) is known in
    <hurd/hurd_types.defs>, since it is used in the `io_stat' RPC.  MiG
@@ -66,7 +69,9 @@ struct stat
     unsigned int st_flags;	/* User-defined flags.
 				   High 16 bits can be set only by root.  */
 
-    int st_spare[11];		/* Room for future expansion.  */
+#define _SPARE_SIZE	((sizeof (__fsid_t) == sizeof (int)) ? 12 : 11)
+    int st_spare[_SPARE_SIZE];	/* Room for future expansion.  */
+#undef _SPARE_SIZE
   };
 
 /* Encoding of the file mode.  */
@@ -128,4 +133,4 @@ struct stat
 #endif
 
 
-#endif /* statbuf.h */
+#endif /* bits/stat.h */
diff --git a/sysdeps/mach/hurd/dirstream.h b/sysdeps/mach/hurd/dirstream.h
index c13383dbd9..9eeb7d9a9e 100644
--- a/sysdeps/mach/hurd/dirstream.h
+++ b/sysdeps/mach/hurd/dirstream.h
@@ -20,7 +20,7 @@ Cambridge, MA 02139, USA.  */
 
 #define	_DIRSTREAM_H	1
 
-#include <libc-lock.h>
+#include <bits/libc-lock.h>
 
 /* Directory stream type.
 
diff --git a/sysdeps/mach/hurd/hppa/sigcontext.h b/sysdeps/mach/hurd/hppa/bits/sigcontext.h
index b616469f21..b616469f21 100644
--- a/sysdeps/mach/hurd/hppa/sigcontext.h
+++ b/sysdeps/mach/hurd/hppa/bits/sigcontext.h
diff --git a/sysdeps/mach/hurd/i386/sigcontext.h b/sysdeps/mach/hurd/i386/bits/sigcontext.h
index b742326bdb..b742326bdb 100644
--- a/sysdeps/mach/hurd/i386/sigcontext.h
+++ b/sysdeps/mach/hurd/i386/bits/sigcontext.h
diff --git a/sysdeps/mach/hurd/ioctl.c b/sysdeps/mach/hurd/ioctl.c
index 4646c42920..1a7c42aad7 100644
--- a/sysdeps/mach/hurd/ioctl.c
+++ b/sysdeps/mach/hurd/ioctl.c
@@ -39,7 +39,7 @@ __ioctl (int fd, unsigned long int request, ...)
   /* Map individual type fields to Mach IPC types.  */
   static const int mach_types[] =
     { MACH_MSG_TYPE_CHAR, MACH_MSG_TYPE_INTEGER_16, MACH_MSG_TYPE_INTEGER_32,
-      -1 };
+      MACH_MSG_TYPE_INTEGER_64 };
 #define io2mach_type(count, type) \
   ((mach_msg_type_t) { mach_types[type], typesize (type) * 8, count, 1, 0, 0 })
 
@@ -47,12 +47,14 @@ __ioctl (int fd, unsigned long int request, ...)
   unsigned int type = _IOC_TYPE (request);
 
   /* Message buffer.  */
+#define msg_align(x) \
+  (((x) + sizeof (mach_msg_type_t) - 1) & ~(sizeof (mach_msg_type_t) - 1))
   struct
     {
       mig_reply_header_t header;
       char data[3 * sizeof (mach_msg_type_t) +
-		_IOT_COUNT0 (type) * typesize (_IOT_TYPE0 (type)) +
-		_IOT_COUNT1 (type) * typesize (_IOT_TYPE1 (type)) +
+		msg_align (_IOT_COUNT0 (type) * typesize (_IOT_TYPE0 (type))) +
+		msg_align (_IOT_COUNT1 (type) * typesize (_IOT_TYPE1 (type))) +
 		_IOT_COUNT2 (type) * typesize (_IOT_TYPE2 (type))];
     } msg;
   mach_msg_header_t *const m = &msg.header.Head;
diff --git a/sysdeps/mach/hurd/jmp-unwind.c b/sysdeps/mach/hurd/jmp-unwind.c
index 2d5804c71e..7b66df3b4d 100644
--- a/sysdeps/mach/hurd/jmp-unwind.c
+++ b/sysdeps/mach/hurd/jmp-unwind.c
@@ -25,7 +25,7 @@
 
 
 #ifndef _JMPBUF_UNWINDS
- #error "sysdeps/MACHINE/jmp_buf.h fails to define _JMPBUF_UNWINDS"
+#error "<bits/setjmp.h> fails to define _JMPBUF_UNWINDS"
 #endif
 
 /* This function is called by `longjmp' (with its arguments) to restore
diff --git a/sysdeps/mach/hurd/mips/sigcontext.h b/sysdeps/mach/hurd/mips/bits/sigcontext.h
index 81d1f25f25..81d1f25f25 100644
--- a/sysdeps/mach/hurd/mips/sigcontext.h
+++ b/sysdeps/mach/hurd/mips/bits/sigcontext.h
diff --git a/sysdeps/mach/hurd/mips/dl-machine.c b/sysdeps/mach/hurd/mips/dl-machine.c
new file mode 100644
index 0000000000..18261e1115
--- /dev/null
+++ b/sysdeps/mach/hurd/mips/dl-machine.c
@@ -0,0 +1,131 @@
+/* Operating system support for run-time dynamic linker.  MIPS specific
+   stuffs on Hurd.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <hurd.h>
+#include <link.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <assert.h>
+#include <sysdep.h>
+#include <mach/mig_support.h>
+#include "../stdio-common/_itoa.h"
+#include <stdarg.h>
+#include <ctype.h>
+#include <sys/stat.h>
+
+void weak_function
+abort (void)
+{
+  _exit (127);
+}
+
+
+#include <string.h>
+#include <mach/error.h>
+#include <errorlib.h>
+
+#undef _
+#define _(x) x
+
+/* Return a string describing the errno code in ERRNUM.  */
+char * weak_function
+_strerror_internal (int errnum, char *buf, size_t buflen)
+{
+  int system;
+  int sub;
+  int code;
+  const struct error_system *es;
+  extern void __mach_error_map_compat (int *);
+
+  __mach_error_map_compat (&errnum);
+
+  system = err_get_system (errnum);
+  sub = err_get_sub (errnum);
+  code = err_get_code (errnum);
+
+  if (system > err_max_system || ! __mach_error_systems[system].bad_sub)
+    {
+      const char *unk = _("Error in unknown error system: ");
+      const size_t unklen = strlen (unk);
+      char *p = buf + buflen;
+      *--p = '\0';
+      p = _itoa (errnum, p, 16, 1);
+      return memcpy (p - unklen, unk, unklen);
+    }
+
+  es = &__mach_error_systems[system];
+
+  if (sub >= es->max_sub)
+    return (char *) es->bad_sub;
+
+  if (code >= es->subsystem[sub].max_code)
+    {
+      const char *unk = _("Unknown error ");
+      const size_t unklen = strlen (unk);
+      char *p = buf + buflen;
+      size_t len = strlen (es->subsystem[sub].subsys_name);
+      *--p = '\0';
+      p = _itoa (errnum, p, 16, 1);
+      *p-- = ' ';
+      p = memcpy (p - len, es->subsystem[sub].subsys_name, len);
+      return memcpy (p - unklen, unk, unklen);
+    }
+
+  return (char *) _(es->subsystem[sub].codes[code]);
+}
+
+/* Read the whole contents of FILE into new mmap'd space with given
+   protections.  The size of the file is returned in SIZE.  */
+void *
+_dl_sysdep_read_whole_file (const char *file, size_t *size, int prot)
+{
+  struct stat stat;
+  mach_port_t memobj_rd;
+  void *contents;
+  error_t err;
+
+  memobj_rd = __open (file, O_RDONLY, 0);
+  if (memobj_rd)
+    {
+      err = __io_stat ((file_t) memobj_rd, &stat);
+      if (err)
+	{
+	  __hurd_fail (err);
+	  contents = 0;
+	}
+      else
+	{
+	  /* Map a copy of the file contents.  */
+	  contents = __mmap (0, stat.st_size, prot, MAP_COPY, memobj_rd, 0);
+	  if (contents == (void *)-1)
+	    contents = 0;
+	  else
+	    *size = stat.st_size;
+	}
+
+      __mach_port_deallocate (__mach_task_self (), memobj_rd);
+    }
+  else
+    contents = 0;
+
+  return contents;
+}
diff --git a/sysdeps/mach/hurd/mips/exc2signal.c b/sysdeps/mach/hurd/mips/exc2signal.c
index f907c89cf0..235b2e2947 100644
--- a/sysdeps/mach/hurd/mips/exc2signal.c
+++ b/sysdeps/mach/hurd/mips/exc2signal.c
@@ -1,21 +1,21 @@
 /* Translate Mach exception codes into signal numbers.  MIPS version.
-Copyright (C) 1991, 1992, 1994, 1995 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is 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 <hurd.h>
 #include <hurd/signal.h>
@@ -25,56 +25,55 @@ Cambridge, MA 02139, USA.  */
    into a signal number and signal subcode.  */
 
 void
-_hurd_exception2signal (int exception, int code, int subcode,
-			int *signo, long int *sigcode, int *error)
+_hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
 {
-  *error = 0;
+  detail->error = 0;
 
-  switch (exception)
+  switch (detail->exc)
     {
     default:
       *signo = SIGIOT;
-      *sigcode = exception;
+      detail->code = detail->exc;
       break;
       
     case EXC_BAD_ACCESS:
-      if (code == KERN_PROTECTION_FAILURE)
+      if (detail->exc_code == KERN_PROTECTION_FAILURE)
 	*signo = SIGSEGV;
       else
 	*signo = SIGBUS;
-      *sigcode = subcode;
-      *error = code;
+      detail->code = detail->exc_subcode;
+      detail->error = detail->exc_code;
       break;
 
     case EXC_BAD_INSTRUCTION:
       *signo = SIGILL;
-      if (code == EXC_MIPS_II)
-	*sigcode = code;
+      if (detail->exc_code == EXC_MIPS_II)
+	detail->code = detail->exc_subcode;
       else
-	*sigcode = 0;
+	detail->code = 0;
       break;
       
     case EXC_ARITHMETIC:
-      switch (code)
+      switch (detail->exc_code)
 	{
 	case EXC_MIPS_OV:	/* integer overflow */
 	  *signo = SIGFPE;
-	  *sigcode = EXC_MIPS_FLT_OVERFLOW;
+	  detail->code = detail->exc_subcode;
 	  break;
 
 	default:
 	  *signo = SIGFPE;
-	  *sigcode = 0;
+	  detail->code = 0;
 	  break;
 
 	case EXC_MIPS_INT:
 	  /* Subcode is the fp_status word saved by the hardware.
 	     Give an error code corresponding to the first bit set.  */
-	  if (subcode == EXC_MIPS_FLT_UNIMP)
+	  if (detail->exc_subcode == EXC_MIPS_FLT_UNIMP)
 	    *signo = SIGILL;
 	  else
 	    *signo = SIGFPE;
-	  *sigcode = subcode;
+	  detail->code = detail->exc_subcode;
 	  break;
 	}
       break;
@@ -82,17 +81,17 @@ _hurd_exception2signal (int exception, int code, int subcode,
     case EXC_EMULATION:		
       /* 3.0 doesn't give this one, why, I don't know.  */
       *signo = SIGEMT;
-      *sigcode = 0;
+      detail->code = 0;
       break;
 
     case EXC_SOFTWARE:
       *signo = SIGEMT;
-      *sigcode = 0;
+      detail->code = 0;
       break;
       
     case EXC_BREAKPOINT:
       *signo = SIGTRAP;
-      *sigcode = code;
+      detail->code = 0;
       break;
     }
 }
diff --git a/sysdeps/mach/hurd/mips/init-fault.c b/sysdeps/mach/hurd/mips/init-fault.c
new file mode 100644
index 0000000000..619ef996a9
--- /dev/null
+++ b/sysdeps/mach/hurd/mips/init-fault.c
@@ -0,0 +1,41 @@
+/* Set up a thread_state for proc_handle_exceptions.  MIPS version.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <hurd/signal.h>
+#include <mach/thread_status.h>
+#include <string.h>
+#include <setjmp.h>
+
+extern jmp_buf _hurd_sigthread_fault_env;
+
+static char fault_stack[32];
+static volatile void
+faulted (void)
+{
+  __longjmp (_hurd_sigthread_fault_env, 1);
+}
+
+void
+_hurd_initialize_fault_recovery_state (void *state)
+{
+  struct mips_thread_state *ts = state;
+  memset (ts, 0, sizeof (*ts));
+  ts->r29 = (int) &fault_stack[sizeof (fault_stack)];
+  ts->pc = (int) &faulted;
+}
diff --git a/sysdeps/mach/hurd/mips/init-first.c b/sysdeps/mach/hurd/mips/init-first.c
new file mode 100644
index 0000000000..b057aeb097
--- /dev/null
+++ b/sysdeps/mach/hurd/mips/init-first.c
@@ -0,0 +1,407 @@
+/* Initialization code run first thing by the ELF startup code.  For Mips/Hurd.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <hurd.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include "hurdstartup.h"
+#include "set-hooks.h"
+#include "hurdmalloc.h"		/* XXX */
+
+extern void __mach_init (void);
+extern void __libc_init (int, char **, char **);
+extern void __getopt_clean_environment (void);
+extern void __libc_global_ctors (void);
+
+unsigned int __hurd_threadvar_max;
+unsigned long int __hurd_threadvar_stack_offset;
+unsigned long int __hurd_threadvar_stack_mask;
+
+int __libc_multiple_libcs = 1;
+
+int __libc_argc;
+char **__libc_argv;
+
+/* We often need the PID.  Cache this value.  */
+pid_t __libc_pid;
+
+void *(*_cthread_init_routine) (void); /* Returns new SP to use.  */
+void (*_cthread_exit_routine) (int status) __attribute__ ((__noreturn__));
+
+
+/* Things that want to be run before _hurd_init or much anything else.
+   Importantly, these are called before anything tries to use malloc.  */
+DEFINE_HOOK (_hurd_preinit_hook, (void));
+
+static void
+init1 (int argc, char *arg0, ...)
+{
+  char **argv = &arg0;
+  char **envp = &argv[argc + 1];
+  struct hurd_startup_data *d;
+
+  __libc_argc = argc;
+  __libc_argv = argv;
+  __environ = envp;
+  while (*envp)
+    ++envp;
+  d = (void *) ++envp;
+
+  /* If we are the bootstrap task started by the kernel,
+     then after the environment pointers there is no Hurd
+     data block; the argument strings start there.  */
+  if ((void *) d != argv[0])
+    {
+      _hurd_init_dtable = d->dtable;
+      _hurd_init_dtablesize = d->dtablesize;
+
+      {
+	/* Check if the stack we are now on is different from
+	   the one described by _hurd_stack_{base,size}.  */
+
+	char dummy;
+	const vm_address_t newsp = (vm_address_t) &dummy;
+
+	if (d->stack_size != 0 && (newsp < d->stack_base ||
+				   newsp - d->stack_base > d->stack_size))
+	  /* The new stack pointer does not intersect with the
+	     stack the exec server set up for us, so free that stack.  */
+	  __vm_deallocate (__mach_task_self (), d->stack_base, d->stack_size);
+      }
+    }
+
+  if (__hurd_threadvar_stack_mask == 0)
+    {
+      /* We are not using cthreads, so we will have just a single allocated
+	 area for the per-thread variables of the main user thread.  */
+      unsigned long int i;
+      __hurd_threadvar_stack_offset
+	= (unsigned long int) malloc (__hurd_threadvar_max *
+				      sizeof (unsigned long int));
+      if (__hurd_threadvar_stack_offset == 0)
+	__libc_fatal ("Can't allocate single-threaded per-thread variables.");
+      for (i = 0; i < __hurd_threadvar_max; ++i)
+	((unsigned long int *) __hurd_threadvar_stack_offset)[i] = 0;
+    }
+
+  if ((void *) d != argv[0] && (d->portarray || d->intarray))
+    /* Initialize library data structures, start signal processing, etc.  */
+    _hurd_init (d->flags, argv,
+		d->portarray, d->portarraysize,
+		d->intarray, d->intarraysize);
+
+  __libc_init (argc, argv, __environ);
+
+  /* This is a hack to make the special getopt in GNU libc working.  */
+  __getopt_clean_environment ();
+
+#ifdef PIC
+  __libc_global_ctors ();
+#endif
+
+  (void) &init1;
+}
+
+static void *
+__init (int *data)
+{
+  int argc = *data;
+  char **argv = (void *) (data + 1);
+  char **envp = &argv[argc + 1];
+  struct hurd_startup_data *d;
+
+  __environ = envp;
+  while (*envp)
+    ++envp;
+  d = (void *) ++envp;
+
+  /* The user might have defined a value for this, to get more variables.
+     Otherwise it will be zero on startup.  We must make sure it is set
+     properly before before cthreads initialization, so cthreads can know
+     how much space to leave for thread variables.  */
+  if (__hurd_threadvar_max < _HURD_THREADVAR_MAX)
+    __hurd_threadvar_max = _HURD_THREADVAR_MAX;
+
+
+  /* After possibly switching stacks, call `init1' (above) with the user
+     code as the return address, and the argument data immediately above
+     that on the stack.  */
+
+  if (_cthread_init_routine)
+    {
+      /* Initialize cthreads, which will allocate us a new stack to run on.  */
+      void *newsp = (*_cthread_init_routine) ();
+      struct hurd_startup_data *od;
+
+      /* Copy the argdata from the old stack to the new one.  */
+      newsp = memcpy (newsp - ((char *) &d[1] - (char *) data), data,
+		      (char *) d - (char *) data);
+
+      /* Set up the Hurd startup data block immediately following
+	 the argument and environment pointers on the new stack.  */
+      od = (newsp + ((char *) d - (char *) data));
+      if ((void *) argv[0] == d)
+	/* We were started up by the kernel with arguments on the stack.
+	   There is no Hurd startup data, so zero the block.  */
+	memset (od, 0, sizeof *od);
+      else
+	/* Copy the Hurd startup data block to the new stack.  */
+	*od = *d;
+
+      /* Push the user code address on the top of the new stack.  It will
+	 be the return address for `init1'; we will jump there with NEWSP
+	 as the stack pointer.  */
+      return newsp;
+    } 
+
+  /* The argument data is just above the stack frame we will unwind by
+     returning.  */
+  return (void *) data;
+
+  (void) &__init;
+}  
+
+#ifdef PIC
+/* This function is called to initialize the shared C library.
+   It is called just before the user _start code from mips/elf/start.S,
+   with the stack set up as that code gets it.  */
+
+/* NOTE!  The linker notices the magical name `_init' and sets the DT_INIT
+   pointer in the dynamic section based solely on that.  It is convention
+   for this function to be in the `.init' section, but the symbol name is
+   the only thing that really matters!!  */
+/*void _init (int argc, ...) __attribute__ ((unused, section (".init")));*/
+
+#if __mips64
+asm ("\
+	.section .init,\"ax\",@progbits\n\
+	.align 3\n\
+	.globl _init\n\
+	.type _init,@function\n\
+	.ent _init\n\
+_init:\n\
+	.set noreorder\n\
+	.cpload $25\n\
+	.set reorder\n\
+	dsubu $29, 8*8\n\
+	.cprestore 6*8\n\
+	sd $16, 4*8($29)\n\
+	sd $31, 5*8($29)\n\
+	jal preinit\n\
+	sd $28, 6*8($29)\n\
+	move $16, $29 # Save the old stack pointer to s0 ($16)\n\
+	daddu $4, $29, 4*8
+	jal __init\n\
+	# Restore saved registers from the old stack.\n\
+	ld $28, 6*8($16)\n\
+	ld $31, 5*8($16)\n\
+	ld $16, 4*8($16)\n\
+	move $29, $2 # set new sp to SP\n\
+call_init1:\n\
+	ld $4, 0($29)\n\
+	ld $5, 1*8($29)\n\
+	ld $6, 2*8($29)\n\
+	ld $7, 3*8($29)\n\
+	dla $25, init1\n\
+	jr $25\n\
+	.end _init\n\
+	.text\n\
+");
+#else
+asm ("\
+	.section .init,\"ax\",@progbits\n\
+	.align 2\n\
+	.globl _init\n\
+	.type _init,@function\n\
+	.ent _init\n\
+_init:\n\
+	.set noreorder\n\
+	.cpload $25\n\
+	.set reorder\n\
+	subu $29, 32\n\
+	.cprestore 24\n\
+	sw $16, 16($29)\n\
+	sw $31, 20($29)\n\
+	jal preinit\n\
+	sw $28, 24($29)\n\
+	move $16, $29 # Save the old stack pointer to s0 ($16)\n\
+	addu $4, $29, 32
+	jal __init\n\
+	# Restore saved registers from the old stack.\n\
+	lw $28, 24($16)\n\
+	lw $31, 20($16)\n\
+	lw $16, 16($16)\n\
+	move $29, $2 # set new sp to SP\n\
+call_init1:\n\
+	lw $4, 0($29)\n\
+	lw $5, 4($29)\n\
+	lw $6, 8($29)\n\
+	lw $7, 12($29)\n\
+	la $25, init1\n\
+	jr $25\n\
+	.end _init\n\
+	.text\n\
+");
+#endif
+
+static void
+preinit (void)
+{
+  /* Initialize data structures so we can do RPCs.  */
+  __mach_init ();
+
+  RUN_HOOK (_hurd_preinit_hook, ());
+
+  (void) &preinit;
+}
+
+void __libc_init_first (int argc, ...)
+{
+}
+#endif
+
+#ifndef PIC
+/* An assembler code wrapping c function __init.  */
+#ifdef __mips64
+asm ("\
+	.text\n\
+	.align 3\n\
+init:\n\
+	dsubu $29, 8*8\n\
+	sd $16, 4*8($29)\n\
+	sd $31, 5*8($29)\n\
+	move $16, $29\n\
+	jal __init\n\
+	ld $31, 5*8($16)\n\
+	ld $16, 4*8($16)\n\
+	move $29, $2 # set new sp to SP\n\
+call_init1:\n\
+	ld $4, 0($29)\n\
+	ld $5, 1*8($29)\n\
+	ld $6, 2*8($29)\n\
+	ld $7, 3*8($29)\n\
+	dla $25, init1\n\
+	jr $25\n\
+");
+#else
+asm ("\
+	.text\n\
+	.align 2\n\
+init:\n\
+	subu $29, 32\n\
+	sw $16, 16($29)\n\
+	sw $31, 20($29)\n\
+	move $16, $29\n\
+	jal __init\n\
+	lw $31, 20($16)\n\
+	lw $16, 16($16)\n\
+	move $29, $2 # set new sp to SP\n\
+call_init1:\n\
+	lw $4, 0($29)\n\
+	lw $5, 4($29)\n\
+	lw $6, 8($29)\n\
+	lw $7, 12($29)\n\
+	la $25, init1\n\
+	jr $25\n\
+");
+#endif
+
+/* An assembler code wrapping c function ___libc_init_first.
+   ___libc_init_first does an RPC call to flush cache to put doinit
+   function on the stack, so we should call __mach_init first in
+   this wrap. */
+#ifdef __mips64
+asm ("\
+	.text\n\
+	.align 3\n\
+	.globl __libc_init_first\n\
+__libc_init_first:\n\
+	dsubu $29, 8\n\
+	sd $31, 0($29)
+	jal __mach_init\n\
+	ld $4, 0($29)
+	ld $5, 1*8($29)
+	ld $6, 2*8($29)
+	ld $7, 3*8($29)
+	j ___libc_init_first\n\
+");
+#else
+asm ("\
+	.text\n\
+	.align 2\n\
+	.globl __libc_init_first\n\
+__libc_init_first:\n\
+	subu $29, 4\n\
+	sw $31, 0($29)
+	jal __mach_init\n\
+	lw $4, 0($29)
+	lw $5, 4($29)
+	lw $6, 8($29)
+	lw $7, 12($29)
+	j ___libc_init_first\n\
+");
+#endif
+
+static void
+___libc_init_first (int return_addr, int argc, ...)
+{
+  void doinit (int *data)
+    {
+#if 0
+      /* This function gets called with the argument data at TOS.  */
+      void doinit1 (int argc, ...)
+	{
+	  init (&argc);
+	}
+#endif
+      extern void init (int *data);
+
+      /* Push the user return address after the argument data, and then
+	 jump to `doinit1' (above), so it is as if __libc_init_first's
+	 caller had called `init' with the argument data already on the
+	 stack.  */
+      *--data = return_addr;
+
+#ifdef __mips64
+      asm volatile ("ld $31, 0(%0)\n" /* Load the original return address.  */
+		    "daddu $29, %0, 8\n" /* Switch to new outermost stack.  */
+		    "move $4, $29\n"
+		    "jr %1" : : "r" (data), "r" (&init));
+#else
+      asm volatile ("lw $31, 0(%0)\n" /* Load the original return address.  */
+		    "addu $29, %0, 4\n" /* Switch to new outermost stack.  */
+		    "move $4, $29\n"
+		    "jr %1" : : "r" (data), "r" (&init));
+#endif
+      /* NOTREACHED */
+    }
+
+#if 0
+  /* Initialize data structures so we can do RPCs.  */
+  __mach_init ();
+#endif
+
+  RUN_HOOK (_hurd_preinit_hook, ());
+  
+  _hurd_startup ((void **) &argc, &doinit);
+
+  (void) &___libc_init_first;
+}
+#endif
diff --git a/sysdeps/mach/hurd/mips/intr-msg.h b/sysdeps/mach/hurd/mips/intr-msg.h
new file mode 100644
index 0000000000..7d155f63f3
--- /dev/null
+++ b/sysdeps/mach/hurd/mips/intr-msg.h
@@ -0,0 +1,127 @@
+/* Machine-dependent details of interruptible RPC messaging.  Mips version.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+
+#ifdef __mips64
+#define INTR_MSG_TRAP(msg, option, send_size, rcv_size, rcv_name, timeout, notify) \
+({									      \
+  error_t err;								      \
+  mach_port_t __rcv_name = (rcv_name);					      \
+  mach_msg_timeout_t __timeout = (timeout);	       			      \
+  mach_port_t __notify = (notify);					      \
+  asm (".globl _hurd_intr_rpc_msg_do_trap\n" 				      \
+       ".globl _hurd_intr_rpc_msg_in_trap\n"				      \
+       "				move $4, %1\n"			      \
+       "				move $5, %2\n"			      \
+       "				move $6, %3\n"			      \
+       "				move $7, %4\n"			      \
+       "				move $8, %5\n"			      \
+       "				move $9, %6\n"			      \
+       "				move $10, %7\n"			      \
+       "				dli $2, -25\n"			      \
+       "_hurd_intr_rpc_msg_do_trap:	syscall\n"			      \
+       "_hurd_intr_rpc_msg_in_trap:	move %0, $2\n"			      \
+       : "=r" (err)							      \
+       : "r" (msg), "r" (option), "r" (send_size), "r" (rcv_size),	      \
+         "r" (__rcv_name), "r" (__timeout), "r" (__notify)		      \
+       : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10",	      \
+         "$11", "$12", "$13", "$14", "$15", "$24", "$25", "$28");	      \
+  err;									      \
+})
+#else
+#define INTR_MSG_TRAP(msg, option, send_size, rcv_size, rcv_name, timeout, notify) \
+({									      \
+  error_t err;								      \
+  mach_port_t __rcv_name = (rcv_name);					      \
+  mach_msg_timeout_t __timeout = (timeout);	       			      \
+  mach_port_t __notify = (notify);					      \
+  asm (".globl _hurd_intr_rpc_msg_do_trap\n" 				      \
+       ".globl _hurd_intr_rpc_msg_in_trap\n"				      \
+       "				move $4, %1\n"			      \
+       "				move $5, %2\n"			      \
+       "				move $6, %3\n"			      \
+       "				move $7, %4\n"			      \
+       "				move $8, %5\n"			      \
+       "				move $9, %6\n"			      \
+       "				move $10, %7\n"			      \
+       "				li $2, -25\n"			      \
+       "_hurd_intr_rpc_msg_do_trap:	syscall\n"			      \
+       "_hurd_intr_rpc_msg_in_trap:	move %0, $2\n"			      \
+       : "=r" (err)							      \
+       : "r" (msg), "r" (option), "r" (send_size), "r" (rcv_size),	      \
+         "r" (__rcv_name), "r" (__timeout), "r" (__notify)		      \
+       : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10",	      \
+         "$11", "$12", "$13", "$14", "$15", "$24", "$25", "$28");	      \
+  err;									      \
+})
+#endif
+
+static inline void
+INTR_MSG_BACK_OUT (struct mips_thread_state *state)
+{
+  return;
+}
+
+#include "hurdfault.h"
+
+static inline int
+SYSCALL_EXAMINE (struct mips_thread_state *state, int *callno)
+{
+  u_int32_t *p = (void *) (state->pc - 4);
+  int result;
+  if (_hurdsig_catch_memory_fault (p))
+    return 0;
+  if (result = (*p == 0x0000000c))
+    /* The PC is just after a `syscall' instruction.
+       This is a system call in progress; v0($2) holds the call number.  */
+    *callno = state->r2;
+  _hurdsig_end_catch_fault ();
+  return result;
+}
+
+
+struct mach_msg_trap_args
+  {
+    /* This is the order of arguments to mach_msg_trap.  */
+    mach_msg_header_t *msg;
+    mach_msg_option_t option;
+    mach_msg_size_t send_size;
+    mach_msg_size_t rcv_size;
+    mach_port_t rcv_name;
+    mach_msg_timeout_t timeout;
+    mach_port_t notify;
+  };
+
+
+static inline mach_port_t
+MSG_EXAMINE (struct mips_thread_state *state, int *msgid)
+{
+  mach_msg_header_t *msg;
+  mach_port_t send_port;
+
+  msg = (mach_msg_header_t *) state->r4;
+
+  if (_hurdsig_catch_memory_fault (msg))
+    return MACH_PORT_NULL;
+  send_port = msg->msgh_remote_port;
+  *msgid = msg->msgh_id;
+  _hurdsig_end_catch_fault ();
+
+  return send_port;
+}
diff --git a/sysdeps/mach/hurd/mips/longjmp-ctx.c b/sysdeps/mach/hurd/mips/longjmp-ctx.c
new file mode 100644
index 0000000000..df04900e78
--- /dev/null
+++ b/sysdeps/mach/hurd/mips/longjmp-ctx.c
@@ -0,0 +1,41 @@
+/* Perform a `longjmp' on a `struct sigcontext'.  MIPS version.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <setjmp.h>
+#include <hurd/signal.h>
+#include <string.h>
+
+void
+_hurd_longjmp_sigcontext (struct sigcontext *scp, jmp_buf env, int retval)
+{
+  scp->sc_gpr[16] = env[0].__regs[0];
+  scp->sc_gpr[17] = env[0].__regs[1];
+  scp->sc_gpr[18] = env[0].__regs[2];
+  scp->sc_gpr[19] = env[0].__regs[3];
+  scp->sc_gpr[20] = env[0].__regs[4];
+  scp->sc_gpr[21] = env[0].__regs[5];
+  scp->sc_gpr[22] = env[0].__regs[6];
+  scp->sc_gpr[23] = env[0].__regs[7];
+
+  scp->sc_gpr[28] = (int) env[0].__gp;
+  scp->sc_fp = (int) env[0].__fp;
+  scp->sc_sp = (int) env[0].__sp;
+  scp->sc_pc = (int) env[0].__pc;
+  scp->sc_gpr[2] = retval ?: 1;
+}
diff --git a/sysdeps/mach/hurd/mips/longjmp-ts.c b/sysdeps/mach/hurd/mips/longjmp-ts.c
index 980a2ceb94..ea62bb1bf3 100644
--- a/sysdeps/mach/hurd/mips/longjmp-ts.c
+++ b/sysdeps/mach/hurd/mips/longjmp-ts.c
@@ -1,21 +1,21 @@
 /* Perform a `longjmp' on a Mach thread_state.  MIPS version.
-Copyright (C) 1991, 1994 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) 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 <hurd/signal.h>
 #include <setjmp.h>
diff --git a/sysdeps/mach/hurd/mips/sigreturn.c b/sysdeps/mach/hurd/mips/sigreturn.c
index 7396a8bb22..fe38fac1df 100644
--- a/sysdeps/mach/hurd/mips/sigreturn.c
+++ b/sysdeps/mach/hurd/mips/sigreturn.c
@@ -1,30 +1,32 @@
-/* Copyright (C) 1991, 1992, 1994, 1995 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is 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 <hurd.h>
 #include <hurd/signal.h>
 #include <hurd/threadvar.h>
 #include <stdlib.h>
+#include <mach/mips/mips_instruction.h>
 
 int
 __sigreturn (struct sigcontext *scp)
 {
   struct hurd_sigstate *ss;
+  struct hurd_userlink *link = (void *) &scp[1];
   mach_port_t *reply_port;
 
   if (scp == NULL || (scp->sc_mask & _SIG_CANT_MASK))
@@ -36,6 +38,11 @@ __sigreturn (struct sigcontext *scp)
   ss = _hurd_self_sigstate ();
   __spin_lock (&ss->lock);
 
+  /* Remove the link on the `active resources' chain added by
+     _hurd_setup_sighandler.  Its purpose was to make sure
+     that we got called; now we have, it is done.  */
+  _hurd_userlink_unlink (link);
+
   /* Restore the set of blocked signals, and the intr_port slot.  */
   ss->blocked = scp->sc_mask;
   ss->intr_port = scp->sc_intr_port;
@@ -48,15 +55,11 @@ __sigreturn (struct sigcontext *scp)
 	 the signal thread will notice it if it runs another handler, and
 	 arrange to have us called over again in the new reality.  */
       ss->context = scp;
-      /* Clear the intr_port slot, since we are not in fact doing
-	 an interruptible RPC right now.  If SS->intr_port is not null,
-	 the SCP context is doing an interruptible RPC, but the signal
-	 thread will examine us while we are blocked in the sig_post RPC.  */
-      ss->intr_port = MACH_PORT_NULL;
       __spin_unlock (&ss->lock);
-      __msg_sig_post (_hurd_msgport, 0, __mach_task_self ());
+      __msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ());
       /* If a pending signal was handled, sig_post never returned.  */
       __spin_lock (&ss->lock);
+      ss->context = NULL;
     }
 
   if (scp->sc_onstack)
@@ -73,7 +76,17 @@ __sigreturn (struct sigcontext *scp)
   reply_port =
     (mach_port_t *) __hurd_threadvar_location (_HURD_THREADVAR_MIG_REPLY);
   if (*reply_port)
-    __mach_port_destroy (__mach_task_self (), *reply_port);
+    {
+      mach_port_t port = *reply_port;
+
+      /* Assigning MACH_PORT_DEAD here tells libc's mig_get_reply_port not to
+	 get another reply port, but avoids mig_dealloc_reply_port trying to
+	 deallocate it after the receive fails (which it will, because the
+	 reply port will be bogus, whether we do this or not).  */
+      *reply_port = MACH_PORT_DEAD;
+
+      __mach_port_destroy (__mach_task_self (), port);
+    }
   *reply_port = scp->sc_reply_port;
 
   if (scp->sc_coproc_used & SC_COPROC_USE_FPU)
@@ -83,30 +96,70 @@ __sigreturn (struct sigcontext *scp)
   asm volatile ("l.d $f" #n ",%0" : : "m" (scp->sc_fpr[n]))
 
       /* Restore floating-point registers. */
+#ifdef __mips64
       restore_fpr (0);
+      restore_fpr (1);
       restore_fpr (2);
+      restore_fpr (3);
       restore_fpr (4);
+      restore_fpr (5);
       restore_fpr (6);
+      restore_fpr (7);
       restore_fpr (8);
+      restore_fpr (9);
       restore_fpr (10);
+      restore_fpr (11);
       restore_fpr (12);
+      restore_fpr (13);
       restore_fpr (14);
+      restore_fpr (15);
       restore_fpr (16);
+      restore_fpr (17);
       restore_fpr (18);
+      restore_fpr (19);
       restore_fpr (20);
+      restore_fpr (21);
       restore_fpr (22);
+      restore_fpr (23);
       restore_fpr (24);
+      restore_fpr (25);
       restore_fpr (26);
+      restore_fpr (27);
       restore_fpr (28);
+      restore_fpr (29);
       restore_fpr (30);
+      restore_fpr (31);
+#else
+      restore_fpr (0);
+      restore_fpr (2);
+      restore_fpr (4);
+      restore_fpr (6);
+      restore_fpr (8);
+      restore_fpr (10);
+      restore_fpr (12);
+      restore_fpr (14);
+      restore_fpr (16);
+      restore_fpr (18);
+      restore_fpr (20);
+      restore_fpr (22);
+      restore_fpr (24);
+      restore_fpr (26);
+      restore_fpr (28);
+      restore_fpr (30);
+#endif
 
       /* Restore the floating-point control/status register ($f31).  */
       asm volatile ("ctc1 %0,$f31" : : "r" (scp->sc_fpcsr));
     }
 
   /* Load all the registers from the sigcontext.  */
+#ifdef __mips64
+#define restore_gpr(n) \
+  asm volatile ("ld $" #n ",%0" : : "m" (scpreg->sc_gpr[n - 1]))
+#else
 #define restore_gpr(n) \
   asm volatile ("lw $" #n ",%0" : : "m" (scpreg->sc_gpr[n - 1]))
+#endif
 
   {
     register const struct sigcontext *const scpreg asm ("$1") = scp;
@@ -157,9 +210,10 @@ __sigreturn (struct sigcontext *scp)
     at = &scpreg->sc_pc;
     /* This is an emulated instruction that will find at the address in $1
        two words: the PC value to restore, and the $1 value to restore.  */
-    asm volatile (".word op_sigreturn");
-
+    asm volatile (".word %0" : : "i" (op_sigreturn));
     asm volatile (".set reorder; .set at;");
+    /* NOTREACHED */
+    return at;		/* To prevent optimization.  */
   }
 
   /* NOTREACHED */
diff --git a/sysdeps/mach/hurd/mips/trampoline.c b/sysdeps/mach/hurd/mips/trampoline.c
index 03e3d1da6f..fbb7df508f 100644
--- a/sysdeps/mach/hurd/mips/trampoline.c
+++ b/sysdeps/mach/hurd/mips/trampoline.c
@@ -1,56 +1,58 @@
 /* Set thread_state for sighandler, and sigcontext to recover.  MIPS version.
-Copyright (C) 1994, 1995 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is 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 <hurd/signal.h>
+#include <hurd/userlink.h>
 #include "thread_state.h"
-
-
-struct mach_msg_trap_args
-  {
-    /* This is the order of arguments to mach_msg_trap.  */
-    mach_msg_header_t *msg;
-    mach_msg_option_t option;
-    mach_msg_size_t send_size;
-    mach_msg_size_t rcv_size;
-    mach_port_t rcv_name;
-    mach_msg_timeout_t timeout;
-    mach_port_t notify;
-  };
+#include <assert.h>
+#include <errno.h>
+#include "hurdfault.h"
+#include "intr-msg.h"
 
 
 struct sigcontext *
 _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
-			int signo, long int sigcode,
-			int rpc_wait,
+			int signo, struct hurd_signal_detail *detail,
+			volatile int rpc_wait,
 			struct machine_thread_all_state *state)
 {
-
-  __label__ trampoline, rpc_wait_trampoline;
-  void *sigsp;
+  __label__ trampoline, rpc_wait_trampoline, firewall;
+  void *volatile sigsp;
   struct sigcontext *scp;
+  struct 
+    {
+      int signo;
+      long int sigcode;
+      struct sigcontext *scp;	/* Points to ctx, below.  */
+      void *sigreturn_addr;
+      void *sigreturn_returns_here;
+      struct sigcontext *return_scp; /* Same; arg to sigreturn.  */
+      struct sigcontext ctx;
+      struct hurd_userlink link;
+    } *stackframe;
 
   if (ss->context)
     {
       /* We have a previous sigcontext that sigreturn was about
 	 to restore when another signal arrived.  We will just base
 	 our setup on that.  */
-      if (! setjmp (_hurd_sigthread_fault_env))
+      if (! _hurdsig_catch_memory_fault (ss->context))
 	{
 	  memcpy (&state->basic, &ss->context->sc_mips_thread_state,
 		  sizeof (state->basic));
@@ -63,24 +65,17 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
 		      sizeof (state->fpu));
 	      state->set |= (1 << MIPS_FLOAT_STATE);
 	    }
-	  assert (! rpc_wait);
-	  /* The intr_port slot was cleared before sigreturn sent us the
-	     sig_post that made us notice this pending signal, so
-	     _hurd_internal_post_signal wouldn't do interrupt_operation.
-	     After we return, our caller will set SCP->sc_intr_port (in the
-	     new context) from SS->intr_port and clear SS->intr_port.  Now
-	     that we are restoring this old context recorded by sigreturn,
-	     we want to restore its intr_port too; so store it in
-	     SS->intr_port now, so it will end up in SCP->sc_intr_port
-	     later.  */
-	  ss->intr_port = ss->context->sc_intr_port;
 	}
-      /* If the sigreturn context was bogus, just ignore it.  */
-      ss->context = NULL;
     }
-  else if (! machine_get_basic_state (ss->thread, state))
+
+  if (! machine_get_basic_state (ss->thread, state))
     return NULL;
 
+  /* Save the original SP in the gratuitous s0 ($16) slot.
+     We may need to reset the SP (the `r29' slot) to avoid clobbering an
+     interrupted RPC frame.  */
+  state->basic.r16 = state->basic.r29;
+
   if ((ss->actions[signo].sa_flags & SA_ONSTACK) &&
       !(ss->sigaltstack.ss_flags & (SA_DISABLE|SA_ONSTACK)))
     {
@@ -92,13 +87,46 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
   else
     sigsp = (char *) state->basic.r29;
 
-  /* Set up the sigcontext structure on the stack.  This is all the stack
-     needs, since the args are passed in registers (below).  */
-  sigsp -= sizeof (*scp);
-  scp = sigsp;
+  /* Push the arguments to call `trampoline' on the stack.  */
+  sigsp -= sizeof (*stackframe);
+  stackframe = sigsp;
 
-  if (! setjmp (_hurd_sigthread_fault_env))
+  if (_hurdsig_catch_memory_fault (stackframe))
     {
+      /* We got a fault trying to write the stack frame.
+	 We cannot set up the signal handler.
+	 Returning NULL tells our caller, who will nuke us with a SIGILL.  */
+      return NULL;
+    }
+  else
+    {
+      int ok;
+
+      extern void _hurdsig_longjmp_from_handler (void *, jmp_buf, int);
+
+      /* Add a link to the thread's active-resources list.  We mark this as
+	 the only user of the "resource", so the cleanup function will be
+	 called by any longjmp which is unwinding past the signal frame.
+	 The cleanup function (in sigunwind.c) will make sure that all the
+	 appropriate cleanups done by sigreturn are taken care of.  */
+      stackframe->link.cleanup = &_hurdsig_longjmp_from_handler;
+      stackframe->link.cleanup_data = &stackframe->ctx;
+      stackframe->link.resource.next = NULL;
+      stackframe->link.resource.prevp = NULL;
+      stackframe->link.thread.next = ss->active_resources;
+      stackframe->link.thread.prevp = &ss->active_resources;
+      if (stackframe->link.thread.next)
+	stackframe->link.thread.next->thread.prevp
+	  = &stackframe->link.thread.next;
+      ss->active_resources = &stackframe->link;
+
+      /* Set up the arguments for the signal handler.  */
+      stackframe->signo = signo;
+      stackframe->sigcode = detail->code;
+      stackframe->scp = stackframe->return_scp = scp = &stackframe->ctx;
+      stackframe->sigreturn_addr = &__sigreturn;
+      stackframe->sigreturn_returns_here = &&firewall; /* Crash on return.  */
+
       /* Set up the sigcontext from the current state of the thread.  */
 
       scp->sc_onstack = ss->sigaltstack.ss_flags & SA_ONSTACK ? 1 : 0;
@@ -110,24 +138,23 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
 
       /* struct sigcontext is laid out so that starting at sc_cause
 	 mimics a struct mips_exc_state.  */
-      if (! machine_get_state (ss->thread, state, MIPS_EXC_STATE,
-			       &state->exc, &scp->sc_cause,
-			       sizeof (state->exc)))
-	return NULL;
-      if ((scp->sc_coproc_used & SC_COPROC_USE_FPU) &&
-	  /* struct sigcontext is laid out so that starting at sc_fpr
-	     mimics a struct mips_float_state.  This state
-	     is only meaningful if the coprocessor was used.  */
-	  ! machine_get_state (ss->thread, state, MIPS_FLOAT_STATE,
-			       &state->fpu,
-			       &scp->sc_mips_float_state, sizeof (state->fpu)))
+      ok = machine_get_state (ss->thread, state, MIPS_EXC_STATE,
+			      &state->exc, &scp->sc_cause,
+			      sizeof (state->exc));
+
+      if (ok && (scp->sc_coproc_used & SC_COPROC_USE_FPU))
+	/* struct sigcontext is laid out so that starting at sc_fpr
+	   mimics a struct mips_float_state.  This state
+	   is only meaningful if the coprocessor was used.  */
+	  ok = machine_get_state (ss->thread, state, MIPS_FLOAT_STATE,
+				  &state->fpu, &scp->sc_mips_float_state,
+				  sizeof (state->fpu));
+
+      _hurdsig_end_catch_fault ();
+
+      if (! ok)
 	return NULL;
     }
-  else
-    /* We got a fault trying to write the stack frame.
-       We cannot set up the signal handler.
-       Returning NULL tells our caller, who will nuke us with a SIGILL.  */
-    return NULL;
 
   /* Modify the thread state to call the trampoline code on the new stack.  */
   if (rpc_wait)
@@ -145,6 +172,12 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
 	 starting with a0 ($4).  */
       struct mach_msg_trap_args *args = (void *) &state->basic.r4;
 
+      if (_hurdsig_catch_memory_fault (args))
+	{
+	  /* Faulted accessing ARGS.  Bomb.  */
+	  return NULL;
+	}
+
       assert (args->option & MACH_RCV_MSG);
       /* Disable the message-send, since it has already completed.  The
 	 calls we retry need only wait to receive the reply message.  */
@@ -156,17 +189,22 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
       args->option |= MACH_RCV_TIMEOUT;
       args->timeout = _hurd_interrupted_rpc_timeout;
 
+      _hurdsig_end_catch_fault ();
+
       state->basic.pc = (int) &&rpc_wait_trampoline;
-      state->basic.r29 = (int) sigsp; /* $29 is the stack pointer register.  */
+      /* The reply-receiving trampoline code runs initially on the original
+	 user stack.  We pass it the signal stack pointer in s4 ($20).  */
+      state->basic.r29 = state->basic.r16; /* Restore mach_msg syscall SP.  */
+      state->basic.r20 = (int) sigsp;
       /* After doing the message receive, the trampoline code will need to
 	 update the v0 ($2) value to be restored by sigreturn.  To simplify
 	 the assembly code, we pass the address of its slot in SCP to the
-	 trampoline code in v1 ($3).  */
-      state->basic.r3 = (int) &scp->sc_gpr[1];
+	 trampoline code in s5 ($21).  */
+      state->basic.r21 = (int) &scp->sc_gpr[1];
       /* We must preserve the mach_msg_trap args in a0..t2 ($4..$10).
 	 Pass the handler args to the trampoline code in s1..s3 ($17..$19).  */
       state->basic.r17 = signo;
-      state->basic.r18 = sigcode;
+      state->basic.r18 = detail->code;
       state->basic.r19 = (int) scp;
     }
   else
@@ -174,12 +212,12 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
       state->basic.pc = (int) &&trampoline;
       state->basic.r29 = (int) sigsp;
       state->basic.r4 = signo;
-      state->basic.r5 = sigcode;
+      state->basic.r5 = detail->code;
       state->basic.r6 = (int) scp;
     }
 
-  /* We pass the handler function to the trampoline code in at ($1).  */
-  state->basic.r1 = (int) handler;
+  /* We pass the handler function to the trampoline code in s6 ($22).  */
+  state->basic.r22 = (int) handler;
   /* In the callee-saved register s0 ($16), we save the SCP value to pass
      to __sigreturn after the handler returns.  */
   state->basic.r16 = (int) scp;
@@ -197,21 +235,31 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
   asm volatile
     (".set noat; .set noreorder; .set nomacro\n"
      /* Retry the interrupted mach_msg system call.  */
+#ifdef __mips64
+     "dli $2, -25\n"		/* mach_msg_trap */
+#else
      "li $2, -25\n"		/* mach_msg_trap */
+#endif
      "syscall\n"
      /* When the sigcontext was saved, v0 was MACH_RCV_INTERRUPTED.  But
 	now the message receive has completed and the original caller of
 	the RPC (i.e. the code running when the signal arrived) needs to
 	see the final return value of the message receive in v0.  So
 	store the new v0 value into the sc_gpr[1] member of the sigcontext
-	(whose address is in v1 to make this code simpler).  */
-     "sw $2, ($3)\n"
+	(whose address is in s5 to make this code simpler).  */
+#ifdef __mips64
+     "sd $2, ($21)\n"
+#else
+     "sw $2, ($21)\n"
+#endif
      /* Since the argument registers needed to have the mach_msg_trap
 	arguments, we've stored the arguments to the handler function
 	in registers s1..s3 ($17..$19).  */
      "move $4, $17\n"
      "move $5, $18\n"
-     "move $6, $19\n");
+     "move $6, $19\n"
+     /* Switch to the signal stack.  */
+     "move $29, $20\n");
 
  trampoline:
   /* Entry point for running the handler normally.  The arguments to the
@@ -222,14 +270,23 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
        a2	SCP
      */
   asm volatile
-    ("jal $1; nop\n"		/* Call the handler function.  */
+    ("move $25, $22\n"		/* Copy s6 to t9 for MIPS ABI.  */
+     "jal $25; nop\n"		/* Call the handler function.  */
      /* Call __sigreturn (SCP); this cannot return.  */
-     "j %0\n"
+#ifdef __mips64
+     "dla $1,%0\n"
+#else
+     "la $1,%0\n"
+#endif
+     "j $1\n"
      "move $4, $16"		/* Set up arg from saved SCP in delay slot.  */
      : : "i" (&__sigreturn));
 
   /* NOTREACHED */
   asm volatile (".set reorder; .set at; .set macro");
 
+ firewall:
+  asm volatile ("hlt: j hlt");
+
   return NULL;
 }
diff --git a/sysdeps/mach/hurd/select.c b/sysdeps/mach/hurd/select.c
index 391b57bf5c..f8385ff29b 100644
--- a/sysdeps/mach/hurd/select.c
+++ b/sysdeps/mach/hurd/select.c
@@ -223,7 +223,7 @@ __select (nfds, readfds, writefds, exceptfds, timeout)
 	  /* We got a message.  Decode it.  */
 #define IO_SELECT_REPLY_MSGID (21012 + 100) /* XXX */
 	  const mach_msg_type_t inttype =
-	    { MACH_MSG_TYPE_INTEGER_32, 32, 1, 1, 0, 0 };
+	    { MACH_MSG_TYPE_INTEGER_T, MACH_MSG_SIZE_INTEGER_T, 1, 1, 0, 0 };
 	  if (msg.head.msgh_id == IO_SELECT_REPLY_MSGID &&
 	      msg.head.msgh_size >= sizeof msg.error &&
 	      !(msg.head.msgh_bits & MACH_MSGH_BITS_COMPLEX) &&
diff --git a/sysdeps/mach/mips/cacheflush.c b/sysdeps/mach/mips/cacheflush.c
index 5325e6fd1e..de2ec58bff 100644
--- a/sysdeps/mach/mips/cacheflush.c
+++ b/sysdeps/mach/mips/cacheflush.c
@@ -1,28 +1,28 @@
 /* Flush the insn cache after GCC writes a closure on the stack.  Mach/MIPS.
-Copyright (C) 1994 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is 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 <mach.h>
 #include <mach/vm_attributes.h>
 
 /* Stupid name, but this is what GCC generates (config/mips/mips.h).  */
 void
-cacheflush (void *addr, size_t size, int flag)
+cacheflush (void *addr, unsigned size, int flag)
 {
   vm_machine_attribute_val_t val;
 
diff --git a/sysdeps/mach/mips/machine-lock.h b/sysdeps/mach/mips/machine-lock.h
index 628aae41bb..91d39e3753 100644
--- a/sysdeps/mach/mips/machine-lock.h
+++ b/sysdeps/mach/mips/machine-lock.h
@@ -1,25 +1,28 @@
 /* Machine-specific definition for spin locks.  MIPS version.
-Copyright (C) 1994 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is 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.  */
 
 #ifndef _MACHINE_LOCK_H
 #define	_MACHINE_LOCK_H
 
+/* To get the TAS pseudo-instruction. */
+#include <mach/mips/mips_instruction.h>
+
 /* The type of a spin lock variable.  */
 
 typedef __volatile int __spin_lock_t;
@@ -46,19 +49,35 @@ __spin_unlock (__spin_lock_t *__lock)
 _EXTERN_INLINE int
 __spin_try_lock (register __spin_lock_t *__lock)
 {
-  register int __rtn;
+#if (__mips >= 2)
+  int __rtn;
+
   __asm__ __volatile (".set noreorder");
-#if 0
-  __asm__ __volatile ("lw %0,0(%1)": "=r" (__rtn) : "r" (__lock));
-  __asm__ __volatile ("sw %0,0(%0)": : "r" (__lock));
-  __asm__ __volatile ("xor %0,%1,%0": "=r" (__rtn) : "r" (__lock));
+#if (__mips64)
+  __asm__ __volatile ("lld %0,0(%1)" : "=r" (__rtn) : "r" (__lock));
 #else
-  /* Use the Mach microkernel's emulated TAS pseudo-instruction.  */
-  register int __rtn __asm__ ("a0");
-  __asm__ __volatile (".word 0xf ! %0 " : "=r" (__rtn) : "0" (__lock));
+  __asm__ __volatile ("ll %0,0(%1)" : "=r" (__rtn) : "r" (__lock));
+#endif
+  if (__rtn)
+    return 0;
+  __asm__ __volatile ("move %0,%1" : "=r" (__rtn) : "r" (__lock));
+#if (__mips64)
+  __asm__ __volatile ("scd %0,0(%1)" : "=r" (__rtn) : "r" (__lock));
+#else
+  __asm__ __volatile ("sc %0,0(%1)" : "=r" (__rtn) : "r" (__lock));
 #endif
   __asm__ __volatile (".set reorder");
+  return __rtn;
+#else
+  register int __rtn __asm__ ("a0");
+
+  /* Use the Mach microkernel's emulated TAS pseudo-instruction.  */
+  __asm__ __volatile (".set noreorder");
+  __asm__ __volatile (".word %1" : "=r" (__rtn) : "i" (op_tas), "0" (__lock));
+  __asm__ __volatile ("nop");
+  __asm__ __volatile (".set reorder");
   return __rtn ^ (int) __lock;
+#endif
 }
 
 /* Return nonzero if LOCK is locked.  */
diff --git a/sysdeps/mach/mips/machine-sp.h b/sysdeps/mach/mips/machine-sp.h
index 7406658f53..e1217c31f3 100644
--- a/sysdeps/mach/mips/machine-sp.h
+++ b/sysdeps/mach/mips/machine-sp.h
@@ -1,21 +1,21 @@
 /* Machine-specific function to return the stack pointer.  MIPS version.
-Copyright (C) 1994 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) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
 
 #ifndef _MACHINE_SP_H
 #define _MACHINE_SP_H
diff --git a/sysdeps/mach/mips/syscall.S b/sysdeps/mach/mips/syscall.S
index bf56b401dd..9936772295 100644
--- a/sysdeps/mach/mips/syscall.S
+++ b/sysdeps/mach/mips/syscall.S
@@ -1,37 +1,48 @@
-/* Copyright (C) 1994 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is 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 <sysdep.h>
 
+#ifdef PIC
+	.option pic2
+#endif
 ENTRY (syscall)
-	.frame	sp,0,ra
 	move	v0, a0		/* Load system call number from first arg.  */
 	move	a0, a1		/* Move the next three args up a register.  */
 	move	a1, a2
 	move	a2, a3
      	/* Load the remaining possible args (up to 11) from the stack.  */
-	lw	t0,16(sp)
-	lw	t1,20(sp)
-	lw	t2,24(sp)
-	lw	t3,28(sp)
-	lw	t4,32(sp)
-	lw	t5,36(sp)
-	lw	t6,40(sp)
+#ifdef __mips64
+	ld	t0,4*8(sp)
+	ld	t1,5*8(sp)
+	ld	t2,6*8(sp)
+	ld	t3,7*8(sp)
+	ld	t4,8*8(sp)
+	ld	t5,9*8(sp)
+	ld	t6,10*8(sp)
+#else
+	lw	t0,4*4(sp)
+	lw	t1,5*4(sp)
+	lw	t2,6*4(sp)
+	lw	t3,7*4(sp)
+	lw	t4,8*4(sp)
+	lw	t5,9*4(sp)
+	lw	t6,10*4(sp)
+#endif
 	syscall			/* Do the system call.  */
      	j ra			/* Return to caller.  */
-	.end	syscall
diff --git a/sysdeps/mach/mips/sysdep.h b/sysdeps/mach/mips/sysdep.h
index 7609be5931..a4e6dff148 100644
--- a/sysdeps/mach/mips/sysdep.h
+++ b/sysdeps/mach/mips/sysdep.h
@@ -1,35 +1,40 @@
-/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is 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.  */
 
-#define MOVE(x,y)	move y , x
-
-#if 0
 #define LOSE asm volatile ("1: b 1b")
-#endif
 
+#define START_MACHDEP asm ("\
+	.text\n\
+	.globl _start\n\
+	.ent _start\n\
+_start:\n\
+	# Put initial SP in a0.\n\
+	move $4, $29\n\
+	# Jump to _start0; don't return.\n\
+	j _start0\n\
+	.end _start\n\
+");
+#define START_ARGS	int *entry_sp
 #define SNARF_ARGS(argc, argv, envp)					      \
   do									      \
     {									      \
-      int *entry_sp;							      \
       register char **p;						      \
 									      \
-      asm ("addu %0,$30,4" : "=r" (entry_sp));				      \
-									      \
       argc = *entry_sp;							      \
       argv = (char **) (entry_sp + 1);					      \
       p = argv;								      \
@@ -44,11 +49,20 @@ Cambridge, MA 02139, USA.  */
   ({ register int __fn = fn, __sp = (int) sp; \
      asm volatile ("move $sp,%0; j %1" : : "r" (__sp), "r" (__fn));})
 
+#define RETURN_TO(sp, pc, retval) \
+  asm volatile ("move $29, %0; move $2, %2; move $25, %1; jr $25" \
+		: : "r" (sp), "r" (pc), "r" (retval))
+
 #define STACK_GROWTH_DOWN
 
-#ifdef P40
 #include <syscall.h>
 
+#if defined (ASSEMBLER)
+
+#define ALIGN	2
+
+#define MOVE(x,y)	move y , x
+
 #define SYSCALL(name, args)	\
   .globl syscall_error;	\
   kernel_trap(name,SYS_##name,args);	\
diff --git a/sysdeps/mach/mips/thread_state.h b/sysdeps/mach/mips/thread_state.h
index f4f4b429cf..a72848dfc0 100644
--- a/sysdeps/mach/mips/thread_state.h
+++ b/sysdeps/mach/mips/thread_state.h
@@ -1,25 +1,30 @@
 /* Mach thread state definitions for machine-independent code.  MIPS version.
-Copyright (C) 1994 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is 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.  */
 
 #define MACHINE_THREAD_STATE_FLAVOR	MIPS_THREAD_STATE
 #define MACHINE_THREAD_STATE_COUNT	MIPS_THREAD_STATE_COUNT
 
+#ifdef PIC
+#define MACHINE_THREAD_STATE_SET_PC(ts, pc) \
+  ((ts)->PC = (ts)->r25 = (unsigned long int) (pc))
+#endif
+
 #define machine_thread_state mips_thread_state
 
 #define PC pc
diff --git a/sysdeps/mach/start.c b/sysdeps/mach/start.c
index c2ea3e3b7b..b1d121eb75 100644
--- a/sysdeps/mach/start.c
+++ b/sysdeps/mach/start.c
@@ -29,7 +29,9 @@ Cambridge, MA 02139, USA.  */
 /* The first piece of initialized data.  */
 int __data_start = 0;
 
+#ifndef _HURD_THREADVAR_H
 volatile int errno;
+#endif
 
 extern void __mach_init (void);
 extern void __libc_init (int argc, char **argv, char **envp);
@@ -62,6 +64,7 @@ start1 (void)
 
 #ifndef START_ARGS
 #define START_ARGS void
+#endif
 #ifdef START_MACHDEP
 START_MACHDEP
 #define _start _start0
diff --git a/sysdeps/mips/add_n.S b/sysdeps/mips/add_n.S
new file mode 100644
index 0000000000..df32eecfcf
--- /dev/null
+++ b/sysdeps/mips/add_n.S
@@ -0,0 +1,121 @@
+/* MIPS2 __mpn_add_n -- Add two limb vectors of the same length > 0 and
+store sum in a third limb vector.
+
+Copyright (C) 1995 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP 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 MP 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 MP 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>
+
+/* INPUT PARAMETERS
+   res_ptr	$4
+   s1_ptr	$5
+   s2_ptr	$6
+   size		$7
+*/
+#ifdef PIC
+	.option pic2
+#endif
+ENTRY (__mpn_add_n)
+	.set	noreorder
+#ifdef PIC
+	.cpload t9
+#endif
+	.set	nomacro
+
+	lw	$10,0($5)
+	lw	$11,0($6)
+
+	addiu	$7,$7,-1
+	and	$9,$7,4-1	/* number of limbs in first loop */
+	beq	$9,$0,.L0	/* if multiple of 4 limbs, skip first loop */
+	move	$2,$0
+
+	subu	$7,$7,$9
+
+.Loop0:	addiu	$9,$9,-1
+	lw	$12,4($5)
+	addu	$11,$11,$2
+	lw	$13,4($6)
+	sltu	$8,$11,$2
+	addu	$11,$10,$11
+	sltu	$2,$11,$10
+	sw	$11,0($4)
+	or	$2,$2,$8
+
+	addiu	$5,$5,4
+	addiu	$6,$6,4
+	move	$10,$12
+	move	$11,$13
+	bne	$9,$0,.Loop0
+	 addiu	$4,$4,4
+
+.L0:	beq	$7,$0,.Lend
+	 nop
+
+.Loop:	addiu	$7,$7,-4
+
+	lw	$12,4($5)
+	addu	$11,$11,$2
+	lw	$13,4($6)
+	sltu	$8,$11,$2
+	addu	$11,$10,$11
+	sltu	$2,$11,$10
+	sw	$11,0($4)
+	or	$2,$2,$8
+
+	lw	$10,8($5)
+	addu	$13,$13,$2
+	lw	$11,8($6)
+	sltu	$8,$13,$2
+	addu	$13,$12,$13
+	sltu	$2,$13,$12
+	sw	$13,4($4)
+	or	$2,$2,$8
+
+	lw	$12,12($5)
+	addu	$11,$11,$2
+	lw	$13,12($6)
+	sltu	$8,$11,$2
+	addu	$11,$10,$11
+	sltu	$2,$11,$10
+	sw	$11,8($4)
+	or	$2,$2,$8
+
+	lw	$10,16($5)
+	addu	$13,$13,$2
+	lw	$11,16($6)
+	sltu	$8,$13,$2
+	addu	$13,$12,$13
+	sltu	$2,$13,$12
+	sw	$13,12($4)
+	or	$2,$2,$8
+
+	addiu	$5,$5,16
+	addiu	$6,$6,16
+
+	bne	$7,$0,.Loop
+	 addiu	$4,$4,16
+
+.Lend:	addu	$11,$11,$2
+	sltu	$8,$11,$2
+	addu	$11,$10,$11
+	sltu	$2,$11,$10
+	sw	$11,0($4)
+	j	$31
+	or	$2,$2,$8
diff --git a/sysdeps/mips/add_n.s b/sysdeps/mips/add_n.s
deleted file mode 100644
index f5525cec46..0000000000
--- a/sysdeps/mips/add_n.s
+++ /dev/null
@@ -1,120 +0,0 @@
- # MIPS2 __mpn_add_n -- Add two limb vectors of the same length > 0 and
- # store sum in a third limb vector.
-
- # Copyright (C) 1995 Free Software Foundation, Inc.
-
- # This file is part of the GNU MP Library.
-
- # The GNU MP 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 MP 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 MP 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.
-
-
- # INPUT PARAMETERS
- # res_ptr	$4
- # s1_ptr	$5
- # s2_ptr	$6
- # size		$7
-
-	.text
-	.align	2
-	.globl	__mpn_add_n
-	.ent	__mpn_add_n
-__mpn_add_n:
-	.set	noreorder
-	.set	nomacro
-
-	lw	$10,0($5)
-	lw	$11,0($6)
-
-	addiu	$7,$7,-1
-	and	$9,$7,4-1	# number of limbs in first loop
-	beq	$9,$0,.L0	# if multiple of 4 limbs, skip first loop
-	 move	$2,$0
-
-	subu	$7,$7,$9
-
-.Loop0:	addiu	$9,$9,-1
-	lw	$12,4($5)
-	addu	$11,$11,$2
-	lw	$13,4($6)
-	sltu	$8,$11,$2
-	addu	$11,$10,$11
-	sltu	$2,$11,$10
-	sw	$11,0($4)
-	or	$2,$2,$8
-
-	addiu	$5,$5,4
-	addiu	$6,$6,4
-	move	$10,$12
-	move	$11,$13
-	bne	$9,$0,.Loop0
-	 addiu	$4,$4,4
-
-.L0:	beq	$7,$0,.Lend
-	 nop
-
-.Loop:	addiu	$7,$7,-4
-
-	lw	$12,4($5)
-	addu	$11,$11,$2
-	lw	$13,4($6)
-	sltu	$8,$11,$2
-	addu	$11,$10,$11
-	sltu	$2,$11,$10
-	sw	$11,0($4)
-	or	$2,$2,$8
-
-	lw	$10,8($5)
-	addu	$13,$13,$2
-	lw	$11,8($6)
-	sltu	$8,$13,$2
-	addu	$13,$12,$13
-	sltu	$2,$13,$12
-	sw	$13,4($4)
-	or	$2,$2,$8
-
-	lw	$12,12($5)
-	addu	$11,$11,$2
-	lw	$13,12($6)
-	sltu	$8,$11,$2
-	addu	$11,$10,$11
-	sltu	$2,$11,$10
-	sw	$11,8($4)
-	or	$2,$2,$8
-
-	lw	$10,16($5)
-	addu	$13,$13,$2
-	lw	$11,16($6)
-	sltu	$8,$13,$2
-	addu	$13,$12,$13
-	sltu	$2,$13,$12
-	sw	$13,12($4)
-	or	$2,$2,$8
-
-	addiu	$5,$5,16
-	addiu	$6,$6,16
-
-	bne	$7,$0,.Loop
-	 addiu	$4,$4,16
-
-.Lend:	addu	$11,$11,$2
-	sltu	$8,$11,$2
-	addu	$11,$10,$11
-	sltu	$2,$11,$10
-	sw	$11,0($4)
-	j	$31
-	or	$2,$2,$8
-
-	.end	__mpn_add_n
diff --git a/sysdeps/mips/addmul_1.S b/sysdeps/mips/addmul_1.S
new file mode 100644
index 0000000000..dc1dc1ba50
--- /dev/null
+++ b/sysdeps/mips/addmul_1.S
@@ -0,0 +1,98 @@
+/* MIPS __mpn_addmul_1 -- Multiply a limb vector with a single limb and
+add the product to a second limb vector.
+
+Copyright (C) 1995 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP 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 MP 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 MP 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>
+
+/* INPUT PARAMETERS
+   res_ptr	$4
+   s1_ptr	$5
+   size		$6
+   s2_limb	$7
+*/
+#ifdef PIC
+	.option pic2
+#endif
+ENTRY (__mpn_addmul_1)
+	.set    noreorder
+#ifdef PIC
+	.cpload t9
+#endif
+	.set    nomacro
+
+	/* warm up phase 0 */
+	lw	$8,0($5)
+
+	/* warm up phase 1 */
+	addiu	$5,$5,4
+	multu	$8,$7
+
+	addiu	$6,$6,-1
+	beq	$6,$0,$LC0
+	move	$2,$0		/* zero cy2 */
+
+	addiu	$6,$6,-1
+	beq	$6,$0,$LC1
+	lw	$8,0($5)	/* load new s1 limb as early as possible */
+
+Loop:	lw	$10,0($4)
+	mflo	$3
+	mfhi	$9
+	addiu	$5,$5,4
+	addu	$3,$3,$2	/* add old carry limb to low product limb */
+	multu	$8,$7
+	lw	$8,0($5)	/* load new s1 limb as early as possible */
+	addiu	$6,$6,-1	/* decrement loop counter */
+	sltu	$2,$3,$2	/* carry from previous addition -> $2 */
+	addu	$3,$10,$3
+	sltu	$10,$3,$10
+	addu	$2,$2,$10
+	sw	$3,0($4)
+	addiu	$4,$4,4
+	bne	$6,$0,Loop	/* should be "bnel" */
+	addu	$2,$9,$2	/* add high product limb and carry from addition */
+
+	/* cool down phase 1 */
+$LC1:	lw	$10,0($4)
+	mflo	$3
+	mfhi	$9
+	addu	$3,$3,$2
+	sltu	$2,$3,$2
+	multu	$8,$7
+	addu	$3,$10,$3
+	sltu	$10,$3,$10
+	addu	$2,$2,$10
+	sw	$3,0($4)
+	addiu	$4,$4,4
+	addu	$2,$9,$2	/* add high product limb and carry from addition */
+
+	/* cool down phase 0 */
+$LC0:	lw	$10,0($4)
+	mflo	$3
+	mfhi	$9
+	addu	$3,$3,$2
+	sltu	$2,$3,$2
+	addu	$3,$10,$3
+	sltu	$10,$3,$10
+	addu	$2,$2,$10
+	sw	$3,0($4)
+	j	$31
+	addu	$2,$9,$2	/* add high product limb and carry from addition */
diff --git a/sysdeps/mips/addmul_1.s b/sysdeps/mips/addmul_1.s
deleted file mode 100644
index 6145771e39..0000000000
--- a/sysdeps/mips/addmul_1.s
+++ /dev/null
@@ -1,97 +0,0 @@
- # MIPS __mpn_addmul_1 -- Multiply a limb vector with a single limb and
- # add the product to a second limb vector.
-
- # Copyright (C) 1992, 1994, 1996 Free Software Foundation, Inc.
-
- # This file is part of the GNU MP Library.
-
- # The GNU MP 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 MP 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 MP 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.
-
-
- # INPUT PARAMETERS
- # res_ptr	$4
- # s1_ptr	$5
- # size		$6
- # s2_limb	$7
-
-	.text
-	.align	 4
-	.globl	 __mpn_addmul_1
-	.ent	__mpn_addmul_1
-__mpn_addmul_1:
-	.set    noreorder
-	.set    nomacro
-
- # warm up phase 0
-	lw	$8,0($5)
-
- # warm up phase 1
-	addiu	$5,$5,4
-	multu	$8,$7
-
-	addiu	$6,$6,-1
-	beq	$6,$0,$LC0
-	 move	$2,$0		# zero cy2
-
-	addiu	$6,$6,-1
-	beq	$6,$0,$LC1
-	lw	$8,0($5)	# load new s1 limb as early as possible
-
-Loop:	lw	$10,0($4)
-	mflo	$3
-	mfhi	$9
-	addiu	$5,$5,4
-	addu	$3,$3,$2	# add old carry limb to low product limb
-	multu	$8,$7
-	lw	$8,0($5)	# load new s1 limb as early as possible
-	addiu	$6,$6,-1	# decrement loop counter
-	sltu	$2,$3,$2	# carry from previous addition -> $2
-	addu	$3,$10,$3
-	sltu	$10,$3,$10
-	addu	$2,$2,$10
-	sw	$3,0($4)
-	addiu	$4,$4,4
-	bne	$6,$0,Loop
-	 addu	$2,$9,$2	# add high product limb and carry from addition
-
- # cool down phase 1
-$LC1:	lw	$10,0($4)
-	mflo	$3
-	mfhi	$9
-	addu	$3,$3,$2
-	sltu	$2,$3,$2
-	multu	$8,$7
-	addu	$3,$10,$3
-	sltu	$10,$3,$10
-	addu	$2,$2,$10
-	sw	$3,0($4)
-	addiu	$4,$4,4
-	addu	$2,$9,$2	# add high product limb and carry from addition
-
- # cool down phase 0
-$LC0:	lw	$10,0($4)
-	mflo	$3
-	mfhi	$9
-	addu	$3,$3,$2
-	sltu	$2,$3,$2
-	addu	$3,$10,$3
-	sltu	$10,$3,$10
-	addu	$2,$2,$10
-	sw	$3,0($4)
-	j	$31
-	addu	$2,$9,$2	# add high product limb and carry from addition
-
-	.end	__mpn_addmul_1
diff --git a/sysdeps/mips/bytesex.h b/sysdeps/mips/bits/endian.h
index ba555cd76e..ba555cd76e 100644
--- a/sysdeps/mips/bytesex.h
+++ b/sysdeps/mips/bits/endian.h
diff --git a/sysdeps/mips/bits/setjmp.h b/sysdeps/mips/bits/setjmp.h
new file mode 100644
index 0000000000..7e570c6bff
--- /dev/null
+++ b/sysdeps/mips/bits/setjmp.h
@@ -0,0 +1,53 @@
+/* Define the machine-dependent type `jmp_buf'.  MIPS version.
+   Copyright (C) 1992, 1993, 1995, 1997 Free Software Foundation, Inc.
+   Contributed by Brendan Kehoe (brendan@zen.org).
+
+   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.  */
+
+typedef struct
+  {
+    /* Program counter.  */
+    __ptr_t __pc;
+
+    /* Stack pointer.  */
+    __ptr_t __sp;
+
+    /* Callee-saved registers s0 through s7.  */
+    int __regs[8];
+
+    /* The frame pointer.  */
+    __ptr_t __fp;
+
+    /* The global pointer.  */
+    __ptr_t __gp;
+
+    /* Floating point status register.  */
+    int __fpc_csr;
+
+    /* Callee-saved floating point registers.  */
+    double __fpregs[6];
+  } __jmp_buf[1];
+
+#ifdef __USE_MISC
+/* Offset to the program counter in `jmp_buf'.  */
+# define JB_PC	0
+#endif
+
+
+/* Test if longjmp to JMPBUF would unwind the frame
+   containing a local variable at ADDRESS.  */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+  ((__ptr_t) (address) < (jmpbuf)[0].__sp)
diff --git a/sysdeps/mips/bsd-_setjmp.S b/sysdeps/mips/bsd-_setjmp.S
index 78776cd3e5..f519f19359 100644
--- a/sysdeps/mips/bsd-_setjmp.S
+++ b/sysdeps/mips/bsd-_setjmp.S
@@ -1,21 +1,21 @@
 /* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'.  MIPS version.
-Copyright (C) 1994, 1995 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is 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.  */
 
 /* This just does a tail-call to `__sigsetjmp (ARG, 0)'.
    We cannot do it in C because it must be a tail-call, so frame-unwinding
@@ -23,7 +23,14 @@ Cambridge, MA 02139, USA.  */
 
 #include <sysdep.h>
 
-ENTRY (setjmp)
-	j C_SYMBOL_NAME (__sigsetjmp)
-	li a1, $0		/* Pass a second argument of zero.  */
-	.end setjmp
+#ifdef PIC
+	.option pic2
+#endif
+ENTRY (_setjmp)
+#ifdef PIC
+	.cpload t9
+#endif
+	la t9, C_SYMBOL_NAME (__sigsetjmp)
+	nop
+	jr t9
+	li a1, 0		/* Pass a second argument of zero.  */
diff --git a/sysdeps/mips/bsd-setjmp.S b/sysdeps/mips/bsd-setjmp.S
index 4742462e88..9a22700718 100644
--- a/sysdeps/mips/bsd-setjmp.S
+++ b/sysdeps/mips/bsd-setjmp.S
@@ -1,21 +1,21 @@
 /* BSD `setjmp' entry point to `sigsetjmp (..., 1)'.  MIPS version.
-Copyright (C) 1994, 1995 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is 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.  */
 
 /* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
    We cannot do it in C because it must be a tail-call, so frame-unwinding
@@ -23,7 +23,14 @@ Cambridge, MA 02139, USA.  */
 
 #include <sysdep.h>
 
+#ifdef PIC
+	.option pic2
+#endif
 ENTRY (setjmp)
-	j C_SYMBOL_NAME (__sigsetjmp)
+#ifdef PIC
+	.cpload t9
+#endif
+	la t9, C_SYMBOL_NAME (__sigsetjmp)
+	nop
+	jr t9
 	li a1, 1		/* Pass a second argument of one.  */
-	.end setjmp
diff --git a/sysdeps/mips/dec/bytesex.h b/sysdeps/mips/dec/bits/endian.h
index 157bc44d06..157bc44d06 100644
--- a/sysdeps/mips/dec/bytesex.h
+++ b/sysdeps/mips/dec/bits/endian.h
diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h
index 422179c47d..ff7d371025 100644
--- a/sysdeps/mips/dl-machine.h
+++ b/sysdeps/mips/dl-machine.h
@@ -18,30 +18,25 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#ifndef dl_machine_h
+#define dl_machine_h
+
 #define ELF_MACHINE_NAME "MIPS"
 
 #include <assert.h>
-#include <string.h>
-#include <link.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <unistd.h>
 
 /* Translate a processor specific dynamic tag to the index
    in l_info array.  */
 #define DT_MIPS(x) (DT_MIPS_##x - DT_LOPROC + DT_NUM)
 
-#if 1
-/* XXX If FLAGS has the MAP_ALIGN bit, we need 64k alignment. */
-#ifndef MAP_ALIGN
-#define MAP_ALIGN 0x1000
-#endif
-#define ELF_MACHINE_ALIGN_MASK(flags) ((flags & MAP_ALIGN) ? 0xffff : 0)
+#if 0
+/* We may need 64k alignment. */
+#define ELF_MACHINE_ALIGN_MASK 0xffff
 #endif
 
 /* If there is a DT_MIPS_RLD_MAP entry in the dynamic section, fill it in
    with the run-time address of the r_debug structure  */
-#define ELF_MACHINE_SET_DEBUG(l,r) \
+#define ELF_MACHINE_DEBUG_SETUP(l,r) \
 do { if ((l)->l_info[DT_MIPS (RLD_MAP)]) \
        *(ElfW(Addr) *)((l)->l_info[DT_MIPS (RLD_MAP)]->d_un.d_ptr) = \
        (ElfW(Addr)) (r); \
@@ -67,14 +62,16 @@ elf_mips_got_from_gpreg (ElfW(Addr) gpreg)
   /* FIXME: the offset of gp from GOT may be system-dependent. */
   return (ElfW(Addr) *) (gpreg - 0x7ff0);
 }
-/* Return the link-time address of _DYNAMIC.  Conveniently, this is the
-   first element of the GOT.  This must be inlined in a function which
-   uses global data.  */
-static inline ElfW(Addr)
-elf_machine_dynamic (void)
+
+/* Return the run-time address of the _GLOBAL_OFFSET_TABLE_.
+   Must be inlined in a function which uses global data.  */
+static inline ElfW(Addr) *
+elf_machine_got (void)
 {
-  register ElfW(Addr) gp asm ("$28");
-  return * (ElfW(Addr) *) (gp - 0x7ff0);
+  ElfW(Addr) gp;
+
+  __asm__ __volatile__("move %0, $28\n\t" : "=r" (gp));
+  return elf_mips_got_from_gpreg (gp);
 }
 
 
@@ -83,6 +80,15 @@ static inline ElfW(Addr)
 elf_machine_load_address (void)
 {
   ElfW(Addr) addr;
+#ifdef __mips64
+  asm ("	.set noreorder\n"
+       "	dla %0, here\n"
+       "	bltzal $0, here\n"
+       "	nop\n"
+       "here:	dsubu %0, $31, %0\n"
+       "	.set reorder\n"
+       : "=r" (addr));
+#else
   asm ("	.set noreorder\n"
        "	la %0, here\n"
        "	bltzal $0, here\n"
@@ -90,6 +96,7 @@ elf_machine_load_address (void)
        "here:	subu %0, $31, %0\n"
        "	.set reorder\n"
        : "=r" (addr));
+#endif
   return addr;
 }
 
@@ -97,7 +104,7 @@ elf_machine_load_address (void)
 #define ELF_MIPS_GNU_GOT1_MASK 0x80000000
 
 /* Relocate GOT. */
-static void
+static inline void
 elf_machine_got_rel (struct link_map *map)
 {
   ElfW(Addr) *got;
@@ -107,14 +114,14 @@ elf_machine_got_rel (struct link_map *map)
   const char *strtab
     = ((void *) map->l_addr + map->l_info[DT_STRTAB]->d_un.d_ptr);
 
-  ElfW(Addr) resolve (const ElfW(Sym) *sym)
-    {
-      const ElfW(Sym) *ref = sym;
-      ElfW(Addr) sym_loadaddr;
-      sym_loadaddr = _dl_lookup_symbol (strtab + sym->st_name, &ref, scope,
-					map->l_name, 0, 1);
-      return (ref)? sym_loadaddr + ref->st_value: 0;
-    }
+#define RESOLVE_GOTSYM(sym) \
+    ({ \
+      const ElfW(Sym) *ref = sym; \
+      ElfW(Addr) sym_loadaddr; \
+      sym_loadaddr = _dl_lookup_symbol (strtab + sym->st_name, &ref, scope, \
+					map->l_name, DL_LOOKUP_NOPLT); \
+      (ref)? sym_loadaddr + ref->st_value: 0; \
+    })
 
   got = (ElfW(Addr) *) ((void *) map->l_addr
 			+ map->l_info[DT_PLTGOT]->d_un.d_ptr);
@@ -147,39 +154,35 @@ elf_machine_got_rel (struct link_map *map)
 	      if (sym->st_value /* && maybe_stub (sym->st_value) */)
 		*got = sym->st_value + map->l_addr;
 	      else
-		*got = resolve (sym);
+		*got = RESOLVE_GOTSYM (sym);
 	    }
 	  else /* if (*got == 0 || *got == QS) */
-	    *got = resolve (sym);
+	    *got = RESOLVE_GOTSYM (sym);
 	}
       else if (sym->st_shndx == SHN_COMMON)
-	*got = resolve (sym);
+	*got = RESOLVE_GOTSYM (sym);
       else if (ELFW(ST_TYPE) (sym->st_info) == STT_FUNC
 	       && *got != sym->st_value
 	       /* && maybe_stub (*got) */)
 	*got += map->l_addr;
-      else if (ELFW(ST_TYPE) (sym->st_info) == STT_SECTION
-	       && ELFW(ST_BIND) (sym->st_info) == STB_GLOBAL)
+      else if (ELFW(ST_TYPE) (sym->st_info) == STT_SECTION)
 	{
-	  if (sym->st_other == 0 && sym->st_shndx == SHN_ABS)
-	    *got = sym->st_value + map->l_addr; /* only for _gp_disp  */
-	  /* else SGI stuff ignored */
+	  if (sym->st_other == 0)
+	    *got += map->l_addr;
 	}
       else
-	*got = resolve (sym);
+	*got = RESOLVE_GOTSYM (sym);
 
       got++;
       sym++;
     }
 
+#undef RESOLVE_GOTSYM
   *_dl_global_scope_end = NULL;
 
   return;
 }
 
-/* The MIPS never uses Elfxx_Rela relocations.  */
-#define ELF_MACHINE_NO_RELA 1
-
 /* Set up the loaded object described by L so its stub function
    will jump to the on-demand fixup code in dl-runtime.c.  */
 
@@ -188,6 +191,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy)
 {
   ElfW(Addr) *got;
   extern void _dl_runtime_resolve (ElfW(Word));
+  extern int _dl_mips_gnu_objects;
 
   if (lazy)
     {
@@ -208,7 +212,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy)
       if ((got[1] & ELF_MIPS_GNU_GOT1_MASK) != 0)
 	got[1] = (ElfW(Addr)) ((unsigned) l | ELF_MIPS_GNU_GOT1_MASK);
       else
-	; /* Do nothing. */
+	_dl_mips_gnu_objects = 0;
     }
 
   /* Relocate global offset table.  */
@@ -219,29 +223,64 @@ elf_machine_runtime_setup (struct link_map *l, int lazy)
 
 /* Get link_map for this object.  */
 static inline struct link_map *
-elf_machine_runtime_link_map (ElfW(Addr) gpreg)
+elf_machine_runtime_link_map (ElfW(Addr) gpreg, ElfW(Addr) stub_pc)
 {
-  ElfW(Addr) *got = elf_mips_got_from_gpreg (gpreg);
-  ElfW(Word) g1;
-
-  g1 = ((ElfW(Word) *) got)[1];
+  extern int _dl_mips_gnu_objects;
 
   /* got[1] is reserved to keep its link map address for the shared
-     object generated by gnu linker. If not so, we must search GOT
-     in object list slowly. XXX  */
-  if ((g1 & ELF_MIPS_GNU_GOT1_MASK) != 0)
-    return (struct link_map *) (g1 & ~ELF_MIPS_GNU_GOT1_MASK);
-  else
+     object generated by gnu linker. If all are such object, we can
+     find link map from current GPREG simply. If not so, get link map
+     for callers object containing STUB_PC.  */
+
+  if (_dl_mips_gnu_objects)
+    {
+      ElfW(Addr) *got = elf_mips_got_from_gpreg (gpreg);
+      ElfW(Word) g1;
+
+      g1 = ((ElfW(Word) *) got)[1];
+
+      if ((g1 & ELF_MIPS_GNU_GOT1_MASK) != 0)
+	return (struct link_map *) (g1 & ~ELF_MIPS_GNU_GOT1_MASK);
+    }
+
     {
       struct link_map *l = _dl_loaded;
+      struct link_map *ret = 0;
+      ElfW(Addr) candidate = 0;
+
       while (l)
 	{
-	  if (got == (ElfW(Addr) *) ((void *) l->l_addr
-				     + l->l_info[DT_PLTGOT]->d_un.d_ptr))
-	    return l;
+	  ElfW(Addr) base = 0;
+	  const ElfW(Phdr) *p = l->l_phdr;
+	  ElfW(Half) this, nent = l->l_phnum;
+
+	  /* Get the base. */
+	  for (this = 0; this < nent; this++)
+	    if (p[this].p_type == PT_LOAD)
+	      {
+		base = p[this].p_vaddr + l->l_addr;
+		break;
+	      }
+	  if (! base)
+	    {
+	      l = l->l_next;
+	      continue;
+	    }
+
+	  /* Find closest link base addr. */
+	  if ((base < stub_pc) && (candidate < base))
+	    {
+	      candidate = base;
+	      ret = l;
+	    }
 	  l = l->l_next;
 	}
+      if (candidate && ret && (candidate < stub_pc))
+	return ret;
+      else if (!candidate)
+	return _dl_loaded;
     }
+
   _dl_signal_error (0, NULL, "cannot find runtime link map");
 }
 
@@ -255,17 +294,117 @@ elf_machine_runtime_link_map (ElfW(Addr) gpreg)
      t8  index for this function symbol in .dynsym
    to usual c arguments.  */
 
+#ifdef __mips64
+#define ELF_MACHINE_RUNTIME_TRAMPOLINE \
+/* The flag _dl_mips_gnu_objects is set if all dynamic objects are \
+   generated by the gnu linker. */\
+int _dl_mips_gnu_objects = 1;\
+\
+/* This is called from assembly stubs below which the compiler can't see.  */ \
+static ElfW(Addr) \
+__dl_runtime_resolve (ElfW(Word), ElfW(Word), ElfW(Addr), ElfW(Addr)) \
+                  __attribute__ ((unused)); \
+\
+static ElfW(Addr) \
+__dl_runtime_resolve (ElfW(Word) sym_index,\
+		      ElfW(Word) return_address,\
+		      ElfW(Addr) old_gpreg,\
+		      ElfW(Addr) stub_pc)\
+{\
+  struct link_map *l = elf_machine_runtime_link_map (old_gpreg, stub_pc);\
+  const ElfW(Sym) *const symtab\
+    = (const ElfW(Sym) *) (l->l_addr + l->l_info[DT_SYMTAB]->d_un.d_ptr);\
+  const char *strtab\
+    = (void *) (l->l_addr + l->l_info[DT_STRTAB]->d_un.d_ptr);\
+  const ElfW(Addr) *got\
+    = (const ElfW(Addr) *) (l->l_addr + l->l_info[DT_PLTGOT]->d_un.d_ptr);\
+  const ElfW(Word) local_gotno\
+    = (const ElfW(Word)) l->l_info[DT_MIPS (LOCAL_GOTNO)]->d_un.d_val;\
+  const ElfW(Word) gotsym\
+    = (const ElfW(Word)) l->l_info[DT_MIPS (GOTSYM)]->d_un.d_val;\
+  const ElfW(Sym) *definer;\
+  ElfW(Addr) loadbase;\
+  ElfW(Addr) funcaddr;\
+  struct link_map **scope;\
+\
+  /* Look up the symbol's run-time value.  */\
+  scope = _dl_object_relocation_scope (l);\
+  definer = &symtab[sym_index];\
+\
+  loadbase = _dl_lookup_symbol (strtab + definer->st_name, &definer,\
+				scope, l->l_name, DL_LOOKUP_NOPLT);\
+\
+  *_dl_global_scope_end = NULL;\
+\
+  /* Apply the relocation with that value.  */\
+  funcaddr = loadbase + definer->st_value;\
+  *(got + local_gotno + sym_index - gotsym) = funcaddr;\
+\
+  return funcaddr;\
+}\
+\
+asm ("\n\
+	.text\n\
+	.align	3\n\
+	.globl	_dl_runtime_resolve\n\
+	.type	_dl_runtime_resolve,@function\n\
+	.ent	_dl_runtime_resolve\n\
+_dl_runtime_resolve:\n\
+	.set noreorder\n\
+	# Save old GP to $3.\n\
+	move	$3,$28\n\
+	# Modify t9 ($25) so as to point .cpload instruction.\n\
+	daddu	$25,2*8\n\
+	# Compute GP.\n\
+	.cpload $25\n\
+	.set reorder\n\
+	# Save slot call pc.\n\
+        move	$2, $31\n\
+	# Save arguments and sp value in stack.\n\
+	dsubu	$29, 10*8\n\
+	.cprestore 8*8\n\
+	sd	$15, 9*8($29)\n\
+	sd	$4, 3*8($29)\n\
+	sd	$5, 4*8($29)\n\
+	sd	$6, 5*8($29)\n\
+	sd	$7, 6*8($29)\n\
+	sd	$16, 7*8($29)\n\
+	move	$16, $29\n\
+	move	$4, $24\n\
+	move	$5, $15\n\
+	move	$6, $3\n\
+	move	$7, $2\n\
+	jal	__dl_runtime_resolve\n\
+	move	$29, $16\n\
+	ld	$31, 9*8($29)\n\
+	ld	$4, 3*8($29)\n\
+	ld	$5, 4*8($29)\n\
+	ld	$6, 5*8($29)\n\
+	ld	$7, 6*8($29)\n\
+	ld	$16, 7*8($29)\n\
+	daddu	$29, 10*8\n\
+	move	$25, $2\n\
+	jr	$25\n\
+	.end	_dl_runtime_resolve\n\
+");
+#else
 #define ELF_MACHINE_RUNTIME_TRAMPOLINE \
+/* The flag _dl_mips_gnu_objects is set if all dynamic objects are \
+   generated by the gnu linker. */\
+int _dl_mips_gnu_objects = 1;\
+\
 /* This is called from assembly stubs below which the compiler can't see.  */ \
-static ElfW(Addr) __dl_runtime_resolve (ElfW(Word), ElfW(Word), ElfW(Addr)) \
+static ElfW(Addr) \
+__dl_runtime_resolve (ElfW(Word), ElfW(Word), ElfW(Addr), ElfW(Addr)) \
                   __attribute__ ((unused)); \
 \
 static ElfW(Addr) \
 __dl_runtime_resolve (ElfW(Word) sym_index,\
 		      ElfW(Word) return_address,\
-		      ElfW(Addr) old_gpreg)\
+		      ElfW(Addr) old_gpreg,\
+		      ElfW(Addr) stub_pc)\
 {\
-  struct link_map *l = elf_machine_runtime_link_map (old_gpreg);\
+  struct link_map *l = elf_machine_runtime_link_map (old_gpreg, stub_pc);\
   const ElfW(Sym) *const symtab\
     = (const ElfW(Sym) *) (l->l_addr + l->l_info[DT_SYMTAB]->d_un.d_ptr);\
   const char *strtab\
@@ -286,7 +425,7 @@ __dl_runtime_resolve (ElfW(Word) sym_index,\
   definer = &symtab[sym_index];\
 \
   loadbase = _dl_lookup_symbol (strtab + definer->st_name, &definer,\
-				scope, l->l_name, 0, 1);\
+				scope, l->l_name, DL_LOOKUP_NOPLT);\
 \
   *_dl_global_scope_end = NULL;\
 \
@@ -312,6 +451,8 @@ _dl_runtime_resolve:\n\
 	# Compute GP.\n\
 	.cpload $25\n\
 	.set reorder\n\
+	# Save slot call pc.\n\
+        move	$2, $31\n\
 	# Save arguments and sp value in stack.\n\
 	subu	$29, 40\n\
 	.cprestore 32\n\
@@ -325,6 +466,7 @@ _dl_runtime_resolve:\n\
 	move	$4, $24\n\
 	move	$5, $15\n\
 	move	$6, $3\n\
+	move	$7, $2\n\
 	jal	__dl_runtime_resolve\n\
 	move	$29, $16\n\
 	lw	$31, 36($29)\n\
@@ -338,15 +480,91 @@ _dl_runtime_resolve:\n\
 	jr	$25\n\
 	.end	_dl_runtime_resolve\n\
 ");
+#endif
 
 /* Mask identifying addresses reserved for the user program,
    where the dynamic linker should not map anything.  */
 #define ELF_MACHINE_USER_ADDRESS_MASK	0x00000000UL
 
+
+
 /* Initial entry point code for the dynamic linker.
    The C function `_dl_start' is the real entry point;
    its return value is the user program's entry point.  */
 
+#ifdef __mips64
+#define RTLD_START asm ("\
+	.text\n\
+	.align	3\n\
+	.globl _start\n\
+	.globl _dl_start_user\n\
+	.ent _start\n\
+_start:\n\
+	.set noreorder\n\
+	bltzal $0, 0f\n\
+	nop\n\
+0:	.cpload $31\n\
+	.set reorder\n\
+	# i386 ABI book says that the first entry of GOT holds\n\
+	# the address of the dynamic structure. Though MIPS ABI\n\
+	# doesn't say nothing about this, I emulate this here.\n\
+	dla $4, _DYNAMIC\n\
+	sd $4, -0x7ff0($28)\n\
+	move $4, $29\n\
+	jal _dl_start\n\
+	# Get the value of label '_dl_start_user' in t9 ($25).\n\
+	dla $25, _dl_start_user\n\
+_dl_start_user:\n\
+	.set noreorder\n\
+	.cpload $25\n\
+	.set reorder\n\
+	move $16, $28\n\
+	# Save the user entry point address in saved register.\n\
+	move $17, $2\n\
+	# See if we were run as a command with the executable file\n\
+	# name as an extra leading argument.\n\
+	ld $2, _dl_skip_args\n\
+	beq $2, $0, 1f\n\
+	# Load the original argument count.\n\
+	ld $4, 0($29)\n\
+	# Subtract _dl_skip_args from it.\n\
+	dsubu $4, $2\n\
+	# Adjust the stack pointer to skip _dl_skip_args words.\n\
+	dsll $2,2\n\
+	daddu $29, $2\n\
+	# Save back the modified argument count.\n\
+	sd $4, 0($29)\n\
+	# Get _dl_default_scope[2] as argument in _dl_init_next call below.\n\
+1:	dla $2, _dl_default_scope\n\
+	ld $4, 2*8($2)\n\
+	# Call _dl_init_next to return the address of an initializer\n\
+	# function to run.\n\
+	jal _dl_init_next\n\
+	move $28, $16\n\
+	# Check for zero return,  when out of initializers.\n\
+	beq $2, $0, 2f\n\
+	# Call the shared object initializer function.\n\
+	move $25, $2\n\
+	ld $4, 0($29)\n\
+	ld $5, 1*8($29)\n\
+	ld $6, 2*8($29)\n\
+	ld $7, 3*8($29)\n\
+	jalr $25\n\
+	move $28, $16\n\
+	# Loop to call _dl_init_next for the next initializer.\n\
+	b 1b\n\
+	# Pass our finalizer function to the user in ra.\n\
+2:	dla $31, _dl_fini\n\
+	# Jump to the user entry point.\n\
+	move $25, $17\n\
+	ld $4, 0($29)\n\
+	ld $5, 1*8($29)\n\
+	ld $6, 2*8$29)\n\
+	ld $7, 3*8($29)\n\
+	jr $25\n\
+	.end _start\n\
+");
+#else
 #define RTLD_START asm ("\
 	.text\n\
 	.globl _start\n\
@@ -417,6 +635,12 @@ _dl_start_user:\n\
 	jr $25\n\
 	.end _start\n\
 ");
+#endif
+
+/* The MIPS never uses Elfxx_Rela relocations.  */
+#define ELF_MACHINE_NO_RELA 1
+
+#endif /* !dl_machine_h */
 
 #ifdef RESOLVE
 
@@ -428,34 +652,37 @@ elf_machine_rel (struct link_map *map, const ElfW(Rel) *reloc,
 		 const ElfW(Sym) *sym, const struct r_found_version *version)
 {
   ElfW(Addr) *const reloc_addr = (void *) (map->l_addr + reloc->r_offset);
-  ElfW(Addr) loadbase, undo;
+  ElfW(Addr) loadbase;
+  ElfW(Addr) undo __attribute__ ((unused));
 
   switch (ELFW(R_TYPE) (reloc->r_info))
     {
     case R_MIPS_REL32:
-      if (ELFW(ST_BIND) (sym->st_info) == STB_LOCAL
-	  && (ELFW(ST_TYPE) (sym->st_info) == STT_SECTION
-	      || ELFW(ST_TYPE) (sym->st_info) == STT_NOTYPE))
-	*reloc_addr += map->l_addr;
-      else
-	{
+      {
+	ElfW(Addr) undo = 0;
+
+	if (ELFW(ST_BIND) (sym->st_info) == STB_LOCAL
+	    && (ELFW(ST_TYPE) (sym->st_info) == STT_SECTION
+		|| ELFW(ST_TYPE) (sym->st_info) == STT_NOTYPE))
+	  {
+	    *reloc_addr += map->l_addr;
+	    break;
+	  }
 #ifndef RTLD_BOOTSTRAP
-	  /* This is defined in rtld.c, but nowhere in the static libc.a;
-	     make the reference weak so static programs can still link.  This
-	     declaration cannot be done when compiling rtld.c (i.e.  #ifdef
-	     RTLD_BOOTSTRAP) because rtld.c contains the common defn for
-	     _dl_rtld_map, which is incompatible with a weak decl in the same
-	     file.  */
-	  weak_extern (_dl_rtld_map);
-	  if (map == &_dl_rtld_map)
-	    /* Undo the relocation done here during bootstrapping.  Now we will
-	       relocate it anew, possibly using a binding found in the user
-	       program or a loaded library rather than the dynamic linker's
-	       built-in definitions used while loading those libraries.  */
-	    undo = map->l_addr + sym->st_value;
-	  else
+	/* This is defined in rtld.c, but nowhere in the static libc.a;
+	   make the reference weak so static programs can still link.  This
+	   declaration cannot be done when compiling rtld.c (i.e.  #ifdef
+	   RTLD_BOOTSTRAP) because rtld.c contains the common defn for
+	   _dl_rtld_map, which is incompatible with a weak decl in the same
+	   file.  */
+	weak_extern (_dl_rtld_map);
+	if (map == &_dl_rtld_map)
+	  /* Undo the relocation done here during bootstrapping.  Now we will
+	     relocate it anew, possibly using a binding found in the user
+	     program or a loaded library rather than the dynamic linker's
+	     built-in definitions used while loading those libraries.  */
+	  undo = map->l_addr + sym->st_value;
 #endif
-	    undo = 0;
 	  loadbase = RESOLVE (&sym, version, 0);
 	  *reloc_addr += (sym ? (loadbase + sym->st_value) : 0) - undo;
 	}
diff --git a/sysdeps/mips/elf/start.S b/sysdeps/mips/elf/start.S
new file mode 100644
index 0000000000..0db3a04a7d
--- /dev/null
+++ b/sysdeps/mips/elf/start.S
@@ -0,0 +1,181 @@
+/* Startup code compliant to the ELF Mips ABI.
+Copyright (C) 1995 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.  */
+
+/* This is the canonical entry point, usually the first thing in the text
+   segment.  The SVR4/Mips ABI (pages 3-31, 3-32) says that when the entry
+   point runs, most registers' values are unspecified, except for:
+
+   v1 ($2)	Contains a function pointer to be registered with `atexit'.
+   		This is how the dynamic linker arranges to have DT_FINI
+		functions called for shared libraries that have been loaded
+		before this code runs.
+
+   sp ($29)	The stack contains the arguments and environment:
+   		0(%esp)			argc
+		4(%esp)			argv[0]
+		...
+		(4*argc)(%esp)		NULL
+		(4*(argc+1))(%esp)	envp[0]
+		...
+					NULL
+   ra ($31)	The return address register is set to zero so that programs
+		that search backword through stack frames recognize the last
+		stack frame.
+*/
+
+#ifdef PIC
+/* A macro to (re)initialize gp. We can get the run time address of 0f in
+   ra ($31) by blezal instruction. In this early phase, we can't save gp
+   in stack and .cprestore doesn't work properly. So we set gp by using
+   this macro. */
+#define SET_GP \
+	.set noreorder;	\
+	bltzal $0,0f;	\
+	nop;		\
+0:	.cpload $31;	\
+	.set reorder;
+#endif
+
+	.text	
+	.globl _start
+_start:
+#ifdef PIC
+	SET_GP
+#endif
+	move $31, $0
+
+	/* $2 contains the address of the shared library termination
+	   function, which we will register with `atexit' to be called by
+	   `exit'.  I suspect that on some systems, and when statically
+	   linked, this will not be set by anything to any function
+	   pointer; hopefully it will be zero so we don't try to call
+	   random pointers.  */
+	beq $2, $0, nofini
+	move $4, $2
+	jal atexit
+#ifdef PIC
+	SET_GP
+#endif
+nofini:
+
+	/* Do essential libc initialization.  In statically linked
+	   programs under the GNU Hurd, this is what sets up the
+	   arguments on the stack for the code below. Since the argument
+	   registers (a0 - a3) saved to the first 4 stack entries by
+	   the prologue of __libc_init_first, we preload them to
+	   prevent clobbering the stack tops. In Hurd case, stack pointer
+	   ($29) may be VM_MAX_ADDRESS here. If so, we must modify it.  */
+#if (__mips64)
+	dli $4, 0x10000000000
+	bne $29, $4, 1f
+	dsubu $29, 32
+	sd $0, 0($29)
+	sd $0, 8($29)
+	sd $0, 16($29)
+	sd $0, 24($29)
+1:
+	ld $4, 0($29)
+	ld $5, 8($29)
+	ld $6, 16($29)
+	ld $7, 24($29)
+#else  /* __mips64 */
+	li $4, 0x80000000
+	bne $29, $4, 1f
+	subu $29, 16
+	sw $0, 0($29)
+	sw $0, 4($29)
+	sw $0, 8($29)
+	sw $0, 12($29)
+1:
+	lw $4, 0($29)
+	lw $5, 4($29)
+	lw $6, 8($29)
+	lw $7, 12($29)
+#endif  /* __mips64 */
+
+	jal __libc_init_first
+#ifdef PIC
+	SET_GP
+#endif
+#if (__mips64)
+	ld $4, 0($29)
+	ld $5, 8($29)
+	ld $6, 16($29)
+	ld $7, 24($29)
+#else  /* __mips64 */
+	lw $4, 0($29)
+	lw $5, 4($29)
+	lw $6, 8($29)
+	lw $7, 12($29)
+#endif  /* __mips64 */
+	
+	/* Call `_init', which is the entry point to our own `.init'
+	   section; and register with `atexit' to have `exit' call
+	   `_fini', which is the entry point to our own `.fini' section.  */
+	jal _init
+#ifdef PIC
+	SET_GP
+#endif
+#if (__mips64)
+	dla $4, _fini
+#else  /* __mips64 */
+	la $4, _fini
+#endif  /* __mips64 */
+
+	jal atexit
+#ifdef PIC
+	SET_GP
+#endif
+
+	/* Extract the arguments and environment as encoded on the stack
+	   and set up the arguments for `main': argc, argv, envp.  */
+#if (__mips64)
+	ld $4, 0($29)		/* argc */
+	daddu $5, $29, 8	/* argv */
+	dsll $6, $4, 3
+	daddu $6, $6, 8
+	daddu $6, $5, $6	/* envp = &argv[argc + 1] */
+#else  /* __mips64 */
+	lw $4, 0($29)		/* argc */
+	addu $5, $29, 4		/* argv */
+	sll $6, $4, 2
+	addu $6, $6, 4
+	addu $6, $5, $6		/* envp = &argv[argc + 1] */
+#endif  /* __mips64 */
+
+	/* Call the user's main function, and exit with its value.  */
+	jal main
+#ifdef PIC
+	SET_GP
+#endif
+	move $4, $2
+	jal exit		/* This should never return.  */
+hlt:	b hlt			/* Crash if somehow it does return.  */
+
+/* Define a symbol for the first piece of initialized data.  */
+	.data
+	.globl __data_start
+__data_start:
+#if (__mips64)
+	.dword 0
+#else  /* __mips64 */
+	.word 0
+#endif  /* __mips64 */
+	.weak data_start
+	data_start = __data_start
diff --git a/sysdeps/mips/fpu_control.h b/sysdeps/mips/fpu_control.h
new file mode 100644
index 0000000000..36e05a4f6e
--- /dev/null
+++ b/sysdeps/mips/fpu_control.h
@@ -0,0 +1,96 @@
+/* FPU control word bits.  Mips version.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Olaf Flebbe.
+
+   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
+
+/* FP control/status register bit assignments.
+ *
+ *     31-25    24  23     22-18       17-12          11-7       6-2     1-0
+ *                                    (cause)      (enables)   (flags)
+ * | reserved | FS | C | reserved | E V Z O U I | V Z O U I | V Z O U I | RM
+ *
+ * FS: When set, denormalized results are flushed to zero instead of
+ *     causing an unimplemented operation exception.
+ * C:  Condition bit.
+ * E:  Unimplemented Operation.
+ * V:  Invalid Operation.
+ * Z:  Division by zero.
+ * O:  Overflow.
+ * U:  Underflow.
+ * I:  Inexact Operation
+ * RM: Rounding mode bits
+ * 00 (RN) - rounding to nearest
+ * 01 (RZ) - rounding toward zero
+ * 10 (RP) - rounding down (toward - infinity)
+ * 11 (RM) - rounding up (toward + infinity)
+ *
+ */
+
+#include <features.h>
+
+/* masking of interrupts */
+#define _FPU_MASK_IM  (1 << 11)
+#define _FPU_MASK_DM  (1 << 24)	/* XXX */
+#define _FPU_MASK_ZM  (1 << 10)
+#define _FPU_MASK_OM  (1 << 9)
+#define _FPU_MASK_UM  (1 << 8)
+#define _FPU_MASK_PM  (1 << 7)
+
+/* precision control */
+#define _FPU_EXTENDED 0
+#define _FPU_DOUBLE   0
+#define _FPU_SINGLE   0
+
+/* rounding control */
+#define _FPU_RC_NEAREST 0x0    /* RECOMMENDED */
+#define _FPU_RC_DOWN    0x2
+#define _FPU_RC_UP      0x3
+#define _FPU_RC_ZERO    0x1
+
+#define _FPU_RESERVED 0xfe7c0000  /* Reserved bits */
+
+
+/* The fdlibm code requires strict IEEE double precision arithmetic,
+   and no interrupts for exceptions, rounding to nearest.  */
+
+#define _FPU_DEFAULT  0x0
+
+/* IEEE:  same as above, but exceptions */
+#define _FPU_IEEE     (0x1f << 7)
+
+/* Type of the control word.  */
+typedef unsigned int fpu_control_t;
+
+/* Macros for accessing the hardware control word.  */
+#define _FPU_GETCW(cw) __asm__ ("cfc1 %0, $31; nop; nop" : "=r" (cw))
+#define _FPU_SETCW(cw) __asm__ ("ctc1 %0, $31; nop; nop" : : "r" (cw))
+
+/* 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/mips/init-first.c b/sysdeps/mips/init-first.c
new file mode 100644
index 0000000000..3fc4b7bc04
--- /dev/null
+++ b/sysdeps/mips/init-first.c
@@ -0,0 +1,64 @@
+/* Initialization code run first thing by the ELF startup code.  For mips/Unix.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <unistd.h>
+
+extern void __libc_init (int, char **, char **);
+extern void __libc_global_ctors (void);
+
+
+static void
+init (int *data)
+{
+  int argc = *data;
+  char **argv = (void *) (data + 1);
+  char **envp = &argv[argc + 1];
+
+  __environ = envp;
+  __libc_init (argc, argv, envp);
+}
+
+#ifdef PIC
+/* This function is called to initialize the shared C library.
+   It is called just before the user _start code from mips/elf/start.S,
+   with the stack set up as that code gets it.  */
+
+/* NOTE!  The linker notices the magical name `_init' and sets the DT_INIT
+   pointer in the dynamic section based solely on that.  It is convention
+   for this function to be in the `.init' section, but the symbol name is
+   the only thing that really matters!!  */
+/*void _init (int argc, ...) __attribute__ ((unused, section (".init")));*/
+
+void
+_init (int argc, ...)
+{
+  init (&argc);
+
+  __libc_global_ctors ();
+}
+#endif
+
+
+void
+__libc_init_first (int argc __attribute__ ((unused)), ...)
+{
+#ifndef PIC
+  init (&argc);
+#endif
+}
diff --git a/sysdeps/mips/jmp_buf.h b/sysdeps/mips/jmp_buf.h
deleted file mode 100644
index 102a0193d8..0000000000
--- a/sysdeps/mips/jmp_buf.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Define the machine-dependent type `jmp_buf'.  MIPS version.
-   Copyright (C) 1992, 1993, 1995 Free Software Foundation, Inc.
-   Contributed by Brendan Kehoe (brendan@zen.org).
-
-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.  */
-
-typedef struct
-  {
-    /* Program counter.  */
-    __ptr_t __pc;
-    
-    /* Stack pointer.  */
-    __ptr_t __sp;
-    
-    /* Callee-saved registers s0 through s7.  */
-    int __regs[8];
-    
-    /* The frame pointer.  */
-    __ptr_t __fp;
-    
-    /* The global pointer.  */
-    __ptr_t __gp;
-    
-    /* Floating point status register.  */
-    int __fpc_csr;
-    
-    /* Callee-saved floating point registers.  */
-    double __fpregs[6];
-  } __jmp_buf[1];
-
-#ifdef __USE_MISC
-/* Offset to the program counter in `jmp_buf'.  */
-#define JB_PC	0
-#endif
-
-
-/* Test if longjmp to JMPBUF would unwind the frame
-   containing a local variable at ADDRESS.  */
-#define _JMPBUF_UNWINDS(jmpbuf, address) \
-  ((__ptr_t) (address) < (jmpbuf)[0].__sp)
diff --git a/sysdeps/mips/lshift.S b/sysdeps/mips/lshift.S
new file mode 100644
index 0000000000..e76630310f
--- /dev/null
+++ b/sysdeps/mips/lshift.S
@@ -0,0 +1,97 @@
+/* MIPS2 __mpn_lshift --
+
+Copyright (C) 1995 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP 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 MP 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 MP 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>
+
+/* INPUT PARAMETERS
+   res_ptr	$4
+   src_ptr	$5
+   size		$6
+   cnt		$7
+*/
+#ifdef PIC
+	.option pic2
+#endif
+ENTRY (__mpn_lshift)
+	.set	noreorder
+#ifdef PIC
+	.cpload t9
+#endif
+	.set	nomacro
+
+	sll	$2,$6,2
+	addu	$5,$5,$2	/* make r5 point at end of src */
+	lw	$10,-4($5)	/* load first limb */
+	subu	$13,$0,$7
+	addu	$4,$4,$2	/* make r4 point at end of res */
+	addiu	$6,$6,-1
+	and	$9,$6,4-1	/* number of limbs in first loop */
+	beq	$9,$0,.L0	/* if multiple of 4 limbs, skip first loop */
+	 srl	$2,$10,$13	/* compute function result */
+
+	subu	$6,$6,$9
+
+.Loop0:	lw	$3,-8($5)
+	addiu	$4,$4,-4
+	addiu	$5,$5,-4
+	addiu	$9,$9,-1
+	sll	$11,$10,$7
+	srl	$12,$3,$13
+	move	$10,$3
+	or	$8,$11,$12
+	bne	$9,$0,.Loop0
+	 sw	$8,0($4)
+
+.L0:	beq	$6,$0,.Lend
+	 nop
+
+.Loop:	lw	$3,-8($5)
+	addiu	$4,$4,-16
+	addiu	$6,$6,-4
+	sll	$11,$10,$7
+	srl	$12,$3,$13
+
+	lw	$10,-12($5)
+	sll	$14,$3,$7
+	or	$8,$11,$12
+	sw	$8,12($4)
+	srl	$9,$10,$13
+
+	lw	$3,-16($5)
+	sll	$11,$10,$7
+	or	$8,$14,$9
+	sw	$8,8($4)
+	srl	$12,$3,$13
+
+	lw	$10,-20($5)
+	sll	$14,$3,$7
+	or	$8,$11,$12
+	sw	$8,4($4)
+	srl	$9,$10,$13
+
+	addiu	$5,$5,-16
+	or	$8,$14,$9
+	bgtz	$6,.Loop
+	 sw	$8,0($4)
+
+.Lend:	sll	$8,$10,$7
+	j	$31
+	sw	$8,-4($4)
diff --git a/sysdeps/mips/lshift.s b/sysdeps/mips/lshift.s
deleted file mode 100644
index ee92d7916f..0000000000
--- a/sysdeps/mips/lshift.s
+++ /dev/null
@@ -1,95 +0,0 @@
- # MIPS2 __mpn_lshift --
-
- # Copyright (C) 1995 Free Software Foundation, Inc.
-
- # This file is part of the GNU MP Library.
-
- # The GNU MP 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 MP 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 MP 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.
-
-
- # INPUT PARAMETERS
- # res_ptr	$4
- # src_ptr	$5
- # size		$6
- # cnt		$7
-
-	.text
-	.align	2
-	.globl	__mpn_lshift
-	.ent	__mpn_lshift
-__mpn_lshift:
-	.set	noreorder
-	.set	nomacro
-
-	sll	$2,$6,2
-	addu	$5,$5,$2	# make r5 point at end of src
-	lw	$10,-4($5)	# load first limb
-	subu	$13,$0,$7
-	addu	$4,$4,$2	# make r4 point at end of res
-	addiu	$6,$6,-1
-	and	$9,$6,4-1	# number of limbs in first loop
-	beq	$9,$0,.L0	# if multiple of 4 limbs, skip first loop
-	 srl	$2,$10,$13	# compute function result
-
-	subu	$6,$6,$9
-
-.Loop0:	lw	$3,-8($5)
-	addiu	$4,$4,-4
-	addiu	$5,$5,-4
-	addiu	$9,$9,-1
-	sll	$11,$10,$7
-	srl	$12,$3,$13
-	move	$10,$3
-	or	$8,$11,$12
-	bne	$9,$0,.Loop0
-	 sw	$8,0($4)
-
-.L0:	beq	$6,$0,.Lend
-	 nop
-
-.Loop:	lw	$3,-8($5)
-	addiu	$4,$4,-16
-	addiu	$6,$6,-4
-	sll	$11,$10,$7
-	srl	$12,$3,$13
-
-	lw	$10,-12($5)
-	sll	$14,$3,$7
-	or	$8,$11,$12
-	sw	$8,12($4)
-	srl	$9,$10,$13
-
-	lw	$3,-16($5)
-	sll	$11,$10,$7
-	or	$8,$14,$9
-	sw	$8,8($4)
-	srl	$12,$3,$13
-
-	lw	$10,-20($5)
-	sll	$14,$3,$7
-	or	$8,$11,$12
-	sw	$8,4($4)
-	srl	$9,$10,$13
-
-	addiu	$5,$5,-16
-	or	$8,$14,$9
-	bgtz	$6,.Loop
-	 sw	$8,0($4)
-
-.Lend:	sll	$8,$10,$7
-	j	$31
-	sw	$8,-4($4)
-	.end	__mpn_lshift
diff --git a/sysdeps/mips/machine-gmon.h b/sysdeps/mips/machine-gmon.h
new file mode 100644
index 0000000000..a01b1746f4
--- /dev/null
+++ b/sysdeps/mips/machine-gmon.h
@@ -0,0 +1,57 @@
+/* Machine-specific calling sequence for `mcount' profiling function.  MIPS
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#define _MCOUNT_DECL static void __mcount
+
+/* Call __mcount with our the return PC for our caller,
+   and the return PC our caller will return to.  */
+#ifdef PIC
+#define CPLOAD ".cpload $25;"
+#else
+#define CPLOAD
+#endif
+
+#define MCOUNT asm(\
+	".globl _mcount;" \
+	".align 2;" \
+	".type _mcount,@function;" \
+        "_mcount:;" \
+        ".set noreorder;" \
+        ".set noat;" \
+        CPLOAD \
+        "sw $4,8($29);" \
+        "sw $5,12($29);" \
+        "sw $6,16($29);" \
+        "sw $7,20($29);" \
+        "sw $1,0($29);" \
+        "sw $31,4($29);" \
+        "move $5,$31;" \
+        "jal __mcount;" \
+        "move $4,$1;" \
+        "lw $4,8($29);" \
+        "lw $5,12($29);" \
+        "lw $6,16($29);" \
+        "lw $7,20($29);" \
+        "lw $31,4($29);" \
+        "lw $1,0($29);" \
+        "addu $29,$29,8;" \
+        "j $31;" \
+        "move $31,$1;" \
+        ".set reorder;" \
+        ".set at");
diff --git a/sysdeps/mips/mips64/Implies b/sysdeps/mips/mips64/Implies
new file mode 100644
index 0000000000..a8cae95f9d
--- /dev/null
+++ b/sysdeps/mips/mips64/Implies
@@ -0,0 +1 @@
+wordsize-64
diff --git a/sysdeps/mips/mips64/__longjmp.c b/sysdeps/mips/mips64/__longjmp.c
new file mode 100644
index 0000000000..551daa4895
--- /dev/null
+++ b/sysdeps/mips/mips64/__longjmp.c
@@ -0,0 +1,85 @@
+/* Copyright (C) 1992, 1995, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Brendan Kehoe (brendan@zen.org).
+
+   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 <setjmp.h>
+#include <stdlib.h>
+
+#undef __longjmp
+
+#ifndef	__GNUC__
+  #error This file uses GNU C extensions; you must compile with GCC.
+#endif
+
+void
+__longjmp (env, val_arg)
+     __jmp_buf env;
+     int val_arg;
+{
+  /* gcc 1.39.19 miscompiled the longjmp routine (as it did setjmp before
+     the hack around it); force it to use $a1 for the longjmp value.
+     Without this it saves $a1 in a register which gets clobbered
+     along the way.  */
+  register int val asm ("a1");
+
+  /* Pull back the floating point callee-saved registers.  */
+  asm volatile ("l.d $f24, %0" : : "m" (env[0].__fpregs[0]));
+  asm volatile ("l.d $f25, %0" : : "m" (env[0].__fpregs[1]));
+  asm volatile ("l.d $f26, %0" : : "m" (env[0].__fpregs[2]));
+  asm volatile ("l.d $f27, %0" : : "m" (env[0].__fpregs[3]));
+  asm volatile ("l.d $f28, %0" : : "m" (env[0].__fpregs[4]));
+  asm volatile ("l.d $f29, %0" : : "m" (env[0].__fpregs[5]));
+  asm volatile ("l.d $f30, %0" : : "m" (env[0].__fpregs[6]));
+  asm volatile ("l.d $f31, %0" : : "m" (env[0].__fpregs[7]));
+
+  /* Restore the stack pointer.  */
+  asm volatile ("ld $29, %0" : : "m" (env[0].__sp));
+
+  /* Get and reconstruct the floating point csr.  */
+  asm volatile ("lw $2, %0" : : "m" (env[0].__fpc_csr));
+  asm volatile ("ctc1 $2, $31");
+
+  /* Get the FP.  */
+  asm volatile ("ld $30, %0" : : "m" (env[0].__fp));
+
+  /* Get the GP. */
+  asm volatile ("ld $gp, %0" : : "m" (env[0].__gp));
+
+  /* Get the callee-saved registers.  */
+  asm volatile ("ld $16, %0" : : "m" (env[0].__regs[0]));
+  asm volatile ("ld $17, %0" : : "m" (env[0].__regs[1]));
+  asm volatile ("ld $18, %0" : : "m" (env[0].__regs[2]));
+  asm volatile ("ld $19, %0" : : "m" (env[0].__regs[3]));
+  asm volatile ("ld $20, %0" : : "m" (env[0].__regs[4]));
+  asm volatile ("ld $21, %0" : : "m" (env[0].__regs[5]));
+  asm volatile ("ld $22, %0" : : "m" (env[0].__regs[6]));
+  asm volatile ("ld $23, %0" : : "m" (env[0].__regs[7]));
+
+  /* Get the PC.  */
+  asm volatile ("ld $31, %0" : : "m" (env[0].__pc));
+
+  /* Give setjmp 1 if given a 0, or what they gave us if non-zero.  */
+  if (val == 0)
+    asm volatile ("dli $2, 1");
+  else
+    asm volatile ("move $2, %0" : : "r" (val));
+
+  asm volatile ("j $31");
+
+  abort ();
+}
diff --git a/sysdeps/mips/mips64/add_n.S b/sysdeps/mips/mips64/add_n.S
new file mode 100644
index 0000000000..ad93d9d081
--- /dev/null
+++ b/sysdeps/mips/mips64/add_n.S
@@ -0,0 +1,129 @@
+/* MIPS3 __mpn_add_n -- Add two limb vectors of the same length > 0 and
+ * store sum in a third limb vector.
+ *
+ * Copyright (C) 1995 Free Software Foundation, Inc.
+ *
+ * This file is part of the GNU MP Library.
+ *
+ * The GNU MP 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 MP 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 MP 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>
+
+/*
+ * INPUT PARAMETERS
+ * res_ptr	$4
+ * s1_ptr	$5
+ * s2_ptr	$6
+ * size		$7
+ */
+#ifdef PIC
+	.option pic2
+#endif
+	.text
+	.align	2
+	.globl	__mpn_add_n
+	.ent	__mpn_add_n
+__mpn_add_n:
+	.set	noreorder
+#ifdef PIC
+	.cpload t9
+#endif
+	.set	nomacro
+
+	ld	$10,0($5)
+	ld	$11,0($6)
+
+	daddiu	$7,$7,-1
+	and	$9,$7,4-1	# number of limbs in first loop
+	beq	$9,$0,.L0	# if multiple of 4 limbs, skip first loop
+	 move	$2,$0
+
+	dsubu	$7,$7,$9
+
+.Loop0:	daddiu	$9,$9,-1
+	ld	$12,8($5)
+	daddu	$11,$11,$2
+	ld	$13,8($6)
+	sltu	$8,$11,$2
+	daddu	$11,$10,$11
+	sltu	$2,$11,$10
+	sd	$11,0($4)
+	or	$2,$2,$8
+
+	daddiu	$5,$5,8
+	daddiu	$6,$6,8
+	move	$10,$12
+	move	$11,$13
+	bne	$9,$0,.Loop0
+	 daddiu	$4,$4,8
+
+.L0:	beq	$7,$0,.Lend
+	 nop
+
+.Loop:	daddiu	$7,$7,-4
+
+	ld	$12,8($5)
+	daddu	$11,$11,$2
+	ld	$13,8($6)
+	sltu	$8,$11,$2
+	daddu	$11,$10,$11
+	sltu	$2,$11,$10
+	sd	$11,0($4)
+	or	$2,$2,$8
+
+	ld	$10,16($5)
+	daddu	$13,$13,$2
+	ld	$11,16($6)
+	sltu	$8,$13,$2
+	daddu	$13,$12,$13
+	sltu	$2,$13,$12
+	sd	$13,8($4)
+	or	$2,$2,$8
+
+	ld	$12,24($5)
+	daddu	$11,$11,$2
+	ld	$13,24($6)
+	sltu	$8,$11,$2
+	daddu	$11,$10,$11
+	sltu	$2,$11,$10
+	sd	$11,16($4)
+	or	$2,$2,$8
+
+	ld	$10,32($5)
+	daddu	$13,$13,$2
+	ld	$11,32($6)
+	sltu	$8,$13,$2
+	daddu	$13,$12,$13
+	sltu	$2,$13,$12
+	sd	$13,24($4)
+	or	$2,$2,$8
+
+	daddiu	$5,$5,32
+	daddiu	$6,$6,32
+
+	bne	$7,$0,.Loop
+	 daddiu	$4,$4,32
+
+.Lend:	daddu	$11,$11,$2
+	sltu	$8,$11,$2
+	daddu	$11,$10,$11
+	sltu	$2,$11,$10
+	sd	$11,0($4)
+	j	$31
+	or	$2,$2,$8
+
+	.end	__mpn_add_n
diff --git a/sysdeps/mips/mips64/addmul_1.S b/sysdeps/mips/mips64/addmul_1.S
new file mode 100644
index 0000000000..58eff8c889
--- /dev/null
+++ b/sysdeps/mips/mips64/addmul_1.S
@@ -0,0 +1,106 @@
+/* MIPS3 __mpn_addmul_1 -- Multiply a limb vector with a single limb and
+ * add the product to a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
+ *
+ * This file is part of the GNU MP Library.
+ *
+ * The GNU MP 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 MP 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 MP 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>
+
+/* INPUT PARAMETERS
+ * res_ptr	$4
+ * s1_ptr	$5
+ * size		$6
+ * s2_limb	$7
+ */
+
+#ifdef PIC
+	.option pic2
+#endif
+	.text
+	.align	4
+	.globl	__mpn_addmul_1
+	.ent	__mpn_addmul_1
+__mpn_addmul_1:
+	.set    noreorder
+#ifdef PIC
+	.cpload t9
+#endif
+	.set    nomacro
+
+ # warm up phase 0
+	ld	$8,0($5)
+
+ # warm up phase 1
+	daddiu	$5,$5,8
+	dmultu	$8,$7
+
+	daddiu	$6,$6,-1
+	beq	$6,$0,$LC0
+	 move	$2,$0		# zero cy2
+
+	daddiu	$6,$6,-1
+	beq	$6,$0,$LC1
+	ld	$8,0($5)	# load new s1 limb as early as possible
+
+Loop:	ld	$10,0($4)
+	mflo	$3
+	mfhi	$9
+	daddiu	$5,$5,8
+	daddu	$3,$3,$2	# add old carry limb to low product limb
+	dmultu	$8,$7
+	ld	$8,0($5)	# load new s1 limb as early as possible
+	daddiu	$6,$6,-1	# decrement loop counter
+	sltu	$2,$3,$2	# carry from previous addition -> $2
+	daddu	$3,$10,$3
+	sltu	$10,$3,$10
+	daddu	$2,$2,$10
+	sd	$3,0($4)
+	daddiu	$4,$4,8
+	bne	$6,$0,Loop
+	 daddu	$2,$9,$2	# add high product limb and carry from addition
+
+ # cool down phase 1
+$LC1:	ld	$10,0($4)
+	mflo	$3
+	mfhi	$9
+	daddu	$3,$3,$2
+	sltu	$2,$3,$2
+	dmultu	$8,$7
+	daddu	$3,$10,$3
+	sltu	$10,$3,$10
+	daddu	$2,$2,$10
+	sd	$3,0($4)
+	daddiu	$4,$4,8
+	daddu	$2,$9,$2	# add high product limb and carry from addition
+
+ # cool down phase 0
+$LC0:	ld	$10,0($4)
+	mflo	$3
+	mfhi	$9
+	daddu	$3,$3,$2
+	sltu	$2,$3,$2
+	daddu	$3,$10,$3
+	sltu	$10,$3,$10
+	daddu	$2,$2,$10
+	sd	$3,0($4)
+	j	$31
+	daddu	$2,$9,$2	# add high product limb and carry from addition
+
+	.end	__mpn_addmul_1
diff --git a/sysdeps/mips/mips64/bits/setjmp.h b/sysdeps/mips/mips64/bits/setjmp.h
new file mode 100644
index 0000000000..b108540505
--- /dev/null
+++ b/sysdeps/mips/mips64/bits/setjmp.h
@@ -0,0 +1,54 @@
+/* Define the machine-dependent type `jmp_buf'.  MIPS version.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Brendan Kehoe (brendan@zen.org).
+
+   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.  */
+
+typedef struct
+  {
+    /* Program counter.  */
+    __ptr_t __pc;
+
+    /* Stack pointer.  */
+    __ptr_t __sp;
+
+    /* Callee-saved registers s0 through s7.  */
+    int __regs[8];
+
+    /* The frame pointer.  */
+    __ptr_t __fp;
+
+    /* The global pointer.  */
+    __ptr_t __gp;
+
+    /* Floating point status register.  */
+    int __fpc_csr;
+
+    /* Callee-saved floating point registers.  */
+    double __fpregs[8];
+  } __jmp_buf[1];
+
+#ifdef __USE_MISC
+/* Offset to the program counter in `jmp_buf'.  */
+# define JB_PC	0
+#endif
+
+
+/* Test if longjmp to JMPBUF would unwind the frame
+   containing a local variable at ADDRESS.  */
+#define _JMPBUF_UNWINDS(jmpbuf, address) \
+  ((__ptr_t) (address) < (jmpbuf)[0].__sp)
diff --git a/sysdeps/mips/mips64/bsd-_setjmp.S b/sysdeps/mips/mips64/bsd-_setjmp.S
new file mode 100644
index 0000000000..cd6ec3e196
--- /dev/null
+++ b/sysdeps/mips/mips64/bsd-_setjmp.S
@@ -0,0 +1,36 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'.  MIPS64 version.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 0)'.
+   We cannot do it in C because it must be a tail-call, so frame-unwinding
+   in setjmp doesn't clobber the state restored by longjmp.  */
+
+#include <sysdep.h>
+
+#ifdef PIC
+	.option pic2
+#endif
+ENTRY (_setjmp)
+#ifdef PIC
+	.cpload t9
+#endif
+	dla t9, C_SYMBOL_NAME (__sigsetjmp)
+	nop
+	jr t9
+	dli a1, 0		/* Pass a second argument of zero.  */
diff --git a/sysdeps/mips/mips64/bsd-setjmp.S b/sysdeps/mips/mips64/bsd-setjmp.S
new file mode 100644
index 0000000000..b37031679d
--- /dev/null
+++ b/sysdeps/mips/mips64/bsd-setjmp.S
@@ -0,0 +1,36 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'.  MIPS64 version.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
+   We cannot do it in C because it must be a tail-call, so frame-unwinding
+   in setjmp doesn't clobber the state restored by longjmp.  */
+
+#include <sysdep.h>
+
+#ifdef PIC
+	.option pic2
+#endif
+ENTRY (setjmp)
+#ifdef PIC
+	.cpload t9
+#endif
+	dla t9, C_SYMBOL_NAME (__sigsetjmp)
+	nop
+	jr t9
+	dli a1, 1		/* Pass a second argument of one.  */
diff --git a/sysdeps/mips/mips64/gmp-mparam.h b/sysdeps/mips/mips64/gmp-mparam.h
index a801b35d7a..38872ec5bc 100644
--- a/sysdeps/mips/mips64/gmp-mparam.h
+++ b/sysdeps/mips/mips64/gmp-mparam.h
@@ -20,7 +20,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 #define BITS_PER_MP_LIMB 64
 #define BYTES_PER_MP_LIMB 8
-#define BITS_PER_LONGINT 32
-#define BITS_PER_INT 32
+#define BITS_PER_LONGINT 64
+#define BITS_PER_INT 64
 #define BITS_PER_SHORTINT 16
 #define BITS_PER_CHAR 8
diff --git a/sysdeps/mips/mips64/lshift.S b/sysdeps/mips/mips64/lshift.S
new file mode 100644
index 0000000000..ef403ec25f
--- /dev/null
+++ b/sysdeps/mips/mips64/lshift.S
@@ -0,0 +1,104 @@
+/* MIPS3 __mpn_lshift --
+ *
+ * Copyright (C) 1995 Free Software Foundation, Inc.
+ *
+ * This file is part of the GNU MP Library.
+ *
+ * The GNU MP 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 MP 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 MP 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>
+
+/* INPUT PARAMETERS
+ * res_ptr	$4
+ * src_ptr	$5
+ * size		$6
+ * cnt		$7
+ */
+
+#ifdef PIC
+	.option pic2
+#endif
+	.text
+	.align	2
+	.globl	__mpn_lshift
+	.ent	__mpn_lshift
+__mpn_lshift:
+	.set	noreorder
+#ifdef PIC
+	.cpload t9
+#endif
+	.set	nomacro
+
+	dsll	$2,$6,3
+	daddu	$5,$5,$2	# make r5 point at end of src
+	ld	$10,-8($5)	# load first limb
+	dsubu	$13,$0,$7
+	daddu	$4,$4,$2	# make r4 point at end of res
+	daddiu	$6,$6,-1
+	and	$9,$6,4-1	# number of limbs in first loop
+	beq	$9,$0,.L0	# if multiple of 4 limbs, skip first loop
+	 dsrl	$2,$10,$13	# compute function result
+
+	dsubu	$6,$6,$9
+
+.Loop0:	ld	$3,-16($5)
+	daddiu	$4,$4,-8
+	daddiu	$5,$5,-8
+	daddiu	$9,$9,-1
+	dsll	$11,$10,$7
+	dsrl	$12,$3,$13
+	move	$10,$3
+	or	$8,$11,$12
+	bne	$9,$0,.Loop0
+	 sd	$8,0($4)
+
+.L0:	beq	$6,$0,.Lend
+	 nop
+
+.Loop:	ld	$3,-16($5)
+	daddiu	$4,$4,-32
+	daddiu	$6,$6,-4
+	dsll	$11,$10,$7
+	dsrl	$12,$3,$13
+
+	ld	$10,-24($5)
+	dsll	$14,$3,$7
+	or	$8,$11,$12
+	sd	$8,24($4)
+	dsrl	$9,$10,$13
+
+	ld	$3,-32($5)
+	dsll	$11,$10,$7
+	or	$8,$14,$9
+	sd	$8,16($4)
+	dsrl	$12,$3,$13
+
+	ld	$10,-40($5)
+	dsll	$14,$3,$7
+	or	$8,$11,$12
+	sd	$8,8($4)
+	dsrl	$9,$10,$13
+
+	daddiu	$5,$5,-32
+	or	$8,$14,$9
+	bgtz	$6,.Loop
+	 sd	$8,0($4)
+
+.Lend:	dsll	$8,$10,$7
+	j	$31
+	sd	$8,-8($4)
+	.end	__mpn_lshift
diff --git a/sysdeps/mips/mips64/mul_1.S b/sysdeps/mips/mips64/mul_1.S
new file mode 100644
index 0000000000..ef0cf36d75
--- /dev/null
+++ b/sysdeps/mips/mips64/mul_1.S
@@ -0,0 +1,94 @@
+/* MIPS3 __mpn_mul_1 -- Multiply a limb vector with a single limb and
+ * store the product in a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
+ *
+ * This file is part of the GNU MP Library.
+ *
+ * The GNU MP 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 MP 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 MP 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>
+
+/* INPUT PARAMETERS
+ * res_ptr	$4
+ * s1_ptr	$5
+ * size		$6
+ * s2_limb	$7
+ */
+
+#ifdef PIC
+	.option pic2
+#endif
+	.text
+	.align	4
+	.globl	__mpn_mul_1
+	.ent	__mpn_mul_1
+__mpn_mul_1:
+	.set    noreorder
+#ifdef PIC
+	.cpload t9
+#endif
+	.set    nomacro
+
+ # warm up phase 0
+	ld	$8,0($5)
+
+ # warm up phase 1
+	daddiu	$5,$5,8
+	dmultu	$8,$7
+
+	daddiu	$6,$6,-1
+	beq	$6,$0,$LC0
+	 move	$2,$0		# zero cy2
+
+	daddiu	$6,$6,-1
+	beq	$6,$0,$LC1
+	ld	$8,0($5)	# load new s1 limb as early as possible
+
+Loop:	mflo	$10
+	mfhi	$9
+	daddiu	$5,$5,8
+	daddu	$10,$10,$2	# add old carry limb to low product limb
+	dmultu	$8,$7
+	ld	$8,0($5)	# load new s1 limb as early as possible
+	daddiu	$6,$6,-1	# decrement loop counter
+	sltu	$2,$10,$2	# carry from previous addition -> $2
+	sd	$10,0($4)
+	daddiu	$4,$4,8
+	bne	$6,$0,Loop
+	 daddu	$2,$9,$2	# add high product limb and carry from addition
+
+ # cool down phase 1
+$LC1:	mflo	$10
+	mfhi	$9
+	daddu	$10,$10,$2
+	sltu	$2,$10,$2
+	dmultu	$8,$7
+	sd	$10,0($4)
+	daddiu	$4,$4,8
+	daddu	$2,$9,$2	# add high product limb and carry from addition
+
+ # cool down phase 0
+$LC0:	mflo	$10
+	mfhi	$9
+	daddu	$10,$10,$2
+	sltu	$2,$10,$2
+	sd	$10,0($4)
+	j	$31
+	daddu	$2,$9,$2	# add high product limb and carry from addition
+
+	.end	__mpn_mul_1
diff --git a/sysdeps/mips/mips64/rshift.S b/sysdeps/mips/mips64/rshift.S
new file mode 100644
index 0000000000..bc26f3f360
--- /dev/null
+++ b/sysdeps/mips/mips64/rshift.S
@@ -0,0 +1,101 @@
+/* MIPS3 __mpn_rshift --
+ *
+ * Copyright (C) 1995 Free Software Foundation, Inc.
+ *
+ * This file is part of the GNU MP Library.
+ *
+ * The GNU MP 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 MP 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 MP 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>
+
+/* INPUT PARAMETERS
+ * res_ptr	$4
+ * src_ptr	$5
+ * size		$6
+ * cnt		$7
+ */
+
+#ifdef PIC
+	.option pic2
+#endif
+	.text
+	.align	2
+	.globl	__mpn_rshift
+	.ent	__mpn_rshift
+__mpn_rshift:
+	.set	noreorder
+#ifdef PIC
+	.cpload t9
+#endif
+	.set	nomacro
+
+	ld	$10,0($5)	# load first limb
+	dsubu	$13,$0,$7
+	daddiu	$6,$6,-1
+	and	$9,$6,4-1	# number of limbs in first loop
+	beq	$9,$0,.L0	# if multiple of 4 limbs, skip first loop
+	 dsll	$2,$10,$13	# compute function result
+
+	dsubu	$6,$6,$9
+
+.Loop0:	ld	$3,8($5)
+	daddiu	$4,$4,8
+	daddiu	$5,$5,8
+	daddiu	$9,$9,-1
+	dsrl	$11,$10,$7
+	dsll	$12,$3,$13
+	move	$10,$3
+	or	$8,$11,$12
+	bne	$9,$0,.Loop0
+	 sd	$8,-8($4)
+
+.L0:	beq	$6,$0,.Lend
+	 nop
+
+.Loop:	ld	$3,8($5)
+	daddiu	$4,$4,32
+	daddiu	$6,$6,-4
+	dsrl	$11,$10,$7
+	dsll	$12,$3,$13
+
+	ld	$10,16($5)
+	dsrl	$14,$3,$7
+	or	$8,$11,$12
+	sd	$8,-32($4)
+	dsll	$9,$10,$13
+
+	ld	$3,24($5)
+	dsrl	$11,$10,$7
+	or	$8,$14,$9
+	sd	$8,-24($4)
+	dsll	$12,$3,$13
+
+	ld	$10,32($5)
+	dsrl	$14,$3,$7
+	or	$8,$11,$12
+	sd	$8,-16($4)
+	dsll	$9,$10,$13
+
+	daddiu	$5,$5,32
+	or	$8,$14,$9
+	bgtz	$6,.Loop
+	 sd	$8,-8($4)
+
+.Lend:	dsrl	$8,$10,$7
+	j	$31
+	sd	$8,0($4)
+	.end	__mpn_rshift
diff --git a/sysdeps/mips/mips64/setjmp.S b/sysdeps/mips/mips64/setjmp.S
new file mode 100644
index 0000000000..74214297b8
--- /dev/null
+++ b/sysdeps/mips/mips64/setjmp.S
@@ -0,0 +1,35 @@
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+
+/* The function __sigsetjmp_aux saves all the registers, but it can't
+   reliably access the stack or frame pointers, so we pass them in as
+   extra arguments.  */
+#ifdef PIC
+	.option pic2
+#endif
+ENTRY (__sigsetjmp)
+#ifdef PIC
+	.cpload t9
+#endif
+	move a2, sp
+	move a3, fp
+	dla t9, __sigsetjmp_aux
+	nop
+	jr t9
diff --git a/sysdeps/mips/mips64/setjmp_aux.c b/sysdeps/mips/mips64/setjmp_aux.c
new file mode 100644
index 0000000000..19d06e9999
--- /dev/null
+++ b/sysdeps/mips/mips64/setjmp_aux.c
@@ -0,0 +1,67 @@
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Brendan Kehoe (brendan@zen.org).
+
+   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 <setjmp.h>
+
+/* This function is only called via the assembly language routine
+   __sigsetjmp, which arranges to pass in the stack pointer and the frame
+   pointer.  We do things this way because it's difficult to reliably
+   access them in C.  */
+
+int
+__sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp)
+{
+  /* Store the floating point callee-saved registers...  */
+  asm volatile ("s.d $f24, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[0]));
+  asm volatile ("s.d $f25, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[1]));
+  asm volatile ("s.d $f26, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[2]));
+  asm volatile ("s.d $f27, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[3]));
+  asm volatile ("s.d $f28, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[4]));
+  asm volatile ("s.d $f29, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[5]));
+  asm volatile ("s.d $f30, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[6]));
+  asm volatile ("s.d $f31, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[7]));
+
+  /* .. and the PC;  */
+  asm volatile ("sd $31, %0" : : "m" (env[0].__jmpbuf[0].__pc));
+
+  /* .. and the stack pointer;  */
+  env[0].__jmpbuf[0].__sp = sp;
+
+  /* .. and the FP; it'll be in s8. */
+  env[0].__jmpbuf[0].__fp = fp;
+
+  /* .. and the GP; */
+  asm volatile ("sd $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp));
+
+  /* .. and the callee-saved registers; */
+  asm volatile ("sd $16, %0" : : "m" (env[0].__jmpbuf[0].__regs[0]));
+  asm volatile ("sd $17, %0" : : "m" (env[0].__jmpbuf[0].__regs[1]));
+  asm volatile ("sd $18, %0" : : "m" (env[0].__jmpbuf[0].__regs[2]));
+  asm volatile ("sd $19, %0" : : "m" (env[0].__jmpbuf[0].__regs[3]));
+  asm volatile ("sd $20, %0" : : "m" (env[0].__jmpbuf[0].__regs[4]));
+  asm volatile ("sd $21, %0" : : "m" (env[0].__jmpbuf[0].__regs[5]));
+  asm volatile ("sd $22, %0" : : "m" (env[0].__jmpbuf[0].__regs[6]));
+  asm volatile ("sd $23, %0" : : "m" (env[0].__jmpbuf[0].__regs[7]));
+
+  /* .. and finally get and reconstruct the floating point csr.  */
+  asm ("cfc1 %0, $31" : "=r" (env[0].__jmpbuf[0].__fpc_csr));
+
+  /* Save the signal mask if requested.  */
+  return __sigjmp_save (env, savemask);
+}
diff --git a/sysdeps/mips/mips64/sub_n.S b/sysdeps/mips/mips64/sub_n.S
new file mode 100644
index 0000000000..bfcba95afa
--- /dev/null
+++ b/sysdeps/mips/mips64/sub_n.S
@@ -0,0 +1,129 @@
+/* MIPS3 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
+ * store difference in a third limb vector.
+ *
+ * Copyright (C) 1995 Free Software Foundation, Inc.
+ *
+ * This file is part of the GNU MP Library.
+ *
+ * The GNU MP 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 MP 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 MP 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>
+
+/* INPUT PARAMETERS
+ * res_ptr	$4
+ * s1_ptr	$5
+ * s2_ptr	$6
+ * size		$7
+ */
+
+#ifdef PIC
+	.option pic2
+#endif
+	.text
+	.align	2
+	.globl	__mpn_sub_n
+	.ent	__mpn_sub_n
+__mpn_sub_n:
+	.set	noreorder
+#ifdef PIC
+	.cpload t9
+#endif
+	.set	nomacro
+
+	ld	$10,0($5)
+	ld	$11,0($6)
+
+	daddiu	$7,$7,-1
+	and	$9,$7,4-1	# number of limbs in first loop
+	beq	$9,$0,.L0	# if multiple of 4 limbs, skip first loop
+	 move	$2,$0
+
+	dsubu	$7,$7,$9
+
+.Loop0:	daddiu	$9,$9,-1
+	ld	$12,8($5)
+	daddu	$11,$11,$2
+	ld	$13,8($6)
+	sltu	$8,$11,$2
+	dsubu	$11,$10,$11
+	sltu	$2,$10,$11
+	sd	$11,0($4)
+	or	$2,$2,$8
+
+	daddiu	$5,$5,8
+	daddiu	$6,$6,8
+	move	$10,$12
+	move	$11,$13
+	bne	$9,$0,.Loop0
+	 daddiu	$4,$4,8
+
+.L0:	beq	$7,$0,.Lend
+	 nop
+
+.Loop:	daddiu	$7,$7,-4
+
+	ld	$12,8($5)
+	daddu	$11,$11,$2
+	ld	$13,8($6)
+	sltu	$8,$11,$2
+	dsubu	$11,$10,$11
+	sltu	$2,$10,$11
+	sd	$11,0($4)
+	or	$2,$2,$8
+
+	ld	$10,16($5)
+	daddu	$13,$13,$2
+	ld	$11,16($6)
+	sltu	$8,$13,$2
+	dsubu	$13,$12,$13
+	sltu	$2,$12,$13
+	sd	$13,8($4)
+	or	$2,$2,$8
+
+	ld	$12,24($5)
+	daddu	$11,$11,$2
+	ld	$13,24($6)
+	sltu	$8,$11,$2
+	dsubu	$11,$10,$11
+	sltu	$2,$10,$11
+	sd	$11,16($4)
+	or	$2,$2,$8
+
+	ld	$10,32($5)
+	daddu	$13,$13,$2
+	ld	$11,32($6)
+	sltu	$8,$13,$2
+	dsubu	$13,$12,$13
+	sltu	$2,$12,$13
+	sd	$13,24($4)
+	or	$2,$2,$8
+
+	daddiu	$5,$5,32
+	daddiu	$6,$6,32
+
+	bne	$7,$0,.Loop
+	 daddiu	$4,$4,32
+
+.Lend:	daddu	$11,$11,$2
+	sltu	$8,$11,$2
+	dsubu	$11,$10,$11
+	sltu	$2,$10,$11
+	sd	$11,0($4)
+	j	$31
+	or	$2,$2,$8
+
+	.end	__mpn_sub_n
diff --git a/sysdeps/mips/mips64/submul_1.S b/sysdeps/mips/mips64/submul_1.S
new file mode 100644
index 0000000000..66e634e102
--- /dev/null
+++ b/sysdeps/mips/mips64/submul_1.S
@@ -0,0 +1,106 @@
+/* MIPS3 __mpn_submul_1 -- Multiply a limb vector with a single limb and
+ * subtract the product from a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
+ *
+ * This file is part of the GNU MP Library.
+ *
+ * The GNU MP 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 MP 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 MP 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>
+
+/* INPUT PARAMETERS
+ * res_ptr	$4
+ * s1_ptr	$5
+ * size		$6
+ * s2_limb	$7
+ */
+
+#ifdef PIC
+	.option pic2
+#endif
+	.text
+	.align	4
+	.globl	__mpn_submul_1
+	.ent	__mpn_submul_1
+__mpn_submul_1:
+	.set    noreorder
+#ifdef PIC
+	.cpload t9
+#endif
+	.set    nomacro
+
+ # warm up phase 0
+	ld	$8,0($5)
+
+ # warm up phase 1
+	daddiu	$5,$5,8
+	dmultu	$8,$7
+
+	daddiu	$6,$6,-1
+	beq	$6,$0,$LC0
+	 move	$2,$0		# zero cy2
+
+	daddiu	$6,$6,-1
+	beq	$6,$0,$LC1
+	ld	$8,0($5)	# load new s1 limb as early as possible
+
+Loop:	ld	$10,0($4)
+	mflo	$3
+	mfhi	$9
+	daddiu	$5,$5,8
+	daddu	$3,$3,$2	# add old carry limb to low product limb
+	dmultu	$8,$7
+	ld	$8,0($5)	# load new s1 limb as early as possible
+	daddiu	$6,$6,-1	# decrement loop counter
+	sltu	$2,$3,$2	# carry from previous addition -> $2
+	dsubu	$3,$10,$3
+	sgtu	$10,$3,$10
+	daddu	$2,$2,$10
+	sd	$3,0($4)
+	daddiu	$4,$4,8
+	bne	$6,$0,Loop
+	 daddu	$2,$9,$2	# add high product limb and carry from addition
+
+ # cool down phase 1
+$LC1:	ld	$10,0($4)
+	mflo	$3
+	mfhi	$9
+	daddu	$3,$3,$2
+	sltu	$2,$3,$2
+	dmultu	$8,$7
+	dsubu	$3,$10,$3
+	sgtu	$10,$3,$10
+	daddu	$2,$2,$10
+	sd	$3,0($4)
+	daddiu	$4,$4,8
+	daddu	$2,$9,$2	# add high product limb and carry from addition
+
+ # cool down phase 0
+$LC0:	ld	$10,0($4)
+	mflo	$3
+	mfhi	$9
+	daddu	$3,$3,$2
+	sltu	$2,$3,$2
+	dsubu	$3,$10,$3
+	sgtu	$10,$3,$10
+	daddu	$2,$2,$10
+	sd	$3,0($4)
+	j	$31
+	daddu	$2,$9,$2	# add high product limb and carry from addition
+
+	.end	__mpn_submul_1
diff --git a/sysdeps/mips/mipsel/bytesex.h b/sysdeps/mips/mipsel/bits/endian.h
index 5da5965cb2..5da5965cb2 100644
--- a/sysdeps/mips/mipsel/bytesex.h
+++ b/sysdeps/mips/mipsel/bits/endian.h
diff --git a/sysdeps/mips/mul_1.S b/sysdeps/mips/mul_1.S
new file mode 100644
index 0000000000..184aae6fa1
--- /dev/null
+++ b/sysdeps/mips/mul_1.S
@@ -0,0 +1,86 @@
+/* MIPS __mpn_mul_1 -- Multiply a limb vector with a single limb and
+store the product in a second limb vector.
+
+Copyright (C) 1995 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP 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 MP 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 MP 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>
+
+/* INPUT PARAMETERS
+   res_ptr	$4
+   s1_ptr	$5
+   size		$6
+   s2_limb	$7
+*/
+#ifdef PIC
+	.option pic2
+#endif
+ENTRY (__mpn_mul_1)
+	.set    noreorder
+#ifdef PIC
+	.cpload t9
+#endif
+	.set    nomacro
+
+	/* warm up phase 0 */
+	lw	$8,0($5)
+
+	/* warm up phase 1 */
+	addiu	$5,$5,4
+	multu	$8,$7
+
+	addiu	$6,$6,-1
+	beq	$6,$0,$LC0
+	move	$2,$0		/* zero cy2 */
+
+	addiu	$6,$6,-1
+	beq	$6,$0,$LC1
+	lw	$8,0($5)	/* load new s1 limb as early as possible */
+
+Loop:	mflo	$10
+	mfhi	$9
+	addiu	$5,$5,4
+	addu	$10,$10,$2	/* add old carry limb to low product limb */
+	multu	$8,$7
+	lw	$8,0($5)	/* load new s1 limb as early as possible */
+	addiu	$6,$6,-1	/* decrement loop counter */
+	sltu	$2,$10,$2	/* carry from previous addition -> $2 */
+	sw	$10,0($4)
+	addiu	$4,$4,4
+	bne	$6,$0,Loop	/* should be "bnel" */
+	addu	$2,$9,$2	/* add high product limb and carry from addition */
+
+	/* cool down phase 1 */
+$LC1:	mflo	$10
+	mfhi	$9
+	addu	$10,$10,$2
+	sltu	$2,$10,$2
+	multu	$8,$7
+	sw	$10,0($4)
+	addiu	$4,$4,4
+	addu	$2,$9,$2	/* add high product limb and carry from addition
+
+	/* cool down phase 0 */
+$LC0:	mflo	$10
+	mfhi	$9
+	addu	$10,$10,$2
+	sltu	$2,$10,$2
+	sw	$10,0($4)
+	j	$31
+	addu	$2,$9,$2	/* add high product limb and carry from addition */
diff --git a/sysdeps/mips/mul_1.s b/sysdeps/mips/mul_1.s
deleted file mode 100644
index d006fa1221..0000000000
--- a/sysdeps/mips/mul_1.s
+++ /dev/null
@@ -1,85 +0,0 @@
- # MIPS __mpn_mul_1 -- Multiply a limb vector with a single limb and
- # store the product in a second limb vector.
-
- # Copyright (C) 1992, 1994, 1996 Free Software Foundation, Inc.
-
- # This file is part of the GNU MP Library.
-
- # The GNU MP 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 MP 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 MP 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.
-
-
- # INPUT PARAMETERS
- # res_ptr	$4
- # s1_ptr	$5
- # size		$6
- # s2_limb	$7
-
-	.text
-	.align	 4
-	.globl	 __mpn_mul_1
-	.ent	__mpn_mul_1
-__mpn_mul_1:
-	.set    noreorder
-	.set    nomacro
-
- # warm up phase 0
-	lw	$8,0($5)
-
- # warm up phase 1
-	addiu	$5,$5,4
-	multu	$8,$7
-
-	addiu	$6,$6,-1
-	beq	$6,$0,$LC0
-	 move	$2,$0		# zero cy2
-
-	addiu	$6,$6,-1
-	beq	$6,$0,$LC1
-	lw	$8,0($5)	# load new s1 limb as early as possible
-
-Loop:	mflo	$10
-	mfhi	$9
-	addiu	$5,$5,4
-	addu	$10,$10,$2	# add old carry limb to low product limb
-	multu	$8,$7
-	lw	$8,0($5)	# load new s1 limb as early as possible
-	addiu	$6,$6,-1	# decrement loop counter
-	sltu	$2,$10,$2	# carry from previous addition -> $2
-	sw	$10,0($4)
-	addiu	$4,$4,4
-	bne	$6,$0,Loop
-	 addu	$2,$9,$2	# add high product limb and carry from addition
-
- # cool down phase 1
-$LC1:	mflo	$10
-	mfhi	$9
-	addu	$10,$10,$2
-	sltu	$2,$10,$2
-	multu	$8,$7
-	sw	$10,0($4)
-	addiu	$4,$4,4
-	addu	$2,$9,$2	# add high product limb and carry from addition
-
- # cool down phase 0
-$LC0:	mflo	$10
-	mfhi	$9
-	addu	$10,$10,$2
-	sltu	$2,$10,$2
-	sw	$10,0($4)
-	j	$31
-	addu	$2,$9,$2	# add high product limb and carry from addition
-
-	.end	__mpn_mul_1
diff --git a/sysdeps/mips/p40/bytesex.h b/sysdeps/mips/p40/bits/endian.h
index e4b0119433..e4b0119433 100644
--- a/sysdeps/mips/p40/bytesex.h
+++ b/sysdeps/mips/p40/bits/endian.h
diff --git a/sysdeps/mips/rshift.S b/sysdeps/mips/rshift.S
new file mode 100644
index 0000000000..37bde2f7cd
--- /dev/null
+++ b/sysdeps/mips/rshift.S
@@ -0,0 +1,94 @@
+/* MIPS2 __mpn_rshift --
+
+Copyright (C) 1995 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP 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 MP 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 MP 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>
+
+/* INPUT PARAMETERS
+   res_ptr	$4
+   src_ptr	$5
+   size		$6
+   cnt		$7
+*/
+#ifdef PIC
+	.option pic2
+#endif
+ENTRY (__mpn_rshift)
+	.set	noreorder
+#ifdef PIC
+	.cpload t9
+#endif
+	.set	nomacro
+
+	lw	$10,0($5)	/* load first limb */
+	subu	$13,$0,$7
+	addiu	$6,$6,-1
+	and	$9,$6,4-1	/* number of limbs in first loop */
+	beq	$9,$0,.L0	/* if multiple of 4 limbs, skip first loop*/
+	 sll	$2,$10,$13	/* compute function result */
+
+	subu	$6,$6,$9
+
+.Loop0:	lw	$3,4($5)
+	addiu	$4,$4,4
+	addiu	$5,$5,4
+	addiu	$9,$9,-1
+	srl	$11,$10,$7
+	sll	$12,$3,$13
+	move	$10,$3
+	or	$8,$11,$12
+	bne	$9,$0,.Loop0
+	 sw	$8,-4($4)
+
+.L0:	beq	$6,$0,.Lend
+	 nop
+
+.Loop:	lw	$3,4($5)
+	addiu	$4,$4,16
+	addiu	$6,$6,-4
+	srl	$11,$10,$7
+	sll	$12,$3,$13
+
+	lw	$10,8($5)
+	srl	$14,$3,$7
+	or	$8,$11,$12
+	sw	$8,-16($4)
+	sll	$9,$10,$13
+
+	lw	$3,12($5)
+	srl	$11,$10,$7
+	or	$8,$14,$9
+	sw	$8,-12($4)
+	sll	$12,$3,$13
+
+	lw	$10,16($5)
+	srl	$14,$3,$7
+	or	$8,$11,$12
+	sw	$8,-8($4)
+	sll	$9,$10,$13
+
+	addiu	$5,$5,16
+	or	$8,$14,$9
+	bgtz	$6,.Loop
+	 sw	$8,-4($4)
+
+.Lend:	srl	$8,$10,$7
+	j	$31
+	sw	$8,0($4)
diff --git a/sysdeps/mips/rshift.s b/sysdeps/mips/rshift.s
deleted file mode 100644
index a8beb40577..0000000000
--- a/sysdeps/mips/rshift.s
+++ /dev/null
@@ -1,92 +0,0 @@
- # MIPS2 __mpn_rshift --
-
- # Copyright (C) 1995 Free Software Foundation, Inc.
-
- # This file is part of the GNU MP Library.
-
- # The GNU MP 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 MP 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 MP 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.
-
-
- # INPUT PARAMETERS
- # res_ptr	$4
- # src_ptr	$5
- # size		$6
- # cnt		$7
-
-	.text
-	.align	2
-	.globl	__mpn_rshift
-	.ent	__mpn_rshift
-__mpn_rshift:
-	.set	noreorder
-	.set	nomacro
-
-	lw	$10,0($5)	# load first limb
-	subu	$13,$0,$7
-	addiu	$6,$6,-1
-	and	$9,$6,4-1	# number of limbs in first loop
-	beq	$9,$0,.L0	# if multiple of 4 limbs, skip first loop
-	 sll	$2,$10,$13	# compute function result
-
-	subu	$6,$6,$9
-
-.Loop0:	lw	$3,4($5)
-	addiu	$4,$4,4
-	addiu	$5,$5,4
-	addiu	$9,$9,-1
-	srl	$11,$10,$7
-	sll	$12,$3,$13
-	move	$10,$3
-	or	$8,$11,$12
-	bne	$9,$0,.Loop0
-	 sw	$8,-4($4)
-
-.L0:	beq	$6,$0,.Lend
-	 nop
-
-.Loop:	lw	$3,4($5)
-	addiu	$4,$4,16
-	addiu	$6,$6,-4
-	srl	$11,$10,$7
-	sll	$12,$3,$13
-
-	lw	$10,8($5)
-	srl	$14,$3,$7
-	or	$8,$11,$12
-	sw	$8,-16($4)
-	sll	$9,$10,$13
-
-	lw	$3,12($5)
-	srl	$11,$10,$7
-	or	$8,$14,$9
-	sw	$8,-12($4)
-	sll	$12,$3,$13
-
-	lw	$10,16($5)
-	srl	$14,$3,$7
-	or	$8,$11,$12
-	sw	$8,-8($4)
-	sll	$9,$10,$13
-
-	addiu	$5,$5,16
-	or	$8,$14,$9
-	bgtz	$6,.Loop
-	 sw	$8,-4($4)
-
-.Lend:	srl	$8,$10,$7
-	j	$31
-	sw	$8,0($4)
-	.end	__mpn_rshift
diff --git a/sysdeps/mips/setjmp.S b/sysdeps/mips/setjmp.S
index 0f5dba3a60..bc42dcb03b 100644
--- a/sysdeps/mips/setjmp.S
+++ b/sysdeps/mips/setjmp.S
@@ -1,32 +1,35 @@
-/* Copyright (C) 1992, 1994 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
 
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+   The GNU C Library is 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 <sysdep.h>
 
 /* The function __sigsetjmp_aux saves all the registers, but it can't
    reliably access the stack or frame pointers, so we pass them in as
    extra arguments.  */
+#ifdef PIC
+	.option pic2
+#endif
 ENTRY (__sigsetjmp)
+#ifdef PIC
+	.cpload t9
+#endif
 	move a2, sp
-#ifdef __sgi__
 	move a3, fp
-#else
-	move a3, $fp
-#endif
-	j __sigsetjmp_aux
-	.end __sigsetjmp
+	la t9, __sigsetjmp_aux
+	nop
+	jr t9
diff --git a/sysdeps/mips/setjmp_aux.c b/sysdeps/mips/setjmp_aux.c
index d478e3fdc9..d06732efc2 100644
--- a/sysdeps/mips/setjmp_aux.c
+++ b/sysdeps/mips/setjmp_aux.c
@@ -1,20 +1,21 @@
-/* Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
    Contributed by Brendan Kehoe (brendan@zen.org).
 
-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 <setjmp.h>
 
diff --git a/sysdeps/mips/sub_n.S b/sysdeps/mips/sub_n.S
new file mode 100644
index 0000000000..09fbf7eeff
--- /dev/null
+++ b/sysdeps/mips/sub_n.S
@@ -0,0 +1,121 @@
+/* MIPS2 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
+store difference in a third limb vector.
+
+Copyright (C) 1995 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP 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 MP 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 MP 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>
+
+/* INPUT PARAMETERS
+   res_ptr	$4
+   s1_ptr	$5
+   s2_ptr	$6
+   size		$7
+*/
+#ifdef PIC
+	.option pic2
+#endif
+ENTRY (__mpn_sub_n)
+	.set	noreorder
+#ifdef PIC
+	.cpload t9
+#endif
+	.set	nomacro
+
+	lw	$10,0($5)
+	lw	$11,0($6)
+
+	addiu	$7,$7,-1
+	and	$9,$7,4-1	/* number of limbs in first loop */
+	beq	$9,$0,.L0	/* if multiple of 4 limbs, skip first loop */
+	 move	$2,$0
+
+	subu	$7,$7,$9
+
+.Loop0:	addiu	$9,$9,-1
+	lw	$12,4($5)
+	addu	$11,$11,$2
+	lw	$13,4($6)
+	sltu	$8,$11,$2
+	subu	$11,$10,$11
+	sltu	$2,$10,$11
+	sw	$11,0($4)
+	or	$2,$2,$8
+
+	addiu	$5,$5,4
+	addiu	$6,$6,4
+	move	$10,$12
+	move	$11,$13
+	bne	$9,$0,.Loop0
+	 addiu	$4,$4,4
+
+.L0:	beq	$7,$0,.Lend
+	 nop
+
+.Loop:	addiu	$7,$7,-4
+
+	lw	$12,4($5)
+	addu	$11,$11,$2
+	lw	$13,4($6)
+	sltu	$8,$11,$2
+	subu	$11,$10,$11
+	sltu	$2,$10,$11
+	sw	$11,0($4)
+	or	$2,$2,$8
+
+	lw	$10,8($5)
+	addu	$13,$13,$2
+	lw	$11,8($6)
+	sltu	$8,$13,$2
+	subu	$13,$12,$13
+	sltu	$2,$12,$13
+	sw	$13,4($4)
+	or	$2,$2,$8
+
+	lw	$12,12($5)
+	addu	$11,$11,$2
+	lw	$13,12($6)
+	sltu	$8,$11,$2
+	subu	$11,$10,$11
+	sltu	$2,$10,$11
+	sw	$11,8($4)
+	or	$2,$2,$8
+
+	lw	$10,16($5)
+	addu	$13,$13,$2
+	lw	$11,16($6)
+	sltu	$8,$13,$2
+	subu	$13,$12,$13
+	sltu	$2,$12,$13
+	sw	$13,12($4)
+	or	$2,$2,$8
+
+	addiu	$5,$5,16
+	addiu	$6,$6,16
+
+	bne	$7,$0,.Loop
+	 addiu	$4,$4,16
+
+.Lend:	addu	$11,$11,$2
+	sltu	$8,$11,$2
+	subu	$11,$10,$11
+	sltu	$2,$10,$11
+	sw	$11,0($4)
+	j	$31
+	or	$2,$2,$8
diff --git a/sysdeps/mips/sub_n.s b/sysdeps/mips/sub_n.s
deleted file mode 100644
index 3368ef29d6..0000000000
--- a/sysdeps/mips/sub_n.s
+++ /dev/null
@@ -1,120 +0,0 @@
- # MIPS2 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
- # store difference in a third limb vector.
-
- # Copyright (C) 1995 Free Software Foundation, Inc.
-
- # This file is part of the GNU MP Library.
-
- # The GNU MP 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 MP 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 MP 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.
-
-
- # INPUT PARAMETERS
- # res_ptr	$4
- # s1_ptr	$5
- # s2_ptr	$6
- # size		$7
-
-	.text
-	.align	2
-	.globl	__mpn_sub_n
-	.ent	__mpn_sub_n
-__mpn_sub_n:
-	.set	noreorder
-	.set	nomacro
-
-	lw	$10,0($5)
-	lw	$11,0($6)
-
-	addiu	$7,$7,-1
-	and	$9,$7,4-1	# number of limbs in first loop
-	beq	$9,$0,.L0	# if multiple of 4 limbs, skip first loop
-	 move	$2,$0
-
-	subu	$7,$7,$9
-
-.Loop0:	addiu	$9,$9,-1
-	lw	$12,4($5)
-	addu	$11,$11,$2
-	lw	$13,4($6)
-	sltu	$8,$11,$2
-	subu	$11,$10,$11
-	sltu	$2,$10,$11
-	sw	$11,0($4)
-	or	$2,$2,$8
-
-	addiu	$5,$5,4
-	addiu	$6,$6,4
-	move	$10,$12
-	move	$11,$13
-	bne	$9,$0,.Loop0
-	 addiu	$4,$4,4
-
-.L0:	beq	$7,$0,.Lend
-	 nop
-
-.Loop:	addiu	$7,$7,-4
-
-	lw	$12,4($5)
-	addu	$11,$11,$2
-	lw	$13,4($6)
-	sltu	$8,$11,$2
-	subu	$11,$10,$11
-	sltu	$2,$10,$11
-	sw	$11,0($4)
-	or	$2,$2,$8
-
-	lw	$10,8($5)
-	addu	$13,$13,$2
-	lw	$11,8($6)
-	sltu	$8,$13,$2
-	subu	$13,$12,$13
-	sltu	$2,$12,$13
-	sw	$13,4($4)
-	or	$2,$2,$8
-
-	lw	$12,12($5)
-	addu	$11,$11,$2
-	lw	$13,12($6)
-	sltu	$8,$11,$2
-	subu	$11,$10,$11
-	sltu	$2,$10,$11
-	sw	$11,8($4)
-	or	$2,$2,$8
-
-	lw	$10,16($5)
-	addu	$13,$13,$2
-	lw	$11,16($6)
-	sltu	$8,$13,$2
-	subu	$13,$12,$13
-	sltu	$2,$12,$13
-	sw	$13,12($4)
-	or	$2,$2,$8
-
-	addiu	$5,$5,16
-	addiu	$6,$6,16
-
-	bne	$7,$0,.Loop
-	 addiu	$4,$4,16
-
-.Lend:	addu	$11,$11,$2
-	sltu	$8,$11,$2
-	subu	$11,$10,$11
-	sltu	$2,$10,$11
-	sw	$11,0($4)
-	j	$31
-	or	$2,$2,$8
-
-	.end	__mpn_sub_n
diff --git a/sysdeps/mips/submul_1.S b/sysdeps/mips/submul_1.S
new file mode 100644
index 0000000000..eae8ebbfaf
--- /dev/null
+++ b/sysdeps/mips/submul_1.S
@@ -0,0 +1,98 @@
+/* MIPS __mpn_submul_1 -- Multiply a limb vector with a single limb and
+subtract the product from a second limb vector.
+
+Copyright (C) 1995 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP 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 MP 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 MP 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>
+
+/* INPUT PARAMETERS
+   res_ptr	$4
+   s1_ptr	$5
+   size		$6
+   s2_limb	$7
+*/
+#ifdef PIC
+	.option pic2
+#endif
+ENTRY (__mpn_submul_1)
+	.set    noreorder
+#ifdef PIC
+	.cpload t9
+#endif
+	.set    nomacro
+
+	/* warm up phase 0 */
+	lw	$8,0($5)
+
+	/* warm up phase 1 */
+	addiu	$5,$5,4
+	multu	$8,$7
+
+	addiu	$6,$6,-1
+	beq	$6,$0,$LC0
+	move	$2,$0		/* zero cy2 */
+
+	addiu	$6,$6,-1
+	beq	$6,$0,$LC1
+	lw	$8,0($5)	/* load new s1 limb as early as possible */
+
+Loop:	lw	$10,0($4)
+	mflo	$3
+	mfhi	$9
+	addiu	$5,$5,4
+	addu	$3,$3,$2	/* add old carry limb to low product limb */
+	multu	$8,$7
+	lw	$8,0($5)	/* load new s1 limb as early as possible */
+	addiu	$6,$6,-1	/* decrement loop counter */
+	sltu	$2,$3,$2	/* carry from previous addition -> $2 */
+	subu	$3,$10,$3
+	sgtu	$10,$3,$10
+	addu	$2,$2,$10
+	sw	$3,0($4)
+	addiu	$4,$4,4
+	bne	$6,$0,Loop	/* should be "bnel" */
+	addu	$2,$9,$2	/* add high product limb and carry from addition */
+
+	/* cool down phase 1 */
+$LC1:	lw	$10,0($4)
+	mflo	$3
+	mfhi	$9
+	addu	$3,$3,$2
+	sltu	$2,$3,$2
+	multu	$8,$7
+	subu	$3,$10,$3
+	sgtu	$10,$3,$10
+	addu	$2,$2,$10
+	sw	$3,0($4)
+	addiu	$4,$4,4
+	addu	$2,$9,$2	/* add high product limb and carry from addition */
+
+	/* cool down phase 0 */
+$LC0:	lw	$10,0($4)
+	mflo	$3
+	mfhi	$9
+	addu	$3,$3,$2
+	sltu	$2,$3,$2
+	subu	$3,$10,$3
+	sgtu	$10,$3,$10
+	addu	$2,$2,$10
+	sw	$3,0($4)
+	j	$31
+	addu	$2,$9,$2	/* add high product limb and carry from addition */
diff --git a/sysdeps/mips/submul_1.s b/sysdeps/mips/submul_1.s
deleted file mode 100644
index 1324b66090..0000000000
--- a/sysdeps/mips/submul_1.s
+++ /dev/null
@@ -1,97 +0,0 @@
- # MIPS __mpn_submul_1 -- Multiply a limb vector with a single limb and
- # subtract the product from a second limb vector.
-
- # Copyright (C) 1992, 1994, 1996 Free Software Foundation, Inc.
-
- # This file is part of the GNU MP Library.
-
- # The GNU MP 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 MP 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 MP 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.
-
-
- # INPUT PARAMETERS
- # res_ptr	$4
- # s1_ptr	$5
- # size		$6
- # s2_limb	$7
-
-	.text
-	.align	 4
-	.globl	 __mpn_submul_1
-	.ent	__mpn_submul_1
-__mpn_submul_1:
-	.set    noreorder
-	.set    nomacro
-
- # warm up phase 0
-	lw	$8,0($5)
-
- # warm up phase 1
-	addiu	$5,$5,4
-	multu	$8,$7
-
-	addiu	$6,$6,-1
-	beq	$6,$0,$LC0
-	 move	$2,$0		# zero cy2
-
-	addiu	$6,$6,-1
-	beq	$6,$0,$LC1
-	lw	$8,0($5)	# load new s1 limb as early as possible
-
-Loop:	lw	$10,0($4)
-	mflo	$3
-	mfhi	$9
-	addiu	$5,$5,4
-	addu	$3,$3,$2	# add old carry limb to low product limb
-	multu	$8,$7
-	lw	$8,0($5)	# load new s1 limb as early as possible
-	addiu	$6,$6,-1	# decrement loop counter
-	sltu	$2,$3,$2	# carry from previous addition -> $2
-	subu	$3,$10,$3
-	sgtu	$10,$3,$10
-	addu	$2,$2,$10
-	sw	$3,0($4)
-	addiu	$4,$4,4
-	bne	$6,$0,Loop
-	 addu	$2,$9,$2	# add high product limb and carry from addition
-
- # cool down phase 1
-$LC1:	lw	$10,0($4)
-	mflo	$3
-	mfhi	$9
-	addu	$3,$3,$2
-	sltu	$2,$3,$2
-	multu	$8,$7
-	subu	$3,$10,$3
-	sgtu	$10,$3,$10
-	addu	$2,$2,$10
-	sw	$3,0($4)
-	addiu	$4,$4,4
-	addu	$2,$9,$2	# add high product limb and carry from addition
-
- # cool down phase 0
-$LC0:	lw	$10,0($4)
-	mflo	$3
-	mfhi	$9
-	addu	$3,$3,$2
-	sltu	$2,$3,$2
-	subu	$3,$10,$3
-	sgtu	$10,$3,$10
-	addu	$2,$2,$10
-	sw	$3,0($4)
-	j	$31
-	addu	$2,$9,$2	# add high product limb and carry from addition
-
-	.end	__mpn_submul_1
diff --git a/sysdeps/posix/Makefile b/sysdeps/posix/Makefile
index a47f77af32..358114a921 100644
--- a/sysdeps/posix/Makefile
+++ b/sysdeps/posix/Makefile
@@ -20,13 +20,13 @@ ifneq (yes,$(inhibit-stdio_lim))
 # Disable these rules if we generate stdio_lim.h by other means.
 
 ifeq (yes,$(cross-compiling))
-$(common-objpfx)stdio_lim.h:
+$(common-objpfx)bits/stdio_lim.h:
 	@echo
-	@echo "You must build stdio_lim.h by hand.  Stop."
+	@echo "You must build <bits/stdio_lim.h> by hand.  Stop."
 	@echo
 	@exit 1
 else
-$(common-objpfx)stdio_lim.h: $(common-objpfx)mk-stdiolim
+$(common-objpfx)bits/stdio_lim.h: $(common-objpfx)mk-stdiolim
 	$(dir $<)$(notdir $<) > $@-t
 	mv $@-t $@
 endif
@@ -36,10 +36,10 @@ mk-stdiolim-CFLAGS = $(patsubst -I$(shell pwd)//%,-I/%,\
 				$(patsubst -I%,-I$(shell pwd)/%,$(+includes)))
 # $(ALL_BUILD_CFLAGS) needs to come last because it contains unwanted -Is.
 $(common-objpfx)mk-stdiolim: $(sysdep_dir)/posix/mk-stdiolim.c \
-			     $(..)posix/posix1_lim.h local_lim.h
+			     $(..)posix/bits/posix1_lim.h bits/local_lim.h
 	$(common-objdir-compile)
 
-common-generated := $(common-generated) stdio_lim.h mk-stdiolim
-before-compile := $(before-compile) $(common-objpfx)stdio_lim.h
+common-generated := $(common-generated) bits/stdio_lim.h mk-stdiolim
+before-compile := $(before-compile) $(common-objpfx)bits/stdio_lim.h
 
 endif # inhibit-stdio_lim
diff --git a/sysdeps/posix/mk-stdiolim.c b/sysdeps/posix/mk-stdiolim.c
index 5df460e89a..a129f2b4f9 100644
--- a/sysdeps/posix/mk-stdiolim.c
+++ b/sysdeps/posix/mk-stdiolim.c
@@ -16,7 +16,7 @@ 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.  */
 
-#include <posix1_lim.h>
+#include <bits/posix1_lim.h>
 
 int
 main()
@@ -32,9 +32,9 @@ main()
   puts  ("#endif");
 
   /* POSIX does not require that OPEN_MAX and PATH_MAX be defined, so
-     <local_lim.h> will not define them if they are run-time variant (which
-     is the case in the Hurd).  ANSI still requires that FOPEN_MAX and
-     FILENAME_MAX be defined, however.  */
+     <bits/local_lim.h> will not define them if they are run-time
+     variant (which is the case in the Hurd).  ANSI still requires
+     that FOPEN_MAX and FILENAME_MAX be defined, however.  */
 
   printf("#define FOPEN_MAX %u\n",
 #ifdef	OPEN_MAX
diff --git a/sysdeps/powerpc/__longjmp.S b/sysdeps/powerpc/__longjmp.S
index 02292a0eb2..4a22fb8952 100644
--- a/sysdeps/powerpc/__longjmp.S
+++ b/sysdeps/powerpc/__longjmp.S
@@ -19,7 +19,7 @@
 
 #include <sysdep.h>
 #define _ASM
-#include <jmp_buf.h>
+#include <bits/setjmp.h>
 
 ENTRY (__longjmp)
 	lwz %r1,(JB_GPR1*4)(%r3)
diff --git a/sysdeps/powerpc/fenvbits.h b/sysdeps/powerpc/bits/fenv.h
index 8acd0ab8a4..9158a54586 100644
--- a/sysdeps/powerpc/fenvbits.h
+++ b/sysdeps/powerpc/bits/fenv.h
@@ -16,10 +16,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-/* This file should never be included directly.  */
+#ifndef _FENV_H
+# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
 
-#ifndef _FENVBITS_H
-#define _FENVBITS_H	1
 
 /* Define bits representing the exception.  We use the bit positions of
    the appropriate bits in the FPSCR...  */
@@ -126,5 +126,3 @@ extern const fenv_t __fe_dfl_env;
 extern const fenv_t __fe_nomask_env;
 # define FE_NOMASK_ENV	(&__fe_nomask_env);
 #endif
-
-#endif /* fenvbits.h */
diff --git a/sysdeps/powerpc/mathbits.h b/sysdeps/powerpc/bits/mathdef.h
index 2cecb6fa88..c0e6caa843 100644
--- a/sysdeps/powerpc/mathbits.h
+++ b/sysdeps/powerpc/bits/mathdef.h
@@ -16,8 +16,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _MATHBITS_H
-#define _MATHBITS_H	1
+#ifndef _MATH_H
+#error "Never use <bits/mathdef.h> directly; include <math.h> instead"
+#endif
+
 
 /* FIXME! This file describes properties of the compiler, not the machine;
    it should not be part of libc!
@@ -68,5 +70,3 @@ typedef double double_t;
 #define INFINITY	HUGE_VAL
 
 #endif
-
-#endif /* mathbits.h */
diff --git a/sysdeps/powerpc/__math.h b/sysdeps/powerpc/bits/mathinline.h
index db9688cfc5..db9688cfc5 100644
--- a/sysdeps/powerpc/__math.h
+++ b/sysdeps/powerpc/bits/mathinline.h
diff --git a/sysdeps/powerpc/jmp_buf.h b/sysdeps/powerpc/bits/setjmp.h
index df832b157c..a9cab03fc6 100644
--- a/sysdeps/powerpc/jmp_buf.h
+++ b/sysdeps/powerpc/bits/setjmp.h
@@ -1,6 +1,6 @@
 /* Define the machine-dependent type `jmp_buf'.  PowerPC version.  */
 
-/* The previous jmp_buf.h had __jmp_buf defined as a structure.
+/* The previous bits/setjmp.h had __jmp_buf defined as a structure.
    We use an array of 'long int' instead, to make writing the
    assembler easier. Naturally, user code should not depend on
    either representation. */
diff --git a/sysdeps/powerpc/dl-machine.h b/sysdeps/powerpc/dl-machine.h
index 17e8d9a12d..6ddbea584b 100644
--- a/sysdeps/powerpc/dl-machine.h
+++ b/sysdeps/powerpc/dl-machine.h
@@ -591,6 +591,10 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
     }
   else if (rinfo == R_PPC_COPY)
     {
+      if (sym == NULL)
+	/* This can happen in trace mode when an object could not be
+	   found.  */
+	return;
       if (sym->st_size > refsym->st_size
 	  || (_dl_verbose && sym->st_size < refsym->st_size))
 	{
diff --git a/sysdeps/powerpc/setjmp.S b/sysdeps/powerpc/setjmp.S
index af10581af0..ddfea7eed3 100644
--- a/sysdeps/powerpc/setjmp.S
+++ b/sysdeps/powerpc/setjmp.S
@@ -19,7 +19,7 @@
 
 #include <sysdep.h>
 #define _ASM
-#include <jmp_buf.h>
+#include <bits/setjmp.h>
 
 ENTRY (__sigsetjmp)
 	stw  %r1,(JB_GPR1*4)(3)
diff --git a/sysdeps/sparc/__longjmp.S b/sysdeps/sparc/__longjmp.S
index 5424300fe5..36e1c170dd 100644
--- a/sysdeps/sparc/__longjmp.S
+++ b/sysdeps/sparc/__longjmp.S
@@ -1,25 +1,25 @@
-/* Copyright (C) 1991, 1993, 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1991, 1993, 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 <sysdep.h>
 
 #define _ASM 1
-#include <jmp_buf.h>
+#include <bits/setjmp.h>
 #define ENV(reg) [%g1 + (reg * 4)]
 
 ENTRY (__longjmp)
diff --git a/sysdeps/sparc/bytesex.h b/sysdeps/sparc/bits/endian.h
index f1a75c0652..f1a75c0652 100644
--- a/sysdeps/sparc/bytesex.h
+++ b/sysdeps/sparc/bits/endian.h
diff --git a/sysdeps/sparc/jmp_buf.h b/sysdeps/sparc/bits/setjmp.h
index 43bae1a496..43bae1a496 100644
--- a/sysdeps/sparc/jmp_buf.h
+++ b/sysdeps/sparc/bits/setjmp.h
diff --git a/sysdeps/sparc/setjmp.S b/sysdeps/sparc/setjmp.S
index 84c63542cc..b80a83046e 100644
--- a/sysdeps/sparc/setjmp.S
+++ b/sysdeps/sparc/setjmp.S
@@ -19,7 +19,7 @@
 #include <sysdep.h>
 
 #define _ASM 1
-#include <jmp_buf.h>
+#include <bits/setjmp.h>
 
 ENTRY (__sigsetjmp)
 	/* Save our SP and FP; in the delay slot of the jump, save our
diff --git a/sysdeps/standalone/arm/errnos.h b/sysdeps/standalone/arm/bits/errno.h
index 8090a8074d..8090a8074d 100644
--- a/sysdeps/standalone/arm/errnos.h
+++ b/sysdeps/standalone/arm/bits/errno.h
diff --git a/sysdeps/standalone/stdio_lim.h b/sysdeps/standalone/bits/stdio_lim.h
index 5552bc4325..5552bc4325 100644
--- a/sysdeps/standalone/stdio_lim.h
+++ b/sysdeps/standalone/bits/stdio_lim.h
diff --git a/sysdeps/standalone/close.c b/sysdeps/standalone/close.c
index 7ef1a5f878..2d92937ec1 100644
--- a/sysdeps/standalone/close.c
+++ b/sysdeps/standalone/close.c
@@ -22,7 +22,7 @@ Cambridge, MA 02139, USA.  */
 #include <errno.h>
 #include <unistd.h>
 
-#include <stdio_lim.h>
+#include <bits/stdio_lim.h>
 #include "filedesc.h"
 
 /* Close the file descriptor FD.  */
diff --git a/sysdeps/standalone/filedesc.h b/sysdeps/standalone/filedesc.h
index bf3b6a9f0c..e4b8d6545e 100644
--- a/sysdeps/standalone/filedesc.h
+++ b/sysdeps/standalone/filedesc.h
@@ -27,7 +27,7 @@ Cambridge, MA 02139, USA.  */
 #ifndef __FILEDESC_h
 #define __FILEDESC_h
 
-#include <stdio_lim.h>
+#include <bits/stdio_lim.h>
 
 #ifndef __DECLARE_FILE_DESCRIPTORS__
 #define FILEDESC_EXTERN extern
diff --git a/sysdeps/standalone/open.c b/sysdeps/standalone/open.c
index 87097d9cb0..b61b729ca6 100644
--- a/sysdeps/standalone/open.c
+++ b/sysdeps/standalone/open.c
@@ -25,7 +25,7 @@ Cambridge, MA 02139, USA.  */
 #include <stddef.h>
 
 #include <stdio.h>
-#include <stdio_lim.h>
+#include <bits/stdio_lim.h>
 #include <unistd.h>
 
 #define __DECLARE_FILE_DESCRIPTORS__
diff --git a/sysdeps/stub/direntry.h b/sysdeps/stub/bits/dirent.h
index 2f7dca78aa..2f7dca78aa 100644
--- a/sysdeps/stub/direntry.h
+++ b/sysdeps/stub/bits/dirent.h
diff --git a/sysdeps/stub/elfclass.h b/sysdeps/stub/bits/elfclass.h
index 1ad12954b2..1ad12954b2 100644
--- a/sysdeps/stub/elfclass.h
+++ b/sysdeps/stub/bits/elfclass.h
diff --git a/sysdeps/stub/bytesex.h b/sysdeps/stub/bits/endian.h
index 238a082bad..597f079a0f 100644
--- a/sysdeps/stub/bytesex.h
+++ b/sysdeps/stub/bits/endian.h
@@ -1,9 +1,9 @@
 /* This file should define __BYTE_ORDER as appropriate for the machine
    in question.  See string/endian.h for how to define it.
 
-   If only the stub bytesex.h applies to a particular configuration,
+   If only the stub bits/endian.h applies to a particular configuration,
    bytesex.h is generated by running a program on the host machine.
    So if cross-compiling to a machine with a different byte order,
-   the bytesex.h file for that machine must exist.  */
+   the bits/endian.h file for that machine must exist.  */
 
 #error Machine byte order unknown.
diff --git a/sysdeps/stub/errnos.h b/sysdeps/stub/bits/errno.h
index 0a0f80a19d..0a0f80a19d 100644
--- a/sysdeps/stub/errnos.h
+++ b/sysdeps/stub/bits/errno.h
diff --git a/sysdeps/stub/fcntlbits.h b/sysdeps/stub/bits/fcntl.h
index 48237f53c6..24a1c38be6 100644
--- a/sysdeps/stub/fcntlbits.h
+++ b/sysdeps/stub/bits/fcntl.h
@@ -19,9 +19,9 @@
 
 /* These values should be changed as appropriate for your system.  */
 
-#ifndef	_FCNTLBITS_H
-
-#define	_FCNTLBITS_H	1
+#ifndef	_FCNTL_H
+#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
 
 
 /* File access modes for `open' and `fcntl'.  */
@@ -66,7 +66,7 @@
 #define	FD_CLOEXEC	1	/* Close on exec.  */
 
 
-#include <gnu/types.h>
+#include <bits/types.h>
 
 /* The structure describing an advisory lock.  This is the type of the third
    argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests.  */
@@ -83,6 +83,3 @@ struct flock
 #define	F_RDLCK	1	/* Read lock.  */
 #define	F_WRLCK	2	/* Write lock.  */
 #define	F_UNLCK	3	/* Remove lock.  */
-
-
-#endif	/* fcntlbits.h */
diff --git a/sysdeps/stub/fenvbits.h b/sysdeps/stub/bits/fenv.h
index cb8868cc70..f45deb07c1 100644
--- a/sysdeps/stub/fenvbits.h
+++ b/sysdeps/stub/bits/fenv.h
@@ -16,10 +16,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-/* This file should never be included directly.  */
+#ifndef _FENV_H
+#error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
 
-#ifndef _FENVBITS_H
-#define _FENVBITS_H	1
 
 /* Here should be the exception be defined:
     FE_INVALID
@@ -59,5 +59,3 @@ fenv_t;
 
 /* If the default argument is used we use this value.  */
 #define FE_DFL_ENV	((fenv_t *) -1l)
-
-#endif /* fenvbits.h */
diff --git a/sysdeps/stub/huge_val.h b/sysdeps/stub/bits/huge_val.h
index 18e96b14fb..8f137d1734 100644
--- a/sysdeps/stub/huge_val.h
+++ b/sysdeps/stub/bits/huge_val.h
@@ -18,9 +18,9 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	   _HUGE_VAL_H
-#define	   _HUGE_VAL_H	1
+#ifndef _MATH_H
+#error "Never use <bits/huge_val.h> directly; include <math.h> instead."
+#endif
 
-#define	   HUGE_VAL	1e37
 
-#endif	   /* huge_val.h */
+#define	   HUGE_VAL	1e37
diff --git a/sysdeps/stub/ioctls.h b/sysdeps/stub/bits/ioctls.h
index 3b6178bfae..3b6178bfae 100644
--- a/sysdeps/stub/ioctls.h
+++ b/sysdeps/stub/bits/ioctls.h
diff --git a/sysdeps/stub/sys/ipc_buf.h b/sysdeps/stub/bits/ipc.h
index a5ecbd90b7..a5ecbd90b7 100644
--- a/sysdeps/stub/sys/ipc_buf.h
+++ b/sysdeps/stub/bits/ipc.h
diff --git a/sysdeps/stub/libc-lock.h b/sysdeps/stub/bits/libc-lock.h
index 724b6e59d4..4261728b2c 100644
--- a/sysdeps/stub/libc-lock.h
+++ b/sysdeps/stub/bits/libc-lock.h
@@ -17,8 +17,8 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _LIBC_LOCK_H
-#define _LIBC_LOCK_H 1
+#ifndef _BITS_LIBC_LOCK_H
+#define _BITS_LIBC_LOCK_H 1
 
 
 /* Define a lock variable NAME with storage class CLASS.  The lock must be
@@ -80,4 +80,4 @@
 /* We need portable names for some of the functions.  */
 #define __libc_mutex_unlock
 
-#endif	/* libc-lock.h */
+#endif	/* bits/libc-lock.h */
diff --git a/sysdeps/stub/local_lim.h b/sysdeps/stub/bits/local_lim.h
index 42cc7ebbc9..42cc7ebbc9 100644
--- a/sysdeps/stub/local_lim.h
+++ b/sysdeps/stub/bits/local_lim.h
diff --git a/sysdeps/stub/__math.h b/sysdeps/stub/bits/mathinline.h
index 8159c89b94..8159c89b94 100644
--- a/sysdeps/stub/__math.h
+++ b/sysdeps/stub/bits/mathinline.h
diff --git a/sysdeps/stub/bits/msq.h b/sysdeps/stub/bits/msq.h
new file mode 100644
index 0000000000..37daa9bf8c
--- /dev/null
+++ b/sysdeps/stub/bits/msq.h
@@ -0,0 +1,47 @@
+/* Copyright (C) 1995, 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.
+
+   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 _SYS_MSG_H
+#error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
+#endif
+
+
+#include <features.h>
+#include <sys/types.h>
+
+/* Define options for message queue functions.  */
+#define MSG_NOERROR	010000	/* no error if message is too big */
+
+__BEGIN_DECLS
+
+/* Structure of record for one message inside the kernel.
+   The type `struct __msg' is opaque.  */
+struct msqid_ds
+{
+  struct ipc_perm msg_perm;	/* structure describing operation permission */
+  __time_t msg_stime;		/* time of last msgsnd command */
+  __time_t msg_rtime;		/* time of last msgrcv command */
+  __time_t msg_ctime;		/* time of last change */
+  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() */
+};
+
+__END_DECLS
diff --git a/sysdeps/stub/bits/nan.h b/sysdeps/stub/bits/nan.h
new file mode 100644
index 0000000000..ab38168ea4
--- /dev/null
+++ b/sysdeps/stub/bits/nan.h
@@ -0,0 +1,5 @@
+#ifndef _MATH_H
+#error "Never use <bits/nan.h> directly; include <math.h> instead."
+#endif
+
+/* This file should define `NAN' on machines that have such things.  */
diff --git a/sysdeps/stub/posix_opt.h b/sysdeps/stub/bits/posix_opt.h
index 54f5a79aa2..54f5a79aa2 100644
--- a/sysdeps/stub/posix_opt.h
+++ b/sysdeps/stub/bits/posix_opt.h
diff --git a/sysdeps/stub/sys/sem_buf.h b/sysdeps/stub/bits/sem.h
index 278cdeb1e2..1d3e41bd56 100644
--- a/sysdeps/stub/sys/sem_buf.h
+++ b/sysdeps/stub/bits/sem.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.
 
@@ -17,8 +17,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _SYS_SEM_BUF_H
-#define _SYS_SEM_BUF_H
+#ifndef _SYS_SEM_H
+#error "Never use <bits/sem.h> directly; include <sys/sem.h> instead."
+#endif
+
 
 #include <features.h>
 #include <sys/types.h>
@@ -57,5 +59,3 @@ union semun
  };
 
 __END_DECLS
-
-#endif /* sys/sem_buf.h */
diff --git a/sysdeps/stub/jmp_buf.h b/sysdeps/stub/bits/setjmp.h
index 6620e5ab15..6620e5ab15 100644
--- a/sysdeps/stub/jmp_buf.h
+++ b/sysdeps/stub/bits/setjmp.h
diff --git a/sysdeps/stub/sys/shm_buf.h b/sysdeps/stub/bits/shm.h
index 45147d4b06..b41d0c1e86 100644
--- a/sysdeps/stub/sys/shm_buf.h
+++ b/sysdeps/stub/bits/shm.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.
 
@@ -17,8 +17,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _SYS_SHM_BUF_H
-#define _SYS_SHM_BUF_H
+#ifndef _SYS_SHM_H
+#error "Never use <bits/shm.h> directly; include <sys/shm.h> instead."
+#endif
+
 
 #include <features.h>
 #include <sys/types.h>
@@ -49,5 +51,3 @@ struct shmid_ds
 };
 
 __END_DECLS
-
-#endif /* sys/shm_buf.h */
diff --git a/sysdeps/stub/sigcontext.h b/sysdeps/stub/bits/sigcontext.h
index 18d599fa8a..18d599fa8a 100644
--- a/sysdeps/stub/sigcontext.h
+++ b/sysdeps/stub/bits/sigcontext.h
diff --git a/sysdeps/stub/signum.h b/sysdeps/stub/bits/signum.h
index 6b4693f64c..6b4693f64c 100644
--- a/sysdeps/stub/signum.h
+++ b/sysdeps/stub/bits/signum.h
diff --git a/sysdeps/stub/statbuf.h b/sysdeps/stub/bits/stat.h
index ab14e23bc5..dab0cd00cb 100644
--- a/sysdeps/stub/statbuf.h
+++ b/sysdeps/stub/bits/stat.h
@@ -16,14 +16,17 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+/*
+ * Never include this file directly; use <sys/stat.h> instead.
+ */
+
 /* This structure needs to be defined in accordance with the
    implementation of __stat, __fstat, and __lstat.  */
 
-#ifndef	_STATBUF_H
-
-#define	_STATBUF_H	1
+#ifndef	_BITS_STAT_H
+#define	_BITS_STAT_H	1
 
-#include <gnu/types.h>
+#include <bits/types.h>
 
 /* Structure describing file characteristics.  */
 struct stat
@@ -68,4 +71,4 @@ struct stat
 #define	__S_IEXEC	0100	/* Execute by owner.  */
 
 
-#endif /* statbuf.h */
+#endif /* bits/stat.h */
diff --git a/sysdeps/stub/stdio_lim.h b/sysdeps/stub/bits/stdio_lim.h
index 59b6a40ebe..59b6a40ebe 100644
--- a/sysdeps/stub/stdio_lim.h
+++ b/sysdeps/stub/bits/stdio_lim.h
diff --git a/sysdeps/stub/timebits.h b/sysdeps/stub/bits/time.h
index 45185cc356..e41a991b44 100644
--- a/sysdeps/stub/timebits.h
+++ b/sysdeps/stub/bits/time.h
@@ -1,5 +1,5 @@
 /* System-dependent timing definitions.  Stub version.
-   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
@@ -17,6 +17,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+/*
+ * Never include this file directly; use <time.h> instead.
+ */
+
 #ifdef __need_timeval
 # undef __need_timeval
 # ifndef _STRUCT_TIMEVAL
@@ -32,9 +36,9 @@ struct timeval
 #endif	/* need timeval */
 
 
-#ifndef _TIMEBITS_H
-#define	_TIMEBITS_H	1
+#ifndef _BITS_TIME_H
+#define	_BITS_TIME_H	1
 
 #define CLOCKS_PER_SEC 60
 
-#endif	/* timebits.h */
+#endif	/* bits/time.h */
diff --git a/sysdeps/stub/waitflags.h b/sysdeps/stub/bits/waitflags.h
index e8c9843339..127eb6ce4c 100644
--- a/sysdeps/stub/waitflags.h
+++ b/sysdeps/stub/bits/waitflags.h
@@ -1,5 +1,5 @@
 /* Definitions of flag bits for `waitpid' et al.
-   Copyright (C) 1992, 1996 Free Software Foundation, Inc.
+   Copyright (C) 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
@@ -17,12 +17,11 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_WAITFLAGS_H
+#ifndef _SYS_WAIT_H
+#error "Never use <bits/waitflags.h> directly; include <sys/wait.h> instead."
+#endif
 
-#define	_WAITFLAGS_H	1
 
 /* Bits in the third argument to `waitpid'.  */
 #define	WNOHANG		1	/* Don't block waiting.  */
 #define	WUNTRACED	2	/* Report status of stopped children.  */
-
-#endif	/* waitflags.h */
diff --git a/sysdeps/stub/nan.h b/sysdeps/stub/nan.h
deleted file mode 100644
index 9dd53415c8..0000000000
--- a/sysdeps/stub/nan.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef	_NAN_H
-#define	_NAN_H	1
-
-/* This file should define `NAN' on machines that have such things.  */
-
-#endif	/* nan.h */
diff --git a/sysdeps/stub/sys/msq_buf.h b/sysdeps/stub/sys/msq_buf.h
deleted file mode 100644
index 0222a652ab..0000000000
--- a/sysdeps/stub/sys/msq_buf.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Copyright (C) 1995 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
-
-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 _SYS_MSQ_BUF_H
-#define _SYS_MSQ_BUF_H
-
-#include <features.h>
-#include <sys/types.h>
-
-/* Define options for message queue functions.  */
-#define MSG_NOERROR	010000	/* no error if message is too big */
-
-__BEGIN_DECLS
-
-/* Structure of record for one message inside the kernel.
-   The type `struct __msg' is opaque.  */
-struct msqid_ds
-{
-  struct ipc_perm msg_perm;	/* structure describing operation permission */
-  __time_t msg_stime;		/* time of last msgsnd command */
-  __time_t msg_rtime;		/* time of last msgrcv command */
-  __time_t msg_ctime;		/* time of last change */
-  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() */
-};
-
-__END_DECLS
-
-#endif /* sys/msq_buf.h */
diff --git a/sysdeps/unix/Makefile b/sysdeps/unix/Makefile
index f51dc508a0..0e837ca2e7 100644
--- a/sysdeps/unix/Makefile
+++ b/sysdeps/unix/Makefile
@@ -20,7 +20,7 @@
 config-generated := $(config-generated) $(unix-generated)
 
 ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
-	$(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/local_lim.h))))))
+	$(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/bits/local_lim.h))))))
 
 ifneq (,$(wildcard $(sysincludedir)/sys/param.h))
 mk-local_lim-CFLAGS += -DHAVE_SYS_PARAM_H
@@ -32,13 +32,13 @@ ifneq (,$(wildcard $(sysincludedir)/limits.h))
 mk-local_lim-CFLAGS += -DHAVE_LIMITS_H
 endif
 
-$(common-objpfx)local_lim.h: $(common-objpfx)mk-local_lim
+$(common-objpfx)bits/local_lim.h: $(common-objpfx)mk-local_lim
 	$(dir $<)$(notdir $<) > $@-t
 	mv -f $@-t $@
 $(common-objpfx)mk-local_lim: $(sysdep_dir)/unix/mk-local_lim.c
 	$(common-objdir-compile)
 
-before-compile := $(before-compile) $(common-objpfx)local_lim.h
+before-compile := $(before-compile) $(common-objpfx)bits/local_lim.h
 common-generated := $(common-generated) local_lim.h mk-local_lim
 
 endif
@@ -51,8 +51,8 @@ before-compile := $(before-compile) $(common-objpfx)sys/param.h
 
 $(common-objpfx)sys/param.h: $(sysincludedir)/sys/param.h
 	$(make-target-directory)
-	(echo '#ifndef _GNU_SYS_PARAM_H';	\
-	 echo '#define _GNU_SYS_PARAM_H 1';	\
+	(echo '#ifndef _SYS_PARAM_H';	\
+	 echo '#define _SYS_PARAM_H 1';	\
 	 echo '#include <endian.h>';		\
 	 awk < $<			\
 	   '/^#define[ 	]*NULL/ { print "#ifndef NULL";	\
@@ -127,13 +127,13 @@ endif # misc
 endif # No sysdep sys/param.h.
 
 ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
-	$(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/errnos.h))))))
+	$(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/bits/errno.h))))))
 
 # These need to exist before any compiling is done,
 # so cpp doesn't instead find the stub versions.
-before-compile := $(before-compile) $(common-objpfx)errnos.h
+before-compile := $(before-compile) $(common-objpfx)bits/errno.h
 
-$(common-objpfx)errnos.h: $(common-objpfx)make-errnos
+$(common-objpfx)bits/errno.h: $(common-objpfx)make-errnos
 	$(dir $<)$(notdir $<) > $@-tmp
 	mv $@-tmp $@
 
@@ -156,11 +156,11 @@ common-generated := $(common-generated) \
 endif
 
 ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
-	$(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/ioctls.h))))))
+	$(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/bits/ioctls.h))))))
 
-before-compile := $(before-compile) $(common-objpfx)ioctls.h
+before-compile := $(before-compile) $(common-objpfx)bits/ioctls.h
 
-$(common-objpfx)ioctls.h: $(common-objpfx)make-ioctls
+$(common-objpfx)bits/ioctls.h: $(common-objpfx)make-ioctls
 	$(dir $<)$(notdir $<) > $@-tmp
 	mv $@-tmp $@
 
@@ -180,25 +180,26 @@ $(common-objpfx)make-ioctls.c: $(sysdep_dir)/unix/ioctls-tmpl.c \
 	mv $@T $@
 
 
-termbits.h := $(firstword $(wildcard $(+sysdep_dirs:%=%/termbits.h)))
-ifeq ($(termbits.h),$(sysdep_dir)/generic/termbits.h)
-termbits.h := # Ignore the generic version.
+bits_termios.h := $(firstword $(wildcard $(+sysdep_dirs:%=%/bits/termios.h)))
+ifeq ($(bits_termios.h),$(sysdep_dir)/generic/bits/termios.h)
+bits_termios.h := # Ignore the generic version.
 endif
 
-# If there is a system-specific <termbits.h> file, we want to omit all the
-# symbols it defines from ioctls.  Otherwise, both ioctls.h and termbits.h
-# would define them.  The system-specific <termbits.h> file presumably
-# defines them with the same values as we find from the system's headers.
-# We also want to omit from ioctls the symbols defined in our own
+# If there is a system-specific <bits/termios.h> file, we want to omit
+# all the symbols it defines from ioctls.  Otherwise, both
+# <bits/ioctls.h> and <bits/termios.h> would define them.  The
+# system-specific <bits/termios.h> file presumably defines them with
+# the same values as we find from the system's headers.  We also want
+# to omit from ioctls the symbols defined in our own
 # <sys/ttydefaults.h>, to avoid multiple definition conflicts.  We use
-# snarf-ioctls on these files to find what symbols we want to omit.  fgrep
-# -xv gives all lines which do not match in their entirety; without -x,
-# CSTOP's presence elided TIOCSTOP.
+# snarf-ioctls on these files to find what symbols we want to omit.
+# fgrep -xv gives all lines which do not match in their entirety;
+# without -x, CSTOP's presence elided TIOCSTOP.
 
 $(common-objpfx)ioctls: $(sysdep_dir)/unix/snarf-ioctls \
 			$(sysincludedir)/sys/ioctl.h $(ioctl-includes)
 	$(dir $<)$(notdir $<) $(filter-out $<,$^) \
-	| fgrep -xv "`($(dir $<)$(notdir $<) $(termbits.h) \
+	| fgrep -xv "`($(dir $<)$(notdir $<) $(bits_termios.h) \
 					     $(..)sysdeps/generic/sys/ttydefaults.h; \
 		      echo NULL) \
 		     | sort | uniq`" \
@@ -206,7 +207,7 @@ $(common-objpfx)ioctls: $(sysdep_dir)/unix/snarf-ioctls \
 	mv $@-tmp $@
 
 common-generated := $(common-generated) \
-		    ioctls.h ioctls make-ioctls make-ioctls.c
+		    bits/ioctls.h ioctls make-ioctls make-ioctls.c
 endif
 
 ifeq ($(subdir),stdio-common)
diff --git a/sysdeps/unix/bsd/direntry.h b/sysdeps/unix/bsd/bits/dirent.h
index 2f563ec306..2f563ec306 100644
--- a/sysdeps/unix/bsd/direntry.h
+++ b/sysdeps/unix/bsd/bits/dirent.h
diff --git a/sysdeps/unix/bsd/fcntlbits.h b/sysdeps/unix/bsd/bits/fcntl.h
index 1e87a379e4..3d9bcb5c60 100644
--- a/sysdeps/unix/bsd/fcntlbits.h
+++ b/sysdeps/unix/bsd/bits/fcntl.h
@@ -17,9 +17,9 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_FCNTLBITS_H
-
-#define	_FCNTLBITS_H	1
+#ifndef	_FCNTL_H
+#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
 
 
 /* File access modes for `open' and `fcntl'.  */
@@ -94,7 +94,7 @@
 #define	FD_CLOEXEC	1	/* Close on exec.  */
 
 
-#include <gnu/types.h>
+#include <bits/types.h>
 
 /* The structure describing an advisory lock.  This is the type of the third
    argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests.  */
@@ -112,6 +112,3 @@ struct flock
 #define	F_RDLCK	1	/* Read lock.  */
 #define	F_WRLCK	2	/* Write lock.  */
 #define	F_UNLCK	3	/* Remove lock.  */
-
-
-#endif	/* fcntlbits.h */
diff --git a/sysdeps/unix/bsd/posix_opt.h b/sysdeps/unix/bsd/bits/posix_opt.h
index 7d5e5782eb..7d5e5782eb 100644
--- a/sysdeps/unix/bsd/posix_opt.h
+++ b/sysdeps/unix/bsd/bits/posix_opt.h
diff --git a/sysdeps/unix/bsd/signum.h b/sysdeps/unix/bsd/bits/signum.h
index 775240fc05..775240fc05 100644
--- a/sysdeps/unix/bsd/signum.h
+++ b/sysdeps/unix/bsd/bits/signum.h
diff --git a/sysdeps/unix/bsd/statbuf.h b/sysdeps/unix/bsd/bits/stat.h
index c4a4e0964b..037433f388 100644
--- a/sysdeps/unix/bsd/statbuf.h
+++ b/sysdeps/unix/bsd/bits/stat.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1996 Free Software Foundation, Inc.
+/* 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
@@ -16,11 +16,14 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_STATBUF_H
+/*
+ * Never include this file directly; use <sys/stat.h> instead.
+ */
 
+#ifndef	_STATBUF_H
 #define	_STATBUF_H	1
 
-#include <gnu/types.h>
+#include <bits/types.h>
 
 /* Structure describing file characteristics.  */
 struct stat
@@ -81,4 +84,4 @@ struct stat
 #define	__S_IEXEC	0100	/* Execute by owner.  */
 
 
-#endif /* statbuf.h */
+#endif /* bits/stat.h */
diff --git a/sysdeps/unix/bsd/waitflags.h b/sysdeps/unix/bsd/bits/waitflags.h
index 00a1520db4..ca952f90b4 100644
--- a/sysdeps/unix/bsd/waitflags.h
+++ b/sysdeps/unix/bsd/bits/waitflags.h
@@ -1,5 +1,5 @@
 /* Definitions of flag bits for `waitpid' et al.  Hurd version.
-   Copyright (C) 1992, 1996 Free Software Foundation, Inc.
+   Copyright (C) 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
@@ -17,9 +17,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_WAITFLAGS_H
+#ifndef _SYS_WAIT_H
+#error "Never use <bits/waitflags.h> directly; include <sys/wait.h> instead."
+#endif
 
-#define	_WAITFLAGS_H	1
 
 /* Bits in the third argument to `waitpid'.  */
 #define	WNOHANG		1	/* Don't block waiting.  */
@@ -27,5 +28,3 @@
 #ifdef  __USE_GNU
 #define WNOREAP		4	/* Don't remove record of child reported.  */
 #endif
-
-#endif	/* waitflags.h */
diff --git a/sysdeps/unix/bsd/bsd4.4/direntry.h b/sysdeps/unix/bsd/bsd4.4/bits/dirent.h
index b9e0d7277e..b9e0d7277e 100644
--- a/sysdeps/unix/bsd/bsd4.4/direntry.h
+++ b/sysdeps/unix/bsd/bsd4.4/bits/dirent.h
diff --git a/sysdeps/unix/bsd/bsd4.4/errnos.h b/sysdeps/unix/bsd/bsd4.4/bits/errno.h
index c2a9c08413..c2a9c08413 100644
--- a/sysdeps/unix/bsd/bsd4.4/errnos.h
+++ b/sysdeps/unix/bsd/bsd4.4/bits/errno.h
diff --git a/sysdeps/unix/bsd/bsd4.4/fcntlbits.h b/sysdeps/unix/bsd/bsd4.4/bits/fcntl.h
index 3ab2bf027d..c00a0e80dd 100644
--- a/sysdeps/unix/bsd/bsd4.4/fcntlbits.h
+++ b/sysdeps/unix/bsd/bsd4.4/bits/fcntl.h
@@ -17,9 +17,9 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_FCNTLBITS_H
-
-#define	_FCNTLBITS_H	1
+#ifndef	_FCNTL_H
+#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
 
 
 /* File access modes for `open' and `fcntl'.  */
@@ -94,7 +94,7 @@
 #define	FD_CLOEXEC	1	/* Close on exec.  */
 
 
-#include <gnu/types.h>
+#include <bits/types.h>
 
 /* The structure describing an advisory lock.  This is the type of the third
    argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests.  */
@@ -111,6 +111,3 @@ struct flock
 #define	F_RDLCK	1	/* Read lock.  */
 #define	F_WRLCK	2	/* Write lock.  */
 #define	F_UNLCK	3	/* Remove lock.  */
-
-
-#endif	/* fcntlbits.h */
diff --git a/sysdeps/unix/bsd/bsd4.4/ioctls.h b/sysdeps/unix/bsd/bsd4.4/bits/ioctls.h
index 6c351f46a6..6c351f46a6 100644
--- a/sysdeps/unix/bsd/bsd4.4/ioctls.h
+++ b/sysdeps/unix/bsd/bsd4.4/bits/ioctls.h
diff --git a/sysdeps/unix/bsd/bsd4.4/sockaddrcom.h b/sysdeps/unix/bsd/bsd4.4/bits/sockaddr.h
index 87da37df90..d70dfe4031 100644
--- a/sysdeps/unix/bsd/bsd4.4/sockaddrcom.h
+++ b/sysdeps/unix/bsd/bsd4.4/bits/sockaddr.h
@@ -17,8 +17,12 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _SOCKADDRCOM_H
-#define _SOCKADDRCOM_H	1
+/*
+ * Never include this file directly; use <sys/socket.h> instead.
+ */
+
+#ifndef _BITS_SOCKADDR_H
+#define _BITS_SOCKADDR_H	1
 
 
 /* POSIX.1g specifies this type name for the `sa_family' member.  */
@@ -35,4 +39,4 @@ typedef unsigned char sa_family_t;
 #define __SOCKADDR_COMMON_SIZE	(2 * sizeof (unsigned char))
 
 
-#endif	/* sockaddrcom.h */
+#endif	/* bits/sockaddr.h */
diff --git a/sysdeps/unix/bsd/bsd4.4/tcgetattr.c b/sysdeps/unix/bsd/bsd4.4/tcgetattr.c
index d47443a335..29c7e28b8e 100644
--- a/sysdeps/unix/bsd/bsd4.4/tcgetattr.c
+++ b/sysdeps/unix/bsd/bsd4.4/tcgetattr.c
@@ -19,7 +19,7 @@
 #include <stddef.h>
 #include <termios.h>
 
-/* These are defined both in termbits.h and in ioctls.h.
+/* These are defined both in <bits/termios.h> and in <bits/ioctls.h>.
    They should have the same values, but perhaps not written the same way.  */
 #undef ECHO
 #undef MDMBUF
diff --git a/sysdeps/unix/bsd/bsd4.4/tcsetattr.c b/sysdeps/unix/bsd/bsd4.4/tcsetattr.c
index 7c09f90f0e..2e4b00b68d 100644
--- a/sysdeps/unix/bsd/bsd4.4/tcsetattr.c
+++ b/sysdeps/unix/bsd/bsd4.4/tcsetattr.c
@@ -20,7 +20,7 @@
 #include <stddef.h>
 #include <termios.h>
 
-/* These are defined both in termbits.h and in ioctls.h.
+/* These are defined both in <bits/termios.h> and in <bits/ioctls.h>.
    They should have the same values, but perhaps not written the same way.  */
 #undef ECHO
 #undef MDMBUF
diff --git a/sysdeps/unix/bsd/m68k/sysdep.S b/sysdeps/unix/bsd/m68k/sysdep.S
index cef8990eea..1be2d5a23f 100644
--- a/sysdeps/unix/bsd/m68k/sysdep.S
+++ b/sysdeps/unix/bsd/m68k/sysdep.S
@@ -17,7 +17,7 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
 #define _ERRNO_H
-#include <errnos.h>
+#include <bits/errno.h>
 
 .globl syscall_error
 syscall_error:
diff --git a/sysdeps/unix/bsd/osf/alpha/statbuf.h b/sysdeps/unix/bsd/osf/alpha/bits/stat.h
index 8541922b37..752d4eede1 100644
--- a/sysdeps/unix/bsd/osf/alpha/statbuf.h
+++ b/sysdeps/unix/bsd/osf/alpha/bits/stat.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Brendan Kehoe (brendan@zen.org).
 
@@ -17,10 +17,14 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_STATBUF_H
-#define	_STATBUF_H
+/*
+ * Never include this file directly; use <sys/stat.h> instead.
+ */
 
-#include <gnu/types.h>
+#ifndef	_BITS_STAT_H
+#define	_BITS_STAT_H
+
+#include <bits/types.h>
 
 /* Structure describing file characteristics.  */
 struct stat
@@ -73,4 +77,4 @@ struct stat
 #define	__S_IWRITE	0200	/* Write by owner.  */
 #define	__S_IEXEC	0100	/* Execute by owner.  */
 
-#endif	/* statbuf.h */
+#endif	/* bits/stat.h */
diff --git a/sysdeps/unix/bsd/osf/sigaction.h b/sysdeps/unix/bsd/osf/bits/sigaction.h
index df400d4aaa..df400d4aaa 100644
--- a/sysdeps/unix/bsd/osf/sigaction.h
+++ b/sysdeps/unix/bsd/osf/bits/sigaction.h
diff --git a/sysdeps/unix/bsd/osf/sys/mman.h b/sysdeps/unix/bsd/osf/sys/mman.h
index 6dc3e4e0cf..72846195d2 100644
--- a/sysdeps/unix/bsd/osf/sys/mman.h
+++ b/sysdeps/unix/bsd/osf/sys/mman.h
@@ -22,7 +22,7 @@
 #define	_SYS_MMAN_H	1
 #include <features.h>
 
-#include <gnu/types.h>
+#include <bits/types.h>
 #define __need_size_t
 #include <stddef.h>
 
diff --git a/sysdeps/unix/bsd/sun/signum.h b/sysdeps/unix/bsd/sun/bits/signum.h
index a327401d0b..a327401d0b 100644
--- a/sysdeps/unix/bsd/sun/signum.h
+++ b/sysdeps/unix/bsd/sun/bits/signum.h
diff --git a/sysdeps/unix/bsd/sun/m68k/sigcontext.h b/sysdeps/unix/bsd/sun/m68k/bits/sigcontext.h
index 471b516bdc..471b516bdc 100644
--- a/sysdeps/unix/bsd/sun/m68k/sigcontext.h
+++ b/sysdeps/unix/bsd/sun/m68k/bits/sigcontext.h
diff --git a/sysdeps/unix/bsd/sun/m68k/sethostid.S b/sysdeps/unix/bsd/sun/m68k/sethostid.S
index 8b30f3fe65..ab76d75f7b 100644
--- a/sysdeps/unix/bsd/sun/m68k/sethostid.S
+++ b/sysdeps/unix/bsd/sun/m68k/sethostid.S
@@ -25,7 +25,7 @@ SYSCALL (sethostid, 1)
 
 #else
 
-#include <errnos.h>
+#include <bits/errno.h>
 
 .globl _sethostid
 .even
diff --git a/sysdeps/unix/bsd/sun/sparc/sigcontext.h b/sysdeps/unix/bsd/sun/sparc/bits/sigcontext.h
index 290bf817af..290bf817af 100644
--- a/sysdeps/unix/bsd/sun/sparc/sigcontext.h
+++ b/sysdeps/unix/bsd/sun/sparc/bits/sigcontext.h
diff --git a/sysdeps/unix/bsd/sun/sparc/sethostid.S b/sysdeps/unix/bsd/sun/sparc/sethostid.S
index fbafba5277..f8ee805c75 100644
--- a/sysdeps/unix/bsd/sun/sparc/sethostid.S
+++ b/sysdeps/unix/bsd/sun/sparc/sethostid.S
@@ -25,9 +25,9 @@ SYSCALL (sethostid, 1)
 
 #else
 
-/* <errnos.h> only defines E* #ifdef _ERRNO_H.  */
+/* <bits/errno.h> only defines E* #ifdef _ERRNO_H.  */
 #define	_ERRNO_H
-#include <errnos.h>
+#include <bits/errno.h>
 
 ENTRY (sethostid)
 	mov ENOSYS, %o0
diff --git a/sysdeps/unix/bsd/sun/sunos4/fcntlbits.h b/sysdeps/unix/bsd/sun/sunos4/bits/fcntl.h
index a9f66c47a3..b74c80e170 100644
--- a/sysdeps/unix/bsd/sun/sunos4/fcntlbits.h
+++ b/sysdeps/unix/bsd/sun/sunos4/bits/fcntl.h
@@ -17,9 +17,9 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_FCNTLBITS_H
-
-#define	_FCNTLBITS_H	1
+#ifndef	_FCNTL_H
+#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
 
 
 /* File access modes for `open' and `fcntl'.  */
@@ -104,7 +104,7 @@
 #define	FD_CLOEXEC	1	/* Close on exec.  */
 
 
-#include <gnu/types.h>
+#include <bits/types.h>
 
 /* The structure describing an advisory lock.  This is the type of the third
    argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests.  */
@@ -140,6 +140,3 @@ struct eflock
 #define	F_RDLCK	1	/* Read lock.  */
 #define	F_WRLCK	2	/* Write lock.  */
 #define	F_UNLCK	3	/* Remove lock.  */
-
-
-#endif	/* fcntlbits.h */
diff --git a/sysdeps/unix/bsd/sun/sunos4/resourcebits.h b/sysdeps/unix/bsd/sun/sunos4/bits/resource.h
index ff55773e69..ff55773e69 100644
--- a/sysdeps/unix/bsd/sun/sunos4/resourcebits.h
+++ b/sysdeps/unix/bsd/sun/sunos4/bits/resource.h
diff --git a/sysdeps/unix/bsd/sun/sunos4/termbits.h b/sysdeps/unix/bsd/sun/sunos4/bits/termios.h
index dc0a007208..dc0a007208 100644
--- a/sysdeps/unix/bsd/sun/sunos4/termbits.h
+++ b/sysdeps/unix/bsd/sun/sunos4/bits/termios.h
diff --git a/sysdeps/unix/bsd/sun/sunos4/utsnamelen.h b/sysdeps/unix/bsd/sun/sunos4/bits/utsname.h
index e9111b6504..e9111b6504 100644
--- a/sysdeps/unix/bsd/sun/sunos4/utsnamelen.h
+++ b/sysdeps/unix/bsd/sun/sunos4/bits/utsname.h
diff --git a/sysdeps/unix/bsd/sun/sunos4/sys/mman.h b/sysdeps/unix/bsd/sun/sunos4/sys/mman.h
index fb38c34d90..65771a2aac 100644
--- a/sysdeps/unix/bsd/sun/sunos4/sys/mman.h
+++ b/sysdeps/unix/bsd/sun/sunos4/sys/mman.h
@@ -22,7 +22,7 @@
 #define	_SYS_MMAN_H	1
 #include <features.h>
 
-#include <gnu/types.h>
+#include <bits/types.h>
 #define __need_size_t
 #include <stddef.h>
 
diff --git a/sysdeps/unix/bsd/ultrix4/fcntlbits.h b/sysdeps/unix/bsd/ultrix4/bits/fcntl.h
index ba736e428e..1398b811ce 100644
--- a/sysdeps/unix/bsd/ultrix4/fcntlbits.h
+++ b/sysdeps/unix/bsd/ultrix4/bits/fcntl.h
@@ -17,9 +17,9 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_FCNTLBITS_H
-
-#define	_FCNTLBITS_H	1
+#ifndef	_FCNTL_H
+#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
 
 
 /* File access modes for `open' and `fcntl'.  */
@@ -103,7 +103,7 @@
 #define	FD_CLOEXEC	1	/* Close on exec.  */
 
 
-#include <gnu/types.h>
+#include <bits/types.h>
 
 /* The structure describing an advisory lock.  This is the type of the third
    argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests.  */
@@ -120,6 +120,3 @@ struct flock
 #define	F_RDLCK	1	/* Read lock.  */
 #define	F_WRLCK	2	/* Write lock.  */
 #define	F_UNLCK	3	/* Remove lock.  */
-
-
-#endif	/* fcntlbits.h */
diff --git a/sysdeps/unix/bsd/ultrix4/posix_opt.h b/sysdeps/unix/bsd/ultrix4/bits/posix_opt.h
index ecd04d1f0e..ecd04d1f0e 100644
--- a/sysdeps/unix/bsd/ultrix4/posix_opt.h
+++ b/sysdeps/unix/bsd/ultrix4/bits/posix_opt.h
diff --git a/sysdeps/unix/bsd/ultrix4/utsnamelen.h b/sysdeps/unix/bsd/ultrix4/bits/utsname.h
index ad4389ab02..ad4389ab02 100644
--- a/sysdeps/unix/bsd/ultrix4/utsnamelen.h
+++ b/sysdeps/unix/bsd/ultrix4/bits/utsname.h
diff --git a/sysdeps/unix/bsd/ultrix4/mips/sigcontext.h b/sysdeps/unix/bsd/ultrix4/mips/bits/sigcontext.h
index 4bddcf2f4b..4bddcf2f4b 100644
--- a/sysdeps/unix/bsd/ultrix4/mips/sigcontext.h
+++ b/sysdeps/unix/bsd/ultrix4/mips/bits/sigcontext.h
diff --git a/sysdeps/unix/bsd/ultrix4/sys/mman.h b/sysdeps/unix/bsd/ultrix4/sys/mman.h
index 2d3c8fe2ef..989bf21754 100644
--- a/sysdeps/unix/bsd/ultrix4/sys/mman.h
+++ b/sysdeps/unix/bsd/ultrix4/sys/mman.h
@@ -22,7 +22,7 @@
 #define	_SYS_MMAN_H	1
 #include <features.h>
 
-#include <gnu/types.h>
+#include <bits/types.h>
 #define __need_size_t
 #include <stddef.h>
 
diff --git a/sysdeps/unix/bsd/vax/sysdep.S b/sysdeps/unix/bsd/vax/sysdep.S
index 618d889742..b5b76aaba5 100644
--- a/sysdeps/unix/bsd/vax/sysdep.S
+++ b/sysdeps/unix/bsd/vax/sysdep.S
@@ -17,7 +17,7 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
 #define _ERRNO_H
-#include <errnos.h>
+#include <bits/errno.h>
 
 .globl _errno
 .globl syscall_error
diff --git a/sysdeps/unix/common/direntry.h b/sysdeps/unix/common/bits/dirent.h
index aa065474bf..aa065474bf 100644
--- a/sysdeps/unix/common/direntry.h
+++ b/sysdeps/unix/common/bits/dirent.h
diff --git a/sysdeps/unix/common/fcntlbits.h b/sysdeps/unix/common/bits/fcntl.h
index e416e0df13..31f213eab7 100644
--- a/sysdeps/unix/common/fcntlbits.h
+++ b/sysdeps/unix/common/bits/fcntl.h
@@ -17,9 +17,9 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_FCNTLBITS_H
-
-#define	_FCNTLBITS_H	1
+#ifndef	_FCNTL_H
+#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
 
 
 /* File access modes for `open' and `fcntl'.  */
@@ -98,7 +98,7 @@
 #define	FD_CLOEXEC	1	/* Close on exec.  */
 
 
-#include <gnu/types.h>
+#include <bits/types.h>
 
 /* The structure describing an advisory lock.  This is the type of the third
    argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests.  */
@@ -117,6 +117,3 @@ struct flock
 #define	F_RDLCK	1	/* Read lock.  */
 #define	F_WRLCK	2	/* Write lock.  */
 #define	F_UNLCK	3	/* Remove lock.  */
-
-
-#endif	/* fcntlbits.h */
diff --git a/sysdeps/unix/dirstream.h b/sysdeps/unix/dirstream.h
index cbbdb6b659..424627e740 100644
--- a/sysdeps/unix/dirstream.h
+++ b/sysdeps/unix/dirstream.h
@@ -22,7 +22,7 @@
 
 #include <sys/types.h>
 
-#include <libc-lock.h>
+#include <bits/libc-lock.h>
 
 /* Directory stream type.
 
diff --git a/sysdeps/unix/i386/sysdep.S b/sysdeps/unix/i386/sysdep.S
index a65589df72..b296bb707a 100644
--- a/sysdeps/unix/i386/sysdep.S
+++ b/sysdeps/unix/i386/sysdep.S
@@ -18,7 +18,7 @@
 
 #include <sysdep.h>
 #define _ERRNO_H
-#include <errnos.h>
+#include <bits/errno.h>
 
 .globl C_SYMBOL_NAME(errno)
 .globl syscall_error
diff --git a/sysdeps/unix/mips/sysdep.S b/sysdeps/unix/mips/sysdep.S
index f17ba44341..1791801ec5 100644
--- a/sysdeps/unix/mips/sysdep.S
+++ b/sysdeps/unix/mips/sysdep.S
@@ -18,7 +18,7 @@ Cambridge, MA 02139, USA.  */
 
 #include <sysdep.h>
 #define _ERRNO_H
-#include <errnos.h>
+#include <bits/errno.h>
 
 /* .globl errno */
 .set noreorder
diff --git a/sysdeps/unix/mk-local_lim.c b/sysdeps/unix/mk-local_lim.c
index b2212ee46d..27dfbc2dfc 100644
--- a/sysdeps/unix/mk-local_lim.c
+++ b/sysdeps/unix/mk-local_lim.c
@@ -31,7 +31,8 @@ Cambridge, MA 02139, USA.  */
 #include <sys/limits.h>
 #endif
 
-/* Generate local_lim.h from the values defined in the system's headers.  */
+/* Generate bits/local_lim.h from the values defined in the system's
+   headers.  */
 
 struct param
   {
diff --git a/sysdeps/unix/sparc/sysdep.S b/sysdeps/unix/sparc/sysdep.S
index d04a778794..5eea06939e 100644
--- a/sysdeps/unix/sparc/sysdep.S
+++ b/sysdeps/unix/sparc/sysdep.S
@@ -18,7 +18,7 @@ Cambridge, MA 02139, USA.  */
 
 #include <sysdep.h>
 #define _ERRNO_H
-#include <errnos.h>
+#include <bits/errno.h>
 
 .global C_SYMBOL_NAME(errno)
 .global syscall_error
diff --git a/sysdeps/unix/sysv/direntry.h b/sysdeps/unix/sysv/bits/dirent.h
index 5035f143ce..5035f143ce 100644
--- a/sysdeps/unix/sysv/direntry.h
+++ b/sysdeps/unix/sysv/bits/dirent.h
diff --git a/sysdeps/unix/sysv/fcntlbits.h b/sysdeps/unix/sysv/bits/fcntl.h
index 7f38422707..22863ffa5e 100644
--- a/sysdeps/unix/sysv/fcntlbits.h
+++ b/sysdeps/unix/sysv/bits/fcntl.h
@@ -17,9 +17,9 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_FCNTLBITS_H
-
-#define	_FCNTLBITS_H	1
+#ifndef	_FCNTL_H
+#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
 
 
 /* File access modes for `open' and `fcntl'.  */
@@ -64,7 +64,7 @@
 #define	FD_CLOEXEC	1	/* Close on exec.  */
 
 
-#include <gnu/types.h>
+#include <bits/types.h>
 
 /* The structure describing an advisory lock.  This is the type of the third
    argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests.  */
@@ -92,5 +92,3 @@ struct flock
 #define	FNONBLOCK	O_NONBLOCK
 #define	FNDELAY		O_NDELAY
 #endif /* Use BSD.  */
-
-#endif	/* fcntlbits.h */
diff --git a/sysdeps/unix/sysv/local_lim.h b/sysdeps/unix/sysv/bits/local_lim.h
index a370928484..a370928484 100644
--- a/sysdeps/unix/sysv/local_lim.h
+++ b/sysdeps/unix/sysv/bits/local_lim.h
diff --git a/sysdeps/unix/sysv/signum.h b/sysdeps/unix/sysv/bits/signum.h
index 088ca2a1be..088ca2a1be 100644
--- a/sysdeps/unix/sysv/signum.h
+++ b/sysdeps/unix/sysv/bits/signum.h
diff --git a/sysdeps/unix/sysv/statbuf.h b/sysdeps/unix/sysv/bits/stat.h
index f74943c19a..56f4544594 100644
--- a/sysdeps/unix/sysv/statbuf.h
+++ b/sysdeps/unix/sysv/bits/stat.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -16,8 +16,12 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_STATBUF_H
-#define	_STATBUF_H	1
+/*
+ * Never include this file directly; use <sys/stat.h> instead.
+ */
+
+#ifndef	_BITS_STAT_H
+#define	_BITS_STAT_H	1
 
 struct stat
   {
@@ -58,4 +62,4 @@ struct stat
 #define	__S_IWRITE	0200	/* Write by owner.  */
 #define	__S_IEXEC	0100	/* Execute by owner.  */
 
-#endif	/* statbuf.h */
+#endif	/* bits/stat.h */
diff --git a/sysdeps/unix/sysv/bits/utmp.h b/sysdeps/unix/sysv/bits/utmp.h
new file mode 100644
index 0000000000..1bb1a55873
--- /dev/null
+++ b/sysdeps/unix/sysv/bits/utmp.h
@@ -0,0 +1,57 @@
+/* The `struct utmp' type, describing entries in the utmp file.  System V.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef _UTMP_H
+#error "Never use <bits/utmp.h> directly; include <utmp.h> instead."
+#endif
+
+
+#include <time.h>
+
+#define _PATH_UTMP      "/var/adm/utmp"
+#define _PATH_WTMP      "/var/adm/wtmp"
+#define _PATH_LASTLOG   "/var/adm/lastlog"
+
+__BEGIN_DECLS
+
+struct utmp
+  {
+#define	ut_name	ut_user
+    char ut_user[8];
+    char ut_id[4];
+    char ut_line[12];
+    short ut_pid;
+    short ut_type;
+    struct exit_status
+      {
+	short e_termination;
+	short e_exit;
+      } ut_exit;
+    time_t ut_time;
+  };
+
+
+/* Tell the user that we have a modern system with UT_HOST, UT_TYPE, UT_ID
+   and UT_TV fields.  */
+#define _HAVE_UT_TYPE	1
+#define _HAVE_UT_ID	1
+#define _HAVE_UT_TV	1
+#define _HAVE_UT_HOST	1
+
+__END_DECLS
diff --git a/sysdeps/unix/sysv/utsnamelen.h b/sysdeps/unix/sysv/bits/utsname.h
index 31473cf4ea..31473cf4ea 100644
--- a/sysdeps/unix/sysv/utsnamelen.h
+++ b/sysdeps/unix/sysv/bits/utsname.h
diff --git a/sysdeps/unix/sysv/irix4/confname.h b/sysdeps/unix/sysv/irix4/bits/confname.h
index 49d2f9c989..49d2f9c989 100644
--- a/sysdeps/unix/sysv/irix4/confname.h
+++ b/sysdeps/unix/sysv/irix4/bits/confname.h
diff --git a/sysdeps/unix/sysv/irix4/fcntlbits.h b/sysdeps/unix/sysv/irix4/bits/fcntl.h
index 318e483279..a926d049ec 100644
--- a/sysdeps/unix/sysv/irix4/fcntlbits.h
+++ b/sysdeps/unix/sysv/irix4/bits/fcntl.h
@@ -17,9 +17,9 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_FCNTLBITS_H
-
-#define	_FCNTLBITS_H	1
+#ifndef	_FCNTL_H
+#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
 
 
 /* File access modes for `open' and `fcntl'.  */
@@ -76,7 +76,7 @@
 #define	FD_CLOEXEC	1	/* Close on exec.  */
 
 
-#include <gnu/types.h>
+#include <bits/types.h>
 
 /* The structure describing an advisory lock.  This is the type of the third
    argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests.  */
@@ -105,6 +105,3 @@ struct flock
 #define	FNONBLOCK	O_NONBLOCK
 #define	FNDELAY		O_NDELAY
 #endif /* Use BSD.  */
-
-
-#endif	/* fcntlbits.h */
diff --git a/sysdeps/unix/sysv/irix4/signum.h b/sysdeps/unix/sysv/irix4/bits/signum.h
index 13314cff42..13314cff42 100644
--- a/sysdeps/unix/sysv/irix4/signum.h
+++ b/sysdeps/unix/sysv/irix4/bits/signum.h
diff --git a/sysdeps/unix/sysv/irix4/statbuf.h b/sysdeps/unix/sysv/irix4/bits/stat.h
index 579ccec8a6..0dab45cfa0 100644
--- a/sysdeps/unix/sysv/irix4/statbuf.h
+++ b/sysdeps/unix/sysv/irix4/bits/stat.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -16,8 +16,12 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_STATBUF_H
-#define	_STATBUF_H	1
+/*
+ * Never include this file directly; use <sys/stat.h> instead.
+ */
+
+#ifndef	_BITS_STAT_H
+#define	_BITS_STAT_H	1
 
 struct stat
   {
@@ -58,4 +62,4 @@ struct stat
 #define	__S_IWRITE	0200	/* Write by owner.  */
 #define	__S_IEXEC	0100	/* Execute by owner.  */
 
-#endif	/* statbuf.h */
+#endif	/* bits/stat.h */
diff --git a/sysdeps/unix/sysv/irix4/sys/mman.h b/sysdeps/unix/sysv/irix4/sys/mman.h
index 9ceca1fe96..f42a9f67aa 100644
--- a/sysdeps/unix/sysv/irix4/sys/mman.h
+++ b/sysdeps/unix/sysv/irix4/sys/mman.h
@@ -22,7 +22,7 @@
 #define	_SYS_MMAN_H	1
 #include <features.h>
 
-#include <gnu/types.h>
+#include <bits/types.h>
 #define __need_size_t
 #include <stddef.h>
 
diff --git a/sysdeps/unix/sysv/linux/Dist b/sysdeps/unix/sysv/linux/Dist
index ae79600717..53700850b9 100644
--- a/sysdeps/unix/sysv/linux/Dist
+++ b/sysdeps/unix/sysv/linux/Dist
@@ -2,8 +2,10 @@ cmsg_nxthdr.c
 init-first.h
 kernel_sigaction.h
 kernel_stat.h
+kernel_termios.h
 llseek.c
 siglist.h
+socketcall.h
 sysctl.c
 termio.h
 net/ethernet.h
@@ -30,14 +32,12 @@ sys/debugreg.h
 sys/io.h
 sys/kd.h
 sys/kdaemon.h
-sys/kernel_termios.h
 sys/klog.h
 sys/module.h
 sys/mount.h
 sys/mtio.h
 sys/procfs.h
 sys/quota.h
-sys/socketcall.h
 sys/socketvar.h
 sys/soundcard.h
 sys/sysctl.h
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 7255a69ece..42f64638ca 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -36,7 +36,7 @@ sysdep_headers += sys/timex.h
 endif
 
 ifeq ($(subdir),socket)
-sysdep_headers += sys/socketcall.h net/if.h net/if_ppp.h net/ppp-comp.h \
+sysdep_headers += net/if.h net/if_ppp.h net/ppp-comp.h \
 		  net/ppp_defs.h net/if_arp.h net/route.h net/ethernet.h \
 		  net/if_slip.h
 sysdep_routines += cmsg_nxthdr
@@ -47,7 +47,7 @@ sysdep_headers += nfs/nfs.h
 endif
 
 ifeq ($(subdir),termios)
-sysdep_headers += termio.h sys/kernel_termios.h
+sysdep_headers += termio.h
 endif
 
 ifeq ($(subdir),stdio-common)
diff --git a/sysdeps/unix/sysv/linux/alpha/fcntlbits.h b/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h
index 6e1c843ccb..b70502f21a 100644
--- a/sysdeps/unix/sysv/linux/alpha/fcntlbits.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h
@@ -17,8 +17,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_FCNTLBITS_H
-#define	_FCNTLBITS_H	1
+#ifndef	_FCNTL_H
+#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
 
 #include <sys/types.h>
 
@@ -96,5 +98,3 @@ struct flock
 #define	FNONBLOCK	O_NONBLOCK
 #define	FNDELAY		O_NDELAY
 #endif /* Use BSD.  */
-
-#endif	/* fcntlbits.h */
diff --git a/sysdeps/unix/sysv/linux/sparc/ioctls.h b/sysdeps/unix/sysv/linux/alpha/bits/ioctls.h
index 80b2e62e77..8a14f99f43 100644
--- a/sysdeps/unix/sysv/linux/sparc/ioctls.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/ioctls.h
@@ -16,12 +16,16 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _IOCTLS_H
-#define _IOCTLS_H 1
+/*
+ * Never include this file directly; use <sys/ioctl.h> instead.
+ */
+
+#ifndef _BITS_IOCTLS_H
+#define _BITS_IOCTLS_H 1
 
 /* Use the definitions from the kernel header files.  */
 #include <asm/ioctls.h>
-#include <sys/kernel_termios.h>
+#include <kernel_termios.h>
 
 /* Oh well, this is necessary since the kernel data structure is
    different from the user-level version.  */
@@ -36,4 +40,4 @@
 
 #include <linux/sockios.h>
 
-#endif /* ioctls.h  */
+#endif /* bits/ioctls.h  */
diff --git a/sysdeps/unix/sysv/linux/alpha/sys/ipc_buf.h b/sysdeps/unix/sysv/linux/alpha/bits/ipc.h
index 57830daae1..57830daae1 100644
--- a/sysdeps/unix/sysv/linux/alpha/sys/ipc_buf.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/ipc.h
diff --git a/sysdeps/unix/sysv/linux/alpha/sigaction.h b/sysdeps/unix/sysv/linux/alpha/bits/sigaction.h
index 57ce5e6ded..57ce5e6ded 100644
--- a/sysdeps/unix/sysv/linux/alpha/sigaction.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/sigaction.h
diff --git a/sysdeps/unix/sysv/linux/alpha/signum.h b/sysdeps/unix/sysv/linux/alpha/bits/signum.h
index be6132d42f..be6132d42f 100644
--- a/sysdeps/unix/sysv/linux/alpha/signum.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/signum.h
diff --git a/sysdeps/unix/sysv/linux/alpha/statbuf.h b/sysdeps/unix/sysv/linux/alpha/bits/stat.h
index 207fa0ca1c..768b8192ff 100644
--- a/sysdeps/unix/sysv/linux/alpha/statbuf.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/stat.h
@@ -16,8 +16,12 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_STATBUF_H
-#define	_STATBUF_H	1
+/*
+ * Never include this file directly; use <sys/stat.h> instead.
+ */
+
+#ifndef	_BITS_STAT_H
+#define	_BITS_STAT_H	1
 
 /* Versions of the `struct stat' data structure.  */
 #define _STAT_VER_LINUX_OLD	0
@@ -71,4 +75,4 @@ struct stat
 #define	__S_IWRITE	0200	/* Write by owner.  */
 #define	__S_IEXEC	0100	/* Execute by owner.  */
 
-#endif	/* statbuf.h */
+#endif	/* bits/stat.h */
diff --git a/sysdeps/unix/sysv/linux/alpha/termbits.h b/sysdeps/unix/sysv/linux/alpha/bits/termios.h
index d0932c1cd7..d0932c1cd7 100644
--- a/sysdeps/unix/sysv/linux/alpha/termbits.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/termios.h
diff --git a/sysdeps/unix/sysv/linux/alpha/timebits.h b/sysdeps/unix/sysv/linux/alpha/bits/time.h
index 1ad0df8c5b..7475b68f5b 100644
--- a/sysdeps/unix/sysv/linux/alpha/timebits.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/time.h
@@ -1,5 +1,5 @@
 /* System-dependent timing definitions.  Linux/Alpha version.
-   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
@@ -17,6 +17,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+/*
+ * Never include this file directly; use <time.h> instead.
+ */
+
 #ifdef __need_timeval
 # undef __need_timeval
 # ifndef _STRUCT_TIMEVAL
@@ -32,8 +36,8 @@ struct timeval
 #endif	/* need timeval */
 
 
-#ifndef _TIMEBITS_H
-# define _TIMEBITS_H	1
+#ifndef _BITS_TIME_H
+#define _BITS_TIME_H	1
 
 /* ISO/IEC 9899:1990 7.12.1: <time.h>
    The macro `CLOCKS_PER_SEC' is the number per second of the value
@@ -47,4 +51,4 @@ struct timeval
    presents the real value for clock ticks per second for the system.  */
 # define CLK_TCK 1024
 
-#endif	/* timebits.h */
+#endif	/* bits/time.h */
diff --git a/sysdeps/unix/sysv/linux/alpha/gnu/types.h b/sysdeps/unix/sysv/linux/alpha/bits/types.h
index 2af77f70cf..9a4666a508 100644
--- a/sysdeps/unix/sysv/linux/alpha/gnu/types.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/types.h
@@ -16,8 +16,12 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_GNU_TYPES_H
-#define	_GNU_TYPES_H	1
+/*
+ * Never include this file directly; use <sys/types.h> instead.
+ */
+
+#ifndef	_BITS_TYPES_H
+#define	_BITS_TYPES_H	1
 
 #include <features.h>
 
@@ -26,19 +30,16 @@ typedef unsigned char __u_char;
 typedef unsigned short __u_short;
 typedef unsigned int __u_int;
 typedef unsigned long __u_long;
-#ifdef __GNUC__
-typedef unsigned long long int __u_quad_t;
-typedef long long int __quad_t;
-#else
-typedef struct
-  {
-    long int __val[2];
-  } __quad_t;
-typedef struct
-  {
-    __u_long __val[2];
-  } __u_quad_t;
-#endif
+typedef unsigned long int __u_quad_t;
+typedef long int __quad_t;
+typedef signed char __int8_t;
+typedef unsigned char __uint8_t;
+typedef signed short int __int16_t;
+typedef unsigned short int __uint16_t;
+typedef signed int __int32_t;
+typedef unsigned int __uint32_t;
+typedef signed long int __int64_t;
+typedef unsigned long int __uint64_t;
 typedef __quad_t *__qaddr_t;
 
 typedef __u_long __dev_t;		/* Type of device numbers.  */
@@ -91,4 +92,4 @@ typedef struct
 
 typedef int __key_t;
 
-#endif /* gnu/types.h */
+#endif /* bits/types.h */
diff --git a/sysdeps/unix/sysv/linux/alpha/brk.S b/sysdeps/unix/sysv/linux/alpha/brk.S
index be0539b475..6f994937d3 100644
--- a/sysdeps/unix/sysv/linux/alpha/brk.S
+++ b/sysdeps/unix/sysv/linux/alpha/brk.S
@@ -23,7 +23,7 @@
 
 #include <sysdep.h>
 #define _ERRNO_H
-#include <errnos.h>
+#include <bits/errno.h>
 
 #ifdef PIC
 .section .bss
diff --git a/sysdeps/unix/sysv/linux/alpha/clone.S b/sysdeps/unix/sysv/linux/alpha/clone.S
index aab4e590a5..3f097fe068 100644
--- a/sysdeps/unix/sysv/linux/alpha/clone.S
+++ b/sysdeps/unix/sysv/linux/alpha/clone.S
@@ -22,7 +22,7 @@
 
 #include <sysdep.h>
 #define _ERRNO_H	1
-#include <errnos.h>
+#include <bits/errno.h>
 
 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg) */
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/sys/kernel_termios.h b/sysdeps/unix/sysv/linux/alpha/kernel_termios.h
index c5e9e2684a..093ac25096 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sys/kernel_termios.h
+++ b/sysdeps/unix/sysv/linux/alpha/kernel_termios.h
@@ -16,12 +16,13 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _SYS_KERNEL_TERMIOS_H
-#define _SYS_KERNEL_TERMIOS_H 1
-/* The following corresponds to the values from the Linux 2.0.28 kernel.  */
+#ifndef _KERNEL_TERMIOS_H
+#define _KERNEL_TERMIOS_H 1
+
+/* The following corresponds to the values from the Linux 2.1.20 kernel.  */
 
 /* We need the definition of tcflag_t, cc_t, and speed_t.  */
-#include <termbits.h>
+#include <bits/termios.h>
 
 #define __KERNEL_NCCS 19
 
@@ -33,11 +34,11 @@ struct __kernel_termios
     tcflag_t c_lflag;		/* local mode flags */
     cc_t c_cc[__KERNEL_NCCS];	/* control characters */
     cc_t c_line;		/* line discipline */
-    int c_ispeed;               /* input speed */
-    int c_ospeed;               /* output speed */
+    speed_t c_ispeed;		/* input speed */
+    speed_t c_ospeed;		/* output speed */
   };
 
 #define _HAVE_C_ISPEED 1
 #define _HAVE_C_OSPEED 1
 
-#endif /* sys/kernel_termios.h */
+#endif /* kernel_termios.h */
diff --git a/sysdeps/unix/sysv/linux/alpha/sys/kernel_termios.h b/sysdeps/unix/sysv/linux/alpha/sys/kernel_termios.h
deleted file mode 100644
index 4be759a51f..0000000000
--- a/sysdeps/unix/sysv/linux/alpha/sys/kernel_termios.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef _SYS_KERNEL_TERMIOS_H
-#define _SYS_KERNEL_TERMIOS_H 1
-/* The following corresponds to the values from the Linux 2.1.20 kernel.  */
-
-/* We need the definition of tcflag_t, cc_t, and speed_t.  */
-#include <termbits.h>
-
-#define __KERNEL_NCCS 19
-
-struct __kernel_termios
-  {
-    tcflag_t c_iflag;		/* input mode flags */
-    tcflag_t c_oflag;		/* output mode flags */
-    tcflag_t c_cflag;		/* control mode flags */
-    tcflag_t c_lflag;		/* local mode flags */
-    cc_t c_cc[__KERNEL_NCCS];	/* control characters */
-    cc_t c_line;		/* line discipline */
-    speed_t c_ispeed;		/* input speed */
-    speed_t c_ospeed;		/* output speed */
-  };
-
-#define _HAVE_C_ISPEED 1
-#define _HAVE_C_OSPEED 1
-
-#endif /* sys/kernel_termios.h */
diff --git a/sysdeps/unix/sysv/linux/arm/clone.S b/sysdeps/unix/sysv/linux/arm/clone.S
index c7e7aed9c8..8125ebff20 100644
--- a/sysdeps/unix/sysv/linux/arm/clone.S
+++ b/sysdeps/unix/sysv/linux/arm/clone.S
@@ -21,7 +21,7 @@
 
 #include <sysdep.h>
 #define _ERRNO_H	1
-#include <errnos.h>
+#include <bits/errno.h>
 
 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
 
diff --git a/sysdeps/unix/sysv/linux/arm/profil-counter.h b/sysdeps/unix/sysv/linux/arm/profil-counter.h
index a915da7788..802cbd5d63 100644
--- a/sysdeps/unix/sysv/linux/arm/profil-counter.h
+++ b/sysdeps/unix/sysv/linux/arm/profil-counter.h
@@ -17,7 +17,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#include <sigcontext.h>
+#include <signal.h>
 
 void
 profil_counter (int signo, struct sigcontext sc)
diff --git a/sysdeps/unix/sysv/linux/arm/socket.S b/sysdeps/unix/sysv/linux/arm/socket.S
index e8db072971..4d877e51d5 100644
--- a/sysdeps/unix/sysv/linux/arm/socket.S
+++ b/sysdeps/unix/sysv/linux/arm/socket.S
@@ -17,7 +17,7 @@
    Boston, MA 02111-1307, USA.  */
 
 #include <sysdep.h>
-#include <sys/socketcall.h>
+#include <socketcall.h>
 
 #define P(a, b) P2(a, b)
 #define P2(a, b) a##b
diff --git a/sysdeps/unix/sysv/linux/direntry.h b/sysdeps/unix/sysv/linux/bits/dirent.h
index ccf5080151..ccf5080151 100644
--- a/sysdeps/unix/sysv/linux/direntry.h
+++ b/sysdeps/unix/sysv/linux/bits/dirent.h
diff --git a/sysdeps/unix/sysv/linux/errnos.h b/sysdeps/unix/sysv/linux/bits/errno.h
index f676d35e49..f676d35e49 100644
--- a/sysdeps/unix/sysv/linux/errnos.h
+++ b/sysdeps/unix/sysv/linux/bits/errno.h
diff --git a/sysdeps/unix/sysv/linux/fcntlbits.h b/sysdeps/unix/sysv/linux/bits/fcntl.h
index f6ba880459..62c3052d8c 100644
--- a/sysdeps/unix/sysv/linux/fcntlbits.h
+++ b/sysdeps/unix/sysv/linux/bits/fcntl.h
@@ -17,8 +17,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_FCNTLBITS_H
-#define	_FCNTLBITS_H	1
+#ifndef	_FCNTL_H
+#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
 
 #include <sys/types.h>
 
@@ -95,5 +97,3 @@ struct flock
 #define	FNONBLOCK	O_NONBLOCK
 #define	FNDELAY		O_NDELAY
 #endif /* Use BSD.  */
-
-#endif	/* fcntlbits.h */
diff --git a/sysdeps/unix/sysv/linux/ioctl-types.h b/sysdeps/unix/sysv/linux/bits/ioctl-types.h
index 91fcc2653b..af988a3c9d 100644
--- a/sysdeps/unix/sysv/linux/ioctl-types.h
+++ b/sysdeps/unix/sysv/linux/bits/ioctl-types.h
@@ -17,8 +17,12 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _IOCTL_TYPES_H
-#define _IOCTL_TYPES_H 1
+/*
+ * Never include this file directly; use <sys/ioctl.h> instead.
+ */
+
+#ifndef _BITS_IOCTL_TYPES_H
+#define _BITS_IOCTL_TYPES_H 1
 
 /* Get definition of constants for use with `ioctl'.  */
 #include <asm/ioctls.h>
@@ -67,4 +71,4 @@ struct termio
 #define N_AX25		5
 
 
-#endif /* ioctl-types.h */
+#endif /* bits/ioctl-types.h */
diff --git a/sysdeps/unix/sysv/linux/ioctls.h b/sysdeps/unix/sysv/linux/bits/ioctls.h
index 8b5326998a..265c857f92 100644
--- a/sysdeps/unix/sysv/linux/ioctls.h
+++ b/sysdeps/unix/sysv/linux/bits/ioctls.h
@@ -16,11 +16,15 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _IOCTLS_H
-#define _IOCTLS_H 1
+/*
+ * Never include this file directly; use <sys/ioctl.h> instead.
+ */
+
+#ifndef _BITS_IOCTLS_H
+#define _BITS_IOCTLS_H 1
 
 /* Use the definitions from the kernel header files.  */
 #include <asm/ioctls.h>
 #include <linux/sockios.h>
 
-#endif /* ioctls.h  */
+#endif /* bits/ioctls.h  */
diff --git a/sysdeps/unix/sysv/linux/sys/ipc_buf.h b/sysdeps/unix/sysv/linux/bits/ipc.h
index f5fea0d295..f5fea0d295 100644
--- a/sysdeps/unix/sysv/linux/sys/ipc_buf.h
+++ b/sysdeps/unix/sysv/linux/bits/ipc.h
diff --git a/sysdeps/unix/sysv/linux/local_lim.h b/sysdeps/unix/sysv/linux/bits/local_lim.h
index 7ce423061a..7ce423061a 100644
--- a/sysdeps/unix/sysv/linux/local_lim.h
+++ b/sysdeps/unix/sysv/linux/bits/local_lim.h
diff --git a/sysdeps/unix/sysv/linux/sys/msq_buf.h b/sysdeps/unix/sysv/linux/bits/msq.h
index 0abc10f6e5..0abc10f6e5 100644
--- a/sysdeps/unix/sysv/linux/sys/msq_buf.h
+++ b/sysdeps/unix/sysv/linux/bits/msq.h
diff --git a/sysdeps/unix/sysv/linux/posix_opt.h b/sysdeps/unix/sysv/linux/bits/posix_opt.h
index a467acfb48..e9f8b7f8f3 100644
--- a/sysdeps/unix/sysv/linux/posix_opt.h
+++ b/sysdeps/unix/sysv/linux/bits/posix_opt.h
@@ -17,8 +17,12 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_POSIX_OPT_H
-#define	_POSIX_OPT_H	1
+/*
+ * Never include this file directly; use <unistd.h> instead.
+ */
+
+#ifndef	_BITS_POSIX_OPT_H
+#define	_BITS_POSIX_OPT_H	1
 
 /* Job control is supported.  */
 #define	_POSIX_JOB_CONTROL	1
@@ -66,4 +70,4 @@
 /* XPG4.2 shared memory is supported.  */
 #define	_XOPEN_SHM	1
 
-#endif /* posix_opt.h */
+#endif /* bits/posix_opt.h */
diff --git a/sysdeps/unix/sysv/linux/resourcebits.h b/sysdeps/unix/sysv/linux/bits/resource.h
index 05cae83244..05cae83244 100644
--- a/sysdeps/unix/sysv/linux/resourcebits.h
+++ b/sysdeps/unix/sysv/linux/bits/resource.h
diff --git a/sysdeps/unix/sysv/linux/schedbits.h b/sysdeps/unix/sysv/linux/bits/sched.h
index fccb5d834f..521bbb7177 100644
--- a/sysdeps/unix/sysv/linux/schedbits.h
+++ b/sysdeps/unix/sysv/linux/bits/sched.h
@@ -18,9 +18,11 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_SCHEDBITS_H
+#ifndef _SCHED_H
+#error "Never use <bits/sched.h> directly; include <sched.h> instead."
+#endif
+
 
-#define	_SCHEDBITS_H	1
 #include <features.h>
 
 /* Scheduling algorithms.  */
@@ -50,6 +52,3 @@ extern int __clone __P ((int (*__fn) (void *__arg), void *__child_stack,
 extern int clone __P ((int (*__fn) (void *__arg), void *__child_stack,
 		       int __flags, void *__arg));
 #endif
-
-
-#endif /* schedbits.h */
diff --git a/sysdeps/unix/sysv/linux/sys/sem_buf.h b/sysdeps/unix/sysv/linux/bits/sem.h
index 049a71bc47..049a71bc47 100644
--- a/sysdeps/unix/sysv/linux/sys/sem_buf.h
+++ b/sysdeps/unix/sysv/linux/bits/sem.h
diff --git a/sysdeps/unix/sysv/linux/sys/shm_buf.h b/sysdeps/unix/sysv/linux/bits/shm.h
index 642b7bd191..642b7bd191 100644
--- a/sysdeps/unix/sysv/linux/sys/shm_buf.h
+++ b/sysdeps/unix/sysv/linux/bits/shm.h
diff --git a/sysdeps/unix/sysv/linux/sigaction.h b/sysdeps/unix/sysv/linux/bits/sigaction.h
index 13a6a03248..13a6a03248 100644
--- a/sysdeps/unix/sysv/linux/sigaction.h
+++ b/sysdeps/unix/sysv/linux/bits/sigaction.h
diff --git a/sysdeps/unix/sysv/linux/sigcontext.h b/sysdeps/unix/sysv/linux/bits/sigcontext.h
index 71afc76c71..fb8bc5fc57 100644
--- a/sysdeps/unix/sysv/linux/sigcontext.h
+++ b/sysdeps/unix/sysv/linux/bits/sigcontext.h
@@ -16,14 +16,13 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _SIGCONTEXT_H
-#define _SIGCONTEXT_H 1
+#ifndef _SIGNAL_H
+#error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
+#endif
+
 
 /* Kernel headers before 2.1.1 define a struct sigcontext_struct, but
    we need sigcontext.  */
 #define sigcontext_struct sigcontext
 
 #include <asm/sigcontext.h>
-
-
-#endif /* sigcontext.h */
diff --git a/sysdeps/unix/sysv/linux/signum.h b/sysdeps/unix/sysv/linux/bits/signum.h
index d8a716f2e0..d8a716f2e0 100644
--- a/sysdeps/unix/sysv/linux/signum.h
+++ b/sysdeps/unix/sysv/linux/bits/signum.h
diff --git a/sysdeps/unix/sysv/linux/sigset.h b/sysdeps/unix/sysv/linux/bits/sigset.h
index 741ff9ac9d..741ff9ac9d 100644
--- a/sysdeps/unix/sysv/linux/sigset.h
+++ b/sysdeps/unix/sysv/linux/bits/sigset.h
diff --git a/sysdeps/unix/sysv/linux/socketbits.h b/sysdeps/unix/sysv/linux/bits/socket.h
index e60f903fc5..e3f53a97be 100644
--- a/sysdeps/unix/sysv/linux/socketbits.h
+++ b/sysdeps/unix/sysv/linux/bits/socket.h
@@ -17,9 +17,11 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_SOCKETBITS_H
+#ifndef _SYS_SOCKET_H
+#error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
+#endif
+
 
-#define	_SOCKETBITS_H	1
 #include <features.h>
 
 #define	__need_size_t
@@ -101,7 +103,7 @@ enum __socket_type
 #define SOMAXCONN	128
 
 /* Get the definition of the macro to define the common sockaddr members.  */
-#include <sockaddrcom.h>
+#include <bits/sockaddr.h>
 
 /* Structure describing a generic socket address.  */
 struct sockaddr
@@ -201,5 +203,3 @@ struct linger
   };
 
 __END_DECLS
-
-#endif /* socketbits.h */
diff --git a/sysdeps/unix/sysv/linux/statbuf.h b/sysdeps/unix/sysv/linux/bits/stat.h
index 15ffe637bc..1c6e5f84ca 100644
--- a/sysdeps/unix/sysv/linux/statbuf.h
+++ b/sysdeps/unix/sysv/linux/bits/stat.h
@@ -16,8 +16,12 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_STATBUF_H
-#define	_STATBUF_H	1
+/*
+ * Never include this file directly; use <sys/stat.h> instead.
+ */
+
+#ifndef	_BITS_STAT_H
+#define	_BITS_STAT_H	1
 
 /* Versions of the `struct stat' data structure.  */
 #define _STAT_VER_LINUX_OLD	1
@@ -81,4 +85,4 @@ struct stat
 #define	__S_IWRITE	0200	/* Write by owner.  */
 #define	__S_IEXEC	0100	/* Execute by owner.  */
 
-#endif	/* statbuf.h */
+#endif	/* bits/stat.h */
diff --git a/sysdeps/unix/sysv/linux/statfsbuf.h b/sysdeps/unix/sysv/linux/bits/statfs.h
index 7e1aa55334..8b9501423c 100644
--- a/sysdeps/unix/sysv/linux/statfsbuf.h
+++ b/sysdeps/unix/sysv/linux/bits/statfs.h
@@ -16,10 +16,14 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _STATFSBUF_H
-#define _STATFSBUF_H
+/*
+ * Never include this file directly; use <sys/statfs.h> instead.
+ */
 
-#include <gnu/types.h>  /* for __fsid_t */
+#ifndef _BITS_STATFS_H
+#define _BITS_STATFS_H
+
+#include <bits/types.h>  /* for __fsid_t */
 
 struct statfs
   {
@@ -35,4 +39,4 @@ struct statfs
     int f_spare[6];
   };
 
-#endif	/* statfsbuf.h */
+#endif	/* bits/statfs.h */
diff --git a/sysdeps/unix/sysv/linux/termbits.h b/sysdeps/unix/sysv/linux/bits/termios.h
index 8224ac5403..dd42012374 100644
--- a/sysdeps/unix/sysv/linux/termbits.h
+++ b/sysdeps/unix/sysv/linux/bits/termios.h
@@ -17,8 +17,13 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _TERMBITS_H
-#define _TERMBITS_H	1
+/*
+ * Never include this file directly; use <termios.h> instead.
+ */
+
+
+#ifndef _BITS_TERMIOS_H
+#define _BITS_TERMIOS_H	1
 
 typedef unsigned char	cc_t;
 typedef unsigned int	speed_t;
@@ -181,4 +186,4 @@ struct termios
 #define _IOT_termios /* Hurd ioctl type field.  */ \
   _IOT (_IOTS (cflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)
 
-#endif /* termbits.h */
+#endif /* bits/termios.h */
diff --git a/sysdeps/unix/sysv/linux/timebits.h b/sysdeps/unix/sysv/linux/bits/time.h
index de30a6f348..509cb2ce32 100644
--- a/sysdeps/unix/sysv/linux/timebits.h
+++ b/sysdeps/unix/sysv/linux/bits/time.h
@@ -17,6 +17,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+/*
+ * Never include this file directly; use <time.h> instead.
+ */
+
 #ifdef __need_timeval
 # undef __need_timeval
 # ifndef _STRUCT_TIMEVAL
@@ -32,8 +36,8 @@ struct timeval
 #endif	/* need timeval */
 
 
-#ifndef _TIMEBITS_H
-# define _TIMEBITS_H	1
+#ifndef _BITS_TIME_H
+#define _BITS_TIME_H	1
 
 /* ISO/IEC 9899:1990 7.12.1: <time.h>
    The macro `CLOCKS_PER_SEC' is the number per second of the value
@@ -49,4 +53,4 @@ struct timeval
 #  define CLK_TCK 100
 # endif
 
-#endif	/* timebits.h */
+#endif	/* bits/time.h */
diff --git a/sysdeps/unix/sysv/linux/gnu/types.h b/sysdeps/unix/sysv/linux/bits/types.h
index 872fc4e557..34f4682b3c 100644
--- a/sysdeps/unix/sysv/linux/gnu/types.h
+++ b/sysdeps/unix/sysv/linux/bits/types.h
@@ -16,8 +16,12 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_GNU_TYPES_H
-#define	_GNU_TYPES_H	1
+/*
+ * Never include this file directly; use <sys/types.h> instead.
+ */
+
+#ifndef	_BITS_TYPES_H
+#define	_BITS_TYPES_H	1
 
 #include <features.h>
 
@@ -39,6 +43,16 @@ typedef struct
     __u_long __val[2];
   } __u_quad_t;
 #endif
+typedef signed char __int8_t;
+typedef unsigned char __uint8_t;
+typedef signed short int __int16_t;
+typedef unsigned short int __uint16_t;
+typedef signed int __int32_t;
+typedef unsigned int __uint32_t;
+#ifdef __GNUC__
+typedef signed long long int __int64_t;
+typedef unsigned long long int __uint64_t;
+#endif
 typedef __quad_t *__qaddr_t;
 
 typedef __u_quad_t __dev_t;		/* Type of device numbers.  */
@@ -86,4 +100,4 @@ typedef struct
 
 typedef int __key_t;
 
-#endif /* gnu/types.h */
+#endif /* bits/types.h */
diff --git a/sysdeps/unix/sysv/linux/iovec.h b/sysdeps/unix/sysv/linux/bits/uio.h
index 430edfc029..3f1dc01c73 100644
--- a/sysdeps/unix/sysv/linux/iovec.h
+++ b/sysdeps/unix/sysv/linux/bits/uio.h
@@ -16,9 +16,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _IOVEC_H
+#ifndef _SYS_UIO_H
+#error "Never use <bits/uio.h> directly; include <sys/uio.h> instead."
+#endif
 
-#define _IOVEC_H	1
 
 #include <sys/types.h>
 
@@ -43,5 +44,3 @@ struct iovec
     void *iov_base;	/* Pointer to data.  */
     size_t iov_len;	/* Length of data.  */
   };
-
-#endif	/* iovec.h */
diff --git a/sysdeps/unix/sysv/linux/ustatbits.h b/sysdeps/unix/sysv/linux/bits/ustat.h
index 526069a7f3..526069a7f3 100644
--- a/sysdeps/unix/sysv/linux/ustatbits.h
+++ b/sysdeps/unix/sysv/linux/bits/ustat.h
diff --git a/sysdeps/unix/sysv/linux/utsnamelen.h b/sysdeps/unix/sysv/linux/bits/utsname.h
index 64e2ab5bbc..64e2ab5bbc 100644
--- a/sysdeps/unix/sysv/linux/utsnamelen.h
+++ b/sysdeps/unix/sysv/linux/bits/utsname.h
diff --git a/sysdeps/unix/sysv/linux/waitflags.h b/sysdeps/unix/sysv/linux/bits/waitflags.h
index a60d17272b..ba3528b709 100644
--- a/sysdeps/unix/sysv/linux/waitflags.h
+++ b/sysdeps/unix/sysv/linux/bits/waitflags.h
@@ -1,5 +1,5 @@
 /* Definitions of flag bits for `waitpid' et al.
-   Copyright (C) 1992, 1996 Free Software Foundation, Inc.
+   Copyright (C) 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
@@ -17,14 +17,13 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_WAITFLAGS_H
+#ifndef _SYS_WAIT_H
+#error "Never use <bits/waitflags.h> directly; include <sys/wait.h> instead."
+#endif
 
-#define	_WAITFLAGS_H	1
 
 /* Bits in the third argument to `waitpid'.  */
 #define	WNOHANG		1	/* Don't block waiting.  */
 #define	WUNTRACED	2	/* Report status of stopped children.  */
 
 #define __WCLONE	0x80000000 /* Wait for cloned process.  */
-
-#endif	/* waitflags.h */
diff --git a/sysdeps/unix/sysv/linux/i386/clone.S b/sysdeps/unix/sysv/linux/i386/clone.S
index 3cdd2dc468..7f758a52a8 100644
--- a/sysdeps/unix/sysv/linux/i386/clone.S
+++ b/sysdeps/unix/sysv/linux/i386/clone.S
@@ -22,7 +22,7 @@
 
 #include <sysdep.h>
 #define _ERRNO_H	1
-#include <errnos.h>
+#include <bits/errno.h>
 
 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
 
diff --git a/sysdeps/unix/sysv/linux/i386/profil-counter.h b/sysdeps/unix/sysv/linux/i386/profil-counter.h
index 96b38e24c0..56754744c7 100644
--- a/sysdeps/unix/sysv/linux/i386/profil-counter.h
+++ b/sysdeps/unix/sysv/linux/i386/profil-counter.h
@@ -17,7 +17,7 @@ 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.  */
 
-#include <sigcontext.h>
+#include <signal.h>
 
 void
 profil_counter (int signo, struct sigcontext sc)
diff --git a/sysdeps/unix/sysv/linux/i386/socket.S b/sysdeps/unix/sysv/linux/i386/socket.S
index 441c143156..7c539e17d2 100644
--- a/sysdeps/unix/sysv/linux/i386/socket.S
+++ b/sysdeps/unix/sysv/linux/i386/socket.S
@@ -17,7 +17,7 @@
    Boston, MA 02111-1307, USA.  */
 
 #include <sysdep.h>
-#include <sys/socketcall.h>
+#include <socketcall.h>
 
 #define P(a, b) P2(a, b)
 #define P2(a, b) a##b
diff --git a/sysdeps/unix/sysv/linux/kernel_termios.h b/sysdeps/unix/sysv/linux/kernel_termios.h
new file mode 100644
index 0000000000..78c6f4aa2f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/kernel_termios.h
@@ -0,0 +1,38 @@
+/* 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.  */
+
+#ifndef _KERNEL_TERMIOS_H
+#define _KERNEL_TERMIOS_H 1
+/* The following corresponds to the values from the Linux 2.1.20 kernel.  */
+
+/* We need the definition of tcflag_t, cc_t, and speed_t.  */
+#include <bits/termios.h>
+
+#define __KERNEL_NCCS 19
+
+struct __kernel_termios
+  {
+    tcflag_t c_iflag;		/* input mode flags */
+    tcflag_t c_oflag;		/* output mode flags */
+    tcflag_t c_cflag;		/* control mode flags */
+    tcflag_t c_lflag;		/* local mode flags */
+    cc_t c_line;		/* line discipline */
+    cc_t c_cc[__KERNEL_NCCS];	/* control characters */
+  };
+
+#endif /* kernel_termios.h */
diff --git a/sysdeps/unix/sysv/linux/m68k/clone.S b/sysdeps/unix/sysv/linux/m68k/clone.S
index ef9716d979..d553ab78c6 100644
--- a/sysdeps/unix/sysv/linux/m68k/clone.S
+++ b/sysdeps/unix/sysv/linux/m68k/clone.S
@@ -21,7 +21,7 @@
 
 #include <sysdep.h>
 #define _ERRNO_H	1
-#include <errnos.h>
+#include <bits/errno.h>
 
 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
 
diff --git a/sysdeps/unix/sysv/linux/m68k/socket.S b/sysdeps/unix/sysv/linux/m68k/socket.S
index d0741afeb1..1508b879f6 100644
--- a/sysdeps/unix/sysv/linux/m68k/socket.S
+++ b/sysdeps/unix/sysv/linux/m68k/socket.S
@@ -17,7 +17,7 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
 #include <sysdep.h>
-#include <sys/socketcall.h>
+#include <socketcall.h>
 
 #define P(a, b) P2(a, b)
 #define P2(a, b) a##b
diff --git a/sysdeps/unix/sysv/linux/netinet/ip.h b/sysdeps/unix/sysv/linux/netinet/ip.h
index 6d50bb41d1..bf4e01680b 100644
--- a/sysdeps/unix/sysv/linux/netinet/ip.h
+++ b/sysdeps/unix/sysv/linux/netinet/ip.h
@@ -37,7 +37,7 @@ struct timestamp
     u_int8_t overflow:4;
     u_int8_t flags:4;
 #else
-#error	"Please fix <bytesex.h>"
+#error	"Please fix <bits/endian.h>"
 #endif
     u_int32_t data[9];
   };
@@ -72,7 +72,7 @@ struct iphdr
     u_int8_t	version:4;
     u_int8_t ihl:4;
 #else
-#error	"Please fix <bytesex.h>"
+#error	"Please fix <bits/endian.h>"
 #endif
     u_int8_t tos;
     u_int16_t tot_len;
diff --git a/sysdeps/unix/sysv/linux/netinet/tcp.h b/sysdeps/unix/sysv/linux/netinet/tcp.h
index b7bf0857b8..60e67c5149 100644
--- a/sysdeps/unix/sysv/linux/netinet/tcp.h
+++ b/sysdeps/unix/sysv/linux/netinet/tcp.h
@@ -99,7 +99,7 @@ struct tcphdr {
 		syn:1,
 		fin:1;
 #else
-#error	"Adjust your <bytesex.h> defines"
+#error	"Adjust your <bits/endian.h> defines"
 #endif	
 	u_int16_t	window;
 	u_int16_t	check;
diff --git a/sysdeps/unix/sysv/linux/netipx/ipx.h b/sysdeps/unix/sysv/linux/netipx/ipx.h
index 170dfdf134..ec93c8185c 100644
--- a/sysdeps/unix/sysv/linux/netipx/ipx.h
+++ b/sysdeps/unix/sysv/linux/netipx/ipx.h
@@ -19,10 +19,94 @@
 #ifndef __NETIPX_IPX_H
 #define __NETIPX_IPX_H 1
 
-#include <asm/types.h>
-#include <linux/ipx.h>
+#include <features.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+__BEGIN_DECLS
 
 #define SOL_IPX    256          /* sockopt level */
-#define IPX_TYPE   1
+
+#define IPX_TYPE        1
+#define IPX_NODE_LEN	6
+#define IPX_MTU		576
+
+struct sockaddr_ipx
+  {
+    sa_family_t sipx_family;
+    u_int16_t sipx_port;
+    u_int32_t sipx_network;
+    unsigned char sipx_node[IPX_NODE_LEN];
+    u_int8_t sipx_type;
+    unsigned char sipx_zero;	/* 16 byte fill */
+  };
+
+/*
+ *	So we can fit the extra info for SIOCSIFADDR into the address nicely
+ */
+
+#define sipx_special	sipx_port
+#define sipx_action	sipx_zero
+#define IPX_DLTITF	0
+#define IPX_CRTITF	1
+
+typedef struct ipx_route_definition
+  {
+    unsigned long ipx_network;
+    unsigned long ipx_router_network;
+    unsigned char ipx_router_node[IPX_NODE_LEN];
+  }
+ipx_route_definition;
+
+typedef struct ipx_interface_definition
+  {
+    unsigned long ipx_network;
+    unsigned char ipx_device[16];
+    unsigned char ipx_dlink_type;
+#define IPX_FRAME_NONE		0
+#define IPX_FRAME_SNAP		1
+#define IPX_FRAME_8022		2
+#define IPX_FRAME_ETHERII	3
+#define IPX_FRAME_8023		4
+#define IPX_FRAME_TR_8022	5
+    unsigned char ipx_special;
+#define IPX_SPECIAL_NONE	0
+#define IPX_PRIMARY		1
+#define IPX_INTERNAL		2
+    unsigned char ipx_node[IPX_NODE_LEN];
+  }
+ipx_interface_definition;
+
+typedef struct ipx_config_data
+  {
+    unsigned char ipxcfg_auto_select_primary;
+    unsigned char ipxcfg_auto_create_interfaces;
+  }
+ipx_config_data;
+
+/*
+ * OLD Route Definition for backward compatibility.
+ */
+
+struct ipx_route_def
+  {
+    unsigned long ipx_network;
+    unsigned long ipx_router_network;
+#define IPX_ROUTE_NO_ROUTER	0
+    unsigned char ipx_router_node[IPX_NODE_LEN];
+    unsigned char ipx_device[16];
+    unsigned short ipx_flags;
+#define IPX_RT_SNAP		8
+#define IPX_RT_8022		4
+#define IPX_RT_BLUEBOOK		2
+#define IPX_RT_ROUTED		1
+  };
+
+#define SIOCAIPXITFCRT		(SIOCPROTOPRIVATE)
+#define SIOCAIPXPRISLT		(SIOCPROTOPRIVATE + 1)
+#define SIOCIPXCFGDATA		(SIOCPROTOPRIVATE + 2)
+
+__END_DECLS
 
 #endif /* netipx/ipx.h */
diff --git a/sysdeps/unix/sysv/linux/powerpc/ioctl-types.h b/sysdeps/unix/sysv/linux/powerpc/bits/ioctl-types.h
index 9e2695652e..9e2695652e 100644
--- a/sysdeps/unix/sysv/linux/powerpc/ioctl-types.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/ioctl-types.h
diff --git a/sysdeps/unix/sysv/linux/powerpc/termbits.h b/sysdeps/unix/sysv/linux/powerpc/bits/termios.h
index 4c6073bfc2..4c6073bfc2 100644
--- a/sysdeps/unix/sysv/linux/powerpc/termbits.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/termios.h
diff --git a/sysdeps/unix/sysv/linux/powerpc/clone.S b/sysdeps/unix/sysv/linux/powerpc/clone.S
index 068b14c538..cca63fe0bc 100644
--- a/sysdeps/unix/sysv/linux/powerpc/clone.S
+++ b/sysdeps/unix/sysv/linux/powerpc/clone.S
@@ -19,7 +19,7 @@
 
 #include <sysdep.h>
 #define _ERRNO_H	1
-#include <errnos.h>
+#include <bits/errno.h>
 
 /* This is the only really unusual system call in PPC linux, but not
    because of any weirdness in the system call itself; because of
diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel_termios.h b/sysdeps/unix/sysv/linux/powerpc/kernel_termios.h
index acf62a42ca..9a5e830c31 100644
--- a/sysdeps/unix/sysv/linux/powerpc/kernel_termios.h
+++ b/sysdeps/unix/sysv/linux/powerpc/kernel_termios.h
@@ -1,9 +1,27 @@
-#ifndef _SYS_KERNEL_TERMIOS_H
-#define _SYS_KERNEL_TERMIOS_H 1
+/* 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.  */
+
+#ifndef _KERNEL_TERMIOS_H
+#define _KERNEL_TERMIOS_H 1
 /* The following corresponds to the values from the Linux 2.0.28 kernel.  */
 
 /* We need the definition of tcflag_t, cc_t, and speed_t.  */
-#include <termbits.h>
+#include <bits/termios.h>
 
 #define __KERNEL_NCCS 19
 
@@ -22,4 +40,4 @@ struct __kernel_termios
 #define _HAVE_C_ISPEED 1
 #define _HAVE_C_OSPEED 1
 
-#endif /* sys/kernel_termios.h */
+#endif /* kernel_termios.h */
diff --git a/sysdeps/unix/sysv/linux/powerpc/socket.S b/sysdeps/unix/sysv/linux/powerpc/socket.S
index 305aba9281..904bca4dc3 100644
--- a/sysdeps/unix/sysv/linux/powerpc/socket.S
+++ b/sysdeps/unix/sysv/linux/powerpc/socket.S
@@ -17,7 +17,7 @@
    Boston, MA 02111-1307, USA.  */
 
 #include <sysdep.h>
-#include <sys/socketcall.h>
+#include <socketcall.h>
 
 #define P(a, b) P2(a, b)
 #define P2(a, b) a##b
diff --git a/sysdeps/unix/sysv/linux/sys/socketcall.h b/sysdeps/unix/sysv/linux/socketcall.h
index 9aaca7a27b..9aaca7a27b 100644
--- a/sysdeps/unix/sysv/linux/sys/socketcall.h
+++ b/sysdeps/unix/sysv/linux/socketcall.h
diff --git a/sysdeps/unix/sysv/linux/sparc/fcntlbits.h b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h
index 3fc7240a66..3fc7240a66 100644
--- a/sysdeps/unix/sysv/linux/sparc/fcntlbits.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h
diff --git a/sysdeps/unix/sysv/linux/alpha/ioctls.h b/sysdeps/unix/sysv/linux/sparc/bits/ioctls.h
index 80b2e62e77..8a14f99f43 100644
--- a/sysdeps/unix/sysv/linux/alpha/ioctls.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/ioctls.h
@@ -16,12 +16,16 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _IOCTLS_H
-#define _IOCTLS_H 1
+/*
+ * Never include this file directly; use <sys/ioctl.h> instead.
+ */
+
+#ifndef _BITS_IOCTLS_H
+#define _BITS_IOCTLS_H 1
 
 /* Use the definitions from the kernel header files.  */
 #include <asm/ioctls.h>
-#include <sys/kernel_termios.h>
+#include <kernel_termios.h>
 
 /* Oh well, this is necessary since the kernel data structure is
    different from the user-level version.  */
@@ -36,4 +40,4 @@
 
 #include <linux/sockios.h>
 
-#endif /* ioctls.h  */
+#endif /* bits/ioctls.h  */
diff --git a/sysdeps/unix/sysv/linux/sparc/sigaction.h b/sysdeps/unix/sysv/linux/sparc/bits/sigaction.h
index 19aa7e39cb..19aa7e39cb 100644
--- a/sysdeps/unix/sysv/linux/sparc/sigaction.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/sigaction.h
diff --git a/sysdeps/unix/sysv/linux/sparc/signum.h b/sysdeps/unix/sysv/linux/sparc/bits/signum.h
index 3437c16113..3437c16113 100644
--- a/sysdeps/unix/sysv/linux/sparc/signum.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/signum.h
diff --git a/sysdeps/unix/sysv/linux/sparc/termbits.h b/sysdeps/unix/sysv/linux/sparc/bits/termios.h
index bf7aa1480f..bf7aa1480f 100644
--- a/sysdeps/unix/sysv/linux/sparc/termbits.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/termios.h
diff --git a/sysdeps/unix/sysv/linux/sparc/profil-counter.h b/sysdeps/unix/sysv/linux/sparc/profil-counter.h
index 258df5ba93..1bd06482c9 100644
--- a/sysdeps/unix/sysv/linux/sparc/profil-counter.h
+++ b/sysdeps/unix/sysv/linux/sparc/profil-counter.h
@@ -17,7 +17,7 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#include <sigcontext.h>
+#include <signal.h>
 
 void
 profil_counter (int signo, __siginfo_t si)
diff --git a/sysdeps/unix/sysv/linux/sparc/socket.S b/sysdeps/unix/sysv/linux/sparc/socket.S
index 24aba3fc74..bdfc2fcc6d 100644
--- a/sysdeps/unix/sysv/linux/sparc/socket.S
+++ b/sysdeps/unix/sysv/linux/sparc/socket.S
@@ -18,7 +18,7 @@
    Boston, MA 02111-1307, USA.  */
 
 #include <sysdep.h>
-#include <sys/socketcall.h>
+#include <socketcall.h>
 
 #define P(a, b) P2(a, b)
 #define P2(a, b) a##b
diff --git a/sysdeps/unix/sysv/linux/sys/kernel_termios.h b/sysdeps/unix/sysv/linux/sys/kernel_termios.h
deleted file mode 100644
index 629508e765..0000000000
--- a/sysdeps/unix/sysv/linux/sys/kernel_termios.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _SYS_KERNEL_TERMIOS_H
-#define _SYS_KERNEL_TERMIOS_H 1
-/* The following corresponds to the values from the Linux 2.1.20 kernel.  */
-
-/* We need the definition of tcflag_t, cc_t, and speed_t.  */
-#include <termbits.h>
-
-#define __KERNEL_NCCS 19
-
-struct __kernel_termios
-  {
-    tcflag_t c_iflag;		/* input mode flags */
-    tcflag_t c_oflag;		/* output mode flags */
-    tcflag_t c_cflag;		/* control mode flags */
-    tcflag_t c_lflag;		/* local mode flags */
-    cc_t c_line;		/* line discipline */
-    cc_t c_cc[__KERNEL_NCCS];	/* control characters */
-  };
-
-#endif /* sys/kernel_termios.h */
diff --git a/sysdeps/unix/sysv/linux/sys/mman.h b/sysdeps/unix/sysv/linux/sys/mman.h
index 367b9062b3..dc9f8f7e48 100644
--- a/sysdeps/unix/sysv/linux/sys/mman.h
+++ b/sysdeps/unix/sysv/linux/sys/mman.h
@@ -22,7 +22,7 @@
 #define	_SYS_MMAN_H	1
 #include <features.h>
 
-#include <gnu/types.h>
+#include <bits/types.h>
 #define __need_size_t
 #include <stddef.h>
 
diff --git a/sysdeps/unix/sysv/linux/sys/syscall.h b/sysdeps/unix/sysv/linux/sys/syscall.h
index cef91f6727..d6b14fcf0a 100644
--- a/sysdeps/unix/sysv/linux/sys/syscall.h
+++ b/sysdeps/unix/sysv/linux/sys/syscall.h
@@ -27,9 +27,9 @@
 #ifndef _LIBC
 /* The Linux kernel header file defines macros `__NR_<name>', but some
    programs expect the traditional form `SYS_<name>'.  So in building libc
-   we scan the kernel's list and produce <syscall-list.h> with macros for
+   we scan the kernel's list and produce <bits/syscall.h> with macros for
    all the `SYS_' names.  */
-#include <syscall-list.h>
+#include <bits/syscall.h>
 #endif
 
 #endif
diff --git a/sysdeps/unix/sysv/linux/tcgetattr.c b/sysdeps/unix/sysv/linux/tcgetattr.c
index 9578c4b772..7866183abe 100644
--- a/sysdeps/unix/sysv/linux/tcgetattr.c
+++ b/sysdeps/unix/sysv/linux/tcgetattr.c
@@ -23,7 +23,7 @@
 /* The difference here is that the termios structure used in the
    kernel is not the same as we use in the libc.  Therefore we must
    translate it here.  */
-#include <sys/kernel_termios.h>
+#include <kernel_termios.h>
 
 /* Put the state of FD into *TERMIOS_P.  */
 int
diff --git a/sysdeps/unix/sysv/linux/tcsetattr.c b/sysdeps/unix/sysv/linux/tcsetattr.c
index 6c128110f6..0b9fee2165 100644
--- a/sysdeps/unix/sysv/linux/tcsetattr.c
+++ b/sysdeps/unix/sysv/linux/tcsetattr.c
@@ -24,7 +24,7 @@
 /* The difference here is that the termios structure used in the
    kernel is not the same as we use in the libc.  Therefore we must
    translate it here.  */
-#include <sys/kernel_termios.h>
+#include <kernel_termios.h>
 
 
 /* Set the state of FD to *TERMIOS_P.  */
diff --git a/sysdeps/unix/sysv/minix/sigaction.h b/sysdeps/unix/sysv/minix/bits/sigaction.h
index 6b0c460914..6b0c460914 100644
--- a/sysdeps/unix/sysv/minix/sigaction.h
+++ b/sysdeps/unix/sysv/minix/bits/sigaction.h
diff --git a/sysdeps/unix/sysv/sco3.2.4/confname.h b/sysdeps/unix/sysv/sco3.2.4/bits/confname.h
index 0408951863..0408951863 100644
--- a/sysdeps/unix/sysv/sco3.2.4/confname.h
+++ b/sysdeps/unix/sysv/sco3.2.4/bits/confname.h
diff --git a/sysdeps/unix/sysv/sco3.2.4/sigaction.h b/sysdeps/unix/sysv/sco3.2.4/bits/sigaction.h
index c21b928cdb..c21b928cdb 100644
--- a/sysdeps/unix/sysv/sco3.2.4/sigaction.h
+++ b/sysdeps/unix/sysv/sco3.2.4/bits/sigaction.h
diff --git a/sysdeps/unix/sysv/sco3.2.4/sysconf.S b/sysdeps/unix/sysv/sco3.2.4/sysconf.S
index 631e5e977a..44c89f2cf8 100644
--- a/sysdeps/unix/sysv/sco3.2.4/sysconf.S
+++ b/sysdeps/unix/sysv/sco3.2.4/sysconf.S
@@ -17,7 +17,7 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
 #include <sysdep.h>
-#include <confname.h>
+#include <bits/confname.h>
 
 .globl	__tzname_max
 ENTRY (__sysconf)
diff --git a/sysdeps/unix/sysv/sco3.2/local_lim.h b/sysdeps/unix/sysv/sco3.2/bits/local_lim.h
index e456816446..365858c6f8 100644
--- a/sysdeps/unix/sysv/sco3.2/local_lim.h
+++ b/sysdeps/unix/sysv/sco3.2/bits/local_lim.h
@@ -16,8 +16,8 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _LOCAL_LIM_H
-#define _LOCAL_LIM_H 1
+#ifndef _BITS_LOCAL_LIM_H
+#define _BITS_LOCAL_LIM_H 1
 
 #define NGROUPS_MAX 8		/* Maximum number of supplementary groups.  */
 #define ARG_MAX 5120
@@ -34,4 +34,4 @@
 
 #define PATH_MAX 1024
 
-#endif	/* local_lim.h */
+#endif	/* bits/local_lim.h */
diff --git a/sysdeps/unix/sysv/sysv4/sigaction.h b/sysdeps/unix/sysv/sysv4/bits/sigaction.h
index 1305ba61e6..1305ba61e6 100644
--- a/sysdeps/unix/sysv/sysv4/sigaction.h
+++ b/sysdeps/unix/sysv/sysv4/bits/sigaction.h
diff --git a/sysdeps/unix/sysv/sysv4/signum.h b/sysdeps/unix/sysv/sysv4/bits/signum.h
index f11c731a42..f11c731a42 100644
--- a/sysdeps/unix/sysv/sysv4/signum.h
+++ b/sysdeps/unix/sysv/sysv4/bits/signum.h
diff --git a/sysdeps/unix/sysv/sysv4/sigset.h b/sysdeps/unix/sysv/sysv4/bits/sigset.h
index 1461c93b3d..1461c93b3d 100644
--- a/sysdeps/unix/sysv/sysv4/sigset.h
+++ b/sysdeps/unix/sysv/sysv4/bits/sigset.h
diff --git a/sysdeps/unix/sysv/sysv4/utsnamelen.h b/sysdeps/unix/sysv/sysv4/bits/utsname.h
index 9dcc618068..9dcc618068 100644
--- a/sysdeps/unix/sysv/sysv4/utsnamelen.h
+++ b/sysdeps/unix/sysv/sysv4/bits/utsname.h
diff --git a/sysdeps/unix/sysv/sysv4/waitflags.h b/sysdeps/unix/sysv/sysv4/bits/waitflags.h
index f5613c1327..29ff566342 100644
--- a/sysdeps/unix/sysv/sysv4/waitflags.h
+++ b/sysdeps/unix/sysv/sysv4/bits/waitflags.h
@@ -1,5 +1,5 @@
 /* Definitions of flag bits for `waitpid' et al.
-   Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Brendan Kehoe (brendan@zen.org).
 
@@ -18,9 +18,10 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_WAITFLAGS_H
+#ifndef _SYS_WAIT_H
+#error "Never use <bits/waitflags.h> directly; include <sys/wait.h> instead."
+#endif
 
-#define	_WAITFLAGS_H	1
 
 /* Bits in the third argument to `waitpid'.  */
 #define	WNOHANG		64	/* Don't block waiting.  */
@@ -31,5 +32,3 @@
 #define WTRAPPED	2	/* Look for processes that stopped
 				   while tracing.  */
 #endif
-
-#endif	/* waitflags.h */
diff --git a/sysdeps/unix/sysv/sysv4/i386/statbuf.h b/sysdeps/unix/sysv/sysv4/i386/bits/stat.h
index 9354d6790c..9b6fed083d 100644
--- a/sysdeps/unix/sysv/sysv4/i386/statbuf.h
+++ b/sysdeps/unix/sysv/sysv4/i386/bits/stat.h
@@ -17,10 +17,14 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_STATBUF_H
-#define	_STATBUF_H	1
+/*
+ * Never include this file directly; use <sys/stat.h> instead.
+ */
 
-#include <gnu/types.h>
+#ifndef	_BITS_STAT_H
+#define	_BITS_STAT_H	1
+
+#include <bits/types.h>
 
 /* Versions of the `struct stat' data structure and
    the bits of the `xmknod' interface.  */
@@ -87,4 +91,4 @@ struct stat
 #define	__S_IWRITE	0200	/* Write by owner.  */
 #define	__S_IEXEC	0100	/* Execute by owner.  */
 
-#endif	/* statbuf.h */
+#endif	/* bits/stat.h */
diff --git a/sysdeps/unix/sysv/sysv4/i386/sysdep.h b/sysdeps/unix/sysv/sysv4/i386/sysdep.h
index 1e0cd69f74..ad262e23de 100644
--- a/sysdeps/unix/sysv/sysv4/i386/sysdep.h
+++ b/sysdeps/unix/sysv/sysv4/i386/sysdep.h
@@ -24,7 +24,7 @@ Cambridge, MA 02139, USA.  */
 #ifndef _ERRNO_H
 #define _ERRNO_H
 #endif
-#include <errnos.h>
+#include <bits/errno.h>
 
 #undef	PSEUDO
 #define	PSEUDO(name, syscall_name, args)				      \
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/signum.h b/sysdeps/unix/sysv/sysv4/solaris2/bits/signum.h
index 4e5576425b..4e5576425b 100644
--- a/sysdeps/unix/sysv/sysv4/solaris2/signum.h
+++ b/sysdeps/unix/sysv/sysv4/solaris2/bits/signum.h
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/statbuf.h b/sysdeps/unix/sysv/sysv4/solaris2/bits/stat.h
index e4e2ab8bcf..ea5f1f4279 100644
--- a/sysdeps/unix/sysv/sysv4/solaris2/statbuf.h
+++ b/sysdeps/unix/sysv/sysv4/solaris2/bits/stat.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Brendan Kehoe (brendan@zen.org).
 
@@ -17,10 +17,14 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	_STATBUF_H
-#define	_STATBUF_H	1
+/*
+ * Never include this file directly; use <sys/stat.h> instead.
+ */
 
-#include <gnu/types.h>
+#ifndef	_BITS_STAT_H
+#define	_BITS_STAT_H	1
+
+#include <bits/types.h>
 
 /* Structure describing file characteristics.  */
 struct stat
@@ -80,4 +84,4 @@ struct stat
 #define	__S_IWRITE	0200	/* Write by owner.  */
 #define	__S_IEXEC	0100	/* Execute by owner.  */
 
-#endif	/* statbuf.h */
+#endif	/* bits/stat.h */
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/sparc/bits/sigcontext.h b/sysdeps/unix/sysv/sysv4/solaris2/sparc/bits/sigcontext.h
new file mode 100644
index 0000000000..7402704864
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/solaris2/sparc/bits/sigcontext.h
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/sun/sparc/bits/sigcontext.h>
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/sparc/sigcontext.h b/sysdeps/unix/sysv/sysv4/solaris2/sparc/sigcontext.h
deleted file mode 100644
index 532b3793ec..0000000000
--- a/sysdeps/unix/sysv/sysv4/solaris2/sparc/sigcontext.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/bsd/sun/sparc/sigcontext.h>
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.S b/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.S
index da3cd6b8be..edefad0168 100644
--- a/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.S
+++ b/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.S
@@ -18,7 +18,7 @@ Cambridge, MA 02139, USA.  */
 
 #include <sysdep.h>
 #define _ERRNO_H
-#include <errnos.h>
+#include <bits/errno.h>
 
 ENTRY(syscall_error)
 	/* If it was a syscall that got interrupted, but can
diff --git a/sysdeps/unix/sysv/utmpbits.h b/sysdeps/unix/sysv/utmpbits.h
deleted file mode 100644
index 3d2ccf3b12..0000000000
--- a/sysdeps/unix/sysv/utmpbits.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* The `struct utmp' type, describing entries in the utmp file.  System V.
-Copyright (C) 1996 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.  */
-
-#ifndef _UTMPBITS_H
-
-#define _UTMPBITS_H	1
-
-#include <time.h>
-
-#define _PATH_UTMP      "/var/adm/utmp"
-#define _PATH_WTMP      "/var/adm/wtmp"
-#define _PATH_LASTLOG   "/var/adm/lastlog"
-
-__BEGIN_DECLS
-
-struct utmp
-  {
-#define	ut_name	ut_user
-    char ut_user[8];
-    char ut_id[4];
-    char ut_line[12];
-    short ut_pid;
-    short ut_type;
-    struct exit_status
-      {
-	short e_termination;
-	short e_exit;
-      } ut_exit;
-    time_t ut_time;
-  };
-
-
-/* Tell the user that we have a modern system with UT_HOST, UT_TYPE, UT_ID
-   and UT_TV fields.  */
-#define _HAVE_UT_TYPE	1
-#define _HAVE_UT_ID	1
-#define _HAVE_UT_TV	1
-#define _HAVE_UT_HOST	1
-
-__END_DECLS
-
-#endif /* utmpbits.h  */
diff --git a/sysdeps/vax/huge_val.h b/sysdeps/vax/bits/huge_val.h
index 02cafb0141..f323049d83 100644
--- a/sysdeps/vax/huge_val.h
+++ b/sysdeps/vax/bits/huge_val.h
@@ -18,9 +18,9 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef	   _HUGE_VAL_H
-#define	   _HUGE_VAL_H	1
+#ifndef _MATH_H
+#error "Never use <bits/huge_val.h> directly; include <math.h> instead."
+#endif
 
-#define	   HUGE_VAL	1.70141182460469227e38
 
-#endif	   /* huge_val.h */
+#define	   HUGE_VAL	1.70141182460469227e38
diff --git a/sysdeps/vax/jmp_buf.h b/sysdeps/vax/bits/setjmp.h
index 7adecd9a17..7adecd9a17 100644
--- a/sysdeps/vax/jmp_buf.h
+++ b/sysdeps/vax/bits/setjmp.h
diff --git a/sysdeps/wordsize-32/elfclass.h b/sysdeps/wordsize-32/bits/elfclass.h
index 49411d66f3..49411d66f3 100644
--- a/sysdeps/wordsize-32/elfclass.h
+++ b/sysdeps/wordsize-32/bits/elfclass.h
diff --git a/sysdeps/wordsize-32/inttypes.h b/sysdeps/wordsize-32/inttypes.h
index f3029cc823..a2648bf2e2 100644
--- a/sysdeps/wordsize-32/inttypes.h
+++ b/sysdeps/wordsize-32/inttypes.h
@@ -28,10 +28,15 @@
 /* Exact integral types.  */
 
 /* Signed.  */
+
+/* There is some amount of overlap with <sys/types.h> as known by inet code */
+#ifndef __int8_t_defined
+#define __int8_t_defined
 typedef signed char    int8_t;
 typedef short int     int16_t;
 typedef int           int32_t;
 typedef long long int int64_t;
+#endif
 
 /* Unsigned.  */
 typedef unsigned char           uint8_t;
diff --git a/sysdeps/wordsize-64/elfclass.h b/sysdeps/wordsize-64/bits/elfclass.h
index ac52904886..ac52904886 100644
--- a/sysdeps/wordsize-64/elfclass.h
+++ b/sysdeps/wordsize-64/bits/elfclass.h
diff --git a/sysdeps/wordsize-64/inttypes.h b/sysdeps/wordsize-64/inttypes.h
index b94aff0749..07680d0488 100644
--- a/sysdeps/wordsize-64/inttypes.h
+++ b/sysdeps/wordsize-64/inttypes.h
@@ -28,10 +28,15 @@
 /* Exact integral types.  */
 
 /* Signed.  */
+
+/* There is some amount of overlap with <sys/types.h> as known by inet code */
+#ifndef __int8_t_defined
+#define __int8_t_defined
 typedef signed char int8_t;
 typedef short int  int16_t;
 typedef int        int32_t;
 typedef long int   int64_t;
+#endif
 
 /* Unsigned.  */
 typedef unsigned char       uint8_t;