]> Savannah Git Hosting - gnulib.git/commitdiff
Speed up INT_MULTIPLY_WRAPV on macOS
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 27 Aug 2019 11:23:44 +0000 (04:23 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 27 Aug 2019 11:24:09 +0000 (04:24 -0700)
Assume that __builtin_mul_overflow works OK with Clang on macOS.
Mattias Engdegård says it’s safe to assume the relevant library
is always available there.
* lib/intprops.h (_GL_HAS___builtin_mul_overflow):
New temporary internal macro.
(_GL_HAS_BUILTIN_MUL_OVERFLOW):
No need to work around the Clang bug on macOS.

ChangeLog
lib/intprops.h

index e6f5a096ada11ae5fa15fec4e71839e1087153be..9976e1833b0f136514f0cc39aaadea9a6520eaeb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2019-08-27  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Speed up INT_MULTIPLY_WRAPV on macOS
+       Assume that __builtin_mul_overflow works OK with Clang on macOS.
+       Mattias Engdegård says it’s safe to assume the relevant library
+       is always available there.
+       * lib/intprops.h (_GL_HAS___builtin_mul_overflow):
+       New temporary internal macro.
+       (_GL_HAS_BUILTIN_MUL_OVERFLOW):
+       No need to work around the Clang bug on macOS.
+
 2019-08-25  Paul Eggert  <eggert@cs.ucla.edu>
 
        intprops.h, verify.h: port better to clang
index ffd737028482246f0ffda34b0b3e5774e50435ba..2cb6ada51b4419015eb39a210fbd26500b5beff8 100644 (file)
@@ -31,6 +31,7 @@
 # else
 #  define _GL_HAS___builtin_add_overflow 0
 # endif
+# define _GL_HAS___builtin_mul_overflow _GL_HAS___builtin_add_overflow
 # define _GL_TEMPDEF___has_builtin
 #endif
 
 # define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
 #endif
 
-/* True if __builtin_mul_overflow (A, B, P) works when P is non-null.  */
-#ifdef __clang__
-/* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>.  */
-# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0
+/* True if __builtin_mul_overflow (A, B, P) works when P is non-null.
+   Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>.  */
+#if (__has_builtin (__builtin_mul_overflow) \
+     && (!defined __clang__ || (defined __APPLE__ && defined __MACH__)))
+# define _GL_HAS_BUILTIN_MUL_OVERFLOW 1
 #else
-# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW
+# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0
 #endif
 
 /* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
 #ifdef _GL_TEMPDEF___has_builtin
 # undef __has_builtin
 # undef _GL_HAS___builtin_add_overflow
+# undef _GL_HAS___builtin_mul_overflow
 # undef _GL_TEMPDEF___has_builtin
 #endif