diff options
author | Kaleb S. KEITHLEY <kkeithle@redhat.com> | 2017-04-04 07:35:52 -0400 |
---|---|---|
committer | Xavier Hernandez <xhernandez@datalab.es> | 2017-04-05 02:12:53 -0400 |
commit | 1063efeb2275039a75eb6fe5e423845e28098df2 (patch) | |
tree | 0c17ea2b1da3b4bb00ec270154b98011c89f149f | |
parent | 6b069086cbee39aec9da77b1831e88fe85258b0f (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>
-rw-r--r-- | libglusterfs/src/common-utils.c | 8 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-helpers.c | 2 |
2 files changed, 7 insertions, 3 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* diff --git a/xlators/cluster/ec/src/ec-helpers.c b/xlators/cluster/ec/src/ec-helpers.c index 751d45a63f6..4e9771f5308 100644 --- a/xlators/cluster/ec/src/ec-helpers.c +++ b/xlators/cluster/ec/src/ec-helpers.c @@ -102,7 +102,7 @@ int32_t ec_bits_consume(uint64_t * n) tmp &= -tmp; *n ^= tmp; - return ffsll(tmp) - 1; + return gf_bits_index(tmp); } size_t ec_iov_copy_to(void * dst, struct iovec * vector, int32_t count, |