summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgcc <gcc@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2006-08-17 01:23:58 +0000
committergcc <gcc@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2006-08-17 01:23:58 +0000
commiteb697f7064d66386974cd5f64295d9b437b675b3 (patch)
tree8195e081e1055614522efaa6712a899e1824a9ed
parentc7e41c7c096c142b6463c78feb196e63655b6f31 (diff)
downloadeglibc2-eb697f7064d66386974cd5f64295d9b437b675b3.tar.gz
Import glibc-ports-mainline for 2006-08-16
git-svn-id: svn://svn.eglibc.org/fsf/trunk@8 7b3dc134-2b1b-0410-93df-9e9f96275f8d
-rw-r--r--ports/.cvsignore1
-rw-r--r--ports/Banner1
-rw-r--r--ports/ChangeLog43
-rw-r--r--ports/ChangeLog.aix6
-rw-r--r--ports/ChangeLog.am33242
-rw-r--r--ports/ChangeLog.arm477
-rw-r--r--ports/ChangeLog.cris15
-rw-r--r--ports/ChangeLog.hppa193
-rw-r--r--ports/ChangeLog.m68k3
-rw-r--r--ports/ChangeLog.mips170
-rw-r--r--ports/ChangeLog.powerpc16
-rw-r--r--ports/Makefile43
-rw-r--r--ports/README43
-rw-r--r--ports/bare/.cvsignore6
-rw-r--r--ports/bare/Makefile55
-rw-r--r--ports/bare/brdinit.c32
-rw-r--r--ports/bare/console.c42
-rw-r--r--ports/bare/strtsupp.c28
-rw-r--r--ports/sysdeps/am29k/ffs.c43
-rw-r--r--ports/sysdeps/am33/Implies3
-rw-r--r--ports/sysdeps/am33/__longjmp.S61
-rw-r--r--ports/sysdeps/am33/atomicity.h87
-rw-r--r--ports/sysdeps/am33/bits/endian.h7
-rw-r--r--ports/sysdeps/am33/bits/setjmp.h27
-rw-r--r--ports/sysdeps/am33/bsd-_setjmp.S1
-rw-r--r--ports/sysdeps/am33/bsd-setjmp.S1
-rw-r--r--ports/sysdeps/am33/dl-machine.h481
-rw-r--r--ports/sysdeps/am33/elf/start.S81
-rw-r--r--ports/sysdeps/am33/fpu/bits/fenv.h67
-rw-r--r--ports/sysdeps/am33/fpu/fclrexcpt.c52
-rw-r--r--ports/sysdeps/am33/fpu/fedisblxcpt.c42
-rw-r--r--ports/sysdeps/am33/fpu/feenablxcpt.c42
-rw-r--r--ports/sysdeps/am33/fpu/fegetenv.c35
-rw-r--r--ports/sysdeps/am33/fpu/fegetexcept.c35
-rw-r--r--ports/sysdeps/am33/fpu/fegetround.c35
-rw-r--r--ports/sysdeps/am33/fpu/feholdexcpt.c39
-rw-r--r--ports/sysdeps/am33/fpu/fenv_libc.h33
-rw-r--r--ports/sysdeps/am33/fpu/fesetenv.c60
-rw-r--r--ports/sysdeps/am33/fpu/fesetround.c29
-rw-r--r--ports/sysdeps/am33/fpu/feupdateenv.c47
-rw-r--r--ports/sysdeps/am33/fpu/fgetexcptflg.c44
-rw-r--r--ports/sysdeps/am33/fpu/fpu_control.h75
-rw-r--r--ports/sysdeps/am33/fpu/fraiseexcpt.c79
-rw-r--r--ports/sysdeps/am33/fpu/fsetexcptflg.c57
-rw-r--r--ports/sysdeps/am33/fpu/ftestexcept.c34
-rw-r--r--ports/sysdeps/am33/jmpbuf-offsets.h20
-rw-r--r--ports/sysdeps/am33/jmpbuf-unwind.h26
-rw-r--r--ports/sysdeps/am33/linuxthreads/pspinlock.c74
-rw-r--r--ports/sysdeps/am33/linuxthreads/pt-machine.h68
-rw-r--r--ports/sysdeps/am33/memusage.h23
-rw-r--r--ports/sysdeps/am33/preconfigure5
-rw-r--r--ports/sysdeps/am33/setjmp.S80
-rw-r--r--ports/sysdeps/am33/shlib-versions1
-rw-r--r--ports/sysdeps/am33/stackinfo.h28
-rw-r--r--ports/sysdeps/am33/sys/ucontext.h123
-rw-r--r--ports/sysdeps/am33/sysdep.h82
-rw-r--r--ports/sysdeps/arm/Implies3
-rw-r--r--ports/sysdeps/arm/__longjmp.S33
-rw-r--r--ports/sysdeps/arm/bits/atomic.h101
-rw-r--r--ports/sysdeps/arm/bits/endian.h19
-rw-r--r--ports/sysdeps/arm/bits/huge_val.h56
-rw-r--r--ports/sysdeps/arm/bits/link.h66
-rw-r--r--ports/sysdeps/arm/bits/linkmap.h4
-rw-r--r--ports/sysdeps/arm/bits/setjmp.h34
-rw-r--r--ports/sysdeps/arm/bits/string.h31
-rw-r--r--ports/sysdeps/arm/bsd-_setjmp.S30
-rw-r--r--ports/sysdeps/arm/bsd-setjmp.S29
-rw-r--r--ports/sysdeps/arm/dl-machine.h603
-rw-r--r--ports/sysdeps/arm/dl-sysdep.h24
-rw-r--r--ports/sysdeps/arm/dl-tls.h29
-rw-r--r--ports/sysdeps/arm/dl-trampoline.S216
-rw-r--r--ports/sysdeps/arm/eabi/Makefile22
-rw-r--r--ports/sysdeps/arm/eabi/Versions17
-rw-r--r--ports/sysdeps/arm/eabi/__longjmp.S85
-rw-r--r--ports/sysdeps/arm/eabi/aeabi_assert.c27
-rw-r--r--ports/sysdeps/arm/eabi/aeabi_atexit.c28
-rw-r--r--ports/sysdeps/arm/eabi/aeabi_errno_addr.c25
-rw-r--r--ports/sysdeps/arm/eabi/aeabi_lcsts.c84
-rw-r--r--ports/sysdeps/arm/eabi/aeabi_localeconv.c25
-rw-r--r--ports/sysdeps/arm/eabi/aeabi_math.c42
-rw-r--r--ports/sysdeps/arm/eabi/aeabi_mb_cur_max.c28
-rw-r--r--ports/sysdeps/arm/eabi/aeabi_memclr.c31
-rw-r--r--ports/sysdeps/arm/eabi/aeabi_memcpy.c32
-rw-r--r--ports/sysdeps/arm/eabi/aeabi_memmove.c32
-rw-r--r--ports/sysdeps/arm/eabi/aeabi_memset.c31
-rw-r--r--ports/sysdeps/arm/eabi/aeabi_sighandlers.S54
-rw-r--r--ports/sysdeps/arm/eabi/aeabi_unwind_cpp_pr1.c52
-rw-r--r--ports/sysdeps/arm/eabi/bits/fenv.h74
-rw-r--r--ports/sysdeps/arm/eabi/bits/huge_val.h55
-rw-r--r--ports/sysdeps/arm/eabi/bits/setjmp.h38
-rw-r--r--ports/sysdeps/arm/eabi/fclrexcpt.c61
-rw-r--r--ports/sysdeps/arm/eabi/fedisblxcpt.c51
-rw-r--r--ports/sysdeps/arm/eabi/feenablxcpt.c51
-rw-r--r--ports/sysdeps/arm/eabi/fegetenv.c51
-rw-r--r--ports/sysdeps/arm/eabi/fegetexcept.c43
-rw-r--r--ports/sysdeps/arm/eabi/fegetround.c43
-rw-r--r--ports/sysdeps/arm/eabi/feholdexcpt.c54
-rw-r--r--ports/sysdeps/arm/eabi/fesetenv.c57
-rw-r--r--ports/sysdeps/arm/eabi/fesetround.c57
-rw-r--r--ports/sysdeps/arm/eabi/find_exidx.c80
-rw-r--r--ports/sysdeps/arm/eabi/fpu_control.h51
-rw-r--r--ports/sysdeps/arm/eabi/fraiseexcpt.c110
-rw-r--r--ports/sysdeps/arm/eabi/fsetexcptflg.c60
-rw-r--r--ports/sysdeps/arm/eabi/ftestexcept.c43
-rw-r--r--ports/sysdeps/arm/eabi/rtld-global-offsets.sym7
-rw-r--r--ports/sysdeps/arm/eabi/setfpucw.c47
-rw-r--r--ports/sysdeps/arm/eabi/setjmp.S85
-rw-r--r--ports/sysdeps/arm/elf/configure45
-rw-r--r--ports/sysdeps/arm/elf/configure.in35
-rw-r--r--ports/sysdeps/arm/elf/start.S112
-rw-r--r--ports/sysdeps/arm/fpu/__longjmp.S36
-rw-r--r--ports/sysdeps/arm/fpu/bits/fenv.h58
-rw-r--r--ports/sysdeps/arm/fpu/bits/mathdef.h44
-rw-r--r--ports/sysdeps/arm/fpu/bits/setjmp.h34
-rw-r--r--ports/sysdeps/arm/fpu/fclrexcpt.c50
-rw-r--r--ports/sysdeps/arm/fpu/fedisblxcpt.c40
-rw-r--r--ports/sysdeps/arm/fpu/feenablxcpt.c40
-rw-r--r--ports/sysdeps/arm/fpu/fegetenv.c40
-rw-r--r--ports/sysdeps/arm/fpu/fegetexcept.c32
-rw-r--r--ports/sysdeps/arm/fpu/fegetround.c26
-rw-r--r--ports/sysdeps/arm/fpu/feholdexcpt.c39
-rw-r--r--ports/sysdeps/arm/fpu/fesetenv.c45
-rw-r--r--ports/sysdeps/arm/fpu/fesetround.c29
-rw-r--r--ports/sysdeps/arm/fpu/fpu_control.h102
-rw-r--r--ports/sysdeps/arm/fpu/fraiseexcpt.c44
-rw-r--r--ports/sysdeps/arm/fpu/fsetexcptflg.c49
-rw-r--r--ports/sysdeps/arm/fpu/ftestexcept.c32
-rw-r--r--ports/sysdeps/arm/fpu/jmpbuf-offsets.h20
-rw-r--r--ports/sysdeps/arm/fpu/setjmp.S35
-rw-r--r--ports/sysdeps/arm/frame.h28
-rw-r--r--ports/sysdeps/arm/framestate.c1
-rw-r--r--ports/sysdeps/arm/gccframe.h22
-rw-r--r--ports/sysdeps/arm/gmp-mparam.h38
-rw-r--r--ports/sysdeps/arm/initfini.c42
-rw-r--r--ports/sysdeps/arm/jmpbuf-offsets.h20
-rw-r--r--ports/sysdeps/arm/jmpbuf-unwind.h36
-rw-r--r--ports/sysdeps/arm/ldsodefs.h41
-rw-r--r--ports/sysdeps/arm/libc-tls.c37
-rw-r--r--ports/sysdeps/arm/libm-test-ulps1079
-rw-r--r--ports/sysdeps/arm/linuxthreads/pspinlock.c82
-rw-r--r--ports/sysdeps/arm/linuxthreads/pt-machine.h55
-rw-r--r--ports/sysdeps/arm/linuxthreads/tls.h172
-rw-r--r--ports/sysdeps/arm/machine-gmon.h67
-rw-r--r--ports/sysdeps/arm/memset.S68
-rw-r--r--ports/sysdeps/arm/memusage.h21
-rw-r--r--ports/sysdeps/arm/nptl/Makefile21
-rw-r--r--ports/sysdeps/arm/nptl/pthread_spin_lock.S31
-rw-r--r--ports/sysdeps/arm/nptl/pthread_spin_trylock.S34
-rw-r--r--ports/sysdeps/arm/nptl/pthreaddef.h47
-rw-r--r--ports/sysdeps/arm/nptl/tcb-offsets.sym11
-rw-r--r--ports/sysdeps/arm/nptl/tls.h137
-rw-r--r--ports/sysdeps/arm/preconfigure13
-rw-r--r--ports/sysdeps/arm/setjmp.S31
-rw-r--r--ports/sysdeps/arm/shlib-versions4
-rw-r--r--ports/sysdeps/arm/stackinfo.h28
-rw-r--r--ports/sysdeps/arm/strlen.S73
-rw-r--r--ports/sysdeps/arm/sys/ucontext.h95
-rw-r--r--ports/sysdeps/arm/sysdep.h108
-rw-r--r--ports/sysdeps/arm/tls-macros.h51
-rw-r--r--ports/sysdeps/arm/tst-audit.h26
-rw-r--r--ports/sysdeps/arm/unwind-dw2-fde-glibc.c80
-rw-r--r--ports/sysdeps/arm/unwind-pe.c1
-rw-r--r--ports/sysdeps/cris/Implies3
-rw-r--r--ports/sysdeps/cris/Makefile44
-rw-r--r--ports/sysdeps/cris/__longjmp.S38
-rw-r--r--ports/sysdeps/cris/_mcount.S36
-rw-r--r--ports/sysdeps/cris/bits/endian.h7
-rw-r--r--ports/sysdeps/cris/bits/setjmp.h54
-rw-r--r--ports/sysdeps/cris/bits/string.h26
-rwxr-xr-xports/sysdeps/cris/configure7
-rw-r--r--ports/sysdeps/cris/configure.in5
-rw-r--r--ports/sysdeps/cris/dl-machine.h391
-rw-r--r--ports/sysdeps/cris/elf/start.S141
-rw-r--r--ports/sysdeps/cris/machine-gmon.h28
-rw-r--r--ports/sysdeps/cris/memcopy.h57
-rw-r--r--ports/sysdeps/cris/memusage.h27
-rw-r--r--ports/sysdeps/cris/setjmp.S66
-rw-r--r--ports/sysdeps/cris/stackinfo.h28
-rw-r--r--ports/sysdeps/cris/sysdep.h114
-rw-r--r--ports/sysdeps/cris/wordcopy.c1
-rw-r--r--ports/sysdeps/hppa/Makefile41
-rw-r--r--ports/sysdeps/hppa/Versions12
-rw-r--r--ports/sysdeps/hppa/__longjmp.S72
-rw-r--r--ports/sysdeps/hppa/abort-instr.h6
-rw-r--r--ports/sysdeps/hppa/add_n.s58
-rw-r--r--ports/sysdeps/hppa/bits/endian.h7
-rw-r--r--ports/sysdeps/hppa/bits/link.h57
-rw-r--r--ports/sysdeps/hppa/bits/linkmap.h6
-rw-r--r--ports/sysdeps/hppa/bits/setjmp.h36
-rw-r--r--ports/sysdeps/hppa/bsd-_setjmp.S39
-rw-r--r--ports/sysdeps/hppa/bsd-setjmp.S36
-rw-r--r--ports/sysdeps/hppa/configure33
-rw-r--r--ports/sysdeps/hppa/configure.in21
-rw-r--r--ports/sysdeps/hppa/dl-fptr.h35
-rw-r--r--ports/sysdeps/hppa/dl-lookupcfg.h80
-rw-r--r--ports/sysdeps/hppa/dl-machine.h782
-rw-r--r--ports/sysdeps/hppa/dl-symaddr.c36
-rw-r--r--ports/sysdeps/hppa/dl-tls.h29
-rw-r--r--ports/sysdeps/hppa/dl-trampoline.S197
-rw-r--r--ports/sysdeps/hppa/elf/configure63
-rw-r--r--ports/sysdeps/hppa/elf/configure.in49
-rw-r--r--ports/sysdeps/hppa/elf/entry.h10
-rw-r--r--ports/sysdeps/hppa/elf/initfini.c139
-rw-r--r--ports/sysdeps/hppa/elf/start.S121
-rw-r--r--ports/sysdeps/hppa/fpu/bits/fenv.h83
-rw-r--r--ports/sysdeps/hppa/fpu/fclrexcpt.c36
-rw-r--r--ports/sysdeps/hppa/fpu/fedisblxcpt.c38
-rw-r--r--ports/sysdeps/hppa/fpu/feenablxcpt.c38
-rw-r--r--ports/sysdeps/hppa/fpu/fegetenv.c35
-rw-r--r--ports/sysdeps/hppa/fpu/fegetexcept.c34
-rw-r--r--ports/sysdeps/hppa/fpu/fegetround.c34
-rw-r--r--ports/sysdeps/hppa/fpu/feholdexcpt.c55
-rw-r--r--ports/sysdeps/hppa/fpu/fesetenv.c64
-rw-r--r--ports/sysdeps/hppa/fpu/fesetround.c41
-rw-r--r--ports/sysdeps/hppa/fpu/feupdateenv.c40
-rw-r--r--ports/sysdeps/hppa/fpu/fgetexcptflg.c38
-rw-r--r--ports/sysdeps/hppa/fpu/fraiseexcpt.c102
-rw-r--r--ports/sysdeps/hppa/fpu/fsetexcptflg.c38
-rw-r--r--ports/sysdeps/hppa/fpu/ftestexcept.c34
-rw-r--r--ports/sysdeps/hppa/fpu/libm-test-ulps891
-rw-r--r--ports/sysdeps/hppa/frame.h28
-rw-r--r--ports/sysdeps/hppa/gccframe.h23
-rw-r--r--ports/sysdeps/hppa/hppa1.1/Implies3
-rw-r--r--ports/sysdeps/hppa/hppa1.1/addmul_1.s104
-rw-r--r--ports/sysdeps/hppa/hppa1.1/mul_1.s100
-rw-r--r--ports/sysdeps/hppa/hppa1.1/submul_1.s113
-rw-r--r--ports/sysdeps/hppa/hppa1.1/udiv_qrnnd.s78
-rw-r--r--ports/sysdeps/hppa/jmpbuf-offsets.h20
-rw-r--r--ports/sysdeps/hppa/jmpbuf-unwind.h27
-rw-r--r--ports/sysdeps/hppa/ldsodefs.h42
-rw-r--r--ports/sysdeps/hppa/libc-tls.c38
-rw-r--r--ports/sysdeps/hppa/libgcc-compat.c43
-rw-r--r--ports/sysdeps/hppa/linuxthreads/pspinlock.c82
-rw-r--r--ports/sysdeps/hppa/linuxthreads/pt-machine.h134
-rw-r--r--ports/sysdeps/hppa/linuxthreads/tls.h163
-rw-r--r--ports/sysdeps/hppa/lshift.s66
-rw-r--r--ports/sysdeps/hppa/machine-gmon.h25
-rw-r--r--ports/sysdeps/hppa/memusage.h22
-rw-r--r--ports/sysdeps/hppa/mp_clz_tab.c1
-rw-r--r--ports/sysdeps/hppa/nptl/Makefile21
-rw-r--r--ports/sysdeps/hppa/nptl/jmpbuf-unwind.h31
-rw-r--r--ports/sysdeps/hppa/nptl/pthread_spin_lock.c38
-rw-r--r--ports/sysdeps/hppa/nptl/pthread_spin_trylock.c34
-rw-r--r--ports/sysdeps/hppa/nptl/pthread_spin_unlock.c36
-rw-r--r--ports/sysdeps/hppa/nptl/pthreaddef.h40
-rw-r--r--ports/sysdeps/hppa/nptl/tcb-offsets.sym18
-rw-r--r--ports/sysdeps/hppa/nptl/tls.h151
-rw-r--r--ports/sysdeps/hppa/preconfigure6
-rw-r--r--ports/sysdeps/hppa/rshift.s63
-rw-r--r--ports/sysdeps/hppa/setjmp.S69
-rw-r--r--ports/sysdeps/hppa/shlib-versions7
-rw-r--r--ports/sysdeps/hppa/stackinfo.h28
-rw-r--r--ports/sysdeps/hppa/sub_n.s59
-rw-r--r--ports/sysdeps/hppa/sysdep.h77
-rw-r--r--ports/sysdeps/hppa/tls-macros.h115
-rw-r--r--ports/sysdeps/hppa/tst-audit.h26
-rw-r--r--ports/sysdeps/hppa/udiv_qrnnd.s286
-rw-r--r--ports/sysdeps/i860/memcopy.h33
-rw-r--r--ports/sysdeps/i960/Implies3
-rw-r--r--ports/sysdeps/i960/add_n.s21
-rw-r--r--ports/sysdeps/i960/addmul_1.s26
-rw-r--r--ports/sysdeps/i960/ffs.c46
-rw-r--r--ports/sysdeps/i960/mul_1.s23
-rw-r--r--ports/sysdeps/i960/sub_n.s21
-rw-r--r--ports/sysdeps/m68k/Implies5
-rw-r--r--ports/sysdeps/m68k/Makefile38
-rw-r--r--ports/sysdeps/m68k/Versions13
-rw-r--r--ports/sysdeps/m68k/__longjmp.c55
-rw-r--r--ports/sysdeps/m68k/abort-instr.h2
-rw-r--r--ports/sysdeps/m68k/add_n.S76
-rw-r--r--ports/sysdeps/m68k/asm-syntax.h109
-rw-r--r--ports/sysdeps/m68k/bits/byteswap.h67
-rw-r--r--ports/sysdeps/m68k/bits/endian.h7
-rw-r--r--ports/sysdeps/m68k/bits/huge_vall.h43
-rw-r--r--ports/sysdeps/m68k/bits/link.h58
-rw-r--r--ports/sysdeps/m68k/bits/mathdef.h38
-rw-r--r--ports/sysdeps/m68k/bits/setjmp.h45
-rw-r--r--ports/sysdeps/m68k/bsd-_setjmp.c22
-rw-r--r--ports/sysdeps/m68k/bsd-setjmp.c21
-rw-r--r--ports/sysdeps/m68k/dl-machine.h290
-rw-r--r--ports/sysdeps/m68k/dl-trampoline.S129
-rw-r--r--ports/sysdeps/m68k/elf/start.S100
-rw-r--r--ports/sysdeps/m68k/ffs.c48
-rw-r--r--ports/sysdeps/m68k/fpu/Makefile11
-rw-r--r--ports/sysdeps/m68k/fpu/bits/fenv.h79
-rw-r--r--ports/sysdeps/m68k/fpu/bits/mathinline.h445
-rw-r--r--ports/sysdeps/m68k/fpu/branred.c1
-rw-r--r--ports/sysdeps/m68k/fpu/doasin.c1
-rw-r--r--ports/sysdeps/m68k/fpu/dosincos.c1
-rw-r--r--ports/sysdeps/m68k/fpu/e_acos.c35
-rw-r--r--ports/sysdeps/m68k/fpu/e_acosf.c5
-rw-r--r--ports/sysdeps/m68k/fpu/e_acosl.c5
-rw-r--r--ports/sysdeps/m68k/fpu/e_asin.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_asinf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_asinl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_atan2.c104
-rw-r--r--ports/sysdeps/m68k/fpu/e_atan2f.c3
-rw-r--r--ports/sysdeps/m68k/fpu/e_atan2l.c3
-rw-r--r--ports/sysdeps/m68k/fpu/e_atanh.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_atanhf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_atanhl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_cosh.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_coshf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_coshl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_exp.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_exp10.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_exp10f.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_exp10l.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_exp2.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_exp2f.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_exp2l.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_expf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_expl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_fmod.c36
-rw-r--r--ports/sysdeps/m68k/fpu/e_fmodf.c5
-rw-r--r--ports/sysdeps/m68k/fpu/e_fmodl.c5
-rw-r--r--ports/sysdeps/m68k/fpu/e_log.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_log10.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_log10f.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_log10l.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_log2.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_log2f.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_log2l.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_logf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_logl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_pow.c126
-rw-r--r--ports/sysdeps/m68k/fpu/e_powf.c3
-rw-r--r--ports/sysdeps/m68k/fpu/e_powl.c3
-rw-r--r--ports/sysdeps/m68k/fpu/e_rem_pio2.c3
-rw-r--r--ports/sysdeps/m68k/fpu/e_rem_pio2f.c3
-rw-r--r--ports/sysdeps/m68k/fpu/e_rem_pio2l.c3
-rw-r--r--ports/sysdeps/m68k/fpu/e_remainder.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_remainderf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_remainderl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_scalb.c60
-rw-r--r--ports/sysdeps/m68k/fpu/e_scalbf.c3
-rw-r--r--ports/sysdeps/m68k/fpu/e_scalbl.c3
-rw-r--r--ports/sysdeps/m68k/fpu/e_sinh.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_sinhf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_sinhl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_sqrt.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_sqrtf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/e_sqrtl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/fclrexcpt.c50
-rw-r--r--ports/sysdeps/m68k/fpu/fedisblxcpt.c39
-rw-r--r--ports/sysdeps/m68k/fpu/feenablxcpt.c39
-rw-r--r--ports/sysdeps/m68k/fpu/fegetenv.c38
-rw-r--r--ports/sysdeps/m68k/fpu/fegetexcept.c32
-rw-r--r--ports/sysdeps/m68k/fpu/fegetround.c31
-rw-r--r--ports/sysdeps/m68k/fpu/feholdexcpt.c39
-rw-r--r--ports/sysdeps/m68k/fpu/fesetenv.c60
-rw-r--r--ports/sysdeps/m68k/fpu/fesetround.c38
-rw-r--r--ports/sysdeps/m68k/fpu/feupdateenv.c50
-rw-r--r--ports/sysdeps/m68k/fpu/fgetexcptflg.c43
-rw-r--r--ports/sysdeps/m68k/fpu/fraiseexcpt.c83
-rw-r--r--ports/sysdeps/m68k/fpu/fsetexcptflg.c49
-rw-r--r--ports/sysdeps/m68k/fpu/ftestexcept.c32
-rw-r--r--ports/sysdeps/m68k/fpu/halfulp.c1
-rw-r--r--ports/sysdeps/m68k/fpu/k_cos.c42
-rw-r--r--ports/sysdeps/m68k/fpu/k_cosf.c3
-rw-r--r--ports/sysdeps/m68k/fpu/k_cosl.c3
-rw-r--r--ports/sysdeps/m68k/fpu/k_rem_pio2.c3
-rw-r--r--ports/sysdeps/m68k/fpu/k_rem_pio2f.c3
-rw-r--r--ports/sysdeps/m68k/fpu/k_rem_pio2l.c3
-rw-r--r--ports/sysdeps/m68k/fpu/k_sin.c45
-rw-r--r--ports/sysdeps/m68k/fpu/k_sinf.c3
-rw-r--r--ports/sysdeps/m68k/fpu/k_sinl.c3
-rw-r--r--ports/sysdeps/m68k/fpu/k_tan.c44
-rw-r--r--ports/sysdeps/m68k/fpu/k_tanf.c3
-rw-r--r--ports/sysdeps/m68k/fpu/k_tanl.c3
-rw-r--r--ports/sysdeps/m68k/fpu/libm-test-ulps1165
-rw-r--r--ports/sysdeps/m68k/fpu/mathimpl.h94
-rw-r--r--ports/sysdeps/m68k/fpu/mpa.c1
-rw-r--r--ports/sysdeps/m68k/fpu/mpatan.c1
-rw-r--r--ports/sysdeps/m68k/fpu/mpatan2.c1
-rw-r--r--ports/sysdeps/m68k/fpu/mpexp.c1
-rw-r--r--ports/sysdeps/m68k/fpu/mplog.c1
-rw-r--r--ports/sysdeps/m68k/fpu/mpsqrt.c1
-rw-r--r--ports/sysdeps/m68k/fpu/mptan.c1
-rw-r--r--ports/sysdeps/m68k/fpu/s_atan.c38
-rw-r--r--ports/sysdeps/m68k/fpu/s_atanf.c5
-rw-r--r--ports/sysdeps/m68k/fpu/s_atanl.c5
-rw-r--r--ports/sysdeps/m68k/fpu/s_ccos.c73
-rw-r--r--ports/sysdeps/m68k/fpu/s_ccosf.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_ccosh.c78
-rw-r--r--ports/sysdeps/m68k/fpu/s_ccoshf.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_ccoshl.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_ccosl.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_ceil.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_ceilf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_ceill.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_cexp.c117
-rw-r--r--ports/sysdeps/m68k/fpu/s_cexpf.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_cexpl.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_cos.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_cosf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_cosl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_csin.c69
-rw-r--r--ports/sysdeps/m68k/fpu/s_csinf.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_csinh.c71
-rw-r--r--ports/sysdeps/m68k/fpu/s_csinhf.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_csinhl.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_csinl.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_expm1.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_expm1f.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_expm1l.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_fabs.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_fabsf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_fabsl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_finite.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_finitef.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_finitel.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_floor.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_floorf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_floorl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_fpclassifyl.c44
-rw-r--r--ports/sysdeps/m68k/fpu/s_frexp.c56
-rw-r--r--ports/sysdeps/m68k/fpu/s_frexpf.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_frexpl.c59
-rw-r--r--ports/sysdeps/m68k/fpu/s_ilogb.c51
-rw-r--r--ports/sysdeps/m68k/fpu/s_ilogbf.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_ilogbl.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_isinf.c40
-rw-r--r--ports/sysdeps/m68k/fpu/s_isinff.c5
-rw-r--r--ports/sysdeps/m68k/fpu/s_isinfl.c5
-rw-r--r--ports/sysdeps/m68k/fpu/s_isnan.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_isnanf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_isnanl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_llrint.c76
-rw-r--r--ports/sysdeps/m68k/fpu/s_llrintf.c66
-rw-r--r--ports/sysdeps/m68k/fpu/s_llrintl.c65
-rw-r--r--ports/sysdeps/m68k/fpu/s_log1p.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_log1pf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_log1pl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_lrint.c40
-rw-r--r--ports/sysdeps/m68k/fpu/s_lrintf.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_lrintl.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_modf.c56
-rw-r--r--ports/sysdeps/m68k/fpu/s_modff.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_modfl.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_nearbyint.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_nearbyintf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_nearbyintl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_nextafterl.c109
-rw-r--r--ports/sysdeps/m68k/fpu/s_remquo.c48
-rw-r--r--ports/sysdeps/m68k/fpu/s_remquof.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_remquol.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_rint.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_rintf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_rintl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_scalbln.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_scalblnf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_scalblnl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_scalbn.c54
-rw-r--r--ports/sysdeps/m68k/fpu/s_scalbnf.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_scalbnl.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_significand.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_significandf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_significandl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_sin.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_sincos.c38
-rw-r--r--ports/sysdeps/m68k/fpu/s_sincosf.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_sincosl.c3
-rw-r--r--ports/sysdeps/m68k/fpu/s_sinf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_sinl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_tan.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_tanf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_tanh.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_tanhf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_tanhl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_tanl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_trunc.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_truncf.c2
-rw-r--r--ports/sysdeps/m68k/fpu/s_truncl.c2
-rw-r--r--ports/sysdeps/m68k/fpu/sincos32.c1
-rw-r--r--ports/sysdeps/m68k/fpu/slowexp.c1
-rw-r--r--ports/sysdeps/m68k/fpu/slowpow.c1
-rw-r--r--ports/sysdeps/m68k/fpu/switch/68881-sw.h64
-rw-r--r--ports/sysdeps/m68k/fpu/switch/Makefile51
-rw-r--r--ports/sysdeps/m68k/fpu/switch/bits/mathinline.h1
-rw-r--r--ports/sysdeps/m68k/fpu/switch/switch.c87
-rw-r--r--ports/sysdeps/m68k/fpu/t_exp.c1
-rw-r--r--ports/sysdeps/m68k/fpu_control.h101
-rw-r--r--ports/sysdeps/m68k/gccframe.h22
-rw-r--r--ports/sysdeps/m68k/jmpbuf-unwind.h25
-rw-r--r--ports/sysdeps/m68k/lshift.S147
-rw-r--r--ports/sysdeps/m68k/m68020/Makefile3
-rw-r--r--ports/sysdeps/m68k/m68020/addmul_1.S80
-rw-r--r--ports/sysdeps/m68k/m68020/bits/atomic.h254
-rw-r--r--ports/sysdeps/m68k/m68020/bits/string.h26
-rw-r--r--ports/sysdeps/m68k/m68020/mul_1.S87
-rw-r--r--ports/sysdeps/m68k/m68020/submul_1.S80
-rw-r--r--ports/sysdeps/m68k/m68020/wordcopy.S1
-rw-r--r--ports/sysdeps/m68k/memchr.S232
-rw-r--r--ports/sysdeps/m68k/memcopy.h100
-rw-r--r--ports/sysdeps/m68k/memusage.h22
-rw-r--r--ports/sysdeps/m68k/preconfigure6
-rw-r--r--ports/sysdeps/m68k/printf_fphex.c2
-rw-r--r--ports/sysdeps/m68k/rawmemchr.S180
-rw-r--r--ports/sysdeps/m68k/rshift.S146
-rw-r--r--ports/sysdeps/m68k/s_isinfl.c42
-rw-r--r--ports/sysdeps/m68k/s_isnanl.c38
-rw-r--r--ports/sysdeps/m68k/setjmp.c63
-rw-r--r--ports/sysdeps/m68k/stackinfo.h28
-rw-r--r--ports/sysdeps/m68k/strchr.S258
-rw-r--r--ports/sysdeps/m68k/strchrnul.S250
-rw-r--r--ports/sysdeps/m68k/strtold_l.c2
-rw-r--r--ports/sysdeps/m68k/sub_n.S76
-rw-r--r--ports/sysdeps/m68k/sys/ucontext.h108
-rw-r--r--ports/sysdeps/m68k/sysdep.h100
-rw-r--r--ports/sysdeps/m88k/add_n.s104
-rw-r--r--ports/sysdeps/m88k/ffs.c45
-rw-r--r--ports/sysdeps/m88k/m88100/add_n.S133
-rw-r--r--ports/sysdeps/m88k/m88100/add_n.s103
-rw-r--r--ports/sysdeps/m88k/m88100/mul_1.S127
-rw-r--r--ports/sysdeps/m88k/m88100/mul_1.s128
-rw-r--r--ports/sysdeps/m88k/m88100/sub_n.S134
-rw-r--r--ports/sysdeps/m88k/m88100/sub_n.s104
-rw-r--r--ports/sysdeps/m88k/m88110/add_n.S200
-rw-r--r--ports/sysdeps/m88k/m88110/addmul_1.s61
-rw-r--r--ports/sysdeps/m88k/m88110/mul_1.S80
-rw-r--r--ports/sysdeps/m88k/m88110/mul_1.s59
-rw-r--r--ports/sysdeps/m88k/m88110/sub_n.S276
-rw-r--r--ports/sysdeps/m88k/mul_1.s127
-rw-r--r--ports/sysdeps/m88k/sub_n.s106
-rw-r--r--ports/sysdeps/mach/hppa/machine-lock.h63
-rw-r--r--ports/sysdeps/mach/hurd/hppa/bits/sigcontext.h94
-rw-r--r--ports/sysdeps/mach/hurd/hppa/trampoline.c230
-rw-r--r--ports/sysdeps/mach/hurd/mips/bits/sigcontext.h80
-rw-r--r--ports/sysdeps/mach/hurd/mips/dl-machine.c132
-rw-r--r--ports/sysdeps/mach/hurd/mips/exc2signal.c97
-rw-r--r--ports/sysdeps/mach/hurd/mips/init-fault.c41
-rw-r--r--ports/sysdeps/mach/hurd/mips/init-first.c414
-rw-r--r--ports/sysdeps/mach/hurd/mips/intr-msg.h127
-rw-r--r--ports/sysdeps/mach/hurd/mips/longjmp-ctx.c41
-rw-r--r--ports/sysdeps/mach/hurd/mips/longjmp-ts.c45
-rw-r--r--ports/sysdeps/mach/hurd/mips/sigreturn.c223
-rw-r--r--ports/sysdeps/mach/hurd/mips/trampoline.c292
-rw-r--r--ports/sysdeps/mach/mips/Makefile3
-rw-r--r--ports/sysdeps/mach/mips/cacheflush.c44
-rw-r--r--ports/sysdeps/mach/mips/machine-lock.h92
-rw-r--r--ports/sysdeps/mach/mips/machine-sp.h38
-rw-r--r--ports/sysdeps/mach/mips/syscall.S48
-rw-r--r--ports/sysdeps/mach/mips/sysdep.h83
-rw-r--r--ports/sysdeps/mach/mips/thread_state.h42
-rw-r--r--ports/sysdeps/mips/.cvsignore4
-rw-r--r--ports/sysdeps/mips/Implies3
-rw-r--r--ports/sysdeps/mips/Makefile14
-rw-r--r--ports/sysdeps/mips/__longjmp.c84
-rw-r--r--ports/sysdeps/mips/abort-instr.h2
-rw-r--r--ports/sysdeps/mips/add_n.S122
-rw-r--r--ports/sysdeps/mips/addmul_1.S99
-rw-r--r--ports/sysdeps/mips/bits/atomic.h303
-rw-r--r--ports/sysdeps/mips/bits/dlfcn.h66
-rw-r--r--ports/sysdeps/mips/bits/endian.h13
-rw-r--r--ports/sysdeps/mips/bits/fenv.h77
-rw-r--r--ports/sysdeps/mips/bits/ipctypes.h32
-rw-r--r--ports/sysdeps/mips/bits/link.h118
-rw-r--r--ports/sysdeps/mips/bits/mathdef.h46
-rw-r--r--ports/sysdeps/mips/bits/nan.h56
-rw-r--r--ports/sysdeps/mips/bits/setjmp.h75
-rw-r--r--ports/sysdeps/mips/bits/wordsize.h19
-rw-r--r--ports/sysdeps/mips/bsd-_setjmp.S43
-rw-r--r--ports/sysdeps/mips/bsd-setjmp.S42
-rw-r--r--ports/sysdeps/mips/dl-dtprocnum.h22
-rw-r--r--ports/sysdeps/mips/dl-machine.h607
-rw-r--r--ports/sysdeps/mips/dl-tls.h46
-rw-r--r--ports/sysdeps/mips/dl-trampoline.c272
-rw-r--r--ports/sysdeps/mips/elf/configure46
-rw-r--r--ports/sysdeps/mips/elf/configure.in35
-rw-r--r--ports/sysdeps/mips/elf/ldsodefs.h109
-rw-r--r--ports/sysdeps/mips/elf/start.S119
-rw-r--r--ports/sysdeps/mips/fpregdef.h24
-rw-r--r--ports/sysdeps/mips/fpu/e_sqrt.c38
-rw-r--r--ports/sysdeps/mips/fpu/e_sqrtf.c39
-rw-r--r--ports/sysdeps/mips/fpu/fclrexcpt.c47
-rw-r--r--ports/sysdeps/mips/fpu/fedisblxcpt.c42
-rw-r--r--ports/sysdeps/mips/fpu/feenablxcpt.c42
-rw-r--r--ports/sysdeps/mips/fpu/fegetenv.c31
-rw-r--r--ports/sysdeps/mips/fpu/fegetexcept.c34
-rw-r--r--ports/sysdeps/mips/fpu/fegetround.c33
-rw-r--r--ports/sysdeps/mips/fpu/feholdexcpt.c40
-rw-r--r--ports/sysdeps/mips/fpu/fenv_libc.h32
-rw-r--r--ports/sysdeps/mips/fpu/fesetenv.c43
-rw-r--r--ports/sysdeps/mips/fpu/fesetround.c45
-rw-r--r--ports/sysdeps/mips/fpu/feupdateenv.c43
-rw-r--r--ports/sysdeps/mips/fpu/fgetexcptflg.c40
-rw-r--r--ports/sysdeps/mips/fpu/fraiseexcpt.c47
-rw-r--r--ports/sysdeps/mips/fpu/fsetexcptflg.c43
-rw-r--r--ports/sysdeps/mips/fpu/ftestexcept.c33
-rw-r--r--ports/sysdeps/mips/fpu/libm-test-ulps890
-rw-r--r--ports/sysdeps/mips/fpu_control.h98
-rw-r--r--ports/sysdeps/mips/gccframe.h22
-rw-r--r--ports/sysdeps/mips/ieee754.h325
-rw-r--r--ports/sysdeps/mips/init-first.c64
-rw-r--r--ports/sysdeps/mips/jmpbuf-unwind.h46
-rw-r--r--ports/sysdeps/mips/ldsodefs.h66
-rw-r--r--ports/sysdeps/mips/libc-tls.c37
-rw-r--r--ports/sysdeps/mips/lshift.S98
-rw-r--r--ports/sysdeps/mips/machine-gmon.h141
-rw-r--r--ports/sysdeps/mips/memcpy.S136
-rw-r--r--ports/sysdeps/mips/memset.S86
-rw-r--r--ports/sysdeps/mips/memusage.h21
-rw-r--r--ports/sysdeps/mips/mips32/Implies2
-rw-r--r--ports/sysdeps/mips/mips32/Makefile3
-rw-r--r--ports/sysdeps/mips/mips64/Implies3
-rw-r--r--ports/sysdeps/mips/mips64/Versions7
-rw-r--r--ports/sysdeps/mips/mips64/__longjmp.c98
-rw-r--r--ports/sysdeps/mips/mips64/add_n.S130
-rw-r--r--ports/sysdeps/mips/mips64/addmul_1.S107
-rw-r--r--ports/sysdeps/mips/mips64/bsd-_setjmp.S49
-rw-r--r--ports/sysdeps/mips/mips64/bsd-setjmp.S47
-rw-r--r--ports/sysdeps/mips/mips64/gmp-mparam.h31
-rw-r--r--ports/sysdeps/mips/mips64/lshift.S105
-rw-r--r--ports/sysdeps/mips/mips64/memcpy.S140
-rw-r--r--ports/sysdeps/mips/mips64/memset.S92
-rw-r--r--ports/sysdeps/mips/mips64/mul_1.S96
-rw-r--r--ports/sysdeps/mips/mips64/n32/Implies4
-rw-r--r--ports/sysdeps/mips/mips64/n32/Makefile6
-rw-r--r--ports/sysdeps/mips/mips64/n32/libm-test-ulps1245
-rw-r--r--ports/sysdeps/mips/mips64/n64/Implies4
-rw-r--r--ports/sysdeps/mips/mips64/n64/Makefile6
-rw-r--r--ports/sysdeps/mips/mips64/n64/libm-test-ulps1245
-rw-r--r--ports/sysdeps/mips/mips64/rshift.S102
-rw-r--r--ports/sysdeps/mips/mips64/setjmp.S46
-rw-r--r--ports/sysdeps/mips/mips64/setjmp_aux.c78
-rw-r--r--ports/sysdeps/mips/mips64/soft-fp/sfp-machine.h47
-rw-r--r--ports/sysdeps/mips/mips64/sub_n.S130
-rw-r--r--ports/sysdeps/mips/mips64/submul_1.S108
-rw-r--r--ports/sysdeps/mips/mul_1.S87
-rw-r--r--ports/sysdeps/mips/nptl/Makefile25
-rw-r--r--ports/sysdeps/mips/nptl/nptl-sysdep.S2
-rw-r--r--ports/sysdeps/mips/nptl/pthread_spin_lock.S37
-rw-r--r--ports/sysdeps/mips/nptl/pthread_spin_trylock.S41
-rw-r--r--ports/sysdeps/mips/nptl/pthreaddef.h39
-rw-r--r--ports/sysdeps/mips/nptl/tcb-offsets.sym11
-rw-r--r--ports/sysdeps/mips/nptl/tls.h161
-rw-r--r--ports/sysdeps/mips/preconfigure29
-rw-r--r--ports/sysdeps/mips/regdef.h27
-rw-r--r--ports/sysdeps/mips/rshift.S95
-rw-r--r--ports/sysdeps/mips/setjmp.S45
-rw-r--r--ports/sysdeps/mips/setjmp_aux.c65
-rw-r--r--ports/sysdeps/mips/sgidefs.h73
-rw-r--r--ports/sysdeps/mips/shlib-versions21
-rw-r--r--ports/sysdeps/mips/soft-fp/sfp-machine.h47
-rw-r--r--ports/sysdeps/mips/stackinfo.h28
-rw-r--r--ports/sysdeps/mips/sub_n.S122
-rw-r--r--ports/sysdeps/mips/submul_1.S99
-rw-r--r--ports/sysdeps/mips/sys/asm.h490
-rw-r--r--ports/sysdeps/mips/sys/fpregdef.h61
-rw-r--r--ports/sysdeps/mips/sys/regdef.h82
-rw-r--r--ports/sysdeps/mips/sys/ucontext.h159
-rw-r--r--ports/sysdeps/mips/tls-macros.h88
-rw-r--r--ports/sysdeps/mips/tst-audit.h40
-rw-r--r--ports/sysdeps/powerpc/nofpu/Makefile10
-rw-r--r--ports/sysdeps/powerpc/nofpu/Subdirs1
-rw-r--r--ports/sysdeps/powerpc/nofpu/Versions18
-rw-r--r--ports/sysdeps/powerpc/nofpu/fclrexcpt.c37
-rw-r--r--ports/sysdeps/powerpc/nofpu/fedisblxcpt.c33
-rw-r--r--ports/sysdeps/powerpc/nofpu/feenablxcpt.c33
-rw-r--r--ports/sysdeps/powerpc/nofpu/fegetenv.c49
-rw-r--r--ports/sysdeps/powerpc/nofpu/fegetexcept.c28
-rw-r--r--ports/sysdeps/powerpc/nofpu/fegetround.c29
-rw-r--r--ports/sysdeps/powerpc/nofpu/feholdexcpt.c43
-rw-r--r--ports/sysdeps/powerpc/nofpu/fenv_const.c35
-rw-r--r--ports/sysdeps/powerpc/nofpu/fesetenv.c48
-rw-r--r--ports/sysdeps/powerpc/nofpu/fesetround.c34
-rw-r--r--ports/sysdeps/powerpc/nofpu/feupdateenv.c50
-rw-r--r--ports/sysdeps/powerpc/nofpu/fgetexcptflg.c38
-rw-r--r--ports/sysdeps/powerpc/nofpu/fraiseexcpt.c46
-rw-r--r--ports/sysdeps/powerpc/nofpu/fsetexcptflg.c40
-rw-r--r--ports/sysdeps/powerpc/nofpu/ftestexcept.c28
-rw-r--r--ports/sysdeps/powerpc/nofpu/libm-test-ulps890
-rw-r--r--ports/sysdeps/powerpc/nofpu/sim-full.c45
-rw-r--r--ports/sysdeps/powerpc/nofpu/soft-supp.h37
-rw-r--r--ports/sysdeps/rs6000/add_n.s81
-rw-r--r--ports/sysdeps/rs6000/addmul_1.s123
-rw-r--r--ports/sysdeps/rs6000/ffs.c42
-rw-r--r--ports/sysdeps/rs6000/lshift.s59
-rw-r--r--ports/sysdeps/rs6000/memcopy.h86
-rw-r--r--ports/sysdeps/rs6000/mul_1.s110
-rw-r--r--ports/sysdeps/rs6000/rshift.s57
-rw-r--r--ports/sysdeps/rs6000/sub_n.s82
-rw-r--r--ports/sysdeps/rs6000/submul_1.s128
-rw-r--r--ports/sysdeps/standalone/Subdirs4
-rw-r--r--ports/sysdeps/standalone/arm/bits/errno.h65
-rw-r--r--ports/sysdeps/standalone/arm/sysdep.c32
-rw-r--r--ports/sysdeps/standalone/bits/errno.h59
-rw-r--r--ports/sysdeps/standalone/brk.c66
-rw-r--r--ports/sysdeps/standalone/close.c43
-rw-r--r--ports/sysdeps/standalone/dirstream.h43
-rw-r--r--ports/sysdeps/standalone/filedesc.h48
-rw-r--r--ports/sysdeps/standalone/i386/force_cpu386/Makefile26
-rw-r--r--ports/sysdeps/standalone/i386/force_cpu386/_exit.c47
-rw-r--r--ports/sysdeps/standalone/i386/force_cpu386/brdinit.c42
-rw-r--r--ports/sysdeps/standalone/i386/force_cpu386/console.c163
-rw-r--r--ports/sysdeps/standalone/i386/force_cpu386/strtsupp.S87
-rw-r--r--ports/sysdeps/standalone/i386/force_cpu386/target.ld58
-rw-r--r--ports/sysdeps/standalone/i386/i386.h326
-rw-r--r--ports/sysdeps/standalone/i386/start.S338
-rw-r--r--ports/sysdeps/standalone/i960/i960ca.h206
-rw-r--r--ports/sysdeps/standalone/i960/nindy960/Makefile24
-rw-r--r--ports/sysdeps/standalone/i960/nindy960/_exit.c55
-rw-r--r--ports/sysdeps/standalone/i960/nindy960/brdinit.c64
-rw-r--r--ports/sysdeps/standalone/i960/nindy960/console.c76
-rw-r--r--ports/sysdeps/standalone/i960/start.S152
-rw-r--r--ports/sysdeps/standalone/m68k/m68020/m68020.h87
-rw-r--r--ports/sysdeps/standalone/m68k/m68020/mvme135/Implies2
-rw-r--r--ports/sysdeps/standalone/m68k/m68020/mvme136/Makefile23
-rw-r--r--ports/sysdeps/standalone/m68k/m68020/mvme136/_exit.c50
-rw-r--r--ports/sysdeps/standalone/m68k/m68020/mvme136/brdinit.c51
-rw-r--r--ports/sysdeps/standalone/m68k/m68020/mvme136/console.c101
-rw-r--r--ports/sysdeps/standalone/m68k/m68020/mvme136/mvme136.ld61
-rw-r--r--ports/sysdeps/standalone/m68k/m68020/start.S172
-rw-r--r--ports/sysdeps/standalone/open.c125
-rw-r--r--ports/sysdeps/standalone/read.c86
-rw-r--r--ports/sysdeps/standalone/standalone.h31
-rw-r--r--ports/sysdeps/standalone/write.c73
-rw-r--r--ports/sysdeps/tahoe/Implies2
-rw-r--r--ports/sysdeps/unix/am33/sysdep.S64
-rw-r--r--ports/sysdeps/unix/am33/sysdep.h33
-rw-r--r--ports/sysdeps/unix/arm/brk.S56
-rw-r--r--ports/sysdeps/unix/arm/dl-brk.S1
-rw-r--r--ports/sysdeps/unix/arm/fork.S34
-rw-r--r--ports/sysdeps/unix/arm/start.c97
-rw-r--r--ports/sysdeps/unix/arm/sysdep.S98
-rw-r--r--ports/sysdeps/unix/arm/sysdep.h31
-rw-r--r--ports/sysdeps/unix/bsd/hp/m68k/brk.S46
-rw-r--r--ports/sysdeps/unix/bsd/hp/m68k/dl-brk.S1
-rw-r--r--ports/sysdeps/unix/bsd/hp/m68k/start.c10
-rw-r--r--ports/sysdeps/unix/bsd/hp/m68k/sysdep.h56
-rw-r--r--ports/sysdeps/unix/bsd/hp/m68k/vfork.S56
-rw-r--r--ports/sysdeps/unix/bsd/hp/m68k/wait3.S39
-rw-r--r--ports/sysdeps/unix/bsd/m68k/pipe.S33
-rw-r--r--ports/sysdeps/unix/bsd/m68k/start.c3
-rw-r--r--ports/sysdeps/unix/bsd/m68k/syscall.S26
-rw-r--r--ports/sysdeps/unix/bsd/m68k/sysdep.S44
-rw-r--r--ports/sysdeps/unix/bsd/m68k/wait.S35
-rw-r--r--ports/sysdeps/unix/bsd/osf/Implies2
-rw-r--r--ports/sysdeps/unix/bsd/osf/Makefile3
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/bits/stat.h79
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/brk.S54
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/dl-brk.S1
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/fork.S28
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/killpg.S27
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/recv.S26
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/send.S26
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/sigblock.S29
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/sigpause.S30
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/sigsetmask.S29
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/sigvec.S29
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/start.S83
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/syscalls.list3
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/sysdep.h30
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/vhangup.S26
-rw-r--r--ports/sysdeps/unix/bsd/osf/alpha/waitpid.c1
-rw-r--r--ports/sysdeps/unix/bsd/osf/bits/mman.h71
-rw-r--r--ports/sysdeps/unix/bsd/osf/bits/sigaction.h50
-rw-r--r--ports/sysdeps/unix/bsd/osf/syscalls.list3
-rw-r--r--ports/sysdeps/unix/bsd/osf/system.c2
-rw-r--r--ports/sysdeps/unix/bsd/sequent/i386/getgroups.S44
-rw-r--r--ports/sysdeps/unix/bsd/sequent/i386/sigvec.S45
-rw-r--r--ports/sysdeps/unix/bsd/sequent/i386/syscall.S31
-rw-r--r--ports/sysdeps/unix/bsd/sequent/i386/sysdep.h82
-rw-r--r--ports/sysdeps/unix/bsd/sony/newsos/m68k/Implies2
-rw-r--r--ports/sysdeps/unix/bsd/sony/newsos/m68k/sysdep.h56
-rw-r--r--ports/sysdeps/unix/bsd/sony/newsos4/Makefile3
-rw-r--r--ports/sysdeps/unix/bsd/sony/newsos4/syscalls.list3
-rw-r--r--ports/sysdeps/unix/bsd/sony/newsos4/wait.c1
-rw-r--r--ports/sysdeps/unix/bsd/sony/newsos4/wait3.c1
-rw-r--r--ports/sysdeps/unix/bsd/sony/newsos4/wait4.c1
-rw-r--r--ports/sysdeps/unix/bsd/sun/bits/signum.h69
-rw-r--r--ports/sysdeps/unix/bsd/sun/m68k/Makefile3
-rw-r--r--ports/sysdeps/unix/bsd/sun/m68k/bits/sigcontext.h30
-rw-r--r--ports/sysdeps/unix/bsd/sun/m68k/brk.S45
-rw-r--r--ports/sysdeps/unix/bsd/sun/m68k/dl-brk.S1
-rw-r--r--ports/sysdeps/unix/bsd/sun/m68k/sethostid.S40
-rw-r--r--ports/sysdeps/unix/bsd/sun/m68k/sigtramp.c145
-rw-r--r--ports/sysdeps/unix/bsd/sun/m68k/syscall.S28
-rw-r--r--ports/sysdeps/unix/bsd/sun/m68k/sysdep.h62
-rw-r--r--ports/sysdeps/unix/bsd/sun/m68k/vfork.S56
-rw-r--r--ports/sysdeps/unix/bsd/sun/sethostid.c1
-rw-r--r--ports/sysdeps/unix/bsd/sun/sigreturn.S28
-rw-r--r--ports/sysdeps/unix/bsd/sun/sparc/Makefile7
-rw-r--r--ports/sysdeps/unix/bsd/sun/sparc/bits/sigcontext.h34
-rw-r--r--ports/sysdeps/unix/bsd/sun/sparc/sethostid.S43
-rw-r--r--ports/sysdeps/unix/bsd/sun/sparc/sigtramp.c247
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/.cvsignore4
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/Implies2
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/Makefile7
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/bits/fcntl.h142
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/bits/mman.h68
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/bits/resource.h174
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/bits/termios.h212
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/bits/utsname.h24
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/mmap.c42
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/speed.c118
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/sys/ttydefaults.h100
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/syscalls.list6
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/system.c2
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/tcflow.c30
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/tcflush.c30
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/tcgetattr.c33
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/tcsendbrk.c32
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/tcsetattr.c50
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/wait.c1
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/wait3.c1
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/wait4.c50
-rw-r--r--ports/sysdeps/unix/bsd/sun/sunos4/waitpid.c1
-rw-r--r--ports/sysdeps/unix/bsd/sun/syscalls.list3
-rw-r--r--ports/sysdeps/unix/bsd/tahoe/Implies1
-rw-r--r--ports/sysdeps/unix/bsd/tahoe/sysdep.h5
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/Implies2
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/Makefile3
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/bits/fcntl.h122
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/bits/mman.h51
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/bits/posix_opt.h24
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/bits/utsname.h23
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/mips/Makefile3
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/mips/__handler.S115
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/mips/bits/sigcontext.h63
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/mips/sigvec.c55
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/mips/start.S87
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/mips/syscalls.list3
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/mips/sysdep.h3
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/mips/vfork.S36
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/syscalls.list3
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/sysconf.c61
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/system.c2
-rw-r--r--ports/sysdeps/unix/bsd/ultrix4/wait3.S26
-rw-r--r--ports/sysdeps/unix/bsd/vax/brk.S47
-rw-r--r--ports/sysdeps/unix/bsd/vax/dl-brk.S1
-rw-r--r--ports/sysdeps/unix/bsd/vax/pipe.S29
-rw-r--r--ports/sysdeps/unix/bsd/vax/sysdep.S35
-rw-r--r--ports/sysdeps/unix/bsd/vax/sysdep.h55
-rw-r--r--ports/sysdeps/unix/bsd/vax/vfork.S57
-rw-r--r--ports/sysdeps/unix/bsd/vax/wait.S27
-rw-r--r--ports/sysdeps/unix/bsd/vax/wait3.S37
-rw-r--r--ports/sysdeps/unix/mips/brk.S48
-rw-r--r--ports/sysdeps/unix/mips/dl-brk.S1
-rw-r--r--ports/sysdeps/unix/mips/fork.S32
-rw-r--r--ports/sysdeps/unix/mips/mips32/sysdep.h52
-rw-r--r--ports/sysdeps/unix/mips/mips64/n32/sysdep.h57
-rw-r--r--ports/sysdeps/unix/mips/mips64/n64/sysdep.h57
-rw-r--r--ports/sysdeps/unix/mips/pipe.S33
-rw-r--r--ports/sysdeps/unix/mips/rt-sysdep.S1
-rw-r--r--ports/sysdeps/unix/mips/sigreturn.S31
-rw-r--r--ports/sysdeps/unix/mips/sysdep.S100
-rw-r--r--ports/sysdeps/unix/mips/sysdep.h79
-rw-r--r--ports/sysdeps/unix/mips/wait.S47
-rw-r--r--ports/sysdeps/unix/sysv/aix/Implies8
-rw-r--r--ports/sysdeps/unix/sysv/aix/Makefile41
-rw-r--r--ports/sysdeps/unix/sysv/aix/Versions6
-rw-r--r--ports/sysdeps/unix/sysv/aix/_exit.c29
-rw-r--r--ports/sysdeps/unix/sysv/aix/accept.c30
-rw-r--r--ports/sysdeps/unix/sysv/aix/access.c30
-rw-r--r--ports/sysdeps/unix/sysv/aix/bind.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/dirent.h55
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/dlfcn.h47
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/endian.h23
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/errno.h153
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/fcntl.h137
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/ioctl-types.h91
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/ioctls.h248
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/poll.h43
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/resource.h191
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/setjmp.h46
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/sigaction.h72
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/sigcontext.h32
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/signum.h96
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/sigset.h125
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/sigstack.h46
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/socket.h293
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/stat.h119
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/statfs.h77
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/termios.h189
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/types.h136
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/uio.h42
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/utmp.h73
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/utmpx.h75
-rw-r--r--ports/sysdeps/unix/sysv/aix/bits/utsname.h23
-rw-r--r--ports/sysdeps/unix/sysv/aix/brk.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/chdir.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/chmod.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/chown.c26
-rw-r--r--ports/sysdeps/unix/sysv/aix/chroot.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/close.c26
-rw-r--r--ports/sysdeps/unix/sysv/aix/configure6
-rw-r--r--ports/sysdeps/unix/sysv/aix/configure.in6
-rw-r--r--ports/sysdeps/unix/sysv/aix/connect.c11
-rw-r--r--ports/sysdeps/unix/sysv/aix/creat.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/dl-addr.c30
-rw-r--r--ports/sysdeps/unix/sysv/aix/dl-close.c46
-rw-r--r--ports/sysdeps/unix/sysv/aix/dl-error.c20
-rw-r--r--ports/sysdeps/unix/sysv/aix/dl-libc.c41
-rw-r--r--ports/sysdeps/unix/sysv/aix/dl-open.c133
-rw-r--r--ports/sysdeps/unix/sysv/aix/dl-support.c20
-rw-r--r--ports/sysdeps/unix/sysv/aix/dl-sym.c58
-rw-r--r--ports/sysdeps/unix/sysv/aix/dlldr.h111
-rw-r--r--ports/sysdeps/unix/sysv/aix/environ.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/euidaccess.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/execve.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/fchdir.c26
-rw-r--r--ports/sysdeps/unix/sysv/aix/fchmod.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/fchown.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/fcntl.c43
-rw-r--r--ports/sysdeps/unix/sysv/aix/fdatasync.c31
-rw-r--r--ports/sysdeps/unix/sysv/aix/fork.c29
-rw-r--r--ports/sysdeps/unix/sysv/aix/fstatfs.c27
-rw-r--r--ports/sysdeps/unix/sysv/aix/fsync.c31
-rw-r--r--ports/sysdeps/unix/sysv/aix/ftruncate.c28
-rw-r--r--ports/sysdeps/unix/sysv/aix/ftruncate64.c28
-rw-r--r--ports/sysdeps/unix/sysv/aix/fxstat.c32
-rw-r--r--ports/sysdeps/unix/sysv/aix/fxstat64.c33
-rw-r--r--ports/sysdeps/unix/sysv/aix/getdents.c28
-rw-r--r--ports/sysdeps/unix/sysv/aix/getegid.c29
-rw-r--r--ports/sysdeps/unix/sysv/aix/geteuid.c29
-rw-r--r--ports/sysdeps/unix/sysv/aix/getgid.c30
-rw-r--r--ports/sysdeps/unix/sysv/aix/getgroups.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/gethostname.c27
-rw-r--r--ports/sysdeps/unix/sysv/aix/getpeername.c28
-rw-r--r--ports/sysdeps/unix/sysv/aix/getpgid.c29
-rw-r--r--ports/sysdeps/unix/sysv/aix/getpgrp.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/getpid.c9
-rw-r--r--ports/sysdeps/unix/sysv/aix/getppid.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/getpriority.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/getrlimit.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/getrlimit64.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/getrusage.c27
-rw-r--r--ports/sysdeps/unix/sysv/aix/getsid.c27
-rw-r--r--ports/sysdeps/unix/sysv/aix/getsockname.c29
-rw-r--r--ports/sysdeps/unix/sysv/aix/gettimeofday.c98
-rw-r--r--ports/sysdeps/unix/sysv/aix/getuid.c30
-rw-r--r--ports/sysdeps/unix/sysv/aix/gnu/lib-names.h31
-rw-r--r--ports/sysdeps/unix/sysv/aix/init-first.c103
-rw-r--r--ports/sysdeps/unix/sysv/aix/ioctl.c43
-rw-r--r--ports/sysdeps/unix/sysv/aix/kernel_proto.h25
-rw-r--r--ports/sysdeps/unix/sysv/aix/kill.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/lchown.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/libc-start.c290
-rw-r--r--ports/sysdeps/unix/sysv/aix/link.c27
-rw-r--r--ports/sysdeps/unix/sysv/aix/lockf.c27
-rw-r--r--ports/sysdeps/unix/sysv/aix/lockf64.c27
-rw-r--r--ports/sysdeps/unix/sysv/aix/lseek.c10
-rw-r--r--ports/sysdeps/unix/sysv/aix/lseek64.c35
-rw-r--r--ports/sysdeps/unix/sysv/aix/lxstat.c32
-rw-r--r--ports/sysdeps/unix/sysv/aix/lxstat64.c33
-rw-r--r--ports/sysdeps/unix/sysv/aix/madvise.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/mkdir.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/mknod.c28
-rw-r--r--ports/sysdeps/unix/sysv/aix/mmap.c9
-rw-r--r--ports/sysdeps/unix/sysv/aix/mmap64.c30
-rw-r--r--ports/sysdeps/unix/sysv/aix/mprotect.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/msgctl.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/msgget.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/msgrcv.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/msgsnd.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/msync.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/munmap.c8
-rw-r--r--ports/sysdeps/unix/sysv/aix/nanosleep.c40
-rw-r--r--ports/sysdeps/unix/sysv/aix/net/if.h196
-rw-r--r--ports/sysdeps/unix/sysv/aix/open.c40
-rw-r--r--ports/sysdeps/unix/sysv/aix/pipe.c27
-rw-r--r--ports/sysdeps/unix/sysv/aix/poll.c29
-rw-r--r--ports/sysdeps/unix/sysv/aix/posix_madvise.c8
-rw-r--r--ports/sysdeps/unix/sysv/aix/powerpc/memset.c21
-rw-r--r--ports/sysdeps/unix/sysv/aix/powerpc/register-dump.h281
-rw-r--r--ports/sysdeps/unix/sysv/aix/powerpc/s_lrint.c29
-rw-r--r--ports/sysdeps/unix/sysv/aix/pread.c28
-rw-r--r--ports/sysdeps/unix/sysv/aix/pread64.c28
-rw-r--r--ports/sysdeps/unix/sysv/aix/profil-counter.h27
-rw-r--r--ports/sysdeps/unix/sysv/aix/read.c31
-rw-r--r--ports/sysdeps/unix/sysv/aix/readlink.c8
-rw-r--r--ports/sysdeps/unix/sysv/aix/readv.c38
-rw-r--r--ports/sysdeps/unix/sysv/aix/recv.c28
-rw-r--r--ports/sysdeps/unix/sysv/aix/recvfrom.c31
-rw-r--r--ports/sysdeps/unix/sysv/aix/recvmsg.c29
-rw-r--r--ports/sysdeps/unix/sysv/aix/rename.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/revoke.c41
-rw-r--r--ports/sysdeps/unix/sysv/aix/rmdir.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/sbrk.c26
-rw-r--r--ports/sysdeps/unix/sysv/aix/sched_yield.c31
-rw-r--r--ports/sysdeps/unix/sysv/aix/select.c31
-rw-r--r--ports/sysdeps/unix/sysv/aix/semctl.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/semget.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/semop.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/sendmsg.c30
-rw-r--r--ports/sysdeps/unix/sysv/aix/sendto.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/setegid.c32
-rw-r--r--ports/sysdeps/unix/sysv/aix/seteuid.c32
-rw-r--r--ports/sysdeps/unix/sysv/aix/setgid.c31
-rw-r--r--ports/sysdeps/unix/sysv/aix/setgroups.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/setitimer.c68
-rw-r--r--ports/sysdeps/unix/sysv/aix/setpgid.c28
-rw-r--r--ports/sysdeps/unix/sysv/aix/setpgrp.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/setpriority.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/setregid.c41
-rw-r--r--ports/sysdeps/unix/sysv/aix/setreuid.c41
-rw-r--r--ports/sysdeps/unix/sysv/aix/setrlimit.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/setrlimit64.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/setsid.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/setsockopt.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/setuid.c31
-rw-r--r--ports/sysdeps/unix/sysv/aix/shmat.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/shmctl.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/shmdt.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/shmget.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/sigaction.c36
-rw-r--r--ports/sysdeps/unix/sysv/aix/sigaltstack.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/sigpending.c30
-rw-r--r--ports/sysdeps/unix/sysv/aix/sigprocmask.c8
-rw-r--r--ports/sysdeps/unix/sysv/aix/sigset-cvt-mask.h33
-rw-r--r--ports/sysdeps/unix/sysv/aix/sigstack.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/sigsuspend.c33
-rw-r--r--ports/sysdeps/unix/sysv/aix/sleep.c34
-rw-r--r--ports/sysdeps/unix/sysv/aix/socket.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/socketpair.c25
-rw-r--r--ports/sysdeps/unix/sysv/aix/speed.c75
-rw-r--r--ports/sysdeps/unix/sysv/aix/start-libc.c265
-rw-r--r--ports/sysdeps/unix/sysv/aix/start.s126
-rw-r--r--ports/sysdeps/unix/sysv/aix/statfs.c28
-rw-r--r--ports/sysdeps/unix/sysv/aix/symlink.c27
-rw-r--r--ports/sysdeps/unix/sysv/aix/sync.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/sys/param.h48
-rw-r--r--ports/sysdeps/unix/sysv/aix/sys/ucontext.h113
-rw-r--r--ports/sysdeps/unix/sysv/aix/syscall.c2
-rw-r--r--ports/sysdeps/unix/sysv/aix/sysdep.h88
-rw-r--r--ports/sysdeps/unix/sysv/aix/sysv_termio.h155
-rw-r--r--ports/sysdeps/unix/sysv/aix/tcgetattr.c152
-rw-r--r--ports/sysdeps/unix/sysv/aix/tcsetattr.c198
-rw-r--r--ports/sysdeps/unix/sysv/aix/times.c30
-rw-r--r--ports/sysdeps/unix/sysv/aix/truncate.c28
-rw-r--r--ports/sysdeps/unix/sysv/aix/truncate64.c28
-rw-r--r--ports/sysdeps/unix/sysv/aix/uitrunc.c42
-rw-r--r--ports/sysdeps/unix/sysv/aix/ulimit.c37
-rw-r--r--ports/sysdeps/unix/sysv/aix/umask.c26
-rw-r--r--ports/sysdeps/unix/sysv/aix/uname.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/unlink.c26
-rw-r--r--ports/sysdeps/unix/sysv/aix/usleep.c34
-rw-r--r--ports/sysdeps/unix/sysv/aix/ustat.c1
-rw-r--r--ports/sysdeps/unix/sysv/aix/utimes.c27
-rw-r--r--ports/sysdeps/unix/sysv/aix/utmpx.h89
-rw-r--r--ports/sysdeps/unix/sysv/aix/wait3.c42
-rw-r--r--ports/sysdeps/unix/sysv/aix/wait4.c33
-rw-r--r--ports/sysdeps/unix/sysv/aix/waitid.c83
-rw-r--r--ports/sysdeps/unix/sysv/aix/waitpid.c53
-rw-r--r--ports/sysdeps/unix/sysv/aix/write.c36
-rw-r--r--ports/sysdeps/unix/sysv/aix/writev.c38
-rw-r--r--ports/sysdeps/unix/sysv/aix/xstat.c32
-rw-r--r--ports/sysdeps/unix/sysv/aix/xstat64.c34
-rw-r--r--ports/sysdeps/unix/sysv/hpux/bits/errno.h34
-rw-r--r--ports/sysdeps/unix/sysv/hpux/bits/setjmp.h16
-rw-r--r--ports/sysdeps/unix/sysv/hpux/bits/stat.h128
-rw-r--r--ports/sysdeps/unix/sysv/hpux/bits/types.h128
-rw-r--r--ports/sysdeps/unix/sysv/hpux/sysdep.h26
-rw-r--r--ports/sysdeps/unix/sysv/i386/signal.S31
-rw-r--r--ports/sysdeps/unix/sysv/i386/sigreturn.S27
-rw-r--r--ports/sysdeps/unix/sysv/irix4/Implies4
-rw-r--r--ports/sysdeps/unix/sysv/irix4/Makefile25
-rw-r--r--ports/sysdeps/unix/sysv/irix4/__handler.S117
-rw-r--r--ports/sysdeps/unix/sysv/irix4/bits/confname.h84
-rw-r--r--ports/sysdeps/unix/sysv/irix4/bits/fcntl.h109
-rw-r--r--ports/sysdeps/unix/sysv/irix4/bits/mman.h64
-rw-r--r--ports/sysdeps/unix/sysv/irix4/bits/signum.h69
-rw-r--r--ports/sysdeps/unix/sysv/irix4/bits/stat.h65
-rw-r--r--ports/sysdeps/unix/sysv/irix4/dup2.c3
-rw-r--r--ports/sysdeps/unix/sysv/irix4/fpathconf.c35
-rw-r--r--ports/sysdeps/unix/sysv/irix4/getgroups.c34
-rw-r--r--ports/sysdeps/unix/sysv/irix4/getpriority.c47
-rw-r--r--ports/sysdeps/unix/sysv/irix4/getrusage.c35
-rw-r--r--ports/sysdeps/unix/sysv/irix4/gettimeofday.c1
-rw-r--r--ports/sysdeps/unix/sysv/irix4/pathconf.c35
-rw-r--r--ports/sysdeps/unix/sysv/irix4/readv.c1
-rw-r--r--ports/sysdeps/unix/sysv/irix4/reboot.c1
-rw-r--r--ports/sysdeps/unix/sysv/irix4/setgroups.c33
-rw-r--r--ports/sysdeps/unix/sysv/irix4/setpriority.c42
-rw-r--r--ports/sysdeps/unix/sysv/irix4/sigreturn.S26
-rw-r--r--ports/sysdeps/unix/sysv/irix4/sigtramp.c53
-rw-r--r--ports/sysdeps/unix/sysv/irix4/start.c75
-rw-r--r--ports/sysdeps/unix/sysv/irix4/swapon.c1
-rw-r--r--ports/sysdeps/unix/sysv/irix4/syscalls.list8
-rw-r--r--ports/sysdeps/unix/sysv/irix4/sysconf.c36
-rw-r--r--ports/sysdeps/unix/sysv/irix4/uname.S26
-rw-r--r--ports/sysdeps/unix/sysv/irix4/wait.S43
-rw-r--r--ports/sysdeps/unix/sysv/irix4/waitpid.c1
-rw-r--r--ports/sysdeps/unix/sysv/irix4/writev.c1
-rw-r--r--ports/sysdeps/unix/sysv/isc2.2/syscalls.list2
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/Makefile3
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/bits/fcntl.h179
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/bits/mman.h97
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/brk.c46
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/chown.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/clone.S81
-rwxr-xr-xports/sysdeps/unix/sysv/linux/am33/configure4
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/configure.in4
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/fchown.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/fcntl.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/fxstat.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/getegid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/geteuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/getgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/getgroups.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/getmsg.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/getresgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/getresuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/getrlimit.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/getuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/lchown.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/linuxthreads/sysdep-cancel.h159
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/lockf64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/lxstat.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/profil-counter.h27
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/putmsg.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/setegid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/seteuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/setfsgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/setfsuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/setgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/setgroups.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/setregid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/setresgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/setresuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/setreuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/setrlimit.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/setuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/socket.S73
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/syscall.S43
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/sysdep.S42
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/sysdep.h317
-rw-r--r--ports/sysdeps/unix/sysv/linux/am33/xstat.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/Makefile22
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/Versions37
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S51
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/alphasort64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/bits/armsigctx.h73
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/bits/fcntl.h235
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/bits/mman.h103
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/brk.c42
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/chown.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/clone.S107
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.c64
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h86
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/Makefile9
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/configure5
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/configure.in5
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/ftruncate64.c77
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/linuxthreads/sysdep-cancel.h116
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/mmap64.S56
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/Makefile17
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/configure4
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/configure.in8
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/nptl-aeabi_unwind_cpp_pr1.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/rt-aeabi_unwind_cpp_pr1.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/sysdep-cancel.h153
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c113
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c82
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind.h274
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/oldgetrlimit.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/oldsetrlimit.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/pread.c61
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/pread64.c63
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/pwrite.c61
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/pwrite64.c64
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/readahead.c51
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S54
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/syscall.S38
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/syscalls.list34
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/sysdep.h83
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/truncate64.c75
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/eabi/umount.c31
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/fchown.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/fcntl.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/fxstat.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/getdents64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/getegid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/geteuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/getgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/getgroups.c2
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/getresgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/getresuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/getrlimit.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/getrlimit64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/getuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/glob64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/ioperm.c281
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/kernel-features.h49
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/lchown.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/libc-aeabi_read_tp.S1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/linuxthreads/fork.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/linuxthreads/sysdep-cancel.h129
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/linuxthreads/vfork.S78
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/lockf64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/lxstat.c2
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/mmap.S92
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/mmap64.S89
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/msgctl.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/Makefile8
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/Versions6
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h95
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes.h167
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/bits/semaphore.h38
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/clone.S3
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/createthread.c23
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/fork.c31
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.c118
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h326
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S38
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/pthread_once.c99
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/sysdep-cancel.h128
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/unwind-forcedunwind.c117
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/unwind-resume.c87
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/unwind.h31
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/nptl/vfork.S39
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/posix_fadvise.c31
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/posix_fadvise64.c78
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/profil-counter.h37
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/readdir64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/readdir64_r.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/register-dump.h166
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/scandir64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/semctl.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/setegid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/seteuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/setfsgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/setfsuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/setgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/setgroups.c2
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/setregid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/setresgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/setresuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/setreuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/setrlimit.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/setuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/shmctl.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/sigaction.c162
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/sigcontextinfo.h51
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/sigrestorer.S33
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/socket.S127
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/sys/elf.h26
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/sys/io.h48
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/sys/procfs.h123
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/sys/ucontext.h97
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/sys/user.h72
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/syscalls.list5
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/sysdep.S35
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/sysdep.h277
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/versionsort64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/vfork.S65
-rw-r--r--ports/sysdeps/unix/sysv/linux/arm/xstat.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/_G_config.h106
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/bits/fcntl.h189
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/bits/mman.h97
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/brk.c44
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/chown.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/clone.S88
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/fchown.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/fcntl.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/fxstat.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/getegid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/geteuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/getgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/getgroups.c2
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/getresgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/getresuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/getrlimit.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/getrlimit64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/getuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/lchown.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/lockf64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/lxstat.c2
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/mmap.S68
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/mmap64.S91
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/msgctl.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/profil-counter.h26
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/register-dump.h117
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/semctl.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/setegid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/seteuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/setfsgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/setfsuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/setgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/setgroups.c2
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/setregid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/setresgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/setresuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/setreuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/setrlimit.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/setuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/shmctl.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/socket.S96
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/sys/ucontext.h56
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/syscall.S40
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/sysdep.S66
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/sysdep.h226
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/vfork.S27
-rw-r--r--ports/sysdeps/unix/sysv/linux/cris/xstat.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/Makefile2
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/Versions28
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/bits/atomic.h120
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/bits/errno.h51
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/bits/fcntl.h222
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/bits/ioctls.h37
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/bits/ipc.h63
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/bits/mman.h92
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/bits/msq.h84
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/bits/sem.h92
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/bits/shm.h107
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/bits/sigaction.h75
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/bits/signum.h82
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/brk.c42
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/clone.S133
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/fcntl.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/fxstat.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/fxstatat.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/getdents64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/getrlimit64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/kernel-features.h39
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/kernel_sigaction.h18
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/kernel_stat.h31
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/aio_cancel.c33
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/bits/initspin.h41
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/bits/pthreadtypes.h160
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/malloc-machine.h73
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/pt-initfini.c109
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/sysdep-cancel.h238
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/lxstat.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/mmap.c50
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/nptl/bits/pthreadtypes.h188
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/nptl/bits/semaphore.h39
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/nptl/createthread.c23
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/nptl/fork.c34
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/nptl/internaltypes.h153
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/nptl/libc-lowlevellock.c21
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/nptl/lowlevellock.c130
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/nptl/lowlevellock.h339
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/nptl/pt-initfini.c109
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/nptl/pt-vfork.S90
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/nptl/pthread_once.c94
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/nptl/sysdep-cancel.h217
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/nptl/unwind-forcedunwind.c21
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/nptl/unwind-resume.c21
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/profil-counter.h25
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/socket.S10
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/sys/procfs.h113
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/sys/ucontext.h67
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/syscall.S19
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/syscalls.list37
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/sysdep.c78
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/sysdep.h484
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/umount.c31
-rw-r--r--ports/sysdeps/unix/sysv/linux/hppa/xstat.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/Makefile17
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/Versions32
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/alphasort64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/bits/a.out.h3
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/bits/fcntl.h188
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/bits/mman.h102
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/bits/poll.h43
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/bits/stat.h164
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/brk.c48
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/chown.c69
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/clone.S66
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/dl-librecon.h1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/fchown.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/fchownat.c122
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/fcntl.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/fxstat.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/fxstatat.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/getdents64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/getegid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/geteuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/getgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/getgroups.c2
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/getmsg.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/getpagesize.c50
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/getresgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/getresuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/getrlimit.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/getrlimit64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/getsysstats.c37
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/getuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/glob64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/lchown.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/ldconfig.h1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/lockf64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/lxstat.c2
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/mmap.S43
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/mremap.S29
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/msgctl.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/putmsg.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/readdir64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/readdir64_r.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/register-dump.h214
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/scandir64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/semctl.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/semtimedop.S60
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/setegid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/seteuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/setfsgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/setfsuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/setgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/setgroups.c2
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/setregid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/setresgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/setresuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/setreuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/setrlimit.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/setuid.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/shmctl.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/sigcontextinfo.h26
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/socket.S111
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/sys/procfs.h126
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/sys/reg.h89
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/sys/ucontext.h109
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/syscall.S33
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/syscalls.list5
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/sysdep.S49
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/sysdep.h295
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/versionsort64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/vfork.S76
-rw-r--r--ports/sysdeps/unix/sysv/linux/m68k/xstat.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/Makefile128
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/Versions31
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/_test_and_set.c30
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/endian.h16
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/errno.h59
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/fcntl.h249
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/ioctl-types.h76
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/ipc.h55
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/mman.h106
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/msq.h74
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/poll.h50
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/resource.h233
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/sem.h85
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/shm.h94
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/sigaction.h89
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/sigcontext.h84
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/siginfo.h310
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/signum.h79
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/sigstack.h55
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/socket.h315
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/stat.h255
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/statfs.h72
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/bits/termios.h218
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/brk.c57
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/clone.S166
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/configure112
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/configure.in112
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/dl-cache.h43
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/entry.h5
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/fcntl.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/ftruncate64.c76
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/getmsg.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/getpagesize.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/getsysstats.c36
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/ipc_priv.h1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/kernel-features.h34
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/kernel_sigaction.h40
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/kernel_stat.h57
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/kernel_termios.h35
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/lockf64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h292
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/Makefile9
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/configure4
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/configure.in5
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/ldconfig.h26
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/ldd-rewrite.sed1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/llseek.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/n32/ftruncate64.c28
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h248
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/n32/truncate64.c30
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S42
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h248
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/nptl/sysdep-cancel.h183
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/recv.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/send.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/syscall.S60
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list17
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/mips64/umount.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/nptl/bits/pthreadtypes.h215
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/nptl/bits/semaphore.h40
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/nptl/clone.S2
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/nptl/createthread.c24
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/nptl/fork.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/nptl/lowlevellock.h293
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/nptl/pt-vfork.S37
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/nptl/pthread_once.c94
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h170
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/nptl/vfork.S42
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/pipe.S1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/pread.c109
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/pread64.c107
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/profil-counter.h2
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/putmsg.c1
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/pwrite.c109
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/pwrite64.c108
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/readelflib.c71
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/register-dump.h105
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/sigaction.c192
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/sigcontextinfo.h43
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/sys/cachectl.h42
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/sys/procfs.h128
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/sys/syscall.h42
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/sys/sysmips.h43
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/sys/tas.h67
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/sys/ucontext.h117
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/sys/user.h219
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/syscalls.list31
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/truncate64.c76
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/ustat.c37
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/vfork.S98
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/xmknod.c51
-rw-r--r--ports/sysdeps/unix/sysv/linux/mips/xstatconv.c139
-rw-r--r--ports/sysdeps/unix/sysv/minix/bits/sigaction.h53
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2.4/Makefile17
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2.4/__setpgid.c33
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2.4/bits/confname.h54
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2.4/bits/sigaction.h43
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2.4/getgroups.c45
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2.4/getpgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2.4/setpgid.c1
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2.4/setsid.c1
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2.4/sigaction.S30
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2.4/sys/syscall.h125
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2.4/syscalls.list8
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2.4/sysconf.S30
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2.4/system.c10
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2.4/uname.S41
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2.4/waitpid.S37
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2/Makefile23
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2/__fltused.c3
-rw-r--r--ports/sysdeps/unix/sysv/sco3.2/bits/local_lim.h37
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/Implies3
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/Makefile29
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/__getpgid.c33
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/__setpgid.c34
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/bits/sigaction.h55
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/bits/signum.h66
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/bits/sigset.h98
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/bits/utsname.h23
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/bits/waitflags.h34
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/dup2.c2
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/ftruncate.c37
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/gethostname.c35
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/getpagesize.c2
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/getpgid.c32
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/i386/Makefile3
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/i386/bits/stat.h93
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/i386/sys-sig.S30
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/i386/syscalls.list6
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/i386/sysdep.h38
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/i386/vfork.S1
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/sethostname.c33
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/setpgid.c34
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/setsid.c33
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/sigaction.c80
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/siginfo.h59
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/sigset-cvt-mask.h37
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/Makefile6
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/bits/dirent.h50
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/bits/errno.h168
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/bits/signum.h76
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/bits/sigstack.h55
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/bits/stat.h119
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/bits/types.h120
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/fsync.S30
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/getdents.c114
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/sigpending.c37
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/sigstack.c3
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/sigwaitinfo.c2
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile11
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/bits/sigcontext.h34
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/errlist.c185
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sparc32/syscall.S2
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/start.c4
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sys/trap.h36
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sys/ucontext.h42
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/syscalls.list3
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.S47
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h56
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/sys/param.h59
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/sys/syscall.h245
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/solaris2/syscalls.list7
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/syscalls.list7
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/sysconf.c366
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/sysconfig.h28
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/system.c2
-rw-r--r--ports/sysdeps/unix/sysv/sysv4/waitpid.c120
-rw-r--r--ports/sysdeps/vax/DEFS.h57
-rw-r--r--ports/sysdeps/vax/Makefile32
-rw-r--r--ports/sysdeps/vax/__longjmp.c129
-rw-r--r--ports/sysdeps/vax/add_n.s48
-rw-r--r--ports/sysdeps/vax/addmul_1.s126
-rw-r--r--ports/sysdeps/vax/bcopy.s74
-rw-r--r--ports/sysdeps/vax/bits/huge_val.h26
-rw-r--r--ports/sysdeps/vax/bits/setjmp.h11
-rw-r--r--ports/sysdeps/vax/bsd-_setjmp.S33
-rw-r--r--ports/sysdeps/vax/bsd-setjmp.S32
-rw-r--r--ports/sysdeps/vax/bzero.s50
-rw-r--r--ports/sysdeps/vax/ffs.s45
-rw-r--r--ports/sysdeps/vax/fl.h68
-rw-r--r--ports/sysdeps/vax/gccframe.h22
-rw-r--r--ports/sysdeps/vax/gmp-mparam.h29
-rw-r--r--ports/sysdeps/vax/htonl.s43
-rw-r--r--ports/sysdeps/vax/htons.s43
-rw-r--r--ports/sysdeps/vax/memccpy.c46
-rw-r--r--ports/sysdeps/vax/memchr.s74
-rw-r--r--ports/sysdeps/vax/memcmp.s59
-rw-r--r--ports/sysdeps/vax/memmove.s89
-rw-r--r--ports/sysdeps/vax/memset.s51
-rw-r--r--ports/sysdeps/vax/mul_1.s123
-rw-r--r--ports/sysdeps/vax/setjmp.c62
-rw-r--r--ports/sysdeps/vax/strcat.s62
-rw-r--r--ports/sysdeps/vax/strchr.s103
-rw-r--r--ports/sysdeps/vax/strcmp.s81
-rw-r--r--ports/sysdeps/vax/strcpy.s58
-rw-r--r--ports/sysdeps/vax/strcspn.s62
-rw-r--r--ports/sysdeps/vax/strlen.s48
-rw-r--r--ports/sysdeps/vax/strncat.s79
-rw-r--r--ports/sysdeps/vax/strncmp.s85
-rw-r--r--ports/sysdeps/vax/strncpy.s80
-rw-r--r--ports/sysdeps/vax/strpbrk.s64
-rw-r--r--ports/sysdeps/vax/strrchr.s112
-rw-r--r--ports/sysdeps/vax/strsep.s81
-rw-r--r--ports/sysdeps/vax/strspn.s66
-rw-r--r--ports/sysdeps/vax/strstr.s109
-rw-r--r--ports/sysdeps/vax/sub_n.s48
-rw-r--r--ports/sysdeps/vax/submul_1.s126
-rw-r--r--ports/sysdeps/z8000/add_n.s53
-rw-r--r--ports/sysdeps/z8000/gmp-mparam.h27
-rw-r--r--ports/sysdeps/z8000/mul_1.s68
-rw-r--r--ports/sysdeps/z8000/sub_n.s54
1635 files changed, 90163 insertions, 0 deletions
diff --git a/ports/.cvsignore b/ports/.cvsignore
new file mode 100644
index 000000000..613f66d7a
--- /dev/null
+++ b/ports/.cvsignore
@@ -0,0 +1 @@
+glibc-ports-*.tar* glibc-port-*.tar*
diff --git a/ports/Banner b/ports/Banner
new file mode 100644
index 000000000..6b9c1f0b4
--- /dev/null
+++ b/ports/Banner
@@ -0,0 +1 @@
+Support for some architectures added on, not maintained in glibc core.
diff --git a/ports/ChangeLog b/ports/ChangeLog
new file mode 100644
index 000000000..fcd20111f
--- /dev/null
+++ b/ports/ChangeLog
@@ -0,0 +1,43 @@
+2006-03-06 Roland McGrath <roland@redhat.com>
+
+ * Makefile (%.bz2, %.gz): New pattern rules.
+
+2006-02-28 Roland McGrath <roland@redhat.com>
+
+ * Makefile (glibc-port-%-$(dist-version).tar): Don't include top-level
+ stuff.
+
+ * README: Update for new add-on scheme.
+
+2006-02-27 Roland McGrath <roland@redhat.com>
+
+ * Makefile: Remove libc boilerplate.
+ * Makeconfig: File removed.
+ * configure.in: File removed.
+ * configure: File removed.
+
+2005-03-22 Roland McGrath <roland@redhat.com>
+
+ * Makefile ($(distname).tar): Fail if sysdeps/.../configure files are
+ not all up to date. Touch configure files after cvs export.
+ (glibc-port-%-$(dist-version).tar): Likewise.
+
+2004-10-22 Roland McGrath <roland@frob.com>
+
+ * Makefile (dist, dist-ports): New target.
+ (dist-port-%): New pattern rule.
+ * Makeconfig [!subdir] (ports/%): New pattern rule.
+
+ * configure.in: Cope if there are no sysdeps/*/preconfigure files.
+ * configure: Regenerated.
+
+2004-08-16 Roland McGrath <roland@frob.com>
+
+ * Makefile: New file.
+
+2004-08-04 Roland McGrath <roland@frob.com>
+
+ New directory implementing glibc add-on infrastructure for
+ ports maintained separate from the core glibc source tree.
+ * README, configure.in, Makeconfig, Banner, ChangeLog: New files.
+ * configure: New generated file.
diff --git a/ports/ChangeLog.aix b/ports/ChangeLog.aix
new file mode 100644
index 000000000..5305d338d
--- /dev/null
+++ b/ports/ChangeLog.aix
@@ -0,0 +1,6 @@
+2005-12-27 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/aix/bits/setjmp.h (_JMPBUF_UNWINDS): Take third
+ argument DEMANGLE, and pass SP value through it.
+
+ * sysdeps/unix/sysv/aix/powerpc/memset.c: Don't use sysdeps/generic.
diff --git a/ports/ChangeLog.am33 b/ports/ChangeLog.am33
new file mode 100644
index 000000000..f794cc55d
--- /dev/null
+++ b/ports/ChangeLog.am33
@@ -0,0 +1,242 @@
+2006-01-12 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/am33/jmpbuf-unwind.h: Include <jmpbuf-offsets.h>.
+
+2006-01-10 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/am33/bits/setjmp.h (__JMP_BUF_SP): Macro moved ...
+ * sysdeps/am33/jmpbuf-offsets.h: ... here, new file.
+
+ * sysdeps/am33/bits/setjmp.h (_JMPBUF_UNWINDS, __JMP_BUF_SP):
+ Move macros ...
+ * sysdeps/am33/jmpbuf-unwind.h: ... here, new file.
+
+2005-12-27 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/am33/bits/setjmp.h (_JMPBUF_UNWINDS): Take third argument
+ DEMANGLE, and pass SP value through it.
+
+2004-10-25 Alexandre Oliva <aoliva@redhat.com>
+
+ * ChangeLog.am33: Added emacs local variables for mode setting and
+ default changelog name.
+
+ * sysdeps/unix/sysv/linux/linuxthreads/sysdep-cancel.h: Moved...
+ * sysdeps/unix/sysv/linux/am33/linuxthreads/sysdep-cancel.h:
+ ... here, where it should have been added in the first place.
+
+2004-10-22 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/unix/sysv/linux/am33/bits/mman.h (PROT_GROWSDOWN): New.
+ (PROT_GROWSUP): New.
+
+2004-08-16 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/am33/shlib-versions: Moved from top level.
+
+2004-08-09 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/am33/preconfigure: Renamed from configure.
+ * Makefile: Removed.
+
+2004-07-20 Alexandre Oliva <aoliva@redhat.com>
+
+ Moved from separate linuxthreads tree into am33/linuxthreads
+ subdirs:
+ 2004-07-01 Alexandre Oliva <aoliva@redhat.com>
+ * sysdeps/unix/sysv/linux/am33/linuxthreads/sysdep-cancel.h
+ (PSEUDO): Save value returned by CENABLE and pass it to CDISABLE.
+ * sysdeps/am33/linuxthreads/pt-machine.h (testandset): Take
+ volatile argument. Improve asm statement.
+ 2001-10-31 Alexandre Oliva <aoliva@redhat.com>
+ * sysdeps/am33/linuxthreads/pspinlock.c: New file.
+ * sysdeps/am33/linuxthreads/pt-machine.h: New file.
+
+2004-07-19 Alexandre Oliva <aoliva@redhat.com>
+
+ * configure: New.
+ * mach.sh: Removed.
+ * sysdeps/am33/Makefile: Likewise.
+
+2004-06-28 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/am33/Makefile: New file.
+ * sysdeps/unix/sysv/linux/am33/configure.in: New file.
+ * sysdeps/unix/sysv/linux/am33/configure: New file.
+ * mach.sh: New file.
+
+2004-06-19 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/am33/fpu/bits/fenv.h: New file.
+ * sysdeps/am33/fpu/fpu_control.h: New file.
+ * sysdeps/am33/fpu/fenv_libc.h: New file.
+ * sysdeps/am33/fpu/fclrexcpt.c: New file.
+ * sysdeps/am33/fpu/fedisblxcpt.c: New file.
+ * sysdeps/am33/fpu/feenablxcpt.c: New file.
+ * sysdeps/am33/fpu/fegetenv.c: New file.
+ * sysdeps/am33/fpu/fegetexcept.c: New file.
+ * sysdeps/am33/fpu/fegetround.c: New file.
+ * sysdeps/am33/fpu/feholdexcpt.c: New file.
+ * sysdeps/am33/fpu/fesetenv.c: New file.
+ * sysdeps/am33/fpu/fesetround.c: New file.
+ * sysdeps/am33/fpu/feupdateenv.c: New file.
+ * sysdeps/am33/fpu/fgetexcptflg.c: New file.
+ * sysdeps/am33/fpu/fraiseexcpt.c: New file.
+ * sysdeps/am33/fpu/fsetexcptflg.c: New file.
+ * sysdeps/am33/fpu/ftestexcept.c: New file.
+
+ * sysdeps/unix/am33/sysdep.h: Use relative pathnames.
+ * sysdeps/unix/sysv/linux/am33/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/am33/sysdep.S: Likewise.
+ * configure, Makefile: Do nothing.
+
+2004-06-09 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/am33/bsd-setjmp.S: Move into...
+ * sysdeps/am33/setjmp.S: ... this file.
+ * sysdeps/am33/bsd-_setjmp.S: Likewise.
+ * sysdeps/am33/dl-machine.h (_dl_start_user): Do not do double
+ indirection to obtain _dl_loaded.
+ (elf_machine_rela_relative): Do not add addend.
+
+2004-06-08 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/am33/sysdep.h (JUMPTARGET): Undef before redefining.
+ * sysdeps/unix/sysv/linux/am33/sysdep.h (PSEUDO_NOERROR,
+ PSEUDO_END_NOERROR, ret_NOERROR, PSEUDO_ERRVAL, PSEUDO_END_ERRVAL,
+ ret_ERRVAL, INTERNAL_SYSCALL, INTERNAL_SYSCALL_DECL,
+ INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New.
+ (INLINE_SYSCALL): Rewrite in terms of INTERNAL_SYSCALL macros.
+ (DO_CALL): Reorder arguments.
+ * sysdeps/am33/dl-machine.h (elf_machine_rela): Update prototype.
+
+2003-05-16 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/unix/sysv/linux/am33/Makefile: New file.
+ * sysdeps/unix/sysv/linux/am33/sysdep.h (INLINE_SYSCALL1): Drop
+ comma before args when calling inline_syscall0.
+ * sysdeps/unix/sysv/linux/am33/chown.c: New file.
+ * sysdeps/unix/sysv/linux/am33/fchown.c: New file.
+ * sysdeps/unix/sysv/linux/am33/fxstat.c: New file.
+ * sysdeps/unix/sysv/linux/am33/getegid.c: New file.
+ * sysdeps/unix/sysv/linux/am33/geteuid.c: New file.
+ * sysdeps/unix/sysv/linux/am33/getgid.c: New file.
+ * sysdeps/unix/sysv/linux/am33/getrlimit.c: New file.
+ * sysdeps/unix/sysv/linux/am33/getuid.c: New file.
+ * sysdeps/unix/sysv/linux/am33/lchown.c: New file.
+ * sysdeps/unix/sysv/linux/am33/lockf64.c: New file.
+ * sysdeps/unix/sysv/linux/am33/lxstat.c: New file.
+ * sysdeps/unix/sysv/linux/am33/setegid.c: New file.
+ * sysdeps/unix/sysv/linux/am33/seteuid.c: New file.
+ * sysdeps/unix/sysv/linux/am33/setfsgid.c: New file.
+ * sysdeps/unix/sysv/linux/am33/setfsuid.c: New file.
+ * sysdeps/unix/sysv/linux/am33/setgid.c: New file.
+ * sysdeps/unix/sysv/linux/am33/setregid.c: New file.
+ * sysdeps/unix/sysv/linux/am33/setresgid.c: New file.
+ * sysdeps/unix/sysv/linux/am33/setresuid.c: New file.
+ * sysdeps/unix/sysv/linux/am33/setreuid.c: New file.
+ * sysdeps/unix/sysv/linux/am33/setrlimit.c: New file.
+ * sysdeps/unix/sysv/linux/am33/setuid.c: New file.
+ * sysdeps/unix/sysv/linux/am33/xstat.c: New file.
+ * sysdeps/unix/sysv/linux/am33/syscalls.list: Removed, reverting
+ 2003-03-26's patch.
+ * sysdeps/unix/sysv/linux/am33/getresgid.c: New file.
+ * sysdeps/unix/sysv/linux/am33/getresuid.c: New file.
+
+2003-05-09 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/unix/sysv/linux/am33/getgroups.c: New file.
+ * sysdeps/unix/sysv/linux/am33/setgroups.c: New file.
+
+2003-05-07 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/unix/sysv/linux/am33/getmsg.c: New file.
+ * sysdeps/unix/sysv/linux/am33/putmsg.c: New file.
+
+2003-03-26 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/unix/sysv/linux/am33/syscalls.list: Added getresuid and
+ getresgid.
+
+2003-01-17 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/unix/sysv/linux/am33/fcntl.c: New file.
+
+2002-02-08 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/am33/sys/ucontext.h (fpregset_t): Make it a structure.
+
+2002-01-07 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/am33/sys/ucontext.h (NFREG): Increment by 1, to make
+ room for FPCR.
+
+2001-12-13 Alexandre Oliva <aoliva@redhat.com>
+
+ * shlib-versions: Set GLIBC_2.2.5 as the earliest symbol set.
+
+2001-12-07 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/am33/__longjmp.S: Tabify.
+ * sysdeps/am33/setjmp.S: Likewise.
+ * sysdeps/am33/dl-debug.h: Remove.
+ * sysdeps/am33/dl-machine.h: Delete commented-out uses of
+ macros defined in dl-debug.
+ (elf_machine_rela): Optimize if HAVE_Z_COMBRELOC. Fix
+ prediction of R_MN10300_NONE. Don't test for impossible
+ condition.
+ * sysdeps/am33/sysdep.h (ASM_TYPE_DIRECTIVE,
+ ASM_SIZE_DIRECTIVE): Define to nothing if ! HAVE_ELF.
+
+2001-11-09 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/unix/sysv/linux/am33/clone.S: Avoid branch overflow in
+ static link.
+
+2001-11-08 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/unix/sysv/linux/am33/clone.S: Load arguments correctly
+ for syscall.
+
+2001-11-07 Alexandre Oliva <aoliva@redhat.com>
+
+ * sysdeps/unix/sysv/linux/am33/clone.S: Fix argument-passing
+ to thread_start.
+
+2001-10-31 Alexandre Oliva <aoliva@redhat.com>
+
+ * shlib-versions: Added am33_2.0 support.
+ * sysdeps/am33/Implies: New file.
+ * sysdeps/am33/__longjmp.S: New file.
+ * sysdeps/am33/atomicity.h: New file.
+ * sysdeps/am33/bsd-_setjmp.S: New file.
+ * sysdeps/am33/bsd-setjmp.S: New file.
+ * sysdeps/am33/dl-debug.h: New file.
+ * sysdeps/am33/dl-machine.h: New file.
+ * sysdeps/am33/memusage.h: New file.
+ * sysdeps/am33/setjmp.S: New file.
+ * sysdeps/am33/stackinfo.h: New file.
+ * sysdeps/am33/sysdep.h: New file.
+ * sysdeps/am33/bits/endian.h: New file.
+ * sysdeps/am33/bits/setjmp.h: New file.
+ * sysdeps/am33/elf/start.S: New file.
+ * sysdeps/am33/sys/ucontext.h: New file.
+ * sysdeps/unix/am33/sysdep.S: New file.
+ * sysdeps/unix/am33/sysdep.h: New file.
+ * sysdeps/unix/sysv/linux/am33/brk.c: New file.
+ * sysdeps/unix/sysv/linux/am33/clone.S: New file.
+ * sysdeps/unix/sysv/linux/am33/profil-counter.h: New file.
+ * sysdeps/unix/sysv/linux/am33/socket.S: New file.
+ * sysdeps/unix/sysv/linux/am33/syscall.S: New file.
+ * sysdeps/unix/sysv/linux/am33/sysdep.S: New file.
+ * sysdeps/unix/sysv/linux/am33/sysdep.h: New file.
+ * sysdeps/unix/sysv/linux/am33/bits/fcntl.h: New file.
+ * sysdeps/unix/sysv/linux/am33/bits/mman.h: New file.
+
+Local Variables:
+mode: change-log
+left-margin: 8
+fill-column: 74
+version-control: never
+change-log-default-name: "ChangeLog.am33"
+End:
diff --git a/ports/ChangeLog.arm b/ports/ChangeLog.arm
new file mode 100644
index 000000000..9b0cd77a7
--- /dev/null
+++ b/ports/ChangeLog.arm
@@ -0,0 +1,477 @@
+2006-08-04 Daniel Jacobowitz <dan@codesourcery.com>
+
+ Reported by Joseph Myers <joseph@codesourcery.com>:
+ * sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h (FUTEX_LOCK_PI,
+ FUTEX_UNLOCK_PI, FUTEX_TRYLOCK_PI): Define.
+
+2006-07-24 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/sigaction.c: If WRAPPER_INCLUDE is
+ defined, include the named file.
+
+2006-07-05 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/sys/ucontext.h: Include
+ <bits/sigcontext.h>.
+ (NGREG, mcontext_t, struct ucontext): Update to match the kernel.
+
+2006-07-05 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/arm/dl-machine.h (elf_machine_dynamic): Correct GOT access to
+ load the _DYNAMIC slot.
+
+2006-06-08 Mark Shinwell <shinwell@codesourcery.com>
+
+ * sysdeps/arm/nptl/pthreaddef.h (CURRENT_STACK_FRAME): Add -12.
+
+2006-06-08 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/bits/fcntl.h: Reformat.
+ (SPLICE_F_MOVE, SPLICE_F_NONBLOCK, SPLICE_F_MORE, SPLICE_F_GIFT):
+ Define.
+
+2006-05-30 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/arm/initfini.c: New file.
+
+2006-05-30 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/arm/dl-machine.h (elf_machine_dynamic): Rewrite to load
+ _GLOBAL_OFFSET_TABLE_ explicitly.
+
+2006-05-30 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/kernel-features.h: Add conditionals
+ for __ASSUME_TRUNCATE64_SYSCALL, __ASSUME_MMAP2_SYSCALL,
+ __ASSUME_STAT64_SYSCALL, __ASSUME_FCNTL64, and
+ __ASSUME_VFORK_SYSCALL.
+
+2006-05-05 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/bits/mman.h: Update error message
+ for consistency with other ports.
+ (MADV_REMOVE, MADV_DONTFORK, MADV_DOFORK): Define.
+
+2006-05-05 Lior Balkohen <balkohen@gmail.com>
+
+ * sysdeps/unix/sysv/linux/arm/bits/fcntl.h: Remove
+ LINUX_FADV_ASYNC_WRITE and LINUX_FADV_WRITE_WAIT.
+ Define SYNC_FILE_RANGE_WAIT_BEFORE, SYNC_FILE_RANGE_WRITE
+ and SYNC_FILE_RANGE_WAIT_AFTER.
+ Declare sync_file_range, vmsplice, splice and tee.
+
+2006-03-27 Lior Balkohen <balkohen@gmail.com>
+
+ * sysdeps/unix/sysv/linux/arm/bits/fcntl.h: Define
+ LINUX_FADV_ASYNC_WRITE and LINUX_FADV_WRITE_WAIT.
+
+2006-03-21 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/eabi/socket.S: Delete.
+ * sysdeps/unix/sysv/linux/arm/eabi/syscalls.list,
+ sysdeps/unix/sysv/linux/arm/kernel-features.h,
+ sysdeps/unix/sysv/linux/arm/eabi/umount.c: New files.
+ * sysdeps/unix/sysv/linux/arm/eabi/linuxthreads/sysdep-cancel.h
+ (DOCARGS_6, UNDOCARGS_6, RESTORE_LR_6): Define.
+ * sysdeps/unix/sysv/linux/arm/eabi/nptl/sysdep-cancel.h
+ (DOCARGS_6, UNDOCARGS_6, RESTORE_LR_6): Define.
+ * sysdeps/unix/sysv/linux/arm/eabi/sysdep.h: Undefine
+ __NR_stime and __NR_alarm.
+
+2006-03-02 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/linuxthreads/sysdep-cancel.h
+ (PSEUDO): Inline correct versions of PSEUDO_RET_MOV and MAYBE_SAVE_LR.
+ (PSEUDO_RET_MOV, MAYBE_SAVE_LR): Don't define.
+
+2006-03-02 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/eabi/Makefile (arm-using-eabi): Set.
+ * sysdeps/unix/sysv/linux/arm/nptl/Makefile: New file.
+
+2006-02-28 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/arm/sysdep.h, sysdeps/unix/sysv/linux/arm/sysdep.S,
+ sysdeps/unix/sysv/linux/arm/sysdep.h: Remove ports/ from include
+ paths.
+
+2006-02-27 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes.h
+ (struct __pthread_internal_slist): New.
+ (union pthread_mutex_t): Give struct a tag. Add __list
+ in an anonymous union.
+ (union pthread_cond_t): Use __extension__.
+ * sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h
+ (__lll_mutex_lock_outlined, __lll_mutex_timedlock_outlined): Remove
+ prototypes.
+ (lll_robust_mutex_dead, __lll_robust_mutex_trylock,
+ lll_robust_mutex_trylock, __lll_robust_mutex_lock,
+ lll_robust_mutex_lock, lll_robust_mutex_cond_lock,
+ __lll_robust_mutex_timedlock, lll_robust_mutex_timedlock,
+ __lll_robust_mutex_unlock, lll_robust_mutex_unlock): New.
+ (__lll_robust_lock_wait, __lll_robust_timedlock_wait): New
+ prototypes.
+
+2006-02-27 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/eabi/ftruncate64.c: Don't use
+ sysdeps/generic/.
+ * sysdeps/unix/sysv/linux/arm/eabi/truncate64.c: Likewise.
+
+2006-01-12 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/arm/jmpbuf-unwind.h: Include <jmpbuf-offsets.h>.
+
+2006-01-10 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/arm/bits/setjmp.h (__JMP_BUF_SP): Macro moved to ...
+ * sysdeps/arm/jmpbuf-offsets.h: ... here, new file.
+ * sysdeps/arm/fpu/bits/setjmp.h: (__JMP_BUF_SP): Macro moved to ...
+ * sysdeps/arm/fpu/jmpbuf-offsets.h: ... here, new file.
+ * sysdeps/arm/eabi/bits/setjmp.h (__JMP_BUF_SP): Macro removed.
+
+ * sysdeps/arm/bits/setjmp.h (_JMPBUF_UNWINDS): Move macro ...
+ * sysdeps/arm/jmpbuf-unwind.h: ... here.
+ * sysdeps/arm/fpu/bits/setjmp.h (_JMPBUF_UNWINDS): Macro removed.
+ * sysdeps/arm/eabi/bits/setjmp.h (_JMPBUF_UNWINDS): Macro removed.
+
+ * sysdeps/arm/nptl/jmpbuf-unwind.h: Moved to ...
+ * sysdeps/arm/jmpbuf-unwind.h: ... here.
+
+2005-12-27 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/arm/eabi/bits/setjmp.h (_JMPBUF_UNWINDS): Take third argument
+ DEMANGLE, and pass SP value through it.
+ * sysdeps/arm/bits/setjmp.h (_JMPBUF_UNWINDS): Likewise.
+ * sysdeps/arm/fpu/bits/setjmp.h (_JMPBUF_UNWINDS): Likewise.
+
+2005-12-15 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/arm/libc-tls.c: Use csu/ instead of sysdeps/generic/.
+
+2005-11-16 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/nptl/sysdep-cancel.h,
+ sysdeps/unix/sysv/linux/arm/nptl/unwind-forcedunwind.c,
+ sysdeps/unix/sysv/linux/arm/nptl/unwind-resume.c,
+ sysdeps/unix/sysv/linux/arm/nptl/unwind.h,
+ sysdeps/arm/unwind-dw2-fde-glibc.c,
+ sysdeps/arm/unwind-pe.c, sysdeps/arm/framestate.c: New files.
+
+2005-11-16 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/arm/bits/setjmp.h, sysdeps/arm/fpu/bits/setjmp.h: Update
+ include guards.
+
+ * sysdeps/unix/arm/sysdep.S (syscall_error): Handle USE___THREAD and
+ RTLD_PRIVATE_ERRNO.
+
+ * sysdeps/unix/sysv/linux/arm/clone.S (__clone): Handle RESET_PID.
+ Handle new arguments.
+ * sysdeps/unix/sysv/linux/arm/vfork.S (__vfork): Use SAVE_PID and
+ RESTORE_PID. Use the right syscall error handler.
+
+ * sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S
+ (__default_sa_restorer, __default_rt_sa_restorer): Add unwind
+ information.
+
+ * sysdeps/unix/sysv/linux/arm/eabi/socket.S: Update formatting.
+ Add unwind information. Correct stack alignment typo.
+
+ * sysdeps/unix/sysv/linux/arm/eabi/sysdep.h
+ (INTERNAL_SYSCALL_NCS): Define.
+
+ * sysdeps/unix/sysv/linux/arm/sigaction.c
+ (__libc_sigaction): Remove never-valid handling for SA_ONSTACK.
+
+ * sysdeps/unix/sysv/linux/arm/socket.S: Whitespace cleanup.
+
+ * sysdeps/unix/sysv/linux/arm/sysdep.h (SYSCALL_ERROR_HANDLER): Handle
+ RTLD_PRIVATE_ERRNO.
+ (INTERNAL_SYSCALL_NCS): Implement.
+
+ * sysdeps/arm/nptl/Makefile, sysdeps/arm/nptl/jmpbuf-unwind.h,
+ sysdeps/arm/nptl/pthread_spin_lock.S,
+ sysdeps/arm/nptl/pthread_spin_trylock.S,
+ sysdeps/arm/nptl/pthreaddef.h, sysdeps/arm/nptl/tcb-offsets.sym,
+ sysdeps/arm/nptl/tls.h, sysdeps/unix/sysv/linux/arm/eabi/Makefile,
+ sysdeps/unix/sysv/linux/arm/eabi/nptl/Makefile,
+ sysdeps/unix/sysv/linux/arm/eabi/nptl/configure,
+ sysdeps/unix/sysv/linux/arm/eabi/nptl/configure.in,
+ sysdeps/unix/sysv/linux/arm/eabi/nptl/nptl-aeabi_unwind_cpp_pr1.c,
+ sysdeps/unix/sysv/linux/arm/eabi/nptl/rt-aeabi_unwind_cpp_pr1.c,
+ sysdeps/unix/sysv/linux/arm/eabi/nptl/sysdep-cancel.h,
+ sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c,
+ sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c,
+ sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind.h,
+ sysdeps/unix/sysv/linux/arm/nptl/Versions,
+ sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h,
+ sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes.h,
+ sysdeps/unix/sysv/linux/arm/nptl/clone.S,
+ sysdeps/unix/sysv/linux/arm/nptl/createthread.c,
+ sysdeps/unix/sysv/linux/arm/nptl/fork.c,
+ sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.c,
+ sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h,
+ sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S,
+ sysdeps/unix/sysv/linux/arm/nptl/pthread_once.c,
+ sysdeps/unix/sysv/linux/arm/nptl/vfork.S: New files.
+
+2005-11-16 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/arm/dl-machine.h (CLEAR_CACHE): Use INTERNAL_SYSCALL_ARM.
+ * sysdeps/unix/sysv/linux/arm/brk.c (__brk): Use INLINE_SYSCALL.
+ * sysdeps/unix/sysv/linux/arm/clone.S (__clone): Use DO_CALL.
+ * sysdeps/unix/sysv/linux/arm/eabi/configure.in: Bump
+ arch_minimum_kernel.
+ * sysdeps/unix/sysv/linux/arm/eabi/configure: Regenerated.
+ * sysdeps/unix/sysv/linux/arm/eabi/epoll_ctl.c,
+ sysdeps/unix/sysv/linux/arm/eabi/epoll_wait.c,
+ sysdeps/unix/sysv/linux/arm/eabi/fcntl.c,
+ sysdeps/unix/sysv/linux/arm/eabi/fstatfs64.c,
+ sysdeps/unix/sysv/linux/arm/eabi/ftruncate64.c,
+ sysdeps/unix/sysv/linux/arm/eabi/fxstat64.c,
+ sysdeps/unix/sysv/linux/arm/eabi/kernel_epoll.h,
+ sysdeps/unix/sysv/linux/arm/eabi/kernel_stat.h,
+ sysdeps/unix/sysv/linux/arm/eabi/lockf64.c,
+ sysdeps/unix/sysv/linux/arm/eabi/lxstat64.c,
+ sysdeps/unix/sysv/linux/arm/eabi/semop.c,
+ sysdeps/unix/sysv/linux/arm/eabi/semtimedop.c,
+ sysdeps/unix/sysv/linux/arm/eabi/statfs64.c,
+ sysdeps/unix/sysv/linux/arm/eabi/syscalls.list,
+ sysdeps/unix/sysv/linux/arm/eabi/uname.c,
+ sysdeps/unix/sysv/linux/arm/eabi/xstat64.c,
+ sysdeps/unix/sysv/linux/arm/eabi/xstatconv.c,
+ sysdeps/unix/sysv/linux/arm/eabi/xstatconv.h: Removed.
+ * sysdeps/unix/sysv/linux/arm/eabi/linuxthreads/sysdep-cancel.h,
+ sysdeps/unix/sysv/linux/arm/eabi/mmap64.S,
+ sysdeps/unix/sysv/linux/arm/eabi/pread.c,
+ sysdeps/unix/sysv/linux/arm/eabi/pread64.c,
+ sysdeps/unix/sysv/linux/arm/eabi/pwrite.c,
+ sysdeps/unix/sysv/linux/arm/eabi/pwrite64.c,
+ sysdeps/unix/sysv/linux/arm/eabi/readahead.c,
+ sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S,
+ sysdeps/unix/sysv/linux/arm/eabi/socket.S,
+ sysdeps/unix/sysv/linux/arm/eabi/syscall.S,
+ sysdeps/unix/sysv/linux/arm/eabi/sysdep.h,
+ sysdeps/unix/sysv/linux/arm/eabi/truncate64.c: New files.
+ * sysdeps/unix/sysv/linux/arm/linuxthreads/sysdep-cancel.h
+ (SINGLE_THREAD_P_INT, SINGLE_THREAD_P_PIC): Removed.
+ (SINGLE_THREAD_P): Rewritten to use only ip.
+ * sysdeps/unix/sysv/linux/arm/linuxthreads/vfork.S (__vfork): Use
+ DO_CALL.
+ * sysdeps/unix/sysv/linux/arm/mmap.S (__mmap): Use DO_CALL.
+ * sysdeps/unix/sysv/linux/arm/mmap64.S (__mmap64): Use DO_CALL.
+ Don't handle EABI here.
+ * sysdeps/unix/sysv/linux/arm/socket.S (__socket): Use
+ SINGLE_THREAD_P.
+ * sysdeps/unix/sysv/linux/arm/vfork.S (__vfork): Use DO_CALL.
+
+2005-11-03 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S: Add LGPL exception.
+
+2005-10-31 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/arm/eabi/aeabi_lcsts.c, sysdeps/arm/eabi/aeabi_math.c,
+ sysdeps/arm/eabi/aeabi_sighandlers.S: Add LGPL exception.
+
+2005-10-31 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/arm/eabi/Makefile (static-only-routines): Remove
+ $(aeabi_routines).
+ * sysdeps/arm/eabi/Versions (GLIBC_2.4): Add ARM EABI portability
+ routines.
+ * sysdeps/arm/eabi/aeabi_assert.c, sysdeps/arm/eabi/aeabi_atexit.c,
+ sysdeps/arm/eabi/aeabi_errno_addr.c,
+ sysdeps/arm/eabi/aeabi_localeconv.c,
+ sysdeps/arm/eabi/aeabi_mb_cur_max.c, sysdeps/arm/eabi/aeabi_memclr.c,
+ sysdeps/arm/eabi/aeabi_memcpy.c, sysdeps/arm/eabi/aeabi_memmove.c,
+ sysdeps/arm/eabi/aeabi_memset.c: Remove attribute_hidden.
+
+2005-10-31 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/bits/mman.h (MREMAP_FIXED): Define.
+
+2005-10-27 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/socket.S: Honor NO_WEAK_ALIAS.
+
+2005-10-10 Daniel Jacobowitz <dan@codesourcery.com>
+ Joseph Myers <joseph@codesourcery.com>
+ Julian Brown <julian@codesourcery.com>
+ Mark Mitchell <mark@codesourcery.com>
+ Paul Brook <paul@codesourcery.com>
+
+ * sysdeps/arm/dl-machine.h (_dl_start_user): Preserve eight-byte
+ stack alignment.
+
+ * sysdeps/arm/elf/start.S (_start): Add unwind markers for EABI
+ targets.
+
+ * sysdeps/arm/preconfigure: Set machine for EABI targets. Remove
+ obsolete Thumb support.
+
+ * sysdeps/arm/shlib-versions: Add EABI support.
+
+ * sysdeps/unix/sysv/linux/arm/mmap64.S (__mmap64): Allow for padding
+ in the argument list for EABI targets.
+
+ * sysdeps/arm/fpu/feholdexcpt.c, sysdeps/arm/fpu/fesetround.c: Add
+ libm_hidden_def.
+
+ * sysdeps/arm/dl-sysdep.h, sysdeps/arm/eabi/Makefile,
+ sysdeps/arm/eabi/Versions, sysdeps/arm/eabi/__longjmp.S,
+ sysdeps/arm/eabi/aeabi_assert.c, sysdeps/arm/eabi/aeabi_atexit.c,
+ sysdeps/arm/eabi/aeabi_errno_addr.c, sysdeps/arm/eabi/aeabi_lcsts.c,
+ sysdeps/arm/eabi/aeabi_localeconv.c, sysdeps/arm/eabi/aeabi_math.c,
+ sysdeps/arm/eabi/aeabi_mb_cur_max.c, sysdeps/arm/eabi/aeabi_memclr.c,
+ sysdeps/arm/eabi/aeabi_memcpy.c, sysdeps/arm/eabi/aeabi_memmove.c
+ sysdeps/arm/eabi/aeabi_memset.c, sysdeps/arm/eabi/aeabi_sighandlers.S,
+ sysdeps/arm/eabi/aeabi_unwind_cpp_pr1.c, sysdeps/arm/eabi/bits/fenv.h,
+ sysdeps/arm/eabi/bits/huge_val.h, sysdeps/arm/eabi/bits/setjmp.h,
+ sysdeps/arm/eabi/fclrexcpt.c, sysdeps/arm/eabi/fedisblxcpt.c,
+ sysdeps/arm/eabi/feenablxcpt.c, sysdeps/arm/eabi/fegetenv.c,
+ sysdeps/arm/eabi/fegetexcept.c, sysdeps/arm/eabi/fegetround.c,
+ sysdeps/arm/eabi/feholdexcpt.c, sysdeps/arm/eabi/fesetenv.c,
+ sysdeps/arm/eabi/fesetround.c, sysdeps/arm/eabi/find_exidx.c,
+ sysdeps/arm/eabi/fpu_control.h, sysdeps/arm/eabi/fraiseexcpt.c,
+ sysdeps/arm/eabi/fsetexcptflg.c, sysdeps/arm/eabi/ftestexcept.c,
+ sysdeps/arm/eabi/setjmp.S, sysdeps/unix/sysv/linux/arm/eabi/configure,
+ sysdeps/arm/eabi/rtld-global-offsets.sym, sysdeps/arm/eabi/setfpucw.c,
+ sysdeps/unix/sysv/linux/arm/eabi/configure.in,
+ sysdeps/unix/sysv/linux/arm/eabi/epoll_ctl.c,
+ sysdeps/unix/sysv/linux/arm/eabi/epoll_wait.c,
+ sysdeps/unix/sysv/linux/arm/eabi/fcntl.c,
+ sysdeps/unix/sysv/linux/arm/eabi/fstatfs64.c,
+ sysdeps/unix/sysv/linux/arm/eabi/fxstat64.c,
+ sysdeps/unix/sysv/linux/arm/eabi/kernel_epoll.h,
+ sysdeps/unix/sysv/linux/arm/eabi/kernel_stat.h,
+ sysdeps/unix/sysv/linux/arm/eabi/lockf64.c,
+ sysdeps/unix/sysv/linux/arm/eabi/lxstat64.c,
+ sysdeps/unix/sysv/linux/arm/eabi/oldgetrlimit.c,
+ sysdeps/unix/sysv/linux/arm/eabi/oldsetrlimit.c,
+ sysdeps/unix/sysv/linux/arm/eabi/semop.c,
+ sysdeps/unix/sysv/linux/arm/eabi/semtimedop.c,
+ sysdeps/unix/sysv/linux/arm/eabi/statfs64.c,
+ sysdeps/unix/sysv/linux/arm/eabi/syscalls.list,
+ sysdeps/unix/sysv/linux/arm/eabi/uname.c,
+ sysdeps/unix/sysv/linux/arm/eabi/xstat64.c,
+ sysdeps/unix/sysv/linux/arm/eabi/xstatconv.c,
+ sysdeps/unix/sysv/linux/arm/eabi/xstatconv.h: New files.
+
+2005-10-10 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/arm/memset.S (memset): Correct handling of negative
+ arguments.
+
+2005-10-10 Philip Blundell <philb@gnu.org>
+
+ * sysdeps/arm/Makefile, sysdeps/arm/machine-gmon.h,
+ sysdeps/arm/_mcount.S: Revert previous bogus changes.
+
+2005-10-10 Philip Blundell <philb@gnu.org>
+
+ * sysdeps/arm/_mcount.S: Suppress profiling when building this
+ file.
+
+2005-10-09 Phil Blundell <pb@reciva.com>
+
+ * sysdeps/arm/Makefile [subdir=gmon] (sysdep_routines): Add
+ _mcount.
+ * sysdeps/arm/machine-gmon.h (MCOUNT): Replace with empty
+ definition.
+ (_MCOUNT_DECL): Make linkage global.
+ * sysdeps/arm/_mcount.S: New file.
+
+2005-10-09 Phil Blundell <pb@reciva.com>
+
+ * sysdeps/arm/dl-trampoline.S: [PROF] (_dl_runtime_profile):
+ Don't compile. Correct cut'n'paste error with .size.
+
+2005-10-05 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/posix_fadvise.c,
+ sysdeps/unix/sysv/linux/arm/posix_fadvise64.c: New files.
+
+2005-10-05 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/arm/dl-machine.h: Include <tls.h>.
+ (elf_machine_type_class, elf_machine_rel, elf_machine_rela): Handle
+ TLS relocations.
+ * sysdeps/unix/sysv/linux/arm/Makefile: Build __aeabi_read_tp.
+ * sysdeps/unix/sysv/linux/arm/sysdep.h (INTERNAL_SYSCALL_RAW): Renamed
+ from INTERNAL_SYSCALL.
+ (INTERNAL_SYSCALL, INTERNAL_SYSCALL_ARM): New macros.
+ * sysdeps/arm/dl-tls.h, sysdeps/arm/elf/configure.in,
+ sysdeps/arm/elf/configure, sysdeps/arm/libc-tls.c,
+ sysdeps/arm/linuxthreads/tls.h, sysdeps/arm/tls-macros.h,
+ sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S,
+ sysdeps/unix/sysv/linux/arm/libc-aeabi_read_tp.S: New files.
+
+2005-10-05 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/arm/atomicity.h: Delete.
+ * sysdeps/arm/bits/atomic.h: New file.
+
+2005-10-05 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/arm/dl-machine.h (ARCH_LA_PLTENTER,
+ ARCH_LA_PLTEXIT): Define.
+ * sysdeps/arm/ldsodefs.h, sysdeps/arm/tst-audit.h: New files.
+
+2005-06-13 Philip Blundell <philb@gnu.org>
+
+ Patch from addsub@eyou.com:
+ * sysdeps/arm/ieee754.h: Deleted.
+ * sysdeps/arm/gmp-mparam.h: Support VFP and big endian.
+ * sysdeps/arm/bits/endian.h: Likewise.
+
+2005-06-11 Phil Blundell <pb@reciva.com>
+
+ * sysdeps/arm/init-first.c: Deleted.
+ * sysdeps/unix/sysv/linux/arm/linuxthreads/fork.c: New file.
+
+2005-06-10 Phil Blundell <pb@reciva.com>
+
+ Bug #957:
+ * sysdeps/unix/sysv/linux/arm/mmap64.S: Handle offset correctly on
+ big endian machines. Reported by Sven Henkel <shenkel@gmail.com>.
+
+2005-05-09 Daniel Jacobowitz <dan@codesourcery.com>
+ Mark Mitchell <mark@codesourcery.com>
+
+ * sysdeps/arm/bits/link.h: New file.
+ * sysdeps/arm/dl-trampoline.S: New file.
+ * sysdeps/arm/dl-machine.h: Check RESOLVE_MAP instead of RESOLVE.
+ (elf_machine_runtime_setup): Check dl_profile before calling
+ _dl_name_match_p.
+ (ELF_MACHINE_RUNTIME_TRAMPOLINE): Delete.
+ (elf_machine_rel, elf_machine_rela): Use RESOLVE_MAP.
+ (fix_bad_pc24): Use auto instead of static.
+
+2005-05-09 Daniel Jacobowitz <dan@codesourcery.com>
+ Mark Mitchell <mark@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/arm/ioperm.c (BUS_ISA): Define for new
+ kernel headers.
+
+2005-06-09 Phil Blundell <pb@reciva.com>
+
+ * sysdeps/unix/arm/sysdep.h, sysdeps/unix/sysv/linux/arm/sysdep.h,
+ sysdeps/unix/sysv/linux/arm/sysdep.S: Correct paths to included
+ files.
+
+2005-05-23 Roland McGrath <roland@redhat.com>
+
+ * ChangeLog.arm: New file (this one).
+ * sysdeps/arm, sysdeps/unix/arm, sysdeps/unix/sysv/linux/arm:
+ Subdirectories moved here from main repository.
+ * sysdeps/arm/preconfigure: New file.
+ * sysdeps/arm/shlib-versions: New file.
+
+Local Variables:
+mode: change-log
+left-margin: 8
+fill-column: 74
+End:
diff --git a/ports/ChangeLog.cris b/ports/ChangeLog.cris
new file mode 100644
index 000000000..af91a1d42
--- /dev/null
+++ b/ports/ChangeLog.cris
@@ -0,0 +1,15 @@
+2005-12-27 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/cris/bits/setjmp.h (_JMPBUF_UNWINDS): Take third argument
+ DEMANGLE, and pass SP value through it.
+
+2004-10-25 Roland McGrath <roland@frob.com>
+
+ * sysdeps/cris/configure.in: New file, with test moved out of main
+ libc configure.in file.
+ * sysdeps/cris/configure: New generated file.
+
+2004-10-23 Roland McGrath <roland@frob.com>
+
+ * sysdeps/cris, sysdeps/unix/sysv/linux/cris: Moved here from main
+ libc source tree.
diff --git a/ports/ChangeLog.hppa b/ports/ChangeLog.hppa
new file mode 100644
index 000000000..1f90c8dc2
--- /dev/null
+++ b/ports/ChangeLog.hppa
@@ -0,0 +1,193 @@
+2006-08-13 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/unix/sysv/linux/hppa/nptl/lowlevellock.h (FUTEX_LOCK_PI,
+ FUTEX_UNLOCK_PI, FUTEX_TRYLOCK_PI): Define.
+
+2006-07-24 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/unix/sysv/linux/hppa/nptl/bits/pthreadtypes.h:
+ __SIZEOF_PTHREAD_COND_T is 64 bytes. Remove __PAD_ATOMIC_LOCK_T.
+
+2006-07-18 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/hppa/nptl/pthread_spin_lock.c (pthread_spin_lock): Swap
+ newval and oldval.
+ * sysdeps/hppa/nptl/pthread_spin_trylock.c (pthread_spin_trylock):
+ Likewise.
+
+2006-07-16 Jeff Bailey <jbailey@ubuntu.com>
+
+ * sysdeps/hppa/tst-audit.h: New file.
+
+2006-07-16 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/hppa/tls-macros.h: Cleanup formatting.
+
+2006-07-15 Jeff Bailey <jbailey@ubuntu.com>
+
+ * sysdeps/hppa/nptl/tls.h (TLS_INIT_TP): Return NULL.
+
+2006-07-13 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/unix/sysv/linux/hppa/xstat.c: New file.
+ * sysdeps/unix/sysv/linux/hppa/lxstat.c: Likewise.
+ * sysdeps/unix/sysv/linux/hppa/fxstat.c: Likewise.
+ * sysdeps/unix/sysv/linux/hppa/fxstatat.c: Likewise.
+
+2006-07-13 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/hppa/nptl/Makefile: New file
+ * sysdeps/hppa/nptl/jmpbuf-unwind.h: Likewise
+ * sysdeps/hppa/nptl/pthread_spin_lock.c: Likewise
+ * sysdeps/hppa/nptl/pthread_spin_trylock.c: Likewise
+ * sysdeps/hppa/nptl/pthread_spin_unlock.c: Likewise
+ * sysdeps/hppa/nptl/pthreaddef.h: Likewise
+ * sysdeps/hppa/nptl/tcb-offsets.sym: Likewise
+ * sysdeps/hppa/nptl/tls.h: Likewise
+ * sysdeps/unix/sysv/linux/hppa/nptl/bits: Likewise
+ * sysdeps/unix/sysv/linux/hppa/nptl/createthread.c: Likewise
+ * sysdeps/unix/sysv/linux/hppa/nptl/fork.c: Likewise
+ * sysdeps/unix/sysv/linux/hppa/nptl/internaltypes.h: Likewise
+ * sysdeps/unix/sysv/linux/hppa/nptl/libc-lowlevellock.c: Likewise
+ * sysdeps/unix/sysv/linux/hppa/nptl/lowlevellock.c: Likewise
+ * sysdeps/unix/sysv/linux/hppa/nptl/lowlevellock.h: Likewise
+ * sysdeps/unix/sysv/linux/hppa/nptl/pt-initfini.c: Likewise
+ * sysdeps/unix/sysv/linux/hppa/nptl/pt-vfork.S: Likewise
+ * sysdeps/unix/sysv/linux/hppa/nptl/pthread_once.c: Likewise
+ * sysdeps/unix/sysv/linux/hppa/nptl/sysdep-cancel.h: Likewise
+ * sysdeps/unix/sysv/linux/hppa/nptl/unwind-forcedunwind.c: Likewise
+ * sysdeps/unix/sysv/linux/hppa/nptl/unwind-resume.c: Likewise
+
+2006-06-08 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/unix/sysv/linux/hppa/Versions: new errlist compat entry
+ for up to 256 errnos
+
+2006-06-08 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/hppa/hppa1.1/Implies: Remove ieee754/ldbl-128.
+ * sysdeps/unix/sysv/linux/hppa/kernel-features.h
+ [__LINUX_KERNEL_VERSION >= 0x020609]: Define __ASSUME_LWS_CAS.
+ * sysdeps/unix/sysv/linux/hppa/bits/atomic.h: New file.
+
+2006-06-08 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/unix/sysv/linux/hppa/bits/fcntl.h: Reformat
+ (SPLICE_F_MOVE, SPLICE_F_NONBLOCK, SPLICE_F_MORE, SPLICE_F_GIFT):
+ Define.
+
+2006-05-24 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/unix/sysv/linux/hppa/clone.S: .LerrorRest
+ is a label.
+
+2006-05-24 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/hppa/ldsodefs.h: New file.
+ * sysdeps/unix/sysv/linux/hppa/bits/mman.h:
+ Only define MADV_* macros when __USE_BSD is present.
+ (MADV_REMOVE, MADV_DONTFORK, MADV_DOFORK): Define.
+
+2006-05-15 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/unix/sysv/linux/hppa/clone.S: Accept extra arguments
+ required for NPTL.
+ * sysdeps/unix/sysv/linux/hppa/sysdep.c: Use var args for 6 arg
+ syscall.
+ * sysdeps/unix/sysv/linux/hppa/sysdep.h: Move DOARGS and UNDOARGS
+ into PSEUDO_*'s.
+ (ENTRY_LEAF): Define.
+ (PSEUDO_NOERRNO, PSEUDO_ERRVAL): Use ENTRY_LEAF.
+ (DO_CALL): Create frame.
+
+2006-05-15 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/hppa/dl-machine.h: Include tls.h
+ (elf_machine_fixup_plt): Returns fdesc.
+ (elf_machine_profile_fixup_plt): Remove.
+ (elf_machine_plt_value): Returns fdesc.
+ (elf_machine_runtime_setup): Check that dl_profile != NULL.
+ (ARCH_LA_PLTENT, ARCH_LA_PLTEXIT): Define.
+ (RTLD_START): Use iitlbp with sr0.
+ (elf_machine_type_class): Include TLS relocs.
+ (reassemble_21, reassemble_14): Define.
+ (elf_machine_rela): Add DIR21L, DIR14R, PLABEL21L, PLABEL14R,
+ TLS_DTPMOD32, TLS_TPREL32, TLS_DTPOFF32 support.
+ (TRAMPOLINE_TEMPLATE): Move to ...
+ * sysdeps/hppa/dl-trampoline.S: ... here.
+ * sysdeps/hppa/abort-instr.h: Use iitlbp with sr0.
+ * sysdeps/hppa/dl-lookupcfg.h: Inlcude dl-fptr.h.
+ (DL_FIXUP_VALUE_TYPE, DL_FIXUP_MAKE_VALUE, DL_FIXUP_VALUE_CODE_ADDR,
+ DL_FIXUP_VALUE_ADD, DL_FIXUP_ADDR_VALUE): Define.
+ * sysdeps/hppa/sysdep.h: Use "!" as a separator. Cleanup comments.
+ * sysdeps/hppa/bits/link.h (La_hppa_regs, La_hppa_retval): Define.
+ Define prototypes for la_hppa_gnu_pltenter and la_hppa_gnu_pltexit.
+
+2006-04-27 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/unix/sysv/linux/hppa/bits/fcntl.h: Include uio.h, and
+ define vmsplice.
+
+2006-04-21 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/hppa/dl-tls.h: New file
+ * sysdeps/hppa/libc-tls.c: Likewise.
+ * sysdeps/hppa/tls-macros.h: Likewise.
+ * sysdeps/hppa/elf/configure: Likewise.
+ * sysdeps/hppa/elf/configure.in: Likewise.
+
+2006-04-20 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/hppa/fpu/fclrexcpt.c (feclearexcept): Use union to
+ align parameters. Specify memory clobbers.
+ * sysdeps/hppa/fpu/fedisblxcpt.c (fedisableexcept): Likewise.
+ * sysdeps/hppa/fpu/feenablxcpt.c (feenableexcept): Likewise.
+ * sysdeps/hppa/fpu/fegetenv.c (fegetenv): Do not save exception
+ register. Use memcpy to align buffer.
+ * sysdeps/hppa/fpu/fegetexcept.c (fegetexcept): Store and reload
+ fr0. Use union to align parameters.
+ * sysdeps/hppa/fpu/fegetround.c (fegetround): Likewise.
+ * sysdeps/hppa/fpu/feholdexcpt.c (feholdexcept): Do not save
+ exception registers. Define libm_hidden_def.
+ * sysdeps/hppa/fpu/fesetenv.c (fesetenv): Do not save exception
+ registers.
+ * sysdeps/hppa/fpu/fesetround.c (fesetround): Use union to
+ align parameters, speficy memory clobbers. Define libm_hidde_def
+ * sysdeps/hppa/fpu/feupdateenv.c (feupdateenv): Use union to align
+ parameters. Use memcpy to align buffer.
+ * sysdeps/hppa/fpu/fgetexcptflg.c (fegetexceptflag): Likewise.
+ * sysdeps/hppa/fpu/fsetexcptflg.c (fesetexceptflag): Likewise.
+ * sysdeps/hppa/fpu/ftestexcept.c (fetestexcept): Likewise.
+ * sysdeps/hppa/fpu/libm-test-ulps: Update.
+ * sysdeps/hppa/fpu/bits/fenv.h: Add ABI comments.
+
+2006-04-19 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/unix/sysv/linux/hppa/bits/mman.h [__USE_GNU]:
+ Define MMAP_FIXED.
+ * sysdeps/unix/sysv/linux/hppa/bits/fcntl.h [__USE_GNU]:
+ Define SYNC_FILE_RANGE_WAIT_BEFORE, SYNC_FILE_RANGE_WRITE,
+ SYNC_FILE_RANGE_WAIT_AFTER, sync_file_range, splice, tee.
+
+2006-04-19 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/unix/sysv/linux/hppa/kernel-features.h: New file.
+
+2006-04-19 Carlos O'Donell <carlos@systemhalted.org>
+
+ * sysdeps/hppa/linuxthreads/pspinlock.c: New file.
+ * sysdeps/hppa/linuxthreads/pt-machine.h: Likewise.
+ * sysdeps/hppa/linuxthreads/tls.h: Likewise.
+ * sysdeps/unix/sysv/linux/hppa/linuxthreads/aio_cancel.c: Likewise.
+ * sysdeps/unix/sysv/linux/hppa/linuxthreads/malloc-machine.h:
+ Likewise.
+ * sysdeps/unix/sysv/linux/hppa/linuxthreads/pt-initfini.c: Likewise.
+ * sysdeps/unix/sysv/linux/hppa/linuxthreads/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/hppa/linuxthreads/bits/initspin.h: Likewise.
+ * sysdeps/unix/sysv/linux/hppa/linuxthreads/bits/pthreadtypes.h:
+ Likewise.
+
+2006-02-28 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/hppa/shlib-versions: New file.
+ * sysdeps/hppa/preconfigure: New file.
diff --git a/ports/ChangeLog.m68k b/ports/ChangeLog.m68k
new file mode 100644
index 000000000..328f858c8
--- /dev/null
+++ b/ports/ChangeLog.m68k
@@ -0,0 +1,3 @@
+2006-02-28 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/m68k/preconfigure: New file.
diff --git a/ports/ChangeLog.mips b/ports/ChangeLog.mips
new file mode 100644
index 000000000..b3bf0907f
--- /dev/null
+++ b/ports/ChangeLog.mips
@@ -0,0 +1,170 @@
+2006-08-04 Joseph Myers <joseph@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/mips/nptl/lowlevellock.h (FUTEX_LOCK_PI,
+ FUTEX_UNLOCK_PI, FUTEX_TRYLOCK_PI): Define.
+
+2006-07-24 Joseph Myers <joseph@codesourcery.com>
+
+ * sysdeps/mips/mips64/n32/libm-test-ulps,
+ sysdeps/mips/mips64/n64/libm-test-ulps: New.
+
+2006-07-24 Joseph Myers <joseph@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/mips/sigaction.c: If WRAPPER_INCLUDE is
+ defined, include the named file.
+
+2006-06-08 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/mips/bits/fcntl.h: Reformat.
+ (SPLICE_F_MOVE, SPLICE_F_NONBLOCK, SPLICE_F_MORE, SPLICE_F_GIFT):
+ Define.
+
+2006-06-02 Joseph Myers <joseph@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/mips/bits/resource.h (RLIM_INFINITY,
+ RLIM64_INFINITY): Define appropriately for N64. Use unsigned
+ types.
+
+2006-06-02 Joseph Myers <joseph@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/mips/kernel_stat.h (struct kernel_stat):
+ Don't use struct timespec.
+ * sysdeps/unix/sysv/linux/mips/xstatconv.c (__xstat_conv,
+ __xstat64_conv): Copy individual timespec fields.
+
+2006-06-02 Richard Sandiford <richard@codesourcery.com>
+
+ * sysdeps/mips/Makefile (ASFLAGS-.os): Define.
+
+2006-06-02 Joseph Myers <joseph@codesourcery.com>
+
+ * sysdeps/mips/fpu/feholdexcpt.c: Add libm_hidden_def.
+ * sysdeps/mips/fpu/fesetround.c: Likewise.
+
+2006-05-10 Richard Sandiford <richard@codesourcery.com>
+ Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/mips/register-dump.h (register_dump): Don't
+ dump sc_cause, sc_status or sc_badvaddr.
+ * sysdeps/unix/sysv/linux/mips/bits/sigcontext.h: Rewrite. Update
+ structure definitions after DSP kernel changes.
+ * sysdeps/unix/sysv/linux/mips/sys/ucontext.h (mcontext_t): Update
+ after the same DSP changes.
+
+2006-05-08 Richard Sandiford <richard@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/mips/bits/stat.h (struct stat): Add
+ st_atim, st_mtim and st_ctim interface.
+ (struct stat64): Likewise.
+ * sysdeps/unix/sysv/linux/mips/kernel_stat.h (struct kernel_stat):
+ Replace st_atime and its padding field with st_atim. Likewise
+ st_mtime/st_mtim and st_ctime/st_ctim.
+ * sysdeps/unix/sysv/linux/mips/xstatconv.c (__xstat_conv): Update
+ after above changes.
+ (__xstat64_conv): Likewise.
+
+2006-05-08 Richard Sandiford <richard@codesourcery.com>
+
+ * sysdeps/mips/ldsodefs.h: New file.
+ * sysdeps/mips/tst-audit.h: New file.
+
+2006-05-05 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/mips/bits/mman.h: Formatting changes
+ for consistency with other ports.
+ (MADV_REMOVE): Correct value.
+ (MADV_DONTFORK, MADV_DOFORK, POSIX_MADV_NORMAL,
+ POSIX_MADV_RANDOM, POSIX_MADV_SEQUENTIAL, POSIX_MADV_WILLNEED,
+ POSIX_MADV_DONTNEED): Define.
+
+2006-05-05 Lior Balkohen <balkohen@gmail.com>
+
+ * sysdeps/unix/sysv/linux/mips/bits/fcntl.h: Remove
+ LINUX_FADV_ASYNC_WRITE and LINUX_FADV_WRITE_WAIT.
+ Define SYNC_FILE_RANGE_WAIT_BEFORE, SYNC_FILE_RANGE_WRITE
+ and SYNC_FILE_RANGE_WAIT_AFTER.
+ Declare sync_file_range, vmsplice, splice and tee.
+
+2006-03-27 Lior Balkohen <balkohen@gmail.com>
+
+ * sysdeps/unix/sysv/linux/mips/bits/fcntl.h: Define
+ LINUX_FADV_ASYNC_WRITE and LINUX_FADV_WRITE_WAIT. Add readahead
+ prototype.
+
+2006-03-27 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/mips/bits/poll.h (POLLREMOVE, POLLRDHUP):
+ Define.
+
+2006-03-27 Denis Barbier <barbier@linuxfr.org>
+
+ * sysdeps/unix/sysv/linux/mips/bits/resource.h (RLIMIT_RTPRIO): Fix
+ typo.
+
+2006-03-11 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/mips/nptl/fork.c: Correct path to
+ i386/fork.c.
+
+2006-03-11 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/mips/configure.in: Set libc_cv_slibdir,
+ libc_cv_localedir, libdir, arch_minimum_kernel, and
+ libc_cv_gcc_unwind_find_fde.
+ * sysdeps/unix/sysv/linux/mips/mips64/configure.in: New file.
+ * sysdeps/unix/sysv/linux/mips/configure: Regenerated.
+ * sysdeps/unix/sysv/linux/mips/mips64/configure: Generated.
+
+2006-03-02 Lior Balkohen <balkohen@gmail.com>
+
+ * sysdeps/unix/sysv/linux/mips/nptl/bits/pthreadtypes.h
+ (__pthread_list_t, __pthread_slist_t): New typedefs.
+ (pthread_mutex_t): Replace __next and __prev fields with __list.
+ * sysdeps/unix/sysv/linux/mips/nptl/lowlevellock.h (FUTEX_WAKE_OP,
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (lll_futex_wake_unlock): Define.
+ (lll_robust_mutex_dead, lll_robust_mutex_trylock, lll_robust_mutex_lock,
+ lll_robust_mutex_cond_lock, lll_robust_mutex_timedlock,
+ lll_robust_mutex_unlock): New macros.
+ (__lll_robust_lock_wait, __lll_robust_timedlock_wait): New prototypes.
+ * sysdeps/unix/sysv/linux/mips/nptl/pt-vfork.S: Use correct path to
+ vfork.S.
+ * sysdeps/unix/sysv/linux/mips/nptl/vfork.S: Likewise.
+
+2006-03-02 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/mips/ptrace.c: Delete file.
+ * sysdeps/unix/sysv/linux/mips/sys/ptrace.h: Delete file.
+
+2006-03-02 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
+ (INTERNAL_SYSCALL): Update internal_syscall##nr invocation.
+ (INTERNAL_SYSCALL_NCS): New.
+ (internal_syscall0, internal_syscall1, internal_syscall2,
+ internal_syscall3, internal_syscall4, internal_syscall5,
+ internal_syscall6): Take ncs_init, cs_init, and input arguments.
+ Use them. Correct types for registers.
+ * sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
+ (INTERNAL_SYSCALL): Update internal_syscall##nr invocation.
+ (INTERNAL_SYSCALL_NCS): New.
+ (internal_syscall0, internal_syscall1, internal_syscall2,
+ internal_syscall3, internal_syscall4, internal_syscall5,
+ internal_syscall6): Take ncs_init, cs_init, and input arguments.
+ Use them.
+ * sysdeps/unix/sysv/linux/mips/mips64/syscalls.list: Remove
+ recvfrom and sendto. Mark lseek, msgrcv, and msgsnd as cancellation
+ points.
+ * sysdeps/mips/dl-machine.h (elf_machine_rel): Remove unused "value".
+ Use Elf(Addr) for TLS relocation targets.
+ * sysdeps/unix/sysv/linux/mips/mips64/Makefile: New file.
+ * sysdeps/unix/sysv/linux/mips/nptl/lowlevellock.h (lll_futex_wait,
+ lll_futex_timed_wait, lll_futex_wake, lll_futex_requeue): Cast
+ futexp to long for n64.
+ * sysdeps/unix/sysv/linux/mips/mips64/nptl/sysdep-cancel.h: New file.
+
+2006-02-20 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/mips/shlib-versions: New file.
+ * sysdeps/mips/preconfigure: New file.
+ * sysdeps/unix/sysv/linux/mips/kernel-features.h: New file.
diff --git a/ports/ChangeLog.powerpc b/ports/ChangeLog.powerpc
new file mode 100644
index 000000000..b04ad8c34
--- /dev/null
+++ b/ports/ChangeLog.powerpc
@@ -0,0 +1,16 @@
+2006-01-27 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/powerpc/nofpu/Subdirs: New file.
+
+ * sysdeps/powerpc/nofpu/Makefile [$(subdir) = soft-fp]
+ (sysdep_routines): Add $(gcc-quad-routines) here.
+
+2006-01-06 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/powerpc/nofpu/Versions (libc: GLIBC_2.4): New set.
+ Add __floatundidf, __floatundisf, __floatunditf, __floatunsidf,
+ __floatunsisf, __floatunsitf, __unorddf2, __unordsf2, __unordtf2.
+
+2005-10-11 Steven Munroe <sjmunroe@us.ibm.com>
+
+ * sysdeps/powerpc/nofpu/fesetround.c: Add libm_hidden_def.
diff --git a/ports/Makefile b/ports/Makefile
new file mode 100644
index 000000000..657fdeef7
--- /dev/null
+++ b/ports/Makefile
@@ -0,0 +1,43 @@
+# This makefile is not used by the glibc build process.
+# It's purely for making ports tarballs.
+
+.PHONY: dist dist-ports
+dist: dist-ports
+
+# Do `make dist dist-version=X.Y.Z' to make tar files of an older version.
+dist-version = $(version)
+# Also try 'dist-tag=some="-r TAG"' (or -D DATE) to get some tag rather
+# than the release tag for X.Y.Z.
+dist-tag = -r glibc-$(subst .,_,$(dist-version))
+
+distname = glibc-ports-$(dist-version)
+
+do-export = cvs $(CVSOPTS) -Q export -d $(basename $@) $(dist-tag)
+
+dist-ports: $(foreach Z,.bz2 .gz,$(distname).tar$Z)
+ md5sum $^
+$(distname).tar:
+ @rm -fr $(basename $@)
+ $(MAKE) -q `find sysdeps -name configure`
+ $(do-export) ports
+ find $(basename $@) -name configure -print | xargs touch
+ tar cf $@ $(basename $@)
+ rm -fr $(basename $@)
+
+sysdeps-of-stem = sysdeps/$* sysdeps/unix/sysv/linux/$*
+
+.PRECIOUS: %.gz %.bz2 # Don't delete output as intermediate files.
+dist-port-%: $(foreach Z,.bz2 .gz,glibc-port-%-$(dist-version).tar$Z)
+ md5sum $^
+glibc-port-%-$(dist-version).tar: ChangeLog.%
+ @rm -fr $(basename $@)
+ $(MAKE) -q `find $(sysdeps-of-stem) -name configure`
+ $(do-export) ports/ChangeLog.$* $(addprefix ports/,$(sysdeps-of-stem))
+ mv $(basename $@)/ports/* $(basename $@)/
+ rmdir $(basename $@)/ports
+ find $(basename $@) -name configure -print | xargs touch
+ tar cf $@ $(basename $@)
+ rm -fr $(basename $@)
+
+%.bz2: %; bzip2 -9vk $<
+%.gz: %; gzip -9vnc $< > $@.new && mv -f $@.new $@
diff --git a/ports/README b/ports/README
new file mode 100644
index 000000000..e781322fa
--- /dev/null
+++ b/ports/README
@@ -0,0 +1,43 @@
+This is the glibc ports repository, an add-on for the GNU C Library (glibc).
+It contains code that is not maintained in the official glibc source tree.
+
+This includes working ports to GNU/Linux on some machine architectures that
+are not maintained in the official glibc source tree. It also includes
+some code once used by old libc ports now defunct, which has been abandoned
+but may be useful for some future porter to examine. It may also include
+some optimized functions tailored for specific CPU implementations of an
+architecture, to be selected using --with-cpu.
+
+The ports repository is cooperatively maintained by volunteers on the
+<libc-ports@sourceware.org> mailing list, and housed in the glibc CVS as a
+module called "ports". See http://www.gnu.org/software/libc/resources.html
+for details on using CVS. To report a bug in code housed in the ports
+repository, please go to http://sources.redhat.com/bugzilla/ and file a bug
+report under the glibc "ports" component.
+
+An add-on for an individual port can be made from just the sysdeps/
+subdirectories containing the port's code. You may want to include a
+README and Banner of your own talking about your port's code in particular,
+rather than the generic ones here.
+
+The real source code for any ports is found in the sysdeps/ subdirectories.
+These should be exactly what would go into the main libc source tree if you
+were to incorporate it directly. The only exceptions are the files
+sysdeps/*/preconfigure and sysdeps/*/preconfigure.in; these are fragments
+used by this add-on's configure fragment. The purpose of these is to set
+$base_machine et al when the main libc configure's defaults are not right
+for some machine. Everything else can and should be done from a normal
+sysdeps/.../configure fragment that is used only when the configuration
+selects that sysdeps subdirectory. Each port that requires some special
+treatment before the sysdeps directory list is calculated, should add a
+sysdeps/CPU/preconfigure file; this can either be written by hand or
+generated by Autoconf from sysdeps/CPU/preconfigure.in, and follow the
+rules for glibc add-on configure fragments. No preconfigure file should do
+anything on an unrelated configuration, so that disparate ports can be put
+into a single add-on without interfering with each other.
+
+Like all glibc add-ons, this must be used by specifying the directory in
+the --enable-add-ons option when running glibc's configure script.
+
+
+$Id: README,v 1.2 2006/02/28 08:23:38 roland Exp $
diff --git a/ports/bare/.cvsignore b/ports/bare/.cvsignore
new file mode 100644
index 000000000..3fc9f4cdf
--- /dev/null
+++ b/ports/bare/.cvsignore
@@ -0,0 +1,6 @@
+*.d *.o *.so *.po *.go stamp.* *.stamp *.ustamp *.udeps
+*.gz *.Z *.tar *.tgz
+=*
+TODO COPYING* AUTHORS copyr-* copying.*
+glibc-*
+distinfo
diff --git a/ports/bare/Makefile b/ports/bare/Makefile
new file mode 100644
index 000000000..ddfa6ac5e
--- /dev/null
+++ b/ports/bare/Makefile
@@ -0,0 +1,55 @@
+# Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# 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 Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+subdir := bare
+
+bare-routines := brdinit console strtsupp
+routines = $(bare-routines)
+elided-routines = $(bare-routines)
+extra-objs = $(bare-routines:%=%.o)
+
+install-lib = lib$(config-vendor).a
+
+include ../Rules
+
+#
+# For bare targets, the $(config-vendor) is the name of the board.
+# We will place the board dependent code ONLY in a library which
+# is board dependent. This way many target boards can share a
+# single libc.a. To resolve all symbols and successfully link
+# a program, the application must link against libc.a and libMY_TARGET.a.
+# For example, the target specific library for the Motorola MVME135
+# board will be named libmvme135.a. To link a program for the
+# MVME135, one must link against -lc and -lmvme135.
+#
+
+lib: $(objpfx)lib$(config-vendor).a
+
+$(objpfx)lib$(config-vendor).a: $(bare-routines:%=$(objpfx)%.o)
+# This library is small enough that it's simplest to recreate the archive
+# from scratch each time.
+ rm -f $@
+ifdef objdir
+ cd $(objpfx); $(AR) cq$(verbose) $(@:$(objpfx)%=%) $(^:$(objpfx)%=%)
+else
+ $(AR) cq$(verbose) $@ $^
+endif
+ $(RANLIB) $@
diff --git a/ports/bare/brdinit.c b/ports/bare/brdinit.c
new file mode 100644
index 000000000..af96bcd12
--- /dev/null
+++ b/ports/bare/brdinit.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <standalone.h>
+
+/* This file is only required when a "bare" board is configured. */
+
+/* _Board_Initialize
+
+This routine normally performs board specific initialization. */
+
+void
+_Board_Initialize ()
+{
+}
diff --git a/ports/bare/console.c b/ports/bare/console.c
new file mode 100644
index 000000000..326ebed4a
--- /dev/null
+++ b/ports/bare/console.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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
+_Console_Putc (ch)
+ char ch;
+{
+ /* eat the character */
+
+ return 0;
+}
+
+int
+_Console_Getc (poll)
+ int poll;
+{
+ /* boring user, never types anything */
+ return -1;
+}
diff --git a/ports/bare/strtsupp.c b/ports/bare/strtsupp.c
new file mode 100644
index 000000000..c66495bb3
--- /dev/null
+++ b/ports/bare/strtsupp.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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/ports/sysdeps/am29k/ffs.c b/ports/sysdeps/am29k/ffs.c
new file mode 100644
index 000000000..9abd2c6bc
--- /dev/null
+++ b/ports/sysdeps/am29k/ffs.c
@@ -0,0 +1,43 @@
+/* ffs -- find first set bit in a word, counted from least significant end.
+ For Amd 290x0.
+ Copyright (C) 1991, 1992, 1997, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <bstring.h>
+
+#undef ffs
+
+#ifdef __GNUC__
+
+int
+__ffs (x)
+ int x;
+{
+ int cnt;
+
+ asm ("clz %0,%1" : "=r" (cnt) : "r" (x & -x));
+
+ return 32 - cnt;
+}
+weak_alias (__ffs, ffs)
+libc_hidden_builtin_def (ffs)
+
+#else
+#include <string/ffs.c>
+#endif
diff --git a/ports/sysdeps/am33/Implies b/ports/sysdeps/am33/Implies
new file mode 100644
index 000000000..780c4e246
--- /dev/null
+++ b/ports/sysdeps/am33/Implies
@@ -0,0 +1,3 @@
+wordsize-32
+ieee754/flt-32
+ieee754/dbl-64
diff --git a/ports/sysdeps/am33/__longjmp.S b/ports/sysdeps/am33/__longjmp.S
new file mode 100644
index 000000000..9bdcc489e
--- /dev/null
+++ b/ports/sysdeps/am33/__longjmp.S
@@ -0,0 +1,61 @@
+/* longjmp for AM33.
+ Copyright 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _ASM
+#define _SETJMP_H
+#include <bits/setjmp.h>
+#include <asm-syntax.h>
+
+ENTRY (__longjmp)
+ mov d0,a0
+ mov (8,a0),d2
+ mov d2,mdr
+ mov (0,a0),d2
+ mov (4,a0),d3
+ mov (12,a0),a2
+ mov (16,a0),a3
+ mov (20,a0),a1
+ mov a1,sp
+ add 24,a0
+ mov (a0+),r4
+ mov (a0+),r5
+ mov (a0+),r6
+ mov (a0+),r7
+#ifdef __AM33_2__
+ fmov (a0+),fs4
+ fmov (a0+),fs5
+ fmov (a0+),fs6
+ fmov (a0+),fs7
+ fmov (a0+),fs8
+ fmov (a0+),fs9
+ fmov (a0+),fs10
+ fmov (a0+),fs11
+ fmov (a0+),fs12
+ fmov (a0+),fs13
+ fmov (a0+),fs14
+ fmov (a0+),fs15
+ fmov (a0+),fs16
+ fmov (a0+),fs17
+ fmov (a0+),fs18
+ fmov (a0+),fs19
+#endif
+ mov d1,d0
+ retf [],0
+END (__longjmp)
diff --git a/ports/sysdeps/am33/atomicity.h b/ports/sysdeps/am33/atomicity.h
new file mode 100644
index 000000000..d7765338a
--- /dev/null
+++ b/ports/sysdeps/am33/atomicity.h
@@ -0,0 +1,87 @@
+/* Low-level functions for atomic operations. AM33 version.
+ Copyright 1999, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>.
+ Based on ../sparc/sparc32/atomicity.h
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _ATOMICITY_H
+#define _ATOMICITY_H 1
+
+#include <inttypes.h>
+
+#define __acquire_lock(lock) \
+ __asm__ __volatile__("1: bset %1, (%0)\n\t" \
+ " beq 1b" \
+ : : "a" (&(lock)), "d" (1) \
+ : "memory")
+
+#define __release_lock(lock) lock = 0
+
+static int
+__attribute__ ((unused))
+exchange_and_add (volatile uint32_t *mem, int val)
+{
+ static unsigned char lock;
+ int result;
+
+ __acquire_lock (lock);
+
+ result = *mem;
+ *mem += val;
+
+ __release_lock (lock);
+
+ return result;
+}
+
+static void
+__attribute__ ((unused))
+atomic_add (volatile uint32_t *mem, int val)
+{
+ static unsigned char lock;
+
+ __acquire_lock (lock);
+
+ *mem += val;
+
+ __release_lock (lock);
+}
+
+static int
+__attribute__ ((unused))
+compare_and_swap (volatile long int *p, long int oldval, long int newval)
+{
+ static unsigned char lock;
+ int ret;
+
+ __acquire_lock (lock);
+
+ if (*p != oldval)
+ ret = 0;
+ else
+ {
+ *p = newval;
+ ret = 1;
+ }
+
+ __release_lock (lock);
+
+ return ret;
+}
+
+#endif /* atomicity.h */
diff --git a/ports/sysdeps/am33/bits/endian.h b/ports/sysdeps/am33/bits/endian.h
new file mode 100644
index 000000000..7423f0957
--- /dev/null
+++ b/ports/sysdeps/am33/bits/endian.h
@@ -0,0 +1,7 @@
+/* AM33 is little-endian. */
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#define __BYTE_ORDER __LITTLE_ENDIAN
diff --git a/ports/sysdeps/am33/bits/setjmp.h b/ports/sysdeps/am33/bits/setjmp.h
new file mode 100644
index 000000000..3e578a41a
--- /dev/null
+++ b/ports/sysdeps/am33/bits/setjmp.h
@@ -0,0 +1,27 @@
+/* Copyright 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Define the machine-dependent type `jmp_buf'. AM33 version. */
+
+#ifndef _SETJMP_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+#ifndef _ASM
+typedef int __jmp_buf[26];
+#endif
diff --git a/ports/sysdeps/am33/bsd-_setjmp.S b/ports/sysdeps/am33/bsd-_setjmp.S
new file mode 100644
index 000000000..9bbfcbbba
--- /dev/null
+++ b/ports/sysdeps/am33/bsd-_setjmp.S
@@ -0,0 +1 @@
+/* _setjmp is in setjmp.S */
diff --git a/ports/sysdeps/am33/bsd-setjmp.S b/ports/sysdeps/am33/bsd-setjmp.S
new file mode 100644
index 000000000..b6b239e67
--- /dev/null
+++ b/ports/sysdeps/am33/bsd-setjmp.S
@@ -0,0 +1 @@
+/* setjmp is in setjmp.S */
diff --git a/ports/sysdeps/am33/dl-machine.h b/ports/sysdeps/am33/dl-machine.h
new file mode 100644
index 000000000..808fd9cc8
--- /dev/null
+++ b/ports/sysdeps/am33/dl-machine.h
@@ -0,0 +1,481 @@
+/* Machine-dependent ELF dynamic relocation inline functions. AM33 version.
+ Copyright (C) 1995,96,97,98,99,2000,2001, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef dl_machine_h
+#define dl_machine_h
+
+#define ELF_MACHINE_NAME "mn10300"
+
+#include <sys/param.h>
+
+/* Return nonzero iff ELF header is compatible with the running host. */
+static inline int __attribute__ ((unused))
+elf_machine_matches_host (const Elf32_Ehdr *ehdr)
+{
+ return ehdr->e_machine == EM_MN10300;
+}
+
+
+/* Return the link-time address of _DYNAMIC. Conveniently, this is the
+ first element of the GOT. This must be inlined in a function which
+ uses global data. */
+static inline Elf32_Addr __attribute__ ((unused))
+elf_machine_dynamic (void)
+{
+ register Elf32_Addr *got asm ("a2");
+ return *got;
+}
+
+
+/* Return the run-time load address of the shared object. */
+static inline Elf32_Addr __attribute__ ((unused))
+elf_machine_load_address (void)
+{
+ register Elf32_Addr gotaddr asm ("a2");
+ Elf32_Addr off, gotval;
+
+ asm ("mov _dl_start@GOTOFF,%0" : "=r" (off));
+ asm ("mov (_dl_start@GOT,%1),%0" : "=r" (gotval) : "r" (gotaddr));
+
+ return off + gotaddr - gotval;
+}
+
+#if !defined PROF && !__BOUNDED_POINTERS__
+/* We add a declaration of this function here so that in dl-runtime.c
+ the ELF_MACHINE_RUNTIME_TRAMPOLINE macro really can pass the parameters
+ in registers.
+
+ We cannot use this scheme for profiling because the _mcount call
+ destroys the passed register information. */
+/* GKM FIXME: Fix trampoline to pass bounds so we can do
+ without the `__unbounded' qualifier. */
+static ElfW(Addr) fixup (struct link_map *__unbounded l, ElfW(Word) reloc_offset)
+ __attribute__ ((unused));
+static ElfW(Addr) profile_fixup (struct link_map *l, ElfW(Word) reloc_offset,
+ ElfW(Addr) retaddr)
+ __attribute__ ((unused));
+#endif
+
+/* Set up the loaded object described by L so its unrelocated PLT
+ entries will jump to the on-demand fixup code in dl-runtime.c. */
+
+static inline int __attribute__ ((unused))
+elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
+{
+ Elf32_Addr *got;
+ extern void _dl_runtime_resolve (Elf32_Word) attribute_hidden;
+ extern void _dl_runtime_profile (Elf32_Word) attribute_hidden;
+
+ if (l->l_info[DT_JMPREL] && lazy)
+ {
+ /* The GOT entries for functions in the PLT have not yet been filled
+ in. Their initial contents will arrange when called to push an
+ offset into the .rel.plt section, push _GLOBAL_OFFSET_TABLE_[1],
+ and then jump to _GLOBAL_OFFSET_TABLE[2]. */
+ got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]);
+ got[1] = (Elf32_Addr) l; /* Identify this shared object. */
+
+ /* The got[2] entry contains the address of a function which gets
+ called to get the address of a so far unresolved function and
+ jump to it. The profiling extension of the dynamic linker allows
+ to intercept the calls to collect information. In this case we
+ don't store the address in the GOT so that all future calls also
+ end in this function. */
+ if (__builtin_expect (profile, 0))
+ {
+ got[2] = (Elf32_Addr) &_dl_runtime_profile;
+
+ if (_dl_name_match_p (GLRO(dl_profile), l))
+ /* This is the object we are looking for. Say that we really
+ want profiling and the timers are started. */
+ GL(dl_profile_map) = l;
+ }
+ else
+ /* This function will get called to fix up the GOT entry indicated by
+ the offset on the stack, and then jump to the resolved address. */
+ got[2] = (Elf32_Addr) &_dl_runtime_resolve;
+ }
+
+ return lazy;
+}
+
+/* This code is used in dl-runtime.c to call the `fixup' function
+ and then redirect to the address it returns. */
+#if !defined PROF && !__BOUNDED_POINTERS__
+# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
+ .text\n\
+ .globl _dl_runtime_resolve\n\
+ .type _dl_runtime_resolve, @function\n\
+_dl_runtime_resolve:\n\
+ add -12,sp # Preserve registers otherwise clobbered.\n\
+ mov d1,(20,sp)\n\
+ mov d0,(16,sp)\n\
+ mov r1,d0\n\
+ mov r0,d1\n\
+ call fixup,[],0 # Call resolver.\n\
+ mov d0,a0\n\
+ mov (12,sp),d1 # Copy return address back to mdr,\n\
+ mov d1,mdr # in case the callee returns with retf\n\
+ mov (16,sp),d0 # Get register content back.\n\
+ mov (20,sp),d1\n\
+ add 12,sp\n\
+ jmp (a0)\n\
+ .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
+\n\
+ .globl _dl_runtime_profile\n\
+ .type _dl_runtime_profile, @function\n\
+_dl_runtime_profile:\n\
+ add -12,sp # Preserve registers otherwise clobbered.\n\
+ mov d1,(20,sp)\n\
+ mov d0,(16,sp)\n\
+ mov r1,d0\n\
+ mov r0,d1\n\
+ call profile_fixup,[],0 # Call resolver.\n\
+ mov d0,a0\n\
+ mov (12,sp),d1 # Copy return address back to mdr,\n\
+ mov d1,mdr # in case the callee returns with retf\n\
+ mov (16,sp),d0 # Get register content back.\n\
+ mov (20,sp),d1\n\
+ add 12,sp\n\
+ jmp (a0)\n\
+ .size _dl_runtime_profile, .-_dl_runtime_profile\n\
+ .previous\n\
+");
+#else
+# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\n\
+ .text\n\
+ .globl _dl_runtime_resolve\n\
+ .globl _dl_runtime_profile\n\
+ .type _dl_runtime_resolve, @function\n\
+ .type _dl_runtime_profile, @function\n\
+_dl_runtime_resolve:\n\
+_dl_runtime_profile:\n\
+ add -12,sp # Preserve registers otherwise clobbered.\n\
+ mov d1,(20,sp)\n\
+ mov d0,(16,sp)\n\
+ mov r1,d0\n\
+ mov r0,d1\n\
+ call profile_fixup,[],0 # Call resolver.\n\
+ mov d0,a0\n\
+ mov (12,sp),d1 # Copy return address back to mdr,\n\
+ mov d1,mdr # in case the callee returns with retf\n\
+ mov (16,sp),d0 # Get register content back.\n\
+ mov (20,sp),d1\n\
+ add 12,sp\n\
+ jmp (a0)\n\
+ .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
+ .size _dl_runtime_profile, .-_dl_runtime_profile\n\
+ .previous\n\
+");
+#endif
+
+/* Mask identifying addresses reserved for the user program,
+ where the dynamic linker should not map anything. */
+#define ELF_MACHINE_USER_ADDRESS_MASK 0xf8000000UL
+
+/* Initial entry point code for the dynamic linker.
+ The C function `_dl_start' is the real entry point;
+ its return value is the user program's entry point. */
+#define RTLD_START asm ("\n\
+ .text\n\
+.globl _start\n\
+.globl _dl_start_user\n\
+_start:\n\
+ mov 0,a3 # Mark the top of the stack\n\
+ mov sp,a1\n\
+ add -20,sp # Prepare for function call\n\
+ mov a1,d0\n\
+ call _dl_start,[],0\n\
+_dl_start_user:\n\
+ # Save the user entry point address in d2.\n\
+ mov d0,d2\n\
+ # Point a2 at the GOT.\n\
+0: mov pc,a2\n\
+ add _GLOBAL_OFFSET_TABLE_ - (0b-.),a2\n\
+ # Store the highest stack address\n\
+ mov (__libc_stack_end@GOT,a2),a0\n\
+ mov a1,(a0)\n\
+ # See if we were run as a command with the executable file\n\
+ # name as an extra leading argument.\n\
+ mov (_dl_skip_args@GOT,a2),a0\n\
+ mov (a0),d0\n\
+ # Pop the original argument count.\n\
+ mov (20,sp),d3\n\
+ # Subtract _dl_skip_args from it.\n\
+ sub d0,d3\n\
+ # Adjust the stack pointer to skip _dl_skip_args words.\n\
+ asl2 d0\n\
+ mov sp,a0\n\
+ add d0,a0\n\
+ mov a0,sp\n\
+ # Push argc back on the stack.\n\
+ mov d3,(20,sp)\n\
+ # The special initializer gets called with the stack just\n\
+ # as the application's entry point will see it; it can\n\
+ # switch stacks if it moves these contents over.\n\
+" RTLD_START_SPECIAL_INIT "\n\
+ # Load the parameters again.\n\
+ # (d0, d1, (12,sp), (16,sp)) = (_dl_loaded, argc, argv, envp)\n\
+ add 24,a0\n\
+ mov a0,(12,sp) # a0 is 24+sp\n\
+ mov d3,d1 # d3 contained argc\n\
+ inc d3\n\
+ asl2 d3 # d3 is now (argc+1)*4,\n\
+ add d3,a0 # the offset between argv and envp\n\
+ mov a0,(16,sp)\n\
+ mov (_rtld_local@GOTOFF,a2),d0\n\
+ # Call the function to run the initializers.\n\
+ call _dl_init@PLT,[],0\n\
+ # Pass our finalizer function to the user in d0, as per ELF ABI.\n\
+ mov (_dl_fini@GOT,a2),d0\n\
+ add 20,sp\n\
+ # Jump to the user's entry point.\n\
+ mov d2,a1\n\
+ jmp (a1)\n\
+ .previous\n\
+");
+
+#ifndef RTLD_START_SPECIAL_INIT
+#define RTLD_START_SPECIAL_INIT /* nothing */
+#endif
+
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
+ PLT entries should not be allowed to define the value.
+ ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
+ of the main executable's symbols, as for a COPY reloc. */
+#define elf_machine_type_class(type) \
+ ((((type) == R_MN10300_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_MN10300_COPY) * ELF_RTYPE_CLASS_COPY))
+
+/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
+#define ELF_MACHINE_JMP_SLOT R_MN10300_JMP_SLOT
+
+static inline Elf32_Addr
+elf_machine_fixup_plt (struct link_map *map, lookup_t t,
+ const Elf32_Rela *reloc,
+ Elf32_Addr *reloc_addr, Elf32_Addr value)
+{
+ return *reloc_addr = value;
+}
+
+/* Return the final value of a plt relocation. */
+static inline Elf32_Addr
+elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
+ Elf32_Addr value)
+{
+ return value + reloc->r_addend;
+}
+
+#endif /* !dl_machine_h */
+
+#ifdef RESOLVE
+
+/* The mn10300 never uses Elf32_Rel relocations. */
+#define ELF_MACHINE_NO_REL 1
+
+/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
+ MAP is the object containing the reloc. */
+
+static inline void
+elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
+ const Elf32_Sym *sym, const struct r_found_version *version,
+ void *const reloc_addr_arg)
+{
+ const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
+ Elf32_Addr value, *reloc_addr;
+
+ /* Make sure we drop any previous alignment assumptions. */
+ asm ("" : "=r" (reloc_addr) : "0" (reloc_addr_arg));
+
+#define COPY_UNALIGNED_WORD(sw, tw, align) \
+ { \
+ unsigned long *__sl = (void*)&(sw), *__tl = (void*)&(tw); \
+ unsigned short *__ss = (void*)&(sw), *__ts = (void*)&(tw); \
+ unsigned char *__sc = (void*)&(sw), *__tc = (void*)&(tw); \
+ switch ((align)) \
+ { \
+ case 0: \
+ *__tl = *__sl; \
+ break; \
+ case 2: \
+ *__ts++ = *__ss++; \
+ *__ts = *__ss; \
+ break; \
+ default: \
+ *__tc++ = *__sc++; \
+ *__tc++ = *__sc++; \
+ *__tc++ = *__sc++; \
+ *__tc = *__sc; \
+ break; \
+ } \
+ }
+
+#define COPY_UNALIGNED_HALFWORD(sw, tw, align) \
+ { \
+ unsigned short *__ss = (void*)&(sw), *__ts = (void*)&(tw); \
+ unsigned char *__sc = (void*)&(sw), *__tc = (void*)&(tw); \
+ switch ((align)) \
+ { \
+ case 0: \
+ *__ts = *__ss; \
+ break; \
+ default: \
+ *__tc++ = *__sc++; \
+ *__tc = *__sc; \
+ break; \
+ } \
+ }
+
+#if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC
+ if (__builtin_expect (r_type == R_MN10300_RELATIVE, 0))
+ {
+# if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC
+ /* This is defined in rtld.c, but nowhere in the static libc.a;
+ make the reference weak so static programs can still link.
+ This declaration cannot be done when compiling rtld.c (i.e.
+ #ifdef RTLD_BOOTSTRAP) because rtld.c contains the common
+ defn for _dl_rtld_map, which is incompatible with a weak decl
+ in the same file. */
+ weak_extern (_dl_rtld_map);
+ if (map != &_dl_rtld_map) /* Already done in rtld itself. */
+# endif
+ {
+ COPY_UNALIGNED_WORD (*reloc_addr, value, (int) reloc_addr & 3);
+ value += map->l_addr;
+ COPY_UNALIGNED_WORD (value, *reloc_addr, (int) reloc_addr & 3);
+ }
+ }
+# ifndef RTLD_BOOTSTRAP
+ else if (__builtin_expect (r_type == R_MN10300_NONE, 0))
+ return;
+# endif
+ else
+#endif
+ {
+#ifndef RTLD_BOOTSTRAP
+ const Elf32_Sym *const refsym = sym;
+#endif
+
+ value = RESOLVE (&sym, version, ELF32_R_TYPE (reloc->r_info));
+ if (sym)
+ value += sym->st_value;
+ value += reloc->r_addend; /* Assume copy relocs have zero addend. */
+
+ switch (r_type)
+ {
+#ifndef RTLD_BOOTSTRAP
+ case R_MN10300_COPY:
+ if (sym == NULL)
+ /* This can happen in trace mode if an object could not be
+ found. */
+ break;
+ if (sym->st_size > refsym->st_size
+ || (GLRO(dl_verbose) && sym->st_size < refsym->st_size))
+ {
+ extern char **_dl_argv;
+ const char *strtab;
+
+ strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
+ _dl_error_printf ("\
+%s: Symbol `%s' has different size in shared object, consider re-linking\n",
+ _dl_argv[0] ?: "<program name unknown>",
+ strtab + refsym->st_name);
+ }
+ memcpy (reloc_addr, (void *) value, MIN (sym->st_size,
+ refsym->st_size));
+ break;
+#endif
+ case R_MN10300_GLOB_DAT:
+ case R_MN10300_JMP_SLOT:
+ /* These addresses are always aligned. */
+ *reloc_addr = value;
+ break;
+ case R_MN10300_32:
+ COPY_UNALIGNED_WORD (value, *reloc_addr, (int) reloc_addr & 3);
+ break;
+#ifndef RTLD_BOOTSTRAP
+ case R_MN10300_16:
+ COPY_UNALIGNED_HALFWORD (value, *reloc_addr, (int) reloc_addr & 1);
+ break;
+ case R_MN10300_8:
+ *(char *) reloc_addr = value;
+ break;
+ case R_MN10300_PCREL32:
+ value -= (Elf32_Addr) reloc_addr;
+ COPY_UNALIGNED_WORD (value, *reloc_addr, (int) reloc_addr & 3);
+ break;
+ case R_MN10300_PCREL16:
+ value -= (Elf32_Addr) reloc_addr;
+ COPY_UNALIGNED_HALFWORD (value, *reloc_addr, (int) reloc_addr & 1);
+ break;
+ case R_MN10300_PCREL8:
+ value -= (Elf32_Addr) reloc_addr;
+ *(char *) reloc_addr = (value - (Elf32_Addr) reloc_addr);
+ break;
+#endif
+ case R_MN10300_NONE: /* Alright, Wilbur. */
+ break;
+#if !defined RTLD_BOOTSTRAP || defined _NDEBUG
+ default:
+ _dl_reloc_bad_type (map, ELFW(R_TYPE) (reloc->r_info), 0);
+ break;
+#endif
+ }
+
+ }
+}
+
+static inline void
+elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
+ void *const reloc_addr_arg)
+{
+ Elf32_Addr value, *reloc_addr;
+
+ asm ("" : "=r" (reloc_addr) : "0" (reloc_addr_arg));
+
+ COPY_UNALIGNED_WORD (*reloc_addr, value, (int)reloc_addr & 3);
+ value += l_addr;
+ COPY_UNALIGNED_WORD (value, *reloc_addr, (int)reloc_addr & 3);
+}
+
+static inline void
+elf_machine_lazy_rel (struct link_map *map,
+ Elf32_Addr l_addr, const Elf32_Rela *reloc)
+{
+ unsigned long int const r_type = ELF32_R_TYPE (reloc->r_info);
+
+ /* Check for unexpected PLT reloc type. */
+ if (__builtin_expect (r_type, R_MN10300_JMP_SLOT) == R_MN10300_JMP_SLOT)
+ {
+ Elf32_Addr* const reloc_addr = (void *)(l_addr + reloc->r_offset);
+ Elf32_Addr value;
+
+ /* Perform a RELATIVE reloc on the .got entry that transfers
+ to the .plt. */
+ COPY_UNALIGNED_WORD (*reloc_addr, value, (int)reloc_addr & 3);
+ value += l_addr;
+ COPY_UNALIGNED_WORD (value, *reloc_addr, (int)reloc_addr & 3);
+ }
+ else if (__builtin_expect (r_type, R_MN10300_NONE) != R_MN10300_NONE)
+ _dl_reloc_bad_type (map, ELFW(R_TYPE) (reloc->r_info), 1);
+
+}
+
+#endif /* RESOLVE */
diff --git a/ports/sysdeps/am33/elf/start.S b/ports/sysdeps/am33/elf/start.S
new file mode 100644
index 000000000..1b654595c
--- /dev/null
+++ b/ports/sysdeps/am33/elf/start.S
@@ -0,0 +1,81 @@
+/* Startup code compliant to the ELF MN10300 ABI.
+ Copyright (C) 1995,1996,1997,1998,2000,2001 Free Software Foundation, Inc.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ Based on ../../i386/elf/start.S.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This is the canonical entry point, usually the first thing in the text
+ segment. The SVR4/i386 ABI (pages 3-31, 3-32) says that when the entry
+ point runs, most registers' values are unspecified, except for:
+
+ a0 Contains a function pointer to be registered with `atexit'.
+ This is how the dynamic linker arranges to have DT_FINI
+ functions called for shared libraries that have been loaded
+ before this code runs.
+
+ sp The stack contains the arguments and environment:
+ (4,sp) argc
+ (8,sp) argv[0]
+ ...
+ (4*(argc+1),sp) NULL
+ (4*(argc+2),sp) envp[0]
+ ...
+ NULL
+*/
+
+#include "bp-sym.h"
+
+ .text
+ .globl _start
+ .type _start,@function
+_start:
+ /* Extract the arguments as encoded on the stack and set up
+ the arguments for `main': argc, argv. envp will be determined
+ later in __libc_start_main. */
+ mov sp,a3
+ add -32,sp
+
+ mov a3,(28,sp) /* stack_end. */
+ mov d0,(24,sp) /* rtld_fini. */
+ mov _fini, d3
+ mov d3,(20,sp) /* fini. */
+ mov _init, d2
+ mov d2,(16,sp) /* init. */
+ inc4 a3
+ mov a3,(12,sp) /* argv. */
+
+ /* Set the initial frame pointer as 0, so that the bottom of
+ the stack is clearly marked. */
+ mov 0,a3
+
+ mov (32,sp), d1 /* argc. */
+ mov BP_SYM (main), d0 /* main. */
+
+ /* Call the user's main function, and exit with its value.
+ But let the libc call main. */
+ call BP_SYM (__libc_start_main),[],0
+
+ call BP_SYM (abort),[],0 /* Crash if somehow `exit' does return. */
+
+/* Define a symbol for the first piece of initialized data. */
+ .data
+ .globl __data_start
+__data_start:
+ .long 0
+ .weak data_start
+ data_start = __data_start
diff --git a/ports/sysdeps/am33/fpu/bits/fenv.h b/ports/sysdeps/am33/fpu/bits/fenv.h
new file mode 100644
index 000000000..04fe293b1
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/bits/fenv.h
@@ -0,0 +1,67 @@
+/* Copyright (C) 1998, 1999, 2000, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on the corresponding file in the mips port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FENV_H
+# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
+
+
+/* Define bits representing the exception. We use the EF bit
+ positions of the appropriate bits in the FPCR register. */
+enum
+ {
+ FE_INEXACT = 0x01,
+#define FE_INEXACT FE_INEXACT
+ FE_UNDERFLOW = 0x02,
+#define FE_UNDERFLOW FE_UNDERFLOW
+ FE_OVERFLOW = 0x04,
+#define FE_OVERFLOW FE_OVERFLOW
+ FE_DIVBYZERO = 0x08,
+#define FE_DIVBYZERO FE_DIVBYZERO
+ FE_INVALID = 0x10,
+#define FE_INVALID FE_INVALID
+ };
+
+#define FE_ALL_EXCEPT \
+ (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
+
+/* The AM33/2.0 FPU supports only Round to nearest. Bits 3<<16 are
+ reserved to represent other rounding modes. */
+enum
+ {
+ FE_TONEAREST = 0x00000,
+#define FE_TONEAREST FE_TONEAREST
+ };
+
+
+/* Type representing exception flags. */
+typedef unsigned int fexcept_t;
+
+
+/* Type representing floating-point environment. */
+typedef unsigned int fenv_t;
+
+/* If the default argument is used we use this value. */
+#define FE_DFL_ENV ((__const fenv_t *) -1)
+
+#ifdef __USE_GNU
+/* Floating-point environment where none of the exception is masked. */
+# define FE_NOMASK_ENV ((__const fenv_t *) -2)
+#endif
diff --git a/ports/sysdeps/am33/fpu/fclrexcpt.c b/ports/sysdeps/am33/fpu/fclrexcpt.c
new file mode 100644
index 000000000..0c98b4ea9
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/fclrexcpt.c
@@ -0,0 +1,52 @@
+/* Clear given exceptions in current floating-point environment.
+ Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on corresponding file in the MIPS port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fenv_libc.h>
+#include <fpu_control.h>
+#include <shlib-compat.h>
+
+int
+__feclearexcept (int excepts)
+{
+ fpu_control_t cw;
+
+ /* Mask out unsupported bits/exceptions. */
+ excepts &= FE_ALL_EXCEPT;
+
+ /* Read the complete control word. */
+ _FPU_GETCW (cw);
+
+ /* Clear exception flag bits and cause bits. EF bits are cleared by
+ assigning 1 to them (and there's no way to set them); other bits
+ are copied normally. */
+
+ cw &= ~((excepts << CAUSE_SHIFT) | FE_ALL_EXCEPT);
+ cw |= excepts;
+
+ /* Put the new data in effect. */
+ _FPU_SETFCW (cw);
+
+ /* Success. */
+ return 0;
+}
+
+versioned_symbol (libm, __feclearexcept, feclearexcept, GLIBC_2_2);
diff --git a/ports/sysdeps/am33/fpu/fedisblxcpt.c b/ports/sysdeps/am33/fpu/fedisblxcpt.c
new file mode 100644
index 000000000..b4a597773
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/fedisblxcpt.c
@@ -0,0 +1,42 @@
+/* Disable floating-point exceptions.
+ Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on corresponding file in the MIPS port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fenv_libc.h>
+#include <fpu_control.h>
+
+int
+fedisableexcept (int excepts)
+{
+ fpu_control_t new_exc, old_exc;
+
+ /* Get the current control word. */
+ _FPU_GETCW (new_exc);
+
+ old_exc = (new_exc & ENABLE_MASK) >> ENABLE_SHIFT;
+
+ excepts &= FE_ALL_EXCEPT;
+
+ new_exc &= ~(excepts << ENABLE_SHIFT);
+ _FPU_SETCW (new_exc);
+
+ return old_exc;
+}
diff --git a/ports/sysdeps/am33/fpu/feenablxcpt.c b/ports/sysdeps/am33/fpu/feenablxcpt.c
new file mode 100644
index 000000000..0ecaa1887
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/feenablxcpt.c
@@ -0,0 +1,42 @@
+/* Enable floating-point exceptions.
+ Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on corresponding file in the MIPS port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fenv_libc.h>
+#include <fpu_control.h>
+
+int
+feenableexcept (int excepts)
+{
+ fpu_control_t new_exc, old_exc;
+
+ /* Get the current control word. */
+ _FPU_GETCW (new_exc);
+
+ old_exc = (new_exc & ENABLE_MASK) >> ENABLE_SHIFT;
+
+ excepts &= FE_ALL_EXCEPT;
+
+ new_exc |= excepts << ENABLE_SHIFT;
+ _FPU_SETCW (new_exc);
+
+ return old_exc;
+}
diff --git a/ports/sysdeps/am33/fpu/fegetenv.c b/ports/sysdeps/am33/fpu/fegetenv.c
new file mode 100644
index 000000000..f0828011b
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/fegetenv.c
@@ -0,0 +1,35 @@
+/* Store current floating-point environment.
+ Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on corresponding file in the MIPS port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+#include <shlib-compat.h>
+
+int
+__fegetenv (fenv_t *envp)
+{
+ _FPU_GETCW (*envp);
+
+ /* Success. */
+ return 0;
+}
+
+versioned_symbol (libm, __fegetenv, fegetenv, GLIBC_2_2);
diff --git a/ports/sysdeps/am33/fpu/fegetexcept.c b/ports/sysdeps/am33/fpu/fegetexcept.c
new file mode 100644
index 000000000..500a0f822
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/fegetexcept.c
@@ -0,0 +1,35 @@
+/* Get enabled floating-point exceptions.
+ Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on corresponding file in the MIPS port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fenv_libc.h>
+#include <fpu_control.h>
+
+int
+fegetexcept (void)
+{
+ unsigned int exc;
+
+ /* Get the current control word. */
+ _FPU_GETCW (exc);
+
+ return (exc & ENABLE_MASK) >> ENABLE_SHIFT;
+}
diff --git a/ports/sysdeps/am33/fpu/fegetround.c b/ports/sysdeps/am33/fpu/fegetround.c
new file mode 100644
index 000000000..2b914075b
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/fegetround.c
@@ -0,0 +1,35 @@
+/* Return current rounding direction.
+ Copyright (C) 1998, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on corresponding file in the MIPS port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fenv_libc.h>
+#include <fpu_control.h>
+
+int
+fegetround (void)
+{
+ int cw;
+
+ /* Get control word. */
+ _FPU_GETCW (cw);
+
+ return (cw & ROUND_MASK);
+}
diff --git a/ports/sysdeps/am33/fpu/feholdexcpt.c b/ports/sysdeps/am33/fpu/feholdexcpt.c
new file mode 100644
index 000000000..e90fb67da
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/feholdexcpt.c
@@ -0,0 +1,39 @@
+/* Store current floating-point environment and clear exceptions.
+ Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on corresponding file in the MIPS port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+feholdexcept (fenv_t *envp)
+{
+ fpu_control_t cw;
+
+ /* Save the current state. */
+ _FPU_GETCW (cw);
+ *envp = cw;
+
+ /* Clear all exception enable bits and flags. */
+ cw &= ~(_FPU_MASK_V|_FPU_MASK_Z|_FPU_MASK_O|_FPU_MASK_U|_FPU_MASK_I);
+ _FPU_SETFCW (cw);
+
+ return 0;
+}
diff --git a/ports/sysdeps/am33/fpu/fenv_libc.h b/ports/sysdeps/am33/fpu/fenv_libc.h
new file mode 100644
index 000000000..508145470
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/fenv_libc.h
@@ -0,0 +1,33 @@
+/* Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on the corresponding file in the mips port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FENV_LIBC_H
+#define _FENV_LIBC_H 1
+
+/* Mask for enabling exceptions and for the CAUSE bits. */
+#define ENABLE_MASK 0x003E0U
+#define CAUSE_MASK 0x07C00U
+#define ROUND_MASK 0x30000U
+
+/* Shift for FE_* flags to get up to the ENABLE bits and the CAUSE bits. */
+#define ENABLE_SHIFT 5
+#define CAUSE_SHIFT 10
+
+#endif /* _FENV_LIBC_H */
diff --git a/ports/sysdeps/am33/fpu/fesetenv.c b/ports/sysdeps/am33/fpu/fesetenv.c
new file mode 100644
index 000000000..4c551a5c1
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/fesetenv.c
@@ -0,0 +1,60 @@
+/* Install given floating-point environment.
+ Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on corresponding file in the MIPS port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+#include <shlib-compat.h>
+
+int
+__fesetenv (const fenv_t *envp)
+{
+ fpu_control_t cw;
+
+ /* We want to clear all EF bits for the default end IEEE. */
+
+ if (envp == FE_DFL_ENV)
+ _FPU_SETFCW (_FPU_DEFAULT|FE_ALL_EXCEPT);
+ else if (envp == FE_NOMASK_ENV)
+ _FPU_SETFCW (_FPU_IEEE|FE_ALL_EXCEPT);
+ else
+ {
+ fpu_control_t temp;
+
+ _FPU_GETCW (temp);
+ cw = *envp;
+
+ /* If EF bits are cleared and the user requests them to be set,
+ we have to fail, because there's no way to do it. */
+ if (~temp & cw & FE_ALL_EXCEPT)
+ return -1;
+
+ /* We clear EF bits by storing a 1 in them, so flip the
+ FE_ALL_EXCEPT bits. */
+ cw = (cw & ~FE_ALL_EXCEPT) | (~cw & FE_ALL_EXCEPT);
+ _FPU_SETFCW (cw);
+ }
+
+ /* Success. */
+ return 0;
+}
+
+libm_hidden_ver (__fesetenv, fesetenv)
+versioned_symbol (libm, __fesetenv, fesetenv, GLIBC_2_2);
diff --git a/ports/sysdeps/am33/fpu/fesetround.c b/ports/sysdeps/am33/fpu/fesetround.c
new file mode 100644
index 000000000..b1e2b240c
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/fesetround.c
@@ -0,0 +1,29 @@
+/* Set current rounding direction.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+fesetround (int round)
+{
+ /* The only supported rounding mode is to-nearest. Just check
+ whether we're switching to it. */
+ return (round != FE_TONEAREST);
+}
diff --git a/ports/sysdeps/am33/fpu/feupdateenv.c b/ports/sysdeps/am33/fpu/feupdateenv.c
new file mode 100644
index 000000000..e4a0e39d2
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/feupdateenv.c
@@ -0,0 +1,47 @@
+/* Install given floating-point environment and raise exceptions.
+ Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on corresponding file in the MIPS port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+#include <shlib-compat.h>
+
+int
+__feupdateenv (const fenv_t *envp)
+{
+ int temp;
+
+ /* Save current exceptions. */
+ _FPU_GETCW (temp);
+ temp &= FE_ALL_EXCEPT;
+
+ /* Install new environment. */
+ fesetenv (envp);
+
+ /* Raise the safed exception. Incidently for us the implementation
+ defined format of the values in objects of type fexcept_t is the
+ same as the ones specified using the FE_* constants. */
+ feraiseexcept (temp);
+
+ /* Success. */
+ return 0;
+}
+
+versioned_symbol (libm, __feupdateenv, feupdateenv, GLIBC_2_2);
diff --git a/ports/sysdeps/am33/fpu/fgetexcptflg.c b/ports/sysdeps/am33/fpu/fgetexcptflg.c
new file mode 100644
index 000000000..0e8512c9c
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/fgetexcptflg.c
@@ -0,0 +1,44 @@
+/* Store current representation for exceptions.
+ Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on corresponding file in the MIPS port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+#include <shlib-compat.h>
+
+int
+__fegetexceptflag (fexcept_t *flagp, int excepts)
+{
+ fexcept_t temp;
+
+ /* Get the current exceptions. */
+ _FPU_GETCW (temp);
+
+ /* We only save the relevant bits here. In particular, care has to be
+ taken with the CAUSE bits, as an inadvertent restore later on could
+ generate unexpected exceptions. */
+
+ *flagp = temp & excepts & FE_ALL_EXCEPT;
+
+ /* Success. */
+ return 0;
+}
+
+versioned_symbol (libm, __fegetexceptflag, fegetexceptflag, GLIBC_2_2);
diff --git a/ports/sysdeps/am33/fpu/fpu_control.h b/ports/sysdeps/am33/fpu/fpu_control.h
new file mode 100644
index 000000000..c0612ba53
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/fpu_control.h
@@ -0,0 +1,75 @@
+/* FPU control word bits. AM33/2.0 version.
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on the corresponding file in the mips port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FPU_CONTROL_H
+#define _FPU_CONTROL_H
+
+/* AM33/2.0 FPU floating point control register bits.
+ *
+ * 31-22 -> reserved
+ * 21-18 -> floating-point condition codes (L, G, E, U)
+ * 17-16 -> rounding modes (00 is to-nearest; other values are reserved
+ * 15 -> reserved (read as 0, write with 0)
+ * 14-10 -> Exception Cause (inValid, divZero, Overflow, Underflow, Inexact)
+ * 9- 5 -> Exception Enable
+ * 4- 0 -> Exception Flag, cleared when exception cause is set
+ */
+
+#include <features.h>
+#include <fenv.h>
+
+/* masking of interrupts */
+#define _FPU_MASK_V 0x0200 /* Invalid operation */
+#define _FPU_MASK_Z 0x0100 /* Division by zero */
+#define _FPU_MASK_O 0x0080 /* Overflow */
+#define _FPU_MASK_U 0x0040 /* Underflow */
+#define _FPU_MASK_I 0x0020 /* Inexact operation */
+
+/* rounding control */
+#define _FPU_RC_NEAREST 0x0 /* Only available mode */
+
+#define _FPU_RESERVED 0xffc08000 /* Reserved bits in fpcr */
+
+
+/* The fdlibm code requires strict IEEE double precision arithmetic,
+ and no interrupts for exceptions, rounding to nearest. */
+
+#define _FPU_DEFAULT 0x0000001f
+
+/* IEEE: same as above, but exceptions */
+#define _FPU_IEEE 0x000003ff
+
+/* Type of the control word. */
+typedef unsigned int fpu_control_t;
+
+/* Macros for accessing the hardware control word. _FPU_SETCW is
+ defined such that it won't modify the EF bits, that are cleared
+ when assigned bits that are set. Use SETFCW to get them actually
+ reset. */
+#define _FPU_SETFCW(cw) __asm__ ("fmov %0,fpcr" : : "ri" (cw))
+#define _FPU_SETCW(cw) _FPU_SETFCW((cw) & ~FE_ALL_EXCEPT)
+#define _FPU_GETCW(cw) __asm__ ("fmov fpcr,%0" : "=r" (cw))
+
+/* Default control word set at startup. */
+extern fpu_control_t __fpu_control;
+
+#endif /* fpu_control.h */
diff --git a/ports/sysdeps/am33/fpu/fraiseexcpt.c b/ports/sysdeps/am33/fpu/fraiseexcpt.c
new file mode 100644
index 000000000..3405ce509
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/fraiseexcpt.c
@@ -0,0 +1,79 @@
+/* Raise given exceptions.
+ Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on corresponding file in the M68K port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <float.h>
+#include <math.h>
+#include <shlib-compat.h>
+
+int
+__feraiseexcept (int excepts)
+{
+ /* Raise exceptions represented by EXCEPTS. But we must raise only one
+ signal at a time. It is important that if the overflow/underflow
+ exception and the divide by zero exception are given at the same
+ time, the overflow/underflow exception follows the divide by zero
+ exception. */
+
+ /* First: invalid exception. */
+ if (excepts & FE_INVALID)
+ {
+ /* One example of a invalid operation is 0 * Infinity. */
+ float x = HUGE_VALF, y = 0.0f;
+ __asm__ __volatile__ ("fmul %1,%0" : "+f" (x) : "f" (y));
+ }
+
+ /* Next: division by zero. */
+ if (excepts & FE_DIVBYZERO)
+ {
+ float x = 1.0f, y = 0.0f;
+ __asm__ __volatile__ ("fdiv %1,%0" : "+f" (x) : "f" (y));
+ }
+
+ /* Next: overflow. */
+ if (excepts & FE_OVERFLOW)
+ {
+ float x = FLT_MAX;
+
+ __asm__ __volatile__ ("fmul %0,%0" : "+f" (x));
+ }
+
+ /* Next: underflow. */
+ if (excepts & FE_UNDERFLOW)
+ {
+ float x = -FLT_MIN;
+
+ __asm__ __volatile__ ("fmul %0,%0" : "+f" (x));
+ }
+
+ /* Last: inexact. */
+ if (excepts & FE_INEXACT)
+ {
+ float x = 1.0f, y = 3.0f;
+ __asm__ __volatile__ ("fdiv %1,%0" : "=f" (x) : "f" (y));
+ }
+
+ /* Success. */
+ return 0;
+}
+
+libm_hidden_ver (__feraiseexcept, feraiseexcept)
+versioned_symbol (libm, __feraiseexcept, feraiseexcept, GLIBC_2_2);
diff --git a/ports/sysdeps/am33/fpu/fsetexcptflg.c b/ports/sysdeps/am33/fpu/fsetexcptflg.c
new file mode 100644
index 000000000..be315a44b
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/fsetexcptflg.c
@@ -0,0 +1,57 @@
+/* Set floating-point environment exception handling.
+ Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on corresponding file in the MIPS port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+#include <shlib-compat.h>
+
+int
+__fesetexceptflag (const fexcept_t *flagp, int excepts)
+{
+ fpu_control_t cw, temp;
+
+ /* Get the current exceptions. */
+ _FPU_GETCW (cw);
+
+ /* Make sure the flags we want restored are legal. */
+ excepts &= FE_ALL_EXCEPT;
+ temp = *flagp & excepts;
+
+ /* If EF bits are clear and the user requests them to be set,
+ we have to fail, because there's no way to do it. */
+ if (~(cw & excepts) & temp)
+ return -1;
+
+ /* We clear EF bits by storing a 1 in them, so flip the
+ FE_ALL_EXCEPT bits. */
+ temp = (~temp & FE_ALL_EXCEPT);
+
+ /* Now clear the bits called for, and copy them in from flagp. Note that
+ we ignore all non-flag bits from *flagp, so they don't matter. */
+ cw = (cw & ~FE_ALL_EXCEPT) | temp;
+
+ _FPU_SETFCW (cw);
+
+ /* Success. */
+ return 0;
+}
+
+versioned_symbol (libm, __fesetexceptflag, fesetexceptflag, GLIBC_2_2);
diff --git a/ports/sysdeps/am33/fpu/ftestexcept.c b/ports/sysdeps/am33/fpu/ftestexcept.c
new file mode 100644
index 000000000..0e0db4ca3
--- /dev/null
+++ b/ports/sysdeps/am33/fpu/ftestexcept.c
@@ -0,0 +1,34 @@
+/* Test exception in current environment.
+ Copyright (C) 1998, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ based on corresponding file in the MIPS port.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fetestexcept (int excepts)
+{
+ int cw;
+
+ /* Get current control word. */
+ _FPU_GETCW (cw);
+
+ return cw & excepts & FE_ALL_EXCEPT;
+}
diff --git a/ports/sysdeps/am33/jmpbuf-offsets.h b/ports/sysdeps/am33/jmpbuf-offsets.h
new file mode 100644
index 000000000..1a8520af4
--- /dev/null
+++ b/ports/sysdeps/am33/jmpbuf-offsets.h
@@ -0,0 +1,20 @@
+/* Private macros for accessing __jmp_buf contents. AM33 version.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define __JMP_BUF_SP 20
diff --git a/ports/sysdeps/am33/jmpbuf-unwind.h b/ports/sysdeps/am33/jmpbuf-unwind.h
new file mode 100644
index 000000000..1566a0b19
--- /dev/null
+++ b/ports/sysdeps/am33/jmpbuf-unwind.h
@@ -0,0 +1,26 @@
+/* Examine __jmp_buf for unwinding frames. AM33 version.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
+ ((void *) (address) < (void *) demangle (jmpbuf[__JMP_BUF_SP]))
diff --git a/ports/sysdeps/am33/linuxthreads/pspinlock.c b/ports/sysdeps/am33/linuxthreads/pspinlock.c
new file mode 100644
index 000000000..5eaf81668
--- /dev/null
+++ b/ports/sysdeps/am33/linuxthreads/pspinlock.c
@@ -0,0 +1,74 @@
+/* POSIX spinlock implementation. AM33 version.
+ Copyright 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ __asm__ __volatile__("1: bset %1, (%0); beq 1b"
+ : : "a" (lock), "d" (1) : "memory");
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ int oldval = 1;
+
+ __asm__ __volatile__ ("bset %0, (%1); beq 1f; clr %0; 1:" :
+ "+d" (oldval) : "a" (lock) : "memory");
+
+ return oldval ? EBUSY : 0;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ *lock = 0;
+ return 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ *lock = 0;
+ return 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/ports/sysdeps/am33/linuxthreads/pt-machine.h b/ports/sysdeps/am33/linuxthreads/pt-machine.h
new file mode 100644
index 000000000..ba80bfb5e
--- /dev/null
+++ b/ports/sysdeps/am33/linuxthreads/pt-machine.h
@@ -0,0 +1,68 @@
+/* Machine-dependent pthreads configuration and inline functions.
+ am33 version.
+ Copyright (C) 1996,1997,1998,1999,2000,2001, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ Based on ../i386/pt-machine.h.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#ifndef __ASSEMBLER__
+#ifndef PT_EI
+# define PT_EI extern inline
+#endif
+
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
+
+/* Spinlock implementation; required. */
+PT_EI long int
+testandset (int *spinlock)
+{
+ long int ret = 1;
+
+ /* This won't test&set the entire int, only the least significant
+ byte. I hope this doesn't matter, since we can't do better. */
+ __asm__ __volatile__ ("bset %0, %1; bne 1f; clr %0; 1:" :
+ "+d" (ret), "+m" (*(volatile int *)spinlock));
+
+ return ret;
+}
+
+
+PT_EI int
+get_eflags (void)
+{
+ int res;
+ __asm__ __volatile__ ("mov psw,%0" : "=d" (res));
+ return res;
+}
+
+
+PT_EI void
+set_eflags (int newflags)
+{
+ __asm__ __volatile__ ("mov %0,psw" : : "d" (newflags) : "cc");
+}
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* pt-machine.h */
diff --git a/ports/sysdeps/am33/memusage.h b/ports/sysdeps/am33/memusage.h
new file mode 100644
index 000000000..9913e781e
--- /dev/null
+++ b/ports/sysdeps/am33/memusage.h
@@ -0,0 +1,23 @@
+/* Copyright 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define GETSP() ({ uintptr_t stack_ptr; \
+ asm ("mov sp,%0" : "=a" (stack_ptr)); \
+ stack_ptr; })
+
+#include <sysdeps/generic/memusage.h>
diff --git a/ports/sysdeps/am33/preconfigure b/ports/sysdeps/am33/preconfigure
new file mode 100644
index 000000000..949546538
--- /dev/null
+++ b/ports/sysdeps/am33/preconfigure
@@ -0,0 +1,5 @@
+case "$machine" in
+am33*)
+ base_machine=am33 machine=am33
+ ;;
+esac
diff --git a/ports/sysdeps/am33/setjmp.S b/ports/sysdeps/am33/setjmp.S
new file mode 100644
index 000000000..26ec2ed49
--- /dev/null
+++ b/ports/sysdeps/am33/setjmp.S
@@ -0,0 +1,80 @@
+/* setjmp for am33.
+ Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _ASM
+#define _SETJMP_H
+#include <bits/setjmp.h>
+#include <asm-syntax.h>
+
+
+ENTRY (__sigsetjmp)
+.Lsigsetjmp:
+ /* Save registers. */
+ mov d0,a0
+ mov d2,(0,a0)
+ mov d3,(4,a0)
+ mov mdr,d0
+ mov d0,(8,a0)
+ /* Restore d0 for __sigjmp_save. */
+ mov a0,d0
+ mov a2,(12,a0)
+ mov a3,(16,a0)
+ mov sp,a1
+ mov a1,(20,a0)
+ add 24,a0
+ mov r4,(a0+)
+ mov r5,(a0+)
+ mov r6,(a0+)
+ mov r7,(a0+)
+#ifdef __AM33_2__
+ fmov fs4,(a0+)
+ fmov fs5,(a0+)
+ fmov fs6,(a0+)
+ fmov fs7,(a0+)
+ fmov fs8,(a0+)
+ fmov fs9,(a0+)
+ fmov fs10,(a0+)
+ fmov fs11,(a0+)
+ fmov fs12,(a0+)
+ fmov fs13,(a0+)
+ fmov fs14,(a0+)
+ fmov fs15,(a0+)
+ fmov fs16,(a0+)
+ fmov fs17,(a0+)
+ fmov fs18,(a0+)
+ fmov fs19,(a0+)
+#endif
+ /* Make a tail call to __sigjmp_save; it takes the same args. */
+ jmp __sigjmp_save
+END (__sigsetjmp)
+
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 1)'. */
+ENTRY (setjmp)
+ /* Tail-call setsetjmp with savesigs==1. */
+ mov 1,d1
+ bra .Lsigsetjmp
+END (setjmp)
+
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. */
+ENTRY (_setjmp)
+ /* Tail-call setsetjmp with savesigs==0. */
+ clr d1
+ bra .Lsigsetjmp
+END (_setjmp)
diff --git a/ports/sysdeps/am33/shlib-versions b/ports/sysdeps/am33/shlib-versions
new file mode 100644
index 000000000..ad6ded9dc
--- /dev/null
+++ b/ports/sysdeps/am33/shlib-versions
@@ -0,0 +1 @@
+am33.*-.*-linux.* DEFAULT GLIBC_2.2.5
diff --git a/ports/sysdeps/am33/stackinfo.h b/ports/sysdeps/am33/stackinfo.h
new file mode 100644
index 000000000..a64027a6a
--- /dev/null
+++ b/ports/sysdeps/am33/stackinfo.h
@@ -0,0 +1,28 @@
+/* Copyright 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file contains a bit of information about the stack allocation
+ of the processor. */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+/* On am33 the stack grows down. */
+#define _STACK_GROWS_DOWN 1
+
+#endif /* stackinfo.h */
diff --git a/ports/sysdeps/am33/sys/ucontext.h b/ports/sysdeps/am33/sys/ucontext.h
new file mode 100644
index 000000000..7995aae42
--- /dev/null
+++ b/ports/sysdeps/am33/sys/ucontext.h
@@ -0,0 +1,123 @@
+/* Copyright 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* AM33/2.0 context switching support. */
+
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <signal.h>
+
+/* Type for general register. */
+typedef int greg_t;
+
+/* Number of general registers. */
+#define NGREG 28
+
+/* Container for all general registers. */
+typedef greg_t gregset_t[NGREG];
+
+/* Number of each register is the `gregset_t' array. */
+enum
+{
+ REG_D0 = 0,
+#define REG_D0 REG_D0
+ REG_D1,
+#define REG_D1 REG_D1
+ REG_D2,
+#define REG_D2 REG_D2
+ REG_D3,
+#define REG_D3 REG_D3
+ REG_A0,
+#define REG_A0 REG_A0
+ REG_A1,
+#define REG_A1 REG_A1
+ REG_A2,
+#define REG_A2 REG_A2
+ REG_A3,
+#define REG_A3 REG_A3
+ REG_E0,
+#define REG_E0 REG_E0
+ REG_E1,
+#define REG_E1 REG_E1
+ REG_E2,
+#define REG_E2 REG_E2
+ REG_E3,
+#define REG_E3 REG_E3
+ REG_E4,
+#define REG_E4 REG_E4
+ REG_E5,
+#define REG_E5 REG_E5
+ REG_E6,
+#define REG_E6 REG_E6
+ REG_E7,
+#define REG_E7 REG_E7
+ REG_LAR,
+#define REG_LAR REG_LAR
+ REG_LIR,
+#define REG_LIR REG_LIR
+ REG_MDR,
+#define REG_MDR REG_MDR
+ REG_MCVF,
+#define REG_MCVF REG_MCVF
+ REG_MCRL,
+#define REG_MCRL REG_MCRL
+ REG_MCRH,
+#define REG_MCRH REG_MCRH
+ REG_MDRQ,
+#define REG_MDRQ REG_MDRQ
+ REG_SP,
+#define REG_SP REG_SP
+ REG_EPSW,
+#define REG_EPSW REG_EPSW
+ REG_PC,
+#define REG_PC REG_PC
+};
+
+typedef int freg_t;
+
+/* Structure to describe FPU registers. */
+typedef struct {
+ union {
+ double fp_dregs[16];
+ float fp_fregs[32];
+ freg_t fp_regs[32];
+ } regs;
+ freg_t fpcr;
+} fpregset_t;
+
+/* Context to describe whole processor state. */
+typedef struct
+ {
+ gregset_t gregs;
+ fpregset_t fpregs;
+ } mcontext_t;
+
+/* Userlevel context. */
+typedef struct ucontext
+ {
+ unsigned long int uc_flags;
+ struct ucontext *uc_link;
+ __sigset_t uc_sigmask;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ long int uc_filler[5];
+ } ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/ports/sysdeps/am33/sysdep.h b/ports/sysdeps/am33/sysdep.h
new file mode 100644
index 000000000..efd052714
--- /dev/null
+++ b/ports/sysdeps/am33/sysdep.h
@@ -0,0 +1,82 @@
+/* Copyright 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>.
+ Based on ../i386/sysdep.h.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdeps/generic/sysdep.h>
+
+#ifdef __ASSEMBLER__
+
+/* Syntactic details of assembler. */
+
+#ifdef HAVE_ELF
+/* For ELF we need the `.type' directive to make shared libs work right. */
+#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
+#define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
+
+/* In ELF C symbols are asm symbols. */
+#undef NO_UNDERSCORES
+#define NO_UNDERSCORES
+#else
+#define ASM_TYPE_DIRECTIVE(name,type) /* Nothing is specified. */
+#define ASM_SIZE_DIRECTIVE(name) /* Nothing is specified. */
+#endif
+
+/* Define an entry point visible from C. */
+#define ENTRY(name) \
+ ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
+ C_LABEL(name) \
+ CALL_MCOUNT
+
+#undef END
+#define END(name) \
+ ASM_SIZE_DIRECTIVE(name) \
+
+/* If compiled for profiling, call `mcount' at the start of each function. */
+#ifdef PROF
+/* The mcount code relies on a normal frame pointer being on the stack
+ to locate our caller, so push one just for its benefit. */
+#define CALL_MCOUNT \
+ movm [a3],(sp); mov sp,a3; add -12,sp; \
+ call JUMPTARGET(mcount),[],0; add 12,sp; movm (sp),[a3];
+#else
+#define CALL_MCOUNT /* Do nothing. */
+#endif
+
+#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
+#define mcount _mcount
+#endif
+
+#undef JUMPTARGET
+#ifdef PIC
+#define JUMPTARGET(name) name##@PLT
+#else
+#define JUMPTARGET(name) name
+#endif
+
+/* Local label name for asm code. */
+#ifndef L
+#define L(name) name
+#endif
+
+#endif /* __ASSEMBLER__ */
diff --git a/ports/sysdeps/arm/Implies b/ports/sysdeps/arm/Implies
new file mode 100644
index 000000000..780c4e246
--- /dev/null
+++ b/ports/sysdeps/arm/Implies
@@ -0,0 +1,3 @@
+wordsize-32
+ieee754/flt-32
+ieee754/dbl-64
diff --git a/ports/sysdeps/arm/__longjmp.S b/ports/sysdeps/arm/__longjmp.S
new file mode 100644
index 000000000..7b3016004
--- /dev/null
+++ b/ports/sysdeps/arm/__longjmp.S
@@ -0,0 +1,33 @@
+/* longjmp for ARM.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+
+/* __longjmp(jmpbuf, val) */
+
+ENTRY (__longjmp)
+ mov ip, r0
+ movs r0, r1 /* get the return value in place */
+ moveq r0, #1 /* can't let setjmp() return zero! */
+
+ LOADREGS(ia, ip, {v1-v6, sl, fp, sp, pc})
+END (__longjmp)
diff --git a/ports/sysdeps/arm/bits/atomic.h b/ports/sysdeps/arm/bits/atomic.h
new file mode 100644
index 000000000..14d2dbe0e
--- /dev/null
+++ b/ports/sysdeps/arm/bits/atomic.h
@@ -0,0 +1,101 @@
+/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdint.h>
+#include <sysdep.h>
+
+
+typedef int8_t atomic8_t;
+typedef uint8_t uatomic8_t;
+typedef int_fast8_t atomic_fast8_t;
+typedef uint_fast8_t uatomic_fast8_t;
+
+typedef int32_t atomic32_t;
+typedef uint32_t uatomic32_t;
+typedef int_fast32_t atomic_fast32_t;
+typedef uint_fast32_t uatomic_fast32_t;
+
+typedef intptr_t atomicptr_t;
+typedef uintptr_t uatomicptr_t;
+typedef intmax_t atomic_max_t;
+typedef uintmax_t uatomic_max_t;
+
+void __arm_link_error (void);
+
+#define atomic_exchange_acq(mem, newvalue) \
+ ({ __typeof (*mem) result; \
+ if (sizeof (*mem) == 1) \
+ __asm__ __volatile__ ("swpb %0, %1, [%2]" \
+ : "=&r,&r" (result) \
+ : "r,0" (newvalue), "r,r" (mem) : "memory"); \
+ else if (sizeof (*mem) == 4) \
+ __asm__ __volatile__ ("swp %0, %1, [%2]" \
+ : "=&r,&r" (result) \
+ : "r,0" (newvalue), "r,r" (mem) : "memory"); \
+ else \
+ { \
+ result = 0; \
+ abort (); \
+ } \
+ result; })
+
+/* Atomic compare and exchange. These sequences are not actually atomic;
+ there is a race if *MEM != OLDVAL and we are preempted between the two
+ swaps. However, they are very close to atomic, and are the best that a
+ pre-ARMv6 implementation can do without operating system support.
+ LinuxThreads has been using these sequences for many years. */
+
+#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+ ({ __typeof (oldval) result, tmp; \
+ __asm__ ("\n" \
+ "0:\tldr\t%1,[%2]\n\t" \
+ "cmp\t%1,%4\n\t" \
+ "movne\t%0,%1\n\t" \
+ "bne\t1f\n\t" \
+ "swpb\t%0,%3,[%2]\n\t" \
+ "cmp\t%1,%0\n\t" \
+ "swpbne\t%1,%0,[%2]\n\t" \
+ "bne\t0b\n\t" \
+ "1:" \
+ : "=&r" (result), "=&r" (tmp) \
+ : "r" (mem), "r" (newval), "r" (oldval) \
+ : "cc", "memory"); \
+ result; })
+
+#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
+ ({ __arm_link_error (); oldval; })
+
+#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
+ ({ __typeof (oldval) result, tmp; \
+ __asm__ ("\n" \
+ "0:\tldr\t%1,[%2]\n\t" \
+ "cmp\t%1,%4\n\t" \
+ "movne\t%0,%1\n\t" \
+ "bne\t1f\n\t" \
+ "swp\t%0,%3,[%2]\n\t" \
+ "cmp\t%1,%0\n\t" \
+ "swpne\t%1,%0,[%2]\n\t" \
+ "bne\t0b\n\t" \
+ "1:" \
+ : "=&r" (result), "=&r" (tmp) \
+ : "r" (mem), "r" (newval), "r" (oldval) \
+ : "cc", "memory"); \
+ result; })
+
+#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
+ ({ __arm_link_error (); oldval; })
diff --git a/ports/sysdeps/arm/bits/endian.h b/ports/sysdeps/arm/bits/endian.h
new file mode 100644
index 000000000..dc909c33e
--- /dev/null
+++ b/ports/sysdeps/arm/bits/endian.h
@@ -0,0 +1,19 @@
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+/* ARM can be either big or little endian. */
+#ifdef __ARMEB__
+#define __BYTE_ORDER __BIG_ENDIAN
+#else
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
+
+/* FPA floating point units are always big-endian, irrespective of the
+ CPU endianness. VFP floating point units use the same endianness
+ as the rest of the system. */
+#ifdef __VFP_FP__
+#define __FLOAT_WORD_ORDER __BYTE_ORDER
+#else
+#define __FLOAT_WORD_ORDER __BIG_ENDIAN
+#endif
diff --git a/ports/sysdeps/arm/bits/huge_val.h b/ports/sysdeps/arm/bits/huge_val.h
new file mode 100644
index 000000000..3339a0d01
--- /dev/null
+++ b/ports/sysdeps/arm/bits/huge_val.h
@@ -0,0 +1,56 @@
+/* `HUGE_VAL' constant for IEEE 754 machines (where it is infinity).
+ Used by <stdlib.h> and <math.h> functions for overflow.
+ ARM version.
+ Copyright (C) 1992, 95, 96, 97, 98, 99, 2000, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MATH_H
+# error "Never use <bits/huge_val.h> directly; include <math.h> instead."
+#endif
+
+/* IEEE positive infinity (-HUGE_VAL is negative infinity). */
+
+#if __GNUC_PREREQ(3,3)
+# define HUGE_VAL (__builtin_huge_val())
+#elif __GNUC_PREREQ(2,96)
+# define HUGE_VAL (__extension__ 0x1.0p2047)
+#elif defined __GNUC__
+
+# define HUGE_VAL \
+ (__extension__ \
+ ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) \
+ { __l: 0x000000007ff00000ULL }).__d)
+
+#else /* not GCC */
+
+# include <endian.h>
+
+typedef union { unsigned char __c[8]; double __d; } __huge_val_t;
+
+# if __BYTE_ORDER == __BIG_ENDIAN
+# define __HUGE_VAL_bytes { 0, 0, 0, 0, 0x7f, 0xf0, 0, 0 }
+# endif
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define __HUGE_VAL_bytes { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 }
+# endif
+
+static __huge_val_t __huge_val = { __HUGE_VAL_bytes };
+# define HUGE_VAL (__huge_val.__d)
+
+#endif /* GCC. */
diff --git a/ports/sysdeps/arm/bits/link.h b/ports/sysdeps/arm/bits/link.h
new file mode 100644
index 000000000..8dbd2c7ba
--- /dev/null
+++ b/ports/sysdeps/arm/bits/link.h
@@ -0,0 +1,66 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _LINK_H
+# error "Never include <bits/link.h> directly; use <link.h> instead."
+#endif
+
+
+/* Registers for entry into PLT on ARM. */
+typedef struct La_arm_regs
+{
+ uint32_t lr_reg[4];
+ uint32_t lr_sp;
+ uint32_t lr_lr;
+ /* Coprocessor registers used for argument passing. The data
+ stored here depends on the coprocessors available in the
+ system which are used for function calls in the current ABI.
+ VFP uses eight 64-bit registers, and iWMMXt uses ten. */
+ uint32_t lr_coproc[42];
+} La_arm_regs;
+
+/* Return values for calls from PLT on ARM. */
+typedef struct La_arm_retval
+{
+ /* Up to four integer registers can be used for a return value in
+ some ABIs (APCS complex long double). */
+ uint32_t lrv_reg[4];
+
+ /* Any coprocessor registers which might be used to return values
+ in the current ABI. */
+ uint32_t lrv_coproc[12];
+} La_arm_retval;
+
+
+__BEGIN_DECLS
+
+extern Elf32_Addr la_arm_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ La_arm_regs *__regs,
+ unsigned int *__flags,
+ const char *__symname,
+ long int *__framesizep);
+extern unsigned int la_arm_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ const La_arm_regs *__inregs,
+ La_arm_retval *__outregs,
+ const char *symname);
+
+__END_DECLS
diff --git a/ports/sysdeps/arm/bits/linkmap.h b/ports/sysdeps/arm/bits/linkmap.h
new file mode 100644
index 000000000..648976d7d
--- /dev/null
+++ b/ports/sysdeps/arm/bits/linkmap.h
@@ -0,0 +1,4 @@
+struct link_map_machine
+ {
+ Elf32_Addr plt; /* Address of .plt */
+ };
diff --git a/ports/sysdeps/arm/bits/setjmp.h b/ports/sysdeps/arm/bits/setjmp.h
new file mode 100644
index 000000000..2792350f8
--- /dev/null
+++ b/ports/sysdeps/arm/bits/setjmp.h
@@ -0,0 +1,34 @@
+/* Copyright (C) 1997,1998,2005,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Define the machine-dependent type `jmp_buf'. ARM version. */
+
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H 1
+
+#if !defined _SETJMP_H && !defined _PTHREAD_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+#ifndef _ASM
+/* Jump buffer contains v1-v6, sl, fp, sp and pc. Other registers are not
+ saved. */
+typedef int __jmp_buf[10];
+#endif
+
+#endif
diff --git a/ports/sysdeps/arm/bits/string.h b/ports/sysdeps/arm/bits/string.h
new file mode 100644
index 000000000..206f956df
--- /dev/null
+++ b/ports/sysdeps/arm/bits/string.h
@@ -0,0 +1,31 @@
+/* Optimized, inlined string functions. ARM version.
+ Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _STRING_H
+# error "Never use <bits/string.h> directly; include <string.h> instead."
+#endif
+
+/* We must defeat the generic optimized versions of these functions in
+ <bits/string2.h> since they don't work on the ARM. This is because
+ the games they play with the __STRING2_COPY_ARR# structures fail
+ when structs are always 32-bit aligned.
+ XXX Should provide suitably optimal replacements. */
+#define _HAVE_STRING_ARCH_strcpy 1
+#define _HAVE_STRING_ARCH_stpcpy 1
+#define _HAVE_STRING_ARCH_mempcpy 1
diff --git a/ports/sysdeps/arm/bsd-_setjmp.S b/ports/sysdeps/arm/bsd-_setjmp.S
new file mode 100644
index 000000000..c4a094e50
--- /dev/null
+++ b/ports/sysdeps/arm/bsd-_setjmp.S
@@ -0,0 +1,30 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. ARM version.
+ Copyright (C) 1997, 1998, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
+ We cannot do it in C because it must be a tail-call, so frame-unwinding
+ in setjmp doesn't clobber the state restored by longjmp. */
+
+#include <sysdep.h>
+
+ENTRY (_setjmp)
+ mov r1, #0
+ b PLTJMP(C_SYMBOL_NAME(__sigsetjmp))
+END (_setjmp)
+libc_hidden_def (_setjmp)
diff --git a/ports/sysdeps/arm/bsd-setjmp.S b/ports/sysdeps/arm/bsd-setjmp.S
new file mode 100644
index 000000000..d227ba68a
--- /dev/null
+++ b/ports/sysdeps/arm/bsd-setjmp.S
@@ -0,0 +1,29 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. ARM version.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
+ We cannot do it in C because it must be a tail-call, so frame-unwinding
+ in setjmp doesn't clobber the state restored by longjmp. */
+
+#include <sysdep.h>
+
+ENTRY (setjmp)
+ mov r1, #1
+ b PLTJMP(C_SYMBOL_NAME(__sigsetjmp))
+END (setjmp)
diff --git a/ports/sysdeps/arm/dl-machine.h b/ports/sysdeps/arm/dl-machine.h
new file mode 100644
index 000000000..ff8a17066
--- /dev/null
+++ b/ports/sysdeps/arm/dl-machine.h
@@ -0,0 +1,603 @@
+/* Machine-dependent ELF dynamic relocation inline functions. ARM version.
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef dl_machine_h
+#define dl_machine_h
+
+#define ELF_MACHINE_NAME "ARM"
+
+#include <sys/param.h>
+#include <tls.h>
+
+#define VALID_ELF_ABIVERSION(ver) (ver == 0)
+#define VALID_ELF_OSABI(osabi) \
+ (osabi == ELFOSABI_SYSV || osabi == ELFOSABI_ARM)
+#define VALID_ELF_HEADER(hdr,exp,size) \
+ memcmp (hdr,exp,size-2) == 0 \
+ && VALID_ELF_OSABI (hdr[EI_OSABI]) \
+ && VALID_ELF_ABIVERSION (hdr[EI_ABIVERSION])
+
+#define CLEAR_CACHE(BEG,END) \
+ INTERNAL_SYSCALL_ARM (cacheflush, , 3, (BEG), (END), 0)
+
+/* Return nonzero iff ELF header is compatible with the running host. */
+static inline int __attribute__ ((unused))
+elf_machine_matches_host (const Elf32_Ehdr *ehdr)
+{
+ return ehdr->e_machine == EM_ARM;
+}
+
+
+/* Return the link-time address of _DYNAMIC. Conveniently, this is the
+ first element of the GOT. We used to use the PIC register to do this
+ without a constant pool reference, but GCC 4.2 will use a pseudo-register
+ for the PIC base, so it may not be in r10. */
+static inline Elf32_Addr __attribute__ ((unused))
+elf_machine_dynamic (void)
+{
+ Elf32_Addr dynamic;
+ asm ("ldr %0, 2f\n"
+ "1: ldr %0, [pc, %0]\n"
+ "b 3f\n"
+ "2: .word _GLOBAL_OFFSET_TABLE_ - (1b+8)\n"
+ "3:" : "=r" (dynamic));
+ return dynamic;
+}
+
+
+/* Return the run-time load address of the shared object. */
+static inline Elf32_Addr __attribute__ ((unused))
+elf_machine_load_address (void)
+{
+ extern void __dl_start asm ("_dl_start");
+ Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
+ Elf32_Addr pcrel_addr;
+ asm ("adr %0, _dl_start" : "=r" (pcrel_addr));
+ return pcrel_addr - got_addr;
+}
+
+
+/* Set up the loaded object described by L so its unrelocated PLT
+ entries will jump to the on-demand fixup code in dl-runtime.c. */
+
+static inline int __attribute__ ((unused))
+elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
+{
+ Elf32_Addr *got;
+ extern void _dl_runtime_resolve (Elf32_Word);
+ extern void _dl_runtime_profile (Elf32_Word);
+
+ if (l->l_info[DT_JMPREL] && lazy)
+ {
+ /* patb: this is different than i386 */
+ /* The GOT entries for functions in the PLT have not yet been filled
+ in. Their initial contents will arrange when called to push an
+ index into the .got section, load ip with &_GLOBAL_OFFSET_TABLE_[3],
+ and then jump to _GLOBAL_OFFSET_TABLE[2]. */
+ got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]);
+ /* If a library is prelinked but we have to relocate anyway,
+ we have to be able to undo the prelinking of .got.plt.
+ The prelinker saved us here address of .plt. */
+ if (got[1])
+ l->l_mach.plt = got[1] + l->l_addr;
+ got[1] = (Elf32_Addr) l; /* Identify this shared object. */
+
+ /* The got[2] entry contains the address of a function which gets
+ called to get the address of a so far unresolved function and
+ jump to it. The profiling extension of the dynamic linker allows
+ to intercept the calls to collect information. In this case we
+ don't store the address in the GOT so that all future calls also
+ end in this function. */
+ if (profile)
+ {
+ got[2] = (Elf32_Addr) &_dl_runtime_profile;
+
+ if (GLRO(dl_profile) != NULL
+ && _dl_name_match_p (GLRO(dl_profile), l))
+ /* Say that we really want profiling and the timers are
+ started. */
+ GL(dl_profile_map) = l;
+ }
+ else
+ /* This function will get called to fix up the GOT entry indicated by
+ the offset on the stack, and then jump to the resolved address. */
+ got[2] = (Elf32_Addr) &_dl_runtime_resolve;
+ }
+ return lazy;
+}
+
+#if defined(__USE_BX__)
+#define BX(x) "bx\t" #x
+#else
+#define BX(x) "mov\tpc, " #x
+#endif
+
+/* Mask identifying addresses reserved for the user program,
+ where the dynamic linker should not map anything. */
+#define ELF_MACHINE_USER_ADDRESS_MASK 0xf8000000UL
+
+/* Initial entry point code for the dynamic linker.
+ The C function `_dl_start' is the real entry point;
+ its return value is the user program's entry point. */
+
+#define RTLD_START asm ("\
+.text\n\
+.globl _start\n\
+.globl _dl_start_user\n\
+_start:\n\
+ @ we are PIC code, so get global offset table\n\
+ ldr sl, .L_GET_GOT\n\
+ @ See if we were run as a command with the executable file\n\
+ @ name as an extra leading argument.\n\
+ ldr r4, .L_SKIP_ARGS\n\
+ @ at start time, all the args are on the stack\n\
+ mov r0, sp\n\
+ bl _dl_start\n\
+ @ returns user entry point in r0\n\
+_dl_start_user:\n\
+ add sl, pc, sl\n\
+.L_GOT_GOT:\n\
+ ldr r4, [sl, r4]\n\
+ @ save the entry point in another register\n\
+ mov r6, r0\n\
+ @ get the original arg count\n\
+ ldr r1, [sp]\n\
+ @ get the argv address\n\
+ add r2, sp, #4\n\
+ @ Fix up the stack if necessary.\n\
+ cmp r4, #0\n\
+ bne .L_fixup_stack\n\
+.L_done_fixup:\n\
+ @ compute envp\n\
+ add r3, r2, r1, lsl #2\n\
+ add r3, r3, #4\n\
+ @ now we call _dl_init\n\
+ ldr r0, .L_LOADED\n\
+ ldr r0, [sl, r0]\n\
+ @ call _dl_init\n\
+ bl _dl_init_internal(PLT)\n\
+ @ load the finalizer function\n\
+ ldr r0, .L_FINI_PROC\n\
+ add r0, sl, r0\n\
+ @ jump to the user_s entry point\n\
+ " BX(r6) "\n\
+\n\
+ @ iWMMXt and EABI targets require the stack to be eight byte\n\
+ @ aligned - shuffle arguments etc.\n\
+.L_fixup_stack:\n\
+ @ subtract _dl_skip_args from original arg count\n\
+ sub r1, r1, r4\n\
+ @ store the new argc in the new stack location\n\
+ str r1, [sp]\n\
+ @ find the first unskipped argument\n\
+ mov r3, r2\n\
+ add r4, r2, r4, lsl #2\n\
+ @ shuffle argv down\n\
+1: ldr r5, [r4], #4\n\
+ str r5, [r3], #4\n\
+ cmp r5, #0\n\
+ bne 1b\n\
+ @ shuffle envp down\n\
+1: ldr r5, [r4], #4\n\
+ str r5, [r3], #4\n\
+ cmp r5, #0\n\
+ bne 1b\n\
+ @ shuffle auxv down\n\
+1: ldmia r4!, {r0, r5}\n\
+ stmia r3!, {r0, r5}\n\
+ cmp r0, #0\n\
+ bne 1b\n\
+ @ Update _dl_argv\n\
+ ldr r3, .L_ARGV\n\
+ str r2, [sl, r3]\n\
+ b .L_done_fixup\n\
+\n\
+.L_GET_GOT:\n\
+ .word _GLOBAL_OFFSET_TABLE_ - .L_GOT_GOT - 4\n\
+.L_SKIP_ARGS:\n\
+ .word _dl_skip_args(GOTOFF)\n\
+.L_FINI_PROC:\n\
+ .word _dl_fini(GOTOFF)\n\
+.L_ARGV:\n\
+ .word _dl_argv(GOTOFF)\n\
+.L_LOADED:\n\
+ .word _rtld_local(GOTOFF)\n\
+.previous\n\
+");
+
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
+ TLS variable, so undefined references should not be allowed to
+ define the value.
+ ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
+ of the main executable's symbols, as for a COPY reloc. */
+#if defined USE_TLS && (!defined RTLD_BOOTSTRAP || USE___THREAD)
+# define elf_machine_type_class(type) \
+ ((((type) == R_ARM_JUMP_SLOT || (type) == R_ARM_TLS_DTPMOD32 \
+ || (type) == R_ARM_TLS_DTPOFF32 || (type) == R_ARM_TLS_TPOFF32) \
+ * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_ARM_COPY) * ELF_RTYPE_CLASS_COPY))
+#else
+#define elf_machine_type_class(type) \
+ ((((type) == R_ARM_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_ARM_COPY) * ELF_RTYPE_CLASS_COPY))
+#endif
+
+/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
+#define ELF_MACHINE_JMP_SLOT R_ARM_JUMP_SLOT
+
+/* ARM never uses Elf32_Rela relocations for the dynamic linker.
+ Prelinked libraries may use Elf32_Rela though. */
+#define ELF_MACHINE_PLT_REL 1
+
+/* We define an initialization functions. This is called very early in
+ _dl_sysdep_start. */
+#define DL_PLATFORM_INIT dl_platform_init ()
+
+static inline void __attribute__ ((unused))
+dl_platform_init (void)
+{
+ if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0')
+ /* Avoid an empty string which would disturb us. */
+ GLRO(dl_platform) = NULL;
+}
+
+static inline Elf32_Addr
+elf_machine_fixup_plt (struct link_map *map, lookup_t t,
+ const Elf32_Rel *reloc,
+ Elf32_Addr *reloc_addr, Elf32_Addr value)
+{
+ return *reloc_addr = value;
+}
+
+/* Return the final value of a plt relocation. */
+static inline Elf32_Addr
+elf_machine_plt_value (struct link_map *map, const Elf32_Rel *reloc,
+ Elf32_Addr value)
+{
+ return value;
+}
+
+#endif /* !dl_machine_h */
+
+
+/* ARM never uses Elf32_Rela relocations for the dynamic linker.
+ Prelinked libraries may use Elf32_Rela though. */
+#define ELF_MACHINE_NO_RELA defined RTLD_BOOTSTRAP
+
+/* Names of the architecture-specific auditing callback functions. */
+#define ARCH_LA_PLTENTER arm_gnu_pltenter
+#define ARCH_LA_PLTEXIT arm_gnu_pltexit
+
+#ifdef RESOLVE_MAP
+
+/* Deal with an out-of-range PC24 reloc. */
+auto Elf32_Addr
+fix_bad_pc24 (Elf32_Addr *const reloc_addr, Elf32_Addr value)
+{
+ static void *fix_page;
+ static unsigned int fix_offset;
+ static size_t pagesize;
+ Elf32_Word *fix_address;
+
+ if (! fix_page)
+ {
+ if (! pagesize)
+ pagesize = getpagesize ();
+ fix_page = mmap (NULL, pagesize, PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (! fix_page)
+ assert (! "could not map page for fixup");
+ fix_offset = 0;
+ }
+
+ fix_address = (Elf32_Word *)(fix_page + fix_offset);
+ fix_address[0] = 0xe51ff004; /* ldr pc, [pc, #-4] */
+ fix_address[1] = value;
+
+ fix_offset += 8;
+ if (fix_offset >= pagesize)
+ fix_page = NULL;
+
+ return (Elf32_Addr)fix_address;
+}
+
+/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
+ MAP is the object containing the reloc. */
+
+auto inline void
+__attribute__ ((always_inline))
+elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
+ const Elf32_Sym *sym, const struct r_found_version *version,
+ void *const reloc_addr_arg)
+{
+ Elf32_Addr *const reloc_addr = reloc_addr_arg;
+ const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
+
+#if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC
+ if (__builtin_expect (r_type == R_ARM_RELATIVE, 0))
+ {
+# if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC
+ /* This is defined in rtld.c, but nowhere in the static libc.a;
+ make the reference weak so static programs can still link.
+ This declaration cannot be done when compiling rtld.c
+ (i.e. #ifdef RTLD_BOOTSTRAP) because rtld.c contains the
+ common defn for _dl_rtld_map, which is incompatible with a
+ weak decl in the same file. */
+# ifndef SHARED
+ weak_extern (_dl_rtld_map);
+# endif
+ if (map != &GL(dl_rtld_map)) /* Already done in rtld itself. */
+# endif
+ *reloc_addr += map->l_addr;
+ }
+# ifndef RTLD_BOOTSTRAP
+ else if (__builtin_expect (r_type == R_ARM_NONE, 0))
+ return;
+# endif
+ else
+#endif
+ {
+ const Elf32_Sym *const refsym = sym;
+ struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
+ Elf32_Addr value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
+
+ switch (r_type)
+ {
+ case R_ARM_COPY:
+ if (sym == NULL)
+ /* This can happen in trace mode if an object could not be
+ found. */
+ break;
+ if (sym->st_size > refsym->st_size
+ || (GLRO(dl_verbose) && sym->st_size < refsym->st_size))
+ {
+ const char *strtab;
+
+ strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
+ _dl_error_printf ("\
+%s: Symbol `%s' has different size in shared object, consider re-linking\n",
+ rtld_progname ?: "<program name unknown>",
+ strtab + refsym->st_name);
+ }
+ memcpy (reloc_addr_arg, (void *) value,
+ MIN (sym->st_size, refsym->st_size));
+ break;
+ case R_ARM_GLOB_DAT:
+ case R_ARM_JUMP_SLOT:
+# ifdef RTLD_BOOTSTRAP
+ /* Fix weak undefined references. */
+ if (sym != NULL && sym->st_value == 0)
+ *reloc_addr = 0;
+ else
+# endif
+ *reloc_addr = value;
+ break;
+ case R_ARM_ABS32:
+ {
+# ifndef RTLD_BOOTSTRAP
+ /* This is defined in rtld.c, but nowhere in the static
+ libc.a; make the reference weak so static programs can
+ still link. This declaration cannot be done when
+ compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP) because
+ rtld.c contains the common defn for _dl_rtld_map, which
+ is incompatible with a weak decl in the same file. */
+# ifndef SHARED
+ weak_extern (_dl_rtld_map);
+# endif
+ if (map == &GL(dl_rtld_map))
+ /* Undo the relocation done here during bootstrapping.
+ Now we will relocate it anew, possibly using a
+ binding found in the user program or a loaded library
+ rather than the dynamic linker's built-in definitions
+ used while loading those libraries. */
+ value -= map->l_addr + refsym->st_value;
+# endif
+ *reloc_addr += value;
+ break;
+ }
+ case R_ARM_PC24:
+ {
+ Elf32_Sword addend;
+ Elf32_Addr newvalue, topbits;
+
+ addend = *reloc_addr & 0x00ffffff;
+ if (addend & 0x00800000) addend |= 0xff000000;
+
+ newvalue = value - (Elf32_Addr)reloc_addr + (addend << 2);
+ topbits = newvalue & 0xfe000000;
+ if (topbits != 0xfe000000 && topbits != 0x00000000)
+ {
+ newvalue = fix_bad_pc24(reloc_addr, value)
+ - (Elf32_Addr)reloc_addr + (addend << 2);
+ topbits = newvalue & 0xfe000000;
+ if (topbits != 0xfe000000 && topbits != 0x00000000)
+ {
+ _dl_signal_error (0, map->l_name, NULL,
+ "R_ARM_PC24 relocation out of range");
+ }
+ }
+ newvalue >>= 2;
+ value = (*reloc_addr & 0xff000000) | (newvalue & 0x00ffffff);
+ *reloc_addr = value;
+ }
+ break;
+#if defined USE_TLS && !defined RTLD_BOOTSTRAP
+ case R_ARM_TLS_DTPMOD32:
+ /* Get the information from the link map returned by the
+ resolv function. */
+ if (sym_map != NULL)
+ *reloc_addr = sym_map->l_tls_modid;
+ break;
+
+ case R_ARM_TLS_DTPOFF32:
+ *reloc_addr += sym->st_value;
+ break;
+
+ case R_ARM_TLS_TPOFF32:
+ CHECK_STATIC_TLS (map, sym_map);
+ *reloc_addr += sym->st_value + sym_map->l_tls_offset;
+ break;
+#endif
+ default:
+ _dl_reloc_bad_type (map, r_type, 0);
+ break;
+ }
+ }
+}
+
+# ifndef RTLD_BOOTSTRAP
+auto inline void
+__attribute__ ((always_inline))
+elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
+ const Elf32_Sym *sym, const struct r_found_version *version,
+ void *const reloc_addr_arg)
+{
+ Elf32_Addr *const reloc_addr = reloc_addr_arg;
+ const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
+
+ if (__builtin_expect (r_type == R_ARM_RELATIVE, 0))
+ *reloc_addr = map->l_addr + reloc->r_addend;
+ else if (__builtin_expect (r_type == R_ARM_NONE, 0))
+ return;
+ else
+ {
+# ifndef RESOLVE_CONFLICT_FIND_MAP
+ const Elf32_Sym *const refsym = sym;
+# endif
+ struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
+ Elf32_Addr value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
+
+ switch (r_type)
+ {
+# ifndef RESOLVE_CONFLICT_FIND_MAP
+ /* Not needed for dl-conflict.c. */
+ case R_ARM_COPY:
+ if (sym == NULL)
+ /* This can happen in trace mode if an object could not be
+ found. */
+ break;
+ if (sym->st_size > refsym->st_size
+ || (GLRO(dl_verbose) && sym->st_size < refsym->st_size))
+ {
+ const char *strtab;
+
+ strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
+ _dl_error_printf ("\
+%s: Symbol `%s' has different size in shared object, consider re-linking\n",
+ rtld_progname ?: "<program name unknown>",
+ strtab + refsym->st_name);
+ }
+ memcpy (reloc_addr_arg, (void *) value,
+ MIN (sym->st_size, refsym->st_size));
+ break;
+# endif /* !RESOLVE_CONFLICT_FIND_MAP */
+ case R_ARM_GLOB_DAT:
+ case R_ARM_JUMP_SLOT:
+ case R_ARM_ABS32:
+ *reloc_addr = value + reloc->r_addend;
+ break;
+ case R_ARM_PC24:
+ {
+ Elf32_Addr newvalue, topbits;
+
+ newvalue = value + reloc->r_addend - (Elf32_Addr)reloc_addr;
+ topbits = newvalue & 0xfe000000;
+ if (topbits != 0xfe000000 && topbits != 0x00000000)
+ {
+ newvalue = fix_bad_pc24(reloc_addr, value)
+ - (Elf32_Addr)reloc_addr + (reloc->r_addend << 2);
+ topbits = newvalue & 0xfe000000;
+ if (topbits != 0xfe000000 && topbits != 0x00000000)
+ {
+ _dl_signal_error (0, map->l_name, NULL,
+ "R_ARM_PC24 relocation out of range");
+ }
+ }
+ newvalue >>= 2;
+ value = (*reloc_addr & 0xff000000) | (newvalue & 0x00ffffff);
+ *reloc_addr = value;
+ }
+ break;
+#if defined USE_TLS && !defined RTLD_BOOTSTRAP
+ case R_ARM_TLS_DTPMOD32:
+ /* Get the information from the link map returned by the
+ resolv function. */
+ if (sym_map != NULL)
+ *reloc_addr = sym_map->l_tls_modid;
+ break;
+
+ case R_ARM_TLS_DTPOFF32:
+ *reloc_addr = sym->st_value + reloc->r_addend;
+ break;
+
+ case R_ARM_TLS_TPOFF32:
+ CHECK_STATIC_TLS (map, sym_map);
+ *reloc_addr = (sym->st_value + sym_map->l_tls_offset
+ + reloc->r_addend);
+ break;
+#endif
+ default:
+ _dl_reloc_bad_type (map, r_type, 0);
+ break;
+ }
+ }
+}
+# endif
+
+auto inline void
+__attribute__ ((always_inline))
+elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc,
+ void *const reloc_addr_arg)
+{
+ Elf32_Addr *const reloc_addr = reloc_addr_arg;
+ *reloc_addr += l_addr;
+}
+
+# ifndef RTLD_BOOTSTRAP
+auto inline void
+__attribute__ ((always_inline))
+elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
+ void *const reloc_addr_arg)
+{
+ Elf32_Addr *const reloc_addr = reloc_addr_arg;
+ *reloc_addr = l_addr + reloc->r_addend;
+}
+# endif
+
+auto inline void
+__attribute__ ((always_inline))
+elf_machine_lazy_rel (struct link_map *map,
+ Elf32_Addr l_addr, const Elf32_Rel *reloc)
+{
+ Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
+ const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
+ /* Check for unexpected PLT reloc type. */
+ if (__builtin_expect (r_type == R_ARM_JUMP_SLOT, 1))
+ {
+ if (__builtin_expect (map->l_mach.plt, 0) == 0)
+ *reloc_addr += l_addr;
+ else
+ *reloc_addr = map->l_mach.plt;
+ }
+ else
+ _dl_reloc_bad_type (map, r_type, 1);
+}
+
+#endif /* RESOLVE_MAP */
diff --git a/ports/sysdeps/arm/dl-sysdep.h b/ports/sysdeps/arm/dl-sysdep.h
new file mode 100644
index 000000000..cd678f4e4
--- /dev/null
+++ b/ports/sysdeps/arm/dl-sysdep.h
@@ -0,0 +1,24 @@
+/* System-specific settings for dynamic linker code. Alpha version.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include_next <dl-sysdep.h>
+
+/* _dl_argv cannot be attribute_relro, because _dl_start_user
+ might write into it after _dl_start returns. */
+#define DL_ARGV_NOT_RELRO 1
diff --git a/ports/sysdeps/arm/dl-tls.h b/ports/sysdeps/arm/dl-tls.h
new file mode 100644
index 000000000..e0324a7b6
--- /dev/null
+++ b/ports/sysdeps/arm/dl-tls.h
@@ -0,0 +1,29 @@
+/* Thread-local storage handling in the ELF dynamic linker. ARM version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+/* Type used for the representation of TLS information in the GOT. */
+typedef struct
+{
+ unsigned long int ti_module;
+ unsigned long int ti_offset;
+} tls_index;
+
+
+extern void *__tls_get_addr (tls_index *ti);
diff --git a/ports/sysdeps/arm/dl-trampoline.S b/ports/sysdeps/arm/dl-trampoline.S
new file mode 100644
index 000000000..0224fa1d1
--- /dev/null
+++ b/ports/sysdeps/arm/dl-trampoline.S
@@ -0,0 +1,216 @@
+/* PLT trampolines. ARM version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <libc-symbols.h>
+
+#if defined(__USE_BX__)
+#define BX(x) bx x
+#else
+#define BX(x) mov pc, x
+#endif
+
+ .text
+ .globl _dl_runtime_resolve
+ .type _dl_runtime_resolve, #function
+ cfi_startproc
+ .align 2
+_dl_runtime_resolve:
+ cfi_adjust_cfa_offset (4)
+ cfi_rel_offset (lr, 0)
+
+ @ we get called with
+ @ stack[0] contains the return address from this call
+ @ ip contains &GOT[n+3] (pointer to function)
+ @ lr points to &GOT[2]
+
+ @ Save arguments. We save r4 to realign the stack.
+ stmdb sp!,{r0-r4}
+ cfi_adjust_cfa_offset (20)
+ cfi_rel_offset (r0, 0)
+ cfi_rel_offset (r1, 4)
+ cfi_rel_offset (r2, 8)
+ cfi_rel_offset (r3, 12)
+
+ @ get pointer to linker struct
+ ldr r0, [lr, #-4]
+
+ @ prepare to call _dl_fixup()
+ @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each
+ sub r1, ip, lr
+ sub r1, r1, #4
+ add r1, r1, r1
+
+ @ call fixup routine
+ bl _dl_fixup
+
+ @ save the return
+ mov ip, r0
+
+ @ get arguments and return address back. We restore r4
+ @ only to realign the stack.
+ ldmia sp!, {r0-r4,lr}
+ cfi_adjust_cfa_offset (-24)
+
+ @ jump to the newly found address
+ BX(ip)
+
+ cfi_endproc
+ .size _dl_runtime_resolve, .-_dl_runtime_resolve
+
+#ifndef PROF
+ .globl _dl_runtime_profile
+ .type _dl_runtime_profile, #function
+ cfi_startproc
+ .align 2
+_dl_runtime_profile:
+ cfi_adjust_cfa_offset (4)
+ cfi_rel_offset (lr, 0)
+
+ @ we get called with
+ @ stack[0] contains the return address from this call
+ @ ip contains &GOT[n+3] (pointer to function)
+ @ lr points to &GOT[2]
+
+ @ Stack layout:
+ @ 212 - saved lr
+ @ 208 - framesize returned from pltenter
+ @ 16 - La_arm_regs
+ @ 8 - Saved two arguments to _dl_profile_fixup
+ @ 4 - Saved result of _dl_profile_fixup
+ @ 0 - outgoing argument to _dl_profile_fixup
+ @ For now, we only save the general purpose registers.
+
+ sub sp, sp, #196
+ cfi_adjust_cfa_offset (196)
+ stmia sp, {r0-r3}
+ cfi_rel_offset (r0, 0)
+ cfi_rel_offset (r1, 4)
+ cfi_rel_offset (r2, 8)
+ cfi_rel_offset (r3, 12)
+
+ sub sp, sp, #16
+ cfi_adjust_cfa_offset (16)
+
+ @ Save sp and lr.
+ add r0, sp, #216
+ str r0, [sp, #32]
+ ldr r2, [sp, #212]
+ str r2, [sp, #36]
+
+ @ get pointer to linker struct
+ ldr r0, [lr, #-4]
+
+ @ prepare to call _dl_profile_fixup()
+ @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each
+ sub r1, ip, lr
+ sub r1, r1, #4
+ add r1, r1, r1
+
+ @ Save these two arguments for pltexit.
+ add r3, sp, #8
+ stmia r3!, {r0,r1}
+
+ @ Set up extra args for _dl_profile_fixup.
+ @ r2 and r3 are already loaded.
+ add ip, sp, #208
+ str ip, [sp, #0]
+
+ @ call profiling fixup routine
+ bl _dl_profile_fixup
+
+ @ The address to call is now in r0.
+
+ @ Check whether we're wrapping this function.
+ ldr ip, [sp, #208]
+ cmp ip, #0
+ bge 1f
+ cfi_remember_state
+
+ @ save the return
+ mov ip, r0
+
+ @ get arguments and return address back
+ add sp, sp, #16
+ cfi_adjust_cfa_offset (-16)
+ ldmia sp, {r0-r3,sp,lr}
+ cfi_adjust_cfa_offset (-200)
+
+ @ jump to the newly found address
+ BX(ip)
+
+ cfi_restore_state
+1:
+ @ The new frame size is in ip.
+
+ @ New stack layout:
+ @ 268 - saved r7
+ @ 264 - saved result of _dl_profile_fixup
+ @ 72 - La_arm_regs
+ @ 64 - Saved two arguments to _dl_profile_fixup
+ @ 0 - La_arm_retval
+ @ For now, we only save the general purpose registers.
+
+ @ Build the new frame.
+ str r7, [sp, #212]
+ cfi_rel_offset (r7, 212)
+ sub r7, sp, #56
+ cfi_def_cfa_register (r7)
+ cfi_adjust_cfa_offset (56)
+ sub sp, sp, ip
+ bic sp, sp, #7
+
+ @ Save the _dl_profile_fixup result around the call to memcpy.
+ str r0, [r7, #264]
+
+ @ Copy the stack arguments.
+ mov r0, sp
+ add r1, r7, #272
+ mov r2, ip
+ bl memcpy
+
+ @ Call the function.
+ add ip, r7, #72
+ ldmia ip, {r0-r3}
+ ldr ip, [r7, #264]
+ mov lr, pc
+ BX(ip)
+ stmia r7, {r0-r3}
+
+ @ Call pltexit.
+ add ip, r7, #64
+ ldmia ip, {r0,r1}
+ add r2, r7, #72
+ add r3, r7, #0
+ bl _dl_call_pltexit
+
+ @ Return to caller.
+ ldmia r7, {r0-r3}
+ mov sp, r7
+ cfi_def_cfa_register (sp)
+ ldr r7, [sp, #268]
+ ldr lr, [sp, #92]
+ add sp, sp, #272
+ cfi_adjust_cfa_offset (-272)
+ BX(lr)
+
+ cfi_endproc
+ .size _dl_runtime_profile, .-_dl_runtime_profile
+#endif
+ .previous
diff --git a/ports/sysdeps/arm/eabi/Makefile b/ports/sysdeps/arm/eabi/Makefile
new file mode 100644
index 000000000..0f92d7ad4
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/Makefile
@@ -0,0 +1,22 @@
+ifeq ($(subdir),csu)
+aeabi_constants = aeabi_lcsts aeabi_sighandlers aeabi_math
+aeabi_routines = aeabi_assert aeabi_localeconv aeabi_errno_addr \
+ aeabi_mb_cur_max aeabi_atexit aeabi_memclr aeabi_memcpy \
+ aeabi_memmove aeabi_memset
+
+sysdep_routines += $(aeabi_constants) $(aeabi_routines)
+static-only-routines += $(aeabi_constants)
+
+# get offset to rtld_global._dl_hwcap
+gen-as-const-headers += rtld-global-offsets.sym
+endif
+
+ifeq ($(subdir),elf)
+sysdep_routines += aeabi_unwind_cpp_pr1 find_exidx
+shared-only-routines += aeabi_unwind_cpp_pr1
+sysdep-rtld-routines += aeabi_unwind_cpp_pr1
+endif
+
+ifeq ($(subdir),math)
+$(objpfx)libm.so: $(elfobjdir)/ld.so
+endif
diff --git a/ports/sysdeps/arm/eabi/Versions b/ports/sysdeps/arm/eabi/Versions
new file mode 100644
index 000000000..ca51099cd
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/Versions
@@ -0,0 +1,17 @@
+libc {
+ GLIBC_2.4 {
+ # ARM EABI compatibility routines
+ __aeabi_assert;
+ __aeabi_atexit;
+ __aeabi_errno_addr;
+ __aeabi_localeconv;
+ __aeabi_MB_CUR_MAX;
+ __aeabi_memclr; __aeabi_memclr4; __aeabi_memclr8;
+ __aeabi_memcpy; __aeabi_memcpy4; __aeabi_memcpy8;
+ __aeabi_memmove; __aeabi_memmove4; __aeabi_memmove8;
+ __aeabi_memset; __aeabi_memset4; __aeabi_memset8;
+
+ # Helper routines
+ __gnu_Unwind_Find_exidx;
+ }
+}
diff --git a/ports/sysdeps/arm/eabi/__longjmp.S b/ports/sysdeps/arm/eabi/__longjmp.S
new file mode 100644
index 000000000..56776338a
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/__longjmp.S
@@ -0,0 +1,85 @@
+/* longjmp for ARM.
+ Copyright (C) 1997, 1998, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include <sysdep.h>
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+#define __ASSEMBLY__
+#include <asm/procinfo.h>
+#include <rtld-global-offsets.h>
+
+/* __longjmp(jmpbuf, val) */
+
+ENTRY (__longjmp)
+ mov ip, r0
+ movs r0, r1 /* get the return value in place */
+ moveq r0, #1 /* can't let setjmp() return zero! */
+
+ LOADREGS(ia, ip!, {v1-v6, sl, fp, sp, lr})
+
+#ifdef IS_IN_rtld
+ ldr a2, 1f
+ ldr a3, Lrtld_local_ro
+0: add a2, pc, a2
+ add a2, a2, a3
+ ldr a2, [a2, #RTLD_GLOBAL_RO_DL_HWCAP_OFFSET]
+#else
+#ifdef PIC
+ ldr a2, 1f
+ ldr a3, Lrtld_global_ro
+0: add a2, pc, a2
+ ldr a2, [a2, a3]
+ ldr a2, [a2, #RTLD_GLOBAL_RO_DL_HWCAP_OFFSET]
+#else
+ ldr a2, Lhwcap
+ ldr a2, [a2, #0]
+#endif
+#endif
+
+ tst a2, #HWCAP_VFP
+ beq Lno_vfp
+
+ /* Restore the VFP registers. */
+ /* Following instruction is fldmiax ip!, {d8-d15}. */
+ ldc p11, cr8, [r12], #68
+ /* Restore the floating-point status register. */
+ ldr r1, [ip], #4
+ /* Following instruction is fmxr fpscr, r1. */
+ mcr p10, 7, r1, cr1, cr0, 0
+Lno_vfp:
+
+ DO_RET(lr)
+
+#ifdef IS_IN_rtld
+1: .long _GLOBAL_OFFSET_TABLE_ - 0b - 8
+Lrtld_local_ro:
+ .long C_SYMBOL_NAME(_rtld_local_ro)(GOTOFF)
+#else
+#ifdef PIC
+1: .long _GLOBAL_OFFSET_TABLE_ - 0b - 8
+Lrtld_global_ro:
+ .long C_SYMBOL_NAME(_rtld_global_ro)(GOT)
+#else
+Lhwcap:
+ .long C_SYMBOL_NAME(_dl_hwcap)
+#endif
+#endif
+
+END (__longjmp)
diff --git a/ports/sysdeps/arm/eabi/aeabi_assert.c b/ports/sysdeps/arm/eabi/aeabi_assert.c
new file mode 100644
index 000000000..14801c264
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/aeabi_assert.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <stdlib.h>
+
+void
+__aeabi_assert (const char *assertion, const char *file,
+ unsigned int line)
+{
+ __assert_fail (assertion, file, line, NULL);
+}
diff --git a/ports/sysdeps/arm/eabi/aeabi_atexit.c b/ports/sysdeps/arm/eabi/aeabi_atexit.c
new file mode 100644
index 000000000..697f54ce9
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/aeabi_atexit.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdlib.h>
+
+/* Register a function to be called by exit or when a shared library
+ is unloaded. This routine is like __cxa_atexit, but uses the
+ calling sequence required by the ARM EABI. */
+int
+__aeabi_atexit (void *arg, void (*func) (void *), void *d)
+{
+ return __cxa_atexit (func, arg, d);
+}
diff --git a/ports/sysdeps/arm/eabi/aeabi_errno_addr.c b/ports/sysdeps/arm/eabi/aeabi_errno_addr.c
new file mode 100644
index 000000000..09bdc1efe
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/aeabi_errno_addr.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+
+volatile int *
+__aeabi_errno_addr (void)
+{
+ return &errno;
+}
diff --git a/ports/sysdeps/arm/eabi/aeabi_lcsts.c b/ports/sysdeps/arm/eabi/aeabi_lcsts.c
new file mode 100644
index 000000000..99c79851e
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/aeabi_lcsts.c
@@ -0,0 +1,84 @@
+/* Link-time constants for ARM EABI.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* The ARM EABI requires that we provide ISO compile-time constants as
+ link-time constants. Some portable applications may reference these. */
+
+#include <errno.h>
+#include <limits.h>
+#include <locale.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
+#include <time.h>
+
+#define eabi_constant2(X,Y) const int __aeabi_##X attribute_hidden = Y
+#define eabi_constant(X) const int __aeabi_##X attribute_hidden = X
+
+eabi_constant (EDOM);
+eabi_constant (ERANGE);
+eabi_constant (EILSEQ);
+
+eabi_constant (MB_LEN_MAX);
+
+eabi_constant (LC_COLLATE);
+eabi_constant (LC_CTYPE);
+eabi_constant (LC_MONETARY);
+eabi_constant (LC_NUMERIC);
+eabi_constant (LC_TIME);
+eabi_constant (LC_ALL);
+
+/* The value of __aeabi_JMP_BUF_SIZE is the number of doublewords in a
+ jmp_buf. */
+eabi_constant2 (JMP_BUF_SIZE, sizeof (jmp_buf) / 8);
+
+eabi_constant (SIGABRT);
+eabi_constant (SIGFPE);
+eabi_constant (SIGILL);
+eabi_constant (SIGINT);
+eabi_constant (SIGSEGV);
+eabi_constant (SIGTERM);
+
+eabi_constant2 (IOFBF, _IOFBF);
+eabi_constant2 (IOLBF, _IOLBF);
+eabi_constant2 (IONBF, _IONBF);
+eabi_constant (BUFSIZ);
+eabi_constant (FOPEN_MAX);
+eabi_constant (TMP_MAX);
+eabi_constant (FILENAME_MAX);
+eabi_constant (L_tmpnam);
+
+eabi_constant (CLOCKS_PER_SEC);
diff --git a/ports/sysdeps/arm/eabi/aeabi_localeconv.c b/ports/sysdeps/arm/eabi/aeabi_localeconv.c
new file mode 100644
index 000000000..f4e51d02e
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/aeabi_localeconv.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <locale.h>
+
+struct lconv *
+__aeabi_localeconv (void)
+{
+ return localeconv ();
+}
diff --git a/ports/sysdeps/arm/eabi/aeabi_math.c b/ports/sysdeps/arm/eabi/aeabi_math.c
new file mode 100644
index 000000000..e7f1dbf5f
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/aeabi_math.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+const double __aeabi_HUGE_VAL attribute_hidden = HUGE_VAL;
+const long double __aeabi_HUGE_VALL attribute_hidden = HUGE_VALL;
+const float __aeabi_HUGE_VALF attribute_hidden = HUGE_VALF;
+const float __aeabi_INFINITY attribute_hidden = INFINITY;
+const float __aeabi_NAN attribute_hidden = NAN;
diff --git a/ports/sysdeps/arm/eabi/aeabi_mb_cur_max.c b/ports/sysdeps/arm/eabi/aeabi_mb_cur_max.c
new file mode 100644
index 000000000..866da795d
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/aeabi_mb_cur_max.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <langinfo.h>
+#include <locale.h>
+#include <stdlib.h>
+#include <locale/localeinfo.h>
+
+int
+__aeabi_MB_CUR_MAX (void)
+{
+ return MB_CUR_MAX;
+}
diff --git a/ports/sysdeps/arm/eabi/aeabi_memclr.c b/ports/sysdeps/arm/eabi/aeabi_memclr.c
new file mode 100644
index 000000000..986de85ed
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/aeabi_memclr.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <string.h>
+
+/* Clear memory. Can't alias to bzero because it's not defined in the
+ same translation unit. */
+void
+__aeabi_memclr (void *dest, size_t n)
+{
+ __bzero (dest, n);
+}
+
+/* Versions of the above which may assume memory alignment. */
+strong_alias (__aeabi_memclr, __aeabi_memclr4)
+strong_alias (__aeabi_memclr, __aeabi_memclr8)
diff --git a/ports/sysdeps/arm/eabi/aeabi_memcpy.c b/ports/sysdeps/arm/eabi/aeabi_memcpy.c
new file mode 100644
index 000000000..7d7c47ba3
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/aeabi_memcpy.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <string.h>
+
+/* Copy memory like memcpy, but no return value required. Can't alias
+ to memcpy because it's not defined in the same translation
+ unit. */
+void
+__aeabi_memcpy (void *dest, const void *src, size_t n)
+{
+ memcpy (dest, src, n);
+}
+
+/* Versions of the above which may assume memory alignment. */
+strong_alias (__aeabi_memcpy, __aeabi_memcpy4)
+strong_alias (__aeabi_memcpy, __aeabi_memcpy8)
diff --git a/ports/sysdeps/arm/eabi/aeabi_memmove.c b/ports/sysdeps/arm/eabi/aeabi_memmove.c
new file mode 100644
index 000000000..b2a4e3531
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/aeabi_memmove.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <string.h>
+
+/* Copy memory like memmove, but no return value required. Can't
+ alias to memmove because it's not defined in the same translation
+ unit. */
+void
+__aeabi_memmove (void *dest, const void *src, size_t n)
+{
+ memmove (dest, src, n);
+}
+
+/* Versions of the above which may assume memory alignment. */
+strong_alias (__aeabi_memmove, __aeabi_memmove4)
+strong_alias (__aeabi_memmove, __aeabi_memmove8)
diff --git a/ports/sysdeps/arm/eabi/aeabi_memset.c b/ports/sysdeps/arm/eabi/aeabi_memset.c
new file mode 100644
index 000000000..ed38bdea5
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/aeabi_memset.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <string.h>
+
+/* Set memory like memset, but different argument order and no return
+ value required. */
+void
+__aeabi_memset (void *dest, size_t n, int c)
+{
+ memset (dest, c, n);
+}
+
+/* Versions of the above which may assume memory alignment. */
+strong_alias (__aeabi_memset, __aeabi_memset4)
+strong_alias (__aeabi_memset, __aeabi_memset8)
diff --git a/ports/sysdeps/arm/eabi/aeabi_sighandlers.S b/ports/sysdeps/arm/eabi/aeabi_sighandlers.S
new file mode 100644
index 000000000..ff8162e39
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/aeabi_sighandlers.S
@@ -0,0 +1,54 @@
+/* Link-time constants for ARM EABI - signal handlers.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* The ARM EABI defines these as "functions". */
+
+#include <sysdep.h>
+
+ .global __aeabi_SIG_DFL
+ .hidden __aeabi_SIG_DFL
+ .type __aeabi_SIG_DFL, %function
+ .set __aeabi_SIG_DFL, 0
+
+ .global __aeabi_SIG_IGN
+ .hidden __aeabi_SIG_IGN
+ .type __aeabi_SIG_IGN, %function
+ .set __aeabi_SIG_IGN, 1
+
+ .global __aeabi_SIG_ERR
+ .hidden __aeabi_SIG_ERR
+ .type __aeabi_SIG_ERR, %function
+ .set __aeabi_SIG_ERR, -1
diff --git a/ports/sysdeps/arm/eabi/aeabi_unwind_cpp_pr1.c b/ports/sysdeps/arm/eabi/aeabi_unwind_cpp_pr1.c
new file mode 100644
index 000000000..91df013ad
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/aeabi_unwind_cpp_pr1.c
@@ -0,0 +1,52 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Because some objects in ld.so and libc.so are built with
+ -fexceptions, we end up with references to this personality
+ routine. However, these libraries are not linked against
+ libgcc_eh.a, so we need a dummy definition. This routine will
+ never actually be called. */
+
+#include <stdlib.h>
+
+attribute_hidden
+void
+__aeabi_unwind_cpp_pr0 (void)
+{
+#ifndef IS_IN_rtld
+ abort ();
+#endif
+}
+
+attribute_hidden
+void
+__aeabi_unwind_cpp_pr1 (void)
+{
+#ifndef IS_IN_rtld
+ abort ();
+#endif
+}
+
+attribute_hidden
+void
+__aeabi_unwind_cpp_pr2 (void)
+{
+#ifndef IS_IN_rtld
+ abort ();
+#endif
+}
diff --git a/ports/sysdeps/arm/eabi/bits/fenv.h b/ports/sysdeps/arm/eabi/bits/fenv.h
new file mode 100644
index 000000000..49e386222
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/bits/fenv.h
@@ -0,0 +1,74 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#ifndef _FENV_H
+# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
+
+/* Define bits representing exceptions in the FPU status word. */
+enum
+ {
+ FE_INVALID = 1,
+#define FE_INVALID FE_INVALID
+ FE_DIVBYZERO = 2,
+#define FE_DIVBYZERO FE_DIVBYZERO
+ FE_OVERFLOW = 4,
+#define FE_OVERFLOW FE_OVERFLOW
+ FE_UNDERFLOW = 8,
+#define FE_UNDERFLOW FE_UNDERFLOW
+ FE_INEXACT = 16,
+#define FE_INEXACT FE_INEXACT
+ };
+
+/* Amount to shift by to convert an exception to a mask bit. */
+#define FE_EXCEPT_SHIFT 8
+
+/* All supported exceptions. */
+#define FE_ALL_EXCEPT \
+ (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
+
+/* VFP supports all of the four defined rounding modes. */
+enum
+ {
+ FE_TONEAREST = 0,
+#define FE_TONEAREST FE_TONEAREST
+ FE_UPWARD = 0x400000,
+#define FE_UPWARD FE_UPWARD
+ FE_DOWNWARD = 0x800000,
+#define FE_DOWNWARD FE_DOWNWARD
+ FE_TOWARDZERO = 0xc00000
+#define FE_TOWARDZERO FE_TOWARDZERO
+ };
+
+/* Type representing exception flags. */
+typedef unsigned int fexcept_t;
+
+/* Type representing floating-point environment. */
+typedef struct
+ {
+ unsigned int __cw;
+ }
+fenv_t;
+
+/* If the default argument is used we use this value. */
+#define FE_DFL_ENV ((fenv_t *) -1l)
+
+#ifdef __USE_GNU
+/* Floating-point environment where none of the exceptions are masked. */
+# define FE_NOMASK_ENV ((__const fenv_t *) -2)
+#endif
diff --git a/ports/sysdeps/arm/eabi/bits/huge_val.h b/ports/sysdeps/arm/eabi/bits/huge_val.h
new file mode 100644
index 000000000..11ca11f18
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/bits/huge_val.h
@@ -0,0 +1,55 @@
+/* `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, 1996, 1997, 1999, 2000, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MATH_H
+# error "Never use <bits/huge_val.h> directly; include <math.h> instead."
+#endif
+
+/* IEEE positive infinity (-HUGE_VAL is negative infinity). */
+
+#if __GNUC_PREREQ(3,3)
+# define HUGE_VAL (__builtin_huge_val())
+#elif __GNUC_PREREQ(2,96)
+# define HUGE_VAL (__extension__ 0x1.0p2047)
+#elif defined __GNUC__
+
+# define HUGE_VAL \
+ (__extension__ \
+ ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) \
+ { __l: 0x7ff0000000000000ULL }).__d)
+
+#else /* not GCC */
+
+# include <endian.h>
+
+typedef union { unsigned char __c[8]; double __d; } __huge_val_t;
+
+# 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
+
+static __huge_val_t __huge_val = { __HUGE_VAL_bytes };
+# define HUGE_VAL (__huge_val.__d)
+
+#endif /* GCC. */
diff --git a/ports/sysdeps/arm/eabi/bits/setjmp.h b/ports/sysdeps/arm/eabi/bits/setjmp.h
new file mode 100644
index 000000000..dd7679d20
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/bits/setjmp.h
@@ -0,0 +1,38 @@
+/* Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Define the machine-dependent type `jmp_buf'. ARM EABI version. */
+
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H 1
+
+#if !defined _SETJMP_H && !defined _PTHREAD_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+#ifndef _ASM
+/* The exact set of registers saved may depend on the particular core
+ in use, as some coprocessor registers may need to be saved. The C
+ Library ABI requires that the buffer be 8-byte aligned, and
+ recommends that the buffer contain 64 words. The first 28 words
+ are occupied by v1-v6, sl, fp, sp, pc, d8-d15, and fpscr. (Note
+ that d8-15 require 17 words, due to the use of fstmx.) */
+typedef int __jmp_buf[64] __attribute__((aligned (8)));
+#endif
+
+#endif
diff --git a/ports/sysdeps/arm/eabi/fclrexcpt.c b/ports/sysdeps/arm/eabi/fclrexcpt.c
new file mode 100644
index 000000000..6e5d24280
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/fclrexcpt.c
@@ -0,0 +1,61 @@
+/* Clear given exceptions in current floating-point environment.
+ Copyright (C) 1997,98,99,2000,01,05 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
+#include <asm/procinfo.h>
+
+int
+__feclearexcept (int excepts)
+{
+ if (GLRO (dl_hwcap) & HWCAP_VFP)
+ {
+ unsigned long int temp;
+
+ /* Mask out unsupported bits/exceptions. */
+ excepts &= FE_ALL_EXCEPT;
+
+ /* Get the current floating point status. */
+ _FPU_GETCW (temp);
+
+ /* Clear the relevant bits. */
+ temp = (temp & ~FE_ALL_EXCEPT) | (temp & FE_ALL_EXCEPT & ~excepts);
+
+ /* Put the new data in effect. */
+ _FPU_SETCW (temp);
+
+ /* Success. */
+ return 0;
+ }
+
+ /* Unsupported, so fail. */
+ return 1;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__feclearexcept, __old_feclearexcept)
+compat_symbol (libm, __old_feclearexcept, feclearexcept, GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, __feclearexcept, feclearexcept, GLIBC_2_2);
diff --git a/ports/sysdeps/arm/eabi/fedisblxcpt.c b/ports/sysdeps/arm/eabi/fedisblxcpt.c
new file mode 100644
index 000000000..414d34b1e
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/fedisblxcpt.c
@@ -0,0 +1,51 @@
+/* Disable floating-point exceptions.
+ Copyright (C) 2001, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <philb@gnu.org>, 2001.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
+#include <asm/procinfo.h>
+
+int
+fedisableexcept (int excepts)
+{
+ if (GLRO (dl_hwcap) & HWCAP_VFP)
+ {
+ unsigned long int new_exc, old_exc;
+
+ _FPU_GETCW(new_exc);
+
+ old_exc = (new_exc >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT;
+
+ excepts &= FE_ALL_EXCEPT;
+
+ new_exc &= ~(excepts << FE_EXCEPT_SHIFT);
+
+ _FPU_SETCW(new_exc);
+
+ return old_exc;
+ }
+
+ /* Unsupported, so return -1 for failure. */
+ return -1;
+}
diff --git a/ports/sysdeps/arm/eabi/feenablxcpt.c b/ports/sysdeps/arm/eabi/feenablxcpt.c
new file mode 100644
index 000000000..e104bc4f6
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/feenablxcpt.c
@@ -0,0 +1,51 @@
+/* Enable floating-point exceptions.
+ Copyright (C) 2001, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <philb@gnu.org>, 2001.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
+#include <asm/procinfo.h>
+
+int
+feenableexcept (int excepts)
+{
+ if (GLRO (dl_hwcap) & HWCAP_VFP)
+ {
+ unsigned long int new_exc, old_exc;
+
+ _FPU_GETCW(new_exc);
+
+ old_exc = (new_exc >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT;
+
+ excepts &= FE_ALL_EXCEPT;
+
+ new_exc |= (excepts << FE_EXCEPT_SHIFT);
+
+ _FPU_SETCW(new_exc);
+
+ return old_exc;
+ }
+
+ /* Unsupported, so return -1 for failure. */
+ return -1;
+}
diff --git a/ports/sysdeps/arm/eabi/fegetenv.c b/ports/sysdeps/arm/eabi/fegetenv.c
new file mode 100644
index 000000000..178d22a42
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/fegetenv.c
@@ -0,0 +1,51 @@
+/* Store current floating-point environment.
+ Copyright (C) 1997,98,99,2000,01,05 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
+#include <asm/procinfo.h>
+
+int
+__fegetenv (fenv_t *envp)
+{
+ if (GLRO (dl_hwcap) & HWCAP_VFP)
+ {
+ unsigned long int temp;
+ _FPU_GETCW (temp);
+ envp->__cw = temp;
+
+ /* Success. */
+ return 0;
+ }
+
+ /* Unsupported, so fail. */
+ return 1;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__fegetenv, __old_fegetenv)
+compat_symbol (libm, __old_fegetenv, fegetenv, GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, __fegetenv, fegetenv, GLIBC_2_2);
diff --git a/ports/sysdeps/arm/eabi/fegetexcept.c b/ports/sysdeps/arm/eabi/fegetexcept.c
new file mode 100644
index 000000000..811c8ae25
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/fegetexcept.c
@@ -0,0 +1,43 @@
+/* Get floating-point exceptions.
+ Copyright (C) 2001, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <philb@gnu.org>, 2001
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
+#include <asm/procinfo.h>
+
+int
+fegetexcept (void)
+{
+ if (GLRO (dl_hwcap) & HWCAP_VFP)
+ {
+ unsigned long temp;
+
+ _FPU_GETCW (temp);
+
+ return (temp >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT;
+ }
+
+ /* Unsupported. Return all exceptions disabled. */
+ return 0;
+}
diff --git a/ports/sysdeps/arm/eabi/fegetround.c b/ports/sysdeps/arm/eabi/fegetround.c
new file mode 100644
index 000000000..1c4be04e6
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/fegetround.c
@@ -0,0 +1,43 @@
+/* Return current rounding direction.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
+#include <asm/procinfo.h>
+
+int
+fegetround (void)
+{
+ if (GLRO (dl_hwcap) & HWCAP_VFP)
+ {
+ unsigned int temp;
+
+ /* Get the current environment. */
+ _FPU_GETCW (temp);
+
+ return temp & FE_TOWARDZERO;
+ }
+
+ /* The current soft-float implementation only handles TONEAREST. */
+ return FE_TONEAREST;
+}
diff --git a/ports/sysdeps/arm/eabi/feholdexcpt.c b/ports/sysdeps/arm/eabi/feholdexcpt.c
new file mode 100644
index 000000000..9872ea17b
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/feholdexcpt.c
@@ -0,0 +1,54 @@
+/* Store current floating-point environment and clear exceptions.
+ Copyright (C) 1997, 1998, 1999, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
+#include <asm/procinfo.h>
+
+int
+feholdexcept (fenv_t *envp)
+{
+ if (GLRO (dl_hwcap) & HWCAP_VFP)
+ {
+ unsigned long int temp;
+
+ /* Store the environment. */
+ _FPU_GETCW(temp);
+ envp->__cw = temp;
+
+ /* Now set all exceptions to non-stop. */
+ temp &= ~(FE_ALL_EXCEPT << FE_EXCEPT_SHIFT);
+
+ /* And clear all exception flags. */
+ temp &= ~FE_ALL_EXCEPT;
+
+ _FPU_SETCW(temp);
+
+ return 0;
+ }
+
+ /* Unsupported, so fail. */
+ return 1;
+}
+
+libm_hidden_def (feholdexcept)
diff --git a/ports/sysdeps/arm/eabi/fesetenv.c b/ports/sysdeps/arm/eabi/fesetenv.c
new file mode 100644
index 000000000..bf253848b
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/fesetenv.c
@@ -0,0 +1,57 @@
+/* Install given floating-point environment.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
+#include <asm/procinfo.h>
+
+int
+__fesetenv (const fenv_t *envp)
+{
+ if (GLRO (dl_hwcap) & HWCAP_VFP)
+ {
+ unsigned int temp;
+
+ _FPU_GETCW (temp);
+ temp &= _FPU_RESERVED;
+
+ if (envp == FE_DFL_ENV)
+ temp |= _FPU_DEFAULT;
+ else if (envp == FE_NOMASK_ENV)
+ temp |= _FPU_IEEE;
+ else
+ temp |= envp->__cw & ~_FPU_RESERVED;
+
+ _FPU_SETCW (temp);
+
+ /* Success. */
+ return 0;
+ }
+
+ /* Unsupported, so fail. */
+ return 1;
+}
+
+#include <shlib-compat.h>
+libm_hidden_ver (__fesetenv, fesetenv)
+versioned_symbol (libm, __fesetenv, fesetenv, GLIBC_2_2);
diff --git a/ports/sysdeps/arm/eabi/fesetround.c b/ports/sysdeps/arm/eabi/fesetround.c
new file mode 100644
index 000000000..f6e20cb72
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/fesetround.c
@@ -0,0 +1,57 @@
+/* Set current rounding direction.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
+#include <asm/procinfo.h>
+
+int
+fesetround (int round)
+{
+ if (GLRO (dl_hwcap) & HWCAP_VFP)
+ {
+ fpu_control_t temp;
+
+ switch (round)
+ {
+ case FE_TONEAREST:
+ case FE_UPWARD:
+ case FE_DOWNWARD:
+ case FE_TOWARDZERO:
+ _FPU_GETCW (temp);
+ temp = (temp & ~FE_TOWARDZERO) | round;
+ _FPU_SETCW (temp);
+ return 0;
+ default:
+ return 1;
+ }
+ }
+ else if (round == FE_TONEAREST)
+ /* This is the only supported rounding mode for soft-fp. */
+ return 0;
+
+ /* Unsupported, so fail. */
+ return 1;
+}
+
+libm_hidden_def (fesetround)
diff --git a/ports/sysdeps/arm/eabi/find_exidx.c b/ports/sysdeps/arm/eabi/find_exidx.c
new file mode 100644
index 000000000..9e4f4012f
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/find_exidx.c
@@ -0,0 +1,80 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <link.h>
+#include <unwind.h>
+
+struct unw_eh_callback_data
+{
+ _Unwind_Ptr pc;
+ _Unwind_Ptr exidx_start;
+ int exidx_len;
+};
+
+
+/* Callback to determins if the PC lies within an object, and remember the
+ location of the exception index table if it does. */
+
+static int
+find_exidx_callback (struct dl_phdr_info * info, size_t size, void * ptr)
+{
+ struct unw_eh_callback_data * data;
+ const ElfW(Phdr) *phdr;
+ int i;
+ int match;
+ _Unwind_Ptr load_base;
+
+ data = (struct unw_eh_callback_data *) ptr;
+ load_base = info->dlpi_addr;
+ phdr = info->dlpi_phdr;
+
+ match = 0;
+ for (i = info->dlpi_phnum; i > 0; i--, phdr++)
+ {
+ if (phdr->p_type == PT_LOAD)
+ {
+ _Unwind_Ptr vaddr = phdr->p_vaddr + load_base;
+ if (data->pc >= vaddr && data->pc < vaddr + phdr->p_memsz)
+ match = 1;
+ }
+ else if (phdr->p_type == PT_ARM_EXIDX)
+ {
+ data->exidx_start = (_Unwind_Ptr) (phdr->p_vaddr + load_base);
+ data->exidx_len = phdr->p_memsz;
+ }
+ }
+
+ return match;
+}
+
+
+/* Find the exception index table containing PC. */
+
+_Unwind_Ptr
+__gnu_Unwind_Find_exidx (_Unwind_Ptr pc, int * pcount)
+{
+ struct unw_eh_callback_data data;
+
+ data.pc = pc;
+ data.exidx_start = 0;
+ if (dl_iterate_phdr (find_exidx_callback, &data) <= 0)
+ return 0;
+
+ *pcount = data.exidx_len / 8;
+ return data.exidx_start;
+}
diff --git a/ports/sysdeps/arm/eabi/fpu_control.h b/ports/sysdeps/arm/eabi/fpu_control.h
new file mode 100644
index 000000000..55d77649c
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/fpu_control.h
@@ -0,0 +1,51 @@
+/* FPU control word definitions. ARM VFP version.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#ifndef _FPU_CONTROL_H
+#define _FPU_CONTROL_H
+
+/* masking of interrupts */
+#define _FPU_MASK_IM 0x00000100 /* invalid operation */
+#define _FPU_MASK_ZM 0x00000200 /* divide by zero */
+#define _FPU_MASK_OM 0x00000400 /* overflow */
+#define _FPU_MASK_UM 0x00000800 /* underflow */
+#define _FPU_MASK_PM 0x00001000 /* inexact */
+
+/* Some bits in the FPSCR are not yet defined. They must be preserved when
+ modifying the contents. */
+#define _FPU_RESERVED 0x0e08e0e0
+#define _FPU_DEFAULT 0x00000000
+/* Default + exceptions enabled. */
+#define _FPU_IEEE (_FPU_DEFAULT | 0x00001f00)
+
+/* Type of the control word. */
+typedef unsigned int fpu_control_t;
+
+/* Macros for accessing the hardware control word. */
+/* This is fmrx %0, fpscr. */
+#define _FPU_GETCW(cw) \
+ __asm__ __volatile__ ("mrc p10, 7, %0, cr1, cr0, 0" : "=r" (cw))
+/* This is fmxr fpscr, %0. */
+#define _FPU_SETCW(cw) \
+ __asm__ __volatile__ ("mcr p10, 7, %0, cr1, cr0, 0" : : "r" (cw))
+
+/* Default control word set at startup. */
+extern fpu_control_t __fpu_control;
+
+#endif /* _FPU_CONTROL_H */
diff --git a/ports/sysdeps/arm/eabi/fraiseexcpt.c b/ports/sysdeps/arm/eabi/fraiseexcpt.c
new file mode 100644
index 000000000..c0ab41967
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/fraiseexcpt.c
@@ -0,0 +1,110 @@
+/* Raise given exceptions.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include <fpu_control.h>
+#include <fenv.h>
+#include <float.h>
+
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
+#include <asm/procinfo.h>
+
+int
+feraiseexcept (int excepts)
+{
+ if (GLRO (dl_hwcap) & HWCAP_VFP)
+ {
+ int fpscr;
+ const float fp_zero = 0.0, fp_one = 1.0, fp_max = FLT_MAX,
+ fp_min = FLT_MIN, fp_1e32 = 1.0e32f, fp_two = 2.0,
+ fp_three = 3.0;
+
+ /* Raise exceptions represented by EXPECTS. But we must raise only
+ one signal at a time. It is important that if the overflow/underflow
+ exception and the inexact exception are given at the same time,
+ the overflow/underflow exception follows the inexact exception. After
+ each exception we read from the fpscr, to force the exception to be
+ raised immediately. */
+
+ /* There are additional complications because this file may be compiled
+ without VFP support enabled, and we also can't assume that the
+ assembler has VFP instructions enabled. To get around this we use the
+ generic coprocessor mnemonics and avoid asking GCC to put float values
+ in VFP registers. */
+
+ /* First: invalid exception. */
+ if (FE_INVALID & excepts)
+ __asm__ __volatile__ (
+ "ldc p10, cr0, %1\n\t" /* flds s0, %1 */
+ "cdp p10, 8, cr0, cr0, cr0, 0\n\t" /* fdivs s0, s0, s0 */
+ "mrc p10, 7, %0, cr1, cr0, 0" : "=r" (fpscr) /* fmrx %0, fpscr */
+ : "m" (fp_zero)
+ : "s0");
+
+ /* Next: division by zero. */
+ if (FE_DIVBYZERO & excepts)
+ __asm__ __volatile__ (
+ "ldc p10, cr0, %1\n\t" /* flds s0, %1 */
+ "ldcl p10, cr0, %2\n\t" /* flds s1, %2 */
+ "cdp p10, 8, cr0, cr0, cr0, 1\n\t" /* fdivs s0, s0, s1 */
+ "mrc p10, 7, %0, cr1, cr0, 0" : "=r" (fpscr) /* fmrx %0, fpscr */
+ : "m" (fp_one), "m" (fp_zero)
+ : "s0", "s1");
+
+ /* Next: overflow. */
+ if (FE_OVERFLOW & excepts)
+ /* There's no way to raise overflow without also raising inexact. */
+ __asm__ __volatile__ (
+ "ldc p10, cr0, %1\n\t" /* flds s0, %1 */
+ "ldcl p10, cr0, %2\n\t" /* flds s1, %2 */
+ "cdp p10, 3, cr0, cr0, cr0, 1\n\t" /* fadds s0, s0, s1 */
+ "mrc p10, 7, %0, cr1, cr0, 0" : "=r" (fpscr) /* fmrx %0, fpscr */
+ : "m" (fp_max), "m" (fp_1e32)
+ : "s0", "s1");
+
+ /* Next: underflow. */
+ if (FE_UNDERFLOW & excepts)
+ __asm__ __volatile__ (
+ "ldc p10, cr0, %1\n\t" /* flds s0, %1 */
+ "ldcl p10, cr0, %2\n\t" /* flds s1, %2 */
+ "cdp p10, 8, cr0, cr0, cr0, 1\n\t" /* fdivs s0, s0, s1 */
+ "mrc p10, 7, %0, cr1, cr0, 0" : "=r" (fpscr) /* fmrx %0, fpscr */
+ : "m" (fp_min), "m" (fp_three)
+ : "s0", "s1");
+
+ /* Last: inexact. */
+ if (FE_INEXACT & excepts)
+ __asm__ __volatile__ (
+ "ldc p10, cr0, %1\n\t" /* flds s0, %1 */
+ "ldcl p10, cr0, %2\n\t" /* flds s1, %2 */
+ "cdp p10, 8, cr0, cr0, cr0, 1\n\t" /* fdivs s0, s0, s1 */
+ "mrc p10, 7, %0, cr1, cr0, 0" : "=r" (fpscr) /* fmrx %0, fpscr */
+ : "m" (fp_two), "m" (fp_three)
+ : "s0", "s1");
+
+ /* Success. */
+ return 0;
+ }
+
+ /* Unsupported, so fail. */
+ return 1;
+}
+
+libm_hidden_def (feraiseexcept)
diff --git a/ports/sysdeps/arm/eabi/fsetexcptflg.c b/ports/sysdeps/arm/eabi/fsetexcptflg.c
new file mode 100644
index 000000000..e76d74619
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/fsetexcptflg.c
@@ -0,0 +1,60 @@
+/* Set floating-point environment exception handling.
+ Copyright (C) 1997,98,99,2000,01,05 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include <fenv.h>
+#include <math.h>
+#include <fpu_control.h>
+
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
+#include <asm/procinfo.h>
+
+int
+__fesetexceptflag (const fexcept_t *flagp, int excepts)
+{
+ if (GLRO (dl_hwcap) & HWCAP_VFP)
+ {
+ fexcept_t temp;
+
+ /* Get the current environment. */
+ _FPU_GETCW (temp);
+
+ /* Set the desired exception mask. */
+ temp &= ~((excepts & FE_ALL_EXCEPT) << FE_EXCEPT_SHIFT);
+ temp |= (*flagp & excepts & FE_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
+
+ /* Save state back to the FPU. */
+ _FPU_SETCW (temp);
+
+ /* Success. */
+ return 0;
+ }
+
+ /* Unsupported, so fail. */
+ return 1;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__fesetexceptflag, __old_fesetexceptflag)
+compat_symbol (libm, __old_fesetexceptflag, fesetexceptflag, GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, __fesetexceptflag, fesetexceptflag, GLIBC_2_2);
diff --git a/ports/sysdeps/arm/eabi/ftestexcept.c b/ports/sysdeps/arm/eabi/ftestexcept.c
new file mode 100644
index 000000000..230ccbdce
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/ftestexcept.c
@@ -0,0 +1,43 @@
+/* Test exception in current environment.
+ Copyright (C) 1997, 1998, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
+#include <asm/procinfo.h>
+
+int
+fetestexcept (int excepts)
+{
+ if (GLRO (dl_hwcap) & HWCAP_VFP)
+ {
+ fexcept_t temp;
+
+ /* Get current exceptions. */
+ _FPU_GETCW(temp);
+
+ return temp & excepts & FE_ALL_EXCEPT;
+ }
+
+ /* Unsupported, return 0. */
+ return 0;
+}
diff --git a/ports/sysdeps/arm/eabi/rtld-global-offsets.sym b/ports/sysdeps/arm/eabi/rtld-global-offsets.sym
new file mode 100644
index 000000000..ff4e97f2a
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/rtld-global-offsets.sym
@@ -0,0 +1,7 @@
+#define SHARED 1
+
+#include <ldsodefs.h>
+
+#define rtld_global_ro_offsetof(mem) offsetof (struct rtld_global_ro, mem)
+
+RTLD_GLOBAL_RO_DL_HWCAP_OFFSET rtld_global_ro_offsetof (_dl_hwcap)
diff --git a/ports/sysdeps/arm/eabi/setfpucw.c b/ports/sysdeps/arm/eabi/setfpucw.c
new file mode 100644
index 000000000..2bd1f5561
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/setfpucw.c
@@ -0,0 +1,47 @@
+/* Set the FPU control word.
+ Copyright (C) 1996, 1997, 1999, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include <fpu_control.h>
+
+#include <unistd.h>
+#include <ldsodefs.h>
+#include <dl-procinfo.h>
+#include <asm/procinfo.h>
+
+void
+__setfpucw (fpu_control_t set)
+{
+ if (GLRO (dl_hwcap) & HWCAP_VFP)
+ {
+ fpu_control_t cw;
+
+ /* Fetch the current control word. */
+ _FPU_GETCW (cw);
+
+ /* Preserve the reserved bits, and set the rest as the user
+ specified (or the default, if the user gave zero). */
+ cw &= _FPU_RESERVED;
+ cw |= set & ~_FPU_RESERVED;
+
+ _FPU_SETCW (cw);
+ }
+
+ /* Do nothing if a VFP unit isn't present. */
+}
diff --git a/ports/sysdeps/arm/eabi/setjmp.S b/ports/sysdeps/arm/eabi/setjmp.S
new file mode 100644
index 000000000..d9ad26a91
--- /dev/null
+++ b/ports/sysdeps/arm/eabi/setjmp.S
@@ -0,0 +1,85 @@
+/* setjmp for ARM.
+ Copyright (C) 1997, 1998, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the Free
+ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include <sysdep.h>
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+#define __ASSEMBLY__
+#include <asm/procinfo.h>
+#include <rtld-global-offsets.h>
+
+ENTRY (__sigsetjmp)
+ mov ip, r0
+
+ /* Save registers */
+ stmia ip!, {v1-v6, sl, fp, sp, lr}
+
+ /* Check if we have a VFP unit. */
+#ifdef IS_IN_rtld
+ ldr a3, 1f
+ ldr a4, Lrtld_local_ro
+0: add a3, pc, a3
+ add a3, a3, a4
+ ldr a3, [a3, #RTLD_GLOBAL_RO_DL_HWCAP_OFFSET]
+#else
+#ifdef PIC
+ ldr a3, 1f
+ ldr a4, Lrtld_global_ro
+0: add a3, pc, a3
+ ldr a3, [a3, a4]
+ ldr a3, [a3, #RTLD_GLOBAL_RO_DL_HWCAP_OFFSET]
+#else
+ ldr a3, Lhwcap
+ ldr a3, [a3, #0]
+#endif
+#endif
+
+ tst a3, #HWCAP_VFP
+ beq Lno_vfp
+
+ /* Store the VFP registers. */
+ /* Following instruction is fstmiax ip!, {d8-d15}. */
+ stc p11, cr8, [r12], #68
+ /* Store the floating-point status register. */
+ /* Following instruction is fmrx r2, fpscr. */
+ mrc p10, 7, r2, cr1, cr0, 0
+ str r2, [ip], #4
+Lno_vfp:
+
+ /* Make a tail call to __sigjmp_save; it takes the same args. */
+ B PLTJMP(C_SYMBOL_NAME(__sigjmp_save))
+
+#ifdef IS_IN_rtld
+1: .long _GLOBAL_OFFSET_TABLE_ - 0b - 8
+Lrtld_local_ro:
+ .long C_SYMBOL_NAME(_rtld_local_ro)(GOTOFF)
+#else
+#ifdef PIC
+1: .long _GLOBAL_OFFSET_TABLE_ - 0b - 8
+Lrtld_global_ro:
+ .long C_SYMBOL_NAME(_rtld_global_ro)(GOT)
+#else
+Lhwcap:
+ .long C_SYMBOL_NAME(_dl_hwcap)
+#endif
+#endif
+
+END (__sigsetjmp)
+
diff --git a/ports/sysdeps/arm/elf/configure b/ports/sysdeps/arm/elf/configure
new file mode 100644
index 000000000..234fc20c5
--- /dev/null
+++ b/ports/sysdeps/arm/elf/configure
@@ -0,0 +1,45 @@
+# This file is generated from configure.in by Autoconf. DO NOT EDIT!
+ # Local configure fragment for sysdeps/arm/elf.
+
+if test "$usetls" != no; then
+# Check for support of thread-local storage handling in assembler and
+# linker.
+echo "$as_me:$LINENO: checking for ARM TLS support" >&5
+echo $ECHO_N "checking for ARM TLS support... $ECHO_C" >&6
+if test "${libc_cv_arm_tls+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat > conftest.s <<\EOF
+ .section ".tdata", "awT", %progbits
+ .globl foo
+foo: .long 1
+ .section ".tbss", "awT", %nobits
+ .globl bar
+bar: .skip 4
+ .text
+.word foo(tpoff)
+.word foo(tlsgd)
+EOF
+if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ libc_cv_arm_tls=yes
+else
+ libc_cv_arm_tls=no
+fi
+rm -f conftest*
+fi
+echo "$as_me:$LINENO: result: $libc_cv_arm_tls" >&5
+echo "${ECHO_T}$libc_cv_arm_tls" >&6
+if test $libc_cv_arm_tls = yes; then
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_TLS_SUPPORT 1
+_ACEOF
+
+fi
+fi
+
+#AC_DEFINE(PI_STATIC_AND_HIDDEN)
diff --git a/ports/sysdeps/arm/elf/configure.in b/ports/sysdeps/arm/elf/configure.in
new file mode 100644
index 000000000..104529677
--- /dev/null
+++ b/ports/sysdeps/arm/elf/configure.in
@@ -0,0 +1,35 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/arm/elf.
+
+if test "$usetls" != no; then
+# Check for support of thread-local storage handling in assembler and
+# linker.
+AC_CACHE_CHECK(for ARM TLS support, libc_cv_arm_tls, [dnl
+cat > conftest.s <<\EOF
+ .section ".tdata", "awT", %progbits
+ .globl foo
+foo: .long 1
+ .section ".tbss", "awT", %nobits
+ .globl bar
+bar: .skip 4
+ .text
+.word foo(tpoff)
+.word foo(tlsgd)
+EOF
+dnl
+if AC_TRY_COMMAND(${CC-cc} -c $CFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
+ libc_cv_arm_tls=yes
+else
+ libc_cv_arm_tls=no
+fi
+rm -f conftest*])
+if test $libc_cv_arm_tls = yes; then
+ AC_DEFINE(HAVE_TLS_SUPPORT)
+fi
+fi
+
+dnl It is always possible to access static and hidden symbols in an
+dnl position independent way.
+dnl NOTE: This feature was added by the GCC TLS patches. We should test for
+dnl it. Until we do, don't define it.
+#AC_DEFINE(PI_STATIC_AND_HIDDEN)
diff --git a/ports/sysdeps/arm/elf/start.S b/ports/sysdeps/arm/elf/start.S
new file mode 100644
index 000000000..2e0a8b1d6
--- /dev/null
+++ b/ports/sysdeps/arm/elf/start.S
@@ -0,0 +1,112 @@
+/* Startup code for ARM & ELF
+ Copyright (C) 1995, 1996, 1997, 1998, 2001, 2002, 2005
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This is the canonical entry point, usually the first thing in the text
+ segment.
+
+ Note that the code in the .init section has already been run.
+ This includes _init and _libc_init
+
+
+ At this entry point, most registers' values are unspecified, except:
+
+ a1 Contains a function pointer to be registered with `atexit'.
+ This is how the dynamic linker arranges to have DT_FINI
+ functions called for shared libraries that have been loaded
+ before this code runs.
+
+ sp The stack contains the arguments and environment:
+ 0(sp) argc
+ 4(sp) argv[0]
+ ...
+ (4*argc)(sp) NULL
+ (4*(argc+1))(sp) envp[0]
+ ...
+ NULL
+*/
+
+ .text
+ .globl _start
+ .type _start,#function
+_start:
+#if !defined(__USING_SJLJ_EXCEPTIONS__)
+ /* Protect against unhandled exceptions. */
+ .fnstart
+#endif
+ /* Fetch address of fini */
+ ldr ip, =__libc_csu_fini
+
+ /* Clear the frame pointer since this is the outermost frame. */
+ mov fp, #0
+
+ /* Pop argc off the stack and save a pointer to argv */
+ ldr a2, [sp], #4
+ mov a3, sp
+
+ /* Push stack limit */
+ str a3, [sp, #-4]!
+
+ /* Push rtld_fini */
+ str a1, [sp, #-4]!
+
+ /* Set up the other arguments in registers */
+ ldr a1, =main
+ ldr a4, =__libc_csu_init
+
+ /* Push fini */
+ str ip, [sp, #-4]!
+
+ /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
+
+ /* Let the libc call main and exit with its return code. */
+ bl __libc_start_main
+
+ /* should never get here....*/
+ bl abort
+
+#if !defined(__USING_SJLJ_EXCEPTIONS__)
+ .cantunwind
+ .fnend
+#endif
+
+/* Define a symbol for the first piece of initialized data. */
+ .data
+ .globl __data_start
+__data_start:
+ .long 0
+ .weak data_start
+ data_start = __data_start
diff --git a/ports/sysdeps/arm/fpu/__longjmp.S b/ports/sysdeps/arm/fpu/__longjmp.S
new file mode 100644
index 000000000..90efeec1e
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/__longjmp.S
@@ -0,0 +1,36 @@
+/* longjmp for ARM.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+
+/* __longjmp(jmpbuf, val) */
+
+ENTRY (__longjmp)
+ mov ip, r0 /* save jmp_buf pointer */
+
+ movs r0, r1 /* get the return value in place */
+ moveq r0, #1 /* can't let setjmp() return zero! */
+
+ lfmfd f4, 4, [ip] ! /* load the floating point regs */
+
+ LOADREGS(ia, ip, {v1-v6, sl, fp, sp, pc})
+END (__longjmp)
diff --git a/ports/sysdeps/arm/fpu/bits/fenv.h b/ports/sysdeps/arm/fpu/bits/fenv.h
new file mode 100644
index 000000000..7bd242385
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/bits/fenv.h
@@ -0,0 +1,58 @@
+/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FENV_H
+# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
+
+/* Define bits representing exceptions in the FPU status word. */
+enum
+ {
+ FE_INVALID = 1,
+#define FE_INVALID FE_INVALID
+ FE_DIVBYZERO = 2,
+#define FE_DIVBYZERO FE_DIVBYZERO
+ FE_OVERFLOW = 4,
+#define FE_OVERFLOW FE_OVERFLOW
+ FE_UNDERFLOW = 8,
+#define FE_UNDERFLOW FE_UNDERFLOW
+ };
+
+/* Amount to shift by to convert an exception to a mask bit. */
+#define FE_EXCEPT_SHIFT 16
+
+/* All supported exceptions. */
+#define FE_ALL_EXCEPT \
+ (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW)
+
+/* The ARM FPU basically only supports round-to-nearest. Other rounding
+ modes exist, but you have to encode them in the actual instruction. */
+#define FE_TONEAREST 0
+
+/* Type representing exception flags. */
+typedef unsigned long int fexcept_t;
+
+/* Type representing floating-point environment. */
+typedef struct
+ {
+ unsigned long int __cw;
+ }
+fenv_t;
+
+/* If the default argument is used we use this value. */
+#define FE_DFL_ENV ((fenv_t *) -1l)
diff --git a/ports/sysdeps/arm/fpu/bits/mathdef.h b/ports/sysdeps/arm/fpu/bits/mathdef.h
new file mode 100644
index 000000000..e013e74b7
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/bits/mathdef.h
@@ -0,0 +1,44 @@
+/* Copyright (C) 1999, 2000, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#if !defined _MATH_H && !defined _COMPLEX_H
+# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
+#endif
+
+#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
+# define _MATH_H_MATHDEF 1
+
+/* GCC does not promote `float' values to `double'. */
+typedef float float_t; /* `float' expressions are evaluated as
+ `float'. */
+typedef double double_t; /* `double' expressions are evaluated as
+ `double'. */
+
+/* The values returned by `ilogb' for 0 and NaN respectively. */
+# define FP_ILOGB0 (-2147483647)
+# define FP_ILOGBNAN (2147483647)
+
+#endif /* ISO C99 */
+
+#ifndef __NO_LONG_DOUBLE_MATH
+/* Signal that we do not really have a `long double'. This disables the
+ declaration of all the `long double' function variants. */
+/* XXX The FPA does support this but the patterns in GCC are currently
+ turned off. */
+# define __NO_LONG_DOUBLE_MATH 1
+#endif
diff --git a/ports/sysdeps/arm/fpu/bits/setjmp.h b/ports/sysdeps/arm/fpu/bits/setjmp.h
new file mode 100644
index 000000000..431fa039a
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/bits/setjmp.h
@@ -0,0 +1,34 @@
+/* Copyright (C) 1997, 1998, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Define the machine-dependent type `jmp_buf'. ARM version. */
+
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H 1
+
+#if !defined _SETJMP_H && !defined _PTHREAD_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+#ifndef _ASM
+/* Jump buffer contains v1-v6, sl, fp, sp and pc. Other registers are not
+ saved. */
+typedef int __jmp_buf[22];
+#endif
+
+#endif
diff --git a/ports/sysdeps/arm/fpu/fclrexcpt.c b/ports/sysdeps/arm/fpu/fclrexcpt.c
new file mode 100644
index 000000000..c6a53df45
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/fclrexcpt.c
@@ -0,0 +1,50 @@
+/* Clear given exceptions in current floating-point environment.
+ Copyright (C) 1997,98,99,2000,01 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+__feclearexcept (int excepts)
+{
+ unsigned long int temp;
+
+ /* Mask out unsupported bits/exceptions. */
+ excepts &= FE_ALL_EXCEPT;
+
+ /* Get the current floating point status. */
+ _FPU_GETCW (temp);
+
+ /* Clear the relevant bits. */
+ temp &= excepts ^ FE_ALL_EXCEPT;
+
+ /* Put the new data in effect. */
+ _FPU_SETCW (temp);
+
+ /* Success. */
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__feclearexcept, __old_feclearexcept)
+compat_symbol (libm, __old_feclearexcept, feclearexcept, GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, __feclearexcept, feclearexcept, GLIBC_2_2);
diff --git a/ports/sysdeps/arm/fpu/fedisblxcpt.c b/ports/sysdeps/arm/fpu/fedisblxcpt.c
new file mode 100644
index 000000000..91f60a9c9
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/fedisblxcpt.c
@@ -0,0 +1,40 @@
+/* Disable floating-point exceptions.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <philb@gnu.org>, 2001.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fedisableexcept (int excepts)
+{
+ unsigned long int new_exc, old_exc;
+
+ _FPU_GETCW(new_exc);
+
+ old_exc = (new_exc >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT;
+
+ excepts &= FE_ALL_EXCEPT;
+
+ new_exc &= ~(excepts << FE_EXCEPT_SHIFT);
+
+ _FPU_SETCW(new_exc);
+
+ return old_exc;
+}
diff --git a/ports/sysdeps/arm/fpu/feenablxcpt.c b/ports/sysdeps/arm/fpu/feenablxcpt.c
new file mode 100644
index 000000000..e77e45a52
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/feenablxcpt.c
@@ -0,0 +1,40 @@
+/* Enable floating-point exceptions.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <philb@gnu.org>, 2001.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+feenableexcept (int excepts)
+{
+ unsigned long int new_exc, old_exc;
+
+ _FPU_GETCW(new_exc);
+
+ old_exc = (new_exc >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT;
+
+ excepts &= FE_ALL_EXCEPT;
+
+ new_exc |= (excepts << FE_EXCEPT_SHIFT);
+
+ _FPU_SETCW(new_exc);
+
+ return old_exc;
+}
diff --git a/ports/sysdeps/arm/fpu/fegetenv.c b/ports/sysdeps/arm/fpu/fegetenv.c
new file mode 100644
index 000000000..0b40f183e
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/fegetenv.c
@@ -0,0 +1,40 @@
+/* Store current floating-point environment.
+ Copyright (C) 1997,98,99,2000,01 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+__fegetenv (fenv_t *envp)
+{
+ unsigned long int temp;
+ _FPU_GETCW (temp);
+ envp->__cw = temp;
+
+ /* Success. */
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__fegetenv, __old_fegetenv)
+compat_symbol (libm, __old_fegetenv, fegetenv, GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, __fegetenv, fegetenv, GLIBC_2_2);
diff --git a/ports/sysdeps/arm/fpu/fegetexcept.c b/ports/sysdeps/arm/fpu/fegetexcept.c
new file mode 100644
index 000000000..653c8d5a0
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/fegetexcept.c
@@ -0,0 +1,32 @@
+/* Get floating-point exceptions.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <philb@gnu.org>, 2001
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fegetexcept (void)
+{
+ unsigned long temp;
+
+ _FPU_GETCW (temp);
+
+ return (temp >> FE_EXCEPT_SHIFT) & FE_ALL_EXCEPT;
+}
diff --git a/ports/sysdeps/arm/fpu/fegetround.c b/ports/sysdeps/arm/fpu/fegetround.c
new file mode 100644
index 000000000..6bf65f5b5
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/fegetround.c
@@ -0,0 +1,26 @@
+/* Return current rounding direction.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+fegetround (void)
+{
+ return FE_TONEAREST; /* Easy. :-) */
+}
diff --git a/ports/sysdeps/arm/fpu/feholdexcpt.c b/ports/sysdeps/arm/fpu/feholdexcpt.c
new file mode 100644
index 000000000..ae8c6a6d6
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/feholdexcpt.c
@@ -0,0 +1,39 @@
+/* Store current floating-point environment and clear exceptions.
+ Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+feholdexcept (fenv_t *envp)
+{
+ unsigned long int temp;
+
+ /* Store the environment. */
+ _FPU_GETCW(temp);
+ envp->__cw = temp;
+
+ /* Now set all exceptions to non-stop. */
+ temp &= ~(FE_ALL_EXCEPT << FE_EXCEPT_SHIFT);
+ _FPU_SETCW(temp);
+
+ return 0;
+}
+
+libm_hidden_def (feholdexcept)
diff --git a/ports/sysdeps/arm/fpu/fesetenv.c b/ports/sysdeps/arm/fpu/fesetenv.c
new file mode 100644
index 000000000..bb8812aca
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/fesetenv.c
@@ -0,0 +1,45 @@
+/* Install given floating-point environment.
+ Copyright (C) 1997,98,99,2000,01,02 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+__fesetenv (const fenv_t *envp)
+{
+ if (envp == FE_DFL_ENV)
+ _FPU_SETCW (_FPU_DEFAULT);
+ else
+ {
+ unsigned long int temp = envp->__cw;
+ _FPU_SETCW (temp);
+ }
+
+ /* Success. */
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__fesetenv, __old_fesetenv)
+compat_symbol (libm, __old_fesetenv, fesetenv, GLIBC_2_1);
+#endif
+
+libm_hidden_ver (__fesetenv, fesetenv)
+versioned_symbol (libm, __fesetenv, fesetenv, GLIBC_2_2);
diff --git a/ports/sysdeps/arm/fpu/fesetround.c b/ports/sysdeps/arm/fpu/fesetround.c
new file mode 100644
index 000000000..2733e7f5d
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/fesetround.c
@@ -0,0 +1,29 @@
+/* Set current rounding direction.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+fesetround (int round)
+{
+ /* We only support FE_TONEAREST, so there is no need for any work. */
+ return (round == FE_TONEAREST)?0:1;
+}
+
+libm_hidden_def (fesetround)
diff --git a/ports/sysdeps/arm/fpu/fpu_control.h b/ports/sysdeps/arm/fpu/fpu_control.h
new file mode 100644
index 000000000..65912e496
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/fpu_control.h
@@ -0,0 +1,102 @@
+/* FPU control word definitions. ARM version.
+ Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FPU_CONTROL_H
+#define _FPU_CONTROL_H
+
+/* We have a slight terminology confusion here. On the ARM, the register
+ * we're interested in is actually the FPU status word - the FPU control
+ * word is something different (which is implementation-defined and only
+ * accessible from supervisor mode.)
+ *
+ * The FPSR looks like this:
+ *
+ * 31-24 23-16 15-8 7-0
+ * | system ID | trap enable | system control | exception flags |
+ *
+ * We ignore the system ID bits; for interest's sake they are:
+ *
+ * 0000 "old" FPE
+ * 1000 FPPC hardware
+ * 0001 FPE 400
+ * 1001 FPA hardware
+ *
+ * The trap enable and exception flags are both structured like this:
+ *
+ * 7 - 5 4 3 2 1 0
+ * | reserved | INX | UFL | OFL | DVZ | IVO |
+ *
+ * where a `1' bit in the enable byte means that the trap can occur, and
+ * a `1' bit in the flags byte means the exception has occurred.
+ *
+ * The exceptions are:
+ *
+ * IVO - invalid operation
+ * DVZ - divide by zero
+ * OFL - overflow
+ * UFL - underflow
+ * INX - inexact (do not use; implementations differ)
+ *
+ * The system control byte looks like this:
+ *
+ * 7-5 4 3 2 1 0
+ * | reserved | AC | EP | SO | NE | ND |
+ *
+ * where the bits mean
+ *
+ * ND - no denormalised numbers (force them all to zero)
+ * NE - enable NaN exceptions
+ * SO - synchronous operation
+ * EP - use expanded packed-decimal format
+ * AC - use alternate definition for C flag on compare operations
+ */
+
+/* masking of interrupts */
+#define _FPU_MASK_IM 0x00010000 /* invalid operation */
+#define _FPU_MASK_ZM 0x00020000 /* divide by zero */
+#define _FPU_MASK_OM 0x00040000 /* overflow */
+#define _FPU_MASK_UM 0x00080000 /* underflow */
+#define _FPU_MASK_PM 0x00100000 /* inexact */
+#define _FPU_MASK_DM 0x00000000 /* denormalized operation */
+
+/* The system id bytes cannot be changed.
+ Only the bottom 5 bits in the trap enable byte can be changed.
+ Only the bottom 5 bits in the system control byte can be changed.
+ Only the bottom 5 bits in the exception flags are used.
+ The exception flags are set by the fpu, but can be zeroed by the user. */
+#define _FPU_RESERVED 0xffe0e0e0 /* These bits are reserved. */
+
+/* The fdlibm code requires strict IEEE double precision arithmetic,
+ no interrupts for exceptions, rounding to nearest. Changing the
+ rounding mode will break long double I/O. Turn on the AC bit,
+ the compiler generates code that assumes it is on. */
+#define _FPU_DEFAULT 0x00001000 /* Default value. */
+#define _FPU_IEEE 0x001f1000 /* Default + exceptions enabled. */
+
+/* Type of the control word. */
+typedef unsigned int fpu_control_t;
+
+/* Macros for accessing the hardware control word. */
+#define _FPU_GETCW(cw) __asm__ ("rfs %0" : "=r" (cw))
+#define _FPU_SETCW(cw) __asm__ ("wfs %0" : : "r" (cw))
+
+/* Default control word set at startup. */
+extern fpu_control_t __fpu_control;
+
+#endif /* _FPU_CONTROL_H */
diff --git a/ports/sysdeps/arm/fpu/fraiseexcpt.c b/ports/sysdeps/arm/fpu/fraiseexcpt.c
new file mode 100644
index 000000000..f7dede2fe
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/fraiseexcpt.c
@@ -0,0 +1,44 @@
+/* Raise given exceptions.
+ Copyright (C) 1997,98,99,2000,01,02 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+#include <math.h>
+
+int
+__feraiseexcept (int excepts)
+{
+ /* Raise exceptions represented by EXPECTS. */
+ fexcept_t temp;
+ _FPU_GETCW (temp);
+ temp |= (excepts & FE_ALL_EXCEPT);
+ _FPU_SETCW (temp);
+
+ /* Success. */
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__feraiseexcept, __old_feraiseexcept)
+compat_symbol (libm, __old_feraiseexcept, feraiseexcept, GLIBC_2_1);
+#endif
+
+libm_hidden_ver (__feraiseexcept, feraiseexcept)
+versioned_symbol (libm, __feraiseexcept, feraiseexcept, GLIBC_2_2);
diff --git a/ports/sysdeps/arm/fpu/fsetexcptflg.c b/ports/sysdeps/arm/fpu/fsetexcptflg.c
new file mode 100644
index 000000000..4e1d2cba4
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/fsetexcptflg.c
@@ -0,0 +1,49 @@
+/* Set floating-point environment exception handling.
+ Copyright (C) 1997,98,99,2000,01 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <math.h>
+#include <fpu_control.h>
+
+int
+__fesetexceptflag (const fexcept_t *flagp, int excepts)
+{
+ fexcept_t temp;
+
+ /* Get the current environment. */
+ _FPU_GETCW (temp);
+
+ /* Set the desired exception mask. */
+ temp &= ~((excepts & FE_ALL_EXCEPT) << FE_EXCEPT_SHIFT);
+ temp |= (*flagp & excepts & FE_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
+
+ /* Save state back to the FPU. */
+ _FPU_SETCW (temp);
+
+ /* Success. */
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__fesetexceptflag, __old_fesetexceptflag)
+compat_symbol (libm, __old_fesetexceptflag, fesetexceptflag, GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, __fesetexceptflag, fesetexceptflag, GLIBC_2_2);
diff --git a/ports/sysdeps/arm/fpu/ftestexcept.c b/ports/sysdeps/arm/fpu/ftestexcept.c
new file mode 100644
index 000000000..328bcb05f
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/ftestexcept.c
@@ -0,0 +1,32 @@
+/* Test exception in current environment.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fetestexcept (int excepts)
+{
+ fexcept_t temp;
+
+ /* Get current exceptions. */
+ _FPU_GETCW(temp);
+
+ return temp & excepts & FE_ALL_EXCEPT;
+}
diff --git a/ports/sysdeps/arm/fpu/jmpbuf-offsets.h b/ports/sysdeps/arm/fpu/jmpbuf-offsets.h
new file mode 100644
index 000000000..ad2a75ba0
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/jmpbuf-offsets.h
@@ -0,0 +1,20 @@
+/* Private macros for accessing __jmp_buf contents. ARM/FPU version.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define __JMP_BUF_SP 20
diff --git a/ports/sysdeps/arm/fpu/setjmp.S b/ports/sysdeps/arm/fpu/setjmp.S
new file mode 100644
index 000000000..84328369a
--- /dev/null
+++ b/ports/sysdeps/arm/fpu/setjmp.S
@@ -0,0 +1,35 @@
+/* setjmp for ARM.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+
+ENTRY (__sigsetjmp)
+ /* Save registers */
+ sfmea f4, 4, [r0]!
+ stmia r0, {v1-v6, sl, fp, sp, lr}
+
+ /* Restore pointer to jmp_buf */
+ sub r0, r0, #48
+
+ /* Make a tail call to __sigjmp_save; it takes the same args. */
+ B PLTJMP(C_SYMBOL_NAME(__sigjmp_save))
+END (__sigsetjmp)
diff --git a/ports/sysdeps/arm/frame.h b/ports/sysdeps/arm/frame.h
new file mode 100644
index 000000000..deb46c013
--- /dev/null
+++ b/ports/sysdeps/arm/frame.h
@@ -0,0 +1,28 @@
+/* Definition of stack frame structure. ARM/APCS version.
+ Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This is the APCS stack backtrace structure. */
+struct layout
+{
+ struct layout *__unbounded next;
+ void *__unbounded sp;
+ void *__unbounded return_address;
+};
+
+#define FIRST_FRAME_POINTER ADVANCE_STACK_FRAME (__builtin_frame_address (0))
diff --git a/ports/sysdeps/arm/framestate.c b/ports/sysdeps/arm/framestate.c
new file mode 100644
index 000000000..710cecca9
--- /dev/null
+++ b/ports/sysdeps/arm/framestate.c
@@ -0,0 +1 @@
+/* Empty */
diff --git a/ports/sysdeps/arm/gccframe.h b/ports/sysdeps/arm/gccframe.h
new file mode 100644
index 000000000..ef8df2630
--- /dev/null
+++ b/ports/sysdeps/arm/gccframe.h
@@ -0,0 +1,22 @@
+/* Definition of object in frame unwind info. arm version.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define FIRST_PSEUDO_REGISTER 27
+
+#include <sysdeps/generic/gccframe.h>
diff --git a/ports/sysdeps/arm/gmp-mparam.h b/ports/sysdeps/arm/gmp-mparam.h
new file mode 100644
index 000000000..57ad7e21f
--- /dev/null
+++ b/ports/sysdeps/arm/gmp-mparam.h
@@ -0,0 +1,38 @@
+/* gmp-mparam.h -- Compiler/machine parameter header file.
+
+Copyright (C) 1991, 1993, 1994, 1995, 2005 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#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
+
+#if defined(__ARMEB__)
+# define IEEE_DOUBLE_MIXED_ENDIAN 0
+# define IEEE_DOUBLE_BIG_ENDIAN 1
+#elif defined(__VFP_FP__)
+# define IEEE_DOUBLE_MIXED_ENDIAN 0
+# define IEEE_DOUBLE_BIG_ENDIAN 0
+#else
+# define IEEE_DOUBLE_BIG_ENDIAN 0
+# define IEEE_DOUBLE_MIXED_ENDIAN 1
+#endif
diff --git a/ports/sysdeps/arm/initfini.c b/ports/sysdeps/arm/initfini.c
new file mode 100644
index 000000000..659ee9140
--- /dev/null
+++ b/ports/sysdeps/arm/initfini.c
@@ -0,0 +1,42 @@
+/* Special .init and .fini section support. ARM version.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Prevent this function from being inlined. Otherwise half of its
+ constant pool will end up in crti and the other half in crtn. */
+
+static void call_gmon_start (void) __attribute__((noinline));
+
+#include <sysdeps/generic/initfini.c>
diff --git a/ports/sysdeps/arm/jmpbuf-offsets.h b/ports/sysdeps/arm/jmpbuf-offsets.h
new file mode 100644
index 000000000..d4f7fe2bf
--- /dev/null
+++ b/ports/sysdeps/arm/jmpbuf-offsets.h
@@ -0,0 +1,20 @@
+/* Private macros for accessing __jmp_buf contents. ARM version.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define __JMP_BUF_SP 8
diff --git a/ports/sysdeps/arm/jmpbuf-unwind.h b/ports/sysdeps/arm/jmpbuf-unwind.h
new file mode 100644
index 000000000..7990eeb12
--- /dev/null
+++ b/ports/sysdeps/arm/jmpbuf-unwind.h
@@ -0,0 +1,36 @@
+/* Copyright (C) 2005,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+#include <stdint.h>
+#include <unwind.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
+ ((void *) (address) < (void *) demangle (jmpbuf[__JMP_BUF_SP]))
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf)[__JMP_BUF_SP] - (_adj))
+
+/* We use the normal longjmp for unwinding. */
+#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
diff --git a/ports/sysdeps/arm/ldsodefs.h b/ports/sysdeps/arm/ldsodefs.h
new file mode 100644
index 000000000..d700e220c
--- /dev/null
+++ b/ports/sysdeps/arm/ldsodefs.h
@@ -0,0 +1,41 @@
+/* Run-time dynamic linker data structures for loaded ELF shared objects.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _ARM_LDSODEFS_H
+#define _ARM_LDSODEFS_H 1
+
+#include <elf.h>
+
+struct La_arm_regs;
+struct La_arm_retval;
+
+#define ARCH_PLTENTER_MEMBERS \
+ Elf32_Addr (*arm_gnu_pltenter) (Elf32_Sym *, unsigned int, uintptr_t *, \
+ uintptr_t *, struct La_arm_regs *, \
+ unsigned int *, const char *, \
+ long int *)
+
+#define ARCH_PLTEXIT_MEMBERS \
+ Elf32_Addr (*arm_gnu_pltexit) (Elf32_Sym *, unsigned int, uintptr_t *, \
+ uintptr_t *, struct La_arm_regs *, \
+ struct La_arm_retval *, const char *)
+
+#include_next <ldsodefs.h>
+
+#endif
diff --git a/ports/sysdeps/arm/libc-tls.c b/ports/sysdeps/arm/libc-tls.c
new file mode 100644
index 000000000..affb1899e
--- /dev/null
+++ b/ports/sysdeps/arm/libc-tls.c
@@ -0,0 +1,37 @@
+/* Thread-local storage handling in the ELF dynamic linker. ARM version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <csu/libc-tls.c>
+#include <dl-tls.h>
+
+#if USE_TLS
+
+/* On ARM, linker optimizations are not required, so __tls_get_addr
+ can be called even in statically linked binaries. In this case module
+ must be always 1 and PT_TLS segment exist in the binary, otherwise it
+ would not link. */
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+ dtv_t *dtv = THREAD_DTV ();
+ return (char *) dtv[1].pointer.val + ti->ti_offset;
+}
+
+#endif
diff --git a/ports/sysdeps/arm/libm-test-ulps b/ports/sysdeps/arm/libm-test-ulps
new file mode 100644
index 000000000..6a4bcc614
--- /dev/null
+++ b/ports/sysdeps/arm/libm-test-ulps
@@ -0,0 +1,1079 @@
+# Begin of automatic generation
+
+# asin
+Test "asin (-0.5) == -pi/6":
+float: 2
+ifloat: 2
+Test "asin (0.5) == pi/6":
+float: 2
+ifloat: 2
+Test "asin (0.7) == 0.77539749661075306374035335271498708":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# atanh
+Test "atanh (0.7) == 0.8673005276940531944":
+double: 1
+idouble: 1
+
+# cabs
+Test "cabs (-0.7 + 12.4 i) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "cabs (-0.7 - 12.4 i) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "cabs (-12.4 + 0.7 i) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "cabs (-12.4 - 0.7 i) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "cabs (0.7 + 1.2 i) == 1.3892443989449804508432547041028554":
+double: 1
+idouble: 1
+Test "cabs (0.7 + 12.4 i) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# cacos
+Test "Real part of: cacos (0.7 + 1.2 i) == 1.1351827477151551088992008271819053 - 1.0927647857577371459105272080819308 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0.7 + 1.2 i) == 1.1351827477151551088992008271819053 - 1.0927647857577371459105272080819308 i":
+float: 1
+ifloat: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+Test "Real part of: cacosh (0.7 + 1.2 i) == 1.0927647857577371459105272080819308 + 1.1351827477151551088992008271819053 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# casin
+Test "Real part of: casin (0.7 + 1.2 i) == 0.4356135790797415103321208644578462 + 1.0927647857577371459105272080819308 i":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+Test "Imaginary part of: casin (0.7 + 1.2 i) == 0.4356135790797415103321208644578462 + 1.0927647857577371459105272080819308 i":
+float: 1
+ifloat: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+Test "Real part of: casinh (0.7 + 1.2 i) == 0.97865459559367387689317593222160964 + 0.91135418953156011567903546856170941 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (0.7 + 1.2 i) == 0.97865459559367387689317593222160964 + 0.91135418953156011567903546856170941 i":
+float: 1
+ifloat: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.7 + 1.2 i) == 1.0785743834118921877443707996386368 + 0.57705737765343067644394541889341712 i":
+float: 4
+ifloat: 4
+Test "Imaginary part of: catan (0.7 + 1.2 i) == 1.0785743834118921877443707996386368 + 0.57705737765343067644394541889341712 i":
+double: 1
+idouble: 1
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.7 + 1.2 i) == 0.2600749516525135959200648705635915 + 0.97024030779509898497385130162655963 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0.7 + 1.2 i) == 0.2600749516525135959200648705635915 + 0.97024030779509898497385130162655963 i":
+double: 1
+float: 6
+idouble: 1
+ifloat: 6
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.970299) == 0.99":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.7 + 1.2 i) == 1.3848657645312111080 - 0.97242170335830028619 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccos (0.7 + 1.2 i) == 1.3848657645312111080 - 0.97242170335830028619 i":
+double: 1
+idouble: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.7 + 1.2 i) == 0.4548202223691477654 + 0.7070296600921537682 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.7 + 1.2 i) == 0.4548202223691477654 + 0.7070296600921537682 i":
+double: 1
+idouble: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.7 + 1.2 i) == 0.72969890915032360123451688642930727 + 1.8768962328348102821139467908203072 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cexp (0.7 + 1.2 i) == 0.72969890915032360123451688642930727 + 1.8768962328348102821139467908203072 i":
+float: 1
+ifloat: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0.7 + 1.2 i) == 0.1427786545038868803 + 0.4528483579352493248 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0.7 + 1.2 i) == 0.1427786545038868803 + 0.4528483579352493248 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+float: 1
+ifloat: 1
+
+# cos
+Test "cos (0.7) == 0.76484218728448842625585999019186495":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 0.5
+idouble: 1
+ifloat: 0.5
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "cos (pi/2) == 0":
+double: 0.2758
+float: 0.3667
+idouble: 0.2758
+ifloat: 0.3667
+
+# cpow
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 1.1031
+float: 1.5
+idouble: 1.1031
+ifloat: 1.5
+
+# csin
+Test "Imaginary part of: csin (0.7 + 1.2 i) == 1.1664563419657581376 + 1.1544997246948547371 i":
+float: 1
+ifloat: 1
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.7 + 1.2 i) == 0.27487868678117583582 + 1.1698665727426565139 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.7 + 1.2 i) == 0.27487868678117583582 + 1.1698665727426565139 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (0.7 + 1.2 i) == 1.022067610030026450706487883081139 + 0.58704531296356521154977678719838035 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: csqrt (0.7 + 1.2 i) == 1.022067610030026450706487883081139 + 0.58704531296356521154977678719838035 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+Test "Real part of: ctan (0.7 + 1.2 i) == 0.1720734197630349001 + 0.9544807059989405538 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctan (0.7 + 1.2 i) == 0.1720734197630349001 + 0.9544807059989405538 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.7 + 1.2 i) == 1.3472197399061191630 + 0.4778641038326365540 i":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "Imaginary part of: ctanh (0.7 + 1.2 i) == 1.3472197399061191630 + 0.4778641038326365540 i":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# erfc
+Test "erfc (0.7) == 0.32219880616258152702":
+double: 1
+idouble: 1
+Test "erfc (1.2) == 0.089686021770364619762":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+Test "erfc (2.0) == 0.0046777349810472658379":
+double: 1
+idouble: 1
+Test "erfc (4.1) == 0.67000276540848983727e-8":
+double: 24
+float: 12
+idouble: 24
+ifloat: 12
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.7) == 5.0118723362727228500155418688494574":
+float: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+# expm1
+Test "expm1 (1) == M_El - 1.0":
+float: 1
+ifloat: 1
+
+# fmod
+Test "fmod (-6.5, -2.3) == -1.9":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "fmod (-6.5, 2.3) == -1.9":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "fmod (6.5, -2.3) == 1.9":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "fmod (6.5, 2.3) == 1.9":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 1.2) == 1.3892443989449804508432547041028554":
+double: 1
+idouble: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (10.0) == -0.24593576445134833520":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0) == 0.22389077914123566805":
+float: 2
+ifloat: 2
+Test "j0 (8.0) == 0.17165080713755390609":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.043472746168861436670":
+float: 2
+ifloat: 2
+Test "j1 (2.0) == 0.57672480775687338720":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.23463634685391462438":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, 10.0) == -0.24593576445134833520":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0) == 0.22389077914123566805":
+float: 2
+ifloat: 2
+Test "jn (0, 8.0) == 0.17165080713755390609":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.043472746168861436670":
+float: 2
+ifloat: 2
+Test "jn (1, 2.0) == 0.57672480775687338720":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.23463634685391462438":
+double: 1
+idouble: 1
+Test "jn (10, 0.1) == 0.26905328954342155795e-19":
+double: 6
+float: 4
+idouble: 6
+ifloat: 4
+Test "jn (10, 0.7) == 0.75175911502153953928e-11":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (10, 10.0) == 0.20748610663335885770":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (10, 2.0) == 0.25153862827167367096e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.1) == 0.000020820315754756261429":
+double: 1
+idouble: 1
+Test "jn (3, 0.7) == 0.0069296548267508408077":
+float: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.058379379305186812343":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (3, 2.0) == 0.12894324947440205110":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log
+Test "log (0.7) == -0.35667494393873237891263871124118447":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# log10
+Test "log10 (0.7) == -0.15490195998574316929":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.3) == -0.35667494393873237891263871124118447":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# log2
+Test "log2 (0.7) == -0.51457317282975824043":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# sincos
+Test "sincos (0.7, &sin_res, &cos_res) puts 0.76484218728448842625585999019186495 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 0.5
+idouble: 1
+ifloat: 0.5
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 0.2758
+float: 0.3667
+idouble: 0.2758
+ifloat: 0.3667
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.866025403784438646764 in cos_res":
+float: 1
+ifloat: 1
+
+# sinh
+Test "sinh (0.7) == 0.75858370183953350346":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 0.5
+idouble: 0.5
+
+# tanh
+Test "tanh (0.7) == 0.60436777711716349631":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (0.7) == -0.19066492933739506743":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.0) == 0.088256964215676957983":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.38244892379775884396":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.055671167283599391424":
+float: 1
+ifloat: 1
+Test "y0 (8.0) == 0.22352148938756622053":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y1
+Test "y1 (0.1) == -6.4589510947020269877":
+double: 1
+idouble: 1
+Test "y1 (0.7) == -1.1032498719076333697":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (1.5) == -0.41230862697391129595":
+float: 1
+ifloat: 1
+Test "y1 (10.0) == 0.24901542420695388392":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.10703243154093754689":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (8.0) == -0.15806046173124749426":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 0.7) == -0.19066492933739506743":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.0) == 0.088256964215676957983":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.38244892379775884396":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.055671167283599391424":
+float: 1
+ifloat: 1
+Test "yn (0, 8.0) == 0.22352148938756622053":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 0.1) == -6.4589510947020269877":
+double: 1
+idouble: 1
+Test "yn (1, 0.7) == -1.1032498719076333697":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 1.5) == -0.41230862697391129595":
+float: 1
+ifloat: 1
+Test "yn (1, 10.0) == 0.24901542420695388392":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.10703243154093754689":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0) == -0.15806046173124749426":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.1) == -0.11831335132045197885e19":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+Test "yn (10, 0.7) == -0.42447194260703866924e10":
+double: 3
+idouble: 3
+Test "yn (10, 1.0) == -0.12161801427868918929e9":
+double: 1
+idouble: 1
+Test "yn (10, 10.0) == -0.35981415218340272205":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 2.0) == -129184.54220803928264":
+double: 2
+idouble: 2
+Test "yn (3, 0.1) == -5099.3323786129048894":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 0.7) == -15.819479052819633505":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (3, 10.0) == -0.25136265718383732978":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.1277837768404277861":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "asin":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "atanh":
+double: 1
+idouble: 1
+
+Function: "cabs":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "cacos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "cacos":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "casin":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: Imaginary part of "casin":
+float: 1
+ifloat: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+float: 1
+idouble: 4
+ifloat: 1
+
+Function: Imaginary part of "catanh":
+double: 1
+float: 6
+idouble: 1
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+
+Function: Real part of "ccos":
+double: 1
+idouble: 1
+
+Function: Imaginary part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+double: 1.1031
+float: 2
+idouble: 1.1031
+ifloat: 2
+
+Function: Imaginary part of "csin":
+float: 1
+ifloat: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "ctanh":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Imaginary part of "ctanh":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "erfc":
+double: 24
+float: 12
+idouble: 24
+ifloat: 12
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+Function: "expm1":
+float: 1
+ifloat: 1
+
+Function: "fmod":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "hypot":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 6
+float: 4
+idouble: 6
+ifloat: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "log10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "log1p":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "log2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "sinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 0.5
+idouble: 0.5
+
+Function: "tanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
diff --git a/ports/sysdeps/arm/linuxthreads/pspinlock.c b/ports/sysdeps/arm/linuxthreads/pspinlock.c
new file mode 100644
index 000000000..665e270b6
--- /dev/null
+++ b/ports/sysdeps/arm/linuxthreads/pspinlock.c
@@ -0,0 +1,82 @@
+/* POSIX spinlock implementation. Arm version.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+
+
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ unsigned int val;
+
+ do
+ asm volatile ("swp %0, %1, [%2]"
+ : "=r" (val)
+ : "0" (1), "r" (lock)
+ : "memory");
+ while (val != 0);
+
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ unsigned int val;
+
+ asm volatile ("swp %0, %1, [%2]"
+ : "=r" (val)
+ : "0" (1), "r" (lock)
+ : "memory");
+
+ return val ? EBUSY : 0;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ return *lock = 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ return *lock = 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/ports/sysdeps/arm/linuxthreads/pt-machine.h b/ports/sysdeps/arm/linuxthreads/pt-machine.h
new file mode 100644
index 000000000..a4c2f314c
--- /dev/null
+++ b/ports/sysdeps/arm/linuxthreads/pt-machine.h
@@ -0,0 +1,55 @@
+/* Machine-dependent pthreads configuration and inline functions.
+ ARM version.
+ Copyright (C) 1997, 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <philb@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#ifndef PT_EI
+# define PT_EI extern inline __attribute__ ((always_inline))
+#endif
+
+extern long int testandset (int *spinlock);
+extern int __compare_and_swap (long int *p, long int oldval, long int newval);
+
+/* This will not work on ARM1 or ARM2 because SWP is lacking on those
+ machines. Unfortunately we have no way to detect this at compile
+ time; let's hope nobody tries to use one. */
+
+/* Spinlock implementation; required. */
+PT_EI long int
+testandset (int *spinlock)
+{
+ register unsigned int ret;
+
+ __asm__ __volatile__("swp %0, %1, [%2]"
+ : "=r"(ret)
+ : "0"(1), "r"(spinlock));
+
+ return ret;
+}
+
+
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME stack_pointer
+register char * stack_pointer __asm__ ("sp");
+
+#endif /* pt-machine.h */
diff --git a/ports/sysdeps/arm/linuxthreads/tls.h b/ports/sysdeps/arm/linuxthreads/tls.h
new file mode 100644
index 000000000..8057a5413
--- /dev/null
+++ b/ports/sysdeps/arm/linuxthreads/tls.h
@@ -0,0 +1,172 @@
+/* Definitions for thread-local data handling. linuxthreads/ARM version.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+#ifndef __ASSEMBLER__
+
+# include <stdbool.h>
+# include <pt-machine.h>
+# include <stddef.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+typedef struct
+{
+ dtv_t *dtv;
+
+ /* Reserved for the thread implementation. Unused in LinuxThreads. */
+ void *private;
+} tcbhead_t;
+#endif
+
+
+/* We can support TLS only if the floating-stack support is available.
+ However, we want to compile in the support and test at runtime whether
+ the running kernel can support it or not. To avoid bothering with the
+ TLS support code at all, use configure --without-tls.
+
+ We need USE_TLS to be consistently defined, for ldsodefs.h conditionals.
+ But some of the code below can cause problems in building libpthread
+ (e.g. useldt.h will defined FLOATING_STACKS when it shouldn't). */
+
+/* LinuxThreads can only support TLS if both floating stacks and support
+ from the tools are available.
+
+ We have to define USE_TLS consistently, or ldsodefs.h will lay out types
+ differently between an NPTL build and a LinuxThreads build. It can be set
+ for libc.so and not libpthread.so, but only if we provide appropriate padding
+ in the _pthread_descr_struct.
+
+ Currently nothing defines FLOATING_STACKS. We could assume this based on
+ kernel version once the TLS patches are available in kernel.org.
+
+ To avoid bothering with the TLS support code at all, use configure
+ --without-tls. */
+
+#if defined HAVE_TLS_SUPPORT \
+ && (defined FLOATING_STACKS || !defined IS_IN_libpthread)
+
+/* Signal that TLS support is available. */
+# define USE_TLS 1
+
+/* Include padding in _pthread_descr_struct so that libc can find p_errno,
+ if libpthread will only include the padding because of the !IS_IN_libpthread
+ check. */
+#ifndef FLOATING_STACKS
+# define INCLUDE_TLS_PADDING 1
+#endif
+
+# ifndef __ASSEMBLER__
+/* Get system call information. */
+# include <sysdep.h>
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (tcbhead_t)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
+
+/* The DTV is allocated at the TP; the TCB is placed elsewhere. */
+# define TLS_DTV_AT_TP 1
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(TCBP, DTVP) \
+ (((tcbhead_t *) (TCBP))->dtv = (DTVP) + 1)
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(DTV) \
+ (((tcbhead_t *)__builtin_thread_pointer ())->dtv = (DTV))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(TCBP) \
+ (((tcbhead_t *) (TCBP))->dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(TCBP, SECONDCALL) \
+ ({ INTERNAL_SYSCALL_DECL (err); \
+ long result_var; \
+ result_var = INTERNAL_SYSCALL_ARM (set_tls, err, 1, (TCBP)); \
+ INTERNAL_SYSCALL_ERROR_P (result_var, err) \
+ ? "unknown error" : NULL; })
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *)__builtin_thread_pointer ())->dtv)
+
+/* Return the thread descriptor for the current thread. */
+# undef THREAD_SELF
+# define THREAD_SELF \
+ ((pthread_descr)__builtin_thread_pointer () - 1)
+
+# undef INIT_THREAD_SELF
+# define INIT_THREAD_SELF(DESCR, NR) \
+ TLS_INIT_TP ((struct _pthread_descr_struct *)(DESCR) + 1, 0)
+
+/* Get the thread descriptor definition. */
+# include <linuxthreads/descr.h>
+
+/* ??? Generic bits of LinuxThreads may call these macros with
+ DESCR set to NULL. We are expected to be able to reference
+ the "current" value.
+
+ In our case, we'd really prefer to use DESCR, since lots of
+ PAL_code calls would be expensive. We can only trust that
+ the compiler does its job and unifies the multiple
+ __builtin_thread_pointer instances. */
+
+#define THREAD_GETMEM(descr, member) \
+ ((void) sizeof (descr), THREAD_SELF->member)
+#define THREAD_GETMEM_NC(descr, member) \
+ ((void) sizeof (descr), THREAD_SELF->member)
+#define THREAD_SETMEM(descr, member, value) \
+ ((void) sizeof (descr), THREAD_SELF->member = (value))
+#define THREAD_SETMEM_NC(descr, member, value) \
+ ((void) sizeof (descr), THREAD_SELF->member = (value))
+
+/* Initializing the thread pointer will generate a SIGILL if the syscall
+ is not available. */
+#define TLS_INIT_TP_EXPENSIVE 1
+
+# endif /* HAVE_TLS_SUPPORT */
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/ports/sysdeps/arm/machine-gmon.h b/ports/sysdeps/arm/machine-gmon.h
new file mode 100644
index 000000000..fa3f65237
--- /dev/null
+++ b/ports/sysdeps/arm/machine-gmon.h
@@ -0,0 +1,67 @@
+/* Machine-dependent definitions for profiling support. ARM version.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* GCC for the ARM cannot compile __builtin_return_address(N) for N != 0,
+ so we must use an assembly stub. */
+
+#include <sysdep.h>
+#ifndef NO_UNDERSCORES
+/* The asm symbols for C functions are `_function'.
+ The canonical name for the counter function is `mcount', no _. */
+void _mcount (void) asm ("mcount");
+#else
+/* The canonical name for the function is `_mcount' in both C and asm,
+ but some old asm code might assume it's `mcount'. */
+void _mcount (void);
+weak_alias (_mcount, mcount)
+#endif
+
+static void mcount_internal (u_long frompc, u_long selfpc) __attribute_used__;
+
+#define _MCOUNT_DECL(frompc, selfpc) \
+static void mcount_internal (u_long frompc, u_long selfpc)
+
+/* This macro/func MUST save r0, r1 because the compiler inserts
+ blind calls to _mount(), ignoring the fact that _mcount may
+ clobber registers; therefore, _mcount may NOT clobber registers */
+/* if (this_fp!=0) {
+ r0 = this_fp
+ r1 = this_lr
+ r1 = [r1-4] which is caller's lr
+ if (r1!=0)
+ r1 = caller's lr
+ call mcount_internal(this_lr, caller's_lr)
+ }
+*/
+
+#define MCOUNT \
+void _mcount (void) \
+{ \
+ __asm__("stmdb sp!, {r0, r1, r2, r3};" \
+ "movs fp, fp;" \
+ "moveq r1, #0;" \
+ "ldrne r1, [fp, $-4];" \
+ "ldrne r0, [fp, $-12];" \
+ "movnes r0, r0;" \
+ "ldrne r0, [r0, $-4];" \
+ "movs r0, r0;" \
+ "blne mcount_internal;" \
+ "ldmia sp!, {r0, r1, r2, r3}"); \
+}
+
diff --git a/ports/sysdeps/arm/memset.S b/ports/sysdeps/arm/memset.S
new file mode 100644
index 000000000..b37451bc1
--- /dev/null
+++ b/ports/sysdeps/arm/memset.S
@@ -0,0 +1,68 @@
+/* Copyright (C) 1998, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <philb@gnu.org>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+/* void *memset (dstpp, c, len) */
+
+ENTRY(memset)
+ mov r3, r0
+ cmp r2, #8
+ bcc 2f @ less than 8 bytes to move
+
+1:
+ tst r3, #3 @ aligned yet?
+ strneb r1, [r3], #1
+ subne r2, r2, #1
+ bne 1b
+
+ and r1, r1, #255 @ clear any sign bits
+ orr r1, r1, r1, lsl $8
+ orr r1, r1, r1, lsl $16
+
+1:
+ subs r2, r2, #8
+ strcs r1, [r3], #4 @ store up to 32 bytes per loop iteration
+ strcs r1, [r3], #4
+ subcss r2, r2, #8
+ strcs r1, [r3], #4
+ strcs r1, [r3], #4
+ subcss r2, r2, #8
+ strcs r1, [r3], #4
+ strcs r1, [r3], #4
+ subcss r2, r2, #8
+ strcs r1, [r3], #4
+ strcs r1, [r3], #4
+ bcs 1b
+
+ and r2, r2, #7
+2:
+ subs r2, r2, #1 @ store up to 4 bytes per loop iteration
+ strcsb r1, [r3], #1
+ subcss r2, r2, #1
+ strcsb r1, [r3], #1
+ subcss r2, r2, #1
+ strcsb r1, [r3], #1
+ subcss r2, r2, #1
+ strcsb r1, [r3], #1
+ bcs 2b
+
+ DO_RET(lr)
+END(memset)
+libc_hidden_builtin_def (memset)
diff --git a/ports/sysdeps/arm/memusage.h b/ports/sysdeps/arm/memusage.h
new file mode 100644
index 000000000..c558a06b5
--- /dev/null
+++ b/ports/sysdeps/arm/memusage.h
@@ -0,0 +1,21 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; })
+
+#include <sysdeps/generic/memusage.h>
diff --git a/ports/sysdeps/arm/nptl/Makefile b/ports/sysdeps/arm/nptl/Makefile
new file mode 100644
index 000000000..030069378
--- /dev/null
+++ b/ports/sysdeps/arm/nptl/Makefile
@@ -0,0 +1,21 @@
+# Copyright (C) 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+ifeq ($(subdir),csu)
+gen-as-const-headers += tcb-offsets.sym
+endif
diff --git a/ports/sysdeps/arm/nptl/pthread_spin_lock.S b/ports/sysdeps/arm/nptl/pthread_spin_lock.S
new file mode 100644
index 000000000..bd6adf794
--- /dev/null
+++ b/ports/sysdeps/arm/nptl/pthread_spin_lock.S
@@ -0,0 +1,31 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+ .text
+ .align 4
+
+ENTRY (pthread_spin_lock)
+ mov r1, #1
+1: swp r2, r1, [r0]
+ teq r2, #0
+ bne 1b
+ mov r0, #0
+ PSEUDO_RET_NOERRNO
+END (pthread_spin_lock)
diff --git a/ports/sysdeps/arm/nptl/pthread_spin_trylock.S b/ports/sysdeps/arm/nptl/pthread_spin_trylock.S
new file mode 100644
index 000000000..85931507a
--- /dev/null
+++ b/ports/sysdeps/arm/nptl/pthread_spin_trylock.S
@@ -0,0 +1,34 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define _ERRNO_H 1
+#include <bits/errno.h>
+
+#include <sysdep.h>
+
+ .text
+ .align 4
+
+ENTRY (pthread_spin_trylock)
+ mov r1, #1
+ swp r2, r1, [r0]
+ teq r2, #0
+ moveq r0, #0
+ movne r0, #EBUSY
+ PSEUDO_RET_NOERRNO
+END (pthread_spin_trylock)
diff --git a/ports/sysdeps/arm/nptl/pthreaddef.h b/ports/sysdeps/arm/nptl/pthreaddef.h
new file mode 100644
index 000000000..b1a06cd1e
--- /dev/null
+++ b/ports/sysdeps/arm/nptl/pthreaddef.h
@@ -0,0 +1,47 @@
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. SSE requires 16
+ bytes. */
+#define STACK_ALIGN 16
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 16
+
+
+/* Location of current stack frame.
+
+ __builtin_frame_address (0) returns the value of the hard frame
+ pointer, which will point at the location of the saved PC on the
+ stack. Below this in memory is the remainder of the linkage info,
+ occupying 12 bytes. Therefore in order to address from
+ CURRENT_STACK_FRAME using "struct layout", we need to have the macro
+ return the hard FP minus 12. Of course, this makes no sense
+ without the obsolete APCS stack layout... */
+#define CURRENT_STACK_FRAME (__builtin_frame_address (0) - 12)
+
+
+/* XXX Until we have a better place keep the definitions here. */
+#define __exit_thread_inline(val) \
+ INLINE_SYSCALL (exit, 1, (val))
diff --git a/ports/sysdeps/arm/nptl/tcb-offsets.sym b/ports/sysdeps/arm/nptl/tcb-offsets.sym
new file mode 100644
index 000000000..92cc441d3
--- /dev/null
+++ b/ports/sysdeps/arm/nptl/tcb-offsets.sym
@@ -0,0 +1,11 @@
+#include <sysdep.h>
+#include <tls.h>
+
+--
+
+-- Derive offsets relative to the thread register.
+#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - sizeof(struct pthread))
+
+MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
+PID_OFFSET thread_offsetof (pid)
+TID_OFFSET thread_offsetof (tid)
diff --git a/ports/sysdeps/arm/nptl/tls.h b/ports/sysdeps/arm/nptl/tls.h
new file mode 100644
index 000000000..26ef70961
--- /dev/null
+++ b/ports/sysdeps/arm/nptl/tls.h
@@ -0,0 +1,137 @@
+/* Definition for thread-local data handling. NPTL/ARM version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _TLS_H
+#define _TLS_H 1
+
+#include <dl-sysdep.h>
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+
+/* We require TLS support in the tools. */
+#ifndef HAVE_TLS_SUPPORT
+# error "TLS support is required."
+#endif
+
+/* Signal that TLS support is available. */
+# define USE_TLS 1
+
+#ifndef __ASSEMBLER__
+
+/* Get system call information. */
+# include <sysdep.h>
+
+/* The TP points to the start of the thread blocks. */
+# define TLS_DTV_AT_TP 1
+
+/* Get the thread descriptor definition. */
+# include <nptl/descr.h>
+
+typedef struct
+{
+ dtv_t *dtv;
+ void *private;
+} tcbhead_t;
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN 16
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN 16
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(tcbp, dtvp) \
+ (((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1)
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtv) \
+ (THREAD_DTV() = (dtv))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(tcbp) \
+ (((tcbhead_t *) (tcbp))->dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(tcbp, secondcall) \
+ ({ INTERNAL_SYSCALL_DECL (err); \
+ long result_var; \
+ result_var = INTERNAL_SYSCALL_ARM (set_tls, err, 1, (tcbp)); \
+ INTERNAL_SYSCALL_ERROR_P (result_var, err) \
+ ? "unknown error" : NULL; })
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *) __builtin_thread_pointer ())->dtv)
+
+/* Return the thread descriptor for the current thread. */
+# define THREAD_SELF \
+ ((struct pthread *)__builtin_thread_pointer () - 1)
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF \
+ CONST_THREAD_AREA (32, sizeof (struct pthread))
+
+/* Access to data in the thread descriptor is easy. */
+#define THREAD_GETMEM(descr, member) \
+ descr->member
+#define THREAD_GETMEM_NC(descr, member, idx) \
+ descr->member[idx]
+#define THREAD_SETMEM(descr, member, value) \
+ descr->member = (value)
+#define THREAD_SETMEM_NC(descr, member, idx, value) \
+ descr->member[idx] = (value)
+
+/* Initializing the thread pointer will generate a SIGILL if the syscall
+ is not available. */
+#define TLS_INIT_TP_EXPENSIVE 1
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/ports/sysdeps/arm/preconfigure b/ports/sysdeps/arm/preconfigure
new file mode 100644
index 000000000..337e84f16
--- /dev/null
+++ b/ports/sysdeps/arm/preconfigure
@@ -0,0 +1,13 @@
+case "$machine" in
+arm*)
+ base_machine=arm
+ case $config_os in
+ linux-gnueabi)
+ machine=arm/eabi/$machine
+ ;;
+ *)
+ machine=arm/$machine
+ ;;
+ esac
+ ;;
+esac
diff --git a/ports/sysdeps/arm/setjmp.S b/ports/sysdeps/arm/setjmp.S
new file mode 100644
index 000000000..2e8c6940f
--- /dev/null
+++ b/ports/sysdeps/arm/setjmp.S
@@ -0,0 +1,31 @@
+/* setjmp for ARM.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+
+ENTRY (__sigsetjmp)
+ /* Save registers */
+ stmia r0, {v1-v6, sl, fp, sp, lr}
+
+ /* Make a tail call to __sigjmp_save; it takes the same args. */
+ B PLTJMP(C_SYMBOL_NAME(__sigjmp_save))
+END (__sigsetjmp)
diff --git a/ports/sysdeps/arm/shlib-versions b/ports/sysdeps/arm/shlib-versions
new file mode 100644
index 000000000..ed6603f07
--- /dev/null
+++ b/ports/sysdeps/arm/shlib-versions
@@ -0,0 +1,4 @@
+arm.*-.*-linux-gnueabi DEFAULT GLIBC_2.4
+
+arm.*-.*-linux-gnueabi ld=ld-linux.so.3
+arm.*-.*-linux.* ld=ld-linux.so.2
diff --git a/ports/sysdeps/arm/stackinfo.h b/ports/sysdeps/arm/stackinfo.h
new file mode 100644
index 000000000..2410ba9bd
--- /dev/null
+++ b/ports/sysdeps/arm/stackinfo.h
@@ -0,0 +1,28 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file contains a bit of information about the stack allocation
+ of the processor. */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+/* On Arm the stack grows down. */
+#define _STACK_GROWS_DOWN 1
+
+#endif /* stackinfo.h */
diff --git a/ports/sysdeps/arm/strlen.S b/ports/sysdeps/arm/strlen.S
new file mode 100644
index 000000000..86e16652e
--- /dev/null
+++ b/ports/sysdeps/arm/strlen.S
@@ -0,0 +1,73 @@
+/* Copyright (C) 1998, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Code contributed by Matthew Wilcox <willy@odie.barnet.ac.uk>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+/* size_t strlen(const char *S)
+ * entry: r0 -> string
+ * exit: r0 = len
+ */
+
+ENTRY(strlen)
+ bic r1, r0, $3 @ addr of word containing first byte
+ ldr r2, [r1], $4 @ get the first word
+ ands r3, r0, $3 @ how many bytes are duff?
+ rsb r0, r3, $0 @ get - that number into counter.
+ beq Laligned @ skip into main check routine if no
+ @ more
+#ifdef __ARMEB__
+ orr r2, r2, $0xff000000 @ set this byte to non-zero
+ subs r3, r3, $1 @ any more to do?
+ orrgt r2, r2, $0x00ff0000 @ if so, set this byte
+ subs r3, r3, $1 @ more?
+ orrgt r2, r2, $0x0000ff00 @ then set.
+#else
+ orr r2, r2, $0x000000ff @ set this byte to non-zero
+ subs r3, r3, $1 @ any more to do?
+ orrgt r2, r2, $0x0000ff00 @ if so, set this byte
+ subs r3, r3, $1 @ more?
+ orrgt r2, r2, $0x00ff0000 @ then set.
+#endif
+Laligned: @ here, we have a word in r2. Does it
+ tst r2, $0x000000ff @ contain any zeroes?
+ tstne r2, $0x0000ff00 @
+ tstne r2, $0x00ff0000 @
+ tstne r2, $0xff000000 @
+ addne r0, r0, $4 @ if not, the string is 4 bytes longer
+ ldrne r2, [r1], $4 @ and we continue to the next word
+ bne Laligned @
+Llastword: @ drop through to here once we find a
+#ifdef __ARMEB__
+ tst r2, $0xff000000 @ word that has a zero byte in it
+ addne r0, r0, $1 @
+ tstne r2, $0x00ff0000 @ and add up to 3 bytes on to it
+ addne r0, r0, $1 @
+ tstne r2, $0x0000ff00 @ (if first three all non-zero, 4th
+ addne r0, r0, $1 @ must be zero)
+#else
+ tst r2, $0x000000ff @ word that has a zero byte in it
+ addne r0, r0, $1 @
+ tstne r2, $0x0000ff00 @ and add up to 3 bytes on to it
+ addne r0, r0, $1 @
+ tstne r2, $0x00ff0000 @ (if first three all non-zero, 4th
+ addne r0, r0, $1 @ must be zero)
+#endif
+ DO_RET(lr)
+END(strlen)
+libc_hidden_builtin_def (strlen)
diff --git a/ports/sysdeps/arm/sys/ucontext.h b/ports/sysdeps/arm/sys/ucontext.h
new file mode 100644
index 000000000..9c800bfa9
--- /dev/null
+++ b/ports/sysdeps/arm/sys/ucontext.h
@@ -0,0 +1,95 @@
+/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* System V/ARM ABI compliant context switching support. */
+
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <signal.h>
+
+typedef int greg_t;
+
+/* Number of general registers. */
+#define NGREG 16
+
+/* Container for all general registers. */
+typedef greg_t gregset_t[NGREG];
+
+/* Number of each register is the `gregset_t' array. */
+enum
+{
+ R0 = 0,
+#define R0 R0
+ R1 = 1,
+#define R1 R1
+ R2 = 2,
+#define R2 R2
+ R3 = 3,
+#define R3 R3
+ R4 = 4,
+#define R4 R4
+ R5 = 5,
+#define R5 R5
+ R6 = 6,
+#define R6 R6
+ R7 = 7,
+#define R7 R7
+ R8 = 8,
+#define R8 R8
+ R9 = 9,
+#define R9 R9
+ R10 = 10,
+#define R10 R10
+ R11 = 11,
+#define R11 R11
+ R12 = 12,
+#define R12 R12
+ R13 = 13,
+#define R13 R13
+ R14 = 14,
+#define R14 R14
+ R15 = 15,
+#define R15 R15
+};
+
+/* Structure to describe FPU registers. */
+typedef struct fpregset
+ {
+ } fpregset_t;
+
+/* Context to describe whole processor state. */
+typedef struct
+ {
+ gregset_t gregs;
+ fpregset_t fpregs;
+ } mcontext_t;
+
+/* Userlevel context. */
+typedef struct ucontext
+ {
+ unsigned long int uc_flags;
+ struct ucontext *uc_link;
+ __sigset_t uc_sigmask;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ long int uc_filler[5];
+ } ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/ports/sysdeps/arm/sysdep.h b/ports/sysdeps/arm/sysdep.h
new file mode 100644
index 000000000..8ca77a60c
--- /dev/null
+++ b/ports/sysdeps/arm/sysdep.h
@@ -0,0 +1,108 @@
+/* Assembler macros for ARM.
+ Copyright (C) 1997, 1998, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdeps/generic/sysdep.h>
+
+#if (!defined (__ARM_ARCH_2__) && !defined (__ARM_ARCH_3__) \
+ && !defined (__ARM_ARCH_3M__) && !defined (__ARM_ARCH_4__))
+# define __USE_BX__
+#endif
+
+#ifdef __ASSEMBLER__
+
+/* Syntactic details of assembler. */
+
+#ifdef HAVE_ELF
+
+#define ALIGNARG(log2) log2
+/* For ELF we need the `.type' directive to make shared libs work right. */
+#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,%##typearg;
+#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
+
+/* In ELF C symbols are asm symbols. */
+#undef NO_UNDERSCORES
+#define NO_UNDERSCORES
+
+#define PLTJMP(_x) _x##(PLT)
+
+#else
+
+#define ALIGNARG(log2) log2
+#define ASM_TYPE_DIRECTIVE(name,type) /* Nothing is specified. */
+#define ASM_SIZE_DIRECTIVE(name) /* Nothing is specified. */
+
+#define PLTJMP(_x) _x
+
+#endif
+
+/* APCS-32 doesn't preserve the condition codes across function call. */
+#ifdef __APCS_32__
+#define LOADREGS(cond, base, reglist...)\
+ ldm##cond base,reglist
+#ifdef __USE_BX__
+#define RETINSTR(cond, reg) \
+ bx##cond reg
+#define DO_RET(_reg) \
+ bx _reg
+#else
+#define RETINSTR(cond, reg) \
+ mov##cond pc, reg
+#define DO_RET(_reg) \
+ mov pc, _reg
+#endif
+#else /* APCS-26 */
+#define LOADREGS(cond, base, reglist...)\
+ ldm##cond base,reglist^
+#define RETINSTR(cond, reg) \
+ mov##cond##s pc, reg
+#define DO_RET(_reg) \
+ movs pc, _reg
+#endif
+
+/* Define an entry point visible from C. */
+#define ENTRY(name) \
+ ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),function) \
+ .align ALIGNARG(4); \
+ C_LABEL(name) \
+ CALL_MCOUNT
+
+#undef END
+#define END(name) \
+ ASM_SIZE_DIRECTIVE(name)
+
+/* If compiled for profiling, call `mcount' at the start of each function. */
+#ifdef PROF
+#define CALL_MCOUNT \
+ str lr,[sp, #-4]! ; \
+ bl PLTJMP(mcount) ; \
+ ldr lr, [sp], #4 ;
+#else
+#define CALL_MCOUNT /* Do nothing. */
+#endif
+
+#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
+#define mcount _mcount
+#endif
+
+#endif /* __ASSEMBLER__ */
diff --git a/ports/sysdeps/arm/tls-macros.h b/ports/sysdeps/arm/tls-macros.h
new file mode 100644
index 000000000..94aa3a83b
--- /dev/null
+++ b/ports/sysdeps/arm/tls-macros.h
@@ -0,0 +1,51 @@
+#define TLS_LE(x) \
+ ({ int *__result; \
+ void *tp = __builtin_thread_pointer (); \
+ asm ("ldr %0, 1f; " \
+ "add %0, %1, %0; " \
+ "b 2f; " \
+ "1: .word " #x "(tpoff); " \
+ "2: " \
+ : "=&r" (__result) : "r" (tp)); \
+ __result; })
+
+#define TLS_IE(x) \
+ ({ int *__result; \
+ void *tp = __builtin_thread_pointer (); \
+ asm ("ldr %0, 1f; " \
+ "3: ldr %0, [pc, %0];" \
+ "add %0, %1, %0; " \
+ "b 2f; " \
+ "1: .word " #x "(gottpoff) + (. - 3b - 8); " \
+ "2: " \
+ : "=&r" (__result) : "r" (tp)); \
+ __result; })
+
+#define TLS_LD(x) \
+ ({ char *__result; \
+ int __offset; \
+ extern void *__tls_get_addr (void *); \
+ asm ("ldr %0, 2f; " \
+ "1: add %0, pc, %0; " \
+ "b 3f; " \
+ "2: .word " #x "(tlsldm) + (. - 1b - 8); " \
+ "3: " \
+ : "=r" (__result)); \
+ __result = (char *)__tls_get_addr (__result); \
+ asm ("ldr %0, 1f; " \
+ "b 2f; " \
+ "1: .word " #x "(tlsldo); " \
+ "2: " \
+ : "=r" (__offset)); \
+ (int *) (__result + __offset); })
+
+#define TLS_GD(x) \
+ ({ int *__result; \
+ extern void *__tls_get_addr (void *); \
+ asm ("ldr %0, 2f; " \
+ "1: add %0, pc, %0; " \
+ "b 3f; " \
+ "2: .word " #x "(tlsgd) + (. - 1b - 8); " \
+ "3: " \
+ : "=r" (__result)); \
+ (int *)__tls_get_addr (__result); })
diff --git a/ports/sysdeps/arm/tst-audit.h b/ports/sysdeps/arm/tst-audit.h
new file mode 100644
index 000000000..bec743cff
--- /dev/null
+++ b/ports/sysdeps/arm/tst-audit.h
@@ -0,0 +1,26 @@
+/* Definitions for testing PLT entry/exit auditing. ARM version.
+
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define pltenter la_arm_gnu_pltenter
+#define pltexit la_arm_gnu_pltexit
+#define La_regs La_arm_regs
+#define La_retval La_arm_retval
+#define int_retval lrv_reg[0]
diff --git a/ports/sysdeps/arm/unwind-dw2-fde-glibc.c b/ports/sysdeps/arm/unwind-dw2-fde-glibc.c
new file mode 100644
index 000000000..6c0d7350d
--- /dev/null
+++ b/ports/sysdeps/arm/unwind-dw2-fde-glibc.c
@@ -0,0 +1,80 @@
+/* Dummy exception handling and frame unwind runtime interface routines.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* ARM uses setjmp-longjmp exceptions. However, previous versions of
+ GNU libc exported some DWARF-2 exception handling support routines.
+ They are not necessary, but older (or broken) configurations of GCC
+ will do so. Even though all references to these are weak, because
+ they refer to versioned symbols, they must be provided. */
+
+#include <stdlib.h>
+#include <unwind.h>
+#include <unwind-dw2-fde.h>
+
+/* These may be called from startup code, but don't need to do
+ anything. */
+
+void __register_frame_info_bases (void *a1, struct object *a2,
+ void *a3, void *a4)
+{
+}
+
+void __register_frame_info (void *a1, struct object *a2)
+{
+}
+
+void __register_frame (void *a1)
+{
+}
+
+void __register_frame_info_table_bases (void *a1, struct object *a2,
+ void *a3, void *a4)
+{
+}
+
+void __register_frame_info_table (void *a1, struct object *a2)
+{
+}
+
+void __register_frame_table (void *a1)
+{
+}
+
+void *__deregister_frame_info (void *a1)
+{
+ return NULL;
+}
+
+void *__deregister_frame_info_bases (void *a1)
+{
+ return NULL;
+}
+
+void __deregister_frame (void *a1)
+{
+}
+
+/* This should not be called. */
+
+fde *
+_Unwind_Find_FDE (void *a1, struct dwarf_eh_bases *a2)
+{
+ abort ();
+}
diff --git a/ports/sysdeps/arm/unwind-pe.c b/ports/sysdeps/arm/unwind-pe.c
new file mode 100644
index 000000000..710cecca9
--- /dev/null
+++ b/ports/sysdeps/arm/unwind-pe.c
@@ -0,0 +1 @@
+/* Empty */
diff --git a/ports/sysdeps/cris/Implies b/ports/sysdeps/cris/Implies
new file mode 100644
index 000000000..780c4e246
--- /dev/null
+++ b/ports/sysdeps/cris/Implies
@@ -0,0 +1,3 @@
+wordsize-32
+ieee754/flt-32
+ieee754/dbl-64
diff --git a/ports/sysdeps/cris/Makefile b/ports/sysdeps/cris/Makefile
new file mode 100644
index 000000000..1ecb78c3e
--- /dev/null
+++ b/ports/sysdeps/cris/Makefile
@@ -0,0 +1,44 @@
+# Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+# We don't support long doubles as a distinct type. We don't need to set
+# this variable; it's here mostly for documentational purposes.
+
+long-double-fcts = no
+
+# FIXME: Note that this is a machine-specific stub; profiling is not
+# implemented.
+ifeq ($(subdir),gmon)
+sysdep_routines += _mcount
+endif
+
+# FIXME: This test seems generally bogus. Wrong types in function calls
+# and assumes FE_TONEAREST is defined. Does it work somewhere?
+# Presumably it does, so let's settle for filtering it out target-wise
+# until it's agreed what should be done.
+ifeq ($(subdir),math)
+tests := $(filter-out test-fenv, $(tests))
+endif
+
+# PIC code must be assembled with special options, passed on by gcc when
+# given the -fpic option.
+ASFLAGS-.os = -fpic
+
+# Overflow occurs at 2**15/4 (8192) symbols. Glibc uses about 2000.
+# So use -fpic: smaller-size relocs; smaller, faster code.
+pic-ccflag = -fpic
diff --git a/ports/sysdeps/cris/__longjmp.S b/ports/sysdeps/cris/__longjmp.S
new file mode 100644
index 000000000..cce27ca25
--- /dev/null
+++ b/ports/sysdeps/cris/__longjmp.S
@@ -0,0 +1,38 @@
+/* longjmp for CRIS.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+
+ .syntax no_register_prefix
+
+/* Saving and restoring CCR is meaningless, so we don't do it. */
+ENTRY (__longjmp)
+ /* Note that r10 = jmp_buf, r11 = retval. */
+ move [r10+16*4],srp
+ test.d r11
+ beq 0f /* Already a 1 in place. */
+ nop
+ /* Offset for r9, the return value (see setjmp). */
+ move.d r11,[r10+6*4]
+0:
+ movem [r10],pc
+END (__longjmp)
diff --git a/ports/sysdeps/cris/_mcount.S b/ports/sysdeps/cris/_mcount.S
new file mode 100644
index 000000000..a93913164
--- /dev/null
+++ b/ports/sysdeps/cris/_mcount.S
@@ -0,0 +1,36 @@
+/* Machine-specific calling sequence for `mcount' profiling function for CRIS.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* FIXME: This isn't implemented yet. This is just a machine-specific
+ stub. Perhaps a real implementation can make use of it. */
+
+#include <sysdep.h>
+
+#undef CALL_MCOUNT
+#define CALL_MCOUNT
+
+ENTRY (_mcount)
+ SETUP_PIC
+ /* Sorry, isn't implemented yet.
+ Can't call abort; that will recurse. Force SEGV instead. */
+ test.d [99]
+1:
+ ba 1b
+ nop
+END (_mcount)
diff --git a/ports/sysdeps/cris/bits/endian.h b/ports/sysdeps/cris/bits/endian.h
new file mode 100644
index 000000000..034307e39
--- /dev/null
+++ b/ports/sysdeps/cris/bits/endian.h
@@ -0,0 +1,7 @@
+/* CRIS is little-endian. */
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#define __BYTE_ORDER __LITTLE_ENDIAN
diff --git a/ports/sysdeps/cris/bits/setjmp.h b/ports/sysdeps/cris/bits/setjmp.h
new file mode 100644
index 000000000..fa62a85de
--- /dev/null
+++ b/ports/sysdeps/cris/bits/setjmp.h
@@ -0,0 +1,54 @@
+/* Copyright (C) 1997, 1998, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Define the machine-dependent type `jmp_buf', CRIS version. */
+
+/* Note that saving and restoring CCR has no meaning in user mode, so we
+ don't actually do it; the slot is now reserved.
+
+ jmp_buf[0] - PC
+ jmp_buf[1] - SP (R14)
+ jmp_buf[2] - R13
+ jmp_buf[3] - R12
+ jmp_buf[4] - R11
+ jmp_buf[5] - R10
+ jmp_buf[6] - R9
+ jmp_buf[7] - R8
+ jmp_buf[8] - R7
+ jmp_buf[9] - R6
+ jmp_buf[10] - R5
+ jmp_buf[11] - R4
+ jmp_buf[12] - R3
+ jmp_buf[13] - R2
+ jmp_buf[14] - R1
+ jmp_buf[15] - R0
+ jmp_buf[16] - SRP
+ jmp_buf[17] - CCR */
+
+#ifndef _ASM
+typedef unsigned long int __jmp_buf[18];
+#endif
+
+#if defined (__USE_MISC) || defined (_ASM)
+#define JB_SP 1
+#endif
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
+ ((unsigned long int) (address) < demangle ((jmpbuf)[JB_SP]))
diff --git a/ports/sysdeps/cris/bits/string.h b/ports/sysdeps/cris/bits/string.h
new file mode 100644
index 000000000..fa893d365
--- /dev/null
+++ b/ports/sysdeps/cris/bits/string.h
@@ -0,0 +1,26 @@
+/* Optimized, inlined string functions. CRIS version.
+ Copyright (C) 1997, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _STRING_H
+# error "Never use <bits/string.h> directly; include <string.h> instead."
+#endif
+
+/* Currently the only purpose of this file is to tell the generic inline
+ macros that unaligned memory access is possible. */
+#define _STRING_ARCH_unaligned 1
diff --git a/ports/sysdeps/cris/configure b/ports/sysdeps/cris/configure
new file mode 100755
index 000000000..205bbac85
--- /dev/null
+++ b/ports/sysdeps/cris/configure
@@ -0,0 +1,7 @@
+# This file is generated from configure.in by Autoconf. DO NOT EDIT!
+
+libc_cv_asm_line_sep='@'
+cat >>confdefs.h <<_ACEOF
+#define ASM_LINE_SEP $libc_cv_asm_line_sep
+_ACEOF
+
diff --git a/ports/sysdeps/cris/configure.in b/ports/sysdeps/cris/configure.in
new file mode 100644
index 000000000..94bc13750
--- /dev/null
+++ b/ports/sysdeps/cris/configure.in
@@ -0,0 +1,5 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+
+dnl CRIS uses `;' to start comments and `@' for line separator.
+libc_cv_asm_line_sep='@'
+AC_DEFINE_UNQUOTED(ASM_LINE_SEP, $libc_cv_asm_line_sep)
diff --git a/ports/sysdeps/cris/dl-machine.h b/ports/sysdeps/cris/dl-machine.h
new file mode 100644
index 000000000..368733e73
--- /dev/null
+++ b/ports/sysdeps/cris/dl-machine.h
@@ -0,0 +1,391 @@
+/* Machine-dependent ELF dynamic relocation inline functions. CRIS version.
+ Copyright (C) 1996-2001, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef dl_machine_h
+#define dl_machine_h
+
+#define ELF_MACHINE_NAME "CRIS"
+
+#include <sys/param.h>
+
+#ifdef __PIC__
+# define CALL_FN(x) \
+ "move.d $pc,$r9\n\t" \
+ "add.d " #x " - .,$r9\n\t" \
+ "jsr $r9"
+#else
+# define CALL_FN(x) "jsr " #x
+#endif
+
+/* Return nonzero iff ELF header is compatible with the running host. */
+
+static inline int
+elf_machine_matches_host (const Elf32_Ehdr *ehdr)
+{
+ return ehdr->e_machine == EM_CRIS;
+}
+
+/* Return the link-time address of _DYNAMIC. Conveniently, this is the
+ first element of the GOT. This must be inlined in a function which
+ uses global data. */
+
+static inline Elf32_Addr
+elf_machine_dynamic (void)
+{
+ /* Don't just set this to an asm variable "r0" since that's not logical
+ (like, the variable is uninitialized and the register is fixed) and
+ may make GCC trip over itself doing register allocation. Yes, I'm
+ paranoid. Why do you ask? */
+ Elf32_Addr *got;
+
+ __asm__ ("move.d $r0,%0" : "=rm" (got));
+ return *got;
+}
+
+/* Return the run-time load address of the shared object. We do it like
+ m68k and i386, by taking an arbitrary local symbol, forcing a GOT entry
+ for it, and peeking into the GOT table, which is set to the link-time
+ file-relative symbol value (regardless of whether the target is REL or
+ RELA). We subtract this link-time file-relative value from the "local"
+ value we calculate from GOT position and GOT offset. FIXME: Perhaps
+ there's some other symbol we could use, that we don't *have* to force a
+ GOT entry for. */
+
+static inline Elf32_Addr
+elf_machine_load_address (void)
+{
+ Elf32_Addr gotaddr_diff;
+ __asm__ ("sub.d [$r0+_dl_start:GOT16],$r0,%0\n\t"
+ "add.d _dl_start:GOTOFF,%0" : "=r" (gotaddr_diff));
+ return gotaddr_diff;
+}
+
+/* Set up the loaded object described by L so its unrelocated PLT
+ entries will jump to the on-demand fixup code in dl-runtime.c. */
+
+static inline int
+elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
+{
+ Elf32_Addr *got;
+ extern void _dl_runtime_resolve (Elf32_Word);
+ extern void _dl_runtime_profile (Elf32_Word);
+
+ if (l->l_info[DT_JMPREL] && lazy)
+ {
+ /* The GOT entries for functions in the PLT have not yet been
+ filled in. Their initial contents will arrange when called
+ to push an offset into the .rela.plt section, push
+ _GLOBAL_OFFSET_TABLE_[1], and then jump to
+ _GLOBAL_OFFSET_TABLE_[2]. */
+ got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]);
+ got[1] = (Elf32_Addr) l; /* Identify this shared object. */
+
+ /* The got[2] entry contains the address of a function which gets
+ called to get the address of a so far unresolved function and
+ jump to it. The profiling extension of the dynamic linker allows
+ to intercept the calls to collect information. In this case we
+ don't store the address in the GOT so that all future calls also
+ end in this function. */
+ if (__builtin_expect (profile, 0))
+ {
+ got[2] = (Elf32_Addr) &_dl_runtime_profile;
+
+ if (_dl_name_match_p (GL(dl_profile), l))
+ {
+ /* This is the object we are looking for. Say that we really
+ want profiling and the timers are started. */
+ GL(dl_profile_map) = l;
+ }
+ }
+ else
+ /* This function will get called to fix up the GOT entry indicated by
+ the offset on the stack, and then jump to the resolved address. */
+ got[2] = (Elf32_Addr) &_dl_runtime_resolve;
+ }
+
+ return lazy;
+}
+
+/* This code is used in dl-runtime.c to call the `fixup' function
+ and then redirect to the address it returns.
+
+ We get here with the offset into the relocation table pushed on stack,
+ and the link map in MOF. */
+
+#define TRAMPOLINE_TEMPLATE(tramp_name, fixup_name) \
+"; Trampoline for " #fixup_name "\n\
+ .globl " #tramp_name "\n\
+ .type " #tramp_name ", @function\n\
+" #tramp_name ":\n\
+ push $r13\n\
+ push $r12\n\
+ push $r11\n\
+ push $r10\n\
+ push $r9\n\
+ push $srp\n\
+ move.d [$sp+6*4],$r11\n\
+ move $mof,$r10\n\
+ " CALL_FN (fixup_name) "\n\
+ move.d $r10,[$sp+6*4]\n\
+ pop $srp\n\
+ pop $r9\n\
+ pop $r10\n\
+ pop $r11\n\
+ pop $r12\n\
+ pop $r13\n\
+ jump [$sp+]\n\
+ .size " #tramp_name ", . - " #tramp_name "\n"
+#ifndef PROF
+#define ELF_MACHINE_RUNTIME_TRAMPOLINE \
+asm (TRAMPOLINE_TEMPLATE (_dl_runtime_resolve, fixup) \
+ TRAMPOLINE_TEMPLATE (_dl_runtime_profile, profile_fixup));
+#else
+#define ELF_MACHINE_RUNTIME_TRAMPOLINE \
+asm (TRAMPOLINE_TEMPLATE (_dl_runtime_resolve, fixup) \
+ ".globl _dl_runtime_profile\n" \
+ ".set _dl_runtime_profile, _dl_runtime_resolve");
+#endif
+
+
+/* Mask identifying addresses reserved for the user program,
+ where the dynamic linker should not map anything. */
+#define ELF_MACHINE_USER_ADDRESS_MASK 0xf8000000UL
+
+/* Initial entry point code for the dynamic linker.
+ The C function `_dl_start' is the real entry point;
+ its return value is the user program's entry point. */
+
+#define RTLD_START asm ("\
+ .text\n\
+ .globl _start\n\
+ .type _start,@function\n\
+_start:\n\
+ move.d $sp,$r10\n\
+ " CALL_FN (_dl_start) "\n\
+ /* FALLTHRU */\n\
+\n\
+ .globl _dl_start_user\n\
+ .type _dl_start_user,@function\n\
+_dl_start_user:\n\
+ ; Save the user entry point address in R1.\n\
+ move.d $r10,$r1\n\
+ ; Point R0 at the GOT.\n\
+ move.d $pc,$r0\n\
+ sub.d .:GOTOFF,$r0\n\
+ ; See if we were run as a command with the executable file\n\
+ ; name as an extra leading argument.\n\
+ move.d [$r0+_dl_skip_args:GOT16],$r13\n\
+ move.d [$r13],$r9\n\
+ ; Get the original argument count\n\
+ move.d [$sp],$r11\n\
+ ; Subtract _dl_skip_args from it.\n\
+ sub.d $r9,$r11\n\
+ ; Adjust the stack pointer to skip _dl_skip_args words.\n\
+ addi $r9.d,$sp\n\
+ ; Put the new argc in place as expected by the user entry.\n\
+ move.d $r11,[$sp]\n\
+ ; Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\
+ ; env: skip scaled argc and skip stored argc and NULL at end of argv[].\n\
+ move.d $sp,$r13\n\
+ addi $r11.d,$r13\n\
+ addq 8,$r13\n\
+ ; argv: skip stored argc.\n\
+ move.d $sp,$r12\n\
+ addq 4,$r12\n\
+ ; main_map: at _dl_loaded.\n\
+ move.d [$r0+_rtld_local:GOT16],$r9\n\
+ move.d [$r9],$r10\n\
+ move.d _dl_init_internal:PLTG,$r9\n\
+ add.d $r0,$r9\n\
+ jsr $r9\n\
+ ; Pass our finalizer function to the user in R10.\n\
+ move.d [$r0+_dl_fini:GOT16],$r10\n\
+ ; Terminate the frame-pointer.\n\
+ moveq 0,$r8\n\
+ ; Cause SEGV if user entry returns.\n\
+ move $r8,$srp\n\
+ ; Jump to the user's entry point.\n\
+ jump $r1\n\
+ .size _dl_start_user, . - _dl_start_user\n\
+ .previous");
+
+/* The union of reloc-type-classes where the reloc TYPE is a member.
+
+ TYPE is in the class ELF_RTYPE_CLASS_PLT if it can describe a
+ relocation for a PLT entry, that is, for which a PLT entry should not
+ be allowed to define the value. The GNU linker for CRIS can merge a
+ .got.plt entry (R_CRIS_JUMP_SLOT) with a .got entry (R_CRIS_GLOB_DAT),
+ so we need to match both these reloc types.
+
+ TYPE is in the class ELF_RTYPE_CLASS_NOCOPY if it should not be allowed
+ to resolve to one of the main executable's symbols, as for a COPY
+ reloc. */
+#define elf_machine_type_class(type) \
+ ((((((type) == R_CRIS_JUMP_SLOT)) \
+ || ((type) == R_CRIS_GLOB_DAT)) * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_CRIS_COPY) * ELF_RTYPE_CLASS_COPY))
+
+/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
+#define ELF_MACHINE_JMP_SLOT R_CRIS_JUMP_SLOT
+
+/* CRIS never uses Elf32_Rel relocations. */
+#define ELF_MACHINE_NO_REL 1
+
+/* We define an initialization functions. This is called very early in
+ _dl_sysdep_start. */
+#define DL_PLATFORM_INIT dl_platform_init ()
+
+static inline void __attribute__ ((unused))
+dl_platform_init (void)
+{
+ if (GL(dl_platform) != NULL && *GL(dl_platform) == '\0')
+ /* Avoid an empty string which would disturb us. */
+ GL(dl_platform) = NULL;
+}
+
+static inline Elf32_Addr
+elf_machine_fixup_plt (struct link_map *map, lookup_t t,
+ const Elf32_Rela *reloc,
+ Elf32_Addr *reloc_addr, Elf32_Addr value)
+{
+ return *reloc_addr = value;
+}
+
+/* Return the final value of a plt relocation. */
+static inline Elf32_Addr
+elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
+ Elf32_Addr value)
+{
+ return value + reloc->r_addend;
+}
+
+#endif /* !dl_machine_h */
+
+#ifdef RESOLVE
+
+/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
+ MAP is the object containing the reloc. */
+
+static inline void
+elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
+ const Elf32_Sym *sym, const struct r_found_version *version,
+ void *const reloc_addr_arg)
+{
+ Elf32_Addr *const reloc_addr = reloc_addr_arg;
+ const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
+
+ if (__builtin_expect (r_type == R_CRIS_RELATIVE, 0))
+ *reloc_addr = map->l_addr + reloc->r_addend;
+ else
+ {
+#ifndef RTLD_BOOTSTRAP
+ const Elf32_Sym *const refsym = sym;
+#endif
+ Elf32_Addr value;
+ if (sym->st_shndx != SHN_UNDEF
+ && ELF32_ST_BIND (sym->st_info) == STB_LOCAL)
+ value = map->l_addr;
+ else
+ {
+ value = RESOLVE (&sym, version, r_type);
+ if (sym)
+ value += sym->st_value;
+ }
+ value += reloc->r_addend; /* Assume copy relocs have zero addend. */
+
+ switch (r_type)
+ {
+#ifndef RTLD_BOOTSTRAP
+ case R_CRIS_COPY:
+ if (sym == NULL)
+ /* This can happen in trace mode if an object could not be
+ found. */
+ break;
+ if (sym->st_size > refsym->st_size
+ || (GL(dl_verbose) && sym->st_size < refsym->st_size))
+ {
+ const char *strtab;
+
+ strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
+ _dl_error_printf ("\
+%s: Symbol `%s' has different size in shared object, consider re-linking\n",
+ rtld_progname ?: "<program name unknown>",
+ strtab + refsym->st_name);
+ }
+ memcpy (reloc_addr_arg, (void *) value,
+ MIN (sym->st_size, refsym->st_size));
+ break;
+
+ case R_CRIS_32:
+#endif
+ case R_CRIS_GLOB_DAT:
+ case R_CRIS_JUMP_SLOT:
+ *reloc_addr = value;
+ break;
+#ifndef RTLD_BOOTSTRAP
+ case R_CRIS_8:
+ *(char *) reloc_addr = value;
+ break;
+ case R_CRIS_16:
+ *(short *) reloc_addr = value;
+ break;
+ case R_CRIS_8_PCREL:
+ *(char *) reloc_addr
+ = value + reloc->r_addend - (Elf32_Addr) reloc_addr - 1;
+ break;
+ case R_CRIS_16_PCREL:
+ *(short *) reloc_addr
+ = value + reloc->r_addend - (Elf32_Addr) reloc_addr - 2;
+ break;
+ case R_CRIS_32_PCREL:
+ *reloc_addr = value + reloc->r_addend - (Elf32_Addr) reloc_addr - 4;
+ break;
+#endif
+ case R_CRIS_NONE:
+ break;
+#if !defined RTLD_BOOTSTRAP || defined _NDEBUG
+ default:
+ _dl_reloc_bad_type (map, r_type, 0);
+ break;
+#endif
+ }
+ }
+}
+
+static inline void
+elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
+ void *const reloc_addr_arg)
+{
+ Elf32_Addr *const reloc_addr = reloc_addr_arg;
+ *reloc_addr = l_addr + reloc->r_addend;
+}
+
+static inline void
+elf_machine_lazy_rel (struct link_map *map,
+ Elf32_Addr l_addr, const Elf32_Rela *reloc)
+{
+ Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
+ const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
+ if (__builtin_expect (r_type == R_CRIS_JUMP_SLOT, 1))
+ *reloc_addr += l_addr;
+ else
+ _dl_reloc_bad_type (map, r_type, 1);
+}
+
+#endif /* RESOLVE */
diff --git a/ports/sysdeps/cris/elf/start.S b/ports/sysdeps/cris/elf/start.S
new file mode 100644
index 000000000..a3f85bcd0
--- /dev/null
+++ b/ports/sysdeps/cris/elf/start.S
@@ -0,0 +1,141 @@
+/* Startup code compliant to the ELF CRIS ABI (to-be-written).
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+/* This is the canonical entry point, usually the first thing in the text
+ segment. When the entry point runs, most registers' values are
+ unspecified, except for:
+
+ R10 Contains a function pointer to be registered with `atexit'.
+ This is how the dynamic linker arranges to have DT_FINI
+ functions called for shared libraries that have been loaded
+ before this code runs.
+
+ SP The stack contains the arguments and environment:
+ [SP] argc
+ [SP+4] argv[0]
+ ...
+ [SP+4*argc] NULL
+ [SP+4*(argc+1)] envp[0]
+ ...
+ NULL
+*/
+
+ .syntax no_register_prefix
+
+ .text
+ .globl _start
+ .type _start,@function
+_start:
+ /* Clear the frame pointer, to mark the outermost frame. */
+ moveq 0,r8
+
+ /* Move the shared library termination function to the right place
+ for __libc_main. */
+ move.d r10,r9
+
+ /* Extract the arguments as encoded on the stack and set up the
+ arguments for `main': argc, argv. envp will be determined
+ later in __libc_start_main. */
+
+ /* Get the argument count. */
+ move.d [sp],r11
+
+ /* Store the stack pointer as end of stack. We overwrite
+ the incoming argc. */
+ move.d sp,[sp]
+
+ /* The argument vector starts just after the argument count. */
+ move.d sp,r12
+ addq 4,r12
+
+ /* There are seven arguments to __libc_start_main:
+ r10: main - Address of it.
+ r11: argc
+ r12: argv
+ r13: init - Function to call.
+
+ [sp]: fini - Function to register with atexit.
+ [sp+4]: rtld_fini - Another function to register with atexit.
+ [sp+8]: stack_end - Top of stack (actually same as argv).
+
+ The last two are passed on stack. */
+
+ /* Store the fini function coming from the dynamic loader. */
+ push r9
+
+ /* Get the addresses of our own entry points to `.fini' and
+ `.init'. */
+
+#ifdef __PIC__
+ /* If for some reason this program is compiled as PIC, set up R0. */
+ move.d pc,r0
+ sub.d .:GOTOFF,r0
+
+ move.d __libc_csu_init:PLTG,r13
+ add.d r0,r13
+ move.d __libc_csu_fini:PLTG,r9
+ add.d r0,r9
+ move.d main:PLTG,r10
+ add.d r0,r10
+#else
+ move.d __libc_csu_init,r13
+ move.d __libc_csu_fini,r9
+ move.d main,r10
+#endif
+ push r9
+
+ /* Call the user's main function, and exit with its value. But
+ let the libc call main. */
+ PLTCALL (__libc_start_main)
+
+ /* Crash if somehow `exit' does return. We have at least 8192
+ invalid addresses to choose from. */
+ test.d [6502]
+
+ /* Stop the unstoppable. */
+0:
+ ba 0b
+ nop
+
+/* Define a symbol for the first piece of initialized data. */
+ .data
+ .globl __data_start
+__data_start:
+ .long 0
+ .weak data_start
+ data_start = __data_start
diff --git a/ports/sysdeps/cris/machine-gmon.h b/ports/sysdeps/cris/machine-gmon.h
new file mode 100644
index 000000000..2f36a34d6
--- /dev/null
+++ b/ports/sysdeps/cris/machine-gmon.h
@@ -0,0 +1,28 @@
+/* PowerPC-specific implementation of profiling support.
+ Copyright (C) 1997, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+void __mcount_internal (unsigned long frompc, unsigned long selfpc);
+
+#define _MCOUNT_DECL(frompc, selfpc) \
+void __mcount_internal (unsigned long frompc, unsigned long selfpc)
+
+
+/* Define MCOUNT as empty since we have the implementation in another
+ file. FIXME: Just stubs, currently. */
+#define MCOUNT
diff --git a/ports/sysdeps/cris/memcopy.h b/ports/sysdeps/cris/memcopy.h
new file mode 100644
index 000000000..134d36121
--- /dev/null
+++ b/ports/sysdeps/cris/memcopy.h
@@ -0,0 +1,57 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdeps/generic/memcopy.h>
+
+/* We override the word-copying macros, partly because misalignment in one
+ pointer isn't cause for a special function, partly because we want to
+ get rid of wordcopy.c; these macros are only used in memmove.c (and
+ it's sibling bcopy) since we have arch-specific mempcpy, memcpy and
+ memset. */
+
+#undef OP_T_THRES
+#define OP_T_THRES OPSIZ
+
+#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
+ do \
+ { \
+ unsigned long enddst_bp = dst_bp + nbytes - (nbytes % OPSIZ); \
+ nbytes_left = (nbytes % OPSIZ); \
+ while (dst_bp < (unsigned long) enddst_bp) \
+ { \
+ op_t x = *(op_t *) src_bp; \
+ src_bp += sizeof x; \
+ *(op_t *) dst_bp = x; \
+ dst_bp += sizeof x; \
+ } \
+ } while (0)
+
+#define WORD_COPY_BWD(dst_bp, src_bp, nbytes_left, nbytes) \
+ do \
+ { \
+ unsigned long enddst_bp = dst_bp - nbytes + (nbytes % OPSIZ); \
+ nbytes_left = (nbytes % OPSIZ); \
+ while (dst_bp > enddst_bp) \
+ { \
+ op_t x; \
+ src_bp -= sizeof x; \
+ x = *(op_t *) src_bp; \
+ dst_bp -= sizeof x; \
+ *(op_t *) dst_bp = x; \
+ } \
+ } while (0)
diff --git a/ports/sysdeps/cris/memusage.h b/ports/sysdeps/cris/memusage.h
new file mode 100644
index 000000000..58b57ff37
--- /dev/null
+++ b/ports/sysdeps/cris/memusage.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* No asm variables, just for reasons of solid healthy paranoia. */
+#define GETSP() \
+ ({ \
+ uintptr_t stack_ptr; \
+ __asm__ ("move.d $sp,%0" : "=rm" (stack_ptr)); \
+ stack_ptr; \
+ })
+
+#include <sysdeps/generic/memusage.h>
diff --git a/ports/sysdeps/cris/setjmp.S b/ports/sysdeps/cris/setjmp.S
new file mode 100644
index 000000000..c5a512f49
--- /dev/null
+++ b/ports/sysdeps/cris/setjmp.S
@@ -0,0 +1,66 @@
+/* setjmp for CRIS.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+
+ .syntax no_register_prefix
+
+ENTRY (__sigsetjmp)
+.Local__sigsetjmp:
+ moveq 1,r9
+ movem sp,[r10+1*4]
+#ifdef __PIC__
+ move.d pc,r9
+ addq 0f-.,r9
+#else
+ move.d 0f,r9
+#endif
+ move.d r9,[r10]
+ move srp,[r10+16*4]
+ move ccr,[r10+17*4]
+ PLTJUMP (__sigjmp_save)
+0: /* This is where longjmp returns. (Don't use "ret" - it's a macro. */
+ Ret
+ move.d r9,r10
+END (__sigsetjmp)
+
+/* Binary compatibility entry points. Having these in separate files
+ is not meaningful and just adds library overhead. */
+
+ENTRY (__setjmp)
+ ba .Local__sigsetjmp
+ moveq 0,r11
+END (__setjmp)
+
+ENTRY (_setjmp)
+ ba .Local__sigsetjmp
+ moveq 0,r11
+END (_setjmp)
+
+ENTRY (setjmp)
+ ba .Local__sigsetjmp
+ moveq 1,r11
+END (setjmp)
+
+weak_extern (__setjmp)
+weak_extern (_setjmp)
+weak_extern (setjmp)
diff --git a/ports/sysdeps/cris/stackinfo.h b/ports/sysdeps/cris/stackinfo.h
new file mode 100644
index 000000000..43c944834
--- /dev/null
+++ b/ports/sysdeps/cris/stackinfo.h
@@ -0,0 +1,28 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file contains a bit of information about the stack allocation
+ of the processor. */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+/* On cris the stack grows down. */
+#define _STACK_GROWS_DOWN 1
+
+#endif /* stackinfo.h */
diff --git a/ports/sysdeps/cris/sysdep.h b/ports/sysdeps/cris/sysdep.h
new file mode 100644
index 000000000..913d5ad9b
--- /dev/null
+++ b/ports/sysdeps/cris/sysdep.h
@@ -0,0 +1,114 @@
+/* Assembler macros for CRIS.
+ Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdeps/generic/sysdep.h>
+
+#ifndef HAVE_ELF
+# error ELF is assumed. Generalize the code and retry.
+#endif
+
+#ifndef NO_UNDERSCORES
+# error User-label prefix (underscore) assumed absent. Generalize the code and retry.
+#endif
+
+#ifdef __ASSEMBLER__
+
+/* Syntactic details of assembly-code. */
+
+/* It is *not* generally true that "ELF uses byte-counts for .align, most
+ others use log2 of count of bytes", like some neighboring configs say.
+ See "align" in gas/read.c which is not overridden by
+ gas/config/obj-elf.c. It takes a log2 argument. *Some* targets
+ override it to take a byte argument. People should read source instead
+ of relying on hearsay. */
+# define ALIGNARG(log2) log2
+
+# define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg
+# define ASM_SIZE_DIRECTIVE(name) .size name,.-name
+
+/* The non-PIC jump is preferred, since it does not stall, and does not
+ invoke generation of a PLT. These macros assume that $r0 is set up as
+ GOT register. */
+# ifdef __PIC__
+# define PLTJUMP(_x) \
+ add.d C_SYMBOL_NAME (_x):PLT,$pc
+
+# define PLTCALL(_x) \
+ move.d C_SYMBOL_NAME (_x):PLTG,$r9 @ \
+ add.d $r0,$r9 @ \
+ jsr $r9
+
+# define SETUP_PIC \
+ push $r0 @ \
+ move.d $pc,$r0 @ \
+ sub.d .:GOTOFF,$r0
+
+# define TEARDOWN_PIC pop $r0
+# else
+# define PLTJUMP(_x) jump C_SYMBOL_NAME (_x)
+# define PLTCALL(_x) jsr C_SYMBOL_NAME (_x)
+# define SETUP_PIC
+# define TEARDOWN_PIC
+# endif
+
+/* Define an entry point visible from C. */
+# define ENTRY(name) \
+ .text @ \
+ ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (name) @ \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME (name), function) @ \
+ .align ALIGNARG (2) @ \
+ C_LABEL(name) @ \
+ CALL_MCOUNT
+
+# undef END
+# define END(name) \
+ ASM_SIZE_DIRECTIVE (C_SYMBOL_NAME (name))
+
+/* If compiled for profiling, call `mcount' at the start of each function.
+ FIXME: Note that profiling is not actually implemented. This is just
+ example code which might not even compile, though it is believed to be
+ correct. */
+# ifdef PROF
+# define CALL_MCOUNT \
+ push $srp @ \
+ push $r9 @ \
+ push $r10 @ \
+ push $r11 @ \
+ push $r12 @ \
+ push $r13 @ \
+ SETUP_PIC @ \
+ PLTCALL (mcount) @ \
+ TEARDOWN_PIC @ \
+ pop $r13 @ \
+ pop $r12 @ \
+ pop $r11 @ \
+ pop $r10 @ \
+ pop $r9 @ \
+ pop $srp
+# else
+# define CALL_MCOUNT /* Do nothing. */
+# endif
+
+/* 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
+# define mcount _mcount
+
+#endif /* __ASSEMBLER__ */
diff --git a/ports/sysdeps/cris/wordcopy.c b/ports/sysdeps/cris/wordcopy.c
new file mode 100644
index 000000000..6525e9f03
--- /dev/null
+++ b/ports/sysdeps/cris/wordcopy.c
@@ -0,0 +1 @@
+/* Empty; not needed. */
diff --git a/ports/sysdeps/hppa/Makefile b/ports/sysdeps/hppa/Makefile
new file mode 100644
index 000000000..73947031d
--- /dev/null
+++ b/ports/sysdeps/hppa/Makefile
@@ -0,0 +1,41 @@
+# Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by David Huggins-Daines (dhd@debian.org)
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+# We used to need this since the build process uses ld -r. Now we use
+# ld -r --unique=.text* which does more or less the same thing, but better.
+# CFLAGS-.os += -ffunction-sections
+LDFLAGS-c_pic.os += -Wl,--unique=.text*
+
+ifeq ($(subdir),elf)
+CFLAGS-rtld.c += -mdisable-fpregs
+sysdep-dl-routines += dl-symaddr dl-fptr
+sysdep_routines += $(sysdep-dl-routines)
+sysdep-rtld-routines += $(sysdep-dl-routines)
+endif
+
+ifeq ($(subdir),csu)
+ifeq (yes,$(build-shared))
+# Compatibility
+ifeq (yes,$(have-protected))
+CPPFLAGS-libgcc-compat.c = -DHAVE_DOT_HIDDEN
+endif
+sysdep_routines += libgcc-compat
+shared-only-routines += libgcc-compat
+endif
+endif
diff --git a/ports/sysdeps/hppa/Versions b/ports/sysdeps/hppa/Versions
new file mode 100644
index 000000000..2ae3cbdf1
--- /dev/null
+++ b/ports/sysdeps/hppa/Versions
@@ -0,0 +1,12 @@
+ld {
+ GLIBC_PRIVATE {
+ # hppa specific functions in the dynamic linker, but used by libc.so.
+ _dl_symbol_address; _dl_unmap; _dl_lookup_address;
+ _dl_function_address;
+ }
+}
+libc {
+ GLIBC_2.2 {
+ __clz_tab;
+ }
+}
diff --git a/ports/sysdeps/hppa/__longjmp.S b/ports/sysdeps/hppa/__longjmp.S
new file mode 100644
index 000000000..dee4d9f7b
--- /dev/null
+++ b/ports/sysdeps/hppa/__longjmp.S
@@ -0,0 +1,72 @@
+/* longjmp for PA-RISC.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+
+/* __longjmp(jmpbuf, val) */
+
+ .text
+ .align 4
+ .globl __longjmp
+ .export __longjmp, code
+ .proc
+ .callinfo
+__longjmp:
+ /* set return value */
+ copy %r25, %r28
+
+ ldw 0(%r26), %r3
+ ldw 8(%r26), %r4
+ ldw 12(%r26), %r5
+ ldw 16(%r26), %r6
+ ldw 20(%r26), %r7
+ ldw 24(%r26), %r8
+ ldw 28(%r26), %r9
+ ldw 32(%r26), %r10
+ ldw 36(%r26), %r11
+ ldw 40(%r26), %r12
+ ldw 44(%r26), %r13
+ ldw 48(%r26), %r14
+ ldw 52(%r26), %r15
+ ldw 56(%r26), %r16
+ ldw 60(%r26), %r17
+ ldw 64(%r26), %r18
+ ldw 68(%r26), %r19
+ ldw 72(%r26), %r27
+ ldw 76(%r26), %r30
+
+ ldw 80(%r26), %rp
+
+ ldo 88(%r26),%r20
+ fldds,ma 8(%r20), %fr12
+ fldds,ma 8(%r20), %fr13
+ fldds,ma 8(%r20), %fr14
+ fldds,ma 8(%r20), %fr15
+ fldds,ma 8(%r20), %fr16
+ fldds,ma 8(%r20), %fr17
+ fldds,ma 8(%r20), %fr18
+ fldds,ma 8(%r20), %fr19
+ fldds,ma 8(%r20), %fr20
+ fldds 0(%r20), %fr21
+
+ bv,n %r0(%r2)
+ .procend
diff --git a/ports/sysdeps/hppa/abort-instr.h b/ports/sysdeps/hppa/abort-instr.h
new file mode 100644
index 000000000..c13b0e5a4
--- /dev/null
+++ b/ports/sysdeps/hppa/abort-instr.h
@@ -0,0 +1,6 @@
+/* An instruction privileged instruction to crash a userspace program.
+
+ We go with iitlbp because it has a history of being used to crash
+ programs. */
+
+#define ABORT_INSTRUCTION asm ("iitlbp %r0,(%sr0, %r0)")
diff --git a/ports/sysdeps/hppa/add_n.s b/ports/sysdeps/hppa/add_n.s
new file mode 100644
index 000000000..a396b3471
--- /dev/null
+++ b/ports/sysdeps/hppa/add_n.s
@@ -0,0 +1,58 @@
+;! HP-PA __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 Lesser General Public License as published by
+;! the Free Software Foundation; either version 2.1 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 Lesser General Public
+;! License for more details.
+
+;! You should have received a copy of the GNU Lesser General Public License
+;! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+;! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+;! MA 02111-1307, USA.
+
+
+;! INPUT PARAMETERS
+;! res_ptr gr26
+;! s1_ptr gr25
+;! s2_ptr gr24
+;! size gr23
+
+;! One might want to unroll this as for other processors, but it turns
+;! out that the data cache contention after a store makes such
+;! unrolling useless. We can't come under 5 cycles/limb anyway.
+
+ .text
+ .export __mpn_add_n
+__mpn_add_n:
+ .proc
+ .callinfo frame=0,no_calls
+ .entry
+
+ ldws,ma 4(%r25),%r21
+ ldws,ma 4(%r24),%r20
+
+ addib,= -1,%r23,L$end ;! check for (SIZE == 1)
+ add %r21,%r20,%r28 ;! add first limbs ignoring cy
+
+L$loop: ldws,ma 4(%r25),%r21
+ ldws,ma 4(%r24),%r20
+ stws,ma %r28,4(%r26)
+ addib,<> -1,%r23,L$loop
+ addc %r21,%r20,%r28
+
+L$end: stws %r28,0(%r26)
+ bv 0(%r2)
+ addc %r0,%r0,%r28
+
+ .exit
+ .procend
diff --git a/ports/sysdeps/hppa/bits/endian.h b/ports/sysdeps/hppa/bits/endian.h
new file mode 100644
index 000000000..585db0c0f
--- /dev/null
+++ b/ports/sysdeps/hppa/bits/endian.h
@@ -0,0 +1,7 @@
+/* hppa1.1 big-endian. */
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#define __BYTE_ORDER __BIG_ENDIAN
diff --git a/ports/sysdeps/hppa/bits/link.h b/ports/sysdeps/hppa/bits/link.h
new file mode 100644
index 000000000..2c1c81de4
--- /dev/null
+++ b/ports/sysdeps/hppa/bits/link.h
@@ -0,0 +1,57 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _LINK_H
+# error "Never include <bits/link.h> directly; use <link.h> instead."
+#endif
+
+/* Registers for entry into PLT on hppa. */
+typedef struct La_hppa_regs
+{
+ uint32_t lr_reg[4];
+ double lr_fpreg[4];
+ uint32_t lr_sp;
+ uint32_t lr_ra;
+} La_hppa_regs;
+
+/* Return values for calls from PLT on hppa. */
+typedef struct La_hppa_retval
+{
+ uint32_t lrv_r28;
+ uint32_t lrv_r29;
+ double lr_fr4;
+} La_hppa_retval;
+
+
+__BEGIN_DECLS
+
+extern Elf32_Addr la_hppa_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ La_hppa_regs *__regs,
+ unsigned int *__flags,
+ const char *__symname,
+ long int *__framesizep);
+extern unsigned int la_hppa_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ const La_hppa_regs *__inregs,
+ La_hppa_retval *__outregs,
+ const char *symname);
+
+__END_DECLS
diff --git a/ports/sysdeps/hppa/bits/linkmap.h b/ports/sysdeps/hppa/bits/linkmap.h
new file mode 100644
index 000000000..54842b229
--- /dev/null
+++ b/ports/sysdeps/hppa/bits/linkmap.h
@@ -0,0 +1,6 @@
+/* Used to store the function descriptor table */
+struct link_map_machine
+ {
+ size_t fptr_table_len;
+ ElfW(Addr) *fptr_table;
+ };
diff --git a/ports/sysdeps/hppa/bits/setjmp.h b/ports/sysdeps/hppa/bits/setjmp.h
new file mode 100644
index 000000000..d5ae7e7b5
--- /dev/null
+++ b/ports/sysdeps/hppa/bits/setjmp.h
@@ -0,0 +1,36 @@
+/* Copyright (C) 2000, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Define the machine-dependent type `jmp_buf'. HPPA version. */
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H 1
+
+#if !defined _SETJMP_H && !defined _PTHREAD_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+/* The previous bits/setjmp.h had __jmp_buf defined as a structure.
+ We use an array of 'double' instead, to make writing the assembler
+ easier, and to ensure proper alignment. Naturally, user code should
+ not depend on either representation. */
+
+#ifndef _ASM
+typedef double __jmp_buf[21];
+#endif
+
+#endif /* bits/setjmp.h */
diff --git a/ports/sysdeps/hppa/bsd-_setjmp.S b/ports/sysdeps/hppa/bsd-_setjmp.S
new file mode 100644
index 000000000..e5ec94c12
--- /dev/null
+++ b/ports/sysdeps/hppa/bsd-_setjmp.S
@@ -0,0 +1,39 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. HPPA version.
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+/* 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. */
+
+ .text
+ .align 4
+ .globl _setjmp
+ .export _setjmp, code
+ .level 2.0
+ .proc
+ .callinfo
+ .import __sigsetjmp
+_setjmp:
+ b __sigsetjmp
+ ldi 0, %r25
+
+ .procend
+libc_hidden_def (_setjmp)
diff --git a/ports/sysdeps/hppa/bsd-setjmp.S b/ports/sysdeps/hppa/bsd-setjmp.S
new file mode 100644
index 000000000..04ddba465
--- /dev/null
+++ b/ports/sysdeps/hppa/bsd-setjmp.S
@@ -0,0 +1,36 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. HPPA version.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
+ We cannot do it in C because it must be a tail-call, so frame-unwinding
+ in setjmp doesn't clobber the state restored by longjmp. */
+
+ .text
+ .align 4
+ .globl setjmp
+ .export setjmp, code
+ .level 2.0
+ .proc
+ .callinfo
+ .import __sigsetjmp
+setjmp:
+ b __sigsetjmp
+ ldi 1, %r25
+
+ .procend
diff --git a/ports/sysdeps/hppa/configure b/ports/sysdeps/hppa/configure
new file mode 100644
index 000000000..bc01e46b6
--- /dev/null
+++ b/ports/sysdeps/hppa/configure
@@ -0,0 +1,33 @@
+# This file is generated from configure.in by Autoconf. DO NOT EDIT!
+
+echo "$as_me:$LINENO: checking for assembler line separator" >&5
+echo $ECHO_N "checking for assembler line separator... $ECHO_C" >&6
+if test "${libc_cv_asm_line_sep+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat > conftest.s <<EOF
+nop ; is_old_puffin
+EOF
+if { ac_try='${CC-cc} -c $ASFLAGS conftest.s 1>&5'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ libc_cv_asm_line_sep='!'
+else
+ if test -z "$enable_hacker_mode"; then
+ echo "*** You need a newer assembler to compile glibc"
+ rm -f conftest*
+ exit 1
+ fi
+ libc_cv_asm_line_sep=';'
+fi
+rm -f conftest*
+fi
+echo "$as_me:$LINENO: result: $libc_cv_asm_line_sep" >&5
+echo "${ECHO_T}$libc_cv_asm_line_sep" >&6
+cat >>confdefs.h <<_ACEOF
+#define ASM_LINE_SEP $libc_cv_asm_line_sep
+_ACEOF
+
diff --git a/ports/sysdeps/hppa/configure.in b/ports/sysdeps/hppa/configure.in
new file mode 100644
index 000000000..1ec417b94
--- /dev/null
+++ b/ports/sysdeps/hppa/configure.in
@@ -0,0 +1,21 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+
+dnl The standard hppa assembler uses `;' to start comments and `!'
+dnl as a line separator.
+AC_CACHE_CHECK(for assembler line separator,
+ libc_cv_asm_line_sep, [dnl
+cat > conftest.s <<EOF
+nop ; is_old_puffin
+EOF
+if AC_TRY_COMMAND(${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
+ libc_cv_asm_line_sep='!'
+else
+ if test -z "$enable_hacker_mode"; then
+ echo "*** You need a newer assembler to compile glibc"
+ rm -f conftest*
+ exit 1
+ fi
+ libc_cv_asm_line_sep=';'
+fi
+rm -f conftest*])
+AC_DEFINE_UNQUOTED(ASM_LINE_SEP, $libc_cv_asm_line_sep)
diff --git a/ports/sysdeps/hppa/dl-fptr.h b/ports/sysdeps/hppa/dl-fptr.h
new file mode 100644
index 000000000..2ac9740e3
--- /dev/null
+++ b/ports/sysdeps/hppa/dl-fptr.h
@@ -0,0 +1,35 @@
+/* Function descriptors. HPPA version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef dl_hppa_fptr_h
+#define dl_hppa_fptr_h 1
+
+#include <sysdeps/generic/dl-fptr.h>
+
+/* There are currently 20 dynamic symbols in ld.so.
+ ELF_MACHINE_BOOT_FPTR_TABLE_LEN needs to be at least that big. */
+#define ELF_MACHINE_BOOT_FPTR_TABLE_LEN 200
+
+#define ELF_MACHINE_LOAD_ADDRESS(var, symbol) \
+ asm (" addil LT%%" #symbol ", %%r19\n" \
+ " ldw RT%%" #symbol "(%%sr0,%%r1), %0\n" \
+ : "=&r" (var));
+
+
+#endif /* !dl_hppa_fptr_h */
diff --git a/ports/sysdeps/hppa/dl-lookupcfg.h b/ports/sysdeps/hppa/dl-lookupcfg.h
new file mode 100644
index 000000000..89a2d2274
--- /dev/null
+++ b/ports/sysdeps/hppa/dl-lookupcfg.h
@@ -0,0 +1,80 @@
+/* Configuration of lookup functions.
+ Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define ELF_FUNCTION_PTR_IS_SPECIAL
+#define DL_UNMAP_IS_SPECIAL
+
+#include <dl-fptr.h>
+
+/* Forward declaration. */
+struct link_map;
+
+void *_dl_symbol_address (struct link_map *map, const ElfW(Sym) *ref);
+
+#define DL_SYMBOL_ADDRESS(map, ref) _dl_symbol_address(map, ref)
+
+Elf32_Addr _dl_lookup_address (const void *address);
+
+/* Clear the bottom two bits so generic code can find the fdesc entry */
+#define DL_LOOKUP_ADDRESS(addr) \
+ (_dl_lookup_address ((void *)((unsigned long)addr & ~3)))
+
+void _dl_unmap (struct link_map *map);
+
+#define DL_UNMAP(map) _dl_unmap (map)
+
+#define DL_AUTO_FUNCTION_ADDRESS(map, addr) \
+({ \
+ unsigned int fptr[2]; \
+ fptr[0] = (unsigned int) (addr); \
+ fptr[1] = (map)->l_info[DT_PLTGOT]->d_un.d_ptr; \
+ /* Set bit 30 to indicate to $$dyncall that this is a PLABEL. */ \
+ (ElfW(Addr))((unsigned int)fptr | 2); \
+})
+
+#define DL_STATIC_FUNCTION_ADDRESS(map, addr) \
+({ \
+ static unsigned int fptr[2]; \
+ fptr[0] = (unsigned int) (addr); \
+ fptr[1] = (map)->l_info[DT_PLTGOT]->d_un.d_ptr; \
+ /* Set bit 30 to indicate to $$dyncall that this is a PLABEL. */ \
+ (ElfW(Addr))((unsigned int)fptr | 2); \
+})
+
+
+/* The test for "addr & 2" below is to accomodate old binaries which
+ violated the ELF ABI by pointing DT_INIT and DT_FINI at a function
+ descriptor. */
+#define DL_DT_INIT_ADDRESS(map, addr) \
+ ((Elf32_Addr)(addr) & 2 ? (addr) : DL_AUTO_FUNCTION_ADDRESS (map, addr))
+#define DL_DT_FINI_ADDRESS(map, addr) \
+ ((Elf32_Addr)(addr) & 2 ? (addr) : DL_AUTO_FUNCTION_ADDRESS (map, addr))
+
+/* The type of the return value of fixup/profile_fixup */
+#define DL_FIXUP_VALUE_TYPE struct fdesc
+
+/* Construct a fixup value from the address and linkmap */
+#define DL_FIXUP_MAKE_VALUE(map, addr) \
+ ((struct fdesc) { (addr), (map)->l_info[DT_PLTGOT]->d_un.d_ptr })
+
+/* Extract the code address from a fixup value */
+#define DL_FIXUP_VALUE_CODE_ADDR(value) ((value).ip)
+#define DL_FIXUP_VALUE_ADDR(value) ((uintptr_t) &(value))
+#define DL_FIXUP_ADDR_VALUE(addr) (*(struct fdesc *) (addr))
+
diff --git a/ports/sysdeps/hppa/dl-machine.h b/ports/sysdeps/hppa/dl-machine.h
new file mode 100644
index 000000000..dd5a28190
--- /dev/null
+++ b/ports/sysdeps/hppa/dl-machine.h
@@ -0,0 +1,782 @@
+/* Machine-dependent ELF dynamic relocation inline functions. PA-RISC version.
+ Copyright (C) 1995-1997,1999-2003
+ Free Software Foundation, Inc.
+ Contributed by David Huggins-Daines <dhd@debian.org>
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef dl_machine_h
+#define dl_machine_h 1
+
+#define ELF_MACHINE_NAME "hppa"
+
+#include <sys/param.h>
+#include <assert.h>
+#include <string.h>
+#include <link.h>
+#include <errno.h>
+#include <dl-fptr.h>
+#include <abort-instr.h>
+#include <tls.h>
+
+# define VALID_ELF_OSABI(osabi) ((osabi == ELFOSABI_SYSV) || (osabi == ELFOSABI_LINUX))
+# define VALID_ELF_ABIVERSION(ver) (ver == 0)
+# define VALID_ELF_HEADER(hdr,exp,size) \
+ memcmp (hdr,exp,size-2) == 0 \
+ && VALID_ELF_OSABI (hdr[EI_OSABI]) \
+ && VALID_ELF_ABIVERSION (hdr[EI_ABIVERSION])
+
+/* These two definitions must match the definition of the stub in
+ bfd/elf32-hppa.c (see plt_stub[]).
+
+ a. Define the size of the *entire* stub we place at the end of the PLT
+ table (right up against the GOT).
+
+ b. Define the number of bytes back from the GOT to the entry point of
+ the PLT stub. You see the PLT stub must be entered in the middle
+ so it can depwi to find it's own address (long jump stub)
+
+ c. Define the size of a single PLT entry so we can jump over the
+ last entry to get the stub address */
+
+#define SIZEOF_PLT_STUB (7*4)
+#define GOT_FROM_PLT_STUB (4*4)
+#define PLT_ENTRY_SIZE (2*4)
+
+/* Initialize the function descriptor table before relocations */
+static inline void
+__hppa_init_bootstrap_fdesc_table (struct link_map *map)
+{
+ ElfW(Addr) *boot_table;
+
+ /* Careful: this will be called before got has been relocated... */
+ ELF_MACHINE_LOAD_ADDRESS(boot_table,_dl_boot_fptr_table);
+
+ map->l_mach.fptr_table_len = ELF_MACHINE_BOOT_FPTR_TABLE_LEN;
+ map->l_mach.fptr_table = boot_table;
+}
+
+#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info) \
+ __hppa_init_bootstrap_fdesc_table (&bootstrap_map);
+
+/* Return nonzero iff ELF header is compatible with the running host. */
+static inline int
+elf_machine_matches_host (const Elf32_Ehdr *ehdr)
+{
+ return ehdr->e_machine == EM_PARISC;
+}
+
+/* Return the link-time address of _DYNAMIC. */
+static inline Elf32_Addr
+elf_machine_dynamic (void) __attribute__ ((const));
+
+static inline Elf32_Addr
+elf_machine_dynamic (void)
+{
+ Elf32_Addr dynamic;
+
+ asm ("b,l 1f,%0\n"
+" depi 0,31,2,%0\n"
+"1: addil L'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 8),%0\n"
+" ldw R'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 12)(%%r1),%0\n"
+ : "=r" (dynamic) : : "r1");
+
+ return dynamic;
+}
+
+/* Return the run-time load address of the shared object. */
+static inline Elf32_Addr
+elf_machine_load_address (void) __attribute__ ((const));
+
+static inline Elf32_Addr
+elf_machine_load_address (void)
+{
+ Elf32_Addr dynamic;
+
+ asm (
+" b,l 1f,%0\n"
+" depi 0,31,2,%0\n"
+"1: addil L'_DYNAMIC - ($PIC_pcrel$0 - 8),%0\n"
+" ldo R'_DYNAMIC - ($PIC_pcrel$0 - 12)(%%r1),%0\n"
+ : "=r" (dynamic) : : "r1");
+
+ return dynamic - elf_machine_dynamic ();
+}
+
+/* Fixup a PLT entry to bounce directly to the function at VALUE. */
+static inline struct fdesc __attribute__ ((always_inline))
+elf_machine_fixup_plt (struct link_map *map, lookup_t t,
+ const Elf32_Rela *reloc,
+ Elf32_Addr *reloc_addr, struct fdesc value)
+{
+ /* map is the link_map for the caller, t is the link_map for the object
+ being called */
+ reloc_addr[1] = value.gp;
+ /* Need to ensure that the gp is visible before the code
+ entry point is updated */
+ ((volatile Elf32_Addr *) reloc_addr)[0] = value.ip;
+ return value;
+}
+
+/* Return the final value of a plt relocation. */
+static inline struct fdesc
+elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
+ struct fdesc value)
+{
+ /* We are rela only, return a function descriptor as a plt entry. */
+ return (struct fdesc) { value.ip + reloc->r_addend, value.gp };
+}
+
+/* Set up the loaded object described by L so its unrelocated PLT
+ entries will jump to the on-demand fixup code in dl-runtime.c. */
+
+static inline int
+elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
+{
+ Elf32_Addr *got = NULL;
+ Elf32_Addr l_addr, iplt, jmprel, end_jmprel, r_type, r_sym;
+ const Elf32_Rela *reloc;
+ struct fdesc *fptr;
+ static union {
+ unsigned char c[8];
+ Elf32_Addr i[2];
+ } sig = {{0x00,0xc0,0xff,0xee, 0xde,0xad,0xbe,0xef}};
+
+ /* If we don't have a PLT we can just skip all this... */
+ if (__builtin_expect (l->l_info[DT_JMPREL] == NULL,0))
+ return lazy;
+
+ /* All paths use these values */
+ l_addr = l->l_addr;
+ jmprel = D_PTR(l, l_info[DT_JMPREL]);
+ end_jmprel = jmprel + l->l_info[DT_PLTRELSZ]->d_un.d_val;
+
+ extern void _dl_runtime_resolve (void);
+ extern void _dl_runtime_profile (void);
+
+ /* Linking lazily */
+ if (lazy)
+ {
+ /* FIXME: Search for the got, but backwards through the relocs, technically we should
+ find it on the first try. However, assuming the relocs got out of order the
+ routine is made a bit more robust by searching them all in case of failure. */
+ for (iplt = (end_jmprel - sizeof(Elf32_Rela)); iplt >= jmprel; iplt -= sizeof (Elf32_Rela))
+ {
+
+ reloc = (const Elf32_Rela *) iplt;
+ r_type = ELF32_R_TYPE (reloc->r_info);
+ r_sym = ELF32_R_SYM (reloc->r_info);
+
+ got = (Elf32_Addr *) (reloc->r_offset + l_addr + PLT_ENTRY_SIZE + SIZEOF_PLT_STUB);
+
+ /* If we aren't an IPLT, and we aren't NONE then it's a bad reloc */
+ if (__builtin_expect (r_type != R_PARISC_IPLT, 0))
+ {
+ if (__builtin_expect (r_type != R_PARISC_NONE, 0))
+ _dl_reloc_bad_type (l, r_type, 1);
+ continue;
+ }
+
+ /* Check for the plt_stub that binutils placed here for us
+ to use with _dl_runtime_resolve */
+ if (got[-2] != sig.i[0] || got[-1] != sig.i[1])
+ {
+ got = NULL; /* Not the stub... keep looking */
+ }
+ else
+ {
+ /* Found the GOT! */
+ register Elf32_Addr ltp __asm__ ("%r19");
+
+ /* Identify this shared object. Second entry in the got. */
+ got[1] = (Elf32_Addr) l;
+
+ /* This function will be called to perform the relocation. */
+ if (__builtin_expect (!profile, 1))
+ {
+ /* If a static application called us, then _dl_runtime_resolve is not
+ a function descriptor, but the *real* address of the function... */
+ if((unsigned long) &_dl_runtime_resolve & 3)
+ {
+ got[-2] = (Elf32_Addr) ((struct fdesc *)
+ ((unsigned long) &_dl_runtime_resolve & ~3))->ip;
+ }
+ else
+ {
+ /* Static executable! */
+ got[-2] = (Elf32_Addr) &_dl_runtime_resolve;
+ }
+ }
+ else
+ {
+ if (GLRO(dl_profile) != NULL
+ && _dl_name_match_p (GLRO(dl_profile), l))
+ {
+ /* This is the object we are looking for. Say that
+ we really want profiling and the timers are
+ started. */
+ GL(dl_profile_map) = l;
+ }
+
+ if((unsigned long) &_dl_runtime_resolve & 3)
+ {
+ got[-2] = (Elf32_Addr) ((struct fdesc *)
+ ((unsigned long) &_dl_runtime_profile & ~3))->ip;
+ }
+ else
+ {
+ /* Static executable */
+ got[-2] = (Elf32_Addr) &_dl_runtime_profile;
+ }
+ }
+ /* Plunk in the gp of this function descriptor so we
+ can make the call to _dl_runtime_xxxxxx */
+ got[-1] = ltp;
+ break;
+ /* Done looking for the GOT, and stub is setup */
+ } /* else we found the GOT */
+ } /* for, walk the relocs backwards */
+
+ if(!got)
+ return 0; /* No lazy linking for you! */
+
+ /* Process all the relocs, now that we know the GOT... */
+ for (iplt = jmprel; iplt < end_jmprel; iplt += sizeof (Elf32_Rela))
+ {
+ reloc = (const Elf32_Rela *) iplt;
+ r_type = ELF32_R_TYPE (reloc->r_info);
+ r_sym = ELF32_R_SYM (reloc->r_info);
+
+ if (__builtin_expect (r_type == R_PARISC_IPLT, 1))
+ {
+ fptr = (struct fdesc *) (reloc->r_offset + l_addr);
+ if (r_sym != 0)
+ {
+ /* Relocate the pointer to the stub. */
+ fptr->ip = (Elf32_Addr) got - GOT_FROM_PLT_STUB;
+
+ /* Instead of the LTP value, we put the reloc offset
+ here. The trampoline code will load the proper
+ LTP and pass the reloc offset to the fixup
+ function. */
+ fptr->gp = iplt - jmprel;
+ } /* r_sym != 0 */
+ else
+ {
+ /* Relocate this *ABS* entry. */
+ fptr->ip = reloc->r_addend + l_addr;
+ fptr->gp = D_PTR (l, l_info[DT_PLTGOT]);
+ }
+ } /* r_type == R_PARISC_IPLT */
+ } /* for all the relocations */
+ } /* if lazy */
+ else
+ {
+ for (iplt = jmprel; iplt < end_jmprel; iplt += sizeof (Elf32_Rela))
+ {
+ reloc = (const Elf32_Rela *) iplt;
+ r_type = ELF32_R_TYPE (reloc->r_info);
+ r_sym = ELF32_R_SYM (reloc->r_info);
+
+ if (__builtin_expect ((r_type == R_PARISC_IPLT) && (r_sym == 0), 1))
+ {
+ fptr = (struct fdesc *) (reloc->r_offset + l_addr);
+ /* Relocate this *ABS* entry, set only the gp, the rest is set later
+ when elf_machine_rela_relative is called (WITHOUT the linkmap) */
+ fptr->gp = D_PTR (l, l_info[DT_PLTGOT]);
+ } /* r_type == R_PARISC_IPLT */
+ } /* for all the relocations */
+ }
+ return lazy;
+}
+
+
+/* Names of the architecture-specific auditing callback functions. */
+#define ARCH_LA_PLTENTER hppa_gnu_pltenter
+#define ARCH_LA_PLTEXIT hppa_gnu_pltexit
+
+/* Initial entry point code for the dynamic linker.
+ The C function `_dl_start' is the real entry point;
+ its return value is the user program's entry point. */
+
+#define RTLD_START \
+/* Set up dp for any non-PIC lib constructors that may be called. */ \
+static struct link_map * __attribute__((used)) \
+set_dp (struct link_map *map) \
+{ \
+ register Elf32_Addr dp asm ("%r27"); \
+ dp = D_PTR (map, l_info[DT_PLTGOT]); \
+ asm volatile ("" : : "r" (dp)); \
+ return map; \
+} \
+ \
+asm ( \
+" .text\n" \
+" .globl _start\n" \
+" .type _start,@function\n" \
+"_start:\n" \
+ /* The kernel does not give us an initial stack frame. */ \
+" ldo 64(%sp),%sp\n" \
+ /* Save the relevant arguments (yes, those are the correct \
+ registers, the kernel is weird) in their stack slots. */ \
+" stw %r25,-40(%sp)\n" /* argc */ \
+" stw %r24,-44(%sp)\n" /* argv */ \
+ \
+ /* We need the LTP, and we need it now. \
+ $PIC_pcrel$0 points 8 bytes past the current instruction, \
+ just like a branch reloc. This sequence gets us the \
+ runtime address of _DYNAMIC. */ \
+" bl 0f,%r19\n" \
+" depi 0,31,2,%r19\n" /* clear priviledge bits */ \
+"0: addil L'_DYNAMIC - ($PIC_pcrel$0 - 8),%r19\n" \
+" ldo R'_DYNAMIC - ($PIC_pcrel$0 - 12)(%r1),%r26\n" \
+ \
+ /* The link time address is stored in the first entry of the \
+ GOT. */ \
+" addil L'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 16),%r19\n" \
+" ldw R'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 20)(%r1),%r20\n" \
+ \
+" sub %r26,%r20,%r20\n" /* Calculate load offset */ \
+ \
+ /* Rummage through the dynamic entries, looking for \
+ DT_PLTGOT. */ \
+" ldw,ma 8(%r26),%r19\n" \
+"1: cmpib,=,n 3,%r19,2f\n" /* tag == DT_PLTGOT? */ \
+" cmpib,<>,n 0,%r19,1b\n" \
+" ldw,ma 8(%r26),%r19\n" \
+ \
+ /* Uh oh! We didn't find one. Abort. */ \
+" iitlbp %r0,(%sr0,%r0)\n" \
+ \
+"2: ldw -4(%r26),%r19\n" /* Found it, load value. */ \
+" add %r19,%r20,%r19\n" /* And add the load offset. */ \
+ \
+ /* Our initial stack layout is rather different from everyone \
+ else's due to the unique PA-RISC ABI. As far as I know it \
+ looks like this: \
+ \
+ ----------------------------------- (this frame created above) \
+ | 32 bytes of magic | \
+ |---------------------------------| \
+ | 32 bytes argument/sp save area | \
+ |---------------------------------| ((current->mm->env_end) \
+ | N bytes of slack | + 63 & ~63) \
+ |---------------------------------| \
+ | envvar and arg strings | \
+ |---------------------------------| \
+ | ELF auxiliary info | \
+ | (up to 28 words) | \
+ |---------------------------------| \
+ | Environment variable pointers | \
+ | upwards to NULL | \
+ |---------------------------------| \
+ | Argument pointers | \
+ | upwards to NULL | \
+ |---------------------------------| \
+ | argc (1 word) | \
+ ----------------------------------- \
+ \
+ So, obviously, we can't just pass %sp to _dl_start. That's \
+ okay, argv-4 will do just fine. \
+ \
+ The pleasant part of this is that if we need to skip \
+ arguments we can just decrement argc and move argv, because \
+ the stack pointer is utterly unrelated to the location of \
+ the environment and argument vectors. */ \
+ \
+ /* This is always within range so we'll be okay. */ \
+" bl _dl_start,%rp\n" \
+" ldo -4(%r24),%r26\n" \
+ \
+" .globl _dl_start_user\n" \
+" .type _dl_start_user,@function\n" \
+"_dl_start_user:\n" \
+ /* Save the entry point in %r3. */ \
+" copy %ret0,%r3\n" \
+ \
+ /* Remember the lowest stack address. */ \
+" addil LT'__libc_stack_end,%r19\n" \
+" ldw RT'__libc_stack_end(%r1),%r20\n" \
+" stw %sp,0(%r20)\n" \
+ \
+ /* See if we were called as a command with the executable file \
+ name as an extra leading argument. */ \
+" addil LT'_dl_skip_args,%r19\n" \
+" ldw RT'_dl_skip_args(%r1),%r20\n" \
+" ldw 0(%r20),%r20\n" \
+ \
+" ldw -40(%sp),%r25\n" /* argc */ \
+" comib,= 0,%r20,.Lnofix\n" /* FIXME: Mispredicted branch */\
+" ldw -44(%sp),%r24\n" /* argv (delay slot) */ \
+ \
+" sub %r25,%r20,%r25\n" \
+" stw %r25,-40(%sp)\n" \
+" sh2add %r20,%r24,%r24\n" \
+" stw %r24,-44(%sp)\n" \
+ \
+".Lnofix:\n" \
+" addil LT'_rtld_local,%r19\n" \
+" ldw RT'_rtld_local(%r1),%r26\n" \
+" bl set_dp, %r2\n" \
+" ldw 0(%r26),%r26\n" \
+ \
+ /* Call _dl_init(_dl_loaded, argc, argv, envp). */ \
+" copy %r28,%r26\n" \
+ \
+ /* envp = argv + argc + 1 */ \
+" sh2add %r25,%r24,%r23\n" \
+" bl _dl_init_internal,%r2\n" \
+" ldo 4(%r23),%r23\n" /* delay slot */ \
+ \
+ /* Reload argc, argv to the registers start.S expects. */ \
+" ldw -40(%sp),%r25\n" \
+" ldw -44(%sp),%r24\n" \
+ \
+ /* _dl_fini does have a PLT slot now. I don't know how to get \
+ to it though, so this hack will remain. */ \
+" .section .data\n" \
+"__dl_fini_plabel:\n" \
+" .word _dl_fini\n" \
+" .word 0xdeadbeef\n" \
+" .previous\n" \
+ \
+ /* %r3 contains a function pointer, we need to mask out the \
+ lower bits and load the gp and jump address. */ \
+" depi 0,31,2,%r3\n" \
+" ldw 0(%r3),%r2\n" \
+" addil LT'__dl_fini_plabel,%r19\n" \
+" ldw RT'__dl_fini_plabel(%r1),%r23\n" \
+" stw %r19,4(%r23)\n" \
+" ldw 4(%r3),%r19\n" /* load the object's gp */ \
+" bv %r0(%r2)\n" \
+" depi 2,31,2,%r23\n" /* delay slot */ \
+);
+
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
+ a TLS variable, so references should not be allowed to define the value.
+ ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
+ of the main executable's symbols, as for a COPY reloc. */
+#if defined USE_TLS && (!defined RTLD_BOOTSTRAP || USE___THREAD)
+# define elf_machine_type_class(type) \
+ ((((type) == R_PARISC_IPLT \
+ || (type) == R_PARISC_EPLT \
+ || (type) == R_PARISC_TLS_DTPMOD32 \
+ || (type) == R_PARISC_TLS_DTPOFF32 \
+ || (type) == R_PARISC_TLS_TPREL32) \
+ * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_PARISC_COPY) * ELF_RTYPE_CLASS_COPY))
+#else
+#define elf_machine_type_class(type) \
+ ((((type) == R_PARISC_IPLT \
+ || (type) == R_PARISC_EPLT) \
+ * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_PARISC_COPY) * ELF_RTYPE_CLASS_COPY))
+#endif
+
+/* Used by the runtime in fixup to figure out if reloc is *really* PLT */
+#define ELF_MACHINE_JMP_SLOT R_PARISC_IPLT
+#define ELF_MACHINE_SIZEOF_JMP_SLOT PLT_ENTRY_SIZE
+
+/* We only use RELA. */
+#define ELF_MACHINE_NO_REL 1
+
+/* Return the address of the entry point. */
+#define ELF_MACHINE_START_ADDRESS(map, start) \
+ DL_STATIC_FUNCTION_ADDRESS (map, start)
+
+/* We define an initialization functions. This is called very early in
+ * _dl_sysdep_start. */
+#define DL_PLATFORM_INIT dl_platform_init ()
+
+static inline void __attribute__ ((unused))
+dl_platform_init (void)
+{
+ if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0')
+ /* Avoid an empty string which would disturb us. */
+ GLRO(dl_platform) = NULL;
+}
+
+#endif /* !dl_machine_h */
+
+/* These are only actually used where RESOLVE_MAP is defined, anyway. */
+#ifdef RESOLVE_MAP
+
+#define reassemble_21(as21) \
+ ( (((as21) & 0x100000) >> 20) \
+ | (((as21) & 0x0ffe00) >> 8) \
+ | (((as21) & 0x000180) << 7) \
+ | (((as21) & 0x00007c) << 14) \
+ | (((as21) & 0x000003) << 12))
+
+#define reassemble_14(as14) \
+ ( (((as14) & 0x1fff) << 1) \
+ | (((as14) & 0x2000) >> 13))
+
+auto void __attribute__((always_inline))
+elf_machine_rela (struct link_map *map,
+ const Elf32_Rela *reloc,
+ const Elf32_Sym *sym,
+ const struct r_found_version *version,
+ void *const reloc_addr_arg)
+{
+ Elf32_Addr *const reloc_addr = reloc_addr_arg;
+ const Elf32_Sym *const refsym = sym;
+ unsigned long const r_type = ELF32_R_TYPE (reloc->r_info);
+ struct link_map *sym_map;
+ Elf32_Addr value;
+
+# if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC && !defined SHARED
+ /* This is defined in rtld.c, but nowhere in the static libc.a; make the
+ reference weak so static programs can still link. This declaration
+ cannot be done when compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP)
+ because rtld.c contains the common defn for _dl_rtld_map, which is
+ incompatible with a weak decl in the same file. */
+ weak_extern (GL(dl_rtld_map));
+# endif
+
+ /* RESOLVE_MAP will return a null value for undefined syms, and
+ non-null for all other syms. In particular, relocs with no
+ symbol (symbol index of zero), also called *ABS* relocs, will be
+ resolved to MAP. (The first entry in a symbol table is all
+ zeros, and an all zero Elf32_Sym has a binding of STB_LOCAL.)
+ See RESOLVE_MAP definition in elf/dl-reloc.c */
+# ifdef RTLD_BOOTSTRAP
+ /* RESOLVE_MAP in rtld.c doesn't have the local sym test. */
+ sym_map = (ELF32_ST_BIND (sym->st_info) != STB_LOCAL
+ ? RESOLVE_MAP (&sym, version, r_type) : map);
+# else
+ sym_map = RESOLVE_MAP (&sym, version, r_type);
+# endif
+
+ if (sym_map)
+ {
+ value = sym ? sym_map->l_addr + sym->st_value : 0;
+ value += reloc->r_addend;
+ }
+ else
+ value = 0;
+
+ switch (r_type)
+ {
+ case R_PARISC_DIR32:
+ /* .eh_frame can have unaligned relocs. */
+ if ((unsigned long) reloc_addr_arg & 3)
+ {
+ char *rel_addr = (char *) reloc_addr_arg;
+ rel_addr[0] = value >> 24;
+ rel_addr[1] = value >> 16;
+ rel_addr[2] = value >> 8;
+ rel_addr[3] = value;
+ return;
+ }
+ break;
+
+ case R_PARISC_DIR21L:
+ {
+ unsigned int insn = *(unsigned int *)reloc_addr;
+ value = sym_map->l_addr + sym->st_value
+ + ((reloc->r_addend + 0x1000) & -0x2000);
+ value = value >> 11;
+ insn = (insn &~ 0x1fffff) | reassemble_21 (value);
+ *(unsigned int *)reloc_addr = insn;
+ }
+ return;
+
+ case R_PARISC_DIR14R:
+ {
+ unsigned int insn = *(unsigned int *)reloc_addr;
+ value = ((sym_map->l_addr + sym->st_value) & 0x7ff)
+ + (((reloc->r_addend & 0x1fff) ^ 0x1000) - 0x1000);
+ insn = (insn &~ 0x3fff) | reassemble_14 (value);
+ *(unsigned int *)reloc_addr = insn;
+ }
+ return;
+
+ case R_PARISC_PLABEL32:
+ /* Easy rule: If there is a symbol and it is global, then we
+ need to make a dynamic function descriptor. Otherwise we
+ have the address of a PLT slot for a local symbol which we
+ know to be unique. */
+ if (sym == NULL
+ || sym_map == NULL
+ || ELF32_ST_BIND (sym->st_info) == STB_LOCAL)
+ {
+ break;
+ }
+ /* Set bit 30 to indicate to $$dyncall that this is a PLABEL.
+ We have to do this outside of the generic function descriptor
+ code, since it doesn't know about our requirement for setting
+ protection bits */
+ value = (Elf32_Addr)((unsigned int)_dl_make_fptr (sym_map, sym, value) | 2);
+ break;
+
+ case R_PARISC_PLABEL21L:
+ case R_PARISC_PLABEL14R:
+ {
+ unsigned int insn = *(unsigned int *)reloc_addr;
+
+ if (__builtin_expect (sym == NULL, 0))
+ break;
+
+ value = (Elf32_Addr)((unsigned int)_dl_make_fptr (sym_map, sym, value) | 2);
+
+ if (r_type == R_PARISC_PLABEL21L)
+ {
+ value >>= 11;
+ insn = (insn &~ 0x1fffff) | reassemble_21 (value);
+ }
+ else
+ {
+ value &= 0x7ff;
+ insn = (insn &~ 0x3fff) | reassemble_14 (value);
+ }
+
+ *(unsigned int *)reloc_addr = insn;
+ }
+ return;
+
+ case R_PARISC_IPLT:
+ if (__builtin_expect (sym_map != NULL, 1))
+ {
+ elf_machine_fixup_plt (NULL, sym_map, reloc, reloc_addr,
+ DL_FIXUP_MAKE_VALUE(sym_map, value));
+ }
+ else
+ {
+ /* If we get here, it's a (weak) undefined sym. */
+ elf_machine_fixup_plt (NULL, map, reloc, reloc_addr,
+ DL_FIXUP_MAKE_VALUE(map, value));
+ }
+ return;
+
+ case R_PARISC_COPY:
+ if (__builtin_expect (sym == NULL, 0))
+ /* This can happen in trace mode if an object could not be
+ found. */
+ break;
+ if (__builtin_expect (sym->st_size > refsym->st_size, 0)
+ || (__builtin_expect (sym->st_size < refsym->st_size, 0)
+ && __builtin_expect (GLRO(dl_verbose), 0)))
+ {
+ const char *strtab;
+
+ strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
+ _dl_error_printf ("%s: Symbol `%s' has different size in shared object, "
+ "consider re-linking\n",
+ rtld_progname ?: "<program name unknown>",
+ strtab + refsym->st_name);
+ }
+ memcpy (reloc_addr_arg, (void *) value,
+ MIN (sym->st_size, refsym->st_size));
+ return;
+
+#if defined USE_TLS && (!defined RTLD_BOOTSTRAP)
+ case R_PARISC_TLS_DTPMOD32:
+ value = sym_map->l_tls_modid;
+ break;
+
+ case R_PARISC_TLS_DTPOFF32:
+ /* During relocation all TLS symbols are defined and used.
+ Therefore the offset is already correct. */
+ if (sym != NULL)
+ *reloc_addr = sym->st_value;
+ return;
+
+ case R_PARISC_TLS_TPREL32:
+ /* The offset is negative, forward from the thread pointer */
+ if (sym != NULL)
+ {
+ CHECK_STATIC_TLS (map, sym_map);
+ value = sym_map->l_tls_offset + sym->st_value + reloc->r_addend;
+ }
+ break;
+#endif /* use TLS */
+
+ case R_PARISC_NONE: /* Alright, Wilbur. */
+ return;
+
+ default:
+ _dl_reloc_bad_type (map, r_type, 0);
+ }
+
+ *reloc_addr = value;
+}
+
+/* hppa doesn't have an R_PARISC_RELATIVE reloc, but uses relocs with
+ ELF32_R_SYM (info) == 0 for a similar purpose. */
+auto void __attribute__((always_inline))
+elf_machine_rela_relative (Elf32_Addr l_addr,
+ const Elf32_Rela *reloc,
+ void *const reloc_addr_arg)
+{
+ unsigned long const r_type = ELF32_R_TYPE (reloc->r_info);
+ Elf32_Addr *const reloc_addr = reloc_addr_arg;
+ static char msgbuf[] = { "Unknown" };
+ struct link_map map;
+ Elf32_Addr value;
+
+ value = l_addr + reloc->r_addend;
+
+ if (ELF32_R_SYM (reloc->r_info) != 0){
+ _dl_error_printf ("%s: In elf_machine_rela_relative "
+ "ELF32_R_SYM (reloc->r_info) != 0. Aborting.",
+ rtld_progname ?: "<program name unknown>");
+ ABORT_INSTRUCTION; /* Crash. */
+ }
+
+ switch (r_type)
+ {
+ case R_PARISC_DIR32:
+ /* .eh_frame can have unaligned relocs. */
+ if ((unsigned long) reloc_addr_arg & 3)
+ {
+ char *rel_addr = (char *) reloc_addr_arg;
+ rel_addr[0] = value >> 24;
+ rel_addr[1] = value >> 16;
+ rel_addr[2] = value >> 8;
+ rel_addr[3] = value;
+ return;
+ }
+ break;
+
+ case R_PARISC_PLABEL32:
+ break;
+
+ case R_PARISC_IPLT: /* elf_machine_runtime_setup already set gp */
+ break;
+
+ case R_PARISC_NONE:
+ return;
+
+ default: /* Bad reloc, map unknown (really it's the current map) */
+ map.l_name = msgbuf;
+ _dl_reloc_bad_type (&map, r_type, 0);
+ return;
+ }
+
+ *reloc_addr = value;
+}
+
+auto void __attribute__((always_inline))
+elf_machine_lazy_rel (struct link_map *map,
+ Elf32_Addr l_addr, const Elf32_Rela *reloc)
+{
+ /* We don't have anything to do here. elf_machine_runtime_setup has
+ done all the relocs already. */
+}
+
+#endif /* RESOLVE_MAP */
diff --git a/ports/sysdeps/hppa/dl-symaddr.c b/ports/sysdeps/hppa/dl-symaddr.c
new file mode 100644
index 000000000..e5ce6a9c0
--- /dev/null
+++ b/ports/sysdeps/hppa/dl-symaddr.c
@@ -0,0 +1,36 @@
+/* Get the symbol address. HPPA version.
+ Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <ldsodefs.h>
+#include <dl-machine.h>
+
+void *
+_dl_symbol_address (struct link_map *map, const ElfW(Sym) *ref)
+{
+ /* Find the "ip" from the "map" and symbol "ref" */
+ Elf32_Addr value = (map ? map->l_addr : 0) + ref->st_value;
+
+ /* On hppa, we have to return the pointer to function descriptor.
+ This involves an "| 2" to inform $$dyncall that this is a plabel32 */
+ if (ELFW(ST_TYPE) (ref->st_info) == STT_FUNC){
+ return (void *)((unsigned long)_dl_make_fptr (map, ref, value) | 2);
+ }
+ else
+ return (void *) value;
+}
diff --git a/ports/sysdeps/hppa/dl-tls.h b/ports/sysdeps/hppa/dl-tls.h
new file mode 100644
index 000000000..1bc9aae66
--- /dev/null
+++ b/ports/sysdeps/hppa/dl-tls.h
@@ -0,0 +1,29 @@
+/* Thread-local storage handling in the ELF dynamic linker. hppa version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+/* Type used for the representation of TLS information in the GOT. */
+typedef struct
+{
+ unsigned long int ti_module;
+ unsigned long int ti_offset;
+} tls_index;
+
+
+extern void *__tls_get_addr (tls_index *ti);
diff --git a/ports/sysdeps/hppa/dl-trampoline.S b/ports/sysdeps/hppa/dl-trampoline.S
new file mode 100644
index 000000000..c476138eb
--- /dev/null
+++ b/ports/sysdeps/hppa/dl-trampoline.S
@@ -0,0 +1,197 @@
+/* PLT trampolines. hppa version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+/* This code gets called via the .plt stub, and is used in
+ dl-runtime.c to call the `_dl_fixup' function and then redirect
+ to the address it returns. `_dl_fixup' takes two
+ arguments, however `_dl_profile_fixup' takes a number of
+ parameters for use with library auditing (LA).
+
+ WARNING: This template is also used by gcc's __cffc, and expects
+ that the "bl" for _dl_runtime_resolve exist at a particular offset.
+ Do not change this template without changing gcc, while the prefix
+ "bl" should fix everything so gcc finds the right spot, it will
+ slow down __cffc when it attempts to call fixup to resolve function
+ descriptor references. Please refer to gcc/gcc/config/pa/fptr.c
+
+ Enter with r19 = reloc offset, r20 = got-8, r21 = fixup ltp. */
+
+ /* FAKE bl to provide gcc's __cffc with fixup loc. */
+ .text
+ bl _dl_fixup, %r2
+ .text
+ .align 4
+ .global _dl_runtime_resolve
+ .type _dl_runtime_resolve,@function
+_dl_runtime_resolve:
+ .PROC
+ .CALLINFO FRAME=128,CALLS,SAVE_RP,ENTRY_GR=3
+ .ENTRY
+ /* SAVE_RP says we do */
+ stw %rp, -20(%sp)
+
+ /* Save static link register */
+ stw %r29,-16(%sp)
+ /* Save argument registers in the call stack frame. */
+ stw %r26,-36(%sp)
+ stw %r25,-40(%sp)
+ stw %r24,-44(%sp)
+ stw %r23,-48(%sp)
+
+ /* Build a call frame, and save structure pointer. */
+ copy %sp, %r26 /* Copy previous sp */
+ /* Save function result address (on entry) */
+ stwm %r28,128(%sp)
+
+ /* Save floating point argument registers */
+ ldo -56(%sp),%r26
+ fstd,ma %fr4,-8(%r26)
+ fstd,ma %fr5,-8(%r26)
+ fstd,ma %fr6,-8(%r26)
+ fstd %fr7,0(%r26)
+
+ /* Fillin some frame info to follow ABI */
+ stw %r21,-32(%sp) /* PIC register value */
+ stw %r26,-4(%sp) /* Previous sp */
+
+ /* Set up args to fixup func, needs only two arguments */
+ ldw 8+4(%r20),%r26 /* (1) got[1] == struct link_map */
+ copy %r19,%r25 /* (2) reloc offset */
+
+ /* Call the real address resolver. */
+ bl _dl_fixup,%rp
+ copy %r21,%r19 /* set fixup func ltp */
+
+ /* Load up the returned func descriptor */
+ copy %ret0, %r22
+ copy %ret1, %r19
+
+ /* Reload arguments fp args */
+ ldo -80(%sp),%r26
+ fldd,ma 8(%r26),%fr7
+ fldd,ma 8(%r26),%fr6
+ fldd,ma 8(%r26),%fr5
+ fldd 0(%r26),%fr4
+
+ /* Adjust sp, and restore function result address*/
+ ldwm -128(%sp),%r28
+
+ /* Reload static link register */
+ ldw -16(%sp),%r29
+ /* Reload general args */
+ ldw -36(%sp),%r26
+ ldw -40(%sp),%r25
+ ldw -44(%sp),%r24
+ ldw -48(%sp),%r23
+
+ /* Jump to new function, but return to previous function */
+ bv %r0(%r22)
+ ldw -20(%sp),%rp
+ .EXIT
+ .PROCEND
+ .size _dl_runtime_resolve, . - _dl_runtime_resolve
+
+
+ /* FIXME:
+ Need to largely rewrite the bottom half of
+ this code in order to save and restore the
+ LA struct from the stack along with
+ interpreted parameters.
+ */
+ .text
+ .align 4
+ .global _dl_runtime_profile
+ .type _dl_runtime_profile,@function
+_dl_runtime_profile:
+ .PROC
+ .CALLINFO FRAME=128,CALLS,SAVE_RP,ENTRY_GR=3
+ .ENTRY
+
+ /* SAVE_RP says we do */
+ stw %rp, -20(%sp)
+
+ /* Save static link register */
+ stw %r29,-16(%sp)
+ /* Save argument registers in the call stack frame. */
+ stw %r26,-36(%sp)
+ stw %r25,-40(%sp)
+ stw %r24,-44(%sp)
+ stw %r23,-48(%sp)
+
+ /* Build a call frame, and save structure pointer. */
+ copy %sp, %r26 /* Copy previous sp */
+ /* Save function result address (on entry) */
+ stwm %r28,128(%sp)
+
+ /* Save floating point argument registers */
+ ldo -56(%sp),%r26
+ fstd,ma %fr4,-8(%r26)
+ fstd,ma %fr5,-8(%r26)
+ fstd,ma %fr6,-8(%r26)
+ fstd %fr7,0(%r26)
+
+ /* Fillin some frame info to follow ABI */
+ stw %r21,-32(%sp) /* PIC register value */
+ stw %r26,-4(%sp) /* Previous sp */
+
+ /* Set up args to fixup func, needs five arguments */
+ ldw 8+4(%r20),%r26 /* (1) got[1] == struct link_map */
+ copy %r19,%r25 /* (2) reloc offset */
+ copy %rp,%r24 /* (3) profile_fixup needs rp */
+ copy %r0,%r23 /* (4) regs */
+ ldo -56(%sp), %r1
+ stw %r1, -52(%sp) /* (5) long int *framesizep */
+
+ /* Call the real address resolver. */
+ bl _dl_profile_fixup,%rp
+ copy %r21,%r19 /* set fixup func ltp */
+
+ /* Load up the returned func descriptor */
+ copy %ret0, %r22
+ copy %ret1, %r19
+
+ /* Reload arguments fp args */
+ ldo -80(%sp),%r26
+ fldd,ma 8(%r26),%fr7
+ fldd,ma 8(%r26),%fr6
+ fldd,ma 8(%r26),%fr5
+ fldd 0(%r26),%fr4
+
+ /* Adjust sp, and restore function result address*/
+ ldwm -128(%sp),%r28
+
+ /* Reload static link register */
+ ldw -16(%sp),%r29
+ /* Reload general args */
+ ldw -36(%sp),%r26
+ ldw -40(%sp),%r25
+ ldw -44(%sp),%r24
+ ldw -48(%sp),%r23
+
+ /* Jump to new function, but return to previous function */
+ bv %r0(%r22)
+ ldw -20(%sp),%rp
+ .EXIT
+ .PROCEND
+ .size _dl_runtime_profile, . - _dl_runtime_profile
+
+
+
diff --git a/ports/sysdeps/hppa/elf/configure b/ports/sysdeps/hppa/elf/configure
new file mode 100644
index 000000000..226c30d3b
--- /dev/null
+++ b/ports/sysdeps/hppa/elf/configure
@@ -0,0 +1,63 @@
+# This file is generated from configure.in by Autoconf. DO NOT EDIT!
+ # Local configure fragment for sysdeps/hppa/elf.
+
+if test "$usetls" != no; then
+# Check for support of thread-local storage handling in assembler and
+# linker.
+echo "$as_me:$LINENO: checking for hppa TLS support" >&5
+echo $ECHO_N "checking for hppa TLS support... $ECHO_C" >&6
+if test "${libc_cv_hppa_tls+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat > conftest.s <<\EOF
+; Setup tls data
+.section ".tdata","awT",@progbits
+foo: .data 32
+ .text
+; Test general dyanmic relocations
+test0:
+ addil LT'foo-$tls_gdidx$, %r19
+ ldo RT'foo-$tls_gdidx$(%r1), %r26
+ b __tls_get_addr
+ nop
+; Test local dynamic relocations
+test1:
+ addil LT'foo-$tls_ldidx$, %r19
+ b __tls_get_addr
+ ldo RT'foo-$tls_ldidx$(%r1), %r26
+ ldo RR'foo-$tls_dtpoff$(%r1), %r25
+ ; More variables can be loaded...
+; Test initial exec reloctiosn
+test2:
+ mfctl %cr27, %r26
+ addil LT'foo-$tls_ieoff$, %r19
+ ldw RT'foo-$tls_ieoff$(%r1), %r25
+ add %r26, %r25, %r24
+; Test local exec relocations
+test3:
+ mfctl %cr27, %r26
+ addil LR'foo-$tls_leoff$, %r26
+ ldo RR'foo-$tls_leoff$(%r1), %r25
+; Done all the TLS tests.
+EOF
+if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ libc_cv_hppa_tls=yes
+else
+ libc_cv_hppa_tls=no
+fi
+rm -f conftest*
+fi
+echo "$as_me:$LINENO: result: $libc_cv_hppa_tls" >&5
+echo "${ECHO_T}$libc_cv_hppa_tls" >&6
+if test $libc_cv_hppa_tls = yes; then
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_TLS_SUPPORT 1
+_ACEOF
+
+fi
+fi
diff --git a/ports/sysdeps/hppa/elf/configure.in b/ports/sysdeps/hppa/elf/configure.in
new file mode 100644
index 000000000..1b70a5b74
--- /dev/null
+++ b/ports/sysdeps/hppa/elf/configure.in
@@ -0,0 +1,49 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/hppa/elf.
+
+if test "$usetls" != no; then
+# Check for support of thread-local storage handling in assembler and
+# linker.
+AC_CACHE_CHECK(for hppa TLS support, libc_cv_hppa_tls, [dnl
+cat > conftest.s <<\EOF
+; Setup tls data
+.section ".tdata","awT",@progbits
+foo: .data 32
+ .text
+; Test general dyanmic relocations
+test0:
+ addil LT'foo-$tls_gdidx$, %r19
+ ldo RT'foo-$tls_gdidx$(%r1), %r26
+ b __tls_get_addr
+ nop
+; Test local dynamic relocations
+test1:
+ addil LT'foo-$tls_ldidx$, %r19
+ b __tls_get_addr
+ ldo RT'foo-$tls_ldidx$(%r1), %r26
+ ldo RR'foo-$tls_dtpoff$(%r1), %r25
+ ; More variables can be loaded...
+; Test initial exec reloctiosn
+test2:
+ mfctl %cr27, %r26
+ addil LT'foo-$tls_ieoff$, %r19
+ ldw RT'foo-$tls_ieoff$(%r1), %r25
+ add %r26, %r25, %r24
+; Test local exec relocations
+test3:
+ mfctl %cr27, %r26
+ addil LR'foo-$tls_leoff$, %r26
+ ldo RR'foo-$tls_leoff$(%r1), %r25
+; Done all the TLS tests.
+EOF
+dnl
+if AC_TRY_COMMAND(${CC-cc} -c $CFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
+ libc_cv_hppa_tls=yes
+else
+ libc_cv_hppa_tls=no
+fi
+rm -f conftest*])
+if test $libc_cv_hppa_tls = yes; then
+ AC_DEFINE(HAVE_TLS_SUPPORT)
+fi
+fi
diff --git a/ports/sysdeps/hppa/elf/entry.h b/ports/sysdeps/hppa/elf/entry.h
new file mode 100644
index 000000000..b024db2be
--- /dev/null
+++ b/ports/sysdeps/hppa/elf/entry.h
@@ -0,0 +1,10 @@
+#ifndef __ASSEMBLY__
+extern void _start (void);
+#endif
+
+/* The function's entry point is stored in the first word of the
+ function descriptor (plabel) of _start(). */
+#define ENTRY_POINT __canonicalize_funcptr_for_compare(_start)
+
+/* We have to provide a special declaration. */
+#define ENTRY_POINT_DECL(class) class void _start (void);
diff --git a/ports/sysdeps/hppa/elf/initfini.c b/ports/sysdeps/hppa/elf/initfini.c
new file mode 100644
index 000000000..35f5dd52f
--- /dev/null
+++ b/ports/sysdeps/hppa/elf/initfini.c
@@ -0,0 +1,139 @@
+/* Special .init and .fini section support for HPPA
+ Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file is compiled into assembly code which is then munged by a sed
+ script into two files: crti.s and crtn.s.
+
+ * crti.s puts a function prologue at the beginning of the
+ .init and .fini sections and defines global symbols for
+ those addresses, so they can be called as functions.
+
+ * crtn.s puts the corresponding function epilogues
+ in the .init and .fini sections. */
+
+/* If we use the standard C version, the linkage table pointer won't
+ be properly preserved due to the splitting up of function prologues
+ and epilogues. Therefore we write these in assembly to make sure
+ they do the right thing.
+
+ Note that we cannot have a weak undefined __gmon_start__, because
+ that would require this to be PIC, and the linker is currently not
+ able to generate a proper procedure descriptor for _init. Sad but
+ true. Anyway, HPPA is one of those horrible architectures where
+ making the comparison and indirect call is quite expensive (see the
+ comment in sysdeps/generic/initfini.c). */
+
+__asm__ ("\
+\n\
+#include \"defs.h\"\n\
+\n\
+/*@HEADER_ENDS*/\n\
+\n\
+/*@_init_PROLOG_BEGINS*/\n\
+ .section .init\n\
+ .align 4\n\
+ .globl _init\n\
+ .type _init,@function\n\
+_init:\n\
+ stw %rp,-20(%sp)\n\
+ stwm %r4,64(%sp)\n\
+ stw %r19,-32(%sp)\n\
+ bl __gmon_start__,%rp\n\
+ copy %r19,%r4 /* delay slot */\n\
+ copy %r4,%r19\n\
+/*@_init_PROLOG_ENDS*/\n\
+\n\
+/*@_init_EPILOG_BEGINS*/\n\
+ .text\n\
+ .align 4\n\
+ .weak __gmon_start__\n\
+ .type __gmon_start__,@function\n\
+__gmon_start__:\n\
+ .proc\n\
+ .callinfo\n\
+ .entry\n\
+ bv,n %r0(%r2)\n\
+ .exit\n\
+ .procend\n\
+\n\
+/* Here is the tail end of _init. We put __gmon_start before this so\n\
+ that the assembler creates the .PARISC.unwind section for us, ie.\n\
+ with the right attributes. */\n\
+ .section .init\n\
+ ldw -84(%sp),%rp\n\
+ copy %r4,%r19\n\
+ bv %r0(%rp)\n\
+_end_init:\n\
+ ldwm -64(%sp),%r4\n\
+\n\
+/* Our very own unwind info, because the assembler can't handle\n\
+ functions split into two or more pieces. */\n\
+ .section .PARISC.unwind\n\
+ .extern _init\n\
+ .word _init, _end_init\n\
+ .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n\
+\n\
+/*@_init_EPILOG_ENDS*/\n\
+\n\
+/*@_fini_PROLOG_BEGINS*/\n\
+ .section .fini\n\
+ .align 4\n\
+ .globl _fini\n\
+ .type _fini,@function\n\
+_fini:\n\
+ stw %rp,-20(%sp)\n\
+ stwm %r4,64(%sp)\n\
+ stw %r19,-32(%sp)\n\
+ copy %r19,%r4\n\
+/*@_fini_PROLOG_ENDS*/\n\
+\n\
+/*@_fini_EPILOG_BEGINS*/\n\
+ .section .fini\n\
+ ldw -84(%sp),%rp\n\
+ copy %r4,%r19\n\
+ bv %r0(%rp)\n\
+_end_fini:\n\
+ ldwm -64(%sp),%r4\n\
+\n\
+ .section .PARISC.unwind\n\
+ .extern _fini\n\
+ .word _fini, _end_fini\n\
+ .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n\
+\n\
+/*@_fini_EPILOG_ENDS*/\n\
+\n\
+/*@TRAILER_BEGINS*/\
+");
diff --git a/ports/sysdeps/hppa/elf/start.S b/ports/sysdeps/hppa/elf/start.S
new file mode 100644
index 000000000..94edeaa21
--- /dev/null
+++ b/ports/sysdeps/hppa/elf/start.S
@@ -0,0 +1,121 @@
+/* ELF startup code for HPPA.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+ .import main, code
+ .import $global$, data
+ .import __libc_start_main, code
+ .import __libc_csu_fini, code
+ .import __libc_csu_init, code
+
+ /* Have the linker create plabel words
+ so we get PLABEL32 relocs and not 21/14 */
+ .section .rodata
+ .align 4
+.Lpmain:
+ .word P%main
+.Lp__libc_start_main:
+ .word P%__libc_start_main
+.Lp__libc_csu_fini:
+ .word P%__libc_csu_fini
+.Lp__libc_csu_init:
+ .word P%__libc_csu_init
+
+ .text
+ .align 4
+ .globl _start
+ .export _start, ENTRY
+ .type _start,@function
+_start:
+
+ .proc
+ .callinfo
+
+ /* Expand the stack to store the 5th through 7th args */
+ ldo 64(%sp), %sp
+ /* TODO: Follow ABI? Place more things on the stack here... */
+
+#if SHARED
+ /* load main (1st argument) */
+ addil LR'.Lpmain, %r19
+ ldw RR'.Lpmain(%r1), %r26
+ ldw 0(%r26),%r26
+ /* argc and argv should be in 25 and 24 (2nd and 3rd argument) */
+ /* void (*init) (void) (4th argument) */
+ addil LR'.Lp__libc_csu_init, %r19
+ ldw RR'.Lp__libc_csu_init(%r1), %r23
+ ldw 0(%r23), %r23
+ /* void (*fini) (void) (5th argument) */
+ addil LR'.Lp__libc_csu_fini, %r19
+ ldw RR'.Lp__libc_csu_fini(%r1), %r22
+ ldw 0(%r22), %r22
+#else
+ /* load main (1st argument) */
+ ldil LR'.Lpmain, %r26
+ ldw RR'.Lpmain(%r26), %r26
+ /* argc and argv should be in 25 and 24 (2nd and 3rd argument) */
+ /* void (*init) (void) (4th argument) */
+ ldil LR'.Lp__libc_csu_init, %r23
+ ldw RR'.Lp__libc_csu_init(%r23), %r23
+ /* void (*fini) (void) (5th argument) */
+ ldil LR'.Lp__libc_csu_fini, %r22
+ ldw RR'.Lp__libc_csu_fini(%r22), %r22
+#endif
+ /* Store 5th argument */
+ stw %r22, -52(%sp)
+ /* void (*rtld_fini) (void) (6th argument) */
+ stw %r23, -56(%sp)
+ /* void *stack_end (7th argument) */
+ stw %sp, -60(%sp)
+
+ /* load global */
+ ldil L%$global$, %dp
+ ldo R%$global$(%dp), %dp
+
+ bl __libc_start_main,%r2
+ nop
+ /* die horribly if it returned (it shouldn't) */
+ iitlbp %r0,(%sr0,%r0)
+ nop
+
+ .procend
+
+/* Define a symbol for the first piece of initialized data. */
+ .data
+ .globl __data_start
+__data_start:
+ .long 0
+ .weak data_start
+ data_start = __data_start
diff --git a/ports/sysdeps/hppa/fpu/bits/fenv.h b/ports/sysdeps/hppa/fpu/bits/fenv.h
new file mode 100644
index 000000000..6d83b141f
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/bits/fenv.h
@@ -0,0 +1,83 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FENV_H
+# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
+
+/* Define bits representing the exception. We use the values of the
+ appropriate enable bits in the FPU status word (which,
+ coincidentally, are the same as the flag bits, but shifted right by
+ 27 bits). */
+enum
+{
+ FE_INVALID = 1<<4, /* V */
+#define FE_INVALID FE_INVALID
+ FE_DIVBYZERO = 1<<3, /* Z */
+#define FE_DIVBYZERO FE_DIVBYZERO
+ FE_OVERFLOW = 1<<2, /* O */
+#define FE_OVERFLOW FE_OVERFLOW
+ FE_UNDERFLOW = 1<<1, /* U */
+#define FE_UNDERFLOW FE_UNDERFLOW
+ FE_INEXACT = 1<<0, /* I */
+#define FE_INEXACT FE_INEXACT
+};
+
+#define FE_ALL_EXCEPT \
+ (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
+
+/* The PA-RISC FPU supports all of the four defined rounding modes.
+ We use the values of the RM field in the floating point status
+ register for the appropriate macros. */
+enum
+ {
+ FE_TONEAREST = 0 << 9,
+#define FE_TONEAREST FE_TONEAREST
+ FE_TOWARDZERO = 1 << 9,
+#define FE_TOWARDZERO FE_TOWARDZERO
+ FE_UPWARD = 2 << 9,
+#define FE_UPWARD FE_UPWARD
+ FE_DOWNWARD = 3 << 9,
+#define FE_DOWNWARD FE_DOWNWARD
+ };
+
+/* Type representing exception flags. */
+typedef unsigned int fexcept_t;
+
+/* Type representing floating-point environment. This structure
+ corresponds to the layout of the status and exception words in the
+ register file. The exception registers are never saved/stored by
+ userspace. This structure is also not correctly aligned ever, in
+ an ABI error we left out __aligned(8) and subsequently all of our
+ fenv functions must accept unaligned input, align the input, and
+ then use assembly to store fr0. This is a performance hit, but
+ means the ABI is stable. */
+typedef struct
+{
+ unsigned int __status_word;
+ unsigned int __exception[7];
+} fenv_t;
+
+/* If the default argument is used we use this value. */
+#define FE_DFL_ENV ((fenv_t *) -1)
+
+#ifdef __USE_GNU
+/* Floating-point environment where none of the exceptions are masked. */
+# define FE_NOMASK_ENV ((fenv_t *) -2)
+#endif
diff --git a/ports/sysdeps/hppa/fpu/fclrexcpt.c b/ports/sysdeps/hppa/fpu/fclrexcpt.c
new file mode 100644
index 000000000..d74a449eb
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fclrexcpt.c
@@ -0,0 +1,36 @@
+/* Clear given exceptions in current floating-point environment.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+feclearexcept (int excepts)
+{
+ union { unsigned long long l; unsigned int sw[2]; } s;
+
+ /* Get the current status word. */
+ __asm__ ("fstd %%fr0,0(%1)" : "=m" (s.l) : "r" (&s.l) : "%r0");
+ /* Clear all the relevant bits. */
+ s.sw[0] &= ~((excepts & FE_ALL_EXCEPT) << 27);
+ __asm__ ("fldd 0(%0),%%fr0" : : "r" (&s.l), "m" (s.l) : "%r0");
+
+ /* Success. */
+ return 0;
+}
diff --git a/ports/sysdeps/hppa/fpu/fedisblxcpt.c b/ports/sysdeps/hppa/fpu/fedisblxcpt.c
new file mode 100644
index 000000000..8d2e66403
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fedisblxcpt.c
@@ -0,0 +1,38 @@
+/* Disable floating-point exceptions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+fedisableexcept (int excepts)
+{
+ union { unsigned long long l; unsigned int sw[2]; } s;
+ unsigned int old_exc;
+
+ /* Get the current status word. */
+ __asm__ ("fstd %%fr0,0(%1)" : "=m" (s.l) : "r" (&s.l) : "%r0");
+
+ old_exc = s.sw[0] & FE_ALL_EXCEPT;
+
+ s.sw[0] &= ~(excepts & FE_ALL_EXCEPT);
+ __asm__ ("fldd 0(%0),%%fr0" : : "r" (&s.l), "m" (s.l) : "%r0");
+
+ return old_exc;
+}
diff --git a/ports/sysdeps/hppa/fpu/feenablxcpt.c b/ports/sysdeps/hppa/fpu/feenablxcpt.c
new file mode 100644
index 000000000..4b17a6037
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/feenablxcpt.c
@@ -0,0 +1,38 @@
+/* Enable floating-point exceptions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+feenableexcept (int excepts)
+{
+ union { unsigned long long l; unsigned int sw[2]; } s;
+ unsigned int old_exc;
+
+ /* Get the current status word. */
+ __asm__ ("fstd %%fr0,0(%1)" : "=m" (s.l) : "r" (&s.l) : "%r0");
+
+ old_exc = s.sw[0] & FE_ALL_EXCEPT;
+
+ s.sw[0] |= (excepts & FE_ALL_EXCEPT);
+ __asm__ ("fldd 0(%0),%%fr0" : : "r" (&s.l), "m" (s.l) : "%r0");
+
+ return old_exc;
+}
diff --git a/ports/sysdeps/hppa/fpu/fegetenv.c b/ports/sysdeps/hppa/fpu/fegetenv.c
new file mode 100644
index 000000000..fcf5d2dcf
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fegetenv.c
@@ -0,0 +1,35 @@
+/* Store current floating-point environment.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <string.h>
+
+int
+fegetenv (fenv_t *envp)
+{
+ unsigned long long buf[4], *bufptr = buf;
+
+ __asm__ (
+ "fstd,ma %%fr0,8(%1) \n\t"
+ "fldd -8(%1),%%fr0 \n\t"
+ : "=m" (buf), "+r" (bufptr) : : "%r0");
+ memcpy(envp, buf, sizeof (*envp));
+ return 0;
+}
diff --git a/ports/sysdeps/hppa/fpu/fegetexcept.c b/ports/sysdeps/hppa/fpu/fegetexcept.c
new file mode 100644
index 000000000..d249dc6b9
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fegetexcept.c
@@ -0,0 +1,34 @@
+/* Get enabled floating-point exceptions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+fegetexcept (void)
+{
+ union { unsigned long long l; unsigned int sw[2] } s;
+
+ /* Get the current status word. */
+ __asm__ ("fstd %%fr0,0(%1) \n\t"
+ "fldd 0(%1),%%fr0 \n\t"
+ : "=m" (s.l) : "r" (&s.l) : "%r0");
+
+ return (s.sw[0] & FE_ALL_EXCEPT);
+}
diff --git a/ports/sysdeps/hppa/fpu/fegetround.c b/ports/sysdeps/hppa/fpu/fegetround.c
new file mode 100644
index 000000000..1e606c9ec
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fegetround.c
@@ -0,0 +1,34 @@
+/* Return current rounding direction.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+fegetround (void)
+{
+ union { unsigned long long l; unsigned int sw[2] } s;
+
+ /* Get the current status word. */
+ __asm__ ("fstd %%fr0,0(%1) \n\t"
+ "fldd 0(%1),%%fr0 \n\t"
+ : "=m" (s.l) : "r" (&s.l));
+
+ return (s.sw[0] & FE_DOWNWARD);
+}
diff --git a/ports/sysdeps/hppa/fpu/feholdexcpt.c b/ports/sysdeps/hppa/fpu/feholdexcpt.c
new file mode 100644
index 000000000..ac6eb5805
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/feholdexcpt.c
@@ -0,0 +1,55 @@
+/* Store current floating-point environment and clear exceptions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <string.h>
+
+int
+feholdexcept (fenv_t *envp)
+{
+ union { unsigned long long buf[4]; fenv_t env; } clear;
+ unsigned long long *bufptr;
+
+ /* Store the environment. */
+ bufptr = clear.buf;
+ __asm__ (
+ "fstd,ma %%fr0,8(%1)\n"
+ : "=m" (clear), "+r" (bufptr) : : "%r0");
+ memcpy (envp, &clear.env, sizeof (fenv_t));
+
+ /* Clear exception queues */
+ memset (clear.env.__exception, 0, sizeof (clear.env.__exception));
+ /* And set all exceptions to non-stop. */
+ clear.env.__status_word &= ~FE_ALL_EXCEPT;
+ /* Now clear all flags */
+ clear.env.__status_word &= ~(FE_ALL_EXCEPT << 27);
+
+ /* Load the new environment. Note: fr0 must load last to enable T-bit
+ Thus we start bufptr at the end and work backwards */
+ bufptr = (unsigned int)(clear.buf) + sizeof(unsigned int)*4;
+ __asm__ (
+ "fldd,mb -8(%0),%%fr0\n"
+ : : "r" (bufptr), "m" (clear) : "%r0");
+
+ return 0;
+}
+
+libm_hidden_def (feholdexcept)
+
diff --git a/ports/sysdeps/hppa/fpu/fesetenv.c b/ports/sysdeps/hppa/fpu/fesetenv.c
new file mode 100644
index 000000000..b5753efab
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fesetenv.c
@@ -0,0 +1,64 @@
+/* Install given floating-point environment.
+ Copyright (C) 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000
+ Based on the m68k version by
+ Andreas Schwab <schwab@suse.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+fesetenv (const fenv_t *envp)
+{
+ union { unsigned long long buf[4]; fenv_t env; } temp;
+ unsigned long long *bufptr;
+
+ /* Install the environment specified by ENVP. But there are a few
+ values which we do not want to come from the saved environment.
+ Therefore, we get the current environment and replace the values
+ we want to use from the environment specified by the parameter. */
+ bufptr = temp.buf;
+ __asm__ (
+ "fstd,ma %%fr0,8(%1)\n"
+ : "=m" (temp), "+r" (bufptr) : : "%r0");
+
+ temp.env.__status_word &= ~(FE_ALL_EXCEPT
+ | (FE_ALL_EXCEPT << 27)
+ | FE_DOWNWARD);
+ if (envp == FE_DFL_ENV)
+ ;
+ else if (envp == FE_NOMASK_ENV)
+ temp.env.__status_word |= FE_ALL_EXCEPT;
+ else
+ temp.env.__status_word |= (envp->__status_word
+ & (FE_ALL_EXCEPT
+ | FE_DOWNWARD
+ | (FE_ALL_EXCEPT << 27)));
+
+ /* Load the new environment. We use bufptr again since the
+ initial asm has modified the value of the register and here
+ we take advantage of that to load in reverse order so fr0
+ is loaded last and T-Bit is enabled. */
+ __asm__ (
+ "fldd,mb -8(%1),%%fr0\n"
+ : "=m" (temp), "+r" (bufptr) : : "%r0" );
+
+ /* Success. */
+ return 0;
+}
+libm_hidden_def (fesetenv)
diff --git a/ports/sysdeps/hppa/fpu/fesetround.c b/ports/sysdeps/hppa/fpu/fesetround.c
new file mode 100644
index 000000000..9f30c2495
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fesetround.c
@@ -0,0 +1,41 @@
+/* Set current rounding direction.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+fesetround (int round)
+{
+ union { unsigned long long l; unsigned int sw[2]; } s;
+
+ if (round & ~FE_DOWNWARD)
+ /* round is not a valid rounding mode. */
+ return 1;
+
+ /* Get the current status word. */
+ __asm__ ("fstd %%fr0,0(%1)" : "=m" (s.l) : "r" (&s.l) : "%r0");
+ s.sw[0] &= ~FE_DOWNWARD;
+ s.sw[0] |= round & FE_DOWNWARD;
+ __asm__ ("fldd 0(%0),%%fr0" : : "r" (&s.l), "m" (s.l) : "%r0");
+
+ return 0;
+}
+
+libm_hidden_def (fesetround)
diff --git a/ports/sysdeps/hppa/fpu/feupdateenv.c b/ports/sysdeps/hppa/fpu/feupdateenv.c
new file mode 100644
index 000000000..17140060a
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/feupdateenv.c
@@ -0,0 +1,40 @@
+/* Install given floating-point environment and raise exceptions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <string.h>
+
+int
+feupdateenv (const fenv_t *envp)
+{
+ union { unsigned long long l; unsigned int sw[2]; } s;
+ fenv_t temp;
+ /* Get the current exception status */
+ __asm__ ("fstd %%fr0,0(%1) \n\t"
+ "fldd 0(%1),%%fr0 \n\t"
+ : "=m" (s.l) : "r" (&s.l));
+ memcpy(&temp, envp, sizeof(fenv_t));
+ /* Currently raised exceptions not cleared */
+ temp.__status_word |= s.sw[0] & (FE_ALL_EXCEPT << 27);
+ /* Install new environment. */
+ fesetenv (&temp);
+ /* Success. */
+ return 0;
+}
diff --git a/ports/sysdeps/hppa/fpu/fgetexcptflg.c b/ports/sysdeps/hppa/fpu/fgetexcptflg.c
new file mode 100644
index 000000000..d5bcfe31d
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fgetexcptflg.c
@@ -0,0 +1,38 @@
+/* Store current representation for exceptions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+fegetexceptflag (fexcept_t *flagp, int excepts)
+{
+ union { unsigned long long l; unsigned int sw[2]; } s;
+
+ /* Get the current status word. */
+ __asm__ ("fstd %%fr0,0(%1) \n\t"
+ "fldd 0(%1),%%fr0 \n\t"
+ : "=m" (s.l) : "r" (&s.l) : "%r0");
+
+ *flagp = (s.sw[0] >> 27) & excepts & FE_ALL_EXCEPT;
+
+ /* Success. */
+ return 0;
+}
+
diff --git a/ports/sysdeps/hppa/fpu/fraiseexcpt.c b/ports/sysdeps/hppa/fpu/fraiseexcpt.c
new file mode 100644
index 000000000..b064dc152
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fraiseexcpt.c
@@ -0,0 +1,102 @@
+/* Raise given exceptions.
+ Copyright (C) 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <float.h>
+#include <math.h>
+
+/* Please see section 10,
+ page 10-5 "Delayed Trapping" in the PA-RISC 2.0 Architecture manual */
+
+int
+feraiseexcept (int excepts)
+{
+ /* Raise exceptions represented by EXCEPTS. But we must raise only one
+ signal at a time. It is important that if the overflow/underflow
+ exception and the divide by zero exception are given at the same
+ time, the overflow/underflow exception follows the divide by zero
+ exception. */
+
+ /* We do these bits in assembly to be certain GCC doesn't optimize
+ away something important, and so we can force delayed traps to
+ occur. */
+
+ /* We use "fldd 0(%%sr0,%%sp),%0" to flush the delayed exception */
+
+ /* First: Invalid exception. */
+ if (excepts & FE_INVALID)
+ {
+ /* One example of a invalid operation is 0 * Infinity. */
+ double d = HUGE_VAL;
+ __asm__ __volatile__ (
+ " fcpy,dbl %%fr0,%%fr22\n"
+ " fmpy,dbl %0,%%fr22,%0\n"
+ " fldd 0(%%sr0,%%sp),%0"
+ : "+f" (d) : : "%fr22" );
+ }
+
+ /* Second: Division by zero. */
+ if (excepts & FE_DIVBYZERO)
+ {
+ double d = 1.0;
+ __asm__ __volatile__ (
+ " fcpy,dbl %%fr0,%%fr22\n"
+ " fdiv,dbl %0,%%fr22,%0\n"
+ " fldd 0(%%sr0,%%sp),%0"
+ : "+f" (d) : : "%fr22" );
+ }
+
+ /* Third: Overflow. */
+ if (excepts & FE_OVERFLOW)
+ {
+ double d = DBL_MAX;
+ __asm__ __volatile__ (
+ " fadd,dbl %0,%0,%0\n"
+ " fldd 0(%%sr0,%%sp),%0"
+ : "+f" (d) );
+ }
+
+ /* Fourth: Underflow. */
+ if (excepts & FE_UNDERFLOW)
+ {
+ double d = DBL_MIN;
+ double e = 3.0;
+ __asm__ __volatile__ (
+ " fdiv,dbl %0,%1,%0\n"
+ " fldd 0(%%sr0,%%sp),%0"
+ : "+f" (d) : "f" (e) );
+ }
+
+ /* Fifth: Inexact */
+ if (excepts & FE_INEXACT)
+ {
+ double d = M_PI;
+ double e = 69.69;
+ __asm__ __volatile__ (
+ " fdiv,dbl %0,%1,%%fr22\n"
+ " fcnvfxt,dbl,sgl %%fr22,%%fr22L\n"
+ " fldd 0(%%sr0,%%sp),%%fr22"
+ : : "f" (d), "f" (e) : "%fr22" );
+ }
+
+ /* Success. */
+ return 0;
+}
+libm_hidden_def (feraiseexcept)
diff --git a/ports/sysdeps/hppa/fpu/fsetexcptflg.c b/ports/sysdeps/hppa/fpu/fsetexcptflg.c
new file mode 100644
index 000000000..4ec3a92dc
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fsetexcptflg.c
@@ -0,0 +1,38 @@
+/* Set floating-point environment exception handling.
+ Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <math.h>
+
+int
+fesetexceptflag (const fexcept_t *flagp, int excepts)
+{
+ union { unsigned long long l; unsigned int sw[2]; } s;
+
+ /* Get the current status word. */
+ __asm__ ("fstd %%fr0,0(%1)" : "=m" (s.l) : "r" (&s.l) : "%r0");
+ /* Install new raised trap bits */
+ s.sw[0] |= (*flagp & excepts & FE_ALL_EXCEPT) << 27;
+ /* Store the new status word. */
+ __asm__ ("fldd 0(%0),%%fr0" : : "r" (&s.l), "m" (s.l) : "%r0");
+
+ /* Success. */
+ return 0;
+}
diff --git a/ports/sysdeps/hppa/fpu/ftestexcept.c b/ports/sysdeps/hppa/fpu/ftestexcept.c
new file mode 100644
index 000000000..ac6d4b2e3
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/ftestexcept.c
@@ -0,0 +1,34 @@
+/* Test exception in current environment.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+fetestexcept (int excepts)
+{
+ union { unsigned long long l; unsigned int sw[2] } s;
+
+ /* Get the current status word. */
+ __asm__ ("fstd %%fr0,0(%1) \n\t"
+ "fldd 0(%1),%%fr0 \n\t"
+ : "=m" (s.l) : "r" (&s.l));
+
+ return (s.sw[0] >> 27) & excepts & FE_ALL_EXCEPT;
+}
diff --git a/ports/sysdeps/hppa/fpu/libm-test-ulps b/ports/sysdeps/hppa/fpu/libm-test-ulps
new file mode 100644
index 000000000..c4ffefaa8
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/libm-test-ulps
@@ -0,0 +1,891 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.00756827042671106339, -.001792735857538728036) == -1.80338464113663849327153994380":
+float: 6
+ifloat: 6
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+float: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+float: 1
+ifloat: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# lround
+Test "lround (1071930.0008) == 1071930":
+double: -214511494
+idouble: -214511494
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+idouble: 1
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+idouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 6
+ifloat: 6
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log1p":
+float: 1
+ifloat: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
diff --git a/ports/sysdeps/hppa/frame.h b/ports/sysdeps/hppa/frame.h
new file mode 100644
index 000000000..0a234f1aa
--- /dev/null
+++ b/ports/sysdeps/hppa/frame.h
@@ -0,0 +1,28 @@
+/* Definition of stack frame structure. HPPA version.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* PA stacks grow upwards. */
+#define INNER_THAN >
+
+/* FIXME: will verify this later */
+struct layout
+{
+ void *next;
+ void *return_address;
+};
diff --git a/ports/sysdeps/hppa/gccframe.h b/ports/sysdeps/hppa/gccframe.h
new file mode 100644
index 000000000..65e44dfd7
--- /dev/null
+++ b/ports/sysdeps/hppa/gccframe.h
@@ -0,0 +1,23 @@
+/* Definition of object in frame unwind info. hppa version.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Note: For hppa64 this is 61 */
+#define DWARF_FRAME_REGISTERS 89
+
+#include <sysdeps/generic/gccframe.h>
diff --git a/ports/sysdeps/hppa/hppa1.1/Implies b/ports/sysdeps/hppa/hppa1.1/Implies
new file mode 100644
index 000000000..780c4e246
--- /dev/null
+++ b/ports/sysdeps/hppa/hppa1.1/Implies
@@ -0,0 +1,3 @@
+wordsize-32
+ieee754/flt-32
+ieee754/dbl-64
diff --git a/ports/sysdeps/hppa/hppa1.1/addmul_1.s b/ports/sysdeps/hppa/hppa1.1/addmul_1.s
new file mode 100644
index 000000000..a1fb083a8
--- /dev/null
+++ b/ports/sysdeps/hppa/hppa1.1/addmul_1.s
@@ -0,0 +1,104 @@
+;! HP-PA-1.1 __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 Lesser General Public License as published by
+;! the Free Software Foundation; either version 2.1 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 Lesser General Public
+;! License for more details.
+
+;! You should have received a copy of the GNU Lesser General Public License
+;! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+;! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+;! MA 02111-1307, USA.
+
+
+;! INPUT PARAMETERS
+;! res_ptr r26
+;! s1_ptr r25
+;! size r24
+;! s2_limb r23
+
+;! This runs at 11 cycles/limb on a PA7000. With the used instructions, it
+;! can not become faster due to data cache contention after a store. On the
+;! PA7100 it runs at 10 cycles/limb, and that can not be improved either,
+;! since only the xmpyu does not need the integer pipeline, so the only
+;! dual-issue we will get are addc+xmpyu. Unrolling could gain a cycle/limb
+;! on the PA7100.
+
+;! There are some ideas described in mul_1.s that applies to this code too.
+
+ .text
+ .export __mpn_addmul_1
+__mpn_addmul_1:
+ .proc
+ .callinfo frame=64,no_calls
+ .entry
+
+ ldo 64(%r30),%r30
+ fldws,ma 4(%r25),%fr5
+ stw %r23,-16(%r30) ;! move s2_limb ...
+ addib,= -1,%r24,L$just_one_limb
+ fldws -16(%r30),%fr4 ;! ... into fr4
+ add %r0,%r0,%r0 ;! clear carry
+ xmpyu %fr4,%fr5,%fr6
+ fldws,ma 4(%r25),%fr7
+ fstds %fr6,-16(%r30)
+ xmpyu %fr4,%fr7,%fr8
+ ldw -12(%r30),%r20 ;! least significant limb in product
+ ldw -16(%r30),%r28
+
+ fstds %fr8,-16(%r30)
+ addib,= -1,%r24,L$end
+ ldw -12(%r30),%r1
+
+;! Main loop
+L$loop:
+ ldws 0(%r26),%r29
+ fldws,ma 4(%r25),%fr5
+ add %r29,%r20,%r20
+ stws,ma %r20,4(%r26)
+ addc %r28,%r1,%r20
+ xmpyu %fr4,%fr5,%fr6
+ ldw -16(%r30),%r28
+ fstds %fr6,-16(%r30)
+ addc %r0,%r28,%r28
+ addib,<> -1,%r24,L$loop
+ ldw -12(%r30),%r1
+
+L$end:
+ ldw 0(%r26),%r29
+ add %r29,%r20,%r20
+ stws,ma %r20,4(%r26)
+ addc %r28,%r1,%r20
+ ldw -16(%r30),%r28
+ ldws 0(%r26),%r29
+ addc %r0,%r28,%r28
+ add %r29,%r20,%r20
+ stws,ma %r20,4(%r26)
+ addc %r0,%r28,%r28
+ bv 0(%r2)
+ ldo -64(%r30),%r30
+
+L$just_one_limb:
+ xmpyu %fr4,%fr5,%fr6
+ ldw 0(%r26),%r29
+ fstds %fr6,-16(%r30)
+ ldw -12(%r30),%r1
+ ldw -16(%r30),%r28
+ add %r29,%r1,%r20
+ stw %r20,0(%r26)
+ addc %r0,%r28,%r28
+ bv 0(%r2)
+ ldo -64(%r30),%r30
+
+ .exit
+ .procend
diff --git a/ports/sysdeps/hppa/hppa1.1/mul_1.s b/ports/sysdeps/hppa/hppa1.1/mul_1.s
new file mode 100644
index 000000000..00c770f27
--- /dev/null
+++ b/ports/sysdeps/hppa/hppa1.1/mul_1.s
@@ -0,0 +1,100 @@
+;! HP-PA-1.1 __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 Lesser General Public License as published by
+;! the Free Software Foundation; either version 2.1 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 Lesser General Public
+;! License for more details.
+
+;! You should have received a copy of the GNU Lesser General Public License
+;! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+;! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+;! MA 02111-1307, USA.
+
+
+;! INPUT PARAMETERS
+;! res_ptr r26
+;! s1_ptr r25
+;! size r24
+;! s2_limb r23
+
+;! This runs at 9 cycles/limb on a PA7000. With the used instructions, it can
+;! not become faster due to data cache contention after a store. On the
+;! PA7100 it runs at 7 cycles/limb, and that can not be improved either, since
+;! only the xmpyu does not need the integer pipeline, so the only dual-issue
+;! we will get are addc+xmpyu. Unrolling would not help either CPU.
+
+;! We could use fldds to read two limbs at a time from the S1 array, and that
+;! could bring down the times to 8.5 and 6.5 cycles/limb for the PA7000 and
+;! PA7100, respectively. We don't do that since it does not seem worth the
+;! (alignment) troubles...
+
+;! At least the PA7100 is rumored to be able to deal with cache-misses
+;! without stalling instruction issue. If this is true, and the cache is
+;! actually also lockup-free, we should use a deeper software pipeline, and
+;! load from S1 very early; (The loads and stores to -12(sp) will surely be
+;! in the cache.)
+
+ .text
+ .export __mpn_mul_1
+__mpn_mul_1:
+ .proc
+ .callinfo frame=64,no_calls
+ .entry
+
+ ldo 64(%r30),%r30
+ fldws,ma 4(%r25),%fr5
+ stw %r23,-16(%r30) ;! move s2_limb ...
+ addib,= -1,%r24,L$just_one_limb
+ fldws -16(%r30),%fr4 ;! ... into fr4
+ add %r0,%r0,%r0 ;! clear carry
+ xmpyu %fr4,%fr5,%fr6
+ fldws,ma 4(%r25),%fr7
+ fstds %fr6,-16(%r30)
+ xmpyu %fr4,%fr7,%fr8
+ ldw -12(%r30),%r20 ;! least significant limb in product
+ ldw -16(%r30),%r28
+
+ fstds %fr8,-16(%r30)
+ addib,= -1,%r24,L$end
+ ldw -12(%r30),%r1
+
+;! Main loop
+L$loop:
+ fldws,ma 4(%r25),%fr5
+ stws,ma %r20,4(%r26)
+ addc %r28,%r1,%r20
+ xmpyu %fr4,%fr5,%fr6
+ ldw -16(%r30),%r28
+ fstds %fr6,-16(%r30)
+ addib,<> -1,%r24,L$loop
+ ldw -12(%r30),%r1
+
+L$end:
+ stws,ma %r20,4(%r26)
+ addc %r28,%r1,%r20
+ ldw -16(%r30),%r28
+ stws,ma %r20,4(%r26)
+ addc %r0,%r28,%r28
+ bv 0(%r2)
+ ldo -64(%r30),%r30
+
+L$just_one_limb:
+ xmpyu %fr4,%fr5,%fr6
+ fstds %fr6,-16(%r30)
+ ldw -16(%r30),%r28
+ ldo -64(%r30),%r30
+ bv 0(%r2)
+ fstws %fr6R,0(%r26)
+
+ .exit
+ .procend
diff --git a/ports/sysdeps/hppa/hppa1.1/submul_1.s b/ports/sysdeps/hppa/hppa1.1/submul_1.s
new file mode 100644
index 000000000..997bd6d52
--- /dev/null
+++ b/ports/sysdeps/hppa/hppa1.1/submul_1.s
@@ -0,0 +1,113 @@
+;! HP-PA-1.1 __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 Lesser General Public License as published by
+;! the Free Software Foundation; either version 2.1 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 Lesser General Public
+;! License for more details.
+
+;! You should have received a copy of the GNU Lesser General Public License
+;! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+;! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+;! MA 02111-1307, USA.
+
+
+;! INPUT PARAMETERS
+;! res_ptr r26
+;! s1_ptr r25
+;! size r24
+;! s2_limb r23
+
+;! This runs at 12 cycles/limb on a PA7000. With the used instructions, it
+;! can not become faster due to data cache contention after a store. On the
+;! PA7100 it runs at 11 cycles/limb, and that can not be improved either,
+;! since only the xmpyu does not need the integer pipeline, so the only
+;! dual-issue we will get are addc+xmpyu. Unrolling could gain a cycle/limb
+;! on the PA7100.
+
+;! There are some ideas described in mul_1.s that applies to this code too.
+
+;! It seems possible to make this run as fast as __mpn_addmul_1, if we use
+;! sub,>>= %r29,%r20,%r22
+;! addi 1,%r28,%r28
+;! but that requires reworking the hairy software pipeline...
+
+ .text
+ .export __mpn_submul_1
+__mpn_submul_1:
+ .proc
+ .callinfo frame=64,no_calls
+ .entry
+
+ ldo 64(%r30),%r30
+ fldws,ma 4(%r25),%fr5
+ stw %r23,-16(%r30) ;! move s2_limb ...
+ addib,= -1,%r24,L$just_one_limb
+ fldws -16(%r30),%fr4 ;! ... into fr4
+ add %r0,%r0,%r0 ;! clear carry
+ xmpyu %fr4,%fr5,%fr6
+ fldws,ma 4(%r25),%fr7
+ fstds %fr6,-16(%r30)
+ xmpyu %fr4,%fr7,%fr8
+ ldw -12(%r30),%r20 ;! least significant limb in product
+ ldw -16(%r30),%r28
+
+ fstds %fr8,-16(%r30)
+ addib,= -1,%r24,L$end
+ ldw -12(%r30),%r1
+
+;! Main loop
+L$loop:
+ ldws 0(%r26),%r29
+ fldws,ma 4(%r25),%fr5
+ sub %r29,%r20,%r22
+ add %r22,%r20,%r0
+ stws,ma %r22,4(%r26)
+ addc %r28,%r1,%r20
+ xmpyu %fr4,%fr5,%fr6
+ ldw -16(%r30),%r28
+ fstds %fr6,-16(%r30)
+ addc %r0,%r28,%r28
+ addib,<> -1,%r24,L$loop
+ ldw -12(%r30),%r1
+
+L$end:
+ ldw 0(%r26),%r29
+ sub %r29,%r20,%r22
+ add %r22,%r20,%r0
+ stws,ma %r22,4(%r26)
+ addc %r28,%r1,%r20
+ ldw -16(%r30),%r28
+ ldws 0(%r26),%r29
+ addc %r0,%r28,%r28
+ sub %r29,%r20,%r22
+ add %r22,%r20,%r0
+ stws,ma %r22,4(%r26)
+ addc %r0,%r28,%r28
+ bv 0(%r2)
+ ldo -64(%r30),%r30
+
+L$just_one_limb:
+ xmpyu %fr4,%fr5,%fr6
+ ldw 0(%r26),%r29
+ fstds %fr6,-16(%r30)
+ ldw -12(%r30),%r1
+ ldw -16(%r30),%r28
+ sub %r29,%r1,%r22
+ add %r22,%r1,%r0
+ stw %r22,0(%r26)
+ addc %r0,%r28,%r28
+ bv 0(%r2)
+ ldo -64(%r30),%r30
+
+ .exit
+ .procend
diff --git a/ports/sysdeps/hppa/hppa1.1/udiv_qrnnd.s b/ports/sysdeps/hppa/hppa1.1/udiv_qrnnd.s
new file mode 100644
index 000000000..7b83619c7
--- /dev/null
+++ b/ports/sysdeps/hppa/hppa1.1/udiv_qrnnd.s
@@ -0,0 +1,78 @@
+;! HP-PA __udiv_qrnnd division support, used from longlong.h.
+;! This version runs fast on PA 7000 and later.
+
+;! 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 Lesser General Public License as published by
+;! the Free Software Foundation; either version 2.1 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 Lesser General Public
+;! License for more details.
+
+;! You should have received a copy of the GNU Lesser General Public License
+;! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+;! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+;! MA 02111-1307, USA.
+
+
+;! INPUT PARAMETERS
+;! rem_ptr gr26
+;! n1 gr25
+;! n0 gr24
+;! d gr23
+
+ .text
+L$0000:
+ .word 0x43f00000
+ .word 0x0
+ .export __udiv_qrnnd
+__udiv_qrnnd:
+ .proc
+ .callinfo frame=64,no_calls
+ .entry
+ ldo 64(%r30),%r30
+
+ stws %r25,-16(%r30) ;! n_hi
+ stws %r24,-12(%r30) ;! n_lo
+ b,l L$0,%r1
+ ldo L$0000-L$0(%r1),%r1
+L$0:
+ fldds -16(%r30),%fr5
+ stws %r23,-12(%r30)
+ comib,<= 0,%r25,L$1
+ fcnvxf,dbl,dbl %fr5,%fr5
+ fldds 0(%r1),%fr4
+ fadd,dbl %fr4,%fr5,%fr5
+L$1:
+ fcpy,sgl %fr0,%fr6L
+ fldws -12(%r30),%fr6R
+ fcnvxf,dbl,dbl %fr6,%fr4
+
+ fdiv,dbl %fr5,%fr4,%fr5
+
+ fcnvfx,dbl,dbl %fr5,%fr4
+ fstws %fr4R,-16(%r30)
+ xmpyu %fr4R,%fr6R,%fr6
+ ldws -16(%r30),%r28
+ fstds %fr6,-16(%r30)
+ ldws -12(%r30),%r21
+ ldws -16(%r30),%r20
+ sub %r24,%r21,%r22
+ subb %r25,%r20,%r1
+ comib,= 0,%r1,L$2
+ ldo -64(%r30),%r30
+
+ add %r22,%r23,%r22
+ ldo -1(%r28),%r28
+L$2:
+ bv 0(%r2)
+ stws %r22,0(%r26)
+
+ .exit
+ .procend
diff --git a/ports/sysdeps/hppa/jmpbuf-offsets.h b/ports/sysdeps/hppa/jmpbuf-offsets.h
new file mode 100644
index 000000000..d95ed8a41
--- /dev/null
+++ b/ports/sysdeps/hppa/jmpbuf-offsets.h
@@ -0,0 +1,20 @@
+/* Private macros for accessing __jmp_buf contents. HPPA version.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define JB_SP (76/4)
diff --git a/ports/sysdeps/hppa/jmpbuf-unwind.h b/ports/sysdeps/hppa/jmpbuf-unwind.h
new file mode 100644
index 000000000..6ea1876e1
--- /dev/null
+++ b/ports/sysdeps/hppa/jmpbuf-unwind.h
@@ -0,0 +1,27 @@
+/* Examine __jmp_buf for unwinding frames. HPPA version.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame containing a local
+ variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(_jmpbuf, _address, _demangle) \
+ ((void *) (_address) > \
+ (void *) _demangle ((((unsigned long *) _jmpbuf)[JB_SP])))
diff --git a/ports/sysdeps/hppa/ldsodefs.h b/ports/sysdeps/hppa/ldsodefs.h
new file mode 100644
index 000000000..5bd788726
--- /dev/null
+++ b/ports/sysdeps/hppa/ldsodefs.h
@@ -0,0 +1,42 @@
+/* Run-time dynamic linker data structures for loaded ELF shared objects.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _HPPA_LDSODEFS_H
+#define _HPPA_LDSODEFS_H 1
+
+#include <elf.h>
+
+struct La_hppa_regs;
+struct La_hppa_retval;
+
+#define ARCH_PLTENTER_MEMBERS \
+ Elf32_Addr (*hppa_gnu_pltenter) (Elf32_Sym *, unsigned int, uintptr_t *, \
+ uintptr_t *, struct La_hppa_regs *, \
+ unsigned int *, const char *name, \
+ long int *framesizep);
+
+#define ARCH_PLTEXIT_MEMBERS \
+ unsigned int (*hppa_gnu_pltexit) (Elf32_Sym *, unsigned int, uintptr_t *, \
+ uintptr_t *, \
+ const struct La_hppa_regs *, \
+ struct La_hppa_retval *, const char *);
+
+#include_next <ldsodefs.h>
+
+#endif
diff --git a/ports/sysdeps/hppa/libc-tls.c b/ports/sysdeps/hppa/libc-tls.c
new file mode 100644
index 000000000..232f80f82
--- /dev/null
+++ b/ports/sysdeps/hppa/libc-tls.c
@@ -0,0 +1,38 @@
+/* Thread-local storage handling in the ELF dynamic linker. hppa version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <csu/libc-tls.c>
+#include <dl-tls.h>
+
+#if USE_TLS
+
+/* On hppa, linker optimizations are not required, so __tls_get_addr
+ can be called even in statically linked binaries. In this case module
+ must be always 1 and PT_TLS segment exist in the binary, otherwise it
+ would not link. */
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+ dtv_t *dtv = THREAD_DTV ();
+ return (char *) dtv[1].pointer.val + ti->ti_offset;
+}
+
+#endif
+
diff --git a/ports/sysdeps/hppa/libgcc-compat.c b/ports/sysdeps/hppa/libgcc-compat.c
new file mode 100644
index 000000000..2957eba89
--- /dev/null
+++ b/ports/sysdeps/hppa/libgcc-compat.c
@@ -0,0 +1,43 @@
+/* pre-.hidden libgcc compatibility
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Randolph Chung
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+#include <stdint.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2_6)
+
+symbol_version (__clz_tab_internal, __clz_tab, GLIBC_2.2);
+
+typedef unsigned int UQItype __attribute__ ((mode (QI)));
+
+const UQItype __clz_tab_internal[] =
+{
+ 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,
+};
+
+#endif
diff --git a/ports/sysdeps/hppa/linuxthreads/pspinlock.c b/ports/sysdeps/hppa/linuxthreads/pspinlock.c
new file mode 100644
index 000000000..e5a554522
--- /dev/null
+++ b/ports/sysdeps/hppa/linuxthreads/pspinlock.c
@@ -0,0 +1,82 @@
+/* POSIX spinlock implementation. hppa version.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ volatile unsigned int *addr = __ldcw_align (lock);
+
+ while (__ldcw (addr) == 0)
+ while (*addr == 0) ;
+
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ volatile unsigned int *a = __ldcw_align (lock);
+
+ return __ldcw (a) ? 0 : EBUSY;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ volatile unsigned int *a = __ldcw_align (lock);
+ int tmp = 1;
+ /* This should be a memory barrier to newer compilers */
+ __asm__ __volatile__ ("stw,ma %1,0(%0)"
+ : : "r" (a), "r" (tmp) : "memory");
+ return 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ volatile unsigned int *a = __ldcw_align (lock);
+ int tmp = 1;
+ /* This should be a memory barrier to newer compilers */
+ __asm__ __volatile__ ("stw,ma %1,0(%0)"
+ : : "r" (a), "r" (tmp) : "memory");
+ return 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/ports/sysdeps/hppa/linuxthreads/pt-machine.h b/ports/sysdeps/hppa/linuxthreads/pt-machine.h
new file mode 100644
index 000000000..f35523f0f
--- /dev/null
+++ b/ports/sysdeps/hppa/linuxthreads/pt-machine.h
@@ -0,0 +1,134 @@
+/* Machine-dependent pthreads configuration and inline functions.
+ hppa version.
+ Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@tamu.edu>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#include <sys/types.h>
+#include <bits/initspin.h>
+
+#ifndef PT_EI
+# define PT_EI extern inline __attribute__ ((always_inline))
+#endif
+
+extern inline long int testandset (__atomic_lock_t *spinlock);
+extern inline int __compare_and_swap (long int *p, long int oldval, long int newval);
+extern inline int lock_held (__atomic_lock_t *spinlock);
+extern inline int __load_and_clear (__atomic_lock_t *spinlock);
+
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME stack_pointer
+register char * stack_pointer __asm__ ("%r30");
+
+/* Get/Set thread-specific pointer. We have to call into the kernel to
+ * modify it, but we can read it in user mode. */
+#ifndef THREAD_SELF
+#define THREAD_SELF __get_cr27()
+#endif
+
+#ifndef SET_THREAD_SELF
+#define SET_THREAD_SELF(descr) __set_cr27(descr)
+#endif
+/* Use this to determine type */
+struct _pthread_descr_struct *__thread_self;
+
+static inline struct _pthread_descr_struct * __get_cr27(void)
+{
+ long cr27;
+ asm ("mfctl %%cr27, %0" : "=r" (cr27) : );
+ return (struct _pthread_descr_struct *) cr27;
+}
+
+#ifndef INIT_THREAD_SELF
+#define INIT_THREAD_SELF(descr, nr) __set_cr27(descr)
+#endif
+
+static inline void __set_cr27(struct _pthread_descr_struct * cr27)
+{
+ asm ( "ble 0xe0(%%sr2, %%r0)\n\t"
+ "copy %0, %%r26"
+ : : "r" (cr27) : "r26" );
+}
+
+/* We want the OS to assign stack addresses. */
+#define FLOATING_STACKS 1
+#define ARCH_STACK_MAX_SIZE 8*1024*1024
+
+/* The hppa only has one atomic read and modify memory operation,
+ load and clear, so hppa spinlocks must use zero to signify that
+ someone is holding the lock. The address used for the ldcw
+ semaphore must be 16-byte aligned. */
+#define __ldcw(a) \
+({ \
+ unsigned int __ret; \
+ __asm__ __volatile__("ldcw 0(%1),%0" \
+ : "=r" (__ret) : "r" (a) : "memory"); \
+ __ret; \
+})
+
+/* Strongly ordered lock reset */
+#define __lock_reset(lock_addr, tmp) \
+({ \
+ __asm__ __volatile__ ("stw,ma %1,0(%0)" \
+ : : "r" (lock_addr), "r" (tmp) : "memory"); \
+})
+
+/* Because malloc only guarantees 8-byte alignment for malloc'd data,
+ and GCC only guarantees 8-byte alignment for stack locals, we can't
+ be assured of 16-byte alignment for atomic lock data even if we
+ specify "__attribute ((aligned(16)))" in the type declaration. So,
+ we use a struct containing an array of four ints for the atomic lock
+ type and dynamically select the 16-byte aligned int from the array
+ for the semaphore. */
+#define __PA_LDCW_ALIGNMENT 16
+#define __ldcw_align(a) ({ \
+ volatile unsigned int __ret = (unsigned int) a; \
+ if ((__ret & ~(__PA_LDCW_ALIGNMENT - 1)) < (unsigned int) a) \
+ __ret = (__ret & ~(__PA_LDCW_ALIGNMENT - 1)) + __PA_LDCW_ALIGNMENT; \
+ (unsigned int *) __ret; \
+})
+
+/* Spinlock implementation; required. */
+PT_EI int
+__load_and_clear (__atomic_lock_t *spinlock)
+{
+ volatile unsigned int *a = __ldcw_align (spinlock);
+
+ return __ldcw (a);
+}
+
+/* Emulate testandset */
+PT_EI long int
+testandset (__atomic_lock_t *spinlock)
+{
+ return (__load_and_clear(spinlock) == 0);
+}
+
+PT_EI int
+lock_held (__atomic_lock_t *spinlock)
+{
+ volatile unsigned int *a = __ldcw_align (spinlock);
+
+ return *a == 0;
+}
+
+#endif /* pt-machine.h */
diff --git a/ports/sysdeps/hppa/linuxthreads/tls.h b/ports/sysdeps/hppa/linuxthreads/tls.h
new file mode 100644
index 000000000..3d33a1892
--- /dev/null
+++ b/ports/sysdeps/hppa/linuxthreads/tls.h
@@ -0,0 +1,163 @@
+/* Definition for thread-local data handling. linuxthreads/hppa version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+#ifndef __ASSEMBLER__
+# include <pt-machine.h>
+# include <stdbool.h>
+# include <stddef.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+
+#if defined HAVE_TLS_SUPPORT
+
+/* Signal that TLS support is available. */
+# define USE_TLS 1
+
+# ifndef __ASSEMBLER__
+
+typedef struct
+{
+ dtv_t *dtv;
+ void *private;
+} tcbhead_t;
+
+/* Include some syscall information for other headers */
+# include <sysdep.h>
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
+
+/* The TLS blocks start right after the TCB. */
+# define TLS_DTV_AT_TP 1
+
+/* Return the thread descriptor for the current thread. */
+# undef THREAD_SELF
+# define THREAD_SELF \
+ ({ struct _pthread_descr_struct *__self; \
+ __self = __get_cr27(); \
+ __self - 1; \
+ })
+
+# undef INIT_THREAD_SELF
+# define INIT_THREAD_SELF(descr, nr) \
+ ({ struct _pthread_descr_struct *__self = (void *)descr; \
+ __set_cr27(__self + 1); \
+ 0; \
+ })
+
+/* Access to data in the thread descriptor is easy. */
+#define THREAD_GETMEM(descr, member) \
+ ((void) sizeof (descr), THREAD_SELF->member)
+#define THREAD_GETMEM_NC(descr, member) \
+ ((void) sizeof (descr), THREAD_SELF->member)
+#define THREAD_SETMEM(descr, member, value) \
+ ((void) sizeof (descr), THREAD_SELF->member = (value))
+#define THREAD_SETMEM_NC(descr, member, value) \
+ ((void) sizeof (descr), THREAD_SELF->member = (value))
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(tcbp, dtvp) \
+ ((tcbhead_t *) (tcbp))->dtv = dtvp + 1
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtv) \
+ ({ tcbhead_t *__tcbp = (tcbhead_t *)__get_cr27(); \
+ __tcbp->dtv = dtv; \
+ })
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(tcbp) \
+ (((tcbhead_t *) (tcbp))->dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(tcbp, secondcall) \
+ ({ __set_cr27(tcbp); 0; })
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ ({ tcbhead_t *__tcbp = (tcbhead_t *)__get_cr27(); \
+ __tcbp->dtv; \
+ })
+
+# define TLS_MULTIPLE_THREADS_IN_TCB 1
+
+/* Get the thread descriptor definition. This must be after the
+ the definition of THREAD_SELF for TLS. */
+# include <linuxthreads/descr.h>
+
+# endif /* __ASSEMBLER__ */
+
+#else
+
+# ifndef __ASSEMBLER__
+
+typedef struct
+{
+ void *tcb;
+ dtv_t *dtv;
+ void *self;
+ int multiple_threads;
+} tcbhead_t;
+
+/* Get the thread descriptor definition. */
+# include <linuxthreads/descr.h>
+
+# define NONTLS_INIT_TP \
+ do { \
+ static const tcbhead_t nontls_init_tp = { .multiple_threads = 0 }; \
+ INIT_THREAD_SELF(&nontls_init_tp, 0); \
+ } while (0)
+
+# endif /* __ASSEMBLER__ */
+
+#endif /* HAVE_TLS_SUPPORT */
+
+#endif /* tls.h */
diff --git a/ports/sysdeps/hppa/lshift.s b/ports/sysdeps/hppa/lshift.s
new file mode 100644
index 000000000..151b283e5
--- /dev/null
+++ b/ports/sysdeps/hppa/lshift.s
@@ -0,0 +1,66 @@
+;! HP-PA __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 Lesser General Public License as published by
+;! the Free Software Foundation; either version 2.1 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 Lesser General Public
+;! License for more details.
+
+;! You should have received a copy of the GNU Lesser General Public License
+;! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+;! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+;! MA 02111-1307, USA.
+
+
+;! INPUT PARAMETERS
+;! res_ptr gr26
+;! s_ptr gr25
+;! size gr24
+;! cnt gr23
+
+ .text
+ .export __mpn_lshift
+__mpn_lshift:
+ .proc
+ .callinfo frame=64,no_calls
+ .entry
+
+ sh2add %r24,%r25,%r25
+ sh2add %r24,%r26,%r26
+ ldws,mb -4(%r25),%r22
+ subi 32,%r23,%r1
+ mtsar %r1
+ addib,= -1,%r24,L$0004
+ vshd %r0,%r22,%r28 ;! compute carry out limb
+ ldws,mb -4(%r25),%r29
+ addib,= -1,%r24,L$0002
+ vshd %r22,%r29,%r20
+
+L$loop: ldws,mb -4(%r25),%r22
+ stws,mb %r20,-4(%r26)
+ addib,= -1,%r24,L$0003
+ vshd %r29,%r22,%r20
+ ldws,mb -4(%r25),%r29
+ stws,mb %r20,-4(%r26)
+ addib,<> -1,%r24,L$loop
+ vshd %r22,%r29,%r20
+
+L$0002: stws,mb %r20,-4(%r26)
+ vshd %r29,%r0,%r20
+ bv 0(%r2)
+ stw %r20,-4(%r26)
+L$0003: stws,mb %r20,-4(%r26)
+L$0004: vshd %r22,%r0,%r20
+ bv 0(%r2)
+ stw %r20,-4(%r26)
+
+ .exit
+ .procend
diff --git a/ports/sysdeps/hppa/machine-gmon.h b/ports/sysdeps/hppa/machine-gmon.h
new file mode 100644
index 000000000..3eeef6737
--- /dev/null
+++ b/ports/sysdeps/hppa/machine-gmon.h
@@ -0,0 +1,25 @@
+/* Machine-specific calling sequence for `mcount' profiling function. PA-RISC
+ Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* We can call _mcount directly since gcc supplies the correct
+ * arguments */
+#define _MCOUNT_DECL(from, self) \
+ void _mcount (u_long from, u_long self)
+
+#define MCOUNT
diff --git a/ports/sysdeps/hppa/memusage.h b/ports/sysdeps/hppa/memusage.h
new file mode 100644
index 000000000..d3dd10e10
--- /dev/null
+++ b/ports/sysdeps/hppa/memusage.h
@@ -0,0 +1,22 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define GETSP() ({ register uintptr_t stack_ptr asm ("%r30"); stack_ptr; })
+#define STACK_GROWS_UPWARD 1
+
+#include <sysdeps/generic/memusage.h>
diff --git a/ports/sysdeps/hppa/mp_clz_tab.c b/ports/sysdeps/hppa/mp_clz_tab.c
new file mode 100644
index 000000000..52d06383c
--- /dev/null
+++ b/ports/sysdeps/hppa/mp_clz_tab.c
@@ -0,0 +1 @@
+/* __clz_tab not needed on hppa. */
diff --git a/ports/sysdeps/hppa/nptl/Makefile b/ports/sysdeps/hppa/nptl/Makefile
new file mode 100644
index 000000000..030069378
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/Makefile
@@ -0,0 +1,21 @@
+# Copyright (C) 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+ifeq ($(subdir),csu)
+gen-as-const-headers += tcb-offsets.sym
+endif
diff --git a/ports/sysdeps/hppa/nptl/jmpbuf-unwind.h b/ports/sysdeps/hppa/nptl/jmpbuf-unwind.h
new file mode 100644
index 000000000..7f92627f9
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/jmpbuf-unwind.h
@@ -0,0 +1,31 @@
+/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <setjmp.h>
+#include <jmpbuf-offsets.h>
+#include <stdint.h>
+#include <unwind.h>
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) > (uintptr_t)(((unsigned long *) _jmpbuf)[JB_SP]) - (_adj))
+
+/* We use the normal longjmp for unwinding. */
+#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
diff --git a/ports/sysdeps/hppa/nptl/pthread_spin_lock.c b/ports/sysdeps/hppa/nptl/pthread_spin_lock.c
new file mode 100644
index 000000000..966f5c918
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/pthread_spin_lock.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <atomic.h>
+#include "pthreadP.h"
+
+int
+pthread_spin_lock (pthread_spinlock_t *lock)
+{
+#if 0
+ volatile unsigned int *addr = __ldcw_align (lock);
+
+ while (__ldcw (addr) == 0)
+ while (*addr == 0) ;
+
+ return 0;
+#endif
+
+ while (atomic_compare_and_exchange_val_acq(lock, 1, 0) == 1)
+ while (*lock == 1);
+
+ return 0;
+}
diff --git a/ports/sysdeps/hppa/nptl/pthread_spin_trylock.c b/ports/sysdeps/hppa/nptl/pthread_spin_trylock.c
new file mode 100644
index 000000000..609a62f62
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/pthread_spin_trylock.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <atomic.h>
+#include "pthreadP.h"
+
+int
+pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+#if 0
+ volatile unsigned int *a = __ldcw_align (lock);
+
+ return __ldcw (a) ? 0 : EBUSY;
+#endif
+
+ return atomic_compare_and_exchange_val_acq(lock, 1, 0) ? EBUSY : 0;
+
+}
diff --git a/ports/sysdeps/hppa/nptl/pthread_spin_unlock.c b/ports/sysdeps/hppa/nptl/pthread_spin_unlock.c
new file mode 100644
index 000000000..463d23c97
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/pthread_spin_unlock.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Ugly hack to avoid the declaration of pthread_spin_init. */
+#define pthread_spin_init pthread_spin_init_XXX
+#include "pthreadP.h"
+#undef pthread_spin_init
+
+int
+pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+#if 0
+ volatile unsigned int *a = __ldcw_align (lock);
+#endif
+ int tmp = 0;
+ /* This should be a memory barrier to newer compilers */
+ __asm__ __volatile__ ("stw,ma %1,0(%0)"
+ : : "r" (lock), "r" (tmp) : "memory");
+ return 0;
+}
+strong_alias (pthread_spin_unlock, pthread_spin_init)
diff --git a/ports/sysdeps/hppa/nptl/pthreaddef.h b/ports/sysdeps/hppa/nptl/pthreaddef.h
new file mode 100644
index 000000000..6445f7bb0
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/pthreaddef.h
@@ -0,0 +1,40 @@
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (8 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. */
+#define STACK_ALIGN 64
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB, note that this must be larger than STACK_ALIGN */
+#define TCB_ALIGNMENT STACK_ALIGN
+
+
+/* Location of current stack frame. */
+#define CURRENT_STACK_FRAME stack_pointer
+register char * stack_pointer __asm__ ("%r30");
+
+
+/* XXX Until we have a better place keep the definitions here. */
+
+#define __exit_thread_inline(val) \
+ INLINE_SYSCALL (exit, 1, (val))
diff --git a/ports/sysdeps/hppa/nptl/tcb-offsets.sym b/ports/sysdeps/hppa/nptl/tcb-offsets.sym
new file mode 100644
index 000000000..1c8aef4c5
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/tcb-offsets.sym
@@ -0,0 +1,18 @@
+#include <sysdep.h>
+#include <tls.h>
+
+RESULT offsetof (struct pthread, result)
+TID offsetof (struct pthread, tid)
+PID offsetof (struct pthread, pid)
+CANCELHANDLING offsetof (struct pthread, cancelhandling)
+CLEANUP_JMP_BUF offsetof (struct pthread, cleanup_jmp_buf)
+MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads)
+TLS_PRE_TCB_SIZE sizeof (struct pthread)
+MUTEX_FUTEX offsetof (pthread_mutex_t, __data.__lock)
+
+-- Use a thread_offset when working with asm to make things simpler
+-- This way we get the offset of a member in the struct pthread that
+-- preceeds the thread pointer (which points to the dtv).
+#define thread_offsetof(mem) (unsigned int)(offsetof(struct pthread, mem) - sizeof(struct pthread))
+PID_THREAD_OFFSET thread_offsetof (pid)
+MULTIPLE_THREADS_THREAD_OFFSET thread_offsetof (header.multiple_threads)
diff --git a/ports/sysdeps/hppa/nptl/tls.h b/ports/sysdeps/hppa/nptl/tls.h
new file mode 100644
index 000000000..0759aec8f
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/tls.h
@@ -0,0 +1,151 @@
+/* Definition for thread-local data handling. NPTL/hppa version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _TLS_H
+#define _TLS_H 1
+
+#include <dl-sysdep.h>
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+
+/* We require TLS support in the tools. */
+#ifndef HAVE_TLS_SUPPORT
+# error "TLS support is required."
+#endif
+
+/* Signal that TLS support is available. */
+#define USE_TLS 1
+
+#ifndef __ASSEMBLER__
+
+/* Get system call information. */
+# include <sysdep.h>
+
+/* The TP points to the start of the thread blocks. */
+# define TLS_DTV_AT_TP 1
+
+/* Get the thread descriptor definition. */
+# include <nptl/descr.h>
+
+typedef struct
+{
+ dtv_t *dtv;
+ void *private;
+} tcbhead_t;
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (struct pthread)
+
+/* This is the size we need before TCB */
+# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(tcbp, dtvp) \
+ ((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtv) \
+ ({ tcbhead_t *__tcbp = (tcbhead_t *)__get_cr27(); \
+ __tcbp->dtv = dtv; \
+ })
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(tcbp) \
+ (((tcbhead_t *) (tcbp))->dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(tcbp, secondcall) \
+ ({ __set_cr27(tcbp); NULL; })
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ ({ tcbhead_t *__tcbp = (tcbhead_t *)__get_cr27(); \
+ __tcbp->dtv; \
+ })
+
+/* Return the thread descriptor for the current thread. */
+# define THREAD_SELF \
+ ({ struct pthread *__self; \
+ __self = __get_cr27(); \
+ __self - 1; \
+ })
+
+/* FIXME */
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF \
+ REGISTER (32, 32, 32 * 4, -sizeof (struct pthread))
+
+/* Access to data in the thread descriptor is easy. */
+# define THREAD_GETMEM(descr, member) \
+ descr->member
+# define THREAD_GETMEM_NC(descr, member, idx) \
+ descr->member[idx]
+# define THREAD_SETMEM(descr, member, value) \
+ descr->member = (value)
+# define THREAD_SETMEM_NC(descr, member, idx, value) \
+ descr->member[idx] = (value)
+
+static inline struct pthread *__get_cr27(void)
+{
+ long cr27;
+ asm ("mfctl %%cr27, %0" : "=r" (cr27) : );
+ return (struct pthread *) cr27;
+}
+
+static inline void __set_cr27(struct pthread *cr27)
+{
+ asm ( "ble 0xe0(%%sr2, %%r0)\n\t"
+ "copy %0, %%r26"
+ : : "r" (cr27) : "r26" );
+}
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/ports/sysdeps/hppa/preconfigure b/ports/sysdeps/hppa/preconfigure
new file mode 100644
index 000000000..4d7fdcd03
--- /dev/null
+++ b/ports/sysdeps/hppa/preconfigure
@@ -0,0 +1,6 @@
+# This fragment canonicalizes the machine names for hppa variants.
+
+case "$machine" in
+hppa*64*) base_machine=hppa machine=hppa/hppa64 ;;
+hppa*) base_machine=hppa machine=hppa/hppa1.1 ;;
+esac
diff --git a/ports/sysdeps/hppa/rshift.s b/ports/sysdeps/hppa/rshift.s
new file mode 100644
index 000000000..dff189dc4
--- /dev/null
+++ b/ports/sysdeps/hppa/rshift.s
@@ -0,0 +1,63 @@
+;! HP-PA __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 Lesser General Public License as published by
+;! the Free Software Foundation; either version 2.1 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 Lesser General Public
+;! License for more details.
+
+;! You should have received a copy of the GNU Lesser General Public License
+;! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+;! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+;! MA 02111-1307, USA.
+
+
+;! INPUT PARAMETERS
+;! res_ptr gr26
+;! s_ptr gr25
+;! size gr24
+;! cnt gr23
+
+ .text
+ .export __mpn_rshift
+__mpn_rshift:
+ .proc
+ .callinfo frame=64,no_calls
+ .entry
+
+ ldws,ma 4(%r25),%r22
+ mtsar %r23
+ addib,= -1,%r24,L$0004
+ vshd %r22,%r0,%r28 ;! compute carry out limb
+ ldws,ma 4(%r25),%r29
+ addib,= -1,%r24,L$0002
+ vshd %r29,%r22,%r20
+
+L$loop: ldws,ma 4(%r25),%r22
+ stws,ma %r20,4(%r26)
+ addib,= -1,%r24,L$0003
+ vshd %r22,%r29,%r20
+ ldws,ma 4(%r25),%r29
+ stws,ma %r20,4(%r26)
+ addib,<> -1,%r24,L$loop
+ vshd %r29,%r22,%r20
+
+L$0002: stws,ma %r20,4(%r26)
+ vshd %r0,%r29,%r20
+ bv 0(%r2)
+ stw %r20,0(%r26)
+L$0003: stws,ma %r20,4(%r26)
+L$0004: vshd %r0,%r22,%r20
+ bv 0(%r2)
+ stw %r20,0(%r26)
+
+ .exit
+ .procend
diff --git a/ports/sysdeps/hppa/setjmp.S b/ports/sysdeps/hppa/setjmp.S
new file mode 100644
index 000000000..0da34db6f
--- /dev/null
+++ b/ports/sysdeps/hppa/setjmp.S
@@ -0,0 +1,69 @@
+/* setjmp for HPPA.
+ Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _ASM
+#define _SETJMP_H
+#include <bits/setjmp.h>
+
+
+ .text
+ .align 4
+ .import __sigjmp_save, code
+ .globl __sigsetjmp
+ .export __sigsetjmp, code
+ .proc
+ .callinfo
+__sigsetjmp:
+ stw %r3, 0(%r26)
+ stw %r4, 8(%r26)
+ stw %r5, 12(%r26)
+ stw %r6, 16(%r26)
+ stw %r7, 20(%r26)
+ stw %r8, 24(%r26)
+ stw %r9, 28(%r26)
+ stw %r10, 32(%r26)
+ stw %r11, 36(%r26)
+ stw %r12, 40(%r26)
+ stw %r13, 44(%r26)
+ stw %r14, 48(%r26)
+ stw %r15, 52(%r26)
+ stw %r16, 56(%r26)
+ stw %r17, 60(%r26)
+ stw %r18, 64(%r26)
+ stw %r19, 68(%r26)
+ stw %r27, 72(%r26)
+ stw %r30, 76(%r26)
+
+ stw %rp, 80(%r26)
+
+ ldo 88(%r26),%r1
+ fstds,ma %fr12, 8(%r1) /* 88 */
+ fstds,ma %fr13, 8(%r1) /* 96 */
+ fstds,ma %fr14, 8(%r1) /* 104 */
+ fstds,ma %fr15, 8(%r1) /* 112 */
+ fstds,ma %fr16, 8(%r1) /* 120 */
+ fstds,ma %fr17, 8(%r1) /* 128 */
+ fstds,ma %fr18, 8(%r1) /* 136 */
+ fstds,ma %fr19, 8(%r1) /* 144 */
+ fstds,ma %fr20, 8(%r1) /* 152 */
+ fstds %fr21, 0(%r1) /* 160 */
+ b __sigjmp_save
+ nop
+ .procend
diff --git a/ports/sysdeps/hppa/shlib-versions b/ports/sysdeps/hppa/shlib-versions
new file mode 100644
index 000000000..5a1a865a2
--- /dev/null
+++ b/ports/sysdeps/hppa/shlib-versions
@@ -0,0 +1,7 @@
+hppa.*-.*-.* libm=6 GLIBC_2.2
+
+hppa.*-.*-.* libc=6 GLIBC_2.2
+
+hppa.*-.*-.* ld=ld.so.1 GLIBC_2.2
+
+hppa-.*-.* libBrokenLocale=1 GLIBC_2.2
diff --git a/ports/sysdeps/hppa/stackinfo.h b/ports/sysdeps/hppa/stackinfo.h
new file mode 100644
index 000000000..318de7143
--- /dev/null
+++ b/ports/sysdeps/hppa/stackinfo.h
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file contains a bit of information about the stack allocation
+ of the processor. */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+/* On PA the stack grows up. */
+#define _STACK_GROWS_UP 1
+
+#endif /* stackinfo.h */
diff --git a/ports/sysdeps/hppa/sub_n.s b/ports/sysdeps/hppa/sub_n.s
new file mode 100644
index 000000000..7764961a2
--- /dev/null
+++ b/ports/sysdeps/hppa/sub_n.s
@@ -0,0 +1,59 @@
+;! HP-PA __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 Lesser General Public License as published by
+;! the Free Software Foundation; either version 2.1 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 Lesser General Public
+;! License for more details.
+
+;! You should have received a copy of the GNU Lesser General Public License
+;! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+;! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+;! MA 02111-1307, USA.
+
+
+;! INPUT PARAMETERS
+;! res_ptr gr26
+;! s1_ptr gr25
+;! s2_ptr gr24
+;! size gr23
+
+;! One might want to unroll this as for other processors, but it turns
+;! out that the data cache contention after a store makes such
+;! unrolling useless. We can't come under 5 cycles/limb anyway.
+
+ .text
+ .export __mpn_sub_n
+__mpn_sub_n:
+ .proc
+ .callinfo frame=0,no_calls
+ .entry
+
+ ldws,ma 4(%r25),%r21
+ ldws,ma 4(%r24),%r20
+
+ addib,= -1,%r23,L$end ;! check for (SIZE == 1)
+ sub %r21,%r20,%r28 ;! subtract first limbs ignoring cy
+
+L$loop: ldws,ma 4(%r25),%r21
+ ldws,ma 4(%r24),%r20
+ stws,ma %r28,4(%r26)
+ addib,<> -1,%r23,L$loop
+ subb %r21,%r20,%r28
+
+L$end: stws %r28,0(%r26)
+ addc %r0,%r0,%r28
+ bv 0(%r2)
+ subi 1,%r28,%r28
+
+ .exit
+ .procend
diff --git a/ports/sysdeps/hppa/sysdep.h b/ports/sysdeps/hppa/sysdep.h
new file mode 100644
index 000000000..5d02f37da
--- /dev/null
+++ b/ports/sysdeps/hppa/sysdep.h
@@ -0,0 +1,77 @@
+/* Assembler macros for HP/PA.
+ Copyright (C) 1999, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper, <drepper@cygnus.com>, August 1999.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdeps/generic/sysdep.h>
+#include <sys/syscall.h>
+#include "config.h"
+
+#undef ASM_LINE_SEP
+#define ASM_LINE_SEP !
+
+#ifdef __ASSEMBLER__
+
+/* Syntactic details of assembler. */
+
+#define ALIGNARG(log2) log2
+
+
+/* Define an entry point visible from C.
+
+ There is currently a bug in gdb which prevents us from specifying
+ incomplete stabs information. Fake some entries here which specify
+ the current source file. */
+#define ENTRY(name) \
+ .SPACE $TEXT$ ASM_LINE_SEP \
+ .SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY ASM_LINE_SEP \
+ .align ALIGNARG(4) ASM_LINE_SEP \
+ .NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY ASM_LINE_SEP \
+ .EXPORT C_SYMBOL_NAME(name),ENTRY,PRIV_LEV=3,ARGW0=GR,RTNVAL=GR ASM_LINE_SEP\
+ C_LABEL(name) \
+ CALL_MCOUNT
+
+#undef END
+#define END(name) \
+ .PROCEND
+
+/* GCC does everything for us. */
+#ifdef PROF
+#define CALL_MCOUNT
+#else
+#define CALL_MCOUNT /* Do nothing. */
+#endif
+
+#define PSEUDO(name, syscall_name, args) \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args)
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) \
+ END (name)
+
+#undef JUMPTARGET
+#define JUMPTARGET(name) name
+#define SYSCALL_PIC_SETUP /* Nothing. */
+
+/* Local label name for asm code. */
+#ifndef L
+#define L(name) name
+#endif
+
+#endif /* __ASSEMBLER__ */
diff --git a/ports/sysdeps/hppa/tls-macros.h b/ports/sysdeps/hppa/tls-macros.h
new file mode 100644
index 000000000..f5a1cd8f3
--- /dev/null
+++ b/ports/sysdeps/hppa/tls-macros.h
@@ -0,0 +1,115 @@
+/* TLS Access Macros for HP PARISC Linux */
+
+/* HPPA Local Exec TLS access. */
+#define TLS_LE(x) \
+ ({ int * __result; \
+ unsigned long __tmp; \
+ asm ( \
+ " mfctl %%cr27, %1\n" \
+ " addil LR'" #x "-$tls_leoff$, %1\n" \
+ " ldo RR'" #x "-$tls_leoff$(%%r1), %0\n" \
+ : "=r" (__result), "=r" (__tmp) \
+ : \
+ : "r1" ); \
+ __result; \
+ })
+
+/* HPPA Initial Exec TLS access. */
+#ifdef PIC
+# define TLS_IE(x) \
+ ({ int * __result; \
+ unsigned long __tmp, __tmp2; \
+ asm ( \
+ " mfctl %%cr27, %1\n" \
+ " addil LT'" #x "-$tls_ieoff$, %%r19\n" \
+ " ldw RT'" #x "-$tls_ieoff$(%%r1), %2\n" \
+ " add %1, %2, %0\n" \
+ : "=r" (__result), "=r" (__tmp), "=r" (__tmp2) \
+ : \
+ : "r1" ); \
+ __result; \
+ })
+#else
+# define TLS_IE(x) \
+ ({ int * __result; \
+ unsigned long __tmp, __tmp2; \
+ asm ( \
+ " mfctl %%cr27, %1\n" \
+ " addil LR'" #x "-$tls_ieoff$, %%r27\n" \
+ " ldw RR'" #x "-$tls_ieoff$(%%r1), %2\n" \
+ " add %1, %2, %0\n" \
+ : "=r" (__result), "=r" (__tmp), "=r" (__tmp2) \
+ : \
+ : "r1" ); \
+ __result; \
+ })
+#endif
+
+#ifdef PIC
+/* HPPA Local Dynamic TLS access. */
+# define TLS_LD(x) \
+ ({ int * __result; \
+ asm ( \
+ " copy %%r19, %%r4\n" \
+ " addil LT'" #x "-$tls_ldidx$, %%r19\n" \
+ " bl __tls_get_addr, %%r2\n" \
+ " ldo RT'" #x "-$tls_ldidx$(%%r1), %%r26\n" \
+ " addil LR'" #x "-$tls_dtpoff$, %%r28\n" \
+ " ldo RR'" #x "-$tls_dtpoff$(%%r1), %0\n" \
+ " copy %%r4, %%r19\n" \
+ : "=r" (__result) \
+ : \
+ : "r1", "r2", "r4", "r20", "r21", "r22", "r23", "r24", \
+ "r25", "r26", "r28", "r29", "r31" ); \
+ __result; \
+ })
+#else
+# define TLS_LD(x) \
+ ({ int * __result; \
+ asm ( \
+ " addil LR'" #x "-$tls_ldidx$, %%r27\n" \
+ " bl __tls_get_addr, %%r2\n" \
+ " ldo RR'" #x "-$tls_ldidx$(%%r1), %%r26\n" \
+ " addil LR'" #x "-$tls_dtpoff$, %%r28\n" \
+ " ldo RR'" #x "-$tls_dtpoff$(%%r1), %0\n" \
+ : "=r" (__result) \
+ : \
+ : "r1", "r2", "r20", "r21", "r22", "r23", "r24", \
+ "r25", "r26", "r28", "r29", "r31" ); \
+ __result; \
+ })
+#endif
+
+/* HPPA General Dynamic TLS access. */
+#ifdef PIC
+# define TLS_GD(x) \
+ ({ int * __result; \
+ asm ( \
+ " copy %%r19, %%r4\n" \
+ " addil LT'" #x "-$tls_gdidx$, %%r19\n" \
+ " bl __tls_get_addr, %%r2\n" \
+ " ldo RT'" #x "-$tls_gdidx$(%%r1), %%r26\n" \
+ " copy %%r28, %0\n" \
+ " copy %%r4, %%r19\n" \
+ : "=r" (__result) \
+ : \
+ : "r1", "r2", "r4", "r20", "r21", "r22", "r23", "r24", \
+ "r25", "r26", "r28", "r29", "r31" ); \
+ __result; \
+ })
+#else
+# define TLS_GD(x) \
+ ({ int * __result; \
+ asm ( \
+ " addil LR'" #x "-$tls_gdidx$, %%r27\n" \
+ " bl __tls_get_addr, %%r2\n" \
+ " ldo RR'" #x "-$tls_gdidx$(%%r1), %%r26\n" \
+ " copy %%r28, %0\n" \
+ : "=r" (__result) \
+ : \
+ : "r1", "r2", "r20", "r21", "r22", "r23", "r24", \
+ "r25", "r26", "r28", "r29", "r31" ); \
+ __result; \
+ })
+#endif
+
diff --git a/ports/sysdeps/hppa/tst-audit.h b/ports/sysdeps/hppa/tst-audit.h
new file mode 100644
index 000000000..93b459225
--- /dev/null
+++ b/ports/sysdeps/hppa/tst-audit.h
@@ -0,0 +1,26 @@
+/* Definitions for testing PLT entry/exit auditing. HP-PARISC version.
+
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define pltenter la_hppa_gnu_pltenter
+#define pltexit la_hppa_gnu_pltexit
+#define La_regs La_hppa_regs
+#define La_retval La_hppa_retval
+#define int_retval lrv_r28
diff --git a/ports/sysdeps/hppa/udiv_qrnnd.s b/ports/sysdeps/hppa/udiv_qrnnd.s
new file mode 100644
index 000000000..8e9c07a20
--- /dev/null
+++ b/ports/sysdeps/hppa/udiv_qrnnd.s
@@ -0,0 +1,286 @@
+;! HP-PA __udiv_qrnnd division support, used from longlong.h.
+;! This version runs fast on pre-PA7000 CPUs.
+
+;! 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 Lesser General Public License as published by
+;! the Free Software Foundation; either version 2.1 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 Lesser General Public
+;! License for more details.
+
+;! You should have received a copy of the GNU Lesser General Public License
+;! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+;! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+;! MA 02111-1307, USA.
+
+
+;! INPUT PARAMETERS
+;! rem_ptr gr26
+;! n1 gr25
+;! n0 gr24
+;! d gr23
+
+;! The code size is a bit excessive. We could merge the last two ds;addc
+;! sequences by simply moving the "bb,< Odd" instruction down. The only
+;! trouble is the FFFFFFFF code that would need some hacking.
+
+ .text
+ .export __udiv_qrnnd
+__udiv_qrnnd:
+ .proc
+ .callinfo frame=0,no_calls
+ .entry
+
+ comb,< %r23,%r0,L$largedivisor
+ sub %r0,%r23,%r1 ;! clear cy as side-effect
+ ds %r0,%r1,%r0
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r23,%r25
+ addc %r24,%r24,%r28
+ ds %r25,%r23,%r25
+ comclr,>= %r25,%r0,%r0
+ addl %r25,%r23,%r25
+ stws %r25,0(%r26)
+ bv 0(%r2)
+ addc %r28,%r28,%r28
+
+L$largedivisor:
+ extru %r24,31,1,%r20 ;! r20 = n0 & 1
+ bb,< %r23,31,L$odd
+ extru %r23,30,31,%r22 ;! r22 = d >> 1
+ shd %r25,%r24,1,%r24 ;! r24 = new n0
+ extru %r25,30,31,%r25 ;! r25 = new n1
+ sub %r0,%r22,%r21
+ ds %r0,%r21,%r0
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ comclr,>= %r25,%r0,%r0
+ addl %r25,%r22,%r25
+ sh1addl %r25,%r20,%r25
+ stws %r25,0(%r26)
+ bv 0(%r2)
+ addc %r24,%r24,%r28
+
+L$odd: addib,sv,n 1,%r22,L$FF.. ;! r22 = (d / 2 + 1)
+ shd %r25,%r24,1,%r24 ;! r24 = new n0
+ extru %r25,30,31,%r25 ;! r25 = new n1
+ sub %r0,%r22,%r21
+ ds %r0,%r21,%r0
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r24
+ ds %r25,%r22,%r25
+ addc %r24,%r24,%r28
+ comclr,>= %r25,%r0,%r0
+ addl %r25,%r22,%r25
+ sh1addl %r25,%r20,%r25
+;! We have computed (n1,,n0) / (d + 1), q' = r28, r' = r25
+ add,nuv %r28,%r25,%r25
+ addl %r25,%r1,%r25
+ addc %r0,%r28,%r28
+ sub,<< %r25,%r23,%r0
+ addl %r25,%r1,%r25
+ stws %r25,0(%r26)
+ bv 0(%r2)
+ addc %r0,%r28,%r28
+
+;! This is just a special case of the code above.
+;! We come here when d == 0xFFFFFFFF
+L$FF..: add,uv %r25,%r24,%r24
+ sub,<< %r24,%r23,%r0
+ ldo 1(%r24),%r24
+ stws %r24,0(%r26)
+ bv 0(%r2)
+ addc %r0,%r25,%r28
+
+ .exit
+ .procend
diff --git a/ports/sysdeps/i860/memcopy.h b/ports/sysdeps/i860/memcopy.h
new file mode 100644
index 000000000..3bb9ba513
--- /dev/null
+++ b/ports/sysdeps/i860/memcopy.h
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/i960/Implies b/ports/sysdeps/i960/Implies
new file mode 100644
index 000000000..1d569744a
--- /dev/null
+++ b/ports/sysdeps/i960/Implies
@@ -0,0 +1,3 @@
+# i960 family uses IEEE 754 floating point.
+ieee754/flt-32
+ieee754/dbl-64
diff --git a/ports/sysdeps/i960/add_n.s b/ports/sysdeps/i960/add_n.s
new file mode 100644
index 000000000..6031f6d4c
--- /dev/null
+++ b/ports/sysdeps/i960/add_n.s
@@ -0,0 +1,21 @@
+.text
+ .align 4
+ .globl ___mpn_add_n
+___mpn_add_n:
+ mov 0,g6 # clear carry-save register
+ cmpo 1,0 # clear cy
+
+Loop: subo 1,g3,g3 # update loop counter
+ ld (g1),g5 # load from s1_ptr
+ addo 4,g1,g1 # s1_ptr++
+ ld (g2),g4 # load from s2_ptr
+ addo 4,g2,g2 # s2_ptr++
+ cmpo g6,1 # restore cy from g6, relies on cy being 0
+ addc g4,g5,g4 # main add
+ subc 0,0,g6 # save cy in g6
+ st g4,(g0) # store result to res_ptr
+ addo 4,g0,g0 # res_ptr++
+ cmpobne 0,g3,Loop # when branch is taken, clears C bit
+
+ mov g6,g0
+ ret
diff --git a/ports/sysdeps/i960/addmul_1.s b/ports/sysdeps/i960/addmul_1.s
new file mode 100644
index 000000000..1a3de95e5
--- /dev/null
+++ b/ports/sysdeps/i960/addmul_1.s
@@ -0,0 +1,26 @@
+.text
+ .align 4
+ .globl ___mpn_mul_1
+___mpn_mul_1:
+ subo g2,0,g2
+ shlo 2,g2,g4
+ subo g4,g1,g1
+ subo g4,g0,g13
+ mov 0,g0
+
+ cmpo 1,0 # clear C bit on AC.cc
+
+Loop: ld (g1)[g2*4],g5
+ emul g3,g5,g6
+ ld (g13)[g2*4],g5
+
+ addc g0,g6,g6 # relies on that C bit is clear
+ addc 0,g7,g7
+ addc g5,g6,g6 # relies on that C bit is clear
+ st g6,(g13)[g2*4]
+ addc 0,g7,g0
+
+ addo g2,1,g2
+ cmpobne 0,g2,Loop # when branch is taken, clears C bit
+
+ ret
diff --git a/ports/sysdeps/i960/ffs.c b/ports/sysdeps/i960/ffs.c
new file mode 100644
index 000000000..090d1148b
--- /dev/null
+++ b/ports/sysdeps/i960/ffs.c
@@ -0,0 +1,46 @@
+/* ffs -- find first set bit in a word, counted from least significant end.
+ For i960 Core architecture
+ This file is part of the GNU C Library.
+ Copyright (C) 1994, 1997, 2004, 2005 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <string.h>
+
+#undef ffs
+
+#if defined (__GNUC__) && defined (__i960__)
+
+int
+__ffs (x)
+ int x;
+{
+ int cnt;
+
+ asm ("scanbit %1,%0" : "=d" (cnt) : "rm" (x & -x));
+
+ return cnt;
+}
+weak_alias (__ffs, ffs)
+libc_hidden_builtin_def (ffs)
+
+#else
+
+#include <string/ffs.c>
+
+#endif
diff --git a/ports/sysdeps/i960/mul_1.s b/ports/sysdeps/i960/mul_1.s
new file mode 100644
index 000000000..e75ea42d3
--- /dev/null
+++ b/ports/sysdeps/i960/mul_1.s
@@ -0,0 +1,23 @@
+.text
+ .align 4
+ .globl ___mpn_mul_1
+___mpn_mul_1:
+ subo g2,0,g2
+ shlo 2,g2,g4
+ subo g4,g1,g1
+ subo g4,g0,g13
+ mov 0,g0
+
+ cmpo 1,0 # clear C bit on AC.cc
+
+Loop: ld (g1)[g2*4],g5
+ emul g3,g5,g6
+
+ addc g0,g6,g6 # relies on that C bit is clear
+ st g6,(g13)[g2*4]
+ addc 0,g7,g0
+
+ addo g2,1,g2
+ cmpobne 0,g2,Loop # when branch is taken, clears C bit
+
+ ret
diff --git a/ports/sysdeps/i960/sub_n.s b/ports/sysdeps/i960/sub_n.s
new file mode 100644
index 000000000..13ebbfa9f
--- /dev/null
+++ b/ports/sysdeps/i960/sub_n.s
@@ -0,0 +1,21 @@
+.text
+ .align 4
+ .globl ___mpn_sub_n
+___mpn_sub_n:
+ mov 1,g6 # set carry-save register
+ cmpo 1,0 # clear cy
+
+Loop: subo 1,g3,g3 # update loop counter
+ ld (g1),g5 # load from s1_ptr
+ addo 4,g1,g1 # s1_ptr++
+ ld (g2),g4 # load from s2_ptr
+ addo 4,g2,g2 # s2_ptr++
+ cmpo g6,1 # restore cy from g6, relies on cy being 0
+ subc g4,g5,g4 # main subtract
+ subc 0,0,g6 # save cy in g6
+ st g4,(g0) # store result to res_ptr
+ addo 4,g0,g0 # res_ptr++
+ cmpobne 0,g3,Loop # when branch is taken, cy will be 0
+
+ mov g6,g0
+ ret
diff --git a/ports/sysdeps/m68k/Implies b/ports/sysdeps/m68k/Implies
new file mode 100644
index 000000000..5c778d4fb
--- /dev/null
+++ b/ports/sysdeps/m68k/Implies
@@ -0,0 +1,5 @@
+wordsize-32
+# 68k uses IEEE 754 floating point.
+ieee754/ldbl-96
+ieee754/dbl-64
+ieee754/flt-32
diff --git a/ports/sysdeps/m68k/Makefile b/ports/sysdeps/m68k/Makefile
new file mode 100644
index 000000000..fab6bd583
--- /dev/null
+++ b/ports/sysdeps/m68k/Makefile
@@ -0,0 +1,38 @@
+# Copyright (C) 1993, 1994, 1996, 1997, 2003 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+# 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 += $(m68k-syntax-flag)
+
+pic-ccflag = -fpic
+
+# Make sure setjmp.c is compiled with a frame pointer
+CFLAGS-setjmp.c := -fno-omit-frame-pointer
+
+# The 68k `long double' is a distinct type we support.
+long-double-fcts = yes
+
+ifeq ($(subdir),elf)
+CFLAGS-rtld.c += -Wno-uninitialized -Wno-unused
+endif
diff --git a/ports/sysdeps/m68k/Versions b/ports/sysdeps/m68k/Versions
new file mode 100644
index 000000000..f450291a9
--- /dev/null
+++ b/ports/sysdeps/m68k/Versions
@@ -0,0 +1,13 @@
+libc {
+ GLIBC_2.0 {
+ # Functions from libgcc.
+ __divdi3; __moddi3; __udivdi3; __umoddi3;
+ }
+}
+libm {
+ GLIBC_2.1 {
+ # A generic bug got this omitted from other configurations' version
+ # sets, but we always had it.
+ exp2l;
+ }
+}
diff --git a/ports/sysdeps/m68k/__longjmp.c b/ports/sysdeps/m68k/__longjmp.c
new file mode 100644
index 000000000..89ff5bab5
--- /dev/null
+++ b/ports/sysdeps/m68k/__longjmp.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1991, 92, 93, 94, 95, 97 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <setjmp.h>
+#include <stdlib.h>
+
+/* 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]));
+#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. */
+ );
+
+ /* Avoid `volatile function does return' warnings. */
+ for (;;);
+}
diff --git a/ports/sysdeps/m68k/abort-instr.h b/ports/sysdeps/m68k/abort-instr.h
new file mode 100644
index 000000000..b43c9efe1
--- /dev/null
+++ b/ports/sysdeps/m68k/abort-instr.h
@@ -0,0 +1,2 @@
+/* An instruction which should crash any program is `illegal'. */
+#define ABORT_INSTRUCTION asm ("illegal")
diff --git a/ports/sysdeps/m68k/add_n.S b/ports/sysdeps/m68k/add_n.S
new file mode 100644
index 000000000..a9558491e
--- /dev/null
+++ b/ports/sysdeps/m68k/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, 1996, 1998 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s1_ptr (sp + 8)
+ s2_ptr (sp + 16)
+ size (sp + 12)
+*/
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+ TEXT
+ENTRY(__mpn_add_n)
+/* Save used registers on the stack. */
+ movel R(d2),MEM_PREDEC(sp)
+ movel R(a2),MEM_PREDEC(sp)
+
+/* Copy the arguments to registers. Better use movem? */
+ movel MEM_DISP(sp,12),R(a2)
+ movel MEM_DISP(sp,16),R(a0)
+ movel MEM_DISP(sp,20),R(a1)
+ movel MEM_DISP(sp,24),R(d2)
+
+ eorw #1,R(d2)
+ lsrl #1,R(d2)
+ bcc L(L1)
+ subql #1,R(d2) /* clears cy as side effect */
+
+L(Loop:)
+ movel MEM_POSTINC(a0),R(d0)
+ movel MEM_POSTINC(a1),R(d1)
+ addxl R(d1),R(d0)
+ movel R(d0),MEM_POSTINC(a2)
+L(L1:) movel MEM_POSTINC(a0),R(d0)
+ movel MEM_POSTINC(a1),R(d1)
+ addxl R(d1),R(d0)
+ movel R(d0),MEM_POSTINC(a2)
+
+ dbf R(d2),L(Loop) /* loop until 16 lsb of %4 == -1 */
+ subxl R(d0),R(d0) /* d0 <= -cy; save cy as 0 or -1 in d0 */
+ subl #0x10000,R(d2)
+ bcs L(L2)
+ addl R(d0),R(d0) /* restore cy */
+ bra L(Loop)
+
+L(L2:)
+ negl R(d0)
+
+/* Restore used registers from stack frame. */
+ movel MEM_POSTINC(sp),R(a2)
+ movel MEM_POSTINC(sp),R(d2)
+
+ rts
+END(__mpn_add_n)
diff --git a/ports/sysdeps/m68k/asm-syntax.h b/ports/sysdeps/m68k/asm-syntax.h
new file mode 100644
index 000000000..8e2a4ca2c
--- /dev/null
+++ b/ports/sysdeps/m68k/asm-syntax.h
@@ -0,0 +1,109 @@
+/* Definitions for 68k syntax variations.
+ Copyright (C) 1992, 1994, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library. Its master source is NOT part of
+ the C library, however. The master source lives in the GNU MP Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifdef HAVE_ELF
+
+/* ELF uses byte-counts for .align, most others use log2 of count of bytes. */
+#define ALIGNARG(log2) 1<<log2
+/* For ELF we need the `.type' directive to make shared libs work right. */
+#define PROLOG(name) .type name,@function
+#define EPILOG(name) .size name,.-name
+/* For ELF we need to prefix register names and local labels. */
+#ifdef __STDC__
+#define R_(r) %##r
+#define R(r) R_(r)
+#define L(label) .##label
+#else
+#define R(r) %/**/r
+#define L(label) ./**/label
+#endif
+
+#else
+
+#define ALIGNARG(log2) log2
+#define PROLOG(name) /* Nothing. */
+#define EPILOG(name) /* Nothing. */
+#define R(r) r
+#define L(label) label
+
+#endif
+
+#ifdef MIT_SYNTAX
+#define MEM(base)R(base)@
+#define MEM_DISP(base,displacement)R(base)@(displacement)
+#define MEM_INDX(base,idx,size_suffix)R(base)@(R(idx):size_suffix)
+#define MEM_INDX1(base,idx,size_suffix,scale)R(base)@(R(idx):size_suffix:scale)
+#define MEM_PREDEC(memory_base)R(memory_base)@-
+#define MEM_POSTINC(memory_base)R(memory_base)@+
+#define TEXT .text
+#define ALIGN .even
+#define GLOBL .globl
+/* Use variable sized opcodes. */
+#define bcc jcc
+#define bcs jcs
+#define bls jls
+#define beq jeq
+#define bne jne
+#define bra jra
+#endif
+
+#ifdef MOTOROLA_SYNTAX
+#define MEM(base)(R(base))
+#define MEM_DISP(base,displacement)(displacement,R(base))
+#define MEM_PREDEC(memory_base)-(R(memory_base))
+#define MEM_POSTINC(memory_base)(R(memory_base))+
+#ifdef __STDC__
+#define MEM_INDX_(base,idx,size_suffix)(R(base),R(idx##.##size_suffix))
+#define MEM_INDX(base,idx,size_suffix)MEM_INDX_(base,idx,size_suffix)
+#define MEM_INDX1_(base,idx,size_suffix,scale)(R(base),R(idx##.##size_suffix*scale))
+#define MEM_INDX1(base,idx,size_suffix,scale)MEM_INDX1_(base,idx,size_suffix,scale)
+#else
+#define MEM_INDX(base,idx,size_suffix)(R(base),R(idx).size_suffix)
+#define MEM_INDX1(base,idx,size_suffix,scale)(R(base),R(idx).size_suffix*scale)
+#endif
+#define TEXT .text
+#define ALIGN .align ALIGNARG(2)
+#define GLOBL .globl
+#define bcc jbcc
+#define bcs jbcs
+#define bls jbls
+#define beq jbeq
+#define bne jbne
+#define bra jbra
+#define movel move.l
+#define moveml movem.l
+#define moveql moveq.l
+#define cmpl cmp.l
+#define orl or.l
+#define clrl clr.l
+#define eorw eor.w
+#define lsrl lsr.l
+#define lsll lsl.l
+#define roxrl roxr.l
+#define roxll roxl.l
+#define addl add.l
+#define addxl addx.l
+#define addql addq.l
+#define subl sub.l
+#define subxl subx.l
+#define subql subq.l
+#define negl neg.l
+#define mulul mulu.l
+#endif
diff --git a/ports/sysdeps/m68k/bits/byteswap.h b/ports/sysdeps/m68k/bits/byteswap.h
new file mode 100644
index 000000000..549d4452e
--- /dev/null
+++ b/ports/sysdeps/m68k/bits/byteswap.h
@@ -0,0 +1,67 @@
+/* Macros to swap the order of bytes in integer values. m68k version.
+ Copyright (C) 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
+# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
+#endif
+
+#ifndef _BITS_BYTESWAP_H
+#define _BITS_BYTESWAP_H 1
+
+/* Swap bytes in 16 bit value. We don't provide an assembler version
+ because GCC is smart enough to generate optimal assembler output, and
+ this allows for better cse. */
+#define __bswap_16(x) \
+ ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
+
+/* Swap bytes in 32 bit value. */
+#define __bswap_constant_32(x) \
+ ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+
+#if defined __GNUC__ && __GNUC__ >= 2
+# define __bswap_32(x) \
+ __extension__ \
+ ({ unsigned int __bswap_32_v; \
+ if (__builtin_constant_p (x)) \
+ __bswap_32_v = __bswap_constant_32 (x); \
+ else \
+ __asm__ __volatile__ ("ror%.w %#8, %0;" \
+ "swap %0;" \
+ "ror%.w %#8, %0" \
+ : "=d" (__bswap_32_v) \
+ : "0" ((unsigned int) (x))); \
+ __bswap_32_v; })
+#else
+# define __bswap_32(x) __bswap_constant_32 (x)
+#endif
+
+#if defined __GNUC__ && __GNUC__ >= 2
+/* Swap bytes in 64 bit value. */
+# define __bswap_64(x) \
+ __extension__ \
+ ({ union { unsigned long long int __ll; \
+ unsigned long int __l[2]; } __bswap_64_v, __bswap_64_r; \
+ __bswap_64_v.__ll = (x); \
+ __bswap_64_r.__l[0] = __bswap_32 (__bswap_64_v.__l[1]); \
+ __bswap_64_r.__l[1] = __bswap_32 (__bswap_64_v.__l[0]); \
+ __bswap_64_r.__ll; })
+#endif
+
+#endif /* _BITS_BYTESWAP_H */
diff --git a/ports/sysdeps/m68k/bits/endian.h b/ports/sysdeps/m68k/bits/endian.h
new file mode 100644
index 000000000..bf4ecb60a
--- /dev/null
+++ b/ports/sysdeps/m68k/bits/endian.h
@@ -0,0 +1,7 @@
+/* m68k is big-endian. */
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#define __BYTE_ORDER __BIG_ENDIAN
diff --git a/ports/sysdeps/m68k/bits/huge_vall.h b/ports/sysdeps/m68k/bits/huge_vall.h
new file mode 100644
index 000000000..8b9630c6d
--- /dev/null
+++ b/ports/sysdeps/m68k/bits/huge_vall.h
@@ -0,0 +1,43 @@
+/* `HUGE_VALL' constant for m68k (where it is infinity).
+ Used by <stdlib.h> and <math.h> functions for overflow.
+ Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MATH_H
+# error "Never use <bits/huge_val.h> directly; include <math.h> instead."
+#endif
+
+#if __GNUC_PREREQ(3,3)
+# define HUGE_VALL (__builtin_huge_vall ())
+#elif __GNUC_PREREQ(2,96)
+# define HUGE_VALL (__extension__ 0x1.0p32767L)
+#elif defined__GNUC__
+
+# define HUGE_VALL \
+ (__extension__ \
+ ((union { unsigned long __l[3]; long double __ld; }) \
+ { __l: { 0x7fff0000UL, 0x80000000UL, 0UL } }).__ld)
+
+#else /* not GCC */
+
+static union { unsigned char __c[12]; long double __ld; } __huge_vall =
+ { { 0x7f, 0xff, 0, 0, 0x80, 0, 0, 0, 0, 0, 0, 0 } };
+# define HUGE_VALL (__huge_vall.__ld)
+
+#endif /* GCC 2.95. */
diff --git a/ports/sysdeps/m68k/bits/link.h b/ports/sysdeps/m68k/bits/link.h
new file mode 100644
index 000000000..9d0a94592
--- /dev/null
+++ b/ports/sysdeps/m68k/bits/link.h
@@ -0,0 +1,58 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _LINK_H
+# error "Never include <bits/link.h> directly; use <link.h> instead."
+#endif
+
+
+/* Registers for entry into PLT on M68K. */
+typedef struct La_m68k_regs
+{
+ uint32_t lr_a0;
+ uint32_t lr_a1;
+ uint32_t lr_sp;
+} La_m68k_regs;
+
+/* Return values for calls from PLT on M68K. */
+typedef struct La_m68k_retval
+{
+ uint32_t lrv_d0;
+ uint32_t lrv_d1;
+ uint32_t lrv_a0;
+ long double lrv_fp0;
+} La_m68k_retval;
+
+
+__BEGIN_DECLS
+
+extern Elf32_Addr la_m68k_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ La_m68k_regs *__regs,
+ unsigned int *__flags,
+ const char *__symname,
+ long int *__framesizep);
+extern unsigned int la_m68k_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ const La_m68k_regs *__inregs,
+ La_m68k_retval *__outregs,
+ const char *symname);
+
+__END_DECLS
diff --git a/ports/sysdeps/m68k/bits/mathdef.h b/ports/sysdeps/m68k/bits/mathdef.h
new file mode 100644
index 000000000..65cf8d49f
--- /dev/null
+++ b/ports/sysdeps/m68k/bits/mathdef.h
@@ -0,0 +1,38 @@
+/* Copyright (C) 1997, 1998, 1999, 2000, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#if !defined _MATH_H && !defined _COMPLEX_H
+# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
+#endif
+
+#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
+# define _MATH_H_MATHDEF 1
+
+/* The m68k FPUs evaluate all values in the 96 bit floating-point format
+ which is also available for the user as `long double'. Therefore we
+ define: */
+typedef long double float_t; /* `float' expressions are evaluated as
+ `long double'. */
+typedef long double double_t; /* `double' expressions are evaluated as
+ `long double'. */
+
+/* The values returned by `ilogb' for 0 and NaN respectively. */
+# define FP_ILOGB0 (-2147483647 - 1)
+# define FP_ILOGBNAN (2147483647)
+
+#endif /* ISO C99 */
diff --git a/ports/sysdeps/m68k/bits/setjmp.h b/ports/sysdeps/m68k/bits/setjmp.h
new file mode 100644
index 000000000..2d5a08227
--- /dev/null
+++ b/ports/sysdeps/m68k/bits/setjmp.h
@@ -0,0 +1,45 @@
+/* Copyright (C) 1997,1998,2005,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Define the machine-dependent type `jmp_buf'. m68k version. */
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H 1
+
+#if !defined _SETJMP_H && !defined _PTHREAD_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+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];
+
+#endif /* bits/setjmp.h */
diff --git a/ports/sysdeps/m68k/bsd-_setjmp.c b/ports/sysdeps/m68k/bsd-_setjmp.c
new file mode 100644
index 000000000..a6b404aeb
--- /dev/null
+++ b/ports/sysdeps/m68k/bsd-_setjmp.c
@@ -0,0 +1,22 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. m68k version.
+ Copyright (C) 1994, 1997, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define BSD__SETJMP
+#include <sysdeps/m68k/setjmp.c>
+libc_hidden_def (_setjmp)
diff --git a/ports/sysdeps/m68k/bsd-setjmp.c b/ports/sysdeps/m68k/bsd-setjmp.c
new file mode 100644
index 000000000..59b5acfee
--- /dev/null
+++ b/ports/sysdeps/m68k/bsd-setjmp.c
@@ -0,0 +1,21 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. m68k version.
+ Copyright (C) 1994, 1997, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define BSD_SETJMP
+#include <sysdeps/m68k/setjmp.c>
diff --git a/ports/sysdeps/m68k/dl-machine.h b/ports/sysdeps/m68k/dl-machine.h
new file mode 100644
index 000000000..f31b68772
--- /dev/null
+++ b/ports/sysdeps/m68k/dl-machine.h
@@ -0,0 +1,290 @@
+/* Machine-dependent ELF dynamic relocation inline functions. m68k version.
+ Copyright (C) 1996-2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef dl_machine_h
+#define dl_machine_h
+
+#define ELF_MACHINE_NAME "m68k"
+
+#include <sys/param.h>
+
+/* Return nonzero iff ELF header is compatible with the running host. */
+static inline int
+elf_machine_matches_host (const Elf32_Ehdr *ehdr)
+{
+ return ehdr->e_machine == EM_68K;
+}
+
+
+/* Return the link-time address of _DYNAMIC. Conveniently, this is the
+ first element of the GOT. This must be inlined in a function which
+ uses global data. */
+static inline Elf32_Addr
+elf_machine_dynamic (void)
+{
+ register Elf32_Addr *got asm ("%a5");
+ return *got;
+}
+
+
+/* Return the run-time load address of the shared object. */
+static inline Elf32_Addr
+elf_machine_load_address (void)
+{
+ Elf32_Addr addr;
+ asm ("lea _dl_start(%%pc), %0\n\t"
+ "sub.l _dl_start@GOT.w(%%a5), %0"
+ : "=a" (addr));
+ return addr;
+}
+
+
+/* Set up the loaded object described by L so its unrelocated PLT
+ entries will jump to the on-demand fixup code in dl-runtime.c. */
+
+static inline int __attribute__ ((always_inline))
+elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
+{
+ Elf32_Addr *got;
+ extern void _dl_runtime_resolve (Elf32_Word);
+ extern void _dl_runtime_profile (Elf32_Word);
+
+ if (l->l_info[DT_JMPREL] && lazy)
+ {
+ /* The GOT entries for functions in the PLT have not yet been
+ filled in. Their initial contents will arrange when called
+ to push an offset into the .rela.plt section, push
+ _GLOBAL_OFFSET_TABLE_[1], and then jump to
+ _GLOBAL_OFFSET_TABLE_[2]. */
+ got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]);
+ got[1] = (Elf32_Addr) l; /* Identify this shared object. */
+
+ /* The got[2] entry contains the address of a function which gets
+ called to get the address of a so far unresolved function and
+ jump to it. The profiling extension of the dynamic linker allows
+ to intercept the calls to collect information. In this case we
+ don't store the address in the GOT so that all future calls also
+ end in this function. */
+ if (profile)
+ {
+ got[2] = (Elf32_Addr) &_dl_runtime_profile;
+
+ if (GLRO(dl_profile) != NULL
+ && _dl_name_match_p (GLRO(dl_profile), l))
+ {
+ /* This is the object we are looking for. Say that we really
+ want profiling and the timers are started. */
+ GL(dl_profile_map) = l;
+ }
+ }
+ else
+ /* This function will get called to fix up the GOT entry indicated by
+ the offset on the stack, and then jump to the resolved address. */
+ got[2] = (Elf32_Addr) &_dl_runtime_resolve;
+ }
+
+ return lazy;
+}
+
+#define ELF_MACHINE_RUNTIME_FIXUP_ARGS long int save_a0, long int save_a1
+
+
+/* Mask identifying addresses reserved for the user program,
+ where the dynamic linker should not map anything. */
+#define ELF_MACHINE_USER_ADDRESS_MASK 0x80000000UL
+
+/* Initial entry point code for the dynamic linker.
+ The C function `_dl_start' is the real entry point;
+ its return value is the user program's entry point. */
+
+#define RTLD_START asm ("\
+ .text\n\
+ .globl _start\n\
+ .type _start,@function\n\
+_start:\n\
+ move.l %sp, -(%sp)\n\
+ jbsr _dl_start\n\
+ addq.l #4, %sp\n\
+ /* FALLTHRU */\n\
+\n\
+ .globl _dl_start_user\n\
+ .type _dl_start_user,@function\n\
+_dl_start_user:\n\
+ | Save the user entry point address in %a4.\n\
+ move.l %d0, %a4\n\
+ | See if we were run as a command with the executable file\n\
+ | name as an extra leading argument.\n\
+ move.l _dl_skip_args(%pc), %d0\n\
+ | Pop the original argument count\n\
+ move.l (%sp)+, %d1\n\
+ | Subtract _dl_skip_args from it.\n\
+ sub.l %d0, %d1\n\
+ | Adjust the stack pointer to skip _dl_skip_args words.\n\
+ lea (%sp, %d0*4), %sp\n\
+ | Push back the modified argument count.\n\
+ move.l %d1, -(%sp)\n\
+ # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\
+ pea 8(%sp, %d1*4)\n\
+ pea 8(%sp)\n\
+ move.l %d1, -(%sp)\n\
+ move.l _rtld_local(%pc), -(%sp)\n\
+ jbsr _dl_init_internal@PLTPC\n\
+ addq.l #8, %sp\n\
+ addq.l #8, %sp\n\
+ | Pass our finalizer function to the user in %a1.\n\
+ lea _dl_fini(%pc), %a1\n\
+ | Initialize %fp with the stack pointer.\n\
+ move.l %sp, %fp\n\
+ | Jump to the user's entry point.\n\
+ jmp (%a4)\n\
+ .size _dl_start_user, . - _dl_start_user\n\
+ .previous");
+
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
+ PLT entries should not be allowed to define the value.
+ ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
+ of the main executable's symbols, as for a COPY reloc. */
+#define elf_machine_type_class(type) \
+ ((((type) == R_68K_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_68K_COPY) * ELF_RTYPE_CLASS_COPY))
+
+/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
+#define ELF_MACHINE_JMP_SLOT R_68K_JMP_SLOT
+
+/* The m68k never uses Elf32_Rel relocations. */
+#define ELF_MACHINE_NO_REL 1
+
+static inline Elf32_Addr
+elf_machine_fixup_plt (struct link_map *map, lookup_t t,
+ const Elf32_Rela *reloc,
+ Elf32_Addr *reloc_addr, Elf32_Addr value)
+{
+ return *reloc_addr = value;
+}
+
+/* Return the final value of a plt relocation. On the m68k the JMP_SLOT
+ relocation ignores the addend. */
+static inline Elf32_Addr
+elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
+ Elf32_Addr value)
+{
+ return value;
+}
+
+/* Names of the architecture-specific auditing callback functions. */
+#define ARCH_LA_PLTENTER m68k_gnu_pltenter
+#define ARCH_LA_PLTEXIT m68k_gnu_pltexit
+
+#endif /* !dl_machine_h */
+
+#ifdef RESOLVE_MAP
+
+/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
+ MAP is the object containing the reloc. */
+
+auto inline void __attribute__ ((unused, always_inline))
+elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
+ const Elf32_Sym *sym, const struct r_found_version *version,
+ void *const reloc_addr_arg)
+{
+ Elf32_Addr *const reloc_addr = reloc_addr_arg;
+ const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
+
+ if (__builtin_expect (r_type == R_68K_RELATIVE, 0))
+ *reloc_addr = map->l_addr + reloc->r_addend;
+ else
+ {
+ const Elf32_Sym *const refsym = sym;
+ struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
+ Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value;
+
+ switch (r_type)
+ {
+ case R_68K_COPY:
+ if (sym == NULL)
+ /* This can happen in trace mode if an object could not be
+ found. */
+ break;
+ if (sym->st_size > refsym->st_size
+ || (sym->st_size < refsym->st_size && GLRO(dl_verbose)))
+ {
+ const char *strtab;
+
+ strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
+ _dl_error_printf ("\
+%s: Symbol `%s' has different size in shared object, consider re-linking\n",
+ rtld_progname ?: "<program name unknown>",
+ strtab + refsym->st_name);
+ }
+ memcpy (reloc_addr_arg, (void *) value,
+ MIN (sym->st_size, refsym->st_size));
+ break;
+ case R_68K_GLOB_DAT:
+ case R_68K_JMP_SLOT:
+ *reloc_addr = value;
+ break;
+ case R_68K_8:
+ *(char *) reloc_addr = value + reloc->r_addend;
+ break;
+ case R_68K_16:
+ *(short *) reloc_addr = value + reloc->r_addend;
+ break;
+ case R_68K_32:
+ *reloc_addr = value + reloc->r_addend;
+ break;
+ case R_68K_PC8:
+ *(char *) reloc_addr
+ = value + reloc->r_addend - (Elf32_Addr) reloc_addr;
+ break;
+ case R_68K_PC16:
+ *(short *) reloc_addr
+ = value + reloc->r_addend - (Elf32_Addr) reloc_addr;
+ break;
+ case R_68K_PC32:
+ *reloc_addr = value + reloc->r_addend - (Elf32_Addr) reloc_addr;
+ break;
+ case R_68K_NONE: /* Alright, Wilbur. */
+ break;
+ default:
+ _dl_reloc_bad_type (map, r_type, 0);
+ break;
+ }
+ }
+}
+
+auto inline void __attribute__ ((unused, always_inline))
+elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
+ void *const reloc_addr_arg)
+{
+ Elf32_Addr *const reloc_addr = reloc_addr_arg;
+ *reloc_addr = l_addr + reloc->r_addend;
+}
+
+auto inline void __attribute__ ((unused, always_inline))
+elf_machine_lazy_rel (struct link_map *map,
+ Elf32_Addr l_addr, const Elf32_Rela *reloc)
+{
+ Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
+ if (ELF32_R_TYPE (reloc->r_info) == R_68K_JMP_SLOT)
+ *reloc_addr += l_addr;
+ else
+ _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 1);
+}
+
+#endif /* RESOLVE_MAP */
diff --git a/ports/sysdeps/m68k/dl-trampoline.S b/ports/sysdeps/m68k/dl-trampoline.S
new file mode 100644
index 000000000..879128037
--- /dev/null
+++ b/ports/sysdeps/m68k/dl-trampoline.S
@@ -0,0 +1,129 @@
+/* PLT trampolines. m68k version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+ .text
+ .globl _dl_runtime_resolve
+ .type _dl_runtime_resolve, @function
+_dl_runtime_resolve:
+ | Save %a0 (struct return address) and %a1.
+ move.l %a0, -(%sp)
+ move.l %a1, -(%sp)
+ | Call the real address resolver.
+ jbsr _dl_fixup
+ | Restore register %a0 and %a1.
+ move.l (%sp)+, %a1
+ move.l (%sp)+, %a0
+ | Pop parameters
+ addq.l #8, %sp
+ | Call real function.
+ jmp (%d0)
+ .size _dl_runtime_resolve, . - _dl_runtime_resolve
+
+ .text
+ .globl _dl_runtime_profile
+ .type _dl_runtime_profile, @function
+_dl_runtime_profile:
+ pea 8(%sp)
+ move.l %a1, -(%sp)
+ move.l %a0, -(%sp)
+ pea -1.w
+ | Push parameters for _dl_profile_fixup
+ pea (%sp)
+ pea 8(%sp)
+ move.l 32(%sp), -(%sp)
+ move.l 32(%sp), -(%sp)
+ move.l 32(%sp), -(%sp)
+ subq.l #8, %sp
+ | Call the real address resolver.
+ jbsr _dl_profile_fixup
+ | Pop parameters
+ lea 28(%sp), %sp
+ move.l (%sp), %d1
+ jpl 1f
+ addq.l #4, %sp
+ | Restore register %a0 and %a1.
+ move.l (%sp)+, %a0
+ move.l (%sp)+, %a1
+ lea 12(%sp), %sp
+ | Call real function.
+ jmp (%d0)
+
+ /*
+ +24 return address
+ +20 PLT1
+ +16 PLT2
+ +12 %sp
+ +8 %a1
+ +4 %a0
+ %sp free
+ */
+1: move.l %a2, (%sp)
+ move.l %sp, %a2
+ move.l %sp, %a0
+ lea 28(%sp), %a1
+ | Round framesize up to even
+ addq.l #1, %d1
+ lsr #1, %d1
+ sub.l %d1, %a0
+ sub.l %d1, %a0
+ move.l %a0, %sp
+ jra 2f
+1: move.w (%a1)+, (%a0)+
+2: dbra %d1,1b
+ /*
+ %a2+24 return address
+ %a2+20 PLT1
+ %a2+16 PLT2
+ %a2+12 %sp
+ %a2+8 %a1
+ %a2+4 %a0
+ %a2 %a2
+ %sp copied stack frame
+ */
+
+ move.l 4(%a2), %a0
+ move.l 8(%a2), %a1
+ jsr (%d0)
+ move.l %a2, %sp
+ move.l (%sp)+, %a2
+ /*
+ +20 return address
+ +16 PLT1
+ +12 PLT2
+ +8 %sp
+ +4 %a1
+ %sp %a0
+ */
+ fmove.x %fp0, -(%sp)
+ move.l %d1, -(%sp)
+ move.l %d0, -(%sp)
+ pea (%sp)
+ pea 20(%sp)
+ move.l 40(%sp), -(%sp)
+ move.l 40(%sp), -(%sp)
+ jbsr _dl_call_pltexit
+ lea 16(%sp), %sp
+ move.l (%sp)+, %d0
+ move.l (%sp)+, %d1
+ fmove.x (%sp)+, %fp0
+ lea 20(%sp), %sp
+ rts
+ .size _dl_runtime_profile, . - _dl_runtime_profile
diff --git a/ports/sysdeps/m68k/elf/start.S b/ports/sysdeps/m68k/elf/start.S
new file mode 100644
index 000000000..8c89b37ec
--- /dev/null
+++ b/ports/sysdeps/m68k/elf/start.S
@@ -0,0 +1,100 @@
+/* Startup code compliant to the ELF m68k ABI.
+ Copyright (C) 1996, 1997, 1998, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This is the canonical entry point, usually the first thing in the text
+ segment. The SVR4/m68k ABI says that when the entry point runs,
+ most registers' values are unspecified, except for:
+
+ %a1 Contains a function pointer to be registered with `atexit'.
+ This is how the dynamic linker arranges to have DT_FINI
+ functions called for shared libraries that have been loaded
+ before this code runs.
+
+ %sp The stack contains the arguments and environment:
+ 0(%sp) argc
+ 4(%sp) argv[0]
+ ...
+ (4*argc)(%sp) NULL
+ (4*(argc+1))(%sp) envp[0]
+ ...
+ NULL
+*/
+
+ .text
+ .globl _start
+ .type _start,@function
+_start:
+ /* Clear the frame pointer. The ABI suggests this be done, to mark
+ the outermost frame obviously. */
+ sub.l %fp, %fp
+
+ /* Extract the arguments as encoded on the stack and set up the
+ arguments for `main': argc, argv. envp will be determined
+ later in __libc_start_main. */
+ move.l (%sp)+, %d0 /* Pop the argument count. */
+ move.l %sp, %a0 /* The argument vector starts just at the
+ current stack top. */
+
+ /* Provide the highest stack address to the user code (for stacks
+ which grow downward). */
+ pea (%sp)
+
+ pea (%a1) /* Push address of the shared library
+ termination function. */
+
+ /* Push the address of our own entry points to `.fini' and
+ `.init'. */
+ pea __libc_csu_fini
+ pea __libc_csu_init
+
+ pea (%a0) /* Push second argument: argv. */
+ move.l %d0, -(%sp) /* Push first argument: argc. */
+
+ pea main
+
+ /* Call the user's main function, and exit with its value. But
+ let the libc call main. */
+ jbsr __libc_start_main
+
+ illegal /* Crash if somehow `exit' does return. */
+
+/* Define a symbol for the first piece of initialized data. */
+ .data
+ .globl __data_start
+__data_start:
+ .long 0
+ .weak data_start
+ data_start = __data_start
diff --git a/ports/sysdeps/m68k/ffs.c b/ports/sysdeps/m68k/ffs.c
new file mode 100644
index 000000000..2032e8662
--- /dev/null
+++ b/ports/sysdeps/m68k/ffs.c
@@ -0,0 +1,48 @@
+/* ffs -- find first set bit in a word, counted from least significant end.
+ For mc68020, mc68030, mc68040.
+ This file is part of the GNU C Library.
+ Copyright (C) 1991, 1992, 1997, 1998, 2004, 2005 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define ffsl __something_else
+#include <string.h>
+
+#undef ffs
+
+#if defined (__GNUC__) && defined (__mc68020__)
+
+int
+__ffs (x)
+ int x;
+{
+ int cnt;
+
+ asm ("bfffo %1{#0:#0},%0" : "=d" (cnt) : "dm" (x & -x));
+
+ return 32 - cnt;
+}
+weak_alias (__ffs, ffs)
+libc_hidden_builtin_def (ffs)
+#undef ffsl
+weak_alias (__ffs, ffsl)
+
+#else
+
+#include <string/ffs.c>
+
+#endif
diff --git a/ports/sysdeps/m68k/fpu/Makefile b/ports/sysdeps/m68k/fpu/Makefile
new file mode 100644
index 000000000..42db6381d
--- /dev/null
+++ b/ports/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/ports/sysdeps/m68k/fpu/bits/fenv.h b/ports/sysdeps/m68k/fpu/bits/fenv.h
new file mode 100644
index 000000000..7c0bcb669
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/bits/fenv.h
@@ -0,0 +1,79 @@
+/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FENV_H
+# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
+
+
+/* Define bits representing the exception. We use the bit positions of
+ the appropriate bits in the FPSR Accrued Exception Byte. */
+enum
+ {
+ FE_INEXACT = 1 << 3,
+#define FE_INEXACT FE_INEXACT
+ FE_DIVBYZERO = 1 << 4,
+#define FE_DIVBYZERO FE_DIVBYZERO
+ FE_UNDERFLOW = 1 << 5,
+#define FE_UNDERFLOW FE_UNDERFLOW
+ FE_OVERFLOW = 1 << 6,
+#define FE_OVERFLOW FE_OVERFLOW
+ FE_INVALID = 1 << 7
+#define FE_INVALID FE_INVALID
+ };
+
+#define FE_ALL_EXCEPT \
+ (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
+
+/* The m68k FPU supports all of the four defined rounding modes. We use
+ the bit positions in the FPCR Mode Control Byte as the values for the
+ appropriate macros. */
+enum
+ {
+ FE_TONEAREST = 0,
+#define FE_TONEAREST FE_TONEAREST
+ FE_TOWARDZERO = 1 << 4,
+#define FE_TOWARDZERO FE_TOWARDZERO
+ FE_DOWNWARD = 2 << 4,
+#define FE_DOWNWARD FE_DOWNWARD
+ FE_UPWARD = 3 << 4
+#define FE_UPWARD FE_UPWARD
+ };
+
+
+/* Type representing exception flags. */
+typedef unsigned int fexcept_t;
+
+
+/* Type representing floating-point environment. This structure
+ corresponds to the layout of the block written by `fmovem'. */
+typedef struct
+ {
+ unsigned int __control_register;
+ unsigned int __status_register;
+ unsigned int __instruction_address;
+ }
+fenv_t;
+
+/* If the default argument is used we use this value. */
+#define FE_DFL_ENV ((__const fenv_t *) -1)
+
+#ifdef __USE_GNU
+/* Floating-point environment where none of the exceptions are masked. */
+# define FE_NOMASK_ENV ((__const fenv_t *) -2)
+#endif
diff --git a/ports/sysdeps/m68k/fpu/bits/mathinline.h b/ports/sysdeps/m68k/fpu/bits/mathinline.h
new file mode 100644
index 000000000..acbac47aa
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/bits/mathinline.h
@@ -0,0 +1,445 @@
+/* Definitions of inline math functions implemented by the m68881/2.
+ Copyright (C) 1991,92,93,94,96,97,98,99,2000,2002, 2003, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifdef __GNUC__
+
+#ifdef __USE_ISOC99
+/* GCC 3.1 and up have builtins that actually can be used. */
+# if !__GNUC_PREREQ (3,1)
+/* ISO C99 defines some macros to perform unordered comparisons. The
+ m68k FPU supports this with special opcodes and we should use them.
+ These must not be inline functions since we have to be able to handle
+ all floating-point types. */
+# undef isgreater
+# undef isgreaterequal
+# undef isless
+# undef islessequal
+# undef islessgreater
+# undef isunordered
+# define isgreater(x, y) \
+ __extension__ \
+ ({ char __result; \
+ __asm__ ("fcmp%.x %2,%1; fsogt %0" \
+ : "=dm" (__result) : "f" (x), "f" (y)); \
+ __result != 0; })
+
+# define isgreaterequal(x, y) \
+ __extension__ \
+ ({ char __result; \
+ __asm__ ("fcmp%.x %2,%1; fsoge %0" \
+ : "=dm" (__result) : "f" (x), "f" (y)); \
+ __result != 0; })
+
+# define isless(x, y) \
+ __extension__ \
+ ({ char __result; \
+ __asm__ ("fcmp%.x %2,%1; fsolt %0" \
+ : "=dm" (__result) : "f" (x), "f" (y)); \
+ __result != 0; })
+
+# define islessequal(x, y) \
+ __extension__ \
+ ({ char __result; \
+ __asm__ ("fcmp%.x %2,%1; fsole %0" \
+ : "=dm" (__result) : "f" (x), "f" (y)); \
+ __result != 0; })
+
+# define islessgreater(x, y) \
+ __extension__ \
+ ({ char __result; \
+ __asm__ ("fcmp%.x %2,%1; fsogl %0" \
+ : "=dm" (__result) : "f" (x), "f" (y)); \
+ __result != 0; })
+
+# define isunordered(x, y) \
+ __extension__ \
+ ({ char __result; \
+ __asm__ ("fcmp%.x %2,%1; fsun %0" \
+ : "=dm" (__result) : "f" (x), "f" (y)); \
+ __result != 0; })
+# endif /* GCC 3.1 */
+#endif
+
+
+#if (!defined __NO_MATH_INLINES && defined __OPTIMIZE__) \
+ || defined __LIBC_INTERNAL_MATH_INLINES
+
+#ifdef __LIBC_INTERNAL_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
+# ifdef __cplusplus
+# define __m81_inline __inline
+# else
+# define __m81_inline extern __inline
+# endif
+# define __M81_MATH_INLINES 1
+#endif
+
+/* Define a const math function. */
+#define __m81_defun(rettype, func, args) \
+ __m81_inline rettype __attribute__((__const__)) \
+ __m81_u(func) args
+
+/* Define the three variants of a math function that has a direct
+ implementation in the m68k fpu. FUNC is the name for C (which will be
+ suffixed with f and l for the float and long double version, resp). OP
+ is the name of the fpu operation (without leading f). */
+
+#if defined __USE_MISC || defined __USE_ISOC99
+# define __inline_mathop(func, op) \
+ __inline_mathop1(double, func, op) \
+ __inline_mathop1(float, __CONCAT(func,f), op) \
+ __inline_mathop1(long double, __CONCAT(func,l), op)
+#else
+# define __inline_mathop(func, op) \
+ __inline_mathop1(double, func, op)
+#endif
+
+#define __inline_mathop1(float_type,func, op) \
+ __m81_defun (float_type, func, (float_type __mathop_x)) \
+ { \
+ float_type __result; \
+ __asm("f" __STRING(op) "%.x %1, %0" : "=f" (__result) : "f" (__mathop_x));\
+ return __result; \
+ }
+
+__inline_mathop(__atan, atan)
+__inline_mathop(__cos, cos)
+__inline_mathop(__sin, sin)
+__inline_mathop(__tan, tan)
+__inline_mathop(__tanh, tanh)
+__inline_mathop(__fabs, abs)
+
+#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
+__inline_mathop(__rint, int)
+__inline_mathop(__expm1, etoxm1)
+__inline_mathop(__log1p, lognp1)
+#endif
+
+#ifdef __USE_MISC
+__inline_mathop(__significand, getman)
+#endif
+
+#ifdef __USE_ISOC99
+__inline_mathop(__trunc, intrz)
+#endif
+
+#if !defined __NO_MATH_INLINES && defined __OPTIMIZE__
+
+__inline_mathop(atan, atan)
+__inline_mathop(cos, cos)
+__inline_mathop(sin, sin)
+__inline_mathop(tan, tan)
+__inline_mathop(tanh, tanh)
+
+# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
+__inline_mathop(rint, int)
+__inline_mathop(expm1, etoxm1)
+__inline_mathop(log1p, lognp1)
+# endif
+
+# ifdef __USE_MISC
+__inline_mathop(significand, getman)
+# endif
+
+# ifdef __USE_ISOC99
+__inline_mathop(trunc, intrz)
+# endif
+
+#endif /* !__NO_MATH_INLINES && __OPTIMIZE__ */
+
+/* This macro contains the definition for the rest of the inline
+ functions, using FLOAT_TYPE as the domain type and S as the suffix
+ for the function names. */
+
+#define __inline_functions(float_type, s) \
+__m81_defun (float_type, __CONCAT(__floor,s), (float_type __x)) \
+{ \
+ float_type __result; \
+ unsigned long int __ctrl_reg; \
+ __asm __volatile__ ("fmove%.l %!, %0" : "=dm" (__ctrl_reg)); \
+ /* Set rounding towards negative infinity. */ \
+ __asm __volatile__ ("fmove%.l %0, %!" : /* No outputs. */ \
+ : "dmi" ((__ctrl_reg & ~0x10) | 0x20)); \
+ /* Convert X to an integer, using -Inf rounding. */ \
+ __asm __volatile__ ("fint%.x %1, %0" : "=f" (__result) : "f" (__x)); \
+ /* Restore the previous rounding mode. */ \
+ __asm __volatile__ ("fmove%.l %0, %!" : /* No outputs. */ \
+ : "dmi" (__ctrl_reg)); \
+ return __result; \
+} \
+ \
+__m81_defun (float_type, __CONCAT(__ceil,s), (float_type __x)) \
+{ \
+ float_type __result; \
+ unsigned long int __ctrl_reg; \
+ __asm __volatile__ ("fmove%.l %!, %0" : "=dm" (__ctrl_reg)); \
+ /* Set rounding towards positive infinity. */ \
+ __asm __volatile__ ("fmove%.l %0, %!" : /* No outputs. */ \
+ : "dmi" (__ctrl_reg | 0x30)); \
+ /* Convert X to an integer, using +Inf rounding. */ \
+ __asm __volatile__ ("fint%.x %1, %0" : "=f" (__result) : "f" (__x)); \
+ /* Restore the previous rounding mode. */ \
+ __asm __volatile__ ("fmove%.l %0, %!" : /* No outputs. */ \
+ : "dmi" (__ctrl_reg)); \
+ return __result; \
+}
+
+__inline_functions(double,)
+#if defined __USE_MISC || defined __USE_ISOC99
+__inline_functions(float,f)
+__inline_functions(long double,l)
+#endif
+#undef __inline_functions
+
+#ifdef __USE_MISC
+
+# define __inline_functions(float_type, s) \
+__m81_defun (int, __CONCAT(__isinf,s), (float_type __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" : "=dm" (__fpsr) : "f" (__value)); \
+ return (__fpsr & (2 << 24)) ? (__fpsr & (8 << 24) ? -1 : 1) : 0; \
+} \
+ \
+__m81_defun (int, __CONCAT(__finite,s), (float_type __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" : "=dm" (__fpsr) : "f" (__value)); \
+ return (__fpsr & (3 << 24)) == 0; \
+} \
+ \
+__m81_defun (float_type, __CONCAT(__scalbn,s), \
+ (float_type __x, int __n)) \
+{ \
+ float_type __result; \
+ __asm ("fscale%.l %1, %0" : "=f" (__result) : "dmi" (__n), "0" (__x)); \
+ return __result; \
+}
+
+__inline_functions(double,)
+__inline_functions(float,f)
+__inline_functions(long double,l)
+# undef __inline_functions
+
+#endif /* Use misc. */
+
+#if defined __USE_MISC || defined __USE_XOPEN
+
+# define __inline_functions(float_type, s) \
+__m81_defun (int, __CONCAT(__isnan,s), (float_type __value)) \
+{ \
+ char __result; \
+ __asm("ftst%.x %1\n" \
+ "fsun %0" : "=dm" (__result) : "f" (__value)); \
+ return __result; \
+}
+
+__inline_functions(double,)
+# ifdef __USE_MISC
+__inline_functions(float,f)
+__inline_functions(long double,l)
+# endif
+# undef __inline_functions
+
+#endif
+
+#ifdef __USE_ISOC99
+
+# define __inline_functions(float_type, s) \
+__m81_defun (int, __CONCAT(__signbit,s), (float_type __value)) \
+{ \
+ /* There is no branch-condition for the sign bit, so we must extract \
+ and examine the condition codes manually. */ \
+ unsigned long int __fpsr; \
+ __asm ("ftst%.x %1\n" \
+ "fmove%.l %/fpsr, %0" : "=dm" (__fpsr) : "f" (__value)); \
+ return (__fpsr >> 27) & 1; \
+} \
+ \
+ __m81_defun (float_type, __CONCAT(__scalbln,s), \
+ (float_type __x, long int __n)) \
+{ \
+ return __CONCAT(__scalbn,s) (__x, __n); \
+} \
+ \
+__m81_defun (float_type, __CONCAT(__nearbyint,s), (float_type __x)) \
+{ \
+ float_type __result; \
+ unsigned long int __ctrl_reg; \
+ __asm __volatile__ ("fmove%.l %!, %0" : "=dm" (__ctrl_reg)); \
+ /* Temporarily disable the inexact exception. */ \
+ __asm __volatile__ ("fmove%.l %0, %!" : /* No outputs. */ \
+ : "dmi" (__ctrl_reg & ~0x200)); \
+ __asm __volatile__ ("fint%.x %1, %0" : "=f" (__result) : "f" (__x)); \
+ __asm __volatile__ ("fmove%.l %0, %!" : /* No outputs. */ \
+ : "dmi" (__ctrl_reg)); \
+ return __result; \
+} \
+ \
+__m81_defun (long int, __CONCAT(__lrint,s), (float_type __x)) \
+{ \
+ long int __result; \
+ __asm ("fmove%.l %1, %0" : "=dm" (__result) : "f" (__x)); \
+ return __result; \
+} \
+ \
+__m81_inline float_type \
+__m81_u(__CONCAT(__fma,s))(float_type __x, float_type __y, \
+ float_type __z) \
+{ \
+ return (__x * __y) + __z; \
+}
+
+__inline_functions (double,)
+__inline_functions (float,f)
+__inline_functions (long double,l)
+# undef __inline_functions
+
+#endif /* Use ISO C9x */
+
+#ifdef __USE_GNU
+
+# define __inline_functions(float_type, s) \
+__m81_inline void \
+__m81_u(__CONCAT(__sincos,s))(float_type __x, float_type *__sinx, \
+ float_type *__cosx) \
+{ \
+ __asm ("fsincos%.x %2,%1:%0" \
+ : "=f" (*__sinx), "=f" (*__cosx) : "f" (__x)); \
+}
+
+__inline_functions (double,)
+__inline_functions (float,f)
+__inline_functions (long double,l)
+# undef __inline_functions
+
+#endif
+
+#if !defined __NO_MATH_INLINES && defined __OPTIMIZE__
+
+/* Define inline versions of the user visible functions. */
+
+/* Note that there must be no whitespace before the argument passed for
+ NAME, to make token pasting work correctly with -traditional. */
+# define __inline_forward_c(rettype, name, args1, args2) \
+extern __inline rettype __attribute__((__const__)) \
+ name args1 \
+{ \
+ return __CONCAT(__,name) args2; \
+}
+
+# define __inline_forward(rettype, name, args1, args2) \
+extern __inline rettype name args1 \
+{ \
+ return __CONCAT(__,name) args2; \
+}
+
+__inline_forward_c(double,floor, (double __x), (__x))
+__inline_forward_c(double,ceil, (double __x), (__x))
+# ifdef __USE_MISC
+# ifndef __USE_ISOC99 /* Conflict with macro of same name. */
+__inline_forward_c(int,isinf, (double __value), (__value))
+# endif
+__inline_forward_c(int,finite, (double __value), (__value))
+__inline_forward_c(double,scalbn, (double __x, int __n), (__x, __n))
+# endif
+# if defined __USE_MISC || defined __USE_XOPEN
+# ifndef __USE_ISOC99 /* Conflict with macro of same name. */
+__inline_forward_c(int,isnan, (double __value), (__value))
+# endif
+# endif
+# ifdef __USE_ISOC99
+__inline_forward_c(double,scalbln, (double __x, long int __n), (__x, __n))
+__inline_forward_c(double,nearbyint, (double __value), (__value))
+__inline_forward_c(long int,lrint, (double __value), (__value))
+__inline_forward_c(double,fma, (double __x, double __y, double __z),
+ (__x, __y, __z))
+# endif
+# ifdef __USE_GNU
+__inline_forward(void,sincos, (double __x, double *__sinx, double *__cosx),
+ (__x, __sinx, __cosx))
+# endif
+
+# if defined __USE_MISC || defined __USE_ISOC99
+
+__inline_forward_c(float,floorf, (float __x), (__x))
+__inline_forward_c(float,ceilf, (float __x), (__x))
+# ifdef __USE_MISC
+__inline_forward_c(int,isinff, (float __value), (__value))
+__inline_forward_c(int,finitef, (float __value), (__value))
+__inline_forward_c(float,scalbnf, (float __x, int __n), (__x, __n))
+__inline_forward_c(int,isnanf, (float __value), (__value))
+# endif
+# ifdef __USE_ISOC99
+__inline_forward_c(float,scalblnf, (float __x, long int __n), (__x, __n))
+__inline_forward_c(float,nearbyintf, (float __value), (__value))
+__inline_forward_c(long int,lrintf, (float __value), (__value))
+__inline_forward_c(float,fmaf, (float __x, float __y, float __z),
+ (__x, __y, __z))
+# endif
+# ifdef __USE_GNU
+__inline_forward(void,sincosf, (float __x, float *__sinx, float *__cosx),
+ (__x, __sinx, __cosx))
+# endif
+
+__inline_forward_c(long double,floorl, (long double __x), (__x))
+__inline_forward_c(long double,ceill, (long double __x), (__x))
+# ifdef __USE_MISC
+__inline_forward_c(int,isinfl, (long double __value), (__value))
+__inline_forward_c(int,finitel, (long double __value), (__value))
+__inline_forward_c(long double,scalbnl, (long double __x, int __n), (__x, __n))
+__inline_forward_c(int,isnanl, (long double __value), (__value))
+# endif
+# ifdef __USE_ISOC99
+__inline_forward_c(long double,scalblnl, (long double __x, long int __n),
+ (__x, __n))
+__inline_forward_c(long double,nearbyintl, (long double __value), (__value))
+__inline_forward_c(long int,lrintl, (long double __value), (__value))
+__inline_forward_c(long double,fmal,
+ (long double __x, long double __y, long double __z),
+ (__x, __y, __z))
+# endif
+# ifdef __USE_GNU
+__inline_forward(void,sincosl,
+ (long double __x, long double *__sinx, long double *__cosx),
+ (__x, __sinx, __cosx))
+# endif
+
+#endif /* Use misc or ISO C99 */
+
+#undef __inline_forward
+#undef __inline_forward_c
+
+#endif /* !__NO_MATH_INLINES && __OPTIMIZE__ */
+
+#endif
+#endif /* GCC. */
diff --git a/ports/sysdeps/m68k/fpu/branred.c b/ports/sysdeps/m68k/fpu/branred.c
new file mode 100644
index 000000000..1cc893170
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/branred.c
@@ -0,0 +1 @@
+/* Not needed. */
diff --git a/ports/sysdeps/m68k/fpu/doasin.c b/ports/sysdeps/m68k/fpu/doasin.c
new file mode 100644
index 000000000..1cc893170
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/doasin.c
@@ -0,0 +1 @@
+/* Not needed. */
diff --git a/ports/sysdeps/m68k/fpu/dosincos.c b/ports/sysdeps/m68k/fpu/dosincos.c
new file mode 100644
index 000000000..1cc893170
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/dosincos.c
@@ -0,0 +1 @@
+/* Not needed. */
diff --git a/ports/sysdeps/m68k/fpu/e_acos.c b/ports/sysdeps/m68k/fpu/e_acos.c
new file mode 100644
index 000000000..c9f6c6a16
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_acos.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include "math_private.h"
+#include "mathimpl.h"
+
+#ifndef FUNC
+#define FUNC __ieee754_acos
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+float_type
+FUNC (x)
+ float_type x;
+{
+ return __m81_u(FUNC)(x);
+}
diff --git a/ports/sysdeps/m68k/fpu/e_acosf.c b/ports/sysdeps/m68k/fpu/e_acosf.c
new file mode 100644
index 000000000..90665082d
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_acosf.c
@@ -0,0 +1,5 @@
+#ifndef FUNC
+#define FUNC __ieee754_acosf
+#endif
+#define float_type float
+#include <e_acos.c>
diff --git a/ports/sysdeps/m68k/fpu/e_acosl.c b/ports/sysdeps/m68k/fpu/e_acosl.c
new file mode 100644
index 000000000..e3dcd170f
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_acosl.c
@@ -0,0 +1,5 @@
+#ifndef FUNC
+#define FUNC __ieee754_acosl
+#endif
+#define float_type long double
+#include <e_acos.c>
diff --git a/ports/sysdeps/m68k/fpu/e_asin.c b/ports/sysdeps/m68k/fpu/e_asin.c
new file mode 100644
index 000000000..b6176c708
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_asin.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_asin
+#include <e_acos.c>
diff --git a/ports/sysdeps/m68k/fpu/e_asinf.c b/ports/sysdeps/m68k/fpu/e_asinf.c
new file mode 100644
index 000000000..05fb82670
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_asinf.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_asinf
+#include <e_acosf.c>
diff --git a/ports/sysdeps/m68k/fpu/e_asinl.c b/ports/sysdeps/m68k/fpu/e_asinl.c
new file mode 100644
index 000000000..0dd89fb9d
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_asinl.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_asinl
+#include <e_acosl.c>
diff --git a/ports/sysdeps/m68k/fpu/e_atan2.c b/ports/sysdeps/m68k/fpu/e_atan2.c
new file mode 100644
index 000000000..551b14db8
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_atan2.c
@@ -0,0 +1,104 @@
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include "math_private.h"
+#include "mathimpl.h"
+
+#ifndef SUFF
+#define SUFF
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define CONCATX(a,b) __CONCAT(a,b)
+#define s(name) CONCATX(name,SUFF)
+#define m81(func) __m81_u(s(func))
+
+float_type
+s(__ieee754_atan2) (float_type y, float_type x)
+{
+ float_type pi, pi_2, z;
+ unsigned long y_cond, x_cond;
+
+ __asm ("fmovecr%.x %#0, %0" : "=f" (pi));
+ __asm ("fscale%.w %#-1, %0" : "=f" (pi_2) : "0" (pi));
+ y_cond = __m81_test (y);
+ x_cond = __m81_test (x);
+
+ if ((x_cond | y_cond) & __M81_COND_NAN)
+ z = x + y;
+ else if (y_cond & __M81_COND_ZERO)
+ {
+ if (x_cond & __M81_COND_NEG)
+ z = y_cond & __M81_COND_NEG ? -pi : pi;
+ else
+ z = y;
+ }
+ else if (x_cond & __M81_COND_INF)
+ {
+ if (y_cond & __M81_COND_INF)
+ {
+ float_type pi_4;
+ __asm ("fscale%.w %#-2, %0" : "=f" (pi_4) : "0" (pi));
+ z = x_cond & __M81_COND_NEG ? 3 * pi_4 : pi_4;
+ }
+ else
+ z = x_cond & __M81_COND_NEG ? pi : 0;
+ if (y_cond & __M81_COND_NEG)
+ z = -z;
+ }
+ else if (y_cond & __M81_COND_INF)
+ z = y_cond & __M81_COND_NEG ? -pi_2 : pi_2;
+ else if (x_cond & __M81_COND_NEG)
+ {
+ if (y_cond & __M81_COND_NEG)
+ {
+ if (-x > -y)
+ z = -pi + m81(__atan) (y / x);
+ else
+ z = -pi_2 - m81(__atan) (x / y);
+ }
+ else
+ {
+ if (-x > y)
+ z = pi + m81(__atan) (y / x);
+ else
+ z = pi_2 - m81(__atan) (x / y);
+ }
+ }
+ else
+ {
+ if (y_cond & __M81_COND_NEG)
+ {
+ if (x > -y)
+ z = m81(__atan) (y / x);
+ else
+ z = -pi_2 - m81(__atan) (x / y);
+ }
+ else
+ {
+ if (x > y)
+ z = m81(__atan) (y / x);
+ else
+ z = pi_2 - m81(__atan) (x / y);
+ }
+ }
+ return z;
+}
diff --git a/ports/sysdeps/m68k/fpu/e_atan2f.c b/ports/sysdeps/m68k/fpu/e_atan2f.c
new file mode 100644
index 000000000..a0c750a75
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_atan2f.c
@@ -0,0 +1,3 @@
+#define SUFF f
+#define float_type float
+#include <e_atan2.c>
diff --git a/ports/sysdeps/m68k/fpu/e_atan2l.c b/ports/sysdeps/m68k/fpu/e_atan2l.c
new file mode 100644
index 000000000..426ca94ba
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_atan2l.c
@@ -0,0 +1,3 @@
+#define SUFF l
+#define float_type long double
+#include <e_atan2.c>
diff --git a/ports/sysdeps/m68k/fpu/e_atanh.c b/ports/sysdeps/m68k/fpu/e_atanh.c
new file mode 100644
index 000000000..11bf43068
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_atanh.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_atanh
+#include <e_acos.c>
diff --git a/ports/sysdeps/m68k/fpu/e_atanhf.c b/ports/sysdeps/m68k/fpu/e_atanhf.c
new file mode 100644
index 000000000..7a8f92ecf
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_atanhf.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_atanhf
+#include <e_acosf.c>
diff --git a/ports/sysdeps/m68k/fpu/e_atanhl.c b/ports/sysdeps/m68k/fpu/e_atanhl.c
new file mode 100644
index 000000000..d8975d678
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_atanhl.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_atanhl
+#include <e_acosl.c>
diff --git a/ports/sysdeps/m68k/fpu/e_cosh.c b/ports/sysdeps/m68k/fpu/e_cosh.c
new file mode 100644
index 000000000..93d753c51
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_cosh.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_cosh
+#include <e_acos.c>
diff --git a/ports/sysdeps/m68k/fpu/e_coshf.c b/ports/sysdeps/m68k/fpu/e_coshf.c
new file mode 100644
index 000000000..433faf17b
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_coshf.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_coshf
+#include <e_acosf.c>
diff --git a/ports/sysdeps/m68k/fpu/e_coshl.c b/ports/sysdeps/m68k/fpu/e_coshl.c
new file mode 100644
index 000000000..39144fd20
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_coshl.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_coshl
+#include <e_acosl.c>
diff --git a/ports/sysdeps/m68k/fpu/e_exp.c b/ports/sysdeps/m68k/fpu/e_exp.c
new file mode 100644
index 000000000..1e95ac474
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_exp.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_exp
+#include <e_acos.c>
diff --git a/ports/sysdeps/m68k/fpu/e_exp10.c b/ports/sysdeps/m68k/fpu/e_exp10.c
new file mode 100644
index 000000000..a1dd22447
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_exp10.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_exp10
+#include <e_acos.c>
diff --git a/ports/sysdeps/m68k/fpu/e_exp10f.c b/ports/sysdeps/m68k/fpu/e_exp10f.c
new file mode 100644
index 000000000..1b78bc372
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_exp10f.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_exp10f
+#include <e_acosf.c>
diff --git a/ports/sysdeps/m68k/fpu/e_exp10l.c b/ports/sysdeps/m68k/fpu/e_exp10l.c
new file mode 100644
index 000000000..5e901999f
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_exp10l.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_exp10l
+#include <e_acosl.c>
diff --git a/ports/sysdeps/m68k/fpu/e_exp2.c b/ports/sysdeps/m68k/fpu/e_exp2.c
new file mode 100644
index 000000000..24fac4fce
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_exp2.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_exp2
+#include <e_acos.c>
diff --git a/ports/sysdeps/m68k/fpu/e_exp2f.c b/ports/sysdeps/m68k/fpu/e_exp2f.c
new file mode 100644
index 000000000..593842e4e
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_exp2f.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_exp2f
+#include <e_acosf.c>
diff --git a/ports/sysdeps/m68k/fpu/e_exp2l.c b/ports/sysdeps/m68k/fpu/e_exp2l.c
new file mode 100644
index 000000000..0ab2a428c
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_exp2l.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_exp2l
+#include <e_acosl.c>
diff --git a/ports/sysdeps/m68k/fpu/e_expf.c b/ports/sysdeps/m68k/fpu/e_expf.c
new file mode 100644
index 000000000..2aeaacfab
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_expf.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_expf
+#include <e_acosf.c>
diff --git a/ports/sysdeps/m68k/fpu/e_expl.c b/ports/sysdeps/m68k/fpu/e_expl.c
new file mode 100644
index 000000000..8805a1b83
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_expl.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_expl
+#include <e_acosl.c>
diff --git a/ports/sysdeps/m68k/fpu/e_fmod.c b/ports/sysdeps/m68k/fpu/e_fmod.c
new file mode 100644
index 000000000..bd229ae4b
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_fmod.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include "math_private.h"
+#include "mathimpl.h"
+
+#ifndef FUNC
+#define FUNC __ieee754_fmod
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+float_type
+FUNC (x, y)
+ float_type x;
+ float_type y;
+{
+ return __m81_u(FUNC)(x, y);
+}
diff --git a/ports/sysdeps/m68k/fpu/e_fmodf.c b/ports/sysdeps/m68k/fpu/e_fmodf.c
new file mode 100644
index 000000000..88c350ce9
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_fmodf.c
@@ -0,0 +1,5 @@
+#ifndef FUNC
+#define FUNC __ieee754_fmodf
+#endif
+#define float_type float
+#include <e_fmod.c>
diff --git a/ports/sysdeps/m68k/fpu/e_fmodl.c b/ports/sysdeps/m68k/fpu/e_fmodl.c
new file mode 100644
index 000000000..a46f19ea9
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_fmodl.c
@@ -0,0 +1,5 @@
+#ifndef FUNC
+#define FUNC __ieee754_fmodl
+#endif
+#define float_type long double
+#include <e_fmod.c>
diff --git a/ports/sysdeps/m68k/fpu/e_log.c b/ports/sysdeps/m68k/fpu/e_log.c
new file mode 100644
index 000000000..146dc0c78
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_log.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_log
+#include <e_acos.c>
diff --git a/ports/sysdeps/m68k/fpu/e_log10.c b/ports/sysdeps/m68k/fpu/e_log10.c
new file mode 100644
index 000000000..06a9b87cb
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_log10.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_log10
+#include <e_acos.c>
diff --git a/ports/sysdeps/m68k/fpu/e_log10f.c b/ports/sysdeps/m68k/fpu/e_log10f.c
new file mode 100644
index 000000000..3896864ec
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_log10f.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_log10f
+#include <e_acosf.c>
diff --git a/ports/sysdeps/m68k/fpu/e_log10l.c b/ports/sysdeps/m68k/fpu/e_log10l.c
new file mode 100644
index 000000000..6dcfc5a10
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_log10l.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_log10l
+#include <e_acosl.c>
diff --git a/ports/sysdeps/m68k/fpu/e_log2.c b/ports/sysdeps/m68k/fpu/e_log2.c
new file mode 100644
index 000000000..5528922b9
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_log2.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_log2
+#include <e_acos.c>
diff --git a/ports/sysdeps/m68k/fpu/e_log2f.c b/ports/sysdeps/m68k/fpu/e_log2f.c
new file mode 100644
index 000000000..6b4907686
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_log2f.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_log2f
+#include <e_acosf.c>
diff --git a/ports/sysdeps/m68k/fpu/e_log2l.c b/ports/sysdeps/m68k/fpu/e_log2l.c
new file mode 100644
index 000000000..4c92a11ac
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_log2l.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_log2l
+#include <e_acosl.c>
diff --git a/ports/sysdeps/m68k/fpu/e_logf.c b/ports/sysdeps/m68k/fpu/e_logf.c
new file mode 100644
index 000000000..bc23217c3
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_logf.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_logf
+#include <e_acosf.c>
diff --git a/ports/sysdeps/m68k/fpu/e_logl.c b/ports/sysdeps/m68k/fpu/e_logl.c
new file mode 100644
index 000000000..03b183075
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_logl.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_logl
+#include <e_acosl.c>
diff --git a/ports/sysdeps/m68k/fpu/e_pow.c b/ports/sysdeps/m68k/fpu/e_pow.c
new file mode 100644
index 000000000..0b6cee6f1
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_pow.c
@@ -0,0 +1,126 @@
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include "math_private.h"
+#include "mathimpl.h"
+
+#ifndef SUFF
+#define SUFF
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define CONCATX(a,b) __CONCAT(a,b)
+#define s(name) CONCATX(name,SUFF)
+#define m81(func) __m81_u(s(func))
+
+float_type
+s(__ieee754_pow) (float_type x, float_type y)
+{
+ float_type z;
+ float_type ax;
+ unsigned long x_cond, y_cond;
+
+ y_cond = __m81_test (y);
+ if (y_cond & __M81_COND_ZERO)
+ return 1.0;
+ if (y_cond & __M81_COND_NAN)
+ return x == 1.0 ? x : x + y;
+
+ x_cond = __m81_test (x);
+ if (x_cond & __M81_COND_NAN)
+ return x + y;
+
+ if (y_cond & __M81_COND_INF)
+ {
+ ax = s(fabs) (x);
+ if (ax == 1.0)
+ return ax;
+ if (ax > 1.0)
+ return y_cond & __M81_COND_NEG ? 0 : y;
+ else
+ return y_cond & __M81_COND_NEG ? -y : 0;
+ }
+
+ if (s(fabs) (y) == 1.0)
+ return y_cond & __M81_COND_NEG ? 1 / x : x;
+
+ if (y == 2)
+ return x * x;
+ if (y == 0.5 && !(x_cond & __M81_COND_NEG))
+ return m81(__ieee754_sqrt) (x);
+
+ if (x == 10.0)
+ {
+ __asm ("ftentox%.x %1, %0" : "=f" (z) : "f" (y));
+ return z;
+ }
+ if (x == 2.0)
+ {
+ __asm ("ftwotox%.x %1, %0" : "=f" (z) : "f" (y));
+ return z;
+ }
+
+ ax = s(fabs) (x);
+ if (x_cond & (__M81_COND_INF | __M81_COND_ZERO) || ax == 1.0)
+ {
+ z = ax;
+ if (y_cond & __M81_COND_NEG)
+ z = 1 / z;
+ if (x_cond & __M81_COND_NEG)
+ {
+ if (y != m81(__rint) (y))
+ {
+ if (x == -1)
+ z = (z - z) / (z - z);
+ }
+ else
+ goto maybe_negate;
+ }
+ return z;
+ }
+
+ if (x_cond & __M81_COND_NEG)
+ {
+ if (y == m81(__rint) (y))
+ {
+ z = m81(__ieee754_exp) (y * m81(__ieee754_log) (-x));
+ maybe_negate:
+ /* We always use the long double format, since y is already in
+ this format and rounding won't change the result. */
+ {
+ int32_t exponent;
+ u_int32_t i0, i1;
+ GET_LDOUBLE_WORDS (exponent, i0, i1, y);
+ exponent = (exponent & 0x7fff) - 0x3fff;
+ if (exponent <= 31
+ ? i0 & (1 << (31 - exponent))
+ : (exponent <= 63
+ && i1 & (1 << (63 - exponent))))
+ z = -z;
+ }
+ }
+ else
+ z = (y - y) / (y - y);
+ }
+ else
+ z = m81(__ieee754_exp) (y * m81(__ieee754_log) (x));
+ return z;
+}
diff --git a/ports/sysdeps/m68k/fpu/e_powf.c b/ports/sysdeps/m68k/fpu/e_powf.c
new file mode 100644
index 000000000..379014355
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_powf.c
@@ -0,0 +1,3 @@
+#define SUFF f
+#define float_type float
+#include <e_pow.c>
diff --git a/ports/sysdeps/m68k/fpu/e_powl.c b/ports/sysdeps/m68k/fpu/e_powl.c
new file mode 100644
index 000000000..f71fa34a2
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_powl.c
@@ -0,0 +1,3 @@
+#define SUFF l
+#define float_type long double
+#include <e_pow.c>
diff --git a/ports/sysdeps/m68k/fpu/e_rem_pio2.c b/ports/sysdeps/m68k/fpu/e_rem_pio2.c
new file mode 100644
index 000000000..1347b0468
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_rem_pio2.c
@@ -0,0 +1,3 @@
+/* Empty. This file is only meant to avoid compiling the file with the
+ same name in the libm-ieee754 directory. The code is not used since
+ there is an assembler version for all users of this file. */
diff --git a/ports/sysdeps/m68k/fpu/e_rem_pio2f.c b/ports/sysdeps/m68k/fpu/e_rem_pio2f.c
new file mode 100644
index 000000000..1347b0468
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_rem_pio2f.c
@@ -0,0 +1,3 @@
+/* Empty. This file is only meant to avoid compiling the file with the
+ same name in the libm-ieee754 directory. The code is not used since
+ there is an assembler version for all users of this file. */
diff --git a/ports/sysdeps/m68k/fpu/e_rem_pio2l.c b/ports/sysdeps/m68k/fpu/e_rem_pio2l.c
new file mode 100644
index 000000000..1347b0468
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_rem_pio2l.c
@@ -0,0 +1,3 @@
+/* Empty. This file is only meant to avoid compiling the file with the
+ same name in the libm-ieee754 directory. The code is not used since
+ there is an assembler version for all users of this file. */
diff --git a/ports/sysdeps/m68k/fpu/e_remainder.c b/ports/sysdeps/m68k/fpu/e_remainder.c
new file mode 100644
index 000000000..aa31bc011
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_remainder.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_remainder
+#include <e_fmod.c>
diff --git a/ports/sysdeps/m68k/fpu/e_remainderf.c b/ports/sysdeps/m68k/fpu/e_remainderf.c
new file mode 100644
index 000000000..b04f0c87c
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_remainderf.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_remainderf
+#include <e_fmodf.c>
diff --git a/ports/sysdeps/m68k/fpu/e_remainderl.c b/ports/sysdeps/m68k/fpu/e_remainderl.c
new file mode 100644
index 000000000..b9dc540cc
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_remainderl.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_remainderl
+#include <e_fmodl.c>
diff --git a/ports/sysdeps/m68k/fpu/e_scalb.c b/ports/sysdeps/m68k/fpu/e_scalb.c
new file mode 100644
index 000000000..88edba1ca
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_scalb.c
@@ -0,0 +1,60 @@
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include "math_private.h"
+#include "mathimpl.h"
+
+#ifndef SUFF
+#define SUFF
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define CONCATX(a,b) __CONCAT(a,b)
+#define s(name) CONCATX(name,SUFF)
+#define m81(func) __m81_u(s(func))
+
+float_type
+s(__ieee754_scalb) (float_type x, float_type fn)
+{
+ float_type retval;
+ unsigned long x_cond = __m81_test (x);
+ unsigned long fn_cond = __m81_test (fn);
+
+ if ((x_cond | fn_cond) & __M81_COND_NAN)
+ return x * fn;
+
+ if (fn_cond & __M81_COND_INF)
+ {
+ if (!(fn_cond & __M81_COND_NEG))
+ return x * fn;
+ else if (x_cond & __M81_COND_ZERO)
+ return x;
+ else
+ return x / -fn;
+ }
+
+ if (m81(__rint) (fn) != fn)
+ return (x - x) / (x - x);
+
+ __asm ("fscale%.x %1, %0" : "=f" (retval) : "f" (fn), "0" (x));
+ return retval;
+}
diff --git a/ports/sysdeps/m68k/fpu/e_scalbf.c b/ports/sysdeps/m68k/fpu/e_scalbf.c
new file mode 100644
index 000000000..794357124
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_scalbf.c
@@ -0,0 +1,3 @@
+#define SUFF f
+#define float_type float
+#include <e_scalb.c>
diff --git a/ports/sysdeps/m68k/fpu/e_scalbl.c b/ports/sysdeps/m68k/fpu/e_scalbl.c
new file mode 100644
index 000000000..35fb2dc0e
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_scalbl.c
@@ -0,0 +1,3 @@
+#define SUFF l
+#define float_type long double
+#include <e_scalb.c>
diff --git a/ports/sysdeps/m68k/fpu/e_sinh.c b/ports/sysdeps/m68k/fpu/e_sinh.c
new file mode 100644
index 000000000..c6fed7ff4
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_sinh.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_sinh
+#include <e_acos.c>
diff --git a/ports/sysdeps/m68k/fpu/e_sinhf.c b/ports/sysdeps/m68k/fpu/e_sinhf.c
new file mode 100644
index 000000000..b5034b7b0
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_sinhf.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_sinhf
+#include <e_acosf.c>
diff --git a/ports/sysdeps/m68k/fpu/e_sinhl.c b/ports/sysdeps/m68k/fpu/e_sinhl.c
new file mode 100644
index 000000000..2f42d96a3
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_sinhl.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_sinhl
+#include <e_acosl.c>
diff --git a/ports/sysdeps/m68k/fpu/e_sqrt.c b/ports/sysdeps/m68k/fpu/e_sqrt.c
new file mode 100644
index 000000000..70f19710c
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_sqrt.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_sqrt
+#include <e_acos.c>
diff --git a/ports/sysdeps/m68k/fpu/e_sqrtf.c b/ports/sysdeps/m68k/fpu/e_sqrtf.c
new file mode 100644
index 000000000..5dc1904cb
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_sqrtf.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_sqrtf
+#include <e_acosf.c>
diff --git a/ports/sysdeps/m68k/fpu/e_sqrtl.c b/ports/sysdeps/m68k/fpu/e_sqrtl.c
new file mode 100644
index 000000000..fede1024a
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/e_sqrtl.c
@@ -0,0 +1,2 @@
+#define FUNC __ieee754_sqrtl
+#include <e_acosl.c>
diff --git a/ports/sysdeps/m68k/fpu/fclrexcpt.c b/ports/sysdeps/m68k/fpu/fclrexcpt.c
new file mode 100644
index 000000000..bcd7a3fe5
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/fclrexcpt.c
@@ -0,0 +1,50 @@
+/* Clear given exceptions in current floating-point environment.
+ Copyright (C) 1997,99,2000,01 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+__feclearexcept (int excepts)
+{
+ fexcept_t fpsr;
+
+ /* Mask out unsupported bits/exceptions. */
+ excepts &= FE_ALL_EXCEPT;
+
+ /* Fetch the fpu status register. */
+ __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr));
+
+ /* Clear the relevant bits. */
+ fpsr &= ~excepts;
+
+ /* Put the new data in effect. */
+ __asm__ __volatile__ ("fmove%.l %0,%/fpsr" : : "dm" (fpsr));
+
+ /* Success. */
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__feclearexcept, __old_feclearexcept)
+compat_symbol (libm, __old_feclearexcept, feclearexcept, GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, __feclearexcept, feclearexcept, GLIBC_2_2);
diff --git a/ports/sysdeps/m68k/fpu/fedisblxcpt.c b/ports/sysdeps/m68k/fpu/fedisblxcpt.c
new file mode 100644
index 000000000..416e0ba46
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/fedisblxcpt.c
@@ -0,0 +1,39 @@
+/* Disable floating-point exceptions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@suse.de>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+fedisableexcept (int excepts)
+{
+ unsigned int old_exc, new_exc;
+
+ /* Get the current control register contents. */
+ __asm__ ("fmove%.l %!,%0" : "=dm" (new_exc));
+
+ old_exc = (new_exc >> 6) & FE_ALL_EXCEPT;
+
+ excepts &= FE_ALL_EXCEPT;
+
+ new_exc &= ~(excepts << 6);
+ __asm__ ("fmove%.l %0,%!" : : "dm" (new_exc));
+
+ return old_exc;
+}
diff --git a/ports/sysdeps/m68k/fpu/feenablxcpt.c b/ports/sysdeps/m68k/fpu/feenablxcpt.c
new file mode 100644
index 000000000..f963acf01
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/feenablxcpt.c
@@ -0,0 +1,39 @@
+/* Enable floating-point exceptions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@suse.de>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+feenableexcept (int excepts)
+{
+ unsigned int new_exc, old_exc;
+
+ /* Get the current control register contents. */
+ __asm__ ("fmove%.l %!,%0" : "=dm" (new_exc));
+
+ old_exc = (new_exc >> 6) & FE_ALL_EXCEPT;
+
+ excepts &= FE_ALL_EXCEPT;
+
+ new_exc |= excepts << 6;
+ __asm__ ("fmove%.l %0,%!" : : "dm" (new_exc));
+
+ return old_exc;
+}
diff --git a/ports/sysdeps/m68k/fpu/fegetenv.c b/ports/sysdeps/m68k/fpu/fegetenv.c
new file mode 100644
index 000000000..6c94b0731
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/fegetenv.c
@@ -0,0 +1,38 @@
+/* Store current floating-point environment.
+ Copyright (C) 1997,99,2000,01 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+__fegetenv (fenv_t *envp)
+{
+ __asm__ ("fmovem%.l %/fpcr/%/fpsr/%/fpiar,%0" : "=m" (*envp));
+
+ /* Success. */
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__fegetenv, __old_fegetenv)
+compat_symbol (libm, __old_fegetenv, fegetenv, GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, __fegetenv, fegetenv, GLIBC_2_2);
diff --git a/ports/sysdeps/m68k/fpu/fegetexcept.c b/ports/sysdeps/m68k/fpu/fegetexcept.c
new file mode 100644
index 000000000..b34b2c1e2
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/fegetexcept.c
@@ -0,0 +1,32 @@
+/* Get enabled floating-point exceptions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@suse.de>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+fegetexcept (void)
+{
+ unsigned int exc;
+
+ /* Get the current control register contents. */
+ __asm__ ("fmove%.l %!,%0" : "=dm" (exc));
+
+ return (exc >> 6) & FE_ALL_EXCEPT;
+}
diff --git a/ports/sysdeps/m68k/fpu/fegetround.c b/ports/sysdeps/m68k/fpu/fegetround.c
new file mode 100644
index 000000000..74fc56f74
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/fegetround.c
@@ -0,0 +1,31 @@
+/* Return current rounding direction.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+fegetround (void)
+{
+ int fpcr;
+
+ __asm__ ("fmove%.l %!,%0" : "=dm" (fpcr));
+
+ return fpcr & FE_UPWARD;
+}
diff --git a/ports/sysdeps/m68k/fpu/feholdexcpt.c b/ports/sysdeps/m68k/fpu/feholdexcpt.c
new file mode 100644
index 000000000..88fb1c59a
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/feholdexcpt.c
@@ -0,0 +1,39 @@
+/* Store current floating-point environment and clear exceptions.
+ Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+feholdexcept (fenv_t *envp)
+{
+ fexcept_t fpcr, fpsr;
+
+ /* Store the environment. */
+ __asm__ ("fmovem%.l %/fpcr/%/fpsr/%/fpiar,%0" : "=m" (*envp));
+
+ /* Now clear all exceptions. */
+ fpsr = envp->__status_register & ~FE_ALL_EXCEPT;
+ __asm__ __volatile__ ("fmove%.l %0,%/fpsr" : : "dm" (fpsr));
+ /* And set all exceptions to non-stop. */
+ fpcr = envp->__control_register & ~(FE_ALL_EXCEPT << 6);
+ __asm__ __volatile__ ("fmove%.l %0,%!" : : "dm" (fpcr));
+
+ return 0;
+}
diff --git a/ports/sysdeps/m68k/fpu/fesetenv.c b/ports/sysdeps/m68k/fpu/fesetenv.c
new file mode 100644
index 000000000..20653f0dd
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/fesetenv.c
@@ -0,0 +1,60 @@
+/* Install given floating-point environment.
+ Copyright (C) 1997,99,2000,01,02 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+__fesetenv (const fenv_t *envp)
+{
+ fenv_t temp;
+
+ /* Install the environment specified by ENVP. But there are a few
+ values which we do not want to come from the saved environment.
+ Therefore, we get the current environment and replace the values
+ we want to use from the environment specified by the parameter. */
+ __asm__ ("fmovem%.l %/fpcr/%/fpsr/%/fpiar,%0" : "=m" (*&temp));
+
+ temp.__status_register &= ~FE_ALL_EXCEPT;
+ temp.__control_register &= ~((FE_ALL_EXCEPT << 6) | FE_UPWARD);
+ if (envp == FE_DFL_ENV)
+ ;
+ else if (envp == FE_NOMASK_ENV)
+ temp.__control_register |= FE_ALL_EXCEPT << 6;
+ else
+ {
+ temp.__control_register |= (envp->__control_register
+ & ((FE_ALL_EXCEPT << 6) | FE_UPWARD));
+ temp.__status_register |= envp->__status_register & FE_ALL_EXCEPT;
+ }
+
+ __asm__ __volatile__ ("fmovem%.l %0,%/fpcr/%/fpsr/%/fpiar" : : "m" (*&temp));
+
+ /* Success. */
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__fesetenv, __old_fesetenv)
+compat_symbol (libm, __old_fesetenv, fesetenv, GLIBC_2_1);
+#endif
+
+libm_hidden_ver (__fesetenv, fesetenv)
+versioned_symbol (libm, __fesetenv, fesetenv, GLIBC_2_2);
diff --git a/ports/sysdeps/m68k/fpu/fesetround.c b/ports/sysdeps/m68k/fpu/fesetround.c
new file mode 100644
index 000000000..956325de8
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/fesetround.c
@@ -0,0 +1,38 @@
+/* Set current rounding direction.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+fesetround (int round)
+{
+ fexcept_t fpcr;
+
+ if (round & ~FE_UPWARD)
+ /* ROUND is no valid rounding mode. */
+ return 1;
+
+ __asm__ ("fmove%.l %!,%0" : "=dm" (fpcr));
+ fpcr &= ~FE_UPWARD;
+ fpcr |= round;
+ __asm__ __volatile__ ("fmove%.l %0,%!" : : "dm" (fpcr));
+
+ return 0;
+}
diff --git a/ports/sysdeps/m68k/fpu/feupdateenv.c b/ports/sysdeps/m68k/fpu/feupdateenv.c
new file mode 100644
index 000000000..2a6831387
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/feupdateenv.c
@@ -0,0 +1,50 @@
+/* Install given floating-point environment and raise exceptions.
+ Copyright (C) 1997,99,2000,01 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+__feupdateenv (const fenv_t *envp)
+{
+ fexcept_t fpsr;
+
+ /* Save current exceptions. */
+ __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr));
+ fpsr &= FE_ALL_EXCEPT;
+
+ /* Install new environment. */
+ fesetenv (envp);
+
+ /* Raise the saved exception. Incidently for us the implementation
+ defined format of the values in objects of type fexcept_t is the
+ same as the ones specified using the FE_* constants. */
+ feraiseexcept ((int) fpsr);
+
+ /* Success. */
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__feupdateenv, __old_feupdateenv)
+compat_symbol (libm, __old_feupdateenv, feupdateenv, GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, __feupdateenv, feupdateenv, GLIBC_2_2);
diff --git a/ports/sysdeps/m68k/fpu/fgetexcptflg.c b/ports/sysdeps/m68k/fpu/fgetexcptflg.c
new file mode 100644
index 000000000..764b900c0
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/fgetexcptflg.c
@@ -0,0 +1,43 @@
+/* Store current representation for exceptions.
+ Copyright (C) 1997,99,2000,01 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+__fegetexceptflag (fexcept_t *flagp, int excepts)
+{
+ fexcept_t fpsr;
+
+ /* Get the current exceptions. */
+ __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr));
+
+ *flagp = fpsr & excepts & FE_ALL_EXCEPT;
+
+ /* Success. */
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__fegetexceptflag, __old_fegetexceptflag)
+compat_symbol (libm, __old_fegetexceptflag, fegetexceptflag, GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, __fegetexceptflag, fegetexceptflag, GLIBC_2_2);
diff --git a/ports/sysdeps/m68k/fpu/fraiseexcpt.c b/ports/sysdeps/m68k/fpu/fraiseexcpt.c
new file mode 100644
index 000000000..69f746c9b
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/fraiseexcpt.c
@@ -0,0 +1,83 @@
+/* Raise given exceptions.
+ Copyright (C) 1997,99,2000,01,02 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <float.h>
+#include <math.h>
+
+int
+__feraiseexcept (int excepts)
+{
+ /* Raise exceptions represented by EXCEPTS. But we must raise only one
+ signal at a time. It is important that if the overflow/underflow
+ exception and the divide by zero exception are given at the same
+ time, the overflow/underflow exception follows the divide by zero
+ exception. */
+
+ /* First: invalid exception. */
+ if (excepts & FE_INVALID)
+ {
+ /* One example of a invalid operation is 0 * Infinity. */
+ double d = HUGE_VAL;
+ __asm__ __volatile__ ("fmul%.s %#0r0,%0; fnop" : "=f" (d) : "0" (d));
+ }
+
+ /* Next: division by zero. */
+ if (excepts & FE_DIVBYZERO)
+ {
+ double d = 1.0;
+ __asm__ __volatile__ ("fdiv%.s %#0r0,%0; fnop" : "=f" (d) : "0" (d));
+ }
+
+ /* Next: overflow. */
+ if (excepts & FE_OVERFLOW)
+ {
+ long double d = LDBL_MAX;
+
+ __asm__ __volatile__ ("fmul%.x %0,%0; fnop" : "=f" (d) : "0" (d));
+ }
+
+ /* Next: underflow. */
+ if (excepts & FE_UNDERFLOW)
+ {
+ long double d = -LDBL_MAX;
+
+ __asm__ __volatile__ ("fetox%.x %0; fnop" : "=f" (d) : "0" (d));
+ }
+
+ /* Last: inexact. */
+ if (excepts & FE_INEXACT)
+ {
+ long double d = 1.0;
+ __asm__ __volatile__ ("fdiv%.s %#0r3,%0; fnop" : "=f" (d) : "0" (d));
+ }
+
+ /* Success. */
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__feraiseexcept, __old_feraiseexcept)
+compat_symbol (libm, __old_feraiseexcept, feraiseexcept, GLIBC_2_1);
+#endif
+
+libm_hidden_ver (__feraiseexcept, feraiseexcept)
+versioned_symbol (libm, __feraiseexcept, feraiseexcept, GLIBC_2_2);
diff --git a/ports/sysdeps/m68k/fpu/fsetexcptflg.c b/ports/sysdeps/m68k/fpu/fsetexcptflg.c
new file mode 100644
index 000000000..51b086a8f
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/fsetexcptflg.c
@@ -0,0 +1,49 @@
+/* Set floating-point environment exception handling.
+ Copyright (C) 1997,99,2000,01 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <math.h>
+
+int
+__fesetexceptflag (const fexcept_t *flagp, int excepts)
+{
+ fexcept_t fpsr;
+
+ /* Get the current status register. */
+ __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr));
+
+ /* Install the new exception bits in the Accrued Exception Byte. */
+ fpsr &= ~(excepts & FE_ALL_EXCEPT);
+ fpsr |= *flagp & excepts & FE_ALL_EXCEPT;
+
+ /* Store the new status register. */
+ __asm__ __volatile__ ("fmove%.l %0,%/fpsr" : : "dm" (fpsr));
+
+ /* Success. */
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__fesetexceptflag, __old_fesetexceptflag)
+compat_symbol (libm, __old_fesetexceptflag, fesetexceptflag, GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, __fesetexceptflag, fesetexceptflag, GLIBC_2_2);
diff --git a/ports/sysdeps/m68k/fpu/ftestexcept.c b/ports/sysdeps/m68k/fpu/ftestexcept.c
new file mode 100644
index 000000000..3157c90d1
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/ftestexcept.c
@@ -0,0 +1,32 @@
+/* Test exception in current environment.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+int
+fetestexcept (int excepts)
+{
+ fexcept_t fpsr;
+
+ /* Get current exceptions. */
+ __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr));
+
+ return fpsr & excepts & FE_ALL_EXCEPT;
+}
diff --git a/ports/sysdeps/m68k/fpu/halfulp.c b/ports/sysdeps/m68k/fpu/halfulp.c
new file mode 100644
index 000000000..1cc893170
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/halfulp.c
@@ -0,0 +1 @@
+/* Not needed. */
diff --git a/ports/sysdeps/m68k/fpu/k_cos.c b/ports/sysdeps/m68k/fpu/k_cos.c
new file mode 100644
index 000000000..dd6c215c2
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/k_cos.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include "math_private.h"
+
+#ifndef FUNC
+#define FUNC cos
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define __CONCATX(a,b) __CONCAT(a,b)
+
+float_type
+__CONCATX(__kernel_,FUNC) (x, y)
+ float_type x;
+ float_type y;
+{
+ float_type sin_x, cos_x, sin_y, cos_y;
+ __asm__ __volatile__ ("fsincosx %2,%0:%1" : "=f" (cos_x), "=f" (sin_x)
+ : "f" (x));
+ __asm__ __volatile__ ("fsincosx %2,%0:%1" : "=f" (cos_y), "=f" (sin_y)
+ : "f" (y));
+ return cos_x * cos_y - sin_x * sin_y;
+}
diff --git a/ports/sysdeps/m68k/fpu/k_cosf.c b/ports/sysdeps/m68k/fpu/k_cosf.c
new file mode 100644
index 000000000..2a366d094
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/k_cosf.c
@@ -0,0 +1,3 @@
+#define FUNC cosf
+#define float_type float
+#include <k_cos.c>
diff --git a/ports/sysdeps/m68k/fpu/k_cosl.c b/ports/sysdeps/m68k/fpu/k_cosl.c
new file mode 100644
index 000000000..983b66544
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/k_cosl.c
@@ -0,0 +1,3 @@
+#define FUNC cosl
+#define float_type long double
+#include <k_cos.c>
diff --git a/ports/sysdeps/m68k/fpu/k_rem_pio2.c b/ports/sysdeps/m68k/fpu/k_rem_pio2.c
new file mode 100644
index 000000000..1347b0468
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/k_rem_pio2.c
@@ -0,0 +1,3 @@
+/* Empty. This file is only meant to avoid compiling the file with the
+ same name in the libm-ieee754 directory. The code is not used since
+ there is an assembler version for all users of this file. */
diff --git a/ports/sysdeps/m68k/fpu/k_rem_pio2f.c b/ports/sysdeps/m68k/fpu/k_rem_pio2f.c
new file mode 100644
index 000000000..1347b0468
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/k_rem_pio2f.c
@@ -0,0 +1,3 @@
+/* Empty. This file is only meant to avoid compiling the file with the
+ same name in the libm-ieee754 directory. The code is not used since
+ there is an assembler version for all users of this file. */
diff --git a/ports/sysdeps/m68k/fpu/k_rem_pio2l.c b/ports/sysdeps/m68k/fpu/k_rem_pio2l.c
new file mode 100644
index 000000000..1347b0468
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/k_rem_pio2l.c
@@ -0,0 +1,3 @@
+/* Empty. This file is only meant to avoid compiling the file with the
+ same name in the libm-ieee754 directory. The code is not used since
+ there is an assembler version for all users of this file. */
diff --git a/ports/sysdeps/m68k/fpu/k_sin.c b/ports/sysdeps/m68k/fpu/k_sin.c
new file mode 100644
index 000000000..652ca0e13
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/k_sin.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include "math_private.h"
+
+#ifndef FUNC
+#define FUNC sin
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define __CONCATX(a,b) __CONCAT(a,b)
+
+float_type
+__CONCATX(__kernel_,FUNC) (x, y, iy)
+ float_type x;
+ float_type y;
+ int iy;
+{
+ float_type sin_x, cos_x, sin_y, cos_y;
+ if (iy == 0)
+ return __m81_u(__CONCATX(__,FUNC)) (x);
+ __asm__ __volatile__ ("fsincosx %2,%0:%1" : "=f" (cos_x), "=f" (sin_x)
+ : "f" (x));
+ __asm__ __volatile__ ("fsincosx %2,%0:%1" : "=f" (cos_y), "=f" (sin_y)
+ : "f" (y));
+ return sin_x * cos_y + cos_x * sin_y;
+}
diff --git a/ports/sysdeps/m68k/fpu/k_sinf.c b/ports/sysdeps/m68k/fpu/k_sinf.c
new file mode 100644
index 000000000..7050347c4
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/k_sinf.c
@@ -0,0 +1,3 @@
+#define FUNC sinf
+#define float_type float
+#include <k_sin.c>
diff --git a/ports/sysdeps/m68k/fpu/k_sinl.c b/ports/sysdeps/m68k/fpu/k_sinl.c
new file mode 100644
index 000000000..5a647cafd
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/k_sinl.c
@@ -0,0 +1,3 @@
+#define FUNC sinl
+#define float_type long double
+#include <k_sin.c>
diff --git a/ports/sysdeps/m68k/fpu/k_tan.c b/ports/sysdeps/m68k/fpu/k_tan.c
new file mode 100644
index 000000000..28f6a80cf
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/k_tan.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include "math_private.h"
+
+#ifndef FUNC
+#define FUNC tan
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define __CONCATX(a,b) __CONCAT(a,b)
+
+float_type
+__CONCATX(__kernel_,FUNC) (x, y, iy)
+ float_type x;
+ float_type y;
+ int iy;
+{
+ float_type tan_x, tan_y;
+ tan_x = __m81_u(__CONCATX(__,FUNC)) (x);
+ tan_y = __m81_u(__CONCATX(__,FUNC)) (y);
+ if (iy > 0)
+ return (tan_x + tan_y) / (1 - tan_x * tan_y);
+ else
+ return (tan_x * tan_y - 1) / (tan_x + tan_y);
+}
diff --git a/ports/sysdeps/m68k/fpu/k_tanf.c b/ports/sysdeps/m68k/fpu/k_tanf.c
new file mode 100644
index 000000000..777af1bf1
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/k_tanf.c
@@ -0,0 +1,3 @@
+#define FUNC tanf
+#define float_type float
+#include <k_tan.c>
diff --git a/ports/sysdeps/m68k/fpu/k_tanl.c b/ports/sysdeps/m68k/fpu/k_tanl.c
new file mode 100644
index 000000000..f2570e681
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/k_tanl.c
@@ -0,0 +1,3 @@
+#define FUNC tanl
+#define float_type long double
+#include <k_tan.c>
diff --git a/ports/sysdeps/m68k/fpu/libm-test-ulps b/ports/sysdeps/m68k/fpu/libm-test-ulps
new file mode 100644
index 000000000..854c10cb1
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/libm-test-ulps
@@ -0,0 +1,1165 @@
+# Begin of automatic generation
+
+# acosh
+Test "acosh (7) == 2.63391579384963341725009269461593689":
+ildouble: 1
+ldouble: 1
+
+# asinh
+Test "asinh (0.75) == 0.693147180559945309417232121458176568":
+ildouble: 1
+ldouble: 1
+
+# atan2
+Test "atan2 (0.390625, .00029) == 1.57005392693128974780151246612928941":
+ildouble: 1
+ldouble: 1
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+ildouble: 1
+ldouble: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+ildouble: 1
+ldouble: 1
+
+# cacos
+Test "Real part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 6
+ldouble: 6
+Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: cacosh (0.75 + 1.25 i) == 1.13239363160530819522266333696834467 + 1.11752014915610270578240049553777969 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0.75 + 1.25 i) == 1.13239363160530819522266333696834467 + 1.11752014915610270578240049553777969 i":
+float: 1
+ifloat: 1
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 3
+ldouble: 3
+Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 6
+float: 19
+idouble: 6
+ifloat: 19
+ildouble: 5
+ldouble: 5
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 13
+float: 1
+idouble: 13
+ifloat: 1
+ildouble: 6
+ldouble: 6
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# catan
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+ildouble: 1
+ldouble: 1
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+ildouble: 1
+ldouble: 1
+
+# cbrt
+Test "cbrt (-0.001) == -0.1":
+ildouble: 1
+ldouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+ildouble: 1
+ldouble: 1
+
+# ccos
+Test "Real part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cexp
+Test "Real part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# clog
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+ildouble: 1
+ldouble: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+float: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+float: 1
+ifloat: 1
+ildouble: 9
+ldouble: 9
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 15
+ldouble: 15
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (2 + 0 i, 10 + 0 i) == 1024.0 + 0.0 i":
+ildouble: 5
+ldouble: 5
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 6
+ifloat: 6
+ildouble: 2
+ldouble: 2
+Test "Real part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 1
+ldouble: 1
+
+# csin
+Test "Real part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i":
+float: 1
+ifloat: 1
+Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+float: 1
+ifloat: 1
+
+# csinh
+Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+float: 1
+ifloat: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+ildouble: 2
+ldouble: 2
+
+# ctanh
+Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# erfc
+Test "erfc (0.75) == 0.288844366346484868401062165408589223":
+float: 1
+ifloat: 1
+Test "erfc (1.25) == 0.0770998717435417698634765188027188596":
+ildouble: 1
+ldouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+float: 1
+ifloat: 1
+
+# expm1
+Test "expm1 (1) == M_El - 1.0":
+ildouble: 1
+ldouble: 1
+
+# gamma
+Test "gamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "gamma (0.5) == log(sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "gamma (3) == M_LN2l":
+ildouble: 1
+ldouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (1.5) == 0.511827671735918128749051744283411720":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 1
+idouble: 1
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# j1
+Test "j1 (-1.0) == -0.440050585744933515959682203718914913":
+float: 1
+ifloat: 1
+Test "j1 (1.0) == 0.440050585744933515959682203718914913":
+float: 1
+ifloat: 1
+Test "j1 (1.5) == 0.557936507910099641990121213156089400":
+float: 1
+ifloat: 1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+float: 1
+ifloat: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 1.5) == 0.511827671735918128749051744283411720":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 1
+idouble: 1
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (1, -1.0) == -0.440050585744933515959682203718914913":
+float: 1
+ifloat: 1
+Test "jn (1, 1.0) == 0.440050585744933515959682203718914913":
+float: 1
+ifloat: 1
+Test "jn (1, 1.5) == 0.557936507910099641990121213156089400":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+float: 1
+ifloat: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+float: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 2
+ldouble: 2
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (3, -1.0) == -0.0195633539826684059189053216217515083":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (3, 1.0) == 0.0195633539826684059189053216217515083":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+ildouble: 1
+ldouble: 1
+
+# lgamma
+Test "lgamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.5) == log(sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "lgamma (3) == M_LN2l":
+ildouble: 1
+ldouble: 1
+
+# log
+Test "log (0.75) == -0.287682072451780927439219005993827432":
+ildouble: 1
+ldouble: 1
+Test "log (2) == M_LN2l":
+ildouble: 1
+ldouble: 1
+Test "log (e) == 1":
+float: 1
+ifloat: 1
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+ildouble: 2
+ldouble: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+ildouble: 1
+ldouble: 1
+
+# log2
+Test "log2 (0.75) == -.415037499278843818546261056052183492":
+ildouble: 1
+ldouble: 1
+
+# pow
+Test "pow (0.75, 1.25) == 0.697953644326574699205914060237425566":
+ildouble: 1
+ldouble: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# sinh
+Test "sinh (0.75) == 0.822316731935829980703661634446913849":
+ildouble: 1
+ldouble: 1
+
+# tan
+Test "tan (0.75) == 0.931596459944072461165202756573936428":
+ildouble: 1
+ldouble: 1
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (4) == 6":
+ildouble: 1
+ldouble: 1
+
+# y0
+Test "y0 (0.125) == -1.38968062514384052915582277745018693":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (0.75) == -0.137172769385772397522814379396581855":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+ildouble: 1
+ldouble: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+ildouble: 1
+ldouble: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+ildouble: 1
+ldouble: 1
+Test "y0 (2.0) == 0.510375672649745119596606592727157873":
+float: 1
+ifloat: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+ildouble: 1
+ldouble: 1
+Test "y1 (1.0) == -0.781212821300288716547150000047964821":
+double: 1
+idouble: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+float: 1
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+ildouble: 1
+ldouble: 1
+
+# yn
+Test "yn (0, 0.125) == -1.38968062514384052915582277745018693":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (0, 0.75) == -0.137172769385772397522814379396581855":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+ildouble: 1
+ldouble: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+ildouble: 1
+ldouble: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+ildouble: 1
+ldouble: 1
+Test "yn (0, 2.0) == 0.510375672649745119596606592727157873":
+float: 1
+ifloat: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 0.75) == -1.03759455076928541973767132140642198":
+float: 1
+ifloat: 1
+Test "yn (1, 1.0) == -0.781212821300288716547150000047964821":
+double: 1
+idouble: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+float: 1
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+ildouble: 1
+ldouble: 1
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+float: 1
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+ildouble: 1
+ldouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+float: 1
+ifloat: 1
+
+# Maximal error of functions:
+Function: "acosh":
+ildouble: 1
+ldouble: 1
+
+Function: "asinh":
+ildouble: 1
+ldouble: 1
+
+Function: "atan2":
+ildouble: 1
+ldouble: 1
+
+Function: "atanh":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cacos":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cacos":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 6
+ldouble: 6
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "casin":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 3
+ldouble: 3
+
+Function: Imaginary part of "casin":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "casinh":
+double: 6
+float: 19
+idouble: 6
+ifloat: 19
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "casinh":
+double: 13
+float: 1
+idouble: 13
+ifloat: 1
+ildouble: 6
+ldouble: 6
+
+Function: Real part of "catan":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+ildouble: 1
+ldouble: 1
+
+Function: "cbrt":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccosh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cexp":
+float: 2
+ifloat: 2
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cpow":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 15
+ldouble: 15
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 6
+idouble: 2
+ifloat: 6
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "csin":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csin":
+float: 1
+ifloat: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctan":
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "ctanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "erfc":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "expm1":
+ildouble: 1
+ldouble: 1
+
+Function: "gamma":
+ildouble: 1
+ldouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "j1":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "jn":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 2
+ldouble: 2
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "log10":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: "log1p":
+ildouble: 1
+ldouble: 1
+
+Function: "log2":
+ildouble: 1
+ldouble: 1
+
+Function: "pow":
+ildouble: 1
+ldouble: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sinh":
+ildouble: 1
+ldouble: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: "y1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "yn":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 4
+ldouble: 4
+
+# end of automatic generation
diff --git a/ports/sysdeps/m68k/fpu/mathimpl.h b/ports/sysdeps/m68k/fpu/mathimpl.h
new file mode 100644
index 000000000..bbcaf8485
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/mathimpl.h
@@ -0,0 +1,94 @@
+/* Definitions of libc internal inline math functions implemented
+ by the m68881/2.
+ Copyright (C) 1991,92,93,94,96,97,98,99 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file contains the definitions of the inline math functions that
+ are only used internally inside libm, not visible to the user. */
+
+__inline_mathop (__ieee754_acos, acos)
+__inline_mathop (__ieee754_asin, asin)
+__inline_mathop (__ieee754_cosh, cosh)
+__inline_mathop (__ieee754_sinh, sinh)
+__inline_mathop (__ieee754_exp, etox)
+__inline_mathop (__ieee754_exp2, twotox)
+__inline_mathop (__ieee754_exp10, tentox)
+__inline_mathop (__ieee754_log10, log10)
+__inline_mathop (__ieee754_log2, log2)
+__inline_mathop (__ieee754_log, logn)
+__inline_mathop (__ieee754_sqrt, sqrt)
+__inline_mathop (__ieee754_atanh, atanh)
+
+__m81_defun (double, __ieee754_remainder, (double __x, double __y))
+{
+ double __result;
+ __asm ("frem%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
+ return __result;
+}
+
+__m81_defun (float, __ieee754_remainderf, (float __x, float __y))
+{
+ float __result;
+ __asm ("frem%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
+ return __result;
+}
+
+__m81_defun (long double,
+ __ieee754_remainderl, (long double __x, long double __y))
+{
+ long double __result;
+ __asm ("frem%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
+ return __result;
+}
+
+__m81_defun (double, __ieee754_fmod, (double __x, double __y))
+{
+ double __result;
+ __asm ("fmod%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
+ return __result;
+}
+
+__m81_defun (float, __ieee754_fmodf, (float __x, float __y))
+{
+ float __result;
+ __asm ("fmod%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
+ return __result;
+}
+
+__m81_defun (long double,
+ __ieee754_fmodl, (long double __x, long double __y))
+{
+ long double __result;
+ __asm ("fmod%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x));
+ return __result;
+}
+
+/* Get the m68881 condition codes, to quickly check multiple conditions. */
+static __inline__ unsigned long
+__m81_test (long double __val)
+{
+ unsigned long __fpsr;
+ __asm ("ftst%.x %1; fmove%.l %/fpsr,%0" : "=dm" (__fpsr) : "f" (__val));
+ return __fpsr;
+}
+
+/* Bit values returned by __m81_test. */
+#define __M81_COND_NAN (1 << 24)
+#define __M81_COND_INF (2 << 24)
+#define __M81_COND_ZERO (4 << 24)
+#define __M81_COND_NEG (8 << 24)
diff --git a/ports/sysdeps/m68k/fpu/mpa.c b/ports/sysdeps/m68k/fpu/mpa.c
new file mode 100644
index 000000000..1cc893170
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/mpa.c
@@ -0,0 +1 @@
+/* Not needed. */
diff --git a/ports/sysdeps/m68k/fpu/mpatan.c b/ports/sysdeps/m68k/fpu/mpatan.c
new file mode 100644
index 000000000..1cc893170
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/mpatan.c
@@ -0,0 +1 @@
+/* Not needed. */
diff --git a/ports/sysdeps/m68k/fpu/mpatan2.c b/ports/sysdeps/m68k/fpu/mpatan2.c
new file mode 100644
index 000000000..1cc893170
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/mpatan2.c
@@ -0,0 +1 @@
+/* Not needed. */
diff --git a/ports/sysdeps/m68k/fpu/mpexp.c b/ports/sysdeps/m68k/fpu/mpexp.c
new file mode 100644
index 000000000..1cc893170
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/mpexp.c
@@ -0,0 +1 @@
+/* Not needed. */
diff --git a/ports/sysdeps/m68k/fpu/mplog.c b/ports/sysdeps/m68k/fpu/mplog.c
new file mode 100644
index 000000000..1cc893170
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/mplog.c
@@ -0,0 +1 @@
+/* Not needed. */
diff --git a/ports/sysdeps/m68k/fpu/mpsqrt.c b/ports/sysdeps/m68k/fpu/mpsqrt.c
new file mode 100644
index 000000000..1cc893170
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/mpsqrt.c
@@ -0,0 +1 @@
+/* Not needed. */
diff --git a/ports/sysdeps/m68k/fpu/mptan.c b/ports/sysdeps/m68k/fpu/mptan.c
new file mode 100644
index 000000000..1cc893170
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/mptan.c
@@ -0,0 +1 @@
+/* Not needed. */
diff --git a/ports/sysdeps/m68k/fpu/s_atan.c b/ports/sysdeps/m68k/fpu/s_atan.c
new file mode 100644
index 000000000..8cca490d2
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_atan.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+#ifndef FUNC
+#define FUNC atan
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define __CONCATX(a,b) __CONCAT(a,b)
+
+float_type
+__CONCATX(__,FUNC) (x)
+ float_type x;
+{
+ return __m81_u(__CONCATX(__,FUNC))(x);
+}
+
+#define weak_aliasx(a,b) weak_alias(a,b)
+weak_aliasx (__CONCATX(__,FUNC), FUNC)
diff --git a/ports/sysdeps/m68k/fpu/s_atanf.c b/ports/sysdeps/m68k/fpu/s_atanf.c
new file mode 100644
index 000000000..c98559a8b
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_atanf.c
@@ -0,0 +1,5 @@
+#ifndef FUNC
+#define FUNC atanf
+#endif
+#define float_type float
+#include <s_atan.c>
diff --git a/ports/sysdeps/m68k/fpu/s_atanl.c b/ports/sysdeps/m68k/fpu/s_atanl.c
new file mode 100644
index 000000000..b7e608add
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_atanl.c
@@ -0,0 +1,5 @@
+#ifndef FUNC
+#define FUNC atanl
+#endif
+#define float_type long double
+#include <s_atan.c>
diff --git a/ports/sysdeps/m68k/fpu/s_ccos.c b/ports/sysdeps/m68k/fpu/s_ccos.c
new file mode 100644
index 000000000..d302d3d86
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_ccos.c
@@ -0,0 +1,73 @@
+/* Complex cosine function. m68k fpu version
+ Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <complex.h>
+#include <math.h>
+#include "mathimpl.h"
+
+#ifndef SUFF
+#define SUFF
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define CONCATX(a,b) __CONCAT(a,b)
+#define s(name) CONCATX(name,SUFF)
+#define m81(func) __m81_u(s(func))
+
+__complex__ float_type
+s(__ccos) (__complex__ float_type x)
+{
+ __complex__ float_type retval;
+ unsigned long rx_cond = __m81_test (__real__ x);
+
+ if ((rx_cond & (__M81_COND_INF|__M81_COND_NAN)) == 0)
+ {
+ /* Real part is finite. */
+ float_type sin_rx, cos_rx;
+
+ __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_rx), "=f" (cos_rx)
+ : "f" (__real__ x));
+ __real__ retval = cos_rx * m81(__ieee754_cosh) (__imag__ x);
+ if (rx_cond & __M81_COND_ZERO)
+ __imag__ retval = (m81(__signbit) (__imag__ x)
+ ? __real__ x : -__real__ x);
+ else
+ __imag__ retval = -sin_rx * m81(__ieee754_sinh) (__imag__ x);
+ }
+ else
+ {
+ unsigned long ix_cond = __m81_test (__imag__ x);
+
+ if (ix_cond & __M81_COND_INF)
+ __real__ retval = s(fabs) (__imag__ x);
+ else
+ __real__ retval = __real__ x - __real__ x;
+ if (ix_cond & __M81_COND_ZERO)
+ __imag__ retval = __imag__ x;
+ else
+ __imag__ retval = __real__ x - __real__ x;
+ }
+
+ return retval;
+}
+#define weak_aliasx(a,b) weak_alias(a,b)
+weak_aliasx (s(__ccos), s(ccos))
diff --git a/ports/sysdeps/m68k/fpu/s_ccosf.c b/ports/sysdeps/m68k/fpu/s_ccosf.c
new file mode 100644
index 000000000..f5e8a41fa
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_ccosf.c
@@ -0,0 +1,3 @@
+#define SUFF f
+#define float_type float
+#include <s_ccos.c>
diff --git a/ports/sysdeps/m68k/fpu/s_ccosh.c b/ports/sysdeps/m68k/fpu/s_ccosh.c
new file mode 100644
index 000000000..1698881b9
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_ccosh.c
@@ -0,0 +1,78 @@
+/* Complex cosine hyperbole function. m68k fpu version
+ Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <complex.h>
+#include <math.h>
+#include "mathimpl.h"
+
+#ifndef SUFF
+#define SUFF
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define CONCATX(a,b) __CONCAT(a,b)
+#define s(name) CONCATX(name,SUFF)
+#define m81(func) __m81_u(s(func))
+
+__complex__ float_type
+s(__ccosh) (__complex__ float_type x)
+{
+ __complex__ float_type retval;
+ unsigned long ix_cond = __m81_test (__imag__ x);
+
+ if ((ix_cond & (__M81_COND_INF|__M81_COND_NAN)) == 0)
+ {
+ /* Imaginary part is finite. */
+ float_type sin_ix, cos_ix;
+
+ __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_ix), "=f" (cos_ix)
+ : "f" (__imag__ x));
+ __real__ retval = cos_ix * m81(__ieee754_cosh) (__real__ x);
+ if (ix_cond & __M81_COND_ZERO)
+ __imag__ retval = (m81(__signbit) (__real__ x)
+ ? -__imag__ x : __imag__ x);
+ else
+ __imag__ retval = sin_ix * m81(__ieee754_sinh) (__real__ x);
+ }
+ else
+ {
+ unsigned long rx_cond = __m81_test (__real__ x);
+
+ if (rx_cond & __M81_COND_ZERO)
+ {
+ __real__ retval = __imag__ x - __imag__ x;
+ __imag__ retval = __real__ x;
+ }
+ else
+ {
+ if (rx_cond & __M81_COND_INF)
+ __real__ retval = s(fabs) (__real__ x);
+ else
+ __real__ retval = 0.0/0.0;
+ __imag__ retval = __imag__ x - __imag__ x;
+ }
+ }
+
+ return retval;
+}
+#define weak_aliasx(a,b) weak_alias(a,b)
+weak_aliasx (s(__ccosh), s(ccosh))
diff --git a/ports/sysdeps/m68k/fpu/s_ccoshf.c b/ports/sysdeps/m68k/fpu/s_ccoshf.c
new file mode 100644
index 000000000..3c8e7c7bb
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_ccoshf.c
@@ -0,0 +1,3 @@
+#define SUFF f
+#define float_type float
+#include <s_ccosh.c>
diff --git a/ports/sysdeps/m68k/fpu/s_ccoshl.c b/ports/sysdeps/m68k/fpu/s_ccoshl.c
new file mode 100644
index 000000000..772d5786c
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_ccoshl.c
@@ -0,0 +1,3 @@
+#define SUFF l
+#define float_type long double
+#include <s_ccosh.c>
diff --git a/ports/sysdeps/m68k/fpu/s_ccosl.c b/ports/sysdeps/m68k/fpu/s_ccosl.c
new file mode 100644
index 000000000..aaff36520
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_ccosl.c
@@ -0,0 +1,3 @@
+#define SUFF l
+#define float_type long double
+#include <s_ccos.c>
diff --git a/ports/sysdeps/m68k/fpu/s_ceil.c b/ports/sysdeps/m68k/fpu/s_ceil.c
new file mode 100644
index 000000000..93d5ad72e
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_ceil.c
@@ -0,0 +1,2 @@
+#define FUNC ceil
+#include <s_atan.c>
diff --git a/ports/sysdeps/m68k/fpu/s_ceilf.c b/ports/sysdeps/m68k/fpu/s_ceilf.c
new file mode 100644
index 000000000..b3ba6a570
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_ceilf.c
@@ -0,0 +1,2 @@
+#define FUNC ceilf
+#include <s_atanf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_ceill.c b/ports/sysdeps/m68k/fpu/s_ceill.c
new file mode 100644
index 000000000..2bf95b00c
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_ceill.c
@@ -0,0 +1,2 @@
+#define FUNC ceill
+#include <s_atanl.c>
diff --git a/ports/sysdeps/m68k/fpu/s_cexp.c b/ports/sysdeps/m68k/fpu/s_cexp.c
new file mode 100644
index 000000000..4babf1268
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_cexp.c
@@ -0,0 +1,117 @@
+/* Complex exponential function. m68k fpu version
+ Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <complex.h>
+#include <math.h>
+#include "mathimpl.h"
+
+#ifndef SUFF
+#define SUFF
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define CONCATX(a,b) __CONCAT(a,b)
+#define s(name) CONCATX(name,SUFF)
+#define m81(func) __m81_u(s(func))
+
+__complex__ float_type
+s(__cexp) (__complex__ float_type x)
+{
+ __complex__ float_type retval;
+ unsigned long ix_cond;
+
+ ix_cond = __m81_test (__imag__ x);
+
+ if ((ix_cond & (__M81_COND_NAN|__M81_COND_INF)) == 0)
+ {
+ /* Imaginary part is finite. */
+ float_type exp_val = m81(__ieee754_exp) (__real__ x);
+
+ __real__ retval = __imag__ retval = exp_val;
+ if (m81(__finite) (exp_val))
+ {
+ float_type sin_ix, cos_ix;
+ __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_ix), "=f" (cos_ix)
+ : "f" (__imag__ x));
+ __real__ retval *= cos_ix;
+ if (ix_cond & __M81_COND_ZERO)
+ __imag__ retval = __imag__ x;
+ else
+ __imag__ retval *= sin_ix;
+ }
+ else
+ {
+ /* Compute the sign of the result. */
+ float_type remainder, pi_2;
+ int quadrant;
+
+ __asm ("fmovecr %#0,%0\n\tfscale%.w %#-1,%0" : "=f" (pi_2));
+ __asm ("fmod%.x %2,%0\n\tfmove%.l %/fpsr,%1"
+ : "=f" (remainder), "=dm" (quadrant)
+ : "f" (pi_2), "0" (__imag__ x));
+ quadrant = (quadrant >> 16) & 0x83;
+ if (quadrant & 0x80)
+ quadrant ^= 0x83;
+ switch (quadrant)
+ {
+ default:
+ break;
+ case 1:
+ __real__ retval = -__real__ retval;
+ break;
+ case 2:
+ __real__ retval = -__real__ retval;
+ case 3:
+ __imag__ retval = -__imag__ retval;
+ break;
+ }
+ if (ix_cond & __M81_COND_ZERO && !m81(__isnan) (exp_val))
+ __imag__ retval = __imag__ x;
+ }
+ }
+ else
+ {
+ unsigned long rx_cond = __m81_test (__real__ x);
+
+ if (rx_cond & __M81_COND_INF)
+ {
+ /* Real part is infinite. */
+ if (rx_cond & __M81_COND_NEG)
+ {
+ __real__ retval = __imag__ retval = 0.0;
+ if (ix_cond & __M81_COND_NEG)
+ __imag__ retval = -__imag__ retval;
+ }
+ else
+ {
+ __real__ retval = __real__ x;
+ __imag__ retval = __imag__ x - __imag__ x;
+ }
+ }
+ else
+ __real__ retval = __imag__ retval = __imag__ x - __imag__ x;
+ }
+
+ return retval;
+}
+#define weak_aliasx(a,b) weak_alias(a,b)
+weak_aliasx (s(__cexp), s(cexp))
diff --git a/ports/sysdeps/m68k/fpu/s_cexpf.c b/ports/sysdeps/m68k/fpu/s_cexpf.c
new file mode 100644
index 000000000..177a360f9
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_cexpf.c
@@ -0,0 +1,3 @@
+#define SUFF f
+#define float_type float
+#include <s_cexp.c>
diff --git a/ports/sysdeps/m68k/fpu/s_cexpl.c b/ports/sysdeps/m68k/fpu/s_cexpl.c
new file mode 100644
index 000000000..bbda4ba99
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_cexpl.c
@@ -0,0 +1,3 @@
+#define SUFF l
+#define float_type long double
+#include <s_cexp.c>
diff --git a/ports/sysdeps/m68k/fpu/s_cos.c b/ports/sysdeps/m68k/fpu/s_cos.c
new file mode 100644
index 000000000..9c9607631
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_cos.c
@@ -0,0 +1,2 @@
+#define FUNC cos
+#include <s_atan.c>
diff --git a/ports/sysdeps/m68k/fpu/s_cosf.c b/ports/sysdeps/m68k/fpu/s_cosf.c
new file mode 100644
index 000000000..db965b8cc
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_cosf.c
@@ -0,0 +1,2 @@
+#define FUNC cosf
+#include <s_atanf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_cosl.c b/ports/sysdeps/m68k/fpu/s_cosl.c
new file mode 100644
index 000000000..4198feef1
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_cosl.c
@@ -0,0 +1,2 @@
+#define FUNC cosl
+#include <s_atanl.c>
diff --git a/ports/sysdeps/m68k/fpu/s_csin.c b/ports/sysdeps/m68k/fpu/s_csin.c
new file mode 100644
index 000000000..7c590e4af
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_csin.c
@@ -0,0 +1,69 @@
+/* Complex sine function. m68k fpu version
+ Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <complex.h>
+#include <math.h>
+#include "mathimpl.h"
+
+#ifndef SUFF
+#define SUFF
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define CONCATX(a,b) __CONCAT(a,b)
+#define s(name) CONCATX(name,SUFF)
+#define m81(func) __m81_u(s(func))
+
+__complex__ float_type
+s(__csin) (__complex__ float_type x)
+{
+ __complex__ float_type retval;
+ unsigned long rx_cond = __m81_test (__real__ x);
+
+ if ((rx_cond & (__M81_COND_INF|__M81_COND_NAN)) == 0)
+ {
+ /* Real part is finite. */
+ float_type sin_rx, cos_rx;
+
+ __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_rx), "=f" (cos_rx)
+ : "f" (__real__ x));
+ if (rx_cond & __M81_COND_ZERO)
+ __real__ retval = __real__ x;
+ else
+ __real__ retval = sin_rx * m81(__ieee754_cosh) (__imag__ x);
+ __imag__ retval = cos_rx * m81(__ieee754_sinh) (__imag__ x);
+ }
+ else
+ {
+ unsigned long ix_cond = __m81_test (__imag__ x);
+
+ __real__ retval = __real__ x - __real__ x;
+ if (ix_cond & (__M81_COND_ZERO|__M81_COND_INF|__M81_COND_NAN))
+ __imag__ retval = __imag__ x;
+ else
+ __imag__ retval = __real__ retval;
+ }
+
+ return retval;
+}
+#define weak_aliasx(a,b) weak_alias(a,b)
+weak_aliasx (s(__csin), s(csin))
diff --git a/ports/sysdeps/m68k/fpu/s_csinf.c b/ports/sysdeps/m68k/fpu/s_csinf.c
new file mode 100644
index 000000000..b760e192c
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_csinf.c
@@ -0,0 +1,3 @@
+#define SUFF f
+#define float_type float
+#include <s_csin.c>
diff --git a/ports/sysdeps/m68k/fpu/s_csinh.c b/ports/sysdeps/m68k/fpu/s_csinh.c
new file mode 100644
index 000000000..dafb82af1
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_csinh.c
@@ -0,0 +1,71 @@
+/* Complex sine hyperbole function. m68k fpu version
+ Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <complex.h>
+#include <math.h>
+#include "mathimpl.h"
+
+#ifndef SUFF
+#define SUFF
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define CONCATX(a,b) __CONCAT(a,b)
+#define s(name) CONCATX(name,SUFF)
+#define m81(func) __m81_u(s(func))
+
+__complex__ float_type
+s(__csinh) (__complex__ float_type x)
+{
+ __complex__ float_type retval;
+ unsigned long ix_cond;
+
+ ix_cond = __m81_test (__imag__ x);
+
+ if ((ix_cond & (__M81_COND_INF|__M81_COND_NAN)) == 0)
+ {
+ /* Imaginary part is finite. */
+ float_type sin_ix, cos_ix;
+
+ __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_ix), "=f" (cos_ix)
+ : "f" (__imag__ x));
+ __real__ retval = cos_ix * m81(__ieee754_sinh) (__real__ x);
+ if (ix_cond & __M81_COND_ZERO)
+ __imag__ retval = __imag__ x;
+ else
+ __imag__ retval = sin_ix * m81(__ieee754_cosh) (__real__ x);
+ }
+ else
+ {
+ unsigned long rx_cond = __m81_test (__real__ x);
+
+ __imag__ retval = __imag__ x - __imag__ x;
+ if (rx_cond & (__M81_COND_ZERO|__M81_COND_INF|__M81_COND_NAN))
+ __real__ retval = __real__ x;
+ else
+ __real__ retval = __imag__ retval;
+ }
+
+ return retval;
+}
+#define weak_aliasx(a,b) weak_alias(a,b)
+weak_aliasx (s(__csinh), s(csinh))
diff --git a/ports/sysdeps/m68k/fpu/s_csinhf.c b/ports/sysdeps/m68k/fpu/s_csinhf.c
new file mode 100644
index 000000000..2f7a43e6a
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_csinhf.c
@@ -0,0 +1,3 @@
+#define SUFF f
+#define float_type float
+#include <s_csinh.c>
diff --git a/ports/sysdeps/m68k/fpu/s_csinhl.c b/ports/sysdeps/m68k/fpu/s_csinhl.c
new file mode 100644
index 000000000..026a20e7b
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_csinhl.c
@@ -0,0 +1,3 @@
+#define SUFF l
+#define float_type long double
+#include <s_csinh.c>
diff --git a/ports/sysdeps/m68k/fpu/s_csinl.c b/ports/sysdeps/m68k/fpu/s_csinl.c
new file mode 100644
index 000000000..ea2dad055
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_csinl.c
@@ -0,0 +1,3 @@
+#define SUFF l
+#define float_type long double
+#include <s_csin.c>
diff --git a/ports/sysdeps/m68k/fpu/s_expm1.c b/ports/sysdeps/m68k/fpu/s_expm1.c
new file mode 100644
index 000000000..1ef99e21c
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_expm1.c
@@ -0,0 +1,2 @@
+#define FUNC expm1
+#include <s_atan.c>
diff --git a/ports/sysdeps/m68k/fpu/s_expm1f.c b/ports/sysdeps/m68k/fpu/s_expm1f.c
new file mode 100644
index 000000000..84935b1b4
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_expm1f.c
@@ -0,0 +1,2 @@
+#define FUNC expm1f
+#include <s_atanf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_expm1l.c b/ports/sysdeps/m68k/fpu/s_expm1l.c
new file mode 100644
index 000000000..feee07a1d
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_expm1l.c
@@ -0,0 +1,3 @@
+#define FUNC expm1l
+#include <s_atanl.c>
+libm_hidden_def (__expm1l)
diff --git a/ports/sysdeps/m68k/fpu/s_fabs.c b/ports/sysdeps/m68k/fpu/s_fabs.c
new file mode 100644
index 000000000..1f0631e2f
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_fabs.c
@@ -0,0 +1,2 @@
+#define FUNC fabs
+#include <s_atan.c>
diff --git a/ports/sysdeps/m68k/fpu/s_fabsf.c b/ports/sysdeps/m68k/fpu/s_fabsf.c
new file mode 100644
index 000000000..8f9421998
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_fabsf.c
@@ -0,0 +1,2 @@
+#define FUNC fabsf
+#include <s_atanf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_fabsl.c b/ports/sysdeps/m68k/fpu/s_fabsl.c
new file mode 100644
index 000000000..8ac14d5b8
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_fabsl.c
@@ -0,0 +1,2 @@
+#define FUNC fabsl
+#include <s_atanl.c>
diff --git a/ports/sysdeps/m68k/fpu/s_finite.c b/ports/sysdeps/m68k/fpu/s_finite.c
new file mode 100644
index 000000000..dafbd5901
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_finite.c
@@ -0,0 +1,2 @@
+#define FUNC finite
+#include <s_isinf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_finitef.c b/ports/sysdeps/m68k/fpu/s_finitef.c
new file mode 100644
index 000000000..b81342e5c
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_finitef.c
@@ -0,0 +1,2 @@
+#define FUNC finitef
+#include <s_isinff.c>
diff --git a/ports/sysdeps/m68k/fpu/s_finitel.c b/ports/sysdeps/m68k/fpu/s_finitel.c
new file mode 100644
index 000000000..bd346a220
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_finitel.c
@@ -0,0 +1,2 @@
+#define FUNC finitel
+#include <s_isinfl.c>
diff --git a/ports/sysdeps/m68k/fpu/s_floor.c b/ports/sysdeps/m68k/fpu/s_floor.c
new file mode 100644
index 000000000..e1219c602
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_floor.c
@@ -0,0 +1,2 @@
+#define FUNC floor
+#include <s_atan.c>
diff --git a/ports/sysdeps/m68k/fpu/s_floorf.c b/ports/sysdeps/m68k/fpu/s_floorf.c
new file mode 100644
index 000000000..f4f9b9a1d
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_floorf.c
@@ -0,0 +1,2 @@
+#define FUNC floorf
+#include <s_atanf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_floorl.c b/ports/sysdeps/m68k/fpu/s_floorl.c
new file mode 100644
index 000000000..2c1ffd7d2
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_floorl.c
@@ -0,0 +1,2 @@
+#define FUNC floorl
+#include <s_atanl.c>
diff --git a/ports/sysdeps/m68k/fpu/s_fpclassifyl.c b/ports/sysdeps/m68k/fpu/s_fpclassifyl.c
new file mode 100644
index 000000000..a8cb09992
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_fpclassifyl.c
@@ -0,0 +1,44 @@
+/* Return classification value corresponding to argument. m68k version.
+ Copyright (C) 1997, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+ Fixed for m68k by Andreas Schwab <schwab@suse.de>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+#include "math_private.h"
+
+
+int
+__fpclassifyl (long double x)
+{
+ u_int32_t ex, hx, lx;
+ int retval = FP_NORMAL;
+
+ GET_LDOUBLE_WORDS (ex, hx, lx, x);
+ ex &= 0x7fff;
+ if ((ex | hx | lx) == 0)
+ retval = FP_ZERO;
+ else if (ex == 0 && (hx & 0x80000000) == 0)
+ retval = FP_SUBNORMAL;
+ else if (ex == 0x7fff)
+ retval = ((hx & 0x7fffffff) | lx) != 0 ? FP_NAN : FP_INFINITE;
+
+ return retval;
+}
+libm_hidden_def (__fpclassifyl)
diff --git a/ports/sysdeps/m68k/fpu/s_frexp.c b/ports/sysdeps/m68k/fpu/s_frexp.c
new file mode 100644
index 000000000..b06141283
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_frexp.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 1996, 1997, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+#ifndef FUNC
+#define FUNC frexp
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define __CONCATX(a,b) __CONCAT(a,b)
+
+float_type
+__CONCATX(__,FUNC) (float_type value, int *expptr)
+{
+ float_type mantissa, exponent;
+ int iexponent;
+ unsigned long fpsr;
+
+ __asm ("ftst%.x %1\n"
+ "fmove%.l %/fpsr, %0"
+ : "=dm" (fpsr) : "f" (value));
+ if (fpsr & (7 << 24))
+ {
+ /* Not finite or zero. */
+ *expptr = 0;
+ return value;
+ }
+ __asm ("fgetexp%.x %1, %0" : "=f" (exponent) : "f" (value));
+ iexponent = (int) exponent + 1;
+ *expptr = iexponent;
+ __asm ("fscale%.l %2, %0"
+ : "=f" (mantissa)
+ : "0" (value), "dmi" (-iexponent));
+ return mantissa;
+}
+
+#define weak_aliasx(a,b) weak_alias(a,b)
+weak_aliasx (__CONCATX(__,FUNC), FUNC)
diff --git a/ports/sysdeps/m68k/fpu/s_frexpf.c b/ports/sysdeps/m68k/fpu/s_frexpf.c
new file mode 100644
index 000000000..893b6ad3c
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_frexpf.c
@@ -0,0 +1,3 @@
+#define FUNC frexpf
+#define float_type float
+#include <s_frexp.c>
diff --git a/ports/sysdeps/m68k/fpu/s_frexpl.c b/ports/sysdeps/m68k/fpu/s_frexpl.c
new file mode 100644
index 000000000..f9a531526
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_frexpl.c
@@ -0,0 +1,59 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+long double
+__frexpl (long double value, int *expptr)
+{
+ long double mantissa, exponent;
+ int iexponent;
+ unsigned long fpsr;
+
+ __asm ("ftst%.x %1\n"
+ "fmove%.l %/fpsr, %0"
+ : "=dm" (fpsr) : "f" (value));
+ if (fpsr & (7 << 24))
+ {
+ /* Not finite or zero. */
+ *expptr = 0;
+ return value;
+ }
+ __asm ("fgetexp%.x %1, %0" : "=f" (exponent) : "f" (value));
+ iexponent = (int) exponent + 1;
+ *expptr = iexponent;
+ /* Unnormalized numbers must be handled specially, otherwise fscale
+ results in overflow. */
+ if (iexponent <= -16384)
+ {
+ value *= 0x1p16383L;
+ iexponent += 16383;
+ }
+ else if (iexponent >= 16384)
+ {
+ value *= 0x1p-16383L;
+ iexponent -= 16383;
+ }
+
+ __asm ("fscale%.l %2, %0"
+ : "=f" (mantissa)
+ : "0" (value), "dmi" (-iexponent));
+ return mantissa;
+}
+
+weak_alias (__frexpl, frexpl)
diff --git a/ports/sysdeps/m68k/fpu/s_ilogb.c b/ports/sysdeps/m68k/fpu/s_ilogb.c
new file mode 100644
index 000000000..ee1e3975f
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_ilogb.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include "mathimpl.h"
+
+#ifndef SUFF
+#define SUFF
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define CONCATX(a,b) __CONCAT(a,b)
+#define s(name) CONCATX(name,SUFF)
+#define m81(func) __m81_u(s(func))
+
+int
+s(__ilogb) (float_type x)
+{
+ float_type result;
+ unsigned long x_cond;
+
+ x_cond = __m81_test (x);
+ /* We must return consistent values for zero and NaN. */
+ if (x_cond & __M81_COND_ZERO)
+ return FP_ILOGB0;
+ if (x_cond & (__M81_COND_NAN | __M81_COND_INF))
+ return FP_ILOGBNAN;
+
+ __asm ("fgetexp%.x %1, %0" : "=f" (result) : "f" (x));
+ return (int) result;
+}
+
+#define weak_aliasx(a,b) weak_alias(a,b)
+weak_aliasx (s(__ilogb), s(ilogb))
diff --git a/ports/sysdeps/m68k/fpu/s_ilogbf.c b/ports/sysdeps/m68k/fpu/s_ilogbf.c
new file mode 100644
index 000000000..4031c42ff
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_ilogbf.c
@@ -0,0 +1,3 @@
+#define SUFF f
+#define float_type float
+#include <s_ilogb.c>
diff --git a/ports/sysdeps/m68k/fpu/s_ilogbl.c b/ports/sysdeps/m68k/fpu/s_ilogbl.c
new file mode 100644
index 000000000..9c55a115e
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_ilogbl.c
@@ -0,0 +1,3 @@
+#define SUFF l
+#define float_type long double
+#include <s_ilogb.c>
diff --git a/ports/sysdeps/m68k/fpu/s_isinf.c b/ports/sysdeps/m68k/fpu/s_isinf.c
new file mode 100644
index 000000000..5fb43ea2a
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_isinf.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+#ifndef FUNC
+#define FUNC isinf
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define __CONCATX(a,b) __CONCAT(a,b)
+
+int
+__CONCATX(__,FUNC) (x)
+ float_type x;
+{
+ return __m81_u(__CONCATX(__,FUNC))(x);
+}
+
+#define hidden_defx(a) hidden_def(a)
+hidden_defx(__CONCATX(__,FUNC))
+#define weak_aliasx(a,b) weak_alias(a,b)
+weak_aliasx (__CONCATX(__,FUNC), FUNC)
diff --git a/ports/sysdeps/m68k/fpu/s_isinff.c b/ports/sysdeps/m68k/fpu/s_isinff.c
new file mode 100644
index 000000000..ebf4f2ae9
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_isinff.c
@@ -0,0 +1,5 @@
+#ifndef FUNC
+#define FUNC isinff
+#endif
+#define float_type float
+#include <s_isinf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_isinfl.c b/ports/sysdeps/m68k/fpu/s_isinfl.c
new file mode 100644
index 000000000..963725ad7
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_isinfl.c
@@ -0,0 +1,5 @@
+#ifndef FUNC
+#define FUNC isinfl
+#endif
+#define float_type long double
+#include <s_isinf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_isnan.c b/ports/sysdeps/m68k/fpu/s_isnan.c
new file mode 100644
index 000000000..151d6dc6b
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_isnan.c
@@ -0,0 +1,2 @@
+#define FUNC isnan
+#include <s_isinf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_isnanf.c b/ports/sysdeps/m68k/fpu/s_isnanf.c
new file mode 100644
index 000000000..667bca723
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_isnanf.c
@@ -0,0 +1,2 @@
+#define FUNC isnanf
+#include <s_isinff.c>
diff --git a/ports/sysdeps/m68k/fpu/s_isnanl.c b/ports/sysdeps/m68k/fpu/s_isnanl.c
new file mode 100644
index 000000000..bbacb64f1
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_isnanl.c
@@ -0,0 +1,2 @@
+#define FUNC isnanl
+#include <s_isinfl.c>
diff --git a/ports/sysdeps/m68k/fpu/s_llrint.c b/ports/sysdeps/m68k/fpu/s_llrint.c
new file mode 100644
index 000000000..8f2442982
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_llrint.c
@@ -0,0 +1,76 @@
+/* Round argument to nearest integral value according to current rounding
+ direction.
+ Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include "math_private.h"
+#include "mathimpl.h"
+
+long long int
+__llrint (double x)
+{
+ int32_t e;
+ u_int32_t h, l, s;
+ long long int result;
+
+ x = __m81_u(__rint) (x);
+
+ /* We could use __fixxfdi from libgcc, but here we can take advantage of
+ the known floating point format. */
+ EXTRACT_WORDS (h, l, x);
+
+ e = ((h >> 20) & 0x7ff) - 0x3ff;
+ if (e < 0)
+ return 0;
+ s = h;
+ h &= 0xfffff;
+ h |= 0x100000;
+
+ if (e < 63)
+ {
+ if (e > 52)
+ {
+ h <<= e - 52;
+ h |= l >> (84 - e);
+ l <<= e - 52;
+ result = ((long long int) h << 32) | l;
+ }
+ else if (e > 20)
+ {
+ l >>= 52 - e;
+ l |= h << (e - 20);
+ h >>= 52 - e;
+ result = ((long long int) h << 32) | l;
+ }
+ else
+ result = h >> (20 - e);
+ if (s & 0x80000000)
+ result = -result;
+ }
+ else
+ /* The number is too large or not finite. The standard leaves it
+ undefined what to return when the number is too large to fit in a
+ `long long int'. */
+ result = -1LL;
+
+ return result;
+}
+
+weak_alias (__llrint, llrint)
diff --git a/ports/sysdeps/m68k/fpu/s_llrintf.c b/ports/sysdeps/m68k/fpu/s_llrintf.c
new file mode 100644
index 000000000..bd573b257
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_llrintf.c
@@ -0,0 +1,66 @@
+/* Round argument to nearest integral value according to current rounding
+ direction.
+ Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include "math_private.h"
+#include "mathimpl.h"
+
+long long int
+__llrintf (float x)
+{
+ int32_t e;
+ u_int32_t i, s;
+ long long int result;
+
+ x = __m81_u(__rintf) (x);
+
+ GET_FLOAT_WORD (i, x);
+
+ e = ((i >> 23) & 0xff) - 0x7f;
+ if (e < 0)
+ return 0;
+ s = i;
+ i &= 0x7fffff;
+ i |= 0x800000;
+
+ if (e < 63)
+ {
+ if (e > 55)
+ result = (long long int) (i << (e - 55)) << 32;
+ else if (e > 31)
+ result = (((long long int) (i >> (55 - e)) << 32) | (i << (e - 23)));
+ else if (e > 23)
+ result = i << (e - 23);
+ else
+ result = i >> (23 - e);
+ if (s & 0x80000000)
+ result = -result;
+ }
+ else
+ /* The number is too large or not finite. The standard leaves it
+ undefined what to return when the number is too large to fit in a
+ `long long int'. */
+ result = -1LL;
+
+ return result;
+}
+
+weak_alias (__llrintf, llrintf)
diff --git a/ports/sysdeps/m68k/fpu/s_llrintl.c b/ports/sysdeps/m68k/fpu/s_llrintl.c
new file mode 100644
index 000000000..d749f3515
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_llrintl.c
@@ -0,0 +1,65 @@
+/* Round argument to nearest integral value according to current rounding
+ direction.
+ Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include "math_private.h"
+#include "mathimpl.h"
+
+long long int
+__llrintl (long double x)
+{
+ int32_t e, s;
+ u_int32_t h, l;
+ long long int result;
+
+ x = __m81_u(__rintl) (x);
+
+ GET_LDOUBLE_WORDS (e, h, l, x);
+
+ s = e;
+ e = (e & 0x7fff) - 0x3fff;
+ if (e < 0)
+ return 0;
+
+ if (e < 63)
+ {
+ if (e > 31)
+ {
+ l >>= 63 - e;
+ l |= h << (e - 31);
+ h >>= 63 - e;
+ result = ((long long int) h << 32) | l;
+ }
+ else
+ result = h >> (31 - e);
+ if (s & 0x8000)
+ result = -result;
+ }
+ else
+ /* The number is too large or not finite. The standard leaves it
+ undefined what to return when the number is too large to fit in a
+ `long long int'. */
+ result = -1LL;
+
+ return result;
+}
+
+weak_alias (__llrintl, llrintl)
diff --git a/ports/sysdeps/m68k/fpu/s_log1p.c b/ports/sysdeps/m68k/fpu/s_log1p.c
new file mode 100644
index 000000000..1840ced13
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_log1p.c
@@ -0,0 +1,2 @@
+#define FUNC log1p
+#include <s_atan.c>
diff --git a/ports/sysdeps/m68k/fpu/s_log1pf.c b/ports/sysdeps/m68k/fpu/s_log1pf.c
new file mode 100644
index 000000000..cb7235a07
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_log1pf.c
@@ -0,0 +1,2 @@
+#define FUNC log1pf
+#include <s_atanf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_log1pl.c b/ports/sysdeps/m68k/fpu/s_log1pl.c
new file mode 100644
index 000000000..8dbef8909
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_log1pl.c
@@ -0,0 +1,2 @@
+#define FUNC log1pl
+#include <s_atanl.c>
diff --git a/ports/sysdeps/m68k/fpu/s_lrint.c b/ports/sysdeps/m68k/fpu/s_lrint.c
new file mode 100644
index 000000000..0a23f29ee
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_lrint.c
@@ -0,0 +1,40 @@
+/* Round argument to nearest integral value according to current rounding
+ direction.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+#ifndef suffix
+#define suffix /*empty*/
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define CONCATX(a,b) __CONCAT(a,b)
+
+long int
+CONCATX(__lrint,suffix) (float_type x)
+{
+ return __m81_u(CONCATX(__lrint,suffix)) (x);
+}
+
+#define weak_aliasx(a,b) weak_alias(a,b)
+weak_aliasx (CONCATX(__lrint,suffix), CONCATX(lrint,suffix))
diff --git a/ports/sysdeps/m68k/fpu/s_lrintf.c b/ports/sysdeps/m68k/fpu/s_lrintf.c
new file mode 100644
index 000000000..44924cb82
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_lrintf.c
@@ -0,0 +1,3 @@
+#define suffix f
+#define float_type float
+#include <s_lrint.c>
diff --git a/ports/sysdeps/m68k/fpu/s_lrintl.c b/ports/sysdeps/m68k/fpu/s_lrintl.c
new file mode 100644
index 000000000..cd0bd23b8
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_lrintl.c
@@ -0,0 +1,3 @@
+#define suffix l
+#define float_type long double
+#include <s_lrint.c>
diff --git a/ports/sysdeps/m68k/fpu/s_modf.c b/ports/sysdeps/m68k/fpu/s_modf.c
new file mode 100644
index 000000000..2f5a83dea
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_modf.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include "mathimpl.h"
+
+#ifndef SUFF
+#define SUFF
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define CONCATX(a,b) __CONCAT(a,b)
+#define s(name) CONCATX(name,SUFF)
+#define m81(func) __m81_u(s(func))
+
+float_type
+s(__modf) (float_type x, float_type *iptr)
+{
+ float_type x_int, result;
+ unsigned long x_cond;
+
+ __asm ("fintrz%.x %1, %0" : "=f" (x_int) : "f" (x));
+ *iptr = x_int;
+ x_cond = __m81_test (x);
+ if (x_cond & __M81_COND_INF)
+ {
+ result = 0;
+ if (x_cond & __M81_COND_NEG)
+ result = -result;
+ }
+ else if (x_cond & __M81_COND_ZERO)
+ result = x;
+ else
+ result = x - x_int;
+ return result;
+}
+
+#define weak_aliasx(a,b) weak_alias(a,b)
+weak_aliasx(s(__modf), s(modf))
diff --git a/ports/sysdeps/m68k/fpu/s_modff.c b/ports/sysdeps/m68k/fpu/s_modff.c
new file mode 100644
index 000000000..0c44d7c0a
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_modff.c
@@ -0,0 +1,3 @@
+#define SUFF f
+#define float_type float
+#include <s_modf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_modfl.c b/ports/sysdeps/m68k/fpu/s_modfl.c
new file mode 100644
index 000000000..c7075b3ba
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_modfl.c
@@ -0,0 +1,3 @@
+#define SUFF l
+#define float_type long double
+#include <s_modf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_nearbyint.c b/ports/sysdeps/m68k/fpu/s_nearbyint.c
new file mode 100644
index 000000000..b87f5e216
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_nearbyint.c
@@ -0,0 +1,2 @@
+#define FUNC nearbyint
+#include <s_atan.c>
diff --git a/ports/sysdeps/m68k/fpu/s_nearbyintf.c b/ports/sysdeps/m68k/fpu/s_nearbyintf.c
new file mode 100644
index 000000000..70d08ab44
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_nearbyintf.c
@@ -0,0 +1,2 @@
+#define FUNC nearbyintf
+#include <s_atanf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_nearbyintl.c b/ports/sysdeps/m68k/fpu/s_nearbyintl.c
new file mode 100644
index 000000000..230cd7784
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_nearbyintl.c
@@ -0,0 +1,2 @@
+#define FUNC nearbyintl
+#include <s_atanl.c>
diff --git a/ports/sysdeps/m68k/fpu/s_nextafterl.c b/ports/sysdeps/m68k/fpu/s_nextafterl.c
new file mode 100644
index 000000000..70ab5a478
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_nextafterl.c
@@ -0,0 +1,109 @@
+/* s_nextafterl.c -- long double version of s_nextafter.c.
+ * Conversion to long double by Ulrich Drepper,
+ * Cygnus Support, drepper@cygnus.com.
+ * Fixed for m68k by Andreas Schwab <schwab@suse.de>.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#if defined(LIBM_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: $";
+#endif
+
+/* IEEE functions
+ * nextafterl(x,y)
+ * return the next machine floating-point number of x in the
+ * direction toward y.
+ * Special cases:
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+#ifdef __STDC__
+ long double __nextafterl(long double x, long double y)
+#else
+ long double __nextafterl(x,y)
+ long double x,y;
+#endif
+{
+ int32_t ix,iy,esx,esy;
+ u_int32_t hx,hy,lx,ly;
+
+ GET_LDOUBLE_WORDS(esx,hx,lx,x);
+ GET_LDOUBLE_WORDS(esy,hy,ly,y);
+ ix = esx&0x7fff; /* |x| */
+ iy = esy&0x7fff; /* |y| */
+
+ if(((ix==0x7fff)&&((hx&0x7fffffff)|lx)!=0) || /* x is nan */
+ ((iy==0x7fff)&&((hy&0x7fffffff)|ly)!=0)) /* y is nan */
+ return x+y;
+ if(x==y) return y; /* x=y, return y */
+ if((ix|hx|lx)==0) { /* x == 0 */
+ SET_LDOUBLE_WORDS(x,esy&0x8000,0,1);/* return +-minsubnormal */
+ y = x*x;
+ if(y==x) return y; else return x; /* raise underflow flag */
+ }
+ if(esx>=0) { /* x > 0 */
+ if(esx>esy||((esx==esy) && (hx>hy||((hx==hy)&&(lx>ly))))) {
+ /* x > y, x -= ulp */
+ if(lx==0) {
+ if (ix != 0 && hx == 0x80000000) hx = 0;
+ if (hx==0) esx -= 1;
+ hx -= 1;
+ }
+ lx -= 1;
+ } else { /* x < y, x += ulp */
+ lx += 1;
+ if(lx==0) {
+ hx += 1;
+ if (hx==0) {
+ hx = 0x80000000;
+ esx += 1;
+ }
+ }
+ }
+ } else { /* x < 0 */
+ if(esy>=0||esx>esy||((esx==esy) && (hx>hy||((hx==hy)&&(lx>ly))))){
+ /* x < y, x -= ulp */
+ if(lx==0) {
+ if (ix != 0 && hx == 0x80000000) hx = 0;
+ if (hx==0) esx -= 1;
+ hx -= 1;
+ }
+ lx -= 1;
+ } else { /* x > y, x += ulp */
+ lx += 1;
+ if(lx==0) {
+ hx += 1;
+ if (hx==0) {
+ hx = 0x80000000;
+ esx += 1;
+ }
+ }
+ }
+ }
+ esy = esx&0x7fff;
+ if(esy==0x7fff) return x+x; /* overflow */
+ if(esy==0 && (hx & 0x80000000) == 0) { /* underflow */
+ y = x*x;
+ if(y!=x) { /* raise underflow flag */
+ SET_LDOUBLE_WORDS(y,esx,hx,lx);
+ return y;
+ }
+ }
+ SET_LDOUBLE_WORDS(x,esx,hx,lx);
+ return x;
+}
+weak_alias (__nextafterl, nextafterl)
+strong_alias (__nextafterl, __nexttowardl)
+weak_alias (__nextafterl, nexttowardl)
diff --git a/ports/sysdeps/m68k/fpu/s_remquo.c b/ports/sysdeps/m68k/fpu/s_remquo.c
new file mode 100644
index 000000000..5b65f85fb
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_remquo.c
@@ -0,0 +1,48 @@
+/* Compute remainder and a congruent to the quotient. m68k fpu version
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+#ifndef SUFF
+#define SUFF
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define CONCATX(a,b) __CONCAT(a,b)
+#define s(name) CONCATX(name,SUFF)
+
+float_type
+s(__remquo) (float_type x, float_type y, int *quo)
+{
+ float_type result;
+ int cquo, fpsr;
+
+ __asm ("frem%.x %2,%0\n\tfmove%.l %/fpsr,%1"
+ : "=f" (result), "=dm" (fpsr) : "f" (y), "0" (x));
+ cquo = (fpsr >> 16) & 0x7f;
+ if (fpsr & (1 << 23))
+ cquo = -cquo;
+ *quo = cquo;
+ return result;
+}
+#define weak_aliasx(a,b) weak_alias(a,b)
+weak_aliasx (s(__remquo), s(remquo))
diff --git a/ports/sysdeps/m68k/fpu/s_remquof.c b/ports/sysdeps/m68k/fpu/s_remquof.c
new file mode 100644
index 000000000..8a292fc26
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_remquof.c
@@ -0,0 +1,3 @@
+#define SUFF f
+#define float_type float
+#include <s_remquo.c>
diff --git a/ports/sysdeps/m68k/fpu/s_remquol.c b/ports/sysdeps/m68k/fpu/s_remquol.c
new file mode 100644
index 000000000..d236cfd1f
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_remquol.c
@@ -0,0 +1,3 @@
+#define SUFF l
+#define float_type long double
+#include <s_remquo.c>
diff --git a/ports/sysdeps/m68k/fpu/s_rint.c b/ports/sysdeps/m68k/fpu/s_rint.c
new file mode 100644
index 000000000..f0f18c734
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_rint.c
@@ -0,0 +1,2 @@
+#define FUNC rint
+#include <s_atan.c>
diff --git a/ports/sysdeps/m68k/fpu/s_rintf.c b/ports/sysdeps/m68k/fpu/s_rintf.c
new file mode 100644
index 000000000..4e00cab0f
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_rintf.c
@@ -0,0 +1,2 @@
+#define FUNC rintf
+#include <s_atanf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_rintl.c b/ports/sysdeps/m68k/fpu/s_rintl.c
new file mode 100644
index 000000000..305667b3a
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_rintl.c
@@ -0,0 +1,2 @@
+#define FUNC rintl
+#include <s_atanl.c>
diff --git a/ports/sysdeps/m68k/fpu/s_scalbln.c b/ports/sysdeps/m68k/fpu/s_scalbln.c
new file mode 100644
index 000000000..1009713fb
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_scalbln.c
@@ -0,0 +1,2 @@
+/* Nothing to do. This function is the same as scalbn. So we define an
+ alias. */
diff --git a/ports/sysdeps/m68k/fpu/s_scalblnf.c b/ports/sysdeps/m68k/fpu/s_scalblnf.c
new file mode 100644
index 000000000..5e558c354
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_scalblnf.c
@@ -0,0 +1,2 @@
+/* Nothing to do. This function is the same as scalbnf. So we define an
+ alias. */
diff --git a/ports/sysdeps/m68k/fpu/s_scalblnl.c b/ports/sysdeps/m68k/fpu/s_scalblnl.c
new file mode 100644
index 000000000..cda2ec11c
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_scalblnl.c
@@ -0,0 +1,2 @@
+/* Nothing to do. This function is the same as scalbnl. So we define an
+ alias. */
diff --git a/ports/sysdeps/m68k/fpu/s_scalbn.c b/ports/sysdeps/m68k/fpu/s_scalbn.c
new file mode 100644
index 000000000..d76d94d94
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_scalbn.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define scalbln __no_scalbln_decl
+#define scalblnf __no_scalblnf_decl
+#define scalblnl __no_scalblnl_decl
+#define __scalbln __no__scalbln_decl
+#define __scalblnf __no__scalblnf_decl
+#define __scalblnl __no__scalblnl_decl
+#include <math.h>
+#undef scalbln
+#undef scalblnf
+#undef scalblnl
+#undef __scalbln
+#undef __scalblnf
+#undef __scalblnl
+
+#ifndef suffix
+#define suffix /*empty*/
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define __CONCATX(a,b) __CONCAT(a,b)
+
+float_type
+__CONCATX(__scalbn,suffix) (x, exp)
+ float_type x;
+ int exp;
+{
+ return __m81_u(__CONCATX(__scalbn,suffix))(x, exp);
+}
+
+#define weak_aliasx(a,b) weak_alias(a,b)
+#define strong_aliasx(a,b) strong_alias(a,b)
+weak_aliasx (__CONCATX(__scalbn,suffix), __CONCATX(scalbn,suffix))
+strong_aliasx (__CONCATX(__scalbn,suffix), __CONCATX(__scalbln,suffix))
+weak_aliasx (__CONCATX(__scalbn,suffix), __CONCATX(scalbln,suffix))
diff --git a/ports/sysdeps/m68k/fpu/s_scalbnf.c b/ports/sysdeps/m68k/fpu/s_scalbnf.c
new file mode 100644
index 000000000..547971836
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_scalbnf.c
@@ -0,0 +1,3 @@
+#define suffix f
+#define float_type float
+#include <s_scalbn.c>
diff --git a/ports/sysdeps/m68k/fpu/s_scalbnl.c b/ports/sysdeps/m68k/fpu/s_scalbnl.c
new file mode 100644
index 000000000..874bafb04
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_scalbnl.c
@@ -0,0 +1,3 @@
+#define suffix l
+#define float_type long double
+#include <s_scalbn.c>
diff --git a/ports/sysdeps/m68k/fpu/s_significand.c b/ports/sysdeps/m68k/fpu/s_significand.c
new file mode 100644
index 000000000..34d4ea3d1
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_significand.c
@@ -0,0 +1,2 @@
+#define FUNC significand
+#include <s_atan.c>
diff --git a/ports/sysdeps/m68k/fpu/s_significandf.c b/ports/sysdeps/m68k/fpu/s_significandf.c
new file mode 100644
index 000000000..4e769ca31
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_significandf.c
@@ -0,0 +1,2 @@
+#define FUNC significandf
+#include <s_atanf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_significandl.c b/ports/sysdeps/m68k/fpu/s_significandl.c
new file mode 100644
index 000000000..8c6fc7e61
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_significandl.c
@@ -0,0 +1,2 @@
+#define FUNC significandl
+#include <s_atanl.c>
diff --git a/ports/sysdeps/m68k/fpu/s_sin.c b/ports/sysdeps/m68k/fpu/s_sin.c
new file mode 100644
index 000000000..0d4abdbfe
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_sin.c
@@ -0,0 +1,2 @@
+#define FUNC sin
+#include <s_atan.c>
diff --git a/ports/sysdeps/m68k/fpu/s_sincos.c b/ports/sysdeps/m68k/fpu/s_sincos.c
new file mode 100644
index 000000000..5df4a5a1c
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_sincos.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+#ifndef FUNC
+#define FUNC sincos
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define CONCATX(a,b) __CONCAT(a,b)
+
+void
+CONCATX(__,FUNC) (x, sinx, cosx)
+ float_type x, *sinx, *cosx;
+{
+ __m81_u(CONCATX(__,FUNC))(x, sinx, cosx);
+}
+
+#define weak_aliasx(a,b) weak_alias(a,b)
+weak_aliasx (CONCATX(__,FUNC), FUNC)
diff --git a/ports/sysdeps/m68k/fpu/s_sincosf.c b/ports/sysdeps/m68k/fpu/s_sincosf.c
new file mode 100644
index 000000000..7ee2ec660
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_sincosf.c
@@ -0,0 +1,3 @@
+#define FUNC sincosf
+#define float_type float
+#include <s_sincos.c>
diff --git a/ports/sysdeps/m68k/fpu/s_sincosl.c b/ports/sysdeps/m68k/fpu/s_sincosl.c
new file mode 100644
index 000000000..f998cc097
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_sincosl.c
@@ -0,0 +1,3 @@
+#define FUNC sincosl
+#define float_type long double
+#include <s_sincos.c>
diff --git a/ports/sysdeps/m68k/fpu/s_sinf.c b/ports/sysdeps/m68k/fpu/s_sinf.c
new file mode 100644
index 000000000..9b23d4823
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_sinf.c
@@ -0,0 +1,2 @@
+#define FUNC sinf
+#include <s_atanf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_sinl.c b/ports/sysdeps/m68k/fpu/s_sinl.c
new file mode 100644
index 000000000..9ac532cb4
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_sinl.c
@@ -0,0 +1,2 @@
+#define FUNC sinl
+#include <s_atanl.c>
diff --git a/ports/sysdeps/m68k/fpu/s_tan.c b/ports/sysdeps/m68k/fpu/s_tan.c
new file mode 100644
index 000000000..ca7fb0e6d
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_tan.c
@@ -0,0 +1,2 @@
+#define FUNC tan
+#include <s_atan.c>
diff --git a/ports/sysdeps/m68k/fpu/s_tanf.c b/ports/sysdeps/m68k/fpu/s_tanf.c
new file mode 100644
index 000000000..95fe9c71a
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_tanf.c
@@ -0,0 +1,2 @@
+#define FUNC tanf
+#include <s_atanf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_tanh.c b/ports/sysdeps/m68k/fpu/s_tanh.c
new file mode 100644
index 000000000..ac2e7dbb7
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_tanh.c
@@ -0,0 +1,2 @@
+#define FUNC tanh
+#include <s_atan.c>
diff --git a/ports/sysdeps/m68k/fpu/s_tanhf.c b/ports/sysdeps/m68k/fpu/s_tanhf.c
new file mode 100644
index 000000000..1addaae4f
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_tanhf.c
@@ -0,0 +1,2 @@
+#define FUNC tanhf
+#include <s_atanf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_tanhl.c b/ports/sysdeps/m68k/fpu/s_tanhl.c
new file mode 100644
index 000000000..6e997911f
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_tanhl.c
@@ -0,0 +1,2 @@
+#define FUNC tanhl
+#include <s_atanl.c>
diff --git a/ports/sysdeps/m68k/fpu/s_tanl.c b/ports/sysdeps/m68k/fpu/s_tanl.c
new file mode 100644
index 000000000..64fcb5440
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_tanl.c
@@ -0,0 +1,2 @@
+#define FUNC tanl
+#include <s_atanl.c>
diff --git a/ports/sysdeps/m68k/fpu/s_trunc.c b/ports/sysdeps/m68k/fpu/s_trunc.c
new file mode 100644
index 000000000..96f29a776
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_trunc.c
@@ -0,0 +1,2 @@
+#define FUNC trunc
+#include <s_atan.c>
diff --git a/ports/sysdeps/m68k/fpu/s_truncf.c b/ports/sysdeps/m68k/fpu/s_truncf.c
new file mode 100644
index 000000000..44dca748c
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_truncf.c
@@ -0,0 +1,2 @@
+#define FUNC truncf
+#include <s_atanf.c>
diff --git a/ports/sysdeps/m68k/fpu/s_truncl.c b/ports/sysdeps/m68k/fpu/s_truncl.c
new file mode 100644
index 000000000..8d35777ae
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/s_truncl.c
@@ -0,0 +1,2 @@
+#define FUNC truncl
+#include <s_atanl.c>
diff --git a/ports/sysdeps/m68k/fpu/sincos32.c b/ports/sysdeps/m68k/fpu/sincos32.c
new file mode 100644
index 000000000..1cc893170
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/sincos32.c
@@ -0,0 +1 @@
+/* Not needed. */
diff --git a/ports/sysdeps/m68k/fpu/slowexp.c b/ports/sysdeps/m68k/fpu/slowexp.c
new file mode 100644
index 000000000..1cc893170
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/slowexp.c
@@ -0,0 +1 @@
+/* Not needed. */
diff --git a/ports/sysdeps/m68k/fpu/slowpow.c b/ports/sysdeps/m68k/fpu/slowpow.c
new file mode 100644
index 000000000..1cc893170
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/slowpow.c
@@ -0,0 +1 @@
+/* Not needed. */
diff --git a/ports/sysdeps/m68k/fpu/switch/68881-sw.h b/ports/sysdeps/m68k/fpu/switch/68881-sw.h
new file mode 100644
index 000000000..c5a0f71fa
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/switch/68881-sw.h
@@ -0,0 +1,64 @@
+/* Copyright (C) 1991, 1992, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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. */
+ void *target; /* The target of the instruction. */
+ void *soft; /* The address of the soft function. */
+ void *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 __68881_switch (int __dummy) __THROW;
+
+
+/* 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/ports/sysdeps/m68k/fpu/switch/Makefile b/ports/sysdeps/m68k/fpu/switch/Makefile
new file mode 100644
index 000000000..c04107163
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/switch/Makefile
@@ -0,0 +1,51 @@
+# Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 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 <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/ports/sysdeps/m68k/fpu/switch/bits/mathinline.h b/ports/sysdeps/m68k/fpu/switch/bits/mathinline.h
new file mode 100644
index 000000000..c0f696698
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/switch/bits/mathinline.h
@@ -0,0 +1 @@
+/* We don't want any inlines when we might not have a 68881. */
diff --git a/ports/sysdeps/m68k/fpu/switch/switch.c b/ports/sysdeps/m68k/fpu/switch/switch.c
new file mode 100644
index 000000000..e0558176d
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/switch/switch.c
@@ -0,0 +1,87 @@
+/* Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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
+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
+__68881_switch (dummy)
+ int dummy;
+{
+ void **return_address_location = &((void **) &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/ports/sysdeps/m68k/fpu/t_exp.c b/ports/sysdeps/m68k/fpu/t_exp.c
new file mode 100644
index 000000000..fd37963b0
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu/t_exp.c
@@ -0,0 +1 @@
+/* Empty. Not needed. */
diff --git a/ports/sysdeps/m68k/fpu_control.h b/ports/sysdeps/m68k/fpu_control.h
new file mode 100644
index 000000000..86358e655
--- /dev/null
+++ b/ports/sysdeps/m68k/fpu_control.h
@@ -0,0 +1,101 @@
+/* 68k FPU control word definitions.
+ Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FPU_CONTROL_H
+#define _FPU_CONTROL_H
+
+/*
+ * Motorola floating point control register bits.
+ *
+ * 31-16 -> reserved (read as 0, ignored on write)
+ * 15 -> enable trap for BSUN exception
+ * 14 -> enable trap for SNAN exception
+ * 13 -> enable trap for OPERR exception
+ * 12 -> enable trap for OVFL exception
+ * 11 -> enable trap for UNFL exception
+ * 10 -> enable trap for DZ exception
+ * 9 -> enable trap for INEX2 exception
+ * 8 -> enable trap for INEX1 exception
+ * 7-6 -> Precision Control
+ * 5-4 -> Rounding Control
+ * 3-0 -> zero (read as 0, write as 0)
+ *
+ *
+ * Precision Control:
+ * 00 - round to extended precision
+ * 01 - round to single precision
+ * 10 - round to double precision
+ * 11 - undefined
+ *
+ * Rounding Control:
+ * 00 - rounding to nearest (RN)
+ * 01 - rounding toward zero (RZ)
+ * 10 - rounding (down)toward minus infinity (RM)
+ * 11 - rounding (up) toward plus infinity (RP)
+ *
+ * The hardware default is 0x0000. I choose 0x5400.
+ */
+
+#include <features.h>
+
+/* masking of interrupts */
+#define _FPU_MASK_BSUN 0x8000
+#define _FPU_MASK_SNAN 0x4000
+#define _FPU_MASK_OPERR 0x2000
+#define _FPU_MASK_OVFL 0x1000
+#define _FPU_MASK_UNFL 0x0800
+#define _FPU_MASK_DZ 0x0400
+#define _FPU_MASK_INEX1 0x0200
+#define _FPU_MASK_INEX2 0x0100
+
+/* precision control */
+#define _FPU_EXTENDED 0x00 /* RECOMMENDED */
+#define _FPU_DOUBLE 0x80
+#define _FPU_SINGLE 0x40 /* DO NOT USE */
+
+/* rounding control */
+#define _FPU_RC_NEAREST 0x00 /* RECOMMENDED */
+#define _FPU_RC_ZERO 0x10
+#define _FPU_RC_DOWN 0x20
+#define _FPU_RC_UP 0x30
+
+#define _FPU_RESERVED 0xFFFF000F /* Reserved bits in fpucr */
+
+
+/* Now two recommended fpucr */
+
+/* The fdlibm code requires no interrupts for exceptions. Don't
+ change the rounding mode, it would break long double I/O! */
+#define _FPU_DEFAULT 0x00000000
+
+/* IEEE: same as above, but exceptions. We must make it non-zero so
+ that __setfpucw works. This bit will be ignored. */
+#define _FPU_IEEE 0x00000001
+
+/* Type of the control word. */
+typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
+
+/* Macros for accessing the hardware control word. */
+#define _FPU_GETCW(cw) __asm__ ("fmove%.l %!, %0" : "=dm" (cw))
+#define _FPU_SETCW(cw) __asm__ volatile ("fmove%.l %0, %!" : : "dm" (cw))
+
+/* Default control word set at startup. */
+extern fpu_control_t __fpu_control;
+
+#endif /* _M68K_FPU_CONTROL_H */
diff --git a/ports/sysdeps/m68k/gccframe.h b/ports/sysdeps/m68k/gccframe.h
new file mode 100644
index 000000000..452f53f62
--- /dev/null
+++ b/ports/sysdeps/m68k/gccframe.h
@@ -0,0 +1,22 @@
+/* Definition of object in frame unwind info. m68k version.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define FIRST_PSEUDO_REGISTER 24
+
+#include <sysdeps/generic/gccframe.h>
diff --git a/ports/sysdeps/m68k/jmpbuf-unwind.h b/ports/sysdeps/m68k/jmpbuf-unwind.h
new file mode 100644
index 000000000..3490c79bd
--- /dev/null
+++ b/ports/sysdeps/m68k/jmpbuf-unwind.h
@@ -0,0 +1,25 @@
+/* Examine __jmp_buf for unwinding frames. m68k version.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <setjmp.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
+ ((void *) (address) < (void *) demangle ((jmpbuf)->__sp))
diff --git a/ports/sysdeps/m68k/lshift.S b/ports/sysdeps/m68k/lshift.S
new file mode 100644
index 000000000..434b344bd
--- /dev/null
+++ b/ports/sysdeps/m68k/lshift.S
@@ -0,0 +1,147 @@
+/* mc68020 __mpn_lshift -- Shift left a low-level natural-number integer.
+
+Copyright (C) 1996, 1998 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s_ptr (sp + 8)
+ s_size (sp + 16)
+ cnt (sp + 12)
+*/
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+#define res_ptr a1
+#define s_ptr a0
+#define s_size d6
+#define cnt d4
+
+ TEXT
+ENTRY(__mpn_lshift)
+
+/* Save used registers on the stack. */
+ moveml R(d2)-R(d6)/R(a2),MEM_PREDEC(sp)
+
+/* Copy the arguments to registers. */
+ movel MEM_DISP(sp,28),R(res_ptr)
+ movel MEM_DISP(sp,32),R(s_ptr)
+ movel MEM_DISP(sp,36),R(s_size)
+ movel MEM_DISP(sp,40),R(cnt)
+
+ moveql #1,R(d5)
+ cmpl R(d5),R(cnt)
+ bne L(Lnormal)
+ cmpl R(s_ptr),R(res_ptr)
+ bls L(Lspecial) /* jump if s_ptr >= res_ptr */
+#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
+ lea MEM_INDX1(s_ptr,s_size,l,4),R(a2)
+#else /* not mc68020 */
+ movel R(s_size),R(d0)
+ asll #2,R(d0)
+ lea MEM_INDX(s_ptr,d0,l),R(a2)
+#endif
+ cmpl R(res_ptr),R(a2)
+ bls L(Lspecial) /* jump if res_ptr >= s_ptr + s_size */
+
+L(Lnormal:)
+ moveql #32,R(d5)
+ subl R(cnt),R(d5)
+
+#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
+ lea MEM_INDX1(s_ptr,s_size,l,4),R(s_ptr)
+ lea MEM_INDX1(res_ptr,s_size,l,4),R(res_ptr)
+#else /* not mc68000 */
+ movel R(s_size),R(d0)
+ asll #2,R(d0)
+ addl R(s_size),R(s_ptr)
+ addl R(s_size),R(res_ptr)
+#endif
+ movel MEM_PREDEC(s_ptr),R(d2)
+ movel R(d2),R(d0)
+ lsrl R(d5),R(d0) /* compute carry limb */
+
+ lsll R(cnt),R(d2)
+ movel R(d2),R(d1)
+ subql #1,R(s_size)
+ beq L(Lend)
+ lsrl #1,R(s_size)
+ bcs L(L1)
+ subql #1,R(s_size)
+
+L(Loop:)
+ movel MEM_PREDEC(s_ptr),R(d2)
+ movel R(d2),R(d3)
+ lsrl R(d5),R(d3)
+ orl R(d3),R(d1)
+ movel R(d1),MEM_PREDEC(res_ptr)
+ lsll R(cnt),R(d2)
+L(L1:)
+ movel MEM_PREDEC(s_ptr),R(d1)
+ movel R(d1),R(d3)
+ lsrl R(d5),R(d3)
+ orl R(d3),R(d2)
+ movel R(d2),MEM_PREDEC(res_ptr)
+ lsll R(cnt),R(d1)
+
+ dbf R(s_size),L(Loop)
+ subl #0x10000,R(s_size)
+ bcc L(Loop)
+
+L(Lend:)
+ movel R(d1),MEM_PREDEC(res_ptr) /* store least significant limb */
+
+/* Restore used registers from stack frame. */
+ moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
+ rts
+
+/* We loop from least significant end of the arrays, which is only
+ permissible if the source and destination don't overlap, since the
+ function is documented to work for overlapping source and destination. */
+
+L(Lspecial:)
+ clrl R(d0) /* initialize carry */
+ eorw #1,R(s_size)
+ lsrl #1,R(s_size)
+ bcc L(LL1)
+ subql #1,R(s_size)
+
+L(LLoop:)
+ movel MEM_POSTINC(s_ptr),R(d2)
+ addxl R(d2),R(d2)
+ movel R(d2),MEM_POSTINC(res_ptr)
+L(LL1:)
+ movel MEM_POSTINC(s_ptr),R(d2)
+ addxl R(d2),R(d2)
+ movel R(d2),MEM_POSTINC(res_ptr)
+
+ dbf R(s_size),L(LLoop)
+ addxl R(d0),R(d0) /* save cy in lsb */
+ subl #0x10000,R(s_size)
+ bcs L(LLend)
+ lsrl #1,R(d0) /* restore cy */
+ bra L(LLoop)
+
+L(LLend:)
+/* Restore used registers from stack frame. */
+ moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
+ rts
+END(__mpn_lshift)
diff --git a/ports/sysdeps/m68k/m68020/Makefile b/ports/sysdeps/m68k/m68020/Makefile
new file mode 100644
index 000000000..b17635467
--- /dev/null
+++ b/ports/sysdeps/m68k/m68020/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),db2)
+CPPFLAGS += -DHAVE_SPINLOCKS=1 -DHAVE_ASSEM_MC68020_GCC=1
+endif
diff --git a/ports/sysdeps/m68k/m68020/addmul_1.S b/ports/sysdeps/m68k/m68020/addmul_1.S
new file mode 100644
index 000000000..05d1d8a80
--- /dev/null
+++ b/ports/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, 1996, 1998 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s1_ptr (sp + 8)
+ s1_size (sp + 12)
+ s2_limb (sp + 16)
+*/
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+ TEXT
+ENTRY(__mpn_addmul_1)
+
+#define res_ptr a0
+#define s1_ptr a1
+#define s1_size d2
+#define s2_limb d4
+
+/* Save used registers on the stack. */
+ moveml R(d2)-R(d5),MEM_PREDEC(sp)
+
+/* Copy the arguments to registers. Better use movem? */
+ movel MEM_DISP(sp,20),R(res_ptr)
+ movel MEM_DISP(sp,24),R(s1_ptr)
+ movel MEM_DISP(sp,28),R(s1_size)
+ movel MEM_DISP(sp,32),R(s2_limb)
+
+ eorw #1,R(s1_size)
+ clrl R(d1)
+ clrl R(d5)
+ lsrl #1,R(s1_size)
+ bcc L(L1)
+ subql #1,R(s1_size)
+ subl R(d0),R(d0) /* (d0,cy) <= (0,0) */
+
+L(Loop:)
+ movel MEM_POSTINC(s1_ptr),R(d3)
+ mulul R(s2_limb),R(d1):R(d3)
+ addxl R(d0),R(d3)
+ addxl R(d5),R(d1)
+ addl R(d3),MEM_POSTINC(res_ptr)
+L(L1:) movel MEM_POSTINC(s1_ptr),R(d3)
+ mulul R(s2_limb),R(d0):R(d3)
+ addxl R(d1),R(d3)
+ addxl R(d5),R(d0)
+ addl R(d3),MEM_POSTINC(res_ptr)
+
+ dbf R(s1_size),L(Loop)
+ addxl R(d5),R(d0)
+ subl #0x10000,R(s1_size)
+ bcc L(Loop)
+
+/* Restore used registers from stack frame. */
+ moveml MEM_POSTINC(sp),R(d2)-R(d5)
+
+ rts
+END(__mpn_addmul_1)
diff --git a/ports/sysdeps/m68k/m68020/bits/atomic.h b/ports/sysdeps/m68k/m68020/bits/atomic.h
new file mode 100644
index 000000000..6b6db7146
--- /dev/null
+++ b/ports/sysdeps/m68k/m68020/bits/atomic.h
@@ -0,0 +1,254 @@
+/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@suse.de>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdint.h>
+
+
+typedef int8_t atomic8_t;
+typedef uint8_t uatomic8_t;
+typedef int_fast8_t atomic_fast8_t;
+typedef uint_fast8_t uatomic_fast8_t;
+
+typedef int16_t atomic16_t;
+typedef uint16_t uatomic16_t;
+typedef int_fast16_t atomic_fast16_t;
+typedef uint_fast16_t uatomic_fast16_t;
+
+typedef int32_t atomic32_t;
+typedef uint32_t uatomic32_t;
+typedef int_fast32_t atomic_fast32_t;
+typedef uint_fast32_t uatomic_fast32_t;
+
+typedef int64_t atomic64_t;
+typedef uint64_t uatomic64_t;
+typedef int_fast64_t atomic_fast64_t;
+typedef uint_fast64_t uatomic_fast64_t;
+
+typedef intptr_t atomicptr_t;
+typedef uintptr_t uatomicptr_t;
+typedef intmax_t atomic_max_t;
+typedef uintmax_t uatomic_max_t;
+
+#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+ ({ __typeof (*(mem)) __ret; \
+ __asm __volatile ("cas%.b %0,%2,%1" \
+ : "=d" (__ret), "+m" (*(mem)) \
+ : "d" (newval), "0" (oldval)); \
+ __ret; })
+
+#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
+ ({ __typeof (*(mem)) __ret; \
+ __asm __volatile ("cas%.w %0,%2,%1" \
+ : "=d" (__ret), "+m" (*(mem)) \
+ : "d" (newval), "0" (oldval)); \
+ __ret; })
+
+#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
+ ({ __typeof (*(mem)) __ret; \
+ __asm __volatile ("cas%.l %0,%2,%1" \
+ : "=d" (__ret), "+m" (*(mem)) \
+ : "d" (newval), "0" (oldval)); \
+ __ret; })
+
+# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
+ ({ __typeof (*(mem)) __ret; \
+ __typeof (mem) __memp = (mem); \
+ __asm __volatile ("cas2%.l %0:%R0,%1:%R1,(%2):(%3)" \
+ : "=d" (__ret) \
+ : "d" (newval), "r" (__memp), \
+ "r" ((char *) __memp + 4), "0" (oldval) \
+ : "memory"); \
+ __ret; })
+
+#define atomic_exchange_acq(mem, newvalue) \
+ ({ __typeof (*(mem)) __result = *(mem); \
+ if (sizeof (*(mem)) == 1) \
+ __asm __volatile ("1: cas%.b %0,%2,%1;" \
+ " jbne 1b" \
+ : "=d" (__result), "+m" (*(mem)) \
+ : "d" (newvalue), "0" (__result)); \
+ else if (sizeof (*(mem)) == 2) \
+ __asm __volatile ("1: cas%.w %0,%2,%1;" \
+ " jbne 1b" \
+ : "=d" (__result), "+m" (*(mem)) \
+ : "d" (newvalue), "0" (__result)); \
+ else if (sizeof (*(mem)) == 4) \
+ __asm __volatile ("1: cas%.l %0,%2,%1;" \
+ " jbne 1b" \
+ : "=d" (__result), "+m" (*(mem)) \
+ : "d" (newvalue), "0" (__result)); \
+ else \
+ { \
+ __typeof (mem) __memp = (mem); \
+ __asm __volatile ("1: cas2%.l %0:%R0,%1:%R1,(%2):(%3);" \
+ " jbne 1b" \
+ : "=d" (__result) \
+ : "d" (newvalue), "r" (__memp), \
+ "r" ((char *) __memp + 4), "0" (__result) \
+ : "memory"); \
+ } \
+ __result; })
+
+#define atomic_exchange_and_add(mem, value) \
+ ({ __typeof (*(mem)) __result = *(mem); \
+ __typeof (*(mem)) __temp; \
+ if (sizeof (*(mem)) == 1) \
+ __asm __volatile ("1: move%.b %0,%2;" \
+ " add%.b %3,%2;" \
+ " cas%.b %0,%2,%1;" \
+ " jbne 1b" \
+ : "=d" (__result), "+m" (*(mem)), \
+ "=&d" (__temp) \
+ : "d" (value), "0" (__result)); \
+ else if (sizeof (*(mem)) == 2) \
+ __asm __volatile ("1: move%.w %0,%2;" \
+ " add%.w %3,%2;" \
+ " cas%.w %0,%2,%1;" \
+ " jbne 1b" \
+ : "=d" (__result), "+m" (*(mem)), \
+ "=&d" (__temp) \
+ : "d" (value), "0" (__result)); \
+ else if (sizeof (*(mem)) == 4) \
+ __asm __volatile ("1: move%.l %0,%2;" \
+ " add%.l %3,%2;" \
+ " cas%.l %0,%2,%1;" \
+ " jbne 1b" \
+ : "=d" (__result), "+m" (*(mem)), \
+ "=&d" (__temp) \
+ : "d" (value), "0" (__result)); \
+ else \
+ { \
+ __typeof (mem) __memp = (mem); \
+ __asm __volatile ("1: move%.l %0,%1;" \
+ " move%.l %R0,%R1;" \
+ " add%.l %2,%1;" \
+ " addx%.l %R2,%R1;" \
+ " cas2%.l %0:%R0,%1:%R1,(%3):(%4);" \
+ " jbne 1b" \
+ : "=d" (__result), "=&d" (__temp) \
+ : "d" (value), "r" (__memp), \
+ "r" ((char *) __memp + 4), "0" (__result) \
+ : "memory"); \
+ } \
+ __result; })
+
+#define atomic_add(mem, value) \
+ (void) ({ if (sizeof (*(mem)) == 1) \
+ __asm __volatile ("add%.b %1,%0" \
+ : "+m" (*(mem)) \
+ : "id" (value)); \
+ else if (sizeof (*(mem)) == 2) \
+ __asm __volatile ("add%.w %1,%0" \
+ : "+m" (*(mem)) \
+ : "id" (value)); \
+ else if (sizeof (*(mem)) == 4) \
+ __asm __volatile ("add%.l %1,%0" \
+ : "+m" (*(mem)) \
+ : "id" (value)); \
+ else \
+ { \
+ __typeof (mem) __memp = (mem); \
+ __typeof (*(mem)) __oldval = *__memp; \
+ __typeof (*(mem)) __temp; \
+ __asm __volatile ("1: move%.l %0,%1;" \
+ " move%.l %R0,%R1;" \
+ " add%.l %2,%1;" \
+ " addx%.l %R2,%R1;" \
+ " cas2%.l %0:%R0,%1:%R1,(%3):(%4);" \
+ " jbne 1b" \
+ : "=d" (__oldval), "=&d" (__temp) \
+ : "d" (value), "r" (__memp), \
+ "r" ((char *) __memp + 4), "0" (__oldval) \
+ : "memory"); \
+ } \
+ })
+
+#define atomic_increment_and_test(mem) \
+ ({ char __result; \
+ if (sizeof (*(mem)) == 1) \
+ __asm __volatile ("addq%.b %#1,%1; seq %0" \
+ : "=dm" (__result), "+m" (*(mem))); \
+ else if (sizeof (*(mem)) == 2) \
+ __asm __volatile ("addq%.w %#1,%1; seq %0" \
+ : "=dm" (__result), "+m" (*(mem))); \
+ else if (sizeof (*(mem)) == 4) \
+ __asm __volatile ("addq%.l %#1,%1; seq %0" \
+ : "=dm" (__result), "+m" (*(mem))); \
+ else \
+ { \
+ __typeof (mem) __memp = (mem); \
+ __typeof (*(mem)) __oldval = *__memp; \
+ __typeof (*(mem)) __temp; \
+ __asm __volatile ("1: move%.l %1,%2;" \
+ " move%.l %R1,%R2;" \
+ " addq%.l %#1,%2;" \
+ " addx%.l %5,%R2;" \
+ " seq %0;" \
+ " cas2%.l %1:%R1,%2:%R2,(%3):(%4);" \
+ " jbne 1b" \
+ : "=&dm" (__result), "=d" (__oldval), \
+ "=&d" (__temp) \
+ : "r" (__memp), "r" ((char *) __memp + 4), \
+ "d" (0), "1" (__oldval) \
+ : "memory"); \
+ } \
+ __result; })
+
+#define atomic_decrement_and_test(mem) \
+ ({ char __result; \
+ if (sizeof (*(mem)) == 1) \
+ __asm __volatile ("subq%.b %#1,%1; seq %0" \
+ : "=dm" (__result), "+m" (*(mem))); \
+ else if (sizeof (*(mem)) == 2) \
+ __asm __volatile ("subq%.w %#1,%1; seq %0" \
+ : "=dm" (__result), "+m" (*(mem))); \
+ else if (sizeof (*(mem)) == 4) \
+ __asm __volatile ("subq%.l %#1,%1; seq %0" \
+ : "=dm" (__result), "+m" (*(mem))); \
+ else \
+ { \
+ __typeof (mem) __memp = (mem); \
+ __typeof (*(mem)) __oldval = *__memp; \
+ __typeof (*(mem)) __temp; \
+ __asm __volatile ("1: move%.l %1,%2;" \
+ " move%.l %R1,%R2;" \
+ " subq%.l %#1,%2;" \
+ " subx%.l %5,%R2;" \
+ " seq %0;" \
+ " cas2%.l %1:%R1,%2:%R2,(%3):(%4);" \
+ " jbne 1b" \
+ : "=&dm" (__result), "=d" (__oldval), \
+ "=&d" (__temp) \
+ : "r" (__memp), "r" ((char *) __memp + 4), \
+ "d" (0), "1" (__oldval) \
+ : "memory"); \
+ } \
+ __result; })
+
+#define atomic_bit_set(mem, bit) \
+ __asm __volatile ("bfset %0{%1,#1}" \
+ : "+m" (*(mem)) \
+ : "di" (sizeof (*(mem)) * 8 - (bit) - 1))
+
+#define atomic_bit_test_set(mem, bit) \
+ ({ char __result; \
+ __asm __volatile ("bfset %1{%2,#1}; sne %0" \
+ : "=dm" (__result), "+m" (*(mem)) \
+ : "di" (sizeof (*(mem)) * 8 - (bit) - 1)); \
+ __result; })
diff --git a/ports/sysdeps/m68k/m68020/bits/string.h b/ports/sysdeps/m68k/m68020/bits/string.h
new file mode 100644
index 000000000..84be224b7
--- /dev/null
+++ b/ports/sysdeps/m68k/m68020/bits/string.h
@@ -0,0 +1,26 @@
+/* Optimized, inlined string functions. m680x0 version, x >= 2.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _STRING_H
+# error "Never use <bits/string.h> directly; include <string.h> instead."
+#endif
+
+/* Currently the only purpose of this file is to tell the generic inline
+ macros that unaligned memory access is possible. */
+#define _STRING_ARCH_unaligned 1
diff --git a/ports/sysdeps/m68k/m68020/mul_1.S b/ports/sysdeps/m68k/m68020/mul_1.S
new file mode 100644
index 000000000..f3e450ed9
--- /dev/null
+++ b/ports/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, 1996, 1998 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s1_ptr (sp + 8)
+ s1_size (sp + 12)
+ s2_limb (sp + 16)
+*/
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+ TEXT
+ENTRY(__mpn_mul_1)
+
+#define res_ptr a0
+#define s1_ptr a1
+#define s1_size d2
+#define s2_limb d4
+
+/* Save used registers on the stack. */
+ moveml R(d2)-R(d4),MEM_PREDEC(sp)
+#if 0
+ movel R(d2),MEM_PREDEC(sp)
+ movel R(d3),MEM_PREDEC(sp)
+ movel R(d4),MEM_PREDEC(sp)
+#endif
+
+/* Copy the arguments to registers. Better use movem? */
+ movel MEM_DISP(sp,16),R(res_ptr)
+ movel MEM_DISP(sp,20),R(s1_ptr)
+ movel MEM_DISP(sp,24),R(s1_size)
+ movel MEM_DISP(sp,28),R(s2_limb)
+
+ eorw #1,R(s1_size)
+ clrl R(d1)
+ lsrl #1,R(s1_size)
+ bcc L(L1)
+ subql #1,R(s1_size)
+ subl R(d0),R(d0) /* (d0,cy) <= (0,0) */
+
+L(Loop:)
+ movel MEM_POSTINC(s1_ptr),R(d3)
+ mulul R(s2_limb),R(d1):R(d3)
+ addxl R(d0),R(d3)
+ movel R(d3),MEM_POSTINC(res_ptr)
+L(L1:) movel MEM_POSTINC(s1_ptr),R(d3)
+ mulul R(s2_limb),R(d0):R(d3)
+ addxl R(d1),R(d3)
+ movel R(d3),MEM_POSTINC(res_ptr)
+
+ dbf R(s1_size),L(Loop)
+ clrl R(d3)
+ addxl R(d3),R(d0)
+ subl #0x10000,R(s1_size)
+ bcc L(Loop)
+
+/* Restore used registers from stack frame. */
+ moveml MEM_POSTINC(sp),R(d2)-R(d4)
+#if 0
+ movel MEM_POSTINC(sp),R(d4)
+ movel MEM_POSTINC(sp),R(d3)
+ movel MEM_POSTINC(sp),R(d2)
+#endif
+ rts
+END(__mpn_mul_1)
diff --git a/ports/sysdeps/m68k/m68020/submul_1.S b/ports/sysdeps/m68k/m68020/submul_1.S
new file mode 100644
index 000000000..7522046b4
--- /dev/null
+++ b/ports/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, 1996, 1998 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s1_ptr (sp + 8)
+ s1_size (sp + 12)
+ s2_limb (sp + 16)
+*/
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+ TEXT
+ENTRY(__mpn_submul_1)
+
+#define res_ptr a0
+#define s1_ptr a1
+#define s1_size d2
+#define s2_limb d4
+
+/* Save used registers on the stack. */
+ moveml R(d2)-R(d5),MEM_PREDEC(sp)
+
+/* Copy the arguments to registers. Better use movem? */
+ movel MEM_DISP(sp,20),R(res_ptr)
+ movel MEM_DISP(sp,24),R(s1_ptr)
+ movel MEM_DISP(sp,28),R(s1_size)
+ movel MEM_DISP(sp,32),R(s2_limb)
+
+ eorw #1,R(s1_size)
+ clrl R(d1)
+ clrl R(d5)
+ lsrl #1,R(s1_size)
+ bcc L(L1)
+ subql #1,R(s1_size)
+ subl R(d0),R(d0) /* (d0,cy) <= (0,0) */
+
+L(Loop:)
+ movel MEM_POSTINC(s1_ptr),R(d3)
+ mulul R(s2_limb),R(d1):R(d3)
+ addxl R(d0),R(d3)
+ addxl R(d5),R(d1)
+ subl R(d3),MEM_POSTINC(res_ptr)
+L(L1:) movel MEM_POSTINC(s1_ptr),R(d3)
+ mulul R(s2_limb),R(d0):R(d3)
+ addxl R(d1),R(d3)
+ addxl R(d5),R(d0)
+ subl R(d3),MEM_POSTINC(res_ptr)
+
+ dbf R(s1_size),L(Loop)
+ addxl R(d5),R(d0)
+ subl #0x10000,R(s1_size)
+ bcc L(Loop)
+
+/* Restore used registers from stack frame. */
+ moveml MEM_POSTINC(sp),R(d2)-R(d5)
+
+ rts
+END(__mpn_submul_1)
diff --git a/ports/sysdeps/m68k/m68020/wordcopy.S b/ports/sysdeps/m68k/m68020/wordcopy.S
new file mode 100644
index 000000000..4fb1a4518
--- /dev/null
+++ b/ports/sysdeps/m68k/m68020/wordcopy.S
@@ -0,0 +1 @@
+/* Empty, not needed. */
diff --git a/ports/sysdeps/m68k/memchr.S b/ports/sysdeps/m68k/memchr.S
new file mode 100644
index 000000000..fab65a9ae
--- /dev/null
+++ b/ports/sysdeps/m68k/memchr.S
@@ -0,0 +1,232 @@
+/* memchr (str, ch, n) -- Return pointer to first occurrence of CH in the
+ first N bytes of STR.
+ For Motorola 68000.
+ Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include "asm-syntax.h"
+
+ TEXT
+ENTRY(__memchr)
+ /* Save the callee-saved registers we use. */
+ moveml R(d2)-R(d4),MEM_PREDEC(sp)
+
+ /* Get string pointer, character and length. */
+ movel MEM_DISP(sp,16),R(a0)
+ moveb MEM_DISP(sp,23),R(d0)
+ movel MEM_DISP(sp,24),R(d4)
+
+ /* Check if at least four bytes left to search. */
+ moveql #4,R(d1)
+ cmpl R(d1),R(d4)
+ bcs L(L6)
+
+ /* Distribute the character to all bytes of a longword. */
+ movel R(d0),R(d1)
+ lsll #8,R(d1)
+ moveb R(d0),R(d1)
+ movel R(d1),R(d0)
+ swap R(d0)
+ movew R(d1),R(d0)
+
+ /* First search for the character one byte at a time until the
+ pointer is aligned to a longword boundary. */
+ movel R(a0),R(d1)
+ andw #3,R(d1)
+ beq L(L1)
+ cmpb MEM(a0),R(d0)
+ beq L(L9)
+ addql #1,R(a0)
+ subql #1,R(d4)
+ beq L(L7)
+
+ movel R(a0),R(d1)
+ andw #3,R(d1)
+ beq L(L1)
+ cmpb MEM(a0),R(d0)
+ beq L(L9)
+ addql #1,R(a0)
+ subql #1,R(d4)
+ beq L(L7)
+
+ movel R(a0),R(d1)
+ andw #3,R(d1)
+ beq L(L1)
+ cmpb MEM(a0),R(d0)
+ beq L(L9)
+ addql #1,R(a0)
+ subql #1,R(d4)
+ beq L(L7)
+
+L(L1:)
+ /* Load the magic bits. Unlike the generic implementation we can
+ use the carry bit as the fourth hole. */
+ movel #0xfefefeff,R(d3)
+
+ /* We 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-31 is set, there will be a carry
+ into bit 32 (=carry flag), so all of the hole bits will
+ be changed.
+
+ 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. */
+
+ /* Still at least 4 bytes to search? */
+ subql #4,R(d4)
+ bcs L(L6)
+
+L(L2:)
+ /* Get the longword in question. */
+ movel MEM_POSTINC(a0),R(d1)
+ /* XOR with the byte we search for. */
+ eorl R(d0),R(d1)
+
+ /* Add the magic value. We get carry bits reported for each byte
+ which is not C. */
+ movel R(d3),R(d2)
+ addl R(d1),R(d2)
+
+ /* Check the fourth carry bit before it is clobbered by the next
+ XOR. If it is not set we have a hit. */
+ bcc L(L8)
+
+ /* We are only interested in carry bits that change due to the
+ previous add, so remove original bits. */
+ eorl R(d1),R(d2)
+
+ /* Now test for the other three overflow bits.
+ Set all non-carry bits. */
+ orl R(d3),R(d2)
+ /* Add 1 to get zero if all carry bits were set. */
+ addql #1,R(d2)
+
+ /* If we don't get zero then at least one byte of the word equals
+ C. */
+ bne L(L8)
+
+ /* Still at least 4 bytes to search? */
+ subql #4,R(d4)
+ bcs L(L6)
+
+ /* Get the longword in question. */
+ movel MEM_POSTINC(a0),R(d1)
+ /* XOR with the byte we search for. */
+ eorl R(d0),R(d1)
+
+ /* Add the magic value. We get carry bits reported for each byte
+ which is not C. */
+ movel R(d3),R(d2)
+ addl R(d1),R(d2)
+
+ /* Check the fourth carry bit before it is clobbered by the next
+ XOR. If it is not set we have a hit. */
+ bcc L(L8)
+
+ /* We are only interested in carry bits that change due to the
+ previous add, so remove original bits */
+ eorl R(d1),R(d2)
+
+ /* Now test for the other three overflow bits.
+ Set all non-carry bits. */
+ orl R(d3),R(d2)
+ /* Add 1 to get zero if all carry bits were set. */
+ addql #1,R(d2)
+
+ /* If we don't get zero then at least one byte of the word equals
+ C. */
+ bne L(L8)
+
+ /* Still at least 4 bytes to search? */
+ subql #4,R(d4)
+ bcc L(L2)
+
+L(L6:)
+ /* Search one byte at a time in the remaining less than 4 bytes. */
+ andw #3,R(d4)
+ beq L(L7)
+ cmpb MEM(a0),R(d0)
+ beq L(L9)
+ addql #1,R(a0)
+
+ subqw #1,R(d4)
+ beq L(L7)
+ cmpb MEM(a0),R(d0)
+ beq L(L9)
+ addql #1,R(a0)
+
+ subqw #1,R(d4)
+ beq L(L7)
+ cmpb MEM(a0),R(d0)
+ beq L(L9)
+
+L(L7:)
+ /* Return NULL. */
+ clrl R(d0)
+ movel R(d0),R(a0)
+ moveml MEM_POSTINC(sp),R(d2)-R(d4)
+ rts
+
+L(L8:)
+ /* We have a hit. Check to see which byte it was. First
+ compensate for the autoincrement in the loop. */
+ subql #4,R(a0)
+
+ cmpb MEM(a0),R(d0)
+ beq L(L9)
+ addql #1,R(a0)
+
+ cmpb MEM(a0),R(d0)
+ beq L(L9)
+ addql #1,R(a0)
+
+ cmpb MEM(a0),R(d0)
+ beq L(L9)
+ addql #1,R(a0)
+
+ /* Otherwise the fourth byte must equal C. */
+L(L9:)
+ movel R(a0),R(d0)
+ moveml MEM_POSTINC(sp),R(d2)-R(d4)
+ rts
+END(__memchr)
+
+weak_alias (__memchr, memchr)
+#if !__BOUNDED_POINTERS__
+weak_alias (__memchr, __ubp_memchr)
+#endif
+libc_hidden_builtin_def (memchr)
diff --git a/ports/sysdeps/m68k/memcopy.h b/ports/sysdeps/m68k/memcopy.h
new file mode 100644
index 000000000..0951eeaf7
--- /dev/null
+++ b/ports/sysdeps/m68k/memcopy.h
@@ -0,0 +1,100 @@
+/* memcopy.h -- definitions for memory copy functions. Motorola 68020 version.
+ Copyright (C) 1991, 1997, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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; \
+ op_t *__dst_ep = (op_t *) (dst_ep); \
+ op_t *__src_ep = (op_t *) (src_ep); \
+ switch ((nbytes) / sizeof (op_t) % 8) \
+ do \
+ { \
+ *--__dst_ep = *--__src_ep; \
+ case 7: \
+ *--__dst_ep = *--__src_ep; \
+ case 6: \
+ *--__dst_ep = *--__src_ep; \
+ case 5: \
+ *--__dst_ep = *--__src_ep; \
+ case 4: \
+ *--__dst_ep = *--__src_ep; \
+ case 3: \
+ *--__dst_ep = *--__src_ep; \
+ case 2: \
+ *--__dst_ep = *--__src_ep; \
+ case 1: \
+ *--__dst_ep = *--__src_ep; \
+ case 0: \
+ __nblocks--; \
+ } \
+ while (__nblocks != 0); \
+ (nbytes_left) = (nbytes) % sizeof (op_t); \
+ (dst_ep) = (unsigned long) __dst_ep; \
+ (src_ep) = (unsigned long) __src_ep; \
+ } while (0)
+
+#endif
diff --git a/ports/sysdeps/m68k/memusage.h b/ports/sysdeps/m68k/memusage.h
new file mode 100644
index 000000000..bb22c0acc
--- /dev/null
+++ b/ports/sysdeps/m68k/memusage.h
@@ -0,0 +1,22 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+#define GETSP() ({ register uintptr_t stack_ptr asm ("%sp"); stack_ptr; })
+
+#include <sysdeps/generic/memusage.h>
diff --git a/ports/sysdeps/m68k/preconfigure b/ports/sysdeps/m68k/preconfigure
new file mode 100644
index 000000000..35dcea4be
--- /dev/null
+++ b/ports/sysdeps/m68k/preconfigure
@@ -0,0 +1,6 @@
+# This fragment canonicalizes the machine names for m68k variants.
+
+case "$machine" in
+m680?0) base_machine=m68k machine=m68k/$machine ;;
+m68k) base_machine=m68k machine=m68k/m68020 ;;
+esac
diff --git a/ports/sysdeps/m68k/printf_fphex.c b/ports/sysdeps/m68k/printf_fphex.c
new file mode 100644
index 000000000..d021a090a
--- /dev/null
+++ b/ports/sysdeps/m68k/printf_fphex.c
@@ -0,0 +1,2 @@
+#define LONG_DOUBLE_DENORM_BIAS IEEE854_LONG_DOUBLE_BIAS
+#include <sysdeps/ieee754/ldbl-96/printf_fphex.c>
diff --git a/ports/sysdeps/m68k/rawmemchr.S b/ports/sysdeps/m68k/rawmemchr.S
new file mode 100644
index 000000000..acd8f76e4
--- /dev/null
+++ b/ports/sysdeps/m68k/rawmemchr.S
@@ -0,0 +1,180 @@
+/* rawmemchr (str, ch) -- Return pointer to first occurrence of CH in STR.
+ For Motorola 68000.
+ Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include "asm-syntax.h"
+
+ TEXT
+ENTRY(__rawmemchr)
+ /* Save the callee-saved registers we use. */
+ movel R(d2),MEM_PREDEC(sp)
+ movel R(d3),MEM_PREDEC(sp)
+
+ /* Get string pointer and character. */
+ movel MEM_DISP(sp,12),R(a0)
+ moveb MEM_DISP(sp,19),R(d0)
+
+ /* Distribute the character to all bytes of a longword. */
+ movel R(d0),R(d1)
+ lsll #8,R(d1)
+ moveb R(d0),R(d1)
+ movel R(d1),R(d0)
+ swap R(d0)
+ movew R(d1),R(d0)
+
+ /* First search for the character one byte at a time until the
+ pointer is aligned to a longword boundary. */
+ movel R(a0),R(d1)
+ andw #3,R(d1)
+ beq L(L1)
+ cmpb MEM(a0),R(d0)
+ beq L(L9)
+ addql #1,R(a0)
+
+ movel R(a0),R(d1)
+ andw #3,R(d1)
+ beq L(L1)
+ cmpb MEM(a0),R(d0)
+ beq L(L9)
+ addql #1,R(a0)
+
+ movel R(a0),R(d1)
+ andw #3,R(d1)
+ beq L(L1)
+ cmpb MEM(a0),R(d0)
+ beq L(L9)
+ addql #1,R(a0)
+
+L(L1:)
+ /* Load the magic bits. Unlike the generic implementation we can
+ use the carry bit as the fourth hole. */
+ movel #0xfefefeff,R(d3)
+
+ /* We 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-31 is set, there will be a carry
+ into bit 32 (=carry flag), so all of the hole bits will
+ be changed.
+
+ 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. */
+
+L(L2:)
+ /* Get the longword in question. */
+ movel MEM_POSTINC(a0),R(d1)
+ /* XOR with the byte we search for. */
+ eorl R(d0),R(d1)
+
+ /* Add the magic value. We get carry bits reported for each byte
+ which is not C. */
+ movel R(d3),R(d2)
+ addl R(d1),R(d2)
+
+ /* Check the fourth carry bit before it is clobbered by the next
+ XOR. If it is not set we have a hit. */
+ bcc L(L8)
+
+ /* We are only interested in carry bits that change due to the
+ previous add, so remove original bits. */
+ eorl R(d1),R(d2)
+
+ /* Now test for the other three overflow bits.
+ Set all non-carry bits. */
+ orl R(d3),R(d2)
+ /* Add 1 to get zero if all carry bits were set. */
+ addql #1,R(d2)
+
+ /* If we don't get zero then at least one byte of the word equals
+ C. */
+ bne L(L8)
+
+ /* Get the longword in question. */
+ movel MEM_POSTINC(a0),R(d1)
+ /* XOR with the byte we search for. */
+ eorl R(d0),R(d1)
+
+ /* Add the magic value. We get carry bits reported for each byte
+ which is not C. */
+ movel R(d3),R(d2)
+ addl R(d1),R(d2)
+
+ /* Check the fourth carry bit before it is clobbered by the next
+ XOR. If it is not set we have a hit. */
+ bcc L(L8)
+
+ /* We are only interested in carry bits that change due to the
+ previous add, so remove original bits */
+ eorl R(d1),R(d2)
+
+ /* Now test for the other three overflow bits.
+ Set all non-carry bits. */
+ orl R(d3),R(d2)
+ /* Add 1 to get zero if all carry bits were set. */
+ addql #1,R(d2)
+
+ /* If we don't get zero then at least one byte of the word equals
+ C. */
+ beq L(L2)
+
+L(L8:)
+ /* We have a hit. Check to see which byte it was. First
+ compensate for the autoincrement in the loop. */
+ subql #4,R(a0)
+
+ cmpb MEM(a0),R(d0)
+ beq L(L9)
+ addql #1,R(a0)
+
+ cmpb MEM(a0),R(d0)
+ beq L(L9)
+ addql #1,R(a0)
+
+ cmpb MEM(a0),R(d0)
+ beq L(L9)
+ addql #1,R(a0)
+
+ /* Otherwise the fourth byte must equal C. */
+L(L9:)
+ movel R(a0),R(d0)
+ movel MEM_POSTINC(sp),R(d3)
+ movel MEM_POSTINC(sp),R(d2)
+ rts
+END(__rawmemchr)
+
+libc_hidden_def (__rawmemchr)
+weak_alias (__rawmemchr, rawmemchr)
diff --git a/ports/sysdeps/m68k/rshift.S b/ports/sysdeps/m68k/rshift.S
new file mode 100644
index 000000000..5e6abceb9
--- /dev/null
+++ b/ports/sysdeps/m68k/rshift.S
@@ -0,0 +1,146 @@
+/* mc68020 __mpn_rshift -- Shift right a low-level natural-number integer.
+
+Copyright (C) 1996, 1998 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s_ptr (sp + 8)
+ s_size (sp + 16)
+ cnt (sp + 12)
+*/
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+#define res_ptr a1
+#define s_ptr a0
+#define s_size d6
+#define cnt d4
+
+ TEXT
+ENTRY(__mpn_rshift)
+/* Save used registers on the stack. */
+ moveml R(d2)-R(d6)/R(a2),MEM_PREDEC(sp)
+
+/* Copy the arguments to registers. */
+ movel MEM_DISP(sp,28),R(res_ptr)
+ movel MEM_DISP(sp,32),R(s_ptr)
+ movel MEM_DISP(sp,36),R(s_size)
+ movel MEM_DISP(sp,40),R(cnt)
+
+ moveql #1,R(d5)
+ cmpl R(d5),R(cnt)
+ bne L(Lnormal)
+ cmpl R(res_ptr),R(s_ptr)
+ bls L(Lspecial) /* jump if res_ptr >= s_ptr */
+#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
+ lea MEM_INDX1(res_ptr,s_size,l,4),R(a2)
+#else /* not mc68020 */
+ movel R(s_size),R(d0)
+ asll #2,R(d0)
+ lea MEM_INDX(res_ptr,d0,l),R(a2)
+#endif
+ cmpl R(s_ptr),R(a2)
+ bls L(Lspecial) /* jump if s_ptr >= res_ptr + s_size */
+
+L(Lnormal:)
+ moveql #32,R(d5)
+ subl R(cnt),R(d5)
+ movel MEM_POSTINC(s_ptr),R(d2)
+ movel R(d2),R(d0)
+ lsll R(d5),R(d0) /* compute carry limb */
+
+ lsrl R(cnt),R(d2)
+ movel R(d2),R(d1)
+ subql #1,R(s_size)
+ beq L(Lend)
+ lsrl #1,R(s_size)
+ bcs L(L1)
+ subql #1,R(s_size)
+
+L(Loop:)
+ movel MEM_POSTINC(s_ptr),R(d2)
+ movel R(d2),R(d3)
+ lsll R(d5),R(d3)
+ orl R(d3),R(d1)
+ movel R(d1),MEM_POSTINC(res_ptr)
+ lsrl R(cnt),R(d2)
+L(L1:)
+ movel MEM_POSTINC(s_ptr),R(d1)
+ movel R(d1),R(d3)
+ lsll R(d5),R(d3)
+ orl R(d3),R(d2)
+ movel R(d2),MEM_POSTINC(res_ptr)
+ lsrl R(cnt),R(d1)
+
+ dbf R(s_size),L(Loop)
+ subl #0x10000,R(s_size)
+ bcc L(Loop)
+
+L(Lend:)
+ movel R(d1),MEM(res_ptr) /* store most significant limb */
+
+/* Restore used registers from stack frame. */
+ moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
+ rts
+
+/* We loop from most significant end of the arrays, which is only
+ permissible if the source and destination don't overlap, since the
+ function is documented to work for overlapping source and destination. */
+
+L(Lspecial:)
+#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
+ lea MEM_INDX1(s_ptr,s_size,l,4),R(s_ptr)
+ lea MEM_INDX1(res_ptr,s_size,l,4),R(res_ptr)
+#else /* not mc68000 */
+ movel R(s_size),R(d0)
+ asll #2,R(d0)
+ addl R(s_size),R(s_ptr)
+ addl R(s_size),R(res_ptr)
+#endif
+
+ clrl R(d0) /* initialize carry */
+ eorw #1,R(s_size)
+ lsrl #1,R(s_size)
+ bcc L(LL1)
+ subql #1,R(s_size)
+
+L(LLoop:)
+ movel MEM_PREDEC(s_ptr),R(d2)
+ roxrl #1,R(d2)
+ movel R(d2),MEM_PREDEC(res_ptr)
+L(LL1:)
+ movel MEM_PREDEC(s_ptr),R(d2)
+ roxrl #1,R(d2)
+ movel R(d2),MEM_PREDEC(res_ptr)
+
+ dbf R(s_size),L(LLoop)
+ roxrl #1,R(d0) /* save cy in msb */
+ subl #0x10000,R(s_size)
+ bcs L(LLend)
+ addl R(d0),R(d0) /* restore cy */
+ bra L(LLoop)
+
+L(LLend:)
+/* Restore used registers from stack frame. */
+ moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2)
+ rts
+END(__mpn_rshift)
diff --git a/ports/sysdeps/m68k/s_isinfl.c b/ports/sysdeps/m68k/s_isinfl.c
new file mode 100644
index 000000000..250203908
--- /dev/null
+++ b/ports/sysdeps/m68k/s_isinfl.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1991, 1992, 1995, 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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
+__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.
+ In Motorola's interpretation the integer bit is ignored. */
+ if ((u.ieee.exponent & 0x7fff) == 0x7fff &&
+ (u.ieee.mantissa0 & 0x7fffffff) == 0 && u.ieee.mantissa1 == 0)
+ return u.ieee.negative ? -1 : 1;
+
+ return 0;
+}
+
+hidden_def (__isinfl)
+weak_alias (__isinfl, isinfl);
diff --git a/ports/sysdeps/m68k/s_isnanl.c b/ports/sysdeps/m68k/s_isnanl.c
new file mode 100644
index 000000000..999746f29
--- /dev/null
+++ b/ports/sysdeps/m68k/s_isnanl.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991, 1992, 1995, 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include "ieee754.h"
+
+/* 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. In Motorola's
+ interpretation the integer bit is ignored. */
+ return ((u.ieee.exponent & 0x7fff) == 0x7fff &&
+ ((u.ieee.mantissa0 & 0x7fffffff) != 0 || u.ieee.mantissa1 != 0));
+}
+
+hidden_def (__isnanl)
+weak_alias (__isnanl, isnanl);
diff --git a/ports/sysdeps/m68k/setjmp.c b/ports/sysdeps/m68k/setjmp.c
new file mode 100644
index 000000000..8a6c3f9a0
--- /dev/null
+++ b/ports/sysdeps/m68k/setjmp.c
@@ -0,0 +1,63 @@
+/* Copyright (C) 1991, 1992, 1994, 1997, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <setjmp.h>
+
+/* Save the current program position in ENV and return 0. */
+int
+#if defined BSD_SETJMP
+# undef setjmp
+# define savemask 1
+setjmp (jmp_buf env)
+#elif defined BSD__SETJMP
+# undef _setjmp
+# define savemask 0
+_setjmp (jmp_buf env)
+#else
+__sigsetjmp (jmp_buf env, int savemask)
+#endif
+{
+ /* 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);
+}
+#if !defined BSD_SETJMP && !defined BSD__SETJMP
+hidden_def (__sigsetjmp)
+#endif
diff --git a/ports/sysdeps/m68k/stackinfo.h b/ports/sysdeps/m68k/stackinfo.h
new file mode 100644
index 000000000..66e5a17fb
--- /dev/null
+++ b/ports/sysdeps/m68k/stackinfo.h
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file contains a bit of information about the stack allocation
+ of the processor. */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+/* On m68k the stack grows down. */
+#define _STACK_GROWS_DOWN 1
+
+#endif /* stackinfo.h */
diff --git a/ports/sysdeps/m68k/strchr.S b/ports/sysdeps/m68k/strchr.S
new file mode 100644
index 000000000..04626ffd6
--- /dev/null
+++ b/ports/sysdeps/m68k/strchr.S
@@ -0,0 +1,258 @@
+/* strchr (str, ch) -- Return pointer to first occurrence of CH in STR.
+ For Motorola 68000.
+ Copyright (C) 1999, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include "asm-syntax.h"
+
+ TEXT
+ENTRY(strchr)
+ /* Save the callee-saved registers we use. */
+ movel R(d2),MEM_PREDEC(sp)
+ movel R(d3),MEM_PREDEC(sp)
+
+ /* Get string pointer and character. */
+ movel MEM_DISP(sp,12),R(a0)
+ moveb MEM_DISP(sp,19),R(d0)
+
+ /* Distribute the character to all bytes of a longword. */
+ movel R(d0),R(d1)
+ lsll #8,R(d1)
+ moveb R(d0),R(d1)
+ movel R(d1),R(d0)
+ swap R(d0)
+ movew R(d1),R(d0)
+
+ /* First search for the character one byte at a time until the
+ pointer is aligned to a longword boundary. */
+ movel R(a0),R(d1)
+ andw #3,R(d1)
+ beq L(L1)
+ moveb MEM(a0),R(d1)
+ cmpb R(d0),R(d1)
+ beq L(L9)
+ tstb R(d1)
+ beq L(L3)
+ addql #1,R(a0)
+
+ movel R(a0),R(d1)
+ andw #3,R(d1)
+ beq L(L1)
+ moveb MEM(a0),R(d1)
+ cmpb R(d0),R(d1)
+ beq L(L9)
+ tstb R(d1)
+ beq L(L3)
+ addql #1,R(a0)
+
+ movel R(a0),R(d1)
+ andw #3,R(d1)
+ beq L(L1)
+ moveb MEM(a0),R(d1)
+ cmpb R(d0),R(d1)
+ beq L(L9)
+ tstb R(d1)
+ beq L(L3)
+ addql #1,R(a0)
+
+L(L1:)
+ /* Load the magic bits. Unlike the generic implementation we can
+ use the carry bit as the fourth hole. */
+ movel #0xfefefeff,R(d3)
+
+ /* We 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-31 is set, there will be a carry
+ into bit 32 (=carry flag), so all of the hole bits will
+ be changed.
+
+ 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. */
+
+L(L2:)
+ /* Get the longword in question. */
+ movel MEM_POSTINC(a0),R(d1)
+ /* XOR with the byte we search for. */
+ eorl R(d0),R(d1)
+
+ /* Add the magic value. We get carry bits reported for each byte
+ which is not C. */
+ movel R(d3),R(d2)
+ addl R(d1),R(d2)
+
+ /* Check the fourth carry bit before it is clobbered by the next
+ XOR. If it is not set we have a hit. */
+ bcc L(L8)
+
+ /* We are only interested in carry bits that change due to the
+ previous add, so remove original bits. */
+ eorl R(d1),R(d2)
+
+ /* Now test for the other three overflow bits.
+ Set all non-carry bits. */
+ orl R(d3),R(d2)
+ /* Add 1 to get zero if all carry bits were set. */
+ addql #1,R(d2)
+
+ /* If we don't get zero then at least one byte of the word equals
+ C. */
+ bne L(L8)
+
+ /* Next look for a NUL byte.
+ Restore original longword without reload. */
+ eorl R(d0),R(d1)
+ /* Add the magic value. We get carry bits reported for each byte
+ which is not NUL. */
+ movel R(d3),R(d2)
+ addl R(d1),R(d2)
+
+ /* Check the fourth carry bit before it is clobbered by the next
+ XOR. If it is not set we have a hit, and return NULL. */
+ bcc L(L3)
+
+ /* We are only interested in carry bits that change due to the
+ previous add, so remove original bits. */
+ eorl R(d1),R(d2)
+
+ /* Now test for the other three overflow bits.
+ Set all non-carry bits. */
+ orl R(d3),R(d2)
+ /* Add 1 to get zero if all carry bits were set. */
+ addql #1,R(d2)
+
+ /* If we don't get zero then at least one byte of the word was NUL
+ and we return NULL. Otherwise continue with the next longword. */
+ bne L(L3)
+
+ /* Get the longword in question. */
+ movel MEM_POSTINC(a0),R(d1)
+ /* XOR with the byte we search for. */
+ eorl R(d0),R(d1)
+
+ /* Add the magic value. We get carry bits reported for each byte
+ which is not C. */
+ movel R(d3),R(d2)
+ addl R(d1),R(d2)
+
+ /* Check the fourth carry bit before it is clobbered by the next
+ XOR. If it is not set we have a hit. */
+ bcc L(L8)
+
+ /* We are only interested in carry bits that change due to the
+ previous add, so remove original bits */
+ eorl R(d1),R(d2)
+
+ /* Now test for the other three overflow bits.
+ Set all non-carry bits. */
+ orl R(d3),R(d2)
+ /* Add 1 to get zero if all carry bits were set. */
+ addql #1,R(d2)
+
+ /* If we don't get zero then at least one byte of the word equals
+ C. */
+ bne L(L8)
+
+ /* Next look for a NUL byte.
+ Restore original longword without reload. */
+ eorl R(d0),R(d1)
+ /* Add the magic value. We get carry bits reported for each byte
+ which is not NUL. */
+ movel R(d3),R(d2)
+ addl R(d1),R(d2)
+
+ /* Check the fourth carry bit before it is clobbered by the next
+ XOR. If it is not set we have a hit, and return NULL. */
+ bcc L(L3)
+
+ /* We are only interested in carry bits that change due to the
+ previous add, so remove original bits */
+ eorl R(d1),R(d2)
+
+ /* Now test for the other three overflow bits.
+ Set all non-carry bits. */
+ orl R(d3),R(d2)
+ /* Add 1 to get zero if all carry bits were set. */
+ addql #1,R(d2)
+
+ /* If we don't get zero then at least one byte of the word was NUL
+ and we return NULL. Otherwise continue with the next longword. */
+ beq L(L2)
+
+L(L3:)
+ /* Return NULL. */
+ clrl R(d0)
+ movel R(d0),R(a0)
+ movel MEM_POSTINC(sp),R(d3)
+ movel MEM_POSTINC(sp),R(d2)
+ rts
+
+L(L8:)
+ /* We have a hit. Check to see which byte it was. First
+ compensate for the autoincrement in the loop. */
+ subql #4,R(a0)
+
+ moveb MEM(a0),R(d1)
+ cmpb R(d0),R(d1)
+ beq L(L9)
+ tstb R(d1)
+ beq L(L3)
+ addql #1,R(a0)
+
+ moveb MEM(a0),R(d1)
+ cmpb R(d0),R(d1)
+ beq L(L9)
+ tstb R(d1)
+ beq L(L3)
+ addql #1,R(a0)
+
+ moveb MEM(a0),R(d1)
+ cmpb R(d0),R(d1)
+ beq L(L9)
+ tstb R(d1)
+ beq L(L3)
+ addql #1,R(a0)
+
+ /* Otherwise the fourth byte must equal C. */
+L(L9:)
+ movel R(a0),R(d0)
+ movel MEM_POSTINC(sp),R(d3)
+ movel MEM_POSTINC(sp),R(d2)
+ rts
+END(strchr)
+
+weak_alias (strchr, index)
+libc_hidden_builtin_def (strchr)
diff --git a/ports/sysdeps/m68k/strchrnul.S b/ports/sysdeps/m68k/strchrnul.S
new file mode 100644
index 000000000..3fee2b236
--- /dev/null
+++ b/ports/sysdeps/m68k/strchrnul.S
@@ -0,0 +1,250 @@
+/* strchrnul (str, ch) -- Return pointer to first occurrence of CH in STR
+ or the final NUL byte.
+ For Motorola 68000.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include "asm-syntax.h"
+
+ TEXT
+ENTRY(__strchrnul)
+ /* Save the callee-saved registers we use. */
+ movel R(d2),MEM_PREDEC(sp)
+ movel R(d3),MEM_PREDEC(sp)
+
+ /* Get string pointer and character. */
+ movel MEM_DISP(sp,12),R(a0)
+ moveb MEM_DISP(sp,19),R(d0)
+
+ /* Distribute the character to all bytes of a longword. */
+ movel R(d0),R(d1)
+ lsll #8,R(d1)
+ moveb R(d0),R(d1)
+ movel R(d1),R(d0)
+ swap R(d0)
+ movew R(d1),R(d0)
+
+ /* First search for the character one byte at a time until the
+ pointer is aligned to a longword boundary. */
+ movel R(a0),R(d1)
+ andw #3,R(d1)
+ beq L(L1)
+ moveb MEM(a0),R(d1)
+ cmpb R(d0),R(d1)
+ beq L(L9)
+ tstb R(d1)
+ beq L(L9)
+ addql #1,R(a0)
+
+ movel R(a0),R(d1)
+ andw #3,R(d1)
+ beq L(L1)
+ moveb MEM(a0),R(d1)
+ cmpb R(d0),R(d1)
+ beq L(L9)
+ tstb R(d1)
+ beq L(L9)
+ addql #1,R(a0)
+
+ movel R(a0),R(d1)
+ andw #3,R(d1)
+ beq L(L1)
+ moveb MEM(a0),R(d1)
+ cmpb R(d0),R(d1)
+ beq L(L9)
+ tstb R(d1)
+ beq L(L9)
+ addql #1,R(a0)
+
+L(L1:)
+ /* Load the magic bits. Unlike the generic implementation we can
+ use the carry bit as the fourth hole. */
+ movel #0xfefefeff,R(d3)
+
+ /* We 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-31 is set, there will be a carry
+ into bit 32 (=carry flag), so all of the hole bits will
+ be changed.
+
+ 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. */
+
+L(L2:)
+ /* Get the longword in question. */
+ movel MEM_POSTINC(a0),R(d1)
+ /* XOR with the byte we search for. */
+ eorl R(d0),R(d1)
+
+ /* Add the magic value. We get carry bits reported for each byte
+ which is not C. */
+ movel R(d3),R(d2)
+ addl R(d1),R(d2)
+
+ /* Check the fourth carry bit before it is clobbered by the next
+ XOR. If it is not set we have a hit. */
+ bcc L(L8)
+
+ /* We are only interested in carry bits that change due to the
+ previous add, so remove original bits. */
+ eorl R(d1),R(d2)
+
+ /* Now test for the other three overflow bits.
+ Set all non-carry bits. */
+ orl R(d3),R(d2)
+ /* Add 1 to get zero if all carry bits were set. */
+ addql #1,R(d2)
+
+ /* If we don't get zero then at least one byte of the word equals
+ C. */
+ bne L(L8)
+
+ /* Next look for a NUL byte.
+ Restore original longword without reload. */
+ eorl R(d0),R(d1)
+ /* Add the magic value. We get carry bits reported for each byte
+ which is not NUL. */
+ movel R(d3),R(d2)
+ addl R(d1),R(d2)
+
+ /* Check the fourth carry bit before it is clobbered by the next
+ XOR. If it is not set we have a hit. */
+ bcc L(L8)
+
+ /* We are only interested in carry bits that change due to the
+ previous add, so remove original bits. */
+ eorl R(d1),R(d2)
+
+ /* Now test for the other three overflow bits.
+ Set all non-carry bits. */
+ orl R(d3),R(d2)
+ /* Add 1 to get zero if all carry bits were set. */
+ addql #1,R(d2)
+
+ /* If we don't get zero then at least one byte of the word was
+ NUL. Otherwise continue with the next longword. */
+ bne L(L8)
+
+ /* Get the longword in question. */
+ movel MEM_POSTINC(a0),R(d1)
+ /* XOR with the byte we search for. */
+ eorl R(d0),R(d1)
+
+ /* Add the magic value. We get carry bits reported for each byte
+ which is not C. */
+ movel R(d3),R(d2)
+ addl R(d1),R(d2)
+
+ /* Check the fourth carry bit before it is clobbered by the next
+ XOR. If it is not set we have a hit. */
+ bcc L(L8)
+
+ /* We are only interested in carry bits that change due to the
+ previous add, so remove original bits */
+ eorl R(d1),R(d2)
+
+ /* Now test for the other three overflow bits.
+ Set all non-carry bits. */
+ orl R(d3),R(d2)
+ /* Add 1 to get zero if all carry bits were set. */
+ addql #1,R(d2)
+
+ /* If we don't get zero then at least one byte of the word equals
+ C. */
+ bne L(L8)
+
+ /* Next look for a NUL byte.
+ Restore original longword without reload. */
+ eorl R(d0),R(d1)
+ /* Add the magic value. We get carry bits reported for each byte
+ which is not NUL. */
+ movel R(d3),R(d2)
+ addl R(d1),R(d2)
+
+ /* Check the fourth carry bit before it is clobbered by the next
+ XOR. If it is not set we have a hit. */
+ bcc L(L8)
+
+ /* We are only interested in carry bits that change due to the
+ previous add, so remove original bits */
+ eorl R(d1),R(d2)
+
+ /* Now test for the other three overflow bits.
+ Set all non-carry bits. */
+ orl R(d3),R(d2)
+ /* Add 1 to get zero if all carry bits were set. */
+ addql #1,R(d2)
+
+ /* If we don't get zero then at least one byte of the word was
+ NUL. Otherwise continue with the next longword. */
+ beq L(L2)
+
+L(L8:)
+ /* We have a hit. Check to see which byte it was. First
+ compensate for the autoincrement in the loop. */
+ subql #4,R(a0)
+
+ moveb MEM(a0),R(d1)
+ cmpb R(d0),R(d1)
+ beq L(L9)
+ tstb R(d1)
+ beq L(L9)
+ addql #1,R(a0)
+
+ moveb MEM(a0),R(d1)
+ cmpb R(d0),R(d1)
+ beq L(L9)
+ tstb R(d1)
+ beq L(L9)
+ addql #1,R(a0)
+
+ moveb MEM(a0),R(d1)
+ cmpb R(d0),R(d1)
+ beq L(L9)
+ tstb R(d1)
+ beq L(L9)
+ addql #1,R(a0)
+
+ /* Otherwise the fourth byte must equal C or be NUL. */
+L(L9:)
+ movel R(a0),R(d0)
+ movel MEM_POSTINC(sp),R(d3)
+ movel MEM_POSTINC(sp),R(d2)
+ rts
+END(__strchrnul)
+
+weak_alias (__strchrnul, strchrnul)
diff --git a/ports/sysdeps/m68k/strtold_l.c b/ports/sysdeps/m68k/strtold_l.c
new file mode 100644
index 000000000..481d9924c
--- /dev/null
+++ b/ports/sysdeps/m68k/strtold_l.c
@@ -0,0 +1,2 @@
+#define DENORM_EXP (MIN_EXP - 1)
+#include <sysdeps/ieee754/ldbl-96/strtold_l.c>
diff --git a/ports/sysdeps/m68k/sub_n.S b/ports/sysdeps/m68k/sub_n.S
new file mode 100644
index 000000000..5833dd271
--- /dev/null
+++ b/ports/sysdeps/m68k/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, 1996, 1998 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+/*
+ INPUT PARAMETERS
+ res_ptr (sp + 4)
+ s1_ptr (sp + 8)
+ s2_ptr (sp + 16)
+ size (sp + 12)
+*/
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+ TEXT
+ENTRY(__mpn_sub_n)
+/* Save used registers on the stack. */
+ movel R(d2),MEM_PREDEC(sp)
+ movel R(a2),MEM_PREDEC(sp)
+
+/* Copy the arguments to registers. Better use movem? */
+ movel MEM_DISP(sp,12),R(a2)
+ movel MEM_DISP(sp,16),R(a0)
+ movel MEM_DISP(sp,20),R(a1)
+ movel MEM_DISP(sp,24),R(d2)
+
+ eorw #1,R(d2)
+ lsrl #1,R(d2)
+ bcc L(L1)
+ subql #1,R(d2) /* clears cy as side effect */
+
+L(Loop:)
+ movel MEM_POSTINC(a0),R(d0)
+ movel MEM_POSTINC(a1),R(d1)
+ subxl R(d1),R(d0)
+ movel R(d0),MEM_POSTINC(a2)
+L(L1:) movel MEM_POSTINC(a0),R(d0)
+ movel MEM_POSTINC(a1),R(d1)
+ subxl R(d1),R(d0)
+ movel R(d0),MEM_POSTINC(a2)
+
+ dbf R(d2),L(Loop) /* loop until 16 lsb of %4 == -1 */
+ subxl R(d0),R(d0) /* d0 <= -cy; save cy as 0 or -1 in d0 */
+ subl #0x10000,R(d2)
+ bcs L(L2)
+ addl R(d0),R(d0) /* restore cy */
+ bra L(Loop)
+
+L(L2:)
+ negl R(d0)
+
+/* Restore used registers from stack frame. */
+ movel MEM_POSTINC(sp),R(a2)
+ movel MEM_POSTINC(sp),R(d2)
+
+ rts
+END(__mpn_sub_n)
diff --git a/ports/sysdeps/m68k/sys/ucontext.h b/ports/sysdeps/m68k/sys/ucontext.h
new file mode 100644
index 000000000..857ed6b42
--- /dev/null
+++ b/ports/sysdeps/m68k/sys/ucontext.h
@@ -0,0 +1,108 @@
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* System V/m68k ABI compliant context switching support. */
+
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <signal.h>
+
+/* Type for general register. */
+typedef int greg_t;
+
+/* Number of general registers. */
+#define NGREG 18
+
+/* Container for all general registers. */
+typedef greg_t gregset_t[NGREG];
+
+/* Number of each register is the `gregset_t' array. */
+enum
+{
+ R_D0 = 0,
+#define R_D0 R_D0
+ R_D1 = 1,
+#define R_D1 R_D1
+ R_D2 = 2,
+#define R_D2 R_D2
+ R_D3 = 3,
+#define R_D3 R_D3
+ R_D4 = 4,
+#define R_D4 R_D4
+ R_D5 = 5,
+#define R_D5 R_D5
+ R_D6 = 6,
+#define R_D6 R_D6
+ R_D7 = 7,
+#define R_D7 R_D7
+ R_A0 = 8,
+#define R_A0 R_A0
+ R_A1 = 9,
+#define R_A1 R_A1
+ R_A2 = 10,
+#define R_A2 R_A2
+ R_A3 = 11,
+#define R_A3 R_A3
+ R_A4 = 12,
+#define R_A4 R_A4
+ R_A5 = 13,
+#define R_A5 R_A5
+ R_A6 = 14,
+#define R_A6 R_A6
+ R_A7 = 15,
+#define R_A7 R_A7
+ R_SP = 15,
+#define R_SP R_SP
+ R_PC = 16,
+#define R_PC R_PC
+ R_PS = 17
+#define R_PS R_PS
+};
+
+/* Structure to describe FPU registers. */
+typedef struct fpregset
+{
+ int f_pcr;
+ int f_psr;
+ int f_fpiaddr;
+ int f_fpregs[8][3];
+} fpregset_t;
+
+/* Context to describe whole processor state. */
+typedef struct
+{
+ int version;
+ gregset_t gregs;
+} mcontext_t;
+
+#define MCONTEXT_VERSION 1
+
+/* Userlevel context. */
+typedef struct ucontext
+{
+ unsigned long int uc_flags;
+ struct ucontext *uc_link;
+ __sigset_t uc_sigmask;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ long int uc_filler[201];
+} ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/ports/sysdeps/m68k/sysdep.h b/ports/sysdeps/m68k/sysdep.h
new file mode 100644
index 000000000..f492ff617
--- /dev/null
+++ b/ports/sysdeps/m68k/sysdep.h
@@ -0,0 +1,100 @@
+/* Assembler macros for m68k.
+ Copyright (C) 1998, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdeps/generic/sysdep.h>
+
+#ifdef __ASSEMBLER__
+
+/* Syntactic details of assembler. */
+
+# ifdef HAVE_ELF
+
+/* ELF uses byte-counts for .align, most others use log2 of count of bytes. */
+# define ALIGNARG(log2) 1<<log2
+/* For ELF we need the `.type' directive to make shared libs work right. */
+# define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg
+# define ASM_SIZE_DIRECTIVE(name) .size name,.-name
+
+/* In ELF C symbols are asm symbols. */
+# undef NO_UNDERSCORES
+# define NO_UNDERSCORES
+
+# else
+
+# define ALIGNARG(log2) log2
+# define ASM_TYPE_DIRECTIVE(name,type) /* Nothing is specified. */
+# define ASM_SIZE_DIRECTIVE(name) /* Nothing is specified. */
+
+# endif
+
+
+/* Define an entry point visible from C.
+
+ There is currently a bug in gdb which prevents us from specifying
+ incomplete stabs information. Fake some entries here which specify
+ the current source file. */
+# define ENTRY(name) \
+ .globl C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function); \
+ .align ALIGNARG(2); \
+ C_LABEL(name) \
+ CALL_MCOUNT
+
+# undef END
+# define END(name) ASM_SIZE_DIRECTIVE(name)
+
+
+/* If compiled for profiling, call `_mcount' at the start of each function. */
+# ifdef PROF
+/* The mcount code relies on a normal frame pointer being on the stack
+ to locate our caller, so push one just for its benefit. */
+# define CALL_MCOUNT \
+ move.l %fp, -(%sp); move.l %sp, %fp; \
+ jbsr JUMPTARGET (mcount); \
+ move.l (%sp)+, %fp;
+# else
+# define CALL_MCOUNT /* Do nothing. */
+# endif
+
+# 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
+# define mcount _mcount
+# endif
+
+# define PSEUDO(name, syscall_name, args) \
+ .globl syscall_error; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args); \
+ jcc JUMPTARGET(syscall_error)
+
+# undef PSEUDO_END
+# define PSEUDO_END(name) \
+ END (name)
+
+# undef JUMPTARGET
+# ifdef PIC
+# define JUMPTARGET(name) name##@PLTPC
+# else
+# define JUMPTARGET(name) name
+# endif
+
+#endif /* __ASSEMBLER__ */
diff --git a/ports/sysdeps/m88k/add_n.s b/ports/sysdeps/m88k/add_n.s
new file mode 100644
index 000000000..a10730d7c
--- /dev/null
+++ b/ports/sysdeps/m88k/add_n.s
@@ -0,0 +1,104 @@
+; mc88100 __mpn_add -- Add two limb vectors of the same length > 0 and store
+; sum in a third limb vector.
+
+; Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
+
+; This file is part of the GNU MP Library.
+
+; The GNU MP Library is free software; you can redistribute it and/or modify
+; it under the terms of the GNU Lesser General Public License as published by
+; the Free Software Foundation; either version 2.1 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 Lesser General Public
+; License for more details.
+
+; You should have received a copy of the GNU Lesser General Public License
+; along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+; MA 02111-1307, USA.
+
+
+; INPUT PARAMETERS
+; res_ptr 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 about 4.6 clocks/limb + 18 clocks/limb-vector on an 88100,
+; but on the 88110, it seems to run much slower, 6.6 clocks/limb.
+
+ text
+ align 16
+ global ___mpn_add_n
+___mpn_add_n:
+ ld r6,r3,0 ; read first limb from s1_ptr
+ extu r10,r5,3
+ ld r7,r4,0 ; read first limb from s2_ptr
+
+ subu.co r5,r0,r5 ; (clear carry as side effect)
+ mak r5,r5,3<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,32
+ st r8,r2,28
+ addu r4,r4,32
+ ld r6,r3,0
+ addu r2,r2,32
+ ld r7,r4,0
+Lzero: subu r10,r10,1 ; add 0 + 8r limbs (adj loop cnt)
+Lbase: ld r8,r3,4
+ addu.cio r6,r6,r7
+ ld r9,r4,4
+ st r6,r2,0
+ ld r6,r3,8 ; add 7 + 8r limbs
+ addu.cio r8,r8,r9
+ ld r7,r4,8
+ st r8,r2,4
+ ld r8,r3,12 ; add 6 + 8r limbs
+ addu.cio r6,r6,r7
+ ld r9,r4,12
+ st r6,r2,8
+ ld r6,r3,16 ; add 5 + 8r limbs
+ addu.cio r8,r8,r9
+ ld r7,r4,16
+ st r8,r2,12
+ ld r8,r3,20 ; add 4 + 8r limbs
+ addu.cio r6,r6,r7
+ ld r9,r4,20
+ st r6,r2,16
+ ld r6,r3,24 ; add 3 + 8r limbs
+ addu.cio r8,r8,r9
+ ld r7,r4,24
+ st r8,r2,20
+ ld r8,r3,28 ; add 2 + 8r limbs
+ addu.cio r6,r6,r7
+ ld r9,r4,28
+ st r6,r2,24
+ bcnd.n ne0,r10,Loop ; add 1 + 8r limbs
+ addu.cio r8,r8,r9
+
+ st r8,r2,28 ; store most significant limb
+
+ jmp.n r1
+ addu.ci r2,r0,r0 ; return carry-out from most sign. limb
diff --git a/ports/sysdeps/m88k/ffs.c b/ports/sysdeps/m88k/ffs.c
new file mode 100644
index 000000000..9381f54b0
--- /dev/null
+++ b/ports/sysdeps/m88k/ffs.c
@@ -0,0 +1,45 @@
+/* ffs -- find first set bit in a word, counted from least significant end.
+ For Motorola 88000.
+ This file is part of the GNU C Library.
+ Copyright (C) 1991, 1992, 1997, 2004, 2005 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <bstring.h>
+
+#undef ffs
+
+#ifdef __GNUC__
+
+int
+__ffs (x)
+ int x;
+{
+ int cnt;
+
+ if (x == 0)
+ return 0;
+
+ asm ("ff1 %0,%1" : "=r" (cnt) : "r" (x & -x));
+ return cnt + 1;
+}
+weak_alias (__ffs, ffs)
+libc_hidden_builtin_def (ffs)
+
+#else
+#include <string/ffs.c>
+#endif
diff --git a/ports/sysdeps/m88k/m88100/add_n.S b/ports/sysdeps/m88k/m88100/add_n.S
new file mode 100644
index 000000000..2107eb55c
--- /dev/null
+++ b/ports/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/ports/sysdeps/m88k/m88100/add_n.s b/ports/sysdeps/m88k/m88100/add_n.s
new file mode 100644
index 000000000..0741ec91d
--- /dev/null
+++ b/ports/sysdeps/m88k/m88100/add_n.s
@@ -0,0 +1,103 @@
+; 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 Lesser General Public License as published by
+; the Free Software Foundation; either version 2.1 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 Lesser General Public
+; License for more details.
+
+; You should have received a copy of the GNU Lesser 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 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 about 4.6 clocks/limb + 18 clocks/limb-vector on an 88100,
+; but on the 88110, it seems to run much slower, 6.6 clocks/limb.
+
+ text
+ align 16
+ global ___mpn_add_n
+___mpn_add_n:
+ ld r6,r3,0 ; read first limb from s1_ptr
+ extu r10,r5,3
+ ld r7,r4,0 ; read first limb from s2_ptr
+
+ subu.co r5,r0,r5 ; (clear carry as side effect)
+ mak r5,r5,3<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,32
+ st r8,r2,28
+ addu r4,r4,32
+ ld r6,r3,0
+ addu r2,r2,32
+ ld r7,r4,0
+Lzero: subu r10,r10,1 ; add 0 + 8r limbs (adj loop cnt)
+Lbase: ld r8,r3,4
+ addu.cio r6,r6,r7
+ ld r9,r4,4
+ st r6,r2,0
+ ld r6,r3,8 ; add 7 + 8r limbs
+ addu.cio r8,r8,r9
+ ld r7,r4,8
+ st r8,r2,4
+ ld r8,r3,12 ; add 6 + 8r limbs
+ addu.cio r6,r6,r7
+ ld r9,r4,12
+ st r6,r2,8
+ ld r6,r3,16 ; add 5 + 8r limbs
+ addu.cio r8,r8,r9
+ ld r7,r4,16
+ st r8,r2,12
+ ld r8,r3,20 ; add 4 + 8r limbs
+ addu.cio r6,r6,r7
+ ld r9,r4,20
+ st r6,r2,16
+ ld r6,r3,24 ; add 3 + 8r limbs
+ addu.cio r8,r8,r9
+ ld r7,r4,24
+ st r8,r2,20
+ ld r8,r3,28 ; add 2 + 8r limbs
+ addu.cio r6,r6,r7
+ ld r9,r4,28
+ st r6,r2,24
+ bcnd.n ne0,r10,Loop ; add 1 + 8r limbs
+ addu.cio r8,r8,r9
+
+ st r8,r2,28 ; store most significant limb
+
+ jmp.n r1
+ addu.ci r2,r0,r0 ; return carry-out from most sign. limb
diff --git a/ports/sysdeps/m88k/m88100/mul_1.S b/ports/sysdeps/m88k/m88100/mul_1.S
new file mode 100644
index 000000000..503897b29
--- /dev/null
+++ b/ports/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/ports/sysdeps/m88k/m88100/mul_1.s b/ports/sysdeps/m88k/m88100/mul_1.s
new file mode 100644
index 000000000..77242778d
--- /dev/null
+++ b/ports/sysdeps/m88k/m88100/mul_1.s
@@ -0,0 +1,128 @@
+; 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 Lesser General Public License as published by
+; the Free Software Foundation; either version 2.1 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 Lesser General Public
+; License for more details.
+
+; You should have received a copy of the GNU Lesser 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 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.)
+
+ text
+ align 16
+ global ___mpn_mul_1
+___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/ports/sysdeps/m88k/m88100/sub_n.S b/ports/sysdeps/m88k/m88100/sub_n.S
new file mode 100644
index 000000000..927ece4f1
--- /dev/null
+++ b/ports/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/ports/sysdeps/m88k/m88100/sub_n.s b/ports/sysdeps/m88k/m88100/sub_n.s
new file mode 100644
index 000000000..a132c212a
--- /dev/null
+++ b/ports/sysdeps/m88k/m88100/sub_n.s
@@ -0,0 +1,104 @@
+; 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 Lesser General Public License as published by
+; the Free Software Foundation; either version 2.1 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 Lesser General Public
+; License for more details.
+
+; You should have received a copy of the GNU Lesser 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 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 about 4.6 clocks/limb + 18 clocks/limb-vector on an 88100,
+; but on the 88110, it seems to run much slower, 6.6 clocks/limb.
+
+ text
+ align 16
+ global ___mpn_sub_n
+___mpn_sub_n:
+ ld r6,r3,0 ; read first limb from s1_ptr
+ extu r10,r5,3
+ ld r7,r4,0 ; read first limb from s2_ptr
+
+ subu.co r5,r0,r5 ; (clear carry as side effect)
+ mak r5,r5,3<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,32
+ st r8,r2,28
+ addu r4,r4,32
+ ld r6,r3,0
+ addu r2,r2,32
+ ld r7,r4,0
+Lzero: subu r10,r10,1 ; subtract 0 + 8r limbs (adj loop cnt)
+Lbase: ld r8,r3,4
+ subu.cio r6,r6,r7
+ ld r9,r4,4
+ st r6,r2,0
+ ld r6,r3,8 ; subtract 7 + 8r limbs
+ subu.cio r8,r8,r9
+ ld r7,r4,8
+ st r8,r2,4
+ ld r8,r3,12 ; subtract 6 + 8r limbs
+ subu.cio r6,r6,r7
+ ld r9,r4,12
+ st r6,r2,8
+ ld r6,r3,16 ; subtract 5 + 8r limbs
+ subu.cio r8,r8,r9
+ ld r7,r4,16
+ st r8,r2,12
+ ld r8,r3,20 ; subtract 4 + 8r limbs
+ subu.cio r6,r6,r7
+ ld r9,r4,20
+ st r6,r2,16
+ ld r6,r3,24 ; subtract 3 + 8r limbs
+ subu.cio r8,r8,r9
+ ld r7,r4,24
+ st r8,r2,20
+ ld r8,r3,28 ; subtract 2 + 8r limbs
+ subu.cio r6,r6,r7
+ ld r9,r4,28
+ st r6,r2,24
+ bcnd.n ne0,r10,Loop ; subtract 1 + 8r limbs
+ subu.cio r8,r8,r9
+
+ st r8,r2,28 ; 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/ports/sysdeps/m88k/m88110/add_n.S b/ports/sysdeps/m88k/m88110/add_n.S
new file mode 100644
index 000000000..3c9067448
--- /dev/null
+++ b/ports/sysdeps/m88k/m88110/add_n.S
@@ -0,0 +1,200 @@
+; mc88110 __mpn_add_n -- Add two limb vectors of the same length > 0 and store
+; sum in a third limb vector.
+
+; Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+
+; This file is part of the GNU MP Library.
+
+; The GNU MP Library is free software; you can redistribute it and/or modify
+; it under the terms of the GNU Lesser General Public License as published by
+; the Free Software Foundation; either version 2.1 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 Lesser General Public
+; License for more details.
+
+; You should have received a copy of the GNU Lesser General Public License
+; along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+; MA 02111-1307, USA.
+
+
+; INPUT PARAMETERS
+#define res_ptr r2
+#define s1_ptr r3
+#define s2_ptr r4
+#define size r5
+
+#include "sysdep.h"
+
+ text
+ align 16
+ global C_SYMBOL_NAME(__mpn_add_n)
+C_SYMBOL_NAME(__mpn_add_n):
+ addu.co r0,r0,r0 ; clear cy flag
+ xor r12,s2_ptr,res_ptr
+ bb1 2,r12,L1
+; ** V1a **
+L0: bb0 2,res_ptr,L_v1 ; branch if res_ptr is aligned?
+/* Add least significant limb separately to align res_ptr and s2_ptr */
+ ld r10,s1_ptr,0
+ addu s1_ptr,s1_ptr,4
+ ld r8,s2_ptr,0
+ addu s2_ptr,s2_ptr,4
+ subu size,size,1
+ addu.co r6,r10,r8
+ st r6,res_ptr,0
+ addu res_ptr,res_ptr,4
+L_v1: cmp r12,size,2
+ bb1 lt,r12,Lend2
+
+ ld r10,s1_ptr,0
+ ld r12,s1_ptr,4
+ ld.d r8,s2_ptr,0
+ subu size,size,10
+ bcnd lt0,size,Lfin1
+/* Add blocks of 8 limbs until less than 8 limbs remain */
+ align 8
+Loop1: subu size,size,8
+ addu.cio r6,r10,r8
+ ld r10,s1_ptr,8
+ addu.cio r7,r12,r9
+ ld r12,s1_ptr,12
+ ld.d r8,s2_ptr,8
+ st.d r6,res_ptr,0
+ addu.cio r6,r10,r8
+ ld r10,s1_ptr,16
+ addu.cio r7,r12,r9
+ ld r12,s1_ptr,20
+ ld.d r8,s2_ptr,16
+ st.d r6,res_ptr,8
+ addu.cio r6,r10,r8
+ ld r10,s1_ptr,24
+ addu.cio r7,r12,r9
+ ld r12,s1_ptr,28
+ ld.d r8,s2_ptr,24
+ st.d r6,res_ptr,16
+ addu.cio r6,r10,r8
+ ld r10,s1_ptr,32
+ addu.cio r7,r12,r9
+ ld r12,s1_ptr,36
+ addu s1_ptr,s1_ptr,32
+ ld.d r8,s2_ptr,32
+ addu s2_ptr,s2_ptr,32
+ st.d r6,res_ptr,24
+ addu res_ptr,res_ptr,32
+ bcnd ge0,size,Loop1
+
+Lfin1: addu size,size,8-2
+ bcnd lt0,size,Lend1
+/* Add blocks of 2 limbs until less than 2 limbs remain */
+Loope1: addu.cio r6,r10,r8
+ ld r10,s1_ptr,8
+ addu.cio r7,r12,r9
+ ld r12,s1_ptr,12
+ ld.d r8,s2_ptr,8
+ st.d r6,res_ptr,0
+ subu size,size,2
+ addu s1_ptr,s1_ptr,8
+ addu s2_ptr,s2_ptr,8
+ addu res_ptr,res_ptr,8
+ bcnd ge0,size,Loope1
+Lend1: addu.cio r6,r10,r8
+ addu.cio r7,r12,r9
+ st.d r6,res_ptr,0
+
+ bb0 0,size,Lret1
+/* Add last limb */
+ ld r10,s1_ptr,8
+ ld r8,s2_ptr,8
+ addu.cio r6,r10,r8
+ st r6,res_ptr,8
+
+Lret1: jmp.n r1
+ addu.ci r2,r0,r0 ; return carry-out from most sign. limb
+
+L1: xor r12,s1_ptr,res_ptr
+ bb1 2,r12,L2
+; ** V1b **
+ or r12,r0,s2_ptr
+ or s2_ptr,r0,s1_ptr
+ or s1_ptr,r0,r12
+ br L0
+
+; ** V2 **
+/* If we come here, the alignment of s1_ptr and res_ptr as well as the
+ alignment of s2_ptr and res_ptr differ. Since there are only two ways
+ things can be aligned (that we care about) we now know that the alignment
+ of s1_ptr and s2_ptr are the same. */
+
+L2: cmp r12,size,1
+ bb1 eq,r12,Ljone
+ bb0 2,s1_ptr,L_v2 ; branch if s1_ptr is aligned
+/* Add least significant limb separately to align res_ptr and s2_ptr */
+ ld r10,s1_ptr,0
+ addu s1_ptr,s1_ptr,4
+ ld r8,s2_ptr,0
+ addu s2_ptr,s2_ptr,4
+ subu size,size,1
+ addu.co r6,r10,r8
+ st r6,res_ptr,0
+ addu res_ptr,res_ptr,4
+
+L_v2: subu size,size,8
+ bcnd lt0,size,Lfin2
+/* Add blocks of 8 limbs until less than 8 limbs remain */
+ align 8
+Loop2: subu size,size,8
+ ld.d r8,s1_ptr,0
+ ld.d r6,s2_ptr,0
+ addu.cio r8,r8,r6
+ st r8,res_ptr,0
+ addu.cio r9,r9,r7
+ st r9,res_ptr,4
+ ld.d r8,s1_ptr,8
+ ld.d r6,s2_ptr,8
+ addu.cio r8,r8,r6
+ st r8,res_ptr,8
+ addu.cio r9,r9,r7
+ st r9,res_ptr,12
+ ld.d r8,s1_ptr,16
+ ld.d r6,s2_ptr,16
+ addu.cio r8,r8,r6
+ st r8,res_ptr,16
+ addu.cio r9,r9,r7
+ st r9,res_ptr,20
+ ld.d r8,s1_ptr,24
+ ld.d r6,s2_ptr,24
+ addu.cio r8,r8,r6
+ st r8,res_ptr,24
+ addu.cio r9,r9,r7
+ st r9,res_ptr,28
+ addu s1_ptr,s1_ptr,32
+ addu s2_ptr,s2_ptr,32
+ addu res_ptr,res_ptr,32
+ bcnd ge0,size,Loop2
+
+Lfin2: addu size,size,8-2
+ bcnd lt0,size,Lend2
+Loope2: ld.d r8,s1_ptr,0
+ ld.d r6,s2_ptr,0
+ addu.cio r8,r8,r6
+ st r8,res_ptr,0
+ addu.cio r9,r9,r7
+ st r9,res_ptr,4
+ subu size,size,2
+ addu s1_ptr,s1_ptr,8
+ addu s2_ptr,s2_ptr,8
+ addu res_ptr,res_ptr,8
+ bcnd ge0,size,Loope2
+Lend2: bb0 0,size,Lret2
+/* Add last limb */
+Ljone: ld r10,s1_ptr,0
+ ld r8,s2_ptr,0
+ addu.cio r6,r10,r8
+ st r6,res_ptr,0
+
+Lret2: jmp.n r1
+ addu.ci r2,r0,r0 ; return carry-out from most sign. limb
diff --git a/ports/sysdeps/m88k/m88110/addmul_1.s b/ports/sysdeps/m88k/m88110/addmul_1.s
new file mode 100644
index 000000000..a9845efa3
--- /dev/null
+++ b/ports/sysdeps/m88k/m88110/addmul_1.s
@@ -0,0 +1,61 @@
+; mc88110 __mpn_addmul_1 -- Multiply a limb vector with a single limb and
+; store the product in a second limb vector.
+
+; Copyright (C) 1996 Free Software Foundation, Inc.
+
+; This file is part of the GNU MP Library.
+
+; The GNU MP Library is free software; you can redistribute it and/or modify
+; it under the terms of the GNU Lesser General Public License as published by
+; the Free Software Foundation; either version 2.1 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 Lesser General Public
+; License for more details.
+
+; You should have received a copy of the GNU Lesser General Public License
+; along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+; MA 02111-1307, USA.
+
+
+; INPUT PARAMETERS
+; res_ptr r2
+; s1_ptr r3
+; size r4
+; s2_limb r5
+
+ text
+ align 16
+ global ___mpn_addmul_1
+___mpn_addmul_1:
+ lda r3,r3[r4]
+ lda r8,r2[r4] ; RES_PTR in r8 since r2 is retval
+ subu r4,r0,r4
+ addu.co r2,r0,r0 ; r2 = cy = 0
+
+ ld r6,r3[r4]
+ addu r4,r4,1
+ subu r8,r8,4
+ bcnd.n eq0,r4,Lend
+ mulu.d r10,r6,r5
+
+Loop: ld r7,r8[r4]
+ ld r6,r3[r4]
+ addu.cio r9,r11,r2
+ addu.ci r2,r10,r0
+ addu.co r9,r9,r7
+ st r9,r8[r4]
+ addu r4,r4,1
+ mulu.d r10,r6,r5
+ bcnd ne0,r4,Loop
+
+Lend: ld r7,r8,0
+ addu.cio r9,r11,r2
+ addu.ci r2,r10,r0
+ addu.co r9,r9,r7
+ st r9,r8,0
+ jmp.n r1
+ addu.ci r2,r2,r0
diff --git a/ports/sysdeps/m88k/m88110/mul_1.S b/ports/sysdeps/m88k/m88110/mul_1.S
new file mode 100644
index 000000000..7a0762386
--- /dev/null
+++ b/ports/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/ports/sysdeps/m88k/m88110/mul_1.s b/ports/sysdeps/m88k/m88110/mul_1.s
new file mode 100644
index 000000000..103869dc4
--- /dev/null
+++ b/ports/sysdeps/m88k/m88110/mul_1.s
@@ -0,0 +1,59 @@
+; 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, 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 Lesser General Public License as published by
+; the Free Software Foundation; either version 2.1 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 Lesser General Public
+; License for more details.
+
+; You should have received a copy of the GNU Lesser General Public License
+; along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+; MA 02111-1307, USA.
+
+
+; INPUT PARAMETERS
+; res_ptr r2
+; s1_ptr r3
+; size r4
+; s2_limb r5
+
+ text
+ align 16
+ global ___mpn_mul_1
+___mpn_mul_1:
+ ; Make S1_PTR and RES_PTR point at the end of their blocks
+ ; and negate SIZE.
+ lda r3,r3[r4]
+ lda r8,r2[r4] ; RES_PTR in r8 since r2 is retval
+ subu r4,r0,r4
+
+ addu.co r2,r0,r0 ; r2 = cy = 0
+
+ ld r6,r3[r4]
+ addu r4,r4,1
+ mulu.d r10,r6,r5
+ bcnd.n eq0,r4,Lend
+ subu r8,r8,8
+
+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.n 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
diff --git a/ports/sysdeps/m88k/m88110/sub_n.S b/ports/sysdeps/m88k/m88110/sub_n.S
new file mode 100644
index 000000000..a937882db
--- /dev/null
+++ b/ports/sysdeps/m88k/m88110/sub_n.S
@@ -0,0 +1,276 @@
+; mc88110 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
+; store difference in a third limb vector.
+
+; Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+
+; This file is part of the GNU MP Library.
+
+; The GNU MP Library is free software; you can redistribute it and/or modify
+; it under the terms of the GNU Lesser General Public License as published by
+; the Free Software Foundation; either version 2.1 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 Lesser General Public
+; License for more details.
+
+; You should have received a copy of the GNU Lesser General Public License
+; along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+; MA 02111-1307, USA.
+
+
+; INPUT PARAMETERS
+#define res_ptr r2
+#define s1_ptr r3
+#define s2_ptr r4
+#define size r5
+
+#include "sysdep.h"
+
+ text
+ align 16
+ global C_SYMBOL_NAME(__mpn_sub_n)
+C_SYMBOL_NAME(__mpn_sub_n):
+ subu.co r0,r0,r0 ; set cy flag
+ xor r12,s2_ptr,res_ptr
+ bb1 2,r12,L1
+; ** V1a **
+L0: bb0 2,res_ptr,L_v1 ; branch if res_ptr is aligned
+/* Add least significant limb separately to align res_ptr and s2_ptr */
+ ld r10,s1_ptr,0
+ addu s1_ptr,s1_ptr,4
+ ld r8,s2_ptr,0
+ addu s2_ptr,s2_ptr,4
+ subu size,size,1
+ subu.co r6,r10,r8
+ st r6,res_ptr,0
+ addu res_ptr,res_ptr,4
+L_v1: cmp r12,size,2
+ bb1 lt,r12,Lend2
+
+ ld r10,s1_ptr,0
+ ld r12,s1_ptr,4
+ ld.d r8,s2_ptr,0
+ subu size,size,10
+ bcnd lt0,size,Lfin1
+/* Add blocks of 8 limbs until less than 8 limbs remain */
+ align 8
+Loop1: subu size,size,8
+ subu.cio r6,r10,r8
+ ld r10,s1_ptr,8
+ subu.cio r7,r12,r9
+ ld r12,s1_ptr,12
+ ld.d r8,s2_ptr,8
+ st.d r6,res_ptr,0
+ subu.cio r6,r10,r8
+ ld r10,s1_ptr,16
+ subu.cio r7,r12,r9
+ ld r12,s1_ptr,20
+ ld.d r8,s2_ptr,16
+ st.d r6,res_ptr,8
+ subu.cio r6,r10,r8
+ ld r10,s1_ptr,24
+ subu.cio r7,r12,r9
+ ld r12,s1_ptr,28
+ ld.d r8,s2_ptr,24
+ st.d r6,res_ptr,16
+ subu.cio r6,r10,r8
+ ld r10,s1_ptr,32
+ subu.cio r7,r12,r9
+ ld r12,s1_ptr,36
+ addu s1_ptr,s1_ptr,32
+ ld.d r8,s2_ptr,32
+ addu s2_ptr,s2_ptr,32
+ st.d r6,res_ptr,24
+ addu res_ptr,res_ptr,32
+ bcnd ge0,size,Loop1
+
+Lfin1: addu size,size,8-2
+ bcnd lt0,size,Lend1
+/* Add blocks of 2 limbs until less than 2 limbs remain */
+Loope1: subu.cio r6,r10,r8
+ ld r10,s1_ptr,8
+ subu.cio r7,r12,r9
+ ld r12,s1_ptr,12
+ ld.d r8,s2_ptr,8
+ st.d r6,res_ptr,0
+ subu size,size,2
+ addu s1_ptr,s1_ptr,8
+ addu s2_ptr,s2_ptr,8
+ addu res_ptr,res_ptr,8
+ bcnd ge0,size,Loope1
+Lend1: subu.cio r6,r10,r8
+ subu.cio r7,r12,r9
+ st.d r6,res_ptr,0
+
+ bb0 0,size,Lret1
+/* Add last limb */
+ ld r10,s1_ptr,8
+ ld r8,s2_ptr,8
+ subu.cio r6,r10,r8
+ st r6,res_ptr,8
+
+Lret1: addu.ci r2,r0,r0 ; return carry-out from most sign. limb
+ jmp.n r1
+ xor r2,r2,1
+
+L1: xor r12,s1_ptr,res_ptr
+ bb1 2,r12,L2
+; ** V1b **
+ bb0 2,res_ptr,L_v1b ; branch if res_ptr is aligned
+/* Add least significant limb separately to align res_ptr and s1_ptr */
+ ld r10,s2_ptr,0
+ addu s2_ptr,s2_ptr,4
+ ld r8,s1_ptr,0
+ addu s1_ptr,s1_ptr,4
+ subu size,size,1
+ subu.co r6,r8,r10
+ st r6,res_ptr,0
+ addu res_ptr,res_ptr,4
+L_v1b: cmp r12,size,2
+ bb1 lt,r12,Lend2
+
+ ld r10,s2_ptr,0
+ ld r12,s2_ptr,4
+ ld.d r8,s1_ptr,0
+ subu size,size,10
+ bcnd lt0,size,Lfin1b
+/* Add blocks of 8 limbs until less than 8 limbs remain */
+ align 8
+Loop1b: subu size,size,8
+ subu.cio r6,r8,r10
+ ld r10,s2_ptr,8
+ subu.cio r7,r9,r12
+ ld r12,s2_ptr,12
+ ld.d r8,s1_ptr,8
+ st.d r6,res_ptr,0
+ subu.cio r6,r8,r10
+ ld r10,s2_ptr,16
+ subu.cio r7,r9,r12
+ ld r12,s2_ptr,20
+ ld.d r8,s1_ptr,16
+ st.d r6,res_ptr,8
+ subu.cio r6,r8,r10
+ ld r10,s2_ptr,24
+ subu.cio r7,r9,r12
+ ld r12,s2_ptr,28
+ ld.d r8,s1_ptr,24
+ st.d r6,res_ptr,16
+ subu.cio r6,r8,r10
+ ld r10,s2_ptr,32
+ subu.cio r7,r9,r12
+ ld r12,s2_ptr,36
+ addu s2_ptr,s2_ptr,32
+ ld.d r8,s1_ptr,32
+ addu s1_ptr,s1_ptr,32
+ st.d r6,res_ptr,24
+ addu res_ptr,res_ptr,32
+ bcnd ge0,size,Loop1b
+
+Lfin1b: addu size,size,8-2
+ bcnd lt0,size,Lend1b
+/* Add blocks of 2 limbs until less than 2 limbs remain */
+Loope1b:subu.cio r6,r8,r10
+ ld r10,s2_ptr,8
+ subu.cio r7,r9,r12
+ ld r12,s2_ptr,12
+ ld.d r8,s1_ptr,8
+ st.d r6,res_ptr,0
+ subu size,size,2
+ addu s1_ptr,s1_ptr,8
+ addu s2_ptr,s2_ptr,8
+ addu res_ptr,res_ptr,8
+ bcnd ge0,size,Loope1b
+Lend1b: subu.cio r6,r8,r10
+ subu.cio r7,r9,r12
+ st.d r6,res_ptr,0
+
+ bb0 0,size,Lret1b
+/* Add last limb */
+ ld r10,s2_ptr,8
+ ld r8,s1_ptr,8
+ subu.cio r6,r8,r10
+ st r6,res_ptr,8
+
+Lret1b: addu.ci r2,r0,r0 ; return carry-out from most sign. limb
+ jmp.n r1
+ xor r2,r2,1
+
+; ** V2 **
+/* If we come here, the alignment of s1_ptr and res_ptr as well as the
+ alignment of s2_ptr and res_ptr differ. Since there are only two ways
+ things can be aligned (that we care about) we now know that the alignment
+ of s1_ptr and s2_ptr are the same. */
+
+L2: cmp r12,size,1
+ bb1 eq,r12,Ljone
+ bb0 2,s1_ptr,L_v2 ; branch if s1_ptr is aligned
+/* Add least significant limb separately to align res_ptr and s2_ptr */
+ ld r10,s1_ptr,0
+ addu s1_ptr,s1_ptr,4
+ ld r8,s2_ptr,0
+ addu s2_ptr,s2_ptr,4
+ subu size,size,1
+ subu.co r6,r10,r8
+ st r6,res_ptr,0
+ addu res_ptr,res_ptr,4
+
+L_v2: subu size,size,8
+ bcnd lt0,size,Lfin2
+/* Add blocks of 8 limbs until less than 8 limbs remain */
+ align 8
+Loop2: subu size,size,8
+ ld.d r8,s1_ptr,0
+ ld.d r6,s2_ptr,0
+ subu.cio r8,r8,r6
+ st r8,res_ptr,0
+ subu.cio r9,r9,r7
+ st r9,res_ptr,4
+ ld.d r8,s1_ptr,8
+ ld.d r6,s2_ptr,8
+ subu.cio r8,r8,r6
+ st r8,res_ptr,8
+ subu.cio r9,r9,r7
+ st r9,res_ptr,12
+ ld.d r8,s1_ptr,16
+ ld.d r6,s2_ptr,16
+ subu.cio r8,r8,r6
+ st r8,res_ptr,16
+ subu.cio r9,r9,r7
+ st r9,res_ptr,20
+ ld.d r8,s1_ptr,24
+ ld.d r6,s2_ptr,24
+ subu.cio r8,r8,r6
+ st r8,res_ptr,24
+ subu.cio r9,r9,r7
+ st r9,res_ptr,28
+ addu s1_ptr,s1_ptr,32
+ addu s2_ptr,s2_ptr,32
+ addu res_ptr,res_ptr,32
+ bcnd ge0,size,Loop2
+
+Lfin2: addu size,size,8-2
+ bcnd lt0,size,Lend2
+Loope2: ld.d r8,s1_ptr,0
+ ld.d r6,s2_ptr,0
+ subu.cio r8,r8,r6
+ st r8,res_ptr,0
+ subu.cio r9,r9,r7
+ st r9,res_ptr,4
+ subu size,size,2
+ addu s1_ptr,s1_ptr,8
+ addu s2_ptr,s2_ptr,8
+ addu res_ptr,res_ptr,8
+ bcnd ge0,size,Loope2
+Lend2: bb0 0,size,Lret2
+/* Add last limb */
+Ljone: ld r10,s1_ptr,0
+ ld r8,s2_ptr,0
+ subu.cio r6,r10,r8
+ st r6,res_ptr,0
+
+Lret2: addu.ci r2,r0,r0 ; return carry-out from most sign. limb
+ jmp.n r1
+ xor r2,r2,1
diff --git a/ports/sysdeps/m88k/mul_1.s b/ports/sysdeps/m88k/mul_1.s
new file mode 100644
index 000000000..7aa6d6406
--- /dev/null
+++ b/ports/sysdeps/m88k/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, 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 Lesser General Public License as published by
+; the Free Software Foundation; either version 2.1 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 Lesser General Public
+; License for more details.
+
+; You should have received a copy of the GNU Lesser General Public License
+; along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+; MA 02111-1307, USA.
+
+
+; INPUT PARAMETERS
+; res_ptr 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.)
+
+ text
+ align 16
+ global ___mpn_mul_1
+___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/ports/sysdeps/m88k/sub_n.s b/ports/sysdeps/m88k/sub_n.s
new file mode 100644
index 000000000..7616dc46b
--- /dev/null
+++ b/ports/sysdeps/m88k/sub_n.s
@@ -0,0 +1,106 @@
+; mc88100 __mpn_sub -- Subtract two limb vectors of the same length > 0 and
+; store difference in a third limb vector.
+
+; Copyright (C) 1992, 1994, 1996 Free Software Foundation, Inc.
+
+; This file is part of the GNU MP Library.
+
+; The GNU MP Library is free software; you can redistribute it and/or modify
+; it under the terms of the GNU Lesser General Public License as published by
+; the Free Software Foundation; either version 2.1 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 Lesser General Public
+; License for more details.
+
+; You should have received a copy of the GNU Lesser General Public License
+; along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+; MA 02111-1307, USA.
+
+
+; INPUT PARAMETERS
+; res_ptr 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 about 4.6 clocks/limb + 18 clocks/limb-vector on an 88100,
+; but on the 88110, it seems to run much slower, 6.6 clocks/limb.
+
+ text
+ align 16
+ global ___mpn_sub_n
+___mpn_sub_n:
+ ld r6,r3,0 ; read first limb from s1_ptr
+ extu r10,r5,3
+ ld r7,r4,0 ; read first limb from s2_ptr
+
+ subu r5,r0,r5
+ mak r5,r5,3<4>
+ bcnd.n eq0,r5,Lzero
+ subu.co r0,r0,r0 ; initialize carry
+
+ 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,32
+ st r8,r2,28
+ addu r4,r4,32
+ ld r6,r3,0
+ addu r2,r2,32
+ ld r7,r4,0
+Lzero: subu r10,r10,1 ; subtract 0 + 8r limbs (adj loop cnt)
+Lbase: ld r8,r3,4
+ subu.cio r6,r6,r7
+ ld r9,r4,4
+ st r6,r2,0
+ ld r6,r3,8 ; subtract 7 + 8r limbs
+ subu.cio r8,r8,r9
+ ld r7,r4,8
+ st r8,r2,4
+ ld r8,r3,12 ; subtract 6 + 8r limbs
+ subu.cio r6,r6,r7
+ ld r9,r4,12
+ st r6,r2,8
+ ld r6,r3,16 ; subtract 5 + 8r limbs
+ subu.cio r8,r8,r9
+ ld r7,r4,16
+ st r8,r2,12
+ ld r8,r3,20 ; subtract 4 + 8r limbs
+ subu.cio r6,r6,r7
+ ld r9,r4,20
+ st r6,r2,16
+ ld r6,r3,24 ; subtract 3 + 8r limbs
+ subu.cio r8,r8,r9
+ ld r7,r4,24
+ st r8,r2,20
+ ld r8,r3,28 ; subtract 2 + 8r limbs
+ subu.cio r6,r6,r7
+ ld r9,r4,28
+ st r6,r2,24
+ bcnd.n ne0,r10,Loop ; subtract 1 + 8r limbs
+ subu.cio r8,r8,r9
+
+ st r8,r2,28 ; 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/ports/sysdeps/mach/hppa/machine-lock.h b/ports/sysdeps/mach/hppa/machine-lock.h
new file mode 100644
index 000000000..8c71d40a5
--- /dev/null
+++ b/ports/sysdeps/mach/hppa/machine-lock.h
@@ -0,0 +1,63 @@
+/* Machine-specific definition for spin locks. HPPA version.
+ Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MACHINE_LOCK_H
+#define _MACHINE_LOCK_H
+
+/* 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/ports/sysdeps/mach/hurd/hppa/bits/sigcontext.h b/ports/sysdeps/mach/hurd/hppa/bits/sigcontext.h
new file mode 100644
index 000000000..5db43fc22
--- /dev/null
+++ b/ports/sysdeps/mach/hurd/hppa/bits/sigcontext.h
@@ -0,0 +1,94 @@
+/* Machine-dependent signal context structure for GNU Hurd. HPPA version.
+ Copyright (C) 1995,97,2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
+# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
+#endif
+
+#ifndef sc_parisc_thread_state
+
+/* 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];
+ };
+
+#endif /* sc_parisc_thread_state */
diff --git a/ports/sysdeps/mach/hurd/hppa/trampoline.c b/ports/sysdeps/mach/hurd/hppa/trampoline.c
new file mode 100644
index 000000000..fc811c5e7
--- /dev/null
+++ b/ports/sysdeps/mach/hurd/hppa/trampoline.c
@@ -0,0 +1,230 @@
+/* Set thread_state for sighandler, and sigcontext to recover. HPPA version.
+ Copyright (C) 1995, 1997, 1998, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 & (SS_DISABLE|SS_ONSTACK)))
+ {
+ sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size;
+ ss->sigaltstack.ss_flags |= SS_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 & SS_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;
+
+ /* Limit the time to receive the reply message, in case the server
+ claimed that `interrupt_operation' succeeded but in fact the RPC
+ is hung. */
+ args->option |= MACH_RCV_TIMEOUT;
+ args->timeout = _hurd_interrupted_rpc_timeout;
+
+ _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;
+}
diff --git a/ports/sysdeps/mach/hurd/mips/bits/sigcontext.h b/ports/sysdeps/mach/hurd/mips/bits/sigcontext.h
new file mode 100644
index 000000000..14c618857
--- /dev/null
+++ b/ports/sysdeps/mach/hurd/mips/bits/sigcontext.h
@@ -0,0 +1,80 @@
+/* Machine-dependent signal context structure for GNU Hurd. MIPS version.
+ Copyright (C) 1994,97,2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
+# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
+#endif
+
+#ifndef sc_mips_thread_state
+
+/* 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. */
+ };
+
+#endif /* sc_mips_thread_state */
diff --git a/ports/sysdeps/mach/hurd/mips/dl-machine.c b/ports/sysdeps/mach/hurd/mips/dl-machine.c
new file mode 100644
index 000000000..ce2d5db51
--- /dev/null
+++ b/ports/sysdeps/mach/hurd/mips/dl-machine.c
@@ -0,0 +1,132 @@
+/* Operating system support for run-time dynamic linker. MIPS specific
+ stuffs on Hurd.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <hurd.h>
+#include <link.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <assert.h>
+#include <sysdep.h>
+#include <mach/mig_support.h>
+#include "../stdio-common/_itoa.h"
+#include <stdarg.h>
+#include <ctype.h>
+#include <sys/stat.h>
+#include <libintl.h>
+
+void weak_function
+abort (void)
+{
+ _exit (127);
+}
+
+
+#include <string.h>
+#include <mach/error.h>
+#include <errorlib.h>
+
+#undef _
+#define _(x) x
+
+/* Return a string describing the errno code in ERRNUM. */
+char * weak_function
+_strerror_internal (int errnum, char *buf, size_t buflen)
+{
+ int system;
+ int sub;
+ int code;
+ const struct error_system *es;
+ extern void __mach_error_map_compat (int *);
+
+ __mach_error_map_compat (&errnum);
+
+ system = err_get_system (errnum);
+ sub = err_get_sub (errnum);
+ code = err_get_code (errnum);
+
+ if (system > err_max_system || ! __mach_error_systems[system].bad_sub)
+ {
+ const char *unk = _("Error in unknown error system: ");
+ const size_t unklen = strlen (unk);
+ char *p = buf + buflen;
+ *--p = '\0';
+ p = _itoa (errnum, p, 16, 1);
+ return memcpy (p - unklen, unk, unklen);
+ }
+
+ es = &__mach_error_systems[system];
+
+ if (sub >= es->max_sub)
+ return (char *) es->bad_sub;
+
+ if (code >= es->subsystem[sub].max_code)
+ {
+ const char *unk = _("Unknown error ");
+ const size_t unklen = strlen (unk);
+ char *p = buf + buflen;
+ size_t len = strlen (es->subsystem[sub].subsys_name);
+ *--p = '\0';
+ p = _itoa (errnum, p, 16, 1);
+ *p-- = ' ';
+ p = memcpy (p - len, es->subsystem[sub].subsys_name, len);
+ return memcpy (p - unklen, unk, unklen);
+ }
+
+ return (char *) _(es->subsystem[sub].codes[code]);
+}
+
+/* Read the whole contents of FILE into new mmap'd space with given
+ protections. The size of the file is returned in SIZE. */
+void *
+_dl_sysdep_read_whole_file (const char *file, size_t *size, int prot)
+{
+ struct stat stat;
+ mach_port_t memobj_rd;
+ void *contents;
+ error_t err;
+
+ memobj_rd = __open (file, O_RDONLY, 0);
+ if (memobj_rd)
+ {
+ err = __io_stat ((file_t) memobj_rd, &stat);
+ if (err)
+ {
+ __hurd_fail (err);
+ contents = 0;
+ }
+ else
+ {
+ /* Map a copy of the file contents. */
+ contents = __mmap (0, stat.st_size, prot, MAP_COPY, memobj_rd, 0);
+ if (contents == (void *)-1)
+ contents = 0;
+ else
+ *size = stat.st_size;
+ }
+
+ __mach_port_deallocate (__mach_task_self (), memobj_rd);
+ }
+ else
+ contents = 0;
+
+ return contents;
+}
diff --git a/ports/sysdeps/mach/hurd/mips/exc2signal.c b/ports/sysdeps/mach/hurd/mips/exc2signal.c
new file mode 100644
index 000000000..c505ae5b2
--- /dev/null
+++ b/ports/sysdeps/mach/hurd/mips/exc2signal.c
@@ -0,0 +1,97 @@
+/* Translate Mach exception codes into signal numbers. MIPS version.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <hurd.h>
+#include <hurd/signal.h>
+#include <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 (struct hurd_signal_detail *detail, int *signo)
+{
+ detail->error = 0;
+
+ switch (detail->exc)
+ {
+ default:
+ *signo = SIGIOT;
+ detail->code = detail->exc;
+ break;
+
+ case EXC_BAD_ACCESS:
+ if (detail->exc_code == KERN_PROTECTION_FAILURE)
+ *signo = SIGSEGV;
+ else
+ *signo = SIGBUS;
+ detail->code = detail->exc_subcode;
+ detail->error = detail->exc_code;
+ break;
+
+ case EXC_BAD_INSTRUCTION:
+ *signo = SIGILL;
+ if (detail->exc_code == EXC_MIPS_II)
+ detail->code = detail->exc_subcode;
+ else
+ detail->code = 0;
+ break;
+
+ case EXC_ARITHMETIC:
+ switch (detail->exc_code)
+ {
+ case EXC_MIPS_OV: /* integer overflow */
+ *signo = SIGFPE;
+ detail->code = detail->exc_subcode;
+ break;
+
+ default:
+ *signo = SIGFPE;
+ detail->code = 0;
+ break;
+
+ case EXC_MIPS_INT:
+ /* Subcode is the fp_status word saved by the hardware.
+ Give an error code corresponding to the first bit set. */
+ if (detail->exc_subcode == EXC_MIPS_FLT_UNIMP)
+ *signo = SIGILL;
+ else
+ *signo = SIGFPE;
+ detail->code = detail->exc_subcode;
+ break;
+ }
+ break;
+
+ case EXC_EMULATION:
+ /* 3.0 doesn't give this one, why, I don't know. */
+ *signo = SIGEMT;
+ detail->code = 0;
+ break;
+
+ case EXC_SOFTWARE:
+ *signo = SIGEMT;
+ detail->code = 0;
+ break;
+
+ case EXC_BREAKPOINT:
+ *signo = SIGTRAP;
+ detail->code = 0;
+ break;
+ }
+}
diff --git a/ports/sysdeps/mach/hurd/mips/init-fault.c b/ports/sysdeps/mach/hurd/mips/init-fault.c
new file mode 100644
index 000000000..05f48a3a5
--- /dev/null
+++ b/ports/sysdeps/mach/hurd/mips/init-fault.c
@@ -0,0 +1,41 @@
+/* Set up a thread_state for proc_handle_exceptions. MIPS version.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <hurd/signal.h>
+#include <mach/thread_status.h>
+#include <string.h>
+#include <setjmp.h>
+
+extern jmp_buf _hurd_sigthread_fault_env;
+
+static char fault_stack[32];
+static volatile void
+faulted (void)
+{
+ __longjmp (_hurd_sigthread_fault_env, 1);
+}
+
+void
+_hurd_initialize_fault_recovery_state (void *state)
+{
+ struct mips_thread_state *ts = state;
+ memset (ts, 0, sizeof (*ts));
+ ts->r29 = (int) &fault_stack[sizeof (fault_stack)];
+ ts->pc = (int) &faulted;
+}
diff --git a/ports/sysdeps/mach/hurd/mips/init-first.c b/ports/sysdeps/mach/hurd/mips/init-first.c
new file mode 100644
index 000000000..6f53e839b
--- /dev/null
+++ b/ports/sysdeps/mach/hurd/mips/init-first.c
@@ -0,0 +1,414 @@
+/* Initialization code run first thing by the ELF startup code. For Mips/Hurd.
+ Copyright (C) 1996,1997,1998,2000,01,02,03 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <hurd.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include "hurdstartup.h"
+#include "set-hooks.h"
+#include "hurdmalloc.h" /* XXX */
+
+extern void __mach_init (void);
+extern void __init_misc (int, char **, char **);
+#ifdef USE_NONOPTION_FLAGS
+extern void __getopt_clean_environment (char **);
+#endif
+#ifndef SHARED
+extern void _dl_non_dynamic_init (void) internal_function;
+#endif
+extern void __libc_global_ctors (void);
+
+unsigned int __hurd_threadvar_max;
+unsigned long int __hurd_threadvar_stack_offset;
+unsigned long int __hurd_threadvar_stack_mask;
+
+int __libc_multiple_libcs attribute_hidden = 1;
+
+int __libc_argc attribute_hidden;
+char **__libc_argv attribute_hidden;
+
+void *(*_cthread_init_routine) (void); /* Returns new SP to use. */
+void (*_cthread_exit_routine) (int status) __attribute__ ((__noreturn__));
+
+
+/* Things that want to be run before _hurd_init or much anything else.
+ Importantly, these are called before anything tries to use malloc. */
+DEFINE_HOOK (_hurd_preinit_hook, (void));
+
+static void
+init1 (int argc, char *arg0, ...)
+{
+ char **argv = &arg0;
+ char **envp = &argv[argc + 1];
+ struct hurd_startup_data *d;
+
+ __libc_argc = argc;
+ __libc_argv = argv;
+ __environ = envp;
+ while (*envp)
+ ++envp;
+ d = (void *) ++envp;
+
+ /* If we are the bootstrap task started by the kernel,
+ then after the environment pointers there is no Hurd
+ data block; the argument strings start there. */
+ if ((void *) d != argv[0])
+ {
+ _hurd_init_dtable = d->dtable;
+ _hurd_init_dtablesize = d->dtablesize;
+
+ {
+ /* Check if the stack we are now on is different from
+ the one described by _hurd_stack_{base,size}. */
+
+ char dummy;
+ const vm_address_t newsp = (vm_address_t) &dummy;
+
+ if (d->stack_size != 0 && (newsp < d->stack_base ||
+ newsp - d->stack_base > d->stack_size))
+ /* The new stack pointer does not intersect with the
+ stack the exec server set up for us, so free that stack. */
+ __vm_deallocate (__mach_task_self (), d->stack_base, d->stack_size);
+ }
+ }
+
+ if (__hurd_threadvar_stack_mask == 0)
+ {
+ /* We are not using cthreads, so we will have just a single allocated
+ area for the per-thread variables of the main user thread. */
+ unsigned long int i;
+ __hurd_threadvar_stack_offset
+ = (unsigned long int) malloc (__hurd_threadvar_max *
+ sizeof (unsigned long int));
+ if (__hurd_threadvar_stack_offset == 0)
+ __libc_fatal ("Can't allocate single-threaded per-thread variables.");
+ for (i = 0; i < __hurd_threadvar_max; ++i)
+ ((unsigned long int *) __hurd_threadvar_stack_offset)[i] = 0;
+ }
+
+ if ((void *) d != argv[0] && (d->portarray || d->intarray))
+ /* Initialize library data structures, start signal processing, etc. */
+ _hurd_init (d->flags, argv,
+ d->portarray, d->portarraysize,
+ d->intarray, d->intarraysize);
+
+#ifndef SHARED
+ _dl_non_dynamic_init ();
+#endif
+ __init_misc (argc, argv, __environ);
+
+#ifdef USE_NONOPTION_FLAGS
+ /* This is a hack to make the special getopt in GNU libc working. */
+ __getopt_clean_environment (envp);
+#endif
+
+#ifdef SHARED
+ __libc_global_ctors ();
+#endif
+
+ (void) &init1;
+}
+
+static void *
+__init (int *data)
+{
+ int argc = *data;
+ char **argv = (void *) (data + 1);
+ char **envp = &argv[argc + 1];
+ struct hurd_startup_data *d;
+
+ __environ = envp;
+ while (*envp)
+ ++envp;
+ d = (void *) ++envp;
+
+ /* The user might have defined a value for this, to get more variables.
+ Otherwise it will be zero on startup. We must make sure it is set
+ properly before before cthreads initialization, so cthreads can know
+ how much space to leave for thread variables. */
+ if (__hurd_threadvar_max < _HURD_THREADVAR_MAX)
+ __hurd_threadvar_max = _HURD_THREADVAR_MAX;
+
+
+ /* After possibly switching stacks, call `init1' (above) with the user
+ code as the return address, and the argument data immediately above
+ that on the stack. */
+
+ if (_cthread_init_routine)
+ {
+ /* Initialize cthreads, which will allocate us a new stack to run on. */
+ void *newsp = (*_cthread_init_routine) ();
+ struct hurd_startup_data *od;
+
+ /* Copy the argdata from the old stack to the new one. */
+ newsp = memcpy (newsp - ((char *) &d[1] - (char *) data), data,
+ (char *) d - (char *) data);
+
+ /* Set up the Hurd startup data block immediately following
+ the argument and environment pointers on the new stack. */
+ od = (newsp + ((char *) d - (char *) data));
+ if ((void *) argv[0] == d)
+ /* We were started up by the kernel with arguments on the stack.
+ There is no Hurd startup data, so zero the block. */
+ memset (od, 0, sizeof *od);
+ else
+ /* Copy the Hurd startup data block to the new stack. */
+ *od = *d;
+
+ /* Push the user code address on the top of the new stack. It will
+ be the return address for `init1'; we will jump there with NEWSP
+ as the stack pointer. */
+ return newsp;
+ }
+
+ /* The argument data is just above the stack frame we will unwind by
+ returning. */
+ return (void *) data;
+
+ (void) &__init;
+}
+
+#ifdef SHARED
+/* This function is called to initialize the shared C library.
+ It is called just before the user _start code from mips/elf/start.S,
+ with the stack set up as that code gets it. */
+
+/* NOTE! The linker notices the magical name `_init' and sets the DT_INIT
+ pointer in the dynamic section based solely on that. It is convention
+ for this function to be in the `.init' section, but the symbol name is
+ the only thing that really matters!! */
+/*void _init (int argc, ...) __attribute__ ((unused, section (".init")));*/
+
+#if __mips64
+asm ("\
+ .section .init,\"ax\",@progbits\n\
+ .align 3\n\
+ .globl _init\n\
+ .type _init,@function\n\
+ .ent _init\n\
+_init:\n\
+ .set noreorder\n\
+ .cpload $25\n\
+ .set reorder\n\
+ dsubu $29, 8*8\n\
+ .cprestore 6*8\n\
+ sd $16, 4*8($29)\n\
+ sd $31, 5*8($29)\n\
+ jal preinit\n\
+ sd $28, 6*8($29)\n\
+ move $16, $29 # Save the old stack pointer to s0 ($16)\n\
+ daddu $4, $29, 4*8\n\
+ jal __init\n\
+ # Restore saved registers from the old stack.\n\
+ ld $28, 6*8($16)\n\
+ ld $31, 5*8($16)\n\
+ ld $16, 4*8($16)\n\
+ move $29, $2 # set new sp to SP\n\
+call_init1:\n\
+ ld $4, 0($29)\n\
+ ld $5, 1*8($29)\n\
+ ld $6, 2*8($29)\n\
+ ld $7, 3*8($29)\n\
+ dla $25, init1\n\
+ jr $25\n\
+ .end _init\n\
+ .text\n\
+");
+#else
+asm ("\
+ .section .init,\"ax\",@progbits\n\
+ .align 2\n\
+ .globl _init\n\
+ .type _init,@function\n\
+ .ent _init\n\
+_init:\n\
+ .set noreorder\n\
+ .cpload $25\n\
+ .set reorder\n\
+ subu $29, 32\n\
+ .cprestore 24\n\
+ sw $16, 16($29)\n\
+ sw $31, 20($29)\n\
+ jal preinit\n\
+ sw $28, 24($29)\n\
+ move $16, $29 # Save the old stack pointer to s0 ($16)\n\
+ addu $4, $29, 32\n\
+ jal __init\n\
+ # Restore saved registers from the old stack.\n\
+ lw $28, 24($16)\n\
+ lw $31, 20($16)\n\
+ lw $16, 16($16)\n\
+ move $29, $2 # set new sp to SP\n\
+call_init1:\n\
+ lw $4, 0($29)\n\
+ lw $5, 4($29)\n\
+ lw $6, 8($29)\n\
+ lw $7, 12($29)\n\
+ la $25, init1\n\
+ jr $25\n\
+ .end _init\n\
+ .text\n\
+");
+#endif
+
+static void
+preinit (void)
+{
+ /* Initialize data structures so we can do RPCs. */
+ __mach_init ();
+
+ RUN_HOOK (_hurd_preinit_hook, ());
+
+ (void) &preinit;
+}
+
+void __libc_init_first (int argc, ...)
+{
+}
+#endif
+
+#ifndef SHARED
+/* An assembler code wrapping c function __init. */
+#ifdef __mips64
+asm ("\
+ .text\n\
+ .align 3\n\
+init:\n\
+ dsubu $29, 8*8\n\
+ sd $16, 4*8($29)\n\
+ sd $31, 5*8($29)\n\
+ move $16, $29\n\
+ jal __init\n\
+ ld $31, 5*8($16)\n\
+ ld $16, 4*8($16)\n\
+ move $29, $2 # set new sp to SP\n\
+call_init1:\n\
+ ld $4, 0($29)\n\
+ ld $5, 1*8($29)\n\
+ ld $6, 2*8($29)\n\
+ ld $7, 3*8($29)\n\
+ dla $25, init1\n\
+ jr $25\n\
+");
+#else
+asm ("\
+ .text\n\
+ .align 2\n\
+init:\n\
+ subu $29, 32\n\
+ sw $16, 16($29)\n\
+ sw $31, 20($29)\n\
+ move $16, $29\n\
+ jal __init\n\
+ lw $31, 20($16)\n\
+ lw $16, 16($16)\n\
+ move $29, $2 # set new sp to SP\n\
+call_init1:\n\
+ lw $4, 0($29)\n\
+ lw $5, 4($29)\n\
+ lw $6, 8($29)\n\
+ lw $7, 12($29)\n\
+ la $25, init1\n\
+ jr $25\n\
+");
+#endif
+
+/* An assembler code wrapping c function ___libc_init_first.
+ ___libc_init_first does an RPC call to flush cache to put doinit
+ function on the stack, so we should call __mach_init first in
+ this wrap. */
+#ifdef __mips64
+asm ("\
+ .text\n\
+ .align 3\n\
+ .globl __libc_init_first\n\
+__libc_init_first:\n\
+ dsubu $29, 8\n\
+ sd $31, 0($29)\n\
+ jal __mach_init\n\
+ ld $4, 0($29)\n\
+ ld $5, 1*8($29)\n\
+ ld $6, 2*8($29)\n\
+ ld $7, 3*8($29)\n\
+ j ___libc_init_first\n\
+");
+#else
+asm ("\
+ .text\n\
+ .align 2\n\
+ .globl __libc_init_first\n\
+__libc_init_first:\n\
+ subu $29, 4\n\
+ sw $31, 0($29)\n\
+ jal __mach_init\n\
+ lw $4, 0($29)\n\
+ lw $5, 4($29)\n\
+ lw $6, 8($29)\n\
+ lw $7, 12($29)\n\
+ j ___libc_init_first\n\
+");
+#endif
+
+static void
+___libc_init_first (int return_addr, int argc, ...)
+{
+ void doinit (int *data)
+ {
+#if 0
+ /* This function gets called with the argument data at TOS. */
+ void doinit1 (int argc, ...)
+ {
+ init (&argc);
+ }
+#endif
+ extern void init (int *data);
+
+ /* Push the user return address after the argument data, and then
+ jump to `doinit1' (above), so it is as if __libc_init_first's
+ caller had called `init' with the argument data already on the
+ stack. */
+ *--data = return_addr;
+
+#ifdef __mips64
+ asm volatile ("ld $31, 0(%0)\n" /* Load the original return address. */
+ "daddu $29, %0, 8\n" /* Switch to new outermost stack. */
+ "move $4, $29\n"
+ "jr %1" : : "r" (data), "r" (&init));
+#else
+ asm volatile ("lw $31, 0(%0)\n" /* Load the original return address. */
+ "addu $29, %0, 4\n" /* Switch to new outermost stack. */
+ "move $4, $29\n"
+ "jr %1" : : "r" (data), "r" (&init));
+#endif
+ /* NOTREACHED */
+ }
+
+#if 0
+ /* Initialize data structures so we can do RPCs. */
+ __mach_init ();
+#endif
+
+ RUN_HOOK (_hurd_preinit_hook, ());
+
+ _hurd_startup ((void **) &argc, &doinit);
+
+ (void) &___libc_init_first;
+}
+#endif
diff --git a/ports/sysdeps/mach/hurd/mips/intr-msg.h b/ports/sysdeps/mach/hurd/mips/intr-msg.h
new file mode 100644
index 000000000..16c78972a
--- /dev/null
+++ b/ports/sysdeps/mach/hurd/mips/intr-msg.h
@@ -0,0 +1,127 @@
+/* Machine-dependent details of interruptible RPC messaging. Mips version.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+#ifdef __mips64
+#define INTR_MSG_TRAP(msg, option, send_size, rcv_size, rcv_name, timeout, notify) \
+({ \
+ error_t err; \
+ mach_port_t __rcv_name = (rcv_name); \
+ mach_msg_timeout_t __timeout = (timeout); \
+ mach_port_t __notify = (notify); \
+ asm (".globl _hurd_intr_rpc_msg_do_trap\n" \
+ ".globl _hurd_intr_rpc_msg_in_trap\n" \
+ " move $4, %1\n" \
+ " move $5, %2\n" \
+ " move $6, %3\n" \
+ " move $7, %4\n" \
+ " move $8, %5\n" \
+ " move $9, %6\n" \
+ " move $10, %7\n" \
+ " dli $2, -25\n" \
+ "_hurd_intr_rpc_msg_do_trap: syscall\n" \
+ "_hurd_intr_rpc_msg_in_trap: move %0, $2\n" \
+ : "=r" (err) \
+ : "r" (msg), "r" (option), "r" (send_size), "r" (rcv_size), \
+ "r" (__rcv_name), "r" (__timeout), "r" (__notify) \
+ : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", \
+ "$11", "$12", "$13", "$14", "$15", "$24", "$25", "$28"); \
+ err; \
+})
+#else
+#define INTR_MSG_TRAP(msg, option, send_size, rcv_size, rcv_name, timeout, notify) \
+({ \
+ error_t err; \
+ mach_port_t __rcv_name = (rcv_name); \
+ mach_msg_timeout_t __timeout = (timeout); \
+ mach_port_t __notify = (notify); \
+ asm (".globl _hurd_intr_rpc_msg_do_trap\n" \
+ ".globl _hurd_intr_rpc_msg_in_trap\n" \
+ " move $4, %1\n" \
+ " move $5, %2\n" \
+ " move $6, %3\n" \
+ " move $7, %4\n" \
+ " move $8, %5\n" \
+ " move $9, %6\n" \
+ " move $10, %7\n" \
+ " li $2, -25\n" \
+ "_hurd_intr_rpc_msg_do_trap: syscall\n" \
+ "_hurd_intr_rpc_msg_in_trap: move %0, $2\n" \
+ : "=r" (err) \
+ : "r" (msg), "r" (option), "r" (send_size), "r" (rcv_size), \
+ "r" (__rcv_name), "r" (__timeout), "r" (__notify) \
+ : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", \
+ "$11", "$12", "$13", "$14", "$15", "$24", "$25", "$28"); \
+ err; \
+})
+#endif
+
+static inline void
+INTR_MSG_BACK_OUT (struct mips_thread_state *state)
+{
+ return;
+}
+
+#include "hurdfault.h"
+
+static inline int
+SYSCALL_EXAMINE (struct mips_thread_state *state, int *callno)
+{
+ u_int32_t *p = (void *) (state->pc - 4);
+ int result;
+ if (_hurdsig_catch_memory_fault (p))
+ return 0;
+ if (result = (*p == 0x0000000c))
+ /* The PC is just after a `syscall' instruction.
+ This is a system call in progress; v0($2) holds the call number. */
+ *callno = state->r2;
+ _hurdsig_end_catch_fault ();
+ return result;
+}
+
+
+struct mach_msg_trap_args
+ {
+ /* This is the order of arguments to mach_msg_trap. */
+ mach_msg_header_t *msg;
+ mach_msg_option_t option;
+ mach_msg_size_t send_size;
+ mach_msg_size_t rcv_size;
+ mach_port_t rcv_name;
+ mach_msg_timeout_t timeout;
+ mach_port_t notify;
+ };
+
+
+static inline mach_port_t
+MSG_EXAMINE (struct mips_thread_state *state, int *msgid)
+{
+ mach_msg_header_t *msg;
+ mach_port_t send_port;
+
+ msg = (mach_msg_header_t *) state->r4;
+
+ if (_hurdsig_catch_memory_fault (msg))
+ return MACH_PORT_NULL;
+ send_port = msg->msgh_remote_port;
+ *msgid = msg->msgh_id;
+ _hurdsig_end_catch_fault ();
+
+ return send_port;
+}
diff --git a/ports/sysdeps/mach/hurd/mips/longjmp-ctx.c b/ports/sysdeps/mach/hurd/mips/longjmp-ctx.c
new file mode 100644
index 000000000..66ee7b6fb
--- /dev/null
+++ b/ports/sysdeps/mach/hurd/mips/longjmp-ctx.c
@@ -0,0 +1,41 @@
+/* Perform a `longjmp' on a `struct sigcontext'. MIPS version.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <setjmp.h>
+#include <hurd/signal.h>
+#include <string.h>
+
+void
+_hurd_longjmp_sigcontext (struct sigcontext *scp, jmp_buf env, int retval)
+{
+ scp->sc_gpr[16] = env[0].__regs[0];
+ scp->sc_gpr[17] = env[0].__regs[1];
+ scp->sc_gpr[18] = env[0].__regs[2];
+ scp->sc_gpr[19] = env[0].__regs[3];
+ scp->sc_gpr[20] = env[0].__regs[4];
+ scp->sc_gpr[21] = env[0].__regs[5];
+ scp->sc_gpr[22] = env[0].__regs[6];
+ scp->sc_gpr[23] = env[0].__regs[7];
+
+ scp->sc_gpr[28] = (int) env[0].__gp;
+ scp->sc_fp = (int) env[0].__fp;
+ scp->sc_sp = (int) env[0].__sp;
+ scp->sc_pc = (int) env[0].__pc;
+ scp->sc_gpr[2] = retval ?: 1;
+}
diff --git a/ports/sysdeps/mach/hurd/mips/longjmp-ts.c b/ports/sysdeps/mach/hurd/mips/longjmp-ts.c
new file mode 100644
index 000000000..4c69e4e2b
--- /dev/null
+++ b/ports/sysdeps/mach/hurd/mips/longjmp-ts.c
@@ -0,0 +1,45 @@
+/* Perform a `longjmp' on a Mach thread_state. MIPS version.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <hurd/signal.h>
+#include <setjmp.h>
+#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/ports/sysdeps/mach/hurd/mips/sigreturn.c b/ports/sysdeps/mach/hurd/mips/sigreturn.c
new file mode 100644
index 000000000..a9f7673eb
--- /dev/null
+++ b/ports/sysdeps/mach/hurd/mips/sigreturn.c
@@ -0,0 +1,223 @@
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <hurd.h>
+#include <hurd/signal.h>
+#include <hurd/threadvar.h>
+#include <stdlib.h>
+#include <mach/mips/mips_instruction.h>
+
+int
+__sigreturn (struct sigcontext *scp)
+{
+ struct hurd_sigstate *ss;
+ struct hurd_userlink *link = (void *) &scp[1];
+ mach_port_t *reply_port;
+
+ if (scp == NULL || (scp->sc_mask & _SIG_CANT_MASK))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ss = _hurd_self_sigstate ();
+ __spin_lock (&ss->lock);
+
+ /* Remove the link on the `active resources' chain added by
+ _hurd_setup_sighandler. Its purpose was to make sure
+ that we got called; now we have, it is done. */
+ _hurd_userlink_unlink (link);
+
+ /* Restore the set of blocked signals, and the intr_port slot. */
+ ss->blocked = scp->sc_mask;
+ ss->intr_port = scp->sc_intr_port;
+
+ /* 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;
+ __spin_unlock (&ss->lock);
+ __msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ());
+ /* If a pending signal was handled, sig_post never returned. */
+ __spin_lock (&ss->lock);
+ ss->context = NULL;
+ }
+
+ if (scp->sc_onstack)
+ {
+ ss->sigaltstack.ss_flags &= ~SS_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_t port = *reply_port;
+
+ /* Assigning MACH_PORT_DEAD here tells libc's mig_get_reply_port not to
+ get another reply port, but avoids mig_dealloc_reply_port trying to
+ deallocate it after the receive fails (which it will, because the
+ reply port will be bogus, whether we do this or not). */
+ *reply_port = MACH_PORT_DEAD;
+
+ __mach_port_destroy (__mach_task_self (), port);
+ }
+ *reply_port = scp->sc_reply_port;
+
+ if (scp->sc_coproc_used & SC_COPROC_USE_FPU)
+ {
+ /* Restore FPU state. */
+#define restore_fpr(n) \
+ asm volatile ("l.d $f" #n ",%0" : : "m" (scp->sc_fpr[n]))
+
+ /* Restore floating-point registers. */
+#ifdef __mips64
+ restore_fpr (0);
+ restore_fpr (1);
+ restore_fpr (2);
+ restore_fpr (3);
+ restore_fpr (4);
+ restore_fpr (5);
+ restore_fpr (6);
+ restore_fpr (7);
+ restore_fpr (8);
+ restore_fpr (9);
+ restore_fpr (10);
+ restore_fpr (11);
+ restore_fpr (12);
+ restore_fpr (13);
+ restore_fpr (14);
+ restore_fpr (15);
+ restore_fpr (16);
+ restore_fpr (17);
+ restore_fpr (18);
+ restore_fpr (19);
+ restore_fpr (20);
+ restore_fpr (21);
+ restore_fpr (22);
+ restore_fpr (23);
+ restore_fpr (24);
+ restore_fpr (25);
+ restore_fpr (26);
+ restore_fpr (27);
+ restore_fpr (28);
+ restore_fpr (29);
+ restore_fpr (30);
+ restore_fpr (31);
+#else
+ restore_fpr (0);
+ restore_fpr (2);
+ restore_fpr (4);
+ restore_fpr (6);
+ restore_fpr (8);
+ restore_fpr (10);
+ restore_fpr (12);
+ restore_fpr (14);
+ restore_fpr (16);
+ restore_fpr (18);
+ restore_fpr (20);
+ restore_fpr (22);
+ restore_fpr (24);
+ restore_fpr (26);
+ restore_fpr (28);
+ restore_fpr (30);
+#endif
+
+ /* Restore the floating-point control/status register ($f31). */
+ asm volatile ("ctc1 %0,$f31" : : "r" (scp->sc_fpcsr));
+ }
+
+ /* Load all the registers from the sigcontext. */
+#ifdef __mips64
+#define restore_gpr(n) \
+ asm volatile ("ld $" #n ",%0" : : "m" (scpreg->sc_gpr[n - 1]))
+#else
+#define restore_gpr(n) \
+ asm volatile ("lw $" #n ",%0" : : "m" (scpreg->sc_gpr[n - 1]))
+#endif
+
+ {
+ register const struct sigcontext *const scpreg asm ("$1") = scp;
+ 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 %0" : : "i" (op_sigreturn));
+ asm volatile (".set reorder; .set at;");
+ /* NOTREACHED */
+ return at; /* To prevent optimization. */
+ }
+
+ /* NOTREACHED */
+ return -1;
+}
+
+weak_alias (__sigreturn, sigreturn)
diff --git a/ports/sysdeps/mach/hurd/mips/trampoline.c b/ports/sysdeps/mach/hurd/mips/trampoline.c
new file mode 100644
index 000000000..34e363b1a
--- /dev/null
+++ b/ports/sysdeps/mach/hurd/mips/trampoline.c
@@ -0,0 +1,292 @@
+/* Set thread_state for sighandler, and sigcontext to recover. MIPS version.
+ Copyright (C) 1996, 1997, 1998, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <hurd/signal.h>
+#include <hurd/userlink.h>
+#include <thread_state.h>
+#include <assert.h>
+#include <errno.h>
+#include "hurdfault.h"
+#include <intr-msg.h>
+
+
+struct sigcontext *
+_hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
+ int signo, struct hurd_signal_detail *detail,
+ volatile int rpc_wait,
+ struct machine_thread_all_state *state)
+{
+ __label__ trampoline, rpc_wait_trampoline, firewall;
+ void *volatile sigsp;
+ struct sigcontext *scp;
+ struct
+ {
+ int signo;
+ long int sigcode;
+ struct sigcontext *scp; /* Points to ctx, below. */
+ void *sigreturn_addr;
+ void *sigreturn_returns_here;
+ struct sigcontext *return_scp; /* Same; arg to sigreturn. */
+ struct sigcontext ctx;
+ struct hurd_userlink link;
+ } *stackframe;
+
+ if (ss->context)
+ {
+ /* We have a previous sigcontext that sigreturn was about
+ to restore when another signal arrived. We will just base
+ our setup on that. */
+ if (! _hurdsig_catch_memory_fault (ss->context))
+ {
+ 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);
+ }
+ }
+ }
+
+ if (! machine_get_basic_state (ss->thread, state))
+ return NULL;
+
+ /* Save the original SP in the gratuitous s0 ($16) slot.
+ We may need to reset the SP (the `r29' slot) to avoid clobbering an
+ interrupted RPC frame. */
+ state->basic.r16 = state->basic.r29;
+
+ if ((ss->actions[signo].sa_flags & SA_ONSTACK) &&
+ !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK)))
+ {
+ sigsp = ss->sigaltstack.ss_sp + ss->sigaltstack.ss_size;
+ ss->sigaltstack.ss_flags |= SS_ONSTACK;
+ /* XXX need to set up base of new stack for
+ per-thread variables, cthreads. */
+ }
+ else
+ sigsp = (char *) state->basic.r29;
+
+ /* Push the arguments to call `trampoline' on the stack. */
+ sigsp -= sizeof (*stackframe);
+ stackframe = sigsp;
+
+ if (_hurdsig_catch_memory_fault (stackframe))
+ {
+ /* We got a fault trying to write the stack frame.
+ We cannot set up the signal handler.
+ Returning NULL tells our caller, who will nuke us with a SIGILL. */
+ return NULL;
+ }
+ else
+ {
+ int ok;
+
+ extern void _hurdsig_longjmp_from_handler (void *, jmp_buf, int);
+
+ /* Add a link to the thread's active-resources list. We mark this as
+ the only user of the "resource", so the cleanup function will be
+ called by any longjmp which is unwinding past the signal frame.
+ The cleanup function (in sigunwind.c) will make sure that all the
+ appropriate cleanups done by sigreturn are taken care of. */
+ stackframe->link.cleanup = &_hurdsig_longjmp_from_handler;
+ stackframe->link.cleanup_data = &stackframe->ctx;
+ stackframe->link.resource.next = NULL;
+ stackframe->link.resource.prevp = NULL;
+ stackframe->link.thread.next = ss->active_resources;
+ stackframe->link.thread.prevp = &ss->active_resources;
+ if (stackframe->link.thread.next)
+ stackframe->link.thread.next->thread.prevp
+ = &stackframe->link.thread.next;
+ ss->active_resources = &stackframe->link;
+
+ /* Set up the arguments for the signal handler. */
+ stackframe->signo = signo;
+ stackframe->sigcode = detail->code;
+ stackframe->scp = stackframe->return_scp = scp = &stackframe->ctx;
+ stackframe->sigreturn_addr = &__sigreturn;
+ stackframe->sigreturn_returns_here = &&firewall; /* Crash on return. */
+
+ /* Set up the sigcontext from the current state of the thread. */
+
+ scp->sc_onstack = ss->sigaltstack.ss_flags & SS_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. */
+ ok = machine_get_state (ss->thread, state, MIPS_EXC_STATE,
+ &state->exc, &scp->sc_cause,
+ sizeof (state->exc));
+
+ if (ok && (scp->sc_coproc_used & SC_COPROC_USE_FPU))
+ /* struct sigcontext is laid out so that starting at sc_fpr
+ mimics a struct mips_float_state. This state
+ is only meaningful if the coprocessor was used. */
+ ok = machine_get_state (ss->thread, state, MIPS_FLOAT_STATE,
+ &state->fpu, &scp->sc_mips_float_state,
+ sizeof (state->fpu));
+
+ _hurdsig_end_catch_fault ();
+
+ if (! ok)
+ return NULL;
+ }
+
+ /* 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;
+
+ if (_hurdsig_catch_memory_fault (args))
+ {
+ /* Faulted accessing ARGS. Bomb. */
+ return NULL;
+ }
+
+ assert (args->option & MACH_RCV_MSG);
+ /* Disable the message-send, since it has already completed. The
+ calls we retry need only wait to receive the reply message. */
+ args->option &= ~MACH_SEND_MSG;
+
+ /* Limit the time to receive the reply message, in case the server
+ claimed that `interrupt_operation' succeeded but in fact the RPC
+ is hung. */
+ args->option |= MACH_RCV_TIMEOUT;
+ args->timeout = _hurd_interrupted_rpc_timeout;
+
+ _hurdsig_end_catch_fault ();
+
+ state->basic.pc = (int) &&rpc_wait_trampoline;
+ /* The reply-receiving trampoline code runs initially on the original
+ user stack. We pass it the signal stack pointer in s4 ($20). */
+ state->basic.r29 = state->basic.r16; /* Restore mach_msg syscall SP. */
+ state->basic.r20 = (int) sigsp;
+ /* After doing the message receive, the trampoline code will need to
+ update the v0 ($2) value to be restored by sigreturn. To simplify
+ the assembly code, we pass the address of its slot in SCP to the
+ trampoline code in s5 ($21). */
+ state->basic.r21 = (int) &scp->sc_gpr[1];
+ /* We must preserve the mach_msg_trap args in a0..t2 ($4..$10).
+ Pass the handler args to the trampoline code in s1..s3 ($17..$19). */
+ state->basic.r17 = signo;
+ state->basic.r18 = detail->code;
+ state->basic.r19 = (int) scp;
+ }
+ else
+ {
+ state->basic.pc = (int) &&trampoline;
+ state->basic.r29 = (int) sigsp;
+ state->basic.r4 = signo;
+ state->basic.r5 = detail->code;
+ state->basic.r6 = (int) scp;
+ }
+
+ /* We pass the handler function to the trampoline code in s6 ($22). */
+ state->basic.r22 = (int) handler;
+ /* In the callee-saved register s0 ($16), we save the SCP value to pass
+ to __sigreturn after the handler returns. */
+ state->basic.r16 = (int) scp;
+
+ 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. */
+#ifdef __mips64
+ "dli $2, -25\n" /* mach_msg_trap */
+#else
+ "li $2, -25\n" /* mach_msg_trap */
+#endif
+ "syscall\n"
+ /* When the sigcontext was saved, v0 was MACH_RCV_INTERRUPTED. But
+ now the message receive has completed and the original caller of
+ the RPC (i.e. the code running when the signal arrived) needs to
+ see the final return value of the message receive in v0. So
+ store the new v0 value into the sc_gpr[1] member of the sigcontext
+ (whose address is in s5 to make this code simpler). */
+#ifdef __mips64
+ "sd $2, ($21)\n"
+#else
+ "sw $2, ($21)\n"
+#endif
+ /* Since the argument registers needed to have the mach_msg_trap
+ arguments, we've stored the arguments to the handler function
+ in registers s1..s3 ($17..$19). */
+ "move $4, $17\n"
+ "move $5, $18\n"
+ "move $6, $19\n"
+ /* Switch to the signal stack. */
+ "move $29, $20\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
+ ("move $25, $22\n" /* Copy s6 to t9 for MIPS ABI. */
+ "jal $25; nop\n" /* Call the handler function. */
+ /* Call __sigreturn (SCP); this cannot return. */
+#ifdef __mips64
+ "dla $1,%0\n"
+#else
+ "la $1,%0\n"
+#endif
+ "j $1\n"
+ "move $4, $16" /* Set up arg from saved SCP in delay slot. */
+ : : "i" (&__sigreturn));
+
+ /* NOTREACHED */
+ asm volatile (".set reorder; .set at; .set macro");
+
+ firewall:
+ asm volatile ("hlt: j hlt");
+
+ return NULL;
+}
diff --git a/ports/sysdeps/mach/mips/Makefile b/ports/sysdeps/mach/mips/Makefile
new file mode 100644
index 000000000..a890ae7b4
--- /dev/null
+++ b/ports/sysdeps/mach/mips/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),gnulib)
+sysdep_routines += cacheflush
+endif
diff --git a/ports/sysdeps/mach/mips/cacheflush.c b/ports/sysdeps/mach/mips/cacheflush.c
new file mode 100644
index 000000000..2a283e3e8
--- /dev/null
+++ b/ports/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) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <mach.h>
+#include <mach/vm_attributes.h>
+
+/* Stupid name, but this is what GCC generates (config/mips/mips.h). */
+void
+cacheflush (void *addr, unsigned 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/ports/sysdeps/mach/mips/machine-lock.h b/ports/sysdeps/mach/mips/machine-lock.h
new file mode 100644
index 000000000..eccc720df
--- /dev/null
+++ b/ports/sysdeps/mach/mips/machine-lock.h
@@ -0,0 +1,92 @@
+/* Machine-specific definition for spin locks. MIPS version.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MACHINE_LOCK_H
+#define _MACHINE_LOCK_H
+
+/* To get the TAS pseudo-instruction. */
+#include <mach/mips/mips_instruction.h>
+
+/* The type of a spin lock variable. */
+
+typedef __volatile int __spin_lock_t;
+
+/* 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)
+{
+#if (__mips >= 2)
+ int __rtn;
+
+ __asm__ __volatile (".set noreorder");
+#if (__mips64)
+ __asm__ __volatile ("lld %0,0(%1)" : "=r" (__rtn) : "r" (__lock));
+#else
+ __asm__ __volatile ("ll %0,0(%1)" : "=r" (__rtn) : "r" (__lock));
+#endif
+ if (__rtn)
+ return 0;
+ __asm__ __volatile ("move %0,%1" : "=r" (__rtn) : "r" (__lock));
+#if (__mips64)
+ __asm__ __volatile ("scd %0,0(%1)" : "=r" (__rtn) : "r" (__lock));
+#else
+ __asm__ __volatile ("sc %0,0(%1)" : "=r" (__rtn) : "r" (__lock));
+#endif
+ __asm__ __volatile (".set reorder");
+ return __rtn;
+#else
+ register int __rtn __asm__ ("a0");
+
+ /* Use the Mach microkernel's emulated TAS pseudo-instruction. */
+ __asm__ __volatile (".set noreorder");
+ __asm__ __volatile (".word %1" : "=r" (__rtn) : "i" (op_tas), "0" (__lock));
+ __asm__ __volatile ("nop");
+ __asm__ __volatile (".set reorder");
+ return __rtn ^ (int) __lock;
+#endif
+}
+
+/* Return nonzero if LOCK is locked. */
+
+_EXTERN_INLINE int
+__spin_lock_locked (__spin_lock_t *__lock)
+{
+ return *__lock != 0;
+}
+
+
+#endif /* machine-lock.h */
diff --git a/ports/sysdeps/mach/mips/machine-sp.h b/ports/sysdeps/mach/mips/machine-sp.h
new file mode 100644
index 000000000..144356a39
--- /dev/null
+++ b/ports/sysdeps/mach/mips/machine-sp.h
@@ -0,0 +1,38 @@
+/* Machine-specific function to return the stack pointer. MIPS version.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MACHINE_SP_H
+#define _MACHINE_SP_H
+
+/* 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/ports/sysdeps/mach/mips/syscall.S b/ports/sysdeps/mach/mips/syscall.S
new file mode 100644
index 000000000..f2fc29df1
--- /dev/null
+++ b/ports/sysdeps/mach/mips/syscall.S
@@ -0,0 +1,48 @@
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#ifdef PIC
+ .option pic2
+#endif
+ENTRY (syscall)
+ 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. */
+#ifdef __mips64
+ ld t0,4*8(sp)
+ ld t1,5*8(sp)
+ ld t2,6*8(sp)
+ ld t3,7*8(sp)
+ ld t4,8*8(sp)
+ ld t5,9*8(sp)
+ ld t6,10*8(sp)
+#else
+ lw t0,4*4(sp)
+ lw t1,5*4(sp)
+ lw t2,6*4(sp)
+ lw t3,7*4(sp)
+ lw t4,8*4(sp)
+ lw t5,9*4(sp)
+ lw t6,10*4(sp)
+#endif
+ syscall /* Do the system call. */
+ j ra /* Return to caller. */
diff --git a/ports/sysdeps/mach/mips/sysdep.h b/ports/sysdeps/mach/mips/sysdep.h
new file mode 100644
index 000000000..8136f95bf
--- /dev/null
+++ b/ports/sysdeps/mach/mips/sysdep.h
@@ -0,0 +1,83 @@
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define LOSE asm volatile ("1: b 1b")
+
+#define START_MACHDEP asm ("\
+ .text\n\
+ .globl _start\n\
+ .ent _start\n\
+_start:\n\
+ # Put initial SP in a0.\n\
+ move $4, $29\n\
+ # Jump to _start0; don't return.\n\
+ j _start0\n\
+ .end _start\n\
+");
+#define START_ARGS int *entry_sp
+#define SNARF_ARGS(argc, argv, envp) \
+ do \
+ { \
+ register char **p; \
+ \
+ 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 RETURN_TO(sp, pc, retval) \
+ asm volatile ("move $29, %0; move $2, %2; move $25, %1; jr $25" \
+ : : "r" (sp), "r" (pc), "r" (retval))
+
+#define STACK_GROWTH_DOWN
+
+#include <syscall.h>
+
+#if defined (__ASSEMBLER__)
+
+#define ALIGN 2
+
+#define MOVE(x,y) move y , x
+
+#define SYSCALL(name, args) \
+ .globl syscall_error; \
+ kernel_trap(name,SYS_##name,args); \
+ 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 <sysdeps/mach/sysdep.h>
diff --git a/ports/sysdeps/mach/mips/thread_state.h b/ports/sysdeps/mach/mips/thread_state.h
new file mode 100644
index 000000000..a0800de2d
--- /dev/null
+++ b/ports/sysdeps/mach/mips/thread_state.h
@@ -0,0 +1,42 @@
+/* Mach thread state definitions for machine-independent code. MIPS version.
+ Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define MACHINE_THREAD_STATE_FLAVOR MIPS_THREAD_STATE
+#define MACHINE_THREAD_STATE_COUNT MIPS_THREAD_STATE_COUNT
+
+#ifdef __PIC__
+#define MACHINE_THREAD_STATE_SET_PC(ts, pc) \
+ ((ts)->PC = (ts)->r25 = (unsigned long int) (pc))
+#endif
+
+#define machine_thread_state mips_thread_state
+
+#define PC pc
+#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 <sysdeps/mach/thread_state.h>
diff --git a/ports/sysdeps/mips/.cvsignore b/ports/sysdeps/mips/.cvsignore
new file mode 100644
index 000000000..1f69fd919
--- /dev/null
+++ b/ports/sysdeps/mips/.cvsignore
@@ -0,0 +1,4 @@
+*.gz *.Z *.tar *.tgz
+=*
+TODO COPYING* AUTHORS copyr-* copying.*
+glibc-*
diff --git a/ports/sysdeps/mips/Implies b/ports/sysdeps/mips/Implies
new file mode 100644
index 000000000..8c18cb303
--- /dev/null
+++ b/ports/sysdeps/mips/Implies
@@ -0,0 +1,3 @@
+# MIPS uses IEEE 754 floating point.
+ieee754/flt-32
+ieee754/dbl-64
diff --git a/ports/sysdeps/mips/Makefile b/ports/sysdeps/mips/Makefile
new file mode 100644
index 000000000..9d01522a3
--- /dev/null
+++ b/ports/sysdeps/mips/Makefile
@@ -0,0 +1,14 @@
+ifeq ($(subdir),misc)
+sysdep_headers += regdef.h fpregdef.h sys/regdef.h sys/fpregdef.h \
+ sys/asm.h sgidefs.h
+endif
+
+ifeq ($(subdir),setjmp)
+sysdep_routines += setjmp_aux
+endif
+
+ifeq ($(subdir),rt)
+librt-sysdep_routines += rt-sysdep
+endif
+
+ASFLAGS-.os += $(pic-ccflag)
diff --git a/ports/sysdeps/mips/__longjmp.c b/ports/sysdeps/mips/__longjmp.c
new file mode 100644
index 000000000..750a71fd1
--- /dev/null
+++ b/ports/sysdeps/mips/__longjmp.c
@@ -0,0 +1,84 @@
+/* Copyright (C) 1992, 1995, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <setjmp.h>
+#include <stdlib.h>
+
+#undef __longjmp
+
+#ifndef __GNUC__
+ #error This file uses GNU C extensions; you must compile with GCC.
+#endif
+
+void
+__longjmp (env, val_arg)
+ __jmp_buf env;
+ int val_arg;
+{
+ /* gcc 1.39.19 miscompiled the longjmp routine (as it did setjmp before
+ the hack around it); force it to use $a1 for the longjmp value.
+ Without this it saves $a1 in a register which gets clobbered
+ along the way. */
+ register int val asm ("a1");
+
+ /* Pull back the floating point callee-saved registers. */
+ asm volatile ("l.d $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]));
+
+ /* Get and reconstruct the floating point csr. */
+ asm volatile ("lw $2, %0" : : "m" (env[0].__fpc_csr));
+ asm volatile ("ctc1 $2, $31");
+
+ /* 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 $25, %0" : : "m" (env[0].__pc));
+
+ /* Restore the stack pointer and the FP. They have to be restored
+ last and in a single asm as gcc, depending on options used, may
+ use either of them to access env. */
+ asm volatile ("lw $29, %0\n\t"
+ "lw $30, %1\n\t" : : "m" (env[0].__sp), "m" (env[0].__fp));
+
+/* 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 ("jr $25");
+
+ /* Avoid `volatile function does return' warnings. */
+ for (;;);
+}
diff --git a/ports/sysdeps/mips/abort-instr.h b/ports/sysdeps/mips/abort-instr.h
new file mode 100644
index 000000000..d7d8d501b
--- /dev/null
+++ b/ports/sysdeps/mips/abort-instr.h
@@ -0,0 +1,2 @@
+/* An instruction which should crash any program is a breakpoint. */
+#define ABORT_INSTRUCTION asm ("break 255")
diff --git a/ports/sysdeps/mips/add_n.S b/ports/sysdeps/mips/add_n.S
new file mode 100644
index 000000000..c82871f70
--- /dev/null
+++ b/ports/sysdeps/mips/add_n.S
@@ -0,0 +1,122 @@
+/* MIPS2 __mpn_add_n -- Add two limb vectors of the same length > 0 and
+store sum in a third limb vector.
+
+Copyright (C) 1995, 2000, 2002, 2003 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+/* INPUT PARAMETERS
+ res_ptr $4
+ s1_ptr $5
+ s2_ptr $6
+ size $7
+*/
+#ifdef __PIC__
+ .option pic2
+#endif
+ENTRY (__mpn_add_n)
+ .set noreorder
+#ifdef __PIC__
+ .cpload t9
+#endif
+ .set nomacro
+
+ lw $10,0($5)
+ lw $11,0($6)
+
+ addiu $7,$7,-1
+ and $9,$7,4-1 /* number of limbs in first loop */
+ beq $9,$0,L(L0) /* if multiple of 4 limbs, skip first loop */
+ move $2,$0
+
+ subu $7,$7,$9
+
+L(Loop0): addiu $9,$9,-1
+ lw $12,4($5)
+ addu $11,$11,$2
+ lw $13,4($6)
+ sltu $8,$11,$2
+ addu $11,$10,$11
+ sltu $2,$11,$10
+ sw $11,0($4)
+ or $2,$2,$8
+
+ addiu $5,$5,4
+ addiu $6,$6,4
+ move $10,$12
+ move $11,$13
+ bne $9,$0,L(Loop0)
+ addiu $4,$4,4
+
+L(L0): beq $7,$0,L(end)
+ nop
+
+L(Loop): addiu $7,$7,-4
+
+ lw $12,4($5)
+ addu $11,$11,$2
+ lw $13,4($6)
+ sltu $8,$11,$2
+ addu $11,$10,$11
+ sltu $2,$11,$10
+ sw $11,0($4)
+ or $2,$2,$8
+
+ lw $10,8($5)
+ addu $13,$13,$2
+ lw $11,8($6)
+ sltu $8,$13,$2
+ addu $13,$12,$13
+ sltu $2,$13,$12
+ sw $13,4($4)
+ or $2,$2,$8
+
+ lw $12,12($5)
+ addu $11,$11,$2
+ lw $13,12($6)
+ sltu $8,$11,$2
+ addu $11,$10,$11
+ sltu $2,$11,$10
+ sw $11,8($4)
+ or $2,$2,$8
+
+ lw $10,16($5)
+ addu $13,$13,$2
+ lw $11,16($6)
+ sltu $8,$13,$2
+ addu $13,$12,$13
+ sltu $2,$13,$12
+ sw $13,12($4)
+ or $2,$2,$8
+
+ addiu $5,$5,16
+ addiu $6,$6,16
+
+ bne $7,$0,L(Loop)
+ addiu $4,$4,16
+
+L(end): addu $11,$11,$2
+ sltu $8,$11,$2
+ addu $11,$10,$11
+ sltu $2,$11,$10
+ sw $11,0($4)
+ j $31
+ or $2,$2,$8
+ .end __mpn_add_n
diff --git a/ports/sysdeps/mips/addmul_1.S b/ports/sysdeps/mips/addmul_1.S
new file mode 100644
index 000000000..3e1fc09d1
--- /dev/null
+++ b/ports/sysdeps/mips/addmul_1.S
@@ -0,0 +1,99 @@
+/* MIPS __mpn_addmul_1 -- Multiply a limb vector with a single limb and
+add the product to a second limb vector.
+
+Copyright (C) 1995, 2000, 2002, 2003 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+/* INPUT PARAMETERS
+ res_ptr $4
+ s1_ptr $5
+ size $6
+ s2_limb $7
+*/
+#ifdef __PIC__
+ .option pic2
+#endif
+ENTRY (__mpn_addmul_1)
+ .set noreorder
+#ifdef __PIC__
+ .cpload t9
+#endif
+ .set nomacro
+
+ /* warm up phase 0 */
+ lw $8,0($5)
+
+ /* warm up phase 1 */
+ addiu $5,$5,4
+ multu $8,$7
+
+ addiu $6,$6,-1
+ beq $6,$0,L(LC0)
+ move $2,$0 /* zero cy2 */
+
+ addiu $6,$6,-1
+ beq $6,$0,L(LC1)
+ lw $8,0($5) /* load new s1 limb as early as possible */
+
+L(Loop): lw $10,0($4)
+ mflo $3
+ mfhi $9
+ addiu $5,$5,4
+ addu $3,$3,$2 /* add old carry limb to low product limb */
+ multu $8,$7
+ lw $8,0($5) /* load new s1 limb as early as possible */
+ addiu $6,$6,-1 /* decrement loop counter */
+ sltu $2,$3,$2 /* carry from previous addition -> $2 */
+ addu $3,$10,$3
+ sltu $10,$3,$10
+ addu $2,$2,$10
+ sw $3,0($4)
+ addiu $4,$4,4
+ bne $6,$0,L(Loop) /* should be "bnel" */
+ addu $2,$9,$2 /* add high product limb and carry from addition */
+
+ /* cool down phase 1 */
+L(LC1): lw $10,0($4)
+ mflo $3
+ mfhi $9
+ addu $3,$3,$2
+ sltu $2,$3,$2
+ multu $8,$7
+ addu $3,$10,$3
+ sltu $10,$3,$10
+ addu $2,$2,$10
+ sw $3,0($4)
+ addiu $4,$4,4
+ addu $2,$9,$2 /* add high product limb and carry from addition */
+
+ /* cool down phase 0 */
+L(LC0): lw $10,0($4)
+ mflo $3
+ mfhi $9
+ addu $3,$3,$2
+ sltu $2,$3,$2
+ addu $3,$10,$3
+ sltu $10,$3,$10
+ addu $2,$2,$10
+ sw $3,0($4)
+ j $31
+ addu $2,$9,$2 /* add high product limb and carry from addition */
+ END (__mpn_addmul_1)
diff --git a/ports/sysdeps/mips/bits/atomic.h b/ports/sysdeps/mips/bits/atomic.h
new file mode 100644
index 000000000..167d9a59c
--- /dev/null
+++ b/ports/sysdeps/mips/bits/atomic.h
@@ -0,0 +1,303 @@
+/* Low-level functions for atomic operations. Mips version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MIPS_BITS_ATOMIC_H
+#define _MIPS_BITS_ATOMIC_H 1
+
+#include <inttypes.h>
+#include <sgidefs.h>
+
+typedef int32_t atomic32_t;
+typedef uint32_t uatomic32_t;
+typedef int_fast32_t atomic_fast32_t;
+typedef uint_fast32_t uatomic_fast32_t;
+
+typedef int64_t atomic64_t;
+typedef uint64_t uatomic64_t;
+typedef int_fast64_t atomic_fast64_t;
+typedef uint_fast64_t uatomic_fast64_t;
+
+typedef intptr_t atomicptr_t;
+typedef uintptr_t uatomicptr_t;
+typedef intmax_t atomic_max_t;
+typedef uintmax_t uatomic_max_t;
+
+#if _MIPS_SIM == _ABIO32
+#define MIPS_PUSH_MIPS2 ".set mips2\n\t"
+#else
+#define MIPS_PUSH_MIPS2
+#endif
+
+/* See the comments in <sys/asm.h> about the use of the sync instruction. */
+#ifndef MIPS_SYNC
+# define MIPS_SYNC sync
+#endif
+
+#define MIPS_SYNC_STR_2(X) #X
+#define MIPS_SYNC_STR_1(X) MIPS_SYNC_STR_2(X)
+#define MIPS_SYNC_STR MIPS_SYNC_STR_1(MIPS_SYNC)
+
+/* Compare and exchange. For all of the "xxx" routines, we expect a
+ "__prev" and a "__cmp" variable to be provided by the enclosing scope,
+ in which values are returned. */
+
+#define __arch_compare_and_exchange_xxx_8_int(mem, newval, oldval, rel, acq) \
+ (abort (), __prev = __cmp = 0)
+
+#define __arch_compare_and_exchange_xxx_16_int(mem, newval, oldval, rel, acq) \
+ (abort (), __prev = __cmp = 0)
+
+#define __arch_compare_and_exchange_xxx_32_int(mem, newval, oldval, rel, acq) \
+ __asm__ __volatile__ ( \
+ ".set push\n\t" \
+ MIPS_PUSH_MIPS2 \
+ rel "\n" \
+ "1:\t" \
+ "ll %0,%4\n\t" \
+ "move %1,$0\n\t" \
+ "bne %0,%2,2f\n\t" \
+ "move %1,%3\n\t" \
+ "sc %1,%4\n\t" \
+ "beqz %1,1b\n" \
+ acq "\n\t" \
+ ".set pop\n" \
+ "2:\n\t" \
+ : "=&r" (__prev), "=&r" (__cmp) \
+ : "r" (oldval), "r" (newval), "m" (*mem) \
+ : "memory")
+
+#if _MIPS_SIM == _ABIO32
+/* We can't do an atomic 64-bit operation in O32. */
+#define __arch_compare_and_exchange_xxx_64_int(mem, newval, oldval, rel, acq) \
+ (abort (), __prev = __cmp = 0)
+#else
+#define __arch_compare_and_exchange_xxx_64_int(mem, newval, oldval, rel, acq) \
+ __asm__ __volatile__ ("\n" \
+ ".set push\n\t" \
+ MIPS_PUSH_MIPS2 \
+ rel "\n" \
+ "1:\t" \
+ "lld %0,%4\n\t" \
+ "move %1,$0\n\t" \
+ "bne %0,%2,2f\n\t" \
+ "move %1,%3\n\t" \
+ "scd %1,%4\n\t" \
+ "beqz %1,1b\n" \
+ acq "\n\t" \
+ ".set pop\n" \
+ "2:\n\t" \
+ : "=&r" (__prev), "=&r" (__cmp) \
+ : "r" (oldval), "r" (newval), "m" (*mem) \
+ : "memory")
+#endif
+
+/* For all "bool" routines, we return FALSE if exchange succesful. */
+
+#define __arch_compare_and_exchange_bool_8_int(mem, new, old, rel, acq) \
+({ typeof (*mem) __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_8_int(mem, new, old, rel, acq); \
+ !__cmp; })
+
+#define __arch_compare_and_exchange_bool_16_int(mem, new, old, rel, acq) \
+({ typeof (*mem) __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_16_int(mem, new, old, rel, acq); \
+ !__cmp; })
+
+#define __arch_compare_and_exchange_bool_32_int(mem, new, old, rel, acq) \
+({ typeof (*mem) __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_32_int(mem, new, old, rel, acq); \
+ !__cmp; })
+
+#define __arch_compare_and_exchange_bool_64_int(mem, new, old, rel, acq) \
+({ typeof (*mem) __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_64_int(mem, new, old, rel, acq); \
+ !__cmp; })
+
+/* For all "val" routines, return the old value whether exchange
+ successful or not. */
+
+#define __arch_compare_and_exchange_val_8_int(mem, new, old, rel, acq) \
+({ typeof (*mem) __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_8_int(mem, new, old, rel, acq); \
+ (typeof (*mem))__prev; })
+
+#define __arch_compare_and_exchange_val_16_int(mem, new, old, rel, acq) \
+({ typeof (*mem) __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_16_int(mem, new, old, rel, acq); \
+ (typeof (*mem))__prev; })
+
+#define __arch_compare_and_exchange_val_32_int(mem, new, old, rel, acq) \
+({ typeof (*mem) __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_32_int(mem, new, old, rel, acq); \
+ (typeof (*mem))__prev; })
+
+#define __arch_compare_and_exchange_val_64_int(mem, new, old, rel, acq) \
+({ typeof (*mem) __prev; int __cmp; \
+ __arch_compare_and_exchange_xxx_64_int(mem, new, old, rel, acq); \
+ (typeof (*mem))__prev; })
+
+/* Compare and exchange with "acquire" semantics, ie barrier after. */
+
+#define atomic_compare_and_exchange_bool_acq(mem, new, old) \
+ __atomic_bool_bysize (__arch_compare_and_exchange_bool, int, \
+ mem, new, old, "", MIPS_SYNC_STR)
+
+#define atomic_compare_and_exchange_val_acq(mem, new, old) \
+ __atomic_val_bysize (__arch_compare_and_exchange_val, int, \
+ mem, new, old, "", MIPS_SYNC_STR)
+
+/* Compare and exchange with "release" semantics, ie barrier before. */
+
+#define atomic_compare_and_exchange_bool_rel(mem, new, old) \
+ __atomic_bool_bysize (__arch_compare_and_exchange_bool, int, \
+ mem, new, old, MIPS_SYNC_STR, "")
+
+#define atomic_compare_and_exchange_val_rel(mem, new, old) \
+ __atomic_val_bysize (__arch_compare_and_exchange_val, int, \
+ mem, new, old, MIPS_SYNC_STR, "")
+
+
+
+/* Atomic exchange (without compare). */
+
+#define __arch_exchange_xxx_8_int(mem, newval, rel, acq) \
+ (abort (), 0)
+
+#define __arch_exchange_xxx_16_int(mem, newval, rel, acq) \
+ (abort (), 0)
+
+#define __arch_exchange_xxx_32_int(mem, newval, rel, acq) \
+({ typeof (*mem) __prev; int __cmp; \
+ __asm__ __volatile__ ("\n" \
+ ".set push\n\t" \
+ MIPS_PUSH_MIPS2 \
+ rel "\n" \
+ "1:\t" \
+ "ll %0,%3\n\t" \
+ "move %1,%2\n\t" \
+ "sc %1,%3\n\t" \
+ "beqz %1,1b\n" \
+ acq "\n\t" \
+ ".set pop\n" \
+ "2:\n\t" \
+ : "=&r" (__prev), "=&r" (__cmp) \
+ : "r" (newval), "m" (*mem) \
+ : "memory"); \
+ __prev; })
+
+#if _MIPS_SIM == _ABIO32
+/* We can't do an atomic 64-bit operation in O32. */
+#define __arch_exchange_xxx_64_int(mem, newval, rel, acq) \
+ (abort (), 0)
+#else
+#define __arch_exchange_xxx_64_int(mem, newval, rel, acq) \
+({ typeof (*mem) __prev; int __cmp; \
+ __asm__ __volatile__ ("\n" \
+ ".set push\n\t" \
+ MIPS_PUSH_MIPS2 \
+ rel "\n" \
+ "1:\n" \
+ "lld %0,%3\n\t" \
+ "move %1,%2\n\t" \
+ "scd %1,%3\n\t" \
+ "beqz %1,1b\n" \
+ acq "\n\t" \
+ ".set pop\n" \
+ "2:\n\t" \
+ : "=&r" (__prev), "=&r" (__cmp) \
+ : "r" (newval), "m" (*mem) \
+ : "memory"); \
+ __prev; })
+#endif
+
+#define atomic_exchange_acq(mem, value) \
+ __atomic_val_bysize (__arch_exchange_xxx, int, mem, value, "", MIPS_SYNC_STR)
+
+#define atomic_exchange_rel(mem, value) \
+ __atomic_val_bysize (__arch_exchange_xxx, int, mem, value, MIPS_SYNC_STR, "")
+
+
+/* Atomically add value and return the previous (unincremented) value. */
+
+#define __arch_exchange_and_add_8_int(mem, newval, rel, acq) \
+ (abort (), (typeof(*mem)) 0)
+
+#define __arch_exchange_and_add_16_int(mem, newval, rel, acq) \
+ (abort (), (typeof(*mem)) 0)
+
+#define __arch_exchange_and_add_32_int(mem, value, rel, acq) \
+({ typeof (*mem) __prev; int __cmp; \
+ __asm__ __volatile__ ("\n" \
+ ".set push\n\t" \
+ MIPS_PUSH_MIPS2 \
+ rel "\n" \
+ "1:\t" \
+ "ll %0,%3\n\t" \
+ "addu %1,%0,%2\n\t" \
+ "sc %1,%3\n\t" \
+ "beqz %1,1b\n" \
+ acq "\n\t" \
+ ".set pop\n" \
+ "2:\n\t" \
+ : "=&r" (__prev), "=&r" (__cmp) \
+ : "r" (value), "m" (*mem) \
+ : "memory"); \
+ __prev; })
+
+#if _MIPS_SIM == _ABIO32
+/* We can't do an atomic 64-bit operation in O32. */
+#define __arch_exchange_and_add_64_int(mem, value, rel, acq) \
+ (abort (), (typeof(*mem)) 0)
+#else
+#define __arch_exchange_and_add_64_int(mem, value, rel, acq) \
+({ typeof (*mem) __prev; int __cmp; \
+ __asm__ __volatile__ ( \
+ ".set push\n\t" \
+ MIPS_PUSH_MIPS2 \
+ rel "\n" \
+ "1:\t" \
+ "lld %0,%3\n\t" \
+ "daddu %1,%0,%2\n\t" \
+ "scd %1,%3\n\t" \
+ "beqz %1,1b\n" \
+ acq "\n\t" \
+ ".set pop\n" \
+ "2:\n\t" \
+ : "=&r" (__prev), "=&r" (__cmp) \
+ : "r" (value), "m" (*mem) \
+ : "memory"); \
+ __prev; })
+#endif
+
+/* ??? Barrier semantics for atomic_exchange_and_add appear to be
+ undefined. Use full barrier for now, as that's safe. */
+#define atomic_exchange_and_add(mem, value) \
+ __atomic_val_bysize (__arch_exchange_and_add, int, mem, value, \
+ MIPS_SYNC_STR, MIPS_SYNC_STR)
+
+/* TODO: More atomic operations could be implemented efficiently; only the
+ basic requirements are done. */
+
+#define atomic_full_barrier() \
+ __asm__ __volatile__ (".set push\n\t" \
+ MIPS_PUSH_MIPS2 \
+ MIPS_SYNC_STR "\n\t" \
+ ".set pop" : : : "memory")
+
+#endif /* bits/atomic.h */
diff --git a/ports/sysdeps/mips/bits/dlfcn.h b/ports/sysdeps/mips/bits/dlfcn.h
new file mode 100644
index 000000000..a5b5bf53f
--- /dev/null
+++ b/ports/sysdeps/mips/bits/dlfcn.h
@@ -0,0 +1,66 @@
+/* System dependent definitions for run-time dynamic loading.
+ Copyright (C) 1996, 1997, 1999, 2000, 2001, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _DLFCN_H
+# error "Never use <bits/dlfcn.h> directly; include <dlfcn.h> instead."
+#endif
+
+/* The MODE argument to `dlopen' contains one of the following: */
+#define RTLD_LAZY 0x0001 /* Lazy function call binding. */
+#define RTLD_NOW 0x0002 /* Immediate function call binding. */
+#define RTLD_BINDING_MASK 0x3 /* Mask of binding time value. */
+#define RTLD_NOLOAD 0x00008 /* Do not load the object. */
+#define RTLD_DEEPBIND 0x00010 /* Use deep binding. */
+
+/* If the following bit is set in the MODE argument to `dlopen',
+ the symbols of the loaded object and its dependencies are made
+ visible as if the object were linked directly into the program. */
+#define RTLD_GLOBAL 0x0004
+
+/* Unix98 demands the following flag which is the inverse to RTLD_GLOBAL.
+ The implementation does this by default and so we can define the
+ value to zero. */
+#define RTLD_LOCAL 0
+
+/* Do not delete object when closed. */
+#define RTLD_NODELETE 0x01000
+
+#ifdef __USE_GNU
+/* To support profiling of shared objects it is a good idea to call
+ the function found using `dlsym' using the following macro since
+ these calls do not use the PLT. But this would mean the dynamic
+ loader has no chance to find out when the function is called. The
+ macro applies the necessary magic so that profiling is possible.
+ Rewrite
+ foo = (*fctp) (arg1, arg2);
+ into
+ foo = DL_CALL_FCT (fctp, (arg1, arg2));
+*/
+# define DL_CALL_FCT(fctp, args) \
+ (_dl_mcount_wrapper_check ((void *) (fctp)), (*(fctp)) args)
+
+__BEGIN_DECLS
+
+/* This function calls the profiling functions. */
+extern void _dl_mcount_wrapper_check (void *__selfpc) __THROW;
+
+__END_DECLS
+
+#endif
diff --git a/ports/sysdeps/mips/bits/endian.h b/ports/sysdeps/mips/bits/endian.h
new file mode 100644
index 000000000..9586104cc
--- /dev/null
+++ b/ports/sysdeps/mips/bits/endian.h
@@ -0,0 +1,13 @@
+/* The MIPS architecture has selectable endianness.
+ This file is for a machine using big-endian mode. */
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#if __MIPSEB
+# define __BYTE_ORDER __BIG_ENDIAN
+#endif
+#if __MIPSEL
+# define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
diff --git a/ports/sysdeps/mips/bits/fenv.h b/ports/sysdeps/mips/bits/fenv.h
new file mode 100644
index 000000000..24e0694ca
--- /dev/null
+++ b/ports/sysdeps/mips/bits/fenv.h
@@ -0,0 +1,77 @@
+/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FENV_H
+# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
+
+
+/* Define bits representing the exception. We use the bit positions
+ of the appropriate bits in the FPU control word. */
+enum
+ {
+ FE_INEXACT = 0x04,
+#define FE_INEXACT FE_INEXACT
+ FE_UNDERFLOW = 0x08,
+#define FE_UNDERFLOW FE_UNDERFLOW
+ FE_OVERFLOW = 0x10,
+#define FE_OVERFLOW FE_OVERFLOW
+ FE_DIVBYZERO = 0x20,
+#define FE_DIVBYZERO FE_DIVBYZERO
+ FE_INVALID = 0x40,
+#define FE_INVALID FE_INVALID
+ };
+
+#define FE_ALL_EXCEPT \
+ (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
+
+/* The MIPS FPU supports all of the four defined rounding modes. We
+ use again the bit positions in the FPU control word as the values
+ for the appropriate macros. */
+enum
+ {
+ FE_TONEAREST = 0x0,
+#define FE_TONEAREST FE_TONEAREST
+ FE_TOWARDZERO = 0x1,
+#define FE_TOWARDZERO FE_TOWARDZERO
+ FE_UPWARD = 0x2,
+#define FE_UPWARD FE_UPWARD
+ FE_DOWNWARD = 0x3
+#define FE_DOWNWARD FE_DOWNWARD
+ };
+
+
+/* Type representing exception flags. */
+typedef unsigned short int fexcept_t;
+
+
+/* Type representing floating-point environment. This function corresponds
+ to the layout of the block written by the `fstenv'. */
+typedef struct
+ {
+ unsigned int __fp_control_register;
+ }
+fenv_t;
+
+/* If the default argument is used we use this value. */
+#define FE_DFL_ENV ((__const fenv_t *) -1)
+
+#ifdef __USE_GNU
+/* Floating-point environment where none of the exception is masked. */
+# define FE_NOMASK_ENV ((__const fenv_t *) -2)
+#endif
diff --git a/ports/sysdeps/mips/bits/ipctypes.h b/ports/sysdeps/mips/bits/ipctypes.h
new file mode 100644
index 000000000..0956e7d58
--- /dev/null
+++ b/ports/sysdeps/mips/bits/ipctypes.h
@@ -0,0 +1,32 @@
+/* bits/ipctypes.h -- Define some types used by SysV IPC/MSG/SHM. MIPS version
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/*
+ * Never include <bits/ipctypes.h> directly.
+ */
+
+#ifndef _BITS_IPCTYPES_H
+#define _BITS_IPCTYPES_H 1
+
+#include <bits/types.h>
+
+typedef __SLONG32_TYPE __ipc_pid_t;
+
+
+#endif /* bits/ipctypes.h */
diff --git a/ports/sysdeps/mips/bits/link.h b/ports/sysdeps/mips/bits/link.h
new file mode 100644
index 000000000..3d77a4c4a
--- /dev/null
+++ b/ports/sysdeps/mips/bits/link.h
@@ -0,0 +1,118 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _LINK_H
+# error "Never include <bits/link.h> directly; use <link.h> instead."
+#endif
+
+#include <sgidefs.h>
+
+#if _MIPS_SIM == _ABIO32
+
+/* Registers for entry into PLT on MIPS. */
+typedef struct La_mips_32_regs
+{
+ uint32_t lr_reg[4]; /* $a0 through $a3 */
+ double lr_fpreg[2]; /* $f12 and $f14 */
+ uint32_t lr_ra;
+ uint32_t lr_sp;
+} La_mips_32_regs;
+
+/* Return values for calls from PLT on MIPS. */
+typedef struct La_mips_32_retval
+{
+ uint32_t lrv_v0;
+ uint32_t lrv_v1;
+ double lrv_f0;
+ double lrv_f2;
+} La_mips_32_retval;
+
+#else
+
+typedef struct La_mips_64_regs
+{
+ uint64_t lr_reg[8]; /* $a0 through $a7 */
+ double lr_fpreg[8]; /* $f12 throgh $f19 */
+ uint64_t lr_ra;
+ uint64_t lr_sp;
+} La_mips_64_regs;
+
+/* Return values for calls from PLT on MIPS. */
+typedef struct La_mips_64_retval
+{
+ uint64_t lrv_v0;
+ uint64_t lrv_v1;
+ double lrv_f0;
+ double lrv_f2;
+} La_mips_64_retval;
+
+#endif
+
+__BEGIN_DECLS
+
+#if _MIPS_SIM == _ABIO32
+
+extern Elf32_Addr la_mips_o32_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ La_mips_32_regs *__regs,
+ unsigned int *__flags,
+ const char *__symname,
+ long int *__framesizep);
+extern unsigned int la_mips_o32_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ const La_mips_32_regs *__inregs,
+ La_mips_32_retval *__outregs,
+ const char *symname);
+
+#elif _MIPS_SIM == _ABIN32
+
+extern Elf32_Addr la_mips_n32_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ La_mips_64_regs *__regs,
+ unsigned int *__flags,
+ const char *__symname,
+ long int *__framesizep);
+extern unsigned int la_mips_n32_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ const La_mips_64_regs *__inregs,
+ La_mips_64_retval *__outregs,
+ const char *symname);
+
+#else
+
+extern Elf64_Addr la_mips_n64_gnu_pltenter (Elf64_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ La_mips_64_regs *__regs,
+ unsigned int *__flags,
+ const char *__symname,
+ long int *__framesizep);
+extern unsigned int la_mips_n64_gnu_pltexit (Elf64_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ const La_mips_64_regs *__inregs,
+ La_mips_64_retval *__outregs,
+ const char *symname);
+
+#endif
+
+__END_DECLS
diff --git a/ports/sysdeps/mips/bits/mathdef.h b/ports/sysdeps/mips/bits/mathdef.h
new file mode 100644
index 000000000..99be0db2b
--- /dev/null
+++ b/ports/sysdeps/mips/bits/mathdef.h
@@ -0,0 +1,46 @@
+/* Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#if !defined _MATH_H && !defined _COMPLEX_H
+# error "Never use <bits/mathdef.h> directly; include <math.h> instead"
+#endif
+
+#include <sgidefs.h>
+
+#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF
+# define _MATH_H_MATHDEF 1
+
+/* Normally, there is no long double type and the `float' and `double'
+ expressions are evaluated as `double'. */
+typedef double float_t; /* `float' expressions are evaluated as
+ `double'. */
+typedef double double_t; /* `double' expressions are evaluated as
+ `double'. */
+
+/* The values returned by `ilogb' for 0 and NaN respectively. */
+# define FP_ILOGB0 (-2147483647)
+# define FP_ILOGBNAN 2147483647
+
+#endif /* ISO C99 */
+
+#if ! defined __NO_LONG_DOUBLE_MATH && _MIPS_SIM == _ABIO32
+/* Signal that we do not really have a `long double'. This disables the
+ declaration of all the `long double' function variants. */
+# define __NO_LONG_DOUBLE_MATH 1
+#endif
diff --git a/ports/sysdeps/mips/bits/nan.h b/ports/sysdeps/mips/bits/nan.h
new file mode 100644
index 000000000..baaaa551f
--- /dev/null
+++ b/ports/sysdeps/mips/bits/nan.h
@@ -0,0 +1,56 @@
+/* `NAN' constant for IEEE 754 machines.
+ Copyright (C) 1992, 1996, 1997, 1999, 2002, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MATH_H
+# error "Never use <bits/nan.h> directly; include <math.h> instead."
+#endif
+
+
+/* IEEE Not A Number (QNaN). Note that MIPS has the QNaN and SNaN patterns
+ reversed compared to most other architectures. The IEEE spec left
+ the definition of this open to implementations, and for MIPS the top
+ bit of the mantissa must be SET to indicate a SNaN. */
+
+#if __GNUC_PREREQ(3,3)
+
+# define NAN (__builtin_nanf(""))
+
+#elif defined __GNUC__
+
+# define NAN \
+ (__extension__ \
+ ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) \
+ { __l: 0x7fbfffffUL }).__d)
+
+#else
+
+# include <endian.h>
+
+# if __BYTE_ORDER == __BIG_ENDIAN
+# define __nan_bytes { 0x7f, 0xbf, 0xff, 0xff }
+# endif
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define __nan_bytes { 0xff, 0xff, 0xbf, 0x7f }
+# endif
+
+static union { unsigned char __c[4]; float __d; } __nan_union = { __nan_bytes };
+# define NAN (__nan_union.__d)
+
+#endif /* GCC. */
diff --git a/ports/sysdeps/mips/bits/setjmp.h b/ports/sysdeps/mips/bits/setjmp.h
new file mode 100644
index 000000000..4f159c498
--- /dev/null
+++ b/ports/sysdeps/mips/bits/setjmp.h
@@ -0,0 +1,75 @@
+/* Define the machine-dependent type `jmp_buf'. MIPS version.
+ Copyright (C) 1992,1993,1995,1997,2000,2002,2003,2004,2005,2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MIPS_BITS_SETJMP_H
+#define _MIPS_BITS_SETJMP_H 1
+
+#if !defined(_SETJMP_H) && !defined(_PTHREAD_H)
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+#include <sgidefs.h>
+
+typedef struct
+ {
+#if _MIPS_SIM == _ABIO32
+ /* 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;
+#else
+ /* Program counter. */
+ __extension__ long long __pc;
+
+ /* Stack pointer. */
+ __extension__ long long __sp;
+
+ /* Callee-saved registers s0 through s7. */
+ __extension__ long long __regs[8];
+
+ /* The frame pointer. */
+ __extension__ long long __fp;
+
+ /* The global pointer. */
+ __extension__ long long __gp;
+#endif
+
+ /* Floating point status register. */
+ int __fpc_csr;
+
+ /* Callee-saved floating point registers. */
+#if _MIPS_SIM == _ABI64
+ double __fpregs[8];
+#else
+ double __fpregs[6];
+#endif
+ } __jmp_buf[1];
+
+#endif /* _MIPS_BITS_SETJMP_H */
diff --git a/ports/sysdeps/mips/bits/wordsize.h b/ports/sysdeps/mips/bits/wordsize.h
new file mode 100644
index 000000000..666c7ad07
--- /dev/null
+++ b/ports/sysdeps/mips/bits/wordsize.h
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define __WORDSIZE _MIPS_SZPTR
diff --git a/ports/sysdeps/mips/bsd-_setjmp.S b/ports/sysdeps/mips/bsd-_setjmp.S
new file mode 100644
index 000000000..5e3ad5030
--- /dev/null
+++ b/ports/sysdeps/mips/bsd-_setjmp.S
@@ -0,0 +1,43 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. MIPS version.
+ Copyright (C) 1996, 1997, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 0)'.
+ We cannot do it in C because it must be a tail-call, so frame-unwinding
+ in setjmp doesn't clobber the state restored by longjmp. */
+
+#include <sysdep.h>
+
+#ifdef __PIC__
+ .option pic2
+#endif
+ENTRY (_setjmp)
+#ifdef __PIC__
+ .set noreorder
+ .cpload t9
+ .set reorder
+ la t9, C_SYMBOL_NAME (__sigsetjmp)
+#endif
+ move a1,zero /* Pass a second argument of zero. */
+#ifdef __PIC__
+ jr t9
+#else
+ j C_SYMBOL_NAME (__sigsetjmp)
+#endif
+ .end _setjmp
+libc_hidden_def (_setjmp)
diff --git a/ports/sysdeps/mips/bsd-setjmp.S b/ports/sysdeps/mips/bsd-setjmp.S
new file mode 100644
index 000000000..0aea01132
--- /dev/null
+++ b/ports/sysdeps/mips/bsd-setjmp.S
@@ -0,0 +1,42 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. MIPS version.
+ Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
+ We cannot do it in C because it must be a tail-call, so frame-unwinding
+ in setjmp doesn't clobber the state restored by longjmp. */
+
+#include <sysdep.h>
+
+#ifdef __PIC__
+ .option pic2
+#endif
+ENTRY (setjmp)
+ .set noreorder
+#ifdef __PIC__
+ .cpload t9
+ .set reorder
+ la t9, C_SYMBOL_NAME (__sigsetjmp)
+#endif
+ li a1, 1 /* Pass a second argument of one. */
+#ifdef __PIC__
+ jr t9
+#else
+ j C_SYMBOL_NAME (__sigsetjmp)
+#endif
+ .end setjmp
diff --git a/ports/sysdeps/mips/dl-dtprocnum.h b/ports/sysdeps/mips/dl-dtprocnum.h
new file mode 100644
index 000000000..dfd03ba31
--- /dev/null
+++ b/ports/sysdeps/mips/dl-dtprocnum.h
@@ -0,0 +1,22 @@
+/* Configuration of lookup functions. MIPS version.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Number of extra dynamic section entries for this architecture. By
+ default there are none. */
+#define DT_THISPROCNUM DT_MIPS_NUM
diff --git a/ports/sysdeps/mips/dl-machine.h b/ports/sysdeps/mips/dl-machine.h
new file mode 100644
index 000000000..b91218479
--- /dev/null
+++ b/ports/sysdeps/mips/dl-machine.h
@@ -0,0 +1,607 @@
+/* Machine-dependent ELF dynamic relocation inline functions. MIPS version.
+ Copyright (C) 1996-2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kazumoto Kojima <kkojima@info.kanagawa-u.ac.jp>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* FIXME: Profiling of shared libraries is not implemented yet. */
+#ifndef dl_machine_h
+#define dl_machine_h
+
+#define ELF_MACHINE_NAME "MIPS"
+
+#define ELF_MACHINE_NO_PLT
+
+#include <entry.h>
+
+#ifndef ENTRY_POINT
+#error ENTRY_POINT needs to be defined for MIPS.
+#endif
+
+#include <sgidefs.h>
+#include <sys/asm.h>
+#include <dl-tls.h>
+
+/* The offset of gp from GOT might be system-dependent. It's set by
+ ld. The same value is also */
+#define OFFSET_GP_GOT 0x7ff0
+
+#ifndef _RTLD_PROLOGUE
+# define _RTLD_PROLOGUE(entry) \
+ ".globl\t" __STRING(entry) "\n\t" \
+ ".ent\t" __STRING(entry) "\n\t" \
+ ".type\t" __STRING(entry) ", @function\n" \
+ __STRING(entry) ":\n\t"
+#endif
+
+#ifndef _RTLD_EPILOGUE
+# define _RTLD_EPILOGUE(entry) \
+ ".end\t" __STRING(entry) "\n\t" \
+ ".size\t" __STRING(entry) ", . - " __STRING(entry) "\n\t"
+#endif
+
+/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries.
+ This makes no sense on MIPS but we have to define this to R_MIPS_REL32
+ to avoid the asserts in dl-lookup.c from blowing. */
+#define ELF_MACHINE_JMP_SLOT R_MIPS_REL32
+#define elf_machine_type_class(type) ELF_RTYPE_CLASS_PLT
+
+/* Translate a processor specific dynamic tag to the index
+ in l_info array. */
+#define DT_MIPS(x) (DT_MIPS_##x - DT_LOPROC + DT_NUM)
+
+/* If there is a DT_MIPS_RLD_MAP entry in the dynamic section, fill it in
+ with the run-time address of the r_debug structure */
+#define ELF_MACHINE_DEBUG_SETUP(l,r) \
+do { if ((l)->l_info[DT_MIPS (RLD_MAP)]) \
+ *(ElfW(Addr) *)((l)->l_info[DT_MIPS (RLD_MAP)]->d_un.d_ptr) = \
+ (ElfW(Addr)) (r); \
+ } while (0)
+
+/* Return nonzero iff ELF header is compatible with the running host. */
+static inline int __attribute_used__
+elf_machine_matches_host (const ElfW(Ehdr) *ehdr)
+{
+#if _MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIN32
+ /* Don't link o32 and n32 together. */
+ if (((ehdr->e_flags & EF_MIPS_ABI2) != 0) != (_MIPS_SIM == _ABIN32))
+ return 0;
+#endif
+
+ switch (ehdr->e_machine)
+ {
+ case EM_MIPS:
+ case EM_MIPS_RS3_LE:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static inline ElfW(Addr) *
+elf_mips_got_from_gpreg (ElfW(Addr) gpreg)
+{
+ /* FIXME: the offset of gp from GOT may be system-dependent. */
+ return (ElfW(Addr) *) (gpreg - OFFSET_GP_GOT);
+}
+
+/* Return the link-time address of _DYNAMIC. Conveniently, this is the
+ first element of the GOT. This must be inlined in a function which
+ uses global data. We assume its $gp points to the primary GOT. */
+static inline ElfW(Addr)
+elf_machine_dynamic (void)
+{
+ register ElfW(Addr) gp __asm__ ("$28");
+ return *elf_mips_got_from_gpreg (gp);
+}
+
+#define STRINGXP(X) __STRING(X)
+#define STRINGXV(X) STRINGV_(X)
+#define STRINGV_(...) # __VA_ARGS__
+
+/* Return the run-time load address of the shared object. */
+static inline ElfW(Addr)
+elf_machine_load_address (void)
+{
+ ElfW(Addr) addr;
+ asm (" .set noreorder\n"
+ " " STRINGXP (PTR_LA) " %0, 0f\n"
+ " bltzal $0, 0f\n"
+ " nop\n"
+ "0: " STRINGXP (PTR_SUBU) " %0, $31, %0\n"
+ " .set reorder\n"
+ : "=r" (addr)
+ : /* No inputs */
+ : "$31");
+ return addr;
+}
+
+/* The MSB of got[1] of a gnu object is set to identify gnu objects. */
+#if _MIPS_SIM == _ABI64
+# define ELF_MIPS_GNU_GOT1_MASK 0x8000000000000000L
+#else
+# define ELF_MIPS_GNU_GOT1_MASK 0x80000000L
+#endif
+
+/* We can't rely on elf_machine_got_rel because _dl_object_relocation_scope
+ fiddles with global data. */
+#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info) \
+do { \
+ struct link_map *map = &bootstrap_map; \
+ ElfW(Sym) *sym; \
+ ElfW(Addr) *got; \
+ int i, n; \
+ \
+ got = (ElfW(Addr) *) D_PTR (map, l_info[DT_PLTGOT]); \
+ \
+ if (__builtin_expect (map->l_addr == 0, 1)) \
+ break; \
+ \
+ /* got[0] is reserved. got[1] is also reserved for the dynamic object \
+ generated by gnu ld. Skip these reserved entries from \
+ relocation. */ \
+ i = (got[1] & ELF_MIPS_GNU_GOT1_MASK)? 2 : 1; \
+ n = map->l_info[DT_MIPS (LOCAL_GOTNO)]->d_un.d_val; \
+ \
+ /* Add the run-time displacement to all local got entries. */ \
+ while (i < n) \
+ got[i++] += map->l_addr; \
+ \
+ /* Handle global got entries. */ \
+ got += n; \
+ sym = (ElfW(Sym) *) D_PTR(map, l_info[DT_SYMTAB]) \
+ + map->l_info[DT_MIPS (GOTSYM)]->d_un.d_val; \
+ i = (map->l_info[DT_MIPS (SYMTABNO)]->d_un.d_val \
+ - map->l_info[DT_MIPS (GOTSYM)]->d_un.d_val); \
+ \
+ while (i--) \
+ { \
+ if (sym->st_shndx == SHN_UNDEF || sym->st_shndx == SHN_COMMON) \
+ *got = map->l_addr + sym->st_value; \
+ else if (ELFW(ST_TYPE) (sym->st_info) == STT_FUNC \
+ && *got != sym->st_value) \
+ *got += map->l_addr; \
+ else if (ELFW(ST_TYPE) (sym->st_info) == STT_SECTION) \
+ { \
+ if (sym->st_other == 0) \
+ *got += map->l_addr; \
+ } \
+ else \
+ *got = map->l_addr + sym->st_value; \
+ \
+ got++; \
+ sym++; \
+ } \
+} while(0)
+
+
+/* Mask identifying addresses reserved for the user program,
+ where the dynamic linker should not map anything. */
+#define ELF_MACHINE_USER_ADDRESS_MASK 0x80000000UL
+
+
+/* Initial entry point code for the dynamic linker.
+ The C function `_dl_start' is the real entry point;
+ its return value is the user program's entry point.
+ Note how we have to be careful about two things:
+
+ 1) That we allocate a minimal stack of 24 bytes for
+ every function call, the MIPS ABI states that even
+ if all arguments are passed in registers the procedure
+ called can use the 16 byte area pointed to by $sp
+ when it is called to store away the arguments passed
+ to it.
+
+ 2) That under Linux the entry is named __start
+ and not just plain _start. */
+
+#define RTLD_START asm (\
+ ".text\n\
+ " _RTLD_PROLOGUE(ENTRY_POINT) "\
+ " STRINGXV(SETUP_GPX($25)) "\n\
+ " STRINGXV(SETUP_GPX64($18,$25)) "\n\
+ # i386 ABI book says that the first entry of GOT holds\n\
+ # the address of the dynamic structure. Though MIPS ABI\n\
+ # doesn't say nothing about this, I emulate this here.\n\
+ " STRINGXP(PTR_LA) " $4, _DYNAMIC\n\
+ # Subtract OFFSET_GP_GOT\n\
+ " STRINGXP(PTR_S) " $4, -0x7ff0($28)\n\
+ move $4, $29\n\
+ " STRINGXP(PTR_SUBIU) " $29, 16\n\
+ \n\
+ " STRINGXP(PTR_LA) " $8, .Lcoff\n\
+ bltzal $8, .Lcoff\n\
+.Lcoff: " STRINGXP(PTR_SUBU) " $8, $31, $8\n\
+ \n\
+ " STRINGXP(PTR_LA) " $25, _dl_start\n\
+ " STRINGXP(PTR_ADDU) " $25, $8\n\
+ jalr $25\n\
+ \n\
+ " STRINGXP(PTR_ADDIU) " $29, 16\n\
+ # Get the value of label '_dl_start_user' in t9 ($25).\n\
+ " STRINGXP(PTR_LA) " $25, _dl_start_user\n\
+ " _RTLD_EPILOGUE(ENTRY_POINT) "\
+ \n\
+ \n\
+ " _RTLD_PROLOGUE(_dl_start_user) "\
+ " STRINGXP(SETUP_GP) "\n\
+ " STRINGXV(SETUP_GP64($18,_dl_start_user)) "\n\
+ move $16, $28\n\
+ # Save the user entry point address in a saved register.\n\
+ move $17, $2\n\
+ # See if we were run as a command with the executable file\n\
+ # name as an extra leading argument.\n\
+ lw $2, _dl_skip_args\n\
+ beq $2, $0, 1f\n\
+ # Load the original argument count.\n\
+ " STRINGXP(PTR_L) " $4, 0($29)\n\
+ # Subtract _dl_skip_args from it.\n\
+ subu $4, $2\n\
+ # Adjust the stack pointer to skip _dl_skip_args words.\n\
+ sll $2, " STRINGXP (PTRLOG) "\n\
+ " STRINGXP(PTR_ADDU) " $29, $2\n\
+ # Save back the modified argument count.\n\
+ " STRINGXP(PTR_S) " $4, 0($29)\n\
+1: # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env) \n\
+ " STRINGXP(PTR_L) " $4, _rtld_local\n\
+ " STRINGXP(PTR_L) /* or lw??? fixme */ " $5, 0($29)\n\
+ " STRINGXP(PTR_LA) " $6, " STRINGXP (PTRSIZE) "($29)\n\
+ sll $7, $5, " STRINGXP (PTRLOG) "\n\
+ " STRINGXP(PTR_ADDU) " $7, $7, $6\n\
+ " STRINGXP(PTR_ADDU) " $7, $7, " STRINGXP (PTRSIZE) " \n\
+ # Make sure the stack pointer is aligned for _dl_init_internal.\n\
+ and $2, $29, -2 * " STRINGXP(SZREG) "\n\
+ " STRINGXP(PTR_S) " $29, -" STRINGXP(SZREG) "($2)\n\
+ " STRINGXP(PTR_SUBIU) " $29, $2, 32\n\
+ " STRINGXP(SAVE_GP(16)) "\n\
+ # Call the function to run the initializers.\n\
+ jal _dl_init_internal\n\
+ # Restore the stack pointer for _start.\n\
+ " STRINGXP(PTR_L) " $29, 32-" STRINGXP(SZREG) "($29)\n\
+ # Pass our finalizer function to the user in $2 as per ELF ABI.\n\
+ " STRINGXP(PTR_LA) " $2, _dl_fini\n\
+ # Jump to the user entry point.\n\
+ move $25, $17\n\
+ jr $25\n\t"\
+ _RTLD_EPILOGUE(_dl_start_user)\
+ ".previous"\
+);
+
+/* The MIPS never uses Elfxx_Rela relocations. */
+#define ELF_MACHINE_NO_RELA 1
+
+/* Names of the architecture-specific auditing callback functions. */
+# if _MIPS_SIM == _ABIO32
+# define ARCH_LA_PLTENTER mips_o32_gnu_pltenter
+# define ARCH_LA_PLTEXIT mips_o32_gnu_pltexit
+# elif _MIPS_SIM == _ABIN32
+# define ARCH_LA_PLTENTER mips_n32_gnu_pltenter
+# define ARCH_LA_PLTEXIT mips_n32_gnu_pltexit
+# else
+# define ARCH_LA_PLTENTER mips_n64_gnu_pltenter
+# define ARCH_LA_PLTEXIT mips_n64_gnu_pltexit
+# endif
+
+#endif /* !dl_machine_h */
+
+#ifdef RESOLVE_MAP
+
+/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
+ MAP is the object containing the reloc. */
+
+auto inline void
+__attribute__ ((always_inline))
+elf_machine_rel (struct link_map *map, const ElfW(Rel) *reloc,
+ const ElfW(Sym) *sym, const struct r_found_version *version,
+ void *const reloc_addr)
+{
+ const unsigned long int r_type = ELFW(R_TYPE) (reloc->r_info);
+
+#if !defined RTLD_BOOTSTRAP && !defined SHARED
+ /* This is defined in rtld.c, but nowhere in the static libc.a;
+ make the reference weak so static programs can still link. This
+ declaration cannot be done when compiling rtld.c (i.e. #ifdef
+ RTLD_BOOTSTRAP) because rtld.c contains the common defn for
+ _dl_rtld_map, which is incompatible with a weak decl in the same
+ file. */
+ weak_extern (GL(dl_rtld_map));
+#endif
+
+ switch (r_type)
+ {
+#if defined (USE_TLS) && !defined (RTLD_BOOTSTRAP)
+# if _MIPS_SIM == _ABI64
+ case R_MIPS_TLS_DTPMOD64:
+ case R_MIPS_TLS_DTPREL64:
+ case R_MIPS_TLS_TPREL64:
+# else
+ case R_MIPS_TLS_DTPMOD32:
+ case R_MIPS_TLS_DTPREL32:
+ case R_MIPS_TLS_TPREL32:
+# endif
+ {
+ struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
+
+ switch (r_type)
+ {
+ case R_MIPS_TLS_DTPMOD64:
+ case R_MIPS_TLS_DTPMOD32:
+ if (sym_map)
+ *(ElfW(Addr) *)reloc_addr = sym_map->l_tls_modid;
+ break;
+
+ case R_MIPS_TLS_DTPREL64:
+ case R_MIPS_TLS_DTPREL32:
+ *(ElfW(Addr) *)reloc_addr += TLS_DTPREL_VALUE (sym);
+ break;
+
+ case R_MIPS_TLS_TPREL32:
+ case R_MIPS_TLS_TPREL64:
+ CHECK_STATIC_TLS (map, sym_map);
+ *(ElfW(Addr) *)reloc_addr += TLS_TPREL_VALUE (sym_map, sym);
+ break;
+ }
+
+ break;
+ }
+#endif
+
+#if _MIPS_SIM == _ABI64
+ case (R_MIPS_64 << 8) | R_MIPS_REL32:
+#else
+ case R_MIPS_REL32:
+#endif
+ {
+ int symidx = ELFW(R_SYM) (reloc->r_info);
+ ElfW(Addr) reloc_value;
+
+ /* Support relocations on mis-aligned offsets. Should we ever
+ implement RELA, this should be replaced with an assignment
+ from reloc->r_addend. */
+ __builtin_memcpy (&reloc_value, reloc_addr, sizeof (reloc_value));
+
+ if (symidx)
+ {
+ const ElfW(Word) gotsym
+ = (const ElfW(Word)) map->l_info[DT_MIPS (GOTSYM)]->d_un.d_val;
+
+ if ((ElfW(Word))symidx < gotsym)
+ {
+ /* This wouldn't work for a symbol imported from other
+ libraries for which there's no GOT entry, but MIPS
+ requires every symbol referenced in a dynamic
+ relocation to have a GOT entry in the primary GOT,
+ so we only get here for locally-defined symbols.
+ For section symbols, we should *NOT* be adding
+ sym->st_value (per the definition of the meaning of
+ S in reloc expressions in the ELF64 MIPS ABI),
+ since it should have already been added to
+ reloc_value by the linker, but older versions of
+ GNU ld didn't add it, and newer versions don't emit
+ useless relocations to section symbols any more, so
+ it is safe to keep on adding sym->st_value, even
+ though it's not ABI compliant. Some day we should
+ bite the bullet and stop doing this. */
+#ifndef RTLD_BOOTSTRAP
+ if (map != &GL(dl_rtld_map))
+#endif
+ reloc_value += sym->st_value + map->l_addr;
+ }
+ else
+ {
+#ifndef RTLD_BOOTSTRAP
+ const ElfW(Addr) *got
+ = (const ElfW(Addr) *) D_PTR (map, l_info[DT_PLTGOT]);
+ const ElfW(Word) local_gotno
+ = (const ElfW(Word))
+ map->l_info[DT_MIPS (LOCAL_GOTNO)]->d_un.d_val;
+
+ reloc_value += got[symidx + local_gotno - gotsym];
+#endif
+ }
+ }
+ else
+#ifndef RTLD_BOOTSTRAP
+ if (map != &GL(dl_rtld_map))
+#endif
+ reloc_value += map->l_addr;
+
+ __builtin_memcpy (reloc_addr, &reloc_value, sizeof (reloc_value));
+ }
+ break;
+ case R_MIPS_NONE: /* Alright, Wilbur. */
+ break;
+#if _MIPS_SIM == _ABI64
+ case R_MIPS_64:
+ /* For full compliance with the ELF64 ABI, one must precede the
+ _REL32/_64 pair of relocations with a _64 relocation, such
+ that the in-place addend is read as a 64-bit value. IRIX
+ didn't pick up on this requirement, so we treat the
+ _REL32/_64 relocation as a 64-bit relocation even if it's by
+ itself. For ABI compliance, we ignore such _64 dummy
+ relocations. For RELA, this may be simply removed, since
+ it's totally unnecessary. */
+ if (ELFW(R_SYM) (reloc->r_info) == 0)
+ break;
+ /* Fall through. */
+#endif
+ default:
+ _dl_reloc_bad_type (map, r_type, 0);
+ break;
+ }
+}
+
+auto inline void
+__attribute__((always_inline))
+elf_machine_rel_relative (ElfW(Addr) l_addr, const ElfW(Rel) *reloc,
+ void *const reloc_addr)
+{
+ /* XXX Nothing to do. There is no relative relocation, right? */
+}
+
+auto inline void
+__attribute__((always_inline))
+elf_machine_lazy_rel (struct link_map *map,
+ ElfW(Addr) l_addr, const ElfW(Rel) *reloc)
+{
+ /* Do nothing. */
+}
+
+auto inline void
+__attribute__ ((always_inline))
+elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
+ const ElfW(Sym) *sym, const struct r_found_version *version,
+ void *const reloc_addr)
+{
+}
+
+auto inline void
+__attribute__((always_inline))
+elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
+ void *const reloc_addr)
+{
+}
+
+#ifndef RTLD_BOOTSTRAP
+/* Relocate GOT. */
+auto inline void
+__attribute__((always_inline))
+elf_machine_got_rel (struct link_map *map, int lazy)
+{
+ ElfW(Addr) *got;
+ ElfW(Sym) *sym;
+ const ElfW(Half) *vernum;
+ int i, n, symidx;
+
+#define RESOLVE_GOTSYM(sym,vernum,sym_index) \
+ ({ \
+ const ElfW(Sym) *ref = sym; \
+ const struct r_found_version *version \
+ = vernum ? &map->l_versions[vernum[sym_index] & 0x7fff] : NULL; \
+ struct link_map *sym_map; \
+ sym_map = RESOLVE_MAP (&ref, version, R_MIPS_REL32); \
+ ref ? sym_map->l_addr + ref->st_value : 0; \
+ })
+
+ if (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL)
+ vernum = (const void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
+ else
+ vernum = NULL;
+
+ got = (ElfW(Addr) *) D_PTR (map, l_info[DT_PLTGOT]);
+
+ n = map->l_info[DT_MIPS (LOCAL_GOTNO)]->d_un.d_val;
+ /* The dynamic linker's local got entries have already been relocated. */
+ if (map != &GL(dl_rtld_map))
+ {
+ /* got[0] is reserved. got[1] is also reserved for the dynamic object
+ generated by gnu ld. Skip these reserved entries from relocation. */
+ i = (got[1] & ELF_MIPS_GNU_GOT1_MASK)? 2 : 1;
+
+ /* Add the run-time displacement to all local got entries if
+ needed. */
+ if (__builtin_expect (map->l_addr != 0, 0))
+ {
+ while (i < n)
+ got[i++] += map->l_addr;
+ }
+ }
+
+ /* Handle global got entries. */
+ got += n;
+ /* Keep track of the symbol index. */
+ symidx = map->l_info[DT_MIPS (GOTSYM)]->d_un.d_val;
+ sym = (ElfW(Sym) *) D_PTR (map, l_info[DT_SYMTAB]) + symidx;
+ i = (map->l_info[DT_MIPS (SYMTABNO)]->d_un.d_val
+ - map->l_info[DT_MIPS (GOTSYM)]->d_un.d_val);
+
+ /* This loop doesn't handle Quickstart. */
+ while (i--)
+ {
+ if (sym->st_shndx == SHN_UNDEF)
+ {
+ if (ELFW(ST_TYPE) (sym->st_info) == STT_FUNC
+ && sym->st_value && lazy)
+ *got = sym->st_value + map->l_addr;
+ else
+ *got = RESOLVE_GOTSYM (sym, vernum, symidx);
+ }
+ else if (sym->st_shndx == SHN_COMMON)
+ *got = RESOLVE_GOTSYM (sym, vernum, symidx);
+ else if (ELFW(ST_TYPE) (sym->st_info) == STT_FUNC
+ && *got != sym->st_value
+ && lazy)
+ *got += map->l_addr;
+ else if (ELFW(ST_TYPE) (sym->st_info) == STT_SECTION)
+ {
+ if (sym->st_other == 0)
+ *got += map->l_addr;
+ }
+ else
+ *got = RESOLVE_GOTSYM (sym, vernum, symidx);
+
+ ++got;
+ ++sym;
+ ++symidx;
+ }
+
+#undef RESOLVE_GOTSYM
+}
+#endif
+
+/* Set up the loaded object described by L so its stub function
+ will jump to the on-demand fixup code __dl_runtime_resolve. */
+
+auto inline int
+__attribute__((always_inline))
+elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
+{
+# ifndef RTLD_BOOTSTRAP
+ ElfW(Addr) *got;
+ extern void _dl_runtime_resolve (ElfW(Word));
+ extern int _dl_mips_gnu_objects;
+
+ if (lazy)
+ {
+ /* The GOT entries for functions have not yet been filled in.
+ Their initial contents will arrange when called to put an
+ offset into the .dynsym section in t8, the return address
+ in t7 and then jump to _GLOBAL_OFFSET_TABLE[0]. */
+ got = (ElfW(Addr) *) D_PTR (l, l_info[DT_PLTGOT]);
+
+ /* This function will get called to fix up the GOT entry indicated by
+ the register t8, and then jump to the resolved address. */
+ got[0] = (ElfW(Addr)) &_dl_runtime_resolve;
+
+ /* Store l to _GLOBAL_OFFSET_TABLE[1] for gnu object. The MSB
+ of got[1] of a gnu object is set to identify gnu objects.
+ Where we can store l for non gnu objects? XXX */
+ if ((got[1] & ELF_MIPS_GNU_GOT1_MASK) != 0)
+ got[1] = ((ElfW(Addr)) l | ELF_MIPS_GNU_GOT1_MASK);
+ else
+ _dl_mips_gnu_objects = 0;
+ }
+
+ /* Relocate global offset table. */
+ elf_machine_got_rel (l, lazy);
+
+# endif
+ return lazy;
+}
+
+#endif /* RESOLVE_MAP */
diff --git a/ports/sysdeps/mips/dl-tls.h b/ports/sysdeps/mips/dl-tls.h
new file mode 100644
index 000000000..6d3ed6f5a
--- /dev/null
+++ b/ports/sysdeps/mips/dl-tls.h
@@ -0,0 +1,46 @@
+/* Thread-local storage handling in the ELF dynamic linker. MIPS version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+/* Type used for the representation of TLS information in the GOT. */
+typedef struct
+{
+ unsigned long int ti_module;
+ unsigned long int ti_offset;
+} tls_index;
+
+/* The thread pointer points 0x7000 past the first static TLS block. */
+#define TLS_TP_OFFSET 0x7000
+
+/* Dynamic thread vector pointers point 0x8000 past the start of each
+ TLS block. */
+#define TLS_DTV_OFFSET 0x8000
+
+/* Compute the value for a GOTTPREL reloc. */
+#define TLS_TPREL_VALUE(sym_map, sym) \
+ ((sym_map)->l_tls_offset + (sym)->st_value - TLS_TP_OFFSET)
+
+/* Compute the value for a DTPREL reloc. */
+#define TLS_DTPREL_VALUE(sym) \
+ ((sym)->st_value - TLS_DTV_OFFSET)
+
+extern void *__tls_get_addr (tls_index *ti);
+
+# define GET_ADDR_OFFSET (ti->ti_offset + TLS_DTV_OFFSET)
+# define __TLS_GET_ADDR(__ti) (__tls_get_addr (__ti) - TLS_DTV_OFFSET)
diff --git a/ports/sysdeps/mips/dl-trampoline.c b/ports/sysdeps/mips/dl-trampoline.c
new file mode 100644
index 000000000..459adf9a8
--- /dev/null
+++ b/ports/sysdeps/mips/dl-trampoline.c
@@ -0,0 +1,272 @@
+/* PLT trampoline. MIPS version.
+ Copyright (C) 1996-2001, 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kazumoto Kojima <kkojima@info.kanagawa-u.ac.jp>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* FIXME: Profiling of shared libraries is not implemented yet. */
+
+#include <sysdep.h>
+#include <link.h>
+#include <elf.h>
+#include <ldsodefs.h>
+#include <dl-machine.h>
+
+/* Get link map for callers object containing STUB_PC. */
+static inline struct link_map *
+elf_machine_runtime_link_map (ElfW(Addr) gpreg, ElfW(Addr) stub_pc)
+{
+ extern int _dl_mips_gnu_objects;
+
+ /* got[1] is reserved to keep its link map address for the shared
+ object generated by the gnu linker. If all are such objects, we
+ can find the link map from current GPREG simply. If not so, get
+ the link map for caller's object containing STUB_PC. */
+
+ if (_dl_mips_gnu_objects)
+ {
+ ElfW(Addr) *got = elf_mips_got_from_gpreg (gpreg);
+ ElfW(Word) g1;
+
+ g1 = ((ElfW(Word) *) got)[1];
+
+ if ((g1 & ELF_MIPS_GNU_GOT1_MASK) != 0)
+ {
+ struct link_map *l =
+ (struct link_map *) (g1 & ~ELF_MIPS_GNU_GOT1_MASK);
+ ElfW(Addr) base, limit;
+ const ElfW(Phdr) *p = l->l_phdr;
+ ElfW(Half) this, nent = l->l_phnum;
+
+ /* For the common case of a stub being called from the containing
+ object, STUB_PC will point to somewhere within the object that
+ is described by the link map fetched via got[1]. Otherwise we
+ have to scan all maps. */
+ for (this = 0; this < nent; this++)
+ {
+ if (p[this].p_type == PT_LOAD)
+ {
+ base = p[this].p_vaddr + l->l_addr;
+ limit = base + p[this].p_memsz;
+ if (stub_pc >= base && stub_pc < limit)
+ return l;
+ }
+ }
+ }
+ }
+
+ struct link_map *l;
+ Lmid_t nsid;
+
+ for (nsid = 0; nsid < DL_NNS; ++nsid)
+ for (l = GL(dl_ns)[nsid]._ns_loaded; l != NULL; l = l->l_next)
+ {
+ ElfW(Addr) base, limit;
+ const ElfW(Phdr) *p = l->l_phdr;
+ ElfW(Half) this, nent = l->l_phnum;
+
+ for (this = 0; this < nent; ++this)
+ {
+ if (p[this].p_type == PT_LOAD)
+ {
+ base = p[this].p_vaddr + l->l_addr;
+ limit = base + p[this].p_memsz;
+ if (stub_pc >= base && stub_pc < limit)
+ return l;
+ }
+ }
+ }
+
+ _dl_signal_error (0, NULL, NULL, "cannot find runtime link map");
+ return NULL;
+}
+
+/* Define mips specific runtime resolver. The function __dl_runtime_resolve
+ is called from assembler function _dl_runtime_resolve which converts
+ special argument registers t7 ($15) and t8 ($24):
+ t7 address to return to the caller of the function
+ t8 index for this function symbol in .dynsym
+ to usual c arguments.
+
+ Other architectures call fixup from dl-runtime.c in
+ _dl_runtime_resolve. MIPS instead calls __dl_runtime_resolve. We
+ have to use our own version because of the way the got section is
+ treated on MIPS (we've also got ELF_MACHINE_PLT defined). */
+
+/* The flag _dl_mips_gnu_objects is set if all dynamic objects are
+ generated by the gnu linker. */
+int _dl_mips_gnu_objects = 1;
+
+#define VERSYMIDX(sym) (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (sym))
+
+/* This is called from assembly stubs below which the compiler can't see. */
+static ElfW(Addr)
+__dl_runtime_resolve (ElfW(Word), ElfW(Word), ElfW(Addr), ElfW(Addr))
+ __attribute_used__;
+
+static ElfW(Addr)
+__dl_runtime_resolve (ElfW(Word) sym_index,
+ ElfW(Word) return_address,
+ ElfW(Addr) old_gpreg,
+ ElfW(Addr) stub_pc)
+{
+ struct link_map *l = elf_machine_runtime_link_map (old_gpreg, stub_pc);
+ const ElfW(Sym) *const symtab
+ = (const ElfW(Sym) *) D_PTR (l, l_info[DT_SYMTAB]);
+ const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
+ ElfW(Addr) *got
+ = (ElfW(Addr) *) D_PTR (l, l_info[DT_PLTGOT]);
+ const ElfW(Word) local_gotno
+ = (const ElfW(Word)) l->l_info[DT_MIPS (LOCAL_GOTNO)]->d_un.d_val;
+ const ElfW(Word) gotsym
+ = (const ElfW(Word)) l->l_info[DT_MIPS (GOTSYM)]->d_un.d_val;
+ const ElfW(Sym) *sym = &symtab[sym_index];
+ struct link_map *sym_map;
+ ElfW(Addr) value;
+
+ /* FIXME: The symbol versioning stuff is not tested yet. */
+ if (__builtin_expect (ELFW(ST_VISIBILITY) (sym->st_other), 0) == 0)
+ {
+ switch (l->l_info[VERSYMIDX (DT_VERSYM)] != NULL)
+ {
+ default:
+ {
+ const ElfW(Half) *vernum =
+ (const void *) D_PTR (l, l_info[VERSYMIDX (DT_VERSYM)]);
+ ElfW(Half) ndx = vernum[sym_index] & 0x7fff;
+ const struct r_found_version *version = &l->l_versions[ndx];
+
+ if (version->hash != 0)
+ {
+ sym_map = _dl_lookup_symbol_x (strtab + sym->st_name, l,
+ &sym, l->l_scope, version,
+ ELF_RTYPE_CLASS_PLT, 0, 0);
+ break;
+ }
+ /* Fall through. */
+ }
+ case 0:
+ sym_map = _dl_lookup_symbol_x (strtab + sym->st_name, l, &sym,
+ l->l_scope, 0, ELF_RTYPE_CLASS_PLT,
+ DL_LOOKUP_ADD_DEPENDENCY, 0);
+ }
+
+ /* Currently value contains the base load address of the object
+ that defines sym. Now add in the symbol offset. */
+ value = (sym ? sym_map->l_addr + sym->st_value : 0);
+ }
+ else
+ /* We already found the symbol. The module (and therefore its load
+ address) is also known. */
+ value = l->l_addr + sym->st_value;
+
+ /* Apply the relocation with that value. */
+ *(got + local_gotno + sym_index - gotsym) = value;
+
+ return value;
+}
+
+#if _MIPS_SIM == _ABIO32
+#define ELF_DL_FRAME_SIZE 40
+
+#define ELF_DL_SAVE_ARG_REGS "\
+ sw $15, 36($29)\n \
+ sw $4, 16($29)\n \
+ sw $5, 20($29)\n \
+ sw $6, 24($29)\n \
+ sw $7, 28($29)\n \
+"
+
+#define ELF_DL_RESTORE_ARG_REGS "\
+ lw $31, 36($29)\n \
+ lw $4, 16($29)\n \
+ lw $5, 20($29)\n \
+ lw $6, 24($29)\n \
+ lw $7, 28($29)\n \
+"
+
+#define IFABIO32(X) X
+
+#else /* _MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64 */
+
+#define ELF_DL_FRAME_SIZE 80
+
+#define ELF_DL_SAVE_ARG_REGS "\
+ sd $15, 72($29)\n \
+ sd $4, 8($29)\n \
+ sd $5, 16($29)\n \
+ sd $6, 24($29)\n \
+ sd $7, 32($29)\n \
+ sd $8, 40($29)\n \
+ sd $9, 48($29)\n \
+ sd $10, 56($29)\n \
+ sd $11, 64($29)\n \
+"
+
+#define ELF_DL_RESTORE_ARG_REGS "\
+ ld $31, 72($29)\n \
+ ld $4, 8($29)\n \
+ ld $5, 16($29)\n \
+ ld $6, 24($29)\n \
+ ld $7, 32($29)\n \
+ ld $8, 40($29)\n \
+ ld $9, 48($29)\n \
+ ld $10, 56($29)\n \
+ ld $11, 64($29)\n \
+"
+
+#define IFABIO32(X)
+
+#endif
+
+asm ("\n\
+ .text\n\
+ .align 2\n\
+ .globl _dl_runtime_resolve\n\
+ .type _dl_runtime_resolve,@function\n\
+ .ent _dl_runtime_resolve\n\
+_dl_runtime_resolve:\n\
+ .frame $29, " STRINGXP(ELF_DL_FRAME_SIZE) ", $31\n\
+ .set noreorder\n\
+ # Save GP.\n\
+ move $3, $28\n\
+ # Save arguments and sp value in stack.\n\
+ " STRINGXP(PTR_SUBIU) " $29, " STRINGXP(ELF_DL_FRAME_SIZE) "\n\
+ # Modify t9 ($25) so as to point .cpload instruction.\n\
+ " IFABIO32(STRINGXP(PTR_ADDIU) " $25, 12\n") "\
+ # Compute GP.\n\
+ " STRINGXP(SETUP_GP) "\n\
+ " STRINGXV(SETUP_GP64 (0, _dl_runtime_resolve)) "\n\
+ .set reorder\n\
+ # Save slot call pc.\n\
+ move $2, $31\n\
+ " IFABIO32(STRINGXP(CPRESTORE(32))) "\n\
+ " ELF_DL_SAVE_ARG_REGS "\
+ move $4, $24\n\
+ move $5, $15\n\
+ move $6, $3\n\
+ move $7, $2\n\
+ jal __dl_runtime_resolve\n\
+ " ELF_DL_RESTORE_ARG_REGS "\
+ " STRINGXP(RESTORE_GP64) "\n\
+ " STRINGXP(PTR_ADDIU) " $29, " STRINGXP(ELF_DL_FRAME_SIZE) "\n\
+ move $25, $2\n\
+ jr $25\n\
+ .end _dl_runtime_resolve\n\
+ .previous\n\
+");
diff --git a/ports/sysdeps/mips/elf/configure b/ports/sysdeps/mips/elf/configure
new file mode 100644
index 000000000..3d90a1e42
--- /dev/null
+++ b/ports/sysdeps/mips/elf/configure
@@ -0,0 +1,46 @@
+# This file is generated from configure.in by Autoconf. DO NOT EDIT!
+ # Local configure fragment for sysdeps/mips/elf.
+
+if test "$usetls" != no; then
+# Check for support of thread-local storage handling in assembler and
+# linker.
+echo "$as_me:$LINENO: checking for MIPS TLS support" >&5
+echo $ECHO_N "checking for MIPS TLS support... $ECHO_C" >&6
+if test "${libc_cv_mips_tls+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat > conftest.s <<\EOF
+ .section ".tdata", "awT", %progbits
+ .globl foo
+foo: .long 1
+ .section ".tbss", "awT", %nobits
+ .globl bar
+bar: .skip 4
+ .text
+
+ lw $25, %call16(__tls_get_addr)($28)
+ jalr $25
+ addiu $4, $28, %tlsgd(x)
+EOF
+if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ libc_cv_mips_tls=yes
+else
+ libc_cv_mips_tls=no
+fi
+rm -f conftest*
+fi
+echo "$as_me:$LINENO: result: $libc_cv_mips_tls" >&5
+echo "${ECHO_T}$libc_cv_mips_tls" >&6
+if test $libc_cv_mips_tls = yes; then
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_TLS_SUPPORT 1
+_ACEOF
+
+fi
+fi
+
diff --git a/ports/sysdeps/mips/elf/configure.in b/ports/sysdeps/mips/elf/configure.in
new file mode 100644
index 000000000..ecb9108c1
--- /dev/null
+++ b/ports/sysdeps/mips/elf/configure.in
@@ -0,0 +1,35 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/mips/elf.
+
+if test "$usetls" != no; then
+# Check for support of thread-local storage handling in assembler and
+# linker.
+AC_CACHE_CHECK(for MIPS TLS support, libc_cv_mips_tls, [dnl
+cat > conftest.s <<\EOF
+ .section ".tdata", "awT", %progbits
+ .globl foo
+foo: .long 1
+ .section ".tbss", "awT", %nobits
+ .globl bar
+bar: .skip 4
+ .text
+
+ lw $25, %call16(__tls_get_addr)($28)
+ jalr $25
+ addiu $4, $28, %tlsgd(x)
+EOF
+dnl
+if AC_TRY_COMMAND(${CC-cc} -c $CFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
+ libc_cv_mips_tls=yes
+else
+ libc_cv_mips_tls=no
+fi
+rm -f conftest*])
+if test $libc_cv_mips_tls = yes; then
+ AC_DEFINE(HAVE_TLS_SUPPORT)
+fi
+fi
+
+dnl No MIPS GCC supports accessing static and hidden symbols in an
+dnl position independent way.
+dnl AC_DEFINE(PI_STATIC_AND_HIDDEN)
diff --git a/ports/sysdeps/mips/elf/ldsodefs.h b/ports/sysdeps/mips/elf/ldsodefs.h
new file mode 100644
index 000000000..3868b50ff
--- /dev/null
+++ b/ports/sysdeps/mips/elf/ldsodefs.h
@@ -0,0 +1,109 @@
+/* Run-time dynamic linker data structures for loaded ELF shared objects.
+ Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MIPS_LDSODEFS_H
+#define _MIPS_LDSODEFS_H
+
+/* The MIPS ABI specifies that the dynamic section has to be read-only. */
+
+#define DL_RO_DYN_SECTION 1
+
+#include_next <ldsodefs.h>
+
+/* The 64-bit MIPS ELF ABI uses an unusual reloc format. Each
+ relocation entry specifies up to three actual relocations, all at
+ the same address. The first relocation which required a symbol
+ uses the symbol in the r_sym field. The second relocation which
+ requires a symbol uses the symbol in the r_ssym field. If all
+ three relocations require a symbol, the third one uses a zero
+ value.
+
+ We define these structures in internal headers because we're not
+ sure we want to make them part of the ABI yet. Eventually, some of
+ this may move into elf/elf.h. */
+
+/* An entry in a 64 bit SHT_REL section. */
+
+typedef struct
+{
+ Elf32_Word r_sym; /* Symbol index */
+ unsigned char r_ssym; /* Special symbol for 2nd relocation */
+ unsigned char r_type3; /* 3rd relocation type */
+ unsigned char r_type2; /* 2nd relocation type */
+ unsigned char r_type1; /* 1st relocation type */
+} _Elf64_Mips_R_Info;
+
+typedef union
+{
+ Elf64_Xword r_info_number;
+ _Elf64_Mips_R_Info r_info_fields;
+} _Elf64_Mips_R_Info_union;
+
+typedef struct
+{
+ Elf64_Addr r_offset; /* Address */
+ _Elf64_Mips_R_Info_union r_info; /* Relocation type and symbol index */
+} Elf64_Mips_Rel;
+
+typedef struct
+{
+ Elf64_Addr r_offset; /* Address */
+ _Elf64_Mips_R_Info_union r_info; /* Relocation type and symbol index */
+ Elf64_Sxword r_addend; /* Addend */
+} Elf64_Mips_Rela;
+
+#define ELF64_MIPS_R_SYM(i) \
+ ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym)
+#define ELF64_MIPS_R_TYPE(i) \
+ (((_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1 \
+ | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
+ ).r_info_fields.r_type2 << 8) \
+ | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
+ ).r_info_fields.r_type3 << 16) \
+ | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
+ ).r_info_fields.r_ssym << 24))
+#define ELF64_MIPS_R_INFO(sym, type) \
+ (__extension__ (_Elf64_Mips_R_Info_union) \
+ (__extension__ (_Elf64_Mips_R_Info) \
+ { (sym), ELF64_MIPS_R_SSYM (type), \
+ ELF64_MIPS_R_TYPE3 (type), \
+ ELF64_MIPS_R_TYPE2 (type), \
+ ELF64_MIPS_R_TYPE1 (type) \
+ }).r_info_number)
+/* These macros decompose the value returned by ELF64_MIPS_R_TYPE, and
+ compose it back into a value that it can be used as an argument to
+ ELF64_MIPS_R_INFO. */
+#define ELF64_MIPS_R_SSYM(i) (((i) >> 24) & 0xff)
+#define ELF64_MIPS_R_TYPE3(i) (((i) >> 16) & 0xff)
+#define ELF64_MIPS_R_TYPE2(i) (((i) >> 8) & 0xff)
+#define ELF64_MIPS_R_TYPE1(i) ((i) & 0xff)
+#define ELF64_MIPS_R_TYPEENC(type1, type2, type3, ssym) \
+ ((type1) \
+ | ((Elf32_Word)(type2) << 8) \
+ | ((Elf32_Word)(type3) << 16) \
+ | ((Elf32_Word)(ssym) << 24))
+
+#undef ELF64_R_SYM
+#define ELF64_R_SYM(i) ELF64_MIPS_R_SYM (i)
+#undef ELF64_R_TYPE
+#define ELF64_R_TYPE(i) ELF64_MIPS_R_TYPE (i)
+#undef ELF64_R_INFO
+#define ELF64_R_INFO(sym, type) ELF64_MIPS_R_INFO ((sym), (type))
+
+#endif
diff --git a/ports/sysdeps/mips/elf/start.S b/ports/sysdeps/mips/elf/start.S
new file mode 100644
index 000000000..d9cc3b7ee
--- /dev/null
+++ b/ports/sysdeps/mips/elf/start.S
@@ -0,0 +1,119 @@
+/* Startup code compliant to the ELF Mips ABI.
+ Copyright (C) 1995, 1997, 2000, 2001, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define __ASSEMBLY__ 1
+#include <entry.h>
+#include <sgidefs.h>
+#include <sys/asm.h>
+
+#ifndef ENTRY_POINT
+#error ENTRY_POINT needs to be defined for start.S on MIPS/ELF.
+#endif
+
+/* This is the canonical entry point, usually the first thing in the text
+ segment. The SVR4/Mips ABI (pages 3-31, 3-32) says that when the entry
+ point runs, most registers' values are unspecified, except for:
+
+ v0 ($2) Contains a function pointer to be registered with `atexit'.
+ This is how the dynamic linker arranges to have DT_FINI
+ functions called for shared libraries that have been loaded
+ before this code runs.
+
+ sp ($29) The stack contains the arguments and environment:
+ 0(%esp) argc
+ 4(%esp) argv[0]
+ ...
+ (4*argc)(%esp) NULL
+ (4*(argc+1))(%esp) envp[0]
+ ...
+ NULL
+ ra ($31) The return address register is set to zero so that programs
+ that search backword through stack frames recognize the last
+ stack frame.
+*/
+
+
+/* We need to call:
+ __libc_start_main (int (*main) (int, char **, char **), int argc,
+ char **argv, void (*init) (void), void (*fini) (void),
+ void (*rtld_fini) (void), void *stack_end)
+*/
+
+ .text
+ .globl ENTRY_POINT
+ .type ENTRY_POINT,@function
+ENTRY_POINT:
+#ifdef __PIC__
+ SETUP_GPX($0)
+ SETUP_GPX64($25,$0)
+#else
+ PTR_LA $28, _gp /* Setup GP correctly if we're non-PIC. */
+ move $31, $0
+#endif
+
+ PTR_LA $4, main /* main */
+ PTR_L $5, 0($29) /* argc */
+ PTR_ADDIU $6, $29, PTRSIZE /* argv */
+
+ /* Allocate space on the stack for seven arguments (o32 only)
+ and make sure the stack is aligned to double words (8 bytes)
+ on o32 and quad words (16 bytes) on n32 and n64. */
+
+ and $29, -2 * SZREG
+#if _MIPS_SIM == _ABIO32
+ PTR_SUBIU $29, 32
+#endif
+ PTR_LA $7, __libc_csu_init /* init */
+ PTR_LA $8, __libc_csu_fini
+#if _MIPS_SIM == _ABIO32
+ PTR_S $8, 16($29) /* fini */
+ PTR_S $2, 20($29) /* rtld_fini */
+ PTR_S $29, 24($29) /* stack_end */
+#else
+ move $9, $2 /* rtld_fini */
+ move $10, $29 /* stack_end */
+#endif
+ jal __libc_start_main
+hlt: b hlt /* Crash if somehow it does return. */
+
+/* Define a symbol for the first piece of initialized data. */
+ .data
+ .globl __data_start
+__data_start:
+ .long 0
+ .weak data_start
+ data_start = __data_start
diff --git a/ports/sysdeps/mips/fpregdef.h b/ports/sysdeps/mips/fpregdef.h
new file mode 100644
index 000000000..6f76d1183
--- /dev/null
+++ b/ports/sysdeps/mips/fpregdef.h
@@ -0,0 +1,24 @@
+/* Copyright (C) 1991, 92, 94, 95, 96 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FPREGDEF_H
+#define _FPREGDEF_H
+
+#include <sys/fpregdef.h>
+
+#endif /* _FPREGDEF_H */
diff --git a/ports/sysdeps/mips/fpu/e_sqrt.c b/ports/sysdeps/mips/fpu/e_sqrt.c
new file mode 100644
index 000000000..5449710af
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/e_sqrt.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Hartvig Ekner <hartvige@mips.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+#include <sgidefs.h>
+
+
+#if (_MIPS_ISA >= _MIPS_ISA_MIPS2)
+
+double
+__ieee754_sqrt (double x)
+{
+ double z;
+ __asm__ ("sqrt.d %0,%1" : "=f" (z) : "f" (x));
+ return z;
+}
+
+#else
+
+#include <sysdeps/ieee754/dbl-64/e_sqrt.c>
+
+#endif
diff --git a/ports/sysdeps/mips/fpu/e_sqrtf.c b/ports/sysdeps/mips/fpu/e_sqrtf.c
new file mode 100644
index 000000000..3590ad46d
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/e_sqrtf.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Hartvig Ekner <hartvige@mips.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+#include <sgidefs.h>
+
+
+#if (_MIPS_ISA >= _MIPS_ISA_MIPS2)
+
+float
+__ieee754_sqrtf (float x)
+{
+ float z;
+ __asm__ ("sqrt.s %0,%1" : "=f" (z) : "f" (x));
+ return z;
+}
+
+#else
+
+#include <sysdeps/ieee754/flt-32/e_sqrtf.c>
+
+#endif
+
diff --git a/ports/sysdeps/mips/fpu/fclrexcpt.c b/ports/sysdeps/mips/fpu/fclrexcpt.c
new file mode 100644
index 000000000..f773312b3
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/fclrexcpt.c
@@ -0,0 +1,47 @@
+/* Clear given exceptions in current floating-point environment.
+ Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fenv_libc.h>
+#include <fpu_control.h>
+
+int
+feclearexcept (int excepts)
+{
+ int cw;
+
+ /* Mask out unsupported bits/exceptions. */
+ excepts &= FE_ALL_EXCEPT;
+
+ /* Read the complete control word. */
+ _FPU_GETCW (cw);
+
+ /* Clear exception flag bits and cause bits. If the cause bit is not
+ cleared, the next CTC instruction (just below) will re-generate the
+ exception. */
+
+ cw &= ~(excepts | (excepts << CAUSE_SHIFT));
+
+ /* Put the new data in effect. */
+ _FPU_SETCW (cw);
+
+ /* Success. */
+ return 0;
+}
diff --git a/ports/sysdeps/mips/fpu/fedisblxcpt.c b/ports/sysdeps/mips/fpu/fedisblxcpt.c
new file mode 100644
index 000000000..62e1a7130
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/fedisblxcpt.c
@@ -0,0 +1,42 @@
+/* Disable floating-point exceptions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fenv_libc.h>
+#include <fpu_control.h>
+
+int
+fedisableexcept (int excepts)
+{
+ unsigned int new_exc, old_exc;
+
+ /* Get the current control word. */
+ _FPU_GETCW (new_exc);
+
+ old_exc = (new_exc & ENABLE_MASK) >> ENABLE_SHIFT;
+
+ excepts &= FE_ALL_EXCEPT;
+
+ new_exc &= ~(excepts << ENABLE_SHIFT);
+ new_exc &= ~_FPU_RESERVED;
+ _FPU_SETCW (new_exc);
+
+ return old_exc;
+}
diff --git a/ports/sysdeps/mips/fpu/feenablxcpt.c b/ports/sysdeps/mips/fpu/feenablxcpt.c
new file mode 100644
index 000000000..4c285811d
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/feenablxcpt.c
@@ -0,0 +1,42 @@
+/* Enable floating-point exceptions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fenv_libc.h>
+#include <fpu_control.h>
+
+int
+feenableexcept (int excepts)
+{
+ unsigned int new_exc, old_exc;
+
+ /* Get the current control word. */
+ _FPU_GETCW (new_exc);
+
+ old_exc = (new_exc & ENABLE_MASK) >> ENABLE_SHIFT;
+
+ excepts &= FE_ALL_EXCEPT;
+
+ new_exc |= excepts << ENABLE_SHIFT;
+ new_exc &= ~_FPU_RESERVED;
+ _FPU_SETCW (new_exc);
+
+ return old_exc;
+}
diff --git a/ports/sysdeps/mips/fpu/fegetenv.c b/ports/sysdeps/mips/fpu/fegetenv.c
new file mode 100644
index 000000000..c1741385f
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/fegetenv.c
@@ -0,0 +1,31 @@
+/* Store current floating-point environment.
+ Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fegetenv (fenv_t *envp)
+{
+ _FPU_GETCW (*envp);
+
+ /* Success. */
+ return 0;
+}
diff --git a/ports/sysdeps/mips/fpu/fegetexcept.c b/ports/sysdeps/mips/fpu/fegetexcept.c
new file mode 100644
index 000000000..14b124129
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/fegetexcept.c
@@ -0,0 +1,34 @@
+/* Get enabled floating-point exceptions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fenv_libc.h>
+#include <fpu_control.h>
+
+int
+fegetexcept (void)
+{
+ unsigned int exc;
+
+ /* Get the current control word. */
+ _FPU_GETCW (exc);
+
+ return (exc & ENABLE_MASK) >> ENABLE_SHIFT;
+}
diff --git a/ports/sysdeps/mips/fpu/fegetround.c b/ports/sysdeps/mips/fpu/fegetround.c
new file mode 100644
index 000000000..efb1ba0dc
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/fegetround.c
@@ -0,0 +1,33 @@
+/* Return current rounding direction.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fegetround (void)
+{
+ int cw;
+
+ /* Get control word. */
+ _FPU_GETCW (cw);
+
+ return cw & 0x3;
+}
diff --git a/ports/sysdeps/mips/fpu/feholdexcpt.c b/ports/sysdeps/mips/fpu/feholdexcpt.c
new file mode 100644
index 000000000..02ddc1b03
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/feholdexcpt.c
@@ -0,0 +1,40 @@
+/* Store current floating-point environment and clear exceptions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+feholdexcept (fenv_t *envp)
+{
+ fpu_control_t cw;
+
+ /* Save the current state. */
+ _FPU_GETCW (cw);
+ envp->__fp_control_register = cw;
+
+ /* Clear all exception enable bits and flags. */
+ cw &= ~(_FPU_MASK_V|_FPU_MASK_Z|_FPU_MASK_O|_FPU_MASK_U|_FPU_MASK_I|FE_ALL_EXCEPT);
+ _FPU_SETCW (cw);
+
+ return 0;
+}
+
+libm_hidden_def (feholdexcept)
diff --git a/ports/sysdeps/mips/fpu/fenv_libc.h b/ports/sysdeps/mips/fpu/fenv_libc.h
new file mode 100644
index 000000000..d971d2c71
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/fenv_libc.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FENV_LIBC_H
+#define _FENV_LIBC_H 1
+
+/* Mask for enabling exceptions and for the CAUSE bits. */
+#define ENABLE_MASK 0x00F80U
+#define CAUSE_MASK 0x1F000U
+
+/* Shift for FE_* flags to get up to the ENABLE bits and the CAUSE bits. */
+#define ENABLE_SHIFT 5
+#define CAUSE_SHIFT 10
+
+
+#endif /* _FENV_LIBC_H */
diff --git a/ports/sysdeps/mips/fpu/fesetenv.c b/ports/sysdeps/mips/fpu/fesetenv.c
new file mode 100644
index 000000000..b71a877ae
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/fesetenv.c
@@ -0,0 +1,43 @@
+/* Install given floating-point environment.
+ Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fesetenv (const fenv_t *envp)
+{
+ fpu_control_t cw;
+
+ /* Read first current state to flush fpu pipeline. */
+ _FPU_GETCW (cw);
+
+ if (envp == FE_DFL_ENV)
+ _FPU_SETCW (_FPU_DEFAULT);
+ else if (envp == FE_NOMASK_ENV)
+ _FPU_SETCW (_FPU_IEEE);
+ else
+ _FPU_SETCW (envp->__fp_control_register);
+
+ /* Success. */
+ return 0;
+}
+
+libm_hidden_def (fesetenv)
diff --git a/ports/sysdeps/mips/fpu/fesetround.c b/ports/sysdeps/mips/fpu/fesetround.c
new file mode 100644
index 000000000..94771092c
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/fesetround.c
@@ -0,0 +1,45 @@
+/* Set current rounding direction.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fesetround (int round)
+{
+ unsigned short int cw;
+
+ if ((round & ~0x3) != 0)
+ /* ROUND is no valid rounding mode. */
+ return 1;
+
+ /* Get current state. */
+ _FPU_GETCW (cw);
+
+ /* Set rounding bits. */
+ cw &= ~0x3;
+ cw |= round;
+ /* Set new state. */
+ _FPU_SETCW (cw);
+
+ return 0;
+}
+
+libm_hidden_def (fesetround)
diff --git a/ports/sysdeps/mips/fpu/feupdateenv.c b/ports/sysdeps/mips/fpu/feupdateenv.c
new file mode 100644
index 000000000..20b20e14c
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/feupdateenv.c
@@ -0,0 +1,43 @@
+/* Install given floating-point environment and raise exceptions.
+ Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+feupdateenv (const fenv_t *envp)
+{
+ int temp;
+
+ /* Save current exceptions. */
+ _FPU_GETCW (temp);
+ temp &= FE_ALL_EXCEPT;
+
+ /* Install new environment. */
+ fesetenv (envp);
+
+ /* Raise the safed exception. Incidently for us the implementation
+ defined format of the values in objects of type fexcept_t is the
+ same as the ones specified using the FE_* constants. */
+ feraiseexcept (temp);
+
+ /* Success. */
+ return 0;
+}
diff --git a/ports/sysdeps/mips/fpu/fgetexcptflg.c b/ports/sysdeps/mips/fpu/fgetexcptflg.c
new file mode 100644
index 000000000..341215981
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/fgetexcptflg.c
@@ -0,0 +1,40 @@
+/* Store current representation for exceptions.
+ Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fegetexceptflag (fexcept_t *flagp, int excepts)
+{
+ fexcept_t temp;
+
+ /* Get the current exceptions. */
+ _FPU_GETCW (temp);
+
+ /* We only save the relevant bits here. In particular, care has to be
+ taken with the CAUSE bits, as an inadvertent restore later on could
+ generate unexpected exceptions. */
+
+ *flagp = temp & excepts & FE_ALL_EXCEPT;
+
+ /* Success. */
+ return 0;
+}
diff --git a/ports/sysdeps/mips/fpu/fraiseexcpt.c b/ports/sysdeps/mips/fpu/fraiseexcpt.c
new file mode 100644
index 000000000..3e2ebe0fe
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/fraiseexcpt.c
@@ -0,0 +1,47 @@
+/* Raise given exceptions.
+ Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fenv_libc.h>
+#include <fpu_control.h>
+
+int
+feraiseexcept (int excepts)
+{
+ fpu_control_t cw;
+
+ /* Get current state. */
+ _FPU_GETCW (cw);
+
+ /* Set flag bits (which are accumulative), and *also* set the
+ cause bits. The setting of the cause bits is what actually causes
+ the hardware to generate the exception, if the corresponding enable
+ bit is set as well. */
+
+ excepts &= FE_ALL_EXCEPT;
+ cw |= excepts | (excepts << CAUSE_SHIFT);
+
+ /* Set new state. */
+ _FPU_SETCW (cw);
+
+ return 0;
+}
+
+libm_hidden_def (feraiseexcept)
diff --git a/ports/sysdeps/mips/fpu/fsetexcptflg.c b/ports/sysdeps/mips/fpu/fsetexcptflg.c
new file mode 100644
index 000000000..c65d79317
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/fsetexcptflg.c
@@ -0,0 +1,43 @@
+/* Set floating-point environment exception handling.
+ Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Hartvig Ekner <hartvige@mips.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fesetexceptflag (const fexcept_t *flagp, int excepts)
+{
+ fexcept_t temp;
+
+ /* Get the current exceptions. */
+ _FPU_GETCW (temp);
+
+ /* Make sure the flags we want restored are legal. */
+ excepts &= FE_ALL_EXCEPT;
+
+ /* Now clear the bits called for, and copy them in from flagp. Note that
+ we ignore all non-flag bits from *flagp, so they don't matter. */
+ temp = (temp & ~excepts) | (*flagp & excepts);
+
+ _FPU_SETCW (temp);
+
+ /* Success. */
+ return 0;
+}
diff --git a/ports/sysdeps/mips/fpu/ftestexcept.c b/ports/sysdeps/mips/fpu/ftestexcept.c
new file mode 100644
index 000000000..6a833f756
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/ftestexcept.c
@@ -0,0 +1,33 @@
+/* Test exception in current environment.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fetestexcept (int excepts)
+{
+ int cw;
+
+ /* Get current control word. */
+ _FPU_GETCW (cw);
+
+ return cw & excepts & FE_ALL_EXCEPT;
+}
diff --git a/ports/sysdeps/mips/fpu/libm-test-ulps b/ports/sysdeps/mips/fpu/libm-test-ulps
new file mode 100644
index 000000000..b51449667
--- /dev/null
+++ b/ports/sysdeps/mips/fpu/libm-test-ulps
@@ -0,0 +1,890 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+float: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+float: 1
+ifloat: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+idouble: 1
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+idouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 3
+ifloat: 3
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log1p":
+float: 1
+ifloat: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
diff --git a/ports/sysdeps/mips/fpu_control.h b/ports/sysdeps/mips/fpu_control.h
new file mode 100644
index 000000000..da18deab5
--- /dev/null
+++ b/ports/sysdeps/mips/fpu_control.h
@@ -0,0 +1,98 @@
+/* FPU control word bits. Mips version.
+ Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Olaf Flebbe and Ralf Baechle.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FPU_CONTROL_H
+#define _FPU_CONTROL_H
+
+/* MIPS FPU floating point control register bits.
+ *
+ * 31-25 -> floating point conditions code bits 7-1. These bits are only
+ * available in MIPS IV.
+ * 24 -> flush denormalized results to zero instead of
+ * causing unimplemented operation exception. This bit is only
+ * available for MIPS III and newer.
+ * 23 -> Condition bit
+ * 22-18 -> reserved (read as 0, write with 0)
+ * 17 -> cause bit for unimplemented operation
+ * 16 -> cause bit for invalid exception
+ * 15 -> cause bit for division by zero exception
+ * 14 -> cause bit for overflow exception
+ * 13 -> cause bit for underflow exception
+ * 12 -> cause bit for inexact exception
+ * 11 -> enable exception for invalid exception
+ * 10 -> enable exception for division by zero exception
+ * 9 -> enable exception for overflow exception
+ * 8 -> enable exception for underflow exception
+ * 7 -> enable exception for inexact exception
+ * 6 -> flag invalid exception
+ * 5 -> flag division by zero exception
+ * 4 -> flag overflow exception
+ * 3 -> flag underflow exception
+ * 2 -> flag inexact exception
+ * 1-0 -> rounding control
+ *
+ *
+ * Rounding Control:
+ * 00 - rounding to nearest (RN)
+ * 01 - rounding toward zero (RZ)
+ * 10 - rounding (up) toward plus infinity (RP)
+ * 11 - rounding (down)toward minus infinity (RM)
+ */
+
+#include <features.h>
+
+/* masking of interrupts */
+#define _FPU_MASK_V 0x0800 /* Invalid operation */
+#define _FPU_MASK_Z 0x0400 /* Division by zero */
+#define _FPU_MASK_O 0x0200 /* Overflow */
+#define _FPU_MASK_U 0x0100 /* Underflow */
+#define _FPU_MASK_I 0x0080 /* Inexact operation */
+
+/* flush denormalized numbers to zero */
+#define _FPU_FLUSH_TZ 0x1000000
+
+/* rounding control */
+#define _FPU_RC_NEAREST 0x0 /* RECOMMENDED */
+#define _FPU_RC_ZERO 0x1
+#define _FPU_RC_UP 0x2
+#define _FPU_RC_DOWN 0x3
+
+#define _FPU_RESERVED 0xfe3c0000 /* Reserved bits in cw */
+
+
+/* The fdlibm code requires strict IEEE double precision arithmetic,
+ and no interrupts for exceptions, rounding to nearest. */
+
+#define _FPU_DEFAULT 0x00000000
+
+/* IEEE: same as above, but exceptions */
+#define _FPU_IEEE 0x00000F80
+
+/* Type of the control word. */
+typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
+
+/* Macros for accessing the hardware control word. */
+#define _FPU_GETCW(cw) __asm__ ("cfc1 %0,$31" : "=r" (cw))
+#define _FPU_SETCW(cw) __asm__ ("ctc1 %0,$31" : : "r" (cw))
+
+/* Default control word set at startup. */
+extern fpu_control_t __fpu_control;
+
+#endif /* fpu_control.h */
diff --git a/ports/sysdeps/mips/gccframe.h b/ports/sysdeps/mips/gccframe.h
new file mode 100644
index 000000000..ec9311cac
--- /dev/null
+++ b/ports/sysdeps/mips/gccframe.h
@@ -0,0 +1,22 @@
+/* Definition of object in frame unwind info. mips version.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define FIRST_PSEUDO_REGISTER 76
+
+#include <sysdeps/generic/gccframe.h>
diff --git a/ports/sysdeps/mips/ieee754.h b/ports/sysdeps/mips/ieee754.h
new file mode 100644
index 000000000..ed13de277
--- /dev/null
+++ b/ports/sysdeps/mips/ieee754.h
@@ -0,0 +1,325 @@
+/* Copyright (C) 1992, 1995, 1996, 1999, 2002, 2003
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _IEEE754_H
+
+#define _IEEE754_H 1
+#include <features.h>
+
+#include <endian.h>
+
+#include <float.h>
+
+__BEGIN_DECLS
+
+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
+# if __FLOAT_WORD_ORDER == BIG_ENDIAN
+ unsigned int mantissa0:20;
+ unsigned int exponent:11;
+ unsigned int negative:1;
+ unsigned int mantissa1:32;
+# else
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:20;
+ unsigned int exponent:11;
+ unsigned int negative:1;
+# endif
+#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 comprise the mantissa. */
+ unsigned int mantissa0:19;
+ unsigned int mantissa1:32;
+#else
+# if __FLOAT_WORD_ORDER == BIG_ENDIAN
+ unsigned int mantissa0:19;
+ unsigned int quiet_nan:1;
+ unsigned int exponent:11;
+ unsigned int negative:1;
+ unsigned int mantissa1:32;
+# else
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:19;
+ unsigned int quiet_nan:1;
+ unsigned int exponent:11;
+ unsigned int negative:1;
+# endif
+#endif
+ } ieee_nan;
+ };
+
+#define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */
+
+#if LDBL_MANT_DIG == 113
+
+union ieee854_long_double
+ {
+ long double d;
+
+ /* This is the IEEE 854 quad-precision format. */
+ struct
+ {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int negative:1;
+ unsigned int exponent:15;
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa0:16;
+ unsigned int mantissa1:32;
+ unsigned int mantissa2:32;
+ unsigned int mantissa3:32;
+#endif /* Big endian. */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa3:32;
+ unsigned int mantissa2:32;
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:16;
+ unsigned int exponent:15;
+ 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:15;
+ unsigned int quiet_nan:1;
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa0:15;
+ unsigned int mantissa1:32;
+ unsigned int mantissa2:32;
+ unsigned int mantissa3:32;
+#endif /* Big endian. */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa3:32;
+ unsigned int mantissa2:32;
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:15;
+ unsigned int quiet_nan:1;
+ unsigned int exponent:15;
+ unsigned int negative:1;
+#endif /* Little endian. */
+ } ieee_nan;
+ };
+
+#define IEEE854_LONG_DOUBLE_BIAS 0x3fff /* Added to exponent. */
+
+#elif LDBL_MANT_DIG == 64
+
+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
+# if __FLOAT_WORD_ORDER == BIG_ENDIAN
+ unsigned int exponent:15;
+ unsigned int negative:1;
+ unsigned int empty:16;
+ unsigned int mantissa0:32;
+ unsigned int mantissa1:32;
+# else
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:32;
+ unsigned int exponent:15;
+ unsigned int negative:1;
+ unsigned int empty:16;
+# endif
+#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 one:1;
+ unsigned int quiet_nan:1;
+ unsigned int mantissa0:30;
+ unsigned int mantissa1:32;
+#endif
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# if __FLOAT_WORD_ORDER == BIG_ENDIAN
+ unsigned int exponent:15;
+ unsigned int negative:1;
+ unsigned int empty:16;
+ unsigned int mantissa0:30;
+ unsigned int quiet_nan:1;
+ unsigned int one:1;
+ unsigned int mantissa1:32;
+# else
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:30;
+ unsigned int quiet_nan:1;
+ unsigned int one:1;
+ unsigned int exponent:15;
+ unsigned int negative:1;
+ unsigned int empty:16;
+# endif
+#endif
+ } ieee_nan;
+ };
+
+#define IEEE854_LONG_DOUBLE_BIAS 0x3fff
+
+#elif LDBL_MANT_DIG == 53
+
+union ieee854_long_double
+ {
+ long 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
+# if __FLOAT_WORD_ORDER == BIG_ENDIAN
+ unsigned int mantissa0:20;
+ unsigned int exponent:11;
+ unsigned int negative:1;
+ unsigned int mantissa1:32;
+# else
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:20;
+ unsigned int exponent:11;
+ unsigned int negative:1;
+# endif
+#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 comprise the mantissa. */
+ unsigned int mantissa0:19;
+ unsigned int mantissa1:32;
+#else
+# if __FLOAT_WORD_ORDER == BIG_ENDIAN
+ unsigned int mantissa0:19;
+ unsigned int quiet_nan:1;
+ unsigned int exponent:11;
+ unsigned int negative:1;
+ unsigned int mantissa1:32;
+# else
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:19;
+ unsigned int quiet_nan:1;
+ unsigned int exponent:11;
+ unsigned int negative:1;
+# endif
+#endif
+ } ieee_nan;
+ };
+
+#define IEEE854_LONG_DOUBLE_BIAS 0x3ff /* Added to exponent. */
+
+#endif /* LDBL_MANT_DIG == 53 */
+
+__END_DECLS
+
+#endif /* ieee754.h */
diff --git a/ports/sysdeps/mips/init-first.c b/ports/sysdeps/mips/init-first.c
new file mode 100644
index 000000000..b67a44431
--- /dev/null
+++ b/ports/sysdeps/mips/init-first.c
@@ -0,0 +1,64 @@
+/* Initialization code run first thing by the ELF startup code. For mips/Unix.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+extern void __libc_init (int, char **, char **);
+extern void __libc_global_ctors (void);
+
+
+static void
+init (int *data)
+{
+ int argc = *data;
+ char **argv = (void *) (data + 1);
+ char **envp = &argv[argc + 1];
+
+ __environ = envp;
+ __libc_init (argc, argv, envp);
+}
+
+#ifdef SHARED
+/* This function is called to initialize the shared C library.
+ It is called just before the user _start code from mips/elf/start.S,
+ with the stack set up as that code gets it. */
+
+/* NOTE! The linker notices the magical name `_init' and sets the DT_INIT
+ pointer in the dynamic section based solely on that. It is convention
+ for this function to be in the `.init' section, but the symbol name is
+ the only thing that really matters!! */
+/*void _init (int argc, ...) __attribute__ ((unused, section (".init")));*/
+
+void
+_init (int argc, ...)
+{
+ init (&argc);
+
+ __libc_global_ctors ();
+}
+#endif
+
+
+void
+__libc_init_first (int argc __attribute__ ((unused)), ...)
+{
+#ifndef SHARED
+ init (&argc);
+#endif
+}
diff --git a/ports/sysdeps/mips/jmpbuf-unwind.h b/ports/sysdeps/mips/jmpbuf-unwind.h
new file mode 100644
index 000000000..bfa1a6453
--- /dev/null
+++ b/ports/sysdeps/mips/jmpbuf-unwind.h
@@ -0,0 +1,46 @@
+/* Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <setjmp.h>
+#include <stdint.h>
+#include <unwind.h>
+#include <sysdep.h>
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
+ ((void *) (address) < (void *) demangle ((jmpbuf)[0].__sp))
+
+#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \
+ _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj)
+
+static inline uintptr_t __attribute__ ((unused))
+_jmpbuf_sp (__jmp_buf regs)
+{
+ uintptr_t sp = regs[0].__sp;
+#ifdef PTR_DEMANGLE
+ PTR_DEMANGLE (sp);
+#endif
+ return sp;
+}
+
+#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
+ ((uintptr_t) (_address) - (_adj) < _jmpbuf_sp (_jmpbuf) - (_adj))
+
+/* We use the normal longjmp for unwinding. */
+#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
diff --git a/ports/sysdeps/mips/ldsodefs.h b/ports/sysdeps/mips/ldsodefs.h
new file mode 100644
index 000000000..876f1c3dc
--- /dev/null
+++ b/ports/sysdeps/mips/ldsodefs.h
@@ -0,0 +1,66 @@
+/* Run-time dynamic linker data structures for loaded ELF shared objects.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef __LDSODEFS_H \
+#define _MIPS_LDSODEFS_H 1
+
+#include <elf.h>
+
+struct La_mips_32_regs;
+struct La_mips_32_retval;
+struct La_mips_64_regs;
+struct La_mips_64_retval;
+
+#define ARCH_PLTENTER_MEMBERS \
+ Elf32_Addr (*mips_o32_gnu_pltenter) (Elf32_Sym *, unsigned int, \
+ uintptr_t *, uintptr_t *, \
+ const struct La_mips_32_regs *, \
+ unsigned int *, const char *name, \
+ long int *framesizep); \
+ Elf32_Addr (*mips_n32_gnu_pltenter) (Elf32_Sym *, unsigned int, \
+ uintptr_t *, uintptr_t *, \
+ const struct La_mips_64_regs *, \
+ unsigned int *, const char *name, \
+ long int *framesizep); \
+ Elf64_Addr (*mips_n64_gnu_pltenter) (Elf64_Sym *, unsigned int, \
+ uintptr_t *, uintptr_t *, \
+ const struct La_mips_64_regs *, \
+ unsigned int *, const char *name, \
+ long int *framesizep);
+
+#define ARCH_PLTEXIT_MEMBERS \
+ unsigned int (*mips_o32_gnu_pltexit) (Elf32_Sym *, unsigned int, \
+ uintptr_t *, uintptr_t *, \
+ const struct La_mips_32_regs *, \
+ struct La_mips_32_retval *, \
+ const char *); \
+ unsigned int (*mips_n32_gnu_pltexit) (Elf32_Sym *, unsigned int, \
+ uintptr_t *, uintptr_t *, \
+ const struct La_mips_64_regs *, \
+ struct La_mips_64_retval *, \
+ const char *); \
+ unsigned int (*mips_n64_gnu_pltexit) (Elf64_Sym *, unsigned int, \
+ uintptr_t *, uintptr_t *, \
+ const struct La_mips_64_regs *, \
+ struct La_mips_64_retval *, \
+ const char *);
+
+#include_next <ldsodefs.h>
+
+#endif
diff --git a/ports/sysdeps/mips/libc-tls.c b/ports/sysdeps/mips/libc-tls.c
new file mode 100644
index 000000000..a3d6301d1
--- /dev/null
+++ b/ports/sysdeps/mips/libc-tls.c
@@ -0,0 +1,37 @@
+/* Thread-local storage handling in the ELF dynamic linker. MIPS version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <csu/libc-tls.c>
+#include <dl-tls.h>
+
+#if USE_TLS
+
+/* On MIPS, linker optimizations are not required, so __tls_get_addr
+ can be called even in statically linked binaries. In this case module
+ must be always 1 and PT_TLS segment exist in the binary, otherwise it
+ would not link. */
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+ dtv_t *dtv = THREAD_DTV ();
+ return (char *) dtv[1].pointer.val + GET_ADDR_OFFSET;
+}
+
+#endif
diff --git a/ports/sysdeps/mips/lshift.S b/ports/sysdeps/mips/lshift.S
new file mode 100644
index 000000000..0217bfc58
--- /dev/null
+++ b/ports/sysdeps/mips/lshift.S
@@ -0,0 +1,98 @@
+/* MIPS2 __mpn_lshift --
+
+Copyright (C) 1995, 2000, 2002, 2003 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+/* INPUT PARAMETERS
+ res_ptr $4
+ src_ptr $5
+ size $6
+ cnt $7
+*/
+#ifdef __PIC__
+ .option pic2
+#endif
+ENTRY (__mpn_lshift)
+ .set noreorder
+#ifdef __PIC__
+ .cpload t9
+#endif
+ .set nomacro
+
+ sll $2,$6,2
+ addu $5,$5,$2 /* make r5 point at end of src */
+ lw $10,-4($5) /* load first limb */
+ subu $13,$0,$7
+ addu $4,$4,$2 /* make r4 point at end of res */
+ addiu $6,$6,-1
+ and $9,$6,4-1 /* number of limbs in first loop */
+ beq $9,$0,L(L0) /* if multiple of 4 limbs, skip first loop */
+ srl $2,$10,$13 /* compute function result */
+
+ subu $6,$6,$9
+
+L(Loop0): lw $3,-8($5)
+ addiu $4,$4,-4
+ addiu $5,$5,-4
+ addiu $9,$9,-1
+ sll $11,$10,$7
+ srl $12,$3,$13
+ move $10,$3
+ or $8,$11,$12
+ bne $9,$0,L(Loop0)
+ sw $8,0($4)
+
+L(L0): beq $6,$0,L(Lend)
+ nop
+
+L(Loop): lw $3,-8($5)
+ addiu $4,$4,-16
+ addiu $6,$6,-4
+ sll $11,$10,$7
+ srl $12,$3,$13
+
+ lw $10,-12($5)
+ sll $14,$3,$7
+ or $8,$11,$12
+ sw $8,12($4)
+ srl $9,$10,$13
+
+ lw $3,-16($5)
+ sll $11,$10,$7
+ or $8,$14,$9
+ sw $8,8($4)
+ srl $12,$3,$13
+
+ lw $10,-20($5)
+ sll $14,$3,$7
+ or $8,$11,$12
+ sw $8,4($4)
+ srl $9,$10,$13
+
+ addiu $5,$5,-16
+ or $8,$14,$9
+ bgtz $6,L(Loop)
+ sw $8,0($4)
+
+L(Lend): sll $8,$10,$7
+ j $31
+ sw $8,-4($4)
+ END (__mpn_lshift)
diff --git a/ports/sysdeps/mips/machine-gmon.h b/ports/sysdeps/mips/machine-gmon.h
new file mode 100644
index 000000000..7a089fa59
--- /dev/null
+++ b/ports/sysdeps/mips/machine-gmon.h
@@ -0,0 +1,141 @@
+/* Machine-specific calling sequence for `mcount' profiling function. MIPS
+ Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sgidefs.h>
+
+#define _MCOUNT_DECL(frompc,selfpc) \
+static void __attribute_used__ __mcount (u_long frompc, u_long selfpc)
+
+/* Call __mcount with the return PC for our caller,
+ and the return PC our caller will return to. */
+
+#if _MIPS_SIM == _ABIO32
+
+#ifdef __PIC__
+# define CPLOAD ".cpload $25;"
+# define CPRESTORE ".cprestore 44\n\t"
+#else
+# define CPLOAD
+# define CPRESTORE
+#endif
+
+#define MCOUNT asm(\
+ ".globl _mcount;\n\t" \
+ ".align 2;\n\t" \
+ ".type _mcount,@function;\n\t" \
+ ".ent _mcount\n\t" \
+ "_mcount:\n\t" \
+ ".frame $sp,44,$31\n\t" \
+ ".set noreorder;\n\t" \
+ ".set noat;\n\t" \
+ CPLOAD \
+ "subu $29,$29,48;\n\t" \
+ CPRESTORE \
+ "sw $4,24($29);\n\t" \
+ "sw $5,28($29);\n\t" \
+ "sw $6,32($29);\n\t" \
+ "sw $7,36($29);\n\t" \
+ "sw $2,40($29);\n\t" \
+ "sw $1,16($29);\n\t" \
+ "sw $31,20($29);\n\t" \
+ "move $5,$31;\n\t" \
+ "move $4,$1;\n\t" \
+ "jal __mcount;\n\t" \
+ "nop;\n\t" \
+ "lw $4,24($29);\n\t" \
+ "lw $5,28($29);\n\t" \
+ "lw $6,32($29);\n\t" \
+ "lw $7,36($29);\n\t" \
+ "lw $2,40($29);\n\t" \
+ "lw $31,20($29);\n\t" \
+ "lw $1,16($29);\n\t" \
+ "addu $29,$29,56;\n\t" \
+ "j $31;\n\t" \
+ "move $31,$1;\n\t" \
+ ".set reorder;\n\t" \
+ ".set at\n\t" \
+ ".end _mcount");
+
+#else
+
+#ifdef __PIC__
+# define CPSETUP ".cpsetup $25, 88, _mcount;"
+# define CPRETURN ".cpreturn;"
+#else
+# define CPSETUP
+# define CPRETURN
+#endif
+
+#if _MIPS_SIM == _ABIN32
+# define PTR_ADDU_STRING "add" /* no u */
+# define PTR_SUBU_STRING "sub" /* no u */
+#elif _MIPS_SIM == _ABI64
+# define PTR_ADDU_STRING "daddu"
+# define PTR_SUBU_STRING "dsubu"
+#else
+# error "Unknown ABI"
+#endif
+
+#define MCOUNT asm(\
+ ".globl _mcount;\n\t" \
+ ".align 3;\n\t" \
+ ".type _mcount,@function;\n\t" \
+ ".ent _mcount\n\t" \
+ "_mcount:\n\t" \
+ ".frame $sp,88,$31\n\t" \
+ ".set noreorder;\n\t" \
+ ".set noat;\n\t" \
+ PTR_SUBU_STRING " $29,$29,96;\n\t" \
+ CPSETUP \
+ "sd $4,24($29);\n\t" \
+ "sd $5,32($29);\n\t" \
+ "sd $6,40($29);\n\t" \
+ "sd $7,48($29);\n\t" \
+ "sd $8,56($29);\n\t" \
+ "sd $9,64($29);\n\t" \
+ "sd $10,72($29);\n\t" \
+ "sd $11,80($29);\n\t" \
+ "sd $2,16($29);\n\t" \
+ "sd $1,0($29);\n\t" \
+ "sd $31,8($29);\n\t" \
+ "move $5,$31;\n\t" \
+ "move $4,$1;\n\t" \
+ "jal __mcount;\n\t" \
+ "nop;\n\t" \
+ "ld $4,24($29);\n\t" \
+ "ld $5,32($29);\n\t" \
+ "ld $6,40($29);\n\t" \
+ "ld $7,48($29);\n\t" \
+ "ld $8,56($29);\n\t" \
+ "ld $9,64($29);\n\t" \
+ "ld $10,72($29);\n\t" \
+ "ld $11,80($29);\n\t" \
+ "ld $2,16($29);\n\t" \
+ "ld $31,8($29);\n\t" \
+ "ld $1,0($29);\n\t" \
+ CPRETURN \
+ PTR_ADDU_STRING " $29,$29,96;\n\t" \
+ "j $31;\n\t" \
+ "move $31,$1;\n\t" \
+ ".set reorder;\n\t" \
+ ".set at\n\t" \
+ ".end _mcount");
+
+#endif
diff --git a/ports/sysdeps/mips/memcpy.S b/ports/sysdeps/mips/memcpy.S
new file mode 100644
index 000000000..2049d0582
--- /dev/null
+++ b/ports/sysdeps/mips/memcpy.S
@@ -0,0 +1,136 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Hartvig Ekner <hartvige@mips.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <endian.h>
+
+
+/* void *memcpy(void *s1, const void *s2, size_t n); */
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define LWHI lwl /* high part is left in big-endian */
+# define SWHI swl /* high part is left in big-endian */
+# define LWLO lwr /* low part is right in big-endian */
+# define SWLO swr /* low part is right in big-endian */
+#else
+# define LWHI lwr /* high part is right in little-endian */
+# define SWHI swr /* high part is right in little-endian */
+# define LWLO lwl /* low part is left in little-endian */
+# define SWLO swl /* low part is left in little-endian */
+#endif
+
+ENTRY (memcpy)
+ .set noreorder
+
+ slti t0, a2, 8 # Less than 8?
+ bne t0, zero, L(last8)
+ move v0, a0 # Setup exit value before too late
+
+ xor t0, a1, a0 # Find a0/a1 displacement
+ andi t0, 0x3
+ bne t0, zero, L(shift) # Go handle the unaligned case
+ subu t1, zero, a1
+ andi t1, 0x3 # a0/a1 are aligned, but are we
+ beq t1, zero, L(chk8w) # starting in the middle of a word?
+ subu a2, t1
+ LWHI t0, 0(a1) # Yes we are... take care of that
+ addu a1, t1
+ SWHI t0, 0(a0)
+ addu a0, t1
+
+L(chk8w):
+ andi t0, a2, 0x1f # 32 or more bytes left?
+ beq t0, a2, L(chk1w)
+ subu a3, a2, t0 # Yes
+ addu a3, a1 # a3 = end address of loop
+ move a2, t0 # a2 = what will be left after loop
+L(lop8w):
+ lw t0, 0(a1) # Loop taking 8 words at a time
+ lw t1, 4(a1)
+ lw t2, 8(a1)
+ lw t3, 12(a1)
+ lw t4, 16(a1)
+ lw t5, 20(a1)
+ lw t6, 24(a1)
+ lw t7, 28(a1)
+ addiu a0, 32
+ addiu a1, 32
+ sw t0, -32(a0)
+ sw t1, -28(a0)
+ sw t2, -24(a0)
+ sw t3, -20(a0)
+ sw t4, -16(a0)
+ sw t5, -12(a0)
+ sw t6, -8(a0)
+ bne a1, a3, L(lop8w)
+ sw t7, -4(a0)
+
+L(chk1w):
+ andi t0, a2, 0x3 # 4 or more bytes left?
+ beq t0, a2, L(last8)
+ subu a3, a2, t0 # Yes, handle them one word at a time
+ addu a3, a1 # a3 again end address
+ move a2, t0
+L(lop1w):
+ lw t0, 0(a1)
+ addiu a0, 4
+ addiu a1, 4
+ bne a1, a3, L(lop1w)
+ sw t0, -4(a0)
+
+L(last8):
+ blez a2, L(lst8e) # Handle last 8 bytes, one at a time
+ addu a3, a2, a1
+L(lst8l):
+ lb t0, 0(a1)
+ addiu a0, 1
+ addiu a1, 1
+ bne a1, a3, L(lst8l)
+ sb t0, -1(a0)
+L(lst8e):
+ jr ra # Bye, bye
+ nop
+
+L(shift):
+ subu a3, zero, a0 # Src and Dest unaligned
+ andi a3, 0x3 # (unoptimized case...)
+ beq a3, zero, L(shft1)
+ subu a2, a3 # a2 = bytes left
+ LWHI t0, 0(a1) # Take care of first odd part
+ LWLO t0, 3(a1)
+ addu a1, a3
+ SWHI t0, 0(a0)
+ addu a0, a3
+L(shft1):
+ andi t0, a2, 0x3
+ subu a3, a2, t0
+ addu a3, a1
+L(shfth):
+ LWHI t1, 0(a1) # Limp through, word by word
+ LWLO t1, 3(a1)
+ addiu a0, 4
+ addiu a1, 4
+ bne a1, a3, L(shfth)
+ sw t1, -4(a0)
+ b L(last8) # Handle anything which may be left
+ move a2, t0
+
+ .set reorder
+END (memcpy)
+libc_hidden_builtin_def (memcpy)
diff --git a/ports/sysdeps/mips/memset.S b/ports/sysdeps/mips/memset.S
new file mode 100644
index 000000000..694ee8f1d
--- /dev/null
+++ b/ports/sysdeps/mips/memset.S
@@ -0,0 +1,86 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Hartvig Ekner <hartvige@mips.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <endian.h>
+
+
+/* void *memset(void *s, int c, size_t n). */
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define SWHI swl /* high part is left in big-endian */
+#else
+# define SWHI swr /* high part is right in little-endian */
+#endif
+
+ENTRY (memset)
+ .set noreorder
+
+ slti t1, a2, 8 # Less than 8?
+ bne t1, zero, L(last8)
+ move v0, a0 # Setup exit value before too late
+
+ beq a1, zero, L(ueven) # If zero pattern, no need to extend
+ andi a1, 0xff # Avoid problems with bogus arguments
+ sll t0, a1, 8
+ or a1, t0
+ sll t0, a1, 16
+ or a1, t0 # a1 is now pattern in full word
+
+L(ueven):
+ subu t0, zero, a0 # Unaligned address?
+ andi t0, 0x3
+ beq t0, zero, L(chkw)
+ subu a2, t0
+ SWHI a1, 0(a0) # Yes, handle first unaligned part
+ addu a0, t0 # Now both a0 and a2 are updated
+
+L(chkw):
+ andi t0, a2, 0x7 # Enough left for one loop iteration?
+ beq t0, a2, L(chkl)
+ subu a3, a2, t0
+ addu a3, a0 # a3 is last loop address +1
+ move a2, t0 # a2 is now # of bytes left after loop
+L(loopw):
+ addiu a0, 8 # Handle 2 words pr. iteration
+ sw a1, -8(a0)
+ bne a0, a3, L(loopw)
+ sw a1, -4(a0)
+
+L(chkl):
+ andi t0, a2, 0x4 # Check if there is at least a full
+ beq t0, zero, L(last8) # word remaining after the loop
+ subu a2, t0
+ sw a1, 0(a0) # Yes...
+ addiu a0, 4
+
+L(last8):
+ blez a2, L(exit) # Handle last 8 bytes (if cnt>0)
+ addu a3, a2, a0 # a3 is last address +1
+L(lst8l):
+ addiu a0, 1
+ bne a0, a3, L(lst8l)
+ sb a1, -1(a0)
+L(exit):
+ j ra # Bye, bye
+ nop
+
+ .set reorder
+END (memset)
+libc_hidden_builtin_def (memset)
diff --git a/ports/sysdeps/mips/memusage.h b/ports/sysdeps/mips/memusage.h
new file mode 100644
index 000000000..dc1cc9ca1
--- /dev/null
+++ b/ports/sysdeps/mips/memusage.h
@@ -0,0 +1,21 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define GETSP() ({ register uintptr_t stack_ptr asm ("$29"); stack_ptr; })
+
+#include <sysdeps/generic/memusage.h>
diff --git a/ports/sysdeps/mips/mips32/Implies b/ports/sysdeps/mips/mips32/Implies
new file mode 100644
index 000000000..fab98d731
--- /dev/null
+++ b/ports/sysdeps/mips/mips32/Implies
@@ -0,0 +1,2 @@
+mips
+wordsize-32
diff --git a/ports/sysdeps/mips/mips32/Makefile b/ports/sysdeps/mips/mips32/Makefile
new file mode 100644
index 000000000..dec0b024c
--- /dev/null
+++ b/ports/sysdeps/mips/mips32/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(filter -mabi=32,$(CC)),)
+CC += -mabi=32
+endif
diff --git a/ports/sysdeps/mips/mips64/Implies b/ports/sysdeps/mips/mips64/Implies
new file mode 100644
index 000000000..8c18cb303
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/Implies
@@ -0,0 +1,3 @@
+# MIPS uses IEEE 754 floating point.
+ieee754/flt-32
+ieee754/dbl-64
diff --git a/ports/sysdeps/mips/mips64/Versions b/ports/sysdeps/mips/mips64/Versions
new file mode 100644
index 000000000..253a65f04
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/Versions
@@ -0,0 +1,7 @@
+libm {
+ GLIBC_2.1 {
+ # A generic bug got this omitted from other configurations' version
+ # sets, but we always had it.
+ exp2l;
+ }
+}
diff --git a/ports/sysdeps/mips/mips64/__longjmp.c b/ports/sysdeps/mips/mips64/__longjmp.c
new file mode 100644
index 000000000..546493f84
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/__longjmp.c
@@ -0,0 +1,98 @@
+/* Copyright (C) 1992, 1995, 1997, 2000, 2003, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <setjmp.h>
+#include <sgidefs.h>
+#include <stdlib.h>
+
+#undef __longjmp
+
+#ifndef __GNUC__
+ #error This file uses GNU C extensions; you must compile with GCC.
+#endif
+
+void
+__longjmp (env, val_arg)
+ __jmp_buf env;
+ int val_arg;
+{
+ /* gcc 1.39.19 miscompiled the longjmp routine (as it did setjmp before
+ the hack around it); force it to use $a1 for the longjmp value.
+ Without this it saves $a1 in a register which gets clobbered
+ along the way. */
+ register int val asm ("a1");
+
+ /* Pull back the floating point callee-saved registers. */
+#if _MIPS_SIM == _ABI64
+ asm volatile ("l.d $f24, %0" : : "m" (env[0].__fpregs[0]));
+ asm volatile ("l.d $f25, %0" : : "m" (env[0].__fpregs[1]));
+ asm volatile ("l.d $f26, %0" : : "m" (env[0].__fpregs[2]));
+ asm volatile ("l.d $f27, %0" : : "m" (env[0].__fpregs[3]));
+ asm volatile ("l.d $f28, %0" : : "m" (env[0].__fpregs[4]));
+ asm volatile ("l.d $f29, %0" : : "m" (env[0].__fpregs[5]));
+ asm volatile ("l.d $f30, %0" : : "m" (env[0].__fpregs[6]));
+ asm volatile ("l.d $f31, %0" : : "m" (env[0].__fpregs[7]));
+#else
+ 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]));
+#endif
+
+ /* Get and reconstruct the floating point csr. */
+ asm volatile ("lw $2, %0" : : "m" (env[0].__fpc_csr));
+ asm volatile ("ctc1 $2, $31");
+
+ /* Get the GP. */
+ asm volatile ("ld $gp, %0" : : "m" (env[0].__gp));
+
+ /* Get the callee-saved registers. */
+ asm volatile ("ld $16, %0" : : "m" (env[0].__regs[0]));
+ asm volatile ("ld $17, %0" : : "m" (env[0].__regs[1]));
+ asm volatile ("ld $18, %0" : : "m" (env[0].__regs[2]));
+ asm volatile ("ld $19, %0" : : "m" (env[0].__regs[3]));
+ asm volatile ("ld $20, %0" : : "m" (env[0].__regs[4]));
+ asm volatile ("ld $21, %0" : : "m" (env[0].__regs[5]));
+ asm volatile ("ld $22, %0" : : "m" (env[0].__regs[6]));
+ asm volatile ("ld $23, %0" : : "m" (env[0].__regs[7]));
+
+ /* Get the PC. */
+ asm volatile ("ld $31, %0" : : "m" (env[0].__pc));
+
+
+ /* Restore the stack pointer and the FP. They have to be restored
+ last and in a single asm as gcc, depending on options used, may
+ use either of them to access env. */
+ asm volatile ("ld $29, %0\n\t"
+ "ld $30, %1\n\t" : : "m" (env[0].__sp), "m" (env[0].__fp));
+
+/* Give setjmp 1 if given a 0, or what they gave us if non-zero. */
+ if (val == 0)
+ asm volatile ("dli $2, 1");
+ else
+ asm volatile ("move $2, %0" : : "r" (val));
+
+ asm volatile ("j $31");
+
+ /* Avoid `volatile function does return' warnings. */
+ for (;;);
+}
diff --git a/ports/sysdeps/mips/mips64/add_n.S b/ports/sysdeps/mips/mips64/add_n.S
new file mode 100644
index 000000000..072f4f0b7
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/add_n.S
@@ -0,0 +1,130 @@
+/* MIPS3 __mpn_add_n -- Add two limb vectors of the same length > 0 and
+ * store sum in a third limb vector.
+ *
+ * Copyright (C) 1995, 2000, 2002, 2003 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 Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 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 Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#include <sysdep.h>
+#include <sys/asm.h>
+
+/*
+ * INPUT PARAMETERS
+ * res_ptr $4
+ * s1_ptr $5
+ * s2_ptr $6
+ * size $7
+ */
+#ifdef __PIC__
+ .option pic2
+#endif
+ .text
+ .align 2
+ .globl __mpn_add_n
+ .ent __mpn_add_n
+__mpn_add_n:
+#ifdef __PIC__
+ SETUP_GP /* ??? unused */
+#endif
+ .set noreorder
+ .set nomacro
+
+ ld $10,0($5)
+ ld $11,0($6)
+
+ daddiu $7,$7,-1
+ and $9,$7,4-1 # number of limbs in first loop
+ beq $9,$0,L(L0) # if multiple of 4 limbs, skip first loop
+ move $2,$0
+
+ dsubu $7,$7,$9
+
+L(Loop0): daddiu $9,$9,-1
+ ld $12,8($5)
+ daddu $11,$11,$2
+ ld $13,8($6)
+ sltu $8,$11,$2
+ daddu $11,$10,$11
+ sltu $2,$11,$10
+ sd $11,0($4)
+ or $2,$2,$8
+
+ daddiu $5,$5,8
+ daddiu $6,$6,8
+ move $10,$12
+ move $11,$13
+ bne $9,$0,L(Loop0)
+ daddiu $4,$4,8
+
+L(L0): beq $7,$0,L(Lend)
+ nop
+
+L(Loop): daddiu $7,$7,-4
+
+ ld $12,8($5)
+ daddu $11,$11,$2
+ ld $13,8($6)
+ sltu $8,$11,$2
+ daddu $11,$10,$11
+ sltu $2,$11,$10
+ sd $11,0($4)
+ or $2,$2,$8
+
+ ld $10,16($5)
+ daddu $13,$13,$2
+ ld $11,16($6)
+ sltu $8,$13,$2
+ daddu $13,$12,$13
+ sltu $2,$13,$12
+ sd $13,8($4)
+ or $2,$2,$8
+
+ ld $12,24($5)
+ daddu $11,$11,$2
+ ld $13,24($6)
+ sltu $8,$11,$2
+ daddu $11,$10,$11
+ sltu $2,$11,$10
+ sd $11,16($4)
+ or $2,$2,$8
+
+ ld $10,32($5)
+ daddu $13,$13,$2
+ ld $11,32($6)
+ sltu $8,$13,$2
+ daddu $13,$12,$13
+ sltu $2,$13,$12
+ sd $13,24($4)
+ or $2,$2,$8
+
+ daddiu $5,$5,32
+ daddiu $6,$6,32
+
+ bne $7,$0,L(Loop)
+ daddiu $4,$4,32
+
+L(Lend): daddu $11,$11,$2
+ sltu $8,$11,$2
+ daddu $11,$10,$11
+ sltu $2,$11,$10
+ sd $11,0($4)
+ j $31
+ or $2,$2,$8
+
+ .end __mpn_add_n
diff --git a/ports/sysdeps/mips/mips64/addmul_1.S b/ports/sysdeps/mips/mips64/addmul_1.S
new file mode 100644
index 000000000..f5ecd8370
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/addmul_1.S
@@ -0,0 +1,107 @@
+/* MIPS3 __mpn_addmul_1 -- Multiply a limb vector with a single limb and
+ * add the product to a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 2002, 2003 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 Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 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 Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#include <sysdep.h>
+#include <sys/asm.h>
+
+/* INPUT PARAMETERS
+ * res_ptr $4
+ * s1_ptr $5
+ * size $6
+ * s2_limb $7
+ */
+
+#ifdef PIC
+ .option pic2
+#endif
+ .text
+ .align 4
+ .globl __mpn_addmul_1
+ .ent __mpn_addmul_1
+__mpn_addmul_1:
+#ifdef PIC
+ SETUP_GP /* ??? unused */
+#endif
+ .set noreorder
+ .set nomacro
+
+ # warm up phase 0
+ ld $8,0($5)
+
+ # warm up phase 1
+ daddiu $5,$5,8
+ dmultu $8,$7
+
+ daddiu $6,$6,-1
+ beq $6,$0,L(LC0)
+ move $2,$0 # zero cy2
+
+ daddiu $6,$6,-1
+ beq $6,$0,L(LC1)
+ ld $8,0($5) # load new s1 limb as early as possible
+
+L(Loop): ld $10,0($4)
+ mflo $3
+ mfhi $9
+ daddiu $5,$5,8
+ daddu $3,$3,$2 # add old carry limb to low product limb
+ dmultu $8,$7
+ ld $8,0($5) # load new s1 limb as early as possible
+ daddiu $6,$6,-1 # decrement loop counter
+ sltu $2,$3,$2 # carry from previous addition -> $2
+ daddu $3,$10,$3
+ sltu $10,$3,$10
+ daddu $2,$2,$10
+ sd $3,0($4)
+ daddiu $4,$4,8
+ bne $6,$0,L(Loop)
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+ # cool down phase 1
+L(LC1): ld $10,0($4)
+ mflo $3
+ mfhi $9
+ daddu $3,$3,$2
+ sltu $2,$3,$2
+ dmultu $8,$7
+ daddu $3,$10,$3
+ sltu $10,$3,$10
+ daddu $2,$2,$10
+ sd $3,0($4)
+ daddiu $4,$4,8
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+ # cool down phase 0
+L(LC0): ld $10,0($4)
+ mflo $3
+ mfhi $9
+ daddu $3,$3,$2
+ sltu $2,$3,$2
+ daddu $3,$10,$3
+ sltu $10,$3,$10
+ daddu $2,$2,$10
+ sd $3,0($4)
+ j $31
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+ .end __mpn_addmul_1
diff --git a/ports/sysdeps/mips/mips64/bsd-_setjmp.S b/ports/sysdeps/mips/mips64/bsd-_setjmp.S
new file mode 100644
index 000000000..7620cf391
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/bsd-_setjmp.S
@@ -0,0 +1,49 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. MIPS64 version.
+ Copyright (C) 1996, 1997, 2000, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 0)'.
+ We cannot do it in C because it must be a tail-call, so frame-unwinding
+ in setjmp doesn't clobber the state restored by longjmp. */
+
+#include <sgidefs.h>
+#include <sysdep.h>
+#include <sys/asm.h>
+
+#ifdef __PIC__
+ .option pic2
+#endif
+ENTRY (_setjmp)
+#ifdef __PIC__
+ SETUP_GP
+#endif
+ SETUP_GP64 (v0, C_SYMBOL_NAME (_setjmp))
+ PTR_LA t9, C_SYMBOL_NAME (__sigsetjmp)
+#if _MIPS_SIM == _ABIO32
+ nop
+#endif
+ RESTORE_GP64
+ move a1, zero /* Pass a second argument of zero. */
+#ifdef __PIC__
+ jr t9
+#else
+ j C_SYMBOL_NAME (__sigsetjmp)
+#endif
+ .end _setjmp
+libc_hidden_def (_setjmp)
diff --git a/ports/sysdeps/mips/mips64/bsd-setjmp.S b/ports/sysdeps/mips/mips64/bsd-setjmp.S
new file mode 100644
index 000000000..2a1fd9ce7
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/bsd-setjmp.S
@@ -0,0 +1,47 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. MIPS64 version.
+ Copyright (C) 1996, 1997, 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
+ We cannot do it in C because it must be a tail-call, so frame-unwinding
+ in setjmp doesn't clobber the state restored by longjmp. */
+
+#include <sgidefs.h>
+#include <sysdep.h>
+#include <sys/asm.h>
+
+#ifdef PIC
+ .option pic2
+#endif
+ENTRY (setjmp)
+#ifdef __PIC__
+ SETUP_GP
+#endif
+ SETUP_GP64 (v0, C_SYMBOL_NAME (setjmp))
+ PTR_LA t9, C_SYMBOL_NAME (__sigsetjmp)
+#if _MIPS_SIM == _ABIO32
+ nop
+#endif
+ RESTORE_GP64
+ dli a1, 1 /* Pass a second argument of one. */
+#ifdef __PIC__
+ jr t9
+#else
+ j C_SYMBOL_NAME (__sigsetjmp)
+#endif
+ .end setjmp
diff --git a/ports/sysdeps/mips/mips64/gmp-mparam.h b/ports/sysdeps/mips/mips64/gmp-mparam.h
new file mode 100644
index 000000000..7666137a2
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/gmp-mparam.h
@@ -0,0 +1,31 @@
+/* gmp-mparam.h -- Compiler/machine parameter header file.
+
+Copyright (C) 1991, 1993, 1994, 2002, 2003 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser 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. */
+
+#if defined __GMP_H__ && ! defined _LONG_LONG_LIMB
+#error "Included too late for _LONG_LONG_LIMB to take effect"
+#endif
+
+#define _LONG_LONG_LIMB
+#define BITS_PER_MP_LIMB 64
+#define BYTES_PER_MP_LIMB 8
+#define BITS_PER_LONGINT __WORDSIZE
+#define BITS_PER_INT 32
+#define BITS_PER_SHORTINT 16
+#define BITS_PER_CHAR 8
diff --git a/ports/sysdeps/mips/mips64/lshift.S b/ports/sysdeps/mips/mips64/lshift.S
new file mode 100644
index 000000000..20f9e3da1
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/lshift.S
@@ -0,0 +1,105 @@
+/* MIPS3 __mpn_lshift --
+ *
+ * Copyright (C) 1995, 2000, 2002, 2003 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 Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 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 Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#include <sysdep.h>
+#include <sys/asm.h>
+
+/* INPUT PARAMETERS
+ * res_ptr $4
+ * src_ptr $5
+ * size $6
+ * cnt $7
+ */
+
+#ifdef __PIC__
+ .option pic2
+#endif
+ .text
+ .align 2
+ .globl __mpn_lshift
+ .ent __mpn_lshift
+__mpn_lshift:
+#ifdef __PIC__
+ SETUP_GP /* ??? unused */
+#endif
+ .set noreorder
+ .set nomacro
+
+ dsll $2,$6,3
+ daddu $5,$5,$2 # make r5 point at end of src
+ ld $10,-8($5) # load first limb
+ dsubu $13,$0,$7
+ daddu $4,$4,$2 # make r4 point at end of res
+ daddiu $6,$6,-1
+ and $9,$6,4-1 # number of limbs in first loop
+ beq $9,$0,L(L0) # if multiple of 4 limbs, skip first loop
+ dsrl $2,$10,$13 # compute function result
+
+ dsubu $6,$6,$9
+
+L(Loop0): ld $3,-16($5)
+ daddiu $4,$4,-8
+ daddiu $5,$5,-8
+ daddiu $9,$9,-1
+ dsll $11,$10,$7
+ dsrl $12,$3,$13
+ move $10,$3
+ or $8,$11,$12
+ bne $9,$0,L(Loop0)
+ sd $8,0($4)
+
+L(L0): beq $6,$0,L(Lend)
+ nop
+
+L(Loop): ld $3,-16($5)
+ daddiu $4,$4,-32
+ daddiu $6,$6,-4
+ dsll $11,$10,$7
+ dsrl $12,$3,$13
+
+ ld $10,-24($5)
+ dsll $14,$3,$7
+ or $8,$11,$12
+ sd $8,24($4)
+ dsrl $9,$10,$13
+
+ ld $3,-32($5)
+ dsll $11,$10,$7
+ or $8,$14,$9
+ sd $8,16($4)
+ dsrl $12,$3,$13
+
+ ld $10,-40($5)
+ dsll $14,$3,$7
+ or $8,$11,$12
+ sd $8,8($4)
+ dsrl $9,$10,$13
+
+ daddiu $5,$5,-32
+ or $8,$14,$9
+ bgtz $6,L(Loop)
+ sd $8,0($4)
+
+L(Lend): dsll $8,$10,$7
+ j $31
+ sd $8,-8($4)
+ .end __mpn_lshift
diff --git a/ports/sysdeps/mips/mips64/memcpy.S b/ports/sysdeps/mips/mips64/memcpy.S
new file mode 100644
index 000000000..eab9463f8
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/memcpy.S
@@ -0,0 +1,140 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Hartvig Ekner <hartvige@mips.com>, 2002.
+ Ported to mips3 n32/n64 by Alexandre Oliva <aoliva@redhat.com>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <endian.h>
+#include <sys/asm.h>
+
+
+/* void *memcpy(void *s1, const void *s2, size_t n);
+
+ This could probably be optimized further. */
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define LDHI ldl /* high part is left in big-endian */
+# define SDHI sdl /* high part is left in big-endian */
+# define LDLO ldr /* low part is right in big-endian */
+# define SDLO sdr /* low part is right in big-endian */
+#else
+# define LDHI ldr /* high part is right in little-endian */
+# define SDHI sdr /* high part is right in little-endian */
+# define LDLO ldl /* low part is left in little-endian */
+# define SDLO sdl /* low part is left in little-endian */
+#endif
+
+ENTRY (memcpy)
+ .set noreorder
+
+ slti t0, a2, 16 # Less than 16?
+ bne t0, zero, L(last16)
+ move v0, a0 # Setup exit value before too late
+
+ xor t0, a1, a0 # Find a0/a1 displacement
+ andi t0, 0x7
+ bne t0, zero, L(shift) # Go handle the unaligned case
+ PTR_SUBU t1, zero, a1
+ andi t1, 0x7 # a0/a1 are aligned, but are we
+ beq t1, zero, L(chk8w) # starting in the middle of a word?
+ PTR_SUBU a2, t1
+ LDHI t0, 0(a1) # Yes we are... take care of that
+ PTR_ADDU a1, t1
+ SDHI t0, 0(a0)
+ PTR_ADDU a0, t1
+
+L(chk8w):
+ andi t0, a2, 0x3f # 64 or more bytes left?
+ beq t0, a2, L(chk1w)
+ PTR_SUBU a3, a2, t0 # Yes
+ PTR_ADDU a3, a1 # a3 = end address of loop
+ move a2, t0 # a2 = what will be left after loop
+L(lop8w):
+ ld t0, 0(a1) # Loop taking 8 words at a time
+ ld t1, 8(a1)
+ ld t2, 16(a1)
+ ld t3, 24(a1)
+ ld ta0, 32(a1)
+ ld ta1, 40(a1)
+ ld ta2, 48(a1)
+ ld ta3, 56(a1)
+ PTR_ADDIU a0, 64
+ PTR_ADDIU a1, 64
+ sd t0, -64(a0)
+ sd t1, -56(a0)
+ sd t2, -48(a0)
+ sd t3, -40(a0)
+ sd ta0, -32(a0)
+ sd ta1, -24(a0)
+ sd ta2, -16(a0)
+ bne a1, a3, L(lop8w)
+ sd ta3, -8(a0)
+
+L(chk1w):
+ andi t0, a2, 0x7 # 8 or more bytes left?
+ beq t0, a2, L(last16)
+ PTR_SUBU a3, a2, t0 # Yes, handle them one dword at a time
+ PTR_ADDU a3, a1 # a3 again end address
+ move a2, t0
+L(lop1w):
+ ld t0, 0(a1)
+ PTR_ADDIU a0, 8
+ PTR_ADDIU a1, 8
+ bne a1, a3, L(lop1w)
+ sd t0, -8(a0)
+
+L(last16):
+ blez a2, L(lst16e) # Handle last 16 bytes, one at a time
+ PTR_ADDU a3, a2, a1
+L(lst16l):
+ lb t0, 0(a1)
+ PTR_ADDIU a0, 1
+ PTR_ADDIU a1, 1
+ bne a1, a3, L(lst16l)
+ sb t0, -1(a0)
+L(lst16e):
+ jr ra # Bye, bye
+ nop
+
+L(shift):
+ PTR_SUBU a3, zero, a0 # Src and Dest unaligned
+ andi a3, 0x7 # (unoptimized case...)
+ beq a3, zero, L(shft1)
+ PTR_SUBU a2, a3 # a2 = bytes left
+ LDHI t0, 0(a1) # Take care of first odd part
+ LDLO t0, 7(a1)
+ PTR_ADDU a1, a3
+ SDHI t0, 0(a0)
+ PTR_ADDU a0, a3
+L(shft1):
+ andi t0, a2, 0x7
+ PTR_SUBU a3, a2, t0
+ PTR_ADDU a3, a1
+L(shfth):
+ LDHI t1, 0(a1) # Limp through, dword by dword
+ LDLO t1, 7(a1)
+ PTR_ADDIU a0, 8
+ PTR_ADDIU a1, 8
+ bne a1, a3, L(shfth)
+ sd t1, -8(a0)
+ b L(last16) # Handle anything which may be left
+ move a2, t0
+
+ .set reorder
+END (memcpy)
+libc_hidden_builtin_def (memcpy)
diff --git a/ports/sysdeps/mips/mips64/memset.S b/ports/sysdeps/mips/mips64/memset.S
new file mode 100644
index 000000000..b50aaba81
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/memset.S
@@ -0,0 +1,92 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Hartvig Ekner <hartvige@mips.com>, 2002.
+ Ported to mips3 n32/n64 by Alexandre Oliva <aoliva@redhat.com>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <endian.h>
+#include <sys/asm.h>
+
+
+/* void *memset(void *s, int c, size_t n);
+
+ This could probably be optimized further. */
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define SDHI sdl /* high part is left in big-endian */
+#else
+# define SDHI sdr /* high part is right in little-endian */
+#endif
+
+ENTRY (memset)
+ .set noreorder
+
+ slti ta1, a2, 16 # Less than 16?
+ bne ta1, zero, L(last16)
+ move v0, a0 # Setup exit value before too late
+
+ beq a1, zero, L(ueven) # If zero pattern, no need to extend
+ andi a1, 0xff # Avoid problems with bogus arguments
+ dsll ta0, a1, 8
+ or a1, ta0
+ dsll ta0, a1, 16
+ or a1, ta0 # a1 is now pattern in full word
+ dsll ta0, a1, 32
+ or a1, ta0 # a1 is now pattern in double word
+
+L(ueven):
+ PTR_SUBU ta0, zero, a0 # Unaligned address?
+ andi ta0, 0x7
+ beq ta0, zero, L(chkw)
+ PTR_SUBU a2, ta0
+ SDHI a1, 0(a0) # Yes, handle first unaligned part
+ PTR_ADDU a0, ta0 # Now both a0 and a2 are updated
+
+L(chkw):
+ andi ta0, a2, 0xf # Enough left for one loop iteration?
+ beq ta0, a2, L(chkl)
+ PTR_SUBU a3, a2, ta0
+ PTR_ADDU a3, a0 # a3 is last loop address +1
+ move a2, ta0 # a2 is now # of bytes left after loop
+L(loopw):
+ PTR_ADDIU a0, 16 # Handle 2 dwords pr. iteration
+ sd a1, -16(a0)
+ bne a0, a3, L(loopw)
+ sd a1, -8(a0)
+
+L(chkl):
+ andi ta0, a2, 0x8 # Check if there is at least a double
+ beq ta0, zero, L(last16) # word remaining after the loop
+ PTR_SUBU a2, ta0
+ sd a1, 0(a0) # Yes...
+ PTR_ADDIU a0, 8
+
+L(last16):
+ blez a2, L(exit) # Handle last 16 bytes (if cnt>0)
+ PTR_ADDU a3, a2, a0 # a3 is last address +1
+L(lst16l):
+ PTR_ADDIU a0, 1
+ bne a0, a3, L(lst16l)
+ sb a1, -1(a0)
+L(exit):
+ j ra # Bye, bye
+ nop
+
+ .set reorder
+END (memset)
+libc_hidden_builtin_def (memset)
diff --git a/ports/sysdeps/mips/mips64/mul_1.S b/ports/sysdeps/mips/mips64/mul_1.S
new file mode 100644
index 000000000..c71178300
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/mul_1.S
@@ -0,0 +1,96 @@
+/* MIPS3 __mpn_mul_1 -- Multiply a limb vector with a single limb and
+ * store the product in a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 2000, 2002, 2003
+ * 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 Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 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 Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#include <sysdep.h>
+#include <sys/asm.h>
+
+/* INPUT PARAMETERS
+ * res_ptr $4
+ * s1_ptr $5
+ * size $6
+ * s2_limb $7
+ */
+
+#ifdef __PIC__
+ .option pic2
+#endif
+ .text
+ .align 4
+ .globl __mpn_mul_1
+ .ent __mpn_mul_1
+__mpn_mul_1:
+#ifdef __PIC__
+ SETUP_GP /* ??? unused */
+#endif
+ .set noreorder
+ .set nomacro
+
+ # warm up phase 0
+ ld $8,0($5)
+
+ # warm up phase 1
+ daddiu $5,$5,8
+ dmultu $8,$7
+
+ daddiu $6,$6,-1
+ beq $6,$0,L(LC0)
+ move $2,$0 # zero cy2
+
+ daddiu $6,$6,-1
+ beq $6,$0,L(LC1)
+ ld $8,0($5) # load new s1 limb as early as possible
+
+L(Loop): mflo $10
+ mfhi $9
+ daddiu $5,$5,8
+ daddu $10,$10,$2 # add old carry limb to low product limb
+ dmultu $8,$7
+ ld $8,0($5) # load new s1 limb as early as possible
+ daddiu $6,$6,-1 # decrement loop counter
+ sltu $2,$10,$2 # carry from previous addition -> $2
+ sd $10,0($4)
+ daddiu $4,$4,8
+ bne $6,$0,L(Loop)
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+ # cool down phase 1
+L(LC1): mflo $10
+ mfhi $9
+ daddu $10,$10,$2
+ sltu $2,$10,$2
+ dmultu $8,$7
+ sd $10,0($4)
+ daddiu $4,$4,8
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+ # cool down phase 0
+L(LC0): mflo $10
+ mfhi $9
+ daddu $10,$10,$2
+ sltu $2,$10,$2
+ sd $10,0($4)
+ j $31
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+ .end __mpn_mul_1
diff --git a/ports/sysdeps/mips/mips64/n32/Implies b/ports/sysdeps/mips/mips64/n32/Implies
new file mode 100644
index 000000000..a7cb280ec
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/n32/Implies
@@ -0,0 +1,4 @@
+ieee754/ldbl-128
+mips/mips64
+mips
+wordsize-32
diff --git a/ports/sysdeps/mips/mips64/n32/Makefile b/ports/sysdeps/mips/mips64/n32/Makefile
new file mode 100644
index 000000000..a84d2a51b
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/n32/Makefile
@@ -0,0 +1,6 @@
+# `long double' is a distinct type we support.
+long-double-fcts = yes
+
+ifeq ($(filter -mabi=n32,$(CC)),)
+CC += -mabi=n32
+endif
diff --git a/ports/sysdeps/mips/mips64/n32/libm-test-ulps b/ports/sysdeps/mips/mips64/n32/libm-test-ulps
new file mode 100644
index 000000000..d9df631d7
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/n32/libm-test-ulps
@@ -0,0 +1,1245 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.00756827042671106339, -.001792735857538728036) == -1.80338464113663849327153994379639112":
+ildouble: 1
+ldouble: 1
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cacos
+Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
+ildouble: 1
+ldouble: 1
+
+# cacosh
+Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+ildouble: 1
+ldouble: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 2
+ldouble: 2
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# catan
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+ildouble: 1
+ldouble: 1
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+ildouble: 1
+ldouble: 1
+
+# cbrt
+Test "cbrt (-0.001) == -0.1":
+ildouble: 1
+ldouble: 1
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Real part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Real part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+ildouble: 1
+ldouble: 1
+
+# clog
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 4
+ldouble: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 10
+ldouble: 10
+Test "Real part of: cpow (2 + 0 i, 10 + 0 i) == 1024.0 + 0.0 i":
+ildouble: 2
+ldouble: 2
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 3
+ldouble: 3
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# csin
+Test "Imaginary part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+ildouble: 1
+ldouble: 1
+
+# csinh
+Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0.75 + 1.25 i) == 1.05065169626078392338656675760808326 + 0.594868882070379067881984030639932657 i":
+ildouble: 1
+ldouble: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (27.0) == 0.523704892378925568501606768284954709e-318":
+ildouble: 1
+ldouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# exp2
+Test "exp2 (10) == 1024":
+ildouble: 2
+ldouble: 2
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# gamma
+Test "gamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# j1
+Test "j1 (-1.0) == -0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "j1 (0.75) == 0.349243602174862192523281016426251335":
+ildouble: 1
+ldouble: 1
+Test "j1 (1.0) == 0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 4
+ldouble: 4
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (1, -1.0) == -0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 0.75) == 0.349243602174862192523281016426251335":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 1.0) == 0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 4
+ldouble: 4
+Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+ildouble: 2
+ldouble: 2
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# log2
+Test "log2 (0.75) == -.415037499278843818546261056052183492":
+ildouble: 1
+ldouble: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# sqrt
+Test "sqrt (2) == M_SQRT2l":
+ildouble: 1
+ldouble: 1
+
+# tanh
+Test "tanh (-0.75) == -0.635148952387287319214434357312496495":
+ildouble: 1
+ldouble: 1
+Test "tanh (-1.0) == -0.7615941559557648881194582826047935904":
+ildouble: 1
+ldouble: 1
+Test "tanh (0.75) == 0.635148952387287319214434357312496495":
+ildouble: 1
+ldouble: 1
+Test "tanh (1.0) == 0.7615941559557648881194582826047935904":
+ildouble: 1
+ldouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (4) == 6":
+ildouble: 1
+ldouble: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "y1 (0.75) == -1.03759455076928541973767132140642198":
+ildouble: 1
+ldouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# yn
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "yn (1, 0.75) == -1.03759455076928541973767132140642198":
+ildouble: 1
+ldouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 5
+ldouble: 5
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+idouble: 2
+ildouble: 2
+ldouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cacos":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cacosh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "casin":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 4
+ldouble: 4
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "catanh":
+ildouble: 1
+ldouble: 1
+
+Function: "cbrt":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+ildouble: 10
+ldouble: 10
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csin":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csin":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csqrt":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ctan":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "exp2":
+ildouble: 2
+ldouble: 2
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "gamma":
+ildouble: 1
+ldouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 4
+ldouble: 4
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+ildouble: 4
+ldouble: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log1p":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "log2":
+ildouble: 1
+ldouble: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sqrt":
+ildouble: 1
+ldouble: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tanh":
+ildouble: 1
+ldouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 5
+ldouble: 5
+
+# end of automatic generation
diff --git a/ports/sysdeps/mips/mips64/n64/Implies b/ports/sysdeps/mips/mips64/n64/Implies
new file mode 100644
index 000000000..e50778678
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/n64/Implies
@@ -0,0 +1,4 @@
+ieee754/ldbl-128
+mips/mips64
+mips
+wordsize-64
diff --git a/ports/sysdeps/mips/mips64/n64/Makefile b/ports/sysdeps/mips/mips64/n64/Makefile
new file mode 100644
index 000000000..a823f32b5
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/n64/Makefile
@@ -0,0 +1,6 @@
+# `long double' is a distinct type we support.
+long-double-fcts = yes
+
+ifeq ($(filter -mabi=64,$(CC)),)
+CC += -mabi=64
+endif
diff --git a/ports/sysdeps/mips/mips64/n64/libm-test-ulps b/ports/sysdeps/mips/mips64/n64/libm-test-ulps
new file mode 100644
index 000000000..d9df631d7
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/n64/libm-test-ulps
@@ -0,0 +1,1245 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.00756827042671106339, -.001792735857538728036) == -1.80338464113663849327153994379639112":
+ildouble: 1
+ldouble: 1
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cacos
+Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
+ildouble: 1
+ldouble: 1
+
+# cacosh
+Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+ildouble: 1
+ldouble: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 2
+ldouble: 2
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# catan
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+ildouble: 1
+ldouble: 1
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+ildouble: 1
+ldouble: 1
+
+# cbrt
+Test "cbrt (-0.001) == -0.1":
+ildouble: 1
+ldouble: 1
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Real part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Real part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+ildouble: 1
+ldouble: 1
+
+# clog
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 4
+ldouble: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 10
+ldouble: 10
+Test "Real part of: cpow (2 + 0 i, 10 + 0 i) == 1024.0 + 0.0 i":
+ildouble: 2
+ldouble: 2
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 3
+ldouble: 3
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# csin
+Test "Imaginary part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+ildouble: 1
+ldouble: 1
+
+# csinh
+Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0.75 + 1.25 i) == 1.05065169626078392338656675760808326 + 0.594868882070379067881984030639932657 i":
+ildouble: 1
+ldouble: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (27.0) == 0.523704892378925568501606768284954709e-318":
+ildouble: 1
+ldouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# exp2
+Test "exp2 (10) == 1024":
+ildouble: 2
+ldouble: 2
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# gamma
+Test "gamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# j1
+Test "j1 (-1.0) == -0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "j1 (0.75) == 0.349243602174862192523281016426251335":
+ildouble: 1
+ldouble: 1
+Test "j1 (1.0) == 0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 4
+ldouble: 4
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (1, -1.0) == -0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 0.75) == 0.349243602174862192523281016426251335":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 1.0) == 0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 4
+ldouble: 4
+Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+ildouble: 2
+ldouble: 2
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# log2
+Test "log2 (0.75) == -.415037499278843818546261056052183492":
+ildouble: 1
+ldouble: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# sqrt
+Test "sqrt (2) == M_SQRT2l":
+ildouble: 1
+ldouble: 1
+
+# tanh
+Test "tanh (-0.75) == -0.635148952387287319214434357312496495":
+ildouble: 1
+ldouble: 1
+Test "tanh (-1.0) == -0.7615941559557648881194582826047935904":
+ildouble: 1
+ldouble: 1
+Test "tanh (0.75) == 0.635148952387287319214434357312496495":
+ildouble: 1
+ldouble: 1
+Test "tanh (1.0) == 0.7615941559557648881194582826047935904":
+ildouble: 1
+ldouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (4) == 6":
+ildouble: 1
+ldouble: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "y1 (0.75) == -1.03759455076928541973767132140642198":
+ildouble: 1
+ldouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# yn
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "yn (1, 0.75) == -1.03759455076928541973767132140642198":
+ildouble: 1
+ldouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 5
+ldouble: 5
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+idouble: 2
+ildouble: 2
+ldouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cacos":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cacosh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "casin":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 4
+ldouble: 4
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "catanh":
+ildouble: 1
+ldouble: 1
+
+Function: "cbrt":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+ildouble: 10
+ldouble: 10
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csin":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csin":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csqrt":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ctan":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "exp2":
+ildouble: 2
+ldouble: 2
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "gamma":
+ildouble: 1
+ldouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 4
+ldouble: 4
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+ildouble: 4
+ldouble: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log1p":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "log2":
+ildouble: 1
+ldouble: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sqrt":
+ildouble: 1
+ldouble: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tanh":
+ildouble: 1
+ldouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 5
+ldouble: 5
+
+# end of automatic generation
diff --git a/ports/sysdeps/mips/mips64/rshift.S b/ports/sysdeps/mips/mips64/rshift.S
new file mode 100644
index 000000000..e6a8a06d3
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/rshift.S
@@ -0,0 +1,102 @@
+/* MIPS3 __mpn_rshift --
+ *
+ * Copyright (C) 1995, 2000, 2002, 2003 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 Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 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 Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#include <sysdep.h>
+#include <sys/asm.h>
+
+/* INPUT PARAMETERS
+ * res_ptr $4
+ * src_ptr $5
+ * size $6
+ * cnt $7
+ */
+
+#ifdef __PIC__
+ .option pic2
+#endif
+ .text
+ .align 2
+ .globl __mpn_rshift
+ .ent __mpn_rshift
+__mpn_rshift:
+#ifdef __PIC__
+ SETUP_GP /* ??? unused */
+#endif
+ .set noreorder
+ .set nomacro
+
+ ld $10,0($5) # load first limb
+ dsubu $13,$0,$7
+ daddiu $6,$6,-1
+ and $9,$6,4-1 # number of limbs in first loop
+ beq $9,$0,L(L0) # if multiple of 4 limbs, skip first loop
+ dsll $2,$10,$13 # compute function result
+
+ dsubu $6,$6,$9
+
+L(Loop0): ld $3,8($5)
+ daddiu $4,$4,8
+ daddiu $5,$5,8
+ daddiu $9,$9,-1
+ dsrl $11,$10,$7
+ dsll $12,$3,$13
+ move $10,$3
+ or $8,$11,$12
+ bne $9,$0,L(Loop0)
+ sd $8,-8($4)
+
+L(L0): beq $6,$0,L(Lend)
+ nop
+
+L(Loop): ld $3,8($5)
+ daddiu $4,$4,32
+ daddiu $6,$6,-4
+ dsrl $11,$10,$7
+ dsll $12,$3,$13
+
+ ld $10,16($5)
+ dsrl $14,$3,$7
+ or $8,$11,$12
+ sd $8,-32($4)
+ dsll $9,$10,$13
+
+ ld $3,24($5)
+ dsrl $11,$10,$7
+ or $8,$14,$9
+ sd $8,-24($4)
+ dsll $12,$3,$13
+
+ ld $10,32($5)
+ dsrl $14,$3,$7
+ or $8,$11,$12
+ sd $8,-16($4)
+ dsll $9,$10,$13
+
+ daddiu $5,$5,32
+ or $8,$14,$9
+ bgtz $6,L(Loop)
+ sd $8,-8($4)
+
+L(Lend): dsrl $8,$10,$7
+ j $31
+ sd $8,0($4)
+ .end __mpn_rshift
diff --git a/ports/sysdeps/mips/mips64/setjmp.S b/ports/sysdeps/mips/mips64/setjmp.S
new file mode 100644
index 000000000..bdfd9cd51
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/setjmp.S
@@ -0,0 +1,46 @@
+/* Copyright (C) 1996, 1997, 2000, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sgidefs.h>
+#include <sysdep.h>
+#include <sys/asm.h>
+
+/* The function __sigsetjmp_aux saves all the registers, but it can't
+ reliably access the stack or frame pointers, so we pass them in as
+ extra arguments. */
+#ifdef __PIC__
+ .option pic2
+#endif
+ENTRY (__sigsetjmp)
+#ifdef __PIC__
+ SETUP_GP
+#endif
+ SETUP_GP64 (v0, C_SYMBOL_NAME (__sigsetjmp))
+ move a2, sp
+ move a3, fp
+ PTR_LA t9, __sigsetjmp_aux
+#if _MIPS_SIM == _ABIO32
+ nop
+#endif
+ RESTORE_GP64
+#if _MIPS_SIM != _ABIO32
+ move a4, gp
+#endif
+ jr t9
+ .end __sigsetjmp
diff --git a/ports/sysdeps/mips/mips64/setjmp_aux.c b/ports/sysdeps/mips/mips64/setjmp_aux.c
new file mode 100644
index 000000000..26b4739c3
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/setjmp_aux.c
@@ -0,0 +1,78 @@
+/* Copyright (C) 1996, 1997, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <setjmp.h>
+#include <sgidefs.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, long long sp, long long fp,
+ long long gp)
+{
+ /* Store the floating point callee-saved registers... */
+#if _MIPS_SIM == _ABI64
+ asm volatile ("s.d $f24, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[0]));
+ asm volatile ("s.d $f25, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[1]));
+ asm volatile ("s.d $f26, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[2]));
+ asm volatile ("s.d $f27, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[3]));
+ asm volatile ("s.d $f28, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[4]));
+ asm volatile ("s.d $f29, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[5]));
+ asm volatile ("s.d $f30, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[6]));
+ asm volatile ("s.d $f31, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[7]));
+#else
+ 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]));
+#endif
+
+ /* .. and the PC; */
+ asm volatile ("sd $31, %0" : : "m" (env[0].__jmpbuf[0].__pc));
+
+ /* .. and the stack pointer; */
+ env[0].__jmpbuf[0].__sp = sp;
+
+ /* .. and the FP; it'll be in s8. */
+ env[0].__jmpbuf[0].__fp = fp;
+
+ /* .. and the GP; */
+ env[0].__jmpbuf[0].__gp = gp;
+
+ /* .. and the callee-saved registers; */
+ asm volatile ("sd $16, %0" : : "m" (env[0].__jmpbuf[0].__regs[0]));
+ asm volatile ("sd $17, %0" : : "m" (env[0].__jmpbuf[0].__regs[1]));
+ asm volatile ("sd $18, %0" : : "m" (env[0].__jmpbuf[0].__regs[2]));
+ asm volatile ("sd $19, %0" : : "m" (env[0].__jmpbuf[0].__regs[3]));
+ asm volatile ("sd $20, %0" : : "m" (env[0].__jmpbuf[0].__regs[4]));
+ asm volatile ("sd $21, %0" : : "m" (env[0].__jmpbuf[0].__regs[5]));
+ asm volatile ("sd $22, %0" : : "m" (env[0].__jmpbuf[0].__regs[6]));
+ asm volatile ("sd $23, %0" : : "m" (env[0].__jmpbuf[0].__regs[7]));
+
+ /* .. and finally get and reconstruct the floating point csr. */
+ asm ("cfc1 %0, $31" : "=r" (env[0].__jmpbuf[0].__fpc_csr));
+
+ /* Save the signal mask if requested. */
+ return __sigjmp_save (env, savemask);
+}
diff --git a/ports/sysdeps/mips/mips64/soft-fp/sfp-machine.h b/ports/sysdeps/mips/mips64/soft-fp/sfp-machine.h
new file mode 100644
index 000000000..309a14a5f
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/soft-fp/sfp-machine.h
@@ -0,0 +1,47 @@
+#define _FP_W_TYPE_SIZE 64
+#define _FP_W_TYPE unsigned long long
+#define _FP_WS_TYPE signed long long
+#define _FP_I_TYPE long long
+
+#define _FP_MUL_MEAT_S(R,X,Y) \
+ _FP_MUL_MEAT_1_imm(_FP_WFRACBITS_S,R,X,Y)
+#define _FP_MUL_MEAT_D(R,X,Y) \
+ _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_Q(R,X,Y) \
+ _FP_MUL_MEAT_2_wide_3mul(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
+
+#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_imm(S,R,X,Y,_FP_DIV_HELP_imm)
+#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(D,R,X,Y)
+#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_2_udiv(Q,R,X,Y)
+
+#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
+#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1)
+#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1
+#define _FP_NANSIGN_S 0
+#define _FP_NANSIGN_D 0
+#define _FP_NANSIGN_Q 0
+
+#define _FP_KEEPNANFRACP 1
+/* From my experiments it seems X is chosen unless one of the
+ NaNs is sNaN, in which case the result is NANSIGN/NANFRAC. */
+#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
+ do { \
+ if ((_FP_FRAC_HIGH_RAW_##fs(X) | \
+ _FP_FRAC_HIGH_RAW_##fs(Y)) & _FP_QNANBIT_##fs) \
+ { \
+ R##_s = _FP_NANSIGN_##fs; \
+ _FP_FRAC_SET_##wc(R,_FP_NANFRAC_##fs); \
+ } \
+ else \
+ { \
+ R##_s = X##_s; \
+ _FP_FRAC_COPY_##wc(R,X); \
+ } \
+ R##_c = FP_CLS_NAN; \
+ } while (0)
+
+#define FP_EX_INVALID (1 << 4)
+#define FP_EX_DIVZERO (1 << 3)
+#define FP_EX_OVERFLOW (1 << 2)
+#define FP_EX_UNDERFLOW (1 << 1)
+#define FP_EX_INEXACT (1 << 0)
diff --git a/ports/sysdeps/mips/mips64/sub_n.S b/ports/sysdeps/mips/mips64/sub_n.S
new file mode 100644
index 000000000..aa8b0dcf9
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/sub_n.S
@@ -0,0 +1,130 @@
+/* MIPS3 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
+ * store difference in a third limb vector.
+ *
+ * Copyright (C) 1995, 2000, 2002, 2003 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 Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 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 Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#include <sysdep.h>
+#include <sys/asm.h>
+
+/* INPUT PARAMETERS
+ * res_ptr $4
+ * s1_ptr $5
+ * s2_ptr $6
+ * size $7
+ */
+
+#ifdef __PIC__
+ .option pic2
+#endif
+ .text
+ .align 2
+ .globl __mpn_sub_n
+ .ent __mpn_sub_n
+__mpn_sub_n:
+#ifdef __PIC__
+ SETUP_GP /* ??? unused */
+#endif
+ .set noreorder
+ .set nomacro
+
+ ld $10,0($5)
+ ld $11,0($6)
+
+ daddiu $7,$7,-1
+ and $9,$7,4-1 # number of limbs in first loop
+ beq $9,$0,L(L0) # if multiple of 4 limbs, skip first loop
+ move $2,$0
+
+ dsubu $7,$7,$9
+
+L(Loop0): daddiu $9,$9,-1
+ ld $12,8($5)
+ daddu $11,$11,$2
+ ld $13,8($6)
+ sltu $8,$11,$2
+ dsubu $11,$10,$11
+ sltu $2,$10,$11
+ sd $11,0($4)
+ or $2,$2,$8
+
+ daddiu $5,$5,8
+ daddiu $6,$6,8
+ move $10,$12
+ move $11,$13
+ bne $9,$0,L(Loop0)
+ daddiu $4,$4,8
+
+L(L0): beq $7,$0,L(Lend)
+ nop
+
+L(Loop): daddiu $7,$7,-4
+
+ ld $12,8($5)
+ daddu $11,$11,$2
+ ld $13,8($6)
+ sltu $8,$11,$2
+ dsubu $11,$10,$11
+ sltu $2,$10,$11
+ sd $11,0($4)
+ or $2,$2,$8
+
+ ld $10,16($5)
+ daddu $13,$13,$2
+ ld $11,16($6)
+ sltu $8,$13,$2
+ dsubu $13,$12,$13
+ sltu $2,$12,$13
+ sd $13,8($4)
+ or $2,$2,$8
+
+ ld $12,24($5)
+ daddu $11,$11,$2
+ ld $13,24($6)
+ sltu $8,$11,$2
+ dsubu $11,$10,$11
+ sltu $2,$10,$11
+ sd $11,16($4)
+ or $2,$2,$8
+
+ ld $10,32($5)
+ daddu $13,$13,$2
+ ld $11,32($6)
+ sltu $8,$13,$2
+ dsubu $13,$12,$13
+ sltu $2,$12,$13
+ sd $13,24($4)
+ or $2,$2,$8
+
+ daddiu $5,$5,32
+ daddiu $6,$6,32
+
+ bne $7,$0,L(Loop)
+ daddiu $4,$4,32
+
+L(Lend): daddu $11,$11,$2
+ sltu $8,$11,$2
+ dsubu $11,$10,$11
+ sltu $2,$10,$11
+ sd $11,0($4)
+ j $31
+ or $2,$2,$8
+
+ .end __mpn_sub_n
diff --git a/ports/sysdeps/mips/mips64/submul_1.S b/ports/sysdeps/mips/mips64/submul_1.S
new file mode 100644
index 000000000..4971b992a
--- /dev/null
+++ b/ports/sysdeps/mips/mips64/submul_1.S
@@ -0,0 +1,108 @@
+/* MIPS3 __mpn_submul_1 -- Multiply a limb vector with a single limb and
+ * subtract the product from a second limb vector.
+ *
+ * Copyright (C) 1992, 1994, 1995, 2000, 2002, 2003
+ * 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 Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 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 Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#include <sysdep.h>
+#include <sys/asm.h>
+
+/* INPUT PARAMETERS
+ * res_ptr $4
+ * s1_ptr $5
+ * size $6
+ * s2_limb $7
+ */
+
+#ifdef __PIC__
+ .option pic2
+#endif
+ .text
+ .align 4
+ .globl __mpn_submul_1
+ .ent __mpn_submul_1
+__mpn_submul_1:
+#ifdef __PIC__
+ SETUP_GP /* ??? unused */
+#endif
+ .set noreorder
+ .set nomacro
+
+ # warm up phase 0
+ ld $8,0($5)
+
+ # warm up phase 1
+ daddiu $5,$5,8
+ dmultu $8,$7
+
+ daddiu $6,$6,-1
+ beq $6,$0,L(LC0)
+ move $2,$0 # zero cy2
+
+ daddiu $6,$6,-1
+ beq $6,$0,L(LC1)
+ ld $8,0($5) # load new s1 limb as early as possible
+
+L(Loop): ld $10,0($4)
+ mflo $3
+ mfhi $9
+ daddiu $5,$5,8
+ daddu $3,$3,$2 # add old carry limb to low product limb
+ dmultu $8,$7
+ ld $8,0($5) # load new s1 limb as early as possible
+ daddiu $6,$6,-1 # decrement loop counter
+ sltu $2,$3,$2 # carry from previous addition -> $2
+ dsubu $3,$10,$3
+ sgtu $10,$3,$10
+ daddu $2,$2,$10
+ sd $3,0($4)
+ daddiu $4,$4,8
+ bne $6,$0,L(Loop)
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+ # cool down phase 1
+L(LC1): ld $10,0($4)
+ mflo $3
+ mfhi $9
+ daddu $3,$3,$2
+ sltu $2,$3,$2
+ dmultu $8,$7
+ dsubu $3,$10,$3
+ sgtu $10,$3,$10
+ daddu $2,$2,$10
+ sd $3,0($4)
+ daddiu $4,$4,8
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+ # cool down phase 0
+L(LC0): ld $10,0($4)
+ mflo $3
+ mfhi $9
+ daddu $3,$3,$2
+ sltu $2,$3,$2
+ dsubu $3,$10,$3
+ sgtu $10,$3,$10
+ daddu $2,$2,$10
+ sd $3,0($4)
+ j $31
+ daddu $2,$9,$2 # add high product limb and carry from addition
+
+ .end __mpn_submul_1
diff --git a/ports/sysdeps/mips/mul_1.S b/ports/sysdeps/mips/mul_1.S
new file mode 100644
index 000000000..72f538670
--- /dev/null
+++ b/ports/sysdeps/mips/mul_1.S
@@ -0,0 +1,87 @@
+/* MIPS __mpn_mul_1 -- Multiply a limb vector with a single limb and
+store the product in a second limb vector.
+
+Copyright (C) 1995, 1998, 2000, 2002, 2003 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+/* INPUT PARAMETERS
+ res_ptr $4
+ s1_ptr $5
+ size $6
+ s2_limb $7
+*/
+#ifdef __PIC__
+ .option pic2
+#endif
+ENTRY (__mpn_mul_1)
+ .set noreorder
+#ifdef __PIC__
+ .cpload t9
+#endif
+ .set nomacro
+
+ /* warm up phase 0 */
+ lw $8,0($5)
+
+ /* warm up phase 1 */
+ addiu $5,$5,4
+ multu $8,$7
+
+ addiu $6,$6,-1
+ beq $6,$0,L(LC0)
+ move $2,$0 /* zero cy2 */
+
+ addiu $6,$6,-1
+ beq $6,$0,L(LC1)
+ lw $8,0($5) /* load new s1 limb as early as possible */
+
+L(Loop): mflo $10
+ mfhi $9
+ addiu $5,$5,4
+ addu $10,$10,$2 /* add old carry limb to low product limb */
+ multu $8,$7
+ lw $8,0($5) /* load new s1 limb as early as possible */
+ addiu $6,$6,-1 /* decrement loop counter */
+ sltu $2,$10,$2 /* carry from previous addition -> $2 */
+ sw $10,0($4)
+ addiu $4,$4,4
+ bne $6,$0,L(Loop) /* should be "bnel" */
+ addu $2,$9,$2 /* add high product limb and carry from addition */
+
+ /* cool down phase 1 */
+L(LC1): mflo $10
+ mfhi $9
+ addu $10,$10,$2
+ sltu $2,$10,$2
+ multu $8,$7
+ sw $10,0($4)
+ addiu $4,$4,4
+ addu $2,$9,$2 /* add high product limb and carry from addition */
+
+ /* cool down phase 0 */
+L(LC0): mflo $10
+ mfhi $9
+ addu $10,$10,$2
+ sltu $2,$10,$2
+ sw $10,0($4)
+ j $31
+ addu $2,$9,$2 /* add high product limb and carry from addition */
+ END (__mpn_mul_1)
diff --git a/ports/sysdeps/mips/nptl/Makefile b/ports/sysdeps/mips/nptl/Makefile
new file mode 100644
index 000000000..d0c59a509
--- /dev/null
+++ b/ports/sysdeps/mips/nptl/Makefile
@@ -0,0 +1,25 @@
+# Copyright (C) 2005 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+ifeq ($(subdir),csu)
+gen-as-const-headers += tcb-offsets.sym
+endif
+
+ifeq ($(subdir),nptl)
+libpthread-sysdep_routines += nptl-sysdep
+endif
diff --git a/ports/sysdeps/mips/nptl/nptl-sysdep.S b/ports/sysdeps/mips/nptl/nptl-sysdep.S
new file mode 100644
index 000000000..3f5c2a364
--- /dev/null
+++ b/ports/sysdeps/mips/nptl/nptl-sysdep.S
@@ -0,0 +1,2 @@
+/* Pull in __syscall_error. */
+#include <sysdep.S>
diff --git a/ports/sysdeps/mips/nptl/pthread_spin_lock.S b/ports/sysdeps/mips/nptl/pthread_spin_lock.S
new file mode 100644
index 000000000..d5f2a7234
--- /dev/null
+++ b/ports/sysdeps/mips/nptl/pthread_spin_lock.S
@@ -0,0 +1,37 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/asm.h>
+#include <sysdep.h>
+#include <sgidefs.h>
+
+ENTRY (pthread_spin_lock)
+ .set push
+#if _MIPS_SIM == _ABIO32
+ .set mips2
+#endif
+1: ll a2, 0(a0)
+ li a1, 1
+ bnez a2, 1b
+ sc a1, 0(a0)
+ beqz a1, 1b
+ MIPS_SYNC
+ .set pop
+ li v0, 0
+ ret
+PSEUDO_END (pthread_spin_lock)
diff --git a/ports/sysdeps/mips/nptl/pthread_spin_trylock.S b/ports/sysdeps/mips/nptl/pthread_spin_trylock.S
new file mode 100644
index 000000000..9c6e740f0
--- /dev/null
+++ b/ports/sysdeps/mips/nptl/pthread_spin_trylock.S
@@ -0,0 +1,41 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/asm.h>
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <sgidefs.h>
+
+ENTRY (pthread_spin_trylock)
+ .set push
+#if _MIPS_SIM == _ABIO32
+ .set mips2
+#endif
+ ll a2, 0(a0)
+ li a1, 1
+ bnez a2, 1f
+ sc a1, 0(a0)
+ beqz a1, 1f
+ MIPS_SYNC
+ .set pop
+ li v0, 0
+ ret
+1: li v0, EBUSY
+ ret
+PSEUDO_END (pthread_spin_trylock)
diff --git a/ports/sysdeps/mips/nptl/pthreaddef.h b/ports/sysdeps/mips/nptl/pthreaddef.h
new file mode 100644
index 000000000..e72b4bc58
--- /dev/null
+++ b/ports/sysdeps/mips/nptl/pthreaddef.h
@@ -0,0 +1,39 @@
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. */
+#define STACK_ALIGN 16
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 16
+
+
+/* Location of current stack frame. */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
+
+
+/* XXX Until we have a better place keep the definitions here. */
+
+#define __exit_thread_inline(val) \
+ INLINE_SYSCALL (exit, 1, (val))
diff --git a/ports/sysdeps/mips/nptl/tcb-offsets.sym b/ports/sysdeps/mips/nptl/tcb-offsets.sym
new file mode 100644
index 000000000..e0e71dc43
--- /dev/null
+++ b/ports/sysdeps/mips/nptl/tcb-offsets.sym
@@ -0,0 +1,11 @@
+#include <sysdep.h>
+#include <tls.h>
+
+--
+
+-- Abuse tls.h macros to derive offsets relative to the thread register.
+#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
+
+MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
+PID_OFFSET thread_offsetof (pid)
+TID_OFFSET thread_offsetof (tid)
diff --git a/ports/sysdeps/mips/nptl/tls.h b/ports/sysdeps/mips/nptl/tls.h
new file mode 100644
index 000000000..1cef16101
--- /dev/null
+++ b/ports/sysdeps/mips/nptl/tls.h
@@ -0,0 +1,161 @@
+/* Definition for thread-local data handling. NPTL/MIPS version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _TLS_H
+#define _TLS_H 1
+
+#include <dl-sysdep.h>
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+/* Note: rd must be $v1 to be ABI-conformant. */
+# define READ_THREAD_POINTER() \
+ ({ void *__result; \
+ asm volatile (".set\tpush\n\t.set\tmips32r2\n\t" \
+ "rdhwr\t%0, $29\n\t.set\tpop" : "=v" (__result)); \
+ __result; })
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+
+# define READ_THREAD_POINTER(rd) \
+ .set push; \
+ .set mips32r2; \
+ rdhwr rd, $29; \
+ .set pop
+#endif /* __ASSEMBLER__ */
+
+
+/* We require TLS support in the tools. */
+#ifndef HAVE_TLS_SUPPORT
+# error "TLS support is required."
+#endif
+
+/* Signal that TLS support is available. */
+#define USE_TLS 1
+
+#ifndef __ASSEMBLER__
+
+/* Get system call information. */
+# include <sysdep.h>
+
+/* The TP points to the start of the thread blocks. */
+# define TLS_DTV_AT_TP 1
+
+/* Get the thread descriptor definition. */
+# include <nptl/descr.h>
+
+typedef struct
+{
+ dtv_t *dtv;
+ void *private;
+} tcbhead_t;
+
+/* This is the size of the initial TCB. Because our TCB is before the thread
+ pointer, we don't need this. */
+# define TLS_INIT_TCB_SIZE 0
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
+
+/* This is the size of the TCB. Because our TCB is before the thread
+ pointer, we don't need this. */
+# define TLS_TCB_SIZE 0
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (struct pthread)
+
+/* This is the size we need before TCB - actually, it includes the TCB. */
+# define TLS_PRE_TCB_SIZE \
+ (sizeof (struct pthread) \
+ + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
+
+/* The thread pointer (in hardware register $29) points to the end of
+ the TCB + 0x7000, as for PowerPC. The pthread_descr structure is
+ immediately in front of the TCB. */
+# define TLS_TCB_OFFSET 0x7000
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(tcbp, dtvp) \
+ (((tcbhead_t *) (tcbp))[-1].dtv = (dtvp) + 1)
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtv) \
+ (THREAD_DTV() = (dtv))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(tcbp) \
+ (((tcbhead_t *) (tcbp))[-1].dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(tcbp, secondcall) \
+ ({ INTERNAL_SYSCALL_DECL (err); \
+ long result_var; \
+ result_var = INTERNAL_SYSCALL (set_thread_area, err, 1, \
+ (char *) (tcbp) + TLS_TCB_OFFSET); \
+ INTERNAL_SYSCALL_ERROR_P (result_var, err) \
+ ? "unknown error" : NULL; })
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *) (READ_THREAD_POINTER () - TLS_TCB_OFFSET))[-1].dtv)
+
+/* Return the thread descriptor for the current thread. */
+# define THREAD_SELF \
+ ((struct pthread *) (READ_THREAD_POINTER () \
+ - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF \
+ CONST_THREAD_AREA (32, TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE)
+
+/* Access to data in the thread descriptor is easy. */
+# define THREAD_GETMEM(descr, member) \
+ descr->member
+# define THREAD_GETMEM_NC(descr, member, idx) \
+ descr->member[idx]
+# define THREAD_SETMEM(descr, member, value) \
+ descr->member = (value)
+# define THREAD_SETMEM_NC(descr, member, idx, value) \
+ descr->member[idx] = (value)
+
+/* l_tls_offset == 0 is perfectly valid on MIPS, so we have to use some
+ different value to mean unset l_tls_offset. */
+# define NO_TLS_OFFSET -1
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/ports/sysdeps/mips/preconfigure b/ports/sysdeps/mips/preconfigure
new file mode 100644
index 000000000..9190eee87
--- /dev/null
+++ b/ports/sysdeps/mips/preconfigure
@@ -0,0 +1,29 @@
+case "$machine" in
+mips64*) base_machine=mips64
+ case "$CC $CFLAGS $CPPFLAGS " in
+ *" -mabi=n32 "*) mips_cc_abi=n32 ;;
+ *" -mabi=64 "*|*" -mabi=n64 "*) mips_cc_abi=64 ;;
+ *" -mabi=32 "*|*" -mabi=o32 "*) mips_cc_abi=32 ;;
+ *) mips_cc_abi=default ;;
+ esac
+ case $config_os in
+ *abin32*) mips_config_abi=n32 ;;
+ *abi64*|*abin64*) mips_config_abi=64 ;;
+ *abi32*|*abio32*) mips_config_abi=32 ;;
+ *) mips_config_abi=$mips_cc_abi ;;
+ esac
+ case $mips_config_abi in
+ default) machine=mips/mips64/n32 mips_config_abi=n32 ;;
+ n32) machine=mips/mips64/n32 ;;
+ 64) machine=mips/mips64/n64 ;;
+ 32) machine=mips/mips32/kern64 ;;
+ esac
+ machine=$machine/$config_machine
+ if test $mips_config_abi != $mips_cc_abi; then
+ # This won't make it to config.make, but we want to
+ # set this in case configure tests depend on it.
+ CPPFLAGS="$CPPFLAGS -mabi=$mips_config_abi"
+ fi
+ ;;
+mips*) base_machine=mips machine=mips/mips32/$machine ;;
+esac
diff --git a/ports/sysdeps/mips/regdef.h b/ports/sysdeps/mips/regdef.h
new file mode 100644
index 000000000..bc7f13b4b
--- /dev/null
+++ b/ports/sysdeps/mips/regdef.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ralf Baechle <ralf@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _REGDEF_H
+#define _REGDEF_H
+
+#include <sys/regdef.h>
+#include <sys/fpregdef.h>
+
+#endif /* _REGDEF_H */
+
diff --git a/ports/sysdeps/mips/rshift.S b/ports/sysdeps/mips/rshift.S
new file mode 100644
index 000000000..cb688fe2a
--- /dev/null
+++ b/ports/sysdeps/mips/rshift.S
@@ -0,0 +1,95 @@
+/* MIPS2 __mpn_rshift --
+
+Copyright (C) 1995, 2000, 2002, 2003 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+/* INPUT PARAMETERS
+ res_ptr $4
+ src_ptr $5
+ size $6
+ cnt $7
+*/
+#ifdef __PIC__
+ .option pic2
+#endif
+ENTRY (__mpn_rshift)
+ .set noreorder
+#ifdef __PIC__
+ .cpload t9
+#endif
+ .set nomacro
+
+ lw $10,0($5) /* load first limb */
+ subu $13,$0,$7
+ addiu $6,$6,-1
+ and $9,$6,4-1 /* number of limbs in first loop */
+ beq $9,$0,L(L0) /* if multiple of 4 limbs, skip first loop*/
+ sll $2,$10,$13 /* compute function result */
+
+ subu $6,$6,$9
+
+L(Loop0): lw $3,4($5)
+ addiu $4,$4,4
+ addiu $5,$5,4
+ addiu $9,$9,-1
+ srl $11,$10,$7
+ sll $12,$3,$13
+ move $10,$3
+ or $8,$11,$12
+ bne $9,$0,L(Loop0)
+ sw $8,-4($4)
+
+L(L0): beq $6,$0,L(Lend)
+ nop
+
+L(Loop): lw $3,4($5)
+ addiu $4,$4,16
+ addiu $6,$6,-4
+ srl $11,$10,$7
+ sll $12,$3,$13
+
+ lw $10,8($5)
+ srl $14,$3,$7
+ or $8,$11,$12
+ sw $8,-16($4)
+ sll $9,$10,$13
+
+ lw $3,12($5)
+ srl $11,$10,$7
+ or $8,$14,$9
+ sw $8,-12($4)
+ sll $12,$3,$13
+
+ lw $10,16($5)
+ srl $14,$3,$7
+ or $8,$11,$12
+ sw $8,-8($4)
+ sll $9,$10,$13
+
+ addiu $5,$5,16
+ or $8,$14,$9
+ bgtz $6,L(Loop)
+ sw $8,-4($4)
+
+L(Lend): srl $8,$10,$7
+ j $31
+ sw $8,0($4)
+ END (__mpn_rshift)
diff --git a/ports/sysdeps/mips/setjmp.S b/ports/sysdeps/mips/setjmp.S
new file mode 100644
index 000000000..01ef31399
--- /dev/null
+++ b/ports/sysdeps/mips/setjmp.S
@@ -0,0 +1,45 @@
+/* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+/* The function __sigsetjmp_aux saves all the registers, but it can't
+ reliably access the stack or frame pointers, so we pass them in as
+ extra arguments. */
+#ifdef __PIC__
+ .option pic2
+#endif
+ENTRY (__sigsetjmp)
+#ifdef __PIC__
+ .set noreorder
+ .cpload t9
+ .set reorder
+#endif
+ move a2, sp
+#ifdef fp
+ move a3, fp
+#else
+ move a3, $fp
+#endif
+#ifdef __PIC__
+ la t9, __sigsetjmp_aux
+ jr t9
+#else
+ j __sigsetjmp_aux
+#endif
+ .end __sigsetjmp
diff --git a/ports/sysdeps/mips/setjmp_aux.c b/ports/sysdeps/mips/setjmp_aux.c
new file mode 100644
index 000000000..7125cc4f8
--- /dev/null
+++ b/ports/sysdeps/mips/setjmp_aux.c
@@ -0,0 +1,65 @@
+/* Copyright (C) 1996, 1997, 2000, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <setjmp.h>
+
+/* This function is only called via the assembly language routine
+ __sigsetjmp, which arranges to pass in the stack pointer and the frame
+ pointer. We do things this way because it's difficult to reliably
+ access them in C. */
+
+int
+__sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp)
+{
+ /* Store the floating point callee-saved registers... */
+ asm volatile ("s.d $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 = (void *) sp;
+
+ /* .. and the FP; it'll be in s8. */
+ env[0].__jmpbuf[0].__fp = (void *) 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/ports/sysdeps/mips/sgidefs.h b/ports/sysdeps/mips/sgidefs.h
new file mode 100644
index 000000000..74509fdbd
--- /dev/null
+++ b/ports/sysdeps/mips/sgidefs.h
@@ -0,0 +1,73 @@
+/* Copyright (C) 1996, 1997, 1998, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ralf Baechle <ralf@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SGIDEFS_H
+#define _SGIDEFS_H 1
+
+/*
+ * A crude hack to stop <asm/sgidefs.h>
+ */
+#undef __ASM_SGIDEFS_H
+#define __ASM_SGIDEFS_H
+
+/*
+ * And remove any damage it might have already done
+ */
+#undef _MIPS_ISA_MIPS1
+#undef _MIPS_ISA_MIPS2
+#undef _MIPS_ISA_MIPS3
+#undef _MIPS_ISA_MIPS4
+#undef _MIPS_ISA_MIPS5
+#undef _MIPS_ISA_MIPS32
+#undef _MIPS_ISA_MIPS64
+
+#undef _MIPS_SIM_ABI32
+#undef _MIPS_SIM_NABI32
+#undef _MIPS_SIM_ABI64
+
+/*
+ * Definitions for the ISA level
+ */
+#define _MIPS_ISA_MIPS1 1
+#define _MIPS_ISA_MIPS2 2
+#define _MIPS_ISA_MIPS3 3
+#define _MIPS_ISA_MIPS4 4
+#define _MIPS_ISA_MIPS5 5
+#define _MIPS_ISA_MIPS32 6
+#define _MIPS_ISA_MIPS64 7
+
+/*
+ * Subprogram calling convention
+ */
+#ifndef _ABIO32
+# define _ABIO32 1
+#endif
+#define _MIPS_SIM_ABI32 _ABIO32
+
+#ifndef _ABIN32
+# define _ABIN32 2
+#endif
+#define _MIPS_SIM_NABI32 _ABIN32
+
+#ifndef _ABI64
+# define _ABI64 3
+#endif
+#define _MIPS_SIM_ABI64 _ABI64
+
+#endif /* sgidefs.h */
diff --git a/ports/sysdeps/mips/shlib-versions b/ports/sysdeps/mips/shlib-versions
new file mode 100644
index 000000000..780939369
--- /dev/null
+++ b/ports/sysdeps/mips/shlib-versions
@@ -0,0 +1,21 @@
+mips.*-.*-linux.* libm=6 GLIBC_2.0 GLIBC_2.2
+
+# Working mips versions were never released between 2.0 and 2.2.
+mips.*-.*-linux.* libc=6 GLIBC_2.0 GLIBC_2.2
+
+mips.*-.*-linux.* ld=ld.so.1 GLIBC_2.0 GLIBC_2.2
+mips.*-.*-linux.* libdl=2 GLIBC_2.0 GLIBC_2.2
+
+mips.*-.*-linux.* libresolv=2 GLIBC_2.0 GLIBC_2.2
+
+mips.*-.*-linux.* libnss_files=2 GLIBC_2.0 GLIBC_2.2
+mips.*-.*-linux.* libnss_dns=2 GLIBC_2.0 GLIBC_2.2
+mips.*-.*-linux.* libnss_compat=2 GLIBC_2.0 GLIBC_2.2
+mips.*-.*-linux.* libnss_nis=2 GLIBC_2.0 GLIBC_2.2
+mips.*-.*-linux.* libnss_nisplus=2 GLIBC_2.0 GLIBC_2.2
+mips.*-.*-linux.* libnss_ldap=2 GLIBC_2.0 GLIBC_2.2
+mips.*-.*-linux.* libnss_hesiod=2 GLIBC_2.0 GLIBC_2.2
+
+mips.*-.*-linux.* libnsl=1 GLIBC_2.0 GLIBC_2.2
+
+mips.*-.*-linux.* librt=1 GLIBC_2.0 GLIBC_2.2
diff --git a/ports/sysdeps/mips/soft-fp/sfp-machine.h b/ports/sysdeps/mips/soft-fp/sfp-machine.h
new file mode 100644
index 000000000..3b2a40f0e
--- /dev/null
+++ b/ports/sysdeps/mips/soft-fp/sfp-machine.h
@@ -0,0 +1,47 @@
+#define _FP_W_TYPE_SIZE 32
+#define _FP_W_TYPE unsigned long
+#define _FP_WS_TYPE signed long
+#define _FP_I_TYPE long
+
+#define _FP_MUL_MEAT_S(R,X,Y) \
+ _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_D(R,X,Y) \
+ _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_Q(R,X,Y) \
+ _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
+
+#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv_norm(S,R,X,Y)
+#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
+#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
+
+#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
+#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1
+#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
+#define _FP_NANSIGN_S 0
+#define _FP_NANSIGN_D 0
+#define _FP_NANSIGN_Q 0
+
+#define _FP_KEEPNANFRACP 1
+/* From my experiments it seems X is chosen unless one of the
+ NaNs is sNaN, in which case the result is NANSIGN/NANFRAC. */
+#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
+ do { \
+ if ((_FP_FRAC_HIGH_RAW_##fs(X) | \
+ _FP_FRAC_HIGH_RAW_##fs(Y)) & _FP_QNANBIT_##fs) \
+ { \
+ R##_s = _FP_NANSIGN_##fs; \
+ _FP_FRAC_SET_##wc(R,_FP_NANFRAC_##fs); \
+ } \
+ else \
+ { \
+ R##_s = X##_s; \
+ _FP_FRAC_COPY_##wc(R,X); \
+ } \
+ R##_c = FP_CLS_NAN; \
+ } while (0)
+
+#define FP_EX_INVALID (1 << 4)
+#define FP_EX_DIVZERO (1 << 3)
+#define FP_EX_OVERFLOW (1 << 2)
+#define FP_EX_UNDERFLOW (1 << 1)
+#define FP_EX_INEXACT (1 << 0)
diff --git a/ports/sysdeps/mips/stackinfo.h b/ports/sysdeps/mips/stackinfo.h
new file mode 100644
index 000000000..86e3d621b
--- /dev/null
+++ b/ports/sysdeps/mips/stackinfo.h
@@ -0,0 +1,28 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file contains a bit of information about the stack allocation
+ of the processor. */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+/* On MIPS the stack grows down. */
+#define _STACK_GROWS_DOWN 1
+
+#endif /* stackinfo.h */
diff --git a/ports/sysdeps/mips/sub_n.S b/ports/sysdeps/mips/sub_n.S
new file mode 100644
index 000000000..53fa01934
--- /dev/null
+++ b/ports/sysdeps/mips/sub_n.S
@@ -0,0 +1,122 @@
+/* MIPS2 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
+store difference in a third limb vector.
+
+Copyright (C) 1995, 2000, 2002, 2003 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+/* INPUT PARAMETERS
+ res_ptr $4
+ s1_ptr $5
+ s2_ptr $6
+ size $7
+*/
+#ifdef __PIC__
+ .option pic2
+#endif
+ENTRY (__mpn_sub_n)
+ .set noreorder
+#ifdef __PIC__
+ .cpload t9
+#endif
+ .set nomacro
+
+ lw $10,0($5)
+ lw $11,0($6)
+
+ addiu $7,$7,-1
+ and $9,$7,4-1 /* number of limbs in first loop */
+ beq $9,$0,L(L0) /* if multiple of 4 limbs, skip first loop */
+ move $2,$0
+
+ subu $7,$7,$9
+
+L(Loop0): addiu $9,$9,-1
+ lw $12,4($5)
+ addu $11,$11,$2
+ lw $13,4($6)
+ sltu $8,$11,$2
+ subu $11,$10,$11
+ sltu $2,$10,$11
+ sw $11,0($4)
+ or $2,$2,$8
+
+ addiu $5,$5,4
+ addiu $6,$6,4
+ move $10,$12
+ move $11,$13
+ bne $9,$0,L(Loop0)
+ addiu $4,$4,4
+
+L(L0): beq $7,$0,L(Lend)
+ nop
+
+L(Loop): addiu $7,$7,-4
+
+ lw $12,4($5)
+ addu $11,$11,$2
+ lw $13,4($6)
+ sltu $8,$11,$2
+ subu $11,$10,$11
+ sltu $2,$10,$11
+ sw $11,0($4)
+ or $2,$2,$8
+
+ lw $10,8($5)
+ addu $13,$13,$2
+ lw $11,8($6)
+ sltu $8,$13,$2
+ subu $13,$12,$13
+ sltu $2,$12,$13
+ sw $13,4($4)
+ or $2,$2,$8
+
+ lw $12,12($5)
+ addu $11,$11,$2
+ lw $13,12($6)
+ sltu $8,$11,$2
+ subu $11,$10,$11
+ sltu $2,$10,$11
+ sw $11,8($4)
+ or $2,$2,$8
+
+ lw $10,16($5)
+ addu $13,$13,$2
+ lw $11,16($6)
+ sltu $8,$13,$2
+ subu $13,$12,$13
+ sltu $2,$12,$13
+ sw $13,12($4)
+ or $2,$2,$8
+
+ addiu $5,$5,16
+ addiu $6,$6,16
+
+ bne $7,$0,L(Loop)
+ addiu $4,$4,16
+
+L(Lend): addu $11,$11,$2
+ sltu $8,$11,$2
+ subu $11,$10,$11
+ sltu $2,$10,$11
+ sw $11,0($4)
+ j $31
+ or $2,$2,$8
+ END (__mpn_sub_n)
diff --git a/ports/sysdeps/mips/submul_1.S b/ports/sysdeps/mips/submul_1.S
new file mode 100644
index 000000000..4c8a61265
--- /dev/null
+++ b/ports/sysdeps/mips/submul_1.S
@@ -0,0 +1,99 @@
+/* MIPS __mpn_submul_1 -- Multiply a limb vector with a single limb and
+subtract the product from a second limb vector.
+
+Copyright (C) 1995, 2000, 2002, 2003 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+/* INPUT PARAMETERS
+ res_ptr $4
+ s1_ptr $5
+ size $6
+ s2_limb $7
+*/
+#ifdef __PIC__
+ .option pic2
+#endif
+ENTRY (__mpn_submul_1)
+ .set noreorder
+#ifdef __PIC__
+ .cpload t9
+#endif
+ .set nomacro
+
+ /* warm up phase 0 */
+ lw $8,0($5)
+
+ /* warm up phase 1 */
+ addiu $5,$5,4
+ multu $8,$7
+
+ addiu $6,$6,-1
+ beq $6,$0,L(LC0)
+ move $2,$0 /* zero cy2 */
+
+ addiu $6,$6,-1
+ beq $6,$0,L(LC1)
+ lw $8,0($5) /* load new s1 limb as early as possible */
+
+L(Loop): lw $10,0($4)
+ mflo $3
+ mfhi $9
+ addiu $5,$5,4
+ addu $3,$3,$2 /* add old carry limb to low product limb */
+ multu $8,$7
+ lw $8,0($5) /* load new s1 limb as early as possible */
+ addiu $6,$6,-1 /* decrement loop counter */
+ sltu $2,$3,$2 /* carry from previous addition -> $2 */
+ subu $3,$10,$3
+ sgtu $10,$3,$10
+ addu $2,$2,$10
+ sw $3,0($4)
+ addiu $4,$4,4
+ bne $6,$0,L(Loop) /* should be "bnel" */
+ addu $2,$9,$2 /* add high product limb and carry from addition */
+
+ /* cool down phase 1 */
+L(LC1): lw $10,0($4)
+ mflo $3
+ mfhi $9
+ addu $3,$3,$2
+ sltu $2,$3,$2
+ multu $8,$7
+ subu $3,$10,$3
+ sgtu $10,$3,$10
+ addu $2,$2,$10
+ sw $3,0($4)
+ addiu $4,$4,4
+ addu $2,$9,$2 /* add high product limb and carry from addition */
+
+ /* cool down phase 0 */
+L(LC0): lw $10,0($4)
+ mflo $3
+ mfhi $9
+ addu $3,$3,$2
+ sltu $2,$3,$2
+ subu $3,$10,$3
+ sgtu $10,$3,$10
+ addu $2,$2,$10
+ sw $3,0($4)
+ j $31
+ addu $2,$9,$2 /* add high product limb and carry from addition */
+ END (__mpn_submul_1)
diff --git a/ports/sysdeps/mips/sys/asm.h b/ports/sysdeps/mips/sys/asm.h
new file mode 100644
index 000000000..b590802fd
--- /dev/null
+++ b/ports/sysdeps/mips/sys/asm.h
@@ -0,0 +1,490 @@
+/* Copyright (C) 1997, 1998, 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ralf Baechle <ralf@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_ASM_H
+#define _SYS_ASM_H
+
+#include <sgidefs.h>
+
+#ifndef CAT
+# ifdef __STDC__
+# define __CAT(str1,str2) str1##str2
+# else
+# define __CAT(str1,str2) str1/**/str2
+# endif
+# define CAT(str1,str2) __CAT(str1,str2)
+#endif
+
+/*
+ * Macros to handle different pointer/register sizes for 32/64-bit code
+ *
+ * 64 bit address space isn't used yet, so we may use the R3000 32 bit
+ * defines for now.
+ */
+#if _MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIN32
+# define PTR .word
+# define PTRSIZE 4
+# define PTRLOG 2
+#elif _MIPS_SIM == _ABI64
+# define PTR .dword
+# define PTRSIZE 8
+# define PTRLOG 3
+#endif
+
+/*
+ * PIC specific declarations
+ */
+#if _MIPS_SIM == _ABIO32
+# ifdef __PIC__
+# define CPRESTORE(register) \
+ .cprestore register
+# define CPLOAD(register) \
+ .cpload register
+# else
+# define CPRESTORE(register)
+# define CPLOAD(register)
+# endif
+
+# define CPADD(register) \
+ .cpadd register
+
+/*
+ * Set gp when at 1st instruction
+ */
+# define SETUP_GP \
+ .set noreorder; \
+ .cpload $25; \
+ .set reorder
+/* Set gp when not at 1st instruction */
+# define SETUP_GPX(r) \
+ .set noreorder; \
+ move r, $31; /* Save old ra. */ \
+ bal 10f; /* Find addr of cpload. */ \
+ nop; \
+10: \
+ .cpload $31; \
+ move $31, r; \
+ .set reorder
+# define SETUP_GPX_L(r, l) \
+ .set noreorder; \
+ move r, $31; /* Save old ra. */ \
+ bal l; /* Find addr of cpload. */ \
+ nop; \
+l: \
+ .cpload $31; \
+ move $31, r; \
+ .set reorder
+# define SAVE_GP(x) \
+ .cprestore x /* Save gp trigger t9/jalr conversion. */
+# define SETUP_GP64(a, b)
+# define SETUP_GPX64(a, b)
+# define SETUP_GPX64_L(cp_reg, ra_save, l)
+# define RESTORE_GP64
+# define USE_ALT_CP(a)
+#else /* _MIPS_SIM == _ABI64 || _MIPS_SIM == _ABIN32 */
+/*
+ * For callee-saved gp calling convention:
+ */
+# define SETUP_GP
+# define SETUP_GPX(r)
+# define SETUP_GPX_L(r, l)
+# define SAVE_GP(x)
+
+# define SETUP_GP64(gpoffset, proc) \
+ .cpsetup $25, gpoffset, proc
+# define SETUP_GPX64(cp_reg, ra_save) \
+ move ra_save, $31; /* Save old ra. */ \
+ .set noreorder; \
+ bal 10f; /* Find addr of .cpsetup. */ \
+ nop; \
+10: \
+ .set reorder; \
+ .cpsetup $31, cp_reg, 10b; \
+ move $31, ra_save
+# define SETUP_GPX64_L(cp_reg, ra_save, l) \
+ move ra_save, $31; /* Save old ra. */ \
+ .set noreorder; \
+ bal l; /* Find addr of .cpsetup. */ \
+ nop; \
+l: \
+ .set reorder; \
+ .cpsetup $31, cp_reg, l; \
+ move $31, ra_save
+# define RESTORE_GP64 \
+ .cpreturn
+/* Use alternate register for context pointer. */
+# define USE_ALT_CP(reg) \
+ .cplocal reg
+#endif /* _MIPS_SIM != _ABIO32 */
+
+/*
+ * Stack Frame Definitions
+ */
+#if _MIPS_SIM == _ABIO32
+# define NARGSAVE 4 /* Space for 4 argument registers must be allocated. */
+#endif
+#if _MIPS_SIM == _ABI64 || _MIPS_SIM == _ABIN32
+# define NARGSAVE 0 /* No caller responsibilities. */
+#endif
+
+
+/*
+ * LEAF - declare leaf routine
+ */
+#define LEAF(symbol) \
+ .globl symbol; \
+ .align 2; \
+ .type symbol,@function; \
+ .ent symbol,0; \
+symbol: .frame sp,0,ra
+
+/*
+ * NESTED - declare nested routine entry point
+ */
+#define NESTED(symbol, framesize, rpc) \
+ .globl symbol; \
+ .align 2; \
+ .type symbol,@function; \
+ .ent symbol,0; \
+symbol: .frame sp, framesize, rpc
+
+/*
+ * END - mark end of function
+ */
+#ifndef END
+# define END(function) \
+ .end function; \
+ .size function,.-function
+#endif
+
+/*
+ * EXPORT - export definition of symbol
+ */
+#define EXPORT(symbol) \
+ .globl symbol; \
+symbol:
+
+/*
+ * ABS - export absolute symbol
+ */
+#define ABS(symbol,value) \
+ .globl symbol; \
+symbol = value
+
+#define PANIC(msg) \
+ .set push; \
+ .set reorder; \
+ la a0,8f; \
+ jal panic; \
+9: b 9b; \
+ .set pop; \
+ TEXT(msg)
+
+/*
+ * Print formated string
+ */
+#define PRINT(string) \
+ .set push; \
+ .set reorder; \
+ la a0,8f; \
+ jal printk; \
+ .set pop; \
+ TEXT(string)
+
+#define TEXT(msg) \
+ .data; \
+8: .asciiz msg; \
+ .previous;
+
+/*
+ * Build text tables
+ */
+#define TTABLE(string) \
+ .text; \
+ .word 1f; \
+ .previous; \
+ .data; \
+1: .asciz string; \
+ .previous
+
+/*
+ * MIPS IV pref instruction.
+ * Use with .set noreorder only!
+ *
+ * MIPS IV implementations are free to treat this as a nop. The R5000
+ * is one of them. So we should have an option not to use this instruction.
+ */
+#if (_MIPS_ISA == _MIPS_ISA_MIPS4) || (_MIPS_ISA == _MIPS_ISA_MIPS5) || \
+ (_MIPS_ISA == _MIPS_ISA_MIPS32) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
+# define PREF(hint,addr) \
+ pref hint,addr
+# define PREFX(hint,addr) \
+ prefx hint,addr
+#else
+# define PREF
+# define PREFX
+#endif
+
+/*
+ * MIPS ISA IV/V movn/movz instructions and equivalents for older CPUs.
+ */
+#if _MIPS_ISA == _MIPS_ISA_MIPS1
+# define MOVN(rd,rs,rt) \
+ .set push; \
+ .set reorder; \
+ beqz rt,9f; \
+ move rd,rs; \
+ .set pop; \
+9:
+# define MOVZ(rd,rs,rt) \
+ .set push; \
+ .set reorder; \
+ bnez rt,9f; \
+ move rd,rt; \
+ .set pop; \
+9:
+#endif /* _MIPS_ISA == _MIPS_ISA_MIPS1 */
+#if (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3)
+# define MOVN(rd,rs,rt) \
+ .set push; \
+ .set noreorder; \
+ bnezl rt,9f; \
+ move rd,rs; \
+ .set pop; \
+9:
+# define MOVZ(rd,rs,rt) \
+ .set push; \
+ .set noreorder; \
+ beqzl rt,9f; \
+ movz rd,rs; \
+ .set pop; \
+9:
+#endif /* (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3) */
+#if (_MIPS_ISA == _MIPS_ISA_MIPS4) || (_MIPS_ISA == _MIPS_ISA_MIPS5) || \
+ (_MIPS_ISA == _MIPS_ISA_MIPS32) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
+# define MOVN(rd,rs,rt) \
+ movn rd,rs,rt
+# define MOVZ(rd,rs,rt) \
+ movz rd,rs,rt
+#endif /* (_MIPS_ISA == _MIPS_ISA_MIPS4) || (_MIPS_ISA == _MIPS_ISA_MIPS5) */
+
+/*
+ * Stack alignment
+ */
+#if _MIPS_SIM == _ABI64 || _MIPS_SIM == _ABIN32
+# define ALSZ 15
+# define ALMASK ~15
+#else
+# define ALSZ 7
+# define ALMASK ~7
+#endif
+
+/*
+ * Size of a register
+ */
+#if _MIPS_SIM == _ABI64 || _MIPS_SIM == _ABIN32
+# define SZREG 8
+#else
+# define SZREG 4
+#endif
+
+/*
+ * Use the following macros in assemblercode to load/store registers,
+ * pointers etc.
+ */
+#if (SZREG == 4)
+# define REG_S sw
+# define REG_L lw
+#else
+# define REG_S sd
+# define REG_L ld
+#endif
+
+/*
+ * How to add/sub/load/store/shift C int variables.
+ */
+#if (_MIPS_SZINT == 32)
+# define INT_ADD add
+# define INT_ADDI addi
+# define INT_ADDU addu
+# define INT_ADDIU addiu
+# define INT_SUB add
+# define INT_SUBI subi
+# define INT_SUBU subu
+# define INT_SUBIU subu
+# define INT_L lw
+# define INT_S sw
+#endif
+
+#if (_MIPS_SZINT == 64)
+# define INT_ADD dadd
+# define INT_ADDI daddi
+# define INT_ADDU daddu
+# define INT_ADDIU daddiu
+# define INT_SUB dadd
+# define INT_SUBI dsubi
+# define INT_SUBU dsubu
+# define INT_SUBIU dsubu
+# define INT_L ld
+# define INT_S sd
+#endif
+
+/*
+ * How to add/sub/load/store/shift C long variables.
+ */
+#if (_MIPS_SZLONG == 32)
+# define LONG_ADD add
+# define LONG_ADDI addi
+# define LONG_ADDU addu
+# define LONG_ADDIU addiu
+# define LONG_SUB add
+# define LONG_SUBI subi
+# define LONG_SUBU subu
+# define LONG_SUBIU subu
+# define LONG_L lw
+# define LONG_S sw
+# define LONG_SLL sll
+# define LONG_SLLV sllv
+# define LONG_SRL srl
+# define LONG_SRLV srlv
+# define LONG_SRA sra
+# define LONG_SRAV srav
+#endif
+
+#if (_MIPS_SZLONG == 64)
+# define LONG_ADD dadd
+# define LONG_ADDI daddi
+# define LONG_ADDU daddu
+# define LONG_ADDIU daddiu
+# define LONG_SUB dadd
+# define LONG_SUBI dsubi
+# define LONG_SUBU dsubu
+# define LONG_SUBIU dsubu
+# define LONG_L ld
+# define LONG_S sd
+# define LONG_SLL dsll
+# define LONG_SLLV dsllv
+# define LONG_SRL dsrl
+# define LONG_SRLV dsrlv
+# define LONG_SRA dsra
+# define LONG_SRAV dsrav
+#endif
+
+/*
+ * How to add/sub/load/store/shift pointers.
+ */
+#if (_MIPS_SIM == _ABIO32 && _MIPS_SZPTR == 32)
+# define PTR_ADD add
+# define PTR_ADDI addi
+# define PTR_ADDU addu
+# define PTR_ADDIU addiu
+# define PTR_SUB add
+# define PTR_SUBI subi
+# define PTR_SUBU subu
+# define PTR_SUBIU subu
+# define PTR_L lw
+# define PTR_LA la
+# define PTR_S sw
+# define PTR_SLL sll
+# define PTR_SLLV sllv
+# define PTR_SRL srl
+# define PTR_SRLV srlv
+# define PTR_SRA sra
+# define PTR_SRAV srav
+
+# define PTR_SCALESHIFT 2
+#endif
+
+#if _MIPS_SIM == _ABIN32
+# define PTR_ADD add
+# define PTR_ADDI addi
+# define PTR_ADDU add /* no u */
+# define PTR_ADDIU addi /* no u */
+# define PTR_SUB add
+# define PTR_SUBI subi
+# define PTR_SUBU sub /* no u */
+# define PTR_SUBIU sub /* no u */
+# define PTR_L lw
+# define PTR_LA la
+# define PTR_S sw
+# define PTR_SLL sll
+# define PTR_SLLV sllv
+# define PTR_SRL srl
+# define PTR_SRLV srlv
+# define PTR_SRA sra
+# define PTR_SRAV srav
+
+# define PTR_SCALESHIFT 2
+#endif
+
+#if (_MIPS_SIM == _ABIO32 && _MIPS_SZPTR == 64 /* o64??? */) \
+ || _MIPS_SIM == _ABI64
+# define PTR_ADD dadd
+# define PTR_ADDI daddi
+# define PTR_ADDU daddu
+# define PTR_ADDIU daddiu
+# define PTR_SUB dadd
+# define PTR_SUBI dsubi
+# define PTR_SUBU dsubu
+# define PTR_SUBIU dsubu
+# define PTR_L ld
+# define PTR_LA dla
+# define PTR_S sd
+# define PTR_SLL dsll
+# define PTR_SLLV dsllv
+# define PTR_SRL dsrl
+# define PTR_SRLV dsrlv
+# define PTR_SRA dsra
+# define PTR_SRAV dsrav
+
+# define PTR_SCALESHIFT 3
+#endif
+
+/*
+ * Some cp0 registers were extended to 64bit for MIPS III.
+ */
+#if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2) || \
+ (_MIPS_ISA == _MIPS_ISA_MIPS32)
+# define MFC0 mfc0
+# define MTC0 mtc0
+#endif
+#if (_MIPS_ISA == _MIPS_ISA_MIPS3) || (_MIPS_ISA == _MIPS_ISA_MIPS4) || \
+ (_MIPS_ISA == _MIPS_ISA_MIPS5) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
+# define MFC0 dmfc0
+# define MTC0 dmtc0
+#endif
+
+/* The MIPS archtectures do not have a uniform memory model. Particular
+ platforms may provide additional guarantees - for instance, the R4000
+ LL and SC instructions implicitly perform a SYNC, and the 4K promises
+ strong ordering.
+
+ However, in the absence of those guarantees, we must assume weak ordering
+ and SYNC explicitly where necessary.
+
+ Some obsolete MIPS processors may not support the SYNC instruction. This
+ applies to "true" MIPS I processors; most of the processors which compile
+ using MIPS I implement parts of MIPS II. */
+
+#ifndef MIPS_SYNC
+# define MIPS_SYNC sync
+#endif
+
+#endif /* sys/asm.h */
diff --git a/ports/sysdeps/mips/sys/fpregdef.h b/ports/sysdeps/mips/sys/fpregdef.h
new file mode 100644
index 000000000..378115274
--- /dev/null
+++ b/ports/sysdeps/mips/sys/fpregdef.h
@@ -0,0 +1,61 @@
+/* Copyright (C) 1991, 92, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_FPREGDEF_H
+#define _SYS_FPREGDEF_H
+
+/*
+ * These definitions only cover the R3000-ish 16/32 register model.
+ * But we're trying to be R3000 friendly anyway ...
+ */
+#define fv0 $f0 /* return value */
+#define fv0f $f1
+#define fv1 $f2
+#define fv1f $f3
+#define fa0 $f12 /* argument registers */
+#define fa0f $f13
+#define fa1 $f14
+#define fa1f $f15
+#define ft0 $f4 /* caller saved */
+#define ft0f $f5
+#define ft1 $f6
+#define ft1f $f7
+#define ft2 $f8
+#define ft2f $f9
+#define ft3 $f10
+#define ft3f $f11
+#define ft4 $f16
+#define ft4f $f17
+#define ft5 $f18
+#define ft5f $f19
+#define fs0 $f20 /* callee saved */
+#define fs0f $f21
+#define fs1 $f22
+#define fs1f $f23
+#define fs2 $f24
+#define fs2f $f25
+#define fs3 $f26
+#define fs3f $f27
+#define fs4 $f28
+#define fs4f $f29
+#define fs5 $f30
+#define fs5f $f31
+
+#define fcr31 $31 /* FPU status register */
+
+#endif /* sys/fpregdef.h */
diff --git a/ports/sysdeps/mips/sys/regdef.h b/ports/sysdeps/mips/sys/regdef.h
new file mode 100644
index 000000000..8fb898a2d
--- /dev/null
+++ b/ports/sysdeps/mips/sys/regdef.h
@@ -0,0 +1,82 @@
+/* Copyright (C) 1997, 1998, 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ralf Baechle <ralf@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_REGDEF_H
+#define _SYS_REGDEF_H
+
+#include <sgidefs.h>
+
+/*
+ * Symbolic register names for 32 bit ABI
+ */
+#define zero $0 /* wired zero */
+#define AT $1 /* assembler temp - uppercase because of ".set at" */
+#define v0 $2 /* return value */
+#define v1 $3
+#define a0 $4 /* argument registers */
+#define a1 $5
+#define a2 $6
+#define a3 $7
+#if _MIPS_SIM != _ABIO32
+#define a4 $8
+#define a5 $9
+#define a6 $10
+#define a7 $11
+#define t0 $12
+#define t1 $13
+#define t2 $14
+#define t3 $15
+#define ta0 a4
+#define ta1 a5
+#define ta2 a6
+#define ta3 a7
+#else /* if _MIPS_SIM == _ABIO32 */
+#define t0 $8 /* caller saved */
+#define t1 $9
+#define t2 $10
+#define t3 $11
+#define t4 $12
+#define t5 $13
+#define t6 $14
+#define t7 $15
+#define ta0 t4
+#define ta1 t5
+#define ta2 t6
+#define ta3 t7
+#endif /* _MIPS_SIM == _ABIO32 */
+#define s0 $16 /* callee saved */
+#define s1 $17
+#define s2 $18
+#define s3 $19
+#define s4 $20
+#define s5 $21
+#define s6 $22
+#define s7 $23
+#define t8 $24 /* caller saved */
+#define t9 $25
+#define jp $25 /* PIC jump register */
+#define k0 $26 /* kernel scratch */
+#define k1 $27
+#define gp $28 /* global pointer */
+#define sp $29 /* stack pointer */
+#define fp $30 /* frame pointer */
+#define s8 $30 /* same like fp! */
+#define ra $31 /* return address */
+
+#endif /* _SYS_REGDEF_H */
diff --git a/ports/sysdeps/mips/sys/ucontext.h b/ports/sysdeps/mips/sys/ucontext.h
new file mode 100644
index 000000000..fe378e94c
--- /dev/null
+++ b/ports/sysdeps/mips/sys/ucontext.h
@@ -0,0 +1,159 @@
+/* Copyright (C) 1998, 1999, 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* System V/mips ABI compliant context switching support. */
+
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <sgidefs.h>
+#include <signal.h>
+
+/* Type for general register. */
+#if _MIPS_SIM == _ABIO32
+typedef __uint32_t greg_t;
+#else
+typedef __uint64_t greg_t;
+#endif
+
+/* Number of general registers. */
+#define NGREG 36
+
+/* Container for all general registers. */
+typedef greg_t gregset_t[NGREG];
+
+/* Number of each register is the `gregset_t' array. */
+enum
+{
+ CTX_R0 = 0,
+#define CTX_R0 CTX_R0
+ CTX_AT = 1,
+#define CTX_AT CTX_AT
+ CTX_V0 = 2,
+#define CTX_V0 CTX_V0
+ CTX_V1 = 3,
+#define CTX_V1 CTX_V1
+ CTX_A0 = 4,
+#define CTX_A0 CTX_A0
+ CTX_A1 = 5,
+#define CTX_A1 CTX_A1
+ CTX_A2 = 6,
+#define CTX_A2 CTX_A2
+ CTX_A3 = 7,
+#define CTX_A3 CTX_A3
+ CTX_T0 = 8,
+#define CTX_T0 CTX_T0
+ CTX_T1 = 9,
+#define CTX_T1 CTX_T1
+ CTX_T2 = 10,
+#define CTX_T2 CTX_T2
+ CTX_T3 = 11,
+#define CTX_T3 CTX_T3
+ CTX_T4 = 12,
+#define CTX_T4 CTX_T4
+ CTX_T5 = 13,
+#define CTX_T5 CTX_T5
+ CTX_T6 = 14,
+#define CTX_T6 CTX_T6
+ CTX_T7 = 15,
+#define CTX_T7 CTX_T7
+ CTX_S0 = 16,
+#define CTX_S0 CTX_S0
+ CTX_S1 = 17,
+#define CTX_S1 CTX_S1
+ CTX_S2 = 18,
+#define CTX_S2 CTX_S2
+ CTX_S3 = 19,
+#define CTX_S3 CTX_S3
+ CTX_S4 = 20,
+#define CTX_S4 CTX_S4
+ CTX_S5 = 21,
+#define CTX_S5 CTX_S5
+ CTX_S6 = 22,
+#define CTX_S6 CTX_S6
+ CTX_S7 = 23,
+#define CTX_S7 CTX_S7
+ CTX_T8 = 24,
+#define CTX_T8 CTX_T8
+ CTX_T9 = 25,
+#define CTX_T9 CTX_T9
+ CTX_K0 = 26,
+#define CTX_K0 CTX_K0
+ CTX_K1 = 27,
+#define CTX_K1 CTX_K1
+ CTX_GP = 28,
+#define CTX_GP CTX_GP
+ CTX_SP = 29,
+#define CTX_SP CTX_SP
+ CTX_S8 = 30,
+#define CTX_S8 CTX_S8
+ CTX_RA = 31,
+#define CTX_RA CTX_RA
+ CTX_MDLO = 32,
+#define CTX_MDLO CTX_MDLO
+ CTX_MDHI = 33,
+#define CTX_MDHI CTX_MDHI
+ CTX_CAUSE = 34,
+#define CTX_CAUSE CTX_CAUSE
+ CTX_EPC = 35,
+#define CTX_EPC CTX_EPC
+};
+
+/* Structure to describe FPU registers. */
+typedef struct fpregset
+{
+ union
+ {
+#if _MIPS_SIM == _ABIO32
+ double fp_dregs[16];
+ float fp_fregs[32];
+ unsigned int fp_regs[32];
+#else
+ double fp_dregs[32];
+ /* float fp_fregs[32]; */
+ __uint64_t fp_regs[32];
+#endif
+ } fp_r;
+ unsigned int fp_csr;
+ unsigned int fp_pad;
+} fpregset_t;
+
+/* Context to describe whole processor state. */
+typedef struct
+{
+ gregset_t gpregs;
+ fpregset_t fpregs;
+} mcontext_t;
+
+/* Userlevel context. */
+typedef struct ucontext
+{
+#if _MIPS_SIM == _ABIO32
+ unsigned long int uc_flags;
+#else
+ __uint64_t uc_flags;
+#endif
+ struct ucontext *uc_link;
+ __sigset_t uc_sigmask;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ int uc_filler[48];
+} ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/ports/sysdeps/mips/tls-macros.h b/ports/sysdeps/mips/tls-macros.h
new file mode 100644
index 000000000..2d0516b3e
--- /dev/null
+++ b/ports/sysdeps/mips/tls-macros.h
@@ -0,0 +1,88 @@
+/* Macros to support TLS testing in times of missing compiler support. */
+
+#if _MIPS_SIM != _ABI64
+
+/* These versions are for o32 and n32. */
+
+# define TLS_GD(x) \
+ ({ void *__result; \
+ extern void *__tls_get_addr (void *); \
+ asm ("addiu %0, $28, %%tlsgd(" #x ")" \
+ : "=r" (__result)); \
+ (int *)__tls_get_addr (__result); })
+#else
+# define TLS_GD(x) \
+ ({ void *__result; \
+ extern void *__tls_get_addr (void *); \
+ asm ("daddiu %0, $28, %%tlsgd(" #x ")" \
+ : "=r" (__result)); \
+ (int *)__tls_get_addr (__result); })
+#endif
+
+#if _MIPS_SIM != _ABI64
+# define TLS_LD(x) \
+ ({ void *__result; \
+ extern void *__tls_get_addr (void *); \
+ asm ("addiu %0, $28, %%tlsldm(" #x ")" \
+ : "=r" (__result)); \
+ __result = __tls_get_addr (__result); \
+ asm ("lui $3,%%dtprel_hi(" #x ")\n\t" \
+ "addiu $3,$3,%%dtprel_lo(" #x ")\n\t" \
+ "addu %0,%0,$3" \
+ : "+r" (__result) : : "$3"); \
+ __result; })
+# define TLS_IE(x) \
+ ({ void *__result; \
+ asm (".set push\n\t.set mips32r2\n\t" \
+ "rdhwr\t%0,$29\n\t.set pop" \
+ : "=v" (__result)); \
+ asm ("lw $3,%%gottprel(" #x ")($28)\n\t" \
+ "addu %0,%0,$3" \
+ : "+r" (__result) : : "$3"); \
+ __result; })
+# define TLS_LE(x) \
+ ({ void *__result; \
+ asm (".set push\n\t.set mips32r2\n\t" \
+ "rdhwr\t%0,$29\n\t.set pop" \
+ : "=v" (__result)); \
+ asm ("lui $3,%%tprel_hi(" #x ")\n\t" \
+ "addiu $3,$3,%%tprel_lo(" #x ")\n\t" \
+ "addu %0,%0,$3" \
+ : "+r" (__result) : : "$3"); \
+ __result; })
+
+#else
+
+/* These versions are for n64. */
+
+# define TLS_LD(x) \
+ ({ void *__result; \
+ extern void *__tls_get_addr (void *); \
+ asm ("daddiu %0, $28, %%tlsldm(" #x ")" \
+ : "=r" (__result)); \
+ __result = __tls_get_addr (__result); \
+ asm ("lui $3,%%dtprel_hi(" #x ")\n\t" \
+ "daddiu $3,$3,%%dtprel_lo(" #x ")\n\t" \
+ "daddu %0,%0,$3" \
+ : "+r" (__result) : : "$3"); \
+ __result; })
+# define TLS_IE(x) \
+ ({ void *__result; \
+ asm (".set push\n\t.set mips32r2\n\t" \
+ "rdhwr\t%0,$29\n\t.set pop" \
+ : "=v" (__result)); \
+ asm ("ld $3,%%gottprel(" #x ")($28)\n\t" \
+ "daddu %0,%0,$3" \
+ : "+r" (__result) : : "$3"); \
+ __result; })
+# define TLS_LE(x) \
+ ({ void *__result; \
+ asm (".set push\n\t.set mips32r2\n\t" \
+ "rdhwr\t%0,$29\n\t.set pop" \
+ : "=v" (__result)); \
+ asm ("lui $3,%%tprel_hi(" #x ")\n\t" \
+ "daddiu $3,$3,%%tprel_lo(" #x ")\n\t" \
+ "daddu %0,%0,$3" \
+ : "+r" (__result) : : "$3"); \
+ __result; })
+#endif
diff --git a/ports/sysdeps/mips/tst-audit.h b/ports/sysdeps/mips/tst-audit.h
new file mode 100644
index 000000000..cafa3ebe1
--- /dev/null
+++ b/ports/sysdeps/mips/tst-audit.h
@@ -0,0 +1,40 @@
+/* Definitions for testing PLT entry/exit auditing. ARM version.
+
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sgidefs.h>
+
+#if _MIPS_SIM == _ABIO32
+#define pltenter la_mips_o32_gnu_pltenter
+#define pltexit la_mips_o32_gnu_pltexit
+#define La_regs La_mips_32_regs
+#define La_retval La_mips_32_retval
+#else
+#if _MIPS_SIM == _ABIN32
+#define pltenter la_mips_n32_gnu_pltenter
+#define pltexit la_mips_n32_gnu_pltexit
+#else
+#define pltenter la_mips_n64_gnu_pltenter
+#define pltexit la_mips_n64_gnu_pltexit
+#endif
+#define La_regs La_mips_64_regs
+#define La_retval La_mips_64_retval
+#endif
+#define int_retval lrv_v0
diff --git a/ports/sysdeps/powerpc/nofpu/Makefile b/ports/sysdeps/powerpc/nofpu/Makefile
new file mode 100644
index 000000000..9fde4a51a
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/Makefile
@@ -0,0 +1,10 @@
+# Makefile fragment for PowerPC with no FPU.
+
+ifeq ($(subdir),soft-fp)
+sysdep_routines += $(gcc-single-routines) $(gcc-double-routines) \
+ $(gcc-quad-routines) sim-full
+endif
+
+ifeq ($(subdir),math)
+libm-support += fenv_const fe_nomask
+endif
diff --git a/ports/sysdeps/powerpc/nofpu/Subdirs b/ports/sysdeps/powerpc/nofpu/Subdirs
new file mode 100644
index 000000000..87eadf302
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/Subdirs
@@ -0,0 +1 @@
+soft-fp
diff --git a/ports/sysdeps/powerpc/nofpu/Versions b/ports/sysdeps/powerpc/nofpu/Versions
new file mode 100644
index 000000000..037af6828
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/Versions
@@ -0,0 +1,18 @@
+libc {
+ GLIBC_2.3.2 {
+ __sim_exceptions; __sim_disabled_exceptions; __sim_round_mode;
+ __adddf3; __addsf3; __divdf3; __divsf3; __eqdf2; __eqsf2;
+ __extendsfdf2; __fixdfdi; __fixdfsi; __fixsfdi; __fixsfsi;
+ __fixtfdi; __fixtfsi;
+ __fixunsdfdi; __fixunsdfsi; __fixunssfdi; __fixunssfsi;
+ __floatdidf; __floatdisf; __floatsidf; __floatsisf;
+ __gedf2; __gesf2; __ledf2; __lesf2; __muldf3; __mulsf3;
+ __negdf2; __negsf2; __sqrtdf2; __sqrtsf2; __subdf3;
+ __subsf3; __truncdfsf2; __trunctfsf2;
+ }
+ GLIBC_2.4 {
+ __floatundidf; __floatundisf; __floatunditf;
+ __floatunsidf; __floatunsisf; __floatunsitf;
+ __unorddf2; __unordsf2; __unordtf2;
+ }
+}
diff --git a/ports/sysdeps/powerpc/nofpu/fclrexcpt.c b/ports/sysdeps/powerpc/nofpu/fclrexcpt.c
new file mode 100644
index 000000000..16e96baea
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/fclrexcpt.c
@@ -0,0 +1,37 @@
+/* Clear floating-point exceptions (soft-float edition).
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "soft-fp.h"
+#include "soft-supp.h"
+
+int
+__feclearexcept (int x)
+{
+ __sim_exceptions &= ~x;
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__feclearexcept, __old_feclearexcept)
+compat_symbol (libm, __old_feclearexcept, feclearexcept, GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, __feclearexcept, feclearexcept, GLIBC_2_2);
diff --git a/ports/sysdeps/powerpc/nofpu/fedisblxcpt.c b/ports/sysdeps/powerpc/nofpu/fedisblxcpt.c
new file mode 100644
index 000000000..3d8dd4462
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/fedisblxcpt.c
@@ -0,0 +1,33 @@
+/* Disable exceptions (soft-float edition).
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "soft-fp.h"
+#include "soft-supp.h"
+#include <fenv.h>
+
+int
+fedisableexcept (int x)
+{
+ int old_exceptions = ~__sim_disabled_exceptions & FE_ALL_EXCEPT;
+
+ __sim_disabled_exceptions |= x;
+
+ return old_exceptions;
+}
diff --git a/ports/sysdeps/powerpc/nofpu/feenablxcpt.c b/ports/sysdeps/powerpc/nofpu/feenablxcpt.c
new file mode 100644
index 000000000..060e45059
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/feenablxcpt.c
@@ -0,0 +1,33 @@
+/* Enable exceptions (soft-float edition).
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+extern int __sim_disabled_exceptions;
+
+int
+feenableexcept (int exceptions)
+{
+ int old_exceptions = ~__sim_disabled_exceptions & FE_ALL_EXCEPT;
+
+ __sim_disabled_exceptions &= ~exceptions;
+
+ return old_exceptions;
+}
diff --git a/ports/sysdeps/powerpc/nofpu/fegetenv.c b/ports/sysdeps/powerpc/nofpu/fegetenv.c
new file mode 100644
index 000000000..3cc8b13da
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/fegetenv.c
@@ -0,0 +1,49 @@
+/* Store current floating-point environment (soft-float edition).
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "soft-fp.h"
+#include "soft-supp.h"
+#include <bp-sym.h>
+
+extern int __sim_exceptions;
+extern int __sim_disabled_exceptions;
+extern int __sim_round_mode;
+
+int
+__fegetenv (fenv_t *envp)
+{
+ fenv_union_t u;
+
+ u.l[0] = __sim_exceptions;
+ u.l[0] |= __sim_round_mode;
+ u.l[1] = __sim_disabled_exceptions;
+
+ *envp = u.fenv;
+
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__fegetenv, __old_fegetenv)
+compat_symbol (libm, BP_SYM (__old_fegetenv), BP_SYM (fegetenv), GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, BP_SYM (__fegetenv), BP_SYM (fegetenv), GLIBC_2_2);
diff --git a/ports/sysdeps/powerpc/nofpu/fegetexcept.c b/ports/sysdeps/powerpc/nofpu/fegetexcept.c
new file mode 100644
index 000000000..0a47a09ac
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/fegetexcept.c
@@ -0,0 +1,28 @@
+/* Get floating-point exceptions (soft-float edition).
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "soft-fp.h"
+#include "soft-supp.h"
+
+int
+fegetexcept (void)
+{
+ return (__sim_disabled_exceptions ^ FE_ALL_EXCEPT) & FE_ALL_EXCEPT;
+}
diff --git a/ports/sysdeps/powerpc/nofpu/fegetround.c b/ports/sysdeps/powerpc/nofpu/fegetround.c
new file mode 100644
index 000000000..0d01e4411
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/fegetround.c
@@ -0,0 +1,29 @@
+/* Return current rounding mode (soft-float edition).
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "soft-fp.h"
+#include "soft-supp.h"
+
+#undef fegetround
+int
+fegetround (void)
+{
+ return __sim_round_mode;
+}
diff --git a/ports/sysdeps/powerpc/nofpu/feholdexcpt.c b/ports/sysdeps/powerpc/nofpu/feholdexcpt.c
new file mode 100644
index 000000000..786c691a4
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/feholdexcpt.c
@@ -0,0 +1,43 @@
+/* Store current floating-point environment and clear exceptions
+ (soft-float edition).
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "soft-fp.h"
+#include "soft-supp.h"
+
+int
+feholdexcept (fenv_t *envp)
+{
+ fenv_union_t u;
+
+ /* Get the current state. */
+ fegetenv (envp);
+
+ u.fenv = *envp;
+ /* Clear everything except the rounding mode. */
+ u.l[0] &= 0x3;
+
+ /* ?? Should we clear the disabled exceptions as well ?? */
+
+ /* Put the new state in effect. */
+ fesetenv (envp);
+
+ return 0;
+}
diff --git a/ports/sysdeps/powerpc/nofpu/fenv_const.c b/ports/sysdeps/powerpc/nofpu/fenv_const.c
new file mode 100644
index 000000000..7dc2e817c
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/fenv_const.c
@@ -0,0 +1,35 @@
+/* Constants for fenv_bits.h (soft float edition).
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* We want to specify the bit pattern of the __fe_*_env constants, so
+ pretend they're really `long long' instead of `double'. */
+
+/* If the default argument is used we use this value. Disable all
+ signalling exceptions as default. */
+const unsigned long long __fe_dfl_env __attribute__ ((aligned (8))) =
+0x000000003e000000ULL;
+
+/* Floating-point environment where none of the exceptions are masked. */
+const unsigned long long __fe_enabled_env __attribute__ ((aligned (8))) =
+0xfff80000000000f8ULL;
+
+/* Floating-point environment with the NI bit set. */
+const unsigned long long __fe_nonieee_env __attribute__ ((aligned (8))) =
+0xfff8000000000004ULL;
diff --git a/ports/sysdeps/powerpc/nofpu/fesetenv.c b/ports/sysdeps/powerpc/nofpu/fesetenv.c
new file mode 100644
index 000000000..43d03a45e
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/fesetenv.c
@@ -0,0 +1,48 @@
+/* Set floating point environment (soft-float edition).
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "soft-fp.h"
+#include "soft-supp.h"
+#include <bp-sym.h>
+
+extern int __sim_exceptions attribute_hidden;
+extern int __sim_disabled_exceptions attribute_hidden;
+extern int __sim_round_mode attribute_hidden;
+
+int
+__fesetenv (const fenv_t *envp)
+{
+ fenv_union_t u;
+
+ u.fenv = *envp;
+ __sim_exceptions = u.l[0] & FE_ALL_EXCEPT;
+ __sim_round_mode = u.l[0] & 0x3;
+ __sim_disabled_exceptions = u.l[1];
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__fesetenv, __old_fesetenv)
+compat_symbol (libm, BP_SYM (__old_fesetenv), BP_SYM (fesetenv), GLIBC_2_1);
+#endif
+
+libm_hidden_ver (__fesetenv, fesetenv)
+versioned_symbol (libm, BP_SYM (__fesetenv), BP_SYM (fesetenv), GLIBC_2_2);
diff --git a/ports/sysdeps/powerpc/nofpu/fesetround.c b/ports/sysdeps/powerpc/nofpu/fesetround.c
new file mode 100644
index 000000000..a5f836727
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/fesetround.c
@@ -0,0 +1,34 @@
+/* Set rounding mode (soft-float edition).
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "soft-fp.h"
+#include "soft-supp.h"
+
+int
+fesetround (int round)
+{
+ if ((unsigned int) round > FE_DOWNWARD)
+ return 1;
+
+ __sim_round_mode = round;
+
+ return 0;
+}
+libm_hidden_def (fesetround)
diff --git a/ports/sysdeps/powerpc/nofpu/feupdateenv.c b/ports/sysdeps/powerpc/nofpu/feupdateenv.c
new file mode 100644
index 000000000..5073776e7
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/feupdateenv.c
@@ -0,0 +1,50 @@
+/* Install given floating-point environment and raise exceptions
+ (soft-float edition).
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "soft-fp.h"
+#include "soft-supp.h"
+#include <bp-sym.h>
+
+int
+__feupdateenv (const fenv_t *envp)
+{
+ fenv_union_t u;
+ int saved_exceptions;
+
+ /* Save currently set exceptions. */
+ saved_exceptions = __sim_exceptions;
+
+ /* Set environment. */
+ fesetenv (envp);
+
+ /* Raise old exceptions. */
+ __sim_exceptions |= saved_exceptions;
+
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__feupdateenv, __old_feupdateenv)
+compat_symbol (libm, BP_SYM (__old_feupdateenv), BP_SYM (feupdateenv), GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, BP_SYM (__feupdateenv), BP_SYM (feupdateenv), GLIBC_2_2);
diff --git a/ports/sysdeps/powerpc/nofpu/fgetexcptflg.c b/ports/sysdeps/powerpc/nofpu/fgetexcptflg.c
new file mode 100644
index 000000000..713bd9288
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/fgetexcptflg.c
@@ -0,0 +1,38 @@
+/* Store current representation for exceptions (soft-float edition).
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "soft-fp.h"
+#include "soft-supp.h"
+#include <bp-sym.h>
+
+__fegetexceptflag (fexcept_t *flagp, int excepts)
+{
+ *flagp = (fexcept_t) __sim_exceptions & excepts & FE_ALL_EXCEPT;
+
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__fegetexceptflag, __old_fegetexceptflag)
+compat_symbol (libm, BP_SYM (__old_fegetexceptflag), BP_SYM (fegetexceptflag), GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, BP_SYM (__fegetexceptflag), BP_SYM (fegetexceptflag), GLIBC_2_2);
diff --git a/ports/sysdeps/powerpc/nofpu/fraiseexcpt.c b/ports/sysdeps/powerpc/nofpu/fraiseexcpt.c
new file mode 100644
index 000000000..cd915027e
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/fraiseexcpt.c
@@ -0,0 +1,46 @@
+/* Raise given exceptions (soft-float edition).
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "soft-fp.h"
+#include "soft-supp.h"
+#include <signal.h>
+#include <bp-sym.h>
+
+#undef feraiseexcept
+int
+__feraiseexcept (int x)
+{
+ __sim_exceptions |= x;
+ if (x == 0 || __sim_disabled_exceptions & x)
+ /* Ignore exception. */
+ ;
+ else
+ raise (SIGFPE);
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__feraiseexcept, __old_feraiseexcept)
+compat_symbol (libm, BP_SYM (__old_feraiseexcept), BP_SYM (feraiseexcept), GLIBC_2_1);
+#endif
+
+libm_hidden_ver (__feraiseexcept, feraiseexcept)
+versioned_symbol (libm, BP_SYM (__feraiseexcept), BP_SYM (feraiseexcept), GLIBC_2_2);
diff --git a/ports/sysdeps/powerpc/nofpu/fsetexcptflg.c b/ports/sysdeps/powerpc/nofpu/fsetexcptflg.c
new file mode 100644
index 000000000..85fd88f01
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/fsetexcptflg.c
@@ -0,0 +1,40 @@
+/* Set floating-point environment exception handling (soft-float edition).
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "soft-fp.h"
+#include "soft-supp.h"
+#include <bp-sym.h>
+
+int
+__fesetexceptflag(const fexcept_t *flagp, int excepts)
+{
+ /* Ignore exceptions not listed in 'excepts'. */
+ __sim_exceptions = *flagp & excepts;
+
+ return 0;
+}
+
+#include <shlib-compat.h>
+#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__fesetexceptflag, __old_fesetexceptflag)
+compat_symbol (libm, BP_SYM (__old_fesetexceptflag), BP_SYM (fesetexceptflag), GLIBC_2_1);
+#endif
+
+versioned_symbol (libm, BP_SYM (__fesetexceptflag), BP_SYM (fesetexceptflag), GLIBC_2_2);
diff --git a/ports/sysdeps/powerpc/nofpu/ftestexcept.c b/ports/sysdeps/powerpc/nofpu/ftestexcept.c
new file mode 100644
index 000000000..ce8044fe0
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/ftestexcept.c
@@ -0,0 +1,28 @@
+/* Test floating-point exceptions (soft-float edition).
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "soft-fp.h"
+#include "soft-supp.h"
+
+int
+fetestexcept (int x)
+{
+ return __sim_exceptions & x;
+}
diff --git a/ports/sysdeps/powerpc/nofpu/libm-test-ulps b/ports/sysdeps/powerpc/nofpu/libm-test-ulps
new file mode 100644
index 000000000..73172b49a
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/libm-test-ulps
@@ -0,0 +1,890 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == -1.9833870299165354323470769028940395 + 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+float: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+float: 1
+ifloat: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+idouble: 1
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+idouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 3
+ifloat: 3
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log1p":
+float: 1
+ifloat: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
diff --git a/ports/sysdeps/powerpc/nofpu/sim-full.c b/ports/sysdeps/powerpc/nofpu/sim-full.c
new file mode 100644
index 000000000..d018240e6
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/sim-full.c
@@ -0,0 +1,45 @@
+/* Software floating-point exception handling emulation.
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <signal.h>
+#include "soft-fp.h"
+#include "soft-supp.h"
+
+/* Global to store sticky exceptions. */
+int __sim_exceptions __attribute__ ((nocommon));
+libc_hidden_data_def (__sim_exceptions);
+
+/* By default, no exceptions should trap. */
+int __sim_disabled_exceptions = 0xffffffff;
+libc_hidden_data_def (__sim_disabled_exceptions);
+
+int __sim_round_mode __attribute__ ((nocommon));
+libc_hidden_data_def (__sim_round_mode);
+
+void
+__simulate_exceptions (int x)
+{
+ __sim_exceptions |= x;
+ if (x == 0 || __sim_disabled_exceptions & x)
+ /* Ignore exception. */
+ ;
+ else
+ raise (SIGFPE);
+}
diff --git a/ports/sysdeps/powerpc/nofpu/soft-supp.h b/ports/sysdeps/powerpc/nofpu/soft-supp.h
new file mode 100644
index 000000000..3922426bd
--- /dev/null
+++ b/ports/sysdeps/powerpc/nofpu/soft-supp.h
@@ -0,0 +1,37 @@
+/* Internal support stuff for complete soft float.
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fenv.h>
+
+typedef union
+{
+ fenv_t fenv;
+ unsigned int l[2];
+} fenv_union_t;
+
+
+extern int __sim_exceptions;
+libc_hidden_proto (__sim_exceptions);
+extern int __sim_disabled_exceptions;
+libc_hidden_proto (__sim_disabled_exceptions);
+extern int __sim_round_mode;
+libc_hidden_proto (__sim_round_mode);
+
+extern void __simulate_exceptions (int x) attribute_hidden;
diff --git a/ports/sysdeps/rs6000/add_n.s b/ports/sysdeps/rs6000/add_n.s
new file mode 100644
index 000000000..216874e7a
--- /dev/null
+++ b/ports/sysdeps/rs6000/add_n.s
@@ -0,0 +1,81 @@
+# IBM POWER __mpn_add_n -- Add two limb vectors of equal, non-zero length.
+
+# Copyright (C) 1992, 1994, 1995, 1996 Free Software Foundation, Inc.
+
+# This file is part of the GNU MP Library.
+
+# The GNU MP Library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 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 Lesser General Public
+# License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+
+# INPUT PARAMETERS
+# res_ptr r3
+# s1_ptr r4
+# s2_ptr r5
+# size r6
+
+ .toc
+ .extern __mpn_add_n[DS]
+ .extern .__mpn_add_n
+.csect [PR]
+ .align 2
+ .globl __mpn_add_n
+ .globl .__mpn_add_n
+ .csect __mpn_add_n[DS]
+__mpn_add_n:
+ .long .__mpn_add_n, TOC[tc0], 0
+ .csect [PR]
+.__mpn_add_n:
+ andil. 10,6,1 # odd or even number of limbs?
+ l 8,0(4) # load least significant s1 limb
+ l 0,0(5) # load least significant s2 limb
+ cal 3,-4(3) # offset res_ptr, it's updated before it's used
+ sri 10,6,1 # count for unrolled loop
+ a 7,0,8 # add least significant limbs, set cy
+ mtctr 10 # copy count into CTR
+ beq 0,Leven # branch if even # of limbs (# of limbs >= 2)
+
+# We have an odd # of limbs. Add the first limbs separately.
+ cmpi 1,10,0 # is count for unrolled loop zero?
+ bne 1,L1 # branch if not
+ st 7,4(3)
+ aze 3,10 # use the fact that r10 is zero...
+ br # return
+
+# We added least significant limbs. Now reload the next limbs to enter loop.
+L1: lu 8,4(4) # load s1 limb and update s1_ptr
+ lu 0,4(5) # load s2 limb and update s2_ptr
+ stu 7,4(3)
+ ae 7,0,8 # add limbs, set cy
+Leven: lu 9,4(4) # load s1 limb and update s1_ptr
+ lu 10,4(5) # load s2 limb and update s2_ptr
+ bdz Lend # If done, skip loop
+
+Loop: lu 8,4(4) # load s1 limb and update s1_ptr
+ lu 0,4(5) # load s2 limb and update s2_ptr
+ ae 11,9,10 # add previous limbs with cy, set cy
+ stu 7,4(3) #
+ lu 9,4(4) # load s1 limb and update s1_ptr
+ lu 10,4(5) # load s2 limb and update s2_ptr
+ ae 7,0,8 # add previous limbs with cy, set cy
+ stu 11,4(3) #
+ bdn Loop # decrement CTR and loop back
+
+Lend: ae 11,9,10 # add limbs with cy, set cy
+ st 7,4(3) #
+ st 11,8(3) #
+ lil 3,0 # load cy into ...
+ aze 3,3 # ... return value register
+ br
diff --git a/ports/sysdeps/rs6000/addmul_1.s b/ports/sysdeps/rs6000/addmul_1.s
new file mode 100644
index 000000000..7cd743ced
--- /dev/null
+++ b/ports/sysdeps/rs6000/addmul_1.s
@@ -0,0 +1,123 @@
+# IBM POWER __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 Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 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 Lesser General Public
+# License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+
+# INPUT PARAMETERS
+# res_ptr r3
+# s1_ptr r4
+# size r5
+# s2_limb r6
+
+# The RS/6000 has no unsigned 32x32->64 bit multiplication instruction. To
+# obtain that operation, we have to use the 32x32->64 signed multiplication
+# instruction, and add the appropriate compensation to the high limb of the
+# result. We add the multiplicand if the multiplier has its most significant
+# bit set, and we add the multiplier if the multiplicand has its most
+# significant bit set. We need to preserve the carry flag between each
+# iteration, so we have to compute the compensation carefully (the natural,
+# srai+and doesn't work). Since the POWER architecture has a branch unit
+# we can branch in zero cycles, so that's how we perform the additions.
+
+ .toc
+ .csect .__mpn_addmul_1[PR]
+ .align 2
+ .globl __mpn_addmul_1
+ .globl .__mpn_addmul_1
+ .csect __mpn_addmul_1[DS]
+__mpn_addmul_1:
+ .long .__mpn_addmul_1[PR], TOC[tc0], 0
+ .csect .__mpn_addmul_1[PR]
+.__mpn_addmul_1:
+
+ cal 3,-4(3)
+ l 0,0(4)
+ cmpi 0,6,0
+ mtctr 5
+ mul 9,0,6
+ srai 7,0,31
+ and 7,7,6
+ mfmq 8
+ cax 9,9,7
+ l 7,4(3)
+ a 8,8,7 # add res_limb
+ blt Lneg
+Lpos: bdz Lend
+
+Lploop: lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 10,0,6
+ mfmq 0
+ ae 8,0,9 # low limb + old_cy_limb + old cy
+ l 7,4(3)
+ aze 10,10 # propagate cy to new cy_limb
+ a 8,8,7 # add res_limb
+ bge Lp0
+ cax 10,10,6 # adjust high limb for negative limb from s1
+Lp0: bdz Lend0
+ lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 9,0,6
+ mfmq 0
+ ae 8,0,10
+ l 7,4(3)
+ aze 9,9
+ a 8,8,7
+ bge Lp1
+ cax 9,9,6 # adjust high limb for negative limb from s1
+Lp1: bdn Lploop
+
+ b Lend
+
+Lneg: cax 9,9,0
+ bdz Lend
+Lnloop: lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 10,0,6
+ mfmq 7
+ ae 8,7,9
+ l 7,4(3)
+ ae 10,10,0 # propagate cy to new cy_limb
+ a 8,8,7 # add res_limb
+ bge Ln0
+ cax 10,10,6 # adjust high limb for negative limb from s1
+Ln0: bdz Lend0
+ lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 9,0,6
+ mfmq 7
+ ae 8,7,10
+ l 7,4(3)
+ ae 9,9,0 # propagate cy to new cy_limb
+ a 8,8,7 # add res_limb
+ bge Ln1
+ cax 9,9,6 # adjust high limb for negative limb from s1
+Ln1: bdn Lnloop
+ b Lend
+
+Lend0: cal 9,0(10)
+Lend: st 8,4(3)
+ aze 3,9
+ br
diff --git a/ports/sysdeps/rs6000/ffs.c b/ports/sysdeps/rs6000/ffs.c
new file mode 100644
index 000000000..619412cb5
--- /dev/null
+++ b/ports/sysdeps/rs6000/ffs.c
@@ -0,0 +1,42 @@
+/* ffs -- find first set bit in a word, counted from least significant end.
+ For IBM rs6000.
+ Copyright (C) 1991, 1992, 1997, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <string.h>
+
+#undef ffs
+
+#ifdef __GNUC__
+
+int
+__ffs (x)
+ int x;
+{
+ int cnt;
+
+ asm ("cntlz %0,%1" : "=r" (cnt) : "r" (x & -x));
+ return 32 - cnt;
+}
+weak_alias (__ffs, ffs)
+libc_hidden_builtin_def (ffs)
+
+#else
+#include <string/ffs.c>
+#endif
diff --git a/ports/sysdeps/rs6000/lshift.s b/ports/sysdeps/rs6000/lshift.s
new file mode 100644
index 000000000..8ccba7407
--- /dev/null
+++ b/ports/sysdeps/rs6000/lshift.s
@@ -0,0 +1,59 @@
+# IBM POWER __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 Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 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 Lesser General Public
+# License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+
+# INPUT PARAMETERS
+# res_ptr r3
+# s_ptr r4
+# size r5
+# cnt r6
+
+ .toc
+ .extern __mpn_lshift[DS]
+ .extern .__mpn_lshift
+.csect [PR]
+ .align 2
+ .globl __mpn_lshift
+ .globl .__mpn_lshift
+ .csect __mpn_lshift[DS]
+__mpn_lshift:
+ .long .__mpn_lshift, TOC[tc0], 0
+ .csect [PR]
+.__mpn_lshift:
+ sli 0,5,2
+ cax 9,3,0
+ cax 4,4,0
+ sfi 8,6,32
+ mtctr 5 # put limb count in CTR loop register
+ lu 0,-4(4) # read most significant limb
+ sre 3,0,8 # compute carry out limb, and init MQ register
+ bdz Lend2 # if just one limb, skip loop
+ lu 0,-4(4) # read 2:nd most significant limb
+ sreq 7,0,8 # compute most significant limb of result
+ bdz Lend # if just two limb, skip loop
+Loop: lu 0,-4(4) # load next lower limb
+ stu 7,-4(9) # store previous result during read latency
+ sreq 7,0,8 # compute result limb
+ bdn Loop # loop back until CTR is zero
+Lend: stu 7,-4(9) # store 2:nd least significant limb
+Lend2: sle 7,0,6 # compute least significant limb
+ st 7,-4(9) # store it" \
+ br
diff --git a/ports/sysdeps/rs6000/memcopy.h b/ports/sysdeps/rs6000/memcopy.h
new file mode 100644
index 000000000..8bdb6e976
--- /dev/null
+++ b/ports/sysdeps/rs6000/memcopy.h
@@ -0,0 +1,86 @@
+/* Copyright (C) 1991, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/rs6000/mul_1.s b/ports/sysdeps/rs6000/mul_1.s
new file mode 100644
index 000000000..c0feef4b7
--- /dev/null
+++ b/ports/sysdeps/rs6000/mul_1.s
@@ -0,0 +1,110 @@
+# IBM POWER __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 Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 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 Lesser General Public
+# License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+
+# INPUT PARAMETERS
+# res_ptr r3
+# s1_ptr r4
+# size r5
+# s2_limb r6
+
+# The RS/6000 has no unsigned 32x32->64 bit multiplication instruction. To
+# obtain that operation, we have to use the 32x32->64 signed multiplication
+# instruction, and add the appropriate compensation to the high limb of the
+# result. We add the multiplicand if the multiplier has its most significant
+# bit set, and we add the multiplier if the multiplicand has its most
+# significant bit set. We need to preserve the carry flag between each
+# iteration, so we have to compute the compensation carefully (the natural,
+# srai+and doesn't work). Since the POWER architecture has a branch unit
+# we can branch in zero cycles, so that's how we perform the additions.
+
+ .toc
+ .csect .__mpn_mul_1[PR]
+ .align 2
+ .globl __mpn_mul_1
+ .globl .__mpn_mul_1
+ .csect __mpn_mul_1[DS]
+__mpn_mul_1:
+ .long .__mpn_mul_1[PR], TOC[tc0], 0
+ .csect .__mpn_mul_1[PR]
+.__mpn_mul_1:
+
+ cal 3,-4(3)
+ l 0,0(4)
+ cmpi 0,6,0
+ mtctr 5
+ mul 9,0,6
+ srai 7,0,31
+ and 7,7,6
+ mfmq 8
+ ai 0,0,0 # reset carry
+ cax 9,9,7
+ blt Lneg
+Lpos: bdz Lend
+Lploop: lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 10,0,6
+ mfmq 0
+ ae 8,0,9
+ bge Lp0
+ cax 10,10,6 # adjust high limb for negative limb from s1
+Lp0: bdz Lend0
+ lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 9,0,6
+ mfmq 0
+ ae 8,0,10
+ bge Lp1
+ cax 9,9,6 # adjust high limb for negative limb from s1
+Lp1: bdn Lploop
+ b Lend
+
+Lneg: cax 9,9,0
+ bdz Lend
+Lnloop: lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 10,0,6
+ cax 10,10,0 # adjust high limb for negative s2_limb
+ mfmq 0
+ ae 8,0,9
+ bge Ln0
+ cax 10,10,6 # adjust high limb for negative limb from s1
+Ln0: bdz Lend0
+ lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 9,0,6
+ cax 9,9,0 # adjust high limb for negative s2_limb
+ mfmq 0
+ ae 8,0,10
+ bge Ln1
+ cax 9,9,6 # adjust high limb for negative limb from s1
+Ln1: bdn Lnloop
+ b Lend
+
+Lend0: cal 9,0(10)
+Lend: st 8,4(3)
+ aze 3,9
+ br
diff --git a/ports/sysdeps/rs6000/rshift.s b/ports/sysdeps/rs6000/rshift.s
new file mode 100644
index 000000000..145218fab
--- /dev/null
+++ b/ports/sysdeps/rs6000/rshift.s
@@ -0,0 +1,57 @@
+# IBM POWER __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 Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 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 Lesser General Public
+# License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+
+# INPUT PARAMETERS
+# res_ptr r3
+# s_ptr r4
+# size r5
+# cnt r6
+
+ .toc
+ .extern __mpn_rshift[DS]
+ .extern .__mpn_rshift
+.csect [PR]
+ .align 2
+ .globl __mpn_rshift
+ .globl .__mpn_rshift
+ .csect __mpn_rshift[DS]
+__mpn_rshift:
+ .long .__mpn_rshift, TOC[tc0], 0
+ .csect [PR]
+.__mpn_rshift:
+ sfi 8,6,32
+ mtctr 5 # put limb count in CTR loop register
+ l 0,0(4) # read least significant limb
+ ai 9,3,-4 # adjust res_ptr since it's offset in the stu:s
+ sle 3,0,8 # compute carry limb, and init MQ register
+ bdz Lend2 # if just one limb, skip loop
+ lu 0,4(4) # read 2:nd least significant limb
+ sleq 7,0,8 # compute least significant limb of result
+ bdz Lend # if just two limb, skip loop
+Loop: lu 0,4(4) # load next higher limb
+ stu 7,4(9) # store previous result during read latency
+ sleq 7,0,8 # compute result limb
+ bdn Loop # loop back until CTR is zero
+Lend: stu 7,4(9) # store 2:nd most significant limb
+Lend2: sre 7,0,6 # compute most significant limb
+ st 7,4(9) # store it" \
+ br
diff --git a/ports/sysdeps/rs6000/sub_n.s b/ports/sysdeps/rs6000/sub_n.s
new file mode 100644
index 000000000..d93187093
--- /dev/null
+++ b/ports/sysdeps/rs6000/sub_n.s
@@ -0,0 +1,82 @@
+# IBM POWER __mpn_sub_n -- Subtract two limb vectors of equal, non-zero length.
+
+# Copyright (C) 1992, 1994, 1995, 1996 Free Software Foundation, Inc.
+
+# This file is part of the GNU MP Library.
+
+# The GNU MP Library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 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 Lesser General Public
+# License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+
+# INPUT PARAMETERS
+# res_ptr r3
+# s1_ptr r4
+# s2_ptr r5
+# size r6
+
+ .toc
+ .extern __mpn_sub_n[DS]
+ .extern .__mpn_sub_n
+.csect [PR]
+ .align 2
+ .globl __mpn_sub_n
+ .globl .__mpn_sub_n
+ .csect __mpn_sub_n[DS]
+__mpn_sub_n:
+ .long .__mpn_sub_n, TOC[tc0], 0
+ .csect [PR]
+.__mpn_sub_n:
+ andil. 10,6,1 # odd or even number of limbs?
+ l 8,0(4) # load least significant s1 limb
+ l 0,0(5) # load least significant s2 limb
+ cal 3,-4(3) # offset res_ptr, it's updated before it's used
+ sri 10,6,1 # count for unrolled loop
+ sf 7,0,8 # subtract least significant limbs, set cy
+ mtctr 10 # copy count into CTR
+ beq 0,Leven # branch if even # of limbs (# of limbs >= 2)
+
+# We have an odd # of limbs. Add the first limbs separately.
+ cmpi 1,10,0 # is count for unrolled loop zero?
+ bne 1,L1 # branch if not
+ st 7,4(3)
+ sfe 3,0,0 # load !cy into ...
+ sfi 3,3,0 # ... return value register
+ br # return
+
+# We added least significant limbs. Now reload the next limbs to enter loop.
+L1: lu 8,4(4) # load s1 limb and update s1_ptr
+ lu 0,4(5) # load s2 limb and update s2_ptr
+ stu 7,4(3)
+ sfe 7,0,8 # subtract limbs, set cy
+Leven: lu 9,4(4) # load s1 limb and update s1_ptr
+ lu 10,4(5) # load s2 limb and update s2_ptr
+ bdz Lend # If done, skip loop
+
+Loop: lu 8,4(4) # load s1 limb and update s1_ptr
+ lu 0,4(5) # load s2 limb and update s2_ptr
+ sfe 11,10,9 # subtract previous limbs with cy, set cy
+ stu 7,4(3) #
+ lu 9,4(4) # load s1 limb and update s1_ptr
+ lu 10,4(5) # load s2 limb and update s2_ptr
+ sfe 7,0,8 # subtract previous limbs with cy, set cy
+ stu 11,4(3) #
+ bdn Loop # decrement CTR and loop back
+
+Lend: sfe 11,10,9 # subtract limbs with cy, set cy
+ st 7,4(3) #
+ st 11,8(3) #
+ sfe 3,0,0 # load !cy into ...
+ sfi 3,3,0 # ... return value register
+ br
diff --git a/ports/sysdeps/rs6000/submul_1.s b/ports/sysdeps/rs6000/submul_1.s
new file mode 100644
index 000000000..41095ab00
--- /dev/null
+++ b/ports/sysdeps/rs6000/submul_1.s
@@ -0,0 +1,128 @@
+# IBM POWER __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 Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 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 Lesser General Public
+# License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+
+# INPUT PARAMETERS
+# res_ptr r3
+# s1_ptr r4
+# size r5
+# s2_limb r6
+
+# The RS/6000 has no unsigned 32x32->64 bit multiplication instruction. To
+# obtain that operation, we have to use the 32x32->64 signed multiplication
+# instruction, and add the appropriate compensation to the high limb of the
+# result. We add the multiplicand if the multiplier has its most significant
+# bit set, and we add the multiplier if the multiplicand has its most
+# significant bit set. We need to preserve the carry flag between each
+# iteration, so we have to compute the compensation carefully (the natural,
+# srai+and doesn't work). Since the POWER architecture has a branch unit
+# we can branch in zero cycles, so that's how we perform the additions.
+
+ .toc
+ .csect .__mpn_submul_1[PR]
+ .align 2
+ .globl __mpn_submul_1
+ .globl .__mpn_submul_1
+ .csect __mpn_submul_1[DS]
+__mpn_submul_1:
+ .long .__mpn_submul_1[PR], TOC[tc0], 0
+ .csect .__mpn_submul_1[PR]
+.__mpn_submul_1:
+
+ cal 3,-4(3)
+ l 0,0(4)
+ cmpi 0,6,0
+ mtctr 5
+ mul 9,0,6
+ srai 7,0,31
+ and 7,7,6
+ mfmq 11
+ cax 9,9,7
+ l 7,4(3)
+ sf 8,11,7 # add res_limb
+ a 11,8,11 # invert cy (r11 is junk)
+ blt Lneg
+Lpos: bdz Lend
+
+Lploop: lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 10,0,6
+ mfmq 0
+ ae 11,0,9 # low limb + old_cy_limb + old cy
+ l 7,4(3)
+ aze 10,10 # propagate cy to new cy_limb
+ sf 8,11,7 # add res_limb
+ a 11,8,11 # invert cy (r11 is junk)
+ bge Lp0
+ cax 10,10,6 # adjust high limb for negative limb from s1
+Lp0: bdz Lend0
+ lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 9,0,6
+ mfmq 0
+ ae 11,0,10
+ l 7,4(3)
+ aze 9,9
+ sf 8,11,7
+ a 11,8,11 # invert cy (r11 is junk)
+ bge Lp1
+ cax 9,9,6 # adjust high limb for negative limb from s1
+Lp1: bdn Lploop
+
+ b Lend
+
+Lneg: cax 9,9,0
+ bdz Lend
+Lnloop: lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 10,0,6
+ mfmq 7
+ ae 11,7,9
+ l 7,4(3)
+ ae 10,10,0 # propagate cy to new cy_limb
+ sf 8,11,7 # add res_limb
+ a 11,8,11 # invert cy (r11 is junk)
+ bge Ln0
+ cax 10,10,6 # adjust high limb for negative limb from s1
+Ln0: bdz Lend0
+ lu 0,4(4)
+ stu 8,4(3)
+ cmpi 0,0,0
+ mul 9,0,6
+ mfmq 7
+ ae 11,7,10
+ l 7,4(3)
+ ae 9,9,0 # propagate cy to new cy_limb
+ sf 8,11,7 # add res_limb
+ a 11,8,11 # invert cy (r11 is junk)
+ bge Ln1
+ cax 9,9,6 # adjust high limb for negative limb from s1
+Ln1: bdn Lnloop
+ b Lend
+
+Lend0: cal 9,0(10)
+Lend: st 8,4(3)
+ aze 3,9
+ br
diff --git a/ports/sysdeps/standalone/Subdirs b/ports/sysdeps/standalone/Subdirs
new file mode 100644
index 000000000..4125ae86d
--- /dev/null
+++ b/ports/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/ports/sysdeps/standalone/arm/bits/errno.h b/ports/sysdeps/standalone/arm/bits/errno.h
new file mode 100644
index 000000000..8e1075433
--- /dev/null
+++ b/ports/sysdeps/standalone/arm/bits/errno.h
@@ -0,0 +1,65 @@
+/* Copyright (C) 1991,1994,1996,1997,1998,2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file defines the `errno' constants for standalone ARM machines.
+ These constants are essentially arbitrary. */
+
+#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
+# define ENAMETOOLONG 11 /* File name too long */
+# define ELOOP 12 /* Too many symbolic links encountered */
+# define ENOMSG 13 /* No message of desired type */
+# define E2BIG 14 /* Arg list too long */
+# define EINTR 15
+# define EILSEQ 16
+# define ENOEXEC 17
+# define ENOENT 18
+# define EPROTOTYPE 19
+# define ESRCH 20
+# define EPERM 21
+# define ENOTDIR 22
+# define ESTALE 23
+# define EISDIR 24
+# define EOPNOTSUPP 25 /* Operation not supported. */
+# define ENOTTY 26
+# define EAGAIN 27
+# define EIO 28
+# define ENOSPC 29
+# define EEXIST 30
+# define EBUSY 31
+# define EOVERFLOW 32
+#endif
+
+
+/* Function to get address of global `errno' variable. */
+extern int *__errno_location (void) __THROW __attribute__ ((__const__));
diff --git a/ports/sysdeps/standalone/arm/sysdep.c b/ports/sysdeps/standalone/arm/sysdep.c
new file mode 100644
index 000000000..8c1723422
--- /dev/null
+++ b/ports/sysdeps/standalone/arm/sysdep.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+/* errno has to be defined somewhere, and it might as well be here. */
+int errno = 0;
+
+/* The same goes for these magic signal functions. This is a standalone
+ environment so we do nothing. */
+void _sig_dfl(int sig)
+{
+}
+
+void _sig_ign(int sig)
+{
+}
diff --git a/ports/sysdeps/standalone/bits/errno.h b/ports/sysdeps/standalone/bits/errno.h
new file mode 100644
index 000000000..217c6d5d8
--- /dev/null
+++ b/ports/sysdeps/standalone/bits/errno.h
@@ -0,0 +1,59 @@
+/* Copyright (C) 1991, 1994, 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 EILSEQ 17
+# 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
+# define ENOMSG 11
+# define ENAMETOOLONG 12
+# define ELOOP 13
+# define E2BIG 15
+# define EINTR 16
+# define ENOEXEC 18
+# define ENOENT 19
+# define EPROTOTYPE 20
+# define ESRCH 21
+# define EPERM 22
+# define EEXIST 23
+# define ENOTDIR 24
+# define ESTALE 25
+# define ENOTTY 26
+# define EISDIR 27
+# define EOPNOTSUPP 28
+# define EAGAIN 29
+# define EIO 30
+# define ENOSPC 31
+# define EBUSY 32
+#endif
diff --git a/ports/sysdeps/standalone/brk.c b/ports/sysdeps/standalone/brk.c
new file mode 100644
index 000000000..32e148edc
--- /dev/null
+++ b/ports/sysdeps/standalone/brk.c
@@ -0,0 +1,66 @@
+/* Copyright (C) 1991, 1994, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Ported to standalone 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdlib.h>
+
+void *__curbrk;
+void *__rorig;
+void *__rlimit;
+
+int
+__brk (inaddr)
+ void *inaddr;
+{
+
+ if ( ( (void *)inaddr > (void *)__rlimit ) ||
+ ( (void *)inaddr < (void *)__rorig ) )
+ return -1;
+
+ __curbrk = inaddr;
+ return 0;
+}
+
+/* Initialization Code for Memory Allocation */
+
+void *__C_heap_start;
+int __C_heap_size;
+
+#ifdef HAVE_GNU_LD
+static
+#endif
+void
+__NONE_set_memvals (argc, argv, envp)
+ int argc;
+ char **argv;
+ 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/ports/sysdeps/standalone/close.c b/ports/sysdeps/standalone/close.c
new file mode 100644
index 000000000..8c2caf197
--- /dev/null
+++ b/ports/sysdeps/standalone/close.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1994, 1995, 1996, 1997, 2002 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <unistd.h>
+
+#define _STDIO_H
+#include <bits/stdio_lim.h>
+#include "filedesc.h"
+
+/* Close the file descriptor FD. */
+int
+__close (fd)
+ int fd;
+{
+ if ( !__FD_Is_valid( fd ) || !__FD_Table[ fd ].in_use )
+ {
+ __set_errno (EBADF);
+ return -1;
+ }
+
+ __FD_Table[ fd ].in_use = 0;
+ return 0;
+}
+libc_hidden_def (__close)
+weak_alias (__close, close)
diff --git a/ports/sysdeps/standalone/dirstream.h b/ports/sysdeps/standalone/dirstream.h
new file mode 100644
index 000000000..6f58294b4
--- /dev/null
+++ b/ports/sysdeps/standalone/dirstream.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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. */
+
+struct __dirstream
+ {
+ 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'. */
+ };
+
+#endif /* dirstream.h */
diff --git a/ports/sysdeps/standalone/filedesc.h b/ports/sysdeps/standalone/filedesc.h
new file mode 100644
index 000000000..b7c15b501
--- /dev/null
+++ b/ports/sysdeps/standalone/filedesc.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 1994, 1997, 1998 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/*
+ * This is the file descriptor used by the no OS implementation
+ * of __open, __read, __write, and __close.
+ */
+
+#ifndef __FILEDESC_h
+#define __FILEDESC_h
+
+#define __need_FOPEN_MAX
+#include <bits/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/ports/sysdeps/standalone/i386/force_cpu386/Makefile b/ports/sysdeps/standalone/i386/force_cpu386/Makefile
new file mode 100644
index 000000000..5cb4f2819
--- /dev/null
+++ b/ports/sysdeps/standalone/i386/force_cpu386/Makefile
@@ -0,0 +1,26 @@
+# Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# 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 Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+ifeq (bare,$(subdir))
+install-others += $(inst_libdir)/force_cpu386.ld
+$(inst_libdir)/force_cpu386.ld: $(sysdep_dir)/standalone/i386/target.ld \
+ $(+force)
+ $(do-install)
+endif
diff --git a/ports/sysdeps/standalone/i386/force_cpu386/_exit.c b/ports/sysdeps/standalone/i386/force_cpu386/_exit.c
new file mode 100644
index 000000000..2da822e99
--- /dev/null
+++ b/ports/sysdeps/standalone/i386/force_cpu386/_exit.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991, 1997, 1999, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+#include <stdlib.h>
+
+/* This returns control to FORCEbug. */
+
+void Bsp_cleanup (void);
+
+/* 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
+_exit (status)
+ int status;
+{
+ /* status is ignored */
+ Bsp_cleanup();
+}
+weak_alias (_exit, _Exit)
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(_exit);
+
+#endif /* GNU stabs. */
diff --git a/ports/sysdeps/standalone/i386/force_cpu386/brdinit.c b/ports/sysdeps/standalone/i386/force_cpu386/brdinit.c
new file mode 100644
index 000000000..8392ce585
--- /dev/null
+++ b/ports/sysdeps/standalone/i386/force_cpu386/brdinit.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1994, 1997, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <standalone.h>
+#include "i386.h"
+
+/* _Board_Initialize()
+
+This routine initializes the FORCE CPU386 board. */
+
+void _Console_Initialize (void);
+
+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/ports/sysdeps/standalone/i386/force_cpu386/console.c b/ports/sysdeps/standalone/i386/force_cpu386/console.c
new file mode 100644
index 000000000..4c7271b66
--- /dev/null
+++ b/ports/sysdeps/standalone/i386/force_cpu386/console.c
@@ -0,0 +1,163 @@
+/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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
+_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
+_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
+_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/ports/sysdeps/standalone/i386/force_cpu386/strtsupp.S b/ports/sysdeps/standalone/i386/force_cpu386/strtsupp.S
new file mode 100644
index 000000000..5d9ac5c4a
--- /dev/null
+++ b/ports/sysdeps/standalone/i386/force_cpu386/strtsupp.S
@@ -0,0 +1,87 @@
+/* Copyright (C) 1994, 1997 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/standalone/i386/force_cpu386/target.ld b/ports/sysdeps/standalone/i386/force_cpu386/target.ld
new file mode 100644
index 000000000..d040cf978
--- /dev/null
+++ b/ports/sysdeps/standalone/i386/force_cpu386/target.ld
@@ -0,0 +1,58 @@
+/* Copyright (C) 1994, 1997 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/standalone/i386/i386.h b/ports/sysdeps/standalone/i386/i386.h
new file mode 100644
index 000000000..364e8abb3
--- /dev/null
+++ b/ports/sysdeps/standalone/i386/i386.h
@@ -0,0 +1,326 @@
+/* Copyright (C) 1994, 1997 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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\n"
+ "movw %%es,%0 ; movw %0,%%es\n"
+ "movw %%fs,%0 ; movw %0,%%fs\n"
+ "movw %%gs,%0 ; movw %0,%%gs\n"
+ "movw %%ss,%0 ; movw %0,%%ss"
+ : "=r" (tmp_segment)
+ : "0" (tmp_segment)
+ );
+
+}
+
+#endif
+/* end of include file */
diff --git a/ports/sysdeps/standalone/i386/start.S b/ports/sysdeps/standalone/i386/start.S
new file mode 100644
index 000000000..b3fd315e5
--- /dev/null
+++ b/ports/sysdeps/standalone/i386/start.S
@@ -0,0 +1,338 @@
+/* Copyright (C) 1994, 1997 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/standalone/i960/i960ca.h b/ports/sysdeps/standalone/i960/i960ca.h
new file mode 100644
index 000000000..0dcf5c374
--- /dev/null
+++ b/ports/sysdeps/standalone/i960/i960ca.h
@@ -0,0 +1,206 @@
+/* Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 should 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/ports/sysdeps/standalone/i960/nindy960/Makefile b/ports/sysdeps/standalone/i960/nindy960/Makefile
new file mode 100644
index 000000000..40ead970a
--- /dev/null
+++ b/ports/sysdeps/standalone/i960/nindy960/Makefile
@@ -0,0 +1,24 @@
+# Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# 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 Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+
+# The nindy960 support has only been tested on the following boards:
+#
+# + Cyclone CVME961 VMEbus single board computer.
diff --git a/ports/sysdeps/standalone/i960/nindy960/_exit.c b/ports/sysdeps/standalone/i960/nindy960/_exit.c
new file mode 100644
index 000000000..9cd3f8519
--- /dev/null
+++ b/ports/sysdeps/standalone/i960/nindy960/_exit.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1991, 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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. */
+/* XXX where is __NORETURN ? */
+__NORETURN void
+_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".
+ */
+}
+weak_alias (_exit, _Exit)
+
+
+#ifdef HAVE_GNU_LD
+
+#include <gnu-stabs.h>
+
+stub_warning(_exit);
+
+#endif /* GNU stabs. */
diff --git a/ports/sysdeps/standalone/i960/nindy960/brdinit.c b/ports/sysdeps/standalone/i960/nindy960/brdinit.c
new file mode 100644
index 000000000..9985a9930
--- /dev/null
+++ b/ports/sysdeps/standalone/i960/nindy960/brdinit.c
@@ -0,0 +1,64 @@
+/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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
+_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/ports/sysdeps/standalone/i960/nindy960/console.c b/ports/sysdeps/standalone/i960/nindy960/console.c
new file mode 100644
index 000000000..b062d9215
--- /dev/null
+++ b/ports/sysdeps/standalone/i960/nindy960/console.c
@@ -0,0 +1,76 @@
+/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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
+_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
+_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/ports/sysdeps/standalone/i960/start.S b/ports/sysdeps/standalone/i960/start.S
new file mode 100644
index 000000000..579beb77f
--- /dev/null
+++ b/ports/sysdeps/standalone/i960/start.S
@@ -0,0 +1,152 @@
+/* Copyright (C) 1994, 1997 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/standalone/m68k/m68020/m68020.h b/ports/sysdeps/standalone/m68k/m68020/m68020.h
new file mode 100644
index 000000000..8eee00753
--- /dev/null
+++ b/ports/sysdeps/standalone/m68k/m68020/m68020.h
@@ -0,0 +1,87 @@
+/* Copyright (C) 1994, 1997 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/standalone/m68k/m68020/mvme135/Implies b/ports/sysdeps/standalone/m68k/m68020/mvme135/Implies
new file mode 100644
index 000000000..7142fe298
--- /dev/null
+++ b/ports/sysdeps/standalone/m68k/m68020/mvme135/Implies
@@ -0,0 +1,2 @@
+# Motorola MVME135 and MVME136 are compatible.
+standalone/m68k/m68020/mvme136
diff --git a/ports/sysdeps/standalone/m68k/m68020/mvme136/Makefile b/ports/sysdeps/standalone/m68k/m68020/mvme136/Makefile
new file mode 100644
index 000000000..122c1b183
--- /dev/null
+++ b/ports/sysdeps/standalone/m68k/m68020/mvme136/Makefile
@@ -0,0 +1,23 @@
+# Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# 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 Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+ifeq (bare,$(subdir))
+install-lib += mvme136.ld
+endif
diff --git a/ports/sysdeps/standalone/m68k/m68020/mvme136/_exit.c b/ports/sysdeps/standalone/m68k/m68020/mvme136/_exit.c
new file mode 100644
index 000000000..e5e078c19
--- /dev/null
+++ b/ports/sysdeps/standalone/m68k/m68020/mvme136/_exit.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 1994, 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include "m68020.h"
+
+/* Return control to 135Bug */
+
+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. */
+
+void
+__attribute__ ((noreturn))
+_exit (status)
+ int status;
+{
+ /* status is ignored */
+
+ M68Kvec[ 45 ] = __exit_trap; /* install exit_trap handler */
+ asm volatile( "trap #13" ); /* insures SUPV mode */
+}
+weak_alias (_exit, _Exit)
diff --git a/ports/sysdeps/standalone/m68k/m68020/mvme136/brdinit.c b/ports/sysdeps/standalone/m68k/m68020/mvme136/brdinit.c
new file mode 100644
index 000000000..95b81c1e1
--- /dev/null
+++ b/ports/sysdeps/standalone/m68k/m68020/mvme136/brdinit.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <standalone.h>
+#include "m68020.h"
+
+/* _Board_Initialize()
+
+This routine initializes the Motorola MVME135/MVME136. */
+
+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/ports/sysdeps/standalone/m68k/m68020/mvme136/console.c b/ports/sysdeps/standalone/m68k/m68020/mvme136/console.c
new file mode 100644
index 000000000..85dee983b
--- /dev/null
+++ b/ports/sysdeps/standalone/m68k/m68020/mvme136/console.c
@@ -0,0 +1,101 @@
+/* Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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 macros 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
+_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
+_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/ports/sysdeps/standalone/m68k/m68020/mvme136/mvme136.ld b/ports/sysdeps/standalone/m68k/m68020/mvme136/mvme136.ld
new file mode 100644
index 000000000..9a352f009
--- /dev/null
+++ b/ports/sysdeps/standalone/m68k/m68020/mvme136/mvme136.ld
@@ -0,0 +1,61 @@
+/* Copyright (C) 1994, 1997 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/standalone/m68k/m68020/start.S b/ports/sysdeps/standalone/m68k/m68020/start.S
new file mode 100644
index 000000000..166605fb4
--- /dev/null
+++ b/ports/sysdeps/standalone/m68k/m68020/start.S
@@ -0,0 +1,172 @@
+/* Copyright (C) 1994, 1996, 1997 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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_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/ports/sysdeps/standalone/open.c b/ports/sysdeps/standalone/open.c
new file mode 100644
index 000000000..e0a343241
--- /dev/null
+++ b/ports/sysdeps/standalone/open.c
@@ -0,0 +1,125 @@
+/* Copyright (C) 1994, 1995, 1996, 1997, 2002 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stddef.h>
+
+#include <stdio.h>
+#include <bits/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
+__open (file, oflag)
+ const char *file;
+ int oflag;
+{
+ int mode;
+ int newfd;
+ int index;
+
+ if (file == NULL)
+ {
+ __set_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 ) {
+ __set_errno (ENFILE);
+ return -1;
+ }
+
+ /*
+ * Initialize the open slot
+ */
+
+ __FD_Table[ newfd ].in_use = 1;
+ __FD_Table[ newfd ].flags = oflag;
+
+ return newfd;
+}
+libc_hidden_def (__open)
+
+/* Initialization Code for Console I/O */
+
+#ifdef HAVE_GNU_LD
+static
+#endif
+void
+__NONE_init_console_io (argc, argv, envp)
+ int argc;
+ char **argv;
+ 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/ports/sysdeps/standalone/read.c b/ports/sysdeps/standalone/read.c
new file mode 100644
index 000000000..0fb9e7a1e
--- /dev/null
+++ b/ports/sysdeps/standalone/read.c
@@ -0,0 +1,86 @@
+/* Copyright (C) 1994, 1995, 1996, 1997, 2002 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <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
+__libc_read (int fd, void *buf, size_t nbytes)
+{
+ char *buffer = (char *) buf;
+ int data;
+ int poll;
+
+ __set_errno (0);
+
+ if (nbytes == 0)
+ return 0;
+
+ if ( !__FD_Is_valid( fd ) || !__FD_Table[ fd ].in_use )
+ {
+ __set_errno (EBADF);
+ return -1;
+ }
+ if (buf == NULL)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ if ( __FD_Table[ fd ].flags & O_WRONLY ) /* is it write only? */
+ {
+ __set_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;
+}
+libc_hidden_def (__libc_read)
+weak_alias (__libc_read, __read)
+libc_hidden_weak (__read)
+weak_alias (__libc_read, read)
diff --git a/ports/sysdeps/standalone/standalone.h b/ports/sysdeps/standalone/standalone.h
new file mode 100644
index 000000000..20a0c3380
--- /dev/null
+++ b/ports/sysdeps/standalone/standalone.h
@@ -0,0 +1,31 @@
+/* Copyright (C) 1994, 1997, 2004 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _STANDALONE_H
+#define _STANDALONE_H
+
+#include <sys/cdefs.h>
+
+extern void _Board_Initialize (void);
+
+extern int _Console_Putc (char c);
+extern int _Console_Getc (int poll);
+
+#endif
diff --git a/ports/sysdeps/standalone/write.c b/ports/sysdeps/standalone/write.c
new file mode 100644
index 000000000..5d3823065
--- /dev/null
+++ b/ports/sysdeps/standalone/write.c
@@ -0,0 +1,73 @@
+/* Copyright (C) 1994, 1995, 1996, 1997, 2002 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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
+__libc_write (int fd, const void *buf, size_t nbytes)
+{
+ int count;
+ const char *data = buf;
+
+ if (nbytes == 0)
+ return 0;
+ if ( !__FD_Is_valid( fd ) || !__FD_Table[ fd ].in_use )
+ {
+ __set_errno (EBADF);
+ return -1;
+ }
+ if (buf == NULL)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ if ( !(__FD_Table[ fd ].flags & (O_WRONLY|O_RDWR)) ) /* is it writeable? */
+ {
+ __set_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;
+}
+
+libc_hidden_def (__libc_write)
+weak_alias (__libc_write, __write)
+libc_hidden_weak (__write)
+weak_alias (__libc_write, write)
diff --git a/ports/sysdeps/tahoe/Implies b/ports/sysdeps/tahoe/Implies
new file mode 100644
index 000000000..5a3163701
--- /dev/null
+++ b/ports/sysdeps/tahoe/Implies
@@ -0,0 +1,2 @@
+# A Tahoe is mostly just like a Vax.
+vax
diff --git a/ports/sysdeps/unix/am33/sysdep.S b/ports/sysdeps/unix/am33/sysdep.S
new file mode 100644
index 000000000..d6df22ed6
--- /dev/null
+++ b/ports/sysdeps/unix/am33/sysdep.S
@@ -0,0 +1,64 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>.
+ Based on ../i386/sysdep.S.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#define _ERRNO_H
+#include <bits/errno.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. */
+ cmp EWOULDBLOCK_sys,d0 /* Is it the old EWOULDBLOCK? */
+ bne .Lnotb /* Branch if not. */
+ mov EAGAIN,d0 /* Yes; translate it to EAGAIN. */
+.Lnotb:
+#endif
+#ifndef PIC
+# ifndef _LIBC_REENTRANT
+ mov d0,(C_SYMBOL_NAME (errno))
+# else
+ movm [d2],(sp)
+ add -12,sp
+ mov d0,d2
+ call __errno_location,[],0
+ mov d2,(a0)
+ add 12,sp
+ movm (sp),[d2]
+# endif
+#else
+# error "This shouldn't be assembled for PIC"
+#endif
+ mov -1,d0
+ mov d0,a0
+ ret
+
+#undef __syscall_error
+END (__syscall_error)
diff --git a/ports/sysdeps/unix/am33/sysdep.h b/ports/sysdeps/unix/am33/sysdep.h
new file mode 100644
index 000000000..11578e760
--- /dev/null
+++ b/ports/sysdeps/unix/am33/sysdep.h
@@ -0,0 +1,33 @@
+/* Copyright 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>.
+ Based on ../i386/sysdep.h.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdeps/unix/sysdep.h>
+#include "../../am33/sysdep.h"
+
+#ifdef __ASSEMBLER__
+
+#define r0 d0 /* Normal return-value register. */
+#define r1 !!!! /* Secondary return-value register. */
+#define scratch d1 /* Call-clobbered register for random use. */
+#define MOVE(x,y) mov x, y
+
+#define ret ret [],0
+
+#endif /* __ASSEMBLER__ */
diff --git a/ports/sysdeps/unix/arm/brk.S b/ports/sysdeps/unix/arm/brk.S
new file mode 100644
index 000000000..914e8a8bb
--- /dev/null
+++ b/ports/sysdeps/unix/arm/brk.S
@@ -0,0 +1,56 @@
+/* Copyright (C) 1991, 92, 93, 95, 97, 98 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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)
+#ifdef PIC
+ ldr r1, 1f
+ ldr r2, _cb_addr
+2: add r1, pc, r1
+ add r1, r1, r2
+#else
+ ldr r1, _cb_addr
+#endif
+ str r0, [r1]
+ mov r0, $0
+ DO_RET (r14)
+#ifdef PIC
+1: .long _GLOBAL_OFFSET_TABLE_ - 2b - 8
+_cb_addr:
+ .long C_SYMBOL_NAME(__curbrk)(GOTOFF)
+#else
+_cb_addr:
+ .long C_SYMBOL_NAME(__curbrk)
+#endif
+
+weak_alias (__brk, brk)
diff --git a/ports/sysdeps/unix/arm/dl-brk.S b/ports/sysdeps/unix/arm/dl-brk.S
new file mode 100644
index 000000000..eeb96544e
--- /dev/null
+++ b/ports/sysdeps/unix/arm/dl-brk.S
@@ -0,0 +1 @@
+#include <brk.S>
diff --git a/ports/sysdeps/unix/arm/fork.S b/ports/sysdeps/unix/arm/fork.S
new file mode 100644
index 000000000..bd00c92cf
--- /dev/null
+++ b/ports/sysdeps/unix/arm/fork.S
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991,92,94,95,97,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+/* ARM version. */
+
+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. */
+ sub r1, r1, $1
+ and r0, r0, r1
+ DO_RET (r14)
+PSEUDO_END (__fork)
+libc_hidden_def (__fork)
+
+weak_alias (__fork, fork)
diff --git a/ports/sysdeps/unix/arm/start.c b/ports/sysdeps/unix/arm/start.c
new file mode 100644
index 000000000..6bf08b1d7
--- /dev/null
+++ b/ports/sysdeps/unix/arm/start.c
@@ -0,0 +1,97 @@
+/* Special startup code for ARM a.out binaries.
+ Copyright (C) 1998, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sysdep.h>
+
+/* The first piece of initialized data. */
+int __data_start = 0;
+#ifdef HAVE_WEAK_SYMBOLS
+weak_alias (__data_start, data_start)
+#endif
+
+extern void __libc_init (int argc, char **argv, char **envp);
+extern int main (int argc, char **argv, char **envp);
+
+/* N.B.: It is important that this be the first function.
+ This file is the first thing in the text section. */
+
+/* If this was in C it might create its own stack frame and
+ screw up the arguments. */
+#ifdef NO_UNDERSCORES
+asm (".text; .globl _start; _start: B start1");
+#else
+asm (".text; .globl __start; __start: B _start1");
+
+/* Make an alias called `start' (no leading underscore, so it can't
+ conflict with C symbols) for `_start'. This is the name vendor crt0.o's
+ tend to use, and thus the name most linkers expect. */
+asm (".set start, __start");
+#endif
+
+/* Fool gcc into thinking that more args are passed. This makes it look
+ on the stack (correctly) for the real arguments. It causes somewhat
+ strange register usage in start1(), but we aren't too bothered about
+ that at the moment. */
+#define DUMMIES a1, a2, a3, a4
+
+#ifdef DUMMIES
+#define ARG_DUMMIES DUMMIES,
+#define DECL_DUMMIES int DUMMIES;
+#else
+#define ARG_DUMMIES
+#define DECL_DUMMIES
+#endif
+
+/* ARGSUSED */
+static void
+start1 (ARG_DUMMIES argc, argv, envp)
+ DECL_DUMMIES
+ int argc;
+ char **argv;
+ char **envp;
+{
+ /* Store a pointer to the environment. */
+ __environ = envp;
+
+ /* Do C library initializations. */
+ __libc_init (argc, argv, __environ);
+
+ /* Call the user program. */
+ exit (main (argc, argv, __environ));
+}
diff --git a/ports/sysdeps/unix/arm/sysdep.S b/ports/sysdeps/unix/arm/sysdep.S
new file mode 100644
index 000000000..dcb427e57
--- /dev/null
+++ b/ports/sysdeps/unix/arm/sysdep.S
@@ -0,0 +1,98 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2002, 2003,
+ 2004, 2005
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _ERRNO_H
+#include <bits/errno.h>
+
+#ifdef IS_IN_rtld
+# include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
+#endif
+
+#include <tls.h>
+
+#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 r0, $EWOULDBLOCK_sys /* Is it the old EWOULDBLOCK? */
+ moveq r0, $EAGAIN /* Yes; translate it to EAGAIN. */
+#endif
+
+#if USE___THREAD
+ mov ip, lr
+ mov r1, r0
+
+ mov r0, #0xffff0fff
+ mov lr, pc
+ sub pc, r0, #31
+
+ ldr r2, 1f
+2: ldr r2, [pc, r2]
+ str r1, [r0, r2]
+ mvn r0, #0
+ RETINSTR (, ip)
+
+1: .word errno(gottpoff) + (. - 2b - 8)
+#elif RTLD_PRIVATE_ERRNO
+ ldr r1, 1f
+0: str r0, [pc, r1]
+ mvn r0, $0
+ DO_RET(r14)
+
+1: .word C_SYMBOL_NAME(rtld_errno) - 0b - 8
+#elif defined(_LIBC_REENTRANT)
+ str lr, [sp, #-4]!
+ str r0, [sp, #-4]!
+ bl PLTJMP(C_SYMBOL_NAME(__errno_location))
+ ldr r1, [sp], #4
+ str r1, [r0]
+ mvn r0, $0
+ ldr pc, [sp], #4
+#else
+#ifndef PIC
+ ldr r1, 1f
+ str r0, [r1]
+ mvn r0, $0
+ DO_RET (r14)
+
+1: .long C_SYMBOL_NAME(errno)
+#else
+ @ we have to establish our PIC register
+ ldr r2, 1f
+ ldr r1, 2f
+0: add r2, pc, r2
+ str r0, [r1, r2]
+ mvn r0, $0
+ DO_RET (r14)
+
+1: .word _GLOBAL_OFFSET_TABLE_ - 0b - 8
+2: .word C_SYMBOL_NAME(errno)(GOTOFF)
+#endif
+#endif
+
+#undef __syscall_error
+END (__syscall_error)
diff --git a/ports/sysdeps/unix/arm/sysdep.h b/ports/sysdeps/unix/arm/sysdep.h
new file mode 100644
index 000000000..2cc0a9dae
--- /dev/null
+++ b/ports/sysdeps/unix/arm/sysdep.h
@@ -0,0 +1,31 @@
+/* Copyright (C) 1997, 1998, 2005, 2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdeps/unix/sysdep.h>
+#include <sysdeps/arm/sysdep.h>
+
+/* Some definitions to allow the assembler in sysdeps/unix/ to build
+ without needing ARM-specific versions of all the files. */
+
+#ifdef __ASSEMBLER__
+
+#define ret DO_RET (r14)
+#define MOVE(a,b) mov b,a
+
+#endif
diff --git a/ports/sysdeps/unix/bsd/hp/m68k/brk.S b/ports/sysdeps/unix/bsd/hp/m68k/brk.S
new file mode 100644
index 000000000..037d4d0d0
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/hp/m68k/brk.S
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991, 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/hp/m68k/dl-brk.S b/ports/sysdeps/unix/bsd/hp/m68k/dl-brk.S
new file mode 100644
index 000000000..eeb96544e
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/hp/m68k/dl-brk.S
@@ -0,0 +1 @@
+#include <brk.S>
diff --git a/ports/sysdeps/unix/bsd/hp/m68k/start.c b/ports/sysdeps/unix/bsd/hp/m68k/start.c
new file mode 100644
index 000000000..e04ca0632
--- /dev/null
+++ b/ports/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/ports/sysdeps/unix/bsd/hp/m68k/sysdep.h b/ports/sysdeps/unix/bsd/hp/m68k/sysdep.h
new file mode 100644
index 000000000..75aee674f
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/hp/m68k/sysdep.h
@@ -0,0 +1,56 @@
+/* Copyright (C) 1991, 92, 93, 94, 95, 97 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/hp/m68k/vfork.S b/ports/sysdeps/unix/bsd/hp/m68k/vfork.S
new file mode 100644
index 000000000..abcc1c338
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/hp/m68k/vfork.S
@@ -0,0 +1,56 @@
+/* Copyright (C) 1991, 1994, 1995, 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#ifndef SYS_vfork
+#define SYS_vfork 66
+#endif
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+.globl ___vfork
+___vfork:
+ /* Pop the return PC value into A0. */
+ moveal sp@+, a0
+
+ /* Stuff the syscall number in D0 and trap into the kernel. */
+ movel #SYS_vfork, d0
+ trap #0
+ bcs error /* Branch forward if it failed. */
+
+ /* It succeeded. See which fork we're in. D1 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 D0, so the parent gets D0&-1==R0, and the child
+ gets D0&0==0. */
+ subl #1, d1
+ andl d1, d0
+
+ /* Jump to the return PC. */
+ jmp a0@
+
+error:
+ movel d0, _errno
+ moveq #-1, d0
+ jmp a0@
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/ports/sysdeps/unix/bsd/hp/m68k/wait3.S b/ports/sysdeps/unix/bsd/hp/m68k/wait3.S
new file mode 100644
index 000000000..5b6319182
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/hp/m68k/wait3.S
@@ -0,0 +1,39 @@
+/* Copyright (C) 1991, 1992, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/m68k/pipe.S b/ports/sysdeps/unix/bsd/m68k/pipe.S
new file mode 100644
index 000000000..d7b8ec28d
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/m68k/pipe.S
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991,1992,1993,1995,1997,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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
+
+libc_hidden_def (__pipe)
+weak_alias (__pipe, pipe)
diff --git a/ports/sysdeps/unix/bsd/m68k/start.c b/ports/sysdeps/unix/bsd/m68k/start.c
new file mode 100644
index 000000000..1067853d6
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/m68k/start.c
@@ -0,0 +1,3 @@
+#define DUMMIES ignore0
+
+#include <sysdeps/unix/start.c>
diff --git a/ports/sysdeps/unix/bsd/m68k/syscall.S b/ports/sysdeps/unix/bsd/m68k/syscall.S
new file mode 100644
index 000000000..eb1a8ec7a
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/m68k/syscall.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/m68k/sysdep.S b/ports/sysdeps/unix/bsd/m68k/sysdep.S
new file mode 100644
index 000000000..90f35c9bc
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/m68k/sysdep.S
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define _ERRNO_H
+#include <bits/errno.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/ports/sysdeps/unix/bsd/m68k/wait.S b/ports/sysdeps/unix/bsd/m68k/wait.S
new file mode 100644
index 000000000..9fb4fd93b
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/m68k/wait.S
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 1992, 1993, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/osf/Implies b/ports/sysdeps/unix/bsd/osf/Implies
new file mode 100644
index 000000000..82719f5a5
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/Implies
@@ -0,0 +1,2 @@
+# OSF/1 has the canonical set of <sys/mman.h> system calls.
+unix/mman
diff --git a/ports/sysdeps/unix/bsd/osf/Makefile b/ports/sysdeps/unix/bsd/osf/Makefile
new file mode 100644
index 000000000..743788a41
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/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/ports/sysdeps/unix/bsd/osf/alpha/bits/stat.h b/ports/sysdeps/unix/bsd/osf/alpha/bits/stat.h
new file mode 100644
index 000000000..20f358f70
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/bits/stat.h
@@ -0,0 +1,79 @@
+/* Copyright (C) 1993, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_STAT_H
+# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+#include <bits/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;
+
+ __blksize_t st_blksize; /* Optimal block size for I/O. */
+#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
+
+ __blkcnt_t 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. */
+
+/* POSIX.1b objects. */
+#define __S_TYPEISMQ(buf) (0)
+#define __S_TYPEISSEM(buf) (0)
+#define __S_TYPEISSHM(buf) (0)
+
+/* 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. */
diff --git a/ports/sysdeps/unix/bsd/osf/alpha/brk.S b/ports/sysdeps/unix/bsd/osf/alpha/brk.S
new file mode 100644
index 000000000..51abaa6c1
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/brk.S
@@ -0,0 +1,54 @@
+/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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) */
+ stq 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/ports/sysdeps/unix/bsd/osf/alpha/dl-brk.S b/ports/sysdeps/unix/bsd/osf/alpha/dl-brk.S
new file mode 100644
index 000000000..eeb96544e
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/dl-brk.S
@@ -0,0 +1 @@
+#include <brk.S>
diff --git a/ports/sysdeps/unix/bsd/osf/alpha/fork.S b/ports/sysdeps/unix/bsd/osf/alpha/fork.S
new file mode 100644
index 000000000..a4ec14b56
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/fork.S
@@ -0,0 +1,28 @@
+/* Copyright (C) 1993, 1995, 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+SYSCALL__ (fork, 0)
+ cmovne a4, 0, v0
+ ret
+ .end __fork
+libc_hidden_def (__fork)
+
+weak_alias (__fork, fork)
diff --git a/ports/sysdeps/unix/bsd/osf/alpha/killpg.S b/ports/sysdeps/unix/bsd/osf/alpha/killpg.S
new file mode 100644
index 000000000..741616bc7
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/killpg.S
@@ -0,0 +1,27 @@
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_killpg SYS_ult_killpg
+
+SYSCALL (killpg, 2)
+ ret
+ .end killpg
diff --git a/ports/sysdeps/unix/bsd/osf/alpha/recv.S b/ports/sysdeps/unix/bsd/osf/alpha/recv.S
new file mode 100644
index 000000000..92a273d15
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/recv.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_recv SYS_ult_recv
+
+SYSCALL (recv, 4)
+ ret
+ .end recv
diff --git a/ports/sysdeps/unix/bsd/osf/alpha/send.S b/ports/sysdeps/unix/bsd/osf/alpha/send.S
new file mode 100644
index 000000000..7d61d46a1
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/send.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_send SYS_ult_send
+
+SYSCALL (send, 4)
+ ret
+ .end send
diff --git a/ports/sysdeps/unix/bsd/osf/alpha/sigblock.S b/ports/sysdeps/unix/bsd/osf/alpha/sigblock.S
new file mode 100644
index 000000000..5db55f447
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/sigblock.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_sigblock SYS_ult_sigblock
+
+SYSCALL__ (sigblock, 1)
+ ret
+ .end __sigblock
+
+weak_alias (__sigblock, sigblock)
diff --git a/ports/sysdeps/unix/bsd/osf/alpha/sigpause.S b/ports/sysdeps/unix/bsd/osf/alpha/sigpause.S
new file mode 100644
index 000000000..764636647
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/sigpause.S
@@ -0,0 +1,30 @@
+/* Copyright (C) 1993,95,97,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_sigpause SYS_ult_sigpause
+
+SYSCALL__ (sigpause, 1)
+ ret
+ .end __sigpause
+libc_hidden_def (__sigpause)
+
+weak_alias (__sigpause, sigpause)
diff --git a/ports/sysdeps/unix/bsd/osf/alpha/sigsetmask.S b/ports/sysdeps/unix/bsd/osf/alpha/sigsetmask.S
new file mode 100644
index 000000000..93333aa0b
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/sigsetmask.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_sigsetmask SYS_ult_sigsetmask
+
+SYSCALL__ (sigsetmask, 1)
+ ret
+ .end __sigsetmask
+
+weak_alias (__sigsetmask, sigsetmask)
diff --git a/ports/sysdeps/unix/bsd/osf/alpha/sigvec.S b/ports/sysdeps/unix/bsd/osf/alpha/sigvec.S
new file mode 100644
index 000000000..45fcc58a0
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/sigvec.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_sigvec SYS_ult_sigvec
+
+SYSCALL__ (sigvec, 3)
+ ret
+ .end __sigvec
+
+weak_alias (__sigvec, sigvec)
diff --git a/ports/sysdeps/unix/bsd/osf/alpha/start.S b/ports/sysdeps/unix/bsd/osf/alpha/start.S
new file mode 100644
index 000000000..1fa52a643
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/start.S
@@ -0,0 +1,83 @@
+/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#if 0
+.sdata
+.globl STARTFRM
+STARTFRM = 0
+#endif
+
+.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/ports/sysdeps/unix/bsd/osf/alpha/syscalls.list b/ports/sysdeps/unix/bsd/osf/alpha/syscalls.list
new file mode 100644
index 000000000..ac883925e
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/syscalls.list
@@ -0,0 +1,3 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+wait4 - wait4 4 __wait4 wait4
diff --git a/ports/sysdeps/unix/bsd/osf/alpha/sysdep.h b/ports/sysdeps/unix/bsd/osf/alpha/sysdep.h
new file mode 100644
index 000000000..84ac541aa
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/sysdep.h
@@ -0,0 +1,30 @@
+/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* OSF/1 does not precede the asm names of C symbols with a `_'. */
+#define NO_UNDERSCORES
+
+#include <sysdeps/unix/alpha/sysdep.h>
+
+#ifdef __ASSEMBLER__
+
+#include <machine/pal.h> /* get PAL_callsys */
+#include <regdef.h>
+
+#endif
diff --git a/ports/sysdeps/unix/bsd/osf/alpha/vhangup.S b/ports/sysdeps/unix/bsd/osf/alpha/vhangup.S
new file mode 100644
index 000000000..3c2b04af7
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/vhangup.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#include <sys/ult_syscall.h>
+#define SYS_vhangup SYS_ult_vhangup
+
+SYSCALL (vhangup, 1)
+ ret
+ .end vhangup
diff --git a/ports/sysdeps/unix/bsd/osf/alpha/waitpid.c b/ports/sysdeps/unix/bsd/osf/alpha/waitpid.c
new file mode 100644
index 000000000..8378982ac
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/alpha/waitpid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/waitpid.c>
diff --git a/ports/sysdeps/unix/bsd/osf/bits/mman.h b/ports/sysdeps/unix/bsd/osf/bits/mman.h
new file mode 100644
index 000000000..d4672ccca
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/bits/mman.h
@@ -0,0 +1,71 @@
+/* Flags for BSD-style memory management. OSF/1 version.
+ Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _BITS_MMAN_H
+#define _BITS_MMAN_H 1
+
+/* 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). */
+#ifdef __USE_BSD
+# 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. */
+#endif
+
+/* 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. */
+#ifdef __USE_BSD
+# 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. */
+#endif
+
+/* Advice to `madvise'. */
+#ifdef __USE_BSD
+# 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. */
+#endif
+
+/* Flags to `msync'. */
+#define MS_ASYNC 1 /* Asynchronous cache flush. */
+#define MS_SYNC 3 /* Synchronous cache flush. */
+#define MS_INVALIDATE 4 /* Invalidate cached pages. */
+
+#endif /* bits/mman.h */
diff --git a/ports/sysdeps/unix/bsd/osf/bits/sigaction.h b/ports/sysdeps/unix/bsd/osf/bits/sigaction.h
new file mode 100644
index 000000000..13f9144fa
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/bits/sigaction.h
@@ -0,0 +1,50 @@
+/* Structure and constant definitions for sigaction et al. OSF/1 version.
+ Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SIGNAL_H
+# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
+#endif
+
+/* 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 /* 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/ports/sysdeps/unix/bsd/osf/syscalls.list b/ports/sysdeps/unix/bsd/osf/syscalls.list
new file mode 100644
index 000000000..731763b3e
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/syscalls.list
@@ -0,0 +1,3 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+msync - msync 3 msync
diff --git a/ports/sysdeps/unix/bsd/osf/system.c b/ports/sysdeps/unix/bsd/osf/system.c
new file mode 100644
index 000000000..ef42ea215
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/osf/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/ports/sysdeps/unix/bsd/sequent/i386/getgroups.S b/ports/sysdeps/unix/bsd/sequent/i386/getgroups.S
new file mode 100644
index 000000000..55fa7288d
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sequent/i386/getgroups.S
@@ -0,0 +1,44 @@
+/* Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/sequent/i386/sigvec.S b/ports/sysdeps/unix/bsd/sequent/i386/sigvec.S
new file mode 100644
index 000000000..62373e131
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sequent/i386/sigvec.S
@@ -0,0 +1,45 @@
+/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/sequent/i386/syscall.S b/ports/sysdeps/unix/bsd/sequent/i386/syscall.S
new file mode 100644
index 000000000..9ff189885
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sequent/i386/syscall.S
@@ -0,0 +1,31 @@
+/* `syscall' function for Sequent Symmetry running Dynix version 3.
+ Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/sequent/i386/sysdep.h b/ports/sysdeps/unix/bsd/sequent/i386/sysdep.h
new file mode 100644
index 000000000..c3d9d919b
--- /dev/null
+++ b/ports/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, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/sony/newsos/m68k/Implies b/ports/sysdeps/unix/bsd/sony/newsos/m68k/Implies
new file mode 100644
index 000000000..7b5f3cfc9
--- /dev/null
+++ b/ports/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/ports/sysdeps/unix/bsd/sony/newsos/m68k/sysdep.h b/ports/sysdeps/unix/bsd/sony/newsos/m68k/sysdep.h
new file mode 100644
index 000000000..db124fa15
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sony/newsos/m68k/sysdep.h
@@ -0,0 +1,56 @@
+/* Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/sony/newsos4/Makefile b/ports/sysdeps/unix/bsd/sony/newsos4/Makefile
new file mode 100644
index 000000000..053da568d
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sony/newsos4/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),posix)
+sysdep_routines := $(sysdep_routines) sys_wait4
+endif
diff --git a/ports/sysdeps/unix/bsd/sony/newsos4/syscalls.list b/ports/sysdeps/unix/bsd/sony/newsos4/syscalls.list
new file mode 100644
index 000000000..b90087f42
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sony/newsos4/syscalls.list
@@ -0,0 +1,3 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+sys_wait4 wait4 wait4 4 __wait4_syscall
diff --git a/ports/sysdeps/unix/bsd/sony/newsos4/wait.c b/ports/sysdeps/unix/bsd/sony/newsos4/wait.c
new file mode 100644
index 000000000..79d54580f
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sony/newsos4/wait.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/wait.c>
diff --git a/ports/sysdeps/unix/bsd/sony/newsos4/wait3.c b/ports/sysdeps/unix/bsd/sony/newsos4/wait3.c
new file mode 100644
index 000000000..0b3bdee77
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sony/newsos4/wait3.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/wait3.c>
diff --git a/ports/sysdeps/unix/bsd/sony/newsos4/wait4.c b/ports/sysdeps/unix/bsd/sony/newsos4/wait4.c
new file mode 100644
index 000000000..856c99fd6
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sony/newsos4/wait4.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/sun/sunos4/wait4.c>
diff --git a/ports/sysdeps/unix/bsd/sun/bits/signum.h b/ports/sysdeps/unix/bsd/sun/bits/signum.h
new file mode 100644
index 000000000..c13e7cd74
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/bits/signum.h
@@ -0,0 +1,69 @@
+/* Signal number definitions. SunOS version.
+ Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/sun/m68k/Makefile b/ports/sysdeps/unix/bsd/sun/m68k/Makefile
new file mode 100644
index 000000000..ac4121dc2
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/m68k/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),signal)
+sysdep_routines := $(sysdep_routines) sigtramp
+endif
diff --git a/ports/sysdeps/unix/bsd/sun/m68k/bits/sigcontext.h b/ports/sysdeps/unix/bsd/sun/m68k/bits/sigcontext.h
new file mode 100644
index 000000000..99a0506a8
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/m68k/bits/sigcontext.h
@@ -0,0 +1,30 @@
+/* Structure describing state saved while handling a signal. Sun 3 version.
+ Copyright (C) 1993, 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SIGNAL_H
+# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
+#endif
+
+struct sigcontext
+ {
+ int sc_onstack;
+ __sigset_t sc_mask;
+
+ int sc_sp, sc_pc, sc_ps;
+ };
diff --git a/ports/sysdeps/unix/bsd/sun/m68k/brk.S b/ports/sysdeps/unix/bsd/sun/m68k/brk.S
new file mode 100644
index 000000000..9f821a060
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/m68k/brk.S
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991,1992,1994,1995,1997,2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#ifndef SYS_brk
+#define SYS_brk 17
+#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/ports/sysdeps/unix/bsd/sun/m68k/dl-brk.S b/ports/sysdeps/unix/bsd/sun/m68k/dl-brk.S
new file mode 100644
index 000000000..eeb96544e
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/m68k/dl-brk.S
@@ -0,0 +1 @@
+#include <brk.S>
diff --git a/ports/sysdeps/unix/bsd/sun/m68k/sethostid.S b/ports/sysdeps/unix/bsd/sun/m68k/sethostid.S
new file mode 100644
index 000000000..13af476df
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/m68k/sethostid.S
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991, 1992, 1997, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#ifdef SYS_sethostid
+
+SYSCALL (sethostid, 1)
+ ret
+
+#else
+
+#include <bits/errno.h>
+
+.globl _sethostid
+.even
+_sethostid:
+ movel #ENOSYS, _errno
+ moveq #-1, d0
+ rts
+
+.stabs "warning: sethostid is not implemented and will always fail",30,0,0,0
+.stabs "_sethostid",1,0,0,0
+
+#endif
diff --git a/ports/sysdeps/unix/bsd/sun/m68k/sigtramp.c b/ports/sysdeps/unix/bsd/sun/m68k/sigtramp.c
new file mode 100644
index 000000000..5a3ca3cf1
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/m68k/sigtramp.c
@@ -0,0 +1,145 @@
+/* Copyright (C) 1993, 1996, 1997, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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 __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
+trampoline (sig, code, context, addr)
+ int sig;
+ int code;
+ struct sigcontext *context;
+ void *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 (*) (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
+__sigvec (sig, vec, ovec)
+ int sig;
+ const struct sigvec *vec;
+ 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)
+ {
+ __set_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/ports/sysdeps/unix/bsd/sun/m68k/syscall.S b/ports/sysdeps/unix/bsd/sun/m68k/syscall.S
new file mode 100644
index 000000000..1d4d5be42
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/m68k/syscall.S
@@ -0,0 +1,28 @@
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/sun/m68k/sysdep.h b/ports/sysdeps/unix/bsd/sun/m68k/sysdep.h
new file mode 100644
index 000000000..e51ab0a8e
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/m68k/sysdep.h
@@ -0,0 +1,62 @@
+/* Copyright (C) 1991, 1992, 1994, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/sun/m68k/vfork.S b/ports/sysdeps/unix/bsd/sun/m68k/vfork.S
new file mode 100644
index 000000000..cf9e2e9e1
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/m68k/vfork.S
@@ -0,0 +1,56 @@
+/* Copyright (C) 1991, 92, 93, 94, 95, 97, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#ifndef SYS_vfork
+#define SYS_vfork 66
+#endif
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+.globl ___vfork
+___vfork:
+ /* Pop the return PC value into A0. */
+ movel sp@+, a0
+
+ /* Push the syscall number and trap into the kernel. */
+ movel #SYS_vfork, sp@-
+ trap #0
+ bcs error /* Branch forward if it failed. */
+
+ /* It succeeded. See which fork we're in. D1 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 D0, so the parent gets D0&-1==R0, and the child
+ gets D0&0==0. */
+ subql #1, d1
+ andl d1, d0
+
+ /* Jump to the return PC. */
+ jmp a0@
+
+error:
+ movel d0, _errno
+ moveq #-1, d0
+ jmp a0@
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/ports/sysdeps/unix/bsd/sun/sethostid.c b/ports/sysdeps/unix/bsd/sun/sethostid.c
new file mode 100644
index 000000000..6c0d39db5
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sethostid.c
@@ -0,0 +1 @@
+#include <misc/sethostid.c>
diff --git a/ports/sysdeps/unix/bsd/sun/sigreturn.S b/ports/sysdeps/unix/bsd/sun/sigreturn.S
new file mode 100644
index 000000000..a3ea8e3fa
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sigreturn.S
@@ -0,0 +1,28 @@
+/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/sun/sparc/Makefile b/ports/sysdeps/unix/bsd/sun/sparc/Makefile
new file mode 100644
index 000000000..59d10dbdb
--- /dev/null
+++ b/ports/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/ports/sysdeps/unix/bsd/sun/sparc/bits/sigcontext.h b/ports/sysdeps/unix/bsd/sun/sparc/bits/sigcontext.h
new file mode 100644
index 000000000..7c4bca604
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sparc/bits/sigcontext.h
@@ -0,0 +1,34 @@
+/* Structure describing state saved while handling a signal. Sparc version.
+ Copyright (C) 1992, 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SIGNAL_H
+# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
+#endif
+
+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/ports/sysdeps/unix/bsd/sun/sparc/sethostid.S b/ports/sysdeps/unix/bsd/sun/sparc/sethostid.S
new file mode 100644
index 000000000..100fb1c1c
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sparc/sethostid.S
@@ -0,0 +1,43 @@
+/* Copyright (C) 1991, 1992, 1997, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#ifdef SYS_sethostid
+
+SYSCALL (sethostid, 1)
+ ret
+
+#else
+
+/* <bits/errno.h> only defines E* #ifdef _ERRNO_H. */
+#define _ERRNO_H
+#include <bits/errno.h>
+
+ENTRY (sethostid)
+ mov ENOSYS, %o0
+ sethi %hi(_errno), %g1
+ st %o0, [%g1 + %lo(_errno)]
+ retl
+ sub %g0, 1, %o0
+
+
+.stabs "warning: sethostid is not implemented and will always fail",30,0,0,0
+.stabs "_sethostid",1,0,0,0
+
+#endif
diff --git a/ports/sysdeps/unix/bsd/sun/sparc/sigtramp.c b/ports/sysdeps/unix/bsd/sun/sparc/sigtramp.c
new file mode 100644
index 000000000..e11f7e51d
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sparc/sigtramp.c
@@ -0,0 +1,247 @@
+/* Copyright (C) 1991,1992,1994,1996,1997,2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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 __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
+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. */
+ void *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 (*) (int sig, int code, struct sigcontext *context,
+ void *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
+__sigvec (sig, vec, ovec)
+ int sig;
+ const struct sigvec *vec;
+ 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)
+ {
+ __set_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/ports/sysdeps/unix/bsd/sun/sunos4/.cvsignore b/ports/sysdeps/unix/bsd/sun/sunos4/.cvsignore
new file mode 100644
index 000000000..1f69fd919
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/.cvsignore
@@ -0,0 +1,4 @@
+*.gz *.Z *.tar *.tgz
+=*
+TODO COPYING* AUTHORS copyr-* copying.*
+glibc-*
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/Implies b/ports/sysdeps/unix/bsd/sun/sunos4/Implies
new file mode 100644
index 000000000..c99e256ac
--- /dev/null
+++ b/ports/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/ports/sysdeps/unix/bsd/sun/sunos4/Makefile b/ports/sysdeps/unix/bsd/sun/sunos4/Makefile
new file mode 100644
index 000000000..d17654a30
--- /dev/null
+++ b/ports/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/ports/sysdeps/unix/bsd/sun/sunos4/bits/fcntl.h b/ports/sysdeps/unix/bsd/sun/sunos4/bits/fcntl.h
new file mode 100644
index 000000000..a30b35259
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/bits/fcntl.h
@@ -0,0 +1,142 @@
+/* O_*, F_*, FD_* bit values for SunOS 4.
+ Copyright (C) 1991, 1992, 1997, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FCNTL_H
+#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+
+/* 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. */
+#if defined __USE_BSD || defined __USE_UNIX98
+#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 <bits/types.h>
+
+/* The structure describing an advisory lock. This is the type of the third
+ argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests. */
+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. */
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/bits/mman.h b/ports/sysdeps/unix/bsd/sun/sunos4/bits/mman.h
new file mode 100644
index 000000000..fdef46522
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/bits/mman.h
@@ -0,0 +1,68 @@
+/* Definitions for BSD-style memory management. SunOS 4 version.
+ Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _BITS_MMAN_H
+#define _BITS_MMAN_H 1
+
+/* 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. */
+#ifdef __USE_BSD
+# define MAP_TYPE 0x0f /* Mask for sharing type. */
+#endif
+
+/* 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. */
+#ifdef __USE_BSD
+# 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. */
+#endif
+
+/* 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'. */
+#ifdef __USE_BSD
+# 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. */
+#endif
+
+/* Flags to `msync'. */
+#define MS_ASYNC 0x1 /* Return immediately, don't fsync. */
+#define MS_INVALIDATE 0x2 /* Invalidate caches. */
+
+#endif /* bits/mman.h */
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/bits/resource.h b/ports/sysdeps/unix/bsd/sun/sunos4/bits/resource.h
new file mode 100644
index 000000000..2f0d2dc73
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/bits/resource.h
@@ -0,0 +1,174 @@
+/* Bit values for resource limits. SunOS 4 version.
+ Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_RESOURCE_H
+# error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
+#endif
+
+/* 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. */
+
+#include <bits/types.h>
+
+/* Kinds of resource limit. */
+enum __rlimit_resource
+ {
+ /* Per-process CPU limit, in seconds. */
+ RLIMIT_CPU,
+#define RLIMIT_CPU RLIMIT_CPU
+ /* Largest file that can be created, in bytes. */
+ RLIMIT_FSIZE,
+#define RLIMIT_FSIZE RLIMIT_FSIZE
+ /* Maximum size of data segment, in bytes. */
+ RLIMIT_DATA,
+#define RLIMIT_DATA RLIMIT_DATA
+ /* Maximum size of stack segment, in bytes. */
+ RLIMIT_STACK,
+#define RLIMIT_STACK RLIMIT_STACK
+ /* Largest core file that can be created, in bytes. */
+ RLIMIT_CORE,
+#define RLIMIT_CORE 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,
+#define RLIMIT_RSS RLIMIT_RSS
+ /* Number of open files. */
+ RLIMIT_NOFILE,
+ RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same. */
+#define RLIMIT_NOFILE RLIMIT_NOFILE
+#define RLIMIT_OFILE RLIMIT_OFILE
+
+ RLIM_NLIMITS
+ };
+
+/* Value to indicate that there is no limit. */
+#ifndef __USE_FILE_OFFSET64
+# define RLIM_INFINITY 0x7fffffff
+#else
+# define RLIM_INFINITY 0x7fffffffffffffffLL
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define RLIM64_INFINITY 0x7fffffffffffffffLL
+#endif
+
+
+/* Type to represent quantities in resource limits. */
+#ifndef __USE_FILE_OFFSET64
+typedef __rlim_t rlim_t;
+#else
+typedef __rlim64_t rlim_t;
+#endif
+
+struct rlimit
+ {
+ /* The current (soft) limit. */
+ rlim_t rlim_cur;
+ /* The hard limit. */
+ rlim_t rlim_max;
+ };
+
+#ifdef __USE_LARGEFILE64
+typedef __rlim64_t rlim64_t;
+
+struct rlimit64
+ {
+ /* The current (soft) limit. */
+ rlim64_t rlim_cur;
+ /* The hard limit. */
+ rlim64_t rlim_max;
+ };
+#endif
+
+/* Whose usage statistics do you want? */
+enum __rusage_who
+/* The macro definitions are necessary because some programs want
+ to test for operating system features with #ifdef RUSAGE_SELF.
+ In ISO C the reflexive definition is a no-op. */
+ {
+ /* The calling process. */
+ RUSAGE_SELF = 0,
+#define RUSAGE_SELF RUSAGE_SELF
+ /* All of its terminated child processes. */
+ RUSAGE_CHILDREN = -1
+#define RUSAGE_CHILDREN RUSAGE_CHILDREN
+ };
+
+#define __need_timeval
+#include <bits/time.h> /* For `struct timeval'. */
+
+/* Structure which says how much of each resource has been used. */
+struct rusage
+ {
+ /* Total amount of user time used. */
+ struct timeval ru_utime;
+ /* Total amount of system time used. */
+ struct timeval ru_stime;
+ /* Maximum resident set size (in kilobytes). */
+ long int ru_maxrss;
+ /* Amount of sharing of text segment memory
+ with other processes (kilobyte-seconds). */
+ long int ru_ixrss;
+ /* Amount of data segment memory used (kilobyte-seconds). */
+ long int ru_idrss;
+ /* Amount of stack memory used (kilobyte-seconds). */
+ long int ru_isrss;
+ /* Number of soft page faults (i.e. those serviced by reclaiming
+ a page from the list of pages awaiting reallocation. */
+ long int ru_minflt;
+ /* Number of hard page faults (i.e. those that required I/O). */
+ long int ru_majflt;
+ /* Number of times a process was swapped out of physical memory. */
+ long int ru_nswap;
+ /* Number of input operations via the file system. Note: This
+ and `ru_oublock' do not include operations with the cache. */
+ long int ru_inblock;
+ /* Number of output operations via the file system. */
+ long int ru_oublock;
+ /* Number of IPC messages sent. */
+ long int ru_msgsnd;
+ /* Number of IPC messages received. */
+ long int ru_msgrcv;
+ /* Number of signals delivered. */
+ long int ru_nsignals;
+ /* Number of voluntary context switches, i.e. because the process
+ gave up the process before it had to (usually to wait for some
+ resource to be available). */
+ long int ru_nvcsw;
+ /* Number of involuntary context switches, i.e. a higher priority process
+ became runnable or the current process used up its time slice. */
+ long int ru_nivcsw;
+ };
+
+/* Priority limits. */
+#define PRIO_MIN -20 /* Minimum priority a process can have. */
+#define PRIO_MAX 20 /* Maximum priority a process can have. */
+
+/* The type of the WHICH argument to `getpriority' and `setpriority',
+ indicating what flavor of entity the WHO argument specifies. */
+enum __priority_which
+ {
+ PRIO_PROCESS = 0, /* WHO is a process ID. */
+ PRIO_PGRP = 1, /* WHO is a process group ID. */
+ PRIO_USER = 2 /* WHO is a user ID. */
+ };
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/bits/termios.h b/ports/sysdeps/unix/bsd/sun/sunos4/bits/termios.h
new file mode 100644
index 000000000..97612c8f0
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/bits/termios.h
@@ -0,0 +1,212 @@
+/* termios type and macro definitions. SunOS 4 version.
+ Copyright (C) 1993, 1994, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _TERMIOS_H
+# error "Never include <bits/termios.h> directly; use <termios.h> instead."
+#endif
+
+/* 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/ports/sysdeps/unix/bsd/sun/sunos4/bits/utsname.h b/ports/sysdeps/unix/bsd/sun/sunos4/bits/utsname.h
new file mode 100644
index 000000000..a0246c2a3
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/bits/utsname.h
@@ -0,0 +1,24 @@
+/* Copyright (C) 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_UTSNAME_H
+# error "Never include <bits/utsname.h> directly; use <sys/utsname.h> instead."
+#endif
+
+#define _UTSNAME_LENGTH 9
+#define _UTSNAME_NODENAME_LENGTH 65
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/mmap.c b/ports/sysdeps/unix/bsd/sun/sunos4/mmap.c
new file mode 100644
index 000000000..c513ae27e
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/mmap.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 MAP_FAILED
+ for errors (in which case `errno' is set). A successful `mmap' call
+ deallocates any previous mapping for the affected region. */
+
+extern __ptr_t __mmap_syscall (__ptr_t addr, size_t len,
+ int prot, int flags, int fd, off_t offset);
+
+
+__ptr_t
+__mmap (__ptr_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);
+}
+
+weak_alias (__mmap, mmap)
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/speed.c b/ports/sysdeps/unix/bsd/sun/sunos4/speed.c
new file mode 100644
index 000000000..262d70fdf
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/speed.c
@@ -0,0 +1,118 @@
+/* `struct termios' speed frobnication functions. SunOS 4 version.
+ Copyright (C) 1991,1992,1993,1996,1997,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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
+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
+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
+cfsetospeed (termios_p, speed)
+ struct termios *termios_p;
+ speed_t speed;
+{
+ register unsigned int i;
+
+ if (termios_p == NULL)
+ {
+ __set_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;
+ }
+
+ __set_errno (EINVAL);
+ return -1;
+}
+libc_hidden_def (cfsetospeed)
+
+/* Set the input baud rate stored in *TERMIOS_P to SPEED. */
+int
+cfsetispeed (termios_p, speed)
+ struct termios *termios_p;
+ speed_t speed;
+{
+ register unsigned int i;
+
+ if (termios_p == NULL)
+ {
+ __set_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;
+ }
+
+ __set_errno (EINVAL);
+ return -1;
+}
+libc_hidden_def (cfsetispeed)
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/sys/ttydefaults.h b/ports/sysdeps/unix/bsd/sun/sunos4/sys/ttydefaults.h
new file mode 100644
index 000000000..d18433c6f
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/sys/ttydefaults.h
@@ -0,0 +1,100 @@
+/*-
+ * Copyright (c) 1982, 1986, 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.
+ * 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.
+ *
+ * @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94
+ */
+
+/*
+ * System wide defaults for terminal state. SunOS 4 version.
+ */
+#ifndef _SYS_TTYDEFAULTS_H_
+#define _SYS_TTYDEFAULTS_H_
+
+/*
+ * Defaults on "first" open.
+ */
+#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
+#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS)
+#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
+#define TTYDEF_CFLAG (CREAD | CS7 | PARENB | HUPCL)
+#define TTYDEF_SPEED (B9600)
+
+/*
+ * Control Character Defaults
+ */
+#define CTRL(x) (x&037)
+#define CEOF CTRL('d')
+#ifdef _POSIX_VDISABLE
+# define CEOL _POSIX_VDISABLE
+#else
+# define CEOL ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */
+#endif
+#define CERASE 0177
+#define CINTR CTRL('c')
+#ifdef _POSIX_VDISABLE
+# define CSTATUS _POSIX_VDISABLE
+#else
+# define CSTATUS ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */
+#endif
+#define CKILL CTRL('u')
+#define CMIN 1
+#define CQUIT 034 /* FS, ^\ */
+#define CSUSP CTRL('z')
+#define CTIME 0
+#define CDSUSP CTRL('y')
+#define CSTART CTRL('q')
+#define CSTOP CTRL('s')
+#define CLNEXT CTRL('v')
+#define CDISCARD CTRL('o')
+#define CWERASE CTRL('w')
+#define CREPRINT CTRL('r')
+#define CEOT CEOF
+/* compat */
+#define CBRK CEOL
+#define CRPRNT CREPRINT
+#define CFLUSH CDISCARD
+
+/* PROTECTED INCLUSION ENDS HERE */
+#endif /* !_SYS_TTYDEFAULTS_H_ */
+
+/*
+ * #define TTYDEFCHARS to include an array of default control characters.
+ */
+#ifdef TTYDEFCHARS
+cc_t ttydefchars[NCCS] = {
+ CEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT,
+ _POSIX_VDISABLE, CINTR, CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT,
+ CDISCARD, CMIN, CTIME, CSTATUS, _POSIX_VDISABLE
+};
+#undef TTYDEFCHARS
+#endif
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/syscalls.list b/ports/sysdeps/unix/bsd/sun/sunos4/syscalls.list
new file mode 100644
index 000000000..59992eed5
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/syscalls.list
@@ -0,0 +1,6 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+msync - msync 3 msync
+poll - poll 3 poll
+sys_mmap mmap mmap 5 __mmap_syscall
+sys_wait4 wait4 wait4 4 __wait4_syscall
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/system.c b/ports/sysdeps/unix/bsd/sun/sunos4/system.c
new file mode 100644
index 000000000..2c8e634bc
--- /dev/null
+++ b/ports/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/ports/sysdeps/unix/bsd/sun/sunos4/tcflow.c b/ports/sysdeps/unix/bsd/sun/sunos4/tcflow.c
new file mode 100644
index 000000000..6fcc606f6
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/tcflow.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+/* Suspend or restart transmission on FD. */
+int
+tcflow (fd, action)
+ int fd;
+ int action;
+{
+ return __ioctl (fd, TCXONC, action);
+}
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/tcflush.c b/ports/sysdeps/unix/bsd/sun/sunos4/tcflush.c
new file mode 100644
index 000000000..9e78aadd0
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/tcflush.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+/* Flush pending data on FD. */
+int
+tcflush (fd, queue_selector)
+ int fd;
+ int queue_selector;
+{
+ return __ioctl (fd, TCFLSH, queue_selector);
+}
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/tcgetattr.c b/ports/sysdeps/unix/bsd/sun/sunos4/tcgetattr.c
new file mode 100644
index 000000000..ab74fddf2
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/tcgetattr.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <stddef.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+/* Put the state of FD into *TERMIOS_P. */
+int
+__tcgetattr (fd, termios_p)
+ int fd;
+ struct termios *termios_p;
+{
+ return __ioctl (fd, TCGETS, termios_p);
+}
+
+weak_alias (__tcgetattr, tcgetattr)
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/tcsendbrk.c b/ports/sysdeps/unix/bsd/sun/sunos4/tcsendbrk.c
new file mode 100644
index 000000000..db5ea8c83
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/tcsendbrk.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+#include <sys/termio.h> /* Sun header file. */
+
+/* Send zero bits on FD. */
+int
+tcsendbreak (fd, duration)
+ int fd;
+ int duration;
+{
+ /* According to SunOS 4.1's termios(4), you can't specify a duration. */
+ return __ioctl (fd, TCSBRK, 0);
+}
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/tcsetattr.c b/ports/sysdeps/unix/bsd/sun/sunos4/tcsetattr.c
new file mode 100644
index 000000000..934c4c8cf
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/tcsetattr.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 1993, 1996, 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+/* Set the state of FD to *TERMIOS_P. */
+int
+tcsetattr (fd, optional_actions, termios_p)
+ int fd;
+ int optional_actions;
+ const struct termios *termios_p;
+{
+ unsigned long cmd;
+
+ switch (optional_actions)
+ {
+ case TCSANOW:
+ cmd = TCSETS;
+ break;
+ case TCSADRAIN:
+ cmd = TCSETSW;
+ break;
+ case TCSAFLUSH:
+ cmd = TCSETSF;
+ break;
+ default:
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return __ioctl (fd, cmd, termios_p);
+}
+libc_hidden_def (tcsetattr)
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/wait.c b/ports/sysdeps/unix/bsd/sun/sunos4/wait.c
new file mode 100644
index 000000000..79d54580f
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/wait.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/wait.c>
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/wait3.c b/ports/sysdeps/unix/bsd/sun/sunos4/wait3.c
new file mode 100644
index 000000000..0b3bdee77
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/wait3.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/wait3.c>
diff --git a/ports/sysdeps/unix/bsd/sun/sunos4/wait4.c b/ports/sysdeps/unix/bsd/sun/sunos4/wait4.c
new file mode 100644
index 000000000..097c15e7d
--- /dev/null
+++ b/ports/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,1997,2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+extern pid_t __wait4_syscall (pid_t pid, __WAIT_STATUS_DEFN stat_loc,
+ int options, struct rusage *usage);
+
+pid_t
+__wait4 (pid, stat_loc, options, usage)
+ pid_t pid;
+ __WAIT_STATUS_DEFN stat_loc;
+ int options;
+ 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/ports/sysdeps/unix/bsd/sun/sunos4/waitpid.c b/ports/sysdeps/unix/bsd/sun/sunos4/waitpid.c
new file mode 100644
index 000000000..8378982ac
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/sunos4/waitpid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/waitpid.c>
diff --git a/ports/sysdeps/unix/bsd/sun/syscalls.list b/ports/sysdeps/unix/bsd/sun/syscalls.list
new file mode 100644
index 000000000..079aa9157
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/sun/syscalls.list
@@ -0,0 +1,3 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+sigvec - sigvec 3 __raw_sigvec
diff --git a/ports/sysdeps/unix/bsd/tahoe/Implies b/ports/sysdeps/unix/bsd/tahoe/Implies
new file mode 100644
index 000000000..a7ecf5827
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/tahoe/Implies
@@ -0,0 +1 @@
+unix/bsd/vax
diff --git a/ports/sysdeps/unix/bsd/tahoe/sysdep.h b/ports/sysdeps/unix/bsd/tahoe/sysdep.h
new file mode 100644
index 000000000..b87590632
--- /dev/null
+++ b/ports/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/ports/sysdeps/unix/bsd/ultrix4/Implies b/ports/sysdeps/unix/bsd/ultrix4/Implies
new file mode 100644
index 000000000..b0e08ef1d
--- /dev/null
+++ b/ports/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/ports/sysdeps/unix/bsd/ultrix4/Makefile b/ports/sysdeps/unix/bsd/ultrix4/Makefile
new file mode 100644
index 000000000..26b90346e
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),posix)
+sysdep_routines := $(sysdep_routines) getsysinfo
+endif
diff --git a/ports/sysdeps/unix/bsd/ultrix4/bits/fcntl.h b/ports/sysdeps/unix/bsd/ultrix4/bits/fcntl.h
new file mode 100644
index 000000000..6392bc341
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/bits/fcntl.h
@@ -0,0 +1,122 @@
+/* O_*, F_*, FD_* bit values for Ultrix 4.
+ Copyright (C) 1991, 1992, 1997, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FCNTL_H
+#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+
+/* 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. */
+#if defined __USE_BSD || defined __USE_UNIX98
+#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 <bits/types.h>
+
+/* The structure describing an advisory lock. This is the type of the third
+ argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests. */
+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. */
diff --git a/ports/sysdeps/unix/bsd/ultrix4/bits/mman.h b/ports/sysdeps/unix/bsd/ultrix4/bits/mman.h
new file mode 100644
index 000000000..918b53563
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/bits/mman.h
@@ -0,0 +1,51 @@
+/* Definitions for BSD-style memory management. Ultrix 4 version.
+ Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _BITS_MMAN_H
+#define _BITS_MMAN_H 1
+
+/* 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. */
+#ifdef __USE_BSD
+# define MAP_TYPE 0x0f /* Mask for sharing type. */
+#endif
+
+/* Other flags. */
+#define MAP_FIXED 0x10 /* Map address must be exactly as requested. */
+
+/* Advice to `madvise'. */
+#ifdef __USE_BSD
+# 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. */
+#endif
+
+#endif /* bits/mman.h */
diff --git a/ports/sysdeps/unix/bsd/ultrix4/bits/posix_opt.h b/ports/sysdeps/unix/bsd/ultrix4/bits/posix_opt.h
new file mode 100644
index 000000000..aba6852e1
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/bits/posix_opt.h
@@ -0,0 +1,24 @@
+/* Copyright (C) 1992, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/ultrix4/bits/utsname.h b/ports/sysdeps/unix/bsd/ultrix4/bits/utsname.h
new file mode 100644
index 000000000..57820471a
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/bits/utsname.h
@@ -0,0 +1,23 @@
+/* Copyright (C) 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_UTSNAME_H
+# error "Never include <bits/utsname.h> directly; use <sys/utsname.h> instead."
+#endif
+
+#define _UTSNAME_LENGTH 32
diff --git a/ports/sysdeps/unix/bsd/ultrix4/mips/Makefile b/ports/sysdeps/unix/bsd/ultrix4/mips/Makefile
new file mode 100644
index 000000000..74e3b04f6
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/mips/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),signal)
+sysdep_routines := $(sysdep_routines) __handler
+endif
diff --git a/ports/sysdeps/unix/bsd/ultrix4/mips/__handler.S b/ports/sysdeps/unix/bsd/ultrix4/mips/__handler.S
new file mode 100644
index 000000000..2b815c46d
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/mips/__handler.S
@@ -0,0 +1,115 @@
+/* Copyright (C) 1992, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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
+ .end __handler
diff --git a/ports/sysdeps/unix/bsd/ultrix4/mips/bits/sigcontext.h b/ports/sysdeps/unix/bsd/ultrix4/mips/bits/sigcontext.h
new file mode 100644
index 000000000..367465137
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/mips/bits/sigcontext.h
@@ -0,0 +1,63 @@
+/* Copyright (C) 1992, 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SIGNAL_H
+# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
+#endif
+
+/* 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/ports/sysdeps/unix/bsd/ultrix4/mips/sigvec.c b/ports/sysdeps/unix/bsd/ultrix4/mips/sigvec.c
new file mode 100644
index 000000000..5775c9adb
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/mips/sigvec.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1992, 1996, 1997, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 <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 *);
+
+extern int __raw_sigvec (int sig, CONST struct sigvec *vec,
+ struct sigvec *ovec,
+ void (*)(int sig, int code,
+ struct sigcontext *,
+ handler_type));
+
+extern void __handler (int sig, int code,
+ struct sigcontext *,
+ handler_type);
+
+int
+__sigvec (sig, vec, ovec)
+ int sig;
+ const struct sigvec *vec;
+ struct sigvec *ovec;
+{
+ return __raw_sigvec (sig, vec, ovec, __handler);
+}
diff --git a/ports/sysdeps/unix/bsd/ultrix4/mips/start.S b/ports/sysdeps/unix/bsd/ultrix4/mips/start.S
new file mode 100644
index 000000000..a88268af4
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/mips/start.S
@@ -0,0 +1,87 @@
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+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
+ .end __start
diff --git a/ports/sysdeps/unix/bsd/ultrix4/mips/syscalls.list b/ports/sysdeps/unix/bsd/ultrix4/mips/syscalls.list
new file mode 100644
index 000000000..f7d0bba6a
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/mips/syscalls.list
@@ -0,0 +1,3 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+raw-sigvec sigvec sigvec 4 __raw_sigvec
diff --git a/ports/sysdeps/unix/bsd/ultrix4/mips/sysdep.h b/ports/sysdeps/unix/bsd/ultrix4/mips/sysdep.h
new file mode 100644
index 000000000..09b69ff85
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/mips/sysdep.h
@@ -0,0 +1,3 @@
+#define NO_UNDERSCORES
+
+#include <sysdeps/unix/mips/sysdep.h>
diff --git a/ports/sysdeps/unix/bsd/ultrix4/mips/vfork.S b/ports/sysdeps/unix/bsd/ultrix4/mips/vfork.S
new file mode 100644
index 000000000..d413e45dc
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/mips/vfork.S
@@ -0,0 +1,36 @@
+/* Copyright (C) 1992, 1995, 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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
+ .end __vfork
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/ports/sysdeps/unix/bsd/ultrix4/syscalls.list b/ports/sysdeps/unix/bsd/ultrix4/syscalls.list
new file mode 100644
index 000000000..68df0a766
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/syscalls.list
@@ -0,0 +1,3 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+getsysinfo sysconf getsysinfo 5 __getsysinfo
diff --git a/ports/sysdeps/unix/bsd/ultrix4/sysconf.c b/ports/sysdeps/unix/bsd/ultrix4/sysconf.c
new file mode 100644
index 000000000..0982fc832
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/sysconf.c
@@ -0,0 +1,61 @@
+/* Copyright (C) 1992, 1995, 1996, 1997, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 <unistd.h>
+#include <errno.h>
+
+/* This is an Ultrix header file. */
+#include <sys/sysinfo.h>
+
+extern int __getsysinfo (unsigned int op, void *buffer,
+ size_t nbytes, int *start, void *arg);
+extern long int __default_sysconf (int name);
+
+long int
+__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)
+ {
+ __set_errno (save);
+ return ret;
+ }
+
+ __set_errno (save);
+ }
+
+ return __default_sysconf (name);
+}
+
+#define __sysconf __default_sysconf
+
+#include <sysdeps/posix/sysconf.c>
diff --git a/ports/sysdeps/unix/bsd/ultrix4/system.c b/ports/sysdeps/unix/bsd/ultrix4/system.c
new file mode 100644
index 000000000..b133fe77c
--- /dev/null
+++ b/ports/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/ports/sysdeps/unix/bsd/ultrix4/wait3.S b/ports/sysdeps/unix/bsd/ultrix4/wait3.S
new file mode 100644
index 000000000..b20ecfa24
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/ultrix4/wait3.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1992, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+SYSCALL__ (wait3, 3)
+ ret
+ .end __wait3
+
+weak_alias (__wait3, wait3)
diff --git a/ports/sysdeps/unix/bsd/vax/brk.S b/ports/sysdeps/unix/bsd/vax/brk.S
new file mode 100644
index 000000000..52377bc43
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/vax/brk.S
@@ -0,0 +1,47 @@
+/* Copyright (C) 1991, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/vax/dl-brk.S b/ports/sysdeps/unix/bsd/vax/dl-brk.S
new file mode 100644
index 000000000..eeb96544e
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/vax/dl-brk.S
@@ -0,0 +1 @@
+#include <brk.S>
diff --git a/ports/sysdeps/unix/bsd/vax/pipe.S b/ports/sysdeps/unix/bsd/vax/pipe.S
new file mode 100644
index 000000000..3ed784264
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/vax/pipe.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 1991, 1992, 1995, 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+SYSCALL__ (pipe, 1)
+ movl 4(ap), r2
+ movl r0, (r2)+
+ movl r1, (r2)
+ clrl r0
+ ret
+
+libc_hidden_def (__pipe)
+weak_alias (__pipe, pipe)
diff --git a/ports/sysdeps/unix/bsd/vax/sysdep.S b/ports/sysdeps/unix/bsd/vax/sysdep.S
new file mode 100644
index 000000000..786aed2d1
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/vax/sysdep.S
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define _ERRNO_H
+#include <bits/errno.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/ports/sysdeps/unix/bsd/vax/sysdep.h b/ports/sysdeps/unix/bsd/vax/sysdep.h
new file mode 100644
index 000000000..563ad26c1
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/vax/sysdep.h
@@ -0,0 +1,55 @@
+/* Copyright (C) 1991, 1992, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/vax/vfork.S b/ports/sysdeps/unix/bsd/vax/vfork.S
new file mode 100644
index 000000000..6c7e754ac
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/vax/vfork.S
@@ -0,0 +1,57 @@
+/* Copyright (C) 1991, 1992, 1995, 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#ifndef SYS_vfork
+#define SYS_vfork 66
+#endif
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+.globl ___vfork
+___vfork:
+ .word 0
+ /* Save our return address in R2, and return to code below. */
+ movl 16(fp), r2
+ movab unwind, 16(fp)
+ ret
+unwind:
+ /* Do the system call. */
+ chmk $SYS_vfork
+ bcs error
+
+ tstl r1
+ beq parent
+
+ /* We are the child. Return zero. */
+ clrl r0
+
+ /* Return to the saved address. */
+parent: jmp (r2)
+
+.globl _errno
+error:
+ movl r0, _errno
+ mnegl $1, r0
+ jmp (r2)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/ports/sysdeps/unix/bsd/vax/wait.S b/ports/sysdeps/unix/bsd/vax/wait.S
new file mode 100644
index 000000000..19396f06e
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/vax/wait.S
@@ -0,0 +1,27 @@
+/* Copyright (C) 1991, 1992, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/bsd/vax/wait3.S b/ports/sysdeps/unix/bsd/vax/wait3.S
new file mode 100644
index 000000000..e0ceec1de
--- /dev/null
+++ b/ports/sysdeps/unix/bsd/vax/wait3.S
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991, 1992, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/mips/brk.S b/ports/sysdeps/unix/mips/brk.S
new file mode 100644
index 000000000..a35b8b911
--- /dev/null
+++ b/ports/sysdeps/unix/mips/brk.S
@@ -0,0 +1,48 @@
+/* Copyright (C) 1992, 1995, 1997, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <sys/asm.h>
+
+#ifndef SYS_brk
+#define SYS_brk 17
+#endif
+
+#ifndef HAVE_GNU_LD
+#define _end end
+#endif
+
+ .data
+ENTRY(__curbrk)
+ .word 0
+ .end __curbrk
+
+ .text
+SYSCALL__(brk, 1)
+ .set reorder
+ /* Handle the query case. */
+ bnez a0, 1f
+ move a0, v0
+1: /* Update __curbrk and exit cleanly. */
+ PTR_S a0, __curbrk
+ move v0, zero
+ jr ra
+PSEUDO_END(__brk)
+
+weak_alias (__brk, brk)
diff --git a/ports/sysdeps/unix/mips/dl-brk.S b/ports/sysdeps/unix/mips/dl-brk.S
new file mode 100644
index 000000000..eeb96544e
--- /dev/null
+++ b/ports/sysdeps/unix/mips/dl-brk.S
@@ -0,0 +1 @@
+#include <brk.S>
diff --git a/ports/sysdeps/unix/mips/fork.S b/ports/sysdeps/unix/mips/fork.S
new file mode 100644
index 000000000..a7848acb6
--- /dev/null
+++ b/ports/sysdeps/unix/mips/fork.S
@@ -0,0 +1,32 @@
+/* Copyright (C) 1992, 1995, 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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
+PSEUDO_END(__fork)
+
+libc_hidden_def (__fork)
+weak_alias (__fork, fork)
diff --git a/ports/sysdeps/unix/mips/mips32/sysdep.h b/ports/sysdeps/unix/mips/mips32/sysdep.h
new file mode 100644
index 000000000..0b5d1186b
--- /dev/null
+++ b/ports/sysdeps/unix/mips/mips32/sysdep.h
@@ -0,0 +1,52 @@
+/* Copyright (C) 1992, 1995, 1997, 1999, 2000, 2002, 2003
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdeps/unix/mips/sysdep.h>
+
+/* 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. */
+#ifdef __PIC__
+#define PSEUDO(name, syscall_name, args) \
+ .align 2; \
+ 99: la t9,__syscall_error; \
+ jr t9; \
+ ENTRY(name) \
+ .set noreorder; \
+ .cpload t9; \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, 99b; \
+L(syse1):
+#else
+#define PSEUDO(name, syscall_name, args) \
+ .set noreorder; \
+ .align 2; \
+ 99: j __syscall_error; \
+ nop; \
+ ENTRY(name) \
+ .set noreorder; \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, 99b; \
+L(syse1):
+#endif
diff --git a/ports/sysdeps/unix/mips/mips64/n32/sysdep.h b/ports/sysdeps/unix/mips/mips64/n32/sysdep.h
new file mode 100644
index 000000000..ec93fadc0
--- /dev/null
+++ b/ports/sysdeps/unix/mips/mips64/n32/sysdep.h
@@ -0,0 +1,57 @@
+/* Copyright (C) 1992, 1995, 1997, 1999, 2000, 2002, 2003
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdeps/unix/mips/sysdep.h>
+
+#ifdef __ASSEMBLER__
+
+/* 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. */
+#ifdef __PIC__
+#define PSEUDO(name, syscall_name, args) \
+ .align 2; \
+ 99:; \
+ .set noat; \
+ .cpsetup t9, $1, name; \
+ .set at; \
+ la t9,__syscall_error; \
+ .cpreturn; \
+ jr t9; \
+ ENTRY(name) \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ bne a3, zero, 99b; \
+L(syse1):
+#else
+#define PSEUDO(name, syscall_name, args) \
+ .set noreorder; \
+ .align 2; \
+ 99: j __syscall_error; \
+ ENTRY(name) \
+ .set noreorder; \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, 99b; \
+L(syse1):
+#endif
+
+#endif
diff --git a/ports/sysdeps/unix/mips/mips64/n64/sysdep.h b/ports/sysdeps/unix/mips/mips64/n64/sysdep.h
new file mode 100644
index 000000000..502b66797
--- /dev/null
+++ b/ports/sysdeps/unix/mips/mips64/n64/sysdep.h
@@ -0,0 +1,57 @@
+/* Copyright (C) 1992, 1995, 1997, 1999, 2000, 2002, 2003
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdeps/unix/mips/sysdep.h>
+
+#ifdef __ASSEMBLER__
+
+/* 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. */
+#ifdef __PIC__
+#define PSEUDO(name, syscall_name, args) \
+ .align 2; \
+ 99:; \
+ .set noat; \
+ .cpsetup t9, $1, name; \
+ .set at; \
+ dla t9,__syscall_error; \
+ .cpreturn; \
+ jr t9; \
+ ENTRY(name) \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ bne a3, zero, 99b; \
+L(syse1):
+#else
+#define PSEUDO(name, syscall_name, args) \
+ .set noreorder; \
+ .align 2; \
+ 99: j __syscall_error; \
+ ENTRY(name) \
+ .set noreorder; \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, 99b; \
+L(syse1):
+#endif
+
+#endif
diff --git a/ports/sysdeps/unix/mips/pipe.S b/ports/sysdeps/unix/mips/pipe.S
new file mode 100644
index 000000000..ee7b76d63
--- /dev/null
+++ b/ports/sysdeps/unix/mips/pipe.S
@@ -0,0 +1,33 @@
+/* Copyright (C) 1992, 1995, 1997, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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. */
+ move v0, zero
+ j ra
+PSEUDO_END(__pipe)
+
+libc_hidden_def (__pipe)
+weak_alias (__pipe, pipe)
diff --git a/ports/sysdeps/unix/mips/rt-sysdep.S b/ports/sysdeps/unix/mips/rt-sysdep.S
new file mode 100644
index 000000000..f966bf1e5
--- /dev/null
+++ b/ports/sysdeps/unix/mips/rt-sysdep.S
@@ -0,0 +1 @@
+#include <sysdep.S>
diff --git a/ports/sysdeps/unix/mips/sigreturn.S b/ports/sysdeps/unix/mips/sigreturn.S
new file mode 100644
index 000000000..2cb3adb6d
--- /dev/null
+++ b/ports/sysdeps/unix/mips/sigreturn.S
@@ -0,0 +1,31 @@
+/* Copyright (C) 1992, 1994, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#ifndef SYS_sigreturn
+#define SYS_sigreturn 103
+#endif
+
+ENTRY(__sigreturn)
+ li v0, SYS_sigreturn
+ syscall
+ .end __sigreturn
+
+weak_alias (__sigreturn, sigreturn)
diff --git a/ports/sysdeps/unix/mips/sysdep.S b/ports/sysdeps/unix/mips/sysdep.S
new file mode 100644
index 000000000..8c172db19
--- /dev/null
+++ b/ports/sysdeps/unix/mips/sysdep.S
@@ -0,0 +1,100 @@
+/* Copyright (C) 1992, 1993, 1994, 1997, 1998, 1999, 2000, 2002, 2003
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _ERRNO_H
+#include <bits/errno.h>
+#include <sys/asm.h>
+
+#ifdef _LIBC_REENTRANT
+
+LOCALSZ= 3
+FRAMESZ= (((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
+RAOFF= FRAMESZ-(1*SZREG)
+GPOFF= FRAMESZ-(2*SZREG)
+V0OFF= FRAMESZ-(3*SZREG)
+
+ENTRY(__syscall_error)
+#ifdef __PIC__
+ .set noat
+ SETUP_GPX (AT)
+ .set at
+#endif
+ PTR_SUBU sp, FRAMESZ
+ .set noat
+ SETUP_GPX64(GPOFF,AT)
+ .set at
+#ifdef __PIC__
+ SAVE_GP(GPOFF)
+#endif
+ REG_S v0, V0OFF(sp)
+ REG_S ra, RAOFF(sp)
+
+#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, L(skip)
+ nop
+ li v0, EAGAIN
+L(skip):
+#endif
+ /* Find our per-thread errno address */
+ jal __errno_location
+
+ /* Store the error value. */
+ REG_L t0, V0OFF(sp)
+ sw t0, 0(v0)
+
+ /* And just kick back a -1. */
+ REG_L ra, RAOFF(sp)
+ RESTORE_GP64
+ PTR_ADDU sp, FRAMESZ
+ li v0, -1
+ j ra
+ END(__syscall_error)
+
+#else /* _LIBC_REENTRANT */
+
+
+ENTRY(__syscall_error)
+#ifdef __PIC__
+ SETUP_GPX (AT)
+#endif
+ SETUP_GPX64 (t9, AT)
+
+#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, L(skip)
+ li v0, EAGAIN
+L(skip):
+#endif
+ /* Store it in errno... */
+ sw v0, errno
+
+ /* And just kick back a -1. */
+ li v0, -1
+
+ RESTORE_GP64
+ j ra
+ END(__syscall_error)
+#endif /* _LIBC_REENTRANT */
diff --git a/ports/sysdeps/unix/mips/sysdep.h b/ports/sysdeps/unix/mips/sysdep.h
new file mode 100644
index 000000000..714830147
--- /dev/null
+++ b/ports/sysdeps/unix/mips/sysdep.h
@@ -0,0 +1,79 @@
+/* Copyright (C) 1992, 1995, 1997, 1999, 2000, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sgidefs.h>
+#include <sysdeps/unix/sysdep.h>
+
+#ifdef __ASSEMBLER__
+
+#include <regdef.h>
+
+#define ENTRY(name) \
+ .globl name; \
+ .align 2; \
+ .ent name,0; \
+ name##:
+
+#undef END
+#define END(function) \
+ .end function; \
+ .size function,.-function
+
+#define ret j ra ; nop
+
+#undef PSEUDO_END
+#define PSEUDO_END(sym) .end sym; .size sym,.-sym
+
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+ .align 2; \
+ ENTRY(name) \
+ .set noreorder; \
+ li v0, SYS_ify(syscall_name); \
+ syscall
+
+#undef PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(sym) .end sym; .size sym,.-sym
+
+#define ret_NOERRNO ret
+
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+ .align 2; \
+ ENTRY(name) \
+ .set noreorder; \
+ li v0, SYS_ify(syscall_name); \
+ syscall
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(sym) .end sym; .size sym,.-sym
+
+#define ret_ERRVAL ret
+
+#define r0 v0
+#define r1 v1
+/* The mips move insn is d,s. */
+#define MOVE(x,y) move y , x
+
+#if _MIPS_SIM == _ABIO32
+# define L(label) $L ## label
+#else
+# define L(label) .L ## label
+#endif
+
+#endif
diff --git a/ports/sysdeps/unix/mips/wait.S b/ports/sysdeps/unix/mips/wait.S
new file mode 100644
index 000000000..de0f6ebfa
--- /dev/null
+++ b/ports/sysdeps/unix/mips/wait.S
@@ -0,0 +1,47 @@
+/* Copyright (C) 1992, 1994, 1995, 1997, 2002, 2003
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+.set noreorder
+
+ENTRY(__wait)
+ /* Prep it for wait. */
+ move a1, zero
+ move a2, zero
+
+ li v0, SYS_wait
+ syscall
+ beqz a3, L(noerror)
+ nop
+ j __syscall_error
+ nop
+
+L(noerror):
+ /* If the arg is not NULL, store v1 there. */
+ beqz a0, L(noarg)
+ nop
+ sw v1, 0(a0)
+ nop
+L(noarg):
+ ret
+ .end __wait
+
+weak_alias (__wait, wait)
diff --git a/ports/sysdeps/unix/sysv/aix/Implies b/ports/sysdeps/unix/sysv/aix/Implies
new file mode 100644
index 000000000..279438d43
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/Implies
@@ -0,0 +1,8 @@
+# AIX shares most of the syscalls which are also common to BSD and SVR4.
+unix/common
+
+# AIX has all functions of the mmap family which are described in POSIX.4.
+unix/mman
+
+# AIX has network support in the kernel.
+unix/inet
diff --git a/ports/sysdeps/unix/sysv/aix/Makefile b/ports/sysdeps/unix/sysv/aix/Makefile
new file mode 100644
index 000000000..2da531109
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/Makefile
@@ -0,0 +1,41 @@
+# XXX For now always link against the syscalls export file.
+# This is a hack until the import/export stuff is worked out.
++postctor += /lib/syscalls.exp
+
+ifeq ($(subdir),csu)
+
+sysdep_routines += aix-syscalls
+
+#
+# The foo.c is a workaround for the linker complaining about no input files.
+$(objpfx)aix-syscalls.o : /lib/syscalls.exp
+ echo "static int a;" > foo.c
+ $(CC) -c foo.c
+ ld -bM:SRE -bpT:0x00000000 -bpD:0x00000000 -bnoentry -bI:/lib/syscalls.exp -bE:/lib/syscalls.exp foo.o -o $@
+ rm foo.c foo.o
+
+
+endif
+
+ifeq ($(subdir),misc)
+sysdep_routines += dl-error dl-support dl-libc dl-open dl-sym \
+ dl-close dl-addr uitrunc
+
+static-only-routines = gprsave0 gprrest0 gprsave1 gprrest1 fprsave fprrest
+endif
+
+ifeq ($(subdir),login)
+sysdep_routines += setutxent getutxent endutxent getutxid getutxline \
+ pututxline utmpxname
+
+#sysdep_headers += utmpx.h bits/utmpx.h
+#sysdep_headers += bits/utmp.h bits/utmpx.h
+endif
+
+# Don't compile the ctype glue code, since there is no old non-GNU C library.
+inhibit-glue = yes
+
+# XXX Don't know yet why this is needed in the moment.
+ifeq ($(subdir),timezone)
+CPPFLAGS-zic.c = -Dunix
+endif
diff --git a/ports/sysdeps/unix/sysv/aix/Versions b/ports/sysdeps/unix/sysv/aix/Versions
new file mode 100644
index 000000000..4c32bbbe7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/Versions
@@ -0,0 +1,6 @@
+libc {
+ GLIBC_2.2 {
+ # u*
+ umount;
+ }
+}
diff --git a/ports/sysdeps/unix/sysv/aix/_exit.c b/ports/sysdeps/unix/sysv/aix/_exit.c
new file mode 100644
index 000000000..510f3ae88
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/_exit.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdlib.h>
+
+
+/* We define only thr alias introduced in ISO C99 because _exit itself
+ is a system call. */
+void
+_Exit (status)
+ int status;
+{
+ _exit (status);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/accept.c b/ports/sysdeps/unix/sysv/aix/accept.c
new file mode 100644
index 000000000..73f11499f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/accept.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <sys/socket.h>
+
+extern int naccept (int s, void *uap_name, int *uap_anamelen);
+
+int
+accept (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len)
+{
+ assert (sizeof (socklen_t) == sizeof (int));
+ return naccept (fd, addr.__sockaddr__, addr_len);
+}
+libc_hidden_def (accept)
diff --git a/ports/sysdeps/unix/sysv/aix/access.c b/ports/sysdeps/unix/sysv/aix/access.c
new file mode 100644
index 000000000..97f8e6879
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/access.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+#define ACC_INVOKER 0x01
+
+extern int accessx (const char *name, int type, int who);
+
+int
+__access (const char *name, int type)
+{
+ return accessx (name, type, ACC_INVOKER);
+}
+strong_alias (__access, access)
diff --git a/ports/sysdeps/unix/sysv/aix/bind.c b/ports/sysdeps/unix/sysv/aix/bind.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bind.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/bits/dirent.h b/ports/sysdeps/unix/sysv/aix/bits/dirent.h
new file mode 100644
index 000000000..48eeb3288
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/dirent.h
@@ -0,0 +1,55 @@
+/* Directory entry structure `struct dirent'. Old System V version.
+ Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _DIRENT_H
+# error "Never use <bits/dirent.h> directly; include <dirent.h> instead."
+#endif
+
+struct dirent
+ {
+#ifndef __USE_FILE_OFFSET64
+ __off_t d_off;
+ __ino_t d_ino;
+#else
+ __off64_t d_off;
+ __ino64_t d_ino;
+#endif
+ unsigned short int d_reclen;
+ unsigned short int d_namlen;
+ char d_name[256];
+ };
+
+#ifdef __USE_LARGEFILE64
+struct dirent64
+ {
+ __off64_t d_off;
+ __ino64_t d_ino;
+ unsigned short int d_reclen;
+ unsigned short int d_namlen;
+ char d_name[256];
+ };
+#endif
+
+#define d_fileno d_ino /* Backwards compatibility. */
+#define d_offset d_off
+
+#define _DIRENT_HAVE_D_NAMLEN
+#define _DIRENT_HAVE_D_RECLEN
+#define _DIRENT_HAVE_D_OFF
+#undef _DIRENT_HAVE_D_TYPE
diff --git a/ports/sysdeps/unix/sysv/aix/bits/dlfcn.h b/ports/sysdeps/unix/sysv/aix/bits/dlfcn.h
new file mode 100644
index 000000000..e18417527
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/dlfcn.h
@@ -0,0 +1,47 @@
+/* AIX dependent definitions for run-time dynamic loading.
+ Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _DLFCN_H
+# error "Never use <bits/dlfcn.h> directly; include <dlfcn.h> instead."
+#endif
+
+/* The MODE argument to `dlopen' contains one of the following: */
+#define RTLD_LAZY 0x004 /* Lazy function call binding. */
+#define RTLD_NOW 0x002 /* Immediate function call binding. */
+#define RTLD_BINDING_MASK 0x6 /* Mask of binding time value. */
+
+/* If the following bit is set in the MODE argument to `dlopen',
+ the symbols of the loaded object and its dependencies are made
+ visible as if the object were linked directly into the program. */
+#define RTLD_GLOBAL 0x10000
+
+/* Unix98 demands the following flag which is the inverse to RTLD_GLOBAL.
+ The implementation does this by default and so we can define the
+ value to zero. */
+#define RTLD_LOCAL 0x800000
+
+#ifdef __USE_GNU
+/* These are extensions of the AIX kernel. */
+# define RTLD_NOAUTODEFER 0x020000
+# define RTLD_MEMBER 0x040000
+# define RTLD_UNIX_LATEST 0x100000
+#endif
+
+/* No support to profile shared libraries available. */
+# define DL_CALL_FCT(fctp, args) fctp args
diff --git a/ports/sysdeps/unix/sysv/aix/bits/endian.h b/ports/sysdeps/unix/sysv/aix/bits/endian.h
new file mode 100644
index 000000000..8e9b98ef7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/endian.h
@@ -0,0 +1,23 @@
+/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#define __BYTE_ORDER __BIG_ENDIAN
diff --git a/ports/sysdeps/unix/sysv/aix/bits/errno.h b/ports/sysdeps/unix/sysv/aix/bits/errno.h
new file mode 100644
index 000000000..9f22a965e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/errno.h
@@ -0,0 +1,153 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file defines the `errno' constants. */
+
+#if !defined __Emath_defined && (defined _ERRNO_H || defined __need_Emath)
+#undef __need_Emath
+#define __Emath_defined 1
+
+#endif
+
+#ifdef _ERRNO_H
+# undef EDOM
+# undef EILSEQ
+# undef ERANGE
+
+# 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 /* I/O error. */
+# define ENXIO 6 /* No such device or address. */
+# define E2BIG 7 /* Arg list too long. */
+# define ENOEXEC 8 /* Exec format error. */
+# define EBADF 9 /* Bad file descriptor. */
+# define ECHILD 10 /* No child processes. */
+# define EAGAIN 11 /* Resource temporarily unavailable. */
+# define ENOMEM 12 /* Not enough space. */
+# define EACCES 13 /* Permission denied. */
+# define EFAULT 14 /* Bad address. */
+# define ENOTBLK 15 /* Block device required. */
+# define EBUSY 16 /* Resource busy. */
+# define EEXIST 17 /* File exists. */
+# define EXDEV 18 /* Improper link. */
+# define ENODEV 19 /* No such 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 I/O control operation. */
+# define ETXTBSY 26 /* Text file busy. */
+# define EFBIG 27 /* File too large. */
+# define ENOSPC 28 /* No space left on device. */
+# define ESPIPE 29 /* Invalid seek. */
+# define EROFS 30 /* Read only file system. */
+# define EMLINK 31 /* Too many links. */
+# define EPIPE 32 /* Broken pipe. */
+# define EDOM 33 /* Domain error within math function. */
+# define ERANGE 34 /* Result too large. */
+# define ENOMSG 35 /* No message of desired type. */
+# define EIDRM 36 /* Identifier removed. */
+# define ECHRNG 37 /* Channel number out of range. */
+# define EL2NSYNC 38 /* Level 2 not synchronized. */
+# define EL3HLT 39 /* Level 3 halted. */
+# define EL3RST 40 /* Level 3 reset. */
+# define ELNRNG 41 /* Link number out of range. */
+# define EUNATCH 42 /* Protocol driver not attached. */
+# define ENOCSI 43 /* No CSI structure available. */
+# define EL2HLT 44 /* Level 2 halted. */
+# define EDEADLK 45 /* Resource deadlock avoided. */
+# define ENOTREADY 46 /* Device not ready. */
+# define EWRPROTECT 47 /* Write-protected media. */
+# define EFORMAT 48 /* Unformatted media. */
+# define ENOLCK 49 /* No locks available. */
+# define ENOCONNECT 50 /* No connection. */
+# define ESTALE 52 /* No filesystem. */
+# define EDIST 53 /* Old, currently unused AIX errno. */
+# if __USE_XOPEN_EXTENDED
+# define EWOULDBLOCK EAGAIN /* Operation would block. */
+# else /* __USE_XOPEN_EXTENDED */
+# define EWOULDBLOCK 54
+# endif /* __USE_XOPEN_EXTENDED */
+# define EINPROGRESS 55 /* Operation now in progress. */
+# define EALREADY 56 /* Operation already in progress. */
+# define ENOTSOCK 57 /* Socket operation on non-socket. */
+# define EDESTADDRREQ 58 /* Destination address required. */
+# define EDESTADDREQ EDESTADDRREQ /* Destination address required. */
+# define EMSGSIZE 59 /* Message too long. */
+# define EPROTOTYPE 60 /* Protocol wrong type for socket. */
+# define ENOPROTOOPT 61 /* Protocol not available. */
+# define EPROTONOSUPPORT 62 /* Protocol not supported. */
+# define ESOCKTNOSUPPORT 63 /* Socket type not supported. */
+# define EOPNOTSUPP 64 /* Operation not supported on socket. */
+# define EPFNOSUPPORT 65 /* Protocol family not supported. */
+# define EAFNOSUPPORT 66 /* Address family not supported by protocol
+ family. */
+# define EADDRINUSE 67 /* Address already in use. */
+# define EADDRNOTAVAIL 68 /* Can't assign requested address. */
+# define ENETDOWN 69 /* Network is down. */
+# define ENETUNREACH 70 /* Network is unreachable. */
+# define ENETRESET 71 /* Network dropped connection on reset. */
+# define ECONNABORTED 72 /* Software caused connection abort. */
+# define ECONNRESET 73 /* Connection reset by peer. */
+# define ENOBUFS 74 /* No buffer space available. */
+# define EISCONN 75 /* Socket is already connected. */
+# define ENOTCONN 76 /* Socket is not connected. */
+# define ESHUTDOWN 77 /* Can't send after socket shutdown. */
+# define ETIMEDOUT 78 /* Connection timed out. */
+# define ECONNREFUSED 79 /* Connection refused. */
+# define EHOSTDOWN 80 /* Host is down. */
+# define EHOSTUNREACH 81 /* No route to host. */
+# define ERESTART 82 /* Restart the system call. */
+# define EPROCLIM 83 /* Too many processes. */
+# define EUSERS 84 /* Too many users. */
+# define ELOOP 85 /* Too many levels of symbolic links. */
+# define ENAMETOOLONG 86 /* File name too long. */
+# define ENOTEMPTY EEXIST /* Directory not empty. */
+# define EDQUOT 88 /* Disc quota exceeded. */
+# define ECORRUPT 89 /* Invalid file system control data. */
+# define EREMOTE 93 /* Item is not local to host. */
+# define ENOSYS 109 /* Function not implemented POSIX. */
+# define EMEDIA 110 /* Media surface error. */
+# define ESOFT 111 /* I/O completed, but needs relocation. */
+# define ENOATTR 112 /* No attribute found. */
+# define ESAD 113 /* Security authentication denied. */
+# define ENOTRUST 114 /* Not a trusted program. */
+# define ETOOMANYREFS 115 /* Too many references: can't splice. */
+# define EILSEQ 116 /* Invalid wide character. */
+# define ECANCELED 117 /* Asynchronous i/o cancelled. */
+# define ENOSR 118 /* Temp out of streams resources. */
+# define ETIME 119 /* I_STR ioctl timed out. */
+# define EBADMSG 120 /* Wrong message type at stream head. */
+# define EPROTO 121 /* STREAMS protocol error. */
+# define ENODATA 122 /* No message ready at stream head. */
+# define ENOSTR 123 /* Fd is not a stream. */
+# define ECLONEME ERESTART /* This is the way we clone a stream. */
+# define ENOTSUP 124 /* POSIX threads unsupported value. */
+# define EMULTIHOP 125 /* Multihop is not allowed. */
+# define ENOLINK 126 /* The link has been severed. */
+# define EOVERFLOW 127 /* Value too large to be stored in data type.*/
+#endif
+
+#if !defined _ERRNO_H && defined __need_Emath
+# define EDOM 33 /* Math argument out of domain of function. */
+# define EILSEQ 116 /* Illegal byte sequence. */
+# define ERANGE 34 /* Math result not representable. */
+#endif /* !_ERRNO_H && __need_Emath */
diff --git a/ports/sysdeps/unix/sysv/aix/bits/fcntl.h b/ports/sysdeps/unix/sysv/aix/bits/fcntl.h
new file mode 100644
index 000000000..c65b8beeb
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/fcntl.h
@@ -0,0 +1,137 @@
+/* O_*, F_*, FD_* bit values for Linux.
+ Copyright (C) 1995-1999, 2000, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+
+#include <sys/types.h>
+
+/* open/fcntl. */
+#define O_ACCMODE 0003
+#define O_RDONLY 00
+#define O_WRONLY 01
+#define O_RDWR 02
+#define O_NONBLOCK 04
+#define O_NDELAY O_NONBLOCK
+#define O_APPEND 010
+#define O_SYNC 020
+#define O_FSYNC O_SYNC
+#define O_CREAT 0400 /* not fcntl */
+#define O_TRUNC 01000 /* not fcntl */
+#define O_EXCL 02000 /* not fcntl */
+#define O_NOCTTY 04000 /* not fcntl */
+#define O_ASYNC 0400000
+
+#ifdef __USE_LARGEFILE64
+# define O_LARGEFILE 0400000000
+#endif
+
+/* For now Linux has synchronisity options for data and read operations.
+ We define the symbols here but let them do the same as O_SYNC since
+ this is a superset. */
+#if defined __USE_POSIX199309 || defined __USE_UNIX98
+# define O_DSYNC 020000000 /* Synchronize data. */
+# define O_RSYNC 010000000 /* Synchronize read operations. */
+#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. */
+#ifndef __USE_FILE_OFFSET64
+# define F_GETLK 5 /* Get record locking info. */
+# define F_SETLK 6 /* Set record locking info (non-blocking). */
+# define F_SETLKW 7 /* Set record locking info (blocking). */
+#else
+# define F_GETLK 11 /* Get record locking info. */
+# define F_SETLK 12 /* Set record locking info (non-blocking). */
+# define F_SETLKW 13 /* Set record locking info (blocking). */
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define F_GETLK64 11 /* Get record locking info. */
+# define F_SETLK64 12 /* Set record locking info (non-blocking). */
+# define F_SETLKW64 13 /* Set record locking info (blocking). */
+#endif
+
+#if defined __USE_BSD || defined __USE_UNIX98
+# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */
+# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */
+#endif
+
+/* For F_[GET|SET]FL. */
+#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
+
+/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
+#define F_RDLCK 1 /* Read lock. */
+#define F_WRLCK 2 /* Write lock. */
+#define F_UNLCK 3 /* Remove lock. */
+
+#ifdef __USE_BSD
+/* Operations for bsd flock(), also used by the kernel implementation */
+# define LOCK_SH 1 /* shared lock */
+# define LOCK_EX 2 /* exclusive lock */
+# define LOCK_NB 4 /* or'd with one of the above to prevent
+ blocking */
+# define LOCK_UN 8 /* remove lock */
+#endif
+
+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'). */
+#ifndef __USE_FILE_OFFSET64
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+#endif
+ unsigned int l_sysid;
+ __pid_t l_pid; /* Process holding the lock. */
+ int l_vfs;
+#ifdef __USE_FILE_OFFSET64
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+#endif
+ };
+
+#ifdef __USE_LARGEFILE64
+struct flock64
+ {
+ 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'). */
+ unsigned int l_sysid;
+ __pid_t l_pid; /* Process holding the lock. */
+ int l_vfs;
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+ };
+#endif
+
+/* Define some more compatibility macros to be backward compatible with
+ BSD systems which did not managed to hide these kernel macros. */
+#ifdef __USE_BSD
+# define FAPPEND O_APPEND
+# define FFSYNC O_FSYNC
+# define FASYNC O_ASYNC
+# define FNONBLOCK O_NONBLOCK
+# define FNDELAY O_NDELAY
+#endif /* Use BSD. */
diff --git a/ports/sysdeps/unix/sysv/aix/bits/ioctl-types.h b/ports/sysdeps/unix/sysv/aix/bits/ioctl-types.h
new file mode 100644
index 000000000..d8fe8c8d5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/ioctl-types.h
@@ -0,0 +1,91 @@
+/* Structure types for pre-termios terminal ioctls. AIX version.
+ Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_IOCTL_H
+# error "Never use <bits/ioctl-types.h> directly; include <sys/ioctl.h> instead."
+#endif
+
+/* Constants for use with `ioctl'. */
+#define TIOC ('T' << 8)
+#define TCGETS (TIOC | 1)
+#define TCSETS (TIOC | 2)
+#define TCSETSW (TIOC | 3)
+#define TCSETSF (TIOC | 4)
+#define TCGETA (TIOC | 5)
+#define TCSETA (TIOC | 6)
+#define TCSETAW (TIOC | 7)
+#define TCSETAF (TIOC | 8)
+#define TCSBRK (TIOC | 9)
+#define TCSBREAK (TIOC | 10)
+#define TCXONC (TIOC | 11)
+#define TCFLSH (TIOC | 12)
+#define TCGLEN (TIOC | 13)
+#define TCSLEN (TIOC | 14)
+#define TCSAK (TIOC | 15)
+#define TCQSAK (TIOC | 16)
+#define TCTRUST (TIOC | 17)
+#define TCQTRUST (TIOC | 18)
+#define TCSMAP (TIOC | 19)
+#define TCGMAP (TIOC | 20)
+#define TCKEP (TIOC | 21)
+#define TCGSAK (TIOC | 22)
+#define TCLOOP (TIOC | 23)
+#define TCVPD (TIOC | 24)
+#define TCREG (TIOC | 25)
+#define TCGSTATUS (TIOC | 26)
+#define TCSCONTROL (TIOC | 27)
+#define TCSCSMAP (TIOC | 28)
+#define TCGCSMAP (TIOC | 29)
+#define TCMGR TCSAK
+#define TCQMGR TCQSAK
+#define TIONREAD FIONREAD
+
+
+
+struct winsize
+{
+ unsigned short int ws_row;
+ unsigned short int ws_col;
+ unsigned short int ws_xpixel;
+ unsigned short int ws_ypixel;
+};
+
+#define NCC 8
+struct termio
+{
+ unsigned short int c_iflag; /* input mode flags */
+ unsigned short int c_oflag; /* output mode flags */
+ unsigned short int c_cflag; /* control mode flags */
+ unsigned short int c_lflag; /* local mode flags */
+ char c_line; /* line discipline */
+ unsigned char c_cc[NCC]; /* control characters */
+};
+
+/* modem lines */
+#define TIOCM_LE 0x001
+#define TIOCM_DTR 0x002
+#define TIOCM_RTS 0x004
+#define TIOCM_ST 0x008
+#define TIOCM_SR 0x010
+#define TIOCM_CTS 0x020
+#define TIOCM_CAR 0x040
+#define TIOCM_RNG 0x080
+#define TIOCM_DSR 0x100
+#define TIOCM_CD TIOCM_CAR
+#define TIOCM_RI TIOCM_RNG
diff --git a/ports/sysdeps/unix/sysv/aix/bits/ioctls.h b/ports/sysdeps/unix/sysv/aix/bits/ioctls.h
new file mode 100644
index 000000000..8023c144d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/ioctls.h
@@ -0,0 +1,248 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_IOCTL_H
+# error "Never use <bits/ioctls.h> directly; include <sys/ioctl.h> instead."
+#endif
+
+
+#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
+#define IOC_VOID 0x20000000 /* no parameters */
+#define IOC_OUT 0x40000000 /* copy out parameters */
+#define IOC_IN (0x40000000<<1) /* copy in parameters */
+#define IOC_INOUT (IOC_IN|IOC_OUT)
+#define _IO(x,y) (IOC_VOID|(x<<8)|y)
+#define _IOR(x,y,t) (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
+#define _IOW(x,y,t) (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
+#define _IOWR(x,y,t) (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
+
+#define TIOCGETD _IOR('t', 0, int) /* get line discipline */
+#define TIOCSETD _IOW('t', 1, int) /* set line discipline */
+#define TIOCHPCL _IO('t', 2) /* hang up on last close */
+#define TIOCMODG _IOR('t', 3, int) /* get modem control state */
+#define TIOCMODS _IOW('t', 4, int) /* set modem control state */
+#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 TIOCEXCL _IO('t', 13) /* set exclusive use of tty */
+#define TIOCNXCL _IO('t', 14) /* reset exclusive use of tty */
+#define TIOCFLUSH _IOW('t', 16, int) /* flush buffers */
+#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 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 CRDELAY 0x00000300 /* \r delay */
+#define TBDELAY 0x00000c00 /* horizontal tab delay */
+#define XTABS 0x00000c00 /* expand tabs on output */
+#define BSDELAY 0x00001000 /* \b delay */
+#define VTDELAY 0x00002000 /* vertical tab delay */
+#define NLDELAY 0x0000c000 /* \n delay */
+#define NL2 0x00008000 /* vt05 */
+#define NL3 0x0000c000
+#define ALLDELAY (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)
+#define PRTERA 0x00020000 /* \ ... / erase */
+#define CRTERA 0x00040000 /* " \b " to wipe out char */
+#define TILDE 0x00080000 /* hazeltine tilde kludge */
+#define LITOUT 0x00200000 /* literal output */
+#define CRTBS 0x00400000 /* do backspacing for crt */
+#define MDMBUF 0x00800000 /* dtr pacing */
+#define NOHANG 0x01000000 /* 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 DECCTQ 0x40000000 /* only ^Q starts after ^S */
+#define NOFLUSH 0x80000000 /* no output flush on signal */
+
+
+/* SYS V REL. 4 PTY IOCTLs */
+#define UNLKPT _IO('t',70) /* unlock slave pty */
+#define ISPTM _IO('t',71) /* ret. maj+min of pty master */
+#define ISPTS _IO('t',73) /* return maj+min of slave */
+#define GRTPT _IO('t',74) /* grantpt slave pty*/
+#define RLOGIND _IO('t',75) /* for rlogind protocol in ptydd */
+#define TELNETDP _IO('t',76) /* for telnetd protocol in ptydd */
+
+#define TIOCCONS _IOW('t', 98, int) /* become virtual console */
+#define TIOCGSID _IOR('t', 72, int) /* get the tty session id */
+
+ /* locals, from 127 down */
+#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 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 (NOFLUSH>>16)
+#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 process group */
+#define TIOCSPGRP _IOW('t', 118, int) /* set process gorup */
+#define TIOCSLTC _IOW('t',117,struct ltchars)/* set local special chars */
+#define TIOCGLTC _IOR('t',116,struct ltchars)/* get local special chars */
+#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 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 */
+/* SLIP (Serial Line IP) ioctl's */
+#define SLIOCGUNIT _IOR('t', 101, int) /* get slip unit number */
+#define SLIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */
+#define SLIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */
+#define SLIOCSATTACH _IOWR('t', 91, int) /* Attach slip i.f. to tty */
+#define UIOCCMD(n) _IO('u', n) /* usr cntl op "n" */
+
+#define OTTYDISC 0 /* old, v7 std tty driver */
+#define NETLDISC 1 /* line discip for berk net */
+#define NTTYDISC 2 /* new tty discipline */
+#define TABLDISC 3 /* tablet discipline */
+#define SLIPDISC 4 /* serial IP discipline */
+
+#define FIOCLEX _IO('f', 1) /* set close on exec */
+#define FIONCLEX _IO('f', 2) /* clear close on exec */
+/* another local */
+
+#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 */
+#define FIOASYNCQX _IOW('f', 122, int) /* set/clear async queueing */
+
+/* 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 (int)_IOW('r', 10, struct ortentry) /* add route */
+#define SIOCDELRT (int)_IOW('r', 11, struct ortentry) /* delete route */
+
+#define SIOCSIFADDR (int)_IOW('i', 12, struct oifreq) /* set ifnet address */
+#define OSIOCGIFADDR (int)_IOWR('i',13, struct oifreq) /* get ifnet address */
+#define SIOCGIFADDR (int)_IOWR('i',33, struct oifreq) /* get ifnet address */
+#define SIOCSIFDSTADDR (int)_IOW('i', 14, struct oifreq) /* set p-p address */
+#define OSIOCGIFDSTADDR (int)_IOWR('i',15, struct oifreq) /* get p-p address */
+#define SIOCGIFDSTADDR (int)_IOWR('i',34, struct oifreq) /* get p-p address */
+#define SIOCSIFFLAGS (int)_IOW('i', 16, struct oifreq) /* set ifnet flags */
+#define SIOCGIFFLAGS (int)_IOWR('i',17, struct oifreq) /* get ifnet flags */
+#define OSIOCGIFBRDADDR (int)_IOWR('i',18, struct oifreq) /* get broadcast addr */
+#define SIOCGIFBRDADDR (int)_IOWR('i',35, struct oifreq) /* get broadcast addr */
+#define SIOCSIFBRDADDR (int)_IOW('i',19, struct oifreq) /* set broadcast addr */
+#define OSIOCGIFCONF (int)_IOWR('i',20, struct ifconf) /* get ifnet list */
+#define CSIOCGIFCONF (int)_IOWR('i',36, struct ifconf) /* get ifnet list */
+#define SIOCGIFCONF (int)_IOWR('i',69, struct ifconf) /* get ifnet list */
+#define OSIOCGIFNETMASK (int)_IOWR('i',21, struct oifreq) /* get net addr mask */
+#define SIOCGIFNETMASK (int)_IOWR('i',37, struct oifreq) /* get net addr mask */
+#define SIOCSIFNETMASK (int)_IOW('i',22, struct oifreq) /* set net addr mask */
+#define SIOCGIFMETRIC (int)_IOWR('i',23, struct oifreq) /* get IF metric */
+#define SIOCSIFMETRIC (int)_IOW('i',24, struct oifreq) /* set IF metric */
+#define SIOCDIFADDR (int)_IOW('i',25, struct oifreq) /* delete IF addr */
+#define SIOCAIFADDR (int)_IOW('i',26, struct ifaliasreq) /* add/chg IF alias */
+#define SIOCSIFSUBCHAN (int)_IOW('i',27, struct oifreq) /* set subchannel adr.*/
+#define SIOCSIFNETDUMP (int)_IOW('i',28, struct oifreq) /* set netdump fastwrt*/
+
+#define SIOCSARP (int)_IOW('i', 30, struct arpreq) /* set arp entry */
+#define OSIOCGARP (int)_IOWR('i',31, struct arpreq) /* get arp entry */
+#define SIOCGARP (int)_IOWR('i',38, struct arpreq) /* get arp entry */
+#define SIOCDARP (int)_IOW('i', 32, struct arpreq) /* delete arp entry */
+
+#define SIOCSIFOPTIONS (int)_IOW('i', 41, struct oifreq) /* set ifnet options */
+#define SIOCGIFOPTIONS (int)_IOWR('i',42, struct oifreq) /* get ifnet options */
+#define SIOCADDMULTI (int)_IOW('i', 49, struct ifreq) /* add multicast addr */
+#define SIOCDELMULTI (int)_IOW('i', 50, struct ifreq) /* del multicast addr */
+#define SIOCGETVIFCNT (int)_IOWR('u', 51, struct sioc_vif_req)/* vif pkt cnt */
+#define SIOCGETSGCNT (int)_IOWR('u', 52, struct sioc_sg_req) /* s,g pkt cnt */
+
+#define SIOCADDNETID (int)_IOW('i',87, struct oifreq) /* set netids */
+#define SIOCSIFMTU (int)_IOW('i',88, struct oifreq) /* set mtu */
+#define SIOCGIFMTU (int)_IOWR('i',86, struct oifreq) /* get mtu */
+
+#define SIOCSNETOPT (int)_IOW('i', 90, struct optreq) /* set network option */
+#define SIOCGNETOPT (int)_IOWR('i', 91, struct optreq) /* get network option */
+#define SIOCDNETOPT (int)_IOWR('i', 92, struct optreq) /* set default */
+
+#define SIOCSX25XLATE (int)_IOW('i', 99, struct oifreq) /* set xlate tab */
+#define SIOCGX25XLATE (int)_IOWR('i',100, struct oifreq) /* get xlate tab */
+#define SIOCDX25XLATE (int)_IOW('i', 101, struct oifreq) /* delete xlate tab */
+
+#define SIOCIFDETACH (int)_IOW('i', 102, struct ifreq) /* detach an ifnet */
+#define SIOCIFATTACH (int)_IOW('i', 103, struct ifreq) /* attach an ifnet */
+
+#define SIOCGNMTUS (int)_IO('i',110) /* get NMTUs */
+#define SIOCGETMTUS (int)_IO('i',111) /* get common_mtus */
+#define SIOCADDMTU (int)_IOW('i',112, int) /* add mtu */
+#define SIOCDELMTU (int)_IOW('i',113, int) /* delete mtu */
+
+#define SIOCGIFGIDLIST (int)_IO('i', 104) /* get gidlist */
+#define SIOCSIFGIDLIST (int)_IO('i', 105) /* set gidlist */
+
+#define SIOCGSIZIFCONF (int)_IOR('i', 106, int) /* get size for SIOCGIFCONF */
+
+#define SIOCIF_ATM_UBR (int)_IOW('i',120,struct ifreq) /* set ubr rate */
+#define SIOCIF_ATM_SNMPARP (int)_IOW('i',121,struct ifreq) /* atm snmp arp */
+#define SIOCIF_ATM_IDLE (int)_IOW('i',122,struct ifreq) /* set idle time */
+#define SIOCIF_ATM_DUMPARP (int)_IOW('i',123,struct ifreq) /* atm dump arp */
+#define SIOCIF_ATM_SVC (int)_IOW('i',124,struct ifreq) /* atmif init */
+#define SIOCIF_ATM_DARP (int)_IOW('i',125,struct ifreq) /* del atmarp */
+#define SIOCIF_ATM_GARP (int)_IOW('i',126,struct ifreq) /* get atmarp */
+#define SIOCIF_ATM_SARP (int)_IOW('i',127,struct ifreq) /* set atmarp */
+
+#define SIOCGISNO (int)_IOWR('i',107, struct oifreq) /* get IF network options */
+#define SIOCSISNO (int)_IOW('i', 108, struct oifreq) /* set IF network options */
+#define SIOCGIFBAUDRATE (int)_IOWR('i', 109, struct oifreq) /* get ifnet's if_baudrate */
diff --git a/ports/sysdeps/unix/sysv/aix/bits/poll.h b/ports/sysdeps/unix/sysv/aix/bits/poll.h
new file mode 100644
index 000000000..b9f2f7155
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/poll.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_POLL_H
+# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
+#endif
+
+/* Event types that can be polled for. These bits may be set in `events'
+ to indicate the interesting event types; they will appear in `revents'
+ to indicate the status of the file descriptor. */
+#define POLLIN 0x0001 /* There is data to read. */
+#define POLLPRI 0x0002 /* There is urgent data to read. */
+#define POLLOUT 0x0004 /* Writing now will not block. */
+
+#ifdef __USE_XOPEN
+/* These values are defined in XPG4.2. */
+# define POLLRDNORM 0x0010 /* Normal data may be read. */
+# define POLLRDBAND 0x0020 /* Priority data may be read. */
+# define POLLWRNORM POLLOUT /* Writing now will not block. */
+# define POLLWRBAND 0x0040 /* Priority data may be written. */
+#endif
+
+/* Event types always implicitly polled for. These bits need not be set in
+ `events', but they will appear in `revents' to indicate the status of
+ the file descriptor. */
+#define POLLERR 0x4000 /* Error condition. */
+#define POLLHUP 0x2000 /* Hung up. */
+#define POLLNVAL 0x8000 /* Invalid polling request. */
diff --git a/ports/sysdeps/unix/sysv/aix/bits/resource.h b/ports/sysdeps/unix/sysv/aix/bits/resource.h
new file mode 100644
index 000000000..cc851e8a0
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/resource.h
@@ -0,0 +1,191 @@
+/* Bit values & structures for resource limits. AIX version.
+ Copyright (C) 1994, 1996-1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_RESOURCE_H
+# error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* Transmute defines to enumerations. The macro re-definitions are
+ necessary because some programs want to test for operating system
+ features with #ifdef RUSAGE_SELF. In ISO C the reflexive
+ definition is a no-op. */
+
+/* Kinds of resource limit. */
+enum __rlimit_resource
+{
+ /* Per-process CPU limit, in seconds. */
+ RLIMIT_CPU = 0,
+#define RLIMIT_CPU RLIMIT_CPU
+
+ /* Largest file that can be created, in bytes. */
+ RLIMIT_FSIZE = 1,
+#define RLIMIT_FSIZE RLIMIT_FSIZE
+
+ /* Maximum size of data segment, in bytes. */
+ RLIMIT_DATA = 2,
+#define RLIMIT_DATA RLIMIT_DATA
+
+ /* Maximum size of stack segment, in bytes. */
+ RLIMIT_STACK = 3,
+#define RLIMIT_STACK RLIMIT_STACK
+
+ /* Largest core file that can be created, in bytes. */
+ RLIMIT_CORE = 4,
+#define RLIMIT_CORE 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 = 5,
+#define RLIMIT_RSS RLIMIT_RSS
+
+ /* Address space limit (?) */
+ RLIMIT_AS = 6,
+#define RLIMIT_AS RLIMIT_AS
+
+ /* Number of open files. */
+ RLIMIT_NOFILE = 7,
+ RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same. */
+#define RLIMIT_NOFILE RLIMIT_NOFILE
+#define RLIMIT_OFILE RLIMIT_OFILE
+
+ RLIM_NLIMITS = 10
+#define RLIMIT_NLIMITS RLIMIT_NLIMITS
+#define RLIM_NLIMITS RLIM_NLIMITS
+};
+
+/* Value to indicate that there is no limit. */
+#ifndef __USE_FILE_OFFSET64
+# define RLIM_INFINITY ((long int)(~0UL >> 1))
+#else
+# define RLIM_INFINITY 0x7fffffffffffffffLL
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define RLIM64_INFINITY 0x7fffffffffffffffLL
+#endif
+
+#define RLIM_SAVED_MAX (RLIM_INFINITY - 1)
+#define RLIM_SAVED_CUR (RLIM_INFINITY - 2)
+
+
+/* Type for resource quantity measurement. */
+#ifndef __USE_FILE_OFFSET64
+typedef __rlim_t rlim_t;
+#else
+typedef __rlim64_t rlim_t;
+#endif
+#ifdef __USE_LARGEFILE64
+typedef __rlim64_t rlim64_t;
+#endif
+
+struct rlimit
+ {
+ /* The current (soft) limit. */
+ rlim_t rlim_cur;
+ /* The hard limit. */
+ rlim_t rlim_max;
+ };
+
+#ifdef __USE_LARGEFILE64
+struct rlimit64
+ {
+ /* The current (soft) limit. */
+ rlim64_t rlim_cur;
+ /* The hard limit. */
+ rlim64_t rlim_max;
+ };
+#endif
+
+/* Whose usage statistics do you want? */
+enum __rusage_who
+{
+ /* The calling process. */
+ RUSAGE_SELF = 0,
+#define RUSAGE_SELF RUSAGE_SELF
+
+ /* All of its terminated child processes. */
+ RUSAGE_CHILDREN = -1
+#define RUSAGE_CHILDREN RUSAGE_CHILDREN
+};
+
+#define __need_timeval
+#include <bits/time.h> /* For `struct timeval'. */
+
+/* Structure which says how much of each resource has been used. */
+struct rusage
+ {
+ /* Total amount of user time used. */
+ struct timeval ru_utime;
+ /* Total amount of system time used. */
+ struct timeval ru_stime;
+ /* Maximum resident set size (in kilobytes). */
+ long int ru_maxrss;
+ /* Amount of sharing of text segment memory
+ with other processes (kilobyte-seconds). */
+ long int ru_ixrss;
+ /* Amount of data segment memory used (kilobyte-seconds). */
+ long int ru_idrss;
+ /* Amount of stack memory used (kilobyte-seconds). */
+ long int ru_isrss;
+ /* Number of soft page faults (i.e. those serviced by reclaiming
+ a page from the list of pages awaiting reallocation. */
+ long int ru_minflt;
+ /* Number of hard page faults (i.e. those that required I/O). */
+ long int ru_majflt;
+ /* Number of times a process was swapped out of physical memory. */
+ long int ru_nswap;
+ /* Number of input operations via the file system. Note: This
+ and `ru_oublock' do not include operations with the cache. */
+ long int ru_inblock;
+ /* Number of output operations via the file system. */
+ long int ru_oublock;
+ /* Number of IPC messages sent. */
+ long int ru_msgsnd;
+ /* Number of IPC messages received. */
+ long int ru_msgrcv;
+ /* Number of signals delivered. */
+ long int ru_nsignals;
+ /* Number of voluntary context switches, i.e. because the process
+ gave up the process before it had to (usually to wait for some
+ resource to be available). */
+ long int ru_nvcsw;
+ /* Number of involuntary context switches, i.e. a higher priority process
+ became runnable or the current process used up its time slice. */
+ long int ru_nivcsw;
+ };
+
+/* Priority limits. */
+#define PRIO_MIN -20 /* Minimum priority a process can have. */
+#define PRIO_MAX 20 /* Maximum priority a process can have. */
+
+/* The type of the WHICH argument to `getpriority' and `setpriority',
+ indicating what flavor of entity the WHO argument specifies. */
+enum __priority_which
+{
+ PRIO_PROCESS = 0, /* WHO is a process ID. */
+#define PRIO_PROCESS PRIO_PROCESS
+ PRIO_PGRP = 1, /* WHO is a process group ID. */
+#define PRIO_PGRP PRIO_PGRP
+ PRIO_USER = 2 /* WHO is a user ID. */
+#define PRIO_USER PRIO_USER
+};
diff --git a/ports/sysdeps/unix/sysv/aix/bits/setjmp.h b/ports/sysdeps/unix/sysv/aix/bits/setjmp.h
new file mode 100644
index 000000000..c7a736bc3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/setjmp.h
@@ -0,0 +1,46 @@
+/* Copyright (C) 1997, 1998, 1999, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Define the machine-dependent type `jmp_buf'. PowerPC version. */
+
+#ifndef _SETJMP_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+/* The previous bits/setjmp.h had __jmp_buf defined as a structure.
+ We use an array of 'long int' instead, to make writing the
+ assembler easier. Naturally, user code should not depend on
+ either representation. */
+
+#if defined __USE_MISC || defined _ASM
+# define JB_GPR1 0 /* Also known as the stack pointer */
+# define JB_GPR2 1
+# define JB_LR 2 /* The address we will return to */
+# define JB_GPRS 3 /* GPRs 14 through 31 are saved, 18 in total */
+# define JB_CR 21 /* Condition code registers. */
+# define JB_FPRS 22 /* FPRs 14 through 31 are saved, 18*2 words total */
+#endif
+
+#ifndef _ASM
+typedef long int __jmp_buf[64];
+#endif
+
+/* Test if longjmp to JMPBUF would unwind the frame
+ containing a local variable at ADDRESS. */
+#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \
+ ((void *) (address) < (void *) demangle ((jmpbuf)[JB_GPR1]))
diff --git a/ports/sysdeps/unix/sysv/aix/bits/sigaction.h b/ports/sysdeps/unix/sysv/aix/bits/sigaction.h
new file mode 100644
index 000000000..55414b8f1
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/sigaction.h
@@ -0,0 +1,72 @@
+/* The proper definitions for AIX's sigaction.
+ Copyright (C) 1993-1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SIGNAL_H
+# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
+#endif
+
+/* Structure describing the action to be taken when a signal arrives. */
+struct sigaction
+ {
+ /* Signal handler. */
+#ifdef __USE_POSIX199309
+ union
+ {
+ /* Used if SA_SIGINFO is not set. */
+ __sighandler_t sa_handler;
+ /* Used if SA_SIGINFO is set. */
+ void (*sa_sigaction) (int, siginfo_t *, void *);
+ }
+ __sigaction_handler;
+# define sa_handler __sigaction_handler.sa_handler
+# define sa_sigaction __sigaction_handler.sa_sigaction
+#else
+ __sighandler_t sa_handler;
+#endif
+
+ /* Additional set of signals to be blocked. */
+ __sigset_t sa_mask;
+
+ /* Special flags. */
+ int sa_flags;
+ };
+
+/* Bits in `sa_flags'. */
+#define SA_NOCLDSTOP 4 /* Don't send SIGCHLD when children stop. */
+#define SA_NOCLDWAIT 0x400 /* Don't create on death of child. */
+#define SA_SIGINFO 0x100 /* Invoke signal-catching function with
+ three arguments instead of one. */
+#if defined __USE_UNIX98 || defined __USE_MISC
+# define SA_ONSTACK 0x00000001 /* Use signal stack by using `sa_restorer'. */
+# define SA_RESTART 0x00000008 /* Restart syscall on signal return. */
+# define SA_NODEFER 0x00000200 /* Don't automatically block the signal when
+ its handler is being executed. */
+# define SA_RESETHAND 0x00000002 /* Reset to SIG_DFL on entry to handler. */
+#endif
+#ifdef __USE_MISC
+/* Some aliases for the SA_ constants. */
+# define SA_NOMASK SA_NODEFER
+# define SA_ONESHOT SA_RESETHAND
+# define SA_STACK SA_ONSTACK
+#endif
+
+/* 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/ports/sysdeps/unix/sysv/aix/bits/sigcontext.h b/ports/sysdeps/unix/sysv/aix/bits/sigcontext.h
new file mode 100644
index 000000000..40bec1b71
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/sigcontext.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
+# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
+#endif
+
+#include <sys/ucontext.h>
+
+
+struct sigcontext
+{
+ int sc_onstack; /* Sigstack state to restore. */
+ sigset_t sc_mask; /* Signal mask to restore. */
+ int sc_uerror; /* u_error to restore. */
+ struct mcontext_t sc_jmpbuf; /* Process context to restore. */
+};
diff --git a/ports/sysdeps/unix/sysv/aix/bits/signum.h b/ports/sysdeps/unix/sysv/aix/bits/signum.h
new file mode 100644
index 000000000..67eb94960
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/signum.h
@@ -0,0 +1,96 @@
+/* Signal number definitions. AIX version.
+ Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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. */
+
+#ifdef __USE_UNIX98
+# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */
+# define SIG_CATCHE ((__sighandler_t) 3)
+#endif
+
+
+/* Signals. */
+#define SIGHUP 1 /* Hangup (POSIX). */
+#define SIGINT 2 /* Interrupt (ANSI). */
+#define SIGQUIT 3 /* Quit (POSIX). */
+#define SIGILL 4 /* Illegal instruction (ANSI). */
+#define SIGTRAP 5 /* Trace trap (POSIX). */
+#define SIGABRT 6 /* Abort (ANSI). */
+#define SIGIOT SIGABRT /* Abort (terminal) process. */
+#define SIGEMT 7 /* EMT instruction. */
+#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 system call. */
+#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 SIGIOINT SIGURG /* Printer to backend error signal. */
+#define SIGSTOP 17 /* Stop, unblockable (POSIX). */
+#define SIGTSTP 18 /* Keyboard stop (POSIX). */
+#define SIGCONT 19 /* Continue (POSIX). */
+#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */
+#define SIGCHLD 20 /* Child status has changed (POSIX). */
+#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 SIGAIO SIGIO /* Base LAN I/O. */
+#define SIGPTY SIGIO /* PTY I/O. */
+#define SIGPOLL SIGIO /* ANother I/O event. */
+#define SIGXCPU 24 /* CPU limit exceeded (4.2 BSD). */
+#define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */
+#define SIGMSG 27 /* Input data is in the ring buffer. */
+#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */
+#define SIGPWR 29 /* Power failure restart (System V). */
+#define SIGUSR1 30 /* User-defined signal 1 (POSIX). */
+#define SIGUSR2 31 /* User-defined signal 2 (POSIX). */
+#define SIGPROF 32 /* Profiling alarm clock (4.2 BSD). */
+#define SIGDANGER 33 /* System crash imminent. */
+#define SIGVTALRM 34 /* Virtual alarm clock (4.2 BSD). */
+#define SIGMIGRATE 35 /* Migrate process. */
+#define SIGPRE 36 /* Programming exception. */
+#define SIGVIRT 37 /* AIX virtual time alarm. */
+#define SIGARLM1 38 /* Reserved, don't use. */
+#define SIGWAITING 39 /* Reserved, don't use. */
+#define SIGCPUFAIL 59 /* Predictive de-configuration of processors.*/
+#define SIGKAP 60 /* Keep alive poll from native keyboard. */
+#define SIGGRANT SIGKAP /* Monitor mode granted. */
+#define SIGRETRACT 61 /* Monitor mode should be relinguished. */
+#define SIGSOUND 62 /* Sound control has completed. */
+#define SIGSAK 63 /* Secure attentation key. */
+
+#define _NSIG 64 /* Biggest signal number + 1
+ (including real-time signals). */
+
+#define SIGRTMIN (__libc_current_sigrtmin ())
+#define SIGRTMAX (__libc_current_sigrtmax ())
+
+/* These are the hard limits of the kernel. These values should not be
+ used directly at user level. */
+#define __SIGRTMIN 888
+#define __SIGRTMAX 999
+
+#endif /* <signal.h> included. */
diff --git a/ports/sysdeps/unix/sysv/aix/bits/sigset.h b/ports/sysdeps/unix/sysv/aix/bits/sigset.h
new file mode 100644
index 000000000..0dc6b40a7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/sigset.h
@@ -0,0 +1,125 @@
+/* __sig_atomic_t, __sigset_t, and related definitions. AIX version.
+ Copyright (C) 1991,1992,1994,1996,1997,2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 int __losigs;
+ unsigned int __hisigs;
+ } __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
+
+# ifndef _EXTERN_INLINE
+# define _EXTERN_INLINE extern __inline
+# endif
+
+/* Return a mask that includes the bit for SIG only. */
+# define __sigmask(sig) \
+ (((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned int))))
+
+# if defined __GNUC__ && __GNUC__ >= 2
+# define __sigemptyset(set) \
+ (__extension__ ({ sigset_t *__set = (set); \
+ __set->__losigs = __set->__hisigs = 0; \
+ 0; }))
+# define __sigfillset(set) \
+ (__extension__ ({ sigset_t *__set = (set); \
+ __set->__losigs = __set->__hisigs = ~0u; \
+ 0; }))
+
+# ifdef __USE_GNU
+/* The POSIX does not specify for handling the whole signal set in one
+ command. This is often wanted and so we define three more functions
+ here. */
+# define __sigisemptyset(set) \
+ (__extension__ ({ const sigset_t *__set = (set); \
+ (__set->__losigs | __set->__hisigs) == 0; }))
+# define __sigandset(dest, left, right) \
+ (__extension__ ({ sigset_t *__dest = (dest); \
+ const sigset_t *__left = (left); \
+ const sigset_t *__right = (right); \
+ __dest->__losigs = __left->__losigs & __right->__losigs; \
+ __dest->__hisigs = __left->__hisigs & __right->__hisigs; \
+ 0; }))
+# define __sigorset(dest, left, right) \
+ (__extension__ ({ sigset_t *__dest = (dest); \
+ const sigset_t *__left = (left); \
+ const sigset_t *__right = (right); \
+ __dest->__losigs = __left->__losigs | __right->__losigs; \
+ __dest->__hisigs = __left->__hisigs | __right->__hisigs; \
+ 0; }))
+# endif
+# endif
+
+/* These functions needn't check for a bogus signal number -- error
+ checking is done in the non __ versions. */
+
+extern int __sigismember (__const __sigset_t *, int);
+extern int __sigaddset (__sigset_t *, int);
+extern int __sigdelset (__sigset_t *, int);
+
+# ifdef __USE_EXTERN_INLINES
+_EXTERN_INLINE int
+__sigismember (__const __sigset_t *__set, int __sig)
+{
+ unsigned int __mask = __sigmask (__sig);
+
+ return ((__sig < 33 ? __set->__losigs : __set->__hisigs) & __mask ) ? 1 : 0;
+}
+
+_EXTERN_INLINE int
+__sigaddset (__sigset_t *__set, int __sig)
+{
+ unsigned int __mask = __sigmask (__sig);
+
+ (__sig < 33 ? __set->__losigs : __set->__hisigs) |= __mask;
+
+ return 0;
+}
+
+_EXTERN_INLINE int
+__sigdelset (__sigset_t *__set, int __sig)
+{
+ unsigned int __mask = __sigmask (__sig);
+
+ (__sig < 33 ? __set->__losigs : __set->__hisigs) &= ~__mask;
+
+ return 0;
+}
+# endif
+
+
+#endif /* ! _SIGSET_H_fns. */
diff --git a/ports/sysdeps/unix/sysv/aix/bits/sigstack.h b/ports/sysdeps/unix/sysv/aix/bits/sigstack.h
new file mode 100644
index 000000000..cefd33c23
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/sigstack.h
@@ -0,0 +1,46 @@
+/* sigstack, sigaltstack definitions.
+ Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SIGNAL_H
+# error "Never include this file directly. Use <signal.h> instead"
+#endif
+
+
+/* Structure describing a signal stack (obsolete). */
+struct sigstack
+ {
+ void *ss_sp; /* Signal stack pointer. */
+ int ss_onstack; /* Nonzero if executing on this stack. */
+ };
+
+
+/* Possible values for `ss_flags.'. */
+enum
+{
+ SS_ONSTACK = 1,
+#define SS_ONSTACK SS_ONSTACK
+ SS_DISABLE
+#define SS_DISABLE SS_DISABLE
+};
+
+/* Minimum stack size for a signal handler. */
+#define MINSIGSTKSZ 1024
+
+/* System default stack size. */
+#define SIGSTKSZ 4096
diff --git a/ports/sysdeps/unix/sysv/aix/bits/socket.h b/ports/sysdeps/unix/sysv/aix/bits/socket.h
new file mode 100644
index 000000000..1fdadfe08
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/socket.h
@@ -0,0 +1,293 @@
+/* System-specific socket constants and types. AIX version.
+ Copyright (C) 1991,92,1994-1999,2000,2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef __BITS_SOCKET_H
+#define __BITS_SOCKET_H
+
+#if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H
+# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
+#endif
+
+#define __need_size_t
+#define __need_NULL
+#include <stddef.h>
+
+#include <limits.h>
+#include <sys/types.h>
+
+/* Type for length arguments in socket calls. */
+#ifndef __socklen_t_defined
+typedef __socklen_t socklen_t;
+# define __socklen_t_defined
+#endif
+
+/* Types of sockets. */
+enum __socket_type
+{
+ SOCK_STREAM = 1, /* Sequenced, reliable, connection-based
+ byte streams. */
+#define SOCK_STREAM SOCK_STREAM
+ SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams
+ of fixed maximum length. */
+#define SOCK_DGRAM SOCK_DGRAM
+ SOCK_RAW = 3, /* Raw protocol interface. */
+#define SOCK_RAW SOCK_RAW
+ SOCK_RDM = 4, /* Reliably-delivered messages. */
+#define SOCK_RDM SOCK_RDM
+ SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based,
+ datagrams of fixed maximum length. */
+#define SOCK_SEQPACKET SOCK_SEQPACKET
+ SOCK_CONN_DGRAM = 6 /* Conneciton datagram. */
+#define SOCK_CONN_DGRAM SOCK_CONN_DGRAM
+};
+
+/* Protocol families. */
+#define PF_UNSPEC 0 /* Unspecified. */
+#define PF_LOCAL 1 /* Local to host (pipes and file-domain). */
+#define PF_UNIX PF_LOCAL /* Old BSD name for PF_LOCAL. */
+#define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */
+#define PF_INET 2 /* IP protocol family. */
+#define PF_IMPLINK 3 /* ARPAnet IMP addresses. */
+#define PF_PUP 4 /* PUP protocols (e.g., BSP). */
+#define PF_CHAOS 5 /* MIT CHAOS protocols. */
+#define PF_NS 6 /* XEROX NS protocols. */
+#define PF_ISO 7 /* ISO protocols. */
+#define PF_OSI PF_ISO
+#define PF_ECMA 8 /* European Computer Manufacturers. */
+#define PF_DATAKIT 9 /* Datakit protocols. */
+#define PF_CCITT 10 /* CCITT protocols, X.25 etc. */
+#define PF_SNA 11 /* IBM SNA. */
+#define PF_DECnet 12 /* DECnet. */
+#define PF_DLI 13 /* DEC Direct data link interface. */
+#define PF_LAT 14 /* LAT. */
+#define PF_HYLINK 15 /* NSC Hyperchannel. */
+#define PF_APPLETALK 16 /* Apple Talk. */
+#define PF_NETLINK 17 /* Internet Routing Protocol. */
+#define PF_ROUTE PF_NETLINK /* Alias to emulate 4.4BSD. */
+#define PF_LINK 18 /* Link layer interface. */
+#define PF_XTP 19 /* eXpress Transfer Protocol (no AF). */
+#define PF_INTF 20 /* Debugging use only. */
+#define PF_RIF 21 /* Raw interface. */
+#define PF_NETWARE 22
+#define PF_NDD 23
+#define PF_INET6 24 /* IPv6. */
+#define PF_MAX 30 /* For now.. */
+
+/* Address families. */
+#define AF_UNSPEC PF_UNSPEC
+#define AF_LOCAL PF_LOCAL
+#define AF_UNIX PF_UNIX
+#define AF_FILE PF_FILE
+#define AF_INET PF_INET
+#define AF_IMPLINK PF_IMPLINK
+#define AF_PUP PF_PUP
+#define AF_CHAOS PF_CHAOS
+#define AF_NS PF_NS
+#define AF_ISO PF_ISO
+#define AF_OSI PF_OSI
+#define AF_ECMA PF_ECMA
+#define AF_DATAKIT PF_DATAKIT
+#define AF_CCITT PF_CCITT
+#define AF_SNA PF_SNA
+#define AF_DECnet PF_DECnet
+#define AF_DLI PF_DLI
+#define AF_LAT PF_LAT
+#define AF_HYLINK PF_HYLINK
+#define AF_APPLETALK PF_APPLETALK
+#define AF_NETLINK PF_NETLINK
+#define AF_ROUTE PF_ROUTE
+#define AF_LINK PF_LINK
+#define AF_INTF PF_INTF
+#define AF_RIF PF_RIF
+#define AF_NETWARE PF_NETWARE
+#define AF_NDD PF_NDD
+#define AF_INET6 PF_INET6
+#define AF_MAX PF_MAX
+
+/* Socket level values. Others are defined in the appropriate headers.
+
+ XXX These definitions also should go into the appropriate headers as
+ far as they are available. */
+#define SOL_SOCKET 0xffff
+
+/* Maximum queue length specifiable by listen. */
+#define SOMAXCONN 1024
+
+/* Get the definition of the macro to define the common sockaddr members. */
+#include <bits/sockaddr.h>
+
+/* Structure describing a generic socket address. */
+struct sockaddr
+ {
+ __SOCKADDR_COMMON (sa_); /* Common data: address family and length. */
+ char sa_data[14]; /* Address data. */
+ };
+
+
+/* Structure large enough to hold any socket address (with the historical
+ exception of AF_UNIX). We reserve 128 bytes. */
+#if ULONG_MAX > 0xffffffff
+# define __ss_aligntype __uint64_t
+#else
+# define __ss_aligntype __uint32_t
+#endif
+#define _SS_SIZE 128
+#define _SS_PADSIZE (_SS_SIZE - (2 * sizeof (__ss_aligntype)))
+
+struct sockaddr_storage
+ {
+ __SOCKADDR_COMMON (ss_); /* Address family, etc. */
+ __ss_aligntype __ss_align; /* Force desired alignment. */
+ char __ss_padding[_SS_PADSIZE];
+ };
+
+
+/* Bits in the FLAGS argument to `send', `recv', et al. */
+enum
+ {
+ MSG_OOB = 0x01, /* Process out-of-band data. */
+#define MSG_OOB MSG_OOB
+ MSG_PEEK = 0x02, /* Peek at incoming messages. */
+#define MSG_PEEK MSG_PEEK
+ MSG_DONTROUTE = 0x04, /* Don't use local routing. */
+#define MSG_DONTROUTE MSG_DONTROUTE
+ MSG_EOR = 0x08, /* End of record. */
+#define MSG_EOR MSG_EOR
+ MSG_TRUNC = 0x10,
+#define MSG_TRUNC MSG_TRUNC
+ MSG_CTRUNC = 0x20, /* Control data lost before delivery. */
+#define MSG_CTRUNC MSG_CTRUNC
+ MSG_WAITALL = 0x40, /* Wait for a full request. */
+#define MSG_WAITALL MSG_WAITALL
+ MSG_MPEG2 = 0x80, /* Message contain MPEG2 data. */
+#define MSG_MPEG2 MSG_MPEG2
+ };
+
+
+/* Structure describing messages sent by
+ `sendmsg' and received by `recvmsg'. */
+struct msghdr
+ {
+ void *msg_name; /* Address to send to/receive from. */
+ socklen_t msg_namelen; /* Length of address data. */
+
+ struct iovec *msg_iov; /* Vector of data to send/receive into. */
+ int msg_iovlen; /* Number of elements in the vector. */
+
+ void *msg_control; /* Ancillary data (eg BSD filedesc passing). */
+ socklen_t msg_controllen; /* Ancillary data buffer length. */
+
+ int msg_flags; /* Flags on received message. */
+ };
+
+/* Structure used for storage of ancillary data object information. */
+struct cmsghdr
+ {
+ socklen_t cmsg_len; /* Length of data in cmsg_data plus length
+ of cmsghdr structure. */
+ int cmsg_level; /* Originating protocol. */
+ int cmsg_type; /* Protocol specific type. */
+#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
+ __extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data. */
+#endif
+ };
+
+/* Ancillary data object manipulation macros. */
+#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
+# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
+#else
+# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))
+#endif
+#define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)
+#define CMSG_FIRSTHDR(mhdr) \
+ ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
+ ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) NULL)
+#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \
+ & ~(sizeof (size_t) - 1))
+#define CMSG_SPACE(len) (CMSG_ALIGN (len) \
+ + CMSG_ALIGN (sizeof (struct cmsghdr)))
+#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
+
+extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
+ struct cmsghdr *__cmsg) __THROW;
+#ifdef __USE_EXTERN_INLINES
+# ifndef _EXTERN_INLINE
+# define _EXTERN_INLINE extern __inline
+# endif
+_EXTERN_INLINE struct cmsghdr *
+__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg) __THROW
+{
+ if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
+ /* The kernel header does this so there may be a reason. */
+ return 0;
+
+ __cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
+ + CMSG_ALIGN (__cmsg->cmsg_len));
+ if ((unsigned char *) (__cmsg + 1) >= ((unsigned char *) __mhdr->msg_control
+ + __mhdr->msg_controllen)
+ || ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len)
+ > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
+ /* No more entries. */
+ return 0;
+ return __cmsg;
+}
+#endif /* Use `extern inline'. */
+
+/* Socket level message types. This must match the definitions in
+ <linux/socket.h>. */
+enum
+ {
+ SCM_RIGHTS = 0x01 /* Transfer file descriptors. */
+#define SCM_RIGHTS SCM_RIGHTS
+ };
+
+/* Options flags per socket. */
+#define SO_DEBUG 0x0001 /* Turn on debugging info recording. */
+#define SO_ACCEPTCONN 0x0002 /* Socket has had listen(). */
+#define SO_REUSEADDR 0x0004 /* Allow local address reuse. */
+#define SO_KEEPALIVE 0x0008 /* Keep connections alive. */
+#define SO_DONTROUTE 0x0010 /* Just use interface addresses. */
+#define SO_BROADCAST 0x0020 /* Permit sending of broadcast msgs. */
+#define SO_USELOOPBACK 0x0040 /* Bypass hardware when possible. */
+#define SO_LINGER 0x0080 /* Linger on close if data present. */
+#define SO_OOBINLINE 0x0100 /* Leave received OOB data in line. */
+#define SO_REUSEPORT 0x0200 /* Allow local address & port reuse. */
+#define SO_USE_IFBUFS 0x0400 /* Interface will supply buffers. */
+#define SO_CKSUMRECV 0x0800 /* Defer checksum until receive. */
+#define SO_NOREUSEADDR 0x1000 /* Prevent local address reuse. */
+#define SO_SNDBUF 0x1001 /* Send buffer size. */
+#define SO_RCVBUF 0x1002 /* Receive buffer size. */
+#define SO_SNDLOWAT 0x1003 /* Send low-water mark. */
+#define SO_RCVLOWAT 0x1004 /* Receive low-water mark. */
+#define SO_SNDTIMEO 0x1005 /* Send timeout. */
+#define SO_RCVTIMEO 0x1006 /* Receive timeout. */
+#define SO_ERROR 0x1007 /* Get error status and clear. */
+#define SO_TYPE 0x1008 /* Get socket type. */
+#define SO_KERNACCEPT 0x2000 /* Derive a in-kernel only socket. */
+#define SO_AUDIT 0x8000 /* Turn on socket auditing. */
+
+
+/* Structure used to manipulate the SO_LINGER option. */
+struct linger
+ {
+ int l_onoff; /* Nonzero to linger on close. */
+ int l_linger; /* Time to linger. */
+ };
+
+#endif /* bits/socket.h */
diff --git a/ports/sysdeps/unix/sysv/aix/bits/stat.h b/ports/sysdeps/unix/sysv/aix/bits/stat.h
new file mode 100644
index 000000000..adcb1d101
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/stat.h
@@ -0,0 +1,119 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_STAT_H
+# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+struct stat
+ {
+ __dev_t st_dev; /* Device. */
+ __ino_t st_ino; /* File serial number. */
+ __mode_t st_mode; /* File mode. */
+ __nlink_t st_nlink; /* Link count. */
+ unsigned short int st_flag; /* Flag word. */
+ __uid_t st_uid; /* User ID of the file's owner. */
+ __gid_t st_gid; /* Group ID of the file's group.*/
+ __dev_t st_rdev; /* Device number, if device. */
+#ifndef __USE_FILE_OFFSET64
+ __off_t st_size; /* Size of file, in bytes. */
+#else
+ int st_ssize; /* Size of file, in bytes. */
+#endif
+ __time_t st_atime; /* Time of last access. */
+ unsigned long int __unused1;
+ __time_t st_mtime; /* Time of last modification. */
+ unsigned long int __unused2;
+ __time_t st_ctime; /* Time of last status change. */
+ unsigned long int __unused3;
+ __blksize_t st_blksize; /* Optimal block size for I/O. */
+ __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
+ int st_vfstype; /* Type of the filesystem. */
+ unsigned int st_vfs; /* Vfs number. */
+ unsigned int st_type; /* Vnode type. */
+ unsigned int st_gen; /* Inode generation number. */
+
+#define _STATBUF_RESERVED_SPACE 9
+ unsigned int st_reserved[_STATBUF_RESERVED_SPACE];
+
+#ifdef __USE_FILE_OFFSET64
+ unsigned int st_padto_ll;
+ __off64_t st_size; /* 64 bit file size in bytes. */
+#endif
+ };
+
+#ifdef __USE_LARGEFILE64
+struct stat64
+ {
+ __dev_t st_dev; /* Device. */
+ __ino_t st_ino; /* File serial number. */
+ __mode_t st_mode; /* File mode. */
+ __nlink_t st_nlink; /* Link count. */
+ unsigned short int st_flag; /* Flag word. */
+ __uid_t st_uid; /* User ID of the file's owner. */
+ __gid_t st_gid; /* Group ID of the file's group.*/
+ __dev_t st_rdev; /* Device number, if device. */
+ int st_ssize; /* Size of file, in bytes. */
+ __time_t st_atime; /* Time of last access. */
+ unsigned long int __unused1;
+ __time_t st_mtime; /* Time of last modification. */
+ unsigned long int __unused2;
+ __time_t st_ctime; /* Time of last status change. */
+ unsigned long int __unused3;
+ __blksize_t st_blksize; /* Optimal block size for I/O. */
+ __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
+ int st_vfstype; /* Type of the filesystem. */
+ unsigned int st_vfs; /* Vfs number. */
+ unsigned int st_type; /* Vnode type. */
+ unsigned int st_gen; /* Inode generation number. */
+ unsigned int st_reserved[_STATBUF_RESERVED_SPACE];
+ unsigned int st_padto_ll;
+ __off64_t st_size; /* 64 bit file size in bytes. */
+ };
+#endif
+
+/* Tell code we have these members. */
+#define _STATBUF_ST_BLKSIZE
+#define _STATBUF_ST_RDEV
+
+/* 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. */
+
+/* POSIX.1b objects. */
+#define __S_TYPEISMQ(buf) (0)
+#define __S_TYPEISSEM(buf) (0)
+#define __S_TYPEISSHM(buf) (0)
+
+/* 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. */
diff --git a/ports/sysdeps/unix/sysv/aix/bits/statfs.h b/ports/sysdeps/unix/sysv/aix/bits/statfs.h
new file mode 100644
index 000000000..0a1c0a5e6
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/statfs.h
@@ -0,0 +1,77 @@
+/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_STATFS_H
+# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
+#endif
+
+#include <bits/types.h> /* for __fsid_t and __fsblkcnt_t*/
+
+struct statfs
+ {
+ int f_version;
+ int f_type;
+ int f_bsize;
+ /* The following five elements have type `int' since AIX's fsfilcnt_t
+ and fsblkcnt_t types do not fit. */
+ int f_blocks;
+ int f_bfree;
+ int f_bavail;
+ int f_files;
+ int f_ffree;
+ __fsid_t f_fsid;
+ int f_vfstype;
+ int f_fsize;
+ int f_vfsnumber;
+ int f_vfsoff;
+ int f_vfslen;
+ int f_vfsvers;
+ char f_fname[32];
+ char f_fpack[32];
+ int f_name_max;
+ };
+
+#ifdef __USE_LARGEFILE64
+/* XXX There seems to be no 64-bit versio of this structure. */
+struct statfs64
+ {
+ int f_version;
+ int f_type;
+ int f_bsize;
+ /* The following five elements have type `int' since AIX's fsfilcnt_t
+ and fsblkcnt_t types do not fit. */
+ int f_blocks;
+ int f_bfree;
+ int f_bavail;
+ int f_files;
+ int f_ffree;
+ __fsid_t f_fsid;
+ int f_vfstype;
+ int f_fsize;
+ int f_vfsnumber;
+ int f_vfsoff;
+ int f_vfslen;
+ int f_vfsvers;
+ char f_fname[32];
+ char f_fpack[32];
+ int f_name_max;
+ };
+#endif
+
+/* Tell code we have these members. */
+#define _STATFS_F_NAME_MAX
diff --git a/ports/sysdeps/unix/sysv/aix/bits/termios.h b/ports/sysdeps/unix/sysv/aix/bits/termios.h
new file mode 100644
index 000000000..b178d9c1b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/termios.h
@@ -0,0 +1,189 @@
+/* termios type and macro definitions. AIX version.
+ Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _TERMIOS_H
+# error "Never include <bits/termios.h> directly; use <termios.h> instead."
+#endif
+
+typedef unsigned char cc_t;
+typedef unsigned int speed_t;
+typedef unsigned int tcflag_t;
+
+#define NCCS 16
+struct termios
+ {
+ tcflag_t c_iflag; /* input mode flags */
+ tcflag_t c_oflag; /* output mode flags */
+ tcflag_t c_cflag; /* control mode flags */
+ tcflag_t c_lflag; /* local mode flags */
+ cc_t c_cc[NCCS]; /* control characters */
+ };
+
+/* c_cc characters */
+#define VINTR 0
+#define VQUIT 1
+#define VERASE 2
+#define VKILL 3
+#define VEOF 4
+#define VEOL 5
+#define VSTART 7
+#define VSTOP 8
+#define VSUSP 9
+#define VMIN 4
+#define VTIME 5
+#define VEOL2 6
+#define VDSUSP 10
+#define VREPRINT 11
+#define VDISCARD 12
+#define VWERSE 13
+#define VWERASE VWERSE
+#define VLNEXT 14
+#define VSTRT VSTART
+
+/* c_iflag bits */
+#define IGNBRK 0000001
+#define BRKINT 0000002
+#define IGNPAR 0000004
+#define PARMRK 0000010
+#define INPCK 0000020
+#define ISTRIP 0000040
+#define INLCR 0000100
+#define IGNCR 0000200
+#define ICRNL 0000400
+#define IXON 0001000
+#define IXOFF 0002000
+#define IUCLC 0004000
+#define IXANY 0010000
+#define IMAXBEL 0200000
+
+/* c_oflag bits */
+#define OPOST 0000001
+#define OLCUC 0000002
+#define ONLCR 0000004
+#define OCRNL 0000010
+#define ONOCR 0000020
+#define ONLRET 0000040
+#define OFILL 0000100
+#define OFDEL 0000200
+#if defined __USE_MISC || defined __USE_XOPEN
+# define CRDLY 0001400
+# define CR0 0000000
+# define CR1 0000400
+# define CR2 0001000
+# define CR3 0001400
+# define TABDLY 0006000
+# define TAB0 0000000
+# define TAB1 0002000
+# define TAB2 0004000
+# define TAB3 0006000
+# define BSDLY 0010000
+# define BS0 0000000
+# define BS1 0010000
+# define FFDLY 0020000
+# define FF0 0000000
+# define FF1 0020000
+# define NLDLY 0040000
+# define NL0 0000000
+# define NL1 0040000
+#endif
+
+#define VTDLY 0100000
+#define VT0 0000000
+#define VT1 0100000
+
+/* c_cflag bit meaning */
+#ifdef __USE_MISC
+# define CBAUD 0000017
+#endif
+#define B0 0000000 /* hang up */
+#define B50 0000001
+#define B75 0000002
+#define B110 0000003
+#define B134 0000004
+#define B150 0000005
+#define B200 0000006
+#define B300 0000007
+#define B600 0000010
+#define B1200 0000011
+#define B1800 0000012
+#define B2400 0000013
+#define B4800 0000014
+#define B9600 0000015
+#define B19200 0000016
+#define B38400 0000017
+#ifdef __USE_MISC
+# define EXTA B19200
+# define EXTB B38400
+#endif
+#define CSIZE 0000060
+#define CS5 0000000
+#define CS6 0000020
+#define CS7 0000040
+#define CS8 0000060
+#define CSTOPB 0000100
+#define CREAD 0000200
+#define PARENB 0000400
+#define PARODD 0001000
+#define HUPCL 0002000
+#define CLOCAL 0004000
+#ifdef __USE_MISC
+# define CIBAUD 000003600000 /* input baud rate (not used) */
+# define CRTSCTS 020000000000 /* flow control */
+#endif
+
+/* c_lflag bits */
+#define ISIG 0000001
+#define ICANON 0000002
+#if defined __USE_MISC || defined __USE_XOPEN
+# define XCASE 0000004
+#endif
+#define ECHO 0000010
+#define ECHOE 0000020
+#define ECHOK 0000040
+#define ECHONL 0000100
+#define NOFLSH 0000200
+#define TOSTOP 0200000
+#ifdef __USE_MISC
+# define ECHOCTL 0400000
+# define ECHOPRT 01000000
+# define ECHOKE 02000000
+# define FLUSHO 004000000
+# define PENDIN 04000000000
+#endif
+#define IEXTEN 010000000
+
+/* tcflow() and TCXONC use these */
+#define TCOOFF 0
+#define TCOON 1
+#define TCIOFF 2
+#define TCION 3
+
+/* tcflush() and TCFLSH use these */
+#define TCIFLUSH 0
+#define TCOFLUSH 1
+#define TCIOFLUSH 2
+
+/* tcsetattr uses these */
+#define TCSANOW 0
+#define TCSADRAIN 1
+#define TCSAFLUSH 2
+
+
+#define _IOT_termios /* Hurd ioctl type field. */ \
+ _IOT (_IOTS (cflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)
diff --git a/ports/sysdeps/unix/sysv/aix/bits/types.h b/ports/sysdeps/unix/sysv/aix/bits/types.h
new file mode 100644
index 000000000..12c3be730
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/types.h
@@ -0,0 +1,136 @@
+/* Copyright (C) 1991,92,1994-1999,2000,2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/*
+ * Never include this file directly; use <sys/types.h> instead.
+ */
+
+#ifndef _BITS_TYPES_H
+#define _BITS_TYPES_H 1
+
+#include <features.h>
+
+#define __need_NULL
+#define __need_size_t
+#include <stddef.h>
+
+/* Convenience types. */
+typedef unsigned char __u_char;
+typedef unsigned short __u_short;
+typedef unsigned int __u_int;
+typedef unsigned long __u_long;
+#ifdef __GNUC__
+__extension__ typedef unsigned long long int __u_quad_t;
+__extension__ typedef long long int __quad_t;
+#else
+typedef struct
+ {
+ long int __val[2];
+ } __quad_t;
+typedef struct
+ {
+ __u_long __val[2];
+ } __u_quad_t;
+#endif
+typedef signed char __int8_t;
+typedef unsigned char __uint8_t;
+typedef signed short int __int16_t;
+typedef unsigned short int __uint16_t;
+typedef signed int __int32_t;
+typedef unsigned int __uint32_t;
+#ifdef __GNUC__
+__extension__ typedef signed long long int __int64_t;
+__extension__ typedef unsigned long long int __uint64_t;
+#endif
+typedef __quad_t *__qaddr_t;
+
+typedef __u_long __dev_t; /* Type of device numbers. */
+typedef __u_int __uid_t; /* Type of user identifications. */
+typedef __u_int __gid_t; /* Type of group identifications. */
+typedef __u_long __ino_t; /* Type of file serial numbers. */
+typedef __u_int __mode_t; /* Type of file attribute bitmasks. */
+typedef short int __nlink_t; /* Type of file link counts. */
+typedef long int __off_t; /* Type of file sizes and offsets. */
+typedef __quad_t __loff_t; /* Type of file sizes and offsets. */
+typedef int __pid_t; /* Type of process identifications. */
+typedef long int __ssize_t; /* Type of a byte count, or error. */
+typedef __u_long __rlim_t; /* Type of resource counts. */
+typedef __u_quad_t __rlim64_t; /* Type of resource counts (LFS). */
+typedef unsigned int __id_t; /* General type for ID. */
+
+typedef struct
+ {
+ unsigned long int __val[2];
+ } __fsid_t; /* Type of file system IDs. */
+
+/* Everythin' else. */
+typedef long int __daddr_t; /* The type of a disk address. */
+typedef char *__caddr_t;
+typedef long int __time_t;
+typedef unsigned int __useconds_t;
+typedef int __suseconds_t;
+typedef long int __swblk_t; /* Type of a swap block maybe? */
+
+typedef int __clock_t;
+
+/* Clock ID used in clock and timer functions. */
+typedef int __clockid_t;
+
+/* Timer ID returned by `timer_create'. */
+typedef int __timer_t;
+
+/* Number of descriptors that can fit in an `fd_set'. */
+#define __FD_SETSIZE 1024
+
+
+typedef long int __key_t;
+
+/* Type to represent block size. */
+typedef int __blksize_t;
+
+/* Types from the Large File Support interface. */
+
+/* Type to count number os disk blocks. */
+typedef int __blkcnt_t;
+typedef __quad_t __blkcnt64_t;
+
+/* Type to count file system blocks. */
+typedef __u_long __fsblkcnt_t;
+typedef __u_quad_t __fsblkcnt64_t;
+
+/* Type to count file system inodes. */
+typedef __u_long __fsfilcnt_t;
+typedef __u_quad_t __fsfilcnt64_t;
+
+/* Type of file serial numbers. */
+typedef __u_quad_t __ino64_t;
+
+/* Type of file sizes and offsets. */
+typedef __loff_t __off64_t;
+
+/* Used in XTI. */
+typedef int __t_scalar_t;
+typedef unsigned int __t_uscalar_t;
+
+/* Duplicates info from stdint.h but this is used in unistd.h. */
+typedef signed long __intptr_t;
+
+/* Duplicate info from sys/socket.h. */
+typedef unsigned int __socklen_t;
+
+#endif /* bits/types.h */
diff --git a/ports/sysdeps/unix/sysv/aix/bits/uio.h b/ports/sysdeps/unix/sysv/aix/bits/uio.h
new file mode 100644
index 000000000..60781532a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/uio.h
@@ -0,0 +1,42 @@
+/* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_UIO_H
+# error "Never include <bits/uio.h> directly; use <sys/uio.h> instead."
+#endif
+
+
+#include <sys/types.h>
+
+
+/* Size of object which can be written atomically.
+
+ This macro has different values in different kernel versions. The
+ latest versions of ther kernel use 1024 and this is good choice. Since
+ the C library implementation of readv/writev is able to emulate the
+ functionality even if the currently running kernel does not support
+ this large value the readv/writev call will not fail because of this. */
+#define UIO_MAXIOV 16
+
+
+/* Structure for scatter/gather I/O. */
+struct iovec
+ {
+ void *iov_base; /* Pointer to data. */
+ size_t iov_len; /* Length of data. */
+ };
diff --git a/ports/sysdeps/unix/sysv/aix/bits/utmp.h b/ports/sysdeps/unix/sysv/aix/bits/utmp.h
new file mode 100644
index 000000000..b78a2afda
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/utmp.h
@@ -0,0 +1,73 @@
+/* The `struct utmp' type, describing entries in the utmp file. AIX.
+ Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _UTMP_H
+# error "Never include <bits/utmp.h> directly; use <utmp.h> instead."
+#endif
+
+#include <paths.h>
+#include <sys/time.h>
+#include <sys/types.h>
+
+
+#define UT_LINESIZE 12
+#define UT_NAMESIZE 8
+#define UT_HOSTSIZE 16
+
+
+struct utmp
+ {
+#define ut_name ut_user
+ char ut_user[UT_NAMESIZE];
+ char ut_id[14];
+ char ut_line[UT_LINESIZE];
+ short int ut_type;
+ short int ut_pid;
+ struct exit_status
+ {
+ short int e_termination;
+ short int e_exit;
+ } ut_exit;
+ __time_t ut_time;
+ char ut_host[UT_HOSTSIZE];
+ };
+
+
+/* Values for the `ut_type' field of a `struct utmp'. */
+#define EMPTY 0 /* No valid user accounting information. */
+
+#define RUN_LVL 1 /* The system's runlevel. */
+#define BOOT_TIME 2 /* Time of system boot. */
+#define OLD_TIME 3 /* Time when system clock changed. */
+#define NEW_TIME 4 /* Time after system clock changed. */
+
+#define INIT_PROCESS 5 /* Process spawned by the init process. */
+#define LOGIN_PROCESS 6 /* Session leader of a logged in user. */
+#define USER_PROCESS 7 /* Normal process. */
+#define DEAD_PROCESS 8 /* Terminated process. */
+
+#define ACCOUNTING 9
+
+
+/* Tell the user that we have a modern system with UT_HOST, UT_TYPE, and
+ UT_ID fields. */
+#define _HAVE_UT_TYPE 1
+#define _HAVE_UT_PID 1
+#define _HAVE_UT_ID 1
+#define _HAVE_UT_HOST 1
diff --git a/ports/sysdeps/unix/sysv/aix/bits/utmpx.h b/ports/sysdeps/unix/sysv/aix/bits/utmpx.h
new file mode 100644
index 000000000..438b5f3a5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/utmpx.h
@@ -0,0 +1,75 @@
+/* Structures and defenitions for the user accounting database. AIX.
+ Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _UTMPX_H
+# error "Never include <bits/utmpx.h> directly; use <utmpx.h> instead."
+#endif
+
+#include <bits/types.h>
+#include <sys/time.h>
+
+
+#ifdef __USE_GNU
+# include <paths.h>
+# define _PATH_UTMPX _PATH_UTMP
+# define _PATH_WTMPX _PATH_WTMP
+#endif
+
+
+#define __UT_LINESIZE 12
+#define __UT_NAMESIZE 8
+#define __UT_HOSTSIZE 16
+
+
+/* The structure describing an entry in the user accounting database. */
+struct utmpx
+{
+ char ut_user[__UT_NAMESIZE]; /* Username. */
+ char ut_id[14]; /* Inittab ID. */
+ char ut_line[__UT_LINESIZE]; /* Devicename. */
+ short int ut_type; /* Type of login. */
+ __pid_t ut_pid; /* Process ID of login process. */
+ struct timeval ut_tv; /* Time entry was made. */
+ char ut_host[__UT_HOSTSIZE]; /* Hostname for remote login. */
+};
+
+
+/* Values for the `ut_type' field of a `struct utmpx'. */
+#define EMPTY 0 /* No valid user accounting information. */
+
+#define RUN_LVL 1 /* The system's runlevel. */
+#define BOOT_TIME 2 /* Time of system boot. */
+#define NEW_TIME 3 /* Time after system clock changed. */
+#define OLD_TIME 4 /* Time when system clock changed. */
+
+#define INIT_PROCESS 5 /* Process spawned by the init process. */
+#define LOGIN_PROCESS 6 /* Session leader of a logged in user. */
+#define USER_PROCESS 7 /* Normal process. */
+#define DEAD_PROCESS 8 /* Terminated process. */
+
+#ifdef __USE_GNU
+# define ACCOUNTING 9 /* System accounting. */
+#endif
+
+#define _HAVE_UT_TYPE 1
+#define _HAVE_UT_PID 1
+#define _HAVE_UT_ID 1
+#define _HAVE_UT_TV 1
+#define _HAVE_UT_HOST 1
+
diff --git a/ports/sysdeps/unix/sysv/aix/bits/utsname.h b/ports/sysdeps/unix/sysv/aix/bits/utsname.h
new file mode 100644
index 000000000..d238f5efd
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/bits/utsname.h
@@ -0,0 +1,23 @@
+/* Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_UTSNAME_H
+# error "Never include <bits/utsname.h> directly; use <sys/utsname.h> instead."
+#endif
+
+#define _UTSNAME_LENGTH 32
diff --git a/ports/sysdeps/unix/sysv/aix/brk.c b/ports/sysdeps/unix/sysv/aix/brk.c
new file mode 100644
index 000000000..66707fe60
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/brk.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__brk (void *addr)
+{
+ return brk (addr);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/chdir.c b/ports/sysdeps/unix/sysv/aix/chdir.c
new file mode 100644
index 000000000..153084eb6
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/chdir.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__chdir (const char *path)
+{
+ return chdir (path);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/chmod.c b/ports/sysdeps/unix/sysv/aix/chmod.c
new file mode 100644
index 000000000..628d09cce
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/chmod.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/stat.h>
+
+int
+__chmod (const char *path, mode_t mode)
+{
+ return chmod (path, mode);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/chown.c b/ports/sysdeps/unix/sysv/aix/chown.c
new file mode 100644
index 000000000..2b6e82e73
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/chown.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__chown (const char *file, uid_t owner, gid_t group)
+{
+ return chown (file, owner, group);
+}
+libc_hidden_def (__chown)
diff --git a/ports/sysdeps/unix/sysv/aix/chroot.c b/ports/sysdeps/unix/sysv/aix/chroot.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/chroot.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/close.c b/ports/sysdeps/unix/sysv/aix/close.c
new file mode 100644
index 000000000..7be595643
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/close.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__close (int fd)
+{
+ return close (fd);
+}
+libc_hidden_def (__close)
diff --git a/ports/sysdeps/unix/sysv/aix/configure b/ports/sysdeps/unix/sysv/aix/configure
new file mode 100644
index 000000000..2c07b415f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/configure
@@ -0,0 +1,6 @@
+# This file is generated from configure.in by Autoconf. DO NOT EDIT!
+ # Local configure fragment for sysdeps/unix/sysv/aix.
+
+# 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/ports/sysdeps/unix/sysv/aix/configure.in b/ports/sysdeps/unix/sysv/aix/configure.in
new file mode 100644
index 000000000..bb783fc0c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/configure.in
@@ -0,0 +1,6 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/sysv/aix.
+
+# 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/ports/sysdeps/unix/sysv/aix/connect.c b/ports/sysdeps/unix/sysv/aix/connect.c
new file mode 100644
index 000000000..2f58be1ed
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/connect.c
@@ -0,0 +1,11 @@
+/* This is a system call. We only have to provide the wrapper. */
+#include <sys/socket.h>
+
+#undef __connect
+
+int
+__connect (int fd, __CONST_SOCKADDR_ARG addr, socklen_t len)
+{
+ return connect (fd, addr, len);
+}
+INTDEF(__connect)
diff --git a/ports/sysdeps/unix/sysv/aix/creat.c b/ports/sysdeps/unix/sysv/aix/creat.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/creat.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/dl-addr.c b/ports/sysdeps/unix/sysv/aix/dl-addr.c
new file mode 100644
index 000000000..b8dbddfe4
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/dl-addr.c
@@ -0,0 +1,30 @@
+/*
+ Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <ldsodefs.h>
+
+int
+internal_function
+_dl_addr (const void *address, Dl_info *info)
+{
+ return 0;
+}
+
diff --git a/ports/sysdeps/unix/sysv/aix/dl-close.c b/ports/sysdeps/unix/sysv/aix/dl-close.c
new file mode 100644
index 000000000..edd45851f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/dl-close.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <dlfcn.h>
+#include <dlldr.h>
+
+extern int _dl_numso;
+extern DL_SODATA *_dl_sotable;
+
+void
+_dl_close (void *handle)
+{
+ if ((int) handle < 0 || (int) handle >= _dl_numso || _dl_sotable == NULL)
+ {
+ errno = EINVAL;
+ return;
+ }
+
+ if (_dl_sotable[(int) handle].handle != 0)
+ __unload (_dl_sotable[(int) handle].handle);
+
+ _dl_sotable[(int) handle].index = 0;
+ _dl_sotable[(int) handle].dataorg = 0;
+ _dl_sotable[(int) handle].handle = 0;
+ _dl_sotable[(int) handle].type = 0;
+}
+
diff --git a/ports/sysdeps/unix/sysv/aix/dl-error.c b/ports/sysdeps/unix/sysv/aix/dl-error.c
new file mode 100644
index 000000000..9c6335b59
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/dl-error.c
@@ -0,0 +1,20 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+#include <elf/dl-error.c>
diff --git a/ports/sysdeps/unix/sysv/aix/dl-libc.c b/ports/sysdeps/unix/sysv/aix/dl-libc.c
new file mode 100644
index 000000000..69c627c19
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/dl-libc.c
@@ -0,0 +1,41 @@
+/* Handle loading and unloading shared objects for internal libc purposes.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <ldsodefs.h>
+
+void *
+__libc_dlopen (const char *name)
+{
+ return _dl_open (name, RTLD_LAZY, NULL);
+}
+
+void *
+__libc_dlsym (void *map, const char *name)
+{
+ return _dl_sym (map, name, NULL);
+}
+
+int
+__libc_dlclose (void *map)
+{
+ _dl_close (map);
+ return 0;
+}
diff --git a/ports/sysdeps/unix/sysv/aix/dl-open.c b/ports/sysdeps/unix/sysv/aix/dl-open.c
new file mode 100644
index 000000000..070471d51
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/dl-open.c
@@ -0,0 +1,133 @@
+/* Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <malloc.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <dlfcn.h>
+#include <dlldr.h>
+
+#define NUM_SHARED_OBJECTS 32
+
+int _dl_numso = NUM_SHARED_OBJECTS;
+DL_SODATA *_dl_sotable = NULL;
+
+void *
+_dl_open (const char *file, int mode, const void *caller)
+{
+ DL_SODATA *new_so;
+ void *handle;
+ int entry;
+ int bsize = _dl_numso * sizeof (DL_INFO);
+ DL_INFO *dl_info = malloc (bsize);
+
+ if (dl_info == NULL)
+ return NULL;
+
+ /* 1st time thru initial shared object data table. */
+ if (_dl_sotable == NULL)
+ {
+ _dl_sotable = (DL_SODATA *) calloc (_dl_numso, sizeof (DL_SODATA));
+ if (_dl_sotable == NULL)
+ return NULL;
+
+ __loadx (DL_POSTLOADQ, dl_info, bsize, NULL);
+ while (!(dl_info[0].dlinfo_xflags & DL_INFO_OK)
+ || dl_info[0].dlinfo_arraylen == 0)
+ {
+ bsize *= 2;
+ dl_info = realloc (dl_info, bsize);
+ if (dl_info == NULL)
+ return NULL;
+
+ __loadx (DL_POSTLOADQ, dl_info, bsize, NULL);
+ }
+ }
+
+ /* Validate mode bits. */
+ if (!(mode & RTLD_NOW) && !(mode & RTLD_LAZY))
+ {
+ free (dl_info);
+ errno = EINVAL;
+ return NULL;
+ }
+
+ /* Load the module. */
+ handle = (void *) __loadx (DL_LOAD | DL_LOAD_RTL | DL_LOAD_LDX1,
+ dl_info, bsize, file, NULL);
+ if (handle == NULL)
+ {
+ free (dl_info);
+ errno = EINVAL;
+ return NULL;
+ }
+
+ /* Was dl_info buffer to small to get info. */
+ while (!(dl_info[0].dlinfo_xflags & DL_INFO_OK)
+ || dl_info[0].dlinfo_arraylen == 0)
+ {
+ bsize *= 2;
+ dl_info = realloc (dl_info, bsize);
+ if (dl_info == NULL)
+ {
+ (void) __unload ((void *) handle);
+ errno = ENOMEM;
+ return NULL;
+ }
+ __loadx (DL_POSTLOADQ | DL_LOAD_RTL, dl_info, bsize, handle);
+ }
+
+ /* Get an empty entry in the shared object table. */
+ for (entry = 0; entry < _dl_numso; ++entry)
+ if (_dl_sotable[entry].type == 0)
+ break;
+
+ /* See if the table needs to be increased. */
+ if (entry == _dl_numso)
+ {
+ new_so = (DL_SODATA *) realloc (_dl_sotable,
+ _dl_numso * 2 * sizeof (DL_SODATA));
+ if (new_so == NULL)
+ return NULL;
+
+ memset (new_so + _dl_numso, '\0', _dl_numso * sizeof (DL_SODATA));
+ _dl_numso *= 2;
+ _dl_sotable = new_so;
+ }
+
+ /* See if this is syscall (look for /unix in file). */
+ if (strcmp ("/unix", file) == 0)
+ {
+ _dl_sotable[entry].index = dl_info[1].dlinfo_index;
+ _dl_sotable[entry].dataorg = dl_info[1].dlinfo_dataorg;
+ _dl_sotable[entry].handle = handle;
+ _dl_sotable[entry].type = DL_UNIX_SYSCALL;
+ }
+ else
+ {
+ _dl_sotable[entry].index = dl_info[1].dlinfo_index;
+ _dl_sotable[entry].dataorg = dl_info[1].dlinfo_dataorg;
+ _dl_sotable[entry].handle = handle;
+ _dl_sotable[entry].type = DL_GETSYM;
+ }
+
+ free (dl_info);
+ return (void *) entry;
+}
diff --git a/ports/sysdeps/unix/sysv/aix/dl-support.c b/ports/sysdeps/unix/sysv/aix/dl-support.c
new file mode 100644
index 000000000..6172c853d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/dl-support.c
@@ -0,0 +1,20 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+#include <elf/dl-support.c>
diff --git a/ports/sysdeps/unix/sysv/aix/dl-sym.c b/ports/sysdeps/unix/sysv/aix/dl-sym.c
new file mode 100644
index 000000000..3f48b12cd
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/dl-sym.c
@@ -0,0 +1,58 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <dlfcn.h>
+#include <dlldr.h>
+
+extern int _dl_numso;
+extern DL_SODATA *_dl_sotable;
+
+void *
+_dl_sym (void *handle, const char *symbol, void *who)
+{
+ void *rt_function;
+
+ if ((int) handle < 0 || (int) handle >= _dl_numso || _dl_sotable == NULL)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ switch (_dl_sotable[(int) handle].type)
+ {
+ case DL_UNIX_SYSCALL:
+ rt_function = (void *) __loadx (DL_UNIX_SYSCALL, (void *) symbol);
+ break;
+
+ case DL_GETSYM:
+ rt_function = (void *) __loadx (DL_GETSYM, (void *) symbol,
+ _dl_sotable[(int) handle].index,
+ _dl_sotable[(int) handle].dataorg);
+ break;
+
+ default:
+ errno = EINVAL;
+ return NULL;
+ }
+
+ return rt_function;
+}
diff --git a/ports/sysdeps/unix/sysv/aix/dlldr.h b/ports/sysdeps/unix/sysv/aix/dlldr.h
new file mode 100644
index 000000000..e0f3740d2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/dlldr.h
@@ -0,0 +1,111 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+/*
+
+ int __loadx(flag, module, arg1, arg2, arg3)
+
+ The __loadx() is a call to ld_loadutil() kernel function, which
+ does the real work. Note ld_loadutil() is not exported an cannot be
+ called directly from user space.
+
+ void *ld_loadutil() call is a utility function used for loader extensions
+ supporting run-time linking and dl*() functions.
+
+ void * - will return the modules entry point if it succeds of NULL
+ on failure.
+
+ int flag - the flag field performas a dual role: the top 8 bits specify
+ the work for __loadx() to perform, the bottom 8 bits are
+ used to pass flags to the work routines, all other bits are
+ reserved.
+
+*/
+
+#define DL_LOAD 0x1000000 /* __loadx(flag,buf, buf_len, filename, libr_path) */
+#define DL_POSTLOADQ 0x2000000 /* __loadx(flag,buf, buf_len, module_handle) */
+#define DL_EXECQ 0x3000000 /* __loadx(flag,buf, buf_len) */
+#define DL_EXITQ 0x4000000 /* __loadx(flag,buf, buf_len) */
+#define DL_PREUNLOADQ 0x5000000 /* __loadx(flag,buf, buf_len, module_handle) */
+#define DL_INIT 0x6000000 /* __loadx(flag,NULL) */
+#define DL_GETSYM 0x7000000 /* __loadx(flag,symbol, index, modules_data_origin) */
+#define DL_SETDEPEND 0x8000000 /* __loadx(flag,import_data_org, import_index, */
+ /* export_data_org, export_index) */
+#define DL_DELDEPEND 0x9000000 /* __loadx(flag,import_data_org, import_index, */
+ /* export_data_org, export_index) */
+#define DL_GLOBALSYM 0xA000000 /* __loadx(flag,symbol_name, ptr_to_rec_index, */
+ /* ptr_to_rec_data_org) */
+#define DL_UNIX_SYSCALL 0xB000000 /* __loadx(flag,syscall_symbol_name) */
+
+#define DL_FUNCTION_MASK 0xFF000000
+#define DL_SRCHDEPENDS 0x00100000
+#define DL_SRCHMODULE 0x00080000
+#define DL_SRCHLOADLIST 0x00040000
+#define DL_LOAD_LDX1 0x00040000
+#define DL_LOAD_RTL 0x00020000
+#define DL_HASHSTRING 0x00020000
+#define DL_INFO_OK 0x00010000
+#define DL_LOAD_DLINFO 0x00010000
+#define DL_UNLOADED 0x00020000
+
+typedef union _dl_info
+{
+ struct {
+ uint _xflags; /* flag bits in the array */
+ uint _size; /* size of this structure */
+ uint _arraylen; /* number of following elements */
+ } _dl_stat;
+ struct {
+ caddr_t _textorg; /* start of loaded program image */
+ caddr_t _dataorg; /* start of data instance */
+ uint _datasize; /* size of data instance */
+ ushort _index; /* index of this le in la_dynlist */
+ ushort _mflags; /* info about module from load() */
+ } _dl_array;
+} DL_INFO;
+
+#define dlinfo_xflags _dl_stat._xflags
+#define dlinfo_arraylen _dl_stat._arraylen
+#define dlinfo_size _dl_stat._size
+
+#define dlinfo_textorg _dl_array._textorg
+#define dlinfo_datasize _dl_array._datasize
+#define dlinfo_dataorg _dl_array._dataorg
+#define dlinfo_index _dl_array._index
+#define dlinfo_flags _dl_array._mflags
+
+#define DL_HAS_RTINIT 0x1 /* indicates the module __rtinit symbols */
+#define DL_IS_NEW 0x2 /* indicates that the module is newly loaded */
+
+struct _xArgs
+{
+ char *libpath;
+ DL_INFO *info;
+ uint infosize;
+};
+
+/* Shared Object DATA used for dl-open,dl-sym & dl-close support */
+typedef struct
+{
+ void *handle; /* handle for __loadx */
+ uint type; /* type of __loadx flag */
+ ushort index; /* dlinfo_index */
+ caddr_t dataorg; /* dlinfo_dataorg */
+} DL_SODATA;
+
diff --git a/ports/sysdeps/unix/sysv/aix/environ.c b/ports/sysdeps/unix/sysv/aix/environ.c
new file mode 100644
index 000000000..01e7ba828
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/environ.c
@@ -0,0 +1 @@
+/* We don't need to define environ, the kernel does it. */
diff --git a/ports/sysdeps/unix/sysv/aix/euidaccess.c b/ports/sysdeps/unix/sysv/aix/euidaccess.c
new file mode 100644
index 000000000..c666af5fd
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/euidaccess.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define ACC_SELF 0
+
+int
+euidaccess (const char *name, int type)
+{
+ return accessx (name, type, ACC_SELF);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/execve.c b/ports/sysdeps/unix/sysv/aix/execve.c
new file mode 100644
index 000000000..f8cc07d55
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/execve.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__execve (const char *path, char *const argv[], char *const envp[])
+{
+ return execve (path, argv, envp);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/fchdir.c b/ports/sysdeps/unix/sysv/aix/fchdir.c
new file mode 100644
index 000000000..9fe7e8bec
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/fchdir.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__fchdir (fd)
+ int fd;
+{
+ return fchdir (fd);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/fchmod.c b/ports/sysdeps/unix/sysv/aix/fchmod.c
new file mode 100644
index 000000000..d4f0ac958
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/fchmod.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/stat.h>
+
+int
+__fchmod (int fd, mode_t mode)
+{
+ return fchmod (fd, mode);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/fchown.c b/ports/sysdeps/unix/sysv/aix/fchown.c
new file mode 100644
index 000000000..64252c038
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/fchown.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__fchown (int fds, uid_t owner, gid_t group)
+{
+ return fchown (fds, owner, group);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/fcntl.c b/ports/sysdeps/unix/sysv/aix/fcntl.c
new file mode 100644
index 000000000..7f16cbe01
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/fcntl.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fcntl.h>
+#include <stdarg.h>
+
+extern int kfcntl (int fdes, int cmd, unsigned long int arg);
+
+int
+__fcntl (int fdes, int cmd, ...)
+{
+ va_list va;
+ int res;
+ unsigned long int arg;
+
+ va_start (va, cmd);
+ arg = va_arg (va, unsigned long int);
+
+ res = kfcntl (fdes, cmd, arg);
+
+ va_end (va);
+
+ return res;
+}
+libc_hidden_def (__fcntl)
+strong_alias (__fcntl, fcntl)
+strong_alias (__fcntl, __libc_fcntl)
+libc_hidden_def (__libc_fcntl)
diff --git a/ports/sysdeps/unix/sysv/aix/fdatasync.c b/ports/sysdeps/unix/sysv/aix/fdatasync.c
new file mode 100644
index 000000000..851f2e570
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/fdatasync.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+#define _FDATASYNC 0x00400000
+#define FDATASYNC _FDATASYNC
+
+extern int kfsync_range (int fd, int how, long long int off,
+ long long int len);
+
+int
+fdatasync (int fd)
+{
+ return kfsync_range (fd, FDATASYNC, 0, 0);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/fork.c b/ports/sysdeps/unix/sysv/aix/fork.c
new file mode 100644
index 000000000..478d4afad
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/fork.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+#undef __fork
+
+pid_t
+__fork (void)
+{
+ return kfork ();
+}
+libc_hidden_def (__fork)
+strong_alias (__fork, fork)
diff --git a/ports/sysdeps/unix/sysv/aix/fstatfs.c b/ports/sysdeps/unix/sysv/aix/fstatfs.c
new file mode 100644
index 000000000..3f531f2a8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/fstatfs.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/statfs.h>
+
+extern int fstatfs (int fd, struct statfs *buf);
+
+int
+__fstatfs (int fd, struct statfs *buf)
+{
+ return fstatfs (fd, buf);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/fsync.c b/ports/sysdeps/unix/sysv/aix/fsync.c
new file mode 100644
index 000000000..58734b6e8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/fsync.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+#define _FSYNC 0x00000010
+#define FFILESYNC _FSYNC
+
+extern int kfsync_range (int fd, int how, long long int off,
+ long long int len);
+
+int
+fsync (int fd)
+{
+ return kfsync_range (fd, FFILESYNC, 0, 0);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/ftruncate.c b/ports/sysdeps/unix/sysv/aix/ftruncate.c
new file mode 100644
index 000000000..758f2a423
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/ftruncate.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+extern int kftruncate (int fd, long long int length);
+
+int
+__ftruncate (int fd, off_t length)
+{
+ return kftruncate (fd, length);
+}
+strong_alias (__ftruncate, ftruncate)
diff --git a/ports/sysdeps/unix/sysv/aix/ftruncate64.c b/ports/sysdeps/unix/sysv/aix/ftruncate64.c
new file mode 100644
index 000000000..5e7e4be4c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/ftruncate64.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+extern int kftruncate (int fd, long long int length);
+
+int
+__ftruncate64 (int fd, off64_t length)
+{
+ return kftruncate (fd, length);
+}
+weak_alias (__ftruncate64, ftruncate64)
diff --git a/ports/sysdeps/unix/sysv/aix/fxstat.c b/ports/sysdeps/unix/sysv/aix/fxstat.c
new file mode 100644
index 000000000..1ba56f690
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/fxstat.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <sys/stat.h>
+
+#define STX_NORMAL 0x00
+
+extern int fstatx (int fd, struct stat *st, int len, int cmd);
+
+int
+__fxstat (int ver, int fd, struct stat *st)
+{
+ assert (ver == 0);
+ return fstatx (fd, st, sizeof (*st), STX_NORMAL);
+}
+hidden_def (__fxstat)
diff --git a/ports/sysdeps/unix/sysv/aix/fxstat64.c b/ports/sysdeps/unix/sysv/aix/fxstat64.c
new file mode 100644
index 000000000..5f75e070c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/fxstat64.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <sys/stat.h>
+
+#define STX_NORMAL 0x00
+#define STX_64 0x08
+
+extern int fstatx (int fd, struct stat64 *st, int len, int cmd);
+
+int
+__fxstat64 (int ver, int fd, struct stat64 *st)
+{
+ assert (ver == 0);
+ return fstatx (fd, st, sizeof (*st), STX_NORMAL | STX_64);
+}
+hidden_def (__fxstat64)
diff --git a/ports/sysdeps/unix/sysv/aix/getdents.c b/ports/sysdeps/unix/sysv/aix/getdents.c
new file mode 100644
index 000000000..ca896c332
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getdents.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <dirent.h>
+#include <sys/types.h>
+
+extern int getdirent (int fd, char *buf, size_t count);
+
+ssize_t
+__getdents (int fd, char *buf, size_t count)
+{
+ return getdirent (fd, buf, count);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/getegid.c b/ports/sysdeps/unix/sysv/aix/getegid.c
new file mode 100644
index 000000000..c24692502
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getegid.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+#define ID_EFFECTIVE 0x01
+
+
+gid_t
+__getegid (void)
+{
+ return getgidx (ID_EFFECTIVE);
+}
+strong_alias (__getegid, getegid)
diff --git a/ports/sysdeps/unix/sysv/aix/geteuid.c b/ports/sysdeps/unix/sysv/aix/geteuid.c
new file mode 100644
index 000000000..b0722134b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/geteuid.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+#define ID_EFFECTIVE 0x01
+
+
+uid_t
+__geteuid (void)
+{
+ return getuidx (ID_EFFECTIVE);
+}
+strong_alias (__geteuid, geteuid)
diff --git a/ports/sysdeps/unix/sysv/aix/getgid.c b/ports/sysdeps/unix/sysv/aix/getgid.c
new file mode 100644
index 000000000..8b102b137
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getgid.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+#define ID_REAL 2
+
+extern gid_t getgidx (int which);
+
+gid_t
+__getgid (void)
+{
+ return getgidx (ID_REAL);
+}
+strong_alias (__getgid, getgid)
diff --git a/ports/sysdeps/unix/sysv/aix/getgroups.c b/ports/sysdeps/unix/sysv/aix/getgroups.c
new file mode 100644
index 000000000..f7c813b19
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getgroups.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__getgroups (int size, gid_t list[])
+{
+ return getgroups (size, list);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/gethostname.c b/ports/sysdeps/unix/sysv/aix/gethostname.c
new file mode 100644
index 000000000..a42384059
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/gethostname.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__gethostname (name, len)
+ char *name;
+ size_t len;
+{
+ return gethostname (name, len);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/getpeername.c b/ports/sysdeps/unix/sysv/aix/getpeername.c
new file mode 100644
index 000000000..bec9bac2a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getpeername.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/socket.h>
+
+extern int ngetpeername (int s, void *uap_asa, int *uap_alen);
+
+int
+getpeername (int fd, __SOCKADDR_ARG addr, socklen_t *len)
+{
+ return ngetpeername (fd, addr.__sockaddr__, len);
+}
+weak_alias (getpeername,__getpeername)
diff --git a/ports/sysdeps/unix/sysv/aix/getpgid.c b/ports/sysdeps/unix/sysv/aix/getpgid.c
new file mode 100644
index 000000000..a6e75f3f9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getpgid.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+extern int kgetpgidx (pid_t pid);
+
+int
+__getgpid (pid_t pid)
+{
+ return kgetpgidx (pid);
+}
+libc_hidden_def (__getgpid)
+strong_alias (__getpgid, getpgid)
diff --git a/ports/sysdeps/unix/sysv/aix/getpgrp.c b/ports/sysdeps/unix/sysv/aix/getpgrp.c
new file mode 100644
index 000000000..ce37738be
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getpgrp.c
@@ -0,0 +1 @@
+/* This function is available as a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/getpid.c b/ports/sysdeps/unix/sysv/aix/getpid.c
new file mode 100644
index 000000000..8a74e22da
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getpid.c
@@ -0,0 +1,9 @@
+/* This is a system call. We only have to provide the wrapper. */
+#include <unistd.h>
+
+int
+__getpid (void)
+{
+ return getpid ();
+}
+libc_hidden_def (__getpid)
diff --git a/ports/sysdeps/unix/sysv/aix/getppid.c b/ports/sysdeps/unix/sysv/aix/getppid.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getppid.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/getpriority.c b/ports/sysdeps/unix/sysv/aix/getpriority.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getpriority.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/getrlimit.c b/ports/sysdeps/unix/sysv/aix/getrlimit.c
new file mode 100644
index 000000000..0699cec64
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getrlimit.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/resource.h>
+
+int
+__getrlimit (enum __rlimit_resource resource, struct rlimit *rlimits)
+{
+ return getrlimit (resource, rlimits);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/getrlimit64.c b/ports/sysdeps/unix/sysv/aix/getrlimit64.c
new file mode 100644
index 000000000..dd33ca9c7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getrlimit64.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/resource.h>
+
+int
+__getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
+{
+ return getrlimit64 (resource, rlimits);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/getrusage.c b/ports/sysdeps/unix/sysv/aix/getrusage.c
new file mode 100644
index 000000000..b578b75aa
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getrusage.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/resource.h>
+
+int
+__getrusage (who, usage)
+ enum __rusage_who who;
+ struct rusage *usage;
+{
+ return getrusage (who, usage);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/getsid.c b/ports/sysdeps/unix/sysv/aix/getsid.c
new file mode 100644
index 000000000..6994eb8dd
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getsid.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+extern int kgetsid (pid_t pid);
+
+int
+getsid (pid_t pid)
+{
+ return kgetsid (pid);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/getsockname.c b/ports/sysdeps/unix/sysv/aix/getsockname.c
new file mode 100644
index 000000000..ac1bf34fc
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getsockname.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/socket.h>
+
+extern int ngetsockname (int s, void *uap_asa, int *uap_alen);
+
+int
+__getsockname (int fd, __SOCKADDR_ARG addr, socklen_t *len)
+{
+ return ngetsockname (fd, addr.__sockaddr__, len);
+}
+
+weak_alias (__getsockname, getsockname)
diff --git a/ports/sysdeps/unix/sysv/aix/gettimeofday.c b/ports/sysdeps/unix/sysv/aix/gettimeofday.c
new file mode 100644
index 000000000..34a92eb39
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/gettimeofday.c
@@ -0,0 +1,98 @@
+/* Copyright (C) 1991,92,94,95,96,97,2001,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <time.h>
+#include <sys/time.h>
+
+#ifndef HAVE_GNU_LD
+# define __daylight daylight
+# define __timezone timezone
+# define __tzname tzname
+#endif
+
+#undef __gettimeofday
+
+extern int rtc_upper (void);
+extern int rtc_lower (void);
+
+/* Assembler Routines to access the timer registers */
+asm("\n\
+.rtc_upper: mfspr 3,4 # copy RTCU to return register\n\
+ blr\n\
+\n\
+.rtc_lower: mfspr 3,5 # copy RTCL to return register\n\
+ blr\n\
+");
+
+/* 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
+__gettimeofday (tv, tz)
+ struct timeval *tv;
+ struct timezone *tz;
+{
+ int ts, tl, tu;
+
+ if (tv == NULL)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ ts = rtc_upper (); /* Seconds. */
+ tl = rtc_lower (); /* Nanoseconds. */
+ tu = rtc_upper (); /* Check for a carry from. */
+ if (ts != tu) /* The lower reg to the upper. */
+ tl = rtc_lower (); /* Recover from the race condition. */
+
+ tv->tv_sec = (long int) (tu + (double) tl / 1000000000);
+ tv->tv_usec = (long int) ((double) tl / 1000);
+
+ if (tz != NULL)
+ {
+ const time_t timer = tv->tv_sec;
+ struct tm tm;
+ const struct tm *tmp;
+
+ 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];
+
+ tmp = localtime_r (&timer, &tm);
+
+ 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 (tmp == NULL)
+ return -1;
+ }
+
+ return 0;
+}
+
+INTDEF(__gettimeofday)
+weak_alias (__gettimeofday, gettimeofday)
diff --git a/ports/sysdeps/unix/sysv/aix/getuid.c b/ports/sysdeps/unix/sysv/aix/getuid.c
new file mode 100644
index 000000000..e042666fe
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/getuid.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+#define ID_REAL 2
+
+extern uid_t getuidx (int which);
+
+uid_t
+__getuid (void)
+{
+ return getuidx (ID_REAL);
+}
+strong_alias (__getuid, getuid)
diff --git a/ports/sysdeps/unix/sysv/aix/gnu/lib-names.h b/ports/sysdeps/unix/sysv/aix/gnu/lib-names.h
new file mode 100644
index 000000000..d41f822f1
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/gnu/lib-names.h
@@ -0,0 +1,31 @@
+#ifndef __GNU_LIB_NAMES_H
+#define __GNU_LIB_NAMES_H 1
+
+#define LIBBROKENLOCALE_SO "libBrokenLocale.a"
+#define LIBCRYPT_SO "libcrypt.a"
+#define LIBC_SO "libc.a"
+#define LIBDB1_SO "libdb1.a"
+#define LIBDB_SO "libdb.a"
+#define LIBDL_SO "libdl.a"
+#define LIBM_SO "libm.a"
+#define LIBNOVERSION_SO "libNoVersion.a"
+#define LIBNSL_SO "libnsl.a"
+#define LIBNSS1_COMPAT_SO "libnss1_compat.a"
+#define LIBNSS1_DB_SO "libnss1_db.a"
+#define LIBNSS1_DNS_SO "libnss1_dns.a"
+#define LIBNSS1_FILES_SO "libnss1_files.a"
+#define LIBNSS1_NIS_SO "libnss1_nis.a"
+#define LIBNSS_COMPAT_SO "libnss_compat.a"
+#define LIBNSS_DB_SO "libnss_db.a"
+#define LIBNSS_DNS_SO "libnss_dns.a"
+#define LIBNSS_FILES_SO "libnss_files.a"
+#define LIBNSS_HESIOD_SO "libnss_hesiod.a"
+#define LIBNSS_LDAP_SO "libnss_ldap.a"
+#define LIBNSS_NISPLUS_SO "libnss_nisplus.a"
+#define LIBNSS_NIS_SO "libnss_nis.a"
+#define LIBPTHREAD_SO "libpthread.a"
+#define LIBRESOLV_SO "libresolv.a"
+#define LIBRT_SO "librt.a"
+#define LIBUTIL_SO "libutil.a"
+
+#endif /* gnu/lib-names.h */
diff --git a/ports/sysdeps/unix/sysv/aix/init-first.c b/ports/sysdeps/unix/sysv/aix/init-first.c
new file mode 100644
index 000000000..24ef109dd
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/init-first.c
@@ -0,0 +1,103 @@
+/* Initialization code run first thing by the XCOFF startup code. AIX version.
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sysdep.h>
+#include <fpu_control.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <libc-internal.h>
+
+#ifndef SHARED
+# include <ldsodefs.h>
+# include "dl-osinfo.h"
+#endif
+
+extern void __libc_init (int, char **, char **);
+
+/* The function is called from assembly stubs the compiler can't see. */
+static void init (int, char **, char **) __attribute__ ((unused));
+
+/* Set nonzero if we have to be prepared for more then one libc being
+ used in the process. Safe assumption if initializer never runs. */
+int __libc_multiple_libcs attribute_hidden = 1;
+
+/* Remember the command line argument and enviroment contents for
+ later calls of initializers for dynamic libraries. */
+int __libc_argc attribute_hidden;
+char **__libc_argv attribute_hidden;
+
+
+static void
+init (int argc, char **argv, char **envp)
+{
+#ifdef USE_NONOPTION_FLAGS
+ extern void __getopt_clean_environment (char **);
+#endif
+ /* The next variable is only here to work around a bug in gcc <= 2.7.2.2.
+ If the address would be taken inside the expression the optimizer
+ would try to be too smart and throws it away. Grrr. */
+
+ /* XXX disable dl for now
+ __libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up; */
+
+ /* Save the command-line arguments. */
+ __libc_argc = argc;
+ __libc_argv = argv;
+ __environ = envp;
+
+#ifndef SHARED
+ __libc_init_secure ();
+#endif
+
+ __libc_init (argc, argv, envp);
+
+#ifdef USE_NONOPTION_FLAGS
+ /* This is a hack to make the special getopt in GNU libc working. */
+ __getopt_clean_environment (envp);
+#endif
+
+#ifdef SHARED
+ __libc_global_ctors ();
+#endif
+}
+
+#ifdef SHARED
+
+strong_alias (init, _init);
+
+extern void __libc_init_first (void);
+
+void
+__libc_init_first (void)
+{
+}
+
+#else
+extern void __libc_init_first (int argc, char **argv, char **envp);
+
+void
+__libc_init_first (int argc, char **argv, char **envp)
+{
+ init (argc, argv, envp);
+}
+#endif
diff --git a/ports/sysdeps/unix/sysv/aix/ioctl.c b/ports/sysdeps/unix/sysv/aix/ioctl.c
new file mode 100644
index 000000000..f47b699be
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/ioctl.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdarg.h>
+#include <sys/ioctl.h>
+
+extern int kioctl (int fdes, int cmd, unsigned long int arg,
+ unsigned long int ext);
+
+int
+__ioctl (int fdes, unsigned long int cmd, ...)
+{
+ va_list va;
+ int res;
+ unsigned long int arg;
+ unsigned long int ext;
+
+ va_start (va, cmd);
+ arg = va_arg (va, unsigned long int);
+ ext = va_arg (va, unsigned long int);
+
+ res = kioctl (fdes, cmd, arg, ext);
+
+ va_end (va);
+
+ return res;
+}
+strong_alias (__ioctl, ioctl)
diff --git a/ports/sysdeps/unix/sysv/aix/kernel_proto.h b/ports/sysdeps/unix/sysv/aix/kernel_proto.h
new file mode 100644
index 000000000..e9ad06dc3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/kernel_proto.h
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file contains prototypes for the "functions" exported by /unix
+ on AIX. */
+#include <sys/types.h>
+
+
+extern ssize_t kwrite (int, const void *, size_t);
diff --git a/ports/sysdeps/unix/sysv/aix/kill.c b/ports/sysdeps/unix/sysv/aix/kill.c
new file mode 100644
index 000000000..8538e29f8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/kill.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__kill (pid_t pid, int sig)
+{
+ return kill (pid, sig);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/lchown.c b/ports/sysdeps/unix/sysv/aix/lchown.c
new file mode 100644
index 000000000..44e3b749e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/lchown.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__lchown (const char *file, uid_t owner, gid_t group)
+{
+ return lchown (file, owner, group);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/libc-start.c b/ports/sysdeps/unix/sysv/aix/libc-start.c
new file mode 100644
index 000000000..813e28d09
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/libc-start.c
@@ -0,0 +1,290 @@
+/* Initialization code run first thing by the XCOFF startup code. AIX version.
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* hack to use uchar's */
+typedef unsigned char uchar;
+#include <xcoff.h>
+#include <rtinit.h>
+#include <dlldr.h>
+#include <bits/libc-lock.h>
+
+extern void __libc_init_first (int argc, char **argv, char **envp);
+
+/* XXX disable for now
+extern int __libc_multiple_libcs; */
+
+/* XXX normally defined in generic/dl-sydep.c, hack it into existance
+extern void *__libc_stack_end; */
+void *__libc_stack_end;
+
+ struct __libc_start_data_rec {
+ void *stack;
+ void *toc;
+ int argc;
+ char **argv;
+ char **envp;
+ char *data;
+ char *text;
+ unsigned mcount;
+ unsigned special;
+ int (*main)(int, char **, char **);
+ void (*init)(void);
+ void (*fini)(void);
+ void (*rtld_fini)(void);
+ };
+
+extern struct __libc_start_data_rec __libc_start_data;
+extern int errno;
+
+/* The first piece of initialized data. */
+int __data_start = 0;
+
+#ifndef HAVE_ELF
+/* Since gcc/crtstuff.c won't define it unless the ELF format is used
+ we will need to define it here. */
+void *__dso_handle = NULL;
+#endif
+
+/* AIX kernel function */
+extern int __loadx (int flag, void *module, void *arg1, void *arg2,
+ void *arg3);
+/* Needed by setenv */
+char **__environ;
+
+/*
+ * Find __rtinit symbol
+ *
+ * __RTINIT *find_rtinit()
+ *
+ * __RTINIT *rti - pointer to __rtinit data structure
+ */
+
+static __RTINIT *
+find_rtinit (void)
+{
+ struct xcoffhdr *xcoff_hdr;
+ SCNHDR *sec_hdr;
+ SCNHDR *ldr_sec_hdr;
+ SCNHDR *data_sec_hdr;
+ LDSYM *ldsym_hdr;
+ __RTINIT *rtl;
+
+ xcoff_hdr = (struct xcoffhdr *) __libc_start_data.text;
+ sec_hdr = (SCNHDR *) ((caddr_t) &xcoff_hdr->aouthdr
+ + xcoff_hdr->filehdr.f_opthdr);
+ ldr_sec_hdr = (SCNHDR *) (sec_hdr + (xcoff_hdr->aouthdr.o_snloader - 1));
+ ldsym_hdr = (LDSYM *) ((caddr_t) xcoff_hdr + ldr_sec_hdr->s_scnptr
+ + LDHDRSZ);
+
+ if (__libc_start_data.mcount <= 0)
+ {
+ if (!ldr_sec_hdr->s_scnptr)
+ return NULL;
+
+ if (memcmp (ldsym_hdr, RTINIT_NAME, sizeof(RTINIT_NAME) - 1) != 0)
+ return NULL;
+ }
+
+ data_sec_hdr = (SCNHDR *) (sec_hdr + (xcoff_hdr->aouthdr.o_sndata - 1));
+ rtl = (__RTINIT *) (ldsym_hdr->l_value
+ + (__libc_start_data.data - data_sec_hdr->s_vaddr));
+ return rtl;
+}
+
+/* The mod_init1 calls every initialization function
+ for a given module.
+
+ void mod_init1(handler, rti)
+
+ void *handler - if NULL init funtions for modules loaded at exec time
+ are being executed. Otherwise, the handler points to the
+ module loaded.
+
+ __RTINIT *rti - pointer to __rtinit data structure (with rti->init_offset
+ not equal to zero)
+ */
+
+static void
+mod_init1 (void *handler,__RTINIT *rtl)
+{
+ __RTINIT_DESCRIPTOR *descriptor;
+
+ descriptor = (__RTINIT_DESCRIPTOR *) ((caddr_t) &rtl->rtl
+ + rtl->init_offset);
+ while (descriptor->f != NULL)
+ {
+ if (!(descriptor->flags & _RT_CALLED))
+ {
+ descriptor->flags |= _RT_CALLED;
+ /* Execute init/fini. */
+ descriptor->f (handler, rtl, descriptor);
+ }
+ descriptor = (__RTINIT_DESCRIPTOR *) ((caddr_t) descriptor
+ + rtl->__rtinit_descriptor_size);
+ }
+}
+
+/* The modinit() function performs run-time linking, if enabled, and calling
+ the init() function for all loaded modules.
+
+ int modinit()
+ */
+
+#define DL_BUFFER_SIZE 1000
+
+static int
+modinit (void)
+{
+ int *handler = NULL;
+ __RTINIT *rtinit_info = NULL;
+ int flag;
+ DL_INFO dl_buffer[DL_BUFFER_SIZE];
+ DL_INFO *dl_info = dl_buffer;
+ int i;
+
+ /* Find __rtinit symbols */
+ rtinit_info = find_rtinit ();
+
+ flag = DL_EXECQ;
+ if (rtinit_info && rtinit_info->rtl)
+ flag |= DL_LOAD_RTL;
+
+ /* Get a list of modules that have __rtinit. */
+ if (__loadx (flag, dl_info, (void *) sizeof (dl_buffer), NULL, NULL))
+ exit (0x90);
+
+ if (( dl_info[0].dlinfo_xflags & DL_INFO_OK))
+ {
+ rtinit_info = find_rtinit ();
+ if ((rtinit_info != NULL) & (rtinit_info->rtl != NULL))
+ {
+ if ((*rtinit_info->rtl) (dl_info, 0))
+ exit (0x90);
+ }
+ }
+
+ /* Initialization each module loaded that has __rtinit. */
+ if (dl_info[0].dlinfo_xflags & DL_INFO_OK)
+ {
+ for (i = 1; i < dl_info[0].dlinfo_arraylen + 1; ++i)
+ if (dl_info[i].dlinfo_flags & DL_HAS_RTINIT)
+ {
+ rtinit_info = find_rtinit ();
+ if (rtinit_info)
+ mod_init1 (handler, rtinit_info);
+ }
+ }
+
+ return 0;
+}
+
+
+void
+__libc_start_init (void)
+{
+ /* Do run-time linking, if enabled and call the init()
+ for all loaded modules. */
+ if (__libc_start_data.mcount != __libc_start_data.special)
+ modinit ();
+}
+
+/* For now these are just stubs. */
+void
+__libc_start_fini (void)
+{
+}
+
+void
+__libc_start_rtld_fini (void)
+{
+}
+
+void
+__libc_start_main (void)
+{
+#ifndef SHARED
+
+ /* The next variable is only here to work around a bug in gcc <= 2.7.2.2.
+ If the address would be taken inside the expression the optimizer
+ would try to be too smart and throws it away. Grrr. */
+
+ /* XXX disable for now
+ int *dummy_addr = &_dl_starting_up;
+
+ __libc_multiple_libcs = dummy_addr && !_dl_starting_up; */
+#endif
+
+ /* Store the lowest stack address. */
+ __libc_stack_end = __libc_start_data.stack;
+
+ /* Used by setenv */
+ __environ = __libc_start_data.envp;
+
+#ifndef SHARED
+ /* Clear errno. */
+ errno = 0;
+
+ /* Some security at this point. Prevent starting a SUID binary where
+ the standard file descriptors are not opened. We have to do this
+ only for statically linked applications since otherwise the dynamic
+ loader did the work already. */
+ if (__builtin_expect (__libc_enable_secure, 0))
+ __libc_check_standard_fds ();
+
+#endif
+
+ /* Register the destructor of the dynamic linker if there is any. */
+ if (__builtin_expect (__libc_start_data.rtld_fini != NULL, 1))
+ __cxa_atexit ((void (*) (void *)) __libc_start_data.rtld_fini, NULL, NULL);
+
+ /* Call the initializer of the libc. This is only needed here if we
+ are compiling for the static library in which case we haven't
+ run the constructors in `_dl_start_user'. */
+#ifndef SHARED
+ __libc_init_first (__libc_start_data.argc, __libc_start_data.argv,
+ __libc_start_data.envp);
+#endif
+
+ /* Register the destructor of the program, if any. */
+ if (__libc_start_data.fini)
+ __cxa_atexit ((void (*) (void *)) __libc_start_data.fini, NULL, NULL);
+
+ /* Call the initializer of the program, if any. */
+#ifdef SHARED
+ if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
+ _dl_debug_printf ("\ninitialize program: %s\n\n",
+ __libc_start_data.argv[0]);
+#endif
+ if (__libc_start_data.init)
+ (*__libc_start_data.init) ();
+
+#ifdef SHARED
+ if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
+ _dl_debug_printf ("\ntransferring control: %s\n\n",
+ __libc_start_data.argv[0]);
+#endif
+
+ exit ((*__libc_start_data.main) (__libc_start_data.argc,
+ __libc_start_data.argv,
+ __libc_start_data.envp));
+}
diff --git a/ports/sysdeps/unix/sysv/aix/link.c b/ports/sysdeps/unix/sysv/aix/link.c
new file mode 100644
index 000000000..2cacbebc3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/link.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__link (from, to)
+ const char *from;
+ const char *to;
+{
+ return link (from, to);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/lockf.c b/ports/sysdeps/unix/sysv/aix/lockf.c
new file mode 100644
index 000000000..4a8c14fd6
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/lockf.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+extern int klockf (int fd, int function, long long int size);
+
+int
+lockf (int fd, int cmd, off_t len)
+{
+ return klockf (fd, cmd, len);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/lockf64.c b/ports/sysdeps/unix/sysv/aix/lockf64.c
new file mode 100644
index 000000000..529c2b447
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/lockf64.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+extern int klockf (int fd, int function, long long int size);
+
+int
+lockf64 (int fd, int cmd, off64_t len)
+{
+ return klockf (fd, cmd, len);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/lseek.c b/ports/sysdeps/unix/sysv/aix/lseek.c
new file mode 100644
index 000000000..d4cbdbe70
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/lseek.c
@@ -0,0 +1,10 @@
+/* This is a system call. We only have to provide the wrapper. */
+#include <unistd.h>
+
+off_t
+__lseek (int fd, off_t offset, int whence)
+{
+ return lseek (fd, offset, whence);
+}
+strong_alias (__lseek, __libc_lseek)
+libc_hidden_def (__lseek)
diff --git a/ports/sysdeps/unix/sysv/aix/lseek64.c b/ports/sysdeps/unix/sysv/aix/lseek64.c
new file mode 100644
index 000000000..5892663d8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/lseek64.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+extern int klseek (int fd, long long int offset, int sbase,
+ long long int *new_offp);
+
+off64_t
+__libc_lseek64 (int fd, off64_t offset, int whence)
+{
+ long long int res;
+
+ if (klseek (fd, offset, whence, &res) < 0)
+ res = -1ll;
+
+ return res;
+}
+strong_alias (__libc_lseek64, __lseek64)
+strong_alias (__libc_lseek64, lseek64)
diff --git a/ports/sysdeps/unix/sysv/aix/lxstat.c b/ports/sysdeps/unix/sysv/aix/lxstat.c
new file mode 100644
index 000000000..879e80cbe
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/lxstat.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <sys/stat.h>
+
+#define STX_LINK 0x01
+
+extern int statx (const char *pathname, struct stat *st, int len, int cmd);
+
+int
+__lxstat (int ver, const char *pathname, struct stat *st)
+{
+ assert (ver == 0);
+ return statx (pathname, st, sizeof (*st), STX_LINK);
+}
+hidden_def (__lxstat)
diff --git a/ports/sysdeps/unix/sysv/aix/lxstat64.c b/ports/sysdeps/unix/sysv/aix/lxstat64.c
new file mode 100644
index 000000000..73324fe55
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/lxstat64.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <sys/stat.h>
+
+#define STX_LINK 0x01
+#define STX_64 0x08
+
+extern int statx (const char *pathname, struct stat64 *st, int len, int cmd);
+
+int
+__lxstat64 (int ver, const char *pathname, struct stat64 *st)
+{
+ assert (ver == 0);
+ return statx (pathname, st, sizeof (*st), STX_LINK | STX_64);
+}
+hidden_def (__lxstat64)
diff --git a/ports/sysdeps/unix/sysv/aix/madvise.c b/ports/sysdeps/unix/sysv/aix/madvise.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/madvise.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/mkdir.c b/ports/sysdeps/unix/sysv/aix/mkdir.c
new file mode 100644
index 000000000..4a4e5ceef
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/mkdir.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/stat.h>
+
+int
+__mkdir (const char *name, mode_t mode)
+{
+ return mkdir (name, mode);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/mknod.c b/ports/sysdeps/unix/sysv/aix/mknod.c
new file mode 100644
index 000000000..8ed3d6b53
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/mknod.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/stat.h>
+
+int
+__mknod (path, mode, device)
+ const char *path;
+ mode_t mode;
+ dev_t device;
+{
+ return mknod (path, mode, device);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/mmap.c b/ports/sysdeps/unix/sysv/aix/mmap.c
new file mode 100644
index 000000000..cd967d36b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/mmap.c
@@ -0,0 +1,9 @@
+/* This is a system call. We only have to provide the wrapper. */
+#include <sys/mman.h>
+#include <sys/types.h>
+
+void *
+__mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset)
+{
+ return mmap (addr, len, prot, flags, fd, offset);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/mmap64.c b/ports/sysdeps/unix/sysv/aix/mmap64.c
new file mode 100644
index 000000000..ae70ef4ac
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/mmap64.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/mman.h>
+#include <sys/types.h>
+
+extern int kmmap (void *addr, size_t len, int prot, int flags, int fd,
+ long long int offset);
+
+void *
+__mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset)
+{
+ return kmmap (addr, len, prot, flags, fd, offset);
+}
+strong_alias (__mmap64, mmap64)
diff --git a/ports/sysdeps/unix/sysv/aix/mprotect.c b/ports/sysdeps/unix/sysv/aix/mprotect.c
new file mode 100644
index 000000000..8bf95abb0
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/mprotect.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/mman.h>
+
+int
+__mprotect (void *addr, size_t len, int prot)
+{
+ return mprotect (addr, len, prot);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/msgctl.c b/ports/sysdeps/unix/sysv/aix/msgctl.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/msgctl.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/msgget.c b/ports/sysdeps/unix/sysv/aix/msgget.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/msgget.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/msgrcv.c b/ports/sysdeps/unix/sysv/aix/msgrcv.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/msgrcv.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/msgsnd.c b/ports/sysdeps/unix/sysv/aix/msgsnd.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/msgsnd.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/msync.c b/ports/sysdeps/unix/sysv/aix/msync.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/msync.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/munmap.c b/ports/sysdeps/unix/sysv/aix/munmap.c
new file mode 100644
index 000000000..7f583be35
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/munmap.c
@@ -0,0 +1,8 @@
+/* This is a system call. We only have to provide the wrapper. */
+#include <sys/mman.h>
+
+int
+__munmap (void *addr, size_t len)
+{
+ return munmap (addr, len);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/nanosleep.c b/ports/sysdeps/unix/sysv/aix/nanosleep.c
new file mode 100644
index 000000000..842275f77
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/nanosleep.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <sys/time.h>
+#include <sys/types.h>
+
+struct timestruc_t
+{
+ time_t tv_sec; /* seconds. */
+ suseconds_t tv_nsec; /* and nanoseconds. */
+};
+
+
+extern int _nsleep (struct timestruc_t *rqtp, struct timestruc_t *rmtp);
+
+int
+__libc_nanosleep (const struct timespec *req, struct timespec *rem)
+{
+ assert (sizeof (struct timestruc_t) == sizeof (*req));
+ return _nsleep ((struct timestruc_t *) req, (struct timestruc_t *) rem);
+}
+strong_alias (__libc_nanosleep, __nanosleep)
+libc_hidden_def (__nanosleep)
+strong_alias (__libc_nanosleep, nanosleep)
diff --git a/ports/sysdeps/unix/sysv/aix/net/if.h b/ports/sysdeps/unix/sysv/aix/net/if.h
new file mode 100644
index 000000000..20256d3ad
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/net/if.h
@@ -0,0 +1,196 @@
+/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _NET_IF_H
+
+#define _NET_IF_H 1
+#include <features.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+/* Standard interface flags. */
+enum
+ {
+ IFF_UP = 0x1, /* Interface is up. */
+#define IFF_UP IFF_UP
+ IFF_BROADCAST = 0x2, /* Broadcast address valid. */
+#define IFF_BROADCAST IFF_BROADCAST
+ IFF_DEBUG = 0x4, /* Turn on debugging. */
+#define IFF_DEBUG IFF_DEBUG
+ IFF_LOOPBACK = 0x8, /* Is a loopback net. */
+#define IFF_LOOPBACK IFF_LOOPBACK
+ IFF_POINTOPOINT = 0x10, /* Interface is point-to-point link. */
+#define IFF_POINTOPOINT IFF_POINTOPOINT
+ IFF_NOTRAILERS = 0x20, /* Avoid use of trailers. */
+#define IFF_NOTRAILERS IFF_NOTRAILERS
+ IFF_RUNNING = 0x40, /* Resources allocated. */
+#define IFF_RUNNING IFF_RUNNING
+ IFF_NOARP = 0x80, /* No address resolution protocol. */
+#define IFF_NOARP IFF_NOARP
+ IFF_PROMISC = 0x100, /* Receive all packets. */
+#define IFF_PROMISC IFF_PROMISC
+
+ /* Not supported */
+ IFF_ALLMULTI = 0x200, /* Receive all multicast packets. */
+#define IFF_ALLMULTI IFF_ALLMULTI
+
+ IFF_OACTIVE = 0x400, /* Transmission in progress. */
+#define IFF_OACTIVE IFF_OACTIVE
+ IFF_SIMPLEX = 0x800, /* Cannot hear own transmissions. */
+#define IFF_SIMPLEX IFF_SIMPLEX
+ IFF_DO_HW_LOOPBACK = 0x10000, /* Force loopback through hardware. */
+#define IFF_DO_HW_LOOPBACK IFF_DO_HW_LOOPBACK
+ IFF_ALLCAST = 0x20000, /* Global broadcast. */
+#define IFF_ALLCAST IFF_ALLCAST
+ IFF_BRIDGE = 0x40000, /* Receive all bridge packets. */
+#define IFF_BRIDGE IFF_BRIDGE
+ IFF_NOECHO = IFF_SIMPLEX, /* Reeives echo packets. */
+#define IFF_NOECHO IFF_NOECHO
+ };
+
+/* The ifaddr structure contains information about one address of an
+ interface. They are maintained by the different address families,
+ are allocated and attached when an address is set, and are linked
+ together so all addresses for an interface can be located. */
+
+struct ifaddr
+ {
+ struct sockaddr ifa_addr; /* Address of interface. */
+ union
+ {
+ struct sockaddr ifu_broadaddr;
+ struct sockaddr ifu_dstaddr;
+ } ifa_ifu;
+ struct sockaddr *ifa_netmask; /* Used to determine subnet. */
+ struct iface *ifa_ifp; /* Back-pointer to interface. */
+ struct ifaddr *ifa_next; /* Next address for interface. */
+ void (*ifa_rtrequest) (void);
+ struct rtentry *ifa_rt;
+ unsigned short int ifa_flags;
+ short int ifa_refcnt;
+ };
+
+#define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */
+#define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of link */
+
+/* Interface request structure used for socket ioctl's. All interface
+ ioctl's must have parameter definitions which begin with ifr_name.
+ The remainder may be interface specific. */
+
+struct ifreq
+ {
+#define IFHWADDRLEN 6
+#define IFNAMSIZ 16
+ union
+ {
+ char ifrn_name[IFNAMSIZ]; /* Interface name, e.g. "en0". */
+ } ifr_ifrn;
+
+ union
+ {
+ struct sockaddr ifru_addr;
+ struct sockaddr ifru_dstaddr;
+ struct sockaddr ifru_broadaddr;
+ struct sockaddr ifru_netmask;
+ struct sockaddr ifru_hwaddr;
+ short int ifru_flags;
+ int ifru_ivalue;
+ unsigned int ifru_mtu;
+ char ifru_slave[IFNAMSIZ]; /* Just fits the size */
+ __caddr_t ifru_data;
+ unsigned short int ifru_site6;
+ } ifr_ifru;
+ };
+
+/* Old AIX 3.1 version. */
+struct oifreq
+{
+ char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
+ union
+ {
+ struct sockaddr ifru_addr;
+ struct sockaddr ifru_dstaddr;
+ struct sockaddr ifru_broadaddr;
+ int ifru_flags;
+ int ifru_metric;
+ caddr_t ifru_data;
+ unsigned int ifru_mtu;
+ } ifr_ifru;
+ unsigned char reserved[8];
+};
+
+
+#define ifr_name ifr_ifrn.ifrn_name /* interface name */
+#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
+#define ifr_addr ifr_ifru.ifru_addr /* address */
+#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */
+#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
+#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */
+#define ifr_flags ifr_ifru.ifru_flags /* flags */
+#define ifr_metric ifr_ifru.ifru_ivalue /* metric */
+#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
+#define ifr_slave ifr_ifru.ifru_slave /* slave device */
+#define ifr_data ifr_ifru.ifru_data /* for use by interface */
+#define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */
+#define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */
+#define ifr_baudrate ifr_ifru.ifru_ivalue /* link bandwidth */
+#define ifr_qlen ifr_ifru.ifru_ivalue /* queue length */
+#define ifr_site6 ifr_ifru.ifru_site6 /* IPv6 site index */
+
+
+/* Structure used in SIOCGIFCONF request. Used to retrieve interface
+ configuration for machine (useful for programs which must know all
+ networks accessible). */
+
+struct ifconf
+ {
+ int ifc_len; /* Size of buffer. */
+ union
+ {
+ __caddr_t ifcu_buf;
+ struct ifreq *ifcu_req;
+ } ifc_ifcu;
+ };
+#define ifc_buf ifc_ifcu.ifcu_buf /* Buffer address. */
+#define ifc_req ifc_ifcu.ifcu_req /* Array of structures. */
+
+__BEGIN_DECLS
+
+/* Convert an interface name to an index, and vice versa. */
+
+extern unsigned int if_nametoindex (__const char *__ifname) __THROW;
+extern char *if_indextoname (unsigned int __ifindex, char *__ifname) __THROW;
+
+/* Return a list of all interfaces and their indices. */
+
+struct if_nameindex
+ {
+ unsigned int if_index; /* 1, 2, ... */
+ char *if_name; /* null terminated name: "eth0", ... */
+ };
+
+extern struct if_nameindex *if_nameindex (void) __THROW;
+
+/* Free the data returned from if_nameindex. */
+
+extern void if_freenameindex (struct if_nameindex *__ptr) __THROW;
+
+__END_DECLS
+
+#endif /* net/if.h */
diff --git a/ports/sysdeps/unix/sysv/aix/open.c b/ports/sysdeps/unix/sysv/aix/open.c
new file mode 100644
index 000000000..2b42f8e81
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/open.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fcntl.h>
+#include <stdarg.h>
+#include <unistd.h>
+
+int
+__open (const char *file, int oflag, ...)
+{
+ int mode = 0;
+
+ if (oflag & O_CREAT)
+ {
+ va_list arg;
+ va_start (arg, oflag);
+ mode = va_arg (arg, int);
+ va_end (arg);
+ }
+
+ return open (file, oflag, mode);
+}
+libc_hidden_def (__open)
+strong_alias (__open, __libc_open)
+libc_hidden_def (__libc_open)
diff --git a/ports/sysdeps/unix/sysv/aix/pipe.c b/ports/sysdeps/unix/sysv/aix/pipe.c
new file mode 100644
index 000000000..4a3ba1c04
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/pipe.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__pipe (pipedes)
+ int pipedes[2];
+{
+ return pipe (pipedes);
+}
+libc_hidden_def (__pipe)
diff --git a/ports/sysdeps/unix/sysv/aix/poll.c b/ports/sysdeps/unix/sysv/aix/poll.c
new file mode 100644
index 000000000..5ce540991
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/poll.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/poll.h>
+
+int
+__poll (fds, nfds, timeout)
+ struct pollfd *fds;
+ nfds_t nfds;
+ int timeout;
+{
+ return poll (fds, nfds, timeout);
+}
+libc_hidden_def (__poll)
diff --git a/ports/sysdeps/unix/sysv/aix/posix_madvise.c b/ports/sysdeps/unix/sysv/aix/posix_madvise.c
new file mode 100644
index 000000000..7ab4bed8e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/posix_madvise.c
@@ -0,0 +1,8 @@
+#include <errno.h>
+#include <sys/mman.h>
+
+int
+posix_madvise (void *addr, size_t len, int advise)
+{
+ return madvise (addr, len, advise) ? errno : 0;
+}
diff --git a/ports/sysdeps/unix/sysv/aix/powerpc/memset.c b/ports/sysdeps/unix/sysv/aix/powerpc/memset.c
new file mode 100644
index 000000000..352db1308
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/powerpc/memset.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2001, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+/* Until the cache line issues are resolved use the generic implementation. */
+#include <string/memset.c>
diff --git a/ports/sysdeps/unix/sysv/aix/powerpc/register-dump.h b/ports/sysdeps/unix/sysv/aix/powerpc/register-dump.h
new file mode 100644
index 000000000..f0d8b9983
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/powerpc/register-dump.h
@@ -0,0 +1,281 @@
+/* Dump registers.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/uio.h>
+#include <stdio-common/_itoa.h>
+#include <sys/ucontext.h>
+
+/* We will print the register dump in this format:
+
+Register dump:
+fp0-3: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
+fp4-7: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
+fp8-11: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
+fp12-15: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
+fp16-19: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
+fp20-23: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
+fp24-27: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
+fp28-31: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
+
+r00-07 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
+r08-15 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
+r16-23 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
+r24-31 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
+
+ trap 00000000 iar 00000000 msr 00000000 cr 00000000
+ lr 00000000 ctr 00000000 xer 00000000 mq 00000000
+ tid 00000000 fpscr 00000000
+
+*/
+
+
+static void
+hexvalue (unsigned long int value, char *buf, size_t len)
+{
+ char *cp = _itoa_word (value, buf + len, 16, 0);
+ while (cp > buf)
+ *--cp = '0';
+}
+
+
+static void
+register_dump (int fd, struct sigcontext *ctx)
+{
+ char regs[108][8];
+ struct iovec iov[38];
+ struct __mstsafe *reg_state;
+ int i;
+ int ii;
+ size_t nr = 0;
+
+#define ADD_STRING(str) \
+ iov[nr].iov_base = (char *) str; \
+ iov[nr].iov_len = strlen (str); \
+ ++nr
+#define ADD_MEM(str, len) \
+ iov[nr].iov_base = str; \
+ iov[nr].iov_len = len; \
+ ++nr
+
+ reg_state = (struct __mstsafe *)&ctx->sc_jmpbuf.__jmp_context;
+
+ hexvalue (reg_state->__excp_type, regs[0], 8);
+ hexvalue (reg_state->__iar, regs[1], 8);
+ hexvalue (reg_state->__msr, regs[2], 8);
+ hexvalue (reg_state->__cr, regs[3], 8);
+ hexvalue (reg_state->__lr, regs[4], 8);
+ hexvalue (reg_state->__ctr, regs[5], 8);
+ hexvalue (reg_state->__xer, regs[6], 8);
+ hexvalue (reg_state->__mq, regs[7], 8);
+ hexvalue (reg_state->__tid, regs[8], 8);
+ hexvalue (reg_state->__fpscr, regs[9], 8);
+
+ ii=10;
+ for (i = 0; i <= 96; i++,ii++)
+ hexvalue (reg_state->__gpr[i], regs[ii], 8);
+
+ /* Generate the output. */
+ ADD_STRING ("Register dump:\n\nfp0-3: ");
+ ADD_MEM (regs[42], 8);
+ ADD_MEM (regs[43], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[44], 8);
+ ADD_MEM (regs[45], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[46], 8);
+ ADD_MEM (regs[47], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[48], 8);
+ ADD_MEM (regs[49], 8);
+ ADD_STRING ("\nfp4-7: ");
+ ADD_MEM (regs[50], 8);
+ ADD_MEM (regs[51], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[52], 8);
+ ADD_MEM (regs[53], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[54], 8);
+ ADD_MEM (regs[55], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[56], 8);
+ ADD_MEM (regs[57], 8);
+ ADD_STRING ("\nfp8-11: ");
+ ADD_MEM (regs[58], 8);
+ ADD_MEM (regs[59], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[60], 8);
+ ADD_MEM (regs[61], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[62], 8);
+ ADD_MEM (regs[63], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[64], 8);
+ ADD_MEM (regs[65], 8);
+ ADD_STRING ("\nfp12-15: ");
+ ADD_MEM (regs[66], 8);
+ ADD_MEM (regs[67], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[68], 8);
+ ADD_MEM (regs[69], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[70], 8);
+ ADD_MEM (regs[71], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[72], 8);
+ ADD_MEM (regs[73], 8);
+ ADD_STRING ("\nfp16-19: ");
+ ADD_MEM (regs[74], 8);
+ ADD_MEM (regs[75], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[76], 8);
+ ADD_MEM (regs[78], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[79], 8);
+ ADD_MEM (regs[80], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[81], 8);
+ ADD_MEM (regs[82], 8);
+ ADD_STRING ("\nfp20-23: ");
+ ADD_MEM (regs[83], 8);
+ ADD_MEM (regs[84], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[85], 8);
+ ADD_MEM (regs[86], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[87], 8);
+ ADD_MEM (regs[88], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[89], 8);
+ ADD_MEM (regs[90], 8);
+ ADD_STRING ("\nfp24-27: ");
+ ADD_MEM (regs[91], 8);
+ ADD_MEM (regs[92], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[93], 8);
+ ADD_MEM (regs[94], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[95], 8);
+ ADD_MEM (regs[96], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[97], 8);
+ ADD_MEM (regs[98], 8);
+ ADD_STRING ("\nfp28-31: ");
+ ADD_MEM (regs[99], 8);
+ ADD_MEM (regs[100], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[101], 8);
+ ADD_MEM (regs[102], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[103], 8);
+ ADD_MEM (regs[104], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[105], 8);
+ ADD_MEM (regs[106], 8);
+ ADD_STRING ("\n\nr00-07 ");
+ ADD_MEM (regs[10], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[11], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[12], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[13], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[14], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[15], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[16], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[17], 8);
+ ADD_STRING ("\nr08-15 ");
+ ADD_MEM (regs[18], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[19], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[20], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[21], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[22], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[23], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[24], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[25], 8);
+ ADD_STRING ("\nr16-23 ");
+ ADD_MEM (regs[26], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[27], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[28], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[29], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[30], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[31], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[32], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[33], 8);
+ ADD_STRING ("\nr24-31 ");
+ ADD_MEM (regs[34], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[35], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[36], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[37], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[38], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[39], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[40], 8);
+ ADD_STRING (" ");
+ ADD_MEM (regs[41], 8);
+ ADD_STRING ("\n\n trap ");
+ ADD_MEM (regs[0], 8);
+ ADD_STRING (" iar ");
+ ADD_MEM (regs[1], 8);
+ ADD_STRING (" msr ");
+ ADD_MEM (regs[2], 8);
+ ADD_STRING (" cr ");
+ ADD_MEM (regs[3], 8);
+ ADD_STRING ("\n lr ");
+ ADD_MEM (regs[4], 8);
+ ADD_STRING (" ctr ");
+ ADD_MEM (regs[5], 8);
+ ADD_STRING (" xer ");
+ ADD_MEM (regs[6], 8);
+ ADD_STRING (" mq ");
+ ADD_MEM (regs[7], 8);
+ ADD_STRING ("\n tid ");
+ ADD_MEM (regs[8], 8);
+ ADD_STRING (" fpscr ");
+ ADD_MEM (regs[9], 8);
+ ADD_STRING ("\n");
+
+ /* Write the stuff out. */
+ writev (fd, iov, nr);
+}
+
+#define REGISTER_DUMP register_dump (fd, ctx)
+
diff --git a/ports/sysdeps/unix/sysv/aix/powerpc/s_lrint.c b/ports/sysdeps/unix/sysv/aix/powerpc/s_lrint.c
new file mode 100644
index 000000000..1a8b590d2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/powerpc/s_lrint.c
@@ -0,0 +1,29 @@
+/* Round floating-point to integer. AIX/PowerPC version.
+ Copyright (C) 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdeps/powerpc/fpu/s_lrint.c>
+
+/* This code will also work for a 'float' argument. */
+asm ("\
+ .globl .__lrintf
+ .globl .lrintf
+ .weak .lrintf
+ .set .__lrintf,.__lrint
+ .set .lrintf,.__lrint
+");
diff --git a/ports/sysdeps/unix/sysv/aix/pread.c b/ports/sysdeps/unix/sysv/aix/pread.c
new file mode 100644
index 000000000..8d8bfd741
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/pread.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+extern int kpread (int fd, void *buf, size_t len, long long int off);
+
+ssize_t
+__pread (int fd, void *buf, size_t len, off_t off)
+{
+ return kpread (fd, buf, len, off);
+}
+weak_alias (__pread, pread)
diff --git a/ports/sysdeps/unix/sysv/aix/pread64.c b/ports/sysdeps/unix/sysv/aix/pread64.c
new file mode 100644
index 000000000..0d4df2263
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/pread64.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+extern int kpread (int fd, void *buf, size_t len, long long int off);
+
+ssize_t
+__pread64 (int fd, void *buf, size_t len, off64_t off)
+{
+ return kpread (fd, buf, len, off);
+}
+weak_alias (__pread64, pread64)
diff --git a/ports/sysdeps/unix/sysv/aix/profil-counter.h b/ports/sysdeps/unix/sysv/aix/profil-counter.h
new file mode 100644
index 000000000..2492a63ba
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/profil-counter.h
@@ -0,0 +1,27 @@
+/* Machine-dependent SIGPROF signal handler. AIX version.
+ Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* In many Unix systems signal handlers are called like this
+ and the interrupted PC is easily findable in the `struct sigcontext'. */
+
+static void
+profil_counter (int signr, int code, struct sigcontext *scp)
+{
+ profil_count ((void *) scp->sc_jmpbuf.__jmp_context.__gpr[0]);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/read.c b/ports/sysdeps/unix/sysv/aix/read.c
new file mode 100644
index 000000000..ca0edb30d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/read.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+extern int kread (int fd, void *buf, size_t len);
+
+ssize_t
+__libc_read (int fd, void *buf, size_t len)
+{
+ return kread (fd, buf, len);
+}
+libc_hidden_def (__libc_read)
+strong_alias (__libc_read, __read)
+libc_hidden_def (__read)
+strong_alias (__libc_read, read)
diff --git a/ports/sysdeps/unix/sysv/aix/readlink.c b/ports/sysdeps/unix/sysv/aix/readlink.c
new file mode 100644
index 000000000..2770358b9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/readlink.c
@@ -0,0 +1,8 @@
+/* This is a system call. We only have to provide the wrapper. */
+#include <unistd.h>
+
+int
+__readlink (const char *path, char *buf, size_t len)
+{
+ return readlink (path, buf, len);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/readv.c b/ports/sysdeps/unix/sysv/aix/readv.c
new file mode 100644
index 000000000..eddca0fc8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/readv.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991, 1995-1998, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/uio.h>
+
+extern ssize_t kreadv (int fd, const struct iovec *iovp, size_t iovcnt,
+ long int ext);
+
+/* 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. */
+ssize_t
+__libc_readv (fd, vector, count)
+ int fd;
+ const struct iovec *vector;
+ int count;
+{
+ return kreadv (fd, vector, count, 0);
+}
+strong_alias (__libc_readv, __readv)
+weak_alias (__libc_readv, readv)
diff --git a/ports/sysdeps/unix/sysv/aix/recv.c b/ports/sysdeps/unix/sysv/aix/recv.c
new file mode 100644
index 000000000..b8ae73e20
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/recv.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/socket.h>
+
+extern ssize_t recv (int fd, void *buf, size_t n, int flags);
+
+
+ssize_t
+__recv (int fd, void *buf, size_t n, int flags)
+{
+ return recv (fd, buf, n, flags);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/recvfrom.c b/ports/sysdeps/unix/sysv/aix/recvfrom.c
new file mode 100644
index 000000000..08ff1113f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/recvfrom.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/socket.h>
+
+extern ssize_t nrecvfrom (int s, void *uap_buf, size_t len, int flags,
+ void *uap_from, socklen_t *uap_fromlenaddr);
+
+ssize_t
+__recvfrom (int fd, void *buf, size_t n, int flags, __SOCKADDR_ARG addr,
+ socklen_t *addr_len)
+{
+ return nrecvfrom (fd, buf, n, flags, addr.__sockaddr__, addr_len);
+}
+
+weak_alias (__recvfrom, recvfrom)
diff --git a/ports/sysdeps/unix/sysv/aix/recvmsg.c b/ports/sysdeps/unix/sysv/aix/recvmsg.c
new file mode 100644
index 000000000..201c26741
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/recvmsg.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/socket.h>
+
+extern ssize_t nrecvmsg (int s, struct msghdr *uap_msg, int flags);
+
+ssize_t
+__recvmsg (int fd, struct msghdr *message, int flags)
+{
+ return nrecvmsg (fd, message, flags);
+}
+
+weak_alias (__recvmsg, recvmsg)
diff --git a/ports/sysdeps/unix/sysv/aix/rename.c b/ports/sysdeps/unix/sysv/aix/rename.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/rename.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/revoke.c b/ports/sysdeps/unix/sysv/aix/revoke.c
new file mode 100644
index 000000000..8f6a4848d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/revoke.c
@@ -0,0 +1,41 @@
+/* Revoke the access of all descriptors currently open on a file. AIX version.
+ Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+extern int frevoke (int fdes);
+
+int
+revoke (file)
+ const char *file;
+{
+ int fd;
+ int res;
+
+ fd = open (file, O_RDONLY);
+ if (fd < 0)
+ return -1;
+
+ res = frevoke (fd);
+ (void) close (fd);
+
+ return res;
+}
diff --git a/ports/sysdeps/unix/sysv/aix/rmdir.c b/ports/sysdeps/unix/sysv/aix/rmdir.c
new file mode 100644
index 000000000..91c600694
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/rmdir.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__rmdir (const char *name)
+{
+ return rmdir (name);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/sbrk.c b/ports/sysdeps/unix/sysv/aix/sbrk.c
new file mode 100644
index 000000000..0a590ee8c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sbrk.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+void *
+__sbrk (intptr_t delta)
+{
+ return sbrk (delta);
+}
+libc_hidden_def (__sbrk)
diff --git a/ports/sysdeps/unix/sysv/aix/sched_yield.c b/ports/sysdeps/unix/sysv/aix/sched_yield.c
new file mode 100644
index 000000000..b5fbc0753
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sched_yield.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sched.h>
+
+extern void yield (void);
+
+
+/* Yield the processor. */
+int
+__sched_yield (void)
+{
+ yield ();
+ return 0;
+}
+strong_alias (__sched_yield, sched_yield)
diff --git a/ports/sysdeps/unix/sysv/aix/select.c b/ports/sysdeps/unix/sysv/aix/select.c
new file mode 100644
index 000000000..9bf5bae47
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/select.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/time.h>
+
+int
+__select (nfds, readfds, writefds, exceptfds, timeout)
+ int nfds;
+ fd_set *readfds;
+ fd_set *writefds;
+ fd_set *exceptfds;
+ struct timeval *timeout;
+{
+ return select (nfds, readfds, writefds, exceptfds, timeout);
+}
+libc_hidden_def (__select)
diff --git a/ports/sysdeps/unix/sysv/aix/semctl.c b/ports/sysdeps/unix/sysv/aix/semctl.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/semctl.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/semget.c b/ports/sysdeps/unix/sysv/aix/semget.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/semget.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/semop.c b/ports/sysdeps/unix/sysv/aix/semop.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/semop.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/sendmsg.c b/ports/sysdeps/unix/sysv/aix/sendmsg.c
new file mode 100644
index 000000000..5b1baf63a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sendmsg.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/socket.h>
+
+extern int nsendmsg (int s, const void *uap_msg, int flags);
+
+ssize_t
+__sendmsg (int fd, const struct msghdr *message, int flags)
+{
+ return nsendmsg (fd, message, flags);
+}
+
+weak_alias (__sendmsg, sendmsg)
+
diff --git a/ports/sysdeps/unix/sysv/aix/sendto.c b/ports/sysdeps/unix/sysv/aix/sendto.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sendto.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/setegid.c b/ports/sysdeps/unix/sysv/aix/setegid.c
new file mode 100644
index 000000000..75123cedf
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/setegid.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+#define ID_EFFECTIVE 0x01
+
+
+extern int setgidx (int mask, gid_t gid);
+
+int
+__setegid (gid_t gid)
+{
+ return setgidx (ID_EFFECTIVE, gid);
+}
+strong_alias (__setegid, setegid)
+libc_hidden_def (setegid)
diff --git a/ports/sysdeps/unix/sysv/aix/seteuid.c b/ports/sysdeps/unix/sysv/aix/seteuid.c
new file mode 100644
index 000000000..6ea7e7ba0
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/seteuid.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+#define ID_EFFECTIVE 0x01
+
+
+extern int setuidx (int mask, uid_t uid);
+
+int
+__seteuid (uid_t uid)
+{
+ return setuidx (ID_EFFECTIVE, uid);
+}
+strong_alias (__seteuid, seteuid)
+libc_hidden_def (seteuid)
diff --git a/ports/sysdeps/unix/sysv/aix/setgid.c b/ports/sysdeps/unix/sysv/aix/setgid.c
new file mode 100644
index 000000000..5b8038110
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/setgid.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+#define ID_REAL 0x02
+
+
+extern int setgidx (int mask, gid_t gid);
+
+int
+__setgid (gid_t gid)
+{
+ return setgidx (ID_REAL, gid);
+}
+strong_alias (__setgid, setgid)
diff --git a/ports/sysdeps/unix/sysv/aix/setgroups.c b/ports/sysdeps/unix/sysv/aix/setgroups.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/setgroups.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/setitimer.c b/ports/sysdeps/unix/sysv/aix/setitimer.c
new file mode 100644
index 000000000..d7e741abe
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/setitimer.c
@@ -0,0 +1,68 @@
+/* Copyright (C) 1991, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stddef.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <signal.h>
+
+extern int __libc_nanosleep (const struct timespec *requested_time,
+ struct timespec *remaining);
+int
+__setitimer (which, new, old)
+ enum __itimer_which which;
+ const struct itimerval *new;
+ struct itimerval *old;
+{
+ if (new == NULL)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ switch (which)
+ {
+ default:
+ __set_errno (EINVAL);
+ return -1;
+
+ case ITIMER_VIRTUAL:
+ case ITIMER_PROF:
+ __set_errno (ENOSYS);
+ return -1;
+
+ case ITIMER_REAL:
+ break;
+ }
+
+ switch (__fork())
+ {
+ case -1: exit(-1);
+ case 0:
+ {
+ struct timespec ts ={.tv_sec = (long int)new->it_value.tv_sec, .tv_nsec = 0};
+ __libc_nanosleep(&ts,&ts);
+ __kill(getppid(), SIGALRM);
+ exit(0);
+ }
+ default:
+ }
+ return 0;
+}
+weak_alias (__setitimer, setitimer)
diff --git a/ports/sysdeps/unix/sysv/aix/setpgid.c b/ports/sysdeps/unix/sysv/aix/setpgid.c
new file mode 100644
index 000000000..b076f28ed
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/setpgid.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__setpgid (pid, pgid)
+ int pid;
+ int pgid;
+{
+ return setpgid (pid, pgid);
+}
+libc_hidden_def (__setpgid)
diff --git a/ports/sysdeps/unix/sysv/aix/setpgrp.c b/ports/sysdeps/unix/sysv/aix/setpgrp.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/setpgrp.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/setpriority.c b/ports/sysdeps/unix/sysv/aix/setpriority.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/setpriority.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/setregid.c b/ports/sysdeps/unix/sysv/aix/setregid.c
new file mode 100644
index 000000000..35812300b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/setregid.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+#define ID_EFFECTIVE 0x01
+#define ID_REAL 0x02
+
+
+extern int setgidx (int mask, gid_t gid);
+
+int
+__setregid (gid_t rgid, gid_t egid)
+{
+ int res;
+
+ if (rgid == egid)
+ return setgidx (ID_EFFECTIVE | ID_REAL, egid);
+
+ res = setgidx (ID_REAL, rgid);
+ if (res == 0)
+ res = setgidx (ID_EFFECTIVE, egid);
+
+ return res;
+}
+strong_alias (__setregid, setregid)
diff --git a/ports/sysdeps/unix/sysv/aix/setreuid.c b/ports/sysdeps/unix/sysv/aix/setreuid.c
new file mode 100644
index 000000000..430d2fedc
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/setreuid.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+#define ID_EFFECTIVE 0x01
+#define ID_REAL 0x02
+
+
+extern int setuidx (int mask, uid_t uid);
+
+int
+__setreuid (uid_t ruid, uid_t euid)
+{
+ int res;
+
+ if (ruid == euid)
+ return setuidx (ID_EFFECTIVE | ID_REAL, euid);
+
+ res = setuidx (ID_REAL, ruid);
+ if (res == 0)
+ res = setuidx (ID_EFFECTIVE, euid);
+
+ return res;
+}
+strong_alias (__setreuid, setreuid)
diff --git a/ports/sysdeps/unix/sysv/aix/setrlimit.c b/ports/sysdeps/unix/sysv/aix/setrlimit.c
new file mode 100644
index 000000000..818819d8e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/setrlimit.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/resource.h>
+
+int
+__setrlimit (enum __rlimit_resource resource, const struct rlimit *rlimits)
+{
+ return setrlimit (resource, rlimits);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/setrlimit64.c b/ports/sysdeps/unix/sysv/aix/setrlimit64.c
new file mode 100644
index 000000000..f305c6f82
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/setrlimit64.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/resource.h>
+
+int
+__setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits)
+{
+ return setrlimit64 (resource, rlimits);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/setsid.c b/ports/sysdeps/unix/sysv/aix/setsid.c
new file mode 100644
index 000000000..c017c122b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/setsid.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__setsid ()
+{
+ return setsid ();
+}
diff --git a/ports/sysdeps/unix/sysv/aix/setsockopt.c b/ports/sysdeps/unix/sysv/aix/setsockopt.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/setsockopt.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/setuid.c b/ports/sysdeps/unix/sysv/aix/setuid.c
new file mode 100644
index 000000000..1772fc797
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/setuid.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+#define ID_REAL 0x02
+
+
+extern int setuidx (int mask, uid_t uid);
+
+int
+__setuid (uid_t uid)
+{
+ return setuidx (ID_REAL, uid);
+}
+strong_alias (__setuid, setuid)
diff --git a/ports/sysdeps/unix/sysv/aix/shmat.c b/ports/sysdeps/unix/sysv/aix/shmat.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/shmat.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/shmctl.c b/ports/sysdeps/unix/sysv/aix/shmctl.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/shmctl.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/shmdt.c b/ports/sysdeps/unix/sysv/aix/shmdt.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/shmdt.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/shmget.c b/ports/sysdeps/unix/sysv/aix/shmget.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/shmget.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/sigaction.c b/ports/sysdeps/unix/sysv/aix/sigaction.c
new file mode 100644
index 000000000..6b48a505c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sigaction.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991,1995,1996,1997,2000,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <signal.h>
+
+extern int _sigaction (int sig, const struct sigaction *act,
+ struct sigaction *oact);
+
+/* 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
+__sigaction (sig, act, oact)
+ int sig;
+ const struct sigaction *act;
+ struct sigaction *oact;
+{
+ return _sigaction (sig, act, oact);
+}
+libc_hidden_def (__sigaction)
+strong_alias (__sigaction, sigaction)
diff --git a/ports/sysdeps/unix/sysv/aix/sigaltstack.c b/ports/sysdeps/unix/sysv/aix/sigaltstack.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sigaltstack.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/sigpending.c b/ports/sysdeps/unix/sysv/aix/sigpending.c
new file mode 100644
index 000000000..729b75a3b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sigpending.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1991, 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <signal.h>
+
+extern int _sigpending (sigset_t *set);
+
+
+/* Store in SET all signals that are blocked and pending. */
+int
+sigpending (set)
+ sigset_t *set;
+{
+ return _sigpending (set);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/sigprocmask.c b/ports/sysdeps/unix/sysv/aix/sigprocmask.c
new file mode 100644
index 000000000..1046903b9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sigprocmask.c
@@ -0,0 +1,8 @@
+/* This is a system call. We only have to provide the wrapper. */
+#include <signal.h>
+
+int
+__sigprocmask (int how, const sigset_t *set, sigset_t *oset)
+{
+ return sigprocmask (how, set, oset);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/sigset-cvt-mask.h b/ports/sysdeps/unix/sysv/aix/sigset-cvt-mask.h
new file mode 100644
index 000000000..cc05fb70f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sigset-cvt-mask.h
@@ -0,0 +1,33 @@
+/* Convert between lowlevel sigmask and libc representation of sigset_t.
+ AIX version.
+ Copyright (C) 1998,2000,02 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+static inline int __attribute__ ((unused))
+sigset_set_old_mask (sigset_t *set, int mask)
+{
+ set->__losigs = (unsigned int) mask;
+ set->__hisigs = 0;
+ return 0;
+}
+
+static inline int __attribute__ ((unused))
+sigset_get_old_mask (const sigset_t *set)
+{
+ return (unsigned int) set->__losigs;
+}
diff --git a/ports/sysdeps/unix/sysv/aix/sigstack.c b/ports/sysdeps/unix/sysv/aix/sigstack.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sigstack.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/sigsuspend.c b/ports/sysdeps/unix/sysv/aix/sigsuspend.c
new file mode 100644
index 000000000..c9120d6e9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sigsuspend.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1995-1998, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <signal.h>
+
+extern int _sigsuspend (const sigset_t *sigmask);
+
+
+/* Change the set of blocked signals to SET,
+ wait until a signal arrives, and restore the set of blocked signals. */
+int
+__sigsuspend (set)
+ const sigset_t *set;
+{
+ return _sigsuspend (set);
+}
+libc_hidden_def (__sigsuspend)
+weak_alias (__sigsuspend, sigsuspend)
diff --git a/ports/sysdeps/unix/sysv/aix/sleep.c b/ports/sysdeps/unix/sysv/aix/sleep.c
new file mode 100644
index 000000000..aa8d76d3d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sleep.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <time.h>
+#include <unistd.h>
+#include <errno.h>
+
+extern int __libc_nanosleep (const struct timespec *requested_time,
+ struct timespec *remaining);
+
+unsigned int
+__sleep (seconds)
+ unsigned int seconds;
+{
+ struct timespec ts ={.tv_sec = (long int)seconds, .tv_nsec = 0};
+ __libc_nanosleep(&ts,&ts);
+ return 0;
+}
+weak_alias (__sleep, sleep)
diff --git a/ports/sysdeps/unix/sysv/aix/socket.c b/ports/sysdeps/unix/sysv/aix/socket.c
new file mode 100644
index 000000000..236b1b168
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/socket.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/socket.h>
+
+int
+__socket (int domain, int type, int protocol)
+{
+ return socket (domain, type, protocol);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/socketpair.c b/ports/sysdeps/unix/sysv/aix/socketpair.c
new file mode 100644
index 000000000..8adeac97f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/socketpair.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/socket.h>
+
+int
+__socketpair (int domain, int type, int protocol, int fds[2])
+{
+ return socketpair (domain, type, protocol, fds);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/speed.c b/ports/sysdeps/unix/sysv/aix/speed.c
new file mode 100644
index 000000000..3a453a7be
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/speed.c
@@ -0,0 +1,75 @@
+/* `struct termios' speed frobnication functions. AIX version.
+ Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stddef.h>
+#include <errno.h>
+#include <termios.h>
+
+/* Return the output baud rate stored in *TERMIOS_P. */
+speed_t
+cfgetospeed (termios_p)
+ const struct termios *termios_p;
+{
+ return termios_p->c_cflag & 0x0000000f;
+}
+
+/* Return the input baud rate stored in *TERMIOS_P. */
+speed_t
+cfgetispeed (termios_p)
+ const struct termios *termios_p;
+{
+ return (termios_p->c_cflag & 0x000f0000) >> 16;
+}
+
+/* Set the output baud rate stored in *TERMIOS_P to SPEED. */
+int
+cfsetospeed (termios_p, speed)
+ struct termios *termios_p;
+ speed_t speed;
+{
+ if (termios_p == NULL)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ termios_p->c_cflag &= ~0x0000000f;
+ termios_p->c_cflag |= speed & 0x0000000f;
+ return 0;
+}
+libc_hidden_def (cfsetospeed)
+
+
+/* Set the input baud rate stored in *TERMIOS_P to SPEED. */
+int
+cfsetispeed (termios_p, speed)
+ struct termios *termios_p;
+ speed_t speed;
+{
+ if (termios_p == NULL)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ termios_p->c_cflag &= ~0x000f0000;
+ termios_p->c_cflag |= (speed << 16) & ~0x000f0000;
+ return 0;
+}
+libc_hidden_def (cfsetispeed)
diff --git a/ports/sysdeps/unix/sysv/aix/start-libc.c b/ports/sysdeps/unix/sysv/aix/start-libc.c
new file mode 100644
index 000000000..0cbe79d0b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/start-libc.c
@@ -0,0 +1,265 @@
+/* Initialization code run first thing by the XCOFF startup code. AIX version.
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* hack to use uchar's */
+typedef unsigned char uchar;
+#include <xcoff.h>
+#include <rtinit.h>
+#include <dlldr.h>
+#include <bits/libc-lock.h>
+
+extern void __libc_init_first (int argc, char **argv, char **envp);
+
+/* XXX disable for now
+extern int __libc_multiple_libcs; */
+
+/* XXX normally defined in generic/dl-sydep.c, hack it into existance
+extern void *__libc_stack_end; */
+void *__libc_stack_end;
+
+struct __libc_start_data_rec
+{
+ void *stack;
+ void *toc;
+ int argc;
+ char **argv;
+ char **envp;
+ char *data;
+ char *text;
+ unsigned int mcount;
+ unsigned int special;
+ int (*main) (int, char **, char **);
+ void (*init) (void);
+ void (*fini) (void);
+ void (*rtld_fini) (void);
+};
+
+extern struct __libc_start_data_rec __libc_start_data;
+extern int errno;
+
+/* The first piece of initialized data. */
+int __data_start = 0;
+
+#ifndef HAVE_ELF
+/* Since gcc/crtstuff.c won't define it unless the ELF format is used
+ we will need to define it here. */
+void *__dso_handle = NULL;
+#endif
+
+/* AIX kernel function */
+extern int __loadx (int flag, void *module, void *arg1, void *arg2,
+ void *arg3);
+/* Needed by setenv */
+char **__environ;
+
+/*
+ Find __rtinit symbol
+
+ __RTINIT *find_rtinit()
+
+ __RTINIT *rti - pointer to __rtinit data structure
+ */
+
+static __RTINIT *
+find_rtinit (void)
+{
+ struct xcoffhdr *xcoff_hdr;
+ SCNHDR *sec_hdr;
+ SCNHDR *ldr_sec_hdr;
+ SCNHDR *data_sec_hdr;
+ LDSYM *ldsym_hdr;
+ __RTINIT *rtl;
+
+ xcoff_hdr = (struct xcoffhdr *) __libc_start_data.text;
+ sec_hdr = (SCNHDR *) ((caddr_t) &xcoff_hdr->aouthdr
+ + xcoff_hdr->filehdr.f_opthdr);
+ ldr_sec_hdr = (SCNHDR *) (sec_hdr + (xcoff_hdr->aouthdr.o_snloader - 1));
+ ldsym_hdr = (LDSYM *) ((caddr_t)xcoff_hdr + ldr_sec_hdr->s_scnptr
+ + LDHDRSZ);
+
+ if ( __libc_start_data.mcount <= 0)
+ {
+ if (!ldr_sec_hdr->s_scnptr)
+ return (__RTINIT *) 0;
+
+ if (memcmp (ldsym_hdr, RTINIT_NAME, sizeof (RTINIT_NAME) - 1))
+ return (__RTINIT *) 0;
+ }
+
+ data_sec_hdr = (SCNHDR *) (sec_hdr + (xcoff_hdr->aouthdr.o_sndata - 1));
+ rtl = (__RTINIT *) (ldsym_hdr->l_value
+ + (__libc_start_data.data - data_sec_hdr->s_vaddr));
+ return rtl;
+}
+
+/*
+ The mod_init1 calls every initialization function for a given module.
+
+ void mod_init1(handler, rti)
+
+ void *handler - if NULL init funtions for modules loaded at exec time
+ are being executed. Otherwise, the handler points to the
+ module loaded.
+
+ __RTINIT *rti - pointer to __rtinit data structure (with rti->init_offset
+ not equal to zero)
+ */
+
+static void
+mod_init1 (void *handler,__RTINIT *rtl)
+{
+ __RTINIT_DESCRIPTOR *descriptor;
+
+ descriptor = (__RTINIT_DESCRIPTOR *) ((caddr_t) &rtl->rtl
+ + rtl->init_offset);
+ while (descriptor->f != NULL)
+ {
+ if (!(descriptor->flags & _RT_CALLED))
+ {
+ descriptor->flags |= _RT_CALLED;
+ (descriptor->f) (handler, rtl, descriptor); /* execute init/fini */
+ }
+ descriptor = (__RTINIT_DESCRIPTOR *) ((caddr_t) descriptor
+ + rtl->__rtinit_descriptor_size);
+ }
+}
+
+/* The modinit() function performs run-time linking, if enabled, and calling
+ the init() function for all loaded modules. */
+
+#define DL_BUFFER_SIZE 1000
+
+static int
+modinit (void)
+{
+ int *handler = 0;
+ __RTINIT *rtinit_info = 0;
+ int flag;
+ DL_INFO dl_buffer[DL_BUFFER_SIZE];
+ DL_INFO *dl_info = dl_buffer;
+ int i;
+
+ /* Find __rtinit symbols */
+ rtinit_info = find_rtinit ();
+
+ flag = DL_EXECQ;
+ if (rtinit_info && rtinit_info->rtl)
+ flag |= DL_LOAD_RTL;
+
+ /* Get a list of modules that have __rtinit */
+ if (__loadx (flag, dl_info, (void *) sizeof (dl_buffer), NULL, NULL))
+ exit (0x90);
+
+ if (dl_info[0].dlinfo_xflags & DL_INFO_OK)
+ {
+ rtinit_info = find_rtinit ();
+ if ((rtinit_info != NULL) & (rtinit_info->rtl != NULL))
+ {
+ if ((*rtinit_info->rtl) (dl_info, 0))
+ exit (0x90);
+ }
+ }
+
+ /* Initialization each module loaded that has __rtinit. */
+ if (dl_info[0].dlinfo_xflags & DL_INFO_OK)
+ {
+ for (i = 1; i < dl_info[0].dlinfo_arraylen + 1; ++i)
+ if (dl_info[i].dlinfo_flags & DL_HAS_RTINIT)
+ {
+ rtinit_info = find_rtini t();
+ if (rtinit_info)
+ mod_init1 (handler, rtinit_info);
+ }
+ }
+
+ return 0;
+}
+
+
+void
+__libc_start_init (void)
+{
+ /* Do run-time linking, if enabled and call the init()
+ for all loaded modules. */
+ if (__libc_start_data.mcount != __libc_start_data.special)
+ modinit ();
+}
+
+/* For now these are just stubs. */
+void
+__libc_start_fini (void)
+{
+}
+
+void
+__libc_start_rtld_fini (void)
+{
+}
+
+
+int
+__libc_start_main (void)
+{
+ /* Store the lowest stack address. */
+ __libc_stack_end = __libc_start_data.stack;
+
+ /* Used by setenv */
+ __environ = __libc_start_data.envp;
+
+#ifndef SHARED
+ /* Clear errno. */
+ errno = 0;
+
+ /* Some security at this point. Prevent starting a SUID binary where
+ the standard file descriptors are not opened. We have to do this
+ only for statically linked applications since otherwise the dynamic
+ loader did the work already. */
+ if (__builtin_expect (__libc_enable_secure, 0))
+ __libc_check_standard_fds ();
+
+#endif
+
+ /* Register the destructor of the dynamic linker if there is any. */
+ if (__builtin_expect (__libc_start_data.rtld_fini != NULL, 1))
+ __cxa_atexit ((void (*) (void *)) __libc_start_data.rtld_fini, NULL, NULL);
+
+ /* Call the initializer of the libc. This is only needed here if we
+ are compiling for the static library in which case we haven't
+ run the constructors in `_dl_start_user'. */
+#ifndef SHARED
+ __libc_init_first (__libc_start_data.argc, __libc_start_data.argv,
+ __libc_start_data.envp);
+#endif
+
+ /* Register the destructor of the program, if any. */
+ if (__libc_start_data.fini)
+ __cxa_atexit ((void (*) (void *)) __libc_start_data.fini, NULL, NULL);
+
+ /* Call the initializer of the program, if any. */
+ if (__libc_start_data.init)
+ (*__libc_start_data.init) ();
+
+ exit ((*__libc_start_data.main) (__libc_start_data.argc,
+ __libc_start_data.argv,
+ __libc_start_data.envp));
+}
diff --git a/ports/sysdeps/unix/sysv/aix/start.s b/ports/sysdeps/unix/sysv/aix/start.s
new file mode 100644
index 000000000..79d8ef489
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/start.s
@@ -0,0 +1,126 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+ .file "start.s"
+ .toc
+T.lsd: .tc __libc_start_data[tc], __libc_start_data[rw]
+T.main: .tc main[tc], main[rw]
+T.init: .tc __libc_start_init[tc], __libc_start_init[rw]
+T.fini: .tc __libc_start_fini[tc], __libc_start_init[rw]
+T.rtld_fini : .tc __libc_start_rtld_fini[tc], __libc_start_rtld_fini[rw]
+
+ .globl __start
+ .globl .__start
+ .globl __libc_start_data
+
+ .extern .__libc_start_main
+ .extern .main
+ .extern main
+ .extern __libc_start_init
+ .extern __libc_start_fini
+ .extern __libc_start_rtld_fini
+
+/* Text */
+
+ .csect __start[ds]
+__start:
+ .long .__start, TOC[tc0], 0
+
+ .csect .text[pr]
+.__start:
+
+/* No prologue needed, __start does not have to follow the ABI.
+
+ Input from kernel/loader
+ r1 : stack
+ r2 : TOC
+ r3 : argc
+ r4 : argv
+ r5 : envp
+ r28 : data origin
+ r29 : text origin
+ r30 : module count
+ r31 : default processing flag
+
+ If r31 == r30, no special processing is needed, ie r28, r29 & r30
+ are not used
+
+ Save input in __libc_start_data */
+ l 16, T.lsd(2)
+ st 1, 0(16) /* stack */
+ st 2, 4(16) /* toc */
+ st 3, 8(16) /* argc */
+ st 4, 12(16) /* argv */
+ st 5, 16(16) /* envp */
+ st 28, 20(16) /* data origin */
+ st 29, 24(16) /* text origin */
+ st 30, 28(16) /* module count */
+ st 31, 32(16) /* special */
+
+/* Call __libc_start_main() */
+
+ bl .__libc_start_main
+ nop
+
+/* No epilog needed, __start does not have to follow the ABI */
+
+/* Trace back */
+TB.__start:
+ .long 0x0
+ .long 0xc2040
+ .long 0x0
+ .long TB.__start - .__start
+ .short 7
+ .byte "__start"
+ .byte 0,0,0
+
+/* Data
+ __libc_start_data
+ Space to keep libc initialization information */
+
+ .csect __libc_start_data[rw]
+__libc_start_data:
+/* For kernel/loader input args */
+ .space 36
+
+/* Externs */
+ .long main
+init:
+ .long __libc_start_init
+fini:
+ .long __libc_start_fini
+rtld_fini:
+ .long __libc_start_rtld_fini
+ .space 0x1000 + (4 + rtld_fini - __libc_start_data)
diff --git a/ports/sysdeps/unix/sysv/aix/statfs.c b/ports/sysdeps/unix/sysv/aix/statfs.c
new file mode 100644
index 000000000..1ead597da
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/statfs.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/statfs.h>
+
+extern int statfs (const char *file, struct statfs *buf);
+
+int
+__statfs (const char *file, struct statfs *buf)
+{
+ return statfs (file, buf);
+}
+libc_hidden_def (__statfs)
diff --git a/ports/sysdeps/unix/sysv/aix/symlink.c b/ports/sysdeps/unix/sysv/aix/symlink.c
new file mode 100644
index 000000000..cb2496595
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/symlink.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__symlink (from, to)
+ const char *from;
+ const char *to;
+{
+ return symlink (from, to);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/sync.c b/ports/sysdeps/unix/sysv/aix/sync.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sync.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/sys/param.h b/ports/sysdeps/unix/sysv/aix/sys/param.h
new file mode 100644
index 000000000..7448f1a6e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sys/param.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_PARAM_H
+#define _SYS_PARAM_H 1
+
+/* 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>
+
+#define MAXSYMLINKS 1
+#define MAXPATHLEN 256
+
+/* The pagesize is 4096. */
+#define EXEC_PAGESIZE 4096
+
+/* maximum number of supplemental groups. */
+#define NGROUPS 32
+
+/* Macros for min/max. */
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#define MAX(a,b) (((a)>(b))?(a):(b))
+
+
+/* Maximum length of hostname. */
+#define MAXHOSTNAMELEN 256
+
+#endif /* sys/param.h */
diff --git a/ports/sysdeps/unix/sysv/aix/sys/ucontext.h b/ports/sysdeps/unix/sysv/aix/sys/ucontext.h
new file mode 100644
index 000000000..ddb3f010c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sys/ucontext.h
@@ -0,0 +1,113 @@
+/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <bits/types.h>
+#include <bits/sigset.h>
+
+
+/* Alternate, preferred interface. */
+typedef struct sigaltstack
+ {
+ void *ss_sp;
+ size_t ss_size;
+ int ss_flags;
+ int __pad[4];
+ } stack_t;
+
+
+/* Forward declaration of AIX type. */
+typedef struct label_t label_t;
+
+
+
+typedef unsigned int kvmhandle_t;
+typedef struct
+ {
+ unsigned long int __alloc;
+ kvmhandle_t __srval[16];
+ } adspace_t;
+
+
+
+#define _NGPRS 32
+#define _NFPRS 32
+
+struct __mstsafe
+{
+ struct __mstsave *__prev; /* Previous save area. */
+ label_t *__kjmpbuf; /* Pointer to saved context. */
+ char *__stackfix; /* Stack fix pointer. */
+ char __intpri; /* Interrupt priority. */
+ char __backt; /* Back-track flag. */
+ char __rsvd[2]; /* Reserved. */
+ __pid_t __curid; /* Copy of curid. */
+
+ int __excp_type; /* Exception type for debugger. */
+ unsigned long int __iar; /* Instruction address register. */
+ unsigned long int __msr; /* Machine state register. */
+ unsigned long int __cr; /* Condition register. */
+ unsigned long int __lr; /* Link register. */
+ unsigned long int __ctr; /* Count register. */
+ unsigned long int __xer; /* Fixed point exception. */
+ unsigned long int __mq; /* Multiply/quotient register. */
+ unsigned long int __tid; /* TID register. */
+ unsigned long int __fpscr; /* Floating point status reg. */
+ char __fpeu; /* Floating point ever used. */
+ char __fpinfo; /* Floating point status flags. */
+ char __pad[2]; /* Pad to dword boundary. */
+ /* 1 implies state is in mstext */
+ unsigned long int __except[5]; /* exception structure. */
+ char __pad1[4]; /* Old bus field. */
+ unsigned long int __o_iar; /* Old iar (for longjmp excpt). */
+ unsigned long int __o_toc; /* Old toc (for longjmp excpt). */
+ unsigned long int __o_arg1; /* Old arg1 (for longjmp excpt). */
+ unsigned long int __excbranch; /* If not NULL, address to branch
+ to on exception. Used by
+ assembler routines for low
+ cost exception handling. */
+ unsigned long int __fpscrx; /* Software extension to fpscr. */
+ unsigned long int __o_vaddr; /* Saved vaddr for vmexception. */
+ unsigned long int __cachealign[7]; /* Reserved. */
+ adspace_t __as; /* Segment registers. */
+ unsigned long int __gpr[_NGPRS]; /* General purpose registers. */
+ double __fpr[_NFPRS]; /* Floating point registers. */
+ };
+
+typedef struct mcontext_t
+ {
+ struct __mstsafe __jmp_context;
+ } mcontext_t;
+
+
+typedef struct ucontext_t
+ {
+ int __sc_onstack; /* Sigstack state to restore. */
+ __sigset_t uc_sigmask; /* The set of signals that are blocked when
+ this context is active. */
+ int __sc_uerror; /* u_error to restore. */
+ mcontext_t uc_mcontext; /* Machine-specific image of saved context. */
+ struct ucontext_t *uc_link; /* context resumed after this one returns */
+ stack_t uc_stack; /* stack used by context */
+ int __pad[4];
+ } ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/ports/sysdeps/unix/sysv/aix/syscall.c b/ports/sysdeps/unix/sysv/aix/syscall.c
new file mode 100644
index 000000000..6f204ff80
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/syscall.c
@@ -0,0 +1,2 @@
+/* XXX We will have to see whether it is possible to implement this
+ function at all. */
diff --git a/ports/sysdeps/unix/sysv/aix/sysdep.h b/ports/sysdeps/unix/sysv/aix/sysdep.h
new file mode 100644
index 000000000..dcf37f253
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sysdep.h
@@ -0,0 +1,88 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdeps/unix/powerpc/sysdep.h>
+
+
+/* This seems to always be the case on PPC. */
+#define ALIGNARG(log2) log2
+
+/* How to define local lables. */
+#define L(name) L..##name
+
+/* Label in text section. */
+#define C_TEXT(name) .##name
+
+/* Function descriptor. */
+#define FUNCDESC(real, code) \
+ .toc; \
+ .csect real##[DS], 3; \
+ .globl real; \
+real: \
+ .long code, TOC[tc0], 0;
+
+/* Code to generate function entry code. */
+#define ENTRY(name) \
+ FUNCDESC (name, C_TEXT (name)) \
+ .csect .text[PR], 2; \
+ .globl C_TEXT (name); \
+C_TEXT (name):
+
+/* XXX For now we don't define any code. */
+#define CALL_MCOUNT
+
+#define EALIGN_W_0 /* No words to insert. */
+#define EALIGN_W_1 nop
+#define EALIGN_W_2 nop;nop
+#define EALIGN_W_3 nop;nop;nop
+#define EALIGN_W_4 EALIGN_W_3;nop
+#define EALIGN_W_5 EALIGN_W_4;nop
+#define EALIGN_W_6 EALIGN_W_5;nop
+#define EALIGN_W_7 EALIGN_W_6;nop
+
+/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
+ past a 2^align boundary. */
+#ifdef PROF
+#define EALIGN(name, alignt, words) \
+ FUNCDESC (name, C_TEXT (name)) \
+ .csect .text[PR], 2; \
+ .align ALIGNARG(2); \
+ .globl C_TEXT (name); \
+C_TEXT (name): \
+ CALL_MCOUNT \
+ b L(align_0); \
+ .align ALIGNARG(alignt); \
+ EALIGN_W_##words; \
+L(align_0):
+#else /* PROF */
+#define EALIGN(name, alignt, words) \
+ FUNCDESC (name, C_TEXT (name)) \
+ .csect .text[PR], 2; \
+ .align ALIGNARG(alignt); \
+ EALIGN_W_##words; \
+ .globl C_TEXT (name); \
+C_TEXT (name):
+#endif
+
+/* No special end code for now. We will eventually add to usual prolog
+ with function length etc. */
+#define END(name)
+
+
+/* Jumping to another function. We are jumping to the TOC entry. */
+#define JUMPTARGET(name) C_TEXT (name)
diff --git a/ports/sysdeps/unix/sysv/aix/sysv_termio.h b/ports/sysdeps/unix/sysv/aix/sysv_termio.h
new file mode 100644
index 000000000..f314c0e16
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/sysv_termio.h
@@ -0,0 +1,155 @@
+/* Copyright (C) 1992, 1997, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 0x5405
+#define _TCSETA 0x5406
+#define _TCSETAW 0x5407
+#define _TCSETAF 0x5408
+#define _TCSBRK 0x5409
+#define _TCXONC 0x540B
+#define _TCFLSH 0x540C
+#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/ports/sysdeps/unix/sysv/aix/tcgetattr.c b/ports/sysdeps/unix/sysv/aix/tcgetattr.c
new file mode 100644
index 000000000..01ffd55ef
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/tcgetattr.c
@@ -0,0 +1,152 @@
+/* Copyright (C) 1992, 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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
+__tcgetattr (fd, termios_p)
+ int fd;
+ struct termios *termios_p;
+{
+ struct __sysv_termio buf;
+
+ if (termios_p == NULL)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ if (__ioctl (fd, _TCGETA, &buf) < 0)
+ return -1;
+
+ termios_p->c_cflag &= ~0x000f0000;
+ termios_p->c_cflag |= (termios_p->c_cflag & 0xf) << 16;
+
+ 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/ports/sysdeps/unix/sysv/aix/tcsetattr.c b/ports/sysdeps/unix/sysv/aix/tcsetattr.c
new file mode 100644
index 000000000..8e78da1c2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/tcsetattr.c
@@ -0,0 +1,198 @@
+/* Copyright (C) 1992,1995,1996,1997,2000,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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
+tcsetattr (fd, optional_actions, termios_p)
+ int fd;
+ int optional_actions;
+ const struct termios *termios_p;
+{
+ struct __sysv_termio buf;
+ int ioctl_function;
+
+ if (termios_p == NULL)
+ {
+ __set_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:
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ if ((termios_p->c_cflag & 0x000f0000) >> 16 != (termios_p->c_cflag & 0xf))
+ {
+ __set_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;
+}
+libc_hidden_def (tcsetattr)
diff --git a/ports/sysdeps/unix/sysv/aix/times.c b/ports/sysdeps/unix/sysv/aix/times.c
new file mode 100644
index 000000000..8ebc40b02
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/times.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/times.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
+__times (buffer)
+ struct tms *buffer;
+{
+ return times (buffer);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/truncate.c b/ports/sysdeps/unix/sysv/aix/truncate.c
new file mode 100644
index 000000000..247aebb33
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/truncate.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+extern int ktruncate (const char *name, long long int length);
+
+int
+__truncate (const char *name, off_t length)
+{
+ return ktruncate (name, length);
+}
+strong_alias (__truncate, truncate)
diff --git a/ports/sysdeps/unix/sysv/aix/truncate64.c b/ports/sysdeps/unix/sysv/aix/truncate64.c
new file mode 100644
index 000000000..3a219c018
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/truncate64.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+extern int ktruncate (const char *name, long long int length);
+
+int
+__truncate64 (const char *name, off64_t length)
+{
+ return ktruncate (name, length);
+}
+strong_alias (__truncate64, truncate64)
diff --git a/ports/sysdeps/unix/sysv/aix/uitrunc.c b/ports/sysdeps/unix/sysv/aix/uitrunc.c
new file mode 100644
index 000000000..54cdc3af7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/uitrunc.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+/* The uitrunc function returns the nearest unsigned integer
+ to the x parameter in the direction of 0. This actions is
+ equivalent to truncation off the fraction bits of the x
+ parameter and then converting x to an unsigned integer. */
+unsigned int
+__uitrunc (double x)
+{
+ double xrf;
+ unsigned int xr;
+ xr = (unsigned int) x;
+ xrf = (double) xr;
+ if (x >= 0.0)
+ if (x - xrf >= 0.5 && x - xrf < 1.0 && x + 1 > 0)
+ return x + 1;
+ else
+ return x;
+ else
+ if (xrf - x >= 0.5 && xrf - x < 1.0 && x - 1 < 0)
+ return x - 1;
+ else
+ return x;
+}
diff --git a/ports/sysdeps/unix/sysv/aix/ulimit.c b/ports/sysdeps/unix/sysv/aix/ulimit.c
new file mode 100644
index 000000000..44fef6449
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/ulimit.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdarg.h>
+#include <sys/resource.h>
+
+long int
+__ulimit (int cmd, ...)
+{
+ va_list va;
+ long int arg;
+ long int res;
+
+ va_start (va, cmd);
+ arg = va_arg (va, long int);
+
+ res = ulimit (cmd, arg);
+
+ va_end (va);
+
+ return res;
+}
diff --git a/ports/sysdeps/unix/sysv/aix/umask.c b/ports/sysdeps/unix/sysv/aix/umask.c
new file mode 100644
index 000000000..e8c45e40b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/umask.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/stat.h>
+
+mode_t
+__umask (mask)
+ mode_t mask;
+{
+ return umask (mask);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/uname.c b/ports/sysdeps/unix/sysv/aix/uname.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/uname.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/unlink.c b/ports/sysdeps/unix/sysv/aix/unlink.c
new file mode 100644
index 000000000..6fe9b59c6
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/unlink.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+int
+__unlink (name)
+ const char *name;
+{
+ return unlink (name);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/usleep.c b/ports/sysdeps/unix/sysv/aix/usleep.c
new file mode 100644
index 000000000..a1d55eb2b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/usleep.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <time.h>
+#include <unistd.h>
+#include <errno.h>
+
+extern int __libc_nanosleep (const struct timespec *requested_time,
+ struct timespec *remaining);
+
+/* Sleep USECONDS microseconds, or until a previously set timer goes off. */
+int
+usleep (useconds)
+ useconds_t useconds;
+{
+ struct timespec ts ={.tv_sec = 0, .tv_nsec = (long int)useconds * 1000};
+ __libc_nanosleep(&ts,&ts);
+ return 0;
+}
diff --git a/ports/sysdeps/unix/sysv/aix/ustat.c b/ports/sysdeps/unix/sysv/aix/ustat.c
new file mode 100644
index 000000000..6036fbbff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/ustat.c
@@ -0,0 +1 @@
+/* This is a system call. */
diff --git a/ports/sysdeps/unix/sysv/aix/utimes.c b/ports/sysdeps/unix/sysv/aix/utimes.c
new file mode 100644
index 000000000..9bef02ae0
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/utimes.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/time.h>
+
+int
+__utimes (file, tvp)
+ const char *file;
+ const struct timeval tvp[2];
+{
+ return utimes (file, tvp);
+}
diff --git a/ports/sysdeps/unix/sysv/aix/utmpx.h b/ports/sysdeps/unix/sysv/aix/utmpx.h
new file mode 100644
index 000000000..1647bfe68
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/utmpx.h
@@ -0,0 +1,89 @@
+/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _UTMPX_H
+#define _UTMPX_H 1
+
+#include <features.h>
+#include <sys/time.h>
+
+/* Required according to Unix98. */
+#ifndef __pid_t_defined
+typedef __pid_t pid_t;
+# define __pid_t_defined
+#endif
+
+/* Get system dependent values and data structures. */
+#include <bits/utmpx.h>
+
+#ifdef __USE_GNU
+/* Compatibility names for the strings of the canonical file names. */
+# define UTMPX_FILE _PATH_UTMPX
+# define UTMPX_FILENAME _PATH_UTMPX
+# define WTMPX_FILE _PATH_WTMPX
+# define WTMPX_FILENAME _PATH_WTMPX
+#endif
+
+/* For the getutmp{,x} functions we need the `struct utmp'. */
+#ifdef __USE_GNU
+struct utmp;
+#endif
+
+
+__BEGIN_DECLS
+
+/* Open user accounting database. */
+extern void setutxent (void) __THROW;
+
+/* Close user accounting database. */
+extern void endutxent (void) __THROW;
+
+/* Get the next entry from the user accounting database. */
+extern struct utmpx *getutxent (void) __THROW;
+
+/* Get the user accounting database entry corresponding to ID. */
+extern struct utmpx *getutxid (__const struct utmpx *__id) __THROW;
+
+/* Get the user accounting database entry corresponding to LINE. */
+extern struct utmpx *getutxline (__const struct utmpx *__line) __THROW;
+
+/* Write the entry UTMPX into the user accounting database. */
+extern struct utmpx *pututxline (__const struct utmpx *__utmpx) __THROW;
+
+
+#ifdef __USE_GNU
+/* Change name of the utmpx file to be examined. */
+extern int utmpxname (__const char *__file) __THROW;
+
+/* Append entry UTMP to the wtmpx-like file WTMPX_FILE. */
+extern void updwtmpx (__const char *__wtmpx_file,
+ __const struct utmpx *__utmpx) __THROW;
+
+
+/* Copy the information in UTMPX to UTMP. */
+extern void getutmp (__const struct utmpx *__utmpx,
+ struct utmp *__utmp) __THROW;
+
+/* Copy the information in UTMP to UTMPX. */
+extern void getutmpx (__const struct utmp *__utmp,
+ struct utmpx *__utmpx) __THROW;
+#endif
+
+__END_DECLS
+
+#endif /* utmpx.h */
diff --git a/ports/sysdeps/unix/sysv/aix/wait3.c b/ports/sysdeps/unix/sysv/aix/wait3.c
new file mode 100644
index 000000000..b0f7faa15
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/wait3.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1992, 93, 1995-1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <stddef.h>
+
+extern pid_t kwaitpid (int *stat_loc, pid_t pid, int options,
+ struct rusage *ru_loc, siginfo_t *infop);
+
+/* 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
+__wait3 (__WAIT_STATUS stat_loc, int options, struct rusage *usage)
+{
+ if (usage != NULL)
+ {
+ __set_errno (ENOSYS);
+ return (pid_t) -1;
+ }
+ return kwaitpid (stat_loc.__iptr, WAIT_ANY, options, usage, NULL);
+}
+strong_alias (__wait3, wait3)
diff --git a/ports/sysdeps/unix/sysv/aix/wait4.c b/ports/sysdeps/unix/sysv/aix/wait4.c
new file mode 100644
index 000000000..dd08f4278
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/wait4.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991, 1992, 1995-1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+extern pid_t kwaitpid (int *stat_loc, pid_t pid, int options,
+ struct rusage *ru_loc, siginfo_t *infop);
+
+pid_t
+__wait4 (__pid_t pid, __WAIT_STATUS stat_loc, int options,
+ struct rusage *usage)
+{
+ return kwaitpid (stat_loc.__iptr, pid, options, usage, NULL);
+}
+strong_alias (__wait4, wait4)
diff --git a/ports/sysdeps/unix/sysv/aix/waitid.c b/ports/sysdeps/unix/sysv/aix/waitid.c
new file mode 100644
index 000000000..1d637df76
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/waitid.c
@@ -0,0 +1,83 @@
+/* Pseudo implementation of waitid.
+ Copyright (C) 1997, 1998, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <signal.h>
+#define __need_NULL
+#include <stddef.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+
+#include <assert.h>
+
+extern pid_t kwaitpid (int *stat_loc, pid_t pid, int options,
+ struct rusage *ru_loc, siginfo_t *infop);
+
+int
+__waitid (idtype, id, infop, options)
+ idtype_t idtype;
+ id_t id;
+ siginfo_t *infop;
+ int options;
+{
+ pid_t pid, child;
+ int status;
+
+ switch (idtype)
+ {
+ case P_PID:
+ if(id <= 0)
+ goto invalid;
+ pid = (pid_t) id;
+ break;
+ case P_PGID:
+ if (id < 0 || id == 1)
+ goto invalid;
+ pid = (pid_t) -id;
+ break;
+ case P_ALL:
+ pid = -1;
+ break;
+ default:
+ invalid:
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ /* Technically we're supposed to return EFAULT if infop is bogus,
+ but that would involve mucking with signals, which is
+ too much hassle. User will have to deal with SIGSEGV/SIGBUS.
+ We just check for a null pointer. */
+
+ if (infop == NULL)
+ {
+ __set_errno (EFAULT);
+ return -1;
+ }
+
+ child = kwaitpid (&status, pid, options, NULL, infop);
+
+ if (child == -1)
+ /* `waitpid' set `errno' for us. */
+ return -1;
+
+ return 0;
+}
+weak_alias (__waitid, waitid)
diff --git a/ports/sysdeps/unix/sysv/aix/waitpid.c b/ports/sysdeps/unix/sysv/aix/waitpid.c
new file mode 100644
index 000000000..19bcbab72
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/waitpid.c
@@ -0,0 +1,53 @@
+/* Copyright (C) 1991,95,96,97,2000,02 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+
+extern pid_t kwaitpid (int *stat_loc, pid_t pid, int options,
+ struct rusage *ru_loc, siginfo_t *infop);
+
+
+/* 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
+__libc_waitpid (pid_t pid, int *stat_loc, int options)
+{
+ if ((options & ~(WNOHANG|WUNTRACED)) != 0)
+ {
+ __set_errno (EINVAL);
+ return (pid_t) -1;
+ }
+
+ return kwaitpid (stat_loc, pid, options, NULL, NULL);
+}
+weak_alias (__libc_waitpid, __waitpid)
+libc_hidden_weak (__waitpid)
+weak_alias (__libc_waitpid, waitpid)
diff --git a/ports/sysdeps/unix/sysv/aix/write.c b/ports/sysdeps/unix/sysv/aix/write.c
new file mode 100644
index 000000000..0cc5d33ac
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/write.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+
+#include "kernel_proto.h"
+
+ssize_t
+__write (fd, ptr, n)
+ int fd;
+ const void *ptr;
+ size_t n;
+{
+ return kwrite (fd, ptr, n);
+}
+libc_hidden_def (__write)
+/* AIX has no weak aliases (yet) but let's hope for better times. */
+weak_alias (__write, write)
+strong_alias (__write, __libc_write)
+libc_hidden_def (__libc_write)
diff --git a/ports/sysdeps/unix/sysv/aix/writev.c b/ports/sysdeps/unix/sysv/aix/writev.c
new file mode 100644
index 000000000..d0e574159
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/writev.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1991, 1995-1998, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/uio.h>
+
+extern ssize_t kwritev (int fd, const struct iovec *iovp, size_t iovcnt,
+ long int ext);
+
+/* 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. */
+ssize_t
+__libc_writev (fd, vector, count)
+ int fd;
+ const struct iovec *vector;
+ int count;
+{
+ return kwritev (fd, vector, count, 0);
+}
+strong_alias (__libc_writev, __writev)
+weak_alias (__libc_writev, writev)
diff --git a/ports/sysdeps/unix/sysv/aix/xstat.c b/ports/sysdeps/unix/sysv/aix/xstat.c
new file mode 100644
index 000000000..c76ad0799
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/xstat.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <sys/stat.h>
+
+#define STX_NORMAL 0x00
+
+extern int statx (const char *pathname, struct stat *st, int len, int cmd);
+
+int
+__xstat (int ver, const char *pathname, struct stat *st)
+{
+ assert (ver == 0);
+ return statx (pathname, st, sizeof (*st), STX_NORMAL);
+}
+hidden_def (__xstat)
diff --git a/ports/sysdeps/unix/sysv/aix/xstat64.c b/ports/sysdeps/unix/sysv/aix/xstat64.c
new file mode 100644
index 000000000..cb1bea118
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/aix/xstat64.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <sys/stat.h>
+
+#define STX_NORMAL 0x00
+#define STX_64 0x08
+
+
+extern int statx (const char *pathname, struct stat64 *st, int len, int cmd);
+
+int
+__xstat64 (int ver, const char *pathname, struct stat64 *st)
+{
+ assert (ver == 0);
+ return statx (pathname, st, sizeof (*st), STX_NORMAL | STX_64);
+}
+hidden_def (__xstat64)
diff --git a/ports/sysdeps/unix/sysv/hpux/bits/errno.h b/ports/sysdeps/unix/sysv/hpux/bits/errno.h
new file mode 100644
index 000000000..c9903c6df
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/hpux/bits/errno.h
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991, 1994, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file defines the `errno' constants. */
+
+#if !defined __Emath_defined && (defined _ERRNO_H || defined __need_Emath)
+#undef __need_Emath
+#define __Emath_defined 1
+
+#endif
+
+#ifdef _ERRNO_H
+#define EBADF 9
+#define ENOMEM 12
+#define EINVAL 22
+#define ERANGE 34
+#define ENOMSG 35
+#define ENOSYS 251
+#endif
diff --git a/ports/sysdeps/unix/sysv/hpux/bits/setjmp.h b/ports/sysdeps/unix/sysv/hpux/bits/setjmp.h
new file mode 100644
index 000000000..216d7bdd6
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/hpux/bits/setjmp.h
@@ -0,0 +1,16 @@
+/* Define the machine-dependent type `jmp_buf'. Stub version. */
+
+#ifndef _SETJMP_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+/* XXX This should go into different files!!! */
+
+#ifdef __hp9000s300
+typedef int __jmp_buf[100];
+#endif /* __hp9000s300 */
+
+#ifdef __hp9000s800
+typedef double __jmp_buf[25];
+#endif /* __hp9000s800 */
+
diff --git a/ports/sysdeps/unix/sysv/hpux/bits/stat.h b/ports/sysdeps/unix/sysv/hpux/bits/stat.h
new file mode 100644
index 000000000..845b29765
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/hpux/bits/stat.h
@@ -0,0 +1,128 @@
+/* Copyright (C) 1992, 95, 96, 97, 98, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_STAT_H
+# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+/* Versions of the `struct stat' data structure. */
+#define _STAT_VER_SVR4 1
+#define _STAT_VER _STAT_VER_SVR4 /* The one defined below. */
+
+/* Versions of the `xmknod' interface. */
+#define _MKNOD_VER_SVR4 1
+#define _MKNOD_VER _MKNOD_VER_SVR4 /* The bits defined below. */
+
+
+struct stat
+ {
+ __dev_t st_dev; /* Device. */
+ unsigned short int __pad1;
+#ifndef __USE_FILE_OFFSET64
+ __ino_t st_ino; /* File serial number. */
+#else
+ __ino64_t st_ino; /* File serial number. */
+#endif
+ __mode_t st_mode; /* File mode. */
+ __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.*/
+ __dev_t st_rdev; /* Device number, if device. */
+ unsigned short int __pad2;
+#ifndef __USE_FILE_OFFSET64
+ __off_t st_size; /* Size of file, in bytes. */
+#else
+ __off64_t st_size; /* Size of file, in bytes. */
+#endif
+ unsigned long int st_blksize; /* Optimal block size for I/O. */
+
+#ifndef __USE_FILE_OFFSET64
+ __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
+#else
+ __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
+#endif
+ __time_t st_atime; /* Time of last access. */
+ unsigned long int __unused1;
+ __time_t st_mtime; /* Time of last modification. */
+ unsigned long int __unused2;
+ __time_t st_ctime; /* Time of last status change. */
+ unsigned long int __unused3;
+ unsigned long int __unused4;
+ unsigned long int __unused5;
+ };
+
+#ifdef __USE_LARGEFILE64
+struct stat64
+ {
+ __dev_t st_dev; /* Device. */
+ unsigned short int __pad1;
+
+ __ino64_t st_ino; /* File serial number. */
+ __mode_t st_mode; /* File mode. */
+ __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.*/
+ __dev_t st_rdev; /* Device number, if device. */
+ unsigned short int __pad2;
+ __off64_t st_size; /* Size of file, in bytes. */
+ unsigned long int st_blksize; /* Optimal block size for I/O. */
+
+ __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
+ __time_t st_atime; /* Time of last access. */
+ unsigned long int __unused1;
+ __time_t st_mtime; /* Time of last modification. */
+ unsigned long int __unused2;
+ __time_t st_ctime; /* Time of last status change. */
+ unsigned long int __unused3;
+ unsigned long int __unused4;
+ unsigned long int __unused5;
+ };
+#endif
+
+/* Tell code we have these members. */
+#define _STATBUF_ST_BLKSIZE
+#define _STATBUF_ST_RDEV
+
+/* 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. */
+
+/* POSIX.1b objects. */
+#define __S_TYPEISMQ(buf) (0)
+#define __S_TYPEISSEM(buf) (0)
+#define __S_TYPEISSHM(buf) (0)
+
+/* 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. */
diff --git a/ports/sysdeps/unix/sysv/hpux/bits/types.h b/ports/sysdeps/unix/sysv/hpux/bits/types.h
new file mode 100644
index 000000000..e231841a8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/hpux/bits/types.h
@@ -0,0 +1,128 @@
+/* Copyright (C) 1991,1992,1994-1998,2000,2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/*
+ * Never include this file directly; use <sys/types.h> instead.
+ */
+
+#ifndef _BITS_TYPES_H
+#define _BITS_TYPES_H 1
+
+#include <features.h>
+
+#define __need_size_t
+#include <stddef.h>
+
+/* Convenience types. */
+typedef unsigned char __u_char;
+typedef unsigned short __u_short;
+typedef unsigned int __u_int;
+typedef unsigned long __u_long;
+#ifdef __GNUC__
+__extension__ typedef unsigned long long int __u_quad_t;
+__extension__ typedef long long int __quad_t;
+#else
+typedef struct
+ {
+ long int __val[2];
+ } __quad_t;
+typedef struct
+ {
+ __u_long __val[2];
+ } __u_quad_t;
+#endif
+typedef signed char __int8_t;
+typedef unsigned char __uint8_t;
+typedef signed short int __int16_t;
+typedef unsigned short int __uint16_t;
+typedef signed int __int32_t;
+typedef unsigned int __uint32_t;
+#ifdef __GNUC__
+__extension__ typedef signed long long int __int64_t;
+__extension__ typedef unsigned long long int __uint64_t;
+#endif
+typedef __quad_t *__qaddr_t;
+
+typedef long int __dev_t; /* Type of device numbers. */
+typedef long int __uid_t; /* Type of user identifications. */
+typedef long int __gid_t; /* Type of group identifications. */
+typedef __u_long __ino_t; /* Type of file serial numbers. */
+typedef __u_short __mode_t; /* Type of file attribute bitmasks. */
+typedef short __nlink_t; /* Type of file link counts. */
+typedef long int __off_t; /* Type of file sizes and offsets. */
+typedef __quad_t __loff_t; /* Type of file sizes and offsets. */
+typedef long int __pid_t; /* Type of process identifications. */
+typedef long int __ssize_t; /* Type of a byte count, or error. */
+typedef __u_long __rlim_t; /* Type of resource counts. */
+typedef __quad_t __rlim64_t; /* Type of resource counts (LFS). */
+typedef long int __id_t; /* General type for ID. */
+
+typedef struct
+ {
+ long int __val[2];
+ } __fsid_t; /* Type of file system IDs. */
+
+/* Everythin' else. */
+typedef long int __daddr_t; /* The type of a disk address. */
+typedef char *__caddr_t;
+typedef long int __time_t;
+typedef long int __swblk_t; /* Type of a swap block maybe? */
+
+typedef __u_long __clock_t;
+
+/* Number of descriptors that can fit in an `fd_set'. */
+#define __FD_SETSIZE 2048
+
+
+typedef long int __key_t;
+
+/* Used in `struct shmid_ds'. */
+typedef unsigned short int __ipc_pid_t;
+
+
+/* Types from the Large File Support interface. */
+
+/* Type to count number os disk blocks. */
+typedef __u_long __blkcnt_t;
+typedef __u_quad_t __blkcnt64_t;
+
+/* Type to count file system blocks. */
+typedef long int __fsblkcnt_t;
+typedef __quad_t __fsblkcnt64_t;
+
+/* Type to count file system inodes. */
+typedef __u_long __fsfilcnt_t;
+typedef __u_quad_t __fsfilcnt64_t;
+
+/* Type of file serial numbers. */
+typedef __u_long __ino64_t;
+
+/* Type of file sizes and offsets. */
+typedef __loff_t __off64_t;
+
+/* Used in XTI. */
+typedef int __t_scalar_t;
+typedef unsigned int __t_uscalar_t;
+
+/* Duplicates info from stdint.h but this is used in unistd.h. */
+typedef int __intptr_t;
+
+/* Duplicate info from sys/socket.h. */
+typedef unsigned int __socklen_t;
+
+#endif /* bits/types.h */
diff --git a/ports/sysdeps/unix/sysv/hpux/sysdep.h b/ports/sysdeps/unix/sysv/hpux/sysdep.h
new file mode 100644
index 000000000..89a337711
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/hpux/sysdep.h
@@ -0,0 +1,26 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper, <drepper@cygnus.com>, August 1999.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* No underscores necessary. */
+#define NO_UNDERSCORES
+
+#include <sysdeps/hppa/sysdep.h>
+
+/* HPUX uses the usual syscall naming. */
+#define SYS_ify(name) SYS_##name
diff --git a/ports/sysdeps/unix/sysv/i386/signal.S b/ports/sysdeps/unix/sysv/i386/signal.S
new file mode 100644
index 000000000..af51bc518
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/i386/signal.S
@@ -0,0 +1,31 @@
+/* Copyright (C) 1992, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/sysv/i386/sigreturn.S b/ports/sysdeps/unix/sysv/i386/sigreturn.S
new file mode 100644
index 000000000..edf4418c5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/i386/sigreturn.S
@@ -0,0 +1,27 @@
+/* Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/sysv/irix4/Implies b/ports/sysdeps/unix/sysv/irix4/Implies
new file mode 100644
index 000000000..35e1edd83
--- /dev/null
+++ b/ports/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/ports/sysdeps/unix/sysv/irix4/Makefile b/ports/sysdeps/unix/sysv/irix4/Makefile
new file mode 100644
index 000000000..d07981e8f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/Makefile
@@ -0,0 +1,25 @@
+# Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+ifeq ($(subdir),signal)
+sysdep_routines := $(sysdep_routines) sigtramp __handler
+endif
+
+ifeq ($(subdir),misc)
+sysdep_routines := $(sysdep_routines) syssgi sysmp
+endif
diff --git a/ports/sysdeps/unix/sysv/irix4/__handler.S b/ports/sysdeps/unix/sysv/irix4/__handler.S
new file mode 100644
index 000000000..f02121a0c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/__handler.S
@@ -0,0 +1,117 @@
+/* Copyright (C) 1992, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/sysv/irix4/bits/confname.h b/ports/sysdeps/unix/sysv/irix4/bits/confname.h
new file mode 100644
index 000000000..ed334694c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/bits/confname.h
@@ -0,0 +1,84 @@
+/* `sysconf', `pathconf', and `confstr' NAME values. Irix 4 version.
+ Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _UNISTD_H
+# error "Never use <bits/confname.h> directly; include <unistd.h> instead."
+#endif
+
+/* 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/ports/sysdeps/unix/sysv/irix4/bits/fcntl.h b/ports/sysdeps/unix/sysv/irix4/bits/fcntl.h
new file mode 100644
index 000000000..5eb7c76eb
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/bits/fcntl.h
@@ -0,0 +1,109 @@
+/* O_*, F_*, FD_* bit values for SGI Irix 4.
+ Copyright (C) 1994, 1997, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FCNTL_H
+#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+
+/* 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_FSYNC O_SYNC
+#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. */
+#endif
+#if defined __USE_BSD || defined __USE_UNIX98
+#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 <bits/types.h>
+
+/* The structure describing an advisory lock. This is the type of the third
+ argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests. */
+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. */
+
+
+/* Define some more compatibility macros to be backward compatible with
+ BSD systems which did not managed to hide these kernel macros. */
+#ifdef __USE_BSD
+#define FAPPEND O_APPEND
+#define FFSYNC O_FSYNC
+#define FASYNC O_ASYNC
+#define FNONBLOCK O_NONBLOCK
+#define FNDELAY O_NDELAY
+#endif /* Use BSD. */
diff --git a/ports/sysdeps/unix/sysv/irix4/bits/mman.h b/ports/sysdeps/unix/sysv/irix4/bits/mman.h
new file mode 100644
index 000000000..1549ff01c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/bits/mman.h
@@ -0,0 +1,64 @@
+/* Definitions for BSD-style memory management. Irix 4 version.
+ Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _BITS_MMAN_H
+#define _BITS_MMAN_H 1
+
+/* 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. */
+#ifdef __USE_MISC
+# define PROT_EXECUTE PROT_EXEC
+#endif
+
+/* 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. */
+#ifdef __USE_BSD
+# define MAP_TYPE 0x0f /* Mask for sharing type. */
+#endif
+
+/* Other flags. */
+#define MAP_FIXED 0x10 /* Map address must be exactly as requested. */
+#ifdef __USE_MISC
+# 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. */
+#endif
+
+/* Advice to `madvise'. */
+#ifdef __USE_BSD
+# 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. */
+#endif
+
+/* Flags to `msync'. */
+#define MS_ASYNC 0x1 /* Return immediately, don't fsync. */
+#define MS_INVALIDATE 0x2 /* Invalidate caches. */
+
+#endif /* bits/mman.h */
diff --git a/ports/sysdeps/unix/sysv/irix4/bits/signum.h b/ports/sysdeps/unix/sysv/irix4/bits/signum.h
new file mode 100644
index 000000000..c96ab9d2b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/bits/signum.h
@@ -0,0 +1,69 @@
+/* Signal number definitions. Irix4 version.
+ Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/sysv/irix4/bits/stat.h b/ports/sysdeps/unix/sysv/irix4/bits/stat.h
new file mode 100644
index 000000000..33f575db1
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/bits/stat.h
@@ -0,0 +1,65 @@
+/* Copyright (C) 1992, 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_STAT_H
+# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+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. */
+
+/* POSIX.1b objects. */
+#define __S_TYPEISMQ(buf) (0)
+#define __S_TYPEISSEM(buf) (0)
+#define __S_TYPEISSHM(buf) (0)
+
+/* 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. */
diff --git a/ports/sysdeps/unix/sysv/irix4/dup2.c b/ports/sysdeps/unix/sysv/irix4/dup2.c
new file mode 100644
index 000000000..86720b1b7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/dup2.c
@@ -0,0 +1,3 @@
+#include <sysdeps/posix/__dup2.c>
+
+weak_alias (__dup2, dup2)
diff --git a/ports/sysdeps/unix/sysv/irix4/fpathconf.c b/ports/sysdeps/unix/sysv/irix4/fpathconf.c
new file mode 100644
index 000000000..236eb1a6b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/fpathconf.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1994, 1995, 1997, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <sys/syssgi.h>
+
+extern int __syssgi (int, ...);
+
+/* Get file-specific information about descriptor FD. */
+long int
+__fpathconf (fd, name)
+ int fd;
+ int name;
+{
+ return __syssgi (SGI_PATHCONF, FPATHCONF, fd, name);
+}
+
+weak_alias (__fpathconf, fpathconf)
diff --git a/ports/sysdeps/unix/sysv/irix4/getgroups.c b/ports/sysdeps/unix/sysv/irix4/getgroups.c
new file mode 100644
index 000000000..4c859eac8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/getgroups.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1994, 1995, 1997, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/syssgi.h>
+#include <sys/types.h>
+#include <grp.h>
+
+extern int __syssgi (int, ...);
+
+/* Set the group set for the current user to GROUPS (N of them). */
+int
+__getgroups (n, groups)
+ size_t n;
+ gid_t *groups;
+{
+ return __syssgi (SGI_GETGROUPS, n, groups);
+}
+
+weak_alias (__getgroups, getgroups)
diff --git a/ports/sysdeps/unix/sysv/irix4/getpriority.c b/ports/sysdeps/unix/sysv/irix4/getpriority.c
new file mode 100644
index 000000000..807ac2fba
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/getpriority.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1994,96,97,2000,02, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sys/resource.h>
+#include <sys/sysmp.h>
+
+extern int __sysmp (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
+getpriority (which, who)
+ enum __priority_which which;
+ id_t 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);
+ }
+
+ __set_errno (EINVAL);
+ return -1;
+}
+libc_hidden_def (getpriority)
diff --git a/ports/sysdeps/unix/sysv/irix4/getrusage.c b/ports/sysdeps/unix/sysv/irix4/getrusage.c
new file mode 100644
index 000000000..3cabbdf3e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/getrusage.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1994, 1995, 1997, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/resource.h>
+#include <errno.h>
+#include <sys/syssgi.h>
+
+extern int __syssgi (int, ...);
+
+/* Return resource usage information on process indicated by WHO
+ and put it in *USAGE. Returns 0 for success, -1 for failure. */
+int
+__getrusage (who, usage)
+ enum __rusage_who who;
+ struct rusage *usage;
+{
+ return __syssgi (SGI_RUSAGE, who, usage);
+}
+
+weak_alias (__getrusage, getrusage)
diff --git a/ports/sysdeps/unix/sysv/irix4/gettimeofday.c b/ports/sysdeps/unix/sysv/irix4/gettimeofday.c
new file mode 100644
index 000000000..d7055be82
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/gettimeofday.c
@@ -0,0 +1 @@
+#include <sysdeps/posix/gettimeofday.c>
diff --git a/ports/sysdeps/unix/sysv/irix4/pathconf.c b/ports/sysdeps/unix/sysv/irix4/pathconf.c
new file mode 100644
index 000000000..51da0c563
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/pathconf.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1994, 1995, 1997, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <sys/syssgi.h>
+
+extern int __syssgi (int, ...);
+
+/* Get file-specific information about PATH. */
+long int
+__pathconf (path, name)
+ const char *path;
+ int name;
+{
+ return __syssgi (SGI_PATHCONF, PATHCONF, path, name);
+}
+
+weak_alias (__pathconf, pathconf)
diff --git a/ports/sysdeps/unix/sysv/irix4/readv.c b/ports/sysdeps/unix/sysv/irix4/readv.c
new file mode 100644
index 000000000..baa976da6
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/readv.c
@@ -0,0 +1 @@
+#include <sysdeps/posix/readv.c>
diff --git a/ports/sysdeps/unix/sysv/irix4/reboot.c b/ports/sysdeps/unix/sysv/irix4/reboot.c
new file mode 100644
index 000000000..7c9dbba77
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/reboot.c
@@ -0,0 +1 @@
+#include <misc/reboot.c>
diff --git a/ports/sysdeps/unix/sysv/irix4/setgroups.c b/ports/sysdeps/unix/sysv/irix4/setgroups.c
new file mode 100644
index 000000000..cca816bcf
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/setgroups.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1994,97,2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/syssgi.h>
+#include <sys/types.h>
+#include <grp.h>
+
+extern int __syssgi (int, ...);
+
+/* Set the group set for the current user to GROUPS (N of them). */
+int
+setgroups (n, groups)
+ size_t n;
+ const gid_t *groups;
+{
+ return __syssgi (SGI_SETGROUPS, n, groups);
+}
+libc_hidden_def (setgroups)
diff --git a/ports/sysdeps/unix/sysv/irix4/setpriority.c b/ports/sysdeps/unix/sysv/irix4/setpriority.c
new file mode 100644
index 000000000..99353187f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/setpriority.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1994,96,97,2000,02 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sys/resource.h>
+#include <sys/sysmp.h>
+
+int
+setpriority (which, who, prio)
+ enum __priority_which which;
+ id_t who;
+ 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);
+ }
+
+ __set_errno (EINVAL);
+ return -1;
+}
+libc_hidden_def (setpriority)
diff --git a/ports/sysdeps/unix/sysv/irix4/sigreturn.S b/ports/sysdeps/unix/sysv/irix4/sigreturn.S
new file mode 100644
index 000000000..296db1d47
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/sigreturn.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1992, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+ENTRY(__sigreturn)
+ li v0, SYS_sigreturn
+ syscall
+
+weak_alias (__sigreturn, sigreturn)
diff --git a/ports/sysdeps/unix/sysv/irix4/sigtramp.c b/ports/sysdeps/unix/sysv/irix4/sigtramp.c
new file mode 100644
index 000000000..f8de75a7c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/sigtramp.c
@@ -0,0 +1,53 @@
+/* Copyright (C) 1992, 1997, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 <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 __raw_signal (int sig, __sighandler_t func,
+ void (*)(int sig, int code,
+ struct sigcontext *,
+ handler_type));
+
+extern void __handler (int sig, int code, struct sigcontext *,
+ handler_type);
+
+__sighandler_t
+signal (sig, func)
+ int sig;
+ __sighandler_t func;
+{
+ return __raw_signal (sig, func, __handler);
+}
diff --git a/ports/sysdeps/unix/sysv/irix4/start.c b/ports/sysdeps/unix/sysv/irix4/start.c
new file mode 100644
index 000000000..fdda8809e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/start.c
@@ -0,0 +1,75 @@
+/* Copyright (C) 1991,1992,1995,1996,1997,2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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;
+
+extern void __libc_init (int argc, char **argv, char **envp);
+extern int 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
+__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/ports/sysdeps/unix/sysv/irix4/swapon.c b/ports/sysdeps/unix/sysv/irix4/swapon.c
new file mode 100644
index 000000000..43c5222a4
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/swapon.c
@@ -0,0 +1 @@
+#include <misc/swapon.c>
diff --git a/ports/sysdeps/unix/sysv/irix4/syscalls.list b/ports/sysdeps/unix/sysv/irix4/syscalls.list
new file mode 100644
index 000000000..a57529e9a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/syscalls.list
@@ -0,0 +1,8 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+getpgid - bsdgetpgrp 1 __getpgid getpgid
+msync - msync 3 msync
+setpgid - bsdsetpgrp 2 __setpgid setpgid
+signal - signal 3 __raw_signal
+sysmp - sysmp 4 __sysmp
+syssgi - syssgi 2 __syssgi
diff --git a/ports/sysdeps/unix/sysv/irix4/sysconf.c b/ports/sysdeps/unix/sysv/irix4/sysconf.c
new file mode 100644
index 000000000..ef7606eda
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/sysconf.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1994, 1995, 1997, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+#include <sys/syssgi.h>
+
+extern int __syssgi ((int, ...);
+
+/* Get the value of the system variable NAME. */
+long int
+__sysconf (name)
+ int name;
+{
+ if (name == _SC_TZNAME_MAX)
+ return __tzname_max ();
+
+ return __syssgi (SGI_SYSCONF, name);
+}
+
+weak_alias (__sysconf, sysconf)
+libc_hidden_def (__sysconf)
diff --git a/ports/sysdeps/unix/sysv/irix4/uname.S b/ports/sysdeps/unix/sysv/irix4/uname.S
new file mode 100644
index 000000000..0b6536fd2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/uname.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+ENTRY(uname)
+ li a2, 0
+ li a3, 0
+SYSCALL__ (utssys, 1)
+ j ra
+ move v0, zero
diff --git a/ports/sysdeps/unix/sysv/irix4/wait.S b/ports/sysdeps/unix/sysv/irix4/wait.S
new file mode 100644
index 000000000..90cd5948e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/wait.S
@@ -0,0 +1,43 @@
+/* Copyright (C) 1992, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/sysv/irix4/waitpid.c b/ports/sysdeps/unix/sysv/irix4/waitpid.c
new file mode 100644
index 000000000..8378982ac
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/waitpid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/bsd4.4/waitpid.c>
diff --git a/ports/sysdeps/unix/sysv/irix4/writev.c b/ports/sysdeps/unix/sysv/irix4/writev.c
new file mode 100644
index 000000000..0dc6a7601
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/irix4/writev.c
@@ -0,0 +1 @@
+#include <sysdeps/posix/writev.c>
diff --git a/ports/sysdeps/unix/sysv/isc2.2/syscalls.list b/ports/sysdeps/unix/sysv/isc2.2/syscalls.list
new file mode 100644
index 000000000..0ea253e3c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/isc2.2/syscalls.list
@@ -0,0 +1,2 @@
+# File name Caller Syscall name # args Strong name Weak names
+
diff --git a/ports/sysdeps/unix/sysv/linux/am33/Makefile b/ports/sysdeps/unix/sysv/linux/am33/Makefile
new file mode 100644
index 000000000..ece39e8a4
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),misc)
+sysdep_routines += setfsgid setfsuid
+endif
diff --git a/ports/sysdeps/unix/sysv/linux/am33/bits/fcntl.h b/ports/sysdeps/unix/sysv/linux/am33/bits/fcntl.h
new file mode 100644
index 000000000..4c276c548
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/bits/fcntl.h
@@ -0,0 +1,179 @@
+/* O_*, F_*, FD_* bit values for Linux.
+ Copyright (C) 1995, 1996, 1997, 1998, 2000, Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+
+#include <sys/types.h>
+
+/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
+ located on an ext2 file system */
+#define O_ACCMODE 0003
+#define O_RDONLY 00
+#define O_WRONLY 01
+#define O_RDWR 02
+#define O_CREAT 0100 /* not fcntl */
+#define O_EXCL 0200 /* not fcntl */
+#define O_NOCTTY 0400 /* not fcntl */
+#define O_TRUNC 01000 /* not fcntl */
+#define O_APPEND 02000
+#define O_NONBLOCK 04000
+#define O_NDELAY O_NONBLOCK
+#define O_SYNC 010000
+#define O_FSYNC O_SYNC
+#define O_ASYNC 020000
+
+#ifdef __USE_GNU
+# define O_DIRECT 040000 /* Direct disk access. */
+# define O_DIRECTORY 0200000 /* Must be a directory. */
+# define O_NOFOLLOW 0400000 /* Do not follow links. */
+#endif
+
+/* For now Linux has synchronisity options for data and read operations.
+ We define the symbols here but let them do the same as O_SYNC since
+ this is a superset. */
+#if defined __USE_POSIX199309 || defined __USE_UNIX98
+# define O_DSYNC O_SYNC /* Synchronize data. */
+# define O_RSYNC O_SYNC /* Synchronize read operations. */
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define O_LARGEFILE 0100000
+#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. */
+#ifndef __USE_FILE_OFFSET64
+# define F_GETLK 5 /* Get record locking info. */
+# define F_SETLK 6 /* Set record locking info (non-blocking). */
+# define F_SETLKW 7 /* Set record locking info (blocking). */
+#else
+# define F_GETLK F_GETLK64 /* Get record locking info. */
+# define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/
+# define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
+#endif
+#define F_GETLK64 12 /* Get record locking info. */
+#define F_SETLK64 13 /* Set record locking info (non-blocking). */
+#define F_SETLKW64 14 /* Set record locking info (blocking). */
+
+#if defined __USE_BSD || defined __USE_XOPEN2K
+# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */
+# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETSIG 10 /* Set number of signal to be sent. */
+# define F_GETSIG 11 /* Get number of signal to be sent. */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETLEASE 1024 /* Set a lease. */
+# define F_GETLEASE 1025 /* Enquire what lease is active. */
+# define F_NOTIFY 1026 /* Request notfications on a directory. */
+#endif
+
+/* For F_[GET|SET]FL. */
+#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
+
+/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
+#define F_RDLCK 0 /* Read lock. */
+#define F_WRLCK 1 /* Write lock. */
+#define F_UNLCK 2 /* Remove lock. */
+
+/* For old implementation of bsd flock(). */
+#define F_EXLCK 4 /* or 3 */
+#define F_SHLCK 8 /* or 4 */
+
+#ifdef __USE_BSD
+/* Operations for bsd flock(), also used by the kernel implementation. */
+# define LOCK_SH 1 /* shared lock */
+# define LOCK_EX 2 /* exclusive lock */
+# define LOCK_NB 4 /* or'd with one of the above to prevent
+ blocking */
+# define LOCK_UN 8 /* remove lock */
+#endif
+
+#ifdef __USE_GNU
+# define LOCK_MAND 32 /* This is a mandatory flock: */
+# define LOCK_READ 64 /* ... which allows concurrent read operations. */
+# define LOCK_WRITE 128 /* ... which allows concurrent write operations. */
+# define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */
+#endif
+
+#ifdef __USE_GNU
+/* Types of directory notifications that may be requested with F_NOTIFY. */
+# define DN_ACCESS 0x00000001 /* File accessed. */
+# define DN_MODIFY 0x00000002 /* File modified. */
+# define DN_CREATE 0x00000004 /* File created. */
+# define DN_DELETE 0x00000008 /* File removed. */
+# define DN_RENAME 0x00000010 /* File renamed. */
+# define DN_ATTRIB 0x00000020 /* File changed attibutes. */
+# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
+#endif
+
+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'). */
+#ifndef __USE_FILE_OFFSET64
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+#else
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+#endif
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+
+#ifdef __USE_LARGEFILE64
+struct flock64
+ {
+ 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'). */
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+#endif
+
+/* Define some more compatibility macros to be backward compatible with
+ BSD systems which did not managed to hide these kernel macros. */
+#ifdef __USE_BSD
+# define FAPPEND O_APPEND
+# define FFSYNC O_FSYNC
+# define FASYNC O_ASYNC
+# define FNONBLOCK O_NONBLOCK
+# define FNDELAY O_NDELAY
+#endif /* Use BSD. */
+
+/* Advise to `posix_fadvise'. */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
+# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
+# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
+# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
+# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/am33/bits/mman.h b/ports/sysdeps/unix/sysv/linux/am33/bits/mman.h
new file mode 100644
index 000000000..99fceda88
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/bits/mman.h
@@ -0,0 +1,97 @@
+/* Definitions for POSIX memory map interface. Linux/AM33 version.
+ Copyright (C) 1997, 2000, 2001, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _SYS_MMAN_H
+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
+#endif
+
+/* The following definitions basically come from the kernel headers.
+ But the kernel header is not namespace clean. */
+
+
+/* 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_READ 0x1 /* Page can be read. */
+#define PROT_WRITE 0x2 /* Page can be written. */
+#define PROT_EXEC 0x4 /* Page can be executed. */
+#define PROT_NONE 0x0 /* Page can not be accessed. */
+#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
+ growsdown vma (mprotect only). */
+#define PROT_GROWSUP 0x02000000 /* Extend change to start of
+ growsup vma (mprotect only). */
+
+/* Sharing types (must choose one and only one of these). */
+#define MAP_SHARED 0x01 /* Share changes. */
+#define MAP_PRIVATE 0x02 /* Changes are private. */
+#ifdef __USE_MISC
+# define MAP_TYPE 0x0f /* Mask for type of mapping. */
+#endif
+
+/* Other flags. */
+#define MAP_FIXED 0x10 /* Interpret addr exactly. */
+#ifdef __USE_MISC
+# define MAP_FILE 0
+# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
+# define MAP_ANON MAP_ANONYMOUS
+#endif
+
+/* These are Linux-specific. */
+#ifdef __USE_MISC
+# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
+# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
+# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
+# define MAP_LOCKED 0x2000 /* Lock the mapping. */
+# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
+#endif
+
+/* Flags to `msync'. */
+#define MS_ASYNC 1 /* Sync memory asynchronously. */
+#define MS_SYNC 4 /* Synchronous memory sync. */
+#define MS_INVALIDATE 2 /* Invalidate the caches. */
+
+/* Flags for `mlockall'. */
+#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
+#define MCL_FUTURE 2 /* Lock all additions to address
+ space. */
+
+/* Flags for `mremap'. */
+#ifdef __USE_GNU
+# define MREMAP_MAYMOVE 1
+#endif
+
+/* Advice to `madvise'. */
+#ifdef __USE_BSD
+# 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. */
+#endif
+
+/* The POSIX people had to invent similar names for the same things. */
+#ifdef __USE_XOPEN2K
+# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
+# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
+# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
+# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/am33/brk.c b/ports/sysdeps/unix/sysv/linux/am33/brk.c
new file mode 100644
index 000000000..f56736359
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/brk.c
@@ -0,0 +1,46 @@
+/* brk system call for Linux/am33.
+ Copyright (C) 1995, 1996, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>.
+ Based on ../i386/brk.c.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sysdep.h>
+
+/* This must be initialized data because commons can't have aliases. */
+void *__curbrk = 0;
+
+int
+__brk (void *addr)
+{
+ void *newbrk;
+
+ newbrk = INLINE_SYSCALL (brk, 1, __ptrvalue (addr));
+
+ __curbrk = newbrk;
+
+ if (newbrk < addr)
+ {
+ __set_errno (ENOMEM);
+ return -1;
+ }
+
+ return 0;
+}
+weak_alias (__brk, brk)
diff --git a/ports/sysdeps/unix/sysv/linux/am33/chown.c b/ports/sysdeps/unix/sysv/linux/am33/chown.c
new file mode 100644
index 000000000..819923eb4
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/chown.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/chown.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/clone.S b/ports/sysdeps/unix/sysv/linux/am33/clone.S
new file mode 100644
index 000000000..26ba740d2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/clone.S
@@ -0,0 +1,81 @@
+/* Copyright 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>.
+ Based on ../i386/clone.S.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* clone() is even more special than fork() as it mucks with stacks
+ and invokes a function in the right context after its all over. */
+
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <asm-syntax.h>
+#include <bp-sym.h>
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
+
+ .text
+ENTRY (BP_SYM (__clone))
+ /* Sanity check arguments. */
+ cmp 0,d0 /* no NULL function pointers */
+ beq L(error_inval)
+ cmp 0,d1 /* no NULL stack pointers */
+ beq L(error_inval)
+
+ /* Allocate room for a function call in the new stack, and
+ store fn and arg in it. They will be read back in
+ thread_start. */
+ mov d1,a0
+ sub 12,a0
+ mov d0,(a0)
+ mov (16,sp),d1
+ mov d1,(4,a0)
+
+ /* Do the system call */
+ mov a0,d1
+ mov (12,sp),a0
+ mov SYS_ify(clone),d0
+ syscall 0
+
+ cmp 0,d0
+ beq thread_start
+ blt L(to_SYSCALL_ERROR_LABEL)
+
+L(pseudo_end):
+ ret
+
+L(error_inval):
+ mov -EINVAL,d0
+L(to_SYSCALL_ERROR_LABEL):
+ jmp SYSCALL_ERROR_LABEL
+
+thread_start:
+ mov 0,a3 /* terminate the stack frame */
+ mov (4,sp),d0
+ mov (sp),a0
+ calls (a0)
+#ifdef PIC
+L(here):
+ mov pc,a2
+ add _GLOBAL_OFFSET_TABLE_-(L(here) - .),a2
+#endif
+ call JUMPTARGET (_exit),[],0
+
+PSEUDO_END (BP_SYM (__clone))
+
+weak_alias (BP_SYM (__clone), BP_SYM (clone))
diff --git a/ports/sysdeps/unix/sysv/linux/am33/configure b/ports/sysdeps/unix/sysv/linux/am33/configure
new file mode 100755
index 000000000..d4490122b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/configure
@@ -0,0 +1,4 @@
+# This file is generated from configure.in by Autoconf. DO NOT EDIT!
+ # Local configure fragment for am33/sysdeps/unix/sysv/linux/am33
+
+arch_minimum_kernel=2.4.0
diff --git a/ports/sysdeps/unix/sysv/linux/am33/configure.in b/ports/sysdeps/unix/sysv/linux/am33/configure.in
new file mode 100644
index 000000000..a94c370cf
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/configure.in
@@ -0,0 +1,4 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for am33/sysdeps/unix/sysv/linux/am33
+
+arch_minimum_kernel=2.4.0
diff --git a/ports/sysdeps/unix/sysv/linux/am33/fchown.c b/ports/sysdeps/unix/sysv/linux/am33/fchown.c
new file mode 100644
index 000000000..3a69ecc9e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/fchown.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fchown.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/fcntl.c b/ports/sysdeps/unix/sysv/linux/am33/fcntl.c
new file mode 100644
index 000000000..ea951bc4f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/fcntl.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/fxstat.c b/ports/sysdeps/unix/sysv/linux/am33/fxstat.c
new file mode 100644
index 000000000..4f219f0b9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/fxstat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/getegid.c b/ports/sysdeps/unix/sysv/linux/am33/getegid.c
new file mode 100644
index 000000000..37b4b4a53
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/getegid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getegid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/geteuid.c b/ports/sysdeps/unix/sysv/linux/am33/geteuid.c
new file mode 100644
index 000000000..ebcb555b5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/geteuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/geteuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/getgid.c b/ports/sysdeps/unix/sysv/linux/am33/getgid.c
new file mode 100644
index 000000000..0a4d6061f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/getgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/getgroups.c b/ports/sysdeps/unix/sysv/linux/am33/getgroups.c
new file mode 100644
index 000000000..20a716610
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/getgroups.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getgroups.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/getmsg.c b/ports/sysdeps/unix/sysv/linux/am33/getmsg.c
new file mode 100644
index 000000000..3a1fa0852
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/getmsg.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getmsg.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/getresgid.c b/ports/sysdeps/unix/sysv/linux/am33/getresgid.c
new file mode 100644
index 000000000..b703a414c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/getresgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getresgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/getresuid.c b/ports/sysdeps/unix/sysv/linux/am33/getresuid.c
new file mode 100644
index 000000000..0b14cefe3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/getresuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getresuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/getrlimit.c b/ports/sysdeps/unix/sysv/linux/am33/getrlimit.c
new file mode 100644
index 000000000..fc06dbd64
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/getrlimit.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getrlimit.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/getuid.c b/ports/sysdeps/unix/sysv/linux/am33/getuid.c
new file mode 100644
index 000000000..d682c79a4
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/getuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/lchown.c b/ports/sysdeps/unix/sysv/linux/am33/lchown.c
new file mode 100644
index 000000000..c89de99ba
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/lchown.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/lchown.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/linuxthreads/sysdep-cancel.h b/ports/sysdeps/unix/sysv/linux/am33/linuxthreads/sysdep-cancel.h
new file mode 100644
index 000000000..56d3bb62f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/linuxthreads/sysdep-cancel.h
@@ -0,0 +1,159 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <tls.h>
+#include <pt-machine.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .text ; \
+ ENTRY (name) \
+ PUSHARGS_##args \
+ DOARGS_##args \
+ SINGLE_THREAD_P; \
+ bne L(pseudo_cancel); \
+ mov SYS_ify (syscall_name),d0; \
+ syscall 0 \
+ POPARGS_##args ; \
+ cmp -126,d0; \
+ bls L(pseudo_end); \
+ jmp SYSCALL_ERROR_LABEL; \
+ L(pseudo_cancel): \
+ add -(16+STACK_SPACE (args)),sp; \
+ SAVE_ARGS_##args \
+ CENABLE \
+ mov d0,r0; \
+ LOAD_ARGS_##args \
+ mov SYS_ify (syscall_name),d0; \
+ syscall 0; \
+ mov d0,(12,sp); \
+ mov r0,d0; \
+ CDISABLE \
+ mov (12,sp),d0; \
+ add +16+STACK_SPACE (args),sp \
+ POPARGS_##args ; \
+ cmp -126,d0; \
+ bls L(pseudo_end); \
+ jmp SYSCALL_ERROR_LABEL; \
+ L(pseudo_end): \
+ mov d0,a0
+
+/* Reserve up to 2 stack slots for a0 and d1, but fewer than that if
+ we don't have that many arguments. */
+# define STACK_SPACE(n) (((((n) < 3) * (2 - (n))) + 2) * 4)
+
+# define SAVE_ARGS_0
+# define SAVE_ARGS_1 mov a0,(20,sp) ;
+# define SAVE_ARGS_2 SAVE_ARGS_1 mov d1,(24,sp) ;
+# define SAVE_ARGS_3 SAVE_ARGS_2
+# define SAVE_ARGS_4 SAVE_ARGS_3
+# define SAVE_ARGS_5 SAVE_ARGS_4
+# define SAVE_ARGS_6 SAVE_ARGS_5
+
+# define LOAD_ARGS_0
+# define LOAD_ARGS_1 mov (20,sp),a0 ;
+# define LOAD_ARGS_2 LOAD_ARGS_1 mov (24,sp),d1 ;
+# define LOAD_ARGS_3 LOAD_ARGS_2
+# define LOAD_ARGS_4 LOAD_ARGS_3
+# define LOAD_ARGS_5 LOAD_ARGS_4
+# define LOAD_ARGS_6 LOAD_ARGS_5
+
+# ifdef IS_IN_libpthread
+# define CENABLE call __pthread_enable_asynccancel,[],0;
+# define CDISABLE call __pthread_disable_asynccancel,[],0;
+# elif defined IS_IN_librt
+# ifdef PIC
+# define CENABLE movm [a2],(sp); \
+ 1: mov pc,a2; \
+ add _GLOBAL_OFFSET_TABLE_-(1b-.),a2; \
+ call +__librt_enable_asynccancel@PLT,[],0; \
+ movm (sp),[a2];
+# define CENABLE movm [a2],(sp); \
+ 1: mov pc,a2; \
+ add _GLOBAL_OFFSET_TABLE_-(1b-.),a2; \
+ call +__librt_disable_asynccancel@PLT,[],0; \
+ movm (sp),[a2];
+# else
+# define CENABLE call +__librt_enable_asynccancel,[],0;
+# define CDISABLE call +__librt_disable_asynccancel,[],0;
+# endif
+# else
+# define CENABLE call +__libc_enable_asynccancel,[],0;
+# define CDISABLE call +__libc_disable_asynccancel,[],0;
+# endif
+
+#if !defined NOT_IN_libc
+# define __local_multiple_threads __libc_multiple_threads
+#elif defined IS_IN_libpthread
+# define __local_multiple_threads __pthread_multiple_threads
+#else
+# define __local_multiple_threads __librt_multiple_threads
+#endif
+
+# ifndef __ASSEMBLER__
+# if defined FLOATING_STACKS && USE___THREAD && defined PIC
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ p_header.data.multiple_threads) == 0, 1)
+# else
+extern int __local_multiple_threads
+# if !defined NOT_IN_libc || defined IS_IN_libpthread
+ attribute_hidden;
+# else
+ ;
+# endif
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# endif
+# else
+# if !defined PIC
+# define SINGLE_THREAD_P \
+ mov (+__local_multiple_threads),d0; \
+ cmp 0,d0
+# elif !defined NOT_IN_libc || defined IS_IN_libpthread
+# define SINGLE_THREAD_P \
+ movm [a2],(sp); \
+ 1: mov pc,a2; \
+ add _GLOBAL_OFFSET_TABLE_-(1b-.),a2; \
+ mov (+__local_multiple_threads@GOTOFF,a2),d0; \
+ movm (sp),[a2]; \
+ cmp 0,d0
+# else
+# define SINGLE_THREAD_P \
+ movm [a2],(sp); \
+ 1: mov pc,a2; \
+ add _GLOBAL_OFFSET_TABLE_-(1b-.),a2; \
+ mov (+__local_multiple_threads@GOT,a2),a2; \
+ mov (a2),d0; \
+ movm (sp),[a2]; \
+ cmp 0,d0
+# endif
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/am33/lockf64.c b/ports/sysdeps/unix/sysv/linux/am33/lockf64.c
new file mode 100644
index 000000000..a88f5a784
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/lockf64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/lockf64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/lxstat.c b/ports/sysdeps/unix/sysv/linux/am33/lxstat.c
new file mode 100644
index 000000000..0efa0aea4
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/lxstat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/profil-counter.h b/ports/sysdeps/unix/sysv/linux/am33/profil-counter.h
new file mode 100644
index 000000000..31422bb7e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/profil-counter.h
@@ -0,0 +1,27 @@
+/* Low-level statistical profiling support function. Linux/am33 version.
+ Copyright (C) 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <signal.h>
+#include <sigcontextinfo.h>
+
+static void
+profil_counter (int signo, SIGCONTEXT scp)
+{
+ profil_count ((void *) GET_PC (scp));
+}
diff --git a/ports/sysdeps/unix/sysv/linux/am33/putmsg.c b/ports/sysdeps/unix/sysv/linux/am33/putmsg.c
new file mode 100644
index 000000000..ebc1680ca
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/putmsg.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/putmsg.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/setegid.c b/ports/sysdeps/unix/sysv/linux/am33/setegid.c
new file mode 100644
index 000000000..2e3a54c89
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/setegid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setegid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/seteuid.c b/ports/sysdeps/unix/sysv/linux/am33/seteuid.c
new file mode 100644
index 000000000..18e41d08c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/seteuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/seteuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/setfsgid.c b/ports/sysdeps/unix/sysv/linux/am33/setfsgid.c
new file mode 100644
index 000000000..088671256
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/setfsgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setfsgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/setfsuid.c b/ports/sysdeps/unix/sysv/linux/am33/setfsuid.c
new file mode 100644
index 000000000..a9f22eb8a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/setfsuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setfsuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/setgid.c b/ports/sysdeps/unix/sysv/linux/am33/setgid.c
new file mode 100644
index 000000000..377021d9e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/setgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/setgroups.c b/ports/sysdeps/unix/sysv/linux/am33/setgroups.c
new file mode 100644
index 000000000..cb9a7708e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/setgroups.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setgroups.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/setregid.c b/ports/sysdeps/unix/sysv/linux/am33/setregid.c
new file mode 100644
index 000000000..99c57ad20
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/setregid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setregid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/setresgid.c b/ports/sysdeps/unix/sysv/linux/am33/setresgid.c
new file mode 100644
index 000000000..daca1a483
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/setresgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setresgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/setresuid.c b/ports/sysdeps/unix/sysv/linux/am33/setresuid.c
new file mode 100644
index 000000000..3aeabe9ad
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/setresuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setresuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/setreuid.c b/ports/sysdeps/unix/sysv/linux/am33/setreuid.c
new file mode 100644
index 000000000..8ad61226e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/setreuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setreuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/setrlimit.c b/ports/sysdeps/unix/sysv/linux/am33/setrlimit.c
new file mode 100644
index 000000000..bfaef74c3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/setrlimit.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setrlimit.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/setuid.c b/ports/sysdeps/unix/sysv/linux/am33/setuid.c
new file mode 100644
index 000000000..de394379b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/setuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/am33/socket.S b/ports/sysdeps/unix/sysv/linux/am33/socket.S
new file mode 100644
index 000000000..2c09239f3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/socket.S
@@ -0,0 +1,73 @@
+/* Copyright 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>.
+ Based on ../i386/socket.S.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <socketcall.h>
+
+#define P(a, b) P2(a, b)
+#define P2(a, b) a##b
+
+ .text
+/* The socket-oriented system calls are handled unusally in Linux.
+ They are all gated through the single `socketcall' system call number.
+ `socketcall' takes two arguments: the first is the subcode, specifying
+ which socket function is being called; and the second is a pointer to
+ the arguments to the specific function.
+
+ The .S files for the other calls just #define socket and #include this. */
+
+#ifndef __socket
+#ifndef NO_WEAK_ALIAS
+#define __socket P(__,socket)
+#else
+#define __socket socket
+#endif
+#endif
+
+.globl __socket
+ENTRY (__socket)
+
+ mov d0,(4,sp)
+ mov d1,(8,sp)
+
+ mov SYS_ify(socketcall),d0 /* System call number in d0. */
+
+ /* Use ## so `socket' is a separate token that might be #define'd. */
+ mov P(SOCKOP_,socket),a0 /* Subcode is first arg to syscall. */
+ mov sp,d1
+ add 4,d1 /* Address of args is 2nd arg. */
+
+ /* Do the system call trap. */
+ syscall 0
+
+ /* d0 is < 0 if there was an error. */
+ cmp -126,d0
+ bls L(pseudo_end)
+ jmp SYSCALL_ERROR_LABEL
+
+ /* Successful; return the syscall's value. */
+L(pseudo_end):
+ ret
+
+PSEUDO_END (__socket)
+
+#ifndef NO_WEAK_ALIAS
+weak_alias (__socket, socket)
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/am33/syscall.S b/ports/sysdeps/unix/sysv/linux/am33/syscall.S
new file mode 100644
index 000000000..180e5822c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/syscall.S
@@ -0,0 +1,43 @@
+/* Copyright (C) 1995, 1996, 1998, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>.
+ Based on ../i386/syscall.S.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+/* Please consult the file sysdeps/unix/sysv/linux/am33/sysdep.h for
+ more information about the value -126 used below.*/
+
+ .text
+ENTRY (syscall)
+ movm [d2,d3,a2,a3],(sp) /* Save register contents. */
+ mov d1,a0
+ mov (28,sp),d1
+ mov (32,sp),a3
+ mov (36,sp),a2
+ mov (40,sp),d3
+ mov (44,sp),d2
+ syscall 0 /* Do the system call. */
+ movm (sp),[d2,d3,a2,a3] /* Restore register contents. */
+ cmp -126,d0 /* Check for error. */
+ bls L(pseudo_end)
+ jmp SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
+L(pseudo_end):
+ ret /* Return to caller. */
+
+PSEUDO_END (syscall)
diff --git a/ports/sysdeps/unix/sysv/linux/am33/sysdep.S b/ports/sysdeps/unix/sysv/linux/am33/sysdep.S
new file mode 100644
index 000000000..b41bfce40
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/sysdep.S
@@ -0,0 +1,42 @@
+/* Copyright (C) 1995, 1996, 1997, 1998, 2001, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>.
+ Based on ../i386/sysdep.S.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+
+/* The following code is only used in the shared library when we
+ compile the reentrant version. Otherwise each system call defines
+ each own version. */
+
+#ifndef PIC
+
+#undef CALL_MCOUNT
+#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers %eax. */
+
+ .text
+ENTRY (__syscall_error)
+ mov d0,d1
+ clr d0
+ sub d1,d0
+
+#define __syscall_error __syscall_error_1
+#include <../../../am33/sysdep.S>
+
+#endif /* !PIC */
diff --git a/ports/sysdeps/unix/sysv/linux/am33/sysdep.h b/ports/sysdeps/unix/sysv/linux/am33/sysdep.h
new file mode 100644
index 000000000..b0ff4ec86
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/sysdep.h
@@ -0,0 +1,317 @@
+/* Copyright 2001, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>.
+ Based on ../i386/sysdep.h.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _LINUX_AM33_SYSDEP_H
+#define _LINUX_AM33_SYSDEP_H 1
+
+/* There is some commonality. */
+#include "../../../am33/sysdep.h"
+
+/* For Linux we can use the system call table in the header file
+ /usr/include/asm/unistd.h
+ of the kernel. But these symbols do not follow the SYS_* syntax
+ so we have to redefine the `SYS_ify' macro here. */
+#undef SYS_ify
+#define SYS_ify(syscall_name) __NR_##syscall_name
+
+/* ELF-like local names start with `.L'. */
+#undef L
+#define L(name) .L##name
+
+#ifdef __ASSEMBLER__
+
+/* Linux uses a negative return value to indicate syscall errors,
+ unlike most Unices, which use the condition codes' carry flag.
+
+ Since version 2.1 the return value of a system call might be
+ negative even if the call succeeded. E.g., the `lseek' system call
+ might return a large offset. Therefore we must not anymore test
+ for < 0, but test for a real error by making sure the value in %eax
+ is a real error number. Linus said he will make sure the no syscall
+ returns a value in -1 .. -4095 as a valid result so we can savely
+ test with -4095. */
+
+/* We don't want the label for the error handle to be global when we define
+ it here. */
+#ifdef PIC
+# define SYSCALL_ERROR_LABEL 0f
+#else
+# define SYSCALL_ERROR_LABEL syscall_error
+#endif
+
+#undef PSEUDO
+#define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args); \
+ cmp -126,d0; \
+ bls L(pseudo_end); \
+ jmp SYSCALL_ERROR_LABEL; \
+ L(pseudo_end): \
+ mov d0,a0;
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) \
+ SYSCALL_ERROR_HANDLER \
+ END (name)
+
+#undef PSEUDO_NOERROR
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args)
+
+#undef PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(name) \
+ END (name)
+
+#define ret_NOERRNO ret
+
+/* The function has to return the error code. */
+#undef PSEUDO_ERRVAL
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args); \
+ clr d1; \
+ sub d0,d1,d0
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name) \
+ END (name)
+
+#define ret_ERRVAL ret
+
+#ifndef PIC
+#define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
+#else
+/* Store (- d0) into errno through the GOT. */
+#ifdef _LIBC_REENTRANT
+#define SYSCALL_ERROR_HANDLER \
+0:movm [d2,a2],(sp); \
+ add -12,sp; \
+1:mov pc,a2; \
+ add _GLOBAL_OFFSET_TABLE_-(1b-.),a2; \
+ clr d2; \
+ sub d0,d2; \
+ call __errno_location@PLT,[],0; \
+ mov d2,(a0); \
+ add 12,sp; \
+ movm (sp),[d2,a2]; \
+ mov -1,d0; \
+ mov d0,a0; \
+ jmp L(pseudo_end);
+/* A quick note: it is assumed that the call to `__errno_location' does
+ not modify the stack! */
+#else
+#define SYSCALL_ERROR_HANDLER \
+0:mov pc,a0; \
+ add _GLOBAL_OFFSET_TABLE_-(0b-.),a0; \
+ clr d1; \
+ sub d0,d1; \
+ mov (errno@GOT,a0),a1; \
+ mov d1,(a0); \
+ mov -1,d0; \
+ mov d0,a0; \
+ jmp L(pseudo_end);
+#endif /* _LIBC_REENTRANT */
+#endif /* PIC */
+
+/* Linux takes system call arguments in registers:
+
+ syscall number d0 call-clobbered
+ arg 1 a0 call-clobbered
+ arg 2 d1 call-clobbered
+ arg 3 a3 call-saved
+ arg 4 a2 call-saved
+ arg 5 d3 call-saved
+ arg 6 d2 call-saved
+
+ The stack layout upon entering the function is:
+
+ (24,sp) Arg# 6
+ (20,sp) Arg# 5
+ (16,sp) Arg# 4
+ (12,sp) Arg# 3
+ d1 Arg# 2
+ d0 Arg# 1
+ (sp) Return address
+
+ (Of course a function with say 3 arguments does not have entries for
+ arguments 4, 5 and 6.) */
+
+#undef DO_CALL
+#define DO_CALL(syscall_name, args) \
+ PUSHARGS_##args \
+ DOARGS_##args \
+ mov SYS_ify (syscall_name),d0; \
+ syscall 0 \
+ POPARGS_##args
+
+#define PUSHARGS_0 /* No arguments to push. */
+#define _DOARGS_0(N) /* No arguments to frob. */
+#define DOARGS_0 /* No arguments to frob. */
+#define POPARGS_0 /* No arguments to pop. */
+
+#define PUSHARGS_1 /* No arguments to push. */
+#define _DOARGS_1(N) _DOARGS_0 (N-4) mov d0,a0;
+#define DOARGS_1 _DOARGS_1 (4)
+#define POPARGS_1 /* No arguments to pop. */
+
+#define PUSHARGS_2 /* No arguments to push. */
+#define _DOARGS_2(N) _DOARGS_1 (N-4) /* Argument already in d1. */
+#define DOARGS_2 _DOARGS_2 (8)
+#define POPARGS_2 /* No arguments to pop. */
+
+#define PUSHARGS_3 movm [a3],(sp);
+#define _DOARGS_3(N) _DOARGS_2 (N-4) mov (N,sp),a3;
+#define DOARGS_3 _DOARGS_3 (16)
+#define POPARGS_3 ; movm (sp),[a3]
+
+#define PUSHARGS_4 movm [a2,a3],(sp);
+#define _DOARGS_4(N) _DOARGS_3 (N-4) mov (N,sp),a2;
+#define DOARGS_4 _DOARGS_4 (24)
+#define POPARGS_4 ; movm (sp),[a2,a3]
+
+#define PUSHARGS_5 movm [d3,a2,a3],(sp);
+#define _DOARGS_5(N) _DOARGS_4 (N-4) mov (N,sp),d3;
+#define DOARGS_5 _DOARGS_5 (32)
+#define POPARGS_5 ; movm (sp),[d3,a2,a3]
+
+#define PUSHARGS_6 movm [d2,d3,a2,a3],(sp);
+#define _DOARGS_6(N) _DOARGS_5 (N-4) mov (N,sp),d2;
+#define DOARGS_6 _DOARGS_6 (40)
+#define POPARGS_6 ; movm (sp),[d2,d3,a2,a3]
+
+#else /* !__ASSEMBLER__ */
+
+/* Define a macro which expands inline into the wrapper code for a system
+ call. */
+#undef INLINE_SYSCALL
+#define INLINE_SYSCALL(name, nr, args...) \
+ ({ \
+ unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
+ if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
+ { \
+ __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
+ resultvar = 0xffffffff; \
+ } \
+ (int) resultvar; })
+
+#define INTERNAL_SYSCALL(name, err, nr, args...) \
+({ \
+ register long __sc0 asm ("d0") = __NR_##name; \
+ inline_syscall##nr(name, ## args); \
+ __sc0; \
+})
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+ ((unsigned int) (val) >= (unsigned long)-125)
+
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
+
+#define inline_syscall0(name,dummy...) \
+__asm__ __volatile__ ("syscall 0" \
+ : "+d" (__sc0) \
+ : : "memory")
+
+#define inline_syscall1(name,arg1) \
+register long __sc1 asm ("a0") = (long) (arg1); \
+inline_syscall0 (name); \
+__asm__ __volatile__ ("" : : "r" (__sc1))
+
+#define inline_syscall2(name,arg1,arg2) \
+register long __sc2 asm ("d1") = (long) (arg2); \
+inline_syscall1 (name,(arg1)); \
+__asm__ __volatile__ ("" : : "r" (__sc2))
+
+/* We can't tell whether a3 is going to be eliminated in the enclosing
+ function, so we have to assume it isn't. We first load the value
+ of any arguments into their registers, except for a3 itself, that
+ may be needed to load the value of the other arguments. Then, we
+ save a3's value in some other register, and load the argument value
+ into a3. We have to force both a3 and its copy to be live in
+ different registers at the same time, to avoid having the copy
+ spilled and the value reloaded into the same register, in which
+ case we'd be unable to get the value of a3 back, should the stack
+ slot reference be (offset,a3). */
+#define inline_syscall3(name,arg1,arg2,arg3) \
+long __sc3v = (long) (arg3); \
+register long __sc1 asm ("a0") = (long) (arg1); \
+register long __sc2 asm ("d1") = (long) (arg2); \
+register long __sc3 asm ("a3") = __sc3; \
+register long __sc3c; \
+__asm__ __volatile__ ("mov %1,%0" : "=&r" (__sc3c) : "r" (__sc3)); \
+__sc3 = __sc3v; \
+__asm__ __volatile__ ("" : : "r" (__sc3c), "r" (__sc3)); \
+inline_syscall0 (name); \
+__sc3 = __sc3c; \
+__asm__ __volatile__ ("" : : "r" (__sc3), "r" (__sc2), "r" (__sc1))
+
+#ifdef PIC
+/* Since a2 is the PIC register, it requires similar handling as a3
+ when we're generating PIC, as a2's value may be needed to load
+ arguments whose values live in global variables. The difference is
+ that we don't need to require its value to be live in a register;
+ it may well be in a stack slot, as long as we save it before
+ clobbering a3 and restore it after restoring a3. */
+#define inline_syscall4(name,arg1,arg2,arg3,arg4) \
+long __sc4v = (long) (arg4); \
+long __sc3v = (long) (arg3); \
+register long __sc1 asm ("a0") = (long) (arg1); \
+register long __sc2 asm ("d1") = (long) (arg2); \
+register long __sc3 asm ("a3") = __sc3; \
+register long __sc3c; \
+register long __sc4 asm ("a2") = __sc4; \
+long __sc4c = __sc4; \
+__sc4 = __sc4v; \
+__asm__ __volatile__ ("mov %1,%0" : "=&r" (__sc3c) : "r" (__sc3)); \
+__sc3 = __sc3v; \
+__asm__ __volatile__ ("" : : "r" (__sc3c), "r" (__sc3), "r" (__sc4)); \
+inline_syscall0 (name); \
+__sc3 = __sc3c; \
+__sc4 = __sc4c; \
+__asm__ __volatile__ ("" : : "r" (__sc4), "r" (__sc3), \
+ "r" (__sc2), "r" (__sc1))
+#else
+#define inline_syscall4(name,arg1,arg2,arg3,arg4) \
+register long __sc4 asm ("a2") = (long) (arg4); \
+inline_syscall3 (name,(arg1),(arg2),(arg3)); \
+__asm__ __volatile__ ("" : : "r" (__sc4))
+#endif
+
+#define inline_syscall5(name,arg1,arg2,arg3,arg4,arg5) \
+register long __sc5 asm ("d3") = (long) (arg5); \
+inline_syscall4 (name,(arg1),(arg2),(arg3),(arg4)); \
+__asm__ __volatile__ ("" : : "r" (__sc5))
+
+#define inline_syscall6(name,arg1,arg2,arg3,arg4,arg5,arg6) \
+register long __sc6 asm ("d2") = (long) (arg6); \
+inline_syscall5 (name,(arg1),(arg2),(arg3),(arg4),(arg5)); \
+__asm__ __volatile__ ("" : : "r" (__sc6))
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* linux/am33/sysdep.h */
diff --git a/ports/sysdeps/unix/sysv/linux/am33/xstat.c b/ports/sysdeps/unix/sysv/linux/am33/xstat.c
new file mode 100644
index 000000000..e9869f550
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/am33/xstat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/xstat.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/Makefile b/ports/sysdeps/unix/sysv/linux/arm/Makefile
new file mode 100644
index 000000000..d91b96859
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/Makefile
@@ -0,0 +1,22 @@
+ifeq ($(subdir),csu)
+sysdep_routines += aeabi_read_tp libc-aeabi_read_tp
+static-only-routines += aeabi_read_tp
+shared-only-routines += libc-aeabi_read_tp
+endif
+
+ifeq ($(subdir),elf)
+sysdep-rtld-routines += aeabi_read_tp
+endif
+
+ifeq ($(subdir),misc)
+sysdep_routines += ioperm
+sysdep_headers += sys/elf.h sys/io.h
+endif
+
+ifeq ($(subdir),signal)
+sysdep_routines += sigrestorer
+endif
+
+ifeq ($(subdir),resource)
+sysdep_routines += oldgetrlimit64
+endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/Versions b/ports/sysdeps/unix/sysv/linux/arm/Versions
new file mode 100644
index 000000000..2ddb2af2b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/Versions
@@ -0,0 +1,37 @@
+libc {
+ GLIBC_2.0 {
+ # Exception handling support functions from libgcc
+ __register_frame; __register_frame_table; __deregister_frame;
+ __frame_state_for; __register_frame_info_table;
+ }
+ GLIBC_2.1 {
+ ioperm; iopl;
+ inb; inw; inl;
+ outb; outw; outl;
+ }
+ GLIBC_2.2 {
+ # functions used in other libraries
+ __xstat64; __fxstat64; __lxstat64;
+
+ # a*
+ alphasort64;
+
+ # g*
+ glob64;
+
+ # New rlimit interface
+ getrlimit; setrlimit; getrlimit64;
+
+ # r*
+ readdir64; readdir64_r;
+
+ # s*
+ scandir64;
+
+ # v*
+ versionsort64;
+ }
+ GLIBC_2.3.3 {
+ posix_fadvise64; posix_fallocate64;
+ }
+}
diff --git a/ports/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S b/ports/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S
new file mode 100644
index 000000000..7691a94b1
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S
@@ -0,0 +1,51 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The GNU Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ Note that people who make modified versions of this file are not
+ obligated to grant this special exception for their modified
+ versions; it is their choice whether to do so. The GNU Lesser
+ General Public License gives permission to release a modified
+ version without this exception; this exception also makes it
+ possible to release a modified version which carries forward this
+ exception.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#ifdef HAVE_TLS_SUPPORT
+
+/* GCC will emit calls to this routine under -mtp=soft. Linux has an
+ equivalent helper function (which clobbers fewer registers than
+ a normal function call) in a high page of memory; tail call to the
+ helper. */
+
+ .hidden __aeabi_read_tp
+ENTRY (__aeabi_read_tp)
+ mov r0, #0xffff0fff
+ sub pc, r0, #31
+END (__aeabi_read_tp)
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/alphasort64.c b/ports/sysdeps/unix/sysv/linux/arm/alphasort64.c
new file mode 100644
index 000000000..0b5ae47d2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/alphasort64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/alphasort64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/bits/armsigctx.h b/ports/sysdeps/unix/sysv/linux/arm/bits/armsigctx.h
new file mode 100644
index 000000000..4530cdbda
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/bits/armsigctx.h
@@ -0,0 +1,73 @@
+/* Definition of `struct sigcontext' for Linux/ARM
+ Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* The format of struct sigcontext changed between 2.0 and 2.1 kernels.
+ Fortunately 2.0 puts a magic number in the first word and this is not
+ a legal value for `trap_no', so we can tell them apart. */
+
+/* Early 2.2 and 2.3 kernels do not have the `fault_address' member in
+ the sigcontext structure. Unfortunately there is no reliable way
+ to test for its presence and this word will contain garbage for too-old
+ kernels. Versions 2.2.14 and 2.3.35 (plus later versions) are known to
+ include this element. */
+
+#ifndef __ARMSIGCTX_H
+#define __ARMSIGCTX_H 1
+
+#include <asm/ptrace.h>
+
+union k_sigcontext
+ {
+ struct
+ {
+ unsigned long int trap_no;
+ unsigned long int error_code;
+ unsigned long int oldmask;
+ unsigned long int arm_r0;
+ unsigned long int arm_r1;
+ unsigned long int arm_r2;
+ unsigned long int arm_r3;
+ unsigned long int arm_r4;
+ unsigned long int arm_r5;
+ unsigned long int arm_r6;
+ unsigned long int arm_r7;
+ unsigned long int arm_r8;
+ unsigned long int arm_r9;
+ unsigned long int arm_r10;
+ unsigned long int arm_fp;
+ unsigned long int arm_ip;
+ unsigned long int arm_sp;
+ unsigned long int arm_lr;
+ unsigned long int arm_pc;
+ unsigned long int arm_cpsr;
+ unsigned long fault_address;
+ } v21;
+ struct
+ {
+ unsigned long int magic;
+ struct pt_regs reg;
+ unsigned long int trap_no;
+ unsigned long int error_code;
+ unsigned long int oldmask;
+ } v20;
+};
+
+#define SIGCONTEXT_2_0_MAGIC 0x4B534154
+
+#endif /* bits/armsigctx.h */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/bits/fcntl.h b/ports/sysdeps/unix/sysv/linux/arm/bits/fcntl.h
new file mode 100644
index 000000000..287dbd56f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/bits/fcntl.h
@@ -0,0 +1,235 @@
+/* O_*, F_*, FD_* bit values for Linux.
+ Copyright (C) 1995-1998, 2000, 2004, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+#include <sys/types.h>
+#ifdef __USE_GNU
+# include <bits/uio.h>
+#endif
+
+
+/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
+ located on an ext2 file system */
+#define O_ACCMODE 0003
+#define O_RDONLY 00
+#define O_WRONLY 01
+#define O_RDWR 02
+#define O_CREAT 0100 /* not fcntl */
+#define O_EXCL 0200 /* not fcntl */
+#define O_NOCTTY 0400 /* not fcntl */
+#define O_TRUNC 01000 /* not fcntl */
+#define O_APPEND 02000
+#define O_NONBLOCK 04000
+#define O_NDELAY O_NONBLOCK
+#define O_SYNC 010000
+#define O_FSYNC O_SYNC
+#define O_ASYNC 020000
+
+#ifdef __USE_GNU
+# define O_DIRECTORY 040000 /* Must be a directory. */
+# define O_NOFOLLOW 0100000 /* Do not follow links. */
+# define O_DIRECT 0200000 /* Direct disk access. */
+# define O_NOATIME 01000000 /* Do not set atime. */
+#endif
+
+/* For now Linux has synchronisity options for data and read operations.
+ We define the symbols here but let them do the same as O_SYNC since
+ this is a superset. */
+#if defined __USE_POSIX199309 || defined __USE_UNIX98
+# define O_DSYNC O_SYNC /* Synchronize data. */
+# define O_RSYNC O_SYNC /* Synchronize read operations. */
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define O_LARGEFILE 0400000
+#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. */
+#ifndef __USE_FILE_OFFSET64
+# define F_GETLK 5 /* Get record locking info. */
+# define F_SETLK 6 /* Set record locking info (non-blocking). */
+# define F_SETLKW 7 /* Set record locking info (blocking). */
+#else
+# define F_GETLK F_GETLK64 /* Get record locking info. */
+# define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/
+# define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
+#endif
+#define F_GETLK64 12 /* Get record locking info. */
+#define F_SETLK64 13 /* Set record locking info (non-blocking). */
+#define F_SETLKW64 14 /* Set record locking info (blocking). */
+
+#if defined __USE_BSD || defined __USE_UNIX98
+# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */
+# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETSIG 10 /* Set number of signal to be sent. */
+# define F_GETSIG 11 /* Get number of signal to be sent. */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETLEASE 1024 /* Set a lease. */
+# define F_GETLEASE 1025 /* Enquire what lease is active. */
+# define F_NOTIFY 1026 /* Request notfications on a directory. */
+#endif
+
+/* For F_[GET|SET]FL. */
+#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
+
+/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
+#define F_RDLCK 0 /* Read lock. */
+#define F_WRLCK 1 /* Write lock. */
+#define F_UNLCK 2 /* Remove lock. */
+
+/* For old implementation of bsd flock(). */
+#define F_EXLCK 4 /* or 3 */
+#define F_SHLCK 8 /* or 4 */
+
+#ifdef __USE_BSD
+/* Operations for bsd flock(), also used by the kernel implementation. */
+# define LOCK_SH 1 /* shared lock */
+# define LOCK_EX 2 /* exclusive lock */
+# define LOCK_NB 4 /* or'd with one of the above to prevent
+ blocking */
+# define LOCK_UN 8 /* remove lock */
+#endif
+
+#ifdef __USE_GNU
+# define LOCK_MAND 32 /* This is a mandatory flock: */
+# define LOCK_READ 64 /* ... which allows concurrent read operations. */
+# define LOCK_WRITE 128 /* ... which allows concurrent write operations. */
+# define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */
+#endif
+
+#ifdef __USE_GNU
+/* Types of directory notifications that may be requested with F_NOTIFY. */
+# define DN_ACCESS 0x00000001 /* File accessed. */
+# define DN_MODIFY 0x00000002 /* File modified. */
+# define DN_CREATE 0x00000004 /* File created. */
+# define DN_DELETE 0x00000008 /* File removed. */
+# define DN_RENAME 0x00000010 /* File renamed. */
+# define DN_ATTRIB 0x00000020 /* File changed attibutes. */
+# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
+#endif
+
+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'). */
+#ifndef __USE_FILE_OFFSET64
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+#else
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+#endif
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+
+#ifdef __USE_LARGEFILE64
+struct flock64
+ {
+ 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'). */
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+#endif
+
+/* Define some more compatibility macros to be backward compatible with
+ BSD systems which did not managed to hide these kernel macros. */
+#ifdef __USE_BSD
+# define FAPPEND O_APPEND
+# define FFSYNC O_FSYNC
+# define FASYNC O_ASYNC
+# define FNONBLOCK O_NONBLOCK
+# define FNDELAY O_NDELAY
+#endif /* Use BSD. */
+
+/* Advise to `posix_fadvise'. */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
+# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
+# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
+# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
+# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
+#endif
+
+
+#ifdef __USE_GNU
+/* Flags for SYNC_FILE_RANGE. */
+# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
+ in the range before performing the
+ write. */
+# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those
+ dirty pages in the range which are
+ not presently under writeback. */
+# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
+ the range after performing the
+ write. */
+
+/* Flags for SPLICE and VMSPLICE. */
+# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
+# define SPLICE_F_NONBLOCK 2 /* Don't block on the pipe splicing
+ (but we may still block on the fd
+ we splice from/to). */
+# define SPLICE_F_MORE 4 /* Expect more data. */
+# define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */
+#endif
+
+__BEGIN_DECLS
+
+#ifdef __USE_GNU
+
+/* Provide kernel hint to read ahead. */
+extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
+ __THROW;
+
+
+/* Selective file content synch'ing. */
+extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
+ unsigned int __flags);
+
+
+/* Splice address range into a pipe. */
+extern int vmsplice (int __fdout, const struct iovec *__iov, size_t __count,
+ unsigned int __flags);
+
+/* Splice two files together. */
+extern int splice (int __fdin, int __fdout, size_t __len, unsigned int __flags)
+ __THROW;
+
+/* In-kernel implementation of tee for pipe buffers. */
+extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags)
+ __THROW;
+
+#endif
+
+__END_DECLS
diff --git a/ports/sysdeps/unix/sysv/linux/arm/bits/mman.h b/ports/sysdeps/unix/sysv/linux/arm/bits/mman.h
new file mode 100644
index 000000000..828ec944c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/bits/mman.h
@@ -0,0 +1,103 @@
+/* Definitions for POSIX memory map interface. Linux/ARM version.
+ Copyright (C) 1997, 2000, 2003, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_MMAN_H
+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
+#endif
+
+/* The following definitions basically come from the kernel headers.
+ But the kernel header is not namespace clean. */
+
+
+/* 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_READ 0x1 /* Page can be read. */
+#define PROT_WRITE 0x2 /* Page can be written. */
+#define PROT_EXEC 0x4 /* Page can be executed. */
+#define PROT_NONE 0x0 /* Page can not be accessed. */
+#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
+ growsdown vma (mprotect only). */
+#define PROT_GROWSUP 0x02000000 /* Extend change to start of
+ growsup vma (mprotect only). */
+
+/* Sharing types (must choose one and only one of these). */
+#define MAP_SHARED 0x01 /* Share changes. */
+#define MAP_PRIVATE 0x02 /* Changes are private. */
+#ifdef __USE_MISC
+# define MAP_TYPE 0x0f /* Mask for type of mapping. */
+#endif
+
+/* Other flags. */
+#define MAP_FIXED 0x10 /* Interpret addr exactly. */
+#ifdef __USE_MISC
+# define MAP_FILE 0
+# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
+# define MAP_ANON MAP_ANONYMOUS
+#endif
+
+/* These are Linux-specific. */
+#ifdef __USE_MISC
+# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
+# define MAP_DENYWRITE 0x00800 /* ETXTBSY */
+# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
+# define MAP_LOCKED 0x02000 /* Lock the mapping. */
+# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
+# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
+# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
+#endif
+
+/* Flags to `msync'. */
+#define MS_ASYNC 1 /* Sync memory asynchronously. */
+#define MS_SYNC 4 /* Synchronous memory sync. */
+#define MS_INVALIDATE 2 /* Invalidate the caches. */
+
+/* Flags for `mlockall'. */
+#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
+#define MCL_FUTURE 2 /* Lock all additions to address
+ space. */
+
+/* Flags for `mremap'. */
+#ifdef __USE_GNU
+# define MREMAP_MAYMOVE 1
+# define MREMAP_FIXED 2
+#endif
+
+/* Advice to `madvise'. */
+#ifdef __USE_BSD
+# 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_REMOVE 9 /* Remove these pages and resources. */
+# define MADV_DONTFORK 10 /* Do not inherit across fork. */
+# define MADV_DOFORK 11 /* Do inherit across fork. */
+#endif
+
+/* The POSIX people had to invent similar names for the same things. */
+#ifdef __USE_XOPEN2K
+# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
+# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
+# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
+# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/brk.c b/ports/sysdeps/unix/sysv/linux/arm/brk.c
new file mode 100644
index 000000000..842688a76
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/brk.c
@@ -0,0 +1,42 @@
+/* brk system call for Linux/ARM.
+ Copyright (C) 1995, 1996, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sysdep.h>
+
+/* This must be initialized data because commons can't have aliases. */
+void *__curbrk = 0;
+
+int
+__brk (void *addr)
+{
+ void *newbrk;
+
+ __curbrk = newbrk = (void *) INLINE_SYSCALL (brk, 1, addr);
+
+ if (newbrk < addr)
+ {
+ __set_errno (ENOMEM);
+ return -1;
+ }
+
+ return 0;
+}
+weak_alias (__brk, brk)
diff --git a/ports/sysdeps/unix/sysv/linux/arm/chown.c b/ports/sysdeps/unix/sysv/linux/arm/chown.c
new file mode 100644
index 000000000..196162256
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/chown.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/m68k/chown.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/clone.S b/ports/sysdeps/unix/sysv/linux/arm/clone.S
new file mode 100644
index 000000000..6c8f8e8e2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/clone.S
@@ -0,0 +1,107 @@
+/* Copyright (C) 1996, 1997, 1998, 1999, 2002, 2005
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Pat Beirne <patb@corelcomputer.com>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* clone() is even more special than fork() as it mucks with stacks
+ and invokes a function in the right context after its all over. */
+
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+
+#define CLONE_VM 0x00000100
+#define CLONE_THREAD 0x00010000
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+ pid_t *ptid, struct user_desc *tls, pid_t *ctid); */
+
+ .text
+ENTRY(__clone)
+ @ sanity check args
+ cmp r0, #0
+ cmpne r1, #0
+ moveq r0, #-EINVAL
+ beq PLTJMP(syscall_error)
+
+ @ insert the args onto the new stack
+ str r3, [r1, #-4]!
+ str r0, [r1, #-4]!
+
+ @ do the system call
+ @ get flags
+ mov r0, r2
+#ifdef RESET_PID
+ mov ip, r2
+#endif
+ @ new sp is already in r1
+#ifdef __ARM_EABI__
+ stmfd sp!, {r4, r7}
+#else
+ str r4, [sp, #-8]!
+#endif
+ ldr r2, [sp, #8]
+ ldr r3, [sp, #12]
+ ldr r4, [sp, #16]
+#ifdef __ARM_EABI__
+ ldr r7, =SYS_ify(clone)
+ swi 0x0
+#else
+ swi SYS_ify(clone)
+#endif
+ cmp r0, #0
+ beq 1f
+#ifdef __ARM_EABI__
+ ldmfd sp!, {r4, r7}
+#else
+ ldr r4, [sp], #8
+#endif
+ blt PLTJMP(C_SYMBOL_NAME(__syscall_error))
+ RETINSTR(, lr)
+
+1:
+#ifdef RESET_PID
+ tst ip, #CLONE_THREAD
+ bne 3f
+ mov r0, #0xffff0fff
+ mov lr, pc
+ sub pc, r0, #31
+ mov r1, r0
+ tst ip, #CLONE_VM
+ movne r0, #-1
+#ifdef __ARM_EABI__
+ ldr r7, =SYS_ify(getpid)
+ swieq 0x0
+#else
+ swieq SYS_ify(getpid)
+#endif
+ str r0, [r1, #PID_OFFSET]
+ str r0, [r1, #TID_OFFSET]
+3:
+#endif
+ @ pick the function arg and call address off the stack and execute
+ ldr r0, [sp, #4]
+ mov lr, pc
+ ldr pc, [sp], #8
+
+ @ and we are done, passing the return value through r0
+ b PLTJMP(_exit)
+
+PSEUDO_END (__clone)
+
+weak_alias (__clone, clone)
diff --git a/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.c b/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.c
new file mode 100644
index 000000000..9b87a2003
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.c
@@ -0,0 +1,64 @@
+/* Data for Linux/ARM version of processor capability information.
+ Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <philb@gnu.org>, 2001.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This information must be kept in sync with the _DL_HWCAP_COUNT and
+ _DL_PLATFORM_COUNT definitions in procinfo.h.
+
+ If anything should be added here check whether the size of each string
+ is still ok with the given array size.
+
+ All the #ifdefs in the definitions ar equite irritating but
+ necessary if we want to avoid duplicating the information. There
+ are three different modes:
+
+ - PROCINFO_DECL is defined. This means we are only interested in
+ declarations.
+
+ - PROCINFO_DECL is not defined:
+
+ + if SHARED is defined the file is included in an array
+ initializer. The .element = { ... } syntax is needed.
+
+ + if SHARED is not defined a normal array initialization is
+ needed.
+ */
+
+#ifndef PROCINFO_CLASS
+#define PROCINFO_CLASS
+#endif
+
+#if !defined PROCINFO_DECL && defined SHARED
+ ._dl_arm_cap_flags
+#else
+PROCINFO_CLASS const char _dl_arm_cap_flags[8][10]
+#endif
+#ifndef PROCINFO_DECL
+= {
+ "swp", "half", "thumb", "26bit", "fast-mult", "fpa", "vfp", "edsp",
+ }
+#endif
+#if !defined SHARED || defined PROCINFO_DECL
+;
+#else
+,
+#endif
+
+#undef PROCINFO_DECL
+#undef PROCINFO_CLASS
diff --git a/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h b/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h
new file mode 100644
index 000000000..35b333479
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h
@@ -0,0 +1,86 @@
+/* Linux/ARM version of processor capability information handling macros.
+ Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <philb@gnu.org>, 2001.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _DL_PROCINFO_H
+#define _DL_PROCINFO_H 1
+
+#include <ldsodefs.h>
+
+#define _DL_HWCAP_COUNT 8
+
+/* The kernel provides platform data but it is not interesting. */
+#define _DL_HWCAP_PLATFORM 0
+
+
+static inline int
+__attribute__ ((unused))
+_dl_procinfo (int word)
+{
+ int i;
+
+ _dl_printf ("AT_HWCAP: ");
+
+ for (i = 0; i < _DL_HWCAP_COUNT; ++i)
+ if (word & (1 << i))
+ _dl_printf (" %s", GLRO(dl_arm_cap_flags)[i]);
+
+ _dl_printf ("\n");
+
+ return 0;
+}
+
+static inline const char *
+__attribute__ ((unused))
+_dl_hwcap_string (int idx)
+{
+ return GLRO(dl_arm_cap_flags)[idx];
+};
+
+enum
+{
+ HWCAP_ARM_SWP = 1 << 0,
+ HWCAP_ARM_HALF = 1 << 1,
+ HWCAP_ARM_THUMB = 1 << 2,
+ HWCAP_ARM_26BIT = 1 << 3,
+ HWCAP_ARM_FAST_MULT = 1 << 4,
+ HWCAP_ARM_FPA = 1 << 5,
+ HWCAP_ARM_VFP = 1 << 6,
+ HWCAP_ARM_EDSP = 1 << 7,
+
+ HWCAP_IMPORTANT = (HWCAP_ARM_HALF | HWCAP_ARM_FAST_MULT)
+};
+
+static inline int
+__attribute__ ((unused))
+_dl_string_hwcap (const char *str)
+{
+ int i;
+
+ for (i = 0; i < _DL_HWCAP_COUNT; i++)
+ {
+ if (strcmp (str, GLRO(dl_arm_cap_flags)[i]) == 0)
+ return i;
+ }
+ return -1;
+};
+
+#define _dl_string_platform(str) (-1)
+
+#endif /* dl-procinfo.h */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/Makefile b/ports/sysdeps/unix/sysv/linux/arm/eabi/Makefile
new file mode 100644
index 000000000..9f2b0fe8f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/Makefile
@@ -0,0 +1,9 @@
+# Set this flag here so that arm/nptl/Makefile will see it.
+arm-using-eabi = yes
+
+ifeq ($(subdir),csu)
+# In order for unwinding to fail when it falls out of main, we need a
+# cantunwind marker. There's one in start.S. To make sure we reach it, add
+# unwind tables for __libc_start_main.
+CFLAGS-libc-start.c += -fexceptions
+endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/configure b/ports/sysdeps/unix/sysv/linux/arm/eabi/configure
new file mode 100644
index 000000000..ab8304889
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/configure
@@ -0,0 +1,5 @@
+# This file is generated from configure.in by Autoconf. DO NOT EDIT!
+ # Local configure fragment for sysdeps/unix/sysv/linux/arm/eabi.
+
+arch_minimum_kernel=2.6.14
+libc_cv_gcc_unwind_find_fde=no
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/configure.in b/ports/sysdeps/unix/sysv/linux/arm/eabi/configure.in
new file mode 100644
index 000000000..83aa8fccb
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/configure.in
@@ -0,0 +1,5 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/sysv/linux/arm/eabi.
+
+arch_minimum_kernel=2.6.14
+libc_cv_gcc_unwind_find_fde=no
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/ftruncate64.c b/ports/sysdeps/unix/sysv/linux/arm/eabi/ftruncate64.c
new file mode 100644
index 000000000..38a4fbcd6
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/ftruncate64.c
@@ -0,0 +1,77 @@
+/* Copyright (C) 1997,1998,1999,2000,2001,2003, 2005
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/types.h>
+#include <errno.h>
+#include <endian.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+#include "kernel-features.h"
+
+#ifdef __NR_ftruncate64
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+/* The variable is shared between all wrappers around *truncate64 calls. */
+extern int __have_no_truncate64;
+#endif
+
+
+/* Truncate the file FD refers to to LENGTH bytes. */
+int
+__ftruncate64 (int fd, off64_t length)
+{
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ if (! __have_no_truncate64)
+#endif
+ {
+ unsigned int low = length & 0xffffffff;
+ unsigned int high = length >> 32;
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ int saved_errno = errno;
+#endif
+ int result = INLINE_SYSCALL (ftruncate64, 4, fd, 0,
+ __LONG_LONG_PAIR (high, low));
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ if (result != -1 || errno != ENOSYS)
+#endif
+ return result;
+
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ __set_errno (saved_errno);
+ __have_no_truncate64 = 1;
+#endif
+ }
+
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ if ((off_t) length != length)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+ return __ftruncate (fd, (off_t) length);
+#endif
+}
+weak_alias (__ftruncate64, ftruncate64)
+
+#else
+/* Use the generic implementation. */
+# include <misc/ftruncate64.c>
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/linuxthreads/sysdep-cancel.h b/ports/sysdeps/unix/sysv/linux/arm/eabi/linuxthreads/sysdep-cancel.h
new file mode 100644
index 000000000..bc520426e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/linuxthreads/sysdep-cancel.h
@@ -0,0 +1,116 @@
+/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .section ".text"; \
+ PSEUDO_PROLOGUE; \
+ ENTRY (name); \
+ SINGLE_THREAD_P; \
+ DOARGS_##args; \
+ bne .Lpseudo_cancel; \
+ mov ip, r7; \
+ ldr r7, =SYS_ify (syscall_name); \
+ swi 0x0; \
+ mov r7, ip; \
+ UNDOARGS_##args; \
+ cmn r0, $4096; \
+ PSEUDO_RET; \
+ .Lpseudo_cancel: \
+ DOCARGS_##args; /* save syscall args etc. around CENABLE. */ \
+ CENABLE; \
+ mov ip, r0; /* put mask in safe place. */ \
+ UNDOCARGS_##args; /* restore syscall args. */ \
+ ldr r7, =SYS_ify (syscall_name); \
+ swi 0x0; /* do the call. */ \
+ mov r7, r0; /* save syscall return value. */ \
+ mov r0, ip; /* get mask back. */ \
+ CDISABLE; \
+ mov r0, r7; /* retrieve return value. */ \
+ RESTORE_LR_##args; \
+ UNDOARGS_##args; \
+ cmn r0, $4096;
+
+/* DOARGS pushes four bytes on the stack for five arguments, eight bytes for
+ six arguments, and nothing for fewer. In order to preserve doubleword
+ alignment, sometimes we must save an extra register. */
+
+# define DOCARGS_0 stmfd sp!, {r7, lr}
+# define UNDOCARGS_0
+# define RESTORE_LR_0 ldmfd sp!, {r7, lr}
+
+# define DOCARGS_1 stmfd sp!, {r0, r1, r7, lr}
+# define UNDOCARGS_1 ldr r0, [sp], #8
+# define RESTORE_LR_1 RESTORE_LR_0
+
+# define DOCARGS_2 stmfd sp!, {r0, r1, r7, lr}
+# define UNDOCARGS_2 ldmfd sp!, {r0, r1}
+# define RESTORE_LR_2 RESTORE_LR_0
+
+# define DOCARGS_3 stmfd sp!, {r0, r1, r2, r3, r7, lr}
+# define UNDOCARGS_3 ldmfd sp!, {r0, r1, r2, r3}
+# define RESTORE_LR_3 RESTORE_LR_0
+
+# define DOCARGS_4 stmfd sp!, {r0, r1, r2, r3, r7, lr}
+# define UNDOCARGS_4 ldmfd sp!, {r0, r1, r2, r3}
+# define RESTORE_LR_4 RESTORE_LR_0
+
+# define DOCARGS_5 stmfd sp!, {r0, r1, r2, r3, r4, r7, lr}
+# define UNDOCARGS_5 ldmfd sp!, {r0, r1, r2, r3}
+# define RESTORE_LR_5 ldmfd sp!, {r4, r7, lr}
+
+# define DOCARGS_6 stmfd sp!, {r0, r1, r2, r3, r7, lr}
+# define UNDOCARGS_6 ldmfd sp!, {r0, r1, r2, r3}
+# define RESTORE_LR_6 RESTORE_LR_0
+
+# ifdef IS_IN_libpthread
+# define CENABLE bl PLTJMP(__pthread_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__pthread_disable_asynccancel)
+# define __local_multiple_threads __pthread_multiple_threads
+# else
+# define CENABLE bl PLTJMP(__libc_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__libc_disable_asynccancel)
+# define __local_multiple_threads __libc_multiple_threads
+# endif
+
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# define SINGLE_THREAD_P \
+ ldr ip, 1b; \
+2: \
+ ldr ip, [pc, ip]; \
+ teq ip, #0;
+# define PSEUDO_PROLOGUE \
+ 1: .word __local_multiple_threads - 2f - 8;
+# endif
+
+#else
+
+/* For rtld, et cetera. */
+# define SINGLE_THREAD_P 1
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/mmap64.S b/ports/sysdeps/unix/sysv/linux/arm/eabi/mmap64.S
new file mode 100644
index 000000000..38fac06c3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/mmap64.S
@@ -0,0 +1,56 @@
+/* Copyright (C) 2000, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#define EINVAL 22
+
+#ifdef __ARMEB__
+# define LOW_OFFSET 8 + 4
+/* The initial + 4 is for the stack postdecrement. */
+# define HIGH_OFFSET 4 + 8 + 0
+#else
+# define LOW_OFFSET 8 + 0
+# define HIGH_OFFSET 4 + 8 + 4
+#endif
+
+ /* The mmap2 system call takes six arguments, all in registers. */
+ .text
+ENTRY (__mmap64)
+ ldr ip, [sp, $LOW_OFFSET]
+ str r5, [sp, #-4]!
+ ldr r5, [sp, $HIGH_OFFSET]
+ str r4, [sp, #-4]!
+ movs r4, ip, lsl $20 @ check that offset is page-aligned
+ mov ip, ip, lsr $12
+ moveqs r4, r5, lsr $12 @ check for overflow
+ bne .Linval
+ ldr r4, [sp, $8] @ load fd
+ orr r5, ip, r5, lsl $20 @ compose page offset
+ DO_CALL (mmap2, 0)
+ cmn r0, $4096
+ ldmfd sp!, {r4, r5}
+ RETINSTR(cc, lr)
+ b PLTJMP(syscall_error)
+.Linval:
+ mov r0, $-EINVAL
+ ldmfd sp!, {r4, r5}
+ b PLTJMP(syscall_error)
+PSEUDO_END (__mmap64)
+
+weak_alias (__mmap64, mmap64)
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/Makefile b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/Makefile
new file mode 100644
index 000000000..ef8076cf3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/Makefile
@@ -0,0 +1,17 @@
+ifeq ($(subdir),rt)
+librt-sysdep_routines += rt-aeabi_unwind_cpp_pr1
+librt-shared-only-routines += rt-aeabi_unwind_cpp_pr1
+endif
+
+ifeq ($(subdir),nptl)
+libpthread-sysdep_routines += nptl-aeabi_unwind_cpp_pr1
+libpthread-shared-only-routines += nptl-aeabi_unwind_cpp_pr1
+
+# This test relies on compiling part of the binary with EH information,
+# part without, and unwinding through. The .ARM.exidx tables have
+# start addresses for EH regions, but no end addresses. Every
+# region an exception needs to propogate through must have unwind
+# information, or a previous function's unwind table may be used
+# by mistake.
+tests := $(filter-out tst-cleanupx4,$(tests))
+endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/configure b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/configure
new file mode 100644
index 000000000..518269913
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/configure
@@ -0,0 +1,4 @@
+# This file is generated from configure.in by Autoconf. DO NOT EDIT!
+
+libc_cv_gcc_exceptions=yes
+exceptions=-fexceptions
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/configure.in b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/configure.in
new file mode 100644
index 000000000..22f6f4b8f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/configure.in
@@ -0,0 +1,8 @@
+dnl configure fragment for NPTL and ARM/Linux EABI.
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+
+dnl The normal configure check for gcc -fexecptions fails because it can't
+dnl find __aeabi_unwind_cpp_pr0. Work around this here; our GCC definitely
+dnl has -fexceptions.
+libc_cv_gcc_exceptions=yes
+exceptions=-fexceptions
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/nptl-aeabi_unwind_cpp_pr1.c b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/nptl-aeabi_unwind_cpp_pr1.c
new file mode 100644
index 000000000..7b8352243
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/nptl-aeabi_unwind_cpp_pr1.c
@@ -0,0 +1 @@
+#include <aeabi_unwind_cpp_pr1.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/rt-aeabi_unwind_cpp_pr1.c b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/rt-aeabi_unwind_cpp_pr1.c
new file mode 100644
index 000000000..7b8352243
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/rt-aeabi_unwind_cpp_pr1.c
@@ -0,0 +1 @@
+#include <aeabi_unwind_cpp_pr1.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/sysdep-cancel.h b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/sysdep-cancel.h
new file mode 100644
index 000000000..92fe90385
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/sysdep-cancel.h
@@ -0,0 +1,153 @@
+/* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <nptl/pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+/* NOTE: We do mark syscalls with unwind annotations, for the benefit of
+ cancellation; but they're really only accurate at the point of the
+ syscall. The ARM unwind directives are not rich enough without adding
+ a custom personality function. */
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .section ".text"; \
+ PSEUDO_PROLOGUE; \
+ .type __##syscall_name##_nocancel,%function; \
+ .globl __##syscall_name##_nocancel; \
+ __##syscall_name##_nocancel: \
+ DO_CALL (syscall_name, args); \
+ PSEUDO_RET; \
+ .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
+ ENTRY (name); \
+ SINGLE_THREAD_P; \
+ DOARGS_##args; \
+ bne .Lpseudo_cancel; \
+ DO_CALL (syscall_name, 0); \
+ UNDOARGS_##args; \
+ cmn r0, $4096; \
+ PSEUDO_RET; \
+ .Lpseudo_cancel: \
+ .fnstart; \
+ DOCARGS_##args; /* save syscall args etc. around CENABLE. */ \
+ CENABLE; \
+ mov ip, r0; /* put mask in safe place. */ \
+ UNDOCARGS_##args; /* restore syscall args. */ \
+ ldr r7, =SYS_ify (syscall_name); \
+ swi 0x0; /* do the call. */ \
+ .fnend; /* Past here we can't easily unwind. */ \
+ mov r7, r0; /* save syscall return value. */ \
+ mov r0, ip; /* get mask back. */ \
+ CDISABLE; \
+ mov r0, r7; /* retrieve return value. */ \
+ RESTORE_LR_##args; \
+ UNDOARGS_##args; \
+ cmn r0, $4096;
+
+/* DOARGS pushes four bytes on the stack for five arguments, eight bytes for
+ six arguments, and nothing for fewer. In order to preserve doubleword
+ alignment, sometimes we must save an extra register. */
+
+# define RESTART_UNWIND .fnend; .fnstart; .save {r7, lr}
+
+# define DOCARGS_0 stmfd sp!, {r7, lr}; .save {r7, lr}
+# define UNDOCARGS_0
+# define RESTORE_LR_0 ldmfd sp!, {r7, lr};
+
+# define DOCARGS_1 stmfd sp!, {r0, r1, r7, lr}; .save {r7, lr}; .pad #8
+# define UNDOCARGS_1 ldr r0, [sp], #8; RESTART_UNWIND
+# define RESTORE_LR_1 RESTORE_LR_0
+
+# define DOCARGS_2 stmfd sp!, {r0, r1, r7, lr}; .save {r7, lr}; .pad #8
+# define UNDOCARGS_2 ldmfd sp!, {r0, r1}; RESTART_UNWIND
+# define RESTORE_LR_2 RESTORE_LR_0
+
+# define DOCARGS_3 stmfd sp!, {r0, r1, r2, r3, r7, lr}; .save {r7, lr}; .pad #16
+# define UNDOCARGS_3 ldmfd sp!, {r0, r1, r2, r3}; RESTART_UNWIND
+# define RESTORE_LR_3 RESTORE_LR_0
+
+# define DOCARGS_4 stmfd sp!, {r0, r1, r2, r3, r7, lr}; .save {r7, lr}; .pad #16
+# define UNDOCARGS_4 ldmfd sp!, {r0, r1, r2, r3}; RESTART_UNWIND
+# define RESTORE_LR_4 RESTORE_LR_0
+
+# define DOCARGS_5 .save {r4}; stmfd sp!, {r0, r1, r2, r3, r4, r7, lr}; .save {r7, lr}; .pad #20
+# define UNDOCARGS_5 ldmfd sp!, {r0, r1, r2, r3}; .fnend; .fnstart; .save {r4}; .save {r7, lr}; .pad #4
+# define RESTORE_LR_5 ldmfd sp!, {r4, r7, lr}
+
+# define DOCARGS_6 .save {r4, r5}; stmfd sp!, {r0, r1, r2, r3, r7, lr}; .save {r7, lr}; .pad #20
+# define UNDOCARGS_6 ldmfd sp!, {r0, r1, r2, r3}; .fnend; .fnstart; .save {r4, r5}; .save {r7, lr}
+# define RESTORE_LR_6 RESTORE_LR_0
+
+# ifdef IS_IN_libpthread
+# define CENABLE bl PLTJMP(__pthread_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__pthread_disable_asynccancel)
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define CENABLE bl PLTJMP(__libc_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__libc_disable_asynccancel)
+# define __local_multiple_threads __libc_multiple_threads
+# elif defined IS_IN_librt
+# define CENABLE bl PLTJMP(__librt_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__librt_disable_asynccancel)
+# else
+# error Unsupported library
+# endif
+
+# if defined IS_IN_libpthread || !defined NOT_IN_libc
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# define SINGLE_THREAD_P \
+ ldr ip, 1b; \
+2: \
+ ldr ip, [pc, ip]; \
+ teq ip, #0;
+# define PSEUDO_PROLOGUE \
+ 1: .word __local_multiple_threads - 2f - 8;
+# endif
+# else
+/* There is no __local_multiple_threads for librt, so use the TCB. */
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+# else
+# define PSEUDO_PROLOGUE
+# define SINGLE_THREAD_P \
+ stmfd sp!, {r0, lr}; \
+ bl __aeabi_read_tp; \
+ ldr ip, [r0, #MULTIPLE_THREADS_OFFSET]; \
+ ldmfd sp!, {r0, lr}; \
+ teq ip, #0
+# define SINGLE_THREAD_P_PIC(x) SINGLE_THREAD_P
+# endif
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* For rtld, et cetera. */
+# define SINGLE_THREAD_P 1
+# define NO_CANCELLATION 1
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c
new file mode 100644
index 000000000..ca1cc8d68
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-forcedunwind.c
@@ -0,0 +1,113 @@
+/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <unwind.h>
+#include <pthreadP.h>
+
+static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
+static _Unwind_Reason_Code (*libgcc_s_personality)
+ (_Unwind_State, struct _Unwind_Exception *, struct _Unwind_Context *);
+static _Unwind_Reason_Code (*libgcc_s_forcedunwind)
+ (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
+static _Unwind_Word (*libgcc_s_getcfa) (struct _Unwind_Context *);
+
+void
+pthread_cancel_init (void)
+{
+ void *resume, *personality, *forcedunwind, *getcfa;
+ void *handle;
+
+ if (__builtin_expect (libgcc_s_getcfa != NULL, 1))
+ return;
+
+ handle = __libc_dlopen ("libgcc_s.so.1");
+
+ if (handle == NULL
+ || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL
+ || (personality = __libc_dlsym (handle, "__gcc_personality_v0")) == NULL
+ || (forcedunwind = __libc_dlsym (handle, "_Unwind_ForcedUnwind"))
+ == NULL
+ || (getcfa = __libc_dlsym (handle, "_Unwind_GetCFA")) == NULL
+#ifdef ARCH_CANCEL_INIT
+ || ARCH_CANCEL_INIT (handle)
+#endif
+ )
+ __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n");
+
+ libgcc_s_resume = resume;
+ libgcc_s_personality = personality;
+ libgcc_s_forcedunwind = forcedunwind;
+ libgcc_s_getcfa = getcfa;
+}
+
+/* It's vitally important that _Unwind_Resume not have a stack frame; the
+ ARM unwinder relies on register state at entrance. So we write this in
+ assembly. */
+
+asm (
+" .globl _Unwind_Resume\n"
+" .type _Unwind_Resume, %function\n"
+"_Unwind_Resume:\n"
+" stmfd sp!, {r4, r5, r6, lr}\n"
+" ldr r4, 1f\n"
+" ldr r5, 2f\n"
+"3: add r4, pc, r4\n"
+" ldr r3, [r4, r5]\n"
+" mov r6, r0\n"
+" cmp r3, #0\n"
+" beq 4f\n"
+"5: mov r0, r6\n"
+" ldmfd sp!, {r4, r5, r6, lr}\n"
+" bx r3\n"
+"4: bl pthread_cancel_init\n"
+" ldr r3, [r4, r5]\n"
+" b 5b\n"
+"1: .word _GLOBAL_OFFSET_TABLE_ - 3b - 8\n"
+"2: .word libgcc_s_resume(GOTOFF)\n"
+" .size _Unwind_Resume, .-_Unwind_Resume\n"
+);
+
+_Unwind_Reason_Code
+__gcc_personality_v0 (_Unwind_State state,
+ struct _Unwind_Exception *ue_header,
+ struct _Unwind_Context *context)
+{
+ if (__builtin_expect (libgcc_s_personality == NULL, 0))
+ pthread_cancel_init ();
+ return libgcc_s_personality (state, ue_header, context);
+}
+
+_Unwind_Reason_Code
+_Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop,
+ void *stop_argument)
+{
+ if (__builtin_expect (libgcc_s_forcedunwind == NULL, 0))
+ pthread_cancel_init ();
+ return libgcc_s_forcedunwind (exc, stop, stop_argument);
+}
+
+_Unwind_Word
+_Unwind_GetCFA (struct _Unwind_Context *context)
+{
+ if (__builtin_expect (libgcc_s_getcfa == NULL, 0))
+ pthread_cancel_init ();
+ return libgcc_s_getcfa (context);
+}
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c
new file mode 100644
index 000000000..a9c9d1821
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind-resume.c
@@ -0,0 +1,82 @@
+/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <unwind.h>
+
+static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
+static _Unwind_Reason_Code (*libgcc_s_personality)
+ (_Unwind_State, struct _Unwind_Exception *, struct _Unwind_Context *);
+
+static void init (void) __attribute_used__;
+
+static void
+init (void)
+{
+ void *resume, *personality;
+ void *handle;
+
+ handle = __libc_dlopen ("libgcc_s.so.1");
+
+ if (handle == NULL
+ || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL
+ || (personality = __libc_dlsym (handle, "__gcc_personality_v0")) == NULL)
+ __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n");
+
+ libgcc_s_resume = resume;
+ libgcc_s_personality = personality;
+}
+
+/* It's vitally important that _Unwind_Resume not have a stack frame; the
+ ARM unwinder relies on register state at entrance. So we write this in
+ assembly. */
+
+asm (
+" .globl _Unwind_Resume\n"
+" .type _Unwind_Resume, %function\n"
+"_Unwind_Resume:\n"
+" stmfd sp!, {r4, r5, r6, lr}\n"
+" ldr r4, 1f\n"
+" ldr r5, 2f\n"
+"3: add r4, pc, r4\n"
+" ldr r3, [r4, r5]\n"
+" mov r6, r0\n"
+" cmp r3, #0\n"
+" beq 4f\n"
+"5: mov r0, r6\n"
+" ldmfd sp!, {r4, r5, r6, lr}\n"
+" bx r3\n"
+"4: bl init\n"
+" ldr r3, [r4, r5]\n"
+" b 5b\n"
+"1: .word _GLOBAL_OFFSET_TABLE_ - 3b - 8\n"
+"2: .word libgcc_s_resume(GOTOFF)\n"
+" .size _Unwind_Resume, .-_Unwind_Resume\n"
+);
+
+_Unwind_Reason_Code
+__gcc_personality_v0 (_Unwind_State state,
+ struct _Unwind_Exception *ue_header,
+ struct _Unwind_Context *context)
+{
+ if (__builtin_expect (libgcc_s_personality == NULL, 0))
+ init ();
+ return libgcc_s_personality (state, ue_header, context);
+}
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind.h b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind.h
new file mode 100644
index 000000000..d625fb288
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/nptl/unwind.h
@@ -0,0 +1,274 @@
+/* Header file for the ARM EABI unwinder
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+ Contributed by Paul Brook
+
+ This file 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.
+
+ In addition to the permissions in the GNU General Public License, the
+ Free Software Foundation gives you unlimited permission to link the
+ compiled version of this file into combinations with other programs,
+ and to distribute those combinations without any restriction coming
+ from the use of this file. (The General Public License restrictions
+ do apply in other respects; for example, they cover modification of
+ the file, and distribution when not linked into a combine
+ executable.)
+
+ This file is distributed in the hope that 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, 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
+
+/* Language-independent unwinder header public defines. This contains both
+ ABI defined objects, and GNU support routines. */
+
+#ifndef UNWIND_ARM_H
+#define UNWIND_ARM_H
+
+#define __ARM_EABI_UNWINDER__ 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
+ typedef signed _Unwind_Sword __attribute__((__mode__(__word__)));
+ typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
+ typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
+ typedef _Unwind_Word _uw;
+ typedef unsigned _uw64 __attribute__((mode(__DI__)));
+ typedef unsigned _uw16 __attribute__((mode(__HI__)));
+ typedef unsigned _uw8 __attribute__((mode(__QI__)));
+
+ typedef enum
+ {
+ _URC_OK = 0, /* operation completed successfully */
+ _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
+ _URC_END_OF_STACK = 5,
+ _URC_HANDLER_FOUND = 6,
+ _URC_INSTALL_CONTEXT = 7,
+ _URC_CONTINUE_UNWIND = 8,
+ _URC_FAILURE = 9 /* unspecified failure of some kind */
+ }
+ _Unwind_Reason_Code;
+
+ typedef enum
+ {
+ _US_VIRTUAL_UNWIND_FRAME = 0,
+ _US_UNWIND_FRAME_STARTING = 1,
+ _US_UNWIND_FRAME_RESUME = 2,
+ _US_ACTION_MASK = 3,
+ _US_FORCE_UNWIND = 8,
+ _US_END_OF_STACK = 16
+ }
+ _Unwind_State;
+
+ /* Provided only for for compatibility with existing code. */
+ typedef int _Unwind_Action;
+#define _UA_SEARCH_PHASE 1
+#define _UA_CLEANUP_PHASE 2
+#define _UA_HANDLER_FRAME 4
+#define _UA_FORCE_UNWIND 8
+#define _UA_END_OF_STACK 16
+#define _URC_NO_REASON _URC_OK
+
+ typedef struct _Unwind_Control_Block _Unwind_Control_Block;
+ typedef struct _Unwind_Context _Unwind_Context;
+ typedef _uw _Unwind_EHT_Header;
+
+
+ /* UCB: */
+
+ struct _Unwind_Control_Block
+ {
+#ifdef _LIBC
+ /* For the benefit of code which assumes this is a scalar. All
+ glibc ever does is clear it. */
+ _uw64 exception_class;
+#else
+ char exception_class[8];
+#endif
+ void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block *);
+ /* Unwinder cache, private fields for the unwinder's use */
+ struct
+ {
+ _uw reserved1; /* Forced unwind stop fn, 0 if not forced */
+ _uw reserved2; /* Personality routine address */
+ _uw reserved3; /* Saved callsite address */
+ _uw reserved4; /* Forced unwind stop arg */
+ _uw reserved5;
+ }
+ unwinder_cache;
+ /* Propagation barrier cache (valid after phase 1): */
+ struct
+ {
+ _uw sp;
+ _uw bitpattern[5];
+ }
+ barrier_cache;
+ /* Cleanup cache (preserved over cleanup): */
+ struct
+ {
+ _uw bitpattern[4];
+ }
+ cleanup_cache;
+ /* Pr cache (for pr's benefit): */
+ struct
+ {
+ _uw fnstart; /* function start address */
+ _Unwind_EHT_Header *ehtp; /* pointer to EHT entry header word */
+ _uw additional; /* additional data */
+ _uw reserved1;
+ }
+ pr_cache;
+ long long int :0; /* Force alignment to 8-byte boundary */
+ };
+
+ /* Virtual Register Set*/
+
+ typedef enum
+ {
+ _UVRSC_CORE = 0, /* integer register */
+ _UVRSC_VFP = 1, /* vfp */
+ _UVRSC_FPA = 2, /* fpa */
+ _UVRSC_WMMXD = 3, /* Intel WMMX data register */
+ _UVRSC_WMMXC = 4 /* Intel WMMX control register */
+ }
+ _Unwind_VRS_RegClass;
+
+ typedef enum
+ {
+ _UVRSD_UINT32 = 0,
+ _UVRSD_VFPX = 1,
+ _UVRSD_FPAX = 2,
+ _UVRSD_UINT64 = 3,
+ _UVRSD_FLOAT = 4,
+ _UVRSD_DOUBLE = 5
+ }
+ _Unwind_VRS_DataRepresentation;
+
+ typedef enum
+ {
+ _UVRSR_OK = 0,
+ _UVRSR_NOT_IMPLEMENTED = 1,
+ _UVRSR_FAILED = 2
+ }
+ _Unwind_VRS_Result;
+
+ /* Frame unwinding state. */
+ typedef struct
+ {
+ /* The current word (bytes packed msb first). */
+ _uw data;
+ /* Pointer to the next word of data. */
+ _uw *next;
+ /* The number of bytes left in this word. */
+ _uw8 bytes_left;
+ /* The number of words pointed to by ptr. */
+ _uw8 words_left;
+ }
+ __gnu_unwind_state;
+
+ typedef _Unwind_Reason_Code (*personality_routine) (_Unwind_State,
+ _Unwind_Control_Block *, _Unwind_Context *);
+
+ _Unwind_VRS_Result _Unwind_VRS_Set(_Unwind_Context *, _Unwind_VRS_RegClass,
+ _uw, _Unwind_VRS_DataRepresentation,
+ void *);
+
+ _Unwind_VRS_Result _Unwind_VRS_Get(_Unwind_Context *, _Unwind_VRS_RegClass,
+ _uw, _Unwind_VRS_DataRepresentation,
+ void *);
+
+ _Unwind_VRS_Result _Unwind_VRS_Pop(_Unwind_Context *, _Unwind_VRS_RegClass,
+ _uw, _Unwind_VRS_DataRepresentation);
+
+
+ /* Support functions for the PR. */
+#define _Unwind_Exception _Unwind_Control_Block
+ typedef char _Unwind_Exception_Class[8];
+
+ void * _Unwind_GetLanguageSpecificData (_Unwind_Context *);
+ _Unwind_Ptr _Unwind_GetRegionStart (_Unwind_Context *);
+
+ /* These two should never be used. */
+ _Unwind_Ptr _Unwind_GetDataRelBase (_Unwind_Context *);
+ _Unwind_Ptr _Unwind_GetTextRelBase (_Unwind_Context *);
+
+ /* Interface functions: */
+ _Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Control_Block *ucbp);
+ void __attribute__((noreturn)) _Unwind_Resume(_Unwind_Control_Block *ucbp);
+ _Unwind_Reason_Code _Unwind_Resume_or_Rethrow (_Unwind_Control_Block *ucbp);
+
+ typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
+ (int, _Unwind_Action, _Unwind_Exception_Class,
+ _Unwind_Control_Block *, struct _Unwind_Context *, void *);
+ _Unwind_Reason_Code _Unwind_ForcedUnwind (_Unwind_Control_Block *,
+ _Unwind_Stop_Fn, void *);
+ _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
+ void _Unwind_Complete(_Unwind_Control_Block *ucbp);
+ void _Unwind_DeleteException (_Unwind_Exception *);
+
+ _Unwind_Reason_Code __gnu_unwind_frame (_Unwind_Control_Block *,
+ _Unwind_Context *);
+ _Unwind_Reason_Code __gnu_unwind_execute (_Unwind_Context *,
+ __gnu_unwind_state *);
+
+ /* Decode an R_ARM_TARGET2 relocation. */
+ static inline _Unwind_Word
+ _Unwind_decode_target2 (_Unwind_Word ptr)
+ {
+ _Unwind_Word tmp;
+
+ tmp = *(_Unwind_Word *) ptr;
+ /* Zero values are always NULL. */
+ if (!tmp)
+ return 0;
+
+#if defined(linux) || defined(__NetBSD__)
+ /* Pc-relative indirect. */
+ tmp += ptr;
+ tmp = *(_Unwind_Word *) tmp;
+#elif defined(__symbian__)
+ /* Absolute pointer. Nothing more to do. */
+#else
+ /* Pc-relative pointer. */
+ tmp += ptr;
+#endif
+ return tmp;
+ }
+
+ static inline _Unwind_Word
+ _Unwind_GetGR (_Unwind_Context *context, int regno)
+ {
+ _uw val;
+ _Unwind_VRS_Get (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
+ return val;
+ }
+
+ /* Return the address of the instruction, not the actual IP value. */
+#define _Unwind_GetIP(context) \
+ (_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
+
+ static inline void
+ _Unwind_SetGR (_Unwind_Context *context, int regno, _Unwind_Word val)
+ {
+ _Unwind_VRS_Set (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
+ }
+
+ /* The dwarf unwinder doesn't understand arm/thumb state. We assume the
+ landing pad uses the same instruction set as the call site. */
+#define _Unwind_SetIP(context, val) \
+ _Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1))
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* defined UNWIND_ARM_H */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/oldgetrlimit.c b/ports/sysdeps/unix/sysv/linux/arm/eabi/oldgetrlimit.c
new file mode 100644
index 000000000..6e25b021a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/oldgetrlimit.c
@@ -0,0 +1 @@
+/* Empty. */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/oldsetrlimit.c b/ports/sysdeps/unix/sysv/linux/arm/eabi/oldsetrlimit.c
new file mode 100644
index 000000000..6e25b021a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/oldsetrlimit.c
@@ -0,0 +1 @@
+/* Empty. */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/pread.c b/ports/sysdeps/unix/sysv/linux/arm/eabi/pread.c
new file mode 100644
index 000000000..b6d2aeaa5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/pread.c
@@ -0,0 +1,61 @@
+/* Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2005
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <endian.h>
+#include <unistd.h>
+
+#include <sysdep-cancel.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+ssize_t
+__libc_pread (fd, buf, count, offset)
+ int fd;
+ void *buf;
+ size_t count;
+ off_t offset;
+{
+ ssize_t result;
+
+ if (SINGLE_THREAD_P)
+ {
+ /* In the ARM EABI, 64-bit values are aligned to even/odd register
+ pairs for syscalls. */
+ result = INLINE_SYSCALL (pread64, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR (offset >> 31, offset));
+
+ return result;
+ }
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ /* In the ARM EABI, 64-bit values are aligned to even/odd register
+ pairs for syscalls. */
+ result = INLINE_SYSCALL (pread64, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR (offset >> 31, offset));
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+
+strong_alias (__libc_pread, __pread)
+weak_alias (__libc_pread, pread)
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/pread64.c b/ports/sysdeps/unix/sysv/linux/arm/eabi/pread64.c
new file mode 100644
index 000000000..3b4608e5c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/pread64.c
@@ -0,0 +1,63 @@
+/* Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2005
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <endian.h>
+#include <unistd.h>
+
+#include <sysdep-cancel.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+ssize_t
+__libc_pread64 (fd, buf, count, offset)
+ int fd;
+ void *buf;
+ size_t count;
+ off64_t offset;
+{
+ ssize_t result;
+
+ if (SINGLE_THREAD_P)
+ {
+ /* In the ARM EABI, 64-bit values are aligned to even/odd register
+ pairs for syscalls. */
+ result = INLINE_SYSCALL (pread64, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR ((off_t) (offset >> 32),
+ (off_t) (offset & 0xffffffff)));
+
+ return result;
+ }
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ /* In the ARM EABI, 64-bit values are aligned to even/odd register
+ pairs for syscalls. */
+ result = INLINE_SYSCALL (pread64, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR ((off_t) (offset >> 32),
+ (off_t) (offset & 0xffffffff)));
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+
+weak_alias (__libc_pread64, __pread64)
+weak_alias (__libc_pread64, pread64)
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/pwrite.c b/ports/sysdeps/unix/sysv/linux/arm/eabi/pwrite.c
new file mode 100644
index 000000000..0200b9cc5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/pwrite.c
@@ -0,0 +1,61 @@
+/* Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2005
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <endian.h>
+#include <unistd.h>
+
+#include <sysdep-cancel.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+ssize_t
+__libc_pwrite (fd, buf, count, offset)
+ int fd;
+ const void *buf;
+ size_t count;
+ off_t offset;
+{
+ ssize_t result;
+
+ if (SINGLE_THREAD_P)
+ {
+ /* In the ARM EABI, 64-bit values are aligned to even/odd register
+ pairs for syscalls. */
+ result = INLINE_SYSCALL (pwrite64, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR (offset >> 31, offset));
+
+ return result;
+ }
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ /* In the ARM EABI, 64-bit values are aligned to even/odd register
+ pairs for syscalls. */
+ result = INLINE_SYSCALL (pwrite64, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR (offset >> 31, offset));
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+
+strong_alias (__libc_pwrite, __pwrite)
+weak_alias (__libc_pwrite, pwrite)
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/pwrite64.c b/ports/sysdeps/unix/sysv/linux/arm/eabi/pwrite64.c
new file mode 100644
index 000000000..cf33165cd
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/pwrite64.c
@@ -0,0 +1,64 @@
+/* Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2005
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <endian.h>
+#include <unistd.h>
+
+#include <sysdep-cancel.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+ssize_t
+__libc_pwrite64 (fd, buf, count, offset)
+ int fd;
+ const void *buf;
+ size_t count;
+ off64_t offset;
+{
+ ssize_t result;
+
+ if (SINGLE_THREAD_P)
+ {
+ /* In the ARM EABI, 64-bit values are aligned to even/odd register
+ pairs for syscalls. */
+ result = INLINE_SYSCALL (pwrite64, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR ((off_t) (offset >> 32),
+ (off_t) (offset & 0xffffffff)));
+
+ return result;
+ }
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ /* In the ARM EABI, 64-bit values are aligned to even/odd register
+ pairs for syscalls. */
+ result = INLINE_SYSCALL (pwrite64, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR ((off_t) (offset >> 32),
+ (off_t) (offset & 0xffffffff)));
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+
+weak_alias (__libc_pwrite64, __pwrite64)
+libc_hidden_weak (__pwrite64)
+weak_alias (__libc_pwrite64, pwrite64)
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/readahead.c b/ports/sysdeps/unix/sysv/linux/arm/eabi/readahead.c
new file mode 100644
index 000000000..946745cb4
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/readahead.c
@@ -0,0 +1,51 @@
+/* Provide kernel hint to read ahead.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <endian.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+
+#ifdef __NR_readahead
+
+ssize_t
+__readahead (int fd, off64_t offset, size_t count)
+{
+ return INLINE_SYSCALL (readahead, 5, fd, 0,
+ __LONG_LONG_PAIR ((off_t) (offset >> 32),
+ (off_t) (offset & 0xffffffff)),
+ count);
+}
+#else
+ssize_t
+__readahead (int fd, off64_t offset, size_t count)
+{
+ __set_errno (ENOSYS);
+ return -1;
+}
+stub_warning (readahead)
+
+# include <stub-tag.h>
+#endif
+
+weak_alias (__readahead, readahead)
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S b/ports/sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S
new file mode 100644
index 000000000..543d48cdb
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S
@@ -0,0 +1,54 @@
+/* Copyright (C) 1999, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+/* If no SA_RESTORER function was specified by the application we use
+ one of these. This avoids the need for the kernel to synthesise a return
+ instruction on the stack, which would involve expensive cache flushes.
+
+ Nowadays (2.6 series, and somewhat earlier) the kernel uses a high page
+ for signal trampolines, so the cache flushes are not an issue. But since
+ we do not have a vDSO, continue to use these so that we can provide
+ unwind information.
+
+ Start the unwind tables at least one instruction before the signal
+ trampoline, because the unwinder will assume we are returning after
+ a call site. */
+
+ .fnstart
+ .save {r0-r15}
+ .pad #12
+ nop
+ENTRY(__default_sa_restorer)
+ mov r7, $SYS_ify(sigreturn)
+ swi 0x0
+ .fnend
+
+#ifdef __NR_rt_sigreturn
+
+ .fnstart
+ .save {r0-r15}
+ .pad #168
+ nop
+ENTRY(__default_rt_sa_restorer)
+ mov r7, $SYS_ify(rt_sigreturn)
+ swi 0x0
+ .fnend
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/syscall.S b/ports/sysdeps/unix/sysv/linux/arm/eabi/syscall.S
new file mode 100644
index 000000000..59ca051a8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/syscall.S
@@ -0,0 +1,38 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+/* In the EABI syscall interface, we don't need a special syscall to
+ implement syscall(). It won't work reliably with 64-bit arguments
+ (but that is true on many modern platforms). */
+
+ENTRY (syscall)
+ mov ip, sp
+ stmfd sp!, {r4, r5, r6, r7}
+ mov r7, r0
+ mov r0, r1
+ mov r1, r2
+ mov r2, r3
+ ldmfd ip, {r3, r4, r5, r6}
+ swi 0x0
+ ldmfd sp!, {r4, r5, r6, r7}
+ cmn r0, #4096
+ RETINSTR(cc, lr)
+ b PLTJMP(syscall_error)
+PSEUDO_END (syscall)
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/syscalls.list b/ports/sysdeps/unix/sysv/linux/arm/eabi/syscalls.list
new file mode 100644
index 000000000..31e1cd610
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/syscalls.list
@@ -0,0 +1,34 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+# semaphore and shm system calls
+msgctl - msgctl i:iip __msgctl msgctl
+msgget - msgget i:ii __msgget msgget
+msgrcv - msgrcv Ci:ibnii __msgrcv msgrcv
+msgsnd - msgsnd Ci:ibni __msgsnd msgsnd
+shmat - shmat i:ipi __shmat shmat
+shmctl - shmctl i:iip __shmctl shmctl
+shmdt - shmdt i:s __shmdt shmdt
+shmget - shmget i:iii __shmget shmget
+semop - semop i:ipi __semop semop
+semtimedop - semtimedop i:ipip semtimedop
+semget - semget i:iii __semget semget
+semctl - semctl i:iiii __semctl semctl
+
+# proper socket implementations:
+accept - accept Ci:iBN __libc_accept __accept accept
+bind - bind i:ipi __bind bind
+connect - connect Ci:ipi __libc_connect __connect_internal __connect connect
+getpeername - getpeername i:ipp __getpeername getpeername
+getsockname - getsockname i:ipp __getsockname getsockname
+getsockopt - getsockopt i:iiiBN __getsockopt getsockopt
+listen - listen i:ii __listen listen
+recv - recv Ci:ibni __libc_recv __recv recv
+recvfrom - recvfrom Ci:ibniBN __libc_recvfrom __recvfrom recvfrom
+recvmsg - recvmsg Ci:ipi __libc_recvmsg __recvmsg recvmsg
+send - send Ci:ibni __libc_send __send send
+sendmsg - sendmsg Ci:ipi __libc_sendmsg __sendmsg sendmsg
+sendto - sendto Ci:ibnibn __libc_sendto __sendto sendto
+setsockopt - setsockopt i:iiibn __setsockopt setsockopt
+shutdown - shutdown i:ii __shutdown shutdown
+socket - socket i:iii __socket socket
+socketpair - socketpair i:iiif __socketpair socketpair
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/sysdep.h b/ports/sysdeps/unix/sysv/linux/arm/eabi/sysdep.h
new file mode 100644
index 000000000..bf9c8d76b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/sysdep.h
@@ -0,0 +1,83 @@
+/* Copyright (C) 2005, 2006
+ Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ Contributed by Daniel Jacobowitz <dan@codesourcery.com>, Oct 2005.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _LINUX_ARM_EABI_SYSDEP_H
+#define _LINUX_ARM_EABI_SYSDEP_H 1
+
+#include <arm/sysdep.h>
+
+#if __NR_SYSCALL_BASE != 0
+# error Kernel headers are too old
+#endif
+
+/* Don't use stime, even if the kernel headers define it. We have
+ settimeofday, and some EABI kernels have removed stime. Similarly
+ use setitimer to implement alarm. */
+#undef __NR_stime
+#undef __NR_alarm
+
+/* The ARM EABI user interface passes the syscall number in r7, instead
+ of in the swi. This is more efficient, because the kernel does not need
+ to fetch the swi from memory to find out the number; which can be painful
+ with separate I-cache and D-cache. Make sure to use 0 for the SWI
+ argument; otherwise the (optional) compatibility code for APCS binaries
+ may be invoked. */
+
+#undef INTERNAL_SYSCALL_RAW
+#define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \
+ ({ \
+ register int _a1 asm ("r0"), _nr asm ("r7"); \
+ LOAD_ARGS_##nr (args) \
+ _nr = name; \
+ asm volatile ("swi 0x0 @ syscall " #name \
+ : "=r" (_a1) \
+ : "r" (_nr) ASM_ARGS_##nr \
+ : "memory"); \
+ _a1; })
+
+/* For EABI, non-constant syscalls are actually pretty easy... */
+#undef INTERNAL_SYSCALL_NCS
+#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
+ INTERNAL_SYSCALL_RAW (number, err, nr, args)
+
+/* We must save and restore r7 (call-saved) for the syscall number.
+ We never make function calls from inside here (only potentially
+ signal handlers), so we do not bother with doubleword alignment.
+
+ Just like the APCS syscall convention, the EABI syscall convention uses
+ r0 through r6 for up to seven syscall arguments. None are ever passed to
+ the kernel on the stack, although incoming arguments are on the stack for
+ syscalls with five or more arguments.
+
+ The assembler will convert the literal pool load to a move for most
+ syscalls. */
+
+#undef DO_CALL
+#define DO_CALL(syscall_name, args) \
+ DOARGS_##args \
+ mov ip, r7; \
+ ldr r7, =SYS_ify (syscall_name); \
+ swi 0x0; \
+ mov r7, ip; \
+ UNDOARGS_##args
+
+#endif /* _LINUX_ARM_EABI_SYSDEP_H */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/truncate64.c b/ports/sysdeps/unix/sysv/linux/arm/eabi/truncate64.c
new file mode 100644
index 000000000..6a9c348d8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/truncate64.c
@@ -0,0 +1,75 @@
+/* Copyright (C) 1997-2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/types.h>
+#include <endian.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+#include "kernel-features.h"
+
+#ifdef __NR_truncate64
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+/* The variable is shared between all wrappers around *truncate64 calls. */
+int __have_no_truncate64;
+#endif
+
+/* Truncate the file FD refers to to LENGTH bytes. */
+int
+truncate64 (const char *path, off64_t length)
+{
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ if (! __have_no_truncate64)
+#endif
+ {
+ unsigned int low = length & 0xffffffff;
+ unsigned int high = length >> 32;
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ int saved_errno = errno;
+#endif
+ int result = INLINE_SYSCALL (truncate64, 4, CHECK_STRING (path), 0,
+ __LONG_LONG_PAIR (high, low));
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ if (result != -1 || errno != ENOSYS)
+#endif
+ return result;
+
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ __set_errno (saved_errno);
+ __have_no_truncate64 = 1;
+#endif
+ }
+
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ if ((off_t) length != length)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+ return __truncate (path, (off_t) length);
+#endif
+}
+
+#else
+/* Use the generic implementation. */
+# include <misc/truncate64.c>
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/eabi/umount.c b/ports/sysdeps/unix/sysv/linux/arm/eabi/umount.c
new file mode 100644
index 000000000..e7c569089
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/eabi/umount.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Since we don't have an oldumount system call, do what the kernel
+ does down here. */
+
+extern long int __umount2 (const char *name, int flags);
+
+long int
+__umount (const char *name)
+{
+ return __umount2 (name, 0);
+}
+
+weak_alias (__umount, umount);
diff --git a/ports/sysdeps/unix/sysv/linux/arm/fchown.c b/ports/sysdeps/unix/sysv/linux/arm/fchown.c
new file mode 100644
index 000000000..3a69ecc9e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/fchown.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fchown.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/fcntl.c b/ports/sysdeps/unix/sysv/linux/arm/fcntl.c
new file mode 100644
index 000000000..ea951bc4f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/fcntl.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/fxstat.c b/ports/sysdeps/unix/sysv/linux/arm/fxstat.c
new file mode 100644
index 000000000..4f219f0b9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/fxstat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/getdents64.c b/ports/sysdeps/unix/sysv/linux/arm/getdents64.c
new file mode 100644
index 000000000..0c75fb5a0
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/getdents64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getdents64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/getegid.c b/ports/sysdeps/unix/sysv/linux/arm/getegid.c
new file mode 100644
index 000000000..37b4b4a53
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/getegid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getegid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/geteuid.c b/ports/sysdeps/unix/sysv/linux/arm/geteuid.c
new file mode 100644
index 000000000..ebcb555b5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/geteuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/geteuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/getgid.c b/ports/sysdeps/unix/sysv/linux/arm/getgid.c
new file mode 100644
index 000000000..0a4d6061f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/getgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/getgroups.c b/ports/sysdeps/unix/sysv/linux/arm/getgroups.c
new file mode 100644
index 000000000..102ea24e1
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/getgroups.c
@@ -0,0 +1,2 @@
+/* We also have to rewrite the kernel gid_t to the user land type. */
+#include <sysdeps/unix/sysv/linux/i386/getgroups.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/getresgid.c b/ports/sysdeps/unix/sysv/linux/arm/getresgid.c
new file mode 100644
index 000000000..b703a414c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/getresgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getresgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/getresuid.c b/ports/sysdeps/unix/sysv/linux/arm/getresuid.c
new file mode 100644
index 000000000..0b14cefe3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/getresuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getresuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/getrlimit.c b/ports/sysdeps/unix/sysv/linux/arm/getrlimit.c
new file mode 100644
index 000000000..fc06dbd64
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/getrlimit.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getrlimit.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/getrlimit64.c b/ports/sysdeps/unix/sysv/linux/arm/getrlimit64.c
new file mode 100644
index 000000000..fef018f47
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/getrlimit64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/getuid.c b/ports/sysdeps/unix/sysv/linux/arm/getuid.c
new file mode 100644
index 000000000..d682c79a4
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/getuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/glob64.c b/ports/sysdeps/unix/sysv/linux/arm/glob64.c
new file mode 100644
index 000000000..82a9a296a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/glob64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/glob64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/ioperm.c b/ports/sysdeps/unix/sysv/linux/arm/ioperm.c
new file mode 100644
index 000000000..65ec07733
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/ioperm.c
@@ -0,0 +1,281 @@
+/* Copyright (C) 1998, 1999, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Phil Blundell, based on the Alpha version by
+ David Mosberger.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* I/O port access on the ARM is something of a fiction. What we do is to
+ map an appropriate area of /dev/mem into user space so that a program
+ can blast away at the hardware in such a way as to generate I/O cycles
+ on the bus. To insulate user code from dependencies on particular
+ hardware we don't allow calls to inb() and friends to be inlined, but
+ force them to come through code in here every time. Performance-critical
+ registers tend to be memory mapped these days so this should be no big
+ problem. */
+
+/* Once upon a time this file used mprotect to enable and disable
+ access to particular areas of I/O space. Unfortunately the
+ mprotect syscall also has the side effect of enabling caching for
+ the area affected (this is a kernel limitation). So we now just
+ enable all the ports all of the time. */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/mman.h>
+
+#include <linux/version.h>
+#include <asm/page.h>
+#include <sys/sysctl.h>
+
+#define PATH_ARM_SYSTYPE "/etc/arm_systype"
+#define PATH_CPUINFO "/proc/cpuinfo"
+
+#define MAX_PORT 0x10000
+
+static struct {
+ unsigned long int base;
+ unsigned long int io_base;
+ unsigned int shift;
+ unsigned int initdone; /* since all the above could be 0 */
+} io;
+
+#define IO_BASE_FOOTBRIDGE 0x7c000000
+#define IO_SHIFT_FOOTBRIDGE 0
+
+static struct platform {
+ const char *name;
+ unsigned long int io_base;
+ unsigned int shift;
+} platform[] = {
+ /* All currently supported platforms are in fact the same. :-) */
+ {"Chalice-CATS", IO_BASE_FOOTBRIDGE, IO_SHIFT_FOOTBRIDGE},
+ {"DEC-EBSA285", IO_BASE_FOOTBRIDGE, IO_SHIFT_FOOTBRIDGE},
+ {"Corel-NetWinder", IO_BASE_FOOTBRIDGE, IO_SHIFT_FOOTBRIDGE},
+ {"Rebel-NetWinder", IO_BASE_FOOTBRIDGE, IO_SHIFT_FOOTBRIDGE},
+};
+
+#define IO_ADDR(port) (io.base + ((port) << io.shift))
+
+/*
+ * Initialize I/O system. There are several ways to get the information
+ * we need. Each is tried in turn until one succeeds.
+ *
+ * 1. Sysctl (CTL_BUS, CTL_BUS_ISA, ISA_*). This is the preferred method
+ * but not all kernels support it.
+ *
+ * 2. Read the value (not the contents) of symlink PATH_ARM_SYSTYPE.
+ * - If it matches one of the entries in the table above, use the
+ * corresponding values.
+ * - If it begins with a number, assume this is a previously
+ * unsupported system and the values encode, in order,
+ * "<io_base>,<port_shift>".
+ *
+ * 3. Lookup the "system type" field in /proc/cpuinfo. Again, if it
+ * matches an entry in the platform[] table, use the corresponding
+ * values.
+ */
+
+/* The Linux kernel headers renamed this constant between 2.5.26 and
+ 2.5.27. It was backported to 2.4 between 2.4.22 and 2.4.23. */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,23)
+# define BUS_ISA CTL_BUS_ISA
+#endif
+
+static int
+init_iosys (void)
+{
+ char systype[256];
+ int i, n;
+ static int iobase_name[] = { CTL_BUS, BUS_ISA, BUS_ISA_PORT_BASE };
+ static int ioshift_name[] = { CTL_BUS, BUS_ISA, BUS_ISA_PORT_SHIFT };
+ size_t len = sizeof(io.base);
+
+ if (! sysctl (iobase_name, 3, &io.io_base, &len, NULL, 0)
+ && ! sysctl (ioshift_name, 3, &io.shift, &len, NULL, 0))
+ {
+ io.initdone = 1;
+ return 0;
+ }
+
+ n = readlink (PATH_ARM_SYSTYPE, systype, sizeof (systype) - 1);
+ if (n > 0)
+ {
+ systype[n] = '\0';
+ if (isdigit (systype[0]))
+ {
+ if (sscanf (systype, "%li,%i", &io.io_base, &io.shift) == 2)
+ {
+ io.initdone = 1;
+ return 0;
+ }
+ /* else we're likely going to fail with the system match below */
+ }
+ }
+ else
+ {
+ FILE * fp;
+
+ fp = fopen (PATH_CPUINFO, "r");
+ if (! fp)
+ return -1;
+ while ((n = fscanf (fp, "Hardware\t: %256[^\n]\n", systype))
+ != EOF)
+ {
+ if (n == 1)
+ break;
+ else
+ fgets (systype, 256, fp);
+ }
+ fclose (fp);
+
+ if (n == EOF)
+ {
+ /* this can happen if the format of /proc/cpuinfo changes... */
+ fprintf (stderr,
+ "ioperm: Unable to determine system type.\n"
+ "\t(May need " PATH_ARM_SYSTYPE " symlink?)\n");
+ __set_errno (ENODEV);
+ return -1;
+ }
+ }
+
+ /* translate systype name into i/o system: */
+ for (i = 0; i < sizeof (platform) / sizeof (platform[0]); ++i)
+ {
+ if (strcmp (platform[i].name, systype) == 0)
+ {
+ io.shift = platform[i].shift;
+ io.io_base = platform[i].io_base;
+ io.initdone = 1;
+ return 0;
+ }
+ }
+
+ /* systype is not a known platform name... */
+ __set_errno (ENODEV);
+ return -1;
+}
+
+int
+_ioperm (unsigned long int from, unsigned long int num, int turn_on)
+{
+ if (! io.initdone && init_iosys () < 0)
+ return -1;
+
+ /* this test isn't as silly as it may look like; consider overflows! */
+ if (from >= MAX_PORT || from + num > MAX_PORT)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ if (turn_on)
+ {
+ if (! io.base)
+ {
+ int fd;
+
+ fd = open ("/dev/mem", O_RDWR);
+ if (fd < 0)
+ return -1;
+
+ io.base =
+ (unsigned long int) __mmap (0, MAX_PORT << io.shift,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, io.io_base);
+ close (fd);
+ if ((long) io.base == -1)
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
+int
+_iopl (unsigned int level)
+{
+ if (level > 3)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+ if (level)
+ {
+ return _ioperm (0, MAX_PORT, 1);
+ }
+ return 0;
+}
+
+
+void
+_outb (unsigned char b, unsigned long int port)
+{
+ *((volatile unsigned char *)(IO_ADDR (port))) = b;
+}
+
+
+void
+_outw (unsigned short b, unsigned long int port)
+{
+ *((volatile unsigned short *)(IO_ADDR (port))) = b;
+}
+
+
+void
+_outl (unsigned int b, unsigned long int port)
+{
+ *((volatile unsigned long *)(IO_ADDR (port))) = b;
+}
+
+
+unsigned int
+_inb (unsigned long int port)
+{
+ return *((volatile unsigned char *)(IO_ADDR (port)));
+}
+
+
+unsigned int
+_inw (unsigned long int port)
+{
+ return *((volatile unsigned short *)(IO_ADDR (port)));
+}
+
+
+unsigned int
+_inl (unsigned long int port)
+{
+ return *((volatile unsigned long *)(IO_ADDR (port)));
+}
+
+weak_alias (_ioperm, ioperm);
+weak_alias (_iopl, iopl);
+weak_alias (_inb, inb);
+weak_alias (_inw, inw);
+weak_alias (_inl, inl);
+weak_alias (_outb, outb);
+weak_alias (_outw, outw);
+weak_alias (_outl, outl);
diff --git a/ports/sysdeps/unix/sysv/linux/arm/kernel-features.h b/ports/sysdeps/unix/sysv/linux/arm/kernel-features.h
new file mode 100644
index 000000000..6839e8755
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/kernel-features.h
@@ -0,0 +1,49 @@
+/* Set flags signalling availability of kernel features based on given
+ kernel version number.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* The utimes syscall was added before 2.6.1. */
+#if __LINUX_KERNEL_VERSION >= 132609
+# define __ASSUME_UTIMES 1
+#endif
+
+/* The new getrlimit syscall was added sometime before 2.4.6. */
+#if __LINUX_KERNEL_VERSION >= 132102
+#define __ASSUME_NEW_GETRLIMIT_SYSCALL 1
+#endif
+
+/* On ARM the truncate64/ftruncate64/mmap2/stat64/lstat64/fstat64
+ syscalls were introduced in 2.3.35. */
+#if __LINUX_KERNEL_VERSION >= 131875
+# define __ASSUME_TRUNCATE64_SYSCALL 1
+# define __ASSUME_MMAP2_SYSCALL 1
+# define __ASSUME_STAT64_SYSCALL 1
+#endif
+
+/* Arm got fcntl64 in 2.4.4. */
+#if __LINUX_KERNEL_VERSION >= 132100
+# define __ASSUME_FCNTL64 1
+#endif
+
+/* The vfork syscall on arm was definitely available in 2.4. */
+#if __LINUX_KERNEL_VERSION >= 132097 && defined __i386__
+# define __ASSUME_VFORK_SYSCALL 1
+#endif
+
+#include_next <kernel-features.h>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/lchown.c b/ports/sysdeps/unix/sysv/linux/arm/lchown.c
new file mode 100644
index 000000000..c89de99ba
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/lchown.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/lchown.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/libc-aeabi_read_tp.S b/ports/sysdeps/unix/sysv/linux/arm/libc-aeabi_read_tp.S
new file mode 100644
index 000000000..6132afc15
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/libc-aeabi_read_tp.S
@@ -0,0 +1 @@
+#include <aeabi_read_tp.S>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/linuxthreads/fork.c b/ports/sysdeps/unix/sysv/linux/arm/linuxthreads/fork.c
new file mode 100644
index 000000000..4fb0db2be
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/linuxthreads/fork.c
@@ -0,0 +1 @@
+#include <linuxthreads/sysdeps/unix/sysv/linux/fork.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/linuxthreads/sysdep-cancel.h b/ports/sysdeps/unix/sysv/linux/arm/linuxthreads/sysdep-cancel.h
new file mode 100644
index 000000000..b35d34728
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/linuxthreads/sysdep-cancel.h
@@ -0,0 +1,129 @@
+/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Phil Blundell <pb@nexus.co.uk>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread
+
+/* We push lr onto the stack, so we have to use ldmib instead of ldmia
+ to find the saved arguments. */
+# ifdef PIC
+# undef DOARGS_5
+# undef DOARGS_6
+# undef DOARGS_7
+# define DOARGS_5 str r4, [sp, $-4]!; ldr r4, [sp, $8];
+# define DOARGS_6 mov ip, sp; stmfd sp!, {r4, r5}; ldmib ip, {r4, r5};
+# define DOARGS_7 mov ip, sp; stmfd sp!, {r4, r5, r6}; ldmib ip, {r4, r5, r6};
+# endif
+
+# undef PSEUDO_RET
+# define PSEUDO_RET \
+ ldrcc pc, [sp], $4; \
+ ldr lr, [sp], $4; \
+ b PLTJMP(SYSCALL_ERROR)
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .section ".text"; \
+ PSEUDO_PROLOGUE; \
+ ENTRY (name); \
+ SINGLE_THREAD_P; \
+ bne .Lpseudo_cancel; \
+ DO_CALL (syscall_name, args); \
+ cmn r0, $4096; \
+ RETINSTR(cc, lr); \
+ b PLTJMP(SYSCALL_ERROR); \
+ .Lpseudo_cancel: \
+ str lr, [sp, $-4]!; \
+ DOCARGS_##args; /* save syscall args around CENABLE. */ \
+ CENABLE; \
+ mov ip, r0; /* put mask in safe place. */ \
+ UNDOCARGS_##args; /* restore syscall args. */ \
+ swi SYS_ify (syscall_name); /* do the call. */ \
+ str r0, [sp, $-4]!; /* save syscall return value. */ \
+ mov r0, ip; /* get mask back. */ \
+ CDISABLE; \
+ ldr r0, [sp], $4; /* retrieve return value. */ \
+ UNDOC2ARGS_##args; /* fix register damage. */ \
+ cmn r0, $4096;
+
+# define DOCARGS_0
+# define UNDOCARGS_0
+# define UNDOC2ARGS_0
+
+# define DOCARGS_1 str r0, [sp, #-4]!;
+# define UNDOCARGS_1 ldr r0, [sp], #4;
+# define UNDOC2ARGS_1
+
+# define DOCARGS_2 str r1, [sp, #-4]!; str r0, [sp, #-4]!;
+# define UNDOCARGS_2 ldr r0, [sp], #4; ldr r1, [sp], #4;
+# define UNDOC2ARGS_2
+
+# define DOCARGS_3 str r2, [sp, #-4]!; str r1, [sp, #-4]!; str r0, [sp, #-4]!;
+# define UNDOCARGS_3 ldr r0, [sp], #4; ldr r1, [sp], #4; ldr r2, [sp], #4
+# define UNDOC2ARGS_3
+
+# define DOCARGS_4 stmfd sp!, {r0-r3}
+# define UNDOCARGS_4 ldmfd sp!, {r0-r3}
+# define UNDOC2ARGS_4
+
+# define DOCARGS_5 stmfd sp!, {r0-r3}
+# define UNDOCARGS_5 ldmfd sp, {r0-r3}; str r4, [sp, #-4]!; ldr r4, [sp, #24]
+# define UNDOC2ARGS_5 ldr r4, [sp], #20
+
+# ifdef IS_IN_libpthread
+# define CENABLE bl PLTJMP(__pthread_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__pthread_disable_asynccancel)
+# define __local_multiple_threads __pthread_multiple_threads
+# else
+# define CENABLE bl PLTJMP(__libc_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__libc_disable_asynccancel)
+# define __local_multiple_threads __libc_multiple_threads
+# endif
+
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# if !defined PIC
+# define SINGLE_THREAD_P \
+ ldr ip, =__local_multiple_threads; \
+ ldr ip, [ip]; \
+ teq ip, #0;
+# define PSEUDO_PROLOGUE
+# else
+# define SINGLE_THREAD_P \
+ ldr ip, 1b; \
+2: \
+ ldr ip, [pc, ip]; \
+ teq ip, #0;
+# define PSEUDO_PROLOGUE \
+ 1: .word __local_multiple_threads - 2f - 8;
+# endif
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/linuxthreads/vfork.S b/ports/sysdeps/unix/sysv/linux/arm/linuxthreads/vfork.S
new file mode 100644
index 000000000..b826a99ad
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/linuxthreads/vfork.S
@@ -0,0 +1,78 @@
+/* Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <philb@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep-cancel.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <kernel-features.h>
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+
+ENTRY (__vfork)
+
+#ifdef __NR_vfork
+
+#ifdef SHARED
+ ldr ip, 1f
+ ldr r0, 2f
+3: add ip, pc, ip
+ ldr r0, [ip, r0]
+#else
+ ldr r0, 1f
+#endif
+ movs r0, r0
+ bne HIDDEN_JUMPTARGET (__fork)
+
+ DO_CALL (vfork, 0)
+ cmn a1, #4096
+ RETINSTR(cc, lr)
+
+#ifndef __ASSUME_VFORK_SYSCALL
+ /* Check if vfork syscall is known at all. */
+ cmn a1, #ENOSYS
+ bne PLTJMP(C_SYMBOL_NAME(__syscall_error))
+#endif
+
+#endif
+
+#ifndef __ASSUME_VFORK_SYSCALL
+ /* If we don't have vfork, fork is close enough. */
+ DO_CALL (fork, 0)
+ cmn a1, #4096
+ RETINSTR(cc, lr)
+#elif !defined __NR_vfork
+# error "__NR_vfork not available and __ASSUME_VFORK_SYSCALL defined"
+#endif
+ b PLTJMP(C_SYMBOL_NAME(__syscall_error))
+
+#ifdef SHARED
+1: .word _GLOBAL_OFFSET_TABLE_ - 3b - 8
+2: .word __libc_pthread_functions(GOTOFF)
+#else
+ .weak pthread_create
+1: .word pthread_create
+#endif
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/ports/sysdeps/unix/sysv/linux/arm/lockf64.c b/ports/sysdeps/unix/sysv/linux/arm/lockf64.c
new file mode 100644
index 000000000..a88f5a784
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/lockf64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/lockf64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/lxstat.c b/ports/sysdeps/unix/sysv/linux/arm/lxstat.c
new file mode 100644
index 000000000..2371cd971
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/lxstat.c
@@ -0,0 +1,2 @@
+#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
+
diff --git a/ports/sysdeps/unix/sysv/linux/arm/mmap.S b/ports/sysdeps/unix/sysv/linux/arm/mmap.S
new file mode 100644
index 000000000..9227bd79f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/mmap.S
@@ -0,0 +1,92 @@
+/* Copyright (C) 1998, 2000, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <kernel-features.h>
+
+#define EINVAL 22
+
+ .text
+
+ENTRY (__mmap)
+# ifdef __ASSUME_MMAP2_SYSCALL
+ /* This code is actually a couple of cycles slower than the
+ sys_mmap version below, so it might seem like a loss. But the
+ code path inside the kernel is sufficiently much shorter to
+ make it a net gain to use mmap2 when it's known to be
+ available. */
+
+ /* shuffle args */
+ str r5, [sp, #-4]!
+ ldr r5, [sp, #8]
+ str r4, [sp, #-4]!
+ ldr r4, [sp, #8]
+
+ /* convert offset to pages */
+ movs ip, r5, lsl #20
+ bne .Linval
+ mov r5, r5, lsr #12
+
+ /* do the syscall */
+ DO_CALL (mmap2, 0)
+
+ /* restore registers */
+2:
+ ldr r4, [sp], #4
+ ldr r5, [sp], #4
+
+ cmn r0, $4096
+ RETINSTR(cc, lr)
+ b PLTJMP(syscall_error)
+
+.Linval:
+ mov r0, #-EINVAL
+ b 2b
+# else
+ /* Because we can only get five args through the syscall interface, and
+ mmap() takes six, we need to build a parameter block and pass its
+ address instead. The 386 port does a similar trick. */
+
+ /* This code previously moved sp into ip and stored the args using
+ stmdb ip!, {a1-a4}. It did not modify sp, so the stack never had
+ to be restored after the syscall completed. It saved an
+ instruction and meant no stack cleanup work was required.
+
+ This will not work in the case of a mmap call being interrupted
+ by a signal. If the signal handler uses any stack the arguments
+ to mmap will be trashed. The results of a restart of mmap are
+ then unpredictable. */
+
+ /* store args on the stack */
+ stmdb sp!, {a1-a4}
+
+ /* do the syscall */
+ mov a1, sp
+ DO_CALL (mmap, 0)
+
+ /* pop args off the stack. */
+ add sp, sp, #16
+
+ cmn r0, $4096
+ RETINSTR(cc, lr)
+ b PLTJMP(syscall_error);
+#endif
+
+PSEUDO_END (__mmap)
+
+weak_alias (__mmap, mmap)
diff --git a/ports/sysdeps/unix/sysv/linux/arm/mmap64.S b/ports/sysdeps/unix/sysv/linux/arm/mmap64.S
new file mode 100644
index 000000000..3c1f247ed
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/mmap64.S
@@ -0,0 +1,89 @@
+/* Copyright (C) 2000, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#define EINVAL 22
+#define ENOSYS 38
+
+#include "kernel-features.h"
+
+#ifdef __ARMEB__
+# define LOW_OFFSET 4 + 4
+/* The initial + 4 is for the stack postdecrement. */
+# define HIGH_OFFSET 4 + 4 + 0
+#else
+# define LOW_OFFSET 4 + 0
+# define HIGH_OFFSET 4 + 4 + 4
+#endif
+
+ /* The mmap2 system call takes six arguments, all in registers. */
+ .text
+ENTRY (__mmap64)
+#ifdef __NR_mmap2
+ ldr ip, [sp, $LOW_OFFSET]
+ str r5, [sp, #-4]!
+ ldr r5, [sp, $HIGH_OFFSET]
+ str r4, [sp, #-4]!
+ movs r4, ip, lsl $20 @ check that offset is page-aligned
+ mov ip, ip, lsr $12
+ moveqs r4, r5, lsr $12 @ check for overflow
+ bne .Linval
+ ldr r4, [sp, $8] @ load fd
+ orr r5, ip, r5, lsl $20 @ compose page offset
+ mov ip, r0
+ DO_CALL (mmap2, 0)
+ cmn r0, $4096
+# ifdef __ASSUME_MMAP2_SYSCALL
+ ldr r4, [sp], #4
+ ldr r5, [sp], #4
+ RETINSTR(cc, lr)
+ b PLTJMP(syscall_error)
+# else
+ ldrcc r4, [sp], #4
+ ldrcc r5, [sp], #4
+ RETINSTR(cc, lr)
+ cmn r0, $ENOSYS
+ bne .Lerror
+ /* The current kernel does not support mmap2. Fall back to plain
+ mmap if the offset is small enough. */
+ ldr r5, [sp, $16]
+ mov r0, ip @ first arg was clobbered
+ teq r5, $0
+ ldreq r4, [sp], #4
+ ldreq r5, [sp], #4
+ beq PLTJMP(__mmap)
+# endif
+.Linval:
+ mov r0, $-EINVAL
+.Lerror:
+ ldr r4, [sp], #4
+ ldr r5, [sp], #4
+ b PLTJMP(syscall_error)
+#else
+ /* The kernel headers do not support mmap2. Fall back to plain
+ mmap if the offset is small enough. */
+ ldr ip, [sp, $8]
+ teq ip, $0
+ beq PLTJMP(__mmap)
+ mov r0, $-EINVAL
+ b PLTJMP(syscall_error)
+#endif
+PSEUDO_END (__mmap64)
+
+weak_alias (__mmap64, mmap64)
diff --git a/ports/sysdeps/unix/sysv/linux/arm/msgctl.c b/ports/sysdeps/unix/sysv/linux/arm/msgctl.c
new file mode 100644
index 000000000..9f9b8431a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/msgctl.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/msgctl.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/Makefile b/ports/sysdeps/unix/sysv/linux/arm/nptl/Makefile
new file mode 100644
index 000000000..f270f1943
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/Makefile
@@ -0,0 +1,8 @@
+ifeq ($(subdir),nptl)
+ifneq ($(arm-using-eabi),yes)
+# These tests rely on PTHREAD_KEYS_MAX. The SJLJ exception machinery
+# in libgcc registers one key, however, so only PTHREAD_KEYS_MAX-1
+# keys are available. This works fine for EABI targets.
+tests := $(filter-out tst-key1 tst-key4,$(tests))
+endif
+endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/Versions b/ports/sysdeps/unix/sysv/linux/arm/nptl/Versions
new file mode 100644
index 000000000..c74a06fe1
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/Versions
@@ -0,0 +1,6 @@
+libc {
+ GLIBC_PRIVATE {
+ # A copy of sigaction lives in NPTL, and needs these.
+ __default_sa_restorer; __default_rt_sa_restorer;
+ }
+}
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h b/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h
new file mode 100644
index 000000000..71ed714f3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h
@@ -0,0 +1,95 @@
+/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdint.h>
+#include <sysdep.h>
+
+
+typedef int8_t atomic8_t;
+typedef uint8_t uatomic8_t;
+typedef int_fast8_t atomic_fast8_t;
+typedef uint_fast8_t uatomic_fast8_t;
+
+typedef int32_t atomic32_t;
+typedef uint32_t uatomic32_t;
+typedef int_fast32_t atomic_fast32_t;
+typedef uint_fast32_t uatomic_fast32_t;
+
+typedef intptr_t atomicptr_t;
+typedef uintptr_t uatomicptr_t;
+typedef intmax_t atomic_max_t;
+typedef uintmax_t uatomic_max_t;
+
+void __arm_link_error (void);
+
+#define atomic_exchange_acq(mem, newvalue) \
+ ({ __typeof (*mem) result; \
+ if (sizeof (*mem) == 1) \
+ __asm__ __volatile__ ("swpb %0, %1, [%2]" \
+ : "=&r,&r" (result) \
+ : "r,0" (newvalue), "r,r" (mem) : "memory"); \
+ else if (sizeof (*mem) == 4) \
+ __asm__ __volatile__ ("swp %0, %1, [%2]" \
+ : "=&r,&r" (result) \
+ : "r,0" (newvalue), "r,r" (mem) : "memory"); \
+ else \
+ { \
+ result = 0; \
+ abort (); \
+ } \
+ result; })
+
+/* Atomic compare and exchange. This sequence relies on the kernel to
+ provide a compare and exchange operation which is atomic on the
+ current architecture, either via cleverness on pre-ARMv6 or via
+ ldrex / strex on ARMv6. */
+
+#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+ ({ __arm_link_error (); oldval; })
+
+#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
+ ({ __arm_link_error (); oldval; })
+
+/* It doesn't matter what register is used for a_oldval2, but we must
+ specify one to work around GCC PR rtl-optimization/21223. Otherwise
+ it may cause a_oldval or a_tmp to be moved to a different register. */
+
+#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
+ ({ register __typeof (oldval) a_oldval asm ("r0"); \
+ register __typeof (oldval) a_newval asm ("r1") = (newval); \
+ register __typeof (mem) a_ptr asm ("r2") = (mem); \
+ register __typeof (oldval) a_tmp asm ("r3"); \
+ register __typeof (oldval) a_oldval2 asm ("r4") = (oldval); \
+ __asm__ __volatile__ \
+ ("0:\tldr\t%1,[%3]\n\t" \
+ "cmp\t%1, %4\n\t" \
+ "bne\t1f\n\t" \
+ "mov\t%0, %4\n\t" \
+ "mov\t%1, #0xffff0fff\n\t" \
+ "mov\tlr, pc\n\t" \
+ "add\tpc, %1, #(0xffff0fc0 - 0xffff0fff)\n\t" \
+ "bcc\t0b\n\t" \
+ "mov\t%1, %4\n\t" \
+ "1:" \
+ : "=&r" (a_oldval), "=&r" (a_tmp) \
+ : "r" (a_newval), "r" (a_ptr), "r" (a_oldval2) \
+ : "ip", "lr", "cc", "memory"); \
+ a_tmp; })
+
+#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
+ ({ __arm_link_error (); oldval; })
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes.h b/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes.h
new file mode 100644
index 000000000..ea8d6a2f0
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes.h
@@ -0,0 +1,167 @@
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#define __SIZEOF_PTHREAD_ATTR_T 36
+#define __SIZEOF_PTHREAD_MUTEX_T 24
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_COND_T 48
+#define __SIZEOF_PTHREAD_COND_COMPAT_T 12
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCK_T 32
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIER_T 20
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+
+
+/* Thread identifiers. The structure of the attribute type is not
+ exposed on purpose. */
+typedef unsigned long int pthread_t;
+
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+} pthread_attr_t;
+
+
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is not exposed on purpose. */
+typedef union
+{
+ struct __pthread_mutex_s
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+ unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ long int __align;
+} pthread_mutexattr_t;
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ long int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned int __flags;
+ int __writer;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+#endif /* bits/pthreadtypes.h */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/semaphore.h b/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/semaphore.h
new file mode 100644
index 000000000..3fc647d31
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/semaphore.h
@@ -0,0 +1,38 @@
+/* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+
+#define __SIZEOF_SEM_T 16
+
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+/* Maximum value the semaphore can have. */
+#define SEM_VALUE_MAX ((int) ((~0u) >> 1))
+
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/clone.S b/ports/sysdeps/unix/sysv/linux/arm/nptl/clone.S
new file mode 100644
index 000000000..23750b3f8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/clone.S
@@ -0,0 +1,3 @@
+#define RESET_PID
+#include <tcb-offsets.h>
+#include "../clone.S"
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/createthread.c b/ports/sysdeps/unix/sysv/linux/arm/nptl/createthread.c
new file mode 100644
index 000000000..01bd8ce18
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/createthread.c
@@ -0,0 +1,23 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Value passed to 'clone' for initialization of the thread register. */
+#define TLS_VALUE (pd + 1)
+
+/* Get the real implementation. */
+#include <nptl/sysdeps/pthread/createthread.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/fork.c b/ports/sysdeps/unix/sysv/linux/arm/nptl/fork.c
new file mode 100644
index 000000000..310676f7a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/fork.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Phil Blundell <pb@nexus.co.uk>, 2005
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sched.h>
+#include <signal.h>
+#include <sysdep.h>
+#include <tls.h>
+
+
+#define ARCH_FORK() \
+ INLINE_SYSCALL (clone, 5, \
+ CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, \
+ NULL, NULL, NULL, &THREAD_SELF->tid)
+
+#include <nptl/sysdeps/unix/sysv/linux/fork.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.c b/ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.c
new file mode 100644
index 000000000..e0643a9f3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.c
@@ -0,0 +1,118 @@
+/* low level locking for pthread library. Generic futex-using version.
+ Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <sys/time.h>
+
+int
+__lll_timedlock_wait (int *futex, const struct timespec *abstime)
+{
+ struct timespec rt;
+
+ /* Reject invalid timeouts. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Upgrade the lock. */
+ if (atomic_exchange_acq (futex, 2) == 0)
+ return 0;
+
+ do
+ {
+ struct timeval tv;
+
+ /* Get the current time. */
+ (void) __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ lll_futex_timed_wait (futex, 2, &rt);
+ }
+ while (atomic_exchange_acq (futex, 2) != 0);
+
+ return 0;
+}
+
+
+/* These don't get included in libc.so */
+#ifdef IS_IN_libpthread
+int
+lll_unlock_wake_cb (int *futex)
+{
+ int val = atomic_exchange_rel (futex, 0);
+
+ if (__builtin_expect (val > 1, 0))
+ lll_futex_wake (futex, 1);
+
+ return 0;
+}
+
+
+int
+__lll_timedwait_tid (int *tidp, const struct timespec *abstime)
+{
+ int tid;
+
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Repeat until thread terminated. */
+ while ((tid = *tidp) != 0)
+ {
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* Wait until thread terminates. */
+ if (lll_futex_timed_wait (tidp, tid, &rt) == -ETIMEDOUT)
+ return ETIMEDOUT;
+ }
+
+ return 0;
+}
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h b/ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h
new file mode 100644
index 000000000..4bae95325
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h
@@ -0,0 +1,326 @@
+/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Libr \ary; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _LOWLEVELLOCK_H
+#define _LOWLEVELLOCK_H 1
+
+#include <time.h>
+#include <sys/param.h>
+#include <bits/pthreadtypes.h>
+#include <atomic.h>
+#include <sysdep.h>
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_REQUEUE 3
+#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
+
+/* Initializer for compatibility lock. */
+#define LLL_MUTEX_LOCK_INITIALIZER (0)
+
+#define lll_futex_wait(futexp, val) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, \
+ (futexp), FUTEX_WAIT, (val), 0); \
+ __ret; \
+ })
+
+#define lll_futex_timed_wait(futexp, val, timespec) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, \
+ (futexp), FUTEX_WAIT, (val), (timespec)); \
+ __ret; \
+ })
+
+#define lll_futex_wake(futexp, nr) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, \
+ (futexp), FUTEX_WAKE, (nr), 0); \
+ __ret; \
+ })
+
+#define lll_robust_mutex_dead(futexv) \
+ do \
+ { \
+ int *__futexp = &(futexv); \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ lll_futex_wake (__futexp, 1); \
+ } \
+ while (0)
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, \
+ (futexp), FUTEX_CMP_REQUEUE, (nr_wake), \
+ (nr_move), (mutex), (val)); \
+ __ret; \
+ })
+
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, \
+ (futexp), FUTEX_WAKE_OP, (nr_wake), \
+ (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ __ret; \
+ })
+
+
+static inline int __attribute__((always_inline))
+__lll_mutex_trylock (int *futex)
+{
+ int flag = 1, old;
+ asm volatile (
+ "\tswp %[old], %[flag], [%[futex]] @ try to take the lock\n"
+ "\tcmp %[old], #1 @ check old lock value\n"
+ "\tmovlo %[flag], #0 @ if we got it, return 0\n"
+ "\tswphi %[flag], %[old], [%[futex]] @ if it was contested,\n"
+ " @ restore the contested flag,\n"
+ " @ and check whether that won."
+ : [futex] "+&r" (futex), [flag] "+&r" (flag), [old] "=&r" (old)
+ : : "memory" );
+
+ return flag;
+}
+#define lll_mutex_trylock(lock) __lll_mutex_trylock (&(lock))
+
+
+static inline int __attribute__((always_inline))
+__lll_mutex_cond_trylock (int *futex)
+{
+ int flag = 2, old;
+ asm volatile (
+ "\tswp %[old], %[flag], [%[futex]] @ try to take the lock\n"
+ "\tcmp %[old], #1 @ check old lock value\n"
+ "\tmovlo %[flag], #0 @ if we got it, return 0\n"
+ "\tswphi %[flag], %[old], [%[futex]] @ if it was contested,\n"
+ " @ restore the contested flag,\n"
+ " @ and check whether that won."
+ : [futex] "+&r" (futex), [flag] "+&r" (flag), [old] "=&r" (old)
+ : : "memory" );
+
+ return flag;
+}
+#define lll_mutex_cond_trylock(lock) __lll_mutex_cond_trylock (&(lock))
+
+
+static inline int __attribute__((always_inline))
+__lll_robust_mutex_trylock(int *futex, int id)
+{
+ return atomic_compare_and_exchange_val_acq (futex, id, 0) != 0;
+}
+#define lll_robust_mutex_trylock(lock, id) \
+ __lll_robust_mutex_trylock (&(lock), id)
+
+extern int __lll_robust_lock_wait (int *futex) attribute_hidden;
+
+static inline void __attribute__((always_inline))
+__lll_mutex_lock (int *futex)
+{
+ int val = atomic_exchange_acq (futex, 1);
+
+ if (__builtin_expect (val != 0, 0))
+ {
+ while (atomic_exchange_acq (futex, 2) != 0)
+ lll_futex_wait (futex, 2);
+ }
+}
+#define lll_mutex_lock(futex) __lll_mutex_lock (&(futex))
+
+
+static inline int __attribute__ ((always_inline))
+__lll_robust_mutex_lock (int *futex, int id)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_lock_wait (futex);
+ return result;
+}
+#define lll_robust_mutex_lock(futex, id) \
+ __lll_robust_mutex_lock (&(futex), id)
+
+
+static inline void __attribute__ ((always_inline))
+__lll_mutex_cond_lock (int *futex)
+{
+ int val = atomic_exchange_acq (futex, 2);
+
+ if (__builtin_expect (val != 0, 0))
+ {
+ while (atomic_exchange_acq (futex, 2) != 0)
+ lll_futex_wait (futex, 2);
+ }
+}
+#define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex))
+
+
+#define lll_robust_mutex_cond_lock(futex, id) \
+ __lll_robust_mutex_lock (&(futex), (id) | FUTEX_WAITERS)
+
+
+extern int __lll_timedlock_wait (int *futex, const struct timespec *)
+ attribute_hidden;
+extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *)
+ attribute_hidden;
+
+static inline int __attribute__ ((always_inline))
+__lll_mutex_timedlock (int *futex, const struct timespec *abstime)
+{
+ int result = 0;
+ int val = atomic_exchange_acq (futex, 1);
+
+ if (__builtin_expect (val != 0, 0))
+ result = __lll_timedlock_wait (futex, abstime);
+ return result;
+}
+#define lll_mutex_timedlock(futex, abstime) \
+ __lll_mutex_timedlock (&(futex), abstime)
+
+
+static inline int __attribute__ ((always_inline))
+__lll_robust_mutex_timedlock (int *futex, const struct timespec *abstime,
+ int id)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_timedlock_wait (futex, abstime);
+ return result;
+}
+#define lll_robust_mutex_timedlock(futex, abstime, id) \
+ __lll_robust_mutex_timedlock (&(futex), abstime, id)
+
+
+static inline void __attribute__ ((always_inline))
+__lll_mutex_unlock (int *futex)
+{
+ int val = atomic_exchange_rel (futex, 0);
+ if (__builtin_expect (val > 1, 0))
+ lll_futex_wake (futex, 1);
+}
+#define lll_mutex_unlock(futex) __lll_mutex_unlock(&(futex))
+
+
+static inline void __attribute__ ((always_inline))
+__lll_robust_mutex_unlock (int *futex, int mask)
+{
+ int val = atomic_exchange_rel (futex, 0);
+ if (__builtin_expect (val & mask, 0))
+ lll_futex_wake (futex, 1);
+}
+#define lll_robust_mutex_unlock(futex) \
+ __lll_robust_mutex_unlock(&(futex), FUTEX_WAITERS)
+
+
+static inline void __attribute__ ((always_inline))
+__lll_mutex_unlock_force (int *futex)
+{
+ (void) atomic_exchange_rel (futex, 0);
+ lll_futex_wake (futex, 1);
+}
+#define lll_mutex_unlock_force(futex) __lll_mutex_unlock_force(&(futex))
+
+
+#define lll_mutex_islocked(futex) \
+ (futex != 0)
+
+
+/* Our internal lock implementation is identical to the binary-compatible
+ mutex implementation. */
+
+/* Type for lock object. */
+typedef int lll_lock_t;
+
+/* Initializers for lock. */
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+
+extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
+
+/* The states of a lock are:
+ 0 - untaken
+ 1 - taken by one user
+ >1 - taken by more users */
+
+#define lll_trylock(lock) lll_mutex_trylock (lock)
+#define lll_lock(lock) lll_mutex_lock (lock)
+#define lll_unlock(lock) lll_mutex_unlock (lock)
+#define lll_islocked(lock) lll_mutex_islocked (lock)
+
+/* The kernel notifies a process which uses CLONE_CLEARTID via futex
+ wakeup when the clone terminates. The memory location contains the
+ thread ID while the clone is running and is reset to zero
+ afterwards. */
+#define lll_wait_tid(tid) \
+ do { \
+ __typeof (tid) __tid; \
+ while ((__tid = (tid)) != 0) \
+ lll_futex_wait (&(tid), __tid); \
+ } while (0)
+
+extern int __lll_timedwait_tid (int *, const struct timespec *)
+ attribute_hidden;
+
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __res = 0; \
+ if ((tid) != 0) \
+ __res = __lll_timedwait_tid (&(tid), (abstime)); \
+ __res; \
+ })
+
+
+/* Conditional variable handling. */
+
+extern void __lll_cond_wait (pthread_cond_t *cond)
+ attribute_hidden;
+extern int __lll_cond_timedwait (pthread_cond_t *cond,
+ const struct timespec *abstime)
+ attribute_hidden;
+extern void __lll_cond_wake (pthread_cond_t *cond)
+ attribute_hidden;
+extern void __lll_cond_broadcast (pthread_cond_t *cond)
+ attribute_hidden;
+
+#define lll_cond_wait(cond) \
+ __lll_cond_wait (cond)
+#define lll_cond_timedwait(cond, abstime) \
+ __lll_cond_timedwait (cond, abstime)
+#define lll_cond_wake(cond) \
+ __lll_cond_wake (cond)
+#define lll_cond_broadcast(cond) \
+ __lll_cond_broadcast (cond)
+
+#endif /* lowlevellock.h */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S b/ports/sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S
new file mode 100644
index 000000000..1c2e1f554
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/pt-vfork.S
@@ -0,0 +1,38 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <tcb-offsets.h>
+
+/* Save the PID value. */
+#define SAVE_PID \
+ str lr, [sp, #-4]!; /* Save LR. */ \
+ mov r0, #0xffff0fff; /* Point to the high page. */ \
+ mov lr, pc; /* Save our return address. */ \
+ sub pc, r0, #31; /* Jump to the TLS entry. */ \
+ ldr lr, [sp], #4; /* Restore LR. */ \
+ mov r2, r0; /* Save the TLS addr in r2. */ \
+ ldr r3, [r2, #PID_OFFSET]; /* Load the saved PID. */ \
+ rsb r0, r3, #0; /* Negate it. */ \
+ str r0, [r2, #PID_OFFSET] /* Store the temporary PID. */
+
+/* Restore the old PID value in the parent. */
+#define RESTORE_PID \
+ cmp r0, #0; /* If we are the parent... */ \
+ strne r3, [r2, #PID_OFFSET] /* ... restore the saved PID. */
+
+#include "../vfork.S"
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/pthread_once.c b/ports/sysdeps/unix/sysv/linux/arm/nptl/pthread_once.c
new file mode 100644
index 000000000..c8925810c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/pthread_once.c
@@ -0,0 +1,99 @@
+/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+unsigned long int __fork_generation attribute_hidden;
+
+static void
+clear_once_control (void *arg)
+{
+ pthread_once_t *once_control = (pthread_once_t *) arg;
+
+ *once_control = 0;
+ lll_futex_wake (once_control, INT_MAX);
+}
+
+int
+__pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
+{
+ for (;;)
+ {
+ int oldval;
+ int newval;
+
+ /* Pseudo code:
+ newval = __fork_generation | 1;
+ oldval = *once_control;
+ if ((oldval & 2) == 0)
+ *once_control = newval;
+ Do this atomically.
+ */
+ do
+ {
+ newval = __fork_generation | 1;
+ oldval = *once_control;
+ if (oldval & 2)
+ break;
+ } while (atomic_compare_and_exchange_val_acq (once_control, newval, oldval) != oldval);
+
+ /* Check if the initializer has already been done. */
+ if ((oldval & 2) != 0)
+ return 0;
+
+ /* Check if another thread already runs the initializer. */
+ if ((oldval & 1) == 0)
+ break;
+
+ /* Check whether the initializer execution was interrupted by a fork. */
+ if (oldval != newval)
+ break;
+
+ /* Same generation, some other thread was faster. Wait. */
+ lll_futex_wait (once_control, oldval);
+ }
+
+ /* This thread is the first here. Do the initialization.
+ Register a cleanup handler so that in case the thread gets
+ interrupted the initialization can be restarted. */
+ pthread_cleanup_push (clear_once_control, once_control);
+
+ init_routine ();
+
+ pthread_cleanup_pop (0);
+
+ /* Say that the initialisation is done. */
+ *once_control = __fork_generation | 2;
+
+ /* Wake up all other threads. */
+ lll_futex_wake (once_control, INT_MAX);
+
+ return 0;
+}
+weak_alias (__pthread_once, pthread_once)
+strong_alias (__pthread_once, __pthread_once_internal)
+
+#if defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__PIC__)
+/* When statically linked, if pthread_create is used, this file
+ will be brought in. The exception handling code in GCC assumes
+ that if pthread_create is available, so are these. */
+const void *include_pthread_getspecific attribute_hidden = pthread_getspecific;
+const void *include_pthread_setspecific attribute_hidden = pthread_setspecific;
+const void *include_pthread_key_create attribute_hidden = pthread_key_create;
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/sysdep-cancel.h b/ports/sysdeps/unix/sysv/linux/arm/nptl/sysdep-cancel.h
new file mode 100644
index 000000000..a44ee95e1
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/sysdep-cancel.h
@@ -0,0 +1,128 @@
+/* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <nptl/pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .section ".text"; \
+ PSEUDO_PROLOGUE; \
+ .type __##syscall_name##_nocancel,%function; \
+ .globl __##syscall_name##_nocancel; \
+ __##syscall_name##_nocancel: \
+ DO_CALL (syscall_name, args); \
+ PSEUDO_RET; \
+ .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
+ ENTRY (name); \
+ SINGLE_THREAD_P; \
+ DOARGS_##args; \
+ bne .Lpseudo_cancel; \
+ DO_CALL (syscall_name, 0); \
+ UNDOARGS_##args; \
+ cmn r0, $4096; \
+ PSEUDO_RET; \
+ .Lpseudo_cancel: \
+ DOCARGS_##args; /* save syscall args etc. around CENABLE. */ \
+ CENABLE; \
+ mov ip, r0; /* put mask in safe place. */ \
+ UNDOCARGS_##args; /* restore syscall args. */ \
+ swi SYS_ify (syscall_name); /* do the call. */ \
+ str r0, [sp, $-4]!; /* save syscall return value. */ \
+ mov r0, ip; /* get mask back. */ \
+ CDISABLE; \
+ ldmfd sp!, {r0, lr}; /* retrieve return value and address. */ \
+ UNDOARGS_##args; \
+ cmn r0, $4096;
+
+# define DOCARGS_0 str lr, [sp, #-4]!;
+# define UNDOCARGS_0
+
+# define DOCARGS_1 stmfd sp!, {r0, lr};
+# define UNDOCARGS_1 ldr r0, [sp], #4;
+
+# define DOCARGS_2 stmfd sp!, {r0, r1, lr};
+# define UNDOCARGS_2 ldmfd sp!, {r0, r1};
+
+# define DOCARGS_3 stmfd sp!, {r0, r1, r2, lr};
+# define UNDOCARGS_3 ldmfd sp!, {r0, r1, r2};
+
+# define DOCARGS_4 stmfd sp!, {r0, r1, r2, r3, lr};
+# define UNDOCARGS_4 ldmfd sp!, {r0, r1, r2, r3};
+
+# define DOCARGS_5 DOCARGS_4
+# define UNDOCARGS_5 UNDOCARGS_4
+
+# ifdef IS_IN_libpthread
+# define CENABLE bl PLTJMP(__pthread_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__pthread_disable_asynccancel)
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define CENABLE bl PLTJMP(__libc_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__libc_disable_asynccancel)
+# define __local_multiple_threads __libc_multiple_threads
+# elif defined IS_IN_librt
+# define CENABLE bl PLTJMP(__librt_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__librt_disable_asynccancel)
+# else
+# error Unsupported library
+# endif
+
+# if defined IS_IN_libpthread || !defined NOT_IN_libc
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# define SINGLE_THREAD_P \
+ ldr ip, 1b; \
+2: \
+ ldr ip, [pc, ip]; \
+ teq ip, #0;
+# define PSEUDO_PROLOGUE \
+ 1: .word __local_multiple_threads - 2f - 8;
+# endif
+# else
+/* There is no __local_multiple_threads for librt, so use the TCB. */
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+# else
+# define PSEUDO_PROLOGUE
+# define SINGLE_THREAD_P \
+ stmfd sp!, {r0, lr}; \
+ bl __aeabi_read_tp; \
+ ldr ip, [r0, #MULTIPLE_THREADS_OFFSET]; \
+ ldmfd sp!, {r0, lr}; \
+ teq ip, #0
+# define SINGLE_THREAD_P_PIC(x) SINGLE_THREAD_P
+# endif
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* For rtld, et cetera. */
+# define SINGLE_THREAD_P 1
+# define NO_CANCELLATION 1
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/unwind-forcedunwind.c b/ports/sysdeps/unix/sysv/linux/arm/nptl/unwind-forcedunwind.c
new file mode 100644
index 000000000..ba5327a4d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/unwind-forcedunwind.c
@@ -0,0 +1,117 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <unwind.h>
+#include <pthreadP.h>
+
+static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
+static _Unwind_Reason_Code (*libgcc_s_personality)
+ (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *,
+ struct _Unwind_Context *);
+static _Unwind_Reason_Code (*libgcc_s_forcedunwind)
+ (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
+static _Unwind_Word (*libgcc_s_getcfa) (struct _Unwind_Context *);
+static void (*libgcc_s_sjlj_register) (struct SjLj_Function_Context *);
+static void (*libgcc_s_sjlj_unregister) (struct SjLj_Function_Context *);
+
+void
+pthread_cancel_init (void)
+{
+ void *resume, *personality, *forcedunwind, *getcfa;
+ void *handle;
+ void *sjlj_register, *sjlj_unregister;
+
+ if (__builtin_expect (libgcc_s_getcfa != NULL, 1))
+ return;
+
+ handle = __libc_dlopen ("libgcc_s.so.1");
+
+ if (handle == NULL
+ || (sjlj_register = __libc_dlsym (handle, "_Unwind_SjLj_Register")) == NULL
+ || (sjlj_unregister = __libc_dlsym (handle, "_Unwind_SjLj_Unregister")) == NULL
+ || (resume = __libc_dlsym (handle, "_Unwind_SjLj_Resume")) == NULL
+ || (personality = __libc_dlsym (handle, "__gcc_personality_sj0")) == NULL
+ || (forcedunwind = __libc_dlsym (handle, "_Unwind_SjLj_ForcedUnwind"))
+ == NULL
+ || (getcfa = __libc_dlsym (handle, "_Unwind_GetCFA")) == NULL
+ )
+ __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n");
+
+ libgcc_s_resume = resume;
+ libgcc_s_personality = personality;
+ libgcc_s_forcedunwind = forcedunwind;
+ libgcc_s_getcfa = getcfa;
+ libgcc_s_sjlj_register = sjlj_register;
+ libgcc_s_sjlj_unregister = sjlj_unregister;
+}
+
+void
+_Unwind_Resume (struct _Unwind_Exception *exc)
+{
+ if (__builtin_expect (libgcc_s_resume == NULL, 0))
+ pthread_cancel_init ();
+ libgcc_s_resume (exc);
+}
+
+_Unwind_Reason_Code
+__gcc_personality_v0 (int version, _Unwind_Action actions,
+ _Unwind_Exception_Class exception_class,
+ struct _Unwind_Exception *ue_header,
+ struct _Unwind_Context *context)
+{
+ if (__builtin_expect (libgcc_s_personality == NULL, 0))
+ pthread_cancel_init ();
+ return libgcc_s_personality (version, actions, exception_class,
+ ue_header, context);
+}
+
+_Unwind_Reason_Code
+_Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop,
+ void *stop_argument)
+{
+ if (__builtin_expect (libgcc_s_forcedunwind == NULL, 0))
+ pthread_cancel_init ();
+ return libgcc_s_forcedunwind (exc, stop, stop_argument);
+}
+
+_Unwind_Word
+_Unwind_GetCFA (struct _Unwind_Context *context)
+{
+ if (__builtin_expect (libgcc_s_getcfa == NULL, 0))
+ pthread_cancel_init ();
+ return libgcc_s_getcfa (context);
+}
+
+void
+_Unwind_SjLj_Register (struct SjLj_Function_Context *fc)
+{
+ if (__builtin_expect (libgcc_s_sjlj_register == NULL, 0))
+ pthread_cancel_init ();
+ libgcc_s_sjlj_register (fc);
+}
+
+void
+_Unwind_SjLj_Unregister (struct SjLj_Function_Context *fc)
+{
+ if (__builtin_expect (libgcc_s_sjlj_unregister == NULL, 0))
+ pthread_cancel_init ();
+ libgcc_s_sjlj_unregister (fc);
+}
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/unwind-resume.c b/ports/sysdeps/unix/sysv/linux/arm/nptl/unwind-resume.c
new file mode 100644
index 000000000..8dcfd34b1
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/unwind-resume.c
@@ -0,0 +1,87 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <unwind.h>
+
+static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
+static _Unwind_Reason_Code (*libgcc_s_personality)
+ (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *,
+ struct _Unwind_Context *);
+static void (*libgcc_s_sjlj_register) (struct SjLj_Function_Context *);
+static void (*libgcc_s_sjlj_unregister) (struct SjLj_Function_Context *);
+
+static void
+init (void)
+{
+ void *resume, *personality;
+ void *handle;
+ void *sjlj_register, *sjlj_unregister;
+
+ handle = __libc_dlopen ("libgcc_s.so.1");
+
+ if (handle == NULL
+ || (sjlj_register = __libc_dlsym (handle, "_Unwind_SjLj_Register")) == NULL
+ || (sjlj_unregister = __libc_dlsym (handle, "_Unwind_SjLj_Unregister")) == NULL
+ || (resume = __libc_dlsym (handle, "_Unwind_SjLj_Resume")) == NULL
+ || (personality = __libc_dlsym (handle, "__gcc_personality_sj0")) == NULL)
+ __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n");
+
+ libgcc_s_resume = resume;
+ libgcc_s_personality = personality;
+ libgcc_s_sjlj_register = sjlj_register;
+ libgcc_s_sjlj_unregister = sjlj_unregister;
+}
+
+void
+_Unwind_Resume (struct _Unwind_Exception *exc)
+{
+ if (__builtin_expect (libgcc_s_resume == NULL, 0))
+ init ();
+ libgcc_s_resume (exc);
+}
+
+_Unwind_Reason_Code
+__gcc_personality_v0 (int version, _Unwind_Action actions,
+ _Unwind_Exception_Class exception_class,
+ struct _Unwind_Exception *ue_header,
+ struct _Unwind_Context *context)
+{
+ if (__builtin_expect (libgcc_s_personality == NULL, 0))
+ init ();
+ return libgcc_s_personality (version, actions, exception_class,
+ ue_header, context);
+}
+
+void
+_Unwind_SjLj_Register (struct SjLj_Function_Context *fc)
+{
+ if (__builtin_expect (libgcc_s_sjlj_register == NULL, 0))
+ init ();
+ libgcc_s_sjlj_register (fc);
+}
+
+void
+_Unwind_SjLj_Unregister (struct SjLj_Function_Context *fc)
+{
+ if (__builtin_expect (libgcc_s_sjlj_unregister == NULL, 0))
+ init ();
+ libgcc_s_sjlj_unregister (fc);
+}
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/unwind.h b/ports/sysdeps/unix/sysv/linux/arm/nptl/unwind.h
new file mode 100644
index 000000000..8dd834edd
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/unwind.h
@@ -0,0 +1,31 @@
+/* Exception handling and frame unwind runtime interface routines.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _ARM_UNWIND_H
+#define _ARM_UNWIND_H 1
+
+#include <sysdeps/generic/unwind.h>
+
+/* Call the SjLj versions of these functions. */
+#define _Unwind_ForcedUnwind _Unwind_SjLj_ForcedUnwind
+#define _Unwind_Resume _Unwind_SjLj_Resume
+#define __gcc_personality_v0 __gcc_personality_sj0
+
+#endif /* unwind.h */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/nptl/vfork.S b/ports/sysdeps/unix/sysv/linux/arm/nptl/vfork.S
new file mode 100644
index 000000000..87e055e65
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/nptl/vfork.S
@@ -0,0 +1,39 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <tcb-offsets.h>
+
+/* Save the PID value. */
+#define SAVE_PID \
+ str lr, [sp, #-4]!; /* Save LR. */ \
+ mov r0, #0xffff0fff; /* Point to the high page. */ \
+ mov lr, pc; /* Save our return address. */ \
+ sub pc, r0, #31; /* Jump to the TLS entry. */ \
+ ldr lr, [sp], #4; /* Restore LR. */ \
+ mov r2, r0; /* Save the TLS addr in r2. */ \
+ ldr r3, [r2, #PID_OFFSET]; /* Load the saved PID. */ \
+ rsbs r0, r3, #0; /* Negate it. */ \
+ moveq r0, #0x80000000; /* Use 0x80000000 if it was 0. */ \
+ str r0, [r2, #PID_OFFSET] /* Store the temporary PID. */
+
+/* Restore the old PID value in the parent. */
+#define RESTORE_PID \
+ cmp r0, #0; /* If we are the parent... */ \
+ strne r3, [r2, #PID_OFFSET] /* ... restore the saved PID. */
+
+#include "../vfork.S"
diff --git a/ports/sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c b/ports/sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c
new file mode 100644
index 000000000..4c27e957b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/posix_fadvise.c b/ports/sysdeps/unix/sysv/linux/arm/posix_fadvise.c
new file mode 100644
index 000000000..bb5dd0e8f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/posix_fadvise.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fcntl.h>
+
+int __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise);
+
+/* Advice the system about the expected behaviour of the application with
+ respect to the file associated with FD. */
+
+int
+posix_fadvise (int fd, off_t offset, off_t len, int advise)
+{
+ /* ARM only has a syscall for fadvise64_64. */
+ return __posix_fadvise64_l64 (fd, offset, len, advise);
+}
diff --git a/ports/sysdeps/unix/sysv/linux/arm/posix_fadvise64.c b/ports/sysdeps/unix/sysv/linux/arm/posix_fadvise64.c
new file mode 100644
index 000000000..86752f884
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/posix_fadvise64.c
@@ -0,0 +1,78 @@
+/* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sysdep.h>
+#include <kernel-features.h>
+
+int __posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise);
+int __posix_fadvise64_l32 (int fd, off64_t offset, size_t len, int advise);
+
+/* Advice the system about the expected behaviour of the application with
+ respect to the file associated with FD. */
+
+int
+__posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise)
+{
+#ifdef __NR_arm_fadvise64_64
+ INTERNAL_SYSCALL_DECL (err);
+ int ret = INTERNAL_SYSCALL (arm_fadvise64_64, err, 6, fd, advise,
+ __LONG_LONG_PAIR ((long)(offset >> 32), (long)offset),
+ __LONG_LONG_PAIR ((long)(len >> 32), (long)len));
+ if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
+ return 0;
+# ifndef __ASSUME_FADVISE64_64_SYSCALL
+ if (INTERNAL_SYSCALL_ERRNO (ret, err) != ENOSYS)
+# endif
+ return INTERNAL_SYSCALL_ERRNO (ret, err);
+#endif
+#ifndef __ASSUME_FADVISE64_64_SYSCALL
+# ifdef __NR_fadvise64
+ if (len != (off_t) len)
+ return EOVERFLOW;
+
+ INTERNAL_SYSCALL_DECL (err2);
+ int ret2 = INTERNAL_SYSCALL (fadvise64, err2, 6, fd, 0,
+ __LONG_LONG_PAIR ((long)(offset >> 32), (long)offset),
+ (off_t) len, advise);
+ if (!INTERNAL_SYSCALL_ERROR_P (ret2, err2))
+ return 0;
+ return INTERNAL_SYSCALL_ERRNO (ret2, err2);
+# else
+ return ENOSYS;
+# endif
+#endif
+}
+
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_3_3)
+
+int
+attribute_compat_text_section
+__posix_fadvise64_l32 (int fd, off64_t offset, size_t len, int advise)
+{
+ return __posix_fadvise64_l64 (fd, offset, len, advise);
+}
+
+versioned_symbol (libc, __posix_fadvise64_l64, posix_fadvise64, GLIBC_2_3_3);
+compat_symbol (libc, __posix_fadvise64_l32, posix_fadvise64, GLIBC_2_2);
+#else
+strong_alias (__posix_fadvise64_l64, posix_fadvise64);
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/profil-counter.h b/ports/sysdeps/unix/sysv/linux/arm/profil-counter.h
new file mode 100644
index 000000000..7639883f1
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/profil-counter.h
@@ -0,0 +1,37 @@
+/* Low-level statistical profiling support function. Linux/ARM version.
+ Copyright (C) 1996, 1997, 1998, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <signal.h>
+#include <bits/armsigctx.h>
+
+void
+profil_counter (int signo, int _a2, int _a3, int _a4, union k_sigcontext sc)
+{
+ void *pc;
+ if (sc.v20.magic == SIGCONTEXT_2_0_MAGIC)
+ pc = (void *) sc.v20.reg.ARM_pc;
+ else
+ pc = (void *) sc.v21.arm_pc;
+ profil_count (pc);
+
+ /* This is a hack to prevent the compiler from implementing the
+ above function call as a sibcall. The sibcall would overwrite
+ the signal context. */
+ asm volatile ("");
+}
diff --git a/ports/sysdeps/unix/sysv/linux/arm/readdir64.c b/ports/sysdeps/unix/sysv/linux/arm/readdir64.c
new file mode 100644
index 000000000..2ea26dd40
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/readdir64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/readdir64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/readdir64_r.c b/ports/sysdeps/unix/sysv/linux/arm/readdir64_r.c
new file mode 100644
index 000000000..9f54f897e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/readdir64_r.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/readdir64_r.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/register-dump.h b/ports/sysdeps/unix/sysv/linux/arm/register-dump.h
new file mode 100644
index 000000000..2baccb2cb
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/register-dump.h
@@ -0,0 +1,166 @@
+/* Dump registers.
+ Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <pb@nexus.co.uk>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/uio.h>
+#include <stdio-common/_itoa.h>
+#include <bits/armsigctx.h>
+
+/* We will print the register dump in this format:
+
+ R0: XXXXXXXX R1: XXXXXXXX R2: XXXXXXXX R3: XXXXXXXX
+ R4: XXXXXXXX R5: XXXXXXXX R6: XXXXXXXX R7: XXXXXXXX
+ R8: XXXXXXXX R9: XXXXXXXX SL: XXXXXXXX FP: XXXXXXXX
+ IP: XXXXXXXX SP: XXXXXXXX LR: XXXXXXXX PC: XXXXXXXX
+
+ CPSR: XXXXXXXX
+
+ Trap: XXXXXXXX Error: XXXXXXXX OldMask: XXXXXXXX
+ Addr: XXXXXXXX
+
+ */
+
+static void
+hexvalue (unsigned long int value, char *buf, size_t len)
+{
+ char *cp = _itoa_word (value, buf + len, 16, 0);
+ while (cp > buf)
+ *--cp = '0';
+}
+
+static void
+register_dump (int fd, union k_sigcontext *ctx)
+{
+ char regs[21][8];
+ struct iovec iov[97];
+ size_t nr = 0;
+
+#define ADD_STRING(str) \
+ iov[nr].iov_base = (char *) str; \
+ iov[nr].iov_len = strlen (str); \
+ ++nr
+#define ADD_MEM(str, len) \
+ iov[nr].iov_base = str; \
+ iov[nr].iov_len = len; \
+ ++nr
+
+ /* Generate strings of register contents. */
+ if (ctx->v20.magic == SIGCONTEXT_2_0_MAGIC)
+ {
+ hexvalue (ctx->v20.reg.ARM_r0, regs[0], 8);
+ hexvalue (ctx->v20.reg.ARM_r1, regs[1], 8);
+ hexvalue (ctx->v20.reg.ARM_r2, regs[2], 8);
+ hexvalue (ctx->v20.reg.ARM_r3, regs[3], 8);
+ hexvalue (ctx->v20.reg.ARM_r4, regs[4], 8);
+ hexvalue (ctx->v20.reg.ARM_r5, regs[5], 8);
+ hexvalue (ctx->v20.reg.ARM_r6, regs[6], 8);
+ hexvalue (ctx->v20.reg.ARM_r7, regs[7], 8);
+ hexvalue (ctx->v20.reg.ARM_r8, regs[8], 8);
+ hexvalue (ctx->v20.reg.ARM_r9, regs[9], 8);
+ hexvalue (ctx->v20.reg.ARM_r10, regs[10], 8);
+ hexvalue (ctx->v20.reg.ARM_fp, regs[11], 8);
+ hexvalue (ctx->v20.reg.ARM_ip, regs[12], 8);
+ hexvalue (ctx->v20.reg.ARM_sp, regs[13], 8);
+ hexvalue (ctx->v20.reg.ARM_lr, regs[14], 8);
+ hexvalue (ctx->v20.reg.ARM_pc, regs[15], 8);
+ hexvalue (ctx->v20.reg.ARM_cpsr, regs[16], 8);
+ hexvalue (ctx->v20.trap_no, regs[17], 8);
+ hexvalue (ctx->v20.error_code, regs[18], 8);
+ hexvalue (ctx->v20.oldmask, regs[19], 8);
+ }
+ else
+ {
+ hexvalue (ctx->v21.arm_r0, regs[0], 8);
+ hexvalue (ctx->v21.arm_r1, regs[1], 8);
+ hexvalue (ctx->v21.arm_r2, regs[2], 8);
+ hexvalue (ctx->v21.arm_r3, regs[3], 8);
+ hexvalue (ctx->v21.arm_r4, regs[4], 8);
+ hexvalue (ctx->v21.arm_r5, regs[5], 8);
+ hexvalue (ctx->v21.arm_r6, regs[6], 8);
+ hexvalue (ctx->v21.arm_r7, regs[7], 8);
+ hexvalue (ctx->v21.arm_r8, regs[8], 8);
+ hexvalue (ctx->v21.arm_r9, regs[9], 8);
+ hexvalue (ctx->v21.arm_r10, regs[10], 8);
+ hexvalue (ctx->v21.arm_fp, regs[11], 8);
+ hexvalue (ctx->v21.arm_ip, regs[12], 8);
+ hexvalue (ctx->v21.arm_sp, regs[13], 8);
+ hexvalue (ctx->v21.arm_lr, regs[14], 8);
+ hexvalue (ctx->v21.arm_pc, regs[15], 8);
+ hexvalue (ctx->v21.arm_cpsr, regs[16], 8);
+ hexvalue (ctx->v21.trap_no, regs[17], 8);
+ hexvalue (ctx->v21.error_code, regs[18], 8);
+ hexvalue (ctx->v21.oldmask, regs[19], 8);
+ hexvalue (ctx->v21.fault_address, regs[20], 8);
+ }
+
+ /* Generate the output. */
+ ADD_STRING ("Register dump:\n\n R0: ");
+ ADD_MEM (regs[0], 8);
+ ADD_STRING (" R1: ");
+ ADD_MEM (regs[1], 8);
+ ADD_STRING (" R2: ");
+ ADD_MEM (regs[2], 8);
+ ADD_STRING (" R3: ");
+ ADD_MEM (regs[3], 8);
+ ADD_STRING ("\n R4: ");
+ ADD_MEM (regs[4], 8);
+ ADD_STRING (" R5: ");
+ ADD_MEM (regs[5], 8);
+ ADD_STRING (" R6: ");
+ ADD_MEM (regs[6], 8);
+ ADD_STRING (" R7: ");
+ ADD_MEM (regs[7], 8);
+ ADD_STRING ("\n R8: ");
+ ADD_MEM (regs[8], 8);
+ ADD_STRING (" R9: ");
+ ADD_MEM (regs[9], 8);
+ ADD_STRING (" SL: ");
+ ADD_MEM (regs[10], 8);
+ ADD_STRING (" FP: ");
+ ADD_MEM (regs[11], 8);
+ ADD_STRING ("\n IP: ");
+ ADD_MEM (regs[12], 8);
+ ADD_STRING (" SP: ");
+ ADD_MEM (regs[13], 8);
+ ADD_STRING (" LR: ");
+ ADD_MEM (regs[14], 8);
+ ADD_STRING (" PC: ");
+ ADD_MEM (regs[15], 8);
+ ADD_STRING ("\n\n CPSR: ");
+ ADD_MEM (regs[16], 8);
+ ADD_STRING ("\n\n Trap: ");
+ ADD_MEM (regs[17], 8);
+ ADD_STRING (" Error: ");
+ ADD_MEM (regs[18], 8);
+ ADD_STRING (" OldMask: ");
+ ADD_MEM (regs[19], 8);
+ if (ctx->v20.magic != SIGCONTEXT_2_0_MAGIC)
+ {
+ ADD_STRING ("\n Addr: ");
+ ADD_MEM (regs[20], 8);
+ }
+
+ ADD_STRING ("\n");
+
+ /* Write the stuff out. */
+ writev (fd, iov, nr);
+}
+
+
+#define REGISTER_DUMP register_dump (fd, &ctx)
diff --git a/ports/sysdeps/unix/sysv/linux/arm/scandir64.c b/ports/sysdeps/unix/sysv/linux/arm/scandir64.c
new file mode 100644
index 000000000..506fd8877
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/scandir64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/scandir64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/semctl.c b/ports/sysdeps/unix/sysv/linux/arm/semctl.c
new file mode 100644
index 000000000..e9b1a483c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/semctl.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/semctl.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/setegid.c b/ports/sysdeps/unix/sysv/linux/arm/setegid.c
new file mode 100644
index 000000000..2e3a54c89
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/setegid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setegid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/seteuid.c b/ports/sysdeps/unix/sysv/linux/arm/seteuid.c
new file mode 100644
index 000000000..18e41d08c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/seteuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/seteuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/setfsgid.c b/ports/sysdeps/unix/sysv/linux/arm/setfsgid.c
new file mode 100644
index 000000000..088671256
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/setfsgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setfsgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/setfsuid.c b/ports/sysdeps/unix/sysv/linux/arm/setfsuid.c
new file mode 100644
index 000000000..a9f22eb8a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/setfsuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setfsuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/setgid.c b/ports/sysdeps/unix/sysv/linux/arm/setgid.c
new file mode 100644
index 000000000..377021d9e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/setgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/setgroups.c b/ports/sysdeps/unix/sysv/linux/arm/setgroups.c
new file mode 100644
index 000000000..0e7086278
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/setgroups.c
@@ -0,0 +1,2 @@
+/* We also have to rewrite the kernel gid_t to the user land type. */
+#include <sysdeps/unix/sysv/linux/i386/setgroups.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/setregid.c b/ports/sysdeps/unix/sysv/linux/arm/setregid.c
new file mode 100644
index 000000000..99c57ad20
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/setregid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setregid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/setresgid.c b/ports/sysdeps/unix/sysv/linux/arm/setresgid.c
new file mode 100644
index 000000000..daca1a483
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/setresgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setresgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/setresuid.c b/ports/sysdeps/unix/sysv/linux/arm/setresuid.c
new file mode 100644
index 000000000..3aeabe9ad
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/setresuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setresuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/setreuid.c b/ports/sysdeps/unix/sysv/linux/arm/setreuid.c
new file mode 100644
index 000000000..8ad61226e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/setreuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setreuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/setrlimit.c b/ports/sysdeps/unix/sysv/linux/arm/setrlimit.c
new file mode 100644
index 000000000..bfaef74c3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/setrlimit.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setrlimit.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/setuid.c b/ports/sysdeps/unix/sysv/linux/arm/setuid.c
new file mode 100644
index 000000000..de394379b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/setuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/shmctl.c b/ports/sysdeps/unix/sysv/linux/arm/shmctl.c
new file mode 100644
index 000000000..7eac6380d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/shmctl.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/shmctl.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/sigaction.c b/ports/sysdeps/unix/sysv/linux/arm/sigaction.c
new file mode 100644
index 000000000..2d890d04e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/sigaction.c
@@ -0,0 +1,162 @@
+/* Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2005, 2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <signal.h>
+#include <string.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+#include <kernel-features.h>
+
+/* The difference here is that the sigaction structure used in the
+ kernel is not the same as we use in the libc. Therefore we must
+ translate it here. */
+#include <kernel_sigaction.h>
+
+/* The variable is shared between all wrappers around signal handling
+ functions which have RT equivalents. */
+int __libc_missing_rt_sigs;
+
+#define SA_RESTORER 0x04000000
+
+extern void __default_sa_restorer(void);
+extern void __default_rt_sa_restorer(void);
+
+/* When RT signals are in use we need to use a different return stub. */
+#ifdef __NR_rt_sigreturn
+#define choose_restorer(flags) \
+ (flags & SA_SIGINFO) ? __default_rt_sa_restorer \
+ : __default_sa_restorer
+#else
+#define choose_restorer(flags) \
+ __default_sa_restorer
+#endif
+
+/* 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
+__libc_sigaction (sig, act, oact)
+ int sig;
+ const struct sigaction *act;
+ struct sigaction *oact;
+{
+#ifndef __ASSUME_REALTIME_SIGNALS
+ struct old_kernel_sigaction k_sigact, k_osigact;
+#endif
+ int result;
+
+#ifdef __NR_rt_sigaction
+ /* First try the RT signals. */
+# ifndef __ASSUME_REALTIME_SIGNALS
+ if (!__libc_missing_rt_sigs)
+# endif
+ {
+ struct kernel_sigaction kact, koact;
+# ifndef __ASSUME_REALTIME_SIGNALS
+ int saved_errno = errno;
+# endif
+
+ if (act)
+ {
+ kact.k_sa_handler = act->sa_handler;
+ memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t));
+ kact.sa_flags = act->sa_flags;
+# ifdef HAVE_SA_RESTORER
+ if (kact.sa_flags & SA_RESTORER)
+ kact.sa_restorer = act->sa_restorer;
+ else
+ {
+ kact.sa_restorer = choose_restorer (kact.sa_flags);
+ kact.sa_flags |= SA_RESTORER;
+ }
+# endif
+ }
+
+ /* XXX The size argument hopefully will have to be changed to the
+ real size of the user-level sigset_t. */
+ result = INLINE_SYSCALL (rt_sigaction, 4, sig,
+ act ? __ptrvalue (&kact) : NULL,
+ oact ? __ptrvalue (&koact) : NULL, _NSIG / 8);
+
+# ifndef __ASSUME_REALTIME_SIGNALS
+ if (result >= 0 || errno != ENOSYS)
+# endif
+ {
+ if (oact && result >= 0)
+ {
+ oact->sa_handler = koact.k_sa_handler;
+ memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t));
+ oact->sa_flags = koact.sa_flags;
+# ifdef HAVE_SA_RESTORER
+ oact->sa_restorer = koact.sa_restorer;
+# endif
+ }
+ return result;
+ }
+
+# ifndef __ASSUME_REALTIME_SIGNALS
+ __set_errno (saved_errno);
+ __libc_missing_rt_sigs = 1;
+# endif
+ }
+#endif
+
+#ifndef __ASSUME_REALTIME_SIGNALS
+ if (act)
+ {
+ k_sigact.k_sa_handler = act->sa_handler;
+ k_sigact.sa_mask = act->sa_mask.__val[0];
+ k_sigact.sa_flags = act->sa_flags;
+# ifdef HAVE_SA_RESTORER
+ if (k_sigact.sa_flags & SA_RESTORER)
+ k_sigact.sa_restorer = act->sa_restorer;
+ else
+ {
+ k_sigact.sa_restorer = choose_restorer (k_sigact.sa_flags);
+ k_sigact.sa_flags |= SA_RESTORER;
+ }
+# endif
+ }
+ result = INLINE_SYSCALL (sigaction, 3, sig,
+ act ? __ptrvalue (&k_sigact) : NULL,
+ oact ? __ptrvalue (&k_osigact) : NULL);
+ if (oact && result >= 0)
+ {
+ oact->sa_handler = k_osigact.k_sa_handler;
+ oact->sa_mask.__val[0] = k_osigact.sa_mask;
+ oact->sa_flags = k_osigact.sa_flags;
+# ifdef HAVE_SA_RESTORER
+ oact->sa_restorer = k_osigact.sa_restorer;
+# endif
+ }
+ return result;
+#endif
+}
+libc_hidden_def (__libc_sigaction)
+
+#ifdef WRAPPER_INCLUDE
+# include WRAPPER_INCLUDE
+#endif
+
+#ifndef LIBC_SIGACTION
+weak_alias (__libc_sigaction, __sigaction)
+libc_hidden_weak (__sigaction)
+weak_alias (__libc_sigaction, sigaction)
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/sigcontextinfo.h b/ports/sysdeps/unix/sysv/linux/arm/sigcontextinfo.h
new file mode 100644
index 000000000..30c2e3a6c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/sigcontextinfo.h
@@ -0,0 +1,51 @@
+/* Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <philb@gnu.org>, 1999.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <bits/armsigctx.h>
+#include "kernel-features.h"
+
+#define SIGCONTEXT int _a2, int _a3, int _a4, union k_sigcontext
+#define SIGCONTEXT_EXTRA_ARGS _a2, _a3, _a4,
+
+/* The sigcontext structure changed between 2.0 and 2.1 kernels. On any
+ modern system we should be able to assume that the "new" format will be
+ in use. */
+#if __LINUX_KERNEL_VERSION > 131328
+
+#define GET_PC(ctx) ((void *) ctx.v21.arm_pc)
+#define GET_FRAME(ctx) ADVANCE_STACK_FRAME ((void *) ctx.v21.arm_fp)
+#define GET_STACK(ctx) ((void *) ctx.v21.arm_sp)
+
+#else
+
+#define GET_PC(ctx) ((void *)((ctx.v20.magic == SIGCONTEXT_2_0_MAGIC) ? \
+ ctx.v20.reg.ARM_pc : ctx.v21.arm_pc))
+#define GET_FRAME(ctx) \
+ ADVANCE_STACK_FRAME((void *)((ctx.v20.magic == SIGCONTEXT_2_0_MAGIC) ? \
+ ctx.v20.reg.ARM_fp : ctx.v21.arm_fp))
+#define GET_STACK(ctx) ((void *)((ctx.v20.magic == SIGCONTEXT_2_0_MAGIC) ? \
+ ctx.v20.reg.ARM_sp : ctx.v21.arm_sp))
+
+#endif
+
+#define ADVANCE_STACK_FRAME(frm) \
+ ((struct layout *)frm - 1)
+
+#define CALL_SIGHANDLER(handler, signo, ctx) \
+ (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
diff --git a/ports/sysdeps/unix/sysv/linux/arm/sigrestorer.S b/ports/sysdeps/unix/sysv/linux/arm/sigrestorer.S
new file mode 100644
index 000000000..98e33cb8b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/sigrestorer.S
@@ -0,0 +1,33 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+/* If no SA_RESTORER function was specified by the application we use
+ one of these. This avoids the need for the kernel to synthesise a return
+ instruction on the stack, which would involve expensive cache flushes. */
+
+ENTRY(__default_sa_restorer)
+ swi SYS_ify(sigreturn)
+
+#ifdef __NR_rt_sigreturn
+
+ENTRY(__default_rt_sa_restorer)
+ swi SYS_ify(rt_sigreturn)
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/socket.S b/ports/sysdeps/unix/sysv/linux/arm/socket.S
new file mode 100644
index 000000000..22d0c1ab0
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/socket.S
@@ -0,0 +1,127 @@
+/* Copyright (C) 1995, 1996, 1997, 1998, 2003, 2004, 2005
+ Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+
+#define P(a, b) P2(a, b)
+#define P2(a, b) a##b
+
+ .text
+/* The socket-oriented system calls are handled unusally in Linux.
+ They are all gated through the single `socketcall' system call number.
+ `socketcall' takes two arguments: the first is the subcode, specifying
+ which socket function is being called; and the second is a pointer to
+ the arguments to the specific function.
+
+ The .S files for the other calls just #define socket and #include this. */
+
+#ifndef __socket
+# ifndef NO_WEAK_ALIAS
+# define __socket P(__,socket)
+# else
+# define __socket socket
+# endif
+#endif
+
+#define PUSHARGS_1 str a1, [sp, $-4]!
+#define PUSHARGS_2 stmfd sp!, {a1, a2}
+#define PUSHARGS_3 stmfd sp!, {a1, a2, a3}
+#define PUSHARGS_4 stmfd sp!, {a1, a2, a3, a4}
+#define PUSHARGS_5 stmfd sp!, {a1, a2, a3, a4} /* Caller has already pushed arg 5 */
+#define PUSHARGS_6 stmfd sp!, {a1, a2, a3, a4}
+
+#define POPARGS_1 add sp, sp, #4
+#define POPARGS_2 add sp, sp, #8
+#define POPARGS_3 add sp, sp, #12
+#define POPARGS_4 add sp, sp, #16
+#define POPARGS_5 add sp, sp, #16
+#define POPARGS_6 add sp, sp, #16
+
+#ifndef NARGS
+#define NARGS 3 /* If we were called with no wrapper, this is really socket() */
+#endif
+
+#if defined NEED_CANCELLATION && defined CENABLE
+ PSEUDO_PROLOGUE
+#endif
+
+.globl __socket
+ENTRY (__socket)
+ /* This code previously moved sp into ip and stored the args using
+ stmdb ip!, {a1-a4}. It did not modify sp, so the stack never had
+ to be restored after the syscall completed. It saved an
+ instruction and meant no stack cleanup work was required.
+
+ This will not work in the case of a socket call being interrupted
+ by a signal. If the signal handler uses any stack the arguments
+ to socket will be trashed. The results of a restart of any
+ socket call are then unpredictable. */
+
+ /* Push args onto the stack. */
+ P(PUSHARGS_,NARGS)
+
+#if defined NEED_CANCELLATION && defined CENABLE
+ SINGLE_THREAD_P
+ bne 1f
+#endif
+
+ /* Do the system call trap. */
+ mov a1, $P(SOCKOP_,socket)
+ mov a2, sp
+ swi SYS_ify(socketcall)
+
+ /* Pop args off the stack */
+ P(POPARGS_,NARGS)
+
+ /* r0 is < 0 if there was an error. */
+ cmn r0, $124
+ RETINSTR(cc, r14)
+ b PLTJMP(SYSCALL_ERROR)
+
+#if defined NEED_CANCELLATION && defined CENABLE
+1:
+ str lr, [sp, #-4]!
+ CENABLE
+ mov ip, r0
+
+ mov r0, #P(SOCKOP_,socket)
+ add r1, sp, #4
+ swi SYS_ify(socketcall)
+
+ str r0, [sp, #-4]!
+ mov r0, ip
+ CDISABLE
+ ldr r0, [sp], #4
+ ldr lr, [sp], #4
+
+ P(POPARGS_,NARGS)
+
+ /* r0 is < 0 if there was an error. */
+ cmn r0, $124
+ RETINSTR(cc, r14)
+ b PLTJMP(SYSCALL_ERROR)
+#endif
+
+PSEUDO_END (__socket)
+
+#ifndef NO_WEAK_ALIAS
+weak_alias (__socket, socket)
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/arm/sys/elf.h b/ports/sysdeps/unix/sysv/linux/arm/sys/elf.h
new file mode 100644
index 000000000..faa731068
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/sys/elf.h
@@ -0,0 +1,26 @@
+/* Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_ELF_H
+#define _SYS_ELF_H 1
+
+#warning "This header is obsolete; use <sys/procfs.h> instead."
+
+#include <sys/procfs.h>
+
+#endif /* sys/elf.h */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/sys/io.h b/ports/sysdeps/unix/sysv/linux/arm/sys/io.h
new file mode 100644
index 000000000..68639902c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/sys/io.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 1996, 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_IO_H
+
+#define _SYS_IO_H 1
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* If TURN_ON is TRUE, request for permission to do direct i/o on the
+ port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
+ permission off for that range. This call requires root privileges. */
+extern int ioperm (unsigned long int __from, unsigned long int __num,
+ int __turn_on) __THROW;
+
+/* Set the I/O privilege level to LEVEL. If LEVEL is nonzero,
+ permission to access any I/O port is granted. This call requires
+ root privileges. */
+extern int iopl (int __level) __THROW;
+
+/* The functions that actually perform reads and writes. */
+extern unsigned char inb (unsigned long int port) __THROW;
+extern unsigned short int inw (unsigned long int port) __THROW;
+extern unsigned long int inl (unsigned long int port) __THROW;
+
+extern void outb (unsigned char value, unsigned long int port) __THROW;
+extern void outw (unsigned short value, unsigned long int port) __THROW;
+extern void outl (unsigned long value, unsigned long int port) __THROW;
+
+__END_DECLS
+
+#endif /* _SYS_IO_H */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/sys/procfs.h b/ports/sysdeps/unix/sysv/linux/arm/sys/procfs.h
new file mode 100644
index 000000000..3b3736324
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/sys/procfs.h
@@ -0,0 +1,123 @@
+/* Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_PROCFS_H
+#define _SYS_PROCFS_H 1
+
+/* This is somewhat modelled after the file of the same name on SVR4
+ systems. It provides a definition of the core file format for ELF
+ used on Linux. It doesn't have anything to do with the /proc file
+ system, even though Linux has one.
+
+ Anyway, the whole purpose of this file is for GDB and GDB only.
+ Don't read too much into it. Don't use it for anything other than
+ GDB unless you know what you are doing. */
+
+#include <features.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/user.h>
+
+__BEGIN_DECLS
+
+/* Type for a general-purpose register. */
+typedef unsigned long elf_greg_t;
+
+/* And the whole bunch of them. We could have used `struct
+ user_regs' directly in the typedef, but tradition says that
+ the register set is an array, which does have some peculiar
+ semantics, so leave it that way. */
+#define ELF_NGREG (sizeof (struct user_regs) / sizeof(elf_greg_t))
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+/* Register set for the floating-point registers. */
+typedef struct user_fpregs elf_fpregset_t;
+
+/* Signal info. */
+struct elf_siginfo
+ {
+ int si_signo; /* Signal number. */
+ int si_code; /* Extra code. */
+ int si_errno; /* Errno. */
+ };
+
+/* Definitions to generate Intel SVR4-like core files. These mostly
+ have the same names as the SVR4 types with "elf_" tacked on the
+ front to prevent clashes with Linux definitions, and the typedef
+ forms have been avoided. This is mostly like the SVR4 structure,
+ but more Linuxy, with things that Linux does not support and which
+ GDB doesn't really use excluded. */
+
+struct elf_prstatus
+ {
+ struct elf_siginfo pr_info; /* Info associated with signal. */
+ short int pr_cursig; /* Current signal. */
+ unsigned long int pr_sigpend; /* Set of pending signals. */
+ unsigned long int pr_sighold; /* Set of held signals. */
+ __pid_t pr_pid;
+ __pid_t pr_ppid;
+ __pid_t pr_pgrp;
+ __pid_t pr_sid;
+ struct timeval pr_utime; /* User time. */
+ struct timeval pr_stime; /* System time. */
+ struct timeval pr_cutime; /* Cumulative user time. */
+ struct timeval pr_cstime; /* Cumulative system time. */
+ elf_gregset_t pr_reg; /* GP registers. */
+ int pr_fpvalid; /* True if math copro being used. */
+ };
+
+
+#define ELF_PRARGSZ (80) /* Number of chars for args. */
+
+struct elf_prpsinfo
+ {
+ char pr_state; /* Numeric process state. */
+ char pr_sname; /* Char for pr_state. */
+ char pr_zomb; /* Zombie. */
+ char pr_nice; /* Nice val. */
+ unsigned long int pr_flag; /* Flags. */
+ unsigned short int pr_uid;
+ unsigned short int pr_gid;
+ int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+ /* Lots missing */
+ char pr_fname[16]; /* Filename of executable. */
+ char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
+ };
+
+/* The rest of this file provides the types for emulation of the
+ Solaris <proc_service.h> interfaces that should be implemented by
+ users of libthread_db. */
+
+/* Addresses. */
+typedef void *psaddr_t;
+
+/* Register sets. Linux has different names. */
+typedef elf_gregset_t prgregset_t;
+typedef elf_fpregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+ therefore have only one PID type. */
+typedef __pid_t lwpid_t;
+
+/* Process status and info. In the end we do provide typedefs for them. */
+typedef struct elf_prstatus prstatus_t;
+typedef struct elf_prpsinfo prpsinfo_t;
+
+__END_DECLS
+
+#endif /* sys/procfs.h */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/sys/ucontext.h b/ports/sysdeps/unix/sysv/linux/arm/sys/ucontext.h
new file mode 100644
index 000000000..9ecff7b59
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/sys/ucontext.h
@@ -0,0 +1,97 @@
+/* Copyright (C) 1998, 1999, 2001, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* System V/ARM ABI compliant context switching support. */
+
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <signal.h>
+#include <sys/procfs.h>
+
+/* We need the signal context definitions even if they are not used
+ included in <signal.h>. */
+#include <bits/sigcontext.h>
+
+typedef int greg_t;
+
+/* Number of general registers. */
+#define NGREG 18
+
+/* Container for all general registers. */
+typedef elf_gregset_t gregset_t;
+
+/* Number of each register is the `gregset_t' array. */
+enum
+{
+ R0 = 0,
+#define R0 R0
+ R1 = 1,
+#define R1 R1
+ R2 = 2,
+#define R2 R2
+ R3 = 3,
+#define R3 R3
+ R4 = 4,
+#define R4 R4
+ R5 = 5,
+#define R5 R5
+ R6 = 6,
+#define R6 R6
+ R7 = 7,
+#define R7 R7
+ R8 = 8,
+#define R8 R8
+ R9 = 9,
+#define R9 R9
+ R10 = 10,
+#define R10 R10
+ R11 = 11,
+#define R11 R11
+ R12 = 12,
+#define R12 R12
+ R13 = 13,
+#define R13 R13
+ R14 = 14,
+#define R14 R14
+ R15 = 15
+#define R15 R15
+};
+
+/* Structure to describe FPU registers. */
+typedef elf_fpregset_t fpregset_t;
+
+/* Context to describe whole processor state. This only describes
+ the core registers; coprocessor registers get saved elsewhere
+ (e.g. in uc_regspace, or somewhere unspecified on the stack
+ during non-RT signal handlers). */
+typedef struct sigcontext mcontext_t;
+
+/* Userlevel context. */
+typedef struct ucontext
+ {
+ unsigned long uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ __sigset_t uc_sigmask;
+ unsigned long uc_regspace[128] __attribute__((__aligned__(8)));
+ } ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/sys/user.h b/ports/sysdeps/unix/sysv/linux/arm/sys/user.h
new file mode 100644
index 000000000..3fae43f83
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/sys/user.h
@@ -0,0 +1,72 @@
+/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_USER_H
+#define _SYS_USER_H 1
+
+/* The whole purpose of this file is for GDB and GDB only. Don't read
+ too much into it. Don't use it for anything other than GDB unless
+ you know what you are doing. */
+
+struct user_fpregs
+{
+ struct fp_reg
+ {
+ unsigned int sign1:1;
+ unsigned int unused:15;
+ unsigned int sign2:1;
+ unsigned int exponent:14;
+ unsigned int j:1;
+ unsigned int mantissa1:31;
+ unsigned int mantissa0:32;
+ } fpregs[8];
+ unsigned int fpsr:32;
+ unsigned int fpcr:32;
+ unsigned char ftype[8];
+ unsigned int init_flag;
+};
+
+struct user_regs
+{
+ unsigned long int uregs[18];
+};
+
+struct user
+{
+ struct user_regs regs; /* General registers */
+ int u_fpvalid; /* True if math co-processor being used. */
+
+ unsigned long int u_tsize; /* Text segment size (pages). */
+ unsigned long int u_dsize; /* Data segment size (pages). */
+ unsigned long int u_ssize; /* Stack segment size (pages). */
+
+ unsigned long start_code; /* Starting virtual address of text. */
+ unsigned long start_stack; /* Starting virtual address of stack. */
+
+ long int signal; /* Signal that caused the core dump. */
+ int reserved; /* No longer used */
+ struct user_regs *u_ar0; /* help gdb to find the general registers. */
+
+ unsigned long magic; /* uniquely identify a core file */
+ char u_comm[32]; /* User command that was responsible */
+ int u_debugreg[8];
+ struct user_fpregs u_fp; /* Floating point registers */
+ struct user_fpregs *u_fp0; /* help gdb to find the FP registers. */
+};
+
+#endif /* sys/user.h */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/syscalls.list b/ports/sysdeps/unix/sysv/linux/arm/syscalls.list
new file mode 100644
index 000000000..1db0030b5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/syscalls.list
@@ -0,0 +1,5 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+syscall - syscall 7 syscall
+oldgetrlimit EXTRA getrlimit i:ip __old_getrlimit getrlimit@GLIBC_2.0
+oldsetrlimit EXTRA setrlimit i:ip __old_setrlimit setrlimit@GLIBC_2.0
diff --git a/ports/sysdeps/unix/sysv/linux/arm/sysdep.S b/ports/sysdeps/unix/sysv/linux/arm/sysdep.S
new file mode 100644
index 000000000..72541dd5c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/sysdep.S
@@ -0,0 +1,35 @@
+/* Copyright (C) 1995, 1996, 1997, 1998, 2005, 2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+ .text
+
+/* The syscall stubs jump here when they detect an error.
+ The code for Linux is almost identical to the canonical Unix
+ code, except that the error number in R0 is negated. */
+
+#undef CALL_MCOUNT
+#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers R0. */
+
+ENTRY (__syscall_error)
+ rsb r0, r0, $0
+
+#define __syscall_error __syscall_error_1
+#include <sysdeps/unix/arm/sysdep.S>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/sysdep.h b/ports/sysdeps/unix/sysv/linux/arm/sysdep.h
new file mode 100644
index 000000000..e40add30c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/sysdep.h
@@ -0,0 +1,277 @@
+/* Copyright (C) 1992, 93, 1995-2000, 2002, 2003, 2005, 2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995.
+ ARM changes by Philip Blundell, <pjb27@cam.ac.uk>, May 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _LINUX_ARM_SYSDEP_H
+#define _LINUX_ARM_SYSDEP_H 1
+
+/* There is some commonality. */
+#include <sysdeps/unix/arm/sysdep.h>
+
+/* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */
+#include <dl-sysdep.h>
+
+/* For Linux we can use the system call table in the header file
+ /usr/include/asm/unistd.h
+ of the kernel. But these symbols do not follow the SYS_* syntax
+ so we have to redefine the `SYS_ify' macro here. */
+#undef SYS_ify
+#define SWI_BASE (0x900000)
+#define SYS_ify(syscall_name) (__NR_##syscall_name)
+
+
+#ifdef __ASSEMBLER__
+
+/* Linux uses a negative return value to indicate syscall errors,
+ unlike most Unices, which use the condition codes' carry flag.
+
+ Since version 2.1 the return value of a system call might be
+ negative even if the call succeeded. E.g., the `lseek' system call
+ might return a large offset. Therefore we must not anymore test
+ for < 0, but test for a real error by making sure the value in R0
+ is a real error number. Linus said he will make sure the no syscall
+ returns a value in -1 .. -4095 as a valid result so we can safely
+ test with -4095. */
+
+#undef PSEUDO
+#define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name); \
+ DO_CALL (syscall_name, args); \
+ cmn r0, $4096;
+
+#define PSEUDO_RET \
+ RETINSTR(cc, lr); \
+ b PLTJMP(SYSCALL_ERROR)
+#undef ret
+#define ret PSEUDO_RET
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) \
+ SYSCALL_ERROR_HANDLER \
+ END (name)
+
+#undef PSEUDO_NOERRNO
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name); \
+ DO_CALL (syscall_name, args);
+
+#define PSEUDO_RET_NOERRNO \
+ DO_RET (lr);
+
+#undef ret_NOERRNO
+#define ret_NOERRNO PSEUDO_RET_NOERRNO
+
+#undef PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(name) \
+ END (name)
+
+/* The function has to return the error code. */
+#undef PSEUDO_ERRVAL
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args); \
+ rsb r0, r0, #0
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name) \
+ END (name)
+
+#define ret_ERRVAL PSEUDO_RET_NOERRNO
+
+#if NOT_IN_libc
+# define SYSCALL_ERROR __local_syscall_error
+# if RTLD_PRIVATE_ERRNO
+# define SYSCALL_ERROR_HANDLER \
+__local_syscall_error: \
+ ldr r1, 1f; \
+ rsb r0, r0, #0; \
+0: str r0, [pc, r1]; \
+ mvn r0, #0; \
+ DO_RET(lr); \
+1: .word C_SYMBOL_NAME(rtld_errno) - 0b - 8;
+# else
+# define SYSCALL_ERROR_HANDLER \
+__local_syscall_error: \
+ str lr, [sp, #-4]!; \
+ str r0, [sp, #-4]!; \
+ bl PLTJMP(C_SYMBOL_NAME(__errno_location)); \
+ ldr r1, [sp], #4; \
+ rsb r1, r1, #0; \
+ str r1, [r0]; \
+ mvn r0, #0; \
+ ldr pc, [sp], #4;
+# endif
+#else
+# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
+# define SYSCALL_ERROR __syscall_error
+#endif
+
+/* Linux takes system call args in registers:
+ syscall number in the SWI instruction
+ arg 1 r0
+ arg 2 r1
+ arg 3 r2
+ arg 4 r3
+ arg 5 r4 (this is different from the APCS convention)
+ arg 6 r5
+ arg 7 r6
+
+ The compiler is going to form a call by coming here, through PSEUDO, with
+ arguments
+ syscall number in the DO_CALL macro
+ arg 1 r0
+ arg 2 r1
+ arg 3 r2
+ arg 4 r3
+ arg 5 [sp]
+ arg 6 [sp+4]
+ arg 7 [sp+8]
+
+ We need to shuffle values between R4..R6 and the stack so that the
+ caller's v1..v3 and stack frame are not corrupted, and the kernel
+ sees the right arguments.
+
+*/
+
+#undef DO_CALL
+#define DO_CALL(syscall_name, args) \
+ DOARGS_##args \
+ swi SYS_ify (syscall_name); \
+ UNDOARGS_##args
+
+#define DOARGS_0 /* nothing */
+#define DOARGS_1 /* nothing */
+#define DOARGS_2 /* nothing */
+#define DOARGS_3 /* nothing */
+#define DOARGS_4 /* nothing */
+#define DOARGS_5 str r4, [sp, $-4]!; ldr r4, [sp, $4];
+#define DOARGS_6 mov ip, sp; stmfd sp!, {r4, r5}; ldmia ip, {r4, r5};
+#define DOARGS_7 mov ip, sp; stmfd sp!, {r4, r5, r6}; ldmia ip, {r4, r5, r6};
+
+#define UNDOARGS_0 /* nothing */
+#define UNDOARGS_1 /* nothing */
+#define UNDOARGS_2 /* nothing */
+#define UNDOARGS_3 /* nothing */
+#define UNDOARGS_4 /* nothing */
+#define UNDOARGS_5 ldr r4, [sp], $4;
+#define UNDOARGS_6 ldmfd sp!, {r4, r5};
+#define UNDOARGS_7 ldmfd sp!, {r4, r5, r6};
+
+#else /* not __ASSEMBLER__ */
+
+/* Define a macro which expands into the inline wrapper code for a system
+ call. */
+#undef INLINE_SYSCALL
+#define INLINE_SYSCALL(name, nr, args...) \
+ ({ unsigned int _sys_result = INTERNAL_SYSCALL (name, , nr, args); \
+ if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0)) \
+ { \
+ __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, )); \
+ _sys_result = (unsigned int) -1; \
+ } \
+ (int) _sys_result; })
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+
+#undef INTERNAL_SYSCALL_RAW
+#define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \
+ ({ unsigned int _sys_result; \
+ { \
+ register int _a1 asm ("a1"); \
+ LOAD_ARGS_##nr (args) \
+ asm volatile ("swi %1 @ syscall " #name \
+ : "=r" (_a1) \
+ : "i" (name) ASM_ARGS_##nr \
+ : "memory"); \
+ _sys_result = _a1; \
+ } \
+ (int) _sys_result; })
+
+#undef INTERNAL_SYSCALL
+#define INTERNAL_SYSCALL(name, err, nr, args...) \
+ INTERNAL_SYSCALL_RAW(SYS_ify(name), err, nr, args)
+
+#undef INTERNAL_SYSCALL_ARM
+#define INTERNAL_SYSCALL_ARM(name, err, nr, args...) \
+ INTERNAL_SYSCALL_RAW(__ARM_NR_##name, err, nr, args)
+
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+ ((unsigned int) (val) >= 0xfffff001u)
+
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
+
+#define LOAD_ARGS_0()
+#define ASM_ARGS_0
+#define LOAD_ARGS_1(a1) \
+ _a1 = (int) (a1); \
+ LOAD_ARGS_0 ()
+#define ASM_ARGS_1 ASM_ARGS_0, "r" (_a1)
+#define LOAD_ARGS_2(a1, a2) \
+ register int _a2 asm ("a2") = (int) (a2); \
+ LOAD_ARGS_1 (a1)
+#define ASM_ARGS_2 ASM_ARGS_1, "r" (_a2)
+#define LOAD_ARGS_3(a1, a2, a3) \
+ register int _a3 asm ("a3") = (int) (a3); \
+ LOAD_ARGS_2 (a1, a2)
+#define ASM_ARGS_3 ASM_ARGS_2, "r" (_a3)
+#define LOAD_ARGS_4(a1, a2, a3, a4) \
+ register int _a4 asm ("a4") = (int) (a4); \
+ LOAD_ARGS_3 (a1, a2, a3)
+#define ASM_ARGS_4 ASM_ARGS_3, "r" (_a4)
+#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
+ register int _v1 asm ("v1") = (int) (a5); \
+ LOAD_ARGS_4 (a1, a2, a3, a4)
+#define ASM_ARGS_5 ASM_ARGS_4, "r" (_v1)
+#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
+ register int _v2 asm ("v2") = (int) (a6); \
+ LOAD_ARGS_5 (a1, a2, a3, a4, a5)
+#define ASM_ARGS_6 ASM_ARGS_5, "r" (_v2)
+#define LOAD_ARGS_7(a1, a2, a3, a4, a5, a6, a7) \
+ register int _v3 asm ("v3") = (int) (a7); \
+ LOAD_ARGS_6 (a1, a2, a3, a4, a5, a6)
+#define ASM_ARGS_7 ASM_ARGS_6, "r" (_v3)
+
+/* We can't implement non-constant syscalls directly since the syscall
+ number is normally encoded in the instruction. So use SYS_syscall. */
+#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
+ INTERNAL_SYSCALL_NCS_##nr (number, err, args)
+
+#define INTERNAL_SYSCALL_NCS_0(number, err, args...) \
+ INTERNAL_SYSCALL (syscall, err, 1, number, args)
+#define INTERNAL_SYSCALL_NCS_1(number, err, args...) \
+ INTERNAL_SYSCALL (syscall, err, 2, number, args)
+#define INTERNAL_SYSCALL_NCS_2(number, err, args...) \
+ INTERNAL_SYSCALL (syscall, err, 3, number, args)
+#define INTERNAL_SYSCALL_NCS_3(number, err, args...) \
+ INTERNAL_SYSCALL (syscall, err, 4, number, args)
+#define INTERNAL_SYSCALL_NCS_4(number, err, args...) \
+ INTERNAL_SYSCALL (syscall, err, 5, number, args)
+#define INTERNAL_SYSCALL_NCS_5(number, err, args...) \
+ INTERNAL_SYSCALL (syscall, err, 6, number, args)
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* linux/arm/sysdep.h */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/versionsort64.c b/ports/sysdeps/unix/sysv/linux/arm/versionsort64.c
new file mode 100644
index 000000000..144b691e5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/versionsort64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/versionsort64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/arm/vfork.S b/ports/sysdeps/unix/sysv/linux/arm/vfork.S
new file mode 100644
index 000000000..a02065898
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/vfork.S
@@ -0,0 +1,65 @@
+/* Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <philb@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <kernel-features.h>
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+
+ENTRY (__vfork)
+
+#ifdef __NR_vfork
+#ifdef SAVE_PID
+ SAVE_PID
+#endif
+ DO_CALL (vfork, 0)
+#ifdef RESTORE_PID
+ RESTORE_PID
+#endif
+ cmn a1, #4096
+ RETINSTR(cc, lr)
+
+# ifdef __ASSUME_VFORK_SYSCALL
+ b PLTJMP(SYSCALL_ERROR)
+# else
+ /* Check if vfork syscall is known at all. */
+ cmn a1, #ENOSYS
+ bne PLTJMP(SYSCALL_ERROR)
+# endif
+#endif
+
+#ifndef __ASSUME_VFORK_SYSCALL
+ /* If we don't have vfork, fork is close enough. */
+ DO_CALL (fork, 0)
+ cmn a1, #4096
+ RETINSTR(cc, lr)
+ b PLTJMP(SYSCALL_ERROR)
+#elif !defined __NR_vfork
+# error "__NR_vfork not available and __ASSUME_VFORK_SYSCALL defined"
+#endif
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/ports/sysdeps/unix/sysv/linux/arm/xstat.c b/ports/sysdeps/unix/sysv/linux/arm/xstat.c
new file mode 100644
index 000000000..e9869f550
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/arm/xstat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/xstat.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/_G_config.h b/ports/sysdeps/unix/sysv/linux/cris/_G_config.h
new file mode 100644
index 000000000..083a00abf
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/_G_config.h
@@ -0,0 +1,106 @@
+/* This file is needed by libio to define various configuration parameters.
+ These are always the same in the GNU C library. */
+
+/* We have to keep a separate copy for CRIS, because we don't use thunks,
+ and libstdc++-v2 (which we currently use) cares. The C++ ABI is
+ changed totally with GCC 3.0, where we should not need a separate file. */
+
+#ifndef _G_config_h
+#define _G_config_h 1
+
+/* Define types for libio in terms of the standard internal type names. */
+
+#include <bits/types.h>
+#define __need_size_t
+#define __need_wchar_t
+#define __need_wint_t
+#define __need_NULL
+#include <stddef.h>
+#ifndef _WINT_T
+/* Integral type unchanged by default argument promotions that can
+ hold any value corresponding to members of the extended character
+ set, as well as at least one value that does not correspond to any
+ member of the extended character set. */
+# define _WINT_T
+typedef unsigned int wint_t;
+#endif
+#define __need_mbstate_t
+#include <wchar.h>
+#define _G_size_t size_t
+typedef struct
+{
+ __off_t __pos;
+ __mbstate_t __state;
+} _G_fpos_t;
+typedef struct
+{
+ __off64_t __pos;
+ __mbstate_t __state;
+} _G_fpos64_t;
+#define _G_ssize_t __ssize_t
+#define _G_off_t __off_t
+#define _G_off64_t __off64_t
+#define _G_pid_t __pid_t
+#define _G_uid_t __uid_t
+#define _G_wchar_t wchar_t
+#define _G_wint_t wint_t
+#define _G_stat64 stat64
+#include <gconv.h>
+typedef union
+{
+ struct __gconv_info __cd;
+ struct
+ {
+ struct __gconv_info __cd;
+ struct __gconv_step_data __data;
+ } __combined;
+} _G_iconv_t;
+
+typedef int _G_int16_t __attribute__ ((__mode__ (__HI__)));
+typedef int _G_int32_t __attribute__ ((__mode__ (__SI__)));
+typedef unsigned int _G_uint16_t __attribute__ ((__mode__ (__HI__)));
+typedef unsigned int _G_uint32_t __attribute__ ((__mode__ (__SI__)));
+
+#define _G_HAVE_BOOL 1
+
+
+/* These library features are always available in the GNU C library. */
+#define _G_HAVE_ATEXIT 1
+#define _G_HAVE_SYS_CDEFS 1
+#define _G_HAVE_SYS_WAIT 1
+#define _G_NEED_STDARG_H 1
+#define _G_va_list __gnuc_va_list
+
+#define _G_HAVE_PRINTF_FP 1
+#define _G_HAVE_MMAP 1
+#define _G_HAVE_LONG_DOUBLE_IO 1
+#define _G_HAVE_IO_FILE_OPEN 1
+#define _G_HAVE_IO_GETLINE_INFO 1
+
+#define _G_IO_IO_FILE_VERSION 0x20001
+
+#define _G_OPEN64 __open64
+#define _G_LSEEK64 __lseek64
+#define _G_MMAP64 __mmap64
+#define _G_FSTAT64(fd,buf) __fxstat64 (_STAT_VER, fd, buf)
+
+/* This is defined by <bits/stat.h> if `st_blksize' exists. */
+#define _G_HAVE_ST_BLKSIZE defined (_STATBUF_ST_BLKSIZE)
+
+#define _G_BUFSIZ 8192
+
+/* These are the vtbl details for ELF. */
+#define _G_NAMES_HAVE_UNDERSCORE 0
+#define _G_VTABLE_LABEL_HAS_LENGTH 1
+#undef _G_USING_THUNKS
+#define _G_VTABLE_LABEL_PREFIX "_vt."
+#define _G_VTABLE_LABEL_PREFIX_ID _vt.
+
+
+#if defined __cplusplus || defined __STDC__
+# define _G_ARGS(ARGLIST) ARGLIST
+#else
+# define _G_ARGS(ARGLIST) ()
+#endif
+
+#endif /* _G_config.h */
diff --git a/ports/sysdeps/unix/sysv/linux/cris/bits/fcntl.h b/ports/sysdeps/unix/sysv/linux/cris/bits/fcntl.h
new file mode 100644
index 000000000..36799aa50
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/bits/fcntl.h
@@ -0,0 +1,189 @@
+/* O_*, F_*, FD_* bit values for Linux.
+ Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+
+#include <sys/types.h>
+
+/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
+ located on an ext2 file system */
+#define O_ACCMODE 0003
+#define O_RDONLY 00
+#define O_WRONLY 01
+#define O_RDWR 02
+#define O_CREAT 0100 /* not fcntl */
+#define O_EXCL 0200 /* not fcntl */
+#define O_NOCTTY 0400 /* not fcntl */
+#define O_TRUNC 01000 /* not fcntl */
+#define O_APPEND 02000
+#define O_NONBLOCK 04000
+#define O_NDELAY O_NONBLOCK
+#define O_SYNC 010000
+#define O_FSYNC O_SYNC
+#define O_ASYNC 020000
+
+#ifdef __USE_GNU
+# define O_DIRECT 040000 /* Direct disk access. */
+# define O_DIRECTORY 0200000 /* Must be a directory. */
+# define O_NOFOLLOW 0400000 /* Do not follow links. */
+# define O_NOATIME 01000000 /* Do not set atime. */
+#endif
+
+/* For now Linux has synchronisity options for data and read operations.
+ We define the symbols here but let them do the same as O_SYNC since
+ this is a superset. */
+#if defined __USE_POSIX199309 || defined __USE_UNIX98
+# define O_DSYNC O_SYNC /* Synchronize data. */
+# define O_RSYNC O_SYNC /* Synchronize read operations. */
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define O_LARGEFILE 0100000
+#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. */
+#ifndef __USE_FILE_OFFSET64
+# define F_GETLK 5 /* Get record locking info. */
+# define F_SETLK 6 /* Set record locking info (non-blocking). */
+# define F_SETLKW 7 /* Set record locking info (blocking). */
+#else
+# define F_GETLK F_GETLK64 /* Get record locking info. */
+# define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/
+# define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
+#endif
+#define F_GETLK64 12 /* Get record locking info. */
+#define F_SETLK64 13 /* Set record locking info (non-blocking). */
+#define F_SETLKW64 14 /* Set record locking info (blocking). */
+
+#if defined __USE_BSD || defined __USE_UNIX98
+# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */
+# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETSIG 10 /* Set number of signal to be sent. */
+# define F_GETSIG 11 /* Get number of signal to be sent. */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETLEASE 1024 /* Set a lease. */
+# define F_GETLEASE 1025 /* Enquire what lease is active. */
+# define F_NOTIFY 1026 /* Request notfications on a directory. */
+#endif
+
+/* For F_[GET|SET]FL. */
+#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
+
+/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
+#define F_RDLCK 0 /* Read lock. */
+#define F_WRLCK 1 /* Write lock. */
+#define F_UNLCK 2 /* Remove lock. */
+
+/* For old implementation of bsd flock(). */
+#define F_EXLCK 4 /* or 3 */
+#define F_SHLCK 8 /* or 4 */
+
+#ifdef __USE_BSD
+/* Operations for bsd flock(), also used by the kernel implementation. */
+# define LOCK_SH 1 /* shared lock */
+# define LOCK_EX 2 /* exclusive lock */
+# define LOCK_NB 4 /* or'd with one of the above to prevent
+ blocking */
+# define LOCK_UN 8 /* remove lock */
+#endif
+
+#ifdef __USE_GNU
+# define LOCK_MAND 32 /* This is a mandatory flock: */
+# define LOCK_READ 64 /* ... which allows concurrent read operations. */
+# define LOCK_WRITE 128 /* ... which allows concurrent write operations. */
+# define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */
+#endif
+
+#ifdef __USE_GNU
+/* Types of directory notifications that may be requested with F_NOTIFY. */
+# define DN_ACCESS 0x00000001 /* File accessed. */
+# define DN_MODIFY 0x00000002 /* File modified. */
+# define DN_CREATE 0x00000004 /* File created. */
+# define DN_DELETE 0x00000008 /* File removed. */
+# define DN_RENAME 0x00000010 /* File renamed. */
+# define DN_ATTRIB 0x00000020 /* File changed attibutes. */
+# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
+#endif
+
+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'). */
+#ifndef __USE_FILE_OFFSET64
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+#else
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+#endif
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+
+#ifdef __USE_LARGEFILE64
+struct flock64
+ {
+ 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'). */
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+#endif
+
+/* Define some more compatibility macros to be backward compatible with
+ BSD systems which did not managed to hide these kernel macros. */
+#ifdef __USE_BSD
+# define FAPPEND O_APPEND
+# define FFSYNC O_FSYNC
+# define FASYNC O_ASYNC
+# define FNONBLOCK O_NONBLOCK
+# define FNDELAY O_NDELAY
+#endif /* Use BSD. */
+
+/* Advise to `posix_fadvise'. */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
+# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
+# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
+# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
+# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
+#endif
+
+__BEGIN_DECLS
+
+/* Provide kernel hint to read ahead. */
+extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
+ __THROW;
+
+__END_DECLS
diff --git a/ports/sysdeps/unix/sysv/linux/cris/bits/mman.h b/ports/sysdeps/unix/sysv/linux/cris/bits/mman.h
new file mode 100644
index 000000000..b66c0bdb6
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/bits/mman.h
@@ -0,0 +1,97 @@
+/* Definitions for POSIX memory map interface. Linux/CRIS version.
+ Copyright (C) 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_MMAN_H
+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
+#endif
+
+/* The following definitions basically come from the kernel headers.
+ But the kernel header is not namespace clean. */
+
+
+/* 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_READ 0x1 /* Page can be read. */
+#define PROT_WRITE 0x2 /* Page can be written. */
+#define PROT_EXEC 0x4 /* Page can be executed. */
+#define PROT_NONE 0x0 /* Page can not be accessed. */
+#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
+ growsdown vma (mprotect only). */
+#define PROT_GROWSUP 0x02000000 /* Extend change to start of
+ growsup vma (mprotect only). */
+
+/* Sharing types (must choose one and only one of these). */
+#define MAP_SHARED 0x01 /* Share changes. */
+#define MAP_PRIVATE 0x02 /* Changes are private. */
+#ifdef __USE_MISC
+# define MAP_TYPE 0x0f /* Mask for type of mapping. */
+#endif
+
+/* Other flags. */
+#define MAP_FIXED 0x10 /* Interpret addr exactly. */
+#ifdef __USE_MISC
+# define MAP_FILE 0
+# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
+# define MAP_ANON MAP_ANONYMOUS
+#endif
+
+/* These are Linux-specific. */
+#ifdef __USE_MISC
+# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
+# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
+# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
+# define MAP_LOCKED 0x2000 /* Lock the mapping. */
+# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
+#endif
+
+/* Flags to `msync'. */
+#define MS_ASYNC 1 /* Sync memory asynchronously. */
+#define MS_SYNC 4 /* Synchronous memory sync. */
+#define MS_INVALIDATE 2 /* Invalidate the caches. */
+
+/* Flags for `mlockall'. */
+#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
+#define MCL_FUTURE 2 /* Lock all additions to address
+ space. */
+
+/* Flags for `mremap'. */
+#ifdef __USE_GNU
+# define MREMAP_MAYMOVE 1
+#endif
+
+/* Advice to `madvise'. */
+#ifdef __USE_BSD
+# 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. */
+#endif
+
+/* The POSIX people had to invent similar names for the same things. */
+#ifdef __USE_XOPEN2K
+# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
+# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
+# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
+# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/cris/brk.c b/ports/sysdeps/unix/sysv/linux/cris/brk.c
new file mode 100644
index 000000000..ce4944512
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/brk.c
@@ -0,0 +1,44 @@
+/* brk system call for Linux/CRIS.
+ Copyright (C) 1995, 1996, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sysdep.h>
+
+/* This must be initialized data because commons can't have aliases. */
+void *__curbrk = 0;
+
+int
+__brk (void *addr)
+{
+ unsigned char *newbrk;
+
+ newbrk = (unsigned char *) INLINE_SYSCALL (brk, 1, addr);
+
+ __curbrk = newbrk;
+
+ if (newbrk < (unsigned char *) addr)
+ {
+ __set_errno (ENOMEM);
+ return -1;
+ }
+
+ return 0;
+}
+weak_alias (__brk, brk)
diff --git a/ports/sysdeps/unix/sysv/linux/cris/chown.c b/ports/sysdeps/unix/sysv/linux/cris/chown.c
new file mode 100644
index 000000000..196162256
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/chown.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/m68k/chown.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/clone.S b/ports/sysdeps/unix/sysv/linux/cris/clone.S
new file mode 100644
index 000000000..b2016438a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/clone.S
@@ -0,0 +1,88 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
+
+ .syntax no_register_prefix
+
+ .text
+ENTRY (__clone)
+ /* Sanity check arguments: No NULL function pointers. Allow a NULL
+ stack pointer though; it makes the kernel allocate stack. */
+ test.d r10
+ beq 1f
+ nop
+
+ /* We need to muck with a few registers. */
+ movem r1,[sp=sp-8]
+
+ /* Save the function pointer and argument. We can't save them
+ onto the new stack since it can be NULL. */
+ move.d r10,r0
+ move.d r13,r1
+
+ /* Move the other arguments into place for the system call. */
+ move.d r11,r10
+ move.d r12,r11
+
+ /* Do the system call. */
+ movu.w SYS_ify (clone),r9
+ break 13
+ test.d r10
+ beq .Lthread_start
+ nop
+
+ /* Jump to error handler if we get (unsigned) -4096 .. 0xffffffff. */
+ cmps.w -4096,r10
+ bhs 0f
+ movem [sp+],r1
+
+ /* In parent, successful return. (Avoid using "ret" - it's a macro.) */
+ Ret
+ nop
+
+.Lthread_start:
+ /* Terminate frame pointers here. */
+ moveq 0,r8
+
+ /* I've told you once. */
+ move.d r1,r10
+ jsr r0
+
+ SETUP_PIC
+ PLTCALL (_exit)
+
+ /* Die horribly. */
+ test.d [6809]
+
+ /* Stop the unstoppable. */
+9:
+ ba 9b
+ nop
+
+/* Local error handler. */
+1:
+ movs.w -EINVAL,r10
+ /* Drop through into the ordinary error handler. */
+PSEUDO_END (__clone)
+
+weak_alias (__clone, clone)
diff --git a/ports/sysdeps/unix/sysv/linux/cris/fchown.c b/ports/sysdeps/unix/sysv/linux/cris/fchown.c
new file mode 100644
index 000000000..3a69ecc9e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/fchown.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fchown.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/fcntl.c b/ports/sysdeps/unix/sysv/linux/cris/fcntl.c
new file mode 100644
index 000000000..ea951bc4f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/fcntl.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/fxstat.c b/ports/sysdeps/unix/sysv/linux/cris/fxstat.c
new file mode 100644
index 000000000..4f219f0b9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/fxstat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/getegid.c b/ports/sysdeps/unix/sysv/linux/cris/getegid.c
new file mode 100644
index 000000000..37b4b4a53
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/getegid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getegid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/geteuid.c b/ports/sysdeps/unix/sysv/linux/cris/geteuid.c
new file mode 100644
index 000000000..ebcb555b5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/geteuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/geteuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/getgid.c b/ports/sysdeps/unix/sysv/linux/cris/getgid.c
new file mode 100644
index 000000000..0a4d6061f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/getgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/getgroups.c b/ports/sysdeps/unix/sysv/linux/cris/getgroups.c
new file mode 100644
index 000000000..102ea24e1
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/getgroups.c
@@ -0,0 +1,2 @@
+/* We also have to rewrite the kernel gid_t to the user land type. */
+#include <sysdeps/unix/sysv/linux/i386/getgroups.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/getresgid.c b/ports/sysdeps/unix/sysv/linux/cris/getresgid.c
new file mode 100644
index 000000000..b703a414c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/getresgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getresgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/getresuid.c b/ports/sysdeps/unix/sysv/linux/cris/getresuid.c
new file mode 100644
index 000000000..0b14cefe3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/getresuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getresuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/getrlimit.c b/ports/sysdeps/unix/sysv/linux/cris/getrlimit.c
new file mode 100644
index 000000000..fc06dbd64
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/getrlimit.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getrlimit.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/getrlimit64.c b/ports/sysdeps/unix/sysv/linux/cris/getrlimit64.c
new file mode 100644
index 000000000..fef018f47
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/getrlimit64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/getuid.c b/ports/sysdeps/unix/sysv/linux/cris/getuid.c
new file mode 100644
index 000000000..d682c79a4
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/getuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/lchown.c b/ports/sysdeps/unix/sysv/linux/cris/lchown.c
new file mode 100644
index 000000000..c89de99ba
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/lchown.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/lchown.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/lockf64.c b/ports/sysdeps/unix/sysv/linux/cris/lockf64.c
new file mode 100644
index 000000000..a88f5a784
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/lockf64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/lockf64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/lxstat.c b/ports/sysdeps/unix/sysv/linux/cris/lxstat.c
new file mode 100644
index 000000000..2371cd971
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/lxstat.c
@@ -0,0 +1,2 @@
+#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
+
diff --git a/ports/sysdeps/unix/sysv/linux/cris/mmap.S b/ports/sysdeps/unix/sysv/linux/cris/mmap.S
new file mode 100644
index 000000000..3c74d590f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/mmap.S
@@ -0,0 +1,68 @@
+/* Copyright (C) 1995, 96, 97, 98, 99, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#include "kernel-features.h"
+
+#include <asm/errno.h>
+
+/* Rather than dragging in yet another kernel file, <asm/page.h>, we
+ define it here. Provide for easy override. */
+#ifndef PAGE_SHIFT
+#define PAGE_SHIFT 13
+#endif
+
+ .syntax no_register_prefix
+
+/* This is __ptr_t
+ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset) */
+
+ ENTRY (__mmap)
+
+ /* Only accept a offset (and address) being a multiple of PAGE_SIZE,
+ since we only pass the page part in the system call. */
+ move.d [sp+4],r9
+ btstq (PAGE_SHIFT - 1),r9
+ bne 1f
+ btstq (PAGE_SHIFT - 1),r10
+
+ bne 1f
+ lsrq PAGE_SHIFT,r9
+
+ move [sp],mof
+ move srp,[sp]
+ move r9,srp
+
+ movu.b SYS_ify (mmap2),r9
+ break 13
+
+ cmps.w -4096,r10
+ bhs 0f
+ move [sp],srp
+
+ Ret
+ nop
+
+/* Local error handler. */
+1:
+ movs.w -EINVAL,r10
+ /* Drop through into the ordinary error handler. */
+PSEUDO_END (__mmap)
+
+weak_alias (__mmap, mmap)
diff --git a/ports/sysdeps/unix/sysv/linux/cris/mmap64.S b/ports/sysdeps/unix/sysv/linux/cris/mmap64.S
new file mode 100644
index 000000000..d71114454
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/mmap64.S
@@ -0,0 +1,91 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#include "kernel-features.h"
+
+#include <asm/errno.h>
+
+/* Rather than dragging in yet another kernel file, <asm/page.h>, we
+ define it here. Provide for easy override. */
+#ifndef PAGE_SHIFT
+#define PAGE_SHIFT 13
+#endif
+
+/* This is: __ptr_t
+ __mmap64 (__ptr_t addr, size_t len, int prot, int flags, int fd,
+ off64_t offset); */
+
+/* This was done in C, but the resulting code didn't look anywhere near
+ nice, and mmap64 is important enough to have fast code. Rather than
+ fixing (the generic bits in) gcc, we make sure not to depend on it by
+ writing code that GCC cannot reasonably generate. */
+
+ .syntax no_register_prefix
+
+ENTRY (__mmap64)
+
+ move [sp],mof
+ move.d [sp+4],r9
+
+ /* Only accept an offset being a multiple of PAGE_SIZE, ditto address. */
+ btstq (PAGE_SHIFT - 1),r9
+ bne 1f
+ lsrq PAGE_SHIFT,r9
+
+ btstq (PAGE_SHIFT - 1),r10
+ bne 1f
+ move.d r9,[sp]
+
+ /* We have to store the adjusted part somewhere we can "or" from.
+ No registers available, so let's re-use the incoming low-part
+ parameter location. */
+ move.d [sp+8],r9
+
+ swapwbr r9
+ /* Check if the highest bits (now the lowest bits) are zero. They
+ must be, since we're actually calling a system function
+ specifying the size in *pages* in a single dword. Thus you can
+ mmap64 PAGE_SIZE * 4 Gbyte. */
+ btstq (PAGE_SHIFT - 1),r9
+ bne 1f
+ swapwbr r9
+
+ lslq (32 - PAGE_SHIFT),r9
+ or.d [sp],r9
+ move srp,[sp]
+ move r9,srp
+
+ movu.b SYS_ify (mmap2),r9
+ break 13
+
+ cmps.w -4096,r10
+ bhs 0f
+ move [sp],srp
+
+ Ret
+ nop
+
+/* Local error handler. */
+1:
+ movs.w -EINVAL,r10
+ /* Drop through into the ordinary error handler. */
+PSEUDO_END (__mmap64)
+
+weak_alias (__mmap64, mmap64)
diff --git a/ports/sysdeps/unix/sysv/linux/cris/msgctl.c b/ports/sysdeps/unix/sysv/linux/cris/msgctl.c
new file mode 100644
index 000000000..9f9b8431a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/msgctl.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/msgctl.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/profil-counter.h b/ports/sysdeps/unix/sysv/linux/cris/profil-counter.h
new file mode 100644
index 000000000..37adc1fee
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/profil-counter.h
@@ -0,0 +1,26 @@
+/* Low-level statistical profiling support function. Linux/CRIS version.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <signal.h>
+
+static void
+profil_counter (int signo, struct sigcontext *scp)
+{
+ profil_count ((void *) scp->regs.irp);
+}
diff --git a/ports/sysdeps/unix/sysv/linux/cris/register-dump.h b/ports/sysdeps/unix/sysv/linux/cris/register-dump.h
new file mode 100644
index 000000000..309728bf9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/register-dump.h
@@ -0,0 +1,117 @@
+/* Dump registers.
+ Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stddef.h>
+#include <sys/uio.h>
+#include <stdio-common/_itoa.h>
+
+/* We will print the register dump in this format:
+
+ R0: XXXXXXXX R1: XXXXXXXX R2: XXXXXXXX R3: XXXXXXXX
+ R4: XXXXXXXX R5: XXXXXXXX R6: XXXXXXXX R7: XXXXXXXX
+ R8: XXXXXXXX R9: XXXXXXXX R10: XXXXXXXX R11: XXXXXXXX
+ R12: XXXXXXXX R13: XXXXXXXX SP: XXXXXXXX PC: XXXXXXXX
+DCCR: XXXXXXXX SRP: XXXXXXXX */
+
+static void
+hexvalue (unsigned long int value, char *buf, size_t len)
+{
+ char *cp = _itoa_word (value, buf + len, 16, 0);
+ while (cp > buf)
+ *--cp = '0';
+}
+
+static void register_dump (int fd, struct sigcontext *ctx)
+{
+ char regs[18][8];
+ struct iovec iov[36], *next_iov = iov;
+ struct pt_regs *rx = &ctx->regs;
+
+#define ADD_STRING(str) \
+ next_iov->iov_base = (char *) (str); \
+ next_iov->iov_len = strlen (str); \
+ ++next_iov
+#define ADD_MEM(str, len) \
+ next_iov->iov_base = (str); \
+ next_iov->iov_len = (len); \
+ ++next_iov
+
+ /* Generate strings of register contents. */
+ hexvalue (rx->r0, regs[0], 8);
+ hexvalue (rx->r1, regs[1], 8);
+ hexvalue (rx->r2, regs[2], 8);
+ hexvalue (rx->r3, regs[3], 8);
+ hexvalue (rx->r4, regs[4], 8);
+ hexvalue (rx->r5, regs[5], 8);
+ hexvalue (rx->r6, regs[6], 8);
+ hexvalue (rx->r7, regs[7], 8);
+ hexvalue (rx->r8, regs[8], 8);
+ hexvalue (rx->r9, regs[9], 8);
+ hexvalue (rx->r10, regs[10], 8);
+ hexvalue (rx->r11, regs[11], 8);
+ hexvalue (rx->r12, regs[12], 8);
+ hexvalue (rx->r13, regs[13], 8);
+ hexvalue (ctx->usp, regs[14], 8);
+ hexvalue (rx->irp, regs[17], 8);
+ hexvalue (rx->dccr, regs[15], 8);
+ hexvalue (rx->srp, regs[16], 8);
+
+ /* Generate the output. */
+ ADD_STRING ("Register dump:\n\n R0: ");
+ ADD_MEM (regs[0], 8);
+ ADD_STRING (" R1: ");
+ ADD_MEM (regs[1], 8);
+ ADD_STRING (" R2: ");
+ ADD_MEM (regs[2], 8);
+ ADD_STRING (" R3: ");
+ ADD_MEM (regs[3], 8);
+ ADD_STRING ("\n R4: ");
+ ADD_MEM (regs[4], 8);
+ ADD_STRING (" R5: ");
+ ADD_MEM (regs[5], 8);
+ ADD_STRING (" R6: ");
+ ADD_MEM (regs[6], 8);
+ ADD_STRING (" R7: ");
+ ADD_MEM (regs[7], 8);
+ ADD_STRING ("\n R8: ");
+ ADD_MEM (regs[8], 8);
+ ADD_STRING (" R9: ");
+ ADD_MEM (regs[9], 8);
+ ADD_STRING (" R10: ");
+ ADD_MEM (regs[10], 8);
+ ADD_STRING (" R11: ");
+ ADD_MEM (regs[11], 8);
+ ADD_STRING ("\n R12: ");
+ ADD_MEM (regs[12], 8);
+ ADD_STRING (" R13: ");
+ ADD_MEM (regs[13], 8);
+ ADD_STRING (" SP: ");
+ ADD_MEM (regs[14], 8);
+ ADD_STRING (" PC: ");
+ ADD_MEM (regs[17], 8);
+ ADD_STRING ("\nDCCR: ");
+ ADD_MEM (regs[15], 8);
+ ADD_STRING (" SRP: ");
+ ADD_MEM (regs[16], 4);
+
+ /* Write the stuff out. */
+ writev (fd, iov, next_iov - iov);
+}
+
+#define REGISTER_DUMP register_dump (fd, ctx)
diff --git a/ports/sysdeps/unix/sysv/linux/cris/semctl.c b/ports/sysdeps/unix/sysv/linux/cris/semctl.c
new file mode 100644
index 000000000..e9b1a483c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/semctl.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/semctl.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/setegid.c b/ports/sysdeps/unix/sysv/linux/cris/setegid.c
new file mode 100644
index 000000000..2e3a54c89
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/setegid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setegid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/seteuid.c b/ports/sysdeps/unix/sysv/linux/cris/seteuid.c
new file mode 100644
index 000000000..18e41d08c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/seteuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/seteuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/setfsgid.c b/ports/sysdeps/unix/sysv/linux/cris/setfsgid.c
new file mode 100644
index 000000000..088671256
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/setfsgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setfsgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/setfsuid.c b/ports/sysdeps/unix/sysv/linux/cris/setfsuid.c
new file mode 100644
index 000000000..a9f22eb8a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/setfsuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setfsuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/setgid.c b/ports/sysdeps/unix/sysv/linux/cris/setgid.c
new file mode 100644
index 000000000..377021d9e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/setgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/setgroups.c b/ports/sysdeps/unix/sysv/linux/cris/setgroups.c
new file mode 100644
index 000000000..0e7086278
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/setgroups.c
@@ -0,0 +1,2 @@
+/* We also have to rewrite the kernel gid_t to the user land type. */
+#include <sysdeps/unix/sysv/linux/i386/setgroups.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/setregid.c b/ports/sysdeps/unix/sysv/linux/cris/setregid.c
new file mode 100644
index 000000000..99c57ad20
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/setregid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setregid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/setresgid.c b/ports/sysdeps/unix/sysv/linux/cris/setresgid.c
new file mode 100644
index 000000000..daca1a483
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/setresgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setresgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/setresuid.c b/ports/sysdeps/unix/sysv/linux/cris/setresuid.c
new file mode 100644
index 000000000..3aeabe9ad
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/setresuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setresuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/setreuid.c b/ports/sysdeps/unix/sysv/linux/cris/setreuid.c
new file mode 100644
index 000000000..8ad61226e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/setreuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setreuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/setrlimit.c b/ports/sysdeps/unix/sysv/linux/cris/setrlimit.c
new file mode 100644
index 000000000..bfaef74c3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/setrlimit.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setrlimit.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/setuid.c b/ports/sysdeps/unix/sysv/linux/cris/setuid.c
new file mode 100644
index 000000000..de394379b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/setuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/shmctl.c b/ports/sysdeps/unix/sysv/linux/cris/shmctl.c
new file mode 100644
index 000000000..7eac6380d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/shmctl.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/shmctl.c>
diff --git a/ports/sysdeps/unix/sysv/linux/cris/socket.S b/ports/sysdeps/unix/sysv/linux/cris/socket.S
new file mode 100644
index 000000000..38b4ac5fb
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/socket.S
@@ -0,0 +1,96 @@
+/* Copyright (C) 1995, 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <socketcall.h>
+
+#define P(a, b) P2(a, b)
+#define P2(a, b) a##b
+
+/* The socket-oriented system calls are handled unusally in Linux.
+ They are all gated through the single `socketcall' system call number.
+ `socketcall' takes two arguments: the first is the subcode, specifying
+ which socket function is being called; and the second is a pointer to
+ the arguments to the specific function.
+
+ The .S files for the other calls just #define socket and #include this.
+ They also #define a 'number-of-arguments' word in NARGS, which
+ defaults to 3. */
+
+#ifndef NARGS
+#ifdef socket
+#error NARGS not defined
+#endif
+#define NARGS 3
+#endif
+
+ .syntax no_register_prefix
+
+#ifndef __socket
+#define __socket P(__,socket)
+#endif
+
+ENTRY(__socket)
+ subq NARGS*4,sp
+
+#if NARGS >= 2
+ move.d sp,r9
+ move.d r10,[r9+]
+#else
+ move.d r10,[sp]
+#endif
+#if NARGS >= 2
+ move.d r11,[r9+]
+#endif
+#if NARGS >= 3
+ move.d r12,[r9+]
+#endif
+#if NARGS >= 4
+ move.d r13,[r9+]
+#endif
+#if NARGS >= 5
+ move.d [sp+NARGS*4],r13
+ move.d r13,[r9+]
+#endif
+#if NARGS >= 6
+ move.d [sp+NARGS*4+4],r13
+ move.d r13,[r9+]
+#endif
+#if NARGS >= 7
+ move.d [sp+NARGS*4+8],r13
+ move.d r13,[r9+]
+#endif
+#if NARGS >= 8
+ move.d [sp+NARGS*4+12],r13
+ move.d r13,[r9+]
+#endif
+#if NARGS >= 9
+#error Too many arguments!
+#endif
+ moveq P(SOCKOP_,socket),r10
+ move.d sp,r11
+ movu.w SYS_ify(socketcall),r9
+ break 13
+ cmps.w -4096,r10
+ bhs 0f
+ addq NARGS*4,sp
+ Ret
+ nop
+PSEUDO_END (__socket)
+
+weak_alias (__socket, socket)
diff --git a/ports/sysdeps/unix/sysv/linux/cris/sys/ucontext.h b/ports/sysdeps/unix/sysv/linux/cris/sys/ucontext.h
new file mode 100644
index 000000000..2d3aee076
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/sys/ucontext.h
@@ -0,0 +1,56 @@
+/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <signal.h>
+
+#include <bits/sigcontext.h>
+
+
+/* Type for general register. */
+typedef long int greg_t;
+
+/* Number of general registers. */
+#define NGREG 20
+
+/* Container for all general registers. */
+typedef greg_t gregset_t[NGREG];
+
+/* A placeholder type for floating-point register. */
+typedef long int fpreg_t;
+
+/* A placeholder; CRIS does not have any fp regs. */
+typedef unsigned long fpregset_t;
+
+/* A machine context is exactly a sigcontext. */
+typedef struct sigcontext mcontext_t;
+
+/* Userlevel context. */
+typedef struct ucontext
+ {
+ unsigned long int uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ __sigset_t uc_sigmask;
+ } ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/ports/sysdeps/unix/sysv/linux/cris/syscall.S b/ports/sysdeps/unix/sysv/linux/cris/syscall.S
new file mode 100644
index 000000000..03626b094
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/syscall.S
@@ -0,0 +1,40 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+ .syntax no_register_prefix
+
+/* Make syscall (callno, ...) into a system call. */
+
+ENTRY (syscall)
+ move.d r10,r9
+ move.d r11,r10
+ move.d r12,r11
+ move.d r13,r12
+ move.d [sp],r13
+ move srp,[sp]
+ move [sp+4],mof
+ move [sp+8],srp
+ break 13
+ cmps.w -4096,r10
+ bhs 0f
+ move [sp],srp
+ Ret
+ nop
+PSEUDO_END (syscall)
diff --git a/ports/sysdeps/unix/sysv/linux/cris/sysdep.S b/ports/sysdeps/unix/sysv/linux/cris/sysdep.S
new file mode 100644
index 000000000..e53e7bbfb
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/sysdep.S
@@ -0,0 +1,66 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+/* The syscall stubs jump here when they detect an error, bot for PIC and
+ non-PIC. */
+
+ .syntax no_register_prefix
+
+ENTRY (__syscall_error)
+ neg.d r10,r10
+
+#ifdef _LIBC_REENTRANT
+ push r10
+ push srp
+
+ /* Note that __syscall_error is only visible within this library,
+ and no-one passes it on as a pointer, so can assume that R0 (GOT
+ pointer) is correctly set up. */
+ PLTCALL (__errno_location)
+
+ pop srp
+ pop r11
+ move.d r11,[r10]
+
+#else /* not _LIBC_REENTRANT */
+# ifdef __PIC__
+ move.d [r0+C_SYMBOL_NAME(errno:GOT)],r9
+ move.d r10,[r9]
+# else
+ move.d r10,[C_SYMBOL_NAME(errno)]
+# endif
+#endif /* _LIBC_REENTRANT */
+
+#ifdef __PIC__
+/* PIC callers are supposed to have R0 on stack, ready for us to restore.
+ Callers are only allowed from within this DSO, so the GOT in r0 is the
+ one we want to use.
+
+ (Don't use "ret" - it's a macro). */
+
+ moveq -1,r10
+ Ret
+ pop r0
+#else
+ Ret
+ moveq -1,r10
+#endif
+
+END (__syscall_error)
diff --git a/ports/sysdeps/unix/sysv/linux/cris/sysdep.h b/ports/sysdeps/unix/sysv/linux/cris/sysdep.h
new file mode 100644
index 000000000..5013dd5d3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/sysdep.h
@@ -0,0 +1,226 @@
+/* Assembler macros for CRIS.
+ Copyright (C) 1999, 2001, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <asm/unistd.h>
+#include <sysdeps/cris/sysdep.h>
+#include <sys/syscall.h>
+#include "config.h"
+
+#undef SYS_ify
+#define SYS_ify(syscall_name) (__NR_##syscall_name)
+
+
+#ifdef __ASSEMBLER__
+
+/* For Linux we can use the system call table in the header file
+ /usr/include/asm/unistd.h
+ of the kernel. But these symbols do not follow the SYS_* syntax
+ so we have to redefine the `SYS_ify' macro here. */
+#undef SYS_ify
+#define SYS_ify(syscall_name) __NR_##syscall_name
+
+/* ELF-like local names start with `.L'. */
+#undef L
+#define L(name) .L##name
+
+/* Linux uses a negative return value to indicate syscall errors,
+ unlike most Unices, which use the condition codes' carry flag.
+
+ Since version 2.1 the return value of a system call might be
+ negative even if the call succeeded. E.g., the `lseek' system call
+ might return a large offset. Therefore we must not anymore test
+ for < 0, but test for a real error by making sure the value in %eax
+ is a real error number. Linus said he will make sure the no syscall
+ returns a value in -1 .. -4095 as a valid result so we can safely
+ test with -4095. */
+
+/* Syscall wrappers consist of
+ #include <sysdep.h>
+ PSEUDO (...)
+ ret
+ PSEUDO_END (...)
+
+ which expand to the following. */
+
+/* Linux takes system call arguments in registers:
+ syscall number R9
+ arg 1 R10
+ arg 2 R11
+ arg 3 R12
+ arg 4 R13
+ arg 5 MOF
+ arg 6 SRP
+
+ The compiler calls us by the C convention:
+ syscall number in the DO_CALL macro
+ arg 1 R10
+ arg 2 R11
+ arg 3 R12
+ arg 4 R13
+ arg 5 [SP]
+ arg 6 [SP + 4]
+ */
+
+/* Note that we use "bhs", since we want to match
+ (unsigned) -4096 .. 0xffffffff. Using "ble" would match
+ -4096 .. -2**31. */
+#define PSEUDO(name, syscall_name, args) \
+ ENTRY (name) @ \
+ DOARGS_##args @ \
+ movu.w SYS_ify (syscall_name),$r9 @ \
+ break 13 @ \
+ cmps.w -4096,$r10 @ \
+ bhs 0f @ \
+ nop @ \
+ UNDOARGS_return_##args
+
+/* Ouch! We have to remember not to use "ret" in assembly-code.
+ ("Luckily", mnemonics are case-insensitive.)
+ Note that we assume usage is exactly:
+ PSEUDO (...)
+ ret
+ PSEUDO_END (...)
+ so we can put all payload into PSEUDO (except for error handling). */
+
+#define ret
+
+#define PSEUDO_END(name) \
+0: @ \
+ SETUP_PIC @ \
+ PLTJUMP (syscall_error) @ \
+ END (name)
+
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+ ENTRY (name) @ \
+ DOARGS_##args @ \
+ movu.w SYS_ify (syscall_name),$r9 @ \
+ break 13 @ \
+ UNDOARGS_return_##args
+
+#define ret_NOERRNO
+
+#define PSEUDO_END_NOERRNO(name) \
+ END (name)
+
+#define DOARGS_0
+#define DOARGS_1
+#define DOARGS_2
+#define DOARGS_3
+#define DOARGS_4
+#define DOARGS_5 \
+ move [$sp],$mof
+
+/* To avoid allocating stack-space, we re-use the arg 5 (MOF) entry by
+ storing SRP into it. If called with too-few arguments, we will crash,
+ but that will happen in the general case too. */
+#define DOARGS_6 \
+ DOARGS_5 @ \
+ move $srp,[$sp] @ \
+ move [$sp+4],$srp
+
+#define UNDOARGS_return_0 \
+ Ret @ \
+ nop
+
+#define UNDOARGS_return_1 UNDOARGS_return_0
+#define UNDOARGS_return_2 UNDOARGS_return_0
+#define UNDOARGS_return_3 UNDOARGS_return_0
+#define UNDOARGS_return_4 UNDOARGS_return_0
+#define UNDOARGS_return_5 UNDOARGS_return_0
+
+/* We assume the following code will be "ret" and "PSEUDO_END". */
+#define UNDOARGS_return_return_6 \
+ jump [$sp]
+
+#else /* not __ASSEMBLER__ */
+
+#undef INLINE_SYSCALL
+#define INLINE_SYSCALL(name, nr, args...) \
+ ({ \
+ unsigned long __sys_res; \
+ register unsigned long __res asm ("r10"); \
+ LOAD_ARGS_c_##nr (args) \
+ register unsigned long __callno asm ("r9") \
+ = SYS_ify (name); \
+ asm volatile (LOAD_ARGS_asm_##nr (args) \
+ "break 13" \
+ : "=r" (__res) \
+ : ASM_ARGS_##nr (args) \
+ : ASM_CLOBBER_##nr); \
+ __sys_res = __res; \
+ \
+ if (__sys_res >= (unsigned long) -4096) \
+ { \
+ __set_errno (- __sys_res); \
+ __sys_res = (unsigned long) -1; \
+ } \
+ (long int) __sys_res; \
+ })
+
+#define LOAD_ARGS_c_0()
+#define LOAD_ARGS_asm_0()
+#define ASM_CLOBBER_0 "memory"
+#define ASM_ARGS_0() "r" (__callno)
+
+#define LOAD_ARGS_c_1(r10) \
+ LOAD_ARGS_c_0() \
+ register unsigned long __r10 __asm__ ("r10") = (unsigned long) (r10);
+#define LOAD_ARGS_asm_1(r10) LOAD_ARGS_asm_0 ()
+#define ASM_CLOBBER_1 ASM_CLOBBER_0
+#define ASM_ARGS_1(r10) ASM_ARGS_0 (), "0" (__r10)
+
+#define LOAD_ARGS_c_2(r10, r11) \
+ LOAD_ARGS_c_1(r10) \
+ register unsigned long __r11 __asm__ ("r11") = (unsigned long) (r11);
+#define LOAD_ARGS_asm_2(r10, r11) LOAD_ARGS_asm_1 (r10)
+#define ASM_CLOBBER_2 ASM_CLOBBER_1
+#define ASM_ARGS_2(r10, r11) ASM_ARGS_1 (r10), "r" (__r11)
+
+#define LOAD_ARGS_c_3(r10, r11, r12) \
+ LOAD_ARGS_c_2(r10, r11) \
+ register unsigned long __r12 __asm__ ("r12") = (unsigned long) (r12);
+#define LOAD_ARGS_asm_3(r10, r11, r12) LOAD_ARGS_asm_2 (r10, r11)
+#define ASM_CLOBBER_3 ASM_CLOBBER_2
+#define ASM_ARGS_3(r10, r11, r12) ASM_ARGS_2 (r10, r11), "r" (__r12)
+
+#define LOAD_ARGS_c_4(r10, r11, r12, r13) \
+ LOAD_ARGS_c_3(r10, r11, r12) \
+ register unsigned long __r13 __asm__ ("r13") = (unsigned long) (r13);
+#define LOAD_ARGS_asm_4(r10, r11, r12, r13) LOAD_ARGS_asm_3 (r10, r11, r12)
+#define ASM_CLOBBER_4 ASM_CLOBBER_3
+#define ASM_ARGS_4(r10, r11, r12, r13) ASM_ARGS_3 (r10, r11, r12), "r" (__r13)
+
+#define LOAD_ARGS_c_5(r10, r11, r12, r13, mof) \
+ LOAD_ARGS_c_4(r10, r11, r12, r13)
+#define LOAD_ARGS_asm_5(r10, r11, r12, r13, mof) \
+ LOAD_ARGS_asm_4 (r10, r11, r12, r13) "move %6,$mof\n\t"
+#define ASM_CLOBBER_5 ASM_CLOBBER_4
+#define ASM_ARGS_5(r10, r11, r12, r13, mof) \
+ ASM_ARGS_4 (r10, r11, r12, r13), "g" (mof)
+
+#define LOAD_ARGS_c_6(r10, r11, r12, r13, mof, srp) \
+ LOAD_ARGS_c_5(r10, r11, r12, r13, mof)
+#define LOAD_ARGS_asm_6(r10, r11, r12, r13, mof, srp) \
+ LOAD_ARGS_asm_5(r10, r11, r12, r13, mof) \
+ "move %7,$srp\n\t"
+#define ASM_CLOBBER_6 ASM_CLOBBER_5, "srp"
+#define ASM_ARGS_6(r10, r11, r12, r13, mof, srp) \
+ ASM_ARGS_5 (r10, r11, r12, r13, mof), "g" (srp)
+
+#endif /* not __ASSEMBLER__ */
diff --git a/ports/sysdeps/unix/sysv/linux/cris/vfork.S b/ports/sysdeps/unix/sysv/linux/cris/vfork.S
new file mode 100644
index 000000000..74a855676
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/vfork.S
@@ -0,0 +1,27 @@
+/* Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+PSEUDO (__vfork, vfork, 0)
+ Ret
+ nop
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/ports/sysdeps/unix/sysv/linux/cris/xstat.c b/ports/sysdeps/unix/sysv/linux/cris/xstat.c
new file mode 100644
index 000000000..e9869f550
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/cris/xstat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/xstat.c>
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/Makefile b/ports/sysdeps/unix/sysv/linux/hppa/Makefile
new file mode 100644
index 000000000..1c93ec52d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/Makefile
@@ -0,0 +1,2 @@
+# linux/hppa does not use -lmilli anymore
+gnulib := -lgcc
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/Versions b/ports/sysdeps/unix/sysv/linux/hppa/Versions
new file mode 100644
index 000000000..26eed69eb
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/Versions
@@ -0,0 +1,28 @@
+libc {
+ # The comment lines with "#errlist-compat" are magic; see errlist-compat.awk.
+ # When you get an error from errlist-compat.awk, you need to add a new
+ # version here. Don't do this blindly, since this means changing the ABI
+ # for all GNU/Linux configurations.
+
+ GLIBC_2.1 {
+ #errlist-compat 253
+ _sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
+ }
+ GLIBC_2.2 {
+ # New rlimit interface
+ getrlimit; setrlimit; getrlimit64; setrlimit64;
+ }
+ GLIBC_2.3 {
+ #errlist-compat 254
+ _sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
+ }
+ GLIBC_2.4 {
+ #errlist-compat 256
+ _sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
+}
+librt {
+ GLIBC_2.3 {
+ # AIO functions.
+ aio_cancel; aio_cancel64;
+ }
+}
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/bits/atomic.h b/ports/sysdeps/unix/sysv/linux/hppa/bits/atomic.h
new file mode 100644
index 000000000..36a540728
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/bits/atomic.h
@@ -0,0 +1,120 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Carlos O'Donell <carlos@baldric.uwo.ca>, 2005.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdint.h>
+#include <sysdep.h>
+#include <abort-instr.h>
+#include <kernel-features.h>
+
+/* We need EFAULT, ENONSYS, and EAGAIN */
+#if !defined EFAULT && !defined ENOSYS && !defined EAGAIN
+#undef EFAULT
+#undef ENOSYS
+#undef EAGAIN
+#define EFAULT 14
+#define ENOSYS 251
+#define EAGAIN 11
+#endif
+
+#ifndef _BITS_ATOMIC_H
+#define _BITS_ATOMIC_H 1
+
+typedef int8_t atomic8_t;
+typedef uint8_t uatomic8_t;
+typedef int_fast8_t atomic_fast8_t;
+typedef uint_fast8_t uatomic_fast8_t;
+
+typedef int32_t atomic32_t;
+typedef uint32_t uatomic32_t;
+typedef int_fast32_t atomic_fast32_t;
+typedef uint_fast32_t uatomic_fast32_t;
+
+typedef intptr_t atomicptr_t;
+typedef uintptr_t uatomicptr_t;
+typedef intmax_t atomic_max_t;
+typedef uintmax_t uatomic_max_t;
+
+/* prev = *addr;
+ if (prev == old)
+ *addr = new;
+ return prev; */
+
+/* Use the kernel atomic light weight syscalls on hppa */
+#define LWS "0xb0"
+#define LWS_CAS 0x0
+/* Note r31 is the link register */
+#define LWS_CLOBBER "r1", "r26", "r25", "r24", "r23", "r22", "r21", "r20", "r28", "r31", "memory"
+#define ASM_EAGAIN "11"
+
+#if __ASSUME_LWS_CAS
+/* The only basic operation needed is compare and exchange. */
+# define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
+ ({ \
+ volatile int lws_errno = EFAULT; \
+ volatile int lws_ret = 0xdeadbeef; \
+ asm volatile( \
+ "0: \n\t" \
+ "copy %3, %%r26 \n\t" \
+ "copy %4, %%r25 \n\t" \
+ "copy %5, %%r24 \n\t" \
+ "ble " LWS "(%%sr2, %%r0) \n\t" \
+ "ldi 0, %%r20 \n\t" \
+ "cmpib,=,n " ASM_EAGAIN ",%%r21,0 \n\t" \
+ "nop \n\t" \
+ "stw %%r28, %0 \n\t" \
+ "sub %%r0, %%r21, %%r21 \n\t" \
+ "stw %%r21, %1 \n\t" \
+ : "=m" (lws_ret), "=m" (lws_errno), "=m" (*mem) \
+ : "r" (mem), "r" (oldval), "r" (newval) \
+ : LWS_CLOBBER \
+ ); \
+ \
+ if(lws_errno == EFAULT || lws_errno == ENOSYS) \
+ ABORT_INSTRUCTION; \
+ \
+ lws_ret; \
+ })
+
+# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
+ ({ \
+ int ret; \
+ ret = atomic_compare_and_exchange_val_acq(mem, newval, oldval); \
+ /* Return 1 if it was already acquired */ \
+ (ret != oldval); \
+ })
+#else
+/* Non-atomic primitives. */
+# define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
+ ({ __typeof (mem) __gmemp = (mem); \
+ __typeof (*mem) __gret = *__gmemp; \
+ __typeof (*mem) __gnewval = (newval); \
+ \
+ if (__gret == (oldval)) \
+ *__gmemp = __gnewval; \
+ __gret; })
+
+# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
+ ({ __typeof (mem) __gmemp = (mem); \
+ __typeof (*mem) __gnewval = (newval); \
+ \
+ *__gmemp == (oldval) ? (*__gmemp = __gnewval, 0) : 1; })
+#endif
+
+#endif /* bits/atomic.h */
+
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/bits/errno.h b/ports/sysdeps/unix/sysv/linux/hppa/bits/errno.h
new file mode 100644
index 000000000..003d71f62
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/bits/errno.h
@@ -0,0 +1,51 @@
+/* Error constants. Linux/HPPA specific version.
+ Copyright (C) 1996,1997,1998,1999,2000,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifdef _ERRNO_H
+
+# undef EDOM
+# undef EILSEQ
+# undef ERANGE
+# include <linux/errno.h>
+
+/* Linux also has no ECANCELED error code. Since it is not used here
+ we define it to an invalid value. */
+# ifndef ECANCELED
+# define ECANCELED ECANCELLED
+# endif
+
+# ifndef __ASSEMBLER__
+/* Function to get address of global `errno' variable. */
+extern int *__errno_location (void) __THROW __attribute__ ((__const__));
+
+# if !defined _LIBC || defined _LIBC_REENTRANT
+/* When using threads, errno is a per-thread value. */
+# define errno (*__errno_location ())
+# endif
+# endif /* !__ASSEMBLER__ */
+#endif /* _ERRNO_H */
+
+#if !defined _ERRNO_H && defined __need_Emath
+/* This is ugly but the kernel header is not clean enough. We must
+ define only the values EDOM, EILSEQ and ERANGE in case __need_Emath is
+ defined. */
+# define EDOM 33 /* Math argument out of domain of function. */
+# define EILSEQ 47 /* Illegal byte sequence. */
+# define ERANGE 34 /* Math result not representable. */
+#endif /* !_ERRNO_H && __need_Emath */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/bits/fcntl.h b/ports/sysdeps/unix/sysv/linux/hppa/bits/fcntl.h
new file mode 100644
index 000000000..fc7075841
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/bits/fcntl.h
@@ -0,0 +1,222 @@
+/* O_*, F_*, FD_* bit values for Linux/HPPA.
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2002,2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+#include <sys/types.h>
+#ifdef __USE_GNU
+# include <bits/uio.h>
+#endif
+
+/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
+ located on an ext2 file system */
+#define O_RDONLY 00000000
+#define O_WRONLY 00000001
+#define O_RDWR 00000002
+#define O_ACCMODE 00000003
+#define O_APPEND 00000010
+#define O_BLKSEEK 00000100 /* HPUX only */
+#define O_CREAT 00000400 /* not fcntl */
+#define O_TRUNC 00001000 /* not fcntl */
+#define O_EXCL 00002000 /* not fcntl */
+#define O_ASYNC 00020000
+#define O_SYNC 00100000
+#define O_NONBLOCK 00200004 /* HPUX has separate NDELAY & NONBLOCK */
+#define O_NDELAY O_NONBLOCK
+#define O_NOCTTY 00400000 /* not fcntl */
+
+
+#ifdef __USE_GNU
+# define O_DIRECT 00040000 /* Direct disk access. */
+# define O_DIRECTORY 00010000 /* Must be a directory. */
+# define O_NOFOLLOW 00000200 /* Do not follow links. */
+# define O_NOATIME 04000000 /* Do not set atime. */
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define O_LARGEFILE 00004000
+#endif
+
+#if defined __USE_POSIX199309 || defined __USE_UNIX98
+# define O_DSYNC 01000000 /* HPUX only */
+# define O_RSYNC 02000000 /* HPUX only */
+#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. */
+#ifndef __USE_FILE_OFFSET64
+# define F_GETLK 5 /* Get record locking info. */
+# define F_SETLK 6 /* Set record locking info (non-blocking). */
+# define F_SETLKW 7 /* Set record locking info (blocking). */
+#else
+# define F_GETLK F_GETLK64 /* Get record locking info. */
+# define F_SETLK F_SETLK64 /* Set record locking info (non-blocking). */
+# define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
+#endif
+#define F_GETLK64 8 /* Get record locking info. */
+#define F_SETLK64 9 /* Set record locking info (non-blocking). */
+#define F_SETLKW64 10 /* Set record locking info (blocking). */
+
+#if defined __USE_BSD || defined __USE_UNIX98
+# define F_GETOWN 11 /* Get owner of socket (receiver of SIGIO). */
+# define F_SETOWN 12 /* Set owner of socket (receiver of SIGIO). */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETSIG 13 /* Set number of signal to be sent. */
+# define F_GETSIG 14 /* Get number of signal to be sent. */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETLEASE 1024 /* Set a lease. */
+# define F_GETLEASE 1025 /* Enquire what lease is active. */
+# define F_NOTIFY 1026 /* Request notfications on a directory. */
+#endif
+
+/* for F_[GET|SET]FL */
+#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
+
+/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
+#define F_RDLCK 1 /* Read lock. */
+#define F_WRLCK 2 /* Write lock. */
+#define F_UNLCK 3 /* Remove lock. */
+
+/* for old implementation of bsd flock () */
+#define F_EXLCK 4 /* or 3 */
+#define F_SHLCK 8 /* or 4 */
+
+#ifdef __USE_BSD
+/* operations for bsd flock(), also used by the kernel implementation */
+# define LOCK_SH 1 /* shared lock */
+# define LOCK_EX 2 /* exclusive lock */
+# define LOCK_NB 4 /* or'd with one of the above to prevent
+ blocking */
+# define LOCK_UN 8 /* remove lock */
+#endif
+
+#ifdef __USE_GNU
+/* Types of directory notifications that may be requested with F_NOTIFY. */
+# define DN_ACCESS 0x00000001 /* File accessed. */
+# define DN_MODIFY 0x00000002 /* File modified. */
+# define DN_CREATE 0x00000004 /* File created. */
+# define DN_DELETE 0x00000008 /* File removed. */
+# define DN_RENAME 0x00000010 /* File renamed. */
+# define DN_ATTRIB 0x00000020 /* File changed attibutes. */
+# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
+#endif
+
+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'). */
+#ifndef __USE_FILE_OFFSET64
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+#else
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+#endif
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+
+#ifdef __USE_LARGEFILE64
+struct flock64
+ {
+ 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'). */
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+#endif
+
+/* Define some more compatibility macros to be backward compatible with
+ BSD systems which did not managed to hide these kernel macros. */
+#ifdef __USE_BSD
+# define FAPPEND O_APPEND
+# define FFSYNC O_FSYNC
+# define FASYNC O_ASYNC
+# define FNONBLOCK O_NONBLOCK
+# define FNDELAY O_NDELAY
+#endif /* Use BSD. */
+
+/* Advise to `posix_fadvise'. */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
+# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
+# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
+# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
+# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
+#endif
+
+#ifdef __USE_GNU
+# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
+ in the range before performing the
+ write. */
+# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those
+ dirty pages in the range which are
+ not presently under writeback. */
+# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
+ the range after performing the
+ write. */
+
+/* Flags for SPLICE and VMSPLICE. */
+# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
+# define SPLICE_F_NONBLOCK 2 /* Don't block on the pipe splicing
+ (but we may still block on the fd
+ we splice from/to). */
+# define SPLICE_F_MORE 4 /* Expect more data. */
+# define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */
+#endif
+
+__BEGIN_DECLS
+
+#ifdef __USE_GNU
+
+/* Provide kernel hint to read ahead. */
+extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
+ __THROW;
+
+/* Selective file content synch'ing. */
+extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
+ unsigned int __flags);
+
+/* Splice address range into a pipe. */
+extern int vmsplice (int __fdout, const struct iovec *__iov, size_t __count,
+ unsigned int __flags);
+
+/* Splice two files together. */
+extern int splice (int __fdin, int __fdout, size_t __len, unsigned int __flags)
+ __THROW;
+
+/* In-kernel implementation of tee for pipe buffers. */
+extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags)
+ __THROW;
+
+#endif
+
+__END_DECLS
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/bits/ioctls.h b/ports/sysdeps/unix/sysv/linux/hppa/bits/ioctls.h
new file mode 100644
index 000000000..6f4e05fcc
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/bits/ioctls.h
@@ -0,0 +1,37 @@
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_IOCTL_H
+# error "Never use <bits/ioctls.h> directly; include <sys/ioctl.h> instead."
+#endif
+
+/* Use the definitions from the kernel header files. */
+#include <asm/ioctls.h>
+
+/* Oh well, this is necessary since the kernel data structure is
+ different from the user-level version. */
+#undef TCGETS
+#undef TCSETS
+#undef TCSETSW
+#undef TCSETSF
+#define TCGETS _IOR ('T', 16, char[36])
+#define TCSETS _IOW ('T', 17, char[36])
+#define TCSETSW _IOW ('T', 18, char[36])
+#define TCSETSF _IOW ('T', 19, char[36])
+
+#include <linux/sockios.h>
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/bits/ipc.h b/ports/sysdeps/unix/sysv/linux/hppa/bits/ipc.h
new file mode 100644
index 000000000..d80cf0699
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/bits/ipc.h
@@ -0,0 +1,63 @@
+/* Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_IPC_H
+# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
+#endif
+
+#include <bits/types.h>
+#include <bits/wordsize.h>
+
+/* Mode bits for `msgget', `semget', and `shmget'. */
+#define IPC_CREAT 01000 /* Create key if key does not exist. */
+#define IPC_EXCL 02000 /* Fail if key exists. */
+#define IPC_NOWAIT 04000 /* Return error on wait. */
+
+/* Control commands for `msgctl', `semctl', and `shmctl'. */
+#define IPC_RMID 0 /* Remove identifier. */
+#define IPC_SET 1 /* Set `ipc_perm' options. */
+#define IPC_STAT 2 /* Get `ipc_perm' options. */
+#ifdef __USE_GNU
+# define IPC_INFO 3 /* See ipcs. */
+#endif
+
+/* Special key values. */
+#define IPC_PRIVATE ((__key_t) 0) /* Private key. */
+
+
+/* Data structure used to pass permission information to IPC operations. */
+struct ipc_perm
+ {
+ __key_t __key; /* Key. */
+ __uid_t uid; /* Owner's user ID. */
+ __gid_t gid; /* Owner's group ID. */
+ __uid_t cuid; /* Creator's user ID. */
+ __gid_t cgid; /* Creator's group ID. */
+#if __WORDSIZE == 32
+ unsigned short int __pad1;
+ unsigned short int mode; /* Read/write permission. */
+ unsigned short int __pad2;
+#else
+ __mode_t mode; /* Read/write permission. */
+ unsigned short int __pad2;
+#endif
+ unsigned short int __seq; /* Sequence number. */
+ unsigned int __pad3;
+ unsigned long long int __unused1;
+ unsigned long long int __unused2;
+ };
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/bits/mman.h b/ports/sysdeps/unix/sysv/linux/hppa/bits/mman.h
new file mode 100644
index 000000000..54531ecf2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/bits/mman.h
@@ -0,0 +1,92 @@
+/* Definitions for POSIX memory map interface. Linux/HPPA version.
+ Copyright (C) 1997, 1998, 2000, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_MMAN_H
+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
+#endif
+
+/* these are basically taken from the kernel definitions */
+
+#define PROT_READ 0x1 /* page can be read */
+#define PROT_WRITE 0x2 /* page can be written */
+#define PROT_EXEC 0x4 /* page can be executed */
+#define PROT_NONE 0x0 /* page can not be accessed */
+#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
+ growsdown vma (mprotect only). */
+#define PROT_GROWSUP 0x02000000 /* Extend change to start of
+ growsup vma (mprotect only). */
+
+#define MAP_SHARED 0x01 /* Share changes */
+#define MAP_PRIVATE 0x02 /* Changes are private */
+#define MAP_TYPE 0x03 /* Mask for type of mapping */
+#define MAP_FIXED 0x04 /* Interpret addr exactly */
+#define MAP_ANONYMOUS 0x10 /* don't use a file */
+
+#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
+#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
+#define MAP_LOCKED 0x2000 /* pages are locked */
+#define MAP_NORESERVE 0x4000 /* don't check for reservations */
+#define MAP_GROWSDOWN 0x8000 /* stack-like segment */
+#define MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
+#define MAP_NONBLOCK 0x20000 /* do not block on IO */
+
+#define MS_SYNC 1 /* synchronous memory sync */
+#define MS_ASYNC 2 /* sync memory asynchronously */
+#define MS_INVALIDATE 4 /* invalidate the caches */
+
+#define MCL_CURRENT 1 /* lock all current mappings */
+#define MCL_FUTURE 2 /* lock all future mappings */
+
+/* Advice to "madvise" */
+#ifdef __USE_BSD
+# 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 /* dont need these pages */
+# define MADV_SPACEAVAIL 5 /* insure that resources are reserved */
+# define MADV_VPS_PURGE 6 /* Purge pages from VM page cache */
+# define MADV_VPS_INHERIT 7 /* Inherit parents page size */
+# define MADV_REMOVE 9 /* Remove these pages and resources. */
+# define MADV_DONTFORK 10 /* Do not inherit across fork. */
+# define MADV_DOFORK 11 /* Do inherit across fork. */
+#endif
+
+/* The range 12-64 is reserved for page size specification. */
+#define MADV_4K_PAGES 12 /* Use 4K pages */
+#define MADV_16K_PAGES 14 /* Use 16K pages */
+#define MADV_64K_PAGES 16 /* Use 64K pages */
+#define MADV_256K_PAGES 18 /* Use 256K pages */
+#define MADV_1M_PAGES 20 /* Use 1 Megabyte pages */
+#define MADV_4M_PAGES 22 /* Use 4 Megabyte pages */
+#define MADV_16M_PAGES 24 /* Use 16 Megabyte pages */
+#define MADV_64M_PAGES 26 /* Use 64 Megabyte pages */
+
+/* compatibility flags */
+#define MAP_ANON MAP_ANONYMOUS
+#define MAP_FILE 0
+#define MAP_VARIABLE 0
+
+/* Flags for `mremap'. */
+#ifdef __USE_GNU
+# define MREMAP_MAYMOVE 1
+# define MREMAP_FIXED 2
+#endif
+
+
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/bits/msq.h b/ports/sysdeps/unix/sysv/linux/hppa/bits/msq.h
new file mode 100644
index 000000000..1268dc858
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/bits/msq.h
@@ -0,0 +1,84 @@
+/* Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_MSG_H
+# error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
+#endif
+
+#include <bits/types.h>
+#include <bits/wordsize.h>
+
+/* Define options for message queue functions. */
+#define MSG_NOERROR 010000 /* no error if message is too big */
+#ifdef __USE_GNU
+# define MSG_EXCEPT 020000 /* recv any msg except of specified type */
+#endif
+
+/* Types used in the structure definition. */
+typedef unsigned long int msgqnum_t;
+typedef unsigned long int msglen_t;
+
+
+/* Structure of record for one message inside the kernel.
+ The type `struct msg' is opaque. */
+struct msqid_ds
+{
+ struct ipc_perm msg_perm; /* structure describing operation permission */
+#if __WORDSIZE == 32
+ unsigned int __pad1;
+#endif
+ __time_t msg_stime; /* time of last msgsnd command */
+#if __WORDSIZE == 32
+ unsigned int __pad2;
+#endif
+ __time_t msg_rtime; /* time of last msgrcv command */
+#if __WORDSIZE == 32
+ unsigned int __pad3;
+#endif
+ __time_t msg_ctime; /* time of last change */
+ unsigned long int __msg_cbytes; /* current number of bytes on queue */
+ msgqnum_t msg_qnum; /* number of messages currently on queue */
+ msglen_t msg_qbytes; /* max number of bytes allowed on queue */
+ __pid_t msg_lspid; /* pid of last msgsnd() */
+ __pid_t msg_lrpid; /* pid of last msgrcv() */
+ unsigned long int __unused1;
+ unsigned long int __unused2;
+};
+
+#ifdef __USE_MISC
+
+# define msg_cbytes __msg_cbytes
+
+/* ipcs ctl commands */
+# define MSG_STAT 11
+# define MSG_INFO 12
+
+/* buffer for msgctl calls IPC_INFO, MSG_INFO */
+struct msginfo
+ {
+ int msgpool;
+ int msgmap;
+ int msgmax;
+ int msgmnb;
+ int msgmni;
+ int msgssz;
+ int msgtql;
+ unsigned short int msgseg;
+ };
+
+#endif /* __USE_MISC */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/bits/sem.h b/ports/sysdeps/unix/sysv/linux/hppa/bits/sem.h
new file mode 100644
index 000000000..288076510
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/bits/sem.h
@@ -0,0 +1,92 @@
+/* Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_SEM_H
+# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
+#endif
+
+#include <sys/types.h>
+#include <bits/wordsize.h>
+
+/* Flags for `semop'. */
+#define SEM_UNDO 0x1000 /* undo the operation on exit */
+
+/* Commands for `semctl'. */
+#define GETPID 11 /* get sempid */
+#define GETVAL 12 /* get semval */
+#define GETALL 13 /* get all semval's */
+#define GETNCNT 14 /* get semncnt */
+#define GETZCNT 15 /* get semzcnt */
+#define SETVAL 16 /* set semval */
+#define SETALL 17 /* set all semval's */
+
+
+/* Data structure describing a set of semaphores. */
+struct semid_ds
+{
+ struct ipc_perm sem_perm; /* operation permission struct */
+#if __WORDSIZE == 32
+ unsigned int __pad1;
+#endif
+ __time_t sem_otime; /* last semop() time */
+#if __WORDSIZE == 32
+ unsigned int __pad2;
+#endif
+ __time_t sem_ctime; /* last time changed by semctl() */
+ unsigned long int sem_nsems; /* number of semaphores in set */
+ unsigned long int __unused1;
+ unsigned long int __unused2;
+};
+
+/* The user should define a union like the following to use it for arguments
+ for `semctl'.
+
+ union semun
+ {
+ int val; <= value for SETVAL
+ struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET
+ unsigned short int *array; <= array for GETALL & SETALL
+ struct seminfo *__buf; <= buffer for IPC_INFO
+ };
+
+ Previous versions of this file used to define this union but this is
+ incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether
+ one must define the union or not. */
+#define _SEM_SEMUN_UNDEFINED 1
+
+#ifdef __USE_MISC
+
+/* ipcs ctl cmds */
+# define SEM_STAT 18
+# define SEM_INFO 19
+
+struct seminfo
+{
+ int semmap;
+ int semmni;
+ int semmns;
+ int semmnu;
+ int semmsl;
+ int semopm;
+ int semume;
+ int semusz;
+ int semvmx;
+ int semaem;
+};
+
+#endif /* __USE_MISC */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/bits/shm.h b/ports/sysdeps/unix/sysv/linux/hppa/bits/shm.h
new file mode 100644
index 000000000..a91f1f575
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/bits/shm.h
@@ -0,0 +1,107 @@
+/* Copyright (C) 1995, 1996, 1997, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_SHM_H
+# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
+#endif
+
+#include <bits/types.h>
+#include <bits/wordsize.h>
+
+/* Permission flag for shmget. */
+#define SHM_R 0400 /* or S_IRUGO from <linux/stat.h> */
+#define SHM_W 0200 /* or S_IWUGO from <linux/stat.h> */
+
+/* Flags for `shmat'. */
+#define SHM_RDONLY 010000 /* attach read-only else read-write */
+#define SHM_RND 020000 /* round attach address to SHMLBA */
+#define SHM_REMAP 040000 /* take-over region on attach */
+
+/* Commands for `shmctl'. */
+#define SHM_LOCK 11 /* lock segment (root only) */
+#define SHM_UNLOCK 12 /* unlock segment (root only) */
+
+/* Segment low boundary address multiple. */
+#define SHMLBA 0x00400000 /* address needs to be 4 Mb aligned */
+
+/* Type to count number of attaches. */
+typedef unsigned long int shmatt_t;
+
+/* Data structure describing a set of semaphores. */
+struct shmid_ds
+ {
+ struct ipc_perm shm_perm; /* operation permission struct */
+#if __WORDSIZE == 32
+ unsigned int __pad1;
+#endif
+ __time_t shm_atime; /* time of last shmat() */
+#if __WORDSIZE == 32
+ unsigned int __pad2;
+#endif
+ __time_t shm_dtime; /* time of last shmdt() */
+#if __WORDSIZE == 32
+ unsigned int __pad3;
+#endif
+ __time_t shm_ctime; /* time of last change by shmctl() */
+#if __WORDSIZE == 32
+ unsigned int __pad4;
+#endif
+ size_t shm_segsz; /* size of segment in bytes */
+ __pid_t shm_cpid; /* pid of creator */
+ __pid_t shm_lpid; /* pid of last shmop */
+ shmatt_t shm_nattch; /* number of current attaches */
+ unsigned long int __unused1;
+ unsigned long int __unused2;
+ };
+
+#ifdef __USE_MISC
+
+/* ipcs ctl commands */
+# define SHM_STAT 13
+# define SHM_INFO 14
+
+/* shm_mode upper byte flags */
+# define SHM_DEST 01000 /* segment will be destroyed on last detach */
+# define SHM_LOCKED 02000 /* segment will not be swapped */
+# define SHM_HUGETLB 04000 /* segment is mapped via hugetlb */
+# define SHM_NORESERVE 010000 /* don't check for reservations */
+
+struct shminfo
+ {
+ unsigned long shmmax;
+ unsigned long shmmin;
+ unsigned long shmmni;
+ unsigned long shmseg;
+ unsigned long shmall;
+ unsigned long __unused1;
+ unsigned long __unused2;
+ unsigned long __unused3;
+ unsigned long __unused4;
+ };
+
+struct shm_info
+ {
+ int used_ids;
+ unsigned long int shm_tot; /* total allocated shm */
+ unsigned long int shm_rss; /* total resident shm */
+ unsigned long int shm_swp; /* total swapped shm */
+ unsigned long int swap_attempts;
+ unsigned long int swap_successes;
+ };
+
+#endif /* __USE_MISC */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/bits/sigaction.h b/ports/sysdeps/unix/sysv/linux/hppa/bits/sigaction.h
new file mode 100644
index 000000000..33f2b237b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/bits/sigaction.h
@@ -0,0 +1,75 @@
+/* Definitions for Linux/HPPA sigaction.
+ Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SIGNAL_H
+# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
+#endif
+
+/* Structure describing the action to be taken when a signal arrives. */
+struct sigaction
+ {
+ /* Signal handler. */
+#ifdef __USE_POSIX199309
+ union
+ {
+ /* Used if SA_SIGINFO is not set. */
+ __sighandler_t sa_handler;
+ /* Used if SA_SIGINFO is set. */
+ void (*sa_sigaction) (int, siginfo_t *, void *);
+ }
+ __sigaction_handler;
+# define sa_handler __sigaction_handler.sa_handler
+# define sa_sigaction __sigaction_handler.sa_sigaction
+#else
+ __sighandler_t sa_handler;
+#endif
+
+ /* Special flags. */
+ unsigned long int sa_flags;
+
+ /* Additional set of signals to be blocked. */
+ __sigset_t sa_mask;
+ };
+
+/* Bits in `sa_flags'. */
+
+#define SA_NOCLDSTOP 0x00000008 /* Don't send SIGCHLD when children stop. */
+#define SA_NOCLDWAIT 0x00000080 /* Don't create zombie on child death. */
+#define SA_SIGINFO 0x00000010 /* Invoke signal-catching function with
+ three arguments instead of one. */
+#if defined __USE_UNIX98 || defined __USE_MISC
+# define SA_ONSTACK 0x00000001 /* Use signal stack by using `sa_restorer'. */
+# define SA_RESETHAND 0x00000004 /* Reset to SIG_DFL on entry to handler. */
+# define SA_NODEFER 0x00000020 /* Don't automatically block the signal
+ when its handler is being executed. */
+# define SA_RESTART 0x00000040 /* Restart syscall on signal return. */
+#endif
+#ifdef __USE_MISC
+# define SA_INTERRUPT 0x20000000 /* Historic no-op. */
+
+/* Some aliases for the SA_ constants. */
+# define SA_NOMASK SA_NODEFER
+# define SA_ONESHOT SA_RESETHAND
+# define SA_STACK SA_ONSTACK
+#endif
+
+/* Values for the HOW argument to `sigprocmask'. */
+#define SIG_BLOCK 0 /* for blocking signals */
+#define SIG_UNBLOCK 1 /* for unblocking signals */
+#define SIG_SETMASK 2 /* for setting the signal mask */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/bits/signum.h b/ports/sysdeps/unix/sysv/linux/hppa/bits/signum.h
new file mode 100644
index 000000000..bf46006c8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/bits/signum.h
@@ -0,0 +1,82 @@
+/* Signal number definitions. Linux/HPPA version.
+ Copyright (C) 1995,1996,1997,1998,1999,2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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. */
+
+#ifdef __USE_UNIX98
+# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */
+#endif
+
+
+/* Signals. */
+#define SIGHUP 1 /* Hangup (POSIX). */
+#define SIGINT 2 /* Interrupt (ANSI). */
+#define SIGQUIT 3 /* Quit (POSIX). */
+#define SIGILL 4 /* Illegal instruction (ANSI). */
+#define SIGTRAP 5 /* Trace trap (POSIX). */
+#define SIGABRT 6 /* Abort (ANSI). */
+#define SIGIOT 6 /* IOT trap (4.2 BSD). */
+#define SIGEMT 7
+#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 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 SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */
+#define SIGCHLD 18 /* Child status has changed (POSIX). */
+#define SIGPWR 19 /* Power failure restart (System V). */
+#define SIGVTALRM 20 /* Virtual alarm clock (4.2 BSD). */
+#define SIGPROF 21 /* Profiling alarm clock (4.2 BSD). */
+#define SIGPOLL SIGIO /* Pollable event occurred (System V). */
+#define SIGIO 22 /* I/O now possible (4.2 BSD). */
+#define SIGWINCH 23 /* Window size change (4.3 BSD, Sun). */
+#define SIGSTOP 24 /* Stop, unblockable (POSIX). */
+#define SIGTSTP 25 /* Keyboard stop (POSIX). */
+#define SIGCONT 26 /* Continue (POSIX). */
+#define SIGTTIN 27 /* Background read from tty (POSIX). */
+#define SIGTTOU 28 /* Background write to tty (POSIX). */
+#define SIGURG 29 /* Urgent condition on socket (4.2 BSD). */
+#define SIGLOST 30 /* Operating System Has Lost (HP/UX). */
+#define SIGUNUSED 31
+#define SIGXCPU 33 /* CPU limit exceeded (4.2 BSD). */
+#define SIGXFSZ 34 /* File size limit exceeded (4.2 BSD). */
+#define SIGSTKFLT 36 /* Stack fault. */
+
+#define _NSIG 65 /* Biggest signal number + 1
+ (including real-time signals). */
+
+#define SIGRTMIN (__libc_current_sigrtmin ())
+#define SIGRTMAX (__libc_current_sigrtmax ())
+
+/* These are the hard limits of the kernel. These values should not be
+ used directly at user level. */
+#define __SIGRTMIN 37
+#define __SIGRTMAX (_NSIG - 1)
+
+#endif /* <signal.h> included. */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/brk.c b/ports/sysdeps/unix/sysv/linux/hppa/brk.c
new file mode 100644
index 000000000..a4b4df283
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/brk.c
@@ -0,0 +1,42 @@
+/* brk system call for Linux/HPPA.
+ Copyright (C) 1995, 1996, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sysdep.h>
+
+/* This must be initialized data because commons can't have aliases. */
+void *__curbrk = 0;
+
+int
+__brk (void *addr)
+{
+ void *newbrk;
+
+ __curbrk = newbrk = (void *) INLINE_SYSCALL (brk, 1, addr);
+
+ if (newbrk < addr)
+ {
+ __set_errno (ENOMEM);
+ return -1;
+ }
+
+ return 0;
+}
+weak_alias (__brk, brk)
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/clone.S b/ports/sysdeps/unix/sysv/linux/hppa/clone.S
new file mode 100644
index 000000000..1884518a3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/clone.S
@@ -0,0 +1,133 @@
+/* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000.
+ Based on the Alpha version by Richard Henderson <rth@tamu.edu>, 1996.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* clone() is even more special than fork() as it mucks with stacks
+ and invokes a function in the right context after its all over. */
+
+#include <asm/unistd.h>
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+
+/* Non-thread code calls __clone with the following parameters:
+ int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg)
+
+ NPTL Code will call __clone with the following parameters:
+ int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+ int *parent_tidptr, struct user_desc *newtls, int *child_pidptr)
+
+ The code should not mangle the extra input registers.
+ Syscall expects: Input to __clone:
+ 4(r25) - function pointer (r26, arg0)
+ 0(r25) - argument (r23, arg3)
+ r26 - clone flags. (r24, arg2)
+ r25+64 - user stack pointer. (r25, arg1)
+ r24 - parent tid pointer. (stack - 52)
+ r23 - struct user_desc newtls pointer. (stack - 56)
+ r22 - child tid pointer. (stack - 60)
+ r20 - clone syscall number (constant)
+ */
+
+ .text
+ENTRY(__clone)
+
+ /* Sanity check arguments. */
+ ldi -EINVAL,%ret0
+ comib,=,n 0,%arg0,.Lerror /* no NULL function pointers */
+ comib,=,n 0,%arg1,.Lerror /* no NULL stack pointers */
+
+ /* Save the fn ptr and arg on the new stack. */
+ stwm %r26,64(%r25)
+ stw %r23,-60(%r25)
+ /* Clone arguments are (int flags, void * child_stack) */
+ copy %r24,%r26 /* flags are first */
+ /* User stack pointer is in the correct register already */
+
+ /* Load args from stack... */
+ ldw -52(%sp), %r24 /* Load parent_tidptr */
+ ldw -56(%sp), %r23 /* Load newtls */
+ ldw -60(%sp), %r22 /* Load child_tidptr */
+
+ /* Create frame to get r3 free */
+ copy %sp, %r21
+ stwm %r3, 64(%sp)
+ stw %r21, -4(%sp)
+
+ /* Save the PIC register. */
+#ifdef PIC
+ copy %r19, %r3 /* parent */
+#endif
+
+ /* Do the system call */
+ ble 0x100(%sr2,%r0)
+ ldi __NR_clone,%r20
+
+ ldi -4096,%r1
+ comclr,>>= %r1,%ret0,%r0 /* Note: unsigned compare. */
+ b,n .LerrorRest
+
+ comib,=,n 0,%ret0,thread_start
+
+ /* Successful return from the parent
+ No need to restore the PIC register,
+ since we return immediately. */
+
+ bv %r0(%rp)
+ ldwm -64(%sp), %r3
+
+.LerrorRest:
+ /* Restore the PIC register on error */
+#ifdef PIC
+ copy %r3, %r19 /* parent */
+#endif
+
+ /* Something bad happened -- no child created */
+.Lerror:
+
+ /* Set errno, save ret0 so we return with that value. */
+ copy %ret0, %r3
+ b __syscall_error
+ sub %r0,%ret0,%arg0
+ copy %r3, %ret0
+ /* Return after setting errno, and restoring ret0 */
+ bv %r0(%rp)
+ ldwm -64(%sp), %r3
+
+thread_start:
+
+ /* Load up the arguments. */
+ ldw -60(%sr0, %sp),%arg0
+ ldw -64(%sr0, %sp),%r22
+
+ /* $$dyncall fixes childs PIC register */
+
+ /* Call the user's function */
+ bl $$dyncall,%r31
+ copy %r31,%rp
+
+ bl _exit,%rp
+ copy %ret0,%arg0
+
+ /* Die horribly. */
+ iitlbp %r0,(%sr0,%r0)
+
+PSEUDO_END(__clone)
+
+weak_alias (__clone, clone)
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/fcntl.c b/ports/sysdeps/unix/sysv/linux/hppa/fcntl.c
new file mode 100644
index 000000000..ea951bc4f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/fcntl.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/fxstat.c b/ports/sysdeps/unix/sysv/linux/hppa/fxstat.c
new file mode 100644
index 000000000..4f219f0b9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/fxstat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/fxstatat.c b/ports/sysdeps/unix/sysv/linux/hppa/fxstatat.c
new file mode 100644
index 000000000..0f8b3135d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/fxstatat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/getdents64.c b/ports/sysdeps/unix/sysv/linux/hppa/getdents64.c
new file mode 100644
index 000000000..0c75fb5a0
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/getdents64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getdents64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/getrlimit64.c b/ports/sysdeps/unix/sysv/linux/hppa/getrlimit64.c
new file mode 100644
index 000000000..fef018f47
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/getrlimit64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/kernel-features.h b/ports/sysdeps/unix/sysv/linux/hppa/kernel-features.h
new file mode 100644
index 000000000..e29f6e0c2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/kernel-features.h
@@ -0,0 +1,39 @@
+/* Set flags signalling availability of kernel features based on given
+ kernel version number.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+/* There are an infinite number of PA-RISC kernel versions numbered
+ 2.4.0. But they've not really been released as such. We require
+ and expect the final version here. */
+#define __ASSUME_32BITUIDS 1
+#define __ASSUME_TRUNCATE64_SYSCALL 1
+#define __ASSUME_MMAP2_SYSCALL 1
+#define __ASSUME_STAT64_SYSCALL 1
+#define __ASSUME_IPC64 1
+#define __ASSUME_ST_INO_64_BIT 1
+#define __ASSUME_FCNTL64 1
+#define __ASSUME_GETDENTS64_SYSCALL 1
+
+/* PA-RISC 2.6.9 kernels had the first LWS CAS support */
+#if __LINUX_KERNEL_VERSION >= 0x020609
+# define __ASSUME_LWS_CAS 1
+#endif
+
+#include_next <kernel-features.h>
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/kernel_sigaction.h b/ports/sysdeps/unix/sysv/linux/hppa/kernel_sigaction.h
new file mode 100644
index 000000000..af048cbe7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/kernel_sigaction.h
@@ -0,0 +1,18 @@
+/* We have a separate header file here because we do not support
+ SA_RESTORER on hppa. */
+
+/* This is the sigaction struction from the Linux 2.1.20 kernel. */
+/* Blah. This is bogus. We don't ever use it. */
+struct old_kernel_sigaction {
+ __sighandler_t k_sa_handler;
+ unsigned long sa_mask;
+ unsigned long sa_flags;
+};
+
+/* This is the sigaction structure from the Linux 2.1.68 kernel. */
+
+struct kernel_sigaction {
+ __sighandler_t k_sa_handler;
+ unsigned long sa_flags;
+ sigset_t sa_mask;
+};
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/kernel_stat.h b/ports/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
new file mode 100644
index 000000000..a85c5be46
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
@@ -0,0 +1,31 @@
+/* definition of "struct stat" from the kernel */
+struct kernel_stat {
+ unsigned long st_dev; /* dev_t is 32 bits on parisc */
+ unsigned long st_ino; /* 32 bits */
+ unsigned short st_mode; /* 16 bits */
+ unsigned short st_nlink; /* 16 bits */
+ unsigned short st_reserved1; /* old st_uid */
+ unsigned short st_reserved2; /* old st_gid */
+ unsigned long st_rdev;
+ unsigned long st_size;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ long st_blksize;
+ long st_blocks;
+ unsigned long __unused1; /* ACL stuff */
+ unsigned long __unused2; /* network */
+ unsigned long __unused3; /* network */
+ unsigned long __unused4; /* cnodes */
+ unsigned short __unused5; /* netsite */
+ short st_fstype;
+ unsigned long st_realdev;
+ unsigned short st_basemode;
+ unsigned short st_spareshort;
+ unsigned long st_uid;
+ unsigned long st_gid;
+ unsigned long st_spare4[3];
+};
+
+#define _HAVE_STAT_NSEC
+#define _HAVE_STAT64_NSEC
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/aio_cancel.c b/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/aio_cancel.c
new file mode 100644
index 000000000..0d6da8291
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/aio_cancel.c
@@ -0,0 +1,33 @@
+#include <shlib-compat.h>
+
+#define aio_cancel64 XXX
+#include <aio.h>
+#undef aio_cancel64
+#include <errno.h>
+
+extern __typeof (aio_cancel) __new_aio_cancel;
+extern __typeof (aio_cancel) __old_aio_cancel;
+
+#define aio_cancel __new_aio_cancel
+
+#include <sysdeps/pthread/aio_cancel.c>
+
+#undef aio_cancel
+strong_alias (__new_aio_cancel, __new_aio_cancel64);
+versioned_symbol (librt, __new_aio_cancel, aio_cancel, GLIBC_2_3);
+versioned_symbol (librt, __new_aio_cancel64, aio_cancel64, GLIBC_2_3);
+
+#if SHLIB_COMPAT (librt, GLIBC_2_1, GLIBC_2_3)
+
+#undef ECANCELED
+#define aio_cancel __old_aio_cancel
+#define ECANCELED 125
+
+#include <sysdeps/pthread/aio_cancel.c>
+
+#undef aio_cancel
+strong_alias (__old_aio_cancel, __old_aio_cancel64);
+compat_symbol (librt, __old_aio_cancel, aio_cancel, GLIBC_2_1);
+compat_symbol (librt, __old_aio_cancel64, aio_cancel64, GLIBC_2_1);
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/bits/initspin.h b/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/bits/initspin.h
new file mode 100644
index 000000000..ff0ec200f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/bits/initspin.h
@@ -0,0 +1,41 @@
+/* PA-RISC specific definitions for spinlock initializers.
+ Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* Initial value of a spinlock. PA-RISC only implements atomic load
+ and clear so this must be non-zero. */
+#define __LT_SPINLOCK_INIT ((__atomic_lock_t) { { 1, 1, 1, 1 } })
+
+/* Initialize global spinlocks without cast, generally macro wrapped */
+#define __LT_SPINLOCK_ALT_INIT { { 1, 1, 1, 1 } }
+
+/* Macros for lock initializers, not using the above definition.
+ The above definition is not used in the case that static initializers
+ use this value. */
+#define __LOCK_ALT_INITIALIZER { __LT_SPINLOCK_ALT_INIT, 0 }
+
+/* Used to initialize _pthread_fastlock's in non-static case */
+#define __LOCK_INITIALIZER ((struct _pthread_fastlock){ __LT_SPINLOCK_INIT, 0 })
+
+/* Used in pthread_atomic initialization */
+#define __ATOMIC_INITIALIZER { 0, __LT_SPINLOCK_ALT_INIT }
+
+/* Tell the rest of the code that the initializer is non-zero without
+ explaining it's internal structure */
+#define __LT_INITIALIZER_NOT_ZERO
+
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/bits/pthreadtypes.h b/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/bits/pthreadtypes.h
new file mode 100644
index 000000000..e2c6f5957
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/bits/pthreadtypes.h
@@ -0,0 +1,160 @@
+/* Linuxthreads - a simple clone()-based implementation of Posix */
+/* threads for Linux. */
+/* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */
+/* */
+/* This program is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU Library General Public License */
+/* as published by the Free Software Foundation; either version 2 */
+/* of the License, 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 Library General Public License for more details. */
+
+#if !defined _BITS_TYPES_H && !defined _PTHREAD_H
+# error "Never include <bits/pthreadtypes.h> directly; use <sys/types.h> instead."
+#endif
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#define __need_schedparam
+#include <bits/sched.h>
+
+/* We need 128-bit alignment for the ldcw semaphore. At most, we are
+ assured of 64-bit alignment for stack locals and malloc'd data. Thus,
+ we use a struct with four ints for the atomic lock type. The locking
+ code will figure out which of the four to use for the ldcw semaphore. */
+typedef volatile struct {
+ int lock[4];
+} __attribute__ ((aligned(16))) __atomic_lock_t;
+
+/* Fast locks (not abstract because mutexes and conditions aren't abstract). */
+struct _pthread_fastlock
+{
+ __atomic_lock_t __spinlock; /* Used by compare_and_swap emulation. Also,
+ adaptive SMP lock stores spin count here. */
+ long int __status; /* "Free" or "taken" or head of waiting list */
+};
+
+#ifndef _PTHREAD_DESCR_DEFINED
+/* Thread descriptors */
+typedef struct _pthread_descr_struct *_pthread_descr;
+# define _PTHREAD_DESCR_DEFINED
+#endif
+
+
+/* Attributes for threads. */
+typedef struct __pthread_attr_s
+{
+ int __detachstate;
+ int __schedpolicy;
+ struct __sched_param __schedparam;
+ int __inheritsched;
+ int __scope;
+ size_t __guardsize;
+ int __stackaddr_set;
+ void *__stackaddr;
+ size_t __stacksize;
+} pthread_attr_t;
+
+
+/* Conditions (not abstract because of PTHREAD_COND_INITIALIZER */
+
+#ifdef __GLIBC_HAVE_LONG_LONG
+__extension__ typedef long long __pthread_cond_align_t;
+#else
+typedef long __pthread_cond_align_t;
+#endif
+
+typedef struct
+{
+ struct _pthread_fastlock __c_lock; /* Protect against concurrent access */
+ _pthread_descr __c_waiting; /* Threads waiting on this condition */
+ char __padding[48 - sizeof (struct _pthread_fastlock)
+ - sizeof (_pthread_descr) - sizeof (__pthread_cond_align_t)];
+ __pthread_cond_align_t __align;
+} pthread_cond_t;
+
+
+/* Attribute for conditionally variables. */
+typedef struct
+{
+ int __dummy;
+} pthread_condattr_t;
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Mutexes (not abstract because of PTHREAD_MUTEX_INITIALIZER). */
+/* (The layout is unnatural to maintain binary compatibility
+ with earlier releases of LinuxThreads.) */
+typedef struct
+{
+ int __m_reserved; /* Reserved for future use */
+ int __m_count; /* Depth of recursive locking */
+ _pthread_descr __m_owner; /* Owner thread (if recursive or errcheck) */
+ int __m_kind; /* Mutex kind: fast, recursive or errcheck */
+ struct _pthread_fastlock __m_lock; /* Underlying fast lock */
+} pthread_mutex_t;
+
+
+/* Attribute for mutex. */
+typedef struct
+{
+ int __mutexkind;
+} pthread_mutexattr_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#ifdef __USE_UNIX98
+/* Read-write locks. */
+typedef struct _pthread_rwlock_t
+{
+ struct _pthread_fastlock __rw_lock; /* Lock to guarantee mutual exclusion */
+ int __rw_readers; /* Number of readers */
+ _pthread_descr __rw_writer; /* Identity of writer, or NULL if none */
+ _pthread_descr __rw_read_waiting; /* Threads waiting for reading */
+ _pthread_descr __rw_write_waiting; /* Threads waiting for writing */
+ int __rw_kind; /* Reader/Writer preference selection */
+ int __rw_pshared; /* Shared between processes or not */
+} pthread_rwlock_t;
+
+
+/* Attribute for read-write locks. */
+typedef struct
+{
+ int __lockkind;
+ int __pshared;
+} pthread_rwlockattr_t;
+#endif
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef __atomic_lock_t pthread_spinlock_t;
+
+/* POSIX barrier. */
+typedef struct {
+ struct _pthread_fastlock __ba_lock; /* Lock to guarantee mutual exclusion */
+ int __ba_required; /* Threads needed for completion */
+ int __ba_present; /* Threads waiting */
+ _pthread_descr __ba_waiting; /* Queue of waiting threads */
+} pthread_barrier_t;
+
+/* barrier attribute */
+typedef struct {
+ int __pshared;
+} pthread_barrierattr_t;
+
+#endif
+
+
+/* Thread identifiers */
+typedef unsigned long int pthread_t;
+
+#endif /* bits/pthreadtypes.h */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/malloc-machine.h b/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/malloc-machine.h
new file mode 100644
index 000000000..817cf5922
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/malloc-machine.h
@@ -0,0 +1,73 @@
+/* HP-PARISC macro definitions for mutexes, thread-specific data
+ and parameters for malloc.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Carlos O'Donell <carlos@baldric.uwo.ca>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MALLOC_MACHINE_H
+#define _MALLOC_MACHINE_H
+
+#undef thread_atfork_static
+
+#include <atomic.h>
+#include <bits/libc-lock.h>
+
+__libc_lock_define (typedef, mutex_t)
+
+/* Since our lock structure does not tolerate being initialized to zero, we must
+ modify the standard function calls made by malloc */
+# define mutex_init(m) \
+ __libc_maybe_call (__pthread_mutex_init, (m, NULL), \
+ (((m)->__m_lock.__spinlock = __LT_SPINLOCK_INIT),(*(int *)(m))) )
+# define mutex_lock(m) \
+ __libc_maybe_call (__pthread_mutex_lock, (m), \
+ (__load_and_clear(&((m)->__m_lock.__spinlock)), 0))
+# define mutex_trylock(m) \
+ __libc_maybe_call (__pthread_mutex_trylock, (m), \
+ (*(int *)(m) ? 1 : (__load_and_clear(&((m)->__m_lock.__spinlock)), 0)))
+# define mutex_unlock(m) \
+ __libc_maybe_call (__pthread_mutex_unlock, (m), \
+ (((m)->__m_lock.__spinlock = __LT_SPINLOCK_INIT), (*(int *)(m))) )
+
+/* This is defined by newer gcc version unique for each module. */
+extern void *__dso_handle __attribute__ ((__weak__));
+
+#include <fork.h>
+
+#ifdef SHARED
+# define thread_atfork(prepare, parent, child) \
+ __register_atfork (prepare, parent, child, __dso_handle)
+#else
+# define thread_atfork(prepare, parent, child) \
+ __register_atfork (prepare, parent, child, \
+ &__dso_handle == NULL ? NULL : __dso_handle)
+#endif
+
+/* thread specific data for glibc */
+
+#include <bits/libc-tsd.h>
+
+typedef int tsd_key_t[1]; /* no key data structure, libc magic does it */
+__libc_tsd_define (static, MALLOC) /* declaration/common definition */
+#define tsd_key_create(key, destr) ((void) (key))
+#define tsd_setspecific(key, data) __libc_tsd_set (MALLOC, (data))
+#define tsd_getspecific(key, vptr) ((vptr) = __libc_tsd_get (MALLOC))
+
+#include <sysdeps/generic/malloc-machine.h>
+
+#endif /* !defined(_MALLOC_MACHINE_H) */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/pt-initfini.c b/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/pt-initfini.c
new file mode 100644
index 000000000..27f850cf8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/pt-initfini.c
@@ -0,0 +1,109 @@
+/* Special .init and .fini section support for HPPA. Linuxthreads version.
+ Copyright (C) 2001, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ The GNU C Library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* This file is compiled into assembly code which is then munged by a sed
+ script into two files: crti.s and crtn.s.
+
+ * crti.s puts a function prologue at the beginning of the
+ .init and .fini sections and defines global symbols for
+ those addresses, so they can be called as functions.
+
+ * crtn.s puts the corresponding function epilogues
+ in the .init and .fini sections. */
+
+/* If we use the standard C version, the linkage table pointer won't
+ be properly preserved due to the splitting up of function prologues
+ and epilogues. Therefore we write these in assembly to make sure
+ they do the right thing. */
+
+__asm__ (
+"#include \"defs.h\"\n"
+"\n"
+"/*@HEADER_ENDS*/\n"
+"\n"
+"/*@_init_PROLOG_BEGINS*/\n"
+" .section .init\n"
+" .align 4\n"
+" .globl _init\n"
+" .type _init,@function\n"
+"_init:\n"
+" stw %rp,-20(%sp)\n"
+" stwm %r4,64(%sp)\n"
+" stw %r19,-32(%sp)\n"
+" bl __pthread_initialize_minimal,%rp\n"
+" copy %r19,%r4 /* delay slot */\n"
+" copy %r4,%r19\n"
+"/*@_init_PROLOG_ENDS*/\n"
+"\n"
+"/*@_init_EPILOG_BEGINS*/\n"
+"/* Here is the tail end of _init. */\n"
+" .section .init\n"
+" ldw -84(%sp),%rp\n"
+" copy %r4,%r19\n"
+" bv %r0(%rp)\n"
+"_end_init:\n"
+" ldwm -64(%sp),%r4\n"
+"\n"
+"/* Our very own unwind info, because the assembler can't handle\n"
+" functions split into two or more pieces. */\n"
+" .section .PARISC.unwind,\"a\",@progbits\n"
+" .extern _init\n"
+" .word _init, _end_init\n"
+" .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n"
+"\n"
+"/*@_init_EPILOG_ENDS*/\n"
+"\n"
+"/*@_fini_PROLOG_BEGINS*/\n"
+" .section .fini\n"
+" .align 4\n"
+" .globl _fini\n"
+" .type _fini,@function\n"
+"_fini:\n"
+" stw %rp,-20(%sp)\n"
+" stwm %r4,64(%sp)\n"
+" stw %r19,-32(%sp)\n"
+" copy %r19,%r4\n"
+"/*@_fini_PROLOG_ENDS*/\n"
+"\n"
+"/*@_fini_EPILOG_BEGINS*/\n"
+" .section .fini\n"
+" ldw -84(%sp),%rp\n"
+" copy %r4,%r19\n"
+" bv %r0(%rp)\n"
+"_end_fini:\n"
+" ldwm -64(%sp),%r4\n"
+"\n"
+" .section .PARISC.unwind,\"a\",@progbits\n"
+" .extern _fini\n"
+" .word _fini, _end_fini\n"
+" .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n"
+"\n"
+"/*@_fini_EPILOG_ENDS*/\n"
+"\n"
+"/*@TRAILER_BEGINS*/\n"
+);
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/sysdep-cancel.h b/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/sysdep-cancel.h
new file mode 100644
index 000000000..e01936a3d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/linuxthreads/sysdep-cancel.h
@@ -0,0 +1,238 @@
+/* cancellable system calls for Linux/HPPA.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Carlos O'Donell <carlos@baldric.uwo.ca>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# ifndef NO_ERROR
+# define NO_ERROR -0x1000
+# endif
+
+/* The syscall cancellation mechanism requires userspace
+ assistance, the following code does roughly this:
+
+ do arguments (read arg5 and arg6 to registers)
+ setup frame
+
+ check if there are threads, yes jump to pseudo_cancel
+
+ unthreaded:
+ syscall
+ check syscall return (jump to pre_end)
+ set errno
+ set return to -1
+ (jump to pre_end)
+
+ pseudo_cancel:
+ cenable
+ syscall
+ cdisable
+ check syscall return (jump to pre_end)
+ set errno
+ set return to -1
+
+ pre_end
+ restore stack
+
+ It is expected that 'ret' and 'END' macros will
+ append an 'undo arguments' and 'return' to the
+ this PSEUDO macro. */
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ ENTRY (name) \
+ DOARGS_##args ASM_LINE_SEP \
+ copy TREG, %r1 ASM_LINE_SEP \
+ copy %sp, TREG ASM_LINE_SEP \
+ stwm %r1, 64(%sp) ASM_LINE_SEP \
+ stw %rp, -20(%sp) ASM_LINE_SEP \
+ stw TREG, -4(%sp) ASM_LINE_SEP \
+ /* Done setting up frame, continue... */ ASM_LINE_SEP \
+ SINGLE_THREAD_P ASM_LINE_SEP \
+ cmpib,<>,n 0,%ret0,L(pseudo_cancel) ASM_LINE_SEP \
+L(unthreaded): ASM_LINE_SEP \
+ /* Save r19 */ ASM_LINE_SEP \
+ SAVE_PIC(TREG) ASM_LINE_SEP \
+ /* Do syscall, delay loads # */ ASM_LINE_SEP \
+ ble 0x100(%sr2,%r0) ASM_LINE_SEP \
+ ldi SYS_ify (syscall_name), %r20 /* delay */ ASM_LINE_SEP \
+ ldi NO_ERROR,%r1 ASM_LINE_SEP \
+ cmpb,>>=,n %r1,%ret0,L(pre_end) ASM_LINE_SEP \
+ /* Restore r19 from TREG */ ASM_LINE_SEP \
+ LOAD_PIC(TREG) /* delay */ ASM_LINE_SEP \
+ SYSCALL_ERROR_HANDLER ASM_LINE_SEP \
+ /* Use TREG for temp storage */ ASM_LINE_SEP \
+ copy %ret0, TREG /* delay */ ASM_LINE_SEP \
+ /* OPTIMIZE: Don't reload r19 */ ASM_LINE_SEP \
+ /* do a -1*syscall_ret0 */ ASM_LINE_SEP \
+ sub %r0, TREG, TREG ASM_LINE_SEP \
+ /* Store into errno location */ ASM_LINE_SEP \
+ stw TREG, 0(%sr0,%ret0) ASM_LINE_SEP \
+ b L(pre_end) ASM_LINE_SEP \
+ /* return -1 as error */ ASM_LINE_SEP \
+ ldo -1(%r0), %ret0 /* delay */ ASM_LINE_SEP \
+L(pseudo_cancel): ASM_LINE_SEP \
+ PUSHARGS_##args /* Save args */ ASM_LINE_SEP \
+ /* Save r19 into TREG */ ASM_LINE_SEP \
+ CENABLE /* FUNC CALL */ ASM_LINE_SEP \
+ SAVE_PIC(TREG) /* delay */ ASM_LINE_SEP \
+ /* restore syscall args */ ASM_LINE_SEP \
+ POPARGS_##args ASM_LINE_SEP \
+ /* save mask from cenable (use stub rp slot) */ ASM_LINE_SEP \
+ stw %ret0, -24(%sp) ASM_LINE_SEP \
+ /* ... SYSCALL ... */ ASM_LINE_SEP \
+ ble 0x100(%sr2,%r0) ASM_LINE_SEP \
+ ldi SYS_ify (syscall_name), %r20 /* delay */ ASM_LINE_SEP \
+ /* ............... */ ASM_LINE_SEP \
+ LOAD_PIC(TREG) ASM_LINE_SEP \
+ /* pass mask as arg0 to cdisable */ ASM_LINE_SEP \
+ ldw -24(%sp), %r26 ASM_LINE_SEP \
+ CDISABLE ASM_LINE_SEP \
+ stw %ret0, -24(%sp) /* delay */ ASM_LINE_SEP \
+ /* Restore syscall return */ ASM_LINE_SEP \
+ ldw -24(%sp), %ret0 ASM_LINE_SEP \
+ /* compare error */ ASM_LINE_SEP \
+ ldi NO_ERROR,%r1 ASM_LINE_SEP \
+ /* branch if no error */ ASM_LINE_SEP \
+ cmpb,>>=,n %r1,%ret0,L(pre_end) ASM_LINE_SEP \
+ LOAD_PIC(TREG) /* cond. nullify */ ASM_LINE_SEP \
+ copy %ret0, TREG /* save syscall return */ ASM_LINE_SEP \
+ SYSCALL_ERROR_HANDLER ASM_LINE_SEP \
+ /* make syscall res value positive */ ASM_LINE_SEP \
+ sub %r0, TREG, TREG /* delay */ ASM_LINE_SEP \
+ /* No need to LOAD_PIC */ ASM_LINE_SEP \
+ /* store into errno location */ ASM_LINE_SEP \
+ stw TREG, 0(%sr0,%ret0) ASM_LINE_SEP \
+ /* return -1 */ ASM_LINE_SEP \
+ ldo -1(%r0), %ret0 ASM_LINE_SEP \
+L(pre_end): ASM_LINE_SEP \
+ /* Restore rp before exit */ ASM_LINE_SEP \
+ ldw -84(%sr0,%sp), %rp ASM_LINE_SEP \
+ /* Undo frame */ ASM_LINE_SEP \
+ ldwm -64(%sp),TREG ASM_LINE_SEP \
+ /* No need to LOAD_PIC */ ASM_LINE_SEP
+
+/* Save arguments into our frame */
+# define PUSHARGS_0 /* nothing to do */
+# define PUSHARGS_1 PUSHARGS_0 stw %r26, -36(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_2 PUSHARGS_1 stw %r25, -40(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_3 PUSHARGS_2 stw %r24, -44(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_4 PUSHARGS_3 stw %r23, -48(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_5 PUSHARGS_4 stw %r22, -52(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_6 PUSHARGS_5 stw %r21, -56(%sr0,%sp) ASM_LINE_SEP
+
+/* Bring them back from the stack */
+# define POPARGS_0 /* nothing to do */
+# define POPARGS_1 POPARGS_0 ldw -36(%sr0,%sp), %r26 ASM_LINE_SEP
+# define POPARGS_2 POPARGS_1 ldw -40(%sr0,%sp), %r25 ASM_LINE_SEP
+# define POPARGS_3 POPARGS_2 ldw -44(%sr0,%sp), %r24 ASM_LINE_SEP
+# define POPARGS_4 POPARGS_3 ldw -48(%sr0,%sp), %r23 ASM_LINE_SEP
+# define POPARGS_5 POPARGS_4 ldw -52(%sr0,%sp), %r22 ASM_LINE_SEP
+# define POPARGS_6 POPARGS_5 ldw -56(%sr0,%sp), %r21 ASM_LINE_SEP
+
+# ifdef IS_IN_libpthread
+# ifdef PIC
+# define CENABLE .import __pthread_enable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __pthread_disable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_disable_asynccancel,%r2 ASM_LINE_SEP
+# else
+# define CENABLE .import __pthread_enable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __pthread_disable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_disable_asynccancel,%r2 ASM_LINE_SEP
+# endif
+# elif !defined NOT_IN_libc
+# ifdef PIC
+# define CENABLE .import __libc_enable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __libc_disable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_disable_asynccancel,%r2 ASM_LINE_SEP
+# else
+# define CENABLE .import __libc_enable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __libc_disable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_disable_asynccancel,%r2 ASM_LINE_SEP
+# endif
+# else
+# ifdef PIC
+# define CENABLE .import __librt_enable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __librt_disable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_disable_asynccancel,%r2 ASM_LINE_SEP
+# else
+# define CENABLE .import __librt_enable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __librt_disable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_disable_asynccancel,%r2 ASM_LINE_SEP
+# endif
+# endif
+
+/* p_header.multiple_threads is +12 from the pthread_descr struct start,
+ We could have called __get_cr27() but we really want less overhead */
+# define MULTIPLE_THREADS_OFFSET 0xC
+
+/* cr27 has been initialized to 0x0 by kernel */
+# define NO_THREAD_CR27 0x0
+
+# ifdef IS_IN_libpthread
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define __local_multiple_threads __libc_multiple_threads
+# else
+# define __local_multiple_threads __librt_multiple_threads
+# endif
+
+# ifndef __ASSEMBLER__
+ extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+/* This ALT version requires newer kernel support */
+# define SINGLE_THREAD_P_MFCTL \
+ mfctl %cr27, %ret0 ASM_LINE_SEP \
+ cmpib,= NO_THREAD_CR27,%ret0,L(stp) ASM_LINE_SEP \
+ nop ASM_LINE_SEP \
+ ldw MULTIPLE_THREADS_OFFSET(%sr0,%ret0),%ret0 ASM_LINE_SEP \
+L(stp): ASM_LINE_SEP
+# ifdef PIC
+/* Slower version uses GOT to get value of __local_multiple_threads */
+# define SINGLE_THREAD_P \
+ addil LT%__local_multiple_threads, %r19 ASM_LINE_SEP \
+ ldw RT%__local_multiple_threads(%sr0,%r1), %ret0 ASM_LINE_SEP \
+ ldw 0(%sr0,%ret0), %ret0 ASM_LINE_SEP
+# else
+/* Slow non-pic version using DP */
+# define SINGLE_THREAD_P \
+ addil LR%__local_multiple_threads-$global$,%r27 ASM_LINE_SEP \
+ ldw RR%__local_multiple_threads-$global$(%sr0,%r1),%ret0 ASM_LINE_SEP
+# endif
+# endif
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
+/* !defined NOT_IN_libc || defined IS_IN_libpthread */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/lxstat.c b/ports/sysdeps/unix/sysv/linux/hppa/lxstat.c
new file mode 100644
index 000000000..0efa0aea4
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/lxstat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/mmap.c b/ports/sysdeps/unix/sysv/linux/hppa/mmap.c
new file mode 100644
index 000000000..6f4bfdce2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/mmap.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 MAP_FAILED
+ for errors (in which case `errno' is set). A successful `mmap' call
+ deallocates any previous mapping for the affected region. */
+
+#include <sysdep.h>
+
+__ptr_t
+__mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
+{
+
+ __ptr_t ret;
+
+ ret = INLINE_SYSCALL(mmap, 6, addr, len, prot, flags, fd, offset);
+
+ /* check if it's really a negative number */
+ if(((unsigned long)ret & 0xfffff000) == 0xfffff000)
+ return MAP_FAILED;
+
+ return ret;
+
+}
+
+strong_alias (__mmap, mmap)
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/nptl/bits/pthreadtypes.h b/ports/sysdeps/unix/sysv/linux/hppa/nptl/bits/pthreadtypes.h
new file mode 100644
index 000000000..e1c5325c0
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/nptl/bits/pthreadtypes.h
@@ -0,0 +1,188 @@
+/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+/* Linuxthread type sizes:
+ sizeof(pthread_attr_t) = 0x24 (36)
+ sizeof(pthread_mutex_t) = 0x30 (48)
+ sizeof(pthread_mutexattr_t) = 0x4 (4)
+ sizeof(pthread_cond_t) = 0x30 (48)
+ = Grew to 64 bytes in NPTL.
+ No pthread_cond_compat_t ...
+ sizeof(pthread_condattr_t) = 0x4 (4)
+ sizeof(pthread_rwlock_t) = 0x40 (64)
+ sizeof(pthread_rwlockattr_t) = 0x8 (8)
+ sizeof(pthread_barrier_t) = 0x30 (48)
+ sizeof(pthread_barrierattr_t) = 0x4 (4) */
+
+#define __SIZEOF_PTHREAD_ATTR_T 36
+#define __SIZEOF_PTHREAD_MUTEX_T 48
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_COND_T 64
+#define __SIZEOF_PTHREAD_COND_COMPAT_T 12
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCK_T 64
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIER_T 48
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+
+/* Thread identifiers. The structure of the attribute type is not
+ exposed on purpose. */
+typedef unsigned long int pthread_t;
+
+/* Our old basic lock type, listed here for posterity.
+ We needed self-aligning locks for linuxthreads LDCW
+ implementation. For NPTL we use LWS Compare and
+ Exchange to implement primitives. */
+#if 0
+typedef struct {
+ int lock[4];
+} __atomic_lock_t;
+#endif
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+} pthread_attr_t;
+
+
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is not exposed on purpose. */
+typedef union
+{
+ struct __pthread_mutex_s
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+ unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ long int __align;
+} pthread_mutexattr_t;
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ long int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned int __flags;
+ int __writer;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+#endif /* bits/pthreadtypes.h */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/nptl/bits/semaphore.h b/ports/sysdeps/unix/sysv/linux/hppa/nptl/bits/semaphore.h
new file mode 100644
index 000000000..3d274eea2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/nptl/bits/semaphore.h
@@ -0,0 +1,39 @@
+/* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+
+#define __SIZEOF_SEM_T 16
+
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+/* Maximum value the semaphore can have. */
+#define SEM_VALUE_MAX ((int) ((~0u) >> 1))
+
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
+
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/nptl/createthread.c b/ports/sysdeps/unix/sysv/linux/hppa/nptl/createthread.c
new file mode 100644
index 000000000..01bd8ce18
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/nptl/createthread.c
@@ -0,0 +1,23 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Value passed to 'clone' for initialization of the thread register. */
+#define TLS_VALUE (pd + 1)
+
+/* Get the real implementation. */
+#include <nptl/sysdeps/pthread/createthread.c>
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/nptl/fork.c b/ports/sysdeps/unix/sysv/linux/hppa/nptl/fork.c
new file mode 100644
index 000000000..4dc38e162
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/nptl/fork.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sched.h>
+#include <signal.h>
+#include <sysdep.h>
+#include <tls.h>
+
+/* Argument 1 - Clone flags.
+ 2 - Child stack pointer.
+ 3 - Parent tid pointer.
+ 4 - New TLS area pointer.
+ 5 - Child tid pointer. */
+#define ARCH_FORK() \
+ INLINE_SYSCALL (clone, 5, \
+ CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, \
+ NULL, NULL, NULL, &THREAD_SELF->tid)
+
+#include <nptl/sysdeps/unix/sysv/linux/fork.c>
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/nptl/internaltypes.h b/ports/sysdeps/unix/sysv/linux/hppa/nptl/internaltypes.h
new file mode 100644
index 000000000..528c2a7d9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/nptl/internaltypes.h
@@ -0,0 +1,153 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _INTERNALTYPES_H
+#define _INTERNALTYPES_H 1
+
+#include <stdint.h>
+
+
+struct pthread_attr
+{
+ /* Scheduler parameters and priority. */
+ struct sched_param schedparam;
+ int schedpolicy;
+ /* Various flags like detachstate, scope, etc. */
+ int flags;
+ /* Size of guard area. */
+ size_t guardsize;
+ /* Stack handling. */
+ void *stackaddr;
+ size_t stacksize;
+ /* Affinity map. */
+ cpu_set_t *cpuset;
+ size_t cpusetsize;
+};
+
+#define ATTR_FLAG_DETACHSTATE 0x0001
+#define ATTR_FLAG_NOTINHERITSCHED 0x0002
+#define ATTR_FLAG_SCOPEPROCESS 0x0004
+#define ATTR_FLAG_STACKADDR 0x0008
+#define ATTR_FLAG_OLDATTR 0x0010
+#define ATTR_FLAG_SCHED_SET 0x0020
+#define ATTR_FLAG_POLICY_SET 0x0040
+
+
+/* Mutex attribute data structure. */
+struct pthread_mutexattr
+{
+ /* Identifier for the kind of mutex.
+
+ Bit 31 is set if the mutex is to be shared between processes.
+
+ Bit 0 to 30 contain one of the PTHREAD_MUTEX_ values to identify
+ the type of the mutex. */
+ int mutexkind;
+};
+
+
+/* Conditional variable attribute data structure. */
+struct pthread_condattr
+{
+ /* Combination of values:
+
+ Bit 0 : flag whether coditional variable will be shareable between
+ processes.
+
+ Bit 1-7: clock ID. */
+ int value;
+};
+
+
+/* The __NWAITERS field is used as a counter and to house the number
+ of bits which represent the clock. COND_CLOCK_BITS is the number
+ of bits reserved for the clock. */
+#define COND_CLOCK_BITS 1
+
+
+/* Read-write lock variable attribute data structure. */
+struct pthread_rwlockattr
+{
+ int lockkind;
+ int pshared;
+};
+
+
+/* Barrier data structure. */
+struct pthread_barrier
+{
+ unsigned int curr_event;
+ int lock;
+ unsigned int left;
+ unsigned int init_count;
+};
+
+
+/* Barrier variable attribute data structure. */
+struct pthread_barrierattr
+{
+ int pshared;
+};
+
+
+/* Thread-local data handling. */
+struct pthread_key_struct
+{
+ /* Sequence numbers. Even numbers indicated vacant entries. Note
+ that zero is even. We use uintptr_t to not require padding on
+ 32- and 64-bit machines. On 64-bit machines it helps to avoid
+ wrapping, too. */
+ uintptr_t seq;
+
+ /* Destructor for the data. */
+ void (*destr) (void *);
+};
+
+/* Check whether an entry is unused. */
+#define KEY_UNUSED(p) (((p) & 1) == 0)
+/* Check whether a key is usable. We cannot reuse an allocated key if
+ the sequence counter would overflow after the next destroy call.
+ This would mean that we potentially free memory for a key with the
+ same sequence. This is *very* unlikely to happen, A program would
+ have to create and destroy a key 2^31 times (on 32-bit platforms,
+ on 64-bit platforms that would be 2^63). If it should happen we
+ simply don't use this specific key anymore. */
+#define KEY_USABLE(p) (((uintptr_t) (p)) < ((uintptr_t) ((p) + 2)))
+
+
+/* Handling of read-write lock data. */
+// XXX For now there is only one flag. Maybe more in future.
+#define RWLOCK_RECURSIVE(rwlock) ((rwlock)->__data.__flags != 0)
+
+
+/* Semaphore variable structure. */
+struct sem
+{
+ unsigned int count;
+};
+
+
+/* Compatibility type for old conditional variable interfaces. */
+typedef struct
+{
+ pthread_cond_t *cond;
+} pthread_cond_2_0_t;
+
+#endif /* internaltypes.h */
+
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/nptl/libc-lowlevellock.c b/ports/sysdeps/unix/sysv/linux/hppa/nptl/libc-lowlevellock.c
new file mode 100644
index 000000000..7b1a7c72d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/nptl/libc-lowlevellock.c
@@ -0,0 +1,21 @@
+/* low level locking for pthread library. Generic futex-using version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "lowlevellock.c"
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/nptl/lowlevellock.c b/ports/sysdeps/unix/sysv/linux/hppa/nptl/lowlevellock.c
new file mode 100644
index 000000000..d2919ee46
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/nptl/lowlevellock.c
@@ -0,0 +1,130 @@
+/* low level locking for pthread library. Generic futex-using version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <sys/time.h>
+
+
+void
+__lll_lock_wait (lll_lock_t *futex)
+{
+ do
+ {
+ int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
+ if (oldval != 0)
+ lll_futex_wait (futex, 2);
+ }
+ while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
+}
+
+
+int
+__lll_timedlock_wait (lll_lock_t *futex, const struct timespec *abstime)
+{
+ /* Reject invalid timeouts. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ do
+ {
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* Wait. */
+ int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
+ if (oldval != 0)
+ lll_futex_timed_wait (futex, 2, &rt);
+ }
+ while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
+ return 0;
+}
+
+
+/* These don't get included in libc.so */
+#ifdef IS_IN_libpthread
+int
+lll_unlock_wake_cb (lll_lock_t *futex)
+{
+ int val = atomic_exchange_rel (futex, 0);
+
+ if (__builtin_expect (val > 1, 0))
+ lll_futex_wake (futex, 1);
+ return 0;
+}
+
+
+int
+__lll_timedwait_tid (int *tidp, const struct timespec *abstime)
+{
+ int tid;
+
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Repeat until thread terminated. */
+ while ((tid = *tidp) != 0)
+ {
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* Wait until thread terminates. */
+ if (lll_futex_timed_wait (tidp, tid, &rt) == -ETIMEDOUT)
+ return ETIMEDOUT;
+ }
+
+ return 0;
+}
+
+#endif
+
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/nptl/lowlevellock.h b/ports/sysdeps/unix/sysv/linux/hppa/nptl/lowlevellock.h
new file mode 100644
index 000000000..a5412bfd5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/nptl/lowlevellock.h
@@ -0,0 +1,339 @@
+/* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _LOWLEVELLOCK_H
+#define _LOWLEVELLOCK_H 1
+
+#include <time.h>
+#include <sys/param.h>
+#include <bits/pthreadtypes.h>
+#include <sysdep.h>
+#include <atomic.h>
+
+#if 0
+/* The hppa only has one atomic read and modify memory operation,
+ load and clear, so hppa spinlocks must use zero to signify that
+ someone is holding the lock. The address used for the ldcw
+ semaphore must be 16-byte aligned. */
+#define __ldcw(a) \
+({ \
+ unsigned int __ret; \
+ __asm__ __volatile__("ldcw 0(%1),%0" \
+ : "=r" (__ret) : "r" (a) : "memory"); \
+ __ret; \
+})
+
+/* Because malloc only guarantees 8-byte alignment for malloc'd data,
+ and GCC only guarantees 8-byte alignment for stack locals, we can't
+ be assured of 16-byte alignment for atomic lock data even if we
+ specify "__attribute ((aligned(16)))" in the type declaration. So,
+ we use a struct containing an array of four ints for the atomic lock
+ type and dynamically select the 16-byte aligned int from the array
+ for the semaphore. */
+#define __PA_LDCW_ALIGNMENT 16
+#define __ldcw_align(a) ({ \
+ volatile unsigned int __ret = (unsigned int) a; \
+ if ((__ret & ~(__PA_LDCW_ALIGNMENT - 1)) < (unsigned int) a) \
+ __ret = (__ret & ~(__PA_LDCW_ALIGNMENT - 1)) + __PA_LDCW_ALIGNMENT; \
+ (unsigned int *) __ret; \
+})
+#endif
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_REQUEUE 3
+#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
+
+/* Initializer for compatibility lock. */
+#if 0
+#define LLL_INITIALIZER_NOT_ZERO
+#define LLL_MUTEX_LOCK_INITIALIZER ((__atomic_lock_t){ { 1, 1, 1, 1 } })
+#endif
+#define LLL_MUTEX_LOCK_INITIALIZER (0)
+
+
+/* Type for lock object. */
+typedef int lll_lock_t;
+
+
+#define lll_futex_wait(futexp, val) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, \
+ (futexp), FUTEX_WAIT, (val), 0); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
+ })
+
+#define lll_futex_timed_wait(futexp, val, timespec) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, \
+ (futexp), FUTEX_WAIT, (val), (timespec)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
+ })
+
+#define lll_futex_wake(futexp, nr) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, \
+ (futexp), FUTEX_WAKE, (nr), 0); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
+ })
+
+#define lll_robust_mutex_dead(futexv) \
+ do \
+ { \
+ int *__futexp = &(futexv); \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ lll_futex_wake (__futexp, 1); \
+ } \
+ while (0)
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, \
+ (futexp), FUTEX_CMP_REQUEUE, (nr_wake), \
+ (nr_move), (mutex), (val)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, \
+ (futexp), FUTEX_WAKE_OP, (nr_wake), \
+ (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ __ret; \
+ })
+
+static inline int __attribute__((always_inline))
+__lll_mutex_trylock(lll_lock_t *futex)
+{
+ return atomic_compare_and_exchange_val_acq (futex, 1, 0) != 0;
+}
+#define lll_mutex_trylock(lock) __lll_mutex_trylock (&(lock))
+
+static inline int __attribute__((always_inline))
+__lll_robust_mutex_trylock(int *futex, int id)
+{
+ return atomic_compare_and_exchange_val_acq (futex, id, 0) != 0;
+}
+#define lll_robust_mutex_trylock(lock, id) \
+ __lll_robust_mutex_trylock (&(lock), id)
+
+
+static inline int __attribute__((always_inline))
+__lll_mutex_cond_trylock(lll_lock_t *futex)
+{
+ return atomic_compare_and_exchange_val_acq (futex, 2, 0) != 0;
+}
+#define lll_mutex_cond_trylock(lock) __lll_mutex_cond_trylock (&(lock))
+
+
+extern void __lll_lock_wait (lll_lock_t *futex) attribute_hidden;
+
+static inline void __attribute__((always_inline))
+__lll_mutex_lock(lll_lock_t *futex)
+{
+ if (atomic_compare_and_exchange_bool_acq (futex, 1, 0) != 0)
+ __lll_lock_wait (futex);
+}
+#define lll_mutex_lock(futex) __lll_mutex_lock (&(futex))
+
+extern int __lll_robust_lock_wait (int *futex) attribute_hidden;
+
+static inline int __attribute__ ((always_inline))
+__lll_robust_mutex_lock (int *futex, int id)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_lock_wait (futex);
+ return result;
+}
+#define lll_robust_mutex_lock(futex, id) \
+ __lll_robust_mutex_lock (&(futex), id)
+
+static inline void __attribute__ ((always_inline))
+__lll_mutex_cond_lock (lll_lock_t *futex)
+{
+ if (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0)
+ __lll_lock_wait (futex);
+}
+#define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex))
+
+
+#define lll_robust_mutex_cond_lock(futex, id) \
+ __lll_robust_mutex_lock (&(futex), (id) | FUTEX_WAITERS)
+
+
+extern int __lll_timedlock_wait (lll_lock_t *futex, const struct timespec *)
+ attribute_hidden;
+extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *)
+ attribute_hidden;
+
+static inline int __attribute__ ((always_inline))
+__lll_mutex_timedlock (lll_lock_t *futex, const struct timespec *abstime)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, 1, 0) != 0)
+ result = __lll_timedlock_wait (futex, abstime);
+ return result;
+}
+#define lll_mutex_timedlock(futex, abstime) \
+ __lll_mutex_timedlock (&(futex), abstime)
+
+static inline int __attribute__ ((always_inline))
+__lll_robust_mutex_timedlock (int *futex, const struct timespec *abstime,
+ int id)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_timedlock_wait (futex, abstime);
+ return result;
+}
+#define lll_robust_mutex_timedlock(futex, abstime, id) \
+ __lll_robust_mutex_timedlock (&(futex), abstime, id)
+
+
+static inline void __attribute__ ((always_inline))
+__lll_mutex_unlock (lll_lock_t *futex)
+{
+ int val = atomic_exchange_rel (futex, 0);
+ if (__builtin_expect (val > 1, 0))
+ lll_futex_wake (futex, 1);
+}
+#define lll_mutex_unlock(futex) __lll_mutex_unlock(&(futex))
+
+
+static inline void __attribute__ ((always_inline))
+__lll_robust_mutex_unlock (int *futex, int mask)
+{
+ int val = atomic_exchange_rel (futex, 0);
+ if (__builtin_expect (val & mask, 0))
+ lll_futex_wake (futex, 1);
+}
+#define lll_robust_mutex_unlock(futex) \
+ __lll_robust_mutex_unlock(&(futex), FUTEX_WAITERS)
+
+
+static inline void __attribute__ ((always_inline))
+__lll_mutex_unlock_force (lll_lock_t *futex)
+{
+ (void) atomic_exchange_rel (futex, 0);
+ lll_futex_wake (futex, 1);
+}
+#define lll_mutex_unlock_force(futex) __lll_mutex_unlock_force(&(futex))
+
+
+static inline int __attribute__ ((always_inline))
+__lll_mutex_islocked (lll_lock_t *futex)
+{
+ return (*futex != 0);
+}
+#define lll_mutex_islocked(futex) __lll_mutex_islocked(&(futex))
+
+
+/* Our internal lock implementation is identical to the binary-compatible
+ mutex implementation. */
+
+/* Initializers for lock. */
+#if 0
+#define LLL_LOCK_INITIALIZER ((__atomic_lock_t){ { 1, 1, 1, 1 } })
+#define LLL_LOCK_INITIALIZER_CONST { { 1, 1, 1, 1 } }
+#define LLL_LOCK_INITIALIZER_LOCKED ((__atomic_lock_t){ { 0, 0, 0, 0 } })
+#endif
+
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_CONST (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+
+
+#define THREAD_INIT_LOCK(PD, LOCK) \
+ (PD)->LOCK = LLL_LOCK_INITIALIZER
+
+extern int lll_unlock_wake_cb (lll_lock_t *__futex) attribute_hidden;
+
+/* The states of a lock are:
+ 0 - untaken
+ 1 - taken by one user
+ >1 - taken by more users */
+
+#define lll_trylock(lock) lll_mutex_trylock (lock)
+#define lll_lock(lock) lll_mutex_lock (lock)
+#define lll_unlock(lock) lll_mutex_unlock (lock)
+#define lll_islocked(lock) lll_mutex_islocked (lock)
+
+/* The kernel notifies a process which uses CLONE_CLEARTID via futex
+ wakeup when the clone terminates. The memory location contains the
+ thread ID while the clone is running and is reset to zero
+ afterwards. */
+#define lll_wait_tid(tid) \
+ do { \
+ __typeof (tid) __tid; \
+ while ((__tid = (tid)) != 0) \
+ lll_futex_wait (&(tid), __tid); \
+ } while (0)
+
+extern int __lll_timedwait_tid (int *, const struct timespec *)
+ attribute_hidden;
+
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __res = 0; \
+ if ((tid) != 0) \
+ __res = __lll_timedwait_tid (&(tid), (abstime)); \
+ __res; \
+ })
+
+
+/* Conditional variable handling. */
+
+extern void __lll_cond_wait (pthread_cond_t *cond)
+ attribute_hidden;
+extern int __lll_cond_timedwait (pthread_cond_t *cond,
+ const struct timespec *abstime)
+ attribute_hidden;
+extern void __lll_cond_wake (pthread_cond_t *cond)
+ attribute_hidden;
+extern void __lll_cond_broadcast (pthread_cond_t *cond)
+ attribute_hidden;
+
+#define lll_cond_wait(cond) \
+ __lll_cond_wait (cond)
+#define lll_cond_timedwait(cond, abstime) \
+ __lll_cond_timedwait (cond, abstime)
+#define lll_cond_wake(cond) \
+ __lll_cond_wake (cond)
+#define lll_cond_broadcast(cond) \
+ __lll_cond_broadcast (cond)
+
+#endif /* lowlevellock.h */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/nptl/pt-initfini.c b/ports/sysdeps/unix/sysv/linux/hppa/nptl/pt-initfini.c
new file mode 100644
index 000000000..845e1feb5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/nptl/pt-initfini.c
@@ -0,0 +1,109 @@
+/* Special .init and .fini section support for HPPA. NPTL version.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ In addition to the permissions in the GNU Lesser General Public
+ License, the Free Software Foundation gives you unlimited
+ permission to link the compiled version of this file with other
+ programs, and to distribute those programs without any restriction
+ coming from the use of this file. (The Lesser General Public
+ License restrictions do apply in other respects; for example, they
+ cover modification of the file, and distribution when not linked
+ into another program.)
+
+ The GNU C Library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* This file is compiled into assembly code which is then munged by a sed
+ script into two files: crti.s and crtn.s.
+
+ * crti.s puts a function prologue at the beginning of the
+ .init and .fini sections and defines global symbols for
+ those addresses, so they can be called as functions.
+
+ * crtn.s puts the corresponding function epilogues
+ in the .init and .fini sections. */
+
+/* If we use the standard C version, the linkage table pointer won't
+ be properly preserved due to the splitting up of function prologues
+ and epilogues. Therefore we write these in assembly to make sure
+ they do the right thing. */
+
+__asm__ (
+"#include \"defs.h\"\n"
+"\n"
+"/*@HEADER_ENDS*/\n"
+"\n"
+"/*@_init_PROLOG_BEGINS*/\n"
+" .section .init\n"
+" .align 4\n"
+" .globl _init\n"
+" .type _init,@function\n"
+"_init:\n"
+" stw %rp,-20(%sp)\n"
+" stwm %r4,64(%sp)\n"
+" stw %r19,-32(%sp)\n"
+" bl __pthread_initialize_minimal_internal,%rp\n"
+" copy %r19,%r4 /* delay slot */\n"
+" copy %r4,%r19\n"
+"/*@_init_PROLOG_ENDS*/\n"
+"\n"
+"/*@_init_EPILOG_BEGINS*/\n"
+"/* Here is the tail end of _init. */\n"
+" .section .init\n"
+" ldw -84(%sp),%rp\n"
+" copy %r4,%r19\n"
+" bv %r0(%rp)\n"
+"_end_init:\n"
+" ldwm -64(%sp),%r4\n"
+"\n"
+"/* Our very own unwind info, because the assembler can't handle\n"
+" functions split into two or more pieces. */\n"
+" .section .PARISC.unwind,\"a\",@progbits\n"
+" .extern _init\n"
+" .word _init, _end_init\n"
+" .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n"
+"\n"
+"/*@_init_EPILOG_ENDS*/\n"
+"\n"
+"/*@_fini_PROLOG_BEGINS*/\n"
+" .section .fini\n"
+" .align 4\n"
+" .globl _fini\n"
+" .type _fini,@function\n"
+"_fini:\n"
+" stw %rp,-20(%sp)\n"
+" stwm %r4,64(%sp)\n"
+" stw %r19,-32(%sp)\n"
+" copy %r19,%r4\n"
+"/*@_fini_PROLOG_ENDS*/\n"
+"\n"
+"/*@_fini_EPILOG_BEGINS*/\n"
+" .section .fini\n"
+" ldw -84(%sp),%rp\n"
+" copy %r4,%r19\n"
+" bv %r0(%rp)\n"
+"_end_fini:\n"
+" ldwm -64(%sp),%r4\n"
+"\n"
+" .section .PARISC.unwind,\"a\",@progbits\n"
+" .extern _fini\n"
+" .word _fini, _end_fini\n"
+" .byte 0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08\n"
+"\n"
+"/*@_fini_EPILOG_ENDS*/\n"
+"\n"
+"/*@TRAILER_BEGINS*/\n"
+);
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/nptl/pt-vfork.S b/ports/sysdeps/unix/sysv/linux/hppa/nptl/pt-vfork.S
new file mode 100644
index 000000000..a44e785bb
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/nptl/pt-vfork.S
@@ -0,0 +1,90 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <tcb-offsets.h>
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+
+/* Load the thread register.
+ Load the saved PID value.
+ Negate the value.
+ Store the temporary PID. */
+#define SAVE_PID \
+ mfctl %cr27, %r26 ASM_LINE_SEP \
+ ldw PID_THREAD_OFFSET(%r26),%r1 ASM_LINE_SEP \
+ sub %r0,%r1,%r1 ASM_LINE_SEP \
+ stw %r1,PID_THREAD_OFFSET(%r26) ASM_LINE_SEP
+/* If we are the parent...
+ Get the thread pointer.
+ Load the saved PID.
+ Negate the value (got back original)
+ Restore the PID. */
+#define RESTORE_PID \
+ cmpb,=,n %r0,%ret0,.Lthread_start ASM_LINE_SEP \
+ mfctl %cr27, %r26 ASM_LINE_SEP \
+ ldw PID_THREAD_OFFSET(%r26),%r1 ASM_LINE_SEP \
+ sub %r0,%r1,%r1 ASM_LINE_SEP \
+ stw %r1,PID_THREAD_OFFSET(%r26) ASM_LINE_SEP \
+.Lthread_start: ASM_LINE_SEP
+
+ /* r26, r25, r24, r23 are free since vfork has no arguments */
+ENTRY(__vfork)
+
+ /* Save the PIC register. */
+#ifdef PIC
+ copy %r19, %r25 /* parent */
+#endif
+
+ /* Save the process PID */
+ SAVE_PID
+
+ /* Syscall saves and restores all register states */
+ ble 0x100(%sr2,%r0)
+ ldi __NR_vfork,%r20
+
+ /* Conditionally restore the PID */
+ RESTORE_PID
+
+ /* Check for error */
+ ldi -4096,%r1
+ comclr,>>= %r1,%ret0,%r0 /* Note: unsigned compare. */
+ b,n .Lerror
+
+ /* Return, no need to restore the PIC register. */
+ bv,n %r0(%rp)
+
+.Lerror:
+ SYSCALL_ERROR_HANDLER
+ /* Restore the PIC register (in delay slot) on error */
+#ifdef PIC
+ copy %r25, %r19 /* parent */
+#else
+ nop
+#endif
+ sub %r0,%ret0,%arg0
+ /* Return error */
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+weak_alias (__vfork, vfork)
+
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/nptl/pthread_once.c b/ports/sysdeps/unix/sysv/linux/hppa/nptl/pthread_once.c
new file mode 100644
index 000000000..649b752f5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/nptl/pthread_once.c
@@ -0,0 +1,94 @@
+/* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+
+unsigned long int __fork_generation attribute_hidden;
+
+
+static void
+clear_once_control (void *arg)
+{
+ pthread_once_t *once_control = (pthread_once_t *) arg;
+
+ *once_control = 0;
+ lll_futex_wake (once_control, INT_MAX);
+}
+
+
+int
+__pthread_once (once_control, init_routine)
+ pthread_once_t *once_control;
+ void (*init_routine) (void);
+{
+ while (1)
+ {
+ int oldval, val, newval;
+
+ val = *once_control;
+ do
+ {
+ /* Check if the initialized has already been done. */
+ if ((val & 2) != 0)
+ return 0;
+
+ oldval = val;
+ newval = (oldval & 3) | __fork_generation | 1;
+ val = atomic_compare_and_exchange_val_acq (once_control, newval,
+ oldval);
+ }
+ while (__builtin_expect (val != oldval, 0));
+
+ /* Check if another thread already runs the initializer. */
+ if ((oldval & 1) != 0)
+ {
+ /* Check whether the initializer execution was interrupted
+ by a fork. */
+ if (((oldval ^ newval) & -4) == 0)
+ {
+ /* Same generation, some other thread was faster. Wait. */
+ lll_futex_wait (once_control, newval);
+ continue;
+ }
+ }
+
+ /* This thread is the first here. Do the initialization.
+ Register a cleanup handler so that in case the thread gets
+ interrupted the initialization can be restarted. */
+ pthread_cleanup_push (clear_once_control, once_control);
+
+ init_routine ();
+
+ pthread_cleanup_pop (0);
+
+
+ /* Add one to *once_control. */
+ atomic_increment (once_control);
+
+ /* Wake up all other threads. */
+ lll_futex_wake (once_control, INT_MAX);
+ break;
+ }
+
+ return 0;
+}
+weak_alias (__pthread_once, pthread_once)
+strong_alias (__pthread_once, __pthread_once_internal)
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/nptl/sysdep-cancel.h b/ports/sysdeps/unix/sysv/linux/hppa/nptl/sysdep-cancel.h
new file mode 100644
index 000000000..748fe6961
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/nptl/sysdep-cancel.h
@@ -0,0 +1,217 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <sysdeps/generic/sysdep.h>
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <nptl/pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# ifndef NO_ERROR
+# define NO_ERROR -0x1000
+# endif
+
+/* The syscall cancellation mechanism requires userspace
+ assistance, the following code does roughly this:
+
+ do arguments (read arg5 and arg6 to registers)
+ setup frame
+
+ check if there are threads, yes jump to pseudo_cancel
+
+ unthreaded:
+ syscall
+ check syscall return (jump to pre_end)
+ set errno
+ set return to -1
+ (jump to pre_end)
+
+ pseudo_cancel:
+ cenable
+ syscall
+ cdisable
+ check syscall return (jump to pre_end)
+ set errno
+ set return to -1
+
+ pre_end
+ restore stack
+
+ It is expected that 'ret' and 'END' macros will
+ append an 'undo arguments' and 'return' to the
+ this PSEUDO macro. */
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ ENTRY (name) \
+ DOARGS_##args ASM_LINE_SEP \
+ copy TREG, %r1 ASM_LINE_SEP \
+ copy %sp, TREG ASM_LINE_SEP \
+ stwm %r1, 64(%sp) ASM_LINE_SEP \
+ stw %rp, -20(%sp) ASM_LINE_SEP \
+ stw TREG, -4(%sp) ASM_LINE_SEP \
+ /* Done setting up frame, continue... */ ASM_LINE_SEP \
+ SINGLE_THREAD_P ASM_LINE_SEP \
+ cmpib,<>,n 0,%ret0,L(pseudo_cancel) ASM_LINE_SEP \
+L(unthreaded): ASM_LINE_SEP \
+ /* Save r19 */ ASM_LINE_SEP \
+ SAVE_PIC(TREG) ASM_LINE_SEP \
+ /* Do syscall, delay loads # */ ASM_LINE_SEP \
+ ble 0x100(%sr2,%r0) ASM_LINE_SEP \
+ ldi SYS_ify (syscall_name), %r20 /* delay */ ASM_LINE_SEP \
+ ldi NO_ERROR,%r1 ASM_LINE_SEP \
+ cmpb,>>=,n %r1,%ret0,L(pre_end) ASM_LINE_SEP \
+ /* Restore r19 from TREG */ ASM_LINE_SEP \
+ LOAD_PIC(TREG) /* delay */ ASM_LINE_SEP \
+ SYSCALL_ERROR_HANDLER ASM_LINE_SEP \
+ /* Use TREG for temp storage */ ASM_LINE_SEP \
+ copy %ret0, TREG /* delay */ ASM_LINE_SEP \
+ /* OPTIMIZE: Don't reload r19 */ ASM_LINE_SEP \
+ /* do a -1*syscall_ret0 */ ASM_LINE_SEP \
+ sub %r0, TREG, TREG ASM_LINE_SEP \
+ /* Store into errno location */ ASM_LINE_SEP \
+ stw TREG, 0(%sr0,%ret0) ASM_LINE_SEP \
+ b L(pre_end) ASM_LINE_SEP \
+ /* return -1 as error */ ASM_LINE_SEP \
+ ldo -1(%r0), %ret0 /* delay */ ASM_LINE_SEP \
+L(pseudo_cancel): ASM_LINE_SEP \
+ PUSHARGS_##args /* Save args */ ASM_LINE_SEP \
+ /* Save r19 into TREG */ ASM_LINE_SEP \
+ CENABLE /* FUNC CALL */ ASM_LINE_SEP \
+ SAVE_PIC(TREG) /* delay */ ASM_LINE_SEP \
+ /* restore syscall args */ ASM_LINE_SEP \
+ POPARGS_##args ASM_LINE_SEP \
+ /* save mask from cenable (use stub rp slot) */ ASM_LINE_SEP \
+ stw %ret0, -24(%sp) ASM_LINE_SEP \
+ /* ... SYSCALL ... */ ASM_LINE_SEP \
+ ble 0x100(%sr2,%r0) ASM_LINE_SEP \
+ ldi SYS_ify (syscall_name), %r20 /* delay */ ASM_LINE_SEP \
+ /* ............... */ ASM_LINE_SEP \
+ LOAD_PIC(TREG) ASM_LINE_SEP \
+ /* pass mask as arg0 to cdisable */ ASM_LINE_SEP \
+ ldw -24(%sp), %r26 ASM_LINE_SEP \
+ CDISABLE ASM_LINE_SEP \
+ stw %ret0, -24(%sp) /* delay */ ASM_LINE_SEP \
+ /* Restore syscall return */ ASM_LINE_SEP \
+ ldw -24(%sp), %ret0 ASM_LINE_SEP \
+ /* compare error */ ASM_LINE_SEP \
+ ldi NO_ERROR,%r1 ASM_LINE_SEP \
+ /* branch if no error */ ASM_LINE_SEP \
+ cmpb,>>=,n %r1,%ret0,L(pre_end) ASM_LINE_SEP \
+ LOAD_PIC(TREG) /* cond. nullify */ ASM_LINE_SEP \
+ copy %ret0, TREG /* save syscall return */ ASM_LINE_SEP \
+ SYSCALL_ERROR_HANDLER ASM_LINE_SEP \
+ /* make syscall res value positive */ ASM_LINE_SEP \
+ sub %r0, TREG, TREG /* delay */ ASM_LINE_SEP \
+ /* No need to LOAD_PIC */ ASM_LINE_SEP \
+ /* store into errno location */ ASM_LINE_SEP \
+ stw TREG, 0(%sr0,%ret0) ASM_LINE_SEP \
+ /* return -1 */ ASM_LINE_SEP \
+ ldo -1(%r0), %ret0 ASM_LINE_SEP \
+L(pre_end): ASM_LINE_SEP \
+ /* Restore rp before exit */ ASM_LINE_SEP \
+ ldw -84(%sr0,%sp), %rp ASM_LINE_SEP \
+ /* Undo frame */ ASM_LINE_SEP \
+ ldwm -64(%sp),TREG ASM_LINE_SEP \
+ /* No need to LOAD_PIC */ ASM_LINE_SEP
+
+/* Save arguments into our frame */
+# define PUSHARGS_0 /* nothing to do */
+# define PUSHARGS_1 PUSHARGS_0 stw %r26, -36(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_2 PUSHARGS_1 stw %r25, -40(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_3 PUSHARGS_2 stw %r24, -44(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_4 PUSHARGS_3 stw %r23, -48(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_5 PUSHARGS_4 stw %r22, -52(%sr0,%sp) ASM_LINE_SEP
+# define PUSHARGS_6 PUSHARGS_5 stw %r21, -56(%sr0,%sp) ASM_LINE_SEP
+
+/* Bring them back from the stack */
+# define POPARGS_0 /* nothing to do */
+# define POPARGS_1 POPARGS_0 ldw -36(%sr0,%sp), %r26 ASM_LINE_SEP
+# define POPARGS_2 POPARGS_1 ldw -40(%sr0,%sp), %r25 ASM_LINE_SEP
+# define POPARGS_3 POPARGS_2 ldw -44(%sr0,%sp), %r24 ASM_LINE_SEP
+# define POPARGS_4 POPARGS_3 ldw -48(%sr0,%sp), %r23 ASM_LINE_SEP
+# define POPARGS_5 POPARGS_4 ldw -52(%sr0,%sp), %r22 ASM_LINE_SEP
+# define POPARGS_6 POPARGS_5 ldw -56(%sr0,%sp), %r21 ASM_LINE_SEP
+
+# ifdef IS_IN_libpthread
+# ifdef PIC
+# define CENABLE .import __pthread_enable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __pthread_disable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_disable_asynccancel,%r2 ASM_LINE_SEP
+# else
+# define CENABLE .import __pthread_enable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __pthread_disable_asynccancel,code ASM_LINE_SEP \
+ bl __pthread_disable_asynccancel,%r2 ASM_LINE_SEP
+# endif
+# elif !defined NOT_IN_libc
+# ifdef PIC
+# define CENABLE .import __libc_enable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __libc_disable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_disable_asynccancel,%r2 ASM_LINE_SEP
+# else
+# define CENABLE .import __libc_enable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __libc_disable_asynccancel,code ASM_LINE_SEP \
+ bl __libc_disable_asynccancel,%r2 ASM_LINE_SEP
+# endif
+# else
+# ifdef PIC
+# define CENABLE .import __librt_enable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __librt_disable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_disable_asynccancel,%r2 ASM_LINE_SEP
+# else
+# define CENABLE .import __librt_enable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_enable_asynccancel,%r2 ASM_LINE_SEP
+# define CDISABLE .import __librt_disable_asynccancel,code ASM_LINE_SEP \
+ bl __librt_disable_asynccancel,%r2 ASM_LINE_SEP
+# endif
+# endif
+
+# ifdef IS_IN_libpthread
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define __local_multiple_threads __libc_multiple_threads
+# else
+# define __local_multiple_threads __librt_multiple_threads
+# endif
+
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+# else
+/* Read the value of header.multiple_threads from the thread pointer */
+# define SINGLE_THREAD_P \
+ mfctl %cr27, %ret0 ASM_LINE_SEP \
+ ldw MULTIPLE_THREADS_THREAD_OFFSET(%sr0,%ret0),%ret0 ASM_LINE_SEP
+# endif
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+# define NO_CANCELLATION 1
+
+#endif
+/* !defined NOT_IN_libc || defined IS_IN_libpthread */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/nptl/unwind-forcedunwind.c b/ports/sysdeps/unix/sysv/linux/hppa/nptl/unwind-forcedunwind.c
new file mode 100644
index 000000000..c8142cb54
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/nptl/unwind-forcedunwind.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#define LIBGCC_S_SO "libgcc_s.so.2"
+#include <sysdeps/pthread/unwind-forcedunwind.c>
+
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/nptl/unwind-resume.c b/ports/sysdeps/unix/sysv/linux/hppa/nptl/unwind-resume.c
new file mode 100644
index 000000000..6d1da8550
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/nptl/unwind-resume.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#define LIBGCC_S_SO "libgcc_s.so.2"
+#include <sysdeps/pthread/unwind-resume.c>
+
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/profil-counter.h b/ports/sysdeps/unix/sysv/linux/hppa/profil-counter.h
new file mode 100644
index 000000000..b108be8a3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/profil-counter.h
@@ -0,0 +1,25 @@
+/* Machine-dependent SIGPROF signal handler. PA-RISC version
+ Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+static void
+profil_counter (int signr, siginfo_t *si, struct ucontext *uctx)
+{
+ unsigned long ip = uctx->uc_mcontext.sc_iaoq[0] & ~0x3;
+ profil_count ((void *) ip);
+}
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/socket.S b/ports/sysdeps/unix/sysv/linux/hppa/socket.S
new file mode 100644
index 000000000..dfbb721a8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/socket.S
@@ -0,0 +1,10 @@
+#include <sysdep.h>
+
+ .globl __socket
+PSEUDO(__socket, socket, 3)
+
+PSEUDO_END(__socket)
+
+#ifndef NO_WEAK_ALIAS
+weak_alias (__socket, socket)
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/sys/procfs.h b/ports/sysdeps/unix/sysv/linux/hppa/sys/procfs.h
new file mode 100644
index 000000000..2e6d10956
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/sys/procfs.h
@@ -0,0 +1,113 @@
+/* Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_PROCFS_H
+#define _SYS_PROCFS_H 1
+
+/* This is somewhat modelled after the file of the same name on SVR4
+ systems. It provides a definition of the core file format for ELF
+ used on Linux. It doesn't have anything to do with the /proc file
+ system, even though Linux has one.
+
+ Anyway, the whole purpose of this file is for GDB and GDB only.
+ Don't read too much into it. Don't use it for anything other than
+ GDB unless you know what you are doing. */
+
+#include <features.h>
+#include <signal.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/ucontext.h>
+#include <sys/user.h>
+#include <asm/elf.h>
+
+__BEGIN_DECLS
+
+struct elf_siginfo
+ {
+ int si_signo; /* Signal number. */
+ int si_code; /* Extra code. */
+ int si_errno; /* Errno. */
+ };
+
+/* Definitions to generate Intel SVR4-like core files. These mostly
+ have the same names as the SVR4 types with "elf_" tacked on the
+ front to prevent clashes with Linux definitions, and the typedef
+ forms have been avoided. This is mostly like the SVR4 structure,
+ but more Linuxy, with things that Linux does not support and which
+ GDB doesn't really use excluded. */
+
+struct elf_prstatus
+ {
+ struct elf_siginfo pr_info; /* Info associated with signal. */
+ short int pr_cursig; /* Current signal. */
+ unsigned long int pr_sigpend; /* Set of pending signals. */
+ unsigned long int pr_sighold; /* Set of held signals. */
+ __pid_t pr_pid;
+ __pid_t pr_ppid;
+ __pid_t pr_pgrp;
+ __pid_t pr_sid;
+ struct timeval pr_utime; /* User time. */
+ struct timeval pr_stime; /* System time. */
+ struct timeval pr_cutime; /* Cumulative user time. */
+ struct timeval pr_cstime; /* Cumulative system time. */
+ elf_gregset_t pr_reg; /* GP registers. */
+ int pr_fpvalid; /* True if math copro being used. */
+ };
+
+
+#define ELF_PRARGSZ (80) /* Number of chars for args. */
+
+struct elf_prpsinfo
+ {
+ char pr_state; /* Numeric process state. */
+ char pr_sname; /* Char for pr_state. */
+ char pr_zomb; /* Zombie. */
+ char pr_nice; /* Nice val. */
+ unsigned long int pr_flag; /* Flags. */
+ unsigned int pr_uid;
+ unsigned int pr_gid;
+ int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+ /* Lots missing */
+ char pr_fname[16]; /* Filename of executable. */
+ char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
+ };
+
+
+/* The rest of this file provides the types for emulation of the
+ Solaris <proc_service.h> interfaces that should be implemented by
+ users of libthread_db. */
+
+/* Addresses. */
+typedef void *psaddr_t;
+
+/* Register sets. Linux has different names. */
+typedef elf_gregset_t prgregset_t;
+typedef elf_fpregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+ therefore have only one PID type. */
+typedef __pid_t lwpid_t;
+
+/* Process status and info. In the end we do provide typedefs for them. */
+typedef struct elf_prstatus prstatus_t;
+typedef struct elf_prpsinfo prpsinfo_t;
+
+__END_DECLS
+
+#endif /* sys/procfs.h */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/sys/ucontext.h b/ports/sysdeps/unix/sysv/linux/hppa/sys/ucontext.h
new file mode 100644
index 000000000..143114384
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/sys/ucontext.h
@@ -0,0 +1,67 @@
+/* Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Don't rely on this, the interface is currently messed up and may need to
+ be broken to be fixed. */
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <signal.h>
+
+/* We need the signal context definitions even if they are not used
+ included in <signal.h>. */
+#include <bits/sigcontext.h>
+
+
+/* Type for general register. */
+typedef unsigned long int greg_t;
+
+/* Number of general registers. */
+#define NGREG 80
+#define NFPREG 32
+
+/* Container for all general registers. */
+typedef struct gregset
+ {
+ greg_t g_regs[32];
+ greg_t sr_regs[8];
+ greg_t cr_regs[24];
+ greg_t g_pad[16];
+ } gregset_t;
+
+/* Container for all FPU registers. */
+typedef struct fpregset
+ {
+ double fp_dregs[32];
+ } fpregset_t;
+
+/* Context to describe whole processor state. */
+typedef struct sigcontext mcontext_t;
+
+/* Userlevel context. */
+typedef struct ucontext
+ {
+ unsigned long int uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ __sigset_t uc_sigmask;
+ } ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/syscall.S b/ports/sysdeps/unix/sysv/linux/hppa/syscall.S
new file mode 100644
index 000000000..b333487c9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/syscall.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 1995, 1996, 1998, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* HPPA implements syscall() in 'C'; see sysdep.c. */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/syscalls.list b/ports/sysdeps/unix/sysv/linux/hppa/syscalls.list
new file mode 100644
index 000000000..0f7537c30
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -0,0 +1,37 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+# semaphore and shm system calls
+msgctl - msgctl i:iip __msgctl msgctl
+msgget - msgget i:ii __msgget msgget
+msgrcv - msgrcv Ci:ibnii __msgrcv msgrcv
+msgsnd - msgsnd Ci:ibni __msgsnd msgsnd
+shmat - shmat i:ipi __shmat shmat
+shmctl - shmctl i:iip __shmctl shmctl
+shmdt - shmdt i:s __shmdt shmdt
+shmget - shmget i:iii __shmget shmget
+semop - semop i:ipi __semop semop
+semtimedop - semtimedop i:ipip semtimedop
+semget - semget i:iii __semget semget
+semctl - semctl i:iiii __semctl semctl
+
+# proper socket implementations:
+accept - accept Ci:iBN __libc_accept __accept accept
+bind - bind i:ipi __bind bind
+connect - connect Ci:ipi __libc_connect __connect_internal __connect connect
+getpeername - getpeername i:ipp __getpeername getpeername
+getsockname - getsockname i:ipp __getsockname getsockname
+getsockopt - getsockopt i:iiiBN __getsockopt getsockopt
+listen - listen i:ii __listen listen
+recv - recv Ci:ibni __libc_recv __recv recv
+recvfrom - recvfrom Ci:ibniBN __libc_recvfrom __recvfrom recvfrom
+recvmsg - recvmsg Ci:ipi __libc_recvmsg __recvmsg recvmsg
+send - send Ci:ibni __libc_send __send send
+sendmsg - sendmsg Ci:ipi __libc_sendmsg __sendmsg sendmsg
+sendto - sendto Ci:ibnibn __libc_sendto __sendto sendto
+setsockopt - setsockopt i:iiibn __setsockopt setsockopt
+shutdown - shutdown i:ii __shutdown shutdown
+socket - socket i:iii __socket socket
+socketpair - socketpair i:iiif __socketpair socketpair
+
+setrlimit - setrlimit i:ip __setrlimit setrlimit
+getrlimit - getrlimit i:ip __getrlimit getrlimit
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/sysdep.c b/ports/sysdeps/unix/sysv/linux/hppa/sysdep.c
new file mode 100644
index 000000000..8637c513d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/sysdep.c
@@ -0,0 +1,78 @@
+/* Copyright (C) 1997, 1998, 2001, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdarg.h>
+#include <sysdep.h>
+#include <errno.h>
+
+extern int __syscall_error(int err_no);
+extern long int syscall (long int __sysno, ...) __THROW;
+
+/* This routine is jumped to by all the syscall handlers, to stash
+ an error number into errno. */
+int
+__syscall_error (int err_no)
+{
+ __set_errno (err_no);
+ return -1;
+}
+
+
+/* HPPA implements syscall() in 'C'; the assembler version would
+ typically be in syscall.S. Also note that we have INLINE_SYSCALL,
+ INTERNAL_SYSCALL, and all the generated pure assembly syscall wrappers.
+ How often the function is used is unknown. */
+
+long int
+syscall (long int __sysno, ...)
+{
+ /* FIXME: Keep this matching INLINE_SYSCALL for hppa */
+ va_list args;
+ long int arg0, arg1, arg2, arg3, arg4, arg5;
+ long int __sys_res;
+
+ /* Load varargs */
+ va_start (args, __sysno);
+ arg0 = va_arg (args, long int);
+ arg1 = va_arg (args, long int);
+ arg2 = va_arg (args, long int);
+ arg3 = va_arg (args, long int);
+ arg4 = va_arg (args, long int);
+ arg5 = va_arg (args, long int);
+ va_end (args);
+
+ {
+ register unsigned long int __res asm("r28");
+ LOAD_ARGS_6 (arg0, arg1, arg2, arg3, arg4, arg5)
+ asm volatile (SAVE_ASM_PIC
+ " ble 0x100(%%sr2, %%r0) \n"
+ " copy %1, %%r20 \n"
+ LOAD_ASM_PIC
+ : "=r" (__res)
+ : "r" (__sysno) ASM_ARGS_6
+ : "memory", CALL_CLOB_REGS CLOB_ARGS_6);
+ __sys_res = __res;
+ }
+ if ((unsigned long int) __sys_res >= (unsigned long int) -4095)
+ {
+ __set_errno (-__sys_res);
+ __sys_res = -1;
+ }
+ return __sys_res;
+}
+
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/sysdep.h b/ports/sysdeps/unix/sysv/linux/hppa/sysdep.h
new file mode 100644
index 000000000..b302d37f7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/sysdep.h
@@ -0,0 +1,484 @@
+/* Assembler macros for PA-RISC.
+ Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper, <drepper@cygnus.com>, August 1999.
+ Linux/PA-RISC changes by Philipp Rumpf, <prumpf@tux.org>, March 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <asm/unistd.h>
+#include <sysdeps/generic/sysdep.h>
+#include <sys/syscall.h>
+
+#undef ASM_LINE_SEP
+#define ASM_LINE_SEP !
+
+#undef SYS_ify
+#define SYS_ify(syscall_name) (__NR_##syscall_name)
+
+/* WARNING: TREG must be a callee saves register so
+ that it doesn't have to be restored after a call
+ to another function */
+#ifdef PIC
+# define TREG %r3
+# define SAVE_PIC(SREG) copy %r19, SREG ASM_LINE_SEP
+# define LOAD_PIC(LREG) copy LREG, %r19 ASM_LINE_SEP
+/* Inline assembly defines */
+# define TREG_ASM "%r4" /* Cant clobber r3, it holds framemarker */
+# define SAVE_ASM_PIC " copy %%r19, %" TREG_ASM "\n"
+# define LOAD_ASM_PIC " copy %" TREG_ASM ", %%r19\n"
+# define USING_TREG TREG_ASM,
+#else
+# define TREG %r3
+# define SAVE_PIC(SREG) nop ASM_LINE_SEP
+# define LOAD_PIC(LREG) nop ASM_LINE_SEP
+/* Inline assembly defines */
+# define TREG_ASM
+# define SAVE_ASM_PIC "nop \n"
+# define LOAD_ASM_PIC "nop \n"
+# define USING_TREG
+#endif
+
+#ifdef __ASSEMBLER__
+
+/* Syntactic details of assembler. */
+
+#define ALIGNARG(log2) log2
+
+/* For Linux we can use the system call table in the header file
+ /usr/include/asm/unistd.h
+ of the kernel. But these symbols do not follow the SYS_* syntax
+ so we have to redefine the `SYS_ify' macro here. */
+#undef SYS_ify
+#define SYS_ify(syscall_name) __NR_##syscall_name
+
+/* ELF-like local names start with `.L'. */
+#undef L
+#define L(name) .L##name
+
+/* Linux uses a negative return value to indicate syscall errors,
+ unlike most Unices, which use the condition codes' carry flag.
+
+ Since version 2.1 the return value of a system call might be
+ negative even if the call succeeded. E.g., the `lseek' system call
+ might return a large offset. Therefore we must not anymore test
+ for < 0, but test for a real error by making sure the value in %eax
+ is a real error number. Linus said he will make sure the no syscall
+ returns a value in -1 .. -4095 as a valid result so we can safely
+ test with -4095. */
+
+/* We don't want the label for the error handle to be global when we define
+ it here. */
+/*#ifdef PIC
+# define SYSCALL_ERROR_LABEL 0f
+#else
+# define SYSCALL_ERROR_LABEL syscall_error
+#endif*/
+
+/* Argument manipulation from the stack for preparing to
+ make a syscall */
+
+#define DOARGS_0 /* nothing */
+#define DOARGS_1 /* nothing */
+#define DOARGS_2 /* nothing */
+#define DOARGS_3 /* nothing */
+#define DOARGS_4 /* nothing */
+#define DOARGS_5 ldw -52(%sp), %r22 ASM_LINE_SEP
+#define DOARGS_6 DOARGS_5 ldw -56(%sp), %r21 ASM_LINE_SEP
+
+#define UNDOARGS_0 /* nothing */
+#define UNDOARGS_1 /* nothing */
+#define UNDOARGS_2 /* nothing */
+#define UNDOARGS_3 /* nothing */
+#define UNDOARGS_4 /* nothing */
+#define UNDOARGS_5 /* nothing */
+#define UNDOARGS_6 /* nothing */
+
+/* Define an entry point visible from C.
+
+ There is currently a bug in gdb which prevents us from specifying
+ incomplete stabs information. Fake some entries here which specify
+ the current source file. */
+#define ENTRY(name) \
+ .text ASM_LINE_SEP \
+ .align ALIGNARG(4) ASM_LINE_SEP \
+ .export C_SYMBOL_NAME(name) ASM_LINE_SEP \
+ .type C_SYMBOL_NAME(name),@function ASM_LINE_SEP \
+ C_LABEL(name) ASM_LINE_SEP \
+ .PROC ASM_LINE_SEP \
+ .CALLINFO FRAME=64,CALLS,SAVE_RP,ENTRY_GR=3 ASM_LINE_SEP \
+ .ENTRY ASM_LINE_SEP \
+ /* SAVE_RP says we do */ ASM_LINE_SEP \
+ stw %rp, -20(%sr0,%sp) ASM_LINE_SEP \
+ /*FIXME: Call mcount? (carefull with stack!) */
+
+/* Some syscall wrappers do not call other functions, and
+ hence are classified as leaf, so add NO_CALLS for gdb */
+#define ENTRY_LEAF(name) \
+ .text ASM_LINE_SEP \
+ .align ALIGNARG(4) ASM_LINE_SEP \
+ .export C_SYMBOL_NAME(name) ASM_LINE_SEP \
+ .type C_SYMBOL_NAME(name),@function ASM_LINE_SEP \
+ C_LABEL(name) ASM_LINE_SEP \
+ .PROC ASM_LINE_SEP \
+ .CALLINFO FRAME=64,NO_CALLS,SAVE_RP,ENTRY_GR=3 ASM_LINE_SEP \
+ .ENTRY ASM_LINE_SEP \
+ /* SAVE_RP says we do */ ASM_LINE_SEP \
+ stw %rp, -20(%sr0,%sp) ASM_LINE_SEP \
+ /*FIXME: Call mcount? (carefull with stack!) */
+
+#undef END
+#define END(name) \
+ .EXIT ASM_LINE_SEP \
+ .PROCEND ASM_LINE_SEP \
+.size C_SYMBOL_NAME(name), .-C_SYMBOL_NAME(name) ASM_LINE_SEP
+
+/* If compiled for profiling, call `mcount' at the start
+ of each function. No, don't bother. gcc will put the
+ call in for us. */
+#define CALL_MCOUNT /* Do nothing. */
+
+/* syscall wrappers consist of
+ #include <sysdep.h>
+ PSEUDO(...)
+ ret
+ PSEUDO_END(...)
+
+ which means
+ ENTRY(name)
+ DO_CALL(...)
+ nop
+ bv 0(2)
+ nop
+*/
+
+#define PSEUDO(name, syscall_name, args) \
+ ENTRY (name) ASM_LINE_SEP \
+ /* If necc. load args from stack */ ASM_LINE_SEP \
+ DOARGS_##args ASM_LINE_SEP \
+ DO_CALL (syscall_name, args) ASM_LINE_SEP \
+ UNDOARGS_##args ASM_LINE_SEP \
+ nop ASM_LINE_SEP
+
+#define ret \
+ /* Return value set by ERRNO code */ ASM_LINE_SEP \
+ bv,n 0(2) ASM_LINE_SEP
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) \
+ END (name)
+
+/* We don't set the errno on the return from the syscall */
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+ ENTRY_LEAF (name) ASM_LINE_SEP \
+ DOARGS_##args ASM_LINE_SEP \
+ DO_CALL_NOERRNO (syscall_name, args) ASM_LINE_SEP \
+ UNDOARGS_##args ASM_LINE_SEP \
+ nop ASM_LINE_SEP
+
+#define ret_NOERRNO ret
+
+#undef PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(name) \
+ END (name)
+
+/* This has to return the error value */
+#undef PSEUDO_ERRVAL
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+ ENTRY_LEAF (name) ASM_LINE_SEP \
+ DOARGS_##args ASM_LINE_SEP \
+ DO_CALL_ERRVAL (syscall_name, args) ASM_LINE_SEP \
+ UNDOARGS_##args ASM_LINE_SEP \
+ nop ASM_LINE_SEP
+
+#define ret_ERRVAL ret
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name) \
+ END(name)
+
+#undef JUMPTARGET
+#define JUMPTARGET(name) name
+#define SYSCALL_PIC_SETUP /* Nothing. */
+
+
+/* FIXME: This comment is not true.
+ * All the syscall assembly macros rely on finding the approriate
+ SYSCALL_ERROR_LABEL or rather HANDLER. */
+
+/* int * __errno_location(void) so you have to store your value
+ into the return address! */
+#define DEFAULT_SYSCALL_ERROR_HANDLER \
+ .import __errno_location,code ASM_LINE_SEP \
+ /* branch to errno handler */ ASM_LINE_SEP \
+ bl __errno_location,%rp ASM_LINE_SEP
+
+/* Here are the myriad of configuration options that the above can
+ work for... what we've done is provide the framework for future
+ changes if required to each section */
+
+#ifdef PIC
+# if RTLD_PRIVATE_ERRNO
+# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
+# else /* !RTLD_PRIVATE_ERRNO */
+# if defined _LIBC_REENTRANT
+# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
+# else /* !_LIBC_REENTRANT */
+# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
+# endif /* _LIBC_REENTRANT */
+# endif /* RTLD_PRIVATE_ERRNO */
+#else
+# ifndef _LIBC_REENTRANT
+# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
+# else
+# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
+# endif
+#endif
+
+
+/* Linux takes system call arguments in registers:
+ syscall number gr20
+ arg 1 gr26
+ arg 2 gr25
+ arg 3 gr24
+ arg 4 gr23
+ arg 5 gr22
+ arg 6 gr21
+
+ The compiler calls us by the C convention:
+ syscall number in the DO_CALL macro
+ arg 1 gr26
+ arg 2 gr25
+ arg 3 gr24
+ arg 4 gr23
+ arg 5 -52(sp)
+ arg 6 -56(sp)
+
+ gr22 and gr21 are caller-saves, so we can just load the arguments
+ there and generally be happy. */
+
+/* the cmpb...no_error code below inside DO_CALL
+ * is intended to mimic the if (__sys_res...)
+ * code inside INLINE_SYSCALL
+ */
+#define NO_ERROR -0x1000
+
+#undef DO_CALL
+#define DO_CALL(syscall_name, args) \
+ copy TREG,%r1 ASM_LINE_SEP \
+ copy %sp,TREG ASM_LINE_SEP \
+ /* Create a frame */ ASM_LINE_SEP \
+ stwm %r1, 64(%sp) ASM_LINE_SEP \
+ stw %rp, -20(%sp) ASM_LINE_SEP \
+ stw TREG, -4(%sp) ASM_LINE_SEP \
+ /* Save r19 */ ASM_LINE_SEP \
+ SAVE_PIC(TREG) ASM_LINE_SEP \
+ /* Do syscall, delay loads # */ ASM_LINE_SEP \
+ ble 0x100(%sr2,%r0) ASM_LINE_SEP \
+ ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
+ ldi NO_ERROR,%r1 ASM_LINE_SEP \
+ cmpb,>>=,n %r1,%ret0,L(pre_end) ASM_LINE_SEP \
+ /* Restore r19 from TREG */ ASM_LINE_SEP \
+ LOAD_PIC(TREG) /* delay */ ASM_LINE_SEP \
+ SYSCALL_ERROR_HANDLER ASM_LINE_SEP \
+ /* Use TREG for temp storage */ ASM_LINE_SEP \
+ copy %ret0, TREG /* delay */ ASM_LINE_SEP \
+ /* OPTIMIZE: Don't reload r19 */ ASM_LINE_SEP \
+ /* do a -1*syscall_ret0 */ ASM_LINE_SEP \
+ sub %r0, TREG, TREG ASM_LINE_SEP \
+ /* Store into errno location */ ASM_LINE_SEP \
+ stw TREG, 0(%sr0,%ret0) ASM_LINE_SEP \
+ /* return -1 as error */ ASM_LINE_SEP \
+ ldo -1(%r0), %ret0 ASM_LINE_SEP \
+L(pre_end): ASM_LINE_SEP \
+ /* Restore return pointer */ ASM_LINE_SEP \
+ ldw -84(%sp),%rp ASM_LINE_SEP \
+ /* Restore our frame, restoring TREG */ ASM_LINE_SEP \
+ ldwm -64(%sp), TREG ASM_LINE_SEP
+
+/* We do nothing with the return, except hand it back to someone else */
+#undef DO_CALL_NOERRNO
+#define DO_CALL_NOERRNO(syscall_name, args) \
+ /* No need to store r19 */ ASM_LINE_SEP \
+ ble 0x100(%sr2,%r0) ASM_LINE_SEP \
+ ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
+ /* Caller will restore r19 */ ASM_LINE_SEP
+
+/* Here, we return the ERRVAL in assembly, note we don't call the
+ error handler function, but we do 'negate' the return _IF_
+ it's an error. Not sure if this is the right semantic. */
+
+#undef DO_CALL_ERRVAL
+#define DO_CALL_ERRVAL(syscall_name, args) \
+ /* No need to store r19 */ ASM_LINE_SEP \
+ ble 0x100(%sr2,%r0) ASM_LINE_SEP \
+ ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
+ /* Caller will restore r19 */ ASM_LINE_SEP \
+ ldi NO_ERROR,%r1 ASM_LINE_SEP \
+ cmpb,>>=,n %r1,%ret0,0f ASM_LINE_SEP \
+ sub %r0, %ret0, %ret0 ASM_LINE_SEP \
+0: ASM_LINE_SEP
+
+
+#else
+
+/* GCC has to be warned that a syscall may clobber all the ABI
+ registers listed as "caller-saves", see page 8, Table 2
+ in section 2.2.6 of the PA-RISC RUN-TIME architecture
+ document. However! r28 is the result and will conflict with
+ the clobber list so it is left out. Also the input arguments
+ registers r20 -> r26 will conflict with the list so they
+ are treated specially. Although r19 is clobbered by the syscall
+ we cannot say this because it would violate ABI, thus we say
+ TREG is clobbered and use that register to save/restore r19
+ across the syscall. */
+
+#define CALL_CLOB_REGS "%r1", "%r2", USING_TREG \
+ "%r20", "%r29", "%r31"
+
+#undef INLINE_SYSCALL
+#define INLINE_SYSCALL(name, nr, args...) \
+({ \
+ long __sys_res; \
+ { \
+ register unsigned long __res asm("r28"); \
+ LOAD_ARGS_##nr(args) \
+ /* FIXME: HACK save/load r19 around syscall */ \
+ asm volatile( \
+ SAVE_ASM_PIC \
+ " ble 0x100(%%sr2, %%r0)\n" \
+ " ldi %1, %%r20\n" \
+ LOAD_ASM_PIC \
+ : "=r" (__res) \
+ : "i" (SYS_ify(name)) ASM_ARGS_##nr \
+ : "memory", CALL_CLOB_REGS CLOB_ARGS_##nr \
+ ); \
+ __sys_res = (long)__res; \
+ } \
+ if ( (unsigned long)__sys_res >= (unsigned long)-4095 ){ \
+ __set_errno(-__sys_res); \
+ __sys_res = -1; \
+ } \
+ __sys_res; \
+})
+
+/* INTERNAL_SYSCALL_DECL - Allows us to setup some function static
+ value to use within the context of the syscall
+ INTERNAL_SYSCALL_ERROR_P - Returns 0 if it wasn't an error, 1 otherwise
+ You are allowed to use the syscall result (val) and the DECL error
+ variable to determine what went wrong.
+ INTERLAL_SYSCALL_ERRNO - Munges the val/err pair into the error number.
+ In our case we just flip the sign. */
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err)
+
+/* Equivalent to (val < 0)&&(val > -4095) which is what we want */
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+ ((unsigned long)val >= (unsigned long)-4095)
+
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
+
+/* Similar to INLINE_SYSCALL but we don't set errno */
+#undef INTERNAL_SYSCALL
+#define INTERNAL_SYSCALL(name, err, nr, args...) \
+({ \
+ long __sys_res; \
+ { \
+ register unsigned long __res asm("r28"); \
+ LOAD_ARGS_##nr(args) \
+ /* FIXME: HACK save/load r19 around syscall */ \
+ asm volatile( \
+ SAVE_ASM_PIC \
+ " ble 0x100(%%sr2, %%r0)\n" \
+ " ldi %1, %%r20\n" \
+ LOAD_ASM_PIC \
+ : "=r" (__res) \
+ : "i" (SYS_ify(name)) ASM_ARGS_##nr \
+ : "memory", CALL_CLOB_REGS CLOB_ARGS_##nr \
+ ); \
+ __sys_res = (long)__res; \
+ } \
+ __sys_res; \
+ })
+
+
+/* The _NCS variant allows non-constant syscall numbers. */
+#undef INTERNAL_SYSCALL_NCS
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+({ \
+ long __sys_res; \
+ { \
+ register unsigned long __res asm("r28"); \
+ LOAD_ARGS_##nr(args) \
+ /* FIXME: HACK save/load r19 around syscall */ \
+ asm volatile( \
+ SAVE_ASM_PIC \
+ " ble 0x100(%%sr2, %%r0)\n" \
+ " copy %1, %%r20\n" \
+ LOAD_ASM_PIC \
+ : "=r" (__res) \
+ : "r" (name) ASM_ARGS_##nr \
+ : "memory", CALL_CLOB_REGS CLOB_ARGS_##nr \
+ ); \
+ __sys_res = (long)__res; \
+ } \
+ __sys_res; \
+ })
+
+
+
+#define LOAD_ARGS_0()
+#define LOAD_ARGS_1(r26) \
+ register unsigned long __r26 __asm__("r26") = (unsigned long)(r26); \
+ LOAD_ARGS_0()
+#define LOAD_ARGS_2(r26,r25) \
+ register unsigned long __r25 __asm__("r25") = (unsigned long)(r25); \
+ LOAD_ARGS_1(r26)
+#define LOAD_ARGS_3(r26,r25,r24) \
+ register unsigned long __r24 __asm__("r24") = (unsigned long)(r24); \
+ LOAD_ARGS_2(r26,r25)
+#define LOAD_ARGS_4(r26,r25,r24,r23) \
+ register unsigned long __r23 __asm__("r23") = (unsigned long)(r23); \
+ LOAD_ARGS_3(r26,r25,r24)
+#define LOAD_ARGS_5(r26,r25,r24,r23,r22) \
+ register unsigned long __r22 __asm__("r22") = (unsigned long)(r22); \
+ LOAD_ARGS_4(r26,r25,r24,r23)
+#define LOAD_ARGS_6(r26,r25,r24,r23,r22,r21) \
+ register unsigned long __r21 __asm__("r21") = (unsigned long)(r21); \
+ LOAD_ARGS_5(r26,r25,r24,r23,r22)
+
+/* Even with zero args we use r20 for the syscall number */
+#define ASM_ARGS_0
+#define ASM_ARGS_1 ASM_ARGS_0, "r" (__r26)
+#define ASM_ARGS_2 ASM_ARGS_1, "r" (__r25)
+#define ASM_ARGS_3 ASM_ARGS_2, "r" (__r24)
+#define ASM_ARGS_4 ASM_ARGS_3, "r" (__r23)
+#define ASM_ARGS_5 ASM_ARGS_4, "r" (__r22)
+#define ASM_ARGS_6 ASM_ARGS_5, "r" (__r21)
+
+/* The registers not listed as inputs but clobbered */
+#define CLOB_ARGS_6
+#define CLOB_ARGS_5 CLOB_ARGS_6, "%r21"
+#define CLOB_ARGS_4 CLOB_ARGS_5, "%r22"
+#define CLOB_ARGS_3 CLOB_ARGS_4, "%r23"
+#define CLOB_ARGS_2 CLOB_ARGS_3, "%r24"
+#define CLOB_ARGS_1 CLOB_ARGS_2, "%r25"
+#define CLOB_ARGS_0 CLOB_ARGS_1, "%r26"
+
+#endif /* __ASSEMBLER__ */
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/umount.c b/ports/sysdeps/unix/sysv/linux/hppa/umount.c
new file mode 100644
index 000000000..e7c569089
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/umount.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Huggins-Daines <dhd@debian.org>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Since we don't have an oldumount system call, do what the kernel
+ does down here. */
+
+extern long int __umount2 (const char *name, int flags);
+
+long int
+__umount (const char *name)
+{
+ return __umount2 (name, 0);
+}
+
+weak_alias (__umount, umount);
diff --git a/ports/sysdeps/unix/sysv/linux/hppa/xstat.c b/ports/sysdeps/unix/sysv/linux/hppa/xstat.c
new file mode 100644
index 000000000..e9869f550
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/hppa/xstat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/xstat.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/Makefile b/ports/sysdeps/unix/sysv/linux/m68k/Makefile
new file mode 100644
index 000000000..6bb4f6b81
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/Makefile
@@ -0,0 +1,17 @@
+# Linux/m68k uses Motorola asm syntax and the ELF format.
+
+m68k-syntax-flag = -DMOTOROLA_SYNTAX
+
+ifeq ($(subdir),misc)
+sysdep_routines += mremap
+sysdep_headers += sys/reg.h
+endif
+
+ifeq ($(subdir),elf)
+sysdep-others += lddlibc4
+install-bin += lddlibc4
+endif
+
+ifeq ($(subdir),resource)
+sysdep_routines += oldgetrlimit64
+endif
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/Versions b/ports/sysdeps/unix/sysv/linux/m68k/Versions
new file mode 100644
index 000000000..0799bf310
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/Versions
@@ -0,0 +1,32 @@
+libc {
+ GLIBC_2.0 {
+ # Exception handling support functions from libgcc
+ __register_frame; __register_frame_table; __deregister_frame;
+ __frame_state_for; __register_frame_info_table;
+
+ # c*
+ cacheflush;
+ }
+ GLIBC_2.2 {
+ # functions used in other libraries
+ __xstat64; __fxstat64; __lxstat64;
+
+ # a*
+ alphasort64;
+
+ # g*
+ glob64;
+
+ # New rlimit interface
+ getrlimit; setrlimit; getrlimit64;
+
+ # r*
+ readdir64; readdir64_r;
+
+ # s*
+ scandir64;
+
+ # v*
+ versionsort64;
+ }
+}
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/alphasort64.c b/ports/sysdeps/unix/sysv/linux/m68k/alphasort64.c
new file mode 100644
index 000000000..0b5ae47d2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/alphasort64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/alphasort64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/bits/a.out.h b/ports/sysdeps/unix/sysv/linux/m68k/bits/a.out.h
new file mode 100644
index 000000000..0fb52c381
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/bits/a.out.h
@@ -0,0 +1,3 @@
+#ifndef __A_OUT_GNU_H__
+# error "Never use <bits/a.out.h> directly; include <a.out.h> instead."
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/bits/fcntl.h b/ports/sysdeps/unix/sysv/linux/m68k/bits/fcntl.h
new file mode 100644
index 000000000..90c0a481e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/bits/fcntl.h
@@ -0,0 +1,188 @@
+/* O_*, F_*, FD_* bit values for Linux.
+ Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+
+#include <sys/types.h>
+
+/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
+ located on an ext2 file system */
+#define O_ACCMODE 0003
+#define O_RDONLY 00
+#define O_WRONLY 01
+#define O_RDWR 02
+#define O_CREAT 0100 /* not fcntl */
+#define O_EXCL 0200 /* not fcntl */
+#define O_NOCTTY 0400 /* not fcntl */
+#define O_TRUNC 01000 /* not fcntl */
+#define O_APPEND 02000
+#define O_NONBLOCK 04000
+#define O_NDELAY O_NONBLOCK
+#define O_SYNC 010000
+#define O_FSYNC O_SYNC
+#define O_ASYNC 020000
+
+#ifdef __USE_GNU
+# define O_DIRECTORY 040000 /* Must be a directory. */
+# define O_NOFOLLOW 0100000 /* Do not follow links. */
+# define O_DIRECT 0200000 /* Direct disk access. */
+# define O_NOATIME 01000000 /* Do not set atime. */
+#endif
+
+/* For now Linux has synchronisity options for data and read operations.
+ We define the symbols here but let them do the same as O_SYNC since
+ this is a superset. */
+#if defined __USE_POSIX199309 || defined __USE_UNIX98
+# define O_DSYNC O_SYNC /* Synchronize data. */
+# define O_RSYNC O_SYNC /* Synchronize read operations. */
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define O_LARGEFILE 0400000
+#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. */
+#ifndef __USE_FILE_OFFSET64
+# define F_GETLK 5 /* Get record locking info. */
+# define F_SETLK 6 /* Set record locking info (non-blocking). */
+# define F_SETLKW 7 /* Set record locking info (blocking). */
+#else
+# define F_GETLK F_GETLK64 /* Get record locking info. */
+# define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/
+# define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
+#endif
+#define F_GETLK64 12 /* Get record locking info. */
+#define F_SETLK64 13 /* Set record locking info (non-blocking). */
+#define F_SETLKW64 14 /* Set record locking info (blocking). */
+
+#if defined __USE_BSD || defined __USE_UNIX98
+# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */
+# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETSIG 10 /* Set number of signal to be sent. */
+# define F_GETSIG 11 /* Get number of signal to be sent. */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETLEASE 1024 /* Set a lease. */
+# define F_GETLEASE 1025 /* Enquire what lease is active. */
+# define F_NOTIFY 1026 /* Request notfications on a directory. */
+#endif
+
+/* For F_[GET|SET]FL. */
+#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
+
+/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
+#define F_RDLCK 0 /* Read lock. */
+#define F_WRLCK 1 /* Write lock. */
+#define F_UNLCK 2 /* Remove lock. */
+
+/* For old implementation of bsd flock(). */
+#define F_EXLCK 4 /* or 3 */
+#define F_SHLCK 8 /* or 4 */
+
+#ifdef __USE_BSD
+/* Operations for bsd flock(), also used by the kernel implementation. */
+# define LOCK_SH 1 /* shared lock */
+# define LOCK_EX 2 /* exclusive lock */
+# define LOCK_NB 4 /* or'd with one of the above to prevent
+ blocking */
+# define LOCK_UN 8 /* remove lock */
+#endif
+
+#ifdef __USE_GNU
+# define LOCK_MAND 32 /* This is a mandatory flock: */
+# define LOCK_READ 64 /* ... which allows concurrent read operations. */
+# define LOCK_WRITE 128 /* ... which allows concurrent write operations. */
+# define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */
+#endif
+
+#ifdef __USE_GNU
+/* Types of directory notifications that may be requested with F_NOTIFY. */
+# define DN_ACCESS 0x00000001 /* File accessed. */
+# define DN_MODIFY 0x00000002 /* File modified. */
+# define DN_CREATE 0x00000004 /* File created. */
+# define DN_DELETE 0x00000008 /* File removed. */
+# define DN_RENAME 0x00000010 /* File renamed. */
+# define DN_ATTRIB 0x00000020 /* File changed attibutes. */
+# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
+#endif
+
+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'). */
+#ifndef __USE_FILE_OFFSET64
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+#else
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+#endif
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+
+#ifdef __USE_LARGEFILE64
+struct flock64
+ {
+ 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'). */
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+#endif
+
+/* Define some more compatibility macros to be backward compatible with
+ BSD systems which did not managed to hide these kernel macros. */
+#ifdef __USE_BSD
+# define FAPPEND O_APPEND
+# define FFSYNC O_FSYNC
+# define FASYNC O_ASYNC
+# define FNONBLOCK O_NONBLOCK
+# define FNDELAY O_NDELAY
+#endif /* Use BSD. */
+
+/* Advise to `posix_fadvise'. */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
+# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
+# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
+# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
+# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
+#endif
+
+__BEGIN_DECLS
+
+/* Provide kernel hint to read ahead. */
+extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
+ __THROW;
+
+__END_DECLS
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/bits/mman.h b/ports/sysdeps/unix/sysv/linux/m68k/bits/mman.h
new file mode 100644
index 000000000..fbec1a03f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/bits/mman.h
@@ -0,0 +1,102 @@
+/* Definitions for POSIX memory map interface. Linux/m68k version.
+ Copyright (C) 1997, 2000, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_MMAN_H
+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
+#endif
+
+/* The following definitions basically come from the kernel headers.
+ But the kernel header is not namespace clean. */
+
+
+/* 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_READ 0x1 /* Page can be read. */
+#define PROT_WRITE 0x2 /* Page can be written. */
+#define PROT_EXEC 0x4 /* Page can be executed. */
+#define PROT_NONE 0x0 /* Page can not be accessed. */
+#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
+ growsdown vma (mprotect only). */
+#define PROT_GROWSUP 0x02000000 /* Extend change to start of
+ growsup vma (mprotect only). */
+
+/* Sharing types (must choose one and only one of these). */
+#define MAP_SHARED 0x01 /* Share changes. */
+#define MAP_PRIVATE 0x02 /* Changes are private. */
+#ifdef __USE_MISC
+# define MAP_TYPE 0x0f /* Mask for type of mapping. */
+#endif
+
+/* Other flags. */
+#define MAP_FIXED 0x10 /* Interpret addr exactly. */
+#ifdef __USE_MISC
+# define MAP_FILE 0
+# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
+# define MAP_ANON MAP_ANONYMOUS
+#endif
+
+/* These are Linux-specific. */
+#ifdef __USE_MISC
+# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
+# define MAP_DENYWRITE 0x00800 /* ETXTBSY */
+# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
+# define MAP_LOCKED 0x02000 /* Lock the mapping. */
+# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
+# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
+# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
+#endif
+
+/* Flags to `msync'. */
+#define MS_ASYNC 1 /* Sync memory asynchronously. */
+#define MS_SYNC 4 /* Synchronous memory sync. */
+#define MS_INVALIDATE 2 /* Invalidate the caches. */
+
+/* Flags for `mlockall'. */
+#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
+#define MCL_FUTURE 2 /* Lock all additions to address
+ space. */
+
+/* Flags for `mremap'. */
+#ifdef __USE_GNU
+# define MREMAP_MAYMOVE 1
+# define MREMAP_FIXED 2
+#endif
+
+/* Advice to `madvise'. */
+#ifdef __USE_BSD
+# 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_DONTFORK 10 /* Do not inherit across fork. */
+# define MADV_DOFORK 11 /* Do inherit across fork. */
+#endif
+
+/* The POSIX people had to invent similar names for the same things. */
+#ifdef __USE_XOPEN2K
+# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
+# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
+# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
+# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/bits/poll.h b/ports/sysdeps/unix/sysv/linux/m68k/bits/poll.h
new file mode 100644
index 000000000..f7a739315
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/bits/poll.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 1997, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_POLL_H
+# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
+#endif
+
+/* Event types that can be polled for. These bits may be set in `events'
+ to indicate the interesting event types; they will appear in `revents'
+ to indicate the status of the file descriptor. */
+#define POLLIN 0x001 /* There is data to read. */
+#define POLLPRI 0x002 /* There is urgent data to read. */
+#define POLLOUT 0x004 /* Writing now will not block. */
+
+#ifdef __USE_XOPEN
+/* These values are defined in XPG4.2. */
+# define POLLRDNORM 0x040 /* Normal data may be read. */
+# define POLLRDBAND 0x080 /* Priority data may be read. */
+# define POLLWRNORM POLLOUT /* Writing now will not block. */
+# define POLLWRBAND 0x100 /* Priority data may be written. */
+#endif
+
+/* Event types always implicitly polled for. These bits need not be set in
+ `events', but they will appear in `revents' to indicate the status of
+ the file descriptor. */
+#define POLLERR 0x008 /* Error condition. */
+#define POLLHUP 0x010 /* Hung up. */
+#define POLLNVAL 0x020 /* Invalid polling request. */
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/bits/stat.h b/ports/sysdeps/unix/sysv/linux/m68k/bits/stat.h
new file mode 100644
index 000000000..dc06b13e2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/bits/stat.h
@@ -0,0 +1,164 @@
+/* Copyright (C) 1992,95,96,97,98,99,2000,2001,2002
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_STAT_H
+# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+/* Versions of the `struct stat' data structure. */
+#define _STAT_VER_LINUX_OLD 1
+#define _STAT_VER_KERNEL 1
+#define _STAT_VER_SVR4 2
+#define _STAT_VER_LINUX 3
+#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
+
+/* Versions of the `xmknod' interface. */
+#define _MKNOD_VER_LINUX 1
+#define _MKNOD_VER_SVR4 2
+#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
+
+
+struct stat
+ {
+ __dev_t st_dev; /* Device. */
+ unsigned short int __pad1;
+#ifndef __USE_FILE_OFFSET64
+ __ino_t st_ino; /* File serial number. */
+#else
+ __ino_t __st_ino; /* 32bit file serial number. */
+#endif
+ __mode_t st_mode; /* File mode. */
+ __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.*/
+ __dev_t st_rdev; /* Device number, if device. */
+ unsigned short int __pad2;
+#ifndef __USE_FILE_OFFSET64
+ __off_t st_size; /* Size of file, in bytes. */
+#else
+ __off64_t st_size; /* Size of file, in bytes. */
+#endif
+ __blksize_t st_blksize; /* Optimal block size for I/O. */
+
+#ifndef __USE_FILE_OFFSET64
+ __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
+#else
+ __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
+#endif
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
+ __time_t st_atime; /* Time of last access. */
+ unsigned long int st_atimensec; /* Nscecs of last access. */
+ __time_t st_mtime; /* Time of last modification. */
+ unsigned long int st_mtimensec; /* Nsecs of last modification. */
+ __time_t st_ctime; /* Time of last status change. */
+ unsigned long int st_ctimensec; /* Nsecs of last status change. */
+#endif
+#ifndef __USE_FILE_OFFSET64
+ unsigned long int __unused4;
+ unsigned long int __unused5;
+#else
+ __ino64_t st_ino; /* File serial number. */
+#endif
+ };
+
+#ifdef __USE_LARGEFILE64
+struct stat64
+ {
+ __dev_t st_dev; /* Device. */
+ unsigned short int __pad1;
+
+ __ino_t __st_ino; /* 32bit file serial number. */
+ __mode_t st_mode; /* File mode. */
+ __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.*/
+ __dev_t st_rdev; /* Device number, if device. */
+ unsigned short int __pad2;
+ __off64_t st_size; /* Size of file, in bytes. */
+ __blksize_t st_blksize; /* Optimal block size for I/O. */
+
+ __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+#else
+ __time_t st_atime; /* Time of last access. */
+ unsigned long int st_atimensec; /* Nscecs of last access. */
+ __time_t st_mtime; /* Time of last modification. */
+ unsigned long int st_mtimensec; /* Nsecs of last modification. */
+ __time_t st_ctime; /* Time of last status change. */
+ unsigned long int st_ctimensec; /* Nsecs of last status change. */
+#endif
+ __ino64_t st_ino; /* File serial number. */
+ };
+#endif
+
+/* Tell code we have these members. */
+#define _STATBUF_ST_BLKSIZE
+#define _STATBUF_ST_RDEV
+/* Nanosecond resolution time values are supported. */
+#define _STATBUF_ST_NSEC
+
+/* 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. */
+
+/* POSIX.1b objects. Note that these macros always evaluate to zero. But
+ they do it by enforcing the correct use of the macros. */
+#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
+#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
+#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
+
+/* 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. */
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/brk.c b/ports/sysdeps/unix/sysv/linux/m68k/brk.c
new file mode 100644
index 000000000..6b2c92852
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/brk.c
@@ -0,0 +1,48 @@
+/* brk system call for Linux/m68k.
+ Copyright (C) 1996, 1997, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sysdep.h>
+
+void *__curbrk = 0;
+
+/* Old braindamage in GCC's crtstuff.c requires this symbol in an attempt
+ to work around different old braindamage in the old Linux/x86 ELF
+ dynamic linker. Sigh. */
+weak_alias (__curbrk, ___brk_addr)
+
+int
+__brk (void *addr)
+{
+ void *newbrk;
+
+ INTERNAL_SYSCALL_DECL (err);
+ newbrk = (void *) INTERNAL_SYSCALL (brk, err, 1, addr);
+ __curbrk = newbrk;
+
+ if (newbrk < addr)
+ {
+ __set_errno (ENOMEM);
+ return -1;
+ }
+
+ return 0;
+}
+weak_alias (__brk, brk)
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/chown.c b/ports/sysdeps/unix/sysv/linux/m68k/chown.c
new file mode 100644
index 000000000..e7193dc23
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/chown.c
@@ -0,0 +1,69 @@
+/* Copyright (C) 1998,2000,2002,2003,2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+#include <linux/posix_types.h>
+#include <kernel-features.h>
+
+#ifdef __NR_chown32
+# if __ASSUME_32BITUIDS == 0
+/* This variable is shared with all files that need to check for 32bit
+ uids. */
+extern int __libc_missing_32bit_uids;
+# endif
+#endif /* __NR_chown32 */
+
+int
+__chown (const char *file, uid_t owner, gid_t group)
+{
+#if __ASSUME_32BITUIDS > 0
+ return INLINE_SYSCALL (chown32, 3, CHECK_STRING (file), owner, group);
+#else
+# ifdef __NR_chown32
+ if (__libc_missing_32bit_uids <= 0)
+ {
+ int result;
+ int saved_errno = errno;
+
+ result = INLINE_SYSCALL (chown32, 3, CHECK_STRING (file), owner, group);
+ if (result == 0 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_chown32 */
+
+ if (((owner + 1) > (gid_t) ((__kernel_uid_t) -1U))
+ || ((group + 1) > (gid_t) ((__kernel_gid_t) -1U)))
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return INLINE_SYSCALL (chown, 3, CHECK_STRING (file), owner, group);
+#endif
+}
+libc_hidden_def (__chown)
+weak_alias (__chown, chown)
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/clone.S b/ports/sysdeps/unix/sysv/linux/m68k/clone.S
new file mode 100644
index 000000000..6baf723d9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/clone.S
@@ -0,0 +1,66 @@
+/* Copyright (C) 1996,97,98,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab (schwab@issan.informatik.uni-dortmund.de)
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* clone is even more special than fork as it mucks with stacks
+ and invokes a function in the right context after its all over. */
+
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
+
+ .text
+ENTRY (__clone)
+
+ /* Sanity check arguments. */
+ movel #-EINVAL, %d0
+ movel 4(%sp), %a0 /* no NULL function pointers */
+ tstl %a0
+ jeq SYSCALL_ERROR_LABEL
+ movel 8(%sp), %a1 /* no NULL stack pointers */
+ tstl %a1
+ jeq SYSCALL_ERROR_LABEL
+
+ /* Allocate space and copy the argument onto the new stack. */
+ movel 16(%sp), -(%a1)
+
+ /* Do the system call */
+ exg %d2, %a1 /* save %d2 and get stack pointer */
+ movel 12(%sp), %d1 /* get flags */
+ movel #SYS_ify (clone), %d0
+ trap #0
+ exg %d2, %a1 /* restore %d2 */
+
+ tstl %d0
+ jmi SYSCALL_ERROR_LABEL
+ jeq thread_start
+
+ rts
+
+thread_start:
+ subl %fp, %fp /* terminate the stack frame */
+ jsr (%a0)
+ movel %d0, %d1
+ movel #SYS_ify (exit), %d0
+ trap #0
+
+PSEUDO_END (__clone)
+
+weak_alias (__clone, clone)
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/dl-librecon.h b/ports/sysdeps/unix/sysv/linux/m68k/dl-librecon.h
new file mode 100644
index 000000000..dbb4e7571
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/dl-librecon.h
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/dl-librecon.h>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/fchown.c b/ports/sysdeps/unix/sysv/linux/m68k/fchown.c
new file mode 100644
index 000000000..3a69ecc9e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/fchown.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fchown.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/fchownat.c b/ports/sysdeps/unix/sysv/linux/m68k/fchownat.c
new file mode 100644
index 000000000..6cc093222
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/fchownat.c
@@ -0,0 +1,122 @@
+/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+#include <linux/posix_types.h>
+#include <kernel-features.h>
+
+#ifdef __NR_chown32
+# if __ASSUME_32BITUIDS == 0
+/* This variable is shared with all files that need to check for 32bit
+ uids. */
+extern int __libc_missing_32bit_uids;
+# endif
+#endif /* __NR_chown32 */
+
+int
+fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag)
+{
+ if (flag & ~AT_SYMLINK_NOFOLLOW)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ char *buf = NULL;
+
+ if (fd != AT_FDCWD && file[0] != '/')
+ {
+ size_t filelen = strlen (file);
+ static const char procfd[] = "/proc/self/fd/%d/%s";
+ /* Buffer for the path name we are going to use. It consists of
+ - the string /proc/self/fd/
+ - the file descriptor number
+ - the file name provided.
+ The final NUL is included in the sizeof. A bit of overhead
+ due to the format elements compensates for possible negative
+ numbers. */
+ size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen;
+ buf = alloca (buflen);
+
+ __snprintf (buf, buflen, procfd, fd, file);
+ file = buf;
+ }
+
+ int result;
+ INTERNAL_SYSCALL_DECL (err);
+
+#if __ASSUME_32BITUIDS > 0
+ if (flag & AT_SYMLINK_NOFOLLOW)
+ result = INTERNAL_SYSCALL (lchown32, err, 3, CHECK_STRING (file), owner,
+ group);
+ else
+ result = INTERNAL_SYSCALL (chown32, err, 3, CHECK_STRING (file), owner,
+ group);
+#else
+# ifdef __NR_chown32
+ if (__libc_missing_32bit_uids <= 0)
+ {
+ if (flag & AT_SYMLINK_NOFOLLOW)
+ result = INTERNAL_SYSCALL (lchown32, err, 3, CHECK_STRING (file),
+ owner, group);
+ else
+ result = INTERNAL_SYSCALL (chown32, err, 3, CHECK_STRING (file), owner,
+ group);
+
+ if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+ return result;
+ if (INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS)
+ goto fail;
+
+ __libc_missing_32bit_uids = 1;
+ }
+# endif /* __NR_chown32 */
+
+ if (((owner + 1) > (gid_t) ((__kernel_uid_t) -1U))
+ || ((group + 1) > (gid_t) ((__kernel_gid_t) -1U)))
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ if (flag & AT_SYMLINK_NOFOLLOW)
+ result = INTERNAL_SYSCALL (lchown, err, 3, CHECK_STRING (file), owner,
+ group);
+ else
+ result = INTERNAL_SYSCALL (chown, err, 3, CHECK_STRING (file), owner,
+ group);
+#endif
+
+ if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0))
+ {
+ fail:
+ __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf);
+ result = -1;
+ }
+
+ return result;
+}
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/fcntl.c b/ports/sysdeps/unix/sysv/linux/m68k/fcntl.c
new file mode 100644
index 000000000..ea951bc4f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/fcntl.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/fxstat.c b/ports/sysdeps/unix/sysv/linux/m68k/fxstat.c
new file mode 100644
index 000000000..4f219f0b9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/fxstat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fxstat.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/fxstatat.c b/ports/sysdeps/unix/sysv/linux/m68k/fxstatat.c
new file mode 100644
index 000000000..0f8b3135d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/fxstatat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fxstatat.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/getdents64.c b/ports/sysdeps/unix/sysv/linux/m68k/getdents64.c
new file mode 100644
index 000000000..0c75fb5a0
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/getdents64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getdents64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/getegid.c b/ports/sysdeps/unix/sysv/linux/m68k/getegid.c
new file mode 100644
index 000000000..37b4b4a53
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/getegid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getegid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/geteuid.c b/ports/sysdeps/unix/sysv/linux/m68k/geteuid.c
new file mode 100644
index 000000000..ebcb555b5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/geteuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/geteuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/getgid.c b/ports/sysdeps/unix/sysv/linux/m68k/getgid.c
new file mode 100644
index 000000000..0a4d6061f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/getgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/getgroups.c b/ports/sysdeps/unix/sysv/linux/m68k/getgroups.c
new file mode 100644
index 000000000..102ea24e1
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/getgroups.c
@@ -0,0 +1,2 @@
+/* We also have to rewrite the kernel gid_t to the user land type. */
+#include <sysdeps/unix/sysv/linux/i386/getgroups.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/getmsg.c b/ports/sysdeps/unix/sysv/linux/m68k/getmsg.c
new file mode 100644
index 000000000..3a1fa0852
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/getmsg.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getmsg.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/getpagesize.c b/ports/sysdeps/unix/sysv/linux/m68k/getpagesize.c
new file mode 100644
index 000000000..f7ffdc518
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/getpagesize.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@suse.de>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+#include <sys/param.h>
+#include <errno.h>
+
+#include <ldsodefs.h>
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* Return the system page size. */
+int
+__getpagesize ()
+{
+#ifdef __NR_getpagesize
+ int result;
+#endif
+
+ if (GLRO(dl_pagesize) != 0)
+ return GLRO(dl_pagesize);
+
+#ifdef __NR_getpagesize
+ INTERNAL_SYSCALL_DECL (err);
+ result = INTERNAL_SYSCALL (getpagesize, err, 0);
+ /* The only possible error is ENOSYS. */
+ if (!INTERNAL_SYSCALL_ERROR_P (result, err))
+ return result;
+#endif
+
+ return 4096;
+}
+libc_hidden_def (__getpagesize)
+weak_alias (__getpagesize, getpagesize)
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/getresgid.c b/ports/sysdeps/unix/sysv/linux/m68k/getresgid.c
new file mode 100644
index 000000000..b703a414c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/getresgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getresgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/getresuid.c b/ports/sysdeps/unix/sysv/linux/m68k/getresuid.c
new file mode 100644
index 000000000..0b14cefe3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/getresuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getresuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/getrlimit.c b/ports/sysdeps/unix/sysv/linux/m68k/getrlimit.c
new file mode 100644
index 000000000..fc06dbd64
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/getrlimit.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getrlimit.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/getrlimit64.c b/ports/sysdeps/unix/sysv/linux/m68k/getrlimit64.c
new file mode 100644
index 000000000..fef018f47
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/getrlimit64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getrlimit64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/getsysstats.c b/ports/sysdeps/unix/sysv/linux/m68k/getsysstats.c
new file mode 100644
index 000000000..23207e9bc
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/getsysstats.c
@@ -0,0 +1,37 @@
+/* Determine various system internal values, Linux/m68k version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@suse.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+/* We need to define a special parser for /proc/cpuinfo. */
+#define GET_NPROCS_PARSER(FP, BUFFER, RESULT) \
+ do \
+ { \
+ (RESULT) = 0; \
+ /* Read all lines and count the lines starting with the string \
+ "CPU:". We don't have to fear extremely long lines since \
+ the kernel will not generate them. 8192 bytes are really \
+ enough. */ \
+ while (fgets_unlocked (BUFFER, sizeof (BUFFER), FP) != NULL) \
+ if (strncmp (BUFFER, "CPU:", 4) == 0) \
+ ++(RESULT); \
+ } \
+ while (0)
+
+#include <sysdeps/unix/sysv/linux/getsysstats.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/getuid.c b/ports/sysdeps/unix/sysv/linux/m68k/getuid.c
new file mode 100644
index 000000000..d682c79a4
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/getuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/glob64.c b/ports/sysdeps/unix/sysv/linux/m68k/glob64.c
new file mode 100644
index 000000000..82a9a296a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/glob64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/glob64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/lchown.c b/ports/sysdeps/unix/sysv/linux/m68k/lchown.c
new file mode 100644
index 000000000..c89de99ba
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/lchown.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/lchown.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/ldconfig.h b/ports/sysdeps/unix/sysv/linux/m68k/ldconfig.h
new file mode 100644
index 000000000..953f192bc
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/ldconfig.h
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/ldconfig.h>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/lockf64.c b/ports/sysdeps/unix/sysv/linux/m68k/lockf64.c
new file mode 100644
index 000000000..a88f5a784
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/lockf64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/lockf64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/lxstat.c b/ports/sysdeps/unix/sysv/linux/m68k/lxstat.c
new file mode 100644
index 000000000..2371cd971
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/lxstat.c
@@ -0,0 +1,2 @@
+#include <sysdeps/unix/sysv/linux/i386/lxstat.c>
+
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/mmap.S b/ports/sysdeps/unix/sysv/linux/m68k/mmap.S
new file mode 100644
index 000000000..086212a42
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/mmap.S
@@ -0,0 +1,43 @@
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+ .text
+ENTRY (__mmap)
+
+ move.l #SYS_ify (mmap), %d0 /* System call number in %d0. */
+
+ lea 4(%sp), %a0 /* Address of args is 1st arg. */
+ move.l %a0, %d1
+
+ /* Do the system call trap. */
+ trap #0
+
+ /* Kludge: negative numbers are among the legal return values.
+ If %d0 is between -4096 and 0 then there was an error. */
+ cmp.l #-4096, %d0
+ jhi SYSCALL_ERROR_LABEL
+
+ /* Successful; return the syscall's value. Copy it to %a0 because
+ mmap is declared to return a pointer. */
+ move.l %d0, %a0
+ rts
+PSEUDO_END (__mmap)
+
+weak_alias (__mmap, mmap)
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/mremap.S b/ports/sysdeps/unix/sysv/linux/m68k/mremap.S
new file mode 100644
index 000000000..68d961b55
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/mremap.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 1996 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+/* The mremap system call is special because it needs to return
+ its value in register %a0. */
+
+ .text
+PSEUDO (__mremap, mremap, 4)
+ move.l %d0, %a0
+ rts
+PSEUDO_END (__mremap)
+weak_alias (__mremap, mremap)
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/msgctl.c b/ports/sysdeps/unix/sysv/linux/m68k/msgctl.c
new file mode 100644
index 000000000..9f9b8431a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/msgctl.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/msgctl.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c b/ports/sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c
new file mode 100644
index 000000000..4c27e957b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/putmsg.c b/ports/sysdeps/unix/sysv/linux/m68k/putmsg.c
new file mode 100644
index 000000000..ebc1680ca
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/putmsg.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/putmsg.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/readdir64.c b/ports/sysdeps/unix/sysv/linux/m68k/readdir64.c
new file mode 100644
index 000000000..2ea26dd40
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/readdir64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/readdir64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/readdir64_r.c b/ports/sysdeps/unix/sysv/linux/m68k/readdir64_r.c
new file mode 100644
index 000000000..9f54f897e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/readdir64_r.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/readdir64_r.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/register-dump.h b/ports/sysdeps/unix/sysv/linux/m68k/register-dump.h
new file mode 100644
index 000000000..a7ac3ca01
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/register-dump.h
@@ -0,0 +1,214 @@
+/* Dump registers.
+ Copyright (C) 1998, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stddef.h>
+#include <sys/uio.h>
+#include <stdio-common/_itoa.h>
+
+/* We will print the register dump in this format:
+
+ D0: XXXXXXXX D1: XXXXXXXX D2: XXXXXXXX D3: XXXXXXXX
+ D4: XXXXXXXX D5: XXXXXXXX D6: XXXXXXXX D7: XXXXXXXX
+ A0: XXXXXXXX A1: XXXXXXXX A2: XXXXXXXX A3: XXXXXXXX
+ A4: XXXXXXXX A5: XXXXXXXX A6: XXXXXXXX A7: XXXXXXXX
+ PC: XXXXXXXX SR: XXXX
+
+ OldMask: XXXXXXXX Vector: XXXX
+
+ FP0: XXXXXXXXXXXXXXXXXXXXXXXX FP1: XXXXXXXXXXXXXXXXXXXXXXXX
+ FP2: XXXXXXXXXXXXXXXXXXXXXXXX FP3: XXXXXXXXXXXXXXXXXXXXXXXX
+ FP4: XXXXXXXXXXXXXXXXXXXXXXXX FP5: XXXXXXXXXXXXXXXXXXXXXXXX
+ FP6: XXXXXXXXXXXXXXXXXXXXXXXX FP7: XXXXXXXXXXXXXXXXXXXXXXXX
+ FPCR: XXXXXXXX FPSR: XXXXXXXX FPIAR: XXXXXXXX
+
+*/
+
+/* Linux saves only the call-clobbered registers in the sigcontext. We
+ need to use a trampoline that saves the rest so that the C code can
+ access them. We use the sc_fpstate field, since the handler is not
+ supposed to return anyway, thus it doesn't matter that it's clobbered. */
+
+/* static */ void catch_segfault (int, int, struct sigcontext *);
+
+/* Dummy function so that we can use asm with arguments. */
+static void __attribute_used__
+__dummy__ (void)
+{
+ asm ("\n\
+catch_segfault:\n\
+ move.l 12(%%sp),%%a0\n\
+ lea %c0(%%a0),%%a0\n\
+ /* Clear the first 4 bytes to make it a null fp state, just\n\
+ in case the handler does return. */\n\
+ clr.l (%%a0)+\n\
+ movem.l %%d2-%%d7/%%a2-%%a6,(%%a0)\n\
+ fmovem.x %%fp2-%%fp7,11*4(%%a0)\n\
+ jra real_catch_segfault"
+ : : "n" (offsetof (struct sigcontext, sc_fpstate)));
+}
+#define catch_segfault(a,b) \
+ __attribute_used__ real_catch_segfault(a,b)
+
+static void
+hexvalue (unsigned long int value, char *buf, size_t len)
+{
+ char *cp = _itoa_word (value, buf + len, 16, 0);
+ while (cp > buf)
+ *--cp = '0';
+}
+
+static void
+register_dump (int fd, struct sigcontext *ctx)
+{
+ char regs[20][8];
+ char fpregs[11][24];
+ struct iovec iov[63], *next_iov = iov;
+ unsigned long *p = (unsigned long *) ctx->sc_fpstate + 1;
+
+#define ADD_STRING(str) \
+ next_iov->iov_base = (char *) (str); \
+ next_iov->iov_len = strlen (str); \
+ ++next_iov
+#define ADD_MEM(str, len) \
+ next_iov->iov_base = (str); \
+ next_iov->iov_len = (len); \
+ ++next_iov
+
+ /* Generate strings of register contents. */
+ hexvalue (ctx->sc_d0, regs[0], 8);
+ hexvalue (ctx->sc_d1, regs[1], 8);
+ hexvalue (*p++, regs[2], 8);
+ hexvalue (*p++, regs[3], 8);
+ hexvalue (*p++, regs[4], 8);
+ hexvalue (*p++, regs[5], 8);
+ hexvalue (*p++, regs[6], 8);
+ hexvalue (*p++, regs[7], 8);
+ hexvalue (ctx->sc_a0, regs[8], 8);
+ hexvalue (ctx->sc_a1, regs[9], 8);
+ hexvalue (*p++, regs[10], 8);
+ hexvalue (*p++, regs[11], 8);
+ hexvalue (*p++, regs[12], 8);
+ hexvalue (*p++, regs[13], 8);
+ hexvalue (*p++, regs[14], 8);
+ hexvalue (ctx->sc_usp, regs[15], 8);
+ hexvalue (ctx->sc_pc, regs[16], 8);
+ hexvalue (ctx->sc_sr, regs[17], 4);
+ hexvalue (ctx->sc_mask, regs[18], 8);
+ hexvalue (ctx->sc_formatvec & 0xfff, regs[19], 4);
+ hexvalue (ctx->sc_fpregs[0], fpregs[0], 8);
+ hexvalue (ctx->sc_fpregs[1], fpregs[0] + 8, 8);
+ hexvalue (ctx->sc_fpregs[2], fpregs[0] + 16, 8);
+ hexvalue (ctx->sc_fpregs[3], fpregs[1], 8);
+ hexvalue (ctx->sc_fpregs[4], fpregs[1] + 8, 8);
+ hexvalue (ctx->sc_fpregs[5], fpregs[1] + 16, 8);
+ hexvalue (*p++, fpregs[2], 8);
+ hexvalue (*p++, fpregs[2] + 8, 8);
+ hexvalue (*p++, fpregs[2] + 16, 8);
+ hexvalue (*p++, fpregs[3], 8);
+ hexvalue (*p++, fpregs[3] + 8, 8);
+ hexvalue (*p++, fpregs[3] + 16, 8);
+ hexvalue (*p++, fpregs[4], 8);
+ hexvalue (*p++, fpregs[4] + 8, 8);
+ hexvalue (*p++, fpregs[4] + 16, 8);
+ hexvalue (*p++, fpregs[5], 8);
+ hexvalue (*p++, fpregs[5] + 8, 8);
+ hexvalue (*p++, fpregs[5] + 16, 8);
+ hexvalue (*p++, fpregs[6], 8);
+ hexvalue (*p++, fpregs[6] + 8, 8);
+ hexvalue (*p++, fpregs[6] + 16, 8);
+ hexvalue (*p++, fpregs[7], 8);
+ hexvalue (*p++, fpregs[7] + 8, 8);
+ hexvalue (*p++, fpregs[7] + 16, 8);
+ hexvalue (ctx->sc_fpcntl[0], fpregs[8], 8);
+ hexvalue (ctx->sc_fpcntl[1], fpregs[9], 8);
+ hexvalue (ctx->sc_fpcntl[2], fpregs[10], 8);
+
+ /* Generate the output. */
+ ADD_STRING ("Register dump:\n\n D0: ");
+ ADD_MEM (regs[0], 8);
+ ADD_STRING (" D1: ");
+ ADD_MEM (regs[1], 8);
+ ADD_STRING (" D2: ");
+ ADD_MEM (regs[2], 8);
+ ADD_STRING (" D3: ");
+ ADD_MEM (regs[3], 8);
+ ADD_STRING ("\n D4: ");
+ ADD_MEM (regs[4], 8);
+ ADD_STRING (" D5: ");
+ ADD_MEM (regs[5], 8);
+ ADD_STRING (" D6: ");
+ ADD_MEM (regs[6], 8);
+ ADD_STRING (" D7: ");
+ ADD_MEM (regs[7], 8);
+ ADD_STRING ("\n A0: ");
+ ADD_MEM (regs[8], 8);
+ ADD_STRING (" A1: ");
+ ADD_MEM (regs[9], 8);
+ ADD_STRING (" A2: ");
+ ADD_MEM (regs[10], 8);
+ ADD_STRING (" A3: ");
+ ADD_MEM (regs[11], 8);
+ ADD_STRING ("\n A4: ");
+ ADD_MEM (regs[12], 8);
+ ADD_STRING (" A5: ");
+ ADD_MEM (regs[13], 8);
+ ADD_STRING (" A6: ");
+ ADD_MEM (regs[14], 8);
+ ADD_STRING (" A7: ");
+ ADD_MEM (regs[15], 8);
+ ADD_STRING ("\n PC: ");
+ ADD_MEM (regs[16], 8);
+ ADD_STRING (" SR: ");
+ ADD_MEM (regs[17], 4);
+
+ ADD_STRING ("\n\n OldMask: ");
+ ADD_MEM (regs[18], 8);
+ ADD_STRING (" Vector: ");
+ ADD_MEM (regs[19], 4);
+
+ ADD_STRING ("\n\n FP0: ");
+ ADD_MEM (fpregs[0], 24);
+ ADD_STRING (" FP1: ");
+ ADD_MEM (fpregs[1], 24);
+ ADD_STRING ("\n FP2: ");
+ ADD_MEM (fpregs[2], 24);
+ ADD_STRING (" FP3: ");
+ ADD_MEM (fpregs[3], 24);
+ ADD_STRING ("\n FP4: ");
+ ADD_MEM (fpregs[4], 24);
+ ADD_STRING (" FP5: ");
+ ADD_MEM (fpregs[5], 24);
+ ADD_STRING ("\n FP6: ");
+ ADD_MEM (fpregs[6], 24);
+ ADD_STRING (" FP7: ");
+ ADD_MEM (fpregs[7], 24);
+ ADD_STRING ("\n FPCR: ");
+ ADD_MEM (fpregs[8], 8);
+ ADD_STRING (" FPSR: ");
+ ADD_MEM (fpregs[9], 8);
+ ADD_STRING (" FPIAR: ");
+ ADD_MEM (fpregs[10], 8);
+ ADD_STRING ("\n");
+
+ /* Write the stuff out. */
+ writev (fd, iov, next_iov - iov);
+}
+
+#define REGISTER_DUMP register_dump (fd, ctx)
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/scandir64.c b/ports/sysdeps/unix/sysv/linux/m68k/scandir64.c
new file mode 100644
index 000000000..506fd8877
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/scandir64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/scandir64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/semctl.c b/ports/sysdeps/unix/sysv/linux/m68k/semctl.c
new file mode 100644
index 000000000..e9b1a483c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/semctl.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/semctl.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/semtimedop.S b/ports/sysdeps/unix/sysv/linux/m68k/semtimedop.S
new file mode 100644
index 000000000..2775c124c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/semtimedop.S
@@ -0,0 +1,60 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@suse.de>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#define SYSOP_semtimedop 4
+
+#define SVRSP 8 /* saved register space */
+#define PARMS 4+SVRSP /* space for 3 saved regs */
+#define SEMID PARMS
+#define SOPS SEMID+4
+#define NSOPS SOPS+4
+#define TIMEOUT NSOPS+4
+
+ .text
+ENTRY (semtimedop)
+
+ /* Save registers. */
+ move.l %d2, %a1
+ move.l %d3, -(%sp)
+ move.l %d5, -(%sp)
+
+ move.l #SYSOP_semtimedop, %d1
+ move.l SEMID(%sp), %d2
+ move.l NSOPS(%sp), %d3
+ move.l SOPS(%sp), %d5
+ move.l TIMEOUT(%sp), %a0
+ move.l #SYS_ify (ipc), %d0
+
+ trap #0
+
+ /* Restore registers. */
+ move.l (%sp)+, %d5
+ move.l (%sp)+, %d3
+ move.l %a1, %d2
+
+ /* Check for error. */
+ tst.l %d0
+ jmi SYSCALL_ERROR_LABEL
+
+ /* Successful; return the syscall's value. */
+ ret
+
+PSEUDO_END (semtimedop)
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/setegid.c b/ports/sysdeps/unix/sysv/linux/m68k/setegid.c
new file mode 100644
index 000000000..2e3a54c89
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/setegid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setegid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/seteuid.c b/ports/sysdeps/unix/sysv/linux/m68k/seteuid.c
new file mode 100644
index 000000000..18e41d08c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/seteuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/seteuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/setfsgid.c b/ports/sysdeps/unix/sysv/linux/m68k/setfsgid.c
new file mode 100644
index 000000000..088671256
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/setfsgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setfsgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/setfsuid.c b/ports/sysdeps/unix/sysv/linux/m68k/setfsuid.c
new file mode 100644
index 000000000..a9f22eb8a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/setfsuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setfsuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/setgid.c b/ports/sysdeps/unix/sysv/linux/m68k/setgid.c
new file mode 100644
index 000000000..377021d9e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/setgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/setgroups.c b/ports/sysdeps/unix/sysv/linux/m68k/setgroups.c
new file mode 100644
index 000000000..0e7086278
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/setgroups.c
@@ -0,0 +1,2 @@
+/* We also have to rewrite the kernel gid_t to the user land type. */
+#include <sysdeps/unix/sysv/linux/i386/setgroups.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/setregid.c b/ports/sysdeps/unix/sysv/linux/m68k/setregid.c
new file mode 100644
index 000000000..99c57ad20
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/setregid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setregid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/setresgid.c b/ports/sysdeps/unix/sysv/linux/m68k/setresgid.c
new file mode 100644
index 000000000..daca1a483
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/setresgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setresgid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/setresuid.c b/ports/sysdeps/unix/sysv/linux/m68k/setresuid.c
new file mode 100644
index 000000000..3aeabe9ad
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/setresuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setresuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/setreuid.c b/ports/sysdeps/unix/sysv/linux/m68k/setreuid.c
new file mode 100644
index 000000000..8ad61226e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/setreuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setreuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/setrlimit.c b/ports/sysdeps/unix/sysv/linux/m68k/setrlimit.c
new file mode 100644
index 000000000..bfaef74c3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/setrlimit.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setrlimit.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/setuid.c b/ports/sysdeps/unix/sysv/linux/m68k/setuid.c
new file mode 100644
index 000000000..de394379b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/setuid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/setuid.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/shmctl.c b/ports/sysdeps/unix/sysv/linux/m68k/shmctl.c
new file mode 100644
index 000000000..7eac6380d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/shmctl.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/shmctl.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/sigcontextinfo.h b/ports/sysdeps/unix/sysv/linux/m68k/sigcontextinfo.h
new file mode 100644
index 000000000..b7e08cfc9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/sigcontextinfo.h
@@ -0,0 +1,26 @@
+/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define SIGCONTEXT int _code, struct sigcontext *
+#define SIGCONTEXT_EXTRA_ARGS _code,
+#define GET_PC(ctx) ((void *) (ctx)->sc_pc)
+#define GET_FRAME(ctx) ((void *) __builtin_frame_address (1))
+#define GET_STACK(ctx) ((void *) (ctx)->sc_usp)
+#define CALL_SIGHANDLER(handler, signo, ctx) \
+ (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/socket.S b/ports/sysdeps/unix/sysv/linux/m68k/socket.S
new file mode 100644
index 000000000..1d10f33e1
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/socket.S
@@ -0,0 +1,111 @@
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep-cancel.h>
+#include <socketcall.h>
+
+#define P(a, b) P2(a, b)
+#define P2(a, b) a##b
+
+ .text
+/* The socket-oriented system calls are handled unusally in Linux.
+ They are all gated through the single `socketcall' system call number.
+ `socketcall' takes two arguments: the first is the subcode, specifying
+ which socket function is being called; and the second is a pointer to
+ the arguments to the specific function.
+
+ The .S files for the other calls just #define socket and #include this. */
+
+#ifndef __socket
+#ifndef NO_WEAK_ALIAS
+#define __socket P(__,socket)
+#else
+#define __socket socket
+#endif
+#endif
+
+.globl __socket
+ENTRY (__socket)
+#if defined NEED_CANCELLATION && defined CENABLE
+ SINGLE_THREAD_P
+ jne 1f
+#endif
+
+ /* Save registers. */
+ move.l %d2, %a0
+
+ move.l #SYS_ify (socketcall), %d0 /* System call number in %d0. */
+
+ /* Use ## so `socket' is a separate token that might be #define'd. */
+ move.l #P (SOCKOP_,socket), %d1 /* Subcode is first arg to syscall. */
+ lea 4(%sp), %a1 /* Address of args is 2nd arg. */
+ move.l %a1, %d2
+
+ /* Do the system call trap. */
+ trap #0
+
+ /* Restore registers. */
+ move.l %a0, %d2
+
+ /* %d0 is < 0 if there was an error. */
+ tst.l %d0
+ jmi SYSCALL_ERROR_LABEL
+
+ /* Successful; return the syscall's value. */
+ rts
+
+#if defined NEED_CANCELLATION && defined CENABLE
+1: /* Enable asynchronous cancellation. */
+ CENABLE
+
+ /* Save registers. */
+ move.l %d2, -(%sp)
+ move.l %d0, -(%sp)
+
+ move.l #SYS_ify (socketcall), %d0 /* System call number in %d0. */
+
+ /* Use ## so `socket' is a separate token that might be #define'd. */
+ move.l #P (SOCKOP_,socket), %d1 /* Subcode is first arg to syscall. */
+ lea 4+8(%sp), %a1 /* Address of args is 2nd arg. */
+ move.l %a1, %d2
+
+ /* Do the system call trap. */
+ trap #0
+
+ /* Restore cancellation. */
+ move.l %d0, %d2
+ CDISABLE
+ addq.l #4, %sp
+ move.l %d2, %d0
+
+ /* Restore registers. */
+ move.l (%sp)+, %d2
+
+ /* %d0 is < 0 if there was an error. */
+ tst.l %d0
+ jmi SYSCALL_ERROR_LABEL
+
+ /* Successful; return the syscall's value. */
+ rts
+#endif
+
+PSEUDO_END (__socket)
+
+#ifndef NO_WEAK_ALIAS
+weak_alias (__socket, socket)
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/sys/procfs.h b/ports/sysdeps/unix/sysv/linux/m68k/sys/procfs.h
new file mode 100644
index 000000000..27abf8ef5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/sys/procfs.h
@@ -0,0 +1,126 @@
+/* Copyright (C) 1996, 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_PROCFS_H
+#define _SYS_PROCFS_H 1
+
+/* This is somewhat modelled after the file of the same name on SVR4
+ systems. It provides a definition of the core file format for ELF
+ used on Linux. It doesn't have anything to do with the /proc file
+ system, even though Linux has one.
+
+ Anyway, the whole purpose of this file is for GDB and GDB only.
+ Don't read too much into it. Don't use it for anything other than
+ GDB unless you know what you are doing. */
+
+#include <features.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/user.h>
+
+__BEGIN_DECLS
+
+/* Type for a general-purpose register. */
+typedef unsigned long elf_greg_t;
+
+/* And the whole bunch of them. We could have used `struct
+ user_regs_struct' directly in the typedef, but tradition says that
+ the register set is an array, which does have some peculiar
+ semantics, so leave it that way. */
+#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+/* Register set for the floating-point registers. */
+typedef struct user_m68kfp_struct elf_fpregset_t;
+
+
+/* Signal info. */
+struct elf_siginfo
+ {
+ int si_signo; /* Signal number. */
+ int si_code; /* Extra code. */
+ int si_errno; /* Errno. */
+ };
+
+
+/* Definitions to generate Intel SVR4-like core files. These mostly
+ have the same names as the SVR4 types with "elf_" tacked on the
+ front to prevent clashes with Linux definitions, and the typedef
+ forms have been avoided. This is mostly like the SVR4 structure,
+ but more Linuxy, with things that Linux does not support and which
+ GDB doesn't really use excluded. */
+
+struct elf_prstatus
+ {
+ struct elf_siginfo pr_info; /* Info associated with signal. */
+ short int pr_cursig; /* Current signal. */
+ unsigned long int pr_sigpend; /* Set of pending signals. */
+ unsigned long int pr_sighold; /* Set of held signals. */
+ __pid_t pr_pid;
+ __pid_t pr_ppid;
+ __pid_t pr_pgrp;
+ __pid_t pr_sid;
+ struct timeval pr_utime; /* User time. */
+ struct timeval pr_stime; /* System time. */
+ struct timeval pr_cutime; /* Cumulative user time. */
+ struct timeval pr_cstime; /* Cumulative system time. */
+ elf_gregset_t pr_reg; /* GP registers. */
+ int pr_fpvalid; /* True if math copro being used. */
+ };
+
+
+#define ELF_PRARGSZ (80) /* Number of chars for args. */
+
+struct elf_prpsinfo
+ {
+ char pr_state; /* Numeric process state. */
+ char pr_sname; /* Char for pr_state. */
+ char pr_zomb; /* Zombie. */
+ char pr_nice; /* Nice val. */
+ unsigned long int pr_flag; /* Flags. */
+ unsigned short int pr_uid;
+ unsigned short int pr_gid;
+ int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+ /* Lots missing */
+ char pr_fname[16]; /* Filename of executable. */
+ char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
+ };
+
+
+/* The rest of this file provides the types for emulation of the
+ Solaris <proc_service.h> interfaces that should be implemented by
+ users of libthread_db. */
+
+/* Addresses. */
+typedef void *psaddr_t;
+
+/* Register sets. Linux has different names. */
+typedef elf_gregset_t prgregset_t;
+typedef elf_fpregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+ therefore have only one PID type. */
+typedef __pid_t lwpid_t;
+
+/* Process status and info. In the end we do provide typedefs for them. */
+typedef struct elf_prstatus prstatus_t;
+typedef struct elf_prpsinfo prpsinfo_t;
+
+__END_DECLS
+
+#endif /* sys/procfs.h */
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/sys/reg.h b/ports/sysdeps/unix/sysv/linux/m68k/sys/reg.h
new file mode 100644
index 000000000..418f8323f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/sys/reg.h
@@ -0,0 +1,89 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_REG_H
+#define _SYS_REG_H 1
+
+/* Index into an array of 4 byte integers returned from ptrace for
+ location of the users' stored general purpose registers. */
+
+enum
+{
+ PT_D1 = 0,
+#define PT_D1 PT_D1
+ PT_D2 = 1,
+#define PT_D2 PT_D2
+ PT_D3 = 2,
+#define PT_D3 PT_D3
+ PT_D4 = 3,
+#define PT_D4 PT_D4
+ PT_D5 = 4,
+#define PT_D5 PT_D5
+ PT_D6 = 5,
+#define PT_D6 PT_D6
+ PT_D7 = 6,
+#define PT_D7 PT_D7
+ PT_A0 = 7,
+#define PT_A0 PT_A0
+ PT_A1 = 8,
+#define PT_A1 PT_A1
+ PT_A2 = 9,
+#define PT_A2 PT_A2
+ PT_A3 = 10,
+#define PT_A3 PT_A3
+ PT_A4 = 11,
+#define PT_A4 PT_A4
+ PT_A5 = 12,
+#define PT_A5 PT_A5
+ PT_A6 = 13,
+#define PT_A6 PT_A6
+ PT_D0 = 14,
+#define PT_D0 PT_D0
+ PT_USP = 15,
+#define PT_USP PT_USP
+ PT_ORIG_D0 = 16,
+#define PT_ORIG_D0 PT_ORIG_D0
+ PT_SR = 17,
+#define PT_SR PT_SR
+ PT_PC = 18,
+#define PT_PC PT_PC
+ PT_FP0 = 21,
+#define PT_FP0 PT_FP0
+ PT_FP1 = 24,
+#define PT_FP1 PT_FP1
+ PT_FP2 = 27,
+#define PT_FP2 PT_FP2
+ PT_FP3 = 30,
+#define PT_FP3 PT_FP3
+ PT_FP4 = 33,
+#define PT_FP4 PT_FP4
+ PT_FP5 = 36,
+#define PT_FP5 PT_FP5
+ PT_FP6 = 39,
+#define PT_FP6 PT_FP6
+ PT_FP7 = 42,
+#define PT_FP7 PT_FP7
+ PT_FPCR = 45,
+#define PT_FPCR PT_FPCR
+ PT_FPSR = 46,
+#define PT_FPSR PT_FPSR
+ PT_FPIAR = 47
+#define PT_FPIAR PT_FPIAR
+};
+
+#endif /* _SYS_REG_H */
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/sys/ucontext.h b/ports/sysdeps/unix/sysv/linux/m68k/sys/ucontext.h
new file mode 100644
index 000000000..3c441dc5c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/sys/ucontext.h
@@ -0,0 +1,109 @@
+/* Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* System V/m68k ABI compliant context switching support. */
+
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <signal.h>
+
+/* Type for general register. */
+typedef int greg_t;
+
+/* Number of general registers. */
+#define NGREG 18
+
+/* Container for all general registers. */
+typedef greg_t gregset_t[NGREG];
+
+/* Number of each register is the `gregset_t' array. */
+enum
+{
+ R_D0 = 0,
+#define R_D0 R_D0
+ R_D1 = 1,
+#define R_D1 R_D1
+ R_D2 = 2,
+#define R_D2 R_D2
+ R_D3 = 3,
+#define R_D3 R_D3
+ R_D4 = 4,
+#define R_D4 R_D4
+ R_D5 = 5,
+#define R_D5 R_D5
+ R_D6 = 6,
+#define R_D6 R_D6
+ R_D7 = 7,
+#define R_D7 R_D7
+ R_A0 = 8,
+#define R_A0 R_A0
+ R_A1 = 9,
+#define R_A1 R_A1
+ R_A2 = 10,
+#define R_A2 R_A2
+ R_A3 = 11,
+#define R_A3 R_A3
+ R_A4 = 12,
+#define R_A4 R_A4
+ R_A5 = 13,
+#define R_A5 R_A5
+ R_A6 = 14,
+#define R_A6 R_A6
+ R_A7 = 15,
+#define R_A7 R_A7
+ R_SP = 15,
+#define R_SP R_SP
+ R_PC = 16,
+#define R_PC R_PC
+ R_PS = 17
+#define R_PS R_PS
+};
+
+/* Structure to describe FPU registers. */
+typedef struct fpregset
+{
+ int f_fpregs[8][3];
+ int f_pcr;
+ int f_psr;
+ int f_fpiaddr;
+} fpregset_t;
+
+/* Context to describe whole processor state. */
+typedef struct
+{
+ int version;
+ gregset_t gregs;
+ fpregset_t fpregs;
+} mcontext_t;
+
+#define MCONTEXT_VERSION 2
+
+/* Userlevel context. */
+typedef struct ucontext
+{
+ unsigned long int uc_flags;
+ struct ucontext *uc_link;
+ __sigset_t uc_sigmask;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ long int uc_filler[174];
+} ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/syscall.S b/ports/sysdeps/unix/sysv/linux/m68k/syscall.S
new file mode 100644
index 000000000..4f2c747c2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/syscall.S
@@ -0,0 +1,33 @@
+/* Copyright (C) 1996, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+/* Please consult the file sysdeps/unix/sysv/linux/m68k/sysdep.h for
+ more information about the value -4095 used below.*/
+
+ .text
+ENTRY (syscall)
+ move.l 4(%sp), %d0 /* Load syscall number. */
+ _DOARGS_5 (24) /* Frob arguments. */
+ trap &0 /* Do the system call. */
+ UNDOARGS_5 /* Unfrob arguments. */
+ cmp.l &-4095, %d0 /* Check %d0 for error. */
+ jcc SYSCALL_ERROR_LABEL /* Jump to error handler if negative. */
+ rts /* Return to caller. */
+PSEUDO_END (syscall)
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/syscalls.list b/ports/sysdeps/unix/sysv/linux/m68k/syscalls.list
new file mode 100644
index 000000000..98d30667b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/syscalls.list
@@ -0,0 +1,5 @@
+# File name Caller Syscall name Args Strong name Weak names
+
+cacheflush EXTRA cacheflush i:iiii __cacheflush cacheflush
+oldgetrlimit EXTRA getrlimit i:ip __old_getrlimit getrlimit@GLIBC_2.0
+oldsetrlimit EXTRA setrlimit i:ip __old_setrlimit setrlimit@GLIBC_2.0
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/sysdep.S b/ports/sysdeps/unix/sysv/linux/m68k/sysdep.S
new file mode 100644
index 000000000..e4ec92d83
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/sysdep.S
@@ -0,0 +1,49 @@
+/* Copyright (C) 1996, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+
+/* The following code is only used in the shared library when we
+ compile the reentrant version. Otherwise each system call defines
+ each own version. */
+
+#ifndef PIC
+
+/* The syscall stubs jump here when they detect an error. */
+
+#undef CALL_MCOUNT
+#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers %d0. */
+
+ .text
+ENTRY (__syscall_error)
+ neg.l %d0
+#ifndef _LIBC_REENTRANT
+ move.l %d0, errno
+#else
+ move.l %d0, -(%sp)
+ jbsr __errno_location
+ move.l (%sp)+, (%a0)
+#endif
+ move.l #-1, %d0
+ /* Copy return value to %a0 for syscalls that are declared to
+ return a pointer. */
+ move.l %d0, %a0
+ rts
+END (__syscall_error)
+#endif /* PIC */
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/sysdep.h b/ports/sysdeps/unix/sysv/linux/m68k/sysdep.h
new file mode 100644
index 000000000..091dfc9c7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/sysdep.h
@@ -0,0 +1,295 @@
+/* Copyright (C) 1996, 1997, 1998, 2000, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Andreas Schwab, <schwab@issan.informatik.uni-dortmund.de>,
+ December 1995.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdeps/unix/sysdep.h>
+#include <sysdeps/m68k/sysdep.h>
+
+/* Defines RTLD_PRIVATE_ERRNO. */
+#include <dl-sysdep.h>
+
+/* For Linux we can use the system call table in the header file
+ /usr/include/asm/unistd.h
+ of the kernel. But these symbols do not follow the SYS_* syntax
+ so we have to redefine the `SYS_ify' macro here. */
+#undef SYS_ify
+#ifdef __STDC__
+# define SYS_ify(syscall_name) __NR_##syscall_name
+#else
+# define SYS_ify(syscall_name) __NR_/**/syscall_name
+#endif
+
+#ifdef __ASSEMBLER__
+
+/* Linux uses a negative return value to indicate syscall errors, unlike
+ most Unices, which use the condition codes' carry flag.
+
+ Since version 2.1 the return value of a system call might be negative
+ even if the call succeeded. E.g., the `lseek' system call might return
+ a large offset. Therefore we must not anymore test for < 0, but test
+ for a real error by making sure the value in %d0 is a real error
+ number. Linus said he will make sure the no syscall returns a value
+ in -1 .. -4095 as a valid result so we can savely test with -4095. */
+
+/* We don't want the label for the error handler to be visible in the symbol
+ table when we define it here. */
+#ifdef PIC
+#define SYSCALL_ERROR_LABEL .Lsyscall_error
+#else
+#define SYSCALL_ERROR_LABEL __syscall_error
+#endif
+
+#undef PSEUDO
+#define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args); \
+ cmp.l &-4095, %d0; \
+ jcc SYSCALL_ERROR_LABEL
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) \
+ SYSCALL_ERROR_HANDLER; \
+ END (name)
+
+#undef PSEUDO_NOERRNO
+#define PSEUDO_NOERRNO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args)
+
+#undef PSEUDO_END_NOERRNO
+#define PSEUDO_END_NOERRNO(name) \
+ END (name)
+
+#define ret_NOERRNO rts
+
+/* The function has to return the error code. */
+#undef PSEUDO_ERRVAL
+#define PSEUDO_ERRVAL(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ DO_CALL (syscall_name, args); \
+ negl %d0
+
+#undef PSEUDO_END_ERRVAL
+#define PSEUDO_END_ERRVAL(name) \
+ END (name)
+
+#define ret_ERRVAL rts
+
+#ifdef PIC
+# if RTLD_PRIVATE_ERRNO
+# define SYSCALL_ERROR_HANDLER \
+SYSCALL_ERROR_LABEL: \
+ lea (rtld_errno, %pc), %a0; \
+ neg.l %d0; \
+ move.l %d0, (%a0); \
+ move.l &-1, %d0; \
+ /* Copy return value to %a0 for syscalls that are declared to return \
+ a pointer (e.g., mmap). */ \
+ move.l %d0, %a0; \
+ rts;
+# else /* !RTLD_PRIVATE_ERRNO */
+/* Store (- %d0) into errno through the GOT. */
+# if defined _LIBC_REENTRANT
+# define SYSCALL_ERROR_HANDLER \
+SYSCALL_ERROR_LABEL: \
+ neg.l %d0; \
+ move.l %d0, -(%sp); \
+ jbsr __errno_location@PLTPC; \
+ move.l (%sp)+, (%a0); \
+ move.l &-1, %d0; \
+ /* Copy return value to %a0 for syscalls that are declared to return \
+ a pointer (e.g., mmap). */ \
+ move.l %d0, %a0; \
+ rts;
+# else /* !_LIBC_REENTRANT */
+# define SYSCALL_ERROR_HANDLER \
+SYSCALL_ERROR_LABEL: \
+ move.l (errno@GOTPC, %pc), %a0; \
+ neg.l %d0; \
+ move.l %d0, (%a0); \
+ move.l &-1, %d0; \
+ /* Copy return value to %a0 for syscalls that are declared to return \
+ a pointer (e.g., mmap). */ \
+ move.l %d0, %a0; \
+ rts;
+# endif /* _LIBC_REENTRANT */
+# endif /* RTLD_PRIVATE_ERRNO */
+#else
+# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
+#endif /* PIC */
+
+/* Linux takes system call arguments in registers:
+
+ syscall number %d0 call-clobbered
+ arg 1 %d1 call-clobbered
+ arg 2 %d2 call-saved
+ arg 3 %d3 call-saved
+ arg 4 %d4 call-saved
+ arg 5 %d5 call-saved
+
+ The stack layout upon entering the function is:
+
+ 20(%sp) Arg# 5
+ 16(%sp) Arg# 4
+ 12(%sp) Arg# 3
+ 8(%sp) Arg# 2
+ 4(%sp) Arg# 1
+ (%sp) Return address
+
+ (Of course a function with say 3 arguments does not have entries for
+ arguments 4 and 5.)
+
+ Separate move's are faster than movem, but need more space. Since
+ speed is more important, we don't use movem. Since %a0 and %a1 are
+ scratch registers, we can use them for saving as well. */
+
+#define DO_CALL(syscall_name, args) \
+ move.l &SYS_ify(syscall_name), %d0; \
+ DOARGS_##args \
+ trap &0; \
+ UNDOARGS_##args
+
+#define DOARGS_0 /* No arguments to frob. */
+#define UNDOARGS_0 /* No arguments to unfrob. */
+#define _DOARGS_0(n) /* No arguments to frob. */
+
+#define DOARGS_1 _DOARGS_1 (4)
+#define _DOARGS_1(n) move.l n(%sp), %d1; _DOARGS_0 (n)
+#define UNDOARGS_1 UNDOARGS_0
+
+#define DOARGS_2 _DOARGS_2 (8)
+#define _DOARGS_2(n) move.l %d2, %a0; move.l n(%sp), %d2; _DOARGS_1 (n-4)
+#define UNDOARGS_2 UNDOARGS_1; move.l %a0, %d2
+
+#define DOARGS_3 _DOARGS_3 (12)
+#define _DOARGS_3(n) move.l %d3, %a1; move.l n(%sp), %d3; _DOARGS_2 (n-4)
+#define UNDOARGS_3 UNDOARGS_2; move.l %a1, %d3
+
+#define DOARGS_4 _DOARGS_4 (16)
+#define _DOARGS_4(n) move.l %d4, -(%sp); move.l n+4(%sp), %d4; _DOARGS_3 (n)
+#define UNDOARGS_4 UNDOARGS_3; move.l (%sp)+, %d4
+
+#define DOARGS_5 _DOARGS_5 (20)
+#define _DOARGS_5(n) move.l %d5, -(%sp); move.l n+4(%sp), %d5; _DOARGS_4 (n)
+#define UNDOARGS_5 UNDOARGS_4; move.l (%sp)+, %d5
+
+
+#define ret rts
+#if 0 /* Not used by Linux */
+#define r0 %d0
+#define r1 %d1
+#define MOVE(x,y) movel x , y
+#endif
+
+#else /* not __ASSEMBLER__ */
+
+/* Define a macro which expands into the inline wrapper code for a system
+ call. */
+#undef INLINE_SYSCALL
+#define INLINE_SYSCALL(name, nr, args...) \
+ ({ unsigned int _sys_result = INTERNAL_SYSCALL (name, , nr, args); \
+ if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0))\
+ { \
+ __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, )); \
+ _sys_result = (unsigned int) -1; \
+ } \
+ (int) _sys_result; })
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+
+/* Define a macro which expands inline into the wrapper code for a system
+ call. This use is for internal calls that do not need to handle errors
+ normally. It will never touch errno. This returns just what the kernel
+ gave back. */
+#undef INTERNAL_SYSCALL
+#define INTERNAL_SYSCALL(name, err, nr, args...) \
+ ({ unsigned int _sys_result; \
+ { \
+ /* Load argument values in temporary variables
+ to perform side effects like function calls
+ before the call used registers are set. */ \
+ LOAD_ARGS_##nr (args) \
+ LOAD_REGS_##nr \
+ register int _d0 asm ("%d0") = __NR_##name; \
+ asm volatile ("trap #0" \
+ : "=d" (_d0) \
+ : "0" (_d0) ASM_ARGS_##nr \
+ : "memory"); \
+ _sys_result = _d0; \
+ } \
+ (int) _sys_result; })
+
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+ ((unsigned int) (val) >= -4095U)
+
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
+
+#define LOAD_ARGS_0()
+#define LOAD_REGS_0
+#define ASM_ARGS_0
+#define LOAD_ARGS_1(a1) \
+ LOAD_ARGS_0 () \
+ int __arg1 = (int) (a1);
+#define LOAD_REGS_1 \
+ register int _d1 asm ("d1") = __arg1; \
+ LOAD_REGS_0
+#define ASM_ARGS_1 ASM_ARGS_0, "d" (_d1)
+#define LOAD_ARGS_2(a1, a2) \
+ LOAD_ARGS_1 (a1) \
+ int __arg2 = (int) (a2);
+#define LOAD_REGS_2 \
+ register int _d2 asm ("d2") = __arg2; \
+ LOAD_REGS_1
+#define ASM_ARGS_2 ASM_ARGS_1, "d" (_d2)
+#define LOAD_ARGS_3(a1, a2, a3) \
+ LOAD_ARGS_2 (a1, a2) \
+ int __arg3 = (int) (a3);
+#define LOAD_REGS_3 \
+ register int _d3 asm ("d3") = __arg3; \
+ LOAD_REGS_2
+#define ASM_ARGS_3 ASM_ARGS_2, "d" (_d3)
+#define LOAD_ARGS_4(a1, a2, a3, a4) \
+ LOAD_ARGS_3 (a1, a2, a3) \
+ int __arg4 = (int) (a4);
+#define LOAD_REGS_4 \
+ register int _d4 asm ("d4") = __arg4; \
+ LOAD_REGS_3
+#define ASM_ARGS_4 ASM_ARGS_3, "d" (_d4)
+#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
+ LOAD_ARGS_4 (a1, a2, a3, a4) \
+ int __arg5 = (int) (a5);
+#define LOAD_REGS_5 \
+ register int _d5 asm ("d5") = __arg5; \
+ LOAD_REGS_4
+#define ASM_ARGS_5 ASM_ARGS_4, "d" (_d5)
+#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
+ LOAD_ARGS_5 (a1, a2, a3, a4, a5) \
+ int __arg6 = (int) (a6);
+#define LOAD_REGS_6 \
+ register int _a0 asm ("a0") = __arg6; \
+ LOAD_REGS_5
+#define ASM_ARGS_6 ASM_ARGS_5, "a" (_a0)
+
+#endif /* not __ASSEMBLER__ */
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/versionsort64.c b/ports/sysdeps/unix/sysv/linux/m68k/versionsort64.c
new file mode 100644
index 000000000..144b691e5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/versionsort64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/versionsort64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/vfork.S b/ports/sysdeps/unix/sysv/linux/m68k/vfork.S
new file mode 100644
index 000000000..8027b2f80
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/vfork.S
@@ -0,0 +1,76 @@
+/* Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <kernel-features.h>
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+
+ENTRY (__vfork)
+
+#ifdef __NR_vfork
+
+ /* Pop the return PC value into A0. */
+ movel %sp@+, %a0
+
+ /* Stuff the syscall number in D0 and trap into the kernel. */
+ movel #SYS_ify (vfork), %d0
+ trap #0
+ tstl %d0
+ jmi .Lerror /* Branch forward if it failed. */
+
+ /* Jump to the return PC. */
+ jmp %a0@
+
+.Lerror:
+ /* Push back the return PC. */
+ movel %a0,%sp@-
+
+# ifdef __ASSUME_VFORK_SYSCALL
+# ifndef PIC
+ jbra SYSCALL_ERROR_LABEL
+# endif
+# else
+ /* Check if vfork syscall is known at all. */
+ movel #-ENOSYS,%d1
+ cmpl %d0,%d1
+ jne SYSCALL_ERROR_LABEL
+
+# endif
+#endif
+
+#ifndef __ASSUME_VFORK_SYSCALL
+ /* If we don't have vfork, fork is close enough. */
+
+ movel #SYS_ify (fork), %d0
+ trap #0
+ tstl %d0
+ jmi SYSCALL_ERROR_LABEL
+ rts
+#endif
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/ports/sysdeps/unix/sysv/linux/m68k/xstat.c b/ports/sysdeps/unix/sysv/linux/m68k/xstat.c
new file mode 100644
index 000000000..e9869f550
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/m68k/xstat.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/xstat.c>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/Makefile b/ports/sysdeps/unix/sysv/linux/mips/Makefile
new file mode 100644
index 000000000..72fa87b3f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/Makefile
@@ -0,0 +1,128 @@
+ifeq ($(subdir),signal)
+#sysdep_routines += sigsuspend
+endif
+
+ifeq ($(subdir),misc)
+sysdep_routines += cachectl cacheflush sysmips _test_and_set
+
+sysdep_headers += sys/cachectl.h sys/sysmips.h sys/tas.h
+
+no_syscall_list_h = 1
+
+# A callable macro that expands to a shell command. Preprocess file $(1)
+# using ABI option $(2) and see which macros it defines. Print FOO for each
+# macro of the form __NR$(3)_FOO, filtering out ABI-specific __NR macros
+# that have a prefix other than $(3).
+mips_list_syscalls = $(filter-out -m%,$(CC)) -E -x c $(+includes) \
+ $(sysincludes) -D_LIBC -dM -mabi=$(2) $(1) | \
+ sed -n 's@^\#define __NR$(3)_\([^ ]*\) .*@\1@p' | \
+ sed -e '/^[ON]32_/d' -e '/^N64_/d' -e '/^64_/d' | \
+ LC_ALL=C sort
+
+# Generate a list of SYS_* macros from the linux __NR macros.
+#
+# Before version 2.6, linux had separate 32-bit and 64-bit MIPS ports,
+# each with its own set of headers. The ports were merged for 2.6 and
+# this merged port defines the syscalls in a slightly different way.
+# There are therefore three sets of headers that we need to consider:
+#
+# (1) Headers from the separate 32-bit MIPS port. They just define
+# a single list of __NR macros.
+#
+# (2) Headers from the separate 64-bit MIPS port. They unconditionally
+# define syscalls for all three ABIs, with o32 syscalls prefixed
+# by __NR_O32, n32 syscalls prefixed by __NR_N32 and n64 syscalls
+# prefixed by plain __NR.
+#
+# (3) Headers from the combined port. They use the _MIPS_SIM macro to
+# define the right set of syscalls for the current ABI. The syscalls
+# themselves have no special ABI prefix, but the headers also define:
+#
+# __NR_O32_Linux{,_syscalls}
+# __NR_N32_Linux{,_syscalls}
+# __NR_64_Linux{,_syscalls}
+#
+# In case (1) we just want a simple list of SYS_* macros. In cases (2)
+# and (3) we want a file that will work for all three ABIs, regardless
+# of which ABI we are currently using. We also want the file to work
+# if the user later moves from (2) to (3). Thus the file we create
+# for (2) and (3) has the form:
+#
+# #if _MIPS_SIM == _ABIN32
+# # ifdef __NR_N32_open
+# # define SYS_n32syscall1 __NR_N32_n32syscall1
+# # ...
+# # else
+# # define SYS_n32syscall1 __NR_n32syscall1
+# # ...
+# # endif
+# #elif _MIPS_SIM == _ABI64
+# # define SYS_n64syscall1 __NR_n64syscall1
+# # ...
+# #else
+# # ifdef __NR_O32_open
+# # define SYS_o32syscall1 __NR_O32_o32syscall1
+# # ...
+# # else
+# # define SYS_o32syscall1 __NR_o32syscall1
+# # ...
+# # endif
+# #endif
+#
+# Here, __NR_N32_open and __NR_O32_open are used to detect case (2)
+# over case (3). The n64 SYS_* macros can always use the normal
+# ABI-less names.
+$(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/mips/sys/syscall.h
+ $(make-target-directory)
+ $(CC) -E -x c $(+includes) $(sysincludes) -D_LIBC $< -MD -MP \
+ -MF $(@:.h=.d)-t -MT '$(@:.d=.h) $(@:.h=.d)' > /dev/null
+ { \
+ echo '/* Generated at libc build time from kernel syscall list. */';\
+ echo ''; \
+ echo '#ifndef _SYSCALL_H'; \
+ echo '# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."'; \
+ echo '#endif'; \
+ echo ''; \
+ echo '#include <sgidefs.h>'; \
+ rm -f $(@:.d=.h).new32 $(@:.d=.h).newn32 $(@:.d=.h).new64; \
+ $(call mips_list_syscalls,$<,n32,_N32) > $(@:.d=.h).newn32; \
+ if test -s $(@:.d=.h).newn32; then \
+ if grep open $(@:.d=.h).newn32 > /dev/null; then \
+ $(call mips_list_syscalls,$<,32,_O32) > $(@:.d=.h).new32; \
+ $(call mips_list_syscalls,$<,64,) > $(@:.d=.h).new64; \
+ else \
+ $(call mips_list_syscalls,$<,32,) > $(@:.d=.h).new32; \
+ $(call mips_list_syscalls,$<,n32,) > $(@:.d=.h).newn32; \
+ $(call mips_list_syscalls,$<,64,) > $(@:.d=.h).new64; \
+ fi; \
+ echo '#if _MIPS_SIM == _ABIN32'; \
+ echo '# ifdef __NR_N32_open'; \
+ sed 's@\(.*\)@# define SYS_\1 __NR_N32_\1@' < $(@:.d=.h).newn32; \
+ echo '# else'; \
+ sed 's@\(.*\)@# define SYS_\1 __NR_\1@' < $(@:.d=.h).newn32; \
+ echo '# endif'; \
+ echo '#elif _MIPS_SIM == _ABI64'; \
+ sed 's@\(.*\)@# define SYS_\1 __NR_\1@' < $(@:.d=.h).new64; \
+ echo '#else'; \
+ echo '# ifdef __NR_O32_open'; \
+ sed 's@\(.*\)@# define SYS_\1 __NR_O32_\1@' < $(@:.d=.h).new32; \
+ echo '# else'; \
+ sed 's@\(.*\)@# define SYS_\1 __NR_\1@' < $(@:.d=.h).new32; \
+ echo '# endif'; \
+ echo '#endif'; \
+ else \
+ $(CC) -E -x c $(+includes) $(sysincludes) -D_LIBC -dM $< | \
+ sed -n 's@^\#define __NR_\([^ ]*\) .*@\#define SYS_\1 __NR_\1@p' | \
+ LC_ALL=C sort; \
+ fi; \
+ rm -f $(@:.d=.h).new32 $(@:.d=.h).newn32 $(@:.d=.h).new64; \
+ } > $(@:.d=.h).new
+ mv -f $(@:.d=.h).new $(@:.d=.h)
+ifneq (,$(objpfx))
+ sed $(sed-remove-objpfx) $(@:.h=.d)-t > $(@:.h=.d)-t2
+ rm -f $(@:.h=.d)-t
+ mv -f $(@:.h=.d)-t2 $(@:.h=.d)
+else
+ mv -f $(@:.h=.d)-t $(@:.h=.d)
+endif
+endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/Versions b/ports/sysdeps/unix/sysv/linux/mips/Versions
new file mode 100644
index 000000000..50bfac559
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/Versions
@@ -0,0 +1,31 @@
+libc {
+ # The comment lines with "#errlist-compat" are magic; see errlist-compat.awk.
+ # When you get an error from errlist-compat.awk, you need to add a new
+ # version here. Don't do this blindly, since this means changing the ABI
+ # for all GNU/Linux configurations.
+
+ GLIBC_2.0 {
+ #errlist-compat 123
+ _sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
+
+ # Exception handling support functions from libgcc
+ __register_frame; __register_frame_table; __deregister_frame;
+ __frame_state_for; __register_frame_info_table;
+
+ # Needed by gcc:
+ _flush_cache;
+
+ # c*
+ cachectl; cacheflush;
+
+ # s*
+ sysmips;
+ }
+ GLIBC_2.2 {
+ #errlist-compat 1134
+ _sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
+
+ # _*
+ _test_and_set;
+ }
+}
diff --git a/ports/sysdeps/unix/sysv/linux/mips/_test_and_set.c b/ports/sysdeps/unix/sysv/linux/mips/_test_and_set.c
new file mode 100644
index 000000000..9fd48f753
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/_test_and_set.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Maciej W. Rozycki <macro@ds2.pg.gda.pl>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Define the real-function versions of all inline functions
+ defined in sys/tas.h */
+
+#include <features.h>
+
+#define _EXTERN_INLINE
+#ifndef __USE_EXTERN_INLINES
+# define __USE_EXTERN_INLINES 1
+#endif
+
+#include "sys/tas.h"
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/endian.h b/ports/sysdeps/unix/sysv/linux/mips/bits/endian.h
new file mode 100644
index 000000000..0a3d2fabe
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/endian.h
@@ -0,0 +1,16 @@
+/* The MIPS architecture has selectable endianness.
+ Linux/MIPS exists in two both little and big endian flavours and we
+ want to be able to share the installed headerfiles between both,
+ so we define __BYTE_ORDER based on GCC's predefines. */
+
+#ifndef _ENDIAN_H
+# error "Never use <bits/endian.h> directly; include <endian.h> instead."
+#endif
+
+#ifdef __MIPSEB__
+# define __BYTE_ORDER __BIG_ENDIAN
+#else
+# ifdef __MIPSEL__
+# define __BYTE_ORDER __LITTLE_ENDIAN
+# endif
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/errno.h b/ports/sysdeps/unix/sysv/linux/mips/bits/errno.h
new file mode 100644
index 000000000..5ff11c0e7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/errno.h
@@ -0,0 +1,59 @@
+/* Error constants. MIPS/Linux specific version.
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifdef _ERRNO_H
+
+# undef EDOM
+# undef EILSEQ
+# undef ERANGE
+# include <linux/errno.h>
+
+/* Linux has no ENOTSUP error code. */
+# define ENOTSUP EOPNOTSUPP
+
+# ifndef ECANCELED
+# define ECANCELED 158
+# endif
+
+/* Support for error codes to support robust mutexes was added later, too. */
+# ifndef EOWNERDEAD
+# define EOWNERDEAD 165
+# define ENOTRECOVERABLE 166
+# endif
+
+# ifndef __ASSEMBLER__
+/* Function to get address of global `errno' variable. */
+extern int *__errno_location (void) __THROW __attribute__ ((__const__));
+
+# if !defined _LIBC || defined _LIBC_REENTRANT
+/* When using threads, errno is a per-thread value. */
+# define errno (*__errno_location ())
+# endif
+# endif /* !__ASSEMBLER__ */
+#endif /* _ERRNO_H */
+
+#if !defined _ERRNO_H && defined __need_Emath
+/* This is ugly but the kernel header is not clean enough. We must
+ define only the values EDOM, EILSEQ and ERANGE in case __need_Emath is
+ defined. */
+# define EDOM 33 /* Math argument out of domain of function. */
+# define EILSEQ 88 /* Illegal byte sequence. */
+# define ERANGE 34 /* Math result not representable. */
+#endif /* !_ERRNO_H && __need_Emath */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/fcntl.h b/ports/sysdeps/unix/sysv/linux/mips/bits/fcntl.h
new file mode 100644
index 000000000..b6672b751
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/fcntl.h
@@ -0,0 +1,249 @@
+/* O_*, F_*, FD_* bit values for Linux.
+ Copyright (C) 1995, 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+#include <sgidefs.h>
+#include <sys/types.h>
+#ifdef __USE_GNU
+# include <bits/uio.h>
+#endif
+
+
+/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
+ located on an ext2 file system */
+#define O_ACCMODE 0003
+#define O_RDONLY 00
+#define O_WRONLY 01
+#define O_RDWR 02
+#define O_APPEND 0x0008
+#define O_SYNC 0x0010
+#define O_NONBLOCK 0x0080
+#define O_NDELAY O_NONBLOCK
+#define O_CREAT 0x0100 /* not fcntl */
+#define O_TRUNC 0x0200 /* not fcntl */
+#define O_EXCL 0x0400 /* not fcntl */
+#define O_NOCTTY 0x0800 /* not fcntl */
+#define O_FSYNC O_SYNC
+#define O_ASYNC 0x1000
+
+#ifdef __USE_GNU
+# define O_NOFOLLOW 0x20000 /* Do not follow links. */
+# define O_DIRECT 0x8000 /* Direct disk access hint. */
+# define O_DIRECTORY 0x10000 /* Must be a directory. */
+# define O_NOATIME 0x40000 /* Do not set atime. */
+#endif
+
+/* For now Linux has no synchronisity options for data and read operations.
+ We define the symbols here but let them do the same as O_SYNC since
+ this is a superset. */
+#if defined __USE_POSIX199309 || defined __USE_UNIX98
+# define O_DSYNC O_SYNC /* Synchronize data. */
+# define O_RSYNC O_SYNC /* Synchronize read operations. */
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define O_LARGEFILE 0x2000 /* Allow large file opens. */
+#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. */
+#ifndef __USE_FILE_OFFSET64
+# 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). */
+#else
+# define F_GETLK F_GETLK64 /* Get record locking info. */
+# define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/
+# define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
+#endif
+
+#define F_GETLK64 33 /* Get record locking info. */
+#define F_SETLK64 34 /* Set record locking info (non-blocking). */
+#define F_SETLKW64 35 /* Set record locking info (blocking). */
+
+#if defined __USE_BSD || defined __USE_UNIX98
+# define F_SETOWN 24 /* Get owner of socket (receiver of SIGIO). */
+# define F_GETOWN 23 /* Set owner of socket (receiver of SIGIO). */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETSIG 10 /* Set number of signal to be sent. */
+# define F_GETSIG 11 /* Get number of signal to be sent. */
+#endif
+
+#ifdef __USE_GNU
+# define F_SETLEASE 1024 /* Set a lease. */
+# define F_GETLEASE 1025 /* Enquire what lease is active. */
+# define F_NOTIFY 1026 /* Request notfications on a directory. */
+#endif
+
+/* For F_[GET|SET]FL. */
+#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
+
+/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
+#define F_RDLCK 0 /* Read lock. */
+#define F_WRLCK 1 /* Write lock. */
+#define F_UNLCK 2 /* Remove lock. */
+
+/* For old implementation of bsd flock(). */
+#define F_EXLCK 4 /* or 3 */
+#define F_SHLCK 8 /* or 4 */
+
+#ifdef __USE_BSD
+/* Operations for bsd flock(), also used by the kernel implementation. */
+# define LOCK_SH 1 /* shared lock */
+# define LOCK_EX 2 /* exclusive lock */
+# define LOCK_NB 4 /* or'd with one of the above to prevent
+ blocking */
+# define LOCK_UN 8 /* remove lock */
+#endif
+
+#ifdef __USE_GNU
+# define LOCK_MAND 32 /* This is a mandatory flock: */
+# define LOCK_READ 64 /* ... which allows concurrent read operations. */
+# define LOCK_WRITE 128 /* ... which allows concurrent write operations. */
+# define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */
+#endif
+
+#ifdef __USE_GNU
+/* Types of directory notifications that may be requested with F_NOTIFY. */
+# define DN_ACCESS 0x00000001 /* File accessed. */
+# define DN_MODIFY 0x00000002 /* File modified. */
+# define DN_CREATE 0x00000004 /* File created. */
+# define DN_DELETE 0x00000008 /* File removed. */
+# define DN_RENAME 0x00000010 /* File renamed. */
+# define DN_ATTRIB 0x00000020 /* File changed attibutes. */
+# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
+#endif
+
+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'). */
+#ifndef __USE_FILE_OFFSET64
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+#if _MIPS_SIM != _ABI64
+ /* The 64-bit flock structure, used by the n64 ABI, and for 64-bit
+ fcntls in o32 and n32, never has this field. */
+ long int l_sysid;
+#endif
+#else
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+#endif
+ __pid_t l_pid; /* Process holding the lock. */
+#if ! defined __USE_FILE_OFFSET64 && _MIPS_SIM != _ABI64
+ /* The 64-bit flock structure, used by the n64 ABI, and for 64-bit
+ flock in o32 and n32, never has this field. */
+ long int pad[4];
+#endif
+ };
+typedef struct flock flock_t;
+
+#ifdef __USE_LARGEFILE64
+struct flock64
+ {
+ 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'). */
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+ __pid_t l_pid; /* Process holding the lock. */
+ };
+#endif
+
+/* Define some more compatibility macros to be backward compatible with
+ BSD systems which did not managed to hide these kernel macros. */
+#ifdef __USE_BSD
+# define FAPPEND O_APPEND
+# define FFSYNC O_FSYNC
+# define FASYNC O_ASYNC
+# define FNONBLOCK O_NONBLOCK
+# define FNDELAY O_NDELAY
+#endif /* Use BSD. */
+
+/* Advise to `posix_fadvise'. */
+#ifdef __USE_XOPEN2K
+# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
+# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
+# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
+# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
+# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
+#endif
+
+
+#ifdef __USE_GNU
+/* Flags for SYNC_FILE_RANGE. */
+# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
+ in the range before performing the
+ write. */
+# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those
+ dirty pages in the range which are
+ not presently under writeback. */
+# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
+ the range after performing the
+ write. */
+
+/* Flags for SPLICE and VMSPLICE. */
+# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
+# define SPLICE_F_NONBLOCK 2 /* Don't block on the pipe splicing
+ (but we may still block on the fd
+ we splice from/to). */
+# define SPLICE_F_MORE 4 /* Expect more data. */
+# define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */
+#endif
+
+__BEGIN_DECLS
+
+#ifdef __USE_GNU
+
+/* Provide kernel hint to read ahead. */
+extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
+ __THROW;
+
+
+/* Selective file content synch'ing. */
+extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
+ unsigned int __flags);
+
+
+/* Splice address range into a pipe. */
+extern int vmsplice (int __fdout, const struct iovec *__iov, size_t __count,
+ unsigned int __flags);
+
+/* Splice two files together. */
+extern int splice (int __fdin, int __fdout, size_t __len, unsigned int __flags)
+ __THROW;
+
+/* In-kernel implementation of tee for pipe buffers. */
+extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags)
+ __THROW;
+
+#endif
+
+__END_DECLS
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/ioctl-types.h b/ports/sysdeps/unix/sysv/linux/mips/bits/ioctl-types.h
new file mode 100644
index 000000000..a8dcf242d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/ioctl-types.h
@@ -0,0 +1,76 @@
+/* Structure types for pre-termios terminal ioctls. Linux/MIPS version.
+ Copyright (C) 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_IOCTL_H
+# error "Never use <bits/ioctl-types.h> directly; include <sys/ioctl.h> instead."
+#endif
+
+/* Get definition of constants for use with `ioctl'. */
+#include <asm/ioctls.h>
+
+struct winsize
+ {
+ unsigned short int ws_row;
+ unsigned short int ws_col;
+ unsigned short int ws_xpixel;
+ unsigned short int ws_ypixel;
+ };
+
+#define NCC 8
+struct termio
+ {
+ unsigned short int c_iflag; /* input mode flags */
+ unsigned short int c_oflag; /* output mode flags */
+ unsigned short int c_cflag; /* control mode flags */
+ unsigned short int c_lflag; /* local mode flags */
+ char c_line; /* line discipline */
+ /* Yes, this is really NCCS. */
+ unsigned char c_cc[32 /* NCCS */]; /* control characters */
+ };
+
+/* modem lines */
+#define TIOCM_LE 0x001 /* line enable */
+#define TIOCM_DTR 0x002 /* data terminal ready */
+#define TIOCM_RTS 0x004 /* request to send */
+#define TIOCM_ST 0x010 /* secondary transmit */
+#define TIOCM_SR 0x020 /* secondary receive */
+#define TIOCM_CTS 0x040 /* clear to send */
+#define TIOCM_CAR 0x100 /* carrier detect */
+#define TIOCM_CD TIOCM_CAR
+#define TIOCM_RNG 0x200 /* ring */
+#define TIOCM_RI TIOCM_RNG
+#define TIOCM_DSR 0x400 /* data set ready */
+
+/* line disciplines */
+#define N_TTY 0
+#define N_SLIP 1
+#define N_MOUSE 2
+#define N_PPP 3
+#define N_STRIP 4
+#define N_AX25 5
+#define N_X25 6 /* X.25 async */
+#define N_6PACK 7
+#define N_MASC 8 /* Mobitex module */
+#define N_R3964 9 /* Simatic R3964 module */
+#define N_PROFIBUS_FDL 10 /* Profibus */
+#define N_IRDA 11 /* Linux IR */
+#define N_SMSBLOCK 12 /* SMS block mode */
+#define N_HDLC 13 /* synchronous HDLC */
+#define N_SYNC_PPP 14 /* synchronous PPP */
+#define N_HCI 15 /* Bluetooth HCI UART */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/ipc.h b/ports/sysdeps/unix/sysv/linux/mips/bits/ipc.h
new file mode 100644
index 000000000..1f629ce66
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/ipc.h
@@ -0,0 +1,55 @@
+/* Copyright (C) 1995, 96, 97, 98, 99, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_IPC_H
+# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* Mode bits for `msgget', `semget', and `shmget'. */
+#define IPC_CREAT 01000 /* Create key if key does not exist. */
+#define IPC_EXCL 02000 /* Fail if key exists. */
+#define IPC_NOWAIT 04000 /* Return error on wait. */
+
+/* Control commands for `msgctl', `semctl', and `shmctl'. */
+#define IPC_RMID 0 /* Remove identifier. */
+#define IPC_SET 1 /* Set `ipc_perm' options. */
+#define IPC_STAT 2 /* Get `ipc_perm' options. */
+#ifdef __USE_GNU
+# define IPC_INFO 3 /* See ipcs. */
+#endif
+
+/* Special key values. */
+#define IPC_PRIVATE ((__key_t) 0) /* Private key. */
+
+
+/* Data structure used to pass permission information to IPC operations. */
+struct ipc_perm
+ {
+ __key_t __key; /* Key. */
+ unsigned int uid; /* Owner's user ID. */
+ unsigned int gid; /* Owner's group ID. */
+ unsigned int cuid; /* Creator's user ID. */
+ unsigned int cgid; /* Creator's group ID. */
+ unsigned int mode; /* Read/write permission. */
+ unsigned short int __seq; /* Sequence number. */
+ unsigned short int __pad1;
+ unsigned long int __unused1;
+ unsigned long int __unused2;
+};
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/mman.h b/ports/sysdeps/unix/sysv/linux/mips/bits/mman.h
new file mode 100644
index 000000000..47d33933a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/mman.h
@@ -0,0 +1,106 @@
+/* Definitions for POSIX memory map interface. Linux/MIPS version.
+ Copyright (C) 1997, 2000, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_MMAN_H
+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
+#endif
+
+/* The following definitions basically come from the kernel headers.
+ But the kernel header is not namespace clean. */
+
+
+/* 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_READ 0x1 /* Page can be read. */
+#define PROT_WRITE 0x2 /* Page can be written. */
+#define PROT_EXEC 0x4 /* Page can be executed. */
+#define PROT_NONE 0x0 /* Page can not be accessed. */
+#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
+ growsdown vma (mprotect only). */
+#define PROT_GROWSUP 0x02000000 /* Extend change to start of
+ growsup vma (mprotect only). */
+
+/* Sharing types (must choose one and only one of these). */
+#define MAP_SHARED 0x01 /* Share changes. */
+#define MAP_PRIVATE 0x02 /* Changes are private. */
+#ifdef __USE_MISC
+# define MAP_TYPE 0x0f /* Mask for type of mapping. */
+#endif
+
+/* Other flags. */
+#define MAP_FIXED 0x10 /* Interpret addr exactly. */
+#ifdef __USE_MISC
+# define MAP_FILE 0
+# define MAP_ANONYMOUS 0x0800 /* Don't use a file. */
+# define MAP_ANON MAP_ANONYMOUS
+# define MAP_RENAME MAP_ANONYMOUS
+#endif
+
+/* These are Linux-specific. */
+#ifdef __USE_MISC
+# define MAP_NORESERVE 0x0400 /* don't check for reservations */
+# define MAP_ANONYMOUS 0x0800 /* don't use a file */
+# define MAP_GROWSDOWN 0x1000 /* stack-like segment */
+# define MAP_DENYWRITE 0x2000 /* ETXTBSY */
+# define MAP_EXECUTABLE 0x4000 /* mark it as an executable */
+# define MAP_LOCKED 0x8000 /* pages are locked */
+# define MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
+# define MAP_NONBLOCK 0x20000 /* do not block on IO */
+#endif
+
+/* Flags to `msync'. */
+#define MS_ASYNC 1 /* Sync memory asynchronously. */
+#define MS_SYNC 4 /* Synchronous memory sync. */
+#define MS_INVALIDATE 2 /* Invalidate the caches. */
+
+/* Flags for `mlockall'. */
+#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
+#define MCL_FUTURE 2 /* Lock all additions to address
+ space. */
+
+/* Flags for `mremap'. */
+#ifdef __USE_GNU
+# define MREMAP_MAYMOVE 1
+# define MREMAP_FIXED 2
+#endif
+
+/* Advice to `madvise'. */
+#ifdef __USE_BSD
+# 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_REMOVE 9 /* Remove these pages and resources. */
+# define MADV_DONTFORK 10 /* Do not inherit across fork. */
+# define MADV_DOFORK 11 /* Do inherit across fork. */
+#endif
+
+/* The POSIX people had to invent similar names for the same things. */
+#ifdef __USE_XOPEN2K
+# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
+# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
+# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
+# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
+# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/msq.h b/ports/sysdeps/unix/sysv/linux/mips/bits/msq.h
new file mode 100644
index 000000000..c2c1dd2e8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/msq.h
@@ -0,0 +1,74 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_MSG_H
+# error "Never use <bits/msq.h> directly; include <sys/msg.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* Define options for message queue functions. */
+#define MSG_NOERROR 010000 /* no error if message is too big */
+#ifdef __USE_GNU
+# define MSG_EXCEPT 020000 /* recv any msg except of specified type */
+#endif
+
+/* Types used in the structure definition. */
+typedef unsigned long int msgqnum_t;
+typedef unsigned long int msglen_t;
+
+
+/* Structure of record for one message inside the kernel.
+ The type `struct msg' is opaque. */
+struct msqid_ds
+{
+ struct ipc_perm msg_perm; /* structure describing operation permission */
+ __time_t msg_stime; /* time of last msgsnd command */
+ __time_t msg_rtime; /* time of last msgrcv command */
+ __time_t msg_ctime; /* time of last change */
+ unsigned long int __msg_cbytes; /* current number of bytes on queue */
+ msgqnum_t msg_qnum; /* number of messages currently on queue */
+ msglen_t msg_qbytes; /* max number of bytes allowed on queue */
+ __pid_t msg_lspid; /* pid of last msgsnd() */
+ __pid_t msg_lrpid; /* pid of last msgrcv() */
+ unsigned long int __unused1;
+ unsigned long int __unused2;
+};
+
+#ifdef __USE_MISC
+
+# define msg_cbytes __msg_cbytes
+
+/* ipcs ctl commands */
+# define MSG_STAT 11
+# define MSG_INFO 12
+
+/* buffer for msgctl calls IPC_INFO, MSG_INFO */
+struct msginfo
+ {
+ int msgpool;
+ int msgmap;
+ int msgmax;
+ int msgmnb;
+ int msgmni;
+ int msgssz;
+ int msgtql;
+ unsigned short int msgseg;
+ };
+
+#endif /* __USE_MISC */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/poll.h b/ports/sysdeps/unix/sysv/linux/mips/bits/poll.h
new file mode 100644
index 000000000..eee4ea253
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/poll.h
@@ -0,0 +1,50 @@
+/* Copyright (C) 1997, 2001, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_POLL_H
+# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
+#endif
+
+/* Event types that can be polled for. These bits may be set in `events'
+ to indicate the interesting event types; they will appear in `revents'
+ to indicate the status of the file descriptor. */
+#define POLLIN 0x001 /* There is data to read. */
+#define POLLPRI 0x002 /* There is urgent data to read. */
+#define POLLOUT 0x004 /* Writing now will not block. */
+
+#ifdef __USE_XOPEN
+/* These values are defined in XPG4.2. */
+# define POLLRDNORM 0x040 /* Normal data may be read. */
+# define POLLRDBAND 0x080 /* Priority data may be read. */
+# define POLLWRNORM POLLOUT /* Writing now will not block. */
+# define POLLWRBAND 0x100 /* Priority data may be written. */
+#endif
+
+#ifdef __USE_GNU
+/* These are extensions for Linux. */
+# define POLLMSG 0x400
+# define POLLREMOVE 0x1000
+# define POLLRDHUP 0x2000
+#endif
+
+/* Event types always implicitly polled for. These bits need not be set in
+ `events', but they will appear in `revents' to indicate the status of
+ the file descriptor. */
+#define POLLERR 0x008 /* Error condition. */
+#define POLLHUP 0x010 /* Hung up. */
+#define POLLNVAL 0x020 /* Invalid polling request. */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/resource.h b/ports/sysdeps/unix/sysv/linux/mips/bits/resource.h
new file mode 100644
index 000000000..1c8b99a93
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/resource.h
@@ -0,0 +1,233 @@
+/* Bit values & structures for resource limits. Linux/MIPS version.
+ Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_RESOURCE_H
+# error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* Transmute defines to enumerations. The macro re-definitions are
+ necessary because some programs want to test for operating system
+ features with #ifdef RUSAGE_SELF. In ISO C the reflexive
+ definition is a no-op. */
+
+/* Kinds of resource limit. */
+enum __rlimit_resource
+{
+ /* Per-process CPU limit, in seconds. */
+ RLIMIT_CPU = 0,
+#define RLIMIT_CPU RLIMIT_CPU
+
+ /* Largest file that can be created, in bytes. */
+ RLIMIT_FSIZE = 1,
+#define RLIMIT_FSIZE RLIMIT_FSIZE
+
+ /* Maximum size of data segment, in bytes. */
+ RLIMIT_DATA = 2,
+#define RLIMIT_DATA RLIMIT_DATA
+
+ /* Maximum size of stack segment, in bytes. */
+ RLIMIT_STACK = 3,
+#define RLIMIT_STACK RLIMIT_STACK
+
+ /* Largest core file that can be created, in bytes. */
+ RLIMIT_CORE = 4,
+#define RLIMIT_CORE 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 = 7,
+#define RLIMIT_RSS __RLIMIT_RSS
+
+ /* Number of open files. */
+ RLIMIT_NOFILE = 5,
+ __RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same. */
+#define RLIMIT_NOFILE RLIMIT_NOFILE
+#define RLIMIT_OFILE __RLIMIT_OFILE
+
+ /* Address space limit (?) */
+ RLIMIT_AS = 6,
+#define RLIMIT_AS RLIMIT_AS
+
+ /* Number of processes. */
+ __RLIMIT_NPROC = 8,
+#define RLIMIT_NPROC __RLIMIT_NPROC
+
+ /* Locked-in-memory address space. */
+ __RLIMIT_MEMLOCK = 9,
+#define RLIMIT_MEMLOCK __RLIMIT_MEMLOCK
+
+ /* Maximum number of file locks. */
+ __RLIMIT_LOCKS = 10,
+#define RLIMIT_LOCKS __RLIMIT_LOCKS
+
+ /* Maximum number of pending signals. */
+ __RLIMIT_SIGPENDING = 11,
+#define RLIMIT_SIGPENDING __RLIMIT_SIGPENDING
+
+ /* Maximum bytes in POSIX message queues. */
+ __RLIMIT_MSGQUEUE = 12,
+#define RLIMIT_MSGQUEUE __RLIMIT_MSGQUEUE
+
+ /* Maximum nice priority allowed to raise to.
+ Nice levels 19 .. -20 correspond to 0 .. 39
+ values of this resource limit. */
+ __RLIMIT_NICE = 13,
+#define RLIMIT_NICE __RLIMIT_NICE
+
+ /* Maximum realtime priority allowed for non-priviledged
+ processes. */
+ __RLIMIT_RTPRIO = 14,
+#define RLIMIT_RTPRIO __RLIMIT_RTPRIO
+
+ __RLIMIT_NLIMITS = 15,
+ __RLIM_NLIMITS = __RLIMIT_NLIMITS
+#define RLIMIT_NLIMITS __RLIMIT_NLIMITS
+#define RLIM_NLIMITS __RLIM_NLIMITS
+};
+
+/* Value to indicate that there is no limit. */
+#if _MIPS_SIM == _ABI64
+/* The N64 syscall uses this value. */
+# define RLIM_INFINITY 0xffffffffffffffffUL
+# ifdef __USE_LARGEFILE64
+# define RLIM64_INFINITY 0xffffffffffffffffUL
+# endif
+#else
+/* The O32 and N32 syscalls use 0x7fffffff. */
+# ifndef __USE_FILE_OFFSET64
+# define RLIM_INFINITY ((long int)(~0UL >> 1))
+# else
+# define RLIM_INFINITY 0x7fffffffffffffffULL
+# endif
+# ifdef __USE_LARGEFILE64
+# define RLIM64_INFINITY 0x7fffffffffffffffULL
+# endif
+#endif
+
+/* We can represent all limits. */
+#define RLIM_SAVED_MAX RLIM_INFINITY
+#define RLIM_SAVED_CUR RLIM_INFINITY
+
+
+/* Type for resource quantity measurement. */
+#ifndef __USE_FILE_OFFSET64
+typedef __rlim_t rlim_t;
+#else
+typedef __rlim64_t rlim_t;
+#endif
+#ifdef __USE_LARGEFILE64
+typedef __rlim64_t rlim64_t;
+#endif
+
+struct rlimit
+ {
+ /* The current (soft) limit. */
+ rlim_t rlim_cur;
+ /* The hard limit. */
+ rlim_t rlim_max;
+ };
+
+#ifdef __USE_LARGEFILE64
+struct rlimit64
+ {
+ /* The current (soft) limit. */
+ rlim64_t rlim_cur;
+ /* The hard limit. */
+ rlim64_t rlim_max;
+ };
+#endif
+
+/* Whose usage statistics do you want? */
+enum __rusage_who
+{
+ /* The calling process. */
+ RUSAGE_SELF = 0,
+#define RUSAGE_SELF RUSAGE_SELF
+
+ /* All of its terminated child processes. */
+ RUSAGE_CHILDREN = -1
+#define RUSAGE_CHILDREN RUSAGE_CHILDREN
+};
+
+#define __need_timeval
+#include <bits/time.h> /* For `struct timeval'. */
+
+/* Structure which says how much of each resource has been used. */
+struct rusage
+ {
+ /* Total amount of user time used. */
+ struct timeval ru_utime;
+ /* Total amount of system time used. */
+ struct timeval ru_stime;
+ /* Maximum resident set size (in kilobytes). */
+ long int ru_maxrss;
+ /* Amount of sharing of text segment memory
+ with other processes (kilobyte-seconds). */
+ long int ru_ixrss;
+ /* Amount of data segment memory used (kilobyte-seconds). */
+ long int ru_idrss;
+ /* Amount of stack memory used (kilobyte-seconds). */
+ long int ru_isrss;
+ /* Number of soft page faults (i.e. those serviced by reclaiming
+ a page from the list of pages awaiting reallocation. */
+ long int ru_minflt;
+ /* Number of hard page faults (i.e. those that required I/O). */
+ long int ru_majflt;
+ /* Number of times a process was swapped out of physical memory. */
+ long int ru_nswap;
+ /* Number of input operations via the file system. Note: This
+ and `ru_oublock' do not include operations with the cache. */
+ long int ru_inblock;
+ /* Number of output operations via the file system. */
+ long int ru_oublock;
+ /* Number of IPC messages sent. */
+ long int ru_msgsnd;
+ /* Number of IPC messages received. */
+ long int ru_msgrcv;
+ /* Number of signals delivered. */
+ long int ru_nsignals;
+ /* Number of voluntary context switches, i.e. because the process
+ gave up the process before it had to (usually to wait for some
+ resource to be available). */
+ long int ru_nvcsw;
+ /* Number of involuntary context switches, i.e. a higher priority process
+ became runnable or the current process used up its time slice. */
+ long int ru_nivcsw;
+ };
+
+/* Priority limits. */
+#define PRIO_MIN -20 /* Minimum priority a process can have. */
+#define PRIO_MAX 20 /* Maximum priority a process can have. */
+
+/* The type of the WHICH argument to `getpriority' and `setpriority',
+ indicating what flavor of entity the WHO argument specifies. */
+enum __priority_which
+{
+ PRIO_PROCESS = 0, /* WHO is a process ID. */
+#define PRIO_PROCESS PRIO_PROCESS
+ PRIO_PGRP = 1, /* WHO is a process group ID. */
+#define PRIO_PGRP PRIO_PGRP
+ PRIO_USER = 2 /* WHO is a user ID. */
+#define PRIO_USER PRIO_USER
+};
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/sem.h b/ports/sysdeps/unix/sysv/linux/mips/bits/sem.h
new file mode 100644
index 000000000..6282de9cc
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/sem.h
@@ -0,0 +1,85 @@
+/* Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_SEM_H
+# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
+#endif
+
+#include <sys/types.h>
+
+/* Flags for `semop'. */
+#define SEM_UNDO 0x1000 /* undo the operation on exit */
+
+/* Commands for `semctl'. */
+#define GETPID 11 /* get sempid */
+#define GETVAL 12 /* get semval */
+#define GETALL 13 /* get all semval's */
+#define GETNCNT 14 /* get semncnt */
+#define GETZCNT 15 /* get semzcnt */
+#define SETVAL 16 /* set semval */
+#define SETALL 17 /* set all semval's */
+
+
+/* Data structure describing a set of semaphores. */
+struct semid_ds
+{
+ struct ipc_perm sem_perm; /* operation permission struct */
+ __time_t sem_otime; /* last semop() time */
+ __time_t sem_ctime; /* last time changed by semctl() */
+ unsigned long int sem_nsems; /* number of semaphores in set */
+ unsigned long int __unused1;
+ unsigned long int __unused2;
+};
+
+/* The user should define a union like the following to use it for arguments
+ for `semctl'.
+
+ union semun
+ {
+ int val; <= value for SETVAL
+ struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET
+ unsigned short int *array; <= array for GETALL & SETALL
+ struct seminfo *__buf; <= buffer for IPC_INFO
+ };
+
+ Previous versions of this file used to define this union but this is
+ incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether
+ one must define the union or not. */
+#define _SEM_SEMUN_UNDEFINED 1
+
+#ifdef __USE_MISC
+
+/* ipcs ctl cmds */
+# define SEM_STAT 18
+# define SEM_INFO 19
+
+struct seminfo
+{
+ int semmap;
+ int semmni;
+ int semmns;
+ int semmnu;
+ int semmsl;
+ int semopm;
+ int semume;
+ int semusz;
+ int semvmx;
+ int semaem;
+};
+
+#endif /* __USE_MISC */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/shm.h b/ports/sysdeps/unix/sysv/linux/mips/bits/shm.h
new file mode 100644
index 000000000..b3083346d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/shm.h
@@ -0,0 +1,94 @@
+/* Copyright (C) 1995,1996,1997,2000,2001,2002,2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_SHM_H
+# error "Never include <bits/shm.h> directly; use <sys/shm.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* Permission flag for shmget. */
+#define SHM_R 0400 /* or S_IRUGO from <linux/stat.h> */
+#define SHM_W 0200 /* or S_IWUGO from <linux/stat.h> */
+
+/* Flags for `shmat'. */
+#define SHM_RDONLY 010000 /* attach read-only else read-write */
+#define SHM_RND 020000 /* round attach address to SHMLBA */
+#define SHM_REMAP 040000 /* take-over region on attach */
+
+/* Commands for `shmctl'. */
+#define SHM_LOCK 11 /* lock segment (root only) */
+#define SHM_UNLOCK 12 /* unlock segment (root only) */
+
+/* Segment low boundary address multiple. */
+#define SHMLBA 0x40000
+
+
+/* Type to count number of attaches. */
+typedef unsigned long int shmatt_t;
+
+/* Data structure describing a set of semaphores. */
+struct shmid_ds
+ {
+ struct ipc_perm shm_perm; /* operation permission struct */
+ size_t shm_segsz; /* size of segment in bytes */
+ __time_t shm_atime; /* time of last shmat() */
+ __time_t shm_dtime; /* time of last shmdt() */
+ __time_t shm_ctime; /* time of last change by shmctl() */
+ __pid_t shm_cpid; /* pid of creator */
+ __pid_t shm_lpid; /* pid of last shmop */
+ shmatt_t shm_nattch; /* number of current attaches */
+ unsigned long int __unused1;
+ unsigned long int __unused2;
+ };
+
+#ifdef __USE_MISC
+
+/* ipcs ctl commands */
+# define SHM_STAT 13
+# define SHM_INFO 14
+
+/* shm_mode upper byte flags */
+# define SHM_DEST 01000 /* segment will be destroyed on last detach */
+# define SHM_LOCKED 02000 /* segment will not be swapped */
+# define SHM_HUGETLB 04000 /* segment is mapped via hugetlb */
+
+struct shminfo
+ {
+ unsigned long int shmmax;
+ unsigned long int shmmin;
+ unsigned long int shmmni;
+ unsigned long int shmseg;
+ unsigned long int shmall;
+ unsigned long int __unused1;
+ unsigned long int __unused2;
+ unsigned long int __unused3;
+ unsigned long int __unused4;
+ };
+
+struct shm_info
+ {
+ int used_ids;
+ unsigned long int shm_tot; /* total allocated shm */
+ unsigned long int shm_rss; /* total resident shm */
+ unsigned long int shm_swp; /* total swapped shm */
+ unsigned long int swap_attempts;
+ unsigned long int swap_successes;
+ };
+
+#endif /* __USE_MISC */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/sigaction.h b/ports/sysdeps/unix/sysv/linux/mips/bits/sigaction.h
new file mode 100644
index 000000000..d04e25f76
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/sigaction.h
@@ -0,0 +1,89 @@
+/* The proper definitions for Linux/MIPS's sigaction.
+ Copyright (C) 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2003
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SIGNAL_H
+# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
+#endif
+
+/* Structure describing the action to be taken when a signal arrives. */
+struct sigaction
+ {
+ /* Special flags. */
+ unsigned int sa_flags;
+
+ /* Signal handler. */
+#ifdef __USE_POSIX199309
+ union
+ {
+ /* Used if SA_SIGINFO is not set. */
+ __sighandler_t sa_handler;
+ /* Used if SA_SIGINFO is set. */
+ void (*sa_sigaction) (int, siginfo_t *, void *);
+ }
+ __sigaction_handler;
+# define sa_handler __sigaction_handler.sa_handler
+# define sa_sigaction __sigaction_handler.sa_sigaction
+#else
+ __sighandler_t sa_handler;
+#endif
+ /* Additional set of signals to be blocked. */
+ __sigset_t sa_mask;
+
+ /* The ABI says here are two unused ints following. */
+ /* Restore handler. */
+ void (*sa_restorer) (void);
+
+#if _MIPS_SZPTR < 64
+ int sa_resv[1];
+#endif
+ };
+
+/* Bits in `sa_flags'. */
+/* Please note that some Linux kernels versions use different values for these
+ flags which is a bug in those kernel versions. */
+#define SA_NOCLDSTOP 0x00000001 /* Don't send SIGCHLD when children stop. */
+#define SA_NOCLDWAIT 0x00010000 /* Don't create zombie on child death. */
+#define SA_SIGINFO 0x00000008 /* Invoke signal-catching function with
+ three arguments instead of one. */
+#if defined __USE_UNIX98 || defined __USE_MISC
+# define SA_ONSTACK 0x08000000 /* Use signal stack by using `sa_restorer'. */
+# define SA_RESETHAND 0x80000000 /* Reset to SIG_DFL on entry to handler. */
+# define SA_RESTART 0x10000000 /* Restart syscall on signal return. */
+# define SA_NODEFER 0x40000000 /* Don't automatically block the signal when
+ its handler is being executed. */
+#endif
+#ifdef __USE_MISC
+# define SA_INTERRUPT 0x20000000 /* Historical no-op. */
+
+/* Some aliases for the SA_ constants. */
+# define SA_NOMASK SA_NODEFER
+# define SA_ONESHOT SA_RESETHAND
+# define SA_STACK SA_ONSTACK
+#endif
+
+/* Values for the HOW argument to `sigprocmask'. */
+#define SIG_NOP 0 /* 0 is unused to catch errors */
+#define SIG_BLOCK 1 /* Block signals. */
+#define SIG_UNBLOCK 2 /* Unblock signals. */
+#define SIG_SETMASK 3 /* Set the set of blocked signals. */
+#ifdef __USE_MISC
+# define SIG_SETMASK32 256 /* Goodie from SGI for BSD compatibility:
+ set only the low 32 bit of the sigset. */
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/sigcontext.h b/ports/sysdeps/unix/sysv/linux/mips/bits/sigcontext.h
new file mode 100644
index 000000000..99faeed39
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/sigcontext.h
@@ -0,0 +1,84 @@
+/* Copyright (C) 1996, 1997, 1998, 2003, 2004, 2006 Free Software
+ Foundation, Inc. This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _BITS_SIGCONTEXT_H
+#define _BITS_SIGCONTEXT_H 1
+
+#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
+# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
+#endif
+
+#include <sgidefs.h>
+
+#if _MIPS_SIM == _ABIO32
+
+/* Certain unused fields were replaced with new ones in 2.6.12-rc4.
+ The changes were as follows:
+
+ sc_cause -> sc_hi1
+ sc_badvaddr -> sc_lo1
+ sc_sigset[0] -> sc_hi2
+ sc_sigset[1] -> sc_lo2
+ sc_sigset[2] -> sc_hi3
+ sc_sigset[3] -> sc_lo3
+
+ sc_regmask, sc_ownedfp and sc_fpc_eir are not used. */
+struct sigcontext {
+ unsigned int sc_regmask;
+ unsigned int sc_status;
+ unsigned long long sc_pc;
+ unsigned long long sc_regs[32];
+ unsigned long long sc_fpregs[32];
+ unsigned int sc_ownedfp;
+ unsigned int sc_fpc_csr;
+ unsigned int sc_fpc_eir;
+ unsigned int sc_used_math;
+ unsigned int sc_dsp;
+ unsigned long long sc_mdhi;
+ unsigned long long sc_mdlo;
+ unsigned long sc_hi1;
+ unsigned long sc_lo1;
+ unsigned long sc_hi2;
+ unsigned long sc_lo2;
+ unsigned long sc_hi3;
+ unsigned long sc_lo3;
+};
+
+#else
+
+/* This structure changed in 2.6.12-rc4 when DSP support was added. */
+struct sigcontext {
+ unsigned long long sc_regs[32];
+ unsigned long long sc_fpregs[32];
+ unsigned long long sc_mdhi;
+ unsigned long long sc_hi1;
+ unsigned long long sc_hi2;
+ unsigned long long sc_hi3;
+ unsigned long long sc_mdlo;
+ unsigned long long sc_lo1;
+ unsigned long long sc_lo2;
+ unsigned long long sc_lo3;
+ unsigned long long sc_pc;
+ unsigned int sc_fpc_csr;
+ unsigned int sc_used_math;
+ unsigned int sc_dsp;
+ unsigned int sc_reserved;
+};
+
+#endif /* _MIPS_SIM != _ABIO32 */
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/siginfo.h b/ports/sysdeps/unix/sysv/linux/mips/bits/siginfo.h
new file mode 100644
index 000000000..787e36513
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/siginfo.h
@@ -0,0 +1,310 @@
+/* siginfo_t, sigevent and constants. Linux/MIPS version.
+ Copyright (C) 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#if !defined _SIGNAL_H && !defined __need_siginfo_t \
+ && !defined __need_sigevent_t
+# error "Never include this file directly. Use <signal.h> instead"
+#endif
+
+#include <bits/wordsize.h>
+
+#if (!defined __have_sigval_t \
+ && (defined _SIGNAL_H || defined __need_siginfo_t \
+ || defined __need_sigevent_t))
+# define __have_sigval_t 1
+
+/* Type for data associated with a signal. */
+typedef union sigval
+ {
+ int sival_int;
+ void *sival_ptr;
+ } sigval_t;
+#endif
+
+#if (!defined __have_siginfo_t \
+ && (defined _SIGNAL_H || defined __need_siginfo_t))
+# define __have_siginfo_t 1
+
+# define __SI_MAX_SIZE 128
+# if __WORDSIZE == 64
+# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 4)
+# else
+# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
+# endif
+
+
+typedef struct siginfo
+ {
+ int si_signo; /* Signal number. */
+ int si_code; /* Signal code. */
+ int si_errno; /* If non-zero, an errno value associated with
+ this signal, as defined in <errno.h>. */
+ int __pad0[__SI_MAX_SIZE / sizeof (int) - __SI_PAD_SIZE - 3];
+ /* Explicit padding. */
+
+ union
+ {
+ int _pad[__SI_PAD_SIZE];
+
+ /* kill(). */
+ struct
+ {
+ __pid_t si_pid; /* Sending process ID. */
+ __uid_t si_uid; /* Real user ID of sending process. */
+ } _kill;
+
+ /* SIGCHLD. */
+ struct
+ {
+ __pid_t si_pid; /* Which child. */
+ __uid_t si_uid; /* Real user ID of sending process. */
+ int si_status; /* Exit value or signal. */
+ __clock_t si_utime;
+ __clock_t si_stime;
+ } _sigchld;
+
+ /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
+ struct
+ {
+ void *si_addr; /* Faulting insn/memory ref. */
+ } _sigfault;
+
+ /* SIGPOLL. */
+ struct
+ {
+ int si_band; /* Band event for SIGPOLL. */
+ int si_fd;
+ } _sigpoll;
+
+ /* POSIX.1b timers. */
+ struct
+ {
+ unsigned int _timer1;
+ unsigned int _timer2;
+ } _timer;
+
+ /* POSIX.1b signals. */
+ struct
+ {
+ __pid_t si_pid; /* Sending process ID. */
+ __uid_t si_uid; /* Real user ID of sending process. */
+ sigval_t si_sigval; /* Signal value. */
+ } _rt;
+ } _sifields;
+ } siginfo_t;
+
+
+/* X/Open requires some more fields with fixed names. */
+# define si_pid _sifields._kill.si_pid
+# define si_uid _sifields._kill.si_uid
+# define si_status _sifields._sigchld.si_status
+# define si_utime _sifields._sigchld.si_utime
+# define si_stime _sifields._sigchld.si_stime
+# define si_value _sifields._rt.si_sigval
+# define si_int _sifields._rt.si_sigval.sival_int
+# define si_ptr _sifields._rt.si_sigval.sival_ptr
+# define si_addr _sifields._sigfault.si_addr
+# define si_band _sifields._sigpoll.si_band
+# define si_fd _sifields._sigpoll.si_fd
+
+
+/* Values for `si_code'. Positive values are reserved for kernel-generated
+ signals. */
+enum
+{
+ SI_ASYNCNL = -60, /* Sent by asynch name lookup completion. */
+# define SI_ASYNCNL SI_ASYNCNL
+ SI_TKILL = -6, /* Sent by tkill. */
+# define SI_TKILL SI_TKILL
+ SI_SIGIO, /* Sent by queued SIGIO. */
+# define SI_SIGIO SI_SIGIO
+ SI_MESGQ, /* Sent by real time mesq state change. */
+# define SI_MESGQ SI_MESGQ
+ SI_TIMER, /* Sent by real time mesq state change. */
+# define SI_TIMER SI_TIMER
+ SI_ASYNCIO, /* Sent by AIO completion. */
+# define SI_ASYNCIO SI_ASYNCIO
+ SI_QUEUE, /* Sent by sigqueue. */
+# define SI_QUEUE SI_QUEUE
+ SI_USER, /* Sent by kill, sigsend, raise. */
+# define SI_USER SI_USER
+ SI_KERNEL = 0x80 /* Send by kernel. */
+#define SI_KERNEL SI_KERNEL
+};
+
+
+/* `si_code' values for SIGILL signal. */
+enum
+{
+ ILL_ILLOPC = 1, /* Illegal opcode. */
+# define ILL_ILLOPC ILL_ILLOPC
+ ILL_ILLOPN, /* Illegal operand. */
+# define ILL_ILLOPN ILL_ILLOPN
+ ILL_ILLADR, /* Illegal addressing mode. */
+# define ILL_ILLADR ILL_ILLADR
+ ILL_ILLTRP, /* Illegal trap. */
+# define ILL_ILLTRP ILL_ILLTRP
+ ILL_PRVOPC, /* Privileged opcode. */
+# define ILL_PRVOPC ILL_PRVOPC
+ ILL_PRVREG, /* Privileged register. */
+# define ILL_PRVREG ILL_PRVREG
+ ILL_COPROC, /* Coprocessor error. */
+# define ILL_COPROC ILL_COPROC
+ ILL_BADSTK /* Internal stack error. */
+# define ILL_BADSTK ILL_BADSTK
+};
+
+/* `si_code' values for SIGFPE signal. */
+enum
+{
+ FPE_INTDIV = 1, /* Integer divide by zero. */
+# define FPE_INTDIV FPE_INTDIV
+ FPE_INTOVF, /* Integer overflow. */
+# define FPE_INTOVF FPE_INTOVF
+ FPE_FLTDIV, /* Floating point divide by zero. */
+# define FPE_FLTDIV FPE_FLTDIV
+ FPE_FLTOVF, /* Floating point overflow. */
+# define FPE_FLTOVF FPE_FLTOVF
+ FPE_FLTUND, /* Floating point underflow. */
+# define FPE_FLTUND FPE_FLTUND
+ FPE_FLTRES, /* Floating point inexact result. */
+# define FPE_FLTRES FPE_FLTRES
+ FPE_FLTINV, /* Floating point invalid operation. */
+# define FPE_FLTINV FPE_FLTINV
+ FPE_FLTSUB /* Subscript out of range. */
+# define FPE_FLTSUB FPE_FLTSUB
+};
+
+/* `si_code' values for SIGSEGV signal. */
+enum
+{
+ SEGV_MAPERR = 1, /* Address not mapped to object. */
+# define SEGV_MAPERR SEGV_MAPERR
+ SEGV_ACCERR /* Invalid permissions for mapped object. */
+# define SEGV_ACCERR SEGV_ACCERR
+};
+
+/* `si_code' values for SIGBUS signal. */
+enum
+{
+ BUS_ADRALN = 1, /* Invalid address alignment. */
+# define BUS_ADRALN BUS_ADRALN
+ BUS_ADRERR, /* Non-existant physical address. */
+# define BUS_ADRERR BUS_ADRERR
+ BUS_OBJERR /* Object specific hardware error. */
+# define BUS_OBJERR BUS_OBJERR
+};
+
+/* `si_code' values for SIGTRAP signal. */
+enum
+{
+ TRAP_BRKPT = 1, /* Process breakpoint. */
+# define TRAP_BRKPT TRAP_BRKPT
+ TRAP_TRACE /* Process trace trap. */
+# define TRAP_TRACE TRAP_TRACE
+};
+
+/* `si_code' values for SIGCHLD signal. */
+enum
+{
+ CLD_EXITED = 1, /* Child has exited. */
+# define CLD_EXITED CLD_EXITED
+ CLD_KILLED, /* Child was killed. */
+# define CLD_KILLED CLD_KILLED
+ CLD_DUMPED, /* Child terminated abnormally. */
+# define CLD_DUMPED CLD_DUMPED
+ CLD_TRAPPED, /* Traced child has trapped. */
+# define CLD_TRAPPED CLD_TRAPPED
+ CLD_STOPPED, /* Child has stopped. */
+# define CLD_STOPPED CLD_STOPPED
+ CLD_CONTINUED /* Stopped child has continued. */
+# define CLD_CONTINUED CLD_CONTINUED
+};
+
+/* `si_code' values for SIGPOLL signal. */
+enum
+{
+ POLL_IN = 1, /* Data input available. */
+# define POLL_IN POLL_IN
+ POLL_OUT, /* Output buffers available. */
+# define POLL_OUT POLL_OUT
+ POLL_MSG, /* Input message available. */
+# define POLL_MSG POLL_MSG
+ POLL_ERR, /* I/O error. */
+# define POLL_ERR POLL_ERR
+ POLL_PRI, /* High priority input available. */
+# define POLL_PRI POLL_PRI
+ POLL_HUP /* Device disconnected. */
+# define POLL_HUP POLL_HUP
+};
+
+# undef __need_siginfo_t
+#endif /* !have siginfo_t && (have _SIGNAL_H || need siginfo_t). */
+
+
+#if (defined _SIGNAL_H || defined __need_sigevent_t) \
+ && !defined __have_sigevent_t
+# define __have_sigevent_t 1
+
+/* Structure to transport application-defined values with signals. */
+# define __SIGEV_MAX_SIZE 64
+# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3)
+
+/* Forward declaration of the `pthread_attr_t' type. */
+struct __pthread_attr_s;
+
+/* XXX This one might need to change!!! */
+typedef struct sigevent
+ {
+ sigval_t sigev_value;
+ int sigev_signo;
+ int sigev_notify;
+
+ union
+ {
+ int _pad[__SIGEV_PAD_SIZE];
+
+ struct
+ {
+ void (*_function) (sigval_t); /* Function to start. */
+ void *_attribute; /* Really pthread_attr_t. */
+ } _sigev_thread;
+ } _sigev_un;
+ } sigevent_t;
+
+/* POSIX names to access some of the members. */
+# define sigev_notify_function _sigev_un._sigev_thread._function
+# define sigev_notify_attributes _sigev_un._sigev_thread._attribute
+
+/* `sigev_notify' values. */
+enum
+{
+ SIGEV_SIGNAL = 0, /* Notify via signal. */
+# define SIGEV_SIGNAL SIGEV_SIGNAL
+ SIGEV_NONE, /* Other notification: meaningless. */
+# define SIGEV_NONE SIGEV_NONE
+ SIGEV_THREAD, /* Deliver via thread creation. */
+# define SIGEV_THREAD SIGEV_THREAD
+
+ SIGEV_THREAD_ID = 4 /* Send signal to specific thread. */
+#define SIGEV_THREAD_ID SIGEV_THREAD_ID
+};
+
+#endif /* have _SIGNAL_H. */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/signum.h b/ports/sysdeps/unix/sysv/linux/mips/bits/signum.h
new file mode 100644
index 000000000..a9b684834
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/signum.h
@@ -0,0 +1,79 @@
+/* Signal number definitions. Linux version.
+ Copyright (C) 1995, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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. */
+
+#ifdef __USE_UNIX98
+# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */
+#endif
+
+
+#define SIGHUP 1 /* Hangup (POSIX). */
+#define SIGINT 2 /* Interrupt (ANSI). */
+#define SIGQUIT 3 /* Quit (POSIX). */
+#define SIGILL 4 /* Illegal instruction (ANSI). */
+#define SIGTRAP 5 /* Trace trap (POSIX). */
+#define SIGIOT 6 /* IOT trap (4.2 BSD). */
+#define SIGABRT SIGIOT /* Abort (ANSI). */
+#define SIGEMT 7
+#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
+#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 SIGIO 22 /* I/O now possible (4.2 BSD). */
+#define SIGPOLL SIGIO /* Pollable event occurred (System V). */
+#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). */
+
+
+#define _NSIG 128 /* Biggest signal number + 1
+ (including real-time signals). */
+
+#define SIGRTMIN (__libc_current_sigrtmin ())
+#define SIGRTMAX (__libc_current_sigrtmax ())
+
+/* These are the hard limits of the kernel. These values should not be
+ used directly at user level. */
+#define __SIGRTMIN 32
+#define __SIGRTMAX (_NSIG - 1)
+
+#endif /* <signal.h> included. */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/sigstack.h b/ports/sysdeps/unix/sysv/linux/mips/bits/sigstack.h
new file mode 100644
index 000000000..d2c855220
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/sigstack.h
@@ -0,0 +1,55 @@
+/* sigstack, sigaltstack definitions.
+ Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SIGNAL_H
+# error "Never include this file directly. Use <signal.h> instead"
+#endif
+
+
+/* Structure describing a signal stack (obsolete). */
+struct sigstack
+ {
+ void *ss_sp; /* Signal stack pointer. */
+ int ss_onstack; /* Nonzero if executing on this stack. */
+ };
+
+
+/* Possible values for `ss_flags.'. */
+enum
+{
+ SS_ONSTACK = 1,
+#define SS_ONSTACK SS_ONSTACK
+ SS_DISABLE
+#define SS_DISABLE SS_DISABLE
+};
+
+/* Minimum stack size for a signal handler. */
+#define MINSIGSTKSZ 2048
+
+/* System default stack size. */
+#define SIGSTKSZ 8192
+
+
+/* Alternate, preferred interface. */
+typedef struct sigaltstack
+ {
+ void *ss_sp;
+ size_t ss_size;
+ int ss_flags;
+ } stack_t;
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/socket.h b/ports/sysdeps/unix/sysv/linux/mips/bits/socket.h
new file mode 100644
index 000000000..0e4a2beac
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/socket.h
@@ -0,0 +1,315 @@
+/* System-specific socket constants and types. Linux/MIPS version.
+ Copyright (C) 1991, 92, 1994-1999, 2000, 2001, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef __BITS_SOCKET_H
+#define __BITS_SOCKET_H
+
+#if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H
+# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
+#endif
+
+#define __need_size_t
+#define __need_NULL
+#include <stddef.h>
+
+#include <limits.h>
+#include <sys/types.h>
+
+/* Type for length arguments in socket calls. */
+#ifndef __socklen_t_defined
+typedef __socklen_t socklen_t;
+# define __socklen_t_defined
+#endif
+
+/* Types of sockets. */
+enum __socket_type
+{
+ SOCK_DGRAM = 1, /* Connectionless, unreliable datagrams
+ of fixed maximum length. */
+#define SOCK_DGRAM SOCK_DGRAM
+ SOCK_STREAM = 2, /* Sequenced, reliable, connection-based
+ byte streams. */
+#define SOCK_STREAM SOCK_STREAM
+ SOCK_RAW = 3, /* Raw protocol interface. */
+#define SOCK_RAW SOCK_RAW
+ SOCK_RDM = 4, /* Reliably-delivered messages. */
+#define SOCK_RDM SOCK_RDM
+ SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based,
+ datagrams of fixed maximum length. */
+#define SOCK_SEQPACKET SOCK_SEQPACKET
+ SOCK_PACKET = 10 /* Linux specific way of getting packets
+ at the dev level. For writing rarp and
+ other similar things on the user level. */
+#define SOCK_PACKET SOCK_PACKET
+};
+
+/* Protocol families. */
+#define PF_UNSPEC 0 /* Unspecified. */
+#define PF_LOCAL 1 /* Local to host (pipes and file-domain). */
+#define PF_UNIX PF_LOCAL /* Old BSD name for PF_LOCAL. */
+#define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */
+#define PF_INET 2 /* IP protocol family. */
+#define PF_AX25 3 /* Amateur Radio AX.25. */
+#define PF_IPX 4 /* Novell Internet Protocol. */
+#define PF_APPLETALK 5 /* Appletalk DDP. */
+#define PF_NETROM 6 /* Amateur radio NetROM. */
+#define PF_BRIDGE 7 /* Multiprotocol bridge. */
+#define PF_ATMPVC 8 /* ATM PVCs. */
+#define PF_X25 9 /* Reserved for X.25 project. */
+#define PF_INET6 10 /* IP version 6. */
+#define PF_ROSE 11 /* Amateur Radio X.25 PLP. */
+#define PF_DECnet 12 /* Reserved for DECnet project. */
+#define PF_NETBEUI 13 /* Reserved for 802.2LLC project. */
+#define PF_SECURITY 14 /* Security callback pseudo AF. */
+#define PF_KEY 15 /* PF_KEY key management API. */
+#define PF_NETLINK 16
+#define PF_ROUTE PF_NETLINK /* Alias to emulate 4.4BSD. */
+#define PF_PACKET 17 /* Packet family. */
+#define PF_ASH 18 /* Ash. */
+#define PF_ECONET 19 /* Acorn Econet. */
+#define PF_ATMSVC 20 /* ATM SVCs. */
+#define PF_SNA 22 /* Linux SNA Project */
+#define PF_IRDA 23 /* IRDA sockets. */
+#define PF_PPPOX 24 /* PPPoX sockets. */
+#define PF_WANPIPE 25 /* Wanpipe API sockets. */
+#define PF_BLUETOOTH 31 /* Bluetooth sockets. */
+#define PF_MAX 32 /* For now.. */
+
+/* Address families. */
+#define AF_UNSPEC PF_UNSPEC
+#define AF_LOCAL PF_LOCAL
+#define AF_UNIX PF_UNIX
+#define AF_FILE PF_FILE
+#define AF_INET PF_INET
+#define AF_AX25 PF_AX25
+#define AF_IPX PF_IPX
+#define AF_APPLETALK PF_APPLETALK
+#define AF_NETROM PF_NETROM
+#define AF_BRIDGE PF_BRIDGE
+#define AF_ATMPVC PF_ATMPVC
+#define AF_X25 PF_X25
+#define AF_INET6 PF_INET6
+#define AF_ROSE PF_ROSE
+#define AF_DECnet PF_DECnet
+#define AF_NETBEUI PF_NETBEUI
+#define AF_SECURITY PF_SECURITY
+#define AF_KEY PF_KEY
+#define AF_NETLINK PF_NETLINK
+#define AF_ROUTE PF_ROUTE
+#define AF_PACKET PF_PACKET
+#define AF_ASH PF_ASH
+#define AF_ECONET PF_ECONET
+#define AF_ATMSVC PF_ATMSVC
+#define AF_SNA PF_SNA
+#define AF_IRDA PF_IRDA
+#define AF_PPPOX PF_PPPOX
+#define AF_WANPIPE PF_WANPIPE
+#define AF_BLUETOOTH PF_BLUETOOTH
+#define AF_MAX PF_MAX
+
+/* Socket level values. Others are defined in the appropriate headers.
+
+ XXX These definitions also should go into the appropriate headers as
+ far as they are available. */
+#define SOL_RAW 255
+#define SOL_DECNET 261
+#define SOL_X25 262
+#define SOL_PACKET 263
+#define SOL_ATM 264 /* ATM layer (cell level). */
+#define SOL_AAL 265 /* ATM Adaption Layer (packet level). */
+#define SOL_IRDA 266
+
+/* Maximum queue length specifiable by listen. */
+#define SOMAXCONN 128
+
+/* Get the definition of the macro to define the common sockaddr members. */
+#include <bits/sockaddr.h>
+
+/* Structure describing a generic socket address. */
+struct sockaddr
+ {
+ __SOCKADDR_COMMON (sa_); /* Common data: address family and length. */
+ char sa_data[14]; /* Address data. */
+ };
+
+
+/* Structure large enough to hold any socket address (with the historical
+ exception of AF_UNIX). We reserve 128 bytes. */
+#if ULONG_MAX > 0xffffffff
+# define __ss_aligntype __uint64_t
+#else
+# define __ss_aligntype __uint32_t
+#endif
+#define _SS_SIZE 128
+#define _SS_PADSIZE (_SS_SIZE - (2 * sizeof (__ss_aligntype)))
+
+struct sockaddr_storage
+ {
+ __SOCKADDR_COMMON (ss_); /* Address family, etc. */
+ __ss_aligntype __ss_align; /* Force desired alignment. */
+ char __ss_padding[_SS_PADSIZE];
+ };
+
+
+/* Bits in the FLAGS argument to `send', `recv', et al. */
+enum
+ {
+ MSG_OOB = 0x01, /* Process out-of-band data. */
+#define MSG_OOB MSG_OOB
+ MSG_PEEK = 0x02, /* Peek at incoming messages. */
+#define MSG_PEEK MSG_PEEK
+ MSG_DONTROUTE = 0x04, /* Don't use local routing. */
+#define MSG_DONTROUTE MSG_DONTROUTE
+#ifdef __USE_GNU
+ /* DECnet uses a different name. */
+ MSG_TRYHARD = MSG_DONTROUTE,
+# define MSG_TRYHARD MSG_DONTROUTE
+#endif
+ MSG_CTRUNC = 0x08, /* Control data lost before delivery. */
+#define MSG_CTRUNC MSG_CTRUNC
+ MSG_PROXY = 0x10, /* Supply or ask second address. */
+#define MSG_PROXY MSG_PROXY
+ MSG_TRUNC = 0x20,
+#define MSG_TRUNC MSG_TRUNC
+ MSG_DONTWAIT = 0x40, /* Nonblocking IO. */
+#define MSG_DONTWAIT MSG_DONTWAIT
+ MSG_EOR = 0x80, /* End of record. */
+#define MSG_EOR MSG_EOR
+ MSG_WAITALL = 0x100, /* Wait for a full request. */
+#define MSG_WAITALL MSG_WAITALL
+ MSG_FIN = 0x200,
+#define MSG_FIN MSG_FIN
+ MSG_SYN = 0x400,
+#define MSG_SYN MSG_SYN
+ MSG_CONFIRM = 0x800, /* Confirm path validity. */
+#define MSG_CONFIRM MSG_CONFIRM
+ MSG_RST = 0x1000,
+#define MSG_RST MSG_RST
+ MSG_ERRQUEUE = 0x2000, /* Fetch message from error queue. */
+#define MSG_ERRQUEUE MSG_ERRQUEUE
+ MSG_NOSIGNAL = 0x4000, /* Do not generate SIGPIPE. */
+#define MSG_NOSIGNAL MSG_NOSIGNAL
+ MSG_MORE = 0x8000 /* Sender will send more. */
+#define MSG_MORE MSG_MORE
+ };
+
+
+/* Structure describing messages sent by
+ `sendmsg' and received by `recvmsg'. */
+struct msghdr
+ {
+ void *msg_name; /* Address to send to/receive from. */
+ socklen_t msg_namelen; /* Length of address data. */
+
+ struct iovec *msg_iov; /* Vector of data to send/receive into. */
+ size_t msg_iovlen; /* Number of elements in the vector. */
+
+ void *msg_control; /* Ancillary data (eg BSD filedesc passing). */
+ size_t msg_controllen; /* Ancillary data buffer length. */
+
+ int msg_flags; /* Flags on received message. */
+ };
+
+/* Structure used for storage of ancillary data object information. */
+struct cmsghdr
+ {
+ size_t cmsg_len; /* Length of data in cmsg_data plus length
+ of cmsghdr structure. */
+ int cmsg_level; /* Originating protocol. */
+ int cmsg_type; /* Protocol specific type. */
+#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
+ __extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data. */
+#endif
+ };
+
+/* Ancillary data object manipulation macros. */
+#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
+# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
+#else
+# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))
+#endif
+#define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)
+#define CMSG_FIRSTHDR(mhdr) \
+ ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
+ ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) NULL)
+#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \
+ & (size_t) ~(sizeof (size_t) - 1))
+#define CMSG_SPACE(len) (CMSG_ALIGN (len) \
+ + CMSG_ALIGN (sizeof (struct cmsghdr)))
+#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
+
+extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
+ struct cmsghdr *__cmsg) __THROW;
+#ifdef __USE_EXTERN_INLINES
+# ifndef _EXTERN_INLINE
+# define _EXTERN_INLINE extern __inline
+# endif
+_EXTERN_INLINE struct cmsghdr *
+__NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg))
+{
+ if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
+ /* The kernel header does this so there may be a reason. */
+ return 0;
+
+ __cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
+ + CMSG_ALIGN (__cmsg->cmsg_len));
+ if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) __mhdr->msg_control
+ + __mhdr->msg_controllen)
+ || ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len)
+ > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
+ /* No more entries. */
+ return 0;
+ return __cmsg;
+}
+#endif /* Use `extern inline'. */
+
+/* Socket level message types. This must match the definitions in
+ <linux/socket.h>. */
+enum
+ {
+ SCM_RIGHTS = 0x01 /* Transfer file descriptors. */
+#define SCM_RIGHTS SCM_RIGHTS
+#ifdef __USE_BSD
+ , SCM_CREDENTIALS = 0x02 /* Credentials passing. */
+# define SCM_CREDENTIALS SCM_CREDENTIALS
+#endif
+ };
+
+/* User visible structure for SCM_CREDENTIALS message */
+
+struct ucred
+{
+ pid_t pid; /* PID of sending process. */
+ uid_t uid; /* UID of sending process. */
+ gid_t gid; /* GID of sending process. */
+};
+
+/* Get socket manipulation related informations from kernel headers. */
+#include <asm/socket.h>
+
+
+/* Structure used to manipulate the SO_LINGER option. */
+struct linger
+ {
+ int l_onoff; /* Nonzero to linger on close. */
+ int l_linger; /* Time to linger. */
+ };
+
+#endif /* bits/socket.h */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/stat.h b/ports/sysdeps/unix/sysv/linux/mips/bits/stat.h
new file mode 100644
index 000000000..208197830
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/stat.h
@@ -0,0 +1,255 @@
+/* Copyright (C) 1992, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_STAT_H
+# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+#include <sgidefs.h>
+
+/* Versions of the `struct stat' data structure. */
+#define _STAT_VER_LINUX_OLD 1
+#define _STAT_VER_KERNEL 1
+#define _STAT_VER_SVR4 2
+#define _STAT_VER_LINUX 3
+#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
+
+/* Versions of the `xmknod' interface. */
+#define _MKNOD_VER_LINUX 1
+#define _MKNOD_VER_SVR4 2
+#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
+
+
+#if _MIPS_SIM == _ABIO32
+/* Structure describing file characteristics. */
+struct stat
+ {
+ unsigned long int st_dev;
+ long int st_pad1[3];
+#ifndef __USE_FILE_OFFSET64
+ __ino_t st_ino; /* File serial number. */
+#else
+ __ino64_t st_ino; /* File serial number. */
+#endif
+ __mode_t st_mode; /* File mode. */
+ __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.*/
+ unsigned long int st_rdev; /* Device number, if device. */
+#ifndef __USE_FILE_OFFSET64
+ long int st_pad2[2];
+ __off_t st_size; /* Size of file, in bytes. */
+ /* SVR4 added this extra long to allow for expansion of off_t. */
+ long int st_pad3;
+#else
+ long int st_pad2[3];
+ __off64_t st_size; /* Size of file, in bytes. */
+#endif
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
+ __time_t st_atime; /* Time of last access. */
+ long int __reserved0;
+ __time_t st_mtime; /* Time of last modification. */
+ long int __reserved1;
+ __time_t st_ctime; /* Time of last status change. */
+ long int __reserved2;
+#endif
+ __blksize_t st_blksize; /* Optimal block size for I/O. */
+#ifndef __USE_FILE_OFFSET64
+ __blkcnt_t st_blocks; /* Number of 512-byte blocks allocated. */
+#else
+ long int st_pad4;
+ __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated. */
+#endif
+ long int st_pad5[14];
+ };
+
+#ifdef __USE_LARGEFILE64
+struct stat64
+ {
+ unsigned long int st_dev;
+ long int st_pad1[3];
+ __ino64_t st_ino; /* File serial number. */
+ __mode_t st_mode; /* File mode. */
+ __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.*/
+ unsigned long int st_rdev; /* Device number, if device. */
+ long int st_pad2[3];
+ __off64_t st_size; /* Size of file, in bytes. */
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+#else
+ __time_t st_atime; /* Time of last access. */
+ long int __reserved0;
+ __time_t st_mtime; /* Time of last modification. */
+ long int __reserved1;
+ __time_t st_ctime; /* Time of last status change. */
+ long int __reserved2;
+#endif
+ __blksize_t st_blksize; /* Optimal block size for I/O. */
+ long int st_pad3;
+ __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated. */
+ long int st_pad4[14];
+ };
+#endif
+#else
+struct stat
+ {
+ __dev_t st_dev;
+ int st_pad1[3]; /* Reserved for st_dev expansion */
+#ifndef __USE_FILE_OFFSET64
+ __ino_t st_ino;
+#else
+ __ino64_t st_ino;
+#endif
+ __mode_t st_mode;
+ __nlink_t st_nlink;
+ __uid_t st_uid;
+ __gid_t st_gid;
+ __dev_t st_rdev;
+#if !defined __USE_FILE_OFFSET64
+ unsigned int st_pad2[2]; /* Reserved for st_rdev expansion */
+ __off_t st_size;
+ int st_pad3;
+#else
+ unsigned int st_pad2[3]; /* Reserved for st_rdev expansion */
+ __off64_t st_size;
+#endif
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#else
+ __time_t st_atime;
+ int __reserved0;
+ __time_t st_mtime;
+ int __reserved1;
+ __time_t st_ctime;
+ int __reserved2;
+#endif
+ __blksize_t st_blksize;
+ unsigned int st_pad4;
+#ifndef __USE_FILE_OFFSET64
+ __blkcnt_t st_blocks;
+#else
+ __blkcnt64_t st_blocks;
+#endif
+ int st_pad5[14];
+ };
+
+#ifdef __USE_LARGEFILE64
+struct stat64
+ {
+ __dev_t st_dev;
+ unsigned int st_pad1[3]; /* Reserved for st_dev expansion */
+ __ino64_t st_ino;
+ __mode_t st_mode;
+ __nlink_t st_nlink;
+ __uid_t st_uid;
+ __gid_t st_gid;
+ __dev_t st_rdev;
+ unsigned int st_pad2[3]; /* Reserved for st_rdev expansion */
+ __off64_t st_size;
+#ifdef __USE_MISC
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+#else
+ __time_t st_atime;
+ int __reserved0;
+ __time_t st_mtime;
+ int __reserved1;
+ __time_t st_ctime;
+ int __reserved2;
+#endif
+ __blksize_t st_blksize;
+ unsigned int st_pad3;
+ __blkcnt64_t st_blocks;
+ int st_pad4[14];
+};
+#endif
+#endif
+
+/* Tell code we have these members. */
+#define _STATBUF_ST_BLKSIZE
+#define _STATBUF_ST_RDEV
+
+/* 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. */
+
+/* POSIX.1b objects. Note that these macros always evaluate to zero. But
+ they do it by enforcing the correct use of the macros. */
+#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
+#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
+#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
+
+/* 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. */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/statfs.h b/ports/sysdeps/unix/sysv/linux/mips/bits/statfs.h
new file mode 100644
index 000000000..2f9bd54ed
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/statfs.h
@@ -0,0 +1,72 @@
+/* Copyright (C) 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_STATFS_H
+# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
+#endif
+
+#include <bits/types.h> /* for __fsid_t and __fsblkcnt_t*/
+
+struct statfs
+ {
+ long int f_type;
+#define f_fstyp f_type
+ long int f_bsize;
+ long int f_frsize; /* Fragment size - unsupported */
+#ifndef __USE_FILE_OFFSET64
+ __fsblkcnt_t f_blocks;
+ __fsblkcnt_t f_bfree;
+ __fsblkcnt_t f_files;
+ __fsblkcnt_t f_ffree;
+ __fsblkcnt_t f_bavail;
+#else
+ __fsblkcnt64_t f_blocks;
+ __fsblkcnt64_t f_bfree;
+ __fsblkcnt64_t f_files;
+ __fsblkcnt64_t f_ffree;
+ __fsblkcnt64_t f_bavail;
+#endif
+
+ /* Linux specials */
+ __fsid_t f_fsid;
+ long int f_namelen;
+ long int f_spare[6];
+ };
+
+#ifdef __USE_LARGEFILE64
+struct statfs64
+ {
+ long int f_type;
+#define f_fstyp f_type
+ long int f_bsize;
+ long int f_frsize; /* Fragment size - unsupported */
+ __fsblkcnt64_t f_blocks;
+ __fsblkcnt64_t f_bfree;
+ __fsblkcnt64_t f_files;
+ __fsblkcnt64_t f_ffree;
+ __fsblkcnt64_t f_bavail;
+
+ /* Linux specials */
+ __fsid_t f_fsid;
+ long int f_namelen;
+ long int f_spare[6];
+ };
+#endif
+
+/* Tell code we have these members. */
+#define _STATFS_F_NAMELEN
diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/termios.h b/ports/sysdeps/unix/sysv/linux/mips/bits/termios.h
new file mode 100644
index 000000000..4ff6e37ad
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/bits/termios.h
@@ -0,0 +1,218 @@
+/* termios type and macro definitions. Linux/MIPS version.
+ Copyright (C) 1993, 94, 95, 96, 97, 99 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _TERMIOS_H
+# error "Never include <bits/termios.h> directly; use <termios.h> instead."
+#endif
+
+typedef unsigned char cc_t;
+typedef unsigned int speed_t;
+typedef unsigned int tcflag_t;
+
+#define NCCS 32
+struct termios
+ {
+ tcflag_t c_iflag; /* input mode flags */
+ tcflag_t c_oflag; /* output mode flags */
+ tcflag_t c_cflag; /* control mode flags */
+ tcflag_t c_lflag; /* local mode flags */
+ cc_t c_line; /* line discipline */
+ cc_t c_cc[NCCS]; /* control characters */
+ };
+
+/* c_cc characters */
+#define VINTR 0 /* Interrupt character [ISIG]. */
+#define VQUIT 1 /* Quit character [ISIG]. */
+#define VERASE 2 /* Erase character [ICANON]. */
+#define VKILL 3 /* Kill-line character [ICANON]. */
+#define VMIN 4 /* Minimum number of bytes read at once [!ICANON]. */
+#define VTIME 5 /* Time-out value (tenths of a second) [!ICANON]. */
+#define VEOL2 6 /* Second EOL character [ICANON]. */
+#define VSWTC 7
+#define VSWTCH VSWTC
+#define VSTART 8 /* Start (X-ON) character [IXON, IXOFF]. */
+#define VSTOP 9 /* Stop (X-OFF) character [IXON, IXOFF]. */
+#define VSUSP 10 /* Suspend character [ISIG]. */
+ /* VDSUSP is not supported on Linux. */
+/* #define VDSUSP 11 / * Delayed suspend character [ISIG]. */
+#define VREPRINT 12 /* Reprint-line character [ICANON]. */
+#define VDISCARD 13 /* Discard character [IEXTEN]. */
+#define VWERASE 14 /* Word-erase character [ICANON]. */
+#define VLNEXT 15 /* Literal-next character [IEXTEN]. */
+#define VEOF 16 /* End-of-file character [ICANON]. */
+#define VEOL 17 /* End-of-line character [ICANON]. */
+
+/* c_iflag bits */
+#define IGNBRK 0000001 /* Ignore break condition. */
+#define BRKINT 0000002 /* Signal interrupt on break. */
+#define IGNPAR 0000004 /* Ignore characters with parity errors. */
+#define PARMRK 0000010 /* Mark parity and framing errors. */
+#define INPCK 0000020 /* Enable input parity check. */
+#define ISTRIP 0000040 /* Strip 8th bit off characters. */
+#define INLCR 0000100 /* Map NL to CR on input. */
+#define IGNCR 0000200 /* Ignore CR. */
+#define ICRNL 0000400 /* Map CR to NL on input. */
+#define IUCLC 0001000 /* Map upper case to lower case on input. */
+#define IXON 0002000 /* Enable start/stop output control. */
+#define IXANY 0004000 /* Any character will restart after stop. */
+#define IXOFF 0010000 /* Enable start/stop input control. */
+#define IMAXBEL 0020000 /* Ring bell when input queue is full. */
+#define IUTF8 0040000 /* Input is UTF8. */
+
+/* c_oflag bits */
+#define OPOST 0000001 /* Perform output processing. */
+#define OLCUC 0000002 /* Map lower case to upper case on output. */
+#define ONLCR 0000004 /* Map NL to CR-NL on output. */
+#define OCRNL 0000010
+#define ONOCR 0000020
+#define ONLRET 0000040
+#define OFILL 0000100
+#define OFDEL 0000200
+#if defined __USE_MISC || defined __USE_XOPEN
+# define NLDLY 0000400
+# define NL0 0000000
+# define NL1 0000400
+# define CRDLY 0003000
+# define CR0 0000000
+# define CR1 0001000
+# define CR2 0002000
+# define CR3 0003000
+# define TABDLY 0014000
+# define TAB0 0000000
+# define TAB1 0004000
+# define TAB2 0010000
+# define TAB3 0014000
+# define BSDLY 0020000
+# define BS0 0000000
+# define BS1 0020000
+# define FFDLY 0100000
+# define FF0 0000000
+# define FF1 0100000
+#endif
+
+#define VTDLY 0040000
+#define VT0 0000000
+#define VT1 0040000
+
+#ifdef __USE_MISC
+# define XTABS 0014000
+#endif
+
+/* c_cflag bit meaning */
+#ifdef __USE_MISC
+# define CBAUD 0010017
+#endif
+#define B0 0000000 /* hang up */
+#define B50 0000001
+#define B75 0000002
+#define B110 0000003
+#define B134 0000004
+#define B150 0000005
+#define B200 0000006
+#define B300 0000007
+#define B600 0000010
+#define B1200 0000011
+#define B1800 0000012
+#define B2400 0000013
+#define B4800 0000014
+#define B9600 0000015
+#define B19200 0000016
+#define B38400 0000017
+#ifdef __USE_MISC
+# define EXTA B19200
+# define EXTB B38400
+#endif
+#define CSIZE 0000060 /* Number of bits per byte (mask). */
+#define CS5 0000000 /* 5 bits per byte. */
+#define CS6 0000020 /* 6 bits per byte. */
+#define CS7 0000040 /* 7 bits per byte. */
+#define CS8 0000060 /* 8 bits per byte. */
+#define CSTOPB 0000100 /* Two stop bits instead of one. */
+#define CREAD 0000200 /* Enable receiver. */
+#define PARENB 0000400 /* Parity enable. */
+#define PARODD 0001000 /* Odd parity instead of even. */
+#define HUPCL 0002000 /* Hang up on last close. */
+#define CLOCAL 0004000 /* Ignore modem status lines. */
+#ifdef __USE_MISC
+# define CBAUDEX 0010000
+#endif
+#define B57600 0010001
+#define B115200 0010002
+#define B230400 0010003
+#define B460800 0010004
+#define B500000 0010005
+#define B576000 0010006
+#define B921600 0010007
+#define B1000000 0010010
+#define B1152000 0010011
+#define B1500000 0010012
+#define B2000000 0010013
+#define B2500000 0010014
+#define B3000000 0010015
+#define B3500000 0010016
+#define B4000000 0010017
+#define __MAX_BAUD B4000000
+#ifdef __USE_MISC
+# define CIBAUD 002003600000 /* input baud rate (not used) */
+# define CRTSCTS 020000000000 /* flow control */
+#endif
+
+/* c_lflag bits */
+#define ISIG 0000001 /* Enable signals. */
+#define ICANON 0000002 /* Do erase and kill processing. */
+#if defined __USE_MISC || defined __USE_XOPEN
+# define XCASE 0000004
+#endif
+#define ECHO 0000010 /* Enable echo. */
+#define ECHOE 0000020 /* Visual erase for ERASE. */
+#define ECHOK 0000040 /* Echo NL after KILL. */
+#define ECHONL 0000100 /* Echo NL even if ECHO is off. */
+#define NOFLSH 0000200 /* Disable flush after interrupt. */
+#define IEXTEN 0000400 /* Enable DISCARD and LNEXT. */
+#ifdef __USE_MISC
+# define ECHOCTL 0001000 /* Echo control characters as ^X. */
+# define ECHOPRT 0002000 /* Hardcopy visual erase. */
+# define ECHOKE 0004000 /* Visual erase for KILL. */
+# define FLUSHO 0020000
+# define PENDIN 0040000 /* Retype pending input (state). */
+#endif
+#define TOSTOP 0100000 /* Send SIGTTOU for background output. */
+#define ITOSTOP TOSTOP
+
+/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
+#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
+
+/* tcflow() and TCXONC use these */
+#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. */
+
+/* tcflush() and TCFLSH use these */
+#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. */
+
+/* tcsetattr uses these */
+#define TCSANOW 0x540e /* Same as TCSETS; change immediately. */
+#define TCSADRAIN 0x540f /* Same as TCSETSW; change when pending output is written. */
+#define TCSAFLUSH 0x5410 /* Same as TCSETSF; flush pending input before changing. */
+
+#define _IOT_termios /* Hurd ioctl type field. */ \
+ _IOT (_IOTS (cflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)
diff --git a/ports/sysdeps/unix/sysv/linux/mips/brk.c b/ports/sysdeps/unix/sysv/linux/mips/brk.c
new file mode 100644
index 000000000..00056bee7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/brk.c
@@ -0,0 +1,57 @@
+/* brk system call for Linux/MIPS.
+ Copyright (C) 2000, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sysdep.h>
+
+void *__curbrk = 0;
+
+/* Old braindamage in GCC's crtstuff.c requires this symbol in an attempt
+ to work around different old braindamage in the old Linux/x86 ELF
+ dynamic linker. Sigh. */
+weak_alias (__curbrk, ___brk_addr)
+
+int
+__brk (void *addr)
+{
+ void *newbrk;
+
+ {
+ register long int res __asm__ ("$2");
+
+ asm ("move\t$4,%2\n\t"
+ "li\t%0,%1\n\t"
+ "syscall" /* Perform the system call. */
+ : "=r" (res)
+ : "I" (SYS_ify (brk)), "r" (addr)
+ : "$4", "$7", __SYSCALL_CLOBBERS);
+ newbrk = (void *) res;
+ }
+ __curbrk = newbrk;
+
+ if (newbrk < addr)
+ {
+ __set_errno (ENOMEM);
+ return -1;
+ }
+
+ return 0;
+}
+weak_alias (__brk, brk)
diff --git a/ports/sysdeps/unix/sysv/linux/mips/clone.S b/ports/sysdeps/unix/sysv/linux/mips/clone.S
new file mode 100644
index 000000000..f521df177
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/clone.S
@@ -0,0 +1,166 @@
+/* Copyright (C) 1996, 1997, 2000, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ralf Baechle <ralf@linux-mips.org>, 1996.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* clone() is even more special than fork() as it mucks with stacks
+ and invokes a function in the right context after its all over. */
+
+#include <sys/asm.h>
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#ifdef RESET_PID
+#include <tls.h>
+#endif
+
+#define CLONE_VM 0x00000100
+#define CLONE_THREAD 0x00010000
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+ void *parent_tidptr, void *tls, void *child_tidptr) */
+
+ .text
+#if _MIPS_SIM == _ABIO32
+# define EXTRA_LOCALS 1
+#else
+# define EXTRA_LOCALS 0
+#endif
+LOCALSZ= 4
+FRAMESZ= (((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
+GPOFF= FRAMESZ-(1*SZREG)
+NESTED(__clone,4*SZREG,sp)
+#ifdef __PIC__
+ SETUP_GP
+#endif
+ PTR_SUBU sp, FRAMESZ
+ SETUP_GP64 (GPOFF, __clone)
+#ifdef __PIC__
+ SAVE_GP (GPOFF)
+#endif
+#ifdef PROF
+ .set noat
+ move $1,ra
+ jal _mcount
+ .set at
+#endif
+
+
+ /* Sanity check arguments. */
+ li v0,EINVAL
+ beqz a0,L(error) /* No NULL function pointers. */
+ beqz a1,L(error) /* No NULL stack pointers. */
+
+ PTR_SUBU a1,32 /* Reserve argument save space. */
+ PTR_S a0,0(a1) /* Save function pointer. */
+ PTR_S a3,PTRSIZE(a1) /* Save argument pointer. */
+#ifdef RESET_PID
+ LONG_S a2,(PTRSIZE*2)(a1) /* Save clone flags. */
+#endif
+
+ move a0,a2
+
+ /* Shuffle in the last three arguments - arguments 5, 6, and 7 to
+ this function, but arguments 3, 4, and 5 to the syscall. */
+#if _MIPS_SIM == _ABIO32
+ PTR_L a2,(FRAMESZ+PTRSIZE+PTRSIZE+16)(sp)
+ PTR_S a2,16(sp)
+ PTR_L a2,(FRAMESZ+16)(sp)
+ PTR_L a3,(FRAMESZ+PTRSIZE+16)(sp)
+#else
+ move a2,a4
+ move a3,a5
+ move a4,a6
+#endif
+
+ /* Do the system call */
+ li v0,__NR_clone
+ syscall
+
+ bnez a3,L(error)
+ beqz v0,L(thread_start)
+
+ /* Successful return from the parent */
+ RESTORE_GP64
+ PTR_ADDU sp, FRAMESZ
+ ret
+
+ /* Something bad happened -- no child created */
+L(error):
+#ifdef __PIC__
+ PTR_LA t9,__syscall_error
+ RESTORE_GP64
+ PTR_ADDU sp, FRAMESZ
+ jr t9
+#else
+ RESTORE_GP64
+ PTR_ADDU sp, FRAMESZ
+ j __syscall_error
+#endif
+ END(__clone)
+
+/* Load up the arguments to the function. Put this block of code in
+ its own function so that we can terminate the stack trace with our
+ debug info. */
+
+ENTRY(__thread_start)
+L(thread_start):
+ /* cp is already loaded. */
+ SAVE_GP (GPOFF)
+ /* The stackframe has been created on entry of clone(). */
+
+#ifdef RESET_PID
+ /* Check and see if we need to reset the PID. */
+ LONG_L a0,(PTRSIZE*2)(sp)
+ and a1,a0,CLONE_THREAD
+ beqz a1,L(restore_pid)
+L(donepid):
+#endif
+
+ /* Restore the arg for user's function. */
+ PTR_L t9,0(sp) /* Function pointer. */
+ PTR_L a0,PTRSIZE(sp) /* Argument pointer. */
+
+ /* Call the user's function. */
+ jal t9
+
+ /* Call _exit rather than doing it inline for breakpoint purposes. */
+ move a0,v0
+#ifdef __PIC__
+ PTR_LA t9,_exit
+ jalr t9
+#else
+ jal _exit
+#endif
+
+#ifdef RESET_PID
+L(restore_pid):
+ and a1,a0,CLONE_VM
+ li v0,-1
+ bnez a1,L(gotpid)
+ li v0,__NR_getpid
+ syscall
+L(gotpid):
+ READ_THREAD_POINTER(v1)
+ INT_S v0,PID_OFFSET(v1)
+ INT_S v0,TID_OFFSET(v1)
+ b L(donepid)
+#endif
+
+ END(__thread_start)
+
+weak_alias (__clone, clone)
diff --git a/ports/sysdeps/unix/sysv/linux/mips/configure b/ports/sysdeps/unix/sysv/linux/mips/configure
new file mode 100644
index 000000000..cad59b5f7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/configure
@@ -0,0 +1,112 @@
+# This file is generated from configure.in by Autoconf. DO NOT EDIT!
+ # Local configure fragment for sysdeps/unix/sysv/linux/mips.
+
+case $machine in
+mips*64*)
+ rm -f asm-unistd.h
+ asm_unistd_h=$sysheaders/asm/unistd.h
+ if test ! -f $asm_unistd_h; then
+ # Try to find asm/unistd.h in compiler header search path.
+ try_asm_unistd_h=`echo '#include <asm/unistd.h>' | $CPP - |
+ sed -n '/^# 1 "\(\/[^"]*\)".*/{s,,\1,p;q;}'`
+ if test -n "$try_asm_unistd_h" &&
+ test -f "$try_asm_unistd_h"; then
+ asm_unistd_h=$try_asm_unistd_h
+ fi
+ fi
+ if test ! -f "$asm_unistd_h"; then
+ { echo "$as_me:$LINENO: WARNING: *** asm/unistd.h not found, it will not be pre-processed" >&5
+echo "$as_me: WARNING: *** asm/unistd.h not found, it will not be pre-processed" >&2;}
+ echo '#include <asm/unistd.h>' > asm-unistd.h
+ elif grep __NR_N32_open "$asm_unistd_h" > /dev/null; then
+ # The point of this preprocessing is to turn __NR_<syscall> into
+ # __NR_N64_<syscall>, as well as to define __NR_<syscall> to
+ # __NR_<abi>_<syscall>, if __NR_<abi>_<syscall> is defined
+ # and <abi> is the compiler-enabled ABI.
+ cat "$asm_unistd_h" |
+ sed -e 's,__NR_,__NR_N64_,g' \
+ -e 's,__NR_N64_##,__NR_##,g' \
+ -e 's,__NR_N64_O32_,__NR_O32_,g' \
+ -e 's,__NR_N64_N32_,__NR_N32_,g' \
+ -e 's,__NR_N64_N64_,__NR_N64_,g' \
+ | awk > asm-unistd.h '
+BEGIN { print "#include <sgidefs.h>"; }
+/^#define __NR.*unused/ { print; next; }
+/^#define __NR_N64__exit __NR_N64_exit/ {
+ print "#define __NR__exit __NR_exit";
+ print "#define __NR_O32__exit __NR_O32_exit";
+ print "#define __NR_N32__exit __NR_N32_exit";
+ print; next;
+}
+/^#define __NR_O32_/ {
+ name = $2;
+ sub (/_O32_/, "_", name);
+ print;
+ print "#if _MIPS_SIM == _ABIO32";
+ print "# define " name " " $2;
+ print "#endif";
+ next;
+}
+/^#define __NR_N32_/ {
+ name = $2;
+ sub (/_N32_/, "_", name);
+ print;
+ print "#if _MIPS_SIM == _ABIN32";
+ print "# define " name " " $2;
+ print "#endif";
+ next;
+}
+/^#define __NR_N64_/ {
+ name = $2;
+ sub (/_N64_/, "_", name);
+ print;
+ print "#if _MIPS_SIM == _ABI64";
+ print "# define " name " " $2;
+ print "#endif";
+ next;
+}
+{
+ print;
+}'
+ else
+ echo '#include <asm/unistd.h>' > asm-unistd.h
+ fi ;;
+mips*)
+ rm -f asm-unistd.h
+ echo '#include <asm/unistd.h>' > asm-unistd.h
+ ;;
+esac
+
+case "$prefix" in
+/usr | /usr/)
+ # 64-bit libraries on bi-arch platforms go in /lib64 instead of /lib.
+ # Allow earlier configure scripts to handle libc_cv_slibdir, libdir,
+ # and libc_cv_localedir.
+ test -n "$libc_cv_slibdir" || \
+ case $machine in
+ mips/mips64/n64/* )
+ libc_cv_slibdir="/lib64"
+ if test "$libdir" = '${exec_prefix}/lib'; then
+ libdir='${exec_prefix}/lib64';
+ # Locale data can be shared between 32bit and 64bit libraries
+ libc_cv_localedir='${exec_prefix}/lib/locale'
+ fi
+ ;;
+ mips/mips64/n32/* )
+ libc_cv_slibdir="/lib32"
+ if test "$libdir" = '${exec_prefix}/lib'; then
+ libdir='${exec_prefix}/lib32';
+ # Locale data can be shared between 32bit and 64bit libraries
+ libc_cv_localedir='${exec_prefix}/lib/locale'
+ fi
+ ;;
+ *)
+ libc_cv_slibdir="/lib"
+ ;;
+ esac
+esac
+
+if test -z "$arch_minimum_kernel"; then
+ arch_minimum_kernel=2.4.0
+ libc_cv_gcc_unwind_find_fde=yes
+fi
diff --git a/ports/sysdeps/unix/sysv/linux/mips/configure.in b/ports/sysdeps/unix/sysv/linux/mips/configure.in
new file mode 100644
index 000000000..7248e1f3f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/configure.in
@@ -0,0 +1,112 @@
+sinclude(./aclocal.m4)dnl Autoconf lossage
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/sysv/linux/mips.
+
+case $machine in
+mips*64*)
+ rm -f asm-unistd.h
+ asm_unistd_h=$sysheaders/asm/unistd.h
+ if test ! -f $asm_unistd_h; then
+ # Try to find asm/unistd.h in compiler header search path.
+ try_asm_unistd_h=`echo '#include <asm/unistd.h>' | $CPP - |
+ sed -n '/^# 1 "\(\/[^"]*\)".*/{s,,\1,p;q;}'`
+ if test -n "$try_asm_unistd_h" &&
+ test -f "$try_asm_unistd_h"; then
+ asm_unistd_h=$try_asm_unistd_h
+ fi
+ fi
+ if test ! -f "$asm_unistd_h"; then
+ AC_MSG_WARN([*** asm/unistd.h not found, it will not be pre-processed])
+ echo '#include <asm/unistd.h>' > asm-unistd.h
+ elif grep __NR_N32_open "$asm_unistd_h" > /dev/null; then
+ # The point of this preprocessing is to turn __NR_<syscall> into
+ # __NR_N64_<syscall>, as well as to define __NR_<syscall> to
+ # __NR_<abi>_<syscall>, if __NR_<abi>_<syscall> is defined
+ # and <abi> is the compiler-enabled ABI.
+ cat "$asm_unistd_h" |
+ sed -e 's,__NR_,__NR_N64_,g' \
+ -e 's,__NR_N64_##,__NR_##,g' \
+ -e 's,__NR_N64_O32_,__NR_O32_,g' \
+ -e 's,__NR_N64_N32_,__NR_N32_,g' \
+ -e 's,__NR_N64_N64_,__NR_N64_,g' \
+ | awk > asm-unistd.h '
+BEGIN { print "#include <sgidefs.h>"; }
+/^#define __NR.*unused/ { print; next; }
+/^#define __NR_N64__exit __NR_N64_exit/ {
+ print "#define __NR__exit __NR_exit";
+ print "#define __NR_O32__exit __NR_O32_exit";
+ print "#define __NR_N32__exit __NR_N32_exit";
+ print; next;
+}
+/^#define __NR_O32_/ {
+ name = $2;
+ sub (/_O32_/, "_", name);
+ print;
+ print "#if _MIPS_SIM == _ABIO32";
+ print "# define " name " " $2;
+ print "#endif";
+ next;
+}
+/^#define __NR_N32_/ {
+ name = $2;
+ sub (/_N32_/, "_", name);
+ print;
+ print "#if _MIPS_SIM == _ABIN32";
+ print "# define " name " " $2;
+ print "#endif";
+ next;
+}
+/^#define __NR_N64_/ {
+ name = $2;
+ sub (/_N64_/, "_", name);
+ print;
+ print "#if _MIPS_SIM == _ABI64";
+ print "# define " name " " $2;
+ print "#endif";
+ next;
+}
+{
+ print;
+}'
+ else
+ echo '#include <asm/unistd.h>' > asm-unistd.h
+ fi ;;
+mips*)
+ rm -f asm-unistd.h
+ echo '#include <asm/unistd.h>' > asm-unistd.h
+ ;;
+esac
+
+case "$prefix" in
+/usr | /usr/)
+ # 64-bit libraries on bi-arch platforms go in /lib64 instead of /lib.
+ # Allow earlier configure scripts to handle libc_cv_slibdir, libdir,
+ # and libc_cv_localedir.
+ test -n "$libc_cv_slibdir" || \
+ case $machine in
+ mips/mips64/n64/* )
+ libc_cv_slibdir="/lib64"
+ if test "$libdir" = '${exec_prefix}/lib'; then
+ libdir='${exec_prefix}/lib64';
+ # Locale data can be shared between 32bit and 64bit libraries
+ libc_cv_localedir='${exec_prefix}/lib/locale'
+ fi
+ ;;
+ mips/mips64/n32/* )
+ libc_cv_slibdir="/lib32"
+ if test "$libdir" = '${exec_prefix}/lib'; then
+ libdir='${exec_prefix}/lib32';
+ # Locale data can be shared between 32bit and 64bit libraries
+ libc_cv_localedir='${exec_prefix}/lib/locale'
+ fi
+ ;;
+ *)
+ libc_cv_slibdir="/lib"
+ ;;
+ esac
+esac
+
+if test -z "$arch_minimum_kernel"; then
+ arch_minimum_kernel=2.4.0
+ libc_cv_gcc_unwind_find_fde=yes
+fi
diff --git a/ports/sysdeps/unix/sysv/linux/mips/dl-cache.h b/ports/sysdeps/unix/sysv/linux/mips/dl-cache.h
new file mode 100644
index 000000000..4fa5d3ad2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/dl-cache.h
@@ -0,0 +1,43 @@
+/* Support for reading /etc/ld.so.cache files written by Linux ldconfig.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define add_system_dir(dir) \
+ do \
+ { \
+ size_t len = strlen (dir); \
+ char path[len + 3]; \
+ memcpy (path, dir, len + 1); \
+ if (len >= 6 \
+ && (! memcmp (path + len - 6, "/lib64", 6) \
+ || ! memcmp (path + len - 6, "/lib32", 6))) \
+ { \
+ len -= 2; \
+ path[len] = '\0'; \
+ } \
+ add_dir (path); \
+ if (len >= 4 && ! memcmp (path + len - 4, "/lib", 4)) \
+ { \
+ memcpy (path + len, "32", 3); \
+ add_dir (path); \
+ memcpy (path + len, "64", 3); \
+ add_dir (path); \
+ } \
+ } while (0)
+
+#include_next <dl-cache.h>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/entry.h b/ports/sysdeps/unix/sysv/linux/mips/entry.h
new file mode 100644
index 000000000..04d05d2b0
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/entry.h
@@ -0,0 +1,5 @@
+#ifndef __ASSEMBLY__
+extern void __start (void);
+#endif
+
+#define ENTRY_POINT __start
diff --git a/ports/sysdeps/unix/sysv/linux/mips/fcntl.c b/ports/sysdeps/unix/sysv/linux/mips/fcntl.c
new file mode 100644
index 000000000..ea951bc4f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/fcntl.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/ftruncate64.c b/ports/sysdeps/unix/sysv/linux/mips/ftruncate64.c
new file mode 100644
index 000000000..a46e22f82
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/ftruncate64.c
@@ -0,0 +1,76 @@
+/* Copyright (C) 1997,1998,1999,2000,2001,2002,2003,2005,2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/types.h>
+#include <errno.h>
+#include <endian.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+#include <kernel-features.h>
+
+#ifdef __NR_ftruncate64
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+/* The variable is shared between all wrappers around *truncate64 calls. */
+extern int __have_no_truncate64;
+#endif
+
+/* Truncate the file FD refers to to LENGTH bytes. */
+int
+__ftruncate64 (int fd, off64_t length)
+{
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ if (! __have_no_truncate64)
+#endif
+ {
+ unsigned int low = length & 0xffffffff;
+ unsigned int high = length >> 32;
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ int saved_errno = errno;
+#endif
+ int result = INLINE_SYSCALL (ftruncate64, 4, fd, 0,
+ __LONG_LONG_PAIR (high, low));
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ if (result != -1 || errno != ENOSYS)
+#endif
+ return result;
+
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ __set_errno (saved_errno);
+ __have_no_truncate64 = 1;
+#endif
+ }
+
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ if ((off_t) length != length)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+ return __ftruncate (fd, (off_t) length);
+#endif
+}
+weak_alias (__ftruncate64, ftruncate64)
+
+#else
+/* Use the generic implementation. */
+# include <misc/ftruncate64.c>
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/getmsg.c b/ports/sysdeps/unix/sysv/linux/mips/getmsg.c
new file mode 100644
index 000000000..3a1fa0852
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/getmsg.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/getmsg.c>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/getpagesize.c b/ports/sysdeps/unix/sysv/linux/mips/getpagesize.c
new file mode 100644
index 000000000..49492e513
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/getpagesize.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/ia64/getpagesize.c>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/getsysstats.c b/ports/sysdeps/unix/sysv/linux/mips/getsysstats.c
new file mode 100644
index 000000000..9b521ac76
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/getsysstats.c
@@ -0,0 +1,36 @@
+/* Determine various system internal values, Linux/MIPS version.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+/* We need to define a special parser for /proc/cpuinfo. */
+#define GET_NPROCS_PARSER(FP, BUFFER, RESULT) \
+ do \
+ { \
+ (RESULT) = 0; \
+ /* Read all lines and count the lines starting with the string \
+ "cpu model". We don't have to fear extremely long lines since \
+ the kernel will not generate them. 8192 bytes are really \
+ enough. */ \
+ while (fgets_unlocked (BUFFER, sizeof (BUFFER), FP) != NULL) \
+ if (strncmp (BUFFER, "cpu model", 9) == 0) \
+ ++(RESULT); \
+ } \
+ while (0)
+
+#include <sysdeps/unix/sysv/linux/getsysstats.c>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/ipc_priv.h b/ports/sysdeps/unix/sysv/linux/mips/ipc_priv.h
new file mode 100644
index 000000000..9b85386a7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/ipc_priv.h
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/alpha/ipc_priv.h>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/kernel-features.h b/ports/sysdeps/unix/sysv/linux/mips/kernel-features.h
new file mode 100644
index 000000000..f479b6063
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/kernel-features.h
@@ -0,0 +1,34 @@
+/* Set flags signalling availability of kernel features based on given
+ kernel version number.
+ Copyright (C) 1999-2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sgidefs.h>
+
+/* Linux 2.3.39 introduced 32bit UID/GIDs. Some platforms had 32
+ bit type all along. */
+#define __ASSUME_32BITUIDS 1
+
+/* MIPS platforms had IPC64 all along. */
+#define __ASSUME_IPC64 1
+
+#if _MIPS_SIM == _ABIN32
+# define __ASSUME_FCNTL64 1
+#endif
+
+#include_next <kernel-features.h>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/kernel_sigaction.h b/ports/sysdeps/unix/sysv/linux/mips/kernel_sigaction.h
new file mode 100644
index 000000000..b6f52cc9c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/kernel_sigaction.h
@@ -0,0 +1,40 @@
+/* This is the sigaction structure from the Linux 2.1.24 kernel. */
+
+#include <sgidefs.h>
+
+#define HAVE_SA_RESTORER
+
+struct old_kernel_sigaction {
+ unsigned int sa_flags;
+ __sighandler_t k_sa_handler;
+ unsigned long sa_mask;
+ unsigned int __pad0[3]; /* reserved, keep size constant */
+
+ /* Abi says here follows reserved int[2] */
+ void (*sa_restorer)(void);
+#if (_MIPS_SZPTR < 64)
+ /*
+ * For 32 bit code we have to pad struct sigaction to get
+ * constant size for the ABI
+ */
+ int pad1[1]; /* reserved */
+#endif
+};
+
+
+#define _KERNEL_NSIG 128
+#define _KERNEL_NSIG_BPW _MIPS_SZLONG
+#define _KERNEL_NSIG_WORDS (_KERNEL_NSIG / _KERNEL_NSIG_BPW)
+
+typedef struct {
+ unsigned long sig[_KERNEL_NSIG_WORDS];
+} kernel_sigset_t;
+
+/* This is the sigaction structure from the Linux 2.1.68 kernel. */
+struct kernel_sigaction {
+ unsigned int sa_flags;
+ __sighandler_t k_sa_handler;
+ kernel_sigset_t sa_mask;
+ void (*sa_restorer)(void);
+ int s_resv[1]; /* reserved */
+};
diff --git a/ports/sysdeps/unix/sysv/linux/mips/kernel_stat.h b/ports/sysdeps/unix/sysv/linux/mips/kernel_stat.h
new file mode 100644
index 000000000..e785bcd8c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/kernel_stat.h
@@ -0,0 +1,57 @@
+#include <sgidefs.h>
+/* As tempting as it is to define XSTAT_IS_XSTAT64 for n64, the
+ userland data structures are not identical, because of different
+ padding. */
+/* Definition of `struct stat' used in the kernel. */
+#if _MIPS_SIM != _ABIO32
+struct kernel_stat
+ {
+ unsigned int st_dev;
+ unsigned int __pad1[3];
+ unsigned long long st_ino;
+ unsigned int st_mode;
+ unsigned int st_nlink;
+ int st_uid;
+ int st_gid;
+ unsigned int st_rdev;
+ unsigned int __pad2[3];
+ long long st_size;
+ unsigned int st_atime_sec;
+ unsigned int st_atime_nsec;
+ unsigned int st_mtime_sec;
+ unsigned int st_mtime_nsec;
+ unsigned int st_ctime_sec;
+ unsigned int st_ctime_nsec;
+ unsigned int st_blksize;
+ unsigned int __pad3;
+ unsigned long long st_blocks;
+ };
+#else
+struct kernel_stat
+ {
+ unsigned long int st_dev;
+ long int __pad1[3]; /* Reserved for network id */
+ unsigned long int st_ino;
+ unsigned long int st_mode;
+ unsigned long int st_nlink;
+ long int st_uid;
+ long int st_gid;
+ unsigned long int st_rdev;
+ long int __pad2[2];
+ long int st_size;
+ long int __pad3;
+ unsigned int st_atime_sec;
+ unsigned int st_atime_nsec;
+ unsigned int st_mtime_sec;
+ unsigned int st_mtime_nsec;
+ unsigned int st_ctime_sec;
+ unsigned int st_ctime_nsec;
+ long int st_blksize;
+ long int st_blocks;
+ char st_fstype[16]; /* Filesystem type name, unsupported */
+ long st_pad4[8];
+ /* Linux specific fields */
+ unsigned int st_flags;
+ unsigned int st_gen;
+ };
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/kernel_termios.h b/ports/sysdeps/unix/sysv/linux/mips/kernel_termios.h
new file mode 100644
index 000000000..9b622f4d1
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/kernel_termios.h
@@ -0,0 +1,35 @@
+/* Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _KERNEL_TERMIOS_H
+#define _KERNEL_TERMIOS_H 1
+/* The following corresponds to the values from the Linux 2.1.24 kernel. */
+
+#define __KERNEL_NCCS 23
+
+struct __kernel_termios
+ {
+ tcflag_t c_iflag; /* input mode flags */
+ tcflag_t c_oflag; /* output mode flags */
+ tcflag_t c_cflag; /* control mode flags */
+ tcflag_t c_lflag; /* local mode flags */
+ cc_t c_line; /* line discipline */
+ cc_t c_cc[__KERNEL_NCCS]; /* control characters */
+ };
+
+#endif /* kernel_termios.h */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/lockf64.c b/ports/sysdeps/unix/sysv/linux/mips/lockf64.c
new file mode 100644
index 000000000..a88f5a784
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/lockf64.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/lockf64.c>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/ports/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
new file mode 100644
index 000000000..3da241225
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
@@ -0,0 +1,292 @@
+/* Copyright (C) 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _LINUX_MIPS_MIPS32_SYSDEP_H
+#define _LINUX_MIPS_MIPS32_SYSDEP_H 1
+
+/* There is some commonality. */
+#include <sysdeps/unix/mips/mips32/sysdep.h>
+
+/* For Linux we can use the system call table in the header file
+ /usr/include/asm/unistd.h
+ of the kernel. But these symbols do not follow the SYS_* syntax
+ so we have to redefine the `SYS_ify' macro here. */
+#undef SYS_ify
+#ifdef __STDC__
+# define SYS_ify(syscall_name) __NR_##syscall_name
+#else
+# define SYS_ify(syscall_name) __NR_/**/syscall_name
+#endif
+
+#ifdef __ASSEMBLER__
+
+/* We don't want the label for the error handler to be visible in the symbol
+ table when we define it here. */
+#ifdef __PIC__
+# define SYSCALL_ERROR_LABEL 99b
+#endif
+
+#else /* ! __ASSEMBLER__ */
+
+/* Define a macro which expands into the inline wrapper code for a system
+ call. */
+#undef INLINE_SYSCALL
+#define INLINE_SYSCALL(name, nr, args...) \
+ ({ INTERNAL_SYSCALL_DECL(err); \
+ long result_var = INTERNAL_SYSCALL (name, err, nr, args); \
+ if ( INTERNAL_SYSCALL_ERROR_P (result_var, err) ) \
+ { \
+ __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, err)); \
+ result_var = -1L; \
+ } \
+ result_var; })
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) long err
+
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err) ((long) (err))
+
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err) (val)
+
+#undef INTERNAL_SYSCALL
+#define INTERNAL_SYSCALL(name, err, nr, args...) \
+ internal_syscall##nr (, "li\t$2, %2\t\t\t# " #name "\n\t", \
+ "i" (SYS_ify (name)), err, args)
+
+#undef INTERNAL_SYSCALL_NCS
+#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
+ internal_syscall##nr (= number, , "r" (__v0), err, args)
+
+#define internal_syscall0(ncs_init, cs_init, input, err, dummy...) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long __v0 asm("$2") ncs_init; \
+ register long __a3 asm("$7"); \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set reorder" \
+ : "=r" (__v0), "=r" (__a3) \
+ : input \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall1(ncs_init, cs_init, input, err, arg1) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long __v0 asm("$2") ncs_init; \
+ register long __a0 asm("$4") = (long) arg1; \
+ register long __a3 asm("$7"); \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set reorder" \
+ : "=r" (__v0), "=r" (__a3) \
+ : input, "r" (__a0) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall2(ncs_init, cs_init, input, err, arg1, arg2) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long __v0 asm("$2") ncs_init; \
+ register long __a0 asm("$4") = (long) arg1; \
+ register long __a1 asm("$5") = (long) arg2; \
+ register long __a3 asm("$7"); \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "=r" (__a3) \
+ : input, "r" (__a0), "r" (__a1) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall3(ncs_init, cs_init, input, err, arg1, arg2, arg3)\
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long __v0 asm("$2") ncs_init; \
+ register long __a0 asm("$4") = (long) arg1; \
+ register long __a1 asm("$5") = (long) arg2; \
+ register long __a2 asm("$6") = (long) arg3; \
+ register long __a3 asm("$7"); \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "=r" (__a3) \
+ : input, "r" (__a0), "r" (__a1), "r" (__a2) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall4(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4)\
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long __v0 asm("$2") ncs_init; \
+ register long __a0 asm("$4") = (long) arg1; \
+ register long __a1 asm("$5") = (long) arg2; \
+ register long __a2 asm("$6") = (long) arg3; \
+ register long __a3 asm("$7") = (long) arg4; \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "+r" (__a3) \
+ : input, "r" (__a0), "r" (__a1), "r" (__a2) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+/* We need to use a frame pointer for the functions in which we
+ adjust $sp around the syscall, or debug information and unwind
+ information will be $sp relative and thus wrong during the syscall. As
+ of GCC 3.4.3, this is sufficient. */
+#define FORCE_FRAME_POINTER alloca (4)
+
+#define internal_syscall5(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5)\
+({ \
+ long _sys_result; \
+ \
+ FORCE_FRAME_POINTER; \
+ { \
+ register long __v0 asm("$2") ncs_init; \
+ register long __a0 asm("$4") = (long) arg1; \
+ register long __a1 asm("$5") = (long) arg2; \
+ register long __a2 asm("$6") = (long) arg3; \
+ register long __a3 asm("$7") = (long) arg4; \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ "subu\t$29, 32\n\t" \
+ "sw\t%6, 16($29)\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ "addiu\t$29, 32\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "+r" (__a3) \
+ : input, "r" (__a0), "r" (__a1), "r" (__a2), \
+ "r" ((long)arg5) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall6(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5, arg6)\
+({ \
+ long _sys_result; \
+ \
+ FORCE_FRAME_POINTER; \
+ { \
+ register long __v0 asm("$2") ncs_init; \
+ register long __a0 asm("$4") = (long) arg1; \
+ register long __a1 asm("$5") = (long) arg2; \
+ register long __a2 asm("$6") = (long) arg3; \
+ register long __a3 asm("$7") = (long) arg4; \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ "subu\t$29, 32\n\t" \
+ "sw\t%6, 16($29)\n\t" \
+ "sw\t%7, 20($29)\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ "addiu\t$29, 32\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "+r" (__a3) \
+ : input, "r" (__a0), "r" (__a1), "r" (__a2), \
+ "r" ((long)arg5), "r" ((long)arg6) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall7(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5, arg6, arg7)\
+({ \
+ long _sys_result; \
+ \
+ FORCE_FRAME_POINTER; \
+ { \
+ register long __v0 asm("$2") ncs_init; \
+ register long __a0 asm("$4") = (long) arg1; \
+ register long __a1 asm("$5") = (long) arg2; \
+ register long __a2 asm("$6") = (long) arg3; \
+ register long __a3 asm("$7") = (long) arg4; \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ "subu\t$29, 32\n\t" \
+ "sw\t%6, 16($29)\n\t" \
+ "sw\t%7, 20($29)\n\t" \
+ "sw\t%8, 24($29)\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ "addiu\t$29, 32\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "+r" (__a3) \
+ : input, "r" (__a0), "r" (__a1), "r" (__a2), \
+ "r" ((long)arg5), "r" ((long)arg6), "r" ((long)arg7) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define __SYSCALL_CLOBBERS "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", \
+ "$14", "$15", "$24", "$25", "memory"
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* linux/mips/mips32/sysdep.h */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/Makefile b/ports/sysdeps/unix/sysv/linux/mips/mips64/Makefile
new file mode 100644
index 000000000..0a37c5b9b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/Makefile
@@ -0,0 +1,9 @@
+ifeq ($(subdir),socket)
+CFLAGS-recv.c += -fexceptions
+CFLAGS-send.c += -fexceptions
+endif
+
+ifeq ($(subdir),nptl)
+CFLAGS-recv.c += -fexceptions
+CFLAGS-send.c += -fexceptions
+endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/configure b/ports/sysdeps/unix/sysv/linux/mips/mips64/configure
new file mode 100644
index 000000000..c331f9829
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/configure
@@ -0,0 +1,4 @@
+# This file is generated from configure.in by Autoconf. DO NOT EDIT!
+ # Local configure fragment for sysdeps/unix/sysv/linux/mips/mips64.
+
+ldd_rewrite_script=$dest/ldd-rewrite.sed
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/configure.in b/ports/sysdeps/unix/sysv/linux/mips/mips64/configure.in
new file mode 100644
index 000000000..a28638ad8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/configure.in
@@ -0,0 +1,5 @@
+sinclude(./aclocal.m4)dnl Autoconf lossage
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/sysv/linux/mips/mips64.
+
+ldd_rewrite_script=$dest/ldd-rewrite.sed
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/ldconfig.h b/ports/sysdeps/unix/sysv/linux/mips/mips64/ldconfig.h
new file mode 100644
index 000000000..d490fb95e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/ldconfig.h
@@ -0,0 +1,26 @@
+/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdeps/generic/ldconfig.h>
+
+#define SYSDEP_KNOWN_INTERPRETER_NAMES \
+ { "/lib32/ld.so.1", FLAG_ELF_LIBC6 }, \
+ { "/lib64/ld.so.1", FLAG_ELF_LIBC6 },
+#define SYSDEP_KNOWN_LIBRARY_NAMES \
+ { "libc.so.6", FLAG_ELF_LIBC6 }, \
+ { "libm.so.6", FLAG_ELF_LIBC6 },
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/ldd-rewrite.sed b/ports/sysdeps/unix/sysv/linux/mips/mips64/ldd-rewrite.sed
new file mode 100644
index 000000000..2c327327e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/ldd-rewrite.sed
@@ -0,0 +1 @@
+s_^\(RTLDLIST=\)\(.*lib\)\(\|32\|64\)\(/[^/]*\.so\.[0-9.]*\)[ ]*$_\1"\232\4 \264\4 \2\4"_
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/llseek.c b/ports/sysdeps/unix/sysv/linux/mips/mips64/llseek.c
new file mode 100644
index 000000000..24013a822
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/llseek.c
@@ -0,0 +1 @@
+/* lseek() is 64-bit capable already. */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/n32/ftruncate64.c b/ports/sysdeps/unix/sysv/linux/mips/mips64/n32/ftruncate64.c
new file mode 100644
index 000000000..42efcba31
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/n32/ftruncate64.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/types.h>
+
+#include <sysdep.h>
+
+extern int ftruncate (int fd, off64_t length);
+
+int __ftruncate64 (int fd, off64_t length) {
+ return ftruncate (fd, length);
+}
+weak_alias (__ftruncate64, ftruncate64)
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h b/ports/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
new file mode 100644
index 000000000..247d4ffbf
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
@@ -0,0 +1,248 @@
+/* Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _LINUX_MIPS_SYSDEP_H
+#define _LINUX_MIPS_SYSDEP_H 1
+
+/* There is some commonality. */
+#include <sysdeps/unix/mips/mips64/n32/sysdep.h>
+
+/* For Linux we can use the system call table in the header file
+ /usr/include/asm/unistd.h
+ of the kernel. But these symbols do not follow the SYS_* syntax
+ so we have to redefine the `SYS_ify' macro here. */
+#undef SYS_ify
+#ifdef __STDC__
+# define SYS_ify(syscall_name) __NR_##syscall_name
+#else
+# define SYS_ify(syscall_name) __NR_/**/syscall_name
+#endif
+
+#ifdef __ASSEMBLER__
+
+/* We don't want the label for the error handler to be visible in the symbol
+ table when we define it here. */
+#ifdef __PIC__
+# define SYSCALL_ERROR_LABEL 99b
+#endif
+
+#else /* ! __ASSEMBLER__ */
+
+/* Define a macro which expands into the inline wrapper code for a system
+ call. */
+#undef INLINE_SYSCALL
+#define INLINE_SYSCALL(name, nr, args...) \
+ ({ INTERNAL_SYSCALL_DECL(err); \
+ long result_var = INTERNAL_SYSCALL (name, err, nr, args); \
+ if ( INTERNAL_SYSCALL_ERROR_P (result_var, err) ) \
+ { \
+ __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, err)); \
+ result_var = -1L; \
+ } \
+ result_var; })
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) long err
+
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err) ((long) (err))
+
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err) (val)
+
+#undef INTERNAL_SYSCALL
+#define INTERNAL_SYSCALL(name, err, nr, args...) \
+ internal_syscall##nr (, "li\t$2, %2\t\t\t# " #name "\n\t", \
+ "i" (SYS_ify (name)), err, args)
+
+#undef INTERNAL_SYSCALL_NCS
+#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
+ internal_syscall##nr (= number, , "r" (__v0), err, args)
+
+#define internal_syscall0(ncs_init, cs_init, input, err, dummy...) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long long __v0 asm("$2") ncs_init; \
+ register long long __a3 asm("$7"); \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set reorder" \
+ : "=r" (__v0), "=r" (__a3) \
+ : input \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall1(ncs_init, cs_init, input, err, arg1) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long long __v0 asm("$2") ncs_init; \
+ register long long __a0 asm("$4") = (long long) arg1; \
+ register long long __a3 asm("$7"); \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set reorder" \
+ : "=r" (__v0), "=r" (__a3) \
+ : input, "r" (__a0) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall2(ncs_init, cs_init, input, err, arg1, arg2) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long long __v0 asm("$2") ncs_init; \
+ register long long __a0 asm("$4") = (long long) arg1; \
+ register long long __a1 asm("$5") = (long long) arg2; \
+ register long long __a3 asm("$7"); \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "=r" (__a3) \
+ : input, "r" (__a0), "r" (__a1) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall3(ncs_init, cs_init, input, err, arg1, arg2, arg3) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long long __v0 asm("$2") ncs_init; \
+ register long long __a0 asm("$4") = (long long) arg1; \
+ register long long __a1 asm("$5") = (long long) arg2; \
+ register long long __a2 asm("$6") = (long long) arg3; \
+ register long long __a3 asm("$7"); \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "=r" (__a3) \
+ : input, "r" (__a0), "r" (__a1), "r" (__a2) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall4(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long long __v0 asm("$2") ncs_init; \
+ register long long __a0 asm("$4") = (long long) arg1; \
+ register long long __a1 asm("$5") = (long long) arg2; \
+ register long long __a2 asm("$6") = (long long) arg3; \
+ register long long __a3 asm("$7") = (long long) arg4; \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "+r" (__a3) \
+ : input, "r" (__a0), "r" (__a1), "r" (__a2) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall5(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long long __v0 asm("$2") ncs_init; \
+ register long long __a0 asm("$4") = (long long) arg1; \
+ register long long __a1 asm("$5") = (long long) arg2; \
+ register long long __a2 asm("$6") = (long long) arg3; \
+ register long long __a3 asm("$7") = (long long) arg4; \
+ register long long __a4 asm("$8") = (long long) arg5; \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "+r" (__a3) \
+ : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall6(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5, arg6) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long long __v0 asm("$2") ncs_init; \
+ register long long __a0 asm("$4") = (long long) arg1; \
+ register long long __a1 asm("$5") = (long long) arg2; \
+ register long long __a2 asm("$6") = (long long) arg3; \
+ register long long __a3 asm("$7") = (long long) arg4; \
+ register long long __a4 asm("$8") = (long long) arg5; \
+ register long long __a5 asm("$9") = (long long) arg6; \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "+r" (__a3) \
+ : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), \
+ "r" (__a5) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
+ "$14", "$15", "$24", "$25", "memory"
+#endif /* __ASSEMBLER__ */
+
+#endif /* linux/mips/sysdep.h */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/n32/truncate64.c b/ports/sysdeps/unix/sysv/linux/mips/mips64/n32/truncate64.c
new file mode 100644
index 000000000..339023f14
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/n32/truncate64.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/types.h>
+
+#include <sysdep.h>
+#include <bp-checks.h>
+
+extern int truncate (const char *__unbounded path, int dummy,
+ off64_t length);
+
+int truncate64 (const char *__unbounded path, int dummy,
+ off64_t length) {
+ return truncate (path, dummy, length);
+}
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c b/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c
new file mode 100644
index 000000000..33918ea6a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c
@@ -0,0 +1 @@
+/* glob64 is in glob.c */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S b/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S
new file mode 100644
index 000000000..e4b4f00a8
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S
@@ -0,0 +1,42 @@
+/* Copyright 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#include <sys/asm.h>
+
+/* Sign-extend the ioctl number, since the kernel wants it as a
+ sign-extended 32-bit value, but our prototype is that of a long. */
+
+ .text
+ENTRY (__ioctl)
+ sll a1, a1, 0
+ li v0, __NR_ioctl
+ syscall /* Do the system call. */
+ bne a3, zero, L(error)
+ ret
+
+L(error):
+ SETUP_GP64 (a0, __ioctl)
+ PTR_LA t9, __syscall_error
+ RESTORE_GP64
+ jr t9
+
+PSEUDO_END (__ioctl)
+
+weak_alias (__ioctl, ioctl)
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h b/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
new file mode 100644
index 000000000..c238822b2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
@@ -0,0 +1,248 @@
+/* Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _LINUX_MIPS_SYSDEP_H
+#define _LINUX_MIPS_SYSDEP_H 1
+
+/* There is some commonality. */
+#include <sysdeps/unix/mips/mips64/n64/sysdep.h>
+
+/* For Linux we can use the system call table in the header file
+ /usr/include/asm/unistd.h
+ of the kernel. But these symbols do not follow the SYS_* syntax
+ so we have to redefine the `SYS_ify' macro here. */
+#undef SYS_ify
+#ifdef __STDC__
+# define SYS_ify(syscall_name) __NR_##syscall_name
+#else
+# define SYS_ify(syscall_name) __NR_/**/syscall_name
+#endif
+
+#ifdef __ASSEMBLER__
+
+/* We don't want the label for the error handler to be visible in the symbol
+ table when we define it here. */
+#ifdef __PIC__
+# define SYSCALL_ERROR_LABEL 99b
+#endif
+
+#else /* ! __ASSEMBLER__ */
+
+/* Define a macro which expands into the inline wrapper code for a system
+ call. */
+#undef INLINE_SYSCALL
+#define INLINE_SYSCALL(name, nr, args...) \
+ ({ INTERNAL_SYSCALL_DECL(err); \
+ long result_var = INTERNAL_SYSCALL (name, err, nr, args); \
+ if ( INTERNAL_SYSCALL_ERROR_P (result_var, err) ) \
+ { \
+ __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, err)); \
+ result_var = -1L; \
+ } \
+ result_var; })
+
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) long err
+
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err) ((long) (err))
+
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err) (val)
+
+#undef INTERNAL_SYSCALL
+#define INTERNAL_SYSCALL(name, err, nr, args...) \
+ internal_syscall##nr (, "li\t$2, %2\t\t\t# " #name "\n\t", \
+ "i" (SYS_ify (name)), err, args)
+
+#undef INTERNAL_SYSCALL_NCS
+#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
+ internal_syscall##nr (= number, , "r" (__v0), err, args)
+
+#define internal_syscall0(ncs_init, cs_init, input, err, dummy...) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long __v0 asm("$2") ncs_init; \
+ register long __a3 asm("$7"); \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set reorder" \
+ : "=r" (__v0), "=r" (__a3) \
+ : input \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall1(ncs_init, cs_init, input, err, arg1) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long __v0 asm("$2") ncs_init; \
+ register long __a0 asm("$4") = (long) arg1; \
+ register long __a3 asm("$7"); \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set reorder" \
+ : "=r" (__v0), "=r" (__a3) \
+ : input, "r" (__a0) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall2(ncs_init, cs_init, input, err, arg1, arg2) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long __v0 asm("$2") ncs_init; \
+ register long __a0 asm("$4") = (long) arg1; \
+ register long __a1 asm("$5") = (long) arg2; \
+ register long __a3 asm("$7"); \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "=r" (__a3) \
+ : input, "r" (__a0), "r" (__a1) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall3(ncs_init, cs_init, input, err, arg1, arg2, arg3) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long __v0 asm("$2") ncs_init; \
+ register long __a0 asm("$4") = (long) arg1; \
+ register long __a1 asm("$5") = (long) arg2; \
+ register long __a2 asm("$6") = (long) arg3; \
+ register long __a3 asm("$7"); \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "=r" (__a3) \
+ : input, "r" (__a0), "r" (__a1), "r" (__a2) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall4(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long __v0 asm("$2") ncs_init; \
+ register long __a0 asm("$4") = (long) arg1; \
+ register long __a1 asm("$5") = (long) arg2; \
+ register long __a2 asm("$6") = (long) arg3; \
+ register long __a3 asm("$7") = (long) arg4; \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "+r" (__a3) \
+ : input, "r" (__a0), "r" (__a1), "r" (__a2) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall5(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long __v0 asm("$2") ncs_init; \
+ register long __a0 asm("$4") = (long) arg1; \
+ register long __a1 asm("$5") = (long) arg2; \
+ register long __a2 asm("$6") = (long) arg3; \
+ register long __a3 asm("$7") = (long) arg4; \
+ register long __a4 asm("$8") = (long) arg5; \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "+r" (__a3) \
+ : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define internal_syscall6(ncs_init, cs_init, input, err, arg1, arg2, arg3, arg4, arg5, arg6) \
+({ \
+ long _sys_result; \
+ \
+ { \
+ register long __v0 asm("$2") ncs_init; \
+ register long __a0 asm("$4") = (long) arg1; \
+ register long __a1 asm("$5") = (long) arg2; \
+ register long __a2 asm("$6") = (long) arg3; \
+ register long __a3 asm("$7") = (long) arg4; \
+ register long __a4 asm("$8") = (long) arg5; \
+ register long __a5 asm("$9") = (long) arg6; \
+ __asm__ volatile ( \
+ ".set\tnoreorder\n\t" \
+ cs_init \
+ "syscall\n\t" \
+ ".set\treorder" \
+ : "=r" (__v0), "+r" (__a3) \
+ : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), \
+ "r" (__a5) \
+ : __SYSCALL_CLOBBERS); \
+ err = __a3; \
+ _sys_result = __v0; \
+ } \
+ _sys_result; \
+})
+
+#define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
+ "$14", "$15", "$24", "$25", "memory"
+#endif /* __ASSEMBLER__ */
+
+#endif /* linux/mips/sysdep.h */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/nptl/sysdep-cancel.h b/ports/sysdeps/unix/sysv/linux/mips/mips64/nptl/sysdep-cancel.h
new file mode 100644
index 000000000..e184c9123
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/nptl/sysdep-cancel.h
@@ -0,0 +1,183 @@
+/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <sysdeps/generic/sysdep.h>
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <nptl/pthreadP.h>
+#endif
+#include <sys/asm.h>
+
+/* Gas will put the initial save of $gp into the CIE, because it appears to
+ happen before any instructions. So we use cfi_same_value instead of
+ cfi_restore. */
+
+#ifdef HAVE_ASM_CFI_DIRECTIVES
+# define cfi_same_value .cfi_same_value
+#else
+# define cfi_same_value
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+#ifdef __PIC__
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .align 2; \
+ L(pseudo_start): \
+ cfi_startproc; \
+ cfi_adjust_cfa_offset (STKSPACE); \
+ cfi_rel_offset (gp, STKOFF_GP); \
+ 99: PTR_LA t9,__syscall_error; \
+ /* manual cpreturn */ \
+ REG_L gp, STKOFF_GP(sp); \
+ cfi_same_value (gp); \
+ RESTORESTK; \
+ jr t9; \
+ .type __##syscall_name##_nocancel, @function; \
+ .globl __##syscall_name##_nocancel; \
+ __##syscall_name##_nocancel: \
+ SAVESTK; \
+ .cpsetup t9, STKOFF_GP, name; \
+ cfi_rel_offset (gp, STKOFF_GP); \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ bne a3, zero, SYSCALL_ERROR_LABEL; \
+ /* manual cpreturn */ \
+ REG_L gp, STKOFF_GP(sp); \
+ cfi_same_value (gp); \
+ RESTORESTK; \
+ ret; \
+ .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
+ ENTRY (name) \
+ SAVESTK; \
+ .cpsetup t9, STKOFF_GP, name; \
+ cfi_rel_offset (gp, STKOFF_GP); \
+ SINGLE_THREAD_P(v1); \
+ bne zero, v1, L(pseudo_cancel); \
+ .set noreorder; \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, SYSCALL_ERROR_LABEL; \
+ /* manual cpreturn */ \
+ REG_L gp, STKOFF_GP(sp); \
+ cfi_same_value (gp); \
+ RESTORESTK; \
+ ret; \
+ L(pseudo_cancel): \
+ cfi_adjust_cfa_offset (STKSPACE); \
+ cfi_rel_offset (gp, STKOFF_GP); \
+ REG_S ra, STKOFF_RA(sp); \
+ cfi_rel_offset (ra, STKOFF_RA); \
+ PUSHARGS_##args; /* save syscall args */ \
+ CENABLE; \
+ REG_S v0, STKOFF_SVMSK(sp); /* save mask */ \
+ POPARGS_##args; /* restore syscall args */ \
+ .set noreorder; \
+ li v0, SYS_ify (syscall_name); \
+ syscall; \
+ .set reorder; \
+ REG_S v0, STKOFF_SC_V0(sp); /* save syscall result */ \
+ REG_S a3, STKOFF_SC_ERR(sp); /* save syscall error flag */ \
+ REG_L a0, STKOFF_SVMSK(sp); /* pass mask as arg1 */ \
+ CDISABLE; \
+ REG_L a3, STKOFF_SC_ERR(sp); /* restore syscall error flag */ \
+ REG_L ra, STKOFF_RA(sp); /* restore return address */ \
+ REG_L v0, STKOFF_SC_V0(sp); /* restore syscall result */ \
+ bne a3, zero, SYSCALL_ERROR_LABEL; \
+ /* manual cpreturn */ \
+ REG_L gp, STKOFF_GP(sp); \
+ cfi_same_value (gp); \
+ RESTORESTK; \
+ L(pseudo_end):
+
+
+# undef PSEUDO_END
+# define PSEUDO_END(sym) cfi_endproc; .end sym; .size sym,.-sym
+
+#endif
+
+# define PUSHARGS_0 /* nothing to do */
+# define PUSHARGS_1 PUSHARGS_0 REG_S a0, STKOFF_A0(sp); cfi_rel_offset (a0, STKOFF_A0);
+# define PUSHARGS_2 PUSHARGS_1 REG_S a1, STKOFF_A1(sp); cfi_rel_offset (a1, STKOFF_A1);
+# define PUSHARGS_3 PUSHARGS_2 REG_S a2, STKOFF_A2(sp); cfi_rel_offset (a2, STKOFF_A2);
+# define PUSHARGS_4 PUSHARGS_3 REG_S a3, STKOFF_A3(sp); cfi_rel_offset (a3, STKOFF_A3);
+# define PUSHARGS_5 PUSHARGS_4 REG_S a4, STKOFF_A4(sp); cfi_rel_offset (a3, STKOFF_A4);
+# define PUSHARGS_6 PUSHARGS_5 REG_S a5, STKOFF_A5(sp); cfi_rel_offset (a3, STKOFF_A5);
+
+# define POPARGS_0 /* nothing to do */
+# define POPARGS_1 POPARGS_0 REG_L a0, STKOFF_A0(sp);
+# define POPARGS_2 POPARGS_1 REG_L a1, STKOFF_A1(sp);
+# define POPARGS_3 POPARGS_2 REG_L a2, STKOFF_A2(sp);
+# define POPARGS_4 POPARGS_3 REG_L a3, STKOFF_A3(sp);
+# define POPARGS_5 POPARGS_4 REG_L a4, STKOFF_A4(sp);
+# define POPARGS_6 POPARGS_5 REG_L a5, STKOFF_A5(sp);
+
+/* Save an even number of slots. Should be 0 if an even number of slots
+ are used below, or SZREG if an odd number are used. */
+# define STK_PAD SZREG
+
+/* Place values that we are more likely to use later in this sequence, i.e.
+ closer to the SP at function entry. If you do that, the are more
+ likely to already be in your d-cache. */
+# define STKOFF_A5 (STK_PAD)
+# define STKOFF_A4 (STKOFF_A5 + SZREG)
+# define STKOFF_A3 (STKOFF_A4 + SZREG)
+# define STKOFF_A2 (STKOFF_A3 + SZREG) /* MT and more args. */
+# define STKOFF_A1 (STKOFF_A2 + SZREG) /* MT and 2 args. */
+# define STKOFF_A0 (STKOFF_A1 + SZREG) /* MT and 1 arg. */
+# define STKOFF_RA (STKOFF_A0 + SZREG) /* Used if MT. */
+# define STKOFF_SC_V0 (STKOFF_RA + SZREG) /* Used if MT. */
+# define STKOFF_SC_ERR (STKOFF_SC_V0 + SZREG) /* Used if MT. */
+# define STKOFF_SVMSK (STKOFF_SC_ERR + SZREG) /* Used if MT. */
+# define STKOFF_GP (STKOFF_SVMSK + SZREG) /* Always used. */
+
+# define STKSPACE (STKOFF_GP + SZREG)
+# define SAVESTK PTR_SUBU sp, STKSPACE; cfi_adjust_cfa_offset(STKSPACE)
+# define RESTORESTK PTR_ADDU sp, STKSPACE; cfi_adjust_cfa_offset(-STKSPACE)
+
+# ifdef IS_IN_libpthread
+# define CENABLE PTR_LA t9, __pthread_enable_asynccancel; jalr t9
+# define CDISABLE PTR_LA t9, __pthread_disable_asynccancel; jalr t9
+# elif defined IS_IN_librt
+# define CENABLE PTR_LA t9, __librt_enable_asynccancel; jalr t9
+# define CDISABLE PTR_LA t9, __librt_disable_asynccancel; jalr t9
+# else
+# define CENABLE PTR_LA t9, __libc_enable_asynccancel; jalr t9
+# define CDISABLE PTR_LA t9, __libc_disable_asynccancel; jalr t9
+# endif
+
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) \
+ == 0, 1)
+# else
+# define SINGLE_THREAD_P(reg) \
+ READ_THREAD_POINTER(reg); \
+ lw reg, MULTIPLE_THREADS_OFFSET(reg)
+#endif
+
+#elif !defined __ASSEMBLER__
+
+# define SINGLE_THREAD_P 1
+# define NO_CANCELLATION 1
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/recv.c b/ports/sysdeps/unix/sysv/linux/mips/mips64/recv.c
new file mode 100644
index 000000000..b910525c9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/recv.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/x86_64/recv.c>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/send.c b/ports/sysdeps/unix/sysv/linux/mips/mips64/send.c
new file mode 100644
index 000000000..d2c2996a2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/send.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/x86_64/send.c>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/syscall.S b/ports/sysdeps/unix/sysv/linux/mips/mips64/syscall.S
new file mode 100644
index 000000000..3c6aaac81
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/syscall.S
@@ -0,0 +1,60 @@
+/* Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#include <sys/asm.h>
+
+/* Usage:
+ long syscall (syscall_number, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
+
+ We need to do some arg shifting, syscall_number will be in v0. */
+
+
+ .text
+NESTED (syscall, SZREG, ra)
+ .mask 0x00010000, -SZREG
+ .fmask 0x00000000, 0
+ PTR_ADDIU sp, -SZREG
+ REG_S s0, (sp)
+
+ move s0, a0
+ move a0, a1 /* shift arg1 - arg7. */
+ move a1, a2
+ move a2, a3
+ move a3, a4
+ move a4, a5
+ move a5, a6
+ move a6, a7
+
+ move v0, s0 /* Syscall number -> v0 */
+ syscall /* Do the system call. */
+
+ REG_L s0, (sp)
+ PTR_ADDIU sp, SZREG
+ bne a3, zero, L(error)
+
+ ret
+
+L(error):
+ SETUP_GP64 (a0, syscall)
+ PTR_LA t9, __syscall_error
+ RESTORE_GP64
+ jr t9
+
+END (syscall)
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list b/ports/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
new file mode 100644
index 000000000..0d1657d9f
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/syscalls.list
@@ -0,0 +1,17 @@
+# File name Caller Syscall name Args Strong name Weak names
+
+lseek - lseek Ci:iii __libc_lseek __lseek lseek __llseek llseek __libc_lseek64 __lseek64 lseek64
+
+# semaphore and shm system calls
+msgctl - msgctl i:iip __msgctl msgctl
+msgget - msgget i:ii __msgget msgget
+msgrcv - msgrcv Ci:ibnii __msgrcv msgrcv
+msgsnd - msgsnd Ci:ibni __msgsnd msgsnd
+shmat - shmat i:ipi __shmat shmat
+shmctl - shmctl i:iip __shmctl shmctl
+shmdt - shmdt i:s __shmdt shmdt
+shmget - shmget i:iii __shmget shmget
+semop - semop i:ipi __semop semop
+semtimedop - semtimedop i:ipip semtimedop
+semget - semget i:iii __semget semget
+semctl - semctl i:iiii __semctl semctl
diff --git a/ports/sysdeps/unix/sysv/linux/mips/mips64/umount.c b/ports/sysdeps/unix/sysv/linux/mips/mips64/umount.c
new file mode 100644
index 000000000..9a91ba5b2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/mips64/umount.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/hppa/umount.c>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/nptl/bits/pthreadtypes.h b/ports/sysdeps/unix/sysv/linux/mips/nptl/bits/pthreadtypes.h
new file mode 100644
index 000000000..eda0a2fbe
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/nptl/bits/pthreadtypes.h
@@ -0,0 +1,215 @@
+/* Machine-specific pthread type layouts. MIPS version.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#if _MIPS_SIM == _ABI64
+# define __SIZEOF_PTHREAD_ATTR_T 56
+# define __SIZEOF_PTHREAD_MUTEX_T 40
+# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+# define __SIZEOF_PTHREAD_COND_T 48
+# define __SIZEOF_PTHREAD_CONDATTR_T 4
+# define __SIZEOF_PTHREAD_RWLOCK_T 56
+# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+# define __SIZEOF_PTHREAD_BARRIER_T 32
+# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+#else
+# define __SIZEOF_PTHREAD_ATTR_T 36
+# define __SIZEOF_PTHREAD_MUTEX_T 24
+# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+# define __SIZEOF_PTHREAD_COND_T 48
+# define __SIZEOF_PTHREAD_CONDATTR_T 4
+# define __SIZEOF_PTHREAD_RWLOCK_T 32
+# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+# define __SIZEOF_PTHREAD_BARRIER_T 20
+# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+#endif
+
+
+/* Thread identifiers. The structure of the attribute type is
+ deliberately not exposed. */
+typedef unsigned long int pthread_t;
+
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+} pthread_attr_t;
+
+
+#if _MIPS_SIM == _ABI64
+typedef struct __pthread_internal_list
+{
+ struct __pthread_internal_list *__prev;
+ struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is deliberately not exposed. */
+typedef union
+{
+ struct __pthread_mutex_s
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+#if _MIPS_SIM == _ABI64
+ unsigned int __nusers;
+#endif
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+#if _MIPS_SIM == _ABI64
+ int __spins;
+ __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV 1
+#else
+ unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
+#endif
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ int __align;
+} pthread_mutexattr_t;
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is deliberately not exposed. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is deliberately not exposed. */
+typedef union
+{
+# if _MIPS_SIM == _ABI64
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+ int __writer;
+ int __pad1;
+ unsigned long int __pad2;
+ unsigned long int __pad3;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned int __flags;
+ } __data;
+# else
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned int __flags;
+ int __writer;
+ } __data;
+# endif
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+#endif /* bits/pthreadtypes.h */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/nptl/bits/semaphore.h b/ports/sysdeps/unix/sysv/linux/mips/nptl/bits/semaphore.h
new file mode 100644
index 000000000..c4440f9e9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/nptl/bits/semaphore.h
@@ -0,0 +1,40 @@
+/* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+#if _MIPS_SIM == _ABI64
+# define __SIZEOF_SEM_T 32
+#else
+# define __SIZEOF_SEM_T 16
+#endif
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+/* Maximum value the semaphore can have. */
+#define SEM_VALUE_MAX (2147483647)
+
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
diff --git a/ports/sysdeps/unix/sysv/linux/mips/nptl/clone.S b/ports/sysdeps/unix/sysv/linux/mips/nptl/clone.S
new file mode 100644
index 000000000..80c265bf6
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/nptl/clone.S
@@ -0,0 +1,2 @@
+#define RESET_PID
+#include <sysdeps/unix/sysv/linux/mips/clone.S>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/nptl/createthread.c b/ports/sysdeps/unix/sysv/linux/mips/nptl/createthread.c
new file mode 100644
index 000000000..5b2234f47
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/nptl/createthread.c
@@ -0,0 +1,24 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Value passed to 'clone' for initialization of the thread register. */
+#define TLS_VALUE ((void *) (pd) \
+ + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE)
+
+/* Get the real implementation. */
+#include <nptl/sysdeps/pthread/createthread.c>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/nptl/fork.c b/ports/sysdeps/unix/sysv/linux/mips/nptl/fork.c
new file mode 100644
index 000000000..d31889e42
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/nptl/fork.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/fork.c>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/nptl/lowlevellock.h b/ports/sysdeps/unix/sysv/linux/mips/nptl/lowlevellock.h
new file mode 100644
index 000000000..36a20f164
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/nptl/lowlevellock.h
@@ -0,0 +1,293 @@
+/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _LOWLEVELLOCK_H
+#define _LOWLEVELLOCK_H 1
+
+#include <time.h>
+#include <sys/param.h>
+#include <bits/pthreadtypes.h>
+#include <atomic.h>
+#include <sysdep.h>
+
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_REQUEUE 3
+#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
+
+/* Initializer for compatibility lock. */
+#define LLL_MUTEX_LOCK_INITIALIZER (0)
+
+#define lll_futex_wait(futexp, val) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, \
+ (long) (futexp), FUTEX_WAIT, (val), 0); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
+ })
+
+#define lll_futex_timed_wait(futexp, val, timespec) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, \
+ (long) (futexp), FUTEX_WAIT, (val), (timespec));\
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
+ })
+
+#define lll_futex_wake(futexp, nr) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, \
+ (long) (futexp), FUTEX_WAKE, (nr), 0); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
+ })
+
+#define lll_robust_mutex_dead(futexv) \
+ do \
+ { \
+ int *__futexp = &(futexv); \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ lll_futex_wake (__futexp, 1); \
+ } \
+ while (0)
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, \
+ (long) (futexp), FUTEX_CMP_REQUEUE, (nr_wake), \
+ (nr_move), (mutex), (val)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, \
+ (futexp), FUTEX_WAKE_OP, (nr_wake), \
+ (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+static inline int __attribute__((always_inline))
+__lll_mutex_trylock(int *futex)
+{
+ return atomic_compare_and_exchange_val_acq (futex, 1, 0) != 0;
+}
+#define lll_mutex_trylock(lock) __lll_mutex_trylock (&(lock))
+
+
+static inline int __attribute__((always_inline))
+__lll_mutex_cond_trylock(int *futex)
+{
+ return atomic_compare_and_exchange_val_acq (futex, 2, 0) != 0;
+}
+#define lll_mutex_cond_trylock(lock) __lll_mutex_cond_trylock (&(lock))
+
+
+static inline int __attribute__((always_inline))
+__lll_robust_mutex_trylock(int *futex, int id)
+{
+ return atomic_compare_and_exchange_val_acq (futex, id, 0) != 0;
+}
+#define lll_robust_mutex_trylock(lock, id) \
+ __lll_robust_mutex_trylock (&(lock), id)
+
+extern void __lll_lock_wait (int *futex) attribute_hidden;
+extern int __lll_robust_lock_wait (int *futex) attribute_hidden;
+
+static inline void __attribute__((always_inline))
+__lll_mutex_lock(int *futex)
+{
+ if (atomic_compare_and_exchange_bool_acq (futex, 1, 0) != 0)
+ __lll_lock_wait (futex);
+}
+#define lll_mutex_lock(futex) __lll_mutex_lock (&(futex))
+
+
+static inline int __attribute__ ((always_inline))
+__lll_robust_mutex_lock (int *futex, int id)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_lock_wait (futex);
+ return result;
+}
+#define lll_robust_mutex_lock(futex, id) \
+ __lll_robust_mutex_lock (&(futex), id)
+
+
+static inline void __attribute__ ((always_inline))
+__lll_mutex_cond_lock (int *futex)
+{
+ if (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0)
+ __lll_lock_wait (futex);
+}
+#define lll_mutex_cond_lock(futex) __lll_mutex_cond_lock (&(futex))
+
+
+#define lll_robust_mutex_cond_lock(futex, id) \
+ __lll_robust_mutex_lock (&(futex), (id) | FUTEX_WAITERS)
+
+
+extern int __lll_timedlock_wait (int *futex, const struct timespec *)
+ attribute_hidden;
+extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *)
+ attribute_hidden;
+
+static inline int __attribute__ ((always_inline))
+__lll_mutex_timedlock (int *futex, const struct timespec *abstime)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, 1, 0) != 0)
+ result = __lll_timedlock_wait (futex, abstime);
+ return result;
+}
+#define lll_mutex_timedlock(futex, abstime) \
+ __lll_mutex_timedlock (&(futex), abstime)
+
+
+static inline int __attribute__ ((always_inline))
+__lll_robust_mutex_timedlock (int *futex, const struct timespec *abstime,
+ int id)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_timedlock_wait (futex, abstime);
+ return result;
+}
+#define lll_robust_mutex_timedlock(futex, abstime, id) \
+ __lll_robust_mutex_timedlock (&(futex), abstime, id)
+
+
+static inline void __attribute__ ((always_inline))
+__lll_mutex_unlock (int *futex)
+{
+ int val = atomic_exchange_rel (futex, 0);
+ if (__builtin_expect (val > 1, 0))
+ lll_futex_wake (futex, 1);
+}
+#define lll_mutex_unlock(futex) __lll_mutex_unlock(&(futex))
+
+
+static inline void __attribute__ ((always_inline))
+__lll_robust_mutex_unlock (int *futex, int mask)
+{
+ int val = atomic_exchange_rel (futex, 0);
+ if (__builtin_expect (val & mask, 0))
+ lll_futex_wake (futex, 1);
+}
+#define lll_robust_mutex_unlock(futex) \
+ __lll_robust_mutex_unlock(&(futex), FUTEX_WAITERS)
+
+
+static inline void __attribute__ ((always_inline))
+__lll_mutex_unlock_force (int *futex)
+{
+ (void) atomic_exchange_rel (futex, 0);
+ lll_futex_wake (futex, 1);
+}
+#define lll_mutex_unlock_force(futex) __lll_mutex_unlock_force(&(futex))
+
+
+#define lll_mutex_islocked(futex) \
+ (futex != 0)
+
+
+/* Our internal lock implementation is identical to the binary-compatible
+ mutex implementation. */
+
+/* Type for lock object. */
+typedef int lll_lock_t;
+
+/* Initializers for lock. */
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+
+extern int lll_unlock_wake_cb (int *__futex) attribute_hidden;
+
+/* The states of a lock are:
+ 0 - untaken
+ 1 - taken by one user
+ >1 - taken by more users */
+
+#define lll_trylock(lock) lll_mutex_trylock (lock)
+#define lll_lock(lock) lll_mutex_lock (lock)
+#define lll_unlock(lock) lll_mutex_unlock (lock)
+#define lll_islocked(lock) lll_mutex_islocked (lock)
+
+/* The kernel notifies a process which uses CLONE_CLEARTID via futex
+ wakeup when the clone terminates. The memory location contains the
+ thread ID while the clone is running and is reset to zero
+ afterwards. */
+#define lll_wait_tid(tid) \
+ do { \
+ __typeof (tid) __tid; \
+ while ((__tid = (tid)) != 0) \
+ lll_futex_wait (&(tid), __tid); \
+ } while (0)
+
+extern int __lll_timedwait_tid (int *, const struct timespec *)
+ attribute_hidden;
+
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __res = 0; \
+ if ((tid) != 0) \
+ __res = __lll_timedwait_tid (&(tid), (abstime)); \
+ __res; \
+ })
+
+
+/* Conditional variable handling. */
+
+extern void __lll_cond_wait (pthread_cond_t *cond)
+ attribute_hidden;
+extern int __lll_cond_timedwait (pthread_cond_t *cond,
+ const struct timespec *abstime)
+ attribute_hidden;
+extern void __lll_cond_wake (pthread_cond_t *cond)
+ attribute_hidden;
+extern void __lll_cond_broadcast (pthread_cond_t *cond)
+ attribute_hidden;
+
+#define lll_cond_wait(cond) \
+ __lll_cond_wait (cond)
+#define lll_cond_timedwait(cond, abstime) \
+ __lll_cond_timedwait (cond, abstime)
+#define lll_cond_wake(cond) \
+ __lll_cond_wake (cond)
+#define lll_cond_broadcast(cond) \
+ __lll_cond_broadcast (cond)
+
+#endif /* lowlevellock.h */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/nptl/pt-vfork.S b/ports/sysdeps/unix/sysv/linux/mips/nptl/pt-vfork.S
new file mode 100644
index 000000000..652dfb1e5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/nptl/pt-vfork.S
@@ -0,0 +1,37 @@
+/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <tls.h>
+
+/* Save the PID value. */
+#define SAVE_PID \
+ READ_THREAD_POINTER(v1); /* Get the thread pointer. */ \
+ lw a2, PID_OFFSET(v1); /* Load the saved PID. */ \
+ subu a2, $0, a2; /* Negate it. */ \
+ sw a2, PID_OFFSET(v1); /* Store the temporary PID. */
+
+/* Restore the old PID value in the parent. */
+#define RESTORE_PID \
+ beqz v0, 1f; /* If we are the parent... */ \
+ READ_THREAD_POINTER(v1); /* Get the thread pointer. */ \
+ lw a2, PID_OFFSET(v1); /* Load the saved PID. */ \
+ subu a2, $0, a2; /* Re-negate it. */ \
+ sw a2, PID_OFFSET(v1); /* Restore the PID. */ \
+1:
+
+#include <sysdeps/unix/sysv/linux/mips/vfork.S>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/nptl/pthread_once.c b/ports/sysdeps/unix/sysv/linux/mips/nptl/pthread_once.c
new file mode 100644
index 000000000..649b752f5
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/nptl/pthread_once.c
@@ -0,0 +1,94 @@
+/* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+
+unsigned long int __fork_generation attribute_hidden;
+
+
+static void
+clear_once_control (void *arg)
+{
+ pthread_once_t *once_control = (pthread_once_t *) arg;
+
+ *once_control = 0;
+ lll_futex_wake (once_control, INT_MAX);
+}
+
+
+int
+__pthread_once (once_control, init_routine)
+ pthread_once_t *once_control;
+ void (*init_routine) (void);
+{
+ while (1)
+ {
+ int oldval, val, newval;
+
+ val = *once_control;
+ do
+ {
+ /* Check if the initialized has already been done. */
+ if ((val & 2) != 0)
+ return 0;
+
+ oldval = val;
+ newval = (oldval & 3) | __fork_generation | 1;
+ val = atomic_compare_and_exchange_val_acq (once_control, newval,
+ oldval);
+ }
+ while (__builtin_expect (val != oldval, 0));
+
+ /* Check if another thread already runs the initializer. */
+ if ((oldval & 1) != 0)
+ {
+ /* Check whether the initializer execution was interrupted
+ by a fork. */
+ if (((oldval ^ newval) & -4) == 0)
+ {
+ /* Same generation, some other thread was faster. Wait. */
+ lll_futex_wait (once_control, newval);
+ continue;
+ }
+ }
+
+ /* This thread is the first here. Do the initialization.
+ Register a cleanup handler so that in case the thread gets
+ interrupted the initialization can be restarted. */
+ pthread_cleanup_push (clear_once_control, once_control);
+
+ init_routine ();
+
+ pthread_cleanup_pop (0);
+
+
+ /* Add one to *once_control. */
+ atomic_increment (once_control);
+
+ /* Wake up all other threads. */
+ lll_futex_wake (once_control, INT_MAX);
+ break;
+ }
+
+ return 0;
+}
+weak_alias (__pthread_once, pthread_once)
+strong_alias (__pthread_once, __pthread_once_internal)
diff --git a/ports/sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h b/ports/sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h
new file mode 100644
index 000000000..02508e215
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/nptl/sysdep-cancel.h
@@ -0,0 +1,170 @@
+/* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <sysdeps/generic/sysdep.h>
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <nptl/pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+#ifdef __PIC__
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .align 2; \
+ L(pseudo_start): \
+ cfi_startproc; \
+ 99: la t9,__syscall_error; \
+ jr t9; \
+ .type __##syscall_name##_nocancel, @function; \
+ .globl __##syscall_name##_nocancel; \
+ __##syscall_name##_nocancel: \
+ .set noreorder; \
+ .cpload t9; \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, SYSCALL_ERROR_LABEL; \
+ ret; \
+ .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
+ ENTRY (name) \
+ .set noreorder; \
+ .cpload t9; \
+ .set reorder; \
+ SINGLE_THREAD_P(v1); \
+ bne zero, v1, L(pseudo_cancel); \
+ .set noreorder; \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, SYSCALL_ERROR_LABEL; \
+ ret; \
+ L(pseudo_cancel): \
+ SAVESTK_##args; \
+ sw ra, 28(sp); \
+ cfi_rel_offset (ra, 28); \
+ sw gp, 32(sp); \
+ cfi_rel_offset (gp, 32); \
+ PUSHARGS_##args; /* save syscall args */ \
+ CENABLE; \
+ lw gp, 32(sp); \
+ sw v0, 44(sp); /* save mask */ \
+ POPARGS_##args; /* restore syscall args */ \
+ .set noreorder; \
+ li v0, SYS_ify (syscall_name); \
+ syscall; \
+ .set reorder; \
+ sw v0, 36(sp); /* save syscall result */ \
+ sw a3, 40(sp); /* save syscall error flag */ \
+ lw a0, 44(sp); /* pass mask as arg1 */ \
+ CDISABLE; \
+ lw gp, 32(sp); \
+ lw v0, 36(sp); /* restore syscall result */ \
+ lw a3, 40(sp); /* restore syscall error flag */ \
+ lw ra, 28(sp); /* restore return address */ \
+ .set noreorder; \
+ bne a3, zero, SYSCALL_ERROR_LABEL; \
+ RESTORESTK; \
+ L(pseudo_end): \
+ .set reorder;
+
+# undef PSEUDO_END
+# define PSEUDO_END(sym) cfi_endproc; .end sym; .size sym,.-sym
+
+#endif
+
+# define PUSHARGS_0 /* nothing to do */
+# define PUSHARGS_1 PUSHARGS_0 sw a0, 0(sp); cfi_rel_offset (a0, 0);
+# define PUSHARGS_2 PUSHARGS_1 sw a1, 4(sp); cfi_rel_offset (a1, 4);
+# define PUSHARGS_3 PUSHARGS_2 sw a2, 8(sp); cfi_rel_offset (a2, 8);
+# define PUSHARGS_4 PUSHARGS_3 sw a3, 12(sp); cfi_rel_offset (a3, 12);
+# define PUSHARGS_5 PUSHARGS_4 /* handled by SAVESTK_## */
+# define PUSHARGS_6 PUSHARGS_5
+# define PUSHARGS_7 PUSHARGS_6
+
+# define POPARGS_0 /* nothing to do */
+# define POPARGS_1 POPARGS_0 lw a0, 0(sp);
+# define POPARGS_2 POPARGS_1 lw a1, 4(sp);
+# define POPARGS_3 POPARGS_2 lw a2, 8(sp);
+# define POPARGS_4 POPARGS_3 lw a3, 12(sp);
+# define POPARGS_5 POPARGS_4 /* args already in new stackframe */
+# define POPARGS_6 POPARGS_5
+# define POPARGS_7 POPARGS_6
+
+
+# define STKSPACE 48
+# define SAVESTK_0 subu sp, STKSPACE; cfi_adjust_cfa_offset(STKSPACE)
+# define SAVESTK_1 SAVESTK_0
+# define SAVESTK_2 SAVESTK_1
+# define SAVESTK_3 SAVESTK_2
+# define SAVESTK_4 SAVESTK_3
+# define SAVESTK_5 lw t0, 16(sp); \
+ SAVESTK_0; \
+ sw t0, 16(sp)
+
+# define SAVESTK_6 lw t0, 16(sp); \
+ lw t1, 20(sp); \
+ SAVESTK_0; \
+ sw t0, 16(sp); \
+ sw t1, 20(sp)
+
+# define SAVESTK_7 lw t0, 16(sp); \
+ lw t1, 20(sp); \
+ lw t2, 24(sp); \
+ SAVESTK_0; \
+ sw t0, 16(sp); \
+ sw t1, 20(sp); \
+ sw t2, 24(sp)
+
+# define RESTORESTK addu sp, STKSPACE; cfi_adjust_cfa_offset(-STKSPACE)
+
+
+/* We use jalr rather than jal. This means that the assembler will not
+ automatically restore $gp (in case libc has multiple GOTs) so we must
+ do it manually - which we have to do anyway since we don't use .cprestore.
+ It also shuts up the assembler warning about not using .cprestore. */
+# ifdef IS_IN_libpthread
+# define CENABLE la t9, __pthread_enable_asynccancel; jalr t9;
+# define CDISABLE la t9, __pthread_disable_asynccancel; jalr t9;
+# elif defined IS_IN_librt
+# define CENABLE la t9, __librt_enable_asynccancel; jalr t9;
+# define CDISABLE la t9, __librt_disable_asynccancel; jalr t9;
+# else
+# define CENABLE la t9, __libc_enable_asynccancel; jalr t9;
+# define CDISABLE la t9, __libc_disable_asynccancel; jalr t9;
+# endif
+
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) \
+ == 0, 1)
+# else
+# define SINGLE_THREAD_P(reg) \
+ READ_THREAD_POINTER(reg); \
+ lw reg, MULTIPLE_THREADS_OFFSET(reg)
+#endif
+
+#elif !defined __ASSEMBLER__
+
+# define SINGLE_THREAD_P 1
+# define NO_CANCELLATION 1
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/nptl/vfork.S b/ports/sysdeps/unix/sysv/linux/mips/nptl/vfork.S
new file mode 100644
index 000000000..b93a924cc
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/nptl/vfork.S
@@ -0,0 +1,42 @@
+/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <tls.h>
+
+/* Save the PID value. */
+#define SAVE_PID \
+ READ_THREAD_POINTER(v1); /* Get the thread pointer. */ \
+ lw a2, PID_OFFSET(v1); /* Load the saved PID. */ \
+ subu a2, $0, a2; /* Negate it. */ \
+ bnez a2, 1f; /* If it was zero... */ \
+ lui a2, 0x8000; /* use 0x80000000 instead. */ \
+1: sw a2, PID_OFFSET(v1); /* Store the temporary PID. */
+
+/* Restore the old PID value in the parent. */
+#define RESTORE_PID \
+ beqz v0, 1f; /* If we are the parent... */ \
+ READ_THREAD_POINTER(v1); /* Get the thread pointer. */ \
+ lw a2, PID_OFFSET(v1); /* Load the saved PID. */ \
+ subu a2, $0, a2; /* Re-negate it. */ \
+ lui a0, 0x8000; /* Load 0x80000000... */ \
+ bne a2, a0, 2f; /* ... compare against it... */ \
+ li a2, 0; /* ... use 0 instead. */ \
+2: sw a2, PID_OFFSET(v1); /* Restore the PID. */ \
+1:
+
+#include <sysdeps/unix/sysv/linux/mips/vfork.S>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/pipe.S b/ports/sysdeps/unix/sysv/linux/mips/pipe.S
new file mode 100644
index 000000000..1708888da
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/pipe.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/mips/pipe.S>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/pread.c b/ports/sysdeps/unix/sysv/linux/mips/pread.c
new file mode 100644
index 000000000..eff7d473d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/pread.c
@@ -0,0 +1,109 @@
+/* Copyright (C) 1997, 1998, 2000, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <errno.h>
+#ifndef NO_SGIDEFS_H
+#include <sgidefs.h>
+#endif
+#include <unistd.h>
+#include <endian.h>
+
+#include <sysdep-cancel.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+#include <kernel-features.h>
+
+#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
+# ifdef __NR_pread
+# error "__NR_pread and __NR_pread64 both defined???"
+# endif
+# define __NR_pread __NR_pread64
+#endif
+
+#if defined __NR_pread || __ASSUME_PREAD_SYSCALL > 0
+
+# if __ASSUME_PREAD_SYSCALL == 0
+static ssize_t __emulate_pread (int fd, void *buf, size_t count,
+ off_t offset) internal_function;
+# endif
+
+ssize_t
+__libc_pread (fd, buf, count, offset)
+ int fd;
+ void *buf;
+ size_t count;
+ off_t offset;
+{
+ ssize_t result;
+
+#if _MIPS_SIM != _ABI64
+ assert (sizeof (offset) == 4);
+#endif
+
+ if (SINGLE_THREAD_P)
+ {
+ /* First try the syscall. */
+#if _MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64
+ result = INLINE_SYSCALL (pread, 4, fd, CHECK_N (buf, count), count,
+ offset);
+#else
+ result = INLINE_SYSCALL (pread, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR (offset >> 31, offset));
+#endif
+# if __ASSUME_PREAD_SYSCALL == 0
+ if (result == -1 && errno == ENOSYS)
+ /* No system call available. Use the emulation. */
+ result = __emulate_pread (fd, buf, count, offset);
+# endif
+ return result;
+ }
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ /* First try the syscall. */
+#if _MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64
+ result = INLINE_SYSCALL (pread, 4, fd, CHECK_N (buf, count), count, offset);
+#else
+ result = INLINE_SYSCALL (pread, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR (offset >> 31, offset));
+#endif
+# if __ASSUME_PREAD_SYSCALL == 0
+ if (result == -1 && errno == ENOSYS)
+ /* No system call available. Use the emulation. */
+ result = __emulate_pread (fd, buf, count, offset);
+# endif
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+
+strong_alias (__libc_pread, __pread)
+weak_alias (__libc_pread, pread)
+
+# define __libc_pread(fd, buf, count, offset) \
+ static internal_function __emulate_pread (fd, buf, count, offset)
+#endif
+
+#if __ASSUME_PREAD_SYSCALL == 0
+# include <sysdeps/posix/pread.c>
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/pread64.c b/ports/sysdeps/unix/sysv/linux/mips/pread64.c
new file mode 100644
index 000000000..d8763acab
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/pread64.c
@@ -0,0 +1,107 @@
+/* Copyright (C) 1997, 1998, 2000, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#ifndef NO_SGIDEFS_H
+#include <sgidefs.h>
+#endif
+#include <unistd.h>
+#include <endian.h>
+
+#include <sysdep-cancel.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+#include <kernel-features.h>
+
+#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
+# ifdef __NR_pread
+# error "__NR_pread and __NR_pread64 both defined???"
+# endif
+# define __NR_pread __NR_pread64
+#endif
+
+#if defined __NR_pread || __ASSUME_PREAD_SYSCALL > 0
+
+# if __ASSUME_PREAD_SYSCALL == 0
+static ssize_t __emulate_pread64 (int fd, void *buf, size_t count,
+ off64_t offset) internal_function;
+# endif
+
+ssize_t
+__libc_pread64 (fd, buf, count, offset)
+ int fd;
+ void *buf;
+ size_t count;
+ off64_t offset;
+{
+ ssize_t result;
+
+
+ if (SINGLE_THREAD_P)
+ {
+ /* First try the syscall. */
+#if _MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64
+ result = INLINE_SYSCALL (pread, 4, fd, CHECK_N (buf, count), count,
+ offset);
+#else
+ result = INLINE_SYSCALL (pread, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR ((off_t) (offset >> 32),
+ (off_t) (offset & 0xffffffff)));
+#endif
+# if __ASSUME_PREAD_SYSCALL == 0
+ if (result == -1 && errno == ENOSYS)
+ /* No system call available. Use the emulation. */
+ result = __emulate_pread64 (fd, buf, count, offset);
+# endif
+ return result;
+ }
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ /* First try the syscall. */
+#if _MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64
+ result = INLINE_SYSCALL (pread, 4, fd, CHECK_N (buf, count), count, offset);
+#else
+ result = INLINE_SYSCALL (pread, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR ((off_t) (offset >> 32),
+ (off_t) (offset & 0xffffffff)));
+#endif
+# if __ASSUME_PREAD_SYSCALL == 0
+ if (result == -1 && errno == ENOSYS)
+ /* No system call available. Use the emulation. */
+ result = __emulate_pread64 (fd, buf, count, offset);
+# endif
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+
+weak_alias (__libc_pread64, __pread64)
+weak_alias (__libc_pread64, pread64)
+
+# define __libc_pread64(fd, buf, count, offset) \
+ static internal_function __emulate_pread64 (fd, buf, count, offset)
+#endif
+
+#if __ASSUME_PREAD_SYSCALL == 0
+# include <sysdeps/posix/pread64.c>
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/profil-counter.h b/ports/sysdeps/unix/sysv/linux/mips/profil-counter.h
new file mode 100644
index 000000000..8a6a0bcf3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/profil-counter.h
@@ -0,0 +1,2 @@
+/* We can use the ix86 version. */
+#include <sysdeps/unix/sysv/linux/i386/profil-counter.h>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/putmsg.c b/ports/sysdeps/unix/sysv/linux/mips/putmsg.c
new file mode 100644
index 000000000..ebc1680ca
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/putmsg.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/i386/putmsg.c>
diff --git a/ports/sysdeps/unix/sysv/linux/mips/pwrite.c b/ports/sysdeps/unix/sysv/linux/mips/pwrite.c
new file mode 100644
index 000000000..4378ebc85
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/pwrite.c
@@ -0,0 +1,109 @@
+/* Copyright (C) 1997, 1998, 2000, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <assert.h>
+#include <errno.h>
+#ifndef NO_SGIDEFS_H
+#include <sgidefs.h>
+#endif
+#include <unistd.h>
+#include <endian.h>
+
+#include <sysdep-cancel.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+#include <kernel-features.h>
+
+#ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
+# ifdef __NR_pwrite
+# error "__NR_pwrite and __NR_pwrite64 both defined???"
+# endif
+# define __NR_pwrite __NR_pwrite64
+#endif
+
+#if defined __NR_pwrite || __ASSUME_PWRITE_SYSCALL > 0
+
+# if __ASSUME_PWRITE_SYSCALL == 0
+static ssize_t __emulate_pwrite (int fd, const void *buf, size_t count,
+ off_t offset) internal_function;
+# endif
+
+ssize_t
+__libc_pwrite (fd, buf, count, offset)
+ int fd;
+ const void *buf;
+ size_t count;
+ off_t offset;
+{
+ ssize_t result;
+
+#if _MIPS_SIM != _ABI64
+ assert (sizeof (offset) == 4);
+#endif
+
+ if (SINGLE_THREAD_P)
+ {
+ /* First try the syscall. */
+#if _MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64
+ result = INLINE_SYSCALL (pwrite, 4, fd, CHECK_N (buf, count), count,
+ offset);
+#else
+ result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR (offset >> 31, offset));
+#endif
+# if __ASSUME_PWRITE_SYSCALL == 0
+ if (result == -1 && errno == ENOSYS)
+ /* No system call available. Use the emulation. */
+ result = __emulate_pwrite (fd, buf, count, offset);
+# endif
+ return result;
+ }
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ /* First try the syscall. */
+#if _MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64
+ result = INLINE_SYSCALL (pwrite, 4, fd, CHECK_N (buf, count), count, offset);
+#else
+ result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR (offset >> 31, offset));
+#endif
+# if __ASSUME_PWRITE_SYSCALL == 0
+ if (result == -1 && errno == ENOSYS)
+ /* No system call available. Use the emulation. */
+ result = __emulate_pwrite (fd, buf, count, offset);
+# endif
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+
+strong_alias (__libc_pwrite, __pwrite)
+weak_alias (__libc_pwrite, pwrite)
+
+# define __libc_pwrite(fd, buf, count, offset) \
+ static internal_function __emulate_pwrite (fd, buf, count, offset)
+#endif
+
+#if __ASSUME_PWRITE_SYSCALL == 0
+# include <sysdeps/posix/pwrite.c>
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/pwrite64.c b/ports/sysdeps/unix/sysv/linux/mips/pwrite64.c
new file mode 100644
index 000000000..e5853e432
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/pwrite64.c
@@ -0,0 +1,108 @@
+/* Copyright (C) 1997, 1998, 2000, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ralf Baechle <ralf@gnu.org>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#ifndef NO_SGIDEFS_H
+#include <sgidefs.h>
+#endif
+#include <unistd.h>
+#include <endian.h>
+
+#include <sysdep-cancel.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+#include <kernel-features.h>
+
+#ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
+# ifdef __NR_pwrite
+# error "__NR_pwrite and __NR_pwrite64 both defined???"
+# endif
+# define __NR_pwrite __NR_pwrite64
+#endif
+
+#if defined __NR_pwrite || __ASSUME_PWRITE_SYSCALL > 0
+
+# if __ASSUME_PWRITE_SYSCALL == 0
+static ssize_t __emulate_pwrite64 (int fd, const void *buf, size_t count,
+ off64_t offset) internal_function;
+# endif
+
+ssize_t
+__libc_pwrite64 (fd, buf, count, offset)
+ int fd;
+ const void *buf;
+ size_t count;
+ off64_t offset;
+{
+ ssize_t result;
+
+ if (SINGLE_THREAD_P)
+ {
+ /* First try the syscall. */
+#if _MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64
+ result = INLINE_SYSCALL (pwrite, 4, fd, CHECK_N (buf, count), count,
+ offset);
+#else
+ result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR ((off_t) (offset >> 32),
+ (off_t) (offset & 0xffffffff)));
+#endif
+# if __ASSUME_PWRITE_SYSCALL == 0
+ if (result == -1 && errno == ENOSYS)
+ /* No system call available. Use the emulation. */
+ result = __emulate_pwrite64 (fd, buf, count, offset);
+# endif
+
+ return result;
+ }
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ /* First try the syscall. */
+#if _MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64
+ result = INLINE_SYSCALL (pwrite, 4, fd, CHECK_N (buf, count), count, offset);
+#else
+ result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR ((off_t) (offset >> 32),
+ (off_t) (offset & 0xffffffff)));
+#endif
+# if __ASSUME_PWRITE_SYSCALL == 0
+ if (result == -1 && errno == ENOSYS)
+ /* No system call available. Use the emulation. */
+ result = __emulate_pwrite64 (fd, buf, count, offset);
+# endif
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+
+weak_alias (__libc_pwrite64, __pwrite64)
+libc_hidden_weak (__pwrite64)
+weak_alias (__libc_pwrite64, pwrite64)
+
+# define __libc_pwrite64(fd, buf, count, offset) \
+ static internal_function __emulate_pwrite64 (fd, buf, count, offset)
+#endif
+
+#if __ASSUME_PWRITE_SYSCALL == 0
+# include <sysdeps/posix/pwrite64.c>
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/readelflib.c b/ports/sysdeps/unix/sysv/linux/mips/readelflib.c
new file mode 100644
index 000000000..baa92fe57
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/readelflib.c
@@ -0,0 +1,71 @@
+/* Copyright (C) 1999, 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+ Based on work ../x86_64/readelflib.c,
+ contributed by Andreas Jaeger <aj@suse.de>, 1999 and
+ Jakub Jelinek <jakub@redhat.com>, 1999.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+int process_elf32_file (const char *file_name, const char *lib, int *flag,
+ unsigned int *osversion, char **soname,
+ void *file_contents, size_t file_length);
+int process_elf64_file (const char *file_name, const char *lib, int *flag,
+ unsigned int *osversion, char **soname,
+ void *file_contents, size_t file_length);
+
+/* Returns 0 if everything is ok, != 0 in case of error. */
+int
+process_elf_file (const char *file_name, const char *lib, int *flag,
+ unsigned int *osversion, char **soname, void *file_contents,
+ size_t file_length)
+{
+ ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
+ int ret;
+
+ if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
+ {
+ ret = process_elf32_file (file_name, lib, flag, osversion, soname,
+ file_contents, file_length);
+
+ /* n32 libraries are always libc.so.6+. */
+ if (ret && (elf_header->e_flags & EF_MIPS_ABI2) != 0)
+ *flag = FLAG_MIPS64_LIBN32|FLAG_ELF_LIBC6;
+ }
+ else
+ {
+ ret = process_elf64_file (file_name, lib, flag, osversion, soname,
+ file_contents, file_length);
+ /* n64 libraries are always libc.so.6+. */
+ if (!ret)
+ *flag = FLAG_MIPS64_LIBN64|FLAG_ELF_LIBC6;
+ }
+
+ return ret;
+}
+
+#undef __ELF_NATIVE_CLASS
+#undef process_elf_file
+#define process_elf_file process_elf32_file
+#define __ELF_NATIVE_CLASS 32
+#include "elf/readelflib.c"
+
+#undef __ELF_NATIVE_CLASS
+#undef process_elf_file
+#define process_elf_file process_elf64_file
+#define __ELF_NATIVE_CLASS 64
+#include "elf/readelflib.c"
diff --git a/ports/sysdeps/unix/sysv/linux/mips/register-dump.h b/ports/sysdeps/unix/sysv/linux/mips/register-dump.h
new file mode 100644
index 000000000..8d2ec754d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/register-dump.h
@@ -0,0 +1,105 @@
+/* Dump registers.
+ Copyright (C) 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/uio.h>
+#include <stdio-common/_itoa.h>
+
+/* We will print the register dump in this format:
+
+ R0 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
+ R8 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
+ R16 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
+ R24 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
+ pc lo hi
+ XXXXXXXX XXXXXXXX XXXXXXXX
+ The FPU registers will not be printed.
+*/
+
+static void
+hexvalue (unsigned long int value, char *buf, size_t len)
+{
+ char *cp = _itoa_word (value, buf + len, 16, 0);
+ while (cp > buf)
+ *--cp = '0';
+}
+
+static void
+register_dump (int fd, struct sigcontext *ctx)
+{
+ char regs[38][8];
+ struct iovec iov[38 * 2 + 10];
+ size_t nr = 0;
+ int i;
+
+#define ADD_STRING(str) \
+ iov[nr].iov_base = (char *) str; \
+ iov[nr].iov_len = strlen (str); \
+ ++nr
+#define ADD_MEM(str, len) \
+ iov[nr].iov_base = str; \
+ iov[nr].iov_len = len; \
+ ++nr
+
+ /* Generate strings of register contents. */
+ for (i = 0; i < 32; i++)
+ hexvalue (ctx->sc_regs[i], regs[i], 8);
+ hexvalue (ctx->sc_pc, regs[32], 8);
+ hexvalue (ctx->sc_mdhi, regs[33], 8);
+ hexvalue (ctx->sc_mdlo, regs[34], 8);
+
+ /* Generate the output. */
+ ADD_STRING ("Register dump:\n\n R0 ");
+ for (i = 0; i < 8; i++)
+ {
+ ADD_MEM (regs[i], 8);
+ ADD_STRING (" ");
+ }
+ ADD_STRING ("\n R8 ");
+ for (i = 8; i < 16; i++)
+ {
+ ADD_MEM (regs[i], 8);
+ ADD_STRING (" ");
+ }
+ ADD_STRING ("\n R16 ");
+ for (i = 16; i < 24; i++)
+ {
+ ADD_MEM (regs[i], 8);
+ ADD_STRING (" ");
+ }
+ ADD_STRING ("\n R24 ");
+ for (i = 24; i < 32; i++)
+ {
+ ADD_MEM (regs[i], 8);
+ ADD_STRING (" ");
+ }
+ ADD_STRING ("\n pc lo hi\n ");
+ for (i = 32; i < 35; i++)
+ {
+ ADD_MEM (regs[i], 8);
+ ADD_STRING (" ");
+ }
+ ADD_STRING ("\n");
+
+ /* Write the stuff out. */
+ writev (fd, iov, nr);
+}
+
+
+#define REGISTER_DUMP register_dump (fd, ctx)
diff --git a/ports/sysdeps/unix/sysv/linux/mips/sigaction.c b/ports/sysdeps/unix/sysv/linux/mips/sigaction.c
new file mode 100644
index 000000000..c05dfd1f6
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/sigaction.c
@@ -0,0 +1,192 @@
+/* Copyright (C) 1997,1998,1999,2000,2002,2003,2004,2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sgidefs.h>
+#include <signal.h>
+#include <string.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+#include <sgidefs.h>
+
+#include <kernel-features.h>
+
+/* The difference here is that the sigaction structure used in the
+ kernel is not the same as we use in the libc. Therefore we must
+ translate it here. */
+#include <kernel_sigaction.h>
+
+#if __ASSUME_REALTIME_SIGNALS == 0
+/* The variable is shared between all wrappers around signal handling
+ functions which have RT equivalents. This is the definition. */
+int __libc_missing_rt_sigs;
+
+#endif
+
+#if _MIPS_SIM != _ABIO32
+
+# ifdef __NR_rt_sigreturn
+static void restore_rt (void) asm ("__restore_rt");
+# endif
+# ifdef __NR_sigreturn
+static void restore (void) asm ("__restore");
+# endif
+#endif
+
+/* 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
+__libc_sigaction (sig, act, oact)
+ int sig;
+ const struct sigaction *act;
+ struct sigaction *oact;
+{
+#if __ASSUME_REALTIME_SIGNALS == 0
+ struct old_kernel_sigaction k_sigact, k_osigact;
+#endif
+ int result;
+
+#if defined __NR_rt_sigaction || __ASSUME_REALTIME_SIGNALS > 0
+ /* First try the RT signals. */
+# if __ASSUME_REALTIME_SIGNALS == 0
+ if (!__libc_missing_rt_sigs)
+# endif
+ {
+ struct kernel_sigaction kact, koact;
+ /* Save the current error value for later. We need not do this
+ if we are guaranteed to have realtime signals. */
+# if __ASSUME_REALTIME_SIGNALS == 0
+ int saved_errno = errno;
+# endif
+
+ if (act)
+ {
+ kact.k_sa_handler = act->sa_handler;
+ memcpy (&kact.sa_mask, &act->sa_mask, sizeof (kernel_sigset_t));
+ kact.sa_flags = act->sa_flags;
+# ifdef HAVE_SA_RESTORER
+# if _MIPS_SIM == _ABIO32
+ kact.sa_restorer = act->sa_restorer;
+# else
+ kact.sa_restorer = &restore_rt;
+# endif
+# endif
+ }
+
+ /* XXX The size argument hopefully will have to be changed to the
+ real size of the user-level sigset_t. */
+ result = INLINE_SYSCALL (rt_sigaction, 4, sig,
+ act ? __ptrvalue (&kact) : NULL,
+ oact ? __ptrvalue (&koact) : NULL,
+ sizeof (kernel_sigset_t));
+
+# if __ASSUME_REALTIME_SIGNALS == 0
+ if (result >= 0 || errno != ENOSYS)
+# endif
+ {
+ if (oact && result >= 0)
+ {
+ oact->sa_handler = koact.k_sa_handler;
+ memcpy (&oact->sa_mask, &koact.sa_mask,
+ sizeof (kernel_sigset_t));
+ oact->sa_flags = koact.sa_flags;
+# ifdef HAVE_SA_RESTORER
+ oact->sa_restorer = koact.sa_restorer;
+# endif
+ }
+ return result;
+ }
+
+# if __ASSUME_REALTIME_SIGNALS == 0
+ __set_errno (saved_errno);
+ __libc_missing_rt_sigs = 1;
+# endif
+ }
+#endif
+
+#if __ASSUME_REALTIME_SIGNALS == 0
+ if (act)
+ {
+ k_sigact.k_sa_handler = act->sa_handler;
+ k_sigact.sa_mask = act->sa_mask.__val[0];
+ k_sigact.sa_flags = act->sa_flags;
+# ifdef HAVE_SA_RESTORER
+ k_sigact.sa_restorer = act->sa_restorer;
+# endif
+ }
+ result = INLINE_SYSCALL (sigaction, 3, sig,
+ act ? __ptrvalue (&k_sigact) : NULL,
+ oact ? __ptrvalue (&k_osigact) : NULL);
+ if (oact && result >= 0)
+ {
+ oact->sa_handler = k_osigact.k_sa_handler;
+ oact->sa_mask.__val[0] = k_osigact.sa_mask;
+ oact->sa_flags = k_osigact.sa_flags;
+# ifdef HAVE_SA_RESTORER
+# if _MIPS_SIM == _ABIO32
+ oact->sa_restorer = k_osigact.sa_restorer;
+# else
+ oact->sa_restorer = &restore;
+# endif
+# endif
+ }
+ return result;
+#endif
+}
+libc_hidden_def (__libc_sigaction)
+
+#ifdef WRAPPER_INCLUDE
+# include WRAPPER_INCLUDE
+#endif
+
+#ifndef LIBC_SIGACTION
+weak_alias (__libc_sigaction, __sigaction)
+libc_hidden_weak (__sigaction)
+weak_alias (__libc_sigaction, sigaction)
+#endif
+
+/* NOTE: Please think twice before making any changes to the bits of
+ code below. GDB needs some intimate knowledge about it to
+ recognize them as signal trampolines, and make backtraces through
+ signal handlers work right. Important are both the names
+ (__restore_rt) and the exact instruction sequence.
+ If you ever feel the need to make any changes, please notify the
+ appropriate GDB maintainer. */
+
+#define RESTORE(name, syscall) RESTORE2 (name, syscall)
+#define RESTORE2(name, syscall) \
+asm \
+ ( \
+ ".align 4\n" \
+ "__" #name ":\n" \
+ " li $2, " #syscall "\n" \
+ " syscall\n" \
+ );
+
+/* The return code for realtime-signals. */
+#if _MIPS_SIM != _ABIO32
+# ifdef __NR_rt_sigreturn
+RESTORE (restore_rt, __NR_rt_sigreturn)
+# endif
+# ifdef __NR_sigreturn
+RESTORE (restore, __NR_sigreturn)
+# endif
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/sigcontextinfo.h b/ports/sysdeps/unix/sysv/linux/mips/sigcontextinfo.h
new file mode 100644
index 000000000..f453c8d9b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/sigcontextinfo.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Jaeger <aj@suse.de>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+#include <sgidefs.h>
+
+#if _MIPS_SIM == _ABIO32
+
+#define SIGCONTEXT unsigned long _code, struct sigcontext *
+#define SIGCONTEXT_EXTRA_ARGS _code,
+#define GET_PC(ctx) ((void *) ctx->sc_pc)
+#define GET_FRAME(ctx) ((void *) ctx->sc_regs[30])
+#define GET_STACK(ctx) ((void *) ctx->sc_regs[29])
+#define CALL_SIGHANDLER(handler, signo, ctx) \
+ (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
+
+#else
+
+#define SIGCONTEXT unsigned long _code, ucontext_t *
+#define SIGCONTEXT_EXTRA_ARGS _code,
+#define GET_PC(ctx) ((void *) ctx->uc_mcontext.pc)
+#define GET_FRAME(ctx) ((void *) ctx->uc_mcontext.gregs[30])
+#define GET_STACK(ctx) ((void *) ctx->uc_mcontext.gregs[29])
+#define CALL_SIGHANDLER(handler, signo, ctx) \
+ (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/sys/cachectl.h b/ports/sysdeps/unix/sysv/linux/mips/sys/cachectl.h
new file mode 100644
index 000000000..a93e1fb6d
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/sys/cachectl.h
@@ -0,0 +1,42 @@
+/* Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_CACHECTL_H
+#define _SYS_CACHECTL_H 1
+
+#include <features.h>
+
+/*
+ * Get the kernel definition for the op bits.
+ */
+#include <asm/cachectl.h>
+
+__BEGIN_DECLS
+
+#ifdef __USE_MISC
+extern int cachectl (void *addr, __const int nbytes, __const int op) __THROW;
+#endif
+extern int __cachectl (void *addr, __const int nbytes, __const int op) __THROW;
+#ifdef __USE_MISC
+extern int cacheflush (void *addr, __const int nbytes, __const int op) __THROW;
+#endif
+extern int _flush_cache (char *addr, __const int nbytes, __const int op) __THROW;
+
+__END_DECLS
+
+#endif /* sys/cachectl.h */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/sys/procfs.h b/ports/sysdeps/unix/sysv/linux/mips/sys/procfs.h
new file mode 100644
index 000000000..2bf07be3e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/sys/procfs.h
@@ -0,0 +1,128 @@
+/* Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_PROCFS_H
+#define _SYS_PROCFS_H 1
+
+/* This is somehow modelled after the file of the same name on SysVr4
+ systems. It provides a definition of the core file format for ELF
+ used on Linux. */
+
+#include <features.h>
+#include <sgidefs.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/user.h>
+#include <sgidefs.h>
+
+/* ELF register definitions */
+#define ELF_NGREG 45
+#define ELF_NFPREG 33
+
+#if _MIPS_SIM == _ABIN32
+__extension__ typedef unsigned long long elf_greg_t;
+#else
+typedef unsigned long elf_greg_t;
+#endif
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+typedef double elf_fpreg_t;
+typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
+__BEGIN_DECLS
+
+struct elf_siginfo
+ {
+ int si_signo; /* Signal number. */
+ int si_code; /* Extra code. */
+ int si_errno; /* Errno. */
+ };
+
+
+/* Definitions to generate Intel SVR4-like core files. These mostly
+ have the same names as the SVR4 types with "elf_" tacked on the
+ front to prevent clashes with linux definitions, and the typedef
+ forms have been avoided. This is mostly like the SVR4 structure,
+ but more Linuxy, with things that Linux does not support and which
+ gdb doesn't really use excluded. Fields present but not used are
+ marked with "XXX". */
+struct elf_prstatus
+ {
+ struct elf_siginfo pr_info; /* Info associated with signal. */
+ short int pr_cursig; /* Current signal. */
+#if _MIPS_SIM == _ABIN32
+ __extension__ unsigned long long int pr_sigpend;
+ __extension__ unsigned long long int pr_sighold;
+#else
+ unsigned long int pr_sigpend; /* Set of pending signals. */
+ unsigned long int pr_sighold; /* Set of held signals. */
+#endif
+ __pid_t pr_pid;
+ __pid_t pr_ppid;
+ __pid_t pr_pgrp;
+ __pid_t pr_sid;
+ struct timeval pr_utime; /* User time. */
+ struct timeval pr_stime; /* System time. */
+ struct timeval pr_cutime; /* Cumulative user time. */
+ struct timeval pr_cstime; /* Cumulative system time. */
+ elf_gregset_t pr_reg; /* GP registers. */
+ int pr_fpvalid; /* True if math copro being used. */
+ };
+
+
+#define ELF_PRARGSZ (80) /* Number of chars for args */
+
+struct elf_prpsinfo
+ {
+ char pr_state; /* Numeric process state. */
+ char pr_sname; /* Char for pr_state. */
+ char pr_zomb; /* Zombie. */
+ char pr_nice; /* Nice val. */
+#if _MIPS_SIM == _ABIN32
+ __extension__ unsigned long long int pr_flag;
+#else
+ unsigned long int pr_flag; /* Flags. */
+#endif
+ long pr_uid;
+ long pr_gid;
+ int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+ /* Lots missing */
+ char pr_fname[16]; /* Filename of executable. */
+ char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
+ };
+
+
+/* Addresses. */
+typedef void *psaddr_t;
+
+/* Register sets. Linux has different names. */
+typedef elf_gregset_t prgregset_t;
+typedef elf_fpregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+ therefore habe only ine PID type. */
+typedef __pid_t lwpid_t;
+
+
+typedef struct elf_prstatus prstatus_t;
+typedef struct elf_prpsinfo prpsinfo_t;
+
+__END_DECLS
+
+#endif /* sys/procfs.h */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/sys/syscall.h b/ports/sysdeps/unix/sysv/linux/mips/sys/syscall.h
new file mode 100644
index 000000000..f6458cd31
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/sys/syscall.h
@@ -0,0 +1,42 @@
+/* Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYSCALL_H
+#define _SYSCALL_H 1
+
+/* This file should list the numbers of the system the system knows.
+ But instead of duplicating this we use the information available
+ from the kernel sources. */
+#ifdef _LIBC
+/* Since the kernel doesn't define macro names in a way usable for
+ glibc, we preprocess this header, and use it during the glibc build
+ process. */
+# include <asm-unistd.h>
+#else
+# include <asm/unistd.h>
+#endif
+
+#ifndef _LIBC
+/* The Linux kernel header file defines macros `__NR_<name>', but some
+ programs expect the traditional form `SYS_<name>'. So in building libc
+ we scan the kernel's list and produce <bits/syscall.h> with macros for
+ all the `SYS_' names. */
+# include <bits/syscall.h>
+#endif
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/sys/sysmips.h b/ports/sysdeps/unix/sysv/linux/mips/sys/sysmips.h
new file mode 100644
index 000000000..0677cafaa
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/sys/sysmips.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 1995, 1997, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_SYSMIPS_H
+#define _SYS_SYSMIPS_H 1
+
+#include <features.h>
+
+/*
+ * Commands for the sysmips(2) call
+ *
+ * sysmips(2) is deprecated - though some existing software uses it.
+ * We only support the following commands. Sysmips exists for compatibility
+ * purposes only so new software should avoid it.
+ */
+#define SETNAME 1 /* set hostname */
+#define FLUSH_CACHE 3 /* writeback and invalidate caches */
+#define MIPS_FIXADE 7 /* control address error fixing */
+#define MIPS_RDNVRAM 10 /* read NVRAM */
+#define MIPS_ATOMIC_SET 2001 /* atomically set variable */
+
+__BEGIN_DECLS
+
+extern int sysmips (__const int cmd, ...) __THROW;
+
+__END_DECLS
+
+#endif /* sys/sysmips.h */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/sys/tas.h b/ports/sysdeps/unix/sysv/linux/mips/sys/tas.h
new file mode 100644
index 000000000..1183b867b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/sys/tas.h
@@ -0,0 +1,67 @@
+/* Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Maciej W. Rozycki <macro@ds2.pg.gda.pl>, 2000.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_TAS_H
+#define _SYS_TAS_H 1
+
+#include <features.h>
+#include <sgidefs.h>
+
+__BEGIN_DECLS
+
+extern int _test_and_set (int *p, int v) __THROW;
+
+#ifdef __USE_EXTERN_INLINES
+
+# ifndef _EXTERN_INLINE
+# define _EXTERN_INLINE extern __inline
+# endif
+
+_EXTERN_INLINE int
+__NTH (_test_and_set (int *p, int v))
+{
+ int r, t;
+
+ __asm__ __volatile__
+ ("/* Inline test and set */\n"
+ "1:\n\t"
+ ".set push\n\t"
+#if _MIPS_SIM == _ABIO32
+ ".set mips2\n\t"
+#endif
+ "ll %0,%3\n\t"
+ "move %1,%4\n\t"
+ "beq %0,%4,2f\n\t"
+ "sc %1,%2\n\t"
+ ".set pop\n\t"
+ "beqz %1,1b\n"
+ "2:\n\t"
+ "/* End test and set */"
+ : "=&r" (r), "=&r" (t), "=m" (*p)
+ : "m" (*p), "r" (v)
+ : "memory");
+
+ return r;
+}
+
+#endif /* __USE_EXTERN_INLINES */
+
+__END_DECLS
+
+#endif /* sys/tas.h */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/sys/ucontext.h b/ports/sysdeps/unix/sysv/linux/mips/sys/ucontext.h
new file mode 100644
index 000000000..ac496f3d6
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/sys/ucontext.h
@@ -0,0 +1,117 @@
+/* Copyright (C) 1997, 1998, 2000, 2003, 2004, 2006 Free Software
+ Foundation, Inc. This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Don't rely on this, the interface is currently messed up and may need to
+ be broken to be fixed. */
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <sgidefs.h>
+#include <signal.h>
+
+/* We need the signal context definitions even if they are not used
+ included in <signal.h>. */
+#include <bits/sigcontext.h>
+
+/* Type for general register. Even in o32 we assume 64-bit registers,
+ like the kernel. */
+__extension__ typedef unsigned long long int greg_t;
+
+/* Number of general registers. */
+#define NGREG 32
+#define NFPREG 32
+
+/* Container for all general registers. */
+typedef greg_t gregset_t[NGREG];
+
+/* Container for all FPU registers. */
+typedef struct fpregset {
+ union {
+ double fp_dregs[NFPREG];
+ struct {
+ float _fp_fregs;
+ unsigned int _fp_pad;
+ } fp_fregs[NFPREG];
+ } fp_r;
+} fpregset_t;
+
+
+/* Context to describe whole processor state. */
+#if _MIPS_SIM == _ABIO32
+/* Earlier versions of glibc for mips had an entirely different
+ definition of mcontext_t, that didn't even resemble the
+ corresponding kernel data structure. Since all legitimate uses of
+ ucontext_t in glibc mustn't have accessed anything beyond
+ uc_mcontext and, even then, taking a pointer to it, casting it to
+ sigcontext_t, and accessing it as such, which is what it has always
+ been, this can still be rectified. Fortunately, makecontext,
+ [gs]etcontext et all have never been implemented. */
+typedef struct
+ {
+ unsigned int regmask;
+ unsigned int status;
+ greg_t pc;
+ gregset_t gregs;
+ fpregset_t fpregs;
+ unsigned int fp_owned;
+ unsigned int fpc_csr;
+ unsigned int fpc_eir;
+ unsigned int used_math;
+ unsigned int dsp;
+ greg_t mdhi;
+ greg_t mdlo;
+ unsigned long hi1;
+ unsigned long lo1;
+ unsigned long hi2;
+ unsigned long lo2;
+ unsigned long hi3;
+ unsigned long lo3;
+ } mcontext_t;
+#else
+typedef struct
+ {
+ gregset_t gregs;
+ fpregset_t fpregs;
+ greg_t mdhi;
+ greg_t hi1;
+ greg_t hi2;
+ greg_t hi3;
+ greg_t mdlo;
+ greg_t lo1;
+ greg_t lo2;
+ greg_t lo3;
+ greg_t pc;
+ unsigned int fpc_csr;
+ unsigned int used_math;
+ unsigned int dsp;
+ unsigned int reserved;
+ } mcontext_t;
+#endif
+
+/* Userlevel context. */
+typedef struct ucontext
+ {
+ unsigned long int uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ __sigset_t uc_sigmask;
+ } ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/sys/user.h b/ports/sysdeps/unix/sysv/linux/mips/sys/user.h
new file mode 100644
index 000000000..d5b3b0508
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/sys/user.h
@@ -0,0 +1,219 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_USER_H
+#define _SYS_USER_H 1
+
+#include <sgidefs.h>
+
+/* The whole purpose of this file is for GDB and GDB only. Don't read
+ too much into it. Don't use it for anything other than GDB unless
+ you know what you are doing. */
+
+/* #include <asm/reg.h> */
+/* Instead of including the kernel header, that will vary depending on
+ whether the 32- or the 64-bit kernel is installed, we paste its
+ contents here. Note that the fact that the file is inline here,
+ instead of included separately, doesn't change in any way the
+ licensing status of a program that includes user.h. Since this is
+ for gdb alone, and gdb is GPLed, no surprises here. */
+#if _MIPS_SIM == _ABIO32
+/*
+ * Various register offset definitions for debuggers, core file
+ * examiners and whatnot.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1995, 1999 by Ralf Baechle
+ */
+#ifndef __ASM_MIPS_REG_H
+#define __ASM_MIPS_REG_H
+
+/*
+ * This defines/structures correspond to the register layout on stack -
+ * if the order here is changed, it needs to be updated in
+ * include/asm-mips/stackframe.h
+ */
+#define EF_REG0 6
+#define EF_REG1 7
+#define EF_REG2 8
+#define EF_REG3 9
+#define EF_REG4 10
+#define EF_REG5 11
+#define EF_REG6 12
+#define EF_REG7 13
+#define EF_REG8 14
+#define EF_REG9 15
+#define EF_REG10 16
+#define EF_REG11 17
+#define EF_REG12 18
+#define EF_REG13 19
+#define EF_REG14 20
+#define EF_REG15 21
+#define EF_REG16 22
+#define EF_REG17 23
+#define EF_REG18 24
+#define EF_REG19 25
+#define EF_REG20 26
+#define EF_REG21 27
+#define EF_REG22 28
+#define EF_REG23 29
+#define EF_REG24 30
+#define EF_REG25 31
+/*
+ * k0/k1 unsaved
+ */
+#define EF_REG28 34
+#define EF_REG29 35
+#define EF_REG30 36
+#define EF_REG31 37
+
+/*
+ * Saved special registers
+ */
+#define EF_LO 38
+#define EF_HI 39
+
+#define EF_CP0_EPC 40
+#define EF_CP0_BADVADDR 41
+#define EF_CP0_STATUS 42
+#define EF_CP0_CAUSE 43
+
+#define EF_SIZE 180 /* size in bytes */
+
+#endif /* __ASM_MIPS_REG_H */
+
+#else /* _MIPS_SIM != _ABIO32 */
+
+/*
+ * Various register offset definitions for debuggers, core file
+ * examiners and whatnot.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1995, 1999 Ralf Baechle
+ * Copyright (C) 1995, 1999 Silicon Graphics
+ */
+#ifndef _ASM_REG_H
+#define _ASM_REG_H
+
+/*
+ * This defines/structures correspond to the register layout on stack -
+ * if the order here is changed, it needs to be updated in
+ * include/asm-mips/stackframe.h
+ */
+#define EF_REG0 0
+#define EF_REG1 1
+#define EF_REG2 2
+#define EF_REG3 3
+#define EF_REG4 4
+#define EF_REG5 5
+#define EF_REG6 6
+#define EF_REG7 7
+#define EF_REG8 8
+#define EF_REG9 9
+#define EF_REG10 10
+#define EF_REG11 11
+#define EF_REG12 12
+#define EF_REG13 13
+#define EF_REG14 14
+#define EF_REG15 15
+#define EF_REG16 16
+#define EF_REG17 17
+#define EF_REG18 18
+#define EF_REG19 19
+#define EF_REG20 20
+#define EF_REG21 21
+#define EF_REG22 22
+#define EF_REG23 23
+#define EF_REG24 24
+#define EF_REG25 25
+/*
+ * k0/k1 unsaved
+ */
+#define EF_REG28 28
+#define EF_REG29 29
+#define EF_REG30 30
+#define EF_REG31 31
+
+/*
+ * Saved special registers
+ */
+#define EF_LO 32
+#define EF_HI 33
+
+#define EF_CP0_EPC 34
+#define EF_CP0_BADVADDR 35
+#define EF_CP0_STATUS 36
+#define EF_CP0_CAUSE 37
+
+#define EF_SIZE 304 /* size in bytes */
+
+#endif /* _ASM_REG_H */
+
+#endif /* _MIPS_SIM != _ABIO32 */
+
+#if _MIPS_SIM == _ABIO32
+
+struct user
+{
+ unsigned long regs[EF_SIZE/4+64]; /* integer and fp regs */
+ size_t u_tsize; /* text size (pages) */
+ size_t u_dsize; /* data size (pages) */
+ size_t u_ssize; /* stack size (pages) */
+ unsigned long start_code; /* text starting address */
+ unsigned long start_data; /* data starting address */
+ unsigned long start_stack; /* stack starting address */
+ long int signal; /* signal causing core dump */
+ void* u_ar0; /* help gdb find registers */
+ unsigned long magic; /* identifies a core file */
+ char u_comm[32]; /* user command name */
+};
+
+#else
+
+struct user {
+ __extension__ unsigned long regs[EF_SIZE/8+64]; /* integer and fp regs */
+ __extension__ unsigned long u_tsize; /* text size (pages) */
+ __extension__ unsigned long u_dsize; /* data size (pages) */
+ __extension__ unsigned long u_ssize; /* stack size (pages) */
+ __extension__ unsigned long long start_code; /* text starting address */
+ __extension__ unsigned long long start_data; /* data starting address */
+ __extension__ unsigned long long start_stack; /* stack starting address */
+ __extension__ long long signal; /* signal causing core dump */
+ __extension__ unsigned long long u_ar0; /* help gdb find registers */
+ __extension__ unsigned long long magic; /* identifies a core file */
+ char u_comm[32]; /* user command name */
+};
+
+#endif
+
+#define PAGE_SHIFT 12
+#define PAGE_SIZE (1UL << PAGE_SHIFT)
+#define PAGE_MASK (~(PAGE_SIZE-1))
+#define NBPG PAGE_SIZE
+#define UPAGES 1
+#define HOST_TEXT_START_ADDR (u.start_code)
+#define HOST_DATA_START_ADDR (u.start_data)
+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
+
+#endif /* _SYS_USER_H */
diff --git a/ports/sysdeps/unix/sysv/linux/mips/syscalls.list b/ports/sysdeps/unix/sysv/linux/mips/syscalls.list
new file mode 100644
index 000000000..518f2a252
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/syscalls.list
@@ -0,0 +1,31 @@
+# File name Caller Syscall name Args Strong name Weak names
+
+#
+# Calls for compatibility with existing MIPS OS implementations and
+# compilers.
+#
+cachectl - cachectl i:pii __cachectl cachectl
+cacheflush - cacheflush i:pii _flush_cache cacheflush
+sysmips - sysmips i:iiii __sysmips sysmips
+
+#
+# Socket functions; Linux/MIPS doesn't use the socketcall(2) wrapper;
+# it's provided for compatibility, though.
+#
+accept - accept Ci:iBN __libc_accept __accept accept
+bind - bind i:ipi __bind bind
+connect - connect Ci:ipi __libc_connect __connect_internal __connect connect
+getpeername - getpeername i:ipp __getpeername getpeername
+getsockname - getsockname i:ipp __getsockname getsockname
+getsockopt - getsockopt i:iiiBN __getsockopt getsockopt
+listen - listen i:ii __listen listen
+recv - recv Ci:ibni __libc_recv __recv recv
+recvfrom - recvfrom Ci:ibniBN __libc_recvfrom __recvfrom recvfrom
+recvmsg - recvmsg Ci:ipi __libc_recvmsg __recvmsg recvmsg
+send - send Ci:ibni __libc_send __send send
+sendmsg - sendmsg Ci:ipi __libc_sendmsg __sendmsg sendmsg
+sendto - sendto Ci:ibnibn __libc_sendto __sendto sendto
+setsockopt - setsockopt i:iiibn __setsockopt setsockopt
+shutdown - shutdown i:ii __shutdown shutdown
+socket - socket i:iii __socket socket
+socketpair - socketpair i:iiif __socketpair socketpair
diff --git a/ports/sysdeps/unix/sysv/linux/mips/truncate64.c b/ports/sysdeps/unix/sysv/linux/mips/truncate64.c
new file mode 100644
index 000000000..01cc148be
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/truncate64.c
@@ -0,0 +1,76 @@
+/* Copyright (C) 1997,1998,1999,2000,2002,2003,2005,2006
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/types.h>
+#include <endian.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+#include <kernel-features.h>
+
+#ifdef __NR_truncate64
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+/* The variable is shared between all wrappers around *truncate64 calls. */
+int __have_no_truncate64;
+#endif
+
+/* Truncate the file FD refers to to LENGTH bytes. */
+int
+truncate64 (const char *path, off64_t length)
+{
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ if (! __have_no_truncate64)
+#endif
+ {
+ unsigned int low = length & 0xffffffff;
+ unsigned int high = length >> 32;
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ int saved_errno = errno;
+#endif
+ int result = INLINE_SYSCALL (truncate64, 4, CHECK_STRING (path), 0,
+ __LONG_LONG_PAIR (high, low));
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ if (result != -1 || errno != ENOSYS)
+#endif
+ return result;
+
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ __set_errno (saved_errno);
+ __have_no_truncate64 = 1;
+#endif
+ }
+
+#ifndef __ASSUME_TRUNCATE64_SYSCALL
+ if ((off_t) length != length)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+ return truncate (path, (off_t) length);
+#endif
+}
+
+#else
+/* Use the generic implementation. */
+# include <misc/truncate64.c>
+#endif
diff --git a/ports/sysdeps/unix/sysv/linux/mips/ustat.c b/ports/sysdeps/unix/sysv/linux/mips/ustat.c
new file mode 100644
index 000000000..a309f7104
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/ustat.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1997, 1998, 2000, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sys/ustat.h>
+#include <sys/sysmacros.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+#include <bp-checks.h>
+
+int
+ustat (dev_t dev, struct ustat *ubuf)
+{
+ unsigned long k_dev;
+
+ /* We must convert the value to dev_t type used by the kernel. */
+ k_dev = ((major (dev) & 0xff) << 8) | (minor (dev) & 0xff);
+
+ return INLINE_SYSCALL (ustat, 2, k_dev, CHECK_1 (ubuf));
+}
diff --git a/ports/sysdeps/unix/sysv/linux/mips/vfork.S b/ports/sysdeps/unix/sysv/linux/mips/vfork.S
new file mode 100644
index 000000000..38b619528
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/vfork.S
@@ -0,0 +1,98 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* vfork() is just a special case of clone(). */
+
+#include <sys/asm.h>
+#include <sysdep.h>
+#include <asm/unistd.h>
+#include <sgidefs.h>
+
+#ifndef SAVE_PID
+#define SAVE_PID
+#endif
+
+#ifndef RESTORE_PID
+#define RESTORE_PID
+#endif
+
+
+/* int vfork() */
+
+ .text
+LOCALSZ= 1
+FRAMESZ= (((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
+GPOFF= FRAMESZ-(1*SZREG)
+NESTED(__vfork,FRAMESZ,sp)
+#ifdef __PIC__
+ SETUP_GP
+#endif
+ PTR_SUBU sp, FRAMESZ
+ SETUP_GP64 (a5, __vfork)
+#ifdef __PIC__
+ SAVE_GP (GPOFF)
+#endif
+#ifdef PROF
+# if (_MIPS_SIM != _ABIO32)
+ PTR_S a5, GPOFF(sp)
+# endif
+ .set noat
+ move $1, ra
+# if (_MIPS_SIM == _ABIO32)
+ subu sp,sp,8
+# endif
+ jal _mcount
+ .set at
+# if (_MIPS_SIM != _ABIO32)
+ PTR_L a5, GPOFF(sp)
+# endif
+#endif
+
+ PTR_ADDU sp, FRAMESZ
+
+ SAVE_PID
+
+ li a0, 0x4112 /* CLONE_VM | CLONE_VFORK | SIGCHLD */
+ move a1, sp
+
+ /* Do the system call */
+ li v0,__NR_clone
+ syscall
+
+ RESTORE_PID
+
+ bnez a3,L(error)
+
+ /* Successful return from the parent or child. */
+ RESTORE_GP64
+ ret
+
+ /* Something bad happened -- no child created. */
+L(error):
+#ifdef __PIC__
+ PTR_LA t9, __syscall_error
+ RESTORE_GP64
+ jr t9
+#else
+ RESTORE_GP64
+ j __syscall_error
+#endif
+ END(__vfork)
+
+libc_hidden_def(__vfork)
+weak_alias (__vfork, vfork)
diff --git a/ports/sysdeps/unix/sysv/linux/mips/xmknod.c b/ports/sysdeps/unix/sysv/linux/mips/xmknod.c
new file mode 100644
index 000000000..2d0975240
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/xmknod.c
@@ -0,0 +1,51 @@
+/* xmknod call using old-style Unix mknod system call.
+ Copyright (C) 1991, 1993, 1995, 1996, 1997, 1998, 2000, 2002, 2003
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+#include <bp-checks.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
+__xmknod (int vers, const char *path, mode_t mode, dev_t *dev)
+{
+ unsigned long k_dev;
+
+ if (vers != _MKNOD_VER)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ /* We must convert the value to dev_t type used by the kernel. */
+ k_dev = ((major (*dev) & 0xff) << 8) | (minor (*dev) & 0xff);
+
+ return INLINE_SYSCALL (mknod, 3, CHECK_STRING (path), mode, k_dev);
+}
+
+weak_alias (__xmknod, _xmknod)
+libc_hidden_def (__xmknod)
diff --git a/ports/sysdeps/unix/sysv/linux/mips/xstatconv.c b/ports/sysdeps/unix/sysv/linux/mips/xstatconv.c
new file mode 100644
index 000000000..ccab6b6a7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/linux/mips/xstatconv.c
@@ -0,0 +1,139 @@
+/* Convert between the kernel's `struct stat' format, and libc's.
+ Copyright (C) 1991,1995,1996,1997,1998,2000,2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sys/stat.h>
+#include <kernel_stat.h>
+
+#ifdef STAT_IS_KERNEL_STAT
+
+/* Dummy. */
+struct kernel_stat;
+
+#else
+
+#include <string.h>
+
+
+int
+__xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
+{
+ switch (vers)
+ {
+ case _STAT_VER_KERNEL:
+ /* Nothing to do. The struct is in the form the kernel expects.
+ We should have short-circuted before we got here, but for
+ completeness... */
+ *(struct kernel_stat *) ubuf = *kbuf;
+ break;
+
+ case _STAT_VER_LINUX:
+ {
+ struct stat *buf = ubuf;
+
+ /* Convert to current kernel version of `struct stat'. */
+ buf->st_dev = kbuf->st_dev;
+ buf->st_pad1[0] = 0; buf->st_pad1[1] = 0; buf->st_pad1[2] = 0;
+ buf->st_ino = kbuf->st_ino;
+ buf->st_mode = kbuf->st_mode;
+ buf->st_nlink = kbuf->st_nlink;
+ buf->st_uid = kbuf->st_uid;
+ buf->st_gid = kbuf->st_gid;
+ buf->st_rdev = kbuf->st_rdev;
+ buf->st_pad2[0] = 0; buf->st_pad2[1] = 0;
+ buf->st_pad3 = 0;
+ buf->st_size = kbuf->st_size;
+ buf->st_blksize = kbuf->st_blksize;
+ buf->st_blocks = kbuf->st_blocks;
+
+ buf->st_atim.tv_sec = kbuf->st_atime_sec;
+ buf->st_atim.tv_nsec = kbuf->st_atime_nsec;
+ buf->st_mtim.tv_sec = kbuf->st_mtime_sec;
+ buf->st_mtim.tv_nsec = kbuf->st_mtime_nsec;
+ buf->st_ctim.tv_sec = kbuf->st_ctime_sec;
+ buf->st_ctim.tv_nsec = kbuf->st_ctime_nsec;
+
+ buf->st_pad5[0] = 0; buf->st_pad5[1] = 0;
+ buf->st_pad5[2] = 0; buf->st_pad5[3] = 0;
+ buf->st_pad5[4] = 0; buf->st_pad5[5] = 0;
+ buf->st_pad5[6] = 0; buf->st_pad5[7] = 0;
+ }
+ break;
+
+ default:
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+__xstat64_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
+{
+#ifdef XSTAT_IS_XSTAT64
+ return xstat_conv (vers, kbuf, ubuf);
+#else
+ switch (vers)
+ {
+ case _STAT_VER_LINUX:
+ {
+ struct stat64 *buf = ubuf;
+
+ buf->st_dev = kbuf->st_dev;
+ buf->st_pad1[0] = 0; buf->st_pad1[1] = 0; buf->st_pad1[2] = 0;
+ buf->st_ino = kbuf->st_ino;
+ buf->st_mode = kbuf->st_mode;
+ buf->st_nlink = kbuf->st_nlink;
+ buf->st_uid = kbuf->st_uid;
+ buf->st_gid = kbuf->st_gid;
+ buf->st_rdev = kbuf->st_rdev;
+ buf->st_pad2[0] = 0; buf->st_pad2[1] = 0; buf->st_pad2[2] = 0;
+ buf->st_pad3 = 0;
+ buf->st_size = kbuf->st_size;
+ buf->st_blksize = kbuf->st_blksize;
+ buf->st_blocks = kbuf->st_blocks;
+
+ buf->st_atim.tv_sec = kbuf->st_atime_sec;
+ buf->st_atim.tv_nsec = kbuf->st_atime_nsec;
+ buf->st_mtim.tv_sec = kbuf->st_mtime_sec;
+ buf->st_mtim.tv_nsec = kbuf->st_mtime_nsec;
+ buf->st_ctim.tv_sec = kbuf->st_ctime_sec;
+ buf->st_ctim.tv_nsec = kbuf->st_ctime_nsec;
+
+ buf->st_pad4[0] = 0; buf->st_pad4[1] = 0;
+ buf->st_pad4[2] = 0; buf->st_pad4[3] = 0;
+ buf->st_pad4[4] = 0; buf->st_pad4[5] = 0;
+ buf->st_pad4[6] = 0; buf->st_pad4[7] = 0;
+ }
+ break;
+
+ /* If struct stat64 is different from struct stat then
+ _STAT_VER_KERNEL does not make sense. */
+ case _STAT_VER_KERNEL:
+ default:
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return 0;
+#endif
+}
+
+#endif /* ! STAT_IS_KERNEL_STAT */
diff --git a/ports/sysdeps/unix/sysv/minix/bits/sigaction.h b/ports/sysdeps/unix/sysv/minix/bits/sigaction.h
new file mode 100644
index 000000000..4b04b7b55
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/minix/bits/sigaction.h
@@ -0,0 +1,53 @@
+/* Copyright (C) 1992, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SIGNAL_H
+# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
+#endif
+
+/* 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 /* 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/ports/sysdeps/unix/sysv/sco3.2.4/Makefile b/ports/sysdeps/unix/sysv/sco3.2.4/Makefile
new file mode 100644
index 000000000..a199ba900
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2.4/Makefile
@@ -0,0 +1,17 @@
+ifeq (posix,$(subdir))
+sysdep_routines := $(sysdep_routines) pgrpsys sco_getgrp
+endif
+
+ifeq (csu,$(subdir))
+
+# SCO uses crt1.o, and expects that single initializer file to also start
+# the .init and .fini sections as crti.o normally does.
+start-installed-name = crt1.o
+start-installed-name-rule = yes
+
+# Link together start.o and crti.o into the expected crt1.o.
+# Now crt1.o as initializer and crtn.o as finalizer will work.
+$(objpfx)crt1.o: $(objpfx)start.o $(objpfx)crti.o
+ $(CC) -nostdlib -nostartfiles -Wl,-r -o $@ $^
+
+endif
diff --git a/ports/sysdeps/unix/sysv/sco3.2.4/__setpgid.c b/ports/sysdeps/unix/sysv/sco3.2.4/__setpgid.c
new file mode 100644
index 000000000..d51fa602c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2.4/__setpgid.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1994, 1997, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+extern int __pgrpsys (int type, ...);
+
+/* Get the process group ID of process PID. */
+int
+__setpgid (pid, pgid)
+ pid_t pid;
+ pid_t pgid;
+{
+ return __pgrpsys (2, pid, pgid);
+}
+libc_hidden_def (__setpgid)
diff --git a/ports/sysdeps/unix/sysv/sco3.2.4/bits/confname.h b/ports/sysdeps/unix/sysv/sco3.2.4/bits/confname.h
new file mode 100644
index 000000000..42e6ed0ea
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2.4/bits/confname.h
@@ -0,0 +1,54 @@
+/* `sysconf', `pathconf', and `confstr' NAME values. Generic version.
+ Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _UNISTD_H
+# error "Never use <bits/confname.h> directly; include <unistd.h> instead."
+#endif
+
+/* 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/ports/sysdeps/unix/sysv/sco3.2.4/bits/sigaction.h b/ports/sysdeps/unix/sysv/sco3.2.4/bits/sigaction.h
new file mode 100644
index 000000000..f08738855
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2.4/bits/sigaction.h
@@ -0,0 +1,43 @@
+/* The proper definitions for SCO's sigaction.
+ Copyright (C) 1993, 1994, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SIGNAL_H
+# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
+#endif
+
+/* 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/ports/sysdeps/unix/sysv/sco3.2.4/getgroups.c b/ports/sysdeps/unix/sysv/sco3.2.4/getgroups.c
new file mode 100644
index 000000000..2aac40bdd
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2.4/getgroups.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1994, 1995, 1997, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <limits.h>
+#include <alloca.h>
+
+extern int __sco_getgroups (int size, unsigned short int *list);
+
+int
+__getgroups (size, list)
+ int size; 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/ports/sysdeps/unix/sysv/sco3.2.4/getpgid.c b/ports/sysdeps/unix/sysv/sco3.2.4/getpgid.c
new file mode 100644
index 000000000..3b47d9dee
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2.4/getpgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/sysv4/getpgid.c>
diff --git a/ports/sysdeps/unix/sysv/sco3.2.4/setpgid.c b/ports/sysdeps/unix/sysv/sco3.2.4/setpgid.c
new file mode 100644
index 000000000..cc9c4cd61
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2.4/setpgid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/sysv4/setpgid.c>
diff --git a/ports/sysdeps/unix/sysv/sco3.2.4/setsid.c b/ports/sysdeps/unix/sysv/sco3.2.4/setsid.c
new file mode 100644
index 000000000..633765255
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2.4/setsid.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/sysv4/setsid.c>
diff --git a/ports/sysdeps/unix/sysv/sco3.2.4/sigaction.S b/ports/sysdeps/unix/sysv/sco3.2.4/sigaction.S
new file mode 100644
index 000000000..ae50c17d9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2.4/sigaction.S
@@ -0,0 +1,30 @@
+/* Copyright (C) 1993, 1994, 1995, 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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
+
+libc_hidden_def (__sigaction)
+weak_alias (__sigaction, sigaction)
diff --git a/ports/sysdeps/unix/sysv/sco3.2.4/sys/syscall.h b/ports/sysdeps/unix/sysv/sco3.2.4/sys/syscall.h
new file mode 100644
index 000000000..05bbb89f3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2.4/sys/syscall.h
@@ -0,0 +1,125 @@
+/* Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* 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/ports/sysdeps/unix/sysv/sco3.2.4/syscalls.list b/ports/sysdeps/unix/sysv/sco3.2.4/syscalls.list
new file mode 100644
index 000000000..bda6c16c7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2.4/syscalls.list
@@ -0,0 +1,8 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+pathconf - pathconf 2 __pathconf pathconf
+pgrpsys - pgrpsys 3 __pgrpsys
+sco_getgrp getgroups getgroups 2 __sco_getgroups
+sigpending - sigpending 1 sigpending
+sigprocmask - sigprocmask 3 __sigprocmask sigprocmask
+sigsuspend - sigsuspend 1 sigsuspend
diff --git a/ports/sysdeps/unix/sysv/sco3.2.4/sysconf.S b/ports/sysdeps/unix/sysv/sco3.2.4/sysconf.S
new file mode 100644
index 000000000..9780bd488
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2.4/sysconf.S
@@ -0,0 +1,30 @@
+/* Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#include <bits/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/ports/sysdeps/unix/sysv/sco3.2.4/system.c b/ports/sysdeps/unix/sysv/sco3.2.4/system.c
new file mode 100644
index 000000000..06dc066b8
--- /dev/null
+++ b/ports/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/ports/sysdeps/unix/sysv/sco3.2.4/uname.S b/ports/sysdeps/unix/sysv/sco3.2.4/uname.S
new file mode 100644
index 000000000..bc61089d6
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2.4/uname.S
@@ -0,0 +1,41 @@
+/* Copyright (C) 1993, 1994, 1997 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/sysv/sco3.2.4/waitpid.S b/ports/sysdeps/unix/sysv/sco3.2.4/waitpid.S
new file mode 100644
index 000000000..ccbc81274
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2.4/waitpid.S
@@ -0,0 +1,37 @@
+/* Copyright (C) 1993,94,95,97,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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
+
+libc_hidden_def (__waitpid)
+weak_alias (__waitpid, waitpid)
diff --git a/ports/sysdeps/unix/sysv/sco3.2/Makefile b/ports/sysdeps/unix/sysv/sco3.2/Makefile
new file mode 100644
index 000000000..c4d9da7a0
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2/Makefile
@@ -0,0 +1,23 @@
+# Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+ifeq ($(subdir),misc)
+
+sysdep_routines := $(sysdep_routines) __fltused
+
+endif
diff --git a/ports/sysdeps/unix/sysv/sco3.2/__fltused.c b/ports/sysdeps/unix/sysv/sco3.2/__fltused.c
new file mode 100644
index 000000000..5d1d67f0b
--- /dev/null
+++ b/ports/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/ports/sysdeps/unix/sysv/sco3.2/bits/local_lim.h b/ports/sysdeps/unix/sysv/sco3.2/bits/local_lim.h
new file mode 100644
index 000000000..b4141d0db
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sco3.2/bits/local_lim.h
@@ -0,0 +1,37 @@
+/* Copyright (C) 1993, 1996 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _BITS_LOCAL_LIM_H
+#define _BITS_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 /* bits/local_lim.h */
diff --git a/ports/sysdeps/unix/sysv/sysv4/Implies b/ports/sysdeps/unix/sysv/sysv4/Implies
new file mode 100644
index 000000000..953822ea4
--- /dev/null
+++ b/ports/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/ports/sysdeps/unix/sysv/sysv4/Makefile b/ports/sysdeps/unix/sysv/sysv4/Makefile
new file mode 100644
index 000000000..6f7155c71
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/Makefile
@@ -0,0 +1,29 @@
+# Copyright (C) 1992, 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+ifeq ($(subdir),posix)
+
+sysdep_routines := $(sysdep_routines) sysconfig pgrpsys __waitid
+
+endif
+
+ifeq ($(subdir),misc)
+
+sysdep_routines := $(sysdep_routines) sysinfo
+
+endif
diff --git a/ports/sysdeps/unix/sysv/sysv4/__getpgid.c b/ports/sysdeps/unix/sysv/sysv4/__getpgid.c
new file mode 100644
index 000000000..74ca3e0f9
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/__getpgid.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1993, 1997, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+extern int __pgrpsys (int type, ...);
+
+/* Get the process group ID of process PID. */
+int
+__getpgid (pid)
+ pid_t pid;
+{
+ return __pgrpsys (4, pid);
+}
+libc_hidden_def (__getpgid)
diff --git a/ports/sysdeps/unix/sysv/sysv4/__setpgid.c b/ports/sysdeps/unix/sysv/sysv4/__setpgid.c
new file mode 100644
index 000000000..36ad5cc77
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/__setpgid.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1993, 1997, 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+extern int __pgrpsys (int type, ...);
+
+/* Get the process group ID of process PID. */
+int
+__setpgid (pid, pgid)
+ pid_t pid;
+ pid_t pgid;
+{
+ return __pgrpsys (5, pid, pgid);
+}
+libc_hidden_def (__setpgid)
diff --git a/ports/sysdeps/unix/sysv/sysv4/bits/sigaction.h b/ports/sysdeps/unix/sysv/sysv4/bits/sigaction.h
new file mode 100644
index 000000000..faf07e5ff
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/bits/sigaction.h
@@ -0,0 +1,55 @@
+/* The proper definitions for SVR4's sigaction.
+ Copyright (C) 1993, 1994, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SIGNAL_H
+# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
+#endif
+
+/* 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 /* 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/ports/sysdeps/unix/sysv/sysv4/bits/signum.h b/ports/sysdeps/unix/sysv/sysv4/bits/signum.h
new file mode 100644
index 000000000..07f900a78
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/bits/signum.h
@@ -0,0 +1,66 @@
+/* Signal number definitions. SVR4 version.
+ Copyright (C) 1994, 1996 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/sysv/sysv4/bits/sigset.h b/ports/sysdeps/unix/sysv/sysv4/bits/sigset.h
new file mode 100644
index 000000000..9093c7295
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/bits/sigset.h
@@ -0,0 +1,98 @@
+/* __sig_atomic_t, __sigset_t, and related definitions. SVR4 version.
+ Copyright (C) 1994-1996, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 (unsigned long int) * 8)
+#define __SSELT(s) ((s) / __NSSBITS)
+#define __SSMASK(s) (1 << ((s) % __NSSBITS))
+
+#ifdef __USE_EXTERN_INLINES
+# 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] = ~0L;
+ 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 /* use extern inlines. */
+
+#endif /* ! _SIGSET_H_fns */
diff --git a/ports/sysdeps/unix/sysv/sysv4/bits/utsname.h b/ports/sysdeps/unix/sysv/sysv4/bits/utsname.h
new file mode 100644
index 000000000..891ae6862
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/bits/utsname.h
@@ -0,0 +1,23 @@
+/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_UTSNAME_H
+# error "Never include <bits/utsname.h> directly; use <sys/utsname.h> instead."
+#endif
+
+#define _UTSNAME_LENGTH 257
diff --git a/ports/sysdeps/unix/sysv/sysv4/bits/waitflags.h b/ports/sysdeps/unix/sysv/sysv4/bits/waitflags.h
new file mode 100644
index 000000000..40bc823de
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/bits/waitflags.h
@@ -0,0 +1,34 @@
+/* Definitions of flag bits for `waitpid' et al.
+ Copyright (C) 1993, 1996, 1997, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#if !defined _SYS_WAIT_H && !defined _STDLIB_H
+# error "Never include <bits/waitflags.h> directly; use <sys/wait.h> instead."
+#endif
+
+
+/* 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
diff --git a/ports/sysdeps/unix/sysv/sysv4/dup2.c b/ports/sysdeps/unix/sysv/sysv4/dup2.c
new file mode 100644
index 000000000..7d36e0e35
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/dup2.c
@@ -0,0 +1,2 @@
+/* SVR4 uses the POSIX dup2. */
+#include <sysdeps/posix/dup2.c>
diff --git a/ports/sysdeps/unix/sysv/sysv4/ftruncate.c b/ports/sysdeps/unix/sysv/sysv4/ftruncate.c
new file mode 100644
index 000000000..47e040eb2
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/ftruncate.c
@@ -0,0 +1,37 @@
+/* ftruncate for SVR4 using the fcntl F_FREESP command.
+ Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+
+/* Truncate the file FD refers to to LENGTH bytes. */
+int
+ftruncate (fd, length)
+ int fd;
+ 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/ports/sysdeps/unix/sysv/sysv4/gethostname.c b/ports/sysdeps/unix/sysv/sysv4/gethostname.c
new file mode 100644
index 000000000..4a058b51c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/gethostname.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1994, 1995, 1997, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/systeminfo.h>
+
+extern int __sysinfo (int command, char *buf, long int count);
+
+int
+__gethostname (name, namelen)
+ char *name;
+ size_t namelen;
+{
+ return __sysinfo (SI_HOSTNAME, name, namelen);
+}
+
+weak_alias (__gethostname, gethostname)
diff --git a/ports/sysdeps/unix/sysv/sysv4/getpagesize.c b/ports/sysdeps/unix/sysv/sysv4/getpagesize.c
new file mode 100644
index 000000000..611964075
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/getpagesize.c
@@ -0,0 +1,2 @@
+/* Solaris uses sysconf ala POSIX.1. */
+#include <sysdeps/posix/getpagesize.c>
diff --git a/ports/sysdeps/unix/sysv/sysv4/getpgid.c b/ports/sysdeps/unix/sysv/sysv4/getpgid.c
new file mode 100644
index 000000000..95f96417c
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/getpgid.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1993,1995,1997,1999,2002,2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <unistd.h>
+#include <sys/types.h>
+
+extern pid_t __pgrpsys (int type, ...);
+
+/* Get the process group ID of process PID. */
+pid_t
+__getpgid (pid)
+ pid_t pid;
+{
+ return __pgrpsys (4, pid);
+}
+libc_hidden_def (__getpgid)
+weak_alias (__getpgid, getpgid)
diff --git a/ports/sysdeps/unix/sysv/sysv4/i386/Makefile b/ports/sysdeps/unix/sysv/sysv4/i386/Makefile
new file mode 100644
index 000000000..56f0a37de
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/i386/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),signal)
+sysdep_routines := $(sysdep_routines) sys-sig
+endif
diff --git a/ports/sysdeps/unix/sysv/sysv4/i386/bits/stat.h b/ports/sysdeps/unix/sysv/sysv4/i386/bits/stat.h
new file mode 100644
index 000000000..c1016a922
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/i386/bits/stat.h
@@ -0,0 +1,93 @@
+/* Copyright (C) 1993, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_STAT_H
+# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* Versions of the `struct stat' data structure and
+ the bits of the `xmknod' interface. */
+#define _STAT_VER 2
+#define _MKNOD_VER 2
+
+/* Structure describing file characteristics. */
+struct stat
+ {
+ unsigned long itn st_dev; /* Device. */
+ long int st_filler1[3];
+ unsigned long int st_ino; /* File serial number. */
+ unsigned long int st_mode; /* File mode. */
+ unsigned long int st_nlink; /* Link count. */
+ long int st_uid; /* User ID of the file's owner. */
+ long int st_gid; /* Group ID of the file's group.*/
+ unsigned long int st_rdev; /* Device number, if device. */
+ long int st_filler2[2];
+
+ long int st_size; /* Size of file, in bytes. */
+ /* SVR4 added this extra long to allow for expansion of off_t. */
+ long int st_filler3;
+
+ long int st_atime; /* Time of last access. */
+ unsigned long int st_atime_usec;
+ long int st_mtime; /* Time of last modification. */
+ unsigned long int st_mtime_usec;
+ long int st_ctime; /* Time of last status change. */
+ unsigned long int st_ctime_usec;
+
+ __blksize_t st_blksize; /* Optimal block size for I/O. */
+#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
+
+ __blkcnt_t st_blocks; /* Number of 512-byte blocks allocated. */
+ char st_fstype[16]; /* The type of this filesystem. */
+ int st_aclcnt;
+ unsigned long int st_level;
+ unsigned long int st_flags;
+ unsigned long int st_cmwlevel;
+ long int 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. */
+
+/* POSIX.1b objects. */
+#define __S_TYPEISMQ(buf) (0)
+#define __S_TYPEISSEM(buf) (0)
+#define __S_TYPEISSHM(buf) (0)
+
+/* 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. */
diff --git a/ports/sysdeps/unix/sysv/sysv4/i386/sys-sig.S b/ports/sysdeps/unix/sysv/sysv4/i386/sys-sig.S
new file mode 100644
index 000000000..6e2d1abde
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/i386/sys-sig.S
@@ -0,0 +1,30 @@
+/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/sysv/sysv4/i386/syscalls.list b/ports/sysdeps/unix/sysv/sysv4/i386/syscalls.list
new file mode 100644
index 000000000..560cd8366
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/i386/syscalls.list
@@ -0,0 +1,6 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+xstat - xstat 3 __xstat _xstat
+fxstat - fxstat 3 __fxstat _fxstat
+lxstat - lxstat 3 __lxstat _lxstat
+xmknod - xmknod 4 __xmknod _xmknod
diff --git a/ports/sysdeps/unix/sysv/sysv4/i386/sysdep.h b/ports/sysdeps/unix/sysv/sysv4/i386/sysdep.h
new file mode 100644
index 000000000..daecdb622
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/i386/sysdep.h
@@ -0,0 +1,38 @@
+/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 <bits/errno.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/ports/sysdeps/unix/sysv/sysv4/i386/vfork.S b/ports/sysdeps/unix/sysv/sysv4/i386/vfork.S
new file mode 100644
index 000000000..bbe99fbc4
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/i386/vfork.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/bsd/i386/vfork.S>
diff --git a/ports/sysdeps/unix/sysv/sysv4/sethostname.c b/ports/sysdeps/unix/sysv/sysv4/sethostname.c
new file mode 100644
index 000000000..d74b0f4f3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/sethostname.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1994, 1997, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/systeminfo.h>
+
+extern int __sysinfo (int command, const char *buf, long count);
+
+int
+sethostname (name, namelen)
+ const char *name;
+ size_t namelen;
+{
+ return __sysinfo (SI_SET_HOSTNAME, name, namelen);
+}
diff --git a/ports/sysdeps/unix/sysv/sysv4/setpgid.c b/ports/sysdeps/unix/sysv/sysv4/setpgid.c
new file mode 100644
index 000000000..80f4ad643
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/setpgid.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1993,1995-1997,1999,2002,2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <unistd.h>
+
+extern int __pgrpsys (pid_t 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
+__setpgid (pid, pgid)
+ pid_t pid, pgid;
+{
+ return __pgrpsys (5, pid, pgid);
+}
+libc_hidden_def (__setpgid)
+weak_alias (__setpgid, setpgid)
diff --git a/ports/sysdeps/unix/sysv/sysv4/setsid.c b/ports/sysdeps/unix/sysv/sysv4/setsid.c
new file mode 100644
index 000000000..faa2c42d7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/setsid.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1993, 1995, 1997, 1999, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <unistd.h>
+
+extern pid_t __pgrpsys (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. */
+pid_t
+__setsid ()
+{
+ return __pgrpsys (3);
+}
+
+weak_alias (__setsid, setsid)
diff --git a/ports/sysdeps/unix/sysv/sysv4/sigaction.c b/ports/sysdeps/unix/sysv/sysv4/sigaction.c
new file mode 100644
index 000000000..d5926b3d4
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/sigaction.c
@@ -0,0 +1,80 @@
+/* Copyright (C) 1994,1995,1996,1997,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <signal.h>
+#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
+__sigaction (sig, act, oact)
+ int sig;
+ const struct sigaction *act;
+ struct sigaction *oact;
+{
+ struct sigaction myact;
+ __sighandler_t ohandler;
+
+ if (sig <= 0 || sig >= NSIG)
+ {
+ __set_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;
+}
+libc_hidden_def (__sigaction)
+weak_alias (__sigaction, sigaction)
diff --git a/ports/sysdeps/unix/sysv/sysv4/siginfo.h b/ports/sysdeps/unix/sysv/sysv4/siginfo.h
new file mode 100644
index 000000000..2bb925738
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/siginfo.h
@@ -0,0 +1,59 @@
+/* Definitions of the siginfo structure.
+ Copyright (C) 1993, 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/sysv/sysv4/sigset-cvt-mask.h b/ports/sysdeps/unix/sysv/sysv4/sigset-cvt-mask.h
new file mode 100644
index 000000000..5b7ea2588
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/sigset-cvt-mask.h
@@ -0,0 +1,37 @@
+/* Convert between lowlevel sigmask and libc representation of sigset_t.
+ SysVr4 version.
+ Copyright (C) 1998, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Joe Keane <jgk@jgk.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+static inline int __attribute__ ((unused))
+sigset_set_old_mask (sigset_t *set, int mask)
+{
+ set->__sigbits[0] = (unsigned int) mask;
+ set->__sigbits[1] = 0ul;
+ set->__sigbits[2] = 0ul;
+ set->__sigbits[3] = 0ul;
+
+ return 0;
+}
+
+static inline int __attribute__ ((unused))
+sigset_get_old_mask (const sigset_t *set)
+{
+ return (unsigned int) set->__sigbits[0];
+}
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/Makefile b/ports/sysdeps/unix/sysv/sysv4/solaris2/Makefile
new file mode 100644
index 000000000..3ad90f748
--- /dev/null
+++ b/ports/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.
+ALL_BUILD_CFLAGS += -L/lib
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/dirent.h b/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/dirent.h
new file mode 100644
index 000000000..fa0250eb3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/dirent.h
@@ -0,0 +1,50 @@
+/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _DIRENT_H
+# error "Never use <bits/dirent.h> directly; include <dirent.h> instead."
+#endif
+
+struct dirent
+ {
+#ifndef __USE_FILE_OFFSET64
+ __ino_t d_ino;
+ __off_t d_off;
+#else
+ __ino64_t d_ino;
+ __off64_t d_off;
+#endif
+ unsigned short int d_reclen;
+ char d_name[256]; /* We must not include limits.h! */
+ };
+
+#ifdef __USE_LARGEFILE64
+struct dirent64
+ {
+ __ino64_t d_ino;
+ __off64_t d_off;
+ unsigned short int d_reclen;
+ char d_name[256]; /* We must not include limits.h! */
+ };
+#endif
+
+#define d_fileno d_ino /* Backwards compatibility. */
+
+#undef _DIRENT_HAVE_D_NAMLEN
+#define _DIRENT_HAVE_D_RECLEN
+#define _DIRENT_HAVE_D_OFF
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/errno.h b/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/errno.h
new file mode 100644
index 000000000..6c0de9215
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/errno.h
@@ -0,0 +1,168 @@
+/* Copyright (C) 1991, 1994, 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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 33 /* Math argument out of domain of function. */
+# define EILSEQ 88 /* Illegal byte sequence. */
+# define ERANGE 34 /* Math result not representable. */
+#endif
+
+#ifdef _ERRNO_H
+/* All error codes the system knows about. */
+
+# define EPERM 1 /* Not super-user. */
+# define ENOENT 2 /* No such file or directory. */
+# define ESRCH 3 /* No such process. */
+# define EINTR 4 /* Interrupted system call. */
+# define EIO 5 /* I/O error. */
+# define ENXIO 6 /* No such device or address. */
+# define E2BIG 7 /* Arg list too long. */
+# define ENOEXEC 8 /* Exec format error. */
+# define EBADF 9 /* Bad file number. */
+# define ECHILD 10 /* No children. */
+# define EAGAIN 11 /* Resource temporarily unavailable. */
+# define EWOULDBLOCK EAGAIN
+# define ENOMEM 12 /* Not enough core. */
+# define EACCES 13 /* Permission denied. */
+# define EFAULT 14 /* Bad address. */
+# define ENOTBLK 15 /* Block device required. */
+# define EBUSY 16 /* Mount device busy. */
+# define EEXIST 17 /* File exists. */
+# define EXDEV 18 /* Cross-device link. */
+# define ENODEV 19 /* No such device. */
+# define ENOTDIR 20 /* Not a directory. */
+# define EISDIR 21 /* Is a directory. */
+# define EINVAL 22 /* Invalid argument. */
+# define ENFILE 23 /* File table overflow. */
+# define EMFILE 24 /* Too many open files. */
+# define ENOTTY 25 /* Inappropriate ioctl for device. */
+# define ETXTBSY 26 /* Text file busy. */
+# 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. */
+# define ENOMSG 35 /* No message of desired type. */
+# define EIDRM 36 /* Identifier removed. */
+# define ECHRNG 37 /* Channel number out of range. */
+# define EL2NSYNC 38 /* Level 2 not synchronized. */
+# define EL3HLT 39 /* Level 3 halted. */
+# define EL3RST 40 /* Level 3 reset. */
+# define ELNRNG 41 /* Link number out of range. */
+# define EUNATCH 42 /* Protocol driver not attached. */
+# define ENOCSI 43 /* No CSI structure available. */
+# define EL2HLT 44 /* Level 2 halted. */
+# define EDEADLK 45 /* Deadlock condition. */
+# define ENOLCK 46 /* No record locks available. */
+# define ECANCELED 47 /* Operation canceled. */
+# define ENOTSUP 48 /* Operation not supported. */
+
+/* Filesystem Quotas. */
+# define EDQUOT 49 /* Disc quota exceeded. */
+
+/* Convergent Error Returns. */
+# define EBADE 50 /* Invalid exchange. */
+# define EBADR 51 /* Invalid request descriptor. */
+# define EXFULL 52 /* Exchange full. */
+# define ENOANO 53 /* No anode. */
+# define EBADRQC 54 /* Invalid request code. */
+# define EBADSLT 55 /* Invalid slot. */
+# define EDEADLOCK 56 /* File locking deadlock error. */
+
+# define EBFONT 57 /* Bad font file fmt. */
+
+/* STREAM problems. */
+# define ENOSTR 60 /* Device not a stream. */
+# define ENODATA 61 /* No data (for no delay io). */
+# define ETIME 62 /* Timer expired. */
+# define ENOSR 63 /* Out of streams resources. */
+
+# define ENONET 64 /* Machine is not on the network. */
+# define ENOPKG 65 /* Package not installed. */
+# define EREMOTE 66 /* The object is remote. */
+# define ENOLINK 67 /* The link has been severed. */
+# define EADV 68 /* Advertise error. */
+# define ESRMNT 69 /* Srmount error. */
+
+# define ECOMM 70 /* Communication error on send. */
+# define EPROTO 71 /* Protocol error. */
+# define EMULTIHOP 74 /* Multihop attempted. */
+# define EBADMSG 77 /* Trying to read unreadable message. */
+# define ENAMETOOLONG 78 /* Path name is too long. */
+# define EOVERFLOW 79 /* Value too large to be stored in data type.*/
+# define ENOTUNIQ 80 /* Given log. name not unique. */
+# define EBADFD 81 /* F.d. invalid for this operation. */
+# define EREMCHG 82 /* Remote address changed. */
+
+/* Shared library problems. */
+# define ELIBACC 83 /* Can't access a needed shared lib. */
+# define ELIBBAD 84 /* Accessing a corrupted shared lib. */
+# define ELIBSCN 85 /* .lib section in a.out corrupted. */
+# define ELIBMAX 86 /* Attempting to link in too many libs. */
+# define ELIBEXEC 87 /* Attempting to exec a shared library. */
+# define ENOSYS 89 /* Unsupported file system operation. */
+# define ELOOP 90 /* Symbolic link loop. */
+# define ERESTART 91 /* Restartable system call. */
+# define ESTRPIPE 92 /* If pipe/FIFO, don't sleep in stream head. */
+# define ENOTEMPTY 93 /* Directory not empty. */
+# define EUSERS 94 /* Too many users (for UFS). */
+
+/* BSD Networking Software: argument errors. */
+# define ENOTSOCK 95 /* Socket operation on non-socket. */
+# define EDESTADDRREQ 96 /* Destination address required. */
+# define EMSGSIZE 97 /* Message too long. */
+# define EPROTOTYPE 98 /* Protocol wrong type for socket. */
+# define ENOPROTOOPT 99 /* Protocol not available. */
+# define EPROTONOSUPPORT 120 /* Protocol not supported. */
+# define ESOCKTNOSUPPORT 121 /* Socket type not supported. */
+# define EOPNOTSUPP 122 /* Operation not supported on socket. */
+# define EPFNOSUPPORT 123 /* Protocol family not supported. */
+# define EAFNOSUPPORT 124 /* Address family not supported by
+ protocol family. */
+# define EADDRINUSE 125 /* Address already in use. */
+# define EADDRNOTAVAIL 126 /* Can't assign requested address. */
+/* BSD Networking Software: operational errors. */
+# define ENETDOWN 127 /* Network is down. */
+# define ENETUNREACH 128 /* Network is unreachable. */
+# define ENETRESET 129 /* Network dropped connection because
+ of reset. */
+# define ECONNABORTED 130 /* Software caused connection abort. */
+# define ECONNRESET 131 /* Connection reset by peer. */
+# define ENOBUFS 132 /* No buffer space available. */
+# define EISCONN 133 /* Socket is already connected. */
+# define ENOTCONN 134 /* Socket is not connected. */
+/* XENIX has 135 - 142. */
+# define ESHUTDOWN 143 /* Can't send after socket shutdown. */
+# define ETOOMANYREFS 144 /* Too many references: can't splice. */
+# define ETIMEDOUT 145 /* Connection timed out. */
+# define ECONNREFUSED 146 /* Connection refused. */
+# define EHOSTDOWN 147 /* Host is down. */
+# define EHOSTUNREACH 148 /* No route to host. */
+# define EALREADY 149 /* operation already in progress. */
+# define EINPROGRESS 150 /* operation now in progress. */
+
+/* SUN Network File System. */
+# define ESTALE 151 /* Stale NFS file handle. */
+
+#endif
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/signum.h b/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/signum.h
new file mode 100644
index 000000000..a2659530b
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/signum.h
@@ -0,0 +1,76 @@
+/* Signal number definitions. Solaris 2 version.
+ Copyright (C) 1994, 1996, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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. */
+#ifdef __USE_UNIX98
+# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */
+#endif
+
+
+/* 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/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/sigstack.h b/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/sigstack.h
new file mode 100644
index 000000000..753caac8a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/sigstack.h
@@ -0,0 +1,55 @@
+/* sigstack, sigaltstack definitions.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SIGNAL_H
+# error "Never include this file directly. Use <signal.h> instead"
+#endif
+
+
+/* Structure describing a signal stack (obsolete). */
+struct sigstack
+ {
+ __ptr_t ss_sp; /* Signal stack pointer. */
+ int ss_onstack; /* Nonzero if executing on this stack. */
+ };
+
+
+/* Possible values for `ss_flags.'. */
+enum
+{
+ SS_ONSTACK = 1,
+#define SS_ONSTACK SS_ONSTACK
+ SS_DISABLE
+#define SS_DISABLE SS_DISABLE
+};
+
+/* Minimum stack size for a signal handler. */
+#define MINSIGSTKSZ 2048
+
+/* System default stack size. */
+#define SIGSTKSZ 8192
+
+
+/* Alternate, preferred interface. */
+typedef struct sigaltstack
+ {
+ __ptr_t ss_sp;
+ int ss_flags;
+ size_t ss_size;
+ } stack_t;
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/stat.h b/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/stat.h
new file mode 100644
index 000000000..22c1c1f85
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/stat.h
@@ -0,0 +1,119 @@
+/* Copyright (C) 1993, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_STAT_H
+# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* Length of array allocated for file system type name. */
+#define _ST_FSTYPSZ 16
+
+
+/* Structure describing file characteristics. */
+struct stat
+ {
+ __dev_t st_dev;
+ long int st_filler1[3];
+ __ino_t st_ino; /* File serial number. */
+ __mode_t st_mode; /* File mode. */
+ __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.*/
+ __dev_t st_rdev; /* Device number, if device. */
+ long int 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 int 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;
+
+ __blksize_t st_blksize; /* Optimal block size for I/O. */
+#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
+
+ __blkcnt_t st_blocks; /* Number of 512-byte blocks allocated. */
+ char st_fstype[_ST_FSTYPSZ];
+ long int st_filler4[8];
+ };
+
+#ifdef __USE_LARGEFILE64
+/* struct stat64 has the shape as stat */
+struct stat64
+ {
+ __dev_t st_dev; /* Device */
+ long int st_filler1[2];
+ __ino64_t st_ino; /* File serial number */
+ __mode_t st_mode; /* File mode */
+ __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.*/
+ __dev_t st_rdev; /* Device number, if device */
+ long int st_filler2;
+
+ __off64_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;
+
+ __blksize_t st_blksize;
+ __blkcnt64_t st_blocks;
+ char st_fstype[_ST_FSTYPSZ];
+ long int st_filler3[8];
+};
+#endif
+
+
+/* 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. */
+
+/* POSIX.1b objects. */
+#define __S_TYPEISMQ(buf) (0)
+#define __S_TYPEISSEM(buf) (0)
+#define __S_TYPEISSHM(buf) (0)
+
+/* 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. */
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/types.h b/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/types.h
new file mode 100644
index 000000000..a9ce216c6
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/bits/types.h
@@ -0,0 +1,120 @@
+/* Copyright (C) 1991,92,1994-1999,2000,2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/*
+ * Never include this file directly; use <sys/types.h> instead.
+ */
+
+#ifndef _BITS_TYPES_H
+#define _BITS_TYPES_H 1
+
+#include <features.h>
+
+#define __need_size_t
+#include <stddef.h>
+
+/* Convenience types. */
+typedef unsigned char __u_char;
+typedef unsigned short __u_short;
+typedef unsigned int __u_int;
+typedef unsigned long __u_long;
+#ifdef __GNUC__
+typedef unsigned long long int __u_quad_t;
+typedef long long int __quad_t;
+#else
+typedef struct
+{
+ long __val[2];
+} __quad_t;
+typedef struct
+{
+ __u_long __val[2];
+} __u_quad_t;
+#endif
+typedef signed char __int8_t;
+typedef unsigned char __uint8_t;
+typedef signed short int __int16_t;
+typedef unsigned short int __uint16_t;
+typedef signed int __int32_t;
+typedef unsigned int __uint32_t;
+#ifdef __GNUC__
+typedef signed long long int __int64_t;
+typedef unsigned long long int __uint64_t;
+#endif
+typedef __quad_t *__qaddr_t;
+typedef unsigned long int __dev_t; /* Type of device numbers. */
+typedef long int __uid_t; /* Type of user identifications. */
+typedef long int __gid_t; /* Type of group identifications. */
+typedef unsigned long int __ino_t; /* Type of file serial numbers. */
+typedef unsigned long int __mode_t; /* Type of file attribute bitmasks. */
+typedef unsigned long int __nlink_t; /* Type of file link counts. */
+typedef long int __off_t; /* Type of file sizes and offsets. */
+typedef __quad_t __loff_t; /* Type of file sizes and offsets. */
+typedef long int __pid_t; /* Type of process identifications. */
+typedef int __ssize_t; /* Type of a byte count, or error. */
+typedef __u_quad_t __fsid_t; /* Type of file system IDs. */
+typedef long int __clock_t; /* Type of CPU usage counts. */
+typedef long int __rlim_t; /* Type for resource measurement. */
+typedef __quad_t __rlim64_t; /* Type for resource measurement (LFS). */
+typedef __quad_t __ino64_t; /* Type for file serial numbers. */
+typedef __loff_t __off64_t; /* Type of file izes and offsets. */
+typedef unsigned int __id_t; /* General type for IDs. */
+
+/* Everythin' else. */
+typedef long int __daddr_t; /* The type of a disk address. */
+typedef char *__caddr_t;
+typedef long int __time_t;
+typedef unsigned int __useconds_t;
+typedef int __suseconds_t;
+typedef long int __swblk_t; /* Type of a swap block maybe? */
+typedef int __key_t; /* Type of an IPC key */
+
+/* fd_set for select. */
+
+/* Number of descriptors that can fit in an `fd_set'. */
+#define __FD_SETSIZE 1024
+
+
+/* Type to represent block size. */
+typedef long int __blksize_t;
+
+/* Types from the Large File Support interface. */
+
+/* Type to count number os disk blocks. */
+typedef long int __blkcnt_t;
+typedef __quad_t __blkcnt64_t;
+
+/* Type to count file system blocks. */
+typedef unsigned int __fsblkcnt_t;
+typedef __u_quad_t __fsblkcnt64_t;
+
+/* Type to count file system inodes. */
+typedef unsigned long int __fsfilcnt_t;
+typedef __u_quad_t __fsfilcnt64_t;
+
+/* Used in XTI. */
+typedef int __t_scalar_t;
+typedef unsigned int __t_uscalar_t;
+
+/* Duplicates info from stdint.h but this is used in unistd.h. */
+typedef long int __intptr_t;
+
+/* Duplicate info from sys/socket.h. */
+typedef unsigned int __socklen_t;
+
+#endif /* bits/types.h */
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/fsync.S b/ports/sysdeps/unix/sysv/sysv4/solaris2/fsync.S
new file mode 100644
index 000000000..493926a98
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/fsync.S
@@ -0,0 +1,30 @@
+/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/sysv/sysv4/solaris2/getdents.c b/ports/sysdeps/unix/sysv/sysv4/solaris2/getdents.c
new file mode 100644
index 000000000..ab782ffaa
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/getdents.c
@@ -0,0 +1,114 @@
+/* Copyright (C) 1993,95,96,97,98, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <alloca.h>
+#include <dirent.h>
+#include <stddef.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <sys/types.h>
+
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+
+
+extern int __getdents (int fd, char *buf, size_t nbytes);
+
+/* For Solaris we need a special version of this file since the
+ definition of `struct dirent' is not the same for the kernel and
+ the libc. There is one additional field which might be introduced
+ in the kernel structure in the future.
+
+ He is the system definition of `struct dirent' as of 2.6: */
+
+struct kernel_dirent
+ {
+ ino_t d_ino;
+ off_t d_off;
+ unsigned short int d_reclen;
+ char d_name[256];
+ };
+
+#ifdef GETDENTS64
+#define __getdirentries __getdirentries64
+#define dirent dirent64
+#endif
+
+/* The problem here is that we cannot simply read the next NBYTES
+ bytes. We need to take the additional field into account. We use
+ some heuristic. Assuming the directory contains names with 14
+ characters on average we can compute an estimate number of entries
+ which fit in the buffer. Taking this number allows us to specify a
+ correct number of bytes to read. If we should be wrong, we can reset
+ the file descriptor. */
+ssize_t
+__getdirentries (int fd, char *buf, size_t nbytes, off_t *basep)
+{
+ off_t base = __lseek (fd, (off_t) 0, SEEK_CUR);
+ off_t last_offset = base;
+ size_t red_nbytes;
+ struct kernel_dirent *skdp, *kdp;
+ struct dirent *dp;
+ int retval;
+ const size_t size_diff = (offsetof (struct dirent, d_name)
+ - offsetof (struct kernel_dirent, d_name));
+
+ red_nbytes = nbytes - ((nbytes / (offsetof (struct dirent, d_name) + 14))
+ * size_diff);
+
+ dp = (struct dirent *) buf;
+ skdp = kdp = __alloca (red_nbytes);
+
+ retval = __getdents (fd, (char *) kdp, red_nbytes);
+
+ while ((char *) kdp < (char *) skdp + retval)
+ {
+ const size_t alignment = __alignof__ (struct dirent);
+ /* Since kdp->d_reclen is already aligned for the kernel structure
+ this may compute a value that is bigger than necessary. */
+ size_t new_reclen = ((kdp->d_reclen + size_diff + alignment - 1)
+ & ~(alignment - 1));
+ if ((char *) dp + new_reclen > buf + nbytes)
+ {
+ /* Our heuristic failed. We read too many entries. Reset
+ the stream. */
+ __lseek (fd, last_offset, SEEK_SET);
+ break;
+ }
+
+ last_offset = kdp->d_off;
+ dp->d_ino = kdp->d_ino;
+ dp->d_off = kdp->d_off;
+ dp->d_reclen = new_reclen;
+ dp->d_type = DT_UNKNOWN;
+ memcpy (dp->d_name, kdp->d_name,
+ kdp->d_reclen - offsetof (struct kernel_dirent, d_name));
+
+ dp = (struct dirent *) ((char *) dp + new_reclen);
+ kdp = (struct kernel_dirent *) (((char *) kdp) + kdp->d_reclen);
+ }
+
+ if (basep)
+ *basep = base;
+
+ return (char *) dp - buf;
+}
+
+#ifndef GETDENTS64
+weak_alias (__getdirentries, getdirentries)
+#endif
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/sigpending.c b/ports/sysdeps/unix/sysv/sysv4/solaris2/sigpending.c
new file mode 100644
index 000000000..2723d79f7
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/sigpending.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <stddef.h>
+#include <signal.h>
+
+extern int __syscall_sigpending (int subcode, sigset_t *set);
+
+
+/* Store in SET all signals that are blocked and pending. */
+int
+sigpending (sigset_t *set)
+{
+ if (set == NULL)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return __syscall_sigpending (1, set);
+}
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/sigstack.c b/ports/sysdeps/unix/sysv/sysv4/solaris2/sigstack.c
new file mode 100644
index 000000000..5aa73c8dc
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/sigstack.c
@@ -0,0 +1,3 @@
+/* We can reuse the Linux implementation with some tricks. */
+#define __NR_sigaltstack 1
+#include <sysdeps/unix/sysv/linux/sigstack.c>
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/sigwaitinfo.c b/ports/sysdeps/unix/sysv/sysv4/solaris2/sigwaitinfo.c
new file mode 100644
index 000000000..f24664002
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/sigwaitinfo.c
@@ -0,0 +1,2 @@
+/* We can reuse the Linux implementation. */
+#include <sysdeps/unix/sysv/linux/sigwaitinfo.c>
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile
new file mode 100644
index 000000000..1c17ea168
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/Makefile
@@ -0,0 +1,11 @@
+# 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
+
+ifeq ($(subdir),crypt)
+
+crypt := crypt.solar
+
+endif
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/bits/sigcontext.h b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/bits/sigcontext.h
new file mode 100644
index 000000000..7c4bca604
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/bits/sigcontext.h
@@ -0,0 +1,34 @@
+/* Structure describing state saved while handling a signal. Sparc version.
+ Copyright (C) 1992, 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SIGNAL_H
+# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
+#endif
+
+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/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/errlist.c b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/errlist.c
new file mode 100644
index 000000000..3c75e3f01
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/errlist.c
@@ -0,0 +1,185 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stddef.h>
+#include <libintl.h>
+
+
+/* This is a list of all known `errno' codes. */
+
+
+const int _sys_nerr = 152;
+
+const char *const _sys_errlist[] =
+{
+ N_("Error 0"),
+ N_("Not owner"),
+ N_("No such file or directory"),
+ N_("No such process"),
+ N_("Interrupted system call"),
+ N_("I/O error"),
+ N_("No such device or address"),
+ N_("Arg list too long"),
+ N_("Exec format error"),
+ N_("Bad file number"),
+ N_("No child processes"),
+ N_("Resource temporarily unavailable"),
+ N_("Not enough space"),
+ N_("Permission denied"),
+ N_("Bad address"),
+ N_("Block device required"),
+ N_("Device busy"),
+ N_("File exists"),
+ N_("Cross-device link"),
+ N_("No such device"),
+ N_("Not a directory"),
+ N_("Is a directory"),
+ N_("Invalid argument"),
+ N_("File table overflow"),
+ N_("Too many open files"),
+ N_("Inappropriate ioctl for device"),
+ N_("Text file busy"),
+ N_("File too large"),
+ N_("No space left on device"),
+ N_("Illegal seek"),
+ N_("Read-only file system"),
+ N_("Too many links"),
+ N_("Broken pipe"),
+ N_("Argument out of domain"),
+ N_("Result too large"),
+ N_("No message of desired type"),
+ N_("Identifier removed"),
+ N_("Channel number out of range"),
+ N_("Level 2 not synchronized"),
+ N_("Level 3 halted"),
+ N_("Level 3 reset"),
+ N_("Link number out of range"),
+ N_("Protocol driver not attached"),
+ N_("No CSI structure available"),
+ N_("Level 2 halted"),
+ N_("Deadlock situation detected/avoided"),
+ N_("No record locks available"),
+ N_("Operation canceled"),
+ N_("Operation not supported"),
+ N_("Disc quota exceeded"),
+ N_("Bad exchange descriptor"),
+ N_("Bad request descriptor"),
+ N_("Message tables full"),
+ N_("Anode table overflow"),
+ N_("Bad request code"),
+ N_("Invalid slot"),
+ N_("File locking deadlock"),
+ N_("Bad font file format"),
+ N_("Error 58"),
+ N_("Error 59"),
+ N_("Not a stream device"),
+ N_("No data available"),
+ N_("Timer expired"),
+ N_("Out of stream resources"),
+ N_("Machine is not on the network"),
+ N_("Package not installed"),
+ N_("Object is remote"),
+ N_("Link has been severed"),
+ N_("Advertise error"),
+ N_("Srmount error"),
+ N_("Communication error on send"),
+ N_("Protocol error"),
+ N_("Error 72"),
+ N_("Error 73"),
+ N_("Multihop attempted"),
+ N_("Error 75"),
+ N_("Error 76"),
+ N_("Not a data message"),
+ N_("File name too long"),
+ N_("Value too large for defined data type"),
+ N_("Name not unique on network"),
+ N_("File descriptor in bad state"),
+ N_("Remote address changed"),
+ N_("Can not access a needed shared library"),
+ N_("Accessing a corrupted shared library"),
+ N_(".lib section in a.out corrupted"),
+ N_("Attempting to link in more shared libraries than system limit"),
+ N_("Can not exec a shared library directly"),
+ N_("Illegal byte sequence"),
+ N_("Operation not applicable"),
+ N_("Number of symbolic links encountered during path name traversal exceeds MAXSYMLINKS"),
+ N_("Error 91"),
+ N_("Error 92"),
+ N_("Directory not empty"),
+ N_("Too many users"),
+ N_("Socket operation on non-socket"),
+ N_("Destination address required"),
+ N_("Message too long"),
+ N_("Protocol wrong type for socket"),
+ N_("Option not supported by protocol"),
+ N_("Error 100"),
+ N_("Error 101"),
+ N_("Error 102"),
+ N_("Error 103"),
+ N_("Error 104"),
+ N_("Error 105"),
+ N_("Error 106"),
+ N_("Error 107"),
+ N_("Error 108"),
+ N_("Error 109"),
+ N_("Error 110"),
+ N_("Error 111"),
+ N_("Error 112"),
+ N_("Error 113"),
+ N_("Error 114"),
+ N_("Error 115"),
+ N_("Error 116"),
+ N_("Error 117"),
+ N_("Error 118"),
+ N_("Error 119"),
+ N_("Protocol not supported"),
+ N_("Socket type not supported"),
+ N_("Operation not supported on transport endpoint"),
+ N_("Protocol family not supported"),
+ N_("Address family not supported by protocol family"),
+ N_("Address already in use"),
+ N_("Cannot assign requested address"),
+ N_("Network is down"),
+ N_("Network is unreachable"),
+ N_("Network dropped connection because of reset"),
+ N_("Software caused connection abort"),
+ N_("Connection reset by peer"),
+ N_("No buffer space available"),
+ N_("Transport endpoint is already connected"),
+ N_("Transport endpoint is not connected"),
+ N_("Structure needs cleaning"),
+ N_("Error 136"),
+ N_("Not a name file"),
+ N_("Not available"),
+ N_("Is a name file"),
+ N_("Remote I/O error"),
+ N_("Reserved for future use"),
+ N_("Error 142"),
+ N_("Cannot send after socket shutdown"),
+ N_("Too many references: cannot splice"),
+ N_("Connection timed out"),
+ N_("Connection refused"),
+ N_("Host is down"),
+ N_("No route to host"),
+ N_("Operation already in progress"),
+ N_("Operation now in progress"),
+ N_("Stale NFS file handle")
+};
+
+weak_alias (_sys_errlist, sys_errlist)
+weak_alias (_sys_nerr, sys_nerr)
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sparc32/syscall.S b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sparc32/syscall.S
new file mode 100644
index 000000000..b9f2996e3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sparc32/syscall.S
@@ -0,0 +1,2 @@
+/* Bets are that the Linux code works... */
+#include <sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S>
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/start.c b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/start.c
new file mode 100644
index 000000000..afdfaaa2e
--- /dev/null
+++ b/ports/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/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sys/trap.h b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sys/trap.h
new file mode 100644
index 000000000..39d264597
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sys/trap.h
@@ -0,0 +1,36 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_TRAP_H
+#define _SYS_TRAP_H 1
+
+/* Solaris2 software traps. */
+
+#define ST_OSYSCALL 0x00
+#define ST_BREAKPOINT 0x01
+#define ST_DIV0 0x02
+#define ST_FLUSH_WINDOWS 0x03
+#define ST_CLEAN_WINDOWS 0x04
+#define ST_RANGE_CHECK 0x05
+#define ST_FIX_ALIGN 0x06
+#define ST_INT_OVERFLOW 0x07
+#define ST_SYSCALL 0x08
+
+/* Traps 0x10 through 0x1f are allotted to the user. */
+
+#endif /* sys/trap.h */
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sys/ucontext.h b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sys/ucontext.h
new file mode 100644
index 000000000..6e9f69067
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sys/ucontext.h
@@ -0,0 +1,42 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+#include <signal.h>
+#include <sys/types.h>
+
+typedef struct
+{
+ long int mc_filler[78];
+} mcontext_t;
+
+struct ucontext
+{
+ unsigned long int uc_flags;
+ struct ucontext *uc_link;
+ sigset_t uc_sigmask;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ long int uc_filler[23];
+};
+typedef struct ucontext ucontext_t;
+
+#endif /* sys/ucontext.h */
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/syscalls.list b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/syscalls.list
new file mode 100644
index 000000000..d96fbba7e
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/syscalls.list
@@ -0,0 +1,3 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+sys-sig - context 2 __context_syscall
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.S b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.S
new file mode 100644
index 000000000..2ac767c98
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.S
@@ -0,0 +1,47 @@
+/* Copyright (C) 1993, 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#define _ERRNO_H
+#include <bits/errno.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/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h
new file mode 100644
index 000000000..9a0db6afe
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h
@@ -0,0 +1,56 @@
+/* Copyright (C) 1993,1994,1995,1997,1998,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Solaris 2 does not precede the asm names of C symbols with a `_'. */
+#ifndef NO_UNDERSCORES
+#define NO_UNDERSCORES
+#endif
+
+#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
+
+#define LOC(name) .L##name
+
+#endif /* __ASSEMBLER__ */
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/sys/param.h b/ports/sysdeps/unix/sysv/sysv4/solaris2/sys/param.h
new file mode 100644
index 000000000..bbd7b06a1
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/sys/param.h
@@ -0,0 +1,59 @@
+/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_PARAM_H
+#define _SYS_PARAM_H 1
+
+#include <limits.h>
+
+/* BSD names for some <limits.h> values. */
+
+#define NBBY CHAR_BIT
+#ifndef NGROUPS
+# define NGROUPS NGROUPS_MAX
+#endif
+#define MAXSYMLINKS 5
+#define CANBSIZ MAX_CANON
+#define NCARGS ARG_MAX
+#define MAXPATHLEN PATH_MAX
+#define NOFILE OPEN_MAX
+
+
+#include <sys/types.h>
+
+/* 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))
+
+/* Unit of `st_blocks'. */
+#define DEV_BSIZE 512
+
+#endif /* sys/param.h */
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/sys/syscall.h b/ports/sysdeps/unix/sysv/sysv4/solaris2/sys/syscall.h
new file mode 100644
index 000000000..15c43a3c3
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/sys/syscall.h
@@ -0,0 +1,245 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYSCALL_H
+#define _SYSCALL_H 1
+
+/* Solaris 2 syscall numbers */
+
+#define SYS_syscall 0
+#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_wait 7
+#define SYS_creat 8
+#define SYS_link 9
+#define SYS_unlink 10
+#define SYS_exec 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_stat 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_fstat 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_statfs 35
+#define SYS_sync 36
+#define SYS_kill 37
+#define SYS_fstatfs 38
+#define SYS_pgrpsys 39
+#define SYS_xenix 40
+#define SYS_dup 41
+#define SYS_pipe 42
+#define SYS_times 43
+#define SYS_profil 44
+#define SYS_plock 45
+#define SYS_setgid 46
+#define SYS_getgid 47
+#define SYS_signal 48
+#define SYS_msgsys 49
+#define SYS_syssun 50
+#define SYS_sysi86 50
+#define SYS_sysppc 50
+#define SYS_acct 51
+#define SYS_shmsys 52
+#define SYS_semsys 53
+#define SYS_ioctl 54
+#define SYS_uadmin 55
+#define SYS_utssys 57
+#define SYS_fdsync 58
+#define SYS_execve 59
+#define SYS_umask 60
+#define SYS_chroot 61
+#define SYS_fcntl 62
+#define SYS_ulimit 63
+#define SYS_rmdir 79
+#define SYS_mkdir 80
+#define SYS_getdents 81
+#define SYS_sysfs 84
+#define SYS_getmsg 85
+#define SYS_putmsg 86
+#define SYS_poll 87
+#define SYS_lstat 88
+#define SYS_symlink 89
+#define SYS_readlink 90
+#define SYS_setgroups 91
+#define SYS_getgroups 92
+#define SYS_fchmod 93
+#define SYS_fchown 94
+#define SYS_sigprocmask 95
+#define SYS_sigsuspend 96
+#define SYS_sigaltstack 97
+#define SYS_sigaction 98
+#define SYS_sigpending 99
+#define SYS_context 100
+#define SYS_evsys 101
+#define SYS_evtrapret 102
+#define SYS_statvfs 103
+#define SYS_fstatvfs 104
+#define SYS_nfssys 106
+#define SYS_waitsys 107
+#define SYS_sigsendsys 108
+#define SYS_hrtsys 109
+#define SYS_acancel 110
+#define SYS_async 111
+#define SYS_priocntlsys 112
+#define SYS_pathconf 113
+#define SYS_mincore 114
+#define SYS_mmap 115
+#define SYS_mprotect 116
+#define SYS_munmap 117
+#define SYS_fpathconf 118
+#define SYS_vfork 119
+#define SYS_fchdir 120
+#define SYS_readv 121
+#define SYS_writev 122
+#define SYS_xstat 123
+#define SYS_lxstat 124
+#define SYS_fxstat 125
+#define SYS_xmknod 126
+#define SYS_clocal 127
+#define SYS_setrlimit 128
+#define SYS_getrlimit 129
+#define SYS_lchown 130
+#define SYS_memcntl 131
+#define SYS_getpmsg 132
+#define SYS_putpmsg 133
+#define SYS_rename 134
+#define SYS_uname 135
+#define SYS_setegid 136
+#define SYS_sysconfig 137
+#define SYS_adjtime 138
+#define SYS_systeminfo 139
+#define SYS_seteuid 141
+#define SYS_vtrace 142
+#define SYS_fork1 143
+#define SYS_sigtimedwait 144
+#define SYS_lwp_info 145
+#define SYS_yield 146
+#define SYS_lwp_sema_wait 147
+#define SYS_lwp_sema_post 148
+#define SYS_lwp_sema_trywait 149
+#define SYS_modctl 152
+#define SYS_fchroot 153
+#define SYS_utimes 154
+#define SYS_vhangup 155
+#define SYS_gettimeofday 156
+#define SYS_getitimer 157
+#define SYS_setitimer 158
+#define SYS_lwp_create 159
+#define SYS_lwp_exit 160
+#define SYS_lwp_suspend 161
+#define SYS_lwp_continue 162
+#define SYS_lwp_kill 163
+#define SYS_lwp_self 164
+#define SYS_lwp_setprivate 165
+#define SYS_lwp_getprivate 166
+#define SYS_lwp_wait 167
+#define SYS_lwp_mutex_unlock 168
+#define SYS_lwp_mutex_lock 169
+#define SYS_lwp_cond_wait 170
+#define SYS_lwp_cond_signal 171
+#define SYS_lwp_cond_broadcast 172
+#define SYS_pread 173
+#define SYS_pwrite 174
+#define SYS_llseek 175
+#define SYS_inst_sync 176
+#define SYS_kaio 178
+#define SYS_tsolsys 184
+#define SYS_acl 185
+#define SYS_auditsys 186
+#define SYS_processor_bind 187
+#define SYS_processor_info 188
+#define SYS_p_online 189
+#define SYS_sigqueue 190
+#define SYS_clock_gettime 191
+#define SYS_clock_settime 192
+#define SYS_clock_getres 193
+#define SYS_timer_create 194
+#define SYS_timer_delete 195
+#define SYS_timer_settime 196
+#define SYS_timer_gettime 197
+#define SYS_timer_getoverrun 198
+#define SYS_nanosleep 199
+#define SYS_facl 200
+#define SYS_door 201
+#define SYS_setreuid 202
+#define SYS_setregid 203
+#define SYS_install_utrap 204
+#define SYS_signotify 205
+#define SYS_schedctl 206
+#define SYS_pset 207
+#define SYS_resolvepath 209
+#define SYS_signotifywait 210
+#define SYS_lwp_sigredirect 211
+#define SYS_lwp_alarm 212
+#define SYS_getdents64 213
+#define SYS_mmap64 214
+#define SYS_stat64 215
+#define SYS_lstat64 216
+#define SYS_fstat64 217
+#define SYS_statvfs64 218
+#define SYS_fstatvfs64 219
+#define SYS_setrlimit64 220
+#define SYS_getrlimit64 221
+#define SYS_pread64 222
+#define SYS_pwrite64 223
+#define SYS_creat64 224
+#define SYS_open64 225
+#define SYS_rpcsys 226
+#define SYS_so_socket 230
+#define SYS_so_socketpair 231
+#define SYS_bind 232
+#define SYS_listen 233
+#define SYS_accept 234
+#define SYS_connect 235
+#define SYS_shutdown 236
+#define SYS_recv 237
+#define SYS_recvfrom 238
+#define SYS_recvmsg 239
+#define SYS_send 240
+#define SYS_sendmsg 241
+#define SYS_sendto 242
+#define SYS_getpeername 243
+#define SYS_getsockname 244
+#define SYS_getsockopt 245
+#define SYS_setsockopt 246
+#define SYS_sockconfig 247
+#define SYS_ntp_gettime 248
+#define SYS_ntp_adjtime 249
+
+#endif /* sys/syscall.h */
diff --git a/ports/sysdeps/unix/sysv/sysv4/solaris2/syscalls.list b/ports/sysdeps/unix/sysv/sysv4/solaris2/syscalls.list
new file mode 100644
index 000000000..092d869ef
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/solaris2/syscalls.list
@@ -0,0 +1,7 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+sigaction - sigaction 3 __sigaction sigaction
+sigaltstack - sigaltstack 2 sigaltstack
+sigpending - sigpending 2 __syscall_sigpending
+sigqueue - sigqueue 3 __sigqueue sigqueue
+sigtimedwait - sigtimedwait 3 __sigtimedwait sigtime
diff --git a/ports/sysdeps/unix/sysv/sysv4/syscalls.list b/ports/sysdeps/unix/sysv/sysv4/syscalls.list
new file mode 100644
index 000000000..7b75d5524
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/syscalls.list
@@ -0,0 +1,7 @@
+# File name Caller Syscall name # args Strong name Weak names
+
+pgrpsys - pgrpsys 3 __pgrpsys
+sigprocmask - sigprocmask 3 __sigprocmask sigprocmask
+sysconfig - sysconfig 1 __sysconfig
+sysinfo - systeminfo 3 __sysinfo
+__waitid waitpid waitsys 3 __waitid
diff --git a/ports/sysdeps/unix/sysv/sysv4/sysconf.c b/ports/sysdeps/unix/sysv/sysv4/sysconf.c
new file mode 100644
index 000000000..bfe7823c4
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/sysconf.c
@@ -0,0 +1,366 @@
+/* Copyright (C) 1993,1995,1996,1997,2002,2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <limits.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <time.h>
+#include <sysconfig.h>
+
+extern int __sysconfig (int);
+
+/* Get the value of the system variable NAME. */
+long int
+__sysconf (name)
+ int name;
+{
+ switch (name)
+ {
+ default:
+ __set_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_REALTIME_SIGNALS:
+#ifdef _POSIX_REALTIME_SIGNALS
+ return 1;
+#else
+ return -1;
+#endif
+
+ case _SC_PRIORITY_SCHEDULING:
+#ifdef _POSIX_PRIORITY_SCHEDULING
+ return 1;
+#else
+ return -1;
+#endif
+
+ case _SC_TIMERS:
+#ifdef _POSIX_TIMERS
+ return 1;
+#else
+ return -1;
+#endif
+
+ case _SC_ASYNCHRONOUS_IO:
+#ifdef _POSIX_ASYNCHRONOUS_IO
+ return 1;
+#else
+ return -1;
+#endif
+
+ case _SC_PRIORITIZED_IO:
+#ifdef _POSIX_PRIORITIZED_IO
+ return 1;
+#else
+ return -1;
+#endif
+
+ case _SC_SYNCHRONIZED_IO:
+#ifdef _POSIX_SYNCHRONIZED_IO
+ return 1;
+#else
+ return -1;
+#endif
+
+ case _SC_FSYNC:
+#ifdef _POSIX_FSYNC
+ return 1;
+#else
+ return -1;
+#endif
+
+ case _SC_MAPPED_FILES:
+#ifdef _POSIX_MAPPED_FILES
+ return 1;
+#else
+ return -1;
+#endif
+
+ case _SC_MEMLOCK:
+#ifdef _POSIX_MEMLOCK
+ return 1;
+#else
+ return -1;
+#endif
+
+ case _SC_MEMLOCK_RANGE:
+#ifdef _POSIX_MEMLOCK_RANGE
+ return 1;
+#else
+ return -1;
+#endif
+
+ case _SC_MEMORY_PROTECTION:
+#ifdef _POSIX_MEMORY_PROTECTION
+ return 1;
+#else
+ return -1;
+#endif
+
+ case _SC_MESSAGE_PASSING:
+#ifdef _POSIX_MESSAGE_PASSING
+ return 1;
+#else
+ return -1;
+#endif
+
+ case _SC_SEMAPHORES:
+#ifdef _POSIX_SEMAPHORES
+ return 1;
+#else
+ return -1;
+#endif
+
+ case _SC_SHARED_MEMORY_OBJECTS:
+#ifdef _POSIX_SHARED_MEMORY_OBJECTS
+ return 1;
+#else
+ return -1;
+#endif
+
+ case _SC_VERSION:
+ return _POSIX_VERSION;
+
+ case _SC_PAGESIZE:
+ return __sysconfig (_CONFIG_PAGESIZE);
+
+ case _SC_AIO_LISTIO_MAX:
+#ifdef AIO_LISTIO_MAX
+ return AIO_LISTIO_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_AIO_MAX:
+#ifdef AIO_MAX
+ return AIO_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_AIO_PRIO_DELTA_MAX:
+#ifdef AIO_PRIO_DELTA_MAX
+ return AIO_PRIO_DELTA_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_DELAYTIMER_MAX:
+#ifdef DELAYTIMER_MAX
+ return DELAYTIMER_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_MQ_OPEN_MAX:
+#ifdef MQ_OPEN_MAX
+ return MQ_OPEN_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_MQ_PRIO_MAX:
+#ifdef MQ_PRIO_MAX
+ return MQ_PRIO_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_RTSIG_MAX:
+#ifdef RTSIG_MAX
+ return RTSIG_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_SEM_NSEMS_MAX:
+#ifdef SEM_NSEMS_MAX
+ return SEM_NSEMS_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_SEM_VALUE_MAX:
+#ifdef SEM_VALUE_MAX
+ return SEM_VALUE_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_SIGQUEUE_MAX:
+#ifdef SIGQUEUE_MAX
+ return SIGQUEUE_MAX;
+#else
+ return -1;
+#endif
+
+ case _SC_TIMER_MAX:
+#ifdef TIMER_MAX
+ return TIMER_MAX;
+#else
+ return -1;
+#endif
+
+ 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_CHARCLASS_NAME_MAX:
+#ifdef CHARCLASS_NAME_MAX
+ return CHARCLASS_NAME_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)
+libc_hidden_def (__sysconf)
diff --git a/ports/sysdeps/unix/sysv/sysv4/sysconfig.h b/ports/sysdeps/unix/sysv/sysv4/sysconfig.h
new file mode 100644
index 000000000..b51a3649a
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/sysconfig.h
@@ -0,0 +1,28 @@
+/* `__sysconfig' NAME values.
+ Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/unix/sysv/sysv4/system.c b/ports/sysdeps/unix/sysv/sysv4/system.c
new file mode 100644
index 000000000..fbfe43f19
--- /dev/null
+++ b/ports/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/ports/sysdeps/unix/sysv/sysv4/waitpid.c b/ports/sysdeps/unix/sysv/sysv4/waitpid.c
new file mode 100644
index 000000000..23f9ceb02
--- /dev/null
+++ b/ports/sysdeps/unix/sysv/sysv4/waitpid.c
@@ -0,0 +1,120 @@
+/* Copyright (C) 1993,94,95,96,97,2002,2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Brendan Kehoe (brendan@zen.org).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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 (__pid_t pid);
+extern int __waitid (__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
+__libc_waitpid (__pid_t pid, int *stat_loc, 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 (__libc_waitpid, __waitpid)
+weak_alias (__libc_waitpid, waitpid)
+libc_hidden_weak (__waitpid)
diff --git a/ports/sysdeps/vax/DEFS.h b/ports/sysdeps/vax/DEFS.h
new file mode 100644
index 000000000..50f8b7e13
--- /dev/null
+++ b/ports/sysdeps/vax/DEFS.h
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ * 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/ports/sysdeps/vax/Makefile b/ports/sysdeps/vax/Makefile
new file mode 100644
index 000000000..909fc29f3
--- /dev/null
+++ b/ports/sysdeps/vax/Makefile
@@ -0,0 +1,32 @@
+# Copyright (C) 1991, 1994, 1997 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 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/ports/sysdeps/vax/__longjmp.c b/ports/sysdeps/vax/__longjmp.c
new file mode 100644
index 000000000..8ffb8cd4b
--- /dev/null
+++ b/ports/sysdeps/vax/__longjmp.c
@@ -0,0 +1,129 @@
+/* Copyright (C) 1991, 1992, 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+
+ Derived from @(#)_setjmp.s 5.7 (Berkeley) 6/27/88,
+ 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.
+ 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.*/
+
+#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
+__longjmp (env, val)
+ const __jmp_buf env;
+ 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/ports/sysdeps/vax/add_n.s b/ports/sysdeps/vax/add_n.s
new file mode 100644
index 000000000..265a8c788
--- /dev/null
+++ b/ports/sysdeps/vax/add_n.s
@@ -0,0 +1,48 @@
+# VAX __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 Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 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 Lesser General Public
+# License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+
+# INPUT PARAMETERS
+# res_ptr (sp + 4)
+# s1_ptr (sp + 8)
+# s2_ptr (sp + 12)
+# size (sp + 16)
+
+.text
+ .align 1
+.globl ___mpn_add_n
+___mpn_add_n:
+ .word 0x0
+ movl 16(ap),r0
+ movl 12(ap),r1
+ movl 8(ap),r2
+ movl 4(ap),r3
+ subl2 r4,r4
+
+Loop:
+ movl (r2)+,r4
+ adwc (r1)+,r4
+ movl r4,(r3)+
+ jsobgtr r0,Loop
+
+ adwc r0,r0
+ ret
diff --git a/ports/sysdeps/vax/addmul_1.s b/ports/sysdeps/vax/addmul_1.s
new file mode 100644
index 000000000..c6d657dcf
--- /dev/null
+++ b/ports/sysdeps/vax/addmul_1.s
@@ -0,0 +1,126 @@
+# VAX __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 Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 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 Lesser General Public
+# License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+
+# INPUT PARAMETERS
+# res_ptr (sp + 4)
+# s1_ptr (sp + 8)
+# size (sp + 12)
+# s2_limb (sp + 16)
+
+.text
+ .align 1
+.globl ___mpn_addmul_1
+___mpn_addmul_1:
+ .word 0xfc0
+ movl 12(ap),r4
+ movl 8(ap),r8
+ movl 4(ap),r9
+ movl 16(ap),r6
+ jlss s2_big
+
+ clrl r3
+ incl r4
+ ashl $-1,r4,r7
+ jlbc r4,L1
+ clrl r11
+
+# Loop for S2_LIMB < 0x80000000
+Loop1: movl (r8)+,r1
+ jlss L1n0
+ emul r1,r6,$0,r2
+ addl2 r11,r2
+ adwc $0,r3
+ addl2 r2,(r9)+
+ adwc $0,r3
+L1: movl (r8)+,r1
+ jlss L1n1
+L1p1: emul r1,r6,$0,r10
+ addl2 r3,r10
+ adwc $0,r11
+ addl2 r10,(r9)+
+ adwc $0,r11
+
+ jsobgtr r7,Loop1
+ movl r11,r0
+ ret
+
+L1n0: emul r1,r6,$0,r2
+ addl2 r11,r2
+ adwc r6,r3
+ addl2 r2,(r9)+
+ adwc $0,r3
+ movl (r8)+,r1
+ jgeq L1p1
+L1n1: emul r1,r6,$0,r10
+ addl2 r3,r10
+ adwc r6,r11
+ addl2 r10,(r9)+
+ adwc $0,r11
+
+ jsobgtr r7,Loop1
+ movl r11,r0
+ ret
+
+
+s2_big: clrl r3
+ incl r4
+ ashl $-1,r4,r7
+ jlbc r4,L2
+ clrl r11
+
+# Loop for S2_LIMB >= 0x80000000
+Loop2: movl (r8)+,r1
+ jlss L2n0
+ emul r1,r6,$0,r2
+ addl2 r11,r2
+ adwc r1,r3
+ addl2 r2,(r9)+
+ adwc $0,r3
+L2: movl (r8)+,r1
+ jlss L2n1
+L2p1: emul r1,r6,$0,r10
+ addl2 r3,r10
+ adwc r1,r11
+ addl2 r10,(r9)+
+ adwc $0,r11
+
+ jsobgtr r7,Loop2
+ movl r11,r0
+ ret
+
+L2n0: emul r1,r6,$0,r2
+ addl2 r11,r2
+ adwc r6,r3
+ addl2 r2,(r9)+
+ adwc r1,r3
+ movl (r8)+,r1
+ jgeq L2p1
+L2n1: emul r1,r6,$0,r10
+ addl2 r3,r10
+ adwc r6,r11
+ addl2 r10,(r9)+
+ adwc r1,r11
+
+ jsobgtr r7,Loop2
+ movl r11,r0
+ ret
diff --git a/ports/sysdeps/vax/bcopy.s b/ports/sysdeps/vax/bcopy.s
new file mode 100644
index 000000000..186ad365f
--- /dev/null
+++ b/ports/sysdeps/vax/bcopy.s
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ * 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/ports/sysdeps/vax/bits/huge_val.h b/ports/sysdeps/vax/bits/huge_val.h
new file mode 100644
index 000000000..63395b15e
--- /dev/null
+++ b/ports/sysdeps/vax/bits/huge_val.h
@@ -0,0 +1,26 @@
+/* `HUGE_VAL' constant for Vaxen.
+ Used by <stdlib.h> and <math.h> functions for overflow.
+ Copyright (C) 1992, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _MATH_H
+# error "Never use <bits/huge_val.h> directly; include <math.h> instead."
+#endif
+
+
+#define HUGE_VAL 1.70141182460469227e38
diff --git a/ports/sysdeps/vax/bits/setjmp.h b/ports/sysdeps/vax/bits/setjmp.h
new file mode 100644
index 000000000..10ca170a2
--- /dev/null
+++ b/ports/sysdeps/vax/bits/setjmp.h
@@ -0,0 +1,11 @@
+/* Define the machine-dependent type `jmp_buf'. Vax version. */
+
+#ifndef _SETJMP_H
+# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
+#endif
+
+typedef struct
+ {
+ PTR __fp;
+ PTR __pc;
+ } __jmp_buf[1];
diff --git a/ports/sysdeps/vax/bsd-_setjmp.S b/ports/sysdeps/vax/bsd-_setjmp.S
new file mode 100644
index 000000000..756e96b70
--- /dev/null
+++ b/ports/sysdeps/vax/bsd-_setjmp.S
@@ -0,0 +1,33 @@
+/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. Vax version.
+ Copyright (C) 1994, 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 0)'.
+ We cannot do it in C because it must be a tail-call, so frame-unwinding
+ in setjmp doesn't clobber the state restored by longjmp. */
+
+#include <sysdep.h>
+
+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)
+libc_hidden_def (_setjmp)
diff --git a/ports/sysdeps/vax/bsd-setjmp.S b/ports/sysdeps/vax/bsd-setjmp.S
new file mode 100644
index 000000000..792fcf7a6
--- /dev/null
+++ b/ports/sysdeps/vax/bsd-setjmp.S
@@ -0,0 +1,32 @@
+/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. Vax version.
+ Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This just does a tail-call to `__sigsetjmp (ARG, 1)'.
+ We cannot do it in C because it must be a tail-call, so frame-unwinding
+ in setjmp doesn't clobber the state restored by longjmp. */
+
+#include <sysdep.h>
+
+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/ports/sysdeps/vax/bzero.s b/ports/sysdeps/vax/bzero.s
new file mode 100644
index 000000000..be61a97d8
--- /dev/null
+++ b/ports/sysdeps/vax/bzero.s
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ * 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
+weak_alias (__bzero, bzero)
diff --git a/ports/sysdeps/vax/ffs.s b/ports/sysdeps/vax/ffs.s
new file mode 100644
index 000000000..6272cfd59
--- /dev/null
+++ b/ports/sysdeps/vax/ffs.s
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ * 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
+weak_alias (__ffs, ffs)
diff --git a/ports/sysdeps/vax/fl.h b/ports/sysdeps/vax/fl.h
new file mode 100644
index 000000000..79cbeb247
--- /dev/null
+++ b/ports/sysdeps/vax/fl.h
@@ -0,0 +1,68 @@
+/* Copyright (C) 1991, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 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/ports/sysdeps/vax/gccframe.h b/ports/sysdeps/vax/gccframe.h
new file mode 100644
index 000000000..323d5115d
--- /dev/null
+++ b/ports/sysdeps/vax/gccframe.h
@@ -0,0 +1,22 @@
+/* Definition of object in frame unwind info. vax version.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define DWARF_FRAME_REGISTERS 16
+
+#include <sysdeps/generic/gccframe.h>
diff --git a/ports/sysdeps/vax/gmp-mparam.h b/ports/sysdeps/vax/gmp-mparam.h
new file mode 100644
index 000000000..1ebfa19c5
--- /dev/null
+++ b/ports/sysdeps/vax/gmp-mparam.h
@@ -0,0 +1,29 @@
+/* gmp-mparam.h -- Compiler/machine parameter header file.
+
+Copyright (C) 1991, 1993, 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#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
+
+#define IEEE_DOUBLE_BIG_ENDIAN 0
diff --git a/ports/sysdeps/vax/htonl.s b/ports/sysdeps/vax/htonl.s
new file mode 100644
index 000000000..f3e2195c0
--- /dev/null
+++ b/ports/sysdeps/vax/htonl.s
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ * 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 "@(#)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
+weak_alias (htonl, ntohl)
diff --git a/ports/sysdeps/vax/htons.s b/ports/sysdeps/vax/htons.s
new file mode 100644
index 000000000..5f9ea7384
--- /dev/null
+++ b/ports/sysdeps/vax/htons.s
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ * 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 "@(#)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
+weak_alias (htons, ntohs)
diff --git a/ports/sysdeps/vax/memccpy.c b/ports/sysdeps/vax/memccpy.c
new file mode 100644
index 000000000..9a459ff5e
--- /dev/null
+++ b/ports/sysdeps/vax/memccpy.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1991, 1992, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#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. */
+void *
+__memccpy (dest, src, c, n)
+ void *dest;
+ const void *src;
+ int c;
+ size_t nbytes;
+{
+ /* Except when N > 65535, this is what a hand-coded version would
+ do anyway. */
+
+ void *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/ports/sysdeps/vax/memchr.s b/ports/sysdeps/vax/memchr.s
new file mode 100644
index 000000000..5c54ba8e7
--- /dev/null
+++ b/ports/sysdeps/vax/memchr.s
@@ -0,0 +1,74 @@
+/*-
+ * 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.
+ * 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 occurrence 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
+
+weak_alias (__memchr, memchr)
+#if !__BOUNDED_POINTERS__
+weak_alias (__memchr, __ubp_memchr)
+#endif
diff --git a/ports/sysdeps/vax/memcmp.s b/ports/sysdeps/vax/memcmp.s
new file mode 100644
index 000000000..e32fe24f4
--- /dev/null
+++ b/ports/sysdeps/vax/memcmp.s
@@ -0,0 +1,59 @@
+/*-
+ * 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.
+ * 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
+
+weak_alias (memcmp, bcmp)
diff --git a/ports/sysdeps/vax/memmove.s b/ports/sysdeps/vax/memmove.s
new file mode 100644
index 000000000..738544142
--- /dev/null
+++ b/ports/sysdeps/vax/memmove.s
@@ -0,0 +1,89 @@
+/*-
+ * 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.
+ * 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/ports/sysdeps/vax/memset.s b/ports/sysdeps/vax/memset.s
new file mode 100644
index 000000000..dda14868f
--- /dev/null
+++ b/ports/sysdeps/vax/memset.s
@@ -0,0 +1,51 @@
+/*-
+ * 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.
+ * 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/ports/sysdeps/vax/mul_1.s b/ports/sysdeps/vax/mul_1.s
new file mode 100644
index 000000000..295638b06
--- /dev/null
+++ b/ports/sysdeps/vax/mul_1.s
@@ -0,0 +1,123 @@
+# VAX __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 Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 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 Lesser General Public
+# License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+
+# INPUT PARAMETERS
+# res_ptr (sp + 4)
+# s1_ptr (sp + 8)
+# size (sp + 12)
+# s2_limb (sp + 16)
+
+.text
+ .align 1
+.globl ___mpn_mul_1
+___mpn_mul_1:
+ .word 0xfc0
+ movl 12(ap),r4
+ movl 8(ap),r8
+ movl 4(ap),r9
+ movl 16(ap),r6
+ jlss s2_big
+
+# One might want to combine the addl2 and the store below, but that
+# is actually just slower according to my timing tests. (VAX 3600)
+
+ clrl r3
+ incl r4
+ ashl $-1,r4,r7
+ jlbc r4,L1
+ clrl r11
+
+# Loop for S2_LIMB < 0x80000000
+Loop1: movl (r8)+,r1
+ jlss L1n0
+ emul r1,r6,$0,r2
+ addl2 r11,r2
+ adwc $0,r3
+ movl r2,(r9)+
+L1: movl (r8)+,r1
+ jlss L1n1
+L1p1: emul r1,r6,$0,r10
+ addl2 r3,r10
+ adwc $0,r11
+ movl r10,(r9)+
+
+ jsobgtr r7,Loop1
+ movl r11,r0
+ ret
+
+L1n0: emul r1,r6,$0,r2
+ addl2 r11,r2
+ adwc r6,r3
+ movl r2,(r9)+
+ movl (r8)+,r1
+ jgeq L1p1
+L1n1: emul r1,r6,$0,r10
+ addl2 r3,r10
+ adwc r6,r11
+ movl r10,(r9)+
+
+ jsobgtr r7,Loop1
+ movl r11,r0
+ ret
+
+
+s2_big: clrl r3
+ incl r4
+ ashl $-1,r4,r7
+ jlbc r4,L2
+ clrl r11
+
+# Loop for S2_LIMB >= 0x80000000
+Loop2: movl (r8)+,r1
+ jlss L2n0
+ emul r1,r6,$0,r2
+ addl2 r11,r2
+ adwc r1,r3
+ movl r2,(r9)+
+L2: movl (r8)+,r1
+ jlss L2n1
+L2p1: emul r1,r6,$0,r10
+ addl2 r3,r10
+ adwc r1,r11
+ movl r10,(r9)+
+
+ jsobgtr r7,Loop2
+ movl r11,r0
+ ret
+
+L2n0: emul r1,r6,$0,r2
+ addl2 r1,r3
+ addl2 r11,r2
+ adwc r6,r3
+ movl r2,(r9)+
+ movl (r8)+,r1
+ jgeq L2p1
+L2n1: emul r1,r6,$0,r10
+ addl2 r1,r11
+ addl2 r3,r10
+ adwc r6,r11
+ movl r10,(r9)+
+
+ jsobgtr r7,Loop2
+ movl r11,r0
+ ret
diff --git a/ports/sysdeps/vax/setjmp.c b/ports/sysdeps/vax/setjmp.c
new file mode 100644
index 000000000..0e38f3974
--- /dev/null
+++ b/ports/sysdeps/vax/setjmp.c
@@ -0,0 +1,62 @@
+/* Copyright (C) 1991, 1992, 1994, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA.
+
+ Derived from @(#)_setjmp.s 5.7 (Berkeley) 6/27/88,
+ 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.
+ 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.
+*/
+
+#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/ports/sysdeps/vax/strcat.s b/ports/sysdeps/vax/strcat.s
new file mode 100644
index 000000000..bfe64e61a
--- /dev/null
+++ b/ports/sysdeps/vax/strcat.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.
+ * 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/ports/sysdeps/vax/strchr.s b/ports/sysdeps/vax/strchr.s
new file mode 100644
index 000000000..d56cb4b0a
--- /dev/null
+++ b/ports/sysdeps/vax/strchr.s
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ * 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 occurrence 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
+
+weak_alias (strchr, index)
diff --git a/ports/sysdeps/vax/strcmp.s b/ports/sysdeps/vax/strcmp.s
new file mode 100644
index 000000000..479e14f30
--- /dev/null
+++ b/ports/sysdeps/vax/strcmp.s
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ * 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 "@(#)strcmp.s 5.6 (Berkeley) 6/1/90"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Compare string s1 lexicographically to string s2.
+ * Return:
+ * 0 s1 == s2
+ * > 0 s1 > s2
+ * < 0 s2 < s2
+ *
+ * strcmp(s1, s2)
+ * char *s1, *s2;
+ */
+#include "DEFS.h"
+
+ENTRY(strcmp, 0)
+ movl 4(ap),r1 # r1 = s1
+ movl 8(ap),r3 # r3 = s2
+ subb3 (r3),(r1),r0 # quick check for first char different
+ beql 1f # have to keep checking
+ cvtbl r0,r0
+ ret
+1:
+ clrl r5 # calculate min bytes to next page boundary
+ 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 boundary
+ cmpc3 r5,(r1),(r3) # compare strings
+ bneq 3f
+ 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
+3:
+ subl2 r0,r5 # check for null in matching string
+ subl2 r5,r1
+ locc $0,r5,(r1)
+ bneq 4f
+ subb3 (r3),(r1),r0 # r0 = *s1 - *s2
+ cvtbl r0,r0
+ ret
+4:
+ clrl r0 # both the same to null
+ ret
diff --git a/ports/sysdeps/vax/strcpy.s b/ports/sysdeps/vax/strcpy.s
new file mode 100644
index 000000000..1eb00ba6c
--- /dev/null
+++ b/ports/sysdeps/vax/strcpy.s
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ * 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/ports/sysdeps/vax/strcspn.s b/ports/sysdeps/vax/strcspn.s
new file mode 100644
index 000000000..155b78308
--- /dev/null
+++ b/ports/sysdeps/vax/strcspn.s
@@ -0,0 +1,62 @@
+/*-
+ * 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.
+ * 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/ports/sysdeps/vax/strlen.s b/ports/sysdeps/vax/strlen.s
new file mode 100644
index 000000000..9479fbbf6
--- /dev/null
+++ b/ports/sysdeps/vax/strlen.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.
+ * 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/ports/sysdeps/vax/strncat.s b/ports/sysdeps/vax/strncat.s
new file mode 100644
index 000000000..2387d1b1b
--- /dev/null
+++ b/ports/sysdeps/vax/strncat.s
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ * 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/ports/sysdeps/vax/strncmp.s b/ports/sysdeps/vax/strncmp.s
new file mode 100644
index 000000000..8d8f5d419
--- /dev/null
+++ b/ports/sysdeps/vax/strncmp.s
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ * 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 boundary
+ 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 boundary
+ 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/ports/sysdeps/vax/strncpy.s b/ports/sysdeps/vax/strncpy.s
new file mode 100644
index 000000000..ade70e9dc
--- /dev/null
+++ b/ports/sysdeps/vax/strncpy.s
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ * 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/ports/sysdeps/vax/strpbrk.s b/ports/sysdeps/vax/strpbrk.s
new file mode 100644
index 000000000..4a0e54171
--- /dev/null
+++ b/ports/sysdeps/vax/strpbrk.s
@@ -0,0 +1,64 @@
+/*-
+ * 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.
+ * 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/ports/sysdeps/vax/strrchr.s b/ports/sysdeps/vax/strrchr.s
new file mode 100644
index 000000000..b0e482c9f
--- /dev/null
+++ b/ports/sysdeps/vax/strrchr.s
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ * 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 occurrence 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
+
+weak_alias (strrchr, rindex)
diff --git a/ports/sysdeps/vax/strsep.s b/ports/sysdeps/vax/strsep.s
new file mode 100644
index 000000000..dcf2a7caa
--- /dev/null
+++ b/ports/sysdeps/vax/strsep.s
@@ -0,0 +1,81 @@
+/*-
+ * 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.
+ * 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/ports/sysdeps/vax/strspn.s b/ports/sysdeps/vax/strspn.s
new file mode 100644
index 000000000..ca944828c
--- /dev/null
+++ b/ports/sysdeps/vax/strspn.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.
+ * 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/ports/sysdeps/vax/strstr.s b/ports/sysdeps/vax/strstr.s
new file mode 100644
index 000000000..0283a57dc
--- /dev/null
+++ b/ports/sysdeps/vax/strstr.s
@@ -0,0 +1,109 @@
+/*-
+ * 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.
+ * 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/ports/sysdeps/vax/sub_n.s b/ports/sysdeps/vax/sub_n.s
new file mode 100644
index 000000000..14ba343f9
--- /dev/null
+++ b/ports/sysdeps/vax/sub_n.s
@@ -0,0 +1,48 @@
+# VAX __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 Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 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 Lesser General Public
+# License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+
+# INPUT PARAMETERS
+# res_ptr (sp + 4)
+# s1_ptr (sp + 8)
+# s2_ptr (sp + 12)
+# size (sp + 16)
+
+.text
+ .align 1
+.globl ___mpn_sub_n
+___mpn_sub_n:
+ .word 0x0
+ movl 16(ap),r0
+ movl 12(ap),r1
+ movl 8(ap),r2
+ movl 4(ap),r3
+ subl2 r4,r4
+
+Loop:
+ movl (r2)+,r4
+ sbwc (r1)+,r4
+ movl r4,(r3)+
+ jsobgtr r0,Loop
+
+ adwc r0,r0
+ ret
diff --git a/ports/sysdeps/vax/submul_1.s b/ports/sysdeps/vax/submul_1.s
new file mode 100644
index 000000000..5ff8d016c
--- /dev/null
+++ b/ports/sysdeps/vax/submul_1.s
@@ -0,0 +1,126 @@
+# VAX __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 Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 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 Lesser General Public
+# License for more details.
+
+# You should have received a copy of the GNU Lesser General Public License
+# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+
+# INPUT PARAMETERS
+# res_ptr (sp + 4)
+# s1_ptr (sp + 8)
+# size (sp + 12)
+# s2_limb (sp + 16)
+
+.text
+ .align 1
+.globl ___mpn_submul_1
+___mpn_submul_1:
+ .word 0xfc0
+ movl 12(ap),r4
+ movl 8(ap),r8
+ movl 4(ap),r9
+ movl 16(ap),r6
+ jlss s2_big
+
+ clrl r3
+ incl r4
+ ashl $-1,r4,r7
+ jlbc r4,L1
+ clrl r11
+
+# Loop for S2_LIMB < 0x80000000
+Loop1: movl (r8)+,r1
+ jlss L1n0
+ emul r1,r6,$0,r2
+ addl2 r11,r2
+ adwc $0,r3
+ subl2 r2,(r9)+
+ adwc $0,r3
+L1: movl (r8)+,r1
+ jlss L1n1
+L1p1: emul r1,r6,$0,r10
+ addl2 r3,r10
+ adwc $0,r11
+ subl2 r10,(r9)+
+ adwc $0,r11
+
+ jsobgtr r7,Loop1
+ movl r11,r0
+ ret
+
+L1n0: emul r1,r6,$0,r2
+ addl2 r11,r2
+ adwc r6,r3
+ subl2 r2,(r9)+
+ adwc $0,r3
+ movl (r8)+,r1
+ jgeq L1p1
+L1n1: emul r1,r6,$0,r10
+ addl2 r3,r10
+ adwc r6,r11
+ subl2 r10,(r9)+
+ adwc $0,r11
+
+ jsobgtr r7,Loop1
+ movl r11,r0
+ ret
+
+
+s2_big: clrl r3
+ incl r4
+ ashl $-1,r4,r7
+ jlbc r4,L2
+ clrl r11
+
+# Loop for S2_LIMB >= 0x80000000
+Loop2: movl (r8)+,r1
+ jlss L2n0
+ emul r1,r6,$0,r2
+ addl2 r11,r2
+ adwc r1,r3
+ subl2 r2,(r9)+
+ adwc $0,r3
+L2: movl (r8)+,r1
+ jlss L2n1
+L2p1: emul r1,r6,$0,r10
+ addl2 r3,r10
+ adwc r1,r11
+ subl2 r10,(r9)+
+ adwc $0,r11
+
+ jsobgtr r7,Loop2
+ movl r11,r0
+ ret
+
+L2n0: emul r1,r6,$0,r2
+ addl2 r11,r2
+ adwc r6,r3
+ subl2 r2,(r9)+
+ adwc r1,r3
+ movl (r8)+,r1
+ jgeq L2p1
+L2n1: emul r1,r6,$0,r10
+ addl2 r3,r10
+ adwc r6,r11
+ subl2 r10,(r9)+
+ adwc r1,r11
+
+ jsobgtr r7,Loop2
+ movl r11,r0
+ ret
diff --git a/ports/sysdeps/z8000/add_n.s b/ports/sysdeps/z8000/add_n.s
new file mode 100644
index 000000000..4d290265a
--- /dev/null
+++ b/ports/sysdeps/z8000/add_n.s
@@ -0,0 +1,53 @@
+! Z8000 __mpn_add_n -- Add two limb vectors of equal, non-zero length.
+
+! 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 Lesser General Public License as published by
+! the Free Software Foundation; either version 2.1 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 Lesser General Public
+! License for more details.
+
+! You should have received a copy of the GNU Lesser General Public License
+! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+! MA 02111-1307, USA.
+
+
+! INPUT PARAMETERS
+! res_ptr r7
+! s1_ptr r6
+! s2_ptr r5
+! size r4
+
+! If we are really crazy, we can use push to write a few result words
+! backwards, using push just because it is faster than reg+disp. We'd
+! then add 2x the number of words written to r7...
+
+ unseg
+ .text
+ even
+ global ___mpn_add_n
+___mpn_add_n:
+ pop r0,@r6
+ pop r1,@r5
+ add r0,r1
+ ld @r7,r0
+ dec r4
+ jr eq,Lend
+Loop: pop r0,@r6
+ pop r1,@r5
+ adc r0,r1
+ inc r7,#2
+ ld @r7,r0
+ dec r4
+ jr ne,Loop
+Lend: ld r2,r4 ! use 0 already in r4
+ adc r2,r2
+ ret t
diff --git a/ports/sysdeps/z8000/gmp-mparam.h b/ports/sysdeps/z8000/gmp-mparam.h
new file mode 100644
index 000000000..4216df673
--- /dev/null
+++ b/ports/sysdeps/z8000/gmp-mparam.h
@@ -0,0 +1,27 @@
+/* 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 Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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 Lesser General Public
+License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#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
diff --git a/ports/sysdeps/z8000/mul_1.s b/ports/sysdeps/z8000/mul_1.s
new file mode 100644
index 000000000..e449dfacb
--- /dev/null
+++ b/ports/sysdeps/z8000/mul_1.s
@@ -0,0 +1,68 @@
+! Z8000 __mpn_mul_1 -- Multiply a limb vector with a limb and store
+! the result in a second limb vector.
+
+! Copyright (C) 1993, 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 Lesser General Public License as published by
+! the Free Software Foundation; either version 2.1 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 Lesser General Public
+! License for more details.
+
+! You should have received a copy of the GNU Lesser General Public License
+! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+! MA 02111-1307, USA.
+
+
+! INPUT PARAMETERS
+! res_ptr r7
+! s1_ptr r6
+! size r5
+! s2_limb r4
+
+ unseg
+ .text
+ even
+ global ___mpn_mul_1
+___mpn_mul_1:
+ sub r2,r2 ! zero carry limb
+ and r4,r4
+ jr mi,Lneg
+
+Lpos: pop r1,@r6
+ ld r9,r1
+ mult rr8,r4
+ and r1,r1 ! shift msb of loaded limb into cy
+ jr mi,Lp ! branch if loaded limb's msb is set
+ add r8,r4 ! hi_limb += sign_comp2
+Lp: add r9,r2 ! lo_limb += cy_limb
+ xor r2,r2
+ adc r2,r8
+ ld @r7,r9
+ inc r7,#2
+ dec r5
+ jr ne,Lpos
+ ret t
+
+Lneg: pop r1,@r6
+ ld r9,r1
+ mult rr8,r4
+ add r8,r1 ! hi_limb += sign_comp1
+ and r1,r1
+ jr mi,Ln
+ add r8,r4 ! hi_limb += sign_comp2
+Ln: add r9,r2 ! lo_limb += cy_limb
+ xor r2,r2
+ adc r2,r8
+ ld @r7,r9
+ inc r7,#2
+ dec r5
+ jr ne,Lneg
+ ret t
diff --git a/ports/sysdeps/z8000/sub_n.s b/ports/sysdeps/z8000/sub_n.s
new file mode 100644
index 000000000..c0787755c
--- /dev/null
+++ b/ports/sysdeps/z8000/sub_n.s
@@ -0,0 +1,54 @@
+! Z8000 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
+! store difference in a third limb vector.
+
+! 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 Lesser General Public License as published by
+! the Free Software Foundation; either version 2.1 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 Lesser General Public
+! License for more details.
+
+! You should have received a copy of the GNU Lesser General Public License
+! along with the GNU MP Library; see the file COPYING.LIB. If not, write to
+! the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+! MA 02111-1307, USA.
+
+
+! INPUT PARAMETERS
+! res_ptr r7
+! s1_ptr r6
+! s2_ptr r5
+! size r4
+
+! If we are really crazy, we can use push to write a few result words
+! backwards, using push just because it is faster than reg+disp. We'd
+! then add 2x the number of words written to r7...
+
+ unseg
+ .text
+ even
+ global ___mpn_sub_n
+___mpn_sub_n:
+ pop r0,@r6
+ pop r1,@r5
+ sub r0,r1
+ ld @r7,r0
+ dec r4
+ jr eq,Lend
+Loop: pop r0,@r6
+ pop r1,@r5
+ sbc r0,r1
+ inc r7,#2
+ ld @r7,r0
+ dec r4
+ jr ne,Loop
+Lend: ld r2,r4 ! use 0 already in r4
+ adc r2,r2
+ ret t