[Libreoffice-commits] core.git: config_host/config_global.h.in configure.ac sal/rtl

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 17 13:24:44 UTC 2020


 config_host/config_global.h.in |    1 -
 configure.ac                   |    9 ---------
 sal/rtl/math.cxx               |   11 ++---------
 3 files changed, 2 insertions(+), 19 deletions(-)

New commits:
commit 870ab3b8492fa7d42c56ca09884811fef1695d28
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Apr 17 12:10:00 2020 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Apr 17 15:24:07 2020 +0200

    Just use __builtin_ffs on GCC and Clang
    
    GCC appears to support it at least since <https://gcc.gnu.org/git/
    ?p=gcc.git;a=commit;h=51e2940139d5e3e86590f6e6802ffc3f3010be5b> "Initial
    revision" in 1992, and Clang appears to support it since <https://github.com/
    llvm/llvm-project/commit/d93abc3bb0acdd430839abdd67bd3920fee87bbc> "Implement
    ffs, parity, and popcount builtins" in Clang 2.4.  (And if a build used a
    compiler that does not support it, there would be no guarantee that it would
    support strings.h function ffs from X/Open System Interfaces, either.)
    
    Introducing HAVE_GCC_BUILTIN_FFS in 334a9f16cd1d1f9694f885c759903a41aa3d4833
    "tdf#113211: fix calculations with big integers" appears to be due to a
    misguided recommendation at <https://gerrit.libreoffice.org/c/core/+/43477/4#
    message-899806c724fbdcece0ea9438514a6a5db6a2e645>.
    
    Change-Id: Ib6ee6de548172b3aae25483d03efb86620133933
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92421
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/config_host/config_global.h.in b/config_host/config_global.h.in
index aa5863f73b6a..3f9dded93882 100644
--- a/config_host/config_global.h.in
+++ b/config_host/config_global.h.in
@@ -13,7 +13,6 @@ Any change in this header will cause a rebuild of almost everything.
 #define CONFIG_GLOBAL_H
 
 #define HAVE_GCC_BUILTIN_ATOMIC 0
-#define HAVE_GCC_BUILTIN_FFS 0
 /* _Pragma */
 #define HAVE_GCC_PRAGMA_OPERATOR 0
 #define HAVE_GCC_DEPRECATED_MESSAGE 0
diff --git a/configure.ac b/configure.ac
index 57a243841505..1eb9a1af7898 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6304,15 +6304,6 @@ if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
         AC_MSG_RESULT([no])
     fi
 
-    AC_MSG_CHECKING([whether $CC_BASE supports __builtin_ffs])
-    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return __builtin_ffs(1); ]])],[HAVE_GCC_BUILTIN_FFS=TRUE],[])
-    if test "$HAVE_GCC_BUILTIN_FFS" = "TRUE"; then
-        AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_GCC_BUILTIN_FFS)
-    else
-        AC_MSG_RESULT([no])
-    fi
-
     AC_MSG_CHECKING([whether $CC_BASE supports __attribute__((deprecated(message)))])
     save_CFLAGS=$CFLAGS
     CFLAGS="$CFLAGS -Werror"
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index 099cd3d60578..981009aa036c 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -19,7 +19,6 @@
 
 #include <rtl/math.h>
 
-#include <config_global.h>
 #include <o3tl/safeint.hxx>
 #include <osl/diagnose.h>
 #include <rtl/alloc.h>
@@ -43,10 +42,6 @@
 
 #include <dtoa.h>
 
-#if !HAVE_GCC_BUILTIN_FFS && !defined _WIN32
-    #include <strings.h>
-#endif
-
 static int const n10Count = 16;
 static double const n10s[2][n10Count] = {
     { 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8,
@@ -183,14 +178,12 @@ bool isRepresentableInteger(double fAbsValue)
 // Returns 1-based index of least significant bit in a number, or zero if number is zero
 int findFirstSetBit(unsigned n)
 {
-#if HAVE_GCC_BUILTIN_FFS
-    return __builtin_ffs(n);
-#elif defined _WIN32
+#if defined _WIN32
     unsigned long pos;
     unsigned char bNonZero = _BitScanForward(&pos, n);
     return (bNonZero == 0) ? 0 : pos + 1;
 #else
-    return ffs(n);
+    return __builtin_ffs(n);
 #endif
 }
 


More information about the Libreoffice-commits mailing list