ec/curve448: portability fixups.
authorAndy Polyakov <appro@openssl.org>
Fri, 23 Feb 2018 12:20:33 +0000 (13:20 +0100)
committerAndy Polyakov <appro@openssl.org>
Sat, 24 Feb 2018 13:11:06 +0000 (14:11 +0100)
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 <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5449)

crypto/ec/curve448/curve448.c
crypto/ec/curve448/curve448utils.h

index 7c43a758f91f02afcb055c634444efda1c752379..8ced622b7b4250c39a2a02a38dd8e8c0ab25090d 100644 (file)
@@ -500,7 +500,7 @@ struct smvt_control {
     int power, addend;
 };
 
     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
 # define NUMTRAILINGZEROS      __builtin_ctz
 #else
 # define NUMTRAILINGZEROS      numtrailingzeros
index 4af2c3f12dfc8c94460f160629e82f5a5eae9ee4..9bf837993c94bf900ccd5a7e68553d761927fe76 100644 (file)
@@ -23,7 +23,8 @@
  * with arch_arm32.
  */
 # ifndef C448_WORD_BITS
  * 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 */
 #   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 */