summary refs log tree commit diff stats
path: root/libotr/libgcrypt-1.8.7/mpi/powerpc32
diff options
context:
space:
mode:
Diffstat (limited to 'libotr/libgcrypt-1.8.7/mpi/powerpc32')
-rw-r--r--libotr/libgcrypt-1.8.7/mpi/powerpc32/distfiles9
-rw-r--r--libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-add1.S136
-rw-r--r--libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-lshift.S198
-rw-r--r--libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-mul1.S120
-rw-r--r--libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-mul2.S127
-rw-r--r--libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-mul3.S130
-rw-r--r--libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-rshift.S131
-rw-r--r--libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-sub1.S133
-rw-r--r--libotr/libgcrypt-1.8.7/mpi/powerpc32/syntax.h75
9 files changed, 1059 insertions, 0 deletions
diff --git a/libotr/libgcrypt-1.8.7/mpi/powerpc32/distfiles b/libotr/libgcrypt-1.8.7/mpi/powerpc32/distfiles
new file mode 100644
index 0000000..af10d79
--- /dev/null
+++ b/libotr/libgcrypt-1.8.7/mpi/powerpc32/distfiles
@@ -0,0 +1,9 @@
+mpih-add1.S
+mpih-sub1.S
+mpih-mul1.S
+mpih-mul2.S
+mpih-mul3.S
+mpih-lshift.S
+mpih-rshift.S
+syntax.h
+
diff --git a/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-add1.S b/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-add1.S
new file mode 100644
index 0000000..1661f5e
--- /dev/null
+++ b/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-add1.S
@@ -0,0 +1,136 @@
+/* PowerPC-32 add_n -- Add two limb vectors of equal, non-zero length.
+ *
+ * Copyright (C) 1992, 1994, 1995, 1998, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+#ifndef USE_PPC_PATCHES
+
+/*******************
+ *  mpi_limb_t
+ *  _gcry_mpih_add_n( mpi_ptr_t res_ptr,	(r3)
+ *		   mpi_ptr_t s1_ptr,	(r4)
+ *		   mpi_ptr_t s2_ptr,	(r5)
+ *		   mpi_size_t size)	(r6)
+ */
+
+	.toc
+	.extern _gcry_mpih_add_n[DS]
+	.extern ._gcry_mpih_add_n
+.csect [PR]
+	.align 2
+	.globl _gcry_mpih_add_n
+	.globl ._gcry_mpih_add_n
+	.csect _gcry_mpih_add_n[DS]
+_gcry_mpih_add_n:
+	.long ._gcry_mpih_add_n, TOC[tc0], 0
+	.csect [PR]
+._gcry_mpih_add_n:
+	mtctr	6		# copy size into CTR
+	lwz	8,0(4)		# load least significant s1 limb
+	lwz	0,0(5)		# load least significant s2 limb
+	addi	3,3,-4		# offset res_ptr, it is updated before used
+	addc	7,0,8		# add least significant limbs, set cy
+	bdz	Lend		# If done, skip loop
+Loop:	lwzu	8,4(4)		# load s1 limb and update s1_ptr
+	lwzu	0,4(5)		# load s2 limb and update s2_ptr
+	stwu	7,4(3)		# store previous limb in load latency slot
+	adde	7,0,8		# add new limbs with cy, set cy
+	bdnz	Loop		# decrement CTR and loop back
+Lend:	stw	7,4(3)		# store ultimate result limb
+	li	3,0		# load cy into ...
+	addze	3,3		# ... return value register
+	blr
+
+#else
+/* Add two limb vectors of equal, non-zero length for PowerPC.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.	*/
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+/* mp_limb_t mpn_add_n (mp_ptr res_ptr, mp_srcptr s1_ptr, mp_srcptr s2_ptr,
+			mp_size_t size)
+   Calculate s1+s2 and put result in res_ptr; return carry, 0 or 1.  */
+
+/* Note on optimisation: This code is optimal for the 601.  Almost every other
+   possible 2-unrolled inner loop will not be.	Also, watch out for the
+   alignment...  */
+
+EALIGN(_gcry_mpih_add_n,3,0)
+/* Set up for loop below.  */
+       mtcrf 0x01,%r6
+       srwi. %r7,%r6,1
+       li    %r10,0
+       mtctr %r7
+       bt    31,2f
+
+/* Clear the carry.  */
+       addic %r0,%r0,0
+/* Adjust pointers for loop.  */
+       addi  %r3,%r3,-4
+       addi  %r4,%r4,-4
+       addi  %r5,%r5,-4
+       b     0f
+
+2:     lwz  %r7,0(%r5)
+       lwz  %r6,0(%r4)
+       addc %r6,%r6,%r7
+       stw  %r6,0(%r3)
+	beq  1f
+
+/* The loop.  */
+
+/* Align start of loop to an odd word boundary to guarantee that the
+   last two words can be fetched in one access (for 601).  */
+0:     lwz  %r9,4(%r4)
+       lwz  %r8,4(%r5)
+       lwzu %r6,8(%r4)
+       lwzu %r7,8(%r5)
+       adde %r8,%r9,%r8
+       stw  %r8,4(%r3)
+       adde %r6,%r6,%r7
+       stwu %r6,8(%r3)
+       bdnz 0b
+/* Return the carry.  */
+1:     addze %r3,%r10
+       blr
+END(_gcry_mpih_add_n)
+#endif
+
diff --git a/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-lshift.S b/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-lshift.S
new file mode 100644
index 0000000..6231095
--- /dev/null
+++ b/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-lshift.S
@@ -0,0 +1,198 @@
+/* PowerPC-32 lshift
+ *
+ *      Copyright (C) 1995, 1998, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+#ifndef USE_PPC_PATCHES
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_lshift( mpi_ptr_t wp,	(r3)
+ *		   mpi_ptr_t up,	(r4)
+ *		   mpi_size_t usize,	(r5)
+ *		   unsigned cnt)	(r6)
+ */
+
+	.toc
+.csect	.text[PR]
+	.align	2
+	.globl	_gcry_mpih_lshift
+	.globl	._gcry_mpih_lshift
+	.csect	_gcry_mpih_lshift[DS]
+_gcry_mpih_lshift:
+	.long	._gcry_mpih_lshift,  TOC[tc0],	  0
+	.csect	.text[PR]
+._gcry_mpih_lshift:
+	mtctr	5		# copy size into CTR
+	slwi	0,5,2
+	add	7,3,0		# make r7 point at end of res
+	add	4,4,0		# make r4 point at end of s1
+	subfic	8,6,32
+	lwzu	11,-4(4)	# load first s1 limb
+	srw	3,11,8		# compute function return value
+	bdz	Lend1
+
+Loop:	lwzu	10,-4(4)
+	slw	9,11,6
+	srw	12,10,8
+	or	9,9,12
+	stwu	9,-4(7)
+	bdz	Lend2
+	lwzu	11,-4(4)
+	slw	9,10,6
+	srw	12,11,8
+	or	9,9,12
+	stwu	9,-4(7)
+	bdnz	Loop
+
+Lend1:	slw	0,11,6
+	stw	0,-4(7)
+	blr
+
+Lend2:	slw	0,10,6
+	stw	0,-4(7)
+	blr
+
+#else
+/* Shift a limb left, low level routine.
+   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.	*/
+
+/* mp_limb_t mpn_lshift (mp_ptr wp, mp_srcptr up, mp_size_t usize,
+			unsigned int cnt)  */
+
+EALIGN(_gcry_mpih_lshift,3,0)
+       mtctr   %r5	       # copy size into CTR
+       cmplwi  %cr0,%r5,16     # is size < 16
+       slwi    %r0,%r5,2
+       add     %r7,%r3,%r0     # make r7 point at end of res
+       add     %r4,%r4,%r0     # make r4 point at end of s1
+       lwzu    %r11,-4(%r4)    # load first s1 limb
+       subfic  %r8,%r6,32
+       srw     %r3,%r11,%r8    # compute function return value
+       bge     %cr0,L(big)     # branch if size >= 16
+
+       bdz     L(end1)
+
+0:     lwzu    %r10,-4(%r4)
+       slw     %r9,%r11,%r6
+       srw     %r12,%r10,%r8
+       or      %r9,%r9,%r12
+       stwu    %r9,-4(%r7)
+       bdz     L(end2)
+       lwzu    %r11,-4(%r4)
+       slw     %r9,%r10,%r6
+       srw     %r12,%r11,%r8
+       or      %r9,%r9,%r12
+       stwu    %r9,-4(%r7)
+       bdnz    0b
+
+L(end1):slw    %r0,%r11,%r6
+       stw     %r0,-4(%r7)
+       blr
+
+
+/* Guaranteed not to succeed.  */
+L(boom): tweq	 %r0,%r0
+
+/* We imitate a case statement, by using (yuk!) fixed-length code chunks,
+   of size 4*12 bytes.	We have to do this (or something) to make this PIC.  */
+L(big):        mflr    %r9
+       bltl-   %cr0,L(boom)    # Never taken, only used to set LR.
+       slwi    %r10,%r6,4
+       mflr    %r12
+       add     %r10,%r12,%r10
+       slwi    %r8,%r6,5
+       add     %r10,%r8,%r10
+       mtctr   %r10
+       addi    %r5,%r5,-1
+       mtlr    %r9
+       bctr
+
+L(end2):slw    %r0,%r10,%r6
+       stw     %r0,-4(%r7)
+       blr
+
+#define DO_LSHIFT(n) \
+       mtctr   %r5;						       \
+0:     lwzu    %r10,-4(%r4);					       \
+       slwi    %r9,%r11,n;					       \
+       inslwi  %r9,%r10,n,32-n; 				       \
+       stwu    %r9,-4(%r7);					       \
+       bdz-    L(end2); 					       \
+       lwzu    %r11,-4(%r4);					       \
+       slwi    %r9,%r10,n;					       \
+       inslwi  %r9,%r11,n,32-n; 				       \
+       stwu    %r9,-4(%r7);					       \
+       bdnz    0b;						       \
+       b       L(end1)
+
+       DO_LSHIFT(1)
+       DO_LSHIFT(2)
+       DO_LSHIFT(3)
+       DO_LSHIFT(4)
+       DO_LSHIFT(5)
+       DO_LSHIFT(6)
+       DO_LSHIFT(7)
+       DO_LSHIFT(8)
+       DO_LSHIFT(9)
+       DO_LSHIFT(10)
+       DO_LSHIFT(11)
+       DO_LSHIFT(12)
+       DO_LSHIFT(13)
+       DO_LSHIFT(14)
+       DO_LSHIFT(15)
+       DO_LSHIFT(16)
+       DO_LSHIFT(17)
+       DO_LSHIFT(18)
+       DO_LSHIFT(19)
+       DO_LSHIFT(20)
+       DO_LSHIFT(21)
+       DO_LSHIFT(22)
+       DO_LSHIFT(23)
+       DO_LSHIFT(24)
+       DO_LSHIFT(25)
+       DO_LSHIFT(26)
+       DO_LSHIFT(27)
+       DO_LSHIFT(28)
+       DO_LSHIFT(29)
+       DO_LSHIFT(30)
+       DO_LSHIFT(31)
+
+END(_gcry_mpih_lshift)
+#endif
diff --git a/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-mul1.S b/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-mul1.S
new file mode 100644
index 0000000..bd418f7
--- /dev/null
+++ b/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-mul1.S
@@ -0,0 +1,120 @@
+/* PowerPC-32 mul_1 -- Multiply a limb vector with a limb and store
+ *		       the result in a second limb vector.
+ *
+ *      Copyright (C) 1992, 1993, 1994, 1995,
+ *                    1998, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+#ifndef USE_PPC_PATCHES
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_mul_1( mpi_ptr_t res_ptr,	(r3)
+ *		  mpi_ptr_t s1_ptr,	(r4)
+ *		  mpi_size_t s1_size,	(r5)
+ *		  mpi_limb_t s2_limb)	(r6)
+ *
+ * This is a fairly straightforward implementation.  The timing of the PC601
+ * is hard to understand, so I will wait to optimize this until I have some
+ * hardware to play with.
+ *
+ * The code trivially generalizes to 64 bit limbs for the PC620.
+ */
+
+	.toc
+	.csect ._gcry_mpih_mul_1[PR]
+	.align 2
+	.globl _gcry_mpih_mul_1
+	.globl ._gcry_mpih_mul_1
+	.csect _gcry_mpih_mul_1[DS]
+_gcry_mpih_mul_1:
+	.long ._gcry_mpih_mul_1[PR], TOC[tc0], 0
+	.csect ._gcry_mpih_mul_1[PR]
+._gcry_mpih_mul_1:
+	mtctr	5
+
+	lwz	0,0(4)
+	mullw	7,0,6
+	mulhwu	10,0,6
+	addi	3,3,-4		# adjust res_ptr
+	addic	5,5,0		# clear cy with dummy insn
+	bdz	Lend
+
+Loop:	lwzu	0,4(4)
+	stwu	7,4(3)
+	mullw	8,0,6
+	adde	7,8,10
+	mulhwu	10,0,6
+	bdnz	Loop
+
+Lend:	stw	7,4(3)
+	addze	3,10
+	blr
+
+#else
+/* Multiply a limb vector by a limb, for PowerPC.
+   Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.	*/
+
+
+/* mp_limb_t mpn_mul_1 (mp_ptr res_ptr, mp_srcptr s1_ptr,
+			mp_size_t s1_size, mp_limb_t s2_limb)
+   Calculate s1*s2 and put result in res_ptr; return carry.  */
+
+ENTRY(_gcry_mpih_mul_1)
+       mtctr   %r5
+
+       lwz     %r0,0(%r4)
+       mullw   %r7,%r0,%r6
+       mulhwu  %r10,%r0,%r6
+       addi    %r3,%r3,-4	       # adjust res_ptr
+       addic   %r5,%r5,0	       # clear cy with dummy insn
+       bdz     1f
+
+0:     lwzu    %r0,4(%r4)
+       stwu    %r7,4(%r3)
+       mullw   %r8,%r0,%r6
+       adde    %r7,%r8,%r10
+       mulhwu  %r10,%r0,%r6
+       bdnz    0b
+
+1:     stw     %r7,4(%r3)
+       addze   %r3,%r10
+       blr
+END(_gcry_mpih_mul_1)
+#endif
diff --git a/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-mul2.S b/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-mul2.S
new file mode 100644
index 0000000..1d97b81
--- /dev/null
+++ b/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-mul2.S
@@ -0,0 +1,127 @@
+/* PowerPC-32 addmul_1 -- Multiply a limb vector with a limb and add
+ *			  the result to a second limb vector.
+ *
+ *      Copyright (C) 1995, 1998, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+#ifndef USE_PPC_PATCHES
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr,      (r3)
+ *		     mpi_ptr_t s1_ptr,	     (r4)
+ *		     mpi_size_t s1_size,     (r5)
+ *		     mpi_limb_t s2_limb)     (r6)
+ *
+ * This is a fairly straightforward implementation.  The timing of the PC601
+ * is hard to understand, so I will wait to optimize this until I have some
+ * hardware to play with.
+ *
+ * The code trivially generalizes to 64 bit limbs for the PC620.
+ */
+
+
+	.toc
+	.csect ._gcry_mpih_addmul_1[PR]
+	.align 2
+	.globl _gcry_mpih_addmul_1
+	.globl ._gcry_mpih_addmul_1
+	.csect _gcry_mpih_addmul_1[DS]
+_gcry_mpih_addmul_1:
+	.long ._gcry_mpih_addmul_1[PR], TOC[tc0], 0
+	.csect ._gcry_mpih_addmul_1[PR]
+._gcry_mpih_addmul_1:
+	mtctr	5
+
+	lwz	0,0(4)
+	mullw	7,0,6
+	mulhwu	10,0,6
+	lwz	9,0(3)
+	addc	8,7,9
+	addi	3,3,-4
+	bdz	Lend
+
+Loop:	lwzu	0,4(4)
+	stwu	8,4(3)
+	mullw	8,0,6
+	adde	7,8,10
+	mulhwu	10,0,6
+	lwz	9,4(3)
+	addze	10,10
+	addc	8,7,9
+	bdnz	Loop
+
+Lend:	stw	8,4(3)
+	addze	3,10
+	blr
+
+#else
+/* Multiply a limb vector by a single limb, for PowerPC.
+   Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.	*/
+
+
+/* mp_limb_t mpn_addmul_1 (mp_ptr res_ptr, mp_srcptr s1_ptr,
+			   mp_size_t s1_size, mp_limb_t s2_limb)
+   Calculate res+s1*s2 and put result back in res; return carry.  */
+ENTRY(_gcry_mpih_addmul_1)
+       mtctr   %r5
+
+       lwz     %r0,0(%r4)
+       mullw   %r7,%r0,%r6
+       mulhwu  %r10,%r0,%r6
+       lwz     %r9,0(%r3)
+       addc    %r8,%r7,%r9
+       addi    %r3,%r3,-4	       /* adjust res_ptr */
+       bdz     1f
+
+0:     lwzu    %r0,4(%r4)
+       stwu    %r8,4(%r3)
+       mullw   %r8,%r0,%r6
+       adde    %r7,%r8,%r10
+       mulhwu  %r10,%r0,%r6
+       lwz     %r9,4(%r3)
+       addze   %r10,%r10
+       addc    %r8,%r7,%r9
+       bdnz    0b
+
+1:     stw     %r8,4(%r3)
+       addze   %r3,%r10
+       blr
+END(_gcry_mpih_addmul_1)
+#endif
diff --git a/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-mul3.S b/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-mul3.S
new file mode 100644
index 0000000..c410dbb
--- /dev/null
+++ b/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-mul3.S
@@ -0,0 +1,130 @@
+/* PowerPC-32 submul_1 -- Multiply a limb vector with a limb and subtract
+ *			  the result from a second limb vector.
+ *
+ *      Copyright (C) 1995, 1998, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+#ifndef USE_PPC_PATCHES
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_submul_1( mpi_ptr_t res_ptr,      (r3)
+ *		     mpi_ptr_t s1_ptr,	     (r4)
+ *		     mpi_size_t s1_size,     (r5)
+ *		     mpi_limb_t s2_limb)     (r6)
+ *
+ * This is a fairly straightforward implementation.  The timing of the PC601
+ * is hard to understand, so I will wait to optimize this until I have some
+ * hardware to play with.
+ *
+ * The code trivially generalizes to 64 bit limbs for the PC620.
+ */
+
+	.toc
+	.csect ._gcry_mpih_submul_1[PR]
+	.align 2
+	.globl _gcry_mpih_submul_1
+	.globl ._gcry_mpih_submul_1
+	.csect _gcry_mpih_submul_1[DS]
+_gcry_mpih_submul_1:
+	.long ._gcry_mpih_submul_1[PR], TOC[tc0], 0
+	.csect ._gcry_mpih_submul_1[PR]
+._gcry_mpih_submul_1:
+	mtctr	5
+
+	lwz	0,0(4)
+	mullw	7,0,6
+	mulhwu	10,0,6
+	lwz	9,0(3)
+	subfc	8,7,9
+	addc	7,7,8		# invert cy (r7 is junk)
+	addi	3,3,-4
+	bdz	Lend
+
+Loop:	lwzu	0,4(4)
+	stwu	8,4(3)
+	mullw	8,0,6
+	adde	7,8,10
+	mulhwu	10,0,6
+	lwz	9,4(3)
+	addze	10,10
+	subfc	8,7,9
+	addc	7,7,8		# invert cy (r7 is junk)
+	bdnz	Loop
+
+Lend:	stw	8,4(3)
+	addze	3,10
+	blr
+
+#else
+/* Multiply a limb vector by a single limb, for PowerPC.
+   Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.	*/
+
+/* mp_limb_t mpn_submul_1 (mp_ptr res_ptr, mp_srcptr s1_ptr,
+			   mp_size_t s1_size, mp_limb_t s2_limb)
+   Calculate res-s1*s2 and put result back in res; return carry.  */
+
+ENTRY(_gcry_mpih_submul_1)
+       mtctr   %r5
+
+       lwz     %r0,0(%r4)
+       mullw   %r7,%r0,%r6
+       mulhwu  %r10,%r0,%r6
+       lwz     %r9,0(%r3)
+       subf    %r8,%r7,%r9
+       addc    %r7,%r7,%r8	       # invert cy (r7 is junk)
+       addi    %r3,%r3,-4	       # adjust res_ptr
+       bdz     1f
+
+0:     lwzu    %r0,4(%r4)
+       stwu    %r8,4(%r3)
+       mullw   %r8,%r0,%r6
+       adde    %r7,%r8,%r10
+       mulhwu  %r10,%r0,%r6
+       lwz     %r9,4(%r3)
+       addze   %r10,%r10
+       subf    %r8,%r7,%r9
+       addc    %r7,%r7,%r8	       # invert cy (r7 is junk)
+       bdnz    0b
+
+1:     stw     %r8,4(%r3)
+       addze   %r3,%r10
+       blr
+END(_gcry_mpih_submul_1)
+#endif
diff --git a/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-rshift.S b/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-rshift.S
new file mode 100644
index 0000000..98349ed
--- /dev/null
+++ b/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-rshift.S
@@ -0,0 +1,131 @@
+/* PowerPC-32 rshift
+ *
+ *      Copyright (C) 1995, 1998, 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+#ifndef USE_PPC_PATCHES
+
+/*******************
+ * mpi_limb_t
+ * _gcry_mpih_rshift( mpi_ptr_t wp,	(r3)
+ *		   mpi_ptr_t up,	(r4)
+ *		   mpi_size_t usize,	(r5)
+ *		   unsigned cnt)	(r6)
+ */
+
+	.toc
+.csect	.text[PR]
+	.align	2
+	.globl	_gcry_mpih_rshift
+	.globl	._gcry_mpih_rshift
+	.csect	_gcry_mpih_rshift[DS]
+_gcry_mpih_rshift:
+	.long	._gcry_mpih_rshift,  TOC[tc0],	  0
+	.csect	.text[PR]
+._gcry_mpih_rshift:
+	mtctr	5		# copy size into CTR
+	addi	7,3,-4		# move adjusted res_ptr to free return reg
+	subfic	8,6,32
+	lwz	11,0(4) 	# load first s1 limb
+	slw	3,11,8		# compute function return value
+	bdz	Lend1
+
+Loop:	lwzu	10,4(4)
+	srw	9,11,6
+	slw	12,10,8
+	or	9,9,12
+	stwu	9,4(7)
+	bdz	Lend2
+	lwzu	11,4(4)
+	srw	9,10,6
+	slw	12,11,8
+	or	9,9,12
+	stwu	9,4(7)
+	bdnz	Loop
+
+Lend1:	srw	0,11,6
+	stw	0,4(7)
+	blr
+
+Lend2:	srw	0,10,6
+	stw	0,4(7)
+	blr
+
+#else
+/* Shift a limb right, low level routine.
+   Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.	*/
+
+
+/* INPUT PARAMETERS
+   res_ptr     r3
+   s1_ptr      r4
+   size 	       r5
+   cnt	       r6  */
+
+ENTRY(_gcry_mpih_rshift)
+       mtctr   5	       # copy size into CTR
+       addi    7,3,-4	       # move adjusted res_ptr to free return reg
+       subfic  8,6,32
+       lwz     11,0(4)	       # load first s1 limb
+       slw     3,11,8	       # compute function return value
+       bdz     1f
+
+0:     lwzu    10,4(4)
+       srw     9,11,6
+       slw     12,10,8
+       or      9,9,12
+       stwu    9,4(7)
+       bdz     2f
+       lwzu    11,4(4)
+       srw     9,10,6
+       slw     12,11,8
+       or      9,9,12
+       stwu    9,4(7)
+       bdnz    0b
+
+1:     srw     0,11,6
+       stw     0,4(7)
+       blr
+
+2:     srw     0,10,6
+       stw     0,4(7)
+       blr
+END(_gcry_mpih_rshift)
+#endif
diff --git a/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-sub1.S b/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-sub1.S
new file mode 100644
index 0000000..d612ea8
--- /dev/null
+++ b/libotr/libgcrypt-1.8.7/mpi/powerpc32/mpih-sub1.S
@@ -0,0 +1,133 @@
+/* PowerPC-32  sub_n -- Subtract two limb vectors of the same length > 0
+ *			and store difference in a third limb vector.
+ *
+ *      Copyright (C) 1992, 1994, 1995, 1998,
+ *                    2002 Free Software Foundation, Inc.
+ *
+ * This file is part of Libgcrypt.
+ *
+ * Libgcrypt is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * Libgcrypt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "sysdep.h"
+#include "asm-syntax.h"
+
+
+#ifndef USE_PPC_PATCHES
+
+/*******************
+ *  mpi_limb_t
+ *  _gcry_mpih_sub_n( mpi_ptr_t res_ptr,	(r3)
+ *		   mpi_ptr_t s1_ptr,	(r4)
+ *		   mpi_ptr_t s2_ptr,	(r5)
+ *		   mpi_size_t size)	(r6)
+ */
+
+	.toc
+	.extern _gcry_mpih_sub_n[DS]
+	.extern ._gcry_mpih_sub_n
+.csect [PR]
+	.align 2
+	.globl _gcry_mpih_sub_n
+	.globl ._gcry_mpih_sub_n
+	.csect _gcry_mpih_sub_n[DS]
+_gcry_mpih_sub_n:
+	.long ._gcry_mpih_sub_n, TOC[tc0], 0
+	.csect [PR]
+._gcry_mpih_sub_n:
+	mtctr	6		# copy size into CTR
+	lwz	8,0(4)		# load least significant s1 limb
+	lwz	0,0(5)		# load least significant s2 limb
+	addi	3,3,-4		# offset res_ptr, it is updated before used
+	subfc	7,0,8		# add least significant limbs, set cy
+	bdz	Lend		# If done, skip loop
+Loop:	lwzu	8,4(4)		# load s1 limb and update s1_ptr
+	lwzu	0,4(5)		# load s2 limb and update s2_ptr
+	stwu	7,4(3)		# store previous limb in load latency slot
+	subfe	7,0,8		# add new limbs with cy, set cy
+	bdnz	Loop		# decrement CTR and loop back
+Lend:	stw	7,4(3)		# store ultimate result limb
+	subfe	3,0,0		# load !cy into ...
+	subfic	3,3,0		# ... return value register
+	blr
+
+#else
+/* Subtract two limb vectors of equal, non-zero length for PowerPC.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.	*/
+
+/* mp_limb_t mpn_sub_n (mp_ptr res_ptr, mp_srcptr s1_ptr, mp_srcptr s2_ptr,
+			mp_size_t size)
+   Calculate s1-s2 and put result in res_ptr; return borrow, 0 or 1.  */
+
+/* Note on optimisation: This code is optimal for the 601.  Almost every other
+   possible 2-unrolled inner loop will not be.	Also, watch out for the
+   alignment...  */
+
+EALIGN(_gcry_mpih_sub_n,3,1)
+/* Set up for loop below.  */
+       mtcrf 0x01,%r6
+       srwi. %r7,%r6,1
+       mtctr %r7
+       bt    31,2f
+
+/* Set the carry (clear the borrow).  */
+       subfc %r0,%r0,%r0
+/* Adjust pointers for loop.  */
+       addi  %r3,%r3,-4
+       addi  %r4,%r4,-4
+       addi  %r5,%r5,-4
+       b     0f
+
+2:     lwz   %r7,0(%r5)
+       lwz   %r6,0(%r4)
+       subfc %r6,%r7,%r6
+       stw   %r6,0(%r3)
+	beq   1f
+
+/* Align start of loop to an odd word boundary to guarantee that the
+   last two words can be fetched in one access (for 601).  This turns
+   out to be important.  */
+0:
+       lwz   %r9,4(%r4)
+       lwz   %r8,4(%r5)
+       lwzu  %r6,8(%r4)
+       lwzu  %r7,8(%r5)
+       subfe %r8,%r8,%r9
+       stw   %r8,4(%r3)
+       subfe %r6,%r7,%r6
+       stwu  %r6,8(%r3)
+       bdnz  0b
+/* Return the borrow. */
+1:     subfe %r3,%r3,%r3
+       neg   %r3,%r3
+       blr
+END(_gcry_mpih_sub_n)
+#endif
diff --git a/libotr/libgcrypt-1.8.7/mpi/powerpc32/syntax.h b/libotr/libgcrypt-1.8.7/mpi/powerpc32/syntax.h
new file mode 100644
index 0000000..5d4af9f
--- /dev/null
+++ b/libotr/libgcrypt-1.8.7/mpi/powerpc32/syntax.h
@@ -0,0 +1,75 @@
+/* gmp2-2.0.2-ppc/mpn/powerpc-linux/syntax.h   Tue Oct	6 19:27:01 1998 */
+/* From glibc's sysdeps/unix/sysv/linux/powerpc/sysdep.h */
+
+/* Copyright (C) 1992, 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.	*/
+
+
+#define USE_PPC_PATCHES 1
+
+/* This seems to always be the case on PPC.  */
+#define ALIGNARG(log2) log2
+/* For ELF we need the `.type' directive to make shared libs work right.  */
+#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
+#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
+#define ASM_GLOBAL_DIRECTIVE   .globl
+
+#ifdef __STDC__
+#define C_LABEL(name) C_SYMBOL_NAME(name)##:
+#else
+#define C_LABEL(name) C_SYMBOL_NAME(name)/**/:
+#endif
+
+#ifdef __STDC__
+#define L(body) .L##body
+#else
+#define L(body) .L/**/body
+#endif
+
+/* No profiling of gmp's assembly for now... */
+#define CALL_MCOUNT /* no profiling */
+
+#define        ENTRY(name)				    \
+  ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);		    \
+  ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)	    \
+  .align ALIGNARG(2);					    \
+  C_LABEL(name) 					    \
+  CALL_MCOUNT
+
+#define EALIGN_W_0  /* No words to insert.  */
+#define EALIGN_W_1  nop
+#define EALIGN_W_2  nop;nop
+#define EALIGN_W_3  nop;nop;nop
+#define EALIGN_W_4  EALIGN_W_3;nop
+#define EALIGN_W_5  EALIGN_W_4;nop
+#define EALIGN_W_6  EALIGN_W_5;nop
+#define EALIGN_W_7  EALIGN_W_6;nop
+
+/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
+   past a 2^align boundary.  */
+#define EALIGN(name, alignt, words)			\
+  ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);		\
+  ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)	\
+  .align ALIGNARG(alignt);				\
+  EALIGN_W_##words;					\
+  C_LABEL(name)
+
+#undef END
+#define END(name)		     \
+  ASM_SIZE_DIRECTIVE(name)
+