summaryrefslogtreecommitdiff
path: root/cipher/bithelp.h
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2020-11-07 10:39:25 +0200
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2021-01-20 22:06:07 +0200
commit807827cda3bacf5f475167ee6d34657713111838 (patch)
tree082dac76d33ac3ff94d4deedf9efa142d0359789 /cipher/bithelp.h
parent477355047e5c75ad2b2238a8716e4646b861184c (diff)
downloadlibgcrypt-807827cda3bacf5f475167ee6d34657713111838.tar.gz
cipher/bithelp: use __builtin_ctzl when available
* cipher/bithelp.h (_gcry_ctz64): Use __builtin_ctzl if available. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/bithelp.h')
-rw-r--r--cipher/bithelp.h8
1 files 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);