lightning
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lightning] [PATCH 1/3] Use GCC builtin ffsl function is the regular one


From: Paul Cercueil
Subject: [Lightning] [PATCH 1/3] Use GCC builtin ffsl function is the regular one is missing
Date: Wed, 25 Sep 2019 00:55:08 +0200

Instead of rewriting a ffsl() function that depends on ffs(), use
__builtin_ffsl() that's provided by GCC.

This fixes the build under MinGW, which doesn't provide neither ffsl()
nor ffs().

Signed-off-by: Paul Cercueil <address@hidden>
---
 lib/jit_ia64-cpu.c | 15 +--------------
 lib/jit_x86-cpu.c  | 21 +--------------------
 2 files changed, 2 insertions(+), 34 deletions(-)

diff --git a/lib/jit_ia64-cpu.c b/lib/jit_ia64-cpu.c
index aa7c6be..cd5e5a3 100644
--- a/lib/jit_ia64-cpu.c
+++ b/lib/jit_ia64-cpu.c
@@ -214,7 +214,7 @@ typedef enum {
 #define stxi(i0,r0,r1)                 stxi_l(i0,r0,r1)
 
 #if !HAVE_FFSL
-static int ffsl(long);
+#  define ffsl(l)                      __builtin_ffsl(l)
 #endif
 
 /* libgcc */
@@ -5391,17 +5391,4 @@ _patch_at(jit_state_t *_jit, jit_code_t code,
     }
     set_bundle(c.p, l, h, tm, s0, s1, s2);
 }
-
-#if !HAVE_FFSL
-static int
-ffsl(long i)
-{
-    int                bit;
-    if ((bit = ffs((int)i)) == 0) {
-       if ((bit = ffs((int)((unsigned long)i >> 32))))
-           bit += 32;
-    }
-    return (bit);
-}
-#endif
 #endif
diff --git a/lib/jit_x86-cpu.c b/lib/jit_x86-cpu.c
index 2fdd115..0a386fd 100644
--- a/lib/jit_x86-cpu.c
+++ b/lib/jit_x86-cpu.c
@@ -686,7 +686,7 @@ static void _patch_at(jit_state_t*, jit_node_t*, 
jit_word_t, jit_word_t);
 #    if __X32
 #      define ffsl(i)                  ffs(i)
 #    else
-static int ffsl(long);
+#      define ffsl(l)                  __builtin_ffsl(l)
 #    endif
 #  endif
 #endif
@@ -3842,23 +3842,4 @@ _patch_at(jit_state_t *_jit, jit_node_t *node,
            break;
     }
 }
-
-#  if __X64 && !defined(HAVE_FFSL)
-static int
-ffsl(long i)
-{
-    int                bit;
-#    if __CYGWIN__
-    /* Bug workaround */
-    if ((int)i == (int)0x80000000)
-       bit = 32;
-    else
-#    endif
-    if ((bit = ffs((int)i)) == 0) {
-       if ((bit = ffs((int)((unsigned long)i >> 32))))
-           bit += 32;
-    }
-    return (bit);
-}
-#  endif
 #endif
-- 
2.23.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]