+2020-08-05 Bruno Haible <bruno@clisp.org>
+
+ Use __builtin_clz{,l,ll} with clang, also on Windows.
+ * lib/integer_length.c: With clang, use the GCC built-in, not
+ <intrin.h>.
+ * lib/integer_length_l.c: Likewise.
+ * lib/count-leading-zeros.h (COUNT_LEADING_ZEROS): Use the GCC built-in
+ also on clang.
+ * lib/vasnprintf.c (divide): Likewise.
+
2020-08-04 Paul Eggert <eggert@cs.ucla.edu>
Update srclist.txt as per recent glibc changes
expand to code that computes the number of leading 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_LEADING_ZEROS(BUILTIN, MSC_BUILTIN, TYPE) \
return x ? BUILTIN (x) : CHAR_BIT * sizeof x;
#elif _MSC_VER
#include "float+.h"
-#if defined _MSC_VER
+#if defined _MSC_VER && !(__clang_major__ >= 4)
# include <intrin.h>
#endif
int
integer_length (unsigned int x)
{
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__clang_major__ >= 4)
if (x == 0)
return 0;
else
# define MSVC_BUILTIN _BitScanReverse
#endif
-#if defined _MSC_VER
+#if defined _MSC_VER && !(__clang_major__ >= 4)
# include <intrin.h>
/* Copied from integer_length.c. */
static inline int
int
FUNC (TYPE x)
{
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__clang_major__ >= 4)
if (x == 0)
return 0;
else
mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */
/* Determine s = GMP_LIMB_BITS - integer_length (msd).
Code copied from gnulib's integer_length.c. */
-# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) \
+ || (__clang_major__ >= 4)
s = __builtin_clz (msd);
# else
# if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT