summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/common-utils.c
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2017-04-04 07:35:52 -0400
committerXavier Hernandez <xhernandez@datalab.es>2017-04-05 02:12:53 -0400
commit1063efeb2275039a75eb6fe5e423845e28098df2 (patch)
tree0c17ea2b1da3b4bb00ec270154b98011c89f149f /libglusterfs/src/common-utils.c
parent6b069086cbee39aec9da77b1831e88fe85258b0f (diff)
build: clang has __builtin_popcount() and __builtin_ffs()
Note: Even though gcc(1) will automatically treat ffs() and popcount() as built-in, calling them explicitly as __builtin in the source helps make it easier to find them. (And if no __builtin_ffs use the one in libc.) Change-Id: Ib74d9b221ff03a01df5ad05907024da1a83a7a88 BUG: 1438772 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com> Reviewed-on: https://review.gluster.org/16993 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jeff@pl.atyp.us> Reviewed-by: Xavier Hernandez <xhernandez@datalab.es>
Diffstat (limited to 'libglusterfs/src/common-utils.c')
-rw-r--r--libglusterfs/src/common-utils.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index bdf340d8612..56f545f28de 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -4616,7 +4616,7 @@ int
gf_bits_count (uint64_t n)
{
int val = 0;
-#ifdef _GNU_SOURCE
+#if defined(__GNUC__) || defined(__clang__)
val = __builtin_popcountll (n);
#else
n -= (n >> 1) & 0x5555555555555555ULL;
@@ -4633,7 +4633,11 @@ gf_bits_count (uint64_t n)
int
gf_bits_index (uint64_t n)
{
- return ffsll(n) - 1;
+#if defined(__GNUC__) || defined(__clang__)
+ return __builtin_ffsll (n) - 1;
+#else
+ return ffsll (n) - 1;
+#endif
}
const char*