Also check for errors in x86_64-xlate.pl.
[oweals/openssl.git] / crypto / bn / asm / s390x-mont.pl
index c2fc5adffe0d145dcb5a4bb15ec2c97c9044cca9..03fd15bbd2d82d67bb99e64d86a0c732e3b69e53 100644 (file)
@@ -1,7 +1,7 @@
 #! /usr/bin/env perl
 # Copyright 2007-2018 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
 # On z990 it was measured to perform 2.6-2.2 times better than
 # compiler-generated code, less for longer keys...
 
-$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 =~ /3[12]/) {
        $SIZE_T=4;
@@ -61,8 +64,7 @@ if ($flavour =~ /3[12]/) {
        $g="g";
 }
 
-while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
-open STDOUT,">$output";
+$output and open STDOUT,">$output";
 
 $stdframe=16*$SIZE_T+4*8;
 
@@ -145,7 +147,7 @@ $code.=<<___;
        lghi    $NHI,0
        alcgr   $NHI,$nhi
 
-       la      $j,8(%r0)       # j=1
+       la      $j,8            # j=1
        lr      $count,$num
 
 .align 16
@@ -197,7 +199,7 @@ $code.=<<___;
        lghi    $NHI,0
        alcgr   $NHI,$nhi
 
-       la      $j,8(%r0)       # j=1
+       la      $j,8            # j=1
        lr      $count,$num
 
 .align 16
@@ -241,7 +243,7 @@ $code.=<<___;
        la      $ap,$stdframe($sp)
        ahi     $num,1          # restore $num, incidentally clears "borrow"
 
-       la      $j,0(%r0)
+       la      $j,0
        lr      $count,$num
 .Lsub: lg      $alo,0($j,$ap)
        lg      $nlo,0($j,$np)
@@ -255,7 +257,7 @@ $code.=<<___;
        lghi    $NHI,-1
        xgr     $NHI,$AHI
 
-       la      $j,0(%r0)
+       la      $j,0
        lgr     $count,$num
 .Lcopy:        lg      $ahi,$stdframe($j,$sp)  # conditional copy
        lg      $alo,0($j,$rp)
@@ -281,4 +283,4 @@ foreach (split("\n",$code)) {
        s/_dswap\s+(%r[0-9]+)/sprintf("rllg\t%s,%s,32",$1,$1) if($SIZE_T==4)/e;
        print $_,"\n";
 }
-close STDOUT;
+close STDOUT or die "error closing STDOUT: $!";