Package: flint / 2.5.2-19

use_clz_builtins_for_mips.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Author: Dejan Latinovic
Description: Use clz builtins on MIPS
 Without this patch, the flint-arb package FTBFS.
 There is no need to forward a patch already in
 upstream's git!
Forwarded: not-needed

--- flint-2.5.2.orig/longlong.h
+++ flint-2.5.2/longlong.h
@@ -324,6 +324,39 @@
 
 #endif
 
+/* MIPS */
+#if (defined (__mips__) || defined (__arm__))
+
+#ifdef _LONG_LONG_LIMB
+#define count_leading_zeros(count,x)            \
+  do {                                          \
+    FLINT_ASSERT ((x) != 0);                    \
+    (count) = __builtin_clzll (x);              \
+  } while (0)
+#else
+#define count_leading_zeros(count,x)            \
+  do {                                          \
+    FLINT_ASSERT ((x) != 0);                    \
+    (count) = __builtin_clzl (x);               \
+  } while (0)
+#endif
+
+#ifdef _LONG_LONG_LIMB
+#define count_trailing_zeros(count,x)           \
+  do {                                          \
+    FLINT_ASSERT ((x) != 0);                    \
+    (count) = __builtin_ctzll (x);              \
+  } while (0)
+#else
+#define count_trailing_zeros(count,x)           \
+  do {                                          \
+    FLINT_ASSERT ((x) != 0);                    \
+    (count) = __builtin_ctzl (x);               \
+  } while (0)
+#endif
+
+#endif /* MIPS */
+
 #define udiv_qrnnd_int(q, r, n1, n0, d)                                \
   do {									                                      \
     mp_limb_t __d1, __d0, __q1, __q0, __r1, __r0, __m;			        \
@@ -364,6 +397,7 @@
     (r) = __r0;								                                \
   } while (0)
 
+#ifndef count_leading_zeros
 #define count_leading_zeros(count, x)                        \
   do {									                            \
     mp_limb_t __xr = (x);							                \
@@ -386,9 +421,11 @@
 									                                  \
     (count) = GMP_LIMB_BITS + 1 - __a - __flint_clz_tab[__xr >> __a]; \
   } while (0)
+#endif
 
 #if !(GMP_LIMB_BITS == 64 && defined (__ia64))
 
+#ifndef count_trailing_zeros
 #define count_trailing_zeros(count, x)                 \
   do {									                      \
     mp_limb_t __ctz_x = (x);						          \
@@ -397,6 +434,7 @@
     count_leading_zeros (__ctz_c, __ctz_x & -__ctz_x); \
     (count) = GMP_LIMB_BITS - 1 - __ctz_c;	 \
   } while (0)
+#endif
 
 #endif