[PATCH 2/2] cipher/bithelp: use __builtin_ctzl when available

Jussi Kivilinna jussi.kivilinna at iki.fi
Tue Jan 19 19:14:01 CET 2021


* cipher/bithelp.h (_gcry_ctz64): Use __builtin_ctzl is available.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 cipher/bithelp.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/cipher/bithelp.h b/cipher/bithelp.h
index 26ef7c35..7793ce7c 100644
--- a/cipher/bithelp.h
+++ b/cipher/bithelp.h
@@ -83,7 +83,7 @@ static inline int
 _gcry_ctz (unsigned int x)
 {
 #if defined (HAVE_BUILTIN_CTZ)
-  return x? __builtin_ctz (x) : 8 * sizeof (x);
+  return x ? __builtin_ctz (x) : 8 * sizeof (x);
 #else
   /* See
    * http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightModLookup
@@ -106,9 +106,11 @@ _gcry_ctz (unsigned int x)
 static inline int
 _gcry_ctz64(u64 x)
 {
-#if defined (HAVE_BUILTIN_CTZ) && SIZEOF_UNSIGNED_INT >= 8
+#if defined (HAVE_BUILTIN_CTZL) && SIZEOF_UNSIGNED_LONG >= 8
+  return x ? __builtin_ctzl (x) : 8 * sizeof (x);
+#elif defined (HAVE_BUILTIN_CTZ) && SIZEOF_UNSIGNED_INT >= 8
 #warning hello
-  return x? __builtin_ctz (x) : 8 * sizeof (x);
+  return x ? __builtin_ctz (x) : 8 * sizeof (x);
 #else
   if ((x & 0xffffffff))
     return _gcry_ctz (x);
-- 
2.27.0




More information about the Gcrypt-devel mailing list