about summary refs log tree commit diff
path: root/ports/sysdeps/hppa
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2012-07-01 13:06:41 +0000
committerJoseph Myers <joseph@codesourcery.com>2012-07-01 13:06:41 +0000
commite64ac02c24b43659048622714afdc92fedf561fa (patch)
tree37162878b72d302de351788bec4c9360c9d55f1d /ports/sysdeps/hppa
parenta20c2b3c87aebc7d4b090c622d36480263b80042 (diff)
downloadglibc-e64ac02c24b43659048622714afdc92fedf561fa.tar.gz
glibc-e64ac02c24b43659048622714afdc92fedf561fa.tar.xz
glibc-e64ac02c24b43659048622714afdc92fedf561fa.zip
Move all files into ports/ subdirectory in preparation for merge with glibc glibc-2.16-ports-before-merge
Diffstat (limited to 'ports/sysdeps/hppa')
-rw-r--r--ports/sysdeps/hppa/Makefile45
-rw-r--r--ports/sysdeps/hppa/Versions12
-rw-r--r--ports/sysdeps/hppa/__longjmp.S71
-rw-r--r--ports/sysdeps/hppa/abort-instr.h6
-rw-r--r--ports/sysdeps/hppa/add_n.S57
-rw-r--r--ports/sysdeps/hppa/bits/endian.h7
-rw-r--r--ports/sysdeps/hppa/bits/link.h56
-rw-r--r--ports/sysdeps/hppa/bits/linkmap.h6
-rw-r--r--ports/sysdeps/hppa/bits/setjmp.h35
-rw-r--r--ports/sysdeps/hppa/bsd-_setjmp.S38
-rw-r--r--ports/sysdeps/hppa/bsd-setjmp.S35
-rw-r--r--ports/sysdeps/hppa/configure171
-rw-r--r--ports/sysdeps/hppa/configure.in66
-rw-r--r--ports/sysdeps/hppa/crti.S80
-rw-r--r--ports/sysdeps/hppa/crtn.S88
-rw-r--r--ports/sysdeps/hppa/dl-fptr.c337
-rw-r--r--ports/sysdeps/hppa/dl-fptr.h39
-rw-r--r--ports/sysdeps/hppa/dl-irel.h47
-rw-r--r--ports/sysdeps/hppa/dl-lookupcfg.h79
-rw-r--r--ports/sysdeps/hppa/dl-machine.h779
-rw-r--r--ports/sysdeps/hppa/dl-symaddr.c35
-rw-r--r--ports/sysdeps/hppa/dl-tls.h31
-rw-r--r--ports/sysdeps/hppa/dl-trampoline.S288
-rw-r--r--ports/sysdeps/hppa/entry.h10
-rw-r--r--ports/sysdeps/hppa/fpu/bits/fenv.h82
-rw-r--r--ports/sysdeps/hppa/fpu/bits/mathdef.h39
-rw-r--r--ports/sysdeps/hppa/fpu/fclrexcpt.c35
-rw-r--r--ports/sysdeps/hppa/fpu/fedisblxcpt.c37
-rw-r--r--ports/sysdeps/hppa/fpu/feenablxcpt.c37
-rw-r--r--ports/sysdeps/hppa/fpu/fegetenv.c35
-rw-r--r--ports/sysdeps/hppa/fpu/fegetexcept.c33
-rw-r--r--ports/sysdeps/hppa/fpu/fegetround.c33
-rw-r--r--ports/sysdeps/hppa/fpu/feholdexcpt.c54
-rw-r--r--ports/sysdeps/hppa/fpu/fesetenv.c63
-rw-r--r--ports/sysdeps/hppa/fpu/fesetround.c40
-rw-r--r--ports/sysdeps/hppa/fpu/feupdateenv.c40
-rw-r--r--ports/sysdeps/hppa/fpu/fgetexcptflg.c37
-rw-r--r--ports/sysdeps/hppa/fpu/fraiseexcpt.c101
-rw-r--r--ports/sysdeps/hppa/fpu/fsetexcptflg.c37
-rw-r--r--ports/sysdeps/hppa/fpu/ftestexcept.c34
-rw-r--r--ports/sysdeps/hppa/fpu/libm-test-ulps1454
-rw-r--r--ports/sysdeps/hppa/frame.h27
-rw-r--r--ports/sysdeps/hppa/gccframe.h22
-rw-r--r--ports/sysdeps/hppa/hppa1.1/Implies3
-rw-r--r--ports/sysdeps/hppa/hppa1.1/addmul_1.S103
-rw-r--r--ports/sysdeps/hppa/hppa1.1/mul_1.S99
-rw-r--r--ports/sysdeps/hppa/hppa1.1/s_signbit.c34
-rw-r--r--ports/sysdeps/hppa/hppa1.1/submul_1.S112
-rw-r--r--ports/sysdeps/hppa/hppa1.1/udiv_qrnnd.S77
-rw-r--r--ports/sysdeps/hppa/jmpbuf-offsets.h19
-rw-r--r--ports/sysdeps/hppa/jmpbuf-unwind.h26
-rw-r--r--ports/sysdeps/hppa/ldsodefs.h41
-rw-r--r--ports/sysdeps/hppa/libc-tls.c37
-rw-r--r--ports/sysdeps/hppa/libgcc-compat.c42
-rw-r--r--ports/sysdeps/hppa/lshift.S65
-rw-r--r--ports/sysdeps/hppa/machine-gmon.h24
-rw-r--r--ports/sysdeps/hppa/memusage.h21
-rw-r--r--ports/sysdeps/hppa/mp_clz_tab.c1
-rw-r--r--ports/sysdeps/hppa/nptl/Makefile26
-rw-r--r--ports/sysdeps/hppa/nptl/jmpbuf-unwind.h30
-rw-r--r--ports/sysdeps/hppa/nptl/pthread_spin_init.c28
-rw-r--r--ports/sysdeps/hppa/nptl/pthread_spin_lock.c37
-rw-r--r--ports/sysdeps/hppa/nptl/pthread_spin_trylock.c33
-rw-r--r--ports/sysdeps/hppa/nptl/pthread_spin_unlock.c28
-rw-r--r--ports/sysdeps/hppa/nptl/pthreaddef.h39
-rw-r--r--ports/sysdeps/hppa/nptl/tcb-offsets.sym19
-rw-r--r--ports/sysdeps/hppa/nptl/tls.h170
-rw-r--r--ports/sysdeps/hppa/preconfigure6
-rw-r--r--ports/sysdeps/hppa/rshift.S62
-rw-r--r--ports/sysdeps/hppa/setjmp.S68
-rw-r--r--ports/sysdeps/hppa/shlib-versions9
-rw-r--r--ports/sysdeps/hppa/stackinfo.h33
-rw-r--r--ports/sysdeps/hppa/start.S143
-rw-r--r--ports/sysdeps/hppa/sub_n.S58
-rw-r--r--ports/sysdeps/hppa/sysdep.h76
-rw-r--r--ports/sysdeps/hppa/tls-macros.h115
-rw-r--r--ports/sysdeps/hppa/tst-audit.h25
-rw-r--r--ports/sysdeps/hppa/udiv_qrnnd.S285
78 files changed, 6652 insertions, 0 deletions
diff --git a/ports/sysdeps/hppa/Makefile b/ports/sysdeps/hppa/Makefile
new file mode 100644
index 0000000000..561330dd7e
--- /dev/null
+++ b/ports/sysdeps/hppa/Makefile
@@ -0,0 +1,45 @@
+# 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, see
+# <http://www.gnu.org/licenses/>.
+
+# 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
+
+# We implement a 64-bit `long double'. The standard says we can do this.
+# This means our `long double' and `double' are identical.
+long-double-fcts = no 
+
diff --git a/ports/sysdeps/hppa/Versions b/ports/sysdeps/hppa/Versions
new file mode 100644
index 0000000000..2ae3cbdf17
--- /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 0000000000..4ef219e414
--- /dev/null
+++ b/ports/sysdeps/hppa/__longjmp.S
@@ -0,0 +1,71 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..c13b0e5a4c
--- /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 0000000000..df5ceb8bcb
--- /dev/null
+++ b/ports/sysdeps/hppa/add_n.S
@@ -0,0 +1,57 @@
+;! 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.  If not, see
+;! <http://www.gnu.org/licenses/>.
+
+
+;! 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 0000000000..585db0c0fa
--- /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 0000000000..38d2c54250
--- /dev/null
+++ b/ports/sysdeps/hppa/bits/link.h
@@ -0,0 +1,56 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..54842b2299
--- /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 0000000000..19a0cfe621
--- /dev/null
+++ b/ports/sysdeps/hppa/bits/setjmp.h
@@ -0,0 +1,35 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* 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 0000000000..15888f57b2
--- /dev/null
+++ b/ports/sysdeps/hppa/bsd-_setjmp.S
@@ -0,0 +1,38 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..54e776fac9
--- /dev/null
+++ b/ports/sysdeps/hppa/bsd-setjmp.S
@@ -0,0 +1,35 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* 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 0000000000..c47fb6d0a3
--- /dev/null
+++ b/ports/sysdeps/hppa/configure
@@ -0,0 +1,171 @@
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
+
+  as_lineno_1=$LINENO as_lineno_1a=$LINENO
+  as_lineno_2=$LINENO as_lineno_2a=$LINENO
+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+# This file is generated from configure.in by Autoconf.  DO NOT EDIT!
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for assembler line separator" >&5
+$as_echo_n "checking for assembler line separator... " >&6; }
+if ${libc_cv_asm_line_sep+:} false; then :
+  $as_echo_n "(cached) " >&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\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; 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
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_asm_line_sep" >&5
+$as_echo "$libc_cv_asm_line_sep" >&6; }
+cat >>confdefs.h <<_ACEOF
+#define ASM_LINE_SEP $libc_cv_asm_line_sep
+_ACEOF
+
+
+# Check for support of thread-local storage handling in assembler and
+# linker.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for hppa TLS support" >&5
+$as_echo_n "checking for hppa TLS support... " >&6; }
+if ${libc_cv_hppa_tls+:} false; then :
+  $as_echo_n "(cached) " >&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\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+  libc_cv_hppa_tls=yes
+else
+  libc_cv_hppa_tls=no
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_hppa_tls" >&5
+$as_echo "$libc_cv_hppa_tls" >&6; }
+if test $libc_cv_hppa_tls = no; then
+  as_fn_error $? "the assembler must support TLS" "$LINENO" 5
+fi
diff --git a/ports/sysdeps/hppa/configure.in b/ports/sysdeps/hppa/configure.in
new file mode 100644
index 0000000000..57cb941bef
--- /dev/null
+++ b/ports/sysdeps/hppa/configure.in
@@ -0,0 +1,66 @@
+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)
+
+# 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 = no; then
+  AC_MSG_ERROR([the assembler must support TLS])
+fi
diff --git a/ports/sysdeps/hppa/crti.S b/ports/sysdeps/hppa/crti.S
new file mode 100644
index 0000000000..4bb81bcacd
--- /dev/null
+++ b/ports/sysdeps/hppa/crti.S
@@ -0,0 +1,80 @@
+/* Special .init and .fini section support for HPPA
+   Copyright (C) 2000-2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* 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.  The symbols _init and _fini are
+   magic and cause the linker to emit DT_INIT and DT_FINI.  */
+
+#include <libc-symbols.h>
+#include <sysdep.h>
+
+#ifndef PREINIT_FUNCTION
+# define PREINIT_FUNCTION __gmon_start__
+#endif
+
+#ifndef PREINIT_FUNCTION_WEAK
+# define PREINIT_FUNCTION_WEAK 1
+#endif
+
+/* _init prologue.  */
+	.section .init, "ax", %progbits
+	.align 4
+	.globl _init
+	.type _init,@function
+_init:
+	stw	%rp,-20(%sp)
+	stwm	%r4,64(%sp)
+	stw	%r19,-32(%sp)
+#if PREINIT_FUNCTION_WEAK
+	bl	PREINIT_FUNCTION,%rp
+	copy	%r19,%r4	/* delay slot */
+#else
+	bl	PREINIT_FUNCTION,%rp
+	copy	%r19,%r4	/* delay slot */
+#endif
+	copy	%r4,%r19
+
+/* _fini prologue.  */
+        .section .fini,"ax",%progbits
+	.align 4
+	.globl _fini
+	.type _fini,@function
+_fini:
+	stw	%rp,-20(%sp)
+	stwm	%r4,64(%sp)
+	stw	%r19,-32(%sp)
+	copy	%r19,%r4
+
diff --git a/ports/sysdeps/hppa/crtn.S b/ports/sysdeps/hppa/crtn.S
new file mode 100644
index 0000000000..679d739aa7
--- /dev/null
+++ b/ports/sysdeps/hppa/crtn.S
@@ -0,0 +1,88 @@
+/* Special .init and .fini section support for HPPA
+   Copyright (C) 2000-2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+
+/* crtn.S puts function epilogues in the .init and .fini sections
+   corresponding to the prologues in crti.S. */
+
+/* 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). */
+        .text
+        .align 4
+        .weak   __gmon_start__
+        .type    __gmon_start__,@function
+__gmon_start__:
+	.proc
+	.callinfo
+	.entry
+        bv,n %r0(%r2)
+	.exit
+	.procend
+
+/* Here is the tail end of _init.  We put __gmon_start before this so
+   that the assembler creates the .PARISC.unwind section for us, ie.
+   with the right attributes.  */
+	.section .init, "ax", @progbits
+	ldw	-84(%sp),%rp
+	copy	%r4,%r19
+	bv	%r0(%rp)
+_end_init:
+	ldwm	-64(%sp),%r4
+
+/* Our very own unwind info, because the assembler can't handle
+   functions split into two or more pieces.  */
+	.section .PARISC.unwind
+	.extern _init
+	.word	_init, _end_init
+	.byte	0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08
+
+/* Here is the tail end of _fini.  */
+	.section .fini, "ax", @progbits
+	ldw	-84(%sp),%rp
+	copy	%r4,%r19
+	bv	%r0(%rp)
+_end_fini:
+	ldwm	-64(%sp),%r4
+
+	.section .PARISC.unwind
+	.extern _fini
+	.word	_fini, _end_fini
+	.byte	0x08, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08
+
diff --git a/ports/sysdeps/hppa/dl-fptr.c b/ports/sysdeps/hppa/dl-fptr.c
new file mode 100644
index 0000000000..82b25b5422
--- /dev/null
+++ b/ports/sysdeps/hppa/dl-fptr.c
@@ -0,0 +1,337 @@
+/* Manage function descriptors.  Generic version.
+   Copyright (C) 1999-2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <libintl.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/param.h>
+#include <sys/mman.h>
+#include <link.h>
+#include <ldsodefs.h>
+#include <elf/dynamic-link.h>
+#include <dl-fptr.h>
+#include <atomic.h>
+
+#ifndef ELF_MACHINE_BOOT_FPTR_TABLE_LEN
+/* ELF_MACHINE_BOOT_FPTR_TABLE_LEN should be greater than the number of
+   dynamic symbols in ld.so.  */
+# define ELF_MACHINE_BOOT_FPTR_TABLE_LEN 256
+#endif
+
+#ifndef ELF_MACHINE_LOAD_ADDRESS
+# error "ELF_MACHINE_LOAD_ADDRESS is not defined."
+#endif
+
+#ifndef COMPARE_AND_SWAP
+# define COMPARE_AND_SWAP(ptr, old, new) \
+  (catomic_compare_and_exchange_bool_acq (ptr, new, old) == 0)
+#endif
+
+ElfW(Addr) _dl_boot_fptr_table [ELF_MACHINE_BOOT_FPTR_TABLE_LEN];
+
+static struct local
+  {
+    struct fdesc_table *root;
+    struct fdesc *free_list;
+    unsigned int npages;		/* # of pages to allocate */
+    /* the next to members MUST be consecutive! */
+    struct fdesc_table boot_table;
+    struct fdesc boot_fdescs[1024];
+  }
+local =
+  {
+#ifdef SHARED
+    /* Address of .boot_table is not known until runtime.  */
+    .root = 0,
+#else
+    .root = &local.boot_table,
+#endif
+    .npages = 2,
+    .boot_table =
+      {
+	.len = sizeof (local.boot_fdescs) / sizeof (local.boot_fdescs[0]),
+	.first_unused = 0
+      }
+  };
+
+/* Create a new fdesc table and return a pointer to the first fdesc
+   entry.  The fdesc lock must have been acquired already.  */
+
+static struct fdesc_table *
+new_fdesc_table (struct local *l, size_t *size)
+{
+  size_t old_npages = l->npages;
+  size_t new_npages = old_npages + old_npages;
+  struct fdesc_table *new_table;
+
+  /* If someone has just created a new table, we return NULL to tell
+     the caller to use the new table.  */
+  if (! COMPARE_AND_SWAP (&l->npages, old_npages, new_npages))
+    return (struct fdesc_table *) NULL;
+
+  *size = old_npages * GLRO(dl_pagesize);
+  new_table = __mmap (NULL, *size,
+		      PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
+  if (new_table == MAP_FAILED)
+    _dl_signal_error (errno, NULL, NULL,
+		      N_("cannot map pages for fdesc table"));
+
+  new_table->len
+    = (*size - sizeof (*new_table)) / sizeof (struct fdesc);
+  new_table->first_unused = 1;
+  return new_table;
+}
+
+/* Must call _dl_fptr_init before using any other function.  */
+void 
+_dl_fptr_init (void)
+{
+  struct local *l;
+
+  ELF_MACHINE_LOAD_ADDRESS (l, local);
+  l->root = &l->boot_table;
+}
+
+static ElfW(Addr)
+make_fdesc (ElfW(Addr) ip, ElfW(Addr) gp)
+{
+  struct fdesc *fdesc = NULL;
+  struct fdesc_table *root;
+  unsigned int old;
+  struct local *l;
+
+  ELF_MACHINE_LOAD_ADDRESS (l, local);
+
+ retry:
+  root = l->root;
+  while (1)
+    {
+      old = root->first_unused;
+      if (old >= root->len)
+	break;
+      else if (COMPARE_AND_SWAP (&root->first_unused, old, old + 1))
+	{
+	  fdesc = &root->fdesc[old];
+	  goto install;
+	}
+    }
+
+  if (l->free_list)
+    {
+      /* Get it from free-list.  */
+      do
+	{
+	  fdesc = l->free_list;
+	  if (fdesc == NULL)
+	    goto retry;
+	}
+      while (! COMPARE_AND_SWAP ((ElfW(Addr) *) &l->free_list,
+				 (ElfW(Addr)) fdesc, fdesc->ip));
+    }
+  else
+    {
+      /* Create a new fdesc table.  */
+      size_t size;
+      struct fdesc_table *new_table = new_fdesc_table (l, &size);
+
+      if (new_table == NULL)
+	goto retry;
+
+      new_table->next = root;
+      if (! COMPARE_AND_SWAP ((ElfW(Addr) *) &l->root,
+			      (ElfW(Addr)) root,
+			      (ElfW(Addr)) new_table))
+	{
+	  /* Someone has just installed a new table. Return NULL to
+	     tell the caller to use the new table.  */
+	  __munmap (new_table, size);
+	  goto retry;
+	}
+
+      /* Note that the first entry was reserved while allocating the
+	 memory for the new page.  */
+      fdesc = &new_table->fdesc[0];
+    }
+
+ install:
+  fdesc->ip = ip;
+  fdesc->gp = gp;
+
+  return (ElfW(Addr)) fdesc;
+}
+
+
+static inline ElfW(Addr) * __attribute__ ((always_inline))
+make_fptr_table (struct link_map *map)
+{
+  const ElfW(Sym) *symtab
+    = (const void *) D_PTR (map, l_info[DT_SYMTAB]);
+  const char *strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
+  ElfW(Addr) *fptr_table;
+  size_t size;
+  size_t len;
+
+  /* XXX Apparently the only way to find out the size of the dynamic
+     symbol section is to assume that the string table follows right
+     afterwards...  */
+  len = ((strtab - (char *) symtab)
+	 / map->l_info[DT_SYMENT]->d_un.d_val);
+  size = ((len * sizeof (fptr_table[0]) + GLRO(dl_pagesize) - 1)
+	  & -GLRO(dl_pagesize));
+  /* XXX We don't support here in the moment systems without MAP_ANON.
+     There probably are none for IA-64.  In case this is proven wrong
+     we will have to open /dev/null here and use the file descriptor
+     instead of the hard-coded -1.  */
+  fptr_table = __mmap (NULL, size,
+		       PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE,
+		       -1, 0);
+  if (fptr_table == MAP_FAILED)
+    _dl_signal_error (errno, NULL, NULL,
+		      N_("cannot map pages for fptr table"));
+
+  if (COMPARE_AND_SWAP ((ElfW(Addr) *) &map->l_mach.fptr_table,
+			(ElfW(Addr)) NULL, (ElfW(Addr)) fptr_table))
+    map->l_mach.fptr_table_len = len;
+  else
+    __munmap (fptr_table, len * sizeof (fptr_table[0]));
+
+  return map->l_mach.fptr_table;
+}
+
+
+ElfW(Addr)
+_dl_make_fptr (struct link_map *map, const ElfW(Sym) *sym,
+	       ElfW(Addr) ip)
+{
+  ElfW(Addr) *ftab = map->l_mach.fptr_table;
+  const ElfW(Sym) *symtab;
+  Elf_Symndx symidx;
+  struct local *l;
+
+  if (__builtin_expect (ftab == NULL, 0))
+    ftab = make_fptr_table (map);
+
+  symtab = (const void *) D_PTR (map, l_info[DT_SYMTAB]);
+  symidx = sym - symtab;
+
+  if (symidx >= map->l_mach.fptr_table_len)
+    _dl_signal_error (0, NULL, NULL,
+		      N_("internal error: symidx out of range of fptr table"));
+
+  while (ftab[symidx] == 0)
+    {
+      /* GOT has already been relocated in elf_get_dynamic_info -
+	 don't try to relocate it again.  */
+      ElfW(Addr) fdesc
+	= make_fdesc (ip, map->l_info[DT_PLTGOT]->d_un.d_ptr);
+
+      if (__builtin_expect (COMPARE_AND_SWAP (&ftab[symidx], (ElfW(Addr)) NULL,
+					      fdesc), 1))
+	{
+	  /* Noone has updated the entry and the new function
+	     descriptor has been installed.  */
+#if 0
+	  const char *strtab
+	    = (const void *) D_PTR (map, l_info[DT_STRTAB]);
+
+	  ELF_MACHINE_LOAD_ADDRESS (l, local);
+	  if (l->root != &l->boot_table
+	      || l->boot_table.first_unused > 20)
+	    _dl_debug_printf ("created fdesc symbol `%s' at %lx\n",
+			      strtab + sym->st_name, ftab[symidx]);
+#endif
+	  break;
+	}
+      else
+	{
+	  /* We created a duplicated function descriptor. We put it on
+	     free-list.  */
+	  struct fdesc *f = (struct fdesc *) fdesc;
+
+	  ELF_MACHINE_LOAD_ADDRESS (l, local);
+
+	  do
+	    f->ip = (ElfW(Addr)) l->free_list;
+	  while (! COMPARE_AND_SWAP ((ElfW(Addr) *) &l->free_list,
+				     f->ip, fdesc));
+	}
+    }
+
+  return ftab[symidx];
+}
+
+
+void
+_dl_unmap (struct link_map *map)
+{
+  ElfW(Addr) *ftab = map->l_mach.fptr_table;
+  struct fdesc *head = NULL, *tail = NULL;
+  size_t i;
+
+  __munmap ((void *) map->l_map_start,
+	    map->l_map_end - map->l_map_start);
+
+  if (ftab == NULL)
+    return;
+
+  /* String together the fdesc structures that are being freed.  */
+  for (i = 0; i < map->l_mach.fptr_table_len; ++i)
+    {
+      if (ftab[i])
+	{
+	  *(struct fdesc **) ftab[i] = head;
+	  head = (struct fdesc *) ftab[i];
+	  if (tail == NULL)
+	    tail = head;
+	}
+    }
+
+  /* Prepend the new list to the free_list: */
+  if (tail)
+    do
+      tail->ip = (ElfW(Addr)) local.free_list;
+    while (! COMPARE_AND_SWAP ((ElfW(Addr) *) &local.free_list,
+			       tail->ip, (ElfW(Addr)) head));
+
+  __munmap (ftab, (map->l_mach.fptr_table_len
+		   * sizeof (map->l_mach.fptr_table[0])));
+
+  map->l_mach.fptr_table = NULL;
+}
+
+
+ElfW(Addr)
+_dl_lookup_address (const void *address)
+{
+  ElfW(Addr) addr = (ElfW(Addr)) address;
+  struct fdesc_table *t;
+  unsigned long int i;
+
+  for (t = local.root; t != NULL; t = t->next)
+    {
+      i = (struct fdesc *) addr - &t->fdesc[0];
+      if (i < t->first_unused && addr == (ElfW(Addr)) &t->fdesc[i])
+	{
+	  addr = t->fdesc[i].ip;
+	  break;
+	}
+    }
+
+  return addr;
+}
diff --git a/ports/sysdeps/hppa/dl-fptr.h b/ports/sysdeps/hppa/dl-fptr.h
new file mode 100644
index 0000000000..ae504de08d
--- /dev/null
+++ b/ports/sysdeps/hppa/dl-fptr.h
@@ -0,0 +1,39 @@
+/* Function descriptors.  HPPA version.
+   Copyright (C) 2003-2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef dl_hppa_fptr_h
+#define dl_hppa_fptr_h 1
+
+#include <sysdeps/generic/dl-fptr.h>
+
+/* Initialize function pointer code. Call before relocation processing.  */
+extern void _dl_fptr_init (void);
+
+/* There are currently 33 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 64	
+
+#define ELF_MACHINE_LOAD_ADDRESS(var, symbol) \
+  asm (								\
+"	b,l	1f,%0\n"					\
+"	depi	0,31,2,%0\n"					\
+"1:	addil	L'" #symbol " - ($PIC_pcrel$0 - 8),%0\n"	\
+"	ldo	R'" #symbol " - ($PIC_pcrel$0 - 12)(%%r1),%0\n"	\
+   : "=&r" (var) : : "r1");
+
+#endif /* !dl_hppa_fptr_h */
diff --git a/ports/sysdeps/hppa/dl-irel.h b/ports/sysdeps/hppa/dl-irel.h
new file mode 100644
index 0000000000..90928470bf
--- /dev/null
+++ b/ports/sysdeps/hppa/dl-irel.h
@@ -0,0 +1,47 @@
+/* Machine-dependent ELF indirect relocation inline functions.
+   HP-PARISC version.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along 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_IREL_H
+#define _DL_IREL_H
+
+#include <stdio.h>
+#include <unistd.h>
+#include <dl-fptr.h>
+
+#define ELF_MACHINE_IREL	1
+
+/* Implement enough to get the build going again.  */
+#warning "NEED STT_GNU_IFUNC IMPLEMENTATION"
+
+static inline struct fdesc 
+__attribute ((always_inline))
+elf_ifunc_invoke (uintptr_t addr)
+{
+  return ((struct fdesc) {0, 0});
+}
+
+static inline void
+__attribute ((always_inline))
+elf_irel (const Elf32_Rel *reloc)
+{
+  return;
+}
+
+#endif /* dl-irel.h */
diff --git a/ports/sysdeps/hppa/dl-lookupcfg.h b/ports/sysdeps/hppa/dl-lookupcfg.h
new file mode 100644
index 0000000000..a81f41035f
--- /dev/null
+++ b/ports/sysdeps/hppa/dl-lookupcfg.h
@@ -0,0 +1,79 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..1bee330f8b
--- /dev/null
+++ b/ports/sysdeps/hppa/dl-machine.h
@@ -0,0 +1,779 @@
+/* Machine-dependent ELF dynamic relocation inline functions.  PA-RISC version.
+   Copyright (C) 1995-2012 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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>
+
+/* 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);	\
+	_dl_fptr_init();
+
+/* 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)
+{
+  volatile Elf32_Addr *rfdesc = reloc_addr;
+  /* map is the link_map for the caller, t is the link_map for the object
+     being called */
+  rfdesc[1] = value.gp;
+  /* Need to ensure that the gp is visible before the code
+     entry point is updated */
+  rfdesc[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_profile & 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 is a local function in the loader, so we construct	\
+	   a false OPD here and pass this to the application.  */	\
+	/* FIXME: Should be able to use P%, and LR RR to have the	\
+	   the linker construct a proper OPD.  */			\
+"	.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,
+		  int skip_ifunc)
+{
+  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,
+		      int skip_ifunc)
+{
+  /* 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 0000000000..039a754454
--- /dev/null
+++ b/ports/sysdeps/hppa/dl-symaddr.c
@@ -0,0 +1,35 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..ef8f4e3171
--- /dev/null
+++ b/ports/sysdeps/hppa/dl-tls.h
@@ -0,0 +1,31 @@
+/* Thread-local storage handling in the ELF dynamic linker.  hppa version.
+   Copyright (C) 2003, 2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+
+/* 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);
+
+/* Value used for dtv entries for which the allocation is delayed.  */
+#define TLS_DTV_UNALLOCATED	((void *) -1l)
diff --git a/ports/sysdeps/hppa/dl-trampoline.S b/ports/sysdeps/hppa/dl-trampoline.S
new file mode 100644
index 0000000000..21be0a04af
--- /dev/null
+++ b/ports/sysdeps/hppa/dl-trampoline.S
@@ -0,0 +1,288 @@
+/* PLT trampolines. hppa 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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.  */
+
+	/* RELOCATION MARKER: bl to provide gcc's __cffc with fixup loc. */
+	.text
+	/* THIS CODE DOES NOT EXECUTE */
+	bl	_dl_fixup, %r2
+        .text
+        .global _dl_runtime_resolve
+        .type _dl_runtime_resolve,@function
+	cfi_startproc
+        .align 4
+_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 */
+	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, %r1	/* Copy previous sp */
+	/* Save function result address (on entry) */
+	stwm	%r28,128(%sp)
+	/* Fillin some frame info to follow ABI */
+	stw	%r1,-4(%sp)	/* Previous sp */
+	stw	%r21,-32(%sp)	/* PIC register value */
+
+	/* Save input floating point registers. This must be done
+	   in the new frame since the previous frame doesn't have
+	   enough space */
+	ldo	-56(%sp),%r1
+	fstd,ma	%fr4,-8(%r1)
+	fstd,ma	%fr5,-8(%r1)
+	fstd,ma	%fr6,-8(%r1)
+	fstd,ma	%fr7,-8(%r1)
+
+ 	/* 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	%r28, %r22
+	copy	%r29, %r19
+
+	/* Reload arguments fp args */
+	ldo	-56(%sp),%r1
+	fldd,ma	-8(%r1),%fr4
+	fldd,ma	-8(%r1),%fr5
+	fldd,ma	-8(%r1),%fr6
+	fldd,ma	-8(%r1),%fr7
+
+	/* 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
+	cfi_endproc
+	.size   _dl_runtime_resolve, . - _dl_runtime_resolve
+
+        .text
+        .global _dl_runtime_profile
+        .type _dl_runtime_profile,@function
+	cfi_startproc
+        .align 4
+_dl_runtime_profile:
+        .PROC
+        .CALLINFO FRAME=192,CALLS,SAVE_RP,ENTRY_GR=3
+        .ENTRY
+
+        /* SAVE_RP says we do */
+        stw	%rp, -20(%sp)
+	/* Save static link register */
+	stw	%r29,-16(%sp)
+
+	/* Build a call frame, and save structure pointer. */
+	copy	%sp, %r1	/* Copy previous sp */
+	/* Save function result address (on entry) */
+	stwm	%r28,192(%sp)
+	/* Fillin some frame info to follow ABI */
+	stw	%r1,-4(%sp)	/* Previous sp */
+	stw	%r21,-32(%sp)	/* PIC register value */
+
+	/* Create La_hppa_retval */
+	/* -140, lrv_r28 
+           -136, lrv_r29
+           -132, 4 byte pad 
+           -128, lr_fr4 (8 bytes) */
+
+	/* Create save space for _dl_profile_fixup arguments
+	   -120, Saved reloc offset 
+	   -116, Saved struct link_map 
+	   -112, *framesizep */
+
+	/* Create La_hppa_regs */
+	/* 32-bit registers */
+	stw	%r26,-108(%sp)
+	stw	%r25,-104(%sp)
+	stw	%r24,-100(%sp)
+	stw	%r23,-96(%sp)
+	/* -92, 4 byte pad */
+	/* 64-bit floating point registers */
+	ldo	-88(%sp),%r1
+	fstd,ma	%fr4,8(%r1)
+	fstd,ma	%fr5,8(%r1)
+	fstd,ma	%fr6,8(%r1)
+	fstd,ma	%fr7,8(%r1)
+	/* 32-bit stack pointer and return register */
+	stw	%sp,-56(%sp)
+	stw	%r2,-52(%sp)
+
+
+ 	/* Set up args to fixup func, needs five arguments  */
+	ldw	8+4(%r20),%r26		/* (1) got[1] == struct link_map */
+	stw	%r26,-116(%sp)		/* Save struct link_map */
+	copy	%r19,%r25		/* (2) reloc offset  */
+	stw	%r25,-120(%sp)		/* Save reloc offset */
+	copy    %rp,%r24		/* (3) profile_fixup needs rp */
+	ldo	-56(%sp),%r23		/* (4) La_hppa_regs */
+	ldo	-112(%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 function descriptor */
+	copy	%r28, %r22
+	copy	%r29, %r19
+
+	/* Restore gr/fr/sp/rp */
+	ldw	-108(%sp),%r26
+	ldw	-104(%sp),%r25
+	ldw	-100(%sp),%r24
+	ldw	-96(%sp),%r23
+	/* -92, 4 byte pad, skip */
+	ldo	-88(%sp),%r1
+	fldd,ma	8(%r1),%fr4
+	fldd,ma	8(%r1),%fr5
+	fldd,ma	8(%r1),%fr6
+	fldd,ma	8(%r1),%fr7
+	ldw	-52(%sp),%rp
+
+	/* Reload static link register -(192+16) without adjusting stack */
+	ldw	-208(%sp),%r29
+
+	/* *framesizep is >= 0 if we have to run pltexit */
+	ldw	-112(%sp),%r28
+	cmpb,>>=,N %r0,%r28,L(cpe)
+
+	/* Adjust sp, and restore function result address*/
+	ldwm	-192(%sp),%r28
+	/* Jump to new function, but return to previous function */
+	bv	%r0(%r22)
+	ldw	-20(%sp),%rp
+	/* NO RETURN */
+
+L(nf):
+	/* Call the returned function descriptor */
+	bv	%r0(%r22)
+	nop
+	b,n	L(cont)
+
+L(cpe):
+	/* We are going to call the resolved function, but we have a 
+	   stack frame in the middle. We use the value of framesize to
+	   guess how much extra frame we need, and how much frame to
+	   copy forward. */
+
+	/* Round to nearest multiple of 64 */
+	addi	63, %r28, %r28
+	depi	0, 27, 6, %r28
+
+	/* Calcualte start of stack copy */
+	ldo	-192(%sp),%r2
+
+	/* Increate the stack by *framesizep */
+	copy	%sp, %r1
+	add	%sp, %r28, %sp
+	/* Save stack pointer */
+	stw	%r1, -4(%sp)
+
+	/* Single byte copy of prevous stack onto newly allocated stack */
+1:	ldb	%r28(%r2), %r1
+	add	%r28, %sp, %r26
+	stb	%r1, 0(%r26)
+	addi,<	-1,%r28,%r28
+	b,n	1b
+
+	/* Retore r28 and r27 and r2 already points at -192(%sp) */
+	ldw	0(%r2),%r28
+	ldw	84(%r2),%r26
+
+	/* Calculate address of L(cont) */
+	b,l	L(nf),%r2
+	depwi 0,31,2,%r2
+L(cont):
+	/* Undo fake stack */
+	ldw	-4(%sp),%r1
+	copy	%r1, %sp
+
+	/* Arguments to _dl_call_pltexit */
+	ldw	-116(%sp), %r26		/* (1) got[1] == struct link_map */ 
+	ldw 	-120(%sp), %r25		/* (2) reloc offsets */
+	ldo	-56(%sp), %r24		/* (3) *La_hppa_regs */
+	ldo	-124(%sp), %r23		/* (4) *La_hppa_retval */
+
+	/* Fill *La_hppa_retval */
+	stw	%r28,-140(%sp)
+	stw	%r29,-136(%sp)
+	ldo	-128(%sp), %r1
+	fstd	%fr4,0(%r1)
+
+	/* Call _dl_call_pltexit */
+	bl	_dl_call_pltexit,%rp
+	nop
+
+	/* Restore *La_hppa_retval */
+	ldw	-140(%sp), %r28
+	ldw	-136(%sp), %r29
+	ldo	-128(%sp), %r1
+	fldd	0(%r1), %fr4
+
+	/* Unwind the stack */
+	ldo	192(%sp),%sp
+	/* Retore callers rp */
+        ldw -20(%sp),%rp
+	/* Return */
+	bv,n	0(%r2)
+        .EXIT
+        .PROCEND
+	cfi_endproc
+	.size   _dl_runtime_profile, . - _dl_runtime_profile
+
diff --git a/ports/sysdeps/hppa/entry.h b/ports/sysdeps/hppa/entry.h
new file mode 100644
index 0000000000..b024db2be7
--- /dev/null
+++ b/ports/sysdeps/hppa/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/fpu/bits/fenv.h b/ports/sysdeps/hppa/fpu/bits/fenv.h
new file mode 100644
index 0000000000..6af5ddeef3
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/bits/fenv.h
@@ -0,0 +1,82 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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/bits/mathdef.h b/ports/sysdeps/hppa/fpu/bits/mathdef.h
new file mode 100644
index 0000000000..811b3684a4
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/bits/mathdef.h
@@ -0,0 +1,39 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 */
+
+/* On hppa `long double' is 64-bits. */
+#undef __NO_LONG_DOUBLE_MATH
+
diff --git a/ports/sysdeps/hppa/fpu/fclrexcpt.c b/ports/sysdeps/hppa/fpu/fclrexcpt.c
new file mode 100644
index 0000000000..5d1e593105
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fclrexcpt.c
@@ -0,0 +1,35 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..c69d8bacba
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fedisblxcpt.c
@@ -0,0 +1,37 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..20577f41b3
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/feenablxcpt.c
@@ -0,0 +1,37 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..b5ab4e1c41
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fegetenv.c
@@ -0,0 +1,35 @@
+/* Store current floating-point environment.
+   Copyright (C) 2000, 2011 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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;
+}
+libm_hidden_def (fegetenv)
diff --git a/ports/sysdeps/hppa/fpu/fegetexcept.c b/ports/sysdeps/hppa/fpu/fegetexcept.c
new file mode 100644
index 0000000000..0faa3b213f
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fegetexcept.c
@@ -0,0 +1,33 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..70d2e476fe
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fegetround.c
@@ -0,0 +1,33 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..6e3cabd88a
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/feholdexcpt.c
@@ -0,0 +1,54 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..e768bb2c37
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fesetenv.c
@@ -0,0 +1,63 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..d7acab2668
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fesetround.c
@@ -0,0 +1,40 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..cd01f07d96
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/feupdateenv.c
@@ -0,0 +1,40 @@
+/* Install given floating-point environment and raise exceptions.
+   Copyright (C) 2000, 2011 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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;
+}
+libm_hidden_def (feupdateenv)
diff --git a/ports/sysdeps/hppa/fpu/fgetexcptflg.c b/ports/sysdeps/hppa/fpu/fgetexcptflg.c
new file mode 100644
index 0000000000..360df383e2
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fgetexcptflg.c
@@ -0,0 +1,37 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..4b0161a6e9
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fraiseexcpt.c
@@ -0,0 +1,101 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..6a1d189fad
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/fsetexcptflg.c
@@ -0,0 +1,37 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..90f984e735
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/ftestexcept.c
@@ -0,0 +1,34 @@
+/* Test exception in current environment.
+   Copyright (C) 2000, 2011 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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;
+}
+libm_hidden_def (fetestexcept)
diff --git a/ports/sysdeps/hppa/fpu/libm-test-ulps b/ports/sysdeps/hppa/fpu/libm-test-ulps
new file mode 100644
index 0000000000..b8ec3d25f4
--- /dev/null
+++ b/ports/sysdeps/hppa/fpu/libm-test-ulps
@@ -0,0 +1,1454 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 1
+ifloat: 1
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 1
+ifloat: 1
+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 "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+float: 1
+ifloat: 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
+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: 5
+ldouble: 5
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 3
+ldouble: 3
+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
+ildouble: 1
+ldouble: 1
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+ildouble: 4
+ldouble: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 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
+ildouble: 1
+ldouble: 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
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# ceil
+Test "ceil (-4503599627370496.75) == -4503599627370496.0":
+ildouble: 1
+ldouble: 1
+Test "ceil (-4503599627370497.5) == -4503599627370497.0":
+ildouble: 1
+ldouble: 1
+Test "ceil (-9007199254740991.5) == -9007199254740991.0":
+ildouble: 1
+ldouble: 1
+Test "ceil (-9007199254740993.5) == -9007199254740993.0":
+ildouble: 1
+ldouble: 1
+Test "ceil (4503599627370496.25) == 4503599627370497.0":
+ildouble: 1
+ldouble: 1
+Test "ceil (4503599627370496.5) == 4503599627370497.0":
+ildouble: 1
+ldouble: 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 "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
+idouble: 1
+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 - 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
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# 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: 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: 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: 1
+ldouble: 1
+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: 2
+ldouble: 2
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 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
+ildouble: 1
+ldouble: 1
+
+# 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 (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
+ildouble: 1
+ldouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# erfc
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 6
+ldouble: 6
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "expm1 (1) == M_El - 1.0":
+float: 1
+ifloat: 1
+
+# floor
+Test "floor (-4503599627370496.25) == -4503599627370497.0":
+ildouble: 1
+ldouble: 1
+Test "floor (-4503599627370496.5) == -4503599627370497.0":
+ildouble: 1
+ldouble: 1
+Test "floor (4503599627370496.75) == 4503599627370496.0":
+ildouble: 1
+ldouble: 1
+Test "floor (4503599627370497.5) == 4503599627370497.0":
+ildouble: 1
+ldouble: 1
+Test "floor (9007199254740991.5) == 9007199254740991.0":
+ildouble: 1
+ldouble: 1
+Test "floor (9007199254740993.5) == 9007199254740993.0":
+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
+ildouble: 1
+ldouble: 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
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 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
+ildouble: 1
+ldouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 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
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 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
+ildouble: 1
+ldouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+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, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+ildouble: 4
+ldouble: 4
+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
+ildouble: 1
+ldouble: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# lgamma
+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
+
+# llrint
+Test "llrint (-72057594037927936.75) == -72057594037927937LL":
+ildouble: 1
+ldouble: 1
+Test "llrint (-72057594037927937.5) == -72057594037927938LL":
+ildouble: 2
+ldouble: 2
+Test "llrint (-9007199254740992.75) == -9007199254740993LL":
+ildouble: 1
+ldouble: 1
+Test "llrint (72057594037927936.75) == 72057594037927937LL":
+ildouble: -1
+ldouble: -1
+Test "llrint (72057594037927937.5) == 72057594037927938LL":
+ildouble: -2
+ldouble: -2
+Test "llrint (9007199254740992.75) == 9007199254740993LL":
+ildouble: -1
+ldouble: -1
+
+# llrint_downward
+Test "llrint_downward (-4503599627370496.25) == -4503599627370497LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (-4503599627370496.4999999999999) == -4503599627370497LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (-4503599627370496.5) == -4503599627370497LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (-4503599627370497.4999999999999) == -4503599627370498LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (-72057594037927936.25) == -72057594037927937LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (-72057594037927936.5) == -72057594037927937LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (-72057594037927936.75) == -72057594037927937LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (-72057594037927937.5) == -72057594037927938LL":
+ildouble: 2
+ldouble: 2
+Test "llrint_downward (-9007199254740991.4999999999999) == -9007199254740992LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (-9007199254740992.25) == -9007199254740993LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (-9007199254740992.4999999999999) == -9007199254740993LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (-9007199254740992.5) == -9007199254740993LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (-9007199254740992.5000000000001) == -9007199254740993LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (-9007199254740992.75) == -9007199254740993LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (4503599627370496.5000000000001) == 4503599627370496LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (4503599627370496.75) == 4503599627370496LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (4503599627370497.5) == 4503599627370497LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (72057594037927935.5) == 72057594037927935LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (72057594037927937.5) == 72057594037927937LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_downward (9007199254740991.5) == 9007199254740991LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (9007199254740991.5000000000001) == 9007199254740991LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (9007199254740993.4999999999999) == 9007199254740993LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (9007199254740993.5) == 9007199254740993LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_downward (9007199254740993.5000000000001) == 9007199254740993LL":
+ildouble: 1
+ldouble: 1
+
+# llrint_tonearest
+Test "llrint_tonearest (-72057594037927936.75) == -72057594037927937LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_tonearest (-72057594037927937.5) == -72057594037927938LL":
+ildouble: 2
+ldouble: 2
+Test "llrint_tonearest (-9007199254740992.75) == -9007199254740993LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_tonearest (72057594037927936.75) == 72057594037927937LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_tonearest (72057594037927937.5) == 72057594037927938LL":
+ildouble: -2
+ldouble: -2
+Test "llrint_tonearest (9007199254740992.75) == 9007199254740993LL":
+ildouble: -1
+ldouble: -1
+
+# llrint_towardzero
+Test "llrint_towardzero (-4503599627370496.75) == -4503599627370496LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_towardzero (-4503599627370497.5) == -4503599627370497LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_towardzero (-72057594037927935.5) == -72057594037927935LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_towardzero (-72057594037927937.5) == -72057594037927937LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_towardzero (-9007199254740991.5) == -9007199254740991LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_towardzero (-9007199254740993.5) == -9007199254740993LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_towardzero (4503599627370496.75) == 4503599627370496LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_towardzero (4503599627370497.5) == 4503599627370497LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_towardzero (72057594037927935.5) == 72057594037927935LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_towardzero (72057594037927937.5) == 72057594037927937LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_towardzero (9007199254740991.5) == 9007199254740991LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_towardzero (9007199254740993.5) == 9007199254740993LL":
+ildouble: 1
+ldouble: 1
+
+# llrint_upward
+Test "llrint_upward (-4503599627370496.5000000000001) == -4503599627370496LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (-4503599627370496.75) == -4503599627370496LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (-4503599627370497.5) == -4503599627370497LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (-72057594037927935.5) == -72057594037927935LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (-72057594037927937.5) == -72057594037927937LL":
+ildouble: 1
+ldouble: 1
+Test "llrint_upward (-9007199254740991.5) == -9007199254740991LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (-9007199254740991.5000000000001) == -9007199254740991LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (-9007199254740993.4999999999999) == -9007199254740993LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (-9007199254740993.5) == -9007199254740993LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (-9007199254740993.5000000000001) == -9007199254740993LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (4503599627370496.25) == 4503599627370497LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (4503599627370496.4999999999999) == 4503599627370497LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (4503599627370496.5) == 4503599627370497LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (4503599627370497.4999999999999) == 4503599627370498LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (72057594037927936.25) == 72057594037927937LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (72057594037927936.5) == 72057594037927937LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (72057594037927936.75) == 72057594037927937LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (72057594037927937.5) == 72057594037927938LL":
+ildouble: -2
+ldouble: -2
+Test "llrint_upward (9007199254740991.4999999999999) == 9007199254740992LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (9007199254740992.25) == 9007199254740993LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (9007199254740992.4999999999999) == 9007199254740993LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (9007199254740992.5) == 9007199254740993LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (9007199254740992.5000000000001) == 9007199254740993LL":
+ildouble: -1
+ldouble: -1
+Test "llrint_upward (9007199254740992.75) == 9007199254740993LL":
+ildouble: -1
+ldouble: -1
+
+# llround
+Test "llround (-4503599627370496.5) == -4503599627370497LL":
+ildouble: 1
+ldouble: 1
+Test "llround (-72057594037927936.5) == -72057594037927937LL":
+ildouble: 1
+ldouble: 1
+Test "llround (-72057594037927936.75) == -72057594037927937LL":
+ildouble: 1
+ldouble: 1
+Test "llround (-72057594037927937.5) == -72057594037927938LL":
+ildouble: 2
+ldouble: 2
+Test "llround (-9007199254740992.5) == -9007199254740993LL":
+ildouble: 1
+ldouble: 1
+Test "llround (-9007199254740992.75) == -9007199254740993LL":
+ildouble: 1
+ldouble: 1
+Test "llround (-9223372036854775806.25) == -9223372036854775806LL":
+ildouble: -2
+ldouble: -2
+Test "llround (-9223372036854775806.5) == -9223372036854775807LL":
+ildouble: -1
+ldouble: -1
+Test "llround (-9223372036854775807.0) == -9223372036854775807LL":
+ildouble: -1
+ldouble: -1
+Test "llround (4503599627370496.5) == 4503599627370497LL":
+ildouble: -1
+ldouble: -1
+Test "llround (72057594037927936.5) == 72057594037927937LL":
+ildouble: -1
+ldouble: -1
+Test "llround (72057594037927936.75) == 72057594037927937LL":
+ildouble: -1
+ldouble: -1
+Test "llround (72057594037927937.5) == 72057594037927938LL":
+ildouble: -2
+ldouble: -2
+Test "llround (9007199254740992.5) == 9007199254740993LL":
+ildouble: -1
+ldouble: -1
+Test "llround (9007199254740992.75) == 9007199254740993LL":
+ildouble: -1
+ldouble: -1
+Test "llround (9223372036854775806.25) == 9223372036854775806LL":
+ildouble: 1
+ldouble: 1
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# rint_downward
+Test "rint_downward (-4503599627370496.25) == -4503599627370497.0":
+ildouble: 1
+ldouble: 1
+Test "rint_downward (-4503599627370496.5) == -4503599627370497.0":
+ildouble: 1
+ldouble: 1
+Test "rint_downward (4503599627370496.75) == 4503599627370496.0":
+ildouble: 1
+ldouble: 1
+Test "rint_downward (4503599627370497.5) == 4503599627370497.0":
+ildouble: 1
+ldouble: 1
+
+# rint_towardzero
+Test "rint_towardzero (-4503599627370496.75) == -4503599627370496.0":
+ildouble: 1
+ldouble: 1
+Test "rint_towardzero (-4503599627370497.5) == -4503599627370497.0":
+ildouble: 1
+ldouble: 1
+Test "rint_towardzero (4503599627370496.75) == 4503599627370496.0":
+ildouble: 1
+ldouble: 1
+Test "rint_towardzero (4503599627370497.5) == 4503599627370497.0":
+ildouble: 1
+ldouble: 1
+
+# rint_upward
+Test "rint_upward (-4503599627370496.75) == -4503599627370496.0":
+ildouble: 1
+ldouble: 1
+Test "rint_upward (-4503599627370497.5) == -4503599627370497.0":
+ildouble: 1
+ldouble: 1
+Test "rint_upward (4503599627370496.25) == 4503599627370497.0":
+ildouble: 1
+ldouble: 1
+Test "rint_upward (4503599627370496.5) == 4503599627370497.0":
+ildouble: 1
+ldouble: 1
+
+# round
+Test "round (-4503599627370496.5) == -4503599627370497.0":
+ildouble: 1
+ldouble: 1
+Test "round (4503599627370496.5) == 4503599627370497.0":
+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
+
+# 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
+ildouble: 1
+ldouble: 1
+
+# trunc
+Test "trunc (-4503599627370496.75) == -4503599627370496.0":
+ildouble: 1
+ldouble: 1
+Test "trunc (-4503599627370497.5) == -4503599627370497.0":
+ildouble: 1
+ldouble: 1
+Test "trunc (-9007199254740991.5) == -9007199254740991.0":
+ildouble: 1
+ldouble: 1
+Test "trunc (-9007199254740993.5) == -9007199254740993.0":
+ildouble: 1
+ldouble: 1
+Test "trunc (4503599627370496.75) == 4503599627370496.0":
+ildouble: 1
+ldouble: 1
+Test "trunc (4503599627370497.5) == 4503599627370497.0":
+ildouble: 1
+ldouble: 1
+Test "trunc (9007199254740991.5) == 9007199254740991.0":
+ildouble: 1
+ldouble: 1
+Test "trunc (9007199254740993.5) == 9007199254740993.0":
+ildouble: 1
+ldouble: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 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
+ildouble: 3
+ldouble: 3
+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
+ildouble: 2
+ldouble: 2
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+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
+ildouble: 1
+ldouble: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 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
+ildouble: 3
+ldouble: 3
+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: 1
+ldouble: 1
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+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: 1
+ldouble: 1
+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
+ildouble: 1
+ldouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+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
+ildouble: 1
+ldouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 1
+ifloat: 1
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cacosh":
+float: 1
+ifloat: 1
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 3
+ldouble: 3
+
+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: 4
+ldouble: 4
+
+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
+
+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
+
+Function: "ceil":
+ildouble: 1
+ldouble: 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: Real part of "clog10":
+float: 1
+ifloat: 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: 2
+ldouble: 2
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+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
+
+Function: "erf":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 6
+ldouble: 6
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "floor":
+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: 1
+ldouble: 1
+
+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
+
+Function: "rint_downward":
+ildouble: 1
+ldouble: 1
+
+Function: "rint_towardzero":
+ildouble: 1
+ldouble: 1
+
+Function: "rint_upward":
+ildouble: 1
+ldouble: 1
+
+Function: "round":
+ildouble: 1
+ldouble: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+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: "trunc":
+ildouble: 1
+ldouble: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 3
+ldouble: 3
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 3
+ldouble: 3
+
+# end of automatic generation
diff --git a/ports/sysdeps/hppa/frame.h b/ports/sysdeps/hppa/frame.h
new file mode 100644
index 0000000000..a37652ad62
--- /dev/null
+++ b/ports/sysdeps/hppa/frame.h
@@ -0,0 +1,27 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* 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 0000000000..bdf5dd36bc
--- /dev/null
+++ b/ports/sysdeps/hppa/gccframe.h
@@ -0,0 +1,22 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* 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 0000000000..780c4e2467
--- /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 0000000000..ce1137bb99
--- /dev/null
+++ b/ports/sysdeps/hppa/hppa1.1/addmul_1.S
@@ -0,0 +1,103 @@
+;! 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.  If not, see
+;! <http://www.gnu.org/licenses/>.
+
+
+;! 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 0000000000..53abc09550
--- /dev/null
+++ b/ports/sysdeps/hppa/hppa1.1/mul_1.S
@@ -0,0 +1,99 @@
+;! 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.  If not, see
+;! <http://www.gnu.org/licenses/>.
+
+
+;! 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/s_signbit.c b/ports/sysdeps/hppa/hppa1.1/s_signbit.c
new file mode 100644
index 0000000000..3e298a29df
--- /dev/null
+++ b/ports/sysdeps/hppa/hppa1.1/s_signbit.c
@@ -0,0 +1,34 @@
+/* Return nonzero value if number is negative.
+   Copyright (C) 1997, 2009 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <math.h>
+
+#include <math_private.h>
+
+int
+__signbit (double x)
+{
+  int32_t hx;
+
+  GET_HIGH_WORD (hx, x);
+  return hx & 0x80000000;
+}
+#ifdef NO_LONG_DOUBLE
+strong_alias (__signbit, __signbitl)
+#endif
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 0000000000..910745243c
--- /dev/null
+++ b/ports/sysdeps/hppa/hppa1.1/submul_1.S
@@ -0,0 +1,112 @@
+;! 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.  If not, see
+;! <http://www.gnu.org/licenses/>.
+
+
+;! 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 0000000000..bcb3a86dd0
--- /dev/null
+++ b/ports/sysdeps/hppa/hppa1.1/udiv_qrnnd.S
@@ -0,0 +1,77 @@
+;! 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.  If not, see
+;! <http://www.gnu.org/licenses/>.
+
+
+;! 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 0000000000..b2a1b95312
--- /dev/null
+++ b/ports/sysdeps/hppa/jmpbuf-offsets.h
@@ -0,0 +1,19 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..ef448b3d3c
--- /dev/null
+++ b/ports/sysdeps/hppa/jmpbuf-unwind.h
@@ -0,0 +1,26 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..8e14126688
--- /dev/null
+++ b/ports/sysdeps/hppa/ldsodefs.h
@@ -0,0 +1,41 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..b96842625b
--- /dev/null
+++ b/ports/sysdeps/hppa/libc-tls.c
@@ -0,0 +1,37 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..a08ea7db93
--- /dev/null
+++ b/ports/sysdeps/hppa/libgcc-compat.c
@@ -0,0 +1,42 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+
+#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/lshift.S b/ports/sysdeps/hppa/lshift.S
new file mode 100644
index 0000000000..ce18a981f3
--- /dev/null
+++ b/ports/sysdeps/hppa/lshift.S
@@ -0,0 +1,65 @@
+;! 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.  If not, see
+;! <http://www.gnu.org/licenses/>.
+
+
+;! 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 0000000000..02838502b8
--- /dev/null
+++ b/ports/sysdeps/hppa/machine-gmon.h
@@ -0,0 +1,24 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* 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 0000000000..45834ff48e
--- /dev/null
+++ b/ports/sysdeps/hppa/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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..52d06383c1
--- /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 0000000000..86be06ade8
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/Makefile
@@ -0,0 +1,26 @@
+# 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, see
+# <http://www.gnu.org/licenses/>.
+
+ifeq ($(subdir),csu)
+gen-as-const-headers += tcb-offsets.sym
+endif
+
+# This sets the stack resource limit to 8193kb, which is not a multiple
+# of the page size, and therefore an odd sized stack limit. We override
+# this because the default is too small to run with. 
+tst-oddstacklimit-ENV = ; ulimit -s 8193;
+
diff --git a/ports/sysdeps/hppa/nptl/jmpbuf-unwind.h b/ports/sysdeps/hppa/nptl/jmpbuf-unwind.h
new file mode 100644
index 0000000000..02cb728342
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/jmpbuf-unwind.h
@@ -0,0 +1,30 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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_init.c b/ports/sysdeps/hppa/nptl/pthread_spin_init.c
new file mode 100644
index 0000000000..3a3aa9a736
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/pthread_spin_init.c
@@ -0,0 +1,28 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include "pthreadP.h"
+
+int
+pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+  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;
+}
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 0000000000..bcf22408da
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/pthread_spin_lock.c
@@ -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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..a802861012
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/pthread_spin_trylock.c
@@ -0,0 +1,33 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..005726bff6
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/pthread_spin_unlock.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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include "pthreadP.h"
+
+int
+pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+  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;
+}
diff --git a/ports/sysdeps/hppa/nptl/pthreaddef.h b/ports/sysdeps/hppa/nptl/pthreaddef.h
new file mode 100644
index 0000000000..484b16d1cf
--- /dev/null
+++ b/ports/sysdeps/hppa/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, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* 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 0000000000..f3cc82621a
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/tcb-offsets.sym
@@ -0,0 +1,19 @@
+#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)
+TID_THREAD_OFFSET		thread_offsetof (tid)
+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 0000000000..5eb55a5360
--- /dev/null
+++ b/ports/sysdeps/hppa/nptl/tls.h
@@ -0,0 +1,170 @@
+/* Definition for thread-local data handling.  NPTL/hppa version.
+   Copyright (C) 2005, 2007, 2010, 2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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__ */
+
+/* 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;				\
+   })
+
+/* Magic for libthread_db to know how to do THREAD_SELF.
+   Our thread pointer is stored in cr27.  See asm/elf.h for the offset into
+   elf_gregset_t.  The thread descriptor is sizeof (struct pthread) away.  */
+# define DB_THREAD_SELF \
+  REGISTER (32, 32, 53 * 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;
+}
+
+/* We write to cr27, clobber r26 as the input argument, and clobber
+   r31 as the link register.  */
+static inline void __set_cr27(struct pthread *cr27)
+{
+  asm ( "ble	0xe0(%%sr2, %%r0)\n\t"
+	"copy	%0, %%r26"
+	: : "r" (cr27) : "r26", "r31" );
+}
+
+/* Get and set the global scope generation counter in struct pthread.  */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED   1
+#define THREAD_GSCOPE_FLAG_WAIT   2
+#define THREAD_GSCOPE_RESET_FLAG() \
+  do									     \
+    { int __res								     \
+	= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag,	     \
+			       THREAD_GSCOPE_FLAG_UNUSED);		     \
+      if (__res == THREAD_GSCOPE_FLAG_WAIT)				     \
+	lll_private_futex_wake (&THREAD_SELF->header.gscope_flag, 1);	     \
+    }									     \
+  while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+  do									     \
+    {									     \
+      THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	     \
+      atomic_write_barrier ();						     \
+    }									     \
+  while (0)
+#define THREAD_GSCOPE_WAIT() \
+  GL(dl_wait_lookup_done) ()
+
+#endif /* !__ASSEMBLER__ */
+
+#endif	/* tls.h */
diff --git a/ports/sysdeps/hppa/preconfigure b/ports/sysdeps/hppa/preconfigure
new file mode 100644
index 0000000000..4d7fdcd032
--- /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 0000000000..9384ed2a9d
--- /dev/null
+++ b/ports/sysdeps/hppa/rshift.S
@@ -0,0 +1,62 @@
+;! 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.  If not, see
+;! <http://www.gnu.org/licenses/>.
+
+
+;! 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 0000000000..146e4d1943
--- /dev/null
+++ b/ports/sysdeps/hppa/setjmp.S
@@ -0,0 +1,68 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..6b9225c925
--- /dev/null
+++ b/ports/sysdeps/hppa/shlib-versions
@@ -0,0 +1,9 @@
+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
+
+hppa.*-.*-.*		libgcc_s=4
diff --git a/ports/sysdeps/hppa/stackinfo.h b/ports/sysdeps/hppa/stackinfo.h
new file mode 100644
index 0000000000..04dcd2c8c1
--- /dev/null
+++ b/ports/sysdeps/hppa/stackinfo.h
@@ -0,0 +1,33 @@
+/* Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* This file contains a bit of information about the stack allocation
+   of the processor.  */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H	1
+
+#include <elf.h>
+
+/* Default to an executable stack.  PF_X can be overridden if PT_GNU_STACK is
+ * present, but it is presumed absent.  */
+#define DEFAULT_STACK_PERMS (PF_R|PF_W|PF_X)
+
+/* On PA the stack grows up.  */
+#define _STACK_GROWS_UP	1
+
+#endif	/* stackinfo.h */
diff --git a/ports/sysdeps/hppa/start.S b/ports/sysdeps/hppa/start.S
new file mode 100644
index 0000000000..97196bd52d
--- /dev/null
+++ b/ports/sysdeps/hppa/start.S
@@ -0,0 +1,143 @@
+/* ELF startup code for HPPA.
+   Copyright (C) 2002, 2009 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+	.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.  The use of 21/14 relocs is only 
+	   supported in the latest dynamic linker.  */
+	.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:
+	/* At entry to the function we have:
+
+		r26 - Unused
+		r25 - argc
+		r24 - argv
+		r23 - False _dl_fini plabel address
+
+	   This function is called from the lower half of RTLD_START.  
+
+	   The call to __libc_start_main expects:
+
+		1. r26 - Application main
+		2. r25 - argc
+		3. r24 - argv
+		4. r23 - __libc_csu_init
+		5. sp-52 - __libc_csu_fini
+		6. sp-56 - rtld_fini
+		7. sp-60 - stackend  */ 
+
+	.proc
+	.callinfo
+	/* Clear previous-sp.  */
+	stw	%r0, -4(%sp)
+	/* Setup the stack and frame.  */
+	stw	%rp, -20(%sp)
+	ldo	64(%sp), %sp
+	stw	%sp, -4(%sp)
+	stw	%r19, -32(%sp)
+
+	/* argc and argv should be in 25 and 24 (2nd and 3rd argument) */
+	/* void (*rtld_fini) (void) (6th argument) */
+	stw	%r23, -56(%sp)
+	/* Need to setup 1, 4, 5, and 7th arguments */
+
+#if SHARED
+	/* load main (1st argument) */
+	addil	LT'.Lpmain, %r19
+	ldw	RT'.Lpmain(%r1), %r26
+	ldw	0(%r26),%r26
+	/* void (*init) (void) (4th argument) */
+	addil	LT'.Lp__libc_csu_init, %r19
+	ldw	RT'.Lp__libc_csu_init(%r1), %r23
+	ldw	0(%r23), %r23
+	/* void (*fini) (void) (5th argument) */
+	addil	LT'.Lp__libc_csu_fini, %r19
+	ldw	RT'.Lp__libc_csu_fini(%r1), %r22
+	ldw	0(%r22), %r22
+#else
+	/* load main (1st argument) */
+	ldil	LR'.Lpmain, %r26
+	ldw	RR'.Lpmain(%r26), %r26
+	/* 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 *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/sub_n.S b/ports/sysdeps/hppa/sub_n.S
new file mode 100644
index 0000000000..f4f22f8659
--- /dev/null
+++ b/ports/sysdeps/hppa/sub_n.S
@@ -0,0 +1,58 @@
+;! 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.  If not, see
+;! <http://www.gnu.org/licenses/>.
+
+
+;! 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 0000000000..746e611623
--- /dev/null
+++ b/ports/sysdeps/hppa/sysdep.h
@@ -0,0 +1,76 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..f5a1cd8f3d
--- /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 0000000000..c2b741b6f6
--- /dev/null
+++ b/ports/sysdeps/hppa/tst-audit.h
@@ -0,0 +1,25 @@
+/* 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, see
+   <http://www.gnu.org/licenses/>.  */
+
+#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 0000000000..2345ee5c9c
--- /dev/null
+++ b/ports/sysdeps/hppa/udiv_qrnnd.S
@@ -0,0 +1,285 @@
+;! 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.  If not, see
+;! <http://www.gnu.org/licenses/>.
+
+
+;! 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