aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-02-18 01:27:10 +0000
committerRoland McGrath <roland@gnu.org>1995-02-18 01:27:10 +0000
commit28f540f45bbacd939bfd07f213bcad2bf730b1bf (patch)
tree15f07c4c43d635959c6afee96bde71fb1b3614ee /sysdeps
downloadglibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.zip
glibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.tar.gz
glibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.tar.bz2
initial import
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/alpha/DEFS.h27
-rw-r--r--sysdeps/alpha/Dist4
-rw-r--r--sysdeps/alpha/Implies2
-rw-r--r--sysdeps/alpha/Makefile94
-rw-r--r--sysdeps/alpha/__longjmp.c91
-rw-r--r--sysdeps/alpha/__math.h35
-rw-r--r--sysdeps/alpha/bsd-_setjmp.S30
-rw-r--r--sysdeps/alpha/bsd-setjmp.S30
-rw-r--r--sysdeps/alpha/bytesex.h3
-rw-r--r--sysdeps/alpha/copysign.c31
-rw-r--r--sysdeps/alpha/divl.S54
-rw-r--r--sysdeps/alpha/divlu.S54
-rw-r--r--sysdeps/alpha/divq.S51
-rw-r--r--sysdeps/alpha/divqu.S57
-rw-r--r--sysdeps/alpha/divrem.m448
-rw-r--r--sysdeps/alpha/fabs.c28
-rw-r--r--sysdeps/alpha/gmp-mparam.h26
-rw-r--r--sysdeps/alpha/jmp_buf.h46
-rw-r--r--sysdeps/alpha/macros.m434
-rw-r--r--sysdeps/alpha/memchr.c86
-rw-r--r--sysdeps/alpha/reml.S57
-rw-r--r--sysdeps/alpha/remlu.S57
-rw-r--r--sysdeps/alpha/remq.S54
-rw-r--r--sysdeps/alpha/remqu.S60
-rw-r--r--sysdeps/alpha/setjmp.S29
-rw-r--r--sysdeps/alpha/setjmp_aux.c74
-rw-r--r--sysdeps/alpha/strchr.c84
-rw-r--r--sysdeps/alpha/strlen.c54
-rw-r--r--sysdeps/alpha/udiv_qrnnd.S152
-rw-r--r--sysdeps/am29k/ffs.c40
-rw-r--r--sysdeps/generic/Dist8
-rw-r--r--sysdeps/generic/Makefile60
-rw-r--r--sysdeps/generic/_strerror.c43
-rw-r--r--sysdeps/generic/abort.c42
-rw-r--r--sysdeps/generic/acos.c42
-rw-r--r--sysdeps/generic/acosh.c102
-rw-r--r--sysdeps/generic/add_1.c61
-rw-r--r--sysdeps/generic/add_n.c61
-rw-r--r--sysdeps/generic/addmul_1.c64
-rw-r--r--sysdeps/generic/asin.c44
-rw-r--r--sysdeps/generic/asincos.c169
-rw-r--r--sysdeps/generic/asinh.c101
-rw-r--r--sysdeps/generic/atan.c27
-rw-r--r--sysdeps/generic/atan2.c281
-rw-r--r--sysdeps/generic/atanh.c83
-rw-r--r--sysdeps/generic/bcopy.c31
-rw-r--r--sysdeps/generic/bzero.c81
-rw-r--r--sysdeps/generic/cabs.c26
-rw-r--r--sysdeps/generic/ceil.c68
-rw-r--r--sysdeps/generic/cmp.c55
-rwxr-xr-xsysdeps/generic/configure52
-rw-r--r--sysdeps/generic/configure.in7
-rw-r--r--sysdeps/generic/confname.h76
-rw-r--r--sysdeps/generic/copysign.c30
-rw-r--r--sysdeps/generic/cosh.c133
-rw-r--r--sysdeps/generic/det_endian.c34
-rw-r--r--sysdeps/generic/divmod.c234
-rw-r--r--sysdeps/generic/divmod_1.c209
-rw-r--r--sysdeps/generic/exp.c203
-rw-r--r--sysdeps/generic/exp__E.c136
-rw-r--r--sysdeps/generic/expm1.c169
-rw-r--r--sysdeps/generic/fabs.c27
-rw-r--r--sysdeps/generic/ffs.c47
-rw-r--r--sysdeps/generic/floor.c74
-rw-r--r--sysdeps/generic/fmod.c155
-rw-r--r--sysdeps/generic/frexp.c53
-rw-r--r--sysdeps/generic/ftime.c44
-rw-r--r--sysdeps/generic/get_str.c213
-rw-r--r--sysdeps/generic/getenv.c44
-rw-r--r--sysdeps/generic/getpgrp.c28
-rw-r--r--sysdeps/generic/gmp-mparam.h26
-rw-r--r--sysdeps/generic/htonl.c32
-rw-r--r--sysdeps/generic/htons.c32
-rw-r--r--sysdeps/generic/hypot.c27
-rw-r--r--sysdeps/generic/infnan.c48
-rw-r--r--sysdeps/generic/isnan.c29
-rw-r--r--sysdeps/generic/ldexp.c27
-rw-r--r--sysdeps/generic/log.c486
-rw-r--r--sysdeps/generic/log10.c37
-rw-r--r--sysdeps/generic/log1p.c170
-rw-r--r--sysdeps/generic/log__L.c110
-rw-r--r--sysdeps/generic/lshift.c86
-rw-r--r--sysdeps/generic/lstat.c31
-rw-r--r--sysdeps/generic/make_siglist.c51
-rw-r--r--sysdeps/generic/mathimpl.h127
-rw-r--r--sysdeps/generic/memccpy.c44
-rw-r--r--sysdeps/generic/memchr.c168
-rw-r--r--sysdeps/generic/memcmp.c369
-rw-r--r--sysdeps/generic/memcopy.h149
-rw-r--r--sysdeps/generic/memcpy.c55
-rw-r--r--sysdeps/generic/memmem.c46
-rw-r--r--sysdeps/generic/memmove.c99
-rw-r--r--sysdeps/generic/memset.c85
-rw-r--r--sysdeps/generic/mig-reply.c53
-rw-r--r--sysdeps/generic/mod_1.c198
-rw-r--r--sysdeps/generic/modf.c31
-rw-r--r--sysdeps/generic/morecore.c48
-rw-r--r--sysdeps/generic/mul.c147
-rw-r--r--sysdeps/generic/mul_1.c58
-rw-r--r--sysdeps/generic/mul_n.c420
-rw-r--r--sysdeps/generic/ntohl.c32
-rw-r--r--sysdeps/generic/ntohs.c32
-rw-r--r--sysdeps/generic/pow.c215
-rw-r--r--sysdeps/generic/putenv.c101
-rw-r--r--sysdeps/generic/resourcebits.h53
-rw-r--r--sysdeps/generic/rint.c87
-rw-r--r--sysdeps/generic/rshift.c87
-rw-r--r--sysdeps/generic/sbrk.c42
-rw-r--r--sysdeps/generic/setenv.c86
-rw-r--r--sysdeps/generic/sigaction.h50
-rw-r--r--sysdeps/generic/signame.c275
-rw-r--r--sysdeps/generic/signame.h57
-rw-r--r--sysdeps/generic/sigset.h79
-rw-r--r--sysdeps/generic/sincos.c98
-rw-r--r--sysdeps/generic/sinh.c121
-rw-r--r--sysdeps/generic/sockaddrcom.h34
-rw-r--r--sysdeps/generic/speed.c67
-rw-r--r--sysdeps/generic/stpcpy.c35
-rw-r--r--sysdeps/generic/stpncpy.c89
-rw-r--r--sysdeps/generic/strcasecmp.c46
-rw-r--r--sysdeps/generic/strcat.c48
-rw-r--r--sysdeps/generic/strchr.c183
-rw-r--r--sysdeps/generic/strcmp.c43
-rw-r--r--sysdeps/generic/strcpy.c41
-rw-r--r--sysdeps/generic/strcspn.c38
-rw-r--r--sysdeps/generic/strlen.c149
-rw-r--r--sysdeps/generic/strncase.c47
-rw-r--r--sysdeps/generic/strncat.c76
-rw-r--r--sysdeps/generic/strncmp.c69
-rw-r--r--sysdeps/generic/strncpy.c82
-rw-r--r--sysdeps/generic/strpbrk.c38
-rw-r--r--sysdeps/generic/strrchr.c49
-rw-r--r--sysdeps/generic/strsep.c39
-rw-r--r--sysdeps/generic/strspn.c44
-rw-r--r--sysdeps/generic/strstr.c56
-rw-r--r--sysdeps/generic/sub_n.c61
-rw-r--r--sysdeps/generic/submul_1.c64
-rw-r--r--sysdeps/generic/sys/mman.h106
-rw-r--r--sysdeps/generic/sysd-stdio.c189
-rw-r--r--sysdeps/generic/tan.c74
-rw-r--r--sysdeps/generic/tanh.c99
-rw-r--r--sysdeps/generic/termbits.h202
-rw-r--r--sysdeps/generic/trig.h215
-rw-r--r--sysdeps/generic/uname.c63
-rw-r--r--sysdeps/generic/utsnamelen.h3
-rw-r--r--sysdeps/generic/varargs.h61
-rw-r--r--sysdeps/generic/vfork.c31
-rw-r--r--sysdeps/generic/vlimit.c51
-rw-r--r--sysdeps/generic/vtimes.c66
-rw-r--r--sysdeps/generic/waitstatus.h103
-rw-r--r--sysdeps/generic/wordcopy.c405
-rw-r--r--sysdeps/i386/Implies1
-rw-r--r--sysdeps/i386/Makefile3
-rw-r--r--sysdeps/i386/__longjmp.c66
-rw-r--r--sysdeps/i386/abort.c28
-rw-r--r--sysdeps/i386/add_n.S94
-rw-r--r--sysdeps/i386/addmul_1.S75
-rw-r--r--sysdeps/i386/asm-syntax.h64
-rw-r--r--sysdeps/i386/bsd-_setjmp.S32
-rw-r--r--sysdeps/i386/bsd-setjmp.S32
-rw-r--r--sysdeps/i386/bytesex.h3
-rw-r--r--sysdeps/i386/bzero.c81
-rw-r--r--sysdeps/i386/ffs.c45
-rw-r--r--sysdeps/i386/i586/memcopy.h94
-rw-r--r--sysdeps/i386/jmp_buf.h9
-rw-r--r--sysdeps/i386/lshift.S84
-rw-r--r--sysdeps/i386/memchr.c48
-rw-r--r--sysdeps/i386/memcopy.h86
-rw-r--r--sysdeps/i386/memset.c83
-rw-r--r--sysdeps/i386/mul_1.S74
-rw-r--r--sysdeps/i386/rshift.S86
-rw-r--r--sysdeps/i386/setjmp.c55
-rw-r--r--sysdeps/i386/strlen.c36
-rw-r--r--sysdeps/i386/sub_n.S94
-rw-r--r--sysdeps/i386/submul_1.S75
-rw-r--r--sysdeps/i860/memcopy.h33
-rw-r--r--sysdeps/i960/Implies2
-rw-r--r--sysdeps/i960/ffs.c43
-rw-r--r--sysdeps/ieee754/Dist2
-rw-r--r--sysdeps/ieee754/cabs.c228
-rw-r--r--sysdeps/ieee754/cbrt.c120
-rw-r--r--sysdeps/ieee754/copysign.c37
-rw-r--r--sysdeps/ieee754/dbl2mpn.c107
-rw-r--r--sysdeps/ieee754/drem.c107
-rw-r--r--sysdeps/ieee754/frexp.c42
-rw-r--r--sysdeps/ieee754/huge_val.h87
-rw-r--r--sysdeps/ieee754/ieee754.h153
-rw-r--r--sysdeps/ieee754/infnan.c50
-rw-r--r--sysdeps/ieee754/isinf.c40
-rw-r--r--sysdeps/ieee754/isinfl.c44
-rw-r--r--sysdeps/ieee754/isnan.c37
-rw-r--r--sysdeps/ieee754/isnanl.c40
-rw-r--r--sysdeps/ieee754/ldbl2mpn.c93
-rw-r--r--sysdeps/ieee754/ldexp.c145
-rw-r--r--sysdeps/ieee754/log10.c30
-rw-r--r--sysdeps/ieee754/logb.c48
-rw-r--r--sysdeps/ieee754/mpn2dbl.c46
-rw-r--r--sysdeps/ieee754/mpn2flt.c42
-rw-r--r--sysdeps/ieee754/mpn2ldbl.c46
-rw-r--r--sysdeps/ieee754/nan.h46
-rw-r--r--sysdeps/ieee754/sqrt.c120
-rw-r--r--sysdeps/ieee754/support.c524
-rw-r--r--sysdeps/m68k/Implies2
-rw-r--r--sysdeps/m68k/Makefile32
-rw-r--r--sysdeps/m68k/__longjmp.c56
-rw-r--r--sysdeps/m68k/bsd-_setjmp.S42
-rw-r--r--sysdeps/m68k/bsd-setjmp.S42
-rw-r--r--sysdeps/m68k/bytesex.h3
-rw-r--r--sysdeps/m68k/ffs.c42
-rw-r--r--sysdeps/m68k/fpu/Makefile11
-rw-r--r--sysdeps/m68k/fpu/__math.h168
-rw-r--r--sysdeps/m68k/fpu/acos.c32
-rw-r--r--sysdeps/m68k/fpu/asin.c2
-rw-r--r--sysdeps/m68k/fpu/atan.c2
-rw-r--r--sysdeps/m68k/fpu/atan2.c71
-rw-r--r--sysdeps/m68k/fpu/atanh.c2
-rw-r--r--sysdeps/m68k/fpu/ceil.c4
-rw-r--r--sysdeps/m68k/fpu/cos.c2
-rw-r--r--sysdeps/m68k/fpu/cosh.c2
-rw-r--r--sysdeps/m68k/fpu/drem.c31
-rw-r--r--sysdeps/m68k/fpu/exp.c3
-rw-r--r--sysdeps/m68k/fpu/expm1.c3
-rw-r--r--sysdeps/m68k/fpu/fabs.c3
-rw-r--r--sysdeps/m68k/fpu/fl.h41
-rw-r--r--sysdeps/m68k/fpu/floor.c3
-rw-r--r--sysdeps/m68k/fpu/fmod.c27
-rw-r--r--sysdeps/m68k/fpu/frexp.c27
-rw-r--r--sysdeps/m68k/fpu/isinf.c34
-rw-r--r--sysdeps/m68k/fpu/isnan.c4
-rw-r--r--sysdeps/m68k/fpu/ldexp.c27
-rw-r--r--sysdeps/m68k/fpu/log.c3
-rw-r--r--sysdeps/m68k/fpu/log10.c2
-rw-r--r--sysdeps/m68k/fpu/log1p.c2
-rw-r--r--sysdeps/m68k/fpu/logb.c46
-rw-r--r--sysdeps/m68k/fpu/pow.c27
-rw-r--r--sysdeps/m68k/fpu/rint.c5
-rw-r--r--sysdeps/m68k/fpu/sin.c2
-rw-r--r--sysdeps/m68k/fpu/sinh.c2
-rw-r--r--sysdeps/m68k/fpu/sqrt.c2
-rw-r--r--sysdeps/m68k/fpu/switch/68881-sw.h64
-rw-r--r--sysdeps/m68k/fpu/switch/Dist1
-rw-r--r--sysdeps/m68k/fpu/switch/Makefile52
-rw-r--r--sysdeps/m68k/fpu/switch/__math.h1
-rw-r--r--sysdeps/m68k/fpu/switch/switch.c86
-rw-r--r--sysdeps/m68k/fpu/tan.c2
-rw-r--r--sysdeps/m68k/fpu/tanh.c2
-rw-r--r--sysdeps/m68k/jmp_buf.h19
-rw-r--r--sysdeps/m68k/m68020/add_n.S76
-rw-r--r--sysdeps/m68k/m68020/addmul_1.S80
-rw-r--r--sysdeps/m68k/m68020/asm-syntax.h105
-rw-r--r--sysdeps/m68k/m68020/mul_1.S87
-rw-r--r--sysdeps/m68k/m68020/sub_n.S76
-rw-r--r--sysdeps/m68k/m68020/submul_1.S80
-rw-r--r--sysdeps/m68k/memcopy.h95
-rw-r--r--sysdeps/m68k/setjmp.c48
-rw-r--r--sysdeps/m88k/ffs.c42
-rw-r--r--sysdeps/m88k/m88100/add_n.S133
-rw-r--r--sysdeps/m88k/m88100/mul_1.S127
-rw-r--r--sysdeps/m88k/m88100/sub_n.S134
-rw-r--r--sysdeps/m88k/m88110/mul_1.S80
-rw-r--r--sysdeps/mach/Makefile74
-rw-r--r--sysdeps/mach/Subdirs1
-rw-r--r--sysdeps/mach/_strerror.c60
-rw-r--r--sysdeps/mach/adjtime.c46
-rw-r--r--sysdeps/mach/alpha/machine-lock.h80
-rw-r--r--sysdeps/mach/alpha/machine-sp.h36
-rw-r--r--sysdeps/mach/alpha/syscall.S39
-rw-r--r--sysdeps/mach/alpha/sysdep.h41
-rw-r--r--sysdeps/mach/alpha/thread_state.h39
-rw-r--r--sysdeps/mach/configure17
-rw-r--r--sysdeps/mach/configure.in15
-rw-r--r--sysdeps/mach/getpagesize.c32
-rw-r--r--sysdeps/mach/gettimeofday.c47
-rw-r--r--sysdeps/mach/hppa/machine-lock.h63
-rw-r--r--sysdeps/mach/hurd/.cvsignore4
-rw-r--r--sysdeps/mach/hurd/Dist3
-rw-r--r--sysdeps/mach/hurd/Implies2
-rw-r--r--sysdeps/mach/hurd/Makefile132
-rw-r--r--sysdeps/mach/hurd/Subdirs1
-rw-r--r--sysdeps/mach/hurd/_exit.c54
-rw-r--r--sysdeps/mach/hurd/accept.c71
-rw-r--r--sysdeps/mach/hurd/access.c138
-rw-r--r--sysdeps/mach/hurd/adjtime.c53
-rw-r--r--sysdeps/mach/hurd/alpha/exc2signal.c76
-rw-r--r--sysdeps/mach/hurd/alpha/longjmp-ctx.c38
-rw-r--r--sysdeps/mach/hurd/alpha/longjmp-ts.c41
-rw-r--r--sysdeps/mach/hurd/alpha/sigcontext.h65
-rw-r--r--sysdeps/mach/hurd/alpha/sigreturn.c212
-rw-r--r--sysdeps/mach/hurd/alpha/trampoline.c286
-rw-r--r--sysdeps/mach/hurd/bind.c102
-rw-r--r--sysdeps/mach/hurd/brk.c130
-rw-r--r--sysdeps/mach/hurd/chdir.c45
-rw-r--r--sysdeps/mach/hurd/chflags.c38
-rw-r--r--sysdeps/mach/hurd/chmod.c40
-rw-r--r--sysdeps/mach/hurd/chown.c41
-rw-r--r--sysdeps/mach/hurd/chroot.c45
-rw-r--r--sysdeps/mach/hurd/close.c36
-rw-r--r--sysdeps/mach/hurd/closedir.c52
-rwxr-xr-xsysdeps/mach/hurd/configure21
-rw-r--r--sysdeps/mach/hurd/configure.in19
-rw-r--r--sysdeps/mach/hurd/connect.c75
-rw-r--r--sysdeps/mach/hurd/defs.c85
-rw-r--r--sysdeps/mach/hurd/dirstream.h40
-rw-r--r--sysdeps/mach/hurd/dup2.c114
-rw-r--r--sysdeps/mach/hurd/err_hurd.sub11
-rw-r--r--sysdeps/mach/hurd/errlist.awk77
-rw-r--r--sysdeps/mach/hurd/errlist.c93
-rw-r--r--sysdeps/mach/hurd/errnos.awk157
-rw-r--r--sysdeps/mach/hurd/errnos.h266
-rw-r--r--sysdeps/mach/hurd/execve.c45
-rw-r--r--sysdeps/mach/hurd/fchdir.c45
-rw-r--r--sysdeps/mach/hurd/fchflags.c36
-rw-r--r--sysdeps/mach/hurd/fchmod.c38
-rw-r--r--sysdeps/mach/hurd/fchown.c39
-rw-r--r--sysdeps/mach/hurd/fcntl.c159
-rw-r--r--sysdeps/mach/hurd/fcntlbits.h178
-rw-r--r--sysdeps/mach/hurd/fdopen.c69
-rw-r--r--sysdeps/mach/hurd/fexecve.c34
-rw-r--r--sysdeps/mach/hurd/flock.c39
-rw-r--r--sysdeps/mach/hurd/fork.c574
-rw-r--r--sysdeps/mach/hurd/fstat.c38
-rw-r--r--sysdeps/mach/hurd/fsync.c33
-rw-r--r--sysdeps/mach/hurd/ftruncate.c34
-rw-r--r--sysdeps/mach/hurd/getcwd.c250
-rw-r--r--sysdeps/mach/hurd/getdents.c62
-rw-r--r--sysdeps/mach/hurd/getdtsz.c39
-rw-r--r--sysdeps/mach/hurd/getegid.c58
-rw-r--r--sysdeps/mach/hurd/geteuid.c58
-rw-r--r--sysdeps/mach/hurd/getgid.c55
-rw-r--r--sysdeps/mach/hurd/getgroups.c68
-rw-r--r--sysdeps/mach/hurd/gethostid.c33
-rw-r--r--sysdeps/mach/hurd/gethostname.c48
-rw-r--r--sysdeps/mach/hurd/getitimer.c104
-rw-r--r--sysdeps/mach/hurd/getlogin.c40
-rw-r--r--sysdeps/mach/hurd/getpeername.c59
-rw-r--r--sysdeps/mach/hurd/getpgid.c44
-rw-r--r--sysdeps/mach/hurd/getpid.c32
-rw-r--r--sysdeps/mach/hurd/getppid.c34
-rw-r--r--sysdeps/mach/hurd/getpriority.c73
-rw-r--r--sysdeps/mach/hurd/getrlimit.c46
-rw-r--r--sysdeps/mach/hurd/getsockname.c58
-rw-r--r--sysdeps/mach/hurd/getsockopt.c53
-rw-r--r--sysdeps/mach/hurd/getuid.c55
-rw-r--r--sysdeps/mach/hurd/hppa/sigcontext.h86
-rw-r--r--sysdeps/mach/hurd/hppa/trampoline.c258
-rw-r--r--sysdeps/mach/hurd/i386/exc2signal.c165
-rw-r--r--sysdeps/mach/hurd/i386/init-fault.c41
-rw-r--r--sysdeps/mach/hurd/i386/longjmp-ctx.c35
-rw-r--r--sysdeps/mach/hurd/i386/longjmp-ts.c39
-rw-r--r--sysdeps/mach/hurd/i386/sigcontext.h106
-rw-r--r--sysdeps/mach/hurd/i386/sigreturn.c126
-rw-r--r--sysdeps/mach/hurd/i386/trampoline.c271
-rw-r--r--sysdeps/mach/hurd/ioctl.c242
-rw-r--r--sysdeps/mach/hurd/ioctls.h323
-rw-r--r--sysdeps/mach/hurd/isatty.c39
-rw-r--r--sysdeps/mach/hurd/kill.c106
-rw-r--r--sysdeps/mach/hurd/libc-ldscript5
-rw-r--r--sysdeps/mach/hurd/link.c60
-rw-r--r--sysdeps/mach/hurd/listen.c36
-rw-r--r--sysdeps/mach/hurd/local_lim.h40
-rw-r--r--sysdeps/mach/hurd/lseek.c35
-rw-r--r--sysdeps/mach/hurd/lstat.c40
-rw-r--r--sysdeps/mach/hurd/mig-reply.c86
-rw-r--r--sysdeps/mach/hurd/mips/exc2signal.c98
-rw-r--r--sysdeps/mach/hurd/mips/init-fault.c41
-rw-r--r--sysdeps/mach/hurd/mips/longjmp-ctx.c41
-rw-r--r--sysdeps/mach/hurd/mips/longjmp-ts.c45
-rw-r--r--sysdeps/mach/hurd/mips/sigcontext.h71
-rw-r--r--sysdeps/mach/hurd/mips/sigreturn.c169
-rw-r--r--sysdeps/mach/hurd/mips/trampoline.c260
-rw-r--r--sysdeps/mach/hurd/mkdir.c41
-rw-r--r--sysdeps/mach/hurd/mknod.c114
-rw-r--r--sysdeps/mach/hurd/mmap.c105
-rw-r--r--sysdeps/mach/hurd/open.c51
-rw-r--r--sysdeps/mach/hurd/opendir.c60
-rw-r--r--sysdeps/mach/hurd/pipe.c99
-rw-r--r--sysdeps/mach/hurd/ptrace.c392
-rw-r--r--sysdeps/mach/hurd/read.c34
-rw-r--r--sysdeps/mach/hurd/readdir.c90
-rw-r--r--sysdeps/mach/hurd/readlink.c76
-rw-r--r--sysdeps/mach/hurd/reboot.c51
-rw-r--r--sysdeps/mach/hurd/recv.c60
-rw-r--r--sysdeps/mach/hurd/recvfrom.c85
-rw-r--r--sysdeps/mach/hurd/rename.c47
-rw-r--r--sysdeps/mach/hurd/rewinddir.c31
-rw-r--r--sysdeps/mach/hurd/rmdir.c41
-rw-r--r--sysdeps/mach/hurd/sbrk.c42
-rw-r--r--sysdeps/mach/hurd/seekdir.c35
-rw-r--r--sysdeps/mach/hurd/select.c275
-rw-r--r--sysdeps/mach/hurd/send.c40
-rw-r--r--sysdeps/mach/hurd/sendto.c60
-rw-r--r--sysdeps/mach/hurd/setegid.c67
-rw-r--r--sysdeps/mach/hurd/seteuid.c67
-rw-r--r--sysdeps/mach/hurd/setgid.c76
-rw-r--r--sysdeps/mach/hurd/setgroups.c63
-rw-r--r--sysdeps/mach/hurd/sethostid.c31
-rw-r--r--sysdeps/mach/hurd/sethostname.c34
-rw-r--r--sysdeps/mach/hurd/setitimer.c332
-rw-r--r--sysdeps/mach/hurd/setlogin.c32
-rw-r--r--sysdeps/mach/hurd/setpgid.c57
-rw-r--r--sysdeps/mach/hurd/setpriority.c85
-rw-r--r--sysdeps/mach/hurd/setregid.c71
-rw-r--r--sysdeps/mach/hurd/setreuid.c71
-rw-r--r--sysdeps/mach/hurd/setrlimit.c58
-rw-r--r--sysdeps/mach/hurd/setsid.c59
-rw-r--r--sysdeps/mach/hurd/setsockopt.c40
-rw-r--r--sysdeps/mach/hurd/settimeofday.c56
-rw-r--r--sysdeps/mach/hurd/setuid.c76
-rw-r--r--sysdeps/mach/hurd/shutdown.c40
-rw-r--r--sysdeps/mach/hurd/sigaction.c84
-rw-r--r--sysdeps/mach/hurd/sigaltstack.c62
-rw-r--r--sysdeps/mach/hurd/sigpending.c46
-rw-r--r--sysdeps/mach/hurd/sigprocmask.c87
-rw-r--r--sysdeps/mach/hurd/sigstack.c46
-rw-r--r--sysdeps/mach/hurd/sigsuspend.c81
-rw-r--r--sysdeps/mach/hurd/socket.c57
-rw-r--r--sysdeps/mach/hurd/socketpair.c93
-rw-r--r--sysdeps/mach/hurd/start.c316
-rw-r--r--sysdeps/mach/hurd/stat.c40
-rw-r--r--sysdeps/mach/hurd/statbuf.h119
-rw-r--r--sysdeps/mach/hurd/stdio_init.c63
-rw-r--r--sysdeps/mach/hurd/symlink.c68
-rw-r--r--sysdeps/mach/hurd/sync.c33
-rw-r--r--sysdeps/mach/hurd/sys/param.h135
-rw-r--r--sysdeps/mach/hurd/sysd-stdio.c237
-rw-r--r--sysdeps/mach/hurd/telldir.c31
-rw-r--r--sysdeps/mach/hurd/truncate.c42
-rw-r--r--sysdeps/mach/hurd/ttyname.c38
-rw-r--r--sysdeps/mach/hurd/umask.c34
-rw-r--r--sysdeps/mach/hurd/uname.c31
-rw-r--r--sysdeps/mach/hurd/unlink.c46
-rw-r--r--sysdeps/mach/hurd/utimes.c43
-rw-r--r--sysdeps/mach/hurd/wait4.c40
-rw-r--r--sysdeps/mach/hurd/write.c35
-rw-r--r--sysdeps/mach/i386/machine-lock.h66
-rw-r--r--sysdeps/mach/i386/machine-sp.h38
-rw-r--r--sysdeps/mach/i386/syscall.S26
-rw-r--r--sysdeps/mach/i386/sysdep.h47
-rw-r--r--sysdeps/mach/i386/thread_state.h38
-rw-r--r--sysdeps/mach/mips/Dist1
-rw-r--r--sysdeps/mach/mips/Makefile3
-rw-r--r--sysdeps/mach/mips/cacheflush.c44
-rw-r--r--sysdeps/mach/mips/machine-lock.h73
-rw-r--r--sysdeps/mach/mips/machine-sp.h38
-rw-r--r--sysdeps/mach/mips/syscall.S37
-rw-r--r--sysdeps/mach/mips/sysdep.h69
-rw-r--r--sysdeps/mach/mips/thread_state.h37
-rw-r--r--sysdeps/mach/mprotect.c50
-rw-r--r--sysdeps/mach/munmap.c39
-rw-r--r--sysdeps/mach/sleep.c45
-rw-r--r--sysdeps/mach/start.c89
-rw-r--r--sysdeps/mach/sys/reboot.h153
-rw-r--r--sysdeps/mach/syscall.h1
-rw-r--r--sysdeps/mach/sysdep.h82
-rw-r--r--sysdeps/mach/thread_state.h87
-rw-r--r--sysdeps/mach/usleep.c43
-rw-r--r--sysdeps/mips/.cvsignore4
-rw-r--r--sysdeps/mips/Dist1
-rw-r--r--sysdeps/mips/Implies2
-rw-r--r--sysdeps/mips/Makefile3
-rw-r--r--sysdeps/mips/__longjmp.c81
-rw-r--r--sysdeps/mips/bsd-_setjmp.S28
-rw-r--r--sysdeps/mips/bsd-setjmp.S28
-rw-r--r--sysdeps/mips/dec/bytesex.h4
-rw-r--r--sysdeps/mips/jmp_buf.h47
-rw-r--r--sysdeps/mips/mips64/gmp-mparam.h26
-rw-r--r--sysdeps/mips/mipsel/bytesex.h4
-rw-r--r--sysdeps/mips/p40/bytesex.h4
-rw-r--r--sysdeps/mips/setjmp.S31
-rw-r--r--sysdeps/mips/setjmp_aux.c64
-rw-r--r--sysdeps/posix/Dist1
-rw-r--r--sysdeps/posix/Makefile40
-rw-r--r--sysdeps/posix/clock.c33
-rw-r--r--sysdeps/posix/ctermid.c39
-rw-r--r--sysdeps/posix/cuserid.c46
-rw-r--r--sysdeps/posix/defs.c76
-rw-r--r--sysdeps/posix/dup.c32
-rw-r--r--sysdeps/posix/dup2.c59
-rw-r--r--sysdeps/posix/fdopen.c72
-rw-r--r--sysdeps/posix/flock.c58
-rw-r--r--sysdeps/posix/fpathconf.c116
-rw-r--r--sysdeps/posix/getcwd.c366
-rw-r--r--sysdeps/posix/getdtsz.c32
-rw-r--r--sysdeps/posix/getpagesize.c31
-rw-r--r--sysdeps/posix/gettimeofday.c75
-rw-r--r--sysdeps/posix/isatty.c39
-rw-r--r--sysdeps/posix/killpg.c37
-rw-r--r--sysdeps/posix/libc_fatal.c56
-rw-r--r--sysdeps/posix/mk-stdiolim.c71
-rw-r--r--sysdeps/posix/mkstemp.c64
-rw-r--r--sysdeps/posix/mktemp.c64
-rw-r--r--sysdeps/posix/pipestream.c223
-rw-r--r--sysdeps/posix/raise.c28
-rw-r--r--sysdeps/posix/readv.c68
-rw-r--r--sysdeps/posix/remove.c40
-rw-r--r--sysdeps/posix/rename.c50
-rw-r--r--sysdeps/posix/sigblock.c55
-rw-r--r--sysdeps/posix/sigintr.c57
-rw-r--r--sysdeps/posix/signal.c47
-rw-r--r--sysdeps/posix/sigpause.c45
-rw-r--r--sysdeps/posix/sigsetmask.c55
-rw-r--r--sysdeps/posix/sigsuspend.c51
-rw-r--r--sysdeps/posix/sigvec.c162
-rw-r--r--sysdeps/posix/sleep.c106
-rw-r--r--sysdeps/posix/stdio_init.c70
-rw-r--r--sysdeps/posix/sysconf.c183
-rw-r--r--sysdeps/posix/system.c145
-rw-r--r--sysdeps/posix/tempname.c208
-rw-r--r--sysdeps/posix/truncate.c41
-rw-r--r--sysdeps/posix/ttyname.c82
-rw-r--r--sysdeps/posix/wait.c31
-rw-r--r--sysdeps/posix/wait3.c42
-rw-r--r--sysdeps/posix/writev.c64
-rw-r--r--sysdeps/rs6000/ffs.c39
-rw-r--r--sysdeps/rs6000/memcopy.h86
-rw-r--r--sysdeps/sparc/DEFS.h4
-rw-r--r--sysdeps/sparc/Dist4
-rw-r--r--sysdeps/sparc/Implies2
-rw-r--r--sysdeps/sparc/Makefile57
-rw-r--r--sysdeps/sparc/__longjmp.S47
-rw-r--r--sysdeps/sparc/add_n.S134
-rw-r--r--sysdeps/sparc/addmul_1.S146
-rw-r--r--sysdeps/sparc/alloca.S32
-rw-r--r--sysdeps/sparc/bsd-_setjmp.S26
-rw-r--r--sysdeps/sparc/bsd-setjmp.S26
-rw-r--r--sysdeps/sparc/bytesex.h3
-rw-r--r--sysdeps/sparc/divrem.m4234
-rw-r--r--sysdeps/sparc/jmp_buf.h14
-rw-r--r--sysdeps/sparc/memcopy.h21
-rw-r--r--sysdeps/sparc/mul_1.S198
-rw-r--r--sysdeps/sparc/rem.S365
-rw-r--r--sysdeps/sparc/sdiv.S365
-rw-r--r--sysdeps/sparc/setjmp.S31
-rw-r--r--sysdeps/sparc/sparc8/addmul_1.S116
-rw-r--r--sysdeps/sparc/sparc8/mul_1.S91
-rw-r--r--sysdeps/sparc/sparc8/submul_1.S57
-rw-r--r--sysdeps/sparc/sparc8/udiv_qrnnd.S186
-rw-r--r--sysdeps/sparc/sqrt.c34
-rw-r--r--sysdeps/sparc/sub_n.S134
-rw-r--r--sysdeps/sparc/submul_1.S146
-rw-r--r--sysdeps/sparc/udiv.S348
-rw-r--r--sysdeps/sparc/udiv_qrnnd.S143
-rw-r--r--sysdeps/sparc/umul.S153
-rw-r--r--sysdeps/sparc/urem.S348
-rw-r--r--sysdeps/standalone/Dist2
-rw-r--r--sysdeps/standalone/Subdirs4
-rw-r--r--sysdeps/standalone/brk.c65
-rw-r--r--sysdeps/standalone/close.c44
-rw-r--r--sysdeps/standalone/dirstream.h43
-rw-r--r--sysdeps/standalone/filedesc.h48
-rw-r--r--sysdeps/standalone/i386/Dist1
-rw-r--r--sysdeps/standalone/i386/force_cpu386/Dist1
-rw-r--r--sysdeps/standalone/i386/force_cpu386/Makefile24
-rw-r--r--sysdeps/standalone/i386/force_cpu386/_exit.c47
-rw-r--r--sysdeps/standalone/i386/force_cpu386/brdinit.c44
-rw-r--r--sysdeps/standalone/i386/force_cpu386/console.c163
-rw-r--r--sysdeps/standalone/i386/force_cpu386/strtsupp.S89
-rw-r--r--sysdeps/standalone/i386/force_cpu386/target.ld59
-rw-r--r--sysdeps/standalone/i386/i386.h327
-rw-r--r--sysdeps/standalone/i386/start.S323
-rw-r--r--sysdeps/standalone/i960/Dist1
-rw-r--r--sysdeps/standalone/i960/i960ca.h207
-rw-r--r--sysdeps/standalone/i960/nindy960/Makefile23
-rw-r--r--sysdeps/standalone/i960/nindy960/_exit.c55
-rw-r--r--sysdeps/standalone/i960/nindy960/brdinit.c66
-rw-r--r--sysdeps/standalone/i960/nindy960/console.c76
-rw-r--r--sysdeps/standalone/i960/start.S137
-rw-r--r--sysdeps/standalone/m68k/m68020/Dist1
-rw-r--r--sysdeps/standalone/m68k/m68020/m68020.h88
-rw-r--r--sysdeps/standalone/m68k/m68020/mvme135/Implies2
-rw-r--r--sysdeps/standalone/m68k/m68020/mvme136/Dist1
-rw-r--r--sysdeps/standalone/m68k/m68020/mvme136/Makefile22
-rw-r--r--sysdeps/standalone/m68k/m68020/mvme136/_exit.c49
-rw-r--r--sysdeps/standalone/m68k/m68020/mvme136/brdinit.c53
-rw-r--r--sysdeps/standalone/m68k/m68020/mvme136/console.c101
-rw-r--r--sysdeps/standalone/m68k/m68020/mvme136/mvme136.ld62
-rw-r--r--sysdeps/standalone/m68k/m68020/start.S155
-rw-r--r--sysdeps/standalone/open.c122
-rw-r--r--sysdeps/standalone/read.c87
-rw-r--r--sysdeps/standalone/standalone.h32
-rw-r--r--sysdeps/standalone/stdio_lim.h27
-rw-r--r--sysdeps/standalone/write.c74
-rw-r--r--sysdeps/stub/__longjmp.c44
-rw-r--r--sysdeps/stub/__math.h6
-rw-r--r--sysdeps/stub/_exit.c40
-rw-r--r--sysdeps/stub/accept.c43
-rw-r--r--sysdeps/stub/access.c39
-rw-r--r--sysdeps/stub/acct.c33
-rw-r--r--sysdeps/stub/acos.c38
-rw-r--r--sysdeps/stub/adjtime.c37
-rw-r--r--sysdeps/stub/alarm.c44
-rw-r--r--sysdeps/stub/asin.c38
-rw-r--r--sysdeps/stub/asm-syntax.h3
-rw-r--r--sysdeps/stub/atan2.c37
-rw-r--r--sysdeps/stub/bind.c39
-rw-r--r--sysdeps/stub/brdinit.c34
-rw-r--r--sysdeps/stub/brk.c32
-rw-r--r--sysdeps/stub/bsd-_setjmp.c33
-rw-r--r--sysdeps/stub/bsd-setjmp.c33
-rw-r--r--sysdeps/stub/bytesex.h9
-rw-r--r--sysdeps/stub/cbrt.c38
-rw-r--r--sysdeps/stub/chdir.c39
-rw-r--r--sysdeps/stub/chflags.c38
-rw-r--r--sysdeps/stub/chmod.c40
-rw-r--r--sysdeps/stub/chown.c41
-rw-r--r--sysdeps/stub/chroot.c39
-rw-r--r--sysdeps/stub/clock.c30
-rw-r--r--sysdeps/stub/close.c38
-rw-r--r--sysdeps/stub/closedir.c41
-rw-r--r--sysdeps/stub/confstr.h4
-rw-r--r--sysdeps/stub/connect.c42
-rw-r--r--sysdeps/stub/console.c42
-rw-r--r--sysdeps/stub/cos.c38
-rw-r--r--sysdeps/stub/cosh.c38
-rw-r--r--sysdeps/stub/ctermid.c41
-rw-r--r--sysdeps/stub/cuserid.c40
-rw-r--r--sysdeps/stub/dbl2mpn.c32
-rw-r--r--sysdeps/stub/defs.c51
-rw-r--r--sysdeps/stub/direct.h5
-rw-r--r--sysdeps/stub/dirstream.h30
-rw-r--r--sysdeps/stub/drem.c33
-rw-r--r--sysdeps/stub/dup.c33
-rw-r--r--sysdeps/stub/dup2.c45
-rw-r--r--sysdeps/stub/errlist.c42
-rw-r--r--sysdeps/stub/errnos.h38
-rw-r--r--sysdeps/stub/exc2signal.c68
-rw-r--r--sysdeps/stub/execve.c43
-rw-r--r--sysdeps/stub/exp.c38
-rw-r--r--sysdeps/stub/fchdir.c32
-rw-r--r--sysdeps/stub/fchflags.c38
-rw-r--r--sysdeps/stub/fchmod.c40
-rw-r--r--sysdeps/stub/fchown.c41
-rw-r--r--sysdeps/stub/fcntl.c38
-rw-r--r--sysdeps/stub/fcntlbits.h88
-rw-r--r--sysdeps/stub/fdopen.c29
-rw-r--r--sysdeps/stub/fexecve.c42
-rw-r--r--sysdeps/stub/flock.c33
-rw-r--r--sysdeps/stub/fmod.c38
-rw-r--r--sysdeps/stub/fork.c35
-rw-r--r--sysdeps/stub/fpathconf.c57
-rw-r--r--sysdeps/stub/frexp.c39
-rw-r--r--sysdeps/stub/fstat.c44
-rw-r--r--sysdeps/stub/fsync.c38
-rw-r--r--sysdeps/stub/ftruncate.c30
-rw-r--r--sysdeps/stub/getcwd.c45
-rw-r--r--sysdeps/stub/getdents.c33
-rw-r--r--sysdeps/stub/getdomain.c34
-rw-r--r--sysdeps/stub/getdtsz.c33
-rw-r--r--sysdeps/stub/getegid.c32
-rw-r--r--sysdeps/stub/getenv.c38
-rw-r--r--sysdeps/stub/geteuid.c33
-rw-r--r--sysdeps/stub/getgid.c33
-rw-r--r--sysdeps/stub/getgroups.c46
-rw-r--r--sysdeps/stub/gethostid.c38
-rw-r--r--sysdeps/stub/gethostname.c35
-rw-r--r--sysdeps/stub/getitimer.c41
-rw-r--r--sysdeps/stub/getlogin.c40
-rw-r--r--sysdeps/stub/getpagesize.c32
-rw-r--r--sysdeps/stub/getpeername.c40
-rw-r--r--sysdeps/stub/getpgid.c32
-rw-r--r--sysdeps/stub/getpid.c33
-rw-r--r--sysdeps/stub/getppid.c33
-rw-r--r--sysdeps/stub/getpriority.c42
-rw-r--r--sysdeps/stub/getrlimit.c40
-rw-r--r--sysdeps/stub/getrusage.c34
-rw-r--r--sysdeps/stub/getsockname.c39
-rw-r--r--sysdeps/stub/getsockopt.c42
-rw-r--r--sysdeps/stub/gettimeofday.c35
-rw-r--r--sysdeps/stub/getuid.c33
-rw-r--r--sysdeps/stub/gtty.c37
-rw-r--r--sysdeps/stub/huge_val.h27
-rw-r--r--sysdeps/stub/init-fault.c38
-rw-r--r--sysdeps/stub/init-posix.c38
-rw-r--r--sysdeps/stub/ioctl.c34
-rw-r--r--sysdeps/stub/ioctls.h1
-rw-r--r--sysdeps/stub/isatty.c31
-rw-r--r--sysdeps/stub/isinf.c31
-rw-r--r--sysdeps/stub/isinfl.c33
-rw-r--r--sysdeps/stub/isnanl.c33
-rw-r--r--sysdeps/stub/jmp_buf.h3
-rw-r--r--sysdeps/stub/kill.c35
-rw-r--r--sysdeps/stub/killpg.c32
-rw-r--r--sysdeps/stub/ldbl2mpn.c32
-rw-r--r--sysdeps/stub/libc_fatal.c31
-rw-r--r--sysdeps/stub/link.c40
-rw-r--r--sysdeps/stub/listen.c41
-rw-r--r--sysdeps/stub/local_lim.h3
-rw-r--r--sysdeps/stub/log.c38
-rw-r--r--sysdeps/stub/log10.c38
-rw-r--r--sysdeps/stub/logb.c31
-rw-r--r--sysdeps/stub/longjmp-ctx.c32
-rw-r--r--sysdeps/stub/longjmp-ts.c32
-rw-r--r--sysdeps/stub/lseek.c49
-rw-r--r--sysdeps/stub/lstat.c40
-rw-r--r--sysdeps/stub/machine-lock.h64
-rw-r--r--sysdeps/stub/machine-sp.h37
-rw-r--r--sysdeps/stub/madvise.c31
-rw-r--r--sysdeps/stub/mkdir.c41
-rw-r--r--sysdeps/stub/mkfifo.c47
-rw-r--r--sysdeps/stub/mknod.c36
-rw-r--r--sysdeps/stub/mkstemp.c38
-rw-r--r--sysdeps/stub/mktemp.c37
-rw-r--r--sysdeps/stub/mmap.c38
-rw-r--r--sysdeps/stub/morecore.c43
-rw-r--r--sysdeps/stub/mpn2dbl.c31
-rw-r--r--sysdeps/stub/mpn2flt.c31
-rw-r--r--sysdeps/stub/mpn2ldbl.c31
-rw-r--r--sysdeps/stub/mprotect.c33
-rw-r--r--sysdeps/stub/msync.c32
-rw-r--r--sysdeps/stub/munmap.c32
-rw-r--r--sysdeps/stub/nan.h6
-rw-r--r--sysdeps/stub/nice.c39
-rw-r--r--sysdeps/stub/nlist.c48
-rw-r--r--sysdeps/stub/open.c51
-rw-r--r--sysdeps/stub/opendir.c40
-rw-r--r--sysdeps/stub/pathconf.c37
-rw-r--r--sysdeps/stub/pause.c42
-rw-r--r--sysdeps/stub/pipe.c42
-rw-r--r--sysdeps/stub/pipestream.c64
-rw-r--r--sysdeps/stub/poll.c36
-rw-r--r--sysdeps/stub/posix_opt.h2
-rw-r--r--sysdeps/stub/ptrace.c108
-rw-r--r--sysdeps/stub/putenv.c39
-rw-r--r--sysdeps/stub/raise.c29
-rw-r--r--sysdeps/stub/read.c47
-rw-r--r--sysdeps/stub/readdir.c39
-rw-r--r--sysdeps/stub/readlink.c35
-rw-r--r--sysdeps/stub/readv.c35
-rw-r--r--sysdeps/stub/reboot.c38
-rw-r--r--sysdeps/stub/recv.c40
-rw-r--r--sysdeps/stub/recvfrom.c42
-rw-r--r--sysdeps/stub/recvmsg.c33
-rw-r--r--sysdeps/stub/remove.c31
-rw-r--r--sysdeps/stub/rename.c45
-rw-r--r--sysdeps/stub/rewinddir.c40
-rw-r--r--sysdeps/stub/rmdir.c40
-rw-r--r--sysdeps/stub/sbrk.c33
-rw-r--r--sysdeps/stub/seekdir.c45
-rw-r--r--sysdeps/stub/select.c39
-rw-r--r--sysdeps/stub/send.c39
-rw-r--r--sysdeps/stub/sendmsg.c33
-rw-r--r--sysdeps/stub/sendto.c41
-rw-r--r--sysdeps/stub/setdomain.c33
-rw-r--r--sysdeps/stub/setegid.c38
-rw-r--r--sysdeps/stub/setenv.c29
-rw-r--r--sysdeps/stub/seteuid.c38
-rw-r--r--sysdeps/stub/setgid.c36
-rw-r--r--sysdeps/stub/setgroups.c39
-rw-r--r--sysdeps/stub/sethostid.c39
-rw-r--r--sysdeps/stub/sethostname.c40
-rw-r--r--sysdeps/stub/setitimer.c43
-rw-r--r--sysdeps/stub/setjmp.c42
-rw-r--r--sysdeps/stub/setlogin.c29
-rw-r--r--sysdeps/stub/setpgid.c35
-rw-r--r--sysdeps/stub/setpriority.c40
-rw-r--r--sysdeps/stub/setregid.c35
-rw-r--r--sysdeps/stub/setreuid.c35
-rw-r--r--sysdeps/stub/setrlimit.c41
-rw-r--r--sysdeps/stub/setsid.c35
-rw-r--r--sysdeps/stub/setsockopt.c42
-rw-r--r--sysdeps/stub/settimeofday.c34
-rw-r--r--sysdeps/stub/setuid.c36
-rw-r--r--sysdeps/stub/shutdown.c44
-rw-r--r--sysdeps/stub/sigaction.c41
-rw-r--r--sysdeps/stub/sigaltstack.c31
-rw-r--r--sysdeps/stub/sigblock.c32
-rw-r--r--sysdeps/stub/sigcontext.h29
-rw-r--r--sysdeps/stub/sigintr.c32
-rw-r--r--sysdeps/stub/siglist.c43
-rw-r--r--sysdeps/stub/signal.c40
-rw-r--r--sysdeps/stub/signum.h53
-rw-r--r--sysdeps/stub/sigpause.c31
-rw-r--r--sysdeps/stub/sigpending.c39
-rw-r--r--sysdeps/stub/sigprocmask.c50
-rw-r--r--sysdeps/stub/sigreturn.c31
-rw-r--r--sysdeps/stub/sigsetmask.c31
-rw-r--r--sysdeps/stub/sigstack.c31
-rw-r--r--sysdeps/stub/sigsuspend.c40
-rw-r--r--sysdeps/stub/sigvec.c37
-rw-r--r--sysdeps/stub/sin.c38
-rw-r--r--sysdeps/stub/sinh.c38
-rw-r--r--sysdeps/stub/sleep.c37
-rw-r--r--sysdeps/stub/socket.c41
-rw-r--r--sysdeps/stub/socketpair.c42
-rw-r--r--sysdeps/stub/sqrt.c38
-rw-r--r--sysdeps/stub/sstk.c29
-rw-r--r--sysdeps/stub/start.c16
-rw-r--r--sysdeps/stub/stat.c39
-rw-r--r--sysdeps/stub/statbuf.h71
-rw-r--r--sysdeps/stub/stdio_init.c30
-rw-r--r--sysdeps/stub/stdio_lim.h6
-rw-r--r--sysdeps/stub/stime.c37
-rw-r--r--sysdeps/stub/strtsupp.c31
-rw-r--r--sysdeps/stub/stty.c37
-rw-r--r--sysdeps/stub/swapon.c32
-rw-r--r--sysdeps/stub/symlink.c40
-rw-r--r--sysdeps/stub/sync.c38
-rw-r--r--sysdeps/stub/sys/param.h8
-rw-r--r--sysdeps/stub/sys/reboot.h9
-rw-r--r--sysdeps/stub/syscall.c31
-rw-r--r--sysdeps/stub/syscall.h2
-rw-r--r--sysdeps/stub/sysconf.c69
-rw-r--r--sysdeps/stub/sysd-stdio.c111
-rw-r--r--sysdeps/stub/sysdep.c2
-rw-r--r--sysdeps/stub/sysdep.h3
-rw-r--r--sysdeps/stub/system.c42
-rw-r--r--sysdeps/stub/tan.c38
-rw-r--r--sysdeps/stub/tanh.c38
-rw-r--r--sysdeps/stub/tcdrain.c44
-rw-r--r--sysdeps/stub/tcflow.c57
-rw-r--r--sysdeps/stub/tcflush.c50
-rw-r--r--sysdeps/stub/tcgetattr.c45
-rw-r--r--sysdeps/stub/tcgetpgrp.c45
-rw-r--r--sysdeps/stub/tcsendbrk.c44
-rw-r--r--sysdeps/stub/tcsetattr.c100
-rw-r--r--sysdeps/stub/tcsetpgrp.c46
-rw-r--r--sysdeps/stub/telldir.c46
-rw-r--r--sysdeps/stub/tempname.c47
-rw-r--r--sysdeps/stub/thread_state.h47
-rw-r--r--sysdeps/stub/time.c43
-rw-r--r--sysdeps/stub/times.c42
-rw-r--r--sysdeps/stub/trampoline.c37
-rw-r--r--sysdeps/stub/truncate.c30
-rw-r--r--sysdeps/stub/ttyname.c43
-rw-r--r--sysdeps/stub/ualarm.c33
-rw-r--r--sysdeps/stub/udiv_qrnnd.c10
-rw-r--r--sysdeps/stub/ulimit.c45
-rw-r--r--sysdeps/stub/umask.c33
-rw-r--r--sysdeps/stub/unlink.c40
-rw-r--r--sysdeps/stub/usleep.c28
-rw-r--r--sysdeps/stub/utime.c47
-rw-r--r--sysdeps/stub/utimes.c40
-rw-r--r--sysdeps/stub/vhangup.c33
-rw-r--r--sysdeps/stub/wait.c33
-rw-r--r--sysdeps/stub/wait3.c44
-rw-r--r--sysdeps/stub/wait4.c34
-rw-r--r--sysdeps/stub/waitflags.h28
-rw-r--r--sysdeps/stub/waitpid.c52
-rw-r--r--sysdeps/stub/write.c48
-rw-r--r--sysdeps/stub/writev.c35
-rw-r--r--sysdeps/tahoe/Implies2
-rw-r--r--sysdeps/tahoe/log10.c22
-rw-r--r--sysdeps/unix/Dist4
-rw-r--r--sysdeps/unix/Implies1
-rw-r--r--sysdeps/unix/Makefile267
-rw-r--r--sysdeps/unix/_exit.S22
-rw-r--r--sysdeps/unix/acct.S22
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/=dirstream.h44
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/Implies2
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/Makefile3
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/brk.S53
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/fork.S25
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/getdents.S25
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/killpg.S25
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/pipe.S30
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/recv.S25
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/send.S25
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/sigblock.S27
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/sigpause.S27
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/sigsetmask.S27
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/sigvec.S27
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/start.S72
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/statbuf.h75
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/sysdep.S40
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/sysdep.h73
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/vhangup.S25
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/wait4.S1
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/alpha/waitpid.c1
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/msync.S1
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/sigaction.h45
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/sys/mman.h114
-rw-r--r--sysdeps/unix/bsd/Attic/osf1/system.c2
-rw-r--r--sysdeps/unix/bsd/Dist1
-rw-r--r--sysdeps/unix/bsd/Implies5
-rw-r--r--sysdeps/unix/bsd/alarm.c43
-rw-r--r--sysdeps/unix/bsd/bsd4.4/Implies2
-rw-r--r--sysdeps/unix/bsd/bsd4.4/chflags.S22
-rw-r--r--sysdeps/unix/bsd/bsd4.4/direct.h16
-rw-r--r--sysdeps/unix/bsd/bsd4.4/errnos.h168
-rw-r--r--sysdeps/unix/bsd/bsd4.4/fchdir.S22
-rw-r--r--sysdeps/unix/bsd/bsd4.4/fchflags.S22
-rw-r--r--sysdeps/unix/bsd/bsd4.4/fcntlbits.h116
-rw-r--r--sysdeps/unix/bsd/bsd4.4/getdents.S1
-rw-r--r--sysdeps/unix/bsd/bsd4.4/getdomain.S22
-rw-r--r--sysdeps/unix/bsd/bsd4.4/ioctls.h292
-rw-r--r--sysdeps/unix/bsd/bsd4.4/setdomain.S22
-rw-r--r--sysdeps/unix/bsd/bsd4.4/setegid.S22
-rw-r--r--sysdeps/unix/bsd/bsd4.4/seteuid.S22
-rw-r--r--sysdeps/unix/bsd/bsd4.4/setlogin.S22
-rw-r--r--sysdeps/unix/bsd/bsd4.4/setsid.S24
-rw-r--r--sysdeps/unix/bsd/bsd4.4/sigaltstack.S22
-rw-r--r--sysdeps/unix/bsd/bsd4.4/sigblock.c1
-rw-r--r--sysdeps/unix/bsd/bsd4.4/sigsetmask.c1
-rw-r--r--sysdeps/unix/bsd/bsd4.4/sigvec.c1
-rw-r--r--sysdeps/unix/bsd/bsd4.4/sockaddrcom.h35
-rw-r--r--sysdeps/unix/bsd/bsd4.4/sstk.S23
-rw-r--r--sysdeps/unix/bsd/bsd4.4/system.c2
-rw-r--r--sysdeps/unix/bsd/bsd4.4/tcdrain.c28
-rw-r--r--sysdeps/unix/bsd/bsd4.4/tcgetattr.c41
-rw-r--r--sysdeps/unix/bsd/bsd4.4/tcsetattr.c61
-rw-r--r--sysdeps/unix/bsd/bsd4.4/wait.c33
-rw-r--r--sysdeps/unix/bsd/bsd4.4/wait3.c36
-rw-r--r--sysdeps/unix/bsd/bsd4.4/wait4.S24
-rw-r--r--sysdeps/unix/bsd/bsd4.4/waitpid.c44
-rw-r--r--sysdeps/unix/bsd/bsdstat.h112
-rw-r--r--sysdeps/unix/bsd/bsdtty.h218
-rw-r--r--sysdeps/unix/bsd/clock.c45
-rw-r--r--sysdeps/unix/bsd/confstr.h1
-rw-r--r--sysdeps/unix/bsd/direct.h13
-rw-r--r--sysdeps/unix/bsd/dirstream.h48
-rw-r--r--sysdeps/unix/bsd/fcntlbits.h117
-rw-r--r--sysdeps/unix/bsd/flock.S24
-rw-r--r--sysdeps/unix/bsd/ftime.c37
-rw-r--r--sysdeps/unix/bsd/getdtsz.S24
-rw-r--r--sysdeps/unix/bsd/getpagesize.S24
-rw-r--r--sysdeps/unix/bsd/gtty.c29
-rw-r--r--sysdeps/unix/bsd/hp/m68k/brk.S46
-rw-r--r--sysdeps/unix/bsd/hp/m68k/getdents.S1
-rw-r--r--sysdeps/unix/bsd/hp/m68k/start.c10
-rw-r--r--sysdeps/unix/bsd/hp/m68k/sysdep.h56
-rw-r--r--sysdeps/unix/bsd/hp/m68k/wait3.S39
-rw-r--r--sysdeps/unix/bsd/i386/wait3.S44
-rw-r--r--sysdeps/unix/bsd/init-posix.c36
-rw-r--r--sysdeps/unix/bsd/isatty.c39
-rw-r--r--sysdeps/unix/bsd/killpg.S22
-rw-r--r--sysdeps/unix/bsd/m68k/pipe.S32
-rw-r--r--sysdeps/unix/bsd/m68k/start.c3
-rw-r--r--sysdeps/unix/bsd/m68k/syscall.S26
-rw-r--r--sysdeps/unix/bsd/m68k/sysdep.S44
-rw-r--r--sysdeps/unix/bsd/m68k/wait.S35
-rw-r--r--sysdeps/unix/bsd/nice.c45
-rw-r--r--sysdeps/unix/bsd/pause.c31
-rw-r--r--sysdeps/unix/bsd/poll.c81
-rw-r--r--sysdeps/unix/bsd/posix_opt.h5
-rw-r--r--sysdeps/unix/bsd/readdir.c70
-rw-r--r--sysdeps/unix/bsd/seekdir.c1
-rw-r--r--sysdeps/unix/bsd/sequent/i386/getgroups.S44
-rw-r--r--sysdeps/unix/bsd/sequent/i386/sigvec.S45
-rw-r--r--sysdeps/unix/bsd/sequent/i386/syscall.S31
-rw-r--r--sysdeps/unix/bsd/sequent/i386/sysdep.h82
-rw-r--r--sysdeps/unix/bsd/setegid.c27
-rw-r--r--sysdeps/unix/bsd/seteuid.c27
-rw-r--r--sysdeps/unix/bsd/setgid.c35
-rw-r--r--sysdeps/unix/bsd/setrgid.c27
-rw-r--r--sysdeps/unix/bsd/setruid.c27
-rw-r--r--sysdeps/unix/bsd/setsid.c59
-rw-r--r--sysdeps/unix/bsd/settimeofday.S24
-rw-r--r--sysdeps/unix/bsd/setuid.c35
-rw-r--r--sysdeps/unix/bsd/sigaction.c62
-rw-r--r--sysdeps/unix/bsd/sigblock.S24
-rw-r--r--sysdeps/unix/bsd/signum.h70
-rw-r--r--sysdeps/unix/bsd/sigpause.S24
-rw-r--r--sysdeps/unix/bsd/sigprocmask.c65
-rw-r--r--sysdeps/unix/bsd/sigsetmask.S24
-rw-r--r--sysdeps/unix/bsd/sigstack.S22
-rw-r--r--sysdeps/unix/bsd/sigsuspend.c46
-rw-r--r--sysdeps/unix/bsd/sigvec.S24
-rw-r--r--sysdeps/unix/bsd/sony/newsos/m68k/Implies2
-rw-r--r--sysdeps/unix/bsd/sony/newsos/m68k/sysdep.h56
-rw-r--r--sysdeps/unix/bsd/sony/newsos4/Dist1
-rw-r--r--sysdeps/unix/bsd/sony/newsos4/Makefile3
-rw-r--r--sysdeps/unix/bsd/sony/newsos4/fchdir.S1
-rw-r--r--sysdeps/unix/bsd/sony/newsos4/sys_wait4.S1
-rw-r--r--sysdeps/unix/bsd/sony/newsos4/wait.c1
-rw-r--r--sysdeps/unix/bsd/sony/newsos4/wait3.c1
-rw-r--r--sysdeps/unix/bsd/sony/newsos4/wait4.c1
-rw-r--r--sysdeps/unix/bsd/statbuf.h84
-rw-r--r--sysdeps/unix/bsd/stime.c39
-rw-r--r--sysdeps/unix/bsd/stty.c29
-rw-r--r--sysdeps/unix/bsd/sun/getdents.S24
-rw-r--r--sysdeps/unix/bsd/sun/m68k/Dist1
-rw-r--r--sysdeps/unix/bsd/sun/m68k/Makefile3
-rw-r--r--sysdeps/unix/bsd/sun/m68k/brk.S49
-rw-r--r--sysdeps/unix/bsd/sun/m68k/sethostid.S44
-rw-r--r--sysdeps/unix/bsd/sun/m68k/sigcontext.h26
-rw-r--r--sysdeps/unix/bsd/sun/m68k/sigtramp.c142
-rw-r--r--sysdeps/unix/bsd/sun/m68k/syscall.S28
-rw-r--r--sysdeps/unix/bsd/sun/m68k/sysdep.h62
-rw-r--r--sysdeps/unix/bsd/sun/sethostid.c1
-rw-r--r--sysdeps/unix/bsd/sun/signum.h69
-rw-r--r--sysdeps/unix/bsd/sun/sigreturn.S28
-rw-r--r--sysdeps/unix/bsd/sun/sigvec.S26
-rw-r--r--sysdeps/unix/bsd/sun/sparc/Dist1
-rw-r--r--sysdeps/unix/bsd/sun/sparc/Makefile7
-rw-r--r--sysdeps/unix/bsd/sun/sparc/sethostid.S46
-rw-r--r--sysdeps/unix/bsd/sun/sparc/sigcontext.h31
-rw-r--r--sysdeps/unix/bsd/sun/sparc/sigtramp.c246
-rw-r--r--sysdeps/unix/bsd/sun/sunos3/m68k/wait.S1
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/.cvsignore4
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/Dist2
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/Implies2
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/Makefile7
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/fcntlbits.h145
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/mmap.c41
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/msync.S22
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/poll.S1
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/resourcebits.h48
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/setsid.S1
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/speed.c113
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/sys/mman.h107
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/sys_mmap.S22
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/sys_wait4.S22
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/system.c2
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/tcflow.c29
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/tcflush.c29
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/tcgetattr.c33
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/tcsendbrk.c31
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/tcsetattr.c49
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/termbits.h208
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/uname.S1
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/utsnamelen.h2
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/wait.c1
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/wait3.c1
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/wait4.c50
-rw-r--r--sysdeps/unix/bsd/sun/sunos4/waitpid.c1
-rw-r--r--sysdeps/unix/bsd/sys/reboot.h88
-rw-r--r--sysdeps/unix/bsd/tahoe/Implies1
-rw-r--r--sysdeps/unix/bsd/tahoe/sysdep.h5
-rw-r--r--sysdeps/unix/bsd/tcdrain.c38
-rw-r--r--sysdeps/unix/bsd/tcflow.c57
-rw-r--r--sysdeps/unix/bsd/tcflush.c50
-rw-r--r--sysdeps/unix/bsd/tcgetattr.c130
-rw-r--r--sysdeps/unix/bsd/tcgetpgrp.c33
-rw-r--r--sysdeps/unix/bsd/tcsendbrk.c55
-rw-r--r--sysdeps/unix/bsd/tcsetattr.c186
-rw-r--r--sysdeps/unix/bsd/tcsetpgrp.c30
-rw-r--r--sysdeps/unix/bsd/telldir.c93
-rw-r--r--sysdeps/unix/bsd/time.c40
-rw-r--r--sysdeps/unix/bsd/times.c68
-rw-r--r--sysdeps/unix/bsd/ualarm.c42
-rw-r--r--sysdeps/unix/bsd/ulimit.c86
-rw-r--r--sysdeps/unix/bsd/ultrix4/Dist1
-rw-r--r--sysdeps/unix/bsd/ultrix4/Implies2
-rw-r--r--sysdeps/unix/bsd/ultrix4/Makefile3
-rw-r--r--sysdeps/unix/bsd/ultrix4/fcntlbits.h125
-rw-r--r--sysdeps/unix/bsd/ultrix4/getdents.S1
-rw-r--r--sysdeps/unix/bsd/ultrix4/getsysinfo.S25
-rw-r--r--sysdeps/unix/bsd/ultrix4/mips/Dist1
-rw-r--r--sysdeps/unix/bsd/ultrix4/mips/Makefile3
-rw-r--r--sysdeps/unix/bsd/ultrix4/mips/__handler.S113
-rw-r--r--sysdeps/unix/bsd/ultrix4/mips/sigcontext.h60
-rw-r--r--sysdeps/unix/bsd/ultrix4/mips/sigtramp.c55
-rw-r--r--sysdeps/unix/bsd/ultrix4/mips/sigvec.S24
-rw-r--r--sysdeps/unix/bsd/ultrix4/mips/start.S77
-rw-r--r--sysdeps/unix/bsd/ultrix4/mips/vfork.S33
-rw-r--r--sysdeps/unix/bsd/ultrix4/posix_opt.h23
-rw-r--r--sysdeps/unix/bsd/ultrix4/setsid.S1
-rw-r--r--sysdeps/unix/bsd/ultrix4/sys/mman.h99
-rw-r--r--sysdeps/unix/bsd/ultrix4/sysconf.c61
-rw-r--r--sysdeps/unix/bsd/ultrix4/system.c2
-rw-r--r--sysdeps/unix/bsd/ultrix4/uname.S1
-rw-r--r--sysdeps/unix/bsd/ultrix4/utsnamelen.h1
-rw-r--r--sysdeps/unix/bsd/ultrix4/wait3.S24
-rw-r--r--sysdeps/unix/bsd/ultrix4/waitpid.S24
-rw-r--r--sysdeps/unix/bsd/usleep.c37
-rw-r--r--sysdeps/unix/bsd/utime.c50
-rw-r--r--sysdeps/unix/bsd/utimes.S24
-rw-r--r--sysdeps/unix/bsd/vax/brk.S47
-rw-r--r--sysdeps/unix/bsd/vax/pipe.S28
-rw-r--r--sysdeps/unix/bsd/vax/sysdep.S35
-rw-r--r--sysdeps/unix/bsd/vax/sysdep.h55
-rw-r--r--sysdeps/unix/bsd/vax/wait.S27
-rw-r--r--sysdeps/unix/bsd/vax/wait3.S37
-rw-r--r--sysdeps/unix/bsd/waitflags.h28
-rw-r--r--sysdeps/unix/chdir.S24
-rw-r--r--sysdeps/unix/chmod.S24
-rw-r--r--sysdeps/unix/chown.S24
-rw-r--r--sysdeps/unix/chroot.S22
-rw-r--r--sysdeps/unix/close.S24
-rw-r--r--sysdeps/unix/closedir.c46
-rw-r--r--sysdeps/unix/common/.cvsignore4
-rw-r--r--sysdeps/unix/common/Dist1
-rw-r--r--sysdeps/unix/common/Makefile35
-rw-r--r--sysdeps/unix/common/access.S24
-rw-r--r--sysdeps/unix/common/adjtime.S24
-rwxr-xr-xsysdeps/unix/common/configure101
-rw-r--r--sysdeps/unix/common/configure.in22
-rw-r--r--sysdeps/unix/common/direct.h43
-rw-r--r--sysdeps/unix/common/dup2.S24
-rw-r--r--sysdeps/unix/common/fchmod.S24
-rw-r--r--sysdeps/unix/common/fchown.S24
-rw-r--r--sysdeps/unix/common/fcntlbits.h122
-rw-r--r--sysdeps/unix/common/ftruncate.S22
-rw-r--r--sysdeps/unix/common/getgroups.S24
-rw-r--r--sysdeps/unix/common/getitimer.S24
-rw-r--r--sysdeps/unix/common/getpgid.S24
-rw-r--r--sysdeps/unix/common/getpriority.S22
-rw-r--r--sysdeps/unix/common/getrlimit.S22
-rw-r--r--sysdeps/unix/common/getrusage.S24
-rw-r--r--sysdeps/unix/common/gettimeofday.S24
-rw-r--r--sysdeps/unix/common/glue-ctype.c91
-rw-r--r--sysdeps/unix/common/lstat.S24
-rw-r--r--sysdeps/unix/common/mk-local_lim.c78
-rw-r--r--sysdeps/unix/common/mkdir.S24
-rw-r--r--sysdeps/unix/common/readlink.S24
-rw-r--r--sysdeps/unix/common/readv.S22
-rw-r--r--sysdeps/unix/common/rename.S22
-rw-r--r--sysdeps/unix/common/rmdir.S24
-rw-r--r--sysdeps/unix/common/select.S24
-rw-r--r--sysdeps/unix/common/setgroups.S22
-rw-r--r--sysdeps/unix/common/setitimer.S24
-rw-r--r--sysdeps/unix/common/setpgid.S25
-rw-r--r--sysdeps/unix/common/setpriority.S22
-rw-r--r--sysdeps/unix/common/setregid.S24
-rw-r--r--sysdeps/unix/common/setreuid.S24
-rw-r--r--sysdeps/unix/common/setrlimit.S22
-rw-r--r--sysdeps/unix/common/swapon.S22
-rw-r--r--sysdeps/unix/common/symlink.S24
-rw-r--r--sysdeps/unix/common/truncate.S22
-rw-r--r--sysdeps/unix/common/vhangup.S22
-rw-r--r--sysdeps/unix/common/writev.S22
-rwxr-xr-xsysdeps/unix/configure127
-rw-r--r--sysdeps/unix/configure.in136
-rw-r--r--sysdeps/unix/confstr.h1
-rw-r--r--sysdeps/unix/dirstream.h43
-rw-r--r--sysdeps/unix/dup.S24
-rw-r--r--sysdeps/unix/errnos-tmpl.c98
-rw-r--r--sysdeps/unix/errnos.awk12
-rw-r--r--sysdeps/unix/execve.S32
-rw-r--r--sysdeps/unix/fcntl.S24
-rw-r--r--sysdeps/unix/fork.S32
-rw-r--r--sysdeps/unix/fstat.S24
-rw-r--r--sysdeps/unix/fsync.S22
-rw-r--r--sysdeps/unix/getdents.c36
-rw-r--r--sysdeps/unix/getegid.S29
-rw-r--r--sysdeps/unix/geteuid.S29
-rw-r--r--sysdeps/unix/getgid.S24
-rw-r--r--sysdeps/unix/getlogin.c90
-rw-r--r--sysdeps/unix/getpagesize.c40
-rw-r--r--sysdeps/unix/getpid.S24
-rw-r--r--sysdeps/unix/getppid.S29
-rw-r--r--sysdeps/unix/getuid.S24
-rw-r--r--sysdeps/unix/i386/brk.S41
-rw-r--r--sysdeps/unix/i386/fork.S30
-rw-r--r--sysdeps/unix/i386/pipe.S28
-rw-r--r--sysdeps/unix/i386/sigreturn.S27
-rw-r--r--sysdeps/unix/i386/start.c2
-rw-r--r--sysdeps/unix/i386/syscall.S28
-rw-r--r--sysdeps/unix/i386/sysdep.S42
-rw-r--r--sysdeps/unix/i386/sysdep.h55
-rw-r--r--sysdeps/unix/i386/wait.S28
-rw-r--r--sysdeps/unix/inet/Subdirs3
-rw-r--r--sysdeps/unix/inet/accept.S22
-rw-r--r--sysdeps/unix/inet/bind.S22
-rw-r--r--sysdeps/unix/inet/connect.S22
-rw-r--r--sysdeps/unix/inet/gethostid.S22
-rw-r--r--sysdeps/unix/inet/gethostname.S24
-rw-r--r--sysdeps/unix/inet/getpeername.S22
-rw-r--r--sysdeps/unix/inet/getsockname.S22
-rw-r--r--sysdeps/unix/inet/getsockopt.S22
-rw-r--r--sysdeps/unix/inet/listen.S22
-rw-r--r--sysdeps/unix/inet/recv.S22
-rw-r--r--sysdeps/unix/inet/recvfrom.S22
-rw-r--r--sysdeps/unix/inet/recvmsg.S22
-rw-r--r--sysdeps/unix/inet/send.S22
-rw-r--r--sysdeps/unix/inet/sendmsg.S22
-rw-r--r--sysdeps/unix/inet/sendto.S22
-rw-r--r--sysdeps/unix/inet/sethostid.S22
-rw-r--r--sysdeps/unix/inet/sethostname.S22
-rw-r--r--sysdeps/unix/inet/setsockopt.S22
-rw-r--r--sysdeps/unix/inet/shutdown.S22
-rw-r--r--sysdeps/unix/inet/socket.S22
-rw-r--r--sysdeps/unix/inet/socketpair.S22
-rw-r--r--sysdeps/unix/ioctl.S24
-rw-r--r--sysdeps/unix/ioctls-tmpl.c134
-rw-r--r--sysdeps/unix/ioctls.awk10
-rw-r--r--sysdeps/unix/kill.S24
-rw-r--r--sysdeps/unix/link.S24
-rw-r--r--sysdeps/unix/lseek.S24
-rw-r--r--sysdeps/unix/make_errlist.c51
-rw-r--r--sysdeps/unix/mips/brk.S67
-rw-r--r--sysdeps/unix/mips/fork.S29
-rw-r--r--sysdeps/unix/mips/pipe.S31
-rw-r--r--sysdeps/unix/mips/sigreturn.S29
-rw-r--r--sysdeps/unix/mips/sysdep.S41
-rw-r--r--sysdeps/unix/mips/sysdep.h52
-rw-r--r--sysdeps/unix/mips/wait.S44
-rw-r--r--sysdeps/unix/mk-local_lim.c118
-rw-r--r--sysdeps/unix/mkfifo.c29
-rw-r--r--sysdeps/unix/mknod.S24
-rw-r--r--sysdeps/unix/mman/madvise.S22
-rw-r--r--sysdeps/unix/mman/mmap.S22
-rw-r--r--sysdeps/unix/mman/mprotect.S22
-rw-r--r--sysdeps/unix/mman/msync.S22
-rw-r--r--sysdeps/unix/mman/munmap.S22
-rw-r--r--sysdeps/unix/nlist.c91
-rw-r--r--sysdeps/unix/open.S24
-rw-r--r--sysdeps/unix/opendir.c95
-rw-r--r--sysdeps/unix/pipestream.c2
-rw-r--r--sysdeps/unix/ptrace.S22
-rw-r--r--sysdeps/unix/read.S24
-rw-r--r--sysdeps/unix/readdir.c82
-rw-r--r--sysdeps/unix/reboot.S22
-rw-r--r--sysdeps/unix/rewinddir.c33
-rw-r--r--sysdeps/unix/seekdir.c33
-rw-r--r--sysdeps/unix/setgid.S24
-rw-r--r--sysdeps/unix/setuid.S24
-rw-r--r--sysdeps/unix/siglist.c46
-rwxr-xr-xsysdeps/unix/snarf-ioctls46
-rw-r--r--sysdeps/unix/sparc/brk.S55
-rw-r--r--sysdeps/unix/sparc/fork.S30
-rw-r--r--sysdeps/unix/sparc/pipe.S29
-rw-r--r--sysdeps/unix/sparc/start.c184
-rw-r--r--sysdeps/unix/sparc/sysdep.S47
-rw-r--r--sysdeps/unix/sparc/sysdep.h50
-rw-r--r--sysdeps/unix/sparc/vfork.S34
-rw-r--r--sysdeps/unix/start.c106
-rw-r--r--sysdeps/unix/stat.S24
-rw-r--r--sysdeps/unix/sync.S22
-rw-r--r--sysdeps/unix/syscall.S29
-rw-r--r--sysdeps/unix/sysdep.h59
-rw-r--r--sysdeps/unix/system.c2
-rw-r--r--sysdeps/unix/sysv/Dist3
-rw-r--r--sysdeps/unix/sysv/Makefile42
-rw-r--r--sysdeps/unix/sysv/alarm.S22
-rw-r--r--sysdeps/unix/sysv/direct.h10
-rw-r--r--sysdeps/unix/sysv/fcntlbits.h86
-rw-r--r--sysdeps/unix/sysv/getdents.c37
-rw-r--r--sysdeps/unix/sysv/gethostname.c38
-rw-r--r--sysdeps/unix/sysv/i386/linux/socket.S55
-rw-r--r--sysdeps/unix/sysv/i386/linux/sysdep.S38
-rw-r--r--sysdeps/unix/sysv/i386/linux/sysdep.h57
-rw-r--r--sysdeps/unix/sysv/i386/linux/wait.S31
-rw-r--r--sysdeps/unix/sysv/i386/signal.S31
-rw-r--r--sysdeps/unix/sysv/i386/sigreturn.S27
-rw-r--r--sysdeps/unix/sysv/i386/sysdep.h4
-rw-r--r--sysdeps/unix/sysv/i386/time.S26
-rw-r--r--sysdeps/unix/sysv/irix4/Dist2
-rw-r--r--sysdeps/unix/sysv/irix4/Implies4
-rw-r--r--sysdeps/unix/sysv/irix4/Makefile25
-rw-r--r--sysdeps/unix/sysv/irix4/__handler.S116
-rw-r--r--sysdeps/unix/sysv/irix4/confname.h80
-rw-r--r--sysdeps/unix/sysv/irix4/direct.h15
-rw-r--r--sysdeps/unix/sysv/irix4/dup2.c3
-rw-r--r--sysdeps/unix/sysv/irix4/fcntlbits.h98
-rw-r--r--sysdeps/unix/sysv/irix4/fpathconf.c34
-rw-r--r--sysdeps/unix/sysv/irix4/getgroups.c33
-rw-r--r--sysdeps/unix/sysv/irix4/getpgid.S24
-rw-r--r--sysdeps/unix/sysv/irix4/getpriority.c46
-rw-r--r--sysdeps/unix/sysv/irix4/getrusage.c35
-rw-r--r--sysdeps/unix/sysv/irix4/gettimeofday.c1
-rw-r--r--sysdeps/unix/sysv/irix4/msync.S1
-rw-r--r--sysdeps/unix/sysv/irix4/pathconf.c34
-rw-r--r--sysdeps/unix/sysv/irix4/readv.c1
-rw-r--r--sysdeps/unix/sysv/irix4/reboot.c1
-rw-r--r--sysdeps/unix/sysv/irix4/setgroups.c31
-rw-r--r--sysdeps/unix/sysv/irix4/setpgid.S25
-rw-r--r--sysdeps/unix/sysv/irix4/setpriority.c41
-rw-r--r--sysdeps/unix/sysv/irix4/signal.S22
-rw-r--r--sysdeps/unix/sysv/irix4/signum.h67
-rw-r--r--sysdeps/unix/sysv/irix4/sigreturn.S25
-rw-r--r--sysdeps/unix/sysv/irix4/sigtramp.c54
-rw-r--r--sysdeps/unix/sysv/irix4/start.c68
-rw-r--r--sysdeps/unix/sysv/irix4/statbuf.h61
-rw-r--r--sysdeps/unix/sysv/irix4/swapon.c1
-rw-r--r--sysdeps/unix/sysv/irix4/sys/mman.h101
-rw-r--r--sysdeps/unix/sysv/irix4/sysconf.c35
-rw-r--r--sysdeps/unix/sysv/irix4/sysmp.S22
-rw-r--r--sysdeps/unix/sysv/irix4/syssgi.S22
-rw-r--r--sysdeps/unix/sysv/irix4/time.S1
-rw-r--r--sysdeps/unix/sysv/irix4/uname.S26
-rw-r--r--sysdeps/unix/sysv/irix4/wait.S42
-rw-r--r--sysdeps/unix/sysv/irix4/wait3.S1
-rw-r--r--sysdeps/unix/sysv/irix4/waitpid.c1
-rw-r--r--sysdeps/unix/sysv/irix4/writev.c1
-rw-r--r--sysdeps/unix/sysv/isc2.2/rename.S1
-rw-r--r--sysdeps/unix/sysv/isc3/direct.h1
-rw-r--r--sysdeps/unix/sysv/linux/Implies2
-rw-r--r--sysdeps/unix/sysv/linux/accept.S2
-rw-r--r--sysdeps/unix/sysv/linux/bind.S2
-rw-r--r--sysdeps/unix/sysv/linux/connect.S2
-rw-r--r--sysdeps/unix/sysv/linux/getpeername.S2
-rw-r--r--sysdeps/unix/sysv/linux/getpgrp.S22
-rw-r--r--sysdeps/unix/sysv/linux/getsockname.S2
-rw-r--r--sysdeps/unix/sysv/linux/listen.S2
-rw-r--r--sysdeps/unix/sysv/linux/rename.S1
-rw-r--r--sysdeps/unix/sysv/linux/setsid.S1
-rw-r--r--sysdeps/unix/sysv/linux/socketpair.S2
-rw-r--r--sysdeps/unix/sysv/linux/syscall.h124
-rw-r--r--sysdeps/unix/sysv/linux/wait4.S1
-rw-r--r--sysdeps/unix/sysv/linux/waitpid.S24
-rw-r--r--sysdeps/unix/sysv/local_lim.h32
-rw-r--r--sysdeps/unix/sysv/minix/sigaction.h49
-rw-r--r--sysdeps/unix/sysv/mkdir.c97
-rw-r--r--sysdeps/unix/sysv/nice.S22
-rw-r--r--sysdeps/unix/sysv/pause.S22
-rw-r--r--sysdeps/unix/sysv/poll.S22
-rw-r--r--sysdeps/unix/sysv/rmdir.c78
-rw-r--r--sysdeps/unix/sysv/s_getdents.S22
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/Dist2
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/Makefile3
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/__setpgid.c30
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/confname.h50
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/direct.h22
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/getgroups.c45
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/getpgid.c1
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/pathconf.S24
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/pgrpsys.S1
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/pipestream.c3
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/sco_getgrp.S22
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/setpgid.c1
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/setsid.c1
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/sigaction.S29
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/sigaction.h39
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/sigpending.S22
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/sigprocmask.S24
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/sigsuspend.S1
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/syscall.h107
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/sysconf.S30
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/system.c10
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/uname.S42
-rw-r--r--sysdeps/unix/sysv/sco3.2.4/waitpid.S36
-rw-r--r--sysdeps/unix/sysv/sco3.2/Dist1
-rw-r--r--sysdeps/unix/sysv/sco3.2/Makefile23
-rw-r--r--sysdeps/unix/sysv/sco3.2/__fltused.c3
-rw-r--r--sysdeps/unix/sysv/sco3.2/local_lim.h37
-rw-r--r--sysdeps/unix/sysv/setrlimit.c58
-rw-r--r--sysdeps/unix/sysv/settimeofday.c47
-rw-r--r--sysdeps/unix/sysv/sigaction.c83
-rw-r--r--sysdeps/unix/sysv/signal.S22
-rw-r--r--sysdeps/unix/sysv/signum.h56
-rw-r--r--sysdeps/unix/sysv/statbuf.h61
-rw-r--r--sysdeps/unix/sysv/stime.S22
-rw-r--r--sysdeps/unix/sysv/sysd-stdio.c2
-rw-r--r--sysdeps/unix/sysv/sysv4/Dist7
-rw-r--r--sysdeps/unix/sysv/sysv4/Implies3
-rw-r--r--sysdeps/unix/sysv/sysv4/Makefile36
-rw-r--r--sysdeps/unix/sysv/sysv4/__getpgid.c31
-rw-r--r--sysdeps/unix/sysv/sysv4/__setpgid.c31
-rw-r--r--sysdeps/unix/sysv/sysv4/__waitid.S25
-rw-r--r--sysdeps/unix/sysv/sysv4/dup2.c4
-rw-r--r--sysdeps/unix/sysv/sysv4/fchdir.S2
-rw-r--r--sysdeps/unix/sysv/sysv4/ftruncate.c37
-rw-r--r--sysdeps/unix/sysv/sysv4/getdtsz.c2
-rw-r--r--sysdeps/unix/sysv/sysv4/gethostname.c33
-rw-r--r--sysdeps/unix/sysv/sysv4/getpagesize.c2
-rw-r--r--sysdeps/unix/sysv/sysv4/getpgid.c33
-rw-r--r--sysdeps/unix/sysv/sysv4/i386/Dist1
-rw-r--r--sysdeps/unix/sysv/sysv4/i386/Makefile3
-rw-r--r--sysdeps/unix/sysv/sysv4/i386/fstat.S37
-rw-r--r--sysdeps/unix/sysv/sysv4/i386/lstat.S37
-rw-r--r--sysdeps/unix/sysv/sysv4/i386/mknod.S36
-rw-r--r--sysdeps/unix/sysv/sysv4/i386/stat.S37
-rw-r--r--sysdeps/unix/sysv/sysv4/i386/statbuf.h84
-rw-r--r--sysdeps/unix/sysv/sysv4/i386/sys-sig.S30
-rw-r--r--sysdeps/unix/sysv/sysv4/i386/sysdep.h38
-rw-r--r--sysdeps/unix/sysv/sysv4/i386/vfork.S1
-rw-r--r--sysdeps/unix/sysv/sysv4/pgrpsys.S22
-rw-r--r--sysdeps/unix/sysv/sysv4/pipestream.c2
-rw-r--r--sysdeps/unix/sysv/sysv4/setegid.S2
-rw-r--r--sysdeps/unix/sysv/sysv4/seteuid.S2
-rw-r--r--sysdeps/unix/sysv/sysv4/sethostname.c31
-rw-r--r--sysdeps/unix/sysv/sysv4/setpgid.c35
-rw-r--r--sysdeps/unix/sysv/sysv4/setsid.c34
-rw-r--r--sysdeps/unix/sysv/sysv4/sigaction.c79
-rw-r--r--sysdeps/unix/sysv/sysv4/sigaction.h51
-rw-r--r--sysdeps/unix/sysv/sysv4/sigaltstack.S2
-rw-r--r--sysdeps/unix/sysv/sysv4/siginfo.h58
-rw-r--r--sysdeps/unix/sysv/sysv4/signum.h66
-rw-r--r--sysdeps/unix/sysv/sysv4/sigprocmask.S24
-rw-r--r--sysdeps/unix/sysv/sysv4/sigset.h97
-rw-r--r--sysdeps/unix/sysv/sysv4/sigsuspend.S22
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/Makefile6
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/direct.h39
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/fsync.S29
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/signum.h73
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/sparc/Dist1
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile5
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/sparc/start.c4
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/sparc/sys-sig.S25
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.S46
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h51
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/statbuf.h82
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/utimes.S2
-rw-r--r--sysdeps/unix/sysv/sysv4/sysconf.c181
-rw-r--r--sysdeps/unix/sysv/sysv4/sysconfig.S22
-rw-r--r--sysdeps/unix/sysv/sysv4/sysconfig.h28
-rw-r--r--sysdeps/unix/sysv/sysv4/sysinfo.S22
-rw-r--r--sysdeps/unix/sysv/sysv4/system.c2
-rw-r--r--sysdeps/unix/sysv/sysv4/time.S22
-rw-r--r--sysdeps/unix/sysv/sysv4/utsnamelen.h1
-rw-r--r--sysdeps/unix/sysv/sysv4/waitflags.h34
-rw-r--r--sysdeps/unix/sysv/sysv4/waitpid.c120
-rw-r--r--sysdeps/unix/sysv/sysv_termio.h155
-rw-r--r--sysdeps/unix/sysv/tcdrain.c33
-rw-r--r--sysdeps/unix/sysv/tcflow.c46
-rw-r--r--sysdeps/unix/sysv/tcflush.c44
-rw-r--r--sysdeps/unix/sysv/tcgetattr.c171
-rw-r--r--sysdeps/unix/sysv/tcgetpgrp.c35
-rw-r--r--sysdeps/unix/sysv/tcsendbrk.c43
-rw-r--r--sysdeps/unix/sysv/tcsetattr.c208
-rw-r--r--sysdeps/unix/sysv/tcsetpgrp.c31
-rw-r--r--sysdeps/unix/sysv/times.S24
-rw-r--r--sysdeps/unix/sysv/ulimit.S22
-rw-r--r--sysdeps/unix/sysv/uname.S22
-rw-r--r--sysdeps/unix/sysv/utime.S22
-rw-r--r--sysdeps/unix/sysv/utmp.h23
-rw-r--r--sysdeps/unix/sysv/utsnamelen.h1
-rw-r--r--sysdeps/unix/telldir.c42
-rw-r--r--sysdeps/unix/umask.S24
-rw-r--r--sysdeps/unix/unlink.S24
-rw-r--r--sysdeps/unix/write.S24
-rw-r--r--sysdeps/vax/DEFS.h61
-rw-r--r--sysdeps/vax/Dist1
-rw-r--r--sysdeps/vax/Makefile32
-rw-r--r--sysdeps/vax/__longjmp.c100
-rw-r--r--sysdeps/vax/bcmp.s57
-rw-r--r--sysdeps/vax/bcopy.s78
-rw-r--r--sysdeps/vax/bsd-_setjmp.S32
-rw-r--r--sysdeps/vax/bsd-setjmp.S32
-rw-r--r--sysdeps/vax/bzero.s53
-rw-r--r--sysdeps/vax/ffs.s48
-rw-r--r--sysdeps/vax/fl.h68
-rw-r--r--sysdeps/vax/htonl.s30
-rw-r--r--sysdeps/vax/htons.s30
-rw-r--r--sysdeps/vax/huge_val.h27
-rw-r--r--sysdeps/vax/index.s99
-rw-r--r--sysdeps/vax/infnan.c62
-rw-r--r--sysdeps/vax/jmp_buf.h7
-rw-r--r--sysdeps/vax/log10.c28
-rw-r--r--sysdeps/vax/memccpy.c45
-rw-r--r--sysdeps/vax/memchr.s73
-rw-r--r--sysdeps/vax/memcmp.s61
-rw-r--r--sysdeps/vax/memmove.s93
-rw-r--r--sysdeps/vax/memset.s55
-rw-r--r--sysdeps/vax/ntohl.s30
-rw-r--r--sysdeps/vax/ntohs.s30
-rw-r--r--sysdeps/vax/rindex.s113
-rw-r--r--sysdeps/vax/setjmp.c33
-rw-r--r--sysdeps/vax/strcat.s66
-rw-r--r--sysdeps/vax/strchr.s105
-rw-r--r--sysdeps/vax/strcpy.s62
-rw-r--r--sysdeps/vax/strcspn.s66
-rw-r--r--sysdeps/vax/strlen.s52
-rw-r--r--sysdeps/vax/strncat.s83
-rw-r--r--sysdeps/vax/strncmp.s89
-rw-r--r--sysdeps/vax/strncpy.s84
-rw-r--r--sysdeps/vax/strpbrk.s68
-rw-r--r--sysdeps/vax/strrchr.s114
-rw-r--r--sysdeps/vax/strsep.s85
-rw-r--r--sysdeps/vax/strspn.s70
-rw-r--r--sysdeps/vax/strstr.s113
-rw-r--r--sysdeps/z8000/gmp-mparam.h26
1443 files changed, 75303 insertions, 0 deletions
diff --git a/sysdeps/alpha/DEFS.h b/sysdeps/alpha/DEFS.h
new file mode 100644
index 0000000..c2a4fc8
--- /dev/null
+++ b/sysdeps/alpha/DEFS.h
@@ -0,0 +1,27 @@
+#ifdef __STDC__
+#define FUNC__(name) \
+ .align 3; \
+ .globl __##name; \
+ .ent __##name; \
+ __##name: \
+ lda sp, -16(sp); \
+ .frame sp, 16, t9, 0; \
+ .prologue 0
+#else
+#define FUNC__(name) \
+ .align 3; \
+ .globl __/**/name; \
+ .ent __/**/name,0; \
+ __/**/name: \
+ lda sp, -16(sp); \
+ .frame sp, 16, t9, 0; \
+ .prologue 0
+#endif
+
+#ifdef __STDC__
+#define NAME__(name) \
+ __##name
+#else
+#define NAME__(name) \
+ __/**/name
+#endif
diff --git a/sysdeps/alpha/Dist b/sysdeps/alpha/Dist
new file mode 100644
index 0000000..c4ea856
--- /dev/null
+++ b/sysdeps/alpha/Dist
@@ -0,0 +1,4 @@
+setjmp_aux.c
+DEFS.h
+divrem.m4 macros.m4
+divl.S divlu.S divq.S divqu.S reml.S remlu.S remq.S remqu.S
diff --git a/sysdeps/alpha/Implies b/sysdeps/alpha/Implies
new file mode 100644
index 0000000..9323409
--- /dev/null
+++ b/sysdeps/alpha/Implies
@@ -0,0 +1,2 @@
+# Alpha uses IEEE 754 floating point.
+ieee754
diff --git a/sysdeps/alpha/Makefile b/sysdeps/alpha/Makefile
new file mode 100644
index 0000000..06621b8
--- /dev/null
+++ b/sysdeps/alpha/Makefile
@@ -0,0 +1,94 @@
+# Copyright (C) 1993, 1994, 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.
+
+ifeq ($(subdir),setjmp)
+sysdep_routines := $(sysdep_routines) setjmp_aux
+endif
+
+ifeq ($(subdir),gnulib)
+routines = $(divrem)
+endif # gnulib
+
+# We distribute these files, even though they are generated,
+# so as to avoid the need for a functioning m4 to build the library.
+divrem := divl divlu divq divqu reml remlu remq remqu
+
++divrem-NAME-divl := divl
++divrem-NAME-divlu := divlu
++divrem-NAME-divq := divq
++divrem-NAME-divqu := divqu
++divrem-NAME-reml := reml
++divrem-NAME-remlu := remlu
++divrem-NAME-remq := remq
++divrem-NAME-remqu := remqu
++divrem-NAME = $(+divrem-NAME-$(basename $(notdir $@)))
+
++divrem-OP-divl := divl
++divrem-OP-divlu := divlu
++divrem-OP-divq := divq
++divrem-OP-divqu := divqu
++divrem-OP-reml := reml
++divrem-OP-remlu := remlu
++divrem-OP-remq := remq
++divrem-OP-remqu := remqu
++divrem-BASEOP-divl := div
++divrem-BASEOP-divlu := div
++divrem-BASEOP-divq := div
++divrem-BASEOP-divqu := div
++divrem-BASEOP-reml := rem
++divrem-BASEOP-remlu := rem
++divrem-BASEOP-remq := rem
++divrem-BASEOP-remqu := rem
++divrem-S-divl := true
++divrem-S-divlu := false
++divrem-S-divq := true
++divrem-S-divqu := false
++divrem-S-reml := true
++divrem-S-remlu := false
++divrem-S-remq := true
++divrem-S-remqu := false
++divrem-SIZE-divl := l
++divrem-SIZE-divlu := l
++divrem-SIZE-divq := q
++divrem-SIZE-divqu := q
++divrem-SIZE-reml := l
++divrem-SIZE-remlu := l
++divrem-SIZE-remq := q
++divrem-SIZE-remqu := q
++divrem-MODE-divl := l
++divrem-MODE-divlu := lu
++divrem-MODE-divq := q
++divrem-MODE-divqu := qu
++divrem-MODE-reml := l
++divrem-MODE-remlu := lu
++divrem-MODE-remq := q
++divrem-MODE-remqu := qu
+
+$(divrem:%=$(sysdep_dir)/alpha/%.S): $(sysdep_dir)/alpha/divrem.m4 $(sysdep_dir)/alpha/DEFS.h $(sysdep_dir)/alpha/macros.m4
+ (echo "define(OP,\`$(+divrem-NAME)')\
+ define(BASEOP,\`$(+divrem-BASEOP-$(+divrem-NAME))')\
+ define(MODE,\`$(+divrem-MODE-$(+divrem-NAME))')\
+ define(SIZE,\`$(+divrem-SIZE-$(+divrem-NAME))')\
+ define(SIGNED,\`$(+divrem-S-$(+divrem-NAME))')\
+ define(SYSDEP_DIR, \`$(sysdep_dir)/alpha')\
+ /* This file is generated from divrem.m4; DO NOT EDIT! */"; \
+ cat $<) | $(M4) > $@-tmp
+# Make it unwritable so noone will edit it by mistake.
+ -chmod a-w $@-tmp
+ mv -f $@-tmp $@
+ test -d CVS && cvs commit -m'Regenerated from $<' $@
diff --git a/sysdeps/alpha/__longjmp.c b/sysdeps/alpha/__longjmp.c
new file mode 100644
index 0000000..19a2e26
--- /dev/null
+++ b/sysdeps/alpha/__longjmp.c
@@ -0,0 +1,91 @@
+/* Copyright (C) 1992, 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. */
+
+/* Global register vars must come before any function defn. */
+
+register long int
+ r9 asm ("$9"), r10 asm ("$10"), r11 asm ("$11"), r12 asm ("$12"),
+ r13 asm ("$13"), r14 asm ("$14");
+
+register long int *fp asm ("$15"), *sp asm ("$30"), *retpc asm ("$26");
+
+#if 1 /* XXX */
+register double
+ f2 asm ("$f2"), f3 asm ("$f3"), f4 asm ("$f4"), f5 asm ("$f5"),
+ f6 asm ("$f6"), f7 asm ("$f7"), f8 asm ("$f8"), f9 asm ("$f9");
+#endif
+
+#include <setjmp.h>
+
+
+/* Jump to the position specified by ENV, causing the
+ setjmp call there to return VAL, or 1 if VAL is 0. */
+__NORETURN
+void
+__longjmp (const __jmp_buf env, int val)
+{
+ /* Restore the integer registers. */
+ r9 = env[0].__9;
+ r10 = env[0].__10;
+ r11 = env[0].__11;
+ r12 = env[0].__12;
+ r13 = env[0].__13;
+ r14 = env[0].__14;
+
+#if 1 /* XXX */
+ /* Restore the floating point registers. */
+ f2 = env[0].__f2;
+ f3 = env[0].__f3;
+ f4 = env[0].__f4;
+ f5 = env[0].__f5;
+ f6 = env[0].__f6;
+ f7 = env[0].__f7;
+ f8 = env[0].__f8;
+ f9 = env[0].__f9;
+#endif
+
+ /* Set the return PC to that of setjmp's caller. */
+ retpc = env[0].__pc;
+
+ /* Restore the FP and SP of setjmp's caller. */
+ fp = env[0].__fp;
+ sp = env[0].__sp;
+
+ /* Return VAL (or 1 if VAL is zero) to setjmp's caller.
+
+ We use an asm here rather than a normal C return statement
+ just in case the compiler wanted to do some stack frobnication
+ in the function epilogue. Since we have already restored
+ precisely the FP and SP the desired environment needs,
+ we must avoid the compiler doing anything with the stack. */
+
+ while (1)
+ {
+ /* The loop is just to avoid `volatile function does return' warnings.
+ The instruction will only be executed once. */
+
+ register long int retval asm ("$0");
+
+ asm volatile
+ ("cmoveq %1, 1, %0\n\t" /* $0 = val ?: 1; */
+ "ret $31, (%2), 1" /* return $0 */
+ : "=r" (retval)
+ /* The "0" constraint should force VAL into $0. */
+ : "0" (val), "r" (retpc));
+ }
+}
diff --git a/sysdeps/alpha/__math.h b/sysdeps/alpha/__math.h
new file mode 100644
index 0000000..b06f716
--- /dev/null
+++ b/sysdeps/alpha/__math.h
@@ -0,0 +1,35 @@
+/* Copyright (C) 1992 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. */
+
+#if defined (__GNUC__) && !defined (__NO_MATH_INLINES)
+
+extern __inline __CONSTVALUE double
+__copysign (double __x, double __y)
+{
+ __asm ("cpys %1, %2, %0" : "=f" (__x) : "f" (__y), "f" (__x));
+ return __x;
+}
+
+extern __inline double
+fabs (double __x)
+{
+ __asm ("cpys $f31, %1, %0" : "=f" (__x) : "f" (__x));
+ return __x;
+}
+
+#endif
diff --git a/sysdeps/alpha/bsd-_setjmp.S b/sysdeps/alpha/bsd-_setjmp.S
new file mode 100644
index 0000000..9947d8f
--- /dev/null
+++ b/sysdeps/alpha/bsd-_setjmp.S
@@ -0,0 +1,30 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. Alpha 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. */
+
+/* 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>
+
+ENTRY (setjmp)
+ lda $27, __sigsetjmp /* Load address to jump to. */
+ bis $31, $31, $17 /* Pass a second argument of zero. */
+ jmp $31, ($27), __sigsetjmp /* Call __sigsetjmp. */
+ .end setjmp
diff --git a/sysdeps/alpha/bsd-setjmp.S b/sysdeps/alpha/bsd-setjmp.S
new file mode 100644
index 0000000..470f7bc
--- /dev/null
+++ b/sysdeps/alpha/bsd-setjmp.S
@@ -0,0 +1,30 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. Alpha 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. */
+
+/* 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>
+
+ENTRY (setjmp)
+ lda $27, __sigsetjmp /* Load address to jump to. */
+ bis $31, 1, $17 /* Pass a second argument of one. */
+ jmp $31, ($27), __sigsetjmp /* Call __sigsetjmp. */
+ .end setjmp
diff --git a/sysdeps/alpha/bytesex.h b/sysdeps/alpha/bytesex.h
new file mode 100644
index 0000000..e873d21
--- /dev/null
+++ b/sysdeps/alpha/bytesex.h
@@ -0,0 +1,3 @@
+/* Alpha is little-endian. */
+
+#define __BYTE_ORDER __LITTLE_ENDIAN
diff --git a/sysdeps/alpha/copysign.c b/sysdeps/alpha/copysign.c
new file mode 100644
index 0000000..69544b0
--- /dev/null
+++ b/sysdeps/alpha/copysign.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1992, 1993, 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. */
+
+#define __NO_MATH_INLINES
+
+#include <math.h>
+
+/* Return X with its sign changed to Y's. */
+__inline double
+__copysign (double __x, double __y)
+{
+ __asm ("cpys %1, %2, %0" : "=f" (__x) : "f" (__y), "f" (__x));
+ return __x;
+}
+
+weak_alias (__copysign, copysign)
diff --git a/sysdeps/alpha/divl.S b/sysdeps/alpha/divl.S
new file mode 100644
index 0000000..7ae3e0c
--- /dev/null
+++ b/sysdeps/alpha/divl.S
@@ -0,0 +1,54 @@
+ /* This file is generated from divrem.m4; DO NOT EDIT! */
+/* For each N divided by D, we do:
+ result = (double) N / (double) D
+ Then, for each N mod D, we do:
+ result = N - (D * divMODE (N, D))
+
+ FIXME:
+ The q and qu versions won't deal with operands > 50 bits. We also
+ don't check for divide by zero. */
+
+#include "DEFS.h"
+#if 0
+/* We do not handle div by zero yet. */
+#include <machine/pal.h>
+#endif
+#include <sysdep.h>
+
+
+
+
+
+
+FUNC__(divl)
+ /* First set up the dividend. */
+ sextl t10, t10
+
+ stq t10,0(sp)
+ ldt $f10,0(sp)
+ cvtqt $f10,$f10
+
+
+ /* Then set up the divisor. */
+ sextl t11, t11
+
+ stq t11,0(sp)
+ ldt $f1,0(sp)
+ cvtqt $f1,$f1
+
+
+ /* Do the division. */
+ divt $f10,$f1,$f10
+ cvttqc $f10,$f10
+
+ /* Put the result in t12. */
+ stt $f10,0(sp)
+ ldq t12,0(sp)
+ sextl t12, t12
+
+
+
+
+ lda sp,16(sp)
+ ret zero,(t9),1
+ .end NAME__(divl)
diff --git a/sysdeps/alpha/divlu.S b/sysdeps/alpha/divlu.S
new file mode 100644
index 0000000..9ae5950
--- /dev/null
+++ b/sysdeps/alpha/divlu.S
@@ -0,0 +1,54 @@
+ /* This file is generated from divrem.m4; DO NOT EDIT! */
+/* For each N divided by D, we do:
+ result = (double) N / (double) D
+ Then, for each N mod D, we do:
+ result = N - (D * divMODE (N, D))
+
+ FIXME:
+ The q and qu versions won't deal with operands > 50 bits. We also
+ don't check for divide by zero. */
+
+#include "DEFS.h"
+#if 0
+/* We do not handle div by zero yet. */
+#include <machine/pal.h>
+#endif
+#include <sysdep.h>
+
+
+
+
+
+
+FUNC__(divlu)
+ /* First set up the dividend. */
+ zapnot t10, 0xf, t10
+
+ stq t10,0(sp)
+ ldt $f10,0(sp)
+ cvtqt $f10,$f10
+
+
+ /* Then set up the divisor. */
+ zapnot t11, 0xf, t11
+
+ stq t11,0(sp)
+ ldt $f1,0(sp)
+ cvtqt $f1,$f1
+
+
+ /* Do the division. */
+ divt $f10,$f1,$f10
+ cvttqc $f10,$f10
+
+ /* Put the result in t12. */
+ stt $f10,0(sp)
+ ldq t12,0(sp)
+ sextl t12, t12
+
+
+
+
+ lda sp,16(sp)
+ ret zero,(t9),1
+ .end NAME__(divlu)
diff --git a/sysdeps/alpha/divq.S b/sysdeps/alpha/divq.S
new file mode 100644
index 0000000..79ff6ca
--- /dev/null
+++ b/sysdeps/alpha/divq.S
@@ -0,0 +1,51 @@
+ /* This file is generated from divrem.m4; DO NOT EDIT! */
+/* For each N divided by D, we do:
+ result = (double) N / (double) D
+ Then, for each N mod D, we do:
+ result = N - (D * divMODE (N, D))
+
+ FIXME:
+ The q and qu versions won't deal with operands > 50 bits. We also
+ don't check for divide by zero. */
+
+#include "DEFS.h"
+#if 0
+/* We do not handle div by zero yet. */
+#include <machine/pal.h>
+#endif
+#include <sysdep.h>
+
+
+
+
+
+
+FUNC__(divq)
+ /* First set up the dividend. */
+
+ stq t10,0(sp)
+ ldt $f10,0(sp)
+ cvtqt $f10,$f10
+
+
+ /* Then set up the divisor. */
+
+ stq t11,0(sp)
+ ldt $f1,0(sp)
+ cvtqt $f1,$f1
+
+
+ /* Do the division. */
+ divt $f10,$f1,$f10
+ cvttqc $f10,$f10
+
+ /* Put the result in t12. */
+ stt $f10,0(sp)
+ ldq t12,0(sp)
+
+
+
+
+ lda sp,16(sp)
+ ret zero,(t9),1
+ .end NAME__(divq)
diff --git a/sysdeps/alpha/divqu.S b/sysdeps/alpha/divqu.S
new file mode 100644
index 0000000..7908b9f
--- /dev/null
+++ b/sysdeps/alpha/divqu.S
@@ -0,0 +1,57 @@
+ /* This file is generated from divrem.m4; DO NOT EDIT! */
+/* For each N divided by D, we do:
+ result = (double) N / (double) D
+ Then, for each N mod D, we do:
+ result = N - (D * divMODE (N, D))
+
+ FIXME:
+ The q and qu versions won't deal with operands > 50 bits. We also
+ don't check for divide by zero. */
+
+#include "DEFS.h"
+#if 0
+/* We do not handle div by zero yet. */
+#include <machine/pal.h>
+#endif
+#include <sysdep.h>
+
+
+
+
+
+
+FUNC__(divqu)
+ /* First set up the dividend. */
+
+ stq t10,0(sp)
+ ldt $f10,0(sp)
+ cvtqt $f10,$f10
+ ldit $f26, 18446744073709551616.0
+ addt $f26, $f10, $f26
+ fcmovlt $f10, $f26, $f10
+
+
+ /* Then set up the divisor. */
+
+ stq t11,0(sp)
+ ldt $f1,0(sp)
+ cvtqt $f1,$f1
+ ldit $f26, 18446744073709551616.0
+ addt $f26, $f1, $f26
+ fcmovlt $f1, $f26, $f1
+
+
+ /* Do the division. */
+ divt $f10,$f1,$f10
+ cvttqc $f10,$f10
+
+ /* Put the result in t12. */
+ stt $f10,0(sp)
+ ldq t12,0(sp)
+
+
+
+
+ lda sp,16(sp)
+ ret zero,(t9),1
+ .end NAME__(divqu)
diff --git a/sysdeps/alpha/divrem.m4 b/sysdeps/alpha/divrem.m4
new file mode 100644
index 0000000..5942cf4
--- /dev/null
+++ b/sysdeps/alpha/divrem.m4
@@ -0,0 +1,48 @@
+/* For each N divided by D, we do:
+ result = (double) N / (double) D
+ Then, for each N mod D, we do:
+ result = N - (D * divMODE (N, D))
+
+ FIXME:
+ The q and qu versions won't deal with operands > 50 bits. We also
+ don't check for divide by zero. */
+
+#include "DEFS.h"
+#if 0
+/* We do not handle div by zero yet. */
+#include <machine/pal.h>
+#endif
+#include <sysdep.h>
+
+define(path, `SYSDEP_DIR/macros.m4')dnl
+include(path)
+
+FUNC__(OP)
+ /* First set up the dividend. */
+ EXTEND(t10)
+ stq t10,0(sp)
+ ldt $f10,0(sp)
+ cvtqt $f10,$f10
+ ADJQU($f10)
+
+ /* Then set up the divisor. */
+ EXTEND(t11)
+ stq t11,0(sp)
+ ldt $f1,0(sp)
+ cvtqt $f1,$f1
+ ADJQU($f1)
+
+ /* Do the division. */
+ divt $f10,$f1,$f10
+ cvttqc $f10,$f10
+
+ /* Put the result in t12. */
+ stt $f10,0(sp)
+ ldq t12,0(sp)
+ FULLEXTEND(t12)
+
+ DOREM
+
+ lda sp,16(sp)
+ ret zero,(t9),1
+ .end NAME__(OP)
diff --git a/sysdeps/alpha/fabs.c b/sysdeps/alpha/fabs.c
new file mode 100644
index 0000000..321df0d
--- /dev/null
+++ b/sysdeps/alpha/fabs.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1992 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. */
+
+#define __NO_MATH_INLINES
+
+#include <math.h>
+
+__inline double
+fabs (double __x)
+{
+ __asm ("cpys $f31, %1, %0" : "=f" (__x) : "f" (__x));
+ return __x;
+}
diff --git a/sysdeps/alpha/gmp-mparam.h b/sysdeps/alpha/gmp-mparam.h
new file mode 100644
index 0000000..05c893f
--- /dev/null
+++ b/sysdeps/alpha/gmp-mparam.h
@@ -0,0 +1,26 @@
+/* gmp-mparam.h -- Compiler/machine parameter header file.
+
+Copyright (C) 1991, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#define BITS_PER_MP_LIMB 64
+#define BYTES_PER_MP_LIMB 8
+#define BITS_PER_LONGINT 64
+#define BITS_PER_INT 32
+#define BITS_PER_SHORTINT 16
+#define BITS_PER_CHAR 8
diff --git a/sysdeps/alpha/jmp_buf.h b/sysdeps/alpha/jmp_buf.h
new file mode 100644
index 0000000..6e6f6b4
--- /dev/null
+++ b/sysdeps/alpha/jmp_buf.h
@@ -0,0 +1,46 @@
+/* Define the machine-dependent type `jmp_buf'. Alpha version.
+Copyright (C) 1992 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. */
+
+typedef struct
+ {
+ /* Integer registers:
+ $0 is the return value;
+ $1-$8, $22-$25, $28 are call-used;
+ $9-$14 we save here;
+ $15 is the FP and we save it here;
+ $16-$21 are input arguments (call-used);
+ $26 is the return PC and we save it here;
+ $27 is the procedure value (i.e., the address of __setjmp);
+ $29 is the global pointer, which the caller will reconstruct
+ from the return address restored in $26;
+ $30 is the stack pointer and we save it here;
+ $31 is always zero. */
+ long int __9, __10, __11, __12, __13, __14;
+ long int *__pc, *__fp, *__sp;
+
+#if 1 /* XXX need predefine for TARGET_FPREGS */
+ /* Floating-point registers:
+ $f0 is the floating return value;
+ $f1, $f10-$f15, $f22-$f30 are call-used;
+ $f2-$f9 we save here;
+ $f16-$21 are input args (call-used);
+ $f31 is always zero. */
+ double __f2, __f3, __f4, __f5, __f6, __f7, __f8, __f9;
+#endif /* Have FP regs. */
+ } __jmp_buf[1];
diff --git a/sysdeps/alpha/macros.m4 b/sysdeps/alpha/macros.m4
new file mode 100644
index 0000000..f8c1fe9
--- /dev/null
+++ b/sysdeps/alpha/macros.m4
@@ -0,0 +1,34 @@
+dnl NOTE: The $1 below is the argument to EXTEND, not register $1.
+define(EXTEND,
+`ifelse(SIZE, `l',
+`ifelse(SIGNED, `true',
+` sextl $1, $1
+',dnl
+` zapnot $1, 0xf, $1
+')')')dnl
+
+dnl FULLEXTEND -- extend the register named in the first argument
+define(FULLEXTEND,
+`ifelse(SIZE, `l',
+` sextl $1, $1
+')')dnl
+
+dnl This is used by divqu.
+define(ADJQU,
+`ifelse(MODE, `qu',
+` ldit $f26, 18446744073709551616.0
+ addt $f26, $1, $f26
+ fcmovlt $1, $f26, $1
+')')dnl
+
+define(DOREM,
+`ifelse(BASEOP, `rem',
+` /* Compute the remainder. */
+ifelse(SIZE, `l',
+` mull t11, t12, t11
+ subl t10, t11, t12
+',dnl Note mulq/subq were only really used in remq, but we will find out
+dnl if assuming they apply to remqu as well is wrong or not.
+` mulq t11, t12, t11
+ subq t10, t11, t12
+')')')dnl
diff --git a/sysdeps/alpha/memchr.c b/sysdeps/alpha/memchr.c
new file mode 100644
index 0000000..11ff542
--- /dev/null
+++ b/sysdeps/alpha/memchr.c
@@ -0,0 +1,86 @@
+/* Copyright (C) 1992, 1993, 1994 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
+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. */
+
+#include <string.h>
+
+/* Search no more than N bytes of S for C. */
+
+void *
+memchr (const void *s, int c, size_t n)
+{
+ const char *char_ptr;
+ const unsigned long int *longword_ptr;
+ unsigned long int charmask;
+ size_t x;
+
+ c = (unsigned char) c;
+
+ /* Handle the first few characters by reading one character at a time.
+ Do this until STR is aligned on a 8-byte border. */
+ for (char_ptr = s; n > 0 && ((unsigned long int) char_ptr & 7) != 0;
+ --n, ++char_ptr)
+ if (*char_ptr == c)
+ return (void *) char_ptr;
+
+ if (n == (size_t)0)
+ return NULL;
+
+ x = n;
+
+ longword_ptr = (unsigned long int *) char_ptr;
+
+ /* Set up a longword, each of whose bytes is C. */
+ charmask = c | (c << 8);
+ charmask |= charmask << 16;
+ charmask |= charmask << 32;
+
+ for (;;)
+ {
+ const unsigned long int longword = *longword_ptr++;
+ int ge, le;
+
+ if (x < 4)
+ x = (size_t) 0;
+ else
+ x -= 4;
+
+ /* Set bits in GE if bytes in CHARMASK are >= bytes in LONGWORD. */
+ asm ("cmpbge %1, %2, %0" : "=r" (ge) : "r" (charmask), "r" (longword));
+
+ /* Set bits in LE if bytes in CHARMASK are <= bytes in LONGWORD. */
+ asm ("cmpbge %2, %1, %0" : "=r" (le) : "r" (charmask), "r" (longword));
+
+ /* Bytes that are both <= and >= are == to C. */
+ if (ge & le)
+ {
+ /* Which of the bytes was the C? */
+
+ unsigned char *cp = (unsigned char *) (longword_ptr - 1);
+ int i;
+
+ for (i = 0; i < 6; i++)
+ if (cp[i] == c)
+ return &cp[i];
+ return &cp[7];
+ }
+
+ if (x == (size_t)0)
+ break;
+ }
+
+ return NULL;
+}
diff --git a/sysdeps/alpha/reml.S b/sysdeps/alpha/reml.S
new file mode 100644
index 0000000..2ece297
--- /dev/null
+++ b/sysdeps/alpha/reml.S
@@ -0,0 +1,57 @@
+ /* This file is generated from divrem.m4; DO NOT EDIT! */
+/* For each N divided by D, we do:
+ result = (double) N / (double) D
+ Then, for each N mod D, we do:
+ result = N - (D * divMODE (N, D))
+
+ FIXME:
+ The q and qu versions won't deal with operands > 50 bits. We also
+ don't check for divide by zero. */
+
+#include "DEFS.h"
+#if 0
+/* We do not handle div by zero yet. */
+#include <machine/pal.h>
+#endif
+#include <sysdep.h>
+
+
+
+
+
+
+FUNC__(reml)
+ /* First set up the dividend. */
+ sextl t10, t10
+
+ stq t10,0(sp)
+ ldt $f10,0(sp)
+ cvtqt $f10,$f10
+
+
+ /* Then set up the divisor. */
+ sextl t11, t11
+
+ stq t11,0(sp)
+ ldt $f1,0(sp)
+ cvtqt $f1,$f1
+
+
+ /* Do the division. */
+ divt $f10,$f1,$f10
+ cvttqc $f10,$f10
+
+ /* Put the result in t12. */
+ stt $f10,0(sp)
+ ldq t12,0(sp)
+ sextl t12, t12
+
+
+ /* Compute the remainder. */
+ mull t11, t12, t11
+ subl t10, t11, t12
+
+
+ lda sp,16(sp)
+ ret zero,(t9),1
+ .end NAME__(reml)
diff --git a/sysdeps/alpha/remlu.S b/sysdeps/alpha/remlu.S
new file mode 100644
index 0000000..d7700e6
--- /dev/null
+++ b/sysdeps/alpha/remlu.S
@@ -0,0 +1,57 @@
+ /* This file is generated from divrem.m4; DO NOT EDIT! */
+/* For each N divided by D, we do:
+ result = (double) N / (double) D
+ Then, for each N mod D, we do:
+ result = N - (D * divMODE (N, D))
+
+ FIXME:
+ The q and qu versions won't deal with operands > 50 bits. We also
+ don't check for divide by zero. */
+
+#include "DEFS.h"
+#if 0
+/* We do not handle div by zero yet. */
+#include <machine/pal.h>
+#endif
+#include <sysdep.h>
+
+
+
+
+
+
+FUNC__(remlu)
+ /* First set up the dividend. */
+ zapnot t10, 0xf, t10
+
+ stq t10,0(sp)
+ ldt $f10,0(sp)
+ cvtqt $f10,$f10
+
+
+ /* Then set up the divisor. */
+ zapnot t11, 0xf, t11
+
+ stq t11,0(sp)
+ ldt $f1,0(sp)
+ cvtqt $f1,$f1
+
+
+ /* Do the division. */
+ divt $f10,$f1,$f10
+ cvttqc $f10,$f10
+
+ /* Put the result in t12. */
+ stt $f10,0(sp)
+ ldq t12,0(sp)
+ sextl t12, t12
+
+
+ /* Compute the remainder. */
+ mull t11, t12, t11
+ subl t10, t11, t12
+
+
+ lda sp,16(sp)
+ ret zero,(t9),1
+ .end NAME__(remlu)
diff --git a/sysdeps/alpha/remq.S b/sysdeps/alpha/remq.S
new file mode 100644
index 0000000..47510cb
--- /dev/null
+++ b/sysdeps/alpha/remq.S
@@ -0,0 +1,54 @@
+ /* This file is generated from divrem.m4; DO NOT EDIT! */
+/* For each N divided by D, we do:
+ result = (double) N / (double) D
+ Then, for each N mod D, we do:
+ result = N - (D * divMODE (N, D))
+
+ FIXME:
+ The q and qu versions won't deal with operands > 50 bits. We also
+ don't check for divide by zero. */
+
+#include "DEFS.h"
+#if 0
+/* We do not handle div by zero yet. */
+#include <machine/pal.h>
+#endif
+#include <sysdep.h>
+
+
+
+
+
+
+FUNC__(remq)
+ /* First set up the dividend. */
+
+ stq t10,0(sp)
+ ldt $f10,0(sp)
+ cvtqt $f10,$f10
+
+
+ /* Then set up the divisor. */
+
+ stq t11,0(sp)
+ ldt $f1,0(sp)
+ cvtqt $f1,$f1
+
+
+ /* Do the division. */
+ divt $f10,$f1,$f10
+ cvttqc $f10,$f10
+
+ /* Put the result in t12. */
+ stt $f10,0(sp)
+ ldq t12,0(sp)
+
+
+ /* Compute the remainder. */
+ mulq t11, t12, t11
+ subq t10, t11, t12
+
+
+ lda sp,16(sp)
+ ret zero,(t9),1
+ .end NAME__(remq)
diff --git a/sysdeps/alpha/remqu.S b/sysdeps/alpha/remqu.S
new file mode 100644
index 0000000..ec9572d
--- /dev/null
+++ b/sysdeps/alpha/remqu.S
@@ -0,0 +1,60 @@
+ /* This file is generated from divrem.m4; DO NOT EDIT! */
+/* For each N divided by D, we do:
+ result = (double) N / (double) D
+ Then, for each N mod D, we do:
+ result = N - (D * divMODE (N, D))
+
+ FIXME:
+ The q and qu versions won't deal with operands > 50 bits. We also
+ don't check for divide by zero. */
+
+#include "DEFS.h"
+#if 0
+/* We do not handle div by zero yet. */
+#include <machine/pal.h>
+#endif
+#include <sysdep.h>
+
+
+
+
+
+
+FUNC__(remqu)
+ /* First set up the dividend. */
+
+ stq t10,0(sp)
+ ldt $f10,0(sp)
+ cvtqt $f10,$f10
+ ldit $f26, 18446744073709551616.0
+ addt $f26, $f10, $f26
+ fcmovlt $f10, $f26, $f10
+
+
+ /* Then set up the divisor. */
+
+ stq t11,0(sp)
+ ldt $f1,0(sp)
+ cvtqt $f1,$f1
+ ldit $f26, 18446744073709551616.0
+ addt $f26, $f1, $f26
+ fcmovlt $f1, $f26, $f1
+
+
+ /* Do the division. */
+ divt $f10,$f1,$f10
+ cvttqc $f10,$f10
+
+ /* Put the result in t12. */
+ stt $f10,0(sp)
+ ldq t12,0(sp)
+
+
+ /* Compute the remainder. */
+ mulq t11, t12, t11
+ subq t10, t11, t12
+
+
+ lda sp,16(sp)
+ ret zero,(t9),1
+ .end NAME__(remqu)
diff --git a/sysdeps/alpha/setjmp.S b/sysdeps/alpha/setjmp.S
new file mode 100644
index 0000000..08932cc
--- /dev/null
+++ b/sysdeps/alpha/setjmp.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 1992, 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. */
+
+#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. */
+ENTRY (__sigsetjmp)
+ lda $27, __sigsetjmp_aux/* Load address to jump to. */
+ bis $15, $15, $18 /* Pass FP as 3rd arg. */
+ bis $30, $30, $19 /* Pass SP as 4th arg. */
+ jmp $31, ($27), __sigsetjmp_aux /* Call __sigsetjmp_aux. */
+ .end __sigsetjmp
diff --git a/sysdeps/alpha/setjmp_aux.c b/sysdeps/alpha/setjmp_aux.c
new file mode 100644
index 0000000..f92517b
--- /dev/null
+++ b/sysdeps/alpha/setjmp_aux.c
@@ -0,0 +1,74 @@
+/* Copyright (C) 1992, 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. */
+
+/* Global register decls must come before any function defn. */
+
+register long int
+ r9 asm ("$9"), r10 asm ("$10"), r11 asm ("$11"), r12 asm ("$12"),
+ r13 asm ("$13"), r14 asm ("$14");
+
+register long int *fp asm ("$15"), *sp asm ("$30"), *retpc asm ("$26");
+
+#if 1 /* XXX */
+register double
+ f2 asm ("$f2"), f3 asm ("$f3"), f4 asm ("$f4"), f5 asm ("$f5"),
+ f6 asm ("$f6"), f7 asm ("$f7"), f8 asm ("$f8"), f9 asm ("$f9");
+#endif
+
+
+#include <setjmp.h>
+
+
+/* Save the current program position in ENV and return 0. */
+int
+__sigsetjmp_aux (sigjmp_buf env, int savemask, long int *sp, long int *fp)
+{
+ /* Save the integer registers. */
+ env[0].__jmpbuf[0].__9 = r9;
+ env[0].__jmpbuf[0].__10 = r10;
+ env[0].__jmpbuf[0].__11 = r11;
+ env[0].__jmpbuf[0].__12 = r12;
+ env[0].__jmpbuf[0].__13 = r13;
+ env[0].__jmpbuf[0].__14 = r14;
+
+#if 1 /* XXX */
+ /* Save the floating point registers. */
+ env[0].__jmpbuf[0].__f2 = f2;
+ env[0].__jmpbuf[0].__f3 = f3;
+ env[0].__jmpbuf[0].__f4 = f4;
+ env[0].__jmpbuf[0].__f5 = f5;
+ env[0].__jmpbuf[0].__f6 = f6;
+ env[0].__jmpbuf[0].__f7 = f7;
+ env[0].__jmpbuf[0].__f8 = f8;
+ env[0].__jmpbuf[0].__f9 = f9;
+#endif
+
+ /* Save the return address of our caller, where longjmp will jump to. */
+ env[0].__jmpbuf[0].__pc = retpc;
+
+ /* Save the FP and SP of our caller. The __sigsetjmp entry point
+ simply puts these in the argument registers for us to fetch. */
+ env[0].__jmpbuf[0].__fp = fp;
+ env[0].__jmpbuf[0].__sp = sp;
+
+ /* Save the signal mask if requested. */
+ __sigjmp_save (env, savemask);
+
+ /* Return to the original caller of __sigsetjmp. */
+ return 0;
+}
diff --git a/sysdeps/alpha/strchr.c b/sysdeps/alpha/strchr.c
new file mode 100644
index 0000000..69afa4b
--- /dev/null
+++ b/sysdeps/alpha/strchr.c
@@ -0,0 +1,84 @@
+/* Copyright (C) 1992, 1993, 1994, 1995 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
+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. */
+
+#include <string.h>
+
+/* Return the length of the null-terminated string STR. Scan for
+ the null terminator quickly by testing eight bytes at a time. */
+
+char *
+strchr (const char *str, int c)
+{
+ const char *char_ptr;
+ const unsigned long int *longword_ptr;
+ unsigned long int charmask;
+
+ c = (unsigned char) c;
+
+ /* Handle the first few characters by reading one character at a time.
+ Do this until STR is aligned on a 8-byte border. */
+ for (char_ptr = str; ((unsigned long int) char_ptr & 7) != 0; ++char_ptr)
+ if (*char_ptr == c)
+ return (char *) char_ptr;
+ else if (*char_ptr == '\0')
+ return NULL;
+
+ longword_ptr = (unsigned long int *) char_ptr;
+
+ /* Set up a longword, each of whose bytes is C. */
+ charmask = c | (c << 8);
+ charmask |= charmask << 16;
+ charmask |= charmask << 32;
+
+ for (;;)
+ {
+ const unsigned long int longword = *longword_ptr++;
+ int ge, le, zero;
+
+ /* Set bits in ZERO if bytes in LONGWORD are zero. */
+ asm ("cmpbge $31, %1, %0" : "=r" (zero) : "r" (longword));
+
+ /* Set bits in GE if bytes in CHARMASK are >= bytes in LONGWORD. */
+ asm ("cmpbge %1, %2, %0" : "=r" (ge) : "r" (charmask), "r" (longword));
+
+ /* Set bits in LE if bytes in CHARMASK are <= bytes in LONGWORD. */
+ asm ("cmpbge %2, %1, %0" : "=r" (le) : "r" (charmask), "r" (longword));
+
+ /* Bytes that are both <= and >= are == to C. */
+ if (zero || (ge & le))
+ {
+ /* Which of the bytes was the C? */
+
+ char *cp = (char *) (longword_ptr - 1);
+ int i;
+
+ for (i = 0; i < 8; i++)
+ {
+ if (cp[i] == c)
+ return &cp[i];
+ if (cp[i] == 0)
+ return NULL;
+ }
+ return NULL;
+ }
+ }
+}
+
+#ifdef weak_alias
+#undef index
+weak_alias (strchr, index)
+#endif
diff --git a/sysdeps/alpha/strlen.c b/sysdeps/alpha/strlen.c
new file mode 100644
index 0000000..d774447
--- /dev/null
+++ b/sysdeps/alpha/strlen.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 1992 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
+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. */
+
+#include <string.h>
+
+/* Return the length of the null-terminated string STR. Scan for
+ the null terminator quickly by testing eight bytes at a time. */
+
+size_t
+strlen (const char *str)
+{
+ const char *char_ptr;
+ const unsigned long int *longword_ptr;
+
+ /* Handle the first few characters by reading one character at a time.
+ Do this until STR is aligned on a 8-byte border. */
+ for (char_ptr = str; ((unsigned long int) char_ptr & 7) != 0; ++char_ptr)
+ if (*char_ptr == '\0')
+ return char_ptr - str;
+
+ longword_ptr = (unsigned long int *) char_ptr;
+
+ for (;;)
+ {
+ int mask;
+ asm ("cmpbge %1, %2, %0" : "=r" (mask) : "r" (0), "r" (*longword_ptr++));
+ if (mask)
+ {
+ /* Which of the bytes was the zero? */
+
+ const char *cp = (const char *) (longword_ptr - 1);
+ int i;
+
+ for (i = 0; i < 6; i++)
+ if (cp[i] == 0)
+ return cp - str + i;
+ return cp - str + 7;
+ }
+ }
+}
diff --git a/sysdeps/alpha/udiv_qrnnd.S b/sysdeps/alpha/udiv_qrnnd.S
new file mode 100644
index 0000000..942d7a8
--- /dev/null
+++ b/sysdeps/alpha/udiv_qrnnd.S
@@ -0,0 +1,152 @@
+ # Alpha 21064 __udiv_qrnnd
+
+ # Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+ .set noreorder
+ .set noat
+
+.text
+ .align 3
+ .globl __udiv_qrnnd
+ .ent __udiv_qrnnd 0
+__udiv_qrnnd:
+__udiv_qrnnd..ng:
+ .frame $30,0,$26,0
+ .prologue 0
+#define cnt $2
+#define tmp $3
+#define rem_ptr $16
+#define n1 $17
+#define n0 $18
+#define d $19
+#define qb $20
+
+ ldiq cnt,16
+ blt d,Largedivisor
+
+Loop1: cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ subq cnt,1,cnt
+ bgt cnt,Loop1
+ stq n1,0(rem_ptr)
+ bis $31,n0,$0
+ ret $31,($26),1
+
+Largedivisor:
+ and n0,1,$4
+
+ srl n0,1,n0
+ sll n1,63,tmp
+ or tmp,n0,n0
+ srl n1,1,n1
+
+ and d,1,$6
+ srl d,1,$5
+ addq $5,$6,$5
+
+Loop2: cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ subq cnt,1,cnt
+ bgt cnt,Loop2
+
+ addq n1,n1,n1
+ addq $4,n1,n1
+ bne $6,Odd
+ stq n1,0(rem_ptr)
+ bis $31,n0,$0
+ ret $31,($26),1
+
+Odd:
+ /* q' in n0. r' in n1. */
+ addq n1,n0,n1
+ cmpult n1,n0,tmp # tmp := carry from addq
+ beq tmp,LLp6
+ addq n0,1,n0
+ subq n1,d,n1
+LLp6: cmpult n1,d,tmp
+ bne tmp,LLp7
+ addq n0,1,n0
+ subq n1,d,n1
+LLp7:
+ stq n1,0(rem_ptr)
+ bis $31,n0,$0
+ ret $31,($26),1
+
+ .end __udiv_qrnnd
diff --git a/sysdeps/am29k/ffs.c b/sysdeps/am29k/ffs.c
new file mode 100644
index 0000000..0f38f87
--- /dev/null
+++ b/sysdeps/am29k/ffs.c
@@ -0,0 +1,40 @@
+/* ffs -- find first set bit in a word, counted from least significant end.
+ For Amd 290x0.
+ Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <ansidecl.h>
+#include <bstring.h>
+
+#undef ffs
+
+#ifdef __GNUC__
+
+int
+DEFUN(ffs, (x), int x)
+{
+ int cnt;
+
+ asm ("clz %0,%1" : "=r" (cnt) : "r" (x & -x));
+
+ return 32 - cnt;
+}
+
+#else
+#include <sysdeps/generic/ffs.c>
+#endif
diff --git a/sysdeps/generic/Dist b/sysdeps/generic/Dist
new file mode 100644
index 0000000..2431f7b
--- /dev/null
+++ b/sysdeps/generic/Dist
@@ -0,0 +1,8 @@
+make_siglist.c signame.c signame.h
+det_endian.c
+mathimpl.h
+trig.h
+sincos.c
+asincos.c
+exp__E.c
+log__L.c
diff --git a/sysdeps/generic/Makefile b/sysdeps/generic/Makefile
new file mode 100644
index 0000000..b80b073
--- /dev/null
+++ b/sysdeps/generic/Makefile
@@ -0,0 +1,60 @@
+# Copyright (C) 1992, 1993, 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.
+
+ifeq ($(subdir),math)
+ifndef math-twiddled
+
+elided-routines := $(elided-routines) acos asin cos sin hypot
+sysdep_routines := $(sysdep_routines) sincos asincos exp__E log__L
+
+math-twiddled := t
+endif
+
+endif
+
+ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
+ $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/bytesex.h))))))
+
+$(common-objpfx)bytesex.h: $(common-objpfx)det_endian
+ $(dir $<)$(notdir $<) > $@-tmp
+ mv $@-tmp $@
+
+$(common-objpfx)det_endian: $(sysdep_dir)/generic/det_endian.c
+ $(native-compile)
+
+before-compile := $(before-compile) $(common-objpfx)bytesex.h
+common-generated := $(common-generated) bytesex.h det_endian
+
+endif
+
+ifeq ($(subdir),stdio)
+
+ifeq "$(filter $(objpfx)siglist.c,$(before-compile))" ""
+before-compile := $(before-compile) $(objpfx)siglist.c
+$(objpfx)siglist.c: $(objpfx)make_siglist
+ @rm -f $@
+ $(dir $<)$(notdir $<) > $@-tmp
+ mv $@-tmp $@
+
+$(objpfx)make_siglist: $(sysdep_dir)/generic/make_siglist.c
+ $(native-compile)
+
+generated := $(generated) make_siglist siglist.c
+endif
+
+endif
diff --git a/sysdeps/generic/_strerror.c b/sysdeps/generic/_strerror.c
new file mode 100644
index 0000000..455c8ff
--- /dev/null
+++ b/sysdeps/generic/_strerror.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 19911993 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. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+#include <string.h>
+
+#ifndef HAVE_GNU_LD
+#define _sys_errlist sys_errlist
+#define _sys_nerr sys_nerr
+#endif
+
+/* Return a string describing the errno code in ERRNUM. */
+char *
+DEFUN(_strerror_internal, (errnum, buf), int errnum AND char buf[1024])
+{
+ if (errnum < 0 || errnum > _sys_nerr)
+ {
+ static char fmt[] = "Unknown error %d";
+ size_t len = sprintf (buf, fmt, errnum);
+ if (len < sizeof(fmt) - 2)
+ return NULL;
+ buf[len - 1] = '\0';
+ return buf;
+ }
+
+ return (char *) _sys_errlist[errnum];
+}
diff --git a/sysdeps/generic/abort.c b/sysdeps/generic/abort.c
new file mode 100644
index 0000000..1a27c49
--- /dev/null
+++ b/sysdeps/generic/abort.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+
+/* Cause an abnormal program termination with core-dump. */
+void
+DEFUN_VOID(abort)
+{
+ sigset_t sigs;
+
+ if (__sigemptyset(&sigs) == 0 &&
+ __sigaddset(&sigs, SIGABRT) == 0)
+ (void) __sigprocmask(SIG_UNBLOCK, &sigs, (sigset_t *) NULL);
+
+ while (1)
+ if (raise (SIGABRT))
+ /* If we can't signal ourselves, exit. */
+ _exit (127);
+ /* If we signal ourselves and are still alive,
+ or can't exit, loop forever. */
+}
diff --git a/sysdeps/generic/acos.c b/sysdeps/generic/acos.c
new file mode 100644
index 0000000..c77c9fa
--- /dev/null
+++ b/sysdeps/generic/acos.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the inverse cosine of X. */
+double
+DEFUN(acos, (x), double x)
+{
+ double t;
+
+ if (__isnan(x))
+ {
+ errno = EDOM;
+ return x;
+ }
+
+ if (x == -1.0)
+ /* If X is -1, the general formula blows up (zero divided by zero loses),
+ but we know that acos(-1) = pi. */
+ t = atan2(1.0, 0.0);
+ else
+ t = atan2(sqrt((1.0 - x) / (1.0 + x)), 1.0);
+ return t + t;
+}
diff --git a/sysdeps/generic/acosh.c b/sysdeps/generic/acosh.c
new file mode 100644
index 0000000..bc16cc7
--- /dev/null
+++ b/sysdeps/generic/acosh.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)acosh.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* ACOSH(X)
+ * RETURN THE INVERSE HYPERBOLIC COSINE OF X
+ * DOUBLE PRECISION (VAX D FORMAT 56 BITS, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 2/16/85;
+ * REVISED BY K.C. NG on 3/6/85, 3/24/85, 4/16/85, 8/17/85.
+ *
+ * Required system supported functions :
+ * sqrt(x)
+ *
+ * Required kernel function:
+ * log1p(x) ...return log(1+x)
+ *
+ * Method :
+ * Based on
+ * acosh(x) = log [ x + sqrt(x*x-1) ]
+ * we have
+ * acosh(x) := log1p(x)+ln2, if (x > 1.0E20); else
+ * acosh(x) := log1p( sqrt(x-1) * (sqrt(x-1) + sqrt(x+1)) ) .
+ * These formulae avoid the over/underflow complication.
+ *
+ * Special cases:
+ * acosh(x) is NaN with signal if x<1.
+ * acosh(NaN) is NaN without signal.
+ *
+ * Accuracy:
+ * acosh(x) returns the exact inverse hyperbolic cosine of x nearly
+ * rounded. In a test run with 512,000 random arguments on a VAX, the
+ * maximum observed error was 3.30 ulps (units of the last place) at
+ * x=1.0070493753568216 .
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include "mathimpl.h"
+
+vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000)
+vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC)
+
+ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000)
+ic(ln2lo, 1.9082149292705877000E-10,-33, 1.A39EF35793C76)
+
+#ifdef vccast
+#define ln2hi vccast(ln2hi)
+#define ln2lo vccast(ln2lo)
+#endif
+
+double acosh(x)
+double x;
+{
+ double t,big=1.E20; /* big+1==big */
+
+#if !defined(vax)&&!defined(tahoe)
+ if(x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+
+ /* return log1p(x) + log(2) if x is large */
+ if(x>big) {t=log1p(x)+ln2lo; return(t+ln2hi);}
+
+ t=sqrt(x-1.0);
+ return(log1p(t*(t+sqrt(x+1.0))));
+}
diff --git a/sysdeps/generic/add_1.c b/sysdeps/generic/add_1.c
new file mode 100644
index 0000000..7b1c697
--- /dev/null
+++ b/sysdeps/generic/add_1.c
@@ -0,0 +1,61 @@
+/* mpn_add_1 --
+
+Copyright (C) 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#define __mpn_add_1 __noname
+#include "gmp.h"
+#undef __mpn_add_1
+
+#include "gmp-impl.h"
+
+mp_limb
+__mpn_add_1 (res_ptr, s1_ptr, s1_size, s2_limb)
+ register mp_ptr res_ptr;
+ register mp_srcptr s1_ptr;
+ register mp_size_t s1_size;
+ register mp_limb s2_limb;
+{
+ register mp_limb x;
+
+ x = *s1_ptr++;
+ s2_limb = x + s2_limb;
+ *res_ptr++ = s2_limb;
+ if (s2_limb < x)
+ {
+ while (--s1_size != 0)
+ {
+ x = *s1_ptr++ + 1;
+ *res_ptr++ = x;
+ if (x != 0)
+ goto fin;
+ }
+
+ return 1;
+ }
+
+ fin:
+ if (res_ptr != s1_ptr)
+ {
+ mp_size_t i;
+ for (i = 0; i < s1_size - 1; i++)
+ res_ptr[i] = s1_ptr[i];
+ }
+
+ return 0;
+}
diff --git a/sysdeps/generic/add_n.c b/sysdeps/generic/add_n.c
new file mode 100644
index 0000000..6989ab0
--- /dev/null
+++ b/sysdeps/generic/add_n.c
@@ -0,0 +1,61 @@
+/* __mpn_add_n -- Add two limb vectors of equal, non-zero length.
+
+Copyright (C) 1992, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
+mp_limb
+#if __STDC__
+__mpn_add_n (mp_ptr res_ptr, mp_srcptr s1_ptr, mp_srcptr s2_ptr, mp_size_t size)
+#else
+__mpn_add_n (res_ptr, s1_ptr, s2_ptr, size)
+ register mp_ptr res_ptr;
+ register mp_srcptr s1_ptr;
+ register mp_srcptr s2_ptr;
+ mp_size_t size;
+#endif
+{
+ register mp_limb x, y, cy;
+ register mp_size_t j;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ the loop becomes faster. */
+ j = -size;
+
+ /* Offset the base pointers to compensate for the negative indices. */
+ s1_ptr -= j;
+ s2_ptr -= j;
+ res_ptr -= j;
+
+ cy = 0;
+ do
+ {
+ y = s2_ptr[j];
+ x = s1_ptr[j];
+ y += cy; /* add previous carry to one addend */
+ cy = (y < cy); /* get out carry from that addition */
+ y = x + y; /* add other addend */
+ cy = (y < x) + cy; /* get out carry from that add, combine */
+ res_ptr[j] = y;
+ }
+ while (++j != 0);
+
+ return cy;
+}
diff --git a/sysdeps/generic/addmul_1.c b/sysdeps/generic/addmul_1.c
new file mode 100644
index 0000000..fdf3541
--- /dev/null
+++ b/sysdeps/generic/addmul_1.c
@@ -0,0 +1,64 @@
+/* __mpn_addmul_1 -- multiply the S1_SIZE long limb vector pointed to by S1_PTR
+ by S2_LIMB, add the S1_SIZE least significant limbs of the product to the
+ limb vector pointed to by RES_PTR. Return the most significant limb of
+ the product, adjusted for carry-out from the addition.
+
+Copyright (C) 1992, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include "longlong.h"
+
+mp_limb
+__mpn_addmul_1 (res_ptr, s1_ptr, s1_size, s2_limb)
+ register mp_ptr res_ptr;
+ register mp_srcptr s1_ptr;
+ mp_size_t s1_size;
+ register mp_limb s2_limb;
+{
+ register mp_limb cy_limb;
+ register mp_size_t j;
+ register mp_limb prod_high, prod_low;
+ register mp_limb x;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ the loop becomes faster. */
+ j = -s1_size;
+
+ /* Offset the base pointers to compensate for the negative indices. */
+ res_ptr -= j;
+ s1_ptr -= j;
+
+ cy_limb = 0;
+ do
+ {
+ umul_ppmm (prod_high, prod_low, s1_ptr[j], s2_limb);
+
+ prod_low += cy_limb;
+ cy_limb = (prod_low < cy_limb) + prod_high;
+
+ x = res_ptr[j];
+ prod_low = x + prod_low;
+ cy_limb += (prod_low < x);
+ res_ptr[j] = prod_low;
+ }
+ while (++j != 0);
+
+ return cy_limb;
+}
diff --git a/sysdeps/generic/asin.c b/sysdeps/generic/asin.c
new file mode 100644
index 0000000..e75ee3d
--- /dev/null
+++ b/sysdeps/generic/asin.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the inverse sine of X. */
+double
+DEFUN(asin, (x), double x)
+{
+ double abs_x;
+
+ if (__isnan(x))
+ {
+ errno = EDOM;
+ return x;
+ }
+
+ abs_x = fabs(x);
+
+ if (abs_x <= 0.5)
+ return atan2(x, sqrt(1.0 - (x * x)));
+ else
+ {
+ double t = 1.0 - abs_x;
+ return atan2(x, sqrt((t + t) - (t * t)));
+ }
+}
diff --git a/sysdeps/generic/asincos.c b/sysdeps/generic/asincos.c
new file mode 100644
index 0000000..c746b16
--- /dev/null
+++ b/sysdeps/generic/asincos.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)asincos.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* ASIN(X)
+ * RETURNS ARC SINE OF X
+ * DOUBLE PRECISION (IEEE DOUBLE 53 bits, VAX D FORMAT 56 bits)
+ * CODED IN C BY K.C. NG, 4/16/85, REVISED ON 6/10/85.
+ *
+ * Required system supported functions:
+ * copysign(x,y)
+ * sqrt(x)
+ *
+ * Required kernel function:
+ * atan2(y,x)
+ *
+ * Method :
+ * asin(x) = atan2(x,sqrt(1-x*x)); for better accuracy, 1-x*x is
+ * computed as follows
+ * 1-x*x if x < 0.5,
+ * 2*(1-|x|)-(1-|x|)*(1-|x|) if x >= 0.5.
+ *
+ * Special cases:
+ * if x is NaN, return x itself;
+ * if |x|>1, return NaN.
+ *
+ * Accuracy:
+ * 1) If atan2() uses machine PI, then
+ *
+ * asin(x) returns (PI/pi) * (the exact arc sine of x) nearly rounded;
+ * and PI is the exact pi rounded to machine precision (see atan2 for
+ * details):
+ *
+ * in decimal:
+ * pi = 3.141592653589793 23846264338327 .....
+ * 53 bits PI = 3.141592653589793 115997963 ..... ,
+ * 56 bits PI = 3.141592653589793 227020265 ..... ,
+ *
+ * in hexadecimal:
+ * pi = 3.243F6A8885A308D313198A2E....
+ * 53 bits PI = 3.243F6A8885A30 = 2 * 1.921FB54442D18 error=.276ulps
+ * 56 bits PI = 3.243F6A8885A308 = 4 * .C90FDAA22168C2 error=.206ulps
+ *
+ * In a test run with more than 200,000 random arguments on a VAX, the
+ * maximum observed error in ulps (units in the last place) was
+ * 2.06 ulps. (comparing against (PI/pi)*(exact asin(x)));
+ *
+ * 2) If atan2() uses true pi, then
+ *
+ * asin(x) returns the exact asin(x) with error below about 2 ulps.
+ *
+ * In a test run with more than 1,024,000 random arguments on a VAX, the
+ * maximum observed error in ulps (units in the last place) was
+ * 1.99 ulps.
+ */
+
+double asin(x)
+double x;
+{
+ double s,t,copysign(),atan2(),sqrt(),one=1.0;
+#if !defined(vax)&&!defined(tahoe)
+ if(x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+ s=copysign(x,one);
+ if(s <= 0.5)
+ return(atan2(x,sqrt(one-x*x)));
+ else
+ { t=one-s; s=t+t; return(atan2(x,sqrt(s-t*t))); }
+
+}
+
+/* ACOS(X)
+ * RETURNS ARC COS OF X
+ * DOUBLE PRECISION (IEEE DOUBLE 53 bits, VAX D FORMAT 56 bits)
+ * CODED IN C BY K.C. NG, 4/16/85, REVISED ON 6/10/85.
+ *
+ * Required system supported functions:
+ * copysign(x,y)
+ * sqrt(x)
+ *
+ * Required kernel function:
+ * atan2(y,x)
+ *
+ * Method :
+ * ________
+ * / 1 - x
+ * acos(x) = 2*atan2( / -------- , 1 ) .
+ * \/ 1 + x
+ *
+ * Special cases:
+ * if x is NaN, return x itself;
+ * if |x|>1, return NaN.
+ *
+ * Accuracy:
+ * 1) If atan2() uses machine PI, then
+ *
+ * acos(x) returns (PI/pi) * (the exact arc cosine of x) nearly rounded;
+ * and PI is the exact pi rounded to machine precision (see atan2 for
+ * details):
+ *
+ * in decimal:
+ * pi = 3.141592653589793 23846264338327 .....
+ * 53 bits PI = 3.141592653589793 115997963 ..... ,
+ * 56 bits PI = 3.141592653589793 227020265 ..... ,
+ *
+ * in hexadecimal:
+ * pi = 3.243F6A8885A308D313198A2E....
+ * 53 bits PI = 3.243F6A8885A30 = 2 * 1.921FB54442D18 error=.276ulps
+ * 56 bits PI = 3.243F6A8885A308 = 4 * .C90FDAA22168C2 error=.206ulps
+ *
+ * In a test run with more than 200,000 random arguments on a VAX, the
+ * maximum observed error in ulps (units in the last place) was
+ * 2.07 ulps. (comparing against (PI/pi)*(exact acos(x)));
+ *
+ * 2) If atan2() uses true pi, then
+ *
+ * acos(x) returns the exact acos(x) with error below about 2 ulps.
+ *
+ * In a test run with more than 1,024,000 random arguments on a VAX, the
+ * maximum observed error in ulps (units in the last place) was
+ * 2.15 ulps.
+ */
+
+double acos(x)
+double x;
+{
+ double t,copysign(),atan2(),sqrt(),one=1.0;
+#if !defined(vax)&&!defined(tahoe)
+ if(x!=x) return(x);
+#endif /* !defined(vax)&&!defined(tahoe) */
+ if( x != -1.0)
+ t=atan2(sqrt((one-x)/(one+x)),one);
+ else
+ t=atan2(one,0.0); /* t = PI/2 */
+ return(t+t);
+}
diff --git a/sysdeps/generic/asinh.c b/sysdeps/generic/asinh.c
new file mode 100644
index 0000000..5db8d2d
--- /dev/null
+++ b/sysdeps/generic/asinh.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)asinh.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* ASINH(X)
+ * RETURN THE INVERSE HYPERBOLIC SINE OF X
+ * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 2/16/85;
+ * REVISED BY K.C. NG on 3/7/85, 3/24/85, 4/16/85.
+ *
+ * Required system supported functions :
+ * copysign(x,y)
+ * sqrt(x)
+ *
+ * Required kernel function:
+ * log1p(x) ...return log(1+x)
+ *
+ * Method :
+ * Based on
+ * asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ]
+ * we have
+ * asinh(x) := x if 1+x*x=1,
+ * := sign(x)*(log1p(x)+ln2)) if sqrt(1+x*x)=x, else
+ * := sign(x)*log1p(|x| + |x|/(1/|x| + sqrt(1+(1/|x|)^2)) )
+ *
+ * Accuracy:
+ * asinh(x) returns the exact inverse hyperbolic sine of x nearly rounded.
+ * In a test run with 52,000 random arguments on a VAX, the maximum
+ * observed error was 1.58 ulps (units in the last place).
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+#include "mathimpl.h"
+
+vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000)
+vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC)
+
+ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000)
+ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76)
+
+#ifdef vccast
+#define ln2hi vccast(ln2hi)
+#define ln2lo vccast(ln2lo)
+#endif
+
+double asinh(x)
+double x;
+{
+ double t,s;
+ const static double small=1.0E-10, /* fl(1+small*small) == 1 */
+ big =1.0E20, /* fl(1+big) == big */
+ one =1.0 ;
+
+#if !defined(vax)&&!defined(tahoe)
+ if(x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+ if((t=copysign(x,one))>small)
+ if(t<big) {
+ s=one/t; return(copysign(log1p(t+t/(s+sqrt(one+s*s))),x)); }
+ else /* if |x| > big */
+ {s=log1p(t)+ln2lo; return(copysign(s+ln2hi,x));}
+ else /* if |x| < small */
+ return(x);
+}
diff --git a/sysdeps/generic/atan.c b/sysdeps/generic/atan.c
new file mode 100644
index 0000000..f2cc693
--- /dev/null
+++ b/sysdeps/generic/atan.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+
+/* Return the inverse tangent of X. */
+double
+DEFUN(atan, (x), register double x)
+{
+ return atan2(x, 1.0);
+}
diff --git a/sysdeps/generic/atan2.c b/sysdeps/generic/atan2.c
new file mode 100644
index 0000000..958a154
--- /dev/null
+++ b/sysdeps/generic/atan2.c
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)atan2.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* ATAN2(Y,X)
+ * RETURN ARG (X+iY)
+ * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 1/8/85;
+ * REVISED BY K.C. NG on 2/7/85, 2/13/85, 3/7/85, 3/30/85, 6/29/85.
+ *
+ * Required system supported functions :
+ * copysign(x,y)
+ * scalb(x,y)
+ * logb(x)
+ *
+ * Method :
+ * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
+ * 2. Reduce x to positive by (if x and y are unexceptional):
+ * ARG (x+iy) = arctan(y/x) ... if x > 0,
+ * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0,
+ * 3. According to the integer k=4t+0.25 truncated , t=y/x, the argument
+ * is further reduced to one of the following intervals and the
+ * arctangent of y/x is evaluated by the corresponding formula:
+ *
+ * [0,7/16] atan(y/x) = t - t^3*(a1+t^2*(a2+...(a10+t^2*a11)...)
+ * [7/16,11/16] atan(y/x) = atan(1/2) + atan( (y-x/2)/(x+y/2) )
+ * [11/16.19/16] atan(y/x) = atan( 1 ) + atan( (y-x)/(x+y) )
+ * [19/16,39/16] atan(y/x) = atan(3/2) + atan( (y-1.5x)/(x+1.5y) )
+ * [39/16,INF] atan(y/x) = atan(INF) + atan( -x/y )
+ *
+ * Special cases:
+ * Notations: atan2(y,x) == ARG (x+iy) == ARG(x,y).
+ *
+ * ARG( NAN , (anything) ) is NaN;
+ * ARG( (anything), NaN ) is NaN;
+ * ARG(+(anything but NaN), +-0) is +-0 ;
+ * ARG(-(anything but NaN), +-0) is +-PI ;
+ * ARG( 0, +-(anything but 0 and NaN) ) is +-PI/2;
+ * ARG( +INF,+-(anything but INF and NaN) ) is +-0 ;
+ * ARG( -INF,+-(anything but INF and NaN) ) is +-PI;
+ * ARG( +INF,+-INF ) is +-PI/4 ;
+ * ARG( -INF,+-INF ) is +-3PI/4;
+ * ARG( (anything but,0,NaN, and INF),+-INF ) is +-PI/2;
+ *
+ * Accuracy:
+ * atan2(y,x) returns (PI/pi) * the exact ARG (x+iy) nearly rounded,
+ * where
+ *
+ * in decimal:
+ * pi = 3.141592653589793 23846264338327 .....
+ * 53 bits PI = 3.141592653589793 115997963 ..... ,
+ * 56 bits PI = 3.141592653589793 227020265 ..... ,
+ *
+ * in hexadecimal:
+ * pi = 3.243F6A8885A308D313198A2E....
+ * 53 bits PI = 3.243F6A8885A30 = 2 * 1.921FB54442D18 error=.276ulps
+ * 56 bits PI = 3.243F6A8885A308 = 4 * .C90FDAA22168C2 error=.206ulps
+ *
+ * In a test run with 356,000 random argument on [-1,1] * [-1,1] on a
+ * VAX, the maximum observed error was 1.41 ulps (units of the last place)
+ * compared with (PI/pi)*(the exact ARG(x+iy)).
+ *
+ * Note:
+ * We use machine PI (the true pi rounded) in place of the actual
+ * value of pi for all the trig and inverse trig functions. In general,
+ * if trig is one of sin, cos, tan, then computed trig(y) returns the
+ * exact trig(y*pi/PI) nearly rounded; correspondingly, computed arctrig
+ * returns the exact arctrig(y)*PI/pi nearly rounded. These guarantee the
+ * trig functions have period PI, and trig(arctrig(x)) returns x for
+ * all critical values x.
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include "mathimpl.h"
+
+vc(athfhi, 4.6364760900080611433E-1 ,6338,3fed,da7b,2b0d, -1, .ED63382B0DDA7B)
+vc(athflo, 1.9338828231967579916E-19 ,5005,2164,92c0,9cfe, -62, .E450059CFE92C0)
+vc(PIo4, 7.8539816339744830676E-1 ,0fda,4049,68c2,a221, 0, .C90FDAA22168C2)
+vc(at1fhi, 9.8279372324732906796E-1 ,985e,407b,b4d9,940f, 0, .FB985E940FB4D9)
+vc(at1flo,-3.5540295636764633916E-18 ,1edc,a383,eaea,34d6, -57,-.831EDC34D6EAEA)
+vc(PIo2, 1.5707963267948966135E0 ,0fda,40c9,68c2,a221, 1, .C90FDAA22168C2)
+vc(PI, 3.1415926535897932270E0 ,0fda,4149,68c2,a221, 2, .C90FDAA22168C2)
+vc(a1, 3.3333333333333473730E-1 ,aaaa,3faa,ab75,aaaa, -1, .AAAAAAAAAAAB75)
+vc(a2, -2.0000000000017730678E-1 ,cccc,bf4c,946e,cccd, -2,-.CCCCCCCCCD946E)
+vc(a3, 1.4285714286694640301E-1 ,4924,3f12,4262,9274, -2, .92492492744262)
+vc(a4, -1.1111111135032672795E-1 ,8e38,bee3,6292,ebc6, -3,-.E38E38EBC66292)
+vc(a5, 9.0909091380563043783E-2 ,2e8b,3eba,d70c,b31b, -3, .BA2E8BB31BD70C)
+vc(a6, -7.6922954286089459397E-2 ,89c8,be9d,7f18,27c3, -3,-.9D89C827C37F18)
+vc(a7, 6.6663180891693915586E-2 ,86b4,3e88,9e58,ae37, -3, .8886B4AE379E58)
+vc(a8, -5.8772703698290408927E-2 ,bba5,be70,a942,8481, -4,-.F0BBA58481A942)
+vc(a9, 5.2170707402812969804E-2 ,b0f3,3e55,13ab,a1ab, -4, .D5B0F3A1AB13AB)
+vc(a10, -4.4895863157820361210E-2 ,e4b9,be37,048f,7fd1, -4,-.B7E4B97FD1048F)
+vc(a11, 3.3006147437343875094E-2 ,3174,3e07,2d87,3cf7, -4, .8731743CF72D87)
+vc(a12, -1.4614844866464185439E-2 ,731a,bd6f,76d9,2f34, -6,-.EF731A2F3476D9)
+
+ic(athfhi, 4.6364760900080609352E-1 , -2, 1.DAC670561BB4F)
+ic(athflo, 4.6249969567426939759E-18 , -58, 1.5543B8F253271)
+ic(PIo4, 7.8539816339744827900E-1 , -1, 1.921FB54442D18)
+ic(at1fhi, 9.8279372324732905408E-1 , -1, 1.F730BD281F69B)
+ic(at1flo,-2.4407677060164810007E-17 , -56, -1.C23DFEFEAE6B5)
+ic(PIo2, 1.5707963267948965580E0 , 0, 1.921FB54442D18)
+ic(PI, 3.1415926535897931160E0 , 1, 1.921FB54442D18)
+ic(a1, 3.3333333333333942106E-1 , -2, 1.55555555555C3)
+ic(a2, -1.9999999999979536924E-1 , -3, -1.9999999997CCD)
+ic(a3, 1.4285714278004377209E-1 , -3, 1.24924921EC1D7)
+ic(a4, -1.1111110579344973814E-1 , -4, -1.C71C7059AF280)
+ic(a5, 9.0908906105474668324E-2 , -4, 1.745CE5AA35DB2)
+ic(a6, -7.6919217767468239799E-2 , -4, -1.3B0FA54BEC400)
+ic(a7, 6.6614695906082474486E-2 , -4, 1.10DA924597FFF)
+ic(a8, -5.8358371008508623523E-2 , -5, -1.DE125FDDBD793)
+ic(a9, 4.9850617156082015213E-2 , -5, 1.9860524BDD807)
+ic(a10, -3.6700606902093604877E-2 , -5, -1.2CA6C04C6937A)
+ic(a11, 1.6438029044759730479E-2 , -6, 1.0D52174A1BB54)
+
+#ifdef vccast
+#define athfhi vccast(athfhi)
+#define athflo vccast(athflo)
+#define PIo4 vccast(PIo4)
+#define at1fhi vccast(at1fhi)
+#define at1flo vccast(at1flo)
+#define PIo2 vccast(PIo2)
+#define PI vccast(PI)
+#define a1 vccast(a1)
+#define a2 vccast(a2)
+#define a3 vccast(a3)
+#define a4 vccast(a4)
+#define a5 vccast(a5)
+#define a6 vccast(a6)
+#define a7 vccast(a7)
+#define a8 vccast(a8)
+#define a9 vccast(a9)
+#define a10 vccast(a10)
+#define a11 vccast(a11)
+#define a12 vccast(a12)
+#endif
+
+double atan2(y,x)
+double y,x;
+{
+ static const double zero=0, one=1, small=1.0E-9, big=1.0E18;
+ double t,z,signy,signx,hi,lo;
+ int k,m;
+
+#if !defined(vax)&&!defined(tahoe)
+ /* if x or y is NAN */
+ if(x!=x) return(x); if(y!=y) return(y);
+#endif /* !defined(vax)&&!defined(tahoe) */
+
+ /* copy down the sign of y and x */
+ signy = copysign(one,y) ;
+ signx = copysign(one,x) ;
+
+ /* if x is 1.0, goto begin */
+ if(x==1) { y=copysign(y,one); t=y; if(finite(t)) goto begin;}
+
+ /* when y = 0 */
+ if(y==zero) return((signx==one)?y:copysign(PI,signy));
+
+ /* when x = 0 */
+ if(x==zero) return(copysign(PIo2,signy));
+
+ /* when x is INF */
+ if(!finite(x))
+ if(!finite(y))
+ return(copysign((signx==one)?PIo4:3*PIo4,signy));
+ else
+ return(copysign((signx==one)?zero:PI,signy));
+
+ /* when y is INF */
+ if(!finite(y)) return(copysign(PIo2,signy));
+
+ /* compute y/x */
+ x=copysign(x,one);
+ y=copysign(y,one);
+ if((m=(k=logb(y))-logb(x)) > 60) t=big+big;
+ else if(m < -80 ) t=y/x;
+ else { t = y/x ; y = scalb(y,-k); x=scalb(x,-k); }
+
+ /* begin argument reduction */
+begin:
+ if (t < 2.4375) {
+
+ /* truncate 4(t+1/16) to integer for branching */
+ k = 4 * (t+0.0625);
+ switch (k) {
+
+ /* t is in [0,7/16] */
+ case 0:
+ case 1:
+ if (t < small)
+ { big + small ; /* raise inexact flag */
+ return (copysign((signx>zero)?t:PI-t,signy)); }
+
+ hi = zero; lo = zero; break;
+
+ /* t is in [7/16,11/16] */
+ case 2:
+ hi = athfhi; lo = athflo;
+ z = x+x;
+ t = ( (y+y) - x ) / ( z + y ); break;
+
+ /* t is in [11/16,19/16] */
+ case 3:
+ case 4:
+ hi = PIo4; lo = zero;
+ t = ( y - x ) / ( x + y ); break;
+
+ /* t is in [19/16,39/16] */
+ default:
+ hi = at1fhi; lo = at1flo;
+ z = y-x; y=y+y+y; t = x+x;
+ t = ( (z+z)-x ) / ( t + y ); break;
+ }
+ }
+ /* end of if (t < 2.4375) */
+
+ else
+ {
+ hi = PIo2; lo = zero;
+
+ /* t is in [2.4375, big] */
+ if (t <= big) t = - x / y;
+
+ /* t is in [big, INF] */
+ else
+ { big+small; /* raise inexact flag */
+ t = zero; }
+ }
+ /* end of argument reduction */
+
+ /* compute atan(t) for t in [-.4375, .4375] */
+ z = t*t;
+#if defined(vax)||defined(tahoe)
+ z = t*(z*(a1+z*(a2+z*(a3+z*(a4+z*(a5+z*(a6+z*(a7+z*(a8+
+ z*(a9+z*(a10+z*(a11+z*a12))))))))))));
+#else /* defined(vax)||defined(tahoe) */
+ z = t*(z*(a1+z*(a2+z*(a3+z*(a4+z*(a5+z*(a6+z*(a7+z*(a8+
+ z*(a9+z*(a10+z*a11)))))))))));
+#endif /* defined(vax)||defined(tahoe) */
+ z = lo - z; z += t; z += hi;
+
+ return(copysign((signx>zero)?z:PI-z,signy));
+}
diff --git a/sysdeps/generic/atanh.c b/sysdeps/generic/atanh.c
new file mode 100644
index 0000000..89cb61c
--- /dev/null
+++ b/sysdeps/generic/atanh.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)atanh.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* ATANH(X)
+ * RETURN THE HYPERBOLIC ARC TANGENT OF X
+ * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 1/8/85;
+ * REVISED BY K.C. NG on 2/7/85, 3/7/85, 8/18/85.
+ *
+ * Required kernel function:
+ * log1p(x) ...return log(1+x)
+ *
+ * Method :
+ * Return
+ * 1 2x x
+ * atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------)
+ * 2 1 - x 1 - x
+ *
+ * Special cases:
+ * atanh(x) is NaN if |x| > 1 with signal;
+ * atanh(NaN) is that NaN with no signal;
+ * atanh(+-1) is +-INF with signal.
+ *
+ * Accuracy:
+ * atanh(x) returns the exact hyperbolic arc tangent of x nearly rounded.
+ * In a test run with 512,000 random arguments on a VAX, the maximum
+ * observed error was 1.87 ulps (units in the last place) at
+ * x= -3.8962076028810414000e-03.
+ */
+#include "mathimpl.h"
+
+#if defined(vax)||defined(tahoe)
+#include <errno.h>
+#endif /* defined(vax)||defined(tahoe) */
+
+double atanh(x)
+double x;
+{
+ double z;
+ z = copysign(0.5,x);
+ x = copysign(x,1.0);
+#if defined(vax)||defined(tahoe)
+ if (x == 1.0) {
+ return(copysign(1.0,z)*infnan(ERANGE)); /* sign(x)*INF */
+ }
+#endif /* defined(vax)||defined(tahoe) */
+ x = x/(1.0-x);
+ return( z*log1p(x+x) );
+}
diff --git a/sysdeps/generic/bcopy.c b/sysdeps/generic/bcopy.c
new file mode 100644
index 0000000..51de492
--- /dev/null
+++ b/sysdeps/generic/bcopy.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+
+
+#define memmove bcopy
+#define rettype void
+#define RETURN(s) return
+#define a1 src
+#define a1const CONST
+#define a2 dest
+#define a2const
+
+#include <memmove.c>
diff --git a/sysdeps/generic/bzero.c b/sysdeps/generic/bzero.c
new file mode 100644
index 0000000..7ebdcfe
--- /dev/null
+++ b/sysdeps/generic/bzero.c
@@ -0,0 +1,81 @@
+/* Copyright (C) 1991 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <memcopy.h>
+
+/* Set N bytes of S to 0. */
+void
+DEFUN(bzero, (s, n), PTR s AND size_t len)
+{
+ long int dstp = (long int) s;
+ CONST op_t zero = 0;
+
+ if (len >= 8)
+ {
+ size_t xlen;
+
+ /* There are at least some bytes to zero. No need to test
+ for LEN == 0 in this alignment loop. */
+ while (dstp % OPSIZ != 0)
+ {
+ ((byte *) dstp)[0] = 0;
+ dstp += 1;
+ len -= 1;
+ }
+
+ /* Write 8 op_t per iteration until less than 8 op_t remain. */
+ xlen = len / (OPSIZ * 8);
+ while (xlen != 0)
+ {
+ ((op_t *) dstp)[0] = zero;
+ ((op_t *) dstp)[1] = zero;
+ ((op_t *) dstp)[2] = zero;
+ ((op_t *) dstp)[3] = zero;
+ ((op_t *) dstp)[4] = zero;
+ ((op_t *) dstp)[5] = zero;
+ ((op_t *) dstp)[6] = zero;
+ ((op_t *) dstp)[7] = zero;
+ dstp += 8 * OPSIZ;
+ xlen -= 1;
+ }
+ len %= OPSIZ * 8;
+
+ /* Write 1 op_t per iteration until less than op_t remain. */
+ xlen = len / OPSIZ;
+ while (xlen != 0)
+ {
+ ((op_t *) dstp)[0] = zero;
+ dstp += OPSIZ;
+ xlen -= 1;
+ }
+ len %= OPSIZ;
+ }
+
+ /* Write the last few bytes. */
+ while (len != 0)
+ {
+ ((byte *) dstp)[0] = 0;
+ dstp += 1;
+ len -= 1;
+ }
+}
+
diff --git a/sysdeps/generic/cabs.c b/sysdeps/generic/cabs.c
new file mode 100644
index 0000000..6f4e1cd
--- /dev/null
+++ b/sysdeps/generic/cabs.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 1992, 1993 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+
+double
+DEFUN(cabs, (z), struct __cabs_complex z)
+{
+ return hypot (z.__x, z.__y);
+}
diff --git a/sysdeps/generic/ceil.c b/sysdeps/generic/ceil.c
new file mode 100644
index 0000000..6b7fad3
--- /dev/null
+++ b/sysdeps/generic/ceil.c
@@ -0,0 +1,68 @@
+/* snarfed from BSD common_source/floor.c:
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)floor.c 5.7 (Berkeley) 10/9/90";
+#endif /* not lint */
+
+#include "mathimpl.h"
+
+vc(L, 4503599627370496.0E0 ,0000,5c00,0000,0000, 55, 1.0) /* 2**55 */
+
+ic(L, 4503599627370496.0E0, 52, 1.0) /* 2**52 */
+
+#ifdef vccast
+#define L vccast(L)
+#endif
+
+double
+ceil(x)
+double x;
+{
+ double y;
+
+ if (
+#if !defined(vax)&&!defined(tahoe)
+ x != x || /* NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+ x >= L) /* already an even integer */
+ return x;
+ else if (x < (double)0)
+ return -floor(-x);
+ else { /* now 0 <= x < L */
+ y = L+x; /* destructive store must be forced */
+ y -= L; /* an integer, and |x-y| < 1 */
+ return x > y ? y+(double)1 : y;
+ }
+}
+
diff --git a/sysdeps/generic/cmp.c b/sysdeps/generic/cmp.c
new file mode 100644
index 0000000..144c885
--- /dev/null
+++ b/sysdeps/generic/cmp.c
@@ -0,0 +1,55 @@
+/* __mpn_cmp -- Compare two low-level natural-number integers.
+
+Copyright (C) 1991, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
+/* Compare OP1_PTR/OP1_SIZE with OP2_PTR/OP2_SIZE.
+ There are no restrictions on the relative sizes of
+ the two arguments.
+ Return 1 if OP1 > OP2, 0 if they are equal, and -1 if OP1 < OP2. */
+
+int
+#if __STDC__
+__mpn_cmp (mp_srcptr op1_ptr, mp_srcptr op2_ptr, mp_size_t size)
+#else
+__mpn_cmp (op1_ptr, op2_ptr, size)
+ mp_srcptr op1_ptr;
+ mp_srcptr op2_ptr;
+ mp_size_t size;
+#endif
+{
+ mp_size_t i;
+ mp_limb op1_word, op2_word;
+
+ for (i = size - 1; i >= 0; i--)
+ {
+ op1_word = op1_ptr[i];
+ op2_word = op2_ptr[i];
+ if (op1_word != op2_word)
+ goto diff;
+ }
+ return 0;
+ diff:
+ /* This can *not* be simplified to
+ op2_word - op2_word
+ since that expression might give signed overflow. */
+ return (op1_word > op2_word) ? 1 : -1;
+}
diff --git a/sysdeps/generic/configure b/sysdeps/generic/configure
new file mode 100755
index 0000000..c89b679
--- /dev/null
+++ b/sysdeps/generic/configure
@@ -0,0 +1,52 @@
+# This file is generated from configure.in by Autoconf. DO NOT EDIT!
+
+
+if [ ! "$inhibit_glue" ]; then
+
+# For signame.c, used in make_siglist.
+for ac_func in psignal
+do
+ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'`
+echo "checking for ${ac_func}" 1>&4
+if eval "test \"`echo '${'ac_cv_func_${ac_func}'+set}'`\" = set"; then
+ echo " using cached value for ac_cv_func_${ac_func}" 1>&5
+else
+ cat > conftest.${ac_ext} <<EOF
+#include "confdefs.h"
+#include <ctype.h>
+int main() { return 0; }
+int t() {
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_${ac_func}) || defined (__stub___${ac_func})
+choke me
+#else
+/* Override any gcc2 internal prototype to avoid an error. */
+extern char ${ac_func}(); ${ac_func}();
+#endif
+; return 0; }
+EOF
+if eval $ac_compile; then
+ rm -rf conftest*
+ eval "ac_cv_func_${ac_func}=yes"
+else
+ rm -rf conftest*
+ eval "ac_cv_func_${ac_func}=no"
+fi
+rm -f conftest*
+
+fi
+if eval "test \"`echo '$ac_cv_func_'${ac_func}`\" = yes"; then
+
+{
+test "$verbose" = yes && \
+echo " defining ${ac_tr_func}"
+echo "#define" ${ac_tr_func} "1" >> confdefs.h
+DEFS="$DEFS -D${ac_tr_func}=1"
+}
+
+fi
+done
+
+fi
diff --git a/sysdeps/generic/configure.in b/sysdeps/generic/configure.in
new file mode 100644
index 0000000..50209f3
--- /dev/null
+++ b/sysdeps/generic/configure.in
@@ -0,0 +1,7 @@
+sinclude(./aclocal.m4)dnl
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+
+if test -z "$inhibit_glue"; then
+# For signame.c, used in make_siglist.
+AC_CHECK_FUNCS(psignal)
+fi
diff --git a/sysdeps/generic/confname.h b/sysdeps/generic/confname.h
new file mode 100644
index 0000000..3a0305a
--- /dev/null
+++ b/sysdeps/generic/confname.h
@@ -0,0 +1,76 @@
+/* `sysconf', `pathconf', and `confstr' NAME values. Generic version.
+Copyright (C) 1993 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. */
+
+/* Values for the NAME argument to `pathconf' and `fpathconf'. */
+enum
+ {
+ _PC_LINK_MAX,
+ _PC_MAX_CANON,
+ _PC_MAX_INPUT,
+ _PC_NAME_MAX,
+ _PC_PATH_MAX,
+ _PC_PIPE_BUF,
+ _PC_CHOWN_RESTRICTED,
+ _PC_NO_TRUNC,
+ _PC_VDISABLE
+ };
+
+/* Values for the argument to `sysconf'. */
+enum
+ {
+ _SC_ARG_MAX,
+ _SC_CHILD_MAX,
+ _SC_CLK_TCK,
+ _SC_NGROUPS_MAX,
+ _SC_OPEN_MAX,
+ _SC_STREAM_MAX,
+ _SC_TZNAME_MAX,
+ _SC_JOB_CONTROL,
+ _SC_SAVED_IDS,
+ _SC_VERSION,
+ _SC_PAGESIZE,
+
+ /* Values for the argument to `sysconf'
+ corresponding to _POSIX2_* symbols. */
+ _SC_BC_BASE_MAX,
+ _SC_BC_DIM_MAX,
+ _SC_BC_SCALE_MAX,
+ _SC_BC_STRING_MAX,
+ _SC_COLL_WEIGHTS_MAX,
+ _SC_EQUIV_CLASS_MAX,
+ _SC_EXPR_NEST_MAX,
+ _SC_LINE_MAX,
+ _SC_RE_DUP_MAX,
+
+ _SC_2_VERSION,
+ _SC_2_C_BIND,
+ _SC_2_C_DEV,
+ _SC_2_FORT_DEV,
+ _SC_2_FORT_RUN,
+ _SC_2_SW_DEV,
+ _SC_2_LOCALEDEF
+ };
+
+#ifdef __USE_POSIX2
+/* Values for the NAME argument to `confstr'. */
+enum
+ {
+ _CS_PATH /* The default search path. */
+ };
+#endif
diff --git a/sysdeps/generic/copysign.c b/sysdeps/generic/copysign.c
new file mode 100644
index 0000000..0bd3ed9
--- /dev/null
+++ b/sysdeps/generic/copysign.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+
+/* Return X with its signed changed to Y's. */
+double
+DEFUN(__copysign, (x, y), double x AND double y)
+{
+ x = fabs (x);
+ return y < 0 ? - x : x;
+}
+
+weak_alias (__copysign, copysign)
diff --git a/sysdeps/generic/cosh.c b/sysdeps/generic/cosh.c
new file mode 100644
index 0000000..e2b3073
--- /dev/null
+++ b/sysdeps/generic/cosh.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)cosh.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* COSH(X)
+ * RETURN THE HYPERBOLIC COSINE OF X
+ * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 1/8/85;
+ * REVISED BY K.C. NG on 2/8/85, 2/23/85, 3/7/85, 3/29/85, 4/16/85.
+ *
+ * Required system supported functions :
+ * copysign(x,y)
+ * scalb(x,N)
+ *
+ * Required kernel function:
+ * exp(x)
+ * exp__E(x,c) ...return exp(x+c)-1-x for |x|<0.3465
+ *
+ * Method :
+ * 1. Replace x by |x|.
+ * 2.
+ * [ exp(x) - 1 ]^2
+ * 0 <= x <= 0.3465 : cosh(x) := 1 + -------------------
+ * 2*exp(x)
+ *
+ * exp(x) + 1/exp(x)
+ * 0.3465 <= x <= 22 : cosh(x) := -------------------
+ * 2
+ * 22 <= x <= lnovfl : cosh(x) := exp(x)/2
+ * lnovfl <= x <= lnovfl+log(2)
+ * : cosh(x) := exp(x)/2 (avoid overflow)
+ * log(2)+lnovfl < x < INF: overflow to INF
+ *
+ * Note: .3465 is a number near one half of ln2.
+ *
+ * Special cases:
+ * cosh(x) is x if x is +INF, -INF, or NaN.
+ * only cosh(0)=1 is exact for finite x.
+ *
+ * Accuracy:
+ * cosh(x) returns the exact hyperbolic cosine of x nearly rounded.
+ * In a test run with 768,000 random arguments on a VAX, the maximum
+ * observed error was 1.23 ulps (units in the last place).
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include "mathimpl.h"
+
+vc(mln2hi, 8.8029691931113054792E1 ,0f33,43b0,2bdb,c7e2, 7, .B00F33C7E22BDB)
+vc(mln2lo,-4.9650192275318476525E-16 ,1b60,a70f,582a,279e, -50,-.8F1B60279E582A)
+vc(lnovfl, 8.8029691931113053016E1 ,0f33,43b0,2bda,c7e2, 7, .B00F33C7E22BDA)
+
+ic(mln2hi, 7.0978271289338397310E2, 10, 1.62E42FEFA39EF)
+ic(mln2lo, 2.3747039373786107478E-14, -45, 1.ABC9E3B39803F)
+ic(lnovfl, 7.0978271289338397310E2, 9, 1.62E42FEFA39EF)
+
+#ifdef vccast
+#define mln2hi vccast(mln2hi)
+#define mln2lo vccast(mln2lo)
+#define lnovfl vccast(lnovfl)
+#endif
+
+#if defined(vax)||defined(tahoe)
+static max = 126 ;
+#else /* defined(vax)||defined(tahoe) */
+static max = 1023 ;
+#endif /* defined(vax)||defined(tahoe) */
+
+double cosh(x)
+double x;
+{
+ static const double half=1.0/2.0,
+ one=1.0, small=1.0E-18; /* fl(1+small)==1 */
+ double t;
+
+#if !defined(vax)&&!defined(tahoe)
+ if(x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+ if((x=copysign(x,one)) <= 22)
+ if(x<0.3465)
+ if(x<small) return(one+x);
+ else {t=x+__exp__E(x,0.0);x=t+t; return(one+t*t/(2.0+x)); }
+
+ else /* for x lies in [0.3465,22] */
+ { t=exp(x); return((t+one/t)*half); }
+
+ if( lnovfl <= x && x <= (lnovfl+0.7))
+ /* for x lies in [lnovfl, lnovfl+ln2], decrease x by ln(2^(max+1))
+ * and return 2^max*exp(x) to avoid unnecessary overflow
+ */
+ return(scalb(exp((x-mln2hi)-mln2lo), max));
+
+ else
+ return(exp(x)*half); /* for large x, cosh(x)=exp(x)/2 */
+}
diff --git a/sysdeps/generic/det_endian.c b/sysdeps/generic/det_endian.c
new file mode 100644
index 0000000..50b5bdc
--- /dev/null
+++ b/sysdeps/generic/det_endian.c
@@ -0,0 +1,34 @@
+/* Determine the "endianness" of the CPU.
+ Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <stdio.h>
+
+main ()
+{
+ unsigned long int i;
+
+ if (sizeof (i) != 4)
+ puts ("#error \"Not a 32-bit machine!\"");
+
+ i = (((((('4' << 8) + '3') << 8) + '2') << 8) + '1');
+
+ printf ("#define __BYTE_ORDER %.4s\n", (char *) &i);
+
+ exit (0);
+}
diff --git a/sysdeps/generic/divmod.c b/sysdeps/generic/divmod.c
new file mode 100644
index 0000000..76b9bca
--- /dev/null
+++ b/sysdeps/generic/divmod.c
@@ -0,0 +1,234 @@
+/* __mpn_divmod -- Divide natural numbers, producing both remainder and
+ quotient.
+
+Copyright (C) 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include "longlong.h"
+
+/* Divide num (NUM_PTR/NUM_SIZE) by den (DEN_PTR/DEN_SIZE) and write
+ the NUM_SIZE-DEN_SIZE least significant quotient limbs at QUOT_PTR
+ and the DEN_SIZE long remainder at NUM_PTR.
+ Return the most significant limb of the quotient, this is always 0 or 1.
+
+ Argument constraints:
+ 1. The most significant bit of the divisor must be set.
+ 2. QUOT_PTR must either not overlap with the input operands at all, or
+ QUOT_PTR + DEN_SIZE >= NUM_PTR must hold true. (This means that it's
+ possible to put the quotient in the high part of NUM, right after the
+ remainder in NUM. */
+
+mp_limb
+#if __STDC__
+__mpn_divmod (mp_ptr quot_ptr,
+ mp_ptr num_ptr, mp_size_t num_size,
+ mp_srcptr den_ptr, mp_size_t den_size)
+#else
+__mpn_divmod (quot_ptr, num_ptr, num_size, den_ptr, den_size)
+ mp_ptr quot_ptr;
+ mp_ptr num_ptr;
+ mp_size_t num_size;
+ mp_srcptr den_ptr;
+ mp_size_t den_size;
+#endif
+{
+ mp_limb most_significant_q_limb = 0;
+
+ switch (den_size)
+ {
+ case 0:
+ /* We are asked to divide by zero, so go ahead and do it! (To make
+ the compiler not remove this statement, return the value.) */
+ return 1 / den_size;
+
+ case 1:
+ {
+ mp_size_t i;
+ mp_limb n1, n0;
+ mp_limb d;
+
+ d = den_ptr[0];
+ n1 = num_ptr[num_size - 1];
+
+ if (n1 >= d)
+ {
+ most_significant_q_limb = 1;
+ n1 -= d;
+ }
+
+ for (i = num_size - 2; i >= 0; i--)
+ {
+ n0 = num_ptr[i];
+ udiv_qrnnd (quot_ptr[i], n1, n1, n0, d);
+ }
+
+ num_ptr[0] = n1;
+ }
+ break;
+
+ case 2:
+ {
+ mp_size_t i;
+ mp_limb n1, n0, n2;
+ mp_limb d1, d0;
+
+ num_ptr += num_size - 2;
+ d1 = den_ptr[1];
+ d0 = den_ptr[0];
+ n1 = num_ptr[1];
+ n0 = num_ptr[0];
+
+ if (n1 >= d1 && (n1 > d1 || n0 >= d0))
+ {
+ most_significant_q_limb = 1;
+ sub_ddmmss (n1, n0, n1, n0, d1, d0);
+ }
+
+ for (i = num_size - den_size - 1; i >= 0; i--)
+ {
+ mp_limb q;
+ mp_limb r;
+
+ num_ptr--;
+ if (n1 == d1)
+ {
+ /* Q should be either 111..111 or 111..110. Need special
+ treatment of this rare case as normal division would
+ give overflow. */
+ q = ~(mp_limb) 0;
+
+ r = n0 + d1;
+ if (r < d1) /* Carry in the addition? */
+ {
+ add_ssaaaa (n1, n0, r - d0, num_ptr[0], 0, d0);
+ quot_ptr[i] = q;
+ continue;
+ }
+ n1 = d0 - (d0 != 0);
+ n0 = -d0;
+ }
+ else
+ {
+ udiv_qrnnd (q, r, n1, n0, d1);
+ umul_ppmm (n1, n0, d0, q);
+ }
+
+ n2 = num_ptr[0];
+ q_test:
+ if (n1 > r || (n1 == r && n0 > n2))
+ {
+ /* The estimated Q was too large. */
+ q--;
+
+ sub_ddmmss (n1, n0, n1, n0, 0, d0);
+ r += d1;
+ if (r >= d1) /* If not carry, test Q again. */
+ goto q_test;
+ }
+
+ quot_ptr[i] = q;
+ sub_ddmmss (n1, n0, r, n2, n1, n0);
+ }
+ num_ptr[1] = n1;
+ num_ptr[0] = n0;
+ }
+ break;
+
+ default:
+ {
+ mp_size_t i;
+ mp_limb dX, d1, n0;
+
+ num_ptr += num_size;
+ den_ptr += den_size;
+ dX = den_ptr[-1];
+ d1 = den_ptr[-2];
+ n0 = num_ptr[-1];
+
+ if (n0 >= dX)
+ {
+ if (n0 > dX
+ || __mpn_cmp (num_ptr - den_size, den_ptr - den_size,
+ den_size - 1) >= 0)
+ {
+ __mpn_sub_n (num_ptr - den_size,
+ num_ptr - den_size, den_ptr - den_size,
+ den_size);
+ most_significant_q_limb = 1;
+ }
+
+ n0 = num_ptr[-1];
+ }
+
+ for (i = num_size - den_size - 1; i >= 0; i--)
+ {
+ mp_limb q;
+ mp_limb n1;
+ mp_limb cy_limb;
+
+ num_ptr--;
+ if (n0 == dX)
+ /* This might over-estimate q, but it's probably not worth
+ the extra code here to find out. */
+ q = ~(mp_limb) 0;
+ else
+ {
+ mp_limb r;
+
+ udiv_qrnnd (q, r, n0, num_ptr[-1], dX);
+ umul_ppmm (n1, n0, d1, q);
+
+ while (n1 > r || (n1 == r && n0 > num_ptr[-2]))
+ {
+ q--;
+ r += dX;
+ if (r < dX) /* I.e. "carry in previous addition?" */
+ break;
+ n1 -= n0 < d1;
+ n0 -= d1;
+ }
+ }
+
+ /* Possible optimization: We already have (q * n0) and (1 * n1)
+ after the calculation of q. Taking advantage of that, we
+ could make this loop make two iterations less. */
+
+ cy_limb = __mpn_submul_1 (num_ptr - den_size,
+ den_ptr - den_size, den_size, q);
+
+ if (num_ptr[0] != cy_limb)
+ {
+ mp_limb cy;
+ cy = __mpn_add_n (num_ptr - den_size,
+ num_ptr - den_size,
+ den_ptr - den_size, den_size);
+ if (cy == 0)
+ abort ();
+ q--;
+ }
+
+ quot_ptr[i] = q;
+ n0 = num_ptr[-1];
+ }
+ }
+ }
+
+ return most_significant_q_limb;
+}
diff --git a/sysdeps/generic/divmod_1.c b/sysdeps/generic/divmod_1.c
new file mode 100644
index 0000000..d156eeb
--- /dev/null
+++ b/sysdeps/generic/divmod_1.c
@@ -0,0 +1,209 @@
+/* __mpn_divmod_1(quot_ptr, dividend_ptr, dividend_size, divisor_limb) --
+ Divide (DIVIDEND_PTR,,DIVIDEND_SIZE) by DIVISOR_LIMB.
+ Write DIVIDEND_SIZE limbs of quotient at QUOT_PTR.
+ Return the single-limb remainder.
+ There are no constraints on the value of the divisor.
+
+ QUOT_PTR and DIVIDEND_PTR might point to the same limb.
+
+Copyright (C) 1991, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include "longlong.h"
+
+#ifndef UMUL_TIME
+#define UMUL_TIME 1
+#endif
+
+#ifndef UDIV_TIME
+#define UDIV_TIME UMUL_TIME
+#endif
+
+/* FIXME: We should be using invert_limb (or invert_normalized_limb)
+ here (not udiv_qrnnd). */
+
+mp_limb
+#if __STDC__
+__mpn_divmod_1 (mp_ptr quot_ptr,
+ mp_srcptr dividend_ptr, mp_size_t dividend_size,
+ mp_limb divisor_limb)
+#else
+__mpn_divmod_1 (quot_ptr, dividend_ptr, dividend_size, divisor_limb)
+ mp_ptr quot_ptr;
+ mp_srcptr dividend_ptr;
+ mp_size_t dividend_size;
+ mp_limb divisor_limb;
+#endif
+{
+ mp_size_t i;
+ mp_limb n1, n0, r;
+ int dummy;
+
+ /* ??? Should this be handled at all? Rely on callers? */
+ if (dividend_size == 0)
+ return 0;
+
+ /* If multiplication is much faster than division, and the
+ dividend is large, pre-invert the divisor, and use
+ only multiplications in the inner loop. */
+
+ /* This test should be read:
+ Does it ever help to use udiv_qrnnd_preinv?
+ && Does what we save compensate for the inversion overhead? */
+ if (UDIV_TIME > (2 * UMUL_TIME + 6)
+ && (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME)
+ {
+ int normalization_steps;
+
+ count_leading_zeros (normalization_steps, divisor_limb);
+ if (normalization_steps != 0)
+ {
+ mp_limb divisor_limb_inverted;
+
+ divisor_limb <<= normalization_steps;
+
+ /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The
+ result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+ most significant bit (with weight 2**N) implicit. */
+
+#if 0 /* This can't happen when normalization_steps != 0 */
+ /* Special case for DIVISOR_LIMB == 100...000. */
+ if (divisor_limb << 1 == 0)
+ divisor_limb_inverted = ~(mp_limb) 0;
+ else
+#endif
+ udiv_qrnnd (divisor_limb_inverted, dummy,
+ -divisor_limb, 0, divisor_limb);
+
+ n1 = dividend_ptr[dividend_size - 1];
+ r = n1 >> (BITS_PER_MP_LIMB - normalization_steps);
+
+ /* Possible optimization:
+ if (r == 0
+ && divisor_limb > ((n1 << normalization_steps)
+ | (dividend_ptr[dividend_size - 2] >> ...)))
+ ...one division less... */
+
+ for (i = dividend_size - 2; i >= 0; i--)
+ {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd_preinv (quot_ptr[i + 1], r, r,
+ ((n1 << normalization_steps)
+ | (n0 >> (BITS_PER_MP_LIMB - normalization_steps))),
+ divisor_limb, divisor_limb_inverted);
+ n1 = n0;
+ }
+ udiv_qrnnd_preinv (quot_ptr[0], r, r,
+ n1 << normalization_steps,
+ divisor_limb, divisor_limb_inverted);
+ return r >> normalization_steps;
+ }
+ else
+ {
+ mp_limb divisor_limb_inverted;
+
+ /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The
+ result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+ most significant bit (with weight 2**N) implicit. */
+
+ /* Special case for DIVISOR_LIMB == 100...000. */
+ if (divisor_limb << 1 == 0)
+ divisor_limb_inverted = ~(mp_limb) 0;
+ else
+ udiv_qrnnd (divisor_limb_inverted, dummy,
+ -divisor_limb, 0, divisor_limb);
+
+ i = dividend_size - 1;
+ r = dividend_ptr[i];
+
+ if (r >= divisor_limb)
+ r = 0;
+ else
+ {
+ quot_ptr[i] = 0;
+ i--;
+ }
+
+ for (; i >= 0; i--)
+ {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd_preinv (quot_ptr[i], r, r,
+ n0, divisor_limb, divisor_limb_inverted);
+ }
+ return r;
+ }
+ }
+ else
+ {
+ if (UDIV_NEEDS_NORMALIZATION)
+ {
+ int normalization_steps;
+
+ count_leading_zeros (normalization_steps, divisor_limb);
+ if (normalization_steps != 0)
+ {
+ divisor_limb <<= normalization_steps;
+
+ n1 = dividend_ptr[dividend_size - 1];
+ r = n1 >> (BITS_PER_MP_LIMB - normalization_steps);
+
+ /* Possible optimization:
+ if (r == 0
+ && divisor_limb > ((n1 << normalization_steps)
+ | (dividend_ptr[dividend_size - 2] >> ...)))
+ ...one division less... */
+
+ for (i = dividend_size - 2; i >= 0; i--)
+ {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd (quot_ptr[i + 1], r, r,
+ ((n1 << normalization_steps)
+ | (n0 >> (BITS_PER_MP_LIMB - normalization_steps))),
+ divisor_limb);
+ n1 = n0;
+ }
+ udiv_qrnnd (quot_ptr[0], r, r,
+ n1 << normalization_steps,
+ divisor_limb);
+ return r >> normalization_steps;
+ }
+ }
+ /* No normalization needed, either because udiv_qrnnd doesn't require
+ it, or because DIVISOR_LIMB is already normalized. */
+
+ i = dividend_size - 1;
+ r = dividend_ptr[i];
+
+ if (r >= divisor_limb)
+ r = 0;
+ else
+ {
+ quot_ptr[i] = 0;
+ i--;
+ }
+
+ for (; i >= 0; i--)
+ {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd (quot_ptr[i], r, r, n0, divisor_limb);
+ }
+ return r;
+ }
+}
diff --git a/sysdeps/generic/exp.c b/sysdeps/generic/exp.c
new file mode 100644
index 0000000..9b4f045
--- /dev/null
+++ b/sysdeps/generic/exp.c
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)exp.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* EXP(X)
+ * RETURN THE EXPONENTIAL OF X
+ * DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS)
+ * CODED IN C BY K.C. NG, 1/19/85;
+ * REVISED BY K.C. NG on 2/6/85, 2/15/85, 3/7/85, 3/24/85, 4/16/85, 6/14/86.
+ *
+ * Required system supported functions:
+ * scalb(x,n)
+ * copysign(x,y)
+ * finite(x)
+ *
+ * Method:
+ * 1. Argument Reduction: given the input x, find r and integer k such
+ * that
+ * x = k*ln2 + r, |r| <= 0.5*ln2 .
+ * r will be represented as r := z+c for better accuracy.
+ *
+ * 2. Compute exp(r) by
+ *
+ * exp(r) = 1 + r + r*R1/(2-R1),
+ * where
+ * R1 = x - x^2*(p1+x^2*(p2+x^2*(p3+x^2*(p4+p5*x^2)))).
+ *
+ * 3. exp(x) = 2^k * exp(r) .
+ *
+ * Special cases:
+ * exp(INF) is INF, exp(NaN) is NaN;
+ * exp(-INF)= 0;
+ * for finite argument, only exp(0)=1 is exact.
+ *
+ * Accuracy:
+ * exp(x) returns the exponential of x nearly rounded. In a test run
+ * with 1,156,000 random arguments on a VAX, the maximum observed
+ * error was 0.869 ulps (units in the last place).
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include "mathimpl.h"
+
+vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000)
+vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC)
+vc(lnhuge, 9.4961163736712506989E1 ,ec1d,43bd,9010,a73e, 7, .BDEC1DA73E9010)
+vc(lntiny,-9.5654310917272452386E1 ,4f01,c3bf,33af,d72e, 7,-.BF4F01D72E33AF)
+vc(invln2, 1.4426950408889634148E0 ,aa3b,40b8,17f1,295c, 1, .B8AA3B295C17F1)
+vc(p1, 1.6666666666666602251E-1 ,aaaa,3f2a,a9f1,aaaa, -2, .AAAAAAAAAAA9F1)
+vc(p2, -2.7777777777015591216E-3 ,0b60,bc36,ec94,b5f5, -8,-.B60B60B5F5EC94)
+vc(p3, 6.6137563214379341918E-5 ,b355,398a,f15f,792e, -13, .8AB355792EF15F)
+vc(p4, -1.6533902205465250480E-6 ,ea0e,b6dd,5f84,2e93, -19,-.DDEA0E2E935F84)
+vc(p5, 4.1381367970572387085E-8 ,bb4b,3431,2683,95f5, -24, .B1BB4B95F52683)
+
+#ifdef vccast
+#define ln2hi vccast(ln2hi)
+#define ln2lo vccast(ln2lo)
+#define lnhuge vccast(lnhuge)
+#define lntiny vccast(lntiny)
+#define invln2 vccast(invln2)
+#define p1 vccast(p1)
+#define p2 vccast(p2)
+#define p3 vccast(p3)
+#define p4 vccast(p4)
+#define p5 vccast(p5)
+#endif
+
+ic(p1, 1.6666666666666601904E-1, -3, 1.555555555553E)
+ic(p2, -2.7777777777015593384E-3, -9, -1.6C16C16BEBD93)
+ic(p3, 6.6137563214379343612E-5, -14, 1.1566AAF25DE2C)
+ic(p4, -1.6533902205465251539E-6, -20, -1.BBD41C5D26BF1)
+ic(p5, 4.1381367970572384604E-8, -25, 1.6376972BEA4D0)
+ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000)
+ic(ln2lo, 1.9082149292705877000E-10,-33, 1.A39EF35793C76)
+ic(lnhuge, 7.1602103751842355450E2, 9, 1.6602B15B7ECF2)
+ic(lntiny,-7.5137154372698068983E2, 9, -1.77AF8EBEAE354)
+ic(invln2, 1.4426950408889633870E0, 0, 1.71547652B82FE)
+
+double exp(x)
+double x;
+{
+ double z,hi,lo,c;
+ int k;
+
+#if !defined(vax)&&!defined(tahoe)
+ if(x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+ if( x <= lnhuge ) {
+ if( x >= lntiny ) {
+
+ /* argument reduction : x --> x - k*ln2 */
+
+ k=invln2*x+copysign(0.5,x); /* k=NINT(x/ln2) */
+
+ /* express x-k*ln2 as hi-lo and let x=hi-lo rounded */
+
+ hi=x-k*ln2hi;
+ x=hi-(lo=k*ln2lo);
+
+ /* return 2^k*[1+x+x*c/(2+c)] */
+ z=x*x;
+ c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5))));
+ return scalb(1.0+(hi-(lo-(x*c)/(2.0-c))),k);
+
+ }
+ /* end of x > lntiny */
+
+ else
+ /* exp(-big#) underflows to zero */
+ if(finite(x)) return(scalb(1.0,-5000));
+
+ /* exp(-INF) is zero */
+ else return(0.0);
+ }
+ /* end of x < lnhuge */
+
+ else
+ /* exp(INF) is INF, exp(+big#) overflows to INF */
+ return( finite(x) ? scalb(1.0,5000) : x);
+}
+
+/* returns exp(r = x + c) for |c| < |x| with no overlap. */
+
+double __exp__D(x, c)
+double x, c;
+{
+ double z,hi,lo, t;
+ int k;
+
+#if !defined(vax)&&!defined(tahoe)
+ if (x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+ if ( x <= lnhuge ) {
+ if ( x >= lntiny ) {
+
+ /* argument reduction : x --> x - k*ln2 */
+ z = invln2*x;
+ k = z + copysign(.5, x);
+
+ /* express (x+c)-k*ln2 as hi-lo and let x=hi-lo rounded */
+
+ hi=(x-k*ln2hi); /* Exact. */
+ x= hi - (lo = k*ln2lo-c);
+ /* return 2^k*[1+x+x*c/(2+c)] */
+ z=x*x;
+ c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5))));
+ c = (x*c)/(2.0-c);
+
+ return scalb(1.+(hi-(lo - c)), k);
+ }
+ /* end of x > lntiny */
+
+ else
+ /* exp(-big#) underflows to zero */
+ if(finite(x)) return(scalb(1.0,-5000));
+
+ /* exp(-INF) is zero */
+ else return(0.0);
+ }
+ /* end of x < lnhuge */
+
+ else
+ /* exp(INF) is INF, exp(+big#) overflows to INF */
+ return( finite(x) ? scalb(1.0,5000) : x);
+}
diff --git a/sysdeps/generic/exp__E.c b/sysdeps/generic/exp__E.c
new file mode 100644
index 0000000..ab97247
--- /dev/null
+++ b/sysdeps/generic/exp__E.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)exp__E.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* exp__E(x,c)
+ * ASSUMPTION: c << x SO THAT fl(x+c)=x.
+ * (c is the correction term for x)
+ * exp__E RETURNS
+ *
+ * / exp(x+c) - 1 - x , 1E-19 < |x| < .3465736
+ * exp__E(x,c) = |
+ * \ 0 , |x| < 1E-19.
+ *
+ * DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS)
+ * KERNEL FUNCTION OF EXP, EXPM1, POW FUNCTIONS
+ * CODED IN C BY K.C. NG, 1/31/85;
+ * REVISED BY K.C. NG on 3/16/85, 4/16/85.
+ *
+ * Required system supported function:
+ * copysign(x,y)
+ *
+ * Method:
+ * 1. Rational approximation. Let r=x+c.
+ * Based on
+ * 2 * sinh(r/2)
+ * exp(r) - 1 = ---------------------- ,
+ * cosh(r/2) - sinh(r/2)
+ * exp__E(r) is computed using
+ * x*x (x/2)*W - ( Q - ( 2*P + x*P ) )
+ * --- + (c + x*[---------------------------------- + c ])
+ * 2 1 - W
+ * where P := p1*x^2 + p2*x^4,
+ * Q := q1*x^2 + q2*x^4 (for 56 bits precision, add q3*x^6)
+ * W := x/2-(Q-x*P),
+ *
+ * (See the listing below for the values of p1,p2,q1,q2,q3. The poly-
+ * nomials P and Q may be regarded as the approximations to sinh
+ * and cosh :
+ * sinh(r/2) = r/2 + r * P , cosh(r/2) = 1 + Q . )
+ *
+ * The coefficients were obtained by a special Remez algorithm.
+ *
+ * Approximation error:
+ *
+ * | exp(x) - 1 | 2**(-57), (IEEE double)
+ * | ------------ - (exp__E(x,0)+x)/x | <=
+ * | x | 2**(-69). (VAX D)
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include "mathimpl.h"
+
+vc(p1, 1.5150724356786683059E-2 ,3abe,3d78,066a,67e1, -6, .F83ABE67E1066A)
+vc(p2, 6.3112487873718332688E-5 ,5b42,3984,0173,48cd, -13, .845B4248CD0173)
+vc(q1, 1.1363478204690669916E-1 ,b95a,3ee8,ec45,44a2, -3, .E8B95A44A2EC45)
+vc(q2, 1.2624568129896839182E-3 ,7905,3ba5,f5e7,72e4, -9, .A5790572E4F5E7)
+vc(q3, 1.5021856115869022674E-6 ,9eb4,36c9,c395,604a, -19, .C99EB4604AC395)
+
+ic(p1, 1.3887401997267371720E-2, -7, 1.C70FF8B3CC2CF)
+ic(p2, 3.3044019718331897649E-5, -15, 1.15317DF4526C4)
+ic(q1, 1.1110813732786649355E-1, -4, 1.C719538248597)
+ic(q2, 9.9176615021572857300E-4, -10, 1.03FC4CB8C98E8)
+
+#ifdef vccast
+#define p1 vccast(p1)
+#define p2 vccast(p2)
+#define q1 vccast(q1)
+#define q2 vccast(q2)
+#define q3 vccast(q3)
+#endif
+
+double __exp__E(x,c)
+double x,c;
+{
+ const static double zero=0.0, one=1.0, half=1.0/2.0, small=1.0E-19;
+ double z,p,q,xp,xh,w;
+ if(copysign(x,one)>small) {
+ z = x*x ;
+ p = z*( p1 +z* p2 );
+#if defined(vax)||defined(tahoe)
+ q = z*( q1 +z*( q2 +z* q3 ));
+#else /* defined(vax)||defined(tahoe) */
+ q = z*( q1 +z* q2 );
+#endif /* defined(vax)||defined(tahoe) */
+ xp= x*p ;
+ xh= x*half ;
+ w = xh-(q-xp) ;
+ p = p+p;
+ c += x*((xh*w-(q-(p+xp)))/(one-w)+c);
+ return(z*half+c);
+ }
+ /* end of |x| > small */
+
+ else {
+ if(x!=zero) one+small; /* raise the inexact flag */
+ return(copysign(zero,x));
+ }
+}
diff --git a/sysdeps/generic/expm1.c b/sysdeps/generic/expm1.c
new file mode 100644
index 0000000..a738d12
--- /dev/null
+++ b/sysdeps/generic/expm1.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)expm1.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* EXPM1(X)
+ * RETURN THE EXPONENTIAL OF X MINUS ONE
+ * DOUBLE PRECISION (IEEE 53 BITS, VAX D FORMAT 56 BITS)
+ * CODED IN C BY K.C. NG, 1/19/85;
+ * REVISED BY K.C. NG on 2/6/85, 3/7/85, 3/21/85, 4/16/85.
+ *
+ * Required system supported functions:
+ * scalb(x,n)
+ * copysign(x,y)
+ * finite(x)
+ *
+ * Kernel function:
+ * exp__E(x,c)
+ *
+ * Method:
+ * 1. Argument Reduction: given the input x, find r and integer k such
+ * that
+ * x = k*ln2 + r, |r| <= 0.5*ln2 .
+ * r will be represented as r := z+c for better accuracy.
+ *
+ * 2. Compute EXPM1(r)=exp(r)-1 by
+ *
+ * EXPM1(r=z+c) := z + exp__E(z,c)
+ *
+ * 3. EXPM1(x) = 2^k * ( EXPM1(r) + 1-2^-k ).
+ *
+ * Remarks:
+ * 1. When k=1 and z < -0.25, we use the following formula for
+ * better accuracy:
+ * EXPM1(x) = 2 * ( (z+0.5) + exp__E(z,c) )
+ * 2. To avoid rounding error in 1-2^-k where k is large, we use
+ * EXPM1(x) = 2^k * { [z+(exp__E(z,c)-2^-k )] + 1 }
+ * when k>56.
+ *
+ * Special cases:
+ * EXPM1(INF) is INF, EXPM1(NaN) is NaN;
+ * EXPM1(-INF)= -1;
+ * for finite argument, only EXPM1(0)=0 is exact.
+ *
+ * Accuracy:
+ * EXPM1(x) returns the exact (exp(x)-1) nearly rounded. In a test run with
+ * 1,166,000 random arguments on a VAX, the maximum observed error was
+ * .872 ulps (units of the last place).
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include "mathimpl.h"
+
+vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000)
+vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC)
+vc(lnhuge, 9.4961163736712506989E1 ,ec1d,43bd,9010,a73e, 7, .BDEC1DA73E9010)
+vc(invln2, 1.4426950408889634148E0 ,aa3b,40b8,17f1,295c, 1, .B8AA3B295C17F1)
+
+ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000)
+ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76)
+ic(lnhuge, 7.1602103751842355450E2, 9, 1.6602B15B7ECF2)
+ic(invln2, 1.4426950408889633870E0, 0, 1.71547652B82FE)
+
+#ifdef vccast
+#define ln2hi vccast(ln2hi)
+#define ln2lo vccast(ln2lo)
+#define lnhuge vccast(lnhuge)
+#define invln2 vccast(invln2)
+#endif
+
+double expm1(x)
+double x;
+{
+ const static double one=1.0, half=1.0/2.0;
+ double z,hi,lo,c;
+ int k;
+#if defined(vax)||defined(tahoe)
+ static prec=56;
+#else /* defined(vax)||defined(tahoe) */
+ static prec=53;
+#endif /* defined(vax)||defined(tahoe) */
+
+#if !defined(vax)&&!defined(tahoe)
+ if(x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+
+ if( x <= lnhuge ) {
+ if( x >= -40.0 ) {
+
+ /* argument reduction : x - k*ln2 */
+ k= invln2 *x+copysign(0.5,x); /* k=NINT(x/ln2) */
+ hi=x-k*ln2hi ;
+ z=hi-(lo=k*ln2lo);
+ c=(hi-z)-lo;
+
+ if(k==0) return(z+__exp__E(z,c));
+ if(k==1)
+ if(z< -0.25)
+ {x=z+half;x +=__exp__E(z,c); return(x+x);}
+ else
+ {z+=__exp__E(z,c); x=half+z; return(x+x);}
+ /* end of k=1 */
+
+ else {
+ if(k<=prec)
+ { x=one-scalb(one,-k); z += __exp__E(z,c);}
+ else if(k<100)
+ { x = __exp__E(z,c)-scalb(one,-k); x+=z; z=one;}
+ else
+ { x = __exp__E(z,c)+z; z=one;}
+
+ return (scalb(x+z,k));
+ }
+ }
+ /* end of x > lnunfl */
+
+ else
+ /* expm1(-big#) rounded to -1 (inexact) */
+ if(finite(x))
+ { ln2hi+ln2lo; return(-one);}
+
+ /* expm1(-INF) is -1 */
+ else return(-one);
+ }
+ /* end of x < lnhuge */
+
+ else
+ /* expm1(INF) is INF, expm1(+big#) overflows to INF */
+ return( finite(x) ? scalb(one,5000) : x);
+}
+
+weak_alias (__expm1, expm1)
diff --git a/sysdeps/generic/fabs.c b/sysdeps/generic/fabs.c
new file mode 100644
index 0000000..cf8fa18
--- /dev/null
+++ b/sysdeps/generic/fabs.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+
+/* Return the absolute value of X. */
+double
+DEFUN(fabs, (x), register double x)
+{
+ return x < 0.0 ? -x : x;
+}
diff --git a/sysdeps/generic/ffs.c b/sysdeps/generic/ffs.c
new file mode 100644
index 0000000..016f033
--- /dev/null
+++ b/sysdeps/generic/ffs.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <ansidecl.h>
+#include <limits.h>
+#include <string.h>
+
+#undef ffs
+
+
+/* Find the first bit set in I. */
+int
+DEFUN(ffs, (i), int i)
+{
+ static CONST unsigned char table[] =
+ {
+ 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
+ };
+ unsigned long int a;
+ unsigned long int x = i & -i;
+
+ a = x <= 0xffff ? (x <= 0xff ? 0 : 8) : (x <= 0xffffff ? 16 : 24);
+
+ return table[x >> a] + a;
+}
diff --git a/sysdeps/generic/floor.c b/sysdeps/generic/floor.c
new file mode 100644
index 0000000..a57d79a
--- /dev/null
+++ b/sysdeps/generic/floor.c
@@ -0,0 +1,74 @@
+/* snarfed from BSD common_source/floor.c:
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)floor.c 5.7 (Berkeley) 10/9/90";
+#endif /* not lint */
+
+#include "mathimpl.h"
+
+vc(L, 4503599627370496.0E0 ,0000,5c00,0000,0000, 55, 1.0) /* 2**55 */
+
+ic(L, 4503599627370496.0E0, 52, 1.0) /* 2**52 */
+
+#ifdef vccast
+#define L vccast(L)
+#endif
+
+/*
+ * floor(x) := the largest integer no larger than x;
+ * ceil(x) := -floor(-x), for all real x.
+ *
+ * Note: Inexact will be signaled if x is not an integer, as is
+ * customary for IEEE 754. No other signal can be emitted.
+ */
+double
+floor(x)
+double x;
+{
+ double y;
+
+ if (
+#if !defined(vax)&&!defined(tahoe)
+ x != x || /* NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+ x >= L) /* already an even integer */
+ return x;
+ else if (x < (double)0)
+ return -ceil(-x);
+ else { /* now 0 <= x < L */
+ y = L+x; /* destructive store must be forced */
+ y -= L; /* an integer, and |x-y| < 1 */
+ return x < y ? y-(double)1 : y;
+ }
+}
diff --git a/sysdeps/generic/fmod.c b/sysdeps/generic/fmod.c
new file mode 100644
index 0000000..09a31b2
--- /dev/null
+++ b/sysdeps/generic/fmod.c
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)fmod.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* fmod.c
+ *
+ * SYNOPSIS
+ *
+ * #include <math.h>
+ * double fmod(double x, double y)
+ *
+ * DESCRIPTION
+ *
+ * The fmod function computes the floating-point remainder of x/y.
+ *
+ * RETURNS
+ *
+ * The fmod function returns the value x-i*y, for some integer i
+ * such that, if y is nonzero, the result has the same sign as x and
+ * magnitude less than the magnitude of y.
+ *
+ * On a VAX or CCI,
+ *
+ * fmod(x,0) traps/faults on floating-point divided-by-zero.
+ *
+ * On IEEE-754 conforming machines with "isnan()" primitive,
+ *
+ * fmod(x,0), fmod(INF,y) are invalid operations and NaN is returned.
+ *
+ */
+#if !defined(vax) && !defined(tahoe)
+extern int isnan(),finite();
+#endif /* !defined(vax) && !defined(tahoe) */
+extern double frexp(),ldexp(),fabs();
+
+#ifdef TEST_FMOD
+static double
+_fmod(x,y)
+#else /* TEST_FMOD */
+double
+fmod(x,y)
+#endif /* TEST_FMOD */
+double x,y;
+{
+ int ir,iy;
+ double r,w;
+
+ if (y == (double)0
+#if !defined(vax) && !defined(tahoe) /* per "fmod" manual entry, SunOS 4.0 */
+ || isnan(y) || !finite(x)
+#endif /* !defined(vax) && !defined(tahoe) */
+ )
+ return (x*y)/(x*y);
+
+ r = fabs(x);
+ y = fabs(y);
+ (void)frexp(y,&iy);
+ while (r >= y) {
+ (void)frexp(r,&ir);
+ w = ldexp(y,ir-iy);
+ r -= w <= r ? w : w*(double)0.5;
+ }
+ return x >= (double)0 ? r : -r;
+}
+
+#ifdef TEST_FMOD
+extern long random();
+extern double fmod();
+
+#define NTEST 10000
+#define NCASES 3
+
+static int nfail = 0;
+
+static void
+doit(x,y)
+double x,y;
+{
+ double ro = fmod(x,y),rn = _fmod(x,y);
+ if (ro != rn) {
+ (void)printf(" x = 0x%08.8x %08.8x (%24.16e)\n",x,x);
+ (void)printf(" y = 0x%08.8x %08.8x (%24.16e)\n",y,y);
+ (void)printf(" fmod = 0x%08.8x %08.8x (%24.16e)\n",ro,ro);
+ (void)printf("_fmod = 0x%08.8x %08.8x (%24.16e)\n",rn,rn);
+ (void)printf("\n");
+ }
+}
+
+main()
+{
+ register int i,cases;
+ double x,y;
+
+ srandom(12345);
+ for (i = 0; i < NTEST; i++) {
+ x = (double)random();
+ y = (double)random();
+ for (cases = 0; cases < NCASES; cases++) {
+ switch (cases) {
+ case 0:
+ break;
+ case 1:
+ y = (double)1/y; break;
+ case 2:
+ x = (double)1/x; break;
+ default:
+ abort(); break;
+ }
+ doit(x,y);
+ doit(x,-y);
+ doit(-x,y);
+ doit(-x,-y);
+ }
+ }
+ if (nfail)
+ (void)printf("Number of failures: %d (out of a total of %d)\n",
+ nfail,NTEST*NCASES*4);
+ else
+ (void)printf("No discrepancies were found\n");
+ exit(0);
+}
+#endif /* TEST_FMOD */
diff --git a/sysdeps/generic/frexp.c b/sysdeps/generic/frexp.c
new file mode 100644
index 0000000..b2705bd
--- /dev/null
+++ b/sysdeps/generic/frexp.c
@@ -0,0 +1,53 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Break VALUE into a normalized fraction and an integral power of 2. */
+double
+DEFUN(frexp, (value, exp), double value AND int *exp)
+{
+#ifdef NAN
+ if (__isinf (value))
+ {
+ errno = EDOM;
+ *exp = 0;
+ return __copysign (NAN, value);
+ }
+#endif
+
+ if (__isnan (value))
+ {
+ errno = EDOM;
+ *exp = 0;
+ return value;
+ }
+
+ if (value == 0)
+ {
+ *exp = 0;
+ return value;
+ }
+
+ /* Add one to the exponent of the number,
+ so we have one digit before the binary point. */
+ *exp = (int) __logb (value) + 1;
+ return ldexp (value, - *exp);
+}
diff --git a/sysdeps/generic/ftime.c b/sysdeps/generic/ftime.c
new file mode 100644
index 0000000..76e9276
--- /dev/null
+++ b/sysdeps/generic/ftime.c
@@ -0,0 +1,44 @@
+/* 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. */
+
+#include <sys/timeb.h>
+#include <sys/time.h>
+#include <errno.h>
+
+int
+ftime (timebuf)
+ struct timeb *timebuf;
+{
+ int save = errno;
+ struct tm *tp;
+
+ errno = 0;
+ if (time (&timebuf->time) == (time_t) -1 && errno != 0)
+ return -1;
+ timebuf->millitm = 0;
+
+ tp = localtime (&timebuf->time);
+ if (tp == NULL)
+ return -1;
+
+ timebuf->timezone = tp->tm_gmtoff / 60;
+ timebuf->dstflag = tp->tm_isdst;
+
+ errno = save;
+ return 0;
+}
diff --git a/sysdeps/generic/get_str.c b/sysdeps/generic/get_str.c
new file mode 100644
index 0000000..182815e
--- /dev/null
+++ b/sysdeps/generic/get_str.c
@@ -0,0 +1,213 @@
+/* __mpn_get_str -- Convert a MSIZE long limb vector pointed to by MPTR
+ to a printable string in STR in base BASE.
+
+Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+
+
+This file is part of the GNU C Library. Its master source is NOT part of
+the C library, however. This file is in fact copied from the GNU MP
+Library and its source lives there.
+
+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. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
+/* Convert the limb vector pointed to by MPTR and MSIZE long to a
+ char array, using base BASE for the result array. Store the
+ result in the character array STR. STR must point to an array with
+ space for the largest possible number represented by a MSIZE long
+ limb vector + 1 extra character.
+
+ The result is NOT in Ascii, to convert it to printable format, add
+ '0' or 'A' depending on the base and range.
+
+ Return the number of digits in the result string.
+ This may include some leading zeros.
+
+ The limb vector pointed to by MPTR is clobbered. */
+
+size_t
+__mpn_get_str (str, base, mptr, msize)
+ unsigned char *str;
+ int base;
+ mp_ptr mptr;
+ mp_size_t msize;
+{
+ mp_limb big_base;
+#if UDIV_NEEDS_NORMALIZATION || UDIV_TIME > 2 * UMUL_TIME
+ int normalization_steps;
+#endif
+#if UDIV_TIME > 2 * UMUL_TIME
+ mp_limb big_base_inverted;
+#endif
+ unsigned int dig_per_u;
+ mp_size_t out_len;
+ register unsigned char *s;
+
+ big_base = __mp_bases[base].big_base;
+
+ s = str;
+
+ /* Special case zero, as the code below doesn't handle it. */
+ if (msize == 0)
+ {
+ s[0] = 0;
+ return 1;
+ }
+
+ if ((base & (base - 1)) == 0)
+ {
+ /* The base is a power of 2. Make conversion from most
+ significant side. */
+ mp_limb n1, n0;
+ register int bits_per_digit = big_base;
+ register int x;
+ register int bit_pos;
+ register int i;
+
+ n1 = mptr[msize - 1];
+ count_leading_zeros (x, n1);
+
+ /* BIT_POS should be R when input ends in least sign. nibble,
+ R + bits_per_digit * n when input ends in n:th least significant
+ nibble. */
+
+ {
+ int bits;
+
+ bits = BITS_PER_MP_LIMB * msize - x;
+ x = bits % bits_per_digit;
+ if (x != 0)
+ bits += bits_per_digit - x;
+ bit_pos = bits - (msize - 1) * BITS_PER_MP_LIMB;
+ }
+
+ /* Fast loop for bit output. */
+ i = msize - 1;
+ for (;;)
+ {
+ bit_pos -= bits_per_digit;
+ while (bit_pos >= 0)
+ {
+ *s++ = (n1 >> bit_pos) & ((1 << bits_per_digit) - 1);
+ bit_pos -= bits_per_digit;
+ }
+ i--;
+ if (i < 0)
+ break;
+ n0 = (n1 << -bit_pos) & ((1 << bits_per_digit) - 1);
+ n1 = mptr[i];
+ bit_pos += BITS_PER_MP_LIMB;
+ *s++ = n0 | (n1 >> bit_pos);
+ }
+
+ *s = 0;
+
+ return s - str;
+ }
+ else
+ {
+ /* General case. The base is not a power of 2. Make conversion
+ from least significant end. */
+
+ /* If udiv_qrnnd only handles divisors with the most significant bit
+ set, prepare BIG_BASE for being a divisor by shifting it to the
+ left exactly enough to set the most significant bit. */
+#if UDIV_NEEDS_NORMALIZATION || UDIV_TIME > 2 * UMUL_TIME
+ count_leading_zeros (normalization_steps, big_base);
+ big_base <<= normalization_steps;
+#if UDIV_TIME > 2 * UMUL_TIME
+ /* Get the fixed-point approximation to 1/(BIG_BASE << NORMALIZATION_STEPS). */
+ big_base_inverted = __mp_bases[base].big_base_inverted;
+#endif
+#endif
+
+ dig_per_u = __mp_bases[base].chars_per_limb;
+ out_len = ((size_t) msize * BITS_PER_MP_LIMB
+ * __mp_bases[base].chars_per_bit_exactly) + 1;
+ s += out_len;
+
+ while (msize != 0)
+ {
+ int i;
+ mp_limb n0, n1;
+
+#if UDIV_NEEDS_NORMALIZATION || UDIV_TIME > 2 * UMUL_TIME
+ /* If we shifted BIG_BASE above, shift the dividend too, to get
+ the right quotient. We need to do this every loop,
+ since the intermediate quotients are OK, but the quotient from
+ one turn in the loop is going to be the dividend in the
+ next turn, and the dividend needs to be up-shifted. */
+ if (normalization_steps != 0)
+ {
+ n0 = __mpn_lshift (mptr, mptr, msize, normalization_steps);
+
+ /* If the shifting gave a carry out limb, store it and
+ increase the length. */
+ if (n0 != 0)
+ {
+ mptr[msize] = n0;
+ msize++;
+ }
+ }
+#endif
+
+ /* Divide the number at TP with BIG_BASE to get a quotient and a
+ remainder. The remainder is our new digit in base BIG_BASE. */
+ i = msize - 1;
+ n1 = mptr[i];
+
+ if (n1 >= big_base)
+ n1 = 0;
+ else
+ {
+ msize--;
+ i--;
+ }
+
+ for (; i >= 0; i--)
+ {
+ n0 = mptr[i];
+#if UDIV_TIME > 2 * UMUL_TIME
+ udiv_qrnnd_preinv (mptr[i], n1, n1, n0, big_base, big_base_inverted);
+#else
+ udiv_qrnnd (mptr[i], n1, n1, n0, big_base);
+#endif
+ }
+
+#if UDIV_NEEDS_NORMALIZATION || UDIV_TIME > 2 * UMUL_TIME
+ /* If we shifted above (at previous UDIV_NEEDS_NORMALIZATION tests)
+ the remainder will be up-shifted here. Compensate. */
+ n1 >>= normalization_steps;
+#endif
+
+ /* Convert N1 from BIG_BASE to a string of digits in BASE
+ using single precision operations. */
+ for (i = dig_per_u - 1; i >= 0; i--)
+ {
+ *--s = n1 % base;
+ n1 /= base;
+ if (n1 == 0 && msize == 0)
+ break;
+ }
+ }
+
+ while (s != str)
+ *--s = 0;
+ return out_len;
+ }
+}
diff --git a/sysdeps/generic/getenv.c b/sysdeps/generic/getenv.c
new file mode 100644
index 0000000..d4099a9
--- /dev/null
+++ b/sysdeps/generic/getenv.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifndef HAVE_GNU_LD
+#define __environ environ
+#endif
+
+/* Return the value of the environment variable NAME. */
+char *
+DEFUN(getenv, (name), register CONST char *name)
+{
+ register CONST size_t len = strlen(name);
+ register char **ep;
+
+ if (__environ == NULL)
+ return NULL;
+
+ for (ep = __environ; *ep != NULL; ++ep)
+ if (!strncmp(*ep, name, len) && (*ep)[len] == '=')
+ return &(*ep)[len + 1];
+
+ return NULL;
+}
diff --git a/sysdeps/generic/getpgrp.c b/sysdeps/generic/getpgrp.c
new file mode 100644
index 0000000..d745b0f
--- /dev/null
+++ b/sysdeps/generic/getpgrp.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Get the process group ID of the calling process. */
+int
+DEFUN_VOID(getpgrp)
+{
+ return __getpgid (0);
+}
diff --git a/sysdeps/generic/gmp-mparam.h b/sysdeps/generic/gmp-mparam.h
new file mode 100644
index 0000000..4286ebf
--- /dev/null
+++ b/sysdeps/generic/gmp-mparam.h
@@ -0,0 +1,26 @@
+/* gmp-mparam.h -- Compiler/machine parameter header file.
+
+Copyright (C) 1991, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#define BITS_PER_MP_LIMB 32
+#define BYTES_PER_MP_LIMB 4
+#define BITS_PER_LONGINT 32
+#define BITS_PER_INT 32
+#define BITS_PER_SHORTINT 16
+#define BITS_PER_CHAR 8
diff --git a/sysdeps/generic/htonl.c b/sysdeps/generic/htonl.c
new file mode 100644
index 0000000..724ef54
--- /dev/null
+++ b/sysdeps/generic/htonl.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <netinet/in.h>
+
+#undef htonl
+
+unsigned long int
+DEFUN(htonl, (x), unsigned long int x)
+{
+#if BYTE_ORDER == LITTLE_ENDIAN
+ x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24);
+#endif
+
+ return x;
+}
diff --git a/sysdeps/generic/htons.c b/sysdeps/generic/htons.c
new file mode 100644
index 0000000..e3209f3
--- /dev/null
+++ b/sysdeps/generic/htons.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <netinet/in.h>
+
+#undef htons
+
+unsigned short int
+DEFUN(htons, (x), unsigned short int x)
+{
+#if BYTE_ORDER == LITTLE_ENDIAN
+ x = (x << 8) | (x >> 8);
+#endif
+
+ return x;
+}
diff --git a/sysdeps/generic/hypot.c b/sysdeps/generic/hypot.c
new file mode 100644
index 0000000..a0ea8e1
--- /dev/null
+++ b/sysdeps/generic/hypot.c
@@ -0,0 +1,27 @@
+/* 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+
+/* Return `sqrt(x*x + y*y)'. */
+__CONSTVALUE double
+DEFUN(hypot, (x, y), double x AND double y)
+{
+ return sqrt(x*x + y*y);
+}
diff --git a/sysdeps/generic/infnan.c b/sysdeps/generic/infnan.c
new file mode 100644
index 0000000..1102a53
--- /dev/null
+++ b/sysdeps/generic/infnan.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Deal with an infinite or NaN result.
+ If ERROR is ERANGE, result is +Inf;
+ if ERROR is - ERANGE, result is -Inf;
+ otherwise result is NaN.
+ This will set `errno' to either ERANGE or EDOM,
+ and may return an infinity or NaN, or may do something else. */
+double
+DEFUN(__infnan, (error), int error)
+{
+ switch (error)
+ {
+ case ERANGE:
+ errno = ERANGE;
+ return HUGE_VAL;
+
+ case - ERANGE:
+ errno = ERANGE;
+ return - HUGE_VAL;
+
+ default:
+ errno = EDOM;
+ return 0.0;
+ }
+}
+
+weak_alias (__infnan, infnan)
diff --git a/sysdeps/generic/isnan.c b/sysdeps/generic/isnan.c
new file mode 100644
index 0000000..79b2d10
--- /dev/null
+++ b/sysdeps/generic/isnan.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+
+/* Return nonzero if VALUE is not a number. */
+int
+DEFUN(__isnan, (value), double value)
+{
+ return value != value;
+}
+
+weak_alias (__isnan, isnan)
diff --git a/sysdeps/generic/ldexp.c b/sysdeps/generic/ldexp.c
new file mode 100644
index 0000000..ac5b019
--- /dev/null
+++ b/sysdeps/generic/ldexp.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+
+/* Return X times (two to the EXP power). */
+double
+DEFUN(ldexp, (x, exp), register double x AND register int exp)
+{
+ return x * pow(2.0, (double) exp);
+}
diff --git a/sysdeps/generic/log.c b/sysdeps/generic/log.c
new file mode 100644
index 0000000..ae18672
--- /dev/null
+++ b/sysdeps/generic/log.c
@@ -0,0 +1,486 @@
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)log.c 8.2 (Berkeley) 11/30/93";
+#endif /* not lint */
+
+#include <math.h>
+#include <errno.h>
+
+#include "mathimpl.h"
+
+/* Table-driven natural logarithm.
+ *
+ * This code was derived, with minor modifications, from:
+ * Peter Tang, "Table-Driven Implementation of the
+ * Logarithm in IEEE Floating-Point arithmetic." ACM Trans.
+ * Math Software, vol 16. no 4, pp 378-400, Dec 1990).
+ *
+ * Calculates log(2^m*F*(1+f/F)), |f/j| <= 1/256,
+ * where F = j/128 for j an integer in [0, 128].
+ *
+ * log(2^m) = log2_hi*m + log2_tail*m
+ * since m is an integer, the dominant term is exact.
+ * m has at most 10 digits (for subnormal numbers),
+ * and log2_hi has 11 trailing zero bits.
+ *
+ * log(F) = logF_hi[j] + logF_lo[j] is in tabular form in log_table.h
+ * logF_hi[] + 512 is exact.
+ *
+ * log(1+f/F) = 2*f/(2*F + f) + 1/12 * (2*f/(2*F + f))**3 + ...
+ * the leading term is calculated to extra precision in two
+ * parts, the larger of which adds exactly to the dominant
+ * m and F terms.
+ * There are two cases:
+ * 1. when m, j are non-zero (m | j), use absolute
+ * precision for the leading term.
+ * 2. when m = j = 0, |1-x| < 1/256, and log(x) ~= (x-1).
+ * In this case, use a relative precision of 24 bits.
+ * (This is done differently in the original paper)
+ *
+ * Special cases:
+ * 0 return signalling -Inf
+ * neg return signalling NaN
+ * +Inf return +Inf
+*/
+
+#if defined(vax) || defined(tahoe)
+#define _IEEE 0
+#define TRUNC(x) x = (double) (float) (x)
+#else
+#define _IEEE 1
+#define endian (((*(int *) &one)) ? 1 : 0)
+#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000
+#define infnan(x) 0.0
+#endif
+
+#define N 128
+
+/* Table of log(Fj) = logF_head[j] + logF_tail[j], for Fj = 1+j/128.
+ * Used for generation of extend precision logarithms.
+ * The constant 35184372088832 is 2^45, so the divide is exact.
+ * It ensures correct reading of logF_head, even for inaccurate
+ * decimal-to-binary conversion routines. (Everybody gets the
+ * right answer for integers less than 2^53.)
+ * Values for log(F) were generated using error < 10^-57 absolute
+ * with the bc -l package.
+*/
+static double A1 = .08333333333333178827;
+static double A2 = .01250000000377174923;
+static double A3 = .002232139987919447809;
+static double A4 = .0004348877777076145742;
+
+static double logF_head[N+1] = {
+ 0.,
+ .007782140442060381246,
+ .015504186535963526694,
+ .023167059281547608406,
+ .030771658666765233647,
+ .038318864302141264488,
+ .045809536031242714670,
+ .053244514518837604555,
+ .060624621816486978786,
+ .067950661908525944454,
+ .075223421237524235039,
+ .082443669210988446138,
+ .089612158689760690322,
+ .096729626458454731618,
+ .103796793681567578460,
+ .110814366340264314203,
+ .117783035656430001836,
+ .124703478501032805070,
+ .131576357788617315236,
+ .138402322859292326029,
+ .145182009844575077295,
+ .151916042025732167530,
+ .158605030176659056451,
+ .165249572895390883786,
+ .171850256926518341060,
+ .178407657472689606947,
+ .184922338493834104156,
+ .191394852999565046047,
+ .197825743329758552135,
+ .204215541428766300668,
+ .210564769107350002741,
+ .216873938300523150246,
+ .223143551314024080056,
+ .229374101064877322642,
+ .235566071312860003672,
+ .241719936886966024758,
+ .247836163904594286577,
+ .253915209980732470285,
+ .259957524436686071567,
+ .265963548496984003577,
+ .271933715484010463114,
+ .277868451003087102435,
+ .283768173130738432519,
+ .289633292582948342896,
+ .295464212893421063199,
+ .301261330578199704177,
+ .307025035294827830512,
+ .312755710004239517729,
+ .318453731118097493890,
+ .324119468654316733591,
+ .329753286372579168528,
+ .335355541920762334484,
+ .340926586970454081892,
+ .346466767346100823488,
+ .351976423156884266063,
+ .357455888922231679316,
+ .362905493689140712376,
+ .368325561158599157352,
+ .373716409793814818840,
+ .379078352934811846353,
+ .384411698910298582632,
+ .389716751140440464951,
+ .394993808240542421117,
+ .400243164127459749579,
+ .405465108107819105498,
+ .410659924985338875558,
+ .415827895143593195825,
+ .420969294644237379543,
+ .426084395310681429691,
+ .431173464818130014464,
+ .436236766774527495726,
+ .441274560805140936281,
+ .446287102628048160113,
+ .451274644139630254358,
+ .456237433481874177232,
+ .461175715122408291790,
+ .466089729924533457960,
+ .470979715219073113985,
+ .475845904869856894947,
+ .480688529345570714212,
+ .485507815781602403149,
+ .490303988045525329653,
+ .495077266798034543171,
+ .499827869556611403822,
+ .504556010751912253908,
+ .509261901790523552335,
+ .513945751101346104405,
+ .518607764208354637958,
+ .523248143765158602036,
+ .527867089620485785417,
+ .532464798869114019908,
+ .537041465897345915436,
+ .541597282432121573947,
+ .546132437597407260909,
+ .550647117952394182793,
+ .555141507540611200965,
+ .559615787935399566777,
+ .564070138285387656651,
+ .568504735352689749561,
+ .572919753562018740922,
+ .577315365035246941260,
+ .581691739635061821900,
+ .586049045003164792433,
+ .590387446602107957005,
+ .594707107746216934174,
+ .599008189645246602594,
+ .603290851438941899687,
+ .607555250224322662688,
+ .611801541106615331955,
+ .616029877215623855590,
+ .620240409751204424537,
+ .624433288012369303032,
+ .628608659422752680256,
+ .632766669570628437213,
+ .636907462236194987781,
+ .641031179420679109171,
+ .645137961373620782978,
+ .649227946625615004450,
+ .653301272011958644725,
+ .657358072709030238911,
+ .661398482245203922502,
+ .665422632544505177065,
+ .669430653942981734871,
+ .673422675212350441142,
+ .677398823590920073911,
+ .681359224807238206267,
+ .685304003098281100392,
+ .689233281238557538017,
+ .693147180560117703862
+};
+
+static double logF_tail[N+1] = {
+ 0.,
+ -.00000000000000543229938420049,
+ .00000000000000172745674997061,
+ -.00000000000001323017818229233,
+ -.00000000000001154527628289872,
+ -.00000000000000466529469958300,
+ .00000000000005148849572685810,
+ -.00000000000002532168943117445,
+ -.00000000000005213620639136504,
+ -.00000000000001819506003016881,
+ .00000000000006329065958724544,
+ .00000000000008614512936087814,
+ -.00000000000007355770219435028,
+ .00000000000009638067658552277,
+ .00000000000007598636597194141,
+ .00000000000002579999128306990,
+ -.00000000000004654729747598444,
+ -.00000000000007556920687451336,
+ .00000000000010195735223708472,
+ -.00000000000017319034406422306,
+ -.00000000000007718001336828098,
+ .00000000000010980754099855238,
+ -.00000000000002047235780046195,
+ -.00000000000008372091099235912,
+ .00000000000014088127937111135,
+ .00000000000012869017157588257,
+ .00000000000017788850778198106,
+ .00000000000006440856150696891,
+ .00000000000016132822667240822,
+ -.00000000000007540916511956188,
+ -.00000000000000036507188831790,
+ .00000000000009120937249914984,
+ .00000000000018567570959796010,
+ -.00000000000003149265065191483,
+ -.00000000000009309459495196889,
+ .00000000000017914338601329117,
+ -.00000000000001302979717330866,
+ .00000000000023097385217586939,
+ .00000000000023999540484211737,
+ .00000000000015393776174455408,
+ -.00000000000036870428315837678,
+ .00000000000036920375082080089,
+ -.00000000000009383417223663699,
+ .00000000000009433398189512690,
+ .00000000000041481318704258568,
+ -.00000000000003792316480209314,
+ .00000000000008403156304792424,
+ -.00000000000034262934348285429,
+ .00000000000043712191957429145,
+ -.00000000000010475750058776541,
+ -.00000000000011118671389559323,
+ .00000000000037549577257259853,
+ .00000000000013912841212197565,
+ .00000000000010775743037572640,
+ .00000000000029391859187648000,
+ -.00000000000042790509060060774,
+ .00000000000022774076114039555,
+ .00000000000010849569622967912,
+ -.00000000000023073801945705758,
+ .00000000000015761203773969435,
+ .00000000000003345710269544082,
+ -.00000000000041525158063436123,
+ .00000000000032655698896907146,
+ -.00000000000044704265010452446,
+ .00000000000034527647952039772,
+ -.00000000000007048962392109746,
+ .00000000000011776978751369214,
+ -.00000000000010774341461609578,
+ .00000000000021863343293215910,
+ .00000000000024132639491333131,
+ .00000000000039057462209830700,
+ -.00000000000026570679203560751,
+ .00000000000037135141919592021,
+ -.00000000000017166921336082431,
+ -.00000000000028658285157914353,
+ -.00000000000023812542263446809,
+ .00000000000006576659768580062,
+ -.00000000000028210143846181267,
+ .00000000000010701931762114254,
+ .00000000000018119346366441110,
+ .00000000000009840465278232627,
+ -.00000000000033149150282752542,
+ -.00000000000018302857356041668,
+ -.00000000000016207400156744949,
+ .00000000000048303314949553201,
+ -.00000000000071560553172382115,
+ .00000000000088821239518571855,
+ -.00000000000030900580513238244,
+ -.00000000000061076551972851496,
+ .00000000000035659969663347830,
+ .00000000000035782396591276383,
+ -.00000000000046226087001544578,
+ .00000000000062279762917225156,
+ .00000000000072838947272065741,
+ .00000000000026809646615211673,
+ -.00000000000010960825046059278,
+ .00000000000002311949383800537,
+ -.00000000000058469058005299247,
+ -.00000000000002103748251144494,
+ -.00000000000023323182945587408,
+ -.00000000000042333694288141916,
+ -.00000000000043933937969737844,
+ .00000000000041341647073835565,
+ .00000000000006841763641591466,
+ .00000000000047585534004430641,
+ .00000000000083679678674757695,
+ -.00000000000085763734646658640,
+ .00000000000021913281229340092,
+ -.00000000000062242842536431148,
+ -.00000000000010983594325438430,
+ .00000000000065310431377633651,
+ -.00000000000047580199021710769,
+ -.00000000000037854251265457040,
+ .00000000000040939233218678664,
+ .00000000000087424383914858291,
+ .00000000000025218188456842882,
+ -.00000000000003608131360422557,
+ -.00000000000050518555924280902,
+ .00000000000078699403323355317,
+ -.00000000000067020876961949060,
+ .00000000000016108575753932458,
+ .00000000000058527188436251509,
+ -.00000000000035246757297904791,
+ -.00000000000018372084495629058,
+ .00000000000088606689813494916,
+ .00000000000066486268071468700,
+ .00000000000063831615170646519,
+ .00000000000025144230728376072,
+ -.00000000000017239444525614834
+};
+
+double
+#ifdef _ANSI_SOURCE
+log(double x)
+#else
+log(x) double x;
+#endif
+{
+ int m, j;
+ double F, f, g, q, u, u2, v, zero = 0.0, one = 1.0;
+ volatile double u1;
+
+ /* Catch special cases */
+ if (x <= 0)
+ if (_IEEE && x == zero) /* log(0) = -Inf */
+ return (-one/zero);
+ else if (_IEEE) /* log(neg) = NaN */
+ return (zero/zero);
+ else if (x == zero) /* NOT REACHED IF _IEEE */
+ return (infnan(-ERANGE));
+ else
+ return (infnan(EDOM));
+ else if (!finite(x))
+ if (_IEEE) /* x = NaN, Inf */
+ return (x+x);
+ else
+ return (infnan(ERANGE));
+
+ /* Argument reduction: 1 <= g < 2; x/2^m = g; */
+ /* y = F*(1 + f/F) for |f| <= 2^-8 */
+
+ m = logb(x);
+ g = ldexp(x, -m);
+ if (_IEEE && m == -1022) {
+ j = logb(g), m += j;
+ g = ldexp(g, -j);
+ }
+ j = N*(g-1) + .5;
+ F = (1.0/N) * j + 1; /* F*128 is an integer in [128, 512] */
+ f = g - F;
+
+ /* Approximate expansion for log(1+f/F) ~= u + q */
+ g = 1/(2*F+f);
+ u = 2*f*g;
+ v = u*u;
+ q = u*v*(A1 + v*(A2 + v*(A3 + v*A4)));
+
+ /* case 1: u1 = u rounded to 2^-43 absolute. Since u < 2^-8,
+ * u1 has at most 35 bits, and F*u1 is exact, as F has < 8 bits.
+ * It also adds exactly to |m*log2_hi + log_F_head[j] | < 750
+ */
+ if (m | j)
+ u1 = u + 513, u1 -= 513;
+
+ /* case 2: |1-x| < 1/256. The m- and j- dependent terms are zero;
+ * u1 = u to 24 bits.
+ */
+ else
+ u1 = u, TRUNC(u1);
+ u2 = (2.0*(f - F*u1) - u1*f) * g;
+ /* u1 + u2 = 2f/(2F+f) to extra precision. */
+
+ /* log(x) = log(2^m*F*(1+f/F)) = */
+ /* (m*log2_hi+logF_head[j]+u1) + (m*log2_lo+logF_tail[j]+q); */
+ /* (exact) + (tiny) */
+
+ u1 += m*logF_head[N] + logF_head[j]; /* exact */
+ u2 = (u2 + logF_tail[j]) + q; /* tiny */
+ u2 += logF_tail[N]*m;
+ return (u1 + u2);
+}
+
+/*
+ * Extra precision variant, returning struct {double a, b;};
+ * log(x) = a+b to 63 bits, with a is rounded to 26 bits.
+ */
+struct Double
+#ifdef _ANSI_SOURCE
+__log__D(double x)
+#else
+__log__D(x) double x;
+#endif
+{
+ int m, j;
+ double F, f, g, q, u, v, u2, one = 1.0;
+ volatile double u1;
+ struct Double r;
+
+ /* Argument reduction: 1 <= g < 2; x/2^m = g; */
+ /* y = F*(1 + f/F) for |f| <= 2^-8 */
+
+ m = logb(x);
+ g = ldexp(x, -m);
+ if (_IEEE && m == -1022) {
+ j = logb(g), m += j;
+ g = ldexp(g, -j);
+ }
+ j = N*(g-1) + .5;
+ F = (1.0/N) * j + 1;
+ f = g - F;
+
+ g = 1/(2*F+f);
+ u = 2*f*g;
+ v = u*u;
+ q = u*v*(A1 + v*(A2 + v*(A3 + v*A4)));
+ if (m | j)
+ u1 = u + 513, u1 -= 513;
+ else
+ u1 = u, TRUNC(u1);
+ u2 = (2.0*(f - F*u1) - u1*f) * g;
+
+ u1 += m*logF_head[N] + logF_head[j];
+
+ u2 += logF_tail[j]; u2 += q;
+ u2 += logF_tail[N]*m;
+ r.a = u1 + u2; /* Only difference is here */
+ TRUNC(r.a);
+ r.b = (u1 - r.a) + u2;
+ return (r);
+}
diff --git a/sysdeps/generic/log10.c b/sysdeps/generic/log10.c
new file mode 100644
index 0000000..df52d54
--- /dev/null
+++ b/sysdeps/generic/log10.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+#ifndef LN10
+#define LN10 log(10.0)
+#endif
+
+/* Return the base-ten logarithm of X. */
+double
+DEFUN(log10, (x), double x)
+{
+ static double ln10 = 0.0;
+
+ if (ln10 == 0.0)
+ ln10 = LN10;
+
+ return log(x) / ln10;
+}
diff --git a/sysdeps/generic/log1p.c b/sysdeps/generic/log1p.c
new file mode 100644
index 0000000..cbf9fcd
--- /dev/null
+++ b/sysdeps/generic/log1p.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)log1p.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* LOG1P(x)
+ * RETURN THE LOGARITHM OF 1+x
+ * DOUBLE PRECISION (VAX D FORMAT 56 bits, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 1/19/85;
+ * REVISED BY K.C. NG on 2/6/85, 3/7/85, 3/24/85, 4/16/85.
+ *
+ * Required system supported functions:
+ * scalb(x,n)
+ * copysign(x,y)
+ * logb(x)
+ * finite(x)
+ *
+ * Required kernel function:
+ * log__L(z)
+ *
+ * Method :
+ * 1. Argument Reduction: find k and f such that
+ * 1+x = 2^k * (1+f),
+ * where sqrt(2)/2 < 1+f < sqrt(2) .
+ *
+ * 2. Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
+ * = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+ * log(1+f) is computed by
+ *
+ * log(1+f) = 2s + s*log__L(s*s)
+ * where
+ * log__L(z) = z*(L1 + z*(L2 + z*(... (L6 + z*L7)...)))
+ *
+ * See log__L() for the values of the coefficients.
+ *
+ * 3. Finally, log(1+x) = k*ln2 + log(1+f).
+ *
+ * Remarks 1. In step 3 n*ln2 will be stored in two floating point numbers
+ * n*ln2hi + n*ln2lo, where ln2hi is chosen such that the last
+ * 20 bits (for VAX D format), or the last 21 bits ( for IEEE
+ * double) is 0. This ensures n*ln2hi is exactly representable.
+ * 2. In step 1, f may not be representable. A correction term c
+ * for f is computed. It follows that the correction term for
+ * f - t (the leading term of log(1+f) in step 2) is c-c*x. We
+ * add this correction term to n*ln2lo to attenuate the error.
+ *
+ *
+ * Special cases:
+ * log1p(x) is NaN with signal if x < -1; log1p(NaN) is NaN with no signal;
+ * log1p(INF) is +INF; log1p(-1) is -INF with signal;
+ * only log1p(0)=0 is exact for finite argument.
+ *
+ * Accuracy:
+ * log1p(x) returns the exact log(1+x) nearly rounded. In a test run
+ * with 1,536,000 random arguments on a VAX, the maximum observed
+ * error was .846 ulps (units in the last place).
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include <errno.h>
+#include "mathimpl.h"
+
+vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000)
+vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC)
+vc(sqrt2, 1.4142135623730950622E0 ,04f3,40b5,de65,33f9, 1, .B504F333F9DE65)
+
+ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000)
+ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76)
+ic(sqrt2, 1.4142135623730951455E0, 0, 1.6A09E667F3BCD)
+
+#ifdef vccast
+#define ln2hi vccast(ln2hi)
+#define ln2lo vccast(ln2lo)
+#define sqrt2 vccast(sqrt2)
+#endif
+
+double log1p(x)
+double x;
+{
+ const static double zero=0.0, negone= -1.0, one=1.0,
+ half=1.0/2.0, small=1.0E-20; /* 1+small == 1 */
+ double z,s,t,c;
+ int k;
+
+#if !defined(vax)&&!defined(tahoe)
+ if(x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+
+ if(finite(x)) {
+ if( x > negone ) {
+
+ /* argument reduction */
+ if(copysign(x,one)<small) return(x);
+ k=logb(one+x); z=scalb(x,-k); t=scalb(one,-k);
+ if(z+t >= sqrt2 )
+ { k += 1 ; z *= half; t *= half; }
+ t += negone; x = z + t;
+ c = (t-x)+z ; /* correction term for x */
+
+ /* compute log(1+x) */
+ s = x/(2+x); t = x*x*half;
+ c += (k*ln2lo-c*x);
+ z = c+s*(t+__log__L(s*s));
+ x += (z - t) ;
+
+ return(k*ln2hi+x);
+ }
+ /* end of if (x > negone) */
+
+ else {
+#if defined(vax)||defined(tahoe)
+ if ( x == negone )
+ return (infnan(-ERANGE)); /* -INF */
+ else
+ return (infnan(EDOM)); /* NaN */
+#else /* defined(vax)||defined(tahoe) */
+ /* x = -1, return -INF with signal */
+ if ( x == negone ) return( negone/zero );
+
+ /* negative argument for log, return NaN with signal */
+ else return ( zero / zero );
+#endif /* defined(vax)||defined(tahoe) */
+ }
+ }
+ /* end of if (finite(x)) */
+
+ /* log(-INF) is NaN */
+ else if(x<0)
+ return(zero/zero);
+
+ /* log(+INF) is INF */
+ else return(x);
+}
diff --git a/sysdeps/generic/log__L.c b/sysdeps/generic/log__L.c
new file mode 100644
index 0000000..c00158f
--- /dev/null
+++ b/sysdeps/generic/log__L.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)log__L.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* log__L(Z)
+ * LOG(1+X) - 2S X
+ * RETURN --------------- WHERE Z = S*S, S = ------- , 0 <= Z <= .0294...
+ * S 2 + X
+ *
+ * DOUBLE PRECISION (VAX D FORMAT 56 bits or IEEE DOUBLE 53 BITS)
+ * KERNEL FUNCTION FOR LOG; TO BE USED IN LOG1P, LOG, AND POW FUNCTIONS
+ * CODED IN C BY K.C. NG, 1/19/85;
+ * REVISED BY K.C. Ng, 2/3/85, 4/16/85.
+ *
+ * Method :
+ * 1. Polynomial approximation: let s = x/(2+x).
+ * Based on log(1+x) = log(1+s) - log(1-s)
+ * = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+ *
+ * (log(1+x) - 2s)/s is computed by
+ *
+ * z*(L1 + z*(L2 + z*(... (L7 + z*L8)...)))
+ *
+ * where z=s*s. (See the listing below for Lk's values.) The
+ * coefficients are obtained by a special Remez algorithm.
+ *
+ * Accuracy:
+ * Assuming no rounding error, the maximum magnitude of the approximation
+ * error (absolute) is 2**(-58.49) for IEEE double, and 2**(-63.63)
+ * for VAX D format.
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include "mathimpl.h"
+
+vc(L1, 6.6666666666666703212E-1 ,aaaa,402a,aac5,aaaa, 0, .AAAAAAAAAAAAC5)
+vc(L2, 3.9999999999970461961E-1 ,cccc,3fcc,2684,cccc, -1, .CCCCCCCCCC2684)
+vc(L3, 2.8571428579395698188E-1 ,4924,3f92,5782,92f8, -1, .92492492F85782)
+vc(L4, 2.2222221233634724402E-1 ,8e38,3f63,af2c,39b7, -2, .E38E3839B7AF2C)
+vc(L5, 1.8181879517064680057E-1 ,2eb4,3f3a,655e,cc39, -2, .BA2EB4CC39655E)
+vc(L6, 1.5382888777946145467E-1 ,8551,3f1d,781d,e8c5, -2, .9D8551E8C5781D)
+vc(L7, 1.3338356561139403517E-1 ,95b3,3f08,cd92,907f, -2, .8895B3907FCD92)
+vc(L8, 1.2500000000000000000E-1 ,0000,3f00,0000,0000, -2, .80000000000000)
+
+ic(L1, 6.6666666666667340202E-1, -1, 1.5555555555592)
+ic(L2, 3.9999999999416702146E-1, -2, 1.999999997FF24)
+ic(L3, 2.8571428742008753154E-1, -2, 1.24924941E07B4)
+ic(L4, 2.2222198607186277597E-1, -3, 1.C71C52150BEA6)
+ic(L5, 1.8183562745289935658E-1, -3, 1.74663CC94342F)
+ic(L6, 1.5314087275331442206E-1, -3, 1.39A1EC014045B)
+ic(L7, 1.4795612545334174692E-1, -3, 1.2F039F0085122)
+
+#ifdef vccast
+#define L1 vccast(L1)
+#define L2 vccast(L2)
+#define L3 vccast(L3)
+#define L4 vccast(L4)
+#define L5 vccast(L5)
+#define L6 vccast(L6)
+#define L7 vccast(L7)
+#define L8 vccast(L8)
+#endif
+
+double __log__L(z)
+double z;
+{
+#if defined(vax)||defined(tahoe)
+ return(z*(L1+z*(L2+z*(L3+z*(L4+z*(L5+z*(L6+z*(L7+z*L8))))))));
+#else /* defined(vax)||defined(tahoe) */
+ return(z*(L1+z*(L2+z*(L3+z*(L4+z*(L5+z*(L6+z*L7)))))));
+#endif /* defined(vax)||defined(tahoe) */
+}
diff --git a/sysdeps/generic/lshift.c b/sysdeps/generic/lshift.c
new file mode 100644
index 0000000..1ba0903
--- /dev/null
+++ b/sysdeps/generic/lshift.c
@@ -0,0 +1,86 @@
+/* __mpn_lshift -- Shift left low level.
+
+Copyright (C) 1991, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
+/* Shift U (pointed to by UP and USIZE digits long) CNT bits to the left
+ and store the USIZE least significant digits of the result at WP.
+ Return the bits shifted out from the most significant digit.
+
+ Argument constraints:
+ 1. 0 < CNT < BITS_PER_MP_LIMB
+ 2. If the result is to be written over the input, WP must be >= UP.
+*/
+
+mp_limb
+#if __STDC__
+__mpn_lshift (register mp_ptr wp,
+ register mp_srcptr up, mp_size_t usize,
+ register unsigned int cnt)
+#else
+__mpn_lshift (wp, up, usize, cnt)
+ register mp_ptr wp;
+ register mp_srcptr up;
+ mp_size_t usize;
+ register unsigned int cnt;
+#endif
+{
+ register mp_limb high_limb, low_limb;
+ register unsigned sh_1, sh_2;
+ register mp_size_t i;
+ mp_limb retval;
+
+#ifdef DEBUG
+ if (usize == 0 || cnt == 0)
+ abort ();
+#endif
+
+ sh_1 = cnt;
+#if 0
+ if (sh_1 == 0)
+ {
+ if (wp != up)
+ {
+ /* Copy from high end to low end, to allow specified input/output
+ overlapping. */
+ for (i = usize - 1; i >= 0; i--)
+ wp[i] = up[i];
+ }
+ return 0;
+ }
+#endif
+
+ wp += 1;
+ sh_2 = BITS_PER_MP_LIMB - sh_1;
+ i = usize - 1;
+ low_limb = up[i];
+ retval = low_limb >> sh_2;
+ high_limb = low_limb;
+ while (--i >= 0)
+ {
+ low_limb = up[i];
+ wp[i] = (high_limb << sh_1) | (low_limb >> sh_2);
+ high_limb = low_limb;
+ }
+ wp[i] = high_limb << sh_1;
+
+ return retval;
+}
diff --git a/sysdeps/generic/lstat.c b/sysdeps/generic/lstat.c
new file mode 100644
index 0000000..44fafa6
--- /dev/null
+++ b/sysdeps/generic/lstat.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+
+int
+DEFUN(__lstat, (file, buf),
+ CONST char *file AND struct stat *buf)
+{
+ return __stat (file, buf);
+}
+
+weak_alias (__lstat, lstat)
diff --git a/sysdeps/generic/make_siglist.c b/sysdeps/generic/make_siglist.c
new file mode 100644
index 0000000..34abf80
--- /dev/null
+++ b/sysdeps/generic/make_siglist.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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 General Public License as published by
+the Free Software Foundation; either version 2, 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the GNU C Library; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <signal.h>
+#include <stdio.h>
+
+
+/* Make a definition for sys_siglist. */
+
+
+#undef HAVE_SYS_SIGLIST
+#define sys_siglist my_siglist /* Avoid clash with signal.h. */
+
+#include "signame.c"
+
+
+int
+main()
+{
+ register int i;
+
+ signame_init ();
+
+ puts ("#include \"ansidecl.h\"\n#include <stddef.h>\n");
+
+ puts ("\n/* This is a list of all known signal numbers. */");
+
+ puts ("\nCONST char *CONST _sys_siglist[] =\n {");
+
+ for (i = 0; i < NSIG; ++i)
+ printf (" \"%s\",\n", sys_siglist[i]);
+
+ puts (" NULL\n };\n");
+
+ puts ("weak_alias (_sys_siglist, sys_siglist)");
+ exit (0);
+}
diff --git a/sysdeps/generic/mathimpl.h b/sysdeps/generic/mathimpl.h
new file mode 100644
index 0000000..a2c963d
--- /dev/null
+++ b/sysdeps/generic/mathimpl.h
@@ -0,0 +1,127 @@
+/* This part here added by roland@prep.ai.mit.edu for the GNU C library. */
+
+#include <math.h> /* Done first so we can #undef. */
+#include <endian.h>
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#undef national
+#define national
+#endif
+
+#undef isinf
+#define isinf __isinf
+#undef isnan
+#define isnan __isnan
+#undef infnan
+#define infnan __infnan
+#undef copysign
+#define copysign __copysign
+#undef scalb
+#define scalb __scalb
+#undef drem
+#define drem __drem
+#undef logb
+#define logb __logb
+#undef __finite
+#undef finite
+#define finite __finite
+#undef expm1
+#define expm1 __expm1
+
+/*
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)mathimpl.h 8.1 (Berkeley) 6/4/93
+ */
+
+#include <sys/cdefs.h>
+#include <math.h>
+
+#if defined(vax)||defined(tahoe)
+
+/* Deal with different ways to concatenate in cpp */
+# ifdef __STDC__
+# define cat3(a,b,c) a ## b ## c
+# else
+# define cat3(a,b,c) a/**/b/**/c
+# endif
+
+/* Deal with vax/tahoe byte order issues */
+# ifdef vax
+# define cat3t(a,b,c) cat3(a,b,c)
+# else
+# define cat3t(a,b,c) cat3(a,c,b)
+# endif
+
+# define vccast(name) (*(const double *)(cat3(name,,x)))
+
+ /*
+ * Define a constant to high precision on a Vax or Tahoe.
+ *
+ * Args are the name to define, the decimal floating point value,
+ * four 16-bit chunks of the float value in hex
+ * (because the vax and tahoe differ in float format!), the power
+ * of 2 of the hex-float exponent, and the hex-float mantissa.
+ * Most of these arguments are not used at compile time; they are
+ * used in a post-check to make sure the constants were compiled
+ * correctly.
+ *
+ * People who want to use the constant will have to do their own
+ * #define foo vccast(foo)
+ * since CPP cannot do this for them from inside another macro (sigh).
+ * We define "vccast" if this needs doing.
+ */
+# define vc(name, value, x1,x2,x3,x4, bexp, xval) \
+ const static long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)};
+
+# define ic(name, value, bexp, xval) ;
+
+#else /* vax or tahoe */
+
+ /* Hooray, we have an IEEE machine */
+# undef vccast
+# define vc(name, value, x1,x2,x3,x4, bexp, xval) ;
+
+# define ic(name, value, bexp, xval) \
+ const static double name = value;
+
+#endif /* defined(vax)||defined(tahoe) */
+
+
+/*
+ * Functions internal to the math package, yet not static.
+ */
+extern double __exp__E();
+extern double __log__L();
+
+struct Double {double a, b;};
+double __exp__D __P((double, double));
+struct Double __log__D __P((double));
diff --git a/sysdeps/generic/memccpy.c b/sysdeps/generic/memccpy.c
new file mode 100644
index 0000000..b905952
--- /dev/null
+++ b/sysdeps/generic/memccpy.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h> /* For size_t and NULL. */
+
+
+/*
+ * Copy no more than N bytes of SRC to DEST, stopping when C is found.
+ * Return the position in DEST one byte past where C was copied,
+ * or NULL if C was not found in the first N bytes of SRC.
+ */
+PTR
+DEFUN(__memccpy, (dest, src, c, n),
+ PTR dest AND CONST PTR src AND int c AND size_t n)
+{
+ register CONST char *s = src;
+ register char *d = dest;
+ register CONST int x = (unsigned char) c;
+ register size_t i = n;
+
+ while (i-- > 0)
+ if ((*d++ = *s++) == x)
+ return d;
+
+ return NULL;
+}
+
+weak_alias (__memccpy, memccpy)
diff --git a/sysdeps/generic/memchr.c b/sysdeps/generic/memchr.c
new file mode 100644
index 0000000..d17f9c6
--- /dev/null
+++ b/sysdeps/generic/memchr.c
@@ -0,0 +1,168 @@
+/* Copyright (C) 1991, 1993 Free Software Foundation, Inc.
+ Based on strlen implemention by Torbjorn Granlund (tege@sics.se),
+ with help from Dan Sahlin (dan@sics.se) and
+ commentary by Jim Blandy (jimb@ai.mit.edu);
+ adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
+ and implemented by Roland McGrath (roland@ai.mit.edu).
+
+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. */
+
+#include <ansidecl.h>
+#include <string.h>
+
+
+/* Search no more than N bytes of S for C. */
+
+PTR
+DEFUN(memchr, (s, c, n), CONST PTR s AND int c AND size_t n)
+{
+ CONST unsigned char *char_ptr;
+ CONST unsigned long int *longword_ptr;
+ unsigned long int longword, magic_bits, charmask;
+
+ c = (unsigned char) c;
+
+ /* Handle the first few characters by reading one character at a time.
+ Do this until CHAR_PTR is aligned on a longword boundary. */
+ for (char_ptr = s; n > 0 && ((unsigned long int) char_ptr
+ & (sizeof (longword) - 1)) != 0;
+ --n, ++char_ptr)
+ if (*char_ptr == c)
+ return (PTR) char_ptr;
+
+ /* All these elucidatory comments refer to 4-byte longwords,
+ but the theory applies equally well to 8-byte longwords. */
+
+ longword_ptr = (unsigned long int *) char_ptr;
+
+ /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits
+ the "holes." Note that there is a hole just to the left of
+ each byte, with an extra at the end:
+
+ bits: 01111110 11111110 11111110 11111111
+ bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
+
+ The 1-bits make sure that carries propagate to the next 0-bit.
+ The 0-bits provide holes for carries to fall into. */
+ switch (sizeof (longword))
+ {
+ case 4: magic_bits = 0x7efefeffL; break;
+ case 8: magic_bits = (0x7efefefeL << 32) | 0xfefefeffL; break;
+ default:
+ abort ();
+ }
+
+ /* Set up a longword, each of whose bytes is C. */
+ charmask = c | (c << 8);
+ charmask |= charmask << 16;
+ if (sizeof (longword) > 4)
+ charmask |= charmask << 32;
+ if (sizeof (longword) > 8)
+ abort ();
+
+ /* Instead of the traditional loop which tests each character,
+ we will test a longword at a time. The tricky part is testing
+ if *any of the four* bytes in the longword in question are zero. */
+ while (n >= sizeof (longword))
+ {
+ /* We tentatively exit the loop if adding MAGIC_BITS to
+ LONGWORD fails to change any of the hole bits of LONGWORD.
+
+ 1) Is this safe? Will it catch all the zero bytes?
+ Suppose there is a byte with all zeros. Any carry bits
+ propagating from its left will fall into the hole at its
+ least significant bit and stop. Since there will be no
+ carry from its most significant bit, the LSB of the
+ byte to the left will be unchanged, and the zero will be
+ detected.
+
+ 2) Is this worthwhile? Will it ignore everything except
+ zero bytes? Suppose every byte of LONGWORD has a bit set
+ somewhere. There will be a carry into bit 8. If bit 8
+ is set, this will carry into bit 16. If bit 8 is clear,
+ one of bits 9-15 must be set, so there will be a carry
+ into bit 16. Similarly, there will be a carry into bit
+ 24. If one of bits 24-30 is set, there will be a carry
+ into bit 31, so all of the hole bits will be changed.
+
+ The one misfire occurs when bits 24-30 are clear and bit
+ 31 is set; in this case, the hole at bit 31 is not
+ changed. If we had access to the processor carry flag,
+ we could close this loophole by putting the fourth hole
+ at bit 32!
+
+ So it ignores everything except 128's, when they're aligned
+ properly.
+
+ 3) But wait! Aren't we looking for C, not zero?
+ Good point. So what we do is XOR LONGWORD with a longword,
+ each of whose bytes is C. This turns each byte that is C
+ into a zero. */
+
+ longword = *longword_ptr++ ^ charmask;
+
+ /* Add MAGIC_BITS to LONGWORD. */
+ if ((((longword + magic_bits)
+
+ /* Set those bits that were unchanged by the addition. */
+ ^ ~longword)
+
+ /* Look at only the hole bits. If any of the hole bits
+ are unchanged, most likely one of the bytes was a
+ zero. */
+ & ~magic_bits) != 0)
+ {
+ /* Which of the bytes was C? If none of them were, it was
+ a misfire; continue the search. */
+
+ CONST unsigned char *cp = (CONST unsigned char *) (longword_ptr - 1);
+
+ if (cp[0] == c)
+ return (PTR) cp;
+ if (cp[1] == c)
+ return (PTR) &cp[1];
+ if (cp[2] == c)
+ return (PTR) &cp[2];
+ if (cp[3] == c)
+ return (PTR) &cp[3];
+ if (sizeof (longword) > 4)
+ {
+ if (cp[4] == c)
+ return (PTR) &cp[4];
+ if (cp[5] == c)
+ return (PTR) &cp[5];
+ if (cp[6] == c)
+ return (PTR) &cp[6];
+ if (cp[7] == c)
+ return (PTR) &cp[7];
+ }
+ }
+
+ n -= sizeof (longword);
+ }
+
+ char_ptr = (CONST unsigned char *) longword_ptr;
+
+ while (n-- > 0)
+ {
+ if (*char_ptr == c)
+ return (PTR) char_ptr;
+ else
+ ++char_ptr;
+ }
+
+ return NULL;
+}
diff --git a/sysdeps/generic/memcmp.c b/sysdeps/generic/memcmp.c
new file mode 100644
index 0000000..8f5eca0
--- /dev/null
+++ b/sysdeps/generic/memcmp.c
@@ -0,0 +1,369 @@
+/* Copyright (C) 1991, 1993, 1995 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#undef __ptr_t
+#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
+#define __ptr_t void *
+#else /* Not C++ or ANSI C. */
+#undef const
+#define const
+#define __ptr_t char *
+#endif /* C++ or ANSI C. */
+
+#if defined (HAVE_STRING_H) || defined (_LIBC)
+#include <string.h>
+#endif
+
+#ifdef _LIBC
+
+#include <memcopy.h>
+
+#else /* Not in the GNU C library. */
+
+#include <sys/types.h>
+
+/* Type to use for aligned memory operations.
+ This should normally be the biggest type supported by a single load
+ and store. Must be an unsigned type. */
+#define op_t unsigned long int
+#define OPSIZ (sizeof(op_t))
+
+/* Threshold value for when to enter the unrolled loops. */
+#define OP_T_THRES 16
+
+/* Type to use for unaligned operations. */
+typedef unsigned char byte;
+
+#ifndef WORDS_BIGENDIAN
+#define MERGE(w0, sh_1, w1, sh_2) (((w0) >> (sh_1)) | ((w1) << (sh_2)))
+#else
+#define MERGE(w0, sh_1, w1, sh_2) (((w0) << (sh_1)) | ((w1) >> (sh_2)))
+#endif
+
+#endif /* In the GNU C library. */
+
+#ifdef WORDS_BIGENDIAN
+#define CMP_LT_OR_GT(a, b) ((a) > (b) ? 1 : -1)
+#else
+#define CMP_LT_OR_GT(a, b) memcmp_bytes ((a), (b))
+#endif
+
+/* BE VERY CAREFUL IF YOU CHANGE THIS CODE! */
+
+/* The strategy of this memcmp is:
+
+ 1. Compare bytes until one of the block pointers is aligned.
+
+ 2. Compare using memcmp_common_alignment or
+ memcmp_not_common_alignment, regarding the alignment of the other
+ block after the initial byte operations. The maximum number of
+ full words (of type op_t) are compared in this way.
+
+ 3. Compare the few remaining bytes. */
+
+#ifndef WORDS_BIGENDIAN
+/* memcmp_bytes -- Compare A and B bytewise in the byte order of the machine.
+ A and B are known to be different.
+ This is needed only on little-endian machines. */
+#ifdef __GNUC__
+__inline
+#endif
+static int
+memcmp_bytes (a, b)
+ op_t a, b;
+{
+ long int srcp1 = (long int) &a;
+ long int srcp2 = (long int) &b;
+ op_t a0, b0;
+
+ do
+ {
+ a0 = ((byte *) srcp1)[0];
+ b0 = ((byte *) srcp2)[0];
+ srcp1 += 1;
+ srcp2 += 1;
+ }
+ while (a0 == b0);
+ return a0 - b0;
+}
+#endif
+
+/* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t'
+ objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for
+ memory operations on `op_t's. */
+#ifdef __GNUC__
+__inline
+#endif
+static int
+memcmp_common_alignment (srcp1, srcp2, len)
+ long int srcp1;
+ long int srcp2;
+ size_t len;
+{
+ op_t a0, a1;
+ op_t b0, b1;
+
+ switch (len % 4)
+ {
+ case 2:
+ a0 = ((op_t *) srcp1)[0];
+ b0 = ((op_t *) srcp2)[0];
+ srcp1 -= 2 * OPSIZ;
+ srcp2 -= 2 * OPSIZ;
+ len += 2;
+ goto do1;
+ case 3:
+ a1 = ((op_t *) srcp1)[0];
+ b1 = ((op_t *) srcp2)[0];
+ srcp1 -= OPSIZ;
+ srcp2 -= OPSIZ;
+ len += 1;
+ goto do2;
+ case 0:
+ if (OP_T_THRES <= 3 * OPSIZ && len == 0)
+ return 0;
+ a0 = ((op_t *) srcp1)[0];
+ b0 = ((op_t *) srcp2)[0];
+ goto do3;
+ case 1:
+ a1 = ((op_t *) srcp1)[0];
+ b1 = ((op_t *) srcp2)[0];
+ srcp1 += OPSIZ;
+ srcp2 += OPSIZ;
+ len -= 1;
+ if (OP_T_THRES <= 3 * OPSIZ && len == 0)
+ goto do0;
+ /* Fall through. */
+ }
+
+ do
+ {
+ a0 = ((op_t *) srcp1)[0];
+ b0 = ((op_t *) srcp2)[0];
+ if (a1 != b1)
+ return CMP_LT_OR_GT (a1, b1);
+
+ do3:
+ a1 = ((op_t *) srcp1)[1];
+ b1 = ((op_t *) srcp2)[1];
+ if (a0 != b0)
+ return CMP_LT_OR_GT (a0, b0);
+
+ do2:
+ a0 = ((op_t *) srcp1)[2];
+ b0 = ((op_t *) srcp2)[2];
+ if (a1 != b1)
+ return CMP_LT_OR_GT (a1, b1);
+
+ do1:
+ a1 = ((op_t *) srcp1)[3];
+ b1 = ((op_t *) srcp2)[3];
+ if (a0 != b0)
+ return CMP_LT_OR_GT (a0, b0);
+
+ srcp1 += 4 * OPSIZ;
+ srcp2 += 4 * OPSIZ;
+ len -= 4;
+ }
+ while (len != 0);
+
+ /* This is the right position for do0. Please don't move
+ it into the loop. */
+ do0:
+ if (a1 != b1)
+ return CMP_LT_OR_GT (a1, b1);
+ return 0;
+}
+
+/* memcmp_not_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN
+ `op_t' objects (not LEN bytes!). SRCP2 should be aligned for memory
+ operations on `op_t', but SRCP1 *should be unaligned*. */
+#ifdef __GNUC__
+__inline
+#endif
+static int
+memcmp_not_common_alignment (srcp1, srcp2, len)
+ long int srcp1;
+ long int srcp2;
+ size_t len;
+{
+ op_t a0, a1, a2, a3;
+ op_t b0, b1, b2, b3;
+ op_t x;
+ int shl, shr;
+
+ /* Calculate how to shift a word read at the memory operation
+ aligned srcp1 to make it aligned for comparison. */
+
+ shl = 8 * (srcp1 % OPSIZ);
+ shr = 8 * OPSIZ - shl;
+
+ /* Make SRCP1 aligned by rounding it down to the beginning of the `op_t'
+ it points in the middle of. */
+ srcp1 &= -OPSIZ;
+
+ switch (len % 4)
+ {
+ case 2:
+ a1 = ((op_t *) srcp1)[0];
+ a2 = ((op_t *) srcp1)[1];
+ b2 = ((op_t *) srcp2)[0];
+ srcp1 -= 1 * OPSIZ;
+ srcp2 -= 2 * OPSIZ;
+ len += 2;
+ goto do1;
+ case 3:
+ a0 = ((op_t *) srcp1)[0];
+ a1 = ((op_t *) srcp1)[1];
+ b1 = ((op_t *) srcp2)[0];
+ srcp2 -= 1 * OPSIZ;
+ len += 1;
+ goto do2;
+ case 0:
+ if (OP_T_THRES <= 3 * OPSIZ && len == 0)
+ return 0;
+ a3 = ((op_t *) srcp1)[0];
+ a0 = ((op_t *) srcp1)[1];
+ b0 = ((op_t *) srcp2)[0];
+ srcp1 += 1 * OPSIZ;
+ goto do3;
+ case 1:
+ a2 = ((op_t *) srcp1)[0];
+ a3 = ((op_t *) srcp1)[1];
+ b3 = ((op_t *) srcp2)[0];
+ srcp1 += 2 * OPSIZ;
+ srcp2 += 1 * OPSIZ;
+ len -= 1;
+ if (OP_T_THRES <= 3 * OPSIZ && len == 0)
+ goto do0;
+ /* Fall through. */
+ }
+
+ do
+ {
+ a0 = ((op_t *) srcp1)[0];
+ b0 = ((op_t *) srcp2)[0];
+ x = MERGE(a2, shl, a3, shr);
+ if (x != b3)
+ return CMP_LT_OR_GT (x, b3);
+
+ do3:
+ a1 = ((op_t *) srcp1)[1];
+ b1 = ((op_t *) srcp2)[1];
+ x = MERGE(a3, shl, a0, shr);
+ if (x != b0)
+ return CMP_LT_OR_GT (x, b0);
+
+ do2:
+ a2 = ((op_t *) srcp1)[2];
+ b2 = ((op_t *) srcp2)[2];
+ x = MERGE(a0, shl, a1, shr);
+ if (x != b1)
+ return CMP_LT_OR_GT (x, b1);
+
+ do1:
+ a3 = ((op_t *) srcp1)[3];
+ b3 = ((op_t *) srcp2)[3];
+ x = MERGE(a1, shl, a2, shr);
+ if (x != b2)
+ return CMP_LT_OR_GT (x, b2);
+
+ srcp1 += 4 * OPSIZ;
+ srcp2 += 4 * OPSIZ;
+ len -= 4;
+ }
+ while (len != 0);
+
+ /* This is the right position for do0. Please don't move
+ it into the loop. */
+ do0:
+ x = MERGE(a2, shl, a3, shr);
+ if (x != b3)
+ return CMP_LT_OR_GT (x, b3);
+ return 0;
+}
+
+int
+memcmp (s1, s2, len)
+ const __ptr_t s1;
+ const __ptr_t s2;
+ size_t len;
+{
+ op_t a0;
+ op_t b0;
+ long int srcp1 = (long int) s1;
+ long int srcp2 = (long int) s2;
+ op_t res;
+
+ if (len >= OP_T_THRES)
+ {
+ /* There are at least some bytes to compare. No need to test
+ for LEN == 0 in this alignment loop. */
+ while (srcp2 % OPSIZ != 0)
+ {
+ a0 = ((byte *) srcp1)[0];
+ b0 = ((byte *) srcp2)[0];
+ srcp1 += 1;
+ srcp2 += 1;
+ res = a0 - b0;
+ if (res != 0)
+ return res;
+ len -= 1;
+ }
+
+ /* SRCP2 is now aligned for memory operations on `op_t'.
+ SRCP1 alignment determines if we can do a simple,
+ aligned compare or need to shuffle bits. */
+
+ if (srcp1 % OPSIZ == 0)
+ res = memcmp_common_alignment (srcp1, srcp2, len / OPSIZ);
+ else
+ res = memcmp_not_common_alignment (srcp1, srcp2, len / OPSIZ);
+ if (res != 0)
+ return res;
+
+ /* Number of bytes remaining in the interval [0..OPSIZ-1]. */
+ srcp1 += len & -OPSIZ;
+ srcp2 += len & -OPSIZ;
+ len %= OPSIZ;
+ }
+
+ /* There are just a few bytes to compare. Use byte memory operations. */
+ while (len != 0)
+ {
+ a0 = ((byte *) srcp1)[0];
+ b0 = ((byte *) srcp2)[0];
+ srcp1 += 1;
+ srcp2 += 1;
+ res = a0 - b0;
+ if (res != 0)
+ return res;
+ len -= 1;
+ }
+
+ return 0;
+}
+
+#ifdef weak_alias
+#undef bcmp
+weak_alias (memcmp, bcmp)
+#endif
diff --git a/sysdeps/generic/memcopy.h b/sysdeps/generic/memcopy.h
new file mode 100644
index 0000000..262b8aa
--- /dev/null
+++ b/sysdeps/generic/memcopy.h
@@ -0,0 +1,149 @@
+/* memcopy.h -- definitions for memory copy functions. Generic C version.
+ Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+/* The strategy of the memory functions is:
+
+ 1. Copy bytes until the destination pointer is aligned.
+
+ 2. Copy words in unrolled loops. If the source and destination
+ are not aligned in the same way, use word memory operations,
+ but shift and merge two read words before writing.
+
+ 3. Copy the few remaining bytes.
+
+ This is fast on processors that have at least 10 registers for
+ allocation by GCC, and that can access memory at reg+const in one
+ instruction.
+
+ I made an "exhaustive" test of this memmove when I wrote it,
+ exhaustive in the sense that I tried all alignment and length
+ combinations, with and without overlap. */
+
+#include <sys/cdefs.h>
+#include <endian.h>
+
+/* The macros defined in this file are:
+
+ BYTE_COPY_FWD(dst_beg_ptr, src_beg_ptr, nbytes_to_copy)
+
+ BYTE_COPY_BWD(dst_end_ptr, src_end_ptr, nbytes_to_copy)
+
+ WORD_COPY_FWD(dst_beg_ptr, src_beg_ptr, nbytes_remaining, nbytes_to_copy)
+
+ WORD_COPY_BWD(dst_end_ptr, src_end_ptr, nbytes_remaining, nbytes_to_copy)
+
+ MERGE(old_word, sh_1, new_word, sh_2)
+ [I fail to understand. I feel stupid. --roland]
+*/
+
+/* Type to use for aligned memory operations.
+ This should normally be the biggest type supported by a single load
+ and store. */
+#define op_t unsigned long int
+#define OPSIZ (sizeof(op_t))
+
+/* Type to use for unaligned operations. */
+typedef unsigned char byte;
+
+/* Optimal type for storing bytes in registers. */
+#define reg_char char
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define MERGE(w0, sh_1, w1, sh_2) (((w0) >> (sh_1)) | ((w1) << (sh_2)))
+#endif
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define MERGE(w0, sh_1, w1, sh_2) (((w0) << (sh_1)) | ((w1) >> (sh_2)))
+#endif
+
+/* Copy exactly NBYTES bytes from SRC_BP to DST_BP,
+ without any assumptions about alignment of the pointers. */
+#define BYTE_COPY_FWD(dst_bp, src_bp, nbytes) \
+ do \
+ { \
+ size_t __nbytes = (nbytes); \
+ while (__nbytes > 0) \
+ { \
+ byte __x = ((byte *) src_bp)[0]; \
+ src_bp += 1; \
+ __nbytes -= 1; \
+ ((byte *) dst_bp)[0] = __x; \
+ dst_bp += 1; \
+ } \
+ } while (0)
+
+/* Copy exactly NBYTES_TO_COPY bytes from SRC_END_PTR to DST_END_PTR,
+ beginning at the bytes right before the pointers and continuing towards
+ smaller addresses. Don't assume anything about alignment of the
+ pointers. */
+#define BYTE_COPY_BWD(dst_ep, src_ep, nbytes) \
+ do \
+ { \
+ size_t __nbytes = (nbytes); \
+ while (__nbytes > 0) \
+ { \
+ byte __x; \
+ src_ep -= 1; \
+ __x = ((byte *) src_ep)[0]; \
+ dst_ep -= 1; \
+ __nbytes -= 1; \
+ ((byte *) dst_ep)[0] = __x; \
+ } \
+ } while (0)
+
+/* Copy *up to* NBYTES bytes from SRC_BP to DST_BP, with
+ the assumption that DST_BP is aligned on an OPSIZ multiple. If
+ not all bytes could be easily copied, store remaining number of bytes
+ in NBYTES_LEFT, otherwise store 0. */
+extern void _wordcopy_fwd_aligned __P ((long int, long int, size_t));
+extern void _wordcopy_fwd_dest_aligned __P ((long int, long int, size_t));
+#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
+ do \
+ { \
+ if (src_bp % OPSIZ == 0) \
+ _wordcopy_fwd_aligned (dst_bp, src_bp, (nbytes) / OPSIZ); \
+ else \
+ _wordcopy_fwd_dest_aligned (dst_bp, src_bp, (nbytes) / OPSIZ); \
+ src_bp += (nbytes) & -OPSIZ; \
+ dst_bp += (nbytes) & -OPSIZ; \
+ (nbytes_left) = (nbytes) % OPSIZ; \
+ } while (0)
+
+/* Copy *up to* NBYTES_TO_COPY bytes from SRC_END_PTR to DST_END_PTR,
+ beginning at the words (of type op_t) right before the pointers and
+ continuing towards smaller addresses. May take advantage of that
+ DST_END_PTR is aligned on an OPSIZ multiple. If not all bytes could be
+ easily copied, store remaining number of bytes in NBYTES_REMAINING,
+ otherwise store 0. */
+extern void _wordcopy_bwd_aligned __P ((long int, long int, size_t));
+extern void _wordcopy_bwd_dest_aligned __P ((long int, long int, size_t));
+#define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \
+ do \
+ { \
+ if (src_ep % OPSIZ == 0) \
+ _wordcopy_bwd_aligned (dst_ep, src_ep, (nbytes) / OPSIZ); \
+ else \
+ _wordcopy_bwd_dest_aligned (dst_ep, src_ep, (nbytes) / OPSIZ); \
+ src_ep -= (nbytes) & -OPSIZ; \
+ dst_ep -= (nbytes) & -OPSIZ; \
+ (nbytes_left) = (nbytes) % OPSIZ; \
+ } while (0)
+
+
+/* Threshold value for when to enter the unrolled loops. */
+#define OP_T_THRES 16
diff --git a/sysdeps/generic/memcpy.c b/sysdeps/generic/memcpy.c
new file mode 100644
index 0000000..222d358
--- /dev/null
+++ b/sysdeps/generic/memcpy.c
@@ -0,0 +1,55 @@
+/* memcpy -- copy memory to memory until the specified number of bytes
+ has been copied. Overlap is NOT handled correctly.
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <memcopy.h>
+
+PTR
+DEFUN(memcpy, (dstpp, srcpp, len),
+ PTR dstpp AND CONST PTR srcpp AND size_t len)
+{
+ unsigned long int dstp = (long int) dstpp;
+ unsigned long int srcp = (long int) srcpp;
+
+ /* Copy from the beginning to the end. */
+
+ /* If there not too few bytes to copy, use word copy. */
+ if (len >= OP_T_THRES)
+ {
+ /* Copy just a few bytes to make DSTP aligned. */
+ len -= (-dstp) % OPSIZ;
+ BYTE_COPY_FWD (dstp, srcp, (-dstp) % OPSIZ);
+
+ /* Copy from SRCP to DSTP taking advantage of the known
+ alignment of DSTP. Number of bytes remaining is put
+ in the third argumnet, i.e. in LEN. This number may
+ vary from machine to machine. */
+
+ WORD_COPY_FWD (dstp, srcp, len, len);
+
+ /* Fall out and copy the tail. */
+ }
+
+ /* There are just a few bytes to copy. Use byte memory operations. */
+ BYTE_COPY_FWD (dstp, srcp, len);
+
+ return dstpp;
+}
diff --git a/sysdeps/generic/memmem.c b/sysdeps/generic/memmem.c
new file mode 100644
index 0000000..79b4544
--- /dev/null
+++ b/sysdeps/generic/memmem.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <string.h>
+
+
+/* Return the first occurrence of NEEDLE in HAYSTACK. */
+PTR
+DEFUN(memmem, (haystack, haystack_len,
+ needle, needle_len),
+ CONST PTRCONST haystack AND CONST size_t haystack_len AND
+ CONST PTRCONST needle AND CONST size_t needle_len)
+{
+ register CONST char *begin;
+ register CONST char *CONST last_possible
+ = (CONST char *) haystack + haystack_len - needle_len;
+
+ if (needle_len == 0)
+ return (PTR) &((CONST char *) haystack)[needle_len - 1];
+
+ for (begin = (CONST char *) haystack; begin <= last_possible; ++begin)
+ if (begin[0] == ((CONST char *) needle)[0] &&
+ !memcmp ((CONST PTR) &begin[1],
+ (CONST PTR) ((CONST char *) needle + 1),
+ needle_len - 1))
+ return (PTR) begin;
+
+ return NULL;
+}
diff --git a/sysdeps/generic/memmove.c b/sysdeps/generic/memmove.c
new file mode 100644
index 0000000..e301681
--- /dev/null
+++ b/sysdeps/generic/memmove.c
@@ -0,0 +1,99 @@
+/* memmove -- copy memory to memory until the specified number of bytes
+ has been copied. Overlap is handled correctly.
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <memcopy.h>
+
+/* All this is so that bcopy.c can #include
+ this file after defining some things. */
+#ifndef a1
+#define a1 dest /* First arg is DEST. */
+#define a1const
+#define a2 src /* Second arg is SRC. */
+#define a2const CONST
+#endif
+#if !defined(RETURN) || !defined(rettype)
+#define RETURN(s) return (s) /* Return DEST. */
+#define rettype PTR
+#endif
+
+rettype
+DEFUN(memmove, (a1, a2, len),
+ a1const PTR a1 AND a2const PTR a2 AND size_t len)
+{
+ unsigned long int dstp = (long int) dest;
+ unsigned long int srcp = (long int) src;
+
+ /* This test makes the forward copying code be used whenever possible.
+ Reduces the working set. */
+ if (dstp - srcp >= len) /* *Unsigned* compare! */
+ {
+ /* Copy from the beginning to the end. */
+
+ /* If there not too few bytes to copy, use word copy. */
+ if (len >= OP_T_THRES)
+ {
+ /* Copy just a few bytes to make DSTP aligned. */
+ len -= (-dstp) % OPSIZ;
+ BYTE_COPY_FWD (dstp, srcp, (-dstp) % OPSIZ);
+
+ /* Copy from SRCP to DSTP taking advantage of the known
+ alignment of DSTP. Number of bytes remaining is put
+ in the third argumnet, i.e. in LEN. This number may
+ vary from machine to machine. */
+
+ WORD_COPY_FWD (dstp, srcp, len, len);
+
+ /* Fall out and copy the tail. */
+ }
+
+ /* There are just a few bytes to copy. Use byte memory operations. */
+ BYTE_COPY_FWD (dstp, srcp, len);
+ }
+ else
+ {
+ /* Copy from the end to the beginning. */
+ srcp += len;
+ dstp += len;
+
+ /* If there not too few bytes to copy, use word copy. */
+ if (len >= OP_T_THRES)
+ {
+ /* Copy just a few bytes to make DSTP aligned. */
+ len -= dstp % OPSIZ;
+ BYTE_COPY_BWD (dstp, srcp, dstp % OPSIZ);
+
+ /* Copy from SRCP to DSTP taking advantage of the known
+ alignment of DSTP. Number of bytes remaining is put
+ in the third argumnet, i.e. in LEN. This number may
+ vary from machine to machine. */
+
+ WORD_COPY_BWD (dstp, srcp, len, len);
+
+ /* Fall out and copy the tail. */
+ }
+
+ /* There are just a few bytes to copy. Use byte memory operations. */
+ BYTE_COPY_BWD (dstp, srcp, len);
+ }
+
+ RETURN(dest);
+}
diff --git a/sysdeps/generic/memset.c b/sysdeps/generic/memset.c
new file mode 100644
index 0000000..6dee4e2
--- /dev/null
+++ b/sysdeps/generic/memset.c
@@ -0,0 +1,85 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <memcopy.h>
+
+PTR
+DEFUN(memset, (dstpp, c, len), PTR dstpp AND int c AND size_t len)
+{
+ long int dstp = (long int) dstpp;
+
+ if (len >= 8)
+ {
+ size_t xlen;
+ op_t cccc;
+
+ cccc = (unsigned char) c;
+ cccc |= cccc << 8;
+ cccc |= cccc << 16;
+ if (OPSIZ > 4)
+ cccc |= cccc << 32;
+
+ /* There are at least some bytes to set.
+ No need to test for LEN == 0 in this alignment loop. */
+ while (dstp % OPSIZ != 0)
+ {
+ ((byte *) dstp)[0] = c;
+ dstp += 1;
+ len -= 1;
+ }
+
+ /* Write 8 `op_t' per iteration until less than 8 `op_t' remain. */
+ xlen = len / (OPSIZ * 8);
+ while (xlen > 0)
+ {
+ ((op_t *) dstp)[0] = cccc;
+ ((op_t *) dstp)[1] = cccc;
+ ((op_t *) dstp)[2] = cccc;
+ ((op_t *) dstp)[3] = cccc;
+ ((op_t *) dstp)[4] = cccc;
+ ((op_t *) dstp)[5] = cccc;
+ ((op_t *) dstp)[6] = cccc;
+ ((op_t *) dstp)[7] = cccc;
+ dstp += 8 * OPSIZ;
+ xlen -= 1;
+ }
+ len %= OPSIZ * 8;
+
+ /* Write 1 `op_t' per iteration until less than OPSIZ bytes remain. */
+ xlen = len / OPSIZ;
+ while (xlen > 0)
+ {
+ ((op_t *) dstp)[0] = cccc;
+ dstp += OPSIZ;
+ xlen -= 1;
+ }
+ len %= OPSIZ;
+ }
+
+ /* Write the last few bytes. */
+ while (len > 0)
+ {
+ ((byte *) dstp)[0] = c;
+ dstp += 1;
+ len -= 1;
+ }
+
+ return dstpp;
+}
diff --git a/sysdeps/generic/mig-reply.c b/sysdeps/generic/mig-reply.c
new file mode 100644
index 0000000..54712a8
--- /dev/null
+++ b/sysdeps/generic/mig-reply.c
@@ -0,0 +1,53 @@
+/* Copyright (C) 1992 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. */
+
+#include <mach.h>
+
+/* These functions are called by MiG-generated code. */
+
+static mach_port_t reply_port;
+
+/* Called by MiG to get a reply port. */
+mach_port_t
+__mig_get_reply_port (void)
+{
+ if (reply_port == MACH_PORT_NULL)
+ reply_port = __mach_reply_port ();
+
+ return reply_port;
+}
+
+/* Called by MiG to deallocate the reply port. */
+void
+__mig_dealloc_reply_port (void)
+{
+ mach_port_t port = reply_port;
+ reply_port = MACH_PORT_NULL; /* So the mod_refs RPC won't use it. */
+ __mach_port_mod_refs (__mach_task_self (), port,
+ MACH_PORT_RIGHT_RECEIVE, -1);
+}
+
+
+/* Called at startup with CPROC == NULL. cthreads has a different version
+ of this function that is sometimes called with a `cproc_t' pointer. */
+void
+__mig_init (void *cproc)
+{
+ if (cproc == 0)
+ reply_port = MACH_PORT_NULL;
+}
diff --git a/sysdeps/generic/mod_1.c b/sysdeps/generic/mod_1.c
new file mode 100644
index 0000000..ae4ed09
--- /dev/null
+++ b/sysdeps/generic/mod_1.c
@@ -0,0 +1,198 @@
+/* __mpn_mod_1(dividend_ptr, dividend_size, divisor_limb) --
+ Divide (DIVIDEND_PTR,,DIVIDEND_SIZE) by DIVISOR_LIMB.
+ Return the single-limb remainder.
+ There are no constraints on the value of the divisor.
+
+ QUOT_PTR and DIVIDEND_PTR might point to the same limb.
+
+Copyright (C) 1991, 1993, 1994, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include "longlong.h"
+
+#ifndef UMUL_TIME
+#define UMUL_TIME 1
+#endif
+
+#ifndef UDIV_TIME
+#define UDIV_TIME UMUL_TIME
+#endif
+
+/* FIXME: We should be using invert_limb (or invert_normalized_limb)
+ here (not udiv_qrnnd). */
+
+mp_limb
+#if __STDC__
+__mpn_mod_1 (mp_srcptr dividend_ptr, mp_size_t dividend_size,
+ mp_limb divisor_limb)
+#else
+__mpn_mod_1 (dividend_ptr, dividend_size, divisor_limb)
+ mp_srcptr dividend_ptr;
+ mp_size_t dividend_size;
+ mp_limb divisor_limb;
+#endif
+{
+ mp_size_t i;
+ mp_limb n1, n0, r;
+ int dummy;
+
+ /* Botch: Should this be handled at all? Rely on callers? */
+ if (dividend_size == 0)
+ return 0;
+
+ /* If multiplication is much faster than division, and the
+ dividend is large, pre-invert the divisor, and use
+ only multiplications in the inner loop. */
+
+ /* This test should be read:
+ Does it ever help to use udiv_qrnnd_preinv?
+ && Does what we save compensate for the inversion overhead? */
+ if (UDIV_TIME > (2 * UMUL_TIME + 6)
+ && (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME)
+ {
+ int normalization_steps;
+
+ count_leading_zeros (normalization_steps, divisor_limb);
+ if (normalization_steps != 0)
+ {
+ mp_limb divisor_limb_inverted;
+
+ divisor_limb <<= normalization_steps;
+
+ /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The
+ result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+ most significant bit (with weight 2**N) implicit. */
+
+ /* Special case for DIVISOR_LIMB == 100...000. */
+ if (divisor_limb << 1 == 0)
+ divisor_limb_inverted = ~(mp_limb) 0;
+ else
+ udiv_qrnnd (divisor_limb_inverted, dummy,
+ -divisor_limb, 0, divisor_limb);
+
+ n1 = dividend_ptr[dividend_size - 1];
+ r = n1 >> (BITS_PER_MP_LIMB - normalization_steps);
+
+ /* Possible optimization:
+ if (r == 0
+ && divisor_limb > ((n1 << normalization_steps)
+ | (dividend_ptr[dividend_size - 2] >> ...)))
+ ...one division less... */
+
+ for (i = dividend_size - 2; i >= 0; i--)
+ {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd_preinv (dummy, r, r,
+ ((n1 << normalization_steps)
+ | (n0 >> (BITS_PER_MP_LIMB - normalization_steps))),
+ divisor_limb, divisor_limb_inverted);
+ n1 = n0;
+ }
+ udiv_qrnnd_preinv (dummy, r, r,
+ n1 << normalization_steps,
+ divisor_limb, divisor_limb_inverted);
+ return r >> normalization_steps;
+ }
+ else
+ {
+ mp_limb divisor_limb_inverted;
+
+ /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The
+ result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the
+ most significant bit (with weight 2**N) implicit. */
+
+ /* Special case for DIVISOR_LIMB == 100...000. */
+ if (divisor_limb << 1 == 0)
+ divisor_limb_inverted = ~(mp_limb) 0;
+ else
+ udiv_qrnnd (divisor_limb_inverted, dummy,
+ -divisor_limb, 0, divisor_limb);
+
+ i = dividend_size - 1;
+ r = dividend_ptr[i];
+
+ if (r >= divisor_limb)
+ r = 0;
+ else
+ i--;
+
+ for (; i >= 0; i--)
+ {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd_preinv (dummy, r, r,
+ n0, divisor_limb, divisor_limb_inverted);
+ }
+ return r;
+ }
+ }
+ else
+ {
+ if (UDIV_NEEDS_NORMALIZATION)
+ {
+ int normalization_steps;
+
+ count_leading_zeros (normalization_steps, divisor_limb);
+ if (normalization_steps != 0)
+ {
+ divisor_limb <<= normalization_steps;
+
+ n1 = dividend_ptr[dividend_size - 1];
+ r = n1 >> (BITS_PER_MP_LIMB - normalization_steps);
+
+ /* Possible optimization:
+ if (r == 0
+ && divisor_limb > ((n1 << normalization_steps)
+ | (dividend_ptr[dividend_size - 2] >> ...)))
+ ...one division less... */
+
+ for (i = dividend_size - 2; i >= 0; i--)
+ {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd (dummy, r, r,
+ ((n1 << normalization_steps)
+ | (n0 >> (BITS_PER_MP_LIMB - normalization_steps))),
+ divisor_limb);
+ n1 = n0;
+ }
+ udiv_qrnnd (dummy, r, r,
+ n1 << normalization_steps,
+ divisor_limb);
+ return r >> normalization_steps;
+ }
+ }
+ /* No normalization needed, either because udiv_qrnnd doesn't require
+ it, or because DIVISOR_LIMB is already normalized. */
+
+ i = dividend_size - 1;
+ r = dividend_ptr[i];
+
+ if (r >= divisor_limb)
+ r = 0;
+ else
+ i--;
+
+ for (; i >= 0; i--)
+ {
+ n0 = dividend_ptr[i];
+ udiv_qrnnd (dummy, r, r, n0, divisor_limb);
+ }
+ return r;
+ }
+}
diff --git a/sysdeps/generic/modf.c b/sysdeps/generic/modf.c
new file mode 100644
index 0000000..5305caf
--- /dev/null
+++ b/sysdeps/generic/modf.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+
+#undef modf
+
+/* Break VALUE into integral and fractional parts. */
+double
+DEFUN(modf, (value, iptr), double value AND double *iptr)
+{
+ register double ipart = floor(value);
+ *iptr = ipart;
+ return value - ipart;
+}
diff --git a/sysdeps/generic/morecore.c b/sysdeps/generic/morecore.c
new file mode 100644
index 0000000..7c83e4a
--- /dev/null
+++ b/sysdeps/generic/morecore.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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 General Public License as published by
+the Free Software Foundation; either version 2, 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the GNU C Library; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#ifndef _MALLOC_INTERNAL
+#define _MALLOC_INTERNAL
+#include <malloc.h>
+#endif
+
+#ifndef __GNU_LIBRARY__
+#define __sbrk sbrk
+#endif
+
+#ifdef __GNU_LIBRARY__
+/* It is best not to declare this and cast its result on foreign operating
+ systems with potentially hostile include files. */
+extern __ptr_t __sbrk __P ((int increment));
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+/* Allocate INCREMENT more bytes of data space,
+ and return the start of data space, or NULL on errors.
+ If INCREMENT is negative, shrink data space. */
+__ptr_t
+__default_morecore (increment)
+ __malloc_ptrdiff_t increment;
+{
+ __ptr_t result = (__ptr_t) __sbrk (increment);
+ if (result == (__ptr_t) -1)
+ return NULL;
+ return result;
+}
diff --git a/sysdeps/generic/mul.c b/sysdeps/generic/mul.c
new file mode 100644
index 0000000..cd2acb5
--- /dev/null
+++ b/sysdeps/generic/mul.c
@@ -0,0 +1,147 @@
+/* __mpn_mul -- Multiply two natural numbers.
+
+Copyright (C) 1991, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
+/* Multiply the natural numbers u (pointed to by UP, with USIZE limbs)
+ and v (pointed to by VP, with VSIZE limbs), and store the result at
+ PRODP. USIZE + VSIZE limbs are always stored, but if the input
+ operands are normalized. Return the most significant limb of the
+ result.
+
+ NOTE: The space pointed to by PRODP is overwritten before finished
+ with U and V, so overlap is an error.
+
+ Argument constraints:
+ 1. USIZE >= VSIZE.
+ 2. PRODP != UP and PRODP != VP, i.e. the destination
+ must be distinct from the multiplier and the multiplicand. */
+
+/* If KARATSUBA_THRESHOLD is not already defined, define it to a
+ value which is good on most machines. */
+#ifndef KARATSUBA_THRESHOLD
+#define KARATSUBA_THRESHOLD 32
+#endif
+
+mp_limb
+#if __STDC__
+__mpn_mul (mp_ptr prodp,
+ mp_srcptr up, mp_size_t usize,
+ mp_srcptr vp, mp_size_t vsize)
+#else
+__mpn_mul (prodp, up, usize, vp, vsize)
+ mp_ptr prodp;
+ mp_srcptr up;
+ mp_size_t usize;
+ mp_srcptr vp;
+ mp_size_t vsize;
+#endif
+{
+ mp_ptr prod_endp = prodp + usize + vsize - 1;
+ mp_limb cy;
+ mp_ptr tspace;
+
+ if (vsize < KARATSUBA_THRESHOLD)
+ {
+ /* Handle simple cases with traditional multiplication.
+
+ This is the most critical code of the entire function. All
+ multiplies rely on this, both small and huge. Small ones arrive
+ here immediately. Huge ones arrive here as this is the base case
+ for Karatsuba's recursive algorithm below. */
+ mp_size_t i;
+ mp_limb cy_limb;
+ mp_limb v_limb;
+
+ if (vsize == 0)
+ return 0;
+
+ /* Multiply by the first limb in V separately, as the result can be
+ stored (not added) to PROD. We also avoid a loop for zeroing. */
+ v_limb = vp[0];
+ if (v_limb <= 1)
+ {
+ if (v_limb == 1)
+ MPN_COPY (prodp, up, usize);
+ else
+ MPN_ZERO (prodp, usize);
+ cy_limb = 0;
+ }
+ else
+ cy_limb = __mpn_mul_1 (prodp, up, usize, v_limb);
+
+ prodp[usize] = cy_limb;
+ prodp++;
+
+ /* For each iteration in the outer loop, multiply one limb from
+ U with one limb from V, and add it to PROD. */
+ for (i = 1; i < vsize; i++)
+ {
+ v_limb = vp[i];
+ if (v_limb <= 1)
+ {
+ cy_limb = 0;
+ if (v_limb == 1)
+ cy_limb = __mpn_add_n (prodp, prodp, up, usize);
+ }
+ else
+ cy_limb = __mpn_addmul_1 (prodp, up, usize, v_limb);
+
+ prodp[usize] = cy_limb;
+ prodp++;
+ }
+ return cy_limb;
+ }
+
+ tspace = (mp_ptr) alloca (2 * vsize * BYTES_PER_MP_LIMB);
+ MPN_MUL_N_RECURSE (prodp, up, vp, vsize, tspace);
+
+ prodp += vsize;
+ up += vsize;
+ usize -= vsize;
+ if (usize >= vsize)
+ {
+ mp_ptr tp = (mp_ptr) alloca (2 * vsize * BYTES_PER_MP_LIMB);
+ do
+ {
+ MPN_MUL_N_RECURSE (tp, up, vp, vsize, tspace);
+ cy = __mpn_add_n (prodp, prodp, tp, vsize);
+ __mpn_add_1 (prodp + vsize, tp + vsize, vsize, cy);
+ prodp += vsize;
+ up += vsize;
+ usize -= vsize;
+ }
+ while (usize >= vsize);
+ }
+
+ /* True: usize < vsize. */
+
+ /* Make life simple: Recurse. */
+
+ if (usize != 0)
+ {
+ __mpn_mul (tspace, vp, vsize, up, usize);
+ cy = __mpn_add_n (prodp, prodp, tspace, vsize);
+ __mpn_add_1 (prodp + vsize, tspace + vsize, usize, cy);
+ }
+
+ return *prod_endp;
+}
diff --git a/sysdeps/generic/mul_1.c b/sysdeps/generic/mul_1.c
new file mode 100644
index 0000000..37dbc33
--- /dev/null
+++ b/sysdeps/generic/mul_1.c
@@ -0,0 +1,58 @@
+/* __mpn_mul_1 -- Multiply a limb vector with a single limb and
+ store the product in a second limb vector.
+
+Copyright (C) 1991, 1992, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include "longlong.h"
+
+mp_limb
+__mpn_mul_1 (res_ptr, s1_ptr, s1_size, s2_limb)
+ register mp_ptr res_ptr;
+ register mp_srcptr s1_ptr;
+ mp_size_t s1_size;
+ register mp_limb s2_limb;
+{
+ register mp_limb cy_limb;
+ register mp_size_t j;
+ register mp_limb prod_high, prod_low;
+
+ /* The loop counter and index J goes from -S1_SIZE to -1. This way
+ the loop becomes faster. */
+ j = -s1_size;
+
+ /* Offset the base pointers to compensate for the negative indices. */
+ s1_ptr -= j;
+ res_ptr -= j;
+
+ cy_limb = 0;
+ do
+ {
+ umul_ppmm (prod_high, prod_low, s1_ptr[j], s2_limb);
+
+ prod_low += cy_limb;
+ cy_limb = (prod_low < cy_limb) + prod_high;
+
+ res_ptr[j] = prod_low;
+ }
+ while (++j != 0);
+
+ return cy_limb;
+}
diff --git a/sysdeps/generic/mul_n.c b/sysdeps/generic/mul_n.c
new file mode 100644
index 0000000..7900988
--- /dev/null
+++ b/sysdeps/generic/mul_n.c
@@ -0,0 +1,420 @@
+/* __mpn_mul_n -- Multiply two natural numbers of length n.
+
+Copyright (C) 1991, 1992, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
+/* Multiply the natural numbers u (pointed to by UP) and v (pointed to by VP),
+ both with SIZE limbs, and store the result at PRODP. 2 * SIZE limbs are
+ always stored. Return the most significant limb.
+
+ Argument constraints:
+ 1. PRODP != UP and PRODP != VP, i.e. the destination
+ must be distinct from the multiplier and the multiplicand. */
+
+/* If KARATSUBA_THRESHOLD is not already defined, define it to a
+ value which is good on most machines. */
+#ifndef KARATSUBA_THRESHOLD
+#define KARATSUBA_THRESHOLD 32
+#endif
+
+/* The code can't handle KARATSUBA_THRESHOLD smaller than 2. */
+#if KARATSUBA_THRESHOLD < 2
+#undef KARATSUBA_THRESHOLD
+#define KARATSUBA_THRESHOLD 2
+#endif
+
+void
+#if __STDC__
+____mpn_mul_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_ptr);
+#else
+____mpn_mul_n ();
+#endif
+
+/* Handle simple cases with traditional multiplication.
+
+ This is the most critical code of multiplication. All multiplies rely
+ on this, both small and huge. Small ones arrive here immediately. Huge
+ ones arrive here as this is the base case for Karatsuba's recursive
+ algorithm below. */
+
+void
+#if __STDC__
+____mpn_mul_n_basecase (mp_ptr prodp, mp_srcptr up, mp_srcptr vp, mp_size_t size)
+#else
+____mpn_mul_n_basecase (prodp, up, vp, size)
+ mp_ptr prodp;
+ mp_srcptr up;
+ mp_srcptr vp;
+ mp_size_t size;
+#endif
+{
+ mp_size_t i;
+ mp_limb cy_limb;
+ mp_limb v_limb;
+
+ /* Multiply by the first limb in V separately, as the result can be
+ stored (not added) to PROD. We also avoid a loop for zeroing. */
+ v_limb = vp[0];
+ if (v_limb <= 1)
+ {
+ if (v_limb == 1)
+ MPN_COPY (prodp, up, size);
+ else
+ MPN_ZERO (prodp, size);
+ cy_limb = 0;
+ }
+ else
+ cy_limb = __mpn_mul_1 (prodp, up, size, v_limb);
+
+ prodp[size] = cy_limb;
+ prodp++;
+
+ /* For each iteration in the outer loop, multiply one limb from
+ U with one limb from V, and add it to PROD. */
+ for (i = 1; i < size; i++)
+ {
+ v_limb = vp[i];
+ if (v_limb <= 1)
+ {
+ cy_limb = 0;
+ if (v_limb == 1)
+ cy_limb = __mpn_add_n (prodp, prodp, up, size);
+ }
+ else
+ cy_limb = __mpn_addmul_1 (prodp, up, size, v_limb);
+
+ prodp[size] = cy_limb;
+ prodp++;
+ }
+}
+
+void
+#if __STDC__
+____mpn_mul_n (mp_ptr prodp,
+ mp_srcptr up, mp_srcptr vp, mp_size_t size, mp_ptr tspace)
+#else
+____mpn_mul_n (prodp, up, vp, size, tspace)
+ mp_ptr prodp;
+ mp_srcptr up;
+ mp_srcptr vp;
+ mp_size_t size;
+ mp_ptr tspace;
+#endif
+{
+ if ((size & 1) != 0)
+ {
+ /* The size is odd, the code code below doesn't handle that.
+ Multiply the least significant (size - 1) limbs with a recursive
+ call, and handle the most significant limb of S1 and S2
+ separately. */
+ /* A slightly faster way to do this would be to make the Karatsuba
+ code below behave as if the size were even, and let it check for
+ odd size in the end. I.e., in essence move this code to the end.
+ Doing so would save us a recursive call, and potentially make the
+ stack grow a lot less. */
+
+ mp_size_t esize = size - 1; /* even size */
+ mp_limb cy_limb;
+
+ MPN_MUL_N_RECURSE (prodp, up, vp, esize, tspace);
+ cy_limb = __mpn_addmul_1 (prodp + esize, up, esize, vp[esize]);
+ prodp[esize + esize] = cy_limb;
+ cy_limb = __mpn_addmul_1 (prodp + esize, vp, size, up[esize]);
+
+ prodp[esize + size] = cy_limb;
+ }
+ else
+ {
+ /* Anatolij Alekseevich Karatsuba's divide-and-conquer algorithm.
+
+ Split U in two pieces, U1 and U0, such that
+ U = U0 + U1*(B**n),
+ and V in V1 and V0, such that
+ V = V0 + V1*(B**n).
+
+ UV is then computed recursively using the identity
+
+ 2n n n n
+ UV = (B + B )U V + B (U -U )(V -V ) + (B + 1)U V
+ 1 1 1 0 0 1 0 0
+
+ Where B = 2**BITS_PER_MP_LIMB. */
+
+ mp_size_t hsize = size >> 1;
+ mp_limb cy;
+ int negflg;
+
+ /*** Product H. ________________ ________________
+ |_____U1 x V1____||____U0 x V0_____| */
+ /* Put result in upper part of PROD and pass low part of TSPACE
+ as new TSPACE. */
+ MPN_MUL_N_RECURSE (prodp + size, up + hsize, vp + hsize, hsize, tspace);
+
+ /*** Product M. ________________
+ |_(U1-U0)(V0-V1)_| */
+ if (__mpn_cmp (up + hsize, up, hsize) >= 0)
+ {
+ __mpn_sub_n (prodp, up + hsize, up, hsize);
+ negflg = 0;
+ }
+ else
+ {
+ __mpn_sub_n (prodp, up, up + hsize, hsize);
+ negflg = 1;
+ }
+ if (__mpn_cmp (vp + hsize, vp, hsize) >= 0)
+ {
+ __mpn_sub_n (prodp + hsize, vp + hsize, vp, hsize);
+ negflg ^= 1;
+ }
+ else
+ {
+ __mpn_sub_n (prodp + hsize, vp, vp + hsize, hsize);
+ /* No change of NEGFLG. */
+ }
+ /* Read temporary operands from low part of PROD.
+ Put result in low part of TSPACE using upper part of TSPACE
+ as new TSPACE. */
+ MPN_MUL_N_RECURSE (tspace, prodp, prodp + hsize, hsize, tspace + size);
+
+ /*** Add/copy product H. */
+ MPN_COPY (prodp + hsize, prodp + size, hsize);
+ cy = __mpn_add_n (prodp + size, prodp + size, prodp + size + hsize, hsize);
+
+ /*** Add product M (if NEGFLG M is a negative number). */
+ if (negflg)
+ cy -= __mpn_sub_n (prodp + hsize, prodp + hsize, tspace, size);
+ else
+ cy += __mpn_add_n (prodp + hsize, prodp + hsize, tspace, size);
+
+ /*** Product L. ________________ ________________
+ |________________||____U0 x V0_____| */
+ /* Read temporary operands from low part of PROD.
+ Put result in low part of TSPACE using upper part of TSPACE
+ as new TSPACE. */
+ MPN_MUL_N_RECURSE (tspace, up, vp, hsize, tspace + size);
+
+ /*** Add/copy Product L (twice). */
+
+ cy += __mpn_add_n (prodp + hsize, prodp + hsize, tspace, size);
+ if (cy)
+ {
+ if (cy > 0)
+ __mpn_add_1 (prodp + hsize + size, prodp + hsize + size, hsize, cy);
+ else
+ {
+ __mpn_sub_1 (prodp + hsize + size, prodp + hsize + size, hsize, cy);
+ abort ();
+ }
+ }
+
+ MPN_COPY (prodp, tspace, hsize);
+ cy = __mpn_add_n (prodp + hsize, prodp + hsize, tspace + hsize, hsize);
+ if (cy)
+ __mpn_add_1 (prodp + size, prodp + size, size, 1);
+ }
+}
+
+void
+#if __STDC__
+____mpn_sqr_n_basecase (mp_ptr prodp, mp_srcptr up, mp_size_t size)
+#else
+____mpn_sqr_n_basecase (prodp, up, size)
+ mp_ptr prodp;
+ mp_srcptr up;
+ mp_size_t size;
+#endif
+{
+ mp_size_t i;
+ mp_limb cy_limb;
+ mp_limb v_limb;
+
+ /* Multiply by the first limb in V separately, as the result can be
+ stored (not added) to PROD. We also avoid a loop for zeroing. */
+ v_limb = up[0];
+ if (v_limb <= 1)
+ {
+ if (v_limb == 1)
+ MPN_COPY (prodp, up, size);
+ else
+ MPN_ZERO (prodp, size);
+ cy_limb = 0;
+ }
+ else
+ cy_limb = __mpn_mul_1 (prodp, up, size, v_limb);
+
+ prodp[size] = cy_limb;
+ prodp++;
+
+ /* For each iteration in the outer loop, multiply one limb from
+ U with one limb from V, and add it to PROD. */
+ for (i = 1; i < size; i++)
+ {
+ v_limb = up[i];
+ if (v_limb <= 1)
+ {
+ cy_limb = 0;
+ if (v_limb == 1)
+ cy_limb = __mpn_add_n (prodp, prodp, up, size);
+ }
+ else
+ cy_limb = __mpn_addmul_1 (prodp, up, size, v_limb);
+
+ prodp[size] = cy_limb;
+ prodp++;
+ }
+}
+
+void
+#if __STDC__
+____mpn_sqr_n (mp_ptr prodp,
+ mp_srcptr up, mp_size_t size, mp_ptr tspace)
+#else
+____mpn_sqr_n (prodp, up, size, tspace)
+ mp_ptr prodp;
+ mp_srcptr up;
+ mp_size_t size;
+ mp_ptr tspace;
+#endif
+{
+ if ((size & 1) != 0)
+ {
+ /* The size is odd, the code code below doesn't handle that.
+ Multiply the least significant (size - 1) limbs with a recursive
+ call, and handle the most significant limb of S1 and S2
+ separately. */
+ /* A slightly faster way to do this would be to make the Karatsuba
+ code below behave as if the size were even, and let it check for
+ odd size in the end. I.e., in essence move this code to the end.
+ Doing so would save us a recursive call, and potentially make the
+ stack grow a lot less. */
+
+ mp_size_t esize = size - 1; /* even size */
+ mp_limb cy_limb;
+
+ MPN_SQR_N_RECURSE (prodp, up, esize, tspace);
+ cy_limb = __mpn_addmul_1 (prodp + esize, up, esize, up[esize]);
+ prodp[esize + esize] = cy_limb;
+ cy_limb = __mpn_addmul_1 (prodp + esize, up, size, up[esize]);
+
+ prodp[esize + size] = cy_limb;
+ }
+ else
+ {
+ mp_size_t hsize = size >> 1;
+ mp_limb cy;
+
+ /*** Product H. ________________ ________________
+ |_____U1 x U1____||____U0 x U0_____| */
+ /* Put result in upper part of PROD and pass low part of TSPACE
+ as new TSPACE. */
+ MPN_SQR_N_RECURSE (prodp + size, up + hsize, hsize, tspace);
+
+ /*** Product M. ________________
+ |_(U1-U0)(U0-U1)_| */
+ if (__mpn_cmp (up + hsize, up, hsize) >= 0)
+ {
+ __mpn_sub_n (prodp, up + hsize, up, hsize);
+ }
+ else
+ {
+ __mpn_sub_n (prodp, up, up + hsize, hsize);
+ }
+
+ /* Read temporary operands from low part of PROD.
+ Put result in low part of TSPACE using upper part of TSPACE
+ as new TSPACE. */
+ MPN_SQR_N_RECURSE (tspace, prodp, hsize, tspace + size);
+
+ /*** Add/copy product H. */
+ MPN_COPY (prodp + hsize, prodp + size, hsize);
+ cy = __mpn_add_n (prodp + size, prodp + size, prodp + size + hsize, hsize);
+
+ /*** Add product M (if NEGFLG M is a negative number). */
+ cy -= __mpn_sub_n (prodp + hsize, prodp + hsize, tspace, size);
+
+ /*** Product L. ________________ ________________
+ |________________||____U0 x U0_____| */
+ /* Read temporary operands from low part of PROD.
+ Put result in low part of TSPACE using upper part of TSPACE
+ as new TSPACE. */
+ MPN_SQR_N_RECURSE (tspace, up, hsize, tspace + size);
+
+ /*** Add/copy Product L (twice). */
+
+ cy += __mpn_add_n (prodp + hsize, prodp + hsize, tspace, size);
+ if (cy)
+ {
+ if (cy > 0)
+ __mpn_add_1 (prodp + hsize + size, prodp + hsize + size, hsize, cy);
+ else
+ {
+ __mpn_sub_1 (prodp + hsize + size, prodp + hsize + size, hsize, cy);
+ abort ();
+ }
+ }
+
+ MPN_COPY (prodp, tspace, hsize);
+ cy = __mpn_add_n (prodp + hsize, prodp + hsize, tspace + hsize, hsize);
+ if (cy)
+ __mpn_add_1 (prodp + size, prodp + size, size, 1);
+ }
+}
+
+/* This should be made into an inline function in gmp.h. */
+inline void
+#if __STDC__
+__mpn_mul_n (mp_ptr prodp, mp_srcptr up, mp_srcptr vp, mp_size_t size)
+#else
+__mpn_mul_n (prodp, up, vp, size)
+ mp_ptr prodp;
+ mp_srcptr up;
+ mp_srcptr vp;
+ mp_size_t size;
+#endif
+{
+ if (up == vp)
+ {
+ if (size < KARATSUBA_THRESHOLD)
+ {
+ ____mpn_sqr_n_basecase (prodp, up, size);
+ }
+ else
+ {
+ mp_ptr tspace;
+ tspace = (mp_ptr) alloca (2 * size * BYTES_PER_MP_LIMB);
+ ____mpn_sqr_n (prodp, up, size, tspace);
+ }
+ }
+ else
+ {
+ if (size < KARATSUBA_THRESHOLD)
+ {
+ ____mpn_mul_n_basecase (prodp, up, vp, size);
+ }
+ else
+ {
+ mp_ptr tspace;
+ tspace = (mp_ptr) alloca (2 * size * BYTES_PER_MP_LIMB);
+ ____mpn_mul_n (prodp, up, vp, size, tspace);
+ }
+ }
+}
diff --git a/sysdeps/generic/ntohl.c b/sysdeps/generic/ntohl.c
new file mode 100644
index 0000000..389cc9f
--- /dev/null
+++ b/sysdeps/generic/ntohl.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <netinet/in.h>
+
+#undef ntohl
+
+unsigned long int
+DEFUN(ntohl, (x), unsigned long int x)
+{
+#if BYTE_ORDER == LITTLE_ENDIAN
+ x = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24);
+#endif
+
+ return x;
+}
diff --git a/sysdeps/generic/ntohs.c b/sysdeps/generic/ntohs.c
new file mode 100644
index 0000000..1ac462a
--- /dev/null
+++ b/sysdeps/generic/ntohs.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <netinet/in.h>
+
+#undef ntohs
+
+unsigned short int
+DEFUN(ntohs, (x), unsigned short int x)
+{
+#if BYTE_ORDER == LITTLE_ENDIAN
+ x = (x << 8) | (x >> 8);
+#endif
+
+ return x;
+}
diff --git a/sysdeps/generic/pow.c b/sysdeps/generic/pow.c
new file mode 100644
index 0000000..5121f30
--- /dev/null
+++ b/sysdeps/generic/pow.c
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)pow.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* POW(X,Y)
+ * RETURN X**Y
+ * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 1/8/85;
+ * REVISED BY K.C. NG on 7/10/85.
+ * KERNEL pow_P() REPLACED BY P. McILROY 7/22/92.
+ * Required system supported functions:
+ * scalb(x,n)
+ * logb(x)
+ * copysign(x,y)
+ * finite(x)
+ * drem(x,y)
+ *
+ * Required kernel functions:
+ * exp__D(a,c) exp(a + c) for |a| << |c|
+ * struct d_double dlog(x) r.a + r.b, |r.b| < |r.a|
+ *
+ * Method
+ * 1. Compute and return log(x) in three pieces:
+ * log(x) = n*ln2 + hi + lo,
+ * where n is an integer.
+ * 2. Perform y*log(x) by simulating muti-precision arithmetic and
+ * return the answer in three pieces:
+ * y*log(x) = m*ln2 + hi + lo,
+ * where m is an integer.
+ * 3. Return x**y = exp(y*log(x))
+ * = 2^m * ( exp(hi+lo) ).
+ *
+ * Special cases:
+ * (anything) ** 0 is 1 ;
+ * (anything) ** 1 is itself;
+ * (anything) ** NaN is NaN;
+ * NaN ** (anything except 0) is NaN;
+ * +(anything > 1) ** +INF is +INF;
+ * -(anything > 1) ** +INF is NaN;
+ * +-(anything > 1) ** -INF is +0;
+ * +-(anything < 1) ** +INF is +0;
+ * +(anything < 1) ** -INF is +INF;
+ * -(anything < 1) ** -INF is NaN;
+ * +-1 ** +-INF is NaN and signal INVALID;
+ * +0 ** +(anything except 0, NaN) is +0;
+ * -0 ** +(anything except 0, NaN, odd integer) is +0;
+ * +0 ** -(anything except 0, NaN) is +INF and signal DIV-BY-ZERO;
+ * -0 ** -(anything except 0, NaN, odd integer) is +INF with signal;
+ * -0 ** (odd integer) = -( +0 ** (odd integer) );
+ * +INF ** +(anything except 0,NaN) is +INF;
+ * +INF ** -(anything except 0,NaN) is +0;
+ * -INF ** (odd integer) = -( +INF ** (odd integer) );
+ * -INF ** (even integer) = ( +INF ** (even integer) );
+ * -INF ** -(anything except integer,NaN) is NaN with signal;
+ * -(x=anything) ** (k=integer) is (-1)**k * (x ** k);
+ * -(anything except 0) ** (non-integer) is NaN with signal;
+ *
+ * Accuracy:
+ * pow(x,y) returns x**y nearly rounded. In particular, on a SUN, a VAX,
+ * and a Zilog Z8000,
+ * pow(integer,integer)
+ * always returns the correct integer provided it is representable.
+ * In a test run with 100,000 random arguments with 0 < x, y < 20.0
+ * on a VAX, the maximum observed error was 1.79 ulps (units in the
+ * last place).
+ *
+ * Constants :
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include <errno.h>
+#include <math.h>
+
+#include "mathimpl.h"
+
+#if (defined(vax) || defined(tahoe))
+#define TRUNC(x) x = (double) (float) x
+#define _IEEE 0
+#else
+#define _IEEE 1
+#define endian (((*(int *) &one)) ? 1 : 0)
+#define TRUNC(x) *(((int *) &x)+endian) &= 0xf8000000
+#define infnan(x) 0.0
+#endif /* vax or tahoe */
+
+const static double zero=0.0, one=1.0, two=2.0, negone= -1.0;
+
+static double pow_P __P((double, double));
+
+double pow(x,y)
+double x,y;
+{
+ double t;
+ if (y==zero)
+ return (one);
+ else if (y==one || (_IEEE && x != x))
+ return (x); /* if x is NaN or y=1 */
+ else if (_IEEE && y!=y) /* if y is NaN */
+ return (y);
+ else if (!finite(y)) /* if y is INF */
+ if ((t=fabs(x))==one) /* +-1 ** +-INF is NaN */
+ return (y - y);
+ else if (t>one)
+ return ((y<0)? zero : ((x<zero)? y-y : y));
+ else
+ return ((y>0)? zero : ((x<0)? y-y : -y));
+ else if (y==two)
+ return (x*x);
+ else if (y==negone)
+ return (one/x);
+ /* x > 0, x == +0 */
+ else if (copysign(one, x) == one)
+ return (pow_P(x, y));
+
+ /* sign(x)= -1 */
+ /* if y is an even integer */
+ else if ( (t=drem(y,two)) == zero)
+ return (pow_P(-x, y));
+
+ /* if y is an odd integer */
+ else if (copysign(t,one) == one)
+ return (-pow_P(-x, y));
+
+ /* Henceforth y is not an integer */
+ else if (x==zero) /* x is -0 */
+ return ((y>zero)? -x : one/(-x));
+ else if (_IEEE)
+ return (zero/zero);
+ else
+ return (infnan(EDOM));
+}
+/* kernel function for x >= 0 */
+static double
+#ifdef _ANSI_SOURCE
+pow_P(double x, double y)
+#else
+pow_P(x, y) double x, y;
+#endif
+{
+ struct Double s, t, __log__D();
+ double __exp__D(), huge = 1e300, tiny = 1e-300;
+
+ if (x == zero)
+ if (y > zero)
+ return (zero);
+ else if (_IEEE)
+ return (huge*huge);
+ else
+ return (infnan(ERANGE));
+ if (x == one)
+ return (one);
+ if (!finite(x))
+ if (y < zero)
+ return (zero);
+ else if (_IEEE)
+ return (huge*huge);
+ else
+ return (infnan(ERANGE));
+ if (y >= 7e18) /* infinity */
+ if (x < 1)
+ return(tiny*tiny);
+ else if (_IEEE)
+ return (huge*huge);
+ else
+ return (infnan(ERANGE));
+
+ /* Return exp(y*log(x)), using simulated extended */
+ /* precision for the log and the multiply. */
+
+ s = __log__D(x);
+ t.a = y;
+ TRUNC(t.a);
+ t.b = y - t.a;
+ t.b = s.b*y + t.b*s.a;
+ t.a *= s.a;
+ s.a = t.a + t.b;
+ s.b = (t.a - s.a) + t.b;
+ return (__exp__D(s.a, s.b));
+}
diff --git a/sysdeps/generic/putenv.c b/sysdeps/generic/putenv.c
new file mode 100644
index 0000000..77a8393
--- /dev/null
+++ b/sysdeps/generic/putenv.c
@@ -0,0 +1,101 @@
+/* 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. */
+
+#include <errno.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined (__GNU_LIBRARY__) || defined (HAVE_STDLIB_H)
+#include <stdlib.h>
+#endif
+#if defined (__GNU_LIBRARY__) || defined (HAVE_STRING_H)
+#include <string.h>
+#endif
+#if defined (__GNU_LIBRARY__) || defined (HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+
+#if !defined (__GNU_LIBRARY__) && !defined (HAVE_STRCHR)
+#define strchr index
+#endif
+#if !defined (__GNU_LIBRARY__) && !defined (HAVE_MEMCPY)
+#define memcpy(d,s,n) bcopy ((s), (d), (n))
+#endif
+
+#ifndef HAVE_GNU_LD
+#define __environ environ
+#endif
+
+
+/* Put STRING, which is of the form "NAME=VALUE", in the environment. */
+int
+putenv (string)
+ const char *string;
+{
+ const char *const name_end = strchr (string, '=');
+ register size_t size;
+ register char **ep;
+
+ if (name_end == NULL)
+ {
+ /* Remove the variable from the environment. */
+ size = strlen (string);
+ for (ep = __environ; *ep != NULL; ++ep)
+ if (!strncmp (*ep, string, size) && (*ep)[size] == '=')
+ {
+ while (ep[1] != NULL)
+ {
+ ep[0] = ep[1];
+ ++ep;
+ }
+ *ep = NULL;
+ return 0;
+ }
+ }
+
+ size = 0;
+ for (ep = __environ; *ep != NULL; ++ep)
+ if (!strncmp (*ep, string, name_end - string) &&
+ (*ep)[name_end - string] == '=')
+ break;
+ else
+ ++size;
+
+ if (*ep == NULL)
+ {
+ static char **last_environ = NULL;
+ char **new_environ = (char **) malloc ((size + 2) * sizeof (char *));
+ if (new_environ == NULL)
+ return -1;
+ (void) memcpy ((void *) new_environ, (void *) __environ,
+ size * sizeof (char *));
+ new_environ[size] = (char *) string;
+ new_environ[size + 1] = NULL;
+ if (last_environ != NULL)
+ free ((void *) last_environ);
+ last_environ = new_environ;
+ __environ = new_environ;
+ }
+ else
+ *ep = (char *) string;
+
+ return 0;
+}
diff --git a/sysdeps/generic/resourcebits.h b/sysdeps/generic/resourcebits.h
new file mode 100644
index 0000000..e343b30
--- /dev/null
+++ b/sysdeps/generic/resourcebits.h
@@ -0,0 +1,53 @@
+/* Bit values for resource limits. 4.4 BSD/generic GNU 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. */
+
+/* These are the values for 4.4 BSD and GNU. Earlier BSD systems have a
+ subset of these kinds of resource limit. In systems where `getrlimit'
+ and `setrlimit' are not system calls, these are the values used by the C
+ library to emulate them. */
+
+/* Kinds of resource limit. */
+enum __rlimit_resource
+ {
+ /* Per-process CPU limit, in seconds. */
+ RLIMIT_CPU,
+ /* Largest file that can be created, in bytes. */
+ RLIMIT_FSIZE,
+ /* Maximum size of data segment, in bytes. */
+ RLIMIT_DATA,
+ /* Maximum size of stack segment, in bytes. */
+ RLIMIT_STACK,
+ /* Largest core file that can be created, in bytes. */
+ RLIMIT_CORE,
+ /* Largest resident set size, in bytes.
+ This affects swapping; processes that are exceeding their
+ resident set size will be more likely to have physical memory
+ taken from them. */
+ RLIMIT_RSS,
+ /* Locked-in-memory address space. */
+ RLIMIT_MEMLOCK,
+ /* Number of processes. */
+ RLIMIT_NPROC,
+ /* Number of open files. */
+ RLIMIT_OFILE,
+ RLIMIT_NOFILE = RLIMIT_OFILE, /* Another name for the same thing. */
+
+ RLIMIT_NLIMITS, /* Number of limit flavors. */
+ RLIM_NLIMITS = RLIMIT_NLIMITS /* Traditional name for same. */
+ };
diff --git a/sysdeps/generic/rint.c b/sysdeps/generic/rint.c
new file mode 100644
index 0000000..a26fd09
--- /dev/null
+++ b/sysdeps/generic/rint.c
@@ -0,0 +1,87 @@
+/* snarfed from BSD common_source/floor.c:
+ * Copyright (c) 1985, 1995 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)floor.c 5.7 (Berkeley) 10/9/90";
+#endif /* not lint */
+
+#include "mathimpl.h"
+
+vc(L, 4503599627370496.0E0 ,0000,5c00,0000,0000, 55, 1.0) /* 2**55 */
+
+ic(L, 4503599627370496.0E0, 52, 1.0) /* 2**52 */
+
+#ifdef vccast
+#define L vccast(L)
+#endif
+
+/*
+ * algorithm for rint(x) in pseudo-pascal form ...
+ *
+ * real rint(x): real x;
+ * ... delivers integer nearest x in direction of prevailing rounding
+ * ... mode
+ * const L = (last consecutive integer)/2
+ * = 2**55; for VAX D
+ * = 2**52; for IEEE 754 Double
+ * real s,t;
+ * begin
+ * if x != x then return x; ... NaN
+ * if |x| >= L then return x; ... already an integer
+ * s := copysign(L,x);
+ * t := x + s; ... = (x+s) rounded to integer
+ * return t - s
+ * end;
+ *
+ * Note: Inexact will be signaled if x is not an integer, as is
+ * customary for IEEE 754. No other signal can be emitted.
+ */
+double
+__rint(x)
+double x;
+{
+ double s,t;
+ const double one = 1.0;
+
+#if !defined(vax)&&!defined(tahoe)
+ if (x != x) /* NaN */
+ return (x);
+#endif /* !defined(vax)&&!defined(tahoe) */
+ if (copysign(x,one) >= L) /* already an integer */
+ return (x);
+ s = copysign(L,x);
+ t = x + s; /* x+s rounded to integer */
+ return (t - s);
+}
+
+weak_alias (__rint, rint)
diff --git a/sysdeps/generic/rshift.c b/sysdeps/generic/rshift.c
new file mode 100644
index 0000000..966cc7b
--- /dev/null
+++ b/sysdeps/generic/rshift.c
@@ -0,0 +1,87 @@
+/* __mpn_rshift -- Shift right a low-level natural-number integer.
+
+Copyright (C) 1991, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
+/* Shift U (pointed to by UP and USIZE limbs long) CNT bits to the right
+ and store the USIZE least significant limbs of the result at WP.
+ The bits shifted out to the right are returned.
+
+ Argument constraints:
+ 1. 0 < CNT < BITS_PER_MP_LIMB
+ 2. If the result is to be written over the input, WP must be <= UP.
+*/
+
+mp_limb
+#if __STDC__
+__mpn_rshift (register mp_ptr wp,
+ register mp_srcptr up, mp_size_t usize,
+ register unsigned int cnt)
+#else
+__mpn_rshift (wp, up, usize, cnt)
+ register mp_ptr wp;
+ register mp_srcptr up;
+ mp_size_t usize;
+ register unsigned int cnt;
+#endif
+{
+ register mp_limb high_limb, low_limb;
+ register unsigned sh_1, sh_2;
+ register mp_size_t i;
+ mp_limb retval;
+
+#ifdef DEBUG
+ if (usize == 0 || cnt == 0)
+ abort ();
+#endif
+
+ sh_1 = cnt;
+
+#if 0
+ if (sh_1 == 0)
+ {
+ if (wp != up)
+ {
+ /* Copy from low end to high end, to allow specified input/output
+ overlapping. */
+ for (i = 0; i < usize; i++)
+ wp[i] = up[i];
+ }
+ return usize;
+ }
+#endif
+
+ wp -= 1;
+ sh_2 = BITS_PER_MP_LIMB - sh_1;
+ high_limb = up[0];
+ retval = high_limb << sh_2;
+ low_limb = high_limb;
+
+ for (i = 1; i < usize; i++)
+ {
+ high_limb = up[i];
+ wp[i] = (low_limb >> sh_1) | (high_limb << sh_2);
+ low_limb = high_limb;
+ }
+ wp[i] = low_limb >> sh_1;
+
+ return retval;
+}
diff --git a/sysdeps/generic/sbrk.c b/sysdeps/generic/sbrk.c
new file mode 100644
index 0000000..28beab6
--- /dev/null
+++ b/sysdeps/generic/sbrk.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991, 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 General Public License as published by
+the Free Software Foundation; either version 2, 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the GNU C Library; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <ansidecl.h>
+
+/* Defined in brk.c. */
+extern PTR __curbrk;
+extern int EXFUN(__brk, (PTR addr));
+
+/* Extend the process's data space by INCREMENT.
+ If INCREMENT is negative, shrink data space by - INCREMENT.
+ Return start of new space allocated, or -1 for errors. */
+PTR
+DEFUN(__sbrk, (increment), int increment)
+{
+ char *oldbrk;
+
+ if (increment == 0)
+ return __curbrk;
+
+ oldbrk = __curbrk;
+ if (__brk(oldbrk + increment) < 0)
+ return (PTR) -1;
+
+ return oldbrk;
+}
+
+weak_alias (__sbrk, sbrk)
diff --git a/sysdeps/generic/setenv.c b/sysdeps/generic/setenv.c
new file mode 100644
index 0000000..a27f02e
--- /dev/null
+++ b/sysdeps/generic/setenv.c
@@ -0,0 +1,86 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifndef HAVE_GNU_LD
+#define __environ environ
+#endif
+
+int
+DEFUN(setenv, (name, value, replace),
+ CONST char *name AND CONST char *value AND int replace)
+{
+ register char **ep;
+ register size_t size;
+ CONST size_t namelen = strlen (name);
+ CONST size_t vallen = strlen (value);
+
+ size = 0;
+ for (ep = __environ; *ep != NULL; ++ep)
+ if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
+ break;
+ else
+ ++size;
+
+ if (*ep == NULL)
+ {
+ static char **last_environ = NULL;
+ char **new_environ = (char **) malloc((size + 2) * sizeof(char *));
+ if (new_environ == NULL)
+ return -1;
+ (void) memcpy((PTR) new_environ, (PTR) __environ, size * sizeof(char *));
+
+ new_environ[size] = malloc (namelen + 1 + vallen + 1);
+ if (new_environ[size] == NULL)
+ {
+ free (new_environ);
+ errno = ENOMEM;
+ return -1;
+ }
+ memcpy (new_environ[size], name, namelen);
+ new_environ[size][namelen] = '=';
+ memcpy (&new_environ[size][namelen + 1], value, vallen + 1);
+
+ new_environ[size + 1] = NULL;
+
+ if (last_environ != NULL)
+ free ((PTR) last_environ);
+ last_environ = new_environ;
+ __environ = new_environ;
+ }
+ else if (replace)
+ {
+ size_t len = strlen (*ep);
+ if (len < namelen + 1 + vallen)
+ {
+ char *new = malloc (namelen + 1 + vallen);
+ if (new == NULL)
+ return -1;
+ *ep = new;
+ }
+ memcpy (*ep, name, namelen);
+ (*ep)[namelen] = '=';
+ memcpy (&(*ep)[namelen + 1], value, vallen + 1);
+ }
+
+ return 0;
+}
diff --git a/sysdeps/generic/sigaction.h b/sysdeps/generic/sigaction.h
new file mode 100644
index 0000000..31ce45c
--- /dev/null
+++ b/sysdeps/generic/sigaction.h
@@ -0,0 +1,50 @@
+/* Copyright (C) 1991, 1992 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, 1992 Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+/* These definitions match those used by the 4.4 BSD kernel.
+ If the operating system has a `sigaction' system call that correctly
+ implements the POSIX.1 behavior, there should be a system-dependent
+ version of this file that defines `struct sigaction' and the `SA_*'
+ constants appropriately. */
+
+/* Structure describing the action to be taken when a signal arrives. */
+struct sigaction
+ {
+ /* Signal handler. */
+ __sighandler_t sa_handler;
+
+ /* Additional set of signals to be blocked. */
+ __sigset_t sa_mask;
+
+ /* Special flags. */
+ int sa_flags;
+ };
+
+/* Bits in `sa_flags'. */
+#ifdef __USE_BSD
+#define SA_ONSTACK 0x1 /* Take signal on signal stack. */
+#define SA_RESTART 0x2 /* Don't restart syscall on signal return. */
+#define SA_DISABLE 0x4 /* Disable alternate signal stack. */
+#endif
+#define SA_NOCLDSTOP 0x8 /* Don't send SIGCHLD when children stop. */
+
+
+/* Values for the HOW argument to `sigprocmask'. */
+#define SIG_BLOCK 1 /* Block signals. */
+#define SIG_UNBLOCK 2 /* Unblock signals. */
+#define SIG_SETMASK 3 /* Set the set of blocked signals. */
diff --git a/sysdeps/generic/signame.c b/sysdeps/generic/signame.c
new file mode 100644
index 0000000..5f8deab
--- /dev/null
+++ b/sysdeps/generic/signame.c
@@ -0,0 +1,275 @@
+/* Convert between signal names and numbers.
+ Copyright (C) 1990, 1992, 1993 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <stdio.h>
+#include <sys/types.h> /* Some systems need this for <signal.h>. */
+#include <signal.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* Some systems do not define NSIG in <signal.h>. */
+#ifndef NSIG
+#ifdef _NSIG
+#define NSIG _NSIG
+#else
+#define NSIG 32
+#endif
+#endif
+
+#if !__STDC__
+#define const
+#endif
+
+#include "signame.h"
+
+#ifndef HAVE_SYS_SIGLIST
+/* There is too much variation in Sys V signal numbers and names, so
+ we must initialize them at runtime. */
+
+static const char undoc[] = "unknown signal";
+
+const char *sys_siglist[NSIG];
+
+#else /* HAVE_SYS_SIGLIST. */
+
+#ifndef SYS_SIGLIST_DECLARED
+extern char *sys_siglist[];
+#endif /* Not SYS_SIGLIST_DECLARED. */
+
+#endif /* Not HAVE_SYS_SIGLIST. */
+
+/* Table of abbreviations for signals. Note: A given number can
+ appear more than once with different abbreviations. */
+typedef struct
+ {
+ int number;
+ const char *abbrev;
+ } num_abbrev;
+static num_abbrev sig_table[NSIG*2];
+/* Number of elements of sig_table used. */
+static int sig_table_nelts = 0;
+
+/* Enter signal number NUMBER into the tables with ABBREV and NAME. */
+
+static void
+init_sig (number, abbrev, name)
+ int number;
+ const char *abbrev;
+ const char *name;
+{
+#ifndef HAVE_SYS_SIGLIST
+ sys_siglist[number] = name;
+#endif
+ sig_table[sig_table_nelts].number = number;
+ sig_table[sig_table_nelts++].abbrev = abbrev;
+}
+
+void
+signame_init ()
+{
+#ifndef HAVE_SYS_SIGLIST
+ int i;
+ /* Initialize signal names. */
+ for (i = 0; i < NSIG; i++)
+ sys_siglist[i] = undoc;
+#endif /* !HAVE_SYS_SIGLIST */
+
+ /* Initialize signal names. */
+#if defined (SIGHUP)
+ init_sig (SIGHUP, "HUP", "Hangup");
+#endif
+#if defined (SIGINT)
+ init_sig (SIGINT, "INT", "Interrupt");
+#endif
+#if defined (SIGQUIT)
+ init_sig (SIGQUIT, "QUIT", "Quit");
+#endif
+#if defined (SIGILL)
+ init_sig (SIGILL, "ILL", "Illegal Instruction");
+#endif
+#if defined (SIGTRAP)
+ init_sig (SIGTRAP, "TRAP", "Trace/breakpoint trap");
+#endif
+ /* If SIGIOT == SIGABRT, we want to print it as SIGABRT because
+ SIGABRT is in ANSI and POSIX.1 and SIGIOT isn't. */
+#if defined (SIGABRT)
+ init_sig (SIGABRT, "ABRT", "Aborted");
+#endif
+#if defined (SIGIOT)
+ init_sig (SIGIOT, "IOT", "IOT trap");
+#endif
+#if defined (SIGEMT)
+ init_sig (SIGEMT, "EMT", "EMT trap");
+#endif
+#if defined (SIGFPE)
+ init_sig (SIGFPE, "FPE", "Floating point exception");
+#endif
+#if defined (SIGKILL)
+ init_sig (SIGKILL, "KILL", "Killed");
+#endif
+#if defined (SIGBUS)
+ init_sig (SIGBUS, "BUS", "Bus error");
+#endif
+#if defined (SIGSEGV)
+ init_sig (SIGSEGV, "SEGV", "Segmentation fault");
+#endif
+#if defined (SIGSYS)
+ init_sig (SIGSYS, "SYS", "Bad system call");
+#endif
+#if defined (SIGPIPE)
+ init_sig (SIGPIPE, "PIPE", "Broken pipe");
+#endif
+#if defined (SIGALRM)
+ init_sig (SIGALRM, "ALRM", "Alarm clock");
+#endif
+#if defined (SIGTERM)
+ init_sig (SIGTERM, "TERM", "Terminated");
+#endif
+#if defined (SIGUSR1)
+ init_sig (SIGUSR1, "USR1", "User defined signal 1");
+#endif
+#if defined (SIGUSR2)
+ init_sig (SIGUSR2, "USR2", "User defined signal 2");
+#endif
+ /* If SIGCLD == SIGCHLD, we want to print it as SIGCHLD because that
+ is what is in POSIX.1. */
+#if defined (SIGCHLD)
+ init_sig (SIGCHLD, "CHLD", "Child exited");
+#endif
+#if defined (SIGCLD)
+ init_sig (SIGCLD, "CLD", "Child exited");
+#endif
+#if defined (SIGPWR)
+ init_sig (SIGPWR, "PWR", "Power failure");
+#endif
+#if defined (SIGTSTP)
+ init_sig (SIGTSTP, "TSTP", "Stopped");
+#endif
+#if defined (SIGTTIN)
+ init_sig (SIGTTIN, "TTIN", "Stopped (tty input)");
+#endif
+#if defined (SIGTTOU)
+ init_sig (SIGTTOU, "TTOU", "Stopped (tty output)");
+#endif
+#if defined (SIGSTOP)
+ init_sig (SIGSTOP, "STOP", "Stopped (signal)");
+#endif
+#if defined (SIGXCPU)
+ init_sig (SIGXCPU, "XCPU", "CPU time limit exceeded");
+#endif
+#if defined (SIGXFSZ)
+ init_sig (SIGXFSZ, "XFSZ", "File size limit exceeded");
+#endif
+#if defined (SIGVTALRM)
+ init_sig (SIGVTALRM, "VTALRM", "Virtual timer expired");
+#endif
+#if defined (SIGPROF)
+ init_sig (SIGPROF, "PROF", "Profiling timer expired");
+#endif
+#if defined (SIGWINCH)
+ /* "Window size changed" might be more accurate, but even if that
+ is all that it means now, perhaps in the future it will be
+ extended to cover other kinds of window changes. */
+ init_sig (SIGWINCH, "WINCH", "Window changed");
+#endif
+#if defined (SIGCONT)
+ init_sig (SIGCONT, "CONT", "Continued");
+#endif
+#if defined (SIGURG)
+ init_sig (SIGURG, "URG", "Urgent I/O condition");
+#endif
+#if defined (SIGIO)
+ /* "I/O pending" has also been suggested. A disadvantage is
+ that signal only happens when the process has
+ asked for it, not everytime I/O is pending. Another disadvantage
+ is the confusion from giving it a different name than under Unix. */
+ init_sig (SIGIO, "IO", "I/O possible");
+#endif
+#if defined (SIGWIND)
+ init_sig (SIGWIND, "WIND", "SIGWIND");
+#endif
+#if defined (SIGPHONE)
+ init_sig (SIGPHONE, "PHONE", "SIGPHONE");
+#endif
+#if defined (SIGPOLL)
+ init_sig (SIGPOLL, "POLL", "I/O possible");
+#endif
+#if defined (SIGLOST)
+ init_sig (SIGLOST, "LOST", "Resource lost");
+#endif
+#if defined (SIGDANGER)
+ init_sig (SIGDANGER, "DANGER", "Danger signal");
+#endif
+}
+
+/* Return the abbreviation for signal NUMBER. */
+
+char *
+sig_abbrev (number)
+ int number;
+{
+ int i;
+
+ if (sig_table_nelts == 0)
+ signame_init ();
+
+ for (i = 0; i < sig_table_nelts; i++)
+ if (sig_table[i].number == number)
+ return (char *)sig_table[i].abbrev;
+ return NULL;
+}
+
+/* Return the signal number for an ABBREV, or -1 if there is no
+ signal by that name. */
+
+int
+sig_number (abbrev)
+ const char *abbrev;
+{
+ int i;
+
+ if (sig_table_nelts == 0)
+ signame_init ();
+
+ /* Skip over "SIG" if present. */
+ if (abbrev[0] == 'S' && abbrev[1] == 'I' && abbrev[2] == 'G')
+ abbrev += 3;
+
+ for (i = 0; i < sig_table_nelts; i++)
+ if (abbrev[0] == sig_table[i].abbrev[0]
+ && strcmp (abbrev, sig_table[i].abbrev) == 0)
+ return sig_table[i].number;
+ return -1;
+}
+
+#ifndef HAVE_PSIGNAL
+/* Print to standard error the name of SIGNAL, preceded by MESSAGE and
+ a colon, and followed by a newline. */
+
+void
+psignal (signal, message)
+ int signal;
+ const char *message;
+{
+ if (signal <= 0 || signal >= NSIG)
+ fprintf (stderr, "%s: unknown signal", message);
+ else
+ fprintf (stderr, "%s: %s\n", message, sys_siglist[signal]);
+}
+#endif
diff --git a/sysdeps/generic/signame.h b/sysdeps/generic/signame.h
new file mode 100644
index 0000000..2bd1637
--- /dev/null
+++ b/sysdeps/generic/signame.h
@@ -0,0 +1,57 @@
+/* Convert between signal names and numbers.
+ Copyright (C) 1990, 1992, 1993 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#if defined (__STDC__) && __STDC__
+
+/* Initialize `sys_siglist'. */
+void signame_init (void);
+
+/* Return the abbreviation (e.g. ABRT, FPE, etc.) for signal NUMBER.
+ Do not return this as a const char *. The caller might want to
+ assign it to a char *. */
+char *sig_abbrev (int number);
+
+/* Return the signal number for an ABBREV, or -1 if there is no
+ signal by that name. */
+int sig_number (const char *abbrev);
+
+/* Avoid conflicts with a system header file that might define these two. */
+
+#ifndef HAVE_PSIGNAL
+/* Print to standard error the name of SIGNAL, preceded by MESSAGE and
+ a colon, and followed by a newline. */
+void psignal (int signal, const char *message);
+#endif
+
+#if !defined (HAVE_SYS_SIGLIST)
+/* Names for signals from 0 to NSIG-1. */
+extern const char *sys_siglist[];
+#endif
+
+#else
+
+void signame_init ();
+char *sig_abbrev ();
+int sig_number ();
+#if !defined (HAVE_SYS_SIGLIST) && !defined (HAVE_PSIGNAL)
+void psignal ();
+#endif
+#if !defined (HAVE_SYS_SIGLIST)
+extern char *sys_siglist[];
+#endif
+
+#endif
diff --git a/sysdeps/generic/sigset.h b/sysdeps/generic/sigset.h
new file mode 100644
index 0000000..bc56d96
--- /dev/null
+++ b/sysdeps/generic/sigset.h
@@ -0,0 +1,79 @@
+/* __sig_atomic_t, __sigset_t, and related definitions. Generic/BSD version.
+Copyright (C) 1991, 1992, 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, 1992 Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#ifndef _SIGSET_H_types
+#define _SIGSET_H_types 1
+
+typedef int __sig_atomic_t;
+
+/* A `sigset_t' has a bit for each signal. */
+typedef unsigned long int __sigset_t;
+
+#endif
+
+
+/* We only want to define these functions if <signal.h> was actually
+ included; otherwise we were included just to define the types. Since we
+ are namespace-clean, it wouldn't hurt to define extra macros. But
+ trouble can be caused by functions being defined (e.g., any global
+ register vars declared later will cause compilation errors). */
+
+#if !defined (_SIGSET_H_fns) && defined (_SIGNAL_H)
+#define _SIGSET_H_fns 1
+
+/* Return a mask that includes SIG only. The cast to `sigset_t' avoids
+ overflow if `sigset_t' is wider than `int'. */
+#define __sigmask(sig) (((__sigset_t) 1) << ((sig) - 1))
+
+#define __sigemptyset(set) ((*(set) = (__sigset_t) 0), 0)
+#define __sigfillset(set) ((*(set) = ~(__sigset_t) 0), 0)
+
+/* These functions must check for a bogus signal number. We detect it by a
+ zero sigmask, since a number too low or too high will have shifted the 1
+ off the high end of the mask. If we find an error, we punt to a random
+ call we know fails with EINVAL (kludge city!), so as to avoid referring
+ to `errno' in this file (sigh). */
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE extern __inline
+#endif
+#define __SIGSETFN(NAME, BODY, CONST) \
+ _EXTERN_INLINE int \
+ __##NAME (CONST __sigset_t *__set, int __sig) \
+ { \
+ if (__sig < 1 || __sig > sizeof (__sigset_t) * 8) \
+ { \
+ extern int raise (int); \
+ return raise (-1); \
+ } \
+ else \
+ { \
+ __sigset_t __mask = __sigmask (__sig); \
+ return BODY; \
+ } \
+ }
+
+__SIGSETFN (sigismember, (*__set & __mask) ? 1 : 0, __const)
+__SIGSETFN (sigaddset, ((*__set |= __mask), 0), )
+__SIGSETFN (sigdelset, ((*__set &= ~__mask), 0), )
+
+#undef __SIGSETFN
+
+
+#endif /* ! _SIGSET_H_fns. */
diff --git a/sysdeps/generic/sincos.c b/sysdeps/generic/sincos.c
new file mode 100644
index 0000000..ab88560
--- /dev/null
+++ b/sysdeps/generic/sincos.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 1987, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)sincos.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+#include "trig.h"
+double
+sin(x)
+double x;
+{
+ double a,c,z;
+
+ if(!finite(x)) /* sin(NaN) and sin(INF) must be NaN */
+ return x-x;
+ x=drem(x,PI2); /* reduce x into [-PI,PI] */
+ a=copysign(x,one);
+ if (a >= PIo4) {
+ if(a >= PI3o4) /* ... in [3PI/4,PI] */
+ x = copysign((a = PI-a),x);
+ else { /* ... in [PI/4,3PI/4] */
+ a = PIo2-a; /* rtn. sign(x)*C(PI/2-|x|) */
+ z = a*a;
+ c = cos__C(z);
+ z *= half;
+ a = (z >= thresh ? half-((z-half)-c) : one-(z-c));
+ return copysign(a,x);
+ }
+ }
+
+ if (a < small) { /* rtn. S(x) */
+ big+a;
+ return x;
+ }
+ return x+x*sin__S(x*x);
+}
+
+double
+cos(x)
+double x;
+{
+ double a,c,z,s = 1.0;
+
+ if(!finite(x)) /* cos(NaN) and cos(INF) must be NaN */
+ return x-x;
+ x=drem(x,PI2); /* reduce x into [-PI,PI] */
+ a=copysign(x,one);
+ if (a >= PIo4) {
+ if (a >= PI3o4) { /* ... in [3PI/4,PI] */
+ a = PI-a;
+ s = negone;
+ }
+ else { /* ... in [PI/4,3PI/4] */
+ a = PIo2-a;
+ return a+a*sin__S(a*a); /* rtn. S(PI/2-|x|) */
+ }
+ }
+ if (a < small) {
+ big+a;
+ return s; /* rtn. s*C(a) */
+ }
+ z = a*a;
+ c = cos__C(z);
+ z *= half;
+ a = (z >= thresh ? half-((z-half)-c) : one-(z-c));
+ return copysign(a,s);
+}
diff --git a/sysdeps/generic/sinh.c b/sysdeps/generic/sinh.c
new file mode 100644
index 0000000..0516849
--- /dev/null
+++ b/sysdeps/generic/sinh.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)sinh.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* SINH(X)
+ * RETURN THE HYPERBOLIC SINE OF X
+ * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 1/8/85;
+ * REVISED BY K.C. NG on 2/8/85, 3/7/85, 3/24/85, 4/16/85.
+ *
+ * Required system supported functions :
+ * copysign(x,y)
+ * scalb(x,N)
+ *
+ * Required kernel functions:
+ * expm1(x) ...return exp(x)-1
+ *
+ * Method :
+ * 1. reduce x to non-negative by sinh(-x) = - sinh(x).
+ * 2.
+ *
+ * expm1(x) + expm1(x)/(expm1(x)+1)
+ * 0 <= x <= lnovfl : sinh(x) := --------------------------------
+ * 2
+ * lnovfl <= x <= lnovfl+ln2 : sinh(x) := expm1(x)/2 (avoid overflow)
+ * lnovfl+ln2 < x < INF : overflow to INF
+ *
+ *
+ * Special cases:
+ * sinh(x) is x if x is +INF, -INF, or NaN.
+ * only sinh(0)=0 is exact for finite argument.
+ *
+ * Accuracy:
+ * sinh(x) returns the exact hyperbolic sine of x nearly rounded. In
+ * a test run with 1,024,000 random arguments on a VAX, the maximum
+ * observed error was 1.93 ulps (units in the last place).
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include "mathimpl.h"
+
+vc(mln2hi, 8.8029691931113054792E1 ,0f33,43b0,2bdb,c7e2, 7, .B00F33C7E22BDB)
+vc(mln2lo,-4.9650192275318476525E-16 ,1b60,a70f,582a,279e, -50,-.8F1B60279E582A)
+vc(lnovfl, 8.8029691931113053016E1 ,0f33,43b0,2bda,c7e2, 7, .B00F33C7E22BDA)
+
+ic(mln2hi, 7.0978271289338397310E2, 10, 1.62E42FEFA39EF)
+ic(mln2lo, 2.3747039373786107478E-14, -45, 1.ABC9E3B39803F)
+ic(lnovfl, 7.0978271289338397310E2, 9, 1.62E42FEFA39EF)
+
+#ifdef vccast
+#define mln2hi vccast(mln2hi)
+#define mln2lo vccast(mln2lo)
+#define lnovfl vccast(lnovfl)
+#endif
+
+#if defined(vax)||defined(tahoe)
+static max = 126 ;
+#else /* defined(vax)||defined(tahoe) */
+static max = 1023 ;
+#endif /* defined(vax)||defined(tahoe) */
+
+
+double sinh(x)
+double x;
+{
+ static const double one=1.0, half=1.0/2.0 ;
+ double t, sign;
+#if !defined(vax)&&!defined(tahoe)
+ if(x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+ sign=copysign(one,x);
+ x=copysign(x,one);
+ if(x<lnovfl)
+ {t=expm1(x); return(copysign((t+t/(one+t))*half,sign));}
+
+ else if(x <= lnovfl+0.7)
+ /* subtract x by ln(2^(max+1)) and return 2^max*exp(x)
+ to avoid unnecessary overflow */
+ return(copysign(scalb(one+expm1((x-mln2hi)-mln2lo),max),sign));
+
+ else /* sinh(+-INF) = +-INF, sinh(+-big no.) overflow to +-INF */
+ return( expm1(x)*sign );
+}
diff --git a/sysdeps/generic/sockaddrcom.h b/sysdeps/generic/sockaddrcom.h
new file mode 100644
index 0000000..1aac49c
--- /dev/null
+++ b/sysdeps/generic/sockaddrcom.h
@@ -0,0 +1,34 @@
+/* Definition of `struct sockaddr_*' common members. Generic/4.2 BSD version.
+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. */
+
+#ifndef _SOCKADDRCOM_H
+#define _SOCKADDRCOM_H 1
+
+
+/* This macro is used to declare the initial common members
+ of the data types used for socket addresses, `struct sockaddr',
+ `struct sockaddr_in', `struct sockaddr_un', etc. */
+
+#define __SOCKADDR_COMMON(sa_prefix) \
+ unsigned short int sa_prefix##family
+
+#define __SOCKADDR_COMMON_SIZE (sizeof (unsigned short int))
+
+
+#endif /* sockaddrcom.h */
diff --git a/sysdeps/generic/speed.c b/sysdeps/generic/speed.c
new file mode 100644
index 0000000..1f5a3ee
--- /dev/null
+++ b/sysdeps/generic/speed.c
@@ -0,0 +1,67 @@
+/* `struct termios' speed frobnication functions. 4.4 BSD/generic GNU version.
+Copyright (C) 1991, 1992, 1993 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <errno.h>
+#include <termios.h>
+
+/* Return the output baud rate stored in *TERMIOS_P. */
+speed_t
+DEFUN(cfgetospeed, (termios_p), CONST struct termios *termios_p)
+{
+ return termios_p->__ospeed;
+}
+
+/* Return the input baud rate stored in *TERMIOS_P. */
+speed_t
+DEFUN(cfgetispeed, (termios_p), CONST struct termios *termios_p)
+{
+ return termios_p->__ispeed;
+}
+
+/* Set the output baud rate stored in *TERMIOS_P to SPEED. */
+int
+DEFUN(cfsetospeed, (termios_p, speed),
+ struct termios *termios_p AND speed_t speed)
+{
+ if (termios_p == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ termios_p->__ospeed = speed;
+ return 0;
+}
+
+/* Set the input baud rate stored in *TERMIOS_P to SPEED. */
+int
+DEFUN(cfsetispeed, (termios_p, speed),
+ struct termios *termios_p AND speed_t speed)
+{
+ if (termios_p == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ termios_p->__ispeed = speed;
+ return 0;
+}
diff --git a/sysdeps/generic/stpcpy.c b/sysdeps/generic/stpcpy.c
new file mode 100644
index 0000000..dd96948
--- /dev/null
+++ b/sysdeps/generic/stpcpy.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+
+
+/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
+char *
+DEFUN(stpcpy, (dest, src), char *dest AND CONST char *src)
+{
+ register char *d = dest;
+ register CONST char *s = src;
+
+ do
+ *d++ = *s;
+ while (*s++ != '\0');
+
+ return d - 1;
+}
diff --git a/sysdeps/generic/stpncpy.c b/sysdeps/generic/stpncpy.c
new file mode 100644
index 0000000..40c9173
--- /dev/null
+++ b/sysdeps/generic/stpncpy.c
@@ -0,0 +1,89 @@
+/* Copyright (C) 1993, 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 almost copied from strncpy.c, written by Torbjorn Granlund. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <memcopy.h>
+
+
+/* Copy no more than N characters of SRC to DEST, returning the address of
+ the last character written into DEST. */
+char *
+DEFUN(__stpncpy, (dest, src, n), char *dest AND CONST char *src AND size_t n)
+{
+ reg_char c;
+ char *s = dest;
+
+ --dest;
+
+ if (n >= 4)
+ {
+ size_t n4 = n >> 2;
+
+ for (;;)
+ {
+ c = *src++;
+ *++dest = c;
+ if (c == '\0')
+ break;
+ c = *src++;
+ *++dest = c;
+ if (c == '\0')
+ break;
+ c = *src++;
+ *++dest = c;
+ if (c == '\0')
+ break;
+ c = *src++;
+ *++dest = c;
+ if (c == '\0')
+ break;
+ if (--n4 == 0)
+ goto last_chars;
+ }
+ n = n - (dest - s) - 1;
+ if (n == 0)
+ return dest;
+ goto zero_fill;
+ }
+
+ last_chars:
+ n &= 3;
+ if (n == 0)
+ return s;
+
+ do
+ {
+ c = *src++;
+ *++dest = c;
+ if (--n == 0)
+ return dest;
+ }
+ while (c != '\0');
+
+ zero_fill:
+ do
+ *++dest = '\0';
+ while (--n > 0);
+
+ return dest;
+}
+
+weak_alias (__stpncpy, stpncpy)
diff --git a/sysdeps/generic/strcasecmp.c b/sysdeps/generic/strcasecmp.c
new file mode 100644
index 0000000..7ccfe5c
--- /dev/null
+++ b/sysdeps/generic/strcasecmp.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <ctype.h>
+
+/* Compare S1 and S2, ignoring case, returning less than, equal to or
+ greater than zero if S1 is lexiographically less than,
+ equal to or greater than S2. */
+int
+DEFUN(strcasecmp, (s1, s2), CONST char *s1 AND CONST char *s2)
+{
+ register CONST unsigned char *p1 = (CONST unsigned char *) s1;
+ register CONST unsigned char *p2 = (CONST unsigned char *) s2;
+ unsigned char c1, c2;
+
+ if (p1 == p2)
+ return 0;
+
+ do
+ {
+ c1 = tolower (*p1++);
+ c2 = tolower (*p2++);
+ if (c1 == '\0')
+ break;
+ }
+ while (c1 == c2);
+
+ return c1 - c2;
+}
diff --git a/sysdeps/generic/strcat.c b/sysdeps/generic/strcat.c
new file mode 100644
index 0000000..b4b5536
--- /dev/null
+++ b/sysdeps/generic/strcat.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <memcopy.h>
+
+/* Append SRC on the end of DEST. */
+char *
+DEFUN(strcat, (dest, src), char *dest AND CONST char *src)
+{
+ register char *s1 = dest;
+ register CONST char *s2 = src;
+ reg_char c;
+
+ /* Find the end of the string. */
+ do
+ c = *s1++;
+ while (c != '\0');
+
+ /* Make S1 point before the next character, so we can increment
+ it while memory is read (wins on pipelined cpus). */
+ s1 -= 2;
+
+ do
+ {
+ c = *s2++;
+ *++s1 = c;
+ }
+ while (c != '\0');
+
+ return dest;
+}
diff --git a/sysdeps/generic/strchr.c b/sysdeps/generic/strchr.c
new file mode 100644
index 0000000..b9c8393
--- /dev/null
+++ b/sysdeps/generic/strchr.c
@@ -0,0 +1,183 @@
+/* Copyright (C) 1991, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Based on strlen implemention by Torbjorn Granlund (tege@sics.se),
+ with help from Dan Sahlin (dan@sics.se) and
+ bug fix and commentary by Jim Blandy (jimb@ai.mit.edu);
+ adaptation to strchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
+ and implemented by Roland McGrath (roland@ai.mit.edu).
+
+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. */
+
+#include <ansidecl.h>
+#include <string.h>
+
+
+/* Find the first ocurrence of C in S. */
+
+char *
+DEFUN(strchr, (s, c), CONST char *s AND int c)
+{
+ CONST unsigned char *char_ptr;
+ CONST unsigned long int *longword_ptr;
+ unsigned long int longword, magic_bits, charmask;
+
+ c = (unsigned char) c;
+
+ /* Handle the first few characters by reading one character at a time.
+ Do this until CHAR_PTR is aligned on a longword boundary. */
+ for (char_ptr = s; ((unsigned long int) char_ptr
+ & (sizeof (longword) - 1)) != 0;
+ ++char_ptr)
+ if (*char_ptr == c)
+ return (PTR) char_ptr;
+ else if (*char_ptr == '\0')
+ return NULL;
+
+ /* All these elucidatory comments refer to 4-byte longwords,
+ but the theory applies equally well to 8-byte longwords. */
+
+ longword_ptr = (unsigned long int *) char_ptr;
+
+ /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits
+ the "holes." Note that there is a hole just to the left of
+ each byte, with an extra at the end:
+
+ bits: 01111110 11111110 11111110 11111111
+ bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
+
+ The 1-bits make sure that carries propagate to the next 0-bit.
+ The 0-bits provide holes for carries to fall into. */
+ switch (sizeof (longword))
+ {
+ case 4: magic_bits = 0x7efefeffL; break;
+ case 8: magic_bits = (0x7efefefeL << 32) | 0xfefefeffL; break;
+ default:
+ abort ();
+ }
+
+ /* Set up a longword, each of whose bytes is C. */
+ charmask = c | (c << 8);
+ charmask |= charmask << 16;
+ if (sizeof (longword) > 4)
+ charmask |= charmask << 32;
+ if (sizeof (longword) > 8)
+ abort ();
+
+ /* Instead of the traditional loop which tests each character,
+ we will test a longword at a time. The tricky part is testing
+ if *any of the four* bytes in the longword in question are zero. */
+ for (;;)
+ {
+ /* We tentatively exit the loop if adding MAGIC_BITS to
+ LONGWORD fails to change any of the hole bits of LONGWORD.
+
+ 1) Is this safe? Will it catch all the zero bytes?
+ Suppose there is a byte with all zeros. Any carry bits
+ propagating from its left will fall into the hole at its
+ least significant bit and stop. Since there will be no
+ carry from its most significant bit, the LSB of the
+ byte to the left will be unchanged, and the zero will be
+ detected.
+
+ 2) Is this worthwhile? Will it ignore everything except
+ zero bytes? Suppose every byte of LONGWORD has a bit set
+ somewhere. There will be a carry into bit 8. If bit 8
+ is set, this will carry into bit 16. If bit 8 is clear,
+ one of bits 9-15 must be set, so there will be a carry
+ into bit 16. Similarly, there will be a carry into bit
+ 24. If one of bits 24-30 is set, there will be a carry
+ into bit 31, so all of the hole bits will be changed.
+
+ The one misfire occurs when bits 24-30 are clear and bit
+ 31 is set; in this case, the hole at bit 31 is not
+ changed. If we had access to the processor carry flag,
+ we could close this loophole by putting the fourth hole
+ at bit 32!
+
+ So it ignores everything except 128's, when they're aligned
+ properly.
+
+ 3) But wait! Aren't we looking for C as well as zero?
+ Good point. So what we do is XOR LONGWORD with a longword,
+ each of whose bytes is C. This turns each byte that is C
+ into a zero. */
+
+ longword = *longword_ptr++;
+
+ /* Add MAGIC_BITS to LONGWORD. */
+ if ((((longword + magic_bits)
+
+ /* Set those bits that were unchanged by the addition. */
+ ^ ~longword)
+
+ /* Look at only the hole bits. If any of the hole bits
+ are unchanged, most likely one of the bytes was a
+ zero. */
+ & ~magic_bits) != 0 ||
+
+ /* That caught zeroes. Now test for C. */
+ ((((longword ^ charmask) + magic_bits) ^ ~(longword ^ charmask))
+ & ~magic_bits) != 0)
+ {
+ /* Which of the bytes was C or zero?
+ If none of them were, it was a misfire; continue the search. */
+
+ CONST unsigned char *cp = (CONST unsigned char *) (longword_ptr - 1);
+
+ if (*cp == c)
+ return (char *) cp;
+ else if (*cp == '\0')
+ return NULL;
+ if (*++cp == c)
+ return (char *) cp;
+ else if (*cp == '\0')
+ return NULL;
+ if (*++cp == c)
+ return (char *) cp;
+ else if (*cp == '\0')
+ return NULL;
+ if (*++cp == c)
+ return (char *) cp;
+ else if (*cp == '\0')
+ return NULL;
+ if (sizeof (longword) > 4)
+ {
+ if (*++cp == c)
+ return (char *) cp;
+ else if (*cp == '\0')
+ return NULL;
+ if (*++cp == c)
+ return (char *) cp;
+ else if (*cp == '\0')
+ return NULL;
+ if (*++cp == c)
+ return (char *) cp;
+ else if (*cp == '\0')
+ return NULL;
+ if (*++cp == c)
+ return (char *) cp;
+ else if (*cp == '\0')
+ return NULL;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+#ifdef weak_alias
+#undef index
+weak_alias (strchr, index)
+#endif
diff --git a/sysdeps/generic/strcmp.c b/sysdeps/generic/strcmp.c
new file mode 100644
index 0000000..ec0c1e6
--- /dev/null
+++ b/sysdeps/generic/strcmp.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <memcopy.h>
+
+/* Compare S1 and S2, returning less than, equal to or
+ greater than zero if S1 is lexiographically less than,
+ equal to or greater than S2. */
+int
+DEFUN(strcmp, (p1, p2), CONST char *p1 AND CONST char *p2)
+{
+ register CONST unsigned char *s1 = (CONST unsigned char *) p1;
+ register CONST unsigned char *s2 = (CONST unsigned char *) p2;
+ unsigned reg_char c1, c2;
+
+ do
+ {
+ c1 = (unsigned char) *s1++;
+ c2 = (unsigned char) *s2++;
+ if (c1 == '\0')
+ return c1 - c2;
+ }
+ while (c1 == c2);
+
+ return c1 - c2;
+}
diff --git a/sysdeps/generic/strcpy.c b/sysdeps/generic/strcpy.c
new file mode 100644
index 0000000..0a7c2a8
--- /dev/null
+++ b/sysdeps/generic/strcpy.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <string.h>
+#include <memcopy.h>
+
+/* Copy SRC to DEST. */
+char *
+DEFUN(strcpy, (dest, src), char *dest AND CONST char *src)
+{
+ reg_char c;
+ char *s = (char *) src;
+ CONST ptrdiff_t off = dest - src - 1;
+
+ do
+ {
+ c = *s++;
+ s[off] = c;
+ }
+ while (c != '\0');
+
+ return dest;
+}
+
diff --git a/sysdeps/generic/strcspn.c b/sysdeps/generic/strcspn.c
new file mode 100644
index 0000000..915faa7
--- /dev/null
+++ b/sysdeps/generic/strcspn.c
@@ -0,0 +1,38 @@
+/* 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. */
+
+#include <string.h>
+
+/* Return the length of the maximum inital segment of S
+ which contains no characters from REJECT. */
+size_t
+strcspn (s, reject)
+ register const char *s;
+ register const char *reject;
+{
+ register size_t count = 0;
+
+ while (*s != '\0')
+ if (strchr (reject, *s++) == NULL)
+ ++count;
+ else
+ return count;
+
+ return count;
+}
diff --git a/sysdeps/generic/strlen.c b/sysdeps/generic/strlen.c
new file mode 100644
index 0000000..5e8d360
--- /dev/null
+++ b/sysdeps/generic/strlen.c
@@ -0,0 +1,149 @@
+/* Copyright (C) 1991, 1993 Free Software Foundation, Inc.
+ Written by Torbjorn Granlund (tege@sics.se),
+ with help from Dan Sahlin (dan@sics.se);
+ commentary by Jim Blandy (jimb@ai.mit.edu).
+
+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. */
+
+#include <ansidecl.h>
+#include <string.h>
+
+
+/* Return the length of the null-terminated string STR. Scan for
+ the null terminator quickly by testing four bytes at a time. */
+
+size_t
+DEFUN(strlen, (str), CONST char *str)
+{
+ CONST char *char_ptr;
+ CONST unsigned long int *longword_ptr;
+ unsigned long int longword, magic_bits, himagic, lomagic;
+
+ /* Handle the first few characters by reading one character at a time.
+ Do this until CHAR_PTR is aligned on a longword boundary. */
+ for (char_ptr = str; ((unsigned long int) char_ptr
+ & (sizeof (longword) - 1)) != 0;
+ ++char_ptr)
+ if (*char_ptr == '\0')
+ return char_ptr - str;
+
+ /* All these elucidatory comments refer to 4-byte longwords,
+ but the theory applies equally well to 8-byte longwords. */
+
+ longword_ptr = (unsigned long int *) char_ptr;
+
+ /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits
+ the "holes." Note that there is a hole just to the left of
+ each byte, with an extra at the end:
+
+ bits: 01111110 11111110 11111110 11111111
+ bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
+
+ The 1-bits make sure that carries propagate to the next 0-bit.
+ The 0-bits provide holes for carries to fall into. */
+ magic_bits = 0x7efefeffL;
+ himagic = 0x80808080L;
+ lomagic = 0x01010101L;
+ if (sizeof (longword) > 4)
+ {
+ /* 64-bit version of the magic. */
+ magic_bits = (0x7efefefeL << 32) | 0xfefefeffL;
+ himagic = (himagic << 32) | himagic;
+ lomagic = (lomagic << 32) | lomagic;
+ }
+ if (sizeof (longword) > 8)
+ abort ();
+
+ /* Instead of the traditional loop which tests each character,
+ we will test a longword at a time. The tricky part is testing
+ if *any of the four* bytes in the longword in question are zero. */
+ for (;;)
+ {
+ /* We tentatively exit the loop if adding MAGIC_BITS to
+ LONGWORD fails to change any of the hole bits of LONGWORD.
+
+ 1) Is this safe? Will it catch all the zero bytes?
+ Suppose there is a byte with all zeros. Any carry bits
+ propagating from its left will fall into the hole at its
+ least significant bit and stop. Since there will be no
+ carry from its most significant bit, the LSB of the
+ byte to the left will be unchanged, and the zero will be
+ detected.
+
+ 2) Is this worthwhile? Will it ignore everything except
+ zero bytes? Suppose every byte of LONGWORD has a bit set
+ somewhere. There will be a carry into bit 8. If bit 8
+ is set, this will carry into bit 16. If bit 8 is clear,
+ one of bits 9-15 must be set, so there will be a carry
+ into bit 16. Similarly, there will be a carry into bit
+ 24. If one of bits 24-30 is set, there will be a carry
+ into bit 31, so all of the hole bits will be changed.
+
+ The one misfire occurs when bits 24-30 are clear and bit
+ 31 is set; in this case, the hole at bit 31 is not
+ changed. If we had access to the processor carry flag,
+ we could close this loophole by putting the fourth hole
+ at bit 32!
+
+ So it ignores everything except 128's, when they're aligned
+ properly. */
+
+ longword = *longword_ptr++;
+
+ if (
+#if 0
+ /* Add MAGIC_BITS to LONGWORD. */
+ (((longword + magic_bits)
+
+ /* Set those bits that were unchanged by the addition. */
+ ^ ~longword)
+
+ /* Look at only the hole bits. If any of the hole bits
+ are unchanged, most likely one of the bytes was a
+ zero. */
+ & ~magic_bits)
+#else
+ ((longword - lomagic) & himagic)
+#endif
+ != 0)
+ {
+ /* Which of the bytes was the zero? If none of them were, it was
+ a misfire; continue the search. */
+
+ CONST char *cp = (CONST char *) (longword_ptr - 1);
+
+ if (cp[0] == 0)
+ return cp - str;
+ if (cp[1] == 0)
+ return cp - str + 1;
+ if (cp[2] == 0)
+ return cp - str + 2;
+ if (cp[3] == 0)
+ return cp - str + 3;
+ if (sizeof (longword) > 4)
+ {
+ if (cp[4] == 0)
+ return cp - str + 4;
+ if (cp[5] == 0)
+ return cp - str + 5;
+ if (cp[6] == 0)
+ return cp - str + 6;
+ if (cp[7] == 0)
+ return cp - str + 7;
+ }
+ }
+ }
+}
diff --git a/sysdeps/generic/strncase.c b/sysdeps/generic/strncase.c
new file mode 100644
index 0000000..f589937
--- /dev/null
+++ b/sysdeps/generic/strncase.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <ctype.h>
+
+/* Compare no more than N characters of S1 and S2,
+ ignoring case, returning less than, equal to or
+ greater than zero if S1 is lexicographically less
+ than, equal to or greater than S2. */
+int
+DEFUN(strncasecmp, (s1, s2, n),
+ CONST char *s1 AND CONST char *s2 AND size_t n)
+{
+ register CONST unsigned char *p1 = (CONST unsigned char *) s1;
+ register CONST unsigned char *p2 = (CONST unsigned char *) s2;
+ unsigned char c1, c2;
+
+ if (p1 == p2 || n == 0)
+ return 0;
+
+ do
+ {
+ c1 = tolower (*p1++);
+ c2 = tolower (*p2++);
+ if (c1 == '\0' || c1 != c2)
+ return c1 - c2;
+ } while (--n > 0);
+
+ return c1 - c2;
+}
diff --git a/sysdeps/generic/strncat.c b/sysdeps/generic/strncat.c
new file mode 100644
index 0000000..09463b3
--- /dev/null
+++ b/sysdeps/generic/strncat.c
@@ -0,0 +1,76 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <memcopy.h>
+
+char *
+DEFUN(strncat, (s1, s2, n), char *s1 AND CONST char *s2 AND size_t n)
+{
+ reg_char c;
+ char *s = s1;
+
+ /* Find the end of S1. */
+ do
+ c = *s1++;
+ while (c != '\0');
+
+ /* Make S1 point before next character, so we can increment
+ it while memory is read (wins on pipelined cpus). */
+ s1 -= 2;
+
+ if (n >= 4)
+ {
+ size_t n4 = n >> 2;
+ do
+ {
+ c = *s2++;
+ *++s1 = c;
+ if (c == '\0')
+ return s;
+ c = *s2++;
+ *++s1 = c;
+ if (c == '\0')
+ return s;
+ c = *s2++;
+ *++s1 = c;
+ if (c == '\0')
+ return s;
+ c = *s2++;
+ *++s1 = c;
+ if (c == '\0')
+ return s;
+ } while (--n4 > 0);
+ n &= 3;
+ }
+
+ while (n > 0)
+ {
+ c = *s2++;
+ *++s1 = c;
+ if (c == '\0')
+ return s;
+ n--;
+ }
+
+ if (c != '\0')
+ *++s1 = '\0';
+
+ return s;
+}
diff --git a/sysdeps/generic/strncmp.c b/sysdeps/generic/strncmp.c
new file mode 100644
index 0000000..623d9c5
--- /dev/null
+++ b/sysdeps/generic/strncmp.c
@@ -0,0 +1,69 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <memcopy.h>
+
+/* Compare no more than N characters of S1 and S2,
+ returning less than, equal to or greater than zero
+ if S1 is lexiographically less than, equal to or
+ greater than S2. */
+int
+DEFUN(strncmp, (s1, s2, n),
+ CONST char *s1 AND CONST char *s2 AND size_t n)
+{
+ unsigned reg_char c1 = '\0';
+ unsigned reg_char c2 = '\0';
+
+ if (n >= 4)
+ {
+ size_t n4 = n >> 2;
+ do
+ {
+ c1 = (unsigned char) *s1++;
+ c2 = (unsigned char) *s2++;
+ if (c1 == '\0' || c1 != c2)
+ return c1 - c2;
+ c1 = (unsigned char) *s1++;
+ c2 = (unsigned char) *s2++;
+ if (c1 == '\0' || c1 != c2)
+ return c1 - c2;
+ c1 = (unsigned char) *s1++;
+ c2 = (unsigned char) *s2++;
+ if (c1 == '\0' || c1 != c2)
+ return c1 - c2;
+ c1 = (unsigned char) *s1++;
+ c2 = (unsigned char) *s2++;
+ if (c1 == '\0' || c1 != c2)
+ return c1 - c2;
+ } while (--n4 > 0);
+ n &= 3;
+ }
+
+ while (n > 0)
+ {
+ c1 = (unsigned char) *s1++;
+ c2 = (unsigned char) *s2++;
+ if (c1 == '\0' || c1 != c2)
+ return c1 - c2;
+ n--;
+ }
+
+ return c1 - c2;
+}
diff --git a/sysdeps/generic/strncpy.c b/sysdeps/generic/strncpy.c
new file mode 100644
index 0000000..460e0ba
--- /dev/null
+++ b/sysdeps/generic/strncpy.c
@@ -0,0 +1,82 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <memcopy.h>
+
+char *
+DEFUN(strncpy, (s1, s2, n), char *s1 AND CONST char *s2 AND size_t n)
+{
+ reg_char c;
+ char *s = s1;
+
+ --s1;
+
+ if (n >= 4)
+ {
+ size_t n4 = n >> 2;
+
+ for (;;)
+ {
+ c = *s2++;
+ *++s1 = c;
+ if (c == '\0')
+ break;
+ c = *s2++;
+ *++s1 = c;
+ if (c == '\0')
+ break;
+ c = *s2++;
+ *++s1 = c;
+ if (c == '\0')
+ break;
+ c = *s2++;
+ *++s1 = c;
+ if (c == '\0')
+ break;
+ if (--n4 == 0)
+ goto last_chars;
+ }
+ n = n - (s1 - s) - 1;
+ if (n == 0)
+ return s;
+ goto zero_fill;
+ }
+
+ last_chars:
+ n &= 3;
+ if (n == 0)
+ return s;
+
+ do
+ {
+ c = *s2++;
+ *++s1 = c;
+ if (--n == 0)
+ return s;
+ }
+ while (c != '\0');
+
+ zero_fill:
+ do
+ *++s1 = '\0';
+ while (--n > 0);
+
+ return s;
+}
diff --git a/sysdeps/generic/strpbrk.c b/sysdeps/generic/strpbrk.c
new file mode 100644
index 0000000..73339ba
--- /dev/null
+++ b/sysdeps/generic/strpbrk.c
@@ -0,0 +1,38 @@
+/* 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+
+
+/* Find the first ocurrence in S of any character in ACCEPT. */
+char *
+DEFUN(strpbrk, (s, accept),
+ register CONST char *s AND register CONST char *accept)
+{
+ while (*s != '\0')
+ {
+ const char *a = accept;
+ while (*a != '\0')
+ if (*a++ == *s)
+ return (char *) s;
+ ++s;
+ }
+
+ return NULL;
+}
diff --git a/sysdeps/generic/strrchr.c b/sysdeps/generic/strrchr.c
new file mode 100644
index 0000000..29402f0
--- /dev/null
+++ b/sysdeps/generic/strrchr.c
@@ -0,0 +1,49 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+
+
+/* Find the last ocurrence of C in S. */
+char *
+DEFUN(strrchr, (s, c), CONST char *s AND int c)
+{
+ register CONST char *found, *p;
+
+ c = (unsigned char) c;
+
+ /* Since strchr is fast, we use it rather than the obvious loop. */
+
+ if (c == '\0')
+ return strchr(s, '\0');
+
+ found = NULL;
+ while ((p = strchr(s, c)) != NULL)
+ {
+ found = p;
+ s = p + 1;
+ }
+
+ return (char *) found;
+}
+
+#ifdef weak_alias
+#undef rindex
+weak_alias (strrchr, rindex)
+#endif
diff --git a/sysdeps/generic/strsep.c b/sysdeps/generic/strsep.c
new file mode 100644
index 0000000..bb4d68b
--- /dev/null
+++ b/sysdeps/generic/strsep.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1992, 1993 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+
+char *
+DEFUN(strsep, (stringp, delim),
+ char **stringp AND CONST char *delim)
+{
+ char *begin, *end;
+
+ begin = *stringp + strspn (*stringp, delim);
+ end = *stringp + strcspn (*stringp, delim);
+
+ if (end == *stringp)
+ return NULL;
+
+ if (*end != '\0')
+ *end++ = '\0';
+ *stringp = end;
+
+ return begin;
+}
diff --git a/sysdeps/generic/strspn.c b/sysdeps/generic/strspn.c
new file mode 100644
index 0000000..89b45ad
--- /dev/null
+++ b/sysdeps/generic/strspn.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+
+
+/* Return the length of the maximum initial segment
+ of S which contains only characters in ACCEPT. */
+size_t
+DEFUN(strspn, (s, accept), CONST char *s AND CONST char *accept)
+{
+ register CONST char *p;
+ register CONST char *a;
+ register size_t count = 0;
+
+ for (p = s; *p != '\0'; ++p)
+ {
+ for (a = accept; *a != '\0'; ++a)
+ if (*p == *a)
+ break;
+ if (*a == '\0')
+ return count;
+ else
+ ++count;
+ }
+
+ return count;
+}
diff --git a/sysdeps/generic/strstr.c b/sysdeps/generic/strstr.c
new file mode 100644
index 0000000..06681de
--- /dev/null
+++ b/sysdeps/generic/strstr.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <string.h>
+
+/* Return the first ocurrence of NEEDLE in HAYSTACK. */
+char *
+DEFUN(strstr, (haystack, needle),
+ CONST char *CONST haystack AND
+ CONST char *CONST needle)
+{
+ register CONST char *CONST needle_end = strchr(needle, '\0');
+ register CONST char *CONST haystack_end = strchr(haystack, '\0');
+ register CONST size_t needle_len = needle_end - needle;
+ register CONST size_t needle_last = needle_len - 1;
+ register CONST char *begin;
+
+ if (needle_len == 0)
+ return (char *) haystack; /* ANSI 4.11.5.7, line 25. */
+ if ((size_t) (haystack_end - haystack) < needle_len)
+ return NULL;
+
+ for (begin = &haystack[needle_last]; begin < haystack_end; ++begin)
+ {
+ register CONST char *n = &needle[needle_last];
+ register CONST char *h = begin;
+
+ do
+ if (*h != *n)
+ goto loop; /* continue for loop */
+ while (--n >= needle && --h >= haystack);
+
+ return (char *) h;
+
+ loop:;
+ }
+
+ return NULL;
+}
diff --git a/sysdeps/generic/sub_n.c b/sysdeps/generic/sub_n.c
new file mode 100644
index 0000000..6b33e66
--- /dev/null
+++ b/sysdeps/generic/sub_n.c
@@ -0,0 +1,61 @@
+/* __mpn_sub_n -- Subtract two limb vectors of equal, non-zero length.
+
+Copyright (C) 1992, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
+mp_limb
+#if __STDC__
+__mpn_sub_n (mp_ptr res_ptr, mp_srcptr s1_ptr, mp_srcptr s2_ptr, mp_size_t size)
+#else
+__mpn_sub_n (res_ptr, s1_ptr, s2_ptr, size)
+ register mp_ptr res_ptr;
+ register mp_srcptr s1_ptr;
+ register mp_srcptr s2_ptr;
+ mp_size_t size;
+#endif
+{
+ register mp_limb x, y, cy;
+ register mp_size_t j;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ the loop becomes faster. */
+ j = -size;
+
+ /* Offset the base pointers to compensate for the negative indices. */
+ s1_ptr -= j;
+ s2_ptr -= j;
+ res_ptr -= j;
+
+ cy = 0;
+ do
+ {
+ y = s2_ptr[j];
+ x = s1_ptr[j];
+ y += cy; /* add previous carry to subtrahend */
+ cy = (y < cy); /* get out carry from that addition */
+ y = x - y; /* main subtract */
+ cy = (y > x) + cy; /* get out carry from the subtract, combine */
+ res_ptr[j] = y;
+ }
+ while (++j != 0);
+
+ return cy;
+}
diff --git a/sysdeps/generic/submul_1.c b/sysdeps/generic/submul_1.c
new file mode 100644
index 0000000..855dd3f
--- /dev/null
+++ b/sysdeps/generic/submul_1.c
@@ -0,0 +1,64 @@
+/* __mpn_submul_1 -- multiply the S1_SIZE long limb vector pointed to by S1_PTR
+ by S2_LIMB, subtract the S1_SIZE least significant limbs of the product
+ from the limb vector pointed to by RES_PTR. Return the most significant
+ limb of the product, adjusted for carry-out from the subtraction.
+
+Copyright (C) 1992, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include "longlong.h"
+
+mp_limb
+__mpn_submul_1 (res_ptr, s1_ptr, s1_size, s2_limb)
+ register mp_ptr res_ptr;
+ register mp_srcptr s1_ptr;
+ mp_size_t s1_size;
+ register mp_limb s2_limb;
+{
+ register mp_limb cy_limb;
+ register mp_size_t j;
+ register mp_limb prod_high, prod_low;
+ register mp_limb x;
+
+ /* The loop counter and index J goes from -SIZE to -1. This way
+ the loop becomes faster. */
+ j = -s1_size;
+
+ /* Offset the base pointers to compensate for the negative indices. */
+ res_ptr -= j;
+ s1_ptr -= j;
+
+ cy_limb = 0;
+ do
+ {
+ umul_ppmm (prod_high, prod_low, s1_ptr[j], s2_limb);
+
+ prod_low += cy_limb;
+ cy_limb = (prod_low < cy_limb) + prod_high;
+
+ x = res_ptr[j];
+ prod_low = x - prod_low;
+ cy_limb += (prod_low > x);
+ res_ptr[j] = prod_low;
+ }
+ while (++j != 0);
+
+ return cy_limb;
+}
diff --git a/sysdeps/generic/sys/mman.h b/sysdeps/generic/sys/mman.h
new file mode 100644
index 0000000..3575eeb
--- /dev/null
+++ b/sysdeps/generic/sys/mman.h
@@ -0,0 +1,106 @@
+/* Definitions for BSD-style memory management. Generic/4.4 BSD 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. */
+
+/* These are the bits used by 4.4 BSD and its derivatives. On systems
+ (such as GNU) where these facilities are not system services but can be
+ emulated in the C library, these are the definitions we emulate. */
+
+#ifndef _SYS_MMAN_H
+
+#define _SYS_MMAN_H 1
+#include <features.h>
+
+#include <gnu/types.h>
+#define __need_size_t
+#include <stddef.h>
+
+
+/* Protections are chosen from these bits, OR'd together. The
+ implementation does not necessarily support PROT_EXEC or PROT_WRITE
+ without PROT_READ. The only guarantees are that no writing will be
+ allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
+
+#define PROT_NONE 0x00 /* No access. */
+#define PROT_READ 0x04 /* Pages can be read. */
+#define PROT_WRITE 0x02 /* Pages can be written. */
+#define PROT_EXEC 0x01 /* Pages can be executed. */
+
+
+/* Flags contain mapping type, sharing type and options. */
+
+/* Mapping type (must choose one and only one of these). */
+#define MAP_FILE 0x0001 /* Mapped from a file or device. */
+#define MAP_ANON 0x0002 /* Allocated from anonymous virtual memory. */
+#define MAP_TYPE 0x000f /* Mask for type field. */
+
+/* Sharing types (must choose one and only one of these). */
+#define MAP_COPY 0x0020 /* Virtual copy of region at mapping time. */
+#define MAP_SHARED 0x0010 /* Share changes. */
+#define MAP_PRIVATE 0x0000 /* Changes private; copy pages on write. */
+
+/* Other flags. */
+#define MAP_FIXED 0x0100 /* Map address must be exactly as requested. */
+#define MAP_NOEXTEND 0x0200 /* For MAP_FILE, don't change file size. */
+#define MAP_HASSEMPHORE 0x0400 /* Region may contain semaphores. */
+#define MAP_INHERIT 0x0800 /* Region is retained after exec. */
+
+/* Advice to `madvise'. */
+#define MADV_NORMAL 0 /* No further special treatment. */
+#define MADV_RANDOM 1 /* Expect random page references. */
+#define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
+#define MADV_WILLNEED 3 /* Will need these pages. */
+#define MADV_DONTNEED 4 /* Don't need these pages. */
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+/* Map addresses starting near ADDR and extending for LEN bytes. from
+ OFFSET into the file FD describes according to PROT and FLAGS. If ADDR
+ is nonzero, it is the desired mapping address. If the MAP_FIXED bit is
+ set in FLAGS, the mapping will be at ADDR exactly (which must be
+ page-aligned); otherwise the system chooses a convenient nearby address.
+ The return value is the actual mapping address chosen or (caddr_t) -1
+ for errors (in which case `errno' is set). A successful `mmap' call
+ deallocates any previous mapping for the affected region. */
+
+__caddr_t mmap __P ((__caddr_t __addr, size_t __len,
+ int __prot, int __flags, int __fd, off_t __offset));
+
+/* Deallocate any mapping for the region starting at ADDR and extending LEN
+ bytes. Returns 0 if successful, -1 for errors (and sets errno). */
+int munmap __P ((__caddr_t __addr, size_t __len));
+
+/* Change the memory protection of the region starting at ADDR and
+ extending LEN bytes to PROT. Returns 0 if successful, -1 for errors
+ (and sets errno). */
+int mprotect __P ((__caddr_t __addr, size_t __len, int __prot));
+
+/* Synchronize the region starting at ADDR and extending LEN bytes with the
+ file it maps. Filesystem operations on a file being mapped are
+ unpredictable before this is done. */
+int msync __P ((__caddr_t __addr, size_t __len));
+
+/* Advise the system about particular usage patterns the program follows
+ for the region starting at ADDR and extending LEN bytes. */
+int madvise __P ((__caddr_t __addr, size_t __len, int __advice));
+
+__END_DECLS
+
+
+#endif /* sys/mman.h */
diff --git a/sysdeps/generic/sysd-stdio.c b/sysdeps/generic/sysd-stdio.c
new file mode 100644
index 0000000..fef0ed4
--- /dev/null
+++ b/sysdeps/generic/sysd-stdio.c
@@ -0,0 +1,189 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+/* Read N bytes into BUF from COOKIE. */
+int
+DEFUN(__stdio_read, (cookie, buf, n),
+ PTR cookie AND register char *buf AND register size_t n)
+{
+ CONST int fd = (int) cookie;
+#if defined (EINTR) && defined (EINTR_REPEAT)
+ int save = errno;
+ int nread;
+
+ try:;
+ errno = 0;
+ nread = __read (fd, buf, (int) n);
+ if (nread < 0)
+ {
+ if (errno == EINTR)
+ goto try;
+ return -1;
+ }
+ errno = save;
+ return nread;
+
+#else /* No EINTR. */
+ return __read (fd, buf, n);
+#endif
+}
+
+
+/* Write N bytes from BUF to COOKIE. */
+int
+DEFUN(__stdio_write, (cookie, buf, n),
+ PTR cookie AND register CONST char *buf AND register size_t n)
+{
+ CONST int fd = (int) cookie;
+ register size_t written = 0;
+
+ while (n > 0)
+ {
+ int count = __write (fd, buf, (int) n);
+ if (count > 0)
+ {
+ buf += count;
+ written += count;
+ n -= count;
+ }
+ else if (count < 0
+#if defined (EINTR) && defined (EINTR_REPEAT)
+ && errno != EINTR
+#endif
+ )
+ /* Write error. */
+ return -1;
+ }
+
+ return (int) written;
+}
+
+
+/* Move COOKIE's file position *POS bytes, according to WHENCE.
+ The new file position is stored in *POS.
+ Returns zero if successful, nonzero if not. */
+int
+DEFUN(__stdio_seek, (cookie, pos, whence),
+ PTR cookie AND fpos_t *pos AND int whence)
+{
+ off_t new;
+ new = __lseek ((int) cookie, (off_t) *pos, whence);
+ if (new < 0)
+ return 1;
+ *pos = (fpos_t) new;
+ return 0;
+}
+
+
+/* Close COOKIE. */
+int
+DEFUN(__stdio_close, (cookie), PTR cookie)
+{
+ return __close ((int) cookie);
+}
+
+/* Return the POSIX.1 file descriptor associated with COOKIE,
+ or -1 for errors. If COOKIE does not relate to any POSIX.1 file
+ descriptor, this should return -1 with errno set to EOPNOTSUPP. */
+int
+DEFUN(__stdio_fileno, (cookie), PTR cookie)
+{
+ return (int) cookie;
+}
+
+
+/* Open the given file with the mode given in the __io_mode argument. */
+int
+DEFUN(__stdio_open, (filename, m, cookieptr),
+ CONST char *filename AND __io_mode m AND PTR *cookieptr)
+{
+ int fd;
+ int mode;
+
+ if (m.__read && m.__write)
+ mode = O_RDWR;
+ else
+ mode = m.__read ? O_RDONLY : O_WRONLY;
+
+ if (m.__append)
+ mode |= O_APPEND;
+ if (m.__exclusive)
+ mode |= O_EXCL;
+ if (m.__truncate)
+ mode |= O_TRUNC;
+
+ if (m.__create)
+ fd = __open (filename, mode | O_CREAT,
+ S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
+ else
+ fd = __open (filename, mode);
+
+ if (fd < 0)
+ return -1;
+
+ *cookieptr = (PTR) fd;
+ return 0;
+}
+
+
+/* Open FILENAME with the mode in M. Use the same magic cookie
+ already in *COOKIEPTR if possible, closing the old cookie with CLOSEFN. */
+int
+DEFUN(__stdio_reopen, (filename, m, cookieptr),
+ CONST char *filename AND __io_mode m AND
+ PTR *cookieptr AND __io_close_fn closefn)
+{
+ PTR newcookie;
+
+ /* We leave the old descriptor open while we open the file.
+ That way ``freopen ("/dev/stdin", "r", stdin)'' works. */
+
+ if (__stdio_open (filename, m, &newcookie))
+ {
+ if (errno == ENFILE || errno == EMFILE)
+ {
+ /* We are out of file descriptors. Try closing the old one and
+ retrying the open. */
+ (void) (*closefn) (*cookieptr);
+ if (__stdio_open (filename, m, &newcookie))
+ return -1;
+ }
+ }
+
+ if (newcookie != *cookieptr)
+ {
+ if (closefn != __stdio_close ||
+ /* Try to move the descriptor to the desired one. */
+ __dup2 ((int) newcookie, (int) *cookieptr) < 0)
+ /* Didn't work. Give the caller the new cookie. */
+ *cookieptr = newcookie;
+ }
+
+ return 0;
+}
diff --git a/sysdeps/generic/tan.c b/sysdeps/generic/tan.c
new file mode 100644
index 0000000..61ed5c5
--- /dev/null
+++ b/sysdeps/generic/tan.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 1987, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)tan.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+#include "trig.h"
+double
+tan(x)
+double x;
+{
+ double a,z,ss,cc,c;
+ int k;
+
+ if(!finite(x)) /* tan(NaN) and tan(INF) must be NaN */
+ return x-x;
+ x = drem(x,PI); /* reduce x into [-PI/2, PI/2] */
+ a = copysign(x,one); /* ... = abs(x) */
+ if (a >= PIo4) {
+ k = 1;
+ x = copysign(PIo2-a,x);
+ }
+ else {
+ k = 0;
+ if (a < small) {
+ big+a;
+ return x;
+ }
+ }
+ z = x*x;
+ cc = cos__C(z);
+ ss = sin__S(z);
+ z *= half; /* Next get c = cos(x) accurately */
+ c = (z >= thresh ? half-((z-half)-cc) : one-(z-cc));
+ if (k == 0)
+ return x+(x*(z-(cc-ss)))/c; /* ... sin/cos */
+#ifdef national
+ else if (x == zero)
+ return copysign(fmax,x); /* no inf on 32k */
+#endif /* national */
+ else
+ return c/(x+x*ss); /* ... cos/sin */
+}
diff --git a/sysdeps/generic/tanh.c b/sysdeps/generic/tanh.c
new file mode 100644
index 0000000..d4923b3
--- /dev/null
+++ b/sysdeps/generic/tanh.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)tanh.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/* TANH(X)
+ * RETURN THE HYPERBOLIC TANGENT OF X
+ * DOUBLE PRECISION (VAX D FORMAT 56 BITS, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 1/8/85;
+ * REVISED BY K.C. NG on 2/8/85, 2/11/85, 3/7/85, 3/24/85.
+ *
+ * Required system supported functions :
+ * copysign(x,y)
+ * finite(x)
+ *
+ * Required kernel function:
+ * expm1(x) ...exp(x)-1
+ *
+ * Method :
+ * 1. reduce x to non-negative by tanh(-x) = - tanh(x).
+ * 2.
+ * 0 < x <= 1.e-10 : tanh(x) := x
+ * -expm1(-2x)
+ * 1.e-10 < x <= 1 : tanh(x) := --------------
+ * expm1(-2x) + 2
+ * 2
+ * 1 <= x <= 22.0 : tanh(x) := 1 - ---------------
+ * expm1(2x) + 2
+ * 22.0 < x <= INF : tanh(x) := 1.
+ *
+ * Note: 22 was chosen so that fl(1.0+2/(expm1(2*22)+2)) == 1.
+ *
+ * Special cases:
+ * tanh(NaN) is NaN;
+ * only tanh(0)=0 is exact for finite argument.
+ *
+ * Accuracy:
+ * tanh(x) returns the exact hyperbolic tangent of x nealy rounded.
+ * In a test run with 1,024,000 random arguments on a VAX, the maximum
+ * observed error was 2.22 ulps (units in the last place).
+ */
+
+double tanh(x)
+double x;
+{
+ static double one=1.0, two=2.0, small = 1.0e-10, big = 1.0e10;
+ double expm1(), t, copysign(), sign;
+ int finite();
+
+#if !defined(vax)&&!defined(tahoe)
+ if(x!=x) return(x); /* x is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+
+ sign=copysign(one,x);
+ x=copysign(x,one);
+ if(x < 22.0)
+ if( x > one )
+ return(copysign(one-two/(expm1(x+x)+two),sign));
+ else if ( x > small )
+ {t= -expm1(-(x+x)); return(copysign(t/(two-t),sign));}
+ else /* raise the INEXACT flag for non-zero x */
+ {big+x; return(copysign(x,sign));}
+ else if(finite(x))
+ return (sign+1.0E-37); /* raise the INEXACT flag */
+ else
+ return(sign); /* x is +- INF */
+}
diff --git a/sysdeps/generic/termbits.h b/sysdeps/generic/termbits.h
new file mode 100644
index 0000000..542f915
--- /dev/null
+++ b/sysdeps/generic/termbits.h
@@ -0,0 +1,202 @@
+/* termios type and macro definitions. 4.4 BSD/generic GNU version.
+Copyright (C) 1993, 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. */
+
+/* These definitions match those used by the 4.4 BSD kernel.
+ If the operating system has termios system calls or ioctls that
+ correctly implement the POSIX.1 behavior, there should be a
+ system-dependent version of this file that defines `struct termios',
+ `tcflag_t', `cc_t', `speed_t' and the `TC*' constants appropriately. */
+
+/* Type of terminal control flag masks. */
+typedef unsigned long int tcflag_t;
+
+/* Type of control characters. */
+typedef unsigned char cc_t;
+
+/* Type of baud rate specifiers. */
+typedef long int speed_t;
+
+/* Terminal control structure. */
+struct termios
+{
+ /* Input modes. */
+ tcflag_t c_iflag;
+#define IGNBRK (1 << 0) /* Ignore break condition. */
+#define BRKINT (1 << 1) /* Signal interrupt on break. */
+#define IGNPAR (1 << 2) /* Ignore characters with parity errors. */
+#define PARMRK (1 << 3) /* Mark parity and framing errors. */
+#define INPCK (1 << 4) /* Enable input parity check. */
+#define ISTRIP (1 << 5) /* Strip 8th bit off characters. */
+#define INLCR (1 << 6) /* Map NL to CR on input. */
+#define IGNCR (1 << 7) /* Ignore CR. */
+#define ICRNL (1 << 8) /* Map CR to NL on input. */
+#define IXON (1 << 9) /* Enable start/stop output control. */
+#define IXOFF (1 << 10) /* Enable start/stop input control. */
+#ifdef __USE_BSD
+#define IXANY (1 << 11) /* Any character will restart after stop. */
+#define IMAXBEL (1 << 13) /* Ring bell when input queue is full. */
+#endif
+
+ /* Output modes. */
+ tcflag_t c_oflag;
+#define OPOST (1 << 0) /* Perform output processing. */
+#ifdef __USE_BSD
+#define ONLCR (1 << 1) /* Map NL to CR-NL on output. */
+#define OXTABS (1 << 2) /* Expand tabs to spaces. */
+#define ONOEOT (1 << 8) /* Discard EOT (^D) on output. */
+#endif
+
+ /* Control modes. */
+ tcflag_t c_cflag;
+#ifdef __USE_BSD
+#define CIGNORE (1 << 0) /* Ignore these control flags. */
+#endif
+#define CSIZE (CS5|CS6|CS7|CS8) /* Number of bits per byte (mask). */
+#define CS5 0 /* 5 bits per byte. */
+#define CS6 (1 << 8) /* 6 bits per byte. */
+#define CS7 (1 << 9) /* 7 bits per byte. */
+#define CS8 (CS6|CS7) /* 8 bits per byte. */
+#define CSTOPB (1 << 10) /* Two stop bits instead of one. */
+#define CREAD (1 << 11) /* Enable receiver. */
+#define PARENB (1 << 12) /* Parity enable. */
+#define PARODD (1 << 13) /* Odd parity instead of even. */
+#define HUPCL (1 << 14) /* Hang up on last close. */
+#define CLOCAL (1 << 15) /* Ignore modem status lines. */
+#ifdef __USE_BSD
+#define CCTS_OFLOW (1 << 16) /* CTS flow control of output. */
+#define CRTS_IFLOW (1 << 17) /* RTS flow control of input. */
+#define MDMBUF (1 << 20) /* Carrier flow control of output. */
+#endif
+
+ /* Local modes. */
+ tcflag_t c_lflag;
+#ifdef __USE_BSD
+#define ECHOKE (1 << 0) /* Visual erase for KILL. */
+#endif
+#define _ECHOE (1 << 1) /* Visual erase for ERASE. */
+#define ECHOE _ECHOE
+#define _ECHOK (1 << 2) /* Echo NL after KILL. */
+#define ECHOK _ECHOK
+#define _ECHO (1 << 3) /* Enable echo. */
+#define ECHO _ECHO
+#define _ECHONL (1 << 4) /* Echo NL even if ECHO is off. */
+#define ECHONL _ECHONL
+#ifdef __USE_BSD
+#define ECHOPRT (1 << 5) /* Hardcopy visual erase. */
+#define ECHOCTL (1 << 6) /* Echo control characters as ^X. */
+#endif
+#define _ISIG (1 << 7) /* Enable signals. */
+#define ISIG _ISIG
+#define _ICANON (1 << 8) /* Do erase and kill processing. */
+#define ICANON _ICANON
+#ifdef __USE_BSD
+#define ALTWERASE (1 << 9) /* Alternate WERASE algorithm. */
+#endif
+#define _IEXTEN (1 << 10) /* Enable DISCARD and LNEXT. */
+#define IEXTEN _IEXTEN
+#define EXTPROC (1 << 11) /* External processing. */
+#define _TOSTOP (1 << 22) /* Send SIGTTOU for background output. */
+#define TOSTOP _TOSTOP
+#ifdef __USE_BSD
+#define FLUSHO (1 << 23) /* Output being flushed (state). */
+#define NOKERNINFO (1 << 25) /* Disable VSTATUS. */
+#define PENDIN (1 << 29) /* Retype pending input (state). */
+#endif
+#define _NOFLSH (1 << 31) /* Disable flush after interrupt. */
+#define NOFLSH _NOFLSH
+
+ /* Control characters. */
+#define VEOF 0 /* End-of-file character [ICANON]. */
+#define VEOL 1 /* End-of-line character [ICANON]. */
+#ifdef __USE_BSD
+#define VEOL2 2 /* Second EOL character [ICANON]. */
+#endif
+#define VERASE 3 /* Erase character [ICANON]. */
+#ifdef __USE_BSD
+#define VWERASE 4 /* Word-erase character [ICANON]. */
+#endif
+#define VKILL 5 /* Kill-line character [ICANON]. */
+#ifdef __USE_BSD
+#define VREPRINT 6 /* Reprint-line character [ICANON]. */
+#endif
+#define VINTR 8 /* Interrupt character [ISIG]. */
+#define VQUIT 9 /* Quit character [ISIG]. */
+#define VSUSP 10 /* Suspend character [ISIG]. */
+#ifdef __USE_BSD
+#define VDSUSP 11 /* Delayed suspend character [ISIG]. */
+#endif
+#define VSTART 12 /* Start (X-ON) character [IXON, IXOFF]. */
+#define VSTOP 13 /* Stop (X-OFF) character [IXON, IXOFF]. */
+#ifdef __USE_BSD
+#define VLNEXT 14 /* Literal-next character [IEXTEN]. */
+#define VDISCARD 15 /* Discard character [IEXTEN]. */
+#endif
+#define VMIN 16 /* Minimum number of bytes read at once [!ICANON]. */
+#define VTIME 17 /* Time-out value (tenths of a second) [!ICANON]. */
+#ifdef __USE_BSD
+#define VSTATUS 18 /* Status character [ICANON]. */
+#endif
+#define NCCS 20 /* Value duplicated in <hurd/tioctl.defs>. */
+ cc_t c_cc[NCCS];
+
+ /* Input and output baud rates. */
+ speed_t __ispeed, __ospeed;
+#define B0 0 /* Hang up. */
+#define B50 50 /* 50 baud. */
+#define B75 75 /* 75 baud. */
+#define B110 110 /* 110 baud. */
+#define B134 134 /* 134.5 baud. */
+#define B150 150 /* 150 baud. */
+#define B200 200 /* 200 baud. */
+#define B300 300 /* 300 baud. */
+#define B600 600 /* 600 baud. */
+#define B1200 1200 /* 1200 baud. */
+#define B1800 1800 /* 1800 baud. */
+#define B2400 2400 /* 2400 baud. */
+#define B4800 4800 /* 4800 baud. */
+#define B9600 9600 /* 9600 baud. */
+#define B19200 19200 /* 19200 baud. */
+#define B38400 38400 /* 38400 baud. */
+#ifdef __USE_BSD
+#define EXTA 19200
+#define EXTB 38400
+#endif
+};
+
+#define _IOT_termios /* Hurd ioctl type field. */ \
+ _IOT (_IOTS (tcflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)
+
+/* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'. */
+#define TCSANOW 0 /* Change immediately. */
+#define TCSADRAIN 1 /* Change when pending output is written. */
+#define TCSAFLUSH 2 /* Flush pending input before changing. */
+#ifdef __USE_BSD
+#define TCSASOFT 0x10 /* Flag: Don't alter hardware state. */
+#endif
+
+/* Values for the QUEUE_SELECTOR argument to `tcflush'. */
+#define TCIFLUSH 1 /* Discard data received but not yet read. */
+#define TCOFLUSH 2 /* Discard data written but not yet sent. */
+#define TCIOFLUSH 3 /* Discard all pending data. */
+
+/* Values for the ACTION argument to `tcflow'. */
+#define TCOOFF 1 /* Suspend output. */
+#define TCOON 2 /* Restart suspended output. */
+#define TCIOFF 3 /* Send a STOP character. */
+#define TCION 4 /* Send a START character. */
diff --git a/sysdeps/generic/trig.h b/sysdeps/generic/trig.h
new file mode 100644
index 0000000..9e05b0e
--- /dev/null
+++ b/sysdeps/generic/trig.h
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 1987, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)trig.h 8.1 (Berkeley) 6/4/93
+ */
+
+#include "mathimpl.h"
+
+vc(thresh, 2.6117239648121182150E-1 ,b863,3f85,6ea0,6b02, -1, .85B8636B026EA0)
+vc(PIo4, 7.8539816339744830676E-1 ,0fda,4049,68c2,a221, 0, .C90FDAA22168C2)
+vc(PIo2, 1.5707963267948966135E0 ,0fda,40c9,68c2,a221, 1, .C90FDAA22168C2)
+vc(PI3o4, 2.3561944901923449203E0 ,cbe3,4116,0e92,f999, 2, .96CBE3F9990E92)
+vc(PI, 3.1415926535897932270E0 ,0fda,4149,68c2,a221, 2, .C90FDAA22168C2)
+vc(PI2, 6.2831853071795864540E0 ,0fda,41c9,68c2,a221, 3, .C90FDAA22168C2)
+
+ic(thresh, 2.6117239648121182150E-1 , -2, 1.0B70C6D604DD4)
+ic(PIo4, 7.8539816339744827900E-1 , -1, 1.921FB54442D18)
+ic(PIo2, 1.5707963267948965580E0 , 0, 1.921FB54442D18)
+ic(PI3o4, 2.3561944901923448370E0 , 1, 1.2D97C7F3321D2)
+ic(PI, 3.1415926535897931160E0 , 1, 1.921FB54442D18)
+ic(PI2, 6.2831853071795862320E0 , 2, 1.921FB54442D18)
+
+#ifdef vccast
+#define thresh vccast(thresh)
+#define PIo4 vccast(PIo4)
+#define PIo2 vccast(PIo2)
+#define PI3o4 vccast(PI3o4)
+#define PI vccast(PI)
+#define PI2 vccast(PI2)
+#endif
+
+#ifdef national
+static long fmaxx[] = { 0xffffffff, 0x7fefffff};
+#define fmax (*(double*)fmaxx)
+#endif /* national */
+
+static const double
+ zero = 0,
+ one = 1,
+ negone = -1,
+ half = 1.0/2.0,
+ small = 1E-10, /* 1+small**2 == 1; better values for small:
+ * small = 1.5E-9 for VAX D
+ * = 1.2E-8 for IEEE Double
+ * = 2.8E-10 for IEEE Extended
+ */
+ big = 1E20; /* big := 1/(small**2) */
+
+/* sin__S(x*x) ... re-implemented as a macro
+ * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS)
+ * STATIC KERNEL FUNCTION OF SIN(X), COS(X), AND TAN(X)
+ * CODED IN C BY K.C. NG, 1/21/85;
+ * REVISED BY K.C. NG on 8/13/85.
+ *
+ * sin(x*k) - x
+ * RETURN --------------- on [-PI/4,PI/4] , where k=pi/PI, PI is the rounded
+ * x
+ * value of pi in machine precision:
+ *
+ * Decimal:
+ * pi = 3.141592653589793 23846264338327 .....
+ * 53 bits PI = 3.141592653589793 115997963 ..... ,
+ * 56 bits PI = 3.141592653589793 227020265 ..... ,
+ *
+ * Hexadecimal:
+ * pi = 3.243F6A8885A308D313198A2E....
+ * 53 bits PI = 3.243F6A8885A30 = 2 * 1.921FB54442D18
+ * 56 bits PI = 3.243F6A8885A308 = 4 * .C90FDAA22168C2
+ *
+ * Method:
+ * 1. Let z=x*x. Create a polynomial approximation to
+ * (sin(k*x)-x)/x = z*(S0 + S1*z^1 + ... + S5*z^5).
+ * Then
+ * sin__S(x*x) = z*(S0 + S1*z^1 + ... + S5*z^5)
+ *
+ * The coefficient S's are obtained by a special Remez algorithm.
+ *
+ * Accuracy:
+ * In the absence of rounding error, the approximation has absolute error
+ * less than 2**(-61.11) for VAX D FORMAT, 2**(-57.45) for IEEE DOUBLE.
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ *
+ */
+
+vc(S0, -1.6666666666666646660E-1 ,aaaa,bf2a,aa71,aaaa, -2, -.AAAAAAAAAAAA71)
+vc(S1, 8.3333333333297230413E-3 ,8888,3d08,477f,8888, -6, .8888888888477F)
+vc(S2, -1.9841269838362403710E-4 ,0d00,ba50,1057,cf8a, -12, -.D00D00CF8A1057)
+vc(S3, 2.7557318019967078930E-6 ,ef1c,3738,bedc,a326, -18, .B8EF1CA326BEDC)
+vc(S4, -2.5051841873876551398E-8 ,3195,b3d7,e1d3,374c, -25, -.D73195374CE1D3)
+vc(S5, 1.6028995389845827653E-10 ,3d9c,3030,cccc,6d26, -32, .B03D9C6D26CCCC)
+vc(S6, -6.2723499671769283121E-13 ,8d0b,ac30,ea82,7561, -40, -.B08D0B7561EA82)
+
+ic(S0, -1.6666666666666463126E-1 , -3, -1.555555555550C)
+ic(S1, 8.3333333332992771264E-3 , -7, 1.111111110C461)
+ic(S2, -1.9841269816180999116E-4 , -13, -1.A01A019746345)
+ic(S3, 2.7557309793219876880E-6 , -19, 1.71DE3209CDCD9)
+ic(S4, -2.5050225177523807003E-8 , -26, -1.AE5C0E319A4EF)
+ic(S5, 1.5868926979889205164E-10 , -33, 1.5CF61DF672B13)
+
+#ifdef vccast
+#define S0 vccast(S0)
+#define S1 vccast(S1)
+#define S2 vccast(S2)
+#define S3 vccast(S3)
+#define S4 vccast(S4)
+#define S5 vccast(S5)
+#define S6 vccast(S6)
+#endif
+
+#if defined(vax)||defined(tahoe)
+# define sin__S(z) (z*(S0+z*(S1+z*(S2+z*(S3+z*(S4+z*(S5+z*S6)))))))
+#else /* defined(vax)||defined(tahoe) */
+# define sin__S(z) (z*(S0+z*(S1+z*(S2+z*(S3+z*(S4+z*S5))))))
+#endif /* defined(vax)||defined(tahoe) */
+
+/* cos__C(x*x) ... re-implemented as a macro
+ * DOUBLE PRECISION (VAX D FORMAT 56 BITS, IEEE DOUBLE 53 BITS)
+ * STATIC KERNEL FUNCTION OF SIN(X), COS(X), AND TAN(X)
+ * CODED IN C BY K.C. NG, 1/21/85;
+ * REVISED BY K.C. NG on 8/13/85.
+ *
+ * x*x
+ * RETURN cos(k*x) - 1 + ----- on [-PI/4,PI/4], where k = pi/PI,
+ * 2
+ * PI is the rounded value of pi in machine precision :
+ *
+ * Decimal:
+ * pi = 3.141592653589793 23846264338327 .....
+ * 53 bits PI = 3.141592653589793 115997963 ..... ,
+ * 56 bits PI = 3.141592653589793 227020265 ..... ,
+ *
+ * Hexadecimal:
+ * pi = 3.243F6A8885A308D313198A2E....
+ * 53 bits PI = 3.243F6A8885A30 = 2 * 1.921FB54442D18
+ * 56 bits PI = 3.243F6A8885A308 = 4 * .C90FDAA22168C2
+ *
+ *
+ * Method:
+ * 1. Let z=x*x. Create a polynomial approximation to
+ * cos(k*x)-1+z/2 = z*z*(C0 + C1*z^1 + ... + C5*z^5)
+ * then
+ * cos__C(z) = z*z*(C0 + C1*z^1 + ... + C5*z^5)
+ *
+ * The coefficient C's are obtained by a special Remez algorithm.
+ *
+ * Accuracy:
+ * In the absence of rounding error, the approximation has absolute error
+ * less than 2**(-64) for VAX D FORMAT, 2**(-58.3) for IEEE DOUBLE.
+ *
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+vc(C0, 4.1666666666666504759E-2 ,aaaa,3e2a,a9f0,aaaa, -4, .AAAAAAAAAAA9F0)
+vc(C1, -1.3888888888865302059E-3 ,0b60,bbb6,0cca,b60a, -9, -.B60B60B60A0CCA)
+vc(C2, 2.4801587285601038265E-5 ,0d00,38d0,098f,cdcd, -15, .D00D00CDCD098F)
+vc(C3, -2.7557313470902390219E-7 ,f27b,b593,e805,b593, -21, -.93F27BB593E805)
+vc(C4, 2.0875623401082232009E-9 ,74c8,320f,3ff0,fa1e, -28, .8F74C8FA1E3FF0)
+vc(C5, -1.1355178117642986178E-11 ,c32d,ae47,5a63,0a5c, -36, -.C7C32D0A5C5A63)
+
+ic(C0, 4.1666666666666504759E-2 , -5, 1.555555555553E)
+ic(C1, -1.3888888888865301516E-3 , -10, -1.6C16C16C14199)
+ic(C2, 2.4801587269650015769E-5 , -16, 1.A01A01971CAEB)
+ic(C3, -2.7557304623183959811E-7 , -22, -1.27E4F1314AD1A)
+ic(C4, 2.0873958177697780076E-9 , -29, 1.1EE3B60DDDC8C)
+ic(C5, -1.1250289076471311557E-11 , -37, -1.8BD5986B2A52E)
+
+#ifdef vccast
+#define C0 vccast(C0)
+#define C1 vccast(C1)
+#define C2 vccast(C2)
+#define C3 vccast(C3)
+#define C4 vccast(C4)
+#define C5 vccast(C5)
+#endif
+
+#define cos__C(z) (z*z*(C0+z*(C1+z*(C2+z*(C3+z*(C4+z*C5))))))
diff --git a/sysdeps/generic/uname.c b/sysdeps/generic/uname.c
new file mode 100644
index 0000000..b3ecf70
--- /dev/null
+++ b/sysdeps/generic/uname.c
@@ -0,0 +1,63 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/utsname.h>
+#include <unistd.h>
+
+/* This file is created by the configuration process, and defines UNAME_*. */
+#include <config-name.h>
+
+/* Put information about the system in NAME. */
+int
+DEFUN(uname, (name), struct utsname *name)
+{
+ int save;
+
+ if (name == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ save = errno;
+ if (__gethostname (name->nodename, sizeof (name->nodename)) < 0)
+ {
+ if (errno == ENOSYS)
+ {
+ /* Hostname is meaningless for this machine. */
+ name->nodename[0] = '\0';
+ errno = save;
+ }
+#ifdef ENAMETOOLONG
+ else if (errno == ENAMETOOLONG)
+ /* The name was truncated. */
+ errno = save;
+#endif
+ else
+ return -1;
+ }
+ strncpy (name->sysname, UNAME_SYSNAME, sizeof (name->sysname));
+ strncpy (name->release, UNAME_RELEASE, sizeof (name->release));
+ strncpy (name->version, UNAME_VERSION, sizeof (name->version));
+ strncpy (name->machine, UNAME_MACHINE, sizeof (name->machine));
+
+ return 0;
+}
diff --git a/sysdeps/generic/utsnamelen.h b/sysdeps/generic/utsnamelen.h
new file mode 100644
index 0000000..5594bcc
--- /dev/null
+++ b/sysdeps/generic/utsnamelen.h
@@ -0,0 +1,3 @@
+/* The size of the character arrays used to hold the information
+ in a `struct utsname'. Enlarge this as necessary. */
+#define _UTSNAME_LENGTH 1024
diff --git a/sysdeps/generic/varargs.h b/sysdeps/generic/varargs.h
new file mode 100644
index 0000000..3500480
--- /dev/null
+++ b/sysdeps/generic/varargs.h
@@ -0,0 +1,61 @@
+/* Copyright (C) 1991 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 _VARARGS_H
+
+#define _VARARGS_H 1
+#include <features.h>
+
+#ifdef __GNUC__
+
+#define va_alist __builtin_va_alist
+#define va_dcl int __builtin_va_alist;
+#define va_list char *
+
+#ifdef __sparc__
+#define va_start(AP) \
+ (__builtin_saveregs (), \
+ AP = ((void *) &__builtin_va_alist))
+#else
+#define va_start(AP) AP=(char *) &__builtin_va_alist
+#endif
+#define va_end(AP)
+
+#define __va_rounded_size(TYPE) \
+ (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
+
+#define va_arg(AP, TYPE) \
+ (*((TYPE *) (AP += __va_rounded_size (TYPE), \
+ AP - __va_rounded_size (TYPE))))
+
+#else /* Not GCC. */
+
+/* Implement varargs on top of our stdarg implementation. */
+
+#include <stdarg.h>
+
+#define va_alist __va_fakearg
+#define va_dcl int __va_fakearg;
+
+#undef va_start
+#define va_start(ap) (__va_start((ap), __va_fakearg), \
+ (ap) -= sizeof(__va_fakearg))
+
+#endif /* GCC. */
+
+#endif /* varargs.h */
diff --git a/sysdeps/generic/vfork.c b/sysdeps/generic/vfork.c
new file mode 100644
index 0000000..f5d2e84
--- /dev/null
+++ b/sysdeps/generic/vfork.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* If we don't have vfork, fork is close enough. */
+
+__pid_t
+__vfork __P ((void))
+{
+ return __fork ();
+}
+
+weak_alias (__vfork, vfork)
diff --git a/sysdeps/generic/vlimit.c b/sysdeps/generic/vlimit.c
new file mode 100644
index 0000000..56f1199
--- /dev/null
+++ b/sysdeps/generic/vlimit.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 1991 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 generic in the sense that it will work with the BSD, SYSV,
+ or stub versions of getrlimit. Separate versions could be written
+ for efficiency, but it's probably not worth it. */
+
+#include <ansidecl.h>
+#include <sys/vlimit.h>
+#include <sys/resource.h>
+#include <errno.h>
+
+/* Set the soft limit for RESOURCE to be VALUE.
+ Returns 0 for success, -1 for failure. */
+int
+DEFUN(vlimit, (resource, value),
+ enum __vlimit_resource resource AND int value)
+{
+ if (resource >= LIM_CPU && resource <= LIM_MAXRSS)
+ {
+ /* The rlimit codes happen to each be one less
+ than the corresponding vlimit codes. */
+ enum __rlimit_resource rlimit_res =
+ (enum __rlimit_resource) ((int) resource - 1);
+ struct rlimit lims;
+
+ if (getrlimit(rlimit_res, &lims) < 0)
+ return -1;
+
+ lims.rlim_cur = value;
+ return setrlimit(rlimit_res, &lims);
+ }
+
+ errno = EINVAL;
+ return -1;
+}
diff --git a/sysdeps/generic/vtimes.c b/sysdeps/generic/vtimes.c
new file mode 100644
index 0000000..faa053f
--- /dev/null
+++ b/sysdeps/generic/vtimes.c
@@ -0,0 +1,66 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <sys/vtimes.h>
+#include <sys/resource.h>
+
+/* Return the number of 1/VTIMES_UNITS_PER_SECOND-second
+ units in the `struct timeval' TV. */
+#define TIMEVAL_TO_VTIMES(tv) \
+ ((tv.tv_sec * VTIMES_UNITS_PER_SECOND) + \
+ (tv.tv_usec * VTIMES_UNITS_PER_SECOND / 1000000))
+
+/* If VT is not NULL, write statistics for WHO into *VT.
+ Return 0 for success, -1 for failure. */
+static int
+DEFUN(vtimes_one, (vt, who),
+ struct vtimes *vt AND enum __rusage_who who)
+{
+ if (vt != NULL)
+ {
+ struct rusage usage;
+
+ if (getrusage(who, &usage) < 0)
+ return -1;
+
+ vt->vm_utime = TIMEVAL_TO_VTIMES(usage.ru_utime);
+ vt->vm_stime = TIMEVAL_TO_VTIMES(usage.ru_stime);
+ vt->vm_idsrss = usage.ru_idrss + usage.ru_isrss;
+ vt->vm_majflt = usage.ru_majflt;
+ vt->vm_minflt = usage.ru_minflt;
+ vt->vm_nswap = usage.ru_nswap;
+ vt->vm_inblk = usage.ru_inblock;
+ vt->vm_oublk = usage.ru_oublock;
+ }
+ return 0;
+}
+
+/* If CURRENT is not NULL, write statistics for the current process into
+ *CURRENT. If CHILD is not NULL, write statistics for all terminated child
+ processes into *CHILD. Returns 0 for success, -1 for failure. */
+int
+DEFUN(vtimes, (current, child),
+ struct vtimes *current AND struct vtimes *child)
+{
+ if (vtimes_one(current, RUSAGE_SELF) < 0 ||
+ vtimes_one(child, RUSAGE_CHILDREN) < 0)
+ return -1;
+ return 0;
+}
diff --git a/sysdeps/generic/waitstatus.h b/sysdeps/generic/waitstatus.h
new file mode 100644
index 0000000..fdb40db
--- /dev/null
+++ b/sysdeps/generic/waitstatus.h
@@ -0,0 +1,103 @@
+/* Definitions of status bits for `wait' et al.
+Copyright (C) 1992, 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. */
+
+/* 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)
+
+/* If WIFSIGNALED(STATUS), the terminating signal. */
+#define __WTERMSIG(status) ((status) & 0x7f)
+
+/* If WIFSTOPPED(STATUS), the signal that stopped the child. */
+#define __WSTOPSIG(status) __WEXITSTATUS(status)
+
+/* Nonzero if STATUS indicates normal termination. */
+#define __WIFEXITED(status) (__WTERMSIG(status) == 0)
+
+/* Nonzero if STATUS indicates termination by a signal. */
+#ifdef __GNUC__
+#define __WIFSIGNALED(status) \
+ (__extension__ ({ int __stat = (status); \
+ !__WIFSTOPPED(__stat) && !__WIFEXITED(__stat); }))
+#else /* Not GCC. */
+#define __WIFSIGNALED(status) (!__WIFSTOPPED(status) && !__WIFEXITED(status))
+#endif /* GCC. */
+
+/* Nonzero if STATUS indicates the child is stopped. */
+#define __WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
+
+/* Nonzero if STATUS indicates the child dumped core. */
+#define __WCOREDUMP(status) ((status) & __WCOREFLAG)
+
+/* Macros for constructing status values. */
+#define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
+#define __W_STOPCODE(sig) ((sig) << 8 | 0x7f)
+#define __WCOREFLAG 0x80
+
+
+#ifdef __USE_BSD
+
+#include <endian.h>
+
+union wait
+ {
+ struct
+ {
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned int __w_termsig:7; /* Terminating signal. */
+ unsigned int __w_coredump:1; /* Set if dumped core. */
+ unsigned int __w_retcode:8; /* Return code if exited normally. */
+ unsigned int:16;
+#endif /* Little endian. */
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int:16;
+ unsigned int __w_retcode:8;
+ unsigned int __w_coredump:1;
+ unsigned int __w_termsig:7;
+#endif /* Big endian. */
+ } __wait_terminated;
+ struct
+ {
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned int __w_stopval:8; /* W_STOPPED if stopped. */
+ unsigned int __w_stopsig:8; /* Stopping signal. */
+ unsigned int:16;
+#endif /* Little endian. */
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int:16;
+ unsigned int __w_stopsig:8; /* Stopping signal. */
+ unsigned int __w_stopval:8; /* W_STOPPED if stopped. */
+#endif /* Big endian. */
+ } __wait_stopped;
+ };
+
+#define w_termsig __wait_terminated.__w_termsig
+#define w_coredump __wait_terminated.__w_coredump
+#define w_retcode __wait_terminated.__w_retcode
+#define w_stopsig __wait_stopped.__w_stopsig
+#define w_stopval __wait_stopped.__w_stopval
+
+#endif /* Use BSD. */
+
+
+#endif /* waitstatus.h */
diff --git a/sysdeps/generic/wordcopy.c b/sysdeps/generic/wordcopy.c
new file mode 100644
index 0000000..44dabf6
--- /dev/null
+++ b/sysdeps/generic/wordcopy.c
@@ -0,0 +1,405 @@
+/* _memcopy.c -- subroutines for memory copy functions.
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+/* BE VERY CAREFUL IF YOU CHANGE THIS CODE...! */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <memcopy.h>
+
+/* _wordcopy_fwd_aligned -- Copy block beginning at SRCP to
+ block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
+ Both SRCP and DSTP should be aligned for memory operations on `op_t's. */
+
+void
+DEFUN(_wordcopy_fwd_aligned, (dstp, srcp, len),
+ long int dstp AND long int srcp AND size_t len)
+{
+ op_t a0, a1;
+
+ switch (len % 8)
+ {
+ case 2:
+ a0 = ((op_t *) srcp)[0];
+ srcp -= 6 * OPSIZ;
+ dstp -= 7 * OPSIZ;
+ len += 6;
+ goto do1;
+ case 3:
+ a1 = ((op_t *) srcp)[0];
+ srcp -= 5 * OPSIZ;
+ dstp -= 6 * OPSIZ;
+ len += 5;
+ goto do2;
+ case 4:
+ a0 = ((op_t *) srcp)[0];
+ srcp -= 4 * OPSIZ;
+ dstp -= 5 * OPSIZ;
+ len += 4;
+ goto do3;
+ case 5:
+ a1 = ((op_t *) srcp)[0];
+ srcp -= 3 * OPSIZ;
+ dstp -= 4 * OPSIZ;
+ len += 3;
+ goto do4;
+ case 6:
+ a0 = ((op_t *) srcp)[0];
+ srcp -= 2 * OPSIZ;
+ dstp -= 3 * OPSIZ;
+ len += 2;
+ goto do5;
+ case 7:
+ a1 = ((op_t *) srcp)[0];
+ srcp -= 1 * OPSIZ;
+ dstp -= 2 * OPSIZ;
+ len += 1;
+ goto do6;
+
+ case 0:
+ if (OP_T_THRES <= 3 * OPSIZ && len == 0)
+ return;
+ a0 = ((op_t *) srcp)[0];
+ srcp -= 0 * OPSIZ;
+ dstp -= 1 * OPSIZ;
+ goto do7;
+ case 1:
+ a1 = ((op_t *) srcp)[0];
+ srcp -=-1 * OPSIZ;
+ dstp -= 0 * OPSIZ;
+ len -= 1;
+ if (OP_T_THRES <= 3 * OPSIZ && len == 0)
+ goto do0;
+ goto do8; /* No-op. */
+ }
+
+ do
+ {
+ do8:
+ a0 = ((op_t *) srcp)[0];
+ ((op_t *) dstp)[0] = a1;
+ do7:
+ a1 = ((op_t *) srcp)[1];
+ ((op_t *) dstp)[1] = a0;
+ do6:
+ a0 = ((op_t *) srcp)[2];
+ ((op_t *) dstp)[2] = a1;
+ do5:
+ a1 = ((op_t *) srcp)[3];
+ ((op_t *) dstp)[3] = a0;
+ do4:
+ a0 = ((op_t *) srcp)[4];
+ ((op_t *) dstp)[4] = a1;
+ do3:
+ a1 = ((op_t *) srcp)[5];
+ ((op_t *) dstp)[5] = a0;
+ do2:
+ a0 = ((op_t *) srcp)[6];
+ ((op_t *) dstp)[6] = a1;
+ do1:
+ a1 = ((op_t *) srcp)[7];
+ ((op_t *) dstp)[7] = a0;
+
+ srcp += 8 * OPSIZ;
+ dstp += 8 * OPSIZ;
+ len -= 8;
+ }
+ while (len != 0);
+
+ /* This is the right position for do0. Please don't move
+ it into the loop. */
+ do0:
+ ((op_t *) dstp)[0] = a1;
+}
+
+/* _wordcopy_fwd_dest_aligned -- Copy block beginning at SRCP to
+ block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
+ DSTP should be aligned for memory operations on `op_t's, but SRCP must
+ *not* be aligned. */
+
+void
+DEFUN(_wordcopy_fwd_dest_aligned, (dstp, srcp, len),
+ long int dstp AND long int srcp AND size_t len)
+{
+ op_t a0, a1, a2, a3;
+ int sh_1, sh_2;
+
+ /* Calculate how to shift a word read at the memory operation
+ aligned srcp to make it aligned for copy. */
+
+ sh_1 = 8 * (srcp % OPSIZ);
+ sh_2 = 8 * OPSIZ - sh_1;
+
+ /* Make SRCP aligned by rounding it down to the beginning of the `op_t'
+ it points in the middle of. */
+ srcp &= -OPSIZ;
+
+ switch (len % 4)
+ {
+ case 2:
+ a1 = ((op_t *) srcp)[0];
+ a2 = ((op_t *) srcp)[1];
+ srcp -= 1 * OPSIZ;
+ dstp -= 3 * OPSIZ;
+ len += 2;
+ goto do1;
+ case 3:
+ a0 = ((op_t *) srcp)[0];
+ a1 = ((op_t *) srcp)[1];
+ srcp -= 0 * OPSIZ;
+ dstp -= 2 * OPSIZ;
+ len += 1;
+ goto do2;
+ case 0:
+ if (OP_T_THRES <= 3 * OPSIZ && len == 0)
+ return;
+ a3 = ((op_t *) srcp)[0];
+ a0 = ((op_t *) srcp)[1];
+ srcp -=-1 * OPSIZ;
+ dstp -= 1 * OPSIZ;
+ len += 0;
+ goto do3;
+ case 1:
+ a2 = ((op_t *) srcp)[0];
+ a3 = ((op_t *) srcp)[1];
+ srcp -=-2 * OPSIZ;
+ dstp -= 0 * OPSIZ;
+ len -= 1;
+ if (OP_T_THRES <= 3 * OPSIZ && len == 0)
+ goto do0;
+ goto do4; /* No-op. */
+ }
+
+ do
+ {
+ do4:
+ a0 = ((op_t *) srcp)[0];
+ ((op_t *) dstp)[0] = MERGE (a2, sh_1, a3, sh_2);
+ do3:
+ a1 = ((op_t *) srcp)[1];
+ ((op_t *) dstp)[1] = MERGE (a3, sh_1, a0, sh_2);
+ do2:
+ a2 = ((op_t *) srcp)[2];
+ ((op_t *) dstp)[2] = MERGE (a0, sh_1, a1, sh_2);
+ do1:
+ a3 = ((op_t *) srcp)[3];
+ ((op_t *) dstp)[3] = MERGE (a1, sh_1, a2, sh_2);
+
+ srcp += 4 * OPSIZ;
+ dstp += 4 * OPSIZ;
+ len -= 4;
+ }
+ while (len != 0);
+
+ /* This is the right position for do0. Please don't move
+ it into the loop. */
+ do0:
+ ((op_t *) dstp)[0] = MERGE (a2, sh_1, a3, sh_2);
+}
+
+/* _wordcopy_bwd_aligned -- Copy block finishing right before
+ SRCP to block finishing right before DSTP with LEN `op_t' words
+ (not LEN bytes!). Both SRCP and DSTP should be aligned for memory
+ operations on `op_t's. */
+
+void
+DEFUN(_wordcopy_bwd_aligned, (dstp, srcp, len),
+ long int dstp AND long int srcp AND size_t len)
+{
+ op_t a0, a1;
+
+ switch (len % 8)
+ {
+ case 2:
+ srcp -= 2 * OPSIZ;
+ dstp -= 1 * OPSIZ;
+ a0 = ((op_t *) srcp)[1];
+ len += 6;
+ goto do1;
+ case 3:
+ srcp -= 3 * OPSIZ;
+ dstp -= 2 * OPSIZ;
+ a1 = ((op_t *) srcp)[2];
+ len += 5;
+ goto do2;
+ case 4:
+ srcp -= 4 * OPSIZ;
+ dstp -= 3 * OPSIZ;
+ a0 = ((op_t *) srcp)[3];
+ len += 4;
+ goto do3;
+ case 5:
+ srcp -= 5 * OPSIZ;
+ dstp -= 4 * OPSIZ;
+ a1 = ((op_t *) srcp)[4];
+ len += 3;
+ goto do4;
+ case 6:
+ srcp -= 6 * OPSIZ;
+ dstp -= 5 * OPSIZ;
+ a0 = ((op_t *) srcp)[5];
+ len += 2;
+ goto do5;
+ case 7:
+ srcp -= 7 * OPSIZ;
+ dstp -= 6 * OPSIZ;
+ a1 = ((op_t *) srcp)[6];
+ len += 1;
+ goto do6;
+
+ case 0:
+ if (OP_T_THRES <= 3 * OPSIZ && len == 0)
+ return;
+ srcp -= 8 * OPSIZ;
+ dstp -= 7 * OPSIZ;
+ a0 = ((op_t *) srcp)[7];
+ goto do7;
+ case 1:
+ srcp -= 9 * OPSIZ;
+ dstp -= 8 * OPSIZ;
+ a1 = ((op_t *) srcp)[8];
+ len -= 1;
+ if (OP_T_THRES <= 3 * OPSIZ && len == 0)
+ goto do0;
+ goto do8; /* No-op. */
+ }
+
+ do
+ {
+ do8:
+ a0 = ((op_t *) srcp)[7];
+ ((op_t *) dstp)[7] = a1;
+ do7:
+ a1 = ((op_t *) srcp)[6];
+ ((op_t *) dstp)[6] = a0;
+ do6:
+ a0 = ((op_t *) srcp)[5];
+ ((op_t *) dstp)[5] = a1;
+ do5:
+ a1 = ((op_t *) srcp)[4];
+ ((op_t *) dstp)[4] = a0;
+ do4:
+ a0 = ((op_t *) srcp)[3];
+ ((op_t *) dstp)[3] = a1;
+ do3:
+ a1 = ((op_t *) srcp)[2];
+ ((op_t *) dstp)[2] = a0;
+ do2:
+ a0 = ((op_t *) srcp)[1];
+ ((op_t *) dstp)[1] = a1;
+ do1:
+ a1 = ((op_t *) srcp)[0];
+ ((op_t *) dstp)[0] = a0;
+
+ srcp -= 8 * OPSIZ;
+ dstp -= 8 * OPSIZ;
+ len -= 8;
+ }
+ while (len != 0);
+
+ /* This is the right position for do0. Please don't move
+ it into the loop. */
+ do0:
+ ((op_t *) dstp)[7] = a1;
+}
+
+/* _wordcopy_bwd_dest_aligned -- Copy block finishing right
+ before SRCP to block finishing right before DSTP with LEN `op_t'
+ words (not LEN bytes!). DSTP should be aligned for memory
+ operations on `op_t', but SRCP must *not* be aligned. */
+
+void
+DEFUN(_wordcopy_bwd_dest_aligned, (dstp, srcp, len),
+ long int dstp AND long int srcp AND size_t len)
+{
+ op_t a0, a1, a2, a3;
+ int sh_1, sh_2;
+
+ /* Calculate how to shift a word read at the memory operation
+ aligned srcp to make it aligned for copy. */
+
+ sh_1 = 8 * (srcp % OPSIZ);
+ sh_2 = 8 * OPSIZ - sh_1;
+
+ /* Make srcp aligned by rounding it down to the beginning of the op_t
+ it points in the middle of. */
+ srcp &= -OPSIZ;
+ srcp += OPSIZ;
+
+ switch (len % 4)
+ {
+ case 2:
+ srcp -= 3 * OPSIZ;
+ dstp -= 1 * OPSIZ;
+ a2 = ((op_t *) srcp)[2];
+ a1 = ((op_t *) srcp)[1];
+ len += 2;
+ goto do1;
+ case 3:
+ srcp -= 4 * OPSIZ;
+ dstp -= 2 * OPSIZ;
+ a3 = ((op_t *) srcp)[3];
+ a2 = ((op_t *) srcp)[2];
+ len += 1;
+ goto do2;
+ case 0:
+ if (OP_T_THRES <= 3 * OPSIZ && len == 0)
+ return;
+ srcp -= 5 * OPSIZ;
+ dstp -= 3 * OPSIZ;
+ a0 = ((op_t *) srcp)[4];
+ a3 = ((op_t *) srcp)[3];
+ goto do3;
+ case 1:
+ srcp -= 6 * OPSIZ;
+ dstp -= 4 * OPSIZ;
+ a1 = ((op_t *) srcp)[5];
+ a0 = ((op_t *) srcp)[4];
+ len -= 1;
+ if (OP_T_THRES <= 3 * OPSIZ && len == 0)
+ goto do0;
+ goto do4; /* No-op. */
+ }
+
+ do
+ {
+ do4:
+ a3 = ((op_t *) srcp)[3];
+ ((op_t *) dstp)[3] = MERGE (a0, sh_1, a1, sh_2);
+ do3:
+ a2 = ((op_t *) srcp)[2];
+ ((op_t *) dstp)[2] = MERGE (a3, sh_1, a0, sh_2);
+ do2:
+ a1 = ((op_t *) srcp)[1];
+ ((op_t *) dstp)[1] = MERGE (a2, sh_1, a3, sh_2);
+ do1:
+ a0 = ((op_t *) srcp)[0];
+ ((op_t *) dstp)[0] = MERGE (a1, sh_1, a2, sh_2);
+
+ srcp -= 4 * OPSIZ;
+ dstp -= 4 * OPSIZ;
+ len -= 4;
+ }
+ while (len != 0);
+
+ /* This is the right position for do0. Please don't move
+ it into the loop. */
+ do0:
+ ((op_t *) dstp)[3] = MERGE (a0, sh_1, a1, sh_2);
+}
diff --git a/sysdeps/i386/Implies b/sysdeps/i386/Implies
new file mode 100644
index 0000000..1610bfd
--- /dev/null
+++ b/sysdeps/i386/Implies
@@ -0,0 +1 @@
+ieee754
diff --git a/sysdeps/i386/Makefile b/sysdeps/i386/Makefile
new file mode 100644
index 0000000..2967678
--- /dev/null
+++ b/sysdeps/i386/Makefile
@@ -0,0 +1,3 @@
+# The mpn functions need a #define for asm syntax flavor.
+# Every i386 port in use uses gas syntax (I think).
+asm-CPPFLAGS := $(asm-CPPFLAGS) -DGAS_SYNTAX
diff --git a/sysdeps/i386/__longjmp.c b/sysdeps/i386/__longjmp.c
new file mode 100644
index 0000000..65d6ec1
--- /dev/null
+++ b/sysdeps/i386/__longjmp.c
@@ -0,0 +1,66 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#ifndef __GNUC__
+ #error This file uses GNU C extensions; you must compile with GCC.
+#endif
+
+/* Put these global register declarations first, because we get an error if
+ they come after any function definition, including inlines which might
+ be in some header. */
+
+#define REGS \
+ REG (bx);\
+ REG (si);\
+ REG (di);\
+ REG (bp);\
+ REG (sp)
+
+#define REG(xx) register long int xx asm (#xx)
+REGS;
+#undef REG
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <setjmp.h>
+#include <stdlib.h>
+
+/* Jump to the position specified by ENV, causing the
+ setjmp call there to return VAL, or 1 if VAL is 0. */
+void
+DEFUN(__longjmp, (env, val),
+ __jmp_buf env AND int val)
+{
+ /* We specify explicit registers because, when not optimizing,
+ the compiler will generate code that uses the frame pointer
+ after it's been munged. */
+
+ register CONST __typeof (env[0]) *e asm ("cx");
+ register int v asm ("ax");
+
+ e = env;
+ v = val == 0 ? 1 : val;
+
+#define REG(xx) xx = (long int) e->__##xx
+ REGS;
+
+ asm volatile ("jmp %*%0" : : "g" (e->__pc), "a" (v));
+
+ /* NOTREACHED */
+ abort ();
+}
diff --git a/sysdeps/i386/abort.c b/sysdeps/i386/abort.c
new file mode 100644
index 0000000..28513fd
--- /dev/null
+++ b/sysdeps/i386/abort.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1993, 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. */
+
+#include <ansidecl.h>
+#include <stdlib.h>
+
+/* Cause an abnormal program termination with core-dump. */
+void
+DEFUN_VOID(abort)
+{
+ while (1)
+ asm ("hlt");
+}
diff --git a/sysdeps/i386/add_n.S b/sysdeps/i386/add_n.S
new file mode 100644
index 0000000..f528976
--- /dev/null
+++ b/sysdeps/i386/add_n.S
@@ -0,0 +1,94 @@
+/* i80386 __mpn_add_n -- Add two limb vectors of the same length > 0 and store
+sum in a third limb vector.
+
+Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s1_ptr (sp + 8)
+ s2_ptr (sp + 12)
+ size (sp + 16)
+*/
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+.text
+ ALIGN (3)
+ .globl C_SYMBOL_NAME(__mpn_add_n)
+C_SYMBOL_NAME(__mpn_add_n:)
+ pushl %edi
+ pushl %esi
+
+ movl 12(%esp),%edi /* res_ptr */
+ movl 16(%esp),%esi /* s1_ptr */
+ movl 20(%esp),%edx /* s2_ptr */
+ movl 24(%esp),%ecx /* size */
+
+ movl %ecx,%eax
+ shrl $3,%ecx /* compute count for unrolled loop */
+ negl %eax
+ andl $7,%eax /* get index where to start loop */
+ jz Loop /* necessary special case for 0 */
+ incl %ecx /* adjust loop count */
+ shll $2,%eax /* adjustment for pointers... */
+ subl %eax,%edi /* ... since they are offset ... */
+ subl %eax,%esi /* ... by a constant when we ... */
+ subl %eax,%edx /* ... enter the loop */
+ shrl $2,%eax /* restore previous value */
+ leal (Loop - 3)(%eax,%eax,8),%eax /* calc start addr in loop */
+ jmp *%eax /* jump into loop */
+ ALIGN (3)
+Loop: movl (%esi),%eax
+ adcl (%edx),%eax
+ movl %eax,(%edi)
+ movl 4(%esi),%eax
+ adcl 4(%edx),%eax
+ movl %eax,4(%edi)
+ movl 8(%esi),%eax
+ adcl 8(%edx),%eax
+ movl %eax,8(%edi)
+ movl 12(%esi),%eax
+ adcl 12(%edx),%eax
+ movl %eax,12(%edi)
+ movl 16(%esi),%eax
+ adcl 16(%edx),%eax
+ movl %eax,16(%edi)
+ movl 20(%esi),%eax
+ adcl 20(%edx),%eax
+ movl %eax,20(%edi)
+ movl 24(%esi),%eax
+ adcl 24(%edx),%eax
+ movl %eax,24(%edi)
+ movl 28(%esi),%eax
+ adcl 28(%edx),%eax
+ movl %eax,28(%edi)
+ leal 32(%edi),%edi
+ leal 32(%esi),%esi
+ leal 32(%edx),%edx
+ decl %ecx
+ jnz Loop
+
+ sbbl %eax,%eax
+ negl %eax
+
+ popl %esi
+ popl %edi
+ ret
diff --git a/sysdeps/i386/addmul_1.S b/sysdeps/i386/addmul_1.S
new file mode 100644
index 0000000..3e166ec
--- /dev/null
+++ b/sysdeps/i386/addmul_1.S
@@ -0,0 +1,75 @@
+/* i80386 __mpn_addmul_1 -- Multiply a limb vector with a limb and add
+ the result to a second limb vector.
+
+Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s1_ptr (sp + 8)
+ size (sp + 12)
+ s2_limb (sp + 16)
+*/
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+#define res_ptr edi
+#define s1_ptr esi
+#define size ecx
+#define s2_limb ebp
+
+ TEXT
+ ALIGN (3)
+ GLOBL C_SYMBOL_NAME(__mpn_addmul_1)
+C_SYMBOL_NAME(__mpn_addmul_1:)
+
+ INSN1(push,l ,R(edi))
+ INSN1(push,l ,R(esi))
+ INSN1(push,l ,R(ebx))
+ INSN1(push,l ,R(ebp))
+
+ INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
+ INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
+ INSN2(mov,l ,R(size),MEM_DISP(esp,28))
+ INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
+
+ INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4))
+ INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4))
+ INSN1(neg,l ,R(size))
+ INSN2(xor,l ,R(ebx),R(ebx))
+ ALIGN (3)
+Loop:
+ INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4))
+ INSN1(mul,l ,R(s2_limb))
+ INSN2(add,l ,R(eax),R(ebx))
+ INSN2(adc,l ,R(edx),$0)
+ INSN2(add,l ,MEM_INDEX(res_ptr,size,4),R(eax))
+ INSN2(adc,l ,R(edx),$0)
+ INSN2(mov,l ,R(ebx),R(edx))
+
+ INSN1(inc,l ,R(size))
+ INSN1(jnz, ,Loop)
+ INSN2(mov,l ,R(eax),R(ebx))
+
+ INSN1(pop,l ,R(ebp))
+ INSN1(pop,l ,R(ebx))
+ INSN1(pop,l ,R(esi))
+ INSN1(pop,l ,R(edi))
+ ret
diff --git a/sysdeps/i386/asm-syntax.h b/sysdeps/i386/asm-syntax.h
new file mode 100644
index 0000000..6e28776
--- /dev/null
+++ b/sysdeps/i386/asm-syntax.h
@@ -0,0 +1,64 @@
+/* asm.h -- Definitions for x86 syntax variations.
+
+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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#undef ALIGN
+
+#ifdef GAS_SYNTAX
+#define R(r) %r
+#define MEM(base)(base)
+#define MEM_DISP(base,displacement)displacement(R(base))
+#define MEM_INDEX(base,index,size)(R(base),R(index),size)
+#ifdef __STDC__
+#define INSN1(mnemonic,size_suffix,dst)mnemonic##size_suffix dst
+#define INSN2(mnemonic,size_suffix,dst,src)mnemonic##size_suffix src,dst
+#else
+#define INSN1(mnemonic,size_suffix,dst)mnemonic/**/size_suffix dst
+#define INSN2(mnemonic,size_suffix,dst,src)mnemonic/**/size_suffix src,dst
+#endif
+#define TEXT .text
+#define ALIGN(log) .align log
+#define GLOBL .globl
+#endif
+
+#ifdef INTEL_SYNTAX
+#define R(r) r
+#define MEM(base)[base]
+#define MEM_DISP(base,displacement)[base+(displacement)]
+#define MEM_INDEX(base,index,size)[base+index*size]
+#define INSN1(mnemonic,size_suffix,dst)mnemonic dst
+#define INSN2(mnemonic,size_suffix,dst,src)mnemonic dst,src
+#define TEXT .text
+#define ALIGN(log) .align log
+#define GLOBL .globl
+#endif
+
+#ifdef BROKEN_ALIGN
+#undef ALIGN
+#define ALIGN(log) .align log,0x90
+#endif
+
+#if !defined (NOLOG_ALIGN) && defined (HAVE_ELF)
+#define NOLOG_ALIGN
+#endif
+
+#ifdef NOLOG_ALIGN
+#undef ALIGN
+#define ALIGN(log) .align 1<<log
+#endif
diff --git a/sysdeps/i386/bsd-_setjmp.S b/sysdeps/i386/bsd-_setjmp.S
new file mode 100644
index 0000000..372fc24
--- /dev/null
+++ b/sysdeps/i386/bsd-_setjmp.S
@@ -0,0 +1,32 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. i386 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. */
+
+/* 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>
+
+ENTRY (setjmp)
+ popl %eax /* Pop return PC. */
+ popl %ecx /* Pop jmp_buf argument. */
+ pushl $0 /* Push second argument of zero. */
+ pushl %ecx /* Push back first argument. */
+ pushl %eax /* Push back return PC. */
+ jmp C_SYMBOL_NAME (__sigsetjmp)
diff --git a/sysdeps/i386/bsd-setjmp.S b/sysdeps/i386/bsd-setjmp.S
new file mode 100644
index 0000000..238f030
--- /dev/null
+++ b/sysdeps/i386/bsd-setjmp.S
@@ -0,0 +1,32 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. i386 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. */
+
+/* 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>
+
+ENTRY (setjmp)
+ popl %eax /* Pop return PC. */
+ popl %ecx /* Pop jmp_buf argument. */
+ pushl $1 /* Push second argument of one. */
+ pushl %ecx /* Push back first argument. */
+ pushl %eax /* Push back return PC. */
+ jmp C_SYMBOL_NAME (__sigsetjmp)
diff --git a/sysdeps/i386/bytesex.h b/sysdeps/i386/bytesex.h
new file mode 100644
index 0000000..a5d6c5e
--- /dev/null
+++ b/sysdeps/i386/bytesex.h
@@ -0,0 +1,3 @@
+/* i386 is little-endian. */
+
+#define __BYTE_ORDER __LITTLE_ENDIAN
diff --git a/sysdeps/i386/bzero.c b/sysdeps/i386/bzero.c
new file mode 100644
index 0000000..659e54d
--- /dev/null
+++ b/sysdeps/i386/bzero.c
@@ -0,0 +1,81 @@
+/* bzero -- set a block of memory to zero.
+ For Intel 80x86, x>=3.
+ Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <memcopy.h>
+
+#undef bzero
+
+#ifdef __GNUC__
+
+void
+DEFUN(bzero, (dstpp, len),
+ PTR dstpp AND size_t len)
+{
+ /* N.B.: This code is almost verbatim from memset.c. */
+
+ unsigned long int dstp = (unsigned long int) dstpp;
+
+ /* This explicit register allocation
+ improves code very much indeed. */
+ register op_t x asm("ax");
+
+ x = 0;
+
+ /* Clear the direction flag, so filling will move forward. */
+ asm volatile("cld");
+
+ /* This threshold value is optimal. */
+ if (len >= 12)
+ {
+ /* Adjust LEN for the bytes handled in the first loop. */
+ len -= (-dstp) % OPSIZ;
+
+ /* There are at least some bytes to set.
+ No need to test for LEN == 0 in this alignment loop. */
+
+ /* Fill bytes until DSTP is aligned on a longword boundary. */
+ asm volatile("rep\n"
+ "stosb" /* %0, %2, %3 */ :
+ "=D" (dstp) :
+ "0" (dstp), "c" ((-dstp) % OPSIZ), "a" (x) :
+ "cx");
+
+ /* Fill longwords. */
+ asm volatile("rep\n"
+ "stosl" /* %0, %2, %3 */ :
+ "=D" (dstp) :
+ "0" (dstp), "c" (len / OPSIZ), "a" (x) :
+ "cx");
+ len %= OPSIZ;
+ }
+
+ /* Write the last few bytes. */
+ asm volatile("rep\n"
+ "stosb" /* %0, %2, %3 */ :
+ "=D" (dstp) :
+ "0" (dstp), "c" (len), "a" (x) :
+ "cx");
+}
+
+#else
+#include <sysdeps/generic/bzero.c>
+#endif
diff --git a/sysdeps/i386/ffs.c b/sysdeps/i386/ffs.c
new file mode 100644
index 0000000..1e21585
--- /dev/null
+++ b/sysdeps/i386/ffs.c
@@ -0,0 +1,45 @@
+/* ffs -- find first set bit in a word, counted from least significant end.
+ For Intel 80x86, x>=3.
+ Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <ansidecl.h>
+#include <string.h>
+
+#undef ffs
+
+#ifdef __GNUC__
+
+int
+DEFUN(ffs, (x), int x)
+{
+ int cnt;
+ int tmp;
+
+ asm ("xorl %0,%0\n" /* Set CNT to zero. */
+ "bsfl %2,%1\n" /* Count low bits in X and store in %1. */
+ "jz nonzero\n" /* Jump if OK, i.e. X was non-zero. */
+ "leal 1(%1),%0\n" /* Return bsfl-result plus one on %0. */
+ "nonzero:" : "=&a" (cnt), "=r" (tmp) : "rm" (x));
+
+ return cnt;
+}
+
+#else
+#include <sysdeps/generic/ffs.c>
+#endif
diff --git a/sysdeps/i386/i586/memcopy.h b/sysdeps/i386/i586/memcopy.h
new file mode 100644
index 0000000..a9bb9e7
--- /dev/null
+++ b/sysdeps/i386/i586/memcopy.h
@@ -0,0 +1,94 @@
+/* memcopy.h -- definitions for memory copy functions. Pentium version.
+ Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+/* Get the i386 definitions. We will override some of them below. */
+#include_next <memcopy.h>
+
+
+/* Written like this, the Pentium pipeline can execute the loop at a
+ sustained rate of 2 instructions/clock, or asymptotically 480
+ Mbytes/second at 60Mhz. */
+
+#undef WORD_COPY_FWD
+#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
+ do \
+ { \
+ asm volatile ("subl $32,%2\n" \
+ "js 2f\n" \
+ "1:\n" \
+ "movl 0(%1),%%eax\n" \
+ "movl 4(%1),%%edx\n" \
+ "movl %%eax,0(%0)\n" \
+ "movl %%edx,4(%0)\n" \
+ "movl 8(%1),%%eax\n" \
+ "movl 12(%1),%%edx\n" \
+ "movl %%eax,8(%0)\n" \
+ "movl %%edx,12(%0)\n" \
+ "movl 16(%1),%%eax\n" \
+ "movl 20(%1),%%edx\n" \
+ "movl %%eax,16(%0)\n" \
+ "movl %%edx,20(%0)\n" \
+ "movl 24(%1),%%eax\n" \
+ "movl 28(%1),%%edx\n" \
+ "movl %%eax,24(%0)\n" \
+ "movl %%edx,28(%0)\n" \
+ "addl $32,%1\n" \
+ "addl $32,%0\n" \
+ "subl $32,%2\n" \
+ "jns 1b\n" \
+ "2: addl $32,%2" : \
+ "=r" (dst_bp), "=r" (src_bp), "=r" (nbytes_left) : \
+ "0" (dst_bp), "1" (src_bp), "2" (nbytes) : \
+ "ax", "dx"); \
+ } while (0)
+
+#undef WORD_COPY_BWD
+#define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \
+ do \
+ { \
+ asm volatile ("subl $32,%2\n" \
+ "js 2f\n" \
+ "1:\n" \
+ "movl -4(%1),%%eax\n" \
+ "movl -8(%1),%%edx\n" \
+ "movl %%eax,-4(%0)\n" \
+ "movl %%edx,-8(%0)\n" \
+ "movl -12(%1),%%eax\n" \
+ "movl -16(%1),%%edx\n" \
+ "movl %%eax,-12(%0)\n" \
+ "movl %%edx,-16(%0)\n" \
+ "movl -20(%1),%%eax\n" \
+ "movl -24(%1),%%edx\n" \
+ "movl %%eax,-20(%0)\n" \
+ "movl %%edx,-24(%0)\n" \
+ "movl -28(%1),%%eax\n" \
+ "movl -32(%1),%%edx\n" \
+ "movl %%eax,-28(%0)\n" \
+ "movl %%edx,-32(%0)\n" \
+ "subl $32,%1\n" \
+ "subl $32,%0\n" \
+ "subl $32,%2\n" \
+ "jns 1b\n" \
+ "2: addl $32,%2" : \
+ "=r" (dst_bp), "=r" (src_bp), "=r" (nbytes_left) : \
+ "0" (dst_bp), "1" (src_bp), "2" (nbytes) : \
+ "ax", "dx"); \
+ } while (0)
diff --git a/sysdeps/i386/jmp_buf.h b/sysdeps/i386/jmp_buf.h
new file mode 100644
index 0000000..7686c4d2
--- /dev/null
+++ b/sysdeps/i386/jmp_buf.h
@@ -0,0 +1,9 @@
+/* Define the machine-dependent type `jmp_buf'. Intel 386 version. */
+
+typedef struct
+ {
+ long int __bx, __si, __di;
+ __ptr_t __bp;
+ __ptr_t __sp;
+ __ptr_t __pc;
+ } __jmp_buf[1];
diff --git a/sysdeps/i386/lshift.S b/sysdeps/i386/lshift.S
new file mode 100644
index 0000000..ca48eda
--- /dev/null
+++ b/sysdeps/i386/lshift.S
@@ -0,0 +1,84 @@
+/* i80386 __mpn_lshift --
+
+Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s_ptr (sp + 8)
+ size (sp + 12)
+ cnt (sp + 16)
+*/
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+.text
+ ALIGN (3)
+ .globl C_SYMBOL_NAME(__mpn_lshift)
+C_SYMBOL_NAME(__mpn_lshift:)
+ pushl %edi
+ pushl %esi
+ pushl %ebx
+
+ movl 16(%esp),%edi /* res_ptr */
+ movl 20(%esp),%esi /* s_ptr */
+ movl 24(%esp),%edx /* size */
+ movl 28(%esp),%ecx /* cnt */
+
+ subl $4,%esi /* adjust s_ptr */
+
+ movl (%esi,%edx,4),%ebx /* read most significant limb */
+ xorl %eax,%eax
+ shldl %cl,%ebx,%eax /* compute carry limb */
+ decl %edx
+ jz Lend
+ pushl %eax /* push carry limb onto stack */
+ testb $1,%edx
+ jnz L1 /* enter loop in the middle */
+ movl %ebx,%eax
+
+ ALIGN (3)
+Loop: movl (%esi,%edx,4),%ebx /* load next lower limb */
+ shldl %cl,%ebx,%eax /* compute result limb */
+ movl %eax,(%edi,%edx,4) /* store it */
+ decl %edx
+L1: movl (%esi,%edx,4),%eax
+ shldl %cl,%eax,%ebx
+ movl %ebx,(%edi,%edx,4)
+ decl %edx
+ jnz Loop
+
+ shll %cl,%eax /* compute least significant limb */
+ movl %eax,(%edi) /* store it */
+
+ popl %eax /* pop carry limb */
+
+ popl %ebx
+ popl %esi
+ popl %edi
+ ret
+
+Lend: shll %cl,%ebx /* compute least significant limb */
+ movl %ebx,(%edi) /* store it */
+
+ popl %ebx
+ popl %esi
+ popl %edi
+ ret
diff --git a/sysdeps/i386/memchr.c b/sysdeps/i386/memchr.c
new file mode 100644
index 0000000..ff0f8d9
--- /dev/null
+++ b/sysdeps/i386/memchr.c
@@ -0,0 +1,48 @@
+/* memchr (str, ch, n) -- Return pointer to first occurrence of CH in STR less
+ than N.
+ For Intel 80x86, x>=3.
+ Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <ansidecl.h>
+#include <string.h>
+
+#ifdef __GNUC__
+
+PTR
+DEFUN(memchr, (str, c, len),
+ CONST PTR str AND int c AND size_t len)
+{
+ PTR retval;
+ asm("cld\n" /* Search forward. */
+ "testl %1,%1\n" /* Clear Z flag, to handle LEN == 0. */
+ /* Some old versions of gas need `repne' instead of `repnz'. */
+ "repnz\n" /* Search for C in al. */
+ "scasb\n"
+ "movl %2,%0\n" /* Set %0 to 0 (without affecting Z flag). */
+ "jnz done\n" /* Jump if we found nothing equal to C. */
+ "leal -1(%1),%0\n" /* edi has been incremented. Return edi-1. */
+ "done:" :
+ "=a" (retval), "=D" (str), "=c" (len) :
+ "0" (c), "1" (str), "2" (len));
+ return retval;
+}
+
+#else
+#include <sysdeps/generic/memchr.c>
+#endif
diff --git a/sysdeps/i386/memcopy.h b/sysdeps/i386/memcopy.h
new file mode 100644
index 0000000..506d3ea
--- /dev/null
+++ b/sysdeps/i386/memcopy.h
@@ -0,0 +1,86 @@
+/* memcopy.h -- definitions for memory copy functions. i386 version.
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <sysdeps/generic/memcopy.h>
+
+#undef OP_T_THRES
+#define OP_T_THRES 8
+
+#undef BYTE_COPY_FWD
+#define BYTE_COPY_FWD(dst_bp, src_bp, nbytes) \
+ asm volatile(/* Clear the direction flag, so copying goes forward. */ \
+ "cld\n" \
+ /* Copy bytes. */ \
+ "rep\n" \
+ "movsb" : \
+ "=D" (dst_bp), "=S" (src_bp) : \
+ "0" (dst_bp), "1" (src_bp), "c" (nbytes) : \
+ "cx")
+
+#undef BYTE_COPY_BWD
+#define BYTE_COPY_BWD(dst_ep, src_ep, nbytes) \
+ do \
+ { \
+ asm volatile(/* Set the direction flag, so copying goes backwards. */ \
+ "std\n" \
+ /* Copy bytes. */ \
+ "rep\n" \
+ "movsb\n" \
+ /* Clear the dir flag. Convention says it should be 0. */ \
+ "cld" : \
+ "=D" (dst_ep), "=S" (src_ep) : \
+ "0" (dst_ep - 1), "1" (src_ep - 1), "c" (nbytes) : \
+ "cx"); \
+ dst_ep += 1; \
+ src_ep += 1; \
+ } while (0)
+
+#undef WORD_COPY_FWD
+#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
+ do \
+ { \
+ asm volatile(/* Clear the direction flag, so copying goes forward. */ \
+ "cld\n" \
+ /* Copy longwords. */ \
+ "rep\n" \
+ "movsl" : \
+ "=D" (dst_bp), "=S" (src_bp) : \
+ "0" (dst_bp), "1" (src_bp), "c" ((nbytes) / 4) : \
+ "cx"); \
+ (nbytes_left) = (nbytes) % 4; \
+ } while (0)
+
+#undef WORD_COPY_BWD
+#define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \
+ do \
+ { \
+ asm volatile(/* Set the direction flag, so copying goes backwards. */ \
+ "std\n" \
+ /* Copy longwords. */ \
+ "rep\n" \
+ "movsl\n" \
+ /* Clear the dir flag. Convention says it should be 0. */ \
+ "cld" : \
+ "=D" (dst_ep), "=S" (src_ep) : \
+ "0" (dst_ep - 4), "1" (src_ep - 4), "c" ((nbytes) / 4) : \
+ "cx"); \
+ dst_ep += 4; \
+ src_ep += 4; \
+ (nbytes_left) = (nbytes) % 4; \
+ } while (0)
diff --git a/sysdeps/i386/memset.c b/sysdeps/i386/memset.c
new file mode 100644
index 0000000..2987445
--- /dev/null
+++ b/sysdeps/i386/memset.c
@@ -0,0 +1,83 @@
+/* memset -- set a block of memory to some byte value.
+ For Intel 80x86, x>=3.
+ Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <memcopy.h>
+
+#ifdef __GNUC__
+
+PTR
+DEFUN(memset, (dstpp, c, len),
+ PTR dstpp AND int c AND size_t len)
+{
+ unsigned long int dstp = (unsigned long int) dstpp;
+
+ /* This explicit register allocation
+ improves code very much indeed. */
+ register op_t x asm("ax");
+
+ x = (unsigned char) c;
+
+ /* Clear the direction flag, so filling will move forward. */
+ asm volatile("cld");
+
+ /* This threshold value is optimal. */
+ if (len >= 12)
+ {
+ /* Fill X with four copies of the char we want to fill with. */
+ x |= (x << 8);
+ x |= (x << 16);
+
+ /* Adjust LEN for the bytes handled in the first loop. */
+ len -= (-dstp) % OPSIZ;
+
+ /* There are at least some bytes to set.
+ No need to test for LEN == 0 in this alignment loop. */
+
+ /* Fill bytes until DSTP is aligned on a longword boundary. */
+ asm volatile("rep\n"
+ "stosb" /* %0, %2, %3 */ :
+ "=D" (dstp) :
+ "0" (dstp), "c" ((-dstp) % OPSIZ), "a" (x) :
+ "cx");
+
+ /* Fill longwords. */
+ asm volatile("rep\n"
+ "stosl" /* %0, %2, %3 */ :
+ "=D" (dstp) :
+ "0" (dstp), "c" (len / OPSIZ), "a" (x) :
+ "cx");
+ len %= OPSIZ;
+ }
+
+ /* Write the last few bytes. */
+ asm volatile("rep\n"
+ "stosb" /* %0, %2, %3 */ :
+ "=D" (dstp) :
+ "0" (dstp), "c" (len), "a" (x) :
+ "cx");
+
+ return dstpp;
+}
+
+#else
+#include <sysdeps/generic/memset.c>
+#endif
diff --git a/sysdeps/i386/mul_1.S b/sysdeps/i386/mul_1.S
new file mode 100644
index 0000000..303a940
--- /dev/null
+++ b/sysdeps/i386/mul_1.S
@@ -0,0 +1,74 @@
+/* i80386 __mpn_mul_1 -- Multiply a limb vector with a limb and store
+ the result in a second limb vector.
+
+Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s1_ptr (sp + 8)
+ size (sp + 12)
+ s2_limb (sp + 16)
+*/
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+#define res_ptr edi
+#define s1_ptr esi
+#define size ecx
+#define s2_limb ebp
+
+ TEXT
+ ALIGN (3)
+ GLOBL C_SYMBOL_NAME(__mpn_mul_1)
+C_SYMBOL_NAME(__mpn_mul_1:)
+
+ INSN1(push,l ,R(edi))
+ INSN1(push,l ,R(esi))
+ INSN1(push,l ,R(ebx))
+ INSN1(push,l ,R(ebp))
+
+ INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
+ INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
+ INSN2(mov,l ,R(size),MEM_DISP(esp,28))
+ INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
+
+ INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4))
+ INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4))
+ INSN1(neg,l ,R(size))
+ INSN2(xor,l ,R(ebx),R(ebx))
+ ALIGN (3)
+Loop:
+ INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4))
+ INSN1(mul,l ,R(s2_limb))
+ INSN2(add,l ,R(eax),R(ebx))
+ INSN2(mov,l ,MEM_INDEX(res_ptr,size,4),R(eax))
+ INSN2(adc,l ,R(edx),$0)
+ INSN2(mov,l ,R(ebx),R(edx))
+
+ INSN1(inc,l ,R(size))
+ INSN1(jnz, ,Loop)
+ INSN2(mov,l ,R(eax),R(ebx))
+
+ INSN1(pop,l ,R(ebp))
+ INSN1(pop,l ,R(ebx))
+ INSN1(pop,l ,R(esi))
+ INSN1(pop,l ,R(edi))
+ ret
diff --git a/sysdeps/i386/rshift.S b/sysdeps/i386/rshift.S
new file mode 100644
index 0000000..d4aa0b9
--- /dev/null
+++ b/sysdeps/i386/rshift.S
@@ -0,0 +1,86 @@
+/* i80386 __mpn_rshift --
+
+Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s_ptr (sp + 8)
+ size (sp + 12)
+ cnt (sp + 16)
+*/
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+.text
+ ALIGN (3)
+ .globl C_SYMBOL_NAME(__mpn_rshift)
+C_SYMBOL_NAME(__mpn_rshift:)
+ pushl %edi
+ pushl %esi
+ pushl %ebx
+
+ movl 16(%esp),%edi /* res_ptr */
+ movl 20(%esp),%esi /* s_ptr */
+ movl 24(%esp),%edx /* size */
+ movl 28(%esp),%ecx /* cnt */
+
+ leal -4(%edi,%edx,4),%edi
+ leal (%esi,%edx,4),%esi
+ negl %edx
+
+ movl (%esi,%edx,4),%ebx /* read least significant limb */
+ xorl %eax,%eax
+ shrdl %cl,%ebx,%eax /* compute carry limb */
+ incl %edx
+ jz Lend
+ pushl %eax /* push carry limb onto stack */
+ testb $1,%edx
+ jnz L1 /* enter loop in the middle */
+ movl %ebx,%eax
+
+ ALIGN (3)
+Loop: movl (%esi,%edx,4),%ebx /* load next higher limb */
+ shrdl %cl,%ebx,%eax /* compute result limb */
+ movl %eax,(%edi,%edx,4) /* store it */
+ incl %edx
+L1: movl (%esi,%edx,4),%eax
+ shrdl %cl,%eax,%ebx
+ movl %ebx,(%edi,%edx,4)
+ incl %edx
+ jnz Loop
+
+ shrl %cl,%eax /* compute most significant limb */
+ movl %eax,(%edi) /* store it */
+
+ popl %eax /* pop carry limb */
+
+ popl %ebx
+ popl %esi
+ popl %edi
+ ret
+
+Lend: shrl %cl,%ebx /* compute most significant limb */
+ movl %ebx,(%edi) /* store it */
+
+ popl %ebx
+ popl %esi
+ popl %edi
+ ret
diff --git a/sysdeps/i386/setjmp.c b/sysdeps/i386/setjmp.c
new file mode 100644
index 0000000..fb8fc98
--- /dev/null
+++ b/sysdeps/i386/setjmp.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+/* Put these global register declarations first, because we get an error if
+ they come after any function definition, including inlines which might
+ be in some header. */
+
+#define REGS \
+ REG (bx);\
+ REG (si);\
+ REG (di)
+
+#define REG(xx) register long int xx asm (#xx)
+REGS;
+#undef REG
+
+#include <errno.h>
+#include <setjmp.h>
+
+/* Save the current program position in ENV and return 0. */
+int
+__sigsetjmp (jmp_buf env, int savemask)
+{
+ /* Save the general registers. */
+#define REG(xx) env[0].__jmpbuf[0].__##xx = xx
+ REGS;
+#undef REG
+
+ /* Save the return PC. */
+ env[0].__jmpbuf[0].__pc = ((void **) &env)[-1];
+
+ /* Save caller's FP, not our own. */
+ env[0].__jmpbuf[0].__bp = ((void **) &env)[-2];
+
+ /* Save caller's SP, not our own. */
+ env[0].__jmpbuf[0].__sp = (void *) &env;
+
+ /* Save the signal mask if requested. */
+ return __sigjmp_save (env, savemask);
+}
diff --git a/sysdeps/i386/strlen.c b/sysdeps/i386/strlen.c
new file mode 100644
index 0000000..3c1398b
--- /dev/null
+++ b/sysdeps/i386/strlen.c
@@ -0,0 +1,36 @@
+/* strlen -- determine the length of a string.
+ For Intel 80x86, x>=3.
+ Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <ansidecl.h>
+#include <string.h>
+
+size_t
+DEFUN(strlen, (str), CONST char *str)
+{
+ int cnt;
+
+ asm("cld\n" /* Search forward. */
+ /* Some old versions of gas need `repne' instead of `repnz'. */
+ "repnz\n" /* Look for a zero byte. */
+ "scasb" /* %0, %1, %3 */ :
+ "=c" (cnt) : "D" (str), "0" (-1), "a" (0));
+
+ return -2 - cnt;
+}
diff --git a/sysdeps/i386/sub_n.S b/sysdeps/i386/sub_n.S
new file mode 100644
index 0000000..a1630d4
--- /dev/null
+++ b/sysdeps/i386/sub_n.S
@@ -0,0 +1,94 @@
+/* i80386 __mpn_sub_n -- Add two limb vectors of the same length > 0 and store
+ sum in a third limb vector.
+
+Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s1_ptr (sp + 8)
+ s2_ptr (sp + 12)
+ size (sp + 16)
+*/
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+.text
+ ALIGN (3)
+ .globl C_SYMBOL_NAME(__mpn_sub_n)
+C_SYMBOL_NAME(__mpn_sub_n:)
+ pushl %edi
+ pushl %esi
+
+ movl 12(%esp),%edi /* res_ptr */
+ movl 16(%esp),%esi /* s1_ptr */
+ movl 20(%esp),%edx /* s2_ptr */
+ movl 24(%esp),%ecx /* size */
+
+ movl %ecx,%eax
+ shrl $3,%ecx /* compute count for unrolled loop */
+ negl %eax
+ andl $7,%eax /* get index where to start loop */
+ jz Loop /* necessary special case for 0 */
+ incl %ecx /* adjust loop count */
+ shll $2,%eax /* adjustment for pointers... */
+ subl %eax,%edi /* ... since they are offset ... */
+ subl %eax,%esi /* ... by a constant when we ... */
+ subl %eax,%edx /* ... enter the loop */
+ shrl $2,%eax /* restore previous value */
+ leal (Loop - 3)(%eax,%eax,8),%eax /* calc start addr in loop */
+ jmp *%eax /* jump into loop */
+ ALIGN (3)
+Loop: movl (%esi),%eax
+ sbbl (%edx),%eax
+ movl %eax,(%edi)
+ movl 4(%esi),%eax
+ sbbl 4(%edx),%eax
+ movl %eax,4(%edi)
+ movl 8(%esi),%eax
+ sbbl 8(%edx),%eax
+ movl %eax,8(%edi)
+ movl 12(%esi),%eax
+ sbbl 12(%edx),%eax
+ movl %eax,12(%edi)
+ movl 16(%esi),%eax
+ sbbl 16(%edx),%eax
+ movl %eax,16(%edi)
+ movl 20(%esi),%eax
+ sbbl 20(%edx),%eax
+ movl %eax,20(%edi)
+ movl 24(%esi),%eax
+ sbbl 24(%edx),%eax
+ movl %eax,24(%edi)
+ movl 28(%esi),%eax
+ sbbl 28(%edx),%eax
+ movl %eax,28(%edi)
+ leal 32(%edi),%edi
+ leal 32(%esi),%esi
+ leal 32(%edx),%edx
+ decl %ecx
+ jnz Loop
+
+ sbbl %eax,%eax
+ negl %eax
+
+ popl %esi
+ popl %edi
+ ret
diff --git a/sysdeps/i386/submul_1.S b/sysdeps/i386/submul_1.S
new file mode 100644
index 0000000..5ab78f6
--- /dev/null
+++ b/sysdeps/i386/submul_1.S
@@ -0,0 +1,75 @@
+/* i80386 __mpn_submul_1 -- Multiply a limb vector with a limb and subtract
+ the result from a second limb vector.
+
+Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s1_ptr (sp + 8)
+ size (sp + 12)
+ s2_limb (sp + 16)
+*/
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+#define res_ptr edi
+#define s1_ptr esi
+#define size ecx
+#define s2_limb ebp
+
+ TEXT
+ ALIGN (3)
+ GLOBL C_SYMBOL_NAME(__mpn_submul_1)
+C_SYMBOL_NAME(__mpn_submul_1:)
+
+ INSN1(push,l ,R(edi))
+ INSN1(push,l ,R(esi))
+ INSN1(push,l ,R(ebx))
+ INSN1(push,l ,R(ebp))
+
+ INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20))
+ INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24))
+ INSN2(mov,l ,R(size),MEM_DISP(esp,28))
+ INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32))
+
+ INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4))
+ INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4))
+ INSN1(neg,l ,R(size))
+ INSN2(xor,l ,R(ebx),R(ebx))
+ ALIGN (3)
+Loop:
+ INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4))
+ INSN1(mul,l ,R(s2_limb))
+ INSN2(add,l ,R(eax),R(ebx))
+ INSN2(adc,l ,R(edx),$0)
+ INSN2(sub,l ,MEM_INDEX(res_ptr,size,4),R(eax))
+ INSN2(adc,l ,R(edx),$0)
+ INSN2(mov,l ,R(ebx),R(edx))
+
+ INSN1(inc,l ,R(size))
+ INSN1(jnz, ,Loop)
+ INSN2(mov,l ,R(eax),R(ebx))
+
+ INSN1(pop,l ,R(ebp))
+ INSN1(pop,l ,R(ebx))
+ INSN1(pop,l ,R(esi))
+ INSN1(pop,l ,R(edi))
+ ret
diff --git a/sysdeps/i860/memcopy.h b/sysdeps/i860/memcopy.h
new file mode 100644
index 0000000..9f81326
--- /dev/null
+++ b/sysdeps/i860/memcopy.h
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991 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. */
+
+#include <sysdeps/generic/memcopy.h>
+
+#if 0
+#undef MERGE
+/* In order to make this work properly, an 's' constraint need to be added
+ to tm-i860.h, to mean the SC register. */
+#define MERGE(w0, sh_1, w1, sh_2) \
+ ({ \
+ unsigned int __merge; \
+ asm("shrd %2,%1,%0" : \
+ "=r" (__merge) : \
+ "r" (w0), "r" (w1), "s" (sh_1)); \
+ __merge; \
+ })
+#endif
diff --git a/sysdeps/i960/Implies b/sysdeps/i960/Implies
new file mode 100644
index 0000000..f8c4079
--- /dev/null
+++ b/sysdeps/i960/Implies
@@ -0,0 +1,2 @@
+# i960 family uses IEEE 754 floating point.
+ieee754
diff --git a/sysdeps/i960/ffs.c b/sysdeps/i960/ffs.c
new file mode 100644
index 0000000..62b8742
--- /dev/null
+++ b/sysdeps/i960/ffs.c
@@ -0,0 +1,43 @@
+/* ffs -- find first set bit in a word, counted from least significant end.
+ For i960 Core architecture
+ Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <string.h>
+
+#undef ffs
+
+#if defined (__GNUC__) && defined (__i960__)
+
+int
+DEFUN(ffs, (x), int x)
+{
+ int cnt;
+
+ asm("scanbit %1,%0" : "=d" (cnt) : "rm" (x & -x));
+
+ return cnt;
+}
+
+#else
+
+#include <sysdeps/generic/ffs.c>
+
+#endif
diff --git a/sysdeps/ieee754/Dist b/sysdeps/ieee754/Dist
new file mode 100644
index 0000000..94cc5c9
--- /dev/null
+++ b/sysdeps/ieee754/Dist
@@ -0,0 +1,2 @@
+support.c
+ieee754.h
diff --git a/sysdeps/ieee754/cabs.c b/sysdeps/ieee754/cabs.c
new file mode 100644
index 0000000..6b0d4c4
--- /dev/null
+++ b/sysdeps/ieee754/cabs.c
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)cabs.c 5.6 (Berkeley) 10/9/90";
+#endif /* not lint */
+
+/* HYPOT(X,Y)
+ * RETURN THE SQUARE ROOT OF X^2 + Y^2 WHERE Z=X+iY
+ * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 11/28/84;
+ * REVISED BY K.C. NG, 7/12/85.
+ *
+ * Required system supported functions :
+ * copysign(x,y)
+ * finite(x)
+ * scalb(x,N)
+ * sqrt(x)
+ *
+ * Method :
+ * 1. replace x by |x| and y by |y|, and swap x and
+ * y if y > x (hence x is never smaller than y).
+ * 2. Hypot(x,y) is computed by:
+ * Case I, x/y > 2
+ *
+ * y
+ * hypot = x + -----------------------------
+ * 2
+ * sqrt ( 1 + [x/y] ) + x/y
+ *
+ * Case II, x/y <= 2
+ * y
+ * hypot = x + --------------------------------------------------
+ * 2
+ * [x/y] - 2
+ * (sqrt(2)+1) + (x-y)/y + -----------------------------
+ * 2
+ * sqrt ( 1 + [x/y] ) + sqrt(2)
+ *
+ *
+ *
+ * Special cases:
+ * hypot(x,y) is INF if x or y is +INF or -INF; else
+ * hypot(x,y) is NAN if x or y is NAN.
+ *
+ * Accuracy:
+ * hypot(x,y) returns the sqrt(x^2+y^2) with error less than 1 ulps (units
+ * in the last place). See Kahan's "Interval Arithmetic Options in the
+ * Proposed IEEE Floating Point Arithmetic Standard", Interval Mathematics
+ * 1980, Edited by Karl L.E. Nickel, pp 99-128. (A faster but less accurate
+ * code follows in comments.) In a test run with 500,000 random arguments
+ * on a VAX, the maximum observed error was .959 ulps.
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+#include "mathimpl.h"
+
+vc(r2p1hi, 2.4142135623730950345E0 ,8279,411a,ef32,99fc, 2, .9A827999FCEF32)
+vc(r2p1lo, 1.4349369327986523769E-17 ,597d,2484,754b,89b3, -55, .84597D89B3754B)
+vc(sqrt2, 1.4142135623730950622E0 ,04f3,40b5,de65,33f9, 1, .B504F333F9DE65)
+
+ic(r2p1hi, 2.4142135623730949234E0 , 1, 1.3504F333F9DE6)
+ic(r2p1lo, 1.2537167179050217666E-16 , -53, 1.21165F626CDD5)
+ic(sqrt2, 1.4142135623730951455E0 , 0, 1.6A09E667F3BCD)
+
+#ifdef vccast
+#define r2p1hi vccast(r2p1hi)
+#define r2p1lo vccast(r2p1lo)
+#define sqrt2 vccast(sqrt2)
+#endif
+
+double
+hypot(x,y)
+double x, y;
+{
+ static const double zero=0, one=1,
+ small=1.0E-18; /* fl(1+small)==1 */
+ static const ibig=30; /* fl(1+2**(2*ibig))==1 */
+ double t,r;
+ int exp;
+
+ if(finite(x))
+ if(finite(y))
+ {
+ x=copysign(x,one);
+ y=copysign(y,one);
+ if(y > x)
+ { t=x; x=y; y=t; }
+ if(x == zero) return(zero);
+ if(y == zero) return(x);
+ exp= logb(x);
+ if(exp-(int)logb(y) > ibig )
+ /* raise inexact flag and return |x| */
+ { one+small; return(x); }
+
+ /* start computing sqrt(x^2 + y^2) */
+ r=x-y;
+ if(r>y) { /* x/y > 2 */
+ r=x/y;
+ r=r+sqrt(one+r*r); }
+ else { /* 1 <= x/y <= 2 */
+ r/=y; t=r*(r+2.0);
+ r+=t/(sqrt2+sqrt(2.0+t));
+ r+=r2p1lo; r+=r2p1hi; }
+
+ r=y/r;
+ return(x+r);
+
+ }
+
+ else if(y==y) /* y is +-INF */
+ return(copysign(y,one));
+ else
+ return(y); /* y is NaN and x is finite */
+
+ else if(x==x) /* x is +-INF */
+ return (copysign(x,one));
+ else if(finite(y))
+ return(x); /* x is NaN, y is finite */
+#if !defined(vax)&&!defined(tahoe)
+ else if(y!=y) return(y); /* x and y is NaN */
+#endif /* !defined(vax)&&!defined(tahoe) */
+ else return(copysign(y,one)); /* y is INF */
+}
+
+/* CABS(Z)
+ * RETURN THE ABSOLUTE VALUE OF THE COMPLEX NUMBER Z = X + iY
+ * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS)
+ * CODED IN C BY K.C. NG, 11/28/84.
+ * REVISED BY K.C. NG, 7/12/85.
+ *
+ * Required kernel function :
+ * hypot(x,y)
+ *
+ * Method :
+ * cabs(z) = hypot(x,y) .
+ */
+
+double
+cabs(z)
+struct __cabs_complex z;
+{
+ return hypot(z.__x,z.__y);
+}
+
+double
+z_abs(z)
+struct __cabs_complex *z;
+{
+ return hypot(z->__x,z->__y);
+}
+
+/* A faster but less accurate version of cabs(x,y) */
+#if 0
+double hypot(x,y)
+double x, y;
+{
+ static const double zero=0, one=1;
+ small=1.0E-18; /* fl(1+small)==1 */
+ static const ibig=30; /* fl(1+2**(2*ibig))==1 */
+ double temp;
+ int exp;
+
+ if(finite(x))
+ if(finite(y))
+ {
+ x=copysign(x,one);
+ y=copysign(y,one);
+ if(y > x)
+ { temp=x; x=y; y=temp; }
+ if(x == zero) return(zero);
+ if(y == zero) return(x);
+ exp= logb(x);
+ x=scalb(x,-exp);
+ if(exp-(int)logb(y) > ibig )
+ /* raise inexact flag and return |x| */
+ { one+small; return(scalb(x,exp)); }
+ else y=scalb(y,-exp);
+ return(scalb(sqrt(x*x+y*y),exp));
+ }
+
+ else if(y==y) /* y is +-INF */
+ return(copysign(y,one));
+ else
+ return(y); /* y is NaN and x is finite */
+
+ else if(x==x) /* x is +-INF */
+ return (copysign(x,one));
+ else if(finite(y))
+ return(x); /* x is NaN, y is finite */
+ else if(y!=y) return(y); /* x and y is NaN */
+ else return(copysign(y,one)); /* y is INF */
+}
+#endif
diff --git a/sysdeps/ieee754/cbrt.c b/sysdeps/ieee754/cbrt.c
new file mode 100644
index 0000000..fe5fb95
--- /dev/null
+++ b/sysdeps/ieee754/cbrt.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)cbrt.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+#include <sys/cdefs.h>
+
+/* kahan's cube root (53 bits IEEE double precision)
+ * for IEEE machines only
+ * coded in C by K.C. Ng, 4/30/85
+ *
+ * Accuracy:
+ * better than 0.667 ulps according to an error analysis. Maximum
+ * error observed was 0.666 ulps in an 1,000,000 random arguments test.
+ *
+ * Warning: this code is semi machine dependent; the ordering of words in
+ * a floating point number must be known in advance. I assume that the
+ * long interger at the address of a floating point number will be the
+ * leading 32 bits of that floating point number (i.e., sign, exponent,
+ * and the 20 most significant bits).
+ * On a National machine, it has different ordering; therefore, this code
+ * must be compiled with flag -DNATIONAL.
+ */
+#if !defined(vax)&&!defined(tahoe)
+
+static const unsigned long
+ B1 = 715094163, /* B1 = (682-0.03306235651)*2**20 */
+ B2 = 696219795; /* B2 = (664-0.03306235651)*2**20 */
+static const double
+ C= 19./35.,
+ D= -864./1225.,
+ E= 99./70.,
+ F= 45./28.,
+ G= 5./14.;
+
+double cbrt(x)
+double x;
+{
+ double r,s,t=0.0,w;
+ unsigned long *px = (unsigned long *) &x,
+ *pt = (unsigned long *) &t,
+ mexp,sign;
+
+#ifdef national /* ordering of words in a floating points number */
+ const int n0=1,n1=0;
+#else /* national */
+ const int n0=0,n1=1;
+#endif /* national */
+
+ mexp=px[n0]&0x7ff00000;
+ if(mexp==0x7ff00000) return(x); /* cbrt(NaN,INF) is itself */
+ if(x==0.0) return(x); /* cbrt(0) is itself */
+
+ sign=px[n0]&0x80000000; /* sign= sign(x) */
+ px[n0] ^= sign; /* x=|x| */
+
+
+ /* rough cbrt to 5 bits */
+ if(mexp==0) /* subnormal number */
+ {pt[n0]=0x43500000; /* set t= 2**54 */
+ t*=x; pt[n0]=pt[n0]/3+B2;
+ }
+ else
+ pt[n0]=px[n0]/3+B1;
+
+
+ /* new cbrt to 23 bits, may be implemented in single precision */
+ r=t*t/x;
+ s=C+r*t;
+ t*=G+F/(s+E+D/s);
+
+ /* chopped to 20 bits and make it larger than cbrt(x) */
+ pt[n1]=0; pt[n0]+=0x00000001;
+
+
+ /* one step newton iteration to 53 bits with error less than 0.667 ulps */
+ s=t*t; /* t*t is exact */
+ r=x/s;
+ w=t+t;
+ r=(r-t)/(w+r); /* r-t is exact */
+ t=t+t*r;
+
+
+ /* retore the sign bit */
+ pt[n0] |= sign;
+ return(t);
+}
+#endif
diff --git a/sysdeps/ieee754/copysign.c b/sysdeps/ieee754/copysign.c
new file mode 100644
index 0000000..f1f0591
--- /dev/null
+++ b/sysdeps/ieee754/copysign.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+#include "ieee754.h"
+
+/* Return X with its signed changed to Y's. */
+double
+DEFUN(__copysign, (x, y), double x AND double y)
+{
+ union ieee754_double ux, uy;
+
+ ux.d = x;
+ uy.d = y;
+
+ ux.ieee.negative = uy.ieee.negative;
+
+ return ux.d;
+}
+
+weak_alias (__copysign, copysign)
diff --git a/sysdeps/ieee754/dbl2mpn.c b/sysdeps/ieee754/dbl2mpn.c
new file mode 100644
index 0000000..6b690f7
--- /dev/null
+++ b/sysdeps/ieee754/dbl2mpn.c
@@ -0,0 +1,107 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include "longlong.h"
+#include "ieee754.h"
+#include <float.h>
+#include <stdlib.h>
+
+/* Convert a `double' in IEEE754 standard double-precision format to a
+ multi-precision integer representing the significand scaled up by its
+ number of bits (52 for double) and an integral power of two (MPN frexp). */
+
+mp_size_t
+__mpn_extract_double (mp_ptr res_ptr, mp_size_t size,
+ int *expt, int *is_neg,
+ double value)
+{
+ union ieee754_double u;
+ u.d = value;
+
+ *is_neg = u.ieee.negative;
+ *expt = (int) u.ieee.exponent - IEEE754_DOUBLE_BIAS;
+
+#if BITS_PER_MP_LIMB == 32
+ res_ptr[0] = u.ieee.mantissa1; /* Low-order 32 bits of fraction. */
+ res_ptr[1] = u.ieee.mantissa0; /* High-order 20 bits. */
+ #define N 2
+#elif BITS_PER_MP_LIMB == 64
+ /* Hopefully the compiler will combine the two bitfield extracts
+ and this composition into just the original quadword extract. */
+ res_ptr[0] = (u.ieee.mantissa0 << 32) | u.ieee.mantissa1;
+ #define N 1
+#else
+ #error "mp_limb size " BITS_PER_MP_LIMB "not accounted for"
+#endif
+/* The format does not fill the last limb. There are some zeros. */
+#define NUM_LEADING_ZEROS (BITS_PER_MP_LIMB \
+ - (DBL_MANT_DIG - ((N - 1) * BITS_PER_MP_LIMB)))
+
+ if (u.ieee.exponent == 0)
+ {
+ /* A biased exponent of zero is a special case.
+ Either it is a zero or it is a denormal number. */
+ if (res_ptr[0] == 0 && res_ptr[N - 1] == 0) /* Assumes N<=2. */
+ /* It's zero. */
+ *expt = 0;
+ else
+ {
+ /* It is a denormal number, meaning it has no implicit leading
+ one bit, and its exponent is in fact the format minimum. */
+ int cnt;
+
+ if (res_ptr[N - 1] != 0)
+ {
+ count_leading_zeros (cnt, res_ptr[N - 1]);
+ cnt -= NUM_LEADING_ZEROS;
+#if N == 2
+ res_ptr[N - 1] = res_ptr[1] << cnt
+ | (N - 1)
+ * (res_ptr[0] >> (BITS_PER_MP_LIMB - cnt));
+ res_ptr[0] <<= cnt;
+#else
+ res_ptr[N - 1] <<= cnt;
+#endif
+ *expt = DBL_MIN_EXP - 1 - cnt;
+ }
+ else
+ {
+ count_leading_zeros (cnt, res_ptr[0]);
+ if (cnt >= NUM_LEADING_ZEROS)
+ {
+ res_ptr[N - 1] = res_ptr[0] << (cnt - NUM_LEADING_ZEROS);
+ res_ptr[0] = 0;
+ }
+ else
+ {
+ res_ptr[N - 1] = res_ptr[0] >> (NUM_LEADING_ZEROS - cnt);
+ res_ptr[0] <<= BITS_PER_MP_LIMB - (NUM_LEADING_ZEROS - cnt);
+ }
+ *expt = DBL_MIN_EXP - 1
+ - (BITS_PER_MP_LIMB - NUM_LEADING_ZEROS) - cnt;
+ }
+ }
+ }
+ else
+ /* Add the implicit leading one bit for a normalized number. */
+ res_ptr[N - 1] |= 1 << (DBL_MANT_DIG - 1 - ((N - 1) * BITS_PER_MP_LIMB));
+
+ return N;
+}
diff --git a/sysdeps/ieee754/drem.c b/sysdeps/ieee754/drem.c
new file mode 100644
index 0000000..cab3a04
--- /dev/null
+++ b/sysdeps/ieee754/drem.c
@@ -0,0 +1,107 @@
+/* Copyright (C) 1992, 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. */
+
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted provided
+ * that: (1) source distributions retain this entire copyright notice and
+ * comment, and (2) distributions including binaries display the following
+ * acknowledgement: ``This product includes software developed by the
+ * University of California, Berkeley and its contributors'' in the
+ * documentation or other materials provided with the distribution and in
+ * all advertising materials mentioning features or use of this software.
+ * Neither the name of the University nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <ansidecl.h>
+#include <math.h>
+#include <float.h>
+#include "ieee754.h"
+
+/* Return the remainder of X/Y. */
+double
+DEFUN(__drem, (x, y),
+ double x AND double y)
+{
+ union ieee754_double ux, uy;
+
+ ux.d = x;
+ uy.d = y;
+#define x ux.d
+#define y uy.d
+
+ uy.ieee.negative = 0;
+
+ if (!__finite (x) || y == 0.0)
+ return NAN;
+ else if (__isnan (y))
+ return y;
+ else if (__isinf (y))
+ return x;
+ else if (uy.ieee.exponent <= 1)
+ {
+ /* Subnormal (or almost subnormal) Y value. */
+ double b = __scalb (1.0, 54);
+ y *= b;
+ x = __drem (x, y);
+ x *= b;
+ return __drem (x, y) / b;
+ }
+ else if (y >= 1.7e308 / 2)
+ {
+ y /= 2;
+ x /= 2;
+ return __drem (x, y) * 2;
+ }
+ else
+ {
+ union ieee754_double a;
+ double b;
+ unsigned int negative = ux.ieee.negative;
+ a.d = y + y;
+ b = y / 2;
+ ux.ieee.negative = 0;
+ while (x > a.d)
+ {
+ unsigned short int k = ux.ieee.exponent - a.ieee.exponent;
+ union ieee754_double tmp;
+ tmp.d = a.d;
+ tmp.ieee.exponent += k;
+ if (x < tmp.d)
+ --tmp.ieee.exponent;
+ x -= tmp.d;
+ }
+ if (x > b)
+ {
+ x -= y;
+ if (x >= b)
+ x -= y;
+ }
+ ux.ieee.negative ^= negative;
+ return x;
+ }
+}
+
+weak_alias (__drem, drem)
diff --git a/sysdeps/ieee754/frexp.c b/sysdeps/ieee754/frexp.c
new file mode 100644
index 0000000..c56a17f
--- /dev/null
+++ b/sysdeps/ieee754/frexp.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1993 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. */
+
+#include <math.h>
+#include "ieee754.h"
+
+/* Break VALUE into a normalized fraction and an integral power of 2. */
+
+double
+frexp (value, exp)
+ double value;
+ int *exp;
+{
+ if (value == 0)
+ {
+ *exp = 0;
+ return 0;
+ }
+ else
+ {
+ union ieee754_double u;
+ u.d = value;
+ *exp = u.ieee.exponent - 1022;
+ u.ieee.exponent = 1022;
+ return u.d;
+ }
+}
diff --git a/sysdeps/ieee754/huge_val.h b/sysdeps/ieee754/huge_val.h
new file mode 100644
index 0000000..183f213
--- /dev/null
+++ b/sysdeps/ieee754/huge_val.h
@@ -0,0 +1,87 @@
+/* `HUGE_VAL' constant for IEEE 754 machines (where it is infinity).
+ Used by <stdlib.h> and <math.h> functions for overflow.
+
+Copyright (C) 1992, 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. */
+
+#ifndef _HUGE_VAL_H
+#define _HUGE_VAL_H 1
+
+#include <features.h>
+#include <sys/cdefs.h>
+#include <endian.h>
+
+/* IEEE positive infinity (-HUGE_VAL is negative infinity). */
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define __HUGE_VAL_bytes { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }
+#endif
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define __HUGE_VAL_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }
+#endif
+
+#define __huge_val_t union { unsigned char __c[8]; double __d; }
+#ifdef __GNUC__
+#define HUGE_VAL (__extension__ \
+ ((__huge_val_t) { __c: __HUGE_VAL_bytes }).__d)
+#else /* Not GCC. */
+static __huge_val_t __huge_val = { __HUGE_VAL_bytes };
+#define HUGE_VAL (__huge_val.__d)
+#endif /* GCC. */
+
+
+/* GNU extensions: (float) HUGE_VALf and (long double) HUGE_VALl. */
+
+#ifdef __USE_GNU
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define __HUGE_VALf_bytes { 0x7f, 0x80, 0, 0 }
+#endif
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define __HUGE_VALf_bytes { 0, 0, 0x80, 0x7f }
+#endif
+
+#define __huge_valf_t union { unsigned char __c[4]; float __f; }
+#ifdef __GNUC__
+#define HUGE_VALf (__extension__ \
+ ((__huge_valf_t) { __c: __HUGE_VALf_bytes }).__f)
+#else /* Not GCC. */
+static __huge_valf_t __huge_valf = { __HUGE_VALf_bytes };
+#define HUGE_VALf (__huge_valf.__f)
+#endif /* GCC. */
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define __HUGE_VALl_bytes { 0x7f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+#endif
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define __HUGE_VALl_bytes { 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0x7f, 0, 0 }
+#endif
+
+#define __huge_vall_t union { unsigned char __c[12]; long double __ld; }
+#ifdef __GNUC__
+#define HUGE_VALl (__extension__ \
+ ((__huge_vall_t) { __c: __HUGE_VALl_bytes }).__ld)
+#else /* Not GCC. */
+static __huge_vall_t __huge_vall = { __HUGE_VALl_bytes };
+#define HUGE_VALl (__huge_vall.__ld)
+#endif /* GCC. */
+
+#endif /* __USE_GNU. */
+
+
+#endif /* huge_val.h */
diff --git a/sysdeps/ieee754/ieee754.h b/sysdeps/ieee754/ieee754.h
new file mode 100644
index 0000000..9cc6f14
--- /dev/null
+++ b/sysdeps/ieee754/ieee754.h
@@ -0,0 +1,153 @@
+/* Copyright (C) 1992, 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. */
+
+#include <endian.h>
+
+union ieee754_float
+ {
+ float f;
+
+ /* This is the IEEE 754 single-precision format. */
+ struct
+ {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int negative:1;
+ unsigned int exponent:8;
+ unsigned int mantissa:23;
+#endif /* Big endian. */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned int mantissa:23;
+ unsigned int exponent:8;
+ unsigned int negative:1;
+#endif /* Little endian. */
+ } ieee;
+
+ /* This format makes it easier to see if a NaN is a signalling NaN. */
+ struct
+ {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int negative:1;
+ unsigned int exponent:8;
+ unsigned int quiet_nan:1;
+ unsigned int mantissa:22;
+#endif /* Big endian. */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned int mantissa:22;
+ unsigned int quiet_nan:1;
+ unsigned int exponent:8;
+ unsigned int negative:1;
+#endif /* Little endian. */
+ } ieee_nan;
+ };
+
+#define IEEE754_FLOAT_BIAS 0x7f /* Added to exponent. */
+
+
+union ieee754_double
+ {
+ double d;
+
+ /* This is the IEEE 754 double-precision format. */
+ struct
+ {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int negative:1;
+ unsigned int exponent:11;
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa0:20;
+ unsigned int mantissa1:32;
+#endif /* Big endian. */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:20;
+ unsigned int exponent:11;
+ unsigned int negative:1;
+#endif /* Little endian. */
+ } ieee;
+
+ /* This format makes it easier to see if a NaN is a signalling NaN. */
+ struct
+ {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int negative:1;
+ unsigned int exponent:11;
+ unsigned int quiet_nan:1;
+ /* Together these conprise the mantissa. */
+ unsigned int mantissa0:19;
+ unsigned int mantissa1:32;
+#else
+ /* Together these conprise the mantissa. */
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:19;
+ unsigned int quiet_nan:1;
+ unsigned int exponent:11;
+ unsigned int negative:1;
+#endif
+ } ieee_nan;
+ };
+
+#define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */
+
+
+union ieee854_long_double
+ {
+ long double d;
+
+ /* This is the IEEE 854 double-extended-precision format. */
+ struct
+ {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int negative:1;
+ unsigned int exponent:15;
+ unsigned int empty:16;
+ unsigned int mantissa0:32;
+ unsigned int mantissa1:32;
+#endif
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:32;
+ unsigned int exponent:15;
+ unsigned int negative:1;
+ unsigned int empty:16;
+#endif
+ } ieee;
+
+ /* This is for NaNs in the IEEE 854 double-extended-precision format. */
+ struct
+ {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int negative:1;
+ unsigned int exponent:15;
+ unsigned int empty:16;
+ unsigned int quiet_nan:1;
+ unsigned int mantissa0:31;
+ unsigned int mantissa1:32;
+#endif
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:31;
+ unsigned int quiet_nan:1;
+ unsigned int exponent:15;
+ unsigned int negative:1;
+ unsigned int empty:16;
+#endif
+ } ieee_nan;
+ };
+
+#define IEEE854_LONG_DOUBLE_BIAS 0x3fff
diff --git a/sysdeps/ieee754/infnan.c b/sysdeps/ieee754/infnan.c
new file mode 100644
index 0000000..89ab5b6
--- /dev/null
+++ b/sysdeps/ieee754/infnan.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+#include <float.h>
+#include "ieee754.h"
+
+/* Deal with an infinite or NaN result.
+ If ERROR is ERANGE, result is +Inf;
+ if ERROR is - ERANGE, result is -Inf;
+ otherwise result is NaN.
+ This will set `errno' to either ERANGE or EDOM,
+ and may return an infinity or NaN, or may do something else. */
+double
+DEFUN(__infnan, (error), int error)
+{
+ switch (error)
+ {
+ case ERANGE:
+ errno = ERANGE;
+ return HUGE_VAL;
+
+ case - ERANGE:
+ errno = ERANGE;
+ return - HUGE_VAL;
+
+ default:
+ errno = EDOM;
+ return NAN;
+ }
+}
+
+weak_alias (__infnan, infnan)
diff --git a/sysdeps/ieee754/isinf.c b/sysdeps/ieee754/isinf.c
new file mode 100644
index 0000000..79be916
--- /dev/null
+++ b/sysdeps/ieee754/isinf.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+#include "ieee754.h"
+
+/* Return 0 if VALUE is finite or NaN, +1 if it
+ is +Infinity, -1 if it is -Infinity. */
+int
+DEFUN(__isinf, (value), double value)
+{
+ union ieee754_double u;
+
+ u.d = value;
+ /* An IEEE 754 infinity has an exponent with the
+ maximum possible value and a zero mantissa. */
+ if ((u.ieee.exponent & 0x7ff) == 0x7ff &&
+ u.ieee.mantissa0 == 0 && u.ieee.mantissa1 == 0)
+ return u.ieee.negative ? -1 : 1;
+
+ return 0;
+}
+
+weak_alias (__isinf, isinf)
diff --git a/sysdeps/ieee754/isinfl.c b/sysdeps/ieee754/isinfl.c
new file mode 100644
index 0000000..ad03728
--- /dev/null
+++ b/sysdeps/ieee754/isinfl.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <math.h>
+#include "ieee754.h"
+
+#undef __isinfl
+#undef isinfl
+
+
+/* Return 0 if VALUE is finite or NaN, +1 if it
+ is +Infinity, -1 if it is -Infinity. */
+int
+__isinfl (long double value)
+{
+ union ieee854_long_double u;
+
+ u.d = value;
+
+ /* An IEEE 854 infinity has an exponent with the
+ maximum possible value and a zero mantissa. */
+ if ((u.ieee.exponent & 0x7fff) == 0x7fff &&
+ u.ieee.mantissa0 == 0 && u.ieee.mantissa1 == 0)
+ return u.ieee.negative ? -1 : 1;
+
+ return 0;
+}
+
+weak_alias (__isinfl, isinfl);
diff --git a/sysdeps/ieee754/isnan.c b/sysdeps/ieee754/isnan.c
new file mode 100644
index 0000000..8a537cc
--- /dev/null
+++ b/sysdeps/ieee754/isnan.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+#include "ieee754.h"
+
+/* Return nonzero if VALUE is not a number. */
+int
+DEFUN(__isnan, (value), double value)
+{
+ union ieee754_double u;
+
+ u.d = value;
+
+ /* IEEE 754 NaN's have the maximum possible
+ exponent and a nonzero mantissa. */
+ return ((u.ieee.exponent & 0x7ff) == 0x7ff &&
+ (u.ieee.mantissa0 != 0 || u.ieee.mantissa1 != 0));
+}
+
+weak_alias (__isnan, isnan)
diff --git a/sysdeps/ieee754/isnanl.c b/sysdeps/ieee754/isnanl.c
new file mode 100644
index 0000000..b06b31a
--- /dev/null
+++ b/sysdeps/ieee754/isnanl.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <math.h>
+#include "ieee754.h"
+
+#undef __isnanl
+#undef isnanl
+
+
+/* Return nonzero if VALUE is not a number. */
+int
+__isnanl (long double value)
+{
+ union ieee854_long_double u;
+
+ u.d = value;
+
+ /* IEEE 854 NaN's have the maximum possible
+ exponent and a nonzero mantissa. */
+ return ((u.ieee.exponent & 0x7fff) == 0x7fff &&
+ (u.ieee.mantissa0 != 0 || u.ieee.mantissa1 != 0));
+}
+
+weak_alias (__isnanl, isnanl);
diff --git a/sysdeps/ieee754/ldbl2mpn.c b/sysdeps/ieee754/ldbl2mpn.c
new file mode 100644
index 0000000..29e8a3b
--- /dev/null
+++ b/sysdeps/ieee754/ldbl2mpn.c
@@ -0,0 +1,93 @@
+/* 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. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include "longlong.h"
+#include "ieee754.h"
+#include <float.h>
+#include <stdlib.h>
+
+/* Convert a `long double' in IEEE854 standard double-precision format to a
+ multi-precision integer representing the significand scaled up by its
+ number of bits (64 for long double) and an integral power of two
+ (MPN frexpl). */
+
+mp_size_t
+__mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
+ int *expt, int *is_neg,
+ long double value)
+{
+ union ieee854_long_double u;
+ u.d = value;
+
+ *is_neg = u.ieee.negative;
+ *expt = (int) u.ieee.exponent - IEEE854_LONG_DOUBLE_BIAS;
+
+#if BITS_PER_MP_LIMB == 32
+ res_ptr[0] = u.ieee.mantissa1; /* Low-order 32 bits of fraction. */
+ res_ptr[1] = u.ieee.mantissa0; /* High-order 32 bits. */
+ #define N 2
+#elif BITS_PER_MP_LIMB == 64
+ /* Hopefully the compiler will combine the two bitfield extracts
+ and this composition into just the original quadword extract. */
+ res_ptr[0] = (u.ieee.mantissa0 << 32) | u.ieee.mantissa1;
+ #define N 1
+#else
+ #error "mp_limb size " BITS_PER_MP_LIMB "not accounted for"
+#endif
+
+ if (u.ieee.exponent == 0)
+ {
+ /* A biased exponent of zero is a special case.
+ Either it is a zero or it is a denormal number. */
+ if (res_ptr[0] == 0 && res_ptr[N - 1] == 0) /* Assumes N<=2. */
+ /* It's zero. */
+ *expt = 0;
+ else
+ {
+ /* It is a denormal number, meaning it has no implicit leading
+ one bit, and its exponent is in fact the format minimum. */
+ int cnt;
+ if (res_ptr[N - 1] != 0)
+ {
+ count_leading_zeros (cnt, res_ptr[N - 1]);
+ if (cnt != 0)
+ {
+#if N == 2
+ res_ptr[N - 1] = res_ptr[N - 1] << cnt
+ | (res_ptr[0] >> (BITS_PER_MP_LIMB - cnt));
+ res_ptr[0] <<= cnt;
+#else
+ res_ptr[N - 1] <<= cnt;
+#endif
+ }
+ *expt = LDBL_MIN_EXP - 2 - cnt;
+ }
+ else
+ {
+ count_leading_zeros (cnt, res_ptr[0]);
+ res_ptr[N - 1] = res_ptr[0] << cnt;
+ res_ptr[0] = 0;
+ *expt = LDBL_MIN_EXP - 2 - BITS_PER_MP_LIMB - cnt;
+ }
+ }
+ }
+
+ return N;
+}
diff --git a/sysdeps/ieee754/ldexp.c b/sysdeps/ieee754/ldexp.c
new file mode 100644
index 0000000..7e1c747
--- /dev/null
+++ b/sysdeps/ieee754/ldexp.c
@@ -0,0 +1,145 @@
+/* Copyright (C) 1992, 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. */
+
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted provided
+ * that: (1) source distributions retain this entire copyright notice and
+ * comment, and (2) distributions including binaries display the following
+ * acknowledgement: ``This product includes software developed by the
+ * University of California, Berkeley and its contributors'' in the
+ * documentation or other materials provided with the distribution and in
+ * all advertising materials mentioning features or use of this software.
+ * Neither the name of the University nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <ansidecl.h>
+#include <math.h>
+#include <float.h>
+#include "ieee754.h"
+
+double
+DEFUN(ldexp, (x, exp),
+ double x AND int exp)
+{
+ union ieee754_double u;
+ unsigned int exponent;
+
+ u.d = x;
+#define x u.d
+
+ exponent = u.ieee.exponent;
+
+ /* The order of the tests is carefully chosen to handle
+ the usual case first, with no branches taken. */
+
+ if (exponent != 0)
+ {
+ /* X is nonzero and not denormalized. */
+
+ if (exponent <= DBL_MAX_EXP - DBL_MIN_EXP + 1)
+ {
+ /* X is finite. When EXP < 0, overflow is actually underflow. */
+
+ exponent += exp;
+
+ if (exponent != 0)
+ {
+ if (exponent <= DBL_MAX_EXP - DBL_MIN_EXP + 1)
+ {
+ /* In range. */
+ u.ieee.exponent = exponent;
+ return x;
+ }
+
+ if (exp >= 0)
+ overflow:
+ {
+ CONST int negative = u.ieee.negative;
+ u.d = HUGE_VAL;
+ u.ieee.negative = negative;
+ errno = ERANGE;
+ return u.d;
+ }
+
+ if (exponent <= - (unsigned int) (DBL_MANT_DIG + 1))
+ {
+ /* Underflow. */
+ CONST int negative = u.ieee.negative;
+ u.d = 0.0;
+ u.ieee.negative = negative;
+ errno = ERANGE;
+ return u.d;
+ }
+ }
+
+ /* Gradual underflow. */
+ u.ieee.exponent = 1;
+ u.d *= ldexp (1.0, (int) exponent - 1);
+ if (u.ieee.mantissa0 == 0 && u.ieee.mantissa1 == 0)
+ /* Underflow. */
+ errno = ERANGE;
+ return u.d;
+ }
+
+ /* X is +-infinity or NaN. */
+ if (u.ieee.mantissa0 == 0 && u.ieee.mantissa1 == 0)
+ {
+ /* X is +-infinity. */
+ if (exp >= 0)
+ goto overflow;
+ else
+ {
+ /* (infinity * number < 1). With infinite precision,
+ (infinity / finite) would be infinity, but otherwise it's
+ safest to regard (infinity / 2) as indeterminate. The
+ infinity might be (2 * finite). */
+ CONST int negative = u.ieee.negative;
+ u.d = NAN;
+ u.ieee.negative = negative;
+ errno = EDOM;
+ return u.d;
+ }
+ }
+
+ /* X is NaN. */
+ errno = EDOM;
+ return u.d;
+ }
+
+ /* X is zero or denormalized. */
+ if (u.ieee.mantissa0 == 0 && u.ieee.mantissa1 == 0)
+ /* X is +-0.0. */
+ return x;
+
+ /* X is denormalized.
+ Multiplying by 2 ** DBL_MANT_DIG normalizes it;
+ we then subtract the DBL_MANT_DIG we added to the exponent. */
+ return ldexp (x * ldexp (1.0, DBL_MANT_DIG), exp - DBL_MANT_DIG);
+}
+
+/* Compatibility names for the same function. */
+weak_alias (ldexp, __scalb)
+weak_alias (ldexp, scalb)
diff --git a/sysdeps/ieee754/log10.c b/sysdeps/ieee754/log10.c
new file mode 100644
index 0000000..da2f5b4
--- /dev/null
+++ b/sysdeps/ieee754/log10.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the base-ten logarithm of X. */
+double
+DEFUN(log10, (x), double x)
+{
+ CONST double inverse_ln10 = 4.3429448190325181667e-1; /* 1 / log(10) */
+
+ return inverse_ln10 * log(x);
+}
diff --git a/sysdeps/ieee754/logb.c b/sysdeps/ieee754/logb.c
new file mode 100644
index 0000000..918de9e
--- /dev/null
+++ b/sysdeps/ieee754/logb.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+#include <float.h>
+#include "ieee754.h"
+
+/* Return the base 2 signed integral exponent of X. */
+double
+DEFUN(__logb, (x), double x)
+{
+ union ieee754_double u;
+
+ if (__isnan (x))
+ return x;
+ else if (__isinf (x))
+ return HUGE_VAL;
+ else if (x == 0.0)
+ return - HUGE_VAL;
+
+ u.d = x;
+
+ if (u.ieee.exponent == 0)
+ /* A denormalized number.
+ Multiplying by 2 ** DBL_MANT_DIG normalizes it;
+ we then subtract the DBL_MANT_DIG we added to the exponent. */
+ return (__logb (x * ldexp (1.0, DBL_MANT_DIG)) - DBL_MANT_DIG);
+
+ return (int) u.ieee.exponent - (DBL_MAX_EXP - 1);
+}
+
+weak_alias (__logb, logb)
diff --git a/sysdeps/ieee754/mpn2dbl.c b/sysdeps/ieee754/mpn2dbl.c
new file mode 100644
index 0000000..01e0019
--- /dev/null
+++ b/sysdeps/ieee754/mpn2dbl.c
@@ -0,0 +1,46 @@
+/* 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. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include "ieee754.h"
+#include <float.h>
+
+/* Convert a multi-precision integer of the needed number of bits (53 for
+ double) and an integral power of two to a `double' in IEEE754 double-
+ precision format. */
+
+double
+__mpn_construct_double (mp_srcptr frac_ptr, int expt, int negative)
+{
+ union ieee754_double u;
+
+ u.ieee.negative = negative;
+ u.ieee.exponent = expt + IEEE754_DOUBLE_BIAS;
+#if BITS_PER_MP_LIMB == 32
+ u.ieee.mantissa1 = frac_ptr[0];
+ u.ieee.mantissa0 = frac_ptr[1] & ((1 << (DBL_MANT_DIG - 32)) - 1);
+#elif BITS_PER_MP_LIMB == 64
+ u.ieee.mantissa1 = frac_ptr[0] & ((1 << 32) - 1);
+ i.ieee.mantissa0 = (frac_ptr[0] >> 32) & ((1 << (DBL_MANT_DIG - 32)) - 1);
+#else
+ #error "mp_limb size " BITS_PER_MP_LIMB "not accounted for"
+#endif
+
+ return u.d;
+}
diff --git a/sysdeps/ieee754/mpn2flt.c b/sysdeps/ieee754/mpn2flt.c
new file mode 100644
index 0000000..e9bbc49
--- /dev/null
+++ b/sysdeps/ieee754/mpn2flt.c
@@ -0,0 +1,42 @@
+/* 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. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include "ieee754.h"
+#include <float.h>
+
+/* Convert a multi-precision integer of the needed number of bits (24 for
+ float) and an integral power of two to a `float' in IEEE754 single-
+ precision format. */
+
+float
+__mpn_construct_float (mp_srcptr frac_ptr, int expt, int sign)
+{
+ union ieee754_float u;
+
+ u.ieee.negative = sign;
+ u.ieee.exponent = expt + IEEE754_FLOAT_BIAS;
+#if BITS_PER_MP_LIMB > FLT_MANT_DIG
+ u.ieee.mantissa = frac_ptr[0] & ((1 << FLT_MANT_DIG) - 1);
+#else
+ #error "mp_limb size " BITS_PER_MP_LIMB "not accounted for"
+#endif
+
+ return u.f;
+}
diff --git a/sysdeps/ieee754/mpn2ldbl.c b/sysdeps/ieee754/mpn2ldbl.c
new file mode 100644
index 0000000..831f2e5
--- /dev/null
+++ b/sysdeps/ieee754/mpn2ldbl.c
@@ -0,0 +1,46 @@
+/* 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. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include "ieee754.h"
+#include <float.h>
+
+/* Convert a multi-precision integer of the needed number of bits (64 for
+ long double) and an integral power of two to a `long double' in IEEE854
+ extended-precision format. */
+
+long double
+__mpn_construct_long_double (mp_srcptr frac_ptr, int expt, int sign)
+{
+ union ieee854_long_double u;
+
+ u.ieee.negative = sign;
+ u.ieee.exponent = expt + IEEE854_LONG_DOUBLE_BIAS;
+#if BITS_PER_MP_LIMB == 32
+ u.ieee.mantissa1 = frac_ptr[0];
+ u.ieee.mantissa0 = frac_ptr[1];
+#elif BITS_PER_MP_LIMB == 64
+ u.ieee.mantissa1 = frac_ptr[0] & ((1 << 32) - 1);
+ i.ieee.mantissa0 = frac_ptr[0] >> 32;
+#else
+ #error "mp_limb size " BITS_PER_MP_LIMB "not accounted for"
+#endif
+
+ return u.d;
+}
diff --git a/sysdeps/ieee754/nan.h b/sysdeps/ieee754/nan.h
new file mode 100644
index 0000000..e34c172
--- /dev/null
+++ b/sysdeps/ieee754/nan.h
@@ -0,0 +1,46 @@
+/* `NAN' constant for IEEE 754 machines.
+
+Copyright (C) 1992 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 _NAN_H
+
+#define _NAN_H 1
+
+/* IEEE Not A Number. */
+
+#include <endian.h>
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define __nan_bytes { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 }
+#endif
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define __nan_bytes { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }
+#endif
+
+#ifdef __GNUC__
+#define NAN \
+ (__extension__ ((union { unsigned char __c[8]; \
+ double __d; }) \
+ { __nan_bytes }).__d)
+#else /* Not GCC. */
+static CONST char __nan[8] = __nan_bytes;
+#define NAN (*(CONST double *) __nan)
+#endif /* GCC. */
+
+#endif /* nan.h */
diff --git a/sysdeps/ieee754/sqrt.c b/sysdeps/ieee754/sqrt.c
new file mode 100644
index 0000000..7e350e0
--- /dev/null
+++ b/sysdeps/ieee754/sqrt.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted provided
+ * that: (1) source distributions retain this entire copyright notice and
+ * comment, and (2) distributions including binaries display the following
+ * acknowledgement: ``This product includes software developed by the
+ * University of California, Berkeley and its contributors'' in the
+ * documentation or other materials provided with the distribution and in
+ * all advertising materials mentioning features or use of this software.
+ * Neither the name of the University nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the square root of X. */
+double
+DEFUN (sqrt, (x), double x)
+{
+ double q, s, b, r, t;
+ CONST double zero = 0.0;
+ int m, n, i;
+
+ /* sqrt (NaN) is NaN; sqrt (+-0) is +-0. */
+ if (__isnan (x) || x == zero)
+ return x;
+
+ if (x < zero)
+ return zero / zero;
+
+ /* sqrt (Inf) is Inf. */
+ if (__isinf (x))
+ return x;
+
+ /* Scale X to [1,4). */
+ n = __logb (x);
+ x = __scalb (x, -n);
+ m = __logb (x);
+ if (m != 0)
+ /* Subnormal number. */
+ x = __scalb (x, -m);
+
+ m += n;
+ n = m / 2;
+
+ if ((n + n) != m)
+ {
+ x *= 2;
+ --m;
+ n = m / 2;
+ }
+
+ /* Generate sqrt (X) bit by bit (accumulating in Q). */
+ q = 1.0;
+ s = 4.0;
+ x -= 1.0;
+ r = 1;
+ for (i = 1; i <= 51; i++)
+ {
+ t = s + 1;
+ x *= 4;
+ r /= 2;
+ if (t <= x)
+ {
+ s = t + t + 2, x -= t;
+ q += r;
+ }
+ else
+ s *= 2;
+ }
+
+ /* Generate the last bit and determine the final rounding. */
+ r /= 2;
+ x *= 4;
+ if (x == zero)
+ goto end;
+ (void) (100 + r); /* Trigger inexact flag. */
+ if (s < x)
+ {
+ q += r;
+ x -= s;
+ s += 2;
+ s *= 2;
+ x *= 4;
+ t = (x - s) - 5;
+ b = 1.0 + 3 * r / 4;
+ if (b == 1.0)
+ goto end; /* B == 1: Round to zero. */
+ b = 1.0 + r / 4;
+ if (b > 1.0)
+ t = 1; /* B > 1: Round to +Inf. */
+ if (t >= 0)
+ q += r;
+ } /* Else round to nearest. */
+ else
+ {
+ s *= 2;
+ x *= 4;
+ t = (x - s) - 1;
+ b = 1.0 + 3 * r / 4;
+ if (b == 1.0)
+ goto end;
+ b = 1.0 + r / 4;
+ if (b > 1.0)
+ t = 1;
+ if (t >= 0)
+ q += r;
+ }
+
+end:
+ return __scalb (q, n);
+}
diff --git a/sysdeps/ieee754/support.c b/sysdeps/ieee754/support.c
new file mode 100644
index 0000000..e976839
--- /dev/null
+++ b/sysdeps/ieee754/support.c
@@ -0,0 +1,524 @@
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)support.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/*
+ * Some IEEE standard 754 recommended functions and remainder and sqrt for
+ * supporting the C elementary functions.
+ ******************************************************************************
+ * WARNING:
+ * These codes are developed (in double) to support the C elementary
+ * functions temporarily. They are not universal, and some of them are very
+ * slow (in particular, drem and sqrt is extremely inefficient). Each
+ * computer system should have its implementation of these functions using
+ * its own assembler.
+ ******************************************************************************
+ *
+ * IEEE 754 required operations:
+ * drem(x,p)
+ * returns x REM y = x - [x/y]*y , where [x/y] is the integer
+ * nearest x/y; in half way case, choose the even one.
+ * sqrt(x)
+ * returns the square root of x correctly rounded according to
+ * the rounding mod.
+ *
+ * IEEE 754 recommended functions:
+ * (a) copysign(x,y)
+ * returns x with the sign of y.
+ * (b) scalb(x,N)
+ * returns x * (2**N), for integer values N.
+ * (c) logb(x)
+ * returns the unbiased exponent of x, a signed integer in
+ * double precision, except that logb(0) is -INF, logb(INF)
+ * is +INF, and logb(NAN) is that NAN.
+ * (d) finite(x)
+ * returns the value TRUE if -INF < x < +INF and returns
+ * FALSE otherwise.
+ *
+ *
+ * CODED IN C BY K.C. NG, 11/25/84;
+ * REVISED BY K.C. NG on 1/22/85, 2/13/85, 3/24/85.
+ */
+
+#include "mathimpl.h"
+
+#if defined(vax)||defined(tahoe) /* VAX D format */
+#include <errno.h>
+ static const unsigned short msign=0x7fff , mexp =0x7f80 ;
+ static const short prep1=57, gap=7, bias=129 ;
+ static const double novf=1.7E38, nunf=3.0E-39, zero=0.0 ;
+#else /* defined(vax)||defined(tahoe) */
+ static const unsigned short msign=0x7fff, mexp =0x7ff0 ;
+ static const short prep1=54, gap=4, bias=1023 ;
+ static const double novf=1.7E308, nunf=3.0E-308,zero=0.0;
+#endif /* defined(vax)||defined(tahoe) */
+
+double scalb(x,N)
+double x; int N;
+{
+ int k;
+
+#ifdef national
+ unsigned short *px=(unsigned short *) &x + 3;
+#else /* national */
+ unsigned short *px=(unsigned short *) &x;
+#endif /* national */
+
+ if( x == zero ) return(x);
+
+#if defined(vax)||defined(tahoe)
+ if( (k= *px & mexp ) != ~msign ) {
+ if (N < -260)
+ return(nunf*nunf);
+ else if (N > 260) {
+ return(copysign(infnan(ERANGE),x));
+ }
+#else /* defined(vax)||defined(tahoe) */
+ if( (k= *px & mexp ) != mexp ) {
+ if( N<-2100) return(nunf*nunf); else if(N>2100) return(novf+novf);
+ if( k == 0 ) {
+ x *= scalb(1.0,(int)prep1); N -= prep1; return(scalb(x,N));}
+#endif /* defined(vax)||defined(tahoe) */
+
+ if((k = (k>>gap)+ N) > 0 )
+ if( k < (mexp>>gap) ) *px = (*px&~mexp) | (k<<gap);
+ else x=novf+novf; /* overflow */
+ else
+ if( k > -prep1 )
+ /* gradual underflow */
+ {*px=(*px&~mexp)|(short)(1<<gap); x *= scalb(1.0,k-1);}
+ else
+ return(nunf*nunf);
+ }
+ return(x);
+}
+
+
+double copysign(x,y)
+double x,y;
+{
+#ifdef national
+ unsigned short *px=(unsigned short *) &x+3,
+ *py=(unsigned short *) &y+3;
+#else /* national */
+ unsigned short *px=(unsigned short *) &x,
+ *py=(unsigned short *) &y;
+#endif /* national */
+
+#if defined(vax)||defined(tahoe)
+ if ( (*px & mexp) == 0 ) return(x);
+#endif /* defined(vax)||defined(tahoe) */
+
+ *px = ( *px & msign ) | ( *py & ~msign );
+ return(x);
+}
+
+double logb(x)
+double x;
+{
+
+#ifdef national
+ short *px=(short *) &x+3, k;
+#else /* national */
+ short *px=(short *) &x, k;
+#endif /* national */
+
+#if defined(vax)||defined(tahoe)
+ return (int)(((*px&mexp)>>gap)-bias);
+#else /* defined(vax)||defined(tahoe) */
+ if( (k= *px & mexp ) != mexp )
+ if ( k != 0 )
+ return ( (k>>gap) - bias );
+ else if( x != zero)
+ return ( -1022.0 );
+ else
+ return(-(1.0/zero));
+ else if(x != x)
+ return(x);
+ else
+ {*px &= msign; return(x);}
+#endif /* defined(vax)||defined(tahoe) */
+}
+
+finite(x)
+double x;
+{
+#if defined(vax)||defined(tahoe)
+ return(1);
+#else /* defined(vax)||defined(tahoe) */
+#ifdef national
+ return( (*((short *) &x+3 ) & mexp ) != mexp );
+#else /* national */
+ return( (*((short *) &x ) & mexp ) != mexp );
+#endif /* national */
+#endif /* defined(vax)||defined(tahoe) */
+}
+
+double drem(x,p)
+double x,p;
+{
+ short sign;
+ double hp,dp,tmp;
+ unsigned short k;
+#ifdef national
+ unsigned short
+ *px=(unsigned short *) &x +3,
+ *pp=(unsigned short *) &p +3,
+ *pd=(unsigned short *) &dp +3,
+ *pt=(unsigned short *) &tmp+3;
+#else /* national */
+ unsigned short
+ *px=(unsigned short *) &x ,
+ *pp=(unsigned short *) &p ,
+ *pd=(unsigned short *) &dp ,
+ *pt=(unsigned short *) &tmp;
+#endif /* national */
+
+ *pp &= msign ;
+
+#if defined(vax)||defined(tahoe)
+ if( ( *px & mexp ) == ~msign ) /* is x a reserved operand? */
+#else /* defined(vax)||defined(tahoe) */
+ if( ( *px & mexp ) == mexp )
+#endif /* defined(vax)||defined(tahoe) */
+ return (x-p)-(x-p); /* create nan if x is inf */
+ if (p == zero) {
+#if defined(vax)||defined(tahoe)
+ return(infnan(EDOM));
+#else /* defined(vax)||defined(tahoe) */
+ return zero/zero;
+#endif /* defined(vax)||defined(tahoe) */
+ }
+
+#if defined(vax)||defined(tahoe)
+ if( ( *pp & mexp ) == ~msign ) /* is p a reserved operand? */
+#else /* defined(vax)||defined(tahoe) */
+ if( ( *pp & mexp ) == mexp )
+#endif /* defined(vax)||defined(tahoe) */
+ { if (p != p) return p; else return x;}
+
+ else if ( ((*pp & mexp)>>gap) <= 1 )
+ /* subnormal p, or almost subnormal p */
+ { double b; b=scalb(1.0,(int)prep1);
+ p *= b; x = drem(x,p); x *= b; return(drem(x,p)/b);}
+ else if ( p >= novf/2)
+ { p /= 2 ; x /= 2; return(drem(x,p)*2);}
+ else
+ {
+ dp=p+p; hp=p/2;
+ sign= *px & ~msign ;
+ *px &= msign ;
+ while ( x > dp )
+ {
+ k=(*px & mexp) - (*pd & mexp) ;
+ tmp = dp ;
+ *pt += k ;
+
+#if defined(vax)||defined(tahoe)
+ if( x < tmp ) *pt -= 128 ;
+#else /* defined(vax)||defined(tahoe) */
+ if( x < tmp ) *pt -= 16 ;
+#endif /* defined(vax)||defined(tahoe) */
+
+ x -= tmp ;
+ }
+ if ( x > hp )
+ { x -= p ; if ( x >= hp ) x -= p ; }
+
+#if defined(vax)||defined(tahoe)
+ if (x)
+#endif /* defined(vax)||defined(tahoe) */
+ *px ^= sign;
+ return( x);
+
+ }
+}
+
+
+double sqrt(x)
+double x;
+{
+ double q,s,b,r;
+ double t;
+ double const zero=0.0;
+ int m,n,i;
+#if defined(vax)||defined(tahoe)
+ int k=54;
+#else /* defined(vax)||defined(tahoe) */
+ int k=51;
+#endif /* defined(vax)||defined(tahoe) */
+
+ /* sqrt(NaN) is NaN, sqrt(+-0) = +-0 */
+ if(x!=x||x==zero) return(x);
+
+ /* sqrt(negative) is invalid */
+ if(x<zero) {
+#if defined(vax)||defined(tahoe)
+ return (infnan(EDOM)); /* NaN */
+#else /* defined(vax)||defined(tahoe) */
+ return(zero/zero);
+#endif /* defined(vax)||defined(tahoe) */
+ }
+
+ /* sqrt(INF) is INF */
+ if(!finite(x)) return(x);
+
+ /* scale x to [1,4) */
+ n=logb(x);
+ x=scalb(x,-n);
+ if((m=logb(x))!=0) x=scalb(x,-m); /* subnormal number */
+ m += n;
+ n = m/2;
+ if((n+n)!=m) {x *= 2; m -=1; n=m/2;}
+
+ /* generate sqrt(x) bit by bit (accumulating in q) */
+ q=1.0; s=4.0; x -= 1.0; r=1;
+ for(i=1;i<=k;i++) {
+ t=s+1; x *= 4; r /= 2;
+ if(t<=x) {
+ s=t+t+2, x -= t; q += r;}
+ else
+ s *= 2;
+ }
+
+ /* generate the last bit and determine the final rounding */
+ r/=2; x *= 4;
+ if(x==zero) goto end; 100+r; /* trigger inexact flag */
+ if(s<x) {
+ q+=r; x -=s; s += 2; s *= 2; x *= 4;
+ t = (x-s)-5;
+ b=1.0+3*r/4; if(b==1.0) goto end; /* b==1 : Round-to-zero */
+ b=1.0+r/4; if(b>1.0) t=1; /* b>1 : Round-to-(+INF) */
+ if(t>=0) q+=r; } /* else: Round-to-nearest */
+ else {
+ s *= 2; x *= 4;
+ t = (x-s)-1;
+ b=1.0+3*r/4; if(b==1.0) goto end;
+ b=1.0+r/4; if(b>1.0) t=1;
+ if(t>=0) q+=r; }
+
+end: return(scalb(q,n));
+}
+
+#if 0
+/* DREM(X,Y)
+ * RETURN X REM Y =X-N*Y, N=[X/Y] ROUNDED (ROUNDED TO EVEN IN THE HALF WAY CASE)
+ * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS)
+ * INTENDED FOR ASSEMBLY LANGUAGE
+ * CODED IN C BY K.C. NG, 3/23/85, 4/8/85.
+ *
+ * Warning: this code should not get compiled in unless ALL of
+ * the following machine-dependent routines are supplied.
+ *
+ * Required machine dependent functions (not on a VAX):
+ * swapINX(i): save inexact flag and reset it to "i"
+ * swapENI(e): save inexact enable and reset it to "e"
+ */
+
+double drem(x,y)
+double x,y;
+{
+
+#ifdef national /* order of words in floating point number */
+ static const n0=3,n1=2,n2=1,n3=0;
+#else /* VAX, SUN, ZILOG, TAHOE */
+ static const n0=0,n1=1,n2=2,n3=3;
+#endif
+
+ static const unsigned short mexp =0x7ff0, m25 =0x0190, m57 =0x0390;
+ static const double zero=0.0;
+ double hy,y1,t,t1;
+ short k;
+ long n;
+ int i,e;
+ unsigned short xexp,yexp, *px =(unsigned short *) &x ,
+ nx,nf, *py =(unsigned short *) &y ,
+ sign, *pt =(unsigned short *) &t ,
+ *pt1 =(unsigned short *) &t1 ;
+
+ xexp = px[n0] & mexp ; /* exponent of x */
+ yexp = py[n0] & mexp ; /* exponent of y */
+ sign = px[n0] &0x8000; /* sign of x */
+
+/* return NaN if x is NaN, or y is NaN, or x is INF, or y is zero */
+ if(x!=x) return(x); if(y!=y) return(y); /* x or y is NaN */
+ if( xexp == mexp ) return(zero/zero); /* x is INF */
+ if(y==zero) return(y/y);
+
+/* save the inexact flag and inexact enable in i and e respectively
+ * and reset them to zero
+ */
+ i=swapINX(0); e=swapENI(0);
+
+/* subnormal number */
+ nx=0;
+ if(yexp==0) {t=1.0,pt[n0]+=m57; y*=t; nx=m57;}
+
+/* if y is tiny (biased exponent <= 57), scale up y to y*2**57 */
+ if( yexp <= m57 ) {py[n0]+=m57; nx+=m57; yexp+=m57;}
+
+ nf=nx;
+ py[n0] &= 0x7fff;
+ px[n0] &= 0x7fff;
+
+/* mask off the least significant 27 bits of y */
+ t=y; pt[n3]=0; pt[n2]&=0xf800; y1=t;
+
+/* LOOP: argument reduction on x whenever x > y */
+loop:
+ while ( x > y )
+ {
+ t=y;
+ t1=y1;
+ xexp=px[n0]&mexp; /* exponent of x */
+ k=xexp-yexp-m25;
+ if(k>0) /* if x/y >= 2**26, scale up y so that x/y < 2**26 */
+ {pt[n0]+=k;pt1[n0]+=k;}
+ n=x/t; x=(x-n*t1)-n*(t-t1);
+ }
+ /* end while (x > y) */
+
+ if(nx!=0) {t=1.0; pt[n0]+=nx; x*=t; nx=0; goto loop;}
+
+/* final adjustment */
+
+ hy=y/2.0;
+ if(x>hy||((x==hy)&&n%2==1)) x-=y;
+ px[n0] ^= sign;
+ if(nf!=0) { t=1.0; pt[n0]-=nf; x*=t;}
+
+/* restore inexact flag and inexact enable */
+ swapINX(i); swapENI(e);
+
+ return(x);
+}
+#endif
+
+#if 0
+/* SQRT
+ * RETURN CORRECTLY ROUNDED (ACCORDING TO THE ROUNDING MODE) SQRT
+ * FOR IEEE DOUBLE PRECISION ONLY, INTENDED FOR ASSEMBLY LANGUAGE
+ * CODED IN C BY K.C. NG, 3/22/85.
+ *
+ * Warning: this code should not get compiled in unless ALL of
+ * the following machine-dependent routines are supplied.
+ *
+ * Required machine dependent functions:
+ * swapINX(i) ...return the status of INEXACT flag and reset it to "i"
+ * swapRM(r) ...return the current Rounding Mode and reset it to "r"
+ * swapENI(e) ...return the status of inexact enable and reset it to "e"
+ * addc(t) ...perform t=t+1 regarding t as a 64 bit unsigned integer
+ * subc(t) ...perform t=t-1 regarding t as a 64 bit unsigned integer
+ */
+
+static const unsigned long table[] = {
+0, 1204, 3062, 5746, 9193, 13348, 18162, 23592, 29598, 36145, 43202, 50740,
+58733, 67158, 75992, 85215, 83599, 71378, 60428, 50647, 41945, 34246, 27478,
+21581, 16499, 12183, 8588, 5674, 3403, 1742, 661, 130, };
+
+double newsqrt(x)
+double x;
+{
+ double y,z,t,addc(),subc()
+ double const b54=134217728.*134217728.; /* b54=2**54 */
+ long mx,scalx;
+ long const mexp=0x7ff00000;
+ int i,j,r,e,swapINX(),swapRM(),swapENI();
+ unsigned long *py=(unsigned long *) &y ,
+ *pt=(unsigned long *) &t ,
+ *px=(unsigned long *) &x ;
+#ifdef national /* ordering of word in a floating point number */
+ const int n0=1, n1=0;
+#else
+ const int n0=0, n1=1;
+#endif
+/* Rounding Mode: RN ...round-to-nearest
+ * RZ ...round-towards 0
+ * RP ...round-towards +INF
+ * RM ...round-towards -INF
+ */
+ const int RN=0,RZ=1,RP=2,RM=3;
+ /* machine dependent: work on a Zilog Z8070
+ * and a National 32081 & 16081
+ */
+
+/* exceptions */
+ if(x!=x||x==0.0) return(x); /* sqrt(NaN) is NaN, sqrt(+-0) = +-0 */
+ if(x<0) return((x-x)/(x-x)); /* sqrt(negative) is invalid */
+ if((mx=px[n0]&mexp)==mexp) return(x); /* sqrt(+INF) is +INF */
+
+/* save, reset, initialize */
+ e=swapENI(0); /* ...save and reset the inexact enable */
+ i=swapINX(0); /* ...save INEXACT flag */
+ r=swapRM(RN); /* ...save and reset the Rounding Mode to RN */
+ scalx=0;
+
+/* subnormal number, scale up x to x*2**54 */
+ if(mx==0) {x *= b54 ; scalx-=0x01b00000;}
+
+/* scale x to avoid intermediate over/underflow:
+ * if (x > 2**512) x=x/2**512; if (x < 2**-512) x=x*2**512 */
+ if(mx>0x5ff00000) {px[n0] -= 0x20000000; scalx+= 0x10000000;}
+ if(mx<0x1ff00000) {px[n0] += 0x20000000; scalx-= 0x10000000;}
+
+/* magic initial approximation to almost 8 sig. bits */
+ py[n0]=(px[n0]>>1)+0x1ff80000;
+ py[n0]=py[n0]-table[(py[n0]>>15)&31];
+
+/* Heron's rule once with correction to improve y to almost 18 sig. bits */
+ t=x/y; y=y+t; py[n0]=py[n0]-0x00100006; py[n1]=0;
+
+/* triple to almost 56 sig. bits; now y approx. sqrt(x) to within 1 ulp */
+ t=y*y; z=t; pt[n0]+=0x00100000; t+=z; z=(x-z)*y;
+ t=z/(t+x) ; pt[n0]+=0x00100000; y+=t;
+
+/* twiddle last bit to force y correctly rounded */
+ swapRM(RZ); /* ...set Rounding Mode to round-toward-zero */
+ swapINX(0); /* ...clear INEXACT flag */
+ swapENI(e); /* ...restore inexact enable status */
+ t=x/y; /* ...chopped quotient, possibly inexact */
+ j=swapINX(i); /* ...read and restore inexact flag */
+ if(j==0) { if(t==y) goto end; else t=subc(t); } /* ...t=t-ulp */
+ b54+0.1; /* ..trigger inexact flag, sqrt(x) is inexact */
+ if(r==RN) t=addc(t); /* ...t=t+ulp */
+ else if(r==RP) { t=addc(t);y=addc(y);}/* ...t=t+ulp;y=y+ulp; */
+ y=y+t; /* ...chopped sum */
+ py[n0]=py[n0]-0x00100000; /* ...correctly rounded sqrt(x) */
+end: py[n0]=py[n0]+scalx; /* ...scale back y */
+ swapRM(r); /* ...restore Rounding Mode */
+ return(y);
+}
+#endif
diff --git a/sysdeps/m68k/Implies b/sysdeps/m68k/Implies
new file mode 100644
index 0000000..a67e1c2
--- /dev/null
+++ b/sysdeps/m68k/Implies
@@ -0,0 +1,2 @@
+# 68k uses IEEE 754 floating point.
+ieee754
diff --git a/sysdeps/m68k/Makefile b/sysdeps/m68k/Makefile
new file mode 100644
index 0000000..ea0c7d5
--- /dev/null
+++ b/sysdeps/m68k/Makefile
@@ -0,0 +1,32 @@
+# Copyright (C) 1993, 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.
+
+# This uses MIT assembler syntax. We have no convenient
+# way to choose a sysdep file based on MIT vs Motorola syntax.
+# No existing m68k ports use Motorola syntax.
+
+crypt := crypt.sun3 # Use crypt/crypt.sun3.S.
+
+# The mpn functions need this. All existing 68k ports use MIT syntax. If
+# a new port wants to use Motorola or Sony syntax, it can redefine this
+# variable.
+ifndef m68k-syntax-flag
+m68k-syntax-flag = -DMIT_SYNTAX
+endif
+
+asm-CPPFLAGS := $(asm-CPPFLAGS) $(m68k-syntax-flag)
diff --git a/sysdeps/m68k/__longjmp.c b/sysdeps/m68k/__longjmp.c
new file mode 100644
index 0000000..4fc6108
--- /dev/null
+++ b/sysdeps/m68k/__longjmp.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <setjmp.h>
+#include <stdlib.h>
+
+/* Jump to the position specified by ENV, causing the
+ setjmp call there to return VAL, or 1 if VAL is 0. */
+void
+__longjmp (__jmp_buf env, int val)
+{
+ /* This restores the FP and SP that setjmp's caller had,
+ and puts the return address into A0 and VAL into D0. */
+
+#if defined(__HAVE_68881__) || defined(__HAVE_FPU__)
+ /* Restore the floating-point registers. */
+ asm volatile("fmovem%.x %0, fp0-fp7" :
+ /* No outputs. */ : "g" (env[0].__fpregs[0]) :
+ "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7");
+#endif
+
+ /* Put VAL in D0. */
+ asm volatile("move%.l %0, d0" : /* No outputs. */ :
+ "g" (val == 0 ? 1 : val) : "d0");
+
+ asm volatile(/* Restore the data and address registers. */
+ "movem%.l %0, d1-d7/a0-a7\n"
+ /* Return to setjmp's caller. */
+#ifdef __motorola__
+ "jmp (a0)"
+#else
+ "jmp a0@"
+#endif
+ : /* No outputs. */ : "g" (env[0].__dregs[0])
+ /* We don't bother with the clobbers,
+ because this code always jumps out anyway. */
+ );
+
+ /* This call avoids `volatile function does return' warnings. */
+ abort ();
+}
diff --git a/sysdeps/m68k/bsd-_setjmp.S b/sysdeps/m68k/bsd-_setjmp.S
new file mode 100644
index 0000000..a0b6393
--- /dev/null
+++ b/sysdeps/m68k/bsd-_setjmp.S
@@ -0,0 +1,42 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. m68k 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. */
+
+/* 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 MOTOROLA_SYNTAX
+#define d0 %d0
+#define d1 %d1
+#define PUSH(reg) move.l reg, -(%esp)
+#define POP(reg) move.l (%esp)+, reg
+#else
+#define PUSH(reg) movel reg, sp@-
+#define POP(reg) movel sp@+, reg
+#endif
+
+ENTRY (_setjmp)
+ POP (d0) /* Pop return PC. */
+ POP (d1) /* Pop jmp_buf argument. */
+ PUSH (#0) /* Push second argument of zero. */
+ PUSH (d1) /* Push back first argument. */
+ PUSH (d0) /* Push back return PC. */
+ jmp C_SYMBOL_NAME (__sigsetjmp)
diff --git a/sysdeps/m68k/bsd-setjmp.S b/sysdeps/m68k/bsd-setjmp.S
new file mode 100644
index 0000000..d218b44
--- /dev/null
+++ b/sysdeps/m68k/bsd-setjmp.S
@@ -0,0 +1,42 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. m68k 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. */
+
+/* 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 MOTOROLA_SYNTAX
+#define d0 %d0
+#define d1 %d1
+#define PUSH(reg) move.l reg, -(%esp)
+#define POP(reg) move.l (%esp)+, reg
+#else
+#define PUSH(reg) movel reg, sp@-
+#define POP(reg) movel sp@+, reg
+#endif
+
+ENTRY (setjmp)
+ POP (d0) /* Pop return PC. */
+ POP (d1) /* Pop jmp_buf argument. */
+ PUSH (#1) /* Push second argument of one. */
+ PUSH (d1) /* Push back first argument. */
+ PUSH (d0) /* Push back return PC. */
+ jmp C_SYMBOL_NAME (__sigsetjmp)
diff --git a/sysdeps/m68k/bytesex.h b/sysdeps/m68k/bytesex.h
new file mode 100644
index 0000000..6f98529
--- /dev/null
+++ b/sysdeps/m68k/bytesex.h
@@ -0,0 +1,3 @@
+/* m68k is big-endian. */
+
+#define __BYTE_ORDER __BIG_ENDIAN
diff --git a/sysdeps/m68k/ffs.c b/sysdeps/m68k/ffs.c
new file mode 100644
index 0000000..d9ec2b1
--- /dev/null
+++ b/sysdeps/m68k/ffs.c
@@ -0,0 +1,42 @@
+/* ffs -- find first set bit in a word, counted from least significant end.
+ For mc68020, mc68030, mc68040.
+ Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <ansidecl.h>
+#include <string.h>
+
+#undef ffs
+
+#if defined (__GNUC__) && defined (__mc68020__)
+
+int
+DEFUN(ffs, (x), int x)
+{
+ int cnt;
+
+ asm("bfffo %1{#0:#0},%0" : "=d" (cnt) : "rm" (x & -x));
+
+ return 32 - cnt;
+}
+
+#else
+
+#include <sysdeps/generic/ffs.c>
+
+#endif
diff --git a/sysdeps/m68k/fpu/Makefile b/sysdeps/m68k/fpu/Makefile
new file mode 100644
index 0000000..42db638
--- /dev/null
+++ b/sysdeps/m68k/fpu/Makefile
@@ -0,0 +1,11 @@
+ifeq ($(subdir),math)
+ifndef math-twiddled
+
+# Avoid twiddling in generic/Makefile.
+math-twiddled := t
+
+endif
+
+bsdmath_dirs := $(bsdmath_dirs) mc68881
+
+endif
diff --git a/sysdeps/m68k/fpu/__math.h b/sysdeps/m68k/fpu/__math.h
new file mode 100644
index 0000000..a9ae2d9
--- /dev/null
+++ b/sysdeps/m68k/fpu/__math.h
@@ -0,0 +1,168 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#ifdef __GNUC__
+
+#include <sys/cdefs.h>
+
+#ifdef __NO_MATH_INLINES
+/* This is used when defining the functions themselves. Define them with
+ __ names, and with `static inline' instead of `extern inline' so the
+ bodies will always be used, never an external function call. */
+#define __m81_u(x) __CONCAT(__,x)
+#define __m81_inline static __inline
+#else
+#define __m81_u(x) x
+#define __m81_inline exter __inline
+#define __MATH_INLINES 1
+#endif
+
+#define __inline_mathop2(func, op) \
+ __m81_inline __CONSTVALUE double \
+ __m81_u(func)(double __mathop_x) \
+ { \
+ double __result; \
+ __asm("f" __STRING(op) "%.x %1, %0" : "=f" (__result) : "f" (__mathop_x));\
+ return __result; \
+ }
+#define __inline_mathop(op) __inline_mathop2(op, op)
+
+__inline_mathop(acos)
+__inline_mathop(asin)
+__inline_mathop(atan)
+__inline_mathop(cos)
+__inline_mathop(sin)
+__inline_mathop(tan)
+__inline_mathop(cosh)
+__inline_mathop(sinh)
+__inline_mathop(tanh)
+__inline_mathop2(exp, etox)
+__inline_mathop2(fabs, abs)
+__inline_mathop(log10)
+__inline_mathop2(log, logn)
+__inline_mathop2(floor, intrz)
+__inline_mathop(sqrt)
+
+__inline_mathop2(__rint, int)
+__inline_mathop2(__expm1, etoxm1)
+
+#ifdef __USE_MISC
+__inline_mathop2(rint, int)
+__inline_mathop2(expm1, etoxm1)
+__inline_mathop2(log1p, lognp1)
+__inline_mathop(atanh)
+#endif
+
+__m81_inline __CONSTVALUE double
+__m81_u(__drem)(double __x, double __y)
+{
+ double __result;
+ __asm("frem%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
+ return __result;
+}
+
+__m81_inline __CONSTVALUE double
+__m81_u(ldexp)(double __x, int __e)
+{
+ double __result;
+ double __double_e = (double) __e;
+ __asm("fscale%.x %1, %0" : "=f" (__result) : "f" (__double_e), "0" (__x));
+ return __result;
+}
+
+__m81_inline __CONSTVALUE double
+__m81_u(fmod)(double __x, double __y)
+{
+ double __result;
+ __asm("fmod%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
+ return __result;
+}
+
+__m81_inline double
+__m81_u(frexp)(double __value, int *__expptr)
+{
+ double __mantissa, __exponent;
+ __asm("fgetexp%.x %1, %0" : "=f" (__exponent) : "f" (__value));
+ __asm("fgetman%.x %1, %0" : "=f" (__mantissa) : "f" (__value));
+ *__expptr = (int) __exponent;
+ return __mantissa;
+}
+
+__m81_inline __CONSTVALUE double
+__m81_u(pow)(double __x, double __y)
+{
+ double __result;
+ if (__y == 0.0 || __x == 1.0)
+ __result = 1.0;
+ else if (__y == 1.0)
+ __result = __x;
+ else if (__y == 2.0)
+ __result = __x * __x;
+ else if (__x == 10.0)
+ __asm("ftentox%.x %1, %0" : "=f" (__result) : "f" (__y));
+ else if (__x == 2.0)
+ __asm("ftwotox%.x %1, %0" : "=f" (__result) : "f" (__y));
+ else
+ __result = __m81_u(exp)(__y * __m81_u(log)(__x));
+ return __result;
+}
+
+__m81_inline __CONSTVALUE double
+__m81_u(ceil)(double __x)
+{
+ double __result;
+ unsigned long int __ctrl_reg;
+ __asm("fmove%.l fpcr, %0" : "=g" (__ctrl_reg));
+ /* Set rounding towards positive infinity. */
+ __asm("fmove%.l %0, fpcr" : /* No outputs. */ : "g" (__ctrl_reg | 0x30));
+ /* Convert X to an integer, using +Inf rounding. */
+ __asm("fint%.x %1, %0" : "=f" (__result) : "f" (__x));
+ /* Restore the previous rounding mode. */
+ __asm("fmove%.l %0, fpcr" : /* No outputs. */ : "g" (__ctrl_reg));
+ return __result;
+}
+
+__m81_inline double
+__m81_u(modf)(double __value, double *__iptr)
+{
+ double __modf_int = __m81_u(floor)(__value);
+ *__iptr = __modf_int;
+ return __value - __modf_int;
+}
+
+__m81_inline __CONSTVALUE int
+__m81_u(__isinf)(double __value)
+{
+ /* There is no branch-condition for infinity,
+ so we must extract and examine the condition codes manually. */
+ unsigned long int __fpsr;
+ __asm("ftst%.x %1\n"
+ "fmove%.l fpsr, %0" : "=g" (__fpsr) : "f" (__value));
+ return (__fpsr & (2 << (3 * 8))) ? (__value < 0 ? -1 : 1) : 0;
+}
+
+__m81_inline __CONSTVALUE int
+__m81_u(__isnan)(double __value)
+{
+ char __result;
+ __asm("ftst%.x %1\n"
+ "fsun %0" : "=g" (__result) : "f" (__value));
+ return __result;
+}
+
+#endif /* GCC. */
diff --git a/sysdeps/m68k/fpu/acos.c b/sysdeps/m68k/fpu/acos.c
new file mode 100644
index 0000000..d4be88f
--- /dev/null
+++ b/sysdeps/m68k/fpu/acos.c
@@ -0,0 +1,32 @@
+/* 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. */
+
+#include <ansidecl.h>
+#define __NO_MATH_INLINES
+#include <math.h>
+
+#ifndef FUNC
+#define FUNC acos
+#endif
+
+
+__CONSTVALUE double
+DEFUN(FUNC, (x), double x)
+{
+ return __m81_u(FUNC)(x);
+}
diff --git a/sysdeps/m68k/fpu/asin.c b/sysdeps/m68k/fpu/asin.c
new file mode 100644
index 0000000..0e3e58f
--- /dev/null
+++ b/sysdeps/m68k/fpu/asin.c
@@ -0,0 +1,2 @@
+#define FUNC asin
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/atan.c b/sysdeps/m68k/fpu/atan.c
new file mode 100644
index 0000000..b9d428e
--- /dev/null
+++ b/sysdeps/m68k/fpu/atan.c
@@ -0,0 +1,2 @@
+#define FUNC atan
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/atan2.c b/sysdeps/m68k/fpu/atan2.c
new file mode 100644
index 0000000..1efdb1f
--- /dev/null
+++ b/sysdeps/m68k/fpu/atan2.c
@@ -0,0 +1,71 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+
+#ifdef __GNUC__
+
+__CONSTVALUE double
+DEFUN(atan2, (y, x), double y AND double x)
+{
+ static CONST double one = 1.0, zero = 0.0;
+ double signx, signy;
+ double pi, PIo4, PIo2;
+
+ if (__isnan(x))
+ return x;
+ if (__isnan(y))
+ return y;
+
+ signy = __copysign(one, y);
+ signx = __copysign(one, x);
+
+ asm("fmovecr%.x %1, %0" : "=f" (pi) : "i" (0));
+ PIo2 = pi / 2;
+ PIo4 = pi / 4;
+
+ if (y == zero)
+ return signx == one ? y : __copysign(pi, signy);
+
+ if (x == zero)
+ return __copysign(PIo2, signy);
+
+ if (__isinf(x))
+ {
+ if (__isinf(y))
+ return __copysign(signx == one ? PIo4 : 3 * PIo4, signy);
+ else
+ return __copysign(signx == one ? zero : pi, signy);
+ }
+
+ if (__isinf(y))
+ return __copysign(PIo2, signy);
+
+ y = fabs(y);
+
+ if (x < 0.0)
+ /* X is negative. */
+ return __copysign(pi - atan(y / -x), signy);
+
+ return __copysign(atan(y / x), signy);
+}
+
+#else
+#include <sysdeps/generic/atan2.c>
+#endif
diff --git a/sysdeps/m68k/fpu/atanh.c b/sysdeps/m68k/fpu/atanh.c
new file mode 100644
index 0000000..d4636ec
--- /dev/null
+++ b/sysdeps/m68k/fpu/atanh.c
@@ -0,0 +1,2 @@
+#define FUNC atanh
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/ceil.c b/sysdeps/m68k/fpu/ceil.c
new file mode 100644
index 0000000..b4605e1
--- /dev/null
+++ b/sysdeps/m68k/fpu/ceil.c
@@ -0,0 +1,4 @@
+
+#define FUNC ceil
+
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/cos.c b/sysdeps/m68k/fpu/cos.c
new file mode 100644
index 0000000..fa50130
--- /dev/null
+++ b/sysdeps/m68k/fpu/cos.c
@@ -0,0 +1,2 @@
+#define FUNC cos
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/cosh.c b/sysdeps/m68k/fpu/cosh.c
new file mode 100644
index 0000000..78a8194
--- /dev/null
+++ b/sysdeps/m68k/fpu/cosh.c
@@ -0,0 +1,2 @@
+#define FUNC cosh
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/drem.c b/sysdeps/m68k/fpu/drem.c
new file mode 100644
index 0000000..16caacf
--- /dev/null
+++ b/sysdeps/m68k/fpu/drem.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#include <ansidecl.h>
+#define __NO_MATH_INLINES
+#include <math.h>
+
+#undef drem
+
+double
+DEFUN(__drem, (x, y), double x AND double y)
+{
+ return ____drem(x, y);
+}
+
+weak_alias (__drem, drem)
diff --git a/sysdeps/m68k/fpu/exp.c b/sysdeps/m68k/fpu/exp.c
new file mode 100644
index 0000000..2649d72
--- /dev/null
+++ b/sysdeps/m68k/fpu/exp.c
@@ -0,0 +1,3 @@
+#define FUNC exp
+#define OP etox
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/expm1.c b/sysdeps/m68k/fpu/expm1.c
new file mode 100644
index 0000000..19f1802
--- /dev/null
+++ b/sysdeps/m68k/fpu/expm1.c
@@ -0,0 +1,3 @@
+#define FUNC __expm1
+#define OP expm1
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/fabs.c b/sysdeps/m68k/fpu/fabs.c
new file mode 100644
index 0000000..f9538a5
--- /dev/null
+++ b/sysdeps/m68k/fpu/fabs.c
@@ -0,0 +1,3 @@
+#define FUNC fabs
+#define OP abs
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/fl.h b/sysdeps/m68k/fpu/fl.h
new file mode 100644
index 0000000..098e880
--- /dev/null
+++ b/sysdeps/m68k/fpu/fl.h
@@ -0,0 +1,41 @@
+/* Floating-point constants for the 68881.
+ Copyright (C) 1992 Free Software Foundation, Inc. */
+
+/* IGNORE($ This is used internally in the library. */
+#include <sysdeps/ieee754/fl.h>
+/* ansidecl.m4 here inserts the ieee file. Kludge o rama.
+ $) ENDCOMMENT INCLUDE($sysdeps/ieee754/fl.h$) STARTCOMMENT */
+
+#ifndef __need_HUGE_VAL
+
+#ifdef __GNUC__
+
+#undef FLT_ROUNDS
+
+/* Interrogate the 68881 to find the current rounding mode. */
+
+static __const __inline int
+DEFUN_VOID(__flt_rounds)
+{
+ unsigned long int __fpcr;
+ __asm("fmove%.l fpcr, %0" : "=g" (__fpcr));
+ switch (__fpcr & (1 | 2))
+ {
+ case 0:
+ return _FLT_ROUNDS_TONEAREST;
+ case 1:
+ return _FLT_ROUNDS_TOZERO;
+ case 2:
+ return _FLT_ROUNDS_TONEGINF;
+ case 3:
+ return _FLT_ROUNDS_TOPOSINF;
+ default:
+ return _FLT_ROUNDS_INDETERMINATE;
+ }
+}
+
+#define FLT_ROUNDS (__flt_rounds())
+
+#endif /* GCC. */
+
+#endif /* Don't need HUGE_VAL. */
diff --git a/sysdeps/m68k/fpu/floor.c b/sysdeps/m68k/fpu/floor.c
new file mode 100644
index 0000000..92a2ca6
--- /dev/null
+++ b/sysdeps/m68k/fpu/floor.c
@@ -0,0 +1,3 @@
+#define FUNC floor
+#define OP intrz
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/fmod.c b/sysdeps/m68k/fpu/fmod.c
new file mode 100644
index 0000000..9a6c8cd
--- /dev/null
+++ b/sysdeps/m68k/fpu/fmod.c
@@ -0,0 +1,27 @@
+/* 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. */
+
+#include <ansidecl.h>
+#define __NO_MATH_INLINES
+#include <math.h>
+
+__CONSTVALUE double
+DEFUN(fmod, (x, y), double x AND double y)
+{
+ return __fmod(x, y);
+}
diff --git a/sysdeps/m68k/fpu/frexp.c b/sysdeps/m68k/fpu/frexp.c
new file mode 100644
index 0000000..de74851
--- /dev/null
+++ b/sysdeps/m68k/fpu/frexp.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#define __NO_MATH_INLINES
+#include <math.h>
+
+double
+DEFUN(frexp, (value, expptr), double value AND int *expptr)
+{
+ return __frexp(value, expptr);
+}
diff --git a/sysdeps/m68k/fpu/isinf.c b/sysdeps/m68k/fpu/isinf.c
new file mode 100644
index 0000000..ab2cf0b
--- /dev/null
+++ b/sysdeps/m68k/fpu/isinf.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991, 1994, 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. */
+
+#include <ansidecl.h>
+#define __NO_MATH_INLINES
+#include <math.h>
+
+#ifndef FUNC
+#define FUNC __isinf
+#endif
+
+
+int
+DEFUN(FUNC, (x), double x)
+{
+ return __m81_u(FUNC)(x);
+}
+
+weak_alias (__isinf, isinf)
diff --git a/sysdeps/m68k/fpu/isnan.c b/sysdeps/m68k/fpu/isnan.c
new file mode 100644
index 0000000..d098491
--- /dev/null
+++ b/sysdeps/m68k/fpu/isnan.c
@@ -0,0 +1,4 @@
+#define FUNC __isnan
+#include <isinf.c>
+
+weak_alias (__isnan, isnan)
diff --git a/sysdeps/m68k/fpu/ldexp.c b/sysdeps/m68k/fpu/ldexp.c
new file mode 100644
index 0000000..ba91280
--- /dev/null
+++ b/sysdeps/m68k/fpu/ldexp.c
@@ -0,0 +1,27 @@
+/* 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. */
+
+#include <ansidecl.h>
+#define __NO_MATH_INLINES
+#include <math.h>
+
+__CONSTVALUE double
+DEFUN(ldexp, (x, exp), double x AND int exp)
+{
+ return __ldexp(x, exp);
+}
diff --git a/sysdeps/m68k/fpu/log.c b/sysdeps/m68k/fpu/log.c
new file mode 100644
index 0000000..4de3346
--- /dev/null
+++ b/sysdeps/m68k/fpu/log.c
@@ -0,0 +1,3 @@
+#define FUNC log
+#define OP logn
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/log10.c b/sysdeps/m68k/fpu/log10.c
new file mode 100644
index 0000000..246b69a
--- /dev/null
+++ b/sysdeps/m68k/fpu/log10.c
@@ -0,0 +1,2 @@
+#define FUNC log10
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/log1p.c b/sysdeps/m68k/fpu/log1p.c
new file mode 100644
index 0000000..0287838
--- /dev/null
+++ b/sysdeps/m68k/fpu/log1p.c
@@ -0,0 +1,2 @@
+#define FUNC log1p
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/logb.c b/sysdeps/m68k/fpu/logb.c
new file mode 100644
index 0000000..8619c90
--- /dev/null
+++ b/sysdeps/m68k/fpu/logb.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+
+#ifdef __GNUC__
+
+/* Return the base 2 signed integral exponent of X. */
+
+double
+DEFUN(__logb, (x), double x)
+{
+ if (__isnan (x))
+ return x;
+ if (__isinf (x))
+ return fabs (x);
+
+ if (x == 0.0)
+ asm ("flog2%.x %0, %0" : "=f" (x) : "0" (x));
+ else
+ asm ("fgetexp%.x %0, %0" : "=f" (x) : "0" (x));
+
+ return x;
+}
+
+weak_alias (__logb, logb)
+
+#else
+#include <sysdeps/ieee754/logb.c>
+#endif
diff --git a/sysdeps/m68k/fpu/pow.c b/sysdeps/m68k/fpu/pow.c
new file mode 100644
index 0000000..3360020
--- /dev/null
+++ b/sysdeps/m68k/fpu/pow.c
@@ -0,0 +1,27 @@
+/* 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. */
+
+#include <ansidecl.h>
+#define __NO_MATH_INLINES
+#include <math.h>
+
+__CONSTVALUE double
+DEFUN(pow, (x, y), double x AND double y)
+{
+ return __pow(x, y);
+}
diff --git a/sysdeps/m68k/fpu/rint.c b/sysdeps/m68k/fpu/rint.c
new file mode 100644
index 0000000..f83a4e4
--- /dev/null
+++ b/sysdeps/m68k/fpu/rint.c
@@ -0,0 +1,5 @@
+#define FUNC __rint
+#define OP intr
+#include <acos.c>
+
+weak_alias (__rint, rint)
diff --git a/sysdeps/m68k/fpu/sin.c b/sysdeps/m68k/fpu/sin.c
new file mode 100644
index 0000000..28ac9e5
--- /dev/null
+++ b/sysdeps/m68k/fpu/sin.c
@@ -0,0 +1,2 @@
+#define FUNC sin
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/sinh.c b/sysdeps/m68k/fpu/sinh.c
new file mode 100644
index 0000000..fae7c71
--- /dev/null
+++ b/sysdeps/m68k/fpu/sinh.c
@@ -0,0 +1,2 @@
+#define FUNC sinh
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/sqrt.c b/sysdeps/m68k/fpu/sqrt.c
new file mode 100644
index 0000000..2365b61
--- /dev/null
+++ b/sysdeps/m68k/fpu/sqrt.c
@@ -0,0 +1,2 @@
+#define FUNC sqrt
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/switch/68881-sw.h b/sysdeps/m68k/fpu/switch/68881-sw.h
new file mode 100644
index 0000000..3d7a392
--- /dev/null
+++ b/sysdeps/m68k/fpu/switch/68881-sw.h
@@ -0,0 +1,64 @@
+/* Copyright (C) 1991, 1992 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 _68881_SWITCH_H
+
+#define _68881_SWITCH_H 1
+#include <sys/cdefs.h>
+
+/* This is the format of the data at the code label for a function which
+ wants to switch depending on whether or not a 68881 is present.
+
+ Initially, `insn' is a `jsr' instruction, and `target' is __68881_switch.
+ The first time such a function is called, __68881_switch determines whether
+ or not a 68881 is present, and modifies the function accordingly.
+ Then `insn' is a `jmp' instruction, and `target' is the value of `fpu'
+ if there is 68881, or the value of `soft' if not. */
+
+struct switch_caller
+ {
+ unsigned short int insn; /* The `jsr' or `jmp' instruction. */
+ __ptr_t target; /* The target of the instruction. */
+ __ptr_t soft; /* The address of the soft function. */
+ __ptr_t fpu; /* The address of the 68881 function. */
+ };
+
+/* These are opcodes (values for `insn', above) for `jmp' and `jsr'
+ instructions, respectively, to 32-bit absolute addresses. */
+#define JMP 0x4ef9
+#define JSR 0x4eb9
+
+
+/* Function to determine whether or not a 68881 is available,
+ and modify its caller (which must be a `struct switch_caller', above,
+ in data space) to use the appropriate version. */
+extern void EXFUN(__68881_switch, (int __dummy));
+
+
+/* Define FUNCTION as a `struct switch_caller' which will call
+ `__FUNCTION_68881' if a 68881 is present, and `__FUNCTION_soft' if not.
+#define switching_function(FUNCTION) \
+ struct switch_caller FUNCTION = \
+ { \
+ JSR, (__ptr_t) __68881_switch, \
+ __CONCAT(__CONCAT(__,FUNCTION),_soft), \
+ __CONCAT(__CONCAT(__,FUNCTION),_68881) \
+ }
+
+
+#endif /* 68881-switch.h */
diff --git a/sysdeps/m68k/fpu/switch/Dist b/sysdeps/m68k/fpu/switch/Dist
new file mode 100644
index 0000000..1e00e4c
--- /dev/null
+++ b/sysdeps/m68k/fpu/switch/Dist
@@ -0,0 +1 @@
+68881-sw.h switch.c
diff --git a/sysdeps/m68k/fpu/switch/Makefile b/sysdeps/m68k/fpu/switch/Makefile
new file mode 100644
index 0000000..fd8d7c1
--- /dev/null
+++ b/sysdeps/m68k/fpu/switch/Makefile
@@ -0,0 +1,52 @@
+# Copyright (C) 1991, 1992 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.
+
+ifeq ($(subdir),math)
+
+sysdep_routines := $(sysdep_routines) switch
+
+# Find all the sources that have 68881 versions.
++68881-sources := \
+ $(notdir $(wildcard $(addprefix $(filter %/fpu,$(sysdirs)),$(sources))))
+
+# Sysdep directories other than fpu and fpu/switch (this one).
++non68881-dirs := $(filter-out %/fpu %/fpu/switch,$(+sysdep_dirs))
+
+# Get a non-68881 version of the target.
++non68881-version = $(firstword $(wildcard $(addsuffix /$@,$(+non68881-dirs))))
+
+# Directory containing 68881 sources.
++68881-dir := $(filter %/fpu,$(+sysdep_dirs))
+
+# For all the files that have 68881 versions and don't exist already in
+# the source directory (math), automatically make ones that switch between
+# 68881 and soft versions.
+$(addprefix $(objpfx), \
+ $(filter-out $(wildcard $(+68881-sources)),$(+68881-sources))):
+ (echo '#include <ansidecl.h>' ;\
+ echo '#include <68881-sw.h>' ;\
+ echo '#define $* __$*_68881' ;\
+ echo '#include <$(+68881-dir)/$@>' ;\
+ echo '#undef $*' ;\
+ echo '#define $* __$*_soft' ;\
+ echo '#include <$(non68881-version)>' ;\
+ echo '#undef $*' ;\
+ echo 'switching_function($*);') > $@-tmp
+ mv $@-tmp $@
+
+endif
diff --git a/sysdeps/m68k/fpu/switch/__math.h b/sysdeps/m68k/fpu/switch/__math.h
new file mode 100644
index 0000000..c0f6966
--- /dev/null
+++ b/sysdeps/m68k/fpu/switch/__math.h
@@ -0,0 +1 @@
+/* We don't want any inlines when we might not have a 68881. */
diff --git a/sysdeps/m68k/fpu/switch/switch.c b/sysdeps/m68k/fpu/switch/switch.c
new file mode 100644
index 0000000..057bd15
--- /dev/null
+++ b/sysdeps/m68k/fpu/switch/switch.c
@@ -0,0 +1,86 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <signal.h>
+#include <68881-sw.h>
+
+
+/* The signal that is sent when a 68881 instruction
+ is executed and there is no 68881. */
+#ifndef TRAPSIG
+#define TRAPSIG SIGILL
+#endif
+
+/* Zero if no 68881, one if we have a 68881, or -1 if we don't know yet. */
+static int have_fpu = -1;
+
+
+/* Signal handler for the trap that happens if we don't have a 68881. */
+static void
+DEFUN(trap, (sig), int sig)
+{
+ have_fpu = 0;
+}
+
+/* This function is called by functions that want to switch.
+ The calling function must be a `struct switch_caller' in data space.
+ It determines whether a 68881 is present, and modifies its caller
+ to be a static jump to either the 68881 version or the soft version.
+ It then returns into the function it has chosen to do the work. */
+void
+DEFUN(__68881_switch, (dummy), int dummy)
+{
+ PTR *return_address_location = &((PTR *) &dummy)[-1];
+ struct switch_caller *CONST caller
+ = (struct switch_caller *) (((short int *) *return_address_location) - 1);
+
+ if (have_fpu < 0)
+ {
+ /* Figure out whether or not we have a 68881. */
+ __sighandler_t handler = signal (TRAPSIG, trap);
+ if (handler == SIG_ERR)
+ /* We can't figure it out, so assume we don't have a 68881.
+ This assumption will never cause us any problems other than
+ lost performance, while the reverse assumption could cause
+ the program to crash. */
+ have_fpu = 0;
+ else
+ {
+ /* We set `have_fpu' to nonzero, and then execute a 68881
+ no-op instruction. If we have a 68881, this will do nothing.
+ If we don't have one, this will trap and the signal handler
+ will clear `have_fpu'. */
+ have_fpu = 1;
+ asm ("fnop");
+
+ /* Restore the old signal handler. */
+ (void) signal (TRAPSIG, handler);
+ }
+ }
+
+ /* Modify the caller to be a jump to the appropriate address. */
+ caller->insn = JMP;
+ caller->target = have_fpu ? caller->fpu : caller->soft;
+
+ /* Make the address we will return to be the target we have chosen.
+ Our return will match the `jsr' done by the caller we have
+ just modified, and it will be just as if that had instead
+ been a `jmp' to the new target. */
+ *return_address_location = caller->target;
+}
diff --git a/sysdeps/m68k/fpu/tan.c b/sysdeps/m68k/fpu/tan.c
new file mode 100644
index 0000000..53b3b53
--- /dev/null
+++ b/sysdeps/m68k/fpu/tan.c
@@ -0,0 +1,2 @@
+#define FUNC tan
+#include <acos.c>
diff --git a/sysdeps/m68k/fpu/tanh.c b/sysdeps/m68k/fpu/tanh.c
new file mode 100644
index 0000000..cc67395
--- /dev/null
+++ b/sysdeps/m68k/fpu/tanh.c
@@ -0,0 +1,2 @@
+#define FUNC tanh
+#include <acos.c>
diff --git a/sysdeps/m68k/jmp_buf.h b/sysdeps/m68k/jmp_buf.h
new file mode 100644
index 0000000..96240f0
--- /dev/null
+++ b/sysdeps/m68k/jmp_buf.h
@@ -0,0 +1,19 @@
+/* Define the machine-dependent type `jmp_buf'. m68k version. */
+
+typedef struct
+ {
+ /* There are eight 4-byte data registers, but D0 is not saved. */
+ long int __dregs[7];
+
+ /* There are six 4-byte address registers, plus the FP and SP. */
+ int *__aregs[6];
+ int * __fp;
+ int * __sp;
+
+#if defined(__HAVE_68881__) || defined(__HAVE_FPU__)
+ /* There are eight floating point registers which
+ are saved in IEEE 96-bit extended format. */
+ char __fpregs[8 * (96 / 8)];
+#endif
+
+ } __jmp_buf[1];
diff --git a/sysdeps/m68k/m68020/add_n.S b/sysdeps/m68k/m68020/add_n.S
new file mode 100644
index 0000000..ea7a4458
--- /dev/null
+++ b/sysdeps/m68k/m68020/add_n.S
@@ -0,0 +1,76 @@
+/* mc68020 __mpn_add_n -- Add two limb vectors of the same length > 0 and store
+ sum in a third limb vector.
+
+Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s1_ptr (sp + 8)
+ s2_ptr (sp + 16)
+ size (sp + 12)
+*/
+
+#include "asm-syntax.h"
+
+ TEXT
+ ALIGN
+ GLOBL ___mpn_add_n
+
+LAB(___mpn_add_n)
+/* Save used registers on the stack. */
+ INSN2(move,l ,MEM_PREDEC(sp),d2)
+ INSN2(move,l ,MEM_PREDEC(sp),a2)
+
+/* Copy the arguments to registers. Better use movem? */
+ INSN2(move,l ,a2,MEM_DISP(sp,12))
+ INSN2(move,l ,a0,MEM_DISP(sp,16))
+ INSN2(move,l ,a1,MEM_DISP(sp,20))
+ INSN2(move,l ,d2,MEM_DISP(sp,24))
+
+ INSN2(eor,w ,d2,#1)
+ INSN2(lsr,l ,d2,#1)
+ bcc L1
+ INSN2(subq,l ,d2,#1) /* clears cy as side effect */
+
+LAB(Loop)
+ INSN2(move,l ,d0,MEM_POSTINC(a0))
+ INSN2(move,l ,d1,MEM_POSTINC(a1))
+ INSN2(addx,l ,d0,d1)
+ INSN2(move,l ,MEM_POSTINC(a2),d0)
+LAB(L1) INSN2(move,l ,d0,MEM_POSTINC(a0))
+ INSN2(move,l ,d1,MEM_POSTINC(a1))
+ INSN2(addx,l ,d0,d1)
+ INSN2(move,l ,MEM_POSTINC(a2),d0)
+
+ dbf d2,Loop /* loop until 16 lsb of %4 == -1 */
+ INSN2(subx,l ,d0,d0) /* d0 <= -cy; save cy as 0 or -1 in d0 */
+ INSN2(sub,l ,d2,#0x10000)
+ bcs L2
+ INSN2(add,l ,d0,d0) /* restore cy */
+ bra Loop
+
+LAB(L2)
+ INSN1(neg,l ,d0)
+
+/* Restore used registers from stack frame. */
+ INSN2(move,l ,a2,MEM_POSTINC(sp))
+ INSN2(move,l ,d2,MEM_POSTINC(sp))
+
+ rts
diff --git a/sysdeps/m68k/m68020/addmul_1.S b/sysdeps/m68k/m68020/addmul_1.S
new file mode 100644
index 0000000..3f244c4
--- /dev/null
+++ b/sysdeps/m68k/m68020/addmul_1.S
@@ -0,0 +1,80 @@
+/* mc68020 __mpn_addmul_1 -- Multiply a limb vector with a limb and add
+ the result to a second limb vector.
+
+Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s1_ptr (sp + 8)
+ size (sp + 12)
+ s2_limb (sp + 16)
+*/
+
+#include "asm-syntax.h"
+
+ TEXT
+ ALIGN
+ GLOBL ___mpn_addmul_1
+
+LAB(___mpn_addmul_1)
+
+#define res_ptr a0
+#define s1_ptr a1
+#define size d2
+#define s2_limb d4
+
+/* Save used registers on the stack. */
+ INSN2(movem,l ,MEM_PREDEC(sp),d2-d5)
+
+/* Copy the arguments to registers. Better use movem? */
+ INSN2(move,l ,res_ptr,MEM_DISP(sp,20))
+ INSN2(move,l ,s1_ptr,MEM_DISP(sp,24))
+ INSN2(move,l ,size,MEM_DISP(sp,28))
+ INSN2(move,l ,s2_limb,MEM_DISP(sp,32))
+
+ INSN2(eor,w ,size,#1)
+ INSN1(clr,l ,d1)
+ INSN1(clr,l ,d5)
+ INSN2(lsr,l ,size,#1)
+ bcc L1
+ INSN2(subq,l ,size,#1)
+ INSN2(sub,l ,d0,d0) /* (d0,cy) <= (0,0) */
+
+LAB(Loop)
+ INSN2(move,l ,d3,MEM_POSTINC(s1_ptr))
+ INSN2(mulu,l ,d1:d3,s2_limb)
+ INSN2(addx,l ,d3,d0)
+ INSN2(addx,l ,d1,d5)
+ INSN2(add,l ,MEM_POSTINC(res_ptr),d3)
+LAB(L1) INSN2(move,l ,d3,MEM_POSTINC(s1_ptr))
+ INSN2(mulu,l ,d0:d3,s2_limb)
+ INSN2(addx,l ,d3,d1)
+ INSN2(addx,l ,d0,d5)
+ INSN2(add,l ,MEM_POSTINC(res_ptr),d3)
+
+ dbf size,Loop
+ INSN2(addx,l ,d0,d5)
+ INSN2(sub,l ,size,#0x10000)
+ bcc Loop
+
+/* Restore used registers from stack frame. */
+ INSN2(movem,l ,d2-d5,MEM_POSTINC(sp))
+
+ rts
diff --git a/sysdeps/m68k/m68020/asm-syntax.h b/sysdeps/m68k/m68020/asm-syntax.h
new file mode 100644
index 0000000..394b3ca
--- /dev/null
+++ b/sysdeps/m68k/m68020/asm-syntax.h
@@ -0,0 +1,105 @@
+/* asm.h -- Definitions for 68k syntax variations.
+
+Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#ifdef MIT_SYNTAX
+#define MEM(base)base@
+#define MEM_DISP(base,displacement)base@(displacement)
+#define MEM_PREDEC(memory_base)memory_base@-
+#define MEM_POSTINC(memory_base)memory_base@+
+#ifdef __STDC__
+#define INSN1(mnemonic,size_suffix,dst)mnemonic##size_suffix dst
+#define INSN2(mnemonic,size_suffix,dst,src)mnemonic##size_suffix src,dst
+#else
+#define INSN1(mnemonic,size_suffix,dst)mnemonic/**/size_suffix dst
+#define INSN2(mnemonic,size_suffix,dst,src)mnemonic/**/size_suffix src,dst
+#endif
+#define LAB(label) label:
+#define TEXT .text
+#define ALIGN .even
+#define GLOBL .globl
+#endif
+
+#ifdef SONY_SYNTAX
+#define MEM(base)(base)
+#define MEM_DISP(base,displacement)(displacement,base)
+#define MEM_PREDEC(memory_base)-(memory_base)
+#define MEM_POSTINC(memory_base)(memory_base)+
+#define INSN1(mnemonic,size_suffix,dst)mnemonic.size_suffix dst
+#ifdef __STDC__
+#define INSN2(mnemonic,size_suffix,dst,src)mnemonic.size_suffix src##,dst
+#else
+#define INSN2(mnemonic,size_suffix,dst,src)mnemonic.size_suffix src/**/,dst
+#endif
+#define LAB(label) label:
+#define TEXT .text
+#define ALIGN .even
+#define GLOBL .globl
+#endif
+
+#ifdef MOTOROLA_SYNTAX
+#define MEM(base)(base)
+#define MEM_DISP(base,displacement)(displacement,base)
+#define MEM_PREDEC(memory_base)-(memory_base)
+#define MEM_POSTINC(memory_base)(memory_base)+
+#define INSN1(mnemonic,size_suffix,dst)mnemonic.size_suffix dst
+#ifdef __STDC__
+#define INSN2(mnemonic,size_suffix,dst,src)mnemonic.size_suffix src##,dst
+#else
+#define INSN2(mnemonic,size_suffix,dst,src)mnemonic.size_suffix src/**/,dst
+#endif
+#define LAB(label) label
+#define TEXT
+#define ALIGN
+#define GLOBL XDEF
+#define l L
+#define w W
+#define move MOVE
+#define eor EOR
+#define lsr LSR
+#define add ADD
+#define addx ADDX
+#define addq ADDQ
+#define sub SUB
+#define subx SUBX
+#define subq SUBQ
+#define neg NEG
+#define bcc BCC
+#define bcs BCS
+#define bra BRA
+#define dbf DBF
+#define rts RTS
+#define d0 D0
+#define d1 D1
+#define d2 D2
+#define d3 D3
+#define d4 D4
+#define d5 D5
+#define d6 D6
+#define d7 D7
+#define a0 A0
+#define a1 A1
+#define a2 A2
+#define a3 A3
+#define a4 A4
+#define a5 A5
+#define a6 A6
+#define a7 A7
+#define sp SP
+#endif
diff --git a/sysdeps/m68k/m68020/mul_1.S b/sysdeps/m68k/m68020/mul_1.S
new file mode 100644
index 0000000..548ca00
--- /dev/null
+++ b/sysdeps/m68k/m68020/mul_1.S
@@ -0,0 +1,87 @@
+/* mc68020 __mpn_mul_1 -- Multiply a limb vector with a limb and store
+ the result in a second limb vector.
+
+Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s1_ptr (sp + 8)
+ size (sp + 12)
+ s2_limb (sp + 16)
+*/
+
+#include "asm-syntax.h"
+
+ TEXT
+ ALIGN
+ GLOBL ___mpn_mul_1
+
+LAB(___mpn_mul_1)
+
+#define res_ptr a0
+#define s1_ptr a1
+#define size d2
+#define s2_limb d4
+
+/* Save used registers on the stack. */
+ INSN2(movem,l ,MEM_PREDEC(sp),d2-d4)
+#if 0
+ INSN2(move,l ,MEM_PREDEC(sp),d2)
+ INSN2(move,l ,MEM_PREDEC(sp),d3)
+ INSN2(move,l ,MEM_PREDEC(sp),d4)
+#endif
+
+/* Copy the arguments to registers. Better use movem? */
+ INSN2(move,l ,res_ptr,MEM_DISP(sp,16))
+ INSN2(move,l ,s1_ptr,MEM_DISP(sp,20))
+ INSN2(move,l ,size,MEM_DISP(sp,24))
+ INSN2(move,l ,s2_limb,MEM_DISP(sp,28))
+
+ INSN2(eor,w ,size,#1)
+ INSN1(clr,l ,d1)
+ INSN2(lsr,l ,size,#1)
+ bcc L1
+ INSN2(subq,l ,size,#1)
+ INSN2(sub,l ,d0,d0) /* (d0,cy) <= (0,0) */
+
+LAB(Loop)
+ INSN2(move,l ,d3,MEM_POSTINC(s1_ptr))
+ INSN2(mulu,l ,d1:d3,s2_limb)
+ INSN2(addx,l ,d3,d0)
+ INSN2(move,l ,MEM_POSTINC(res_ptr),d3)
+LAB(L1) INSN2(move,l ,d3,MEM_POSTINC(s1_ptr))
+ INSN2(mulu,l ,d0:d3,s2_limb)
+ INSN2(addx,l ,d3,d1)
+ INSN2(move,l ,MEM_POSTINC(res_ptr),d3)
+
+ dbf size,Loop
+ INSN1(clr,l ,d3)
+ INSN2(addx,l ,d0,d3)
+ INSN2(sub,l ,size,#0x10000)
+ bcc Loop
+
+/* Restore used registers from stack frame. */
+ INSN2(movem,l ,d2-d4,MEM_POSTINC(sp))
+#if 0
+ INSN2(move,l ,d4,MEM_POSTINC(sp))
+ INSN2(move,l ,d3,MEM_POSTINC(sp))
+ INSN2(move,l ,d2,MEM_POSTINC(sp))
+#endif
+ rts
diff --git a/sysdeps/m68k/m68020/sub_n.S b/sysdeps/m68k/m68020/sub_n.S
new file mode 100644
index 0000000..19f0ec1
--- /dev/null
+++ b/sysdeps/m68k/m68020/sub_n.S
@@ -0,0 +1,76 @@
+/* mc68020 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
+ store difference in a third limb vector.
+
+Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s1_ptr (sp + 8)
+ s2_ptr (sp + 16)
+ size (sp + 12)
+*/
+
+#include "asm-syntax.h"
+
+ TEXT
+ ALIGN
+ GLOBL ___mpn_sub_n
+
+LAB(___mpn_sub_n)
+/* Save used registers on the stack. */
+ INSN2(move,l ,MEM_PREDEC(sp),d2)
+ INSN2(move,l ,MEM_PREDEC(sp),a2)
+
+/* Copy the arguments to registers. Better use movem? */
+ INSN2(move,l ,a2,MEM_DISP(sp,12))
+ INSN2(move,l ,a0,MEM_DISP(sp,16))
+ INSN2(move,l ,a1,MEM_DISP(sp,20))
+ INSN2(move,l ,d2,MEM_DISP(sp,24))
+
+ INSN2(eor,w ,d2,#1)
+ INSN2(lsr,l ,d2,#1)
+ bcc L1
+ INSN2(subq,l ,d2,#1) /* clears cy as side effect */
+
+LAB(Loop)
+ INSN2(move,l ,d0,MEM_POSTINC(a0))
+ INSN2(move,l ,d1,MEM_POSTINC(a1))
+ INSN2(subx,l ,d0,d1)
+ INSN2(move,l ,MEM_POSTINC(a2),d0)
+LAB(L1) INSN2(move,l ,d0,MEM_POSTINC(a0))
+ INSN2(move,l ,d1,MEM_POSTINC(a1))
+ INSN2(subx,l ,d0,d1)
+ INSN2(move,l ,MEM_POSTINC(a2),d0)
+
+ dbf d2,Loop /* loop until 16 lsb of %4 == -1 */
+ INSN2(subx,l ,d0,d0) /* d0 <= -cy; save cy as 0 or -1 in d0 */
+ INSN2(sub,l ,d2,#0x10000)
+ bcs L2
+ INSN2(add,l ,d0,d0) /* restore cy */
+ bra Loop
+
+LAB(L2)
+ INSN1(neg,l ,d0)
+
+/* Restore used registers from stack frame. */
+ INSN2(move,l ,a2,MEM_POSTINC(sp))
+ INSN2(move,l ,d2,MEM_POSTINC(sp))
+
+ rts
diff --git a/sysdeps/m68k/m68020/submul_1.S b/sysdeps/m68k/m68020/submul_1.S
new file mode 100644
index 0000000..ef7f39d
--- /dev/null
+++ b/sysdeps/m68k/m68020/submul_1.S
@@ -0,0 +1,80 @@
+/* mc68020 __mpn_submul_1 -- Multiply a limb vector with a limb and subtract
+ the result from a second limb vector.
+
+Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s1_ptr (sp + 8)
+ size (sp + 12)
+ s2_limb (sp + 16)
+*/
+
+#include "asm-syntax.h"
+
+ TEXT
+ ALIGN
+ GLOBL ___mpn_submul_1
+
+LAB(___mpn_submul_1)
+
+#define res_ptr a0
+#define s1_ptr a1
+#define size d2
+#define s2_limb d4
+
+/* Save used registers on the stack. */
+ INSN2(movem,l ,MEM_PREDEC(sp),d2-d5)
+
+/* Copy the arguments to registers. Better use movem? */
+ INSN2(move,l ,res_ptr,MEM_DISP(sp,20))
+ INSN2(move,l ,s1_ptr,MEM_DISP(sp,24))
+ INSN2(move,l ,size,MEM_DISP(sp,28))
+ INSN2(move,l ,s2_limb,MEM_DISP(sp,32))
+
+ INSN2(eor,w ,size,#1)
+ INSN1(clr,l ,d1)
+ INSN1(clr,l ,d5)
+ INSN2(lsr,l ,size,#1)
+ bcc L1
+ INSN2(subq,l ,size,#1)
+ INSN2(sub,l ,d0,d0) /* (d0,cy) <= (0,0) */
+
+LAB(Loop)
+ INSN2(move,l ,d3,MEM_POSTINC(s1_ptr))
+ INSN2(mulu,l ,d1:d3,s2_limb)
+ INSN2(addx,l ,d3,d0)
+ INSN2(addx,l ,d1,d5)
+ INSN2(sub,l ,MEM_POSTINC(res_ptr),d3)
+LAB(L1) INSN2(move,l ,d3,MEM_POSTINC(s1_ptr))
+ INSN2(mulu,l ,d0:d3,s2_limb)
+ INSN2(addx,l ,d3,d1)
+ INSN2(addx,l ,d0,d5)
+ INSN2(sub,l ,MEM_POSTINC(res_ptr),d3)
+
+ dbf size,Loop
+ INSN2(addx,l ,d0,d5)
+ INSN2(sub,l ,size,#0x10000)
+ bcc Loop
+
+/* Restore used registers from stack frame. */
+ INSN2(movem,l ,d2-d5,MEM_POSTINC(sp))
+
+ rts
diff --git a/sysdeps/m68k/memcopy.h b/sysdeps/m68k/memcopy.h
new file mode 100644
index 0000000..862e1b8
--- /dev/null
+++ b/sysdeps/m68k/memcopy.h
@@ -0,0 +1,95 @@
+/* memcopy.h -- definitions for memory copy functions. Motorola 68020 version.
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <sysdeps/generic/memcopy.h>
+
+#if defined(__mc68020__) || defined(mc68020)
+
+#undef OP_T_THRES
+#define OP_T_THRES 16
+
+/* WORD_COPY_FWD and WORD_COPY_BWD are not symmetric on the 68020,
+ because of its weird instruction overlap characteristics. */
+
+#undef WORD_COPY_FWD
+#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
+ do \
+ { \
+ size_t __nwords = (nbytes) / sizeof (op_t); \
+ size_t __nblocks = __nwords / 8 + 1; \
+ dst_bp -= (8 - __nwords % 8) * sizeof (op_t); \
+ src_bp -= (8 - __nwords % 8) * sizeof (op_t); \
+ switch (__nwords % 8) \
+ do \
+ { \
+ ((op_t *) dst_bp)[0] = ((op_t *) src_bp)[0]; \
+ case 7: \
+ ((op_t *) dst_bp)[1] = ((op_t *) src_bp)[1]; \
+ case 6: \
+ ((op_t *) dst_bp)[2] = ((op_t *) src_bp)[2]; \
+ case 5: \
+ ((op_t *) dst_bp)[3] = ((op_t *) src_bp)[3]; \
+ case 4: \
+ ((op_t *) dst_bp)[4] = ((op_t *) src_bp)[4]; \
+ case 3: \
+ ((op_t *) dst_bp)[5] = ((op_t *) src_bp)[5]; \
+ case 2: \
+ ((op_t *) dst_bp)[6] = ((op_t *) src_bp)[6]; \
+ case 1: \
+ ((op_t *) dst_bp)[7] = ((op_t *) src_bp)[7]; \
+ case 0: \
+ src_bp += 32; \
+ dst_bp += 32; \
+ __nblocks--; \
+ } \
+ while (__nblocks != 0); \
+ (nbytes_left) = (nbytes) % sizeof (op_t); \
+ } while (0)
+
+#undef WORD_COPY_BWD
+#define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \
+ do \
+ { \
+ size_t __nblocks = (nbytes) / 32 + 1; \
+ switch ((nbytes) / sizeof (op_t) % 8) \
+ do \
+ { \
+ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
+ case 7: \
+ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
+ case 6: \
+ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
+ case 5: \
+ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
+ case 4: \
+ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
+ case 3: \
+ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
+ case 2: \
+ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
+ case 1: \
+ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
+ case 0: \
+ __nblocks--; \
+ } \
+ while (__nblocks != 0); \
+ (nbytes_left) = (nbytes) % sizeof (op_t); \
+ } while (0)
+
+#endif
diff --git a/sysdeps/m68k/setjmp.c b/sysdeps/m68k/setjmp.c
new file mode 100644
index 0000000..853977e
--- /dev/null
+++ b/sysdeps/m68k/setjmp.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <setjmp.h>
+
+/* Save the current program position in ENV and return 0. */
+int
+__sigsetjmp (jmp_buf env, int savemask)
+{
+ /* Save data registers D1 through D7. */
+ asm volatile ("movem%.l d1-d7, %0" : : "m" (env[0].__jmpbuf[0].__dregs[0]));
+
+ /* Save return address in place of register A0. */
+ env[0].__jmpbuf[0].__aregs[0] = ((void **) &env)[-1];
+
+ /* Save address registers A1 through A5. */
+ asm volatile ("movem%.l a1-a5, %0" : : "m" (env[0].__jmpbuf[0].__aregs[1]));
+
+ /* Save caller's FP, not our own. */
+ env[0].__jmpbuf[0].__fp = ((void **) &env)[-2];
+
+ /* Save caller's SP, not our own. */
+ env[0].__jmpbuf[0].__sp = (void *) &env;
+
+#if defined(__HAVE_68881__) || defined(__HAVE_FPU__)
+ /* Save floating-point (68881) registers FP0 through FP7. */
+ asm volatile ("fmovem%.x fp0-fp7, %0"
+ : : "m" (env[0].__jmpbuf[0].__fpregs[0]));
+#endif
+
+ /* Save the signal mask if requested. */
+ return __sigjmp_save (env, savemask);
+}
diff --git a/sysdeps/m88k/ffs.c b/sysdeps/m88k/ffs.c
new file mode 100644
index 0000000..effca9a
--- /dev/null
+++ b/sysdeps/m88k/ffs.c
@@ -0,0 +1,42 @@
+/* ffs -- find first set bit in a word, counted from least significant end.
+ For Motorola 88000.
+ Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <ansidecl.h>
+#include <bstring.h>
+
+#undef ffs
+
+#ifdef __GNUC__
+
+int
+DEFUN(ffs, (x), int x)
+{
+ int cnt;
+
+ if (x == 0)
+ return 0;
+
+ asm ("ff1 %0,%1" : "=r" (cnt) : "r" (x & -x));
+ return cnt + 1;
+}
+
+#else
+#include <sysdeps/generic/ffs.c>
+#endif
diff --git a/sysdeps/m88k/m88100/add_n.S b/sysdeps/m88k/m88100/add_n.S
new file mode 100644
index 0000000..2107eb5
--- /dev/null
+++ b/sysdeps/m88k/m88100/add_n.S
@@ -0,0 +1,133 @@
+; mc88100 __mpn_add -- Add two limb vectors of the same length > 0 and store
+; sum in a third limb vector.
+
+; Copyright (C) 1992, 1994 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 General Public License as published by
+; the Free Software Foundation; either version 2, 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 General Public License for more details.
+
+; You should have received a copy of the GNU General Public License
+; along with the GNU MP Library; see the file COPYING. If not, write to
+; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+; INPUT PARAMETERS
+; res_ptr r2
+; s1_ptr r3
+; s2_ptr r4
+; size r5
+
+; This code has been optimized to run one instruction per clock, avoiding
+; load stalls and writeback contention. As a result, the instruction
+; order is not always natural.
+
+; The speed is approximately 4.3 clocks/limb + 18 clocks/limb-vector.
+
+#include "sysdep.h"
+
+ENTRY (__mpn_add_n)
+ ld r6,r3,0 ; read first limb from s1_ptr
+ extu r10,r5,4
+ ld r7,r4,0 ; read first limb from s2_ptr
+
+ subu.co r5,r0,r5 ; (clear carry as side effect)
+ mak r5,r5,4<4>
+ bcnd eq0,r5,Lzero
+
+ or r12,r0,lo16(Lbase)
+ or.u r12,r12,hi16(Lbase)
+ addu r12,r12,r5 ; r12 is address for entering in loop
+
+ extu r5,r5,2 ; divide by 4
+ subu r2,r2,r5 ; adjust res_ptr
+ subu r3,r3,r5 ; adjust s1_ptr
+ subu r4,r4,r5 ; adjust s2_ptr
+
+ or r8,r6,r0
+
+ jmp.n r12
+ or r9,r7,r0
+
+Loop: addu r3,r3,64
+ st r8,r2,60
+ addu r4,r4,64
+ ld r6,r3,0
+ addu r2,r2,64
+ ld r7,r4,0
+Lzero: subu r10,r10,1 ; add 0 + 16r limbs (adjust loop counter)
+Lbase: ld r8,r3,4
+ addu.cio r6,r6,r7
+ ld r9,r4,4
+ st r6,r2,0
+ ld r6,r3,8 ; add 15 + 16r limbs
+ addu.cio r8,r8,r9
+ ld r7,r4,8
+ st r8,r2,4
+ ld r8,r3,12 ; add 14 + 16r limbs
+ addu.cio r6,r6,r7
+ ld r9,r4,12
+ st r6,r2,8
+ ld r6,r3,16 ; add 13 + 16r limbs
+ addu.cio r8,r8,r9
+ ld r7,r4,16
+ st r8,r2,12
+ ld r8,r3,20 ; add 12 + 16r limbs
+ addu.cio r6,r6,r7
+ ld r9,r4,20
+ st r6,r2,16
+ ld r6,r3,24 ; add 11 + 16r limbs
+ addu.cio r8,r8,r9
+ ld r7,r4,24
+ st r8,r2,20
+ ld r8,r3,28 ; add 10 + 16r limbs
+ addu.cio r6,r6,r7
+ ld r9,r4,28
+ st r6,r2,24
+ ld r6,r3,32 ; add 9 + 16r limbs
+ addu.cio r8,r8,r9
+ ld r7,r4,32
+ st r8,r2,28
+ ld r8,r3,36 ; add 8 + 16r limbs
+ addu.cio r6,r6,r7
+ ld r9,r4,36
+ st r6,r2,32
+ ld r6,r3,40 ; add 7 + 16r limbs
+ addu.cio r8,r8,r9
+ ld r7,r4,40
+ st r8,r2,36
+ ld r8,r3,44 ; add 6 + 16r limbs
+ addu.cio r6,r6,r7
+ ld r9,r4,44
+ st r6,r2,40
+ ld r6,r3,48 ; add 5 + 16r limbs
+ addu.cio r8,r8,r9
+ ld r7,r4,48
+ st r8,r2,44
+ ld r8,r3,52 ; add 4 + 16r limbs
+ addu.cio r6,r6,r7
+ ld r9,r4,52
+ st r6,r2,48
+ ld r6,r3,56 ; add 3 + 16r limbs
+ addu.cio r8,r8,r9
+ ld r7,r4,56
+ st r8,r2,52
+ ld r8,r3,60 ; add 2 + 16r limbs
+ addu.cio r6,r6,r7
+ ld r9,r4,60
+ st r6,r2,56
+ bcnd.n ne0,r10,Loop ; add 1 + 16r limbs
+ addu.cio r8,r8,r9
+
+ st r8,r2,60 ; store most significant limb
+
+ jmp.n r1
+ addu.ci r2,r0,r0 ; return carry-out from most sign. limb
diff --git a/sysdeps/m88k/m88100/mul_1.S b/sysdeps/m88k/m88100/mul_1.S
new file mode 100644
index 0000000..503897b
--- /dev/null
+++ b/sysdeps/m88k/m88100/mul_1.S
@@ -0,0 +1,127 @@
+; mc88100 __mpn_mul_1 -- Multiply a limb vector with a single limb and
+; store the product in a second limb vector.
+
+; Copyright (C) 1992, 1994 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 General Public License as published by
+; the Free Software Foundation; either version 2, 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 General Public License for more details.
+
+; You should have received a copy of the GNU General Public License
+; along with the GNU MP Library; see the file COPYING. If not, write to
+; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+; INPUT PARAMETERS
+; res_ptr r2
+; s1_ptr r3
+; size r4
+; s2_limb r5
+
+; Common overhead is about 11 cycles/invocation.
+
+; The speed for S2_LIMB >= 0x10000 is approximately 21 cycles/limb. (The
+; pipeline stalls 2 cycles due to WB contention.)
+
+; The speed for S2_LIMB < 0x10000 is approximately 16 cycles/limb. (The
+; pipeline stalls 2 cycles due to WB contention and 1 cycle due to latency.)
+
+; To enhance speed:
+; 1. Unroll main loop 4-8 times.
+; 2. Schedule code to avoid WB contention. It might be tempting to move the
+; ld instruction in the loops down to save 2 cycles (less WB contention),
+; but that looses because the ultimate value will be read from outside
+; the allocated space. But if we handle the ultimate multiplication in
+; the tail, we can do this.
+; 3. Make the multiplication with less instructions. I think the code for
+; (S2_LIMB >= 0x10000) is not minimal.
+; With these techniques the (S2_LIMB >= 0x10000) case would run in 17 or
+; less cycles/limb; the (S2_LIMB < 0x10000) case would run in 11
+; cycles/limb. (Assuming infinite unrolling.)
+
+#include "sysdep.h"
+
+ENTRY (__mpn_mul_1)
+
+ ; Make S1_PTR and RES_PTR point at the end of their blocks
+ ; and negate SIZE.
+ lda r3,r3[r4]
+ lda r6,r2[r4] ; RES_PTR in r6 since r2 is retval
+ subu r4,r0,r4
+
+ addu.co r2,r0,r0 ; r2 = cy = 0
+ ld r9,r3[r4]
+ mask r7,r5,0xffff ; r7 = lo(S2_LIMB)
+ extu r8,r5,16 ; r8 = hi(S2_LIMB)
+ bcnd.n eq0,r8,Lsmall ; jump if (hi(S2_LIMB) == 0)
+ subu r6,r6,4
+
+; General code for any value of S2_LIMB.
+
+ ; Make a stack frame and save r25 and r26
+ subu r31,r31,16
+ st.d r25,r31,8
+
+ ; Enter the loop in the middle
+ br.n L1
+ addu r4,r4,1
+
+Loop:
+ ld r9,r3[r4]
+ st r26,r6[r4]
+; bcnd ne0,r0,0 ; bubble
+ addu r4,r4,1
+L1: mul r26,r9,r5 ; low word of product mul_1 WB ld
+ mask r12,r9,0xffff ; r12 = lo(s1_limb) mask_1
+ mul r11,r12,r7 ; r11 = prod_0 mul_2 WB mask_1
+ mul r10,r12,r8 ; r10 = prod_1a mul_3
+ extu r13,r9,16 ; r13 = hi(s1_limb) extu_1 WB mul_1
+ mul r12,r13,r7 ; r12 = prod_1b mul_4 WB extu_1
+ mul r25,r13,r8 ; r25 = prod_2 mul_5 WB mul_2
+ extu r11,r11,16 ; r11 = hi(prod_0) extu_2 WB mul_3
+ addu r10,r10,r11 ; addu_1 WB extu_2
+; bcnd ne0,r0,0 ; bubble WB addu_1
+ addu.co r10,r10,r12 ; WB mul_4
+ mask.u r10,r10,0xffff ; move the 16 most significant bits...
+ addu.ci r10,r10,r0 ; ...to the low half of the word...
+ rot r10,r10,16 ; ...and put carry in pos 16.
+ addu.co r26,r26,r2 ; add old carry limb
+ bcnd.n ne0,r4,Loop
+ addu.ci r2,r25,r10 ; compute new carry limb
+
+ st r26,r6[r4]
+ ld.d r25,r31,8
+ jmp.n r1
+ addu r31,r31,16
+
+; Fast code for S2_LIMB < 0x10000
+Lsmall:
+ ; Enter the loop in the middle
+ br.n SL1
+ addu r4,r4,1
+
+SLoop:
+ ld r9,r3[r4] ;
+ st r8,r6[r4] ;
+ addu r4,r4,1 ;
+SL1: mul r8,r9,r5 ; low word of product
+ mask r12,r9,0xffff ; r12 = lo(s1_limb)
+ extu r13,r9,16 ; r13 = hi(s1_limb)
+ mul r11,r12,r7 ; r11 = prod_0
+ mul r12,r13,r7 ; r12 = prod_1b
+ addu.cio r8,r8,r2 ; add old carry limb
+ extu r10,r11,16 ; r11 = hi(prod_0)
+ addu r10,r10,r12 ;
+ bcnd.n ne0,r4,SLoop
+ extu r2,r10,16 ; r2 = new carry limb
+
+ jmp.n r1
+ st r8,r6[r4]
diff --git a/sysdeps/m88k/m88100/sub_n.S b/sysdeps/m88k/m88100/sub_n.S
new file mode 100644
index 0000000..927ece4
--- /dev/null
+++ b/sysdeps/m88k/m88100/sub_n.S
@@ -0,0 +1,134 @@
+; mc88100 __mpn_sub -- Subtract two limb vectors of the same length > 0 and
+; store difference in a third limb vector.
+
+; Copyright (C) 1992, 1994 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 General Public License as published by
+; the Free Software Foundation; either version 2, 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 General Public License for more details.
+
+; You should have received a copy of the GNU General Public License
+; along with the GNU MP Library; see the file COPYING. If not, write to
+; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+; INPUT PARAMETERS
+; res_ptr r2
+; s1_ptr r3
+; s2_ptr r4
+; size r5
+
+; This code has been optimized to run one instruction per clock, avoiding
+; load stalls and writeback contention. As a result, the instruction
+; order is not always natural.
+
+; The speed is approximately 4.3 clocks/limb + 18 clocks/limb-vector.
+
+#include "sysdep.h"
+
+ENTRY (__mpn_sub_n)
+ ld r6,r3,0 ; read first limb from s1_ptr
+ extu r10,r5,4
+ ld r7,r4,0 ; read first limb from s2_ptr
+
+ subu.co r5,r0,r5 ; (clear carry as side effect)
+ mak r5,r5,4<4>
+ bcnd eq0,r5,Lzero
+
+ or r12,r0,lo16(Lbase)
+ or.u r12,r12,hi16(Lbase)
+ addu r12,r12,r5 ; r12 is address for entering in loop
+
+ extu r5,r5,2 ; divide by 4
+ subu r2,r2,r5 ; adjust res_ptr
+ subu r3,r3,r5 ; adjust s1_ptr
+ subu r4,r4,r5 ; adjust s2_ptr
+
+ or r8,r6,r0
+
+ jmp.n r12
+ or r9,r7,r0
+
+Loop: addu r3,r3,64
+ st r8,r2,60
+ addu r4,r4,64
+ ld r6,r3,0
+ addu r2,r2,64
+ ld r7,r4,0
+Lzero: subu r10,r10,1 ; subtract 0 + 16r limbs (adjust loop counter)
+Lbase: ld r8,r3,4
+ subu.cio r6,r6,r7
+ ld r9,r4,4
+ st r6,r2,0
+ ld r6,r3,8 ; subtract 15 + 16r limbs
+ subu.cio r8,r8,r9
+ ld r7,r4,8
+ st r8,r2,4
+ ld r8,r3,12 ; subtract 14 + 16r limbs
+ subu.cio r6,r6,r7
+ ld r9,r4,12
+ st r6,r2,8
+ ld r6,r3,16 ; subtract 13 + 16r limbs
+ subu.cio r8,r8,r9
+ ld r7,r4,16
+ st r8,r2,12
+ ld r8,r3,20 ; subtract 12 + 16r limbs
+ subu.cio r6,r6,r7
+ ld r9,r4,20
+ st r6,r2,16
+ ld r6,r3,24 ; subtract 11 + 16r limbs
+ subu.cio r8,r8,r9
+ ld r7,r4,24
+ st r8,r2,20
+ ld r8,r3,28 ; subtract 10 + 16r limbs
+ subu.cio r6,r6,r7
+ ld r9,r4,28
+ st r6,r2,24
+ ld r6,r3,32 ; subtract 9 + 16r limbs
+ subu.cio r8,r8,r9
+ ld r7,r4,32
+ st r8,r2,28
+ ld r8,r3,36 ; subtract 8 + 16r limbs
+ subu.cio r6,r6,r7
+ ld r9,r4,36
+ st r6,r2,32
+ ld r6,r3,40 ; subtract 7 + 16r limbs
+ subu.cio r8,r8,r9
+ ld r7,r4,40
+ st r8,r2,36
+ ld r8,r3,44 ; subtract 6 + 16r limbs
+ subu.cio r6,r6,r7
+ ld r9,r4,44
+ st r6,r2,40
+ ld r6,r3,48 ; subtract 5 + 16r limbs
+ subu.cio r8,r8,r9
+ ld r7,r4,48
+ st r8,r2,44
+ ld r8,r3,52 ; subtract 4 + 16r limbs
+ subu.cio r6,r6,r7
+ ld r9,r4,52
+ st r6,r2,48
+ ld r6,r3,56 ; subtract 3 + 16r limbs
+ subu.cio r8,r8,r9
+ ld r7,r4,56
+ st r8,r2,52
+ ld r8,r3,60 ; subtract 2 + 16r limbs
+ subu.cio r6,r6,r7
+ ld r9,r4,60
+ st r6,r2,56
+ bcnd.n ne0,r10,Loop ; subtract 1 + 16r limbs
+ subu.cio r8,r8,r9
+
+ st r8,r2,60 ; store most significant limb
+
+ addu.ci r2,r0,r0 ; return carry-out from most sign. limb
+ jmp.n r1
+ xor r2,r2,1
diff --git a/sysdeps/m88k/m88110/mul_1.S b/sysdeps/m88k/m88110/mul_1.S
new file mode 100644
index 0000000..7a07623
--- /dev/null
+++ b/sysdeps/m88k/m88110/mul_1.S
@@ -0,0 +1,80 @@
+; mc88110 __mpn_mul_1 -- Multiply a limb vector with a single limb and
+; store the product in a second limb vector.
+
+; Copyright (C) 1992, 1994 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 General Public License as published by
+; the Free Software Foundation; either version 2, 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 General Public License for more details.
+
+; You should have received a copy of the GNU General Public License
+; along with the GNU MP Library; see the file COPYING. If not, write to
+; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+; INPUT PARAMETERS
+; res_ptr r2
+; s1_ptr r3
+; size r4
+; s2_limb r5
+
+#include "sysdep.h"
+
+ENTRY (__mpn_mul_1)
+ ld r6,r3,0
+ sub r4,r0,r4
+ sub r3,r3,r4 ; r3 is offset s1_ptr
+ sub r2,r2,r4
+ sub r8,r2,8 ; r8 is offset res_ptr
+ mulu.d r10,r6,r5
+
+ addu r4,r4,1
+ bcnd eq0,r4,Lend
+ addu.co r2,r0,0 ; clear cy_limb
+
+Loop: ld r6,r3[r4]
+ addu.cio r9,r11,r2
+ or r2,r10,r0 ; could be avoided if unrolled
+ addu r4,r4,1
+ mulu.d r10,r6,r5
+ bcnd ne0,r4,Loop
+ st r9,r8[r4]
+
+Lend: addu.cio r9,r11,r2
+ st r9,r8,4
+ jmp.n r1
+ addu.ci r2,r10,r0
+
+; This is the Right Way to do this on '110. 4 cycles / 64-bit limb.
+; ld.d r10,
+; mulu.d
+; addu.cio
+; addu.cio
+; st.d
+; mulu.d ,r11,r5
+; ld.d r12,
+; mulu.d ,r10,r5
+; addu.cio
+; addu.cio
+; st.d
+; mulu.d
+; ld.d r10,
+; mulu.d
+; addu.cio
+; addu.cio
+; st.d
+; mulu.d
+; ld.d r10,
+; mulu.d
+; addu.cio
+; addu.cio
+; st.d
+; mulu.d
diff --git a/sysdeps/mach/Makefile b/sysdeps/mach/Makefile
new file mode 100644
index 0000000..fab174c
--- /dev/null
+++ b/sysdeps/mach/Makefile
@@ -0,0 +1,74 @@
+# Copyright (C) 1993, 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.
+
+ifndef mach-srcdir-computed
+mach-srcdir-computed := yes
+
+# If we were configured with `--with-mach=DIR', then config.make sets
+# mach-srcdir to DIR. Otherwise guess we are in a big source tree.
+ifndef mach-srcdir
+mach-srcdir = ../mach
+endif
+
+# mach-srcdir is now set to the logical directory name. This name might be
+# relative to $(objdir), might be relative to the source directory $(..), or
+# might be absolute. We choose among these possibilities by looking for a
+# canonical file in each of those places (in that order).
+f := mach/mach.defs # Random file that identifies the Mach source dir.
+f := $(strip $f)
+mach-srcdir := $(firstword $(patsubst %/$f,%,$(wildcard $(addsuffix /$f,\
+ $(objpfx)$(mach-srcdir) $(..)$(mach-srcdir)))) $(mach-srcdir))
+
+endif # ! mach-srcdir-computed
+
+ifdef in-Makerules
+
+# Look for header files in mach/ under the top-level library source directory.
+includes += -I$(..)mach
+
+# When compiling, use the Mach header files directly from the kernel sources.
+includes += -I$(mach-srcdir)
+
+# Find Mach header files in the kernel source.
+vpath mach/%.h $(mach-srcdir)
+vpath device/%.h $(mach-srcdir)
+
+ifneq (mach,$(subdir))
+# Subdirectories other than mach/ might use the generated Mach headers.
+# So make sure we get a chance to run in mach/ to make them before all else.
+
+ifdef objpfx
+mach-objpfx = $(objpfx)
+else
+mach-objpfx = $(..)mach/
+endif
+
+# These are all the generated files that <mach.h> includes.
+mach-before-compile := $(mach-objpfx)mach-shortcuts.h \
+ $(patsubst %,$(mach-objpfx)mach/mach_%.h,\
+ interface port host)
+
+# This patsubst generates patterns like `m%h-shortcuts.h', which are damn
+# likely to match just the corresponding particular file we want.
+$(patsubst mach%,m\%h%,$(mach-before-compile)): # Run only if doesn't exist.
+ $(MAKE) -C $(..)mach generated no_deps=t
+
+before-compile += $(mach-before-compile)
+endif
+
+endif # in-Makerules
diff --git a/sysdeps/mach/Subdirs b/sysdeps/mach/Subdirs
new file mode 100644
index 0000000..fc6ac35
--- /dev/null
+++ b/sysdeps/mach/Subdirs
@@ -0,0 +1 @@
+mach
diff --git a/sysdeps/mach/_strerror.c b/sysdeps/mach/_strerror.c
new file mode 100644
index 0000000..4740902
--- /dev/null
+++ b/sysdeps/mach/_strerror.c
@@ -0,0 +1,60 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+#include <string.h>
+#include <mach/error.h>
+#include <mach/errorlib.h>
+
+/* Return a string describing the errno code in ERRNUM. */
+char *
+DEFUN(_strerror_internal, (errnum, buf), int errnum AND char buf[1024])
+{
+ 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)
+ {
+ sprintf (buf, "Unknown error system %d", system);
+ return buf;
+ }
+
+ es = &__mach_error_systems[system];
+
+ if (sub >= es->max_sub)
+ return (char *) es->bad_sub;
+
+ if (code >= es->subsystem[sub].max_code)
+ {
+ sprintf (buf, "Unknown error %d in system %d subsystem %d",
+ code, system, sub);
+ return buf;
+ }
+
+ return (char *) es->subsystem[sub].codes[code];
+}
diff --git a/sysdeps/mach/adjtime.c b/sysdeps/mach/adjtime.c
new file mode 100644
index 0000000..f201535
--- /dev/null
+++ b/sysdeps/mach/adjtime.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <hurd.h>
+
+/* Adjust the current time of day by the amount in DELTA.
+ If OLDDELTA is not NULL, it is filled in with the amount
+ of time adjustment remaining to be done from the last `__adjtime' call.
+ This call is restricted to the super-user. */
+int
+DEFUN(__adjtime, (delta, olddelta),
+ CONST struct timeval *delta AND
+ struct timeval *olddelta)
+{
+ error_t err;
+ mach_port_t hostpriv;
+
+ hostpriv = __pid2task (-1);
+ if (hostpriv == MACH_PORT_NULL)
+ return -1;
+ err = __host_adjust_time (hostpriv, delta, olddelta);
+ __mach_port_deallocate (__mach_task_self (), hostpriv);
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+
+weak_alias (__adjtime, adjtime)
diff --git a/sysdeps/mach/alpha/machine-lock.h b/sysdeps/mach/alpha/machine-lock.h
new file mode 100644
index 0000000..42e21d8
--- /dev/null
+++ b/sysdeps/mach/alpha/machine-lock.h
@@ -0,0 +1,80 @@
+/* Machine-specific definition for spin locks. Alpha 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. */
+
+#ifndef _MACHINE_LOCK_H
+#define _MACHINE_LOCK_H
+
+/* The type of a spin lock variable. */
+
+typedef __volatile long int __spin_lock_t;
+
+/* Value to initialize `__spin_lock_t' variables to. */
+
+#define __SPIN_LOCK_INITIALIZER 0L
+
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE extern __inline
+#endif
+
+/* Unlock LOCK. */
+
+_EXTERN_INLINE void
+__spin_unlock (__spin_lock_t *__lock)
+{
+ __asm__ __volatile__ ("mb; stq $31, %0; mb"
+ : "=m" (__lock));
+}
+
+/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */
+
+_EXTERN_INLINE int
+__spin_try_lock (register __spin_lock_t *__lock)
+{
+ register long int __rtn, __tmp;
+
+ do
+ {
+ __asm__ __volatile__ ("mb; ldq_l %0,%1" /* Load lock value into TMP. */
+ : "=r" (__tmp) : "m" (*__lock));
+ __rtn = 2; /* Load locked value into RTN. */
+ if (__tmp)
+ /* The lock is already taken. */
+ return 0;
+
+ /* The lock is not taken; try to get it now. */
+ __asm__ __volatile__ ("stq_c %0,%1"
+ : "=r" (__rtn), "=m" (*__lock)
+ : "0" (__rtn), "1" (*__lock));
+ /* RTN is clear if stq_c was interrupted; loop to try the lock again. */
+ } while (! __rtn);
+ /* RTN is now nonzero; we have the lock. */
+ return __rtn;
+}
+
+/* Return nonzero if LOCK is locked. */
+
+_EXTERN_INLINE int
+__spin_lock_locked (__spin_lock_t *__lock)
+{
+ return *__lock != 0;
+}
+
+
+#endif /* machine-lock.h */
diff --git a/sysdeps/mach/alpha/machine-sp.h b/sysdeps/mach/alpha/machine-sp.h
new file mode 100644
index 0000000..6a8a3c6
--- /dev/null
+++ b/sysdeps/mach/alpha/machine-sp.h
@@ -0,0 +1,36 @@
+/* Machine-specific function to return the stack pointer. Alpha 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. */
+
+#ifndef _MACHINE_SP_H
+#define _MACHINE_SP_H
+
+/* Return the current stack pointer. */
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE extern __inline
+#endif
+
+_EXTERN_INLINE void *
+__thread_stack_pointer (void)
+{
+ register void *__sp__ __asm__ ("$30");
+ return __sp__;
+}
+
+#endif /* machine-sp.h */
diff --git a/sysdeps/mach/alpha/syscall.S b/sysdeps/mach/alpha/syscall.S
new file mode 100644
index 0000000..31ccb5f
--- /dev/null
+++ b/sysdeps/mach/alpha/syscall.S
@@ -0,0 +1,39 @@
+/* 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. */
+
+#include <sysdep.h>
+#include <mach/machine/alpha_instruction.h>
+
+ENTRY (syscall)
+ .frame sp,0,ra
+ mov a0, v0 /* Load system call number from first arg. */
+ mov a1, a0
+ mov a2, a1
+ mov a3, a2
+ mov a4, a3
+ mov a5, a4
+ /* Load the remaining possible args (up to 11) from the stack. */
+ ldq a5,0(sp)
+ ldq t0,8(sp)
+ ldq t1,16(sp)
+ ldq t2,24(sp)
+ ldq t3,32(sp)
+ ldq t4,40(sp)
+ call_pal op_chmk
+ RET
+ .end syscall
diff --git a/sysdeps/mach/alpha/sysdep.h b/sysdeps/mach/alpha/sysdep.h
new file mode 100644
index 0000000..a327662
--- /dev/null
+++ b/sysdeps/mach/alpha/sysdep.h
@@ -0,0 +1,41 @@
+/* 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. */
+
+#define MOVE(x,y) mov x, y
+
+#define LOSE asm volatile ("call_pal 0") /* halt */
+
+#define START_MACHDEP \
+ asm ("_start: mov $30, $16\n" /* Put initial SP in a0. */ \
+ " br $27, 1f\n" /* Load GP from PC. */ \
+ "1: ldgp $29, 0($27)\n" \
+ " jmp $26, _start0"); /* Jump to _start0; don't return. */
+#define START_ARGS char **sparg
+#define SNARF_ARGS(argc, argv, envp) \
+ (envp = &(argv = &sparg[1])[(argc = *(int *) sparg) + 1])
+
+#define CALL_WITH_SP(fn, sp) \
+ ({ register long int __fn = (long int) fn, __sp = (long int) sp; \
+ asm volatile ("mov %0,$30; jmp $31, (%1); ldgp $29, 0(%1)" \
+ : : "r" (__sp), "r" (__fn)); })
+
+#define ENTRY(name) LEAF(name, ***loser no arg count***)
+
+#define STACK_GROWTH_DOWN
+
+#include_next <sysdep.h>
diff --git a/sysdeps/mach/alpha/thread_state.h b/sysdeps/mach/alpha/thread_state.h
new file mode 100644
index 0000000..28b0a15
--- /dev/null
+++ b/sysdeps/mach/alpha/thread_state.h
@@ -0,0 +1,39 @@
+/* Mach thread state definitions for machine-independent code. Alpha 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. */
+
+#include <mach/machine/thread_status.h>
+
+#define MACHINE_THREAD_STATE_FLAVOR ALPHA_THREAD_STATE
+#define MACHINE_THREAD_STATE_COUNT ALPHA_THREAD_STATE_COUNT
+
+#define machine_thread_state alpha_thread_state
+
+#define PC pc
+#define SP r30
+#define SYSRETURN r0
+
+struct machine_thread_all_state
+ {
+ int set; /* Mask of bits (1 << FLAVOR). */
+ struct alpha_thread_state basic;
+ struct alpha_exc_state exc;
+ struct alpha_float_state fpu;
+ };
+
+#include_next <thread_state.h>
diff --git a/sysdeps/mach/configure b/sysdeps/mach/configure
new file mode 100644
index 0000000..fb1d8b0
--- /dev/null
+++ b/sysdeps/mach/configure
@@ -0,0 +1,17 @@
+
+# If configure is passed `--with-mach=DIR', set `mach-srcdir' to DIR in
+# config.make.
+
+ac_help="$ac_help
+ --with-mach=DIRECTORY find Mach kernel source code in DIRECTORY [../mach]"
+# Check whether --with-mach or --without-mach was given.
+withval="$with_mach"
+if test -n "$withval"; then
+ case z"$with_mach" in
+z | zno | zyes) ;; # Not specified, or specified with no value.
+z*) config_vars="$config_vars
+mach-srcdir = $with_mach" ;;
+esac
+
+fi
+
diff --git a/sysdeps/mach/configure.in b/sysdeps/mach/configure.in
new file mode 100644
index 0000000..2628886
--- /dev/null
+++ b/sysdeps/mach/configure.in
@@ -0,0 +1,15 @@
+sinclude(./aclocal.m4)dnl Autoconf lossage.
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+
+# If configure is passed `--with-mach=DIR', set `mach-srcdir' to DIR in
+# config.make.
+
+AC_ARG_WITH(mach, dnl
+[ --with-mach=DIRECTORY find Mach kernel source code in DIRECTORY [../mach]],
+ [dnl
+case z"$with_mach" in
+z | zno | zyes) ;; # Not specified, or specified with no value.
+z*) config_vars="$config_vars
+mach-srcdir = $with_mach" ;;
+esac
+])
diff --git a/sysdeps/mach/getpagesize.c b/sysdeps/mach/getpagesize.c
new file mode 100644
index 0000000..84f227f
--- /dev/null
+++ b/sysdeps/mach/getpagesize.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <errno.h>
+#include <mach.h>
+
+/* Return the system page size. */
+size_t
+DEFUN_VOID(__getpagesize)
+{
+ return __vm_page_size;
+}
+
+weak_alias (__getpagesize, getpagesize)
diff --git a/sysdeps/mach/gettimeofday.c b/sysdeps/mach/gettimeofday.c
new file mode 100644
index 0000000..9271490
--- /dev/null
+++ b/sysdeps/mach/gettimeofday.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <mach.h>
+
+/* Get the current time of day and timezone information,
+ putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
+ Returns 0 on success, -1 on errors. */
+int
+DEFUN(__gettimeofday, (tv, tz),
+ struct timeval *tv AND struct timezone *tz)
+{
+ kern_return_t err;
+
+ if (tz != NULL)
+ {
+ errno = ENOSYS;
+ return -1;
+ }
+
+ if (err = __host_get_time (__mach_host_self (), (time_value_t *) tv))
+ {
+ errno = err;
+ return -1;
+ }
+ return 0;
+}
+
+weak_alias (__gettimeofday, gettimeofday)
diff --git a/sysdeps/mach/hppa/machine-lock.h b/sysdeps/mach/hppa/machine-lock.h
new file mode 100644
index 0000000..0a17835
--- /dev/null
+++ b/sysdeps/mach/hppa/machine-lock.h
@@ -0,0 +1,63 @@
+/* Machine-specific definition for spin locks. HPPA version.
+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. */
+
+#ifndef _MACHINE_LOCK_H
+#define _MACHINE_LOCK_H
+
+/* The type of a spin lock variable. */
+
+typedef __volatile int __spin_lock_t __attribute__ ((__aligned__ (16)));
+
+/* Value to initialize `__spin_lock_t' variables to. */
+
+#define __SPIN_LOCK_INITIALIZER -1
+
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE extern __inline
+#endif
+
+/* Unlock LOCK. */
+
+_EXTERN_INLINE void
+__spin_unlock (__spin_lock_t *__lock)
+{
+ *__lock = -1;
+}
+
+/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */
+
+_EXTERN_INLINE int
+__spin_try_lock (__spin_lock_t *__lock)
+{
+ register int __result;
+ __asm__ __volatile__ ("ldcws %0, %1" : "=m" (*__lock), "=r" (__result));
+ return __result != 0;
+}
+
+/* Return nonzero if LOCK is locked. */
+
+_EXTERN_INLINE int
+__spin_lock_locked (__spin_lock_t *__lock)
+{
+ return *__lock == 0;
+}
+
+
+#endif /* machine-lock.h */
diff --git a/sysdeps/mach/hurd/.cvsignore b/sysdeps/mach/hurd/.cvsignore
new file mode 100644
index 0000000..1f69fd9
--- /dev/null
+++ b/sysdeps/mach/hurd/.cvsignore
@@ -0,0 +1,4 @@
+*.gz *.Z *.tar *.tgz
+=*
+TODO COPYING* AUTHORS copyr-* copying.*
+glibc-*
diff --git a/sysdeps/mach/hurd/Dist b/sysdeps/mach/hurd/Dist
new file mode 100644
index 0000000..89a6b56
--- /dev/null
+++ b/sysdeps/mach/hurd/Dist
@@ -0,0 +1,3 @@
+errnos.awk errlist.awk err_hurd.sub
+libc-ldscript
+
diff --git a/sysdeps/mach/hurd/Implies b/sysdeps/mach/hurd/Implies
new file mode 100644
index 0000000..b6e4d86
--- /dev/null
+++ b/sysdeps/mach/hurd/Implies
@@ -0,0 +1,2 @@
+# The Hurd provides a rough superset of the functionality of 4.4 BSD.
+unix/bsd/bsd4.4
diff --git a/sysdeps/mach/hurd/Makefile b/sysdeps/mach/hurd/Makefile
new file mode 100644
index 0000000..70b6ec5
--- /dev/null
+++ b/sysdeps/mach/hurd/Makefile
@@ -0,0 +1,132 @@
+# Copyright (C) 1993, 1994, 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.
+
+# Get mach-srcdir defined.
+old-in-Makerules := $(in-Makerules)
+in-Makerules :=
+include $(..)sysdeps/mach/Makefile
+in-Makerules := $(old-in-Makerules)
+
+
+ifndef hurd-srcdir-computed
+hurd-srcdir-computed := yes
+
+# If we were configured with `--with-hurd=DIR', then config.make sets
+# hurd-srcdir to DIR. Otherwise guess we are in a big source tree.
+ifndef hurd-srcdir
+hurd-srcdir = ../hurd
+endif
+
+# hurd-srcdir is now set to the logical directory name. This name might be
+# relative to $(objdir), might be relative to the source directory $(..), or
+# might be absolute. We choose among these possibilities by looking for a
+# canonical file in each of those places (in that order).
+f := hurd/hurd_types.defs # Random file that identifies the Hurd source dir.
+f := $(strip $f)
+hurd-srcdir := $(firstword $(patsubst %/$f,%,$(wildcard $(addsuffix /$f,\
+ $(objpfx)$(hurd-srcdir) $(..)$(hurd-srcdir)))) $(hurd-srcdir))
+
+endif # ! hurd-srcdir-computed
+
+ifdef in-Makerules
+
+# For the time being, elide directories where nothing at all works.
+subdirs := $(filter-out sunrpc manual,$(subdirs)) # XXX
+
+# Look for header files in hurd/ under the top-level library source directory.
+includes += -I$(..)hurd
+
+# When compiling, use the Hurd header files directly from the sources.
+includes += -I$(hurd-srcdir)
+
+# When compiling, find cthreads.h in the Hurd cthreads source.
+# This directory has some other (private) header file with
+# conflicting names, so we put it last.
+last-includes += -I$(hurd-srcdir)/libthreads
+
+# Find the Hurd header files in the Hurd source.
+vpath hurd/%.h $(hurd-srcdir)
+
+# Do not use any assembly code from sysdeps/unix (and subdirectories).
+# This bypasses all the system call stubs and uses any existing posix or
+# generic C files instead.
+inhibit-sysdep-asm += unix*
+
+# Don't try to generate anything from the installed Unix system and its
+# libraries. That is only of use when building for a Unix system, so as to
+# be compatible with some existing binaries for that system.
+inhibit-glue = yes
+
+
+ifeq (,$(filter mach hurd,$(subdir)))
+# Subdirectories other than hurd/ might use the generated Hurd headers.
+# So make sure we get a chance to run in hurd/ to make them before all else.
+# (But we don't want to do this in mach/, because hurd/ needs some things
+# there, and we know mach/ doesn't need anything from hurd/.)
+
+ifdef objpfx
+hurd-objpfx = $(objpfx)
+else
+hurd-objpfx = $(..)hurd/
+endif
+
+# These are all the generated headers that <hurd.h> includes.
+before-compile += $(patsubst %,$(hurd-objpfx)hurd/%.h,io fs process)
+$(patsubst %,$(hurd-objpfx)hurd/%.%,io fs process):
+ $(MAKE) -C $(..)hurd generated no_deps=t
+endif
+
+# Generate errnos.h and sys_errlist.c from the section of the manual that
+# lists all the errno codes.
+
+errno.texinfo = $(..)manual/errno.texi
+
+hurd = $(..)sysdeps/mach/hurd
+
+$(hurd)/errnos.h: $(objpfx)stamp-errnos ;
+$(objpfx)stamp-errnos: $(hurd)/errnos.awk $(errno.texinfo) \
+ $(mach-srcdir)/mach/message.h \
+ $(mach-srcdir)/mach/kern_return.h \
+ $(mach-srcdir)/mach/mig_errors.h \
+ $(mach-srcdir)/device/device_types.h
+ gawk -f $^ > $(hurd)/errnos.h-tmp
+# Make it unwritable so noone will edit it by mistake.
+ -chmod a-w $(hurd)/errnos.h-tmp
+ ./$(..)move-if-change $(hurd)/errnos.h-tmp $(hurd)/errnos.h
+ test -d CVS && cvs commit -m'Regenerated from $^' $@
+ touch $@
+
+$(hurd)/errlist.c: $(hurd)/errlist.awk $(errno.texinfo)
+ gawk -f $^ > $@-tmp
+# Make it unwritable so noone will edit it by mistake.
+ -chmod a-w $@-tmp
+ mv -f $@-tmp $@
+ test -d CVS && cvs commit -m'Regenerated from $^' $@
+
+# We install the real libc.a as libcrt.a and as libc.a we install a linker
+# script which does -( -lcrt -lmachuser -lhurduser -).
+
+libc-name = crt
+
+ifeq (,$(subdir))
+install-others += $(libdir)/libc.a
+$(libdir)/libc.a: $(hurd)/libc-ldscript; $(do-install)
+endif
+
+
+endif # in-Makerules
diff --git a/sysdeps/mach/hurd/Subdirs b/sysdeps/mach/hurd/Subdirs
new file mode 100644
index 0000000..16b8348
--- /dev/null
+++ b/sysdeps/mach/hurd/Subdirs
@@ -0,0 +1 @@
+hurd
diff --git a/sysdeps/mach/hurd/_exit.c b/sysdeps/mach/hurd/_exit.c
new file mode 100644
index 0000000..fd56791
--- /dev/null
+++ b/sysdeps/mach/hurd/_exit.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/port.h>
+#include <sysdep.h>
+#include <sys/wait.h>
+
+void
+_hurd_exit (int status)
+{
+ /* Give the proc server our exit status. */
+ __USEPORT (PROC, __proc_mark_exit (port, status));
+
+ /* Commit suicide. */
+ __task_terminate (__mach_task_self ());
+
+ /* Perhaps the cached mach_task_self was bogus. */
+ __task_terminate ((__mach_task_self) ());
+
+ /* This sucker really doesn't want to die. */
+ while (1)
+ {
+#ifdef LOSE
+ LOSE;
+#else
+ volatile const int zero = 0, one = 1;
+ volatile int lossage = one / zero;
+#endif
+ }
+}
+
+void
+DEFUN(_exit, (status), int status)
+{
+ _hurd_exit (W_EXITCODE (status, 0));
+}
diff --git a/sysdeps/mach/hurd/accept.c b/sysdeps/mach/hurd/accept.c
new file mode 100644
index 0000000..48402b1
--- /dev/null
+++ b/sysdeps/mach/hurd/accept.c
@@ -0,0 +1,71 @@
+/* Copyright (C) 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <sys/socket.h>
+#include <hurd/socket.h>
+#include <fcntl.h>
+#include <string.h>
+
+/* Await a connection on socket FD.
+ When a connection arrives, open a new socket to communicate with it,
+ set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting
+ peer and *ADDR_LEN to the address's actual length, and return the
+ new socket's descriptor, or -1 for errors. */
+int
+DEFUN(accept, (fd, addr, addr_len),
+ int fd AND struct sockaddr *addr AND size_t *addr_len)
+{
+ error_t err;
+ socket_t new;
+ addr_port_t aport;
+ char *buf = (char *) addr;
+ mach_msg_type_number_t buflen = *addr_len;
+ int type;
+
+ if (err = HURD_DPORT_USE (fd, __socket_accept (port, &new, &aport)))
+ return __hurd_dfail (fd, err);
+
+ if (addr != NULL)
+ err = __socket_whatis_address (aport, &type, &buf, &buflen);
+ __mach_port_deallocate (__mach_task_self (), aport);
+
+ if (err)
+ {
+ __mach_port_deallocate (__mach_task_self (), new);
+ return __hurd_dfail (fd, err);
+ }
+
+ if (addr != NULL)
+ {
+ if (buf != (char *) addr)
+ {
+ if (*addr_len < buflen)
+ *addr_len = buflen;
+ memcpy (addr, buf, *addr_len);
+ __vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
+ }
+
+ addr->sa_family = type;
+ }
+
+ return _hurd_intern_fd (new, O_IGNORE_CTTY, 1);
+}
diff --git a/sysdeps/mach/hurd/access.c b/sysdeps/mach/hurd/access.c
new file mode 100644
index 0000000..9093806
--- /dev/null
+++ b/sysdeps/mach/hurd/access.c
@@ -0,0 +1,138 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/port.h>
+#include <hurd/id.h>
+#include <fcntl.h>
+
+/* Test for access to FILE by our real user and group IDs. */
+int
+DEFUN(__access, (file, type), CONST char *file AND int type)
+{
+ error_t err;
+ file_t crdir, cwdir, rcrdir, rcwdir, io;
+ struct hurd_userlink crdir_ulink, cwdir_ulink;
+ int flags, allowed;
+ mach_port_t ref;
+
+ HURD_CRITICAL_BEGIN;
+
+ __mutex_lock (&_hurd_id.lock);
+ /* Get _hurd_id up to date. */
+ if (err = _hurd_check_ids ())
+ goto lose;
+
+ if (_hurd_id.rid_auth == MACH_PORT_NULL)
+ {
+ /* Set up _hurd_id.rid_auth. This is a special auth server port
+ which uses the real uid and gid (the first aux uid and gid) as
+ the only effective uid and gid. */
+
+ if (_hurd_id.aux.nuids < 1 || _hurd_id.aux.ngids < 1)
+ {
+ /* We do not have a real UID and GID. Lose, lose, lose! */
+ err = EGRATUITOUS;
+ goto lose;
+ }
+
+ /* Create a new auth port using our real UID and GID (the first
+ auxiliary UID and GID) as the only effective IDs. */
+ if (err = __USEPORT (AUTH,
+ __auth_makeauth (port,
+ NULL, MACH_MSG_TYPE_COPY_SEND, 0,
+ _hurd_id.aux.uids, 1,
+ _hurd_id.aux.gids, 1,
+ _hurd_id.aux.uids,
+ _hurd_id.aux.nuids,
+ _hurd_id.aux.gids,
+ _hurd_id.aux.ngids,
+ &_hurd_id.rid_auth)))
+ goto lose;
+ }
+
+ /* Get a port to our root directory, authenticated with the real IDs. */
+ crdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink);
+ ref = __mach_reply_port ();
+ err = __io_reauthenticate (crdir, ref, MACH_MSG_TYPE_MAKE_SEND);
+ if (!err)
+ err = __auth_user_authenticate (_hurd_id.rid_auth,
+ crdir,
+ ref, MACH_MSG_TYPE_MAKE_SEND,
+ &rcrdir);
+ _hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir);
+ __mach_port_destroy (__mach_task_self (), ref);
+
+ if (!err)
+ {
+ /* Get a port to our current working directory, authenticated with
+ the real IDs. */
+ cwdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink);
+ ref = __mach_reply_port ();
+ err = __io_reauthenticate (cwdir, ref, MACH_MSG_TYPE_MAKE_SEND);
+ if (!err)
+ err = __auth_user_authenticate (_hurd_id.rid_auth,
+ cwdir,
+ ref, MACH_MSG_TYPE_MAKE_SEND,
+ &rcwdir);
+ _hurd_port_free (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink, cwdir);
+ __mach_port_destroy (__mach_task_self (), ref);
+ }
+
+ /* We are done with _hurd_id.rid_auth now. */
+ lose:
+ __mutex_unlock (&_hurd_id.lock);
+
+ HURD_CRITICAL_END;
+
+ if (err)
+ return __hurd_fail (err);
+
+ /* Now do a path lookup on FILE, using the crdir and cwdir
+ reauthenticated with _hurd_id.rid_auth. */
+
+ err = __hurd_file_name_lookup (rcrdir, rcwdir, file, 0, 0, &io);
+ __mach_port_deallocate (__mach_task_self (), rcrdir);
+ __mach_port_deallocate (__mach_task_self (), rcwdir);
+ if (err)
+ return __hurd_fail (err);
+
+ /* Find out what types of access we are allowed to this file. */
+ err = __file_check_access (io, &allowed);
+ __mach_port_deallocate (__mach_task_self (), io);
+ if (err)
+ return __hurd_fail (err);
+
+ flags = 0;
+ if (type & R_OK)
+ flags |= O_READ;
+ if (type & W_OK)
+ flags |= O_WRITE;
+ if (type & X_OK)
+ flags |= O_EXEC;
+
+ if (flags & ~allowed)
+ /* We are not allowed all the requested types of access. */
+ return __hurd_fail (EACCES);
+
+ return 0;
+}
+
+weak_alias (__access, access)
diff --git a/sysdeps/mach/hurd/adjtime.c b/sysdeps/mach/hurd/adjtime.c
new file mode 100644
index 0000000..d88f404
--- /dev/null
+++ b/sysdeps/mach/hurd/adjtime.c
@@ -0,0 +1,53 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <hurd.h>
+
+/* Adjust the current time of day by the amount in DELTA.
+ If OLDDELTA is not NULL, it is filled in with the amount
+ of time adjustment remaining to be done from the last `__adjtime' call.
+ This call is restricted to the super-user. */
+int
+DEFUN(__adjtime, (delta, olddelta),
+ CONST struct timeval *delta AND
+ struct timeval *olddelta)
+{
+ error_t err;
+ mach_port_t hostpriv, devmaster;
+
+ if (err = __USEPORT (PROC, __proc_getprivports (port,
+ &hostpriv, &devmaster)))
+ return __hurd_fail (err);
+ __mach_port_deallocate (__mach_task_self (), devmaster);
+
+ err = __host_adjust_time (hostpriv,
+ /* `time_value_t' and `struct timeval' are in
+ fact identical with the names changed. */
+ *(time_value_t *) delta,
+ (time_value_t *) olddelta);
+ __mach_port_deallocate (__mach_task_self (), hostpriv);
+
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+
+weak_alias (__adjtime, adjtime)
diff --git a/sysdeps/mach/hurd/alpha/exc2signal.c b/sysdeps/mach/hurd/alpha/exc2signal.c
new file mode 100644
index 0000000..edac0aa
--- /dev/null
+++ b/sysdeps/mach/hurd/alpha/exc2signal.c
@@ -0,0 +1,76 @@
+/* Translate Mach exception codes into signal numbers. Alpha 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. */
+
+#include <hurd.h>
+#include <hurd/signal.h>
+#include <mach/exception.h>
+
+/* Translate the Mach exception codes, as received in an `exception_raise' RPC,
+ into a signal number and signal subcode. */
+
+void
+_hurd_exception2signal (int exception, int code, int subcode,
+ int *signo, long int *sigcode, int *error)
+{
+ *error = 0;
+
+ switch (exception)
+ {
+ default:
+ *signo = SIGIOT;
+ *sigcode = exception;
+ break;
+
+ case EXC_BAD_ACCESS:
+ if (code == KERN_PROTECTION_FAILURE)
+ *signo = SIGSEGV;
+ else
+ *signo = SIGBUS;
+ *sigcode = subcode;
+ *error = code;
+ break;
+
+ case EXC_BAD_INSTRUCTION:
+ *signo = SIGILL;
+ *sigcode = code;
+ break;
+
+ case EXC_ARITHMETIC:
+ *signo = SIGFPE;
+ *sigcode = code;
+ break;
+ break;
+
+ case EXC_EMULATION:
+ /* 3.0 doesn't give this one, why, I don't know. */
+ *signo = SIGEMT;
+ *sigcode = code;
+ break;
+
+ case EXC_SOFTWARE:
+ *signo = SIGEMT;
+ *sigcode = code;
+ break;
+
+ case EXC_BREAKPOINT:
+ *signo = SIGTRAP;
+ *sigcode = code;
+ break;
+ }
+}
diff --git a/sysdeps/mach/hurd/alpha/longjmp-ctx.c b/sysdeps/mach/hurd/alpha/longjmp-ctx.c
new file mode 100644
index 0000000..dfc16fd
--- /dev/null
+++ b/sysdeps/mach/hurd/alpha/longjmp-ctx.c
@@ -0,0 +1,38 @@
+/* Perform a `longjmp' on a `struct sigcontext'. Alpha 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. */
+
+#include <setjmp.h>
+#include <hurd/signal.h>
+#include <string.h>
+
+void
+_hurd_longjmp_sigcontext (struct sigcontext *scp, jmp_buf env, int retval)
+{
+ memset (scp, 0, sizeof (*scp));
+ scp->sc_regs[9] = env[0].__9;
+ scp->sc_regs[11] = env[0].__11;
+ scp->sc_regs[12] = env[0].__12;
+ scp->sc_regs[13] = env[0].__13;
+ scp->sc_regs[14] = env[0].__14;
+ scp->sc_regs[15] = (long int) env[0].__fp;
+ scp->sc_regs[30] = (long int) env[0].__sp;
+ scp->sc_pc = (long int) env[0].__pc;
+
+ memcpy (&scp->sc_fpregs[2], &env[0].__f2, sizeof (double));
+}
diff --git a/sysdeps/mach/hurd/alpha/longjmp-ts.c b/sysdeps/mach/hurd/alpha/longjmp-ts.c
new file mode 100644
index 0000000..ad6f80c
--- /dev/null
+++ b/sysdeps/mach/hurd/alpha/longjmp-ts.c
@@ -0,0 +1,41 @@
+/* Perform a `longjmp' on a Mach thread_state. Alpha 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. */
+
+#include <hurd/signal.h>
+#include <setjmp.h>
+#include <mach/thread_status.h>
+
+
+/* Set up STATE to do the equivalent of `longjmp (ENV, VAL);'. */
+
+void
+_hurd_longjmp_thread_state (void *state, jmp_buf env, int val)
+{
+ struct alpha_thread_state *ts = state;
+
+ ts->r9 = env[0].__jmpbuf[0].__9;
+ ts->r11 = env[0].__jmpbuf[0].__11;
+ ts->r12 = env[0].__jmpbuf[0].__12;
+ ts->r13 = env[0].__jmpbuf[0].__13;
+ ts->r14 = env[0].__jmpbuf[0].__14;
+ ts->r15 = (long int) env[0].__jmpbuf[0].__fp;
+ ts->r30 = (long int) env[0].__jmpbuf[0].__sp;
+ ts->pc = (long int) env[0].__jmpbuf[0].__pc;
+ ts->r0 = val ?: 1;
+}
diff --git a/sysdeps/mach/hurd/alpha/sigcontext.h b/sysdeps/mach/hurd/alpha/sigcontext.h
new file mode 100644
index 0000000..32e0c94
--- /dev/null
+++ b/sysdeps/mach/hurd/alpha/sigcontext.h
@@ -0,0 +1,65 @@
+/* Machine-dependent signal context structure for GNU Hurd. Alpha 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. */
+
+/* Signal handlers are actually called:
+ void handler (int sig, int code, struct sigcontext *scp); */
+
+/* State of this thread when the signal was taken. */
+struct sigcontext
+ {
+ /* These first members are machine-independent. */
+
+ long int sc_onstack; /* Nonzero if running on sigstack. */
+ __sigset_t sc_mask; /* Blocked signals to restore. */
+
+ /* MiG reply port this thread is using. */
+ unsigned long int sc_reply_port;
+
+ /* Port this thread is doing an interruptible RPC on. */
+ unsigned long int sc_intr_port;
+
+ /* Error code associated with this signal (interpreted as `error_t'). */
+ int sc_error;
+
+ /* All following members are machine-dependent. The rest of this
+ structure is written to be laid out identically to:
+ {
+ struct alpha_thread_state basic;
+ struct alpha_exc_state exc;
+ struct alpha_float_state fpu;
+ }
+ trampoline.c knows this, so it must be changed if this changes. */
+
+#define sc_alpha_thread_state sc_regs /* Beginning of correspondence. */
+ long int sc_regs[31]; /* General registers $0..$30. */
+ long int sc_pc; /* Program counter. */
+
+ /* struct alpha_exc_state */
+#define sc_alpha_exc_state sc_badvaddr
+ unsigned long int sc_badvaddr;
+ unsigned int sc_cause; /* Machine-level trap code. */
+#define SC_CAUSE_SET_SSTEP 1
+ int sc_used_fpa; /* Nonzero if FPU was used. */
+
+ /* struct alpha_float_state
+ This is only filled in if sc_used_fpa is nonzero. */
+#define sc_alpha_float_state sc_fpregs
+ double sc_fpregs[31]; /* Floating point registers $f0..$f30. */
+ long int sc_fpcsr; /* Floating point control/status register. */
+ };
diff --git a/sysdeps/mach/hurd/alpha/sigreturn.c b/sysdeps/mach/hurd/alpha/sigreturn.c
new file mode 100644
index 0000000..e5dc383
--- /dev/null
+++ b/sysdeps/mach/hurd/alpha/sigreturn.c
@@ -0,0 +1,212 @@
+/* Return from signal handler in GNU C library for Hurd. Alpha version.
+Copyright (C) 1994, 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. */
+
+#include <hurd.h>
+#include <hurd/signal.h>
+#include <hurd/threadvar.h>
+#include <hurd/msg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mach/machine/alpha_instruction.h>
+
+int
+__sigreturn (struct sigcontext *scp)
+{
+ struct hurd_sigstate *ss;
+ mach_port_t *reply_port;
+
+ if (scp == NULL || (scp->sc_mask & _SIG_CANT_MASK))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ss = _hurd_self_sigstate ();
+ __spin_lock (&ss->lock);
+
+ /* Restore the set of blocked signals, and the intr_port slot. */
+ ss->blocked = scp->sc_mask;
+ ss->intr_port = scp->sc_intr_port;
+
+ /* Check for pending signals that were blocked by the old set. */
+ if (ss->pending & ~ss->blocked)
+ {
+ /* There are pending signals that just became unblocked. Wake up the
+ signal thread to deliver them. But first, squirrel away SCP where
+ 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 ());
+ /* If a pending signal was handled, sig_post never returned. */
+ __spin_lock (&ss->lock);
+ }
+
+ if (scp->sc_onstack)
+ {
+ ss->sigaltstack.ss_flags &= ~SA_ONSTACK; /* XXX threadvars */
+ /* XXX cannot unlock until off sigstack */
+ abort ();
+ }
+ else
+ __spin_unlock (&ss->lock);
+
+ /* Destroy the MiG reply port used by the signal handler, and restore the
+ reply port in use by the thread when interrupted. */
+ reply_port =
+ (mach_port_t *) __hurd_threadvar_location (_HURD_THREADVAR_MIG_REPLY);
+ if (*reply_port)
+ __mach_port_destroy (__mach_task_self (), *reply_port);
+ *reply_port = scp->sc_reply_port;
+
+ if (scp->sc_used_fpa)
+ {
+ /* Restore FPU state. */
+
+ /* Restore the floating-point control/status register.
+ We must do this first because the compiler will need
+ a temporary FP register for the load. */
+ asm volatile ("mt_fpcr %0" : : "f" (scp->sc_fpcsr));
+
+ /* Restore floating-point registers. */
+#define restore_fpr(n) \
+ asm volatile ("ldt $f" #n ",%0" : : "m" (scp->sc_fpregs[n]))
+ 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);
+ }
+
+ /* Load all the registers from the sigcontext. */
+#define restore_gpr(n) \
+ asm volatile ("ldq $" #n ",%0" : : "m" (scpreg->sc_regs[n]))
+
+ {
+ /* The `rei' PAL pseudo-instruction restores registers $2..$7, the PC
+ and processor status. So we can use these few registers for our
+ working variables. Unfortunately, it finds its data on the stack
+ and merely pops the SP ($30) over the words of state restored,
+ allowing no other option for the new SP value. So we must push the
+ registers and PSW it will to restore, onto the user's stack and let
+ it pop them from there. */
+ register const struct sigcontext *const scpreg asm ("$2") = scp;
+ register integer_t *usp asm ("$3") = (integer_t *) scpreg->sc_regs[30];
+ register integer_t usp_align asm ("$4");
+
+ /* Push an 8-word "trap frame" onto the user stack for `rei':
+ registers $2..$7, the PC, and the PSW. */
+
+ register struct rei_frame
+ {
+ integer_t regs[5], pc, ps;
+ } *rei_frame asm ("$5");
+
+ usp -= 8;
+ /* `rei' demands that the stack be aligned to a 64 byte (8 word)
+ boundary; bits 61..56 of the PSW are OR'd back into the SP value
+ after popping the 8-word trap frame, so we store (sp % 64)
+ there and this restores the original user SP. */
+ usp_align = (integer_t) usp & 63L;
+ rei_frame = (void *) ((integer_t) usp & ~63L);
+
+ /* Copy the registers and PC from the sigcontext. */
+ memcpy (rei_frame->regs, &scpreg->sc_regs[2], sizeof rei_frame->regs);
+ rei_frame->pc = scpreg->sc_pc;
+
+ /* Compute the new PS value to be restored. `rei' adds the value at
+ bits 61..56 to the SP to compensate for the alignment above that
+ cleared the low 6 bits; bits 5..3 are the new mode/privilege level
+ (must be >= current mode; 3 == user mode); bits 2..0 are "software",
+ unused by the processor or kernel (XXX should trampoline save these?
+ How?); in user mode, `rei' demands that all other bits be zero. */
+ rei_frame->ps = (usp_align << 56) | (3 << 3); /* XXX low 3 bits??? */
+
+ /* Restore the other general registers: everything except $2..$7, which
+ are in the `rei' trap frame we set up above, and $30, which is the
+ SP which is popped by `rei'. */
+ restore_gpr (1);
+ restore_gpr (8);
+ restore_gpr (9);
+ restore_gpr (10);
+ restore_gpr (11);
+ restore_gpr (12);
+ restore_gpr (13);
+ restore_gpr (14);
+ restore_gpr (15);
+ restore_gpr (16);
+ restore_gpr (17);
+ restore_gpr (18);
+ restore_gpr (19);
+ restore_gpr (20);
+ restore_gpr (21);
+ restore_gpr (22);
+ restore_gpr (23);
+ restore_gpr (24);
+ restore_gpr (25);
+ restore_gpr (26);
+ restore_gpr (27);
+ restore_gpr (28);
+ restore_gpr (29);
+
+ /* Switch the stack pointer to the trap frame set up on
+ the user stack and do the magical `rei' PAL call. */
+ asm volatile ("mov %0, $30\n"
+ "call_pal %1"
+ : : "r" (rei_frame), "i" (op_rei));
+ /* Firewall. */
+ asm volatile ("call_pal %0" : : "i" (op_halt));
+ }
+
+ /* NOTREACHED */
+ return -1;
+}
+
+weak_alias (__sigreturn, sigreturn)
diff --git a/sysdeps/mach/hurd/alpha/trampoline.c b/sysdeps/mach/hurd/alpha/trampoline.c
new file mode 100644
index 0000000..85f4964
--- /dev/null
+++ b/sysdeps/mach/hurd/alpha/trampoline.c
@@ -0,0 +1,286 @@
+/* Set thread_state for sighandler, and sigcontext to recover. Alpha 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. */
+
+#include <hurd/signal.h>
+#include "thread_state.h"
+#include <mach/machine/alpha_instruction.h>
+#include "hurdfault.h"
+#include <assert.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;
+ };
+
+
+struct sigcontext *
+_hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
+ int signo, long int sigcode,
+ int rpc_wait,
+ struct machine_thread_all_state *state)
+{
+ __label__ trampoline, rpc_wait_trampoline;
+ void *sigsp;
+ struct sigcontext *scp;
+
+ 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 (_hurdsig_catch_fault (SIGSEGV))
+ assert (_hurdsig_fault_sigcode >= (long int) ss->context &&
+ _hurdsig_fault_sigcode < (long int) (ss->context + 1));
+ else
+ {
+ memcpy (&state->basic, &ss->context->sc_alpha_thread_state,
+ sizeof (state->basic));
+ memcpy (&state->exc, &ss->context->sc_alpha_exc_state,
+ sizeof (state->exc));
+ state->set = (1 << ALPHA_THREAD_STATE) | (1 << ALPHA_EXC_STATE);
+ if (state->exc.used_fpa)
+ {
+ memcpy (&state->fpu, &ss->context->sc_alpha_float_state,
+ sizeof (state->fpu));
+ state->set |= (1 << ALPHA_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))
+ return NULL;
+
+ if ((ss->actions[signo].sa_flags & SA_ONSTACK) &&
+ !(ss->sigaltstack.ss_flags & (SA_DISABLE|SA_ONSTACK)))
+ {
+ sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size;
+ ss->sigaltstack.ss_flags |= SA_ONSTACK;
+ /* XXX need to set up base of new stack for
+ per-thread variables, cthreads. */
+ }
+ else
+ sigsp = (char *) state->basic.SP;
+
+ /* 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;
+
+ if (_hurdsig_catch_fault (SIGSEGV))
+ {
+ assert (_hurdsig_fault_sigcode >= (long int) scp &&
+ _hurdsig_fault_sigcode < (long int) (scp + 1));
+ /* 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
+ {
+ /* Set up the sigcontext from the current state of the thread. */
+
+ scp->sc_onstack = ss->sigaltstack.ss_flags & SA_ONSTACK ? 1 : 0;
+
+ /* struct sigcontext is laid out so that starting at sc_regs
+ mimics a struct alpha_thread_state. */
+ memcpy (&scp->sc_alpha_thread_state,
+ &state->basic, sizeof (state->basic));
+
+ /* struct sigcontext is laid out so that starting at sc_badvaddr
+ mimics a struct mips_exc_state. */
+ if (! machine_get_state (ss->thread, state, ALPHA_EXC_STATE,
+ &state->exc, &scp->sc_alpha_exc_state,
+ sizeof (state->exc)))
+ return NULL;
+
+ if (state->exc.used_fpa &&
+ /* struct sigcontext is laid out so that starting at sc_fpregs
+ mimics a struct alpha_float_state. This state
+ is only meaningful if the coprocessor was used. */
+ ! machine_get_state (ss->thread, state, ALPHA_FLOAT_STATE,
+ &state->fpu,
+ &scp->sc_alpha_float_state,
+ sizeof (state->fpu)))
+ return NULL;
+ }
+
+ /* Modify the thread state to call the trampoline code on the new stack. */
+ if (rpc_wait)
+ {
+ /* The signalee thread was blocked in a mach_msg_trap system call,
+ still waiting for a reply. We will have it run the special
+ trampoline code which retries the message receive before running
+ the signal handler.
+
+ To do this we change the OPTION argument in its registers to
+ enable only message reception, since the request message has
+ already been sent. */
+
+ /* The system call arguments are stored in consecutive registers
+ starting with a0 ($16). */
+ struct mach_msg_trap_args *args = (void *) &state->basic.r16;
+
+ 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. */
+ args->option &= ~MACH_SEND_MSG;
+
+ state->basic.pc = (long int) &&rpc_wait_trampoline;
+ /* After doing the message receive, the trampoline code will need to
+ update the v0 ($0) 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 at ($28). */
+ state->basic.r28 = (long int) &scp->sc_regs[0];
+ /* We must preserve the mach_msg_trap args in a0..a5 and t0
+ ($16..$21, $1). Pass the handler args to the trampoline code in
+ t8..t10 ($22.$24). */
+ state->basic.r22 = signo;
+ state->basic.r23 = sigcode;
+ state->basic.r24 = (long int) scp;
+ }
+ else
+ {
+ state->basic.pc = (long int) &&trampoline;
+ state->basic.r16 = signo;
+ state->basic.r17 = sigcode;
+ state->basic.r18 = (long int) scp;
+ }
+
+ state->basic.r30 = (long int) sigsp; /* $30 is the stack pointer. */
+
+ /* We pass the handler function to the trampoline code in ra ($26). */
+ state->basic.r26 = (long int) handler;
+ /* In the callee-saved register t12/pv ($27), we store the
+ address of __sigreturn itself, for the trampoline code to use. */
+ state->basic.r27 = (long int) &__sigreturn;
+ /* In the callee-saved register t11/ai ($25), we save the SCP value to pass
+ to __sigreturn after the handler returns. */
+ state->basic.r25 = (long int) scp;
+
+ return scp;
+
+ /* The trampoline code follows. This is not actually executed as part of
+ this function, it is just convenient to write it that way. */
+
+ rpc_wait_trampoline:
+ /* This is the entry point when we have an RPC reply message to receive
+ before running the handler. The MACH_MSG_SEND bit has already been
+ cleared in the OPTION argument in our registers. For our convenience,
+ at ($28) points to the sc_regs[0] member of the sigcontext (saved v0
+ ($0)). */
+ asm volatile
+ (/* Retry the interrupted mach_msg system call. */
+ "lda $0, -25($31)\n" /* mach_msg_trap */
+ "call_pal %0\n" /* Magic system call instruction. */
+ /* 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_regs[0] member of the sigcontext
+ (whose address is in at to make this code simpler). */
+ "stq $0, 0($28)\n"
+ /* Since the argument registers needed to have the mach_msg_trap
+ arguments, we've stored the arguments to the handler function
+ in registers t8..t10 ($22..$24). */
+ "mov $22, $16\n"
+ "mov $23, $17\n"
+ "mov $24, $18\n"
+ : : "i" (op_chmk));
+
+ trampoline:
+ /* Entry point for running the handler normally. The arguments to the
+ handler function are already in the standard registers:
+
+ a0 SIGNO
+ a1 SIGCODE
+ a2 SCP
+
+ t12 also contains SCP; this value is callee-saved (and so should not get
+ clobbered by running the handler). We use this saved value to pass to
+ __sigreturn, so the handler can clobber the argument registers if it
+ likes. */
+ /* Call the handler function, saving return address in ra ($26). */
+ asm volatile ("jsr $26, ($26)");
+ /* Reset gp ($29) from the return address (here) in ra ($26). */
+ asm volatile ("ldgp $29, 0($26)");
+ asm volatile ("mov $25, $16"); /* Move saved SCP to argument register. */
+ /* Call __sigreturn (SCP); this cannot return. */
+ asm volatile ("jmp $31, ($27)");
+
+ /* NOTREACHED */
+ return NULL;
+}
+
+/* STATE describes a thread that had intr_port set (meaning it was inside
+ HURD_EINTR_RPC), after it has been thread_abort'd. If it looks to have
+ just completed a mach_msg_trap system call that returned
+ MACH_RCV_INTERRUPTED, return nonzero and set *PORT to the receive right
+ being waited on. */
+int
+_hurdsig_rcv_interrupted_p (struct machine_thread_all_state *state,
+ mach_port_t *port)
+{
+ if (state->basic.r0 == MACH_RCV_INTERRUPTED)
+ {
+ const unsigned int *pc = (void *) state->basic.pc;
+ struct mach_msg_trap_args *args = (void *) &state->basic.r16;
+
+ if (_hurdsig_catch_fault (SIGSEGV))
+ {
+ assert (_hurdsig_fault_sigcode == (long int) (pc - 1) ||
+ _hurdsig_fault_sigcode == (long int) &args->rcv_name);
+ /* We got a fault trying to read the PC or stack. */
+ return 0;
+ }
+ else
+ {
+ if (pc[-1] == ((alpha_instruction) { pal_format:
+ { opcode: op_pal,
+ function: op_chmk } }).bits)
+ {
+ /* We did just return from a mach_msg_trap system call
+ doing a message receive that was interrupted.
+ Examine the parameters to find the receive right. */
+ *port = args->rcv_name;
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/bind.c b/sysdeps/mach/hurd/bind.c
new file mode 100644
index 0000000..e9e54ec
--- /dev/null
+++ b/sysdeps/mach/hurd/bind.c
@@ -0,0 +1,102 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <hurd/socket.h>
+#include <hurd/paths.h>
+#include <fcntl.h>
+#include <stddef.h>
+#include <hurd/ifsock.h>
+#include <sys/un.h>
+#include <string.h>
+
+/* Give the socket FD the local address ADDR (which is LEN bytes long). */
+int
+DEFUN(bind, (fd, addr, len),
+ int fd AND struct sockaddr *addr AND size_t len)
+{
+ addr_port_t aport;
+ error_t err;
+
+ if (addr->sa_family == AF_LOCAL)
+ {
+ /* For the local domain, we must create a node in the filesystem
+ using the ifsock translator and then fetch the address from it. */
+ struct sockaddr_un *unaddr = (struct sockaddr_un *) addr;
+ file_t dir, node;
+ char name[len - offsetof (struct sockaddr_un, sun_path)], *n;
+ strncpy (name, unaddr->sun_path, sizeof name);
+ dir = __file_name_split (name, &n);
+ if (dir == MACH_PORT_NULL)
+ return -1;
+
+ /* Create a new, unlinked node in the target directory. */
+ err = __dir_mkfile (dir, O_CREAT, 0666 & ~_hurd_umask, &node);
+
+ if (! err)
+ {
+ file_t ifsock;
+ /* Set the node's translator to make it a local-domain socket. */
+ err = __file_set_translator (node,
+ FS_TRANS_EXCL | FS_TRANS_SET,
+ FS_TRANS_EXCL | FS_TRANS_SET, 0,
+ _HURD_IFSOCK, sizeof _HURD_IFSOCK,
+ MACH_PORT_NULL,
+ MACH_MSG_TYPE_COPY_SEND);
+ if (! err)
+ /* Get a port to the ifsock translator. */
+ err = __hurd_invoke_translator (node, 0, &ifsock);
+ if (! err)
+ /* Get the address port. */
+ err = __ifsock_getsockaddr (ifsock, &aport);
+ __mach_port_deallocate (__mach_task_self (), ifsock);
+ if (! err)
+ /* Link the node, now a socket, into the target directory. */
+ err = __dir_link (node, dir, name);
+ __mach_port_deallocate (__mach_task_self (), node);
+ }
+ __mach_port_deallocate (__mach_task_self (), dir);
+
+ if (err)
+ return __hurd_fail (err);
+ }
+ else
+ err = EIEIO;
+
+ err = HURD_DPORT_USE (fd,
+ ({
+ if (err)
+ err = __socket_create_address (port,
+ addr->sa_family,
+ (char *) addr, len,
+ &aport, 1);
+ if (! err)
+ {
+ err = __socket_bind (port, aport);
+ __mach_port_deallocate (__mach_task_self (),
+ aport);
+ }
+ err;
+ }));
+
+ return err ? __hurd_dfail (fd, err) : 0;
+}
diff --git a/sysdeps/mach/hurd/brk.c b/sysdeps/mach/hurd/brk.c
new file mode 100644
index 0000000..a96286b
--- /dev/null
+++ b/sysdeps/mach/hurd/brk.c
@@ -0,0 +1,130 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <hurd.h>
+#include <hurd/resource.h>
+#include <cthreads.h> /* For `struct mutex'. */
+
+
+/* Initial maximum size of the data segment (32MB, which is arbitrary). */
+#define DATA_SIZE (32 * 1024 * 1024)
+
+
+/* Up to the page including this address is allocated from the kernel.
+ This address is the data resource limit. */
+vm_address_t _hurd_data_end;
+
+/* Up to this address is actually available to the user.
+ Pages beyond the one containing this address allow no access. */
+vm_address_t _hurd_brk;
+
+struct mutex _hurd_brk_lock;
+
+extern int __data_start, _end;
+
+
+/* Set the end of the process's data space to INADDR.
+ Return 0 if successful, -1 if not. */
+int
+DEFUN(__brk, (inaddr), PTR inaddr)
+{
+ int ret;
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_brk_lock);
+ ret = _hurd_set_brk ((vm_address_t) inaddr);
+ __mutex_unlock (&_hurd_brk_lock);
+ HURD_CRITICAL_END;
+ return ret;
+}
+weak_alias (__brk, brk)
+
+
+int
+_hurd_set_brk (vm_address_t addr)
+{
+ error_t err;
+ vm_address_t pagend = round_page (addr);
+ vm_address_t pagebrk = round_page (_hurd_brk);
+ long int rlimit;
+
+ if (pagend <= pagebrk)
+ {
+ if (pagend < pagebrk)
+ /* Make that memory inaccessible. */
+ __vm_protect (__mach_task_self (), pagend, pagebrk - pagend,
+ 0, VM_PROT_NONE);
+ _hurd_brk = addr;
+ return 0;
+ }
+
+ __mutex_lock (&_hurd_rlimit_lock);
+ rlimit = _hurd_rlimits[RLIMIT_DATA].rlim_cur;
+ __mutex_unlock (&_hurd_rlimit_lock);
+
+ if (addr - (vm_address_t) &__data_start > rlimit)
+ {
+ /* Need to increase the resource limit. */
+ errno = ENOMEM;
+ return -1;
+ }
+
+ /* Make the memory accessible. */
+ if (err = __vm_protect (__mach_task_self (), pagebrk, pagend - pagebrk,
+ 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE))
+ {
+ errno = err;
+ return -1;
+ }
+
+ _hurd_brk = addr;
+ return 0;
+}
+
+static void
+init_brk (void)
+{
+ vm_address_t pagend;
+
+ __mutex_init (&_hurd_brk_lock);
+
+ /* If _hurd_brk is already set, don't change it. The assumption is that
+ it was set in a previous run before something like Emacs's unexec was
+ called and dumped all the data up to the break at that point. */
+ if (_hurd_brk == 0)
+ _hurd_brk = (vm_address_t) &_end;
+
+ pagend = round_page (_hurd_brk);
+
+ _hurd_data_end = (vm_address_t) &__data_start + DATA_SIZE;
+
+ if (pagend < _hurd_data_end)
+ {
+ /* We use vm_map to allocate and change permissions atomically. */
+ if (__vm_map (__mach_task_self (), &pagend, _hurd_data_end - pagend,
+ 0, 0, MACH_PORT_NULL, 0, 0,
+ 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE,
+ VM_INHERIT_COPY))
+ /* Couldn't allocate the memory. The break will be very short. */
+ _hurd_data_end = pagend;
+ }
+
+ (void) &init_brk; /* Avoid ``defined but not used'' warning. */
+}
+text_set_element (_hurd_preinit_hook, init_brk);
diff --git a/sysdeps/mach/hurd/chdir.c b/sysdeps/mach/hurd/chdir.c
new file mode 100644
index 0000000..912ca08
--- /dev/null
+++ b/sysdeps/mach/hurd/chdir.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <fcntl.h>
+#include <hurd/port.h>
+
+/* Change the current directory to FILE_NAME. */
+int
+DEFUN(__chdir, (file_name), CONST char *file_name)
+{
+ file_t file, dir;
+ error_t err;
+
+ file = __file_name_lookup (file_name, O_EXEC, 0);
+ if (file == MACH_PORT_NULL)
+ return -1;
+ err = __USEPORT (CRDIR, __hurd_file_name_lookup (port, file, "",
+ O_EXEC, 0, &dir));
+ __mach_port_deallocate (__mach_task_self (), file);
+ if (err)
+ return __hurd_fail (err);
+
+ _hurd_port_set (&_hurd_ports[INIT_PORT_CWDIR], dir);
+ return 0;
+}
+
+weak_alias (__chdir, chdir)
diff --git a/sysdeps/mach/hurd/chflags.c b/sysdeps/mach/hurd/chflags.c
new file mode 100644
index 0000000..157940d1
--- /dev/null
+++ b/sysdeps/mach/hurd/chflags.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <hurd.h>
+
+/* Change the flags of FILE to FLAGS. */
+int
+DEFUN(chflags, (file, flags), CONST char *file AND int flags)
+{
+ error_t err;
+ file_t port = __file_name_lookup (file, 0, 0);
+ if (port == MACH_PORT_NULL)
+ return -1;
+ err = __file_chflags (port, flags);
+ __mach_port_deallocate (__mach_task_self (), port);
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/chmod.c b/sysdeps/mach/hurd/chmod.c
new file mode 100644
index 0000000..00a81ef
--- /dev/null
+++ b/sysdeps/mach/hurd/chmod.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <hurd.h>
+
+/* Change the protections of FILE to MODE. */
+int
+DEFUN(__chmod, (file, mode), CONST char *file AND mode_t mode)
+{
+ error_t err;
+ file_t port = __file_name_lookup (file, 0, 0);
+ if (port == MACH_PORT_NULL)
+ return -1;
+ err = __file_chmod (port, mode);
+ __mach_port_deallocate (__mach_task_self (), port);
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+
+weak_alias (__chmod, chmod)
diff --git a/sysdeps/mach/hurd/chown.c b/sysdeps/mach/hurd/chown.c
new file mode 100644
index 0000000..a1ed9d5
--- /dev/null
+++ b/sysdeps/mach/hurd/chown.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <hurd.h>
+
+/* Change the owner and group of FILE. */
+int
+DEFUN(__chown, (file, owner, group),
+ CONST char *file AND uid_t owner AND gid_t group)
+{
+ error_t err;
+ file_t port = __file_name_lookup (file, 0, 0);
+ if (port == MACH_PORT_NULL)
+ return -1;
+ err = __file_chown (port, owner, group);
+ __mach_port_deallocate (__mach_task_self (), port);
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+
+weak_alias (__chown, chown)
diff --git a/sysdeps/mach/hurd/chroot.c b/sysdeps/mach/hurd/chroot.c
new file mode 100644
index 0000000..415a068
--- /dev/null
+++ b/sysdeps/mach/hurd/chroot.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <fcntl.h>
+#include <hurd/port.h>
+
+/* Change the current root to FILE_NAME. */
+int
+DEFUN(chroot, (file_name), CONST char *file_name)
+{
+ file_t file, dir;
+ error_t err;
+
+ file = __file_name_lookup (file_name, O_EXEC, 0);
+ if (file == MACH_PORT_NULL)
+ return -1;
+ err = __USEPORT (CRDIR, __hurd_file_name_lookup (port, file, "",
+ O_EXEC, 0, &dir));
+ __mach_port_deallocate (__mach_task_self (), file);
+ if (err)
+ return __hurd_fail (err);
+
+ _hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], dir);
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/close.c b/sysdeps/mach/hurd/close.c
new file mode 100644
index 0000000..259687e
--- /dev/null
+++ b/sysdeps/mach/hurd/close.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+
+/* Close the file descriptor FD. */
+int
+DEFUN(__close, (fd), int fd)
+{
+ error_t err;
+
+ err = HURD_FD_USE (fd, _hurd_fd_close (descriptor));
+
+ return err ? __hurd_fail (err) : 0;
+}
+
+weak_alias (__close, close)
diff --git a/sysdeps/mach/hurd/closedir.c b/sysdeps/mach/hurd/closedir.c
new file mode 100644
index 0000000..9d20621
--- /dev/null
+++ b/sysdeps/mach/hurd/closedir.c
@@ -0,0 +1,52 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <hurd.h>
+
+/* Close the directory stream DIRP.
+ Return 0 if successful, -1 if not. */
+int
+DEFUN(closedir, (dirp), DIR *dirp)
+{
+ error_t err;
+
+ if (dirp == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if ((err = __vm_deallocate (__mach_task_self (),
+ (vm_address_t) dirp->__data, dirp->__allocation))
+ || (err = __mach_port_deallocate (__mach_task_self (), dirp->__port)))
+ {
+ errno = err;
+ return -1;
+ }
+
+ free (dirp);
+
+ return 0;
+}
+
diff --git a/sysdeps/mach/hurd/configure b/sysdeps/mach/hurd/configure
new file mode 100755
index 0000000..a396cd0
--- /dev/null
+++ b/sysdeps/mach/hurd/configure
@@ -0,0 +1,21 @@
+
+# If configure is passed `--with-hurd=DIR', set `hurd-srcdir' to DIR in
+# config.make.
+
+ac_help="$ac_help
+ --with-hurd=DIRECTORY find Hurd source code in DIRECTORY [../hurd]"
+# Check whether --with-hurd or --without-hurd was given.
+withval="$with_hurd"
+if test -n "$withval"; then
+ case z"$with_hurd" in
+z | zno | zyes) ;; # Not specified, or specified with no value.
+z*) config_vars="$config_vars
+hurd-srcdir = $with_hurd" ;;
+esac
+
+fi
+
+
+# Don't bother trying to generate any glue code to be compatible with the
+# existing system library, because we are the only system library.
+inhibit_glue=yes
diff --git a/sysdeps/mach/hurd/configure.in b/sysdeps/mach/hurd/configure.in
new file mode 100644
index 0000000..39e1002
--- /dev/null
+++ b/sysdeps/mach/hurd/configure.in
@@ -0,0 +1,19 @@
+sinclude(./aclocal.m4)dnl Autoconf lossage.
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+
+# If configure is passed `--with-hurd=DIR', set `hurd-srcdir' to DIR in
+# config.make.
+
+AC_ARG_WITH(hurd, dnl
+[ --with-hurd=DIRECTORY find Hurd source code in DIRECTORY [../hurd]],
+ [dnl
+case z"$with_hurd" in
+z | zno | zyes) ;; # Not specified, or specified with no value.
+z*) config_vars="$config_vars
+hurd-srcdir = $with_hurd" ;;
+esac
+])
+
+# Don't bother trying to generate any glue code to be compatible with the
+# existing system library, because we are the only system library.
+inhibit_glue=yes
diff --git a/sysdeps/mach/hurd/connect.c b/sysdeps/mach/hurd/connect.c
new file mode 100644
index 0000000..e015a14
--- /dev/null
+++ b/sysdeps/mach/hurd/connect.c
@@ -0,0 +1,75 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <sys/socket.h>
+#include <hurd/socket.h>
+#include <sys/un.h>
+#include <hurd/ifsock.h>
+
+/* Open a connection on socket FD to peer at ADDR (which LEN bytes long).
+ For connectionless socket types, just set the default address to send to
+ and the only address from which to accept transmissions.
+ Return 0 on success, -1 for errors. */
+int
+DEFUN(connect, (fd, addr, len),
+ int fd AND struct sockaddr *addr AND size_t len)
+{
+ error_t err;
+ addr_port_t aport;
+
+ if (addr->sa_family == AF_LOCAL)
+ {
+ /* For the local domain, we must look up the name as a file and talk
+ to it with the ifsock protocol. */
+ struct sockaddr_un *unaddr = (struct sockaddr_un *) addr;
+ file_t file = __file_name_lookup (unaddr->sun_path, 0, 0);
+ if (file == MACH_PORT_NULL)
+ return -1;
+ err = __ifsock_getsockaddr (file, &aport);
+ __mach_port_deallocate (__mach_task_self (), file);
+ if (err == MIG_BAD_ID || err == EOPNOTSUPP)
+ /* The file did not grok the ifsock protocol. */
+ err = ENOTSOCK;
+ if (err)
+ return __hurd_fail (err);
+ }
+ else
+ err = EIEIO;
+
+ err = HURD_DPORT_USE (fd,
+ ({
+ if (err)
+ err = __socket_create_address (port,
+ addr->sa_family,
+ (char *) addr, len,
+ &aport, 0);
+ if (! err)
+ {
+ err = __socket_connect (port, aport);
+ __mach_port_deallocate (__mach_task_self (),
+ aport);
+ }
+ err;
+ }));
+
+ return err ? __hurd_dfail (fd, err) : 0;
+}
diff --git a/sysdeps/mach/hurd/defs.c b/sysdeps/mach/hurd/defs.c
new file mode 100644
index 0000000..b2cfe7c
--- /dev/null
+++ b/sysdeps/mach/hurd/defs.c
@@ -0,0 +1,85 @@
+/* Definitions of global stdio data structures.
+
+Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+#include <hurd/fd.h>
+#include <unistd.h>
+
+FILE *stdin, *stdout, *stderr;
+
+/* Pointer to the first stream in the list. */
+FILE *__stdio_head = NULL;
+
+static void
+init_stdio (void)
+{
+ inline void init (FILE **streamptr, int fd)
+ {
+ /* We want to use the existing FILE object if one has been allocated.
+ (This will only be the case if our image came from something like
+ Emacs's unexec, where we were called in the first run.) */
+ FILE *s = *streamptr ?: __newstream ();
+ struct hurd_fd *d = _hurd_fd_get (fd);
+ if (d == NULL)
+ {
+ /* There is no file descriptor allocated. We want the standard
+ streams to always refer to their standard file descriptors, even
+ if those descriptors are not set up until later. So allocate
+ the descriptor structure with no ports and store it in the
+ stream. Operations will fail until ports are installed in the
+ file descriptor. */
+ if (d = _hurd_alloc_fd (NULL, fd))
+ __spin_unlock (&d->port.lock);
+ }
+ if (s)
+ s->__cookie = d;
+ *streamptr = s;
+ }
+#define S(NAME, FD, MODE) \
+ init (&NAME, FD); if (NAME) NAME->__mode.__##MODE = 1;
+
+ S (stdin, STDIN_FILENO, read);
+ S (stdout, STDOUT_FILENO, write);
+ S (stderr, STDERR_FILENO, write);
+
+#undef S
+
+ if (stderr)
+ stderr->__userbuf = 1; /* stderr is always unbuffered. */
+
+ (void) &init_stdio; /* Avoid "defined but not used" warning. */
+}
+text_set_element (_hurd_fd_subinit, init_stdio);
+
+/* This function MUST be in this file!
+ This is because we want _cleanup to go into the __libc_atexit set
+ when any stdio code is used (and to use any stdio code, one must reference
+ something defined in this file), and since only local symbols can be made
+ set elements, having the set element stab entry here and _cleanup elsewhere
+ loses; and having them both elsewhere loses because there is no reference
+ to cause _cleanup to be linked in. */
+
+void
+DEFUN_VOID(_cleanup)
+{
+ (void) fclose ((FILE *) NULL);
+}
+text_set_element (__libc_atexit, _cleanup);
diff --git a/sysdeps/mach/hurd/dirstream.h b/sysdeps/mach/hurd/dirstream.h
new file mode 100644
index 0000000..0bcec36
--- /dev/null
+++ b/sysdeps/mach/hurd/dirstream.h
@@ -0,0 +1,40 @@
+/* Copyright (C) 1993, 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. */
+
+#ifndef _DIRSTREAM_H
+
+#define _DIRSTREAM_H 1
+
+/* Directory stream type.
+
+ The Hurd directory format is the same as `struct dirent', so `readdir'
+ returns a pointer into the buffer we read directory data into. */
+
+typedef struct
+ {
+ /* XXX we need a namespace-clean name for mach_port_t! */
+ unsigned int __port; /* Port to the directory. */
+ char *__data; /* Directory block. */
+ int __entry_data; /* Entry number `__data' corresponds to. */
+ char *__ptr; /* Current pointer into the block. */
+ int __entry_ptr; /* Entry number `__ptr' corresponds to. */
+ unsigned long int __allocation; /* Space allocated for the block. */
+ unsigned long int __size; /* Total valid data in the block. */
+ } DIR;
+
+#endif /* dirstream.h */
diff --git a/sysdeps/mach/hurd/dup2.c b/sysdeps/mach/hurd/dup2.c
new file mode 100644
index 0000000..f4ec623
--- /dev/null
+++ b/sysdeps/mach/hurd/dup2.c
@@ -0,0 +1,114 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+
+
+/* Duplicate FD to FD2, closing the old FD2 and making FD2 be
+ open on the same file as FD is. Return FD2 or -1. */
+int
+DEFUN(__dup2, (fd, fd2), int fd AND int fd2)
+{
+ struct hurd_fd *d;
+
+ /* Extract the ports and flags from FD. */
+ d = _hurd_fd_get (fd);
+ if (d == NULL)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ HURD_CRITICAL_BEGIN;
+
+ __spin_lock (&d->port.lock);
+ if (d->port.port == MACH_PORT_NULL)
+ {
+ __spin_unlock (&d->port.lock);
+ errno = EBADF;
+ fd2 = -1;
+ }
+ else if (fd2 == fd)
+ /* FD is valid and FD2 is already the same; just return it. */
+ __spin_unlock (&d->port.lock);
+ else
+ {
+ struct hurd_userlink ulink, ctty_ulink;
+ int flags = d->flags;
+ io_t ctty = _hurd_port_get (&d->ctty, &ctty_ulink);
+ io_t port = _hurd_port_locked_get (&d->port, &ulink); /* Unlocks D. */
+
+ __mutex_lock (&_hurd_dtable_lock);
+ if (fd2 < 0 || fd2 >= _hurd_dtablesize)
+ {
+ errno = EBADF;
+ fd2 = -1;
+ }
+ else
+ {
+ /* Get a hold of the destination descriptor. */
+ struct hurd_fd *d2 = _hurd_dtable[fd2];
+ if (d2 == NULL)
+ {
+ /* Must allocate a new one. We don't initialize the port cells
+ with this call so that if it fails (out of memory), we will
+ not have already added user references for the ports, which we
+ would then have to deallocate. */
+ d2 = _hurd_dtable[fd2] = _hurd_new_fd (MACH_PORT_NULL,
+ MACH_PORT_NULL);
+ }
+ if (d2 == NULL)
+ {
+ fd2 = -1;
+ if (errno == EINVAL)
+ errno = EBADF; /* POSIX.1-1990 6.2.1.2 ll 54-55. */
+ }
+ else
+ {
+ /* Give the ports each a user ref for the new descriptor. */
+ __mach_port_mod_refs (__mach_task_self (), port,
+ MACH_PORT_RIGHT_SEND, 1);
+ if (ctty != MACH_PORT_NULL)
+ __mach_port_mod_refs (__mach_task_self (), ctty,
+ MACH_PORT_RIGHT_SEND, 1);
+
+ /* Install the ports and flags in the new descriptor slot. */
+ __spin_lock (&d2->port.lock);
+ d2->flags = flags & ~FD_CLOEXEC; /* Dup clears FD_CLOEXEC. */
+ _hurd_port_set (&d2->ctty, ctty);
+ _hurd_port_locked_set (&d2->port, port); /* Unlocks D2. */
+ }
+ }
+ __mutex_unlock (&_hurd_dtable_lock);
+
+ _hurd_port_free (&d->port, &ulink, port);
+ if (ctty != MACH_PORT_NULL)
+ _hurd_port_free (&d->ctty, &ctty_ulink, port);
+ }
+
+ HURD_CRITICAL_END;
+
+ return fd2;
+}
+
+weak_alias (__dup2, dup2)
diff --git a/sysdeps/mach/hurd/err_hurd.sub b/sysdeps/mach/hurd/err_hurd.sub
new file mode 100644
index 0000000..b077d24
--- /dev/null
+++ b/sysdeps/mach/hurd/err_hurd.sub
@@ -0,0 +1,11 @@
+/* This file defines the Mach error system for Hurd server errors. */
+
+#include <stdio.h>
+#include <errno.h>
+
+/* Omit `const' because we are included with `static'
+ defined to `static const'. */
+static struct error_subsystem err_hurd_sub[] =
+ {
+ { "(os/hurd)", _HURD_ERRNOS, (const char *const *) _sys_errlist },
+ };
diff --git a/sysdeps/mach/hurd/errlist.awk b/sysdeps/mach/hurd/errlist.awk
new file mode 100644
index 0000000..a06ec88
--- /dev/null
+++ b/sysdeps/mach/hurd/errlist.awk
@@ -0,0 +1,77 @@
+# Copyright (C) 1991, 1992, 1993, 1994, 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.
+
+# errno.texinfo contains lines like:
+# @comment errno.h
+# @comment POSIX.1: Function not implemented
+# @deftypevr Macro int ENOSYS
+# @comment errno 78
+
+BEGIN {
+ print "/* This file is generated from errno.texi by errlist.awk. */"
+ print "";
+ print "#ifndef HAVE_GNU_LD"
+ print "#define _sys_nerr sys_nerr"
+ print "#define _sys_errlist sys_errlist"
+ print "#endif"
+ print ""
+ print "const char *_sys_errlist[] =";
+ print " {";
+ maxerrno = 0;
+ print " \"Success\","
+ }
+$1 == "@comment" && $2 == "errno.h" { errnoh=1; next }
+errnoh == 1 && $1 == "@comment" \
+ {
+ ++errnoh;
+ etext = $3;
+ for (i = 4; i <= NF; ++i)
+ etext = etext " " $i;
+ next;
+ }
+errnoh == 2 && $1 == "@deftypevr" && $2 == "Macro" && $3 == "int" \
+ {
+ e = $4; errnoh++; next;
+ }
+errnoh == 3 && $1 == "@comment" && $2 == "errno" \
+ {
+ errno = $3 + 0;
+ msgs[errno] = etext;
+ names[errno] = e;
+ if (errno > maxerrno) maxerrno = errno;
+ next;
+ }
+{ errnoh=0 }
+END {
+ for (i = 1; i <= maxerrno; ++i)
+ {
+ if (names[i] == "")
+ print " \"Reserved error " i "\",";
+ else
+ printf "%-40s/* %d = %s */\n", " \"" msgs[i] "\",", i, names[i];
+ }
+ print " };";
+ print "";
+ print "#include <errno.h>";
+ printf "#if _HURD_ERRNOS != %d\n", maxerrno+1;
+ print "#error errlist/errnos generation bug";
+ print "#endif"
+ printf "const int _sys_nerr = %d;\n", maxerrno+1;
+ print "weak_alias (_sys_errlist, sys_errlist)"
+ print "weak_alias (_sys_nerr, sys_nerr)"
+ }
diff --git a/sysdeps/mach/hurd/errlist.c b/sysdeps/mach/hurd/errlist.c
new file mode 100644
index 0000000..b72cd73
--- /dev/null
+++ b/sysdeps/mach/hurd/errlist.c
@@ -0,0 +1,93 @@
+/* This file is generated from errno.texi by errlist.awk. */
+
+#ifndef HAVE_GNU_LD
+#define _sys_nerr sys_nerr
+#define _sys_errlist sys_errlist
+#endif
+
+const char *_sys_errlist[] =
+ {
+ "Success",
+ "Operation not permitted", /* 1 = EPERM */
+ "No such file or directory", /* 2 = ENOENT */
+ "No such process", /* 3 = ESRCH */
+ "Interrupted system call", /* 4 = EINTR */
+ "Input/output error", /* 5 = EIO */
+ "Device not configured", /* 6 = ENXIO */
+ "Argument list too long", /* 7 = E2BIG */
+ "Exec format error", /* 8 = ENOEXEC */
+ "Bad file descriptor", /* 9 = EBADF */
+ "No child processes", /* 10 = ECHILD */
+ "Resource deadlock avoided", /* 11 = EDEADLK */
+ "Cannot allocate memory", /* 12 = ENOMEM */
+ "Permission denied", /* 13 = EACCES */
+ "Bad address", /* 14 = EFAULT */
+ "Block device required", /* 15 = ENOTBLK */
+ "Device busy", /* 16 = EBUSY */
+ "File exists", /* 17 = EEXIST */
+ "Invalid cross-device link", /* 18 = EXDEV */
+ "Operation not supported by device",/* 19 = ENODEV */
+ "Not a directory", /* 20 = ENOTDIR */
+ "Is a directory", /* 21 = EISDIR */
+ "Invalid argument", /* 22 = EINVAL */
+ "Too many open files", /* 23 = EMFILE */
+ "Too many open files in system", /* 24 = ENFILE */
+ "Inappropriate ioctl for device", /* 25 = ENOTTY */
+ "Text file busy", /* 26 = ETXTBSY */
+ "File too large", /* 27 = EFBIG */
+ "No space left on device", /* 28 = ENOSPC */
+ "Illegal seek", /* 29 = ESPIPE */
+ "Read-only file system", /* 30 = EROFS */
+ "Too many links", /* 31 = EMLINK */
+ "Broken pipe", /* 32 = EPIPE */
+ "Numerical argument out of domain", /* 33 = EDOM */
+ "Numerical result out of range", /* 34 = ERANGE */
+ "Operation would block", /* 35 = EWOULDBLOCK */
+ "Operation now in progress", /* 36 = EINPROGRESS */
+ "Operation already in progress", /* 37 = EALREADY */
+ "Socket operation on non-socket", /* 38 = ENOTSOCK */
+ "Destination address required", /* 39 = EDESTADDRREQ */
+ "Message too long", /* 40 = EMSGSIZE */
+ "Protocol wrong type for socket", /* 41 = EPROTOTYPE */
+ "Protocol not available", /* 42 = ENOPROTOOPT */
+ "Protocol not supported", /* 43 = EPROTONOSUPPORT */
+ "Socket type not supported", /* 44 = ESOCKTNOSUPPORT */
+ "Operation not supported", /* 45 = EOPNOTSUPP */
+ "Protocol family not supported", /* 46 = EPFNOSUPPORT */
+ "Address family not supported by protocol family",/* 47 = EAFNOSUPPORT */
+ "Address already in use", /* 48 = EADDRINUSE */
+ "Can't assign requested address", /* 49 = EADDRNOTAVAIL */
+ "Network is down", /* 50 = ENETDOWN */
+ "Network is unreachable", /* 51 = ENETUNREACH */
+ "Network dropped connection on reset",/* 52 = ENETRESET */
+ "Software caused connection abort", /* 53 = ECONNABORTED */
+ "Connection reset by peer", /* 54 = ECONNRESET */
+ "No buffer space available", /* 55 = ENOBUFS */
+ "Socket is already connected", /* 56 = EISCONN */
+ "Socket is not connected", /* 57 = ENOTCONN */
+ "Can't send after socket shutdown", /* 58 = ESHUTDOWN */
+ "Connection timed out", /* 59 = ETIMEDOUT */
+ "Connection refused", /* 60 = ECONNREFUSED */
+ "Too many levels of symbolic links",/* 61 = ELOOP */
+ "File name too long", /* 62 = ENAMETOOLONG */
+ "Host is down", /* 63 = EHOSTDOWN */
+ "No route to host", /* 64 = EHOSTUNREACH */
+ "Directory not empty", /* 65 = ENOTEMPTY */
+ "Too many users", /* 66 = EUSERS */
+ "Disc quota exceeded", /* 67 = EDQUOT */
+ "Stale NFS file handle", /* 68 = ESTALE */
+ "Too many levels of remote in path",/* 69 = EREMOTE */
+ "No locks available", /* 70 = ENOLCK */
+ "Function not implemented", /* 71 = ENOSYS */
+ "Inappropriate operation for background process",/* 72 = EBACKGROUND */
+ "?", /* 73 = ED */
+ "You really blew it this time", /* 74 = EGREGIOUS */
+ "Computer bought the farm", /* 75 = EIEIO */
+ "Gratuitous error", /* 76 = EGRATUITOUS */
+ };
+
+#include <errno.h>
+#if _HURD_ERRNOS != 77
+#error errlist/errnos generation bug
+#endif
+const int _sys_nerr = 77;
diff --git a/sysdeps/mach/hurd/errnos.awk b/sysdeps/mach/hurd/errnos.awk
new file mode 100644
index 0000000..a6b251f
--- /dev/null
+++ b/sysdeps/mach/hurd/errnos.awk
@@ -0,0 +1,157 @@
+# Copyright (C) 1991, 1992, 1993, 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.
+
+# errno.texinfo contains lines like:
+# @comment errno.h
+# @comment POSIX.1: Function not implemented
+# @deftypevr Macro int ENOSYS
+
+BEGIN {
+ printf "/* This file generated by";
+ for (i = 0; i < ARGC; ++i)
+ printf " %s", ARGV[i];
+ printf ". */\n";
+ print "";
+ print "/* The Hurd uses Mach error system 0x10, currently only subsystem 0. */";
+ print "#ifndef _HURD_ERRNO";
+ print "#define _HURD_ERRNO(n)\t((0x10 << 26) | ((n) & 0x3fff))";
+ print "#endif";
+ print "";
+ print "#ifdef _ERRNO_H\n";
+ print "enum __error_t_codes\n{";
+ errnoh = 0;
+ maxerrno = 0;
+ in_mach_errors = 0;
+ in_math = 0;
+ edom = erange = "";
+ print "#undef EDOM\n#undef ERANGE";
+ }
+
+$1 == "@comment" && $2 == "errno.h" { errnoh=1; next }
+$1 == "@comment" && errnoh == 1 \
+ {
+ ++errnoh;
+ etext = "";
+ for (i = 3; i <= NF; ++i)
+ etext = etext " " $i;
+ next;
+ }
+
+errnoh == 2 && $1 == "@deftypevr" && $2 == "Macro" && $3 == "int" \
+ { ++errnoh; e = $4; next; }
+
+errnoh == 3 && $1 == "@comment" && $2 == "errno" {
+ errno = $3 + 0;
+ if (errno > maxerrno) maxerrno = errno;
+ if (e == "EWOULDBLOCK")
+ {
+ print "#define EWOULDBLOCK EAGAIN /* Operation would block */";
+ next;
+ }
+ x = sprintf ("%-40s/*%s */", sprintf ("%-24s%s", "#define\t" e,
+ "_HURD_ERRNO (" errno ")"),
+ etext);
+ if (e == "EDOM")
+ edom = x;
+ else if (e == "ERANGE")
+ erange = x;
+ printf "\t%-16s= _HURD_ERRNO (%d),\n", e, errno;
+ print x;
+ next;
+ }
+{ errnoh=0 }
+
+NF == 3 && $1 == "#define" && $2 == "MACH_SEND_IN_PROGRESS" \
+ {
+ in_mach_errors = 1;
+ print "\n\t/* Errors from <mach/message.h>. */";
+ }
+NF == 3 && $1 == "#define" && $2 == "KERN_SUCCESS" \
+ {
+ in_mach_errors = 1;
+ print "\n\t/* Errors from <mach/kern_return.h>. */";
+ next;
+ }
+
+in_mach_errors && $2 == "MACH_IPC_COMPAT" \
+ {
+ in_mach_errors = 0;
+ }
+
+in_mach_errors == 1 && NF == 3 && $1 == "#define" \
+ {
+ printf "\t%-32s= %s,\n", "E" $2, $3;
+ }
+
+$1 == "#define" && $2 == "_MACH_MIG_ERRORS_H_" \
+ {
+ in_mig_errors = 1;
+ print "\n\t/* Errors from <mach/mig_errors.h>. */";
+ next;
+ }
+in_mig_errors && $1 == "#endif" && $3 == "_MACH_MIG_ERRORS_H_" \
+ {
+ in_mig_errors = 0;
+ }
+
+(in_mig_errors && $1 == "#define" && $3 <= -300) || \
+(in_device_errors && $1 == "#define") \
+ {
+ printf "%-32s", sprintf ("\t%-24s= %s,", "E" $2, $3);
+ for (i = 4; i <= NF; ++i)
+ printf " %s", $i;
+ printf "\n";
+ }
+
+$1 == "#define" && $2 == "D_SUCCESS" \
+ {
+ in_device_errors = 1;
+ print "\n\t/* Errors from <device/device_types.h>. */";
+ next;
+ }
+in_device_errors && $1 == "#endif" \
+ {
+ in_device_errors = 0;
+ }
+
+
+END \
+ {
+ print "";
+ print "};";
+ print "";
+ printf "#define\t_HURD_ERRNOS\t%d\n", maxerrno+1;
+ print "";
+ print "\
+/* User-visible type of error codes. It is ok to use `int' or\n\
+ `kern_return_t' for these, but with `error_t' the debugger prints\n\
+ symbolic values. */";
+ print "#ifdef __USE_GNU";
+ print "typedef enum __error_t_codes error_t;"
+ print "#endif";
+ print "";
+ print "/* errno is a per-thread variable. */";
+ print "#include <hurd/threadvar.h>";
+ print "#define errno (*__hurd_errno_location ())";
+ print "";
+ print "#endif /* <errno.h> included. */";
+ print "";
+ print "#if !defined (_ERRNO_H) && defined (__need_Emath)";
+ print edom; print erange;
+ print "#endif /* <errno.h> not included and need math error codes. */";
+ }
diff --git a/sysdeps/mach/hurd/errnos.h b/sysdeps/mach/hurd/errnos.h
new file mode 100644
index 0000000..911af3c
--- /dev/null
+++ b/sysdeps/mach/hurd/errnos.h
@@ -0,0 +1,266 @@
+/* This file generated by gawk manual/errno.texi ../mach/mach/message.h ../mach/mach/kern_return.h ../mach/mach/mig_errors.h ../mach/device/device_types.h. */
+
+/* The Hurd uses Mach error system 0x10, currently only subsystem 0. */
+#ifndef _HURD_ERRNO
+#define _HURD_ERRNO(n) ((0x10 << 26) | ((n) & 0x3fff))
+#endif
+
+#ifdef _ERRNO_H
+
+enum __error_t_codes
+{
+#undef EDOM
+#undef ERANGE
+ EPERM = _HURD_ERRNO (1),
+#define EPERM _HURD_ERRNO (1) /* Operation not permitted */
+ ENOENT = _HURD_ERRNO (2),
+#define ENOENT _HURD_ERRNO (2) /* No such file or directory */
+ ESRCH = _HURD_ERRNO (3),
+#define ESRCH _HURD_ERRNO (3) /* No such process */
+ EINTR = _HURD_ERRNO (4),
+#define EINTR _HURD_ERRNO (4) /* Interrupted system call */
+ EIO = _HURD_ERRNO (5),
+#define EIO _HURD_ERRNO (5) /* Input/output error */
+ ENXIO = _HURD_ERRNO (6),
+#define ENXIO _HURD_ERRNO (6) /* Device not configured */
+ E2BIG = _HURD_ERRNO (7),
+#define E2BIG _HURD_ERRNO (7) /* Argument list too long */
+ ENOEXEC = _HURD_ERRNO (8),
+#define ENOEXEC _HURD_ERRNO (8) /* Exec format error */
+ EBADF = _HURD_ERRNO (9),
+#define EBADF _HURD_ERRNO (9) /* Bad file descriptor */
+ ECHILD = _HURD_ERRNO (10),
+#define ECHILD _HURD_ERRNO (10)/* No child processes */
+ EDEADLK = _HURD_ERRNO (11),
+#define EDEADLK _HURD_ERRNO (11)/* Resource deadlock avoided */
+ ENOMEM = _HURD_ERRNO (12),
+#define ENOMEM _HURD_ERRNO (12)/* Cannot allocate memory */
+ EACCES = _HURD_ERRNO (13),
+#define EACCES _HURD_ERRNO (13)/* Permission denied */
+ EFAULT = _HURD_ERRNO (14),
+#define EFAULT _HURD_ERRNO (14)/* Bad address */
+ ENOTBLK = _HURD_ERRNO (15),
+#define ENOTBLK _HURD_ERRNO (15)/* Block device required */
+ EBUSY = _HURD_ERRNO (16),
+#define EBUSY _HURD_ERRNO (16)/* Device busy */
+ EEXIST = _HURD_ERRNO (17),
+#define EEXIST _HURD_ERRNO (17)/* File exists */
+ EXDEV = _HURD_ERRNO (18),
+#define EXDEV _HURD_ERRNO (18)/* Invalid cross-device link */
+ ENODEV = _HURD_ERRNO (19),
+#define ENODEV _HURD_ERRNO (19)/* Operation not supported by device */
+ ENOTDIR = _HURD_ERRNO (20),
+#define ENOTDIR _HURD_ERRNO (20)/* Not a directory */
+ EISDIR = _HURD_ERRNO (21),
+#define EISDIR _HURD_ERRNO (21)/* Is a directory */
+ EINVAL = _HURD_ERRNO (22),
+#define EINVAL _HURD_ERRNO (22)/* Invalid argument */
+ EMFILE = _HURD_ERRNO (23),
+#define EMFILE _HURD_ERRNO (23)/* Too many open files */
+ ENFILE = _HURD_ERRNO (24),
+#define ENFILE _HURD_ERRNO (24)/* Too many open files in system */
+ ENOTTY = _HURD_ERRNO (25),
+#define ENOTTY _HURD_ERRNO (25)/* Inappropriate ioctl for device */
+ ETXTBSY = _HURD_ERRNO (26),
+#define ETXTBSY _HURD_ERRNO (26)/* Text file busy */
+ EFBIG = _HURD_ERRNO (27),
+#define EFBIG _HURD_ERRNO (27)/* File too large */
+ ENOSPC = _HURD_ERRNO (28),
+#define ENOSPC _HURD_ERRNO (28)/* No space left on device */
+ ESPIPE = _HURD_ERRNO (29),
+#define ESPIPE _HURD_ERRNO (29)/* Illegal seek */
+ EROFS = _HURD_ERRNO (30),
+#define EROFS _HURD_ERRNO (30)/* Read-only file system */
+ EMLINK = _HURD_ERRNO (31),
+#define EMLINK _HURD_ERRNO (31)/* Too many links */
+ EPIPE = _HURD_ERRNO (32),
+#define EPIPE _HURD_ERRNO (32)/* Broken pipe */
+ EDOM = _HURD_ERRNO (33),
+#define EDOM _HURD_ERRNO (33)/* Numerical argument out of domain */
+ ERANGE = _HURD_ERRNO (34),
+#define ERANGE _HURD_ERRNO (34)/* Numerical result out of range */
+ EAGAIN = _HURD_ERRNO (35),
+#define EAGAIN _HURD_ERRNO (35)/* Resource temporarily unavailable */
+#define EWOULDBLOCK EAGAIN /* Operation would block */
+ EINPROGRESS = _HURD_ERRNO (36),
+#define EINPROGRESS _HURD_ERRNO (36)/* Operation now in progress */
+ EALREADY = _HURD_ERRNO (37),
+#define EALREADY _HURD_ERRNO (37)/* Operation already in progress */
+ ENOTSOCK = _HURD_ERRNO (38),
+#define ENOTSOCK _HURD_ERRNO (38)/* Socket operation on non-socket */
+ EDESTADDRREQ = _HURD_ERRNO (39),
+#define EDESTADDRREQ _HURD_ERRNO (39)/* Destination address required */
+ EMSGSIZE = _HURD_ERRNO (40),
+#define EMSGSIZE _HURD_ERRNO (40)/* Message too long */
+ EPROTOTYPE = _HURD_ERRNO (41),
+#define EPROTOTYPE _HURD_ERRNO (41)/* Protocol wrong type for socket */
+ ENOPROTOOPT = _HURD_ERRNO (42),
+#define ENOPROTOOPT _HURD_ERRNO (42)/* Protocol not available */
+ EPROTONOSUPPORT = _HURD_ERRNO (43),
+#define EPROTONOSUPPORT _HURD_ERRNO (43)/* Protocol not supported */
+ ESOCKTNOSUPPORT = _HURD_ERRNO (44),
+#define ESOCKTNOSUPPORT _HURD_ERRNO (44)/* Socket type not supported */
+ EOPNOTSUPP = _HURD_ERRNO (45),
+#define EOPNOTSUPP _HURD_ERRNO (45)/* Operation not supported */
+ EPFNOSUPPORT = _HURD_ERRNO (46),
+#define EPFNOSUPPORT _HURD_ERRNO (46)/* Protocol family not supported */
+ EAFNOSUPPORT = _HURD_ERRNO (47),
+#define EAFNOSUPPORT _HURD_ERRNO (47)/* Address family not supported by protocol family */
+ EADDRINUSE = _HURD_ERRNO (48),
+#define EADDRINUSE _HURD_ERRNO (48)/* Address already in use */
+ EADDRNOTAVAIL = _HURD_ERRNO (49),
+#define EADDRNOTAVAIL _HURD_ERRNO (49)/* Can't assign requested address */
+ ENETDOWN = _HURD_ERRNO (50),
+#define ENETDOWN _HURD_ERRNO (50)/* Network is down */
+ ENETUNREACH = _HURD_ERRNO (51),
+#define ENETUNREACH _HURD_ERRNO (51)/* Network is unreachable */
+ ENETRESET = _HURD_ERRNO (52),
+#define ENETRESET _HURD_ERRNO (52)/* Network dropped connection on reset */
+ ECONNABORTED = _HURD_ERRNO (53),
+#define ECONNABORTED _HURD_ERRNO (53)/* Software caused connection abort */
+ ECONNRESET = _HURD_ERRNO (54),
+#define ECONNRESET _HURD_ERRNO (54)/* Connection reset by peer */
+ ENOBUFS = _HURD_ERRNO (55),
+#define ENOBUFS _HURD_ERRNO (55)/* No buffer space available */
+ EISCONN = _HURD_ERRNO (56),
+#define EISCONN _HURD_ERRNO (56)/* Socket is already connected */
+ ENOTCONN = _HURD_ERRNO (57),
+#define ENOTCONN _HURD_ERRNO (57)/* Socket is not connected */
+ ESHUTDOWN = _HURD_ERRNO (58),
+#define ESHUTDOWN _HURD_ERRNO (58)/* Can't send after socket shutdown */
+ ETIMEDOUT = _HURD_ERRNO (59),
+#define ETIMEDOUT _HURD_ERRNO (59)/* Connection timed out */
+ ECONNREFUSED = _HURD_ERRNO (60),
+#define ECONNREFUSED _HURD_ERRNO (60)/* Connection refused */
+ ELOOP = _HURD_ERRNO (61),
+#define ELOOP _HURD_ERRNO (61)/* Too many levels of symbolic links */
+ ENAMETOOLONG = _HURD_ERRNO (62),
+#define ENAMETOOLONG _HURD_ERRNO (62)/* File name too long */
+ EHOSTDOWN = _HURD_ERRNO (63),
+#define EHOSTDOWN _HURD_ERRNO (63)/* Host is down */
+ EHOSTUNREACH = _HURD_ERRNO (64),
+#define EHOSTUNREACH _HURD_ERRNO (64)/* No route to host */
+ ENOTEMPTY = _HURD_ERRNO (65),
+#define ENOTEMPTY _HURD_ERRNO (65)/* Directory not empty */
+ EUSERS = _HURD_ERRNO (66),
+#define EUSERS _HURD_ERRNO (66)/* Too many users */
+ EDQUOT = _HURD_ERRNO (67),
+#define EDQUOT _HURD_ERRNO (67)/* Disc quota exceeded */
+ ESTALE = _HURD_ERRNO (68),
+#define ESTALE _HURD_ERRNO (68)/* Stale NFS file handle */
+ EREMOTE = _HURD_ERRNO (69),
+#define EREMOTE _HURD_ERRNO (69)/* Too many levels of remote in path */
+ ENOLCK = _HURD_ERRNO (70),
+#define ENOLCK _HURD_ERRNO (70)/* No locks available */
+ ENOSYS = _HURD_ERRNO (71),
+#define ENOSYS _HURD_ERRNO (71)/* Function not implemented */
+ EBACKGROUND = _HURD_ERRNO (72),
+#define EBACKGROUND _HURD_ERRNO (72)/* Inappropriate operation for background process */
+ ED = _HURD_ERRNO (73),
+#define ED _HURD_ERRNO (73)/* ? */
+ EGREGIOUS = _HURD_ERRNO (74),
+#define EGREGIOUS _HURD_ERRNO (74)/* You really blew it this time */
+ EIEIO = _HURD_ERRNO (75),
+#define EIEIO _HURD_ERRNO (75)/* Computer bought the farm */
+ EGRATUITOUS = _HURD_ERRNO (76),
+#define EGRATUITOUS _HURD_ERRNO (76)/* Gratuitous error */
+
+ /* Errors from <mach/message.h>. */
+ EMACH_SEND_IN_PROGRESS = 0x10000001,
+ EMACH_SEND_INVALID_DATA = 0x10000002,
+ EMACH_SEND_INVALID_DEST = 0x10000003,
+ EMACH_SEND_TIMED_OUT = 0x10000004,
+ EMACH_SEND_WILL_NOTIFY = 0x10000005,
+ EMACH_SEND_NOTIFY_IN_PROGRESS = 0x10000006,
+ EMACH_SEND_INTERRUPTED = 0x10000007,
+ EMACH_SEND_MSG_TOO_SMALL = 0x10000008,
+ EMACH_SEND_INVALID_REPLY = 0x10000009,
+ EMACH_SEND_INVALID_RIGHT = 0x1000000a,
+ EMACH_SEND_INVALID_NOTIFY = 0x1000000b,
+ EMACH_SEND_INVALID_MEMORY = 0x1000000c,
+ EMACH_SEND_NO_BUFFER = 0x1000000d,
+ EMACH_SEND_NO_NOTIFY = 0x1000000e,
+ EMACH_SEND_INVALID_TYPE = 0x1000000f,
+ EMACH_SEND_INVALID_HEADER = 0x10000010,
+ EMACH_RCV_IN_PROGRESS = 0x10004001,
+ EMACH_RCV_INVALID_NAME = 0x10004002,
+ EMACH_RCV_TIMED_OUT = 0x10004003,
+ EMACH_RCV_TOO_LARGE = 0x10004004,
+ EMACH_RCV_INTERRUPTED = 0x10004005,
+ EMACH_RCV_PORT_CHANGED = 0x10004006,
+ EMACH_RCV_INVALID_NOTIFY = 0x10004007,
+ EMACH_RCV_INVALID_DATA = 0x10004008,
+ EMACH_RCV_PORT_DIED = 0x10004009,
+ EMACH_RCV_IN_SET = 0x1000400a,
+ EMACH_RCV_HEADER_ERROR = 0x1000400b,
+ EMACH_RCV_BODY_ERROR = 0x1000400c,
+
+ /* Errors from <mach/kern_return.h>. */
+ EKERN_INVALID_ADDRESS = 1,
+ EKERN_PROTECTION_FAILURE = 2,
+ EKERN_NO_SPACE = 3,
+ EKERN_INVALID_ARGUMENT = 4,
+ EKERN_FAILURE = 5,
+ EKERN_RESOURCE_SHORTAGE = 6,
+ EKERN_NOT_RECEIVER = 7,
+ EKERN_NO_ACCESS = 8,
+ EKERN_MEMORY_FAILURE = 9,
+ EKERN_MEMORY_ERROR = 10,
+ EKERN_NOT_IN_SET = 12,
+ EKERN_NAME_EXISTS = 13,
+ EKERN_ABORTED = 14,
+ EKERN_INVALID_NAME = 15,
+ EKERN_INVALID_TASK = 16,
+ EKERN_INVALID_RIGHT = 17,
+ EKERN_INVALID_VALUE = 18,
+ EKERN_UREFS_OVERFLOW = 19,
+ EKERN_INVALID_CAPABILITY = 20,
+ EKERN_RIGHT_EXISTS = 21,
+ EKERN_INVALID_HOST = 22,
+ EKERN_MEMORY_PRESENT = 23,
+
+ /* Errors from <mach/mig_errors.h>. */
+ EMIG_TYPE_ERROR = -300, /* client type check failure */
+ EMIG_REPLY_MISMATCH = -301, /* wrong reply message ID */
+ EMIG_REMOTE_ERROR = -302, /* server detected error */
+ EMIG_BAD_ID = -303, /* bad request message ID */
+ EMIG_BAD_ARGUMENTS = -304, /* server type check failure */
+ EMIG_NO_REPLY = -305, /* no reply should be sent */
+ EMIG_EXCEPTION = -306, /* server raised exception */
+ EMIG_ARRAY_TOO_LARGE = -307, /* array not large enough */
+ EMIG_SERVER_DIED = -308, /* server died */
+ EMIG_DESTROY_REQUEST = -309, /* destroy request with no reply */
+
+ /* Errors from <device/device_types.h>. */
+ ED_IO_ERROR = 2500, /* hardware IO error */
+ ED_WOULD_BLOCK = 2501, /* would block, but D_NOWAIT set */
+ ED_NO_SUCH_DEVICE = 2502, /* no such device */
+ ED_ALREADY_OPEN = 2503, /* exclusive-use device already open */
+ ED_DEVICE_DOWN = 2504, /* device has been shut down */
+ ED_INVALID_OPERATION = 2505, /* bad operation for device */
+ ED_INVALID_RECNUM = 2506, /* invalid record (block) number */
+ ED_INVALID_SIZE = 2507, /* invalid IO size */
+ ED_NO_MEMORY = 2508, /* memory allocation failure */
+ ED_READ_ONLY = 2509, /* device cannot be written to */
+
+};
+
+#define _HURD_ERRNOS 77
+
+/* User-visible type of error codes. It is ok to use `int' or
+ `kern_return_t' for these, but with `error_t' the debugger prints
+ symbolic values. */
+#ifdef __USE_GNU
+typedef enum __error_t_codes error_t;
+#endif
+
+/* errno is a per-thread variable. */
+#include <hurd/threadvar.h>
+#define errno (*__hurd_errno_location ())
+
+#endif /* <errno.h> included. */
+
+#if !defined (_ERRNO_H) && defined (__need_Emath)
+#define EDOM _HURD_ERRNO (33)/* Numerical argument out of domain */
+#define ERANGE _HURD_ERRNO (34)/* Numerical result out of range */
+#endif /* <errno.h> not included and need math error codes. */
diff --git a/sysdeps/mach/hurd/execve.c b/sysdeps/mach/hurd/execve.c
new file mode 100644
index 0000000..5a45f5f
--- /dev/null
+++ b/sysdeps/mach/hurd/execve.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <fcntl.h>
+
+/* Replace the current process, executing FILE_NAME with arguments ARGV and
+ environment ENVP. ARGV and ENVP are terminated by NULL pointers. */
+int
+DEFUN(__execve, (file_name, argv, envp),
+ CONST char *file_name AND char *CONST argv[] AND char *CONST envp[])
+{
+ error_t err;
+ file_t file = __file_name_lookup (file_name, O_EXEC, 0);
+
+ if (file == MACH_PORT_NULL)
+ return -1;
+
+ /* Hopefully this will not return. */
+ err = _hurd_exec (__mach_task_self (), file, argv, envp);
+
+ /* Oh well. Might as well be tidy. */
+ __mach_port_deallocate (__mach_task_self (), file);
+
+ return __hurd_fail (err);
+}
+
+weak_alias (__execve, execve)
diff --git a/sysdeps/mach/hurd/fchdir.c b/sysdeps/mach/hurd/fchdir.c
new file mode 100644
index 0000000..088bba9
--- /dev/null
+++ b/sysdeps/mach/hurd/fchdir.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/port.h>
+#include <hurd/fd.h>
+
+/* Change the current directory to FD. */
+int
+DEFUN(fchdir, (fd), int fd)
+{
+ error_t err;
+ file_t cwdir;
+
+ err = __USEPORT (CRDIR,
+ ({ file_t crdir = port;
+ HURD_DPORT_USE (fd,
+ __hurd_file_name_lookup (crdir, port, "",
+ 0, 0, &cwdir));
+ }));
+
+ if (err)
+ return __hurd_fail (err);
+
+ _hurd_port_set (&_hurd_ports[INIT_PORT_CWDIR], cwdir);
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/fchflags.c b/sysdeps/mach/hurd/fchflags.c
new file mode 100644
index 0000000..aa1e326
--- /dev/null
+++ b/sysdeps/mach/hurd/fchflags.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+
+/* Change the flags of the file FD refers to to FLAGS. */
+int
+DEFUN(fchflags, (fd, flags), int fd AND int flags)
+{
+ error_t err;
+
+ if (err = HURD_DPORT_USE (fd, __file_chflags (port, flags)))
+ return __hurd_dfail (fd, err);
+
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/fchmod.c b/sysdeps/mach/hurd/fchmod.c
new file mode 100644
index 0000000..3dc84ff
--- /dev/null
+++ b/sysdeps/mach/hurd/fchmod.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+
+/* Change the protections of the file FD refers to to MODE. */
+int
+DEFUN(__fchmod, (fd, mode), int fd AND mode_t mode)
+{
+ error_t err;
+
+ if (err = HURD_DPORT_USE (fd, __file_chmod (port, mode)))
+ return __hurd_dfail (fd, err);
+
+ return 0;
+}
+
+weak_alias (__fchmod, fchmod)
diff --git a/sysdeps/mach/hurd/fchown.c b/sysdeps/mach/hurd/fchown.c
new file mode 100644
index 0000000..c2f873c
--- /dev/null
+++ b/sysdeps/mach/hurd/fchown.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+
+/* Change the owner and group of the file referred to by FD. */
+int
+DEFUN(__fchown, (fd, owner, group),
+ int fd AND uid_t owner AND gid_t group)
+{
+ error_t err;
+
+ if (err = HURD_DPORT_USE (fd, __file_chown (port, owner, group)))
+ return __hurd_dfail (fd, err);
+
+ return 0;
+}
+
+weak_alias (__fchown, fchown)
diff --git a/sysdeps/mach/hurd/fcntl.c b/sysdeps/mach/hurd/fcntl.c
new file mode 100644
index 0000000..4b7207f
--- /dev/null
+++ b/sysdeps/mach/hurd/fcntl.c
@@ -0,0 +1,159 @@
+/* Copyright (C) 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <stdarg.h>
+
+
+/* Perform file control operations on FD. */
+int
+DEFUN(__fcntl, (fd, cmd), int fd AND int cmd DOTS)
+{
+ va_list ap;
+ struct hurd_fd *d;
+ int result;
+
+ d = _hurd_fd_get (fd);
+
+ if (d == NULL)
+ return __hurd_fail (EBADF);
+
+ va_start (ap, cmd);
+
+ switch (cmd)
+ {
+ error_t err;
+
+ default: /* Bad command. */
+ errno = EINVAL;
+ result = -1;
+ break;
+
+ /* First the descriptor-based commands, which do no RPCs. */
+
+ case F_DUPFD: /* Duplicate the file descriptor. */
+ {
+ struct hurd_fd *new;
+ io_t port, ctty;
+ struct hurd_userlink ulink, ctty_ulink;
+ int flags;
+
+ HURD_CRITICAL_BEGIN;
+
+ /* Extract the ports and flags from the file descriptor. */
+ __spin_lock (&d->port.lock);
+ flags = d->flags;
+ ctty = _hurd_port_get (&d->ctty, &ctty_ulink);
+ port = _hurd_port_locked_get (&d->port, &ulink); /* Unlocks D. */
+
+ /* Get a new file descriptor. The third argument to __fcntl is the
+ minimum file descriptor number for it. */
+ new = _hurd_alloc_fd (&result, va_arg (ap, int));
+ if (new == NULL)
+ /* _hurd_alloc_fd has set errno. */
+ result = -1;
+ else
+ {
+ /* Give the ports each a user ref for the new descriptor. */
+ __mach_port_mod_refs (__mach_task_self (), port,
+ MACH_PORT_RIGHT_SEND, 1);
+ if (ctty != MACH_PORT_NULL)
+ __mach_port_mod_refs (__mach_task_self (), ctty,
+ MACH_PORT_RIGHT_SEND, 1);
+
+ /* Install the ports and flags in the new descriptor. */
+ if (ctty != MACH_PORT_NULL)
+ _hurd_port_set (&new->ctty, ctty);
+ /* Duplication clears the FD_CLOEXEC flag. */
+ new->flags = flags & ~FD_CLOEXEC;
+ _hurd_port_locked_set (&new->port, port); /* Unlocks NEW. */
+ }
+
+ HURD_CRITICAL_END;
+
+ _hurd_port_free (&d->port, &ulink, port);
+ if (ctty != MACH_PORT_NULL)
+ _hurd_port_free (&d->ctty, &ctty_ulink, port);
+
+ break;
+ }
+
+ /* Set RESULT by evaluating EXPR with the descriptor locked.
+ Check for an empty descriptor and return EBADF. */
+#define LOCKED(expr) \
+ HURD_CRITICAL_BEGIN; \
+ __spin_lock (&d->port.lock); \
+ if (d->port.port == MACH_PORT_NULL) \
+ result = __hurd_fail (EBADF); \
+ else \
+ result = (expr); \
+ __spin_unlock (&d->port.lock); \
+ HURD_CRITICAL_END;
+
+ case F_GETFD: /* Get descriptor flags. */
+ LOCKED (d->flags);
+ break;
+
+ case F_SETFD: /* Set descriptor flags. */
+ LOCKED ((d->flags = va_arg (ap, int), 0));
+ break;
+
+
+ /* Now the real io operations, done by RPCs to io servers. */
+
+ case F_GETLK:
+ case F_SETLK:
+ case F_SETLKW:
+ {
+ struct flock *fl = va_arg (ap, struct flock *);
+ errno = fl?ENOSYS:EINVAL; /* XXX mib needs to implement io rpcs. */
+ result = -1;
+ break;
+ }
+
+ case F_GETFL: /* Get per-open flags. */
+ if (err = HURD_FD_PORT_USE (d, __io_get_openmodes (port, &result)))
+ result = __hurd_dfail (fd, err);
+ break;
+
+ case F_SETFL: /* Set per-open flags. */
+ err = HURD_FD_PORT_USE (d, __io_set_all_openmodes (port,
+ va_arg (ap, int)));
+ result = err ? __hurd_dfail (fd, err) : 0;
+
+ case F_GETOWN: /* Get owner. */
+ if (err = HURD_FD_PORT_USE (d, __io_get_owner (port, &result)))
+ result = __hurd_dfail (fd, err);
+ break;
+
+ case F_SETOWN: /* Set owner. */
+ err = HURD_FD_PORT_USE (d, __io_mod_owner (port, va_arg (ap, pid_t)));
+ result = err ? __hurd_dfail (fd, err) : 0;
+ break;
+ }
+
+ va_end (ap);
+
+ return result;
+}
+
+weak_alias (__fcntl, fcntl)
diff --git a/sysdeps/mach/hurd/fcntlbits.h b/sysdeps/mach/hurd/fcntlbits.h
new file mode 100644
index 0000000..8a5e4cd
--- /dev/null
+++ b/sysdeps/mach/hurd/fcntlbits.h
@@ -0,0 +1,178 @@
+/* O_*, F_*, FD_* bit values for GNU.
+Copyright (C) 1993, 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. */
+
+#ifndef _FCNTLBITS_H
+
+#define _FCNTLBITS_H 1
+
+
+/* File access modes. These are understood by io servers; they can be
+ passed in `dir_lookup', and are returned by `io_get_openmodes'.
+ Consequently they can be passed to `open', `hurd_file_name_lookup', and
+ `file_name_lookup'; and are returned by `fcntl' with the F_GETFL
+ command. */
+
+/* In GNU, read and write are bits (unlike BSD). */
+#ifdef __USE_GNU
+#define O_READ O_RDONLY /* Open for reading. */
+#define O_WRITE O_WRONLY /* Open for writing. */
+#define O_EXEC 0x0004 /* Open for execution. */
+#endif
+/* POSIX.1 standard names. */
+#define O_RDONLY 0x0001 /* Open read-only. */
+#define O_WRONLY 0x0002 /* Open write-only. */
+#define O_RDWR (O_RDONLY|O_WRONLY) /* Open for reading and writing. */
+#define O_ACCMODE O_RDWR /* Mask for file access modes. */
+
+
+
+/* File name translation flags. These are understood by io servers;
+ they can be passed in `dir_lookup', and consequently to `open',
+ `hurd_file_name_lookup', and `file_name_lookup'. */
+
+#define O_CREAT 0x0010 /* Create file if it doesn't exist. */
+#define O_EXCL 0x0020 /* Fail if file already exists. */
+#ifdef __USE_GNU
+#define O_NOLINK 0x0040 /* No name mappings on final component. */
+#define O_NOTRANS 0x0080 /* No translator on final component. */
+#endif
+
+
+/* I/O operating modes. These are understood by io servers; they can be
+ passed in `dir_lookup' and set or fetched with `io_*_openmodes'.
+ Consequently they can be passed to `open', `hurd_file_name_lookup',
+ `file_name_lookup', and `fcntl' with the F_SETFL command; and are
+ returned by `fcntl' with the F_GETFL command. */
+
+#define O_APPEND 0x0100 /* Writes always append to the file. */
+#ifdef __USE_BSD
+#define O_ASYNC 0x0200 /* Send SIGIO to owner when data is ready. */
+#define O_FSYNC 0x0400 /* Synchronous writes. */
+#define O_SYNC O_FSYNC
+#endif
+#ifdef __USE_GNU
+#define O_NOATIME 0x0800 /* Don't set access time on read (owner). */
+#endif
+
+
+/* The name O_NONBLOCK is unfortunately overloaded; it is both a file name
+ translation flag and an I/O operating mode. O_NDELAY is the deprecated
+ BSD name for the same flag, overloaded in the same way.
+
+ When used in `dir_lookup' (and consequently `open', `hurd_file_name_lookup',
+ or `file_name_lookup'), O_NONBLOCK says the open should return immediately
+ instead of blocking for any significant length of time (e.g., to wait
+ for carrier detect on a serial line). It is also saved as an I/O
+ operating mode, and after open has the following meaning.
+
+ When used in `io_*_openmodes' (and consequently `fcntl' with the F_SETFL
+ command), the O_NONBLOCK flag means to do nonblocking i/o: any i/o
+ operation that would block for any significant length of time will instead
+ fail with EAGAIN. */
+
+#define O_NONBLOCK 0x0008 /* Non-blocking open or non-blocking I/O. */
+#ifdef __USE_BSD
+#define O_NDELAY O_NONBLOCK /* Deprecated. */
+#endif
+
+
+#ifdef __USE_GNU
+/* Mask of bits which are understood by io servers. */
+#define O_HURD 0xffff /* XXX name? want this? */
+#endif
+
+
+/* Open-time action flags. These are understood by `hurd_file_name_lookup'
+ and consequently by `open' and `file_name_lookup'. They are not preserved
+ once the file has been opened. */
+
+#define O_TRUNC 0x00010000 /* Truncate file to zero length. */
+#ifdef __USE_MISC
+#define O_SHLOCK 0x00020000 /* Open with shared file lock. */
+#define O_EXLOCK 0x00040000 /* Open with exclusive file lock. */
+#endif
+
+
+/* Controlling terminal flags. These are understood only by `open',
+ and are not preserved once the file has been opened. */
+
+#ifdef __USE_GNU
+#define O_IGNORE_CTTY 0x00080000 /* Don't do any ctty magic at all. */
+#endif
+/* `open' never assigns a controlling terminal in GNU. */
+#define O_NOCTTY 0 /* Don't assign a controlling terminal. */
+
+
+#ifdef __USE_BSD
+/* Bits in the file status flags returned by F_GETFL. */
+#define FREAD O_RDONLY
+#define FWRITE O_WRONLY
+
+/* Traditional BSD names the O_* bits. */
+#define FASYNC O_ASYNC
+#define FCREAT O_CREAT
+#define FEXCL O_EXCL
+#define FTRUNC O_TRUNC
+#define FNOCTTY O_NOCTTY
+#define FFSYNC O_FSYNC
+#define FSYNC O_SYNC
+#define FAPPEND O_APPEND
+#define FNONBLOCK O_NONBLOCK
+#define FNDELAY O_NDELAY
+#endif
+
+
+/* Values for the second argument to `fcntl'. */
+#define F_DUPFD 0 /* Duplicate file descriptor. */
+#define F_GETFD 1 /* Get file descriptor flags. */
+#define F_SETFD 2 /* Set file descriptor flags. */
+#define F_GETFL 3 /* Get file status flags. */
+#define F_SETFL 4 /* Set file status flags. */
+#ifdef __USE_BSD
+#define F_GETOWN 5 /* Get owner (receiver of SIGIO). */
+#define F_SETOWN 6 /* Set owner (receiver of SIGIO). */
+#endif
+#define F_GETLK 7 /* Get record locking info. */
+#define F_SETLK 8 /* Set record locking info (non-blocking). */
+#define F_SETLKW 9 /* Set record locking info (blocking). */
+
+/* File descriptor flags used with F_GETFD and F_SETFD. */
+#define FD_CLOEXEC 1 /* Close on exec. */
+
+
+#include <gnu/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. */
+struct flock
+ {
+ int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+
+/* Values for the `l_type' field of a `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/fdopen.c b/sysdeps/mach/hurd/fdopen.c
new file mode 100644
index 0000000..3fdd742
--- /dev/null
+++ b/sysdeps/mach/hurd/fdopen.c
@@ -0,0 +1,69 @@
+/* Copyright (C) 1991, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <hurd/fd.h>
+#include <fcntl.h>
+#include <hurd/io.h>
+
+/* Defined in fopen.c. */
+extern int EXFUN(__getmode, (CONST char *mode, __io_mode *mptr));
+
+/* Open a new stream on a given system file descriptor. */
+FILE *
+DEFUN(fdopen, (fd, mode), int fd AND CONST char *mode)
+{
+ FILE *stream;
+ __io_mode m;
+ struct hurd_fd *d;
+ error_t err;
+ int openmodes;
+
+ if (!__getmode (mode, &m))
+ return NULL;
+
+ HURD_CRITICAL_BEGIN;
+ d = _hurd_fd_get (fd);
+ if (d == NULL)
+ err = EBADF;
+ else
+ err = HURD_FD_PORT_USE (d, __io_get_openmodes (port, &openmodes));
+ HURD_CRITICAL_END;
+
+ if (err)
+ return __hurd_dfail (fd, err), NULL;
+
+ /* Check the access mode. */
+ if ((m.__read && !(openmodes & O_READ)) ||
+ (m.__write && !(openmodes & O_WRITE)))
+ {
+ errno = EBADF;
+ return NULL;
+ }
+
+ stream = __newstream ();
+ if (stream == NULL)
+ return NULL;
+
+ stream->__cookie = d;
+ stream->__mode = m;
+
+ return stream;
+}
diff --git a/sysdeps/mach/hurd/fexecve.c b/sysdeps/mach/hurd/fexecve.c
new file mode 100644
index 0000000..e4f2cda
--- /dev/null
+++ b/sysdeps/mach/hurd/fexecve.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1993, 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. */
+
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <errno.h>
+
+/* Execute the file FD refers to, overlaying the running program image. */
+
+int
+fexecve (int fd, char *const argv[], char *const envp[])
+{
+ error_t err = HURD_DPORT_USE (fd, _hurd_exec (__mach_task_self (), port,
+ argv, envp));
+ if (! err)
+ err = EGRATUITOUS;
+ return __hurd_fail (err);
+}
diff --git a/sysdeps/mach/hurd/flock.c b/sysdeps/mach/hurd/flock.c
new file mode 100644
index 0000000..6154fd2
--- /dev/null
+++ b/sysdeps/mach/hurd/flock.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1992, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/file.h>
+#include <hurd/fd.h>
+#include <hurd/fs.h>
+
+/* Apply or remove an advisory lock, according to OPERATION,
+ on the file FD refers to. */
+int
+DEFUN(__flock, (fd, operation),
+ int fd AND int operation)
+{
+ error_t err;
+
+ if (err = HURD_DPORT_USE (fd, __file_lock (port, operation)))
+ return __hurd_dfail (fd, err);
+
+ return 0;
+}
+
+weak_alias (__flock, flock)
diff --git a/sysdeps/mach/hurd/fork.c b/sysdeps/mach/hurd/fork.c
new file mode 100644
index 0000000..b9170f1
--- /dev/null
+++ b/sysdeps/mach/hurd/fork.c
@@ -0,0 +1,574 @@
+/* Copyright (C) 1994, 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. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/signal.h>
+#include <setjmp.h>
+#include "thread_state.h"
+#include <sysdep.h> /* For stack growth direction. */
+#include "set-hooks.h"
+#include <assert.h>
+#include "hurdmalloc.h" /* XXX */
+
+extern void _hurd_longjmp_thread_state (struct machine_thread_state *,
+ jmp_buf env, int value);
+
+
+/* Things that want to be locked while forking. */
+struct
+ {
+ size_t n;
+ struct mutex *locks[0];
+ } _hurd_fork_locks;
+
+
+/* Things that want to be called before we fork, to prepare the parent for
+ task_create, when the new child task will inherit our address space. */
+DEFINE_HOOK (_hurd_fork_prepare_hook, (void));
+
+/* Things that want to be called when we are forking, with the above all
+ locked. They are passed the task port of the child. The child process
+ is all set up except for doing proc_child, and has no threads yet. */
+DEFINE_HOOK (_hurd_fork_setup_hook, (void));
+
+/* Things to be run in the child fork. */
+DEFINE_HOOK (_hurd_fork_child_hook, (void));
+
+/* Things to be run in the parent fork. */
+DEFINE_HOOK (_hurd_fork_parent_hook, (void));
+
+
+/* Clone the calling process, creating an exact copy.
+ Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+pid_t
+__fork (void)
+{
+ jmp_buf env;
+ pid_t pid;
+ size_t i;
+ error_t err;
+ thread_t thread_self = __mach_thread_self ();
+ struct hurd_sigstate *volatile ss;
+ sigset_t pending;
+
+ void unlockss (void)
+ {
+ __spin_lock (&ss->lock);
+ ss->critical_section = 0;
+ pending = ss->pending & ~ss->blocked;
+ __spin_unlock (&ss->lock);
+ /* XXX Copying mutex into child and calling mutex_unlock lossy. */
+ __mutex_unlock (&_hurd_siglock);
+ ss = NULL; /* Make sure we crash if we use it again. */
+ }
+
+ ss = _hurd_self_sigstate ();
+ __spin_lock (&ss->lock);
+ ss->critical_section = 1;
+ __spin_unlock (&ss->lock);
+ __mutex_lock (&_hurd_siglock);
+
+ if (! setjmp (env))
+ {
+ process_t newproc;
+ task_t newtask;
+ thread_t thread, sigthread;
+ mach_port_urefs_t thread_refs, sigthread_refs;
+ struct machine_thread_state state;
+ mach_msg_type_number_t statecount;
+ mach_port_t *portnames = NULL;
+ mach_msg_type_number_t nportnames = 0;
+ mach_port_type_t *porttypes = NULL;
+ mach_msg_type_number_t nporttypes = 0;
+ thread_t *threads = NULL;
+ mach_msg_type_number_t nthreads = 0;
+ int ports_locked = 0;
+
+ /* Run things that prepare for forking before we create the task. */
+ RUN_HOOK (_hurd_fork_prepare_hook, ());
+
+ /* Lock things that want to be locked before we fork. */
+ for (i = 0; i < _hurd_fork_locks.n; ++i)
+ __mutex_lock (_hurd_fork_locks.locks[i]);
+
+ newtask = MACH_PORT_NULL;
+ thread = sigthread = MACH_PORT_NULL;
+ newproc = MACH_PORT_NULL;
+
+ /* Lock all the port cells for the standard ports while we copy the
+ address space. We want to insert all the send rights into the
+ child with the same names. */
+ for (i = 0; i < _hurd_nports; ++i)
+ __spin_lock (&_hurd_ports[i].lock);
+ ports_locked = 1;
+
+ /* Create the child task. It will inherit a copy of our memory. */
+ if (err = __task_create (__mach_task_self (), 1, &newtask))
+ goto lose;
+
+ /* Fetch the names of all ports used in this task. */
+ if (err = __mach_port_names (__mach_task_self (),
+ &portnames, &nportnames,
+ &porttypes, &nporttypes))
+ goto lose;
+ if (nportnames != nporttypes)
+ {
+ err = EGRATUITOUS;
+ goto lose;
+ }
+
+ /* Get send rights for all the threads in this task.
+ We want to avoid giving these rights to the child. */
+ if (err = __task_threads (__mach_task_self (), &threads, &nthreads))
+ goto lose;
+
+ /* Get the child process's proc server port. We will insert it into
+ the child with the same name as we use for our own proc server
+ port; and we will need it to set the child's message port. */
+ if (err = __proc_task2proc (_hurd_ports[INIT_PORT_PROC].port,
+ newtask, &newproc))
+ goto lose;
+
+ /* Insert all our port rights into the child task. */
+ thread_refs = sigthread_refs = 0;
+ for (i = 0; i < nportnames; ++i)
+ {
+ if (porttypes[i] & MACH_PORT_TYPE_RECEIVE)
+ {
+ /* This is a receive right. We want to give the child task
+ its own new receive right under the same name. */
+ err = __mach_port_allocate_name (newtask,
+ MACH_PORT_RIGHT_RECEIVE,
+ portnames[i]);
+ if (err == KERN_NAME_EXISTS)
+ {
+ /* It already has a right under this name (?!). Well,
+ there is this bizarre old Mach IPC feature (in #ifdef
+ MACH_IPC_COMPAT in the ukernel) which results in new
+ tasks getting a new receive right for task special
+ port number 2. What else might be going on I'm not
+ sure. So let's check. */
+#if !MACH_IPC_COMPAT
+#define TASK_NOTIFY_PORT 2
+#endif
+ assert (({ mach_port_t thisport, notify_port;
+ mach_msg_type_name_t poly;
+ (__task_get_special_port (newtask,
+ TASK_NOTIFY_PORT,
+ &notify_port) == 0 &&
+ __mach_port_extract_right
+ (newtask,
+ portnames[i],
+ MACH_MSG_TYPE_MAKE_SEND,
+ &thisport, &poly) == 0 &&
+ (thisport == notify_port) &&
+ __mach_port_deallocate (__mach_task_self (),
+ thisport) == 0 &&
+ __mach_port_deallocate (__mach_task_self (),
+ notify_port) == 0);
+ }));
+ }
+ else if (err)
+ goto lose;
+ if (porttypes[i] & MACH_PORT_TYPE_SEND)
+ {
+ /* Give the child as many send rights for its receive
+ right as we have for ours. */
+ mach_port_urefs_t refs;
+ mach_port_t port;
+ mach_msg_type_name_t poly;
+ if (err = __mach_port_get_refs (__mach_task_self (),
+ portnames[i],
+ MACH_PORT_RIGHT_SEND,
+ &refs))
+ goto lose;
+ if (err = __mach_port_extract_right (newtask,
+ portnames[i],
+ MACH_MSG_TYPE_MAKE_SEND,
+ &port, &poly))
+ goto lose;
+ if (portnames[i] == _hurd_msgport)
+ {
+ /* We just created a receive right for the child's
+ message port and are about to insert send rights
+ for it. Now, while we happen to have a send right
+ for it, give it to the proc server. */
+ mach_port_t old;
+ if (err = __proc_setmsgport (newproc, port, &old))
+ goto lose;
+ if (old != MACH_PORT_NULL)
+ /* XXX what to do here? */
+ __mach_port_deallocate (__mach_task_self (), old);
+ }
+ if (err = __mach_port_insert_right (newtask,
+ portnames[i],
+ port,
+ MACH_MSG_TYPE_MOVE_SEND))
+ goto lose;
+ if (refs > 1 &&
+ (err = __mach_port_mod_refs (newtask,
+ portnames[i],
+ MACH_PORT_RIGHT_SEND,
+ refs - 1)))
+ goto lose;
+ }
+ if (porttypes[i] & MACH_PORT_TYPE_SEND_ONCE)
+ {
+ /* Give the child a send-once right for its receive right,
+ since we have one for ours. */
+ mach_port_t port;
+ mach_msg_type_name_t poly;
+ if (err = __mach_port_extract_right
+ (newtask,
+ portnames[i],
+ MACH_MSG_TYPE_MAKE_SEND_ONCE,
+ &port, &poly))
+ goto lose;
+ if (err = __mach_port_insert_right
+ (newtask,
+ portnames[i], port,
+ MACH_MSG_TYPE_MOVE_SEND_ONCE))
+ goto lose;
+ }
+ }
+ else if (porttypes[i] & MACH_PORT_TYPE_SEND)
+ {
+ /* This is a send right or a dead name.
+ Give the child as many references for it as we have. */
+ mach_port_urefs_t refs, *record_refs = NULL;
+ mach_port_t insert;
+ if (portnames[i] == newtask)
+ /* Skip the name we use for the child's task port. */
+ continue;
+ if (portnames[i] == __mach_task_self ())
+ /* For the name we use for our own task port,
+ insert the child's task port instead. */
+ insert = newtask;
+ else if (portnames[i] == _hurd_ports[INIT_PORT_PROC].port)
+ {
+ /* Get the proc server port for the new task. */
+ if (err = __proc_task2proc (portnames[i], newtask, &insert))
+ goto lose;
+ }
+ else if (portnames[i] == thread_self)
+ {
+ /* For the name we use for our own thread port, we will
+ insert the thread port for the child main user thread
+ after we create it. */
+ insert = MACH_PORT_NULL;
+ record_refs = &thread_refs;
+ /* Allocate a dead name right for this name as a
+ placeholder, so the kernel will not chose this name
+ for any other new port (it might use it for one of the
+ rights created when a thread is created). */
+ if (err = __mach_port_allocate_name
+ (newtask, MACH_PORT_RIGHT_DEAD_NAME, portnames[i]))
+ goto lose;
+ }
+ else if (portnames[i] == _hurd_msgport_thread)
+ /* For the name we use for our signal thread's thread port,
+ we will insert the thread port for the child's signal
+ thread after we create it. */
+ {
+ insert = MACH_PORT_NULL;
+ record_refs = &sigthread_refs;
+ /* Allocate a dead name right as a placeholder. */
+ if (err = __mach_port_allocate_name
+ (newtask, MACH_PORT_RIGHT_DEAD_NAME, portnames[i]))
+ goto lose;
+ }
+ else
+ {
+ /* Skip the name we use for any of our own thread ports. */
+ mach_msg_type_number_t j;
+ for (j = 0; j < nthreads; ++j)
+ if (portnames[i] == threads[j])
+ break;
+ if (j < nthreads)
+ continue;
+
+ insert = portnames[i];
+ }
+ /* Find out how many user references we have for
+ the send right with this name. */
+ if (err = __mach_port_get_refs (__mach_task_self (),
+ portnames[i],
+ MACH_PORT_RIGHT_SEND,
+ record_refs ?: &refs))
+ goto lose;
+ if (insert == MACH_PORT_NULL)
+ continue;
+ /* Insert the chosen send right into the child. */
+ err = __mach_port_insert_right (newtask,
+ portnames[i],
+ insert,
+ MACH_MSG_TYPE_COPY_SEND);
+ if (err == KERN_NAME_EXISTS)
+ {
+ /* It already has a send right under this name (?!).
+ Well, it starts out with a send right for its task
+ port, and inherits the bootstrap and exception ports
+ from us. */
+ mach_port_t childport;
+ mach_msg_type_name_t poly;
+ assert (__mach_port_extract_right (newtask, portnames[i],
+ MACH_MSG_TYPE_COPY_SEND,
+ &childport, &poly) == 0 &&
+ childport == insert &&
+ __mach_port_deallocate (__mach_task_self (),
+ childport) == 0);
+ }
+ else if (err)
+ goto lose;
+ /* Give the child as many user references as we have. */
+ if (refs > 1 &&
+ (err = __mach_port_mod_refs (newtask,
+ portnames[i],
+ MACH_PORT_RIGHT_SEND,
+ refs - 1)))
+ goto lose;
+ }
+ }
+
+ /* Unlock the standard port cells. The child must unlock its own
+ copies too. */
+ for (i = 0; i < _hurd_nports; ++i)
+ __spin_unlock (&_hurd_ports[i].lock);
+ ports_locked = 0;
+
+ /* Unlock the signal state. The child must unlock its own copy too. */
+ unlockss ();
+
+ /* Create the child main user thread and signal thread. */
+ if ((err = __thread_create (newtask, &thread)) ||
+ (err = __thread_create (newtask, &sigthread)))
+ goto lose;
+
+ /* Insert send rights for those threads. We previously allocated
+ dead name rights with the names we want to give the thread ports
+ in the child as placeholders. Now deallocate them so we can use
+ the names. */
+ if ((err = __mach_port_deallocate (newtask, thread_self)) ||
+ (err = __mach_port_insert_right (newtask, thread_self,
+ thread, MACH_MSG_TYPE_COPY_SEND)))
+ goto lose;
+ /* We have one extra user reference created at the beginning of this
+ function, accounted for by mach_port_names (and which will thus be
+ accounted for in the child below). This extra right gets consumed
+ in the child by the store into _hurd_sigthread in the child fork. */
+ if (thread_refs > 1 &&
+ (err = __mach_port_mod_refs (newtask, thread_self,
+ MACH_PORT_RIGHT_SEND,
+ thread_refs - 1)))
+ goto lose;
+ if ((_hurd_msgport_thread != MACH_PORT_NULL) /* Let user have none. */
+ && ((err = __mach_port_deallocate (newtask, _hurd_msgport_thread)) ||
+ (err = __mach_port_insert_right (newtask, _hurd_msgport_thread,
+ sigthread,
+ MACH_MSG_TYPE_COPY_SEND))))
+ goto lose;
+ if (sigthread_refs > 1 &&
+ (err = __mach_port_mod_refs (newtask, _hurd_msgport_thread,
+ MACH_PORT_RIGHT_SEND,
+ sigthread_refs - 1)))
+ goto lose;
+
+ /* This seems like a convenient juncture to copy the proc server's
+ idea of what addresses our argv and envp are found at from the
+ parent into the child. Since we happen to know that the child
+ shares our memory image, it is we who should do this copying. */
+ {
+ vm_address_t argv, envp;
+ err = (__USEPORT (PROC, __proc_get_arg_locations (port, &argv, &envp))
+ ?: __proc_set_arg_locations (newproc, argv, envp));
+ if (err)
+ goto lose;
+ }
+
+ /* Set the child signal thread up to run the msgport server function
+ using the same signal thread stack copied from our address space.
+ We fetch the state before longjmp'ing it so that miscellaneous
+ registers not affected by longjmp (such as i386 segment registers)
+ are in their normal default state. */
+ statecount = MACHINE_THREAD_STATE_COUNT;
+ if (err = __thread_get_state (_hurd_msgport_thread,
+ MACHINE_THREAD_STATE_FLAVOR,
+ (natural_t *) &state, &statecount))
+ goto lose;
+#if STACK_GROWTH_UP
+ state.SP = __hurd_sigthread_stack_base;
+#else
+ state.SP = __hurd_sigthread_stack_end;
+#endif
+ MACHINE_THREAD_STATE_SET_PC (&state,
+ (unsigned long int) _hurd_msgport_receive);
+ if (err = __thread_set_state (sigthread, MACHINE_THREAD_STATE_FLAVOR,
+ (natural_t *) &state, statecount))
+ goto lose;
+ /* We do not thread_resume SIGTHREAD here because the child
+ fork needs to do more setup before it can take signals. */
+
+ /* Set the child user thread up to return 1 from the setjmp above. */
+ _hurd_longjmp_thread_state (&state, env, 1);
+ if (err = __thread_set_state (thread, MACHINE_THREAD_STATE_FLAVOR,
+ (natural_t *) &state, statecount))
+ goto lose;
+
+ /* Get the PID of the child from the proc server. We must do this
+ before calling proc_child below, because at that point any
+ authorized POSIX.1 process may kill the child task with SIGKILL. */
+ if (err = __USEPORT (PROC, __proc_task2pid (port, newtask, &pid)))
+ goto lose;
+
+ /* Register the child with the proc server. It is important that
+ this be that last thing we do before starting the child thread
+ running. Once proc_child has been done for the task, it appears
+ as a POSIX.1 process. Any errors we get must be detected before
+ this point, and the child must have a message port so it responds
+ to POSIX.1 signals. */
+ if (err = __USEPORT (PROC, __proc_child (port, newtask)))
+ goto lose;
+
+ /* This must be the absolutely last thing we do; we can't assume that
+ the child will remain alive for even a moment once we do this. We
+ ignore errors because we have committed to the fork and are not
+ allowed to return them after the process becomes visible to
+ POSIX.1 (which happened right above when we called proc_child). */
+ (void) __thread_resume (thread);
+
+ lose:
+ if (ports_locked)
+ for (i = 0; i < _hurd_nports; ++i)
+ __spin_unlock (&_hurd_ports[i].lock);
+
+ if (newtask != MACH_PORT_NULL)
+ {
+ if (err)
+ __task_terminate (newtask);
+ __mach_port_deallocate (__mach_task_self (), newtask);
+ }
+ if (thread != MACH_PORT_NULL)
+ __mach_port_deallocate (__mach_task_self (), thread);
+ if (sigthread != MACH_PORT_NULL)
+ __mach_port_deallocate (__mach_task_self (), sigthread);
+ if (newproc != MACH_PORT_NULL)
+ __mach_port_deallocate (__mach_task_self (), newproc);
+ if (thread_self != MACH_PORT_NULL)
+ __mach_port_deallocate (__mach_task_self (), thread_self);
+
+ if (portnames)
+ __vm_deallocate (__mach_task_self (),
+ (vm_address_t) portnames,
+ nportnames * sizeof (*portnames));
+ if (porttypes)
+ __vm_deallocate (__mach_task_self (),
+ (vm_address_t) porttypes,
+ nporttypes * sizeof (*porttypes));
+ if (threads)
+ {
+ for (i = 0; i < nthreads; ++i)
+ __mach_port_deallocate (__mach_task_self (), threads[i]);
+ __vm_deallocate (__mach_task_self (),
+ (vm_address_t) threads,
+ nthreads * sizeof (*threads));
+ }
+
+ /* Run things that want to run in the parent to restore it to
+ normality. Usually prepare hooks and parent hooks are
+ symmetrical: the prepare hook arrests state in some way for the
+ fork, and the parent hook restores the state for the parent to
+ continue executing normally. */
+ RUN_HOOK (_hurd_fork_parent_hook, ());
+ }
+ else
+ {
+ struct hurd_sigstate *oldstates;
+
+ /* We are the child task. Unlock the standard port cells, which were
+ locked in the parent when we copied its memory. The parent has
+ inserted send rights with the names that were in the cells then. */
+ for (i = 0; i < _hurd_nports; ++i)
+ __spin_unlock (&_hurd_ports[i].lock);
+
+ /* We are the only thread in this new task, so we will
+ take the task-global signals. */
+ _hurd_sigthread = thread_self;
+
+ /* Unchain the sigstate structures for threads that existed in the
+ parent task but don't exist in this task (the child process).
+ Delay freeing them until later because some of the further setup
+ and unlocking might be required for free to work. */
+ oldstates = _hurd_sigstates;
+ if (oldstates == ss)
+ oldstates = ss->next;
+ else
+ {
+ while (_hurd_sigstates->next != ss)
+ _hurd_sigstates = _hurd_sigstates->next;
+ _hurd_sigstates->next = ss->next;
+ }
+ ss->next = NULL;
+ _hurd_sigstates = ss;
+
+ /* Unlock our copies of the signal state locks. */
+ unlockss ();
+
+ /* Fetch our new process IDs from the proc server. No need to
+ refetch our pgrp; it is always inherited from the parent (so
+ _hurd_pgrp is already correct), and the proc server will send us a
+ proc_newids notification when it changes. */
+ err = __USEPORT (PROC, __proc_getpids (port, &_hurd_pid, &_hurd_ppid,
+ &_hurd_orphaned));
+
+ /* Run things that want to run in the child task to set up. */
+ RUN_HOOK (_hurd_fork_child_hook, ());
+
+ /* Set up proc server-assisted fault recovery for the signal thread. */
+ _hurdsig_fault_init ();
+
+ /* Start the signal thread listening on the message port. */
+ if (!err)
+ err = __thread_resume (_hurd_msgport_thread);
+
+ /* Free the old sigstate structures. */
+ while (oldstates != NULL)
+ {
+ struct hurd_sigstate *next = oldstates->next;
+ free (oldstates);
+ oldstates = next;
+ }
+ /* XXX what to do if we have any errors here? */
+
+ pid = 0;
+ }
+
+ /* Unlock things we locked before creating the child task.
+ They are locked in both the parent and child tasks. */
+ for (i = 0; i < _hurd_fork_locks.n; ++i)
+ __mutex_unlock (_hurd_fork_locks.locks[i]);
+
+ if (pending)
+ __msg_sig_post (_hurd_msgport, 0, __mach_task_self ());
+
+ return err ? __hurd_fail (err) : pid;
+}
+
+weak_alias (__fork, fork)
diff --git a/sysdeps/mach/hurd/fstat.c b/sysdeps/mach/hurd/fstat.c
new file mode 100644
index 0000000..5341e3e
--- /dev/null
+++ b/sysdeps/mach/hurd/fstat.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+
+/* Get information about the file descriptor FD in BUF. */
+int
+DEFUN(__fstat, (fd, buf), int fd AND struct stat *buf)
+{
+ error_t err;
+
+ if (err = HURD_DPORT_USE (fd, __io_stat (port, buf)))
+ return __hurd_dfail (fd, err);
+
+ return 0;
+}
+
+weak_alias (__fstat, fstat)
diff --git a/sysdeps/mach/hurd/fsync.c b/sysdeps/mach/hurd/fsync.c
new file mode 100644
index 0000000..adfe980
--- /dev/null
+++ b/sysdeps/mach/hurd/fsync.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+
+/* Make all changes done to FD actually appear on disk. */
+int
+DEFUN(fsync, (fd), int fd)
+{
+ error_t err = HURD_DPORT_USE (fd, __file_sync (port, 1));
+ if (err)
+ return __hurd_dfail (fd, err);
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/ftruncate.c b/sysdeps/mach/hurd/ftruncate.c
new file mode 100644
index 0000000..23a5e79
--- /dev/null
+++ b/sysdeps/mach/hurd/ftruncate.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+
+/* Truncate the file FD refers to to LENGTH bytes. */
+int
+DEFUN(ftruncate, (fd, length),
+ int fd AND off_t length)
+{
+ error_t err;
+ if (err = HURD_DPORT_USE (fd, __file_truncate (port, length)))
+ return __hurd_dfail (fd, err);
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/getcwd.c b/sysdeps/mach/hurd/getcwd.c
new file mode 100644
index 0000000..c0d9bcd
--- /dev/null
+++ b/sysdeps/mach/hurd/getcwd.c
@@ -0,0 +1,250 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <hurd.h>
+#include <hurd/port.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+
+/* Get the pathname of the current working directory, and put it in SIZE
+ bytes of BUF. Returns NULL if the directory couldn't be determined or
+ SIZE was too small. If successful, returns BUF. In GNU, if BUF is
+ NULL, an array is allocated with `malloc'; the array is SIZE bytes long,
+ unless SIZE <= 0, in which case it is as big as necessary. */
+
+char *
+getcwd (char *buf, size_t size)
+{
+ error_t err;
+ dev_t rootdev, thisdev;
+ ino_t rootino, thisino;
+ char *file_name;
+ register char *file_namep;
+ struct stat st;
+ file_t parent;
+ char *dirbuf = NULL;
+ unsigned int dirbufsize = 0;
+ file_t crdir;
+ struct hurd_userlink crdir_ulink;
+
+ inline void cleanup (void)
+ {
+ _hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir);
+ __mach_port_deallocate (__mach_task_self (), parent);
+
+ if (dirbuf != NULL)
+ __vm_deallocate (__mach_task_self (),
+ (vm_address_t) dirbuf, dirbufsize);
+ }
+
+
+ if (size == 0)
+ {
+ if (buf != NULL)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ size = FILENAME_MAX * 4 + 1; /* Good starting guess. */
+ }
+
+ if (buf != NULL)
+ file_name = buf;
+ else
+ {
+ file_name = malloc (size);
+ if (file_name == NULL)
+ return NULL;
+ }
+
+ file_namep = file_name + size;
+ *--file_namep = '\0';
+
+ /* Get a port to our root directory and stat it. */
+
+ crdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink);
+ if (err = __io_stat (crdir, &st))
+ {
+ _hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir);
+ return __hurd_fail (err), NULL;
+ }
+ rootdev = st.st_dev;
+ rootino = st.st_ino;
+
+ /* Get a port to our current working directory and stat it. */
+
+ if (err = __USEPORT (CWDIR, __mach_port_mod_refs (__mach_task_self (),
+ (parent = port),
+ MACH_PORT_RIGHT_SEND,
+ 1)))
+ {
+ _hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir);
+ return __hurd_fail (err), NULL;
+ }
+ if (err = __io_stat (parent, &st))
+ {
+ cleanup ();
+ return __hurd_fail (err), NULL;
+ }
+
+ thisdev = st.st_dev;
+ thisino = st.st_ino;
+
+ while (!(thisdev == rootdev && thisino == rootino))
+ {
+ /* PARENT is a port to the directory we are currently on;
+ THISDEV and THISINO are its device and node numbers.
+ Look in its parent (..) for a file with the same numbers. */
+
+ struct dirent *d;
+ dev_t dotdev;
+ ino_t dotino;
+ int mount_point;
+ file_t newp;
+ char *dirdata;
+ unsigned int dirdatasize;
+ int direntry, nentries;
+
+ /* Look at the parent directory. */
+ if (err = __hurd_file_name_lookup (crdir, parent, "..", O_READ, 0, &newp))
+ goto lose;
+ __mach_port_deallocate (__mach_task_self (), parent);
+ parent = newp;
+
+ /* Figure out if this directory is a mount point. */
+ if (err = __io_stat (parent, &st))
+ goto lose;
+ dotdev = st.st_dev;
+ dotino = st.st_ino;
+ mount_point = dotdev != thisdev;
+
+ /* Search for the last directory. */
+ direntry = 0;
+ dirdata = dirbuf;
+ dirdatasize = dirbufsize;
+ while (!(err = __dir_readdir (parent, &dirdata, &dirdatasize,
+ direntry, -1, 0, &nentries)) &&
+ nentries != 0)
+ {
+ /* We have a block of directory entries. */
+
+ unsigned int offset;
+
+ direntry += nentries;
+
+ if (dirdata != dirbuf)
+ {
+ /* The data was passed out of line, so our old buffer is no
+ longer useful. Deallocate the old buffer and reset our
+ information for the new buffer. */
+ __vm_deallocate (__mach_task_self (),
+ (vm_address_t) dirbuf, dirbufsize);
+ dirbuf = dirdata;
+ dirbufsize = round_page (dirdatasize);
+ }
+
+ /* Iterate over the returned directory entries, looking for one
+ whose file number is THISINO. */
+
+ offset = 0;
+ while (offset < dirdatasize)
+ {
+ d = (struct dirent *) &dirdata[offset];
+ offset += d->d_reclen;
+
+ /* Ignore `.' and `..'. */
+ if (d->d_name[0] == '.' &&
+ (d->d_namlen == 1 ||
+ (d->d_namlen == 2 && d->d_name[1] == '.')))
+ continue;
+
+ if (mount_point || d->d_ino == thisino)
+ {
+ file_t try;
+ if (err = __hurd_file_name_lookup (crdir, parent, d->d_name,
+ O_NOLINK, 0, &try))
+ goto lose;
+ err = __io_stat (try, &st);
+ __mach_port_deallocate (__mach_task_self (), try);
+ if (err)
+ goto lose;
+ if (st.st_dev == thisdev && st.st_ino == thisino)
+ break;
+ }
+ }
+ }
+
+ if (err)
+ goto lose;
+ else
+ {
+ /* Prepend the directory name just discovered. */
+
+ if (file_namep - file_name < d->d_namlen + 1)
+ {
+ if (buf != NULL)
+ {
+ errno = ERANGE;
+ return NULL;
+ }
+ else
+ {
+ size *= 2;
+ buf = realloc (file_name, size);
+ if (buf == NULL)
+ {
+ free (file_name);
+ return NULL;
+ }
+ file_namep = &buf[file_namep - file_name];
+ file_name = buf;
+ }
+ }
+ file_namep -= d->d_namlen;
+ (void) memcpy (file_namep, d->d_name, d->d_namlen);
+ *--file_namep = '/';
+ }
+
+ /* The next iteration will find the name of the directory we
+ just searched through. */
+ thisdev = dotdev;
+ thisino = dotino;
+ }
+
+ if (file_namep == &file_name[size - 1])
+ /* We found nothing and got all the way to the root.
+ So the root is our current directory. */
+ *--file_namep = '/';
+
+ memmove (file_name, file_namep, file_name + size - file_namep);
+ cleanup ();
+ return file_name;
+
+ lose:
+ cleanup ();
+ return NULL;
+}
diff --git a/sysdeps/mach/hurd/getdents.c b/sysdeps/mach/hurd/getdents.c
new file mode 100644
index 0000000..4de2eb3
--- /dev/null
+++ b/sysdeps/mach/hurd/getdents.c
@@ -0,0 +1,62 @@
+/* Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Ince
+
+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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <string.h>
+
+ssize_t
+DEFUN(__getdirentries, (fd, buf, nbytes, basep),
+ int fd AND PTR buf AND size_t nbytes AND off_t *basep)
+{
+ error_t err;
+ int entriesread;
+ char *data = buf;
+ mach_msg_type_number_t bytesread = nbytes;
+
+ /* Fault before taking any locks. */
+ *(volatile off_t *) basep = *basep;
+
+ err = HURD_DPORT_USE (fd, __dir_readdir (port, &data, &bytesread,
+ *basep, -1, nbytes, &entriesread));
+ if (err)
+ return __hurd_dfail (fd, err);
+
+ if (data != buf)
+ {
+ size_t copy = bytesread;
+ if (copy > nbytes)
+ /* The server has a violated the dir_readdir protocol. */
+ copy = nbytes;
+ memcpy (buf, data, copy);
+ __vm_deallocate (__mach_task_self (), (vm_address_t) data, bytesread);
+ bytesread = copy;
+ }
+
+ *basep += entriesread;
+
+ return bytesread;
+}
+
+weak_alias (__getdirentries, getdirentries)
+
diff --git a/sysdeps/mach/hurd/getdtsz.c b/sysdeps/mach/hurd/getdtsz.c
new file mode 100644
index 0000000..e506963
--- /dev/null
+++ b/sysdeps/mach/hurd/getdtsz.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+
+/* Return the maximum number of file descriptors the current process
+ could possibly have (until it raises the resource limit). */
+int
+DEFUN_VOID(__getdtablesize)
+{
+ int size;
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_dtable_lock);
+ size = _hurd_dtablesize;
+ __mutex_unlock (&_hurd_dtable_lock);
+ HURD_CRITICAL_END;
+ return size;
+}
+
+weak_alias (__getdtablesize, getdtablesize)
diff --git a/sysdeps/mach/hurd/getegid.c b/sysdeps/mach/hurd/getegid.c
new file mode 100644
index 0000000..88f6ea0
--- /dev/null
+++ b/sysdeps/mach/hurd/getegid.c
@@ -0,0 +1,58 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/id.h>
+
+/* Get the effective group ID of the calling process. */
+gid_t
+DEFUN_VOID(__getegid)
+{
+ error_t err;
+ gid_t egid;
+
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_id.lock);
+
+ if (err = _hurd_check_ids ())
+ {
+ errno = err;
+ egid = -1;
+ }
+ else if (_hurd_id.gen.ngids >= 1)
+ egid = _hurd_id.gen.gids[0];
+ else if (_hurd_id.aux.ngids >= 1)
+ /* We have no effective gids. Return the real gid. */
+ egid = _hurd_id.aux.gids[0];
+ else
+ {
+ /* We do not even have a real gid. */
+ errno = EGRATUITOUS;
+ egid = -1;
+ }
+
+ __mutex_unlock (&_hurd_id.lock);
+ HURD_CRITICAL_END;
+
+ return egid;
+}
+
+weak_alias (__getegid, getegid)
diff --git a/sysdeps/mach/hurd/geteuid.c b/sysdeps/mach/hurd/geteuid.c
new file mode 100644
index 0000000..416cd31
--- /dev/null
+++ b/sysdeps/mach/hurd/geteuid.c
@@ -0,0 +1,58 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/id.h>
+
+/* Get the effective user ID of the calling process. */
+uid_t
+DEFUN_VOID(__geteuid)
+{
+ error_t err;
+ uid_t euid;
+
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_id.lock);
+
+ if (err = _hurd_check_ids ())
+ {
+ errno = err;
+ euid = -1;
+ }
+ else if (_hurd_id.gen.nuids >= 1)
+ euid = _hurd_id.gen.uids[0];
+ else if (_hurd_id.aux.nuids >= 1)
+ /* We have no effective uids. Return the real uid. */
+ euid = _hurd_id.aux.uids[0];
+ else
+ {
+ /* We do not even have a real uid. */
+ errno = EGRATUITOUS;
+ euid = -1;
+ }
+
+ __mutex_unlock (&_hurd_id.lock);
+ HURD_CRITICAL_END;
+
+ return euid;
+}
+
+weak_alias (__geteuid, geteuid)
diff --git a/sysdeps/mach/hurd/getgid.c b/sysdeps/mach/hurd/getgid.c
new file mode 100644
index 0000000..0d1b27f
--- /dev/null
+++ b/sysdeps/mach/hurd/getgid.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/id.h>
+
+/* Get the real group ID of the calling process. */
+gid_t
+DEFUN_VOID(__getgid)
+{
+ error_t err;
+ gid_t gid;
+
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_id.lock);
+
+ if (err = _hurd_check_ids ())
+ {
+ errno = err;
+ gid = -1;
+ }
+ else if (_hurd_id.aux.ngids >= 1)
+ gid = _hurd_id.aux.gids[0];
+ else
+ {
+ /* We do not even have a real gid. */
+ errno = EGRATUITOUS;
+ gid = -1;
+ }
+
+ __mutex_unlock (&_hurd_id.lock);
+ HURD_CRITICAL_END;
+
+ return gid;
+}
+
+weak_alias (__getgid, getgid)
diff --git a/sysdeps/mach/hurd/getgroups.c b/sysdeps/mach/hurd/getgroups.c
new file mode 100644
index 0000000..d985d29
--- /dev/null
+++ b/sysdeps/mach/hurd/getgroups.c
@@ -0,0 +1,68 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/id.h>
+#include <string.h>
+
+int
+__getgroups (int n, gid_t *gidset)
+{
+ error_t err;
+ int ngids;
+ void *crit;
+
+ crit = _hurd_critical_section_lock ();
+ __mutex_lock (&_hurd_id.lock);
+
+ if (err = _hurd_check_ids ())
+ {
+ __mutex_unlock (&_hurd_id.lock);
+ _hurd_critical_section_unlock (crit);
+ return __hurd_fail (err);
+ }
+
+ ngids = _hurd_id.gen.ngids;
+
+ if (n != 0)
+ {
+ /* Copy the gids onto stack storage and then release the idlock. */
+ gid_t gids[ngids];
+ memcpy (gids, _hurd_id.gen.gids, sizeof (gids));
+ __mutex_unlock (&_hurd_id.lock);
+ _hurd_critical_section_unlock (crit);
+
+ /* Now that the lock is released, we can safely copy the
+ group set into the user's array, which might fault. */
+ if (ngids > n)
+ ngids = n;
+ memcpy (gidset, gids, ngids * sizeof (gid_t));
+ }
+ else
+ {
+ __mutex_unlock (&_hurd_id.lock);
+ _hurd_critical_section_unlock (crit);
+ }
+
+ return ngids;
+}
+
+weak_alias (__getgroups, getgroups)
diff --git a/sysdeps/mach/hurd/gethostid.c b/sysdeps/mach/hurd/gethostid.c
new file mode 100644
index 0000000..5a33092
--- /dev/null
+++ b/sysdeps/mach/hurd/gethostid.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+
+/* Return the current machine's Internet number. */
+long int
+DEFUN_VOID(gethostid)
+{
+ int hostid;
+ error_t err;
+ if (err = __USEPORT (PROC, __proc_gethostid (port, &hostid)))
+ return __hurd_fail (err);
+ return hostid;
+}
diff --git a/sysdeps/mach/hurd/gethostname.c b/sysdeps/mach/hurd/gethostname.c
new file mode 100644
index 0000000..94a0537
--- /dev/null
+++ b/sysdeps/mach/hurd/gethostname.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/port.h>
+#include <string.h>
+
+/* Put the name of the current host in no more than LEN bytes of NAME.
+ The result is null-terminated if LEN is large enough for the full
+ name and the terminator. */
+int
+DEFUN(__gethostname, (name, len),
+ char *name AND size_t len)
+{
+ error_t err;
+ char *buf = name;
+ mach_msg_type_number_t buflen = len;
+ if (err = __USEPORT (PROC, __proc_gethostname (port, &buf, &buflen)))
+ return __hurd_fail (err);
+ if (buf != name)
+ {
+ memcpy (name, buf, len < buflen ? len : buflen);
+ __vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
+ }
+ if (buflen > len)
+ return __hurd_fail (ENAMETOOLONG);
+ return 0;
+}
+
+weak_alias (__gethostname, gethostname)
diff --git a/sysdeps/mach/hurd/getitimer.c b/sysdeps/mach/hurd/getitimer.c
new file mode 100644
index 0000000..15c46ca
--- /dev/null
+++ b/sysdeps/mach/hurd/getitimer.c
@@ -0,0 +1,104 @@
+/* Copyright (C) 1994, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <hurd.h>
+
+/* XXX Temporary cheezoid implementation; see __setitmr.c. */
+
+/* These are defined in __setitmr.c. */
+extern spin_lock_t _hurd_itimer_lock;
+extern struct itimerval _hurd_itimerval;
+extern struct timeval _hurd_itimer_started;
+
+static inline void
+subtract_timeval (struct timeval *from, const struct timeval *subtract)
+{
+ from->tv_usec -= subtract->tv_usec;
+ from->tv_sec -= subtract->tv_sec;
+ while (from->tv_usec < 0)
+ {
+ --from->tv_sec;
+ from->tv_usec += 1000000;
+ }
+}
+
+/* Set *VALUE to the current setting of timer WHICH.
+ Return 0 on success, -1 on errors. */
+int
+DEFUN(__getitimer, (which, value),
+ enum __itimer_which which AND struct itimerval *value)
+{
+ struct itimerval val;
+ struct timeval elapsed;
+
+ switch (which)
+ {
+ default:
+ return __hurd_fail (EINVAL);
+
+ case ITIMER_VIRTUAL:
+ case ITIMER_PROF:
+ return __hurd_fail (ENOSYS);
+
+ case ITIMER_REAL:
+ break;
+ }
+
+ /* Get the time now. */
+ if (__gettimeofday (&elapsed, NULL) < 0)
+ return -1;
+
+ /* Extract the current timer setting; and the time it was set, so we can
+ calculate the time elapsed so far. */
+ HURD_CRITICAL_BEGIN;
+ __spin_lock (&_hurd_itimer_lock);
+ val = _hurd_itimerval;
+ subtract_timeval (&elapsed, &_hurd_itimer_started);
+ __spin_unlock (&_hurd_itimer_lock);
+ HURD_CRITICAL_END;
+
+ if ((val.it_value.tv_sec | val.it_value.tv_usec) != 0)
+ {
+ /* There is a pending alarm set. VAL indicates the interval it was
+ set for, relative to the time recorded in _hurd_itimer_started.
+ Now compensate for the time elapsed since to get the user's
+ conception of the current value of the timer (as if the value
+ stored decreased every microsecond). */
+ if (timercmp (&val.it_value, &elapsed, <))
+ {
+ /* Hmm. The timer should have just gone off, but has not been
+ reset. This is a possible timing glitch. The alarm will signal
+ soon, so fabricate a value for how soon. */
+ val.it_value.tv_sec = 0;
+ val.it_value.tv_usec = 10; /* Random. */
+ }
+ else
+ /* Subtract the time elapsed since the timer was set
+ from the current timer value the user sees. */
+ subtract_timeval (&val.it_value, &elapsed);
+ }
+
+ *value = val;
+ return 0;
+}
+
+weak_alias (__getitimer, getitimer)
diff --git a/sysdeps/mach/hurd/getlogin.c b/sysdeps/mach/hurd/getlogin.c
new file mode 100644
index 0000000..523db3f
--- /dev/null
+++ b/sysdeps/mach/hurd/getlogin.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+
+/* Return the login name of the user, or NULL if it can't be determined.
+ The returned pointer, if not NULL, is good only until the next call. */
+char *
+DEFUN_VOID(getlogin)
+{
+ static char login[1024]; /* XXX */
+ error_t err;
+
+ if (err = __USEPORT (PROC, __proc_getlogin (port, login)))
+ {
+ errno = err;
+ return NULL;
+ }
+
+ return login;
+}
diff --git a/sysdeps/mach/hurd/getpeername.c b/sysdeps/mach/hurd/getpeername.c
new file mode 100644
index 0000000..a9ea32c
--- /dev/null
+++ b/sysdeps/mach/hurd/getpeername.c
@@ -0,0 +1,59 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <hurd/socket.h>
+#include <string.h>
+
+/* Put the address of the peer connected to socket FD into *ADDR
+ (which is *LEN bytes long), and its actual length into *LEN. */
+int
+DEFUN(getpeername, (fd, addr, len),
+ int fd AND struct sockaddr *addr AND size_t *len)
+{
+ error_t err;
+ char *buf = (char *) addr;
+ mach_msg_type_number_t buflen = *len;
+ int type;
+ addr_port_t aport;
+
+ if (err = HURD_DPORT_USE (fd, __socket_peername (port, &aport)))
+ return __hurd_dfail (fd, err);
+
+ err = __socket_whatis_address (aport, &type, &buf, &buflen);
+ __mach_port_deallocate (__mach_task_self (), aport);
+
+ if (err)
+ return __hurd_dfail (fd, err);
+
+ if (buf != (char *) addr)
+ {
+ if (*len < buflen)
+ *len = buflen;
+ memcpy (addr, buf, *len);
+ __vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
+ }
+
+ addr->sa_family = type;
+
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/getpgid.c b/sysdeps/mach/hurd/getpgid.c
new file mode 100644
index 0000000..b9a3634
--- /dev/null
+++ b/sysdeps/mach/hurd/getpgid.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/port.h>
+
+/* Get the process group ID of process PID. */
+int
+DEFUN(__getpgid, (pid), pid_t pid)
+{
+ error_t err;
+ pid_t pgrp;
+
+ if (pid == 0)
+ {
+ /* Assume atomic word fetch and store, so don't lock _hurd_pid_lock. */
+ pgrp = _hurd_pgrp;
+ err = 0;
+ }
+ else
+ err = __USEPORT (PROC, __proc_getpgrp (port, pid, &pgrp));
+
+ return err ? __hurd_fail (err) : pgrp;
+}
+
+weak_alias (__getpgid, getpgid)
diff --git a/sysdeps/mach/hurd/getpid.c b/sysdeps/mach/hurd/getpid.c
new file mode 100644
index 0000000..bbff6a3
--- /dev/null
+++ b/sysdeps/mach/hurd/getpid.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+
+/* Get the process ID of the calling process. */
+pid_t
+DEFUN_VOID(__getpid)
+{
+ /* Assumes atomic word fetch and store, so doesn't lock _hurd_pid_lock. */
+ return _hurd_pid;
+}
+
+weak_alias (__getpid, getpid)
diff --git a/sysdeps/mach/hurd/getppid.c b/sysdeps/mach/hurd/getppid.c
new file mode 100644
index 0000000..6a5ac1d
--- /dev/null
+++ b/sysdeps/mach/hurd/getppid.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <hurd.h>
+
+
+/* Get the parent process ID of the calling process. */
+pid_t
+DEFUN_VOID(__getppid)
+{
+ /* Assumes atomic word fetch and store, so doesn't lock _hurd_pid_lock. */
+ return _hurd_ppid;
+}
+
+weak_alias (__getppid, getppid)
diff --git a/sysdeps/mach/hurd/getpriority.c b/sysdeps/mach/hurd/getpriority.c
new file mode 100644
index 0000000..5b24ce2
--- /dev/null
+++ b/sysdeps/mach/hurd/getpriority.c
@@ -0,0 +1,73 @@
+/* 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. */
+
+#include <limits.h>
+#include <hurd.h>
+#include <hurd/resource.h>
+
+/* Return the highest priority of any process specified by WHICH and WHO
+ (see <sys/resource.h>); if WHO is zero, the current process, process group,
+ or user (as specified by WHO) is used. A lower priority number means higher
+ priority. Priorities range from PRIO_MIN to PRIO_MAX. */
+int
+getpriority (enum __priority_which which, int who)
+{
+ error_t err, onerr;
+ int maxpri = INT_MIN;
+ struct procinfo *pip; /* Just for sizeof. */
+ int pibuf[sizeof *pip + 2 * sizeof (pip->threadinfos[0])], *pi = pibuf;
+ unsigned int pisize = sizeof pibuf / sizeof pibuf[0];
+
+ error_t getonepriority (pid_t pid, struct procinfo *pip)
+ {
+ if (pip)
+ onerr = 0;
+ else
+ {
+ int *oldpi = pi;
+ unsigned int oldpisize = pisize;
+ onerr = __USEPORT (PROC, __proc_getprocinfo (port,
+ pid,
+ &pi, &pisize));
+ if (pi != oldpi && oldpi != pibuf)
+ /* Old buffer from last call was not reused; free it. */
+ __vm_deallocate (__mach_task_self (),
+ (vm_address_t) oldpi, oldpisize * sizeof pi[0]);
+ pip = (struct procinfo *) pi;
+ }
+ if (!onerr && pip->taskinfo.base_priority > maxpri)
+ maxpri = pip->taskinfo.base_priority;
+ return 0;
+ }
+
+ onerr = 0;
+ err = _hurd_priority_which_map (which, who, getonepriority);
+
+ if (pi != pibuf)
+ __vm_deallocate (__mach_task_self (),
+ (vm_address_t) pi, pisize * sizeof pi[0]);
+
+ if (!err && maxpri == INT_MIN)
+ /* No error, but no pids found. */
+ err = onerr ?: ESRCH;
+
+ if (err)
+ return __hurd_fail (err);
+
+ return MACH_PRIORITY_TO_NICE (maxpri);
+}
diff --git a/sysdeps/mach/hurd/getrlimit.c b/sysdeps/mach/hurd/getrlimit.c
new file mode 100644
index 0000000..a05d322
--- /dev/null
+++ b/sysdeps/mach/hurd/getrlimit.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <sys/resource.h>
+#include <errno.h>
+#include <hurd.h>
+#include <hurd/resource.h>
+
+/* Put the soft and hard limits for RESOURCE in *RLIMITS.
+ Returns 0 if successful, -1 if not (and sets errno). */
+int
+DEFUN(getrlimit, (resource, rlimits),
+ enum __rlimit_resource resource AND struct rlimit *rlimits)
+{
+ struct rlimit lim;
+
+ if (rlimits == NULL || (unsigned int) resource >= RLIMIT_NLIMITS)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ __mutex_lock (&_hurd_rlimit_lock);
+ lim = _hurd_rlimits[resource];
+ __mutex_unlock (&_hurd_rlimit_lock);
+
+ *rlimits = lim;
+
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/getsockname.c b/sysdeps/mach/hurd/getsockname.c
new file mode 100644
index 0000000..5a9182b
--- /dev/null
+++ b/sysdeps/mach/hurd/getsockname.c
@@ -0,0 +1,58 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <hurd/socket.h>
+#include <string.h>
+
+/* Put the local address of FD into *ADDR and its length in *LEN. */
+int
+DEFUN(getsockname, (fd, addr, len),
+ int fd AND struct sockaddr *addr AND size_t *len)
+{
+ error_t err;
+ char *buf = (char *) addr;
+ mach_msg_type_number_t buflen = *len;
+ int type;
+ addr_port_t aport;
+
+ if (err = HURD_DPORT_USE (fd, __socket_name (port, &aport)))
+ return __hurd_dfail (fd, err);
+
+ err = __socket_whatis_address (aport, &type, &buf, &buflen);
+ __mach_port_deallocate (__mach_task_self (), aport);
+
+ if (err)
+ return __hurd_dfail (fd, err);
+
+ if (buf != (char *) addr)
+ {
+ if (*len < buflen)
+ *len = buflen;
+ memcpy (addr, buf, *len);
+ __vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
+ }
+
+ addr->sa_family = type;
+
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/getsockopt.c b/sysdeps/mach/hurd/getsockopt.c
new file mode 100644
index 0000000..a9c91ea
--- /dev/null
+++ b/sysdeps/mach/hurd/getsockopt.c
@@ -0,0 +1,53 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <hurd/socket.h>
+#include <string.h>
+
+/* Put the current value for socket FD's option OPTNAME at protocol level LEVEL
+ into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's
+ actual length. Returns 0 on success, -1 for errors. */
+int
+DEFUN(getsockopt, (fd, level, optname, optval, optlen),
+ int fd AND int level AND int optname AND
+ PTR optval AND size_t *optlen)
+{
+ error_t err;
+ char *buf = optval;
+ mach_msg_type_number_t buflen = *optlen;
+
+ if (err = HURD_DPORT_USE (fd, __socket_getopt (port,
+ level, optname,
+ &buf, &buflen)))
+ return __hurd_dfail (fd, err);
+
+ if (buf != optval)
+ {
+ if (*optlen < buflen)
+ *optlen = buflen;
+ memcpy (optval, buf, *optlen);
+ __vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
+ }
+
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/getuid.c b/sysdeps/mach/hurd/getuid.c
new file mode 100644
index 0000000..9381c6e
--- /dev/null
+++ b/sysdeps/mach/hurd/getuid.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/id.h>
+
+/* Get the real user ID of the calling process. */
+uid_t
+DEFUN_VOID(__getuid)
+{
+ error_t err;
+ uid_t uid;
+
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_id.lock);
+
+ if (err = _hurd_check_ids ())
+ {
+ errno = err;
+ uid = -1;
+ }
+ else if (_hurd_id.aux.nuids >= 1)
+ uid = _hurd_id.aux.uids[0];
+ else
+ {
+ /* We do not even have a real uid. */
+ errno = EGRATUITOUS;
+ uid = -1;
+ }
+
+ __mutex_unlock (&_hurd_id.lock);
+ HURD_CRITICAL_END;
+
+ return uid;
+}
+
+weak_alias (__getuid, getuid)
diff --git a/sysdeps/mach/hurd/hppa/sigcontext.h b/sysdeps/mach/hurd/hppa/sigcontext.h
new file mode 100644
index 0000000..b616469
--- /dev/null
+++ b/sysdeps/mach/hurd/hppa/sigcontext.h
@@ -0,0 +1,86 @@
+/* Machine-dependent signal context structure for GNU Hurd. HPPA version.
+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. */
+
+/* Signal handlers are actually called:
+ void handler (int sig, int code, struct sigcontext *scp); */
+
+/* State of this thread when the signal was taken. */
+struct sigcontext
+ {
+ /* These first members are machine-independent. */
+
+ int sc_onstack; /* Nonzero if running on sigstack. */
+ __sigset_t sc_mask; /* Blocked signals to restore. */
+
+ /* MiG reply port this thread is using. */
+ unsigned int sc_reply_port;
+
+ /* Port this thread is doing an interruptible RPC on. */
+ unsigned int sc_intr_port;
+
+ /* Error code associated with this signal (interpreted as `error_t'). */
+ int sc_error;
+
+ /* All following members are machine-dependent. The rest of this
+ structure is written to be laid out identically to a `struct
+ parisc_thread_state'. trampoline.c knows this, so it must be
+ changed if this changes. */
+
+#define sc_parisc_thread_state sc_flags /* Beginning of correspondence. */
+ /* "General" registers $1..$31. */
+ unsigned int sc_regs[31];
+
+ /* Control registers. */
+ unsigned int sc_cr11; /* sar */
+ /* These four registers make up the PC. */
+ unsigned int iioq_head;
+ unsigned int iisq_head;
+ unsigned int iioq_tail;
+ unsigned int iisq_tail;
+ unsigned int sc_cr15;
+ unsigned int sc_cr19;
+ unsigned int sc_cr20;
+ unsigned int sc_cr21;
+ unsigned int sc_cr22; /* ipsw */
+ unsigned int sc_bsd_goto; /* unused */
+ unsigned int sc_sr4;
+ unsigned int sc_sr0;
+ unsigned int sc_sr1;
+ unsigned int sc_sr2;
+ unsigned int sc_sr3;
+ unsigned int sc_sr5;
+ unsigned int sc_sr6;
+ unsigned int sc_sr7;
+ unsigned int sc_cr0;
+ unsigned int sc_cr8;
+ unsigned int sc_cr9;
+ unsigned int sc_cr10; /* unused */
+ unsigned int sc_cr12;
+ unsigned int sc_cr13;
+ unsigned int sc_cr24; /* unused */
+ unsigned int sc_cr25; /* unused */
+ unsigned int sc_cr26; /* unused */
+ unsigned sc_mpsfu_high; /* unused */
+ unsigned sc_mpsfu_low; /* unused */
+ unsigned sc_mpsfu_ovflo; /* unused */
+ int sc_pad;
+
+ /* Floating point registers $f0..$f31. */
+ double sc_fpregs[32];
+ };
diff --git a/sysdeps/mach/hurd/hppa/trampoline.c b/sysdeps/mach/hurd/hppa/trampoline.c
new file mode 100644
index 0000000..09ab71e
--- /dev/null
+++ b/sysdeps/mach/hurd/hppa/trampoline.c
@@ -0,0 +1,258 @@
+/* Set thread_state for sighandler, and sigcontext to recover. HPPA version.
+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. */
+
+#include <hurd/signal.h>
+#include "thread_state.h"
+#include <assert.h>
+#include <errno.h>
+#include "hurdfault.h"
+
+
+struct mach_msg_trap_regargs
+ {
+ /* These first four arguments are in registers 26..23. */
+ mach_msg_size_t rcv_size; /* arg3 */
+ mach_msg_size_t send_size; /* arg2 */
+ mach_msg_option_t option; /* arg1 */
+ mach_msg_header_t *msg; /* arg0 */
+ };
+
+struct sigcontext *
+_hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
+ int signo, long int sigcode,
+ volatile int rpc_wait,
+ struct machine_thread_all_state *state)
+{
+ __label__ trampoline, rpc_wait_trampoline;
+ void *volatile sigsp;
+ struct sigcontext *scp;
+
+ 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 (_hurdsig_catch_fault (SIGSEGV))
+ assert (_hurdsig_fault_sigcode >= (long int) ss->context &&
+ _hurdsig_fault_sigcode < (long int) (ss->context + 1));
+ else
+ {
+ memcpy (&state->basic, &ss->context->sc_parisc_thread_state,
+ sizeof (state->basic));
+ state->set = (1 << PARISC_THREAD_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))
+ return NULL;
+
+ if ((ss->actions[signo].sa_flags & SA_ONSTACK) &&
+ !(ss->sigaltstack.ss_flags & (SA_DISABLE|SA_ONSTACK)))
+ {
+ sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size;
+ ss->sigaltstack.ss_flags |= SA_ONSTACK;
+ /* XXX need to set up base of new stack for
+ per-thread variables, cthreads. */
+ }
+ else
+ sigsp = (char *) state->basic.uesp;
+
+ /* Push the signal context on the stack. */
+ sigsp -= sizeof (*scp);
+ scp = sigsp;
+
+ if (_hurdsig_catch_fault (SIGSEGV))
+ {
+ assert (_hurdsig_fault_sigcode >= (long int) scp &&
+ _hurdsig_fault_sigcode <= (long int) (scp + 1));
+ /* 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;
+
+ /* Set up the sigcontext from the current state of the thread. */
+
+ scp->sc_onstack = ss->sigaltstack.ss_flags & SA_ONSTACK ? 1 : 0;
+
+ /* struct sigcontext is laid out so that starting at sc_regs mimics a
+ struct parisc_thread_state. */
+ memcpy (&scp->sc_parisc_thread_state,
+ &state->basic, sizeof (state->basic));
+
+ _hurdsig_end_catch_fault ();
+
+ if (! ok)
+ return NULL;
+ }
+
+ /* Modify the thread state to call the trampoline code on the new stack. */
+ if (rpc_wait)
+ {
+ /* The signalee thread was blocked in a mach_msg_trap system call,
+ still waiting for a reply. We will have it run the special
+ trampoline code which retries the message receive before running
+ the signal handler.
+
+ To do this we change the OPTION argument on its stack to enable only
+ message reception, since the request message has already been
+ sent. */
+
+ struct mach_msg_trap_regargs *args = (void *) &state->basic.r23;
+
+ if (_hurdsig_catch_fault (SIGSEGV))
+ {
+ assert (_hurdsig_fault_sigcode >= (long int) args &&
+ _hurdsig_fault_sigcode < (long int) (args + 1));
+ /* 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. */
+ args->option &= ~MACH_SEND_MSG;
+
+ _hurdsig_end_catch_fault ();
+
+ MACHINE_THREAD_STATE_SET_PC (&state->basic, &&rpc_wait_trampoline);
+ /* The reply-receiving trampoline code runs initially on the original
+ user stack. We pass it the signal stack pointer in %r5. */
+ state->basic.r5 = (int) sigsp;
+ /* After doing the message receive, the trampoline code will need to
+ update the %r28 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 %r4. */
+ state->basic.r4 = (unsigned int) &scp->sc_regs[27];
+ /* Set up the arguments for the handler function in callee-saved
+ registers that we will move to the argument registers after
+ mach_msg_trap returns. */
+ state->basic.r6 = signo;
+ state->basic.r7 = sigcode;
+ state->basic.r8 = (unsigned int) scp;
+ }
+ else
+ {
+ MACHINE_THREAD_STATE_SET_PC (&state->basic, &&trampoline);
+ state->basic.r20 = (unsigned int) sigsp;
+ /* Set up the arguments for the handler function. */
+ state->basic.r26 = signo;
+ state->basic.r25 = sigcode;
+ state->basic.r24 = (unsigned int) scp;
+ }
+
+ /* We pass the handler function to the trampoline code in %r9. */
+ state->basic.r9 = (unsigned int) handler;
+ /* For convenience, we pass the address of __sigreturn in %r10. */
+ state->basic.r10 = (unsigned int) &__sigreturn;
+ /* The extra copy of SCP for the __sigreturn arg goes in %r8. */
+ state->basic.r10 = (unsigned int) scp;
+
+ return scp;
+
+ /* The trampoline code follows. This is not actually executed as part of
+ this function, it is just convenient to write it that way. */
+
+ rpc_wait_trampoline:
+ /* This is the entry point when we have an RPC reply message to receive
+ before running the handler. The MACH_MSG_SEND bit has already been
+ cleared in the OPTION argument on our stack. The interrupted user
+ stack pointer has not been changed, so the system call can find its
+ arguments; the signal stack pointer is in %ebx. For our convenience,
+ %ecx points to the sc_eax member of the sigcontext. */
+ asm volatile
+ (/* Retry the interrupted mach_msg system call. */
+ "ldil L%0xC0000000,%r1\nble 4(%sr7,%r1)\n"
+ "ldi -25, %r22\n" /* mach_msg_trap */
+ /* When the sigcontext was saved, %r28 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 %r28. So
+ store the new %r28 value into the sc_regs[27] member of the sigcontext
+ (whose address is in %r4 to make this code simpler). */
+ "stw (%r4), %r28\n"
+ /* Switch to the signal stack. */
+ "copy %r5, %r30\n"
+ /* Copy the handler arguments to the argument registers. */
+ "copy %r6, %r26\n"
+ "copy %r7, %r25\n"
+ "copy %r8, %r24\n"
+ );
+
+ trampoline:
+ /* Entry point for running the handler normally. The arguments to the
+ handler function are already in the argument registers. */
+ asm volatile
+ ("bv (%r9); nop" /* Call the handler function. */
+ "bv (%r10)\n" /* Call __sigreturn (SCP); never returns. */
+ "copy %r8, %r26" /* Set up arg in delay slot. */
+ : : "i" (&__sigreturn));
+
+ /* NOTREACHED */
+ return NULL;
+}
+
+/* STATE describes a thread that had intr_port set (meaning it was inside
+ HURD_EINTR_RPC), after it has been thread_abort'd. It it looks to have
+ just completed a mach_msg_trap system call that returned
+ MACH_RCV_INTERRUPTED, return nonzero and set *PORT to the receive right
+ being waited on. */
+int
+_hurdsig_rcv_interrupted_p (struct machine_thread_all_state *state,
+ mach_port_t *port)
+{
+ const unsigned int *volatile pc
+ = MACHINE_THREAD_STATE_PC (&state->basic);
+ const mach_port_t *rcv_name
+ = (void *) state->r30 -32-20; /* VA_ARG4 from <mach/machine/asm.h>. */
+
+ if (_hurdsig_catch_fault (SIGSEGV))
+ assert (_hurdsig_fault_sigcode == (long int) pc ||
+ _hurdsig_fault_sigcode == (long int) rcv_name);
+ else
+ {
+ int rcving = (state->basic.r28 == MACH_RCV_INTERRUPTED &&
+ pc == ???unfinished???);
+ if (rcving)
+ /* We did just return from a mach_msg_trap system call
+ doing a message receive that was interrupted.
+ Examine the parameters to find the receive right. */
+ *port = *rcv_name;
+ _hurdsig_end_catch_fault ();
+ if (rcving)
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/i386/exc2signal.c b/sysdeps/mach/hurd/i386/exc2signal.c
new file mode 100644
index 0000000..19f845a
--- /dev/null
+++ b/sysdeps/mach/hurd/i386/exc2signal.c
@@ -0,0 +1,165 @@
+/* Translate Mach exception codes into signal numbers. i386 version.
+Copyright (C) 1991, 1992, 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. */
+
+#include <hurd.h>
+#include <hurd/signal.h>
+#include <mach/exception.h>
+
+/* Translate the Mach exception codes, as received in an `exception_raise' RPC,
+ into a signal number and signal subcode. */
+
+void
+_hurd_exception2signal (int exception, int code, int subcode,
+ int *signo, long int *sigcode, int *error)
+{
+ *error = 0;
+
+ switch (exception)
+ {
+ default:
+ *signo = SIGIOT;
+ *sigcode = exception;
+ break;
+
+ case EXC_BAD_ACCESS:
+ if (code == KERN_PROTECTION_FAILURE)
+ *signo = SIGSEGV;
+ else
+ *signo = SIGBUS;
+ *sigcode = subcode;
+ *error = code;
+ break;
+
+ case EXC_BAD_INSTRUCTION:
+ *signo = SIGILL;
+ if (code == EXC_I386_INVOP)
+ *sigcode = ILL_INVOPR_FAULT;
+ else if (code == EXC_I386_STKFLT)
+ *sigcode = ILL_STACK_FAULT;
+ else
+ *sigcode = 0;
+ break;
+
+ case EXC_ARITHMETIC:
+ switch (code)
+ {
+ case EXC_I386_DIV: /* integer divide by zero */
+ *signo = SIGFPE;
+ *sigcode = FPE_INTDIV_FAULT;
+ break;
+
+ case EXC_I386_INTO: /* integer overflow */
+ *signo = SIGFPE;
+ *sigcode = FPE_INTOVF_TRAP;
+ break;
+
+ /* These aren't anywhere documented or used in Mach 3.0. */
+ case EXC_I386_NOEXT:
+ case EXC_I386_EXTOVR:
+ default:
+ *signo = SIGFPE;
+ *sigcode = 0;
+ break;
+
+ case EXC_I386_EXTERR:
+ /* Subcode is the fp_status word saved by the hardware.
+ Give an error code corresponding to the first bit set. */
+ if (subcode & FPS_IE)
+ {
+ *signo = SIGILL;
+ *sigcode = ILL_FPEOPR_FAULT;
+ }
+ else if (subcode & FPS_DE)
+ {
+ *signo = SIGFPE;
+ *sigcode = FPE_FLTDNR_FAULT;
+ }
+ else if (subcode & FPS_ZE)
+ {
+ *signo = SIGFPE;
+ *sigcode = FPE_FLTDIV_FAULT;
+ }
+ else if (subcode & FPS_OE)
+ {
+ *signo = SIGFPE;
+ *sigcode = FPE_FLTOVF_FAULT;
+ }
+ else if (subcode & FPS_UE)
+ {
+ *signo = SIGFPE;
+ *sigcode = FPE_FLTUND_FAULT;
+ }
+ else if (subcode & FPS_PE)
+ {
+ *signo = SIGFPE;
+ *sigcode = FPE_FLTINX_FAULT;
+ }
+ else
+ {
+ *signo = SIGFPE;
+ *sigcode = 0;
+ }
+ break;
+
+ /* These two can only be arithmetic exceptions if we
+ are in V86 mode, which sounds like emulation to me.
+ (See Mach 3.0 i386/trap.c.) */
+ case EXC_I386_EMERR:
+ *signo = SIGFPE;
+ *sigcode = FPE_EMERR_FAULT;
+ break;
+ case EXC_I386_BOUND:
+ *signo = SIGFPE;
+ *sigcode = FPE_EMBND_FAULT;
+ break;
+ }
+ break;
+
+ case EXC_EMULATION:
+ /* 3.0 doesn't give this one, why, I don't know. */
+ *signo = SIGEMT;
+ *sigcode = 0;
+ break;
+
+ case EXC_SOFTWARE:
+ /* The only time we get this in Mach 3.0
+ is for an out of bounds trap. */
+ if (code == EXC_I386_BOUND)
+ {
+ *signo = SIGFPE;
+ *sigcode = FPE_SUBRNG_FAULT;
+ }
+ else
+ {
+ *signo = SIGEMT;
+ *sigcode = 0;
+ }
+ break;
+
+ case EXC_BREAKPOINT:
+ *signo = SIGTRAP;
+ if (code == EXC_I386_SGL)
+ *sigcode = DBG_SINGLE_TRAP;
+ else if (code == EXC_I386_BPT)
+ *sigcode = DBG_BRKPNT_FAULT;
+ else
+ *sigcode = 0;
+ break;
+ }
+}
diff --git a/sysdeps/mach/hurd/i386/init-fault.c b/sysdeps/mach/hurd/i386/init-fault.c
new file mode 100644
index 0000000..ff22814
--- /dev/null
+++ b/sysdeps/mach/hurd/i386/init-fault.c
@@ -0,0 +1,41 @@
+/* Set up a thread_state for proc_handle_exceptions. i386 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. */
+
+#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 i386_thread_state *ts = state;
+ memset (ts, 0, sizeof (*ts));
+ ts->uesp = (int) &fault_stack[sizeof (fault_stack)];
+ ts->eip = (int) &faulted;
+}
diff --git a/sysdeps/mach/hurd/i386/longjmp-ctx.c b/sysdeps/mach/hurd/i386/longjmp-ctx.c
new file mode 100644
index 0000000..acfbee6
--- /dev/null
+++ b/sysdeps/mach/hurd/i386/longjmp-ctx.c
@@ -0,0 +1,35 @@
+/* Perform a `longjmp' on a `struct sigcontext'. i386 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. */
+
+#include <setjmp.h>
+#include <hurd/signal.h>
+#include <string.h>
+
+void
+_hurd_longjmp_sigcontext (struct sigcontext *scp, jmp_buf env, int retval)
+{
+ memset (scp, 0, sizeof (*scp));
+ scp->sc_ebx = env[0].__bx;
+ scp->sc_esi = env[0].__si;
+ scp->sc_edi = env[0].__di;
+ scp->sc_ebp = (int) env[0].__bp;
+ scp->sc_uesp = (int) env[0].__sp;
+ scp->sc_eip = (int) env[0].__pc;
+ scp->sc_eax = retval == 0 ? 1 : retval;
+}
diff --git a/sysdeps/mach/hurd/i386/longjmp-ts.c b/sysdeps/mach/hurd/i386/longjmp-ts.c
new file mode 100644
index 0000000..7da9be2
--- /dev/null
+++ b/sysdeps/mach/hurd/i386/longjmp-ts.c
@@ -0,0 +1,39 @@
+/* Perform a `longjmp' on a Mach thread_state. i386 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. */
+
+#include <hurd/signal.h>
+#include <setjmp.h>
+#include <mach/thread_status.h>
+
+
+/* Set up STATE to do the equivalent of `longjmp (ENV, VAL);'. */
+
+void
+_hurd_longjmp_thread_state (void *state, jmp_buf env, int val)
+{
+ struct i386_thread_state *ts = state;
+
+ ts->ebx = env[0].__jmpbuf[0].__bx;
+ ts->esi = env[0].__jmpbuf[0].__si;
+ ts->edi = env[0].__jmpbuf[0].__di;
+ ts->ebp = (int) env[0].__jmpbuf[0].__bp;
+ ts->uesp = (int) env[0].__jmpbuf[0].__sp;
+ ts->eip = (int) env[0].__jmpbuf[0].__pc;
+ ts->eax = val ?: 1;
+}
diff --git a/sysdeps/mach/hurd/i386/sigcontext.h b/sysdeps/mach/hurd/i386/sigcontext.h
new file mode 100644
index 0000000..b742326
--- /dev/null
+++ b/sysdeps/mach/hurd/i386/sigcontext.h
@@ -0,0 +1,106 @@
+/* Machine-dependent signal context structure for GNU Hurd. i386 version.
+Copyright (C) 1991, 1992, 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. */
+
+/* Signal handlers are actually called:
+ void handler (int sig, int code, struct sigcontext *scp); */
+
+#include <mach/machine/fp_reg.h>
+
+/* State of this thread when the signal was taken. */
+struct sigcontext
+ {
+ /* These first members are machine-independent. */
+
+ int sc_onstack; /* Nonzero if running on sigstack. */
+ __sigset_t sc_mask; /* Blocked signals to restore. */
+
+ /* MiG reply port this thread is using. */
+ unsigned int sc_reply_port;
+
+ /* Port this thread is doing an interruptible RPC on. */
+ unsigned int sc_intr_port;
+
+ /* Error code associated with this signal (interpreted as `error_t'). */
+ int sc_error;
+
+ /* All following members are machine-dependent. The rest of this
+ structure is written to be laid out identically to:
+ {
+ struct i386_thread_state basic;
+ struct i386_float_state fpu;
+ }
+ trampoline.c knows this, so it must be changed if this changes. */
+
+#define sc_i386_thread_state sc_gs /* Beginning of correspondence. */
+ /* Segment registers. */
+ int sc_gs;
+ int sc_fs;
+ int sc_es;
+ int sc_ds;
+
+ /* "General" registers. These members are in the order that the i386
+ `pusha' and `popa' instructions use (`popa' ignores %esp). */
+ int sc_edi;
+ int sc_esi;
+ int sc_ebp;
+ int sc_esp; /* Not used; sc_uesp is used instead. */
+ int sc_ebx;
+ int sc_edx;
+ int sc_ecx;
+ int sc_eax;
+
+ int sc_eip; /* Instruction pointer. */
+ int sc_cs; /* Code segment register. */
+
+ int sc_efl; /* Processor flags. */
+
+ int sc_uesp; /* This stack pointer is used. */
+ int sc_ss; /* Stack segment register. */
+
+ /* Following mimics struct i386_float_state. Structures and symbolic
+ values can be found in <mach/i386/fp_reg.h>. */
+#define sc_i386_float_state sc_fpkind
+ int sc_fpkind; /* FP_NO, FP_387, etc. */
+ int sc_fpused; /* If zero, ignore rest of float state. */
+ struct i386_fp_save sc_fpsave;
+ struct i386_fp_regs sc_fpregs;
+ int sc_fpexcsr; /* FPSR including exception bits. */
+ };
+
+
+/* Codes for SIGFPE. */
+#define FPE_INTOVF_TRAP 0x1 /* integer overflow */
+#define FPE_INTDIV_FAULT 0x2 /* integer divide by zero */
+#define FPE_FLTOVF_FAULT 0x3 /* floating overflow */
+#define FPE_FLTDIV_FAULT 0x4 /* floating divide by zero */
+#define FPE_FLTUND_FAULT 0x5 /* floating underflow */
+#define FPE_SUBRNG_FAULT 0x7 /* BOUNDS instruction failed */
+#define FPE_FLTDNR_FAULT 0x8 /* denormalized operand */
+#define FPE_FLTINX_FAULT 0x9 /* floating loss of precision */
+#define FPE_EMERR_FAULT 0xa /* mysterious emulation error 33 */
+#define FPE_EMBND_FAULT 0xb /* emulation BOUNDS instruction failed */
+
+/* Codes for SIGILL. */
+#define ILL_INVOPR_FAULT 0x1 /* invalid operation */
+#define ILL_STACK_FAULT 0x2 /* fault on microkernel stack access */
+#define ILL_FPEOPR_FAULT 0x3 /* invalid floating operation */
+
+/* Codes for SIGTRAP. */
+#define DBG_SINGLE_TRAP 0x1 /* single step */
+#define DBG_BRKPNT_FAULT 0x2 /* breakpoint instruction */
diff --git a/sysdeps/mach/hurd/i386/sigreturn.c b/sysdeps/mach/hurd/i386/sigreturn.c
new file mode 100644
index 0000000..df89606
--- /dev/null
+++ b/sysdeps/mach/hurd/i386/sigreturn.c
@@ -0,0 +1,126 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+register int *sp asm ("%esp");
+
+#include <hurd.h>
+#include <hurd/signal.h>
+#include <hurd/threadvar.h>
+#include <hurd/msg.h>
+#include <stdlib.h>
+
+int
+__sigreturn (struct sigcontext *scp)
+{
+ struct hurd_sigstate *ss;
+ mach_port_t *reply_port;
+
+ if (scp == NULL || (scp->sc_mask & _SIG_CANT_MASK))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ss = _hurd_self_sigstate ();
+ __spin_lock (&ss->lock);
+
+ /* Restore the set of blocked signals, and the intr_port slot. */
+ ss->blocked = scp->sc_mask;
+ ss->intr_port = scp->sc_intr_port;
+
+ /* Check for pending signals that were blocked by the old set. */
+ if (ss->pending & ~ss->blocked)
+ {
+ /* There are pending signals that just became unblocked. Wake up the
+ signal thread to deliver them. But first, squirrel away SCP where
+ 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 ());
+ /* If a pending signal was handled, sig_post never returned. */
+ __spin_lock (&ss->lock);
+ }
+
+ if (scp->sc_onstack)
+ {
+ ss->sigaltstack.ss_flags &= ~SA_ONSTACK; /* XXX threadvars */
+ /* XXX cannot unlock until off sigstack */
+ abort ();
+ }
+ else
+ __spin_unlock (&ss->lock);
+
+ /* Destroy the MiG reply port used by the signal handler, and restore the
+ reply port in use by the thread when interrupted. */
+ reply_port =
+ (mach_port_t *) __hurd_threadvar_location (_HURD_THREADVAR_MIG_REPLY);
+ if (*reply_port)
+ __mach_port_destroy (__mach_task_self (), *reply_port);
+ *reply_port = scp->sc_reply_port;
+
+ if (scp->sc_fpused)
+ {
+ /* XXX should restore FPU state here XXX roland needs 387 manual */
+ /* abort (); */
+ }
+
+ {
+ /* There are convenient instructions to pop state off the stack, so we
+ copy the registers onto the user's stack, switch there, pop and
+ return. */
+
+ int *usp = (int *) scp->sc_uesp;
+
+ *--usp = scp->sc_eip;
+ *--usp = scp->sc_efl;
+ memcpy (usp -= 12, &scp->sc_i386_thread_state, 12 * sizeof (int));
+
+ sp = usp;
+
+#define A(line) asm volatile (#line)
+ /* The members in the sigcontext are arranged in this order
+ so we can pop them easily. */
+
+ /* Pop the segment registers (except %cs and %ss, done last). */
+ A (popl %gs);
+ A (popl %fs);
+ A (popl %es);
+ A (popl %ds);
+ /* Pop the general registers. */
+ A (popa);
+ /* Pop the processor flags. */
+ A (popf);
+ /* Return to the saved PC. */
+ A (ret);
+
+ /* Firewall. */
+ A (hlt);
+#undef A
+ }
+
+ /* NOTREACHED */
+ return -1;
+}
+
+weak_alias (__sigreturn, sigreturn)
diff --git a/sysdeps/mach/hurd/i386/trampoline.c b/sysdeps/mach/hurd/i386/trampoline.c
new file mode 100644
index 0000000..eabf940
--- /dev/null
+++ b/sysdeps/mach/hurd/i386/trampoline.c
@@ -0,0 +1,271 @@
+/* Set thread_state for sighandler, and sigcontext to recover. i386 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. */
+
+#include <hurd/signal.h>
+#include "thread_state.h"
+#include <assert.h>
+#include <errno.h>
+#include "hurdfault.h"
+
+
+struct mach_msg_trap_args
+ {
+ void *retaddr; /* Address mach_msg_trap will return to. */
+ /* 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;
+ };
+
+struct sigcontext *
+_hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
+ int signo, long int sigcode,
+ volatile int rpc_wait,
+ struct machine_thread_all_state *state)
+{
+ __label__ trampoline, rpc_wait_trampoline;
+ void *volatile sigsp;
+ struct sigcontext *scp;
+ struct
+ {
+ int signo;
+ long int sigcode;
+ struct sigcontext *scp; /* Points to ctx, below. */
+ struct sigcontext *return_scp; /* Same; arg to sigreturn. */
+ struct sigcontext ctx;
+ } *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 (_hurdsig_catch_fault (SIGSEGV))
+ assert (_hurdsig_fault_sigcode >= (long int) ss->context &&
+ _hurdsig_fault_sigcode < (long int) (ss->context + 1));
+ else
+ {
+ memcpy (&state->basic, &ss->context->sc_i386_thread_state,
+ sizeof (state->basic));
+ memcpy (&state->fpu, &ss->context->sc_i386_float_state,
+ sizeof (state->fpu));
+ state->set = (1 << i386_THREAD_STATE) | (1 << i386_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))
+ return NULL;
+
+ if ((ss->actions[signo].sa_flags & SA_ONSTACK) &&
+ !(ss->sigaltstack.ss_flags & (SA_DISABLE|SA_ONSTACK)))
+ {
+ sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size;
+ ss->sigaltstack.ss_flags |= SA_ONSTACK;
+ /* XXX need to set up base of new stack for
+ per-thread variables, cthreads. */
+ }
+ else
+ sigsp = (char *) state->basic.uesp;
+
+ /* Push the arguments to call `trampoline' on the stack. */
+ sigsp -= sizeof (*stackframe);
+ stackframe = sigsp;
+
+ if (_hurdsig_catch_fault (SIGSEGV))
+ {
+ assert (_hurdsig_fault_sigcode >= (long int) stackframe &&
+ _hurdsig_fault_sigcode <= (long int) (stackframe + 1));
+ /* 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;
+
+ /* Set up the arguments for the signal handler. */
+ stackframe->signo = signo;
+ stackframe->sigcode = sigcode;
+ stackframe->scp = stackframe->return_scp = scp = &stackframe->ctx;
+
+ /* Set up the sigcontext from the current state of the thread. */
+
+ scp->sc_onstack = ss->sigaltstack.ss_flags & SA_ONSTACK ? 1 : 0;
+
+ /* struct sigcontext is laid out so that starting at sc_gs mimics a
+ struct i386_thread_state. */
+ memcpy (&scp->sc_i386_thread_state,
+ &state->basic, sizeof (state->basic));
+
+ /* struct sigcontext is laid out so that starting at sc_fpkind mimics
+ a struct i386_float_state. */
+ ok = machine_get_state (ss->thread, state, i386_FLOAT_STATE,
+ &state->fpu, &scp->sc_i386_float_state,
+ sizeof (state->fpu));
+
+ _hurdsig_end_catch_fault ();
+
+ if (! ok)
+ return NULL;
+ }
+
+ /* Modify the thread state to call the trampoline code on the new stack. */
+ if (rpc_wait)
+ {
+ /* The signalee thread was blocked in a mach_msg_trap system call,
+ still waiting for a reply. We will have it run the special
+ trampoline code which retries the message receive before running
+ the signal handler.
+
+ To do this we change the OPTION argument on its stack to enable only
+ message reception, since the request message has already been
+ sent. */
+
+ struct mach_msg_trap_args *args = (void *) state->basic.uesp;
+
+ if (_hurdsig_catch_fault (SIGSEGV))
+ {
+ assert (_hurdsig_fault_sigcode >= (long int) args &&
+ _hurdsig_fault_sigcode < (long int) (args + 1));
+ /* 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. */
+ args->option &= ~MACH_SEND_MSG;
+
+ _hurdsig_end_catch_fault ();
+
+ state->basic.eip = (int) &&rpc_wait_trampoline;
+ /* The reply-receiving trampoline code runs initially on the original
+ user stack. We pass it the signal stack pointer in %ebx. */
+ state->basic.ebx = (int) sigsp;
+ /* After doing the message receive, the trampoline code will need to
+ update the %eax 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 %ecx. */
+ state->basic.ecx = (int) &scp->sc_eax;
+ }
+ else
+ {
+ state->basic.eip = (int) &&trampoline;
+ state->basic.uesp = (int) sigsp;
+ }
+ /* We pass the handler function to the trampoline code in %edx. */
+ state->basic.edx = (int) handler;
+
+ return scp;
+
+ /* The trampoline code follows. This is not actually executed as part of
+ this function, it is just convenient to write it that way. */
+
+ rpc_wait_trampoline:
+ /* This is the entry point when we have an RPC reply message to receive
+ before running the handler. The MACH_MSG_SEND bit has already been
+ cleared in the OPTION argument on our stack. The interrupted user
+ stack pointer has not been changed, so the system call can find its
+ arguments; the signal stack pointer is in %ebx. For our convenience,
+ %ecx points to the sc_eax member of the sigcontext. */
+ asm volatile
+ (/* Retry the interrupted mach_msg system call. */
+ "movl $-25, %eax\n" /* mach_msg_trap */
+ "lcall $7, $0\n"
+ /* When the sigcontext was saved, %eax 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 %eax. So
+ store the new %eax value into the sc_eax member of the sigcontext
+ (whose address is in %ecx to make this code simpler). */
+ "movl %eax, (%ecx)\n"
+ /* Switch to the signal stack. */
+ "movl %ebx, %esp\n");
+
+ trampoline:
+ /* Entry point for running the handler normally. The arguments to the
+ handler function are already on the top of the stack:
+
+ 0(%esp) SIGNO
+ 4(%esp) SIGCODE
+ 8(%esp) SCP
+ */
+ asm volatile
+ ("call %*%%edx\n" /* Call the handler function. */
+ "addl $12, %%esp\n" /* Pop its args. */
+ "call %P0\n" /* Call __sigreturn (SCP); never returns. */
+ "hlt" /* Just in case. */
+ : : "i" (&__sigreturn));
+
+ /* NOTREACHED */
+ return NULL;
+}
+
+/* STATE describes a thread that had intr_port set (meaning it was inside
+ HURD_EINTR_RPC), after it has been thread_abort'd. It it looks to have
+ just completed a mach_msg_trap system call that returned
+ MACH_RCV_INTERRUPTED, return nonzero and set *PORT to the receive right
+ being waited on. */
+int
+_hurdsig_rcv_interrupted_p (struct machine_thread_all_state *state,
+ mach_port_t *port)
+{
+ static const unsigned char syscall[] = { 0x9a, 0, 0, 0, 0, 7, 0 };
+ const unsigned char *volatile pc
+ = (void *) state->basic.eip - sizeof syscall;
+
+ if (_hurdsig_catch_fault (SIGSEGV))
+ assert (_hurdsig_fault_sigcode >= (long int) pc &&
+ _hurdsig_fault_sigcode < (long int) pc + sizeof syscall);
+ else
+ {
+ int rcving = (state->basic.eax == MACH_RCV_INTERRUPTED &&
+ !memcmp (pc, &syscall, sizeof syscall));
+ _hurdsig_end_catch_fault ();
+ if (rcving)
+ {
+ /* We did just return from a mach_msg_trap system call
+ doing a message receive that was interrupted.
+ Examine the parameters to find the receive right. */
+ struct mach_msg_trap_args *args = (void *) state->basic.uesp;
+
+ *port = args->rcv_name;
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/ioctl.c b/sysdeps/mach/hurd/ioctl.c
new file mode 100644
index 0000000..4aad0bb
--- /dev/null
+++ b/sysdeps/mach/hurd/ioctl.c
@@ -0,0 +1,242 @@
+/* Copyright (C) 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <hurd/signal.h>
+#include <stdarg.h>
+#include <mach/notify.h>
+#include <assert.h>
+#include <string.h>
+#include <hurd/ioctl.h>
+
+
+#define typesize(type) (1 << (type))
+
+
+/* Perform the I/O control operation specified by REQUEST on FD.
+ The actual type and use of ARG and the return value depend on REQUEST. */
+int
+DEFUN(__ioctl, (fd, request),
+ int fd AND unsigned long int request DOTS)
+{
+ /* 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 };
+#define io2mach_type(count, type) \
+ ((mach_msg_type_t) { mach_types[type], typesize (type) * 8, count, 1, 0, 0 })
+
+ /* Extract the type information encoded in the request. */
+ unsigned int type = _IOC_TYPE (request);
+
+ /* Message buffer. */
+ 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)) +
+ _IOT_COUNT2 (type) * typesize (_IOT_TYPE2 (type))];
+ } msg;
+ mach_msg_header_t *const m = &msg.header.Head;
+ mach_msg_type_t *t = &msg.header.RetCodeType;
+ mach_msg_id_t msgid;
+ unsigned int reply_size;
+
+ void *arg;
+
+ error_t err;
+
+ /* Send the RPC already packed up in MSG to IOPORT
+ and decode the return value. */
+ error_t send_rpc (io_t ioport)
+ {
+ error_t err;
+
+ m->msgh_size = (char *) t - (char *) &msg;
+ m->msgh_remote_port = ioport;
+ m->msgh_local_port = __mig_get_reply_port ();
+ m->msgh_seqno = 0;
+ m->msgh_id = msgid;
+ m->msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_COPY_SEND,
+ MACH_MSG_TYPE_MAKE_SEND_ONCE);
+ err = HURD_EINTR_RPC (ioport, __mach_msg (m, MACH_SEND_MSG|MACH_RCV_MSG,
+ m->msgh_size, sizeof (msg),
+ m->msgh_local_port,
+ MACH_MSG_TIMEOUT_NONE,
+ MACH_PORT_NULL));
+ switch (err)
+ {
+ case MACH_MSG_SUCCESS:
+ break;
+ case MACH_SEND_INVALID_REPLY:
+ case MACH_RCV_INVALID_NAME:
+ __mig_dealloc_reply_port (m->msgh_local_port);
+ default:
+ return err;
+ }
+
+ if ((m->msgh_bits & MACH_MSGH_BITS_COMPLEX))
+ {
+ /* Allow no ports or VM. */
+ __mach_msg_destroy (m);
+ /* Want to return a different error below for a different msgid. */
+ if (m->msgh_id == msgid + 100)
+ return MIG_TYPE_ERROR;
+ }
+
+ if (m->msgh_id != msgid + 100)
+ return (m->msgh_id == MACH_NOTIFY_SEND_ONCE ?
+ MIG_SERVER_DIED : MIG_REPLY_MISMATCH);
+
+ if (m->msgh_size != reply_size &&
+ m->msgh_size != sizeof (mig_reply_header_t))
+ return MIG_TYPE_ERROR;
+
+ if (*(int *) &msg.header.RetCodeType !=
+ ((union { mach_msg_type_t t; int i; })
+ { t: io2mach_type (1, _IOTS (sizeof msg.header.RetCode)) }).i)
+ return MIG_TYPE_ERROR;
+ return msg.header.RetCode;
+ }
+
+ va_list ap;
+
+ va_start (ap, request);
+ arg = va_arg (ap, void *);
+ va_end (ap);
+
+ {
+ /* Check for a registered handler for REQUEST. */
+ ioctl_handler_t handler = _hurd_lookup_ioctl_handler (request);
+ if (handler)
+ /* This handler groks REQUEST. Se lo puntamonos. */
+ return (*handler) (fd, request, arg);
+ }
+
+ /* Compute the Mach message ID for the RPC from the group and command
+ parts of the ioctl request. */
+ msgid = 100000 + ((_IOC_GROUP (request) - 'f') * 4000); /* Base subsystem */
+ /* Because of MiG's poorly chosen algorithm of adding 100 to a request
+ msgid to produce the reply msgid, we cannot just add the command part
+ of the ioctl request to the subsystem base msgid. For ioctl requests
+ past 99, we must skip blocks of 100 msgids to allow for the reply
+ msgids corresponding to the earlier requests. */
+ if (_IOC_COMMAND (request) >= 100)
+ msgid += 100;
+ if (_IOC_COMMAND (request) >= 200)
+ msgid += 100;
+ msgid += _IOC_COMMAND (request);
+
+ if (_IOC_INOUT (request) & IOC_IN)
+ {
+ /* Pack an argument into the message buffer. */
+ void in (unsigned int count, enum __ioctl_datum type)
+ {
+ if (count > 0)
+ {
+ void *p = &t[1];
+ const size_t len = count * typesize ((unsigned int) type);
+ *t = io2mach_type (count, type);
+ memcpy (p, arg, len);
+ arg += len;
+ p += len;
+ p = (void *) (((unsigned long int) p + sizeof (*t) - 1)
+ & ~(sizeof (*t) - 1));
+ t = p;
+ }
+ }
+
+ /* Pack the argument data. */
+ in (_IOT_COUNT0 (type), _IOT_TYPE0 (type));
+ in (_IOT_COUNT1 (type), _IOT_TYPE1 (type));
+ in (_IOT_COUNT2 (type), _IOT_TYPE2 (type));
+ }
+
+ /* Compute the expected size of the reply. There is a standard header
+ consisting of the message header and the reply code. Then, for out
+ and in/out ioctls, there come the data with their type headers. */
+ reply_size = sizeof (mig_reply_header_t);
+
+ if (_IOC_INOUT (request) & IOC_OUT)
+ {
+ inline void figure_reply (unsigned int count, enum __ioctl_datum type)
+ {
+ if (count > 0)
+ {
+ /* Add the size of the type and data. */
+ reply_size += sizeof (mach_msg_type_t) + typesize (type) * count;
+ /* Align it to word size. */
+ reply_size += sizeof (mach_msg_type_t) - 1;
+ reply_size &= ~(sizeof (mach_msg_type_t) - 1);
+ }
+ }
+ figure_reply (_IOT_COUNT0 (type), _IOT_TYPE0 (type));
+ figure_reply (_IOT_COUNT1 (type), _IOT_TYPE1 (type));
+ figure_reply (_IOT_COUNT2 (type), _IOT_TYPE2 (type));
+ }
+
+ err = HURD_DPORT_USE (fd, _hurd_ctty_output (port, ctty, send_rpc));
+
+ t = (mach_msg_type_t *) msg.data;
+ switch (err)
+ {
+ /* Unpack the message buffer into the argument location. */
+ int out (unsigned int count, unsigned int type,
+ void *store, void **update)
+ {
+ if (count > 0)
+ {
+ const size_t len = count * typesize (type);
+ union { mach_msg_type_t t; int i; } ipctype;
+ ipctype.t = io2mach_type (count, type);
+ if (*(int *) t != ipctype.i)
+ return 1;
+ ++t;
+ memcpy (store, t, len);
+ if (update != NULL)
+ *update += len;
+ t = (void *) (((unsigned long int) t + len + sizeof (*t) - 1)
+ & ~(sizeof (*t) - 1));
+ }
+ return 0;
+ }
+
+ case 0:
+ if (m->msgh_size != reply_size ||
+ ((_IOC_INOUT (request) & IOC_OUT) &&
+ (out (_IOT_COUNT0 (type), _IOT_TYPE0 (type), arg, &arg) ||
+ out (_IOT_COUNT1 (type), _IOT_TYPE1 (type), arg, &arg) ||
+ out (_IOT_COUNT2 (type), _IOT_TYPE2 (type), arg, &arg))))
+ return __hurd_fail (MIG_TYPE_ERROR);
+ return 0;
+
+ case MIG_BAD_ID:
+ case EOPNOTSUPP:
+ /* The server didn't understand the RPC. */
+ err = ENOTTY;
+ default:
+ return __hurd_fail (err);
+ }
+}
+
+weak_alias (__ioctl, ioctl)
diff --git a/sysdeps/mach/hurd/ioctls.h b/sysdeps/mach/hurd/ioctls.h
new file mode 100644
index 0000000..af44873
--- /dev/null
+++ b/sysdeps/mach/hurd/ioctls.h
@@ -0,0 +1,323 @@
+/* Copyright (C) 1992, 1993 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 _IOCTLS_H
+
+#define _IOCTLS_H 1
+
+/* Hurd ioctl request are made up of several fields:
+ bits 31-30: inout direction (enum __ioctl_dir)
+ bits 29-12: type encoding as follows; zero count indicates omitted datum
+ 29-28: datum #0 type (enum __ioctl_datum)
+ 27-26: datum #1 type (enum __ioctl_datum)
+ 25-24: datum #2 type (enum __ioctl_datum)
+ 23-19: datum #0 count [0..31]
+ 18-14: datum #1 count [0..31]
+ 13-12: datum #2 count [0..3]
+ bits 11- 8: group (letter - 'f': ['f'..'v'])
+ bits 7- 0: command [0..127]
+
+ The following macros construct and dissect these fields. */
+
+enum __ioctl_dir
+ {
+ IOC_VOID = 0, /* No parameters. */
+ IOC_OUT = 1, /* Data is written into the user's buffer. */
+ IOC_IN = 2, /* Data is read from the user's buffer. */
+ IOC_INOUT = (IOC_IN|IOC_OUT)
+ };
+
+enum __ioctl_datum { IOC_8, IOC_16, IOC_32 };
+
+/* Construct an ioctl from constructed type plus other fields. */
+#define _IOC(inout, group, num, type) \
+ ((num) | ((((group) - 'f') | ((type) | (inout) << 19) << 4) << 7))
+
+/* Dissect an ioctl into its component fields. */
+#define _IOC_INOUT(request) (((unsigned int) (request) >> 30) & IOC_INOUT)
+#define _IOC_GROUP(request) ('f' + (((unsigned int) (request) >> 7) & 15))
+#define _IOC_COMMAND(request) ((unsigned int) (request) & 0x7f)
+#define _IOC_TYPE(request) (((unsigned int) (request) >> 11) & 0x7ffff)
+
+/* Construct a type information field from
+ the broken-out type and count fields. */
+#define _IOT(t0, c0, t1, c1, t2, c2) \
+ ((c2) | (((c1) | ((c0) | ((t2) | ((t1) | (t0) << 2) << 2) << 5) << 5) << 3))
+
+/* Dissect a type information field into the type and count fields. */
+#define _IOT_TYPE0(type) (((unsigned int) (type) >> 17) & 3)
+#define _IOT_TYPE1(type) (((unsigned int) (type) >> 15) & 3)
+#define _IOT_TYPE2(type) (((unsigned int) (type) >> 13) & 3)
+#define _IOT_COUNT0(type) (((unsigned int) (type) >> 8) & 0x1f)
+#define _IOT_COUNT1(type) (((unsigned int) (type) >> 3) & 0x1f)
+#define _IOT_COUNT2(type) (((unsigned int) (type) >> 0) & 3)
+
+/* Construct an ioctl from all the broken-out fields. */
+#define _IOCT(inout, group, num, t0, c0, t1, c1, t2, c2) \
+ _IOC ((inout), (group), (num), _IOT ((t0), (c0), (t1), (c1), (t2), (c2)))
+
+/* Standard flavors of ioctls.
+ _IOT_foobar is defined either in this file,
+ or where struct foobar is defined. */
+#define _IO(g, n) _IOC (IOC_VOID, (g), (n), 0)
+#define _IOR(g, n, t) _IOC (IOC_OUT, (g), (n), _IOT_##t)
+#define _IOW(g, n, t) _IOC (IOC_IN, (g), (n), _IOT_##t)
+#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)
+
+/* Construct a type information field for
+ a single argument of the scalar TYPE. */
+#define _IOT_SIMPLE(type) _IOT (_IOTS (type), 1, 0, 0, 0, 0)
+
+/* Basic C types. */
+#define _IOT_int _IOT_SIMPLE (int)
+#define _IOT_char _IOT_SIMPLE (char)
+#define _IOT_short _IOT_SIMPLE (short)
+
+
+/* ioctls verbatim from 4.4 <sys/ioctl.h>, with `struct' keywords removed. */
+
+#define TIOCMODG _IOR('t', 3, int) /* get modem control state */
+#define TIOCMODS _IOW('t', 4, int) /* set modem control state */
+#define TIOCM_LE 0001 /* line enable */
+#define TIOCM_DTR 0002 /* data terminal ready */
+#define TIOCM_RTS 0004 /* request to send */
+#define TIOCM_ST 0010 /* secondary transmit */
+#define TIOCM_SR 0020 /* secondary receive */
+#define TIOCM_CTS 0040 /* clear to send */
+#define TIOCM_CAR 0100 /* carrier detect */
+#define TIOCM_CD TIOCM_CAR
+#define TIOCM_RNG 0200 /* ring */
+#define TIOCM_RI TIOCM_RNG
+#define TIOCM_DSR 0400 /* data set ready */
+ /* 8-10 compat */
+#define TIOCEXCL _IO('t', 13) /* set exclusive use of tty */
+#define TIOCNXCL _IO('t', 14) /* reset exclusive use of tty */
+ /* 15 unused */
+#define TIOCFLUSH _IOW('t', 16, int) /* flush buffers */
+ /* 17-18 compat */
+#define TIOCGETA _IOR('t', 19, termios) /* get termios struct */
+#define TIOCSETA _IOW('t', 20, termios) /* set termios struct */
+#define TIOCSETAW _IOW('t', 21, termios) /* drain output, set */
+#define TIOCSETAF _IOW('t', 22, termios) /* drn out, fls in, set */
+#define TIOCGETD _IOR('t', 26, int) /* get line discipline */
+#define TIOCSETD _IOW('t', 27, int) /* set line discipline */
+ /* 127-124 compat */
+#define TIOCSBRK _IO('t', 123) /* set break bit */
+#define TIOCCBRK _IO('t', 122) /* clear break bit */
+#define TIOCSDTR _IO('t', 121) /* set data terminal ready */
+#define TIOCCDTR _IO('t', 120) /* clear data terminal ready */
+#define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */
+#define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */
+ /* 117-116 compat */
+#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
+#define TIOCSTI _IOW('t', 114, char) /* simulate terminal input */
+#define TIOCNOTTY _IO('t', 113) /* void tty association */
+#define TIOCPKT _IOW('t', 112, int) /* pty: set/clear packet mode */
+#define TIOCPKT_DATA 0x00 /* data packet */
+#define TIOCPKT_FLUSHREAD 0x01 /* flush packet */
+#define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */
+#define TIOCPKT_STOP 0x04 /* stop output */
+#define TIOCPKT_START 0x08 /* start output */
+#define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */
+#define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */
+#define TIOCPKT_IOCTL 0x40 /* state change of pty driver */
+#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */
+#define TIOCSTART _IO('t', 110) /* start output, like ^Q */
+#define TIOCMSET _IOW('t', 109, int) /* set all modem bits */
+#define TIOCMBIS _IOW('t', 108, int) /* bis modem bits */
+#define TIOCMBIC _IOW('t', 107, int) /* bic modem bits */
+#define TIOCMGET _IOR('t', 106, int) /* get all modem bits */
+#define TIOCREMOTE _IOW('t', 105, int) /* remote input editing */
+#define TIOCGWINSZ _IOR('t', 104, winsize) /* get window size */
+#define TIOCSWINSZ _IOW('t', 103, winsize) /* set window size */
+#define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */
+#define UIOCCMD(n) _IO('u', n) /* usr cntl op "n" */
+#define TIOCCONS _IOW('t', 98, int) /* become virtual console */
+#define TIOCSCTTY _IO('t', 97) /* become controlling tty */
+#define TIOCEXT _IOW('t', 96, int) /* pty: external processing */
+#define TIOCSIG _IO('t', 95) /* pty: generate signal */
+#define TIOCDRAIN _IO('t', 94) /* wait till output drained */
+
+#define TTYDISC 0 /* termios tty line discipline */
+#define TABLDISC 3 /* tablet discipline */
+#define SLIPDISC 4 /* serial IP discipline */
+
+
+#define FIOCLEX _IO('f', 1) /* set close on exec on fd */
+#define FIONCLEX _IO('f', 2) /* remove close on exec */
+#define FIONREAD _IOR('f', 127, int) /* get # bytes to read */
+#define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */
+#define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */
+#define FIOSETOWN _IOW('f', 124, int) /* set owner */
+#define FIOGETOWN _IOR('f', 123, int) /* get owner */
+
+/* socket i/o controls */
+#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */
+#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */
+#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */
+#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */
+#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */
+#define SIOCSPGRP _IOW('s', 8, int) /* set process group */
+#define SIOCGPGRP _IOR('s', 9, int) /* get process group */
+
+#define SIOCADDRT _IOW('r', 10, ortentry) /* add route */
+#define SIOCDELRT _IOW('r', 11, ortentry) /* delete route */
+
+#define SIOCSIFADDR _IOW('i', 12, ifreq) /* set ifnet address */
+#define OSIOCGIFADDR _IOWR('i',13, ifreq) /* get ifnet address */
+#define SIOCGIFADDR _IOWR('i',33, ifreq) /* get ifnet address */
+#define SIOCSIFDSTADDR _IOW('i', 14, ifreq) /* set p-p address */
+#define OSIOCGIFDSTADDR _IOWR('i',15, ifreq) /* get p-p address */
+#define SIOCGIFDSTADDR _IOWR('i',34, ifreq) /* get p-p address */
+#define SIOCSIFFLAGS _IOW('i', 16, ifreq) /* set ifnet flags */
+#define SIOCGIFFLAGS _IOWR('i',17, ifreq) /* get ifnet flags */
+#define OSIOCGIFBRDADDR _IOWR('i',18, ifreq) /* get broadcast addr */
+#define SIOCGIFBRDADDR _IOWR('i',35, ifreq) /* get broadcast addr */
+#define SIOCSIFBRDADDR _IOW('i',19, ifreq) /* set broadcast addr */
+#define OSIOCGIFCONF _IOWR('i',20, ifconf) /* get ifnet list */
+#define SIOCGIFCONF _IOWR('i',36, ifconf) /* get ifnet list */
+#define OSIOCGIFNETMASK _IOWR('i',21, ifreq) /* get net addr mask */
+#define SIOCGIFNETMASK _IOWR('i',37, ifreq) /* get net addr mask */
+#define SIOCSIFNETMASK _IOW('i',22, ifreq) /* set net addr mask */
+#define SIOCGIFMETRIC _IOWR('i',23, ifreq) /* get IF metric */
+#define SIOCSIFMETRIC _IOW('i',24, ifreq) /* set IF metric */
+#define SIOCDIFADDR _IOW('i',25, ifreq) /* delete IF addr */
+#define SIOCAIFADDR _IOW('i',26, ifaliasreq) /* add/chg IF alias */
+
+#define SIOCSARP _IOW('i', 30, arpreq) /* set arp entry */
+#define OSIOCGARP _IOWR('i',31, arpreq) /* get arp entry */
+#define SIOCGARP _IOWR('i',38, arpreq) /* get arp entry */
+#define SIOCDARP _IOW('i', 32, arpreq) /* delete arp entry */
+
+
+/* Compatibility with 4.3 BSD terminal driver.
+ From 4.4 <sys/ioctl_compat.h>. */
+
+#ifdef USE_OLD_TTY
+# undef TIOCGETD
+# define TIOCGETD _IOR('t', 0, int) /* get line discipline */
+# undef TIOCSETD
+# define TIOCSETD _IOW('t', 1, int) /* set line discipline */
+#else
+# define OTIOCGETD _IOR('t', 0, int) /* get line discipline */
+# define OTIOCSETD _IOW('t', 1, int) /* set line discipline */
+#endif
+#define TIOCHPCL _IO('t', 2) /* hang up on last close */
+#define TIOCGETP _IOR('t', 8,sgttyb)/* get parameters -- gtty */
+#define TIOCSETP _IOW('t', 9,sgttyb)/* set parameters -- stty */
+#define TIOCSETN _IOW('t',10,sgttyb)/* as above, but no flushtty*/
+#define TIOCSETC _IOW('t',17,tchars)/* set special characters */
+#define TIOCGETC _IOR('t',18,tchars)/* get special characters */
+#define TANDEM 0x00000001 /* send stopc on out q full */
+#define CBREAK 0x00000002 /* half-cooked mode */
+#define LCASE 0x00000004 /* simulate lower case */
+#define ECHO 0x00000008 /* echo input */
+#define CRMOD 0x00000010 /* map \r to \r\n on output */
+#define RAW 0x00000020 /* no i/o processing */
+#define ODDP 0x00000040 /* get/send odd parity */
+#define EVENP 0x00000080 /* get/send even parity */
+#define ANYP 0x000000c0 /* get any parity/send none */
+#define NLDELAY 0x00000300 /* \n delay */
+#define NL0 0x00000000
+#define NL1 0x00000100 /* tty 37 */
+#define NL2 0x00000200 /* vt05 */
+#define NL3 0x00000300
+#define TBDELAY 0x00000c00 /* horizontal tab delay */
+#define TAB0 0x00000000
+#define TAB1 0x00000400 /* tty 37 */
+#define TAB2 0x00000800
+#define XTABS 0x00000c00 /* expand tabs on output */
+#define CRDELAY 0x00003000 /* \r delay */
+#define CR0 0x00000000
+#define CR1 0x00001000 /* tn 300 */
+#define CR2 0x00002000 /* tty 37 */
+#define CR3 0x00003000 /* concept 100 */
+#define VTDELAY 0x00004000 /* vertical tab delay */
+#define FF0 0x00000000
+#define FF1 0x00004000 /* tty 37 */
+#define BSDELAY 0x00008000 /* \b delay */
+#define BS0 0x00000000
+#define BS1 0x00008000
+#define ALLDELAY (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)
+#define CRTBS 0x00010000 /* do backspacing for crt */
+#define PRTERA 0x00020000 /* \ ... / erase */
+#define CRTERA 0x00040000 /* " \b " to wipe out char */
+#define TILDE 0x00080000 /* hazeltine tilde kludge */
+#define MDMBUF 0x00100000 /*start/stop output on carrier*/
+#define LITOUT 0x00200000 /* literal output */
+#define TOSTOP 0x00400000 /*SIGSTOP on background output*/
+#define FLUSHO 0x00800000 /* flush output to terminal */
+#define NOHANG 0x01000000 /* (no-op) was no SIGHUP on carrier drop */
+#define L001000 0x02000000
+#define CRTKIL 0x04000000 /* kill line with " \b " */
+#define PASS8 0x08000000
+#define CTLECH 0x10000000 /* echo control chars as ^X */
+#define PENDIN 0x20000000 /* tp->t_rawq needs reread */
+#define DECCTQ 0x40000000 /* only ^Q starts after ^S */
+#define NOFLSH 0x80000000 /* no output flush on signal */
+#define TIOCLBIS _IOW('t', 127, int) /* bis local mode bits */
+#define TIOCLBIC _IOW('t', 126, int) /* bic local mode bits */
+#define TIOCLSET _IOW('t', 125, int) /* set entire local mode word */
+#define TIOCLGET _IOR('t', 124, int) /* get local modes */
+#define LCRTBS (CRTBS>>16)
+#define LPRTERA (PRTERA>>16)
+#define LCRTERA (CRTERA>>16)
+#define LTILDE (TILDE>>16)
+#define LMDMBUF (MDMBUF>>16)
+#define LLITOUT (LITOUT>>16)
+#define LTOSTOP (TOSTOP>>16)
+#define LFLUSHO (FLUSHO>>16)
+#define LNOHANG (NOHANG>>16)
+#define LCRTKIL (CRTKIL>>16)
+#define LPASS8 (PASS8>>16)
+#define LCTLECH (CTLECH>>16)
+#define LPENDIN (PENDIN>>16)
+#define LDECCTQ (DECCTQ>>16)
+#define LNOFLSH (NOFLSH>>16)
+#define TIOCSLTC _IOW('t',117,ltchars)/* set local special chars*/
+#define TIOCGLTC _IOR('t',116,ltchars)/* get local special chars*/
+#define OTIOCCONS _IO('t', 98) /* for hp300 -- sans int arg */
+#define OTTYDISC 0
+#define NETLDISC 1
+#define NTTYDISC 2
+
+/* From 4.4 <sys/ttydev.h>. */
+#ifdef USE_OLD_TTY
+#define B0 0
+#define B50 1
+#define B75 2
+#define B110 3
+#define B134 4
+#define B150 5
+#define B200 6
+#define B300 7
+#define B600 8
+#define B1200 9
+#define B1800 10
+#define B2400 11
+#define B4800 12
+#define B9600 13
+#define EXTA 14
+#define EXTB 15
+#endif /* USE_OLD_TTY */
+
+
+#endif /* ioctls.h */
diff --git a/sysdeps/mach/hurd/isatty.c b/sysdeps/mach/hurd/isatty.c
new file mode 100644
index 0000000..e04793a
--- /dev/null
+++ b/sysdeps/mach/hurd/isatty.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd/fd.h>
+#include <hurd/term.h>
+
+/* Return 1 if FD is a terminal, 0 if not. */
+int
+DEFUN(__isatty, (fd), int fd)
+{
+ error_t err;
+ mach_port_t id;
+
+ err = HURD_DPORT_USE (fd, __term_getctty (port, &id));
+ if (! err)
+ __mach_port_deallocate (__mach_task_self (), id);
+
+ return !err;
+}
+
+weak_alias (__isatty, isatty)
diff --git a/sysdeps/mach/hurd/kill.c b/sysdeps/mach/hurd/kill.c
new file mode 100644
index 0000000..0d4af62
--- /dev/null
+++ b/sysdeps/mach/hurd/kill.c
@@ -0,0 +1,106 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <errno.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <hurd.h>
+#include <hurd/port.h>
+#include <hurd/signal.h>
+#include <hurd/msg.h>
+
+/* Send signal SIG to process number PID. If PID is zero,
+ send SIG to all processes in the current process's process group.
+ If PID is < -1, send SIG to all processes in process group - PID. */
+int
+__kill (pid_t pid, int sig)
+{
+ int delivered = 0; /* Set when we deliver any signal. */
+ error_t err;
+ mach_port_t proc;
+ struct hurd_userlink ulink;
+
+ inline void kill_pid (pid_t pid) /* Kill one PID. */
+ {
+ /* SIGKILL is not delivered as a normal signal.
+ Sending SIGKILL to a process means to terminate its task. */
+ if (sig == SIGKILL)
+ /* Fetch the process's task port and terminate the task. We
+ loop in case the process execs and changes its task port.
+ If the old task port dies after we fetch it but before we
+ send the RPC, we get MACH_SEND_INVALID_DEST; if it dies
+ after we send the RPC request but before it is serviced, we
+ get MIG_SERVER_DIED. */
+ do
+ {
+ task_t refport;
+ err = __proc_pid2task (proc, pid, &refport);
+ if (!err)
+ {
+ err = __task_terminate (refport);
+ __mach_port_deallocate (__mach_task_self (), refport);
+ }
+ } while (err == MACH_SEND_INVALID_DEST ||
+ err == MIG_SERVER_DIED);
+ else
+ err = HURD_MSGPORT_RPC (__proc_getmsgport (proc, pid, &msgport),
+ __proc_pid2task (proc, pid, &refport) ?
+ __proc_getsidport (proc, &refport) : 0, 1,
+ /* If no msgport, we cannot send a signal. */
+ msgport == MACH_PORT_NULL ? EPERM :
+ __msg_sig_post (msgport, sig, refport));
+ if (! err)
+ delivered = 1;
+ }
+
+ proc = _hurd_port_get (&_hurd_ports[INIT_PORT_PROC], &ulink);
+
+ if (pid <= 0)
+ {
+ /* Send SIG to each process in pgrp (- PID). */
+ pid_t pidbuf[10], *pids = pidbuf;
+ mach_msg_type_number_t i, npids = sizeof (pidbuf) / sizeof (pidbuf[0]);
+
+ err = __proc_getpgrppids (proc, - pid, &pids, &npids);
+ if (!err)
+ {
+ for (i = 0; i < npids; ++i)
+ {
+ kill_pid (pids[i]);
+ if (err == ESRCH)
+ /* The process died already. Ignore it. */
+ err = 0;
+ }
+ if (pids != pidbuf)
+ __vm_deallocate (__mach_task_self (),
+ (vm_address_t) pids, npids * sizeof (pids[0]));
+ }
+ }
+ else
+ kill_pid (pid);
+
+ _hurd_port_free (&_hurd_ports[INIT_PORT_PROC], &ulink, proc);
+
+ /* If we delivered no signals, but ERR is clear, this must mean that
+ every kill_pid call failed with ESRCH, meaning all the processes in
+ the pgrp died between proc_getpgrppids and kill_pid; in that case we
+ fail with ESRCH. */
+ return delivered ? 0 : __hurd_fail (err ?: ESRCH);
+}
+
+weak_alias (__kill, kill)
diff --git a/sysdeps/mach/hurd/libc-ldscript b/sysdeps/mach/hurd/libc-ldscript
new file mode 100644
index 0000000..26aca50
--- /dev/null
+++ b/sysdeps/mach/hurd/libc-ldscript
@@ -0,0 +1,5 @@
+/* This linker script is installed as /lib/libc.a.
+ It makes -lc become just like -( -lcrt -lmachuser -lhurduser -).
+ */
+
+GROUP ( libcrt.a libmachuser.a libhurduser.a )
diff --git a/sysdeps/mach/hurd/link.c b/sysdeps/mach/hurd/link.c
new file mode 100644
index 0000000..11262f5
--- /dev/null
+++ b/sysdeps/mach/hurd/link.c
@@ -0,0 +1,60 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <hurd.h>
+
+/* Make a link to FROM called TO. */
+int
+DEFUN(__link, (from, to), CONST char *from AND CONST char *to)
+{
+ error_t err;
+ file_t oldfile, linknode, todir;
+ char *toname;
+
+ oldfile = __file_name_lookup (from, 0, 0);
+ if (oldfile == MACH_PORT_NULL)
+ return -1;
+
+ /* The file_getlinknode RPC returns the port that should be passed to
+ the receiving filesystem (the one containing TODIR) in dir_link. */
+
+ err = __file_getlinknode (oldfile, &linknode);
+ __mach_port_deallocate (__mach_task_self (), oldfile);
+ if (err)
+ return __hurd_fail (err);
+
+ todir = __file_name_split (to, &toname);
+ if (todir != MACH_PORT_NULL)
+ {
+ err = __dir_link (linknode, todir, toname);
+ __mach_port_deallocate (__mach_task_self (), todir);
+ }
+ __mach_port_deallocate (__mach_task_self (), linknode);
+ if (todir == MACH_PORT_NULL)
+ return -1;
+
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+
+weak_alias (__link, link)
diff --git a/sysdeps/mach/hurd/listen.c b/sysdeps/mach/hurd/listen.c
new file mode 100644
index 0000000..2f9c412
--- /dev/null
+++ b/sysdeps/mach/hurd/listen.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <sys/socket.h>
+#include <hurd/socket.h>
+
+/* Prepare to accept connections on socket FD.
+ N connection requests will be queued before further requests are refused.
+ Returns 0 on success, -1 for errors. */
+int
+DEFUN(listen, (fd, n), int fd AND unsigned int n)
+{
+ error_t err = HURD_DPORT_USE (fd, __socket_listen (port, n));
+ if (err)
+ return __hurd_dfail (fd, err);
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/local_lim.h b/sysdeps/mach/hurd/local_lim.h
new file mode 100644
index 0000000..766bd25
--- /dev/null
+++ b/sysdeps/mach/hurd/local_lim.h
@@ -0,0 +1,40 @@
+/* Minimum guaranteed maximum values for system limits. Hurd version.
+
+Copyright (C) 1993, 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. */
+
+/* GNU has no arbitrary fixed limits on these things, so we don't
+ define the macros. Some things are unlimited. Some are in fact
+ limited but the limit is run-time dependent and fetched with
+ `sysconf' or `pathconf'.
+
+ POSIX.1 requires that we define NGROUPS_MAX (though none of the others
+ is required). GNU allows any number of supplementary groups,
+ dynamically allocated. So we pick a number which seems vaguely
+ suitable, and `sysconf' will return a number at least as large. */
+
+#define NGROUPS_MAX 256
+
+/* The maximum number of symbolic links that are allowed in a single file
+ name resolution. When a further link is encountered, the call returns
+ ELOOP. This name is a GNU extension; POSIX.1 has no such limit, and BSD
+ calls it MAXSYMLINKS in <sys/param.h>. */
+
+#ifdef __USE_GNU /* 1003.1a defines this */
+#define SYMLOOP_MAX 8
+#endif
diff --git a/sysdeps/mach/hurd/lseek.c b/sysdeps/mach/hurd/lseek.c
new file mode 100644
index 0000000..396d2b9
--- /dev/null
+++ b/sysdeps/mach/hurd/lseek.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+
+/* Seek to OFFSET on FD, starting from WHENCE. */
+off_t
+DEFUN(__lseek, (fd, offset, whence), int fd AND off_t offset AND int whence)
+{
+ error_t err;
+ if (err = HURD_DPORT_USE (fd, __io_seek (port, offset, whence, &offset)))
+ return __hurd_dfail (fd, err);
+ return offset;
+}
+
+weak_alias (__lseek, lseek)
diff --git a/sysdeps/mach/hurd/lstat.c b/sysdeps/mach/hurd/lstat.c
new file mode 100644
index 0000000..21eb448
--- /dev/null
+++ b/sysdeps/mach/hurd/lstat.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <stddef.h>
+#include <fcntl.h>
+#include <hurd.h>
+
+int
+DEFUN(__lstat, (file, buf), CONST char *file AND struct stat *buf)
+{
+ error_t err;
+ file_t port = __file_name_lookup (file, O_NOLINK, 0);
+ if (port == MACH_PORT_NULL)
+ return -1;
+ err = __io_stat (port, buf);
+ __mach_port_deallocate (__mach_task_self (), port);
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+
+weak_alias (__lstat, lstat)
diff --git a/sysdeps/mach/hurd/mig-reply.c b/sysdeps/mach/hurd/mig-reply.c
new file mode 100644
index 0000000..feb0325
--- /dev/null
+++ b/sysdeps/mach/hurd/mig-reply.c
@@ -0,0 +1,86 @@
+/* Copyright (C) 1994, 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. */
+
+#include <mach.h>
+#include <hurd/threadvar.h>
+
+#define GETPORT \
+ mach_port_t *portloc = \
+ (mach_port_t *) __hurd_threadvar_location (_HURD_THREADVAR_MIG_REPLY)
+#define reply_port (use_threadvar ? *portloc : global_reply_port)
+
+static int use_threadvar;
+static mach_port_t global_reply_port;
+
+/* These functions are called by MiG-generated code. */
+
+/* Called by MiG to get a reply port. */
+mach_port_t
+__mig_get_reply_port (void)
+{
+ GETPORT;
+
+ if (reply_port == MACH_PORT_NULL)
+ reply_port = __mach_reply_port ();
+
+ return reply_port;
+}
+weak_alias (__mig_get_reply_port, mig_get_reply_port)
+
+/* Called by MiG to deallocate the reply port. */
+void
+__mig_dealloc_reply_port (mach_port_t arg)
+{
+ mach_port_t port;
+
+ GETPORT;
+
+ port = reply_port;
+ reply_port = MACH_PORT_NULL; /* So the mod_refs RPC won't use it. */
+ __mach_port_mod_refs (__mach_task_self (), port,
+ MACH_PORT_RIGHT_RECEIVE, -1);
+}
+weak_alias (__mig_dealloc_reply_port, mig_dealloc_reply_port)
+
+/* Called by mig interfaces when done with a port. Used to provide the
+ same interface as needed when a custom allocator is used. */
+void
+__mig_put_reply_port(mach_port_t port)
+{
+ /* Do nothing. */
+}
+weak_alias (__mig_put_reply_port, mig_put_reply_port)
+
+/* Called at startup with STACK == NULL. When per-thread variables are set
+ up, this is called again with STACK set to the new stack being switched
+ to, where per-thread variables should be set up. */
+void
+__mig_init (void *stack)
+{
+ use_threadvar = stack != 0;
+
+ if (use_threadvar)
+ {
+ /* Recycle the reply port used before multithreading was enabled. */
+ mach_port_t *portloc = (mach_port_t *)
+ __hurd_threadvar_location_from_sp (_HURD_THREADVAR_MIG_REPLY, stack);
+ *portloc = global_reply_port;
+ global_reply_port = MACH_PORT_NULL;
+ }
+}
+weak_alias (__mig_init, mig_init)
diff --git a/sysdeps/mach/hurd/mips/exc2signal.c b/sysdeps/mach/hurd/mips/exc2signal.c
new file mode 100644
index 0000000..f907c89
--- /dev/null
+++ b/sysdeps/mach/hurd/mips/exc2signal.c
@@ -0,0 +1,98 @@
+/* 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.
+
+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. */
+
+#include <hurd.h>
+#include <hurd/signal.h>
+#include <mach/exception.h>
+
+/* Translate the Mach exception codes, as received in an `exception_raise' RPC,
+ into a signal number and signal subcode. */
+
+void
+_hurd_exception2signal (int exception, int code, int subcode,
+ int *signo, long int *sigcode, int *error)
+{
+ *error = 0;
+
+ switch (exception)
+ {
+ default:
+ *signo = SIGIOT;
+ *sigcode = exception;
+ break;
+
+ case EXC_BAD_ACCESS:
+ if (code == KERN_PROTECTION_FAILURE)
+ *signo = SIGSEGV;
+ else
+ *signo = SIGBUS;
+ *sigcode = subcode;
+ *error = code;
+ break;
+
+ case EXC_BAD_INSTRUCTION:
+ *signo = SIGILL;
+ if (code == EXC_MIPS_II)
+ *sigcode = code;
+ else
+ *sigcode = 0;
+ break;
+
+ case EXC_ARITHMETIC:
+ switch (code)
+ {
+ case EXC_MIPS_OV: /* integer overflow */
+ *signo = SIGFPE;
+ *sigcode = EXC_MIPS_FLT_OVERFLOW;
+ break;
+
+ default:
+ *signo = SIGFPE;
+ *sigcode = 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)
+ *signo = SIGILL;
+ else
+ *signo = SIGFPE;
+ *sigcode = subcode;
+ break;
+ }
+ break;
+
+ case EXC_EMULATION:
+ /* 3.0 doesn't give this one, why, I don't know. */
+ *signo = SIGEMT;
+ *sigcode = 0;
+ break;
+
+ case EXC_SOFTWARE:
+ *signo = SIGEMT;
+ *sigcode = 0;
+ break;
+
+ case EXC_BREAKPOINT:
+ *signo = SIGTRAP;
+ *sigcode = code;
+ break;
+ }
+}
diff --git a/sysdeps/mach/hurd/mips/init-fault.c b/sysdeps/mach/hurd/mips/init-fault.c
new file mode 100644
index 0000000..e6f8acf
--- /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) 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. */
+
+#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/longjmp-ctx.c b/sysdeps/mach/hurd/mips/longjmp-ctx.c
new file mode 100644
index 0000000..0c78f6b
--- /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) 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. */
+
+#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
new file mode 100644
index 0000000..980a2ce
--- /dev/null
+++ b/sysdeps/mach/hurd/mips/longjmp-ts.c
@@ -0,0 +1,45 @@
+/* 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. */
+
+#include <hurd/signal.h>
+#include <setjmp.h>
+#include <mach/thread_status.h>
+
+
+/* Set up STATE to do the equivalent of `longjmp (ENV, VAL);'. */
+
+void
+_hurd_longjmp_thread_state (void *state, jmp_buf env, int val)
+{
+ struct mips_thread_state *ts = state;
+
+ ts->r16 = env[0].__jmpbuf[0].__regs[0];
+ ts->r17 = env[0].__jmpbuf[0].__regs[1];
+ ts->r18 = env[0].__jmpbuf[0].__regs[2];
+ ts->r19 = env[0].__jmpbuf[0].__regs[3];
+ ts->r20 = env[0].__jmpbuf[0].__regs[4];
+ ts->r21 = env[0].__jmpbuf[0].__regs[5];
+ ts->r22 = env[0].__jmpbuf[0].__regs[6];
+ ts->r23 = env[0].__jmpbuf[0].__regs[7];
+ ts->r28 = (int) env[0].__jmpbuf[0].__gp;
+ ts->r29 = (int) env[0].__jmpbuf[0].__sp;
+ ts->r30 = (int) env[0].__jmpbuf[0].__fp;
+ ts->pc = (int) env[0].__jmpbuf[0].__pc;
+ ts->r2 = val ?: 1;
+}
diff --git a/sysdeps/mach/hurd/mips/sigcontext.h b/sysdeps/mach/hurd/mips/sigcontext.h
new file mode 100644
index 0000000..81d1f25
--- /dev/null
+++ b/sysdeps/mach/hurd/mips/sigcontext.h
@@ -0,0 +1,71 @@
+/* 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. */
+
+/* Signal handlers are actually called:
+ void handler (int sig, int code, struct sigcontext *scp); */
+
+/* State of this thread when the signal was taken. */
+struct sigcontext
+ {
+ /* These first members are machine-independent. */
+
+ int sc_onstack; /* Nonzero if running on sigstack. */
+ __sigset_t sc_mask; /* Blocked signals to restore. */
+
+ /* MiG reply port this thread is using. */
+ unsigned int sc_reply_port;
+
+ /* Port this thread is doing an interruptible RPC on. */
+ unsigned int sc_intr_port;
+
+ /* Error code associated with this signal (interpreted as `error_t'). */
+ int sc_error;
+
+ /* All following members are machine-dependent. The rest of this
+ structure is written to be laid out identically to:
+ {
+ struct mips_thread_state ts;
+ struct mips_exc_state es;
+ struct mips_float_state fs;
+ }
+ trampoline.c knows this, so it must be changed if this changes. */
+#define sc_mips_thread_state sc_gpr /* Beginning of correspondence. */
+ int sc_gpr[31]; /* "General" registers; [0] is r1. */
+ int sc_mdlo, sc_mdhi; /* Low and high multiplication results. */
+ int sc_pc; /* Instruction pointer. */
+
+ /* struct mips_exc_state */
+#define sc_mips_exc_state sc_cause
+ unsigned int sc_cause; /* Machine-level trap code. */
+#define SC_CAUSE_SST 0x00000044
+ unsigned int sc_badvaddr;
+ unsigned int sc_coproc_used; /* Which coprocessors the thread has used. */
+#define SC_COPROC_USE_COP0 1 /* (by definition) */
+#define SC_COPROC_USE_COP1 2 /* FPA */
+#define SC_COPROC_USE_FPU SC_COPROC_USE_COP1
+#define SC_COPROC_USE_COP2 4
+#define SC_COPROC_USE_COP3 8
+
+ /* struct mips_float_state
+ This is only filled in if the SC_COPROC_USE_FPU bit
+ is set in sc_coproc_used. */
+#define sc_mips_float_state sc_fpr
+ int sc_fpr[32]; /* FP registers. */
+ int sc_fpcsr; /* FPU status register. */
+ int sc_fpeir; /* FP exception instruction register. */
+ };
diff --git a/sysdeps/mach/hurd/mips/sigreturn.c b/sysdeps/mach/hurd/mips/sigreturn.c
new file mode 100644
index 0000000..7396a8b
--- /dev/null
+++ b/sysdeps/mach/hurd/mips/sigreturn.c
@@ -0,0 +1,169 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#include <hurd.h>
+#include <hurd/signal.h>
+#include <hurd/threadvar.h>
+#include <stdlib.h>
+
+int
+__sigreturn (struct sigcontext *scp)
+{
+ struct hurd_sigstate *ss;
+ mach_port_t *reply_port;
+
+ if (scp == NULL || (scp->sc_mask & _SIG_CANT_MASK))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ss = _hurd_self_sigstate ();
+ __spin_lock (&ss->lock);
+
+ /* Restore the set of blocked signals, and the intr_port slot. */
+ ss->blocked = scp->sc_mask;
+ ss->intr_port = scp->sc_intr_port;
+
+ /* Check for pending signals that were blocked by the old set. */
+ if (ss->pending & ~ss->blocked)
+ {
+ /* There are pending signals that just became unblocked. Wake up the
+ signal thread to deliver them. But first, squirrel away SCP where
+ 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 ());
+ /* If a pending signal was handled, sig_post never returned. */
+ __spin_lock (&ss->lock);
+ }
+
+ if (scp->sc_onstack)
+ {
+ ss->sigaltstack.ss_flags &= ~SA_ONSTACK; /* XXX threadvars */
+ /* XXX cannot unlock until off sigstack */
+ abort ();
+ }
+ else
+ __spin_unlock (&ss->lock);
+
+ /* Destroy the MiG reply port used by the signal handler, and restore the
+ reply port in use by the thread when interrupted. */
+ reply_port =
+ (mach_port_t *) __hurd_threadvar_location (_HURD_THREADVAR_MIG_REPLY);
+ if (*reply_port)
+ __mach_port_destroy (__mach_task_self (), *reply_port);
+ *reply_port = scp->sc_reply_port;
+
+ if (scp->sc_coproc_used & SC_COPROC_USE_FPU)
+ {
+ /* Restore FPU state. */
+#define restore_fpr(n) \
+ asm volatile ("l.d $f" #n ",%0" : : "m" (scp->sc_fpr[n]))
+
+ /* Restore floating-point registers. */
+ 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);
+
+ /* Restore the floating-point control/status register ($f31). */
+ asm volatile ("ctc1 %0,$f31" : : "r" (scp->sc_fpcsr));
+ }
+
+ /* Load all the registers from the sigcontext. */
+#define restore_gpr(n) \
+ asm volatile ("lw $" #n ",%0" : : "m" (scpreg->sc_gpr[n - 1]))
+
+ {
+ register const struct sigcontext *const scpreg asm ("$1") = scp;
+ register int *at asm ("$1");
+
+ /* First restore the multiplication result registers. The compiler
+ will use some temporary registers, so we do this before restoring
+ the general registers. */
+ asm volatile ("mtlo %0" : : "r" (scpreg->sc_mdlo));
+ asm volatile ("mthi %0" : : "r" (scpreg->sc_mdhi));
+
+ /* In the word after the saved PC, store the saved $1 value. */
+ (&scpreg->sc_pc)[1] = scpreg->sc_gpr[0];
+
+ asm volatile (".set noreorder; .set noat;");
+
+ /* Restore the normal registers. */
+ restore_gpr (2);
+ restore_gpr (3);
+ restore_gpr (4);
+ restore_gpr (5);
+ restore_gpr (6);
+ restore_gpr (7);
+ restore_gpr (8);
+ restore_gpr (9);
+ restore_gpr (10);
+ restore_gpr (11);
+ restore_gpr (12);
+ restore_gpr (13);
+ restore_gpr (14);
+ restore_gpr (15);
+ restore_gpr (16);
+ restore_gpr (17);
+ restore_gpr (18);
+ restore_gpr (19);
+ restore_gpr (20);
+ restore_gpr (21);
+ restore_gpr (22);
+ restore_gpr (23);
+ restore_gpr (24);
+ restore_gpr (25);
+ /* Registers 26-27 are kernel-only. */
+ restore_gpr (28);
+ restore_gpr (29); /* Stack pointer. */
+ restore_gpr (30); /* Frame pointer. */
+ restore_gpr (31); /* Return address. */
+
+ 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 (".set reorder; .set at;");
+ }
+
+ /* NOTREACHED */
+ return -1;
+}
+
+weak_alias (__sigreturn, sigreturn)
diff --git a/sysdeps/mach/hurd/mips/trampoline.c b/sysdeps/mach/hurd/mips/trampoline.c
new file mode 100644
index 0000000..f03ad58
--- /dev/null
+++ b/sysdeps/mach/hurd/mips/trampoline.c
@@ -0,0 +1,260 @@
+/* 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.
+
+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. */
+
+#include <hurd/signal.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;
+ };
+
+
+struct sigcontext *
+_hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
+ int signo, long int sigcode,
+ int rpc_wait,
+ struct machine_thread_all_state *state)
+{
+
+ __label__ trampoline, rpc_wait_trampoline;
+ void *sigsp;
+ struct sigcontext *scp;
+
+ 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))
+ {
+ memcpy (&state->basic, &ss->context->sc_mips_thread_state,
+ sizeof (state->basic));
+ memcpy (&state->exc, &ss->context->sc_mips_exc_state,
+ sizeof (state->exc));
+ state->set = (1 << MIPS_THREAD_STATE) | (1 << MIPS_EXC_STATE);
+ if (state->exc.coproc_state & SC_COPROC_USE_FPU)
+ {
+ memcpy (&state->fpu, &ss->context->sc_mips_float_state,
+ 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))
+ return NULL;
+
+ if ((ss->actions[signo].sa_flags & SA_ONSTACK) &&
+ !(ss->sigaltstack.ss_flags & (SA_DISABLE|SA_ONSTACK)))
+ {
+ sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size;
+ ss->sigaltstack.ss_flags |= SA_ONSTACK;
+ /* XXX need to set up base of new stack for
+ per-thread variables, cthreads. */
+ }
+ 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;
+
+ if (! setjmp (_hurd_sigthread_fault_env))
+ {
+ /* Set up the sigcontext from the current state of the thread. */
+
+ scp->sc_onstack = ss->sigaltstack.ss_flags & SA_ONSTACK ? 1 : 0;
+
+ /* struct sigcontext is laid out so that starting at sc_gpr
+ mimics a struct mips_thread_state. */
+ memcpy (&scp->sc_mips_thread_state,
+ &state->basic, sizeof (state->basic));
+
+ /* 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)))
+ 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)
+ {
+ /* The signalee thread was blocked in a mach_msg_trap system call,
+ still waiting for a reply. We will have it run the special
+ trampoline code which retries the message receive before running
+ the signal handler.
+
+ To do this we change the OPTION argument in its registers to
+ enable only message reception, since the request message has
+ already been sent. */
+
+ /* The system call arguments are stored in consecutive registers
+ starting with a0 ($4). */
+ struct mach_msg_trap_args *args = (void *) &state->basic.r4;
+
+ 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. */
+ args->option &= ~MACH_SEND_MSG;
+
+ state->basic.pc = (int) &&rpc_wait_trampoline;
+ state->basic.r29 = (int) sigsp; /* $29 is the stack pointer register. */
+ /* 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];
+ /* 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.r19 = (int) scp;
+ }
+ else
+ {
+ state->basic.pc = (int) &&trampoline;
+ state->basic.r29 = (int) sigsp;
+ state->basic.r4 = signo;
+ state->basic.r5 = sigcode;
+ state->basic.r6 = (int) scp;
+ }
+
+ /* We pass the handler function to the trampoline code in at ($1). */
+ state->basic.r1 = (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;
+
+ return scp;
+
+ /* The trampoline code follows. This is not actually executed as part of
+ this function, it is just convenient to write it that way. */
+
+ rpc_wait_trampoline:
+ /* This is the entry point when we have an RPC reply message to receive
+ before running the handler. The MACH_MSG_SEND bit has already been
+ cleared in the OPTION argument in our registers. For our convenience,
+ $3 points to the sc_gpr[1] member of the sigcontext (saved v0 ($2)). */
+ asm volatile
+ (".set noat; .set noreorder; .set nomacro\n"
+ /* Retry the interrupted mach_msg system call. */
+ "li $2, -25\n" /* mach_msg_trap */
+ "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"
+ /* 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");
+
+ trampoline:
+ /* Entry point for running the handler normally. The arguments to the
+ handler function are already in the standard registers:
+
+ a0 SIGNO
+ a1 SIGCODE
+ a2 SCP
+ */
+ asm volatile
+ ("jal $1; nop\n" /* Call the handler function. */
+ /* Call __sigreturn (SCP); this cannot return. */
+ "j %0\n"
+ "move $4, $16" /* Set up arg from saved SCP in delay slot. */
+ : : "i" (&__sigreturn));
+
+ /* NOTREACHED */
+ asm volatile (".set reorder; .set at; .set macro");
+
+ return NULL;
+}
+
+/* STATE describes a thread that had intr_port set (meaning it was inside
+ HURD_EINTR_RPC), after it has been thread_abort'd. It it looks to have
+ just completed a mach_msg_trap system call that returned
+ MACH_RCV_INTERRUPTED, return nonzero and set *PORT to the receive right
+ being waited on. */
+int
+_hurdsig_rcv_interrupted_p (struct machine_thread_all_state *state,
+ mach_port_t *port)
+{
+ const unsigned int *const pc = (void *) state->basic.pc;
+
+ if (_hurdsig_catch_fault (SIGSEGV))
+ assert (_hurdsig_fault_sigcode == (long int) pc);
+ else
+ {
+ if (state->basic.r2 == MACH_RCV_INTERRUPTED &&
+ pc[-1] == 0xc) /* syscall */
+ {
+ /* We did just return from a mach_msg_trap system call
+ doing a message receive that was interrupted.
+ Examine the parameters to find the receive right. */
+ struct mach_msg_trap_args *args = (void *) &state->basic.r4;
+
+ *port = args->rcv_name;
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/mkdir.c b/sysdeps/mach/hurd/mkdir.c
new file mode 100644
index 0000000..d477815
--- /dev/null
+++ b/sysdeps/mach/hurd/mkdir.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <hurd.h>
+
+/* Create a directory named FILE_NAME with protections MODE. */
+int
+DEFUN(__mkdir, (file_name, mode), CONST char *file_name AND mode_t mode)
+{
+ error_t err;
+ const char *name;
+ file_t parent = __file_name_split (file_name, (char **) &name);
+ if (parent == MACH_PORT_NULL)
+ return -1;
+ err = __dir_mkdir (parent, name, mode);
+ __mach_port_deallocate (__mach_task_self (), parent);
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+
+weak_alias (__mkdir, mkdir)
diff --git a/sysdeps/mach/hurd/mknod.c b/sysdeps/mach/hurd/mknod.c
new file mode 100644
index 0000000..cf1b4d0
--- /dev/null
+++ b/sysdeps/mach/hurd/mknod.c
@@ -0,0 +1,114 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <hurd.h>
+#include <hurd/paths.h>
+#include <fcntl.h>
+#include "stdio/_itoa.h"
+#include <string.h>
+
+/* Temporary hack; this belongs in a header file, probably types.h. */
+#define major(x) ((int)(((unsigned) (x) >> 8) & 0xff))
+#define minor(x) ((int)((x) & 0xff))
+
+
+/* Create a device file named FILE_NAME, with permission and special bits MODE
+ and device number DEV (which can be constructed from major and minor
+ device numbers with the `makedev' macro above). */
+int
+DEFUN(__mknod, (file_name, mode, dev),
+ CONST char *file_name AND mode_t mode AND dev_t dev)
+{
+ error_t err;
+ file_t dir, node;
+ char *name;
+ char buf[100], *bp;
+ const char *translator;
+ size_t len;
+
+ if (S_ISCHR (mode))
+ {
+ translator = _HURD_CHRDEV;
+ len = sizeof (_HURD_CHRDEV);
+ }
+ else if (S_ISBLK (mode))
+ {
+ translator = _HURD_BLKDEV;
+ len = sizeof (_HURD_BLKDEV);
+ }
+ else if (S_ISFIFO (mode))
+ {
+ translator = _HURD_FIFO;
+ len = sizeof (_HURD_FIFO);
+ }
+ else
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (! S_ISFIFO (mode))
+ {
+ /* We set the translator to "ifmt\0major\0minor\0", where IFMT
+ depends on the S_IFMT bits of our MODE argument, and MAJOR and
+ MINOR are ASCII decimal (octal or hex would do as well)
+ representations of our arguments. Thus the convention is that
+ CHRDEV and BLKDEV translators are invoked with two non-switch
+ arguments, giving the major and minor device numbers in %i format. */
+
+ bp = buf + sizeof (buf);
+ *--bp = '\0';
+ bp = _itoa (minor (dev), bp, 10, 0);
+ *--bp = '\0';
+ bp = _itoa (major (dev), bp, 10, 0);
+ memcpy (bp - len, translator, len);
+ translator = bp - len;
+ len = buf + sizeof (buf) - translator;
+ }
+
+ dir = __file_name_split (file_name, &name);
+ if (dir == MACH_PORT_NULL)
+ return -1;
+
+ /* Create a new, unlinked node in the target directory. */
+ err = __dir_mkfile (dir, O_WRITE, mode & ~S_IFMT & _hurd_umask, &node);
+
+ if (! err)
+ /* Set the node's translator to make it a device. */
+ err = __file_set_translator (node,
+ FS_TRANS_EXCL | FS_TRANS_SET,
+ FS_TRANS_EXCL | FS_TRANS_SET, 0,
+ translator, len,
+ MACH_PORT_NULL, MACH_MSG_TYPE_COPY_SEND);
+
+ if (! err)
+ /* Link the node, now a valid device, into the target directory. */
+ err = __dir_link (node, dir, name);
+
+ __mach_port_deallocate (__mach_task_self (), dir);
+ __mach_port_deallocate (__mach_task_self (), node);
+
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+
+weak_alias (__mknod, mknod)
diff --git a/sysdeps/mach/hurd/mmap.c b/sysdeps/mach/hurd/mmap.c
new file mode 100644
index 0000000..e682225
--- /dev/null
+++ b/sysdeps/mach/hurd/mmap.c
@@ -0,0 +1,105 @@
+/* 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. */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+
+/* Map addresses starting near ADDR and extending for LEN bytes. from
+ OFFSET into the file FD describes according to PROT and FLAGS. If ADDR
+ is nonzero, it is the desired mapping address. If the MAP_FIXED bit is
+ set in FLAGS, the mapping will be at ADDR exactly (which must be
+ page-aligned); otherwise the system chooses a convenient nearby address.
+ The return value is the actual mapping address chosen or (caddr_t) -1
+ for errors (in which case `errno' is set). A successful `mmap' call
+ deallocates any previous mapping for the affected region. */
+
+caddr_t
+mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
+{
+ error_t err;
+ vm_prot_t vmprot;
+ memory_object_t memobj;
+ vm_address_t mapaddr;
+
+ vmprot = VM_PROT_NONE;
+ if (prot & PROT_READ)
+ vmprot |= VM_PROT_READ;
+ if (prot & PROT_WRITE)
+ vmprot |= VM_PROT_WRITE;
+ if (prot & PROT_EXEC)
+ vmprot |= VM_PROT_EXECUTE;
+
+ switch (flags & MAP_TYPE)
+ {
+ default:
+ return (caddr_t) (long int) __hurd_fail (EINVAL);
+
+ case MAP_ANON:
+ memobj = MACH_PORT_NULL;
+ break;
+
+ case MAP_FILE:
+ {
+ mach_port_t robj, wobj;
+ if (err = HURD_DPORT_USE (fd, __io_map (port, &robj, &wobj)))
+ return (caddr_t) (long int) __hurd_dfail (fd, err);
+ switch (prot & (PROT_READ|PROT_WRITE))
+ {
+ case PROT_READ:
+ memobj = robj;
+ __mach_port_deallocate (__mach_task_self (), wobj);
+ break;
+ case PROT_WRITE:
+ memobj = wobj;
+ __mach_port_deallocate (__mach_task_self (), robj);
+ break;
+ case PROT_READ|PROT_WRITE:
+ __mach_port_deallocate (__mach_task_self (), robj);
+ if (robj == wobj)
+ memobj = wobj;
+ else
+ {
+ __mach_port_deallocate (__mach_task_self (), wobj);
+ return ((caddr_t) (long int)
+ __hurd_fail (EGRATUITOUS)); /* XXX */
+ }
+ break;
+ }
+ break;
+ /* XXX handle MAP_NOEXTEND */
+ }
+ }
+
+ mapaddr = (vm_address_t) addr;
+ err = __vm_map (__mach_task_self (),
+ &mapaddr, (vm_size_t) len, (vm_address_t) 0,
+ flags & MAP_FIXED,
+ memobj, (vm_offset_t) offset,
+ flags & (MAP_COPY|MAP_PRIVATE),
+ vmprot, VM_PROT_ALL,
+ flags & MAP_INHERIT);
+
+ if (memobj != MACH_PORT_NULL)
+ __mach_port_deallocate (__mach_task_self (), memobj);
+
+ return err ? (caddr_t) (long int) __hurd_fail (err) : (caddr_t) mapaddr;
+}
+
diff --git a/sysdeps/mach/hurd/open.c b/sysdeps/mach/hurd/open.c
new file mode 100644
index 0000000..0d22e7f
--- /dev/null
+++ b/sysdeps/mach/hurd/open.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+
+/* Open FILE with access OFLAG. If OFLAG includes O_CREAT,
+ a third argument is the file protection. */
+int
+DEFUN(__open, (file, oflag), CONST char *file AND int oflag DOTS)
+{
+ mode_t mode;
+ io_t port;
+
+ if (oflag & O_CREAT)
+ {
+ va_list arg;
+ va_start (arg, oflag);
+ mode = va_arg (arg, mode_t);
+ va_end (arg);
+ }
+ else
+ mode = 0;
+
+ port = __file_name_lookup (file, oflag, mode);
+ if (port == MACH_PORT_NULL)
+ return -1;
+
+ return _hurd_intern_fd (port, oflag, 1);
+}
+
+weak_alias (__open, open)
diff --git a/sysdeps/mach/hurd/opendir.c b/sysdeps/mach/hurd/opendir.c
new file mode 100644
index 0000000..d843da8
--- /dev/null
+++ b/sysdeps/mach/hurd/opendir.c
@@ -0,0 +1,60 @@
+/* Copyright (C) 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <hurd.h>
+
+
+/* Open a directory stream on NAME. */
+DIR *
+DEFUN(opendir, (name), CONST char *name)
+{
+ DIR *dirp;
+ file_t port;
+
+ port = __file_name_lookup (name, O_RDONLY, 0);
+ if (port == MACH_PORT_NULL)
+ return NULL;
+
+ /* XXX this port should be deallocated on exec */
+
+ dirp = (DIR *) malloc (sizeof (DIR));
+ if (dirp == NULL)
+ {
+ __mach_port_deallocate (__mach_task_self (), port);
+ return NULL;
+ }
+
+ dirp->__port = port;
+ dirp->__data = dirp->__ptr = NULL;
+ dirp->__entry_data = dirp->__entry_ptr = 0;
+ dirp->__allocation = 0;
+ dirp->__size = 0;
+
+ return dirp;
+}
diff --git a/sysdeps/mach/hurd/pipe.c b/sysdeps/mach/hurd/pipe.c
new file mode 100644
index 0000000..07c802f
--- /dev/null
+++ b/sysdeps/mach/hurd/pipe.c
@@ -0,0 +1,99 @@
+/* Copyright (C) 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stddef.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <sys/socket.h>
+#include <hurd/socket.h>
+#include <fcntl.h>
+
+/* Create a one-way communication channel (pipe).
+ If successul, two file descriptors are stored in FDS;
+ bytes written on FDS[1] can be read from FDS[0].
+ Returns 0 if successful, -1 if not. */
+int
+DEFUN(__pipe, (fds), int fds[2])
+{
+ error_t err;
+ socket_t server, sock1, sock2;
+ int d1, d2;
+
+ if (fds == NULL)
+ return __hurd_fail (EINVAL);
+
+ /* Find the local domain socket server. */
+ server = _hurd_socket_server (PF_LOCAL, 0);
+ if (server == MACH_PORT_NULL)
+ return -1;
+
+ /* Create two local domain sockets and connect them together. */
+
+ err = __socket_create (server, SOCK_STREAM, 0, &sock1);
+ if (err == MACH_SEND_INVALID_DEST || err == MIG_SERVER_DIED)
+ {
+ /* On the first use of the socket server during the operation,
+ allow for the old server port dying. */
+ server = _hurd_socket_server (PF_LOCAL, 1);
+ if (server == MACH_PORT_NULL)
+ return -1;
+ err = __socket_create (server, SOCK_STREAM, 0, &sock1);
+ }
+ if (err)
+ return __hurd_fail (err);
+ if (err = __socket_create (server, SOCK_STREAM, 0, &sock2))
+ {
+ __mach_port_deallocate (__mach_task_self (), sock1);
+ return __hurd_fail (err);
+ }
+ if (err = __socket_connect2 (sock1, sock2))
+ {
+ __mach_port_deallocate (__mach_task_self (), sock1);
+ __mach_port_deallocate (__mach_task_self (), sock2);
+ return __hurd_fail (err);
+ }
+
+ /* Shut down the unused sides of the sockets. */
+ __socket_shutdown (sock1, 1);
+ __socket_shutdown (sock2, 0);
+
+ /* Put the sockets into file descriptors. */
+
+ d1 = _hurd_intern_fd (sock1, O_IGNORE_CTTY, 1);
+ if (d1 < 0)
+ {
+ __mach_port_deallocate (__mach_task_self (), sock2);
+ return -1;
+ }
+ d2 = _hurd_intern_fd (sock2, O_IGNORE_CTTY, 1);
+ if (d2 < 0)
+ {
+ err = errno;
+ (void) close (d1);
+ return __hurd_fail (err);
+ }
+
+ fds[0] = d1;
+ fds[1] = d2;
+ return 0;
+}
+
+weak_alias (__pipe, pipe)
diff --git a/sysdeps/mach/hurd/ptrace.c b/sysdeps/mach/hurd/ptrace.c
new file mode 100644
index 0000000..3d85587
--- /dev/null
+++ b/sysdeps/mach/hurd/ptrace.c
@@ -0,0 +1,392 @@
+/* Process tracing interface `ptrace' for GNU Hurd.
+Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <errno.h>
+#include <sys/ptrace.h>
+#include <sys/types.h>
+#include <stdarg.h>
+#include <hurd.h>
+#include <hurd/signal.h>
+#include <hurd/msg.h>
+#include <thread_state.h>
+
+/* Perform process tracing functions. REQUEST is one of the values
+ in <sys/ptrace.h>, and determines the action to be taken.
+ For all requests except PTRACE_TRACEME, PID specifies the process to be
+ traced.
+
+ PID and the other arguments described above for the various requests should
+ appear (those that are used for the particular request) as:
+ pid_t PID, void *ADDR, int DATA, void *ADDR2
+ after PID. */
+int
+ptrace (enum __ptrace_request request, ... )
+{
+ pid_t pid;
+ void *addr, *addr2;
+ natural_t data;
+ va_list ap;
+
+ /* Read data from PID's address space, from ADDR for DATA bytes. */
+ error_t read_data (task_t task, vm_address_t *ourpage, vm_size_t *size)
+ {
+ /* Read the pages containing the addressed range. */
+ error_t err;
+ *size = round_page (addr + data) - trunc_page (addr);
+ err = __vm_read (task, trunc_page (addr), *size, ourpage, size);
+ return err;
+ }
+
+ /* Fetch the thread port for PID's user thread. */
+ error_t fetch_user_thread (task_t task, thread_t *thread)
+ {
+ thread_t threadbuf[3], *threads = threadbuf;
+ mach_msg_type_number_t nthreads = 3, i;
+ error_t err = __task_threads (task, &threads, &nthreads);
+ if (err)
+ return err;
+ if (nthreads == 0)
+ return EINVAL;
+ *thread = threads[0]; /* Assume user thread is first. */
+ for (i = 1; i < nthreads; ++i)
+ __mach_port_deallocate (__mach_task_self (), threads[i]);
+ if (threads != threadbuf)
+ __vm_deallocate (__mach_task_self (),
+ (vm_address_t) threads, nthreads * sizeof threads[0]);
+ return 0;
+ }
+
+ /* Fetch a thread state structure from PID and store it at ADDR. */
+ int get_regs (int flavor, mach_msg_type_number_t count)
+ {
+ error_t err;
+ task_t task = __pid2task (pid);
+ thread_t thread;
+ if (task == MACH_PORT_NULL)
+ return -1;
+ err = fetch_user_thread (task, &thread);
+ __mach_port_deallocate (__mach_task_self (), task);
+ if (!err)
+ err = __thread_get_state (thread, flavor, addr, &count);
+ __mach_port_deallocate (__mach_task_self (), thread);
+ return err ? __hurd_fail (err) : 0;
+ }
+
+
+ switch (request)
+ {
+ case PTRACE_TRACEME:
+ /* Make this process be traced. */
+ _hurd_exec_flags |= EXEC_TRACED;
+ break;
+
+ case PTRACE_CONT:
+ va_start (ap, request);
+ pid = va_arg (ap, pid_t);
+ addr = va_arg (ap, void *);
+ data = va_arg (ap, int);
+ va_end (ap);
+ {
+ /* Send a DATA signal to PID, telling it to take the signal
+ normally even if it's traced. */
+ error_t err; task_t task = __pid2task (pid);
+ if (task == MACH_PORT_NULL)
+ return -1;
+ if (data == SIGKILL)
+ err = __task_terminate (task);
+ else
+ {
+ mach_port_t msgport;
+ err = __USEPORT (PROC, __proc_getmsgport (port, pid, &msgport));
+
+ if (!err && addr != (void *) 1)
+ {
+ /* Move the user thread's PC to ADDR. */
+ thread_t thread;
+ err = fetch_user_thread (task, &thread);
+ if (!err)
+ {
+ struct machine_thread_state state;
+ mach_msg_type_number_t count = MACHINE_THREAD_STATE_COUNT;
+ err = __thread_get_state (thread,
+ MACHINE_THREAD_STATE_FLAVOR,
+ (natural_t *) &state, &count);
+ if (!err)
+ {
+ MACHINE_THREAD_STATE_SET_PC (&state, addr);
+ err = __thread_set_state (thread,
+ MACHINE_THREAD_STATE_FLAVOR,
+ (natural_t *) &state, count);
+ }
+
+ }
+ __mach_port_deallocate (__mach_task_self (), thread);
+ }
+
+ if (! err)
+ /* Tell the process to take the signal (or just resume if 0). */
+ err = __msg_sig_post_untraced (msgport, data, task);
+ __mach_port_deallocate (__mach_task_self (), msgport);
+ }
+ __mach_port_deallocate (__mach_task_self (), task);
+ return err ? __hurd_fail (err) : 0;
+ }
+
+ case PTRACE_KILL:
+ va_start (ap, request);
+ pid = va_arg (ap, pid_t);
+ va_end (ap);
+ /* SIGKILL always just terminates the task,
+ so normal kill is just the same when traced. */
+ return kill (pid, SIGKILL);
+
+ case PTRACE_SINGLESTEP:
+ /* This is a machine-dependent kernel RPC on
+ machines that support it. Punt. */
+ return EOPNOTSUPP;
+
+ case PTRACE_ATTACH:
+ case PTRACE_DETACH:
+ va_start (ap, request);
+ pid = va_arg (ap, pid_t);
+ va_end (ap);
+ {
+ /* Tell PID to set or clear its trace bit. */
+ error_t err;
+ mach_port_t msgport;
+ task_t task = __pid2task (pid);
+ if (task == MACH_PORT_NULL)
+ return -1;
+ err = __USEPORT (PROC, __proc_getmsgport (port, pid, &msgport));
+ if (! err)
+ {
+ err = (request == PTRACE_ATTACH ?
+ __msg_set_some_exec_flags :
+ __msg_clear_some_exec_flags) (msgport, task, EXEC_TRACED);
+#ifdef notyet /* XXX */
+ if (! err)
+ /* Request (or request an end to) SIGCHLD notification
+ when PID stops or dies, and proc_wait working on PID. */
+ err = __USEPORT (PROC,
+ __proc_trace_pid (port, pid,
+ request == PTRACE_ATTACH));
+#endif
+ if (! err)
+ {
+ if (request == PTRACE_ATTACH)
+ /* Now stop the process. */
+ err = __msg_sig_post (msgport, SIGSTOP, task);
+ else
+ /* Resume the process from tracing stop. */
+ err = __msg_sig_post_untraced (msgport, 0, task);
+ }
+ __mach_port_deallocate (__mach_task_self (), msgport);
+ }
+ __mach_port_deallocate (__mach_task_self (), task);
+ return err ? __hurd_fail (err) : 0;
+ }
+
+ case PTRACE_PEEKTEXT:
+ case PTRACE_PEEKDATA:
+ va_start (ap, request);
+ pid = va_arg (ap, pid_t);
+ addr = va_arg (ap, void *);
+ va_end (ap);
+ {
+ /* Read the page (or two pages, if the word lies on a boundary)
+ containing the addressed word. */
+ error_t err;
+ vm_address_t ourpage;
+ vm_size_t size;
+ natural_t word;
+ task_t task = __pid2task (pid);
+ if (task == MACH_PORT_NULL)
+ return -1;
+ data = sizeof word;
+ ourpage = 0;
+ size = 0;
+ err = read_data (task, &ourpage, &size);
+ __mach_port_deallocate (__mach_task_self (), task);
+ if (err)
+ return __hurd_fail (err);
+ word = *(natural_t *) ((vm_address_t) addr - trunc_page (addr)
+ + ourpage);
+ __vm_deallocate (__mach_task_self (), ourpage, size);
+ return word;
+ }
+
+ case PTRACE_PEEKUSER:
+ case PTRACE_POKEUSER:
+ /* U area, what's that? */
+ return EOPNOTSUPP;
+
+ case PTRACE_GETREGS:
+ case PTRACE_SETREGS:
+ va_start (ap, request);
+ pid = va_arg (ap, pid_t);
+ addr = va_arg (ap, void *);
+ va_end (ap);
+ return get_regs (MACHINE_THREAD_STATE_FLAVOR,
+ MACHINE_THREAD_STATE_COUNT);
+
+ case PTRACE_GETFPREGS:
+ case PTRACE_SETFPREGS:
+ va_start (ap, request);
+ pid = va_arg (ap, pid_t);
+ addr = va_arg (ap, void *);
+ va_end (ap);
+#ifdef MACHINE_THREAD_FLOAT_STATE_FLAVOR
+ return get_regs (MACHINE_THREAD_FLOAT_STATE_FLAVOR,
+ MACHINE_THREAD_FLOAT_STATE_COUNT);
+#else
+ return EOPNOTSUPP;
+#endif
+
+ case PTRACE_GETFPAREGS:
+ case PTRACE_SETFPAREGS:
+ va_start (ap, request);
+ pid = va_arg (ap, pid_t);
+ addr = va_arg (ap, void *);
+ va_end (ap);
+#ifdef MACHINE_THREAD_FPA_STATE_FLAVOR
+ return get_regs (MACHINE_THREAD_FPA_STATE_FLAVOR,
+ MACHINE_THREAD_FPA_STATE_COUNT);
+#else
+ return EOPNOTSUPP;
+#endif
+
+ case PTRACE_POKETEXT:
+ case PTRACE_POKEDATA:
+ va_start (ap, request);
+ pid = va_arg (ap, pid_t);
+ addr = va_arg (ap, void *);
+ data = va_arg (ap, int);
+ va_end (ap);
+ {
+ /* Read the page (or two pages, if the word lies on a boundary)
+ containing the addressed word. */
+ error_t err;
+ vm_address_t ourpage;
+ vm_size_t size;
+ task_t task = __pid2task (pid);
+ if (task == MACH_PORT_NULL)
+ return -1;
+ data = sizeof (natural_t);
+ ourpage = 0;
+ size = 0;
+ err = read_data (task, &ourpage, &size);
+
+ if (!err)
+ {
+ /* Now modify the specified word and write the page back. */
+ *(natural_t *) ((vm_address_t) addr - trunc_page (addr)
+ + ourpage) = data;
+ err = __vm_write (task, trunc_page (addr), ourpage, size);
+ __vm_deallocate (__mach_task_self (), ourpage, size);
+ }
+
+ __mach_port_deallocate (__mach_task_self (), task);
+ return err ? __hurd_fail (err) : 0;
+ }
+
+ case PTRACE_READDATA:
+ case PTRACE_READTEXT:
+ va_start (ap, request);
+ pid = va_arg (ap, pid_t);
+ addr = va_arg (ap, void *);
+ data = va_arg (ap, int);
+ addr2 = va_arg (ap, void *);
+ va_end (ap);
+ {
+ error_t err;
+ vm_address_t ourpage;
+ vm_size_t size;
+ task_t task = __pid2task (pid);
+ if (task == MACH_PORT_NULL)
+ return -1;
+ if (((vm_address_t) addr2 + data) % __vm_page_size == 0)
+ {
+ /* Perhaps we can write directly to the user's buffer. */
+ ourpage = (vm_address_t) addr2;
+ size = data;
+ }
+ else
+ {
+ ourpage = 0;
+ size = 0;
+ }
+ err = read_data (task, &ourpage, &size);
+ __mach_port_deallocate (__mach_task_self (), task);
+ if (!err && ourpage != (vm_address_t) addr2)
+ {
+ memcpy (addr2, (void *) ourpage, data);
+ __vm_deallocate (__mach_task_self (), ourpage, size);
+ }
+ return err ? __hurd_fail (err) : 0;
+ }
+
+ case PTRACE_WRITEDATA:
+ case PTRACE_WRITETEXT:
+ va_start (ap, request);
+ pid = va_arg (ap, pid_t);
+ addr = va_arg (ap, void *);
+ data = va_arg (ap, int);
+ addr2 = va_arg (ap, void *);
+ va_end (ap);
+ {
+ error_t err;
+ vm_address_t ourpage;
+ vm_size_t size;
+ task_t task = __pid2task (pid);
+ if (task == MACH_PORT_NULL)
+ return -1;
+ if ((vm_address_t) addr % __vm_page_size == 0 &&
+ (vm_address_t) data % __vm_page_size == 0)
+ {
+ /* Writing whole pages; can go directly from the user's buffer. */
+ ourpage = (vm_address_t) addr2;
+ size = data;
+ err = 0;
+ }
+ else
+ {
+ /* Read the task's pages and modify our own copy. */
+ ourpage = 0;
+ size = 0;
+ err = read_data (task, &ourpage, &size);
+ if (!err)
+ memcpy ((void *) ((vm_address_t) addr - trunc_page (addr)
+ + ourpage),
+ addr2,
+ data);
+ }
+ if (!err)
+ /* Write back the modified pages. */
+ err = __vm_write (task, trunc_page (addr), ourpage, size);
+ __mach_port_deallocate (__mach_task_self (), task);
+ return err ? __hurd_fail (err) : 0;
+ }
+
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/read.c b/sysdeps/mach/hurd/read.c
new file mode 100644
index 0000000..c7fdaf8
--- /dev/null
+++ b/sysdeps/mach/hurd/read.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+
+/* Read NBYTES into BUF from FD. Return the number read or -1. */
+ssize_t
+DEFUN(__read, (fd, buf, nbytes),
+ int fd AND PTR buf AND size_t nbytes)
+{
+ error_t err = HURD_FD_USE (fd, _hurd_fd_read (descriptor, buf, &nbytes));
+ return err ? __hurd_dfail (fd, err) : nbytes;
+}
+
+weak_alias (__read, read)
diff --git a/sysdeps/mach/hurd/readdir.c b/sysdeps/mach/hurd/readdir.c
new file mode 100644
index 0000000..185aeee
--- /dev/null
+++ b/sysdeps/mach/hurd/readdir.c
@@ -0,0 +1,90 @@
+/* Copyright (C) 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <limits.h>
+#include <stddef.h>
+#include <string.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <hurd.h>
+
+
+/* Read a directory entry from DIRP. */
+struct dirent *
+DEFUN(readdir, (dirp), DIR *dirp)
+{
+ struct dirent *dp;
+
+ if (dirp == NULL)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ do
+ {
+ if (dirp->__ptr - dirp->__data >= dirp->__size)
+ {
+ /* We've emptied out our buffer. Refill it. */
+
+ char *data = dirp->__data;
+ int nentries;
+ error_t err;
+
+ if (err = __dir_readdir (dirp->__port, &data, &dirp->__size,
+ dirp->__entry_ptr, -1, 0, &nentries))
+ return __hurd_fail (err), NULL;
+
+ /* DATA now corresponds to entry index DIRP->__entry_ptr. */
+ dirp->__entry_data = dirp->__entry_ptr;
+
+ if (data != dirp->__data)
+ {
+ /* The data was passed out of line, so our old buffer is no
+ longer useful. Deallocate the old buffer and reset our
+ information for the new buffer. */
+ __vm_deallocate (__mach_task_self (),
+ (vm_address_t) dirp->__data,
+ dirp->__allocation);
+ dirp->__data = data;
+ dirp->__allocation = round_page (dirp->__size);
+ }
+
+ /* Reset the pointer into the buffer. */
+ dirp->__ptr = dirp->__data;
+
+ if (nentries == 0)
+ /* End of file. */
+ return NULL;
+
+ /* We trust the filesystem to return correct data and so we
+ ignore NENTRIES. */
+ }
+
+ dp = (struct dirent *) dirp->__ptr;
+ dirp->__ptr += dp->d_reclen;
+ ++dirp->__entry_ptr;
+
+ /* Loop to ignore deleted files. */
+ } while (dp->d_fileno == 0);
+
+ return dp;
+}
diff --git a/sysdeps/mach/hurd/readlink.c b/sysdeps/mach/hurd/readlink.c
new file mode 100644
index 0000000..2f51e20
--- /dev/null
+++ b/sysdeps/mach/hurd/readlink.c
@@ -0,0 +1,76 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/paths.h>
+#include <fcntl.h>
+#include <string.h>
+
+/* Read the contents of the symbolic link FILE_NAME into no more than
+ LEN bytes of BUF. The contents are not null-terminated.
+ Returns the number of characters read, or -1 for errors. */
+ssize_t
+DEFUN(__readlink, (file_name, buf, len),
+ CONST char *file_name AND char *buf AND size_t len)
+{
+ error_t err;
+ file_t file;
+ char mybuf[2048], *transp = mybuf;
+ mach_msg_type_number_t translen = sizeof (mybuf);
+
+ file = __file_name_lookup (file_name, O_NOTRANS, 0);
+ if (file == MACH_PORT_NULL)
+ return -1;
+
+ err = __file_get_translator (file, &transp, &translen);
+ __mach_port_deallocate (__mach_task_self (), file);
+
+ if (err)
+ return __hurd_fail (err);
+
+ if (translen < sizeof (_HURD_SYMLINK) ||
+ memcmp (transp, _HURD_SYMLINK, sizeof (_HURD_SYMLINK)))
+ /* The file is not actually a symlink. */
+ err = EINVAL;
+ else
+ {
+ /* This is a symlink; its translator is "/hurd/symlink\0target\0". */
+ if (len >= translen - sizeof (_HURD_SYMLINK))
+ {
+ len = translen - sizeof (_HURD_SYMLINK);
+ if (transp[translen - 1] == '\0')
+ /* Remove the null terminator. */
+ --len;
+ }
+ if (buf == NULL)
+ /* This call is just to find out how large a buffer is required. */
+ len = translen - sizeof (_HURD_SYMLINK) - 1;
+ else
+ /* Copy into the user's buffer. */
+ memcpy (buf, transp + sizeof (_HURD_SYMLINK), len);
+ }
+
+ if (transp != mybuf)
+ __vm_deallocate (__mach_task_self (), (vm_address_t) transp, translen);
+
+ return err ? __hurd_fail (err) : len;
+}
+
+weak_alias (__readlink, readlink)
diff --git a/sysdeps/mach/hurd/reboot.c b/sysdeps/mach/hurd/reboot.c
new file mode 100644
index 0000000..80356fd
--- /dev/null
+++ b/sysdeps/mach/hurd/reboot.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/startup.h>
+
+/* Reboot the system. */
+int
+DEFUN(reboot, (howto), int howto)
+{
+ error_t err;
+ startup_t init;
+ mach_port_t hostpriv, devmaster;
+
+ if (err = __USEPORT (PROC, __proc_getprivports (port,
+ &hostpriv, &devmaster)))
+ return __hurd_fail (err);
+ __mach_port_deallocate (__mach_task_self (), devmaster);
+
+ err = __USEPORT (PROC, __proc_getmsgport (port, 1, &init));
+ if (!err)
+ {
+ err = __startup_reboot (init, hostpriv, howto);
+ __mach_port_deallocate (__mach_task_self (), init);
+ }
+
+ __mach_port_deallocate (__mach_task_self (), hostpriv);
+
+ if (err)
+ return __hurd_fail (err);
+
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/recv.c b/sysdeps/mach/hurd/recv.c
new file mode 100644
index 0000000..7d06919
--- /dev/null
+++ b/sysdeps/mach/hurd/recv.c
@@ -0,0 +1,60 @@
+/* Copyright (C) 1994 Fremach_msg_type_number_t 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <hurd/socket.h>
+#include <string.h>
+
+/* Read N bytes into BUF from socket FD.
+ Returns the number read or -1 for errors. */
+int
+DEFUN(recv, (fd, buf, n, flags),
+ int fd AND PTR buf AND size_t n AND int flags)
+{
+ error_t err;
+ mach_port_t addrport;
+ char *bufp = buf;
+ mach_msg_type_number_t nread = n;
+ mach_port_t *ports;
+ mach_msg_type_number_t nports;
+ char *cdata = NULL;
+ mach_msg_type_number_t clen = 0;
+
+ if (err = HURD_DPORT_USE (fd, __socket_recv (port, &addrport,
+ flags, &bufp, &nread,
+ &ports, &nports,
+ &cdata, &clen,
+ &flags,
+ n)))
+ return __hurd_dfail (fd, err);
+
+ __mach_port_deallocate (__mach_task_self (), addrport);
+ __vm_deallocate (__mach_task_self (), (vm_address_t) cdata, clen);
+
+ if (bufp != buf)
+ {
+ memcpy (buf, bufp, nread);
+ __vm_deallocate (__mach_task_self (), (vm_address_t) bufp, nread);
+ }
+
+ return nread;
+}
diff --git a/sysdeps/mach/hurd/recvfrom.c b/sysdeps/mach/hurd/recvfrom.c
new file mode 100644
index 0000000..09d45c7
--- /dev/null
+++ b/sysdeps/mach/hurd/recvfrom.c
@@ -0,0 +1,85 @@
+/* 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <hurd/socket.h>
+#include <string.h>
+
+/* Read N bytes into BUF through socket FD from peer
+ at address ADDR (which is ADDR_LEN bytes long).
+ Returns the number read or -1 for errors. */
+int
+DEFUN(recvfrom, (fd, buf, n, flags, addr, addr_len),
+ int fd AND PTR buf AND size_t n AND int flags AND
+ struct sockaddr *addr AND size_t *addr_len)
+{
+ error_t err;
+ mach_port_t addrport;
+ char *bufp = buf;
+ mach_msg_type_number_t nread = n;
+ mach_port_t *ports;
+ mach_msg_type_number_t nports;
+ char *cdata = NULL;
+ mach_msg_type_number_t clen = 0;
+
+ if (err = HURD_DPORT_USE (fd, __socket_recv (port, &addrport,
+ flags, &bufp, &nread,
+ &ports, &nports,
+ &cdata, &clen,
+ &flags,
+ n)))
+ return __hurd_dfail (fd, err);
+
+ /* Get address data for the returned address port. */
+ {
+ char *buf = (char *) addr;
+ mach_msg_type_number_t buflen = *addr_len;
+ int type;
+
+ err = __socket_whatis_address (addrport, &type, &buf, &buflen);
+ __mach_port_deallocate (__mach_task_self (), addrport);
+ if (err)
+ return __hurd_dfail (fd, err);
+
+ if (buf != (char *) addr)
+ {
+ if (*addr_len < buflen)
+ *addr_len = buflen;
+ memcpy (addr, buf, *addr_len);
+ __vm_deallocate (__mach_task_self (), (vm_address_t) buf, buflen);
+ }
+
+ addr->sa_family = type;
+ }
+
+ /* Toss control data; we don't care. */
+ __vm_deallocate (__mach_task_self (), (vm_address_t) cdata, clen);
+
+ if (bufp != buf)
+ {
+ memcpy (buf, bufp, nread);
+ __vm_deallocate (__mach_task_self (), (vm_address_t) bufp, nread);
+ }
+
+ return nread;
+}
+
diff --git a/sysdeps/mach/hurd/rename.c b/sysdeps/mach/hurd/rename.c
new file mode 100644
index 0000000..63efbfb
--- /dev/null
+++ b/sysdeps/mach/hurd/rename.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+#include <hurd.h>
+
+/* Rename the file OLD to NEW. */
+int
+DEFUN(rename, (old, new), CONST char *old AND CONST char *new)
+{
+ error_t err;
+ file_t olddir, newdir;
+ const char *oldname, *newname;
+
+ olddir = __file_name_split (old, (char **) &oldname);
+ if (olddir == MACH_PORT_NULL)
+ return -1;
+ newdir = __file_name_split (new, (char **) &newname);
+ if (newdir == MACH_PORT_NULL)
+ {
+ __mach_port_deallocate (__mach_task_self (), olddir);
+ return -1;
+ }
+
+ err = __dir_rename (olddir, oldname, newdir, newname);
+ __mach_port_deallocate (__mach_task_self (), olddir);
+ __mach_port_deallocate (__mach_task_self (), newdir);
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/rewinddir.c b/sysdeps/mach/hurd/rewinddir.c
new file mode 100644
index 0000000..66a11d6
--- /dev/null
+++ b/sysdeps/mach/hurd/rewinddir.c
@@ -0,0 +1,31 @@
+/* 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+
+/* Rewind DIRP to the beginning of the directory. */
+void
+DEFUN(rewinddir, (dirp), DIR *dirp)
+{
+ seekdir (dirp, (off_t) 0L);
+}
diff --git a/sysdeps/mach/hurd/rmdir.c b/sysdeps/mach/hurd/rmdir.c
new file mode 100644
index 0000000..13a199f
--- /dev/null
+++ b/sysdeps/mach/hurd/rmdir.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <hurd.h>
+
+/* Remove the directory FILE_NAME. */
+int
+DEFUN(__rmdir, (file_name), CONST char *file_name)
+{
+ error_t err;
+ const char *name;
+ file_t parent = __file_name_split (file_name, (char **) &name);
+ if (parent == MACH_PORT_NULL)
+ return -1;
+ err = __dir_rmdir (parent, name);
+ __mach_port_deallocate (__mach_task_self (), parent);
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+
+weak_alias (__rmdir, rmdir)
diff --git a/sysdeps/mach/hurd/sbrk.c b/sysdeps/mach/hurd/sbrk.c
new file mode 100644
index 0000000..855cab8
--- /dev/null
+++ b/sysdeps/mach/hurd/sbrk.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <hurd.h>
+
+/* Extend the process's data space by INCREMENT.
+ If INCREMENT is negative, shrink data space by - INCREMENT.
+ Return the address of the start of the new data space, or -1 for errors. */
+PTR
+DEFUN(__sbrk, (increment), int increment)
+{
+ PTR result;
+
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_brk_lock);
+ result = (PTR) _hurd_brk;
+ if (increment != 0 && _hurd_set_brk (_hurd_brk + increment) < 0)
+ result = (PTR) -1;
+ __mutex_unlock (&_hurd_brk_lock);
+ HURD_CRITICAL_END;
+
+ return result;
+}
+
+weak_alias (__sbrk, sbrk)
diff --git a/sysdeps/mach/hurd/seekdir.c b/sysdeps/mach/hurd/seekdir.c
new file mode 100644
index 0000000..9f585eb
--- /dev/null
+++ b/sysdeps/mach/hurd/seekdir.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <dirent.h>
+#include <unistd.h>
+
+/* Seek to position POS in DIRP. */
+void
+DEFUN(seekdir, (dirp, pos), DIR *dirp AND __off_t pos)
+{
+ /* Change our entry index pointer to POS and discard any data already
+ read. The next `readdir' call will notice the empty block and read
+ anew from the location in DIRP->__entry_ptr and reset the other state
+ variables. */
+ dirp->__entry_ptr = pos;
+ dirp->__size = 0;
+}
diff --git a/sysdeps/mach/hurd/select.c b/sysdeps/mach/hurd/select.c
new file mode 100644
index 0000000..d1c5913
--- /dev/null
+++ b/sysdeps/mach/hurd/select.c
@@ -0,0 +1,275 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/* Check the first NFDS descriptors each in READFDS (if not NULL) for read
+ readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS
+ (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out
+ after waiting the interval specified therein. Returns the number of ready
+ descriptors, or -1 for errors. */
+int
+DEFUN(__select, (nfds, readfds, writefds, exceptfds, timeout),
+ int nfds AND fd_set *readfds AND fd_set *writefds AND
+ fd_set *exceptfds AND struct timeval *timeout)
+{
+ int i;
+ mach_port_t port;
+ int got;
+ int *types;
+ struct hurd_userlink *ulink;
+ mach_port_t *ports;
+ struct hurd_fd **cells;
+ error_t err;
+ fd_set rfds, wfds, xfds;
+ int firstfd, lastfd;
+ mach_msg_timeout_t to = (timeout != NULL ?
+ (timeout->tv_sec * 1000 +
+ timeout->tv_usec / 1000) :
+ 0);
+
+ /* Use local copies so we can't crash from user bogosity. */
+ if (readfds == NULL)
+ FD_ZERO (&rfds);
+ else
+ rfds = *readfds;
+ if (writefds == NULL)
+ FD_ZERO (&wfds);
+ else
+ wfds = *writefds;
+ if (exceptfds == NULL)
+ FD_ZERO (&xfds);
+ else
+ xfds = *exceptfds;
+
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_dtable_lock);
+
+ if (nfds > _hurd_dtablesize)
+ nfds = _hurd_dtablesize;
+
+ /* Collect the ports for interesting FDs. */
+ cells = __alloca (nfds * sizeof (*cells));
+ ports = __alloca (nfds * sizeof (*ports));
+ types = __alloca (nfds * sizeof (*types));
+ ulink = __alloca (nfds * sizeof (*ulink));
+ firstfd = lastfd = -1;
+ for (i = 0; i < nfds; ++i)
+ {
+ int type = 0;
+ if (readfds != NULL && FD_ISSET (i, &rfds))
+ type |= SELECT_READ;
+ if (writefds != NULL && FD_ISSET (i, &wfds))
+ type |= SELECT_WRITE;
+ if (exceptfds != NULL && FD_ISSET (i, &xfds))
+ type |= SELECT_URG;
+ types[i] = type;
+ if (type)
+ {
+ cells[i] = _hurd_dtable[i];
+ ports[i] = _hurd_port_get (&cells[i]->port, &ulink[i]);
+ if (ports[i] == MACH_PORT_NULL)
+ {
+ /* If one descriptor is bogus, we fail completely. */
+ while (i-- > 0)
+ _hurd_port_free (&cells[i]->port, &ulink[i], ports[i]);
+ errno = EBADF;
+ break;
+ }
+ lastfd = i;
+ if (firstfd == -1)
+ firstfd = i;
+ }
+ }
+
+ __mutex_unlock (&_hurd_dtable_lock);
+ HURD_CRITICAL_END;
+
+ if (i < nfds)
+ return -1;
+
+ /* Get a port to receive the io_select_reply messages on. */
+ port = __mach_reply_port ();
+
+ /* Send them all io_select request messages. */
+ got = 0;
+ err = 0;
+ for (i = firstfd; i <= lastfd; ++i)
+ if (types[i])
+ {
+ if (!err)
+ {
+ int tag = i;
+ err = __io_select (ports[i], port,
+ /* Poll for each but the last. */
+ (i == lastfd && got == 0) ? to : 0,
+ &types[i], &tag);
+ if (!err)
+ {
+ if (tag != i)
+ err = EGRATUITOUS;
+ else if (types[i] & (SELECT_READ|SELECT_URG|SELECT_WRITE))
+ ++got;
+ }
+ }
+ _hurd_port_free (&cells[i]->port, &ulink[i], ports[i]);
+ }
+
+ /* Now wait for reply messages. */
+ if (!err && got == 0 && port != MACH_PORT_NULL)
+ {
+ /* Now wait for io_select_reply messages on PORT,
+ timing out as appropriate. */
+
+ union
+ {
+ mach_msg_header_t head;
+ struct
+ {
+ mach_msg_header_t head;
+ mach_msg_type_t err_type;
+ error_t err;
+ } error;
+ struct
+ {
+ mach_msg_header_t head;
+ mach_msg_type_t err_type;
+ error_t err;
+ mach_msg_type_t result_type;
+ int result;
+ mach_msg_type_t tag_type;
+ int tag;
+ } success;
+ } msg;
+ mach_msg_option_t options = (timeout == NULL ? 0 : MACH_RCV_TIMEOUT);
+ error_t msgerr;
+ while ((msgerr = __mach_msg (&msg.head,
+ MACH_RCV_MSG | options,
+ sizeof msg, 0, port, to,
+ MACH_PORT_NULL)) == MACH_MSG_SUCCESS)
+ {
+ /* 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 };
+ if (msg.head.msgh_id == IO_SELECT_REPLY_MSGID &&
+ msg.head.msgh_size >= sizeof msg.error &&
+ !(msg.head.msgh_bits & MACH_MSGH_BITS_COMPLEX) &&
+ *(int *) &msg.error.err_type == *(int *) &inttype)
+ {
+ /* This is a properly formatted message so far.
+ See if it is a success or a failure. */
+ if (msg.error.err)
+ {
+ err = msg.error.err;
+ if (msg.head.msgh_size != sizeof msg.error)
+ __mach_msg_destroy (&msg);
+ }
+ else if (msg.head.msgh_size != sizeof msg.success ||
+ *(int *) &msg.success.tag_type != *(int *) &inttype ||
+ *(int *) &msg.success.result_type != *(int *) &inttype)
+ __mach_msg_destroy (&msg);
+ else if ((msg.success.result &
+ (SELECT_READ|SELECT_WRITE|SELECT_URG)) == 0 ||
+ msg.success.tag < firstfd || msg.success.tag > lastfd)
+ err = EGRATUITOUS;
+ else
+ {
+ /* This is a winning io_select_reply message!
+ Record the readiness it indicates and send a reply. */
+ if (types[msg.success.tag] == 0)
+ /* This descriptor is ready and it was not before,
+ so we increment our count of ready descriptors. */
+ ++got;
+ types[msg.success.tag] |= msg.success.result;
+ }
+ }
+
+ if (msg.head.msgh_remote_port != MACH_PORT_NULL)
+ __mach_port_deallocate (__mach_task_self (),
+ msg.head.msgh_remote_port);
+
+ if (got || err == EINTR)
+ {
+ /* Poll for another message. */
+ to = 0;
+ options |= MACH_RCV_TIMEOUT;
+ }
+ }
+
+ if (err == MACH_RCV_TIMED_OUT)
+ /* This is the normal value for ERR. We might have timed out and
+ read no messages. Otherwise, after receiving the first message,
+ we poll for more messages. We receive with a timeout of 0 to
+ effect a poll, so ERR is MACH_RCV_TIMED_OUT when the poll finds no
+ message waiting. */
+ err = 0;
+
+ if (got && err == EINTR)
+ /* Some calls were interrupted, but at least one descriptor
+ is known to be ready now, so we will return success. */
+ err = 0;
+ }
+
+ if (port != MACH_PORT_NULL)
+ /* We must destroy the port if we made some select requests
+ that might send notification on that port after we no longer care.
+ If the port were reused, that notification could confuse the next
+ select call to use the port. The notification might be valid,
+ but the descriptor may have changed to a different server. */
+ __mach_port_destroy (__mach_task_self (), port);
+
+ if (timeout && got == 0 && err == MACH_RCV_TIMED_OUT)
+ /* No io_select call returned success immediately, and the last call
+ blocked for our full timeout period and then timed out. So the
+ multiplex times out too. */
+ return 0;
+
+ if (err)
+ return __hurd_fail (err);
+
+ /* Set the user bitarrays. */
+ for (i = 0; i < nfds; ++i)
+ {
+ if (readfds != NULL)
+ if (types[i] & SELECT_READ)
+ FD_SET (i, readfds);
+ else
+ FD_CLR (i, readfds);
+ if (writefds != NULL)
+ if (types[i] & SELECT_WRITE)
+ FD_SET (i, writefds);
+ else
+ FD_CLR (i, writefds);
+ if (exceptfds != NULL)
+ if (types[i] & SELECT_URG)
+ FD_SET (i, exceptfds);
+ else
+ FD_CLR (i, exceptfds);
+ }
+
+ return got;
+}
+
+weak_alias (__select, select)
diff --git a/sysdeps/mach/hurd/send.c b/sysdeps/mach/hurd/send.c
new file mode 100644
index 0000000..153ee93
--- /dev/null
+++ b/sysdeps/mach/hurd/send.c
@@ -0,0 +1,40 @@
+/* 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <hurd.h>
+#include <hurd/socket.h>
+#include <hurd/fd.h>
+
+/* Send N bytes of BUF to socket FD. Returns the number sent or -1. */
+int
+DEFUN(send, (fd, buf, n, flags),
+ int fd AND PTR buf AND size_t n AND int flags)
+{
+ error_t err;
+ int wrote;
+
+ err = HURD_DPORT_USE (fd, __socket_send (port, MACH_PORT_NULL,
+ flags, buf, n,
+ NULL, MACH_MSG_TYPE_COPY_SEND, 0,
+ NULL, 0, &wrote));
+
+ return err ? __hurd_dfail (fd, err) : wrote;
+}
diff --git a/sysdeps/mach/hurd/sendto.c b/sysdeps/mach/hurd/sendto.c
new file mode 100644
index 0000000..c3d4a4e
--- /dev/null
+++ b/sysdeps/mach/hurd/sendto.c
@@ -0,0 +1,60 @@
+/* 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <hurd.h>
+#include <hurd/socket.h>
+#include <hurd/fd.h>
+
+/* Send N bytes of BUF on socket FD to peer at address ADDR (which is
+ ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */
+int
+DEFUN(sendto, (fd, buf, n, flags, addr, addr_len),
+ int fd AND PTR buf AND size_t n AND int flags AND
+ struct sockaddr *addr AND size_t addr_len)
+{
+ addr_port_t aport;
+ error_t err;
+ int wrote;
+
+ /* Get an address port for the desired destination address. */
+ err = HURD_DPORT_USE (fd,
+ ({
+ err = __socket_create_address (port,
+ addr->sa_family,
+ (char *) addr,
+ addr_len,
+ &aport, 1);
+ if (! err)
+ {
+ /* Send the data. */
+ err = __socket_send (port, aport,
+ flags, buf, n,
+ NULL,
+ MACH_MSG_TYPE_COPY_SEND, 0,
+ NULL, 0, &wrote);
+ __mach_port_deallocate (__mach_task_self (),
+ aport);
+ }
+ err;
+ }));
+
+ return err ? __hurd_dfail (fd, err) : wrote;
+}
diff --git a/sysdeps/mach/hurd/setegid.c b/sysdeps/mach/hurd/setegid.c
new file mode 100644
index 0000000..8ca4abe
--- /dev/null
+++ b/sysdeps/mach/hurd/setegid.c
@@ -0,0 +1,67 @@
+/* Copyright (C) 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <sys/types.h>
+#include <hurd/id.h>
+#include <string.h>
+
+/* Set the effective user ID of the calling process to GID. */
+int
+DEFUN(setegid, (gid), gid_t gid)
+{
+ auth_t newauth;
+ error_t err;
+
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_id.lock);
+ err = _hurd_check_ids ();
+
+ if (!err)
+ {
+ /* Make a new auth handle which has EGID as the first element in the
+ list of effective gids. */
+
+ size_t ngen = _hurd_id.gen.ngids < 1 ? 1 : _hurd_id.gen.ngids;
+ gid_t newgen[ngen];
+
+ newgen[0] = gid;
+ memcpy (&newgen[1], _hurd_id.gen.gids, (ngen - 1) * sizeof (gid_t));
+
+ err = __USEPORT (AUTH, __auth_makeauth
+ (port, NULL, MACH_MSG_TYPE_COPY_SEND, 0,
+ _hurd_id.gen.uids, _hurd_id.gen.nuids,
+ _hurd_id.aux.uids, _hurd_id.aux.nuids,
+ newgen, ngen,
+ _hurd_id.aux.gids, _hurd_id.aux.ngids,
+ &newauth));
+ }
+ __mutex_unlock (&_hurd_id.lock);
+ HURD_CRITICAL_END;
+
+ if (err)
+ return __hurd_fail (err);
+
+ /* Install the new handle and reauthenticate everything. */
+ err = __setauth (newauth);
+ __mach_port_deallocate (__mach_task_self (), newauth);
+ return err;
+}
diff --git a/sysdeps/mach/hurd/seteuid.c b/sysdeps/mach/hurd/seteuid.c
new file mode 100644
index 0000000..9c44c4d
--- /dev/null
+++ b/sysdeps/mach/hurd/seteuid.c
@@ -0,0 +1,67 @@
+/* Copyright (C) 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <sys/types.h>
+#include <hurd/id.h>
+#include <string.h>
+
+/* Set the effective user ID of the calling process to UID. */
+int
+DEFUN(seteuid, (uid), uid_t uid)
+{
+ auth_t newauth;
+ error_t err;
+
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_id.lock);
+ err = _hurd_check_ids ();
+
+ if (!err)
+ {
+ /* Make a new auth handle which has EUID as the first element in the
+ list of effective uids. */
+
+ size_t ngen = _hurd_id.gen.nuids < 1 ? 1 : _hurd_id.gen.nuids;
+ uid_t newgen[ngen];
+
+ newgen[0] = uid;
+ memcpy (&newgen[1], _hurd_id.gen.uids, (ngen - 1) * sizeof (uid_t));
+
+ err = __USEPORT (AUTH, __auth_makeauth
+ (port, NULL, MACH_MSG_TYPE_COPY_SEND, 0,
+ newgen, ngen,
+ _hurd_id.aux.uids, _hurd_id.aux.nuids,
+ _hurd_id.gen.gids, _hurd_id.gen.ngids,
+ _hurd_id.aux.gids, _hurd_id.aux.ngids,
+ &newauth));
+ }
+ __mutex_unlock (&_hurd_id.lock);
+ HURD_CRITICAL_END;
+
+ if (err)
+ return __hurd_fail (err);
+
+ /* Install the new handle and reauthenticate everything. */
+ err = __setauth (newauth);
+ __mach_port_deallocate (__mach_task_self (), newauth);
+ return err;
+}
diff --git a/sysdeps/mach/hurd/setgid.c b/sysdeps/mach/hurd/setgid.c
new file mode 100644
index 0000000..726b413
--- /dev/null
+++ b/sysdeps/mach/hurd/setgid.c
@@ -0,0 +1,76 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <hurd.h>
+#include <hurd/id.h>
+#include <string.h>
+
+/* Set the group ID of the calling process to UID.
+ If the calling process is the super-user, the real
+ and effective group IDs, and the saved set-group-ID to UID;
+ if not, the effective group ID is set to GID. */
+int
+DEFUN(__setgid, (gid), gid_t gid)
+{
+ auth_t newauth;
+ error_t err;
+
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_id.lock);
+ err = _hurd_check_ids ();
+
+ if (!err)
+ {
+ /* Make a new auth handle which has GID as the real gid,
+ and as the first element in the list of effective gids. */
+
+ gid_t newgen[_hurd_id.gen.ngids + 1];
+ gid_t newaux[_hurd_id.aux.ngids];
+
+ newgen[0] = gid;
+ memcpy (&newgen[1], _hurd_id.gen.gids,
+ _hurd_id.gen.ngids * sizeof (gid_t));
+ newaux[0] = gid;
+ memcpy (&newaux[1], _hurd_id.aux.gids,
+ (_hurd_id.aux.ngids - 1) * sizeof (gid_t));
+
+ err = __USEPORT (AUTH, __auth_makeauth
+ (port, NULL, 0, MACH_MSG_TYPE_COPY_SEND,
+ _hurd_id.gen.uids, _hurd_id.gen.nuids,
+ _hurd_id.aux.uids, _hurd_id.aux.nuids,
+ newgen, 1 + _hurd_id.gen.ngids,
+ newaux, _hurd_id.aux.ngids,
+ &newauth));
+ }
+ __mutex_unlock (&_hurd_id.lock);
+ HURD_CRITICAL_END;
+
+ if (err)
+ return __hurd_fail (err);
+
+ /* Install the new handle and reauthenticate everything. */
+ err = __setauth (newauth);
+ __mach_port_deallocate (__mach_task_self (), newauth);
+ return err;
+}
+
+weak_alias (__setgid, setgid)
diff --git a/sysdeps/mach/hurd/setgroups.c b/sysdeps/mach/hurd/setgroups.c
new file mode 100644
index 0000000..c343147
--- /dev/null
+++ b/sysdeps/mach/hurd/setgroups.c
@@ -0,0 +1,63 @@
+/* Copyright (C) 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <grp.h>
+#include <hurd.h>
+#include <hurd/id.h>
+
+/* Set the group set for the current user to GROUPS (N of them). */
+int
+DEFUN(setgroups, (n, groups), size_t n AND CONST gid_t *groups)
+{
+ error_t err;
+ auth_t newauth;
+ size_t i;
+ gid_t new[n];
+
+ /* Fault before taking locks. */
+ for (i = 0; i < n; ++i)
+ new[i] = groups[i];
+
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_id.lock);
+ err = _hurd_check_ids ();
+ if (! err)
+ {
+ /* Get a new auth port using those IDs. */
+ err = __USEPORT (AUTH,
+ __auth_makeauth (port, NULL, MACH_MSG_TYPE_COPY_SEND, 0,
+ _hurd_id.gen.uids, _hurd_id.gen.nuids,
+ _hurd_id.aux.uids, _hurd_id.aux.nuids,
+ new, n,
+ _hurd_id.aux.gids, _hurd_id.aux.ngids,
+ &newauth));
+ }
+ __mutex_unlock (&_hurd_id.lock);
+ HURD_CRITICAL_END;
+
+ if (err)
+ return __hurd_fail (err);
+
+ /* Install the new auth port and reauthenticate everything. */
+ err = __setauth (newauth);
+ __mach_port_deallocate (__mach_task_self (), newauth);
+ return err;
+}
diff --git a/sysdeps/mach/hurd/sethostid.c b/sysdeps/mach/hurd/sethostid.c
new file mode 100644
index 0000000..dc8153c
--- /dev/null
+++ b/sysdeps/mach/hurd/sethostid.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+
+/* Set the current machine's Internet number to ID.
+ This call is restricted to the super-user. */
+int
+DEFUN(sethostid, (id), long int id)
+{
+ error_t err = __USEPORT (PROC, __proc_sethostid (port, id));
+ return err ? __hurd_fail (err) : 0;
+}
diff --git a/sysdeps/mach/hurd/sethostname.c b/sysdeps/mach/hurd/sethostname.c
new file mode 100644
index 0000000..2c019cf
--- /dev/null
+++ b/sysdeps/mach/hurd/sethostname.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+
+/* Set the name of the current host to NAME, which is LEN bytes long.
+ This call is restricted to the super-user. */
+int
+DEFUN(sethostname, (name, len),
+ CONST char *name AND size_t len)
+{
+ error_t err = __USEPORT (PROC, __proc_sethostname (port, name, len));
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/setitimer.c b/sysdeps/mach/hurd/setitimer.c
new file mode 100644
index 0000000..4351c5e
--- /dev/null
+++ b/sysdeps/mach/hurd/setitimer.c
@@ -0,0 +1,332 @@
+/* Copyright (C) 1994, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <hurd.h>
+#include <hurd/signal.h>
+#include <hurd/msg_request.h>
+#include <mach/message.h>
+
+/* XXX Temporary cheezoid implementation of ITIMER_REAL/SIGALRM. */
+
+spin_lock_t _hurd_itimer_lock = SPIN_LOCK_INITIALIZER;
+struct itimerval _hurd_itimerval; /* Current state of the timer. */
+mach_port_t _hurd_itimer_port; /* Port the timer thread blocks on. */
+thread_t _hurd_itimer_thread; /* Thread waiting for timeout. */
+int _hurd_itimer_thread_suspended; /* Nonzero if that thread is suspended. */
+vm_address_t _hurd_itimer_thread_stack_base; /* Base of its stack. */
+vm_address_t _hurd_itimer_thread_stack_size; /* Size of its stack. */
+struct timeval _hurd_itimer_started; /* Time the thread started waiting. */
+
+static inline void
+subtract_timeval (struct timeval *from, const struct timeval *subtract)
+{
+ from->tv_usec -= subtract->tv_usec;
+ from->tv_sec -= subtract->tv_sec;
+ while (from->tv_usec < 0)
+ {
+ --from->tv_sec;
+ from->tv_usec += 1000000;
+ }
+}
+
+/* Function run by the itimer thread.
+ This code must be very careful not ever to require a MiG reply port. */
+
+static void
+timer_thread (void)
+{
+ while (1)
+ {
+ error_t err;
+ /* The only message we ever expect to receive is the reply from the
+ signal thread to a sig_post call we did. We never examine the
+ contents. */
+ struct
+ {
+ mach_msg_header_t header;
+ error_t return_code;
+ } msg;
+
+ /* Wait for a message on a port that noone sends to. The purpose is
+ the receive timeout. Notice interrupts so that if we are
+ thread_abort'd, we will loop around and fetch new values from
+ _hurd_itimerval. */
+ err = __mach_msg (&msg.header,
+ MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT,
+ 0, 0, _hurd_itimer_port,
+ _hurd_itimerval.it_value.tv_sec * 1000 +
+ _hurd_itimerval.it_value.tv_usec / 1000,
+ MACH_PORT_NULL);
+ switch (err)
+ {
+ case MACH_RCV_TIMED_OUT:
+ /* We got the expected timeout. Send a message to the signal
+ thread to tell it to post a SIGALRM signal. We use
+ _hurd_itimer_port as the reply port just so we will block until
+ the signal thread has frobnicated things to reload the itimer or
+ has terminated this thread. */
+ __msg_sig_post_request (_hurd_msgport,
+ _hurd_itimer_port,
+ MACH_MSG_TYPE_MAKE_SEND_ONCE,
+ SIGALRM, __mach_task_self ());
+ break;
+
+ case MACH_RCV_INTERRUPTED:
+ /* We were thread_abort'd. This is to tell us that
+ _hurd_itimerval has changed and we need to reexamine it
+ and start waiting with the new timeout value. */
+ break;
+
+ case MACH_MSG_SUCCESS:
+ /* We got the reply message from the sig_post_request above.
+ Ignore it and reexamine the timer value. */
+ __mach_msg_destroy (&msg.header); /* Just in case. */
+ break;
+
+ default:
+ /* Unexpected lossage. Oh well, keep trying. */
+ break;
+ }
+ }
+}
+
+/* Forward declaration. */
+static sighandler_t preempt_sigalrm (thread_t thread, int signo,
+ long int sigcode, int sigerror);
+
+/* Called before any normal SIGALRM signal is delivered.
+ Reload the itimer, or disable the itimer. */
+
+static int
+setitimer_locked (const struct itimerval *new, struct itimerval *old,
+ void *crit)
+{
+ struct itimerval newval = *new;
+ struct timeval now, remaining, elapsed;
+ struct timeval old_interval;
+ error_t err;
+
+ inline void kill_itimer_thread (void)
+ {
+ __thread_terminate (_hurd_itimer_thread);
+ __vm_deallocate (__mach_task_self (),
+ _hurd_itimer_thread_stack_base,
+ _hurd_itimer_thread_stack_size);
+ _hurd_itimer_thread = MACH_PORT_NULL;
+ }
+
+ if ((newval.it_value.tv_sec | newval.it_value.tv_usec) != 0)
+ {
+ /* Make sure the itimer thread is set up. */
+
+ if (_hurd_signal_preempt[SIGALRM] == NULL)
+ {
+ static struct hurd_signal_preempt preempt =
+ { preempt_sigalrm, 0, 0, NULL };
+ _hurd_signal_preempt[SIGALRM] = &preempt;
+ }
+
+ if (_hurd_itimer_port == MACH_PORT_NULL)
+ {
+ /* Allocate a receive right that the itimer thread will
+ block waiting for a message on. */
+ if (err = __mach_port_allocate (__mach_task_self (),
+ MACH_PORT_RIGHT_RECEIVE,
+ &_hurd_itimer_port))
+ goto out;
+ }
+
+ if (_hurd_itimer_thread == MACH_PORT_NULL)
+ {
+ /* Start up the itimer thread running `timer_thread' (below). */
+ if (err = __thread_create (__mach_task_self (),
+ &_hurd_itimer_thread))
+ return __hurd_fail (err);
+ _hurd_itimer_thread_stack_base = 0; /* Anywhere. */
+ _hurd_itimer_thread_stack_size = __vm_page_size; /* Small stack. */
+ if (err = __mach_setup_thread (__mach_task_self (),
+ _hurd_itimer_thread,
+ &timer_thread,
+ &_hurd_itimer_thread_stack_base,
+ &_hurd_itimer_thread_stack_size))
+ {
+ __thread_terminate (_hurd_itimer_thread);
+ _hurd_itimer_thread = MACH_PORT_NULL;
+ goto out;
+ }
+ _hurd_itimer_thread_suspended = 1;
+ }
+ }
+
+ if ((newval.it_value.tv_sec | newval.it_value.tv_usec) != 0 || old != NULL)
+ {
+ /* Calculate how much time is remaining for the pending alarm. */
+ if (__gettimeofday (&now, NULL) < 0)
+ {
+ __spin_unlock (&_hurd_itimer_lock);
+ _hurd_critical_section_unlock (crit);
+ return -1;
+ }
+ elapsed = now;
+ subtract_timeval (&elapsed, &_hurd_itimer_started);
+ remaining = _hurd_itimerval.it_value;
+ if (timercmp (&remaining, &elapsed, <))
+ {
+ /* Hmm. The timer should have just gone off, but has not been reset.
+ This is a possible timing glitch. The alarm will signal soon. */
+ /* XXX wrong */
+ remaining.tv_sec = 0;
+ remaining.tv_usec = 0;
+ }
+ else
+ subtract_timeval (&remaining, &elapsed);
+
+ /* Remember the old reload interval before changing it. */
+ old_interval = _hurd_itimerval.it_interval;
+
+ /* Record the starting time that the timer interval relates to. */
+ _hurd_itimer_started = now;
+ }
+
+ /* Load the new itimer value. */
+ _hurd_itimerval = newval;
+
+ if ((newval.it_value.tv_sec | newval.it_value.tv_usec) == 0)
+ {
+ /* Disable the itimer. */
+ if (_hurd_itimer_thread && !_hurd_itimer_thread_suspended)
+ {
+ /* Suspend the itimer thread so it does nothing. Then abort its
+ kernel context so that when the thread is resumed, mach_msg
+ will return to timer_thread (below) and it will fetch new
+ values from _hurd_itimerval. */
+ if ((err = __thread_suspend (_hurd_itimer_thread)) ||
+ (err = __thread_abort (_hurd_itimer_thread)))
+ /* If we can't save it for later, nuke it. */
+ kill_itimer_thread ();
+ else
+ _hurd_itimer_thread_suspended = 1;
+ }
+ }
+ /* See if the timeout changed. If so, we must alert the itimer thread. */
+ else if (remaining.tv_sec != new->it_value.tv_sec ||
+ remaining.tv_usec != new->it_value.tv_usec)
+ {
+ /* The timeout value is changing. Tell the itimer thread to
+ reexamine it and start counting down. If the itimer thread is
+ marked as suspended, either we just created it, or it was
+ suspended and thread_abort'd last time the itimer was disabled;
+ either way it will wake up and start waiting for the new timeout
+ value when we resume it. If it is not suspended, the itimer
+ thread is waiting to deliver a pending alarm that we will override
+ (since it would come later than the new alarm being set);
+ thread_abort will make mach_msg return MACH_RCV_INTERRUPTED, so it
+ will loop around and use the new timeout value. */
+ if (err = (_hurd_itimer_thread_suspended
+ ? __thread_resume : __thread_abort) (_hurd_itimer_thread))
+ {
+ kill_itimer_thread ();
+ goto out;
+ }
+ _hurd_itimer_thread_suspended = 0;
+ }
+
+ __spin_unlock (&_hurd_itimer_lock);
+ _hurd_critical_section_unlock (crit);
+
+ if (old != NULL)
+ {
+ old->it_value = remaining;
+ old->it_interval = old_interval;
+ }
+ return 0;
+
+ out:
+ __spin_unlock (&_hurd_itimer_lock);
+ _hurd_critical_section_unlock (crit);
+ return __hurd_fail (err);
+}
+
+/* Set the timer WHICH to *NEW. If OLD is not NULL,
+ set *OLD to the old value of timer WHICH.
+ Returns 0 on success, -1 on errors. */
+int
+DEFUN(__setitimer, (which, new, old),
+ enum __itimer_which which AND
+ struct itimerval *new AND struct itimerval *old)
+{
+ void *crit;
+
+ switch (which)
+ {
+ default:
+ return __hurd_fail (EINVAL);
+
+ case ITIMER_VIRTUAL:
+ case ITIMER_PROF:
+ return __hurd_fail (ENOSYS);
+
+ case ITIMER_REAL:
+ break;
+ }
+
+ crit = _hurd_critical_section_lock ();
+ __spin_lock (&_hurd_itimer_lock);
+ return setitimer_locked (new, old, crit);
+}
+
+static sighandler_t
+preempt_sigalrm (thread_t thread, int signo, long int sigcode, int sigerror)
+{
+ struct itimerval it;
+
+ if (thread != _hurd_sigthread || signo != SIGALRM || sigcode != 0)
+ /* Too much monkey business. */
+ return SIG_DFL;
+
+ /* Either reload or disable the itimer. */
+ __spin_lock (&_hurd_itimer_lock);
+ it = _hurd_itimerval;
+ it.it_value = it.it_interval;
+ setitimer_locked (&it, NULL, NULL);
+
+ /* Continue with normal delivery of SIGALRM. */
+ return SIG_DFL;
+}
+
+static void
+fork_itimer (void)
+{
+ /* We must restart the itimer in the child. */
+
+ struct itimerval it;
+
+ __spin_lock (&_hurd_itimer_lock);
+ _hurd_itimer_thread = MACH_PORT_NULL;
+ it = _hurd_itimerval;
+ it.it_value = it.it_interval;
+
+ setitimer_locked (&it, NULL, NULL);
+}
+text_set_element (_hurd_fork_child_hook, fork_itimer);
+
+weak_alias (__setitimer, setitimer)
diff --git a/sysdeps/mach/hurd/setlogin.c b/sysdeps/mach/hurd/setlogin.c
new file mode 100644
index 0000000..867d8e2
--- /dev/null
+++ b/sysdeps/mach/hurd/setlogin.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+
+/* Set the login name returned by `getlogin'. */
+int
+DEFUN(setlogin, (name), CONST char *name)
+{
+ error_t err;
+ if (err = __USEPORT (PROC, __proc_setlogin (port, name)))
+ return __hurd_fail (err);
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/setpgid.c b/sysdeps/mach/hurd/setpgid.c
new file mode 100644
index 0000000..7c74ef8
--- /dev/null
+++ b/sysdeps/mach/hurd/setpgid.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/port.h>
+
+/* Set the process group ID of the process matching PID to PGID.
+ If PID is zero, the current process's process group ID is set.
+ If PGID is zero, the process ID of the process is used. */
+int
+DEFUN(__setpgid, (pid, pgid), pid_t pid AND pid_t pgid)
+{
+ error_t err;
+ unsigned int stamp;
+
+ stamp = _hurd_pids_changed_stamp; /* Atomic fetch. */
+
+ if (err = __USEPORT (PROC, __proc_setpgrp (port, pid, pgid)))
+ return __hurd_fail (err);
+
+ if (pid == 0 || pid == _hurd_pid)
+ /* Synchronize with the signal thread to make sure we have
+ received and processed proc_newids before returning to the user. */
+ while (_hurd_pids_changed_stamp == stamp)
+ {
+#ifdef noteven
+ /* XXX we have no need for a mutex, but cthreads demands one. */
+ __condition_wait (&_hurd_pids_changed_sync, NULL);
+#else
+ __swtch_pri(0);
+#endif
+ }
+
+ return 0;
+
+}
+
+weak_alias (__setpgid, setpgid)
+weak_alias (__setpgid, setpgrp)
diff --git a/sysdeps/mach/hurd/setpriority.c b/sysdeps/mach/hurd/setpriority.c
new file mode 100644
index 0000000..644bfdf
--- /dev/null
+++ b/sysdeps/mach/hurd/setpriority.c
@@ -0,0 +1,85 @@
+/* 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. */
+
+#include <hurd.h>
+#include <hurd/resource.h>
+
+/* Set the priority of all processes specified by WHICH and WHO
+ to PRIO. Returns 0 on success, -1 on errors. */
+int
+setpriority (enum __priority_which which, int who, int prio)
+{
+ error_t err;
+ error_t pidloser, priloser;
+ unsigned int npids, ntasks, nwin, nperm, nacces;
+
+ error_t setonepriority (pid_t pid, struct procinfo *pi)
+ {
+ task_t task;
+ error_t piderr = __USEPORT (PROC, __proc_pid2task (port, pid, &task));
+ if (piderr == EPERM)
+ ++nperm;
+ if (piderr != ESRCH)
+ {
+ ++npids;
+ if (piderr && piderr != EPERM)
+ pidloser = piderr;
+ }
+ if (! piderr)
+ {
+ error_t prierr;
+ ++ntasks;
+ prierr = __task_priority (task, NICE_TO_MACH_PRIORITY (prio), 1);
+ __mach_port_deallocate (__mach_task_self (), task);
+ switch (prierr)
+ {
+ case KERN_FAILURE:
+ ++nacces;
+ break;
+ case KERN_SUCCESS:
+ ++nwin;
+ break;
+ case KERN_INVALID_ARGUMENT: /* Task died. */
+ --npids;
+ --ntasks;
+ break;
+ default:
+ priloser = prierr;
+ }
+ }
+ return 0;
+ }
+
+ npids = ntasks = nwin = nperm = nacces = 0;
+ pidloser = priloser = 0;
+ err = _hurd_priority_which_map (which, who, setonepriority);
+
+ if (!err && npids == 0)
+ /* No error, but no pids found. */
+ err = ESRCH;
+ else if (nperm == npids)
+ /* Got EPERM from proc_task2pid for every process. */
+ err = EPERM;
+ else if (nacces == ntasks)
+ /* Got KERN_FAILURE from task_priority for every task. */
+ err = EACCES;
+ else if (nwin == 0)
+ err = pidloser ?: priloser;
+
+ return err ? __hurd_fail (err) : 0;
+}
diff --git a/sysdeps/mach/hurd/setregid.c b/sysdeps/mach/hurd/setregid.c
new file mode 100644
index 0000000..8b76f70
--- /dev/null
+++ b/sysdeps/mach/hurd/setregid.c
@@ -0,0 +1,71 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/id.h>
+#include <string.h>
+
+int
+__setregid (gid_t rgid, gid_t egid)
+{
+ auth_t newauth;
+ error_t err;
+
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_id.lock);
+ err = _hurd_check_ids ();
+
+ if (!err)
+ {
+ /* Make a new auth handle which has RGID as the real gid,
+ and EGID as the first element in the list of effective gids. */
+
+ size_t ngen = _hurd_id.gen.ngids < 1 ? 1 : _hurd_id.gen.ngids;
+ size_t naux = _hurd_id.aux.ngids < 1 ? 1 : _hurd_id.aux.ngids;
+ gid_t newaux[naux], newgen[ngen];
+
+ newgen[0] = egid;
+ memcpy (&newgen[1], _hurd_id.gen.gids, (ngen - 1) * sizeof (gid_t));
+ newaux[0] = rgid;
+ memcpy (&newaux[1], _hurd_id.aux.gids, (naux - 1) * sizeof (gid_t));
+
+ err = __USEPORT (AUTH, __auth_makeauth
+ (port, NULL, MACH_MSG_TYPE_COPY_SEND, 0,
+ _hurd_id.gen.gids, _hurd_id.gen.ngids,
+ _hurd_id.aux.gids, _hurd_id.aux.ngids,
+ newgen, ngen,
+ newaux, naux,
+ &newauth));
+ }
+ __mutex_unlock (&_hurd_id.lock);
+ HURD_CRITICAL_END;
+
+ if (err)
+ return __hurd_fail (err);
+
+ /* Install the new handle and reauthenticate everything. */
+ err = __setauth (newauth);
+ __mach_port_deallocate (__mach_task_self (), newauth);
+ return err;
+}
+
+weak_alias (__setregid, setregid)
diff --git a/sysdeps/mach/hurd/setreuid.c b/sysdeps/mach/hurd/setreuid.c
new file mode 100644
index 0000000..1dcbf0e
--- /dev/null
+++ b/sysdeps/mach/hurd/setreuid.c
@@ -0,0 +1,71 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/id.h>
+#include <string.h>
+
+int
+__setreuid (uid_t ruid, uid_t euid)
+{
+ auth_t newauth;
+ error_t err;
+
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_id.lock);
+ err = _hurd_check_ids ();
+
+ if (!err)
+ {
+ /* Make a new auth handle which has RUID as the real uid,
+ and EUID as the first element in the list of effective uids. */
+
+ size_t ngen = _hurd_id.gen.nuids < 1 ? 1 : _hurd_id.gen.nuids;
+ size_t naux = _hurd_id.aux.nuids < 1 ? 1 : _hurd_id.aux.nuids;
+ uid_t newaux[naux], newgen[ngen];
+
+ newgen[0] = euid;
+ memcpy (&newgen[1], _hurd_id.gen.uids, (ngen - 1) * sizeof (uid_t));
+ newaux[0] = ruid;
+ memcpy (&newaux[1], _hurd_id.aux.uids, (naux - 1) * sizeof (uid_t));
+
+ err = __USEPORT (AUTH, __auth_makeauth
+ (port, NULL, MACH_MSG_TYPE_COPY_SEND, 0,
+ newgen, ngen,
+ newaux, naux,
+ _hurd_id.gen.gids, _hurd_id.gen.ngids,
+ _hurd_id.aux.gids, _hurd_id.aux.ngids,
+ &newauth));
+ }
+ __mutex_unlock (&_hurd_id.lock);
+ HURD_CRITICAL_END;
+
+ if (err)
+ return __hurd_fail (err);
+
+ /* Install the new handle and reauthenticate everything. */
+ err = __setauth (newauth);
+ __mach_port_deallocate (__mach_task_self (), newauth);
+ return err;
+}
+
+weak_alias (__setreuid, setreuid)
diff --git a/sysdeps/mach/hurd/setrlimit.c b/sysdeps/mach/hurd/setrlimit.c
new file mode 100644
index 0000000..6d60d6d
--- /dev/null
+++ b/sysdeps/mach/hurd/setrlimit.c
@@ -0,0 +1,58 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <hurd.h>
+#include <hurd/resource.h>
+#include <errno.h>
+#include <hurd/fd.h>
+
+
+/* Set the soft and hard limits for RESOURCE to *RLIMITS.
+ Only the super-user can increase hard limits.
+ Return 0 if successful, -1 if not (and sets errno). */
+int
+DEFUN(setrlimit, (resource, rlimits),
+ enum __rlimit_resource resource AND struct rlimit *rlimits)
+{
+ struct rlimit lim;
+
+ if (rlimits == NULL || (unsigned int) resource >= RLIMIT_NLIMITS)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ lim = *rlimits;
+
+ if (lim.rlim_max != RLIM_INFINITY)
+ {
+ /* We have no enforceable resource limits. */
+ errno = ENOSYS;
+ return -1;
+ }
+
+ if (lim.rlim_cur > lim.rlim_max)
+ lim.rlim_cur = lim.rlim_max;
+
+ __mutex_lock (&_hurd_rlimit_lock);
+ _hurd_rlimits[resource] = lim;
+ __mutex_unlock (&_hurd_rlimit_lock);
+
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/setsid.c b/sysdeps/mach/hurd/setsid.c
new file mode 100644
index 0000000..22dc965
--- /dev/null
+++ b/sysdeps/mach/hurd/setsid.c
@@ -0,0 +1,59 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/port.h>
+
+
+/* Create a new session with the calling process as its leader.
+ The process group IDs of the session and the calling process
+ are set to the process ID of the calling process, which is returned. */
+int
+DEFUN_VOID(__setsid)
+{
+ error_t err;
+ unsigned int stamp;
+
+ stamp = _hurd_pids_changed_stamp; /* Atomic fetch. */
+
+ /* Tell the proc server we want to start a new session. */
+ if (err = __USEPORT (PROC, __proc_setsid (port)))
+ return __hurd_fail (err);
+
+ /* Punt our current ctty. */
+ _hurd_setcttyid (MACH_PORT_NULL);
+
+ /* Synchronize with the signal thread to make sure we have
+ received and processed proc_newids before returning to the user. */
+ while (_hurd_pids_changed_stamp == stamp)
+ {
+#ifdef noteven
+ /* XXX we have no need for a mutex, but cthreads demands one. */
+ __condition_wait (&_hurd_pids_changed_sync, NULL);
+#else
+ __swtch_pri(0);
+#endif
+ }
+
+ return 0;
+}
+
+weak_alias (__setsid, setsid)
diff --git a/sysdeps/mach/hurd/setsockopt.c b/sysdeps/mach/hurd/setsockopt.c
new file mode 100644
index 0000000..4d52769
--- /dev/null
+++ b/sysdeps/mach/hurd/setsockopt.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <hurd.h>
+#include <hurd/socket.h>
+#include <hurd/fd.h>
+
+/* Set socket FD's option OPTNAME at protocol level LEVEL
+ to *OPTVAL (which is OPTLEN bytes long).
+ Returns 0 on success, -1 for errors. */
+int
+DEFUN(setsockopt, (fd, level, optname, optval, optlen),
+ int fd AND int level AND int optname AND
+ PTR optval AND size_t optlen)
+{
+ error_t err = HURD_DPORT_USE (fd, __socket_setopt (port,
+ level, optname,
+ optval, optlen));
+ if (err)
+ return __hurd_dfail (fd, err);
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/settimeofday.c b/sysdeps/mach/hurd/settimeofday.c
new file mode 100644
index 0000000..1747a44
--- /dev/null
+++ b/sysdeps/mach/hurd/settimeofday.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <hurd.h>
+#include <hurd/port.h>
+
+/* Set the current time of day and timezone information.
+ This call is restricted to the super-user. */
+int
+DEFUN(__settimeofday, (tv, tz),
+ CONST struct timeval *tv AND CONST struct timezone *tz)
+{
+ error_t err;
+ mach_port_t hostpriv, devmaster;
+
+ if (tz != NULL)
+ {
+ errno = ENOSYS;
+ return -1;
+ }
+
+ if (err = __USEPORT (PROC, __proc_getprivports (port,
+ &hostpriv, &devmaster)))
+ return __hurd_fail (err);
+ __mach_port_deallocate (__mach_task_self (), devmaster);
+
+ /* `time_value_t' and `struct timeval' are in fact identical with the
+ names changed. */
+ err = __host_set_time (hostpriv, *(time_value_t *) tv);
+ __mach_port_deallocate (__mach_task_self (), hostpriv);
+
+ if (err)
+ return __hurd_fail (err);
+
+ return 0;
+}
+
+weak_alias (__settimeofday, settimeofday)
diff --git a/sysdeps/mach/hurd/setuid.c b/sysdeps/mach/hurd/setuid.c
new file mode 100644
index 0000000..7084038
--- /dev/null
+++ b/sysdeps/mach/hurd/setuid.c
@@ -0,0 +1,76 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <hurd.h>
+#include <hurd/id.h>
+#include <string.h>
+
+/* Set the user ID of the calling process to UID.
+ If the calling process is the super-user, the real
+ and effective user IDs, and the saved set-user-ID to UID;
+ if not, the effective user ID is set to UID. */
+int
+DEFUN(__setuid, (uid), uid_t uid)
+{
+ auth_t newauth;
+ error_t err;
+
+ HURD_CRITICAL_BEGIN;
+ __mutex_lock (&_hurd_id.lock);
+ err = _hurd_check_ids ();
+
+ if (!err)
+ {
+ /* Make a new auth handle which has UID as the real uid,
+ and as the first element in the list of effective uids. */
+
+ uid_t newgen[_hurd_id.gen.nuids + 1];
+ uid_t newaux[_hurd_id.aux.nuids];
+
+ newgen[0] = uid;
+ memcpy (&newgen[1], _hurd_id.gen.uids,
+ _hurd_id.gen.nuids * sizeof (uid_t));
+ newaux[0] = uid;
+ memcpy (&newaux[1], _hurd_id.aux.uids,
+ (_hurd_id.aux.nuids - 1) * sizeof (uid_t));
+
+ err = __USEPORT (AUTH, __auth_makeauth
+ (port, NULL, 0, MACH_MSG_TYPE_COPY_SEND,
+ _hurd_id.gen.uids, _hurd_id.gen.nuids,
+ _hurd_id.aux.uids, _hurd_id.aux.nuids,
+ newgen, 1 + _hurd_id.gen.nuids,
+ newaux, _hurd_id.aux.nuids,
+ &newauth));
+ }
+ __mutex_unlock (&_hurd_id.lock);
+ HURD_CRITICAL_END;
+
+ if (err)
+ return __hurd_fail (err);
+
+ /* Install the new handle and reauthenticate everything. */
+ err = __setauth (newauth);
+ __mach_port_deallocate (__mach_task_self (), newauth);
+ return err;
+}
+
+weak_alias (__setuid, setuid)
diff --git a/sysdeps/mach/hurd/shutdown.c b/sysdeps/mach/hurd/shutdown.c
new file mode 100644
index 0000000..685057b
--- /dev/null
+++ b/sysdeps/mach/hurd/shutdown.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <hurd.h>
+#include <hurd/socket.h>
+#include <hurd/fd.h>
+
+/* Shut down all or part of the connection open on socket FD.
+ HOW determines what to shut down:
+ 0 = No more receptions;
+ 1 = No more transmissions;
+ 2 = No more receptions or transmissions.
+ Returns 0 on success, -1 for errors. */
+int
+DEFUN(shutdown, (fd, how),
+ int fd AND int how)
+{
+ error_t err = HURD_DPORT_USE (fd, __socket_shutdown (port, how));
+ if (err)
+ return __hurd_dfail (fd, err);
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/sigaction.c b/sysdeps/mach/hurd/sigaction.c
new file mode 100644
index 0000000..91de02c
--- /dev/null
+++ b/sysdeps/mach/hurd/sigaction.c
@@ -0,0 +1,84 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+#include <hurd.h>
+#include <hurd/signal.h>
+
+/* If ACT is not NULL, change the action for SIG to *ACT.
+ If OACT is not NULL, put the old action for SIG in *OACT. */
+int
+DEFUN(__sigaction, (sig, act, oact),
+ int sig AND CONST struct sigaction *act AND struct sigaction *oact)
+{
+ struct hurd_sigstate *ss;
+ struct sigaction a, old;
+ sigset_t pending;
+
+ if (sig <= 0 || sig >= NSIG ||
+ (act != NULL && act->sa_handler != SIG_DFL &&
+ ((__sigmask (sig) & _SIG_CANT_MASK) ||
+ act->sa_handler == SIG_ERR)))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* Copy so we fault before taking locks. */
+ if (act != NULL)
+ a = *act;
+
+ ss = _hurd_self_sigstate ();
+
+ __spin_lock (&ss->lock);
+ old = ss->actions[sig];
+ if (act != NULL)
+ ss->actions[sig] = a;
+
+ if (act != NULL && sig == SIGCHLD)
+ {
+ ss->critical_section = 1;
+ __spin_unlock (&ss->lock);
+
+ /* Inform the proc server whether or not it should send us SIGCHLD for
+ stopped children. We do this in a critical section so that no
+ SIGCHLD can arrive in the middle and be of indeterminate status. */
+ __USEPORT (PROC,
+ __proc_mod_stopchild (port, !(a.sa_flags & SA_NOCLDSTOP)));
+
+ __spin_lock (&ss->lock);
+ ss->critical_section = 0;
+ pending = ss->pending & ~ss->blocked;
+ }
+ else
+ pending = 0;
+
+ __spin_unlock (&ss->lock);
+
+ if (pending)
+ __msg_sig_post (_hurd_msgport, 0, __mach_task_self ());
+
+ if (oact != NULL)
+ *oact = old;
+
+ return 0;
+}
+
+weak_alias (__sigaction, sigaction)
diff --git a/sysdeps/mach/hurd/sigaltstack.c b/sysdeps/mach/hurd/sigaltstack.c
new file mode 100644
index 0000000..c4a9052
--- /dev/null
+++ b/sysdeps/mach/hurd/sigaltstack.c
@@ -0,0 +1,62 @@
+/* Copyright (C) 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <hurd.h>
+#include <hurd/signal.h>
+
+/* Run signals handlers on the stack specified by SS (if not NULL).
+ If OSS is not NULL, it is filled in with the old signal stack status. */
+int
+DEFUN(sigaltstack, (ss, oss),
+ CONST struct sigaltstack *argss AND struct sigaltstack *oss)
+{
+ struct hurd_sigstate *s;
+ struct sigaltstack ss, old;
+
+ /* Fault before taking any locks. */
+ if (argss != NULL)
+ ss = *argss;
+ if (oss != NULL)
+ *(volatile struct sigaltstack *) oss = *oss;
+
+ s = _hurd_self_sigstate ();
+ __spin_lock (&s->lock);
+
+ if (argss != NULL &&
+ (ss.ss_flags & SA_DISABLE) && (s->sigaltstack.ss_flags & SA_ONSTACK))
+ {
+ /* Can't disable a stack that is in use. */
+ __spin_unlock (&s->lock);
+ errno = EINVAL;
+ return -1;
+ }
+
+ old = s->sigaltstack;
+
+ if (argss != NULL)
+ s->sigaltstack = ss;
+
+ __spin_unlock (&s->lock);
+
+ if (oss != NULL)
+ *oss = old;
+
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/sigpending.c b/sysdeps/mach/hurd/sigpending.c
new file mode 100644
index 0000000..8c12ed0
--- /dev/null
+++ b/sysdeps/mach/hurd/sigpending.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <hurd.h>
+#include <hurd/signal.h>
+
+
+/* Store in SET all signals that are blocked and pending. */
+int
+DEFUN(sigpending, (set), sigset_t *set)
+{
+ struct hurd_sigstate *ss;
+ sigset_t pending;
+
+ if (set == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ss = _hurd_self_sigstate ();
+ __spin_lock (&ss->lock);
+ pending = ss->pending;
+ __spin_unlock (&ss->lock);
+
+ *set = pending;
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/sigprocmask.c b/sysdeps/mach/hurd/sigprocmask.c
new file mode 100644
index 0000000..bae3266
--- /dev/null
+++ b/sysdeps/mach/hurd/sigprocmask.c
@@ -0,0 +1,87 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+#include <hurd.h>
+#include <hurd/signal.h>
+#include <hurd/msg.h>
+
+
+/* If SET is not NULL, modify the current set of blocked signals
+ according to HOW, which may be SIG_BLOCK, SIG_UNBLOCK or SIG_SETMASK.
+ If OSET is not NULL, store the old set of blocked signals in *OSET. */
+int
+DEFUN(__sigprocmask, (how, set, oset),
+ int how AND CONST sigset_t *set AND sigset_t *oset)
+{
+ struct hurd_sigstate *ss;
+ sigset_t old, new;
+ sigset_t pending;
+
+ if (set != NULL)
+ new = *set;
+
+ ss = _hurd_self_sigstate ();
+
+ __spin_lock (&ss->lock);
+
+ old = ss->blocked;
+
+ if (set != NULL)
+ {
+ switch (how)
+ {
+ case SIG_BLOCK:
+ ss->blocked |= new;
+ break;
+
+ case SIG_UNBLOCK:
+ ss->blocked &= ~new;
+ break;
+
+ case SIG_SETMASK:
+ ss->blocked = new;
+ break;
+
+ default:
+ __spin_unlock (&ss->lock);
+ errno = EINVAL;
+ return -1;
+ }
+
+ ss->blocked &= ~_SIG_CANT_MASK;
+ }
+
+ pending = ss->pending & ~ss->blocked;
+
+ __spin_unlock (&ss->lock);
+
+ if (oset != NULL)
+ *oset = old;
+
+ if (pending)
+ /* Send a message to the signal thread so it
+ will wake up and check for pending signals. */
+ __msg_sig_post (_hurd_msgport, 0, __mach_task_self ());
+
+ return 0;
+}
+
+weak_alias (__sigprocmask, sigprocmask)
diff --git a/sysdeps/mach/hurd/sigstack.c b/sysdeps/mach/hurd/sigstack.c
new file mode 100644
index 0000000..77803ab
--- /dev/null
+++ b/sysdeps/mach/hurd/sigstack.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+#include <hurd.h>
+
+/* Run signals handlers on the stack specified by SS (if not NULL).
+ If OSS is not NULL, it is filled in with the old signal stack status. */
+int
+DEFUN(sigstack, (ss, oss),
+ CONST struct sigstack *ss AND struct sigstack *oss)
+{
+ struct sigaltstack as, oas;
+
+ as.ss_sp = ss->ss_sp;
+ as.ss_size = 0;
+ as.ss_flags = 0;
+
+ if (sigaltstack (&as, &oas) < 0)
+ return -1;
+
+ if (oss != NULL)
+ {
+ oss->ss_sp = oas.ss_sp;
+ oss->ss_onstack = oas.ss_flags & SA_ONSTACK;
+ }
+
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/sigsuspend.c b/sysdeps/mach/hurd/sigsuspend.c
new file mode 100644
index 0000000..aa0b287
--- /dev/null
+++ b/sysdeps/mach/hurd/sigsuspend.c
@@ -0,0 +1,81 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <hurd.h>
+#include <hurd/signal.h>
+#include <hurd/msg.h>
+
+/* Change the set of blocked signals to SET,
+ wait until a signal arrives, and restore the set of blocked signals. */
+int
+DEFUN(sigsuspend, (set), CONST sigset_t *set)
+{
+ struct hurd_sigstate *ss;
+ sigset_t newmask, oldmask, pending;
+ mach_port_t wait;
+ mach_msg_header_t msg;
+
+ if (set != NULL)
+ /* Crash before locking. */
+ newmask = *set;
+
+ /* Get a fresh port we will wait on. */
+ wait = __mach_reply_port ();
+
+ ss = _hurd_self_sigstate ();
+
+ __spin_lock (&ss->lock);
+
+ oldmask = ss->blocked;
+ if (set != NULL)
+ /* Change to the new blocked signal mask. */
+ ss->blocked = newmask & ~_SIG_CANT_MASK;
+
+ /* Notice if any pending signals just became unblocked. */
+ pending = ss->pending & ~ss->blocked;
+
+ /* Tell the signal thread to message us when a signal arrives. */
+ ss->suspended = wait;
+ __spin_unlock (&ss->lock);
+
+ if (pending)
+ /* Tell the signal thread to check for pending signals. */
+ __msg_sig_post (_hurd_msgport, 0, __mach_task_self ());
+
+ /* Wait for the signal thread's message. */
+ __mach_msg (&msg, MACH_RCV_MSG, 0, sizeof (msg), wait,
+ MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
+ __mach_port_destroy (__mach_task_self (), wait);
+
+ __spin_lock (&ss->lock);
+ ss->blocked = oldmask; /* Restore the old mask. */
+ pending = ss->pending & ~ss->blocked; /* Again check for pending signals. */
+ __spin_unlock (&ss->lock);
+
+ if (pending)
+ /* Tell the signal thread to check for pending signals. */
+ __msg_sig_post (_hurd_msgport, 0, __mach_task_self ());
+
+ /* We've been interrupted! And a good thing, too.
+ Otherwise we'd never return.
+ That's right; this function always returns an error. */
+ errno = EINTR;
+ return -1;
+}
diff --git a/sysdeps/mach/hurd/socket.c b/sysdeps/mach/hurd/socket.c
new file mode 100644
index 0000000..b779360
--- /dev/null
+++ b/sysdeps/mach/hurd/socket.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <hurd.h>
+#include <hurd/socket.h>
+#include <hurd/fd.h>
+#include <fcntl.h>
+
+/* Create a new socket of type TYPE in domain DOMAIN, using
+ protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically.
+ Returns a file descriptor for the new socket, or -1 for errors. */
+int
+DEFUN(socket, (domain, type, protocol),
+ int domain AND enum __socket_type type AND int protocol)
+{
+ error_t err;
+ socket_t sock, server;
+
+ /* Find the socket server for DOMAIN. */
+ server = _hurd_socket_server (domain, 0);
+ if (server == MACH_PORT_NULL)
+ return -1;
+
+ err = __socket_create (server, type, protocol, &sock);
+ if (err == MACH_SEND_INVALID_DEST || err == MIG_SERVER_DIED)
+ {
+ /* On the first use of the socket server during the operation,
+ allow for the old server port dying. */
+ server = _hurd_socket_server (domain, 1);
+ if (server == MACH_PORT_NULL)
+ return -1;
+ err = __socket_create (server, type, protocol, &sock);
+ }
+
+ if (err)
+ return __hurd_fail (err);
+
+ return _hurd_intern_fd (sock, O_IGNORE_CTTY, 1);
+}
diff --git a/sysdeps/mach/hurd/socketpair.c b/sysdeps/mach/hurd/socketpair.c
new file mode 100644
index 0000000..c4d09c7
--- /dev/null
+++ b/sysdeps/mach/hurd/socketpair.c
@@ -0,0 +1,93 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <hurd.h>
+#include <hurd/socket.h>
+#include <hurd/fd.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+/* Create two new sockets, of type TYPE in domain DOMAIN and using
+ protocol PROTOCOL, which are connected to each other, and put file
+ descriptors for them in FDS[0] and FDS[1]. If PROTOCOL is zero,
+ one will be chosen automatically. Returns 0 on success, -1 for errors. */
+int
+DEFUN(socketpair, (domain, type, protocol, fds),
+ int domain AND enum __socket_type type AND int protocol AND int fds[2])
+{
+ error_t err;
+ socket_t server, sock1, sock2;
+ int d1, d2;
+
+ if (fds == NULL)
+ return __hurd_fail (EINVAL);
+
+ /* Find the domain's socket server. */
+ server = _hurd_socket_server (domain, 0);
+ if (server == MACH_PORT_NULL)
+ return -1;
+
+ /* Create two sockets and connect them together. */
+
+ err = __socket_create (server, type, protocol, &sock1);
+ if (err == MACH_SEND_INVALID_DEST || err == MIG_SERVER_DIED)
+ {
+ /* On the first use of the socket server during the operation,
+ allow for the old server port dying. */
+ server = _hurd_socket_server (domain, 1);
+ if (server == MACH_PORT_NULL)
+ return -1;
+ err = __socket_create (server, type, protocol, &sock1);
+ }
+ if (err)
+ return __hurd_fail (err);
+ if (err = __socket_create (server, type, protocol, &sock2))
+ {
+ __mach_port_deallocate (__mach_task_self (), sock1);
+ return __hurd_fail (err);
+ }
+ if (err = __socket_connect2 (sock1, sock2))
+ {
+ __mach_port_deallocate (__mach_task_self (), sock1);
+ __mach_port_deallocate (__mach_task_self (), sock2);
+ return __hurd_fail (err);
+ }
+
+ /* Put the sockets into file descriptors. */
+
+ d1 = _hurd_intern_fd (sock1, O_IGNORE_CTTY, 1);
+ if (d1 < 0)
+ {
+ __mach_port_deallocate (__mach_task_self (), sock2);
+ return -1;
+ }
+ d2 = _hurd_intern_fd (sock2, O_IGNORE_CTTY, 1);
+ if (d2 < 0)
+ {
+ err = errno;
+ (void) close (d1);
+ return __hurd_fail (err);
+ }
+
+ fds[0] = d1;
+ fds[1] = d2;
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/start.c b/sysdeps/mach/hurd/start.c
new file mode 100644
index 0000000..91be7ea
--- /dev/null
+++ b/sysdeps/mach/hurd/start.c
@@ -0,0 +1,316 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <hurd.h>
+#include <hurd/exec.h>
+#include <sysdep.h>
+#include <hurd/threadvar.h>
+#include "set-hooks.h"
+#include "hurdmalloc.h" /* XXX */
+
+/* The first piece of initialized data. */
+int __data_start = 0;
+weak_alias (__data_start, data_start)
+
+mach_port_t *_hurd_init_dtable;
+mach_msg_type_number_t _hurd_init_dtablesize;
+
+unsigned int __hurd_threadvar_max;
+unsigned long int __hurd_threadvar_stack_mask;
+unsigned long int __hurd_threadvar_stack_offset;
+
+/* These are set up by _hurdsig_init. */
+unsigned long int __hurd_sigthread_stack_base;
+unsigned long int __hurd_sigthread_stack_end;
+unsigned long int *__hurd_sigthread_variables;
+
+vm_address_t _hurd_stack_base;
+vm_size_t _hurd_stack_size;
+
+char **__environ;
+weak_alias (__environ, environ)
+
+/* 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));
+
+extern void __mach_init (void);
+extern void __libc_init (int argc, char **argv, char **envp);
+extern int main (int argc, char **argv, char **envp);
+
+void *(*_cthread_init_routine) (void); /* Returns new SP to use. */
+void (*_cthread_exit_routine) (int status) __attribute__ ((__noreturn__));
+
+int _hurd_split_args (char *, size_t, char **);
+
+/* These communicate values from _start to start1,
+ where we cannot use the stack for anything. */
+static char *args, *env;
+static mach_port_t *portarray;
+static int *intarray;
+static mach_msg_type_number_t argslen, envlen, portarraysize, intarraysize;
+static int flags;
+static char **argv, **envp;
+static int argc;
+
+
+static void start1 (void) __attribute__ ((__noreturn__));
+
+
+/* Entry point. This is the first thing in the text segment.
+
+ The exec server started the initial thread in our task with this spot the
+ PC, and a stack that is presumably big enough. We do basic Mach
+ initialization so mig-generated stubs work, and then do an exec_startup
+ RPC on our bootstrap port, to which the exec server responds with the
+ information passed in the exec call, as well as our original bootstrap
+ port, and the base address and size of the preallocated stack.
+
+ If using cthreads, we are given a new stack by cthreads initialization and
+ deallocate the stack set up by the exec server. On the new stack we call
+ `start1' (above) to do the rest of the startup work. Since the stack may
+ disappear out from under us in a machine-dependent way, we use a pile of
+ static variables to communicate the information from exec_startup to start1.
+ This is unfortunate but preferable to machine-dependent frobnication to copy
+ the state from the old stack to the new one. */
+
+#ifndef START_ARGS
+#define START_ARGS void
+#endif
+#ifdef START_MACHDEP
+START_MACHDEP
+#define _start _start0
+#endif
+
+void
+_start (START_ARGS)
+{
+ error_t err;
+ mach_port_t in_bootstrap;
+
+ /* Basic Mach initialization, must be done before RPCs can be done. */
+ __mach_init ();
+
+ /* Run things that want to do initialization as soon as possible. We do
+ this before exec_startup so that no out of line data arrives and
+ clutters up the address space before brk initialization. */
+
+ RUN_HOOK (_hurd_preinit_hook, ());
+
+ if (err = __task_get_special_port (__mach_task_self (), TASK_BOOTSTRAP_PORT,
+ &in_bootstrap))
+ LOSE;
+
+ if (in_bootstrap != MACH_PORT_NULL)
+ {
+ /* Call the exec server on our bootstrap port and
+ get all our standard information from it. */
+
+ argslen = envlen = 0;
+ _hurd_init_dtablesize = portarraysize = intarraysize = 0;
+
+ err = __exec_startup (in_bootstrap,
+ &_hurd_stack_base, &_hurd_stack_size,
+ &flags,
+ &args, &argslen, &env, &envlen,
+ &_hurd_init_dtable, &_hurd_init_dtablesize,
+ &portarray, &portarraysize,
+ &intarray, &intarraysize);
+ __mach_port_deallocate (__mach_task_self (), in_bootstrap);
+ }
+
+ if (err || in_bootstrap == MACH_PORT_NULL)
+ {
+ /* Either we have no bootstrap port, or the RPC to the exec server
+ failed. Try to snarf the args in the canonical Mach way.
+ Hopefully either they will be on the stack as expected, or the
+ stack will be zeros so we don't crash. Set all our other
+ variables to have empty information. */
+
+ /* SNARF_ARGS (ARGC, ARGV, ENVP) snarfs the arguments and environment
+ from the stack, assuming they were put there by the microkernel. */
+ SNARF_ARGS (argc, argv, envp);
+
+ flags = 0;
+ args = env = NULL;
+ argslen = envlen = 0;
+ _hurd_init_dtable = NULL;
+ _hurd_init_dtablesize = 0;
+ portarray = NULL;
+ portarraysize = 0;
+ intarray = NULL;
+ intarraysize = 0;
+ }
+ else
+ argv = envp = NULL;
+
+
+ /* 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;
+
+ /* Do cthreads initialization and switch to the cthread stack. */
+
+ if (_cthread_init_routine != NULL)
+ CALL_WITH_SP (start1, (*_cthread_init_routine) ());
+ else
+ start1 ();
+
+ /* Should never get here. */
+ LOSE;
+}
+
+
+static void
+start1 (void)
+{
+ register int envc = 0;
+
+ {
+ /* 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 (_hurd_stack_size != 0 && (newsp < _hurd_stack_base ||
+ newsp - _hurd_stack_base > _hurd_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 (),
+ _hurd_stack_base, _hurd_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;
+ }
+
+
+ /* Turn the block of null-separated strings we were passed for the
+ arguments and environment into vectors of pointers to strings. */
+
+ if (! argv)
+ {
+ if (args)
+ /* Count up the arguments so we can allocate ARGV. */
+ argc = _hurd_split_args (args, argslen, NULL);
+ if (! args || argc == 0)
+ {
+ /* No arguments passed; set argv to { NULL }. */
+ argc = 0;
+ args = NULL;
+ argv = (char **) &args;
+ }
+ }
+
+ if (! envp)
+ {
+ if (env)
+ /* Count up the environment variables so we can allocate ENVP. */
+ envc = _hurd_split_args (env, envlen, NULL);
+ if (! env || envc == 0)
+ {
+ /* No environment passed; set __environ to { NULL }. */
+ env = NULL;
+ envp = (char **) &env;
+ }
+ }
+
+ if (! argv)
+ {
+ /* There were some arguments.
+ Allocate space for the vectors of pointers and fill them in. */
+ argv = __alloca ((argc + 1) * sizeof (char *));
+ _hurd_split_args (args, argslen, argv);
+ }
+
+ if (! envp)
+ {
+ /* There was some environment.
+ Allocate space for the vectors of pointers and fill them in. */
+ envp = __alloca ((envc + 1) * sizeof (char *));
+ _hurd_split_args (env, envlen, envp);
+ }
+
+ __environ = envp;
+
+ if (portarray || intarray)
+ /* Initialize library data structures, start signal processing, etc. */
+ _hurd_init (flags, argv, portarray, portarraysize, intarray, intarraysize);
+
+ /* Random library initialization. These functions may assume that
+ _hurd_init has already run (if it is going to), and POSIX.1 facilities
+ are initialized and available. */
+ __libc_init (argc, argv, __environ);
+
+ /* Finally, run the user program. */
+ (_cthread_exit_routine != NULL ? *_cthread_exit_routine : exit)
+ (main (argc, argv, __environ));
+
+ /* Should never get here. */
+ LOSE;
+}
+
+/* Split ARGSLEN bytes at ARGS into words, breaking at NUL characters. If
+ ARGV is not a null pointer, store a pointer to the start of each word in
+ ARGV[n], and null-terminate ARGV. Return the number of words split. */
+
+int
+_hurd_split_args (char *args, size_t argslen, char **argv)
+{
+ char *p = args;
+ size_t n = argslen;
+ int argc = 0;
+
+ while (n > 0)
+ {
+ char *end = memchr (p, '\0', n);
+
+ if (argv)
+ argv[argc] = p;
+ ++argc;
+
+ if (end == NULL)
+ /* The last argument is unterminated. */
+ break;
+
+ n -= end + 1 - p;
+ p = end + 1;
+ }
+
+ if (argv)
+ argv[argc] = NULL;
+ return argc;
+}
diff --git a/sysdeps/mach/hurd/stat.c b/sysdeps/mach/hurd/stat.c
new file mode 100644
index 0000000..e6df5e6
--- /dev/null
+++ b/sysdeps/mach/hurd/stat.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <stddef.h>
+#include <hurd.h>
+
+/* Get file information about FILE in BUF. */
+int
+DEFUN(__stat, (file, buf), CONST char *file AND struct stat *buf)
+{
+ error_t err;
+ file_t port = __file_name_lookup (file, 0, 0);
+ if (port == MACH_PORT_NULL)
+ return -1;
+ err = __io_stat (port, buf);
+ __mach_port_deallocate (__mach_task_self (), port);
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+
+weak_alias (__stat, stat)
diff --git a/sysdeps/mach/hurd/statbuf.h b/sysdeps/mach/hurd/statbuf.h
new file mode 100644
index 0000000..4d97dc1
--- /dev/null
+++ b/sysdeps/mach/hurd/statbuf.h
@@ -0,0 +1,119 @@
+/* Copyright (C) 1992, 1993, 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. */
+
+#ifndef _STATBUF_H
+
+#define _STATBUF_H 1
+
+#include <gnu/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
+ 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 stat
+ {
+ int st_fstype; /* File system type. */
+ __fsid_t st_fsid; /* File system ID. */
+#define st_dev st_fsid
+
+ __ino_t st_ino; /* File number. */
+ unsigned int st_gen; /* To detect reuse of file numbers. */
+ __dev_t st_rdev; /* Device if special file. */
+ __mode_t st_mode; /* File mode. */
+ __nlink_t st_nlink; /* Number of links. */
+
+ __uid_t st_uid; /* Owner. */
+ __gid_t st_gid; /* Owning group. */
+
+ __off_t st_size; /* Size in bytes. */
+
+ __time_t st_atime; /* Access time, seconds */
+ unsigned long int st_atime_usec; /* and microseconds. */
+ __time_t st_mtime; /* Modification time, seconds */
+ unsigned long int st_mtime_usec; /* and microseconds. */
+ __time_t st_ctime; /* Status change time, seconds */
+ unsigned long int st_ctime_usec; /* and microseconds. */
+
+ unsigned int st_blksize; /* Optimal size for I/O. */
+
+#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
+
+ unsigned int st_blocks; /* Number of 512-byte blocks allocated.
+ Not related to `st_blksize'. */
+
+ __uid_t st_author; /* File author. */
+
+ unsigned int st_flags; /* User-defined flags.
+ High 16 bits can be set only by root. */
+
+ int st_spare[11]; /* Room for future expansion. */
+ };
+
+/* Encoding of the file mode. */
+
+#define __S_IFMT 0170000 /* These bits determine file type. */
+
+/* File types. */
+#define __S_IFDIR 0040000 /* Directory. */
+#define __S_IFCHR 0020000 /* Character device. */
+#define __S_IFBLK 0060000 /* Block device. */
+#define __S_IFREG 0100000 /* Regular file. */
+#define __S_IFLNK 0120000 /* Symbolic link. */
+#define __S_IFSOCK 0140000 /* Socket. */
+#define __S_IFIFO 0010000 /* FIFO. */
+
+/* Protection bits. */
+
+#define __S_ISUID 04000 /* Set user ID on execution. */
+#define __S_ISGID 02000 /* Set group ID on execution. */
+#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
+#define __S_IREAD 00400 /* Read by owner. */
+#define __S_IWRITE 00200 /* Write by owner. */
+#define __S_IEXEC 00100 /* Execute by owner. */
+
+
+#ifdef __USE_GNU
+/* If set, there is no benefit in caching the contents of this file. */
+#define S_INOCACHE 000000200000
+
+/* If the S_IUSEUNK bit is set, then the S_IUNKNOWN bits (see below)
+ control access for unknown users. If S_IUSEUNK is clear, then unknown
+ users are treated as "others" for purposes of access control. */
+#define S_IUSEUNK 000000400000
+/* Mask of protection bits for unknown users (no effective IDs at all). */
+#define S_IUNKNOWN 000007000000
+/* Shift S_IREAD, S_IWRITE, S_IEXEC left this many bits to produce the
+ protection bits for unknown users. */
+#define S_IUNKSHIFT 12
+
+/* All the unused bits. */
+#define S_ISPARE (~(S_IFMT|S_INOCACHE|S_IUNKNOWN|07777))
+#endif
+
+/* Default file creation mask (umask). */
+#ifdef __USE_BSD
+#define CMASK 0022
+#endif
+
+
+#endif /* statbuf.h */
diff --git a/sysdeps/mach/hurd/stdio_init.c b/sysdeps/mach/hurd/stdio_init.c
new file mode 100644
index 0000000..f083ee8
--- /dev/null
+++ b/sysdeps/mach/hurd/stdio_init.c
@@ -0,0 +1,63 @@
+/* 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. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <hurd/fd.h>
+#include <hurd/io.h>
+#include <hurd/term.h>
+
+/* Initialize STREAM as necessary.
+ This may change I/O functions, give a buffer, etc.
+ If no buffer is allocated, but the bufsize is set,
+ the bufsize will be used to allocate the buffer. */
+void
+DEFUN(__stdio_init_stream, (stream), FILE *stream)
+{
+ struct hurd_fd *const d = stream->__cookie;
+ struct stat statb;
+ error_t err;
+
+ if (stream->__buffer != NULL || stream->__userbuf)
+ /* If's unbuffered by request, we can't do anything useful. */
+ return;
+
+ /* Find out what sort of file this is. */
+ if (err = HURD_FD_PORT_USE (d, __io_stat (port, &statb)))
+ return;
+
+ if (S_ISCHR (statb.st_mode))
+ {
+ /* It's a character device.
+ Make it line-buffered if it's a terminal. */
+ mach_port_t cttyid;
+ err = HURD_FD_PORT_USE (d, __term_getctty (port, &cttyid));
+ if (! err)
+ {
+ __mach_port_deallocate (__mach_task_self (), cttyid);
+ stream->__linebuf = 1;
+ }
+ }
+
+ /* Use the block-size field to determine
+ the system's optimal buffering size. */
+ stream->__bufsize = statb.st_blksize;
+}
diff --git a/sysdeps/mach/hurd/symlink.c b/sysdeps/mach/hurd/symlink.c
new file mode 100644
index 0000000..5e67c4e
--- /dev/null
+++ b/sysdeps/mach/hurd/symlink.c
@@ -0,0 +1,68 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/paths.h>
+#include <fcntl.h>
+
+/* Make a link to FROM called TO. */
+int
+DEFUN(__symlink, (from, to), CONST char *from AND CONST char *to)
+{
+ error_t err;
+ file_t dir, node;
+ char *name;
+ const size_t len = strlen (from) + 1;
+ char buf[sizeof (_HURD_SYMLINK) + len];
+
+ /* A symlink is a file whose translator is "/hurd/symlink\0target\0". */
+
+ memcpy (buf, _HURD_SYMLINK, sizeof (_HURD_SYMLINK));
+ memcpy (&buf[sizeof (_HURD_SYMLINK)], from, len);
+
+ dir = __file_name_split (to, &name);
+ if (dir == MACH_PORT_NULL)
+ return -1;
+
+ /* Create a new, unlinked node in the target directory. */
+ err = __dir_mkfile (dir, O_WRITE, 0777 & ~_hurd_umask, &node);
+
+ if (! err)
+ /* Set the node's translator to make it a symlink. */
+ err = __file_set_translator (node,
+ FS_TRANS_EXCL|FS_TRANS_SET,
+ FS_TRANS_EXCL|FS_TRANS_SET, 0,
+ buf, sizeof (_HURD_SYMLINK) + len,
+ MACH_PORT_NULL, MACH_MSG_TYPE_COPY_SEND);
+
+ if (! err)
+ /* Link the node, now a valid symlink, into the target directory. */
+ err = __dir_link (node, dir, name);
+
+ __mach_port_deallocate (__mach_task_self (), dir);
+ __mach_port_deallocate (__mach_task_self (), node);
+
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+
+weak_alias (__symlink, symlink)
diff --git a/sysdeps/mach/hurd/sync.c b/sysdeps/mach/hurd/sync.c
new file mode 100644
index 0000000..af207e6
--- /dev/null
+++ b/sysdeps/mach/hurd/sync.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+
+/* Make all changes done to all files actually appear on disk. */
+int
+DEFUN_VOID(sync)
+{
+ /* This is not actually synchronous; we don't wait. */
+ error_t err = __USEPORT (CRDIR, __file_syncfs (port, 0, 1));
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/sys/param.h b/sysdeps/mach/hurd/sys/param.h
new file mode 100644
index 0000000..79f3b05
--- /dev/null
+++ b/sysdeps/mach/hurd/sys/param.h
@@ -0,0 +1,135 @@
+/* Copyright (C) 1993, 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. */
+
+/* This file is deprecated and is provided only for compatibility with
+ Unix systems. It is unwise to include this file on programs which
+ are intended only for GNU systems.
+
+ Parts from:
+
+ * Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)param.h 7.23 (Berkeley) 5/6/91
+ */
+
+
+#ifndef _SYS_PARAM_H
+
+#define _SYS_PARAM_H 1
+#include <features.h>
+
+#define __need_NULL
+#include <stddef.h>
+
+#include <sys/types.h>
+#include <errno.h>
+#include <signal.h>
+#include <endian.h>
+#include <limits.h>
+#ifdef notyet
+#include <ufs/param.h>
+#endif
+
+
+/* What versions of BSD we are compatible with. */
+#define BSD 199306 /* System version (year & month). */
+#define BSD4_3 1
+#define BSD4_4 1
+
+#define GNU 1994100 /* GNU version (year, month, and release). */
+
+
+/* BSD names for some <limits.h> values. We do not define the BSD names
+ for the values which are not statically limited, such as NOFILE. */
+
+#define NGROUPS NGROUPS_MAX
+#define MAXSYMLINKS SYMLOOP_MAX
+#define CANBSIZ MAX_CANON /* XXX ? */
+
+/* ARG_MAX is unlimited, but we define NCARGS for BSD programs that want to
+ compare against some fixed limit. */
+#define NCARGS INT_MAX
+
+/* There is nothing quite equivalent in GNU to Unix "mounts", but there is
+ no limit on the number of simultaneously attached filesystems. */
+#define NMOUNT INT_MAX
+
+
+/* Magical constants. */
+#define NOGROUP 65535 /* Marker for empty group set member. */
+#define NODEV ((dev_t) -1) /* Non-existent device. */
+
+
+/* Bit map related macros. */
+#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
+#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
+#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
+#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
+
+/* Macros for counting and rounding. */
+#ifndef howmany
+#define howmany(x, y) (((x)+((y)-1))/(y))
+#endif
+#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
+#define powerof2(x) ((((x)-1)&(x))==0)
+
+/* Macros for min/max. */
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#define MAX(a,b) (((a)>(b))?(a):(b))
+
+
+/* Scale factor for scaled integers used to count %cpu time and load avgs.
+
+ The number of CPU `tick's that map to a unique `%age' can be expressed
+ by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that
+ can be calculated (assuming 32 bits) can be closely approximated using
+ the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). */
+
+#define FSHIFT 11 /* Bits to right of fixed binary point. */
+#define FSCALE (1<<FSHIFT)
+
+#endif /* sys/param.h */
diff --git a/sysdeps/mach/hurd/sysd-stdio.c b/sysdeps/mach/hurd/sysd-stdio.c
new file mode 100644
index 0000000..85dd04b
--- /dev/null
+++ b/sysdeps/mach/hurd/sysd-stdio.c
@@ -0,0 +1,237 @@
+/* Copyright (C) 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <hurd.h>
+#include <fcntl.h>
+#include <hurd/fd.h>
+
+
+/* Check ERR for wanting to generate a signal. */
+
+int __stdio_fileno (void *);
+
+static inline int
+fd_fail (struct hurd_fd *fd, error_t err)
+{
+ int signo = _hurd_fd_error_signal (err);
+ if (signo)
+ _hurd_raise_signal (NULL, signo, __stdio_fileno (fd), err);
+ errno = err;
+ return -1;
+}
+
+
+/* Read up to N chars into BUF from COOKIE.
+ Return how many chars were read, 0 for EOF or -1 for error. */
+ssize_t
+DEFUN(__stdio_read, (cookie, buf, n),
+ PTR cookie AND register char *buf AND size_t n)
+{
+ error_t err;
+ struct hurd_fd *fd = cookie;
+
+ if (! fd)
+ return __hurd_fail (EBADF);
+
+ if (err = _hurd_fd_read (fd, buf, &n))
+ return fd_fail (fd, err);
+
+ return n;
+}
+
+/* Write up to N chars from BUF to COOKIE.
+ Return how many chars were written or -1 for error. */
+ssize_t
+DEFUN(__stdio_write, (cookie, buf, n),
+ PTR cookie AND register CONST char *buf AND size_t n)
+{
+ error_t err;
+ size_t wrote, nleft;
+ struct hurd_fd *fd = cookie;
+
+ if (! fd)
+ return __hurd_fail (EBADF);
+
+ nleft = n;
+ do
+ {
+ wrote = nleft;
+ if (err = _hurd_fd_write (fd, buf, &wrote))
+ return fd_fail (fd, err);
+ buf += wrote;
+ nleft -= wrote;
+ } while (nleft > 0);
+
+ return wrote;
+}
+
+/* Move COOKIE's file position *POS bytes, according to WHENCE.
+ The current file position is stored in *POS.
+ Returns zero if successful, nonzero if not. */
+int
+DEFUN(__stdio_seek, (cookie, pos, whence),
+ PTR cookie AND fpos_t *pos AND int whence)
+{
+ error_t err;
+ struct hurd_fd *fd = cookie;
+ if (! fd)
+ return __hurd_fail (EBADF);
+ err = HURD_FD_PORT_USE (fd, __io_seek (port, *pos, whence, pos));
+ return err ? fd_fail (fd, err) : 0;
+}
+
+/* Close the file associated with COOKIE.
+ Return 0 for success or -1 for failure. */
+int
+DEFUN(__stdio_close, (cookie), PTR cookie)
+{
+ error_t error = cookie ? _hurd_fd_close (cookie) : EBADF;
+ return error ? fd_fail (cookie, error) : 0;
+}
+
+
+static inline int
+modeflags (__io_mode m)
+{
+ int flags = 0;
+ if (m.__read)
+ flags |= O_READ;
+ if (m.__write)
+ flags |= O_WRITE;
+ if (m.__append)
+ flags |= O_APPEND;
+ if (m.__create)
+ flags |= O_CREAT;
+ if (m.__truncate)
+ flags |= O_TRUNC;
+ if (m.__exclusive)
+ flags |= O_EXCL;
+ return flags;
+}
+
+/* Open FILENAME with the mode in M. */
+int
+DEFUN(__stdio_open, (filename, m, cookieptr),
+ CONST char *filename AND __io_mode m AND PTR *cookieptr)
+{
+ int flags;
+ file_t port;
+ struct hurd_fd *d;
+
+ flags = modeflags (m);
+ port = __file_name_lookup (filename, flags, 0666 & ~_hurd_umask);
+ if (port == MACH_PORT_NULL)
+ return -1;
+
+ HURD_CRITICAL_BEGIN;
+ d = _hurd_alloc_fd (NULL, 0);
+ if (d != NULL)
+ {
+ _hurd_port2fd (d, port, flags);
+ __spin_unlock (&d->port.lock);
+ }
+ HURD_CRITICAL_END;
+
+ *cookieptr = d;
+ return 0;
+}
+
+
+/* Open FILENAME with the mode in M. Use the same magic cookie
+ already in *COOKIEPTR if possible, closing the old cookie with CLOSEFN. */
+int
+DEFUN(__stdio_reopen, (filename, m, cookieptr),
+ CONST char *filename AND __io_mode m AND
+ PTR *cookieptr AND __io_close_fn closefn)
+{
+ int flags;
+ file_t port;
+ struct hurd_fd *d;
+
+ if (closefn != __stdio_close)
+ {
+ /* The old cookie is Not Of The Body.
+ Just close it and do a normal open. */
+ (*closefn) (*cookieptr);
+ return __stdio_open (filename, m, cookieptr);
+ }
+
+ /* Open a new port on the file. */
+ flags = modeflags (m);
+ port = __file_name_lookup (filename, flags, 0666 & ~_hurd_umask);
+
+ /* Install the new port in the same file descriptor slot the old cookie
+ points to. If opening the file failed, PORT will be MACH_PORT_NULL
+ and installing it in the descriptor will have the effect of closing
+ the old descriptor. */
+
+ d = *cookieptr;
+ HURD_CRITICAL_BEGIN;
+ __spin_lock (&d->port.lock);
+ _hurd_port2fd (d, port, flags);
+ __spin_unlock (&d->port.lock);
+ HURD_CRITICAL_END;
+
+ return port == MACH_PORT_NULL ? -1 : 0;
+}
+
+
+/* Write a message to the error output.
+ Try hard to make it really get out. */
+void
+DEFUN(__stdio_errmsg, (msg, len), CONST char *msg AND size_t len)
+{
+ io_t server;
+ mach_msg_type_number_t wrote;
+
+ server = __getdport (2);
+ __io_write (server, msg, len, -1, &wrote);
+ __mach_port_deallocate (__mach_task_self (), server);
+}
+
+
+/* Return the POSIX.1 file descriptor associated with COOKIE,
+ or -1 for errors. If COOKIE does not relate to any POSIX.1 file
+ descriptor, this should return -1 with errno set to EOPNOTSUPP. */
+int
+DEFUN(__stdio_fileno, (cookie), PTR cookie)
+{
+ int fd;
+
+ if (! cookie)
+ return __hurd_fail (EBADF);
+
+ __mutex_lock (&_hurd_dtable_lock);
+ for (fd = 0; fd < _hurd_dtablesize; ++fd)
+ if (_hurd_dtable[fd] == cookie)
+ {
+ __mutex_unlock (&_hurd_dtable_lock);
+ return fd;
+ }
+ __mutex_unlock (&_hurd_dtable_lock);
+
+ /* This should never happen, because this function should not be
+ installed as a stream's __fileno function unless that stream's cookie
+ points to a file descriptor. */
+ errno = EGRATUITOUS;
+ return -1;
+}
diff --git a/sysdeps/mach/hurd/telldir.c b/sysdeps/mach/hurd/telldir.c
new file mode 100644
index 0000000..7ce8d1f
--- /dev/null
+++ b/sysdeps/mach/hurd/telldir.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Return the current position of DIRP. */
+off_t
+DEFUN(telldir, (dirp), DIR *dirp)
+{
+ return dirp->__entry_ptr;
+}
diff --git a/sysdeps/mach/hurd/truncate.c b/sysdeps/mach/hurd/truncate.c
new file mode 100644
index 0000000..7453bfb
--- /dev/null
+++ b/sysdeps/mach/hurd/truncate.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <hurd.h>
+#include <fcntl.h>
+
+/* Truncate FILE_NAME to LENGTH bytes. */
+int
+DEFUN(truncate, (file_name, length),
+ CONST char *file_name AND off_t length)
+{
+ error_t err;
+ file_t file = __file_name_lookup (file_name, O_WRITE, 0);
+
+ if (file == MACH_PORT_NULL)
+ return -1;
+
+ err = __file_truncate (file, length);
+ __mach_port_deallocate (__mach_task_self (), file);
+
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
diff --git a/sysdeps/mach/hurd/ttyname.c b/sysdeps/mach/hurd/ttyname.c
new file mode 100644
index 0000000..5b8be3c
--- /dev/null
+++ b/sysdeps/mach/hurd/ttyname.c
@@ -0,0 +1,38 @@
+/* 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. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/term.h>
+#include <hurd/fd.h>
+
+/* Return the pathname of the terminal FD is open on, or NULL on errors.
+ The returned storage is good only until the next call to this function. */
+char *
+ttyname (int fd)
+{
+ error_t err;
+ static char nodename[1024]; /* XXX */
+
+ nodename[0] = '\0';
+ if (err = HURD_DPORT_USE (fd, __term_get_nodename (port, nodename)))
+ return __hurd_dfail (fd, err), NULL;
+
+ return nodename;
+}
diff --git a/sysdeps/mach/hurd/umask.c b/sysdeps/mach/hurd/umask.c
new file mode 100644
index 0000000..0848dd7
--- /dev/null
+++ b/sysdeps/mach/hurd/umask.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <sys/stat.h>
+#include <hurd.h>
+
+/* Set the file creation mask to MASK, returning the old mask. */
+mode_t
+DEFUN(__umask, (mask), mode_t mask)
+{
+ mode_t omask;
+ mask &= 0777;
+ omask = _hurd_umask;
+ _hurd_umask = mask;
+ return omask;
+}
+
+weak_alias (__umask, umask)
diff --git a/sysdeps/mach/hurd/uname.c b/sysdeps/mach/hurd/uname.c
new file mode 100644
index 0000000..74d9d37
--- /dev/null
+++ b/sysdeps/mach/hurd/uname.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1992, 1993, 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. */
+
+#include <sys/utsname.h>
+#include <hurd.h>
+#include <hurd/startup.h>
+
+int
+uname (struct utsname *uname)
+{
+ error_t err;
+
+ err = __USEPORT (PROC, __proc_uname (port, uname));
+
+ return err ? __hurd_fail (err) : 0;
+}
diff --git a/sysdeps/mach/hurd/unlink.c b/sysdeps/mach/hurd/unlink.c
new file mode 100644
index 0000000..b71d7f9
--- /dev/null
+++ b/sysdeps/mach/hurd/unlink.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <hurd.h>
+
+
+/* Remove the link named NAME. */
+int
+DEFUN(__unlink, (name), CONST char *name)
+{
+ error_t err;
+ file_t dir;
+ CONST char *file;
+
+ dir = __file_name_split (name, (char **) &file);
+ if (dir == MACH_PORT_NULL)
+ return -1;
+
+ err = __dir_unlink (dir, file);
+ __mach_port_deallocate (__mach_task_self (), dir);
+
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+
+weak_alias (__unlink, unlink)
diff --git a/sysdeps/mach/hurd/utimes.c b/sysdeps/mach/hurd/utimes.c
new file mode 100644
index 0000000..f8f0425
--- /dev/null
+++ b/sysdeps/mach/hurd/utimes.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <sys/time.h>
+#include <errno.h>
+#include <stddef.h>
+#include <hurd.h>
+
+/* Change the access time of FILE to TVP[0] and
+ the modification time of FILE to TVP[1]. */
+int
+DEFUN(__utimes, (file, tvp),
+ CONST char *file AND struct timeval tvp[2])
+{
+ error_t err;
+ file_t f = __file_name_lookup (file, 0, 0);
+ if (f == MACH_PORT_NULL)
+ return -1;
+ err = __file_utimes (f,
+ *(time_value_t *) &tvp[0], *(time_value_t *) &tvp[1]);
+ __mach_port_deallocate (__mach_task_self (), f);
+ if (err)
+ return __hurd_fail (err);
+ return 0;
+}
+
+weak_alias (__utimes, utimes)
diff --git a/sysdeps/mach/hurd/wait4.c b/sysdeps/mach/hurd/wait4.c
new file mode 100644
index 0000000..61e9855
--- /dev/null
+++ b/sysdeps/mach/hurd/wait4.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <hurd.h>
+#include <hurd/port.h>
+
+pid_t
+__wait4 (pid_t pid, __WAIT_STATUS_DEFN stat_loc,
+ int options, struct rusage *usage)
+{
+ pid_t dead;
+ error_t err;
+ struct rusage ignored;
+
+ err = __USEPORT (PROC, __proc_wait (port, pid, options, stat_loc,
+ usage ?: &ignored, &dead));
+
+ return err ? (pid_t) __hurd_fail (err) : dead;
+}
+
+weak_alias (__wait4, wait4)
diff --git a/sysdeps/mach/hurd/write.c b/sysdeps/mach/hurd/write.c
new file mode 100644
index 0000000..c6c3e6c
--- /dev/null
+++ b/sysdeps/mach/hurd/write.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+
+ssize_t
+DEFUN(__write, (fd, buf, nbytes),
+ int fd AND CONST PTR buf AND size_t nbytes)
+{
+ error_t err = HURD_FD_USE (fd, _hurd_fd_write (descriptor, buf, &nbytes));
+ return err ? __hurd_dfail (fd, err) : nbytes;
+}
+
+
+
+weak_alias (__write, write)
diff --git a/sysdeps/mach/i386/machine-lock.h b/sysdeps/mach/i386/machine-lock.h
new file mode 100644
index 0000000..bdc57e0
--- /dev/null
+++ b/sysdeps/mach/i386/machine-lock.h
@@ -0,0 +1,66 @@
+/* Machine-specific definition for spin locks. i386 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. */
+
+#ifndef _MACHINE_LOCK_H
+#define _MACHINE_LOCK_H
+
+/* The type of a spin lock variable. */
+
+typedef __volatile int __spin_lock_t;
+
+/* Value to initialize `__spin_lock_t' variables to. */
+
+#define __SPIN_LOCK_INITIALIZER 0
+
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE extern __inline
+#endif
+
+/* Unlock LOCK. */
+
+_EXTERN_INLINE void
+__spin_unlock (__spin_lock_t *__lock)
+{
+ register int __unlocked;
+ __asm__ __volatile ("xchgl %0, %1"
+ : "=&r" (__unlocked), "=m" (*__lock) : "0" (0));
+}
+
+/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */
+
+_EXTERN_INLINE int
+__spin_try_lock (__spin_lock_t *__lock)
+{
+ register int __locked;
+ __asm__ __volatile ("xchgl %0, %1"
+ : "=&r" (__locked), "=m" (*__lock) : "0" (1));
+ return !__locked;
+}
+
+/* Return nonzero if LOCK is locked. */
+
+_EXTERN_INLINE int
+__spin_lock_locked (__spin_lock_t *__lock)
+{
+ return *__lock != 0;
+}
+
+
+#endif /* machine-lock.h */
diff --git a/sysdeps/mach/i386/machine-sp.h b/sysdeps/mach/i386/machine-sp.h
new file mode 100644
index 0000000..7fd1541
--- /dev/null
+++ b/sysdeps/mach/i386/machine-sp.h
@@ -0,0 +1,38 @@
+/* Machine-specific function to return the stack pointer. i386 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. */
+
+#ifndef _MACHINE_SP_H
+#define _MACHINE_SP_H
+
+/* Return the current stack pointer. */
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE extern __inline
+#endif
+
+_EXTERN_INLINE void *
+__thread_stack_pointer (void)
+{
+ void *__sp__;
+ __asm__ ("movl %%esp, %0" : "=r" (__sp__));
+ return __sp__;
+}
+
+#endif /* machine-sp.h */
+
diff --git a/sysdeps/mach/i386/syscall.S b/sysdeps/mach/i386/syscall.S
new file mode 100644
index 0000000..1e9fbb8
--- /dev/null
+++ b/sysdeps/mach/i386/syscall.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1993 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. */
+
+#include <sysdep.h>
+
+ENTRY (syscall)
+ popl %ecx /* Pop return address into %ecx. */
+ popl %eax /* Pop syscall number into %eax. */
+ pushl %ecx /* Push back return address. */
+ .byte 0x9a, 0, 0, 0, 0, 7, 0 /* lcall $7, $0 -- gas bug */
+ ret
diff --git a/sysdeps/mach/i386/sysdep.h b/sysdeps/mach/i386/sysdep.h
new file mode 100644
index 0000000..8d482a0
--- /dev/null
+++ b/sysdeps/mach/i386/sysdep.h
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#define MOVE(x,y) movl x , y
+
+#define LOSE asm volatile ("hlt")
+
+#define SNARF_ARGS(argc, argv, envp) \
+ do \
+ { \
+ int *entry_sp; \
+ register char **p; \
+ \
+ asm ("leal 4(%%ebp), %0" : "=r" (entry_sp)); \
+ \
+ argc = *entry_sp; \
+ argv = (char **) (entry_sp + 1); \
+ p = argv; \
+ while (*p++ != NULL) \
+ ; \
+ if (p >= (char **) argv[0]) \
+ --p; \
+ envp = p; \
+ } while (0)
+
+#define CALL_WITH_SP(fn, sp) \
+ asm volatile ("movl %0, %%esp; jmp %1" : : \
+ "g" (sp), "m" (*(long int *) (fn)) : "%esp")
+
+#define STACK_GROWTH_DOWN
+
+#include_next <sysdep.h>
diff --git a/sysdeps/mach/i386/thread_state.h b/sysdeps/mach/i386/thread_state.h
new file mode 100644
index 0000000..89779b6
--- /dev/null
+++ b/sysdeps/mach/i386/thread_state.h
@@ -0,0 +1,38 @@
+/* Mach thread state definitions for machine-independent code. i386 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. */
+
+#include <mach/machine/thread_status.h>
+
+#define MACHINE_THREAD_STATE_FLAVOR i386_THREAD_STATE
+#define MACHINE_THREAD_STATE_COUNT i386_THREAD_STATE_COUNT
+
+#define machine_thread_state i386_thread_state
+
+#define PC eip
+#define SP uesp
+#define SYSRETURN eax
+
+struct machine_thread_all_state
+ {
+ int set; /* Mask of bits (1 << FLAVOR). */
+ struct i386_thread_state basic;
+ struct i386_float_state fpu;
+ };
+
+#include_next <thread_state.h>
diff --git a/sysdeps/mach/mips/Dist b/sysdeps/mach/mips/Dist
new file mode 100644
index 0000000..f2699bf
--- /dev/null
+++ b/sysdeps/mach/mips/Dist
@@ -0,0 +1 @@
+cacheflush.c
diff --git a/sysdeps/mach/mips/Makefile b/sysdeps/mach/mips/Makefile
new file mode 100644
index 0000000..a890ae7
--- /dev/null
+++ b/sysdeps/mach/mips/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),gnulib)
+sysdep_routines += cacheflush
+endif
diff --git a/sysdeps/mach/mips/cacheflush.c b/sysdeps/mach/mips/cacheflush.c
new file mode 100644
index 0000000..5325e6f
--- /dev/null
+++ b/sysdeps/mach/mips/cacheflush.c
@@ -0,0 +1,44 @@
+/* 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.
+
+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. */
+
+#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)
+{
+ vm_machine_attribute_val_t val;
+
+ switch (flag)
+ {
+ case 0: /* ? */
+ val = MATTR_VAL_DCACHE_FLUSH;
+ case 1: /* This is the only value GCC uses. */
+ val = MATTR_VAL_ICACHE_FLUSH;
+ break;
+ default:
+ val = MATTR_VAL_CACHE_FLUSH;
+ }
+
+ __vm_machine_attribute (__mach_task_self (),
+ (vm_address_t) addr, size,
+ MATTR_CACHE,
+ &val);
+}
diff --git a/sysdeps/mach/mips/machine-lock.h b/sysdeps/mach/mips/machine-lock.h
new file mode 100644
index 0000000..628aae4
--- /dev/null
+++ b/sysdeps/mach/mips/machine-lock.h
@@ -0,0 +1,73 @@
+/* Machine-specific definition for spin locks. 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. */
+
+#ifndef _MACHINE_LOCK_H
+#define _MACHINE_LOCK_H
+
+/* The type of a spin lock variable. */
+
+typedef __volatile int __spin_lock_t;
+
+/* Value to initialize `__spin_lock_t' variables to. */
+
+#define __SPIN_LOCK_INITIALIZER 0
+
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE extern __inline
+#endif
+
+/* Unlock LOCK. */
+
+_EXTERN_INLINE void
+__spin_unlock (__spin_lock_t *__lock)
+{
+ *__lock = 0;
+}
+
+/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */
+
+_EXTERN_INLINE int
+__spin_try_lock (register __spin_lock_t *__lock)
+{
+ register 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));
+#else
+ /* Use the Mach microkernel's emulated TAS pseudo-instruction. */
+ register int __rtn __asm__ ("a0");
+ __asm__ __volatile (".word 0xf ! %0 " : "=r" (__rtn) : "0" (__lock));
+#endif
+ __asm__ __volatile (".set reorder");
+ return __rtn ^ (int) __lock;
+}
+
+/* Return nonzero if LOCK is locked. */
+
+_EXTERN_INLINE int
+__spin_lock_locked (__spin_lock_t *__lock)
+{
+ return *__lock != 0;
+}
+
+
+#endif /* machine-lock.h */
diff --git a/sysdeps/mach/mips/machine-sp.h b/sysdeps/mach/mips/machine-sp.h
new file mode 100644
index 0000000..7406658
--- /dev/null
+++ b/sysdeps/mach/mips/machine-sp.h
@@ -0,0 +1,38 @@
+/* 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. */
+
+#ifndef _MACHINE_SP_H
+#define _MACHINE_SP_H
+
+/* Return the current stack pointer. */
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE extern __inline
+#endif
+
+_EXTERN_INLINE void *
+__thread_stack_pointer (void)
+{
+ void *__sp__;
+ __asm__ ("move %0,$29" : "=r" (__sp__));
+ return __sp__;
+}
+
+#endif /* machine-sp.h */
+
diff --git a/sysdeps/mach/mips/syscall.S b/sysdeps/mach/mips/syscall.S
new file mode 100644
index 0000000..bf56b40
--- /dev/null
+++ b/sysdeps/mach/mips/syscall.S
@@ -0,0 +1,37 @@
+/* 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. */
+
+#include <sysdep.h>
+
+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)
+ 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
new file mode 100644
index 0000000..7609be5
--- /dev/null
+++ b/sysdeps/mach/mips/sysdep.h
@@ -0,0 +1,69 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#define MOVE(x,y) move y , x
+
+#if 0
+#define LOSE asm volatile ("1: b 1b")
+#endif
+
+#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; \
+ while (*p++ != NULL) \
+ ; \
+ if (p >= (char **) argv[0]) \
+ --p; \
+ envp = p; \
+ } while (0)
+
+#define CALL_WITH_SP(fn, sp) \
+ ({ register int __fn = fn, __sp = (int) sp; \
+ asm volatile ("move $sp,%0; j %1" : : "r" (__sp), "r" (__fn));})
+
+#define STACK_GROWTH_DOWN
+
+#ifdef P40
+#include <syscall.h>
+
+#define SYSCALL(name, args) \
+ .globl syscall_error; \
+ kernel_trap(name,SYS_##name,args); \
+ beq $1,$0,1f; \
+ j syscall_error; \
+1:
+
+#define SYSCALL__(name, args) \
+ .globl syscall_error; \
+ kernel_trap(__##name,SYS_##name,args); \
+ beq $1,$0,1f; \
+ j syscall_error; \
+1:
+
+#define ret j ra; nop
+#endif
+
+#include_next <sysdep.h>
diff --git a/sysdeps/mach/mips/thread_state.h b/sysdeps/mach/mips/thread_state.h
new file mode 100644
index 0000000..f4f4b42
--- /dev/null
+++ b/sysdeps/mach/mips/thread_state.h
@@ -0,0 +1,37 @@
+/* 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.
+
+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. */
+
+#define MACHINE_THREAD_STATE_FLAVOR MIPS_THREAD_STATE
+#define MACHINE_THREAD_STATE_COUNT MIPS_THREAD_STATE_COUNT
+
+#define machine_thread_state mips_thread_state
+
+#define PC pc
+#define SP r29
+#define SYSRETURN r2
+
+struct machine_thread_all_state
+ {
+ int set; /* Mask of bits (1 << FLAVOR). */
+ struct mips_thread_state basic;
+ struct mips_exc_state exc;
+ struct mips_float_state fpu;
+ };
+
+#include_next <thread_state.h>
diff --git a/sysdeps/mach/mprotect.c b/sysdeps/mach/mprotect.c
new file mode 100644
index 0000000..5f1dbe8
--- /dev/null
+++ b/sysdeps/mach/mprotect.c
@@ -0,0 +1,50 @@
+/* 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. */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <mach.h>
+
+/* Change the memory protection of the region starting at ADDR and
+ extending LEN bytes to PROT. Returns 0 if successful, -1 for errors
+ (and sets errno). */
+
+int
+mprotect (caddr_t addr, size_t len, int prot)
+{
+ kern_return_t err;
+ vm_prot_t vmprot;
+
+ vmprot = VM_PROT_NONE;
+ if (prot & PROT_READ)
+ vmprot |= VM_PROT_READ;
+ if (prot & PROT_WRITE)
+ vmprot |= VM_PROT_WRITE;
+ if (prot & PROT_EXEC)
+ vmprot |= VM_PROT_EXECUTE;
+
+ if (err = __vm_protect (__mach_task_self (),
+ (vm_address_t) addr, (vm_size_t) len,
+ 0, vmprot))
+ {
+ errno = err;
+ return -1;
+ }
+ return 0;
+}
diff --git a/sysdeps/mach/munmap.c b/sysdeps/mach/munmap.c
new file mode 100644
index 0000000..5ca11298
--- /dev/null
+++ b/sysdeps/mach/munmap.c
@@ -0,0 +1,39 @@
+/* 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. */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <mach.h>
+
+/* Deallocate any mapping for the region starting at ADDR and extending LEN
+ bytes. Returns 0 if successful, -1 for errors (and sets errno). */
+
+int
+munmap (caddr_t addr, size_t len)
+{
+ kern_return_t err;
+ if (err = __vm_deallocate (__mach_task_self (),
+ (vm_address_t) addr, (vm_size_t) len))
+ {
+ errno = err;
+ return -1;
+ }
+ return 0;
+}
+
diff --git a/sysdeps/mach/sleep.c b/sysdeps/mach/sleep.c
new file mode 100644
index 0000000..0e613d3
--- /dev/null
+++ b/sysdeps/mach/sleep.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <signal.h>
+#include <time.h>
+#include <unistd.h>
+#include <mach.h>
+
+/* Make the process sleep for SECONDS seconds, or until a signal arrives
+ and is not ignored. The function returns the number of seconds less
+ than SECONDS which it actually slept (zero if it slept the full time).
+ There is no return value to indicate error, but if `sleep' returns
+ SECONDS, it probably didn't work. */
+unsigned int
+DEFUN(sleep, (seconds), unsigned int seconds)
+{
+ time_t before, after;
+ mach_port_t recv;
+
+ recv = __mach_reply_port ();
+
+ before = time ((time_t *) NULL);
+ (void) __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT,
+ 0, 0, recv, seconds * 1000, MACH_PORT_NULL);
+ after = time ((time_t *) NULL);
+ __mach_port_destroy (__mach_task_self (), recv);
+
+ return seconds - (after - before);
+}
diff --git a/sysdeps/mach/start.c b/sysdeps/mach/start.c
new file mode 100644
index 0000000..26abc23
--- /dev/null
+++ b/sysdeps/mach/start.c
@@ -0,0 +1,89 @@
+/* Copyright (C) 1992, 1993, 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. */
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sysdep.h>
+
+#ifndef __GNUC__
+ #error This file uses GNU C extensions; you must compile with GCC.
+#endif
+
+/* The first piece of initialized data. */
+int __data_start = 0;
+
+volatile int errno;
+
+#ifndef HAVE_GNU_LD
+#define __environ environ
+#endif
+char **__environ;
+
+extern void __mach_init (void);
+extern void __libc_init (int argc, char **argv, char **envp);
+extern int main (int argc, char **argv, char **envp);
+
+/* These are uninitialized common definitions so they will be zero
+ by default. If the user links in C threads, that will provide initialized
+ definitions that override these. */
+void *(*_cthread_init_routine) (void); /* Returns new SP to use. */
+void (*_cthread_exit_routine) (int status);
+
+
+/* These are for communication from _start to start1,
+ where we cannot use the stack for anything. */
+static int start_argc;
+static char **start_argv;
+
+/* _start calls this on the new stack. */
+static volatile void
+start1 (void)
+{
+ __libc_init (start_argc, start_argv, __environ);
+
+ (_cthread_exit_routine != NULL ? *_cthread_exit_routine : exit)
+ (main (start_argc, start_argv, __environ));
+
+ /* Should never get here. */
+ LOSE;
+}
+
+#ifndef START_ARGS
+#define START_ARGS void
+#ifdef START_MACHDEP
+START_MACHDEP
+#define _start _start0
+#endif
+
+void
+_start (START_ARGS)
+{
+ SNARF_ARGS (start_argc, start_argv, __environ);
+
+ __mach_init ();
+
+ if (_cthread_init_routine != NULL)
+ CALL_WITH_SP (start1, (*_cthread_init_routine) ());
+ else
+ start1 ();
+
+ /* Should never get here. */
+ LOSE;
+}
diff --git a/sysdeps/mach/sys/reboot.h b/sysdeps/mach/sys/reboot.h
new file mode 100644
index 0000000..6435fea
--- /dev/null
+++ b/sysdeps/mach/sys/reboot.h
@@ -0,0 +1,153 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1993,1991,1990 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * HISTORY
+ * $Log$
+ * Revision 1.1 1993/08/03 22:25:15 roland
+ * entered into RCS
+ *
+ * Revision 1.1 1993/08/03 22:25:15 roland
+ * entered into RCS
+ *
+ * Revision 2.8 93/03/11 13:46:40 danner
+ * u_long -> u_int.
+ * [93/03/09 danner]
+ *
+ * Revision 2.7 92/05/21 17:25:11 jfriedl
+ * Appended 'U' to constants that would otherwise be signed.
+ * [92/05/16 jfriedl]
+ *
+ * Revision 2.6 91/06/19 11:59:44 rvb
+ * Second byte of boothowto is flags for "startup" program.
+ * [91/06/18 rvb]
+ * Add ifndef ASSEMBLER so that vax_init.s can include it.
+ * [91/06/11 rvb]
+ *
+ * Revision 2.5 91/05/14 17:40:11 mrt
+ * Correcting copyright
+ *
+ * Revision 2.4 91/02/05 17:56:48 mrt
+ * Changed to new Mach copyright
+ * [91/02/01 17:49:12 mrt]
+ *
+ * Revision 2.3 90/08/27 22:12:56 dbg
+ * Added definitions used by Mach Kernel: RB_DEBUGGER, RB_UNIPROC,
+ * RB_NOBOOTRC, RB_ALTBOOT. Moved RB_KDB to 0x04 (Mach value).
+ * Removed RB_RDONLY, RB_DUMP, RB_NOSYNC.
+ * [90/08/14 dbg]
+ *
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * @(#)reboot.h 7.5 (Berkeley) 6/27/88
+ */
+
+#ifndef _SYS_REBOOT_H_
+#define _SYS_REBOOT_H_
+
+/*
+ * Arguments to reboot system call.
+ * These are converted to switches, and passed to startup program,
+ * and on to init.
+ */
+#define RB_AUTOBOOT 0 /* flags for system auto-booting itself */
+
+#define RB_ASKNAME 0x01 /* -a: ask for file name to reboot from */
+#define RB_SINGLE 0x02 /* -s: reboot to single user only */
+#define RB_KDB 0x04 /* -d: kernel debugger symbols loaded */
+#define RB_HALT 0x08 /* -h: enter KDB at bootup */
+ /* for host_reboot(): don't reboot,
+ just halt */
+#define RB_INITNAME 0x10 /* -i: name given for /etc/init (unused) */
+#define RB_DFLTROOT 0x20 /* use compiled-in rootdev */
+#define RB_NOBOOTRC 0x20 /* -b: don't run /etc/rc.boot */
+#define RB_ALTBOOT 0x40 /* use /boot.old vs /boot */
+#define RB_UNIPROC 0x80 /* -u: start only one processor */
+
+#define RB_SHIFT 8 /* second byte is for ux */
+
+#define RB_DEBUGGER 0x1000 /* for host_reboot(): enter kernel
+ debugger from user level */
+
+/*
+ * Constants for converting boot-style device number to type,
+ * adaptor (uba, mba, etc), unit number and partition number.
+ * Type (== major device number) is in the low byte
+ * for backward compatibility. Except for that of the "magic
+ * number", each mask applies to the shifted value.
+ * Format:
+ * (4) (4) (4) (4) (8) (8)
+ * --------------------------------
+ * |MA | AD| CT| UN| PART | TYPE |
+ * --------------------------------
+ */
+#define B_ADAPTORSHIFT 24
+#define B_ADAPTORMASK 0x0f
+#define B_ADAPTOR(val) (((val) >> B_ADAPTORSHIFT) & B_ADAPTORMASK)
+#define B_CONTROLLERSHIFT 20
+#define B_CONTROLLERMASK 0xf
+#define B_CONTROLLER(val) (((val)>>B_CONTROLLERSHIFT) & B_CONTROLLERMASK)
+#define B_UNITSHIFT 16
+#define B_UNITMASK 0xf
+#define B_UNIT(val) (((val) >> B_UNITSHIFT) & B_UNITMASK)
+#define B_PARTITIONSHIFT 8
+#define B_PARTITIONMASK 0xff
+#define B_PARTITION(val) (((val) >> B_PARTITIONSHIFT) & B_PARTITIONMASK)
+#define B_TYPESHIFT 0
+#define B_TYPEMASK 0xff
+#define B_TYPE(val) (((val) >> B_TYPESHIFT) & B_TYPEMASK)
+
+#define B_MAGICMASK ((u_int)0xf0000000U)
+#define B_DEVMAGIC ((u_int)0xa0000000U)
+
+#define MAKEBOOTDEV(type, adaptor, controller, unit, partition) \
+ (((type) << B_TYPESHIFT) | ((adaptor) << B_ADAPTORSHIFT) | \
+ ((controller) << B_CONTROLLERSHIFT) | ((unit) << B_UNITSHIFT) | \
+ ((partition) << B_PARTITIONSHIFT) | B_DEVMAGIC)
+
+
+#ifdef KERNEL
+#ifndef ASSEMBLER
+extern int boothowto;
+#endif ASSEMBLER
+#endif
+
+#endif /* _SYS_REBOOT_H_ */
diff --git a/sysdeps/mach/syscall.h b/sysdeps/mach/syscall.h
new file mode 100644
index 0000000..6e4ed4d
--- /dev/null
+++ b/sysdeps/mach/syscall.h
@@ -0,0 +1 @@
+/* The Mach syscalls are in <mach/syscall_sw.h>. */
diff --git a/sysdeps/mach/sysdep.h b/sysdeps/mach/sysdep.h
new file mode 100644
index 0000000..9a8dbd5
--- /dev/null
+++ b/sysdeps/mach/sysdep.h
@@ -0,0 +1,82 @@
+/* Copyright (C) 1994, 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. */
+
+#ifdef ASSEMBLER
+
+/* Get the Mach definitions of ENTRY and kernel_trap. */
+#include <mach/machine/syscall_sw.h>
+
+/* The Mach definitions assume underscores should be prepended to
+ symbol names. Redefine them to do so only when appropriate. */
+#undef EXT
+#undef LEXT
+#define EXT(x) C_SYMBOL_NAME(x)
+#define LEXT(x) C_SYMBOL_NAME(x##:)
+
+#endif
+
+/* This is invoked by things run when there is random lossage, before they
+ try to do anything else. Just to be safe, deallocate the reply port so
+ bogons arriving on it don't foul up future RPCs. */
+
+#ifndef ASSEMBLER
+#define FATAL_PREPARE_INCLUDE <mach/mig_support.h>
+#define FATAL_PREPARE __mig_dealloc_reply_port (MACH_PORT_NULL)
+#endif
+
+/* sysdeps/mach/MACHINE/sysdep.h should define the following macros. */
+
+/* Produce a text assembler label for the C global symbol NAME. */
+#ifndef ENTRY
+#define ENTRY(name) .error ENTRY not defined by sysdeps/mach/MACHINE/sysdep.h
+/* This is not used on all machines. */
+#endif
+
+/* Set variables ARGC, ARGV, and ENVP for the arguments
+ left on the stack by the microkernel. */
+#ifndef SNARF_ARGS
+#define SNARF_ARGS(argc, argv, envp)
+#error SNARF_ARGS not defined by sysdeps/mach/MACHINE/sysdep.h
+#endif
+
+/* Call the C function FN with no arguments,
+ on a stack starting at SP (as returned by *_cthread_init_routine).
+ You don't need to deal with FN returning; it shouldn't. */
+#ifndef CALL_WITH_SP
+#define CALL_WITH_SP(fn, sp)
+#error CALL_WITH_SP not defined by sysdeps/mach/MACHINE/sysdep.h
+#endif
+
+/* LOSE can be defined as the `halt' instruction or something
+ similar which will cause the process to die in a characteristic
+ way suggesting a bug. */
+#ifndef LOSE
+#define LOSE ({ volatile int zero = 0; zero / zero; })
+#endif
+
+/* One of these should be defined to specify the stack direction. */
+#if !defined (STACK_GROWTH_UP) && !defined (STACK_GROWTH_DOWN)
+#error stack direction unspecified
+#endif
+
+/* Used by some assembly code. */
+#ifdef NO_UNDERSCORES
+#define C_SYMBOL_NAME(name) name
+#else
+#define C_SYMBOL_NAME(name) _##name
+#endif
diff --git a/sysdeps/mach/thread_state.h b/sysdeps/mach/thread_state.h
new file mode 100644
index 0000000..06f168b
--- /dev/null
+++ b/sysdeps/mach/thread_state.h
@@ -0,0 +1,87 @@
+/* Generic definitions for dealing with Mach thread states.
+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. */
+
+
+/* Everything else is called `thread_state', but CMU's header file is
+ called `thread_status'. Oh boy. */
+#include <mach/thread_status.h>
+
+/* The machine-dependent thread_state.h file can either define these
+ macros, or just define PC and SP to the register names. */
+
+#ifndef MACHINE_THREAD_STATE_SET_PC
+#define MACHINE_THREAD_STATE_SET_PC(ts, pc) \
+ ((ts)->PC = (unsigned long int) (pc))
+#endif
+#ifndef MACHINE_THREAD_STATE_SET_SP
+#ifdef STACK_GROWTH_UP
+#define MACHINE_THREAD_STATE_SET_SP(ts, stack, size) \
+ ((ts)->SP = (unsigned long int) (stack))
+#else
+#define MACHINE_THREAD_STATE_SET_SP(ts, stack, size) \
+ ((ts)->SP = (unsigned long int) (stack) + (size))
+#endif
+#endif
+
+/* These functions are of use in machine-dependent signal trampoline
+ implementations. */
+
+#include <string.h> /* size_t, memcpy */
+#include <mach/mach_interface.h> /* __thread_get_state */
+
+static inline int
+machine_get_state (thread_t thread, struct machine_thread_all_state *state,
+ int flavor, void *stateptr, void *scpptr, size_t size)
+{
+ if (state->set & (1 << flavor))
+ {
+ /* Copy the saved state. */
+ memcpy (scpptr, stateptr, size);
+ return 1;
+ }
+ else
+ {
+ /* Noone asked about this flavor of state before; fetch the state
+ directly from the kernel into the sigcontext. */
+ mach_msg_type_number_t got = (size / sizeof (int));
+ return (! __thread_get_state (thread, flavor, scpptr, &got)
+ && got == (size / sizeof (int)));
+ }
+}
+
+static inline int
+machine_get_basic_state (thread_t thread,
+ struct machine_thread_all_state *state)
+{
+ mach_msg_type_number_t count;
+
+ if (state->set & (1 << MACHINE_THREAD_STATE_FLAVOR))
+ return 1;
+
+ count = MACHINE_THREAD_STATE_COUNT;
+ if (__thread_get_state (thread, MACHINE_THREAD_STATE_FLAVOR,
+ (natural_t *) &state->basic,
+ &count) != KERN_SUCCESS ||
+ count != MACHINE_THREAD_STATE_COUNT)
+ /* What kind of thread?? */
+ return 0; /* XXX */
+
+ state->set |= 1 << MACHINE_THREAD_STATE_FLAVOR;
+ return 1;
+}
diff --git a/sysdeps/mach/usleep.c b/sysdeps/mach/usleep.c
new file mode 100644
index 0000000..90d47d8
--- /dev/null
+++ b/sysdeps/mach/usleep.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <mach.h>
+#include <sys/time.h>
+
+/* Sleep USECONDS microseconds, or until a previously set timer goes off. */
+unsigned int
+DEFUN(usleep, (useconds), unsigned int useconds)
+{
+ mach_port_t recv;
+ struct timeval before, after;
+
+ recv = __mach_reply_port ();
+
+ if (__gettimeofday (&before, NULL) < 0)
+ return useconds;
+ (void) __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT,
+ 0, 0, recv, (useconds + 999) / 1000, MACH_PORT_NULL);
+ __mach_port_destroy (mach_task_self (), recv);
+ if (__gettimeofday (&after, NULL) < 0)
+ return 0;
+
+ return useconds - (((after.tv_sec - before.tv_sec) * 1000000) +
+ (after.tv_usec - before.tv_usec));
+}
diff --git a/sysdeps/mips/.cvsignore b/sysdeps/mips/.cvsignore
new file mode 100644
index 0000000..1f69fd9
--- /dev/null
+++ b/sysdeps/mips/.cvsignore
@@ -0,0 +1,4 @@
+*.gz *.Z *.tar *.tgz
+=*
+TODO COPYING* AUTHORS copyr-* copying.*
+glibc-*
diff --git a/sysdeps/mips/Dist b/sysdeps/mips/Dist
new file mode 100644
index 0000000..ad6ea03
--- /dev/null
+++ b/sysdeps/mips/Dist
@@ -0,0 +1 @@
+setjmp_aux.c
diff --git a/sysdeps/mips/Implies b/sysdeps/mips/Implies
new file mode 100644
index 0000000..60732ce
--- /dev/null
+++ b/sysdeps/mips/Implies
@@ -0,0 +1,2 @@
+# MIPS uses IEEE 754 floating point.
+ieee754
diff --git a/sysdeps/mips/Makefile b/sysdeps/mips/Makefile
new file mode 100644
index 0000000..7364141
--- /dev/null
+++ b/sysdeps/mips/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),setjmp)
+sysdep_routines := $(sysdep_routines) setjmp_aux
+endif
diff --git a/sysdeps/mips/__longjmp.c b/sysdeps/mips/__longjmp.c
new file mode 100644
index 0000000..7ea3df2
--- /dev/null
+++ b/sysdeps/mips/__longjmp.c
@@ -0,0 +1,81 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <setjmp.h>
+#include <stdlib.h>
+
+#undef __longjmp
+
+#ifndef __GNUC__
+ #error This file uses GNU C extensions; you must compile with GCC.
+#endif
+
+void
+DEFUN(__longjmp, (env, val_arg), CONST __jmp_buf env AND 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 $f20, %0" : : "m" (env[0].__fpregs[0]));
+ asm volatile ("l.d $f22, %0" : : "m" (env[0].__fpregs[1]));
+ asm volatile ("l.d $f24, %0" : : "m" (env[0].__fpregs[2]));
+ asm volatile ("l.d $f26, %0" : : "m" (env[0].__fpregs[3]));
+ asm volatile ("l.d $f28, %0" : : "m" (env[0].__fpregs[4]));
+ asm volatile ("l.d $f30, %0" : : "m" (env[0].__fpregs[5]));
+
+ /* Restore the stack pointer. */
+ asm volatile ("lw $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 ("lw $30, %0" : : "m" (env[0].__fp));
+
+ /* Get the GP. */
+ asm volatile ("lw $gp, %0" : : "m" (env[0].__gp));
+
+ /* Get the callee-saved registers. */
+ asm volatile ("lw $16, %0" : : "m" (env[0].__regs[0]));
+ asm volatile ("lw $17, %0" : : "m" (env[0].__regs[1]));
+ asm volatile ("lw $18, %0" : : "m" (env[0].__regs[2]));
+ asm volatile ("lw $19, %0" : : "m" (env[0].__regs[3]));
+ asm volatile ("lw $20, %0" : : "m" (env[0].__regs[4]));
+ asm volatile ("lw $21, %0" : : "m" (env[0].__regs[5]));
+ asm volatile ("lw $22, %0" : : "m" (env[0].__regs[6]));
+ asm volatile ("lw $23, %0" : : "m" (env[0].__regs[7]));
+
+ /* Get the PC. */
+ asm volatile ("lw $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 ("li $2, 1");
+ else
+ asm volatile ("move $2, %0" : : "r" (val));
+
+ asm volatile ("j $31");
+
+ abort ();
+}
diff --git a/sysdeps/mips/bsd-_setjmp.S b/sysdeps/mips/bsd-_setjmp.S
new file mode 100644
index 0000000..6e6844c
--- /dev/null
+++ b/sysdeps/mips/bsd-_setjmp.S
@@ -0,0 +1,28 @@
+/* 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.
+
+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 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>
+
+ENTRY (setjmp)
+ j C_SYMBOL_NAME (__sigsetjmp)
+ li a1, zero /* Pass a second argument of zero. */
diff --git a/sysdeps/mips/bsd-setjmp.S b/sysdeps/mips/bsd-setjmp.S
new file mode 100644
index 0000000..5cd090a
--- /dev/null
+++ b/sysdeps/mips/bsd-setjmp.S
@@ -0,0 +1,28 @@
+/* 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.
+
+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 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>
+
+ENTRY (setjmp)
+ j C_SYMBOL_NAME (__sigsetjmp)
+ li a1, 1 /* Pass a second argument of one. */
diff --git a/sysdeps/mips/dec/bytesex.h b/sysdeps/mips/dec/bytesex.h
new file mode 100644
index 0000000..157bc44
--- /dev/null
+++ b/sysdeps/mips/dec/bytesex.h
@@ -0,0 +1,4 @@
+/* The MIPS architecture has selectable endianness.
+ The DECstation uses little-endian mode. */
+
+#define __BYTE_ORDER __LITTLE_ENDIAN
diff --git a/sysdeps/mips/jmp_buf.h b/sysdeps/mips/jmp_buf.h
new file mode 100644
index 0000000..eed47dc
--- /dev/null
+++ b/sysdeps/mips/jmp_buf.h
@@ -0,0 +1,47 @@
+/* Define the machine-dependent type `jmp_buf'. Mips version.
+ Copyright (C) 1992, 1993 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
diff --git a/sysdeps/mips/mips64/gmp-mparam.h b/sysdeps/mips/mips64/gmp-mparam.h
new file mode 100644
index 0000000..a801b35
--- /dev/null
+++ b/sysdeps/mips/mips64/gmp-mparam.h
@@ -0,0 +1,26 @@
+/* gmp-mparam.h -- Compiler/machine parameter header file.
+
+Copyright (C) 1991, 1993, 1994 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., 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_SHORTINT 16
+#define BITS_PER_CHAR 8
diff --git a/sysdeps/mips/mipsel/bytesex.h b/sysdeps/mips/mipsel/bytesex.h
new file mode 100644
index 0000000..5da5965
--- /dev/null
+++ b/sysdeps/mips/mipsel/bytesex.h
@@ -0,0 +1,4 @@
+/* The MIPS architecture has selectable endianness.
+ This file is for a machine using little-endian mode. */
+
+#define __BYTE_ORDER __LITTLE_ENDIAN
diff --git a/sysdeps/mips/p40/bytesex.h b/sysdeps/mips/p40/bytesex.h
new file mode 100644
index 0000000..e4b0119
--- /dev/null
+++ b/sysdeps/mips/p40/bytesex.h
@@ -0,0 +1,4 @@
+/* The MIPS has selectable endianness.
+ The Japanese homebrew P40 architecture uses big-endian mode. */
+
+#define __BYTE_ORDER __BIG_ENDIAN
diff --git a/sysdeps/mips/setjmp.S b/sysdeps/mips/setjmp.S
new file mode 100644
index 0000000..b3c0247
--- /dev/null
+++ b/sysdeps/mips/setjmp.S
@@ -0,0 +1,31 @@
+/* Copyright (C) 1992, 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. */
+
+#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. */
+ENTRY (__sigsetjmp)
+ move a2, sp
+#ifdef __sgi__
+ move a3, fp
+#else
+ move a3, $fp
+#endif
+ j __sigsetjmp_aux
diff --git a/sysdeps/mips/setjmp_aux.c b/sysdeps/mips/setjmp_aux.c
new file mode 100644
index 0000000..d478e3f
--- /dev/null
+++ b/sysdeps/mips/setjmp_aux.c
@@ -0,0 +1,64 @@
+/* Copyright (C) 1992, 1994, 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. */
+
+#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 $f20, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[0]));
+ asm volatile ("s.d $f22, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[1]));
+ asm volatile ("s.d $f24, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[2]));
+ asm volatile ("s.d $f26, %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 $f30, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[5]));
+
+ /* .. and the PC; */
+ asm volatile ("sw $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 ("sw $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp));
+
+ /* .. and the callee-saved registers; */
+ asm volatile ("sw $16, %0" : : "m" (env[0].__jmpbuf[0].__regs[0]));
+ asm volatile ("sw $17, %0" : : "m" (env[0].__jmpbuf[0].__regs[1]));
+ asm volatile ("sw $18, %0" : : "m" (env[0].__jmpbuf[0].__regs[2]));
+ asm volatile ("sw $19, %0" : : "m" (env[0].__jmpbuf[0].__regs[3]));
+ asm volatile ("sw $20, %0" : : "m" (env[0].__jmpbuf[0].__regs[4]));
+ asm volatile ("sw $21, %0" : : "m" (env[0].__jmpbuf[0].__regs[5]));
+ asm volatile ("sw $22, %0" : : "m" (env[0].__jmpbuf[0].__regs[6]));
+ asm volatile ("sw $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/posix/Dist b/sysdeps/posix/Dist
new file mode 100644
index 0000000..d003c6e
--- /dev/null
+++ b/sysdeps/posix/Dist
@@ -0,0 +1 @@
+mk-stdiolim.c
diff --git a/sysdeps/posix/Makefile b/sysdeps/posix/Makefile
new file mode 100644
index 0000000..fd1b3f2
--- /dev/null
+++ b/sysdeps/posix/Makefile
@@ -0,0 +1,40 @@
+# Copyright (C) 1991, 1992, 1993, 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.
+
+$(common-objpfx)stdio_lim.h: $(common-objpfx)mk-stdiolim
+ $(dir $<)$(notdir $<) > $@-t
+ mv $@-t $@
+
+ifdef subdir
+objdir-CPPFLAGS = $(CPPFLAGS) # Already has appropriate `..'s.
+else
+objdir-CPPFLAGS = $(patsubst -I/..//%,-I/%,$(CPPFLAGS:-I%=-I../%))
+endif
+# Turn into a version that works when cd'd into $(objdir).
+cded-objdir-CPPFLAGS = $(patsubst -I$$cwd//%,-I/%,\
+ $(patsubst -I%,-I$$cwd/%,$(CPPFLAGS)))
+# $(BUILD_CFLAGS) needs to come last because it contains unwanted -Is.
+$(common-objpfx)mk-stdiolim: $(sysdep_dir)/posix/mk-stdiolim.c \
+ posix1_lim.h local_lim.h
+ cwd=`pwd`; cd $(common-objdir); \
+ $(BUILD_CC) $(cded-objdir-CPPFLAGS) $(BUILD_CFLAGS) \
+ $$cwd/$< -o $(patsubst $(common-objpfx)%,%,$@)
+
+
+common-generated := $(common-generated) stdio_lim.h mk-stdiolim
+before-compile := $(before-compile) $(common-objpfx)stdio_lim.h
diff --git a/sysdeps/posix/clock.c b/sysdeps/posix/clock.c
new file mode 100644
index 0000000..c34593b
--- /dev/null
+++ b/sysdeps/posix/clock.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <sys/times.h>
+#include <time.h>
+
+/* Return the time used by the program so far (user time + system time). */
+clock_t
+DEFUN_VOID(clock)
+{
+ struct tms buf;
+
+ if (__times(&buf) < 0)
+ return (clock_t) -1;
+
+ return ((buf.tms_utime + buf.tms_stime) * CLK_TCK * CLOCKS_PER_SEC);
+}
diff --git a/sysdeps/posix/ctermid.c b/sysdeps/posix/ctermid.c
new file mode 100644
index 0000000..8e96694
--- /dev/null
+++ b/sysdeps/posix/ctermid.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+#include <string.h>
+
+
+/* Return the name of the controlling terminal.
+ If S is not NULL, the name is copied into it (it should be at
+ least L_ctermid bytes long), otherwise a static buffer is used. */
+char *
+DEFUN(ctermid, (s), char *s)
+{
+ static char name[L_ctermid];
+
+ if (name[0] == '\0')
+ (void) strcpy(name, "/dev/tty");
+
+ if (s == NULL)
+ return(name);
+
+ return(strcpy(s, name));
+}
diff --git a/sysdeps/posix/cuserid.c b/sysdeps/posix/cuserid.c
new file mode 100644
index 0000000..b874e90
--- /dev/null
+++ b/sysdeps/posix/cuserid.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+#include <string.h>
+#include <pwd.h>
+
+extern int EXFUN(geteuid, (NOARGS));
+
+
+/* Return the username of the caller.
+ If S is not NULL, it points to a buffer of at least L_cuserid bytes
+ into which the name is copied; otherwise, a static buffer is used. */
+char *
+DEFUN(cuserid, (s), char *s)
+{
+ static char name[L_cuserid];
+ struct passwd *pwent = getpwuid(geteuid());
+
+ if (pwent == NULL)
+ {
+ if (s != NULL)
+ s[0] = '\0';
+ return NULL;
+ }
+
+ if (s == NULL)
+ s = name;
+ return strcpy(s, pwent->pw_name);
+}
diff --git a/sysdeps/posix/defs.c b/sysdeps/posix/defs.c
new file mode 100644
index 0000000..fcbaf16
--- /dev/null
+++ b/sysdeps/posix/defs.c
@@ -0,0 +1,76 @@
+/* Definitions of global stdio data structures.
+
+Copyright (C) 1991, 1993 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <unistd.h>
+
+/* This file defines all the global internal variables for stdio. */
+
+/* Standard streams. */
+#define READ 1, 0
+#define WRITE 0, 1
+#define BUFFERED 0
+#define UNBUFFERED 1
+#define stdstream(name, next, fd, readwrite, unbuffered) \
+ { \
+ _IOMAGIC, \
+ NULL, NULL, NULL, NULL, 0, \
+ (PTR) fd, \
+ { readwrite, /* ... */ }, \
+ { NULL, NULL, NULL, NULL, NULL }, \
+ { NULL, NULL }, \
+ -1, -1, \
+ (next), \
+ NULL, '\0', 0, \
+ 0, 0, unbuffered, 0, 0, 0, 0 \
+ }
+static FILE stdstreams[3] =
+ {
+ stdstream (&stdstreams[0], &stdstreams[1], STDIN_FILENO, READ, BUFFERED),
+ stdstream (&stdstreams[1], &stdstreams[2], STDOUT_FILENO, WRITE, BUFFERED),
+ stdstream (&stdstreams[2], NULL, STDERR_FILENO, WRITE, UNBUFFERED),
+ };
+FILE *stdin = &stdstreams[0];
+FILE *stdout = &stdstreams[1];
+FILE *stderr = &stdstreams[2];
+
+/* Pointer to the first stream in the list. */
+FILE *__stdio_head = &stdstreams[0];
+
+/* This function MUST be in this file!
+ This is because we want _cleanup to go into the __libc_atexit set
+ when any stdio code is used (and to use any stdio code, one must reference
+ something defined in this file), and since only local symbols can be made
+ set elements, having the set element stab entry here and _cleanup elsewhere
+ loses; and having them both elsewhere loses because there is no reference
+ to cause _cleanup to be linked in. */
+
+void
+DEFUN_VOID(_cleanup)
+{
+ (void) fclose((FILE *) NULL);
+}
+
+
+#ifdef HAVE_GNU_LD
+text_set_element(__libc_atexit, _cleanup);
+#endif
diff --git a/sysdeps/posix/dup.c b/sysdeps/posix/dup.c
new file mode 100644
index 0000000..73c5900
--- /dev/null
+++ b/sysdeps/posix/dup.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+
+/* Duplicate FD, returning a new file descriptor open on the same file. */
+int
+DEFUN(__dup, (fd), int fd)
+{
+ return fcntl(fd, F_DUPFD, 0);
+}
+
+weak_alias (__dup, dup)
diff --git a/sysdeps/posix/dup2.c b/sysdeps/posix/dup2.c
new file mode 100644
index 0000000..c0c6b2a
--- /dev/null
+++ b/sysdeps/posix/dup2.c
@@ -0,0 +1,59 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <unistd.h>
+
+
+/* Duplicate FD to FD2, closing the old FD2 and making FD2 be
+ open the same file as FD is. Return FD2 or -1. */
+int
+DEFUN(__dup2, (fd, fd2), int fd AND int fd2)
+{
+ int save;
+
+ if (fd2 < 0
+#ifdef OPEN_MAX
+ || fd2 >= OPEN_MAX
+#endif
+)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ /* Check if FD is kosher. */
+ if (fcntl (fd, F_GETFL) < 0)
+ return -1;
+
+ if (fd == fd2)
+ return fd2;
+
+ /* This is not atomic. */
+
+ save = errno;
+ (void) close (fd2);
+ errno = save;
+
+ return fcntl (fd, F_DUPFD, fd2);
+}
+
+weak_alias (__dup2, dup2)
diff --git a/sysdeps/posix/fdopen.c b/sysdeps/posix/fdopen.c
new file mode 100644
index 0000000..ad746ec
--- /dev/null
+++ b/sysdeps/posix/fdopen.c
@@ -0,0 +1,72 @@
+/* Copyright (C) 1991, 1992, 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+/* Defined in fopen.c. */
+extern int EXFUN(__getmode, (CONST char *mode, __io_mode *mptr));
+
+/* Open a new stream on a given system file descriptor. */
+FILE *
+DEFUN(fdopen, (fd, mode), int fd AND CONST char *mode)
+{
+ register FILE *stream;
+ __io_mode m;
+ int dflags;
+
+ if (!__getmode (mode, &m))
+ return NULL;
+
+ /* Verify the FD is valid and allows the access MODE specifies. */
+
+ dflags = __fcntl (fd, F_GETFL);
+ if (dflags == -1)
+ /* FD was invalid; fcntl has already set errno. */
+ return NULL;
+
+ /* Check the access mode. */
+ switch (dflags & O_ACCMODE)
+ {
+ case O_RDONLY:
+ if (!m.__read)
+ {
+ errno = EBADF;
+ return NULL;
+ }
+ break;
+ case O_WRONLY:
+ if (!m.__write)
+ {
+ errno = EBADF;
+ return NULL;
+ }
+ break;
+ }
+
+ stream = __newstream ();
+ if (stream == NULL)
+ return NULL;
+
+ stream->__cookie = (PTR) fd;
+ stream->__mode = m;
+
+ return stream;
+}
diff --git a/sysdeps/posix/flock.c b/sysdeps/posix/flock.c
new file mode 100644
index 0000000..b4c9fc3
--- /dev/null
+++ b/sysdeps/posix/flock.c
@@ -0,0 +1,58 @@
+/* Copyright (C) 1992, 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 file implements the `flock' function in terms of the POSIX.1 `fcntl'
+ locking mechanism. In 4BSD, these are two incompatible locking mechanisms,
+ perhaps with different semantics? */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/file.h>
+
+/* Apply or remove an advisory lock, according to OPERATION,
+ on the file FD refers to. */
+int
+DEFUN(__flock, (fd, operation), int fd AND int operation)
+{
+ struct flock lbuf;
+
+ switch (operation & ~LOCK_NB)
+ {
+ case LOCK_SH:
+ lbuf.l_type = F_RDLCK;
+ break;
+ case LOCK_EX:
+ lbuf.l_type = F_WRLCK;
+ break;
+ case LOCK_UN:
+ lbuf.l_type = F_UNLCK;
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+ lbuf.l_whence = SEEK_SET;
+ lbuf.l_start = lbuf.l_len = 0L; /* Lock the whole file. */
+
+ return __fcntl (fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &lbuf);
+}
+
+weak_alias (__flock, flock)
diff --git a/sysdeps/posix/fpathconf.c b/sysdeps/posix/fpathconf.c
new file mode 100644
index 0000000..b339990
--- /dev/null
+++ b/sysdeps/posix/fpathconf.c
@@ -0,0 +1,116 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <limits.h>
+
+
+/* Get file-specific information about descriptor FD. */
+long int
+DEFUN(__fpathconf, (fd, name), int fd AND int name)
+{
+ if (fd < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ switch (name)
+ {
+ default:
+ errno = EINVAL;
+ return -1;
+
+ case _PC_LINK_MAX:
+#ifdef LINK_MAX
+ return LINK_MAX;
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+
+ case _PC_MAX_CANON:
+#ifdef MAX_CANON
+ return MAX_CANON;
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+
+ case _PC_MAX_INPUT:
+#ifdef MAX_INPUT
+ return MAX_INPUT;
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+
+ case _PC_NAME_MAX:
+#ifdef NAME_MAX
+ return NAME_MAX;
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+
+ case _PC_PATH_MAX:
+#ifdef PATH_MAX
+ return PATH_MAX;
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+
+ case _PC_PIPE_BUF:
+#ifdef PIPE_BUF
+ return PIPE_BUF;
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+
+ case _PC_CHOWN_RESTRICTED:
+#ifdef _POSIX_CHOWN_RESTRICTED
+ return _POSIX_CHOWN_RESTRICTED;
+#else
+ return -1;
+#endif
+
+ case _PC_NO_TRUNC:
+#ifdef _POSIX_NO_TRUNC
+ return _POSIX_NO_TRUNC;
+#else
+ return -1;
+#endif
+
+ case _PC_VDISABLE:
+#ifdef _POSIX_VDISABLE
+ return _POSIX_VDISABLE;
+#else
+ return -1;
+#endif
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+weak_alias (__fpathconf, fpathconf)
diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c
new file mode 100644
index 0000000..7b992a9
--- /dev/null
+++ b/sysdeps/posix/getcwd.c
@@ -0,0 +1,366 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+/* Wants:
+ AC_STDC_HEADERS
+ AC_DIR_HEADER
+ AC_UNISTD_H
+ AC_MEMORY_H
+ AC_CONST
+ AC_ALLOCA
+ */
+
+/* AIX requires this to be the first thing in the file. */
+#if defined (_AIX) && !defined (__GNUC__)
+ #pragma alloca
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#ifdef STDC_HEADERS
+#include <stddef.h>
+#endif
+
+#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS)
+extern int errno;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#if defined (USGr3) && !defined (DIRENT)
+#define DIRENT
+#endif /* USGr3 */
+#if defined (Xenix) && !defined (SYSNDIR)
+#define SYSNDIR
+#endif /* Xenix */
+
+#if defined (POSIX) || defined (DIRENT) || defined (__GNU_LIBRARY__)
+#include <dirent.h>
+#ifndef __GNU_LIBRARY__
+#define D_NAMLEN(d) strlen((d)->d_name)
+#else
+#define HAVE_D_NAMLEN
+#define D_NAMLEN(d) ((d)->d_namlen)
+#endif
+#else /* not POSIX or DIRENT */
+#define dirent direct
+#define D_NAMLEN(d) ((d)->d_namlen)
+#define HAVE_D_NAMLEN
+#if defined (USG) && !defined (sgi)
+#if defined (SYSNDIR)
+#include <sys/ndir.h>
+#else /* Not SYSNDIR */
+#include "ndir.h"
+#endif /* SYSNDIR */
+#else /* not USG */
+#include <sys/dir.h>
+#endif /* USG */
+#endif /* POSIX or DIRENT or __GNU_LIBRARY__ */
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__) \
+ || defined (POSIX))
+#include <stdlib.h>
+#include <string.h>
+#define ANSI_STRING
+#else /* No standard headers. */
+
+#ifdef USG
+
+#include <string.h>
+#ifdef NEED_MEMORY_H
+#include <memory.h>
+#endif
+#define ANSI_STRING
+
+#else /* Not USG. */
+
+#ifdef NeXT
+
+#include <string.h>
+
+#else /* Not NeXT. */
+
+#include <strings.h>
+
+#ifndef bcmp
+extern int bcmp ();
+#endif
+#ifndef bzero
+extern void bzero ();
+#endif
+#ifndef bcopy
+extern void bcopy ();
+#endif
+
+#endif /* NeXT. */
+
+#endif /* USG. */
+
+extern char *malloc (), *realloc ();
+extern void free ();
+
+#endif /* Standard headers. */
+
+#ifndef ANSI_STRING
+#define memcpy(d, s, n) bcopy((s), (d), (n))
+#define memmove memcpy
+#endif /* Not ANSI_STRING. */
+
+#if !defined(__alloca) && !defined(__GNU_LIBRARY__)
+
+#ifdef __GNUC__
+#undef alloca
+#define alloca(n) __builtin_alloca (n)
+#else /* Not GCC. */
+#if defined (sparc) || defined (HAVE_ALLOCA_H)
+#include <alloca.h>
+#else /* Not sparc or HAVE_ALLOCA_H. */
+#ifndef _AIX
+extern char *alloca ();
+#endif /* Not _AIX. */
+#endif /* sparc or HAVE_ALLOCA_H. */
+#endif /* GCC. */
+
+#define __alloca alloca
+
+#endif
+
+#if (defined (HAVE_LIMITS_H) || defined (STDC_HEADERS) || \
+ defined (__GNU_LIBRARY__))
+#include <limits.h>
+#else
+#include <sys/param.h>
+#endif
+
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+
+#ifndef STDC_HEADERS
+#undef size_t
+#define size_t unsigned int
+#endif
+
+#if !__STDC__ && !defined (const)
+#define const
+#endif
+
+#ifndef __GNU_LIBRARY__
+#define __lstat stat
+#endif
+
+/* Get the pathname of the current working directory, and put it in SIZE
+ bytes of BUF. Returns NULL if the directory couldn't be determined or
+ SIZE was too small. If successful, returns BUF. In GNU, if BUF is
+ NULL, an array is allocated with `malloc'; the array is SIZE bytes long,
+ unless SIZE <= 0, in which case it is as big as necessary. */
+
+char *
+getcwd (buf, size)
+ char *buf;
+ size_t size;
+{
+ static const char dots[]
+ = "../../../../../../../../../../../../../../../../../../../../../../../\
+../../../../../../../../../../../../../../../../../../../../../../../../../../\
+../../../../../../../../../../../../../../../../../../../../../../../../../..";
+ const char *dotp, *dotlist;
+ size_t dotsize;
+ dev_t rootdev, thisdev;
+ ino_t rootino, thisino;
+ char *path;
+ register char *pathp;
+ struct stat st;
+
+ if (size == 0)
+ {
+ if (buf != NULL)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ size = PATH_MAX + 1;
+ }
+
+ if (buf != NULL)
+ path = buf;
+ else
+ {
+ path = malloc (size);
+ if (path == NULL)
+ return NULL;
+ }
+
+ pathp = path + size;
+ *--pathp = '\0';
+
+ if (__lstat (".", &st) < 0)
+ return NULL;
+ thisdev = st.st_dev;
+ thisino = st.st_ino;
+
+ if (__lstat ("/", &st) < 0)
+ return NULL;
+ rootdev = st.st_dev;
+ rootino = st.st_ino;
+
+ dotsize = sizeof (dots) - 1;
+ dotp = &dots[sizeof (dots)];
+ dotlist = dots;
+ while (!(thisdev == rootdev && thisino == rootino))
+ {
+ register DIR *dirstream;
+ register struct dirent *d;
+ dev_t dotdev;
+ ino_t dotino;
+ char mount_point;
+
+ /* Look at the parent directory. */
+ if (dotp == dotlist)
+ {
+ /* My, what a deep directory tree you have, Grandma. */
+ char *new;
+ if (dotlist == dots)
+ {
+ new = malloc (dotsize * 2 + 1);
+ if (new == NULL)
+ return NULL;
+ memcpy (new, dots, dotsize);
+ }
+ else
+ {
+ new = realloc ((__ptr_t) dotlist, dotsize * 2 + 1);
+ if (new == NULL)
+ goto lose;
+ }
+ memcpy (&new[dotsize], new, dotsize);
+ dotp = &new[dotsize];
+ dotsize *= 2;
+ new[dotsize] = '\0';
+ dotlist = new;
+ }
+
+ dotp -= 3;
+
+ /* Figure out if this directory is a mount point. */
+ if (__lstat (dotp, &st) < 0)
+ goto lose;
+ dotdev = st.st_dev;
+ dotino = st.st_ino;
+ mount_point = dotdev != thisdev;
+
+ /* Search for the last directory. */
+ dirstream = opendir (dotp);
+ if (dirstream == NULL)
+ goto lose;
+ while ((d = readdir (dirstream)) != NULL)
+ {
+ if (d->d_name[0] == '.' &&
+ (d->d_namlen == 1 || (d->d_namlen == 2 && d->d_name[1] == '.')))
+ continue;
+ if (mount_point || d->d_ino == thisino)
+ {
+ char *name = __alloca (dotlist + dotsize - dotp +
+ 1 + d->d_namlen + 1);
+ memcpy (name, dotp, dotlist + dotsize - dotp);
+ name[dotlist + dotsize - dotp] = '/';
+ memcpy (&name[dotlist + dotsize - dotp + 1],
+ d->d_name, d->d_namlen + 1);
+ if (__lstat (name, &st) < 0)
+ {
+ int save = errno;
+ (void) closedir (dirstream);
+ errno = save;
+ goto lose;
+ }
+ if (st.st_dev == thisdev && st.st_ino == thisino)
+ break;
+ }
+ }
+ if (d == NULL)
+ {
+ int save = errno;
+ (void) closedir (dirstream);
+ errno = save;
+ goto lose;
+ }
+ else
+ {
+ if (pathp - path < d->d_namlen + 1)
+ {
+ if (buf != NULL)
+ {
+ errno = ERANGE;
+ return NULL;
+ }
+ else
+ {
+ size *= 2;
+ buf = realloc (path, size);
+ if (buf == NULL)
+ {
+ (void) closedir (dirstream);
+ free (path);
+ errno = ENOMEM; /* closedir might have changed it. */
+ return NULL;
+ }
+ pathp = &buf[pathp - path];
+ path = buf;
+ }
+ }
+ pathp -= d->d_namlen;
+ (void) memcpy (pathp, d->d_name, d->d_namlen);
+ *--pathp = '/';
+ (void) closedir (dirstream);
+ }
+
+ thisdev = dotdev;
+ thisino = dotino;
+ }
+
+ if (pathp == &path[size - 1])
+ *--pathp = '/';
+
+ if (dotlist != dots)
+ free ((__ptr_t) dotlist);
+
+ memmove (path, pathp, path + size - pathp);
+ return path;
+
+ lose:
+ if (dotlist != dots)
+ free ((__ptr_t) dotlist);
+ return NULL;
+}
diff --git a/sysdeps/posix/getdtsz.c b/sysdeps/posix/getdtsz.c
new file mode 100644
index 0000000..2080dc7
--- /dev/null
+++ b/sysdeps/posix/getdtsz.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+
+extern long int EXFUN(__sysconf, (int));
+
+/* Return the maximum number of file descriptors
+ the current process could possibly have. */
+int
+DEFUN_VOID(__getdtablesize)
+{
+ return __sysconf (_SC_OPEN_MAX);
+}
+
+weak_alias (__getdtablesize, getdtablesize)
diff --git a/sysdeps/posix/getpagesize.c b/sysdeps/posix/getpagesize.c
new file mode 100644
index 0000000..4deb208
--- /dev/null
+++ b/sysdeps/posix/getpagesize.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1993, 1995 Free Software Foundation, Inc.
+ Contributed by Brendan Kehoe (brendan@cygnus.com).
+
+The GNU C Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the GNU C Library; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <unistd.h>
+
+extern long int EXFUN(__sysconf, (int));
+
+/* Return the system page size. */
+size_t
+DEFUN_VOID(__getpagesize)
+{
+ return __sysconf (_SC_PAGESIZE);
+}
+
+weak_alias (__getpagesize, getpagesize)
diff --git a/sysdeps/posix/gettimeofday.c b/sysdeps/posix/gettimeofday.c
new file mode 100644
index 0000000..a4bb38a
--- /dev/null
+++ b/sysdeps/posix/gettimeofday.c
@@ -0,0 +1,75 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/time.h>
+
+#ifndef HAVE_GNU_LD
+#define __daylight daylight
+#define __timezone timezone
+#define __tzname tzname
+#endif
+
+
+/* Get the current time of day and timezone information,
+ putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
+ Returns 0 on success, -1 on errors. */
+int
+DEFUN(__gettimeofday, (tv, tz),
+ struct timeval *tv AND struct timezone *tz)
+{
+ if (tv == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ tv->tv_sec = (long int) time ((time_t *) NULL);
+ tv->tv_usec = 0L;
+
+ if (tz != NULL)
+ {
+ CONST time_t timer = tv->tv_sec;
+ CONST struct tm *tm;
+
+ CONST long int save_timezone = __timezone;
+ CONST long int save_daylight = __daylight;
+ char *save_tzname[2];
+ save_tzname[0] = __tzname[0];
+ save_tzname[1] = __tzname[1];
+
+ tm = localtime (&timer);
+
+ tz->tz_minuteswest = __timezone / 60;
+ tz->tz_dsttime = __daylight;
+
+ __timezone = save_timezone;
+ __daylight = save_daylight;
+ __tzname[0] = save_tzname[0];
+ __tzname[1] = save_tzname[1];
+
+ if (tm == NULL)
+ return -1;
+ }
+
+ return 0;
+}
+
+weak_alias (__gettimeofday, gettimeofday)
diff --git a/sysdeps/posix/isatty.c b/sysdeps/posix/isatty.c
new file mode 100644
index 0000000..7536b1e
--- /dev/null
+++ b/sysdeps/posix/isatty.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <termios.h>
+
+/* Return 1 if FD is a terminal, 0 if not. */
+int
+DEFUN(__isatty, (fd), int fd)
+{
+ int save;
+ int is_tty;
+ struct termios term;
+
+ save = errno;
+ is_tty = __tcgetattr(fd, &term) == 0;
+ errno = save;
+
+ return is_tty;
+}
+
+weak_alias (__isatty, isatty)
diff --git a/sysdeps/posix/killpg.c b/sysdeps/posix/killpg.c
new file mode 100644
index 0000000..0c70dd2
--- /dev/null
+++ b/sysdeps/posix/killpg.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991, 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+
+/* Send SIG to all processes in process group PGRP.
+ If PGRP is zero, send SIG to all processes in
+ the current process's process group. */
+int
+DEFUN(killpg, (pgrp, sig), __pid_t pgrp AND int sig)
+{
+ if (pgrp < 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ return __kill (- pgrp, sig);
+}
diff --git a/sysdeps/posix/libc_fatal.c b/sysdeps/posix/libc_fatal.c
new file mode 100644
index 0000000..5539516
--- /dev/null
+++ b/sysdeps/posix/libc_fatal.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sysdep.h>
+
+#ifdef FATAL_PREPARE_INCLUDE
+#include FATAL_PREPARE_INCLUDE
+#endif
+
+/* Abort with an error message. */
+void
+DEFUN(__libc_fatal, (message), CONST char *message)
+{
+ size_t len = strlen (message);
+
+#ifdef FATAL_PREPARE
+ FATAL_PREPARE;
+#endif
+
+ while (len > 0)
+ {
+ register int count = __write (STDERR_FILENO, message, len);
+ if (count > 0)
+ {
+ message += count;
+ len -= count;
+ }
+ else if (count < 0
+#ifdef EINTR
+ && errno != EINTR
+#endif
+ )
+ break;
+ }
+
+ abort ();
+}
diff --git a/sysdeps/posix/mk-stdiolim.c b/sysdeps/posix/mk-stdiolim.c
new file mode 100644
index 0000000..da78a98
--- /dev/null
+++ b/sysdeps/posix/mk-stdiolim.c
@@ -0,0 +1,71 @@
+/* Copyright (C) 1991, 1992, 1993 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. */
+
+#include <posix1_lim.h>
+
+int
+main()
+{
+ /* These values correspond to the code in sysdeps/posix/tempname.c.
+ Change the values here if you change that code. */
+ printf("#define L_tmpnam %u\n", sizeof("/usr/tmp/") + 8);
+ printf("#define TMP_MAX %u\n", 62 * 62 * 62);
+
+ puts ("#ifdef __USE_POSIX");
+ printf("#define L_ctermid %u\n", sizeof("/dev/tty"));
+ printf("#define L_cuserid 9\n");
+ 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. */
+
+ printf("#define FOPEN_MAX %u\n",
+#ifdef OPEN_MAX
+
+ OPEN_MAX
+#else
+ /* This is the minimum number of files that the implementation
+ guarantees can be open simultaneously. OPEN_MAX not being
+ defined means the maximum is run-time variant; but POSIX.1
+ requires that it never be less than _POSIX_OPEN_MAX, so that is
+ a good minimum to use. */
+ _POSIX_OPEN_MAX
+#endif
+
+ );
+
+ printf("#define FILENAME_MAX %u\n",
+#ifdef PATH_MAX
+ PATH_MAX
+#else
+ /* This is supposed to be the size needed to hold the longest file
+ name string the implementation guarantees can be opened.
+ PATH_MAX not being defined means the actual limit on the length
+ of a file name is runtime-variant (or it is unlimited). ANSI
+ says in such a case FILENAME_MAX should be a good size to
+ allocate for a file name string. POSIX.1 guarantees that a
+ file name up to _POSIX_PATH_MAX chars long can be opened, so
+ this value must be at least that. */
+ 1024 /* _POSIX_PATH_MAX is 255. */
+#endif
+ );
+
+ exit(0);
+}
diff --git a/sysdeps/posix/mkstemp.c b/sysdeps/posix/mkstemp.c
new file mode 100644
index 0000000..9f4f68d
--- /dev/null
+++ b/sysdeps/posix/mkstemp.c
@@ -0,0 +1,64 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+/* Generate a unique temporary file name from TEMPLATE.
+ The last six characters of TEMPLATE must be "XXXXXX";
+ they are replaced with a string that makes the filename unique.
+ Returns a file descriptor open on the file for reading and writing. */
+int
+DEFUN(mkstemp, (template), char *template)
+{
+ static CONST char letters[]
+ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ size_t len;
+ size_t i;
+
+ len = strlen (template);
+ if (len < 6 || strcmp (&template[len - 6], "XXXXXX"))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (sprintf (&template[len - 5], "%.5u",
+ (unsigned int) getpid () % 100000) != 5)
+ /* Inconceivable lossage. */
+ return -1;
+
+ for (i = 0; i < sizeof (letters); ++i)
+ {
+ int fd;
+
+ template[len - 6] = letters[i];
+
+ fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0666);
+ if (fd >= 0)
+ return fd;
+ }
+
+ /* We return the null string if we can't find a unique file name. */
+ template[0] = '\0';
+ return -1;
+}
diff --git a/sysdeps/posix/mktemp.c b/sysdeps/posix/mktemp.c
new file mode 100644
index 0000000..c3aae36
--- /dev/null
+++ b/sysdeps/posix/mktemp.c
@@ -0,0 +1,64 @@
+/* Copyright (C) 1991, 1992, 1993 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+/* Generate a unique temporary file name from TEMPLATE.
+ The last six characters of TEMPLATE must be "XXXXXX";
+ they are replaced with a string that makes the filename unique. */
+char *
+DEFUN(mktemp, (template), char *template)
+{
+ static CONST char letters[]
+ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ size_t len;
+ size_t i;
+
+ len = strlen (template);
+ if (len < 6 || strcmp (&template[len - 6], "XXXXXX"))
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (sprintf (&template[len - 5], "%.5u",
+ (unsigned int) getpid () % 100000) != 5)
+ /* Inconceivable lossage. */
+ return NULL;
+
+ for (i = 0; i < sizeof (letters); ++i)
+ {
+ struct stat ignored;
+
+ template[len - 6] = letters[i];
+
+ if (stat (template, &ignored) < 0 && errno == ENOENT)
+ /* The file does not exist. So return this name. */
+ return template;
+ }
+
+ /* We return the null string if we can't find a unique file name. */
+ template[0] = '\0';
+ return template;
+}
diff --git a/sysdeps/posix/pipestream.c b/sysdeps/posix/pipestream.c
new file mode 100644
index 0000000..53595f5
--- /dev/null
+++ b/sysdeps/posix/pipestream.c
@@ -0,0 +1,223 @@
+/* Copyright (C) 1991, 1992, 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#define SH_PATH "/bin/sh" /* Shell to run. */
+#define SH_NAME "sh" /* Name to give it. */
+
+/* Structure describing a popen child. */
+struct child
+ {
+ pid_t pid; /* PID of the child. */
+ __ptr_t cookie; /* Original cookie from fdopen. */
+ __io_functions funcs; /* Original functions from fdopen. */
+ };
+
+/* io_functions for pipe streams.
+ These all simply call the corresponding
+ original function with the original cookie. */
+
+#define FUNC(type, name, args) \
+ static type DEFUN(__CONCAT(child_,name), args, __CONCAT(name,decl)) \
+ { \
+ struct child *c = (struct child *) cookie; \
+ { \
+ __ptr_t cookie = c->cookie; \
+ return (*c->funcs.__CONCAT(__,name)) args; \
+ } \
+ }
+
+#define readdecl PTR cookie AND register char *buf AND register size_t n
+FUNC (int, read, (cookie, buf, n))
+#define writedecl PTR cookie AND register CONST char *buf AND register size_t n
+FUNC (int, write, (cookie, buf, n))
+#define seekdecl PTR cookie AND fpos_t *pos AND int whence
+FUNC (int, seek, (cookie, pos, whence))
+#define closedecl PTR cookie
+FUNC (int, close, (cookie))
+#define filenodecl PTR cookie
+FUNC (int, fileno, (cookie))
+
+static const __io_functions child_funcs
+ = { child_read, child_write, child_seek, child_close, child_fileno };
+
+/* Open a new stream that is a one-way pipe to a
+ child process running the given shell command. */
+FILE *
+DEFUN(popen, (command, mode), CONST char *command AND CONST char *mode)
+{
+ pid_t pid;
+ int pipedes[2];
+ FILE *stream;
+ struct child *child;
+
+ if (command == NULL || mode == NULL || (*mode != 'r' && *mode != 'w'))
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ /* Create the pipe. */
+ if (pipe(pipedes) < 0)
+ return NULL;
+
+ /* Fork off the child. */
+ pid = __vfork ();
+ if (pid == (pid_t) -1)
+ {
+ /* The fork failed. */
+ (void) close (pipedes[0]);
+ (void) close (pipedes[1]);
+ return NULL;
+ }
+ else if (pid == (pid_t) 0)
+ {
+ /* We are the child side. Make the write side of
+ the pipe be stdin or the read side be stdout. */
+
+ CONST char *new_argv[4];
+
+ if ((*mode == 'w' ? dup2(pipedes[STDIN_FILENO], STDIN_FILENO) :
+ dup2(pipedes[STDOUT_FILENO], STDOUT_FILENO)) < 0)
+ _exit(127);
+
+ /* Close the pipe descriptors. */
+ (void) close(pipedes[STDIN_FILENO]);
+ (void) close(pipedes[STDOUT_FILENO]);
+
+ /* Exec the shell. */
+ new_argv[0] = SH_NAME;
+ new_argv[1] = "-c";
+ new_argv[2] = command;
+ new_argv[3] = NULL;
+ (void) execve(SH_PATH, (char *CONST *) new_argv, environ);
+ /* Die if it failed. */
+ _exit(127);
+ }
+
+ /* We are the parent side. */
+
+ /* Close the irrelevant side of the pipe and open the relevant side as a
+ new stream. Mark our side of the pipe to close on exec, so new children
+ won't see it. */
+ if (*mode == 'r')
+ {
+ (void) close (pipedes[STDOUT_FILENO]);
+ (void) fcntl (pipedes[STDIN_FILENO], F_SETFD, FD_CLOEXEC);
+ stream = fdopen (pipedes[STDIN_FILENO], mode);
+ }
+ else
+ {
+ (void) close (pipedes[STDIN_FILENO]);
+ (void) fcntl (pipedes[STDOUT_FILENO], F_SETFD, FD_CLOEXEC);
+ stream = fdopen (pipedes[STDOUT_FILENO], mode);
+ }
+
+ if (stream == NULL)
+ goto error;
+
+ child = (struct child *) malloc (sizeof (struct child));
+ if (child == NULL)
+ goto error;
+
+ {
+ /* Make sure STREAM has its functions set before
+ we try to squirrel them away in CHILD. */
+ extern void __stdio_check_funcs __P ((FILE *));
+ __stdio_check_funcs (stream);
+ }
+
+ child->pid = pid;
+ child->cookie = stream->__cookie;
+ child->funcs = stream->__io_funcs;
+ stream->__cookie = (PTR) child;
+ stream->__io_funcs = child_funcs;
+ stream->__ispipe = 1;
+ return stream;
+
+ error:
+ {
+ /* The stream couldn't be opened or the child structure couldn't be
+ allocated. Kill the child and close the other side of the pipe. */
+ int save = errno;
+ (void) kill (pid, SIGKILL);
+ if (stream == NULL)
+ (void) close (pipedes[*mode == 'r' ? STDOUT_FILENO : STDIN_FILENO]);
+ else
+ (void) fclose (stream);
+#ifndef NO_WAITPID
+ (void) waitpid (pid, (int *) NULL, 0);
+#else
+ {
+ pid_t dead;
+ do
+ dead = wait ((int *) NULL);
+ while (dead > 0 && dead != pid);
+ }
+#endif
+ errno = save;
+ return NULL;
+ }
+}
+
+/* Close a stream opened by popen and return its status.
+ Returns -1 if the stream was not opened by popen. */
+int
+DEFUN(pclose, (stream), register FILE *stream)
+{
+ struct child *c;
+ pid_t pid, dead;
+ int status;
+
+ if (!__validfp(stream) || !stream->__ispipe)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ c = (struct child *) stream->__cookie;
+ pid = c->pid;
+ stream->__cookie = c->cookie;
+ stream->__io_funcs = c->funcs;
+ free ((PTR) c);
+ stream->__ispipe = 0;
+ if (fclose (stream))
+ return -1;
+
+#ifndef NO_WAITPID
+ dead = waitpid (pid, &status, 0);
+#else
+ do
+ dead = wait (&status);
+ while (dead > 0 && dead != pid);
+#endif
+ if (dead != pid)
+ status = -1;
+
+ return status;
+}
diff --git a/sysdeps/posix/raise.c b/sysdeps/posix/raise.c
new file mode 100644
index 0000000..159fdd5
--- /dev/null
+++ b/sysdeps/posix/raise.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <signal.h>
+#include <unistd.h>
+
+/* Raise the signal SIG. */
+int
+DEFUN(raise, (sig), int sig)
+{
+ return __kill(__getpid(), sig);
+}
diff --git a/sysdeps/posix/readv.c b/sysdeps/posix/readv.c
new file mode 100644
index 0000000..5f61e61
--- /dev/null
+++ b/sysdeps/posix/readv.c
@@ -0,0 +1,68 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/uio.h>
+
+/* Read data from file descriptor FD, and put the result in the
+ buffers described by VECTOR, which is a vector of COUNT `struct iovec's.
+ The buffers are filled in the order specified.
+ Operates just like `read' (see <unistd.h>) except that data are
+ put in VECTOR instead of a contiguous buffer. */
+int
+DEFUN(readv, (fd, vector, count),
+ int fd AND CONST struct iovec *vector AND size_t count)
+{
+ char *buffer;
+ size_t bytes;
+ int bytes_read;
+ register size_t i;
+
+ /* Find the total number of bytes to be read. */
+ bytes = 0;
+ for (i = 0; i < count; ++i)
+ bytes += vector[i].iov_len;
+
+ /* Allocate a temporary buffer to hold the data. */
+ buffer = (char *) __alloca(bytes);
+
+ /* Read the data. */
+ bytes_read = read(fd, buffer, bytes);
+ if (bytes_read <= 0)
+ return -1;
+
+ /* Copy the data from BUFFER into the memory specified by VECTOR. */
+ bytes = bytes_read;
+ for (i = 0; i < count; ++i)
+ {
+#define min(a, b) ((a) > (b) ? (b) : (a))
+ size_t copy = min(vector[i].iov_len, bytes);
+
+ (void) memcpy((PTR) vector[i].iov_base, (PTR) buffer, copy);
+
+ buffer += copy;
+ bytes -= copy;
+ if (bytes == 0)
+ break;
+ }
+
+ return bytes_read;
+}
diff --git a/sysdeps/posix/remove.c b/sysdeps/posix/remove.c
new file mode 100644
index 0000000..66414c9
--- /dev/null
+++ b/sysdeps/posix/remove.c
@@ -0,0 +1,40 @@
+/* ANSI C `remove' function to delete a file or directory. POSIX.1 version.
+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. */
+
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int
+remove (file)
+ const char *file;
+{
+ int save;
+
+ save = errno;
+ if (__rmdir (file) == 0)
+ return 0;
+ else if (errno == ENOTDIR && __unlink (file) == 0)
+ {
+ errno = save;
+ return 0;
+ }
+
+ return -1;
+}
diff --git a/sysdeps/posix/rename.c b/sysdeps/posix/rename.c
new file mode 100644
index 0000000..3245f9c
--- /dev/null
+++ b/sysdeps/posix/rename.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+
+/* Rename the file OLD to NEW. */
+int
+DEFUN(rename, (old, new), CONST char *old AND CONST char *new)
+{
+ int save = errno;
+ if (__link(old, new) < 0)
+ {
+ if (errno == EEXIST)
+ {
+ errno = save;
+ /* Race condition, required for 1003.1 conformance. */
+ if (__unlink(new) < 0 ||
+ __link(old, new) < 0)
+ return -1;
+ }
+ else
+ return -1;
+ }
+ if (__unlink(old) < 0)
+ {
+ save = errno;
+ if (__unlink(new) == 0)
+ errno = save;
+ return -1;
+ }
+ return 0;
+}
diff --git a/sysdeps/posix/sigblock.c b/sysdeps/posix/sigblock.c
new file mode 100644
index 0000000..411a952
--- /dev/null
+++ b/sysdeps/posix/sigblock.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1991, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+/* Block signals in MASK, returning the old mask. */
+int
+DEFUN(__sigblock, (mask), int mask)
+{
+ register int sig;
+ sigset_t set, oset;
+
+ if (__sigemptyset(&set) < 0)
+ return -1;
+
+ if (sizeof (mask) == sizeof (set))
+ *(int *) &set = mask;
+ else
+ for (sig = 1; sig < NSIG; ++sig)
+ if ((mask & sigmask(sig)) &&
+ __sigaddset(&set, sig) < 0)
+ return -1;
+
+ if (sigprocmask(SIG_BLOCK, &set, &oset) < 0)
+ return -1;
+
+ mask = 0;
+ if (sizeof (mask) == sizeof (oset))
+ mask = *(int *) &oset;
+ else
+ for (sig = 1; sig < NSIG; ++sig)
+ if (__sigismember(&oset, sig))
+ mask |= sigmask(sig);
+
+ return mask;
+}
+
+weak_alias (__sigblock, sigblock)
diff --git a/sysdeps/posix/sigintr.c b/sysdeps/posix/sigintr.c
new file mode 100644
index 0000000..441c643
--- /dev/null
+++ b/sysdeps/posix/sigintr.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <signal.h>
+#include <errno.h>
+
+/* If INTERRUPT is nonzero, make signal SIG interrupt system calls
+ (causing them to fail with EINTR); if INTERRUPT is zero, make system
+ calls be restarted after signal SIG. */
+int
+DEFUN(siginterrupt, (sig, interrupt),
+ int sig AND int interrupt)
+{
+#ifdef SA_RESTART
+ extern sigset_t _sigintr; /* Defined in signal.c. */
+ struct sigaction action;
+
+ if (__sigaction (sig, (struct sigaction *) NULL, &action) < 0)
+ return -1;
+
+ if (interrupt)
+ {
+ __sigaddset (&_sigintr, sig);
+ action.sa_flags &= ~SA_RESTART;
+ }
+ else
+ {
+ __sigdelset (&_sigintr, sig);
+ action.sa_flags |= SA_RESTART;
+ }
+
+ if (__sigaction (sig, &action, (struct sigaction *) NULL) < 0)
+ return -1;
+
+ return 0;
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+}
diff --git a/sysdeps/posix/signal.c b/sysdeps/posix/signal.c
new file mode 100644
index 0000000..f9ae47b
--- /dev/null
+++ b/sysdeps/posix/signal.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+
+sigset_t _sigintr; /* Set by siginterrupt. */
+
+/* Set the handler for the signal SIG to HANDLER,
+ returning the old handler, or SIG_ERR on error. */
+__sighandler_t
+DEFUN(signal, (sig, handler), int sig AND __sighandler_t handler)
+{
+ struct sigaction act, oact;
+
+ if (handler == SIG_ERR)
+ {
+ errno = EINVAL;
+ return SIG_ERR;
+ }
+
+ act.sa_handler = handler;
+ if (__sigemptyset (&act.sa_mask) < 0)
+ return SIG_ERR;
+ act.sa_flags = __sigismember (&_sigintr, sig) ? 0 : SA_RESTART;
+ if (__sigaction (sig, &act, &oact) < 0)
+ return SIG_ERR;
+
+ return oact.sa_handler;
+}
diff --git a/sysdeps/posix/sigpause.c b/sysdeps/posix/sigpause.c
new file mode 100644
index 0000000..97716d3
--- /dev/null
+++ b/sysdeps/posix/sigpause.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+/* Set the mask of blocked signals to MASK,
+ wait for a signal to arrive, and then restore the mask. */
+int
+DEFUN(__sigpause, (mask), int mask)
+{
+ sigset_t set;
+ int sig;
+
+ if (__sigemptyset (&set) < 0)
+ return -1;
+
+ if (sizeof (mask) == sizeof (set))
+ *(int *) &set = mask;
+ else
+ for (sig = 1; sig < NSIG; ++sig)
+ if ((mask & sigmask(sig)) &&
+ __sigaddset(&set, sig) < 0)
+ return -1;
+
+ return sigsuspend (&set);
+}
+
+weak_alias (__sigpause, sigpause)
diff --git a/sysdeps/posix/sigsetmask.c b/sysdeps/posix/sigsetmask.c
new file mode 100644
index 0000000..12e77a6
--- /dev/null
+++ b/sysdeps/posix/sigsetmask.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1991, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+/* Set the mask of blocked signals to MASK, returning the old mask. */
+int
+DEFUN(__sigsetmask, (mask), int mask)
+{
+ register int sig;
+ sigset_t set, oset;
+
+ if (__sigemptyset(&set) < 0)
+ return -1;
+
+ if (sizeof (mask) == sizeof (set))
+ *(int *) &set = mask;
+ else
+ for (sig = 1; sig < NSIG; ++sig)
+ if ((mask & sigmask(sig)) &&
+ __sigaddset(&set, sig) < 0)
+ return -1;
+
+ if (sigprocmask(SIG_SETMASK, &set, &oset) < 0)
+ return -1;
+
+ mask = 0;
+ if (sizeof (mask) == sizeof (oset))
+ mask = *(int *) &oset;
+ else
+ for (sig = 1; sig < NSIG; ++sig)
+ if (__sigismember(&oset, sig))
+ mask |= sigmask(sig);
+
+ return mask;
+}
+
+weak_alias (__sigsetmask, sigsetmask)
diff --git a/sysdeps/posix/sigsuspend.c b/sysdeps/posix/sigsuspend.c
new file mode 100644
index 0000000..7713153
--- /dev/null
+++ b/sysdeps/posix/sigsuspend.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+#include <stddef.h>
+#include <unistd.h>
+
+
+/* Change the set of blocked signals to SET,
+ wait until a signal arrives, and restore the set of blocked signals. */
+int
+DEFUN(sigsuspend, (set), CONST sigset_t *set)
+{
+ sigset_t oset;
+ int save;
+
+ if (set == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (sigprocmask(SIG_SETMASK, set, &oset) < 0)
+ return -1;
+
+ (void) pause();
+ save = errno;
+
+ if (sigprocmask(SIG_SETMASK, &oset, (sigset_t *) NULL) < 0)
+ return -1;
+
+ errno = save;
+ return -1;
+}
diff --git a/sysdeps/posix/sigvec.c b/sysdeps/posix/sigvec.c
new file mode 100644
index 0000000..4aef22a
--- /dev/null
+++ b/sysdeps/posix/sigvec.c
@@ -0,0 +1,162 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#include <ansidecl.h>
+#include <signal.h>
+#include <errno.h>
+#include <stddef.h>
+
+
+/* We use a wrapper handler to support SV_RESETHAND. */
+
+static __sighandler_t wrapped_handlers[NSIG];
+static sigset_t wrapped_masks[NSIG];
+
+static void
+DEFUN(wrapper_handler, (sig), int sig)
+{
+ int save;
+ struct sigaction act;
+
+ act.sa_handler = SIG_DFL;
+ act.sa_mask = wrapped_masks[sig];
+ act.sa_flags = 0;
+ save = errno;
+ (void) __sigaction(sig, &act, (struct sigaction *) NULL);
+ errno = save;
+
+ (*wrapped_handlers[sig])(sig);
+}
+
+static
+#ifdef __GNUC__
+inline
+#endif
+int
+DEFUN(convert_mask, (set, mask), sigset_t *set AND CONST int mask)
+{
+ register int sig;
+
+ if (sizeof(*set) == sizeof(mask))
+ {
+ *(int *) set = mask;
+ return 0;
+ }
+
+ if (__sigemptyset(set) < 0)
+ return -1;
+
+ for (sig = 1; sig < NSIG; ++sig)
+ if (mask & sigmask(sig))
+ if (__sigaddset(set, sig) < 0)
+ return -1;
+
+ return 0;
+}
+
+/* If VEC is non-NULL, set the handler for SIG to the `sv_handler' member
+ of VEC. The signals in `sv_mask' will be blocked while the handler runs.
+ If the SV_RESETHAND bit is set in `sv_flags', the handler for SIG will be
+ reset to SIG_DFL before `sv_handler' is entered. If OVEC is non-NULL,
+ it is filled in with the old information for SIG. */
+int
+DEFUN(__sigvec, (sig, vec, ovec),
+ int sig AND CONST struct sigvec *vec AND struct sigvec *ovec)
+{
+ struct sigaction old;
+
+ if (vec == NULL || !(vec->sv_flags & SV_RESETHAND))
+ {
+ struct sigaction new, *n;
+
+ if (vec == NULL)
+ n = NULL;
+ else
+ {
+ n = &new;
+ n->sa_handler = vec->sv_handler;
+ if (convert_mask (&n->sa_mask, vec->sv_mask) < 0)
+ return -1;
+ n->sa_flags = 0;
+
+ if (vec->sv_flags & SV_ONSTACK)
+ {
+#ifdef SA_ONSTACK
+ n->sa_flags |= SA_ONSTACK;
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+ }
+#ifdef SA_RESTART
+ if (!(vec->sv_flags & SV_INTERRUPT))
+ n->sa_flags |= SA_RESTART;
+#endif
+ }
+
+ if (__sigaction (sig, n, &old) < 0)
+ return -1;
+ }
+ else
+ {
+ struct sigaction wrapper;
+
+ wrapper.sa_handler = wrapper_handler;
+ wrapped_handlers[sig] = vec->sv_handler;
+ if (convert_mask (&wrapped_masks[sig], vec->sv_mask) < 0)
+ return -1;
+
+ if (__sigaction (sig, &wrapper, &old) < 0)
+ return -1;
+ }
+
+ if (ovec != NULL)
+ {
+ register int i;
+ int mask = 0;
+
+ if (sizeof (int) == sizeof (sigset_t))
+ mask = *(int *) &old.sa_mask;
+ else
+ for (i = 1; i < NSIG; ++i)
+ if (__sigismember(&old.sa_mask, i))
+ mask |= sigmask(i);
+
+ ovec->sv_mask = mask;
+ ovec->sv_flags = 0;
+#ifdef SA_ONSTACK
+ if (old.sa_flags & SA_ONSTACK)
+ ovec->sv_flags |= SV_ONSTACK;
+#endif
+#ifdef SA_RESTART
+ if (!(old.sa_flags & SA_RESTART))
+#endif
+ ovec->sv_flags |= SV_INTERRUPT;
+ if (old.sa_handler == wrapper_handler)
+ {
+ ovec->sv_flags |= SV_RESETHAND;
+ ovec->sv_handler = wrapped_handlers[sig];
+ }
+ else
+ ovec->sv_handler = old.sa_handler;
+ }
+
+ return 0;
+}
+
+weak_alias (__sigvec, sigvec)
diff --git a/sysdeps/posix/sleep.c b/sysdeps/posix/sleep.c
new file mode 100644
index 0000000..36864cb
--- /dev/null
+++ b/sysdeps/posix/sleep.c
@@ -0,0 +1,106 @@
+/* Copyright (C) 1991, 1992, 1993 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. */
+
+#include <ansidecl.h>
+#include <signal.h>
+#include <time.h>
+#include <unistd.h>
+#include <errno.h>
+
+
+/* SIGALRM signal handler for `sleep'. This does nothing but return,
+ but SIG_IGN isn't supposed to break `pause'. */
+static void
+DEFUN(sleep_handler, (sig), int sig)
+{
+ return;
+}
+
+/* Make the process sleep for SECONDS seconds, or until a signal arrives
+ and is not ignored. The function returns the number of seconds less
+ than SECONDS which it actually slept (zero if it slept the full time).
+ If a signal handler does a `longjmp' or modifies the handling of the
+ SIGALRM signal while inside `sleep' call, the handling of the SIGALRM
+ signal afterwards is undefined. There is no return value to indicate
+ error, but if `sleep' returns SECONDS, it probably didn't work. */
+unsigned int
+DEFUN(sleep, (seconds), unsigned int seconds)
+{
+ unsigned int remaining, slept;
+ time_t before, after;
+ sigset_t set, oset;
+ struct sigaction act, oact;
+ int save = errno;
+
+ if (seconds == 0)
+ return 0;
+
+ /* Block SIGALRM signals while frobbing the handler. */
+ if (sigemptyset (&set) < 0 ||
+ sigaddset (&set, SIGALRM) < 0 ||
+ sigprocmask (SIG_BLOCK, &set, &oset))
+ return seconds;
+
+ act.sa_handler = sleep_handler;
+ act.sa_flags = 0;
+ if (sigemptyset (&act.sa_mask) < 0 ||
+ sigaction (SIGALRM, &act, &oact) < 0)
+ return seconds;
+
+ before = time ((time_t *) NULL);
+ remaining = alarm (seconds);
+
+ if (remaining > 0 && remaining < seconds)
+ {
+ /* The user's alarm will expire before our own would.
+ Restore the user's signal action state and let his alarm happen. */
+ (void) sigaction (SIGALRM, &oact, (struct sigaction *) NULL);
+ alarm (remaining); /* Restore sooner alarm. */
+ sigsuspend (&oset); /* Wait for it to go off. */
+ after = time ((time_t *) NULL);
+ }
+ else
+ {
+ /* Atomically restore the old signal mask
+ (which had better not block SIGALRM),
+ and wait for a signal to arrive. */
+ sigsuspend (&oset);
+
+ after = time ((time_t *) NULL);
+
+ /* Restore the old signal action state. */
+ (void) sigaction (SIGALRM, &oact, (struct sigaction *) NULL);
+ }
+
+ /* Notice how long we actually slept. */
+ slept = after - before;
+
+ /* Restore the user's alarm if we have not already past it.
+ If we have, be sure to turn off the alarm in case a signal
+ other than SIGALRM was what woke us up. */
+ (void) alarm (remaining > slept ? remaining - slept : 0);
+
+ /* Restore the original signal mask. */
+ (void) sigprocmask (SIG_SETMASK, &oset, (sigset_t *) NULL);
+
+ /* Restore the `errno' value we started with.
+ Some of the calls we made might have failed, but we didn't care. */
+ errno = save;
+
+ return slept > seconds ? 0 : seconds - slept;
+}
diff --git a/sysdeps/posix/stdio_init.c b/sysdeps/posix/stdio_init.c
new file mode 100644
index 0000000..422d9b6
--- /dev/null
+++ b/sysdeps/posix/stdio_init.c
@@ -0,0 +1,70 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+/* Initialize STREAM as necessary.
+ This may change I/O functions, give a buffer, etc.
+ If no buffer is allocated, but the bufsize is set,
+ the bufsize will be used to allocate the buffer. */
+void
+DEFUN(__stdio_init_stream, (stream), FILE *stream)
+{
+ register CONST int fd = (int) stream->__cookie;
+ struct stat statb;
+
+ if (stream->__buffer != NULL || stream->__userbuf)
+ /* If's unbuffered by request, we can't do anything useful. */
+ return;
+
+ /* Find out what sort of file this is. */
+ if (__fstat (fd, &statb) < 0)
+ return;
+
+ if (S_ISCHR (statb.st_mode))
+ {
+ /* It's a character device.
+ Make it line-buffered if it's a terminal. */
+ if (__isatty (fd))
+ {
+ stream->__linebuf = 1;
+
+ /* Unix terminal devices have the bad habit of claiming to be
+ seekable. On systems I have tried, seeking on a terminal
+ device seems to set its file position as specified, such that
+ a later tell says the same thing. This is in no way related
+ to actual seekability--the ability to seek back and read old
+ data. Unix terminal devices will let you "seek back", and
+ then read more new data from the terminal. I can think of
+ nothing to do about this lossage except to preemptively disable
+ seeking on terminal devices. */
+
+ stream->__io_funcs.__seek = NULL; /* Seeks get ESPIPE. */
+ }
+ }
+
+#ifdef _STATBUF_ST_BLKSIZE
+ /* Use the block-size field to determine
+ the system's optimal buffering size. */
+ stream->__bufsize = statb.st_blksize;
+#endif
+}
diff --git a/sysdeps/posix/sysconf.c b/sysdeps/posix/sysconf.c
new file mode 100644
index 0000000..7f4fbb7
--- /dev/null
+++ b/sysdeps/posix/sysconf.c
@@ -0,0 +1,183 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <limits.h>
+#include <unistd.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+
+extern int EXFUN(__getdtablesize, (NOARGS));
+extern size_t EXFUN(__getpagesize, (NOARGS));
+
+/* Get the value of the system variable NAME. */
+long int
+DEFUN(__sysconf, (name), int name)
+{
+ switch (name)
+ {
+ default:
+ errno = EINVAL;
+ return -1;
+
+ case _SC_ARG_MAX:
+#ifdef ARG_MAX
+ return ARG_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_CHILD_MAX:
+#ifdef CHILD_MAX
+ return CHILD_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_CLK_TCK:
+ return 60;
+
+ case _SC_NGROUPS_MAX:
+#ifdef NGROUPS_MAX
+ return NGROUPS_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_OPEN_MAX:
+ return __getdtablesize ();
+
+ case _SC_STREAM_MAX:
+ return FOPEN_MAX;
+
+ case _SC_TZNAME_MAX:
+ return __tzname_max ();
+
+ case _SC_JOB_CONTROL:
+#ifdef _POSIX_JOB_CONTROL
+ return 1;
+#else
+ return -1;
+#endif
+ case _SC_SAVED_IDS:
+#ifdef _POSIX_SAVED_IDS
+ return 1;
+#else
+ return -1;
+#endif
+ case _SC_VERSION:
+ return _POSIX_VERSION;
+
+ case _SC_PAGESIZE:
+ return __getpagesize ();
+
+ case _SC_BC_BASE_MAX:
+#ifdef BC_BASE_MAX
+ return BC_BASE_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_BC_DIM_MAX:
+#ifdef BC_DIM_MAX
+ return BC_DIM_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_BC_SCALE_MAX:
+#ifdef BC_SCALE_MAX
+ return BC_SCALE_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_BC_STRING_MAX:
+#ifdef BC_STRING_MAX
+ return BC_STRING_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_EQUIV_CLASS_MAX:
+#ifdef EQUIV_CLASS_MAX
+ return EQUIV_CLASS_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_EXPR_NEST_MAX:
+#ifdef EXPR_NEST_MAX
+ return EXPR_NEST_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_LINE_MAX:
+#ifdef LINE_MAX
+ return LINE_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_RE_DUP_MAX:
+#ifdef RE_DUP_MAX
+ return RE_DUP_MAX;
+#else
+ return -1;
+#endif
+
+
+ case _SC_2_VERSION:
+ /* This is actually supposed to return the version
+ of the 1003.2 utilities on the system {POSIX2_VERSION}. */
+ return _POSIX2_C_VERSION;
+
+ case _SC_2_C_BIND:
+#ifdef _POSIX2_C_BIND
+ return _POSIX2_C_BIND;
+#else
+ return -1;
+#endif
+
+ case _SC_2_C_DEV:
+#ifdef _POSIX2_C_DEV
+ return _POSIX2_C_DEV;
+#else
+ return -1;
+#endif
+
+ case _SC_2_FORT_DEV:
+#ifdef _POSIX2_FORT_DEV
+ return _POSIX2_FORT_DEV;
+#else
+ return -1;
+#endif
+
+ case _SC_2_SW_DEV:
+#ifdef _POSIX2_SW_DEV
+ return _POSIX2_SW_DEV;
+#else
+ return -1;
+#endif
+ }
+}
+
+weak_alias (__sysconf, sysconf)
diff --git a/sysdeps/posix/system.c b/sysdeps/posix/system.c
new file mode 100644
index 0000000..69b004b
--- /dev/null
+++ b/sysdeps/posix/system.c
@@ -0,0 +1,145 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <signal.h>
+#include <sys/types.h>
+
+
+#ifndef HAVE_GNU_LD
+#define __environ environ
+#endif
+
+#define SHELL_PATH "/bin/sh" /* Path of the shell. */
+#define SHELL_NAME "sh" /* Name to give it. */
+
+/* Execute LINE as a shell command, returning its status. */
+int
+DEFUN(system, (line), register CONST char *line)
+{
+ int status, save;
+ pid_t pid;
+ struct sigaction sa, intr, quit;
+#ifndef WAITPID_CANNOT_BLOCK_SIGCHLD
+ sigset_t block, omask;
+#endif
+
+ if (line == NULL)
+ return 1;
+
+ sa.sa_handler = SIG_IGN;
+ sa.sa_flags = 0;
+ __sigemptyset (&sa.sa_mask);
+
+ if (__sigaction (SIGINT, &sa, &intr) < 0)
+ return -1;
+ if (__sigaction (SIGQUIT, &sa, &quit) < 0)
+ {
+ save = errno;
+ (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
+ errno = save;
+ return -1;
+ }
+
+#ifndef WAITPID_CANNOT_BLOCK_SIGCHLD
+
+/* SCO 3.2v4 has a bug where `waitpid' will never return if SIGCHLD is
+ blocked. This makes it impossible for `system' to be implemented in
+ compliance with POSIX.2-1992. They have acknowledged that this is a bug
+ but I have not seen nor heard of any forthcoming fix. */
+
+ __sigemptyset (&block);
+ __sigaddset (&block, SIGCHLD);
+ save = errno;
+ if (__sigprocmask (SIG_BLOCK, &block, &omask) < 0)
+ {
+ if (errno == ENOSYS)
+ errno = save;
+ else
+ {
+ save = errno;
+ (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
+ (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
+ errno = save;
+ return -1;
+ }
+ }
+#define UNBLOCK __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)
+#else
+#define UNBLOCK 0
+#endif
+
+ pid = __vfork ();
+ if (pid == (pid_t) 0)
+ {
+ /* Child side. */
+ CONST char *new_argv[4];
+ new_argv[0] = SHELL_NAME;
+ new_argv[1] = "-c";
+ new_argv[2] = line;
+ new_argv[3] = NULL;
+
+ /* Restore the signals. */
+ (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
+ (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
+ (void) UNBLOCK;
+
+ /* Exec the shell. */
+ (void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ);
+ _exit (127);
+ }
+ else if (pid < (pid_t) 0)
+ /* The fork failed. */
+ status = -1;
+ else
+ /* Parent side. */
+#ifdef NO_WAITPID
+ {
+ pid_t child;
+ do
+ {
+ child = __wait (&status);
+ if (child <= -1)
+ {
+ status = -1;
+ break;
+ }
+ } while (child != pid);
+ }
+#else
+ if (__waitpid (pid, &status, 0) != pid)
+ status = -1;
+#endif
+
+ save = errno;
+ if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL) |
+ __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL) |
+ UNBLOCK) != 0)
+ {
+ if (errno == ENOSYS)
+ errno = save;
+ else
+ return -1;
+ }
+
+ return status;
+}
diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c
new file mode 100644
index 0000000..f2da66a
--- /dev/null
+++ b/sysdeps/posix/tempname.c
@@ -0,0 +1,208 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+/* Return nonzero if DIR is an existent directory. */
+static int
+DEFUN(diraccess, (dir), CONST char *dir)
+{
+ struct stat buf;
+ return __stat (dir, &buf) == 0 && S_ISDIR (buf.st_mode);
+}
+
+/* Return nonzero if FILE exists. */
+static int
+DEFUN(exists, (file), CONST char *file)
+{
+ /* We can stat the file even if we can't read its data. */
+ struct stat st;
+ int save = errno;
+ if (__stat (file, &st) == 0)
+ return 1;
+ else
+ {
+ /* We report that the file exists if stat failed for a reason other
+ than nonexistence. In this case, it may or may not exist, and we
+ don't know; but reporting that it does exist will never cause any
+ trouble, while reporting that it doesn't exist when it does would
+ violate the interface of __stdio_gen_tempname. */
+ int exists = errno != ENOENT;
+ errno = save;
+ return exists;
+ }
+}
+
+
+/* These are the characters used in temporary filenames. */
+static CONST char letters[] =
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+
+/* Generate a temporary filename and return it (in a static buffer). If
+ STREAMPTR is not NULL, open a stream "w+b" on the file and set
+ *STREAMPTR to it. If DIR_SEARCH is nonzero, DIR and PFX are used as
+ described for tempnam. If not, a temporary filename in P_tmpdir with no
+ special prefix is generated. If LENPTR is not NULL, *LENPTR is set the
+ to length (including the terminating '\0') of the resultant filename,
+ which is returned. This goes through a cyclic pattern of all possible
+ filenames consisting of five decimal digits of the current pid and three
+ of the characters in `letters'. Data for tempnam and tmpnam is kept
+ separate, but when tempnam is using P_tmpdir and no prefix (i.e, it is
+ identical to tmpnam), the same data is used. Each potential filename is
+ tested for an already-existing file of the same name, and no name of an
+ existing file will be returned. When the cycle reaches its end
+ (12345ZZZ), NULL is returned. */
+char *
+DEFUN(__stdio_gen_tempname, (dir, pfx, dir_search, lenptr, streamptr),
+ CONST char *dir AND CONST char *pfx AND
+ int dir_search AND size_t *lenptr AND
+ FILE **streamptr)
+{
+ int saverrno = errno;
+ static CONST char tmpdir[] = P_tmpdir;
+ static size_t indices[2];
+ size_t *idx;
+ static char buf[FILENAME_MAX];
+ static pid_t oldpid = (pid_t) 0;
+ pid_t pid = __getpid();
+ register size_t len, plen, dlen;
+
+ if (dir_search)
+ {
+ register CONST char *d = getenv ("TMPDIR");
+ if (d != NULL && !diraccess (d))
+ d = NULL;
+ if (d == NULL && dir != NULL && diraccess (dir))
+ d = dir;
+ if (d == NULL && diraccess (tmpdir))
+ d = tmpdir;
+ if (d == NULL && diraccess ("/tmp"))
+ d = "/tmp";
+ if (d == NULL)
+ {
+ errno = ENOENT;
+ return NULL;
+ }
+ dir = d;
+ }
+ else
+ dir = tmpdir;
+
+ dlen = strlen (dir);
+
+ /* Remove trailing slashes from the directory name. */
+ while (dlen > 1 && dir[dlen - 1] == '/')
+ --dlen;
+
+ if (pfx != NULL && *pfx != '\0')
+ {
+ plen = strlen (pfx);
+ if (plen > 5)
+ plen = 5;
+ }
+ else
+ plen = 0;
+
+ if (dir != tmpdir && !strcmp (dir, tmpdir))
+ dir = tmpdir;
+ idx = &indices[(plen == 0 && dir == tmpdir) ? 1 : 0];
+
+ if (pid != oldpid)
+ {
+ oldpid = pid;
+ indices[0] = indices[1] = 0;
+ }
+
+ len = dlen + 1 + plen + 5 + 3;
+ while (*idx < ((sizeof (letters) - 1) * (sizeof (letters) - 1) *
+ (sizeof (letters) - 1)))
+ {
+ const size_t i = (*idx)++;
+
+ /* Construct a file name and see if it already exists.
+
+ We use a single counter in *IDX to cycle each of three
+ character positions through each of 62 possible letters. */
+
+ if (sizeof (buf) < len ||
+ sprintf (buf, "%.*s/%.*s%.5d%c%c%c",
+ (int) dlen, dir, (int) plen,
+ pfx, pid % 100000,
+ letters[i % (sizeof (letters) - 1)],
+ letters[(i / (sizeof (letters) - 1))
+ % (sizeof (letters) - 1)],
+ letters[(i / ((sizeof (letters) - 1) *
+ (sizeof (letters) - 1)))
+ % (sizeof (letters) - 1)]
+ ) != (int) len)
+ return NULL;
+
+ if (streamptr != NULL)
+ {
+ /* Try to create the file atomically. */
+ int fd = __open (buf, O_RDWR|O_CREAT|O_EXCL, 0666);
+ if (fd >= 0)
+ {
+ /* We got a new file that did not previously exist.
+ Create a stream for it. */
+ *streamptr = __newstream ();
+ if (*streamptr == NULL)
+ {
+ /* We lost trying to create a stream (out of memory?).
+ Nothing to do but remove the file, close the descriptor,
+ and return failure. */
+ const int save = errno;
+ (void) remove (buf);
+ (void) __close (fd);
+ errno = save;
+ return NULL;
+ }
+ (*streamptr)->__cookie = (PTR) (long int) fd;
+ (*streamptr)->__mode.__write = 1;
+ (*streamptr)->__mode.__read = 1;
+ (*streamptr)->__mode.__binary = 1;
+ }
+ else
+ continue;
+ }
+ else if (exists (buf))
+ continue;
+
+ /* If the file already existed we have continued the loop above,
+ so we only get here when we have a winning name to return. */
+
+ errno = saverrno;
+
+ if (lenptr != NULL)
+ *lenptr = len + 1;
+ return buf;
+ }
+
+ /* We got out of the loop because we ran out of combinations to try. */
+ errno = EEXIST; /* ? */
+ return NULL;
+}
diff --git a/sysdeps/posix/truncate.c b/sysdeps/posix/truncate.c
new file mode 100644
index 0000000..9fe0d86
--- /dev/null
+++ b/sysdeps/posix/truncate.c
@@ -0,0 +1,41 @@
+/* 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. */
+
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Truncate PATH to LENGTH bytes. */
+int
+DEFUN(truncate, (path, length),
+ CONST char *path AND off_t length)
+{
+ int fd, ret, save;
+
+ fd = open (path, O_WRONLY);
+ if (fd < 0)
+ return -1;
+
+ ret = ftruncate (fd, length);
+ save = errno;
+ (void) close (fd);
+ if (ret < 0)
+ errno = save;
+ return ret;
+}
diff --git a/sysdeps/posix/ttyname.c b/sysdeps/posix/ttyname.c
new file mode 100644
index 0000000..50e3c79
--- /dev/null
+++ b/sysdeps/posix/ttyname.c
@@ -0,0 +1,82 @@
+/* Copyright (C) 1991, 1992, 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <limits.h>
+#include <stddef.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+
+char *__ttyname = NULL;
+
+/* Return the pathname of the terminal FD is open on, or NULL on errors.
+ The returned storage is good only until the next call to this function. */
+char *
+DEFUN(ttyname, (fd), int fd)
+{
+ static CONST char dev[] = "/dev";
+ static char *name;
+ static size_t namelen = 0;
+ struct stat st;
+ dev_t mydev;
+ ino_t myino;
+ DIR *dirstream;
+ struct dirent *d;
+ int save = errno;
+
+ if (fstat (fd, &st) < 0)
+ return NULL;
+ mydev = st.st_dev;
+ myino = st.st_ino;
+
+ dirstream = opendir (dev);
+ if (dirstream == NULL)
+ return NULL;
+
+ while ((d = readdir (dirstream)) != NULL)
+ if (d->d_fileno == myino)
+ {
+ if (sizeof (dev) + d->d_namlen + 1 > namelen)
+ {
+ free (name);
+ namelen = 2 * (sizeof (dev) + d->d_namlen + 1); /* Big enough. */
+ name = malloc (namelen);
+ if (! name)
+ return NULL;
+ (void) memcpy (name, dev, sizeof (dev) - 1);
+ name[sizeof (dev) - 1] = '/';
+ }
+ (void) memcpy (&name[sizeof (dev)], d->d_name, d->d_namlen + 1);
+ if (stat (name, &st) == 0 && st.st_dev == mydev)
+ {
+ (void) closedir (dirstream);
+ __ttyname = name;
+ errno = save;
+ return name;
+ }
+ }
+
+ (void) closedir (dirstream);
+ errno = save;
+ return NULL;
+}
diff --git a/sysdeps/posix/wait.c b/sysdeps/posix/wait.c
new file mode 100644
index 0000000..38891c7
--- /dev/null
+++ b/sysdeps/posix/wait.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <sys/wait.h>
+
+
+/* Wait for a child to die. When one does, put its status in *STAT_LOC
+ and return its process ID. For errors, return (pid_t) -1. */
+__pid_t
+DEFUN(__wait, (stat_loc), __WAIT_STATUS_DEFN stat_loc)
+{
+ return __waitpid(WAIT_ANY, (int *) stat_loc, 0);
+}
+
+weak_alias (__wait, wait)
diff --git a/sysdeps/posix/wait3.c b/sysdeps/posix/wait3.c
new file mode 100644
index 0000000..5eb084a
--- /dev/null
+++ b/sysdeps/posix/wait3.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <stddef.h>
+
+/* Wait for a child to exit. When one does, put its status in *STAT_LOC and
+ return its process ID. For errors return (pid_t) -1. If USAGE is not nil,
+ store information about the child's resource usage (as a `struct rusage')
+ there. If the WUNTRACED bit is set in OPTIONS, return status for stopped
+ children; otherwise don't. */
+pid_t
+DEFUN(__wait3, (stat_loc, options, usage),
+ __WAIT_STATUS_DEFN stat_loc AND int options AND struct rusage *usage)
+{
+ if (usage != NULL)
+ {
+ errno = ENOSYS;
+ return (pid_t) -1;
+ }
+ return __waitpid (WAIT_ANY, stat_loc, options);
+}
+
+weak_alias (__wait3, wait3)
diff --git a/sysdeps/posix/writev.c b/sysdeps/posix/writev.c
new file mode 100644
index 0000000..56e29a6
--- /dev/null
+++ b/sysdeps/posix/writev.c
@@ -0,0 +1,64 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/uio.h>
+
+/* Write data pointed by the buffers described by VECTOR, which
+ is a vector of COUNT `struct iovec's, to file descriptor FD.
+ The data is written in the order specified.
+ Operates just like `write' (see <unistd.h>) except that the data
+ are taken from VECTOR instead of a contiguous buffer. */
+int
+DEFUN(writev, (fd, vector, count),
+ int fd AND CONST struct iovec *vector AND size_t count)
+{
+ char *buffer;
+ register char *bp;
+ size_t bytes, to_copy;
+ register size_t i;
+
+ /* Find the total number of bytes to be written. */
+ bytes = 0;
+ for (i = 0; i < count; ++i)
+ bytes += vector[i].iov_len;
+
+ /* Allocate a temporary buffer to hold the data. */
+ buffer = (char *) __alloca(bytes);
+
+ /* Copy the data into BUFFER. */
+ to_copy = bytes;
+ bp = buffer;
+ for (i = 0; i < count; ++i)
+ {
+#define min(a, b) ((a) > (b) ? (b) : (a))
+ size_t copy = min(vector[i].iov_len, to_copy);
+
+ (void) memcpy((PTR) bp, (PTR) vector[i].iov_base, copy);
+
+ bp += copy;
+ to_copy -= copy;
+ if (bytes == 0)
+ break;
+ }
+
+ return write(fd, buffer, bytes);
+}
diff --git a/sysdeps/rs6000/ffs.c b/sysdeps/rs6000/ffs.c
new file mode 100644
index 0000000..44e7a43
--- /dev/null
+++ b/sysdeps/rs6000/ffs.c
@@ -0,0 +1,39 @@
+/* ffs -- find first set bit in a word, counted from least significant end.
+ For IBM rs6000.
+ Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+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. */
+
+#include <ansidecl.h>
+#include <bstring.h>
+
+#undef ffs
+
+#ifdef __GNUC__
+
+int
+DEFUN(ffs, (x), int x)
+{
+ int cnt;
+
+ asm ("cntlz %0,%1" : "=r" (cnt) : "r" (x & -x));
+ return 32 - cnt;
+}
+
+#else
+#include <sysdeps/generic/ffs.c>
+#endif
diff --git a/sysdeps/rs6000/memcopy.h b/sysdeps/rs6000/memcopy.h
new file mode 100644
index 0000000..873b312
--- /dev/null
+++ b/sysdeps/rs6000/memcopy.h
@@ -0,0 +1,86 @@
+/* Copyright (C) 1991 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. */
+
+#include <sysdeps/generic/memcopy.h>
+
+#undef OP_T_THRES
+#define OP_T_THRES 32
+
+#undef BYTE_COPY_FWD
+#define BYTE_COPY_FWD(dst_bp, src_bp, nbytes) \
+ do \
+ { \
+ size_t __nbytes = nbytes; \
+ asm volatile("mtspr 1,%2\n" \
+ "lsx 6,0,%1\n" \
+ "stsx 6,0,%0" : /* No outputs. */ : \
+ "b" (dst_bp), "b" (src_bp), "r" (__nbytes) : \
+ "6", "7", "8", "9", "10", "11", "12", "13"); \
+ dst_bp += __nbytes; \
+ src_bp += __nbytes; \
+ } while (0)
+
+#undef BYTE_COPY_BWD
+#define BYTE_COPY_BWD(dst_ep, src_ep, nbytes) \
+ do \
+ { \
+ size_t __nbytes = (nbytes); \
+ dst_ep -= __nbytes; \
+ src_ep -= __nbytes; \
+ asm volatile("mtspr 1,%2\n" \
+ "lsx 6,0,%1\n" \
+ "stsx 6,0,%0" : /* No outputs. */ : \
+ "b" (dst_ep), "b" (src_ep), "r" (__nbytes) : \
+ "6", "7", "8", "9", "10", "11", "12", "13"); \
+ } while (0)
+
+#undef WORD_COPY_FWD
+#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
+ do \
+ { \
+ size_t __nblocks = (nbytes) / 32; \
+ if (__nblocks != 0) \
+ asm volatile("mtctr %4\n" \
+ "lsi 6,%1,32\n" \
+ "ai %1,%1,32\n" \
+ "stsi 6,%0,32\n" \
+ "ai %0,%0,32\n" \
+ "bdn $-16" : \
+ "=b" (dst_bp), "=b" (src_bp) : \
+ "0" (dst_bp), "1" (src_bp), "r" (__nblocks) : \
+ "6", "7", "8", "9", "10", "11", "12", "13"); \
+ (nbytes_left) = (nbytes) % 32; \
+ } while (0)
+
+#undef WORD_COPY_BWD
+#define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \
+ do \
+ { \
+ size_t __nblocks = (nbytes) / 32; \
+ if (__nblocks != 0) \
+ asm volatile("mtctr %4\n" \
+ "ai %1,%1,-32\n" \
+ "lsi 6,%1,32\n" \
+ "ai %0,%0,-32\n" \
+ "stsi 6,%0,32\n" \
+ "bdn $-16" : \
+ "=b" (dst_ep), "=b" (src_ep) : \
+ "0" (dst_ep), "1" (src_ep), "r" (__nblocks) : \
+ "6", "7", "8", "9", "10", "11", "12", "13"); \
+ (nbytes_left) = (nbytes) % 32; \
+ } while (0)
diff --git a/sysdeps/sparc/DEFS.h b/sysdeps/sparc/DEFS.h
new file mode 100644
index 0000000..ef69663
--- /dev/null
+++ b/sysdeps/sparc/DEFS.h
@@ -0,0 +1,4 @@
+#define FUNC(name) \
+ .global name; \
+ .align 4; \
+ name:
diff --git a/sysdeps/sparc/Dist b/sysdeps/sparc/Dist
new file mode 100644
index 0000000..49cd4dc
--- /dev/null
+++ b/sysdeps/sparc/Dist
@@ -0,0 +1,4 @@
+DEFS.h
+mul.S umul.S
+divrem.m4 sdiv.S udiv.S rem.S urem.S
+alloca.S
diff --git a/sysdeps/sparc/Implies b/sysdeps/sparc/Implies
new file mode 100644
index 0000000..da719e1
--- /dev/null
+++ b/sysdeps/sparc/Implies
@@ -0,0 +1,2 @@
+# SPARC uses IEEE 754 floating point.
+ieee754
diff --git a/sysdeps/sparc/Makefile b/sysdeps/sparc/Makefile
new file mode 100644
index 0000000..1154d05
--- /dev/null
+++ b/sysdeps/sparc/Makefile
@@ -0,0 +1,57 @@
+# Copyright (C) 1991, 1992, 1993, 1994, 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.
+
+ifeq ($(subdir),gnulib)
+routines = mul umul $(divrem) alloca
+endif # gnulib
+
+# We distribute these files, even though they are generated,
+# so as to avoid the need for a functioning m4 to build the library.
+divrem := sdiv udiv rem urem
+
++divrem-NAME-sdiv := div
++divrem-NAME-udiv := udiv
++divrem-NAME-rem := rem
++divrem-NAME-urem := urem
++divrem-NAME = $(+divrem-NAME-$(basename $(notdir $@)))
++divrem-OP-div := div
++divrem-OP-udiv := div
++divrem-OP-rem := rem
++divrem-OP-urem := rem
++divrem-S-div := true
++divrem-S-rem := true
++divrem-S-udiv := false
++divrem-S-urem := false
+$(divrem:%=$(sysdep_dir)/sparc/%.S): $(sysdep_dir)/sparc/divrem.m4
+ (echo "define(NAME,\`.$(+divrem-NAME)')\
+ define(OP,\`$(+divrem-OP-$(+divrem-NAME))')\
+ define(S,\`$(+divrem-S-$(+divrem-NAME))')\
+ /* This file is generated from divrem.m4; DO NOT EDIT! */"; \
+ cat $<) | $(M4) > $@-tmp
+# Make it unwritable so noone will edit it by mistake.
+ -chmod a-w $@-tmp
+ mv -f $@-tmp $@
+ test -d CVS && cvs commit -m'Regenerated from $<' $@
+
+sysdep-realclean := $(sysdep-realclean) $(divrem:%=sysdeps/sparc/%.S)
+
+ifeq ($(subdir),crypt)
+
+crypt := crypt.sparc # Use crypt/crypt.sparc.S.
+
+endif # crypt
diff --git a/sysdeps/sparc/__longjmp.S b/sysdeps/sparc/__longjmp.S
new file mode 100644
index 0000000..adff06e
--- /dev/null
+++ b/sysdeps/sparc/__longjmp.S
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991, 1993 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. */
+
+#include <sysdep.h>
+#ifdef __svr4__
+#include <sys/trap.h>
+#else
+#include <machine/trap.h>
+#endif
+
+/* NOTE: This code depends on the definition of `__jmp_buf' in <jmp_buf.h>. */
+
+ENTRY (__longjmp)
+ /* Do a "flush register windows trap". The trap handler in the
+ kernel writes all the register windows to their stack slots, and
+ marks them all as invalid (needing to be sucked up from the
+ stack when used). This ensures that all information needed to
+ unwind to these callers is in memory, not in the register
+ windows. */
+ ta ST_FLUSH_WINDOWS
+ ld [%o0], %o7 /* Return PC. */
+ ld [%o0 + 4], %fp /* Saved SP. */
+ sub %fp, 64, %sp /* Allocate a register save area. */
+
+ /* if (%o1 == 0) %o1 = 1; */
+ tst %o1
+ be,a Ldone
+ mov 1, %o1
+
+Ldone: retl
+ /* On the way out, put the return value in %o0. */
+ restore %o1, 0, %o0
diff --git a/sysdeps/sparc/add_n.S b/sysdeps/sparc/add_n.S
new file mode 100644
index 0000000..3be3e39
--- /dev/null
+++ b/sysdeps/sparc/add_n.S
@@ -0,0 +1,134 @@
+! sparc __mpn_add_n -- Add two limb vectors of the same length > 0 and store
+! sum in a third limb vector.
+
+! Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+! INPUT PARAMETERS
+! res_ptr %o0
+! s1_ptr %o1
+! s2_ptr %o2
+! size %o3
+
+#include "sysdep.h"
+
+ .text
+ .align 4
+ .global C_SYMBOL_NAME(__mpn_add_n)
+C_SYMBOL_NAME(__mpn_add_n):
+ ld [%o1+0],%o4 ! read first limb from s1_ptr
+ srl %o3,4,%g1
+ ld [%o2+0],%o5 ! read first limb from s2_ptr
+
+ sub %g0,%o3,%o3
+ andcc %o3,(16-1),%o3
+ be Lzero
+ nop
+
+ sll %o3,2,%o3 ! multiply by 4
+ sub %o0,%o3,%o0 ! adjust res_ptr
+ sub %o1,%o3,%o1 ! adjust s1_ptr
+ sub %o2,%o3,%o2 ! adjust s2_ptr
+
+ mov %o4,%g2
+
+ sethi %hi(Lbase),%g3
+ or %g3,%lo(Lbase),%g3
+ sll %o3,2,%o3 ! multiply by 4
+ jmp %g3+%o3
+ mov %o5,%g3
+
+Loop: addxcc %g2,%g3,%o3
+ add %o1,64,%o1
+ st %o3,[%o0+60]
+ add %o2,64,%o2
+ ld [%o1+0],%o4
+ add %o0,64,%o0
+ ld [%o2+0],%o5
+Lzero: sub %g1,1,%g1 ! add 0 + 16r limbs (adjust loop counter)
+Lbase: ld [%o1+4],%g2
+ addxcc %o4,%o5,%o3
+ ld [%o2+4],%g3
+ st %o3,[%o0+0]
+ ld [%o1+8],%o4 ! add 15 + 16r limbs
+ addxcc %g2,%g3,%o3
+ ld [%o2+8],%o5
+ st %o3,[%o0+4]
+ ld [%o1+12],%g2 ! add 14 + 16r limbs
+ addxcc %o4,%o5,%o3
+ ld [%o2+12],%g3
+ st %o3,[%o0+8]
+ ld [%o1+16],%o4 ! add 13 + 16r limbs
+ addxcc %g2,%g3,%o3
+ ld [%o2+16],%o5
+ st %o3,[%o0+12]
+ ld [%o1+20],%g2 ! add 12 + 16r limbs
+ addxcc %o4,%o5,%o3
+ ld [%o2+20],%g3
+ st %o3,[%o0+16]
+ ld [%o1+24],%o4 ! add 11 + 16r limbs
+ addxcc %g2,%g3,%o3
+ ld [%o2+24],%o5
+ st %o3,[%o0+20]
+ ld [%o1+28],%g2 ! add 10 + 16r limbs
+ addxcc %o4,%o5,%o3
+ ld [%o2+28],%g3
+ st %o3,[%o0+24]
+ ld [%o1+32],%o4 ! add 9 + 16r limbs
+ addxcc %g2,%g3,%o3
+ ld [%o2+32],%o5
+ st %o3,[%o0+28]
+ ld [%o1+36],%g2 ! add 8 + 16r limbs
+ addxcc %o4,%o5,%o3
+ ld [%o2+36],%g3
+ st %o3,[%o0+32]
+ ld [%o1+40],%o4 ! add 7 + 16r limbs
+ addxcc %g2,%g3,%o3
+ ld [%o2+40],%o5
+ st %o3,[%o0+36]
+ ld [%o1+44],%g2 ! add 6 + 16r limbs
+ addxcc %o4,%o5,%o3
+ ld [%o2+44],%g3
+ st %o3,[%o0+40]
+ ld [%o1+48],%o4 ! add 5 + 16r limbs
+ addxcc %g2,%g3,%o3
+ ld [%o2+48],%o5
+ st %o3,[%o0+44]
+ ld [%o1+52],%g2 ! add 4 + 16r limbs
+ addxcc %o4,%o5,%o3
+ ld [%o2+52],%g3
+ st %o3,[%o0+48]
+ ld [%o1+56],%o4 ! add 3 + 16r limbs
+ addxcc %g2,%g3,%o3
+ ld [%o2+56],%o5
+ st %o3,[%o0+52]
+ ld [%o1+60],%g2 ! add 2 + 16r limbs
+ addxcc %o4,%o5,%o3
+ ld [%o2+60],%g3
+ st %o3,[%o0+56]
+ addx %g0,%g0,%o4
+ tst %g1
+ bne Loop
+ subcc %g0,%o4,%g0 ! restore cy (delay slot)
+
+ addxcc %g2,%g3,%o3
+ st %o3,[%o0+60] ! store most significant limb
+
+ retl
+ addx %g0,%g0,%o0 ! return carry-out from most sign. limb
diff --git a/sysdeps/sparc/addmul_1.S b/sysdeps/sparc/addmul_1.S
new file mode 100644
index 0000000..63e7db0
--- /dev/null
+++ b/sysdeps/sparc/addmul_1.S
@@ -0,0 +1,146 @@
+! SPARC __mpn_addmul_1 -- Multiply a limb vector with a limb and add
+! the result to a second limb vector.
+
+! Copyright (C) 1992, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+! INPUT PARAMETERS
+! res_ptr o0
+! s1_ptr o1
+! size o2
+! s2_limb o3
+
+#include "sysdep.h"
+
+.text
+ .align 4
+ .global C_SYMBOL_NAME(__mpn_addmul_1)
+C_SYMBOL_NAME(__mpn_addmul_1):
+ ! Make S1_PTR and RES_PTR point at the end of their blocks
+ ! and put (- 4 x SIZE) in index/loop counter.
+ sll %o2,2,%o2
+ add %o0,%o2,%o4 ! RES_PTR in o4 since o0 is retval
+ add %o1,%o2,%o1
+ sub %g0,%o2,%o2
+
+ cmp %o3,0xfff
+ bgu Large
+ nop
+
+ ld [%o1+%o2],%o5
+ mov 0,%o0
+ b L0
+ add %o4,-4,%o4
+Loop0:
+ addcc %o5,%g1,%g1
+ ld [%o1+%o2],%o5
+ addx %o0,%g0,%o0
+ st %g1,[%o4+%o2]
+L0: wr %g0,%o3,%y
+ sra %o5,31,%g2
+ and %o3,%g2,%g2
+ andcc %g1,0,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,0,%g1
+ sra %g1,20,%g4
+ sll %g1,12,%g1
+ rd %y,%g3
+ srl %g3,20,%g3
+ or %g1,%g3,%g1
+
+ addcc %g1,%o0,%g1
+ addx %g2,%g4,%o0 ! add sign-compensation and cy to hi limb
+ addcc %o2,4,%o2 ! loop counter
+ bne Loop0
+ ld [%o4+%o2],%o5
+
+ addcc %o5,%g1,%g1
+ addx %o0,%g0,%o0
+ retl
+ st %g1,[%o4+%o2]
+
+
+Large: ld [%o1+%o2],%o5
+ mov 0,%o0
+ sra %o3,31,%g4 ! g4 = mask of ones iff S2_LIMB < 0
+ b L1
+ add %o4,-4,%o4
+Loop:
+ addcc %o5,%g3,%g3
+ ld [%o1+%o2],%o5
+ addx %o0,%g0,%o0
+ st %g3,[%o4+%o2]
+L1: wr %g0,%o5,%y
+ and %o5,%g4,%g2
+ andcc %g0,%g0,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%g0,%g1
+ rd %y,%g3
+ addcc %g3,%o0,%g3
+ addx %g2,%g1,%o0
+ addcc %o2,4,%o2
+ bne Loop
+ ld [%o4+%o2],%o5
+
+ addcc %o5,%g3,%g3
+ addx %o0,%g0,%o0
+ retl
+ st %g3,[%o4+%o2]
diff --git a/sysdeps/sparc/alloca.S b/sysdeps/sparc/alloca.S
new file mode 100644
index 0000000..0a8718d
--- /dev/null
+++ b/sysdeps/sparc/alloca.S
@@ -0,0 +1,32 @@
+/* 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. */
+
+#include "DEFS.h"
+
+/* Code produced by Sun's C compiler calls this function with two extra
+ arguments which it makes relocatable symbols but seem always to be
+ the constant 96; I have no idea what they are for. */
+
+#ifndef NO_UNDERSCORES
+#define __builtin_alloca ___builtin_alloca
+#endif
+
+FUNC (__builtin_alloca)
+ sub %sp, %o0, %sp /* Push some stack space. */
+ retl /* Return; the returned buffer leaves 96 */
+ add %sp, 96, %o0 /* bytes of register save area at the top. */
diff --git a/sysdeps/sparc/bsd-_setjmp.S b/sysdeps/sparc/bsd-_setjmp.S
new file mode 100644
index 0000000..5b685d5
--- /dev/null
+++ b/sysdeps/sparc/bsd-_setjmp.S
@@ -0,0 +1,26 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. Sparc 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. */
+
+#include <sysdep.h>
+
+ENTRY (setjmp)
+ sethi %hi(C_SYMBOL_NAME (__sigsetjmp)), %g1
+ or %lo(C_SYMBOL_NAME (__sigsetjmp)), %g1, %g1
+ jmp %g1
+ mov %g0, %o1 /* Pass second argument of zero. */
diff --git a/sysdeps/sparc/bsd-setjmp.S b/sysdeps/sparc/bsd-setjmp.S
new file mode 100644
index 0000000..b0a6326
--- /dev/null
+++ b/sysdeps/sparc/bsd-setjmp.S
@@ -0,0 +1,26 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. Sparc 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. */
+
+#include <sysdep.h>
+
+ENTRY (setjmp)
+ sethi %hi(C_SYMBOL_NAME (__sigsetjmp)), %g1
+ or %lo(C_SYMBOL_NAME (__sigsetjmp)), %g1, %g1
+ jmp %g1
+ mov 1, %o1 /* Pass second argument of one. */
diff --git a/sysdeps/sparc/bytesex.h b/sysdeps/sparc/bytesex.h
new file mode 100644
index 0000000..f1a75c0
--- /dev/null
+++ b/sysdeps/sparc/bytesex.h
@@ -0,0 +1,3 @@
+/* SPARC is big-endian. */
+
+#define __BYTE_ORDER __BIG_ENDIAN
diff --git a/sysdeps/sparc/divrem.m4 b/sysdeps/sparc/divrem.m4
new file mode 100644
index 0000000..bde8a21
--- /dev/null
+++ b/sysdeps/sparc/divrem.m4
@@ -0,0 +1,234 @@
+/*
+ * Division and remainder, from Appendix E of the Sparc Version 8
+ * Architecture Manual, with fixes from Gordon Irlam.
+ */
+
+/*
+ * Input: dividend and divisor in %o0 and %o1 respectively.
+ *
+ * m4 parameters:
+ * NAME name of function to generate
+ * OP OP=div => %o0 / %o1; OP=rem => %o0 % %o1
+ * S S=true => signed; S=false => unsigned
+ *
+ * Algorithm parameters:
+ * N how many bits per iteration we try to get (4)
+ * WORDSIZE total number of bits (32)
+ *
+ * Derived constants:
+ * TOPBITS number of bits in the top `decade' of a number
+ *
+ * Important variables:
+ * Q the partial quotient under development (initially 0)
+ * R the remainder so far, initially the dividend
+ * ITER number of main division loop iterations required;
+ * equal to ceil(log2(quotient) / N). Note that this
+ * is the log base (2^N) of the quotient.
+ * V the current comparand, initially divisor*2^(ITER*N-1)
+ *
+ * Cost:
+ * Current estimate for non-large dividend is
+ * ceil(log2(quotient) / N) * (10 + 7N/2) + C
+ * A large dividend is one greater than 2^(31-TOPBITS) and takes a
+ * different path, as the upper bits of the quotient must be developed
+ * one bit at a time.
+ */
+
+define(N, `4')dnl
+define(WORDSIZE, `32')dnl
+define(TOPBITS, eval(WORDSIZE - N*((WORDSIZE-1)/N)))dnl
+dnl
+define(dividend, `%o0')dnl
+define(divisor, `%o1')dnl
+define(Q, `%o2')dnl
+define(R, `%o3')dnl
+define(ITER, `%o4')dnl
+define(V, `%o5')dnl
+dnl
+dnl m4 reminder: ifelse(a,b,c,d) => if a is b, then c, else d
+define(T, `%g1')dnl
+define(SC, `%g7')dnl
+ifelse(S, `true', `define(SIGN, `%g6')')dnl
+
+dnl
+dnl This is the recursive definition for developing quotient digits.
+dnl
+dnl Parameters:
+dnl $1 the current depth, 1 <= $1 <= N
+dnl $2 the current accumulation of quotient bits
+dnl N max depth
+dnl
+dnl We add a new bit to $2 and either recurse or insert the bits in
+dnl the quotient. R, Q, and V are inputs and outputs as defined above;
+dnl the condition codes are expected to reflect the input R, and are
+dnl modified to reflect the output R.
+dnl
+define(DEVELOP_QUOTIENT_BITS,
+` ! depth $1, accumulated bits $2
+ bl L.$1.eval(2**N+$2)
+ srl V,1,V
+ ! remainder is positive
+ subcc R,V,R
+ ifelse($1, N,
+ ` b 9f
+ add Q, ($2*2+1), Q
+ ', ` DEVELOP_QUOTIENT_BITS(incr($1), `eval(2*$2+1)')')
+L.$1.eval(2**N+$2):
+ ! remainder is negative
+ addcc R,V,R
+ ifelse($1, N,
+ ` b 9f
+ add Q, ($2*2-1), Q
+ ', ` DEVELOP_QUOTIENT_BITS(incr($1), `eval(2*$2-1)')')
+ ifelse($1, 1, `9:')')dnl
+
+#include "DEFS.h"
+#ifdef __svr4__
+#include <sys/trap.h>
+#else
+#include <machine/trap.h>
+#endif
+
+FUNC(NAME)
+ifelse(S, `true',
+` ! compute sign of result; if neither is negative, no problem
+ orcc divisor, dividend, %g0 ! either negative?
+ bge 2f ! no, go do the divide
+ifelse(OP, `div',
+` xor divisor, dividend, SIGN ! compute sign in any case',
+` mov dividend, SIGN ! sign of remainder matches dividend')
+ tst divisor
+ bge 1f
+ tst dividend
+ ! divisor is definitely negative; dividend might also be negative
+ bge 2f ! if dividend not negative...
+ sub %g0, divisor, divisor ! in any case, make divisor nonneg
+1: ! dividend is negative, divisor is nonnegative
+ sub %g0, dividend, dividend ! make dividend nonnegative
+2:
+')
+ ! Ready to divide. Compute size of quotient; scale comparand.
+ orcc divisor, %g0, V
+ bne 1f
+ mov dividend, R
+
+ ! Divide by zero trap. If it returns, return 0 (about as
+ ! wrong as possible, but that is what SunOS does...).
+ ta ST_DIV0
+ retl
+ clr %o0
+
+1:
+ cmp R, V ! if divisor exceeds dividend, done
+ blu Lgot_result ! (and algorithm fails otherwise)
+ clr Q
+ sethi %hi(1 << (WORDSIZE - TOPBITS - 1)), T
+ cmp R, T
+ blu Lnot_really_big
+ clr ITER
+
+ ! `Here the dividend is >= 2**(31-N) or so. We must be careful here,
+ ! as our usual N-at-a-shot divide step will cause overflow and havoc.
+ ! The number of bits in the result here is N*ITER+SC, where SC <= N.
+ ! Compute ITER in an unorthodox manner: know we need to shift V into
+ ! the top decade: so do not even bother to compare to R.'
+ 1:
+ cmp V, T
+ bgeu 3f
+ mov 1, SC
+ sll V, N, V
+ b 1b
+ add ITER, 1, ITER
+
+ ! Now compute SC.
+ 2: addcc V, V, V
+ bcc Lnot_too_big
+ add SC, 1, SC
+
+ ! We get here if the divisor overflowed while shifting.
+ ! This means that R has the high-order bit set.
+ ! Restore V and subtract from R.
+ sll T, TOPBITS, T ! high order bit
+ srl V, 1, V ! rest of V
+ add V, T, V
+ b Ldo_single_div
+ sub SC, 1, SC
+
+ Lnot_too_big:
+ 3: cmp V, R
+ blu 2b
+ nop
+ be Ldo_single_div
+ nop
+ /* NB: these are commented out in the V8-Sparc manual as well */
+ /* (I do not understand this) */
+ ! V > R: went too far: back up 1 step
+ ! srl V, 1, V
+ ! dec SC
+ ! do single-bit divide steps
+ !
+ ! We have to be careful here. We know that R >= V, so we can do the
+ ! first divide step without thinking. BUT, the others are conditional,
+ ! and are only done if R >= 0. Because both R and V may have the high-
+ ! order bit set in the first step, just falling into the regular
+ ! division loop will mess up the first time around.
+ ! So we unroll slightly...
+ Ldo_single_div:
+ subcc SC, 1, SC
+ bl Lend_regular_divide
+ nop
+ sub R, V, R
+ mov 1, Q
+ b Lend_single_divloop
+ nop
+ Lsingle_divloop:
+ sll Q, 1, Q
+ bl 1f
+ srl V, 1, V
+ ! R >= 0
+ sub R, V, R
+ b 2f
+ add Q, 1, Q
+ 1: ! R < 0
+ add R, V, R
+ sub Q, 1, Q
+ 2:
+ Lend_single_divloop:
+ subcc SC, 1, SC
+ bge Lsingle_divloop
+ tst R
+ b,a Lend_regular_divide
+
+Lnot_really_big:
+1:
+ sll V, N, V
+ cmp V, R
+ bleu 1b
+ addcc ITER, 1, ITER
+ be Lgot_result
+ sub ITER, 1, ITER
+
+ tst R ! set up for initial iteration
+Ldivloop:
+ sll Q, N, Q
+ DEVELOP_QUOTIENT_BITS(1, 0)
+Lend_regular_divide:
+ subcc ITER, 1, ITER
+ bge Ldivloop
+ tst R
+ bl,a Lgot_result
+ ! non-restoring fixup here (one instruction only!)
+ifelse(OP, `div',
+` sub Q, 1, Q
+', ` add R, divisor, R
+')
+
+Lgot_result:
+ifelse(S, `true',
+` ! check to see if answer should be < 0
+ tst SIGN
+ bl,a 1f
+ ifelse(OP, `div', `sub %g0, Q, Q', `sub %g0, R, R')
+1:')
+ retl
+ ifelse(OP, `div', `mov Q, %o0', `mov R, %o0')
diff --git a/sysdeps/sparc/jmp_buf.h b/sysdeps/sparc/jmp_buf.h
new file mode 100644
index 0000000..a5a592f
--- /dev/null
+++ b/sysdeps/sparc/jmp_buf.h
@@ -0,0 +1,14 @@
+/* Define the machine-dependent type `jmp_buf'. SPARC version. */
+
+/* NOTE: The assembly code in __longjmp.S and setjmp.S knows the layout
+ of this structure. You must hack the assembly code if you want to change
+ the order of the members. */
+
+typedef struct
+ {
+ /* Return PC (register o7). */
+ __ptr_t __pc;
+
+ /* Saved FP. */
+ __ptr_t __fp;
+ } __jmp_buf[1];
diff --git a/sysdeps/sparc/memcopy.h b/sysdeps/sparc/memcopy.h
new file mode 100644
index 0000000..3fd4f3d
--- /dev/null
+++ b/sysdeps/sparc/memcopy.h
@@ -0,0 +1,21 @@
+/* Copyright (C) 1991 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. */
+
+#include <sysdeps/generic/memcopy.h>
+#undef reg_char
+#define reg_char int
diff --git a/sysdeps/sparc/mul_1.S b/sysdeps/sparc/mul_1.S
new file mode 100644
index 0000000..84aa12b
--- /dev/null
+++ b/sysdeps/sparc/mul_1.S
@@ -0,0 +1,198 @@
+! SPARC __mpn_mul_1 -- Multiply a limb vector with a limb and store
+! the result in a second limb vector.
+
+! Copyright (C) 1992, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+! INPUT PARAMETERS
+! res_ptr o0
+! s1_ptr o1
+! size o2
+! s2_limb o3
+
+! ADD CODE FOR SMALL MULTIPLIERS!
+!1: ld
+! st
+!
+!2: ld ,a
+! addxcc a,a,x
+! st x,
+!
+!3_unrolled:
+! ld ,a
+! addxcc a,a,x1 ! 2a + cy
+! addx %g0,%g0,x2
+! addcc a,x1,x ! 3a + c
+! st x,
+!
+! ld ,a
+! addxcc a,a,y1
+! addx %g0,%g0,y2
+! addcc a,y1,x
+! st x,
+!
+!4_unrolled:
+! ld ,a
+! srl a,2,x1 ! 4a
+! addxcc y2,x1,x
+! sll a,30,x2
+! st x,
+!
+! ld ,a
+! srl a,2,y1
+! addxcc x2,y1,y
+! sll a,30,y2
+! st x,
+!
+!5_unrolled:
+! ld ,a
+! srl a,2,x1 ! 4a
+! addxcc a,x1,x ! 5a + c
+! sll a,30,x2
+! addx %g0,x2,x2
+! st x,
+!
+! ld ,a
+! srl a,2,y1
+! addxcc a,y1,x
+! sll a,30,y2
+! addx %g0,y2,y2
+! st x,
+!
+!8_unrolled:
+! ld ,a
+! srl a,3,x1 ! 8a
+! addxcc y2,x1,x
+! sll a,29,x2
+! st x,
+!
+! ld ,a
+! srl a,3,y1
+! addxcc x2,y1,y
+! sll a,29,y2
+! st x,
+
+#include "sysdep.h"
+
+.text
+ .align 4
+ .global C_SYMBOL_NAME(__mpn_mul_1)
+C_SYMBOL_NAME(__mpn_mul_1):
+ ! Make S1_PTR and RES_PTR point at the end of their blocks
+ ! and put (- 4 x SIZE) in index/loop counter.
+ sll %o2,2,%o2
+ add %o0,%o2,%o4 ! RES_PTR in o4 since o0 is retval
+ add %o1,%o2,%o1
+ sub %g0,%o2,%o2
+
+ cmp %o3,0xfff
+ bgu Large
+ nop
+
+ ld [%o1+%o2],%o5
+ mov 0,%o0
+ b L0
+ add %o4,-4,%o4
+Loop0:
+ st %g1,[%o4+%o2]
+L0: wr %g0,%o3,%y
+ sra %o5,31,%g2
+ and %o3,%g2,%g2
+ andcc %g1,0,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,0,%g1
+ sra %g1,20,%g4
+ sll %g1,12,%g1
+ rd %y,%g3
+ srl %g3,20,%g3
+ or %g1,%g3,%g1
+
+ addcc %g1,%o0,%g1
+ addx %g2,%g4,%o0 ! add sign-compensation and cy to hi limb
+ addcc %o2,4,%o2 ! loop counter
+ bne,a Loop0
+ ld [%o1+%o2],%o5
+
+ retl
+ st %g1,[%o4+%o2]
+
+
+Large: ld [%o1+%o2],%o5
+ mov 0,%o0
+ sra %o3,31,%g4 ! g4 = mask of ones iff S2_LIMB < 0
+ b L1
+ add %o4,-4,%o4
+Loop:
+ st %g3,[%o4+%o2]
+L1: wr %g0,%o5,%y
+ and %o5,%g4,%g2 ! g2 = S1_LIMB iff S2_LIMB < 0, else 0
+ andcc %g0,%g0,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%g0,%g1
+ rd %y,%g3
+ addcc %g3,%o0,%g3
+ addx %g2,%g1,%o0 ! add sign-compensation and cy to hi limb
+ addcc %o2,4,%o2 ! loop counter
+ bne,a Loop
+ ld [%o1+%o2],%o5
+
+ retl
+ st %g3,[%o4+%o2]
diff --git a/sysdeps/sparc/rem.S b/sysdeps/sparc/rem.S
new file mode 100644
index 0000000..17662f7
--- /dev/null
+++ b/sysdeps/sparc/rem.S
@@ -0,0 +1,365 @@
+ /* This file is generated from divrem.m4; DO NOT EDIT! */
+/*
+ * Division and remainder, from Appendix E of the Sparc Version 8
+ * Architecture Manual, with fixes from Gordon Irlam.
+ */
+
+/*
+ * Input: dividend and divisor in %o0 and %o1 respectively.
+ *
+ * m4 parameters:
+ * .rem name of function to generate
+ * rem rem=div => %o0 / %o1; rem=rem => %o0 % %o1
+ * true true=true => signed; true=false => unsigned
+ *
+ * Algorithm parameters:
+ * N how many bits per iteration we try to get (4)
+ * WORDSIZE total number of bits (32)
+ *
+ * Derived constants:
+ * TOPBITS number of bits in the top decade of a number
+ *
+ * Important variables:
+ * Q the partial quotient under development (initially 0)
+ * R the remainder so far, initially the dividend
+ * ITER number of main division loop iterations required;
+ * equal to ceil(log2(quotient) / N). Note that this
+ * is the log base (2^N) of the quotient.
+ * V the current comparand, initially divisor*2^(ITER*N-1)
+ *
+ * Cost:
+ * Current estimate for non-large dividend is
+ * ceil(log2(quotient) / N) * (10 + 7N/2) + C
+ * A large dividend is one greater than 2^(31-TOPBITS) and takes a
+ * different path, as the upper bits of the quotient must be developed
+ * one bit at a time.
+ */
+
+
+
+#include "DEFS.h"
+#ifdef __svr4__
+#include <sys/trap.h>
+#else
+#include <machine/trap.h>
+#endif
+
+FUNC(.rem)
+ ! compute sign of result; if neither is negative, no problem
+ orcc %o1, %o0, %g0 ! either negative?
+ bge 2f ! no, go do the divide
+ mov %o0, %g6 ! sign of remainder matches %o0
+ tst %o1
+ bge 1f
+ tst %o0
+ ! %o1 is definitely negative; %o0 might also be negative
+ bge 2f ! if %o0 not negative...
+ sub %g0, %o1, %o1 ! in any case, make %o1 nonneg
+1: ! %o0 is negative, %o1 is nonnegative
+ sub %g0, %o0, %o0 ! make %o0 nonnegative
+2:
+
+ ! Ready to divide. Compute size of quotient; scale comparand.
+ orcc %o1, %g0, %o5
+ bne 1f
+ mov %o0, %o3
+
+ ! Divide by zero trap. If it returns, return 0 (about as
+ ! wrong as possible, but that is what SunOS does...).
+ ta ST_DIV0
+ retl
+ clr %o0
+
+1:
+ cmp %o3, %o5 ! if %o1 exceeds %o0, done
+ blu Lgot_result ! (and algorithm fails otherwise)
+ clr %o2
+ sethi %hi(1 << (32 - 4 - 1)), %g1
+ cmp %o3, %g1
+ blu Lnot_really_big
+ clr %o4
+
+ ! Here the dividend is >= 2**(31-N) or so. We must be careful here,
+ ! as our usual N-at-a-shot divide step will cause overflow and havoc.
+ ! The number of bits in the result here is N*ITER+SC, where SC <= N.
+ ! Compute ITER in an unorthodox manner: know we need to shift V into
+ ! the top decade: so do not even bother to compare to R.
+ 1:
+ cmp %o5, %g1
+ bgeu 3f
+ mov 1, %g7
+ sll %o5, 4, %o5
+ b 1b
+ add %o4, 1, %o4
+
+ ! Now compute %g7.
+ 2: addcc %o5, %o5, %o5
+ bcc Lnot_too_big
+ add %g7, 1, %g7
+
+ ! We get here if the %o1 overflowed while shifting.
+ ! This means that %o3 has the high-order bit set.
+ ! Restore %o5 and subtract from %o3.
+ sll %g1, 4, %g1 ! high order bit
+ srl %o5, 1, %o5 ! rest of %o5
+ add %o5, %g1, %o5
+ b Ldo_single_div
+ sub %g7, 1, %g7
+
+ Lnot_too_big:
+ 3: cmp %o5, %o3
+ blu 2b
+ nop
+ be Ldo_single_div
+ nop
+ /* NB: these are commented out in the V8-Sparc manual as well */
+ /* (I do not understand this) */
+ ! %o5 > %o3: went too far: back up 1 step
+ ! srl %o5, 1, %o5
+ ! dec %g7
+ ! do single-bit divide steps
+ !
+ ! We have to be careful here. We know that %o3 >= %o5, so we can do the
+ ! first divide step without thinking. BUT, the others are conditional,
+ ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high-
+ ! order bit set in the first step, just falling into the regular
+ ! division loop will mess up the first time around.
+ ! So we unroll slightly...
+ Ldo_single_div:
+ subcc %g7, 1, %g7
+ bl Lend_regular_divide
+ nop
+ sub %o3, %o5, %o3
+ mov 1, %o2
+ b Lend_single_divloop
+ nop
+ Lsingle_divloop:
+ sll %o2, 1, %o2
+ bl 1f
+ srl %o5, 1, %o5
+ ! %o3 >= 0
+ sub %o3, %o5, %o3
+ b 2f
+ add %o2, 1, %o2
+ 1: ! %o3 < 0
+ add %o3, %o5, %o3
+ sub %o2, 1, %o2
+ 2:
+ Lend_single_divloop:
+ subcc %g7, 1, %g7
+ bge Lsingle_divloop
+ tst %o3
+ b,a Lend_regular_divide
+
+Lnot_really_big:
+1:
+ sll %o5, 4, %o5
+ cmp %o5, %o3
+ bleu 1b
+ addcc %o4, 1, %o4
+ be Lgot_result
+ sub %o4, 1, %o4
+
+ tst %o3 ! set up for initial iteration
+Ldivloop:
+ sll %o2, 4, %o2
+ ! depth 1, accumulated bits 0
+ bl L.1.16
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 2, accumulated bits 1
+ bl L.2.17
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 3, accumulated bits 3
+ bl L.3.19
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 7
+ bl L.4.23
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (7*2+1), %o2
+
+L.4.23:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (7*2-1), %o2
+
+
+L.3.19:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 5
+ bl L.4.21
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (5*2+1), %o2
+
+L.4.21:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (5*2-1), %o2
+
+
+
+L.2.17:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 3, accumulated bits 1
+ bl L.3.17
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 3
+ bl L.4.19
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (3*2+1), %o2
+
+L.4.19:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (3*2-1), %o2
+
+
+L.3.17:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 1
+ bl L.4.17
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (1*2+1), %o2
+
+L.4.17:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (1*2-1), %o2
+
+
+
+
+L.1.16:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 2, accumulated bits -1
+ bl L.2.15
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 3, accumulated bits -1
+ bl L.3.15
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -1
+ bl L.4.15
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-1*2+1), %o2
+
+L.4.15:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-1*2-1), %o2
+
+
+L.3.15:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -3
+ bl L.4.13
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-3*2+1), %o2
+
+L.4.13:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-3*2-1), %o2
+
+
+
+L.2.15:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 3, accumulated bits -3
+ bl L.3.13
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -5
+ bl L.4.11
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-5*2+1), %o2
+
+L.4.11:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-5*2-1), %o2
+
+
+L.3.13:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -7
+ bl L.4.9
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-7*2+1), %o2
+
+L.4.9:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-7*2-1), %o2
+
+
+
+
+ 9:
+Lend_regular_divide:
+ subcc %o4, 1, %o4
+ bge Ldivloop
+ tst %o3
+ bl,a Lgot_result
+ ! non-restoring fixup here (one instruction only!)
+ add %o3, %o1, %o3
+
+
+Lgot_result:
+ ! check to see if answer should be < 0
+ tst %g6
+ bl,a 1f
+ sub %g0, %o3, %o3
+1:
+ retl
+ mov %o3, %o0
diff --git a/sysdeps/sparc/sdiv.S b/sysdeps/sparc/sdiv.S
new file mode 100644
index 0000000..dadbb36
--- /dev/null
+++ b/sysdeps/sparc/sdiv.S
@@ -0,0 +1,365 @@
+ /* This file is generated from divrem.m4; DO NOT EDIT! */
+/*
+ * Division and remainder, from Appendix E of the Sparc Version 8
+ * Architecture Manual, with fixes from Gordon Irlam.
+ */
+
+/*
+ * Input: dividend and divisor in %o0 and %o1 respectively.
+ *
+ * m4 parameters:
+ * .div name of function to generate
+ * div div=div => %o0 / %o1; div=rem => %o0 % %o1
+ * true true=true => signed; true=false => unsigned
+ *
+ * Algorithm parameters:
+ * N how many bits per iteration we try to get (4)
+ * WORDSIZE total number of bits (32)
+ *
+ * Derived constants:
+ * TOPBITS number of bits in the top decade of a number
+ *
+ * Important variables:
+ * Q the partial quotient under development (initially 0)
+ * R the remainder so far, initially the dividend
+ * ITER number of main division loop iterations required;
+ * equal to ceil(log2(quotient) / N). Note that this
+ * is the log base (2^N) of the quotient.
+ * V the current comparand, initially divisor*2^(ITER*N-1)
+ *
+ * Cost:
+ * Current estimate for non-large dividend is
+ * ceil(log2(quotient) / N) * (10 + 7N/2) + C
+ * A large dividend is one greater than 2^(31-TOPBITS) and takes a
+ * different path, as the upper bits of the quotient must be developed
+ * one bit at a time.
+ */
+
+
+
+#include "DEFS.h"
+#ifdef __svr4__
+#include <sys/trap.h>
+#else
+#include <machine/trap.h>
+#endif
+
+FUNC(.div)
+ ! compute sign of result; if neither is negative, no problem
+ orcc %o1, %o0, %g0 ! either negative?
+ bge 2f ! no, go do the divide
+ xor %o1, %o0, %g6 ! compute sign in any case
+ tst %o1
+ bge 1f
+ tst %o0
+ ! %o1 is definitely negative; %o0 might also be negative
+ bge 2f ! if %o0 not negative...
+ sub %g0, %o1, %o1 ! in any case, make %o1 nonneg
+1: ! %o0 is negative, %o1 is nonnegative
+ sub %g0, %o0, %o0 ! make %o0 nonnegative
+2:
+
+ ! Ready to divide. Compute size of quotient; scale comparand.
+ orcc %o1, %g0, %o5
+ bne 1f
+ mov %o0, %o3
+
+ ! Divide by zero trap. If it returns, return 0 (about as
+ ! wrong as possible, but that is what SunOS does...).
+ ta ST_DIV0
+ retl
+ clr %o0
+
+1:
+ cmp %o3, %o5 ! if %o1 exceeds %o0, done
+ blu Lgot_result ! (and algorithm fails otherwise)
+ clr %o2
+ sethi %hi(1 << (32 - 4 - 1)), %g1
+ cmp %o3, %g1
+ blu Lnot_really_big
+ clr %o4
+
+ ! Here the dividend is >= 2**(31-N) or so. We must be careful here,
+ ! as our usual N-at-a-shot divide step will cause overflow and havoc.
+ ! The number of bits in the result here is N*ITER+SC, where SC <= N.
+ ! Compute ITER in an unorthodox manner: know we need to shift V into
+ ! the top decade: so do not even bother to compare to R.
+ 1:
+ cmp %o5, %g1
+ bgeu 3f
+ mov 1, %g7
+ sll %o5, 4, %o5
+ b 1b
+ add %o4, 1, %o4
+
+ ! Now compute %g7.
+ 2: addcc %o5, %o5, %o5
+ bcc Lnot_too_big
+ add %g7, 1, %g7
+
+ ! We get here if the %o1 overflowed while shifting.
+ ! This means that %o3 has the high-order bit set.
+ ! Restore %o5 and subtract from %o3.
+ sll %g1, 4, %g1 ! high order bit
+ srl %o5, 1, %o5 ! rest of %o5
+ add %o5, %g1, %o5
+ b Ldo_single_div
+ sub %g7, 1, %g7
+
+ Lnot_too_big:
+ 3: cmp %o5, %o3
+ blu 2b
+ nop
+ be Ldo_single_div
+ nop
+ /* NB: these are commented out in the V8-Sparc manual as well */
+ /* (I do not understand this) */
+ ! %o5 > %o3: went too far: back up 1 step
+ ! srl %o5, 1, %o5
+ ! dec %g7
+ ! do single-bit divide steps
+ !
+ ! We have to be careful here. We know that %o3 >= %o5, so we can do the
+ ! first divide step without thinking. BUT, the others are conditional,
+ ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high-
+ ! order bit set in the first step, just falling into the regular
+ ! division loop will mess up the first time around.
+ ! So we unroll slightly...
+ Ldo_single_div:
+ subcc %g7, 1, %g7
+ bl Lend_regular_divide
+ nop
+ sub %o3, %o5, %o3
+ mov 1, %o2
+ b Lend_single_divloop
+ nop
+ Lsingle_divloop:
+ sll %o2, 1, %o2
+ bl 1f
+ srl %o5, 1, %o5
+ ! %o3 >= 0
+ sub %o3, %o5, %o3
+ b 2f
+ add %o2, 1, %o2
+ 1: ! %o3 < 0
+ add %o3, %o5, %o3
+ sub %o2, 1, %o2
+ 2:
+ Lend_single_divloop:
+ subcc %g7, 1, %g7
+ bge Lsingle_divloop
+ tst %o3
+ b,a Lend_regular_divide
+
+Lnot_really_big:
+1:
+ sll %o5, 4, %o5
+ cmp %o5, %o3
+ bleu 1b
+ addcc %o4, 1, %o4
+ be Lgot_result
+ sub %o4, 1, %o4
+
+ tst %o3 ! set up for initial iteration
+Ldivloop:
+ sll %o2, 4, %o2
+ ! depth 1, accumulated bits 0
+ bl L.1.16
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 2, accumulated bits 1
+ bl L.2.17
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 3, accumulated bits 3
+ bl L.3.19
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 7
+ bl L.4.23
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (7*2+1), %o2
+
+L.4.23:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (7*2-1), %o2
+
+
+L.3.19:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 5
+ bl L.4.21
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (5*2+1), %o2
+
+L.4.21:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (5*2-1), %o2
+
+
+
+L.2.17:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 3, accumulated bits 1
+ bl L.3.17
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 3
+ bl L.4.19
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (3*2+1), %o2
+
+L.4.19:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (3*2-1), %o2
+
+
+L.3.17:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 1
+ bl L.4.17
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (1*2+1), %o2
+
+L.4.17:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (1*2-1), %o2
+
+
+
+
+L.1.16:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 2, accumulated bits -1
+ bl L.2.15
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 3, accumulated bits -1
+ bl L.3.15
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -1
+ bl L.4.15
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-1*2+1), %o2
+
+L.4.15:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-1*2-1), %o2
+
+
+L.3.15:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -3
+ bl L.4.13
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-3*2+1), %o2
+
+L.4.13:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-3*2-1), %o2
+
+
+
+L.2.15:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 3, accumulated bits -3
+ bl L.3.13
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -5
+ bl L.4.11
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-5*2+1), %o2
+
+L.4.11:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-5*2-1), %o2
+
+
+L.3.13:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -7
+ bl L.4.9
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-7*2+1), %o2
+
+L.4.9:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-7*2-1), %o2
+
+
+
+
+ 9:
+Lend_regular_divide:
+ subcc %o4, 1, %o4
+ bge Ldivloop
+ tst %o3
+ bl,a Lgot_result
+ ! non-restoring fixup here (one instruction only!)
+ sub %o2, 1, %o2
+
+
+Lgot_result:
+ ! check to see if answer should be < 0
+ tst %g6
+ bl,a 1f
+ sub %g0, %o2, %o2
+1:
+ retl
+ mov %o2, %o0
diff --git a/sysdeps/sparc/setjmp.S b/sysdeps/sparc/setjmp.S
new file mode 100644
index 0000000..3c9c18d
--- /dev/null
+++ b/sysdeps/sparc/setjmp.S
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <sysdep.h>
+
+/* NOTE: This code depends on the definition of `__jmp_buf' in <jmp_buf.h>. */
+
+ENTRY (__sigsetjmp)
+ /* Save our return PC and SP (second store in the jmp delay slot). */
+ st %o7, [%o0]
+ /* Save the signal mask if requested. We do this as a tail-call
+ for simplicity; it always returns zero. */
+ sethi %hi(C_SYMBOL_NAME (__sigjmp_save)), %g1
+ or %lo(C_SYMBOL_NAME (__sigjmp_save)), %g1, %g1
+ jmp %g1
+ st %sp, [%o0 + 4]
diff --git a/sysdeps/sparc/sparc8/addmul_1.S b/sysdeps/sparc/sparc8/addmul_1.S
new file mode 100644
index 0000000..fbaacfd
--- /dev/null
+++ b/sysdeps/sparc/sparc8/addmul_1.S
@@ -0,0 +1,116 @@
+! SPARC v8 __mpn_addmul_1 -- Multiply a limb vector with a limb and
+! add the result to a second limb vector.
+
+! Copyright (C) 1992, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+! INPUT PARAMETERS
+! res_ptr o0
+! s1_ptr o1
+! size o2
+! s2_limb o3
+
+#include "sysdep.h"
+
+.text
+ .align 4
+ .global C_SYMBOL_NAME(__mpn_addmul_1)
+C_SYMBOL_NAME(__mpn_addmul_1):
+ orcc %g0,%g0,%g2
+ ld [%o1+0],%o4 ! 1
+
+ sll %o2,4,%g1
+ and %g1,(4-1)<<4,%g1
+ sethi %hi(LL),%g3
+ or %g3,%lo(LL),%g3
+ jmp %g3+%g1
+ nop
+LL:
+LL00: add %o0,-4,%o0
+ b Loop00 /* 4, 8, 12, ... */
+ add %o1,-4,%o1
+ nop
+LL01: b Loop01 /* 1, 5, 9, ... */
+ nop
+ nop
+ nop
+LL10: add %o0,-12,%o0 /* 2, 6, 10, ... */
+ b Loop10
+ add %o1,4,%o1
+ nop
+LL11: add %o0,-8,%o0 /* 3, 7, 11, ... */
+ b Loop11
+ add %o1,-8,%o1
+ nop
+
+1: addcc %g3,%g2,%g3 ! 1
+ ld [%o1+4],%o4 ! 2
+ rd %y,%g2 ! 1
+ addx %g0,%g2,%g2
+ ld [%o0+0],%g1 ! 2
+ addcc %g1,%g3,%g3
+ st %g3,[%o0+0] ! 1
+Loop00: umul %o4,%o3,%g3 ! 2
+ ld [%o0+4],%g1 ! 2
+ addxcc %g3,%g2,%g3 ! 2
+ ld [%o1+8],%o4 ! 3
+ rd %y,%g2 ! 2
+ addx %g0,%g2,%g2
+ nop
+ addcc %g1,%g3,%g3
+ st %g3,[%o0+4] ! 2
+Loop11: umul %o4,%o3,%g3 ! 3
+ addxcc %g3,%g2,%g3 ! 3
+ ld [%o1+12],%o4 ! 4
+ rd %y,%g2 ! 3
+ add %o1,16,%o1
+ addx %g0,%g2,%g2
+ ld [%o0+8],%g1 ! 2
+ addcc %g1,%g3,%g3
+ st %g3,[%o0+8] ! 3
+Loop10: umul %o4,%o3,%g3 ! 4
+ addxcc %g3,%g2,%g3 ! 4
+ ld [%o1+0],%o4 ! 1
+ rd %y,%g2 ! 4
+ addx %g0,%g2,%g2
+ ld [%o0+12],%g1 ! 2
+ addcc %g1,%g3,%g3
+ st %g3,[%o0+12] ! 4
+ add %o0,16,%o0
+ addx %g0,%g2,%g2
+Loop01: addcc %o2,-4,%o2
+ bg 1b
+ umul %o4,%o3,%g3 ! 1
+
+ addcc %g3,%g2,%g3 ! 4
+ rd %y,%g2 ! 4
+ addx %g0,%g2,%g2
+ ld [%o0+0],%g1 ! 2
+ addcc %g1,%g3,%g3
+ st %g3,[%o0+0] ! 4
+ addx %g0,%g2,%o0
+
+ retl
+ nop
+
+
+! umul, ld, addxcc, rd, st
+
+! umul, ld, addxcc, rd, ld, addcc, st, addx
+
diff --git a/sysdeps/sparc/sparc8/mul_1.S b/sysdeps/sparc/sparc8/mul_1.S
new file mode 100644
index 0000000..9c21768
--- /dev/null
+++ b/sysdeps/sparc/sparc8/mul_1.S
@@ -0,0 +1,91 @@
+! SPARC v8 __mpn_mul_1 -- Multiply a limb vector with a single limb and
+! store the product in a second limb vector.
+
+! Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+! INPUT PARAMETERS
+! res_ptr o0
+! s1_ptr o1
+! size o2
+! s2_limb o3
+
+#include "sysdep.h"
+
+.text
+ .align 8
+ .global C_SYMBOL_NAME(__mpn_mul_1)
+C_SYMBOL_NAME(__mpn_mul_1):
+ sll %o2,4,%g1
+ and %g1,(4-1)<<4,%g1
+ sethi %hi(LL),%g3
+ or %g3,%lo(LL),%g3
+ jmp %g3+%g1
+ ld [%o1+0],%o4 ! 1
+LL:
+LL00: add %o0,-4,%o0
+ add %o1,-4,%o1
+ b Loop00 /* 4, 8, 12, ... */
+ orcc %g0,%g0,%g2
+LL01: b Loop01 /* 1, 5, 9, ... */
+ orcc %g0,%g0,%g2
+ nop
+ nop
+LL10: add %o0,-12,%o0 /* 2, 6, 10, ... */
+ add %o1,4,%o1
+ b Loop10
+ orcc %g0,%g0,%g2
+ nop
+LL11: add %o0,-8,%o0 /* 3, 7, 11, ... */
+ add %o1,-8,%o1
+ b Loop11
+ orcc %g0,%g0,%g2
+
+Loop: addcc %g3,%g2,%g3 ! 1
+ ld [%o1+4],%o4 ! 2
+ st %g3,[%o0+0] ! 1
+ rd %y,%g2 ! 1
+Loop00: umul %o4,%o3,%g3 ! 2
+ addxcc %g3,%g2,%g3 ! 2
+ ld [%o1+8],%o4 ! 3
+ st %g3,[%o0+4] ! 2
+ rd %y,%g2 ! 2
+Loop11: umul %o4,%o3,%g3 ! 3
+ addxcc %g3,%g2,%g3 ! 3
+ ld [%o1+12],%o4 ! 4
+ add %o1,16,%o1
+ st %g3,[%o0+8] ! 3
+ rd %y,%g2 ! 3
+Loop10: umul %o4,%o3,%g3 ! 4
+ addxcc %g3,%g2,%g3 ! 4
+ ld [%o1+0],%o4 ! 1
+ st %g3,[%o0+12] ! 4
+ add %o0,16,%o0
+ rd %y,%g2 ! 4
+ addx %g0,%g2,%g2
+Loop01: addcc %o2,-4,%o2
+ bg Loop
+ umul %o4,%o3,%g3 ! 1
+
+ addcc %g3,%g2,%g3 ! 4
+ st %g3,[%o0+0] ! 4
+ rd %y,%g2 ! 4
+
+ retl
+ addx %g0,%g2,%o0
diff --git a/sysdeps/sparc/sparc8/submul_1.S b/sysdeps/sparc/sparc8/submul_1.S
new file mode 100644
index 0000000..5c4d688
--- /dev/null
+++ b/sysdeps/sparc/sparc8/submul_1.S
@@ -0,0 +1,57 @@
+! SPARC v8 __mpn_submul_1 -- Multiply a limb vector with a limb and
+! subtract the result from a second limb vector.
+
+! Copyright (C) 1992, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+! INPUT PARAMETERS
+! res_ptr o0
+! s1_ptr o1
+! size o2
+! s2_limb o3
+
+#include "sysdep.h"
+
+.text
+ .align 4
+ .global C_SYMBOL_NAME(__mpn_submul_1)
+C_SYMBOL_NAME(__mpn_submul_1):
+ sub %g0,%o2,%o2 ! negate ...
+ sll %o2,2,%o2 ! ... and scale size
+ sub %o1,%o2,%o1 ! o1 is offset s1_ptr
+ sub %o0,%o2,%g1 ! g1 is offset res_ptr
+
+ mov 0,%o0 ! clear cy_limb
+
+Loop: ld [%o1+%o2],%o4
+ ld [%g1+%o2],%g2
+ umul %o4,%o3,%o5
+ rd %y,%g3
+ addcc %o5,%o0,%o5
+ addx %g3,0,%o0
+ subcc %g2,%o5,%g2
+ addx %o0,0,%o0
+ st %g2,[%g1+%o2]
+
+ addcc %o2,4,%o2
+ bne Loop
+ nop
+
+ retl
+ nop
diff --git a/sysdeps/sparc/sparc8/udiv_qrnnd.S b/sysdeps/sparc/sparc8/udiv_qrnnd.S
new file mode 100644
index 0000000..49c2398
--- /dev/null
+++ b/sysdeps/sparc/sparc8/udiv_qrnnd.S
@@ -0,0 +1,186 @@
+! SPARC __udiv_qrnnd division support, used from longlong.h.
+
+! Copyright (C) 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+! INPUT PARAMETERS
+! rem_ptr o0
+! n1 o1
+! n0 o2
+! d o3
+
+#include "sysdep.h"
+
+ .text
+ .align 4
+ .global C_SYMBOL_NAME(__udiv_qrnnd)
+C_SYMBOL_NAME(__udiv_qrnnd):
+ tst %o3
+ bneg Largedivisor
+ mov 8,%g1
+
+ b Lp1
+ addxcc %o2,%o2,%o2
+
+Lplop: bcc Ln1
+ addxcc %o2,%o2,%o2
+Lp1: addx %o1,%o1,%o1
+ subcc %o1,%o3,%o4
+ bcc Ln2
+ addxcc %o2,%o2,%o2
+Lp2: addx %o1,%o1,%o1
+ subcc %o1,%o3,%o4
+ bcc Ln3
+ addxcc %o2,%o2,%o2
+Lp3: addx %o1,%o1,%o1
+ subcc %o1,%o3,%o4
+ bcc Ln4
+ addxcc %o2,%o2,%o2
+Lp4: addx %o1,%o1,%o1
+ addcc %g1,-1,%g1
+ bne Lplop
+ subcc %o1,%o3,%o4
+ bcc Ln5
+ addxcc %o2,%o2,%o2
+Lp5: st %o1,[%o0]
+ retl
+ xnor %g0,%o2,%o0
+
+Lnlop: bcc Lp1
+ addxcc %o2,%o2,%o2
+Ln1: addx %o4,%o4,%o4
+ subcc %o4,%o3,%o1
+ bcc Lp2
+ addxcc %o2,%o2,%o2
+Ln2: addx %o4,%o4,%o4
+ subcc %o4,%o3,%o1
+ bcc Lp3
+ addxcc %o2,%o2,%o2
+Ln3: addx %o4,%o4,%o4
+ subcc %o4,%o3,%o1
+ bcc Lp4
+ addxcc %o2,%o2,%o2
+Ln4: addx %o4,%o4,%o4
+ addcc %g1,-1,%g1
+ bne Lnlop
+ subcc %o4,%o3,%o1
+ bcc Lp5
+ addxcc %o2,%o2,%o2
+Ln5: st %o4,[%o0]
+ retl
+ xnor %g0,%o2,%o0
+
+Largedivisor:
+ and %o2,1,%o5 ! %o5 = n0 & 1
+
+ srl %o2,1,%o2
+ sll %o1,31,%g2
+ or %g2,%o2,%o2 ! %o2 = lo(n1n0 >> 1)
+ srl %o1,1,%o1 ! %o1 = hi(n1n0 >> 1)
+
+ and %o3,1,%g2
+ srl %o3,1,%g3 ! %g3 = floor(d / 2)
+ add %g3,%g2,%g3 ! %g3 = ceil(d / 2)
+
+ b LLp1
+ addxcc %o2,%o2,%o2
+
+LLplop: bcc LLn1
+ addxcc %o2,%o2,%o2
+LLp1: addx %o1,%o1,%o1
+ subcc %o1,%g3,%o4
+ bcc LLn2
+ addxcc %o2,%o2,%o2
+LLp2: addx %o1,%o1,%o1
+ subcc %o1,%g3,%o4
+ bcc LLn3
+ addxcc %o2,%o2,%o2
+LLp3: addx %o1,%o1,%o1
+ subcc %o1,%g3,%o4
+ bcc LLn4
+ addxcc %o2,%o2,%o2
+LLp4: addx %o1,%o1,%o1
+ addcc %g1,-1,%g1
+ bne LLplop
+ subcc %o1,%g3,%o4
+ bcc LLn5
+ addxcc %o2,%o2,%o2
+LLp5: add %o1,%o1,%o1 ! << 1
+ tst %g2
+ bne Oddp
+ add %o5,%o1,%o1
+ st %o1,[%o0]
+ retl
+ xnor %g0,%o2,%o0
+
+LLnlop: bcc LLp1
+ addxcc %o2,%o2,%o2
+LLn1: addx %o4,%o4,%o4
+ subcc %o4,%g3,%o1
+ bcc LLp2
+ addxcc %o2,%o2,%o2
+LLn2: addx %o4,%o4,%o4
+ subcc %o4,%g3,%o1
+ bcc LLp3
+ addxcc %o2,%o2,%o2
+LLn3: addx %o4,%o4,%o4
+ subcc %o4,%g3,%o1
+ bcc LLp4
+ addxcc %o2,%o2,%o2
+LLn4: addx %o4,%o4,%o4
+ addcc %g1,-1,%g1
+ bne LLnlop
+ subcc %o4,%g3,%o1
+ bcc LLp5
+ addxcc %o2,%o2,%o2
+LLn5: add %o4,%o4,%o4 ! << 1
+ tst %g2
+ bne Oddn
+ add %o5,%o4,%o4
+ st %o4,[%o0]
+ retl
+ xnor %g0,%o2,%o0
+
+Oddp: xnor %g0,%o2,%o2
+ ! q' in %o2. r' in %o1
+ addcc %o1,%o2,%o1
+ bcc LLp6
+ addx %o2,0,%o2
+ sub %o1,%o3,%o1
+LLp6: subcc %o1,%o3,%g0
+ bcs LLp7
+ subx %o2,-1,%o2
+ sub %o1,%o3,%o1
+LLp7: st %o1,[%o0]
+ retl
+ mov %o2,%o0
+
+Oddn: xnor %g0,%o2,%o2
+ ! q' in %o2. r' in %o4
+ addcc %o4,%o2,%o4
+ bcc LLn6
+ addx %o2,0,%o2
+ sub %o4,%o3,%o4
+LLn6: subcc %o4,%o3,%g0
+ bcs LLn7
+ subx %o2,-1,%o2
+ sub %o4,%o3,%o4
+LLn7: st %o4,[%o0]
+ retl
+ mov %o2,%o0
diff --git a/sysdeps/sparc/sqrt.c b/sysdeps/sparc/sqrt.c
new file mode 100644
index 0000000..bff46e1
--- /dev/null
+++ b/sysdeps/sparc/sqrt.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+#ifndef __GNUC__
+ #error This file uses GNU C extensions; you must compile with GCC.
+#endif
+
+/* Return the square root of X. */
+double
+DEFUN(sqrt, (x), double x)
+{
+ register double result;
+ asm("fsqrtd %1, %0" : "=f" (result) : "f" (x));
+ return result;
+}
diff --git a/sysdeps/sparc/sub_n.S b/sysdeps/sparc/sub_n.S
new file mode 100644
index 0000000..7a167b2
--- /dev/null
+++ b/sysdeps/sparc/sub_n.S
@@ -0,0 +1,134 @@
+! sparc __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
+! store difference in a third limb vector.
+
+! Copyright (C) 1992, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+! INPUT PARAMETERS
+! res_ptr %o0
+! s1_ptr %o1
+! s2_ptr %o2
+! size %o3
+
+#include "sysdep.h"
+
+ .text
+ .align 4
+ .global C_SYMBOL_NAME(__mpn_sub_n)
+C_SYMBOL_NAME(__mpn_sub_n):
+ ld [%o1+0],%o4 ! read first limb from s1_ptr
+ srl %o3,4,%g1
+ ld [%o2+0],%o5 ! read first limb from s2_ptr
+
+ sub %g0,%o3,%o3
+ andcc %o3,(16-1),%o3
+ be Lzero
+ nop
+
+ sll %o3,2,%o3 ! multiply by 4
+ sub %o0,%o3,%o0 ! adjust res_ptr
+ sub %o1,%o3,%o1 ! adjust s1_ptr
+ sub %o2,%o3,%o2 ! adjust s2_ptr
+
+ mov %o4,%g2
+
+ sethi %hi(Lbase),%g3
+ or %g3,%lo(Lbase),%g3
+ sll %o3,2,%o3 ! multiply by 4
+ jmp %g3+%o3
+ mov %o5,%g3
+
+Loop: subxcc %g2,%g3,%o3
+ add %o1,64,%o1
+ st %o3,[%o0+60]
+ add %o2,64,%o2
+ ld [%o1+0],%o4
+ add %o0,64,%o0
+ ld [%o2+0],%o5
+Lzero: sub %g1,1,%g1 ! add 0 + 16r limbs (adjust loop counter)
+Lbase: ld [%o1+4],%g2
+ subxcc %o4,%o5,%o3
+ ld [%o2+4],%g3
+ st %o3,[%o0+0]
+ ld [%o1+8],%o4 ! add 15 + 16r limbs
+ subxcc %g2,%g3,%o3
+ ld [%o2+8],%o5
+ st %o3,[%o0+4]
+ ld [%o1+12],%g2 ! add 14 + 16r limbs
+ subxcc %o4,%o5,%o3
+ ld [%o2+12],%g3
+ st %o3,[%o0+8]
+ ld [%o1+16],%o4 ! add 13 + 16r limbs
+ subxcc %g2,%g3,%o3
+ ld [%o2+16],%o5
+ st %o3,[%o0+12]
+ ld [%o1+20],%g2 ! add 12 + 16r limbs
+ subxcc %o4,%o5,%o3
+ ld [%o2+20],%g3
+ st %o3,[%o0+16]
+ ld [%o1+24],%o4 ! add 11 + 16r limbs
+ subxcc %g2,%g3,%o3
+ ld [%o2+24],%o5
+ st %o3,[%o0+20]
+ ld [%o1+28],%g2 ! add 10 + 16r limbs
+ subxcc %o4,%o5,%o3
+ ld [%o2+28],%g3
+ st %o3,[%o0+24]
+ ld [%o1+32],%o4 ! add 9 + 16r limbs
+ subxcc %g2,%g3,%o3
+ ld [%o2+32],%o5
+ st %o3,[%o0+28]
+ ld [%o1+36],%g2 ! add 8 + 16r limbs
+ subxcc %o4,%o5,%o3
+ ld [%o2+36],%g3
+ st %o3,[%o0+32]
+ ld [%o1+40],%o4 ! add 7 + 16r limbs
+ subxcc %g2,%g3,%o3
+ ld [%o2+40],%o5
+ st %o3,[%o0+36]
+ ld [%o1+44],%g2 ! add 6 + 16r limbs
+ subxcc %o4,%o5,%o3
+ ld [%o2+44],%g3
+ st %o3,[%o0+40]
+ ld [%o1+48],%o4 ! add 5 + 16r limbs
+ subxcc %g2,%g3,%o3
+ ld [%o2+48],%o5
+ st %o3,[%o0+44]
+ ld [%o1+52],%g2 ! add 4 + 16r limbs
+ subxcc %o4,%o5,%o3
+ ld [%o2+52],%g3
+ st %o3,[%o0+48]
+ ld [%o1+56],%o4 ! add 3 + 16r limbs
+ subxcc %g2,%g3,%o3
+ ld [%o2+56],%o5
+ st %o3,[%o0+52]
+ ld [%o1+60],%g2 ! add 2 + 16r limbs
+ subxcc %o4,%o5,%o3
+ ld [%o2+60],%g3
+ st %o3,[%o0+56]
+ subx %g0,%g0,%o4
+ tst %g1
+ bne Loop
+ subcc %g0,%o4,%g0 ! restore cy (delay slot)
+
+ subxcc %g2,%g3,%o3
+ st %o3,[%o0+60] ! store most significant limb
+
+ retl
+ addx %g0,%g0,%o0 ! return carry-out from most sign. limb
diff --git a/sysdeps/sparc/submul_1.S b/sysdeps/sparc/submul_1.S
new file mode 100644
index 0000000..ed67c99
--- /dev/null
+++ b/sysdeps/sparc/submul_1.S
@@ -0,0 +1,146 @@
+! SPARC __mpn_submul_1 -- Multiply a limb vector with a limb and subtract
+! the result from a second limb vector.
+
+! Copyright (C) 1992, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+! INPUT PARAMETERS
+! res_ptr o0
+! s1_ptr o1
+! size o2
+! s2_limb o3
+
+#include "sysdep.h"
+
+.text
+ .align 4
+ .global C_SYMBOL_NAME(__mpn_submul_1)
+C_SYMBOL_NAME(__mpn_submul_1):
+ ! Make S1_PTR and RES_PTR point at the end of their blocks
+ ! and put (- 4 x SIZE) in index/loop counter.
+ sll %o2,2,%o2
+ add %o0,%o2,%o4 ! RES_PTR in o4 since o0 is retval
+ add %o1,%o2,%o1
+ sub %g0,%o2,%o2
+
+ cmp %o3,0xfff
+ bgu Large
+ nop
+
+ ld [%o1+%o2],%o5
+ mov 0,%o0
+ b L0
+ add %o4,-4,%o4
+Loop0:
+ subcc %o5,%g1,%g1
+ ld [%o1+%o2],%o5
+ addx %o0,%g0,%o0
+ st %g1,[%o4+%o2]
+L0: wr %g0,%o3,%y
+ sra %o5,31,%g2
+ and %o3,%g2,%g2
+ andcc %g1,0,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,%o5,%g1
+ mulscc %g1,0,%g1
+ sra %g1,20,%g4
+ sll %g1,12,%g1
+ rd %y,%g3
+ srl %g3,20,%g3
+ or %g1,%g3,%g1
+
+ addcc %g1,%o0,%g1
+ addx %g2,%g4,%o0 ! add sign-compensation and cy to hi limb
+ addcc %o2,4,%o2 ! loop counter
+ bne Loop0
+ ld [%o4+%o2],%o5
+
+ subcc %o5,%g1,%g1
+ addx %o0,%g0,%o0
+ retl
+ st %g1,[%o4+%o2]
+
+
+Large: ld [%o1+%o2],%o5
+ mov 0,%o0
+ sra %o3,31,%g4 ! g4 = mask of ones iff S2_LIMB < 0
+ b L1
+ add %o4,-4,%o4
+Loop:
+ subcc %o5,%g3,%g3
+ ld [%o1+%o2],%o5
+ addx %o0,%g0,%o0
+ st %g3,[%o4+%o2]
+L1: wr %g0,%o5,%y
+ and %o5,%g4,%g2
+ andcc %g0,%g0,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%o3,%g1
+ mulscc %g1,%g0,%g1
+ rd %y,%g3
+ addcc %g3,%o0,%g3
+ addx %g2,%g1,%o0
+ addcc %o2,4,%o2
+ bne Loop
+ ld [%o4+%o2],%o5
+
+ subcc %o5,%g3,%g3
+ addx %o0,%g0,%o0
+ retl
+ st %g3,[%o4+%o2]
diff --git a/sysdeps/sparc/udiv.S b/sysdeps/sparc/udiv.S
new file mode 100644
index 0000000..826d011
--- /dev/null
+++ b/sysdeps/sparc/udiv.S
@@ -0,0 +1,348 @@
+ /* This file is generated from divrem.m4; DO NOT EDIT! */
+/*
+ * Division and remainder, from Appendix E of the Sparc Version 8
+ * Architecture Manual, with fixes from Gordon Irlam.
+ */
+
+/*
+ * Input: dividend and divisor in %o0 and %o1 respectively.
+ *
+ * m4 parameters:
+ * .udiv name of function to generate
+ * div div=div => %o0 / %o1; div=rem => %o0 % %o1
+ * false false=true => signed; false=false => unsigned
+ *
+ * Algorithm parameters:
+ * N how many bits per iteration we try to get (4)
+ * WORDSIZE total number of bits (32)
+ *
+ * Derived constants:
+ * TOPBITS number of bits in the top decade of a number
+ *
+ * Important variables:
+ * Q the partial quotient under development (initially 0)
+ * R the remainder so far, initially the dividend
+ * ITER number of main division loop iterations required;
+ * equal to ceil(log2(quotient) / N). Note that this
+ * is the log base (2^N) of the quotient.
+ * V the current comparand, initially divisor*2^(ITER*N-1)
+ *
+ * Cost:
+ * Current estimate for non-large dividend is
+ * ceil(log2(quotient) / N) * (10 + 7N/2) + C
+ * A large dividend is one greater than 2^(31-TOPBITS) and takes a
+ * different path, as the upper bits of the quotient must be developed
+ * one bit at a time.
+ */
+
+
+
+#include "DEFS.h"
+#ifdef __svr4__
+#include <sys/trap.h>
+#else
+#include <machine/trap.h>
+#endif
+
+FUNC(.udiv)
+
+ ! Ready to divide. Compute size of quotient; scale comparand.
+ orcc %o1, %g0, %o5
+ bne 1f
+ mov %o0, %o3
+
+ ! Divide by zero trap. If it returns, return 0 (about as
+ ! wrong as possible, but that is what SunOS does...).
+ ta ST_DIV0
+ retl
+ clr %o0
+
+1:
+ cmp %o3, %o5 ! if %o1 exceeds %o0, done
+ blu Lgot_result ! (and algorithm fails otherwise)
+ clr %o2
+ sethi %hi(1 << (32 - 4 - 1)), %g1
+ cmp %o3, %g1
+ blu Lnot_really_big
+ clr %o4
+
+ ! Here the dividend is >= 2**(31-N) or so. We must be careful here,
+ ! as our usual N-at-a-shot divide step will cause overflow and havoc.
+ ! The number of bits in the result here is N*ITER+SC, where SC <= N.
+ ! Compute ITER in an unorthodox manner: know we need to shift V into
+ ! the top decade: so do not even bother to compare to R.
+ 1:
+ cmp %o5, %g1
+ bgeu 3f
+ mov 1, %g7
+ sll %o5, 4, %o5
+ b 1b
+ add %o4, 1, %o4
+
+ ! Now compute %g7.
+ 2: addcc %o5, %o5, %o5
+ bcc Lnot_too_big
+ add %g7, 1, %g7
+
+ ! We get here if the %o1 overflowed while shifting.
+ ! This means that %o3 has the high-order bit set.
+ ! Restore %o5 and subtract from %o3.
+ sll %g1, 4, %g1 ! high order bit
+ srl %o5, 1, %o5 ! rest of %o5
+ add %o5, %g1, %o5
+ b Ldo_single_div
+ sub %g7, 1, %g7
+
+ Lnot_too_big:
+ 3: cmp %o5, %o3
+ blu 2b
+ nop
+ be Ldo_single_div
+ nop
+ /* NB: these are commented out in the V8-Sparc manual as well */
+ /* (I do not understand this) */
+ ! %o5 > %o3: went too far: back up 1 step
+ ! srl %o5, 1, %o5
+ ! dec %g7
+ ! do single-bit divide steps
+ !
+ ! We have to be careful here. We know that %o3 >= %o5, so we can do the
+ ! first divide step without thinking. BUT, the others are conditional,
+ ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high-
+ ! order bit set in the first step, just falling into the regular
+ ! division loop will mess up the first time around.
+ ! So we unroll slightly...
+ Ldo_single_div:
+ subcc %g7, 1, %g7
+ bl Lend_regular_divide
+ nop
+ sub %o3, %o5, %o3
+ mov 1, %o2
+ b Lend_single_divloop
+ nop
+ Lsingle_divloop:
+ sll %o2, 1, %o2
+ bl 1f
+ srl %o5, 1, %o5
+ ! %o3 >= 0
+ sub %o3, %o5, %o3
+ b 2f
+ add %o2, 1, %o2
+ 1: ! %o3 < 0
+ add %o3, %o5, %o3
+ sub %o2, 1, %o2
+ 2:
+ Lend_single_divloop:
+ subcc %g7, 1, %g7
+ bge Lsingle_divloop
+ tst %o3
+ b,a Lend_regular_divide
+
+Lnot_really_big:
+1:
+ sll %o5, 4, %o5
+ cmp %o5, %o3
+ bleu 1b
+ addcc %o4, 1, %o4
+ be Lgot_result
+ sub %o4, 1, %o4
+
+ tst %o3 ! set up for initial iteration
+Ldivloop:
+ sll %o2, 4, %o2
+ ! depth 1, accumulated bits 0
+ bl L.1.16
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 2, accumulated bits 1
+ bl L.2.17
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 3, accumulated bits 3
+ bl L.3.19
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 7
+ bl L.4.23
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (7*2+1), %o2
+
+L.4.23:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (7*2-1), %o2
+
+
+L.3.19:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 5
+ bl L.4.21
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (5*2+1), %o2
+
+L.4.21:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (5*2-1), %o2
+
+
+
+L.2.17:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 3, accumulated bits 1
+ bl L.3.17
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 3
+ bl L.4.19
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (3*2+1), %o2
+
+L.4.19:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (3*2-1), %o2
+
+
+L.3.17:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 1
+ bl L.4.17
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (1*2+1), %o2
+
+L.4.17:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (1*2-1), %o2
+
+
+
+
+L.1.16:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 2, accumulated bits -1
+ bl L.2.15
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 3, accumulated bits -1
+ bl L.3.15
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -1
+ bl L.4.15
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-1*2+1), %o2
+
+L.4.15:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-1*2-1), %o2
+
+
+L.3.15:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -3
+ bl L.4.13
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-3*2+1), %o2
+
+L.4.13:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-3*2-1), %o2
+
+
+
+L.2.15:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 3, accumulated bits -3
+ bl L.3.13
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -5
+ bl L.4.11
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-5*2+1), %o2
+
+L.4.11:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-5*2-1), %o2
+
+
+L.3.13:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -7
+ bl L.4.9
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-7*2+1), %o2
+
+L.4.9:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-7*2-1), %o2
+
+
+
+
+ 9:
+Lend_regular_divide:
+ subcc %o4, 1, %o4
+ bge Ldivloop
+ tst %o3
+ bl,a Lgot_result
+ ! non-restoring fixup here (one instruction only!)
+ sub %o2, 1, %o2
+
+
+Lgot_result:
+
+ retl
+ mov %o2, %o0
diff --git a/sysdeps/sparc/udiv_qrnnd.S b/sysdeps/sparc/udiv_qrnnd.S
new file mode 100644
index 0000000..4cd4f05
--- /dev/null
+++ b/sysdeps/sparc/udiv_qrnnd.S
@@ -0,0 +1,143 @@
+! SPARC __udiv_qrnnd division support, used from longlong.h.
+
+! Copyright (C) 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+! INPUT PARAMETERS
+! rem_ptr i0
+! n1 i1
+! n0 i2
+! d i3
+
+#include "sysdep.h"
+#undef ret /* Kludge for glibc */
+
+ .text
+ .align 8
+LC0: .double 0r4294967296
+LC1: .double 0r2147483648
+
+ .align 4
+ .global C_SYMBOL_NAME(__udiv_qrnnd)
+C_SYMBOL_NAME(__udiv_qrnnd):
+ !#PROLOGUE# 0
+ save %sp,-104,%sp
+ !#PROLOGUE# 1
+ st %i1,[%fp-8]
+ ld [%fp-8],%f10
+ sethi %hi(LC0),%o7
+ fitod %f10,%f4
+ ldd [%o7+%lo(LC0)],%f8
+ cmp %i1,0
+ bge L248
+ mov %i0,%i5
+ faddd %f4,%f8,%f4
+L248:
+ st %i2,[%fp-8]
+ ld [%fp-8],%f10
+ fmuld %f4,%f8,%f6
+ cmp %i2,0
+ bge L249
+ fitod %f10,%f2
+ faddd %f2,%f8,%f2
+L249:
+ st %i3,[%fp-8]
+ faddd %f6,%f2,%f2
+ ld [%fp-8],%f10
+ cmp %i3,0
+ bge L250
+ fitod %f10,%f4
+ faddd %f4,%f8,%f4
+L250:
+ fdivd %f2,%f4,%f2
+ sethi %hi(LC1),%o7
+ ldd [%o7+%lo(LC1)],%f4
+ fcmped %f2,%f4
+ nop
+ fbge,a L251
+ fsubd %f2,%f4,%f2
+ fdtoi %f2,%f2
+ st %f2,[%fp-8]
+ b L252
+ ld [%fp-8],%i4
+L251:
+ fdtoi %f2,%f2
+ st %f2,[%fp-8]
+ ld [%fp-8],%i4
+ sethi %hi(-2147483648),%g2
+ xor %i4,%g2,%i4
+L252:
+ wr %g0,%i4,%y
+ sra %i3,31,%g2
+ and %i4,%g2,%g2
+ andcc %g0,0,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,%i3,%g1
+ mulscc %g1,0,%g1
+ add %g1,%g2,%i0
+ rd %y,%g3
+ subcc %i2,%g3,%o7
+ subxcc %i1,%i0,%g0
+ be L253
+ cmp %o7,%i3
+
+ add %i4,-1,%i0
+ add %o7,%i3,%o7
+ st %o7,[%i5]
+ ret
+ restore
+L253:
+ blu L246
+ mov %i4,%i0
+ add %i4,1,%i0
+ sub %o7,%i3,%o7
+L246:
+ st %o7,[%i5]
+ ret
+ restore
diff --git a/sysdeps/sparc/umul.S b/sysdeps/sparc/umul.S
new file mode 100644
index 0000000..7a26c29
--- /dev/null
+++ b/sysdeps/sparc/umul.S
@@ -0,0 +1,153 @@
+/*
+ * Unsigned multiply. Returns %o0 * %o1 in %o1%o0 (i.e., %o1 holds the
+ * upper 32 bits of the 64-bit product).
+ *
+ * This code optimizes short (less than 13-bit) multiplies. Short
+ * multiplies require 25 instruction cycles, and long ones require
+ * 45 instruction cycles.
+ *
+ * On return, overflow has occurred (%o1 is not zero) if and only if
+ * the Z condition code is clear, allowing, e.g., the following:
+ *
+ * call .umul
+ * nop
+ * bnz overflow (or tnz)
+ */
+
+#include "DEFS.h"
+FUNC(.umul)
+ or %o0, %o1, %o4
+ mov %o0, %y ! multiplier -> Y
+ andncc %o4, 0xfff, %g0 ! test bits 12..31 of *both* args
+ be Lmul_shortway ! if zero, can do it the short way
+ andcc %g0, %g0, %o4 ! zero the partial product and clear N and V
+
+ /*
+ * Long multiply. 32 steps, followed by a final shift step.
+ */
+ mulscc %o4, %o1, %o4 ! 1
+ mulscc %o4, %o1, %o4 ! 2
+ mulscc %o4, %o1, %o4 ! 3
+ mulscc %o4, %o1, %o4 ! 4
+ mulscc %o4, %o1, %o4 ! 5
+ mulscc %o4, %o1, %o4 ! 6
+ mulscc %o4, %o1, %o4 ! 7
+ mulscc %o4, %o1, %o4 ! 8
+ mulscc %o4, %o1, %o4 ! 9
+ mulscc %o4, %o1, %o4 ! 10
+ mulscc %o4, %o1, %o4 ! 11
+ mulscc %o4, %o1, %o4 ! 12
+ mulscc %o4, %o1, %o4 ! 13
+ mulscc %o4, %o1, %o4 ! 14
+ mulscc %o4, %o1, %o4 ! 15
+ mulscc %o4, %o1, %o4 ! 16
+ mulscc %o4, %o1, %o4 ! 17
+ mulscc %o4, %o1, %o4 ! 18
+ mulscc %o4, %o1, %o4 ! 19
+ mulscc %o4, %o1, %o4 ! 20
+ mulscc %o4, %o1, %o4 ! 21
+ mulscc %o4, %o1, %o4 ! 22
+ mulscc %o4, %o1, %o4 ! 23
+ mulscc %o4, %o1, %o4 ! 24
+ mulscc %o4, %o1, %o4 ! 25
+ mulscc %o4, %o1, %o4 ! 26
+ mulscc %o4, %o1, %o4 ! 27
+ mulscc %o4, %o1, %o4 ! 28
+ mulscc %o4, %o1, %o4 ! 29
+ mulscc %o4, %o1, %o4 ! 30
+ mulscc %o4, %o1, %o4 ! 31
+ mulscc %o4, %o1, %o4 ! 32
+ mulscc %o4, %g0, %o4 ! final shift
+
+
+ /*
+ * Normally, with the shift-and-add approach, if both numbers are
+ * positive you get the correct result. With 32-bit two's-complement
+ * numbers, -x is represented as
+ *
+ * x 32
+ * ( 2 - ------ ) mod 2 * 2
+ * 32
+ * 2
+ *
+ * (the `mod 2' subtracts 1 from 1.bbbb). To avoid lots of 2^32s,
+ * we can treat this as if the radix point were just to the left
+ * of the sign bit (multiply by 2^32), and get
+ *
+ * -x = (2 - x) mod 2
+ *
+ * Then, ignoring the `mod 2's for convenience:
+ *
+ * x * y = xy
+ * -x * y = 2y - xy
+ * x * -y = 2x - xy
+ * -x * -y = 4 - 2x - 2y + xy
+ *
+ * For signed multiplies, we subtract (x << 32) from the partial
+ * product to fix this problem for negative multipliers (see mul.s).
+ * Because of the way the shift into the partial product is calculated
+ * (N xor V), this term is automatically removed for the multiplicand,
+ * so we don't have to adjust.
+ *
+ * But for unsigned multiplies, the high order bit wasn't a sign bit,
+ * and the correction is wrong. So for unsigned multiplies where the
+ * high order bit is one, we end up with xy - (y << 32). To fix it
+ * we add y << 32.
+ */
+#if 0
+ tst %o1
+ bl,a 1f ! if %o1 < 0 (high order bit = 1),
+ add %o4, %o0, %o4 ! %o4 += %o0 (add y to upper half)
+1: rd %y, %o0 ! get lower half of product
+ retl
+ addcc %o4, %g0, %o1 ! put upper half in place and set Z for %o1==0
+#else
+ /* Faster code from tege@sics.se. */
+ sra %o1, 31, %o2 ! make mask from sign bit
+ and %o0, %o2, %o2 ! %o2 = 0 or %o0, depending on sign of %o1
+ rd %y, %o0 ! get lower half of product
+ retl
+ addcc %o4, %o2, %o1 ! add compensation and put upper half in place
+#endif
+
+Lmul_shortway:
+ /*
+ * Short multiply. 12 steps, followed by a final shift step.
+ * The resulting bits are off by 12 and (32-12) = 20 bit positions,
+ * but there is no problem with %o0 being negative (unlike above),
+ * and overflow is impossible (the answer is at most 24 bits long).
+ */
+ mulscc %o4, %o1, %o4 ! 1
+ mulscc %o4, %o1, %o4 ! 2
+ mulscc %o4, %o1, %o4 ! 3
+ mulscc %o4, %o1, %o4 ! 4
+ mulscc %o4, %o1, %o4 ! 5
+ mulscc %o4, %o1, %o4 ! 6
+ mulscc %o4, %o1, %o4 ! 7
+ mulscc %o4, %o1, %o4 ! 8
+ mulscc %o4, %o1, %o4 ! 9
+ mulscc %o4, %o1, %o4 ! 10
+ mulscc %o4, %o1, %o4 ! 11
+ mulscc %o4, %o1, %o4 ! 12
+ mulscc %o4, %g0, %o4 ! final shift
+
+ /*
+ * %o4 has 20 of the bits that should be in the result; %y has
+ * the bottom 12 (as %y's top 12). That is:
+ *
+ * %o4 %y
+ * +----------------+----------------+
+ * | -12- | -20- | -12- | -20- |
+ * +------(---------+------)---------+
+ * -----result-----
+ *
+ * The 12 bits of %o4 left of the `result' area are all zero;
+ * in fact, all top 20 bits of %o4 are zero.
+ */
+
+ rd %y, %o5
+ sll %o4, 12, %o0 ! shift middle bits left 12
+ srl %o5, 20, %o5 ! shift low bits right 20
+ or %o5, %o0, %o0
+ retl
+ addcc %g0, %g0, %o1 ! %o1 = zero, and set Z
diff --git a/sysdeps/sparc/urem.S b/sysdeps/sparc/urem.S
new file mode 100644
index 0000000..9f64c88
--- /dev/null
+++ b/sysdeps/sparc/urem.S
@@ -0,0 +1,348 @@
+ /* This file is generated from divrem.m4; DO NOT EDIT! */
+/*
+ * Division and remainder, from Appendix E of the Sparc Version 8
+ * Architecture Manual, with fixes from Gordon Irlam.
+ */
+
+/*
+ * Input: dividend and divisor in %o0 and %o1 respectively.
+ *
+ * m4 parameters:
+ * .urem name of function to generate
+ * rem rem=div => %o0 / %o1; rem=rem => %o0 % %o1
+ * false false=true => signed; false=false => unsigned
+ *
+ * Algorithm parameters:
+ * N how many bits per iteration we try to get (4)
+ * WORDSIZE total number of bits (32)
+ *
+ * Derived constants:
+ * TOPBITS number of bits in the top decade of a number
+ *
+ * Important variables:
+ * Q the partial quotient under development (initially 0)
+ * R the remainder so far, initially the dividend
+ * ITER number of main division loop iterations required;
+ * equal to ceil(log2(quotient) / N). Note that this
+ * is the log base (2^N) of the quotient.
+ * V the current comparand, initially divisor*2^(ITER*N-1)
+ *
+ * Cost:
+ * Current estimate for non-large dividend is
+ * ceil(log2(quotient) / N) * (10 + 7N/2) + C
+ * A large dividend is one greater than 2^(31-TOPBITS) and takes a
+ * different path, as the upper bits of the quotient must be developed
+ * one bit at a time.
+ */
+
+
+
+#include "DEFS.h"
+#ifdef __svr4__
+#include <sys/trap.h>
+#else
+#include <machine/trap.h>
+#endif
+
+FUNC(.urem)
+
+ ! Ready to divide. Compute size of quotient; scale comparand.
+ orcc %o1, %g0, %o5
+ bne 1f
+ mov %o0, %o3
+
+ ! Divide by zero trap. If it returns, return 0 (about as
+ ! wrong as possible, but that is what SunOS does...).
+ ta ST_DIV0
+ retl
+ clr %o0
+
+1:
+ cmp %o3, %o5 ! if %o1 exceeds %o0, done
+ blu Lgot_result ! (and algorithm fails otherwise)
+ clr %o2
+ sethi %hi(1 << (32 - 4 - 1)), %g1
+ cmp %o3, %g1
+ blu Lnot_really_big
+ clr %o4
+
+ ! Here the dividend is >= 2**(31-N) or so. We must be careful here,
+ ! as our usual N-at-a-shot divide step will cause overflow and havoc.
+ ! The number of bits in the result here is N*ITER+SC, where SC <= N.
+ ! Compute ITER in an unorthodox manner: know we need to shift V into
+ ! the top decade: so do not even bother to compare to R.
+ 1:
+ cmp %o5, %g1
+ bgeu 3f
+ mov 1, %g7
+ sll %o5, 4, %o5
+ b 1b
+ add %o4, 1, %o4
+
+ ! Now compute %g7.
+ 2: addcc %o5, %o5, %o5
+ bcc Lnot_too_big
+ add %g7, 1, %g7
+
+ ! We get here if the %o1 overflowed while shifting.
+ ! This means that %o3 has the high-order bit set.
+ ! Restore %o5 and subtract from %o3.
+ sll %g1, 4, %g1 ! high order bit
+ srl %o5, 1, %o5 ! rest of %o5
+ add %o5, %g1, %o5
+ b Ldo_single_div
+ sub %g7, 1, %g7
+
+ Lnot_too_big:
+ 3: cmp %o5, %o3
+ blu 2b
+ nop
+ be Ldo_single_div
+ nop
+ /* NB: these are commented out in the V8-Sparc manual as well */
+ /* (I do not understand this) */
+ ! %o5 > %o3: went too far: back up 1 step
+ ! srl %o5, 1, %o5
+ ! dec %g7
+ ! do single-bit divide steps
+ !
+ ! We have to be careful here. We know that %o3 >= %o5, so we can do the
+ ! first divide step without thinking. BUT, the others are conditional,
+ ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high-
+ ! order bit set in the first step, just falling into the regular
+ ! division loop will mess up the first time around.
+ ! So we unroll slightly...
+ Ldo_single_div:
+ subcc %g7, 1, %g7
+ bl Lend_regular_divide
+ nop
+ sub %o3, %o5, %o3
+ mov 1, %o2
+ b Lend_single_divloop
+ nop
+ Lsingle_divloop:
+ sll %o2, 1, %o2
+ bl 1f
+ srl %o5, 1, %o5
+ ! %o3 >= 0
+ sub %o3, %o5, %o3
+ b 2f
+ add %o2, 1, %o2
+ 1: ! %o3 < 0
+ add %o3, %o5, %o3
+ sub %o2, 1, %o2
+ 2:
+ Lend_single_divloop:
+ subcc %g7, 1, %g7
+ bge Lsingle_divloop
+ tst %o3
+ b,a Lend_regular_divide
+
+Lnot_really_big:
+1:
+ sll %o5, 4, %o5
+ cmp %o5, %o3
+ bleu 1b
+ addcc %o4, 1, %o4
+ be Lgot_result
+ sub %o4, 1, %o4
+
+ tst %o3 ! set up for initial iteration
+Ldivloop:
+ sll %o2, 4, %o2
+ ! depth 1, accumulated bits 0
+ bl L.1.16
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 2, accumulated bits 1
+ bl L.2.17
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 3, accumulated bits 3
+ bl L.3.19
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 7
+ bl L.4.23
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (7*2+1), %o2
+
+L.4.23:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (7*2-1), %o2
+
+
+L.3.19:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 5
+ bl L.4.21
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (5*2+1), %o2
+
+L.4.21:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (5*2-1), %o2
+
+
+
+L.2.17:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 3, accumulated bits 1
+ bl L.3.17
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 3
+ bl L.4.19
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (3*2+1), %o2
+
+L.4.19:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (3*2-1), %o2
+
+
+L.3.17:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits 1
+ bl L.4.17
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (1*2+1), %o2
+
+L.4.17:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (1*2-1), %o2
+
+
+
+
+L.1.16:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 2, accumulated bits -1
+ bl L.2.15
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 3, accumulated bits -1
+ bl L.3.15
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -1
+ bl L.4.15
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-1*2+1), %o2
+
+L.4.15:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-1*2-1), %o2
+
+
+L.3.15:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -3
+ bl L.4.13
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-3*2+1), %o2
+
+L.4.13:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-3*2-1), %o2
+
+
+
+L.2.15:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 3, accumulated bits -3
+ bl L.3.13
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -5
+ bl L.4.11
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-5*2+1), %o2
+
+L.4.11:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-5*2-1), %o2
+
+
+L.3.13:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ ! depth 4, accumulated bits -7
+ bl L.4.9
+ srl %o5,1,%o5
+ ! remainder is positive
+ subcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-7*2+1), %o2
+
+L.4.9:
+ ! remainder is negative
+ addcc %o3,%o5,%o3
+ b 9f
+ add %o2, (-7*2-1), %o2
+
+
+
+
+ 9:
+Lend_regular_divide:
+ subcc %o4, 1, %o4
+ bge Ldivloop
+ tst %o3
+ bl,a Lgot_result
+ ! non-restoring fixup here (one instruction only!)
+ add %o3, %o1, %o3
+
+
+Lgot_result:
+
+ retl
+ mov %o3, %o0
diff --git a/sysdeps/standalone/Dist b/sysdeps/standalone/Dist
new file mode 100644
index 0000000..b6b12b7
--- /dev/null
+++ b/sysdeps/standalone/Dist
@@ -0,0 +1,2 @@
+filedesc.h
+standalone.h
diff --git a/sysdeps/standalone/Subdirs b/sysdeps/standalone/Subdirs
new file mode 100644
index 0000000..4125ae8
--- /dev/null
+++ b/sysdeps/standalone/Subdirs
@@ -0,0 +1,4 @@
+# The `bare' subdirectory defines some structure for a target-specific
+# library of functions which are actually implemented in
+# sysdeps/standalone/CPU/TARGET.
+bare
diff --git a/sysdeps/standalone/brk.c b/sysdeps/standalone/brk.c
new file mode 100644
index 0000000..67fbf77
--- /dev/null
+++ b/sysdeps/standalone/brk.c
@@ -0,0 +1,65 @@
+/* Copyright (C) 1991, 1994, 1995 Free Software Foundation, Inc.
+ Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil,
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <stdlib.h>
+
+PTR __curbrk;
+PTR __rorig;
+PTR __rlimit;
+
+int
+DEFUN(__brk, (inaddr), PTR inaddr)
+{
+
+ if ( ( (void *)inaddr > (void *)__rlimit ) ||
+ ( (void *)inaddr < (void *)__rorig ) )
+ return -1;
+
+ __curbrk = inaddr;
+ return 0;
+}
+
+/* Initialization Code for Memory Allocation */
+
+PTR __C_heap_start;
+int __C_heap_size;
+
+#ifdef HAVE_GNU_LD
+static
+#endif
+void
+DEFUN(__NONE_set_memvals, (argc, argv, envp),
+ int argc AND char **argv AND char **envp)
+{
+
+ __rorig =
+ __curbrk = __C_heap_start;
+ __rlimit = __curbrk + __C_heap_size;
+
+ (void) &__NONE_set_memvals; /* Avoid "defined but not used" warning. */
+}
+
+#ifdef HAVE_GNU_LD
+text_set_element (__libc_subinit, __NONE_set_memvals);
+#endif
+
+weak_alias (__brk, brk)
diff --git a/sysdeps/standalone/close.c b/sysdeps/standalone/close.c
new file mode 100644
index 0000000..59b6073
--- /dev/null
+++ b/sysdeps/standalone/close.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+ Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil,
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <stdio_lim.h>
+#include "filedesc.h"
+
+/* Close the file descriptor FD. */
+int
+DEFUN(__close, (fd), int fd)
+{
+ if ( !__FD_Is_valid( fd ) || !__FD_Table[ fd ].in_use )
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ __FD_Table[ fd ].in_use = 0;
+ return 0;
+}
+
+
+weak_alias (__close, close)
diff --git a/sysdeps/standalone/dirstream.h b/sysdeps/standalone/dirstream.h
new file mode 100644
index 0000000..20c4922
--- /dev/null
+++ b/sysdeps/standalone/dirstream.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 1993 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 _DIRSTREAM_H
+
+#define _DIRSTREAM_H 1
+
+#define __need_size_t
+#include <stddef.h>
+
+/* Directory stream type.
+
+ The miscellaneous Unix `readdir' implementations read directory data
+ into a buffer and fill in a `struct dirent' copy in the `DIR' object. */
+
+typedef struct
+ {
+ int __fd; /* File descriptor. */
+
+ char *__data; /* Directory block. */
+ size_t __allocation; /* Space allocated for the block. */
+ size_t __offset; /* Current offset into the block. */
+ size_t __size; /* Total valid data in the block. */
+
+ struct dirent __entry; /* Returned by `readdir'. */
+ } DIR;
+
+#endif /* dirstream.h */
diff --git a/sysdeps/standalone/filedesc.h b/sysdeps/standalone/filedesc.h
new file mode 100644
index 0000000..bf3b6a9
--- /dev/null
+++ b/sysdeps/standalone/filedesc.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil,
+ On-Line Applications Research Corporation.
+
+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 file descriptor used by the no OS implementation
+ * of __open, __read, __write, and __close.
+ */
+
+#ifndef __FILEDESC_h
+#define __FILEDESC_h
+
+#include <stdio_lim.h>
+
+#ifndef __DECLARE_FILE_DESCRIPTORS__
+#define FILEDESC_EXTERN extern
+#else
+#define FILEDESC_EXTERN
+#endif
+
+typedef struct {
+ int in_use; /* 1 if in use, 0 otherwise */
+ int flags; /* Flags from open */
+} __no_os_file_descriptor;
+
+#define __FD_Is_valid( _fd ) \
+ ( (_fd) >= 0 && (_fd) < FOPEN_MAX )
+
+FILEDESC_EXTERN __no_os_file_descriptor __FD_Table[ FOPEN_MAX ];
+
+#endif
diff --git a/sysdeps/standalone/i386/Dist b/sysdeps/standalone/i386/Dist
new file mode 100644
index 0000000..98d13be
--- /dev/null
+++ b/sysdeps/standalone/i386/Dist
@@ -0,0 +1 @@
+i386.h
diff --git a/sysdeps/standalone/i386/force_cpu386/Dist b/sysdeps/standalone/i386/force_cpu386/Dist
new file mode 100644
index 0000000..8b7b09e
--- /dev/null
+++ b/sysdeps/standalone/i386/force_cpu386/Dist
@@ -0,0 +1 @@
+target.ld
diff --git a/sysdeps/standalone/i386/force_cpu386/Makefile b/sysdeps/standalone/i386/force_cpu386/Makefile
new file mode 100644
index 0000000..8483724
--- /dev/null
+++ b/sysdeps/standalone/i386/force_cpu386/Makefile
@@ -0,0 +1,24 @@
+# Copyright (C) 1994 Free Software Foundation, Inc.
+# Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+# On-Line Applications Research Corporation.
+
+# 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.
+
+ifeq (bare,$(subdir))
+install-others += $(libdir)/force_cpu386.ld
+$(libdir)/force_cpu386.ld: $(sysdep_dir)/standalone/i386/target.ld
+ $(do-install)
+endif
diff --git a/sysdeps/standalone/i386/force_cpu386/_exit.c b/sysdeps/standalone/i386/force_cpu386/_exit.c
new file mode 100644
index 0000000..011bb8b
--- /dev/null
+++ b/sysdeps/standalone/i386/force_cpu386/_exit.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+/* This returns control to FORCEbug. */
+
+void DEFUN_VOID(Bsp_cleanup);
+
+/* The function `_exit' should take a status argument and simply
+ terminate program execution, using the low-order 8 bits of the
+ given integer as status. */
+
+__NORETURN void
+DEFUN(_exit, (status), int status)
+{
+ /* status is ignored */
+ Bsp_cleanup();
+}
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(_exit);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/standalone/i386/force_cpu386/brdinit.c b/sysdeps/standalone/i386/force_cpu386/brdinit.c
new file mode 100644
index 0000000..0d27218
--- /dev/null
+++ b/sysdeps/standalone/i386/force_cpu386/brdinit.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <standalone.h>
+#include "i386.h"
+
+/* _Board_Initialize()
+
+This routine initializes the FORCE CPU386 board. */
+
+void DEFUN_VOID(_Console_Initialize);
+
+void
+DEFUN_VOID(_Board_Initialize)
+{
+ /*
+ * FORCE documentation incorrectly states that the bus request
+ * level is initialized to 3. It is actually initialized by
+ * FORCEbug to 0.
+ */
+
+ outport_byte( 0x00, 0x3f ); /* resets VMEbus request level */
+
+ _Console_Initialize();
+}
diff --git a/sysdeps/standalone/i386/force_cpu386/console.c b/sysdeps/standalone/i386/force_cpu386/console.c
new file mode 100644
index 0000000..5d56f76
--- /dev/null
+++ b/sysdeps/standalone/i386/force_cpu386/console.c
@@ -0,0 +1,163 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <standalone.h>
+#include "i386.h"
+
+/* Console IO routines for a FORCE CPU386 board. */
+
+/* Force CPU/386 specific IO addressing
+ *
+ * The following determines whether Port B or the Console should
+ * be used for console I/O. Setting ONE (and only ONE) of these to 1
+ * enables I/O on that port.
+ *
+ * PORT A - DUSCC MC68562 Channel A (*** not supported here ***)
+ * PORT B - DUSCC MC68562 Channel B
+ * PORT C - MFP MC68901 Channel (*** FORCEbug console ***)
+ */
+
+#define PORTB 1 /* use port b as console */
+#define PORTC 0 /* use console port as console */
+
+#if ( PORTB == 1 )
+#define TX_STATUS 0x1b6 /* DUSCC General Status Register */
+#define RX_STATUS 0x1b6 /* DUSCC General Status Register */
+#define TX_BUFFER 0x1e0 /* DUSCC Transmitter Channel B */
+#define RX_BUFFER 0x1e8 /* DUSCC Receiver Channel B */
+#define Is_tx_ready( _status ) ( (_status) & 0x20 )
+#define Is_rx_ready( _status ) ( (_status) & 0x10 )
+#endif
+
+#if ( PORTC == 1 )
+#define TX_STATUS 0x12c /* MFP Transmit Status Register */
+#define RX_STATUS 0x12a /* MFP Receive Status Register */
+#define TX_BUFFER 0x12e /* MFP Transmitter Channel */
+#define RX_BUFFER 0x12e /* MFP Receiver Channel */
+#define Is_tx_ready( _status ) ( (_status) & 0x80 )
+#define Is_rx_ready( _status ) ( (_status) & 0x80 )
+#endif
+
+/* _Console_Initialize
+
+On the Force board the console require some initialization. */
+
+void
+DEFUN_VOID(_Console_Initialize)
+{
+ register unsigned8 ignored;
+
+ /* FORCE technical support mentioned that it may be necessary to
+ read the DUSCC RX_BUFFER port four times to remove all junk.
+ This code is a little more paranoid. */
+
+ inport_byte( RX_BUFFER, ignored );
+ inport_byte( RX_BUFFER, ignored );
+ inport_byte( RX_BUFFER, ignored );
+ inport_byte( RX_BUFFER, ignored );
+ inport_byte( RX_BUFFER, ignored );
+}
+
+/* Miscellaneous support for console IO */
+
+static inline int _Force386_is_rx_ready()
+{
+ register unsigned8 status;
+
+ inport_byte( RX_STATUS, status );
+
+ if ( Is_rx_ready( status ) ) return 1;
+ else return 0;
+}
+
+static inline int _Force386_is_tx_ready()
+{
+ register unsigned8 status;
+
+ inport_byte( TX_STATUS, status );
+
+ if ( Is_tx_ready( status ) ) return 1;
+ else return 0;
+}
+
+
+static inline int _Force386_read_data()
+{
+ register unsigned8 ch;
+
+#if ( PORTB == 1 )
+ /* Force example code resets the Channel B Receiver here.
+ * It appears to cause XON's to be lost.
+ */
+
+ /* outport_byte( RX_STATUS, 0x10 ); */
+#endif
+
+ inport_byte( RX_BUFFER, ch );
+
+ return ch;
+}
+
+/* _Console_Putc
+
+This routine transmits a character. It supports XON/XOFF flow control. */
+
+#define XON 0x11 /* control-Q */
+#define XOFF 0x13 /* control-S */
+
+int
+DEFUN( _Console_Putc, (ch), char ch )
+{
+ register unsigned8 inch;
+
+ while ( !_Force386_is_tx_ready() );
+
+ while ( _Force386_is_rx_ready() == 1 ) { /* must be an XOFF */
+ inch = _Force386_read_data();
+ if ( inch == XOFF )
+ do {
+ while ( _Force386_is_rx_ready() == 0 );
+ inch = _Force386_read_data();
+ } while ( inch != XON );
+ }
+
+ outport_byte( TX_BUFFER, ch );
+ return( 0 );
+}
+
+/* _Console_Getc
+
+This routine reads a character from the UART and returns it. */
+
+int
+DEFUN( _Console_Getc, (poll), int poll )
+{
+ if ( poll ) {
+ if ( !_Force386_is_rx_ready() )
+ return -1;
+ else
+ return _Force386_read_data();
+ } else {
+ while ( !_Force386_is_rx_ready() );
+ return _Force386_read_data();
+ }
+}
diff --git a/sysdeps/standalone/i386/force_cpu386/strtsupp.S b/sysdeps/standalone/i386/force_cpu386/strtsupp.S
new file mode 100644
index 0000000..6b78a8c
--- /dev/null
+++ b/sysdeps/standalone/i386/force_cpu386/strtsupp.S
@@ -0,0 +1,89 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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 file assists the board independent startup code by
+ * loading the proper segment register values. The values
+ * loaded are dependent on the FORCEBUG.
+ *
+ * NOTE: No stack has been established when this routine
+ * is invoked. It returns by jumping back to the start code.
+ *
+ */
+
+/*
+ * FORCEBUG loads us into a virtual address space which
+ * really starts at PHYSICAL_ADDRESS_BASE.
+ *
+ */
+
+.set PHYSICAL_ADDRESS_BASE, 0x00002000
+
+/*
+ * At reset time, FORCEBUG normally has the segment selectors preloaded.
+ * If a human resets the instruction pointer, this will not have occurred.
+ * However, no guarantee can be made of the other registers if cs:ip was
+ * modified to restart the program. Because of this, the BSP reloads all
+ * segment registers (except cs) with the values they have following
+ * a reset.
+ */
+
+
+.set RESET_SS, 0x40 # initial value of stack segment register
+.set RESET_DS, 0x40 # initial value of data segment register
+.set RESET_ES, 0x40 # initial value of extra segment register
+.set RESET_FS, 0x40 # initial value of "f" segment register
+.set RESET_GS, 0x30 # initial value of "g" segment register
+
+
+#define LOAD_SEGMENTS(_value,_segreg) \
+ movw $_value##,%ax ; \
+ movw %ax,##_segreg
+
+
+ .global _load_segments
+
+ .global _establish_stack
+
+_load_segments:
+
+ LOAD_SEGMENTS( RESET_SS, %ss )
+ LOAD_SEGMENTS( RESET_DS, %ds )
+ LOAD_SEGMENTS( RESET_ES, %es )
+ LOAD_SEGMENTS( RESET_FS, %fs )
+ LOAD_SEGMENTS( RESET_GS, %gs )
+
+ jmp _establish_stack # return to the bsp entry code
+
+ .global _return_to_monitor
+_return_to_monitor:
+
+ movb $0,%al
+ int $0x20 # restart FORCEbug
+ jmp start # FORCEbug does not reset PC
+
+ .data
+
+ .global _Do_Load_IDT
+_Do_Load_IDT: .byte 1
+
+ .global _Do_Load_GDT
+_Do_Load_GDT: .byte 0
+
diff --git a/sysdeps/standalone/i386/force_cpu386/target.ld b/sysdeps/standalone/i386/force_cpu386/target.ld
new file mode 100644
index 0000000..056da10
--- /dev/null
+++ b/sysdeps/standalone/i386/force_cpu386/target.ld
@@ -0,0 +1,59 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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 file contains directives for the GNU linker which are specific
+to the FORCE CPU386 board. */
+
+MEMORY
+ {
+ ram : org = 0x0, l = 1M
+ }
+
+/* This value is also when the space is allocated. If you change
+this one, change the other one!!! */
+
+heap_size = 0x20000;
+
+SECTIONS
+{
+ .text 0x0 :
+ {
+ _text_start = ABSOLUTE(.) ;
+ *(.text)
+ _etext = ALIGN( 0x10 ) ;
+ }
+ .data ADDR( .text ) + SIZEOF( .text ):
+ {
+ _data_start = . ;
+ *(.data)
+ _edata = ALIGN( 0x10 ) ;
+ }
+ .bss ADDR( .data ) + SIZEOF( .data ):
+ {
+ _bss_start = . ;
+ *(.bss)
+ *(COMMON)
+ heap_memory = .;
+ . += 0x20000;
+ _end = . ;
+ __end = . ;
+ }
+}
diff --git a/sysdeps/standalone/i386/i386.h b/sysdeps/standalone/i386/i386.h
new file mode 100644
index 0000000..8302773
--- /dev/null
+++ b/sysdeps/standalone/i386/i386.h
@@ -0,0 +1,327 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+/* i386.h
+ *
+ * This file contains macros which are used to access i80386
+ * registers which are not addressable by C. This file contains
+ * functions which are useful to those developing target
+ * specific support routines.
+ */
+
+#ifndef i386_h__
+#define i386_h__
+
+typedef unsigned char unsigned8;
+typedef unsigned short unsigned16;
+typedef unsigned int unsigned32;
+
+#define disable_intr( isrlevel ) \
+ { (isrlevel) = 0; \
+ asm volatile ( "pushf ; \
+ pop %0 ; \
+ cli " \
+ : "=r" ((isrlevel)) : "0" ((isrlevel)) ); \
+ }
+
+
+#define enable_intr( isrlevel ) \
+ { asm volatile ( "push %0 ; \
+ popf " \
+ : "=r" ((isrlevel)) : "0" ((isrlevel)) ); \
+ }
+
+#define delay( _microseconds ) \
+ { \
+ unsigned32 _counter; \
+ \
+ _counter = (_microseconds); \
+ \
+ asm volatile ( "0: nop;" \
+ " mov %0,%0 ;" \
+ " loop 0" : "=c" (_counter) \
+ : "0" (_counter) \
+ ); \
+ \
+ }
+
+/* segment access functions */
+
+static inline unsigned16 get_cs()
+{
+ register unsigned16 segment = 0;
+
+ asm volatile ( "movw %%cs,%0" : "=r" (segment) : "0" (segment) );
+
+ return segment;
+}
+
+static inline unsigned16 get_ds()
+{
+ register unsigned16 segment = 0;
+
+ asm volatile ( "movw %%ds,%0" : "=r" (segment) : "0" (segment) );
+
+ return segment;
+}
+
+static inline unsigned16 get_es()
+{
+ register unsigned16 segment = 0;
+
+ asm volatile ( "movw %%es,%0" : "=r" (segment) : "0" (segment) );
+
+ return segment;
+}
+
+static inline unsigned16 get_ss()
+{
+ register unsigned16 segment = 0;
+
+ asm volatile ( "movw %%ss,%0" : "=r" (segment) : "0" (segment) );
+
+ return segment;
+}
+
+static inline unsigned16 get_fs()
+{
+ register unsigned16 segment = 0;
+
+ asm volatile ( "movw %%fs,%0" : "=r" (segment) : "0" (segment) );
+
+ return segment;
+}
+
+static inline unsigned16 get_gs()
+{
+ register unsigned16 segment = 0;
+
+ asm volatile ( "movw %%gs,%0" : "=r" (segment) : "0" (segment) );
+
+ return segment;
+}
+
+/* i80x86 I/O instructions */
+
+#define outport_byte( _port, _value ) \
+ { register unsigned16 __port = _port; \
+ register unsigned8 __value = _value; \
+ \
+ asm volatile ( "outb %0,%1" : "=a" (__value), "=d" (__port) \
+ : "0" (__value), "1" (__port) \
+ ); \
+ }
+
+#define outport_word( _port, _value ) \
+ { register unsigned16 __port = _port; \
+ register unsigned16 __value = _value; \
+ \
+ asm volatile ( "outw %0,%1" : "=a" (__value), "=d" (__port) \
+ : "0" (__value), "1" (__port) \
+ ); \
+ }
+
+#define outport_long( _port, _value ) \
+ { register unsigned16 __port = _port; \
+ register unsigned32 __value = _value; \
+ \
+ asm volatile ( "outl %0,%1" : "=a" (__value), "=d" (__port) \
+ : "0" (__value), "1" (__port) \
+ ); \
+ }
+
+#define inport_byte( _port, _value ) \
+ { register unsigned16 __port = _port; \
+ register unsigned8 __value = 0; \
+ \
+ asm volatile ( "inb %1,%0" : "=a" (__value), "=d" (__port) \
+ : "0" (__value), "1" (__port) \
+ ); \
+ _value = __value; \
+ }
+
+#define inport_word( _port, _value ) \
+ { register unsigned16 __port = _port; \
+ register unsigned16 __value = 0; \
+ \
+ asm volatile ( "inw %1,%0" : "=a" (__value), "=d" (__port) \
+ : "0" (__value), "1" (__port) \
+ ); \
+ _value = __value; \
+ }
+
+#define inport_long( _port, _value ) \
+ { register unsigned16 __port = _port; \
+ register unsigned32 __value = 0; \
+ \
+ asm volatile ( "inl %1,%0" : "=a" (__value), "=d" (__port) \
+ : "0" (__value), "1" (__port) \
+ ); \
+ _value = __value; \
+ }
+
+/* structures */
+
+/* See Chapter 5 - Memory Management in i386 manual */
+
+struct GDT_slot {
+ unsigned16 limit_0_15;
+ unsigned16 base_0_15;
+ unsigned8 base_16_23;
+ unsigned8 type_dt_dpl_p;
+ unsigned8 limit_16_19_granularity;
+ unsigned8 base_24_31;
+};
+
+/* See Chapter 9 - Exceptions and Interrupts in i386 manual
+ *
+ * NOTE: This is the IDT entry for interrupt gates ONLY.
+ */
+
+struct IDT_slot {
+ unsigned16 offset_0_15;
+ unsigned16 segment_selector;
+ unsigned8 reserved;
+ unsigned8 p_dpl;
+ unsigned16 offset_16_31;
+};
+
+struct DTR_load_save_format {
+ unsigned16 limit;
+ unsigned32 physical_address;
+};
+
+/* variables */
+
+extern struct IDT_slot Interrupt_descriptor_table[ 256 ];
+extern struct GDT_slot Global_descriptor_table[ 8192 ];
+
+/* functions */
+
+#ifdef CPU_INITIALIZE
+#define EXTERN
+#else
+#undef EXTERN
+#define EXTERN extern
+#endif
+
+void *Logical_to_physical(
+ unsigned16 segment,
+ void *address
+);
+
+void *Physical_to_logical(
+ unsigned16 segment,
+ void *address
+);
+
+/* complicated static inline functions */
+
+#define get_GDTR( _gdtr_address ) \
+ { \
+ void *_gdtr = (_gdtr_address); \
+ \
+ asm volatile( "sgdt (%0)" : "=r" (_gdtr) : "0" (_gdtr) ); \
+ }
+
+#define get_GDT_slot( _gdtr_base, _segment, _slot_address ) \
+ { \
+ register unsigned32 _gdt_slot = (_gdtr_base) + (_segment); \
+ register volatile void *_slot = (_slot_address); \
+ register unsigned32 _temporary = 0; \
+ \
+ asm volatile( "movl %%gs:(%0),%1 ; \
+ movl %1,(%2) ; \
+ movl %%gs:4(%0),%1 ; \
+ movl %1,4(%2)" \
+ : "=r" (_gdt_slot), "=r" (_temporary), "=r" (_slot) \
+ : "0" (_gdt_slot), "1" (_temporary), "2" (_slot) \
+ ); \
+ }
+
+#define set_GDT_slot( _gdtr_base, _segment, _slot_address ) \
+ { \
+ register unsigned32 _gdt_slot = (_gdtr_base) + (_segment); \
+ register volatile void *_slot = (_slot_address); \
+ register unsigned32 _temporary = 0; \
+ \
+ asm volatile( "movl (%2),%1 ; \
+ movl %1,%%gs:(%0) ; \
+ movl 4(%2),%1 ; \
+ movl %1,%%gs:4(%0) \
+ " \
+ : "=r" (_gdt_slot), "=r" (_temporary), "=r" (_slot) \
+ : "0" (_gdt_slot), "1" (_temporary), "2" (_slot) \
+ ); \
+ }
+
+static inline void set_segment(
+ unsigned16 segment,
+ unsigned32 base,
+ unsigned32 limit
+)
+{
+ struct DTR_load_save_format gdtr;
+ volatile struct GDT_slot Gdt_slot;
+ volatile struct GDT_slot *gdt_slot = &Gdt_slot;
+ unsigned16 tmp_segment = 0;
+ unsigned32 limit_adjusted;
+
+
+ /* load physical address of the GDT */
+
+ get_GDTR( &gdtr );
+
+ gdt_slot->type_dt_dpl_p = 0x92; /* present, dpl=0, */
+ /* application=1, */
+ /* type=data read/write */
+ gdt_slot->limit_16_19_granularity = 0x40; /* 32 bit segment */
+
+ limit_adjusted = limit;
+ if ( limit > 4095 ) {
+ gdt_slot->limit_16_19_granularity |= 0x80; /* set granularity bit */
+ limit_adjusted /= 4096;
+ }
+
+ gdt_slot->limit_16_19_granularity |= (limit_adjusted >> 16) & 0xff;
+ gdt_slot->limit_0_15 = limit_adjusted & 0xffff;
+
+ gdt_slot->base_0_15 = base & 0xffff;
+ gdt_slot->base_16_23 = (base >> 16) & 0xff;
+ gdt_slot->base_24_31 = (base >> 24);
+
+ set_GDT_slot( gdtr.physical_address, segment, gdt_slot );
+
+ /* Now, reload all segment registers so the limit takes effect. */
+
+ asm volatile( "movw %%ds,%0 ; movw %0,%%ds
+ movw %%es,%0 ; movw %0,%%es
+ movw %%fs,%0 ; movw %0,%%fs
+ movw %%gs,%0 ; movw %0,%%gs
+ movw %%ss,%0 ; movw %0,%%ss"
+ : "=r" (tmp_segment)
+ : "0" (tmp_segment)
+ );
+
+}
+
+#endif
+/* end of include file */
diff --git a/sysdeps/standalone/i386/start.S b/sysdeps/standalone/i386/start.S
new file mode 100644
index 0000000..8331a33
--- /dev/null
+++ b/sysdeps/standalone/i386/start.S
@@ -0,0 +1,323 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+/* entry.s
+ *
+ * This file contains the entry point for the application.
+ * The name of this entry point is compiler dependent.
+ * It jumps to the BSP which is responsible for performing
+ * all initialization.
+ *
+ */
+
+ .data
+ .global _Do_Load_IDT
+ .global _Do_Load_GDT
+
+ .text
+ .global start # GNU default entry point
+ .global _establish_stack
+
+ .global _bsp_start
+ .global _load_segments
+ .global __exit
+
+start:
+ nop
+ cli # DISABLE INTERRUPTS!!!
+#
+# Load the segment registers
+#
+# NOTE: Upon return, gs will contain the segment descriptor for
+# a segment which maps directly to all of physical memory.
+#
+ jmp _load_segments # load board dependent segments
+
+#
+# Set up the stack
+#
+
+_establish_stack:
+
+ movl $stack_end,%esp # set stack pointer
+ movl $stack_end,%ebp # set base pointer
+
+#
+# Zero out the BSS segment
+#
+zero_bss:
+ cld # make direction flag count up
+ movl $_end,%ecx # find end of .bss
+ movl $_bss_start,%edi # edi = beginning of .bss
+ subl %edi,%ecx # ecx = size of .bss in bytes
+ shrl $2,%ecx # size of .bss in longs
+ xorl %eax,%eax # value to clear out memory
+ repne # while ecx != 0
+ stosl # clear a long in the bss
+
+#
+# Set the C heap information for malloc
+#
+ movl $heap_size,___C_heap_size # set ___C_heap_size
+ movl $heap_memory,___C_heap_start # set ___C_heap_start
+
+#
+# Copy the Global Descriptor Table to our space
+#
+
+ sgdt _Original_GDTR # save original GDT
+ movzwl _Original_GDTR_limit,%ecx # size of GDT in bytes; limit
+ # is 8192 entries * 8 bytes per
+
+ # make ds:esi point to the original GDT
+
+ movl _Original_GDTR_base,%esi
+ push %ds # save ds
+ movw %gs,%ax
+ movw %ax,%ds
+
+ # make es:edi point to the new (our copy) GDT
+ movl $_Global_descriptor_table,%edi
+
+ rep
+ movsb # copy the GDT (ds:esi -> es:edi)
+
+ pop %ds # restore ds
+
+ # Build and load new contents of GDTR
+ movw _Original_GDTR_limit,%ecx # set new limit
+ movw %cx,_New_GDTR_limit
+
+ push $_Global_descriptor_table
+ push %es
+ call _Logical_to_physical
+ addl $6,%esp
+ movl %eax,_New_GDTR_base # set new base
+
+ cmpb $0,_Do_Load_GDT # Should the new GDT be loaded?
+ je no_gdt_load # NO, then branch
+ lgdt _New_GDTR # load the new GDT
+no_gdt_load:
+
+#
+# Copy the Interrupt Descriptor Table to our space
+#
+
+ sidt _Original_IDTR # save original IDT
+ movzwl _Original_IDTR_limit,%ecx # size of IDT in bytes; limit
+ # is 256 entries * 8 bytes per
+
+
+ # make ds:esi point to the original IDT
+ movl _Original_IDTR_base,%esi
+
+ push %ds # save ds
+ movw %gs,%ax
+ movw %ax,%ds
+
+ # make es:edi point to the new (our copy) IDT
+ movl $_Interrupt_descriptor_table,%edi
+
+ rep
+ movsb # copy the IDT (ds:esi -> es:edi)
+ pop %ds # restore ds
+
+ # Build and load new contents of IDTR
+ movw _Original_IDTR_limit,%ecx # set new limit
+ movw %cx,_New_IDTR_limit
+
+ push $_Interrupt_descriptor_table
+ push %es
+ call _Logical_to_physical
+ addl $6,%esp
+ movl %eax,_New_IDTR_base # set new base
+
+ cmpb $0,_Do_Load_IDT # Should the new IDT be loaded?
+ je no_idt_load # NO, then branch
+ lidt _New_IDTR # load the new IDT
+no_idt_load:
+
+#
+# Initialize the i387.
+#
+# Using the NO WAIT form of the instruction insures that if
+# it is not present the board will not lock up or get an
+# exception.
+#
+
+ fninit # MUST USE NO-WAIT FORM
+
+ call __Board_Initialize # initialize the board
+
+ pushl $0 # envp = NULL
+ pushl $0 # argv = NULL
+ pushl $0 # argc = NULL
+ call ___libc_init # initialize the library and
+ # call main
+ addl $12,%esp
+
+ pushl $0 # argc = NULL
+ call __exit # call the Board specific exit
+ addl $4,%esp
+
+#
+# Clean up
+#
+
+
+ .global _Bsp_cleanup
+
+ .global _return_to_monitor
+
+_Bsp_cleanup:
+ cmpb $0,_Do_Load_IDT # Was the new IDT loaded?
+ je no_idt_restore # NO, then branch
+ lidt _Original_IDTR # restore the new IDT
+no_idt_restore:
+
+ cmpb $0,_Do_Load_GDT # Was the new GDT loaded?
+ je no_gdt_restore # NO, then branch
+ lgdt _Original_GDTR # restore the new GDT
+no_gdt_restore:
+ jmp _return_to_monitor
+
+#
+# void *Logical_to_physical(
+# rtems_unsigned16 segment,
+# void *address
+# );
+#
+# Returns thirty-two bit physical address for segment:address.
+#
+
+ .global _Logical_to_physical
+
+.set SEGMENT_ARG, 4
+.set ADDRESS_ARG, 8
+
+_Logical_to_physical:
+
+ xorl %eax,%eax # clear eax
+ movzwl SEGMENT_ARG(%esp),%ecx # ecx = segment value
+ movl $_Global_descriptor_table,%edx # edx = address of our GDT
+ addl %ecx,%edx # edx = address of desired entry
+ movb 7(%edx),%ah # ah = base 31:24
+ movb 4(%edx),%al # al = base 23:16
+ shll $16,%eax # move ax into correct bits
+ movw 2(%edx),%ax # ax = base 0:15
+ movl ADDRESS_ARG(%esp),%ecx # ecx = address to convert
+ addl %eax,%ecx # ecx = physical address equivalent
+ movl %ecx,%eax # eax = ecx
+ ret
+
+#
+# void *Physical_to_logical(
+# rtems_unsigned16 segment,
+# void *address
+# );
+#
+# Returns thirty-two bit physical address for segment:address.
+#
+
+ .global _Physical_to_logical
+
+#.set SEGMENT_ARG, 4
+#.set ADDRESS_ARG, 8 -- use sets from above
+
+_Physical_to_logical:
+
+ xorl %eax,%eax # clear eax
+ movzwl SEGMENT_ARG(%esp),%ecx # ecx = segment value
+ movl $_Global_descriptor_table,%edx # edx = address of our GDT
+ addl %ecx,%edx # edx = address of desired entry
+ movb 7(%edx),%ah # ah = base 31:24
+ movb 4(%edx),%al # al = base 23:16
+ shll $16,%eax # move ax into correct bits
+ movw 2(%edx),%ax # ax = base 0:15
+ movl ADDRESS_ARG(%esp),%ecx # ecx = address to convert
+ subl %eax,%ecx # ecx = logical address equivalent
+ movl %ecx,%eax # eax = ecx
+ ret
+
+
+/*
+ * Data Declarations. Start with a macro which helps declare space.
+ */
+
+ .bss
+
+#define DECLARE_SPACE(_name,_space,_align) \
+ .globl _name ; \
+ .align _align ; \
+_name##: .space _space
+
+#define DECLARE_LABEL(_name) \
+ .globl _name ; \
+_name##:
+
+#define DECLARE_PTR(_name) DECLARE_SPACE(_name,4,2)
+#define DECLARE_U32(_name) DECLARE_SPACE(_name,4,2)
+#define DECLARE_U16(_name) DECLARE_SPACE(_name,2,1)
+
+/*
+ * Require environment stuff
+ */
+
+DECLARE_LABEL(_environ)
+DECLARE_PTR(environ)
+
+DECLARE_LABEL(_errno)
+DECLARE_U32(errno)
+
+/*
+ * Miscellaneous Variables used to restore the CPU state.
+ *
+ * Start with a macro to declare the space for the contents of
+ * a Descriptor Table register.
+ */
+
+#define DECLARE_DTR_SPACE(_name) \
+ .global _name ; \
+ .align 4 ; \
+_name##: ; \
+_name##_limit: .space 2 ; \
+_name##_base: .space 4
+
+DECLARE_SPACE(_Interrupt_descriptor_table,256*8,4)
+DECLARE_SPACE(_Global_descriptor_table,8192*8,4)
+
+DECLARE_DTR_SPACE(_Original_IDTR)
+DECLARE_DTR_SPACE(_New_IDTR)
+DECLARE_DTR_SPACE(_Original_GDTR)
+DECLARE_DTR_SPACE(_New_GDTR)
+
+DECLARE_SPACE(_Physical_base_of_ds,4,4)
+DECLARE_SPACE(_Physical_base_of_cs,4,4)
+
+/*
+ * Stack Size and Space
+ */
+
+ .set stack_size, 0x20000
+
+DECLARE_SPACE(stack_memory,stack_size,4)
+DECLARE_LABEL(stack_end)
+
diff --git a/sysdeps/standalone/i960/Dist b/sysdeps/standalone/i960/Dist
new file mode 100644
index 0000000..e1747ef
--- /dev/null
+++ b/sysdeps/standalone/i960/Dist
@@ -0,0 +1 @@
+i960ca.h
diff --git a/sysdeps/standalone/i960/i960ca.h b/sysdeps/standalone/i960/i960ca.h
new file mode 100644
index 0000000..21012b4
--- /dev/null
+++ b/sysdeps/standalone/i960/i960ca.h
@@ -0,0 +1,207 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+/* i960ca.h
+ *
+ * This file contains macros which are used to access i80960CA
+ * registers which are not addressable by C. The functions
+ * in this file sould be useful to the developer of target
+ * specific code.
+ */
+
+#ifndef i960ca_h__
+#define i960ca_h__
+
+typedef unsigned char unsigned8;
+typedef unsigned short unsigned16;
+typedef unsigned int unsigned32;
+
+/*
+ * Intel i80960CA Processor Control Block
+ */
+
+struct i80960ca_prcb {
+ unsigned32 *fault_tbl; /* fault table base address */
+ struct i80960ca_ctltbl
+ *control_tbl; /* control table base address */
+ unsigned32 initial_ac; /* AC register initial value */
+ unsigned32 fault_config; /* fault configuration word */
+ void *intr_tbl; /* interrupt table base address */
+ void *sys_proc_tbl; /* system procedure table */
+ /* base address */
+ unsigned32 reserved; /* reserved */
+ unsigned32 *intr_stack; /* interrupt stack pointer */
+ unsigned32 ins_cache_cfg; /* instruction cache */
+ /* configuration word */
+ unsigned32 reg_cache_cfg; /* register cache */
+ /* configuration word */
+};
+
+/*
+ * Intel i80960CA Control Table
+ */
+
+struct i80960ca_ctltbl {
+ /* Control Group 0 */
+ unsigned32 ipb0; /* IP breakpoint 0 */
+ unsigned32 ipb1; /* IP breakpoint 1 */
+ unsigned32 dab0; /* data address breakpoint 0 */
+ unsigned32 dab1; /* data address breakpoint 1 */
+ /* Control Group 1 */
+ unsigned32 imap0; /* interrupt map 0 */
+ unsigned32 imap1; /* interrupt map 1 */
+ unsigned32 imap2; /* interrupt map 2 */
+ unsigned32 icon; /* interrupt control */
+ /* Control Group 2 */
+ unsigned32 mcon0; /* memory region 0 configuration */
+ unsigned32 mcon1; /* memory region 1 configuration */
+ unsigned32 mcon2; /* memory region 2 configuration */
+ unsigned32 mcon3; /* memory region 3 configuration */
+ /* Control Group 3 */
+ unsigned32 mcon4; /* memory region 4 configuration */
+ unsigned32 mcon5; /* memory region 5 configuration */
+ unsigned32 mcon6; /* memory region 6 configuration */
+ unsigned32 mcon7; /* memory region 7 configuration */
+ /* Control Group 4 */
+ unsigned32 mcon8; /* memory region 8 configuration */
+ unsigned32 mcon9; /* memory region 9 configuration */
+ unsigned32 mcon10; /* memory region 10 configuration */
+ unsigned32 mcon11; /* memory region 11 configuration */
+ /* Control Group 5 */
+ unsigned32 mcon12; /* memory region 12 configuration */
+ unsigned32 mcon13; /* memory region 13 configuration */
+ unsigned32 mcon14; /* memory region 14 configuration */
+ unsigned32 mcon15; /* memory region 15 configuration */
+ /* Control Group 6 */
+ unsigned32 bpcon; /* breakpoint control */
+ unsigned32 tc; /* trace control */
+ unsigned32 bcon; /* bus configuration control */
+ unsigned32 reserved; /* reserved */
+};
+
+#define disable_intr( oldlevel ) \
+ { (oldlevel) = 0x1f0000; \
+ asm volatile ( "modpc 0,%1,%1" \
+ : "=d" ((oldlevel)) \
+ : "0" ((oldlevel)) ); \
+ }
+
+#define enable_intr( oldlevel ) \
+ { unsigned32 _mask = 0x1f0000; \
+ asm volatile ( "modpc 0,%0,%1" \
+ : "=d" (_mask), "=d" ((oldlevel)) \
+ : "0" (_mask), "1" ((oldlevel)) ); \
+ }
+
+#define flash_intr( oldlevel ) \
+ { unsigned32 _mask = 0x1f0000; \
+ asm volatile ( "modpc 0,%0,%1 ; \
+ mov %0,%1 ; \
+ modpc 0,%0,%1" \
+ : "=d" (_mask), "=d" ((oldlevel)) \
+ : "0" (_mask), "1" ((oldlevel)) ); \
+ }
+
+#define atomic_modify( mask, addr, prev ) \
+ { register unsigned32 _mask = (mask); \
+ register unsigned32 *_addr = (unsigned32 *)(addr); \
+ asm volatile( "atmod %0,%1,%1" \
+ : "=d" (_addr), "=d" (_mask) \
+ : "0" (_addr), "1" (_mask) ); \
+ (prev) = _mask; \
+ }
+
+#define delay( microseconds ) \
+ { register unsigned32 _delay=(microseconds); \
+ register unsigned32 _tmp; \
+ asm volatile( "delay0: \
+ remo 3,31,%0 ; \
+ cmpo 0,%0 ; \
+ subo 1,%1,%1 ; \
+ cmpobne.t 0,%1,delay0 " \
+ : "=d" (_tmp), "=d" (_delay) \
+ : "0" (_tmp), "1" (_delay) ); \
+ }
+
+#define enable_tracing() \
+ { register unsigned32 _pc = 0x1; \
+ asm volatile( "modpc 0,%0,%0" : "=d" (_pc) : "0" (_pc) ); \
+ }
+
+#define unmask_intr( xint ) \
+ { register unsigned32 _mask= (1<<(xint)); \
+ asm volatile( "or sf1,%0,sf1" : "=d" (_mask) : "0" (_mask) ); \
+ }
+
+#define mask_intr( xint ) \
+ { register unsigned32 _mask= (1<<(xint)); \
+ asm volatile( "andnot %0,sf1,sf1" : "=d" (_mask) : "0" (_mask) ); \
+ }
+
+#define clear_intr( xint ) \
+ { register unsigned32 _xint=(xint); \
+ asm volatile( "loop_til_cleared:
+ clrbit %0,sf0,sf0 ; \
+ bbs %0,sf0,loop_til_cleared" \
+ : "=d" (_xint) : "0" (_xint) ); \
+ }
+
+#define reload_ctl_group( group ) \
+ { register int _cmd = ((group)|0x400) ; \
+ asm volatile( "sysctl %0,%0,%0" : "=d" (_cmd) : "0" (_cmd) ); \
+ }
+
+#define cause_intr( intr ) \
+ { register int _intr = (intr); \
+ asm volatile( "sysctl %0,%0,%0" : "=d" (_intr) : "0" (_intr) ); \
+ }
+
+#define soft_reset( prcb ) \
+ { register struct i80960ca_prcb *_prcb = (prcb); \
+ register unsigned32 *_next=0; \
+ register unsigned32 _cmd = 0x30000; \
+ asm volatile( "lda next,%1; \
+ sysctl %0,%1,%2; \
+ next: mov g0,g0" \
+ : "=d" (_cmd), "=d" (_next), "=d" (_prcb) \
+ : "0" (_cmd), "1" (_next), "2" (_prcb) ); \
+ }
+
+static inline unsigned32 pend_intrs()
+{ register unsigned32 _intr=0;
+ asm volatile( "mov sf0,%0" : "=d" (_intr) : "0" (_intr) );
+ return ( _intr );
+}
+
+static inline unsigned32 mask_intrs()
+{ register unsigned32 _intr=0;
+ asm volatile( "mov sf1,%0" : "=d" (_intr) : "0" (_intr) );
+ return( _intr );
+}
+
+static inline unsigned32 get_fp()
+{ register unsigned32 _fp=0;
+ asm volatile( "mov fp,%0" : "=d" (_fp) : "0" (_fp) );
+ return ( _fp );
+}
+
+#endif
+/* end of include file */
diff --git a/sysdeps/standalone/i960/nindy960/Makefile b/sysdeps/standalone/i960/nindy960/Makefile
new file mode 100644
index 0000000..e6e65ea
--- /dev/null
+++ b/sysdeps/standalone/i960/nindy960/Makefile
@@ -0,0 +1,23 @@
+# Copyright (C) 1993 Free Software Foundation, Inc.
+# Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+# On-Line Applications Research Corporation.
+
+# 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.
+
+
+# The nindy960 support has only been tested on the following boards:
+#
+# + Cyclone CVME961 VMEbus single board computer.
diff --git a/sysdeps/standalone/i960/nindy960/_exit.c b/sysdeps/standalone/i960/nindy960/_exit.c
new file mode 100644
index 0000000..33553a7
--- /dev/null
+++ b/sysdeps/standalone/i960/nindy960/_exit.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1991 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+/* The function `_exit' should take a status argument and simply
+ terminate program execution, using the low-order 8 bits of the
+ given integer as status. */
+
+/* This returns control to Nindy. */
+
+__NORETURN void
+DEFUN(_exit, (status), int status)
+{
+ /* status is ignored */
+
+ asm volatile( "mov 0,g0; \
+ fmark ; \
+ syncf ; \
+ .word 0xfeedface ; \
+ bx start" : : );
+ /* The constant 0xfeedface is a magic word for break which
+ * is defined by NINDY. The branch extended restarts the
+ * application if the user types "go".
+ */
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(_exit);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/standalone/i960/nindy960/brdinit.c b/sysdeps/standalone/i960/nindy960/brdinit.c
new file mode 100644
index 0000000..c16adcd
--- /dev/null
+++ b/sysdeps/standalone/i960/nindy960/brdinit.c
@@ -0,0 +1,66 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <standalone.h>
+#include "i960ca.h"
+
+/* _Board_Initialize()
+
+This routine initializes the board.
+
+NOTE: Only tested on a Cyclone CVME961 but should be OK on any i960ca board. */
+
+void
+DEFUN_VOID(_Board_Initialize)
+{
+ struct i80960ca_prcb *prcb; /* ptr to processor control block */
+ struct i80960ca_ctltbl *ctl_tbl; /* ptr to control table */
+
+ static inline struct i80960ca_prcb *get_prcb()
+ { register struct i80960ca_prcb *_prcb = 0;
+ asm volatile( "calls 5; \
+ mov g0,%0" \
+ : "=d" (_prcb) \
+ : "0" (_prcb) );
+ return ( _prcb );
+ }
+
+ prcb = get_prcb();
+ ctl_tbl = prcb->control_tbl;
+
+ /* The following configures the data breakpoint (which must be set
+ * before this is executed) to break on writes only.
+ */
+
+ ctl_tbl->bpcon &= ~0x00cc0000;
+ reload_ctl_group( 6 );
+
+ /* bit 31 of the Register Cache Control can be set to
+ * enable an alternative caching algorithm. It does
+ * not appear to help our applications.
+ */
+
+ /* Configure Number of Register Caches */
+
+ prcb->reg_cache_cfg = 8;
+ soft_reset( prcb );
+}
diff --git a/sysdeps/standalone/i960/nindy960/console.c b/sysdeps/standalone/i960/nindy960/console.c
new file mode 100644
index 0000000..8215144
--- /dev/null
+++ b/sysdeps/standalone/i960/nindy960/console.c
@@ -0,0 +1,76 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <standalone.h>
+#include "i960ca.h"
+
+/* Console IO routines for a NINDY960 board. */
+
+/*
+ * NINDY_IO( ... )
+ *
+ * Interface to NINDY.
+ */
+
+#define NINDY_INPUT 0
+#define NINDY_OUTPUT 1
+
+void ___NINDY_IO_WRAPPER( void ) /* never called */
+{
+ asm volatile ( " .text" );
+ asm volatile ( " .align 4" );
+ asm volatile ( " .globl _NINDY_IO" );
+ asm volatile ( "_NINDY_IO:" );
+ asm volatile ( " calls 0 /* call console routines */" );
+ asm volatile ( " ret" );
+}
+
+/***** !!!! HOW DO I EXFUN NINDY_IO? !!!! *****/
+
+/* _Console_Putc
+
+This routine transmits a character using NINDY. */
+
+int
+DEFUN( _Console_Putc, (ch), char ch )
+{
+ NINDY_IO( NINDY_OUTPUT, ch );
+ return( 0 );
+}
+
+/* _Console_Getc
+
+This routine reads a character from NINDY and returns it. */
+
+int
+DEFUN( _Console_Getc, (poll), int poll )
+{
+ char ch;
+
+ if ( poll ) {
+ /* I don't know how to poll with NINDY */
+ return -1;
+ } else {
+ NINDY_IO( NINDY_INPUT, &ch );
+ return ch;
+ }
+}
diff --git a/sysdeps/standalone/i960/start.S b/sysdeps/standalone/i960/start.S
new file mode 100644
index 0000000..c14449d
--- /dev/null
+++ b/sysdeps/standalone/i960/start.S
@@ -0,0 +1,137 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+/* entry.s
+ *
+ * This file contains the entry point for the application.
+ * The name of this entry point is compiler dependent.
+ * It jumps to the BSP which is responsible for performing
+ * all initialization.
+ *
+ */
+
+ .text
+ .globl start # GNU960 default entry point
+
+start:
+ mov 3, r12
+ modpc r12, r12, r12 # enable tracing/trace faults
+ mov g5, g5 # NOP
+ mov 0, g14 # initialize constant for C
+
+ /*
+ * zero out uninitialized data area
+ */
+zerobss:
+ lda _end, r4 /* find end of .bss */
+ lda _bss_start, r5 /* find beginning of .bss */
+ ldconst 0, r6
+
+loop: st r6, (r5) /* to zero out uninitialized */
+ addo 4, r5, r5 /* data area */
+ cmpobl r5, r4, loop /* loop until _end reached */
+
+
+ lda heap_memory, r12 /* tell C lib where heap is */
+ st r12,___C_heap_start
+ lda heap_size, r12 /* tell C lib how big heap is */
+ st r12,___C_heap_size
+ lda stack_memory,r12 /* set up stack pointer: */
+ mov r12, sp
+ mov 0, g14 /* initialize constant for C */
+
+ call init_frames
+ ret /* return to monitor */
+
+init_frames:
+ ldconst 0x3b001000, g0
+ ldconst 0x00009107, g1
+ modac g1, g0, g0 /* set AC controls */
+
+ /*
+ * Call application mainline.
+ * Someday, real values of argc and argv will be set up.
+ * For now, they are set to 0.
+ */
+
+ callx __Board_Initialize /* Initialize the board */
+
+ ldconst 0,g0
+ ldconst 0,g1
+ ldconst 0,g2
+ callx ___libc_init /* initialize the library and */
+ /* call main */
+ /*
+ * if we return from main, we have "fallen" off the end
+ * of the program, therefore status is 0
+ * so move 0 to g0 (exit parameter)
+ */
+
+ mov 0, g0
+ callx __exit
+ ret
+
+
+/*
+ * Data Declarations. Start with a macro which helps declare space.
+ */
+
+#define DECLARE_SPACE(_name,_space,_align) \
+ .globl _name ; \
+ .align _align ; \
+.comm _name##,_space
+
+#define DECLARE_LABEL(_name) \
+ .globl _name ; \
+_name##:
+
+#define DECLARE_PTR(_name) DECLARE_SPACE(_name,4,2)
+#define DECLARE_U32(_name) DECLARE_SPACE(_name,4,2)
+#define DECLARE_U16(_name) DECLARE_SPACE(_name,2,1)
+
+/*
+ * Require environment stuff
+ */
+
+DECLARE_LABEL(_environ)
+DECLARE_PTR(environ)
+
+DECLARE_LABEL(_errno)
+DECLARE_U32(errno)
+
+/*
+ * Stack Size and Space
+ */
+
+ .set stack_size, 0x20000
+
+DECLARE_SPACE(stack_memory,stack_size,4)
+DECLARE_LABEL(stack_end)
+
+/*
+ * Heap Size and Space
+ */
+
+ .set heap_size, 0x20000
+
+DECLARE_SPACE(heap_memory,heap_size,4)
+DECLARE_LABEL(heap_end)
+
diff --git a/sysdeps/standalone/m68k/m68020/Dist b/sysdeps/standalone/m68k/m68020/Dist
new file mode 100644
index 0000000..90b37b4
--- /dev/null
+++ b/sysdeps/standalone/m68k/m68020/Dist
@@ -0,0 +1 @@
+m68020.h
diff --git a/sysdeps/standalone/m68k/m68020/m68020.h b/sysdeps/standalone/m68k/m68020/m68020.h
new file mode 100644
index 0000000..e9e6f7d
--- /dev/null
+++ b/sysdeps/standalone/m68k/m68020/m68020.h
@@ -0,0 +1,88 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+/* m68020.h
+ *
+ * This file contains macros which are used to access MC68020
+ * registers which are not addressable by C. These are
+ * useful when developing the board specific support.
+ */
+
+#ifndef m68020_h__
+#define m68020_h__
+
+typedef void ( *mc68020_isr )( void );
+
+#define disable_intr( level ) \
+ { (level) = 0; \
+ asm volatile ( "movew %%sr,%0 ; \
+ orw #0x0700,%%sr" \
+ : "=d" ((level)) : "0" ((level)) ); \
+ }
+
+#define enable_intr( level ) \
+ { asm volatile ( "movew %0,%%sr " \
+ : "=d" ((level)) : "0" ((level)) ); \
+ }
+
+#define flash_intr( level ) \
+ { asm volatile ( "movew %0,%%sr ; \
+ orw #0x0700,%%sr" \
+ : "=d" ((level)) : "0" ((level)) ); \
+ }
+
+#define get_vbr( vbr ) \
+ { (vbr) = 0; \
+ asm volatile ( "movec %%vbr,%0 " \
+ : "=a" (vbr) : "0" (vbr) ); \
+ }
+
+#define set_vbr( vbr ) \
+ { register mc68020_isr *_vbr= (mc68020_isr *)(vbr); \
+ asm volatile ( "movec %0,%%vbr " \
+ : "=a" (_vbr) : "0" (_vbr) ); \
+ }
+
+#define enable_caching() \
+ { register unsigned int _ctl=0x01; \
+ asm volatile ( "movec %0,%%cacr" \
+ : "=d" (_ctl) : "0" (_ctl) ); \
+ }
+
+#define delay( microseconds ) \
+ { register unsigned int _delay=(microseconds); \
+ register unsigned int _tmp=123; \
+ asm volatile( "0: \
+ nbcd %0 ; \
+ nbcd %0 ; \
+ dbf %1,0 " \
+ : "=d" (_tmp), "=d" (_delay) \
+ : "0" (_tmp), "1" (_delay) ); \
+ }
+
+#define enable_tracing()
+#define cause_intr( X )
+#define clear_intr( X )
+
+extern mc68020_isr M68Kvec[]; /* vector table address */
+
+#endif
+/* end of include file */
diff --git a/sysdeps/standalone/m68k/m68020/mvme135/Implies b/sysdeps/standalone/m68k/m68020/mvme135/Implies
new file mode 100644
index 0000000..7142fe2
--- /dev/null
+++ b/sysdeps/standalone/m68k/m68020/mvme135/Implies
@@ -0,0 +1,2 @@
+# Motorola MVME135 and MVME136 are compatible.
+standalone/m68k/m68020/mvme136
diff --git a/sysdeps/standalone/m68k/m68020/mvme136/Dist b/sysdeps/standalone/m68k/m68020/mvme136/Dist
new file mode 100644
index 0000000..97b9058
--- /dev/null
+++ b/sysdeps/standalone/m68k/m68020/mvme136/Dist
@@ -0,0 +1 @@
+mvme136.ld
diff --git a/sysdeps/standalone/m68k/m68020/mvme136/Makefile b/sysdeps/standalone/m68k/m68020/mvme136/Makefile
new file mode 100644
index 0000000..33f049c
--- /dev/null
+++ b/sysdeps/standalone/m68k/m68020/mvme136/Makefile
@@ -0,0 +1,22 @@
+# Copyright (C) 1993 Free Software Foundation, Inc.
+# Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+# On-Line Applications Research Corporation.
+
+# 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.
+
+ifeq (bare,$(subdir))
+install-lib += mvme136.ld
+endif
diff --git a/sysdeps/standalone/m68k/m68020/mvme136/_exit.c b/sysdeps/standalone/m68k/m68020/mvme136/_exit.c
new file mode 100644
index 0000000..d13b4d9
--- /dev/null
+++ b/sysdeps/standalone/m68k/m68020/mvme136/_exit.c
@@ -0,0 +1,49 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include "m68020.h"
+
+/* Return control to 135Bug */
+
+void
+DEFUN_VOID(__exit_trap)
+{
+ set_vbr( 0 ); /* restore 135Bug vectors */
+ asm volatile( "trap #15" ); /* trap to 135Bug */
+ asm volatile( ".short 0x63" ); /* return to 135Bug (.RETURN) */
+ asm volatile( "jmp main" ); /* restart program */
+}
+
+/* The function `_exit' should take a status argument and simply
+ terminate program execution, using the low-order 8 bits of the
+ given integer as status. */
+
+__NORETURN void
+DEFUN(_exit, (status), int status)
+{
+ /* status is ignored */
+
+ M68Kvec[ 45 ] = __exit_trap; /* install exit_trap handler */
+ asm volatile( "trap #13" ); /* insures SUPV mode */
+}
diff --git a/sysdeps/standalone/m68k/m68020/mvme136/brdinit.c b/sysdeps/standalone/m68k/m68020/mvme136/brdinit.c
new file mode 100644
index 0000000..0c4801a
--- /dev/null
+++ b/sysdeps/standalone/m68k/m68020/mvme136/brdinit.c
@@ -0,0 +1,53 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <standalone.h>
+#include "m68020.h"
+
+/* _Board_Initialize()
+
+This routine initializes the Motorola MVME135/MVME136. */
+
+void
+DEFUN_VOID(_Board_Initialize)
+{
+ mc68020_isr *monitors_vector_table;
+ int index;
+
+ monitors_vector_table = (mc68020_isr *)0; /* 135Bug Vectors are at 0 */
+ set_vbr( monitors_vector_table );
+
+ for ( index=2 ; index<=255 ; index++ )
+ M68Kvec[ index ] = monitors_vector_table[ 32 ];
+
+ M68Kvec[ 2 ] = monitors_vector_table[ 2 ]; /* bus error vector */
+ M68Kvec[ 4 ] = monitors_vector_table[ 4 ]; /* breakpoints vector */
+ M68Kvec[ 9 ] = monitors_vector_table[ 9 ]; /* trace vector */
+ M68Kvec[ 47 ] = monitors_vector_table[ 47 ]; /* system call vector */
+
+ set_vbr( &M68Kvec );
+
+ (*(unsigned char *)0xfffb0067) = 0x7f; /* make VME access round-robin */
+
+ enable_caching();
+
+}
diff --git a/sysdeps/standalone/m68k/m68020/mvme136/console.c b/sysdeps/standalone/m68k/m68020/mvme136/console.c
new file mode 100644
index 0000000..159070b
--- /dev/null
+++ b/sysdeps/standalone/m68k/m68020/mvme136/console.c
@@ -0,0 +1,101 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <standalone.h>
+#include "m68020.h"
+
+/* Console IO routines for a Motorola MVME135/MVME136 board.
+
+They currently use the B port. It should be possible to
+use the A port by filling in the reset of the chip structure,
+adding an ifdef for PORTA/PORTB, and switching the addresses,
+and maybe the macroes based on the macro. */
+
+/* M68681 DUART chip register structures and constants */
+
+typedef struct {
+ volatile unsigned char fill1[ 5 ]; /* channel A regs ( not used ) */
+ volatile unsigned char isr; /* interrupt status reg */
+ volatile unsigned char fill2[ 2 ]; /* counter regs (not used) */
+ volatile unsigned char mr1mr2b; /* MR1B and MR2B regs */
+ volatile unsigned char srb; /* status reg channel B */
+ volatile unsigned char fill3; /* do not access */
+ volatile unsigned char rbb; /* receive buffer channel B */
+ volatile unsigned char ivr; /* interrupt vector register */
+} r_m681_info;
+
+typedef struct {
+ volatile unsigned char fill1[ 4 ]; /* channel A regs (not used) */
+ volatile unsigned char acr; /* auxillary control reg */
+ volatile unsigned char imr; /* interrupt mask reg */
+ volatile unsigned char fill2[ 2 ]; /* counter regs (not used) */
+ volatile unsigned char mr1mr2b; /* MR1B and MR2B regs */
+ volatile unsigned char csrb; /* clock select reg */
+ volatile unsigned char crb; /* command reg */
+ volatile unsigned char tbb; /* transmit buffer channel B */
+ volatile unsigned char ivr; /* interrupt vector register */
+} w_m681_info;
+
+#define RD_M68681 ((r_m681_info *)0xfffb0040) /* ptr to the M68681 */
+#define WR_M68681 ((w_m681_info *)0xfffb0040) /* ptr to the M68681 */
+#define RXRDYB 0x01 /* status reg recv ready mask */
+#define TXRDYB 0x04 /* status reg trans ready mask */
+
+/* _Console_Putc
+
+This routine transmits a character out the M68681. It supports
+XON/XOFF flow control. */
+
+#define XON 0x11 /* control-Q */
+#define XOFF 0x13 /* control-S */
+
+int
+DEFUN( _Console_Putc, (ch), char ch )
+{
+ while ( ! (RD_M68681->srb & TXRDYB) ) ;
+ while ( RD_M68681->srb & RXRDYB ) /* must be an XOFF */
+ if ( RD_M68681->rbb == XOFF )
+ do {
+ while ( ! (RD_M68681->srb & RXRDYB) ) ;
+ } while ( RD_M68681->rbb != XON );
+
+ WR_M68681->tbb = ch;
+ return( 0 );
+}
+
+/* _Console_Getc
+
+This routine reads a character from the UART and returns it. */
+
+int
+DEFUN( _Console_Getc, (poll), int poll )
+{
+ if ( poll ) {
+ if ( !(RD_M68681->srb & RXRDYB) )
+ return -1;
+ else
+ return RD_M68681->rbb;
+ } else {
+ while ( !(RD_M68681->srb & RXRDYB) );
+ return RD_M68681->rbb;
+ }
+}
diff --git a/sysdeps/standalone/m68k/m68020/mvme136/mvme136.ld b/sysdeps/standalone/m68k/m68020/mvme136/mvme136.ld
new file mode 100644
index 0000000..0f68330
--- /dev/null
+++ b/sysdeps/standalone/m68k/m68020/mvme136/mvme136.ld
@@ -0,0 +1,62 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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 file contains directives for the GNU linker which are specific
+to the Motorola MVME136/MVME135 boards. */
+
+MEMORY
+ {
+ ram : org = 0x3000, l = 1M
+ }
+
+/* This value is also when the space is allocated. If you change
+this one, change the other one!!! */
+
+heap_size = 0x20000;
+
+SECTIONS
+{
+ .text 0x3000 :
+ {
+ text_start = ABSOLUTE(.) ;
+ *(.text)
+ etext = ALIGN( 0x10 ) ;
+ }
+
+ .data ADDR( .text ) + SIZEOF( .text ):
+ {
+ data_start = . ;
+ *(.data)
+ edata = ALIGN( 0x10 ) ;
+ }
+
+ .bss ADDR( .data ) + SIZEOF( .data ):
+ {
+ bss_start = . ;
+ _bss_start = . ;
+ *(.bss)
+ *(COMMON)
+ heap_memory = .;
+ . += 0x20000;
+ end = . ;
+ _end = . ;
+ }
+}
diff --git a/sysdeps/standalone/m68k/m68020/start.S b/sysdeps/standalone/m68k/m68020/start.S
new file mode 100644
index 0000000..cbabf5b
--- /dev/null
+++ b/sysdeps/standalone/m68k/m68020/start.S
@@ -0,0 +1,155 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+/* entry.s
+ *
+ * This file contains the entry point for the application.
+ * The name of this entry point is compiler dependent.
+ * It jumps to the BSP which is responsible for performing
+ * all initialization.
+ */
+
+ .text
+ .globl start | Default entry point
+ .globl _start | Default entry point
+ .globl M68Kvec | Vector Table
+ .globl _M68Kvec | Vector Table
+
+start:
+_start:
+M68Kvec: | standard location for vectors
+_M68Kvec: | standard location for vectors
+ nop | for linkers with problem
+ | using location zero as entry
+ jmp around
+ .space 4088 | to avoid initial intr stack
+ | from 135BUG on MVME13? as entry
+ | and start code at 0x4000
+around:
+ move.w %sr,initial_sr | save initial values
+ movec %isp,%a0
+ movel %a0,initial_isp
+ movec %usp,%a0
+ movel %a0,initial_usp
+ movec %msp,%a0
+ movel %a0,initial_msp
+ oriw #0x0700,%sr | INTERRUPTS OFF!!!
+
+
+
+ |
+ | zero out uninitialized data area
+ |
+zerobss:
+ moveal #end,%a0 | find end of .bss
+ moveal #_bss_start,%a1 | find beginning of .bss
+ movel #0,%d0
+
+loop: movel #0,%a1@+ | to zero out uninitialized
+ cmpal %a0,%a1
+ jlt loop | loop until _end reached
+
+ movel #heap_size,__C_heap_size | set ___C_heap_size
+ movel #heap_memory,__C_heap_start | set ___C_heap_start
+ moveal #interrupt_stack_end,%a0 | set interrupt stack pointer
+ movec %a0,%isp
+ moveal #stack_end,%a0 | set master stack pointer
+ movec %a0,%msp
+ moveal #stack_end,%a6 | set base pointer
+ movw #0x3000,%sr | SUPV MODE,INTERRUPTS ON!!!
+
+#ifdef NEED_UNDERSCORES
+ jsr __Board_Initialize | initialize the board
+#else
+ jsr _Board_Initialize | initialize the board
+#endif
+
+ move.l #0,%sp@- | envp = NULL
+ move.l #0,%sp@- | argv = NULL
+ move.l #0,%sp@- | argc = NULL
+#ifdef NEED_UNDERSCORES
+ jsr ___libc_init | initialize the library and
+ | call main
+#else
+ jsr __libc_init | initialize the library and
+ | call main
+#endif
+ add.l #12,%sp
+
+ move.l #0,%sp@- | argc = NULL
+ jsr __exit | call the Board specific exit
+ addq.l #4,%sp
+
+ move.l initial_isp,%a0 | if __exit returns then we can
+ movec %a0,%isp | restore the initial values
+ move.l initial_usp,%a0
+ movec %a0,%usp
+ move.l initial_msp,%a0
+ movec %a0,%msp
+ move.w initial_sr,%sr
+ rts
+
+
+ .bss
+
+/*
+ * So initial stack registers and status register can be saved.
+ */
+
+#define DECLARE_SPACE(_name,_space,_align) \
+ .globl _name ; \
+ .align _align ; \
+_name##: .space _space
+
+#define DECLARE_LABEL(_name) \
+ .globl _name ; \
+_name##:
+
+#define DECLARE_PTR(_name) DECLARE_SPACE(_name,4,2)
+#define DECLARE_U32(_name) DECLARE_SPACE(_name,4,2)
+#define DECLARE_U16(_name) DECLARE_SPACE(_name,2,1)
+
+DECLARE_U32(initial_isp)
+DECLARE_U32(initial_msp)
+DECLARE_U32(initial_usp)
+DECLARE_U16(initial_sr)
+
+/*
+ * Require environment stuff
+ */
+
+DECLARE_LABEL(_environ)
+DECLARE_PTR(environ)
+
+DECLARE_LABEL(_errno)
+DECLARE_U32(errno)
+
+/*
+ * Stack Size and Space
+ */
+
+ .set stack_size, 0x20000
+
+DECLARE_SPACE(stack_memory,stack_size,4)
+DECLARE_LABEL(stack_end)
+
+DECLARE_SPACE(interrupt_stack_memory,0x1000,4)
+DECLARE_LABEL(interrupt_stack_end)
diff --git a/sysdeps/standalone/open.c b/sysdeps/standalone/open.c
new file mode 100644
index 0000000..910e793
--- /dev/null
+++ b/sysdeps/standalone/open.c
@@ -0,0 +1,122 @@
+/* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+ Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil,
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stddef.h>
+
+#include <stdio.h>
+#include <stdio_lim.h>
+#include <unistd.h>
+
+#define __DECLARE_FILE_DESCRIPTORS__
+
+#include "filedesc.h"
+
+/* Open FILE with access OFLAG. If OFLAG includes O_CREAT,
+ a third argument is the file protection. */
+int
+DEFUN(__open, (file, oflag), CONST char *file AND int oflag DOTS)
+{
+ int mode;
+ int newfd;
+ int index;
+
+ if (file == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (oflag & O_CREAT)
+ {
+ va_list arg;
+ va_start(arg, oflag);
+ mode = va_arg(arg, int);
+ va_end(arg);
+ }
+
+ /*
+ * Find an open slot.
+ */
+
+ newfd = -1;
+
+ for ( index=0 ; index< FOPEN_MAX ; index++ )
+ if ( !__FD_Table[ index ].in_use ) {
+ newfd = index;
+ break;
+ }
+
+ if ( newfd == -1 ) {
+ errno = ENFILE;
+ return -1;
+ }
+
+ /*
+ * Initialize the open slot
+ */
+
+ __FD_Table[ newfd ].in_use = 1;
+ __FD_Table[ newfd ].flags = oflag;
+
+ return newfd;
+}
+
+/* Initialization Code for Console I/O */
+
+#ifdef HAVE_GNU_LD
+static
+#endif
+void
+DEFUN(__NONE_init_console_io, (argc, argv, envp),
+ int argc AND char **argv AND char **envp)
+{
+ int index;
+
+ for ( index=0 ; index< FOPEN_MAX ; index++ )
+ __FD_Table[ index ].in_use = 0;
+
+ stdin = fopen( "", "r" );
+
+ stdout = fopen( "", "w" );
+
+ stderr = fopen( "", "w" );
+
+ /*
+ * Line buffer the standard input and output and use no buffering for
+ * standard error.
+ */
+
+ setvbuf( stdin, NULL, _IOLBF, BUFSIZ );
+ setvbuf( stdout, NULL, _IOLBF, BUFSIZ );
+ setvbuf( stderr, NULL, _IONBF, BUFSIZ );
+
+ (void) &__NONE_init_console_io; /* Avoid "defined but not used" warning. */
+}
+
+#ifdef HAVE_GNU_LD
+text_set_element (__libc_subinit, __NONE_init_console_io);
+#endif
+
+weak_alias (__open, open)
diff --git a/sysdeps/standalone/read.c b/sysdeps/standalone/read.c
new file mode 100644
index 0000000..284321d
--- /dev/null
+++ b/sysdeps/standalone/read.c
@@ -0,0 +1,87 @@
+/* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+ Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil,
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stddef.h>
+
+#include "filedesc.h"
+#include <fcntl.h>
+#include <standalone.h>
+
+/* Read NBYTES into BUF from FD. Return the number read or -1. */
+ssize_t
+DEFUN(__read, (fd, buf, nbytes),
+ int fd AND PTR buf AND size_t nbytes)
+{
+ char *buffer = (char *) buf;
+ int data;
+ int poll;
+
+ errno = 0;
+
+ if (nbytes == 0)
+ return 0;
+
+ if ( !__FD_Is_valid( fd ) || !__FD_Table[ fd ].in_use )
+ {
+ errno = EBADF;
+ return -1;
+ }
+ if (buf == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if ( __FD_Table[ fd ].flags & O_WRONLY ) /* is it write only? */
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ /* If this is a non-blocking fd, then we want to poll the console. */
+
+ poll = ( __FD_Table[ fd ].flags & O_NONBLOCK ) ? 1 : 0;
+
+ /* Read a single character. This is a cheap way to insure that the
+ upper layers get every character because _Console_Getc can't timeout
+ or otherwise know when to stop. */
+
+
+ data = _Console_Getc(poll);
+
+ if ( data == -1 ) /* if no data return */
+ return -1;
+
+ (void) _Console_Putc(data); /* echo the character */
+
+ if ( data == '\r' ) { /* translate CR -> CR/LF */
+ (void) _Console_Putc('\n');
+ data = '\n';
+ }
+
+ *buffer = data;
+ return 1;
+}
+
+weak_alias (__read, read)
diff --git a/sysdeps/standalone/standalone.h b/sysdeps/standalone/standalone.h
new file mode 100644
index 0000000..13d58f0
--- /dev/null
+++ b/sysdeps/standalone/standalone.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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 _STANDALONE_H
+#define _STANDALONE_H
+
+#include <sys/cdefs.h>
+
+extern void _Board_Initialize __P ((void));
+
+extern int _Console_Putc __P ((char c));
+extern int _Console_Getc __P ((int poll));
+
+#endif
diff --git a/sysdeps/standalone/stdio_lim.h b/sysdeps/standalone/stdio_lim.h
new file mode 100644
index 0000000..5552bc4
--- /dev/null
+++ b/sysdeps/standalone/stdio_lim.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil,
+ On-Line Applications Research Corporation.
+
+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. */
+
+#define L_tmpnam 1
+#define TMPMAX 0
+#define L_ctermid 1
+#define L_cuserid 1
+#define FOPEN_MAX 16
+#define FILENAME_MAX 14
diff --git a/sysdeps/standalone/write.c b/sysdeps/standalone/write.c
new file mode 100644
index 0000000..f0ae388
--- /dev/null
+++ b/sysdeps/standalone/write.c
@@ -0,0 +1,74 @@
+/* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+ Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil,
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <sysdep.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stddef.h>
+
+#include "filedesc.h"
+#include <fcntl.h>
+#include <standalone.h>
+
+/* Write NBYTES of BUF to FD. Return the number written, or -1. */
+ssize_t
+DEFUN(__write, (fd, buf, nbytes),
+ int fd AND CONST PTR buf AND size_t nbytes)
+{
+ int count;
+ CONST char *data = buf;
+
+ if (nbytes == 0)
+ return 0;
+ if ( !__FD_Is_valid( fd ) || !__FD_Table[ fd ].in_use )
+ {
+ errno = EBADF;
+ return -1;
+ }
+ if (buf == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if ( !(__FD_Table[ fd ].flags & (O_WRONLY|O_RDWR)) ) /* is it writeable? */
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ /*
+ * All open file descriptors are mapped to the console.
+ */
+
+ for ( count=0 ; count != nbytes ; count++ ) {
+ if ( _Console_Putc(data[ count ]) == -1 )
+ return -1;
+ if ( data[count] == '\n' && _Console_Putc('\r') == -1 )
+ return -1;
+ }
+
+ return count;
+}
+
+
+weak_alias (__write, write)
diff --git a/sysdeps/stub/__longjmp.c b/sysdeps/stub/__longjmp.c
new file mode 100644
index 0000000..3cc4c4b
--- /dev/null
+++ b/sysdeps/stub/__longjmp.c
@@ -0,0 +1,44 @@
+/* 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <setjmp.h>
+
+
+/* Jump to the position specified by ENV, causing the
+ setjmp call there to return VAL, or 1 if VAL is 0. */
+__NORETURN
+void
+DEFUN(__longjmp, (env, val), CONST __jmp_buf env AND int val)
+{
+ if (val == 0)
+ val = 1;
+
+ errno = ENOSYS;
+ /* No way to signal failure. */
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(longjmp);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/__math.h b/sysdeps/stub/__math.h
new file mode 100644
index 0000000..8159c89
--- /dev/null
+++ b/sysdeps/stub/__math.h
@@ -0,0 +1,6 @@
+/* This file should provide inline versions of math functions.
+
+ Surround GCC-specific parts with #ifdef __GNUC__, and use `extern __inline'.
+
+ This file should define __MATH_INLINES if functions are actually defined as
+ inlines. */
diff --git a/sysdeps/stub/_exit.c b/sysdeps/stub/_exit.c
new file mode 100644
index 0000000..d72a430
--- /dev/null
+++ b/sysdeps/stub/_exit.c
@@ -0,0 +1,40 @@
+/* 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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+/* The function `_exit' should take a status argument and simply
+ terminate program execution, using the low-order 8 bits of the
+ given integer as status. */
+__NORETURN void
+DEFUN(_exit, (status), int status)
+{
+ status &= 0xff;
+ abort ();
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(_exit);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/accept.c b/sysdeps/stub/accept.c
new file mode 100644
index 0000000..d3a30c2
--- /dev/null
+++ b/sysdeps/stub/accept.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Await a connection on socket FD.
+ When a connection arrives, open a new socket to communicate with it,
+ set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting
+ peer and *ADDR_LEN to the address's actual length, and return the
+ new socket's descriptor, or -1 for errors. */
+int
+DEFUN(accept, (fd, addr, addr_len),
+ int fd AND struct sockaddr *addr AND size_t *addr_len)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(accept);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/access.c b/sysdeps/stub/access.c
new file mode 100644
index 0000000..06ddbb5
--- /dev/null
+++ b/sysdeps/stub/access.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+/* Test for access to FILE. */
+int
+DEFUN(__access, (file, type), CONST char *file AND int type)
+{
+ if (file == NULL || (type & ~(R_OK|W_OK|X_OK|F_OK)) != 0)
+ {
+ errno = EINVAL;
+ return(-1);
+ }
+
+ errno = ENOSYS;
+ return(-1);
+}
+stub_warning (access)
+
+weak_alias (__access, access)
diff --git a/sysdeps/stub/acct.c b/sysdeps/stub/acct.c
new file mode 100644
index 0000000..1b547f3
--- /dev/null
+++ b/sysdeps/stub/acct.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Turn accounting on if NAME is an existing file. The system will then write
+ a record for each process as it terminates, to this file. If NAME is NULL,
+ turn accounting off. This call is restricted to the super-user. */
+int
+DEFUN(acct, (name), CONST char *name)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+stub_warning (acct)
diff --git a/sysdeps/stub/acos.c b/sysdeps/stub/acos.c
new file mode 100644
index 0000000..2ba05b55
--- /dev/null
+++ b/sysdeps/stub/acos.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the inverse cosine of X. */
+double
+DEFUN(acos, (x), double x)
+{
+ errno = ENOSYS;
+ return 0.0;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(acos);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/adjtime.c b/sysdeps/stub/adjtime.c
new file mode 100644
index 0000000..933e2ef
--- /dev/null
+++ b/sysdeps/stub/adjtime.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/time.h>
+
+/* Adjust the current time of day by the amount in DELTA.
+ If OLDDELTA is not NULL, it is filled in with the amount
+ of time adjustment remaining to be done from the last `__adjtime' call.
+ This call is restricted to the super-user. */
+int
+DEFUN(__adjtime, (delta, olddelta),
+ CONST struct timeval *delta AND
+ struct timeval *olddelta)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (adjtime)
+
+weak_alias (__adjtime, adjtime)
diff --git a/sysdeps/stub/alarm.c b/sysdeps/stub/alarm.c
new file mode 100644
index 0000000..861d624
--- /dev/null
+++ b/sysdeps/stub/alarm.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM.
+ If SECONDS is zero, any currently scheduled alarm will be cancelled.
+ The function returns the number of seconds remaining until the last
+ alarm scheduled would have signaled, or zero if there wasn't one.
+ There is no return value to indicate an error, but you can set `errno'
+ to 0 and check its value after calling `alarm', and this might tell you.
+ The signal may come late due to processor scheduling. */
+unsigned int
+DEFUN(alarm, (seconds), unsigned int seconds)
+{
+ errno = ENOSYS;
+ return 0;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(alarm);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/asin.c b/sysdeps/stub/asin.c
new file mode 100644
index 0000000..e645d48
--- /dev/null
+++ b/sysdeps/stub/asin.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the inverse sine of X. */
+double
+DEFUN(asin, (x), double x)
+{
+ errno = ENOSYS;
+ return 0.0;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(asin);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/asm-syntax.h b/sysdeps/stub/asm-syntax.h
new file mode 100644
index 0000000..a361509
--- /dev/null
+++ b/sysdeps/stub/asm-syntax.h
@@ -0,0 +1,3 @@
+/* On some machines the mpn function from GNU MP use a file called
+ "asm-syntax.h" to define macros for assembly source code to use. */
+
diff --git a/sysdeps/stub/atan2.c b/sysdeps/stub/atan2.c
new file mode 100644
index 0000000..c6ed43f
--- /dev/null
+++ b/sysdeps/stub/atan2.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+
+/* Return the inverse tangent of Y/X. */
+double
+DEFUN(atan2, (y, x), double y AND double x)
+{
+ errno = ENOSYS;
+ return 0.0;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(atan2);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/bind.c b/sysdeps/stub/bind.c
new file mode 100644
index 0000000..8ee5023
--- /dev/null
+++ b/sysdeps/stub/bind.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Give the socket FD the local address ADDR (which is LEN bytes long). */
+int
+DEFUN(bind, (fd, addr, len),
+ int fd AND struct sockaddr *addr AND size_t len)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(bind);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/brdinit.c b/sysdeps/stub/brdinit.c
new file mode 100644
index 0000000..50c9287
--- /dev/null
+++ b/sysdeps/stub/brdinit.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <standalone.h>
+
+/* This file is only required when a "bare" board is configured. */
+
+/* _Board_Initialize
+
+This routine normally performs board specific initialization. */
+
+void
+DEFUN_VOID(_Board_Initialize)
+{
+}
diff --git a/sysdeps/stub/brk.c b/sysdeps/stub/brk.c
new file mode 100644
index 0000000..3a48ea2
--- /dev/null
+++ b/sysdeps/stub/brk.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+
+/* Set the end of the process's data space to ADDR.
+ Return 0 if successful, -1 if not. */
+int
+DEFUN(__brk, (addr), PTR addr)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (brk)
+
+weak_alias (__brk, brk)
diff --git a/sysdeps/stub/bsd-_setjmp.c b/sysdeps/stub/bsd-_setjmp.c
new file mode 100644
index 0000000..afb4908
--- /dev/null
+++ b/sysdeps/stub/bsd-_setjmp.c
@@ -0,0 +1,33 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 0)'. Stub 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. */
+
+#include <sysdep.h>
+
+#undef setjmp
+
+/* This implementation in C will not usually work, because the call
+ really needs to be a tail-call so __sigsetjmp saves the state of
+ the caller, not the state of this `setjmp' frame which then
+ immediate unwinds. */
+
+int
+setjmp (jmp_buf env)
+{
+ return __sigsetjmp (env, 0);
+}
diff --git a/sysdeps/stub/bsd-setjmp.c b/sysdeps/stub/bsd-setjmp.c
new file mode 100644
index 0000000..80ff8b1
--- /dev/null
+++ b/sysdeps/stub/bsd-setjmp.c
@@ -0,0 +1,33 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. Stub 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. */
+
+#include <sysdep.h>
+
+#undef setjmp
+
+/* This implementation in C will not usually work, because the call
+ really needs to be a tail-call so __sigsetjmp saves the state of
+ the caller, not the state of this `setjmp' frame which then
+ immediate unwinds. */
+
+int
+setjmp (jmp_buf env)
+{
+ return __sigsetjmp (env, 1);
+}
diff --git a/sysdeps/stub/bytesex.h b/sysdeps/stub/bytesex.h
new file mode 100644
index 0000000..238a082
--- /dev/null
+++ b/sysdeps/stub/bytesex.h
@@ -0,0 +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,
+ 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. */
+
+#error Machine byte order unknown.
diff --git a/sysdeps/stub/cbrt.c b/sysdeps/stub/cbrt.c
new file mode 100644
index 0000000..8835bea
--- /dev/null
+++ b/sysdeps/stub/cbrt.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the cube root of X. */
+double
+DEFUN(cbrt, (x), double x)
+{
+ errno = ENOSYS;
+ return 0.0;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(cbrt);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/chdir.c b/sysdeps/stub/chdir.c
new file mode 100644
index 0000000..f73c981
--- /dev/null
+++ b/sysdeps/stub/chdir.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+/* Change the current directory to PATH. */
+int
+DEFUN(__chdir, (path), CONST char *path)
+{
+ if (path == NULL)
+ {
+ errno = EINVAL;
+ return(-1);
+ }
+
+ errno = ENOSYS;
+ return(-1);
+}
+stub_warning (chdir)
+
+weak_alias (__chdir, chdir)
diff --git a/sysdeps/stub/chflags.c b/sysdeps/stub/chflags.c
new file mode 100644
index 0000000..a906e1b
--- /dev/null
+++ b/sysdeps/stub/chflags.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+
+/* Change the flags of FILE to FLAGS. */
+int
+DEFUN(chflags, (file, flags), CONST char *file AND int flags)
+{
+ if (file == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+stub_warning (chflags)
diff --git a/sysdeps/stub/chmod.c b/sysdeps/stub/chmod.c
new file mode 100644
index 0000000..3259d3e
--- /dev/null
+++ b/sysdeps/stub/chmod.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+/* Change the protections of FILE to MODE. */
+int
+DEFUN(__chmod, (file, mode), CONST char *file AND mode_t mode)
+{
+ if (file == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (chmod)
+
+weak_alias (__chmod, chmod)
diff --git a/sysdeps/stub/chown.c b/sysdeps/stub/chown.c
new file mode 100644
index 0000000..e9db1ed
--- /dev/null
+++ b/sysdeps/stub/chown.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Change the owner and group of FILE. */
+int
+DEFUN(__chown, (file, owner, group),
+ CONST char *file AND uid_t owner AND gid_t group)
+{
+ if (file == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (chown)
+
+weak_alias (__chown, chown)
diff --git a/sysdeps/stub/chroot.c b/sysdeps/stub/chroot.c
new file mode 100644
index 0000000..637784a
--- /dev/null
+++ b/sysdeps/stub/chroot.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Make PATH be the root directory (the starting point for absolute paths).
+ This call is restricted to the super-user. */
+int
+DEFUN(chroot, (path), CONST char *path)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(chroot);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/clock.c b/sysdeps/stub/clock.c
new file mode 100644
index 0000000..151022d
--- /dev/null
+++ b/sysdeps/stub/clock.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <sys/times.h>
+#include <time.h>
+#include <errno.h>
+
+/* Return the time used by the program so far (user time + system time). */
+clock_t
+DEFUN_VOID(clock)
+{
+ errno = ENOSYS;
+ return (clock_t) -1;
+}
diff --git a/sysdeps/stub/close.c b/sysdeps/stub/close.c
new file mode 100644
index 0000000..efa80a7
--- /dev/null
+++ b/sysdeps/stub/close.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Close the file descriptor FD. */
+int
+DEFUN(__close, (fd), int fd)
+{
+ if (fd < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (close)
+
+weak_alias (__close, close)
diff --git a/sysdeps/stub/closedir.c b/sysdeps/stub/closedir.c
new file mode 100644
index 0000000..4595d47
--- /dev/null
+++ b/sysdeps/stub/closedir.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <dirent.h>
+
+
+/* Close the directory stream DIRP.
+ Return 0 if successful, -1 if not. */
+int
+DEFUN(closedir, (dirp), DIR *dirp)
+{
+ errno = ENOSYS;
+ return(-1);
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(closedir);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/confstr.h b/sysdeps/stub/confstr.h
new file mode 100644
index 0000000..988ec88
--- /dev/null
+++ b/sysdeps/stub/confstr.h
@@ -0,0 +1,4 @@
+/* This file should define values for the strings returned by `confstr'.
+ If _NAME is passed to `confstr', define NAME. */
+
+#define CS_PATH ""
diff --git a/sysdeps/stub/connect.c b/sysdeps/stub/connect.c
new file mode 100644
index 0000000..5fae8dd
--- /dev/null
+++ b/sysdeps/stub/connect.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Open a connection on socket FD to peer at ADDR (which LEN bytes long).
+ For connectionless socket types, just set the default address to send to
+ and the only address from which to accept transmissions.
+ Return 0 on success, -1 for errors. */
+int
+DEFUN(connect, (fd, addr, len),
+ int fd AND struct sockaddr *addr AND size_t len)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(connect);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/console.c b/sysdeps/stub/console.c
new file mode 100644
index 0000000..ca55611
--- /dev/null
+++ b/sysdeps/stub/console.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <standalone.h>
+
+/* This file is only required when a "bare" board is configured. */
+
+/* These routines provide console IO routines for your embedded target. */
+
+int
+DEFUN( _Console_Putc, (ch), char ch )
+{
+ /* eat the character */
+
+ return( 0 );
+}
+
+int
+DEFUN( _Console_Getc, (poll), int poll )
+{
+ /* boring user, never types anything */
+ return -1;
+}
diff --git a/sysdeps/stub/cos.c b/sysdeps/stub/cos.c
new file mode 100644
index 0000000..675855c
--- /dev/null
+++ b/sysdeps/stub/cos.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the cosine of X. */
+double
+DEFUN(cos, (x), double x)
+{
+ errno = ENOSYS;
+ return(0.0);
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(cos);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/cosh.c b/sysdeps/stub/cosh.c
new file mode 100644
index 0000000..ce1a0e2
--- /dev/null
+++ b/sysdeps/stub/cosh.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the hyperbolic cosine of X. */
+double
+DEFUN(cosh, (x), double x)
+{
+ errno = ENOSYS;
+ return(0.0);
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(cosh);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/ctermid.c b/sysdeps/stub/ctermid.c
new file mode 100644
index 0000000..0e74518
--- /dev/null
+++ b/sysdeps/stub/ctermid.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stdio.h>
+
+
+/* Return the name of the controlling terminal.
+ If S is not NULL, the name is copied into it (it should be at
+ least L_ctermid bytes long), otherwise a static buffer is used. */
+char *
+DEFUN(ctermid, (s), char *s)
+{
+ errno = ENOSYS;
+ return NULL;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(ctermid);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/cuserid.c b/sysdeps/stub/cuserid.c
new file mode 100644
index 0000000..e2c0eb7
--- /dev/null
+++ b/sysdeps/stub/cuserid.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+#include <errno.h>
+
+/* Return the username of the caller.
+ If S is not NULL, it points to a buffer of at least L_cuserid bytes
+ into which the name is copied; otherwise, a static buffer is used. */
+char *
+DEFUN(cuserid, (s), char *s)
+{
+ errno = ENOSYS;
+ return NULL;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(cuserid);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/dbl2mpn.c b/sysdeps/stub/dbl2mpn.c
new file mode 100644
index 0000000..a5bca3f
--- /dev/null
+++ b/sysdeps/stub/dbl2mpn.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1993 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. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
+/* Convert a `double' to a multi-precision integer representing the
+ significand scaled up by the highest possible number of significant bits
+ of fraction (DBL_MANT_DIG), and an integral power of two (MPN frexp). */
+
+mp_size_t
+__mpn_extract_double (mp_ptr res_ptr, mp_size_t size,
+ int *expt, int *is_neg,
+ double value)
+{
+#error "__mpn_extract_double is not implemented for this floating point format"
+}
diff --git a/sysdeps/stub/defs.c b/sysdeps/stub/defs.c
new file mode 100644
index 0000000..56d1871
--- /dev/null
+++ b/sysdeps/stub/defs.c
@@ -0,0 +1,51 @@
+/* Definitions of global stdio data structures.
+
+Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+
+/* This file should define the following
+ variables as appropriate for the system. */
+
+FILE *stdin, *stdout, *stderr;
+
+/* Pointer to the first stream in the list. */
+FILE *__stdio_head;
+
+/* This function MUST be in this file!
+ This is because we want _cleanup to go into the __libc_atexit set
+ when any stdio code is used (and to use any stdio code, one must reference
+ something defined in this file), and since only local symbols can be made
+ set elements, having the set element stab entry here and _cleanup elsewhere
+ loses; and having them both elsewhere loses because there is no reference
+ to cause _cleanup to be linked in. */
+
+void
+DEFUN_VOID(_cleanup)
+{
+ (void) fclose((FILE *) NULL);
+}
+
+
+#ifdef HAVE_GNU_LD
+#include <gnu-stabs.h>
+
+text_set_element(__libc_atexit, _cleanup);
+#endif
diff --git a/sysdeps/stub/direct.h b/sysdeps/stub/direct.h
new file mode 100644
index 0000000..7205130
--- /dev/null
+++ b/sysdeps/stub/direct.h
@@ -0,0 +1,5 @@
+/* This file should define `struct direct' on Unix systems.
+ This is the type of actual records in directory files.
+ See readdir.c. */
+
+#error No struct dirent definition.
diff --git a/sysdeps/stub/dirstream.h b/sysdeps/stub/dirstream.h
new file mode 100644
index 0000000..9a3d5a0
--- /dev/null
+++ b/sysdeps/stub/dirstream.h
@@ -0,0 +1,30 @@
+/* Copyright (C) 1993 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 _DIRSTREAM_H
+
+#define _DIRSTREAM_H 1
+
+
+/* This file should define a typedef `DIR', the data type of directory
+ stream objects returned by `opendir'. */
+
+#error "No system-dependent definition of `DIR'."
+
+
+#endif /* dirstream.h */
diff --git a/sysdeps/stub/drem.c b/sysdeps/stub/drem.c
new file mode 100644
index 0000000..e4c7cea
--- /dev/null
+++ b/sysdeps/stub/drem.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the remainder of X/Y. */
+double
+DEFUN(__drem, (x, y),
+ double x AND double y)
+{
+ errno = ENOSYS;
+ return 0.0;
+}
+
+stub_warning (drem)
+weak_alias (__drem, drem)
diff --git a/sysdeps/stub/dup.c b/sysdeps/stub/dup.c
new file mode 100644
index 0000000..f15a1be
--- /dev/null
+++ b/sysdeps/stub/dup.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+/* Duplicate FD, returning a new file descriptor open on the same file. */
+int
+DEFUN(__dup, (fd), int fd)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (dup)
+
+weak_alias (__dup, dup)
diff --git a/sysdeps/stub/dup2.c b/sysdeps/stub/dup2.c
new file mode 100644
index 0000000..a0f7aad
--- /dev/null
+++ b/sysdeps/stub/dup2.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+
+/* Duplicate FD to FD2, closing the old FD2 and making FD2 be
+ open the same file as FD is. Return FD2 or -1. */
+int
+DEFUN(__dup2, (fd, fd2), int fd AND int fd2)
+{
+ if (fd < 0 || fd2 < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ if (fd == fd2)
+ /* No way to check that they are valid. */
+ return fd2;
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (dup2)
+
+weak_alias (__dup2, dup2)
diff --git a/sysdeps/stub/errlist.c b/sysdeps/stub/errlist.c
new file mode 100644
index 0000000..adc3129
--- /dev/null
+++ b/sysdeps/stub/errlist.c
@@ -0,0 +1,42 @@
+/* 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+
+#ifndef HAVE_GNU_LD
+#define _sys_errlist sys_errlist
+#define _sys_nerr sys_nerr
+#endif
+
+CONST char *CONST _sys_errlist[] =
+ {
+ "Error 0", /* 0 */
+ "Argument out of function's domain", /* 1 = EDOM */
+ "Result out of range", /* 2 = ERANGE */
+ "Operation not implemented", /* 3 = ENOSYS */
+ "Invalid argument", /* 4 = EINVAL */
+ "Illegal seek", /* 5 = ESPIPE */
+ "Bad file descriptor", /* 6 = EBADF */
+ "Cannot allocate memory", /* 7 = ENOMEM */
+ "Permission denied", /* 8 = EACCES */
+ "Too many open files in system", /* 9 = ENFILE */
+ "Too many open files", /* 10 = EMFILE */
+ };
+
+CONST int _sys_nerr = sizeof (_sys_errlist) / sizeof (_sys_errlist[0]);
diff --git a/sysdeps/stub/errnos.h b/sysdeps/stub/errnos.h
new file mode 100644
index 0000000..1170808
--- /dev/null
+++ b/sysdeps/stub/errnos.h
@@ -0,0 +1,38 @@
+/* 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. */
+
+/* This file defines the `errno' constants. */
+
+#if !defined(__Emath_defined) && (defined(_ERRNO_H) || defined(__need_Emath))
+#undef __need_Emath
+#define __Emath_defined 1
+
+#define EDOM 1
+#define ERANGE 2
+#endif
+
+#ifdef _ERRNO_H
+#define ENOSYS 3
+#define EINVAL 4
+#define ESPIPE 5
+#define EBADF 6
+#define ENOMEM 7
+#define EACCES 8
+#define ENFILE 9
+#define EMFILE 10
+#endif
diff --git a/sysdeps/stub/exc2signal.c b/sysdeps/stub/exc2signal.c
new file mode 100644
index 0000000..1c4c9ac
--- /dev/null
+++ b/sysdeps/stub/exc2signal.c
@@ -0,0 +1,68 @@
+/* Translate Mach exception codes into signal numbers. Stub version.
+Copyright (C) 1991, 1992, 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. */
+
+#include <hurd.h>
+
+/* Translate the Mach exception codes, as received in an `exception_raise' RPC,
+ into a signal number and signal subcode. */
+
+void
+_hurd_exception2signal (int exception, int code, int subcode,
+ int *signo, int *sigcode, int *error)
+{
+ *error = 0;
+
+ switch (exception)
+ {
+ default:
+ *signo = SIGIOT;
+ *sigcode = exception;
+ break;
+
+ case EXC_BAD_ACCESS:
+ if (code == KERN_PROTECTION_FAILURE)
+ *signo = SIGSEGV;
+ else
+ *signo = SIGBUS;
+ *sigcode = subcode;
+ *error = code;
+ break;
+
+ case EXC_BAD_INSTRUCTION:
+ *signo = SIGILL;
+ *sigcode = 0;
+ break;
+
+ case EXC_ARITHMETIC:
+ *signo = SIGFPE;
+ *sigcode = 0;
+ break;
+
+ case EXC_EMULATION:
+ case EXC_SOFTWARE:
+ *signo = SIGEMT;
+ *sigcode = 0;
+ break;
+
+ case EXC_BREAKPOINT:
+ *signo = SIGTRAP;
+ *sigcode = 0;
+ break;
+ }
+}
diff --git a/sysdeps/stub/execve.c b/sysdeps/stub/execve.c
new file mode 100644
index 0000000..680d237
--- /dev/null
+++ b/sysdeps/stub/execve.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+
+/* Replace the current process, executing PATH with arguments ARGV and
+ environment ENVP. ARGV and ENVP are terminated by NULL pointers. */
+int
+DEFUN(__execve, (path, argv, envp),
+ CONST char *path AND
+ char *CONST argv[] AND char *CONST envp[])
+{
+ if (path == NULL || argv == NULL || envp == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (execve)
+
+weak_alias (__execve, execve)
diff --git a/sysdeps/stub/exp.c b/sysdeps/stub/exp.c
new file mode 100644
index 0000000..ba9e578
--- /dev/null
+++ b/sysdeps/stub/exp.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return e to the X. */
+double
+DEFUN(exp, (x), double x)
+{
+ errno = ENOSYS;
+ return 0.0;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(exp);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/fchdir.c b/sysdeps/stub/fchdir.c
new file mode 100644
index 0000000..ba36ed6
--- /dev/null
+++ b/sysdeps/stub/fchdir.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+/* Change the current directory to FD. */
+int
+DEFUN(fchdir, (fd), int fd)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+stub_warning (fchdir)
diff --git a/sysdeps/stub/fchflags.c b/sysdeps/stub/fchflags.c
new file mode 100644
index 0000000..e9640d2
--- /dev/null
+++ b/sysdeps/stub/fchflags.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+
+/* Change the flags of the file FD refers to to FLAGS. */
+int
+DEFUN(fchflags, (fd, flags), int fd AND int flags)
+{
+ if (fd < 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+stub_warning (fchflags)
diff --git a/sysdeps/stub/fchmod.c b/sysdeps/stub/fchmod.c
new file mode 100644
index 0000000..43d4919
--- /dev/null
+++ b/sysdeps/stub/fchmod.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+/* Change the protections of the file FD refers to to MODE. */
+int
+DEFUN(__fchmod, (fd, mode), int fd AND mode_t mode)
+{
+ if (fd < 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (fchmod)
+
+weak_alias (__fchmod, fchmod)
diff --git a/sysdeps/stub/fchown.c b/sysdeps/stub/fchown.c
new file mode 100644
index 0000000..4af1d0d
--- /dev/null
+++ b/sysdeps/stub/fchown.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Change the owner and group of the file referred to by FD. */
+int
+DEFUN(__fchown, (fd, owner, group),
+ int fd AND uid_t owner AND gid_t group)
+{
+ if (fd < 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (fchown)
+
+weak_alias (__fchown, fchown)
diff --git a/sysdeps/stub/fcntl.c b/sysdeps/stub/fcntl.c
new file mode 100644
index 0000000..e35021a
--- /dev/null
+++ b/sysdeps/stub/fcntl.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <fcntl.h>
+
+/* Perform file control operations on FD. */
+int
+DEFUN(__fcntl, (fd, cmd), int fd AND int cmd DOTS)
+{
+ if (fd < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (fcntl)
+
+weak_alias (__fcntl, fcntl)
diff --git a/sysdeps/stub/fcntlbits.h b/sysdeps/stub/fcntlbits.h
new file mode 100644
index 0000000..2365201
--- /dev/null
+++ b/sysdeps/stub/fcntlbits.h
@@ -0,0 +1,88 @@
+/* O_*, F_*, FD_* bit values for stub configuration.
+Copyright (C) 1991, 1992 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. */
+
+/* These values should be changed as appropriate for your system. */
+
+#ifndef _FCNTLBITS_H
+
+#define _FCNTLBITS_H 1
+
+
+/* File access modes for `open' and `fcntl'. */
+#define O_RDONLY 0 /* Open read-only. */
+#define O_WRONLY 1 /* Open write-only. */
+#define O_RDWR 2 /* Open read/write. */
+
+
+/* Bits OR'd into the second argument to open. */
+#define O_CREAT 0x0200 /* Create file if it doesn't exist. */
+#define O_EXCL 0x0800 /* Fail if file already exists. */
+#define O_TRUNC 0x0400 /* Truncate file to zero length. */
+#define O_NOCTTY 0x0100 /* Don't assign a controlling terminal. */
+
+/* File status flags for `open' and `fcntl'. */
+#define O_APPEND 0x0008 /* Writes append to the file. */
+#define O_NONBLOCK 0x0004 /* Non-blocking I/O. */
+
+#ifdef __USE_BSD
+#define O_NDELAY O_NONBLOCK
+#endif
+
+/* Mask for file access modes. This is system-dependent in case
+ some system ever wants to define some other flavor of access. */
+#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
+
+/* Values for the second argument to `fcntl'. */
+#define F_DUPFD 0 /* Duplicate file descriptor. */
+#define F_GETFD 1 /* Get file descriptor flags. */
+#define F_SETFD 2 /* Set file descriptor flags. */
+#define F_GETFL 3 /* Get file status flags. */
+#define F_SETFL 4 /* Set file status flags. */
+#ifdef __USE_BSD
+#define F_GETOWN 5 /* Get owner (receiver of SIGIO). */
+#define F_SETOWN 6 /* Set owner (receiver of SIGIO). */
+#endif
+#define F_GETLK 7 /* Get record locking info. */
+#define F_SETLK 8 /* Set record locking info. */
+#define F_SETLKW 9 /* Set record locking info, wait. */
+
+/* File descriptor flags used with F_GETFD and F_SETFD. */
+#define FD_CLOEXEC 1 /* Close on exec. */
+
+
+#include <gnu/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. */
+struct flock
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+
+/* Values for the `l_type' field of a `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/fdopen.c b/sysdeps/stub/fdopen.c
new file mode 100644
index 0000000..9865f42
--- /dev/null
+++ b/sysdeps/stub/fdopen.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stdio.h>
+
+/* Open a new stream on a given system file descriptor. */
+FILE *
+DEFUN(fdopen, (fd, mode), int fd AND CONST char *mode)
+{
+ errno = ENOSYS;
+ return NULL;
+}
diff --git a/sysdeps/stub/fexecve.c b/sysdeps/stub/fexecve.c
new file mode 100644
index 0000000..c0990f5
--- /dev/null
+++ b/sysdeps/stub/fexecve.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+
+/* Execute the file FD refers to, overlaying the running program image.
+ ARGV and ENVP are passed to the new program, as for `execve'. */
+int
+DEFUN(fexecve, (fd, argv, envp),
+ int fd AND
+ char *CONST argv[] AND char *CONST envp[])
+{
+ if (fd < 0 || argv == NULL || envp == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+stub_warning (fexecve)
diff --git a/sysdeps/stub/flock.c b/sysdeps/stub/flock.c
new file mode 100644
index 0000000..6855cd4
--- /dev/null
+++ b/sysdeps/stub/flock.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/file.h>
+
+/* Apply or remove an advisory lock, according to OPERATION,
+ on the file FD refers to. */
+int
+DEFUN(__flock, (fd, operation),
+ int fd AND int operation)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+weak_alias (__flock, flock)
diff --git a/sysdeps/stub/fmod.c b/sysdeps/stub/fmod.c
new file mode 100644
index 0000000..e2cdc19
--- /dev/null
+++ b/sysdeps/stub/fmod.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the floating-point modulo remainder of X/Y. */
+double
+DEFUN(fmod, (x, y), double x AND double y)
+{
+ errno = ENOSYS;
+ return(0.0);
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(fmod);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/fork.c b/sysdeps/stub/fork.c
new file mode 100644
index 0000000..0b0b63a
--- /dev/null
+++ b/sysdeps/stub/fork.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+
+/* Clone the calling process, creating an exact copy.
+ Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+int
+DEFUN_VOID(__fork)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (fork)
+
+weak_alias (__fork, fork)
diff --git a/sysdeps/stub/fpathconf.c b/sysdeps/stub/fpathconf.c
new file mode 100644
index 0000000..fe121ba
--- /dev/null
+++ b/sysdeps/stub/fpathconf.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+
+/* Get file-specific information about descriptor FD. */
+long int
+DEFUN(__fpathconf, (fd, name), int fd AND int name)
+{
+ if (fd < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ switch (name)
+ {
+ default:
+ errno = EINVAL;
+ return -1;
+
+ case _PC_LINK_MAX:
+ case _PC_MAX_CANON:
+ case _PC_MAX_INPUT:
+ case _PC_NAME_MAX:
+ case _PC_PATH_MAX:
+ case _PC_PIPE_BUF:
+ case _PC_CHOWN_RESTRICTED:
+ case _PC_NO_TRUNC:
+ case _PC_VDISABLE:
+ break;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+weak_alias (__fpathconf, fpathconf)
diff --git a/sysdeps/stub/frexp.c b/sysdeps/stub/frexp.c
new file mode 100644
index 0000000..f1c3693
--- /dev/null
+++ b/sysdeps/stub/frexp.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Break VALUE into a normalized fraction and an integral power of 2. */
+double
+DEFUN(frexp, (value, exp), double value AND int *exp)
+{
+ errno = ENOSYS;
+ *exp = 0;
+ return 0.0;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(frexp);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/fstat.c b/sysdeps/stub/fstat.c
new file mode 100644
index 0000000..49981bb
--- /dev/null
+++ b/sysdeps/stub/fstat.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+
+/* Get information about the file descriptor FD in BUF. */
+int
+DEFUN(__fstat, (fd, buf), int fd AND struct stat *buf)
+{
+ if (fd < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+ else if (buf == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (fstat)
+
+weak_alias (__fstat, fstat)
diff --git a/sysdeps/stub/fsync.c b/sysdeps/stub/fsync.c
new file mode 100644
index 0000000..f8c92bf
--- /dev/null
+++ b/sysdeps/stub/fsync.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Make all changes done to FD actually appear on disk. */
+int
+DEFUN(fsync, (fd), int fd)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(fsync);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/ftruncate.c b/sysdeps/stub/ftruncate.c
new file mode 100644
index 0000000..8b2d466
--- /dev/null
+++ b/sysdeps/stub/ftruncate.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <errno.h>
+
+/* Truncate the file FD refers to to LENGTH bytes. */
+int
+DEFUN(ftruncate, (fd, length),
+ int fd AND off_t length)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/getcwd.c b/sysdeps/stub/getcwd.c
new file mode 100644
index 0000000..16abaee
--- /dev/null
+++ b/sysdeps/stub/getcwd.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stddef.h>
+
+/* Get the pathname of the current working directory,
+ and put it in SIZE bytes of BUF. Returns NULL if the
+ directory couldn't be determined or SIZE was too small.
+ If successful, returns BUF. In GNU, if BUF is NULL,
+ an array is allocated with `malloc'; the array is SIZE
+ bytes long, unless SIZE <= 0, in which case it is as
+ big as necessary. */
+char *
+DEFUN(getcwd, (buf, size), char *buf AND size_t size)
+{
+ errno = ENOSYS;
+ return NULL;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(getcwd);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/getdents.c b/sysdeps/stub/getdents.c
new file mode 100644
index 0000000..8cf890a
--- /dev/null
+++ b/sysdeps/stub/getdents.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <errno.h>
+#include <sys/types.h>
+
+int
+DEFUN(__getdirentries, (fd, buf, nbytes, basep),
+ int fd AND char *buf AND size_t nbytes AND off_t *basep)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (getdirentries)
+
+weak_alias (__getdirentries, getdirentries)
diff --git a/sysdeps/stub/getdomain.c b/sysdeps/stub/getdomain.c
new file mode 100644
index 0000000..c2159df
--- /dev/null
+++ b/sysdeps/stub/getdomain.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Put the name of the current YP domain in no more than LEN bytes of NAME.
+ The result is null-terminated if LEN is large enough for the full
+ name and the terminator. */
+int
+DEFUN(getdomainname, (name, len),
+ char *name AND size_t len)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+stub_warning (getdomainname)
diff --git a/sysdeps/stub/getdtsz.c b/sysdeps/stub/getdtsz.c
new file mode 100644
index 0000000..e9c9b61
--- /dev/null
+++ b/sysdeps/stub/getdtsz.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Return the maximum number of file descriptors
+ the current process could possibly have. */
+int
+DEFUN_VOID(__getdtablesize)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (getdtablesize)
+
+weak_alias (__getdtablesize, getdtablesize)
diff --git a/sysdeps/stub/getegid.c b/sysdeps/stub/getegid.c
new file mode 100644
index 0000000..6e4e611
--- /dev/null
+++ b/sysdeps/stub/getegid.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Get the effective group ID of the calling process. */
+__gid_t
+DEFUN_VOID(__getegid)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (getegid)
+
+weak_alias (__getegid, getegid)
diff --git a/sysdeps/stub/getenv.c b/sysdeps/stub/getenv.c
new file mode 100644
index 0000000..2f5dd99
--- /dev/null
+++ b/sysdeps/stub/getenv.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/* Return the value of the environment variable NAME. */
+char *
+DEFUN(getenv, (name), CONST char *name)
+{
+ errno = ENOSYS;
+ return(NULL);
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(getenv);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/geteuid.c b/sysdeps/stub/geteuid.c
new file mode 100644
index 0000000..f5f4375
--- /dev/null
+++ b/sysdeps/stub/geteuid.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+
+/* Get the effective user ID of the calling process. */
+__uid_t
+DEFUN_VOID(__geteuid)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (geteuid)
+
+weak_alias (__geteuid, geteuid)
diff --git a/sysdeps/stub/getgid.c b/sysdeps/stub/getgid.c
new file mode 100644
index 0000000..f2bfa76
--- /dev/null
+++ b/sysdeps/stub/getgid.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Get the real group ID of the calling process. */
+gid_t
+DEFUN_VOID(__getgid)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (getgid)
+
+weak_alias (__getgid, getgid)
diff --git a/sysdeps/stub/getgroups.c b/sysdeps/stub/getgroups.c
new file mode 100644
index 0000000..f98d966
--- /dev/null
+++ b/sysdeps/stub/getgroups.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <limits.h>
+
+
+/* If SIZE is zero, return the number of supplementary groups
+ the calling process is in. Otherwise, fill in the group IDs
+ of its supplementary groups in LIST and return the number written. */
+int
+DEFUN(__getgroups, (size, list), int size AND gid_t *list)
+{
+#if defined (NGROUPS_MAX) && NGROUPS_MAX == 0
+ /* The system has no supplementary groups. */
+ return 0;
+#endif
+
+ errno = ENOSYS;
+ return -1;
+}
+
+#if defined (HAVE_GNU_LD) && !(defined (NGROUPS_MAX) && NGROUPS_MAX == 0)
+stub_warning (getgroups);
+#endif
+
+weak_alias (__getgroups, getgroups)
diff --git a/sysdeps/stub/gethostid.c b/sysdeps/stub/gethostid.c
new file mode 100644
index 0000000..74a3d66
--- /dev/null
+++ b/sysdeps/stub/gethostid.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Return the current machine's Internet number. */
+long int
+DEFUN_VOID(gethostid)
+{
+ errno = ENOSYS;
+ return -1L;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(gethostid);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/gethostname.c b/sysdeps/stub/gethostname.c
new file mode 100644
index 0000000..1cf3c7b
--- /dev/null
+++ b/sysdeps/stub/gethostname.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Put the name of the current host in no more than LEN bytes of NAME.
+ The result is null-terminated if LEN is large enough for the full
+ name and the terminator. */
+int
+DEFUN(__gethostname, (name, len),
+ char *name AND size_t len)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (gethostname)
+
+weak_alias (__gethostname, gethostname)
diff --git a/sysdeps/stub/getitimer.c b/sysdeps/stub/getitimer.c
new file mode 100644
index 0000000..75b5488
--- /dev/null
+++ b/sysdeps/stub/getitimer.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991, 1994, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <errno.h>
+#include <sys/time.h>
+
+/* Set *VALUE to the current setting of timer WHICH.
+ Return 0 on success, -1 on errors. */
+int
+DEFUN(__getitimer, (which, value),
+ enum __itimer_which which AND struct itimerval *value)
+{
+ if (value == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (getitimer)
+
+weak_alias (__getitimer, getitimer)
diff --git a/sysdeps/stub/getlogin.c b/sysdeps/stub/getlogin.c
new file mode 100644
index 0000000..bd48eb7
--- /dev/null
+++ b/sysdeps/stub/getlogin.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Return the login name of the user, or NULL if it can't be determined.
+ The returned pointer, if not NULL, is good only until the next call. */
+char *
+DEFUN_VOID(getlogin)
+{
+ errno = ENOSYS;
+ return NULL;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(getlogin);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/getpagesize.c b/sysdeps/stub/getpagesize.c
new file mode 100644
index 0000000..1ee4415
--- /dev/null
+++ b/sysdeps/stub/getpagesize.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+
+/* Return the system page size. */
+size_t
+DEFUN_VOID(__getpagesize)
+{
+ errno = ENOSYS;
+ return 0;
+}
+stub_warning (getpagesize)
+
+weak_alias (__getpagesize, getpagesize)
diff --git a/sysdeps/stub/getpeername.c b/sysdeps/stub/getpeername.c
new file mode 100644
index 0000000..ca9cf35
--- /dev/null
+++ b/sysdeps/stub/getpeername.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Put the address of the peer connected to socket FD into *ADDR
+ (which is *LEN bytes long), and its actual length into *LEN. */
+int
+DEFUN(getpeername, (fd, addr, len),
+ int fd AND struct sockaddr *addr AND size_t *len)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(getpeername);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/getpgid.c b/sysdeps/stub/getpgid.c
new file mode 100644
index 0000000..44efc12
--- /dev/null
+++ b/sysdeps/stub/getpgid.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Get the process group ID of process PID. */
+int
+DEFUN(__getpgid, (pid), pid_t pid)
+{
+ return pid;
+}
+weak_alias (__getpgid, getpgid)
+
+stub_warning (getpgid)
diff --git a/sysdeps/stub/getpid.c b/sysdeps/stub/getpid.c
new file mode 100644
index 0000000..270c909
--- /dev/null
+++ b/sysdeps/stub/getpid.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+
+/* Get the process ID of the calling process. */
+int
+DEFUN_VOID(__getpid)
+{
+ errno = ENOSYS;
+ return(-1);
+}
+stub_warning (getpid)
+
+weak_alias (__getpid, getpid)
diff --git a/sysdeps/stub/getppid.c b/sysdeps/stub/getppid.c
new file mode 100644
index 0000000..d6547c7
--- /dev/null
+++ b/sysdeps/stub/getppid.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+
+/* Get the parent process ID of the calling process. */
+int
+DEFUN_VOID(__getppid)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (getppid)
+
+weak_alias (__getppid, getppid)
diff --git a/sysdeps/stub/getpriority.c b/sysdeps/stub/getpriority.c
new file mode 100644
index 0000000..3c04044
--- /dev/null
+++ b/sysdeps/stub/getpriority.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/resource.h>
+
+/* Return the highest priority of any process specified by WHICH and WHO
+ (see <sys/resource.h>); if WHO is zero, the current process, process group,
+ or user (as specified by WHO) is used. A lower priority number means higher
+ priority. Priorities range from PRIO_MIN to PRIO_MAX. */
+int
+DEFUN(getpriority, (which, who),
+ enum __priority_which which AND int who)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(getpriority);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/getrlimit.c b/sysdeps/stub/getrlimit.c
new file mode 100644
index 0000000..ed6f04f
--- /dev/null
+++ b/sysdeps/stub/getrlimit.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <sys/resource.h>
+#include <errno.h>
+
+/* Put the soft and hard limits for RESOURCE in *RLIMITS.
+ Returns 0 if successful, -1 if not (and sets errno). */
+int
+DEFUN(getrlimit, (resource, rlimits),
+ enum __rlimit_resource resource AND struct rlimit *rlimits)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(getrlimit);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/getrusage.c b/sysdeps/stub/getrusage.c
new file mode 100644
index 0000000..6417c8d
--- /dev/null
+++ b/sysdeps/stub/getrusage.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <sys/resource.h>
+#include <errno.h>
+
+/* Return resource usage information on process indicated by WHO
+ and put it in *USAGE. Returns 0 for success, -1 for failure. */
+int
+DEFUN(__getrusage, (who, usage),
+ enum __rusage_who who AND struct rusage *usage)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (getrusage)
+
+weak_alias (__getrusage, getrusage)
diff --git a/sysdeps/stub/getsockname.c b/sysdeps/stub/getsockname.c
new file mode 100644
index 0000000..93a5f8e
--- /dev/null
+++ b/sysdeps/stub/getsockname.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Put the local address of FD into *ADDR and its length in *LEN. */
+int
+DEFUN(getsockname, (fd, addr, len),
+ int fd AND struct sockaddr *addr AND size_t *len)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(getsockname);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/getsockopt.c b/sysdeps/stub/getsockopt.c
new file mode 100644
index 0000000..aa71e72
--- /dev/null
+++ b/sysdeps/stub/getsockopt.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Put the current value for socket FD's option OPTNAME at protocol level LEVEL
+ into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's
+ actual length. Returns 0 on success, -1 for errors. */
+int
+DEFUN(getsockopt, (fd, level, optname, optval, optlen),
+ int fd AND int level AND int optname AND
+ PTR optval AND size_t *optlen)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(getsockopt);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/gettimeofday.c b/sysdeps/stub/gettimeofday.c
new file mode 100644
index 0000000..74e4619
--- /dev/null
+++ b/sysdeps/stub/gettimeofday.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/time.h>
+
+/* Get the current time of day and timezone information,
+ putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
+ Returns 0 on success, -1 on errors. */
+int
+DEFUN(__gettimeofday, (tv, tz),
+ struct timeval *tv AND struct timezone *tz)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (gettimeofday)
+
+weak_alias (__gettimeofday, gettimeofday)
diff --git a/sysdeps/stub/getuid.c b/sysdeps/stub/getuid.c
new file mode 100644
index 0000000..ebdd268
--- /dev/null
+++ b/sysdeps/stub/getuid.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Get the real user ID of the calling process. */
+uid_t
+DEFUN_VOID(__getuid)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (getuid)
+
+weak_alias (__getuid, getuid)
diff --git a/sysdeps/stub/gtty.c b/sysdeps/stub/gtty.c
new file mode 100644
index 0000000..5695d69
--- /dev/null
+++ b/sysdeps/stub/gtty.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sgtty.h>
+#include <stddef.h>
+
+/* Fill in *PARAMS with terminal parameters associated with FD. */
+int
+DEFUN(gtty, (fd, params),
+ int fd AND struct sgttyb *params)
+{
+ if (params == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/huge_val.h b/sysdeps/stub/huge_val.h
new file mode 100644
index 0000000..5c5d379
--- /dev/null
+++ b/sysdeps/stub/huge_val.h
@@ -0,0 +1,27 @@
+/* Stub `HUGE_VAL' constant.
+ Used by <stdlib.h> and <math.h> functions for overflow.
+
+Copyright (C) 1992 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 _HUGE_VAL_H
+#define _HUGE_VAL_H 1
+
+#define HUGE_VAL 1e37
+
+#endif /* huge_val.h */
diff --git a/sysdeps/stub/init-fault.c b/sysdeps/stub/init-fault.c
new file mode 100644
index 0000000..1ba4680
--- /dev/null
+++ b/sysdeps/stub/init-fault.c
@@ -0,0 +1,38 @@
+/* Set up a thread_state for proc_handle_exceptions. Stub 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. */
+
+#include <hurd.h>
+#include <mach/thread_status.h>
+
+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 hurd_thread_state *ts = state;
+ memset (ts, 0, sizeof (*ts));
+ /* Point the SP in TS at the fault stack,
+ and set the PC to run `faulted' (above). */
+ #error "Need to write sysdeps/mach/hurd/MACHINE/init_fault.c"
+}
diff --git a/sysdeps/stub/init-posix.c b/sysdeps/stub/init-posix.c
new file mode 100644
index 0000000..4673c14
--- /dev/null
+++ b/sysdeps/stub/init-posix.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+
+#ifndef HAVE_GNU_LD
+
+void
+DEFUN_VOID(__init_posix)
+{
+ return;
+}
+
+#endif
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(__init_posix);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/ioctl.c b/sysdeps/stub/ioctl.c
new file mode 100644
index 0000000..579ddab
--- /dev/null
+++ b/sysdeps/stub/ioctl.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+
+/* Perform the I/O control operation specified by REQUEST on FD.
+ The actual type and use of ARG and the return value depend on REQUEST. */
+int
+DEFUN(__ioctl, (fd, request),
+ int fd AND unsigned long int request DOTS)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (ioctl)
+
+weak_alias (__ioctl, ioctl)
diff --git a/sysdeps/stub/ioctls.h b/sysdeps/stub/ioctls.h
new file mode 100644
index 0000000..3b6178b
--- /dev/null
+++ b/sysdeps/stub/ioctls.h
@@ -0,0 +1 @@
+/* This space intentionally left blank. */
diff --git a/sysdeps/stub/isatty.c b/sysdeps/stub/isatty.c
new file mode 100644
index 0000000..05477f8
--- /dev/null
+++ b/sysdeps/stub/isatty.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Return 1 if FD is a terminal, 0 if not. */
+int
+DEFUN(__isatty, (fd), int fd)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+weak_alias (__isatty, isatty)
diff --git a/sysdeps/stub/isinf.c b/sysdeps/stub/isinf.c
new file mode 100644
index 0000000..aa02eb1
--- /dev/null
+++ b/sysdeps/stub/isinf.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+
+/* Return 0 if VALUE is finite or NaN, +1 if it
+ is +Infinity, -1 if it is -Infinity. */
+int
+DEFUN(__isinf, (value), double value)
+{
+ return 0;
+}
+weak_alias (__isinf, isinf)
+
+stub_warning (__isinf)
diff --git a/sysdeps/stub/isinfl.c b/sysdeps/stub/isinfl.c
new file mode 100644
index 0000000..71065c7
--- /dev/null
+++ b/sysdeps/stub/isinfl.c
@@ -0,0 +1,33 @@
+/* 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. */
+
+#include <math.h>
+
+#undef __isinfl
+#undef isinfl
+
+
+/* Return 0 if VALUE is finite or NaN, +1 if it
+ is +Infinity, -1 if it is -Infinity. */
+int
+__isinfl (long double value)
+{
+ return 0;
+}
+
+weak_alias (__isinfl, isinfl);
diff --git a/sysdeps/stub/isnanl.c b/sysdeps/stub/isnanl.c
new file mode 100644
index 0000000..c785b35
--- /dev/null
+++ b/sysdeps/stub/isnanl.c
@@ -0,0 +1,33 @@
+/* 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. */
+
+#include <math.h>
+
+#undef __isnanl
+#undef isnanl
+
+
+/* Return nonzero if VALUE is not a number. */
+
+int
+__isnanl (long double value)
+{
+ return 0;
+}
+
+weak_alias (__isnanl, isnanl);
diff --git a/sysdeps/stub/jmp_buf.h b/sysdeps/stub/jmp_buf.h
new file mode 100644
index 0000000..6620e5a
--- /dev/null
+++ b/sysdeps/stub/jmp_buf.h
@@ -0,0 +1,3 @@
+/* Define the machine-dependent type `jmp_buf'. Stub version. */
+
+typedef int __jmp_buf[1];
diff --git a/sysdeps/stub/kill.c b/sysdeps/stub/kill.c
new file mode 100644
index 0000000..b9a8b0e
--- /dev/null
+++ b/sysdeps/stub/kill.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+
+/* Send signal SIG to process number PID. If PID is zero,
+ send SIG to all processes in the current process's process group.
+ If PID is < -1, send SIG to all processes in process group - PID. */
+int
+DEFUN(__kill, (pid, sig), int pid AND int sig)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (kill)
+
+weak_alias (__kill, kill)
diff --git a/sysdeps/stub/killpg.c b/sysdeps/stub/killpg.c
new file mode 100644
index 0000000..eb05bca
--- /dev/null
+++ b/sysdeps/stub/killpg.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+
+/* Send SIG to all processes in process group PGRP.
+ If PGRP is zero, send SIG to all processes in
+ the current process's process group. */
+int
+DEFUN(killpg, (pgrp, sig), __pid_t pgrp AND int sig)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/ldbl2mpn.c b/sysdeps/stub/ldbl2mpn.c
new file mode 100644
index 0000000..b8e920d
--- /dev/null
+++ b/sysdeps/stub/ldbl2mpn.c
@@ -0,0 +1,32 @@
+/* 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. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
+/* Convert a `long double' to a multi-precision integer representing the
+ significand scaled up by the highest possible number of significant bits
+ of fraction (LDBL_MANT_DIG), and an integral power of two (MPN frexpl). */
+
+mp_size_t
+__mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
+ int *expt, int *is_neg,
+ double value)
+{
+#error "not implemented for this floating point format"
+}
diff --git a/sysdeps/stub/libc_fatal.c b/sysdeps/stub/libc_fatal.c
new file mode 100644
index 0000000..5a5d2fb
--- /dev/null
+++ b/sysdeps/stub/libc_fatal.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+
+/* Abort with an error message. */
+__NORETURN
+void
+DEFUN(__libc_fatal, (message), CONST char *message)
+{
+ /* This function should write MESSAGE out in the most reliable way.
+ It is called in situations like internal stdio lossage. */
+
+ abort ();
+}
diff --git a/sysdeps/stub/link.c b/sysdeps/stub/link.c
new file mode 100644
index 0000000..c5ea713
--- /dev/null
+++ b/sysdeps/stub/link.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+
+/* Make a link to FROM called TO. */
+int
+DEFUN(__link, (from, to), CONST char *from AND CONST char *to)
+{
+ if (from == NULL || to == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (link)
+
+weak_alias (__link, link)
diff --git a/sysdeps/stub/listen.c b/sysdeps/stub/listen.c
new file mode 100644
index 0000000..40bd998
--- /dev/null
+++ b/sysdeps/stub/listen.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Prepare to accept connections on socket FD.
+ N connection requests will be queued before further requests are refused.
+ Returns 0 on success, -1 for errors. */
+int
+DEFUN(listen, (fd, n),
+ int fd AND unsigned int n)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(listen);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/local_lim.h b/sysdeps/stub/local_lim.h
new file mode 100644
index 0000000..771d1b0
--- /dev/null
+++ b/sysdeps/stub/local_lim.h
@@ -0,0 +1,3 @@
+/* This file should define the implementaton-specific limits described
+ in posix[12]_lim.h. If there are no useful values to give a limit,
+ don't define it. */
diff --git a/sysdeps/stub/log.c b/sysdeps/stub/log.c
new file mode 100644
index 0000000..49ed802
--- /dev/null
+++ b/sysdeps/stub/log.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the natural logarithm of X. */
+double
+DEFUN(log, (x), double x)
+{
+ errno = ENOSYS;
+ return(0.0);
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(log);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/log10.c b/sysdeps/stub/log10.c
new file mode 100644
index 0000000..26fb854
--- /dev/null
+++ b/sysdeps/stub/log10.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the base-ten logarithm of X. */
+double
+DEFUN(log10, (x), double x)
+{
+ errno = ENOSYS;
+ return 0.0;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(log10);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/logb.c b/sysdeps/stub/logb.c
new file mode 100644
index 0000000..f5af6bf
--- /dev/null
+++ b/sysdeps/stub/logb.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <math.h>
+#include <errno.h>
+
+/* Return the base 2 signed integral exponent of X. */
+double
+DEFUN(__logb, (x), double x)
+{
+ errno = ENOSYS;
+ return 0.0;
+}
+stub_warning (logb)
+weak_alias (__logb, logb)
diff --git a/sysdeps/stub/longjmp-ctx.c b/sysdeps/stub/longjmp-ctx.c
new file mode 100644
index 0000000..11ed609
--- /dev/null
+++ b/sysdeps/stub/longjmp-ctx.c
@@ -0,0 +1,32 @@
+/* Perform a `longjmp' on a `struct sigcontext'. Stub 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. */
+
+#include <setjmp.h>
+#include <signal.h>
+#include <string.h>
+
+void
+_hurd_longjmp_sigcontext (struct sigcontext *scp, jmp_buf env, int retval)
+{
+ memset (scp, 0, sizeof (*scp));
+ /* Set all the registers in *SCP to the values described by ENV and RETVAL.
+ After this, calling `__sigreturn (SCP)' in that thread should be just
+ like calling `longjmp (ENV, RETVAL)'. */
+ #error "Need to write sysdeps/mach/hurd/MACHINE/longjmp-ctx.c"
+}
diff --git a/sysdeps/stub/longjmp-ts.c b/sysdeps/stub/longjmp-ts.c
new file mode 100644
index 0000000..1c50292
--- /dev/null
+++ b/sysdeps/stub/longjmp-ts.c
@@ -0,0 +1,32 @@
+/* Perform a `longjmp' on a Mach thread_state. Stub 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. */
+
+#include <setjmp.h>
+#include <mach/thread_status.h>
+
+/* Set up STATE to do the equivalent of `longjmp (ENV, VAL);'. */
+
+void
+_hurd_longjmp_thread_state (void *state, jmp_buf env, int val)
+{
+ /* Set all the registers in *STATE to the values described by ENV and
+ RETVAL. After this, setting that thread's state to STATE should be
+ just like calling `longjmp (ENV, RETVAL)'. */
+ #error "Need to write sysdeps/mach/hurd/MACHINE/longjmp-ctx.c"
+}
diff --git a/sysdeps/stub/lseek.c b/sysdeps/stub/lseek.c
new file mode 100644
index 0000000..6d9c366
--- /dev/null
+++ b/sysdeps/stub/lseek.c
@@ -0,0 +1,49 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Seek to OFFSET on FD, starting from WHENCE. */
+off_t
+DEFUN(__lseek, (fd, offset, whence), int fd AND off_t offset AND int whence)
+{
+ if (fd < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+ switch (whence)
+ {
+ case SEEK_SET:
+ case SEEK_CUR:
+ case SEEK_END:
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (lseek)
+
+weak_alias (__lseek, lseek)
diff --git a/sysdeps/stub/lstat.c b/sysdeps/stub/lstat.c
new file mode 100644
index 0000000..0e69a08
--- /dev/null
+++ b/sysdeps/stub/lstat.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+
+/* Get file information about FILE in BUF.
+ If FILE is a symbolic link, do not follow it. */
+int
+DEFUN(__lstat, (file, buf), CONST char *file AND struct stat *buf)
+{
+ if (file == NULL || buf == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (lstat)
+
+weak_alias (__lstat, lstat)
diff --git a/sysdeps/stub/machine-lock.h b/sysdeps/stub/machine-lock.h
new file mode 100644
index 0000000..35831c2
--- /dev/null
+++ b/sysdeps/stub/machine-lock.h
@@ -0,0 +1,64 @@
+/* Machine-specific definition for spin locks. Stub 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. */
+
+#ifndef _MACHINE_LOCK_H
+#define _MACHINE_LOCK_H
+
+/* The type of a spin lock variable. */
+
+typedef volatile int __spin_lock_t;
+
+/* Value to initialize `__spin_lock_t' variables to. */
+
+#define __SPIN_LOCK_INITIALIZER 0
+
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE extern __inline
+#endif
+
+/* Unlock LOCK. */
+
+_EXTERN_INLINE void
+__spin_unlock (__spin_lock_t *__lock)
+{
+ *__lock = 0;
+}
+
+/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */
+
+_EXTERN_INLINE int
+__spin_try_lock (__spin_lock_t *__lock)
+{
+ if (*__lock)
+ return 0;
+ *__lock = 1;
+ return 1;
+}
+
+/* Return nonzero if LOCK is locked. */
+
+_EXTERN_INLINE int
+__spin_lock_locked (__spin_lock_t *__lock)
+{
+ return *__lock != 0;
+}
+
+
+#endif /* machine-lock.h */
diff --git a/sysdeps/stub/machine-sp.h b/sysdeps/stub/machine-sp.h
new file mode 100644
index 0000000..3bcfd95
--- /dev/null
+++ b/sysdeps/stub/machine-sp.h
@@ -0,0 +1,37 @@
+/* Machine-specific function to return the stack pointer. Stub 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. */
+
+#ifndef _MACHINE_SP_H
+#define _MACHINE_SP_H
+
+/* Return the current stack pointer. */
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE extern __inline
+#endif
+
+_EXTERN_INLINE void *
+__thread_stack_pointer (void)
+{
+ register void *__sp__ ("{STACK-POINTER}");
+ return __sp__;
+}
+
+#endif /* machine-sp.h */
+
diff --git a/sysdeps/stub/madvise.c b/sysdeps/stub/madvise.c
new file mode 100644
index 0000000..631a151
--- /dev/null
+++ b/sysdeps/stub/madvise.c
@@ -0,0 +1,31 @@
+/* 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. */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <errno.h>
+
+/* Advise the system about particular usage patterns the program follows
+ for the region starting at ADDR and extending LEN bytes. */
+
+int
+madvise (caddr_t addr, size_t len, int advice)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/mkdir.c b/sysdeps/stub/mkdir.c
new file mode 100644
index 0000000..9822b5f
--- /dev/null
+++ b/sysdeps/stub/mkdir.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+
+/* Create a directory named PATH with protections MODE. */
+int
+DEFUN(__mkdir, (path, mode), CONST char *path AND mode_t mode)
+{
+ if (path == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (mkdir)
+
+weak_alias (__mkdir, mkdir)
diff --git a/sysdeps/stub/mkfifo.c b/sysdeps/stub/mkfifo.c
new file mode 100644
index 0000000..2b5c29c
--- /dev/null
+++ b/sysdeps/stub/mkfifo.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+
+/* Create a named pipe (FIFO) named PATH with protections MODE. */
+int
+DEFUN(mkfifo, (path, mode), CONST char *path AND mode_t mode)
+{
+ if (path == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(mkfifo);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/mknod.c b/sysdeps/stub/mknod.c
new file mode 100644
index 0000000..66f88aa
--- /dev/null
+++ b/sysdeps/stub/mknod.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+/* Create a device file named PATH, with permission and special bits MODE
+ and device number DEV (which can be constructed from major and minor
+ device numbers with the `makedev' macro above). */
+int
+DEFUN(__mknod, (path, mode, dev),
+ CONST char *path AND mode_t mode AND dev_t dev)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (mknod)
+
+weak_alias (__mknod, mknod)
diff --git a/sysdeps/stub/mkstemp.c b/sysdeps/stub/mkstemp.c
new file mode 100644
index 0000000..0adc52e
--- /dev/null
+++ b/sysdeps/stub/mkstemp.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <errno.h>
+
+/* Generate a unique temporary file name from TEMPLATE.
+ The last six characters of TEMPLATE must be "XXXXXX";
+ they are replaced with a string that makes the filename unique.
+ Returns a file descriptor open on the file for reading and writing. */
+int
+DEFUN(mkstemp, (template), char *template)
+{
+ if (strcmp(&template[strlen(template) - 6], "XXXXXX"))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/mktemp.c b/sysdeps/stub/mktemp.c
new file mode 100644
index 0000000..33a1295
--- /dev/null
+++ b/sysdeps/stub/mktemp.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+#include <errno.h>
+
+/* Generate a unique temporary file name from TEMPLATE.
+ The last six characters of TEMPLATE must be "XXXXXX";
+ they are replaced with a string that makes the filename unique. */
+char *
+DEFUN(mktemp, (template), char *template)
+{
+ if (strcmp(&template[strlen(template) - 6], "XXXXXX"))
+ {
+ errno = EINVAL;
+ return template;
+ }
+
+ errno = ENOSYS;
+ return NULL;
+}
diff --git a/sysdeps/stub/mmap.c b/sysdeps/stub/mmap.c
new file mode 100644
index 0000000..5ee4fa7
--- /dev/null
+++ b/sysdeps/stub/mmap.c
@@ -0,0 +1,38 @@
+/* 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. */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <errno.h>
+
+/* Map addresses starting near ADDR and extending for LEN bytes. from
+ OFFSET into the file FD describes according to PROT and FLAGS. If ADDR
+ is nonzero, it is the desired mapping address. If the MAP_FIXED bit is
+ set in FLAGS, the mapping will be at ADDR exactly (which must be
+ page-aligned); otherwise the system chooses a convenient nearby address.
+ The return value is the actual mapping address chosen or (caddr_t) -1
+ for errors (in which case `errno' is set). A successful `mmap' call
+ deallocates any previous mapping for the affected region. */
+
+caddr_t
+mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
+{
+ errno = ENOSYS;
+ return (caddr_t) -1;
+}
+
diff --git a/sysdeps/stub/morecore.c b/sysdeps/stub/morecore.c
new file mode 100644
index 0000000..4f11e9c
--- /dev/null
+++ b/sysdeps/stub/morecore.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <errno.h>
+
+#define _MALLOC_INTERNAL
+#include <malloc.h>
+
+/* Allocate INCREMENT more bytes of data space,
+ and return the start of data space, or NULL on errors.
+ If INCREMENT is negative, shrink data space. */
+__ptr_t
+DEFUN(__default_morecore, (increment), ptrdiff_t increment)
+{
+ errno = ENOSYS;
+ return NULL;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(__default_morecore);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/mpn2dbl.c b/sysdeps/stub/mpn2dbl.c
new file mode 100644
index 0000000..7599147
--- /dev/null
+++ b/sysdeps/stub/mpn2dbl.c
@@ -0,0 +1,31 @@
+/* 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. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include <float.h>
+
+/* Convert a multi-precision integer of the needed number of bits and an
+ integral power of two to a `double'. */
+
+double
+__mpn_construct_double (mp_srcptr frac_ptr, int expt, int negative)
+{
+#error "__mpn_construct_double not implemented for this floating point format"
+}
+
diff --git a/sysdeps/stub/mpn2flt.c b/sysdeps/stub/mpn2flt.c
new file mode 100644
index 0000000..ca28c98
--- /dev/null
+++ b/sysdeps/stub/mpn2flt.c
@@ -0,0 +1,31 @@
+/* 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. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include <float.h>
+
+/* Convert a multi-precision integer of the needed number of bits and an
+ integral power of two to a `float'. */
+
+float
+__mpn_construct_float (mp_srcptr frac_ptr, int expt, int negative)
+{
+#error "__mpn_construct_float not implemented for this floating point format"
+}
+
diff --git a/sysdeps/stub/mpn2ldbl.c b/sysdeps/stub/mpn2ldbl.c
new file mode 100644
index 0000000..57060dd
--- /dev/null
+++ b/sysdeps/stub/mpn2ldbl.c
@@ -0,0 +1,31 @@
+/* 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. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+#include <float.h>
+
+/* Convert a multi-precision integer of the needed number of bits and an
+ integral power of two to a `long double'. */
+
+long double
+__mpn_construct_long_double (mp_srcptr frac_ptr, int expt, int negative)
+{
+#error "__mpn_construct_long_double not implemented for floating point format"
+}
+
diff --git a/sysdeps/stub/mprotect.c b/sysdeps/stub/mprotect.c
new file mode 100644
index 0000000..169e6c3
--- /dev/null
+++ b/sysdeps/stub/mprotect.c
@@ -0,0 +1,33 @@
+/* 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. */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <errno.h>
+
+/* Change the memory protection of the region starting at ADDR and
+ extending LEN bytes to PROT. Returns 0 if successful, -1 for errors
+ (and sets errno). */
+
+int
+mprotect (caddr_t addr, size_t len, int prot)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
diff --git a/sysdeps/stub/msync.c b/sysdeps/stub/msync.c
new file mode 100644
index 0000000..ed55915
--- /dev/null
+++ b/sysdeps/stub/msync.c
@@ -0,0 +1,32 @@
+/* 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. */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <errno.h>
+
+/* Synchronize the region starting at ADDR and extending LEN bytes with the
+ file it maps. Filesystem operations on a file being mapped are
+ unpredictable before this is done. */
+
+int
+msync (caddr_t addr, size_t len)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/munmap.c b/sysdeps/stub/munmap.c
new file mode 100644
index 0000000..c12889a
--- /dev/null
+++ b/sysdeps/stub/munmap.c
@@ -0,0 +1,32 @@
+/* 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. */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <errno.h>
+
+/* Deallocate any mapping for the region starting at ADDR and extending LEN
+ bytes. Returns 0 if successful, -1 for errors (and sets errno). */
+
+int
+munmap (caddr_t addr, size_t len)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
diff --git a/sysdeps/stub/nan.h b/sysdeps/stub/nan.h
new file mode 100644
index 0000000..9dd5341
--- /dev/null
+++ b/sysdeps/stub/nan.h
@@ -0,0 +1,6 @@
+#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/nice.c b/sysdeps/stub/nice.c
new file mode 100644
index 0000000..c2ca089
--- /dev/null
+++ b/sysdeps/stub/nice.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Increment the scheduling priority of the calling process by INCR.
+ The superuser may use a negative INCR to decrement the priority. */
+int
+DEFUN(nice, (incr), int incr)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning (nice);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/nlist.c b/sysdeps/stub/nlist.c
new file mode 100644
index 0000000..d0e0e59
--- /dev/null
+++ b/sysdeps/stub/nlist.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <nlist.h>
+#include <stddef.h>
+
+/* Search the executable FILE for symbols matching those in NL,
+ which is terminated by an element with a NULL `n_un.n_name' member,
+ and fill in the elements of NL. */
+int
+DEFUN(nlist, (file, nl),
+ CONST char *file AND struct nlist *nl)
+{
+ if (nl == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(nlist);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/open.c b/sysdeps/stub/open.c
new file mode 100644
index 0000000..af0d272
--- /dev/null
+++ b/sysdeps/stub/open.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stddef.h>
+
+/* Open FILE with access OFLAG. If OFLAG includes O_CREAT,
+ a third argument is the file protection. */
+int
+DEFUN(__open, (file, oflag), CONST char *file AND int oflag DOTS)
+{
+ int mode;
+
+ if (file == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (oflag & O_CREAT)
+ {
+ va_list arg;
+ va_start(arg, oflag);
+ mode = va_arg(arg, int);
+ va_end(arg);
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (open)
+
+weak_alias (__open, open)
diff --git a/sysdeps/stub/opendir.c b/sysdeps/stub/opendir.c
new file mode 100644
index 0000000..e3697d7
--- /dev/null
+++ b/sysdeps/stub/opendir.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <dirent.h>
+
+
+/* Open a directory stream on NAME. */
+DIR *
+DEFUN(opendir, (name), CONST char *name)
+{
+ errno = ENOSYS;
+ return(NULL);
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(opendir);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/pathconf.c b/sysdeps/stub/pathconf.c
new file mode 100644
index 0000000..f14d10f
--- /dev/null
+++ b/sysdeps/stub/pathconf.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+
+/* Get file-specific information about PATH. */
+long int
+DEFUN(__pathconf, (path, name), CONST char *path AND int name)
+{
+ if (path == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ return __fpathconf (0, name);
+}
+
+weak_alias (__pathconf, pathconf)
diff --git a/sysdeps/stub/pause.c b/sysdeps/stub/pause.c
new file mode 100644
index 0000000..6d26864
--- /dev/null
+++ b/sysdeps/stub/pause.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+
+/* Suspend the process until a signal arrives.
+ This is supposed to always return -1 and set errno to EINTR,
+ but rules were meant to be broken. */
+int
+DEFUN_VOID(pause)
+{
+ errno = ENOSYS;
+ return(-1);
+}
+
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(pause);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/pipe.c b/sysdeps/stub/pipe.c
new file mode 100644
index 0000000..acef99b
--- /dev/null
+++ b/sysdeps/stub/pipe.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stddef.h>
+
+/* Create a one-way communication channel (__pipe).
+ If successul, two file descriptors are stored in PIPEDES;
+ bytes written on PIPEDES[1] can be read from PIPEDES[0].
+ Returns 0 if successful, -1 if not. */
+int
+DEFUN(__pipe, (__pipedes), int __pipedes[2])
+{
+ if (__pipedes == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (pipe)
+
+weak_alias (__pipe, pipe)
diff --git a/sysdeps/stub/pipestream.c b/sysdeps/stub/pipestream.c
new file mode 100644
index 0000000..143cf71
--- /dev/null
+++ b/sysdeps/stub/pipestream.c
@@ -0,0 +1,64 @@
+/* Copyright (C) 1991, 1993 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <signal.h>
+#include <stdio.h>
+#include <errno.h>
+
+
+/* Open a new stream that is a one-way pipe to a
+ child process running the given shell command. */
+FILE *
+DEFUN(popen, (command, mode), CONST char *command AND CONST char *mode)
+{
+ if (command == NULL || mode == NULL || (*mode != 'r' && *mode != 'w'))
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ errno = ENOSYS;
+ return NULL;
+}
+
+/* Close a stream opened by popen and return its status.
+ Returns -1 if the stream was not opened by popen. */
+int
+DEFUN(pclose, (stream), register FILE *stream)
+{
+ if (!__validfp (stream) || !stream->__ispipe)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(popen);
+stub_warning(pclose);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/poll.c b/sysdeps/stub/poll.c
new file mode 100644
index 0000000..3436eaa
--- /dev/null
+++ b/sysdeps/stub/poll.c
@@ -0,0 +1,36 @@
+/* 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. */
+
+#include <sys/poll.h>
+#include <errno.h>
+
+/* Poll the file descriptors described by the NFDS structures starting at
+ FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
+ an event to occur; if TIMEOUT is -1, block until an event occurs.
+ Returns the number of file descriptors with events, zero if timed out,
+ or -1 for errors. */
+
+int
+poll (fds, nfds, timeout)
+ struct pollfd *fds;
+ unsigned long int nfds;
+ int timeout;
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/posix_opt.h b/sysdeps/stub/posix_opt.h
new file mode 100644
index 0000000..54f5a79
--- /dev/null
+++ b/sysdeps/stub/posix_opt.h
@@ -0,0 +1,2 @@
+/* This file should define the POSIX options described in <unistd.h>,
+ or leave them undefined, as appropriate. */
diff --git a/sysdeps/stub/ptrace.c b/sysdeps/stub/ptrace.c
new file mode 100644
index 0000000..6bd5917
--- /dev/null
+++ b/sysdeps/stub/ptrace.c
@@ -0,0 +1,108 @@
+/* Copyright (C) 1991, 1992, 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/ptrace.h>
+#include <sys/types.h>
+#include <stdarg.h>
+
+/* Perform process tracing functions. REQUEST is one of the values
+ in <sys/ptrace.h>, and determines the action to be taken.
+ For all requests except PTRACE_TRACEME, PID specifies the process to be
+ traced.
+
+ PID and the other arguments described above for the various requests should
+ appear (those that are used for the particular request) as:
+ pid_t PID, void *ADDR, int DATA, void *ADDR2
+ after PID. */
+int
+DEFUN(ptrace, (request), enum __ptrace_request request DOTS)
+{
+ pid_t pid;
+ PTR addr;
+ PTR addr2;
+ int data;
+ va_list ap;
+
+ switch (request)
+ {
+ case PTRACE_TRACEME:
+ case PTRACE_CONT:
+ case PTRACE_KILL:
+ case PTRACE_SINGLESTEP:
+ case PTRACE_ATTACH:
+ case PTRACE_DETACH:
+ break;
+
+ case PTRACE_PEEKTEXT:
+ case PTRACE_PEEKDATA:
+ case PTRACE_PEEKUSER:
+ case PTRACE_GETREGS:
+ case PTRACE_SETREGS:
+#ifdef PTRACE_GETFPREGS
+ case PTRACE_GETFPGEGS:
+#endif
+ case PTRACE_SETFPREGS:
+ case PTRACE_GETFPAREGS:
+ case PTRACE_SETFPAREGS:
+ va_start(ap, request);
+ pid = va_arg(ap, pid_t);
+ addr = va_arg(ap, PTR);
+ va_end(ap);
+ break;
+
+ case PTRACE_POKETEXT:
+ case PTRACE_POKEDATA:
+ case PTRACE_POKEUSER:
+ va_start(ap, request);
+ pid = va_arg(ap, pid_t);
+ addr = va_arg(ap, PTR);
+ data = va_arg(ap, int);
+ va_end(ap);
+ break;
+
+ case PTRACE_READDATA:
+ case PTRACE_WRITEDATA:
+ case PTRACE_READTEXT:
+ case PTRACE_WRITETEXT:
+ va_start(ap, request);
+ pid = va_arg(ap, pid_t);
+ addr = va_arg(ap, PTR);
+ data = va_arg(ap, int);
+ addr2 = va_arg(ap, PTR);
+ va_end(ap);
+ break;
+
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(ptrace);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/putenv.c b/sysdeps/stub/putenv.c
new file mode 100644
index 0000000..964655f
--- /dev/null
+++ b/sysdeps/stub/putenv.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/* Put STRING, which is of the form "NAME=VALUE", in the environment.
+ If there is no `=', remove NAME from the environment. */
+int
+DEFUN(putenv, (string), CONST char *string)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(putenv);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/raise.c b/sysdeps/stub/raise.c
new file mode 100644
index 0000000..b3af76b
--- /dev/null
+++ b/sysdeps/stub/raise.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <signal.h>
+#include <errno.h>
+
+/* Raise the signal SIG. */
+int
+DEFUN(raise, (sig), int sig)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/read.c b/sysdeps/stub/read.c
new file mode 100644
index 0000000..0143132
--- /dev/null
+++ b/sysdeps/stub/read.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stddef.h>
+
+/* Read NBYTES into BUF from FD. Return the number read or -1. */
+ssize_t
+DEFUN(__read, (fd, buf, nbytes),
+ int fd AND PTR buf AND size_t nbytes)
+{
+ if (nbytes == 0)
+ return 0;
+ if (fd < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+ if (buf == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (read)
+
+weak_alias (__read, read)
diff --git a/sysdeps/stub/readdir.c b/sysdeps/stub/readdir.c
new file mode 100644
index 0000000..bce3df2
--- /dev/null
+++ b/sysdeps/stub/readdir.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <dirent.h>
+
+/* Read a directory entry from DIRP. */
+struct dirent *
+DEFUN(readdir, (dirp), DIR *dirp)
+{
+ errno = ENOSYS;
+ return(NULL);
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(readdir);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/readlink.c b/sysdeps/stub/readlink.c
new file mode 100644
index 0000000..b640a8d
--- /dev/null
+++ b/sysdeps/stub/readlink.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Read the contents of the symbolic link PATH into no more than
+ LEN bytes of BUF. The contents are not null-terminated.
+ Returns the number of characters read, or -1 for errors. */
+int
+DEFUN(__readlink, (path, buf, len),
+ CONST char *path AND char *buf AND size_t len)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (readlink)
+
+weak_alias (__readlink, readlink)
diff --git a/sysdeps/stub/readv.c b/sysdeps/stub/readv.c
new file mode 100644
index 0000000..beebd95
--- /dev/null
+++ b/sysdeps/stub/readv.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/uio.h>
+
+/* Read data from file descriptor FD, and put the result in the
+ buffers described by VECTOR, which is a vector of COUNT `struct iovec's.
+ The buffers are filled in the order specified.
+ Operates just like `read' (see <unistd.h>) except that data are
+ put in VECTOR instead of a contiguous buffer. */
+int
+DEFUN(readv, (fd, vector, count),
+ int fd AND CONST struct iovec *vector AND size_t count)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/reboot.c b/sysdeps/stub/reboot.c
new file mode 100644
index 0000000..6801499
--- /dev/null
+++ b/sysdeps/stub/reboot.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Reboot the system. */
+int
+DEFUN(reboot, (howto), int howto)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(reboot);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/recv.c b/sysdeps/stub/recv.c
new file mode 100644
index 0000000..e7355af
--- /dev/null
+++ b/sysdeps/stub/recv.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Read N bytes into BUF from socket FD.
+ Returns the number read or -1 for errors. */
+int
+DEFUN(recv, (fd, buf, n, flags),
+ int fd AND PTR buf AND size_t n AND int flags)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(recv);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/recvfrom.c b/sysdeps/stub/recvfrom.c
new file mode 100644
index 0000000..6d33bb6
--- /dev/null
+++ b/sysdeps/stub/recvfrom.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Read N bytes into BUF through socket FD from peer
+ at address ADDR (which is ADDR_LEN bytes long).
+ Returns the number read or -1 for errors. */
+int
+DEFUN(recvfrom, (fd, buf, n, flags, addr, addr_len),
+ int fd AND PTR buf AND size_t n AND int flags AND
+ struct sockaddr *addr AND size_t *addr_len)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(recvfrom);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/recvmsg.c b/sysdeps/stub/recvmsg.c
new file mode 100644
index 0000000..eecff02
--- /dev/null
+++ b/sysdeps/stub/recvmsg.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Receive a message as described by MESSAGE from socket FD.
+ Returns the number of bytes read or -1 for errors. */
+int
+DEFUN(recvmsg, (fd, message, flags),
+ int fd AND struct msghdr *message AND int flags)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+stub_warning (recvmsg)
diff --git a/sysdeps/stub/remove.c b/sysdeps/stub/remove.c
new file mode 100644
index 0000000..c044e0a
--- /dev/null
+++ b/sysdeps/stub/remove.c
@@ -0,0 +1,31 @@
+/* ANSI C `remove' function to delete a file or directory. Stub version.
+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. */
+
+#include <errno.h>
+#include <stdio.h>
+
+int
+remove (file)
+ const char *file;
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+stub_warning (remove)
diff --git a/sysdeps/stub/rename.c b/sysdeps/stub/rename.c
new file mode 100644
index 0000000..c69df72
--- /dev/null
+++ b/sysdeps/stub/rename.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+#include <errno.h>
+
+
+/* Rename the file OLD to NEW. */
+int
+DEFUN(rename, (old, new), CONST char *old AND CONST char *new)
+{
+ if (old == NULL || new == NULL)
+ {
+ errno = EINVAL;
+ return(-1);
+ }
+
+ errno = ENOSYS;
+ return(-1);
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(rename);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/rewinddir.c b/sysdeps/stub/rewinddir.c
new file mode 100644
index 0000000..1eb5a0b
--- /dev/null
+++ b/sysdeps/stub/rewinddir.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <dirent.h>
+
+
+/* Rewind DIRP to the beginning of the directory. */
+void
+DEFUN(rewinddir, (dirp), DIR *dirp)
+{
+ errno = ENOSYS;
+ /* No way to indicate failure. */
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(rewinddir);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/rmdir.c b/sysdeps/stub/rmdir.c
new file mode 100644
index 0000000..828a261
--- /dev/null
+++ b/sysdeps/stub/rmdir.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+
+/* Remove the directory PATH. */
+int
+DEFUN(__rmdir, (path), CONST char *path)
+{
+ if (path == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (rmdir)
+
+weak_alias (__rmdir, rmdir)
diff --git a/sysdeps/stub/sbrk.c b/sysdeps/stub/sbrk.c
new file mode 100644
index 0000000..46d9ecd
--- /dev/null
+++ b/sysdeps/stub/sbrk.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+
+/* Extend the process's data space by INCREMENT.
+ If INCREMENT is negative, shrink data space by - INCREMENT.
+ Return the address of the start of data space, or -1 for errors. */
+PTR
+DEFUN(__sbrk, (increment), int increment)
+{
+ errno = ENOSYS;
+ return (PTR) -1;
+}
+stub_warning (sbrk)
+
+weak_alias (__sbrk, sbrk)
diff --git a/sysdeps/stub/seekdir.c b/sysdeps/stub/seekdir.c
new file mode 100644
index 0000000..61d270b
--- /dev/null
+++ b/sysdeps/stub/seekdir.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <stddef.h>
+#include <dirent.h>
+
+/* Seek to position POS in DIRP. */
+void
+DEFUN(seekdir, (dirp, pos), DIR *dirp AND off_t pos)
+{
+ if (dirp == NULL)
+ {
+ errno = EINVAL;
+ return;
+ }
+
+ errno = ENOSYS;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(seekdir);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/select.c b/sysdeps/stub/select.c
new file mode 100644
index 0000000..837f0ad
--- /dev/null
+++ b/sysdeps/stub/select.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <errno.h>
+
+/* Check the first NFDS descriptors each in READFDS (if not NULL) for read
+ readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS
+ (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out
+ after waiting the interval specified therein. Returns the number of ready
+ descriptors, or -1 for errors. */
+int
+DEFUN(__select, (nfds, readfds, writefds, exceptfds, timeout),
+ int nfds AND fd_set *readfds AND fd_set *writefds AND
+ fd_set *exceptfds AND struct timeval *timeout)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (select)
+
+weak_alias (__select, select)
diff --git a/sysdeps/stub/send.c b/sysdeps/stub/send.c
new file mode 100644
index 0000000..d1fbc69
--- /dev/null
+++ b/sysdeps/stub/send.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Send N bytes of BUF to socket FD. Returns the number sent or -1. */
+int
+DEFUN(send, (fd, buf, n, flags),
+ int fd AND PTR buf AND size_t n AND int flags)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(send);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/sendmsg.c b/sysdeps/stub/sendmsg.c
new file mode 100644
index 0000000..2066e52
--- /dev/null
+++ b/sysdeps/stub/sendmsg.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Send a message described MESSAGE on socket FD.
+ Returns the number of bytes sent, or -1 for errors. */
+int
+DEFUN(sendmsg, (fd, message, flags),
+ int fd AND CONST struct msghdr *message AND int flags)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+stub_warning (sendmsg)
diff --git a/sysdeps/stub/sendto.c b/sysdeps/stub/sendto.c
new file mode 100644
index 0000000..21d76ba
--- /dev/null
+++ b/sysdeps/stub/sendto.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Send N bytes of BUF on socket FD to peer at address ADDR (which is
+ ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */
+int
+DEFUN(sendto, (fd, buf, n, flags, addr, addr_len),
+ int fd AND PTR buf AND size_t n AND int flags AND
+ struct sockaddr *addr AND size_t addr_len)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(sendto);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/setdomain.c b/sysdeps/stub/setdomain.c
new file mode 100644
index 0000000..74da539
--- /dev/null
+++ b/sysdeps/stub/setdomain.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Set the name of the current YP domain to NAME, which is LEN bytes long.
+ This call is restricted to the super-user. */
+int
+DEFUN(setdomainname, (name, len),
+ char *name AND size_t len)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+stub_warning (setdomainname)
diff --git a/sysdeps/stub/setegid.c b/sysdeps/stub/setegid.c
new file mode 100644
index 0000000..58a3fe9
--- /dev/null
+++ b/sysdeps/stub/setegid.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Set the effective group ID of the calling process to GID. */
+int
+DEFUN(setegid, (gid), __gid_t gid)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(setegid);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/setenv.c b/sysdeps/stub/setenv.c
new file mode 100644
index 0000000..992a15d
--- /dev/null
+++ b/sysdeps/stub/setenv.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <stdlib.h>
+#include <errno.h>
+
+int
+DEFUN(setenv, (name, value, replace),
+ CONST char *name AND CONST char *value AND int replace)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/seteuid.c b/sysdeps/stub/seteuid.c
new file mode 100644
index 0000000..73180cc
--- /dev/null
+++ b/sysdeps/stub/seteuid.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Set the effective user ID of the calling process to UID. */
+int
+DEFUN(seteuid, (uid), __uid_t uid)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(seteuid);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/setgid.c b/sysdeps/stub/setgid.c
new file mode 100644
index 0000000..df1adbb
--- /dev/null
+++ b/sysdeps/stub/setgid.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Set the group ID of the calling process to GID.
+ If the calling process is the super-user, the real
+ and effective group IDs, and the saved set-group-ID to GID;
+ if not, the effective group ID is set to GID. */
+int
+DEFUN(__setgid, (gid), gid_t gid)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (setgid)
+
+weak_alias (__setgid, setgid)
diff --git a/sysdeps/stub/setgroups.c b/sysdeps/stub/setgroups.c
new file mode 100644
index 0000000..71d08d2
--- /dev/null
+++ b/sysdeps/stub/setgroups.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <grp.h>
+
+/* Set the group set for the current user to GROUPS (N of them). */
+int
+DEFUN(setgroups, (n, groups), size_t n AND CONST gid_t *groups)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(setgroups);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/sethostid.c b/sysdeps/stub/sethostid.c
new file mode 100644
index 0000000..500e100
--- /dev/null
+++ b/sysdeps/stub/sethostid.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Set the current machine's Internet number to ID.
+ This call is restricted to the super-user. */
+int
+DEFUN(sethostid, (id), long int id)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(sethostid);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/sethostname.c b/sysdeps/stub/sethostname.c
new file mode 100644
index 0000000..db44239
--- /dev/null
+++ b/sysdeps/stub/sethostname.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Set the name of the current host to NAME, which is LEN bytes long.
+ This call is restricted to the super-user. */
+int
+DEFUN(sethostname, (name, len),
+ CONST char *name AND size_t len)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(sethostname);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/setitimer.c b/sysdeps/stub/setitimer.c
new file mode 100644
index 0000000..6ba7031
--- /dev/null
+++ b/sysdeps/stub/setitimer.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1991, 1994, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <errno.h>
+#include <sys/time.h>
+
+/* Set the timer WHICH to *NEW. If OLD is not NULL,
+ set *OLD to the old value of timer WHICH.
+ Returns 0 on success, -1 on errors. */
+int
+DEFUN(__setitimer, (which, new, old),
+ enum __itimer_which which AND
+ struct itimerval *new AND struct itimerval *old)
+{
+ if (new == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (setitimer)
+
+weak_alias (__setitimer, setitimer)
diff --git a/sysdeps/stub/setjmp.c b/sysdeps/stub/setjmp.c
new file mode 100644
index 0000000..47a471d
--- /dev/null
+++ b/sysdeps/stub/setjmp.c
@@ -0,0 +1,42 @@
+/* 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. */
+
+#include <errno.h>
+#include <setjmp.h>
+
+
+/* Save the current program position in ENV and return 0. */
+int
+__sigsetjmp (jmp_buf env, int savemask)
+{
+ /* Save the signal mask if requested. */
+ __sigjmp_save (env, savemask);
+
+ errno = ENOSYS;
+ /* No way to signal failure. */
+ return 0;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(__sigsetjmp);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/setlogin.c b/sysdeps/stub/setlogin.c
new file mode 100644
index 0000000..393fd58
--- /dev/null
+++ b/sysdeps/stub/setlogin.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Set the login name returned by `getlogin'. */
+int
+DEFUN(setlogin, (name), CONST char *name)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/setpgid.c b/sysdeps/stub/setpgid.c
new file mode 100644
index 0000000..7e1d1a9
--- /dev/null
+++ b/sysdeps/stub/setpgid.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Set the process group ID of the process matching PID to PGID.
+ If PID is zero, the current process's process group ID is set.
+ If PGID is zero, the process ID of the process is used. */
+int
+DEFUN(__setpgid, (pid, pgid), int pid AND int pgid)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (setpgid)
+
+weak_alias (__setpgid, setpgid)
+weak_alias (__setpgid, setpgrp)
diff --git a/sysdeps/stub/setpriority.c b/sysdeps/stub/setpriority.c
new file mode 100644
index 0000000..b826927
--- /dev/null
+++ b/sysdeps/stub/setpriority.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/resource.h>
+
+/* Set the priority of all processes specified by WHICH and WHO
+ to PRIO. Returns 0 on success, -1 on errors. */
+int
+DEFUN(setpriority, (which, who, prio),
+ enum __priority_which which AND int who AND int prio)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(setpriority);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/setregid.c b/sysdeps/stub/setregid.c
new file mode 100644
index 0000000..017dd08
--- /dev/null
+++ b/sysdeps/stub/setregid.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Set the real group ID of the calling process to RGID,
+ and the effective group ID of the calling process to EGID. */
+int
+DEFUN(__setregid, (effective_gid, real_gid),
+ gid_t effective_gid AND gid_t real_gid)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (setregid)
+
+weak_alias (__setregid, setregid)
diff --git a/sysdeps/stub/setreuid.c b/sysdeps/stub/setreuid.c
new file mode 100644
index 0000000..7640d2f
--- /dev/null
+++ b/sysdeps/stub/setreuid.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Set the real user ID of the calling process to RUID,
+ and the effective user ID of the calling process to EUID. */
+int
+DEFUN(__setreuid, (effective_uid, real_uid),
+ uid_t effective_uid AND uid_t real_uid)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (setreuid)
+
+weak_alias (__setreuid, setreuid)
diff --git a/sysdeps/stub/setrlimit.c b/sysdeps/stub/setrlimit.c
new file mode 100644
index 0000000..4e8083f
--- /dev/null
+++ b/sysdeps/stub/setrlimit.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <sys/resource.h>
+#include <errno.h>
+
+/* Set the soft and hard limits for RESOURCE to *RLIMITS.
+ Only the super-user can increase hard limits.
+ Return 0 if successful, -1 if not (and sets errno). */
+int
+DEFUN(setrlimit, (resource, rlimits),
+ enum __rlimit_resource resource AND struct rlimit *rlimits)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(setrlimit);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/setsid.c b/sysdeps/stub/setsid.c
new file mode 100644
index 0000000..9baf1ee
--- /dev/null
+++ b/sysdeps/stub/setsid.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+
+/* Create a new session with the calling process as its leader.
+ The process group IDs of the session and the calling process
+ are set to the process ID of the calling process, which is returned. */
+int
+DEFUN_VOID(__setsid)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (setsid)
+
+weak_alias (__setsid, setsid)
diff --git a/sysdeps/stub/setsockopt.c b/sysdeps/stub/setsockopt.c
new file mode 100644
index 0000000..bd1500a
--- /dev/null
+++ b/sysdeps/stub/setsockopt.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Set socket FD's option OPTNAME at protocol level LEVEL
+ to *OPTVAL (which is OPTLEN bytes long).
+ Returns 0 on success, -1 for errors. */
+int
+DEFUN(setsockopt, (fd, level, optname, optval, optlen),
+ int fd AND int level AND int optname AND
+ PTR optval AND size_t optlen)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(setsockopt);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/settimeofday.c b/sysdeps/stub/settimeofday.c
new file mode 100644
index 0000000..7d654cd
--- /dev/null
+++ b/sysdeps/stub/settimeofday.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/time.h>
+
+/* Set the current time of day and timezone information.
+ This call is restricted to the super-user. */
+int
+DEFUN(__settimeofday, (tv, tz),
+ CONST struct timeval *tv AND CONST struct timezone *tz)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (settimeofday)
+
+weak_alias (__settimeofday, settimeofday)
diff --git a/sysdeps/stub/setuid.c b/sysdeps/stub/setuid.c
new file mode 100644
index 0000000..3415925
--- /dev/null
+++ b/sysdeps/stub/setuid.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Set the user ID of the calling process to UID.
+ If the calling process is the super-user, the real
+ and effective user IDs, and the saved set-user-ID to UID;
+ if not, the effective user ID is set to UID. */
+int
+DEFUN(__setuid, (uid), uid_t uid)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (setuid)
+
+weak_alias (__setuid, setuid)
diff --git a/sysdeps/stub/shutdown.c b/sysdeps/stub/shutdown.c
new file mode 100644
index 0000000..65d418f
--- /dev/null
+++ b/sysdeps/stub/shutdown.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Shut down all or part of the connection open on socket FD.
+ HOW determines what to shut down:
+ 0 = No more receptions;
+ 1 = No more transmissions;
+ 2 = No more receptions or transmissions.
+ Returns 0 on success, -1 for errors. */
+int
+DEFUN(shutdown, (fd, how),
+ int fd AND int how)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(shutdown);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/sigaction.c b/sysdeps/stub/sigaction.c
new file mode 100644
index 0000000..7321140
--- /dev/null
+++ b/sysdeps/stub/sigaction.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+
+/* If ACT is not NULL, change the action for SIG to *ACT.
+ If OACT is not NULL, put the old action for SIG in *OACT. */
+int
+DEFUN(__sigaction, (sig, act, oact),
+ int sig AND CONST struct sigaction *act AND struct sigaction *OACT)
+{
+ if (sig <= 0 || sig >= NSIG)
+ {
+ errno = EINVAL;
+ return(-1);
+ }
+
+ errno = ENOSYS;
+ return(-1);
+}
+stub_warning (sigaction)
+
+weak_alias (__sigaction, sigaction)
diff --git a/sysdeps/stub/sigaltstack.c b/sysdeps/stub/sigaltstack.c
new file mode 100644
index 0000000..ae5a7ae
--- /dev/null
+++ b/sysdeps/stub/sigaltstack.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+/* Run signals handlers on the stack specified by SS (if not NULL).
+ If OSS is not NULL, it is filled in with the old signal stack status. */
+int
+DEFUN(sigaltstack, (ss, oss),
+ CONST struct sigaltstack *ss AND struct sigaltstack *oss)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/sigblock.c b/sysdeps/stub/sigblock.c
new file mode 100644
index 0000000..7c7469e
--- /dev/null
+++ b/sysdeps/stub/sigblock.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+/* Block signals in MASK, returning the old mask. */
+int
+DEFUN(__sigblock, (mask), int mask)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (sigblock)
+
+weak_alias (__sigblock, sigblock)
diff --git a/sysdeps/stub/sigcontext.h b/sysdeps/stub/sigcontext.h
new file mode 100644
index 0000000..18d599f
--- /dev/null
+++ b/sysdeps/stub/sigcontext.h
@@ -0,0 +1,29 @@
+/* Structure describing state saved while handling a signal. Stub 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. */
+
+/* State of this thread when the signal was taken. */
+struct sigcontext
+ {
+ int sc_onstack;
+ __sigset_t sc_mask;
+
+ /* Registers and such. */
+ };
+
+/* Signal subcodes should be defined here. */
diff --git a/sysdeps/stub/sigintr.c b/sysdeps/stub/sigintr.c
new file mode 100644
index 0000000..5ec83e0
--- /dev/null
+++ b/sysdeps/stub/sigintr.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+/* If INTERRUPT is nonzero, make signal SIG interrupt system calls
+ (causing them to fail with EINTR); if INTERRUPT is zero, make system
+ calls be restarted after signal SIG. */
+int
+DEFUN(siginterrupt, (sig, interrupt),
+ int sig AND int interrupt)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/siglist.c b/sysdeps/stub/siglist.c
new file mode 100644
index 0000000..f32127c
--- /dev/null
+++ b/sysdeps/stub/siglist.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+
+CONST char *CONST _sys_siglist[] =
+ {
+ "Signal 0",
+ "Aborted",
+ "Erroneous arithmetic operation",
+ "Illegal instruction",
+ "Interrupt",
+ "Invalid access to storage",
+ "Terminated",
+ "Hangup",
+ "Quit",
+ "Broken pipe",
+ "Killed",
+ "Alarm clock",
+ "Stopped (signal)",
+ "Stopped",
+ "Continued",
+ "Child exited",
+ "Stopped (tty input)",
+ "Stopped (tty output)",
+ NULL
+ };
diff --git a/sysdeps/stub/signal.c b/sysdeps/stub/signal.c
new file mode 100644
index 0000000..88dc14a
--- /dev/null
+++ b/sysdeps/stub/signal.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+
+/* Set the handler for the signal SIG to HANDLER,
+ returning the old handler, or SIG_ERR on error. */
+__sighandler_t
+DEFUN(signal, (sig, handler), int sig AND __sighandler_t handler)
+{
+ errno = ENOSYS;
+ return SIG_ERR;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(signal);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/signum.h b/sysdeps/stub/signum.h
new file mode 100644
index 0000000..fbcc1fe
--- /dev/null
+++ b/sysdeps/stub/signum.h
@@ -0,0 +1,53 @@
+/* Copyright (C) 1991, 1993 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. */
+
+#ifdef _SIGNAL_H
+
+/* Fake signal functions. */
+extern void _sig_ign __P ((int sig));
+extern void _sig_dfl __P ((int sig));
+
+#define SIG_ERR ((__sighandler_t) 0) /* Error return. */
+#define SIG_DFL _sig_dfl /* Default action. */
+#define SIG_IGN _sig_ign /* Ignore signal. */
+
+
+/* ANSI signals. */
+#define SIGABRT 1 /* Abnormal termination. */
+#define SIGFPE 2 /* Erroneous arithmetic operation. */
+#define SIGILL 3 /* Illegal instruction. */
+#define SIGINT 3 /* Interactive attention signal. */
+#define SIGSEGV 4 /* Invalid access to storage. */
+#define SIGTERM 5 /* Termination request. */
+
+/* POSIX signals. */
+#define SIGHUP 6 /* Hangup. */
+#define SIGQUIT 7 /* Quit. */
+#define SIGPIPE 8 /* Broken pipe. */
+#define SIGKILL 9 /* Kill (cannot be blocked, caught, or ignored). */
+#define SIGALRM 10 /* Alarm clock. */
+#define SIGSTOP 11 /* Stop (cannot be blocked, caught, or ignored). */
+#define SIGTSTP 12 /* Keyboard stop. */
+#define SIGCONT 13 /* Continue. */
+#define SIGCHLD 14 /* Child terminated or stopped. */
+#define SIGTTIN 15 /* Background read from control terminal. */
+#define SIGTTOU 16 /* Background write to control terminal. */
+
+#endif /* <signal.h> included. */
+
+#define _NSIG 17
diff --git a/sysdeps/stub/sigpause.c b/sysdeps/stub/sigpause.c
new file mode 100644
index 0000000..a307422
--- /dev/null
+++ b/sysdeps/stub/sigpause.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+int
+DEFUN(__sigpause, (mask), int mask)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (sigpause)
+
+weak_alias (__sigpause, sigpause)
diff --git a/sysdeps/stub/sigpending.c b/sysdeps/stub/sigpending.c
new file mode 100644
index 0000000..def44ed
--- /dev/null
+++ b/sysdeps/stub/sigpending.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <signal.h>
+
+
+/* Store in SET all signals that are blocked and pending. */
+int
+DEFUN(sigpending, (set), sigset_t *set)
+{
+ if (set == NULL)
+ {
+ errno = EINVAL;
+ return(-1);
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+stub_warning (sigpending)
diff --git a/sysdeps/stub/sigprocmask.c b/sysdeps/stub/sigprocmask.c
new file mode 100644
index 0000000..a89f683
--- /dev/null
+++ b/sysdeps/stub/sigprocmask.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+
+/* If SET is not NULL, modify the current set of blocked signals
+ according to HOW, which may be SIG_BLOCK, SIG_UNBLOCK or SIG_SETMASK.
+ If OSET is not NULL, store the old set of blocked signals in *OSET. */
+int
+DEFUN(__sigprocmask, (how, set, oset),
+ int how AND CONST sigset_t *set AND sigset_t *oset)
+{
+ switch (how)
+ {
+ case SIG_BLOCK:
+ case SIG_UNBLOCK:
+ case SIG_SETMASK:
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+/* No stub warning because abort calls __sigprocmask,
+ and we don't want warnings for every use of abort on
+ a system without safe signals. */
+
+weak_alias (__sigprocmask, sigprocmask)
diff --git a/sysdeps/stub/sigreturn.c b/sysdeps/stub/sigreturn.c
new file mode 100644
index 0000000..d4370e4
--- /dev/null
+++ b/sysdeps/stub/sigreturn.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1992, 1994, 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. */
+
+#include <ansidecl.h>
+#include <signal.h>
+#include <errno.h>
+
+int
+DEFUN(__sigreturn, (context), struct sigcontext *context)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (sigreturn)
+
+weak_alias (__sigreturn, sigreturn)
diff --git a/sysdeps/stub/sigsetmask.c b/sysdeps/stub/sigsetmask.c
new file mode 100644
index 0000000..ab4ae81
--- /dev/null
+++ b/sysdeps/stub/sigsetmask.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+int
+DEFUN(__sigsetmask, (mask), int mask)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (sigsetmask)
+
+weak_alias (__sigsetmask, sigsetmask)
diff --git a/sysdeps/stub/sigstack.c b/sysdeps/stub/sigstack.c
new file mode 100644
index 0000000..001acfd
--- /dev/null
+++ b/sysdeps/stub/sigstack.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+/* Run signals handlers on the stack specified by SS (if not NULL).
+ If OSS is not NULL, it is filled in with the old signal stack status. */
+int
+DEFUN(sigstack, (ss, oss),
+ CONST struct sigstack *ss AND struct sigstack *oss)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/sigsuspend.c b/sysdeps/stub/sigsuspend.c
new file mode 100644
index 0000000..9c2067b
--- /dev/null
+++ b/sysdeps/stub/sigsuspend.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+
+
+/* Change the set of blocked signals to SET,
+ wait until a signal arrives, and restore the set of blocked signals. */
+int
+DEFUN(sigsuspend, (set), CONST sigset_t *set)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(sigsuspend);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/sigvec.c b/sysdeps/stub/sigvec.c
new file mode 100644
index 0000000..af8e24d
--- /dev/null
+++ b/sysdeps/stub/sigvec.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <signal.h>
+#include <errno.h>
+
+/* If VEC is non-NULL, set the handler for SIG to the `sv_handler' member
+ of VEC. The signals in `sv_mask' will be blocked while the handler runs.
+ If the SV_RESETHAND bit is set in `sv_flags', the handler for SIG will be
+ reset to SIG_DFL before `sv_handler' is entered. If OVEC is non-NULL,
+ it is filled in with the old information for SIG. */
+int
+DEFUN(__sigvec, (sig, vec, ovec),
+ int sig AND CONST struct sigvec *vec AND struct sigvec *ovec)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (sigvec)
+
+weak_alias (__sigvec, sigvec)
diff --git a/sysdeps/stub/sin.c b/sysdeps/stub/sin.c
new file mode 100644
index 0000000..9286811
--- /dev/null
+++ b/sysdeps/stub/sin.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the sine of X. */
+double
+DEFUN(sin, (x), double x)
+{
+ errno = ENOSYS;
+ return(0.0);
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(sin);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/sinh.c b/sysdeps/stub/sinh.c
new file mode 100644
index 0000000..80c1b88
--- /dev/null
+++ b/sysdeps/stub/sinh.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the hyperbolic sine of X. */
+double
+DEFUN(sinh, (x), double x)
+{
+ errno = ENOSYS;
+ return(0.0);
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(sinh);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/sleep.c b/sysdeps/stub/sleep.c
new file mode 100644
index 0000000..5cbeaaf
--- /dev/null
+++ b/sysdeps/stub/sleep.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <signal.h>
+#include <time.h>
+#include <unistd.h>
+#include <errno.h>
+
+/* Make the process sleep for SECONDS seconds, or until a signal arrives
+ and is not ignored. The function returns the number of seconds less
+ than SECONDS which it actually slept (zero if it slept the full time).
+ If a signal handler does a `longjmp' or modifies the handling of the
+ SIGALRM signal while inside `sleep' call, the handling of the SIGALRM
+ signal afterwards is undefined. There is no return value to indicate
+ error, but if `sleep' returns SECONDS, it probably didn't work. */
+unsigned int
+DEFUN(sleep, (seconds), unsigned int seconds)
+{
+ errno = ENOSYS;
+ return seconds;
+}
diff --git a/sysdeps/stub/socket.c b/sysdeps/stub/socket.c
new file mode 100644
index 0000000..a1e3d97
--- /dev/null
+++ b/sysdeps/stub/socket.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Create a new socket of type TYPE in domain DOMAIN, using
+ protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically.
+ Returns a file descriptor for the new socket, or -1 for errors. */
+int
+DEFUN(socket, (domain, type, protocol),
+ int domain AND enum __socket_type type AND int protocol)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(socket);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/socketpair.c b/sysdeps/stub/socketpair.c
new file mode 100644
index 0000000..f79cc28
--- /dev/null
+++ b/sysdeps/stub/socketpair.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/socket.h>
+
+/* Create two new sockets, of type TYPE in domain DOMAIN and using
+ protocol PROTOCOL, which are connected to each other, and put file
+ descriptors for them in FDS[0] and FDS[1]. If PROTOCOL is zero,
+ one will be chosen automatically. Returns 0 on success, -1 for errors. */
+int
+DEFUN(socketpair, (domain, type, protocol, fds),
+ int domain AND enum __socket_type type AND int protocol AND int fds[2])
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(socketpair);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/sqrt.c b/sysdeps/stub/sqrt.c
new file mode 100644
index 0000000..bdba5e5
--- /dev/null
+++ b/sysdeps/stub/sqrt.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the square root of X. */
+double
+DEFUN(sqrt, (x), double x)
+{
+ errno = ENOSYS;
+ return(0.0);
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(sqrt);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/sstk.c b/sysdeps/stub/sstk.c
new file mode 100644
index 0000000..0426d39
--- /dev/null
+++ b/sysdeps/stub/sstk.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+
+/* Increase the size of the stack by INCREMENT,
+ and return the address of the bottom of the stack. */
+PTR
+DEFUN(sstk, (increment), int increment)
+{
+ errno = ENOSYS;
+ return (PTR) -1;
+}
diff --git a/sysdeps/stub/start.c b/sysdeps/stub/start.c
new file mode 100644
index 0000000..b8bb04b
--- /dev/null
+++ b/sysdeps/stub/start.c
@@ -0,0 +1,16 @@
+/* This file should define the low-level program entry point,
+ which should set up `__environ', and then do:
+ __libc_init(argc, argv, __environ);
+ exit(main(argc, argv, __environ));
+
+ This file should be prepared to be the first thing in the text section (on
+ Unix systems), or otherwise appropriately special. */
+
+volatile int errno;
+
+#ifndef HAVE_GNU_LD
+#undef environ
+#define __environ environ
+#endif
+
+char **__environ;
diff --git a/sysdeps/stub/stat.c b/sysdeps/stub/stat.c
new file mode 100644
index 0000000..f24ce64
--- /dev/null
+++ b/sysdeps/stub/stat.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <stddef.h>
+
+/* Get file information about FILE in BUF. */
+int
+DEFUN(__stat, (file, buf), CONST char *file AND struct stat *buf)
+{
+ if (file == NULL || buf == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (stat)
+
+weak_alias (__stat, stat)
diff --git a/sysdeps/stub/statbuf.h b/sysdeps/stub/statbuf.h
new file mode 100644
index 0000000..e3fbce1
--- /dev/null
+++ b/sysdeps/stub/statbuf.h
@@ -0,0 +1,71 @@
+/* Copyright (C) 1992 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 structure needs to be defined in accordance with the
+ implementation of __stat, __fstat, and __lstat. */
+
+#ifndef _STATBUF_H
+
+#define _STATBUF_H 1
+
+#include <gnu/types.h>
+
+/* Structure describing file characteristics. */
+struct stat
+ {
+ /* These are the members that POSIX.1 requires. */
+
+ __mode_t st_mode; /* File mode. */
+ __ino_t st_ino; /* File serial number. */
+ __dev_t st_dev; /* Device containing the file. */
+ __nlink_t st_nlink; /* Link count. */
+
+ __uid_t st_uid; /* User ID of the file's owner. */
+ __gid_t st_gid; /* Group ID of the file's group. */
+ __off_t st_size; /* Size of file, in bytes. */
+
+ __time_t st_atime; /* Time of last access. */
+ __time_t st_mtime; /* Time of last modification. */
+ __time_t st_ctime; /* Time of last status change. */
+
+ /* This should be defined if there is a `st_blksize' member. */
+#undef _STATBUF_ST_BLKSIZE
+ };
+
+/* Encoding of the file mode. These are the standard Unix values,
+ but POSIX.1 does not specify what values should be used. */
+
+#define __S_IFMT 0170000 /* These bits determine file type. */
+
+/* File types. */
+#define __S_IFDIR 0040000 /* Directory. */
+#define __S_IFCHR 0020000 /* Character device. */
+#define __S_IFBLK 0060000 /* Block device. */
+#define __S_IFREG 0100000 /* Regular file. */
+#define __S_IFIFO 0010000 /* FIFO. */
+
+/* Protection bits. */
+
+#define __S_ISUID 04000 /* Set user ID on execution. */
+#define __S_ISGID 02000 /* Set group ID on execution. */
+#define __S_IREAD 0400 /* Read by owner. */
+#define __S_IWRITE 0200 /* Write by owner. */
+#define __S_IEXEC 0100 /* Execute by owner. */
+
+
+#endif /* statbuf.h */
diff --git a/sysdeps/stub/stdio_init.c b/sysdeps/stub/stdio_init.c
new file mode 100644
index 0000000..153b1a9
--- /dev/null
+++ b/sysdeps/stub/stdio_init.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <stdio.h>
+
+/* Initialize STREAM as necessary.
+ This may change I/O functions, give a buffer, etc.
+ If no buffer is allocated, but the bufsize is set,
+ the bufsize will be used to allocate the buffer. */
+void
+DEFUN(__stdio_init_stream, (stream), FILE *stream)
+{
+ stream->__bufsize = BUFSIZ;
+}
diff --git a/sysdeps/stub/stdio_lim.h b/sysdeps/stub/stdio_lim.h
new file mode 100644
index 0000000..1a9125b
--- /dev/null
+++ b/sysdeps/stub/stdio_lim.h
@@ -0,0 +1,6 @@
+#define L_tmpnam 1
+#define TMPMAX 0
+#define L_ctermid 1
+#define L_cuserid 1
+#define FOPEN_MAX 16
+#define FILENAME_MAX 14
diff --git a/sysdeps/stub/stime.c b/sysdeps/stub/stime.c
new file mode 100644
index 0000000..df6fdba
--- /dev/null
+++ b/sysdeps/stub/stime.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <time.h>
+#include <stddef.h>
+
+/* Set the system clock to *WHEN. */
+
+int
+DEFUN(stime, (when), CONST time_t *when)
+{
+ if (when == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/strtsupp.c b/sysdeps/stub/strtsupp.c
new file mode 100644
index 0000000..9c5d041
--- /dev/null
+++ b/sysdeps/stub/strtsupp.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+ Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
+ On-Line Applications Research Corporation.
+
+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. */
+
+#include <ansidecl.h>
+#include <standalone.h>
+
+/* This file is only required when a "bare" board is configured. */
+
+/* Start Support Routines
+
+The start code for some CPUs (e.g. i386) require target dependent
+support. For more info, consult the start file for your CPU. */
+
diff --git a/sysdeps/stub/stty.c b/sysdeps/stub/stty.c
new file mode 100644
index 0000000..24a865b
--- /dev/null
+++ b/sysdeps/stub/stty.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sgtty.h>
+#include <stddef.h>
+
+/* Set the terminal parameters associated with FD to *PARAMS. */
+int
+DEFUN(stty, (fd, params),
+ int fd AND CONST struct sgttyb *params)
+{
+ if (params == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/swapon.c b/sysdeps/stub/swapon.c
new file mode 100644
index 0000000..825f353
--- /dev/null
+++ b/sysdeps/stub/swapon.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Make the block special device PATH available to the system for swapping.
+ This call is restricted to the super-user. */
+int
+DEFUN(swapon, (path), CONST char *path)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+stub_warning (swapon)
diff --git a/sysdeps/stub/symlink.c b/sysdeps/stub/symlink.c
new file mode 100644
index 0000000..c8e6f12
--- /dev/null
+++ b/sysdeps/stub/symlink.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+
+/* Make a link to FROM called TO. */
+int
+DEFUN(__symlink, (from, to), CONST char *from AND CONST char *to)
+{
+ if (from == NULL || to == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (symlink)
+
+weak_alias (__symlink, symlink)
diff --git a/sysdeps/stub/sync.c b/sysdeps/stub/sync.c
new file mode 100644
index 0000000..6a8e5e6
--- /dev/null
+++ b/sysdeps/stub/sync.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Make all changes done to all files actually appear on disk. */
+int
+DEFUN_VOID(sync)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(sync);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/sys/param.h b/sysdeps/stub/sys/param.h
new file mode 100644
index 0000000..8a3e73b
--- /dev/null
+++ b/sysdeps/stub/sys/param.h
@@ -0,0 +1,8 @@
+/* This file should contain various parameter macros appropriate for the
+ machine and operating system. There is no standard set of macros; this
+ file is just for compatibility with programs written for Unix that
+ expect it to define things. On Unix systems that do not have their own
+ sysdep version of this file, it is generated at build time by examining
+ the installed headers on the system. */
+
+#include <limits.h>
diff --git a/sysdeps/stub/sys/reboot.h b/sysdeps/stub/sys/reboot.h
new file mode 100644
index 0000000..bada28d
--- /dev/null
+++ b/sysdeps/stub/sys/reboot.h
@@ -0,0 +1,9 @@
+/* This file should define RB_* macros to be used as flag
+ bits in the argument to the `reboot' system call. */
+
+#ifndef _SYS_REBOOT_H
+#define _SYS_REBOOT_H
+
+#define RB_AUTOBOOT 0
+
+#endif /* <sys/reboot.h> */
diff --git a/sysdeps/stub/syscall.c b/sysdeps/stub/syscall.c
new file mode 100644
index 0000000..e8deffd
--- /dev/null
+++ b/sysdeps/stub/syscall.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1993, 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. */
+
+#include <ansidecl.h>
+#include <sysdep.h>
+#include <errno.h>
+
+/* Do system call CALLNO, passing it the remaining arguments.
+ This only makes sense in certain operating systems. */
+
+int
+DEFUN(syscall, (callno), int callno DOTS)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/syscall.h b/sysdeps/stub/syscall.h
new file mode 100644
index 0000000..719bd08
--- /dev/null
+++ b/sysdeps/stub/syscall.h
@@ -0,0 +1,2 @@
+/* For Unix-like systems, this file should contain definitions
+ of macros SYS_call for each system call, giving the call numbers. */
diff --git a/sysdeps/stub/sysconf.c b/sysdeps/stub/sysconf.c
new file mode 100644
index 0000000..1d5d483
--- /dev/null
+++ b/sysdeps/stub/sysconf.c
@@ -0,0 +1,69 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <time.h>
+#include <limits.h>
+
+
+/* Get the value of the system variable NAME. */
+long int
+DEFUN(__sysconf, (name), int name)
+{
+ switch (name)
+ {
+ default:
+ errno = EINVAL;
+ return -1;
+
+ case _SC_TZNAME_MAX:
+ return __tzname_max ();
+
+ case _SC_ARG_MAX:
+ case _SC_CHILD_MAX:
+ case _SC_CLK_TCK:
+ case _SC_NGROUPS_MAX:
+ case _SC_OPEN_MAX:
+ case _SC_JOB_CONTROL:
+ case _SC_SAVED_IDS:
+ case _SC_VERSION:
+
+ case _SC_BC_BASE_MAX:
+ case _SC_BC_DIM_MAX:
+ case _SC_BC_SCALE_MAX:
+ case _SC_BC_STRING_MAX:
+ case _SC_EQUIV_CLASS_MAX:
+ case _SC_EXPR_NEST_MAX:
+ case _SC_LINE_MAX:
+ case _SC_RE_DUP_MAX:
+ case _SC_2_VERSION:
+ case _SC_2_C_BIND:
+ case _SC_2_C_DEV:
+ case _SC_2_FORT_DEV:
+ case _SC_2_SW_DEV:
+
+ break;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+weak_alias (__sysconf, sysconf)
diff --git a/sysdeps/stub/sysd-stdio.c b/sysdeps/stub/sysd-stdio.c
new file mode 100644
index 0000000..51d2ddb
--- /dev/null
+++ b/sysdeps/stub/sysd-stdio.c
@@ -0,0 +1,111 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stdio.h>
+
+
+/* Read up to N chars into BUF from COOKIE.
+ Return how many chars were read, 0 for EOF or -1 for error. */
+int
+DEFUN(__stdio_read, (cookie, buf, n),
+ PTR cookie AND register char *buf AND register size_t n)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+/* Write up to N chars from BUF to COOKIE.
+ Return how many chars were written or -1 for error. */
+int
+DEFUN(__stdio_write, (cookie, buf, n),
+ PTR cookie AND register CONST char *buf AND register size_t n)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+/* Move COOKIE's file position *POS bytes, according to WHENCE.
+ The new file position is stored in *POS.
+ Returns zero if successful, nonzero if not. */
+int
+DEFUN(__stdio_seek, (cookie, pos, whence),
+ PTR cookie AND fpos_t *pos AND int whence)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+/* Close the file associated with COOKIE.
+ Return 0 for success or -1 for failure. */
+int
+DEFUN(__stdio_close, (cookie), PTR cookie)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+/* Return the POSIX.1 file descriptor associated with COOKIE,
+ or -1 for errors. If COOKIE does not relate to any POSIX.1 file
+ descriptor, this should return -1 with errno set to EOPNOTSUPP. */
+int
+DEFUN(__stdio_fileno, (cookie), PTR cookie)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+/* Open FILENAME with the mode in M.
+ Store the magic cookie associated with the opened file in *COOKIEPTR.
+ Return zero on success and nonzero on failure. */
+int
+DEFUN(__stdio_open, (filename, m, cookieptr),
+ CONST char *filename AND __io_mode m AND PTR *cookieptr)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+/* Open FILENAME with the mode in M. Use the same magic cookie
+ already in *COOKIEPTR if possible, closing the old cookie with CLOSEFN. */
+int
+DEFUN(__stdio_reopen, (filename, m, cookieptr),
+ CONST char *filename AND __io_mode m AND
+ PTR *cookieptr AND __io_close_fn closefn)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(__stdio_read);
+stub_warning(__stdio_write);
+stub_warning(__stdio_seek);
+stub_warning(__stdio_close);
+stub_warning(__stdio_fileno);
+stub_warning(__stdio_open);
+stub_warning(__stdio_reopen);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/sysdep.c b/sysdeps/stub/sysdep.c
new file mode 100644
index 0000000..5442eee
--- /dev/null
+++ b/sysdeps/stub/sysdep.c
@@ -0,0 +1,2 @@
+/* This file should contain any system-dependent functions
+ that will be used by many parts of the library. */
diff --git a/sysdeps/stub/sysdep.h b/sysdeps/stub/sysdep.h
new file mode 100644
index 0000000..8c3184b
--- /dev/null
+++ b/sysdeps/stub/sysdep.h
@@ -0,0 +1,3 @@
+/* This file should contain any system-dependent types and macros
+ that will be used by many parts of the library. It should also
+ contain declarations for any functions defined in sysdep.c. */
diff --git a/sysdeps/stub/system.c b/sysdeps/stub/system.c
new file mode 100644
index 0000000..c2b35fb
--- /dev/null
+++ b/sysdeps/stub/system.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991, 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stdlib.h>
+
+
+/* Execute LINE as a shell command. */
+int
+DEFUN(system, (line), CONST char *line)
+{
+ if (line == NULL)
+ return 0; /* This indicates no command processor. */
+
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(system);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/tan.c b/sysdeps/stub/tan.c
new file mode 100644
index 0000000..de7b561
--- /dev/null
+++ b/sysdeps/stub/tan.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the tangent of X. */
+double
+DEFUN(tan, (x), double x)
+{
+ errno = ENOSYS;
+ return(0.0);
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(tan);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/tanh.c b/sysdeps/stub/tanh.c
new file mode 100644
index 0000000..3d748c0
--- /dev/null
+++ b/sysdeps/stub/tanh.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Return the hyperbolic tangent of X. */
+double
+DEFUN(tanh, (x), double x)
+{
+ errno = ENOSYS;
+ return(0.0);
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(tanh);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/tcdrain.c b/sysdeps/stub/tcdrain.c
new file mode 100644
index 0000000..9fc96b8
--- /dev/null
+++ b/sysdeps/stub/tcdrain.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <termios.h>
+
+/* Wait for pending output to be written on FD. */
+int
+DEFUN(tcdrain, (fd), int fd)
+{
+ if (fd < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(tcdrain);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/tcflow.c b/sysdeps/stub/tcflow.c
new file mode 100644
index 0000000..968b9a4
--- /dev/null
+++ b/sysdeps/stub/tcflow.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <termios.h>
+
+/* Suspend or restart transmission on FD. */
+int
+DEFUN(tcflow, (fd, action), int fd AND int action)
+{
+ if (fd < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ switch (action)
+ {
+ case TCOOFF:
+ case TCOON:
+ case TCIOFF:
+ case TCION:
+ break;
+
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(tcflow);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/tcflush.c b/sysdeps/stub/tcflush.c
new file mode 100644
index 0000000..3e9f7ef
--- /dev/null
+++ b/sysdeps/stub/tcflush.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <termios.h>
+
+/* Flush pending data on FD. */
+int
+DEFUN(tcflush, (fd, queue_selector), int fd AND int queue_selector)
+{
+ switch (queue_selector)
+ {
+ case TCIFLUSH:
+ case TCOFLUSH:
+ case TCIOFLUSH:
+ break;
+
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(tcflush);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/tcgetattr.c b/sysdeps/stub/tcgetattr.c
new file mode 100644
index 0000000..7020849
--- /dev/null
+++ b/sysdeps/stub/tcgetattr.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <termios.h>
+
+/* Put the state of FD into *TERMIOS_P. */
+int
+DEFUN(__tcgetattr, (fd, termios_p),
+ int fd AND struct termios *termios_p)
+{
+ if (fd < 0)
+ {
+ errno = EBADF;
+ return(-1);
+ }
+ if (termios_p == NULL)
+ {
+ errno = EINVAL;
+ return(-1);
+ }
+
+ errno = ENOSYS;
+ return(-1);
+}
+stub_warning (tcgetattr)
+
+weak_alias (__tcgetattr, tcgetattr)
diff --git a/sysdeps/stub/tcgetpgrp.c b/sysdeps/stub/tcgetpgrp.c
new file mode 100644
index 0000000..6a667d0
--- /dev/null
+++ b/sysdeps/stub/tcgetpgrp.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Return the foreground process group ID of FD. */
+pid_t
+DEFUN(tcgetpgrp, (fd), int fd)
+{
+ if (fd < 0)
+ {
+ errno = EBADF;
+ return (pid_t) -1;
+ }
+
+ errno = ENOSYS;
+ return (pid_t) -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(tcgetpgrp);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/tcsendbrk.c b/sysdeps/stub/tcsendbrk.c
new file mode 100644
index 0000000..4c90426
--- /dev/null
+++ b/sysdeps/stub/tcsendbrk.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <termios.h>
+
+/* Send zero bits on FD. */
+int
+DEFUN(tcsendbreak, (fd, duration), int fd AND int duration)
+{
+ if (fd < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(tcsendbreak);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/tcsetattr.c b/sysdeps/stub/tcsetattr.c
new file mode 100644
index 0000000..21de21e
--- /dev/null
+++ b/sysdeps/stub/tcsetattr.c
@@ -0,0 +1,100 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <termios.h>
+
+static int EXFUN(bad_speed, (speed_t speed));
+
+/* Set the state of FD to *TERMIOS_P. */
+int
+DEFUN(tcsetattr, (fd, optional_actions, termios_p),
+ int fd AND int optional_actions AND CONST struct termios *termios_p)
+{
+ if (fd < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+ if (termios_p == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ switch (optional_actions)
+ {
+ case TCSANOW:
+ case TCSADRAIN:
+ case TCSAFLUSH:
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (bad_speed(termios_p->__ospeed) ||
+ bad_speed(termios_p->__ispeed == 0 ?
+ termios_p->__ospeed : termios_p->__ispeed))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+
+/* Stricknine checking. */
+static int
+DEFUN(bad_speed, (speed), speed_t speed)
+{
+ switch (speed)
+ {
+ case B0:
+ case B50:
+ case B75:
+ case B110:
+ case B134:
+ case B150:
+ case B200:
+ case B300:
+ case B600:
+ case B1200:
+ case B1800:
+ case B2400:
+ case B4800:
+ case B9600:
+ case B19200:
+ case B38400:
+ return 0;
+ default:
+ return 1;
+ }
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(tcsetattr);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/tcsetpgrp.c b/sysdeps/stub/tcsetpgrp.c
new file mode 100644
index 0000000..06b8fed
--- /dev/null
+++ b/sysdeps/stub/tcsetpgrp.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Set the foreground process group ID of FD set PGRP_ID. */
+int
+DEFUN(tcsetpgrp, (fd, pgrp_id),
+ int fd AND pid_t pgrp_id)
+{
+ if (fd < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(tcsetpgrp);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/telldir.c b/sysdeps/stub/telldir.c
new file mode 100644
index 0000000..3d2a40e
--- /dev/null
+++ b/sysdeps/stub/telldir.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <stddef.h>
+#include <dirent.h>
+
+/* Return the current position of DIRP. */
+off_t
+DEFUN(telldir, (dirp), DIR *dirp)
+{
+ if (dirp == NULL)
+ {
+ errno = EINVAL;
+ return(-1);
+ }
+
+ errno = ENOSYS;
+ return((off_t) -1);
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(telldir);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/tempname.c b/sysdeps/stub/tempname.c
new file mode 100644
index 0000000..6292f8a
--- /dev/null
+++ b/sysdeps/stub/tempname.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991, 1992, 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stdio.h>
+
+/* Generate a (hopefully) unique temporary filename
+ in DIR (if applicable), using prefix PFX.
+ If DIR_SEARCH is nonzero, perform directory searching
+ malarky as per the SVID for tempnam.
+ Return the generated filename or NULL if one could not
+ be generated, putting the length of the string in *LENPTR. */
+char *
+DEFUN(__stdio_gen_tempname, (dir, pfx, dir_search, lenptr),
+ CONST char *dir AND CONST char *pfx AND
+ int dir_search AND size_t *lenptr AND
+ FILE **streamptr)
+{
+ *lenptr = 0;
+ errno = ENOSYS;
+ return NULL;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(__stdio_gen_tempname);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/thread_state.h b/sysdeps/stub/thread_state.h
new file mode 100644
index 0000000..f2ec4ca
--- /dev/null
+++ b/sysdeps/stub/thread_state.h
@@ -0,0 +1,47 @@
+/* Mach thread state definitions for machine-independent code. Stub 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. */
+
+/* Everything else is called `thread_state', but CMU's header file is
+ called `thread_status'. Oh boy. */
+#include <mach/thread_state.h>
+
+/* Replace <machine> with "i386" or "mips" or whatever. */
+
+#define MACHINE_THREAD_STATE_FLAVOR <machine>_THREAD_STATE
+#define MACHINE_THREAD_STATE_COUNT <machine>_THREAD_STATE_COUNT
+
+#define machine_thread_state <machine>_thread_state
+
+/* Define these to the member names in `struct <machine>_thread_state'
+ for the PC and stack pointer. */
+#define PC ?
+#define SP ?
+
+/* This structure should contain all of the different flavors of thread
+ state structures which are meaningful for this machine. Every machine's
+ definition of this structure should have a member `int set' which is a
+ bit mask (1 << FLAVOR) of the flavors of thread state in the structure
+ which are filled in; and a member `struct machine_thread_state basic'.
+ On some machines those are the only members (e.g. i386); on others,
+ there are several relevant flavors of thread state (e.g. mips). */
+struct machine_thread_all_state
+ {
+ int set; /* Mask of bits (1 << FLAVOR). */
+ struct <machine>_thread_state basic;
+ };
diff --git a/sysdeps/stub/time.c b/sysdeps/stub/time.c
new file mode 100644
index 0000000..bc1d3fc
--- /dev/null
+++ b/sysdeps/stub/time.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <time.h>
+
+
+/* Return the time now, and store it in *TIMER if not NULL. */
+time_t
+DEFUN(time, (timer), time_t *timer)
+{
+ errno = ENOSYS;
+
+ if (timer != NULL)
+ *timer = (time_t) -1;
+ return (time_t) -1;
+}
+
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(time);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/times.c b/sysdeps/stub/times.c
new file mode 100644
index 0000000..2b47ec2
--- /dev/null
+++ b/sysdeps/stub/times.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/times.h>
+#include <stddef.h>
+
+/* Store the CPU time used by this process and all its
+ dead children (and their dead children) in BUFFER.
+ Return the elapsed real time, or (clock_t) -1 for errors.
+ All times are in CLK_TCKths of a second. */
+clock_t
+DEFUN(__times, (buffer), struct tms *buffer)
+{
+ if (buffer == NULL)
+ {
+ errno = EINVAL;
+ return (clock_t) -1;
+ }
+
+ errno = ENOSYS;
+ return (clock_t) -1;
+}
+stub_warning (times)
+
+weak_alias (__times, times)
diff --git a/sysdeps/stub/trampoline.c b/sysdeps/stub/trampoline.c
new file mode 100644
index 0000000..8129d3b
--- /dev/null
+++ b/sysdeps/stub/trampoline.c
@@ -0,0 +1,37 @@
+/* Set thread_state for sighandler, and sigcontext to recover. Stub 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. */
+
+#include <hurd.h>
+#include <mach/thread_status.h>
+
+/* Set up STATE to run a signal handler in the thread it describes.
+ This should save the original state in a `struct sigcontext' on the
+ thread's stack (or possibly a signal stack described by SIGALTSTACK,
+ if the SA_ONSTACK bit is set in FLAGS), and return the address of
+ that structure. */
+
+struct sigcontext *
+_hurd_setup_sighandler (int flags,
+ __sighandler_t handler,
+ struct sigaltstack *sigaltstack,
+ int signo, int sigcode,
+ void *state)
+{
+#error "Need to write sysdeps/mach/hurd/MACHINE/trampoline.c"
+}
diff --git a/sysdeps/stub/truncate.c b/sysdeps/stub/truncate.c
new file mode 100644
index 0000000..32d32d8
--- /dev/null
+++ b/sysdeps/stub/truncate.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <errno.h>
+
+/* Truncate PATH to LENGTH bytes. */
+int
+DEFUN(truncate, (path, length),
+ CONST char *path AND off_t length)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/ttyname.c b/sysdeps/stub/ttyname.c
new file mode 100644
index 0000000..1a7c559
--- /dev/null
+++ b/sysdeps/stub/ttyname.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+
+char *__ttyname = NULL;
+
+/* Return the pathname of the terminal FD is open on, or NULL on errors.
+ The returned storage is good only until the next call to this function. */
+char *
+DEFUN(ttyname, (fd), int fd)
+{
+ errno = ENOSYS;
+ return NULL;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(ttyname);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/ualarm.c b/sysdeps/stub/ualarm.c
new file mode 100644
index 0000000..4a596d7
--- /dev/null
+++ b/sysdeps/stub/ualarm.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+
+/* Set an alarm to go off (generating a SIGALRM signal) in VALUE microseconds.
+ If INTERVAL is nonzero, when the alarm goes off, the timer is reset to go
+ off every INTERVAL microseconds thereafter.
+
+ Returns the number of microseconds remaining before the alarm. */
+unsigned int
+DEFUN(ualarm, (value, interval),
+ unsigned int value AND unsigned int interval)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/udiv_qrnnd.c b/sysdeps/stub/udiv_qrnnd.c
new file mode 100644
index 0000000..d32796c
--- /dev/null
+++ b/sysdeps/stub/udiv_qrnnd.c
@@ -0,0 +1,10 @@
+/* For some machines GNU MP needs to define an auxiliary function:
+
+ udiv_qrnnd (quotient, remainder, high_numerator, low_numerator, denominator)
+
+ Divides a two-word unsigned integer, composed by the integers
+ HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient
+ in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less
+ than DENOMINATOR for correct operation. If, in addition, the most
+ significant bit of DENOMINATOR must be 1, then the pre-processor symbol
+ UDIV_NEEDS_NORMALIZATION is defined to 1. */
diff --git a/sysdeps/stub/ulimit.c b/sysdeps/stub/ulimit.c
new file mode 100644
index 0000000..aa9e515
--- /dev/null
+++ b/sysdeps/stub/ulimit.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <sys/resource.h>
+#include <errno.h>
+
+/* Function depends on CMD:
+ 1 = Return the limit on the size of a file, in units of 512 bytes.
+ 2 = Set the limit on the size of a file to NEWLIMIT. Only the
+ super-user can increase the limit.
+ 3 = Return the maximum possible address of the data segment.
+ 4 = Return the maximum number of files that the calling process
+ can open.
+ Returns -1 on errors. */
+long int
+DEFUN(__ulimit, (cmd, newlimit), int cmd AND long int newlimit)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(__ulimit);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/umask.c b/sysdeps/stub/umask.c
new file mode 100644
index 0000000..18c85b7
--- /dev/null
+++ b/sysdeps/stub/umask.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <sys/types.h>
+
+/* Set the file creation mask to MASK, returning the old mask. */
+mode_t
+DEFUN(__umask, (mask), mode_t mask)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (umask)
+
+weak_alias (__umask, umask)
diff --git a/sysdeps/stub/unlink.c b/sysdeps/stub/unlink.c
new file mode 100644
index 0000000..7f8e249
--- /dev/null
+++ b/sysdeps/stub/unlink.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+
+/* Remove the link named NAME. */
+int
+DEFUN(__unlink, (name), CONST char *name)
+{
+ if (name == NULL)
+ {
+ errno = EINVAL;
+ return(-1);
+ }
+
+ errno = ENOSYS;
+ return(-1);
+}
+stub_warning (unlink)
+
+weak_alias (__unlink, unlink)
diff --git a/sysdeps/stub/usleep.c b/sysdeps/stub/usleep.c
new file mode 100644
index 0000000..f0c65d0
--- /dev/null
+++ b/sysdeps/stub/usleep.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+
+/* Sleep USECONDS microseconds, or until a previously set timer goes off. */
+unsigned int
+DEFUN(usleep, (useconds), unsigned int useconds)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/stub/utime.c b/sysdeps/stub/utime.c
new file mode 100644
index 0000000..eee736f
--- /dev/null
+++ b/sysdeps/stub/utime.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <utime.h>
+
+
+/* Set the access and modification times of FILE to those given in TIMES.
+ If TIMES is NULL, set them to the current time. */
+int
+DEFUN(utime, (file, times), CONST char *file AND CONST struct utimbuf *times)
+{
+ if (file == NULL)
+ {
+ errno = EINVAL;
+ return(-1);
+ }
+
+ errno = ENOSYS;
+ return(-1);
+}
+
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(utime);
+
+#endif /* GNU stabs. */
diff --git a/sysdeps/stub/utimes.c b/sysdeps/stub/utimes.c
new file mode 100644
index 0000000..5172b07
--- /dev/null
+++ b/sysdeps/stub/utimes.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <sys/time.h>
+#include <errno.h>
+#include <stddef.h>
+
+/* Change the access time of FILE to TVP[0] and
+ the modification time of FILE to TVP[1]. */
+int
+DEFUN(__utimes, (file, tvp),
+ CONST char *file AND struct timeval tvp[2])
+{
+ if (file == NULL || tvp == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+
+weak_alias (__utimes, utimes)
diff --git a/sysdeps/stub/vhangup.c b/sysdeps/stub/vhangup.c
new file mode 100644
index 0000000..6a7a994
--- /dev/null
+++ b/sysdeps/stub/vhangup.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Revoke access permissions to all processes currently communicating
+ with the control terminal, and then send a SIGHUP signal to the process
+ group of the control terminal. */
+int
+DEFUN_VOID(vhangup)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+stub_warning (vhangup)
diff --git a/sysdeps/stub/wait.c b/sysdeps/stub/wait.c
new file mode 100644
index 0000000..97b7841
--- /dev/null
+++ b/sysdeps/stub/wait.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <sys/wait.h>
+#include <errno.h>
+
+/* Wait for a child to die. When one does, put its status in *STAT_LOC
+ and return its process ID. For errors, return (pid_t) -1. */
+__pid_t
+DEFUN(__wait, (stat_loc), __WAIT_STATUS_DEFN stat_loc)
+{
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (wait)
+
+weak_alias (__wait, wait)
diff --git a/sysdeps/stub/wait3.c b/sysdeps/stub/wait3.c
new file mode 100644
index 0000000..c1640dd
--- /dev/null
+++ b/sysdeps/stub/wait3.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+
+/* Wait for a child to exit. When one does, put its status in *STAT_LOC and
+ return its process ID. For errors return (pid_t) -1. If USAGE is not nil,
+ store information about the child's resource usage (as a `struct rusage')
+ there. If the WUNTRACED bit is set in OPTIONS, return status for stopped
+ children; otherwise don't. */
+pid_t
+DEFUN(__wait3, (stat_loc, options, usage),
+ __WAIT_STATUS_DEFN stat_loc AND int options AND struct rusage *usage)
+{
+ if ((options & ~(WNOHANG|WUNTRACED)) != 0)
+ {
+ errno = EINVAL;
+ return (pid_t) -1;
+ }
+
+ errno = ENOSYS;
+ return (pid_t) -1;
+}
+stub_warning (wait3)
+
+weak_alias (__wait3, wait3)
diff --git a/sysdeps/stub/wait4.c b/sysdeps/stub/wait4.c
new file mode 100644
index 0000000..2062d4b
--- /dev/null
+++ b/sysdeps/stub/wait4.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <errno.h>
+
+pid_t
+DEFUN(__wait4, (pid, stat_loc, options, usage),
+ pid_t pid AND __WAIT_STATUS_DEFN stat_loc AND int options AND
+ struct rusage *usage)
+{
+ errno = ENOSYS;
+ return (pid_t) -1;
+}
+stub_warning (wait4)
+
+weak_alias (__wait4, wait4)
diff --git a/sysdeps/stub/waitflags.h b/sysdeps/stub/waitflags.h
new file mode 100644
index 0000000..52e4f80
--- /dev/null
+++ b/sysdeps/stub/waitflags.h
@@ -0,0 +1,28 @@
+/* Definitions of flag bits for `waitpid' et al.
+Copyright (C) 1992 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 _WAITFLAGS_H
+
+#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/waitpid.c b/sysdeps/stub/waitpid.c
new file mode 100644
index 0000000..22eb019
--- /dev/null
+++ b/sysdeps/stub/waitpid.c
@@ -0,0 +1,52 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+
+
+/* Wait for a child matching PID to die.
+ If PID is greater than 0, match any process whose process ID is PID.
+ If PID is (pid_t) -1, match any process.
+ If PID is (pid_t) 0, match any process with the
+ same process group as the current process.
+ If PID is less than -1, match any process whose
+ process group is the absolute value of PID.
+ If the WNOHANG bit is set in OPTIONS, and that child
+ is not already dead, return (pid_t) 0. If successful,
+ return PID and store the dead child's status in STAT_LOC.
+ Return (pid_t) -1 for errors. If the WUNTRACED bit is set in OPTIONS,
+ return status for stopped children; otherwise don't. */
+pid_t
+DEFUN(__waitpid, (pid, stat_loc, options),
+ pid_t pid AND int *stat_loc AND int options)
+{
+ if ((options & ~(WNOHANG|WUNTRACED)) != 0)
+ {
+ errno = EINVAL;
+ return (pid_t) -1;
+ }
+
+ errno = ENOSYS;
+ return (pid_t) -1;
+}
+stub_warning (waitpid)
+
+weak_alias (__waitpid, waitpid)
diff --git a/sysdeps/stub/write.c b/sysdeps/stub/write.c
new file mode 100644
index 0000000..deb4851
--- /dev/null
+++ b/sysdeps/stub/write.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <sysdep.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stddef.h>
+
+/* Write NBYTES of BUF to FD. Return the number written, or -1. */
+ssize_t
+DEFUN(__write, (fd, buf, nbytes),
+ int fd AND CONST PTR buf AND size_t nbytes)
+{
+ if (nbytes == 0)
+ return 0;
+ if (fd < 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+ if (buf == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ errno = ENOSYS;
+ return -1;
+}
+stub_warning (write)
+
+weak_alias (__write, write)
diff --git a/sysdeps/stub/writev.c b/sysdeps/stub/writev.c
new file mode 100644
index 0000000..de354e8
--- /dev/null
+++ b/sysdeps/stub/writev.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/uio.h>
+
+/* Write data pointed by the buffers described by VECTOR, which
+ is a vector of COUNT `struct iovec's, to file descriptor FD.
+ The data is written in the order specified.
+ Operates just like `write' (see <unistd.h>) except that the data
+ are taken from VECTOR instead of a contiguous buffer. */
+int
+DEFUN(writev, (fd, vector, count),
+ int fd AND CONST struct iovec *vector AND size_t count)
+{
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/sysdeps/tahoe/Implies b/sysdeps/tahoe/Implies
new file mode 100644
index 0000000..5a31637
--- /dev/null
+++ b/sysdeps/tahoe/Implies
@@ -0,0 +1,2 @@
+# A Tahoe is mostly just like a Vax.
+vax
diff --git a/sysdeps/tahoe/log10.c b/sysdeps/tahoe/log10.c
new file mode 100644
index 0000000..2cf2cee
--- /dev/null
+++ b/sysdeps/tahoe/log10.c
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991 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. */
+
+#define FPCONST(hi0, lo0, hi1, lo1) { (hi0), (lo0), (hi1), (lo1) }
+
+#include <../sysdeps/vax/log10.c>
+
diff --git a/sysdeps/unix/Dist b/sysdeps/unix/Dist
new file mode 100644
index 0000000..1816f6b
--- /dev/null
+++ b/sysdeps/unix/Dist
@@ -0,0 +1,4 @@
+errnos-tmpl.c errnos.awk
+ioctls-tmpl.c ioctls.awk snarf-ioctls
+make_errlist.c
+mk-local_lim.c
diff --git a/sysdeps/unix/Implies b/sysdeps/unix/Implies
new file mode 100644
index 0000000..b3188f7
--- /dev/null
+++ b/sysdeps/unix/Implies
@@ -0,0 +1 @@
+posix
diff --git a/sysdeps/unix/Makefile b/sysdeps/unix/Makefile
new file mode 100644
index 0000000..6bc0f5a
--- /dev/null
+++ b/sysdeps/unix/Makefile
@@ -0,0 +1,267 @@
+# Copyright (C) 1991, 1992, 1993, 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.
+
+# The unix-specific configure fragment writes `unix-generated' in config.make.
+config-generated := $(config-generated) $(unix-generated)
+
+ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
+ $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/local_lim.h))))))
+
+ifneq (,$(wildcard $(sysincludedir)/sys/param.h))
+local_lim-CFLAGS := $(local_lim-CFLAGS) -DHAVE_SYS_PARAM_H
+endif
+ifneq (,$(wildcard $(sysincludedir)/sys/limits.h))
+local_lim-CFLAGS := $(local_lim-CFLAGS) -DHAVE_SYS_LIMITS_H
+endif
+ifneq (,$(wildcard $(sysincludedir)/limits.h))
+local_lim-CFLAGS := $(local_lim-CFLAGS) -DHAVE_LIMITS_H
+endif
+
+$(common-objpfx)local_lim.h: $(common-objpfx)mk-local_lim
+ if $(dir $<)$(notdir $<) > $@-t; then mv $@-t $@; else XXX; fi
+$(common-objpfx)mk-local_lim: $(sysdep_dir)/unix/mk-local_lim.c
+ cwd=`pwd`; cd $(@D); \
+ $(BUILD_CC) $(BUILD_CFLAGS) $(local_lim-CFLAGS) $$cwd/$< -o $(@F)
+
+before-compile := $(before-compile) $(common-objpfx)local_lim.h
+common-generated := $(common-generated) local_lim.h mk-local_lim
+
+endif
+
+ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
+ $(patsubst %/sys/param.h,%/,\
+ $(firstword $(wildcard $(+sysdep_dirs:%=%/sys/param.h))))))
+
+before-compile := $(before-compile) $(common-objpfx)sys/param.h
+
+$(common-objpfx)sys/param.h: $(sysincludedir)/sys/param.h
+ -mkdir $(@D:%/=%)
+ (echo '#ifndef _GNU_SYS_PARAM_H'; \
+ echo '#define _GNU_SYS_PARAM_H 1'; \
+ echo '#include <endian.h>'; \
+ awk < $< \
+ '/^#define[ ]*NULL/ { print "#ifndef NULL"; \
+ print $$0; \
+ print "#endif"; \
+ was_null = 1 } \
+ { if (!was_null) print $$0; \
+ was_null = 0 }'; \
+ echo '#ifndef MAXHOSTNAMELEN'; \
+ echo '#define MAXHOSTNAMELEN 64 /* XXX */'; \
+ echo '#endif /* No MAXHOSTNAMELEN. */'; \
+ echo '#endif /* sys/param.h */') > $@-tmp
+ mv $@-tmp $@
+
+$(common-objpfx)param.h.c: $(sysincludedir)/sys/param.h
+ rm -f $@
+ cp $< $@
+$(common-objpfx)param.h.dep: $(common-objpfx)param.h.c \
+ $(sysdep_dir)/unix/Makefile
+ $(+mkdep) -I$(sysincludedir) $< \
+ | sed > $@ \
+ -e 's@^.*:@@' \
+ -e 's@$<@@g' \
+ -e 's@$(sysincludedir)/*@@g' \
+ -e 's@\\$$@@' \
+ -e 's@^@sys/param.h-includes := $$(sys/param.h-includes) @'
+
+# Get the generated definition of sys/param.h-includes.
+ifndef no_deps
+include $(common-objpfx)param.h.dep
+endif
+
+# Don't preempt our own headers.
+sys/param.h-includes := \
+ $(filter-out $(patsubst $(..)%,%,\
+ $(wildcard $(addprefix $(..),\
+ $(sys/param.h-includes)))),\
+ $(sys/param.h-includes))
+
+
+.PHONY: sys/param.h-includes
+sys/param.h-includes: $(addprefix $(common-objpfx),$(sys/param.h-includes))
+
+ifdef sys/param.h-includes
+# Copy the system files to $(common-objdir).
+$(addprefix $(common-objpfx),$(sys/param.h-includes)): $(common-objpfx)%: \
+ $(sysincludedir)/%
+ -mkdir $(@D:%/=%)
+# Some of these files sometimes contain conflicting declarations for htons,
+# ntohs, etc. They also often contain definitions of *_ENDIAN and
+# BYTE_ORDER, which we define ourselves in <endian.h>.
+ sed -e '/[ ]*[hn]to[nh][sl][ (]*/d' \
+ -e '/^#define[ ]*[A-Z]*_ENDIAN/d' \
+ -e '/^#define[ ]*BYTE_ORDER/d' \
+ $< > $@-t
+ mv $@-t $@
+endif
+
+common-generated := $(common-generated) \
+ sys/param.h $(sys/param.h-includes) param.h.c param.h.dep
+
+
+ifeq ($(subdir),misc)
+
+# Install system headers the system sys/param.h uses.
+
+sysdep_headers := $(sysdep_headers) $(sys/param.h-includes)
+
+endif # misc
+
+endif # No sysdep sys/param.h.
+
+ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
+ $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/errnos.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
+
+$(common-objpfx)errnos.h: $(common-objpfx)make-errnos
+ $(dir $<)$(notdir $<) > $@-tmp
+ mv $@-tmp $@
+
+$(common-objpfx)make-errnos: $(common-objpfx)make-errnos.c
+ $(common-objdir-compile)
+
+$(common-objpfx)make-errnos.c: $(sysdep_dir)/unix/errnos-tmpl.c \
+ $(sysdep_dir)/unix/errnos.awk $(common-objpfx)errnos
+ awk -f $(word 2,$^) errnos="`tr '\012' ' ' < $(word 3,$^)`" $< > $@T
+ mv $@T $@
+
+$(common-objpfx)errnos: $(wildcard $(sysincludedir)/errno.h \
+ $(sysincludedir)/sys/errno.h)
+ cat $^ | sed -n 's/^#define[ ]*\(E[A-Z0-9][A-Z0-9]*\)[ ].*$$/\1/p' > $@-tmp
+ mv $@-tmp $@
+
+common-generated := $(common-generated) \
+ errnos.h errnos make-errnos make-errnos.c
+endif
+
+ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
+ $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/ioctls.h))))))
+
+before-compile := $(before-compile) $(common-objpfx)ioctls.h
+
+$(common-objpfx)ioctls.h: $(common-objpfx)make-ioctls
+ $(dir $<)$(notdir $<) > $@-tmp
+ mv $@-tmp $@
+
+ioctl-includes := sys/termios.h net/nit.h
+ioctl-includes := $(wildcard $(addprefix $(sysincludedir)/,$(ioctl-includes)))
+make-ioctls-CFLAGS := $(subst /,_,$(subst .,_,\
+ $(patsubst $(sysincludedir)/%,-DHAVE_%,\
+ $(ioctl-includes))))
+
+$(common-objpfx)make-ioctls: $(common-objpfx)make-ioctls.c
+ cd $(@D); $(BUILD_CC) $(BUILD_CFLAGS) $(make-ioctls-CFLAGS) \
+ $(<:$(common-objpfx)%=%) -o $(@F)
+
+$(common-objpfx)make-ioctls.c: $(sysdep_dir)/unix/ioctls-tmpl.c \
+ $(sysdep_dir)/unix/ioctls.awk \
+ $(common-objpfx)ioctls
+ awk -f $(word 2,$^) requests="`cat $(word 3,$^)`" $< > $@T
+ mv $@T $@
+
+
+termbits.h := $(firstword $(wildcard $(+sysdep_dirs:%=%/termbits.h)))
+ifeq ($(termbits.h),$(sysdep_dir)/generic/termbits.h)
+termbits.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
+# <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.
+
+$(common-objpfx)ioctls: $(sysdep_dir)/unix/snarf-ioctls \
+ $(sysincludedir)/sys/ioctl.h $(ioctl-includes)
+ $(dir $<)$(notdir $<) $(filter-out $<,$^) \
+ | fgrep -xv "`$(dir $<)$(notdir $<) $(termbits.h) \
+ $(..)termios/sys/ttydefaults.h \
+ | sort | uniq`" \
+ | sort | uniq | tr '\012' ' ' > $@-tmp
+ mv $@-tmp $@
+
+common-generated := $(common-generated) \
+ ioctls.h ioctls make-ioctls make-ioctls.c
+endif
+
+ifeq ($(subdir),stdio)
+ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
+ $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/errlist.c))))))
+
+before-compile: $(objpfx)errlist.c
+$(objpfx)errlist.c: $(objpfx)make_errlist
+ @rm -f $@
+ $(dir $<)$(notdir $<) > $@-tmp
+ mv $@-tmp $@
+
+$(objpfx)make_errlist: $(sysdep_dir)/unix/make_errlist.c
+ $(native-compile)
+
+generated := $(generated) make_errlist errlist.c
+
+endif
+endif # stdio
+
+ifeq (,$(filter-out $(sysdep_dir)/stub/ $(common-objpfx),\
+ $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/syscall.h))))))
+
+# The syscall code assumes a file <syscall.h> that defines macros
+# `SYS_call' for syscall `call'. Variations on this I have seen include:
+# it's in <sys/syscall.h>;
+# it's in <sys.s>;
+# it defines `CALL' instead of `SYS_call'.
+# Irix has a <syscall.h> which is not what we want, so check for <sys.s> first.
+
+# Find a file that might have these. NOTE: This list of possibilities is
+# repeated in sysdeps/unix/configure and the two should be kept in sync.
+syscall.h := $(firstword $(wildcard $(addprefix $(sysincludedir)/, \
+ sys.s sys/sys.s \
+ sys.S sys/sys.S \
+ syscall.h sys/syscall.h \
+ )))
+ifdef syscall.h
+
+# Transmogrify any of several formats of the file into the one we want.
+$(common-objpfx)syscall.h: $(syscall.h)
+ tr '[A-Z]' '[a-z]' < $< | \
+ sed -e 's/[ ]sys_/ /' \
+ -e 's/^#define[ ]*\([a-z0-9_]*\)[ ]*/#define SYS_\1 /' \
+ -e 's/[ ]sys_/ SYS_/' \
+ -e 's/SYS_syscall_basenum/syscall_basenum/g' \
+ -e 's/SYS_kerncall_basenum/kerncall_basenum/g' \
+ -e 's/SYS_sysvoffset/sysvoffset/g' \
+ -e '/^#/!d' \
+ -e '/^#ident/d' \
+ -e 's-\(/\*[^*]*\)$$-\1\*/-' \
+ > $@-tmp
+ mv $@-tmp $@
+
+before-compile := $(before-compile) $(common-objpfx)syscall.h
+common-generated := $(common-generated) syscall.h
+
+endif
+
+endif
diff --git a/sysdeps/unix/_exit.S b/sysdeps/unix/_exit.S
new file mode 100644
index 0000000..a171689
--- /dev/null
+++ b/sysdeps/unix/_exit.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+PSEUDO (_exit, exit, 1)
+ /* Shouldn't get here. */
diff --git a/sysdeps/unix/acct.S b/sysdeps/unix/acct.S
new file mode 100644
index 0000000..f9363d2
--- /dev/null
+++ b/sysdeps/unix/acct.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (acct, 1)
+ ret
diff --git a/sysdeps/unix/bsd/Attic/osf1/=dirstream.h b/sysdeps/unix/bsd/Attic/osf1/=dirstream.h
new file mode 100644
index 0000000..c37610e
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/=dirstream.h
@@ -0,0 +1,44 @@
+/* Copyright (C) 1993 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. */
+
+#ifndef _DIRSTREAM_H
+
+#define _DIRSTREAM_H 1
+
+#define __need_size_t
+#include <stddef.h>
+
+/* Directory stream type. */
+
+typedef struct
+ {
+ int __fd; /* File descriptor. */
+
+ size_t __offset; /* Current offset into the block. */
+ size_t __size; /* Total valid data in the block. */
+ char *__data; /* Directory block. */
+
+ int __allocation; /* Space allocated for the block. */
+
+ int __data_len; /* Size of __data. */
+ long __dd_seek; /* OSF/1 magic cookie returned by getdents. */
+ void *dd_lock; /* Used by OSF/1 for inter-thread locking. */
+
+ } DIR;
+
+#endif /* dirstream.h */
diff --git a/sysdeps/unix/bsd/Attic/osf1/Implies b/sysdeps/unix/bsd/Attic/osf1/Implies
new file mode 100644
index 0000000..82719f5
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/Implies
@@ -0,0 +1,2 @@
+# OSF/1 has the canonical set of <sys/mman.h> system calls.
+unix/mman
diff --git a/sysdeps/unix/bsd/Attic/osf1/Makefile b/sysdeps/unix/bsd/Attic/osf1/Makefile
new file mode 100644
index 0000000..743788a
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/Makefile
@@ -0,0 +1,3 @@
+# Without -non_shared (via the compiler's -static flag), we'll end up
+# with some unresolved symbols wrt exceptions.
+LDFLAGS := $(LDFLAGS) -static
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/brk.S b/sysdeps/unix/bsd/Attic/osf1/alpha/brk.S
new file mode 100644
index 0000000..111f339
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/brk.S
@@ -0,0 +1,53 @@
+/* Copyright (C) 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. */
+
+#include <sysdep.h>
+
+#ifndef SYS_brk
+#define SYS_brk 17
+#endif
+
+#ifndef HAVE_GNU_LD
+#define __end end
+#endif
+
+.data
+ .extern __end,8
+ .globl __curbrk
+__curbrk:
+ .quad __end
+
+.text
+ENTRY(__brk)
+ ! FIXME We do not check for asking for less than a page yet.
+ ldiq v0, SYS_brk
+ call_pal PAL_callsys
+ bne a3, error
+
+ /* Update __curbrk and exit cleanly. */
+! ldgp gp, 0(t12)
+ stl a0, __curbrk
+
+ mov zero, v0
+ ret
+ /* What a horrible way to die. */
+error: ldgp gp,0(gp)
+ jmp zero,syscall_error
+ .end __brk
+
+weak_alias (__brk, brk)
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/fork.S b/sysdeps/unix/bsd/Attic/osf1/alpha/fork.S
new file mode 100644
index 0000000..7c8d671
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/fork.S
@@ -0,0 +1,25 @@
+/* Copyright (C) 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (fork, 0)
+ cmovne a4, 0, v0
+ ret
+
+weak_alias (__fork, fork)
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/getdents.S b/sysdeps/unix/bsd/Attic/osf1/alpha/getdents.S
new file mode 100644
index 0000000..16ccbc2
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/getdents.S
@@ -0,0 +1,25 @@
+/* Copyright (C) 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (getdirentries, 4)
+ ret
+
+weak_alias (__getdirentries, getdirentries)
+
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/killpg.S b/sysdeps/unix/bsd/Attic/osf1/alpha/killpg.S
new file mode 100644
index 0000000..f0b82b3
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/killpg.S
@@ -0,0 +1,25 @@
+/* Copyright (C) 1993 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. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_killpg SYS_ult_killpg
+
+SYSCALL (killpg, 2)
+ ret
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/pipe.S b/sysdeps/unix/bsd/Attic/osf1/alpha/pipe.S
new file mode 100644
index 0000000..6b074ed
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/pipe.S
@@ -0,0 +1,30 @@
+/* Copyright (C) 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (pipe, 1)
+ /* Plop in the two descriptors. */
+ stl r0, 0(a0)
+ stl r1, 4(a0)
+
+ /* Go out with a clean status. */
+ mov zero, r0
+ ret
+
+weak_alias (__pipe, pipe)
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/recv.S b/sysdeps/unix/bsd/Attic/osf1/alpha/recv.S
new file mode 100644
index 0000000..4ac00eb
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/recv.S
@@ -0,0 +1,25 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_recv SYS_ult_recv
+
+SYSCALL (recv, 4)
+ ret
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/send.S b/sysdeps/unix/bsd/Attic/osf1/alpha/send.S
new file mode 100644
index 0000000..ca46894
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/send.S
@@ -0,0 +1,25 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_send SYS_ult_send
+
+SYSCALL (send, 4)
+ ret
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/sigblock.S b/sysdeps/unix/bsd/Attic/osf1/alpha/sigblock.S
new file mode 100644
index 0000000..c3556a9
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/sigblock.S
@@ -0,0 +1,27 @@
+/* Copyright (C) 1994, 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. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_sigblock SYS_ult_sigblock
+
+SYSCALL__ (sigblock, 1)
+ ret
+
+weak_alias (__sigblock, sigblock)
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/sigpause.S b/sysdeps/unix/bsd/Attic/osf1/alpha/sigpause.S
new file mode 100644
index 0000000..04b6d45
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/sigpause.S
@@ -0,0 +1,27 @@
+/* Copyright (C) 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. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_sigpause SYS_ult_sigpause
+
+SYSCALL__ (sigpause, 1)
+ ret
+
+weak_alias (__sigpause, sigpause)
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/sigsetmask.S b/sysdeps/unix/bsd/Attic/osf1/alpha/sigsetmask.S
new file mode 100644
index 0000000..fb3a1d1
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/sigsetmask.S
@@ -0,0 +1,27 @@
+/* Copyright (C) 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. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_sigsetmask SYS_ult_sigsetmask
+
+SYSCALL__ (sigsetmask, 1)
+ ret
+
+weak_alias (__sigsetmask, sigsetmask)
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/sigvec.S b/sysdeps/unix/bsd/Attic/osf1/alpha/sigvec.S
new file mode 100644
index 0000000..b04ec6e
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/sigvec.S
@@ -0,0 +1,27 @@
+/* Copyright (C) 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. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_sigvec SYS_ult_sigvec
+
+SYSCALL__ (sigvec, 3)
+ ret
+
+weak_alias (__sigvec, sigvec)
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/start.S b/sysdeps/unix/bsd/Attic/osf1/alpha/start.S
new file mode 100644
index 0000000..8b7109a
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/start.S
@@ -0,0 +1,72 @@
+/* Copyright (C) 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. */
+
+#include <sysdep.h>
+
+#ifndef HAVE_WEAK_SYMBOLS
+#define __environ environ
+#else
+weak_alias (__environ, environ)
+#endif
+
+.comm __environ, 8
+.comm errno, 4
+
+!.sdata
+!.globl STARTFRM
+!STARTFRM = 0
+
+.text
+ENTRY(__start)
+ lda sp, -16(sp)
+ stq zero, 8(sp)
+
+ ! This branch puts the address of the current insn in t0.
+ br t0, 10f
+10:
+ ! We set the GP register by using the address of the ldgp
+ ! (what we just put into t0).
+ ldgp gp, 0(t0)
+
+ ! get argc
+ ldl a0, 16(sp)
+
+ ! get argv
+ lda a1, 24(sp)
+
+ ! move ahead to envp
+ s8addq a0, a1, a2
+ addq a2, 0x8, a2
+
+ ! Store in environ.
+ stq a2, environ
+
+ ! Clear out errno.
+! ldgp gp, 0(t12)
+ stl zero, errno
+
+ ! Call main.
+ jsr ra, main
+ ldgp gp, 0(ra)
+
+ mov v0, a0
+
+ jsr ra, exit
+ ldgp gp, 0(ra)
+
+ .end __start
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/statbuf.h b/sysdeps/unix/bsd/Attic/osf1/alpha/statbuf.h
new file mode 100644
index 0000000..9cadfae
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/statbuf.h
@@ -0,0 +1,75 @@
+/* Copyright (C) 1993 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. */
+
+#ifndef _STATBUF_H
+#define _STATBUF_H
+
+#include <gnu/types.h>
+
+/* Structure describing file characteristics. */
+struct stat
+ {
+ int st_dev; /* Device. */
+ unsigned int st_ino; /* File serial number. */
+ unsigned int st_mode; /* File mode. */
+ unsigned short st_nlink; /* Link count. */
+ unsigned int st_uid; /* User ID of the file's owner. */
+ unsigned int st_gid; /* Group ID of the file's group.*/
+ int st_rdev; /* Device number, if device. */
+
+ long st_size; /* Size of file, in bytes. */
+
+ int st_atime; /* Time of last access. */
+ int st_atime_usec;
+ int st_mtime; /* Time of last modification. */
+ int st_mtime_usec;
+ int st_ctime; /* Time of last status change. */
+ int st_ctime_usec;
+
+ unsigned int st_blksize; /* Optimal block size for I/O. */
+#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
+
+ int st_blocks; /* Number of 512-byte blocks allocated. */
+ unsigned int st_flags;
+ unsigned int st_gen;
+ };
+
+/* Encoding of the file mode. */
+
+#define __S_IFMT 0170000 /* These bits determine file type. */
+
+/* File types. */
+#define __S_IFDIR 0040000 /* Directory. */
+#define __S_IFCHR 0020000 /* Character device. */
+#define __S_IFBLK 0060000 /* Block device. */
+#define __S_IFREG 0100000 /* Regular file. */
+#define __S_IFIFO 0010000 /* FIFO. */
+
+#define __S_IFLNK 0120000 /* Symbolic link. */
+#define __S_IFSOCK 0140000 /* Socket. */
+
+/* Protection bits. */
+
+#define __S_ISUID 04000 /* Set user ID on execution. */
+#define __S_ISGID 02000 /* Set group ID on execution. */
+#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
+#define __S_IREAD 0400 /* Read by owner. */
+#define __S_IWRITE 0200 /* Write by owner. */
+#define __S_IEXEC 0100 /* Execute by owner. */
+
+#endif /* statbuf.h */
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/sysdep.S b/sysdeps/unix/bsd/Attic/osf1/alpha/sysdep.S
new file mode 100644
index 0000000..bc4865c
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/sysdep.S
@@ -0,0 +1,40 @@
+/* Copyright (C) 1993 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. */
+
+#include <sysdep.h>
+#define _ERRNO_H
+#include <errnos.h>
+
+ENTRY(syscall_error)
+#ifdef EWOULDBLOCK_sys
+ /* We translate the system's EWOULDBLOCK error into EAGAIN.
+ The GNU C library always defines EWOULDBLOCK==EAGAIN.
+ EWOULDBLOCK_sys is the original number. */
+ subq v0, EWOULDBLOCK_sys, t0
+ cmoveq t0, EAGAIN, v0
+#endif
+
+ /* Store it in errno... */
+! ldgp gp, 0(t12)
+ stl v0, errno
+
+ /* And just kick back a -1. */
+ ldil v0, -1
+ ret
+
+ .end syscall_error
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/sysdep.h b/sysdeps/unix/bsd/Attic/osf1/alpha/sysdep.h
new file mode 100644
index 0000000..3669a69
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/sysdep.h
@@ -0,0 +1,73 @@
+/* Copyright (C) 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. */
+
+#include <sysdeps/unix/sysdep.h>
+
+#ifdef ASSEMBLER
+
+#include <machine/pal.h> /* get PAL_callsys */
+#include <regdef.h>
+
+#ifdef __STDC__
+#define ENTRY(name) \
+ .globl name; \
+ .ent name,0; \
+ name##:; \
+ .frame sp,0,ra
+#else
+#define ENTRY(name) \
+ .globl name; \
+ .ent name,0; \
+ name/**/:; \
+ .frame sp,0,ra
+#endif
+
+#ifdef __STDC__
+#define PSEUDO(name, syscall_name, args) \
+ ENTRY(name); \
+ ldiq v0, SYS_##syscall_name; \
+ .set noat; \
+ call_pal PAL_callsys; \
+ .set at; \
+ beq a3, 10f; \
+ br gp, 20f; \
+20:; \
+ ldgp gp, 0(gp); \
+ jmp zero, syscall_error; \
+10:
+#else
+#define PSEUDO(name, syscall_name, args) \
+ ENTRY(name); \
+ ldiq v0, SYS_/**/syscall_name; \
+ .set noat; \
+ call_pal PAL_callsys; \
+ .set at; \
+ beq a3, 10f; \
+ br gp, 20f; \
+20:; \
+ ldgp gp, 0(gp); \
+ jmp zero, syscall_error; \
+10:
+#endif
+
+#define ret ret zero,(ra),1
+#define r0 v0
+#define r1 a4
+#define MOVE(x,y) mov x, y
+
+#endif /* ASSEMBLER */
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/vhangup.S b/sysdeps/unix/bsd/Attic/osf1/alpha/vhangup.S
new file mode 100644
index 0000000..d4d2b1c
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/vhangup.S
@@ -0,0 +1,25 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_vhangup SYS_ult_vhangup
+
+SYSCALL (vhangup, 1)
+ ret
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/wait4.S b/sysdeps/unix/bsd/Attic/osf1/alpha/wait4.S
new file mode 100644
index 0000000..e4c3223
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/wait4.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/wait4.S>
diff --git a/sysdeps/unix/bsd/Attic/osf1/alpha/waitpid.c b/sysdeps/unix/bsd/Attic/osf1/alpha/waitpid.c
new file mode 100644
index 0000000..8378982
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/alpha/waitpid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/waitpid.c>
diff --git a/sysdeps/unix/bsd/Attic/osf1/msync.S b/sysdeps/unix/bsd/Attic/osf1/msync.S
new file mode 100644
index 0000000..75b9f15
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/msync.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/sun/sunos4/msync.S>
diff --git a/sysdeps/unix/bsd/Attic/osf1/sigaction.h b/sysdeps/unix/bsd/Attic/osf1/sigaction.h
new file mode 100644
index 0000000..8a4e2c5
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/sigaction.h
@@ -0,0 +1,45 @@
+/* Structure and constand definitions for sigaction et al. OSF/1 version.
+ Copyright (C) 1993 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, 1992 Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+/* Structure describing the action to be taken when a signal arrives. */
+struct sigaction
+ {
+ /* Signal handler. */
+ __sighandler_t sa_handler;
+
+ /* Additional set of signals to be blocked. */
+ __sigset_t sa_mask;
+
+ /* Special flags. */
+ int sa_flags;
+ };
+
+/* Bits in `sa_flags'. */
+#ifdef __USE_BSD
+#define SA_ONSTACK 0x1 /* Take signal on signal stack. */
+#define SA_RESTART 0x2 /* Don't restart syscall on signal return. */
+#define SA_DISABLE 0x4 /* Disable alternate signal stack. */
+#endif
+#define SA_NOCLDSTOP 0x4 /* Don't send SIGCHLD when children stop. */
+
+
+/* Values for the HOW argument to `sigprocmask'. */
+#define SIG_BLOCK 1 /* Block signals. */
+#define SIG_UNBLOCK 2 /* Unblock signals. */
+#define SIG_SETMASK 3 /* Set the set of blocked signals. */
diff --git a/sysdeps/unix/bsd/Attic/osf1/sys/mman.h b/sysdeps/unix/bsd/Attic/osf1/sys/mman.h
new file mode 100644
index 0000000..6ac25f4
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/sys/mman.h
@@ -0,0 +1,114 @@
+/* Definitions for BSD-style memory management. OSF/1 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. */
+
+/* These are the bits used by 4.4 BSD and its derivatives. On systems
+ (such as GNU) where these facilities are not system services but can be
+ emulated in the C library, these are the definitions we emulate. */
+
+#ifndef _SYS_MMAN_H
+
+#define _SYS_MMAN_H 1
+#include <features.h>
+
+#include <gnu/types.h>
+#define __need_size_t
+#include <stddef.h>
+
+
+/* Protections are chosen from these bits, OR'd together. The
+ implementation does not necessarily support PROT_EXEC or PROT_WRITE
+ without PROT_READ. The only guarantees are that no writing will be
+ allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
+
+#define PROT_NONE 0x00 /* No access. */
+#define PROT_READ 0x01 /* Pages can be read. */
+#define PROT_WRITE 0x02 /* Pages can be written. */
+#define PROT_EXEC 0x04 /* Pages can be executed. */
+
+
+/* Flags contain mapping type, sharing type and options. */
+
+/* Mapping type (must choose one and only one of these). */
+#define MAP_FILE 0x00 /* Mapped from a file or device. */
+#define MAP_ANON 0x10 /* Allocated from anonymous virtual memory. */
+#define MAP_ANONYMOUS MAP_ANON
+#define MAP_TYPE 0xf0 /* Mask for type field. */
+
+/* Sharing types (must choose one and only one of these). */
+#define MAP_SHARED 0x01 /* Share changes. */
+#define MAP_PRIVATE 0x02 /* Changes private; copy pages on write. */
+
+/* Other flags. */
+#define MAP_FIXED 0x0100 /* Map address must be exactly as requested. */
+#define MAP_VARIABLE 0 /* Absence of MAP_FIXED. */
+#define MAP_HASSEMPHORE 0x0200 /* Region may contain semaphores. */
+#define MAP_INHERIT 0x0400 /* Region is retained after exec. */
+#define MAP_UNALIGNED 0x0800 /* File offset need not be page-aligned. */
+
+/* Advice to `madvise'. */
+#define MADV_NORMAL 0 /* No further special treatment. */
+#define MADV_RANDOM 1 /* Expect random page references. */
+#define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
+#define MADV_WILLNEED 3 /* Will need these pages. */
+#define MADV_DONTNEED 4 /* Don't need these pages. */
+#define MADV_SPACEAVAIL 5 /* Ensure that resources are available. */
+
+/* Flags to `msync'. */
+#define MS_ASYNC 1 /* Asynchronous cache flush. */
+#define MS_SYNC 3 /* Synchronous cache flush. */
+#define MS_INVALIDATE 4 /* Invalidate cached pages. */
+
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+/* Map addresses starting near ADDR and extending for LEN bytes. from
+ OFFSET into the file FD describes according to PROT and FLAGS. If ADDR
+ is nonzero, it is the desired mapping address. If the MAP_FIXED bit is
+ set in FLAGS, the mapping will be at ADDR exactly (which must be
+ page-aligned); otherwise the system chooses a convenient nearby address.
+ The return value is the actual mapping address chosen or (caddr_t) -1
+ for errors (in which case `errno' is set). A successful `mmap' call
+ deallocates any previous mapping for the affected region. */
+
+__caddr_t mmap __P ((__caddr_t __addr, size_t __len,
+ int __prot, int __flags, int __fd, off_t __offset));
+
+/* Deallocate any mapping for the region starting at ADDR and extending LEN
+ bytes. Returns 0 if successful, -1 for errors (and sets errno). */
+int munmap __P ((__caddr_t __addr, size_t __len));
+
+/* Change the memory protection of the region starting at ADDR and
+ extending LEN bytes to PROT. Returns 0 if successful, -1 for errors
+ (and sets errno). */
+int mprotect __P ((__caddr_t __addr, size_t __len, int __prot));
+
+/* Synchronize the region starting at ADDR and extending LEN bytes with the
+ file it maps. Filesystem operations on a file being mapped are
+ unpredictable before this is done. */
+int msync __P ((__caddr_t __addr, size_t __len, int __flags));
+
+/* Advise the system about particular usage patterns the program follows
+ for the region starting at ADDR and extending LEN bytes. */
+int madvise __P ((__caddr_t __addr, size_t __len, int __advice));
+
+__END_DECLS
+
+
+#endif /* sys/mman.h */
diff --git a/sysdeps/unix/bsd/Attic/osf1/system.c b/sysdeps/unix/bsd/Attic/osf1/system.c
new file mode 100644
index 0000000..ef42ea2
--- /dev/null
+++ b/sysdeps/unix/bsd/Attic/osf1/system.c
@@ -0,0 +1,2 @@
+/* OSF/1 does have `waitpid'. Avoid unix/system.c, which says we don't. */
+#include <sysdeps/posix/system.c>
diff --git a/sysdeps/unix/bsd/Dist b/sysdeps/unix/bsd/Dist
new file mode 100644
index 0000000..9e0e553
--- /dev/null
+++ b/sysdeps/unix/bsd/Dist
@@ -0,0 +1 @@
+bsdtty.h
diff --git a/sysdeps/unix/bsd/Implies b/sysdeps/unix/bsd/Implies
new file mode 100644
index 0000000..cfc4491
--- /dev/null
+++ b/sysdeps/unix/bsd/Implies
@@ -0,0 +1,5 @@
+# The directory unix/common contains things which are common to both BSD
+# and SVR4.
+unix/common
+# The directory unix/inet implements sockets and networking in the usual way.
+unix/inet
diff --git a/sysdeps/unix/bsd/alarm.c b/sysdeps/unix/bsd/alarm.c
new file mode 100644
index 0000000..7743256
--- /dev/null
+++ b/sysdeps/unix/bsd/alarm.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+/* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM.
+ If SECONDS is zero, any currently scheduled alarm will be cancelled.
+ The function returns the number of seconds remaining until the last
+ alarm scheduled would have signaled, or zero if there wasn't one.
+ There is no return value to indicate an error, but you can set `errno'
+ to 0 and check its value after calling `alarm', and this might tell you.
+ The signal may come late due to processor scheduling. */
+unsigned int
+DEFUN(alarm, (seconds), unsigned int seconds)
+{
+ struct itimerval old, new;
+
+ new.it_interval.tv_usec = 0;
+ new.it_interval.tv_sec = 0;
+ new.it_value.tv_usec = 0;
+ new.it_value.tv_sec = (long int) seconds;
+ if (__setitimer(ITIMER_REAL, &new, &old) < 0)
+ return 0;
+
+ return (old.it_value.tv_sec + (old.it_value.tv_usec + 999999) / 1000000);
+}
diff --git a/sysdeps/unix/bsd/bsd4.4/Implies b/sysdeps/unix/bsd/bsd4.4/Implies
new file mode 100644
index 0000000..3bdab54
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/Implies
@@ -0,0 +1,2 @@
+# 4.4 BSD has the canonical set of <sys/mman.h> system calls.
+unix/mman
diff --git a/sysdeps/unix/bsd/bsd4.4/chflags.S b/sysdeps/unix/bsd/bsd4.4/chflags.S
new file mode 100644
index 0000000..629ff5c
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/chflags.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (chflags, 2)
+ ret
diff --git a/sysdeps/unix/bsd/bsd4.4/direct.h b/sysdeps/unix/bsd/bsd4.4/direct.h
new file mode 100644
index 0000000..06641fc
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/direct.h
@@ -0,0 +1,16 @@
+#ifndef MAXNAMLEN
+#define MAXNAMLEN 255
+#endif
+
+struct direct
+ {
+ unsigned long int d_fileno;
+ unsigned short int d_reclen;
+ unsigned char d_type; /* File type, possibly unknown. */
+ unsigned char d_namlen; /* Length of the file name. */
+ char d_name[MAXNAMLEN + 1];
+ };
+
+#define D_NAMLEN(d) ((d)->d_namlen)
+
+#define HAVE_D_TYPE
diff --git a/sysdeps/unix/bsd/bsd4.4/errnos.h b/sysdeps/unix/bsd/bsd4.4/errnos.h
new file mode 100644
index 0000000..dcfdd9c
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/errnos.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)errno.h 8.5 (Berkeley) 1/21/94
+ */
+
+#ifdef _ERRNO_H
+
+#define EPERM 1 /* Operation not permitted */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* Interrupted system call */
+#define EIO 5 /* Input/output error */
+#define ENXIO 6 /* Device not configured */
+#define E2BIG 7 /* Argument list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file descriptor */
+#define ECHILD 10 /* No child processes */
+#define EDEADLK 11 /* Resource deadlock avoided */
+ /* 11 was EAGAIN */
+#define ENOMEM 12 /* Cannot allocate memory */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+#ifdef __USE_BSD
+#define ENOTBLK 15 /* Block device required */
+#endif
+#define EBUSY 16 /* Device busy */
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* Operation not supported by device */
+#define ENOTDIR 20 /* Not a directory */
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* Too many open files in system */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Inappropriate ioctl for device */
+#ifdef __USE_BSD
+#define ETXTBSY 26 /* Text file busy */
+#endif
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read-only file system */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+
+#endif /* <errno.h> included. */
+
+/* math software */
+
+#if !defined(__Emath_defined) && (defined(_ERRNO_H) || defined(__need_Emath))
+#define EDOM 33 /* Numerical argument out of domain */
+#endif /* Emath not defined and <errno.h> included or need Emath. */
+#if !defined(__Emath_defined) && (defined(_ERRNO_H) || defined(__need_Emath))
+#define ERANGE 34 /* Result too large */
+#endif /* Emath not defined and <errno.h> included or need Emath. */
+
+#ifdef _ERRNO_H
+
+/* non-blocking and interrupt i/o */
+#define EAGAIN 35 /* Resource temporarily unavailable */
+#ifdef __USE_BSD
+#define EWOULDBLOCK EAGAIN /* Operation would block */
+#define EINPROGRESS 36 /* Operation now in progress */
+#define EALREADY 37 /* Operation already in progress */
+
+/* ipc/network software -- argument errors */
+#define ENOTSOCK 38 /* Socket operation on non-socket */
+#define EDESTADDRREQ 39 /* Destination address required */
+#define EMSGSIZE 40 /* Message too long */
+#define EPROTOTYPE 41 /* Protocol wrong type for socket */
+#define ENOPROTOOPT 42 /* Protocol not available */
+#define EPROTONOSUPPORT 43 /* Protocol not supported */
+#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
+#define EOPNOTSUPP 45 /* Operation not supported */
+#define EPFNOSUPPORT 46 /* Protocol family not supported */
+#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */
+#define EADDRINUSE 48 /* Address already in use */
+#define EADDRNOTAVAIL 49 /* Can't assign requested address */
+
+/* ipc/network software -- operational errors */
+#define ENETDOWN 50 /* Network is down */
+#define ENETUNREACH 51 /* Network is unreachable */
+#define ENETRESET 52 /* Network dropped connection on reset */
+#define ECONNABORTED 53 /* Software caused connection abort */
+#define ECONNRESET 54 /* Connection reset by peer */
+#define ENOBUFS 55 /* No buffer space available */
+#define EISCONN 56 /* Socket is already connected */
+#define ENOTCONN 57 /* Socket is not connected */
+#define ESHUTDOWN 58 /* Can't send after socket shutdown */
+#define ETOOMANYREFS 59 /* Too many references: can't splice */
+#define ETIMEDOUT 60 /* Operation timed out */
+#define ECONNREFUSED 61 /* Connection refused */
+
+#define ELOOP 62 /* Too many levels of symbolic links */
+#endif /* __USE_BSD */
+#define ENAMETOOLONG 63 /* File name too long */
+
+/* should be rearranged */
+#ifdef __USE_BSD
+#define EHOSTDOWN 64 /* Host is down */
+#define EHOSTUNREACH 65 /* No route to host */
+#endif /* __USE_BSD */
+#define ENOTEMPTY 66 /* Directory not empty */
+
+/* quotas & mush */
+#ifdef __USE_BSD
+#define EPROCLIM 67 /* Too many processes */
+#define EUSERS 68 /* Too many users */
+#define EDQUOT 69 /* Disc quota exceeded */
+
+/* Network File System */
+#define ESTALE 70 /* Stale NFS file handle */
+#define EREMOTE 71 /* Too many levels of remote in path */
+#define EBADRPC 72 /* RPC struct is bad */
+#define ERPCMISMATCH 73 /* RPC version wrong */
+#define EPROGUNAVAIL 74 /* RPC prog. not avail */
+#define EPROGMISMATCH 75 /* Program version wrong */
+#define EPROCUNAVAIL 76 /* Bad procedure for program */
+#endif /* __USE_BSD */
+
+#define ENOLCK 77 /* No locks available */
+#define ENOSYS 78 /* Function not implemented */
+
+#define EFTYPE 79 /* Inappropriate file type or format */
+
+#ifdef __USE_BSD
+#define EAUTH 80 /* Authentication error */
+#define ENEEDAUTH 81 /* Need authenticator */
+#define ELAST 81 /* Must be equal largest errno */
+#endif /* __USE_BSD */
+
+
+#endif /* <errno.h> included. */
diff --git a/sysdeps/unix/bsd/bsd4.4/fchdir.S b/sysdeps/unix/bsd/bsd4.4/fchdir.S
new file mode 100644
index 0000000..e749ade
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/fchdir.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (fchdir, 2)
+ ret
diff --git a/sysdeps/unix/bsd/bsd4.4/fchflags.S b/sysdeps/unix/bsd/bsd4.4/fchflags.S
new file mode 100644
index 0000000..9e4d143
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/fchflags.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (fchflags, 2)
+ ret
diff --git a/sysdeps/unix/bsd/bsd4.4/fcntlbits.h b/sysdeps/unix/bsd/bsd4.4/fcntlbits.h
new file mode 100644
index 0000000..bb61392
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/fcntlbits.h
@@ -0,0 +1,116 @@
+/* O_*, F_*, FD_* bit values for 4.4 BSD.
+Copyright (C) 1991, 1992 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 _FCNTLBITS_H
+
+#define _FCNTLBITS_H 1
+
+
+/* File access modes for `open' and `fcntl'. */
+#define O_RDONLY 0 /* Open read-only. */
+#define O_WRONLY 1 /* Open write-only. */
+#define O_RDWR 2 /* Open read/write. */
+
+
+/* Bits OR'd into the second argument to open. */
+#define O_CREAT 0x0200 /* Create file if it doesn't exist. */
+#define O_EXCL 0x0800 /* Fail if file already exists. */
+#define O_TRUNC 0x0400 /* Truncate file to zero length. */
+/* Apparently not assigning a controlling terminal is the default
+ behavior in BSD, so no bit is required to request that behavior. */
+#define O_NOCTTY 0 /* Don't assign a controlling terminal. */
+#ifdef __USE_MISC
+#define O_ASYNC 0x0040 /* Send SIGIO to owner when data is ready. */
+#define O_FSYNC 0x0080 /* Synchronous writes. */
+#define O_SYNC O_FSYNC
+#define O_SHLOCK 0x0010 /* Open with shared file lock. */
+#define O_EXLOCK 0x0020 /* Open with shared exclusive lock. */
+#endif
+
+/* File status flags for `open' and `fcntl'. */
+#define O_APPEND 0x0008 /* Writes append to the file. */
+#define O_NONBLOCK 0x0004 /* Non-blocking I/O. */
+
+#ifdef __USE_BSD
+#define O_NDELAY O_NONBLOCK
+#endif
+
+#ifdef __USE_BSD
+/* Bits in the file status flags returned by F_GETFL.
+ These are all the O_* flags, plus FREAD and FWRITE, which are
+ independent bits set by which of O_RDONLY, O_WRONLY, and O_RDWR, was
+ given to `open'. */
+#define FREAD 1
+#define FWRITE 2
+
+/* Traditional BSD names the O_* bits. */
+#define FASYNC O_ASYNC
+#define FCREAT O_CREAT
+#define FEXCL O_EXCL
+#define FTRUNC O_TRUNC
+#define FNOCTTY O_NOCTTY
+#define FFSYNC O_FSYNC
+#define FSYNC O_SYNC
+#define FAPPEND O_APPEND
+#define FNONBLOCK O_NONBLOCK
+#define FNDELAY O_NDELAY
+#endif
+
+/* Mask for file access modes. This is system-dependent in case
+ some system ever wants to define some other flavor of access. */
+#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
+
+/* Values for the second argument to `fcntl'. */
+#define F_DUPFD 0 /* Duplicate file descriptor. */
+#define F_GETFD 1 /* Get file descriptor flags. */
+#define F_SETFD 2 /* Set file descriptor flags. */
+#define F_GETFL 3 /* Get file status flags. */
+#define F_SETFL 4 /* Set file status flags. */
+#ifdef __USE_BSD
+#define F_GETOWN 5 /* Get owner (receiver of SIGIO). */
+#define F_SETOWN 6 /* Set owner (receiver of SIGIO). */
+#endif
+#define F_GETLK 7 /* Get record locking info. */
+#define F_SETLK 8 /* Set record locking info (non-blocking). */
+#define F_SETLKW 9 /* Set record locking info (blocking). */
+
+/* File descriptor flags used with F_GETFD and F_SETFD. */
+#define FD_CLOEXEC 1 /* Close on exec. */
+
+
+#include <gnu/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. */
+struct flock
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+ short int l_pid; /* Process holding the lock. */
+ };
+
+/* Values for the `l_type' field of a `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/getdents.S b/sysdeps/unix/bsd/bsd4.4/getdents.S
new file mode 100644
index 0000000..be449b2
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/getdents.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/sun/getdents.S>
diff --git a/sysdeps/unix/bsd/bsd4.4/getdomain.S b/sysdeps/unix/bsd/bsd4.4/getdomain.S
new file mode 100644
index 0000000..b1ba2fd
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/getdomain.S
@@ -0,0 +1,22 @@
+/* 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. */
+
+#include <sysdep.h>
+
+SYSCALL (getdomainname, 2)
+ ret
diff --git a/sysdeps/unix/bsd/bsd4.4/ioctls.h b/sysdeps/unix/bsd/bsd4.4/ioctls.h
new file mode 100644
index 0000000..6c351f4
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/ioctls.h
@@ -0,0 +1,292 @@
+/*-
+ * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ioctl.h 7.19 (Berkeley) 6/26/91
+ */
+
+#ifndef _IOCTLS_H_
+#define _IOCTLS_H_
+
+#define TIOCGSIZE TIOCGWINSZ
+#define TIOCSSIZE TIOCSWINSZ
+
+/*
+ * Ioctl's have the command encoded in the lower word, and the size of
+ * any in or out parameters in the upper word. The high 3 bits of the
+ * upper word are used to encode the in/out status of the parameter.
+ */
+#define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */
+#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
+#define IOCBASECMD(x) ((x) & ~IOCPARM_MASK)
+#define IOCGROUP(x) (((x) >> 8) & 0xff)
+
+#define IOCPARM_MAX NBPG /* max size of ioctl, mult. of NBPG */
+#define IOC_VOID 0x20000000 /* no parameters */
+#define IOC_OUT 0x40000000 /* copy out parameters */
+#define IOC_IN 0x80000000 /* copy in parameters */
+#define IOC_INOUT (IOC_IN|IOC_OUT)
+#define IOC_DIRMASK 0xe0000000 /* mask for IN/OUT/VOID */
+
+#define _IOC(inout,group,num,len) \
+ (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))
+#define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0)
+#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t))
+#define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t))
+/* this should be _IORW, but stdio got there first */
+#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
+
+#define TIOCMODG _IOR('t', 3, int) /* get modem control state */
+#define TIOCMODS _IOW('t', 4, int) /* set modem control state */
+#define TIOCM_LE 0001 /* line enable */
+#define TIOCM_DTR 0002 /* data terminal ready */
+#define TIOCM_RTS 0004 /* request to send */
+#define TIOCM_ST 0010 /* secondary transmit */
+#define TIOCM_SR 0020 /* secondary receive */
+#define TIOCM_CTS 0040 /* clear to send */
+#define TIOCM_CAR 0100 /* carrier detect */
+#define TIOCM_CD TIOCM_CAR
+#define TIOCM_RNG 0200 /* ring */
+#define TIOCM_RI TIOCM_RNG
+#define TIOCM_DSR 0400 /* data set ready */
+ /* 8-10 compat */
+#define TIOCEXCL _IO('t', 13) /* set exclusive use of tty */
+#define TIOCNXCL _IO('t', 14) /* reset exclusive use of tty */
+ /* 15 unused */
+#define TIOCFLUSH _IOW('t', 16, int) /* flush buffers */
+ /* 17-18 compat */
+#define TIOCGETA _IOR('t', 19, struct termios) /* get termios struct */
+#define TIOCSETA _IOW('t', 20, struct termios) /* set termios struct */
+#define TIOCSETAW _IOW('t', 21, struct termios) /* drain output, set */
+#define TIOCSETAF _IOW('t', 22, struct termios) /* drn out, fls in, set */
+#define TIOCGETD _IOR('t', 26, int) /* get line discipline */
+#define TIOCSETD _IOW('t', 27, int) /* set line discipline */
+ /* 127-124 compat */
+#define TIOCSBRK _IO('t', 123) /* set break bit */
+#define TIOCCBRK _IO('t', 122) /* clear break bit */
+#define TIOCSDTR _IO('t', 121) /* set data terminal ready */
+#define TIOCCDTR _IO('t', 120) /* clear data terminal ready */
+#define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */
+#define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */
+ /* 117-116 compat */
+#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
+#define TIOCSTI _IOW('t', 114, char) /* simulate terminal input */
+#define TIOCNOTTY _IO('t', 113) /* void tty association */
+#define TIOCPKT _IOW('t', 112, int) /* pty: set/clear packet mode */
+#define TIOCPKT_DATA 0x00 /* data packet */
+#define TIOCPKT_FLUSHREAD 0x01 /* flush packet */
+#define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */
+#define TIOCPKT_STOP 0x04 /* stop output */
+#define TIOCPKT_START 0x08 /* start output */
+#define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */
+#define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */
+#define TIOCPKT_IOCTL 0x40 /* state change of pty driver */
+#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */
+#define TIOCSTART _IO('t', 110) /* start output, like ^Q */
+#define TIOCMSET _IOW('t', 109, int) /* set all modem bits */
+#define TIOCMBIS _IOW('t', 108, int) /* bis modem bits */
+#define TIOCMBIC _IOW('t', 107, int) /* bic modem bits */
+#define TIOCMGET _IOR('t', 106, int) /* get all modem bits */
+#define TIOCREMOTE _IOW('t', 105, int) /* remote input editing */
+#define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */
+#define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */
+#define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */
+#define UIOCCMD(n) _IO('u', n) /* usr cntl op "n" */
+#define TIOCCONS _IOW('t', 98, int) /* become virtual console */
+#define TIOCSCTTY _IO('t', 97) /* become controlling tty */
+#define TIOCEXT _IOW('t', 96, int) /* pty: external processing */
+#define TIOCSIG _IO('t', 95) /* pty: generate signal */
+#define TIOCDRAIN _IO('t', 94) /* wait till output drained */
+
+#define TTYDISC 0 /* termios tty line discipline */
+#define TABLDISC 3 /* tablet discipline */
+#define SLIPDISC 4 /* serial IP discipline */
+
+
+#define FIOCLEX _IO('f', 1) /* set close on exec on fd */
+#define FIONCLEX _IO('f', 2) /* remove close on exec */
+#define FIONREAD _IOR('f', 127, int) /* get # bytes to read */
+#define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */
+#define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */
+#define FIOSETOWN _IOW('f', 124, int) /* set owner */
+#define FIOGETOWN _IOR('f', 123, int) /* get owner */
+
+/* socket i/o controls */
+#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */
+#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */
+#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */
+#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */
+#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */
+#define SIOCSPGRP _IOW('s', 8, int) /* set process group */
+#define SIOCGPGRP _IOR('s', 9, int) /* get process group */
+
+#define SIOCADDRT _IOW('r', 10, struct ortentry) /* add route */
+#define SIOCDELRT _IOW('r', 11, struct ortentry) /* delete route */
+
+#define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */
+#define OSIOCGIFADDR _IOWR('i',13, struct ifreq) /* get ifnet address */
+#define SIOCGIFADDR _IOWR('i',33, struct ifreq) /* get ifnet address */
+#define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */
+#define OSIOCGIFDSTADDR _IOWR('i',15, struct ifreq) /* get p-p address */
+#define SIOCGIFDSTADDR _IOWR('i',34, struct ifreq) /* get p-p address */
+#define SIOCSIFFLAGS _IOW('i', 16, struct ifreq) /* set ifnet flags */
+#define SIOCGIFFLAGS _IOWR('i',17, struct ifreq) /* get ifnet flags */
+#define OSIOCGIFBRDADDR _IOWR('i',18, struct ifreq) /* get broadcast addr */
+#define SIOCGIFBRDADDR _IOWR('i',35, struct ifreq) /* get broadcast addr */
+#define SIOCSIFBRDADDR _IOW('i',19, struct ifreq) /* set broadcast addr */
+#define OSIOCGIFCONF _IOWR('i',20, struct ifconf) /* get ifnet list */
+#define SIOCGIFCONF _IOWR('i',36, struct ifconf) /* get ifnet list */
+#define OSIOCGIFNETMASK _IOWR('i',21, struct ifreq) /* get net addr mask */
+#define SIOCGIFNETMASK _IOWR('i',37, struct ifreq) /* get net addr mask */
+#define SIOCSIFNETMASK _IOW('i',22, struct ifreq) /* set net addr mask */
+#define SIOCGIFMETRIC _IOWR('i',23, struct ifreq) /* get IF metric */
+#define SIOCSIFMETRIC _IOW('i',24, struct ifreq) /* set IF metric */
+#define SIOCDIFADDR _IOW('i',25, struct ifreq) /* delete IF addr */
+#define SIOCAIFADDR _IOW('i',26, struct ifaliasreq) /* add/chg IF alias */
+
+#define SIOCSARP _IOW('i', 30, struct arpreq) /* set arp entry */
+#define OSIOCGARP _IOWR('i',31, struct arpreq) /* get arp entry */
+#define SIOCGARP _IOWR('i',38, struct arpreq) /* get arp entry */
+#define SIOCDARP _IOW('i', 32, struct arpreq) /* delete arp entry */
+
+
+/* Compatibility with 4.3 BSD terminal driver.
+ From 4.4 <sys/ioctl_compat.h>. */
+
+#ifdef USE_OLD_TTY
+# undef TIOCGETD
+# define TIOCGETD _IOR('t', 0, int) /* get line discipline */
+# undef TIOCSETD
+# define TIOCSETD _IOW('t', 1, int) /* set line discipline */
+#else
+# define OTIOCGETD _IOR('t', 0, int) /* get line discipline */
+# define OTIOCSETD _IOW('t', 1, int) /* set line discipline */
+#endif
+#define TIOCHPCL _IO('t', 2) /* hang up on last close */
+#define TIOCGETP _IOR('t', 8,struct sgttyb)/* get parameters -- gtty */
+#define TIOCSETP _IOW('t', 9,struct sgttyb)/* set parameters -- stty */
+#define TIOCSETN _IOW('t',10,struct sgttyb)/* as above, but no flushtty*/
+#define TIOCSETC _IOW('t',17,struct tchars)/* set special characters */
+#define TIOCGETC _IOR('t',18,struct tchars)/* get special characters */
+#define TANDEM 0x00000001 /* send stopc on out q full */
+#define CBREAK 0x00000002 /* half-cooked mode */
+#define LCASE 0x00000004 /* simulate lower case */
+#define ECHO 0x00000008 /* echo input */
+#define CRMOD 0x00000010 /* map \r to \r\n on output */
+#define RAW 0x00000020 /* no i/o processing */
+#define ODDP 0x00000040 /* get/send odd parity */
+#define EVENP 0x00000080 /* get/send even parity */
+#define ANYP 0x000000c0 /* get any parity/send none */
+#define NLDELAY 0x00000300 /* \n delay */
+#define NL0 0x00000000
+#define NL1 0x00000100 /* tty 37 */
+#define NL2 0x00000200 /* vt05 */
+#define NL3 0x00000300
+#define TBDELAY 0x00000c00 /* horizontal tab delay */
+#define TAB0 0x00000000
+#define TAB1 0x00000400 /* tty 37 */
+#define TAB2 0x00000800
+#define XTABS 0x00000c00 /* expand tabs on output */
+#define CRDELAY 0x00003000 /* \r delay */
+#define CR0 0x00000000
+#define CR1 0x00001000 /* tn 300 */
+#define CR2 0x00002000 /* tty 37 */
+#define CR3 0x00003000 /* concept 100 */
+#define VTDELAY 0x00004000 /* vertical tab delay */
+#define FF0 0x00000000
+#define FF1 0x00004000 /* tty 37 */
+#define BSDELAY 0x00008000 /* \b delay */
+#define BS0 0x00000000
+#define BS1 0x00008000
+#define ALLDELAY (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)
+#define CRTBS 0x00010000 /* do backspacing for crt */
+#define PRTERA 0x00020000 /* \ ... / erase */
+#define CRTERA 0x00040000 /* " \b " to wipe out char */
+#define TILDE 0x00080000 /* hazeltine tilde kludge */
+#define MDMBUF 0x00100000 /*start/stop output on carrier*/
+#define LITOUT 0x00200000 /* literal output */
+#define TOSTOP 0x00400000 /*SIGSTOP on background output*/
+#define FLUSHO 0x00800000 /* flush output to terminal */
+#define NOHANG 0x01000000 /* (no-op) was no SIGHUP on carrier drop */
+#define L001000 0x02000000
+#define CRTKIL 0x04000000 /* kill line with " \b " */
+#define PASS8 0x08000000
+#define CTLECH 0x10000000 /* echo control chars as ^X */
+#define PENDIN 0x20000000 /* tp->t_rawq needs reread */
+#define DECCTQ 0x40000000 /* only ^Q starts after ^S */
+#define NOFLSH 0x80000000 /* no output flush on signal */
+#define TIOCLBIS _IOW('t', 127, int) /* bis local mode bits */
+#define TIOCLBIC _IOW('t', 126, int) /* bic local mode bits */
+#define TIOCLSET _IOW('t', 125, int) /* set entire local mode word */
+#define TIOCLGET _IOR('t', 124, int) /* get local modes */
+#define LCRTBS (CRTBS>>16)
+#define LPRTERA (PRTERA>>16)
+#define LCRTERA (CRTERA>>16)
+#define LTILDE (TILDE>>16)
+#define LMDMBUF (MDMBUF>>16)
+#define LLITOUT (LITOUT>>16)
+#define LTOSTOP (TOSTOP>>16)
+#define LFLUSHO (FLUSHO>>16)
+#define LNOHANG (NOHANG>>16)
+#define LCRTKIL (CRTKIL>>16)
+#define LPASS8 (PASS8>>16)
+#define LCTLECH (CTLECH>>16)
+#define LPENDIN (PENDIN>>16)
+#define LDECCTQ (DECCTQ>>16)
+#define LNOFLSH (NOFLSH>>16)
+#define TIOCSLTC _IOW('t',117,struct ltchars)/* set local special chars*/
+#define TIOCGLTC _IOR('t',116,struct ltchars)/* get local special chars*/
+#define OTIOCCONS _IO('t', 98) /* for hp300 -- sans int arg */
+#define OTTYDISC 0
+#define NETLDISC 1
+#define NTTYDISC 2
+
+/* From 4.4 <sys/ttydev.h>. */
+#ifdef USE_OLD_TTY
+#define B0 0
+#define B50 1
+#define B75 2
+#define B110 3
+#define B134 4
+#define B150 5
+#define B200 6
+#define B300 7
+#define B600 8
+#define B1200 9
+#define B1800 10
+#define B2400 11
+#define B4800 12
+#define B9600 13
+#define EXTA 14
+#define EXTB 15
+#endif /* USE_OLD_TTY */
+
+#endif /* !_IOCTLS_H_ */
diff --git a/sysdeps/unix/bsd/bsd4.4/setdomain.S b/sysdeps/unix/bsd/bsd4.4/setdomain.S
new file mode 100644
index 0000000..fbaa7a8
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/setdomain.S
@@ -0,0 +1,22 @@
+/* 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. */
+
+#include <sysdep.h>
+
+SYSCALL (setdomainname, 2)
+ ret
diff --git a/sysdeps/unix/bsd/bsd4.4/setegid.S b/sysdeps/unix/bsd/bsd4.4/setegid.S
new file mode 100644
index 0000000..b471872
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/setegid.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (setegid, 1)
+ ret
diff --git a/sysdeps/unix/bsd/bsd4.4/seteuid.S b/sysdeps/unix/bsd/bsd4.4/seteuid.S
new file mode 100644
index 0000000..a4f55d3
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/seteuid.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (seteuid, 1)
+ ret
diff --git a/sysdeps/unix/bsd/bsd4.4/setlogin.S b/sysdeps/unix/bsd/bsd4.4/setlogin.S
new file mode 100644
index 0000000..ba364b9
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/setlogin.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (setlogin, 2)
+ ret
diff --git a/sysdeps/unix/bsd/bsd4.4/setsid.S b/sysdeps/unix/bsd/bsd4.4/setsid.S
new file mode 100644
index 0000000..6e776e1
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/setsid.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (setsid, 0)
+ ret
+
+weak_alias (__setsid, setsid)
diff --git a/sysdeps/unix/bsd/bsd4.4/sigaltstack.S b/sysdeps/unix/bsd/bsd4.4/sigaltstack.S
new file mode 100644
index 0000000..86d7706
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/sigaltstack.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (sigaltstack, 2)
+ ret
diff --git a/sysdeps/unix/bsd/bsd4.4/sigblock.c b/sysdeps/unix/bsd/bsd4.4/sigblock.c
new file mode 100644
index 0000000..2647327
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/sigblock.c
@@ -0,0 +1 @@
+#include <sysdeps/posix/sigblock.c>
diff --git a/sysdeps/unix/bsd/bsd4.4/sigsetmask.c b/sysdeps/unix/bsd/bsd4.4/sigsetmask.c
new file mode 100644
index 0000000..47f1e36
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/sigsetmask.c
@@ -0,0 +1 @@
+#include <sysdeps/posix/sigsetmask.c>
diff --git a/sysdeps/unix/bsd/bsd4.4/sigvec.c b/sysdeps/unix/bsd/bsd4.4/sigvec.c
new file mode 100644
index 0000000..d03d9bb
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/sigvec.c
@@ -0,0 +1 @@
+#include <sysdeps/posix/sigvec.c>
diff --git a/sysdeps/unix/bsd/bsd4.4/sockaddrcom.h b/sysdeps/unix/bsd/bsd4.4/sockaddrcom.h
new file mode 100644
index 0000000..4d81f1e
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/sockaddrcom.h
@@ -0,0 +1,35 @@
+/* Definition of `struct sockaddr_*' common members. 4.4 BSD version.
+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. */
+
+#ifndef _SOCKADDRCOM_H
+#define _SOCKADDRCOM_H 1
+
+
+/* This macro is used to declare the initial common members
+ of the data types used for socket addresses, `struct sockaddr',
+ `struct sockaddr_in', `struct sockaddr_un', etc. */
+
+#define __SOCKADDR_COMMON(sa_prefix) \
+ unsigned char sa_prefix##len; \
+ unsigned char sa_prefix##family
+
+#define __SOCKADDR_COMMON_SIZE (2 * sizeof (unsigned char))
+
+
+#endif /* sockaddrcom.h */
diff --git a/sysdeps/unix/bsd/bsd4.4/sstk.S b/sysdeps/unix/bsd/bsd4.4/sstk.S
new file mode 100644
index 0000000..c73840f
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/sstk.S
@@ -0,0 +1,23 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+/* XXX: not 0 args */
+SYSCALL (sstk, 0)
+ ret
diff --git a/sysdeps/unix/bsd/bsd4.4/system.c b/sysdeps/unix/bsd/bsd4.4/system.c
new file mode 100644
index 0000000..9283f74
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/system.c
@@ -0,0 +1,2 @@
+/* BSD 4.4 does have `waitpid'. Avoid unix/system.c, which says we don't. */
+#include <sysdeps/posix/system.c>
diff --git a/sysdeps/unix/bsd/bsd4.4/tcdrain.c b/sysdeps/unix/bsd/bsd4.4/tcdrain.c
new file mode 100644
index 0000000..ac7c9cd
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/tcdrain.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <sys/ioctl.h>
+
+/* Wait for pending output to be written on FD. */
+int
+DEFUN(tcdrain, (fd), int fd)
+{
+ return __ioctl (fd, TIOCDRAIN);
+}
diff --git a/sysdeps/unix/bsd/bsd4.4/tcgetattr.c b/sysdeps/unix/bsd/bsd4.4/tcgetattr.c
new file mode 100644
index 0000000..0173dc5
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/tcgetattr.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <termios.h>
+
+/* These are defined both in termbits.h and in ioctls.h.
+ They should have the same values, but perhaps not written the same way. */
+#undef ECHO
+#undef MDMBUF
+#undef TOSTOP
+#undef FLUSHO
+#undef PENDIN
+#undef NOFLSH
+#include <sys/ioctl.h>
+
+/* Put the state of FD into *TERMIOS_P. */
+int
+DEFUN(__tcgetattr, (fd, termios_p),
+ int fd AND struct termios *termios_p)
+{
+ return __ioctl (fd, TIOCGETA, termios_p);
+}
+
+weak_alias (__tcgetattr, tcgetattr)
diff --git a/sysdeps/unix/bsd/bsd4.4/tcsetattr.c b/sysdeps/unix/bsd/bsd4.4/tcsetattr.c
new file mode 100644
index 0000000..8852ad5
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/tcsetattr.c
@@ -0,0 +1,61 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <termios.h>
+
+/* These are defined both in termbits.h and in ioctls.h.
+ They should have the same values, but perhaps not written the same way. */
+#undef ECHO
+#undef MDMBUF
+#undef TOSTOP
+#undef FLUSHO
+#undef PENDIN
+#undef NOFLSH
+#include <sys/ioctl.h>
+
+
+/* Set the state of FD to *TERMIOS_P. */
+int
+DEFUN(tcsetattr, (fd, optional_actions, termios_p),
+ int fd AND int optional_actions AND CONST struct termios *termios_p)
+{
+ struct termios myt;
+
+ if (optional_actions & TCSASOFT)
+ {
+ myt = *termios_p;
+ myt.c_cflag |= CIGNORE;
+ termios_p = &myt;
+ optional_actions &= ~TCSASOFT;
+ }
+
+ switch (optional_actions)
+ {
+ case TCSANOW:
+ return __ioctl (fd, TIOCSETA, termios_p);
+
+ case TCSADRAIN:
+ return __ioctl (fd, TIOCSETAW, termios_p);
+
+ default:
+ return __ioctl (fd, TIOCSETAF, termios_p);
+ }
+}
diff --git a/sysdeps/unix/bsd/bsd4.4/wait.c b/sysdeps/unix/bsd/bsd4.4/wait.c
new file mode 100644
index 0000000..a29a99f
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/wait.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <sys/resource.h>
+#include <stddef.h>
+
+/* Wait for a child to die. When one does, put its status in *STAT_LOC
+ and return its process ID. For errors, return (pid_t) -1. */
+__pid_t
+DEFUN(__wait, (stat_loc), __WAIT_STATUS_DEFN stat_loc)
+{
+ return __wait4 (WAIT_ANY, stat_loc, 0, (struct rusage *) NULL);
+}
+
+weak_alias (__wait, wait)
diff --git a/sysdeps/unix/bsd/bsd4.4/wait3.c b/sysdeps/unix/bsd/bsd4.4/wait3.c
new file mode 100644
index 0000000..2f18c2c
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/wait3.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+
+/* Wait for a child to exit. When one does, put its status in *STAT_LOC and
+ return its process ID. For errors return (pid_t) -1. If USAGE is not nil,
+ store information about the child's resource usage (as a `struct rusage')
+ there. If the WUNTRACED bit is set in OPTIONS, return status for stopped
+ children; otherwise don't. */
+pid_t
+DEFUN(__wait3, (stat_loc, options, usage),
+ __WAIT_STATUS_DEFN stat_loc AND int options AND struct rusage *usage)
+{
+ return __wait4 (WAIT_ANY, stat_loc, options, usage);
+}
+
+weak_alias (__wait3, wait3)
diff --git a/sysdeps/unix/bsd/bsd4.4/wait4.S b/sysdeps/unix/bsd/bsd4.4/wait4.S
new file mode 100644
index 0000000..43b866f
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/wait4.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (wait4, 4)
+ ret
+
+weak_alias (__wait4, wait4)
diff --git a/sysdeps/unix/bsd/bsd4.4/waitpid.c b/sysdeps/unix/bsd/bsd4.4/waitpid.c
new file mode 100644
index 0000000..b5a34c3
--- /dev/null
+++ b/sysdeps/unix/bsd/bsd4.4/waitpid.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <stddef.h>
+
+/* Wait for a child matching PID to die.
+ If PID is greater than 0, match any process whose process ID is PID.
+ If PID is (pid_t) -1, match any process.
+ If PID is (pid_t) 0, match any process with the
+ same process group as the current process.
+ If PID is less than -1, match any process whose
+ process group is the absolute value of PID.
+ If the WNOHANG bit is set in OPTIONS, and that child
+ is not already dead, return (pid_t) 0. If successful,
+ return PID and store the dead child's status in STAT_LOC.
+ Return (pid_t) -1 for errors. If the WUNTRACED bit is set in OPTIONS,
+ return status for stopped children; otherwise don't. */
+pid_t
+DEFUN(__waitpid, (pid, stat_loc, options),
+ pid_t pid AND int *stat_loc AND int options)
+{
+ return __wait4 (pid, (union wait *) stat_loc, options, NULL);
+}
+
+weak_alias (__waitpid, waitpid)
diff --git a/sysdeps/unix/bsd/bsdstat.h b/sysdeps/unix/bsd/bsdstat.h
new file mode 100644
index 0000000..45b68b9
--- /dev/null
+++ b/sysdeps/unix/bsd/bsdstat.h
@@ -0,0 +1,112 @@
+/* Copyright (C) 1991 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. */
+
+#include "ansidecl.h"
+#include <errno.h>
+#include <stddef.h>
+#include <sys/types.h>
+
+/* This will make it not define major, minor, makedev, and S_IF*. */
+#undef __USE_BSD
+#undef __USE_MISC
+#include <sys/stat.h>
+
+#undef stat
+#undef fstat
+
+#undef S_IRWXU
+#undef S_IRUSR
+#undef S_IWUSR
+#undef S_IXUSR
+#undef S_IRWXG
+#undef S_IRGRP
+#undef S_IWGRP
+#undef S_IXGRP
+#undef S_IRWXO
+#undef S_IROTH
+#undef S_IWOTH
+#undef S_IXOTH
+#undef S_ISBLK
+#undef S_ISCHR
+#undef S_ISDIR
+#undef S_ISFIFO
+#undef S_ISREG
+#undef S_ISUID
+#undef S_ISGID
+#define stat system_stat
+#define fstat system_fstat
+#define KERNEL /* Try to avoid misc decls. */
+#include "/usr/include/sys/stat.h"
+#undef KERNEL
+#undef stat
+#undef fstat
+
+#define member_same(statbufp, sysbufp, member) \
+ (offsetof(struct __stat, member) == offsetof(struct system_stat, member) && \
+ sizeof((statbufp)->member) == sizeof((sysbufp)->member))
+#define need_stat_mapping(statbufp, sysbufp) \
+ (!(member_same(statbufp, sysbufp, st_dev) && \
+ member_same(statbufp, sysbufp, st_ino) && \
+ member_same(statbufp, sysbufp, st_mode) && \
+ member_same(statbufp, sysbufp, st_nlink) && \
+ member_same(statbufp, sysbufp, st_uid) && \
+ member_same(statbufp, sysbufp, st_gid) && \
+ member_same(statbufp, sysbufp, st_rdev) && \
+ member_same(statbufp, sysbufp, st_size) && \
+ member_same(statbufp, sysbufp, st_atime) && \
+ member_same(statbufp, sysbufp, st_mtime) && \
+ member_same(statbufp, sysbufp, st_ctime) && \
+ member_same(statbufp, sysbufp, st_blksize) && \
+ member_same(statbufp, sysbufp, st_blocks)))
+
+/* Map a system `struct stat' to our `struct stat'. */
+#ifdef __GNUC__
+inline
+#endif
+static int
+DEFUN(mapstat, (sysbuf, statbuf),
+ CONST struct system_stat *sysbuf AND struct __stat *buf)
+{
+ if (buf == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (!need_stat_mapping(buf, sysbuf))
+ /* Hopefully this will be optimized out. */
+ *buf = *(struct __stat *) sysbuf;
+ else
+ {
+ buf->st_dev = (dev_t) sysbuf->st_dev;
+ buf->st_ino = (ino_t) sysbuf->st_ino;
+ buf->st_mode = (mode_t) sysbuf->st_mode;
+ buf->st_nlink = (nlink_t) sysbuf->st_nlink;
+ buf->st_uid = (uid_t) sysbuf->st_uid;
+ buf->st_gid = (gid_t) sysbuf->st_gid;
+ buf->st_rdev = (dev_t) sysbuf->st_rdev;
+ buf->st_size = (size_t) sysbuf->st_size;
+ buf->st_atime = (time_t) sysbuf->st_atime;
+ buf->st_mtime = (time_t) sysbuf->st_mtime;
+ buf->st_ctime = (time_t) sysbuf->st_ctime;
+ buf->st_blksize = (size_t) sysbuf->st_blksize;
+ buf->st_blocks = (size_t) sysbuf->st_blocks;
+ }
+
+ return 0;
+}
diff --git a/sysdeps/unix/bsd/bsdtty.h b/sysdeps/unix/bsd/bsdtty.h
new file mode 100644
index 0000000..a1da8d5
--- /dev/null
+++ b/sysdeps/unix/bsd/bsdtty.h
@@ -0,0 +1,218 @@
+#undef B0
+#undef B50
+#undef B75
+#undef B110
+#undef B134
+#undef B150
+#undef B200
+#undef B300
+#undef B600
+#undef B1200
+#undef B1800
+#undef B2400
+#undef B4800
+#undef B9600
+#undef B19200
+#undef B38400
+#undef EXTA
+#undef EXTB
+#undef ECHO
+#undef TOSTOP
+#undef NOFLSH
+#undef MDMBUF
+#undef FLUSHO
+#undef PENDIN
+#undef CERASE
+#undef CKILL
+#undef CINTR
+#undef CQUIT
+#undef CSTART
+#undef CSTOP
+#undef CEOF
+#undef CEOT
+#undef CBRK
+#undef CSUSP
+#undef CDSUSP
+#undef CRPRNT
+#undef CFLUSH
+#undef CWERASE
+#undef CLNEXT
+#undef CSTATUS
+#undef CERASE
+#undef CKILL
+#undef CINTR
+#undef CQUIT
+#undef CSTART
+#undef CSTOP
+#undef CEOF
+#undef CEOT
+#undef CBRK
+#undef CSUSP
+#undef CDSUSP
+#undef CRPRNT
+#undef CFLUSH
+#undef CWERASE
+#undef CLNEXT
+#undef CSTATUS
+#undef CERASE
+#undef CKILL
+#undef CINTR
+#undef CQUIT
+#undef CSTART
+#undef CSTOP
+#undef CEOF
+#undef CEOT
+#undef CBRK
+#undef CSUSP
+#undef CDSUSP
+#undef CRPRNT
+#undef CFLUSH
+#undef CWERASE
+#undef CLNEXT
+#undef CSTATUS
+#undef CERASE
+#undef CKILL
+#undef CINTR
+#undef CQUIT
+#undef CSTART
+#undef CSTOP
+#undef CEOF
+#undef CEOT
+#undef CBRK
+#undef CSUSP
+#undef CDSUSP
+#undef CRPRNT
+#undef CFLUSH
+#undef CWERASE
+#undef CLNEXT
+#undef CSTATUS
+#undef CERASE
+#undef CKILL
+#undef CINTR
+#undef CQUIT
+#undef CSTART
+#undef CSTOP
+#undef CEOF
+#undef CEOT
+#undef CBRK
+#undef CSUSP
+#undef CDSUSP
+#undef CRPRNT
+#undef CFLUSH
+#undef CWERASE
+#undef CLNEXT
+#undef CSTATUS
+#undef CERASE
+#undef CKILL
+#undef CINTR
+#undef CQUIT
+#undef CSTART
+#undef CSTOP
+#undef CEOF
+#undef CEOT
+#undef CBRK
+#undef CSUSP
+#undef CDSUSP
+#undef CRPRNT
+#undef CFLUSH
+#undef CWERASE
+#undef CLNEXT
+#undef CSTATUS
+#undef CERASE
+#undef CKILL
+#undef CINTR
+#undef CQUIT
+#undef CSTART
+#undef CSTOP
+#undef CEOF
+#undef CEOT
+#undef CBRK
+#undef CSUSP
+#undef CDSUSP
+#undef CRPRNT
+#undef CFLUSH
+#undef CWERASE
+#undef CLNEXT
+#undef CSTATUS
+#undef CERASE
+#undef CKILL
+#undef CINTR
+#undef CQUIT
+#undef CSTART
+#undef CSTOP
+#undef CEOF
+#undef CEOT
+#undef CBRK
+#undef CSUSP
+#undef CDSUSP
+#undef CRPRNT
+#undef CFLUSH
+#undef CWERASE
+#undef CLNEXT
+#undef CSTATUS
+#undef CERASE
+#undef CKILL
+#undef CINTR
+#undef CQUIT
+#undef CSTART
+#undef CSTOP
+#undef CEOF
+#undef CEOT
+#undef CBRK
+#undef CSUSP
+#undef CDSUSP
+#undef CRPRNT
+#undef CFLUSH
+#undef CWERASE
+#undef CLNEXT
+#undef CSTATUS
+#undef CERASE
+#undef CKILL
+#undef CINTR
+#undef CQUIT
+#undef CSTART
+#undef CSTOP
+#undef CEOF
+#undef CEOT
+#undef CBRK
+#undef CSUSP
+#undef CDSUSP
+#undef CRPRNT
+#undef CFLUSH
+#undef CWERASE
+#undef CLNEXT
+#undef CSTATUS
+#undef CERASE
+#undef CKILL
+#undef CINTR
+#undef CQUIT
+#undef CSTART
+#undef CSTOP
+#undef CEOF
+#undef CEOT
+#undef CBRK
+#undef CSUSP
+#undef CDSUSP
+#undef CRPRNT
+#undef CFLUSH
+#undef CWERASE
+#undef CLNEXT
+#undef CSTATUS
+#undef CERASE
+#undef CKILL
+#undef CINTR
+#undef CQUIT
+#undef CSTART
+#undef CSTOP
+#undef CEOF
+#undef CEOT
+#undef CBRK
+#undef CSUSP
+#undef CDSUSP
+#undef CRPRNT
+#undef CFLUSH
+#undef CWERASE
+#undef CLNEXT
+#undef CSTATUS
+
+#include <sys/ioctl.h>
diff --git a/sysdeps/unix/bsd/clock.c b/sysdeps/unix/bsd/clock.c
new file mode 100644
index 0000000..2c3e028
--- /dev/null
+++ b/sysdeps/unix/bsd/clock.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <sys/resource.h>
+#include <time.h>
+#include <sys/time.h>
+
+#ifdef __GNUC__
+__inline
+#endif
+static clock_t
+DEFUN(timeval_to_clock_t, (tv), CONST struct timeval *tv)
+{
+ return (clock_t) ((tv->tv_sec * CLK_TCK) +
+ (tv->tv_usec * CLK_TCK / 1000));
+}
+
+/* Return the time used by the program so far (user time + system time). */
+clock_t
+DEFUN_VOID(clock)
+{
+ struct rusage usage;
+
+ if (__getrusage(RUSAGE_SELF, &usage) < 0)
+ return (clock_t) -1;
+
+ return (timeval_to_clock_t(&usage.ru_stime) +
+ timeval_to_clock_t(&usage.ru_utime)) * CLOCKS_PER_SEC;
+}
diff --git a/sysdeps/unix/bsd/confstr.h b/sysdeps/unix/bsd/confstr.h
new file mode 100644
index 0000000..befefb6
--- /dev/null
+++ b/sysdeps/unix/bsd/confstr.h
@@ -0,0 +1 @@
+#define CS_PATH "/usr/ucb:/bin:/usr/bin"
diff --git a/sysdeps/unix/bsd/direct.h b/sysdeps/unix/bsd/direct.h
new file mode 100644
index 0000000..d663bbb
--- /dev/null
+++ b/sysdeps/unix/bsd/direct.h
@@ -0,0 +1,13 @@
+#ifndef MAXNAMLEN
+#define MAXNAMLEN 255
+#endif
+
+struct direct
+ {
+ unsigned int d_fileno; /* 32 bits. */
+ unsigned short int d_reclen; /* 16 bits. */
+ unsigned short int d_namlen; /* 16 bits. */
+ char d_name[MAXNAMLEN + 1];
+ };
+
+#define D_NAMLEN(d) ((d)->d_namlen)
diff --git a/sysdeps/unix/bsd/dirstream.h b/sysdeps/unix/bsd/dirstream.h
new file mode 100644
index 0000000..f3bf9ca
--- /dev/null
+++ b/sysdeps/unix/bsd/dirstream.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 1993, 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. */
+
+#ifndef _DIRSTREAM_H
+
+#define _DIRSTREAM_H 1
+
+#define __need_size_t
+#include <stddef.h>
+#include <gnu/types.h> /* For __off_t. */
+
+/* Directory stream type.
+
+ The BSD directory format is the same as `struct dirent', so `readdir'
+ returns a pointer into the buffer we read directory data into. */
+
+typedef struct
+ {
+ int __fd; /* File descriptor. */
+
+ char *__data; /* Directory block. */
+ size_t __allocation; /* Space allocated for the block. */
+ size_t __offset; /* Current offset into the block. */
+ size_t __size; /* Total valid data in the block. */
+ __off_t __pos; /* Position in directory of this block. */
+ } DIR;
+
+#ifdef __USE_BSD
+/* Macro to return the file descriptor used for an open directory. */
+#define dirfd(DIR) ((DIR)->__fd)
+#endif
+
+#endif /* dirstream.h */
diff --git a/sysdeps/unix/bsd/fcntlbits.h b/sysdeps/unix/bsd/fcntlbits.h
new file mode 100644
index 0000000..dd8b2a9
--- /dev/null
+++ b/sysdeps/unix/bsd/fcntlbits.h
@@ -0,0 +1,117 @@
+/* O_*, F_*, FD_* bit values for 4.3 BSD.
+Copyright (C) 1991, 1992 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 _FCNTLBITS_H
+
+#define _FCNTLBITS_H 1
+
+
+/* File access modes for `open' and `fcntl'. */
+#define O_RDONLY 0 /* Open read-only. */
+#define O_WRONLY 1 /* Open write-only. */
+#define O_RDWR 2 /* Open read/write. */
+
+
+/* Bits OR'd into the second argument to open. */
+#define O_CREAT 0x0200 /* Create file if it doesn't exist. */
+#define O_EXCL 0x0800 /* Fail if file already exists. */
+#define O_TRUNC 0x0400 /* Truncate file to zero length. */
+/* Apparently not assigning a controlling terminal is the default
+ behavior in BSD, so no bit is required to request that behavior. */
+#define O_NOCTTY 0 /* Don't assign a controlling terminal. */
+#if defined (__USE_BSD) || defined (__USE_SVID)
+#define O_ASYNC 0x0040 /* Send SIGIO to owner when data is ready. */
+#define O_FSYNC 0x2000 /* Synchronous writes. */
+#define O_SYNC O_FSYNC
+#endif
+
+/* File status flags for `open' and `fcntl'. */
+#define O_APPEND 0x0008 /* Writes append to the file. */
+#define O_NONBLOCK 0x0004 /* Non-blocking I/O. */
+
+#ifdef __USE_BSD
+/* BSD before 4.4 doesn't support POSIX.1 O_NONBLOCK,
+ but O_NDELAY is close. */
+#define O_NDELAY O_NONBLOCK
+#endif
+
+#ifdef __USE_BSD
+/* Bits in the file status flags returned by F_GETFL.
+ These are all the O_* flags, plus FREAD and FWRITE, which are
+ independent bits set by which of O_RDONLY, O_WRONLY, and O_RDWR, was
+ given to `open'. */
+#define FREAD 1
+#define FWRITE 2
+
+/* Traditional BSD names the O_* bits. */
+#define FASYNC O_ASYNC
+#define FCREAT O_CREAT
+#define FEXCL O_EXCL
+#define FTRUNC O_TRUNC
+#define FNOCTTY O_NOCTTY
+#define FFSYNC O_FSYNC
+#define FSYNC O_SYNC
+#define FAPPEND O_APPEND
+#define FNONBLOCK O_NONBLOCK
+#define FNDELAY O_NDELAY
+#endif
+
+/* Mask for file access modes. This is system-dependent in case
+ some system ever wants to define some other flavor of access. */
+#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
+
+/* Values for the second argument to `fcntl'. */
+#define F_DUPFD 0 /* Duplicate file descriptor. */
+#define F_GETFD 1 /* Get file descriptor flags. */
+#define F_SETFD 2 /* Set file descriptor flags. */
+#define F_GETFL 3 /* Get file status flags. */
+#define F_SETFL 4 /* Set file status flags. */
+#ifdef __USE_BSD
+#define F_GETOWN 5 /* Get owner (receiver of SIGIO). */
+#define F_SETOWN 6 /* Set owner (receiver of SIGIO). */
+#endif
+#define F_GETLK 7 /* Get record locking info. */
+#define F_SETLK 8 /* Set record locking info (non-blocking). */
+#define F_SETLKW 9 /* Set record locking info (blocking). */
+
+/* File descriptor flags used with F_GETFD and F_SETFD. */
+#define FD_CLOEXEC 1 /* Close on exec. */
+
+
+#include <gnu/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. */
+struct flock
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+ short int l_pid; /* Process holding the lock. */
+ short int l_xxx; /* Reserved for future use. */
+ };
+
+/* Values for the `l_type' field of a `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/flock.S b/sysdeps/unix/bsd/flock.S
new file mode 100644
index 0000000..6d72f62
--- /dev/null
+++ b/sysdeps/unix/bsd/flock.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (flock, 2)
+ ret
+
+weak_alias (__flock, flock)
diff --git a/sysdeps/unix/bsd/ftime.c b/sysdeps/unix/bsd/ftime.c
new file mode 100644
index 0000000..66c9ac2
--- /dev/null
+++ b/sysdeps/unix/bsd/ftime.c
@@ -0,0 +1,37 @@
+/* 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. */
+
+#include <sys/timeb.h>
+#include <sys/time.h>
+
+int
+ftime (timebuf)
+ struct timeb *timebuf;
+{
+ struct timeval tv;
+ struct timezone tz;
+
+ if (__gettimeofday (&tv, &tz) < 0)
+ return -1;
+
+ timebuf->time = tv.tv_sec;
+ timebuf->millitm = (tv.tv_usec + 999) / 1000;
+ timebuf->timezone = tz.tz_minuteswest;
+ timebuf->dstflag = tz.tz_dsttime;
+ return 0;
+}
diff --git a/sysdeps/unix/bsd/getdtsz.S b/sysdeps/unix/bsd/getdtsz.S
new file mode 100644
index 0000000..fbba806
--- /dev/null
+++ b/sysdeps/unix/bsd/getdtsz.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (getdtablesize, 0)
+ ret
+
+weak_alias (__getdtablesize, getdtablesize)
diff --git a/sysdeps/unix/bsd/getpagesize.S b/sysdeps/unix/bsd/getpagesize.S
new file mode 100644
index 0000000..16232f0
--- /dev/null
+++ b/sysdeps/unix/bsd/getpagesize.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (getpagesize, 0)
+ ret
+
+weak_alias (__getpagesize, getpagesize)
diff --git a/sysdeps/unix/bsd/gtty.c b/sysdeps/unix/bsd/gtty.c
new file mode 100644
index 0000000..a5bdb10
--- /dev/null
+++ b/sysdeps/unix/bsd/gtty.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sgtty.h>
+
+/* Fill in *PARAMS with terminal parameters associated with FD. */
+int
+DEFUN(gtty, (fd, params),
+ int fd AND struct sgttyb *params)
+{
+ return ioctl(fd, TIOCGETP, (PTR) params);
+}
diff --git a/sysdeps/unix/bsd/hp/m68k/brk.S b/sysdeps/unix/bsd/hp/m68k/brk.S
new file mode 100644
index 0000000..cf46b4d
--- /dev/null
+++ b/sysdeps/unix/bsd/hp/m68k/brk.S
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991, 1993, 1994, 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. */
+
+#include <sysdep.h>
+
+#ifndef SYS_brk
+#define SYS_brk 17
+#endif
+
+#ifndef HAVE_GNU_LD
+#define __end _end
+#endif
+
+.data
+.globl ___curbrk
+___curbrk:
+ .long __end
+
+.text
+ENTRY (__brk)
+ movel #__end, d0
+ cmpl sp@(4), d0
+ ble 0f
+ movel d0, sp@(4)
+0: DO_CALL (#SYS_brk, 1)
+ movel sp@(4), ___curbrk
+ clrl d0
+ rts
+error: jmp syscall_error
+
+weak_alias (__brk, brk)
diff --git a/sysdeps/unix/bsd/hp/m68k/getdents.S b/sysdeps/unix/bsd/hp/m68k/getdents.S
new file mode 100644
index 0000000..be449b2
--- /dev/null
+++ b/sysdeps/unix/bsd/hp/m68k/getdents.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/sun/getdents.S>
diff --git a/sysdeps/unix/bsd/hp/m68k/start.c b/sysdeps/unix/bsd/hp/m68k/start.c
new file mode 100644
index 0000000..e04ca06
--- /dev/null
+++ b/sysdeps/unix/bsd/hp/m68k/start.c
@@ -0,0 +1,10 @@
+/* hp300 4.3 BSD starts at 4, rather than 0, when the start address is 0.
+ Go figure. */
+asm(".globl __start");
+asm("__start: .long 0");
+
+#define _start __start0
+
+#define DUMMIES dummy0
+
+#include <sysdeps/unix/start.c>
diff --git a/sysdeps/unix/bsd/hp/m68k/sysdep.h b/sysdeps/unix/bsd/hp/m68k/sysdep.h
new file mode 100644
index 0000000..3487ab2
--- /dev/null
+++ b/sysdeps/unix/bsd/hp/m68k/sysdep.h
@@ -0,0 +1,56 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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 code wants to be run through m4. */
+
+#include <sysdeps/unix/sysdep.h>
+
+#ifdef ASSEMBLER
+
+#define POUND #
+
+#ifdef __STDC__
+#define ENTRY(name) \
+ .globl _##name; \
+ .even; \
+ _##name##:
+#else
+#define ENTRY(name) \
+ .globl _/**/name; \
+ .even; \
+ _/**/name/**/:
+#endif
+
+#define PSEUDO(name, syscall_name, args) \
+ .even; \
+ .globl syscall_error; \
+ error: jmp syscall_error; \
+ ENTRY (name) \
+ DO_CALL (POUND SYS_ify (syscall_name), args)
+
+#define DO_CALL(syscall, args) \
+ movel syscall, d0; \
+ trap POUND 0; \
+ bcs error
+
+#define ret rts
+#define r0 d0
+#define r1 d1
+#define MOVE(x,y) movel x , y
+
+#endif /* ASSEMBLER */
diff --git a/sysdeps/unix/bsd/hp/m68k/wait3.S b/sysdeps/unix/bsd/hp/m68k/wait3.S
new file mode 100644
index 0000000..d0e7585
--- /dev/null
+++ b/sysdeps/unix/bsd/hp/m68k/wait3.S
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+ENTRY(__wait3)
+ movel sp@(8), d1
+ moveal sp@(12), a0
+ movel #SYS_wait, d0
+ /* Set all condition codes to tell the kernel this is wait3. */
+ movew #31, ccr
+ trap #0
+ bcs error
+
+ tstl sp@(4)
+ beq 1f
+ moveal sp@(4), a0
+ movel d1, a0@
+1: rts
+
+.globl syscall_error
+error: jmp syscall_error
+
+weak_alias (__wait3, wait3)
diff --git a/sysdeps/unix/bsd/i386/wait3.S b/sysdeps/unix/bsd/i386/wait3.S
new file mode 100644
index 0000000..c54417b
--- /dev/null
+++ b/sysdeps/unix/bsd/i386/wait3.S
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <sysdep.h>
+
+/* <sysdeps/unix/bsd/sequent/i386/sysdep.h> defines this to put the first
+ two arguments into registers. Since the arguments to wait3 are
+ transferred magically through the same registers, we want to disable this.
+ This allows us to avoid rewriting this file for that system. */
+
+#undef ARGS_2
+#define ARGS_2 /* Special-case no-op. */
+
+.text
+.globl syscall_error
+.align 4
+ENTRY (__wait3)
+ mov 8(%esp), %ecx /* Flags. */
+ mov 12(%esp), %edx /* rusage pointer. */
+ pushl $0xdf; popf /* Set all the condition codes. */
+ DO_CALL (wait, 2) /* Do the system call. */
+ je syscall_error /* Check for error. */
+ mov 4(%esp), scratch /* Status pointer. */
+ orl scratch, scratch /* Is it nil? */
+ je done /* Yup; return. */
+ mov r1, 0(scratch) /* Non-nil; store the status in it. */
+done: ret
+
+weak_alias (__wait3, wait3)
diff --git a/sysdeps/unix/bsd/init-posix.c b/sysdeps/unix/bsd/init-posix.c
new file mode 100644
index 0000000..a3b2ee1
--- /dev/null
+++ b/sysdeps/unix/bsd/init-posix.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991, 1994, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <time.h>
+
+/* This must be initialized data or its presence will not be sufficient to
+ merit linkage of this file, which is necessary for the real
+ initialization function below to be called. */
+time_t _posix_start_time = -1;
+
+void
+DEFUN_VOID(__init_posix)
+{
+ _posix_start_time = time((time_t *) NULL);
+}
+
+#ifdef HAVE_GNU_LD
+text_set_element(__libc_subinit, __init_posix);
+#endif
diff --git a/sysdeps/unix/bsd/isatty.c b/sysdeps/unix/bsd/isatty.c
new file mode 100644
index 0000000..c3e80eb
--- /dev/null
+++ b/sysdeps/unix/bsd/isatty.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+
+/* Return 1 if FD is a terminal, 0 if not. */
+int
+DEFUN(__isatty, (fd), int fd)
+{
+ int save;
+ int is_tty;
+ struct sgttyb term;
+
+ save = errno;
+ is_tty = __ioctl (fd, TIOCGETP, &term) == 0;
+ errno = save;
+
+ return is_tty;
+}
+
+weak_alias (__isatty, isatty)
diff --git a/sysdeps/unix/bsd/killpg.S b/sysdeps/unix/bsd/killpg.S
new file mode 100644
index 0000000..7ce0f49
--- /dev/null
+++ b/sysdeps/unix/bsd/killpg.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (killpg, 2)
+ ret
diff --git a/sysdeps/unix/bsd/m68k/pipe.S b/sysdeps/unix/bsd/m68k/pipe.S
new file mode 100644
index 0000000..633d18f
--- /dev/null
+++ b/sysdeps/unix/bsd/m68k/pipe.S
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (pipe, 1)
+#ifdef __motorola__
+ move.l 4(sp), a0
+ movem.l d0-d1, (a0)
+#else
+ movel sp@(4), a0
+ moveml d0-d1, a0@
+#endif
+ clrl d0
+ rts
+
+weak_alias (__pipe, pipe)
diff --git a/sysdeps/unix/bsd/m68k/start.c b/sysdeps/unix/bsd/m68k/start.c
new file mode 100644
index 0000000..1067853
--- /dev/null
+++ b/sysdeps/unix/bsd/m68k/start.c
@@ -0,0 +1,3 @@
+#define DUMMIES ignore0
+
+#include <sysdeps/unix/start.c>
diff --git a/sysdeps/unix/bsd/m68k/syscall.S b/sysdeps/unix/bsd/m68k/syscall.S
new file mode 100644
index 0000000..18ef815
--- /dev/null
+++ b/sysdeps/unix/bsd/m68k/syscall.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1993 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. */
+
+#include <sysdep.h>
+
+ENTRY (syscall)
+ movel sp@+, a0 /* Pop return address into A0. */
+ DO_CALL (sp@, 0) /* Do system call. */
+ jmp a0@ /* Return to A0. */
+error: movel a0, sp@- /* Error; push return address */
+ jmp syscall_error /* and jump to error handler. */
diff --git a/sysdeps/unix/bsd/m68k/sysdep.S b/sysdeps/unix/bsd/m68k/sysdep.S
new file mode 100644
index 0000000..cef8990
--- /dev/null
+++ b/sysdeps/unix/bsd/m68k/sysdep.S
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#define _ERRNO_H
+#include <errnos.h>
+
+.globl syscall_error
+syscall_error:
+ /* We translate the system's EWOULDBLOCK error into EAGAIN.
+ The GNU C library always defines EWOULDBLOCK==EAGAIN.
+ EWOULDBLOCK_sys is the original number. */
+#ifdef __motorola__
+#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
+ cmp.l #EWOULDBLOCK_sys, d0
+ bne store
+ moveq.l #EAGAIN, d0
+#endif
+store: move.l d0, _errno
+ moveq.l #-1, d0
+#else
+#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
+ cmpl #EWOULDBLOCK_sys, d0
+ bne store
+ moveq #EAGAIN, d0
+#endif
+store: movel d0, _errno
+ moveq #-1, d0
+#endif
+ rts
diff --git a/sysdeps/unix/bsd/m68k/wait.S b/sysdeps/unix/bsd/m68k/wait.S
new file mode 100644
index 0000000..c7685b7
--- /dev/null
+++ b/sysdeps/unix/bsd/m68k/wait.S
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (wait, 1)
+#ifdef __motorola__
+ tst.l 4(sp)
+ beq 1f
+ movea.l 4(sp), a0
+ move.l d1, (a0)
+#else
+ tstl sp@(4)
+ beq 1f
+ moveal sp@(4), a0
+ movel d1, a0@
+#endif
+1: rts
+
+weak_alias (__wait, wait)
diff --git a/sysdeps/unix/bsd/nice.c b/sysdeps/unix/bsd/nice.c
new file mode 100644
index 0000000..01f1412
--- /dev/null
+++ b/sysdeps/unix/bsd/nice.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/resource.h>
+
+/* Increment the scheduling priority of the calling process by INCR.
+ The superuser may use a negative INCR to decrement the priority. */
+int
+DEFUN(nice, (incr), int incr)
+{
+ int save;
+ int prio;
+
+ /* -1 is a valid priority, so we use errno to check for an error. */
+ save = errno;
+ errno = 0;
+ prio = getpriority (PRIO_PROCESS, 0);
+ if (prio == -1)
+ {
+ if (errno != 0)
+ return -1;
+ else
+ errno = save;
+ }
+
+ return setpriority (PRIO_PROCESS, 0, prio + incr);
+}
diff --git a/sysdeps/unix/bsd/pause.c b/sysdeps/unix/bsd/pause.c
new file mode 100644
index 0000000..b2fafb9
--- /dev/null
+++ b/sysdeps/unix/bsd/pause.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <signal.h>
+#include <unistd.h>
+
+
+/* Suspend the process until a signal arrives.
+ This always returns -1 and sets errno to EINTR. */
+
+int
+DEFUN_VOID(pause)
+{
+ return __sigpause(__sigblock(0));
+}
diff --git a/sysdeps/unix/bsd/poll.c b/sysdeps/unix/bsd/poll.c
new file mode 100644
index 0000000..4797ee0
--- /dev/null
+++ b/sysdeps/unix/bsd/poll.c
@@ -0,0 +1,81 @@
+/* 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. */
+
+#include <sys/poll.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/time.h>
+
+/* Poll the file descriptors described by the NFDS structures starting at
+ FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
+ an event to occur; if TIMEOUT is -1, block until an event occurs.
+ Returns the number of file descriptors with events, zero if timed out,
+ or -1 for errors. */
+
+int
+poll (fds, nfds, timeout)
+ struct pollfd *fds;
+ unsigned long int nfds;
+ int timeout;
+{
+ struct timeval tv;
+ fd_set rset, wset, xset;
+ struct pollfd *f;
+ int ready;
+ int maxfd = 0;
+
+ FD_ZERO (&rset);
+ FD_ZERO (&wset);
+ FD_ZERO (&xset);
+
+ for (f = fds; f < &fds[nfds]; ++f)
+ if (f->fd >= 0)
+ {
+ if (f->events & POLLIN)
+ FD_SET (f->fd, &rset);
+ if (f->events & POLLOUT)
+ FD_SET (f->fd, &wset);
+ if (f->events & POLLPRI)
+ FD_SET (f->fd, &xset);
+ if (f->fd > maxfd && (f->events & (POLLIN|POLLOUT|POLLPRI)))
+ maxfd = f->fd;
+ }
+
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout + 999) / 1000;
+
+ ready = __select (maxfd + 1, &rset, &wset, &xset,
+ timeout == -1 ? NULL : &tv);
+ if (ready > 0)
+ for (f = fds; f < &fds[nfds]; ++f)
+ {
+ f->revents = 0;
+ if (f->fd >= 0)
+ {
+ if (FD_ISSET (f->fd, &rset))
+ f->revents |= POLLIN;
+ if (FD_ISSET (f->fd, &wset))
+ f->revents |= POLLOUT;
+ if (FD_ISSET (f->fd, &xset))
+ f->revents |= POLLPRI;
+ }
+ }
+
+ return ready;
+}
diff --git a/sysdeps/unix/bsd/posix_opt.h b/sysdeps/unix/bsd/posix_opt.h
new file mode 100644
index 0000000..7d5e578
--- /dev/null
+++ b/sysdeps/unix/bsd/posix_opt.h
@@ -0,0 +1,5 @@
+#define _POSIX_JOB_CONTROL 1
+#undef _POSIX_SAVED_IDS
+#define _POSIX_CHOWN_RESTRICTED 1
+#define _POSIX_NO_TRUNC -1
+#define _POSIX_VDISABLE ((unsigned char) -1)
diff --git a/sysdeps/unix/bsd/readdir.c b/sysdeps/unix/bsd/readdir.c
new file mode 100644
index 0000000..e86a94d
--- /dev/null
+++ b/sysdeps/unix/bsd/readdir.c
@@ -0,0 +1,70 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <limits.h>
+#include <stddef.h>
+#include <string.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include "direct.h"
+
+
+/* Read a directory entry from DIRP. */
+struct dirent *
+DEFUN(readdir, (dirp), DIR *dirp)
+{
+ struct dirent *dp;
+
+ if (dirp == NULL || dirp->__data == NULL)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ do
+ {
+ if (dirp->__offset >= dirp->__size)
+ {
+ /* We've emptied out our buffer. Refill it. */
+
+ ssize_t bytes = __getdirentries (dirp->__fd, dirp->__data,
+ dirp->__allocation, &dirp->__pos);
+ if (bytes <= 0)
+ return NULL;
+ dirp->__size = (size_t) bytes;
+
+ /* Reset the offset into the buffer. */
+ dirp->__offset = 0;
+ }
+
+ dp = (struct dirent *) &dirp->__data[dirp->__offset];
+ dirp->__offset += dp->d_reclen;
+
+#ifndef HAVE_D_TYPE
+ dp->d_namlen = ((struct direct *) dp)->d_namlen;
+ dp->d_type = DT_UNKNOWN;
+#endif
+
+ /* Loop to ignore deleted files. */
+ } while (dp->d_fileno == 0);
+
+ return dp;
+}
diff --git a/sysdeps/unix/bsd/seekdir.c b/sysdeps/unix/bsd/seekdir.c
new file mode 100644
index 0000000..4d244f5
--- /dev/null
+++ b/sysdeps/unix/bsd/seekdir.c
@@ -0,0 +1 @@
+/* Because they share a private data structure, seekdir is in telldir.c. */
diff --git a/sysdeps/unix/bsd/sequent/i386/getgroups.S b/sysdeps/unix/bsd/sequent/i386/getgroups.S
new file mode 100644
index 0000000..b68bcbd
--- /dev/null
+++ b/sysdeps/unix/bsd/sequent/i386/getgroups.S
@@ -0,0 +1,44 @@
+/* Copyright (C) 1994, 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. */
+
+#include <sysdep.h>
+#include <limits.h>
+
+/* Dynix erroneously reports `getgroups (0, 0)' as an error.
+ We fix up for that case. */
+
+#define syscall_error myerror
+SYSCALL__ (getgroups, 2)
+#undef syscall_error
+ ret
+myerror:
+ tstl 4(%esp) /* Was the first arg 0? */
+ jnz syscall_error /* If not, go to the normal error case. */
+ /* When called with (0, 0), we want to return the number of groups
+ without storing anything. The Dynix system call gives an error
+ for this case, so we fix up by calling it with a local array we
+ never use, and just use the return value. */
+ subl %esp, $(NGROUPS_MAX * 4) /* Allocate a local array. */
+ movl $NGROUPS_MAX, %ecx /* Pass NGROUPS_MAX for first arg. */
+ movl %esp, %edx /* Pass local array for second arg. */
+ DO_CALL (getgroups, 2) /* Do the system call. */
+ addl %esp, $(NGROUPS_MAX * 4) /* Pop the local array. */
+ jb syscall_error /* Check for error from the system call. */
+ ret /* Return its value. */
+
+weak_alias (__getgroups, getgroups)
diff --git a/sysdeps/unix/bsd/sequent/i386/sigvec.S b/sysdeps/unix/bsd/sequent/i386/sigvec.S
new file mode 100644
index 0000000..1bb57c2
--- /dev/null
+++ b/sysdeps/unix/bsd/sequent/i386/sigvec.S
@@ -0,0 +1,45 @@
+/* Copyright (C) 1993, 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. */
+
+#include <sysdep.h>
+
+/* The Dynix `sigvec' system call takes an extra argument,
+ which is the address of the trampoline function. */
+
+.text
+.align 4
+trampoline:
+ cld /* Clear direction flag. */
+ call %eax /* Call the handler, address in %eax. */
+ addl $8, %esp /* Pop signum & code off the stack. */
+ /* __sigreturn will restore the context, and never return here. */
+ call C_SYMBOL_NAME (__sigreturn)
+
+.globl syscall_error
+ENTRY (__sigvec)
+ pushl $trampoline /* Push fourth arg: trampoline address. */
+ pushl 16(%esp) /* Push third arg: our third arg. */
+ pushl 16(%esp) /* Push second arg: our second arg. */
+ pushl 16(%esp) /* Push first arg: our first arg. */
+ mov %esp, %ecx /* Point the syscall at the arguments. */
+ addl $16, %esp /* Pop those four args. */
+ DO_CALL (sigvec, 4) /* Do the system call. */
+ jb syscall_error /* Check for error. */
+ ret
+
+weak_alias (__sigvec, sigvec)
diff --git a/sysdeps/unix/bsd/sequent/i386/syscall.S b/sysdeps/unix/bsd/sequent/i386/syscall.S
new file mode 100644
index 0000000..bebab8e
--- /dev/null
+++ b/sysdeps/unix/bsd/sequent/i386/syscall.S
@@ -0,0 +1,31 @@
+/* `syscall' function for Sequent Symmetry running Dynix version 3.
+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. */
+
+#include <sysdep.h>
+
+.text
+.globl syscall_error
+.align 4
+ENTRY (syscall)
+ leal 8(%esp), %ecx /* Load address of second argument. */
+ movl $SYS_HANDLER, %eax /* Use BSD system calls. */
+ movw 4(%esp), %ax /* Load system call number into low word. */
+ int $T_SVC6 /* Pretend it takes six args. */
+ jb syscall_error
+ ret
diff --git a/sysdeps/unix/bsd/sequent/i386/sysdep.h b/sysdeps/unix/bsd/sequent/i386/sysdep.h
new file mode 100644
index 0000000..f1365e7
--- /dev/null
+++ b/sysdeps/unix/bsd/sequent/i386/sysdep.h
@@ -0,0 +1,82 @@
+/* System call interface code for Sequent Symmetry running Dynix version 3.
+Copyright (C) 1993, 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. */
+
+#include <sysdeps/unix/i386/sysdep.h>
+
+#ifdef ASSEMBLER
+
+/* Get the symbols for system call interrupts. */
+#include <machine/trap.h>
+
+/* Use the BSD versions of system calls, by setting the high 16 bits
+ of the syscall number (see /usr/include/syscall.h). */
+#define SYS_HANDLER (SYS_bsd << 16)
+
+/* Dynix uses an interrupt interface to system calls.
+ "int $T_SVCn" are syscall interfaces for 0-6 arg functions.
+ (see /usr/include/machine/trap.h). */
+
+#undef DO_CALL
+
+#ifdef __STDC__
+#define DO_CALL(syscall_name, args) \
+ movl $(SYS_HANDLER | SYS_##syscall_name), %eax; \
+ int $T_SVC##args;
+#else
+#define DO_CALL(syscall_name, args) \
+ movl $(SYS_HANDLER | SYS_/**/syscall_name), %eax; \
+ int $T_SVC/**/args;
+#endif
+
+#undef PSEUDO
+#define PSEUDO(name, syscall_name, args) \
+ .text; \
+ .globl syscall_error; \
+ .align 4; \
+ ENTRY (name) \
+ ARGS (args) \
+ DO_CALL (syscall_name, args) \
+ jb syscall_error
+
+/* For one and two-argument calls, Dynix takes the arguments in %ecx and
+ %edx. For 3-6 argument calls, Dynix takes the address of the first
+ argument in %ecx. */
+
+#ifdef __STDC__
+#define ARGS(n) ARGS_##n
+#else
+#define ARGS(n) ARGS_/**/n
+#endif
+
+#define ARGS_0
+#define ARGS_1 movl 4(%esp), %ecx;
+#define ARGS_2 movl 4(%esp), %ecx; movl 8(%esp), %edx;
+#define ARGS_3 leal 4(%esp), %ecx;
+#define ARGS_4 ARGS_3
+#define ARGS_5 ARGS_3
+#define ARGS_6 ARGS_3
+
+/* Dynix reverses %ecx and %edx relative to most i386 Unices. */
+
+#undef r1
+#define r1 %ecx /* Secondary return-value register. */
+#undef scratch
+#define scratch %edx /* Call-clobbered register for random use. */
+
+#endif /* ASSEMBLER */
diff --git a/sysdeps/unix/bsd/setegid.c b/sysdeps/unix/bsd/setegid.c
new file mode 100644
index 0000000..85ebea2
--- /dev/null
+++ b/sysdeps/unix/bsd/setegid.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+int
+DEFUN(setegid, (gid), gid_t gid)
+{
+ return __setregid (-1, gid);
+}
diff --git a/sysdeps/unix/bsd/seteuid.c b/sysdeps/unix/bsd/seteuid.c
new file mode 100644
index 0000000..a4be2d9
--- /dev/null
+++ b/sysdeps/unix/bsd/seteuid.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+int
+DEFUN(seteuid, (uid), uid_t uid)
+{
+ return __setreuid (-1, uid);
+}
diff --git a/sysdeps/unix/bsd/setgid.c b/sysdeps/unix/bsd/setgid.c
new file mode 100644
index 0000000..aa6c4de
--- /dev/null
+++ b/sysdeps/unix/bsd/setgid.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <sysdep.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Set the group ID of the calling process to GID.
+ If the calling process is the super-user, the real
+ and effective group IDs, and the saved set-group-ID to GID;
+ if not, the effective group ID is set to GID. */
+int
+DEFUN(__setgid, (gid), gid_t gid)
+{
+ return __setregid (gid, gid);
+}
+
+weak_alias (__setgid, setgid)
diff --git a/sysdeps/unix/bsd/setrgid.c b/sysdeps/unix/bsd/setrgid.c
new file mode 100644
index 0000000..8a421b7
--- /dev/null
+++ b/sysdeps/unix/bsd/setrgid.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+int
+DEFUN(setrgid, (gid), gid_t gid)
+{
+ return __setregid (gid, -1);
+}
diff --git a/sysdeps/unix/bsd/setruid.c b/sysdeps/unix/bsd/setruid.c
new file mode 100644
index 0000000..320b927
--- /dev/null
+++ b/sysdeps/unix/bsd/setruid.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+int
+DEFUN(setruid, (uid), uid_t uid)
+{
+ return __setreuid (uid, -1);
+}
diff --git a/sysdeps/unix/bsd/setsid.c b/sysdeps/unix/bsd/setsid.c
new file mode 100644
index 0000000..5959410
--- /dev/null
+++ b/sysdeps/unix/bsd/setsid.c
@@ -0,0 +1,59 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+/* Create a new session with the calling process as its leader.
+ The process group IDs of the session and the calling process
+ are set to the process ID of the calling process, which is returned. */
+int
+DEFUN_VOID(__setsid)
+{
+ pid_t pid = getpid ();
+ int tty;
+ int save = errno;
+
+ if (__getpgrp (pid) == pid)
+ {
+ /* Already the leader. */
+ errno = EPERM;
+ return -1;
+ }
+
+ if (setpgid (pid, pid) < 0)
+ return -1;
+
+ tty = open ("/dev/tty", 0);
+ if (tty < 0)
+ {
+ errno = save;
+ return 0;
+ }
+ (void) __ioctl (tty, TIOCNOTTY, 0);
+ (void) __close (tty);
+
+ errno = save;
+ return 0;
+}
+
+weak_alias (__setsid, setsid)
diff --git a/sysdeps/unix/bsd/settimeofday.S b/sysdeps/unix/bsd/settimeofday.S
new file mode 100644
index 0000000..2dcf18d
--- /dev/null
+++ b/sysdeps/unix/bsd/settimeofday.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (settimeofday, 2)
+ ret
+
+weak_alias (__settimeofday, settimeofday)
diff --git a/sysdeps/unix/bsd/setuid.c b/sysdeps/unix/bsd/setuid.c
new file mode 100644
index 0000000..ed68cd0
--- /dev/null
+++ b/sysdeps/unix/bsd/setuid.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 1993, 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. */
+
+#include <ansidecl.h>
+#include <sysdep.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Set the user ID of the calling process to UID.
+ If the calling process is the super-user, the real
+ and effective user IDs, and the saved set-user-ID to UID;
+ if not, the effective user ID is set to UID. */
+int
+DEFUN(__setuid, (uid), uid_t uid)
+{
+ return __setreuid (uid, uid);
+}
+
+weak_alias (__setuid, setuid)
diff --git a/sysdeps/unix/bsd/sigaction.c b/sysdeps/unix/bsd/sigaction.c
new file mode 100644
index 0000000..aa1c53f
--- /dev/null
+++ b/sysdeps/unix/bsd/sigaction.c
@@ -0,0 +1,62 @@
+/* Copyright (C) 1991, 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. */
+
+#include <ansidecl.h>
+#include <sysdep.h>
+#include <errno.h>
+#include <stddef.h>
+#include <signal.h>
+
+
+/* If ACT is not NULL, change the action for SIG to *ACT.
+ If OACT is not NULL, put the old action for SIG in *OACT. */
+int
+DEFUN(__sigaction, (sig, act, oact),
+ int sig AND CONST struct sigaction *act AND struct sigaction *oact)
+{
+ struct sigvec vec, ovec;
+
+ if (sig <= 0 || sig >= NSIG)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (act != NULL)
+ {
+ vec.sv_mask = act->sa_mask;
+ vec.sv_handler = act->sa_handler;
+ vec.sv_flags = (((act->sa_flags & SA_ONSTACK) ? SV_ONSTACK : 0) |
+ (!(act->sa_flags & SA_RESTART) ? SV_INTERRUPT : 0));
+ }
+
+ if (__sigvec(sig, act != NULL ? &vec : (struct sigvec *) NULL, &ovec) < 0)
+ return -1;
+
+ if (oact != NULL)
+ {
+ oact->sa_handler = (void EXFUN((*), (int))) ovec.sv_handler;
+ oact->sa_mask = ovec.sv_mask;
+ oact->sa_flags = (((ovec.sv_flags & SV_ONSTACK) ? SA_ONSTACK : 0) |
+ (!(ovec.sv_flags & SV_INTERRUPT) ? SA_RESTART : 0));
+ }
+
+ return 0;
+}
+
+weak_alias (__sigaction, sigaction)
diff --git a/sysdeps/unix/bsd/sigblock.S b/sysdeps/unix/bsd/sigblock.S
new file mode 100644
index 0000000..26fc674
--- /dev/null
+++ b/sysdeps/unix/bsd/sigblock.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (sigblock, 1)
+ ret
+
+weak_alias (__sigblock, sigblock)
diff --git a/sysdeps/unix/bsd/signum.h b/sysdeps/unix/bsd/signum.h
new file mode 100644
index 0000000..ebbae18
--- /dev/null
+++ b/sysdeps/unix/bsd/signum.h
@@ -0,0 +1,70 @@
+/* Signal number definitions. BSD version.
+Copyright (C) 1991, 1992, 1993 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. */
+
+#ifdef _SIGNAL_H
+
+/* This file defines the fake signal functions and signal
+ number constants for 4.2 or 4.3 BSD-derived Unix system. */
+
+/* Fake signal functions. */
+#define SIG_ERR ((__sighandler_t) -1) /* Error return. */
+#define SIG_DFL ((__sighandler_t) 0) /* Default action. */
+#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */
+
+
+/* Signals. */
+#define SIGHUP 1 /* Hangup (POSIX). */
+#define SIGINT 2 /* Interrupt (ANSI). */
+#define SIGQUIT 3 /* Quit (POSIX). */
+#define SIGILL 4 /* Illegal instruction (ANSI). */
+#define SIGABRT SIGIOT /* Abort (ANSI). */
+#define SIGTRAP 5 /* Trace trap (POSIX). */
+#define SIGIOT 6 /* IOT trap (4.2 BSD). */
+#define SIGEMT 7 /* EMT trap (4.2 BSD). */
+#define SIGFPE 8 /* Floating-point exception (ANSI). */
+#define SIGKILL 9 /* Kill, unblockable (POSIX). */
+#define SIGBUS 10 /* Bus error (4.2 BSD). */
+#define SIGSEGV 11 /* Segmentation violation (ANSI). */
+#define SIGSYS 12 /* Bad argument to system call (4.2 BSD). */
+#define SIGPIPE 13 /* Broken pipe (POSIX). */
+#define SIGALRM 14 /* Alarm clock (POSIX). */
+#define SIGTERM 15 /* Termination (ANSI). */
+#define SIGURG 16 /* Urgent condition on socket (4.2 BSD). */
+#define SIGSTOP 17 /* Stop, unblockable (POSIX). */
+#define SIGTSTP 18 /* Keyboard stop (POSIX). */
+#define SIGCONT 19 /* Continue (POSIX). */
+#define SIGCHLD 20 /* Child status has changed (POSIX). */
+#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */
+#define SIGTTIN 21 /* Background read from tty (POSIX). */
+#define SIGTTOU 22 /* Background write to tty (POSIX). */
+#define SIGIO 23 /* I/O now possible (4.2 BSD). */
+#define SIGPOLL SIGIO /* Same as SIGIO? (SVID). */
+#define SIGXCPU 24 /* CPU limit exceeded (4.2 BSD). */
+#define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */
+#define SIGVTALRM 26 /* Virtual alarm clock (4.2 BSD). */
+#define SIGPROF 27 /* Profiling alarm clock (4.2 BSD). */
+#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */
+#define SIGINFO 29 /* Information request (4.4 BSD). */
+#define SIGUSR1 30 /* User-defined signal 1 (POSIX). */
+#define SIGUSR2 31 /* User-defined signal 2 (POSIX). */
+#define SIGLOST 32 /* Resource lost (Sun); server died (GNU). */
+
+#endif /* <signal.h> included. */
+
+#define _NSIG 33 /* Biggest signal number + 1. */
diff --git a/sysdeps/unix/bsd/sigpause.S b/sysdeps/unix/bsd/sigpause.S
new file mode 100644
index 0000000..de89e99
--- /dev/null
+++ b/sysdeps/unix/bsd/sigpause.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (sigpause, 1)
+ ret
+
+weak_alias (__sigpause, sigpause)
diff --git a/sysdeps/unix/bsd/sigprocmask.c b/sysdeps/unix/bsd/sigprocmask.c
new file mode 100644
index 0000000..31ebb74
--- /dev/null
+++ b/sysdeps/unix/bsd/sigprocmask.c
@@ -0,0 +1,65 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <signal.h>
+
+
+/* If SET is not NULL, modify the current set of blocked signals
+ according to HOW, which may be SIG_BLOCK, SIG_UNBLOCK or SIG_SETMASK.
+ If OSET is not NULL, store the old set of blocked signals in *OSET. */
+int
+DEFUN(__sigprocmask, (how, set, oset),
+ int how AND CONST sigset_t *set AND sigset_t *oset)
+{
+ int mask;
+
+ if (set != NULL)
+ {
+ mask = *set;
+ switch (how)
+ {
+ case SIG_BLOCK:
+ mask = __sigblock(mask);
+ break;
+
+ case SIG_UNBLOCK:
+ mask = __sigblock (0) & ~mask;
+ /* Fall through. */
+
+ case SIG_SETMASK:
+ mask = __sigsetmask(mask);
+ break;
+
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+ }
+ else
+ mask = __sigblock(0);
+
+ if (oset != NULL)
+ *oset = mask;
+
+ return 0;
+}
+
+weak_alias (__sigprocmask, sigprocmask)
diff --git a/sysdeps/unix/bsd/sigsetmask.S b/sysdeps/unix/bsd/sigsetmask.S
new file mode 100644
index 0000000..39fa9e7
--- /dev/null
+++ b/sysdeps/unix/bsd/sigsetmask.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (sigsetmask, 1)
+ ret
+
+weak_alias (__sigsetmask, sigsetmask)
diff --git a/sysdeps/unix/bsd/sigstack.S b/sysdeps/unix/bsd/sigstack.S
new file mode 100644
index 0000000..be92d93
--- /dev/null
+++ b/sysdeps/unix/bsd/sigstack.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (sigstack, 2)
+ ret
diff --git a/sysdeps/unix/bsd/sigsuspend.c b/sysdeps/unix/bsd/sigsuspend.c
new file mode 100644
index 0000000..fff56a9
--- /dev/null
+++ b/sysdeps/unix/bsd/sigsuspend.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+#include <stddef.h>
+#include <unistd.h>
+
+
+/* Change the set of blocked signals to SET,
+ wait until a signal arrives, and restore the set of blocked signals. */
+int
+DEFUN(sigsuspend, (set), CONST sigset_t *set)
+{
+ int mask;
+ int sig;
+
+ if (set == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ mask = 0;
+ for (sig = 1; sig <= NSIG; ++sig)
+ if (__sigismember(set, sig))
+ mask |= sigmask(sig);
+
+ return __sigpause(mask);
+}
diff --git a/sysdeps/unix/bsd/sigvec.S b/sysdeps/unix/bsd/sigvec.S
new file mode 100644
index 0000000..2922a22
--- /dev/null
+++ b/sysdeps/unix/bsd/sigvec.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (sigvec, 3)
+ ret
+
+weak_alias (__sigvec, sigvec)
diff --git a/sysdeps/unix/bsd/sony/newsos/m68k/Implies b/sysdeps/unix/bsd/sony/newsos/m68k/Implies
new file mode 100644
index 0000000..7b5f3cf
--- /dev/null
+++ b/sysdeps/unix/bsd/sony/newsos/m68k/Implies
@@ -0,0 +1,2 @@
+# A news800 is almost exactly like an hp300
+unix/bsd/hp/m68k
diff --git a/sysdeps/unix/bsd/sony/newsos/m68k/sysdep.h b/sysdeps/unix/bsd/sony/newsos/m68k/sysdep.h
new file mode 100644
index 0000000..a62c17e
--- /dev/null
+++ b/sysdeps/unix/bsd/sony/newsos/m68k/sysdep.h
@@ -0,0 +1,56 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <sysdeps/unix/sysdep.h>
+
+#ifdef ASSEMBLER
+
+#define POUND #
+
+#ifdef __STDC__
+#define ENTRY(name) \
+ .globl _##name; \
+ .even; \
+ _##name##:
+#else
+#define ENTRY(name) \
+ .globl _/**/name; \
+ .even; \
+ _/**/name/**/:
+#endif
+
+#define PSEUDO(name, syscall_name, args) \
+ .even; \
+ .globl syscall_error; \
+ error: jmp syscall_error; \
+ ENTRY (name) \
+ DO_CALL (POUND SYS_ify (syscall_name), args)
+
+#define DO_CALL(syscall, args) \
+ movel syscall, d0; \
+ linkw a6, POUND(0); \
+ trap POUND(0); \
+ unlk a6; \
+ bcs error
+
+#define ret rts
+#define r0 d0
+#define r1 d1
+#define MOVE(x,y) movel x , y
+
+#endif
diff --git a/sysdeps/unix/bsd/sony/newsos4/Dist b/sysdeps/unix/bsd/sony/newsos4/Dist
new file mode 100644
index 0000000..d7500fd
--- /dev/null
+++ b/sysdeps/unix/bsd/sony/newsos4/Dist
@@ -0,0 +1 @@
+sys_wait4.S
diff --git a/sysdeps/unix/bsd/sony/newsos4/Makefile b/sysdeps/unix/bsd/sony/newsos4/Makefile
new file mode 100644
index 0000000..7cfecf2
--- /dev/null
+++ b/sysdeps/unix/bsd/sony/newsos4/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir), posix)
+sysdep_routines := $(sysdep_routines) sys_wait4
+endif
diff --git a/sysdeps/unix/bsd/sony/newsos4/fchdir.S b/sysdeps/unix/bsd/sony/newsos4/fchdir.S
new file mode 100644
index 0000000..6db7282
--- /dev/null
+++ b/sysdeps/unix/bsd/sony/newsos4/fchdir.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/fchdir.S>
diff --git a/sysdeps/unix/bsd/sony/newsos4/sys_wait4.S b/sysdeps/unix/bsd/sony/newsos4/sys_wait4.S
new file mode 100644
index 0000000..6a79710
--- /dev/null
+++ b/sysdeps/unix/bsd/sony/newsos4/sys_wait4.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/sun/sunos4/sys_wait4.S>
diff --git a/sysdeps/unix/bsd/sony/newsos4/wait.c b/sysdeps/unix/bsd/sony/newsos4/wait.c
new file mode 100644
index 0000000..79d5458
--- /dev/null
+++ b/sysdeps/unix/bsd/sony/newsos4/wait.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/wait.c>
diff --git a/sysdeps/unix/bsd/sony/newsos4/wait3.c b/sysdeps/unix/bsd/sony/newsos4/wait3.c
new file mode 100644
index 0000000..0b3bdee
--- /dev/null
+++ b/sysdeps/unix/bsd/sony/newsos4/wait3.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/wait3.c>
diff --git a/sysdeps/unix/bsd/sony/newsos4/wait4.c b/sysdeps/unix/bsd/sony/newsos4/wait4.c
new file mode 100644
index 0000000..856c99f
--- /dev/null
+++ b/sysdeps/unix/bsd/sony/newsos4/wait4.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/sun/sunos4/wait4.c>
diff --git a/sysdeps/unix/bsd/statbuf.h b/sysdeps/unix/bsd/statbuf.h
new file mode 100644
index 0000000..166d68b
--- /dev/null
+++ b/sysdeps/unix/bsd/statbuf.h
@@ -0,0 +1,84 @@
+/* Copyright (C) 1991, 1992 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 _GNU_STAT_H
+
+#define _GNU_STAT_H 1
+
+#include <gnu/types.h>
+
+/* Structure describing file characteristics. */
+struct stat
+ {
+ /* This is a short instead of dev_t for compatibility with 4.3. */
+ short int st_dev; /* Device containing the file. */
+ __ino_t st_ino; /* File serial number. */
+
+ /* This is a short instead of mode_t for compatibility with 4.3. */
+ unsigned short int st_mode; /* File mode. */
+
+ __nlink_t st_nlink; /* Link count. */
+
+ /* These are shorts instead of uid_t/gid_t for compatibility with 4.3. */
+ unsigned short int st_uid; /* User ID of the file's owner. */
+ unsigned short int st_gid; /* Group ID of the file's group.*/
+
+ /* This is a short instead of dev_t for compatibility with 4.3. */
+ short int st_rdev; /* Device number, if device. */
+
+ __off_t st_size; /* Size of file, in bytes. */
+
+ __time_t st_atime; /* Time of last access. */
+ unsigned long int st_atime_usec;
+ __time_t st_mtime; /* Time of last modification. */
+ unsigned long int st_mtime_usec;
+ __time_t st_ctime; /* Time of last status change. */
+ unsigned long int st_ctime_usec;
+
+ unsigned long int st_blksize; /* Optimal block size for I/O. */
+#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
+
+ unsigned long int st_blocks; /* Number of 512-byte blocks allocated. */
+
+ long int st_spare[2];
+ };
+
+/* Encoding of the file mode. */
+
+#define __S_IFMT 0170000 /* These bits determine file type. */
+
+/* File types. */
+#define __S_IFDIR 0040000 /* Directory. */
+#define __S_IFCHR 0020000 /* Character device. */
+#define __S_IFBLK 0060000 /* Block device. */
+#define __S_IFREG 0100000 /* Regular file. */
+#define __S_IFLNK 0120000 /* Symbolic link. */
+#define __S_IFSOCK 0140000 /* Socket. */
+#define __S_IFIFO 0010000 /* FIFO. */
+
+/* Protection bits. */
+
+#define __S_ISUID 04000 /* Set user ID on execution. */
+#define __S_ISGID 02000 /* Set group ID on execution. */
+#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
+#define __S_IREAD 0400 /* Read by owner. */
+#define __S_IWRITE 0200 /* Write by owner. */
+#define __S_IEXEC 0100 /* Execute by owner. */
+
+
+#endif /* gnu/stat.h */
diff --git a/sysdeps/unix/bsd/stime.c b/sysdeps/unix/bsd/stime.c
new file mode 100644
index 0000000..be928e8
--- /dev/null
+++ b/sysdeps/unix/bsd/stime.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/time.h>
+
+/* Set the system clock to *WHEN. */
+
+int
+DEFUN(stime, (when), CONST time_t *when)
+{
+ struct timeval tv;
+
+ if (when == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ tv.tv_sec = *when;
+ tv.tv_usec = 0;
+ return __settimeofday (&tv, (struct timezone *) 0);
+}
diff --git a/sysdeps/unix/bsd/stty.c b/sysdeps/unix/bsd/stty.c
new file mode 100644
index 0000000..c6322ba
--- /dev/null
+++ b/sysdeps/unix/bsd/stty.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sgtty.h>
+
+/* Set the terminal parameters associated with FD to *PARAMS. */
+int
+DEFUN(stty, (fd, params),
+ int fd AND CONST struct sgttyb *params)
+{
+ return ioctl(fd, TIOCSETP, (PTR) params);
+}
diff --git a/sysdeps/unix/bsd/sun/getdents.S b/sysdeps/unix/bsd/sun/getdents.S
new file mode 100644
index 0000000..f283a5c
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/getdents.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (getdirentries, 4)
+ ret
+
+weak_alias (__getdirentries, getdirentries)
diff --git a/sysdeps/unix/bsd/sun/m68k/Dist b/sysdeps/unix/bsd/sun/m68k/Dist
new file mode 100644
index 0000000..cd893ff
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/m68k/Dist
@@ -0,0 +1 @@
+sigtramp.c
diff --git a/sysdeps/unix/bsd/sun/m68k/Makefile b/sysdeps/unix/bsd/sun/m68k/Makefile
new file mode 100644
index 0000000..ac4121d
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/m68k/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),signal)
+sysdep_routines := $(sysdep_routines) sigtramp
+endif
diff --git a/sysdeps/unix/bsd/sun/m68k/brk.S b/sysdeps/unix/bsd/sun/m68k/brk.S
new file mode 100644
index 0000000..114fa73
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/m68k/brk.S
@@ -0,0 +1,49 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#include <sysdep.h>
+
+#ifndef SYS_brk
+#define SYS_brk 17
+#endif
+
+#ifndef HAVE_GNU_LD
+#define __end _end
+#endif
+
+.data
+.globl ___curbrk
+___curbrk:
+ .long __end
+
+.text
+ENTRY (__brk)
+ movel __end, d0
+ cmpl sp@(4), d0
+ ble 0f
+ movel d0, sp@(4)
+0: pea SYS_brk
+ trap #0
+ bcs 1f
+ movel sp@(4), ___curbrk
+ clrl d0
+ rts
+1:
+ jmp syscall_error
+
+weak_alias (__brk, brk)
diff --git a/sysdeps/unix/bsd/sun/m68k/sethostid.S b/sysdeps/unix/bsd/sun/m68k/sethostid.S
new file mode 100644
index 0000000..8b30f3f
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/m68k/sethostid.S
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+#ifdef SYS_sethostid
+
+SYSCALL (sethostid, 1)
+ ret
+
+#else
+
+#include <errnos.h>
+
+.globl _sethostid
+.even
+_sethostid:
+ movel #ENOSYS, _errno
+ moveq #-1, d0
+ rts
+
+#ifdef HAVE_GNU_LD
+
+.stabs "warning: sethostid is not implemented and will always fail",30,0,0,0
+.stabs "_sethostid",1,0,0,0
+
+#endif
+
+#endif
diff --git a/sysdeps/unix/bsd/sun/m68k/sigcontext.h b/sysdeps/unix/bsd/sun/m68k/sigcontext.h
new file mode 100644
index 0000000..471b516
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/m68k/sigcontext.h
@@ -0,0 +1,26 @@
+/* Structure describing state saved while handling a signal. Sun 3 version.
+Copyright (C) 1993, 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. */
+
+struct sigcontext
+ {
+ int sc_onstack;
+ __sigset_t sc_mask;
+
+ int sc_sp, sc_pc, sc_ps;
+ };
diff --git a/sysdeps/unix/bsd/sun/m68k/sigtramp.c b/sysdeps/unix/bsd/sun/m68k/sigtramp.c
new file mode 100644
index 0000000..32a2c20
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/m68k/sigtramp.c
@@ -0,0 +1,142 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+
+#ifndef __GNUC__
+ #error This file uses GNU C extensions; you must compile with GCC.
+#endif
+
+/* Get the definition of `struct sigcontext'. */
+#define KERNEL
+#define sigvec sun_sigvec
+#define sigstack sun_sigstack
+#define sigcontext sun_sigcontext
+#include "/usr/include/sys/signal.h"
+#undef sigvec
+#undef sigstack
+#undef sigcontext
+#undef NSIG
+#undef SIGABRT
+#undef SIGCLD
+#undef SV_ONSTACK
+#undef SV_RESETHAND
+#undef SV_INTERRUPT
+#undef SA_ONSTACK
+#undef SA_NOCLDSTOP
+#undef SIG_ERR
+#undef SIG_DFL
+#undef SIG_IGN
+#undef sigmask
+#undef SIG_BLOCK
+#undef SIG_UNBLOCK
+#undef SIG_SETMASK
+
+#include <signal.h>
+#include <stddef.h>
+#include <errno.h>
+
+/* Defined in __sigvec.S. */
+extern int EXFUN(__raw_sigvec, (int sig, CONST struct sigvec *vec,
+ struct sigvec *ovec));
+
+/* User-specified signal handlers. */
+#define mytramp 1
+#ifdef mytramp
+static __sighandler_t handlers[NSIG];
+#else
+#define handlers _sigfunc
+extern __sighandler_t _sigfunc[];
+#endif
+
+#if mytramp
+
+/* Handler for all signals that are handled by a user-specified function.
+ Saves and restores the general regs %g2-%g7, the %y register, and
+ all the FPU regs (including %fsr), around calling the user's handler. */
+static void
+DEFUN(trampoline, (sig, code, context, addr),
+ int sig AND int code AND struct sigcontext *context AND PTR addr)
+{
+ int save[4];
+
+ /* Save the call-clobbered registers. */
+ asm volatile ("movem%.l d0-d1/a0-a1, %0" : : "m" (save[0]));
+
+ /* XXX should save/restore FP regs */
+
+ /* Call the user's handler. */
+ (*((void EXFUN((*), (int sig, int code, struct sigcontext *context,
+ PTR addr))) handlers[sig]))
+ (sig, code, context, addr);
+
+ /* Restore the call-clobbered registers. */
+ asm volatile ("movem%.l %0, d0-d1/a0-a1" : : "g" (save[0]) :
+ "d0", "d1", "a0", "a1");
+
+ __sigreturn (context);
+}
+
+#endif
+
+int
+DEFUN(__sigvec, (sig, vec, ovec),
+ int sig AND CONST struct sigvec *vec AND struct sigvec *ovec)
+{
+#ifndef mytramp
+ extern void _sigtramp (int);
+#define trampoline _sigtramp
+#endif
+ struct sigvec myvec;
+ int mask;
+ __sighandler_t ohandler;
+
+ if (sig <= 0 || sig >= NSIG)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ mask = __sigblock(sigmask(sig));
+
+ ohandler = handlers[sig];
+
+ if (vec != NULL &&
+ vec->sv_handler != SIG_IGN && vec->sv_handler != SIG_DFL)
+ {
+ handlers[sig] = vec->sv_handler;
+ myvec = *vec;
+ myvec.sv_handler = trampoline;
+ vec = &myvec;
+ }
+
+ if (__raw_sigvec(sig, vec, ovec) < 0)
+ {
+ int save = errno;
+ (void) __sigsetmask(mask);
+ errno = save;
+ return -1;
+ }
+
+ if (ovec != NULL && ovec->sv_handler == trampoline)
+ ovec->sv_handler = ohandler;
+
+ (void) __sigsetmask(mask);
+
+ return 0;
+}
diff --git a/sysdeps/unix/bsd/sun/m68k/syscall.S b/sysdeps/unix/bsd/sun/m68k/syscall.S
new file mode 100644
index 0000000..0a98da7
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/m68k/syscall.S
@@ -0,0 +1,28 @@
+/* Copyright (C) 1993 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. */
+
+#include <sysdep.h>
+
+ENTRY (syscall)
+ movel sp@, d0 /* Save return address in D0. */
+ movel sp@(4), sp@ /* Put syscall number at top of stack. */
+ movel d0, sp@(4) /* Put return address under it. */
+ trap #0 /* Do syscall; pops number from stack. */
+ jcs error
+ ret
+error: jmp syscall_error
diff --git a/sysdeps/unix/bsd/sun/m68k/sysdep.h b/sysdeps/unix/bsd/sun/m68k/sysdep.h
new file mode 100644
index 0000000..80f6aba
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/m68k/sysdep.h
@@ -0,0 +1,62 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#include <sysdeps/unix/sysdep.h>
+
+#ifdef ASSEMBLER
+
+#define POUND #
+
+#ifdef __STDC__
+#define ENTRY(name) \
+ .globl _##name; \
+ .even; \
+ _##name##:
+#else
+#define ENTRY(name) \
+ .globl _/**/name; \
+ .even; \
+ _/**/name/**/:
+#endif
+
+#ifdef __STDC__
+#define PSEUDO(name, syscall_name, args) \
+ .even; \
+ .globl syscall_error; \
+ error: jmp syscall_error; \
+ ENTRY (name) \
+ pea SYS_##syscall_name; \
+ trap POUND 0; \
+ bcs error
+#else
+#define PSEUDO(name, syscall_name, args) \
+ .even; \
+ .globl syscall_error; \
+ error: jmp syscall_error; \
+ ENTRY (name) \
+ pea SYS_/**/syscall_name; \
+ trap POUND 0; \
+ bcs error
+#endif
+
+#define ret rts
+#define r0 d0
+#define r1 d1
+#define MOVE(x,y) movel x , y
+
+#endif /* ASSEMBLER */
diff --git a/sysdeps/unix/bsd/sun/sethostid.c b/sysdeps/unix/bsd/sun/sethostid.c
new file mode 100644
index 0000000..a8951fa
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sethostid.c
@@ -0,0 +1 @@
+#include <sysdeps/stub/sethostid.c>
diff --git a/sysdeps/unix/bsd/sun/signum.h b/sysdeps/unix/bsd/sun/signum.h
new file mode 100644
index 0000000..ea83d71
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/signum.h
@@ -0,0 +1,69 @@
+/* Signal number definitions. SunOS 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. */
+
+#ifdef _SIGNAL_H
+
+/* This file defines the fake signal functions and signal
+ number constants for SunOS 3 and 4 Unix systems. */
+
+/* Fake signal functions. */
+#define SIG_ERR ((__sighandler_t) -1) /* Error return. */
+#define SIG_DFL ((__sighandler_t) 0) /* Default action. */
+#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */
+
+
+/* Signals. */
+#define SIGHUP 1 /* Hangup (POSIX). */
+#define SIGINT 2 /* Interrupt (ANSI). */
+#define SIGQUIT 3 /* Quit (POSIX). */
+#define SIGILL 4 /* Illegal instruction (ANSI). */
+#define SIGABRT SIGIOT /* Abort (ANSI). */
+#define SIGTRAP 5 /* Trace trap (POSIX). */
+#define SIGIOT 6 /* IOT trap (4.2 BSD). */
+#define SIGEMT 7 /* EMT trap (4.2 BSD). */
+#define SIGFPE 8 /* Floating-point exception (ANSI). */
+#define SIGKILL 9 /* Kill, unblockable (POSIX). */
+#define SIGBUS 10 /* Bus error (4.2 BSD). */
+#define SIGSEGV 11 /* Segmentation violation (ANSI). */
+#define SIGSYS 12 /* Bad argument to system call (4.2 BSD). */
+#define SIGPIPE 13 /* Broken pipe (POSIX). */
+#define SIGALRM 14 /* Alarm clock (POSIX). */
+#define SIGTERM 15 /* Termination (ANSI). */
+#define SIGURG 16 /* Urgent condition on socket (4.2 BSD). */
+#define SIGSTOP 17 /* Stop, unblockable (POSIX). */
+#define SIGTSTP 18 /* Keyboard stop (POSIX). */
+#define SIGCONT 19 /* Continue (POSIX). */
+#define SIGCHLD 20 /* Child status has changed (POSIX). */
+#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */
+#define SIGTTIN 21 /* Background read from tty (POSIX). */
+#define SIGTTOU 22 /* Background write to tty (POSIX). */
+#define SIGIO 23 /* I/O now possible (4.2 BSD). */
+#define SIGPOLL SIGIO /* Same as SIGIO? (SVID). */
+#define SIGXCPU 24 /* CPU limit exceeded (4.2 BSD). */
+#define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */
+#define SIGVTALRM 26 /* Virtual alarm clock (4.2 BSD). */
+#define SIGPROF 27 /* Profiling alarm clock (4.2 BSD). */
+#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */
+#define SIGLOST 29 /* Resource lost (Sun). */
+#define SIGUSR1 30 /* User-defined signal 1 (POSIX). */
+#define SIGUSR2 31 /* User-defined signal 2 (POSIX). */
+
+#endif /* <signal.h> included. */
+
+#define _NSIG 32 /* Biggest signal number + 1. */
diff --git a/sysdeps/unix/bsd/sun/sigreturn.S b/sysdeps/unix/bsd/sun/sigreturn.S
new file mode 100644
index 0000000..d0a3f3a
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sigreturn.S
@@ -0,0 +1,28 @@
+/* Copyright (C) 1993, 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. */
+
+#include <sysdep.h>
+
+#ifndef SYS_sigreturn
+#define SYS_sigreturn 139
+#endif
+
+SYSCALL__ (sigreturn, 1)
+ /* Does not return. */
+
+weak_alias (__sigreturn, sigreturn)
diff --git a/sysdeps/unix/bsd/sun/sigvec.S b/sysdeps/unix/bsd/sun/sigvec.S
new file mode 100644
index 0000000..c093974
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sigvec.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+/* __sigvec is defined by sigtramp.c. */
+
+PSEUDO (__raw_sigvec, sigvec, 3)
+ ret
+
+weak_alias (__sigvec, sigvec)
diff --git a/sysdeps/unix/bsd/sun/sparc/Dist b/sysdeps/unix/bsd/sun/sparc/Dist
new file mode 100644
index 0000000..cd893ff
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sparc/Dist
@@ -0,0 +1 @@
+sigtramp.c
diff --git a/sysdeps/unix/bsd/sun/sparc/Makefile b/sysdeps/unix/bsd/sun/sparc/Makefile
new file mode 100644
index 0000000..59d10db
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sparc/Makefile
@@ -0,0 +1,7 @@
+# Basically `-e start' is magical to the Sun linker. You would think that
+# having start.o first would be enough, but you would be wrong.
+LDFLAGS := $(LDFLAGS) -Xlinker -e -Xlinker start
+
+ifeq ($(subdir),signal)
+sysdep_routines := $(sysdep_routines) sigtramp
+endif
diff --git a/sysdeps/unix/bsd/sun/sparc/sethostid.S b/sysdeps/unix/bsd/sun/sparc/sethostid.S
new file mode 100644
index 0000000..fbafba5
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sparc/sethostid.S
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+#ifdef SYS_sethostid
+
+SYSCALL (sethostid, 1)
+ ret
+
+#else
+
+/* <errnos.h> only defines E* #ifdef _ERRNO_H. */
+#define _ERRNO_H
+#include <errnos.h>
+
+ENTRY (sethostid)
+ mov ENOSYS, %o0
+ sethi %hi(_errno), %g1
+ st %o0, [%g1 + %lo(_errno)]
+ retl
+ sub %g0, 1, %o0
+
+#ifdef HAVE_GNU_LD
+
+.stabs "warning: sethostid is not implemented and will always fail",30,0,0,0
+.stabs "_sethostid",1,0,0,0
+
+#endif
+
+#endif
diff --git a/sysdeps/unix/bsd/sun/sparc/sigcontext.h b/sysdeps/unix/bsd/sun/sparc/sigcontext.h
new file mode 100644
index 0000000..290bf81
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sparc/sigcontext.h
@@ -0,0 +1,31 @@
+/* Structure describing state saved while handling a signal. Sparc version.
+Copyright (C) 1992, 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. */
+
+struct sigcontext
+ {
+ int sc_onstack;
+ __sigset_t sc_mask;
+
+#define SPARC_MAXREGWINDOW 31 /* Maximum usable register windows. */
+ int sc_sp, sc_pc, sc_npc, sc_psr, sc_g1, sc_o0;
+ int sc_wbcnt; /* Number of outstanding windows. */
+ __ptr_t sc_spbuf[SPARC_MAXREGWINDOW]; /* SP's for each window. */
+ int sc_wbuf[SPARC_MAXREGWINDOW][16]; /* Saved register windows. */
+ };
+
diff --git a/sysdeps/unix/bsd/sun/sparc/sigtramp.c b/sysdeps/unix/bsd/sun/sparc/sigtramp.c
new file mode 100644
index 0000000..54f6293
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sparc/sigtramp.c
@@ -0,0 +1,246 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+
+#ifndef __GNUC__
+ #error This file uses GNU C extensions; you must compile with GCC.
+#endif
+
+/* Get the definition of `struct sigcontext'. */
+#define KERNEL
+#define sigvec sun_sigvec
+#define sigstack sun_sigstack
+#define sigcontext sun_sigcontext
+#include "/usr/include/sys/signal.h"
+#undef sigvec
+#undef sigstack
+#undef sigcontext
+#undef NSIG
+#undef SIGABRT
+#undef SIGCLD
+#undef SV_ONSTACK
+#undef SV_RESETHAND
+#undef SV_INTERRUPT
+#undef SA_ONSTACK
+#undef SA_NOCLDSTOP
+#undef SIG_ERR
+#undef SIG_DFL
+#undef SIG_IGN
+#undef sigmask
+#undef SIG_BLOCK
+#undef SIG_UNBLOCK
+#undef SIG_SETMASK
+
+#include <signal.h>
+#include <stddef.h>
+#include <errno.h>
+
+/* Defined in __sigvec.S. */
+extern int EXFUN(__raw_sigvec, (int sig, CONST struct sigvec *vec,
+ struct sigvec *ovec));
+
+/* User-specified signal handlers. */
+#define mytramp 1
+#ifdef mytramp
+static __sighandler_t handlers[NSIG];
+#else
+#define handlers _sigfunc
+extern __sighandler_t _sigfunc[];
+#endif
+
+#if mytramp
+
+/* Handler for all signals that are handled by a user-specified function.
+ Saves and restores the general regs %g2-%g7, the %y register, and
+ all the FPU regs (including %fsr), around calling the user's handler. */
+static void
+DEFUN(trampoline, (sig), int sig)
+{
+ /* We use `double' and `long long int' so `std' (store doubleword) insns,
+ which might be faster than single-word stores, will be generated. */
+ register double f0 asm("%f0");
+ register double f2 asm("%f2");
+ register double f4 asm("%f4");
+ register double f6 asm("%f6");
+ register double f8 asm("%f8");
+ register double f10 asm("%f10");
+ register double f12 asm("%f12");
+ register double f14 asm("%f14");
+ register double f16 asm("%f16");
+ register double f18 asm("%f18");
+ register double f20 asm("%f20");
+ register double f22 asm("%f22");
+ register double f24 asm("%f24");
+ register double f26 asm("%f26");
+ register double f28 asm("%f28");
+ register double f30 asm("%f30");
+ register long long int g2 asm("%g2");
+ register long long int g4 asm("%g4");
+ register long long int g6 asm("%g6");
+ register int *fp asm("%fp");
+
+ int code;
+ register struct sigcontext *context asm("%i0"); /* See end of fn. */
+ PTR addr;
+ int y;
+ double fpsave[16];
+ int fsr;
+ int savefpu;
+ long long int glsave[3];
+
+ /* SIG isn't really passed as an arg.
+ The args to the signal handler are at fp[16..19]. */
+ sig = fp[16];
+ code = fp[17];
+ context = (struct sigcontext *) fp[18];
+ addr = (PTR) fp[19];
+
+ /* Save the Y register. */
+ asm("rd %%y, %0" : "=r" (y));
+
+ /* Save the FPU regs if the FPU enable bit is set in the PSR,
+ and the signal isn't an FP exception. */
+ savefpu = (context->sc_psr & 0x1000) && sig != SIGFPE;
+ if (savefpu)
+ {
+ fpsave[0] = f0;
+ fpsave[1] = f2;
+ fpsave[2] = f4;
+ fpsave[3] = f6;
+ fpsave[4] = f8;
+ fpsave[5] = f10;
+ fpsave[6] = f12;
+ fpsave[7] = f14;
+ fpsave[8] = f16;
+ fpsave[9] = f18;
+ fpsave[10] = f20;
+ fpsave[11] = f22;
+ fpsave[12] = f24;
+ fpsave[13] = f26;
+ fpsave[14] = f28;
+ fpsave[15] = f30;
+
+ /* Force it into a stack slot so the asm won't barf. Sigh. */
+ (void) &fsr;
+ asm("st %%fsr, %0" : "=m" (fsr));
+ }
+
+ /* Save the global registers (except for %g1, which is a scratch reg). */
+ glsave[0] = g2;
+ glsave[1] = g4;
+ glsave[2] = g6;
+
+ /* Call the user's handler. */
+ (*((void EXFUN((*), (int sig, int code, struct sigcontext *context,
+ PTR addr))) handlers[sig]))
+ (sig, code, context, addr);
+
+ /* Restore the Y register. */
+ asm("mov %0, %%y" : : "r" (y));
+
+ if (savefpu)
+ {
+ /* Restore the FPU regs. */
+ f0 = fpsave[0];
+ f2 = fpsave[1];
+ f4 = fpsave[2];
+ f6 = fpsave[3];
+ f8 = fpsave[4];
+ f10 = fpsave[5];
+ f12 = fpsave[6];
+ f14 = fpsave[7];
+ f16 = fpsave[8];
+ f18 = fpsave[9];
+ f20 = fpsave[10];
+ f22 = fpsave[11];
+ f24 = fpsave[12];
+ f26 = fpsave[13];
+ f28 = fpsave[14];
+ f30 = fpsave[15];
+
+ asm("ld %0, %%fsr" : : "m" (fsr));
+ }
+
+ /* Restore the globals. */
+ g2 = glsave[0];
+ g4 = glsave[1];
+ g6 = glsave[2];
+
+ /* Unwind a frame, and do a "sigcleanup" system call.
+ The system call apparently does a return.
+ I don't know what it's for. Ask Sun. */
+ asm("restore %%g0, 139, %%g1\n"
+ "ta 0\n"
+ "! this should be i0: %0" /* Useless insn that will never be executed, */
+ /* here to make the compiler happy. */
+ : /* No outputs. */ :
+ /* CONTEXT is bound to %i0. We reference it as an input here to make
+ sure the compiler considers it live at this point, and preserves
+ the value in that register. The restore makes %i0 become %o0, the
+ argument to the system call. */
+ "r" (context));
+}
+#endif
+
+int
+DEFUN(__sigvec, (sig, vec, ovec),
+ int sig AND CONST struct sigvec *vec AND struct sigvec *ovec)
+{
+#ifndef mytramp
+ extern void _sigtramp (int);
+#define trampoline _sigtramp
+#endif
+ struct sigvec myvec;
+ int mask;
+ __sighandler_t ohandler;
+
+ if (sig <= 0 || sig >= NSIG)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ mask = __sigblock(sigmask(sig));
+
+ ohandler = handlers[sig];
+
+ if (vec != NULL &&
+ vec->sv_handler != SIG_IGN && vec->sv_handler != SIG_DFL)
+ {
+ handlers[sig] = vec->sv_handler;
+ myvec = *vec;
+ myvec.sv_handler = trampoline;
+ vec = &myvec;
+ }
+
+ if (__raw_sigvec(sig, vec, ovec) < 0)
+ {
+ int save = errno;
+ (void) __sigsetmask(mask);
+ errno = save;
+ return -1;
+ }
+
+ if (ovec != NULL && ovec->sv_handler == trampoline)
+ ovec->sv_handler = ohandler;
+
+ (void) __sigsetmask(mask);
+
+ return 0;
+}
diff --git a/sysdeps/unix/bsd/sun/sunos3/m68k/wait.S b/sysdeps/unix/bsd/sun/sunos3/m68k/wait.S
new file mode 100644
index 0000000..f69c4b4
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos3/m68k/wait.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/hp/m68k/wait.S>
diff --git a/sysdeps/unix/bsd/sun/sunos4/.cvsignore b/sysdeps/unix/bsd/sun/sunos4/.cvsignore
new file mode 100644
index 0000000..1f69fd9
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/.cvsignore
@@ -0,0 +1,4 @@
+*.gz *.Z *.tar *.tgz
+=*
+TODO COPYING* AUTHORS copyr-* copying.*
+glibc-*
diff --git a/sysdeps/unix/bsd/sun/sunos4/Dist b/sysdeps/unix/bsd/sun/sunos4/Dist
new file mode 100644
index 0000000..f1c9046
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/Dist
@@ -0,0 +1,2 @@
+sys_wait4.S
+sys_mmap.S
diff --git a/sysdeps/unix/bsd/sun/sunos4/Implies b/sysdeps/unix/bsd/sun/sunos4/Implies
new file mode 100644
index 0000000..c99e256
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/Implies
@@ -0,0 +1,2 @@
+# SunOS 4 has the canonical set of <sys/mman.h> system calls.
+unix/mman
diff --git a/sysdeps/unix/bsd/sun/sunos4/Makefile b/sysdeps/unix/bsd/sun/sunos4/Makefile
new file mode 100644
index 0000000..96b88e1
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/Makefile
@@ -0,0 +1,7 @@
+ifeq ($(subdir), posix)
+sysdep_routines := $(sysdep_routines) sys_wait4
+endif
+
+ifeq ($(subdir), misc)
+sysdep_routines := $(sysdep_routines) sys_mmap
+endif
diff --git a/sysdeps/unix/bsd/sun/sunos4/fcntlbits.h b/sysdeps/unix/bsd/sun/sunos4/fcntlbits.h
new file mode 100644
index 0000000..2100722
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/fcntlbits.h
@@ -0,0 +1,145 @@
+/* O_*, F_*, FD_* bit values for SunOS 4.
+Copyright (C) 1991, 1992 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 _FCNTLBITS_H
+
+#define _FCNTLBITS_H 1
+
+
+/* File access modes for `open' and `fcntl'. */
+#define O_RDONLY 0 /* Open read-only. */
+#define O_WRONLY 1 /* Open write-only. */
+#define O_RDWR 2 /* Open read/write. */
+
+
+/* Bits OR'd into the second argument to open. */
+#define O_CREAT 0x0200 /* Create file if it doesn't exist. */
+#define O_EXCL 0x0800 /* Fail if file already exists. */
+#define O_TRUNC 0x0400 /* Truncate file to zero length. */
+#define O_NOCTTY 0x8000 /* Don't assign a controlling terminal. */
+#if defined (__USE_BSD) || defined (__USE_SVID)
+#define O_ASYNC 0x0040 /* Send SIGIO to owner when data is ready. */
+#define O_FSYNC 0x2000 /* Synchronous writes. */
+#define O_SYNC O_FSYNC
+#endif
+
+/* File status flags for `open' and `fcntl'. */
+#define O_APPEND 0x0008 /* Writes append to the file. */
+#define O_NONBLOCK 0x4000 /* Non-blocking I/O. */
+
+/* Sun defines O_NDELAY one way for BSD behavior and another for System V
+ behavior. In the GNU C library, you get the BSD behavior unless you
+ define _USG_SOURCE without also defining _BSD_SOURCE or _GNU_SOURCE. */
+#ifdef __USE_BSD
+#define O_NDELAY 0x0004
+#endif
+#if !defined (O_NDELAY) && defined (__USE_SVID)
+#define O_NDELAY 0x1000
+#endif
+
+#ifdef __USE_BSD
+/* Bits in the file status flags returned by F_GETFL.
+ These are all the O_* flags, plus FREAD and FWRITE, which are
+ independent bits set by which of O_RDONLY, O_WRONLY, and O_RDWR, was
+ given to `open'. */
+#define FREAD 1
+#define FWRITE 2
+
+/* Traditional Unix names the O_* bits. */
+#define FASYNC O_ASYNC
+#define FCREAT O_CREAT
+#define FEXCL O_EXCL
+#define FTRUNC O_TRUNC
+#define FNOCTTY O_NOCTTY
+#define FFSYNC O_FSYNC
+#define FSYNC O_SYNC
+#define FAPPEND O_APPEND
+#define FNONBLOCK O_NONBLOCK
+#define FNONBIO O_NONBLOCK
+#define FNDELAY 0x0004 /* BSD O_NDELAY. */
+#define FNBIO 0x1000 /* System V O_NDELAY. */
+#endif
+
+/* Mask for file access modes. This is system-dependent in case
+ some system ever wants to define some other flavor of access. */
+#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
+
+/* Values for the second argument to `fcntl'. */
+#define F_DUPFD 0 /* Duplicate file descriptor. */
+#define F_GETFD 1 /* Get file descriptor flags. */
+#define F_SETFD 2 /* Set file descriptor flags. */
+#define F_GETFL 3 /* Get file status flags. */
+#define F_SETFL 4 /* Set file status flags. */
+#ifdef __USE_BSD
+#define F_GETOWN 5 /* Get owner (receiver of SIGIO). */
+#define F_SETOWN 6 /* Set owner (receiver of SIGIO). */
+#endif
+#define F_GETLK 7 /* Get record locking info. */
+#define F_SETLK 8 /* Set record locking info (non-blocking). */
+#define F_SETLKW 9 /* Set record locking info (blocking). */
+#ifdef __USE_BSD
+#define F_RGETLK 10 /* Get remote record locking info. */
+#define F_RSETLK 11 /* Set remote locking info (non-blocking). */
+#define F_CNVT 12 /* Convert a fhandle to an open fd. */
+#define F_RSETLKW 13 /* Set remote locking info (blocking). */
+#endif
+
+/* File descriptor flags used with F_GETFD and F_SETFD. */
+#define FD_CLOEXEC 1 /* Close on exec. */
+
+
+#include <gnu/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. */
+struct flock
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+ short int l_pid; /* Process holding the lock. */
+ short int l_xxx; /* Reserved for future use. */
+ };
+
+#ifdef __USE_BSD
+/* The structure describing a remote advisory lock. This is the type of the
+ third arg to `fcntl' for the F_RGETLK, F_RSETLK, and F_RSETLKW requests. */
+struct eflock
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+ short int l_pid; /* Process holding the lock. */
+ short int l_xxx; /* Reserved for future use. */
+ long int l_rpid; /* Remote process ID wanting this lock. */
+ long int l_rsys; /* Remote system ID wanting this lock. */
+ };
+
+#endif
+
+
+/* Values for the `l_type' field of a `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/sun/sunos4/mmap.c b/sysdeps/unix/bsd/sun/sunos4/mmap.c
new file mode 100644
index 0000000..4dfc1ca
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/mmap.c
@@ -0,0 +1,41 @@
+/* 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. */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <errno.h>
+
+/* Map addresses starting near ADDR and extending for LEN bytes. from
+ OFFSET into the file FD describes according to PROT and FLAGS. If ADDR
+ is nonzero, it is the desired mapping address. If the MAP_FIXED bit is
+ set in FLAGS, the mapping will be at ADDR exactly (which must be
+ page-aligned); otherwise the system chooses a convenient nearby address.
+ The return value is the actual mapping address chosen or (caddr_t) -1
+ for errors (in which case `errno' is set). A successful `mmap' call
+ deallocates any previous mapping for the affected region. */
+
+extern caddr_t __mmap_syscall (caddr_t addr, size_t len,
+ int prot, int flags, int fd, off_t offset);
+
+
+caddr_t
+mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
+{
+ return __mmap_syscall (addr, len, prot, flags | _MAP_NEW, fd, offset);
+}
+
diff --git a/sysdeps/unix/bsd/sun/sunos4/msync.S b/sysdeps/unix/bsd/sun/sunos4/msync.S
new file mode 100644
index 0000000..9fb8955
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/msync.S
@@ -0,0 +1,22 @@
+/* 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. */
+
+#include <sysdep.h>
+
+SYSCALL (msync, 3)
+ ret
diff --git a/sysdeps/unix/bsd/sun/sunos4/poll.S b/sysdeps/unix/bsd/sun/sunos4/poll.S
new file mode 100644
index 0000000..95c4fd2
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/poll.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/poll.S>
diff --git a/sysdeps/unix/bsd/sun/sunos4/resourcebits.h b/sysdeps/unix/bsd/sun/sunos4/resourcebits.h
new file mode 100644
index 0000000..b5d3704
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/resourcebits.h
@@ -0,0 +1,48 @@
+/* Bit values for resource limits. SunOS 4 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. */
+
+/* These are the values for 4.4 BSD and GNU. Earlier BSD systems have a
+ subset of these kinds of resource limit. In systems where `getrlimit'
+ and `setrlimit' are not system calls, these are the values used by the C
+ library to emulate them. */
+
+/* Kinds of resource limit. */
+enum __rlimit_resource
+ {
+ /* Per-process CPU limit, in seconds. */
+ RLIMIT_CPU,
+ /* Largest file that can be created, in bytes. */
+ RLIMIT_FSIZE,
+ /* Maximum size of data segment, in bytes. */
+ RLIMIT_DATA,
+ /* Maximum size of stack segment, in bytes. */
+ RLIMIT_STACK,
+ /* Largest core file that can be created, in bytes. */
+ RLIMIT_CORE,
+ /* Largest resident set size, in bytes.
+ This affects swapping; processes that are exceeding their
+ resident set size will be more likely to have physical memory
+ taken from them. */
+ RLIMIT_RSS,
+ /* Number of open files. */
+ RLIMIT_NOFILE,
+ RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same. */
+
+ RLIM_NLIMITS
+ };
diff --git a/sysdeps/unix/bsd/sun/sunos4/setsid.S b/sysdeps/unix/bsd/sun/sunos4/setsid.S
new file mode 100644
index 0000000..4930c56
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/setsid.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/setsid.S>
diff --git a/sysdeps/unix/bsd/sun/sunos4/speed.c b/sysdeps/unix/bsd/sun/sunos4/speed.c
new file mode 100644
index 0000000..1c09d55
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/speed.c
@@ -0,0 +1,113 @@
+/* `struct termios' speed frobnication functions. SunOS 4 version.
+Copyright (C) 1991, 1992, 1993 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <errno.h>
+#include <termios.h>
+
+static CONST speed_t speeds[] =
+ {
+ 0,
+ 50,
+ 75,
+ 110,
+ 134,
+ 150,
+ 200,
+ 300,
+ 600,
+ 1200,
+ 1800,
+ 2400,
+ 4800,
+ 9600,
+ 19200,
+ 38400,
+ };
+
+
+/* Return the output baud rate stored in *TERMIOS_P. */
+speed_t
+DEFUN(cfgetospeed, (termios_p), CONST struct termios *termios_p)
+{
+ return termios_p->c_cflag & CBAUD;
+}
+
+/* Return the input baud rate stored in *TERMIOS_P. */
+speed_t
+DEFUN(cfgetispeed, (termios_p), CONST struct termios *termios_p)
+{
+ return (termios_p->c_cflag & CIBAUD) >> IBSHIFT;
+}
+
+/* Set the output baud rate stored in *TERMIOS_P to SPEED. */
+int
+DEFUN(cfsetospeed, (termios_p, speed),
+ struct termios *termios_p AND speed_t speed)
+{
+ register unsigned int i;
+
+ if (termios_p == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* This allows either B1200 or 1200 to work. XXX
+ Do we really want to try to support this, given that
+ fetching the speed must return one or the other? */
+
+ for (i = 0; i < sizeof (speeds) / sizeof (speeds[0]); ++i)
+ if (i == speed || speeds[i] == speed)
+ {
+ termios_p->c_cflag &= ~CBAUD;
+ termios_p->c_cflag |= i;
+ return 0;
+ }
+
+ errno = EINVAL;
+ return -1;
+}
+
+/* Set the input baud rate stored in *TERMIOS_P to SPEED. */
+int
+DEFUN(cfsetispeed, (termios_p, speed),
+ struct termios *termios_p AND speed_t speed)
+{
+ register unsigned int i;
+
+ if (termios_p == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* See comment in cfsetospeed (above). */
+ for (i = 0; i < sizeof (speeds) / sizeof (speeds[0]); ++i)
+ if (i == speed || speeds[i] == speed)
+ {
+ termios_p->c_cflag &= ~CIBAUD;
+ termios_p->c_cflag |= i << IBSHIFT;
+ return 0;
+ }
+
+ errno = EINVAL;
+ return -1;
+}
diff --git a/sysdeps/unix/bsd/sun/sunos4/sys/mman.h b/sysdeps/unix/bsd/sun/sunos4/sys/mman.h
new file mode 100644
index 0000000..727e665
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/sys/mman.h
@@ -0,0 +1,107 @@
+/* Definitions for BSD-style memory management. SunOS 4 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. */
+
+#ifndef _SYS_MMAN_H
+
+#define _SYS_MMAN_H 1
+#include <features.h>
+
+#include <gnu/types.h>
+#define __need_size_t
+#include <stddef.h>
+
+
+/* Protections are chosen from these bits, OR'd together. The
+ implementation does not necessarily support PROT_EXEC or PROT_WRITE
+ without PROT_READ. The only guarantees are that no writing will be
+ allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
+
+#define PROT_NONE 0x00 /* No access. */
+#define PROT_READ 0x01 /* Pages can be read. */
+#define PROT_WRITE 0x02 /* Pages can be written. */
+#define PROT_EXEC 0x04 /* Pages can be executed. */
+
+
+/* Sharing types (must choose one and only one of these). */
+#define MAP_SHARED 0x01 /* Share changes. */
+#define MAP_PRIVATE 0x02 /* Changes private; copy pages on write. */
+#define MAP_TYPE 0x0f /* Mask for sharing type. */
+
+/* Other flags. */
+#define MAP_FIXED 0x10 /* Map address must be exactly as requested. */
+/* The following three flags are not actually implemented in SunOS 4.1. */
+#define MAP_RENAME 0x20 /* Rename private pages to file. */
+#define MAP_NORESERVE 0x40 /* Don't reserve needed swap area. */
+#define MAP_INHERIT 0x80 /* Region is retained after exec. */
+
+/* This is an internal flag that is always set in `mmap' system calls. In
+ older versions of SunOS 4 `mmap' did not return the actual mapping
+ address, but always returned zero. This flag says to return the
+ address; the `mmap' C library function always sets it. */
+#define _MAP_NEW 0x80000000
+
+/* Advice to `madvise'. */
+#define MADV_NORMAL 0 /* No further special treatment. */
+#define MADV_RANDOM 1 /* Expect random page references. */
+#define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
+#define MADV_WILLNEED 3 /* Will need these pages. */
+#define MADV_DONTNEED 4 /* Don't need these pages. */
+
+/* Flags to `msync'. */
+#define MS_ASYNC 0x1 /* Return immediately, don't fsync. */
+#define MS_INVALIDATE 0x2 /* Invalidate caches. */
+
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+/* Map addresses starting near ADDR and extending for LEN bytes. from
+ OFFSET into the file FD describes according to PROT and FLAGS. If ADDR
+ is nonzero, it is the desired mapping address. If the MAP_FIXED bit is
+ set in FLAGS, the mapping will be at ADDR exactly (which must be
+ page-aligned); otherwise the system chooses a convenient nearby address.
+ The return value is the actual mapping address chosen or (caddr_t) -1
+ for errors (in which case `errno' is set). A successful `mmap' call
+ deallocates any previous mapping for the affected region. */
+
+__caddr_t mmap __P ((__caddr_t __addr, size_t __len,
+ int __prot, int __flags, int __fd, __off_t __offset));
+
+/* Deallocate any mapping for the region starting at ADDR and extending LEN
+ bytes. Returns 0 if successful, -1 for errors (and sets errno). */
+int munmap __P ((__caddr_t __addr, size_t __len));
+
+/* Change the memory protection of the region starting at ADDR and
+ extending LEN bytes to PROT. Returns 0 if successful, -1 for errors
+ (and sets errno). */
+int mprotect __P ((__caddr_t __addr, size_t __len, int __prot));
+
+/* Synchronize the region starting at ADDR and extending LEN bytes with the
+ file it maps. Filesystem operations on a file being mapped are
+ unpredictable before this is done. */
+int msync __P ((__caddr_t __addr, size_t __len, int __flags));
+
+/* Advise the system about particular usage patterns the program follows
+ for the region starting at ADDR and extending LEN bytes. */
+int madvise __P ((__caddr_t __addr, size_t __len, int __advice));
+
+__END_DECLS
+
+
+#endif /* sys/mman.h */
diff --git a/sysdeps/unix/bsd/sun/sunos4/sys_mmap.S b/sysdeps/unix/bsd/sun/sunos4/sys_mmap.S
new file mode 100644
index 0000000..61fe877
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/sys_mmap.S
@@ -0,0 +1,22 @@
+/* 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. */
+
+#include <sysdep.h>
+
+PSEUDO (__mmap_syscall, mmap, 5)
+ ret
diff --git a/sysdeps/unix/bsd/sun/sunos4/sys_wait4.S b/sysdeps/unix/bsd/sun/sunos4/sys_wait4.S
new file mode 100644
index 0000000..6b796b7
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/sys_wait4.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+PSEUDO (__wait4_syscall, wait4, 4)
+ ret
diff --git a/sysdeps/unix/bsd/sun/sunos4/system.c b/sysdeps/unix/bsd/sun/sunos4/system.c
new file mode 100644
index 0000000..2c8e634
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/system.c
@@ -0,0 +1,2 @@
+/* SunOS 4 does have `waitpid'. Avoid unix/system.c, which says we don't. */
+#include <sysdeps/posix/system.c>
diff --git a/sysdeps/unix/bsd/sun/sunos4/tcflow.c b/sysdeps/unix/bsd/sun/sunos4/tcflow.c
new file mode 100644
index 0000000..bb9a7fc
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/tcflow.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+/* Suspend or restart transmission on FD. */
+int
+DEFUN(tcflow, (fd, action), int fd AND int action)
+{
+ return __ioctl (fd, TCXONC, action);
+}
diff --git a/sysdeps/unix/bsd/sun/sunos4/tcflush.c b/sysdeps/unix/bsd/sun/sunos4/tcflush.c
new file mode 100644
index 0000000..d76fc07
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/tcflush.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+/* Flush pending data on FD. */
+int
+DEFUN(tcflush, (fd, queue_selector), int fd AND int queue_selector)
+{
+ return __ioctl (fd, TCFLSH, queue_selector);
+}
diff --git a/sysdeps/unix/bsd/sun/sunos4/tcgetattr.c b/sysdeps/unix/bsd/sun/sunos4/tcgetattr.c
new file mode 100644
index 0000000..5e45037
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/tcgetattr.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+/* Put the state of FD into *TERMIOS_P. */
+int
+DEFUN(__tcgetattr, (fd, termios_p),
+ int fd AND struct termios *termios_p)
+{
+ return __ioctl (fd, TCGETS, termios_p);
+}
+
+weak_alias (__tcgetattr, tcgetattr)
diff --git a/sysdeps/unix/bsd/sun/sunos4/tcsendbrk.c b/sysdeps/unix/bsd/sun/sunos4/tcsendbrk.c
new file mode 100644
index 0000000..7a6d5cc
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/tcsendbrk.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+#include <sys/termio.h> /* Sun header file. */
+
+/* Send zero bits on FD. */
+int
+DEFUN(tcsendbreak, (fd, duration), int fd AND int duration)
+{
+ /* According to SunOS 4.1's termios(4), you can't specify a duration. */
+ return __ioctl (fd, TCSBRK, 0);
+}
diff --git a/sysdeps/unix/bsd/sun/sunos4/tcsetattr.c b/sysdeps/unix/bsd/sun/sunos4/tcsetattr.c
new file mode 100644
index 0000000..4ae139a
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/tcsetattr.c
@@ -0,0 +1,49 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+/* Set the state of FD to *TERMIOS_P. */
+int
+DEFUN(tcsetattr, (fd, optional_actions, termios_p),
+ int fd AND int optional_actions AND CONST struct termios *termios_p)
+{
+ int cmd;
+
+ switch (optional_actions)
+ {
+ case TCSANOW:
+ cmd = TCSETS;
+ break;
+ case TCSADRAIN:
+ cmd = TCSETSW;
+ break;
+ case TCSAFLUSH:
+ cmd = TCSETSF;
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+ return __ioctl (fd, cmd, termios_p);
+}
diff --git a/sysdeps/unix/bsd/sun/sunos4/termbits.h b/sysdeps/unix/bsd/sun/sunos4/termbits.h
new file mode 100644
index 0000000..b768dea
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/termbits.h
@@ -0,0 +1,208 @@
+/* termios type and macro definitions. SunOS 4 version.
+Copyright (C) 1993, 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. */
+
+/* Type of terminal control flag masks. */
+typedef unsigned long int tcflag_t;
+
+/* Type of control characters. */
+typedef unsigned char cc_t;
+
+/* Type of baud rate specifiers. */
+typedef unsigned int speed_t;
+
+/* Terminal control structure. */
+struct termios
+{
+ /* Input modes. */
+ tcflag_t c_iflag;
+#define IGNBRK 0x0001 /* Ignore break condition. */
+#define BRKINT 0x0002 /* Signal interrupt on break. */
+#define IGNPAR 0x0004 /* Ignore characters with parity errors. */
+#define PARMRK 0x0008 /* Mark parity and framing errors. */
+#define INPCK 0x0010 /* Enable input parity check. */
+#define ISTRIP 0x0020 /* Strip 8th bit off characters. */
+#define INLCR 0x0040 /* Map NL to CR on input. */
+#define IGNCR 0x0080 /* Ignore CR. */
+#define ICRNL 0x0100 /* Map CR to NL on input. */
+#ifdef __USE_BSD
+#define IUCLC 0x0200 /* Map upper case to lower case on input. */
+#endif
+#define IXON 0x0400 /* Enable start/stop output control. */
+#define IXOFF 0x1000 /* Enable start/stop input control. */
+#ifdef __USE_BSD
+#define IXANY 0x0800 /* Any character will restart after stop. */
+#define IMAXBEL 0x2000 /* Ring bell when input queue is full. */
+#endif
+
+ /* Output modes. */
+ tcflag_t c_oflag;
+#define OPOST 0x0001 /* Perform output processing. */
+#ifdef __USE_BSD
+#define OLCUC 0x00000002 /* Map lower case to upper case on output. */
+#define ONLCR 0x00000004 /* Map NL to CR-NL on output. */
+#define OCRNL 0x00000008
+#define ONOCR 0x00000010
+#define ONLRET 0x00000020
+#define OFILL 0x00000040
+#define OFDEL 0x00000080
+#define NLDLY 0x00000100
+#define NL0 0
+#define NL1 0x00000100
+#define CRDLY 0x00000600
+#define CR0 0
+#define CR1 0x00000200
+#define CR2 0x00000400
+#define CR3 0x00000600
+#define TABDLY 0x00001800
+#define TAB0 0
+#define TAB1 0x00000800
+#define TAB2 0x00001000
+#define XTABS 0x00001800
+#define TAB3 XTABS
+#define BSDLY 0x00002000
+#define BS0 0
+#define BS1 0x00002000
+#define VTDLY 0x00004000
+#define VT0 0
+#define VT1 0x00004000
+#define FFDLY 0x00008000
+#define FF0 0
+#define FF1 0x00008000
+#define PAGEOUT 0x00010000
+#define WRAP 0x00020000
+#endif
+
+ /* Control modes. */
+ tcflag_t c_cflag;
+#define CSIZE (CS5|CS6|CS7|CS8) /* Number of bits per byte (mask). */
+#define CS5 0 /* 5 bits per byte. */
+#define CS6 0x00000010 /* 6 bits per byte. */
+#define CS7 0x00000020 /* 7 bits per byte. */
+#define CS8 0x00000030 /* 8 bits per byte. */
+#define CSTOPB 0x00000040 /* Two stop bits instead of one. */
+#define CREAD 0x00000080 /* Enable receiver. */
+#define PARENB 0x00000100 /* Parity enable. */
+#define PARODD 0x00000200 /* Odd parity instead of even. */
+#define HUPCL 0x00000400 /* Hang up on last close. */
+#define CLOCAL 0x00000800 /* Ignore modem status lines. */
+#ifdef __USE_BSD
+#define LOBLK 0x00001000
+#define CRTSCTS 0x80000000
+#define CIBAUD 0x000f0000 /* Mask for input speed from c_cflag. */
+#define CBAUD 0x0000000f /* Mask for output speed from c_cflag. */
+#define IBSHIFT 16 /* Bits to shift for input speed. */
+#endif
+
+ /* Input and output baud rates. These are encoded in c_cflag. */
+#define B0 0
+#define B50 1
+#define B75 2
+#define B110 3
+#define B134 4
+#define B150 5
+#define B200 6
+#define B300 7
+#define B600 8
+#define B1200 9
+#define B1800 10
+#define B2400 11
+#define B4800 12
+#define B9600 13
+#define B19200 14
+#define B38400 15
+#ifdef __USE_BSD
+#define EXTA 14
+#define EXTB 15
+#endif
+
+ /* Local modes. */
+ tcflag_t c_lflag;
+#ifdef __USE_BSD
+#define ECHOKE 0x00000800 /* Visual erase for KILL. */
+#endif
+#define ECHOE 0x00000010 /* Visual erase for ERASE. */
+#define ECHOK 0x00000020 /* Echo NL after KILL. */
+#define ECHO 0x00000008 /* Enable echo. */
+#define ECHONL 0x00000040 /* Echo NL even if ECHO is off. */
+#ifdef __USE_BSD
+#define ECHOPRT 0x00000400 /* Hardcopy visual erase. */
+#define ECHOCTL 0x00000200 /* Echo control characters as ^X. */
+#endif
+#define ISIG 0x00000001 /* Enable signals. */
+#define ICANON 0x00000002 /* Do erase and kill processing. */
+#define IEXTEN 0x00008000 /* Enable DISCARD and LNEXT. */
+#define TOSTOP 0x00000100 /* Send SIGTTOU for background output. */
+#ifdef __USE_BSD
+#define PENDIN 0x00004000 /* Retype pending input (state). */
+#endif
+#define NOFLSH 0x00000080 /* Disable flush after interrupt. */
+
+ char c_line; /* Line discipline (?) */
+
+ /* Control characters. */
+#define VEOF 4 /* End-of-file character [ICANON]. */
+#define VEOL 5 /* End-of-line character [ICANON]. */
+#ifdef __USE_BSD
+#define VEOL2 6 /* Second EOL character [ICANON]. */
+#define VSWTCH 7 /* ??? */
+#endif
+#define VERASE 2 /* Erase character [ICANON]. */
+#ifdef __USE_BSD
+#define VWERASE 14 /* Word-erase character [ICANON]. */
+#endif
+#define VKILL 3 /* Kill-line character [ICANON]. */
+#ifdef __USE_BSD
+#define VREPRINT 12 /* Reprint-line character [ICANON]. */
+#endif
+#define VINTR 0 /* Interrupt character [ISIG]. */
+#define VQUIT 1 /* Quit character [ISIG]. */
+#define VSUSP 10 /* Suspend character [ISIG]. */
+#ifdef __USE_BSD
+#define VDSUSP 11 /* Delayed suspend character [ISIG]. */
+#endif
+#define VSTART 8 /* Start (X-ON) character [IXON, IXOFF]. */
+#define VSTOP 9 /* Stop (X-OFF) character [IXON, IXOFF]. */
+#ifdef __USE_BSD
+#define VLNEXT 15 /* Literal-next character [IEXTEN]. */
+#define VDISCARD 13 /* Discard character [IEXTEN]. */
+#endif
+#define VMIN VEOF /* Minimum number of bytes read at once [!ICANON]. */
+#define VTIME VEOL /* Time-out value (tenths of a second) [!ICANON]. */
+#define NCCS 17
+ cc_t c_cc[NCCS];
+};
+
+#define _IOT_termios /* Hurd ioctl type field. */ \
+ _IOT (_IOTS (cflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)
+
+/* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'. */
+#define TCSANOW 0 /* Change immediately. */
+#define TCSADRAIN 1 /* Change when pending output is written. */
+#define TCSAFLUSH 2 /* Flush pending input before changing. */
+
+/* Values for the QUEUE_SELECTOR argument to `tcflush'. */
+#define TCIFLUSH 0 /* Discard data received but not yet read. */
+#define TCOFLUSH 1 /* Discard data written but not yet sent. */
+#define TCIOFLUSH 2 /* Discard all pending data. */
+
+/* Values for the ACTION argument to `tcflow'. */
+#define TCOOFF 0 /* Suspend output. */
+#define TCOON 1 /* Restart suspended output. */
+#define TCIOFF 2 /* Send a STOP character. */
+#define TCION 3 /* Send a START character. */
diff --git a/sysdeps/unix/bsd/sun/sunos4/uname.S b/sysdeps/unix/bsd/sun/sunos4/uname.S
new file mode 100644
index 0000000..488eeb1
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/uname.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/uname.S>
diff --git a/sysdeps/unix/bsd/sun/sunos4/utsnamelen.h b/sysdeps/unix/bsd/sun/sunos4/utsnamelen.h
new file mode 100644
index 0000000..e9111b6
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/utsnamelen.h
@@ -0,0 +1,2 @@
+#define _UTSNAME_LENGTH 9
+#define _UTSNAME_NODENAME_LENGTH 65
diff --git a/sysdeps/unix/bsd/sun/sunos4/wait.c b/sysdeps/unix/bsd/sun/sunos4/wait.c
new file mode 100644
index 0000000..79d5458
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/wait.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/wait.c>
diff --git a/sysdeps/unix/bsd/sun/sunos4/wait3.c b/sysdeps/unix/bsd/sun/sunos4/wait3.c
new file mode 100644
index 0000000..0b3bdee
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/wait3.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/wait3.c>
diff --git a/sysdeps/unix/bsd/sun/sunos4/wait4.c b/sysdeps/unix/bsd/sun/sunos4/wait4.c
new file mode 100644
index 0000000..919cd7c
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/wait4.c
@@ -0,0 +1,50 @@
+/* This implements wait4 with the 4.4 BSD semantics (also those documented in
+ SunOS 4.1) on top of SunOS's wait4 system call, which has semantics
+ different from those documented. Go Sun!
+
+Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+extern pid_t __wait4_syscall __P ((pid_t pid, __WAIT_STATUS_DEFN stat_loc,
+ int options, struct rusage *usage));
+
+pid_t
+DEFUN(__wait4, (pid, stat_loc, options, usage),
+ pid_t pid AND __WAIT_STATUS_DEFN stat_loc AND
+ int options AND struct rusage *usage)
+{
+ switch (pid)
+ {
+ case WAIT_ANY:
+ pid = 0;
+ break;
+
+ case WAIT_MYPGRP:
+ pid = - getpgrp ();
+ break;
+ }
+
+ return __wait4_syscall (pid, stat_loc, options, usage);
+}
+
+weak_alias (__wait4, wait4)
diff --git a/sysdeps/unix/bsd/sun/sunos4/waitpid.c b/sysdeps/unix/bsd/sun/sunos4/waitpid.c
new file mode 100644
index 0000000..8378982
--- /dev/null
+++ b/sysdeps/unix/bsd/sun/sunos4/waitpid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/waitpid.c>
diff --git a/sysdeps/unix/bsd/sys/reboot.h b/sysdeps/unix/bsd/sys/reboot.h
new file mode 100644
index 0000000..c3c957e
--- /dev/null
+++ b/sysdeps/unix/bsd/sys/reboot.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)reboot.h 8.1 (Berkeley) 6/2/93
+ */
+
+/*
+ * Arguments to reboot system call.
+ * These are passed to boot program in r11,
+ * and on to init.
+ */
+#define RB_AUTOBOOT 0 /* flags for system auto-booting itself */
+
+#define RB_ASKNAME 0x01 /* ask for file name to reboot from */
+#define RB_SINGLE 0x02 /* reboot to single user only */
+#define RB_NOSYNC 0x04 /* dont sync before reboot */
+#define RB_HALT 0x08 /* don't reboot, just halt */
+#define RB_INITNAME 0x10 /* name given for /etc/init (unused) */
+#define RB_DFLTROOT 0x20 /* use compiled-in rootdev */
+#define RB_KDB 0x40 /* give control to kernel debugger */
+#define RB_RDONLY 0x80 /* mount root fs read-only */
+#define RB_DUMP 0x100 /* dump kernel memory before reboot */
+#define RB_MINIROOT 0x200 /* mini-root present in memory at boot time */
+
+/*
+ * Constants for converting boot-style device number to type,
+ * adaptor (uba, mba, etc), unit number and partition number.
+ * Type (== major device number) is in the low byte
+ * for backward compatibility. Except for that of the "magic
+ * number", each mask applies to the shifted value.
+ * Format:
+ * (4) (4) (4) (4) (8) (8)
+ * --------------------------------
+ * |MA | AD| CT| UN| PART | TYPE |
+ * --------------------------------
+ */
+#define B_ADAPTORSHIFT 24
+#define B_ADAPTORMASK 0x0f
+#define B_ADAPTOR(val) (((val) >> B_ADAPTORSHIFT) & B_ADAPTORMASK)
+#define B_CONTROLLERSHIFT 20
+#define B_CONTROLLERMASK 0xf
+#define B_CONTROLLER(val) (((val)>>B_CONTROLLERSHIFT) & B_CONTROLLERMASK)
+#define B_UNITSHIFT 16
+#define B_UNITMASK 0xf
+#define B_UNIT(val) (((val) >> B_UNITSHIFT) & B_UNITMASK)
+#define B_PARTITIONSHIFT 8
+#define B_PARTITIONMASK 0xff
+#define B_PARTITION(val) (((val) >> B_PARTITIONSHIFT) & B_PARTITIONMASK)
+#define B_TYPESHIFT 0
+#define B_TYPEMASK 0xff
+#define B_TYPE(val) (((val) >> B_TYPESHIFT) & B_TYPEMASK)
+
+#define B_MAGICMASK ((u_long)0xf0000000)
+#define B_DEVMAGIC ((u_long)0xa0000000)
+
+#define MAKEBOOTDEV(type, adaptor, controller, unit, partition) \
+ (((type) << B_TYPESHIFT) | ((adaptor) << B_ADAPTORSHIFT) | \
+ ((controller) << B_CONTROLLERSHIFT) | ((unit) << B_UNITSHIFT) | \
+ ((partition) << B_PARTITIONSHIFT) | B_DEVMAGIC)
diff --git a/sysdeps/unix/bsd/tahoe/Implies b/sysdeps/unix/bsd/tahoe/Implies
new file mode 100644
index 0000000..a7ecf58
--- /dev/null
+++ b/sysdeps/unix/bsd/tahoe/Implies
@@ -0,0 +1 @@
+unix/bsd/vax
diff --git a/sysdeps/unix/bsd/tahoe/sysdep.h b/sysdeps/unix/bsd/tahoe/sysdep.h
new file mode 100644
index 0000000..b875906
--- /dev/null
+++ b/sysdeps/unix/bsd/tahoe/sysdep.h
@@ -0,0 +1,5 @@
+/* The Tahoe is just like the Vax, except the
+ `chmk' instruction is called `kcall'. */
+
+#define chmk kcall
+#include <sysdeps/unix/bsd/vax/sysdep.h>
diff --git a/sysdeps/unix/bsd/tcdrain.c b/sysdeps/unix/bsd/tcdrain.c
new file mode 100644
index 0000000..c9ed18d
--- /dev/null
+++ b/sysdeps/unix/bsd/tcdrain.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <termios.h>
+#include <unistd.h>
+
+#include "bsdtty.h"
+
+/* Wait for pending output to be written on FD. */
+int
+DEFUN(tcdrain, (fd), int fd)
+{
+ /* The TIOCSETP control waits for pending output to be written before
+ affecting its changes, so we use that without changing anything. */
+ struct sgttyb b;
+ if (__ioctl(fd, TIOCGETP, (PTR) &b) < 0 ||
+ __ioctl(fd, TIOCSETP, (PTR) &b) < 0)
+ return -1;
+ return 0;
+}
diff --git a/sysdeps/unix/bsd/tcflow.c b/sysdeps/unix/bsd/tcflow.c
new file mode 100644
index 0000000..06de144
--- /dev/null
+++ b/sysdeps/unix/bsd/tcflow.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <termios.h>
+#include <unistd.h>
+
+#include "bsdtty.h"
+
+/* Suspend or restart transmission on FD. */
+int
+DEFUN(tcflow, (fd, action), int fd AND int action)
+{
+ switch (action)
+ {
+ case TCOOFF:
+ return __ioctl(fd, TIOCSTOP, (PTR) NULL);
+ case TCOON:
+ return __ioctl(fd, TIOCSTART, (PTR) NULL);
+
+ case TCIOFF:
+ case TCION:
+ {
+ /* This just writes the START or STOP character with
+ `write'. Is there another way to do this? */
+ struct termios attr;
+ unsigned char c;
+ if (tcgetattr(fd, &attr) < 0)
+ return -1;
+ c = attr.c_cc[action == TCIOFF ? VSTOP : VSTART];
+ if (c != _POSIX_VDISABLE && write (fd, &c, 1) < 1)
+ return -1;
+ return 0;
+ }
+
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+}
diff --git a/sysdeps/unix/bsd/tcflush.c b/sysdeps/unix/bsd/tcflush.c
new file mode 100644
index 0000000..46454b8
--- /dev/null
+++ b/sysdeps/unix/bsd/tcflush.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <termios.h>
+#include <unistd.h>
+#include "bsdtty.h"
+#include <sys/file.h>
+
+/* Flush pending data on FD. */
+int
+DEFUN(tcflush, (fd, queue_selector), int fd AND int queue_selector)
+{
+ int arg;
+
+ switch (queue_selector)
+ {
+ case TCIFLUSH:
+ arg = FREAD;
+ break;
+ case TCOFLUSH:
+ arg = FWRITE;
+ break;
+ case TCIOFLUSH:
+ arg = FREAD | FWRITE;
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+ return __ioctl (fd, TIOCFLUSH, (PTR) &arg);
+}
diff --git a/sysdeps/unix/bsd/tcgetattr.c b/sysdeps/unix/bsd/tcgetattr.c
new file mode 100644
index 0000000..0e6e378
--- /dev/null
+++ b/sysdeps/unix/bsd/tcgetattr.c
@@ -0,0 +1,130 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <termios.h>
+
+#include "bsdtty.h"
+
+extern CONST speed_t __bsd_speeds[]; /* Defined in tcsetattr.c. */
+
+/* Put the state of FD into *TERMIOS_P. */
+int
+DEFUN(__tcgetattr, (fd, termios_p),
+ int fd AND struct termios *termios_p)
+{
+ struct sgttyb buf;
+ struct tchars tchars;
+ struct ltchars ltchars;
+ int local;
+#ifdef TIOCGETX
+ int extra;
+#endif
+
+ if (termios_p == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (__ioctl(fd, TIOCGETP, &buf) < 0 ||
+ __ioctl(fd, TIOCGETC, &tchars) < 0 ||
+ __ioctl(fd, TIOCGLTC, &ltchars) < 0 ||
+#ifdef TIOCGETX
+ __ioctl(fd, TIOCGETX, &extra) < 0 ||
+#endif
+ __ioctl(fd, TIOCLGET, &local) < 0)
+ return -1;
+
+ termios_p->__ispeed = __bsd_speeds[(unsigned char) buf.sg_ispeed];
+ termios_p->__ospeed = __bsd_speeds[(unsigned char) buf.sg_ospeed];
+
+ termios_p->c_iflag = 0;
+ termios_p->c_oflag = 0;
+ termios_p->c_cflag = 0;
+ termios_p->c_lflag = 0;
+ termios_p->c_oflag |= CREAD | HUPCL;
+#ifdef LPASS8
+ if (local & LPASS8)
+ termios_p->c_oflag |= CS8;
+ else
+#endif
+ termios_p->c_oflag |= CS7;
+ if (!(buf.sg_flags & RAW))
+ {
+ termios_p->c_iflag |= IXON;
+ termios_p->c_cflag |= OPOST;
+#ifndef NOISIG
+ termios_p->c_lflag |= ISIG;
+#endif
+ }
+ if ((buf.sg_flags & (CBREAK|RAW)) == 0)
+ termios_p->c_lflag |= ICANON;
+ if (!(buf.sg_flags & RAW) && !(local & LLITOUT))
+ termios_p->c_oflag |= OPOST;
+ if (buf.sg_flags & CRMOD)
+ termios_p->c_iflag |= ICRNL;
+ if (buf.sg_flags & TANDEM)
+ termios_p->c_iflag |= IXOFF;
+#ifdef TIOCGETX
+ if (!(extra & NOISIG))
+ termios_p->c_lflag |= ISIG;
+ if (extra & STOPB)
+ termios_p->c_cflag |= CSTOPB;
+#endif
+
+ switch (buf.sg_flags & (EVENP|ODDP))
+ {
+ case EVENP|ODDP:
+ break;
+ case ODDP:
+ termios_p->c_cflag |= PARODD;
+ default:
+ termios_p->c_cflag |= PARENB;
+ termios_p->c_iflag |= IGNPAR | INPCK;
+ break;
+ }
+ if (buf.sg_flags & ECHO)
+ termios_p->c_lflag |= _ECHO;
+ if (local & LCRTERA)
+ termios_p->c_lflag |= ECHOE;
+ if (local & LCRTKIL)
+ termios_p->c_lflag |= ECHOK;
+ if (local & LTOSTOP)
+ termios_p->c_lflag |= _TOSTOP;
+ if (local & LNOFLSH)
+ termios_p->c_lflag |= _NOFLSH;
+
+ termios_p->c_cc[VEOF] = tchars.t_eofc;
+ termios_p->c_cc[VEOL] = '\n';
+ termios_p->c_cc[VERASE] = buf.sg_erase;
+ termios_p->c_cc[VKILL] = buf.sg_kill;
+ termios_p->c_cc[VINTR] = tchars.t_intrc;
+ termios_p->c_cc[VQUIT] = tchars.t_quitc;
+ termios_p->c_cc[VSTART] = tchars.t_startc;
+ termios_p->c_cc[VSTOP] = tchars.t_stopc;
+ termios_p->c_cc[VSUSP] = ltchars.t_suspc;
+ termios_p->c_cc[VMIN] = -1;
+ termios_p->c_cc[VTIME] = -1;
+
+ return 0;
+}
+
+weak_alias (__tcgetattr, tcgetattr)
diff --git a/sysdeps/unix/bsd/tcgetpgrp.c b/sysdeps/unix/bsd/tcgetpgrp.c
new file mode 100644
index 0000000..b41f005
--- /dev/null
+++ b/sysdeps/unix/bsd/tcgetpgrp.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Return the foreground process group ID of FD. */
+pid_t
+DEFUN(tcgetpgrp, (fd), int fd)
+{
+ int pgrp;
+ if (__ioctl(fd, TIOCGPGRP, &pgrp) < 0)
+ return (pid_t) -1;
+ return (pid_t) pgrp;
+}
diff --git a/sysdeps/unix/bsd/tcsendbrk.c b/sysdeps/unix/bsd/tcsendbrk.c
new file mode 100644
index 0000000..574f442
--- /dev/null
+++ b/sysdeps/unix/bsd/tcsendbrk.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <signal.h>
+#include <termios.h>
+#include <unistd.h>
+#include "bsdtty.h"
+#include <sys/file.h>
+#include <sys/time.h>
+#include <sys/types.h>
+
+/* Send zero bits on FD. */
+int
+DEFUN(tcsendbreak, (fd, duration), int fd AND int duration)
+{
+ struct timeval delay;
+
+ /* The break lasts 0.25 to 0.5 seconds if DURATION is zero,
+ and an implementation-defined period if DURATION is nonzero.
+ We define a positive DURATION to be number of microseconds to break. */
+ if (duration <= 0)
+ duration = 400000;
+
+ delay.tv_sec = 0;
+ delay.tv_usec = duration;
+
+ /* Starting sending break. */
+ if (__ioctl (fd, TIOCSBRK, (PTR) NULL) < 0)
+ return -1;
+
+ /* Wait DURATION microseconds. */
+ (void) __select (0, (fd_set *) NULL, (fd_set *) NULL, (fd_set *) NULL,
+ &delay);
+
+ /* Turn off the break. */
+ return __ioctl (fd, TIOCCBRK, (PTR) NULL);
+}
diff --git a/sysdeps/unix/bsd/tcsetattr.c b/sysdeps/unix/bsd/tcsetattr.c
new file mode 100644
index 0000000..e731d83
--- /dev/null
+++ b/sysdeps/unix/bsd/tcsetattr.c
@@ -0,0 +1,186 @@
+/* Copyright (C) 1991, 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <termios.h>
+
+#include "bsdtty.h"
+
+
+CONST speed_t __bsd_speeds[] =
+ {
+ 0,
+ 50,
+ 75,
+ 110,
+ 134,
+ 150,
+ 200,
+ 300,
+ 600,
+ 1200,
+ 1800,
+ 2400,
+ 4800,
+ 9600,
+ 19200,
+ 38400,
+ };
+
+
+/* Set the state of FD to *TERMIOS_P. */
+int
+DEFUN(tcsetattr, (fd, optional_actions, termios_p),
+ int fd AND int optional_actions AND CONST struct termios *termios_p)
+{
+ struct sgttyb buf;
+ struct tchars tchars;
+ struct ltchars ltchars;
+ int local;
+#ifdef TIOCGETX
+ int extra;
+#endif
+ size_t i;
+
+ if (__ioctl(fd, TIOCGETP, &buf) < 0 ||
+ __ioctl(fd, TIOCGETC, &tchars) < 0 ||
+ __ioctl(fd, TIOCGLTC, &ltchars) < 0 ||
+#ifdef TIOCGETX
+ __ioctl(fd, TIOCGETX, &extra) < 0 ||
+#endif
+ __ioctl(fd, TIOCLGET, &local) < 0)
+ return -1;
+
+ if (termios_p == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ switch (optional_actions)
+ {
+ case TCSANOW:
+ break;
+ case TCSADRAIN:
+ if (tcdrain(fd) < 0)
+ return -1;
+ break;
+ case TCSAFLUSH:
+ if (tcflush(fd, TCIFLUSH) < 0)
+ return -1;
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+ buf.sg_ispeed = buf.sg_ospeed = -1;
+ for (i = 0; i <= sizeof (__bsd_speeds) / sizeof (__bsd_speeds[0]); ++i)
+ {
+ if (__bsd_speeds[i] == termios_p->__ispeed)
+ buf.sg_ispeed = i;
+ if (__bsd_speeds[i] == termios_p->__ospeed)
+ buf.sg_ospeed = i;
+ }
+ if (buf.sg_ispeed == -1 || buf.sg_ospeed == -1)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ buf.sg_flags &= ~(CBREAK|RAW);
+ if (!(termios_p->c_lflag & ICANON))
+ buf.sg_flags |= (termios_p->c_cflag & ISIG) ? CBREAK : RAW;
+#ifdef LPASS8
+ if (termios_p->c_oflag & CS8)
+ local |= LPASS8;
+ else
+ local &= ~LPASS8;
+#endif
+ if (termios_p->c_lflag & _NOFLSH)
+ local |= LNOFLSH;
+ else
+ local &= ~LNOFLSH;
+ if (termios_p->c_oflag & OPOST)
+ local &= ~LLITOUT;
+ else
+ local |= LLITOUT;
+#ifdef TIOCGETX
+ if (termios_p->c_lflag & ISIG)
+ extra &= ~NOISIG;
+ else
+ extra |= NOISIG;
+ if (termios_p->c_cflag & CSTOPB)
+ extra |= STOPB;
+ else
+ extra &= ~STOPB;
+#endif
+ if (termios_p->c_iflag & ICRNL)
+ buf.sg_flags |= CRMOD;
+ else
+ buf.sg_flags &= ~CRMOD;
+ if (termios_p->c_iflag & IXOFF)
+ buf.sg_flags |= TANDEM;
+ else
+ buf.sg_flags &= ~TANDEM;
+
+ buf.sg_flags &= ~(ODDP|EVENP);
+ if (!(termios_p->c_cflag & PARENB))
+ buf.sg_flags |= ODDP | EVENP;
+ else if (termios_p->c_cflag & PARODD)
+ buf.sg_flags |= ODDP;
+ else
+ buf.sg_flags |= EVENP;
+
+ if (termios_p->c_lflag & _ECHO)
+ buf.sg_flags |= ECHO;
+ else
+ buf.sg_flags &= ~ECHO;
+ if (termios_p->c_lflag & ECHOE)
+ local |= LCRTERA;
+ else
+ local &= ~LCRTERA;
+ if (termios_p->c_lflag & ECHOK)
+ local |= LCRTKIL;
+ else
+ local &= ~LCRTKIL;
+ if (termios_p->c_lflag & _TOSTOP)
+ local |= LTOSTOP;
+ else
+ local &= ~LTOSTOP;
+
+ buf.sg_erase = termios_p->c_cc[VERASE];
+ buf.sg_kill = termios_p->c_cc[VKILL];
+ tchars.t_eofc = termios_p->c_cc[VEOF];
+ tchars.t_intrc = termios_p->c_cc[VINTR];
+ tchars.t_quitc = termios_p->c_cc[VQUIT];
+ ltchars.t_suspc = termios_p->c_cc[VSUSP];
+ tchars.t_startc = termios_p->c_cc[VSTART];
+ tchars.t_stopc = termios_p->c_cc[VSTOP];
+
+ if (__ioctl(fd, TIOCSETP, &buf) < 0 ||
+ __ioctl(fd, TIOCSETC, &tchars) < 0 ||
+ __ioctl(fd, TIOCSLTC, &ltchars) < 0 ||
+#ifdef TIOCGETX
+ __ioctl(fd, TIOCSETX, &extra) < 0 ||
+#endif
+ __ioctl(fd, TIOCLSET, &local) < 0)
+ return -1;
+ return 0;
+}
diff --git a/sysdeps/unix/bsd/tcsetpgrp.c b/sysdeps/unix/bsd/tcsetpgrp.c
new file mode 100644
index 0000000..e5da8b3
--- /dev/null
+++ b/sysdeps/unix/bsd/tcsetpgrp.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <unistd.h>
+
+/* Set the foreground process group ID of FD set PGRP_ID. */
+int
+DEFUN(tcsetpgrp, (fd, pgrp_id), int fd AND pid_t pgrp_id)
+{
+ return __ioctl(fd, TIOCSPGRP, &pgrp_id);
+}
diff --git a/sysdeps/unix/bsd/telldir.c b/sysdeps/unix/bsd/telldir.c
new file mode 100644
index 0000000..0321f95
--- /dev/null
+++ b/sysdeps/unix/bsd/telldir.c
@@ -0,0 +1,93 @@
+/* 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <stdlib.h>
+
+/* Internal data structure for telldir and seekdir. */
+struct record
+ {
+ struct record *next; /* Link in chain. */
+ off_t cookie; /* Value returned by `telldir'. */
+ off_t pos;
+ size_t offset;
+ };
+#define NBUCKETS 32
+static struct record *records[32];
+static off_t lastpos;
+
+
+/* Return the current position of DIRP. */
+off_t
+DEFUN(telldir, (dirp), DIR *dirp)
+{
+ struct record *new;
+
+ new = malloc (sizeof *new);
+ if (new == NULL)
+ return (off_t) -1;
+
+ new->pos = dirp->__pos;
+ new->offset = dirp->__offset;
+ new->cookie = ++lastpos;
+ new->next = records[new->cookie % NBUCKETS];
+ records[new->cookie % NBUCKETS] = new;
+
+ return new->cookie;
+}
+
+
+
+/* Seek to position POS in DIRP. */
+void
+DEFUN(seekdir, (dirp, pos), DIR *dirp AND __off_t pos)
+{
+ struct record *r, **prevr;
+
+ for (prevr = &records[pos % NBUCKETS], r = *prevr;
+ r != NULL;
+ prevr = &r->next, r = r->next)
+ if (r->cookie == pos)
+ {
+ if (dirp->__pos != r->pos || dirp->__offset != r->offset)
+ {
+ dirp->__size = 0; /* Must read a fresh buffer. */
+ /* Move to the saved position. */
+ __lseek (dirp->__fd, r->pos, SEEK_SET);
+ dirp->__pos = r->pos;
+ dirp->__offset = 0;
+ /* Read entries until we reach the saved offset. */
+ while (dirp->__offset < r->offset)
+ if (readdir (dirp) == NULL)
+ break;
+ }
+
+ /* To prevent leaking memory, cookies returned from telldir
+ can only be used once. So free this one's record now. */
+ *prevr = r->next;
+ free (r);
+ return;
+ }
+
+ /* We lost, but have no way to indicate it. Oh well. */
+}
diff --git a/sysdeps/unix/bsd/time.c b/sysdeps/unix/bsd/time.c
new file mode 100644
index 0000000..8f8a46f
--- /dev/null
+++ b/sysdeps/unix/bsd/time.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <time.h>
+#include <sys/time.h>
+
+
+/* Return the current time as a `time_t' and also put it in *T if T is
+ not NULL. Time is represented as seconds from Jan 1 00:00:00 1970. */
+time_t
+DEFUN(time, (t), time_t *t)
+{
+ struct timeval tv;
+ time_t result;
+
+ if (__gettimeofday (&tv, (struct timezone *) NULL))
+ result = (time_t) -1;
+ else
+ result = (time_t) tv.tv_sec;
+
+ if (t != NULL)
+ *t = result;
+ return result;
+}
diff --git a/sysdeps/unix/bsd/times.c b/sysdeps/unix/bsd/times.c
new file mode 100644
index 0000000..edf3e90
--- /dev/null
+++ b/sysdeps/unix/bsd/times.c
@@ -0,0 +1,68 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/times.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+
+/* Time the program started. */
+extern time_t _posix_start_time;
+
+#ifdef __GNUC__
+__inline
+#endif
+static clock_t
+DEFUN(timeval_to_clock_t, (tv), CONST struct timeval *tv)
+{
+ return (clock_t) ((tv->tv_sec * CLK_TCK) +
+ (tv->tv_usec * CLK_TCK / 1000000L));
+}
+
+/* Store the CPU time used by this process and all its
+ dead children (and their dead children) in BUFFER.
+ Return the elapsed real time, or (clock_t) -1 for errors.
+ All times are in CLK_TCKths of a second. */
+clock_t
+DEFUN(__times, (buffer), struct tms *buffer)
+{
+ struct rusage usage;
+
+ if (buffer == NULL)
+ {
+ errno = EINVAL;
+ return (clock_t) -1;
+ }
+
+ if (__getrusage(RUSAGE_SELF, &usage) < 0)
+ return (clock_t) -1;
+ buffer->tms_utime = (clock_t) timeval_to_clock_t(&usage.ru_utime);
+ buffer->tms_stime = (clock_t) timeval_to_clock_t(&usage.ru_stime);
+
+ if (__getrusage(RUSAGE_CHILDREN, &usage) < 0)
+ return (clock_t) -1;
+ buffer->tms_cutime = (clock_t) timeval_to_clock_t(&usage.ru_utime);
+ buffer->tms_cstime = (clock_t) timeval_to_clock_t(&usage.ru_stime);
+
+ return (time((time_t *) NULL) - _posix_start_time) * CLK_TCK;
+}
+
+weak_alias (__times, times)
diff --git a/sysdeps/unix/bsd/ualarm.c b/sysdeps/unix/bsd/ualarm.c
new file mode 100644
index 0000000..8d8e01d
--- /dev/null
+++ b/sysdeps/unix/bsd/ualarm.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <sys/time.h>
+
+/* Set an alarm to go off (generating a SIGALRM signal) in VALUE microseconds.
+ If INTERVAL is nonzero, when the alarm goes off, the timer is reset to go
+ off every INTERVAL microseconds thereafter.
+
+ Returns the number of microseconds remaining before the alarm. */
+unsigned int
+DEFUN(ualarm, (value, interval),
+ unsigned int value AND unsigned int interval)
+{
+ struct itimerval timer, otimer;
+
+ timer.it_value.tv_sec = 0;
+ timer.it_value.tv_usec = value;
+ timer.it_interval.tv_sec = 0;
+ timer.it_interval.tv_usec = interval;
+
+ if (setitimer(ITIMER_REAL, &timer, &otimer) < 0)
+ return -1;
+
+ return (otimer.it_value.tv_sec * 1000) + otimer.it_value.tv_usec;
+}
diff --git a/sysdeps/unix/bsd/ulimit.c b/sysdeps/unix/bsd/ulimit.c
new file mode 100644
index 0000000..912faf4
--- /dev/null
+++ b/sysdeps/unix/bsd/ulimit.c
@@ -0,0 +1,86 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <sysdep.h>
+#include <sys/resource.h>
+#include <unistd.h>
+#include <errno.h>
+
+#ifndef HAVE_GNU_LD
+#define _etext etext
+#endif
+
+extern int _etext;
+
+/* Function depends on CMD:
+ 1 = Return the limit on the size of a file, in units of 512 bytes.
+ 2 = Set the limit on the size of a file to NEWLIMIT. Only the
+ super-user can increase the limit.
+ 3 = Return the maximum possible address of the data segment.
+ 4 = Return the maximum number of files that the calling process
+ can open.
+ Returns -1 on errors. */
+long int
+DEFUN(ulimit, (cmd, newlimit),
+ int cmd AND long int newlimit)
+{
+ int status;
+
+ switch (cmd)
+ {
+ case 1:
+ {
+ /* Get limit on file size. */
+ struct rlimit fsize;
+
+ status = getrlimit(RLIMIT_FSIZE, &fsize);
+ if (status < 0)
+ return -1;
+
+ /* Convert from bytes to 512 byte units. */
+ return fsize.rlim_cur / 512;
+ }
+ case 2:
+ /* Set limit on file size. */
+ {
+ struct rlimit fsize;
+ fsize.rlim_cur = newlimit * 512;
+ fsize.rlim_max = newlimit * 512;
+
+ return setrlimit(RLIMIT_FSIZE, &fsize);
+ }
+ case 3:
+ /* Get maximum address for `brk'. */
+ {
+ struct rlimit dsize;
+
+ status = getrlimit(RLIMIT_DATA, &dsize);
+ if (status < 0)
+ return -1;
+
+ return ((long int) &_etext) + dsize.rlim_cur;
+ }
+ case 4:
+ return sysconf(_SC_OPEN_MAX);
+
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+}
diff --git a/sysdeps/unix/bsd/ultrix4/Dist b/sysdeps/unix/bsd/ultrix4/Dist
new file mode 100644
index 0000000..6745cd4
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/Dist
@@ -0,0 +1 @@
+getsysinfo.S
diff --git a/sysdeps/unix/bsd/ultrix4/Implies b/sysdeps/unix/bsd/ultrix4/Implies
new file mode 100644
index 0000000..b0e08ef
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/Implies
@@ -0,0 +1,2 @@
+# Ultrix 4 has the canonical set of <sys/mman.h> system calls.
+unix/mman
diff --git a/sysdeps/unix/bsd/ultrix4/Makefile b/sysdeps/unix/bsd/ultrix4/Makefile
new file mode 100644
index 0000000..26b9034
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),posix)
+sysdep_routines := $(sysdep_routines) getsysinfo
+endif
diff --git a/sysdeps/unix/bsd/ultrix4/fcntlbits.h b/sysdeps/unix/bsd/ultrix4/fcntlbits.h
new file mode 100644
index 0000000..bf8e7b2
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/fcntlbits.h
@@ -0,0 +1,125 @@
+/* O_*, F_*, FD_* bit values for Ultrix 4.
+Copyright (C) 1991, 1992 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 _FCNTLBITS_H
+
+#define _FCNTLBITS_H 1
+
+
+/* File access modes for `open' and `fcntl'. */
+#define O_RDONLY 0 /* Open read-only. */
+#define O_WRONLY 1 /* Open write-only. */
+#define O_RDWR 2 /* Open read/write. */
+
+
+/* Bits OR'd into the second argument to open. */
+#define O_CREAT 0x0200 /* Create file if it doesn't exist. */
+#define O_EXCL 0x0800 /* Fail if file already exists. */
+#define O_TRUNC 0x0400 /* Truncate file to zero length. */
+#ifdef __USE_MISC
+#define O_ASYNC 0x0040 /* Send SIGIO to owner when data is ready. */
+#define O_FSYNC 0x8000 /* Synchronous writes. */
+#define O_SYNC O_FSYNC
+#define O_BLKINUSE 0x1000 /* Block if "in use". */
+#define O_BLKANDSET 0x3000 /* Block, test and set "in use" flag. */
+#define O_TERMIO 0x40000 /* "termio style program". */
+#endif
+#define O_NOCTTY 0x80000 /* Don't assign a controlling terminal. */
+
+/* File status flags for `open' and `fcntl'. */
+#define O_APPEND 0x0008 /* Writes append to the file. */
+#define O_NONBLOCK 0x20000 /* Non-blocking I/O. */
+
+#ifdef __USE_BSD
+#define O_NDELAY 0x0004
+#endif
+
+#ifdef __USE_BSD
+/* Bits in the file status flags returned by F_GETFL.
+ These are all the O_* flags, plus FREAD and FWRITE, which are
+ independent bits set by which of O_RDONLY, O_WRONLY, and O_RDWR, was
+ given to `open'. */
+#define FREAD 1
+#define FWRITE 2
+
+/* Traditional BSD names the O_* bits. */
+#define FASYNC O_ASYNC
+#define FCREAT O_CREAT
+#define FEXCL O_EXCL
+#define FTRUNC O_TRUNC
+#define FNOCTTY O_NOCTTY
+#define FFSYNC O_FSYNC
+#define FSYNC O_SYNC
+#define FAPPEND O_APPEND
+#define FNONBLOCK O_NONBLOCK
+#define FNDELAY O_NDELAY
+#define FNBLOCK O_NONBLOCK
+#define FTERMIO O_TERMIO
+#define FNOCTTY O_NOCTTY
+#define FSYNCRON O_FSYNC
+#define FBLKINUSE O_BLKINUSE
+#define FBLKANDSET O_BLKANDSET
+#endif
+
+/* Mask for file access modes. This is system-dependent in case
+ some system ever wants to define some other flavor of access. */
+#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
+
+/* Values for the second argument to `fcntl'. */
+#define F_DUPFD 0 /* Duplicate file descriptor. */
+#define F_GETFD 1 /* Get file descriptor flags. */
+#define F_SETFD 2 /* Set file descriptor flags. */
+#define F_GETFL 3 /* Get file status flags. */
+#define F_SETFL 4 /* Set file status flags. */
+#ifdef __USE_BSD
+#define F_GETOWN 5 /* Get owner (receiver of SIGIO). */
+#define F_SETOWN 6 /* Set owner (receiver of SIGIO). */
+#endif
+#define F_GETLK 7 /* Get record locking info. */
+#define F_SETLK 8 /* Set record locking info (non-blocking). */
+#define F_SETLKW 9 /* Set record locking info (blocking). */
+#ifdef __USE_MISC
+#define F_SETSYN 10 /* Set synchronous writing. */
+#define F_CLRSYN 10 /* Clear synchronous writing. */
+#endif
+
+/* File descriptor flags used with F_GETFD and F_SETFD. */
+#define FD_CLOEXEC 1 /* Close on exec. */
+
+
+#include <gnu/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. */
+struct flock
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+
+/* Values for the `l_type' field of a `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/getdents.S b/sysdeps/unix/bsd/ultrix4/getdents.S
new file mode 100644
index 0000000..be449b2
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/getdents.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/sun/getdents.S>
diff --git a/sysdeps/unix/bsd/ultrix4/getsysinfo.S b/sysdeps/unix/bsd/ultrix4/getsysinfo.S
new file mode 100644
index 0000000..1f5b2cf
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/getsysinfo.S
@@ -0,0 +1,25 @@
+/* Copyright (C) 1992 Free Software Foundation, Inc.
+ Contributed by Ian Lance Taylor (ian@airs.com).
+
+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. */
+
+/* Get various sorts of information about the system.
+ This is an Ultrix only call. */
+
+#include <sysdep.h>
+
+SYSCALL__ (getsysinfo, 5)
+ ret
diff --git a/sysdeps/unix/bsd/ultrix4/mips/Dist b/sysdeps/unix/bsd/ultrix4/mips/Dist
new file mode 100644
index 0000000..c2e8abb
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/mips/Dist
@@ -0,0 +1 @@
+sigtramp.c __handler.S
diff --git a/sysdeps/unix/bsd/ultrix4/mips/Makefile b/sysdeps/unix/bsd/ultrix4/mips/Makefile
new file mode 100644
index 0000000..0b71fd9
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/mips/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),signal)
+sysdep_routines := $(sysdep_routines) sigtramp __handler
+endif
diff --git a/sysdeps/unix/bsd/ultrix4/mips/__handler.S b/sysdeps/unix/bsd/ultrix4/mips/__handler.S
new file mode 100644
index 0000000..3ea697c
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/mips/__handler.S
@@ -0,0 +1,113 @@
+/* Copyright (C) 1992 Free Software Foundation, Inc.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+ Also hacked by Ian Lance Taylor (ian@airs.com).
+
+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. */
+
+#include <sysdep.h>
+
+/* This function saves all the registers, calls the
+ user function, and then executes a sigreturn system call. The
+ sigreturn call wants the address of a sigcontext structure. This
+ is all hideously system dependent and, for all intents and
+ purposes, undocumented.
+
+ When we enter here, a3 holds the user's signal handler. We are
+ supposed to fill in the context given in a2, and then pass it and
+ the first two arguments to the user's function. If the user's
+ function returns, we execute a sigreturn system call.
+
+ The sc_onstack, sc_mask and sc_pc elements of the context are
+ already set by the kernel. For some reason we don't have to save
+ the floating point state or the coprocessor state; the kernel may
+ have saved them for us, or it doesn't use them. */
+
+.set noat
+ENTRY (__handler)
+ /* Store zero and the asm temp reg. */
+ sw $0, 12(a2)
+ sw AT, 16(a2)
+
+ /* Put v1 in sc_regs[3]. */
+ sw v1, 24(a2)
+
+ /* Save the caller saved registers in sc_regs[8..15]. */
+ sw t0, 44(a2)
+ sw t1, 48(a2)
+ sw t2, 52(a2)
+ sw t3, 56(a2)
+ sw t4, 60(a2)
+ sw t5, 64(a2)
+ sw t6, 68(a2)
+ sw t7, 72(a2)
+
+ /* Save the callee saved registers in sc_regs[16..23]. */
+ sw s0, 76(a2)
+ sw s1, 80(a2)
+ sw s2, 84(a2)
+ sw s3, 88(a2)
+ sw s4, 92(a2)
+ sw s5, 96(a2)
+ sw s6, 100(a2)
+ sw s7, 104(a2)
+
+ /* Save the code generator registers in sc_regs[24] & sc_regs[25]. */
+ sw t8, 108(a2)
+ sw t9, 112(a2)
+
+ /* Save the kernel temp regs in sc_regs[26] & sc_regs[27]. */
+ sw k0, 116(a2)
+ sw k1, 120(a2)
+
+ /* Save the global pointer in sc_regs[28]. */
+ sw gp, 124(a2)
+
+ /* ... and also the return address in sc_regs[31]. */
+ sw ra, 136(a2)
+
+ /* Note: we don't save the stack pointer in sc_regs[29];
+ instead, we use the one that was already there. */
+#if 0
+ sw sp, 128(a2)
+#endif
+
+ /* Save the floating pointer in sc_regs[30]. */
+ sw $fp, 132(a2)
+
+ /* Save the mul/div stuff in sc_mdlo and sc_mdhi. */
+ mflo t0
+ sw t0, 140(a2)
+ mfhi t0
+ sw t0, 144(a2)
+
+ /* Move the stack up four. This will save the context. */
+ addu sp, sp, -32
+ sw a2, 16(sp)
+
+ /* Call their handler with the signal, code, and context; note
+ this will clobber the context. */
+ .set noreorder
+ jal ra, a3
+ nop
+ .set reorder
+
+ /* When we come back, restore the context and pass it right
+ on into sigreturn(). */
+ lw a0, 16(sp)
+
+ /* Do a sigreturn syscall; this doesn't return. */
+ la v0, __sigreturn
+ jal ra, v0
diff --git a/sysdeps/unix/bsd/ultrix4/mips/sigcontext.h b/sysdeps/unix/bsd/ultrix4/mips/sigcontext.h
new file mode 100644
index 0000000..4bddcf2
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/mips/sigcontext.h
@@ -0,0 +1,60 @@
+/* Copyright (C) 1992, 1994 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. */
+
+/* Note that ANY change to this instantly implies a change to __handler.S. */
+
+struct sigcontext
+ {
+ /* Nonzero if running on signal stack. */
+ int sc_onstack;
+
+ /* Signal mask to restore. */
+ __sigset_t sc_mask;
+
+ /* Program counter when the signal hit. */
+ __ptr_t sc_pc;
+
+ /* Registers 0 through 31. */
+ int sc_regs[32];
+
+ /* mul/div low and hi; these aren't part of a jmp_buf, but are part of the
+ sigcontext and are referenced from the signal trampoline code. */
+ int sc_mdlo;
+ int sc_mdhi;
+
+ /* Flag to see if the FP's been used. */
+ int sc_ownedfp;
+
+ /* Floating point registers 0 to 31. */
+ int sc_fpregs[32];
+ /* Control & status register for FP. */
+ int sc_fpc_csr;
+
+ /* Exception instruction register for FP. */
+ int sc_fpc_eir;
+
+ /* The coprocessor's cause register. */
+ int sc_cause;
+
+ /* CPU bad virtual address. */
+ __ptr_t sc_badvaddr;
+
+ /* CPU board bad physical address. */
+ __ptr_t sc_badpaddr;
+ };
+
diff --git a/sysdeps/unix/bsd/ultrix4/mips/sigtramp.c b/sysdeps/unix/bsd/ultrix4/mips/sigtramp.c
new file mode 100644
index 0000000..1bb208d
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/mips/sigtramp.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1992 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. */
+
+/* The sigvec system call on MIPS Ultrix takes an additional
+ parameter, which is the address that is actually called when the
+ signal occurs.
+
+ When a signal occurs, we arrange for the kernel to call __handler.
+ That will save the frame and stack pointers into the context, and
+ then jump to this routine. See __handler.S.
+
+ This code is based on sysdeps/unix/bsd/sun4/sigtramp.c, but it's
+ different because since we get passed the user signal handler we
+ don't actually need a trampoline. */
+
+#include <ansidecl.h>
+#include <signal.h>
+#include <stddef.h>
+#include <errno.h>
+
+/* The user's signal handler is called with three arguments. */
+typedef void (*handler_type) (int sig, int code, struct sigcontext *);
+
+/* Defined in __raw_sigvec.S. */
+extern int EXFUN(__raw_sigvec, (int sig, CONST struct sigvec *vec,
+ struct sigvec *ovec,
+ void (*)(int sig, int code,
+ struct sigcontext *,
+ handler_type)));
+
+extern void EXFUN(__handler, (int sig, int code,
+ struct sigcontext *,
+ handler_type));
+
+int
+DEFUN(__sigvec, (sig, vec, ovec),
+ int sig AND CONST struct sigvec *vec AND struct sigvec *ovec)
+{
+ return __raw_sigvec (sig, vec, ovec, __handler);
+}
diff --git a/sysdeps/unix/bsd/ultrix4/mips/sigvec.S b/sysdeps/unix/bsd/ultrix4/mips/sigvec.S
new file mode 100644
index 0000000..20a5dd1
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/mips/sigvec.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+/* __sigvec is defined by sigtramp.c. */
+
+PSEUDO (__raw_sigvec, sigvec, 3)
+ ret
diff --git a/sysdeps/unix/bsd/ultrix4/mips/start.S b/sysdeps/unix/bsd/ultrix4/mips/start.S
new file mode 100644
index 0000000..ec0f9d8
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/mips/start.S
@@ -0,0 +1,77 @@
+/* Copyright (C) 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. */
+
+#include <sysdep.h>
+
+#ifndef HAVE_WEAK_SYMBOLS
+#define __environ environ
+#else
+weak_alias (__environ, environ)
+#endif
+
+.comm __environ, 4
+.comm errno, 4
+
+ENTRY(__start)
+ .set noreorder
+
+ /* The first thing on the stack is argc. */
+ lw s0, 0(sp)
+ nop
+
+ /* Set up the global pointer. */
+ la gp, _gp
+
+ /* Then set up argv. */
+ addiu s1, sp, 4
+
+ /* To compute where envp is, first we have to jump ahead four
+ bytes from what argv was. This will bring us ahead, so we don't
+ need to compute the NULL at the end of argv later. */
+ addiu v1, s1, 4
+
+ /* Now, compute the space to skip given the number of arguments
+ we've got. We do this by multiplying argc by 4. */
+ sll v0, s0, 2
+
+ /* Now, add (argv+4) with the space to skip...that's envp. */
+ addu s2, v1, v0
+
+ /* __environ = envp; */
+ sw s2, __environ
+
+ addiu sp, sp, -24
+
+ /* __libc_init (argc, argv, envp); */
+ move a0, s0
+ move a1, s1
+ jal __libc_init
+ move a2, s2
+
+ /* errno = 0; */
+ sw zero, errno
+
+ /* exit (main (argc, argv, envp)); */
+ move a0, s0
+ move a1, s1
+ jal main
+ move a2, s2
+
+ /* Make the value returned by main be the argument to exit. */
+ jal exit
+ move a0, v0
diff --git a/sysdeps/unix/bsd/ultrix4/mips/vfork.S b/sysdeps/unix/bsd/ultrix4/mips/vfork.S
new file mode 100644
index 0000000..37f6d80
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/mips/vfork.S
@@ -0,0 +1,33 @@
+/* Copyright (C) 1992, 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. */
+
+#include <sysdep.h>
+
+#ifndef SYS_vfork
+#define SYS_vfork 66
+#endif
+
+SYSCALL__ (vfork, 0)
+ beq v1, zero, parent /* Branch if parent. */
+ nop
+ move v0, zero
+parent:
+ ret
+ nop
+
+weak_alias (__vfork, vfork)
diff --git a/sysdeps/unix/bsd/ultrix4/posix_opt.h b/sysdeps/unix/bsd/ultrix4/posix_opt.h
new file mode 100644
index 0000000..ecd04d1
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/posix_opt.h
@@ -0,0 +1,23 @@
+/* Copyright (C) 1992 Free Software Foundation, Inc.
+ Contributed by Ian Lance Taylor (ian@airs.com).
+
+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. */
+
+#define _POSIX_JOB_CONTROL 1
+#define _POSIX_SAVED_IDS 1
+#define _POSIX_CHOWN_RESTRICTED 1
+#define _POSIX_NO_TRUNC 1
+#define _POSIX_VDISABLE ((unsigned char) -1)
diff --git a/sysdeps/unix/bsd/ultrix4/setsid.S b/sysdeps/unix/bsd/ultrix4/setsid.S
new file mode 100644
index 0000000..4930c56
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/setsid.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/setsid.S>
diff --git a/sysdeps/unix/bsd/ultrix4/sys/mman.h b/sysdeps/unix/bsd/ultrix4/sys/mman.h
new file mode 100644
index 0000000..c850b4f
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/sys/mman.h
@@ -0,0 +1,99 @@
+/* Definitions for BSD-style memory management. Ultrix 4 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. */
+
+/* These are the bits used by 4.4 BSD and its derivatives. On systems
+ (such as GNU) where these facilities are not system services but can be
+ emulated in the C library, these are the definitions we emulate. */
+
+#ifndef _SYS_MMAN_H
+
+#define _SYS_MMAN_H 1
+#include <features.h>
+
+#include <gnu/types.h>
+#define __need_size_t
+#include <stddef.h>
+
+
+/* Protections are chosen from these bits, OR'd together. The
+ implementation does not necessarily support PROT_EXEC or PROT_WRITE
+ without PROT_READ. The only guarantees are that no writing will be
+ allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
+
+#define PROT_NONE 0x00 /* No access. */
+#define PROT_READ 0x01 /* Pages can be read. */
+#define PROT_WRITE 0x02 /* Pages can be written. */
+#define PROT_EXEC 0x04 /* Pages can be executed. */
+
+
+/* Sharing types (must choose one and only one of these). */
+#define MAP_SHARED 0x01 /* Share changes. */
+#define MAP_PRIVATE 0x02 /* Changes private; copy pages on write. */
+#define MAP_TYPE 0x0f /* Mask for sharing type. */
+
+/* Other flags. */
+#define MAP_FIXED 0x10 /* Map address must be exactly as requested. */
+
+/* Advice to `madvise'. */
+#define MADV_NORMAL 0 /* No further special treatment. */
+#define MADV_RANDOM 1 /* Expect random page references. */
+#define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
+#define MADV_WILLNEED 3 /* Will need these pages. */
+#define MADV_DONTNEED 4 /* Don't need these pages. */
+
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+/* Map addresses starting near ADDR and extending for LEN bytes. from
+ OFFSET into the file FD describes according to PROT and FLAGS. If ADDR
+ is nonzero, it is the desired mapping address. If the MAP_FIXED bit is
+ set in FLAGS, the mapping will be at ADDR exactly (which must be
+ page-aligned); otherwise the system chooses a convenient nearby address.
+ The return value is the actual mapping address chosen or (caddr_t) -1
+ for errors (in which case `errno' is set). A successful `mmap' call
+ deallocates any previous mapping for the affected region. */
+
+__caddr_t mmap __P ((__caddr_t __addr, size_t __len,
+ int __prot, int __flags, int __fd, off_t __offset));
+
+/* Deallocate any mapping for the region starting at ADDR and extending LEN
+ bytes. Returns 0 if successful, -1 for errors (and sets errno). */
+int munmap __P ((__caddr_t __addr, size_t __len));
+
+/* Change the memory protection of the region starting at ADDR and
+ extending LEN bytes to PROT. Returns 0 if successful, -1 for errors
+ (and sets errno). */
+int mprotect __P ((__caddr_t __addr, size_t __len, int __prot));
+
+/* Ultrix 4 does not implement `msync' or `madvise'. */
+
+/* Synchronize the region starting at ADDR and extending LEN bytes with the
+ file it maps. Filesystem operations on a file being mapped are
+ unpredictable before this is done. */
+int msync __P ((caddr_t __addr, size_t __len));
+
+/* Advise the system about particular usage patterns the program follows
+ for the region starting at ADDR and extending LEN bytes. */
+int madvise __P ((__caddr_t __addr, size_t __len, int __advice));
+
+__END_DECLS
+
+
+#endif /* sys/mman.h */
diff --git a/sysdeps/unix/bsd/ultrix4/sysconf.c b/sysdeps/unix/bsd/ultrix4/sysconf.c
new file mode 100644
index 0000000..a9f3c5b
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/sysconf.c
@@ -0,0 +1,61 @@
+/* Copyright (C) 1992, 1995 Free Software Foundation, Inc.
+ Contributed by Ian Lance Taylor (ian@airs.com).
+
+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. */
+
+/* On Ultrix we can use the getsysinfo call to get the right return
+ value for _SC_CHILD_MAX. Everything else is from <sys/param.h>,
+ which the default sysconf already knows how to handle. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <errno.h>
+
+/* This is an Ultrix header file. */
+#include <sys/sysinfo.h>
+
+extern int EXFUN(__getsysinfo, (unsigned int op, void *buffer,
+ size_t nbytes, int *start,
+ void *arg));
+extern long int EXFUN(__default_sysconf, (int name));
+
+long int
+DEFUN(__sysconf, (name), int name)
+{
+ if (name == _SC_CHILD_MAX)
+ {
+ int save = errno;
+ int start = 0;
+ int ret;
+
+ /* getsysinfo returns the number of values it put into the
+ buffer, or 0 if not available, or -1 on error. */
+ if (__getsysinfo (GSI_MAX_UPROCS, &ret, sizeof (ret), &start,
+ (void *) 0) > 0)
+ {
+ errno = save;
+ return ret;
+ }
+
+ errno = save;
+ }
+
+ return __default_sysconf (name);
+}
+
+#define __sysconf __default_sysconf
+
+#include <sysdeps/posix/sysconf.c>
diff --git a/sysdeps/unix/bsd/ultrix4/system.c b/sysdeps/unix/bsd/ultrix4/system.c
new file mode 100644
index 0000000..b133fe7
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/system.c
@@ -0,0 +1,2 @@
+/* Ultrix 4 does have `waitpid'. Avoid unix/system.c, which says we don't. */
+#include <sysdeps/posix/system.c>
diff --git a/sysdeps/unix/bsd/ultrix4/uname.S b/sysdeps/unix/bsd/ultrix4/uname.S
new file mode 100644
index 0000000..488eeb1
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/uname.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/uname.S>
diff --git a/sysdeps/unix/bsd/ultrix4/utsnamelen.h b/sysdeps/unix/bsd/ultrix4/utsnamelen.h
new file mode 100644
index 0000000..ad4389a
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/utsnamelen.h
@@ -0,0 +1 @@
+#define _UTSNAME_LENGTH 32
diff --git a/sysdeps/unix/bsd/ultrix4/wait3.S b/sysdeps/unix/bsd/ultrix4/wait3.S
new file mode 100644
index 0000000..83910a5
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/wait3.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (wait3, 3)
+ ret
+
+weak_alias (__wait3, wait3)
diff --git a/sysdeps/unix/bsd/ultrix4/waitpid.S b/sysdeps/unix/bsd/ultrix4/waitpid.S
new file mode 100644
index 0000000..b64e528
--- /dev/null
+++ b/sysdeps/unix/bsd/ultrix4/waitpid.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (waitpid, 3)
+ ret
+
+weak_alias (__waitpid, waitpid)
diff --git a/sysdeps/unix/bsd/usleep.c b/sysdeps/unix/bsd/usleep.c
new file mode 100644
index 0000000..850233a
--- /dev/null
+++ b/sysdeps/unix/bsd/usleep.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
+/* Sleep USECONDS microseconds, or until a previously set timer goes off. */
+unsigned int
+DEFUN(usleep, (useconds), unsigned int useconds)
+{
+ struct timeval delay;
+
+ delay.tv_sec = 0;
+ delay.tv_usec = useconds;
+
+ (void) __select (0, (fd_set *) NULL, (fd_set *) NULL, (fd_set *) NULL,
+ &delay);
+
+ return 0;
+}
diff --git a/sysdeps/unix/bsd/utime.c b/sysdeps/unix/bsd/utime.c
new file mode 100644
index 0000000..c7ed20f
--- /dev/null
+++ b/sysdeps/unix/bsd/utime.c
@@ -0,0 +1,50 @@
+/* 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. */
+
+#include <ansidecl.h>
+#include <sysdep.h>
+#include <errno.h>
+#include <utime.h>
+#include <time.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
+
+/* Set the access and modification times of FILE to those given in TIMES.
+ If TIMES is NULL, set them to the current time. */
+int
+DEFUN(utime, (file, times), CONST char *file AND CONST struct utimbuf *times)
+{
+ struct timeval timevals[2];
+
+ if (times != NULL)
+ {
+ timevals[0].tv_sec = (long int) times->actime;
+ timevals[0].tv_usec = 0L;
+ timevals[1].tv_sec = (long int) times->modtime;
+ timevals[1].tv_usec = 0L;
+ }
+ else
+ {
+ if (__gettimeofday (&timevals[0], NULL) < 0)
+ return -1;
+ timevals[1] = timevals[0];
+ }
+
+ return __utimes (file, timevals);
+}
diff --git a/sysdeps/unix/bsd/utimes.S b/sysdeps/unix/bsd/utimes.S
new file mode 100644
index 0000000..2f700b0
--- /dev/null
+++ b/sysdeps/unix/bsd/utimes.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (utimes, 2)
+ ret
+
+weak_alias (__utimes, utimes)
diff --git a/sysdeps/unix/bsd/vax/brk.S b/sysdeps/unix/bsd/vax/brk.S
new file mode 100644
index 0000000..b3e8e10
--- /dev/null
+++ b/sysdeps/unix/bsd/vax/brk.S
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991, 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. */
+
+#include <sysdep.h>
+
+#ifndef SYS_brk
+#define SYS_brk 17
+#endif
+
+#ifndef HAVE_GNU_LD
+#define __end _end
+#endif
+
+.data
+.globl ___curbrk
+___curbrk:
+ .long __end
+
+.text
+ENTRY (__brk)
+ cmpl 4(ap), __end
+ bgeq 0f
+ movl __env, 4(ap)
+0: chmk $SYS_brk
+ bcs 1f
+ movl 4(ap), ___curbrk
+ clrl r0
+ ret
+1:
+ jmp syscall_error
+
+weak_alias (__brk, brk)
diff --git a/sysdeps/unix/bsd/vax/pipe.S b/sysdeps/unix/bsd/vax/pipe.S
new file mode 100644
index 0000000..10c681a
--- /dev/null
+++ b/sysdeps/unix/bsd/vax/pipe.S
@@ -0,0 +1,28 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (pipe, 1)
+ movl 4(ap), r2
+ movl r0, (r2)+
+ movl r1, (r2)
+ clrl r0
+ ret
+
+weak_alias (__pipe, pipe)
diff --git a/sysdeps/unix/bsd/vax/sysdep.S b/sysdeps/unix/bsd/vax/sysdep.S
new file mode 100644
index 0000000..618d889
--- /dev/null
+++ b/sysdeps/unix/bsd/vax/sysdep.S
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#define _ERRNO_H
+#include <errnos.h>
+
+.globl _errno
+.globl syscall_error
+syscall_error:
+#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
+ /* We translate the system's EWOULDBLOCK error into EAGAIN.
+ The GNU C library always defines EWOULDBLOCK==EAGAIN.
+ EWOULDBLOCK_sys is the original number. */
+ cmpl r0, $EWOULDBLOCK_sys
+ bne 0f
+ movl $EAGAIN, r0
+#endif
+0: movl r0, _errno
+ mnegl $1, r0
+ ret
diff --git a/sysdeps/unix/bsd/vax/sysdep.h b/sysdeps/unix/bsd/vax/sysdep.h
new file mode 100644
index 0000000..aeddad9
--- /dev/null
+++ b/sysdeps/unix/bsd/vax/sysdep.h
@@ -0,0 +1,55 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdeps/unix/sysdep.h>
+
+#ifdef ASSEMBLER
+
+#ifdef __STDC__
+#define ENTRY(name) \
+ .globl _##name; \
+ .even; \
+ _##name##:
+#else
+#define ENTRY(name) \
+ .globl _/**/name; \
+ .even; \
+ _/**/name/**/:
+#endif
+
+#ifdef __STDC__
+#define PSEUDO(name, syscall_name, args) \
+ .even; \
+ .globl syscall_error \
+ error: jmp syscall_error; \
+ ENTRY (name) \
+ chmk $SYS_##syscall_name \
+ bcs error
+#else
+#define PSEUDO(name, syscall_name, args) \
+ .even; \
+ .globl syscall_error \
+ error: jmp syscall_error; \
+ ENTRY (name) \
+ chmk $SYS_/**/syscall_name \
+ bcs error
+#endif
+
+#define MOVE(x,y) movl x , y
+
+#endif /* ASSEMBLER */
diff --git a/sysdeps/unix/bsd/vax/wait.S b/sysdeps/unix/bsd/vax/wait.S
new file mode 100644
index 0000000..77311b4
--- /dev/null
+++ b/sysdeps/unix/bsd/vax/wait.S
@@ -0,0 +1,27 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (wait, 1)
+ movl 4(ap), r2
+ beq 1f
+ movl r1, (r2)
+1: ret
+
+weak_alias (__wait, wait)
diff --git a/sysdeps/unix/bsd/vax/wait3.S b/sysdeps/unix/bsd/vax/wait3.S
new file mode 100644
index 0000000..2d8dba8
--- /dev/null
+++ b/sysdeps/unix/bsd/vax/wait3.S
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+ENTRY(___wait3)
+ movel 8(ap), r1
+ movel 12(ap), r0
+ /* Set all condition codes to tell the kernel this is wait3. */
+ bispsw $15
+ chmk $SYS_wait
+ bcs error
+
+ movl 4(ap), r2
+ beq 1f
+ movl r1, (r2)
+1: ret
+
+.globl syscall_error
+error: jmp syscall_error
+
+weak_alias (__wait3, wait3)
diff --git a/sysdeps/unix/bsd/waitflags.h b/sysdeps/unix/bsd/waitflags.h
new file mode 100644
index 0000000..52e4f80
--- /dev/null
+++ b/sysdeps/unix/bsd/waitflags.h
@@ -0,0 +1,28 @@
+/* Definitions of flag bits for `waitpid' et al.
+Copyright (C) 1992 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 _WAITFLAGS_H
+
+#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/unix/chdir.S b/sysdeps/unix/chdir.S
new file mode 100644
index 0000000..38d6b88
--- /dev/null
+++ b/sysdeps/unix/chdir.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (chdir, 1)
+ ret
+
+weak_alias (__chdir, chdir)
diff --git a/sysdeps/unix/chmod.S b/sysdeps/unix/chmod.S
new file mode 100644
index 0000000..b8654eb
--- /dev/null
+++ b/sysdeps/unix/chmod.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (chmod, 2)
+ ret
+
+weak_alias (__chmod, chmod)
diff --git a/sysdeps/unix/chown.S b/sysdeps/unix/chown.S
new file mode 100644
index 0000000..83442b4
--- /dev/null
+++ b/sysdeps/unix/chown.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (chown, 3)
+ ret
+
+weak_alias (__chown, chown)
diff --git a/sysdeps/unix/chroot.S b/sysdeps/unix/chroot.S
new file mode 100644
index 0000000..37802cc
--- /dev/null
+++ b/sysdeps/unix/chroot.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (chroot, 1)
+ ret
diff --git a/sysdeps/unix/close.S b/sysdeps/unix/close.S
new file mode 100644
index 0000000..5b0a698
--- /dev/null
+++ b/sysdeps/unix/close.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (close, 1)
+ ret
+
+weak_alias (__close, close)
diff --git a/sysdeps/unix/closedir.c b/sysdeps/unix/closedir.c
new file mode 100644
index 0000000..e01dccb
--- /dev/null
+++ b/sysdeps/unix/closedir.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991, 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <unistd.h>
+
+/* Close the directory stream DIRP.
+ Return 0 if successful, -1 if not. */
+int
+DEFUN(closedir, (dirp), DIR *dirp)
+{
+ int fd;
+
+ if (dirp == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ fd = dirp->__fd;
+
+ free ((PTR) dirp->__data);
+ free ((PTR) dirp);
+
+ return __close (fd);
+}
+
diff --git a/sysdeps/unix/common/.cvsignore b/sysdeps/unix/common/.cvsignore
new file mode 100644
index 0000000..1f69fd9
--- /dev/null
+++ b/sysdeps/unix/common/.cvsignore
@@ -0,0 +1,4 @@
+*.gz *.Z *.tar *.tgz
+=*
+TODO COPYING* AUTHORS copyr-* copying.*
+glibc-*
diff --git a/sysdeps/unix/common/Dist b/sysdeps/unix/common/Dist
new file mode 100644
index 0000000..0c47cab
--- /dev/null
+++ b/sysdeps/unix/common/Dist
@@ -0,0 +1 @@
+glue-ctype.c
diff --git a/sysdeps/unix/common/Makefile b/sysdeps/unix/common/Makefile
new file mode 100644
index 0000000..5c338a2
--- /dev/null
+++ b/sysdeps/unix/common/Makefile
@@ -0,0 +1,35 @@
+# Copyright (C) 1991, 1992, 1993, 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.
+
+ifndef inhibit-glue
+ifeq ($(subdir),ctype)
+
+sysdep_routines := $(sysdep_routines) ctype-glue
+
+generated := $(generated) glue-ctype ctype-glue.c
+
+$(objpfx)ctype-glue.c: $(objpfx)glue-ctype
+ @rm -f $@
+ $(dir $<)$(notdir $<) > $@-t
+ mv $@-t $@
+
+$(objpfx)glue-ctype: $(sysdep_dir)/unix/common/glue-ctype.c
+ $(native-compile)
+
+endif
+endif
diff --git a/sysdeps/unix/common/access.S b/sysdeps/unix/common/access.S
new file mode 100644
index 0000000..ec0f3c9
--- /dev/null
+++ b/sysdeps/unix/common/access.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (access, 2)
+ ret
+
+weak_alias (__access, access)
diff --git a/sysdeps/unix/common/adjtime.S b/sysdeps/unix/common/adjtime.S
new file mode 100644
index 0000000..af080a7
--- /dev/null
+++ b/sysdeps/unix/common/adjtime.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (adjtime, 2)
+ ret
+
+weak_alias (__adjtime, adjtime)
diff --git a/sysdeps/unix/common/configure b/sysdeps/unix/common/configure
new file mode 100755
index 0000000..b01c547
--- /dev/null
+++ b/sysdeps/unix/common/configure
@@ -0,0 +1,101 @@
+
+if test -z "$inhibit_glue"; then
+
+# Find out what this system calls `sys_siglist'.
+echo $ac_n "checking for sys_siglist""... $ac_c" 1>&4
+if eval "test \"`echo '${'ac_cv_check_symbol_sys_siglist'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&4
+else
+ cat > conftest.$ac_ext <<EOF
+#line 11 "configure"
+#include "confdefs.h"
+
+int main() { return 0; }
+int t() {
+extern char *sys_siglist[]; puts(*sys_siglist);
+; return 0; }
+EOF
+if eval $ac_link; then
+ rm -rf conftest*
+ ac_cv_check_symbol_sys_siglist=yes
+else
+ rm -rf conftest*
+ ac_cv_check_symbol_sys_siglist=no
+fi
+rm -f conftest*
+
+fi
+
+if test "$ac_cv_check_symbol_sys_siglist" = yes; then
+ ac_tr_symbol=`echo sys_siglist | tr '[a-z]' '[A-Z]'`
+ cat >> confdefs.h <<EOF
+#define HAVE_${ac_tr_symbol} 1
+EOF
+
+fi
+echo "$ac_t""$ac_cv_check_symbol_sys_siglist" 1>&4
+echo $ac_n "checking for _sys_siglist""... $ac_c" 1>&4
+if eval "test \"`echo '${'ac_cv_check_symbol__sys_siglist'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&4
+else
+ cat > conftest.$ac_ext <<EOF
+#line 43 "configure"
+#include "confdefs.h"
+
+int main() { return 0; }
+int t() {
+extern char *_sys_siglist[]; puts(*_sys_siglist);
+; return 0; }
+EOF
+if eval $ac_link; then
+ rm -rf conftest*
+ ac_cv_check_symbol__sys_siglist=yes
+else
+ rm -rf conftest*
+ ac_cv_check_symbol__sys_siglist=no
+fi
+rm -f conftest*
+
+fi
+
+if test "$ac_cv_check_symbol__sys_siglist" = yes; then
+ ac_tr_symbol=`echo _sys_siglist | tr '[a-z]' '[A-Z]'`
+ cat >> confdefs.h <<EOF
+#define HAVE_${ac_tr_symbol} 1
+EOF
+
+fi
+echo "$ac_t""$ac_cv_check_symbol__sys_siglist" 1>&4
+
+# Find out the name of the table the system's <ctype.h> uses for character
+# classification. This is used by sysdeps/unix/common/glue-ctype.c.
+echo $ac_n "checking ctype array name for glue""... $ac_c" 1>&4
+if eval "test \"`echo '${'libc_cv_ctype_glue'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&4
+else
+ for ctype in _ctype_ __ctype_ __ctype _ctype__ _ctype _locp; do
+cat > conftest.$ac_ext <<EOF
+#line 79 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+int main() { return 0; }
+int t() {
+$ctype[13];
+; return 0; }
+EOF
+if eval $ac_link; then
+ rm -rf conftest*
+ libc_cv_ctype_glue="$ctype"; break
+fi
+rm -f conftest*
+
+done
+fi
+
+echo "$ac_t""$libc_cv_ctype_glue" 1>&4
+cat >> confdefs.h <<EOF
+#define HAVE_`echo $libc_cv_ctype_glue | tr 'a-z' 'A-Z'` 1
+EOF
+
+
+fi
diff --git a/sysdeps/unix/common/configure.in b/sysdeps/unix/common/configure.in
new file mode 100644
index 0000000..807c446
--- /dev/null
+++ b/sysdeps/unix/common/configure.in
@@ -0,0 +1,22 @@
+sinclude(./aclocal.m4)dnl
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+
+if test -z "$inhibit_glue"; then
+
+# Find out what this system calls `sys_siglist'.
+AC_CHECK_SYMBOL(sys_siglist)
+AC_CHECK_SYMBOL(_sys_siglist)
+
+# Find out the name of the table the system's <ctype.h> uses for character
+# classification. This is used by sysdeps/unix/common/glue-ctype.c.
+AC_MSG_CHECKING(ctype array name for glue)
+AC_CACHE_VAL(libc_cv_ctype_glue, [dnl
+for ctype in _ctype_ __ctype_ __ctype _ctype__ _ctype _locp; do
+AC_TRY_LINK([#include <ctype.h>],
+ [$ctype[13];],
+ [libc_cv_ctype_glue="$ctype"; break])
+done])
+AC_MSG_RESULT($libc_cv_ctype_glue)
+AC_DEFINE_UNQUOTED(HAVE_`echo $libc_cv_ctype_glue | tr '[a-z]' '[A-Z]'`)
+
+fi
diff --git a/sysdeps/unix/common/direct.h b/sysdeps/unix/common/direct.h
new file mode 100644
index 0000000..ef88147
--- /dev/null
+++ b/sysdeps/unix/common/direct.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 1992, 1993 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 _BSDDIR_H
+#define _BSDDIR_H 1
+
+#include <limits.h>
+
+/* This is what system V calls a "struct dirent". */
+
+struct direct
+ {
+ unsigned long int d_fileno;
+ long int d_off;
+ unsigned short int d_reclen;
+ char d_name[NAME_MAX + 1];
+ };
+
+#include <stddef.h>
+
+/* We calculate the length of the name by taking the length of the whole
+ `struct direct' record, subtracting the size of everything before the
+ name, and subtracting one for the terminating null. */
+
+#define D_NAMLEN(d) \
+ ((d)->d_reclen - offsetof (struct direct, d_name) - 1)
+
+#endif
diff --git a/sysdeps/unix/common/dup2.S b/sysdeps/unix/common/dup2.S
new file mode 100644
index 0000000..77bcaaf
--- /dev/null
+++ b/sysdeps/unix/common/dup2.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (dup2, 2)
+ ret
+
+weak_alias (__dup2, dup2)
diff --git a/sysdeps/unix/common/fchmod.S b/sysdeps/unix/common/fchmod.S
new file mode 100644
index 0000000..9319648
--- /dev/null
+++ b/sysdeps/unix/common/fchmod.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (fchmod, 2)
+ ret
+
+weak_alias (__fchmod, fchmod)
diff --git a/sysdeps/unix/common/fchown.S b/sysdeps/unix/common/fchown.S
new file mode 100644
index 0000000..bb05e05
--- /dev/null
+++ b/sysdeps/unix/common/fchown.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (fchown, 3)
+ ret
+
+weak_alias (__fchown, fchown)
diff --git a/sysdeps/unix/common/fcntlbits.h b/sysdeps/unix/common/fcntlbits.h
new file mode 100644
index 0000000..0f84433
--- /dev/null
+++ b/sysdeps/unix/common/fcntlbits.h
@@ -0,0 +1,122 @@
+/* O_*, F_*, FD_* bit values for SVR4 and Irix 4.
+Copyright (C) 1991, 1992, 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. */
+
+#ifndef _FCNTLBITS_H
+
+#define _FCNTLBITS_H 1
+
+
+/* File access modes for `open' and `fcntl'. */
+#define O_RDONLY 0 /* Open read-only. */
+#define O_WRONLY 1 /* Open write-only. */
+#define O_RDWR 2 /* Open read/write. */
+
+
+/* Bits OR'd into the second argument to open. */
+#define O_CREAT 0x0100 /* Create file if it doesn't exist. */
+#define O_EXCL 0x0400 /* Fail if file already exists. */
+#define O_TRUNC 0x0200 /* Truncate file to zero length. */
+#define O_NOCTTY 0x0800 /* Don't assign a controlling terminal. */
+#ifdef __USE_MISC
+#define O_ASYNC 0x0040 /* Send SIGIO to owner when data is ready. */
+#define O_FSYNC 0x0010 /* Synchronous writes. */
+#define O_SYNC O_FSYNC
+#endif
+
+/* File status flags for `open' and `fcntl'. */
+#define O_APPEND 0x0008 /* Writes append to the file. */
+#define O_NONBLOCK 0x0080 /* Non-blocking I/O. */
+
+#ifdef __USE_MISC
+#define O_NDELAY 0x0004
+#endif
+
+#ifdef __USE_MISC
+/* Bits in the file status flags returned by F_GETFL.
+ These are all the O_* flags, plus FREAD and FWRITE, which are
+ independent bits set by which of O_RDONLY, O_WRONLY, and O_RDWR, was
+ given to `open'. */
+#define FREAD 1
+#define FWRITE 2
+
+/* Traditional Unix names the O_* bits. */
+#define FASYNC O_ASYNC
+#define FCREAT O_CREAT
+#define FEXCL O_EXCL
+#define FTRUNC O_TRUNC
+#define FNOCTTY O_NOCTTY
+#define FFSYNC O_FSYNC
+#define FSYNC O_SYNC
+#define FAPPEND O_APPEND
+#define FNONBLOCK O_NONBLOCK
+#define FNONBIO O_NONBLOCK
+#define FNDELAY O_NDELAY
+#endif
+
+/* Mask for file access modes. This is system-dependent in case
+ some system ever wants to define some other flavor of access. */
+#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
+
+/* Values for the second argument to `fcntl'. */
+#define F_DUPFD 0 /* Duplicate file descriptor. */
+#define F_GETFD 1 /* Get file descriptor flags. */
+#define F_SETFD 2 /* Set file descriptor flags. */
+#define F_GETFL 3 /* Get file status flags. */
+#define F_SETFL 4 /* Set file status flags. */
+#ifdef __USE_BSD
+#define F_GETOWN 23 /* Get owner (receiver of SIGIO). */
+#define F_SETOWN 24 /* Set owner (receiver of SIGIO). */
+#endif
+#define F_GETLK 14 /* Get record locking info. */
+#define F_SETLK 6 /* Set record locking info (non-blocking). */
+#define F_SETLKW 7 /* Set record locking info (blocking). */
+#ifdef __USE_SVID
+#define F_ALLOCSP 10 /* Allocate space in the file. */
+#define F_FREESP 11 /* Free space in the file. */
+#define F_RGETLK 20 /* Get remote record locking info. */
+#define F_RSETLK 21 /* Set remote locking info (non-blocking). */
+#define F_RSETLKW 22 /* Set remote locking info (blocking). */
+#endif
+
+/* File descriptor flags used with F_GETFD and F_SETFD. */
+#define FD_CLOEXEC 1 /* Close on exec. */
+
+
+#include <gnu/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. */
+struct flock
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+ long int l_sysid; /* System ID where locking process resides. */
+ __pid_t l_pid; /* Process holding the lock. */
+ long int pad[4]; /* Reserved for future use. */
+ };
+
+/* Values for the `l_type' field of a `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/common/ftruncate.S b/sysdeps/unix/common/ftruncate.S
new file mode 100644
index 0000000..6081a05
--- /dev/null
+++ b/sysdeps/unix/common/ftruncate.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (ftruncate, 2)
+ ret
diff --git a/sysdeps/unix/common/getgroups.S b/sysdeps/unix/common/getgroups.S
new file mode 100644
index 0000000..74b657a
--- /dev/null
+++ b/sysdeps/unix/common/getgroups.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1994, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (getgroups, 2)
+ ret
+
+weak_alias (__getgroups, getgroups)
diff --git a/sysdeps/unix/common/getitimer.S b/sysdeps/unix/common/getitimer.S
new file mode 100644
index 0000000..d8db921
--- /dev/null
+++ b/sysdeps/unix/common/getitimer.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (getitimer, 2)
+ ret
+
+weak_alias (__getitimer, getitimer)
diff --git a/sysdeps/unix/common/getpgid.S b/sysdeps/unix/common/getpgid.S
new file mode 100644
index 0000000..0ddfe96
--- /dev/null
+++ b/sysdeps/unix/common/getpgid.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+PSEUDO (__getpgid, getpgrp, 1)
+ ret
+
+weak_alias (__getpgid, getpgid)
diff --git a/sysdeps/unix/common/getpriority.S b/sysdeps/unix/common/getpriority.S
new file mode 100644
index 0000000..d71eeac
--- /dev/null
+++ b/sysdeps/unix/common/getpriority.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (getpriority, 2)
+ ret
diff --git a/sysdeps/unix/common/getrlimit.S b/sysdeps/unix/common/getrlimit.S
new file mode 100644
index 0000000..193acf3
--- /dev/null
+++ b/sysdeps/unix/common/getrlimit.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (getrlimit, 2)
+ ret
diff --git a/sysdeps/unix/common/getrusage.S b/sysdeps/unix/common/getrusage.S
new file mode 100644
index 0000000..227e1ca
--- /dev/null
+++ b/sysdeps/unix/common/getrusage.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (getrusage, 2)
+ ret
+
+weak_alias (__getrusage, getrusage)
diff --git a/sysdeps/unix/common/gettimeofday.S b/sysdeps/unix/common/gettimeofday.S
new file mode 100644
index 0000000..9d7fc3f
--- /dev/null
+++ b/sysdeps/unix/common/gettimeofday.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (gettimeofday, 2)
+ ret
+
+weak_alias (__gettimeofday, gettimeofday)
diff --git a/sysdeps/unix/common/glue-ctype.c b/sysdeps/unix/common/glue-ctype.c
new file mode 100644
index 0000000..d2d645b
--- /dev/null
+++ b/sysdeps/unix/common/glue-ctype.c
@@ -0,0 +1,91 @@
+/* Copyright (C) 1992, 1993, 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. */
+
+/* Different systems have different names for the array.
+ This order is important for some systems. */
+
+#if !defined(TABLE) && defined(HAVE__LOCP)
+/* OSF/1 has the name _ctype defined as a macro, which points down into
+ the _locp structure. Jesus. We'll hope this works. We need to
+ check for LOCP first, since there is no symbol actually named _ctype
+ in their library. */
+#include <sys/types.h> /* for wchar_t used by localdef.h */
+#include <sys/localedef.h>
+extern loc_t *_locp;
+#define TABLE (_locp->lc_chrtbl)->lc_ctype
+#undef _ctype
+#define TABLE_NAME _ctype
+#endif
+#ifdef HAVE__CTYPE__
+#define TABLE _ctype__
+#endif
+#if !defined(TABLE) && defined(HAVE__CTYPE)
+#define TABLE _ctype
+#endif
+#if !defined(TABLE) && defined(HAVE__CTYPE_)
+#define TABLE _ctype_
+#endif
+#if !defined(TABLE) && defined(HAVE___CTYPE_)
+#define TABLE __ctype_
+#endif
+#if !defined(TABLE) && defined(HAVE___CTYPE)
+#define TABLE __ctype
+#endif
+
+#if defined (__STDC__) && __STDC__
+#define STRINGIFY(arg) #arg
+#else
+#define STRINGIFY(arg) "arg"
+#endif
+
+#define EVALLED_STRINGIFY(x) STRINGIFY (x)
+
+main ()
+{
+#ifdef TABLE
+
+ int i;
+
+#ifndef HAVE__LOCP
+ /* This won't work for the define to look into _locp. */
+ extern unsigned char TABLE[];
+#endif
+
+ puts ("#include <ansidecl.h>");
+#ifdef TABLE_NAME
+ printf ("CONST unsigned char %s[] =\n {\n", EVALLED_STRINGIFY (TABLE_NAME));
+#else
+ printf ("CONST unsigned char %s[] =\n {\n", EVALLED_STRINGIFY (TABLE));
+#endif
+
+ for (i = -1; i < 256; ++i)
+ printf (" %d,\n", (int) ((TABLE+1)[i]));
+
+ puts (" };");
+
+#else
+
+ puts ("/* I don't know what the ctype table is called on this system.");
+ puts (" If there is a table, and you want the ctype glue to work,");
+ puts (" edit configure.in and glue-ctype.c in sysdeps/unix/common/");
+ puts (" to check for the right name. */");
+
+#endif
+
+ exit (0);
+}
diff --git a/sysdeps/unix/common/lstat.S b/sysdeps/unix/common/lstat.S
new file mode 100644
index 0000000..bc95922
--- /dev/null
+++ b/sysdeps/unix/common/lstat.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (lstat, 2)
+ ret
+
+weak_alias (__lstat, lstat)
diff --git a/sysdeps/unix/common/mk-local_lim.c b/sysdeps/unix/common/mk-local_lim.c
new file mode 100644
index 0000000..1b014f0
--- /dev/null
+++ b/sysdeps/unix/common/mk-local_lim.c
@@ -0,0 +1,78 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sys/types.h>
+#include <sys/param.h>
+
+/* Generate local_limits.h from <sys/param.h> values for BSD. */
+
+struct param
+ {
+ char *name;
+ int value;
+ };
+
+static struct param params[] =
+ {
+ { "NGROUPS_MAX", NGROUPS },
+
+ { "ARG_MAX", NCARGS },
+
+#ifdef MAXUPRC
+ { "CHILD_MAX", MAXUPRC },
+#endif
+
+ { "OPEN_MAX", NOFILE },
+
+ /* Apparently, Ultrix's <sys/param.h> defines LINK_MAX and not MAXLINK. */
+#if defined (LINK_MAX) && !defined (MAXLINK)
+#define MAXLINK LINK_MAX
+#endif
+#ifdef MAXLINK
+ { "LINK_MAX", MAXLINK },
+#endif
+
+ { "MAX_CANON", CANBSIZ },
+
+#ifndef MAXNAMLEN
+#define MAXNAMLEN 255
+#endif
+ { "NAME_MAX", MAXNAMLEN },
+
+ { "PATH_MAX", MAXPATHLEN },
+
+ { NULL, 0 }
+ };
+
+int
+main()
+{
+ extern char *ctime();
+ extern time_t time();
+ time_t now = time((time_t *) NULL);
+ register struct param *p;
+
+ printf("\
+/* Implementation-specific limits.\n\
+ Generated at %.25s. */\n\n", ctime(&now));
+
+ for (p = params; p->name != NULL; ++p)
+ printf("#define %s %d\n", p->name, p->value);
+
+ exit(0);
+}
diff --git a/sysdeps/unix/common/mkdir.S b/sysdeps/unix/common/mkdir.S
new file mode 100644
index 0000000..d827480
--- /dev/null
+++ b/sysdeps/unix/common/mkdir.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (mkdir, 2)
+ ret
+
+weak_alias (__mkdir, mkdir)
diff --git a/sysdeps/unix/common/readlink.S b/sysdeps/unix/common/readlink.S
new file mode 100644
index 0000000..cf5f25e
--- /dev/null
+++ b/sysdeps/unix/common/readlink.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (readlink, 3)
+ ret
+
+weak_alias (__readlink, readlink)
diff --git a/sysdeps/unix/common/readv.S b/sysdeps/unix/common/readv.S
new file mode 100644
index 0000000..1d643ac
--- /dev/null
+++ b/sysdeps/unix/common/readv.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (readv, 3)
+ ret
diff --git a/sysdeps/unix/common/rename.S b/sysdeps/unix/common/rename.S
new file mode 100644
index 0000000..f5ed73e
--- /dev/null
+++ b/sysdeps/unix/common/rename.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (rename, 2)
+ ret
diff --git a/sysdeps/unix/common/rmdir.S b/sysdeps/unix/common/rmdir.S
new file mode 100644
index 0000000..90b89bb
--- /dev/null
+++ b/sysdeps/unix/common/rmdir.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (rmdir, 1)
+ ret
+
+weak_alias (__rmdir, rmdir)
diff --git a/sysdeps/unix/common/select.S b/sysdeps/unix/common/select.S
new file mode 100644
index 0000000..54ffcec
--- /dev/null
+++ b/sysdeps/unix/common/select.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (select, 5)
+ ret
+
+weak_alias (__select, select)
diff --git a/sysdeps/unix/common/setgroups.S b/sysdeps/unix/common/setgroups.S
new file mode 100644
index 0000000..7f4f1f8
--- /dev/null
+++ b/sysdeps/unix/common/setgroups.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (setgroups, 2)
+ ret
diff --git a/sysdeps/unix/common/setitimer.S b/sysdeps/unix/common/setitimer.S
new file mode 100644
index 0000000..63e4e03
--- /dev/null
+++ b/sysdeps/unix/common/setitimer.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (setitimer, 3)
+ ret
+
+weak_alias (__setitimer, setitimer)
diff --git a/sysdeps/unix/common/setpgid.S b/sysdeps/unix/common/setpgid.S
new file mode 100644
index 0000000..5b33825
--- /dev/null
+++ b/sysdeps/unix/common/setpgid.S
@@ -0,0 +1,25 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+PSEUDO (__setpgid, setpgrp, 2)
+ ret
+
+weak_alias (__setpgid, setpgid)
+weak_alias (__setpgid, setpgrp)
diff --git a/sysdeps/unix/common/setpriority.S b/sysdeps/unix/common/setpriority.S
new file mode 100644
index 0000000..89477c2
--- /dev/null
+++ b/sysdeps/unix/common/setpriority.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (setpriority, 3)
+ ret
diff --git a/sysdeps/unix/common/setregid.S b/sysdeps/unix/common/setregid.S
new file mode 100644
index 0000000..dd80ef4
--- /dev/null
+++ b/sysdeps/unix/common/setregid.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (setregid, 2)
+ ret
+
+weak_alias (__setregid, setregid)
diff --git a/sysdeps/unix/common/setreuid.S b/sysdeps/unix/common/setreuid.S
new file mode 100644
index 0000000..245265a
--- /dev/null
+++ b/sysdeps/unix/common/setreuid.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (setreuid, 2)
+ ret
+
+weak_alias (__setreuid, setreuid)
diff --git a/sysdeps/unix/common/setrlimit.S b/sysdeps/unix/common/setrlimit.S
new file mode 100644
index 0000000..3ae577f
--- /dev/null
+++ b/sysdeps/unix/common/setrlimit.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (setrlimit, 2)
+ ret
diff --git a/sysdeps/unix/common/swapon.S b/sysdeps/unix/common/swapon.S
new file mode 100644
index 0000000..f410372
--- /dev/null
+++ b/sysdeps/unix/common/swapon.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (swapon, 1)
+ ret
diff --git a/sysdeps/unix/common/symlink.S b/sysdeps/unix/common/symlink.S
new file mode 100644
index 0000000..0a4a084
--- /dev/null
+++ b/sysdeps/unix/common/symlink.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (symlink, 2)
+ ret
+
+weak_alias (__symlink, symlink)
diff --git a/sysdeps/unix/common/truncate.S b/sysdeps/unix/common/truncate.S
new file mode 100644
index 0000000..a643e46
--- /dev/null
+++ b/sysdeps/unix/common/truncate.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (truncate, 2)
+ ret
diff --git a/sysdeps/unix/common/vhangup.S b/sysdeps/unix/common/vhangup.S
new file mode 100644
index 0000000..8b1b833
--- /dev/null
+++ b/sysdeps/unix/common/vhangup.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (vhangup, 1)
+ ret
diff --git a/sysdeps/unix/common/writev.S b/sysdeps/unix/common/writev.S
new file mode 100644
index 0000000..3d1692c
--- /dev/null
+++ b/sysdeps/unix/common/writev.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (writev, 3)
+ ret
diff --git a/sysdeps/unix/configure b/sysdeps/unix/configure
new file mode 100755
index 0000000..8069c52
--- /dev/null
+++ b/sysdeps/unix/configure
@@ -0,0 +1,127 @@
+ # Copyright (C) 1993, 1994, 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.
+
+
+sysincludedir=/usr/include # XXX
+
+# Find the <syscall.h> file we will be using, or something like it.
+unix_found=
+for unix_dir in $sysnames; do
+ if test -r $sysdep_dir/$unix_dir/syscall.h; then
+ unix_found=$unix_dir
+ break
+ fi
+done
+if test $unix_found = stub; then
+ # XXX This list of possibilities duplicates the list in Makefile.
+ for try in sys.s sys/sys.s sys.S sys/sys.S syscall.h sys/syscall.h; do
+ if test -r $sysincludedir/$try; then
+ unix_syscall_h=$sysincludedir/$try
+ break
+ fi
+ done
+else
+ unix_syscall_h=$sysdep_dir/$unix_dir/syscall.h
+fi
+
+test -n "$unix_syscall_h" && {
+
+# Where to put the .S files we write.
+if test "`pwd`" = "`(cd $srcdir; pwd)`"; then
+ unix_generated_dirpfx=sysdeps/unix/
+else
+ # We are running in a separate build directory.
+ unix_generated_dirpfx=
+fi
+
+# This variable will collect the names of the files we create.
+unix_generated=
+unix_srcs=
+unix_dests=
+
+# These several functions are system calls on Unix systems which have them.
+# The details of these calls are universal enough that if a system's
+# <syscall.h> defines the system call number, we know that the simple
+# system call implementations in unix/common will be sufficient.
+
+for unix_function in \
+ dup2 lstat mkdir rmdir readlink symlink rename swapon \
+ access select getgroups setgroups \
+ getitimer setitimer \
+ getdomainname/getdomain=bsd/bsd4.4 \
+ setdomainname/setdomain=bsd/bsd4.4
+do
+
+ # $unix_function => $unix_syscall $unix_srcname
+ # CALL CALL CALL
+ # CALL/NAME CALL NAME
+ unix_srcname=
+ unix_srcdir=common
+ eval "unix_syscall=`echo $unix_function | \
+ sed -e 's@=\(.*\)$@ unix_srcdir=\1@' \
+ -e 's@/\(.*\)$@ unix_srcname=\1@'`"
+ test -z "$unix_srcname" && unix_srcname=$unix_function
+
+ unix_implementor=none
+ for unix_dir in $sysnames; do
+ if test -r $sysdep_dir/$unix_dir/${unix_srcname}.c ||
+ test -r $sysdep_dir/$unix_dir/${unix_srcname}.S ||
+ test -r $sysdep_dir/$unix_dir/${unix_srcname}.s; then
+ unix_implementor=$unix_dir
+ break
+ fi
+ done
+
+ # mkdir and rmdir have implementations in unix/sysv, but
+ # the simple syscall versions are preferable if available.
+ test $unix_syscall = mkdir -o $unix_syscall = rmdir && \
+ test $unix_implementor = unix/sysv && \
+ unix_implementor=generic
+
+ case $unix_implementor in
+ none|stub|generic|posix)
+ # The chosen implementation of ${unix_syscall} is a boring one.
+ # We want to use the unix/common implementation instead iff
+ # ${unix_syscall} appears in <syscall.h>.
+ echo $ac_n "checking for ${unix_syscall} system call""... $ac_c" 1>&4
+ if grep -i "[ _]${unix_syscall}[ ]" $unix_syscall_h >/dev/null
+ then
+ # It does seem to be present in <syscall.h>.
+ echo "$ac_t""yes" 1>&4
+ unix_dests="$unix_dests ${unix_generated_dirpfx}${unix_srcname}.S"
+ unix_srcs="$unix_srcs sysdeps/unix/${unix_srcdir}/${unix_srcname}.S"
+ unix_generated="$unix_generated $unix_generated_dirpfx${unix_srcname}.S"
+ else
+ echo "$ac_t""no" 1>&4
+ fi
+ ;;
+ *) ;;
+ esac
+
+done
+
+# Autoconf magic in the top-level configure.in causes config.status to
+# actually make the links.
+libc_link_dests="$libc_link_dests $unix_dests"
+libc_link_sources="$libc_link_sources $unix_srcs"
+
+# Store the list of files we created in config.make; Makefile uses it.
+test -n "$unix_generated" && config_vars="$config_vars
+unix-generated := \$(addprefix \$(objpfx),${unix_generated})"
+
+}
diff --git a/sysdeps/unix/configure.in b/sysdeps/unix/configure.in
new file mode 100644
index 0000000..85bc3d1
--- /dev/null
+++ b/sysdeps/unix/configure.in
@@ -0,0 +1,136 @@
+sinclude(./aclocal.m4)dnl Autoconf lossage.
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Copyright (C) 1993, 1994, 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.
+
+dnl configure fragment for Unix-based systems. This is processed by Autoconf,
+dnl but we just use the AC_MSG_* macros. This file is sourced by the
+dnl top-level configure script. Note that we use the prefix `unix_' on all
+dnl shell variables here, to avoid conflicting with any variables the
+dnl top-level script might be using.
+
+sysincludedir=/usr/include # XXX
+
+# Find the <syscall.h> file we will be using, or something like it.
+unix_found=
+for unix_dir in $sysnames; do
+ if test -r $sysdep_dir/$unix_dir/syscall.h; then
+ unix_found=$unix_dir
+ break
+ fi
+done
+if test $unix_found = stub; then
+ # XXX This list of possibilities duplicates the list in Makefile.
+ for try in sys.s sys/sys.s sys.S sys/sys.S syscall.h sys/syscall.h; do
+ if test -r $sysincludedir/$try; then
+ unix_syscall_h=$sysincludedir/$try
+ break
+ fi
+ done
+else
+ unix_syscall_h=$sysdep_dir/$unix_dir/syscall.h
+fi
+
+test -n "$unix_syscall_h" && {
+
+# Where to put the .S files we write.
+if test "`pwd`" = "`(cd $srcdir; pwd)`"; then
+ unix_generated_dirpfx=sysdeps/unix/
+else
+ # We are running in a separate build directory.
+ unix_generated_dirpfx=
+fi
+
+# This variable will collect the names of the files we create.
+unix_generated=
+unix_srcs=
+unix_dests=
+
+# These several functions are system calls on Unix systems which have them.
+# The details of these calls are universal enough that if a system's
+# <syscall.h> defines the system call number, we know that the simple
+# system call implementations in unix/common will be sufficient.
+
+for unix_function in \
+ dup2 lstat mkdir rmdir readlink symlink rename swapon \
+ access select getgroups setgroups \
+ getitimer setitimer \
+ getdomainname/getdomain=bsd/bsd4.4 \
+ setdomainname/setdomain=bsd/bsd4.4
+do
+
+ # $unix_function => $unix_syscall $unix_srcname
+ # CALL CALL CALL
+ # CALL/NAME CALL NAME
+ unix_srcname=
+ unix_srcdir=common
+ eval "unix_syscall=`echo $unix_function | \
+ sed -e 's@=\(.*\)$@ unix_srcdir=\1@' \
+ -e 's@/\(.*\)$@ unix_srcname=\1@'`"
+ test -z "$unix_srcname" && unix_srcname=$unix_function
+
+ unix_implementor=none
+ for unix_dir in $sysnames; do
+ if test -r $sysdep_dir/$unix_dir/${unix_srcname}.c ||
+ test -r $sysdep_dir/$unix_dir/${unix_srcname}.S ||
+ test -r $sysdep_dir/$unix_dir/${unix_srcname}.s; then
+ unix_implementor=$unix_dir
+ break
+ fi
+ done
+
+ # mkdir and rmdir have implementations in unix/sysv, but
+ # the simple syscall versions are preferable if available.
+ test $unix_syscall = mkdir -o $unix_syscall = rmdir && \
+ test $unix_implementor = unix/sysv && \
+ unix_implementor=generic
+
+ case $unix_implementor in
+ none|stub|generic|posix)
+ # The chosen implementation of ${unix_syscall} is a boring one.
+ # We want to use the unix/common implementation instead iff
+ # ${unix_syscall} appears in <syscall.h>.
+ AC_MSG_CHECKING(for ${unix_syscall} system call)
+changequote(,)dnl We need to use [ and ] for real now.
+ if grep -i "[ _]${unix_syscall}[ ]" $unix_syscall_h >/dev/null
+changequote([,])dnl Back to Autoconf land.
+ then
+ # It does seem to be present in <syscall.h>.
+ AC_MSG_RESULT(yes)
+ unix_dests="$unix_dests ${unix_generated_dirpfx}${unix_srcname}.S"
+ unix_srcs="$unix_srcs sysdeps/unix/${unix_srcdir}/${unix_srcname}.S"
+ unix_generated="$unix_generated $unix_generated_dirpfx${unix_srcname}.S"
+ else
+ AC_MSG_RESULT(no)
+ fi
+ ;;
+ *) ;;
+ esac
+
+done
+
+# Autoconf magic in the top-level configure.in causes config.status to
+# actually make the links.
+libc_link_dests="$libc_link_dests $unix_dests"
+libc_link_sources="$libc_link_sources $unix_srcs"
+
+# Store the list of files we created in config.make; Makefile uses it.
+test -n "$unix_generated" && config_vars="$config_vars
+unix-generated := \$(addprefix \$(objpfx),${unix_generated})"
+
+}
diff --git a/sysdeps/unix/confstr.h b/sysdeps/unix/confstr.h
new file mode 100644
index 0000000..15859c3
--- /dev/null
+++ b/sysdeps/unix/confstr.h
@@ -0,0 +1 @@
+#define CS_PATH "/bin:/usr/bin"
diff --git a/sysdeps/unix/dirstream.h b/sysdeps/unix/dirstream.h
new file mode 100644
index 0000000..20c4922
--- /dev/null
+++ b/sysdeps/unix/dirstream.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 1993 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 _DIRSTREAM_H
+
+#define _DIRSTREAM_H 1
+
+#define __need_size_t
+#include <stddef.h>
+
+/* Directory stream type.
+
+ The miscellaneous Unix `readdir' implementations read directory data
+ into a buffer and fill in a `struct dirent' copy in the `DIR' object. */
+
+typedef struct
+ {
+ int __fd; /* File descriptor. */
+
+ char *__data; /* Directory block. */
+ size_t __allocation; /* Space allocated for the block. */
+ size_t __offset; /* Current offset into the block. */
+ size_t __size; /* Total valid data in the block. */
+
+ struct dirent __entry; /* Returned by `readdir'. */
+ } DIR;
+
+#endif /* dirstream.h */
diff --git a/sysdeps/unix/dup.S b/sysdeps/unix/dup.S
new file mode 100644
index 0000000..3da637d
--- /dev/null
+++ b/sysdeps/unix/dup.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (dup, 2)
+ ret
+
+weak_alias (__dup, dup)
diff --git a/sysdeps/unix/errnos-tmpl.c b/sysdeps/unix/errnos-tmpl.c
new file mode 100644
index 0000000..67611fd
--- /dev/null
+++ b/sysdeps/unix/errnos-tmpl.c
@@ -0,0 +1,98 @@
+/* Copyright (C) 1991, 1993 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 General Public License as published by
+the Free Software Foundation; either version 2, 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the GNU C Library; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <errno.h>
+
+static char iferrno[] = "#ifdef _ERRNO_H";
+static char endiferrno[] = "#endif /* <errno.h> included. */";
+static char ifEmath[] = "#if !defined(__Emath_defined) && \
+ (defined(_ERRNO_H) || defined(__need_Emath))";
+static char endifEmath[] = "#endif /* Emath not defined and <errno.h> \
+included or need Emath. */";
+
+static int biggest_value = 0;
+static int done_ENOSYS = 0;
+static int done_ERANGE = 0, done_EDOM = 0;
+
+static void
+DO(name, value)
+ char *name;
+ int value;
+{
+ int is_ERANGE = !done_ERANGE && !strcmp(name, "ERANGE");
+ int is_EDOM = !done_EDOM && !strcmp(name, "EDOM");
+ int is_Emath = is_ERANGE || is_EDOM;
+
+ if (is_Emath)
+ {
+ puts(endiferrno);
+ puts(ifEmath);
+ }
+
+ if (!strcmp (name, "EWOULDBLOCK"))
+ {
+ puts ("#define EWOULDBLOCK EAGAIN /* Translated in glibc. */");
+ name = "EWOULDBLOCK_sys /* Value actually returned by kernel. */";
+ }
+
+ printf ("#define %s %d\n", name, value);
+
+ if (is_Emath)
+ {
+ puts(endifEmath);
+ puts(iferrno);
+ }
+
+ if (value > biggest_value)
+ biggest_value = value;
+
+ if (is_ERANGE)
+ done_ERANGE = 1;
+ else if (is_EDOM)
+ done_EDOM = 1;
+ else if (!done_ENOSYS && !strcmp(name, "ENOSYS"))
+ done_ENOSYS = 1;
+}
+
+int
+main()
+{
+ puts(iferrno);
+
+ ERRNOS;
+
+ if (!done_EDOM || !done_ERANGE)
+ {
+ puts(endiferrno);
+ puts(ifEmath);
+ if (!done_EDOM)
+ printf("#define EDOM %d\n", ++biggest_value);
+ if (!done_ERANGE)
+ printf("#define ERANGE %d\n", ++biggest_value);
+ puts(endifEmath);
+ }
+
+ if (!done_ENOSYS)
+ printf("#define ENOSYS %d\n", ++biggest_value);
+
+ puts(endiferrno);
+
+ puts("#undef __need_Emath");
+ puts("#ifndef __Emath_defined\n#define __Emath_defined 1\n#endif");
+
+ exit(0);
+}
diff --git a/sysdeps/unix/errnos.awk b/sysdeps/unix/errnos.awk
new file mode 100644
index 0000000..8648f41
--- /dev/null
+++ b/sysdeps/unix/errnos.awk
@@ -0,0 +1,12 @@
+BEGIN { special = 0 }
+
+/ERRNOS/ { nerrnos = split(errnos, errs)
+ for (i = 1; i <= nerrnos; ++i)
+ # Some systems define errno codes inside undefined #ifdefs,
+ # and then never actually use them.
+ printf "#ifdef %s\n DO(\"%s\", %s);\n#endif\n", \
+ errs[i], errs[i], errs[i]
+ special = 1 }
+
+
+{ if (special == 0) print $0; special = 0 }
diff --git a/sysdeps/unix/execve.S b/sysdeps/unix/execve.S
new file mode 100644
index 0000000..7a4fc13
--- /dev/null
+++ b/sysdeps/unix/execve.S
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <sysdep.h>
+
+/* Some systems misname the system call number macro for this. */
+#if !defined (SYS_execve) && defined (SYS_exece)
+#define SYS_execve SYS_exece
+#endif
+#if !defined (SYS_execve) && defined (SYS_exec)
+#define SYS_execve SYS_exec
+#endif
+
+SYSCALL__ (execve, 3)
+ ret
+
+weak_alias (__execve, execve)
diff --git a/sysdeps/unix/fcntl.S b/sysdeps/unix/fcntl.S
new file mode 100644
index 0000000..7ac4f28
--- /dev/null
+++ b/sysdeps/unix/fcntl.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (fcntl, 3)
+ ret
+
+weak_alias (__fcntl, fcntl)
diff --git a/sysdeps/unix/fork.S b/sysdeps/unix/fork.S
new file mode 100644
index 0000000..1c360c6
--- /dev/null
+++ b/sysdeps/unix/fork.S
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#include <sysdep.h>
+
+/* This code works for at least m68k. */
+
+SYSCALL__ (fork, 0)
+ /* R1 is now 0 for the parent and 1 for the child. Decrement it to
+ make it -1 (all bits set) for the parent, and 0 (no bits set)
+ for the child. Then AND it with R0, so the parent gets
+ R0&-1==R0, and the child gets R0&0==0. */
+ subl #1, r1
+ andl r1, r0
+ ret
+
+weak_alias (__fork, fork)
diff --git a/sysdeps/unix/fstat.S b/sysdeps/unix/fstat.S
new file mode 100644
index 0000000..cf501ef
--- /dev/null
+++ b/sysdeps/unix/fstat.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (fstat, 2)
+ ret
+
+weak_alias (__fstat, fstat)
diff --git a/sysdeps/unix/fsync.S b/sysdeps/unix/fsync.S
new file mode 100644
index 0000000..109994b
--- /dev/null
+++ b/sysdeps/unix/fsync.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (fsync, 1)
+ ret
diff --git a/sysdeps/unix/getdents.c b/sysdeps/unix/getdents.c
new file mode 100644
index 0000000..485faa1
--- /dev/null
+++ b/sysdeps/unix/getdents.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1993, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+int
+DEFUN(__getdirentries, (fd, buf, nbytes, basep),
+ int fd AND char *buf AND size_t nbytes AND off_t *basep)
+{
+ if (basep)
+ *basep = __lseek (fd, (off_t) 0, SEEK_CUR);
+
+ return __read (fd, buf, nbytes);
+}
+
+weak_alias (__getdirentries, getdirentries)
+
diff --git a/sysdeps/unix/getegid.S b/sysdeps/unix/getegid.S
new file mode 100644
index 0000000..1bd447b
--- /dev/null
+++ b/sysdeps/unix/getegid.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+#ifdef SYS_getegid
+SYSCALL__ (getegid, 0)
+#else
+PSEUDO (__getegid, getgid, 0)
+ MOVE(r1, r0)
+#endif
+ ret
+
+weak_alias (__getegid, getegid)
diff --git a/sysdeps/unix/geteuid.S b/sysdeps/unix/geteuid.S
new file mode 100644
index 0000000..339eb53
--- /dev/null
+++ b/sysdeps/unix/geteuid.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+#ifdef SYS_geteuid
+SYSCALL__ (geteuid, 0)
+#else
+PSEUDO (__geteuid, getuid, 0)
+ MOVE(r1, r0)
+#endif
+ ret
+
+weak_alias (__geteuid, geteuid)
diff --git a/sysdeps/unix/getgid.S b/sysdeps/unix/getgid.S
new file mode 100644
index 0000000..5788654
--- /dev/null
+++ b/sysdeps/unix/getgid.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (getgid, 0)
+ ret
+
+weak_alias (__getgid, getgid)
diff --git a/sysdeps/unix/getlogin.c b/sysdeps/unix/getlogin.c
new file mode 100644
index 0000000..504a7aa
--- /dev/null
+++ b/sysdeps/unix/getlogin.c
@@ -0,0 +1,90 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <limits.h>
+#include <fcntl.h>
+
+#include <utmp.h>
+
+/* Defined in ttyname.c. */
+extern char *__ttyname;
+
+/* Return the login name of the user, or NULL if it can't be determined.
+ The returned pointer, if not NULL, is good only until the next call. */
+
+char *
+DEFUN_VOID(getlogin)
+{
+ char save_tty_pathname[2 + 2 * NAME_MAX];
+ char *save_ttyname;
+ char *real_tty_path;
+ char *result = NULL;
+ FILE *f;
+ static struct utmp ut;
+
+ if (__ttyname == NULL)
+ save_ttyname = NULL;
+ else
+ save_ttyname = strcpy (save_tty_pathname, __ttyname);
+
+ {
+ int err;
+ int d = __open ("/dev/tty", 0);
+ if (d < 0)
+ return NULL;
+
+ real_tty_path = ttyname (d);
+ err = errno;
+ (void) close (d);
+
+ if (real_tty_path == NULL)
+ {
+ errno = err;
+ return NULL;
+ }
+ }
+
+ real_tty_path += 5; /* Remove "/dev/". */
+
+ f = fopen ("/etc/utmp", "r");
+ if (f != NULL)
+ {
+ while (fread ((PTR) &ut, sizeof(ut), 1, f) == 1)
+ if (!strncmp (ut.ut_line, real_tty_path, sizeof (ut.ut_line)))
+ {
+ result = ut.ut_name;
+ /* The name is not null-terminated if
+ it is as long as sizeof (ut.ut_name). */
+ result[sizeof (ut.ut_name)] = '\0';
+ break;
+ }
+ (void) fclose (f);
+ }
+
+ if (save_ttyname != NULL)
+ strcpy (__ttyname, save_ttyname);
+ if (result == NULL)
+ errno = ENOENT;
+ return result;
+}
diff --git a/sysdeps/unix/getpagesize.c b/sysdeps/unix/getpagesize.c
new file mode 100644
index 0000000..399126e
--- /dev/null
+++ b/sysdeps/unix/getpagesize.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 1992, 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 General Public License as published by
+the Free Software Foundation; either version 2, 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the GNU C Library; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <sys/param.h>
+
+/* Return the system page size. */
+size_t
+DEFUN_VOID(__getpagesize)
+{
+#ifdef EXEC_PAGESIZE
+ return EXEC_PAGESIZE;
+#else /* No EXEC_PAGESIZE. */
+#ifdef NBPG
+#ifndef CLSIZE
+#define CLSIZE 1
+#endif /* No CLSIZE. */
+ return NBPG * CLSIZE;
+#else /* No NBPG. */
+ return NBPC;
+#endif /* NBPG. */
+#endif /* EXEC_PAGESIZE. */
+}
+
+weak_alias (__getpagesize, getpagesize)
diff --git a/sysdeps/unix/getpid.S b/sysdeps/unix/getpid.S
new file mode 100644
index 0000000..9689c1d
--- /dev/null
+++ b/sysdeps/unix/getpid.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (getpid, 1)
+ ret
+
+weak_alias (__getpid, getpid)
diff --git a/sysdeps/unix/getppid.S b/sysdeps/unix/getppid.S
new file mode 100644
index 0000000..132c374
--- /dev/null
+++ b/sysdeps/unix/getppid.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+#ifdef SYS_getppid
+SYSCALL__ (getppid, 0)
+#else
+PSEUDO (__getppid, getpid, 0)
+ MOVE(r1, r0)
+#endif
+ ret
+
+weak_alias (__getppid, getppid)
diff --git a/sysdeps/unix/getuid.S b/sysdeps/unix/getuid.S
new file mode 100644
index 0000000..df076f0
--- /dev/null
+++ b/sysdeps/unix/getuid.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (getuid, 0)
+ ret
+
+weak_alias (__getuid, getuid)
diff --git a/sysdeps/unix/i386/brk.S b/sysdeps/unix/i386/brk.S
new file mode 100644
index 0000000..f55ac7c
--- /dev/null
+++ b/sysdeps/unix/i386/brk.S
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <sysdep.h>
+
+#ifndef SYS_brk
+#define SYS_brk 17
+#endif
+
+.data
+.globl C_SYMBOL_NAME(__curbrk)
+C_LABEL(__curbrk)
+#ifdef HAVE_GNU_LD
+ .long C_SYMBOL_NAME(_end)
+#else
+ .long C_SYMBOL_NAME(end)
+#endif
+
+.text
+SYSCALL__ (brk, 1)
+ movl 4(%esp), %eax
+ movl %eax, C_SYMBOL_NAME(__curbrk)
+ xorl %eax, %eax
+ ret
+
+weak_alias (__brk, brk)
diff --git a/sysdeps/unix/i386/fork.S b/sysdeps/unix/i386/fork.S
new file mode 100644
index 0000000..4388b04
--- /dev/null
+++ b/sysdeps/unix/i386/fork.S
@@ -0,0 +1,30 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (fork, 0)
+ /* R1 is now 0 for the parent and 1 for the child. Decrement it to
+ make it -1 (all bits set) for the parent, and 0 (no bits set)
+ for the child. Then AND it with R0, so the parent gets
+ R0&-1==R0, and the child gets R0&0==0. */
+ decl r1
+ andl r1, r0
+ ret
+
+weak_alias (__fork, fork)
diff --git a/sysdeps/unix/i386/pipe.S b/sysdeps/unix/i386/pipe.S
new file mode 100644
index 0000000..7c7c51a
--- /dev/null
+++ b/sysdeps/unix/i386/pipe.S
@@ -0,0 +1,28 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (pipe, 1)
+ movl 4(%esp), scratch
+ movl %eax, (scratch)
+ movl r1, 4(scratch)
+ xorl %eax, %eax
+ ret
+
+weak_alias (__pipe, pipe)
diff --git a/sysdeps/unix/i386/sigreturn.S b/sysdeps/unix/i386/sigreturn.S
new file mode 100644
index 0000000..3cf79a5
--- /dev/null
+++ b/sysdeps/unix/i386/sigreturn.S
@@ -0,0 +1,27 @@
+/* Copyright (C) 1992, 1993, 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. */
+
+#include <sysdep.h>
+
+.text
+ENTRY (__sigreturn)
+ addl $4, %esp /* Pop the return PC. */
+ DO_CALL (sigreturn, 0) /* Do the system call; it never returns. */
+ /* NOTREACHED */
+
+weak_alias (__sigreturn, sigreturn)
diff --git a/sysdeps/unix/i386/start.c b/sysdeps/unix/i386/start.c
new file mode 100644
index 0000000..e6c89ee
--- /dev/null
+++ b/sysdeps/unix/i386/start.c
@@ -0,0 +1,2 @@
+#define DUMMIES dummy0
+#include <sysdeps/unix/start.c>
diff --git a/sysdeps/unix/i386/syscall.S b/sysdeps/unix/i386/syscall.S
new file mode 100644
index 0000000..5241ee4
--- /dev/null
+++ b/sysdeps/unix/i386/syscall.S
@@ -0,0 +1,28 @@
+/* Copyright (C) 1993 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. */
+
+#include <sysdep.h>
+
+.globl syscall_error
+ENTRY (syscall)
+ popl %ecx /* Pop return address into %ecx. */
+ popl %eax /* Pop syscall number into %eax. */
+ pushl %ecx /* Push back return address. */
+ .byte 0x9a, 0, 0, 0, 0, 7, 0 /* lcall $7, $0 -- gas bug */
+ jb syscall_error
+ ret
diff --git a/sysdeps/unix/i386/sysdep.S b/sysdeps/unix/i386/sysdep.S
new file mode 100644
index 0000000..dae7153
--- /dev/null
+++ b/sysdeps/unix/i386/sysdep.S
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <sysdep.h>
+#define _ERRNO_H
+#include <errnos.h>
+
+.globl C_SYMBOL_NAME(errno)
+.globl syscall_error
+
+#undef syscall_error
+#ifdef NO_UNDERSCORES
+__syscall_error:
+#else
+syscall_error:
+#endif
+#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
+ /* We translate the system's EWOULDBLOCK error into EAGAIN.
+ The GNU C library always defines EWOULDBLOCK==EAGAIN.
+ EWOULDBLOCK_sys is the original number. */
+ cmpl $EWOULDBLOCK_sys, %eax /* Is it the old EWOULDBLOCK? */
+ jne notb /* Branch if not. */
+ movl $EAGAIN, %eax /* Yes; translate it to EAGAIN. */
+#endif
+notb: movl %eax, C_SYMBOL_NAME(errno)
+ movl $-1, %eax
+ ret
diff --git a/sysdeps/unix/i386/sysdep.h b/sysdeps/unix/i386/sysdep.h
new file mode 100644
index 0000000..38dd237
--- /dev/null
+++ b/sysdeps/unix/i386/sysdep.h
@@ -0,0 +1,55 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <sysdeps/unix/sysdep.h>
+
+#ifdef ASSEMBLER
+
+#define ENTRY(name) \
+ .globl C_SYMBOL_NAME(name); \
+ .align 4; \
+ C_LABEL(name)
+
+#ifdef NO_UNDERSCORES
+/* Since C identifiers are not normally prefixed with an underscore
+ on this system, the asm identifier `syscall_error' intrudes on the
+ C name space. Make sure we use an innocuous name. */
+#define syscall_error __syscall_error
+#endif
+
+#define PSEUDO(name, syscall_name, args) \
+ .globl syscall_error; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args); \
+ jb syscall_error
+
+/* This is defined as a separate macro so that other sysdep.h files
+ can include this one and then redefine DO_CALL. */
+
+#define DO_CALL(syscall_name, args) \
+ lea SYS_ify (syscall_name), %eax; \
+ /* lcall $7, $0; */ \
+ /* Above loses; GAS bug. */ \
+ .byte 0x9a, 0, 0, 0, 0, 7, 0
+
+#define r0 %eax /* Normal return-value register. */
+#define r1 %edx /* Secondary return-value register. */
+#define scratch %ecx /* Call-clobbered register for random use. */
+#define MOVE(x,y) movl x, y
+
+#endif /* ASSEMBLER */
diff --git a/sysdeps/unix/i386/wait.S b/sysdeps/unix/i386/wait.S
new file mode 100644
index 0000000..4b2e62c
--- /dev/null
+++ b/sysdeps/unix/i386/wait.S
@@ -0,0 +1,28 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (wait, 1)
+ movl 4(%esp), scratch /* Put status pointer in scratch register. */
+ testl scratch, scratch /* Is it non-nil? */
+ je null
+ movl r1, (scratch) /* Yes; store the status there. */
+null: ret
+
+weak_alias (__wait, wait)
diff --git a/sysdeps/unix/inet/Subdirs b/sysdeps/unix/inet/Subdirs
new file mode 100644
index 0000000..4a40811
--- /dev/null
+++ b/sysdeps/unix/inet/Subdirs
@@ -0,0 +1,3 @@
+inet
+resolv
+sunrpc
diff --git a/sysdeps/unix/inet/accept.S b/sysdeps/unix/inet/accept.S
new file mode 100644
index 0000000..25d4d05
--- /dev/null
+++ b/sysdeps/unix/inet/accept.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (accept, 3)
+ ret
diff --git a/sysdeps/unix/inet/bind.S b/sysdeps/unix/inet/bind.S
new file mode 100644
index 0000000..fc8c818
--- /dev/null
+++ b/sysdeps/unix/inet/bind.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (bind, 3)
+ ret
diff --git a/sysdeps/unix/inet/connect.S b/sysdeps/unix/inet/connect.S
new file mode 100644
index 0000000..714d743
--- /dev/null
+++ b/sysdeps/unix/inet/connect.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (connect, 3)
+ ret
diff --git a/sysdeps/unix/inet/gethostid.S b/sysdeps/unix/inet/gethostid.S
new file mode 100644
index 0000000..e3296f4
--- /dev/null
+++ b/sysdeps/unix/inet/gethostid.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (gethostid, 0)
+ ret
diff --git a/sysdeps/unix/inet/gethostname.S b/sysdeps/unix/inet/gethostname.S
new file mode 100644
index 0000000..d9a1e90
--- /dev/null
+++ b/sysdeps/unix/inet/gethostname.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (gethostname, 2)
+ ret
+
+weak_alias (__gethostname, gethostname)
diff --git a/sysdeps/unix/inet/getpeername.S b/sysdeps/unix/inet/getpeername.S
new file mode 100644
index 0000000..115c93b
--- /dev/null
+++ b/sysdeps/unix/inet/getpeername.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (getpeername, 3)
+ ret
diff --git a/sysdeps/unix/inet/getsockname.S b/sysdeps/unix/inet/getsockname.S
new file mode 100644
index 0000000..94d5c9c
--- /dev/null
+++ b/sysdeps/unix/inet/getsockname.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (getsockname, 3)
+ ret
diff --git a/sysdeps/unix/inet/getsockopt.S b/sysdeps/unix/inet/getsockopt.S
new file mode 100644
index 0000000..d7b4681
--- /dev/null
+++ b/sysdeps/unix/inet/getsockopt.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (getsockopt, 5)
+ ret
diff --git a/sysdeps/unix/inet/listen.S b/sysdeps/unix/inet/listen.S
new file mode 100644
index 0000000..38d42ae
--- /dev/null
+++ b/sysdeps/unix/inet/listen.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (listen, 2)
+ ret
diff --git a/sysdeps/unix/inet/recv.S b/sysdeps/unix/inet/recv.S
new file mode 100644
index 0000000..576863e
--- /dev/null
+++ b/sysdeps/unix/inet/recv.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (recv, 4)
+ ret
diff --git a/sysdeps/unix/inet/recvfrom.S b/sysdeps/unix/inet/recvfrom.S
new file mode 100644
index 0000000..bd75e6d
--- /dev/null
+++ b/sysdeps/unix/inet/recvfrom.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (recvfrom, 6)
+ ret
diff --git a/sysdeps/unix/inet/recvmsg.S b/sysdeps/unix/inet/recvmsg.S
new file mode 100644
index 0000000..dd0a268
--- /dev/null
+++ b/sysdeps/unix/inet/recvmsg.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (recvmsg, 3)
+ ret
diff --git a/sysdeps/unix/inet/send.S b/sysdeps/unix/inet/send.S
new file mode 100644
index 0000000..85ac36b
--- /dev/null
+++ b/sysdeps/unix/inet/send.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (send, 4)
+ ret
diff --git a/sysdeps/unix/inet/sendmsg.S b/sysdeps/unix/inet/sendmsg.S
new file mode 100644
index 0000000..1dadaf3
--- /dev/null
+++ b/sysdeps/unix/inet/sendmsg.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (sendmsg, 3)
+ ret
diff --git a/sysdeps/unix/inet/sendto.S b/sysdeps/unix/inet/sendto.S
new file mode 100644
index 0000000..18d6f6a
--- /dev/null
+++ b/sysdeps/unix/inet/sendto.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (sendto, 6)
+ ret
diff --git a/sysdeps/unix/inet/sethostid.S b/sysdeps/unix/inet/sethostid.S
new file mode 100644
index 0000000..141db20
--- /dev/null
+++ b/sysdeps/unix/inet/sethostid.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (sethostid, 1)
+ ret
diff --git a/sysdeps/unix/inet/sethostname.S b/sysdeps/unix/inet/sethostname.S
new file mode 100644
index 0000000..e7d9f93
--- /dev/null
+++ b/sysdeps/unix/inet/sethostname.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (sethostname, 2)
+ ret
diff --git a/sysdeps/unix/inet/setsockopt.S b/sysdeps/unix/inet/setsockopt.S
new file mode 100644
index 0000000..a3948c2
--- /dev/null
+++ b/sysdeps/unix/inet/setsockopt.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (setsockopt, 5)
+ ret
diff --git a/sysdeps/unix/inet/shutdown.S b/sysdeps/unix/inet/shutdown.S
new file mode 100644
index 0000000..7ce3e6c
--- /dev/null
+++ b/sysdeps/unix/inet/shutdown.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (shutdown, 2)
+ ret
diff --git a/sysdeps/unix/inet/socket.S b/sysdeps/unix/inet/socket.S
new file mode 100644
index 0000000..b0f01cf
--- /dev/null
+++ b/sysdeps/unix/inet/socket.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (socket, 3)
+ ret
diff --git a/sysdeps/unix/inet/socketpair.S b/sysdeps/unix/inet/socketpair.S
new file mode 100644
index 0000000..fb352cf
--- /dev/null
+++ b/sysdeps/unix/inet/socketpair.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (socketpair, 4)
+ ret
diff --git a/sysdeps/unix/ioctl.S b/sysdeps/unix/ioctl.S
new file mode 100644
index 0000000..d80fd68
--- /dev/null
+++ b/sysdeps/unix/ioctl.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (ioctl, 3)
+ ret
+
+weak_alias (__ioctl, ioctl)
diff --git a/sysdeps/unix/ioctls-tmpl.c b/sysdeps/unix/ioctls-tmpl.c
new file mode 100644
index 0000000..1c973c9
--- /dev/null
+++ b/sysdeps/unix/ioctls-tmpl.c
@@ -0,0 +1,134 @@
+/* On SVR4, this #define is necessary to make <sys/ioctl.h> define
+ many of the ioctls. */
+#define BSD_COMP
+
+#include <sys/types.h>
+#include <sys/param.h>
+
+/* On SunOS 4.1, <sys/ioctl.h> and <sys/termios.h> define some symbols
+ with different values, but <sys/termios.h> defines some ioctl symbols
+ not in <sys/ioctl.h>, so we need it. Our <sys/ioctl.h> should define
+ them with the values from Sun's <sys/ioctl.h>, not <sys/termios.h>.
+ So we include <sys/termios.h> and let <sys/ioctl.h> redefine things.
+ This produces some spurious warnings. */
+
+#ifdef HAVE_sys_termios_h
+#include <sys/termios.h>
+#endif
+
+/* This causes <sys/ioctl.h> to define some necessary data structure. */
+#ifdef sony_news
+#define KANJI
+#endif
+
+#include <sys/ioctl.h>
+
+#ifdef SIOCGIFCONF
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <net/if.h>
+#include <net/route.h>
+#if defined(SIOCGARP) && !defined(ARPOP_REQUEST)
+#include <net/if_arp.h>
+#endif
+#ifdef SIOCGNIT
+#ifdef HAVE_net_nit_h
+#include <net/nit.h>
+#else /* No net/nit.h. */
+#undef SIOCGNIT
+#undef SIOCSNIT
+#endif /* net/nit.h. */
+#endif /* SIOCGNIT. */
+#endif /* SIOCGIFCONF. */
+
+/* These exist on Sequents. */
+#ifdef SMIOSTATS
+#include <sec/sec.h>
+#include <sec/sm.h>
+#endif
+#ifdef SMIOGETREBOOT0
+#include <i386/cfg.h>
+#endif
+#ifdef ZIOCBCMD
+#include <zdc/zdc.h>
+#endif
+
+/* These exist under Ultrix, but I figured there may be others. */
+#ifdef DIOCGETPT
+#include <ufs/fs.h> /* for DIOC* */
+#endif
+#ifdef DEVGETGEOM
+#include <sys/devio.h>
+#endif
+
+#ifdef ultrix
+/* Ultrix has a conditional include that brings these in; we have to force
+ their inclusion when we actually compile them. */
+#undef TCGETA
+#undef TCSETA
+#undef TCSETAW
+#undef TCSETAF
+#undef TCGETP
+#undef TCSANOW
+#undef TCSADRAIN
+#undef TCSAFLUSH
+#ifdef ELSETPID
+#include <sys/un.h> /* get sockaddr_un for elcsd.h */
+#include <elcsd.h>
+#endif
+#ifdef DKIOCDOP
+#include <sys/dkio.h>
+#endif
+/* Couldn't find the header where the structures used by these are
+ defined; it looks like an unbundled LAT package or something. */
+#undef LIOCSOL
+#undef LIOCRES
+#undef LIOCCMD
+#undef LIOCINI
+#undef LIOCTTYI
+#undef LIOCCONN
+/* struct mtop hasn't been in sys/mtio.h since 4.1 */
+#undef MTIOCTOP
+#undef MTIOCGET
+#endif
+
+#if defined(__osf__) && defined(__alpha__)
+#include <sys/ioctl_compat.h> /* To get TIOCGETP, etc. */
+#include <alpha/pt.h> /* for DIOC* */
+#include <sys/mtio.h> /* for MTIOC* */
+/* The binlog_getstatus structure doesn't seem to be defined. */
+#undef BINLOG_GETSTATUS
+/* Can't find `struct ifdata' anywhere. */
+#undef SIOCMANREQ
+#undef SIOCGETEVENTS
+/* OSF/1 smells an awful lot like Ultrix. */
+#undef TCGETA
+#undef TCSETA
+#undef TCSETAF
+#undef TCSETAW
+/* This macro looks screwed in sys/devio.h. */
+#undef DEV_DISKPART
+/* This is in sys/dkio.h, but we don't need it. */
+#undef DKIOCACC
+#undef DKIOCDOP
+#undef DKIOCEXCL
+#undef DKIOCGET
+#undef DKIOCHDR
+/* Introduced by OSF/1 2.0. */
+#undef FIOPIPESTAT
+#undef SIOCSRREQR
+#undef SIOCSRREQW
+#undef SRVC_REQUEST
+#endif
+
+#define DEFINE(name, value) \
+ printf("#define %s 0x%.8x\n", (name), (value))
+
+int
+main()
+{
+ REQUESTS
+
+ exit(0);
+ return 0;
+}
diff --git a/sysdeps/unix/ioctls.awk b/sysdeps/unix/ioctls.awk
new file mode 100644
index 0000000..b05140a
--- /dev/null
+++ b/sysdeps/unix/ioctls.awk
@@ -0,0 +1,10 @@
+BEGIN { special = 0 }
+
+/REQUESTS/ { nreqs = split(requests, reqs)
+ for (i = 1; i <= nreqs; ++i)
+ printf "#ifdef\t%s\n DEFINE(\"%s\", %s);\n#endif\n", \
+ reqs[i], reqs[i], reqs[i]
+ special = 1 }
+
+
+{ if (special == 0) print $0; special = 0 }
diff --git a/sysdeps/unix/kill.S b/sysdeps/unix/kill.S
new file mode 100644
index 0000000..b4c6469
--- /dev/null
+++ b/sysdeps/unix/kill.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (kill, 2)
+ ret
+
+weak_alias (__kill, kill)
diff --git a/sysdeps/unix/link.S b/sysdeps/unix/link.S
new file mode 100644
index 0000000..e96c4d9
--- /dev/null
+++ b/sysdeps/unix/link.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (link, 2)
+ ret
+
+weak_alias (__link, link)
diff --git a/sysdeps/unix/lseek.S b/sysdeps/unix/lseek.S
new file mode 100644
index 0000000..66efe1c
--- /dev/null
+++ b/sysdeps/unix/lseek.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (lseek, 3)
+ ret
+
+weak_alias (__lseek, lseek)
diff --git a/sysdeps/unix/make_errlist.c b/sysdeps/unix/make_errlist.c
new file mode 100644
index 0000000..40b4f82
--- /dev/null
+++ b/sysdeps/unix/make_errlist.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 1991, 1992, 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 General Public License as published by
+the Free Software Foundation; either version 2, 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the GNU C Library; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <stdio.h>
+
+
+/* Make a definition for sys_errlist. */
+
+extern int sys_nerr;
+extern char *sys_errlist[];
+
+int
+main ()
+{
+ register int i;
+
+ puts ("#include \"ansidecl.h\"\n#include <stddef.h>\n");
+ puts ("\n/* This is a list of all known `errno' codes. */\n");
+
+ puts ("#ifndef HAVE_GNU_LD");
+ puts ("#define _sys_nerr\tsys_nerr");
+ puts ("#define _sys_errlist\tsys_errlist");
+ puts ("#endif");
+
+ printf ("\nCONST int _sys_nerr = %d;\n\n", sys_nerr);
+ puts ("CONST char *CONST _sys_errlist[] =\n {");
+
+ for (i = 0; i < sys_nerr; ++i)
+ printf (" \"%s\",\n", sys_errlist[i]);
+
+ puts (" NULL\n };\n");
+
+ puts ("weak_alias (_sys_errlist, sys_errlist)");
+ puts ("weak_alias (_sys_nerr, sys_nerr)");
+
+ exit (0);
+}
diff --git a/sysdeps/unix/mips/brk.S b/sysdeps/unix/mips/brk.S
new file mode 100644
index 0000000..1754c0c
--- /dev/null
+++ b/sysdeps/unix/mips/brk.S
@@ -0,0 +1,67 @@
+/* Copyright (C) 1992, 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. */
+
+#include <sysdep.h>
+
+#ifndef SYS_brk
+#define SYS_brk 17
+#endif
+
+#ifndef HAVE_GNU_LD
+#define __end end
+#endif
+
+.data
+.sdata
+ENTRY(__curbrk)
+ .word __end
+
+.text
+.set noreorder
+.set noat
+
+ENTRY(__brk)
+ /* Minimum is one page. */
+ lui v0, 4096
+ lw v0, __end
+ nop
+
+ /* If they ask for less than a page, givvem the whole
+ thing anyway. */
+ sltu AT, a0, v0
+ beq AT, zero, down1
+ nop
+ move a0, v0
+down1:
+ li v0, SYS_brk
+ syscall
+ bne a3, zero, error
+
+ /* Update __curbrk and exit cleanly. */
+ lui AT, 4096
+ sw a0, __curbrk
+ j ra
+ move v0, zero
+
+ /* What a horrible way to die. */
+error: j syscall_error
+ nop
+ nop
+ nop
+
+weak_alias (__brk, brk)
diff --git a/sysdeps/unix/mips/fork.S b/sysdeps/unix/mips/fork.S
new file mode 100644
index 0000000..2347bf4
--- /dev/null
+++ b/sysdeps/unix/mips/fork.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (fork, 0)
+ beq v1, zero, parent /* Branch if parent. */
+ nop
+ /* We are the child. Return zero. */
+ move v0, zero
+parent:
+ ret
+
+weak_alias (__fork, fork)
diff --git a/sysdeps/unix/mips/pipe.S b/sysdeps/unix/mips/pipe.S
new file mode 100644
index 0000000..f8ce56b
--- /dev/null
+++ b/sysdeps/unix/mips/pipe.S
@@ -0,0 +1,31 @@
+/* Copyright (C) 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (pipe, 1)
+ /* Plop in the two descriptors. */
+ sw v0, 0(a0)
+ sw v1, 4(a0)
+
+ /* Go out with a clean status. */
+ j ra
+ move v0, zero
+ nop
+
+weak_alias (__pipe, pipe)
diff --git a/sysdeps/unix/mips/sigreturn.S b/sysdeps/unix/mips/sigreturn.S
new file mode 100644
index 0000000..1e76bf5
--- /dev/null
+++ b/sysdeps/unix/mips/sigreturn.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 1992, 1994, 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. */
+
+#include <sysdep.h>
+
+#ifndef SYS_sigreturn
+#define SYS_sigreturn 103
+#endif
+
+ENTRY(__sigreturn)
+ li v0, SYS_sigreturn
+ syscall
+
+weak_alias (__sigreturn, sigreturn)
diff --git a/sysdeps/unix/mips/sysdep.S b/sysdeps/unix/mips/sysdep.S
new file mode 100644
index 0000000..21bdf23
--- /dev/null
+++ b/sysdeps/unix/mips/sysdep.S
@@ -0,0 +1,41 @@
+/* Copyright (C) 1992, 1993, 1994 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. */
+
+#include <sysdep.h>
+#define _ERRNO_H
+#include <errnos.h>
+
+/* .globl errno */
+.set noreorder
+
+ENTRY(syscall_error)
+#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
+ /* We translate the system's EWOULDBLOCK error into EAGAIN.
+ The GNU C library always defines EWOULDBLOCK==EAGAIN.
+ EWOULDBLOCK_sys is the original number. */
+ bne v0, EWOULDBLOCK_sys, skip
+ nop
+ li v0, EAGAIN
+skip:
+#endif
+ /* Store it in errno... */
+ sw v0, errno
+
+ /* And just kick back a -1. */
+ j ra
+ li v0, -1
diff --git a/sysdeps/unix/mips/sysdep.h b/sysdeps/unix/mips/sysdep.h
new file mode 100644
index 0000000..c09c5af
--- /dev/null
+++ b/sysdeps/unix/mips/sysdep.h
@@ -0,0 +1,52 @@
+/* Copyright (C) 1992, 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. */
+
+#include <sysdeps/unix/sysdep.h>
+
+#ifdef ASSEMBLER
+
+#include <regdef.h>
+
+#define ENTRY(name) \
+ .globl name; \
+ .align 2; \
+ .ent name,0; \
+ name##:
+
+/* Note that while it's better structurally, going back to call syscall_error
+ can make things confusing if you're debugging---it looks like it's jumping
+ backwards into the previous fn. */
+#define PSEUDO(name, syscall_name, args) \
+ .set noreorder; \
+ .align 2; \
+ 99: j syscall_error; \
+ nop; \
+ ENTRY(name) \
+ li v0, SYS_##syscall_name; \
+ syscall; \
+ bne a3, zero, 99b; \
+ nop; \
+syse1:
+
+#define ret j ra ; nop
+#define r0 v0
+#define r1 v1
+/* The mips move insn is d,s. */
+#define MOVE(x,y) move y , x
+
+#endif
diff --git a/sysdeps/unix/mips/wait.S b/sysdeps/unix/mips/wait.S
new file mode 100644
index 0000000..63bce84
--- /dev/null
+++ b/sysdeps/unix/mips/wait.S
@@ -0,0 +1,44 @@
+/* Copyright (C) 1992, 1994, 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. */
+
+#include <sysdep.h>
+
+.set noreorder
+
+ENTRY(__wait)
+ /* Prep it for wait. */
+ move a1, zero
+ move a2, zero
+
+ li v0, SYS_wait
+ syscall
+ beq a3, zero, noerror
+ nop
+ j syscall_error
+ nop
+
+noerror:
+ /* If the arg is not NULL, store v1 there. */
+ beq a0, zero, noarg
+ nop
+ sw v1, 0(a0)
+ nop
+noarg:
+ ret
+
+weak_alias (__wait, wait)
diff --git a/sysdeps/unix/mk-local_lim.c b/sysdeps/unix/mk-local_lim.c
new file mode 100644
index 0000000..c9a1d3d
--- /dev/null
+++ b/sysdeps/unix/mk-local_lim.c
@@ -0,0 +1,118 @@
+/* Copyright (C) 1993 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. */
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+#ifdef HAVE_SYS_LIMITS_H
+#include <sys/limits.h>
+#endif
+
+/* Generate local_lim.h from the values defined in the system's headers. */
+
+struct param
+ {
+ char *name;
+ int value;
+ };
+
+static struct param params[] =
+ {
+
+#if !defined (ARG_MAX) && defined (NCARGS)
+#define ARG_MAX NCARGS
+#endif
+#ifdef ARG_MAX
+ { "ARG_MAX", ARG_MAX },
+#endif
+
+#if !defined (CHILD_MAX) && defined (MAXUPRC)
+#define CHILD_MAX MAXUPRC
+#endif
+#ifdef CHILD_MAX
+ { "CHILD_MAX", CHILD_MAX },
+#endif
+
+#if !defined (LINK_MAX) && defined (MAXLINK)
+#define LINK_MAX MAXLINK
+#endif
+#ifdef LINK_MAX
+ { "LINK_MAX", LINK_MAX },
+#endif
+
+#if !defined (OPEN_MAX) && defined (NOFILE)
+#define OPEN_MAX NOFILE
+#endif
+#ifdef OPEN_MAX
+ { "OPEN_MAX", OPEN_MAX },
+#endif
+
+#if !defined (MAX_CANON) && defined (CANBSIZ)
+#define MAX_CANON CANBSIZ
+#endif
+#ifdef MAX_CANON
+ { "MAX_CANON", MAX_CANON },
+#endif
+
+#if !defined (NAME_MAX) && defined (MAXNAMLEN)
+#define NAME_MAX MAXNAMLEN
+#endif
+#ifndef NAME_MAX
+#define NAME_MAX 255 /* XXX ? */
+#endif
+ { "NAME_MAX", NAME_MAX },
+
+#if !defined (PATH_MAX) && defined (MAXPATHLEN)
+#define PATH_MAX MAXPATHLEN
+#endif
+#ifdef PATH_MAX
+ { "PATH_MAX", PATH_MAX },
+#endif
+
+ { NULL, 0 }
+ };
+
+int
+main()
+{
+ extern char *ctime ();
+ extern time_t time ();
+ time_t now = time ((time_t *) NULL);
+ register struct param *p;
+
+ if (! params[0].name)
+ /* We have no information to give, so let the caller know. */
+ exit (1);
+
+ printf ("\
+/* Implementation-specific limits.\n\
+ Generated at %.24s. */\n\n", ctime (&now));
+
+ for (p = params; p->name != NULL; ++p)
+ printf ("#define %s %d\n", p->name, p->value);
+
+ exit (0);
+}
diff --git a/sysdeps/unix/mkfifo.c b/sysdeps/unix/mkfifo.c
new file mode 100644
index 0000000..776e981
--- /dev/null
+++ b/sysdeps/unix/mkfifo.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1991 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 General Public License as published by
+the Free Software Foundation; either version 2, 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the GNU C Library; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+/* Create a named pipe (FIFO) named PATH with protections MODE. */
+int
+DEFUN(mkfifo, (path, mode), CONST char *path AND mode_t mode)
+{
+ return __mknod (path, mode | S_IFIFO, 0);
+}
diff --git a/sysdeps/unix/mknod.S b/sysdeps/unix/mknod.S
new file mode 100644
index 0000000..76fab52
--- /dev/null
+++ b/sysdeps/unix/mknod.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (mknod, 3)
+ ret
+
+weak_alias (__mknod, mknod)
diff --git a/sysdeps/unix/mman/madvise.S b/sysdeps/unix/mman/madvise.S
new file mode 100644
index 0000000..c22097f
--- /dev/null
+++ b/sysdeps/unix/mman/madvise.S
@@ -0,0 +1,22 @@
+/* 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. */
+
+#include <sysdep.h>
+
+SYSCALL (madvise, 3)
+ ret
diff --git a/sysdeps/unix/mman/mmap.S b/sysdeps/unix/mman/mmap.S
new file mode 100644
index 0000000..dd60f43
--- /dev/null
+++ b/sysdeps/unix/mman/mmap.S
@@ -0,0 +1,22 @@
+/* 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. */
+
+#include <sysdep.h>
+
+SYSCALL (mmap, 5)
+ ret
diff --git a/sysdeps/unix/mman/mprotect.S b/sysdeps/unix/mman/mprotect.S
new file mode 100644
index 0000000..23869e1
--- /dev/null
+++ b/sysdeps/unix/mman/mprotect.S
@@ -0,0 +1,22 @@
+/* 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. */
+
+#include <sysdep.h>
+
+SYSCALL (mprotect, 3)
+ ret
diff --git a/sysdeps/unix/mman/msync.S b/sysdeps/unix/mman/msync.S
new file mode 100644
index 0000000..b165267
--- /dev/null
+++ b/sysdeps/unix/mman/msync.S
@@ -0,0 +1,22 @@
+/* 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. */
+
+#include <sysdep.h>
+
+SYSCALL (msync, 2)
+ ret
diff --git a/sysdeps/unix/mman/munmap.S b/sysdeps/unix/mman/munmap.S
new file mode 100644
index 0000000..6b1ae16
--- /dev/null
+++ b/sysdeps/unix/mman/munmap.S
@@ -0,0 +1,22 @@
+/* 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. */
+
+#include <sysdep.h>
+
+SYSCALL (munmap, 2)
+ ret
diff --git a/sysdeps/unix/nlist.c b/sysdeps/unix/nlist.c
new file mode 100644
index 0000000..5389f65
--- /dev/null
+++ b/sysdeps/unix/nlist.c
@@ -0,0 +1,91 @@
+/* Copyright (C) 1991 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 General Public License as published by
+the Free Software Foundation; either version 2, 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the GNU C Library; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <a.out.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/* Search the executable FILE for symbols matching those in NL,
+ which is terminated by an element with a NULL `n_un.n_name' member,
+ and fill in the elements of NL. */
+int
+DEFUN(nlist, (file, nl),
+ CONST char *file AND struct nlist *nl)
+{
+ FILE *f;
+ struct exec header;
+ size_t nsymbols;
+ struct nlist *symbols;
+ unsigned long int string_table_size;
+ char *string_table;
+ register size_t i;
+
+ if (nl == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ f = fopen(file, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fread((PTR) &header, sizeof(header), 1, f) != 1)
+ goto lose;
+
+ if (fseek(f, N_SYMOFF(header), SEEK_SET) != 0)
+ goto lose;
+
+ symbols = (struct nlist *) __alloca(header.a_syms);
+ nsymbols = header.a_syms / sizeof(symbols[0]);
+
+ if (fread((PTR) symbols, sizeof(symbols[0]), nsymbols, f) != nsymbols)
+ goto lose;
+
+ if (fread((PTR) &string_table_size, sizeof(string_table_size), 1, f) != 1)
+ goto lose;
+ string_table_size -= sizeof(string_table_size);
+
+ string_table = (char *) __alloca(string_table_size);
+ if (fread((PTR) string_table, string_table_size, 1, f) != 1)
+ goto lose;
+
+ for (i = 0; i < nsymbols; ++i)
+ {
+ register struct nlist *nlp;
+ for (nlp = nl; nlp->n_un.n_name != NULL; ++nlp)
+ if (!strcmp(nlp->n_un.n_name,
+ &string_table[symbols[i].n_un.n_strx -
+ sizeof(string_table_size)]))
+ {
+ char *CONST name = nlp->n_un.n_name;
+ *nlp = symbols[i];
+ nlp->n_un.n_name = name;
+ }
+ }
+
+ (void) fclose(f);
+ return 0;
+
+ lose:;
+ (void) fclose(f);
+ return -1;
+}
diff --git a/sysdeps/unix/open.S b/sysdeps/unix/open.S
new file mode 100644
index 0000000..c999677
--- /dev/null
+++ b/sysdeps/unix/open.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (open, 3)
+ ret
+
+weak_alias (__open, open)
diff --git a/sysdeps/unix/opendir.c b/sysdeps/unix/opendir.c
new file mode 100644
index 0000000..d03f45e
--- /dev/null
+++ b/sysdeps/unix/opendir.c
@@ -0,0 +1,95 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdio.h>
+
+#include "direct.h" /* This file defines `struct direct'. */
+
+/* Open a directory stream on NAME. */
+DIR *
+DEFUN(opendir, (name), CONST char *name)
+{
+ DIR *dirp;
+ struct stat statbuf;
+ int fd;
+
+ if (name[0] == '\0')
+ {
+ /* POSIX.1-1990 says an empty name gets ENOENT;
+ but `open' might like it fine. */
+ errno = ENOENT;
+ return NULL;
+ }
+
+ fd = __open (name, O_RDONLY);
+ if (fd < 0)
+ return NULL;
+
+ if (fcntl (fd, F_SETFD, FD_CLOEXEC) < 0)
+ goto lose;
+
+ if (fstat (fd, &statbuf) < 0)
+ goto lose;
+ if (! S_ISDIR (statbuf.st_mode))
+ {
+ errno = ENOTDIR;
+ goto lose;
+ }
+
+ dirp = (DIR *) calloc (1, sizeof (DIR) + NAME_MAX); /* Zero-fill. */
+ if (dirp == NULL)
+ lose:
+ {
+ int save = errno;
+ (void) __close (fd);
+ errno = save;
+ return NULL;
+ }
+
+#ifdef _STATBUF_ST_BLKSIZE
+ if (statbuf.st_blksize < sizeof (struct direct))
+ dirp->__allocation = sizeof (struct direct);
+ else
+ dirp->__allocation = statbuf.st_blksize;
+#else
+ dirp->__allocation = (BUFSIZ < sizeof (struct direct) ?
+ sizeof (struct direct) : BUFSIZ);
+#endif
+ dirp->__data = (char *) malloc (dirp->__allocation);
+ if (dirp->__data == NULL)
+ {
+ int save = errno;
+ free ((PTR) dirp);
+ (void) __close (fd);
+ errno = save;
+ return NULL;
+ }
+
+ dirp->__fd = fd;
+ return dirp;
+}
diff --git a/sysdeps/unix/pipestream.c b/sysdeps/unix/pipestream.c
new file mode 100644
index 0000000..1d3308f
--- /dev/null
+++ b/sysdeps/unix/pipestream.c
@@ -0,0 +1,2 @@
+#define NO_WAITPID
+#include <sysdeps/posix/pipestream.c>
diff --git a/sysdeps/unix/ptrace.S b/sysdeps/unix/ptrace.S
new file mode 100644
index 0000000..dcdb041
--- /dev/null
+++ b/sysdeps/unix/ptrace.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (ptrace, 4)
+ ret
diff --git a/sysdeps/unix/read.S b/sysdeps/unix/read.S
new file mode 100644
index 0000000..016e4c7
--- /dev/null
+++ b/sysdeps/unix/read.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (read, 3)
+ ret
+
+weak_alias (__read, read)
diff --git a/sysdeps/unix/readdir.c b/sysdeps/unix/readdir.c
new file mode 100644
index 0000000..3ffa63e
--- /dev/null
+++ b/sysdeps/unix/readdir.c
@@ -0,0 +1,82 @@
+/* Copyright (C) 1991, 1992, 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <limits.h>
+#include <stddef.h>
+#include <string.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "direct.h" /* This file defines `struct direct'. */
+
+/* direct.h may have an alternate definition for this. */
+#ifndef D_RECLEN
+#define D_RECLEN(dp) ((dp)->d_reclen)
+#endif
+
+
+/* Read a directory entry from DIRP. */
+struct dirent *
+DEFUN(readdir, (dirp), DIR *dirp)
+{
+ if (dirp == NULL || dirp->__data == NULL)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ while (1)
+ {
+ struct direct *dp;
+
+ if (dirp->__offset >= dirp->__size)
+ {
+ /* We've emptied out our buffer. Refill it. */
+
+ off_t base;
+ ssize_t bytes = __getdirentries (dirp->__fd, dirp->__data,
+ dirp->__allocation, &base);
+ if (bytes <= 0)
+ return NULL;
+ dirp->__size = (size_t) bytes;
+
+ /* Reset the offset into the buffer. */
+ dirp->__offset = 0;
+ }
+
+ dp = (struct direct *) &dirp->__data[dirp->__offset];
+ dirp->__offset += D_RECLEN (dp);
+
+ if (dp->d_ino != 0)
+ {
+ /* Not a deleted file. */
+ register struct dirent *d = &dirp->__entry;
+ register const char *p;
+ d->d_fileno = (ino_t) dp->d_ino;
+ /* On some systems the name length does not actually mean much.
+ But we always use it as a maximum. */
+ p = memchr ((PTR) dp->d_name, '\0', D_NAMLEN (dp) + 1);
+ d->d_namlen = (p != NULL) ? p - dp->d_name : D_NAMLEN (dp);
+ memcpy (d->d_name, dp->d_name, d->d_namlen + 1);
+ return d;
+ }
+ }
+}
diff --git a/sysdeps/unix/reboot.S b/sysdeps/unix/reboot.S
new file mode 100644
index 0000000..4e2023b
--- /dev/null
+++ b/sysdeps/unix/reboot.S
@@ -0,0 +1,22 @@
+/* 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. */
+
+#include <sysdep.h>
+
+SYSCALL (reboot, 1)
+ ret
diff --git a/sysdeps/unix/rewinddir.c b/sysdeps/unix/rewinddir.c
new file mode 100644
index 0000000..3b82895
--- /dev/null
+++ b/sysdeps/unix/rewinddir.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+
+/* Rewind DIRP to the beginning of the directory. */
+void
+DEFUN(rewinddir, (dirp), DIR *dirp)
+{
+ (void) lseek(dirp->__fd, (off_t) 0, SEEK_SET);
+ dirp->__offset = 0;
+ dirp->__size = 0;
+}
diff --git a/sysdeps/unix/seekdir.c b/sysdeps/unix/seekdir.c
new file mode 100644
index 0000000..b8d5c3c
--- /dev/null
+++ b/sysdeps/unix/seekdir.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <dirent.h>
+#include <unistd.h>
+
+/* Seek to position POS in DIRP. */
+void
+DEFUN(seekdir, (dirp, pos), DIR *dirp AND __off_t pos)
+{
+ pos -= dirp->__size - dirp->__offset;
+ (void) __lseek(dirp->__fd, pos, SEEK_SET);
+ dirp->__size = 0;
+ dirp->__offset = 0;
+}
diff --git a/sysdeps/unix/setgid.S b/sysdeps/unix/setgid.S
new file mode 100644
index 0000000..4fd02e1
--- /dev/null
+++ b/sysdeps/unix/setgid.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (setgid, 1)
+ ret
+
+weak_alias (__setgid, setgid)
diff --git a/sysdeps/unix/setuid.S b/sysdeps/unix/setuid.S
new file mode 100644
index 0000000..d17961b
--- /dev/null
+++ b/sysdeps/unix/setuid.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (setuid, 1)
+ ret
+
+weak_alias (__setuid, setuid)
diff --git a/sysdeps/unix/siglist.c b/sysdeps/unix/siglist.c
new file mode 100644
index 0000000..c904e7f
--- /dev/null
+++ b/sysdeps/unix/siglist.c
@@ -0,0 +1,46 @@
+#include <ansidecl.h>
+#include <stddef.h>
+
+#ifndef HAVE_GNU_LD
+#define _sys_siglist sys_siglist
+#endif
+
+/* This is a list of all known signal numbers. */
+
+CONST char *CONST _sys_siglist[] =
+ {
+ "Signal 0",
+ "Hangup",
+ "Interrupt",
+ "Quit",
+ "Illegal instruction",
+ "Trace/BPT trap",
+ "IOT trap",
+ "EMT trap",
+ "Floating point exception",
+ "Killed",
+ "Bus error",
+ "Segmentation fault",
+ "Bad system call",
+ "Broken pipe",
+ "Alarm clock",
+ "Terminated",
+ "Urgent I/O condition",
+ "Stopped (signal)",
+ "Stopped",
+ "Continued",
+ "Child exited",
+ "Stopped (tty input)",
+ "Stopped (tty output)",
+ "I/O possible",
+ "Cputime limit exceeded",
+ "Filesize limit exceeded",
+ "Virtual timer expired",
+ "Profiling timer expired",
+ "Window changed",
+ "Resource lost",
+ "User defined signal 1",
+ "User defined signal 2",
+ NULL
+ };
+
diff --git a/sysdeps/unix/snarf-ioctls b/sysdeps/unix/snarf-ioctls
new file mode 100755
index 0000000..d2d02b1
--- /dev/null
+++ b/sysdeps/unix/snarf-ioctls
@@ -0,0 +1,46 @@
+#!/bin/sh
+# Copyright (C) 1991, 1992 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 General Public License as published by
+# the Free Software Foundation; either version 1, 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 General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with the GNU C Library; see the file COPYING. If not, write to
+# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+sysincludedir=${sysincludedir-/usr/include}
+
+if [ ! "$snarfexclude" ]; then
+ # Filter out some headers which cause trouble.
+ snarfexclude="`echo !${sysincludedir}/sys/param.h! \
+ !${sysincludedir}/sys/time.h! \
+ !${sysincludedir}/sys/types.h! \
+ | sed -e 's,/,\\\\/,g' \
+ -e 's,!\\([^!]*\\)!,-e /\\1/d,g'`"
+fi
+
+for file in $*; do
+ sed -n 's/^#define[ ]*\([A-Z][A-Z0-9_]*\)[ ][ ]*[^ ].*$/\1/p' \
+ < $file
+
+ snarfexclude="$snarfexclude \
+ `echo $file | sed -e 's,/,\\\\/,g' -e 's,^.*$,-e /&/d,'`"
+ export snarfexclude
+
+ included="`sed -n < $file \
+ -e 's,^#include[ ]*<\(.*\)>.*$,'${sysincludedir}'/\1,p'\
+ | sed $snarfexclude`"
+ if [ "$included" ]; then
+ $0 $included
+ fi
+done
+
+exit 0
diff --git a/sysdeps/unix/sparc/brk.S b/sysdeps/unix/sparc/brk.S
new file mode 100644
index 0000000..7906695
--- /dev/null
+++ b/sysdeps/unix/sparc/brk.S
@@ -0,0 +1,55 @@
+/* Copyright (C) 1993, 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. */
+
+#include <sysdep.h>
+
+#ifndef SYS_brk
+#define SYS_brk 17
+#endif
+
+#ifndef C_SYMBOL_NAME
+#define C_SYMBOL_NAME(name) _##name
+#endif
+
+.data
+.global C_SYMBOL_NAME(__curbrk)
+C_LABEL(__curbrk)
+#ifdef HAVE_GNU_LD
+ .long C_SYMBOL_NAME(_end)
+#else
+ .long C_SYMBOL_NAME(end)
+#endif
+
+.text
+ENTRY (__brk)
+ add %o0, 7, %o0
+ andn %o0, 7, %o0
+ mov SYS_brk, %g1
+ mov %o0, %o1 /* Save rounded value. */
+ ta %g0
+ bcs error
+ sethi %hi(C_SYMBOL_NAME(__curbrk)), %g1
+ st %o1, [%g1 + %lo(C_SYMBOL_NAME(__curbrk))]
+ ret
+error: sethi %hi(C_SYMBOL_NAME(errno)), %g1
+ st %o0, [%g1 + %lo(C_SYMBOL_NAME(errno))]
+ sub %g0, 1, %o0
+ retl
+ nop /* Fill the delay slot. */
+
+weak_alias (__brk, brk)
diff --git a/sysdeps/unix/sparc/fork.S b/sysdeps/unix/sparc/fork.S
new file mode 100644
index 0000000..dee15ad
--- /dev/null
+++ b/sysdeps/unix/sparc/fork.S
@@ -0,0 +1,30 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (fork, 0)
+ /* %o1 is now 0 for the parent and 1 for the child. Decrement it to
+ make it -1 (all bits set) for the parent, and 0 (no bits set)
+ for the child. Then AND it with %o0, so the parent gets
+ %o0&-1==0, and the child gets %o0&0==0. */
+ sub %o1, 1, %o1
+ retl
+ and %o0, %o1, %o0
+
+weak_alias (__fork, fork)
diff --git a/sysdeps/unix/sparc/pipe.S b/sysdeps/unix/sparc/pipe.S
new file mode 100644
index 0000000..3929413
--- /dev/null
+++ b/sysdeps/unix/sparc/pipe.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+ENTRY (__pipe)
+ mov %o0, %o2 /* Save PIPEDES. */
+PSEUDO (__Spipe, pipe, 1)
+ st %o0, [%o2] /* PIPEDES[0] = %o0; */
+ st %o1, [%o2 + 4] /* PIPEDES[1] = %o1; */
+ retl /* return 0; */
+ clr %o0
+
+weak_alias (__pipe, pipe)
diff --git a/sysdeps/unix/sparc/start.c b/sysdeps/unix/sparc/start.c
new file mode 100644
index 0000000..e0f39f5
--- /dev/null
+++ b/sysdeps/unix/sparc/start.c
@@ -0,0 +1,184 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#ifndef NO_SHLIB
+#include <sys/exec.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <link.h>
+#include <syscall.h>
+#endif
+
+#if !defined (__GNUC__) || __GNUC__ < 2
+ #error This file uses GNU C extensions; you must compile with GCC version 2.
+#endif
+
+/* The first piece of initialized data. */
+int __data_start = 0;
+#ifdef HAVE_WEAK_SYMBOLS
+weak_alias (__data_start, data_start)
+#endif
+
+VOLATILE int errno;
+
+#ifdef HAVE_WEAK_SYMBOLS
+weak_alias (__environ, environ)
+#else
+#undef environ
+#define __environ environ
+#endif
+
+char **__environ;
+
+extern void EXFUN(__libc_init, (int argc, char **argv, char **envp));
+extern int EXFUN(main, (int argc, char **argv, char **envp));
+
+register long int sp asm("%sp"), fp asm("%fp");
+
+#ifndef NO_SHLIB
+static void EXFUN(init_shlib, (NOARGS));
+#endif
+
+#ifndef NO_EXPLICIT_START
+/* Declare _start with an explicit assembly symbol name of `start'
+ (note no leading underscore). This is the name Sun's crt0.o uses,
+ and programs are often linked with `ld -e start'. */
+void _start (void) asm ("start");
+#endif
+
+void
+_start (void)
+{
+ /* It is important that these be declared `register'.
+ Otherwise, when compiled without optimization, they are put on the
+ stack, which loses completely after we zero the FP. */
+ register int argc;
+ register char **argv, **envp;
+
+ /* Unwind the frame built when we entered the function. */
+ asm("restore");
+
+ /* And clear the frame pointer. */
+ fp = 0;
+
+ /* The argument info starts after one register
+ window (64 bytes) past the SP. */
+ argc = ((int *) sp)[16];
+ argv = (char **) &((int *) sp)[17];
+ envp = &argv[argc + 1];
+ __environ = envp;
+
+#ifndef NO_SHLIB
+ init_shlib ();
+#endif
+
+ /* Allocate 24 bytes of stack space for the register save area. */
+ sp -= 24;
+ __libc_init (argc, argv, envp);
+
+ exit (main (argc, argv, envp));
+}
+
+#ifndef NO_SHLIB
+
+/* System calls for use by the bootstrap routine.
+ These are defined here since the usual calls may be dynamically linked. */
+
+int syscall (int sysno, ...) asm ("init_syscall");
+asm ("init_syscall:\n"
+ " clr %g1\n"
+ " ta 0\n"
+ " bcc 1f\n"
+ " sethi %hi(_errno), %g1\n"
+ " st %o0, [%g1 + %lo(_errno)]\n"
+ " sub %g0, 1, %o0\n"
+ "1:retl\n"
+ " nop");
+
+static void
+DEFUN_VOID(init_shlib)
+{
+ extern struct link_dynamic _DYNAMIC;
+ int so, zf;
+ caddr_t somap;
+ caddr_t sodmap;
+ caddr_t sobssmap;
+ void (*ldstart) (int, int);
+ struct exec soexec;
+ struct
+ {
+ caddr_t crt_ba;
+ int crt_dzfd;
+ int crt_ldfd;
+ struct link_dynamic *crt_dp;
+ char **crt_ep;
+ caddr_t crt_bp;
+ } soarg;
+
+ /* If not dynamically linked, do nothing. */
+ if (&_DYNAMIC == 0)
+ return;
+
+ /* Map in the dynamic linker. */
+ so = syscall (SYS_open, "/usr/lib/ld.so", O_RDONLY);
+ if (syscall (SYS_read, so, &soexec, sizeof (soexec)) != sizeof (soexec)
+ || soexec.a_magic != ZMAGIC)
+ {
+ static CONST char emsg[] = "crt0: no /usr/lib/ld.so\n";
+
+ syscall (SYS_write, 2, emsg, sizeof (emsg) - 1);
+ syscall (SYS_exit, 127);
+ }
+ somap = (caddr_t) syscall (SYS_mmap, 0,
+ soexec.a_text + soexec.a_data + soexec.a_bss,
+ PROT_READ | PROT_EXEC, _MAP_NEW | MAP_PRIVATE,
+ so, 0);
+ sodmap = (caddr_t) syscall (SYS_mmap, somap + soexec.a_text, soexec.a_data,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ _MAP_NEW | MAP_FIXED | MAP_PRIVATE,
+ so, soexec.a_text);
+ zf = syscall (SYS_open, "/dev/zero", O_RDONLY);
+ if (soexec.a_bss != 0)
+ sobssmap = (caddr_t) syscall (SYS_mmap,
+ somap + soexec.a_text + soexec.a_data,
+ soexec.a_bss,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ _MAP_NEW | MAP_FIXED | MAP_PRIVATE,
+ zf, 0);
+
+ /* Call the entry point of the dynamic linker. */
+ soarg.crt_ba = somap;
+ soarg.crt_dzfd = zf;
+ soarg.crt_ldfd = so;
+ soarg.crt_dp = &_DYNAMIC;
+ soarg.crt_ep = __environ;
+ soarg.crt_bp = (caddr_t) &&retaddr;
+
+ ldstart = (__typeof (ldstart)) (somap + soexec.a_entry);
+ (*ldstart) (1, (char *) &soarg - (char *) sp);
+
+ retaddr:
+}
+
+#endif
diff --git a/sysdeps/unix/sparc/sysdep.S b/sysdeps/unix/sparc/sysdep.S
new file mode 100644
index 0000000..d04a778
--- /dev/null
+++ b/sysdeps/unix/sparc/sysdep.S
@@ -0,0 +1,47 @@
+/* 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. */
+
+#include <sysdep.h>
+#define _ERRNO_H
+#include <errnos.h>
+
+.global C_SYMBOL_NAME(errno)
+.global syscall_error
+
+.text
+.align 2
+#undef syscall_error
+#ifdef NO_UNDERSCORES
+__syscall_error:
+#else
+syscall_error:
+#endif
+#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
+ /* We translate the system's EWOULDBLOCK error into EAGAIN.
+ The GNU C library always defines EWOULDBLOCK==EAGAIN.
+ EWOULDBLOCK_sys is the original number. */
+ cmp %o0, EWOULDBLOCK_sys
+ be,a notblock
+ mov EAGAIN, %o0
+#endif
+notblock: /* Store the error code in `errno'. */
+ sethi %hi(C_SYMBOL_NAME(errno)), %g1
+ st %o0, [%g1 + %lo(C_SYMBOL_NAME(errno))]
+ /* And return -1. */
+ retl
+ mov -1, %o0
diff --git a/sysdeps/unix/sparc/sysdep.h b/sysdeps/unix/sparc/sysdep.h
new file mode 100644
index 0000000..eab661c
--- /dev/null
+++ b/sysdeps/unix/sparc/sysdep.h
@@ -0,0 +1,50 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <sysdeps/unix/sysdep.h>
+
+#ifdef ASSEMBLER
+
+#ifdef NO_UNDERSCORES
+/* Since C identifiers are not normally prefixed with an underscore
+ on this system, the asm identifier `syscall_error' intrudes on the
+ C name space. Make sure we use an innocuous name. */
+#define syscall_error C_SYMBOL_NAME(__syscall_error)
+#endif
+
+#define ENTRY(name) \
+ .global C_SYMBOL_NAME(name); \
+ .align 2; \
+ C_LABEL(name)
+
+#define PSEUDO(name, syscall_name, args) \
+ .global syscall_error; \
+ ENTRY (name) \
+ mov SYS_ify(syscall_name), %g1; \
+ ta 0; \
+ bcc 1f; \
+ sethi %hi(syscall_error), %g1; \
+ jmp %g1 + %lo(syscall_error); nop; \
+1:
+
+#define ret retl; nop
+#define r0 %o0
+#define r1 %o1
+#define MOVE(x,y) mov x, y
+
+#endif /* ASSEMBLER */
diff --git a/sysdeps/unix/sparc/vfork.S b/sysdeps/unix/sparc/vfork.S
new file mode 100644
index 0000000..aeee378
--- /dev/null
+++ b/sysdeps/unix/sparc/vfork.S
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991, 1992, 1994, 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. */
+
+#include <sysdep.h>
+
+#ifndef SYS_vfork
+#define SYS_vfork 66
+#endif
+
+SYSCALL__ (vfork, 0)
+ /* %o1 is now 0 for the parent and 1 for the child. Decrement it to
+ make it -1 (all bits set) for the parent, and 0 (no bits set)
+ for the child. Then AND it with %o0, so the parent gets
+ %o0&-1==0, and the child gets %o0&0==0. */
+ sub %o1, 1, %o1
+ retl
+ and %o0, %o1, %o0
+
+weak_alias (__vfork, vfork)
diff --git a/sysdeps/unix/start.c b/sysdeps/unix/start.c
new file mode 100644
index 0000000..da7ec71
--- /dev/null
+++ b/sysdeps/unix/start.c
@@ -0,0 +1,106 @@
+/* Copyright (C) 1991, 1993, 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 General Public License as published by
+the Free Software Foundation; either version 2, 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with the GNU C Library; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sysdep.h> /* In case it wants to define anything. */
+
+/* The first piece of initialized data. */
+int __data_start = 0;
+#ifdef HAVE_WEAK_SYMBOLS
+weak_alias (__data_start, data_start)
+#endif
+
+#ifdef DUMMIES
+#define ARG_DUMMIES DUMMIES,
+#define DECL_DUMMIES int DUMMIES;
+#else
+#define ARG_DUMMIES
+#define DECL_DUMMIES
+#endif
+
+VOLATILE int errno;
+
+#ifdef HAVE_WEAK_SYMBOLS
+weak_alias (__environ, environ)
+#else
+#undef environ
+#define __environ environ
+#endif
+
+char **__environ;
+
+extern void EXFUN(__libc_init, (int argc, char **argv, char **envp));
+extern int EXFUN(main, (int argc, char **argv, char **envp));
+
+
+/* Not a prototype because it gets called strangely. */
+static void start1();
+
+#ifndef HAVE__start
+
+#if !defined (NO_UNDERSCORES) && defined (__GNUC__)
+/* Declare _start with an explicit assembly symbol name of `start'
+ (note no leading underscore). This is the name vendor crt0.o's
+ tend to use, and thus the name most linkers expect. */
+void _start (void) asm ("start");
+#endif
+
+/* N.B.: It is important that this be the first function.
+ This file is the first thing in the text section. */
+void
+DEFUN_VOID(_start)
+{
+ start1();
+}
+
+#if !defined (NO_UNDERSCORES) && defined (HAVE_GNU_LD) && !defined (__GNUC__)
+/* Make an alias called `start' (no leading underscore,
+ so it can't conflict with C symbols) for `_start'. */
+asm(".stabs \"start\",11,0,0,0");
+asm(".stabs \"__start\",1,0,0,0");
+#endif
+
+#endif
+
+/* ARGSUSED */
+static void
+start1(ARG_DUMMIES argc, argp)
+ DECL_DUMMIES
+ int argc;
+ char *argp;
+{
+ char **argv = &argp;
+
+ /* The environment starts just after ARGV. */
+ __environ = &argv[argc + 1];
+
+ /* If the first thing after ARGV is the arguments
+ themselves, there is no environment. */
+ if ((char *) __environ == *argv)
+ /* The environment is empty. Make __environ
+ point at ARGV[ARGC], which is NULL. */
+ --__environ;
+
+ /* Do C library initializations. */
+ __libc_init (argc, argv, __environ);
+
+ /* Call the user program. */
+ exit(main(argc, argv, __environ));
+}
diff --git a/sysdeps/unix/stat.S b/sysdeps/unix/stat.S
new file mode 100644
index 0000000..8ffd60a
--- /dev/null
+++ b/sysdeps/unix/stat.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (stat, 2)
+ ret
+
+weak_alias (__stat, stat)
diff --git a/sysdeps/unix/sync.S b/sysdeps/unix/sync.S
new file mode 100644
index 0000000..d82db0e
--- /dev/null
+++ b/sysdeps/unix/sync.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (sync, 0)
+ ret
diff --git a/sysdeps/unix/syscall.S b/sysdeps/unix/syscall.S
new file mode 100644
index 0000000..e3ef177
--- /dev/null
+++ b/sysdeps/unix/syscall.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 1993 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. */
+
+#include <sysdep.h>
+
+#ifndef SYS_syscall
+#define SYS_syscall 0
+#endif
+
+/* This works if the kernel does an "indirect system call" for system call 0,
+ taking the first argument word off the stack as the system call number. */
+
+SYSCALL (syscall, 1)
+ ret
diff --git a/sysdeps/unix/sysdep.h b/sysdeps/unix/sysdep.h
new file mode 100644
index 0000000..07c539b
--- /dev/null
+++ b/sysdeps/unix/sysdep.h
@@ -0,0 +1,59 @@
+/* Copyright (C) 1991, 1992, 1993 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. */
+
+#include <syscall.h>
+#define HAVE_SYSCALLS
+
+/* Note that using a `PASTE' macro loses. */
+#ifdef __STDC__
+#define SYSCALL__(name, args) PSEUDO (__##name, name, args)
+#else
+#define SYSCALL__(name, args) PSEUDO (__/**/name, name, args)
+#endif
+#define SYSCALL(name, args) PSEUDO (name, name, args)
+
+/* Machine-dependent sysdep.h files are expected to define the macro
+ PSEUDO (function_name, syscall_name) to emit assembly code to define the
+ C-callable function FUNCTION_NAME to do system call SYSCALL_NAME.
+ r0 and r1 are the system call outputs. MOVE(x, y) should be defined as
+ an instruction such that "MOVE(r1, r0)" works. ret should be defined
+ as the return instruction. */
+
+/* Define a macro we can use to construct the asm name for a C symbol. */
+#ifdef NO_UNDERSCORES
+#define C_SYMBOL_NAME(name) name
+#ifdef __STDC__
+#define C_LABEL(name) name##:
+#else
+#define C_LABEL(name) name/**/:
+#endif
+#else
+#ifdef __STDC__
+#define C_SYMBOL_NAME(name) _##name
+#define C_LABEL(name) _##name##:
+#else
+#define C_SYMBOL_NAME(name) _/**/name
+#define C_LABEL(name) _/**/name/**/:
+#endif
+#endif
+
+#ifdef __STDC__
+#define SYS_ify(syscall_name) SYS_##syscall_name
+#else
+#define SYS_ify(syscall_name) SYS_/**/syscall_name
+#endif
diff --git a/sysdeps/unix/system.c b/sysdeps/unix/system.c
new file mode 100644
index 0000000..2c52ec8
--- /dev/null
+++ b/sysdeps/unix/system.c
@@ -0,0 +1,2 @@
+#define NO_WAITPID
+#include <sysdeps/posix/system.c>
diff --git a/sysdeps/unix/sysv/Dist b/sysdeps/unix/sysv/Dist
new file mode 100644
index 0000000..f70fcf6
--- /dev/null
+++ b/sysdeps/unix/sysv/Dist
@@ -0,0 +1,3 @@
+sysv_termio.h
+utmp.h
+s_getdents.S
diff --git a/sysdeps/unix/sysv/Makefile b/sysdeps/unix/sysv/Makefile
new file mode 100644
index 0000000..b407660
--- /dev/null
+++ b/sysdeps/unix/sysv/Makefile
@@ -0,0 +1,42 @@
+# Copyright (C) 1992, 1993, 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.
+
+ifeq ($(subdir), misc)
+
+sysdep_headers := $(sysdep_headers) termio.h
+generated := $(generated) termio.h
+
+# termio.h is just like sysv_termio.h except it uses the same names for
+# everything that System V termio does. sysv_termio.h is necessary to
+# include in __tcgetatr.c et al, because some of the names in termio.h
+# conflict with termios.h. The C library doesn't actually use termio.h,
+# but we generate it for those application programs which use it.
+$(objpfx)termio.h: $(..)sysdeps/unix/sysv/sysv_termio.h
+ sed < $< > $@-tmp \
+ -e 's/_SYSV_//' \
+ -e 's/^#define[ ]*_T/#define T/'\
+ -e 's/__sysv_termio/termio/'
+ mv $@-tmp $@
+
+endif
+
+ifeq ($(subdir),dirent)
+
+sysdep_routines := $(sysdep_routines) s_getdents
+
+endif
diff --git a/sysdeps/unix/sysv/alarm.S b/sysdeps/unix/sysv/alarm.S
new file mode 100644
index 0000000..6c002d4
--- /dev/null
+++ b/sysdeps/unix/sysv/alarm.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (alarm, 1)
+ ret
diff --git a/sysdeps/unix/sysv/direct.h b/sysdeps/unix/sysv/direct.h
new file mode 100644
index 0000000..dc1d77b
--- /dev/null
+++ b/sysdeps/unix/sysv/direct.h
@@ -0,0 +1,10 @@
+struct direct
+ {
+ unsigned short int d_fileno;
+ char d_name[14];
+ };
+
+#define D_NAMLEN(d) \
+ ((d)->d_name[13] == '\0' ? strlen ((d)->d_name) : 14)
+
+#define D_RECLEN(d) (sizeof (*(d)))
diff --git a/sysdeps/unix/sysv/fcntlbits.h b/sysdeps/unix/sysv/fcntlbits.h
new file mode 100644
index 0000000..d7dbd0c
--- /dev/null
+++ b/sysdeps/unix/sysv/fcntlbits.h
@@ -0,0 +1,86 @@
+/* O_*, F_*, FD_* bit values for System V.
+Copyright (C) 1991, 1992 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 _FCNTLBITS_H
+
+#define _FCNTLBITS_H 1
+
+
+/* File access modes for `open' and `fcntl'. */
+#define O_RDONLY 0 /* Open read-only. */
+#define O_WRONLY 1 /* Open write-only. */
+#define O_RDWR 2 /* Open read/write. */
+
+
+/* Bits OR'd into the second argument to open. */
+#define O_CREAT 00400 /* Create file if it doesn't exist. */
+#define O_EXCL 02000 /* Fail if file already exists. */
+#define O_TRUNC 01000 /* Truncate file to zero length. */
+#if defined (__USE_BSD) || defined (__USE_SVID)
+#define O_SYNC 00020 /* Synchronous writes. */
+#endif
+
+/* File status flags for `open' and `fcntl'. */
+#define O_APPEND 000010 /* Writes append to the file. */
+#define O_NONBLOCK 000004 /* Non-blocking I/O. */
+
+#ifdef __USE_BSD
+/* System V doesn't support POSIX.1 O_NONBLOCK, but O_NDELAY is close. */
+#define O_NDELAY O_NONBLOCK
+#endif
+
+/* Mask for file access modes. This is system-dependent in case
+ some system ever wants to define some other flavor of access. */
+#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
+
+/* Values for the second argument to `fcntl'. */
+#define F_DUPFD 0 /* Duplicate file descriptor. */
+#define F_GETFD 1 /* Get file descriptor flags. */
+#define F_SETFD 2 /* Set file descriptor flags. */
+#define F_GETFL 3 /* Get file status flags. */
+#define F_SETFL 4 /* Set file status flags. */
+#define F_GETLK 5 /* Get record locking info. */
+#define F_SETLK 6 /* Set record locking info. */
+#define F_SETLKW 7 /* Set record locking info, wait. */
+
+/* File descriptor flags used with F_GETFD and F_SETFD. */
+#define FD_CLOEXEC 1 /* Close on exec. */
+
+
+#include <gnu/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. */
+struct flock
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+ short int l_sysid; /* System ID where locking process resides. */
+ short int l_pid; /* Process holding the lock. */
+ };
+
+/* Values for the `l_type' field of a `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/sysv/getdents.c b/sysdeps/unix/sysv/getdents.c
new file mode 100644
index 0000000..bb6c812
--- /dev/null
+++ b/sysdeps/unix/sysv/getdents.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1993, 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. */
+
+#include <ansidecl.h>
+#include <stddef.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+extern int __getdents __P ((int fd, char *buf, size_t nbytes));
+
+int
+DEFUN(__getdirentries, (fd, buf, nbytes, basep),
+ int fd AND char *buf AND size_t nbytes AND off_t *basep)
+{
+ if (basep)
+ *basep = __lseek (fd, (off_t) 0, SEEK_CUR);
+
+ return __getdents (fd, buf, nbytes);
+}
+
+weak_alias (__getdirentries, getdirentries)
diff --git a/sysdeps/unix/sysv/gethostname.c b/sysdeps/unix/sysv/gethostname.c
new file mode 100644
index 0000000..509a3da
--- /dev/null
+++ b/sysdeps/unix/sysv/gethostname.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/utsname.h>
+
+/* Put the name of the current host in no more than LEN bytes of NAME.
+ The result is null-terminated if LEN is large enough for the full
+ name and the terminator. */
+int
+DEFUN(__gethostname, (name, len),
+ char *name AND size_t len)
+{
+ struct utsname buf;
+ if (uname (&buf))
+ return -1;
+ strncpy (name, buf.nodename, len);
+ return 0;
+}
+
+weak_alias (__gethostname, gethostname)
diff --git a/sysdeps/unix/sysv/i386/linux/socket.S b/sysdeps/unix/sysv/i386/linux/socket.S
new file mode 100644
index 0000000..9f59bad
--- /dev/null
+++ b/sysdeps/unix/sysv/i386/linux/socket.S
@@ -0,0 +1,55 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+.globl syscall_error
+
+/* The socket-oriented system calls are handled unusally in Linux.
+ They are all gated through the single `socketcall' system call number.
+ `socketcall' takes two arguments: the first is the subcode, specifying
+ which socket function is being called; and the second is a pointer to
+ the arguments to specific function.
+
+ The .S files for the other calls just #define socket and #include this. */
+
+ENTRY (socket)
+
+ /* Save registers. */
+ pushl %ebx
+ pushl %ecx
+
+ movl $__NR_socketcall, %eax /* System call number in %eax. */
+
+ /* Use ## so `socket' is a separate token that might be #define'd. */
+ movl $SYS_##socket, %ebx /* Subcode is first arg to syscall. */
+ lea 12(%esp), %ecx /* Address of args in 2nd arg. */
+
+ /* Do the system call trap. */
+ int $0x80
+
+ /* Restore registers. */
+ popl %ecx
+ popl %ebx
+
+ /* %eax is < 0 if there was an error. */
+ testl %eax, %eax
+ jl syscall_error
+
+ /* Successful; return the syscall's value. */
+ ret
diff --git a/sysdeps/unix/sysv/i386/linux/sysdep.S b/sysdeps/unix/sysv/i386/linux/sysdep.S
new file mode 100644
index 0000000..ed3a278
--- /dev/null
+++ b/sysdeps/unix/sysv/i386/linux/sysdep.S
@@ -0,0 +1,38 @@
+/* Copyright (C) 1992, 1993, 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. */
+
+#include <sysdep.h>
+#define _ERRNO_H
+#include <errnos.h>
+
+/* We jump here when a system call gets an error.
+ The error number is negated in %eax. */
+.globl syscall_error
+syscall_error:
+ negl %eax /* Make it positive. */
+#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
+ /* We translate the system's EWOULDBLOCK error into EAGAIN.
+ The GNU C library always defines EWOULDBLOCK==EAGAIN.
+ EWOULDBLOCK_sys is the original number. */
+ cmpl %eax, $EWOULDBLOCK_sys /* Is it the old EWOULDBLOCK? */
+ jne 0f /* Branch if not. */
+ move $EAGAIN, %eax /* Yes; translate it to EAGAIN. */
+#endif
+0: movl %eax, _errno /* Store it in `errno'. */
+ move $-1, %eax /* Return -1. */
+ ret
diff --git a/sysdeps/unix/sysv/i386/linux/sysdep.h b/sysdeps/unix/sysv/i386/linux/sysdep.h
new file mode 100644
index 0000000..298a0e4
--- /dev/null
+++ b/sysdeps/unix/sysv/i386/linux/sysdep.h
@@ -0,0 +1,57 @@
+/* Copyright (C) 1992, 1993 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. */
+
+#include <sysdeps/unix/sysdep.h>
+
+#define ENTRY(name) \
+ .globl _##name; \
+ .align 2; \
+ _##name##:
+
+#define PSEUDO(name, syscall_name, args) \
+ .text; \
+ .globl syscall_error; \
+ ENTRY (name) \
+ XCHG_##args
+ movl $SYS_##syscall_name, %eax; \
+ int $0x80; \
+ test %eax, %eax; \
+ jl syscall_error; \
+ XCHG_##args
+
+/* Linux takes system call arguments in registers:
+ 1: %ebx
+ 2: %ecx
+ 3: %edx
+ 4: %esi
+ 5: %edi
+ We put the arguments into registers from the stack,
+ and save the registers, by using the 386 `xchg' instruction
+ to swap the values in both directions. */
+
+#define XCHG_0 /* No arguments to frob. */
+#define XCHG_1 xchg 8(%esp), %ebx; XCHG_0
+#define XCHG_2 xchg 12(%esp), %ecx; XCHG_1
+#define XCHG_3 xchg 16(%esp), %edx; XCHG_2
+#define XCHG_4 xchg 20(%esp), %esi; XCHG_3
+#define XCHG_5 xchg 24(%esp), %edi; XCHG_3
+
+#define r0 %eax /* Normal return-value register. */
+#define r1 %edx /* Secondary return-value register. */
+#define scratch %ecx /* Call-clobbered register for random use. */
+#define MOVE(x,y) movl x, y
diff --git a/sysdeps/unix/sysv/i386/linux/wait.S b/sysdeps/unix/sysv/i386/linux/wait.S
new file mode 100644
index 0000000..4be64c4
--- /dev/null
+++ b/sysdeps/unix/sysv/i386/linux/wait.S
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+ENTRY (__wait)
+ movl 0(%esp), %eax /* Fetch the return address. */
+ movl $-1, 0(%esp) /* First arg is -1. */
+ /* Second arg is our arg at 4(%esp). */
+ pushl $0 /* Third arg is 0. */
+ pushl %eax /* Push the return address. */
+
+ /* Jump to waitpid; it will return to our caller. */
+ jmp ___waitpid
+
+weak_alias (__wait, wait)
diff --git a/sysdeps/unix/sysv/i386/signal.S b/sysdeps/unix/sysv/i386/signal.S
new file mode 100644
index 0000000..14ef77b
--- /dev/null
+++ b/sysdeps/unix/sysv/i386/signal.S
@@ -0,0 +1,31 @@
+/* Copyright (C) 1992 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. */
+
+#include <sysdep.h>
+
+/* This is just a standard system call, except we need to load %edx
+ with the address of the `__sigreturn' function. */
+
+ .globl syscall_error
+ .globl C_SYMBOL_NAME(__sigreturn)
+ENTRY (signal)
+ lea SYS_signal, %eax
+ lea C_SYMBOL_NAME(__sigreturn), %edx
+ .byte 0x9a, 0, 0, 0, 0, 7, 0 /* lcall $7, $0 -- GAS bug. */
+ jb syscall_error
+ ret
diff --git a/sysdeps/unix/sysv/i386/sigreturn.S b/sysdeps/unix/sysv/i386/sigreturn.S
new file mode 100644
index 0000000..be1c6b8
--- /dev/null
+++ b/sysdeps/unix/sysv/i386/sigreturn.S
@@ -0,0 +1,27 @@
+/* Copyright (C) 1994, 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. */
+
+#include <sysdep.h>
+
+.text
+ENTRY (__sigreturn)
+ addl $4, %esp /* Pop the return PC. */
+ lcall $0xf, $0 /* Do the magic sigreturn trap. */
+ /* NOTREACHED */
+
+weak_alias (__sigreturn, sigreturn)
diff --git a/sysdeps/unix/sysv/i386/sysdep.h b/sysdeps/unix/sysv/i386/sysdep.h
new file mode 100644
index 0000000..fedd5ea
--- /dev/null
+++ b/sysdeps/unix/sysv/i386/sysdep.h
@@ -0,0 +1,4 @@
+/* System V does not precede the asm names of C symbols with a `_'. */
+#define NO_UNDERSCORES
+
+#include <sysdeps/unix/i386/sysdep.h>
diff --git a/sysdeps/unix/sysv/i386/time.S b/sysdeps/unix/sysv/i386/time.S
new file mode 100644
index 0000000..f492141
--- /dev/null
+++ b/sysdeps/unix/sysv/i386/time.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (time, 1)
+ movl 4(%esp), %edx /* Put passed pointer in %edx. */
+ testl %edx, %edx /* Is it non-nil? */
+ je null
+ movl %eax, (%edx) /* Yes; store the time there. */
+null: ret
diff --git a/sysdeps/unix/sysv/irix4/Dist b/sysdeps/unix/sysv/irix4/Dist
new file mode 100644
index 0000000..c5dd106
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/Dist
@@ -0,0 +1,2 @@
+syssgi.S sysmp.S
+__handler.S sigtramp.c
diff --git a/sysdeps/unix/sysv/irix4/Implies b/sysdeps/unix/sysv/irix4/Implies
new file mode 100644
index 0000000..35e1edd
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/Implies
@@ -0,0 +1,4 @@
+# Irix 4 has the set of things which are also common to BSD and SVR4.
+unix/common
+# Irix 4 has the canonical set of <sys/mman.h> system calls.
+unix/mman
diff --git a/sysdeps/unix/sysv/irix4/Makefile b/sysdeps/unix/sysv/irix4/Makefile
new file mode 100644
index 0000000..a7f3ea8
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/Makefile
@@ -0,0 +1,25 @@
+# Copyright (C) 1993 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.
+
+ifeq ($(subdir),signal)
+sysdep_routines := $(sysdep_routines) sigtramp __handler
+endif
+
+ifeq ($(subdir),misc)
+sysdep_routines := $(sysdep_routines) syssgi sysmp
+endif
diff --git a/sysdeps/unix/sysv/irix4/__handler.S b/sysdeps/unix/sysv/irix4/__handler.S
new file mode 100644
index 0000000..bd756a4
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/__handler.S
@@ -0,0 +1,116 @@
+/* Copyright (C) 1992 Free Software Foundation, Inc.
+ Contributed by Brendan Kehoe (brendan@cs.widener.edu).
+ Also hacked by Ian Lance Taylor (ian@airs.com).
+
+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. */
+
+#include <sysdep.h>
+
+/* This function saves all the registers, calls the
+ user function, and then executes a sigreturn system call. The
+ sigreturn call wants the address of a sigcontext structure. This
+ is all hideously system dependent and, for all intents and
+ purposes, undocumented.
+
+ When we enter here, a3 holds the user's signal handler. We are
+ supposed to fill in the context given in a2, and then pass it and
+ the first two arguments to the user's function. If the user's
+ function returns, we execute a sigreturn system call.
+
+ The sc_onstack, sc_mask and sc_pc elements of the context are
+ already set by the kernel. For some reason we don't have to save
+ the floating point state or the coprocessor state; the kernel may
+ have saved them for us, or it doesn't use them. */
+
+.set noat
+ENTRY (__handler)
+#if 0
+ /* Store zero and the asm temp reg. */
+ sw $0, 12(a2)
+ sw AT, 16(a2)
+
+ /* Put v1 in sc_regs[3]. */
+ sw v1, 24(a2)
+
+ /* Save the caller saved registers in sc_regs[8..15]. */
+ sw t0, 44(a2)
+ sw t1, 48(a2)
+ sw t2, 52(a2)
+ sw t3, 56(a2)
+ sw t4, 60(a2)
+ sw t5, 64(a2)
+ sw t6, 68(a2)
+ sw t7, 72(a2)
+
+ /* Save the callee saved registers in sc_regs[16..23]. */
+ sw s0, 76(a2)
+ sw s1, 80(a2)
+ sw s2, 84(a2)
+ sw s3, 88(a2)
+ sw s4, 92(a2)
+ sw s5, 96(a2)
+ sw s6, 100(a2)
+ sw s7, 104(a2)
+
+ /* Save the code generator registers in sc_regs[24] & sc_regs[25]. */
+ sw t8, 108(a2)
+ sw t9, 112(a2)
+
+ /* Save the kernel temp regs in sc_regs[26] & sc_regs[27]. */
+ sw k0, 116(a2)
+ sw k1, 120(a2)
+
+ /* Save the global pointer in sc_regs[28]. */
+ sw gp, 124(a2)
+
+ /* ... and also the return address in sc_regs[31]. */
+ sw ra, 136(a2)
+
+ /* Note: we don't save the stack pointer in sc_regs[29];
+ instead, we use the one that was already there. */
+#if 0
+ sw sp, 128(a2)
+#endif
+
+ /* Save the floating pointer in sc_regs[30]. */
+ sw fp, 132(a2)
+
+ /* Save the mul/div stuff in sc_mdlo and sc_mdhi. */
+ mflo t0
+ sw t0, 140(a2)
+ mfhi t0
+ sw t0, 144(a2)
+
+#endif
+ /* Move the stack up six. This will save the context. */
+ addu sp, sp, -24
+ sw a2, 16(sp)
+
+ /* Call their handler with the signal, code, and context; note
+ this will clobber the context. */
+ .set noreorder
+ jal ra, a3
+ nop
+ .set reorder
+
+ /* When we come back, restore the context and pass it right
+ on into sigreturn(). */
+ lw a0, 16(sp)
+
+ /* Do a sigreturn syscall; this doesn't return. */
+ li v0, SYS_sigreturn
+ syscall
+ nop
diff --git a/sysdeps/unix/sysv/irix4/confname.h b/sysdeps/unix/sysv/irix4/confname.h
new file mode 100644
index 0000000..49d2f9c
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/confname.h
@@ -0,0 +1,80 @@
+/* `sysconf', `pathconf', and `confstr' NAME values. Irix 4 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. */
+
+/* Values for the NAME argument to `pathconf' and `fpathconf'. */
+enum
+ {
+ _PC_LINK_MAX = 1,
+ _PC_MAX_CANON,
+ _PC_MAX_INPUT,
+ _PC_NAME_MAX,
+ _PC_PATH_MAX,
+ _PC_PIPE_BUF,
+ _PC_CHOWN_RESTRICTED,
+ _PC_NO_TRUNC,
+ _PC_VDISABLE
+ };
+
+/* Values for the argument to `sysconf'. */
+enum
+ {
+ _SC_ARG_MAX = 1,
+ _SC_CHILD_MAX,
+ _SC_CLK_TCK,
+ _SC_NGROUPS_MAX,
+ _SC_OPEN_MAX,
+ _SC_JOB_CONTROL,
+ _SC_SAVED_IDS,
+ _SC_VERSION,
+
+ /* Above are done by the Irix system call.
+ The rest are done by the C library (or are not really implemented). */
+
+ _SC_STREAM_MAX,
+ _SC_TZNAME_MAX,
+ _SC_PAGESIZE,
+
+ /* Values for the argument to `sysconf'
+ corresponding to _POSIX2_* symbols. */
+ _SC_BC_BASE_MAX,
+ _SC_BC_DIM_MAX,
+ _SC_BC_SCALE_MAX,
+ _SC_BC_STRING_MAX,
+ _SC_COLL_WEIGHTS_MAX,
+ _SC_EQUIV_CLASS_MAX,
+ _SC_EXPR_NEST_MAX,
+ _SC_LINE_MAX,
+ _SC_RE_DUP_MAX,
+
+ _SC_2_VERSION,
+ _SC_2_C_BIND,
+ _SC_2_C_DEV,
+ _SC_2_FORT_DEV,
+ _SC_2_FORT_RUN,
+ _SC_2_SW_DEV,
+ _SC_2_LOCALEDEF
+ };
+
+#ifdef __USE_POSIX2
+/* Values for the NAME argument to `confstr'. */
+enum
+ {
+ _CS_PATH /* The default search path. */
+ };
+#endif
diff --git a/sysdeps/unix/sysv/irix4/direct.h b/sysdeps/unix/sysv/irix4/direct.h
new file mode 100644
index 0000000..153087f
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/direct.h
@@ -0,0 +1,15 @@
+#ifndef MAXNAMLEN
+#define MAXNAMLEN 255
+#endif
+
+struct direct
+ {
+ unsigned long int d_ino;
+ off_t d_off;
+ unsigned short int d_reclen;
+ char d_name[MAXNAMLEN + 1];
+ };
+
+#define D_NAMLEN(d) (strlen ((d)->d_name))
+
+#define D_RECLEN(d) (d->d_reclen)
diff --git a/sysdeps/unix/sysv/irix4/dup2.c b/sysdeps/unix/sysv/irix4/dup2.c
new file mode 100644
index 0000000..86720b1
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/dup2.c
@@ -0,0 +1,3 @@
+#include <sysdeps/posix/__dup2.c>
+
+weak_alias (__dup2, dup2)
diff --git a/sysdeps/unix/sysv/irix4/fcntlbits.h b/sysdeps/unix/sysv/irix4/fcntlbits.h
new file mode 100644
index 0000000..a8bb776
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/fcntlbits.h
@@ -0,0 +1,98 @@
+/* O_*, F_*, FD_* bit values for SGI Irix 4.
+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. */
+
+#ifndef _FCNTLBITS_H
+
+#define _FCNTLBITS_H 1
+
+
+/* File access modes for `open' and `fcntl'. */
+#define O_RDONLY 0 /* Open read-only. */
+#define O_WRONLY 1 /* Open write-only. */
+#define O_RDWR 2 /* Open read/write. */
+
+
+/* Bits OR'd into the second argument to open. */
+#define O_CREAT 00400 /* Create file if it doesn't exist. */
+#define O_EXCL 02000 /* Fail if file already exists. */
+#define O_TRUNC 01000 /* Truncate file to zero length. */
+#ifdef __USE_MISC
+#define O_SYNC 00020 /* Synchronous writes. */
+#define O_ASYNC 00100 /* Send SIGIO to owner when data is ready. */
+#endif
+
+/* File status flags for `open' and `fcntl'. */
+#define O_APPEND 000010 /* Writes append to the file. */
+#ifdef __USE_BSD
+#define O_NDELAY 000004 /* Non-blocking I/O. */
+#endif
+#define O_NONBLOCK 000200 /* POSIX.1 non-blocking I/O. */
+
+/* Mask for file access modes. This is system-dependent in case
+ some system ever wants to define some other flavor of access. */
+#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
+
+/* Values for the second argument to `fcntl'. */
+#define F_DUPFD 0 /* Duplicate file descriptor. */
+#define F_GETFD 1 /* Get file descriptor flags. */
+#define F_SETFD 2 /* Set file descriptor flags. */
+#define F_GETFL 3 /* Get file status flags. */
+#define F_SETFL 4 /* Set file status flags. */
+#define F_GETLK 5 /* Get record locking info. */
+#define F_SETLK 6 /* Set record locking info. */
+#define F_SETLKW 7 /* Set record locking info, wait. */
+#ifdef __USE_MISC
+#define F_CHKFL 8 /* Check legality of file flag changes. */
+#define F_ALLOCSP 10
+#define F_FREESP 11
+#define F_SETBSDLK 12 /* Set Berkeley record lock. */
+#define F_SETBSDLKW 13 /* Set Berkeley record lock and wait. */
+#define F_RGETLK 20 /* Get info on a remote lock. */
+#define F_RSETLK 21 /* Set or unlock a remote lock. */
+#define F_RSETLKW 22 /* Set or unlock a remote lock and wait. */
+#define F_GETOWN 10 /* Get owner; only works on sockets. */
+#define F_SETOWN 11 /* Set owner; only works on sockets. */
+#endif
+
+
+/* File descriptor flags used with F_GETFD and F_SETFD. */
+#define FD_CLOEXEC 1 /* Close on exec. */
+
+
+#include <gnu/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. */
+struct flock
+ {
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+ short int l_sysid; /* System ID where locking process resides. */
+ short int l_pid; /* Process holding the lock. */
+ };
+
+/* Values for the `l_type' field of a `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/sysv/irix4/fpathconf.c b/sysdeps/unix/sysv/irix4/fpathconf.c
new file mode 100644
index 0000000..3c9f175
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/fpathconf.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <sys/syssgi.h>
+
+extern int __syssgi __P ((int, ...));
+
+/* Get file-specific information about descriptor FD. */
+long int
+DEFUN(__fpathconf, (fd, name), int fd AND int name)
+{
+ return __syssgi (SGI_PATHCONF, FPATHCONF, fd, name);
+}
+
+weak_alias (__fpathconf, fpathconf)
diff --git a/sysdeps/unix/sysv/irix4/getgroups.c b/sysdeps/unix/sysv/irix4/getgroups.c
new file mode 100644
index 0000000..714f660
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/getgroups.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1994, 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. */
+
+#include <sys/syssgi.h>
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <grp.h>
+
+extern int __syssgi __P ((int, ...));
+
+/* Set the group set for the current user to GROUPS (N of them). */
+int
+DEFUN(__getgroups, (n, groups), size_t n AND gid_t *groups)
+{
+ return __syssgi (SGI_GETGROUPS, n, groups);
+}
+
+weak_alias (__getgroups, getgroups)
diff --git a/sysdeps/unix/sysv/irix4/getpgid.S b/sysdeps/unix/sysv/irix4/getpgid.S
new file mode 100644
index 0000000..fbef7a2
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/getpgid.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1994, 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. */
+
+#include <sysdep.h>
+
+PSEUDO (__getpgid, bsdgetpgrp, 1)
+ ret
+
+weak_alias (__getpgid, getpgid)
diff --git a/sysdeps/unix/sysv/irix4/getpriority.c b/sysdeps/unix/sysv/irix4/getpriority.c
new file mode 100644
index 0000000..70a9431
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/getpriority.c
@@ -0,0 +1,46 @@
+/* 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/resource.h>
+#include <sys/sysmp.h>
+
+extern int __sysmp __P ((int, ...));
+
+/* Return the highest priority of any process specified by WHICH and WHO
+ (see <sys/resource.h>); if WHO is zero, the current process, process group,
+ or user (as specified by WHO) is used. A lower priority number means higher
+ priority. Priorities range from PRIO_MIN to PRIO_MAX. */
+int
+DEFUN(getpriority, (which, who),
+ enum __priority_which which AND int who)
+{
+ switch (which)
+ {
+ case PRIO_PROCESS:
+ return __sysmp (MP_SCHED, MPTS_GTNICE_PROC, who);
+ case PRIO_PGRP:
+ return __sysmp (MP_SCHED, MPTS_GTNICE_PGRP, who);
+ case PRIO_USER:
+ return __sysmp (MP_SCHED, MPTS_GTNICE_USER, who);
+ }
+
+ errno = EINVAL;
+ return -1;
+}
diff --git a/sysdeps/unix/sysv/irix4/getrusage.c b/sysdeps/unix/sysv/irix4/getrusage.c
new file mode 100644
index 0000000..fdd3a24
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/getrusage.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1994, 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. */
+
+#include <ansidecl.h>
+#include <sys/resource.h>
+#include <errno.h>
+#include <sys/syssgi.h>
+
+extern int __syssgi __P ((int, ...));
+
+/* Return resource usage information on process indicated by WHO
+ and put it in *USAGE. Returns 0 for success, -1 for failure. */
+int
+DEFUN(__getrusage, (who, usage),
+ enum __rusage_who who AND struct rusage *usage)
+{
+ return __syssgi (SGI_RUSAGE, who, usage);
+}
+
+weak_alias (__getrusage, getrusage)
diff --git a/sysdeps/unix/sysv/irix4/gettimeofday.c b/sysdeps/unix/sysv/irix4/gettimeofday.c
new file mode 100644
index 0000000..d7055be
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/gettimeofday.c
@@ -0,0 +1 @@
+#include <sysdeps/posix/gettimeofday.c>
diff --git a/sysdeps/unix/sysv/irix4/msync.S b/sysdeps/unix/sysv/irix4/msync.S
new file mode 100644
index 0000000..75b9f15
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/msync.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/sun/sunos4/msync.S>
diff --git a/sysdeps/unix/sysv/irix4/pathconf.c b/sysdeps/unix/sysv/irix4/pathconf.c
new file mode 100644
index 0000000..698e30a
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/pathconf.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <sys/syssgi.h>
+
+extern int __syssgi __P ((int, ...));
+
+/* Get file-specific information about PATH. */
+long int
+DEFUN(__pathconf, (path, name), CONST char *path AND int name)
+{
+ return __syssgi (SGI_PATHCONF, PATHCONF, path, name);
+}
+
+weak_alias (__pathconf, pathconf)
diff --git a/sysdeps/unix/sysv/irix4/readv.c b/sysdeps/unix/sysv/irix4/readv.c
new file mode 100644
index 0000000..baa976d
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/readv.c
@@ -0,0 +1 @@
+#include <sysdeps/posix/readv.c>
diff --git a/sysdeps/unix/sysv/irix4/reboot.c b/sysdeps/unix/sysv/irix4/reboot.c
new file mode 100644
index 0000000..d7a3659
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/reboot.c
@@ -0,0 +1 @@
+#include <sysdeps/stub/reboot.c>
diff --git a/sysdeps/unix/sysv/irix4/setgroups.c b/sysdeps/unix/sysv/irix4/setgroups.c
new file mode 100644
index 0000000..052df0f
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/setgroups.c
@@ -0,0 +1,31 @@
+/* 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. */
+
+#include <sys/syssgi.h>
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <grp.h>
+
+extern int __syssgi __P ((int, ...));
+
+/* Set the group set for the current user to GROUPS (N of them). */
+int
+DEFUN(setgroups, (n, groups), size_t n AND CONST gid_t *groups)
+{
+ return __syssgi (SGI_SETGROUPS, n, groups);
+}
diff --git a/sysdeps/unix/sysv/irix4/setpgid.S b/sysdeps/unix/sysv/irix4/setpgid.S
new file mode 100644
index 0000000..9267054
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/setpgid.S
@@ -0,0 +1,25 @@
+/* Copyright (C) 1994, 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. */
+
+#include <sysdep.h>
+
+PSEUDO (__setpgid, bsdsetpgrp, 2)
+ ret
+
+weak_alias (__setpgid, setpgid)
+weak_alias (__setpgid, setpgrp)
diff --git a/sysdeps/unix/sysv/irix4/setpriority.c b/sysdeps/unix/sysv/irix4/setpriority.c
new file mode 100644
index 0000000..a632953
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/setpriority.c
@@ -0,0 +1,41 @@
+/* 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/resource.h>
+#include <sys/sysmp.h>
+
+int
+DEFUN(setpriority, (which, who, prio),
+ enum __priority_which which AND int who AND int prio)
+{
+ switch (which)
+ {
+ case PRIO_PROCESS:
+ return __sysmp (MP_SCHED, MPTS_RENICE_PROC, who, prio);
+ case PRIO_PGRP:
+ return __sysmp (MP_SCHED, MPTS_RENICE_PGRP, who, prio);
+ case PRIO_USER:
+ return __sysmp (MP_SCHED, MPTS_RENICE_USER, who, prio);
+ }
+
+ errno = EINVAL;
+ return -1;
+}
+
diff --git a/sysdeps/unix/sysv/irix4/signal.S b/sysdeps/unix/sysv/irix4/signal.S
new file mode 100644
index 0000000..b0c147d
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/signal.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+PSEUDO (__raw_signal, signal, 3)
+ ret
diff --git a/sysdeps/unix/sysv/irix4/signum.h b/sysdeps/unix/sysv/irix4/signum.h
new file mode 100644
index 0000000..5d30ebb
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/signum.h
@@ -0,0 +1,67 @@
+/* Copyright (C) 1994 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
+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. */
+
+#ifdef _SIGNAL_H
+
+/* This file defines the fake signal functions and signal
+ number constants for SGI Irix 4. */
+
+/* Fake signal functions. */
+#define SIG_ERR ((__sighandler_t) -1)
+#define SIG_DFL ((__sighandler_t) 0)
+#define SIG_IGN ((__sighandler_t) 1)
+
+
+/* Signals. */
+#define SIGHUP 1 /* Hangup (POSIX). */
+#define SIGINT 2 /* Interrupt (ANSI). */
+#define SIGQUIT 3 /* Quit (POSIX). */
+#define SIGILL 4 /* Illegal instruction (ANSI). */
+#define SIGABRT SIGIOT /* Abort (ANSI). */
+#define SIGTRAP 5 /* Trace trap (POSIX). */
+#define SIGIOT 6 /* IOT trap. */
+#define SIGEMT 7 /* EMT trap. */
+#define SIGFPE 8 /* Floating-point exception (ANSI). */
+#define SIGKILL 9 /* Kill, unblockable (POSIX). */
+#define SIGBUS 10 /* Bus error. */
+#define SIGSEGV 11 /* Segmentation violation (ANSI). */
+#define SIGSYS 12 /* Bad argument to system call*/
+#define SIGPIPE 13 /* Broken pipe (POSIX). */
+#define SIGALRM 14 /* Alarm clock (POSIX). */
+#define SIGTERM 15 /* Termination (ANSI). */
+#define SIGUSR1 16 /* User-defined signal 1 (POSIX). */
+#define SIGUSR2 17 /* User-defined signal 2 (POSIX). */
+#define SIGCHLD 18 /* Child status has changed (POSIX). */
+#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */
+#define SIGPWR 19 /* Power going down. */
+#define SIGSTOP 20 /* Stop, unblockable (POSIX). */
+#define SIGTSTP 21 /* Keyboard stop (POSIX). */
+#define SIGPOLL 22 /* Same as SIGIO? (SVID). */
+#define SIGIO 23 /* I/O now possible. */
+#define SIGURG 24 /* Urgent condition on socket.*/
+#define SIGWINCH 25 /* Window size change. */
+#define SIGVTALRM 26 /* Virtual alarm clock. */
+#define SIGPROF 27 /* Profiling alarm clock. */
+#define SIGCONT 28 /* Continue (POSIX). */
+#define SIGTTIN 29 /* Background read from tty (POSIX). */
+#define SIGTTOU 30 /* Background write to tty (POSIX). */
+#define SIGXCPU 31 /* CPU limit exceeded. */
+#define SIGXFSZ 32 /* File size limit exceeded. */
+
+#endif /* <signal.h> included. */
+
+#define _NSIG 33 /* Biggest signal number + 1. */
diff --git a/sysdeps/unix/sysv/irix4/sigreturn.S b/sysdeps/unix/sysv/irix4/sigreturn.S
new file mode 100644
index 0000000..ebb5c1a
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/sigreturn.S
@@ -0,0 +1,25 @@
+/* Copyright (C) 1992, 1995 Free Software Foundation, Inc.
+ Contributed by Brendan Kehoe (brendan@cs.widener.edu).
+
+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. */
+
+#include <sysdep.h>
+
+ENTRY(__sigreturn)
+ li v0, SYS_sigreturn
+ syscall
+
+weak_alias (__sigreturn, sigreturn)
diff --git a/sysdeps/unix/sysv/irix4/sigtramp.c b/sysdeps/unix/sysv/irix4/sigtramp.c
new file mode 100644
index 0000000..85c2c3a
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/sigtramp.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 1992 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. */
+
+/* The sigvec system call on MIPS Ultrix takes an additional
+ parameter, which is the address that is actually called when the
+ signal occurs.
+
+ When a signal occurs, we arrange for the kernel to call __handler.
+ That will save the frame and stack pointers into the context, and
+ then jump to this routine. See __handler.S.
+
+ This code is based on sysdeps/unix/bsd/sun4/sigtramp.c, but it's
+ different because since we get passed the user signal handler we
+ don't actually need a trampoline. */
+
+#include <ansidecl.h>
+#include <signal.h>
+#include <stddef.h>
+#include <errno.h>
+
+/* The user's signal handler is called with three arguments. */
+typedef void (*handler_type) (int sig, int code, struct sigcontext *);
+
+/* Defined in signal.S. */
+extern __sighandler_t EXFUN(__raw_signal, (int sig, __sighandler_t func,
+ void (*)(int sig, int code,
+ struct sigcontext *,
+ handler_type)));
+
+extern void EXFUN(__handler, (int sig, int code,
+ struct sigcontext *,
+ handler_type));
+
+__sighandler_t
+DEFUN(signal, (sig, func),
+ int sig AND __sighandler_t func)
+{
+ return __raw_signal (sig, func, __handler);
+}
diff --git a/sysdeps/unix/sysv/irix4/start.c b/sysdeps/unix/sysv/irix4/start.c
new file mode 100644
index 0000000..4382e6f
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/start.c
@@ -0,0 +1,68 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#ifndef __GNUC__
+ #error This file uses GNU C extensions; you must compile with GCC.
+#endif
+
+/* The first piece of initialized data. */
+int __data_start = 0;
+
+VOLATILE int errno = 0;
+
+#ifndef HAVE_GNU_LD
+#undef environ
+#define __environ environ
+#endif
+
+char **__environ;
+
+extern void EXFUN(__libc_init, (int argc, char **argv, char **envp));
+extern int EXFUN(main, (int argc, char **argv, char **envp));
+
+/* Use the stack pointer to access the arguments. This assumes that
+ we can guess how big the frame will be. */
+register long int sp asm("sp");
+#ifdef __OPTIMIZE__
+#define STACKSIZE 8
+#else
+#define STACKSIZE 10
+#endif
+
+void
+DEFUN_VOID(__start)
+{
+ int argc;
+ char **argv, **envp;
+
+ /* Set up the global pointer. */
+ asm volatile ("la $28,_gp");
+ argc = ((int *) sp)[STACKSIZE];
+ argv = (char **) &((int *) sp)[STACKSIZE + 1];
+ envp = &argv[argc + 1];
+ __environ = envp;
+
+ __libc_init (argc, argv, envp);
+ errno = 0;
+ exit (main (argc, argv, envp));
+}
diff --git a/sysdeps/unix/sysv/irix4/statbuf.h b/sysdeps/unix/sysv/irix4/statbuf.h
new file mode 100644
index 0000000..8b327ba
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/statbuf.h
@@ -0,0 +1,61 @@
+/* Copyright (C) 1992 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 _STATBUF_H
+#define _STATBUF_H
+
+struct stat
+ {
+ unsigned long st_ino;
+ short int st_dev;
+ unsigned short int st_mode;
+ short int st_nlink;
+ unsigned short int st_uid;
+ unsigned short int st_gid;
+ short int st_rdev;
+ long int st_size;
+ long int st_atime;
+ long int st_mtime;
+ long int st_ctime;
+ };
+
+/* Encoding of the file mode. */
+
+#define __S_IFMT 0170000 /* These bits determine file type. */
+
+/* File types. */
+#define __S_IFDIR 0040000 /* Directory. */
+#define __S_IFCHR 0020000 /* Character device. */
+#define __S_IFBLK 0060000 /* Block device. */
+#define __S_IFREG 0100000 /* Regular file. */
+#define __S_IFIFO 0010000 /* FIFO. */
+
+/* These don't actually exist on System V, but having them doesn't hurt. */
+#define __S_IFLNK 0120000 /* Symbolic link. */
+#define __S_IFSOCK 0140000 /* Socket. */
+
+/* Protection bits. */
+
+#define __S_ISUID 04000 /* Set user ID on execution. */
+#define __S_ISGID 02000 /* Set group ID on execution. */
+#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
+#define __S_IREAD 0400 /* Read by owner. */
+#define __S_IWRITE 0200 /* Write by owner. */
+#define __S_IEXEC 0100 /* Execute by owner. */
+
+#endif /* statbuf.h */
diff --git a/sysdeps/unix/sysv/irix4/swapon.c b/sysdeps/unix/sysv/irix4/swapon.c
new file mode 100644
index 0000000..86a638f
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/swapon.c
@@ -0,0 +1 @@
+#include <sysdeps/stub/swapon.c>
diff --git a/sysdeps/unix/sysv/irix4/sys/mman.h b/sysdeps/unix/sysv/irix4/sys/mman.h
new file mode 100644
index 0000000..ac50aab
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/sys/mman.h
@@ -0,0 +1,101 @@
+/* Definitions for BSD-style memory management. Irix 4 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. */
+
+#ifndef _SYS_MMAN_H
+
+#define _SYS_MMAN_H 1
+#include <features.h>
+
+#include <gnu/types.h>
+#define __need_size_t
+#include <stddef.h>
+
+
+/* Protections are chosen from these bits, OR'd together. The
+ implementation does not necessarily support PROT_EXEC or PROT_WRITE
+ without PROT_READ. The only guarantees are that no writing will be
+ allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
+
+#define PROT_NONE 0x00 /* No access. */
+#define PROT_READ 0x04 /* Pages can be read. */
+#define PROT_WRITE 0x02 /* Pages can be written. */
+#define PROT_EXEC 0x01 /* Pages can be executed. */
+#define PROT_EXECUTE PROT_EXEC
+
+
+/* Sharing types (must choose one and only one of these). */
+#define MAP_SHARED 0x01 /* Share changes. */
+#define MAP_PRIVATE 0x02 /* Changes private; copy pages on write. */
+#define MAP_TYPE 0x0f /* Mask for sharing type. */
+
+/* Other flags. */
+#define MAP_FIXED 0x10 /* Map address must be exactly as requested. */
+#define MAP_RENAME 0x20 /* Rename private pages to file. */
+#define MAP_AUTOGROW 0x40 /* Grow file as pages are written. */
+#define MAP_LOCAL 0x80 /* Copy the mapped region on fork. */
+
+/* Advice to `madvise'. */
+#define MADV_NORMAL 0 /* No further special treatment. */
+#define MADV_RANDOM 1 /* Expect random page references. */
+#define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
+#define MADV_WILLNEED 3 /* Will need these pages. */
+#define MADV_DONTNEED 4 /* Don't need these pages. */
+
+/* Flags to `msync'. */
+#define MS_ASYNC 0x1 /* Return immediately, don't fsync. */
+#define MS_INVALIDATE 0x2 /* Invalidate caches. */
+
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+/* Map addresses starting near ADDR and extending for LEN bytes. from
+ OFFSET into the file FD describes according to PROT and FLAGS. If ADDR
+ is nonzero, it is the desired mapping address. If the MAP_FIXED bit is
+ set in FLAGS, the mapping will be at ADDR exactly (which must be
+ page-aligned); otherwise the system chooses a convenient nearby address.
+ The return value is the actual mapping address chosen or (caddr_t) -1
+ for errors (in which case `errno' is set). A successful `mmap' call
+ deallocates any previous mapping for the affected region. */
+
+__caddr_t mmap __P ((__caddr_t __addr, size_t __len,
+ int __prot, int __flags, int __fd, __off_t __offset));
+
+/* Deallocate any mapping for the region starting at ADDR and extending LEN
+ bytes. Returns 0 if successful, -1 for errors (and sets errno). */
+int munmap __P ((__caddr_t __addr, size_t __len));
+
+/* Change the memory protection of the region starting at ADDR and
+ extending LEN bytes to PROT. Returns 0 if successful, -1 for errors
+ (and sets errno). */
+int mprotect __P ((__caddr_t __addr, size_t __len, int __prot));
+
+/* Synchronize the region starting at ADDR and extending LEN bytes with the
+ file it maps. Filesystem operations on a file being mapped are
+ unpredictable before this is done. */
+int msync __P ((caddr_t __addr, size_t __len, int __flags));
+
+/* Advise the system about particular usage patterns the program follows
+ for the region starting at ADDR and extending LEN bytes. */
+int madvise __P ((__caddr_t __addr, size_t __len, int __advice));
+
+__END_DECLS
+
+
+#endif /* sys/mman.h */
diff --git a/sysdeps/unix/sysv/irix4/sysconf.c b/sysdeps/unix/sysv/irix4/sysconf.c
new file mode 100644
index 0000000..a310362
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/sysconf.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1994, 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. */
+
+#include <ansidecl.h>
+#include <unistd.h>
+#include <sys/syssgi.h>
+
+extern int __syssgi __P ((int, ...));
+
+/* Get the value of the system variable NAME. */
+long int
+DEFUN(__sysconf, (name), int name)
+{
+ if (name == _SC_TZNAME_MAX)
+ return __tzname_max ();
+
+ return __syssgi (SGI_SYSCONF, name);
+}
+
+weak_alias (__sysconf, sysconf)
diff --git a/sysdeps/unix/sysv/irix4/sysmp.S b/sysdeps/unix/sysv/irix4/sysmp.S
new file mode 100644
index 0000000..438da60
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/sysmp.S
@@ -0,0 +1,22 @@
+/* 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (sysmp, 4)
+ ret
diff --git a/sysdeps/unix/sysv/irix4/syssgi.S b/sysdeps/unix/sysv/irix4/syssgi.S
new file mode 100644
index 0000000..2715d28
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/syssgi.S
@@ -0,0 +1,22 @@
+/* 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (syssgi, 2)
+ ret
diff --git a/sysdeps/unix/sysv/irix4/time.S b/sysdeps/unix/sysv/irix4/time.S
new file mode 100644
index 0000000..23bfe5d
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/time.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/sysv4/time.S>
diff --git a/sysdeps/unix/sysv/irix4/uname.S b/sysdeps/unix/sysv/irix4/uname.S
new file mode 100644
index 0000000..fe91240
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/uname.S
@@ -0,0 +1,26 @@
+/* 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. */
+
+#include <sysdep.h>
+
+ENTRY(uname)
+ li a2, 0
+ li a3, 0
+SYSCALL__ (utssys, 1)
+ j ra
+ move v0, zero
diff --git a/sysdeps/unix/sysv/irix4/wait.S b/sysdeps/unix/sysv/irix4/wait.S
new file mode 100644
index 0000000..9f2afa7
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/wait.S
@@ -0,0 +1,42 @@
+/* Copyright (C) 1992, 1995 Free Software Foundation, Inc.
+ Contributed by Brendan Kehoe (brendan@cs.widener.edu).
+
+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. */
+
+#include <sysdep.h>
+
+.set noreorder
+
+ENTRY(__wait)
+ /* Prep it for wait */
+ move a1, zero
+ move a2, zero
+
+ li v0, SYS_wait
+ syscall
+ beq a3, zero, noerror
+ nop
+ j syscall_error
+ nop
+noerror:
+ beq a0, zero, noarg
+ nop
+ sw v1, 0(a0)
+ nop
+noarg:
+ ret
+
+weak_alias (__wait, wait)
diff --git a/sysdeps/unix/sysv/irix4/wait3.S b/sysdeps/unix/sysv/irix4/wait3.S
new file mode 100644
index 0000000..54065ae
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/wait3.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/ultrix4/wait3.S>
diff --git a/sysdeps/unix/sysv/irix4/waitpid.c b/sysdeps/unix/sysv/irix4/waitpid.c
new file mode 100644
index 0000000..8378982
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/waitpid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/waitpid.c>
diff --git a/sysdeps/unix/sysv/irix4/writev.c b/sysdeps/unix/sysv/irix4/writev.c
new file mode 100644
index 0000000..0dc6a76
--- /dev/null
+++ b/sysdeps/unix/sysv/irix4/writev.c
@@ -0,0 +1 @@
+#include <sysdeps/posix/writev.c>
diff --git a/sysdeps/unix/sysv/isc2.2/rename.S b/sysdeps/unix/sysv/isc2.2/rename.S
new file mode 100644
index 0000000..a4b2c42
--- /dev/null
+++ b/sysdeps/unix/sysv/isc2.2/rename.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/common/rename.S>
diff --git a/sysdeps/unix/sysv/isc3/direct.h b/sysdeps/unix/sysv/isc3/direct.h
new file mode 100644
index 0000000..e6df212
--- /dev/null
+++ b/sysdeps/unix/sysv/isc3/direct.h
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/sco3.2.4/direct.h>
diff --git a/sysdeps/unix/sysv/linux/Implies b/sysdeps/unix/sysv/linux/Implies
new file mode 100644
index 0000000..fe7e1fd
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/Implies
@@ -0,0 +1,2 @@
+# Linux has the set of things which are also common to BSD and SVR4.
+unix/common
diff --git a/sysdeps/unix/sysv/linux/accept.S b/sysdeps/unix/sysv/linux/accept.S
new file mode 100644
index 0000000..5936a01
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/accept.S
@@ -0,0 +1,2 @@
+#define socket accept
+#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/bind.S b/sysdeps/unix/sysv/linux/bind.S
new file mode 100644
index 0000000..fc82b65
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/bind.S
@@ -0,0 +1,2 @@
+#define socket bind
+#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/connect.S b/sysdeps/unix/sysv/linux/connect.S
new file mode 100644
index 0000000..3433043
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/connect.S
@@ -0,0 +1,2 @@
+#define socket connect
+#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/getpeername.S b/sysdeps/unix/sysv/linux/getpeername.S
new file mode 100644
index 0000000..8429fcd
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/getpeername.S
@@ -0,0 +1,2 @@
+#define socket getpeername
+#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/getpgrp.S b/sysdeps/unix/sysv/linux/getpgrp.S
new file mode 100644
index 0000000..f8d6e07
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/getpgrp.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (getpgrp, 0)
+ ret
diff --git a/sysdeps/unix/sysv/linux/getsockname.S b/sysdeps/unix/sysv/linux/getsockname.S
new file mode 100644
index 0000000..6782707
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/getsockname.S
@@ -0,0 +1,2 @@
+#define socket getsockname
+#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/listen.S b/sysdeps/unix/sysv/linux/listen.S
new file mode 100644
index 0000000..d2cbec6
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/listen.S
@@ -0,0 +1,2 @@
+#define socket listen
+#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/rename.S b/sysdeps/unix/sysv/linux/rename.S
new file mode 100644
index 0000000..a5a8dfe
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/rename.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/rename.S>
diff --git a/sysdeps/unix/sysv/linux/setsid.S b/sysdeps/unix/sysv/linux/setsid.S
new file mode 100644
index 0000000..4930c56
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/setsid.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/setsid.S>
diff --git a/sysdeps/unix/sysv/linux/socketpair.S b/sysdeps/unix/sysv/linux/socketpair.S
new file mode 100644
index 0000000..da71c57
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/socketpair.S
@@ -0,0 +1,2 @@
+#define socket socketpair
+#include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/syscall.h b/sysdeps/unix/sysv/linux/syscall.h
new file mode 100644
index 0000000..b94d919
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/syscall.h
@@ -0,0 +1,124 @@
+#ifndef _SYSCALL_H
+#define _SYSCALL_H
+
+#define SYS_setup 0 /* Used only by init, to get system going. */
+#define SYS_exit 1
+#define SYS_fork 2
+#define SYS_read 3
+#define SYS_write 4
+#define SYS_open 5
+#define SYS_close 6
+#define SYS_waitpid 7
+#define SYS_creat 8
+#define SYS_link 9
+#define SYS_unlink 10
+#define SYS_execve 11
+#define SYS_chdir 12
+#define SYS_time 13
+#define SYS_mknod 14
+#define SYS_chmod 15
+#define SYS_chown 16
+#define SYS_brk 17
+#define SYS_oldstat 18
+#define SYS_lseek 19
+#define SYS_getpid 20
+#define SYS_mount 21
+#define SYS_umount 22
+#define SYS_setuid 23
+#define SYS_getuid 24
+#define SYS_stime 25
+#define SYS_ptrace 26
+#define SYS_alarm 27
+#define SYS_oldfstat 28
+#define SYS_pause 29
+#define SYS_utime 30
+#define SYS_stty 31
+#define SYS_gtty 32
+#define SYS_access 33
+#define SYS_nice 34
+#define SYS_ftime 35
+#define SYS_sync 36
+#define SYS_kill 37
+#define SYS_rename 38
+#define SYS_mkdir 39
+#define SYS_rmdir 40
+#define SYS_dup 41
+#define SYS_pipe 42
+#define SYS_times 43
+#define SYS_prof 44
+#if 0
+#define SYS_brk 45 /* Where did this bogosity crom from? */
+#endif
+#define SYS_setgid 46
+#define SYS_getgid 47
+#define SYS_signal 48
+#define SYS_geteuid 49
+#define SYS_getegid 50
+#define SYS_acct 51
+#define SYS_phys 52
+#define SYS_lock 53
+#define SYS_ioctl 54
+#define SYS_fcntl 55
+#define SYS_mpx 56
+#define SYS_setpgrp 57
+#define SYS_ulimit 58
+#define SYS_olduname 59
+#define SYS_umask 60
+#define SYS_chroot 61
+#define SYS_ustat 62
+#define SYS_dup2 63
+#define SYS_getppid 64
+#define SYS_getpgrp 65
+#define SYS_setsid 66
+#define SYS_sigaction 67
+#define SYS_siggetmask 68
+#define SYS_sigsetmask 69
+#define SYS_setreuid 70
+#define SYS_setregid 71
+#define SYS_sigsuspend 72
+#define SYS_sigpending 73
+#define SYS_sethostname 74
+#define SYS_setrlimit 75
+#define SYS_getrlimit 76
+#define SYS_getrusage 77
+#define SYS_gettimeofday 78
+#define SYS_settimeofday 79
+#define SYS_getgroups 80
+#define SYS_setgroups 81
+#define SYS_select 82
+#define SYS_symlink 83
+#define SYS_oldlstat 84
+#define SYS_readlink 85
+#define SYS_uselib 86
+#define SYS_swapon 87
+#define SYS_reboot 88
+#define SYS_readdir 89
+#define SYS_mmap 90
+#define SYS_munmap 91
+#define SYS_truncate 92
+#define SYS_ftruncate 93
+#define SYS_fchmod 94
+#define SYS_fchown 95
+#define SYS_getpriority 96
+#define SYS_setpriority 97
+#define SYS_profil 98
+#define SYS_statfs 99
+#define SYS_fstatfs 100
+#define SYS_ioperm 101
+#define SYS_socketcall 102
+#define SYS_syslog 103
+#define SYS_setitimer 104
+#define SYS_getitimer 105
+#define SYS_stat 106
+#define SYS_lstat 107
+#define SYS_fstat 108
+#define SYS_uname 109
+#define SYS_iopl 110
+#define SYS_vhangup 111
+#define SYS_idle 112
+#define SYS_vm86 113
+#define SYS_wait4 114
+#define SYS_swapoff 115
+
+
+#endif /* syscall.h */
diff --git a/sysdeps/unix/sysv/linux/wait4.S b/sysdeps/unix/sysv/linux/wait4.S
new file mode 100644
index 0000000..e4c3223
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/wait4.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/wait4.S>
diff --git a/sysdeps/unix/sysv/linux/waitpid.S b/sysdeps/unix/sysv/linux/waitpid.S
new file mode 100644
index 0000000..20d9d66
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/waitpid.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (waitpid, 3)
+ ret
+
+weak_alias (__waitpid, waitpid)
diff --git a/sysdeps/unix/sysv/local_lim.h b/sysdeps/unix/sysv/local_lim.h
new file mode 100644
index 0000000..c2b0468
--- /dev/null
+++ b/sysdeps/unix/sysv/local_lim.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 1992 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. */
+
+#define NGROUPS_MAX 0 /* No supplementary groups. */
+#define ARG_MAX 5120
+#define CHILD_MAX 25
+#define OPEN_MAX 60
+#define LINK_MAX 1000
+#define MAX_CANON 256
+
+/* For SVR3, this is 14. For SVR4, it is 255, at least on ufs
+ file systems, even though the System V limits.h incorrectly
+ defines it as 14. Giving it a value which is too large
+ is harmless (it is a maximum). */
+#define NAME_MAX 255
+
+#define PATH_MAX 1024
diff --git a/sysdeps/unix/sysv/minix/sigaction.h b/sysdeps/unix/sysv/minix/sigaction.h
new file mode 100644
index 0000000..9395206
--- /dev/null
+++ b/sysdeps/unix/sysv/minix/sigaction.h
@@ -0,0 +1,49 @@
+/* Copyright (C) 1992 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, 1992 Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+/* Structure describing the action to be taken when a signal arrives. */
+struct sigaction
+ {
+ /* Signal handler. */
+ __sighandler_t sa_handler;
+
+ /* Additional set of signals to be blocked. */
+ __sigset_t sa_mask;
+
+ /* Special flags. */
+ int sa_flags;
+ };
+
+/* Bits in `sa_flags'. */
+#ifdef __USE_MISC
+#define SA_ONSTACK 0x1 /* Take signal on signal stack. */
+#define SA_RESETHAND 0x2 /* Reset signal handler when signal caught. */
+#define SA_NODEFER 0x4 /* Don't block signal while catching it. */
+#define SA_RESTART 0x8 /* Don't restart syscall on signal return. */
+#define SA_SIGINFO 0x10 /* Extended signal handling. */
+#define SA_NOCLDWAIT 0x20 /* Don't create zombies. */
+#define SA_COMPAT 0x80 /* Internal flag for old signal catchers. */
+#define SA_DISABLE 0x100 /* Disable alternate signal stack. */
+#endif
+#define SA_NOCLDSTOP 0x40 /* Don't send SIGCHLD when children stop. */
+
+
+/* Values for the HOW argument to `sigprocmask'. */
+#define SIG_BLOCK 0 /* Block signals. */
+#define SIG_UNBLOCK 1 /* Unblock signals. */
+#define SIG_SETMASK 2 /* Set the set of blocked signals. */
diff --git a/sysdeps/unix/sysv/mkdir.c b/sysdeps/unix/sysv/mkdir.c
new file mode 100644
index 0000000..16713f9
--- /dev/null
+++ b/sysdeps/unix/sysv/mkdir.c
@@ -0,0 +1,97 @@
+/* Copyright (C) 1992, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <string.h>
+
+/* Create a directory named PATH with protections MODE. */
+int
+DEFUN(__mkdir, (path, mode), CONST char *path AND mode_t mode)
+{
+ char *cmd = __alloca (80 + strlen (path));
+ char *p;
+ int status;
+ mode_t mask;
+ int save;
+ struct stat statbuf;
+
+ if (path == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* Check for some errors. */
+ if (__stat (path, &statbuf) < 0)
+ {
+ if (errno != ENOENT)
+ return -1;
+ /* There is no file by that name. Good. */
+ }
+ else
+ {
+ errno = EEXIST;
+ return -1;
+ }
+
+ /* Race condition, but how else to do it? */
+ mask = __umask (0777);
+ (void) __umask (mask);
+
+ p = cmd;
+ *p++ = 'm';
+ *p++ = 'k';
+ *p++ = 'd';
+ *p++ = 'i';
+ *p++ = 'r';
+ *p++ = ' ';
+
+ mode &= ~mask;
+ *p++ = '-';
+ *p++ = 'm';
+ *p++ = ' ';
+ *p++ = ((mode & 07000) >> 9) + '0';
+ *p++ = ((mode & 0700) >> 6) + '0';
+ *p++ = ((mode & 070) >> 3) + '0';
+ *p++ = ((mode & 07)) + '0';
+ *p++ = ' ';
+
+ strcpy (p, path);
+
+ save = errno;
+ /* If system doesn't set errno, but the mkdir fails, we really
+ have no idea what went wrong. EIO is the vaguest error I
+ can think of, so I'll use that. */
+ errno = EIO;
+ status = system (cmd);
+ if (WIFEXITED (status) && WEXITSTATUS (status) == 0)
+ {
+ errno = save;
+ return 0;
+ }
+ else
+ return -1;
+}
+
+weak_alias (__mkdir, mkdir)
diff --git a/sysdeps/unix/sysv/nice.S b/sysdeps/unix/sysv/nice.S
new file mode 100644
index 0000000..b04bb41
--- /dev/null
+++ b/sysdeps/unix/sysv/nice.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (nice, 1)
+ ret
diff --git a/sysdeps/unix/sysv/pause.S b/sysdeps/unix/sysv/pause.S
new file mode 100644
index 0000000..82441ff
--- /dev/null
+++ b/sysdeps/unix/sysv/pause.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (pause, 0)
+ ret
diff --git a/sysdeps/unix/sysv/poll.S b/sysdeps/unix/sysv/poll.S
new file mode 100644
index 0000000..063236e
--- /dev/null
+++ b/sysdeps/unix/sysv/poll.S
@@ -0,0 +1,22 @@
+/* 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. */
+
+#include <sysdep.h>
+
+SYSCALL (poll, 3)
+ ret
diff --git a/sysdeps/unix/sysv/rmdir.c b/sysdeps/unix/sysv/rmdir.c
new file mode 100644
index 0000000..52a130c
--- /dev/null
+++ b/sysdeps/unix/sysv/rmdir.c
@@ -0,0 +1,78 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <string.h>
+
+/* Create a directory named PATH with protections MODE. */
+int
+DEFUN(__rmdir, (path), CONST char *path)
+{
+ char *cmd = __alloca (80 + strlen (path));
+ char *p;
+ int status;
+ int save;
+ struct stat statbuf;
+
+ if (path == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* Check for some errors. */
+ if (__stat (path, &statbuf) < 0)
+ return -1;
+ if (!S_ISDIR (statbuf.st_mode))
+ {
+ errno = ENOTDIR;
+ return -1;
+ }
+
+ p = cmd;
+ *p++ = 'r';
+ *p++ = 'm';
+ *p++ = 'd';
+ *p++ = 'i';
+ *p++ = 'r';
+ *p++ = ' ';
+
+ strcpy (p, path);
+
+ save = errno;
+ /* If system doesn't set errno, but the rmdir fails, we really
+ have no idea what went wrong. EIO is the vaguest error I
+ can think of, so I'll use that. */
+ errno = EIO;
+ status = system (cmd);
+ if (WIFEXITED (status) && WEXITSTATUS (status) == 0)
+ {
+ return 0;
+ errno = save;
+ }
+ else
+ return -1;
+}
+
+weak_alias (__rmdir, rmdir)
diff --git a/sysdeps/unix/sysv/s_getdents.S b/sysdeps/unix/sysv/s_getdents.S
new file mode 100644
index 0000000..6e60c08
--- /dev/null
+++ b/sysdeps/unix/sysv/s_getdents.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (getdents, 3)
+ ret
diff --git a/sysdeps/unix/sysv/sco3.2.4/Dist b/sysdeps/unix/sysv/sco3.2.4/Dist
new file mode 100644
index 0000000..462b9fb
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/Dist
@@ -0,0 +1,2 @@
+pgrpsys.S
+sco_getgrp.S
diff --git a/sysdeps/unix/sysv/sco3.2.4/Makefile b/sysdeps/unix/sysv/sco3.2.4/Makefile
new file mode 100644
index 0000000..23525e5
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/Makefile
@@ -0,0 +1,3 @@
+ifeq (posix,$(subdir))
+sysdep_routines := $(sysdep_routines) pgrpsys sco_getgrp
+endif
diff --git a/sysdeps/unix/sysv/sco3.2.4/__setpgid.c b/sysdeps/unix/sysv/sco3.2.4/__setpgid.c
new file mode 100644
index 0000000..3c4304c
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/__setpgid.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1994 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
+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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+extern int __pgrpsys __P ((int type, ...));
+
+/* Get the process group ID of process PID. */
+int
+DEFUN(__setpgid, (pid, pgid), pid_t pid AND pid_t pgid)
+{
+ return __pgrpsys (2, pid, pgid);
+}
diff --git a/sysdeps/unix/sysv/sco3.2.4/confname.h b/sysdeps/unix/sysv/sco3.2.4/confname.h
new file mode 100644
index 0000000..0408951
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/confname.h
@@ -0,0 +1,50 @@
+/* `sysconf', `pathconf', and `confstr' NAME values. Generic version.
+Copyright (C) 1993 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. */
+
+/* Values for the NAME argument to `pathconf' and `fpathconf'. */
+#define _PC_LINK_MAX 0
+#define _PC_MAX_CANON 1
+#define _PC_MAX_INPUT 2
+#define _PC_NAME_MAX 3
+#define _PC_PATH_MAX 4
+#define _PC_PIPE_BUF 5
+#define _PC_CHOWN_RESTRICTED 6
+#define _PC_NO_TRUNC 7
+#define _PC_VDISABLE 8
+
+/* Values for the argument to `sysconf'. */
+#define _SC_ARG_MAX 0
+#define _SC_CHILD_MAX 1
+#define _SC_CLK_TCK 2
+#define _SC_NGROUPS_MAX 3
+#define _SC_OPEN_MAX 4
+#define _SC_JOB_CONTROL 5
+#define _SC_SAVED_IDS 6
+#define _SC_VERSION 7
+#define _SC_PASS_MAX 8
+#define _SC_XOPEN_VERSION 9
+#define _SC_TZNAME_MAX 666 /* Not handled by SCO's system call. */
+
+#ifdef __USE_POSIX2
+/* Values for the NAME argument to `confstr'. */
+enum
+ {
+ _CS_PATH /* The default search path. */
+ };
+#endif
diff --git a/sysdeps/unix/sysv/sco3.2.4/direct.h b/sysdeps/unix/sysv/sco3.2.4/direct.h
new file mode 100644
index 0000000..b3eaa54
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/direct.h
@@ -0,0 +1,22 @@
+#ifndef MAXNAMLEN
+#define MAXNAMLEN 512
+#endif
+#define DIRBUF 1048 /* minimum buffer size for call to getdents */
+
+struct direct
+ {
+ unsigned short int d_fileno;
+ short int d_pad;
+ long int d_off;
+ unsigned short int d_reclen;
+ char d_name[1]; /* Actually longer. */
+ };
+
+#include <stddef.h>
+
+/* We calculate the length of the name by taking the length of the whole
+ `struct direct' record, subtracting the size of everything before the
+ name, and subtracting one for the terminating null. */
+
+#define D_NAMLEN(d) \
+ ((d)->d_reclen - offsetof (struct direct, d_name) - 1)
diff --git a/sysdeps/unix/sysv/sco3.2.4/getgroups.c b/sysdeps/unix/sysv/sco3.2.4/getgroups.c
new file mode 100644
index 0000000..68966bc
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/getgroups.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1994, 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. */
+
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <limits.h>
+#include <alloca.h>
+
+extern int __sco_getgroups __P ((int size, unsigned short int *list));
+
+int
+DEFUN(__getgroups, (size, list), int size AND gid_t *list)
+{
+ int i;
+ unsigned short int *shortlist;
+
+ if (size <= 0)
+ return __sco_getgroups (size, NULL);
+
+ shortlist = __alloca (size * sizeof (*shortlist));
+
+ size = __sco_getgroups (size, shortlist);
+ for (i = 0; i < size; ++i)
+ list[i] = shortlist[i];
+
+ return size;
+}
+
+weak_alias (__getgroups, getgroups)
diff --git a/sysdeps/unix/sysv/sco3.2.4/getpgid.c b/sysdeps/unix/sysv/sco3.2.4/getpgid.c
new file mode 100644
index 0000000..3b47d9d
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/getpgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/sysv4/getpgid.c>
diff --git a/sysdeps/unix/sysv/sco3.2.4/pathconf.S b/sysdeps/unix/sysv/sco3.2.4/pathconf.S
new file mode 100644
index 0000000..1c4dd95
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/pathconf.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1993, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (pathconf, 2)
+ ret
+
+weak_alias (__pathconf, pathconf)
diff --git a/sysdeps/unix/sysv/sco3.2.4/pgrpsys.S b/sysdeps/unix/sysv/sco3.2.4/pgrpsys.S
new file mode 100644
index 0000000..2c7d994
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/pgrpsys.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/sysv4/pgrpsys.S>
diff --git a/sysdeps/unix/sysv/sco3.2.4/pipestream.c b/sysdeps/unix/sysv/sco3.2.4/pipestream.c
new file mode 100644
index 0000000..b768e62
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/pipestream.c
@@ -0,0 +1,3 @@
+/* SCO 3.2v4 does have `waitpid'.
+ Avoid unix/pipestream.c, which says we don't. */
+#include <sysdeps/posix/pipestream.c>
diff --git a/sysdeps/unix/sysv/sco3.2.4/sco_getgrp.S b/sysdeps/unix/sysv/sco3.2.4/sco_getgrp.S
new file mode 100644
index 0000000..e68c300
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/sco_getgrp.S
@@ -0,0 +1,22 @@
+/* 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. */
+
+#include <sysdep.h>
+
+PSEUDO (__sco_getgroups, getgroups, 2)
+ ret
diff --git a/sysdeps/unix/sysv/sco3.2.4/setpgid.c b/sysdeps/unix/sysv/sco3.2.4/setpgid.c
new file mode 100644
index 0000000..cc9c4cd
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/setpgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/sysv4/setpgid.c>
diff --git a/sysdeps/unix/sysv/sco3.2.4/setsid.c b/sysdeps/unix/sysv/sco3.2.4/setsid.c
new file mode 100644
index 0000000..6337652
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/setsid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/sysv4/setsid.c>
diff --git a/sysdeps/unix/sysv/sco3.2.4/sigaction.S b/sysdeps/unix/sysv/sco3.2.4/sigaction.S
new file mode 100644
index 0000000..dc1bb41
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/sigaction.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <sysdep.h>
+
+.globl C_SYMBOL_NAME(__sigreturn)
+
+ENTRY (__sigaction)
+ movl $C_SYMBOL_NAME(__sigreturn), %ecx
+ DO_CALL (sigaction, 3)
+ jb syscall_error
+ ret
+
+weak_alias (__sigaction, sigaction)
diff --git a/sysdeps/unix/sysv/sco3.2.4/sigaction.h b/sysdeps/unix/sysv/sco3.2.4/sigaction.h
new file mode 100644
index 0000000..c6344f0
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/sigaction.h
@@ -0,0 +1,39 @@
+/* The proper definitions for SCO's sigaction.
+Copyright (C) 1993, 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, 1992 Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+/* Structure describing the action to be taken when a signal arrives. */
+struct sigaction
+ {
+ /* Signal handler. */
+ __sighandler_t sa_handler;
+
+ /* Additional set of signals to be blocked. */
+ __sigset_t sa_mask;
+
+ /* Special flags. */
+ int sa_flags;
+ };
+
+/* Bits in `sa_flags'. */
+#define SA_NOCLDSTOP 0x01 /* Don't send SIGCHLD when children stop. */
+
+/* Values for the HOW argument to `sigprocmask'. */
+#define SIG_SETMASK 0 /* Set the set of blocked signals. */
+#define SIG_BLOCK 1 /* Block signals. */
+#define SIG_UNBLOCK 2 /* Unblock signals. */
diff --git a/sysdeps/unix/sysv/sco3.2.4/sigpending.S b/sysdeps/unix/sysv/sco3.2.4/sigpending.S
new file mode 100644
index 0000000..bc05b2e
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/sigpending.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1993 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. */
+
+#include <sysdep.h>
+
+SYSCALL (sigpending, 1)
+ ret
diff --git a/sysdeps/unix/sysv/sco3.2.4/sigprocmask.S b/sysdeps/unix/sysv/sco3.2.4/sigprocmask.S
new file mode 100644
index 0000000..ff19915
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/sigprocmask.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1993, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (sigprocmask, 3)
+ ret
+
+weak_alias (__sigprocmask, sigprocmask)
diff --git a/sysdeps/unix/sysv/sco3.2.4/sigsuspend.S b/sysdeps/unix/sysv/sco3.2.4/sigsuspend.S
new file mode 100644
index 0000000..9bce387
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/sigsuspend.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/sysv4/sigsuspend.S>
diff --git a/sysdeps/unix/sysv/sco3.2.4/syscall.h b/sysdeps/unix/sysv/sco3.2.4/syscall.h
new file mode 100644
index 0000000..316bd0d
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/syscall.h
@@ -0,0 +1,107 @@
+/* From Scott Bartram. */
+
+#ifndef _SYSCALL_H
+#define _SYSCALL_H
+
+#define SYS_access 33
+#define SYS_acct 51
+#define SYS_advfs 70
+#define SYS_alarm 27
+#define SYS_break 17
+#define SYS_brk 17
+#define SYS_chdir 12
+#define SYS_chmod 15
+#define SYS_chown 16
+#define SYS_chroot 61
+#define SYS_chsize 0x0a28
+#define SYS_close 6
+#define SYS_creat 8
+#define SYS_dup 41
+#define SYS_exec 11
+#define SYS_exece 59
+#define SYS_exit 1
+#define SYS_fcntl 62
+#define SYS_fork 2
+#define SYS_fpathconf 0x2f28
+#define SYS_fstat 28
+#define SYS_fstatfs 38
+#define SYS_ftime 0x0b28
+#define SYS_getdents 81
+#define SYS_getgid 47
+#define SYS_getgroups 0x2b28
+#define SYS_getitimer 0x3728
+#define SYS_getmsg 85
+#define SYS_getpid 20
+#define SYS_getuid 24
+#define SYS_gtty 32
+#define SYS_ioctl 54
+#define SYS_kill 37
+#define SYS_link 9
+#define SYS_lock 45
+#define SYS_lseek 19
+#define SYS_lstat 91
+#define SYS_mkdir 80
+#define SYS_mknod 14
+#define SYS_mount 21
+#define SYS_msgsys 49
+#define SYS_nap 0x0c28
+#define SYS_nice 34
+#define SYS_open 5
+#define SYS_pathconf 0x2e28
+#define SYS_pause 29
+#define SYS_pgrpsys 39
+#define SYS_pipe 42
+#define SYS_plock 45
+#define SYS_poll 87
+#define SYS_prof 44
+#define SYS_ptrace 26
+#define SYS_putmsg 86
+#define SYS_rdebug 76
+#define SYS_read 3
+#define SYS_readlink 92
+#define SYS_rename 0x3028
+#define SYS_rfstart 74
+#define SYS_rfstop 77
+#define SYS_rfsys 78
+#define SYS_rmdir 79
+#define SYS_rmount 72
+#define SYS_rumount 73
+#define SYS_seek 19
+#define SYS_select 0x2428
+#define SYS_semsys 53
+#define SYS_setgid 46
+#define SYS_setgroups 0x2c28
+#define SYS_setitimer 0x3828
+#define SYS_setpgrp 39
+#define SYS_setuid 23
+#define SYS_shmsys 52
+#define SYS_sigaction 0x2728
+#define SYS_signal 48
+#define SYS_sigpending 0x2928
+#define SYS_sigprocmask 0x2828
+#define SYS_sigsuspend 0x2a28
+#define SYS_stat 18
+#define SYS_statfs 35
+#define SYS_stime 25
+#define SYS_stty 31
+#define SYS_symlink 90
+#define SYS_sync 36
+#define SYS_sys3b 50
+#define SYS_sysacct 51
+#define SYS_sysconf 0x2d28
+#define SYS_sysfs 84
+#define SYS_sysi86 50
+#define SYS_time 13
+#define SYS_times 43
+#define SYS_uadmin 55
+#define SYS_ulimit 63
+#define SYS_umask 60
+#define SYS_umount 22
+#define SYS_unadvfs 71
+#define SYS_unlink 10
+#define SYS_utime 30
+#define SYS_utssys 57
+#define SYS_wait 7
+#define SYS_write 4
+
+#endif
diff --git a/sysdeps/unix/sysv/sco3.2.4/sysconf.S b/sysdeps/unix/sysv/sco3.2.4/sysconf.S
new file mode 100644
index 0000000..631e5e9
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/sysconf.S
@@ -0,0 +1,30 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <sysdep.h>
+#include <confname.h>
+
+.globl __tzname_max
+ENTRY (__sysconf)
+ cmpl $_SC_TZNAME_MAX, 4(%esp) /* Is the arg _SC_TZNAME_MAX? */
+ je tzname
+ DO_CALL (sysconf, 1) /* No; use the SCO system call. */
+ ret
+tzname: jmp C_SYMBOL_NAME(__tzname_max) /* Yes; bounce to __tzname_max (). */
+
+weak_alias (__sysconf, sysconf)
diff --git a/sysdeps/unix/sysv/sco3.2.4/system.c b/sysdeps/unix/sysv/sco3.2.4/system.c
new file mode 100644
index 0000000..06dc066
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/system.c
@@ -0,0 +1,10 @@
+/* SCO has a bug where `waitpid' will never return if SIGCHLD is blocked.
+ They have acknowledged that this is a bug but I have not seen nor heard
+ of any forthcoming fix. */
+
+#define WAITPID_CANNOT_BLOCK_SIGCHLD
+
+/* SCO 3.2v4 does have `waitpid'.
+ Avoid unix/system.c, which says we don't. */
+
+#include <sysdeps/posix/system.c>
diff --git a/sysdeps/unix/sysv/sco3.2.4/uname.S b/sysdeps/unix/sysv/sco3.2.4/uname.S
new file mode 100644
index 0000000..a22d18a
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/uname.S
@@ -0,0 +1,42 @@
+/* Copyright (C) 1993, 1994 Free Software Foundation, Inc.
+ Contributed by Scott Bartram.
+
+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. */
+
+#include <sysdep.h>
+
+/*
+ before lcall, stack contents should be:
+
+ 4(%esp) -> name
+ 8(%esp) -> unspecified
+ 12(%esp) -> 0
+ */
+
+ENTRY (uname)
+ pushl $0x0 /* Push the discriminator flag. */
+ pushl $0x0 /* Push dummy placeholder. */
+ pushl 12(%esp,1) /* Push NAME (ptr to struct utsname) */
+ subl $0x4, %esp /* Adjust stack pointer. */
+ DO_CALL (utssys, 3)
+ jb error /* Test for error. */
+ addl $0x10, %esp /* Adjust the stack pointer. */
+ xorl %eax, %eax /* Clear return value. */
+ ret
+error: addl $0x10, %esp /* Adjust the stack pointer. */
+ jmp syscall_error
diff --git a/sysdeps/unix/sysv/sco3.2.4/waitpid.S b/sysdeps/unix/sysv/sco3.2.4/waitpid.S
new file mode 100644
index 0000000..523ef37
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2.4/waitpid.S
@@ -0,0 +1,36 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <sysdep.h>
+
+ENTRY (__waitpid)
+ /* The `waitpid' system call is distinguished from plain
+ `wait' by setting lots of bits in the processor flags. */
+ pushfl /* Push the flags word. */
+ popl %eax /* Pop it into the accumulator. */
+ orl $0x8c4, %eax /* Set lots of bits. */
+ pushl %eax /* Push the new flags word. */
+ popfl /* Pop it into the flags. */
+ DO_CALL (wait, 2)
+ movl 8(%esp), scratch /* Put status pointer in scratch register. */
+ testl scratch, scratch /* Is it non-nil? */
+ je null
+ movl r1, (scratch) /* Yes; store the status there. */
+null: ret
+
+weak_alias (__waitpid, waitpid)
diff --git a/sysdeps/unix/sysv/sco3.2/Dist b/sysdeps/unix/sysv/sco3.2/Dist
new file mode 100644
index 0000000..60fab2b
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2/Dist
@@ -0,0 +1 @@
+__fltused.c
diff --git a/sysdeps/unix/sysv/sco3.2/Makefile b/sysdeps/unix/sysv/sco3.2/Makefile
new file mode 100644
index 0000000..1be24e8
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2/Makefile
@@ -0,0 +1,23 @@
+# Copyright (C) 1993 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.
+
+ifeq ($(subdir),misc)
+
+sysdep_routines := $(sysdep_routines) __fltused
+
+endif
diff --git a/sysdeps/unix/sysv/sco3.2/__fltused.c b/sysdeps/unix/sysv/sco3.2/__fltused.c
new file mode 100644
index 0000000..5d1d67f
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2/__fltused.c
@@ -0,0 +1,3 @@
+/* Code compiled by the SCO compiler apparently likes this to be defined. */
+
+int __fltused = 1;
diff --git a/sysdeps/unix/sysv/sco3.2/local_lim.h b/sysdeps/unix/sysv/sco3.2/local_lim.h
new file mode 100644
index 0000000..6d6c3b0
--- /dev/null
+++ b/sysdeps/unix/sysv/sco3.2/local_lim.h
@@ -0,0 +1,37 @@
+/* Copyright (C) 1993 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 _LOCAL_LIM_H
+#define _LOCAL_LIM_H 1
+
+#define NGROUPS_MAX 8 /* Maximum number of supplementary groups. */
+#define ARG_MAX 5120
+#define CHILD_MAX 25
+#define OPEN_MAX 60
+#define LINK_MAX 1000
+#define MAX_CANON 256
+
+/* For SVR3, this is 14. For SVR4, it is 255, at least on ufs
+ file systems, even though the System V limits.h incorrectly
+ defines it as 14. Giving it a value which is too large
+ is harmless (it is a maximum). */
+#define NAME_MAX 255
+
+#define PATH_MAX 1024
+
+#endif /* local_lim.h */
diff --git a/sysdeps/unix/sysv/setrlimit.c b/sysdeps/unix/sysv/setrlimit.c
new file mode 100644
index 0000000..be4158e
--- /dev/null
+++ b/sysdeps/unix/sysv/setrlimit.c
@@ -0,0 +1,58 @@
+/* setrlimit function for systems with ulimit system call (SYSV).
+
+Copyright (C) 1991, 1992 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 only implements those functions which are available via ulimit. */
+
+#include <ansidecl.h>
+#include <sys/resource.h>
+#include <stddef.h>
+#include <errno.h>
+
+/* Set the soft and hard limits for RESOURCE to *RLIMITS.
+ Only the super-user can increase hard limits.
+ Return 0 if successful, -1 if not (and sets errno). */
+int
+DEFUN(setrlimit, (resource, rlimits),
+ enum __rlimit_resource resource AND struct rlimit *rlimits)
+{
+ if (rlimits == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ switch (resource)
+ {
+ case RLIMIT_FSIZE:
+ return __ulimit(2, rlimits->rlim_cur);
+
+ case RLIMIT_DATA:
+ case RLIMIT_CPU:
+ case RLIMIT_STACK:
+ case RLIMIT_CORE:
+ case RLIMIT_RSS:
+ errno = ENOSYS;
+ return -1;
+
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+}
diff --git a/sysdeps/unix/sysv/settimeofday.c b/sysdeps/unix/sysv/settimeofday.c
new file mode 100644
index 0000000..1217c6b
--- /dev/null
+++ b/sysdeps/unix/sysv/settimeofday.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/time.h>
+
+/* Set the current time of day and timezone information.
+ This call is restricted to the super-user. */
+int
+DEFUN(__settimeofday, (tv, tz),
+ CONST struct timeval *tv AND CONST struct timezone *tz)
+{
+ time_t when;
+
+ if (tv == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (tz != NULL || tv->tv_usec % 1000000 != 0)
+ {
+ errno = ENOSYS;
+ return -1;
+ }
+
+ when = tv->tv_sec + (tv->tv_usec / 1000000);
+ return stime (&when);
+}
+
+weak_alias (__settimeofday, settimeofday)
diff --git a/sysdeps/unix/sysv/sigaction.c b/sysdeps/unix/sysv/sigaction.c
new file mode 100644
index 0000000..ebb42cf
--- /dev/null
+++ b/sysdeps/unix/sysv/sigaction.c
@@ -0,0 +1,83 @@
+/* Copyright (C) 1992, 1994, 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. */
+
+#include <ansidecl.h>
+#include <sysdep.h>
+#include <errno.h>
+#include <stddef.h>
+#include <signal.h>
+
+
+/* If ACT is not NULL, change the action for SIG to *ACT.
+ If OACT is not NULL, put the old action for SIG in *OACT. */
+int
+DEFUN(__sigaction, (sig, act, oact),
+ int sig AND CONST struct sigaction *act AND struct sigaction *oact)
+{
+ sighandler_t handler;
+ int save;
+
+ if (sig <= 0 || sig >= NSIG)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (act == NULL)
+ {
+ if (oact == NULL)
+ return 0;
+ /* Race condition, but this is the only way to do it. */
+ handler = signal (sig, SIG_IGN);
+ if (handler == SIG_ERR)
+ return -1;
+ save = errno;
+ (void) signal (sig, handler);
+ errno = save;
+ }
+ else
+ {
+ int i;
+
+ if (act->sa_flags != 0)
+ {
+ unimplemented:
+ errno = ENOSYS;
+ return -1;
+ }
+
+ for (i = 1; i < NSIG; ++i)
+ if (__sigismember (&act->sa_mask, i))
+ goto unimplemented;
+
+ handler = signal (sig, act->sa_handler);
+ if (handler == SIG_ERR)
+ return -1;
+ }
+
+ if (oact != NULL)
+ {
+ oact->sa_handler = handler;
+ __sigemptyset (&oact->sa_mask);
+ oact->sa_flags = 0;
+ }
+
+ return 0;
+}
+
+weak_alias (__sigaction, sigaction)
diff --git a/sysdeps/unix/sysv/signal.S b/sysdeps/unix/sysv/signal.S
new file mode 100644
index 0000000..5230b34
--- /dev/null
+++ b/sysdeps/unix/sysv/signal.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (signal, 2)
+ ret
diff --git a/sysdeps/unix/sysv/signum.h b/sysdeps/unix/sysv/signum.h
new file mode 100644
index 0000000..e28a62a
--- /dev/null
+++ b/sysdeps/unix/sysv/signum.h
@@ -0,0 +1,56 @@
+/* Signal number definitions. System V version.
+Copyright (C) 1991, 1992, 1993 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. */
+
+#ifdef _SIGNAL_H
+
+/* This file defines the fake signal functions and signal
+ number constants for System V release 3. */
+
+/* Fake signal functions. */
+#define SIG_ERR ((__sighandler_t) -1) /* Error return. */
+#define SIG_DFL ((__sighandler_t) 0) /* Default action. */
+#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */
+
+
+/* Signals. */
+#define SIGHUP 1 /* Hangup (POSIX). */
+#define SIGINT 2 /* Interrupt (ANSI). */
+#define SIGQUIT 3 /* Quit (POSIX). */
+#define SIGILL 4 /* Illegal instruction (ANSI). */
+#define SIGABRT SIGIOT /* Abort (ANSI). */
+#define SIGTRAP 5 /* Trace trap (POSIX). */
+#define SIGIOT 6 /* IOT trap (4.2 BSD). */
+#define SIGEMT 7 /* EMT trap (4.2 BSD). */
+#define SIGFPE 8 /* Floating-point exception (ANSI). */
+#define SIGKILL 9 /* Kill, unblockable (POSIX). */
+#define SIGBUS 10 /* Bus error (4.2 BSD). */
+#define SIGSEGV 11 /* Segmentation violation (ANSI). */
+#define SIGSYS 12 /* Bad argument to system call (4.2 BSD)*/
+#define SIGPIPE 13 /* Broken pipe (POSIX). */
+#define SIGALRM 14 /* Alarm clock (POSIX). */
+#define SIGTERM 15 /* Termination (ANSI). */
+#define SIGUSR1 16 /* User-defined signal 1 (POSIX). */
+#define SIGUSR2 17 /* User-defined signal 2 (POSIX). */
+#define SIGCHLD 18 /* Child status has changed (POSIX). */
+#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */
+#define SIGPWR 19 /* Power failure restart (System V). */
+
+#endif /* <signal.h> included. */
+
+#define _NSIG 20 /* Biggest signal number + 1. */
diff --git a/sysdeps/unix/sysv/statbuf.h b/sysdeps/unix/sysv/statbuf.h
new file mode 100644
index 0000000..aa2cdfe
--- /dev/null
+++ b/sysdeps/unix/sysv/statbuf.h
@@ -0,0 +1,61 @@
+/* Copyright (C) 1992 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 _STATBUF_H
+#define _STATBUF_H
+
+struct stat
+ {
+ short int st_dev;
+ unsigned short int st_ino;
+ unsigned short int st_mode;
+ short int st_nlink;
+ unsigned short int st_uid;
+ unsigned short int st_gid;
+ short int st_rdev;
+ long int st_size;
+ long int st_atime;
+ long int st_mtime;
+ long int st_ctime;
+ };
+
+/* Encoding of the file mode. */
+
+#define __S_IFMT 0170000 /* These bits determine file type. */
+
+/* File types. */
+#define __S_IFDIR 0040000 /* Directory. */
+#define __S_IFCHR 0020000 /* Character device. */
+#define __S_IFBLK 0060000 /* Block device. */
+#define __S_IFREG 0100000 /* Regular file. */
+#define __S_IFIFO 0010000 /* FIFO. */
+
+/* These don't actually exist on System V, but having them doesn't hurt. */
+#define __S_IFLNK 0120000 /* Symbolic link. */
+#define __S_IFSOCK 0140000 /* Socket. */
+
+/* Protection bits. */
+
+#define __S_ISUID 04000 /* Set user ID on execution. */
+#define __S_ISGID 02000 /* Set group ID on execution. */
+#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
+#define __S_IREAD 0400 /* Read by owner. */
+#define __S_IWRITE 0200 /* Write by owner. */
+#define __S_IEXEC 0100 /* Execute by owner. */
+
+#endif /* statbuf.h */
diff --git a/sysdeps/unix/sysv/stime.S b/sysdeps/unix/sysv/stime.S
new file mode 100644
index 0000000..0ffb6bb
--- /dev/null
+++ b/sysdeps/unix/sysv/stime.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (stime, 1)
+ ret
diff --git a/sysdeps/unix/sysv/sysd-stdio.c b/sysdeps/unix/sysv/sysd-stdio.c
new file mode 100644
index 0000000..35dae27
--- /dev/null
+++ b/sysdeps/unix/sysv/sysd-stdio.c
@@ -0,0 +1,2 @@
+#define EINTR_REPEAT
+#include <../sysdeps/generic/sysd-stdio.c>
diff --git a/sysdeps/unix/sysv/sysv4/Dist b/sysdeps/unix/sysv/sysv4/Dist
new file mode 100644
index 0000000..f603d8b
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/Dist
@@ -0,0 +1,7 @@
+sysconfig.h
+sysconfig.S
+pgrpsys.S
+__waitid.S
+siginfo.h
+__getpgid.c __setpgid.c
+sysinfo.S
diff --git a/sysdeps/unix/sysv/sysv4/Implies b/sysdeps/unix/sysv/sysv4/Implies
new file mode 100644
index 0000000..953822e
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/Implies
@@ -0,0 +1,3 @@
+# The directory unix/common contains things which are common to both BSD
+# and SVR4.
+unix/common
diff --git a/sysdeps/unix/sysv/sysv4/Makefile b/sysdeps/unix/sysv/sysv4/Makefile
new file mode 100644
index 0000000..0c149da
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/Makefile
@@ -0,0 +1,36 @@
+# Copyright (C) 1992, 1993, 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.
+
+ifeq ($(subdir),posix)
+
+sysdep_routines := $(sysdep_routines) sysconfig pgrpsys __waitid
+
+endif
+
+
+ifeq ($(subdir),signal)
+
+sysdep_routines := $(sysdep_routines) sys-sig
+
+endif
+
+ifeq ($(subdir),misc)
+
+sysdep_routines := $(sysdep_routines) sysinfo
+
+endif
diff --git a/sysdeps/unix/sysv/sysv4/__getpgid.c b/sysdeps/unix/sysv/sysv4/__getpgid.c
new file mode 100644
index 0000000..76a6e80
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/__getpgid.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+extern int __pgrpsys __P ((int type, ...));
+
+/* Get the process group ID of process PID. */
+int
+DEFUN(__getpgid, (pid), pid_t pid)
+{
+ return __pgrpsys (4, pid);
+}
diff --git a/sysdeps/unix/sysv/sysv4/__setpgid.c b/sysdeps/unix/sysv/sysv4/__setpgid.c
new file mode 100644
index 0000000..594e4e9
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/__setpgid.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1993 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+extern int __pgrpsys __P ((int type, ...));
+
+/* Get the process group ID of process PID. */
+int
+DEFUN(__setpgid, (pid, pgid), pid_t pid AND pid_t pgid)
+{
+ return __pgrpsys (5, pid, pgid);
+}
diff --git a/sysdeps/unix/sysv/sysv4/__waitid.S b/sysdeps/unix/sysv/sysv4/__waitid.S
new file mode 100644
index 0000000..845bec8
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/__waitid.S
@@ -0,0 +1,25 @@
+/* Copyright (C) 1993 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. */
+
+#include <sysdep.h>
+
+/* XXX */
+#define SYS_waitid SYS_waitsys
+
+SYSCALL__ (waitid, 3)
+ ret
diff --git a/sysdeps/unix/sysv/sysv4/dup2.c b/sysdeps/unix/sysv/sysv4/dup2.c
new file mode 100644
index 0000000..c7015fc
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/dup2.c
@@ -0,0 +1,4 @@
+/* SVR4 uses the POSIX dup2. */
+#include <sysdeps/posix/__dup2.c>
+
+weak_alias (__dup2, dup2)
diff --git a/sysdeps/unix/sysv/sysv4/fchdir.S b/sysdeps/unix/sysv/sysv4/fchdir.S
new file mode 100644
index 0000000..ef11d55
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/fchdir.S
@@ -0,0 +1,2 @@
+/* SVR4 uses the BSD 4.4 fchdir(2) syscall. */
+#include <sysdeps/unix/bsd/bsd4.4/fchdir.S>
diff --git a/sysdeps/unix/sysv/sysv4/ftruncate.c b/sysdeps/unix/sysv/sysv4/ftruncate.c
new file mode 100644
index 0000000..45f2614
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/ftruncate.c
@@ -0,0 +1,37 @@
+/* ftruncate for SVR4 using the fcntl F_FREESP command.
+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. */
+
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+
+/* Truncate the file FD refers to to LENGTH bytes. */
+int
+DEFUN(ftruncate, (fd, length),
+ int fd AND off_t length)
+{
+ struct flock fl;
+
+ memset (&fl, 0, sizeof fl);
+ fl.l_type = F_WRLCK;
+ fl.l_start = length;
+ return fcntl (fd, F_FREESP, &fl);
+}
diff --git a/sysdeps/unix/sysv/sysv4/getdtsz.c b/sysdeps/unix/sysv/sysv4/getdtsz.c
new file mode 100644
index 0000000..c1ae610
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/getdtsz.c
@@ -0,0 +1,2 @@
+/* Solaris uses sysconf ala POSIX.1. */
+#include <sysdeps/posix/getdtsz.c>
diff --git a/sysdeps/unix/sysv/sysv4/gethostname.c b/sysdeps/unix/sysv/sysv4/gethostname.c
new file mode 100644
index 0000000..cce1149
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/gethostname.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/systeminfo.h>
+
+extern int __sysinfo __P ((int command, char *buf, long count));
+
+int
+DEFUN(__gethostname, (name, namelen), char *name AND size_t namelen)
+{
+ return __sysinfo (SI_HOSTNAME, name, namelen);
+}
+
+weak_alias (__gethostname, gethostname)
diff --git a/sysdeps/unix/sysv/sysv4/getpagesize.c b/sysdeps/unix/sysv/sysv4/getpagesize.c
new file mode 100644
index 0000000..6119640
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/getpagesize.c
@@ -0,0 +1,2 @@
+/* Solaris uses sysconf ala POSIX.1. */
+#include <sysdeps/posix/getpagesize.c>
diff --git a/sysdeps/unix/sysv/sysv4/getpgid.c b/sysdeps/unix/sysv/sysv4/getpgid.c
new file mode 100644
index 0000000..309e2f1
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/getpgid.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+extern int __pgrpsys __P ((int type, ...));
+
+/* Get the process group ID of process PID. */
+int
+DEFUN(__getpgid, (pid), pid_t pid)
+{
+ return __pgrpsys (4, pid);
+}
+
+weak_alias (__getpgid, getpgid)
diff --git a/sysdeps/unix/sysv/sysv4/i386/Dist b/sysdeps/unix/sysv/sysv4/i386/Dist
new file mode 100644
index 0000000..69d16ac
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/i386/Dist
@@ -0,0 +1 @@
+sys-sig.S
diff --git a/sysdeps/unix/sysv/sysv4/i386/Makefile b/sysdeps/unix/sysv/sysv4/i386/Makefile
new file mode 100644
index 0000000..56f0a37
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/i386/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),signal)
+sysdep_routines := $(sysdep_routines) sys-sig
+endif
diff --git a/sysdeps/unix/sysv/sysv4/i386/fstat.S b/sysdeps/unix/sysv/sysv4/i386/fstat.S
new file mode 100644
index 0000000..11743b3
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/i386/fstat.S
@@ -0,0 +1,37 @@
+/* Copyright (C) 1994, 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. */
+
+#include <sysdep.h>
+
+/* In SVR4 the `stat' call is actually done by the `xstat' system call,
+ which takes an additional first argument giving a version number for
+ `struct stat'. Likewise for `fstat' and `lstat' there are `fxstat' and
+ `lxstat' system calls. This macro gives the SVR4 version number that
+ corresponds to the definition of `struct stat' in <statbuf.h>. */
+#define _STAT_VER 2
+
+.globl syscall_error
+ENTRY (__fstat)
+ popl %eax /* Pop return address into %eax. */
+ pushl $_STAT_VER /* Push extra first arg to syscall. */
+ pushl %eax /* Push back the return address. */
+ DO_CALL (fxstat, 3) /* Do the syscall. */
+ jb syscall_error /* Check for error. */
+ ret /* Return success. */
+
+weak_alias (__fstat, fstat)
diff --git a/sysdeps/unix/sysv/sysv4/i386/lstat.S b/sysdeps/unix/sysv/sysv4/i386/lstat.S
new file mode 100644
index 0000000..52ffdba
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/i386/lstat.S
@@ -0,0 +1,37 @@
+/* Copyright (C) 1994, 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. */
+
+#include <sysdep.h>
+
+/* In SVR4 the `stat' call is actually done by the `xstat' system call,
+ which takes an additional first argument giving a version number for
+ `struct stat'. Likewise for `fstat' and `lstat' there are `fxstat' and
+ `lxstat' system calls. This macro gives the SVR4 version number that
+ corresponds to the definition of `struct stat' in <statbuf.h>. */
+#define _STAT_VER 2
+
+.globl syscall_error
+ENTRY (__lstat)
+ popl %eax /* Pop return address into %eax. */
+ pushl $_STAT_VER /* Push extra first arg to syscall. */
+ pushl %eax /* Push back the return address. */
+ DO_CALL (lxstat, 3) /* Do the syscall. */
+ jb syscall_error /* Check for error. */
+ ret /* Return success. */
+
+weak_alias (__lstat, lstat)
diff --git a/sysdeps/unix/sysv/sysv4/i386/mknod.S b/sysdeps/unix/sysv/sysv4/i386/mknod.S
new file mode 100644
index 0000000..21f932c
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/i386/mknod.S
@@ -0,0 +1,36 @@
+/* Copyright (C) 1994, 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. */
+
+#include <sysdep.h>
+
+/* In SVR4 the `mknod' call is actually done by the `xmknod' system call,
+ which takes an additional first argument giving a version number for
+ the interface. This macro gives the SVR4 version number that
+ corresponds to the modern interface. */
+#define _MKNOD_VER 2
+
+.globl syscall_error
+ENTRY (__mknod)
+ popl %eax /* Pop return address into %eax. */
+ pushl $_MKNOD_VER /* Push extra first arg to syscall. */
+ pushl %eax /* Push back the return address. */
+ DO_CALL (xmknod, 3) /* Do the syscall. */
+ jb syscall_error /* Check for error. */
+ ret /* Return success. */
+
+weak_alias (__mknod, mknod)
diff --git a/sysdeps/unix/sysv/sysv4/i386/stat.S b/sysdeps/unix/sysv/sysv4/i386/stat.S
new file mode 100644
index 0000000..3a5107c
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/i386/stat.S
@@ -0,0 +1,37 @@
+/* Copyright (C) 1994, 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. */
+
+#include <sysdep.h>
+
+/* In SVR4 the `stat' call is actually done by the `xstat' system call,
+ which takes an additional first argument giving a version number for
+ `struct stat'. Likewise for `fstat' and `lstat' there are `fxstat' and
+ `lxstat' system calls. This macro gives the SVR4 version number that
+ corresponds to the definition of `struct stat' in <statbuf.h>. */
+#define _STAT_VER 2
+
+.globl syscall_error
+ENTRY (__stat)
+ popl %eax /* Pop return address into %eax. */
+ pushl $_STAT_VER /* Push extra first arg to syscall. */
+ pushl %eax /* Push back the return address. */
+ DO_CALL (xstat, 3) /* Do the syscall. */
+ jb syscall_error /* Check for error. */
+ ret /* Return success. */
+
+weak_alias (__stat, stat)
diff --git a/sysdeps/unix/sysv/sysv4/i386/statbuf.h b/sysdeps/unix/sysv/sysv4/i386/statbuf.h
new file mode 100644
index 0000000..6f1bfed
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/i386/statbuf.h
@@ -0,0 +1,84 @@
+/* Copyright (C) 1993 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. */
+
+#ifndef _STATBUF_H
+#define _STATBUF_H
+
+#include <gnu/types.h>
+
+/* Structure describing file characteristics. */
+struct stat
+ {
+ unsigned long st_dev; /* Device. */
+ long st_filler1[3];
+ unsigned long st_ino; /* File serial number. */
+ unsigned long st_mode; /* File mode. */
+ unsigned long st_nlink; /* Link count. */
+ long st_uid; /* User ID of the file's owner. */
+ long st_gid; /* Group ID of the file's group.*/
+ unsigned long st_rdev; /* Device number, if device. */
+ long st_filler2[2];
+
+ long st_size; /* Size of file, in bytes. */
+ /* SVR4 added this extra long to allow for expansion of off_t. */
+ long st_filler3;
+
+ long st_atime; /* Time of last access. */
+ unsigned long st_atime_usec;
+ long st_mtime; /* Time of last modification. */
+ unsigned long st_mtime_usec;
+ long st_ctime; /* Time of last status change. */
+ unsigned long st_ctime_usec;
+
+ long st_blksize; /* Optimal block size for I/O. */
+#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
+
+ long st_blocks; /* Number of 512-byte blocks allocated. */
+ char st_fstype[16]; /* The type of this filesystem. */
+ int st_aclcnt;
+ unsigned long st_level;
+ unsigned long st_flags;
+ unsigned long st_cmwlevel;
+ long st_filler4[4];
+ };
+
+/* Encoding of the file mode. */
+
+#define __S_IFMT 0170000 /* These bits determine file type. */
+
+/* File types. */
+#define __S_IFDIR 0040000 /* Directory. */
+#define __S_IFCHR 0020000 /* Character device. */
+#define __S_IFBLK 0060000 /* Block device. */
+#define __S_IFREG 0100000 /* Regular file. */
+#define __S_IFIFO 0010000 /* FIFO. */
+
+/* These don't actually exist on System V, but having them doesn't hurt. */
+#define __S_IFLNK 0120000 /* Symbolic link. */
+#define __S_IFSOCK 0140000 /* Socket. */
+
+/* Protection bits. */
+
+#define __S_ISUID 04000 /* Set user ID on execution. */
+#define __S_ISGID 02000 /* Set group ID on execution. */
+#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
+#define __S_IREAD 0400 /* Read by owner. */
+#define __S_IWRITE 0200 /* Write by owner. */
+#define __S_IEXEC 0100 /* Execute by owner. */
+
+#endif /* statbuf.h */
diff --git a/sysdeps/unix/sysv/sysv4/i386/sys-sig.S b/sysdeps/unix/sysv/sysv4/i386/sys-sig.S
new file mode 100644
index 0000000..58430e4
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/i386/sys-sig.S
@@ -0,0 +1,30 @@
+/* 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. */
+
+#include <sysdep.h>
+
+.globl C_SYMBOL_NAME(__sigreturn)
+
+ENTRY (__sigaction_syscall)
+ movl $C_SYMBOL_NAME(__sigreturn), %edx
+ DO_CALL (sigaction, 3)
+ jb syscall_error
+ ret
+
+PSEUDO (__context_syscall, context, 2)
+ ret
diff --git a/sysdeps/unix/sysv/sysv4/i386/sysdep.h b/sysdeps/unix/sysv/sysv4/i386/sysdep.h
new file mode 100644
index 0000000..1e0cd69
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/i386/sysdep.h
@@ -0,0 +1,38 @@
+/* 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. */
+
+#include <sysdeps/unix/sysv/i386/sysdep.h>
+
+/* In SVR4 some system calls can fail with the error ERESTART,
+ and this means the call should be retried. */
+
+#ifndef _ERRNO_H
+#define _ERRNO_H
+#endif
+#include <errnos.h>
+
+#undef PSEUDO
+#define PSEUDO(name, syscall_name, args) \
+ .globl syscall_error; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args); \
+ jae noerror; \
+ cmpb $ERESTART, %al; \
+ je C_SYMBOL_NAME (name); \
+ jmp syscall_error; \
+ noerror:
diff --git a/sysdeps/unix/sysv/sysv4/i386/vfork.S b/sysdeps/unix/sysv/sysv4/i386/vfork.S
new file mode 100644
index 0000000..bbe99fb
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/i386/vfork.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/i386/vfork.S>
diff --git a/sysdeps/unix/sysv/sysv4/pgrpsys.S b/sysdeps/unix/sysv/sysv4/pgrpsys.S
new file mode 100644
index 0000000..dcfb487
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/pgrpsys.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1993 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (pgrpsys, 3)
+ ret
diff --git a/sysdeps/unix/sysv/sysv4/pipestream.c b/sysdeps/unix/sysv/sysv4/pipestream.c
new file mode 100644
index 0000000..6a32f95
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/pipestream.c
@@ -0,0 +1,2 @@
+/* We deliberately avoid having NO_WAITPID set. */
+#include <sysdeps/posix/pipestream.c>
diff --git a/sysdeps/unix/sysv/sysv4/setegid.S b/sysdeps/unix/sysv/sysv4/setegid.S
new file mode 100644
index 0000000..f8fd763
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/setegid.S
@@ -0,0 +1,2 @@
+/* SVR4 uses the BSD 4.4 setegid() system call. */
+#include <sysdeps/unix/bsd/bsd4.4/setegid.S>
diff --git a/sysdeps/unix/sysv/sysv4/seteuid.S b/sysdeps/unix/sysv/sysv4/seteuid.S
new file mode 100644
index 0000000..4ff1106
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/seteuid.S
@@ -0,0 +1,2 @@
+/* SVR4 uses the BSD 4.4 seteuid() system call. */
+#include <sysdeps/unix/bsd/bsd4.4/seteuid.S>
diff --git a/sysdeps/unix/sysv/sysv4/sethostname.c b/sysdeps/unix/sysv/sysv4/sethostname.c
new file mode 100644
index 0000000..4cebc45
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/sethostname.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1994 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/systeminfo.h>
+
+extern int __sysinfo __P ((int command, const char *buf, long count));
+
+int
+DEFUN(sethostname, (name, namelen), const char *name AND size_t namelen)
+{
+ return __sysinfo (SI_SET_HOSTNAME, name, namelen);
+}
diff --git a/sysdeps/unix/sysv/sysv4/setpgid.c b/sysdeps/unix/sysv/sysv4/setpgid.c
new file mode 100644
index 0000000..b9e06dc
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/setpgid.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+extern int __pgrpsys __P ((int type, ...));
+
+/* Set the process group ID of the process matching PID to PGID.
+ If PID is zero, the current process's process group ID is set.
+ If PGID is zero, the process ID of the process is used. */
+int
+DEFUN(__setpgid, (pid, pgid), int pid AND int pgid)
+{
+ return __pgrpsys (5, pid, pgid);
+}
+
+weak_alias (__setpgid, setpgid)
+weak_alias (__setpgid, setpgrp)
diff --git a/sysdeps/unix/sysv/sysv4/setsid.c b/sysdeps/unix/sysv/sysv4/setsid.c
new file mode 100644
index 0000000..f0d6c8a
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/setsid.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1993, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <unistd.h>
+
+extern int __pgrpsys __P ((int type, ...));
+
+/* Create a new session with the calling process as its leader.
+ The process group IDs of the session and the calling process
+ are set to the process ID of the calling process, which is returned. */
+int
+DEFUN_VOID(__setsid)
+{
+ return __pgrpsys (3);
+}
+
+weak_alias (__setsid, setsid)
diff --git a/sysdeps/unix/sysv/sysv4/sigaction.c b/sysdeps/unix/sysv/sysv4/sigaction.c
new file mode 100644
index 0000000..68fd7a1
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/sigaction.c
@@ -0,0 +1,79 @@
+/* Copyright (C) 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <signal.h>
+#include <stddef.h>
+
+static __sighandler_t user_handlers[NSIG];
+
+extern int __context_syscall (int, struct sigcontext *);
+extern int __sigaction_syscall (int,
+ const struct sigaction *, struct sigaction *);
+
+static void
+trampoline (int sig, int code, struct sigcontext *context)
+{
+ (*(void (*) (int, int, struct sigcontext *)) user_handlers[sig])
+ (sig, code, context);
+ __context_syscall (1, context);
+}
+
+/* If ACT is not NULL, change the action for SIG to *ACT.
+ If OACT is not NULL, put the old action for SIG in *OACT. */
+int
+DEFUN(__sigaction, (sig, act, oact),
+ int sig AND CONST struct sigaction *act AND struct sigaction *oact)
+{
+ struct sigaction myact;
+ __sighandler_t ohandler;
+
+ if (sig <= 0 || sig >= NSIG)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ohandler = user_handlers[sig];
+
+ if (act != NULL)
+ {
+ user_handlers[sig] = act->sa_handler;
+ if (act->sa_handler != SIG_DFL && act->sa_handler != SIG_IGN)
+ {
+ myact = *act;
+ act = &myact;
+ act->sa_handler = (__sighandler_t) trampoline;
+ }
+ }
+
+ if (__sigaction_syscall (sig, act, oact) < 0)
+ {
+ /* The syscall got an error. Restore the old handler and return -1. */
+ user_handlers[sig] = ohandler;
+ return -1;
+ }
+
+ if (oact != NULL && oact->sa_handler == (__sighandler_t) trampoline)
+ oact->sa_handler = ohandler;
+
+ return 0;
+}
+
+weak_alias (__sigaction, sigaction)
diff --git a/sysdeps/unix/sysv/sysv4/sigaction.h b/sysdeps/unix/sysv/sysv4/sigaction.h
new file mode 100644
index 0000000..dbb31f1
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/sigaction.h
@@ -0,0 +1,51 @@
+/* The proper definitions for SVR4's sigaction.
+Copyright (C) 1993, 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, 1992 Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+/* Structure describing the action to be taken when a signal arrives. */
+struct sigaction
+ {
+ /* Special flags. */
+ int sa_flags;
+
+ /* Signal handler. */
+ __sighandler_t sa_handler;
+
+ /* Additional set of signals to be blocked. */
+ __sigset_t sa_mask;
+
+ /* Padding. */
+ int sa_resv[2];
+ };
+
+/* Bits in `sa_flags'. */
+#ifdef __USE_MISC
+#define SA_ONSTACK 0x1 /* Take signal on signal stack. */
+#define SA_RESETHAND 0x2 /* Reset to SIG_DFL on entry to handler. */
+#define SA_RESTART 0x4 /* Don't restart syscall on signal return. */
+#define SA_SIGINFO 0x8 /* Provide additional info to the handler. */
+#define SA_NODEFER 0x10 /* Don't automatically block the signal when
+ its handler is being executed. */
+#define SA_NOCLDWAIT 0x10000 /* Don't save zombie processes. */
+#endif
+#define SA_NOCLDSTOP 0x20000 /* Don't send SIGCHLD when children stop. */
+
+/* Values for the HOW argument to `sigprocmask'. */
+#define SIG_BLOCK 1 /* Block signals. */
+#define SIG_UNBLOCK 2 /* Unblock signals. */
+#define SIG_SETMASK 3 /* Set the set of blocked signals. */
diff --git a/sysdeps/unix/sysv/sysv4/sigaltstack.S b/sysdeps/unix/sysv/sysv4/sigaltstack.S
new file mode 100644
index 0000000..e7e4060
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/sigaltstack.S
@@ -0,0 +1,2 @@
+/* SVR4 uses the BSD 4.4 sigaltstack syscall. */
+#include <sysdeps/unix/bsd/bsd4.4/sigaltstk.S>
diff --git a/sysdeps/unix/sysv/sysv4/siginfo.h b/sysdeps/unix/sysv/sysv4/siginfo.h
new file mode 100644
index 0000000..ce8dd35
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/siginfo.h
@@ -0,0 +1,58 @@
+/* Definitions of the siginfo structure.
+ Copyright (C) 1993, 1994 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. */
+
+#ifndef _SIGINFO_H
+#define _SIGINFO_H 1
+
+#ifdef __USE_SVID
+/* SVR4 puts a ton of other stuff in this structure. For now, we'll just
+ define the two things we really need out of it, and hope for the best. */
+
+/* These define the different states a child can have on exit.
+ We need these to build the status return for things like waitpid. */
+#define EXITED 1
+#define KILLED 2
+#define CORED 3
+#define TRAPPED 4
+#define STOPPED 5
+#define CONTINUED 6
+
+typedef struct __siginfo
+ {
+ int filler1;
+
+ /* Code indicating child's status */
+ int __code;
+
+ int filler2;
+
+ /* The PID of the child. */
+ long __pid;
+
+ int filler3;
+
+ /* The child's status. */
+ int __status;
+
+ int filler4[26];
+
+ } __siginfo_t;
+
+#endif /* __USE_SVID */
+#endif /* siginfo.h */
diff --git a/sysdeps/unix/sysv/sysv4/signum.h b/sysdeps/unix/sysv/sysv4/signum.h
new file mode 100644
index 0000000..aa3dc7f
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/signum.h
@@ -0,0 +1,66 @@
+/* Signal number definitions. SVR4 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. */
+
+#ifdef _SIGNAL_H
+
+/* Fake signal functions. */
+#define SIG_ERR ((__sighandler_t) -1) /* Error return. */
+#define SIG_DFL ((__sighandler_t) 0) /* Default action. */
+#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */
+
+
+/* Signals. */
+#define SIGHUP 1 /* Hangup (POSIX). */
+#define SIGINT 2 /* Interrupt (ANSI). */
+#define SIGQUIT 3 /* Quit (POSIX). */
+#define SIGILL 4 /* Illegal instruction (ANSI). */
+#define SIGABRT SIGIOT /* Abort (ANSI). */
+#define SIGTRAP 5 /* Trace trap (POSIX). */
+#define SIGIOT 6 /* IOT trap (4.2 BSD). */
+#define SIGEMT 7 /* EMT trap (4.2 BSD). */
+#define SIGFPE 8 /* Floating-point exception (ANSI). */
+#define SIGKILL 9 /* Kill, unblockable (POSIX). */
+#define SIGBUS 10 /* Bus error (4.2 BSD). */
+#define SIGSEGV 11 /* Segmentation violation (ANSI). */
+#define SIGSYS 12 /* Bad argument to system call (4.2 BSD)*/
+#define SIGPIPE 13 /* Broken pipe (POSIX). */
+#define SIGALRM 14 /* Alarm clock (POSIX). */
+#define SIGTERM 15 /* Termination (ANSI). */
+#define SIGUSR1 16 /* User-defined signal 1 (POSIX). */
+#define SIGUSR2 17 /* User-defined signal 2 (POSIX). */
+#define SIGCHLD 18 /* Child status has changed (POSIX). */
+#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */
+#define SIGPWR 19 /* Power failure restart (System V). */
+#define SIGWINCH 20 /* Window size change (4.3 BSD, Sun). */
+#define SIGURG 21 /* Urgent condition on socket (4.2 BSD).*/
+#define SIGPOLL 22 /* Pollable event occurred (System V). */
+#define SIGIO SIGPOLL /* I/O now possible (4.2 BSD). */
+#define SIGSTOP 23 /* Stop, unblockable (POSIX). */
+#define SIGTSTP 24 /* Keyboard stop (POSIX). */
+#define SIGCONT 25 /* Continue (POSIX). */
+#define SIGTTIN 26 /* Background read from tty (POSIX). */
+#define SIGTTOU 27 /* Background write to tty (POSIX). */
+#define SIGVTALRM 28 /* Virtual alarm clock (4.2 BSD). */
+#define SIGPROF 29 /* Profiling alarm clock (4.2 BSD). */
+#define SIGXCPU 30 /* CPU limit exceeded (4.2 BSD). */
+#define SIGXFSZ 31 /* File size limit exceeded (4.2 BSD). */
+
+#endif /* <signal.h> included. */
+
+#define _NSIG 32 /* Biggest signal number + 1. */
diff --git a/sysdeps/unix/sysv/sysv4/sigprocmask.S b/sysdeps/unix/sysv/sysv4/sigprocmask.S
new file mode 100644
index 0000000..51fddb0
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/sigprocmask.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (sigprocmask, 3)
+ ret
+
+weak_alias (__sigprocmask, sigprocmask)
diff --git a/sysdeps/unix/sysv/sysv4/sigset.h b/sysdeps/unix/sysv/sysv4/sigset.h
new file mode 100644
index 0000000..a007a43
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/sigset.h
@@ -0,0 +1,97 @@
+/* __sig_atomic_t, __sigset_t, and related definitions. SVR4 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, 1992 Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#ifndef _SIGSET_H_types
+#define _SIGSET_H_types 1
+
+typedef int __sig_atomic_t;
+
+/* A `sigset_t' has a bit for each signal. */
+typedef struct
+ {
+ unsigned long int __sigbits[4];
+ } __sigset_t;
+
+#endif /* ! _SIGSET_H_types */
+
+/* We only want to define these functions if <signal.h> was actually
+ included; otherwise we were included just to define the types. Since we
+ are namespace-clean, it wouldn't hurt to define extra macros. But
+ trouble can be caused by functions being defined (e.g., any global
+ register vars declared later will cause compilation errors). */
+
+#if !defined (_SIGSET_H_fns) && defined (_SIGNAL_H)
+#define _SIGSET_H_fns 1
+
+/* Return a mask that includes SIG only. */
+#define __sigmask(sig) (1 << ((sig) - 1))
+
+
+/* It's easier to assume 8-bit bytes than to get CHAR_BIT. */
+#define __NSSBITS (sizeof (__sigset_t) * 8)
+#define __SSELT(s) ((s) / __NSSBITS)
+#define __SSMASK(s) (1 << ((s) % __NSSBITS))
+
+#ifndef _EXTERN_INLINE
+#define _EXTERN_INLINE extern __inline
+#endif
+
+_EXTERN_INLINE int
+__sigemptyset (__sigset_t *__set)
+{
+ __set->__sigbits[0] = __set->__sigbits[1] =
+ __set->__sigbits[2] = __set->__sigbits[3] = 0L;
+ return 0;
+}
+
+_EXTERN_INLINE int
+__sigfillset (__sigset_t *__set)
+{
+ /* SVR4 has a system call for `sigfillset' (!), and it only sets the bits
+ for signals [1,31]. Setting bits for unimplemented signals seems
+ harmless (and we will find out if it really is). */
+ __set->__sigbits[0] = __set->__sigbits[1] =
+ __set->__sigbits[2] = __set->__sigbits[3] = -1;
+ return 0;
+}
+
+_EXTERN_INLINE int
+__sigaddset (__sigset_t *__set, int __sig)
+{
+ __set->__sigbits[__SSELT (__sig)] |= __SSMASK (__sig);
+ return 0;
+}
+
+_EXTERN_INLINE int
+__sigdelset (__sigset_t *__set, int __sig)
+{
+ __set->__sigbits[__SSELT (__sig)] &= ~__SSMASK (__sig);
+ return 0;
+}
+
+_EXTERN_INLINE int
+__sigismember (__const __sigset_t *__set, int __sig)
+{
+ if (__set->__sigbits[__SSELT (__sig)] & __SSMASK (__sig))
+ return 1;
+ return 0;
+}
+
+#endif /* ! _SIGSET_H_fns */
+
diff --git a/sysdeps/unix/sysv/sysv4/sigsuspend.S b/sysdeps/unix/sysv/sysv4/sigsuspend.S
new file mode 100644
index 0000000..85d3601
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/sigsuspend.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1993 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. */
+
+#include <sysdep.h>
+
+SYSCALL (sigsuspend, 1)
+ ret
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/Makefile b/sysdeps/unix/sysv/sysv4/solaris2/Makefile
new file mode 100644
index 0000000..3f86c46
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/solaris2/Makefile
@@ -0,0 +1,6 @@
+# The linker supplied with Solaris looks in the current directory
+# before searching others. Compiling the various programs that come
+# along the way (e.g., glue-ctype) will fail because it'll try to link
+# with the libc.a being *constructed* in $(objdir). As a work-around,
+# we add this to each native-compile.
+BUILD_CFLAGS := $(BUILD_CFLAGS) -L/lib
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/direct.h b/sysdeps/unix/sysv/sysv4/solaris2/direct.h
new file mode 100644
index 0000000..f9822dc
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/solaris2/direct.h
@@ -0,0 +1,39 @@
+/* Copyright (C) 1992, 1993 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 _BSDDIR_H
+#define _BSDDIR_H 1
+
+#include <limits.h>
+
+/* This is the Solaris direct; it's the same as that in
+ sysdeps/unix/sysv/sysv4/direct.h, but it uses the length given by d_namlen,
+ since we can't reliably use tyhe sysv4/direct.h method of computing
+ the length. */
+
+struct direct
+ {
+ unsigned long int d_fileno;
+ long int d_off;
+ unsigned short int d_reclen;
+ char d_name[NAME_MAX + 1];
+ };
+
+#define D_NAMLEN(d) (strlen ((d)->d_name))
+
+#endif
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/fsync.S b/sysdeps/unix/sysv/sysv4/solaris2/fsync.S
new file mode 100644
index 0000000..aefa3e3
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/solaris2/fsync.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 1994 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. */
+
+#include <sysdep.h>
+
+/* Solaris uses fdsync for the normal fsync. */
+ENTRY(fsync)
+ mov 16, %i1
+ mov SYS_ify(fdsync), %g1
+ ta 8
+ bcs syscall_error
+ nop
+ mov %g0, %o0
+ ret
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/signum.h b/sysdeps/unix/sysv/sysv4/solaris2/signum.h
new file mode 100644
index 0000000..8219626
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/solaris2/signum.h
@@ -0,0 +1,73 @@
+/* Signal number definitions. Solaris 2 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. */
+
+#ifdef _SIGNAL_H
+
+/* Fake signal functions. */
+#define SIG_ERR ((__sighandler_t) -1) /* Error return. */
+#define SIG_DFL ((__sighandler_t) 0) /* Default action. */
+#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */
+
+
+/* Signals. */
+#define SIGHUP 1 /* Hangup (POSIX). */
+#define SIGINT 2 /* Interrupt (ANSI). */
+#define SIGQUIT 3 /* Quit (POSIX). */
+#define SIGILL 4 /* Illegal instruction (ANSI). */
+#define SIGABRT SIGIOT /* Abort (ANSI). */
+#define SIGTRAP 5 /* Trace trap (POSIX). */
+#define SIGIOT 6 /* IOT trap (4.2 BSD). */
+#define SIGEMT 7 /* EMT trap (4.2 BSD). */
+#define SIGFPE 8 /* Floating-point exception (ANSI). */
+#define SIGKILL 9 /* Kill, unblockable (POSIX). */
+#define SIGBUS 10 /* Bus error (4.2 BSD). */
+#define SIGSEGV 11 /* Segmentation violation (ANSI). */
+#define SIGSYS 12 /* Bad argument to system call (4.2 BSD)*/
+#define SIGPIPE 13 /* Broken pipe (POSIX). */
+#define SIGALRM 14 /* Alarm clock (POSIX). */
+#define SIGTERM 15 /* Termination (ANSI). */
+#define SIGUSR1 16 /* User-defined signal 1 (POSIX). */
+#define SIGUSR2 17 /* User-defined signal 2 (POSIX). */
+#define SIGCHLD 18 /* Child status has changed (POSIX). */
+#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */
+#define SIGPWR 19 /* Power failure restart (System V). */
+#define SIGWINCH 20 /* Window size change (4.3 BSD, Sun). */
+#define SIGURG 21 /* Urgent condition on socket (4.2 BSD).*/
+#define SIGPOLL 22 /* Pollable event occurred (System V). */
+#define SIGIO SIGPOLL /* I/O now possible (4.2 BSD). */
+#define SIGSTOP 23 /* Stop, unblockable (POSIX). */
+#define SIGTSTP 24 /* Keyboard stop (POSIX). */
+#define SIGCONT 25 /* Continue (POSIX). */
+#define SIGTTIN 26 /* Background read from tty (POSIX). */
+#define SIGTTOU 27 /* Background write to tty (POSIX). */
+#define SIGVTALRM 28 /* Virtual alarm clock (4.2 BSD). */
+#define SIGPROF 29 /* Profiling alarm clock (4.2 BSD). */
+#define SIGXCPU 30 /* CPU limit exceeded (4.2 BSD). */
+#define SIGXFSZ 31 /* File size limit exceeded (4.2 BSD). */
+/* The following signals are new in Solaris 2. */
+#define SIGWAITING 32 /* Process's lwps are blocked. */
+#define SIGLWP 33 /* Special signal used by thread library. */
+#define SIGFREEZE 34 /* Special signal used by CPR. */
+#define SIGTHAW 35 /* Special signal used by CPR. */
+#define _SIGRTMIN 36 /* First (highest-priority) realtime signal. */
+#define _SIGRTMAX 43 /* Last (lowest-priority) realtime signal. */
+
+#endif /* <signal.h> included. */
+
+#define _NSIG 44 /* Biggest signal number + 1. */
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/sparc/Dist b/sysdeps/unix/sysv/sysv4/solaris2/sparc/Dist
new file mode 100644
index 0000000..69d16ac
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/solaris2/sparc/Dist
@@ -0,0 +1 @@
+sys-sig.S
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile b/sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile
new file mode 100644
index 0000000..7ad4bb1
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile
@@ -0,0 +1,5 @@
+# This flag is necessary because GCC now tries to call _Q_{mul, etc...}
+# instead of doing the stuff the hard way. For now, printf_fp.o, __vfscanf.o,
+# and difftime.o don't work because of this. The long-term fix is to actually
+# implement what they're doing, but for the short-term, we must do this.
+sysdep-CFLAGS := $(sysdep-CFLAGS) -mhard-quad-float
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/sparc/start.c b/sysdeps/unix/sysv/sysv4/solaris2/sparc/start.c
new file mode 100644
index 0000000..afdfaaa
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/solaris2/sparc/start.c
@@ -0,0 +1,4 @@
+#define NO_SHLIB
+/* Solaris needs start named `_start', not `start'. */
+#define NO_EXPLICIT_START
+#include <sysdeps/unix/sparc/start.c>
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/sparc/sys-sig.S b/sysdeps/unix/sysv/sysv4/solaris2/sparc/sys-sig.S
new file mode 100644
index 0000000..8baa997
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/solaris2/sparc/sys-sig.S
@@ -0,0 +1,25 @@
+/* Copyright (C) 1994 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. */
+
+#include <sysdep.h>
+
+PSEUDO (__sigaction_syscall, sigaction, 3)
+ ret
+
+PSEUDO (__context_syscall, context, 2)
+ ret
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.S b/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.S
new file mode 100644
index 0000000..da3cd6b
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.S
@@ -0,0 +1,46 @@
+/* Copyright (C) 1993, 1994 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. */
+
+#include <sysdep.h>
+#define _ERRNO_H
+#include <errnos.h>
+
+ENTRY(syscall_error)
+ /* If it was a syscall that got interrupted, but can
+ be restarted, drop EINTR in. */
+ cmp %o0, ERESTART
+ be,a notint
+ mov EINTR, %o0
+
+notint:
+#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
+ /* We translate the system's EWOULDBLOCK error into EAGAIN.
+ The GNU C library always defines EWOULDBLOCK==EAGAIN.
+ EWOULDBLOCK_sys is the original number. */
+ cmp %o0, EWOULDBLOCK_sys
+ be,a notblock
+ mov EAGAIN, %o0
+#endif
+
+notblock:/* Store it in errno... */
+ sethi %hi(C_SYMBOL_NAME(errno)), %g1
+ st %o0, [%g1 + %lo(C_SYMBOL_NAME(errno))]
+
+ /* And just kick back a -1. */
+ retl
+ mov -1, %o0
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h b/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h
new file mode 100644
index 0000000..edb9830
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h
@@ -0,0 +1,51 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+/* Solaris 2 does not precede the asm names of C symbols with a `_'. */
+#define NO_UNDERSCORES
+
+#include <sysdeps/unix/sysdep.h>
+
+#ifdef ASSEMBLER
+
+/* As of gcc-2.6.0, it complains about pound signs in front of things
+ that aren't arguments to the macro. So we use this to pull it off
+ instead. */
+#define cat(a,b) a##b
+#define poundfnc cat(#,function)
+
+#define ENTRY(name) \
+ .section ".text"; \
+ .align 4; \
+ .global C_SYMBOL_NAME(name); \
+ .type C_SYMBOL_NAME(name), poundfnc; \
+ C_LABEL(name)
+
+#define PSEUDO(name, syscall_name, args) \
+ ENTRY (name) \
+ mov SYS_ify(syscall_name), %g1; \
+ ta 8; \
+ bcs C_SYMBOL_NAME(syscall_error); \
+ nop
+
+#define ret retl; nop
+#define r0 %o0
+#define r1 %o1
+#define MOVE(x,y) mov x, y
+
+#endif /* ASSEMBLER */
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/statbuf.h b/sysdeps/unix/sysv/sysv4/solaris2/statbuf.h
new file mode 100644
index 0000000..ac74cdf
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/solaris2/statbuf.h
@@ -0,0 +1,82 @@
+/* Copyright (C) 1993 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. */
+
+#ifndef _STATBUF_H
+#define _STATBUF_H
+
+#include <gnu/types.h>
+
+/* Structure describing file characteristics. */
+struct stat
+ {
+ unsigned long int st_dev;
+ long st_filler1[3];
+ __ino_t st_ino; /* File serial number. */
+ unsigned long int st_mode; /* File mode. */
+ /* This is unsigned long instead of __nlink_t, since SVR4 has
+ a long nlink_t, not a short one. */
+ unsigned long int st_nlink; /* Link count. */
+ __uid_t st_uid; /* User ID of the file's owner. */
+ __gid_t st_gid; /* Group ID of the file's group.*/
+ unsigned long int st_rdev; /* Device number, if device. */
+ long st_filler2[2];
+
+ __off_t st_size; /* Size of file, in bytes. */
+ /* SVR4 added this extra long to allow for expansion of off_t. */
+ long st_filler3;
+
+ __time_t st_atime; /* Time of last access. */
+ unsigned long int st_atime_usec;
+ __time_t st_mtime; /* Time of last modification. */
+ unsigned long int st_mtime_usec;
+ __time_t st_ctime; /* Time of last status change. */
+ unsigned long int st_ctime_usec;
+
+ long st_blksize; /* Optimal block size for I/O. */
+#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
+
+ long st_blocks; /* Number of 512-byte blocks allocated. */
+ char st_fstype[16];
+ long st_filler4[8];
+ };
+
+/* Encoding of the file mode. */
+
+#define __S_IFMT 0170000 /* These bits determine file type. */
+
+/* File types. */
+#define __S_IFDIR 0040000 /* Directory. */
+#define __S_IFCHR 0020000 /* Character device. */
+#define __S_IFBLK 0060000 /* Block device. */
+#define __S_IFREG 0100000 /* Regular file. */
+#define __S_IFIFO 0010000 /* FIFO. */
+
+/* These don't actually exist on System V, but having them doesn't hurt. */
+#define __S_IFLNK 0120000 /* Symbolic link. */
+#define __S_IFSOCK 0140000 /* Socket. */
+
+/* Protection bits. */
+
+#define __S_ISUID 04000 /* Set user ID on execution. */
+#define __S_ISGID 02000 /* Set group ID on execution. */
+#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
+#define __S_IREAD 0400 /* Read by owner. */
+#define __S_IWRITE 0200 /* Write by owner. */
+#define __S_IEXEC 0100 /* Execute by owner. */
+
+#endif /* statbuf.h */
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/utimes.S b/sysdeps/unix/sysv/sysv4/solaris2/utimes.S
new file mode 100644
index 0000000..54a043c
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/solaris2/utimes.S
@@ -0,0 +1,2 @@
+/* Solaris has the BSD `utimes' function. */
+#include <sysdeps/unix/bsd/utimes.S>
diff --git a/sysdeps/unix/sysv/sysv4/sysconf.c b/sysdeps/unix/sysv/sysv4/sysconf.c
new file mode 100644
index 0000000..607cd05
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/sysconf.c
@@ -0,0 +1,181 @@
+/* Copyright (C) 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <limits.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <time.h>
+#include <sysconfig.h>
+
+extern int EXFUN(__sysconfig, (int));
+
+/* Get the value of the system variable NAME. */
+long int
+DEFUN(__sysconf, (name), int name)
+{
+ switch (name)
+ {
+ default:
+ errno = EINVAL;
+ return -1;
+
+ case _SC_ARG_MAX:
+#ifdef ARG_MAX
+ return ARG_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_CHILD_MAX:
+#ifdef CHILD_MAX
+ return CHILD_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_CLK_TCK:
+ return __sysconfig (_CONFIG_CLK_TCK);
+
+ case _SC_NGROUPS_MAX:
+#ifdef NGROUPS_MAX
+ return NGROUPS_MAX;
+#else
+ return -1;
+#endif
+
+ /* Both of these are looking for _CONFIG_OPEN_FILES. */
+ case _SC_OPEN_MAX:
+ case _SC_STREAM_MAX:
+ return __sysconfig (_CONFIG_OPEN_FILES);
+
+ case _SC_TZNAME_MAX:
+ return __tzname_max ();
+
+ case _SC_JOB_CONTROL:
+#ifdef _POSIX_JOB_CONTROL
+ return 1;
+#else
+ return -1;
+#endif
+ case _SC_SAVED_IDS:
+#ifdef _POSIX_SAVED_IDS
+ return 1;
+#else
+ return -1;
+#endif
+ case _SC_VERSION:
+ return _POSIX_VERSION;
+
+ case _SC_PAGESIZE:
+ return __sysconfig (_CONFIG_PAGESIZE);
+
+ case _SC_BC_BASE_MAX:
+#ifdef BC_BASE_MAX
+ return BC_BASE_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_BC_DIM_MAX:
+#ifdef BC_DIM_MAX
+ return BC_DIM_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_BC_SCALE_MAX:
+#ifdef BC_SCALE_MAX
+ return BC_SCALE_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_BC_STRING_MAX:
+#ifdef BC_STRING_MAX
+ return BC_STRING_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_EQUIV_CLASS_MAX:
+#ifdef EQUIV_CLASS_MAX
+ return EQUIV_CLASS_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_EXPR_NEST_MAX:
+#ifdef EXPR_NEST_MAX
+ return EXPR_NEST_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_LINE_MAX:
+#ifdef LINE_MAX
+ return LINE_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_RE_DUP_MAX:
+#ifdef RE_DUP_MAX
+ return RE_DUP_MAX;
+#else
+ return -1;
+#endif
+
+
+ case _SC_2_VERSION:
+ /* This is actually supposed to return the version
+ of the 1003.2 utilities on the system {POSIX2_VERSION}. */
+ return _POSIX2_C_VERSION;
+
+ case _SC_2_C_BIND:
+#ifdef _POSIX2_C_BIND
+ return _POSIX2_C_BIND;
+#else
+ return -1;
+#endif
+
+ case _SC_2_C_DEV:
+#ifdef _POSIX2_C_DEV
+ return _POSIX2_C_DEV;
+#else
+ return -1;
+#endif
+
+ case _SC_2_FORT_DEV:
+#ifdef _POSIX2_FORT_DEV
+ return _POSIX2_FORT_DEV;
+#else
+ return -1;
+#endif
+
+ case _SC_2_SW_DEV:
+#ifdef _POSIX2_SW_DEV
+ return _POSIX2_SW_DEV;
+#else
+ return -1;
+#endif
+ }
+}
+
+weak_alias (__sysconf, sysconf)
diff --git a/sysdeps/unix/sysv/sysv4/sysconfig.S b/sysdeps/unix/sysv/sysv4/sysconfig.S
new file mode 100644
index 0000000..034e012
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/sysconfig.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1993 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (sysconfig, 1)
+ ret
diff --git a/sysdeps/unix/sysv/sysv4/sysconfig.h b/sysdeps/unix/sysv/sysv4/sysconfig.h
new file mode 100644
index 0000000..77c84c7
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/sysconfig.h
@@ -0,0 +1,28 @@
+/* `__sysconfig' NAME values.
+ Copyright (C) 1993 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. */
+
+#ifndef __SYSCONFIG_H
+#define __SYSCONFIG_H
+
+#define _CONFIG_OPEN_FILES 4 /* process limit on open files */
+#define _CONFIG_PAGESIZE 6 /* MMU page size */
+#define _CONFIG_CLK_TCK 7 /* all times are in CLK_TCKths of a second */
+
+#endif
+
diff --git a/sysdeps/unix/sysv/sysv4/sysinfo.S b/sysdeps/unix/sysv/sysv4/sysinfo.S
new file mode 100644
index 0000000..c279c96
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/sysinfo.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1994 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. */
+
+#include <sysdep.h>
+
+PSEUDO (__sysinfo, systeminfo, 3)
+ ret
diff --git a/sysdeps/unix/sysv/sysv4/system.c b/sysdeps/unix/sysv/sysv4/system.c
new file mode 100644
index 0000000..fbfe43f
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/system.c
@@ -0,0 +1,2 @@
+/* SVR4 does have `waitpid'. Avoid unix/system.c, which says we don't. */
+#include <sysdeps/posix/system.c>
diff --git a/sysdeps/unix/sysv/sysv4/time.S b/sysdeps/unix/sysv/sysv4/time.S
new file mode 100644
index 0000000..61f3514
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/time.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1993 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. */
+
+#include <sysdep.h>
+
+SYSCALL (time, 1)
+ ret
diff --git a/sysdeps/unix/sysv/sysv4/utsnamelen.h b/sysdeps/unix/sysv/sysv4/utsnamelen.h
new file mode 100644
index 0000000..9dcc618
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/utsnamelen.h
@@ -0,0 +1 @@
+#define _UTSNAME_LENGTH 257
diff --git a/sysdeps/unix/sysv/sysv4/waitflags.h b/sysdeps/unix/sysv/sysv4/waitflags.h
new file mode 100644
index 0000000..cdb6f29
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/waitflags.h
@@ -0,0 +1,34 @@
+/* Definitions of flag bits for `waitpid' et al.
+ Copyright (C) 1993 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. */
+
+#ifndef _WAITFLAGS_H
+
+#define _WAITFLAGS_H 1
+
+/* Bits in the third argument to `waitpid'. */
+#define WNOHANG 64 /* Don't block waiting. */
+#define WUNTRACED 4 /* Report status of stopped children. */
+
+#ifdef __USE_SVID
+#define WEXITED 1 /* Look for children that have exited. */
+#define WTRAPPED 2 /* Look for processes that stopped
+ while tracing. */
+#endif
+
+#endif /* waitflags.h */
diff --git a/sysdeps/unix/sysv/sysv4/waitpid.c b/sysdeps/unix/sysv/sysv4/waitpid.c
new file mode 100644
index 0000000..f54df4b
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv4/waitpid.c
@@ -0,0 +1,120 @@
+/* Copyright (C) 1993, 1994, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <stddef.h>
+#include "siginfo.h"
+
+typedef enum __idtype
+ {
+ /* Look for processes based upon a given PID. */
+ P_PID,
+
+ /* Look for processes based upon a given process-group ID. */
+ P_PGID = 2,
+
+ /* Look for any process. */
+ P_ALL = 7,
+ } __idtype_t;
+
+extern __pid_t __getpgid __P ((__pid_t pid));
+extern int __waitid __P ((__idtype_t idtype, __pid_t id,
+ __siginfo_t *infop, int options));
+
+/* Wait for a child matching PID to die.
+ If PID is greater than 0, match any process whose process ID is PID.
+ If PID is (pid_t) -1, match any process.
+ If PID is (pid_t) 0, match any process with the
+ same process group as the current process.
+ If PID is less than -1, match any process whose
+ process group is the absolute value of PID.
+ If the WNOHANG bit is set in OPTIONS, and that child
+ is not already dead, return (pid_t) 0. If successful,
+ return PID and store the dead child's status in STAT_LOC.
+ Return (pid_t) -1 for errors. If the WUNTRACED bit is set in OPTIONS,
+ return status for stopped children; otherwise don't. */
+
+__pid_t
+DEFUN(__waitpid, (pid, stat_loc, options),
+ __pid_t pid AND int *stat_loc AND int options)
+{
+ __idtype_t idtype;
+ __pid_t tmp_pid = pid;
+ __siginfo_t infop;
+
+ if (pid <= WAIT_MYPGRP)
+ {
+ if (pid == WAIT_ANY)
+ {
+ /* Request the status for any child. */
+ idtype = P_ALL;
+ }
+ else if (pid == WAIT_MYPGRP)
+ {
+ /* Request the status for any child process that has
+ a pgid that's equal to that of our parent. */
+ tmp_pid = __getpgid (0);
+ idtype = P_PGID;
+ }
+ else /* PID < -1 */
+ {
+ /* Request the status for any child whose pgid is equal
+ to the absolute value of PID. */
+ tmp_pid = pid & ~0; /* XXX not pseudo-insn */
+ idtype = P_PGID;
+ }
+ }
+ else
+ {
+ /* Request the status for the child whose pid is PID. */
+ idtype = P_PID;
+ }
+
+ if (__waitid (idtype, tmp_pid, &infop, options | WEXITED | WTRAPPED) < 0)
+ return -1;
+
+ switch (infop.__code)
+ {
+ case EXITED:
+ *stat_loc = W_EXITCODE (infop.__status, 0);
+ break;
+ case STOPPED:
+ case TRAPPED:
+ *stat_loc = W_STOPCODE (infop.__status);
+ break;
+ case KILLED:
+ /* Don't know what to do with continue, since it isn't documented.
+ Putting it here seemed the right place though. */
+ case CONTINUED:
+ *stat_loc = infop.__status;
+ /* FALLTHROUGH */
+ case CORED:
+ *stat_loc |= WCOREFLAG;
+ break;
+ }
+
+ /* Return the PID out of the INFOP structure instead of the one we were
+ called with, to account for cases of being called with -1 to signify
+ any PID. */
+ return infop.__pid;
+}
+
+weak_alias (__waitpid, waitpid)
diff --git a/sysdeps/unix/sysv/sysv_termio.h b/sysdeps/unix/sysv/sysv_termio.h
new file mode 100644
index 0000000..c1c5d72
--- /dev/null
+++ b/sysdeps/unix/sysv/sysv_termio.h
@@ -0,0 +1,155 @@
+/* Copyright (C) 1992 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. */
+
+/* In various parts of this file we define the System V values for
+ things as _SYSV_<whatever>. Those are the values that System V
+ uses for termio, and also (SVR4) termios. Not necessarily the
+ same as the GNU termios that the library user sees. */
+
+/* Number of elements of c_cc. termio only. */
+#define _SYSV_NCC 8
+
+#define _SYSV_VINTR 0
+#define _SYSV_VQUIT 1
+#define _SYSV_VERASE 2
+#define _SYSV_VKILL 3
+#define _SYSV_VEOF 4
+/* This field means VEOF if ICANON, VMIN if not. */
+#define _SYSV_VMIN 4
+#define _SYSV_VEOL 5
+/* This field means VEOL if ICANON, VTIME if not. */
+#define _SYSV_VTIME 5
+#define _SYSV_VEOL2 6
+
+/* Flags in c_iflag. */
+#define _SYSV_IGNBRK 1
+#define _SYSV_BRKINT 2
+#define _SYSV_IGNPAR 4
+#define _SYSV_PARMRK 8
+#define _SYSV_INPCK 0x10
+#define _SYSV_ISTRIP 0x20
+#define _SYSV_INLCR 0x40
+#define _SYSV_IGNCR 0x80
+#define _SYSV_ICRNL 0x100
+#define _SYSV_IUCLC 0x200
+#define _SYSV_IXON 0x400
+#define _SYSV_IXANY 0x800
+#define _SYSV_IXOFF 0x1000
+#define _SYSV_IMAXBEL 0x2000
+
+/* Flags in c_cflag. */
+#define _SYSV_CBAUD 0xf
+#define _SYSV_CIBAUD 0xf0000 /* termios only. */
+#define _SYSV_IBSHIFT 16
+/* Values for CBAUD and CIBAUD. */
+#define _SYSV_B0 0
+#define _SYSV_B50 1
+#define _SYSV_B75 2
+#define _SYSV_B110 3
+#define _SYSV_B134 4
+#define _SYSV_B150 5
+#define _SYSV_B200 6
+#define _SYSV_B300 7
+#define _SYSV_B600 8
+#define _SYSV_B1200 9
+#define _SYSV_B1800 10
+#define _SYSV_B2400 11
+#define _SYSV_B4800 12
+#define _SYSV_B9600 13
+#define _SYSV_B19200 14
+#define _SYSV_B38400 15
+
+#define _SYSV_CS5 0
+#define _SYSV_CS6 0x10
+#define _SYSV_CS7 0x20
+#define _SYSV_CS8 0x30
+#define _SYSV_CSIZE 0x30
+#define _SYSV_CSTOPB 0x40
+#define _SYSV_CREAD 0x80
+#define _SYSV_PARENB 0x100
+#define _SYSV_PARODD 0x200
+#define _SYSV_HUPCL 0x400
+#define _SYSV_CLOCAL 0x800
+
+/* Flags in c_lflag. */
+#define _SYSV_ISIG 1
+#define _SYSV_ICANON 2
+#define _SYSV_ECHO 8
+#define _SYSV_ECHOE 0x10
+#define _SYSV_ECHOK 0x20
+#define _SYSV_ECHONL 0x40
+#define _SYSV_NOFLSH 0x80
+#define _SYSV_TOSTOP 0x100
+#define _SYSV_ECHOCTL 0x200
+#define _SYSV_ECHOPRT 0x400
+#define _SYSV_ECHOKE 0x800
+#define _SYSV_FLUSHO 0x2000
+#define _SYSV_PENDIN 0x4000
+#define _SYSV_IEXTEN 0x8000
+
+/* Flags in c_oflag. */
+#define _SYSV_OPOST 1
+#define _SYSV_OLCUC 2
+#define _SYSV_ONLCR 4
+#define _SYSV_NLDLY 0x100
+#define _SYSV_NL0 0
+#define _SYSV_NL1 0x100
+#define _SYSV_CRDLY 0x600
+#define _SYSV_CR0 0
+#define _SYSV_CR1 0x200
+#define _SYSV_CR2 0x400
+#define _SYSV_CR3 0x600
+#define _SYSV_TABDLY 0x1800
+#define _SYSV_TAB0 0
+#define _SYSV_TAB1 0x0800
+#define _SYSV_TAB2 0x1000
+/* TAB3 is an obsolete name for XTABS. But we provide it since some
+ programs expect it to exist. */
+#define _SYSV_TAB3 0x1800
+#define _SYSV_XTABS 0x1800
+#define _SYSV_BSDLY 0x2000
+#define _SYSV_BS0 0
+#define _SYSV_BS1 0x2000
+#define _SYSV_VTDLY 0x4000
+#define _SYSV_VT0 0
+#define _SYSV_VT1 0x4000
+#define _SYSV_FFDLY 0x8000
+#define _SYSV_FF0 0
+#define _SYSV_FF1 0x8000
+
+/* ioctl's. */
+
+#define _TCGETA 0x5401
+#define _TCSETA 0x5402
+#define _TCSETAW 0x5403
+#define _TCSETAF 0x5404
+#define _TCSBRK 0x5405
+#define _TCXONC 0x5406
+#define _TCFLSH 0x5407
+#define _TIOCGPGRP 0x7414
+#define _TIOCSPGRP 0x7415
+
+struct __sysv_termio
+ {
+ unsigned short c_iflag;
+ unsigned short c_oflag;
+ unsigned short c_cflag;
+ unsigned short c_lflag;
+ char c_line;
+ unsigned char c_cc[_SYSV_NCC];
+ };
diff --git a/sysdeps/unix/sysv/tcdrain.c b/sysdeps/unix/sysv/tcdrain.c
new file mode 100644
index 0000000..3714479
--- /dev/null
+++ b/sysdeps/unix/sysv/tcdrain.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <termios.h>
+#include <unistd.h>
+#include <sysv_termio.h>
+#include <sys/ioctl.h>
+
+/* Wait for pending output to be written on FD. */
+int
+DEFUN(tcdrain, (fd), int fd)
+{
+ /* With an argument of 1, TCSBRK just waits for output to drain. */
+ return __ioctl (fd, _TCSBRK, 1);
+}
diff --git a/sysdeps/unix/sysv/tcflow.c b/sysdeps/unix/sysv/tcflow.c
new file mode 100644
index 0000000..fecb40d
--- /dev/null
+++ b/sysdeps/unix/sysv/tcflow.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <termios.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+
+#include "sysv_termio.h"
+
+/* Suspend or restart transmission on FD. */
+int
+DEFUN(tcflow, (fd, action), int fd AND int action)
+{
+ switch (action)
+ {
+ case TCOOFF:
+ return __ioctl (fd, _TCXONC, 0);
+ case TCOON:
+ return __ioctl (fd, _TCXONC, 1);
+ case TCIOFF:
+ return __ioctl (fd, _TCXONC, 2);
+ case TCION:
+ return __ioctl (fd, _TCXONC, 3);
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+}
diff --git a/sysdeps/unix/sysv/tcflush.c b/sysdeps/unix/sysv/tcflush.c
new file mode 100644
index 0000000..88574a5
--- /dev/null
+++ b/sysdeps/unix/sysv/tcflush.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <termios.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+
+#include <sysv_termio.h>
+
+/* Flush pending data on FD. */
+int
+DEFUN(tcflush, (fd, queue_selector), int fd AND int queue_selector)
+{
+ switch (queue_selector)
+ {
+ case TCIFLUSH:
+ return __ioctl (fd, _TCFLSH, 0);
+ case TCOFLUSH:
+ return __ioctl (fd, _TCFLSH, 1);
+ case TCIOFLUSH:
+ return __ioctl (fd, _TCFLSH, 2);
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+}
diff --git a/sysdeps/unix/sysv/tcgetattr.c b/sysdeps/unix/sysv/tcgetattr.c
new file mode 100644
index 0000000..dd914a2
--- /dev/null
+++ b/sysdeps/unix/sysv/tcgetattr.c
@@ -0,0 +1,171 @@
+/* Copyright (C) 1992, 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <sysv_termio.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+/* Put the state of FD into *TERMIOS_P. */
+int
+DEFUN(__tcgetattr, (fd, termios_p),
+ int fd AND struct termios *termios_p)
+{
+ struct __sysv_termio buf;
+ int termio_speed;
+
+ if (termios_p == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (__ioctl (fd, _TCGETA, &buf) < 0)
+ return -1;
+
+ termio_speed = buf.c_cflag & _SYSV_CBAUD;
+ termios_p->__ospeed =
+ (termio_speed == _SYSV_B0 ? 0 :
+ termio_speed == _SYSV_B50 ? 50 :
+ termio_speed == _SYSV_B75 ? 75 :
+ termio_speed == _SYSV_B110 ? 110 :
+ termio_speed == _SYSV_B134 ? 134 :
+ termio_speed == _SYSV_B150 ? 150 :
+ termio_speed == _SYSV_B200 ? 200 :
+ termio_speed == _SYSV_B300 ? 300 :
+ termio_speed == _SYSV_B600 ? 600 :
+ termio_speed == _SYSV_B1200 ? 1200 :
+ termio_speed == _SYSV_B1800 ? 1800 :
+ termio_speed == _SYSV_B2400 ? 2400 :
+ termio_speed == _SYSV_B4800 ? 4800 :
+ termio_speed == _SYSV_B9600 ? 9600 :
+ termio_speed == _SYSV_B19200 ? 19200 :
+ termio_speed == _SYSV_B38400 ? 38400 :
+ -1);
+ termios_p->__ispeed = termios_p->__ospeed;
+
+ termios_p->c_iflag = 0;
+ if (buf.c_iflag & _SYSV_IGNBRK)
+ termios_p->c_iflag |= IGNBRK;
+ if (buf.c_iflag & _SYSV_BRKINT)
+ termios_p->c_iflag |= BRKINT;
+ if (buf.c_iflag & _SYSV_IGNPAR)
+ termios_p->c_iflag |= IGNPAR;
+ if (buf.c_iflag & _SYSV_PARMRK)
+ termios_p->c_iflag |= PARMRK;
+ if (buf.c_iflag & _SYSV_INPCK)
+ termios_p->c_iflag |= INPCK;
+ if (buf.c_iflag & _SYSV_ISTRIP)
+ termios_p->c_iflag |= ISTRIP;
+ if (buf.c_iflag & _SYSV_INLCR)
+ termios_p->c_iflag |= INLCR;
+ if (buf.c_iflag & _SYSV_IGNCR)
+ termios_p->c_iflag |= IGNCR;
+ if (buf.c_iflag & _SYSV_ICRNL)
+ termios_p->c_iflag |= ICRNL;
+ if (buf.c_iflag & _SYSV_IXON)
+ termios_p->c_iflag |= IXON;
+ if (buf.c_iflag & _SYSV_IXOFF)
+ termios_p->c_iflag |= IXOFF;
+ if (buf.c_iflag & _SYSV_IXANY)
+ termios_p->c_iflag |= IXANY;
+ if (buf.c_iflag & _SYSV_IMAXBEL)
+ termios_p->c_iflag |= IMAXBEL;
+
+ termios_p->c_oflag = 0;
+ if (buf.c_oflag & OPOST)
+ termios_p->c_oflag |= OPOST;
+ if (buf.c_oflag & ONLCR)
+ termios_p->c_oflag |= ONLCR;
+ termios_p->c_cflag = 0;
+ switch (buf.c_cflag & _SYSV_CSIZE)
+ {
+ case _SYSV_CS5:
+ termios_p->c_cflag |= CS5;
+ break;
+ case _SYSV_CS6:
+ termios_p->c_cflag |= CS6;
+ break;
+ case _SYSV_CS7:
+ termios_p->c_cflag |= CS7;
+ break;
+ case _SYSV_CS8:
+ termios_p->c_cflag |= CS8;
+ break;
+ }
+ if (buf.c_cflag & _SYSV_CSTOPB)
+ termios_p->c_cflag |= CSTOPB;
+ if (buf.c_cflag & _SYSV_CREAD)
+ termios_p->c_cflag |= CREAD;
+ if (buf.c_cflag & _SYSV_PARENB)
+ termios_p->c_cflag |= PARENB;
+ if (buf.c_cflag & _SYSV_PARODD)
+ termios_p->c_cflag |= PARODD;
+ if (buf.c_cflag & _SYSV_HUPCL)
+ termios_p->c_cflag |= HUPCL;
+ if (buf.c_cflag & _SYSV_CLOCAL)
+ termios_p->c_cflag |= CLOCAL;
+ termios_p->c_lflag = 0;
+ if (buf.c_lflag & _SYSV_ISIG)
+ termios_p->c_lflag |= _ISIG;
+ if (buf.c_lflag & _SYSV_ICANON)
+ termios_p->c_lflag |= _ICANON;
+ if (buf.c_lflag & _SYSV_ECHO)
+ termios_p->c_lflag |= _ECHO;
+ if (buf.c_lflag & _SYSV_ECHOE)
+ termios_p->c_lflag |= _ECHOE;
+ if (buf.c_lflag & _SYSV_ECHOK)
+ termios_p->c_lflag |= _ECHOK;
+ if (buf.c_lflag & _SYSV_ECHONL)
+ termios_p->c_lflag |= _ECHONL;
+ if (buf.c_lflag & _SYSV_NOFLSH)
+ termios_p->c_lflag |= _NOFLSH;
+ if (buf.c_lflag & _SYSV_TOSTOP)
+ termios_p->c_lflag |= _TOSTOP;
+ if (buf.c_lflag & _SYSV_ECHOKE)
+ termios_p->c_lflag |= ECHOKE;
+ if (buf.c_lflag & _SYSV_ECHOPRT)
+ termios_p->c_lflag |= ECHOPRT;
+ if (buf.c_lflag & _SYSV_ECHOCTL)
+ termios_p->c_lflag |= ECHOCTL;
+ if (buf.c_lflag & _SYSV_FLUSHO)
+ termios_p->c_lflag |= FLUSHO;
+ if (buf.c_lflag & _SYSV_PENDIN)
+ termios_p->c_lflag |= PENDIN;
+ if (buf.c_lflag & _SYSV_IEXTEN)
+ termios_p->c_lflag |= IEXTEN;
+
+ termios_p->c_cc[VEOF] = buf.c_cc[_SYSV_VEOF];
+ termios_p->c_cc[VEOL] = buf.c_cc[_SYSV_VEOL];
+ termios_p->c_cc[VEOL2] = buf.c_cc[_SYSV_VEOL2];
+ termios_p->c_cc[VERASE] = buf.c_cc[_SYSV_VERASE];
+ termios_p->c_cc[VKILL] = buf.c_cc[_SYSV_VKILL];
+ termios_p->c_cc[VINTR] = buf.c_cc[_SYSV_VINTR];
+ termios_p->c_cc[VQUIT] = buf.c_cc[_SYSV_VQUIT];
+ termios_p->c_cc[VSTART] = '\021'; /* XON (^Q). */
+ termios_p->c_cc[VSTOP] = '\023'; /* XOFF (^S). */
+ termios_p->c_cc[VSUSP] = '\0'; /* System V release 3 lacks job control. */
+ termios_p->c_cc[VMIN] = buf.c_cc[_SYSV_VMIN];
+ termios_p->c_cc[VTIME] = buf.c_cc[_SYSV_VTIME];
+
+ return 0;
+}
+
+weak_alias (__tcgetattr, tcgetattr)
diff --git a/sysdeps/unix/sysv/tcgetpgrp.c b/sysdeps/unix/sysv/tcgetpgrp.c
new file mode 100644
index 0000000..d4c4722
--- /dev/null
+++ b/sysdeps/unix/sysv/tcgetpgrp.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <termios.h>
+#include <sysv_termio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+/* Return the foreground process group ID of FD. */
+pid_t
+DEFUN(tcgetpgrp, (fd), int fd)
+{
+ int pgrp;
+ if (__ioctl(fd, _TIOCGPGRP, &pgrp) < 0)
+ return (pid_t) -1;
+ return (pid_t) pgrp;
+}
diff --git a/sysdeps/unix/sysv/tcsendbrk.c b/sysdeps/unix/sysv/tcsendbrk.c
new file mode 100644
index 0000000..78fe2c5
--- /dev/null
+++ b/sysdeps/unix/sysv/tcsendbrk.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <signal.h>
+#include <termios.h>
+#include <unistd.h>
+#include <sysv_termio.h>
+#include <sys/ioctl.h>
+
+/* Send zero bits on FD. */
+int
+DEFUN(tcsendbreak, (fd, duration), int fd AND int duration)
+{
+ /* The break lasts 0.25 to 0.5 seconds if DURATION is zero,
+ and an implementation-defined period if DURATION is nonzero.
+ We define a positive DURATION to be number of milliseconds to break. */
+ if (duration <= 0)
+ return __ioctl (fd, _TCSBRK, 0);
+
+ /* ioctl can't send a break of any other duration for us.
+ This could be changed to use trickery (e.g. lower speed and
+ send a '\0') to send the break, but for now just return an error. */
+ errno = EINVAL;
+ return -1;
+}
diff --git a/sysdeps/unix/sysv/tcsetattr.c b/sysdeps/unix/sysv/tcsetattr.c
new file mode 100644
index 0000000..30e1b0b
--- /dev/null
+++ b/sysdeps/unix/sysv/tcsetattr.c
@@ -0,0 +1,208 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+#include <sysv_termio.h>
+
+
+CONST speed_t __unix_speeds[] =
+ {
+ 0,
+ 50,
+ 75,
+ 110,
+ 134,
+ 150,
+ 200,
+ 300,
+ 600,
+ 1200,
+ 1800,
+ 2400,
+ 4800,
+ 9600,
+ 19200,
+ 38400,
+ };
+
+
+/* Set the state of FD to *TERMIOS_P. */
+int
+DEFUN(tcsetattr, (fd, optional_actions, termios_p),
+ int fd AND int optional_actions AND CONST struct termios *termios_p)
+{
+ struct __sysv_termio buf;
+ int ioctl_function;
+ size_t i;
+
+ if (termios_p == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ switch (optional_actions)
+ {
+ case TCSANOW:
+ ioctl_function = _TCSETA;
+ break;
+ case TCSADRAIN:
+ ioctl_function = _TCSETAW;
+ break;
+ case TCSAFLUSH:
+ ioctl_function = _TCSETAF;
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (termios_p->__ispeed != termios_p->__ospeed)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ buf.c_cflag = -1;
+ for (i = 0; i <= sizeof (__unix_speeds) / sizeof (__unix_speeds[0]); ++i)
+ {
+ if (__unix_speeds[i] == termios_p->__ispeed)
+ buf.c_cflag = i;
+ }
+ if (buf.c_cflag == -1)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ buf.c_iflag = 0;
+ if (termios_p->c_iflag & IGNBRK)
+ buf.c_iflag |= _SYSV_IGNBRK;
+ if (termios_p->c_iflag & BRKINT)
+ buf.c_iflag |= _SYSV_BRKINT;
+ if (termios_p->c_iflag & IGNPAR)
+ buf.c_iflag |= _SYSV_IGNPAR;
+ if (termios_p->c_iflag & PARMRK)
+ buf.c_iflag |= _SYSV_PARMRK;
+ if (termios_p->c_iflag & INPCK)
+ buf.c_iflag |= _SYSV_INPCK;
+ if (termios_p->c_iflag & ISTRIP)
+ buf.c_iflag |= _SYSV_ISTRIP;
+ if (termios_p->c_iflag & INLCR)
+ buf.c_iflag |= _SYSV_INLCR;
+ if (termios_p->c_iflag & IGNCR)
+ buf.c_iflag |= _SYSV_IGNCR;
+ if (termios_p->c_iflag & ICRNL)
+ buf.c_iflag |= _SYSV_ICRNL;
+ if (termios_p->c_iflag & IXON)
+ buf.c_iflag |= _SYSV_IXON;
+ if (termios_p->c_iflag & IXOFF)
+ buf.c_iflag |= _SYSV_IXOFF;
+ if (termios_p->c_iflag & IXANY)
+ buf.c_iflag |= _SYSV_IXANY;
+ if (termios_p->c_iflag & IMAXBEL)
+ buf.c_iflag |= _SYSV_IMAXBEL;
+
+ buf.c_oflag = 0;
+ if (termios_p->c_oflag & OPOST)
+ buf.c_oflag = _SYSV_OPOST;
+ if (termios_p->c_oflag & ONLCR)
+ buf.c_oflag = _SYSV_ONLCR;
+
+ /* So far, buf.c_cflag contains the speed in CBAUD. */
+ if (termios_p->c_cflag & CSTOPB)
+ buf.c_cflag |= _SYSV_CSTOPB;
+ if (termios_p->c_cflag & CREAD)
+ buf.c_cflag |= _SYSV_CREAD;
+ if (termios_p->c_cflag & PARENB)
+ buf.c_cflag |= _SYSV_PARENB;
+ if (termios_p->c_cflag & PARODD)
+ buf.c_cflag |= _SYSV_PARODD;
+ if (termios_p->c_cflag & HUPCL)
+ buf.c_cflag |= _SYSV_HUPCL;
+ if (termios_p->c_cflag & CLOCAL)
+ buf.c_cflag |= _SYSV_CLOCAL;
+ switch (termios_p->c_cflag & CSIZE)
+ {
+ case CS5:
+ buf.c_cflag |= _SYSV_CS5;
+ break;
+ case CS6:
+ buf.c_cflag |= _SYSV_CS6;
+ break;
+ case CS7:
+ buf.c_cflag |= _SYSV_CS7;
+ break;
+ case CS8:
+ buf.c_cflag |= _SYSV_CS8;
+ break;
+ }
+
+ buf.c_lflag = 0;
+ if (termios_p->c_lflag & ISIG)
+ buf.c_lflag |= _SYSV_ISIG;
+ if (termios_p->c_lflag & ICANON)
+ buf.c_lflag |= _SYSV_ICANON;
+ if (termios_p->c_lflag & ECHO)
+ buf.c_lflag |= _SYSV_ECHO;
+ if (termios_p->c_lflag & ECHOE)
+ buf.c_lflag |= _SYSV_ECHOE;
+ if (termios_p->c_lflag & ECHOK)
+ buf.c_lflag |= _SYSV_ECHOK;
+ if (termios_p->c_lflag & ECHONL)
+ buf.c_lflag |= _SYSV_ECHONL;
+ if (termios_p->c_lflag & NOFLSH)
+ buf.c_lflag |= _SYSV_NOFLSH;
+ if (termios_p->c_lflag & TOSTOP)
+ buf.c_lflag |= _SYSV_TOSTOP;
+ if (termios_p->c_lflag & ECHOCTL)
+ buf.c_lflag |= _SYSV_ECHOCTL;
+ if (termios_p->c_lflag & ECHOPRT)
+ buf.c_lflag |= _SYSV_ECHOPRT;
+ if (termios_p->c_lflag & ECHOKE)
+ buf.c_lflag |= _SYSV_ECHOKE;
+ if (termios_p->c_lflag & FLUSHO)
+ buf.c_lflag |= _SYSV_FLUSHO;
+ if (termios_p->c_lflag & PENDIN)
+ buf.c_lflag |= _SYSV_PENDIN;
+ if (termios_p->c_lflag & IEXTEN)
+ buf.c_lflag |= _SYSV_IEXTEN;
+
+ buf.c_cc[_SYSV_VINTR] = termios_p->c_cc[VINTR];
+ buf.c_cc[_SYSV_VQUIT] = termios_p->c_cc[VQUIT];
+ buf.c_cc[_SYSV_VERASE] = termios_p->c_cc[VERASE];
+ buf.c_cc[_SYSV_VKILL] = termios_p->c_cc[VKILL];
+ if (buf.c_lflag & _SYSV_ICANON)
+ {
+ buf.c_cc[_SYSV_VEOF] = termios_p->c_cc[VEOF];
+ buf.c_cc[_SYSV_VEOL] = termios_p->c_cc[VEOL];
+ }
+ else
+ {
+ buf.c_cc[_SYSV_VMIN] = termios_p->c_cc[VMIN];
+ buf.c_cc[_SYSV_VTIME] = termios_p->c_cc[VTIME];
+ }
+ buf.c_cc[_SYSV_VEOL2] = termios_p->c_cc[VEOL2];
+
+ if (__ioctl (fd, ioctl_function, &buf) < 0)
+ return -1;
+ return 0;
+}
diff --git a/sysdeps/unix/sysv/tcsetpgrp.c b/sysdeps/unix/sysv/tcsetpgrp.c
new file mode 100644
index 0000000..da83f3b
--- /dev/null
+++ b/sysdeps/unix/sysv/tcsetpgrp.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1992 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. */
+
+#include <ansidecl.h>
+#include <sys/types.h>
+#include <sysv_termio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+
+/* Set the foreground process group ID of FD set PGRP_ID. */
+int
+DEFUN(tcsetpgrp, (fd, pgrp_id), int fd AND pid_t pgrp_id)
+{
+ return __ioctl (fd, _TIOCSPGRP, &pgrp_id);
+}
diff --git a/sysdeps/unix/sysv/times.S b/sysdeps/unix/sysv/times.S
new file mode 100644
index 0000000..c2bb168
--- /dev/null
+++ b/sysdeps/unix/sysv/times.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (times, 1)
+ ret
+
+weak_alias (__times, times)
diff --git a/sysdeps/unix/sysv/ulimit.S b/sysdeps/unix/sysv/ulimit.S
new file mode 100644
index 0000000..1bc6dc9
--- /dev/null
+++ b/sysdeps/unix/sysv/ulimit.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991, 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (ulimit, 2)
+ ret
diff --git a/sysdeps/unix/sysv/uname.S b/sysdeps/unix/sysv/uname.S
new file mode 100644
index 0000000..ab4879f
--- /dev/null
+++ b/sysdeps/unix/sysv/uname.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (uname, 1)
+ ret
diff --git a/sysdeps/unix/sysv/utime.S b/sysdeps/unix/sysv/utime.S
new file mode 100644
index 0000000..e24db03
--- /dev/null
+++ b/sysdeps/unix/sysv/utime.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1992 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. */
+
+#include <sysdep.h>
+
+SYSCALL (utime, 2)
+ ret
diff --git a/sysdeps/unix/sysv/utmp.h b/sysdeps/unix/sysv/utmp.h
new file mode 100644
index 0000000..4c3d33e
--- /dev/null
+++ b/sysdeps/unix/sysv/utmp.h
@@ -0,0 +1,23 @@
+#ifndef _UTMP_H
+
+#define _UTMP_H 1
+
+#include <time.h>
+
+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;
+ };
+
+#endif /* utmp.h. */
diff --git a/sysdeps/unix/sysv/utsnamelen.h b/sysdeps/unix/sysv/utsnamelen.h
new file mode 100644
index 0000000..31473cf
--- /dev/null
+++ b/sysdeps/unix/sysv/utsnamelen.h
@@ -0,0 +1 @@
+#define _UTSNAME_LENGTH 9
diff --git a/sysdeps/unix/telldir.c b/sysdeps/unix/telldir.c
new file mode 100644
index 0000000..c473bbc
--- /dev/null
+++ b/sysdeps/unix/telldir.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <stddef.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* Return the current position of DIRP. */
+off_t
+DEFUN(telldir, (dirp), DIR *dirp)
+{
+ register off_t pos;
+
+ if (dirp == NULL)
+ {
+ errno = EINVAL;
+ return (off_t) -1;
+ }
+
+ pos = __lseek(dirp->__fd, (off_t) 0, SEEK_CUR);
+ if (pos == (off_t) -1)
+ return (off_t) -1;
+ return pos + (dirp->__size - dirp->__offset);
+}
diff --git a/sysdeps/unix/umask.S b/sysdeps/unix/umask.S
new file mode 100644
index 0000000..bb2b899
--- /dev/null
+++ b/sysdeps/unix/umask.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (umask, 1)
+ ret
+
+weak_alias (__umask, umask)
diff --git a/sysdeps/unix/unlink.S b/sysdeps/unix/unlink.S
new file mode 100644
index 0000000..8f496ce
--- /dev/null
+++ b/sysdeps/unix/unlink.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (unlink, 1)
+ ret
+
+weak_alias (__unlink, unlink)
diff --git a/sysdeps/unix/write.S b/sysdeps/unix/write.S
new file mode 100644
index 0000000..881d127
--- /dev/null
+++ b/sysdeps/unix/write.S
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <sysdep.h>
+
+SYSCALL__ (write, 3)
+ ret
+
+weak_alias (__write, write)
diff --git a/sysdeps/vax/DEFS.h b/sysdeps/vax/DEFS.h
new file mode 100644
index 0000000..01f1f0c
--- /dev/null
+++ b/sysdeps/vax/DEFS.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 1982, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)DEFS.h 8.1 (Berkeley) 6/4/93
+ */
+
+#define R0 0x001
+#define R1 0x002
+#define R2 0x004
+#define R3 0x008
+#define R4 0x010
+#define R5 0x020
+#define R6 0x040
+#define R7 0x080
+#define R8 0x100
+#define R9 0x200
+#define R10 0x400
+#define R11 0x800
+
+#ifdef PROF
+#define ENTRY(x, regs) \
+ .globl _/**/x; .align 2; _/**/x: .word regs; \
+ .data; 1:; .long 0; .text; moval 1b,r0; jsb mcount
+#define ASENTRY(x, regs) \
+ .globl x; .align 2; x: .word regs; \
+ .data; 1:; .long 0; .text; moval 1b,r0; jsb mcount
+#else
+#define ENTRY(x, regs) \
+ .globl _/**/x; .align 2; _/**/x: .word regs
+#define ASENTRY(x, regs) \
+ .globl x; .align 2; x: .word regs
+#endif
diff --git a/sysdeps/vax/Dist b/sysdeps/vax/Dist
new file mode 100644
index 0000000..9830be2
--- /dev/null
+++ b/sysdeps/vax/Dist
@@ -0,0 +1 @@
+DEFS.h
diff --git a/sysdeps/vax/Makefile b/sysdeps/vax/Makefile
new file mode 100644
index 0000000..a6149a9
--- /dev/null
+++ b/sysdeps/vax/Makefile
@@ -0,0 +1,32 @@
+# 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.
+
+ifeq ($(subdir),math)
+ifndef math-twiddled
+
+elided-routines := $(elided-routines) acos asin cos sin ceil rint hypot \
+ __copysign __scalb __drem __logb __finite
+sysdep_routines := $(sysdep_routines) asincos sincos argred \
+ support exp__E log__L
+
+math-twiddled := t
+endif
+
+bsdmath_dirs := $(bsdmath_dirs) vax
+
+endif
diff --git a/sysdeps/vax/__longjmp.c b/sysdeps/vax/__longjmp.c
new file mode 100644
index 0000000..0ee040a
--- /dev/null
+++ b/sysdeps/vax/__longjmp.c
@@ -0,0 +1,100 @@
+/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc.
+ Derived from @(#)_setjmp.s 5.7 (Berkeley) 6/27/88,
+ Copyright (c) 1980 Regents of the University of California.
+
+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. */
+
+#include <ansidecl.h>
+#include <setjmp.h>
+
+#ifndef __GNUC__
+ #error This file uses GNU C extensions; you must compile with GCC.
+#endif
+
+
+#define REI 02 /* Vax `rei' opcode. */
+
+/* Jump to the position specified by ENV, causing the
+ setjmp call there to return VAL, or 1 if VAL is 0. */
+__NORETURN
+void
+DEFUN(__longjmp, (env, val), CONST __jmp_buf env AND int val)
+{
+ register long int *fp asm("fp");
+ long int *regsave;
+ unsigned long int flags;
+
+ if (env.__fp == NULL)
+ __libc_fatal("longjmp: Invalid ENV argument.\n");
+
+ if (val == 0)
+ val = 1;
+
+ asm volatile("loop:");
+
+ flags = *(long int *) (6 + (char *) fp);
+ regsave = (long int *) (20 + (char *) fp);
+ if (flags & 1)
+ /* R0 was saved by the caller.
+ Store VAL where it will be restored from. */
+ *regsave++ = val;
+ if (flags & 2)
+ /* R1 was saved by the caller.
+ Store ENV where it will be restored from. */
+ *regsave = env;
+
+ /* Was the FP saved in the last call the same one in ENV? */
+ asm volatile("cmpl %0, 12(fp);"
+ /* Yes, return to it. */
+ "beql done;"
+ /* The FP in ENV is less than the one saved in the last call.
+ This means we have already returned from the function that
+ called `setjmp' with ENV! */
+ "blssu latejump;" : /* No outputs. */ : "g" (env.__fp));
+
+ /* We are more than one level below the state in ENV.
+ Return to where we will pop another stack frame. */
+ asm volatile("movl $loop, 16(fp);"
+ "ret");
+
+ asm volatile("done:");
+ {
+ char return_insn asm("*16(fp)");
+ if (return_insn == REI)
+ /* We're returning with an `rei' instruction.
+ Do a return with PSL-PC pop. */
+ asm volatile("movab 0f, 16(fp)");
+ else
+ /* Do a standard return. */
+ asm volatile("movab 1f, 16(fp)");
+
+ /* Return. */
+ asm volatile("ret");
+ }
+
+ asm volatile("0:" /* `rei' return. */
+ /* Compensate for PSL-PC push. */
+ "addl2 %0, sp;"
+ "1:" /* Standard return. */
+ /* Return to saved PC. */
+ "jmp %1" : /* No outputs. */ :
+ "g" (8), "g" (env.__pc));
+
+ /* Jump here when the FP saved in ENV points
+ to a function that has already returned. */
+ asm volatile("latejump:");
+ __libc_fatal("longjmp: Attempt to jump to a function that has returned.\n");
+}
diff --git a/sysdeps/vax/bcmp.s b/sysdeps/vax/bcmp.s
new file mode 100644
index 0000000..d980feb
--- /dev/null
+++ b/sysdeps/vax/bcmp.s
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)bcmp.s 5.6 (Berkeley) 6/1/90"
+#endif /* LIBC_SCCS and not lint */
+
+/* bcmp(s1, s2, n) */
+
+#include "DEFS.h"
+
+ENTRY(bcmp, 0)
+ movl 4(ap),r1
+ movl 8(ap),r3
+ movl 12(ap),r4
+1:
+ movzwl $65535,r0
+ cmpl r4,r0
+ jleq 2f
+ subl2 r0,r4
+ cmpc3 r0,(r1),(r3)
+ jeql 1b
+ addl2 r4,r0
+ ret
+2:
+ cmpc3 r4,(r1),(r3)
+ ret
diff --git a/sysdeps/vax/bcopy.s b/sysdeps/vax/bcopy.s
new file mode 100644
index 0000000..43bb93d
--- /dev/null
+++ b/sysdeps/vax/bcopy.s
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)bcopy.s 5.6 (Berkeley) 6/1/90"
+#endif /* LIBC_SCCS and not lint */
+
+/* bcopy(from, to, size) */
+
+#include "DEFS.h"
+
+ENTRY(bcopy, R6)
+ movl 4(ap),r1
+ movl 8(ap),r3
+ movl 12(ap),r6
+ cmpl r1,r3
+ bgtr 2f # normal forward case
+ blss 3f # overlapping, must do backwards
+ ret # equal, nothing to do
+1:
+ subl2 r0,r6
+ movc3 r0,(r1),(r3)
+2:
+ movzwl $65535,r0
+ cmpl r6,r0
+ jgtr 1b
+ movc3 r6,(r1),(r3)
+ ret
+3:
+ addl2 r6,r1
+ addl2 r6,r3
+ movzwl $65535,r0
+ jbr 5f
+4:
+ subl2 r0,r6
+ subl2 r0,r1
+ subl2 r0,r3
+ movc3 r0,(r1),(r3)
+ movzwl $65535,r0
+ subl2 r0,r1
+ subl2 r0,r3
+5:
+ cmpl r6,r0
+ jgtr 4b
+ subl2 r6,r1
+ subl2 r6,r3
+ movc3 r6,(r1),(r3)
+ ret
diff --git a/sysdeps/vax/bsd-_setjmp.S b/sysdeps/vax/bsd-_setjmp.S
new file mode 100644
index 0000000..039fd71
--- /dev/null
+++ b/sysdeps/vax/bsd-_setjmp.S
@@ -0,0 +1,32 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. Vax 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. */
+
+/* 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>
+
+ENTRY (setjmp)
+ popl r0 /* Pop return PC. */
+ popl r1 /* Pop jmp_buf argument. */
+ pushl $0 /* Push second argument of zero. */
+ pushl r1 /* Push back first argument. */
+ pushl r0 /* Push back return PC. */
+ jmp C_SYMBOL_NAME (__sigsetjmp)
diff --git a/sysdeps/vax/bsd-setjmp.S b/sysdeps/vax/bsd-setjmp.S
new file mode 100644
index 0000000..379a65c
--- /dev/null
+++ b/sysdeps/vax/bsd-setjmp.S
@@ -0,0 +1,32 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. Vax 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. */
+
+/* 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>
+
+ENTRY (setjmp)
+ popl r0 /* Pop return PC. */
+ popl r1 /* Pop jmp_buf argument. */
+ pushl $1 /* Push second argument of one. */
+ pushl r1 /* Push back first argument. */
+ pushl r0 /* Push back return PC. */
+ jmp C_SYMBOL_NAME (__sigsetjmp)
diff --git a/sysdeps/vax/bzero.s b/sysdeps/vax/bzero.s
new file mode 100644
index 0000000..5f90763
--- /dev/null
+++ b/sysdeps/vax/bzero.s
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)bzero.s 5.6 (Berkeley) 6/1/90"
+#endif /* LIBC_SCCS and not lint */
+
+/* bzero(base, length) */
+
+#include "DEFS.h"
+
+ENTRY(bzero, 0)
+ movl 4(ap),r3
+ jbr 2f
+1:
+ subl2 r0,8(ap)
+ movc5 $0,(r3),$0,r0,(r3)
+2:
+ movzwl $65535,r0
+ cmpl 8(ap),r0
+ jgtr 1b
+ movc5 $0,(r3),$0,8(ap),(r3)
+ ret
diff --git a/sysdeps/vax/ffs.s b/sysdeps/vax/ffs.s
new file mode 100644
index 0000000..49faffb
--- /dev/null
+++ b/sysdeps/vax/ffs.s
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)ffs.s 5.6 (Berkeley) 6/1/90"
+#endif /* LIBC_SCCS and not lint */
+
+/* bit = ffs(value) */
+
+#include "DEFS.h"
+
+ENTRY(ffs, 0)
+ ffs $0,$32,4(ap),r0
+ bneq 1f
+ mnegl $1,r0
+1:
+ incl r0
+ ret
diff --git a/sysdeps/vax/fl.h b/sysdeps/vax/fl.h
new file mode 100644
index 0000000..49e7456
--- /dev/null
+++ b/sysdeps/vax/fl.h
@@ -0,0 +1,68 @@
+/* Copyright (C) 1991 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 __need_HUGE_VAL
+
+/* Floating-point constants for Vaxen. */
+
+#define FLT_RADIX 2
+
+#define FLT_ROUNDS _FLT_ROUNDS_TONEAREST
+
+#define FLT_MANT_DIG 23
+#define DBL_MANT_DIG 55
+#define LDBL_MANT_DIG 55
+
+#define FLT_DIG 6
+#define DBL_DIG 16
+#define LDBL_DIG 16
+
+#define FLT_MIN_EXP (-128)
+#define DBL_MIN_EXP (-128)
+#define LDBL_MIN_EXP (-128)
+
+#define FLT_MIN_10_EXP (-38)
+#define DBL_MIN_10_EXP (-38)
+#define LDBL_MIN_10_EXP (-38)
+
+#define FLT_MAX_EXP 127
+#define DBL_MAX_EXP 127
+#define LDBL_MAX_EXP 127
+
+#define FLT_MAX_10_EXP 38
+#define DBL_MAX_10_EXP 38
+#define LDBL_MAX_10_EXP 38
+
+#define FLT_MAX 1.7014116e38
+#define DBL_MAX 1.70141182460469227e38
+#define LDBL_MAX DBL_MAX
+
+#define FLT_EPSILON 2.384186e-7
+#define DBL_EPSILON 5.55111512312578270e-17
+#define LDBL_EPSILON DBL_EPSILON
+
+#define FLT_MIN 0.2938736e-38
+#define DBL_MIN 0.29387358770557187e-38
+#define LDBL_MIN DBL_MIN
+
+#else /* Need HUGE_VAL. */
+
+/* Used by <stdlib.h> and <math.h> functions for overflow. */
+#define HUGE_VAL 1.70141182460469227e38
+
+#endif /* Don't need HUGE_VAL. */
diff --git a/sysdeps/vax/htonl.s b/sysdeps/vax/htonl.s
new file mode 100644
index 0000000..af5b96c
--- /dev/null
+++ b/sysdeps/vax/htonl.s
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)htonl.s 5.5 (Berkeley) 6/27/88"
+#endif /* LIBC_SCCS and not lint */
+
+/* netorder = htonl(hostorder) */
+
+#include "DEFS.h"
+
+ENTRY(htonl, 0)
+ rotl $-8,4(ap),r0
+ insv r0,$16,$8,r0
+ movb 7(ap),r0
+ ret
diff --git a/sysdeps/vax/htons.s b/sysdeps/vax/htons.s
new file mode 100644
index 0000000..c500e84
--- /dev/null
+++ b/sysdeps/vax/htons.s
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)htons.s 5.5 (Berkeley) 6/27/88"
+#endif /* LIBC_SCCS and not lint */
+
+/* hostorder = htons(netorder) */
+
+#include "DEFS.h"
+
+ENTRY(htons, 0)
+ rotl $8,4(ap),r0
+ movb 5(ap),r0
+ movzwl r0,r0
+ ret
diff --git a/sysdeps/vax/huge_val.h b/sysdeps/vax/huge_val.h
new file mode 100644
index 0000000..58f5415
--- /dev/null
+++ b/sysdeps/vax/huge_val.h
@@ -0,0 +1,27 @@
+/* `HUGE_VAL' constant for Vaxen.
+ Used by <stdlib.h> and <math.h> functions for overflow.
+
+Copyright (C) 1992 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 _HUGE_VAL_H
+#define _HUGE_VAL_H 1
+
+#define HUGE_VAL 1.70141182460469227e38
+
+#endif /* huge_val.h */
diff --git a/sysdeps/vax/index.s b/sysdeps/vax/index.s
new file mode 100644
index 0000000..e599b27
--- /dev/null
+++ b/sysdeps/vax/index.s
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)index.s 5.6 (Berkeley) 6/1/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Find the first occurence of c in the string cp.
+ * Return pointer to match or null pointer.
+ *
+ * char *
+ * index(cp, c)
+ * char *cp, c;
+ */
+#include "DEFS.h"
+
+ENTRY(index, 0)
+ movq 4(ap),r1 # r1 = cp; r2 = c
+ tstl r2 # check for special case c == '\0'
+ bneq 2f
+1:
+ locc $0,$65535,(r1) # just find end of string
+ beql 1b # still looking
+ movl r1,r0 # found it
+ ret
+2:
+ moval tbl,r3 # r3 = address of table
+ bbss $0,(r3),5f # insure not reentering
+ movab (r3)[r2],r5 # table entry for c
+ incb (r5)
+ movzwl $65535,r4 # fast access
+3:
+ scanc r4,(r1),(r3),$1 # look for c or '\0'
+ beql 3b # still looking
+ movl r1,r0 # return pointer to char
+ tstb (r0) # if have found '\0'
+ bneq 4f
+ clrl r0 # else return 0
+4:
+ clrb (r5) # clean up table
+ clrb (r3)
+ ret
+
+ .data
+tbl: .space 256
+ .text
+
+/*
+ * Reentrant, but slower version of index
+ */
+5:
+ movl r1,r3
+6:
+ locc $0,$65535,(r3) # look for '\0'
+ bneq 7f
+ locc r2,$65535,(r3) # look for c
+ bneq 8f
+ movl r1,r3 # reset pointer and ...
+ jbr 6b # ... try again
+7:
+ subl3 r3,r1,r4 # length of short block
+ incl r4 # +1 for '\0'
+ locc r2,r4,(r3) # look for c
+ bneq 8f
+ ret
+8:
+ movl r1,r0 # return pointer to char
+ ret
diff --git a/sysdeps/vax/infnan.c b/sysdeps/vax/infnan.c
new file mode 100644
index 0000000..62ec9dc
--- /dev/null
+++ b/sysdeps/vax/infnan.c
@@ -0,0 +1,62 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#ifndef __GNUC__
+ #error This file uses GNU C extensions; you must compile with GCC.
+#else
+
+#include <ansidecl.h>
+#include <errno.h>
+#include <math.h>
+
+/* Deal with an infinite or NaN result.
+ If ERROR is ERANGE, result is +Inf;
+ if ERROR is - ERANGE, result is -Inf;
+ otherwise result is NaN.
+ This will set `errno' to either ERANGE or EDOM,
+ and may return an infinity or NaN, or may do something else. */
+double
+DEFUN(__infnan, (error), int error)
+{
+ switch (error)
+ {
+ case ERANGE:
+ errno = ERANGE;
+ break;
+
+ case - ERANGE:
+ errno = ERANGE;
+ break;
+
+ default:
+ errno = EDOM;
+ break;
+ }
+
+ /* Trigger a reserved operand fault. */
+ {
+ double result;
+ asm volatile("emodd %1, %1, %2, %0, %0" : "=r" (result) :
+ "i" (0), "i" (0x8000));
+ return result;
+ }
+}
+
+#endif
+
+weak_alias (__infnan, infnan)
diff --git a/sysdeps/vax/jmp_buf.h b/sysdeps/vax/jmp_buf.h
new file mode 100644
index 0000000..7adecd9
--- /dev/null
+++ b/sysdeps/vax/jmp_buf.h
@@ -0,0 +1,7 @@
+/* Define the machine-dependent type `jmp_buf'. Vax version. */
+
+typedef struct
+ {
+ PTR __fp;
+ PTR __pc;
+ } __jmp_buf[1];
diff --git a/sysdeps/vax/log10.c b/sysdeps/vax/log10.c
new file mode 100644
index 0000000..0874177
--- /dev/null
+++ b/sysdeps/vax/log10.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1991 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. */
+
+#include <ansidecl.h>
+
+#ifndef FPCONST
+#define FPCONST(hi0, lo0, hi1, lo1) { (lo0), (hi0), (lo1), (hi1) }
+#endif
+
+static CONST short int ln10[] = FPCONST(0x4113, 0x5d8d, 0xddaa, 0xa8ac);
+#define LN10 (*(CONST double *) ln10)
+
+#include <../sysdeps/generic/log10.c>
diff --git a/sysdeps/vax/memccpy.c b/sysdeps/vax/memccpy.c
new file mode 100644
index 0000000..9849761
--- /dev/null
+++ b/sysdeps/vax/memccpy.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991, 1992, 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. */
+
+#include <ansidecl.h>
+#include <string.h>
+
+
+/* Copy no more than N bytes of SRC to DEST, stopping when C is found.
+ Return the position in DEST one byte past where C was copied,
+ or NULL if C was not found in the first N bytes of SRC. */
+PTR
+DEFUN(__memccpy, (dest, src, c, n),
+ PTR dest AND CONST PTR src AND int c AND size_t nbytes)
+{
+ /* Except when N > 65535, this is what a hand-coded version would
+ do anyway. */
+
+ PTR found = memchr (src, c, n);
+
+ if (found == NULL)
+ {
+ (void) memcpy (dest, src, n);
+ return NULL;
+ }
+
+ (void) memcpy (dest, src, (char *) found + 1 - (char *) src);
+ return (PTR) ((char *) dest + ((char *) found + 1 - (char *) src));
+}
+
+weak_alias (__memccpy, memccpy)
diff --git a/sysdeps/vax/memchr.s b/sysdeps/vax/memchr.s
new file mode 100644
index 0000000..c7793fb
--- /dev/null
+++ b/sysdeps/vax/memchr.s
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)memchr.s 5.1 (Berkeley) 5/29/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Find the first occurence of c in the memory at cp (length n).
+ * Return pointer to match or null pointer.
+ *
+ * This code optimises the usual case (0 < n < 65535).
+ *
+ * void *
+ * memchr(cp, c, n)
+ * char *cp, c;
+ * size_t n;
+ */
+
+#include "DEFS.h"
+
+ENTRY(memchr, 0)
+ movq 4(ap),r1 # r1 = cp; r2 = c
+ movl 12(ap),r0 # r0 = n
+ movzwl $65535,r4 # handy constant
+0:
+ cmpl r0,r4 # check for annoying locc limit
+ bgtru 3f
+
+ /* n <= 65535 */
+ locc r2,r0,(r1) # search n bytes for c
+ beql 2f # done if not found (r0 already 0)
+1: /* found character c at (r1) */
+ movl r1,r0
+2:
+ ret
+
+3: /* n > 65535 */
+ locc r2,r4,(r1) # search 65535 bytes for c
+ beql 1b # done if found
+ decw r0 # from 0 to 65535
+ subl2 r0,r4 # adjust n
+ brb 0b # and loop
diff --git a/sysdeps/vax/memcmp.s b/sysdeps/vax/memcmp.s
new file mode 100644
index 0000000..3854fd8
--- /dev/null
+++ b/sysdeps/vax/memcmp.s
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)memcmp.s 5.1 (Berkeley) 5/15/90"
+#endif /* LIBC_SCCS and not lint */
+
+/* int memcmp(s1, s2, n) */
+
+#include "DEFS.h"
+
+ENTRY(memcmp, 0)
+ movl 4(ap),r1 /* r1 = s1 */
+ movq 8(ap),r3 /* r3 = s2; r4 = n */
+ movzwl $65535,r5
+0:
+ cmpl r4,r5
+ jgtru 3f /* handle stupid cmpc3 limitation */
+ cmpc3 r4,(r1),(r3) /* compare */
+ beql 2f /* done if same (r0 = 0) */
+1:
+ movzbl (r1),r0
+ movzbl (r3),r2
+ subl2 r2,r0 /* return *s1 - *s2; s1,s2 unsigned chars */
+2:
+ ret
+3:
+ subl2 r5,r4 /* do 64K; adjust count */
+ cmpc3 r5,(r1),(r3)
+ jeql 0b /* loop if same */
+ jbr 1b
diff --git a/sysdeps/vax/memmove.s b/sysdeps/vax/memmove.s
new file mode 100644
index 0000000..8f897fa
--- /dev/null
+++ b/sysdeps/vax/memmove.s
@@ -0,0 +1,93 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)memmove.s 5.1 (Berkeley) 5/15/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * void *memmove(dst, src, size)
+ * returns dst
+ *
+ * This optimises the usual case (count < 65536) at the expense
+ * of some extra memory references and branches when count >= 65536.
+ */
+
+#include "DEFS.h"
+
+ENTRY(memmove, 0)
+ movzwl $65535,r0 /* r0 = 64K (needed below) */
+ movq 8(ap),r1 /* r1 = src, r2 = length */
+ movl 4(ap),r3 /* r3 = dst */
+ cmpl r1,r3
+ bgtru 1f /* normal forward case */
+ beql 2f /* equal, nothing to do */
+ addl2 r2,r1 /* overlaps iff src<dst but src+len>dst */
+ cmpl r1,r3
+ bgtru 4f /* overlapping, must move backwards */
+ subl2 r2,r1
+
+1: /* move forward */
+ cmpl r2,r0
+ bgtru 3f /* stupid movc3 limitation */
+ movc3 r2,(r1),(r3) /* move it all */
+2:
+ movl 4(ap),r0 /* return original dst */
+ ret
+3:
+ subl2 r0,12(ap) /* adjust length by 64K */
+ movc3 r0,(r1),(r3) /* move 64K */
+ movl 12(ap),r2
+ decw r0 /* from 0 to 65535 */
+ brb 1b /* retry */
+
+4: /* move backward */
+ addl2 r2,r3
+5:
+ cmpl r2,r0
+ bgtru 6f /* stupid movc3 limitation */
+ subl2 r2,r1
+ subl2 r2,r3
+ movc3 r2,(r1),(r3) /* move it all */
+ movl 4(ap),r0 /* return original dst */
+ ret
+6:
+ subl2 r0,12(ap) /* adjust length by 64K */
+ subl2 r0,r1
+ subl2 r0,r3
+ movc3 r0,(r1),(r3) /* move 64K */
+ movl 12(ap),r2
+ decw r0
+ subl2 r0,r1
+ subl2 r0,r3
+ brb 5b
diff --git a/sysdeps/vax/memset.s b/sysdeps/vax/memset.s
new file mode 100644
index 0000000..12b1f74
--- /dev/null
+++ b/sysdeps/vax/memset.s
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)memset.s 5.2 (Berkeley) 5/12/91"
+#endif /* LIBC_SCCS and not lint */
+
+/* void *memset(base, c, length) */
+
+#include "DEFS.h"
+
+ENTRY(memset, 0)
+ movl 4(ap),r3
+1:
+ movzwl $65535,r0
+ movq 8(ap),r1
+ cmpl r2,r0
+ jgtru 2f
+ movc5 $0,(r3),r1,r2,(r3)
+ movl r1,r0
+ ret
+2:
+ subl2 r0,12(ap)
+ movc5 $0,(r3),r1,r0,(r3)
+ jbr 1b
diff --git a/sysdeps/vax/ntohl.s b/sysdeps/vax/ntohl.s
new file mode 100644
index 0000000..0fcaa2f
--- /dev/null
+++ b/sysdeps/vax/ntohl.s
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)ntohl.s 5.5 (Berkeley) 6/27/88"
+#endif /* LIBC_SCCS and not lint */
+
+/* hostorder = ntohl(netorder) */
+
+#include "DEFS.h"
+
+ENTRY(ntohl, 0)
+ rotl $-8,4(ap),r0
+ insv r0,$16,$8,r0
+ movb 7(ap),r0
+ ret
diff --git a/sysdeps/vax/ntohs.s b/sysdeps/vax/ntohs.s
new file mode 100644
index 0000000..626a37b
--- /dev/null
+++ b/sysdeps/vax/ntohs.s
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)ntohs.s 5.5 (Berkeley) 6/27/88"
+#endif /* LIBC_SCCS and not lint */
+
+/* hostorder = ntohs(netorder) */
+
+#include "DEFS.h"
+
+ENTRY(ntohs, 0)
+ rotl $8,4(ap),r0
+ movb 5(ap),r0
+ movzwl r0,r0
+ ret
diff --git a/sysdeps/vax/rindex.s b/sysdeps/vax/rindex.s
new file mode 100644
index 0000000..76d7e29
--- /dev/null
+++ b/sysdeps/vax/rindex.s
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)rindex.s 5.6 (Berkeley) 6/1/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Find the last occurence of c in the string cp.
+ * Return pointer to match or null pointer.
+ *
+ * char *
+ * rindex(cp, c)
+ * char *cp, c;
+ */
+#include "DEFS.h"
+
+ENTRY(rindex, 0)
+ movq 4(ap),r1 # r1 = cp; r2 = c
+ tstl r2 # check for special case c == '\0'
+ bneq 2f
+1:
+ locc $0,$65535,(r1) # just find end of string
+ beql 1b # still looking
+ movl r1,r0 # found it
+ ret
+2:
+ moval tbl,r3 # r3 = address of table
+ bbss $0,(r3),5f # insure not reentering
+ movab (r3)[r2],r5 # table entry for c
+ incb (r5)
+ clrl r4 # last found
+3:
+ scanc $65535,(r1),(r3),$1 # look for c or '\0'
+ beql 3b # keep looking
+ tstb (r1) # if have found '\0'
+ beql 4f # we are done
+ movl r1,r4 # save most recently found
+ incl r1 # skip over character
+ jbr 3b # keep looking
+4:
+ movl r4,r0 # return last found (if any)
+ clrb (r5) # clean up table
+ clrb (r3)
+ ret
+
+ .data
+tbl: .space 256
+ .text
+
+/*
+ * Reentrant, but slower version of rindex
+ */
+5:
+ movl r1,r3
+ clrl r4 # r4 = pointer to last match
+6:
+ locc $0,$65535,(r3) # look for '\0'
+ bneq 8f
+ decw r0 # r0 = 65535
+1:
+ locc r2,r0,(r3) # look for c
+ bneq 7f
+ movl r1,r3 # reset pointer and ...
+ jbr 6b # ... try again
+7:
+ movl r1,r4 # stash pointer ...
+ addl3 $1,r1,r3 # ... skip over match and ...
+ decl r0 # ... decrement count
+ jbr 6b # ... try again
+8:
+ subl3 r3,r1,r0 # length of short block
+ incl r0 # +1 for '\0'
+9:
+ locc r2,r0,(r3) # look for c
+ beql 0f
+ movl r1,r4 # stash pointer ...
+ addl3 $1,r1,r3 # ... skip over match ...
+ decl r0 # ... adjust count and ...
+ jbr 9b # ... try again
+0:
+ movl r4,r0 # return stashed pointer
+ ret
diff --git a/sysdeps/vax/setjmp.c b/sysdeps/vax/setjmp.c
new file mode 100644
index 0000000..9d711cb
--- /dev/null
+++ b/sysdeps/vax/setjmp.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc.
+ Derived from @(#)_setjmp.s 5.7 (Berkeley) 6/27/88,
+ Copyright (c) 1980 Regents of the University of California.
+
+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. */
+
+#include <setjmp.h>
+
+
+/* Save the current program position in ENV and return 0. */
+int
+__sigsetjmp (jmp_buf env, int savemask)
+{
+ /* Save our caller's FP and PC. */
+ asm ("movl 12(fp), %0" : "=g" (env[0].__jmpbuf[0].__fp));
+ asm ("movl 16(fp), %0" : "=g" (env[0].__jmpbuf[0].__pc));
+
+ /* Save the signal mask if requested. */
+ return __sigjmp_save (env, savemask);
+}
diff --git a/sysdeps/vax/strcat.s b/sysdeps/vax/strcat.s
new file mode 100644
index 0000000..7cf8884
--- /dev/null
+++ b/sysdeps/vax/strcat.s
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)strcat.s 5.6 (Berkeley) 6/1/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Concatenate string s2 to the end of s1
+ * and return the base of s1.
+ *
+ * char *
+ * strcat(s1, s2)
+ * char *s1, *s2;
+ */
+#include "DEFS.h"
+
+ENTRY(strcat, R6|R7)
+ movq 4(ap), r6 # r6 = s1; r7 = s2
+ movl r6,r1
+0:
+ locc $0,$65535,(r1) # look for '\0'
+ beql 0b
+ movl r1,r3 # save end of s1
+1:
+ locc $0,$65535,(r7) # find length of s2
+ bneq 2f
+ movc3 $65535,(r7),(r3)# copy full block
+ movl r1,r7
+ jbr 1b
+2:
+ subl2 r7,r1 # calculate length
+ incl r1
+ movc3 r1,(r7),(r3) # copy remainder
+ movl r6,r0
+ ret
diff --git a/sysdeps/vax/strchr.s b/sysdeps/vax/strchr.s
new file mode 100644
index 0000000..18b5383
--- /dev/null
+++ b/sysdeps/vax/strchr.s
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)strchr.s 5.4 (Berkeley) 6/1/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Find the first occurence of c in the string cp.
+ * Return pointer to match or null pointer.
+ *
+ * char *
+ * strchr(cp, c)
+ * char *cp, c;
+ */
+#include "DEFS.h"
+
+ .lcomm tbl,256
+
+ENTRY(strchr, 0)
+ movzwl $65535,r4 /* handy constant */
+ movq 4(ap),r1 /* r1 = cp; r2 = c */
+ movzbl r2,r2
+ beql Lzero /* special case for c == '\0' */
+
+/*
+ * Fancy scanc version. Alas, it is not reentrant.
+ */
+ movab tbl,r3 /* r3 = base of table */
+ bbss $0,(r3),Lreent /* ensure not reentering */
+ movab (r3)[r2],r5
+ incb (r5) /* mark both '\0' and c */
+0:
+ scanc r4,(r1),(r3),$1 /* look for c or '\0' */
+ beql 0b /* still looking */
+ movl r1,r0 /* return whatever we found */
+ tstb (r0)
+ bneq 1f # unless it was '\0':
+ clrl r0 # then return NULL
+1:
+ clrb (r5) /* clean up table */
+ clrb (r3)
+ ret
+
+/*
+ * Special case for \0.
+ */
+Lzero:
+ locc r2,r4,(r1) /* just find end of string */
+ beql Lzero /* still looking */
+ movl r1,r0 /* found it */
+ ret
+
+/*
+ * Slower reentrant version is two two-step searches. The first
+ * phase runs until we know where the string ends; it locates the
+ * first occurrence of c within a 65535-byte block. If we find
+ * the end of the string first, we switch to the second phase,
+ * were we look only up to the known end of string.
+ */
+Lreent:
+0: /* first phase */
+ movl r1,r3
+ locc $0,r4,(r3) /* look for '\0' */
+ bneq 1f
+ locc r2,r4,(r3) /* look for c */
+ beql 0b /* not found: reset pointer and loop */
+ movl r1,r0 /* found: return it */
+ ret
+1: /* second phase */
+ subl3 r3,r1,r0 /* length of short block */
+ locc r2,r0,(r3) /* look for c */
+ beql 2f /* not found: return NULL */
+ movl r1,r0
+2: ret
diff --git a/sysdeps/vax/strcpy.s b/sysdeps/vax/strcpy.s
new file mode 100644
index 0000000..56dbe57
--- /dev/null
+++ b/sysdeps/vax/strcpy.s
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)strcpy.s 5.6 (Berkeley) 6/1/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Copy string s2 over top of s1.
+ * Return base of s1.
+ *
+ * char *
+ * strcpy(s1, s2)
+ * char *s1, *s2;
+ */
+#include "DEFS.h"
+
+ENTRY(strcpy, R6)
+ movl 4(ap), r3 # r3 = s1
+ movl 8(ap), r6 # r6 = s2
+1:
+ locc $0,$65535,(r6) # find length of s2
+ bneq 2f
+ movc3 $65535,(r6),(r3)# copy full block
+ movl r1,r6
+ jbr 1b
+2:
+ subl2 r6,r1 # calculate length
+ incl r1
+ movc3 r1,(r6),(r3) # copy remainder
+ movl 4(ap),r0 # return base of s1
+ ret
diff --git a/sysdeps/vax/strcspn.s b/sysdeps/vax/strcspn.s
new file mode 100644
index 0000000..f7b0a99
--- /dev/null
+++ b/sysdeps/vax/strcspn.s
@@ -0,0 +1,66 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)strcspn.s 5.1 (Berkeley) 5/15/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Span the complement of string s2 (skip characters that are not in s2).
+ * Return the number of characters in s1 that were skipped.
+ *
+ * size_t
+ * strcspn(s1, s2)
+ * const char *s1, *s2;
+ */
+#include "DEFS.h"
+
+ENTRY(strcspn, 0)
+ subl2 $32,sp /* make 256 bit table */
+ movc5 $0,(sp),$0,$32,(sp)
+ movq 4(ap),r1 /* r1 = s1, r2 = s2 */
+
+ /* turn on bit for each character in s2, including '\0' */
+1:
+ movzbl (r2)+,r0
+ bbss r0,(sp),1b
+ bneq 1b
+ movl r1,r0 /* r0 = s (current pos in s1) */
+
+ /* look for a character that is in s2 */
+2:
+ movzbl (r0)+,r2 /* c = *s++ */
+ bbc r2,(sp),2b /* loop until c is in table */
+ decl r0 /* s-- */
+ subl2 r1,r0 /* r0 = s - s1 = count */
+ ret
diff --git a/sysdeps/vax/strlen.s b/sysdeps/vax/strlen.s
new file mode 100644
index 0000000..2b7e0a7
--- /dev/null
+++ b/sysdeps/vax/strlen.s
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)strlen.s 5.6 (Berkeley) 6/1/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Return the length of cp (not counting '\0').
+ *
+ * strlen(cp)
+ * char *cp;
+ */
+#include "DEFS.h"
+
+ENTRY(strlen, 0)
+ movl 4(ap),r1
+1:
+ locc $0,$65535,(r1) # look for '\0'
+ beql 1b
+ subl3 4(ap),r1,r0 # len = cp - base
+ ret
diff --git a/sysdeps/vax/strncat.s b/sysdeps/vax/strncat.s
new file mode 100644
index 0000000..bcf29c1
--- /dev/null
+++ b/sysdeps/vax/strncat.s
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)strncat.s 5.6 (Berkeley) 6/1/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Concatenate string s2 on the end of s1
+ * and return the base of s1. The parameter
+ * n is the maximum length of string s2 to
+ * concatenate.
+ *
+ * char *
+ * strncat(s1, s2, n)
+ * char *s1, *s2;
+ * int n;
+ */
+#include "DEFS.h"
+
+ENTRY(strncat, R6)
+ movl 12(ap),r6 # r6 = n
+ bleq done # n <= 0
+ movl 4(ap),r3 # r3 = s1
+ movl r3,r1
+0:
+ locc $0,$65535,(r1)
+ beql 0b
+ movl r1,r3 # r3 = index(s1, '\0');
+ movl 8(ap),r1 # r1 = s2
+1:
+ movzwl $65535,r2 # r2 = bytes in first chunk
+ cmpl r6,r2 # r2 = min(bytes in chunk, n);
+ jgeq 2f
+ movl r6,r2
+2:
+ subl2 r2,r6 # update n
+ locc $0,r2,(r1) # '\0' found?
+ jneq 3f
+ subl2 r2,r1 # back up pointer updated by locc
+ movc3 r2,(r1),(r3) # copy in next piece
+ tstl r6 # run out of space?
+ jneq 1b
+ clrb (r3) # force '\0' termination
+ jbr done
+3:
+ subl2 r0,r2 # r2 = number of bytes to move
+ subl2 r2,r1 # back up pointer updated by locc
+ incl r2 # copy '\0' as well
+ movc3 r2,(r1),(r3) # copy in last piece
+done:
+ movl 4(ap),r0 # return s1
+ ret
diff --git a/sysdeps/vax/strncmp.s b/sysdeps/vax/strncmp.s
new file mode 100644
index 0000000..e5bfcf2
--- /dev/null
+++ b/sysdeps/vax/strncmp.s
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)strncmp.s 5.6 (Berkeley) 6/1/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Compare at most n characters of string
+ * s1 lexicographically to string s2.
+ * Return:
+ * 0 s1 == s2
+ * > 0 s1 > s2
+ * < 0 s2 < s2
+ *
+ * strncmp(s1, s2, n)
+ * char *s1, *s2;
+ * int n;
+ */
+#include "DEFS.h"
+
+ENTRY(strncmp, 0)
+ movl 4(ap),r1 # r1 = s1
+ movq 8(ap),r3 # r3 = s2; r4 = n
+1:
+ clrl r5 # calculate min bytes to next page boundry
+ subb3 r1,$255,r5 # r5 = (bytes - 1) to end of page for s1
+ subb3 r3,$255,r0 # r0 = (bytes - 1) to end of page for s2
+ cmpb r0,r5 # r5 = min(r0, r5);
+ bgtru 2f
+ movb r0,r5
+2:
+ incl r5 # r5 = min bytes to next page boundry
+ cmpl r4,r5 # r5 = min(n, r5);
+ bgeq 3f
+ movl r4,r5
+3:
+ cmpc3 r5,(r1),(r3) # compare strings
+ bneq 4f
+ subl2 r5,r4 # check for end of comparison
+ beql 5f
+ subl2 r5,r1 # check if found null yet
+ locc $0,r5,(r1)
+ beql 1b # not yet done, continue checking
+ subl2 r0,r3
+ mnegb (r3),r0 # r0 = '\0' - *s2
+ cvtbl r0,r0
+ ret
+4:
+ subl2 r0,r5 # check for null in matching string
+ subl2 r5,r1
+ locc $0,r5,(r1)
+ bneq 5f
+ subb3 (r3),(r1),r0 # r0 = *s1 - *s2
+ cvtbl r0,r0
+ ret
+5:
+ clrl r0 # both the same to null
+ ret
diff --git a/sysdeps/vax/strncpy.s b/sysdeps/vax/strncpy.s
new file mode 100644
index 0000000..03a09b7
--- /dev/null
+++ b/sysdeps/vax/strncpy.s
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)strncpy.s 5.6 (Berkeley) 6/1/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Copy string s2 over top of string s1.
+ * Truncate or null-pad to n bytes.
+ *
+ * char *
+ * strncpy(s1, s2, n)
+ * char *s1, *s2;
+ */
+#include "DEFS.h"
+
+ENTRY(strncpy, R6)
+ movl 12(ap),r6 # r6 = n
+ bleq done # n <= 0
+ movl 4(ap),r3 # r3 = s1
+ movl 8(ap),r1 # r1 = s2
+1:
+ movzwl $65535,r2 # r2 = bytes in first chunk
+ cmpl r6,r2 # r2 = min(bytes in chunk, n);
+ jgeq 2f
+ movl r6,r2
+2:
+ subl2 r2,r6 # update n
+ locc $0,r2,(r1) # '\0' found?
+ jneq 3f
+ subl2 r2,r1 # back up pointer updated by locc
+ movc3 r2,(r1),(r3) # copy in next piece
+ tstl r6 # run out of space?
+ jneq 1b
+ jbr done
+3: # copy up to '\0' logic
+ addl2 r0,r6 # r6 = number of null-pad bytes
+ subl2 r0,r2 # r2 = number of bytes to move
+ subl2 r2,r1 # back up pointer updated by locc
+ movc3 r2,(r1),(r3) # copy in last piece
+4: # null-pad logic
+ movzwl $65535,r2 # r2 = bytes in first chunk
+ cmpl r6,r2 # r2 = min(bytes in chunk, n);
+ jgeq 5f
+ movl r6,r2
+5:
+ subl2 r2,r6 # update n
+ movc5 $0,(r3),$0,r2,(r3)# pad with '\0's
+ tstl r6 # finished padding?
+ jneq 4b
+done:
+ movl 4(ap),r0 # return s1
+ ret
diff --git a/sysdeps/vax/strpbrk.s b/sysdeps/vax/strpbrk.s
new file mode 100644
index 0000000..0d1b25e
--- /dev/null
+++ b/sysdeps/vax/strpbrk.s
@@ -0,0 +1,68 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)strpbrk.s 5.1 (Berkeley) 5/15/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Find in s1 the first occurrence of any character from s2.
+ * If there are none, return NULL.
+ *
+ * char *
+ * strpbrk(s1, s2)
+ * const char *s1, *s2;
+ */
+#include "DEFS.h"
+
+ENTRY(strpbrk, 0)
+ subl2 $32,sp /* make 256 bit table */
+ movc5 $0,(sp),$0,$32,(sp)
+ movq 4(ap),r0 /* r0 = s1, r1 = s2 */
+
+ /* turn on bit for each character in s2, including '\0' */
+1:
+ movzbl (r1)+,r2
+ bbss r2,(sp),1b
+ bneq 1b
+
+ /* look for a character that is in s2 */
+2:
+ movzbl (r0)+,r2 /* c = *s++ */
+ bbc r2,(sp),2b /* loop until c is in table */
+ beql 3f /* if c==0, go return NULL */
+ decl r0 /* s-- */
+ ret
+3:
+ clrl r0
+ ret
diff --git a/sysdeps/vax/strrchr.s b/sysdeps/vax/strrchr.s
new file mode 100644
index 0000000..f292eac
--- /dev/null
+++ b/sysdeps/vax/strrchr.s
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)strrchr.s 5.4 (Berkeley) 6/1/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Find the last occurence of c in the string cp.
+ * Return pointer to match or null pointer.
+ *
+ * char *
+ * strrchr(cp, c)
+ * char *cp, c;
+ */
+#include "DEFS.h"
+
+ .lcomm tbl,256
+
+ENTRY(strrchr, 0)
+ movzwl $65535,r4 /* handy 65535 */
+ movq 4(ap),r1 /* r1 = cp; r2 = c */
+ movzbl r2,r2
+ beql Lzero /* special case for c == '\0' */
+
+ clrl r5 /* r5 = pointer to last match */
+
+/*
+ * Fancy scanc version. Alas, it is not reentrant.
+ */
+ movab tbl,r3 /* r3 = address of table */
+ bbss $0,(r3),Lreent /* ensure not reentering */
+ movab (r3)[r2],r4
+ incb (r4) /* mark both '\0' and c */
+0:
+ scanc $65535,(r1),(r3),$1 /* look for c or '\0' */
+ beql 0b /* keep looking */
+ tstb (r1)
+ beql 1f /* done if '\0' */
+ movab (r1)+,r5 /* save most recently found, and skip over it */
+ jbr 0b /* keep looking */
+1:
+ movl r5,r0 /* return last found (if any) */
+ clrb (r4) /* clean up table */
+ clrb (r3)
+ ret
+
+/*
+ * Special case for \0.
+ */
+Lzero:
+ locc $0,r4,(r1) /* just find end of string */
+ beql Lzero /* still looking */
+ movl r1,r0 /* found it */
+ ret
+
+/*
+ * Slower reentrant version is two two-step searches. The first
+ * phase runs until we know where the string ends; it locates any
+ * occurrences of c within a 65535-byte block. Once we have found
+ * the end of the string, we find any further occurrences before
+ * that location.
+ */
+Lreent:
+0: /* first phase */
+ movl r1,r3
+ locc $0,r4,(r3) /* look for '\0' */
+ bneq 1f
+ locc r2,r4,(r3) /* continue phase 1 search for c */
+ beql 0b
+ movab (r1)+,r5 /* found c: save and increment pointer */
+ brb 0b /* and continue */
+
+1: /* second phase */
+ subl3 r3,r1,r0 /* length of short block */
+ movl r3,r1
+2:
+ locc r2,r0,(r1) /* look for c */
+ beql 3f /* skip if not found */
+ movab (r1)+,r5 /* save pointer as before */
+ sobgtr r0,2b /* adjust count and loop */
+3:
+ movl r5,r0 /* return stashed pointer */
+ ret
diff --git a/sysdeps/vax/strsep.s b/sysdeps/vax/strsep.s
new file mode 100644
index 0000000..9751acc
--- /dev/null
+++ b/sysdeps/vax/strsep.s
@@ -0,0 +1,85 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)strsep.s 5.1 (Berkeley) 5/15/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Get next word from string *stringp, where words are
+ * strings separated by characters from delim.
+ *
+ * Writes NULs into the string at *stringp to end tokens.
+ * On return, *stringp points past the last NUL written (if there might
+ * be further tokens), or is NULL (if there are definitely no more tokens).
+ *
+ * If *stringp is NULL, strtoken returns NULL.
+ *
+ * char *
+ * strtoken(stringp, delim)
+ * register char **stringp;
+ * register char const *delim;
+ */
+#include "DEFS.h"
+
+ENTRY(strsep, 0)
+ tstl *4(ap) /* if (*stringp == NULL) */
+ bneq 0f
+ clrl r0 # return (NULL);
+ ret
+
+0:
+ subl2 $32,sp /* make room for 256 bit table */
+ movc5 $0,(sp),$0,$32,(sp)
+ movq 4(ap),r1 /* r1 = stringp, r2 = delim */
+
+ /* turn on bit for each character in s2, including '\0' */
+1:
+ movzbl (r2)+,r0
+ bbss r0,(sp),1b
+ bneq 1b
+
+ movl (r1),r3 /* r3 = s = *stringp */
+ movl r3,r0 /* save return value */
+
+ /* scan for delimiters */
+2:
+ movzbl (r3)+,r2 /* c = *s++ */
+ bbc r2,(sp),2b /* loop until c is in table */
+ beql 3f
+ clrb -1(r3) /* if c!='\0', s[-1] = 0 */
+ movl r3,(r1) /* and *stringp = s */
+ ret
+3:
+ clrl (r1) /* else *stringp = NULL */
+ ret
diff --git a/sysdeps/vax/strspn.s b/sysdeps/vax/strspn.s
new file mode 100644
index 0000000..fc86af7
--- /dev/null
+++ b/sysdeps/vax/strspn.s
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)strspn.s 5.1 (Berkeley) 5/15/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Span the string s2 (skip characters that are in s2).
+ * Return the number of characters in s1 that were skipped.
+ *
+ * size_t
+ * strspn(s1, s2)
+ * const char *s1, *s2;
+ */
+#include "DEFS.h"
+
+ENTRY(strspn, 0)
+ subl2 $32,sp /* make 256 bit table */
+ movc5 $0,(sp),$0,$32,(sp)
+ movq 4(ap),r1 /* r1 = s1, r2 = s2 */
+
+ /* turn on bit for each character in s2, including '\0' */
+1:
+ movzbl (r2)+,r0
+ bbss r0,(sp),1b
+ bneq 1b
+
+ /* now clear bit for '\0' */
+ /* (this is easier than avoiding setting it in the first place) */
+ bicb2 $1,(sp) /* stop at '\0' */
+ movl r1,r0 /* r0 = s (current pos in s1) */
+
+ /* look for a character that is not in s2 */
+2:
+ movzbl (r0)+,r2 /* c = *s++ */
+ bbs r2,(sp),2b /* loop while c is in table */
+ decl r0 /* s-- */
+ subl2 r1,r0 /* r0 = s - s1 = count */
+ ret
diff --git a/sysdeps/vax/strstr.s b/sysdeps/vax/strstr.s
new file mode 100644
index 0000000..2e53375
--- /dev/null
+++ b/sysdeps/vax/strstr.s
@@ -0,0 +1,113 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)strstr.s 5.2 (Berkeley) 8/21/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Find the first occurrence of s2 as a substring in s1.
+ * If s2 is empty, return s1.
+ *
+ * char *strstr(s1, s2)
+ * const char *s1, *s2;
+ */
+#include "DEFS.h"
+
+ENTRY(strstr, 0)
+ movq 4(ap),r3 /* r3 = s1, r4 = s2 */
+ movzwl $65535,r2 /* r2 = locc/matchc limit */
+ locc $0,r2,(r4) /* find '\0' in s2 */
+ beql 4f
+ subl3 r4,r1,r5 /* r5 = strlen(s2) */
+ beql 1f /* if r5 == 0, return s1 */
+
+ /*
+ * s2 is short enough to apply matchc.
+ * If s1 is long, we have to do it in stages.
+ */
+0: locc $0,r2,(r3) /* find '\0' in s1 */
+ beql 3f
+
+ /*
+ * Both strings are `short'; we can use matchc directly.
+ */
+ subl3 r3,r1,r1 /* r1 = strlen(s1) */
+ matchc r5,(r4),r1,(r3) /* find substring */
+ bneq 2f
+
+ /*
+ * r3 points r5 bytes past match. Return the match.
+ */
+1: subl3 r5,r3,r0 /* return (byte_past_match - strlen(s2)) */
+ ret
+
+ /*
+ * There is no matching substring.
+ */
+2: clrl r0 /* return NULL */
+ ret
+
+ /*
+ * s1 is too long (> 65535 bytes) to apply matchc directly,
+ * but s2 is short enough. Apply s2 to s1, then (if not
+ * found yet) advancing s1 by (65536-strlen(s2)) bytes and
+ * loop.
+ */
+3: matchc r5,(r4),r2,(r3) /* search */
+ beql 1b /* if found, go return it */
+ decw r2 /* from 0 to 65535 */
+ incl r3 /* already advanced 65535, now 65536 */
+ subl2 r5,r3 /* ... minus strlen(s2) */
+ brb 0b
+
+ /*
+ * s2 is too long (> 65535 bytes) to bother with matchc.
+ */
+4: locc $0,r2,(r1) /* continue working on strlen(s2) */
+ beql 4b
+ subl3 r1,r4,r5 /* r5 = strlen(s2) */
+ movb (r4)+,r2 /* r2 = *s2++ */
+ decl r5 /* fix up length */
+5: movb (r3)+,r0 /* r0 = *s1++ */
+ beql 2b /* if '\0', return NULL */
+ cmpb r0,r2
+ bneq 5b /* loop until first char found */
+ pushr R5|R4|R3|R2 /* save c, s1, s2, n */
+ pushr R5|R4|R3 /* strncmp(s1, s2, n) */
+ calls $3,_strncmp
+ popr R2|R3|R4|R5 /* restore */
+ tstl r0
+ bneq 5b /* loop until strncmp says rest same too */
+ subl3 $1,r3,r0 /* return previous s1 */
+ ret
diff --git a/sysdeps/z8000/gmp-mparam.h b/sysdeps/z8000/gmp-mparam.h
new file mode 100644
index 0000000..73df5b9
--- /dev/null
+++ b/sysdeps/z8000/gmp-mparam.h
@@ -0,0 +1,26 @@
+/* gmp-mparam.h -- Compiler/machine parameter header file.
+
+Copyright (C) 1991, 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#define BITS_PER_MP_LIMB 16
+#define BYTES_PER_MP_LIMB 2
+#define BITS_PER_LONGINT 32
+#define BITS_PER_INT 16
+#define BITS_PER_SHORTINT 16
+#define BITS_PER_CHAR 8