~ubuntu-branches/ubuntu/oneiric/gnupg2/oneiric-updates

« back to all changes in this revision

Viewing changes to mpi/powerpc32/mpih-sub1.S

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-10-04 10:25:53 UTC
  • mfrom: (5.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081004102553-fv62pp8dsitxli47
Tags: 2.0.9-3.1
* Non-maintainer upload.
* agent/gpg-agent.c: Deinit the threading library before exec'ing
  the command to run in --daemon mode. And because that still doesn't
  restore the sigprocmask, do that manually. Closes: #499569

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* PowerPC-32  sub_n -- Subtract two limb vectors of the same length > 0
2
 
 *                      and store difference in a third limb vector.
3
 
 *
4
 
 *      Copyright (C) 1992, 1994, 1995, 1998 Free Software Foundation, Inc.
5
 
 *
6
 
 * This file is part of GnuPG.
7
 
 *
8
 
 * GnuPG is free software; you can redistribute it and/or modify
9
 
 * it under the terms of the GNU General Public License as published by
10
 
 * the Free Software Foundation; either version 2 of the License, or
11
 
 * (at your option) any later version.
12
 
 *
13
 
 * GnuPG is distributed in the hope that it will be useful,
14
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
 * GNU General Public License for more details.
17
 
 *
18
 
 * You should have received a copy of the GNU General Public License
19
 
 * along with this program; if not, write to the Free Software
20
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21
 
 */
22
 
 
23
 
#include "sysdep.h"
24
 
#include "asm-syntax.h"
25
 
 
26
 
 
27
 
#ifndef USE_PPC_PATCHES
28
 
 
29
 
/*******************
30
 
 *  mpi_limb_t
31
 
 *  mpihelp_sub_n( mpi_ptr_t res_ptr,   (r3)
32
 
 *                 mpi_ptr_t s1_ptr,    (r4)
33
 
 *                 mpi_ptr_t s2_ptr,    (r5)
34
 
 *                 mpi_size_t size)     (r6)
35
 
 */
36
 
 
37
 
        .toc
38
 
        .extern mpihelp_sub_n[DS]
39
 
        .extern .mpihelp_sub_n
40
 
.csect [PR]
41
 
        .align 2
42
 
        .globl mpihelp_sub_n
43
 
        .globl .mpihelp_sub_n
44
 
        .csect mpihelp_sub_n[DS]
45
 
mpihelp_sub_n:
46
 
        .long .mpihelp_sub_n, TOC[tc0], 0
47
 
        .csect [PR]
48
 
.mpihelp_sub_n:
49
 
        mtctr   6               # copy size into CTR
50
 
        lwz     8,0(4)          # load least significant s1 limb
51
 
        lwz     0,0(5)          # load least significant s2 limb
52
 
        addi    3,3,-4          # offset res_ptr, it is updated before used
53
 
        subfc   7,0,8           # add least significant limbs, set cy
54
 
        bdz     Lend            # If done, skip loop
55
 
Loop:   lwzu    8,4(4)          # load s1 limb and update s1_ptr
56
 
        lwzu    0,4(5)          # load s2 limb and update s2_ptr
57
 
        stwu    7,4(3)          # store previous limb in load latency slot
58
 
        subfe   7,0,8           # add new limbs with cy, set cy
59
 
        bdnz    Loop            # decrement CTR and loop back
60
 
Lend:   stw     7,4(3)          # store ultimate result limb
61
 
        subfe   3,0,0           # load !cy into ...
62
 
        subfic  3,3,0           # ... return value register
63
 
        blr
64
 
 
65
 
#else
66
 
/* Subtract two limb vectors of equal, non-zero length for PowerPC.
67
 
   Copyright (C) 1997 Free Software Foundation, Inc.
68
 
   This file is part of the GNU C Library.
69
 
 
70
 
   The GNU C Library is free software; you can redistribute it and/or
71
 
   modify it under the terms of the GNU Library General Public License as
72
 
   published by the Free Software Foundation; either version 2 of the
73
 
   License, or (at your option) any later version.
74
 
 
75
 
   The GNU C Library is distributed in the hope that it will be useful,
76
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
77
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
78
 
   Library General Public License for more details.
79
 
 
80
 
   You should have received a copy of the GNU Library General Public
81
 
   License along with the GNU C Library; see the file COPYING.LIB.  If not,
82
 
   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83
 
   Boston, MA 02111-1307, USA.  */
84
 
 
85
 
/* mp_limb_t mpn_sub_n (mp_ptr res_ptr, mp_srcptr s1_ptr, mp_srcptr s2_ptr,
86
 
                        mp_size_t size)
87
 
   Calculate s1-s2 and put result in res_ptr; return borrow, 0 or 1.  */
88
 
 
89
 
/* Note on optimisation: This code is optimal for the 601.  Almost every other
90
 
   possible 2-unrolled inner loop will not be.  Also, watch out for the
91
 
   alignment...  */
92
 
 
93
 
EALIGN(mpihelp_sub_n,3,1)
94
 
/* Set up for loop below.  */
95
 
       mtcrf 0x01,%r6
96
 
       srwi. %r7,%r6,1
97
 
       mtctr %r7
98
 
       bt    31,2f
99
 
 
100
 
/* Set the carry (clear the borrow).  */
101
 
       subfc %r0,%r0,%r0
102
 
/* Adjust pointers for loop.  */
103
 
       addi  %r3,%r3,-4
104
 
       addi  %r4,%r4,-4
105
 
       addi  %r5,%r5,-4
106
 
       b     0f
107
 
 
108
 
2:     lwz   %r7,0(%r5)
109
 
       lwz   %r6,0(%r4)
110
 
       subfc %r6,%r7,%r6
111
 
       stw   %r6,0(%r3)
112
 
        beq   1f
113
 
 
114
 
/* Align start of loop to an odd word boundary to guarantee that the
115
 
   last two words can be fetched in one access (for 601).  This turns
116
 
   out to be important.  */
117
 
0:
118
 
       lwz   %r9,4(%r4)
119
 
       lwz   %r8,4(%r5)
120
 
       lwzu  %r6,8(%r4)
121
 
       lwzu  %r7,8(%r5)
122
 
       subfe %r8,%r8,%r9
123
 
       stw   %r8,4(%r3)
124
 
       subfe %r6,%r7,%r6
125
 
       stwu  %r6,8(%r3)
126
 
       bdnz  0b
127
 
/* Return the borrow. */
128
 
1:     subfe %r3,%r3,%r3
129
 
       neg   %r3,%r3
130
 
       blr
131
 
END(mpihelp_sub_n)
132
 
#endif