X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fbn%2Fasm%2Fs390x-mont.pl;h=03fd15bbd2d82d67bb99e64d86a0c732e3b69e53;hb=a21314dbbc56cd30580123d74b3106a628540965;hp=9fd64e81eef36cbde53332d10743b934218530e5;hpb=0ab8fd58e1c3077c1e5e9057b3d73b73b99a843e;p=oweals%2Fopenssl.git diff --git a/crypto/bn/asm/s390x-mont.pl b/crypto/bn/asm/s390x-mont.pl index 9fd64e81ee..03fd15bbd2 100644 --- a/crypto/bn/asm/s390x-mont.pl +++ b/crypto/bn/asm/s390x-mont.pl @@ -1,7 +1,14 @@ -#!/usr/bin/env perl +#! /usr/bin/env perl +# Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. +# +# 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 + # ==================================================================== -# Written by Andy Polyakov for the OpenSSL +# Written by Andy Polyakov for the OpenSSL # project. The module is, however, dual licensed under OpenSSL and # CRYPTOGAMS licenses depending on where you obtain it. For further # details see http://www.openssl.org/~appro/cryptogams/. @@ -44,7 +51,10 @@ # 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; @@ -54,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; @@ -138,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 @@ -190,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 @@ -234,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) @@ -245,16 +254,16 @@ $code.=<<___; brct $count,.Lsub lghi $ahi,0 slbgr $AHI,$ahi # handle upmost carry + lghi $NHI,-1 + xgr $NHI,$AHI - ngr $ap,$AHI - lghi $np,-1 - xgr $np,$AHI - ngr $np,$rp - ogr $ap,$np # ap=borrow?tp:rp - - la $j,0(%r0) + la $j,0 lgr $count,$num -.Lcopy: lg $alo,0($j,$ap) # copy or in-place refresh +.Lcopy: lg $ahi,$stdframe($j,$sp) # conditional copy + lg $alo,0($j,$rp) + ngr $ahi,$AHI + ngr $alo,$NHI + ogr $alo,$ahi _dswap $alo stg $j,$stdframe($j,$sp) # zap tp stg $alo,0($j,$rp) @@ -274,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: $!";