summaryrefslogtreecommitdiff
path: root/lib/count-trailing-zeros.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/count-trailing-zeros.h')
-rw-r--r--lib/count-trailing-zeros.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/count-trailing-zeros.h b/lib/count-trailing-zeros.h
index 8de0f5b5469..5a8ef563ea2 100644
--- a/lib/count-trailing-zeros.h
+++ b/lib/count-trailing-zeros.h
@@ -30,11 +30,16 @@ _GL_INLINE_HEADER_BEGIN
# define COUNT_TRAILING_ZEROS_INLINE _GL_INLINE
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* Assuming the GCC builtin is BUILTIN and the MSC builtin is MSC_BUILTIN,
expand to code that computes the number of trailing zeros of the local
variable 'x' of type TYPE (an unsigned integer type) and return it
from the current function. */
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) \
+ || (__clang_major__ >= 4)
# define COUNT_TRAILING_ZEROS(BUILTIN, MSC_BUILTIN, TYPE) \
return x ? BUILTIN (x) : CHAR_BIT * sizeof x;
#elif _MSC_VER
@@ -92,7 +97,6 @@ count_trailing_zeros_l (unsigned long int x)
COUNT_TRAILING_ZEROS (__builtin_ctzl, _BitScanForward, unsigned long int);
}
-#if HAVE_UNSIGNED_LONG_LONG_INT
/* Compute and return the number of trailing zeros in X. */
COUNT_TRAILING_ZEROS_INLINE int
count_trailing_zeros_ll (unsigned long long int x)
@@ -100,6 +104,9 @@ count_trailing_zeros_ll (unsigned long long int x)
COUNT_TRAILING_ZEROS (__builtin_ctzll, _BitScanForward64,
unsigned long long int);
}
+
+#ifdef __cplusplus
+}
#endif
_GL_INLINE_HEADER_END