Split bignum code out of the sparcv9cap.c
[openssl.git] / crypto / bn / asm / sparcv9-mont.pl
index a0830a07e4de122b56e5bbb42c88e5763efdb39f..ac93ef9ee64205a8e5b11a07f2f90bc5ec722fd4 100644 (file)
@@ -1,7 +1,7 @@
 #! /usr/bin/env perl
-# Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2005-2020 The OpenSSL Project Authors. All Rights Reserved.
 #
-# Licensed under the OpenSSL license (the "License").  You may not use
+# Licensed under the Apache License 2.0 (the "License").  You may not use
 # this file except in compliance with the License.  You can obtain a copy
 # in the file LICENSE in the source distribution or at
 # https://www.openssl.org/source/license.html
@@ -49,8 +49,7 @@
 # module still have hidden potential [see TODO list there], which is
 # estimated to be larger than 20%...
 
-$output = pop;
-open STDOUT,">$output";
+$output = pop and open STDOUT,">$output";
 
 # int bn_mul_mont(
 $rp="%i0";     # BN_ULONG *rp,
@@ -84,7 +83,10 @@ $tpj="%l7";
 $fname="bn_mul_mont_int";
 
 $code=<<___;
-#include "sparc_arch.h"
+#ifndef __ASSEMBLER__
+# define __ASSEMBLER__ 1
+#endif
+#include "crypto/sparc_arch.h"
 
 .section       ".text",#alloc,#execinstr
 
@@ -493,6 +495,9 @@ $code.=<<___;
        mulx    $npj,$mul1,$acc1
        add     $tpj,$car1,$car1
        ld      [$np+$j],$npj                   ! np[j]
+       srlx    $car1,32,$tmp0
+       and     $car1,$mask,$car1
+       add     $tmp0,$sbit,$sbit
        add     $acc0,$car1,$car1
        ld      [$tp+8],$tpj                    ! tp[j]
        add     $acc1,$car1,$car1
@@ -614,4 +619,4 @@ $code.=<<___;
 ___
 $code =~ s/\`([^\`]*)\`/eval($1)/gem;
 print $code;
-close STDOUT;
+close STDOUT or die "error closing STDOUT: $!";