Also check for errors in x86_64-xlate.pl.
[openssl.git] / crypto / aes / asm / aesp8-ppc.pl
index ce3fae0912442d2ce07d9e251bbbcbb6ae434660..7bd5e9e3f0b5fd70146f3bc0345b1ec2d4c7865c 100755 (executable)
 # POWER9[le]   4.02/0.86       0.84    1.05
 # POWER9[be]   3.99/0.78       0.79    0.97
 
-$flavour = shift;
+# $output is the last argument if it looks like a file (it has an extension)
+# $flavour is the first argument if it doesn't look like a file
+$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
+$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
 
 if ($flavour =~ /64/) {
        $SIZE_T =8;
@@ -70,7 +73,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
 ( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
 die "can't locate ppc-xlate.pl";
 
-open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
+open STDOUT,"| $^X $xlate $flavour \"$output\""
+    or die "can't call $xlate: $!";
 
 $FRAME=8*$SIZE_T;
 $prefix="aes_p8";
@@ -1829,7 +1833,7 @@ Lctr32_enc8x_three:
        stvx_u          $out1,$x10,$out
        stvx_u          $out2,$x20,$out
        addi            $out,$out,0x30
-       b               Lcbc_dec8x_done
+       b               Lctr32_enc8x_done
 
 .align 5
 Lctr32_enc8x_two:
@@ -1841,7 +1845,7 @@ Lctr32_enc8x_two:
        stvx_u          $out0,$x00,$out
        stvx_u          $out1,$x10,$out
        addi            $out,$out,0x20
-       b               Lcbc_dec8x_done
+       b               Lctr32_enc8x_done
 
 .align 5
 Lctr32_enc8x_one:
@@ -3804,4 +3808,4 @@ foreach(split("\n",$code)) {
         print $_,"\n";
 }
 
-close STDOUT;
+close STDOUT or die "error closing STDOUT: $!";