Don't leak memory on error in PKCS12_key_gen_uni
[openssl.git] / crypto / alphacpuid.pl
1 #! /usr/bin/env perl
2 # Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved.
3 #
4 # Licensed under the OpenSSL license (the "License").  You may not use
5 # this file except in compliance with the License.  You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
8
9
10 $output = pop;
11 open STDOUT,">$stdout";
12
13 print <<'___';
14 .text
15
16 .set    noat
17
18 .globl  OPENSSL_cpuid_setup
19 .ent    OPENSSL_cpuid_setup
20 OPENSSL_cpuid_setup:
21         .frame  $30,0,$26
22         .prologue 0
23         ret     ($26)
24 .end    OPENSSL_cpuid_setup
25
26 .globl  OPENSSL_wipe_cpu
27 .ent    OPENSSL_wipe_cpu
28 OPENSSL_wipe_cpu:
29         .frame  $30,0,$26
30         .prologue 0
31         clr     $1
32         clr     $2
33         clr     $3
34         clr     $4
35         clr     $5
36         clr     $6
37         clr     $7
38         clr     $8
39         clr     $16
40         clr     $17
41         clr     $18
42         clr     $19
43         clr     $20
44         clr     $21
45         clr     $22
46         clr     $23
47         clr     $24
48         clr     $25
49         clr     $27
50         clr     $at
51         clr     $29
52         fclr    $f0
53         fclr    $f1
54         fclr    $f10
55         fclr    $f11
56         fclr    $f12
57         fclr    $f13
58         fclr    $f14
59         fclr    $f15
60         fclr    $f16
61         fclr    $f17
62         fclr    $f18
63         fclr    $f19
64         fclr    $f20
65         fclr    $f21
66         fclr    $f22
67         fclr    $f23
68         fclr    $f24
69         fclr    $f25
70         fclr    $f26
71         fclr    $f27
72         fclr    $f28
73         fclr    $f29
74         fclr    $f30
75         mov     $sp,$0
76         ret     ($26)
77 .end    OPENSSL_wipe_cpu
78
79 .globl  OPENSSL_atomic_add
80 .ent    OPENSSL_atomic_add
81 OPENSSL_atomic_add:
82         .frame  $30,0,$26
83         .prologue 0
84 1:      ldl_l   $0,0($16)
85         addl    $0,$17,$1
86         stl_c   $1,0($16)
87         beq     $1,1b
88         addl    $0,$17,$0
89         ret     ($26)
90 .end    OPENSSL_atomic_add
91
92 .globl  OPENSSL_rdtsc
93 .ent    OPENSSL_rdtsc
94 OPENSSL_rdtsc:
95         .frame  $30,0,$26
96         .prologue 0
97         rpcc    $0
98         ret     ($26)
99 .end    OPENSSL_rdtsc
100
101 .globl  OPENSSL_cleanse
102 .ent    OPENSSL_cleanse
103 OPENSSL_cleanse:
104         .frame  $30,0,$26
105         .prologue 0
106         beq     $17,.Ldone
107         and     $16,7,$0
108         bic     $17,7,$at
109         beq     $at,.Little
110         beq     $0,.Laligned
111
112 .Little:
113         subq    $0,8,$0
114         ldq_u   $1,0($16)
115         mov     $16,$2
116 .Lalign:
117         mskbl   $1,$16,$1
118         lda     $16,1($16)
119         subq    $17,1,$17
120         addq    $0,1,$0
121         beq     $17,.Lout
122         bne     $0,.Lalign
123 .Lout:  stq_u   $1,0($2)
124         beq     $17,.Ldone
125         bic     $17,7,$at
126         beq     $at,.Little
127
128 .Laligned:
129         stq     $31,0($16)
130         subq    $17,8,$17
131         lda     $16,8($16)
132         bic     $17,7,$at
133         bne     $at,.Laligned
134         bne     $17,.Little
135 .Ldone: ret     ($26)
136 .end    OPENSSL_cleanse
137 ___
138 {
139 my ($out,$cnt,$max)=("\$16","\$17","\$18");
140 my ($tick,$lasttick)=("\$19","\$20");
141 my ($diff,$lastdiff)=("\$21","\$22");
142 my ($v0,$ra,$sp,$zero)=("\$0","\$26","\$30","\$31");
143
144 print <<___;
145 .globl  OPENSSL_instrument_bus
146 .ent    OPENSSL_instrument_bus
147 OPENSSL_instrument_bus:
148         .frame  $sp,0,$ra
149         .prologue 0
150         mov     $cnt,$v0
151
152         rpcc    $lasttick
153         mov     0,$diff
154
155         ecb     ($out)
156         ldl_l   $tick,0($out)
157         addl    $diff,$tick,$tick
158         mov     $tick,$diff
159         stl_c   $tick,0($out)
160         stl     $diff,0($out)
161
162 .Loop:  rpcc    $tick
163         subq    $tick,$lasttick,$diff
164         mov     $tick,$lasttick
165
166         ecb     ($out)
167         ldl_l   $tick,0($out)
168         addl    $diff,$tick,$tick
169         mov     $tick,$diff
170         stl_c   $tick,0($out)
171         stl     $diff,0($out)
172
173         subl    $cnt,1,$cnt
174         lda     $out,4($out)
175         bne     $cnt,.Loop
176
177         ret     ($ra)
178 .end    OPENSSL_instrument_bus
179
180 .globl  OPENSSL_instrument_bus2
181 .ent    OPENSSL_instrument_bus2
182 OPENSSL_instrument_bus2:
183         .frame  $sp,0,$ra
184         .prologue 0
185         mov     $cnt,$v0
186
187         rpcc    $lasttick
188         mov     0,$diff
189
190         ecb     ($out)
191         ldl_l   $tick,0($out)
192         addl    $diff,$tick,$tick
193         mov     $tick,$diff
194         stl_c   $tick,0($out)
195         stl     $diff,0($out)
196
197         rpcc    $tick
198         subq    $tick,$lasttick,$diff
199         mov     $tick,$lasttick
200         mov     $diff,$lastdiff
201 .Loop2:
202         ecb     ($out)
203         ldl_l   $tick,0($out)
204         addl    $diff,$tick,$tick
205         mov     $tick,$diff
206         stl_c   $tick,0($out)
207         stl     $diff,0($out)
208
209         subl    $max,1,$max
210         beq     $max,.Ldone2
211
212         rpcc    $tick
213         subq    $tick,$lasttick,$diff
214         mov     $tick,$lasttick
215         subq    $lastdiff,$diff,$tick
216         mov     $diff,$lastdiff
217         cmovne  $tick,1,$tick
218         subl    $cnt,$tick,$cnt
219         s4addq  $tick,$out,$out
220         bne     $cnt,.Loop2
221
222 .Ldone2:
223         subl    $v0,$cnt,$v0
224         ret     ($ra)
225 .end    OPENSSL_instrument_bus2
226 ___
227 }
228
229 close STDOUT;