From: Andy Polyakov Date: Fri, 23 Feb 2018 12:20:33 +0000 (+0100) Subject: ec/curve448: portability fixups. X-Git-Tag: OpenSSL_1_1_1-pre2~10 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=ae1ffe0f65c460ccdfe5153b96fe9943d7a171b8;hp=e8c42b9888f53ac60f92221da309dc5a2b007cc3 ec/curve448: portability fixups. SPARC condition in __SIZEOF_INT128__==16 is rather performance thing than portability. Even though compiler advertises int128 capability, corresponding operations are inefficient, because they are not directly backed by instruction set. Reviewed-by: Matt Caswell Reviewed-by: Rich Salz Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/5449) --- diff --git a/crypto/ec/curve448/curve448.c b/crypto/ec/curve448/curve448.c index 7c43a758f9..8ced622b7b 100644 --- a/crypto/ec/curve448/curve448.c +++ b/crypto/ec/curve448/curve448.c @@ -500,7 +500,7 @@ struct smvt_control { int power, addend; }; -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) # define NUMTRAILINGZEROS __builtin_ctz #else # define NUMTRAILINGZEROS numtrailingzeros diff --git a/crypto/ec/curve448/curve448utils.h b/crypto/ec/curve448/curve448utils.h index 4af2c3f12d..9bf837993c 100644 --- a/crypto/ec/curve448/curve448utils.h +++ b/crypto/ec/curve448/curve448utils.h @@ -23,7 +23,8 @@ * with arch_arm32. */ # ifndef C448_WORD_BITS -# if defined(__SIZEOF_INT128__) && (__SIZEOF_INT128__ == 16) +# if (defined(__SIZEOF_INT128__) && (__SIZEOF_INT128__ == 16)) \ + && !defined(__sparc__) # define C448_WORD_BITS 64 /* The number of bits in a word */ # else # define C448_WORD_BITS 32 /* The number of bits in a word */