Hi,

This patch is to sync up include/longlong.h with its glibc peer after the proposed change here:

http://sourceware.org/ml/libc-alpha/2014-01/msg00114.html

The patch defines a number of macros in stdlib/longlong.h to use GCC builtins __builtin_clz* to implement the __clz* and __ctz* functions on AArch64.

OK for the mainline?

Thanks,
Yufeng

include/

        * longlong.h (count_leading_zeros, count_trailing_zeros)
        (COUNT_LEADING_ZEROS_0): Define for aarch64.
diff --git a/include/longlong.h b/include/longlong.h
index 5f00e54..b4c1f400 100644
--- a/include/longlong.h
+++ b/include/longlong.h
@@ -122,6 +122,22 @@ extern const UQItype __clz_tab[256] attribute_hidden;
 #define __AND_CLOBBER_CC , "cc"
 #endif /* __GNUC__ < 2 */
 
+#if defined (__aarch64__)
+
+#if W_TYPE_SIZE == 32
+#define count_leading_zeros(COUNT, X)  ((COUNT) = __builtin_clz (X))
+#define count_trailing_zeros(COUNT, X)   ((COUNT) = __builtin_ctz (X))
+#define COUNT_LEADING_ZEROS_0 32
+#endif /* W_TYPE_SIZE == 32 */
+
+#if W_TYPE_SIZE == 64
+#define count_leading_zeros(COUNT, X)  ((COUNT) = __builtin_clzll (X))
+#define count_trailing_zeros(COUNT, X)   ((COUNT) = __builtin_ctzll (X))
+#define COUNT_LEADING_ZEROS_0 64
+#endif /* W_TYPE_SIZE == 64 */
+
+#endif /* __aarch64__ */
+
 #if defined (__alpha) && W_TYPE_SIZE == 64
 #define umul_ppmm(ph, pl, m0, m1) \
   do {                                                                 \

Reply via email to