From ab1bd7688b3bef7b7d5a0edb5d295f6561bc9d92 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sat, 7 Dec 2013 13:45:29 -0500 Subject: [PATCH] ck_internal: Use bsf for bsf_64 if available as a built-in. --- src/ck_internal.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ck_internal.h b/src/ck_internal.h index ecda98f..0f40a5f 100644 --- a/src/ck_internal.h +++ b/src/ck_internal.h @@ -102,6 +102,9 @@ ck_internal_bsf(unsigned long v) CK_CC_INLINE static uint64_t ck_internal_bsf_64(uint64_t v) { +#if defined(__GNUC__) + return __builtin_ffs(v); +#else unsigned int i; const unsigned int s = sizeof(unsigned long) * 8 - 1; @@ -109,6 +112,8 @@ ck_internal_bsf_64(uint64_t v) if (v & (1ULL << (63U - i))) return i; } +#endif /* !__GNUC__ */ return 1; } +