]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Require the __builtin functions unconditionally
authorOndřej Surý <ondrej@isc.org>
Tue, 5 Aug 2025 06:19:20 +0000 (08:19 +0200)
committerOndřej Surý <ondrej@isc.org>
Tue, 26 Aug 2025 13:32:53 +0000 (15:32 +0200)
Currently following __builtin functions are used:

    __builtin_add_overflow
    __builtin_mul_overflow
    __builtin_prefetch
    __builtin_sub_overflow
    __builtin_unreachable

These are generally available on our supported platform, and also we use
some of these unconditionally anyway in qp.c.  Thus make the support for
these functions mandatory so we fail early in the 'setup' step.

lib/isc/include/isc/overflow.h
meson.build

index 62727513ad25f7e900919c06214f92c0b4967b81..bd8e4eec737c79085f5a060450506716d0d087cf 100644 (file)
  *     INSIST(!overflow);
  */
 
-#if HAVE_BUILTIN_MUL_OVERFLOW
 #define ISC_OVERFLOW_MUL(a, b, cp) __builtin_mul_overflow(a, b, cp)
-#else
-#define ISC_OVERFLOW_MUL(a, b, cp)                                           \
-       ((ISC_OVERFLOW_UINT_MAX(a) / (b) > (a)) ? (*(cp) = (a) * (b), false) \
-                                               : true)
-#endif
 
-#if HAVE_BUILTIN_ADD_OVERFLOW
 #define ISC_OVERFLOW_ADD(a, b, cp) __builtin_add_overflow(a, b, cp)
-#else
-#define ISC_OVERFLOW_ADD(a, b, cp)                                           \
-       ((ISC_OVERFLOW_UINT_MAX(a) - (b) > (a)) ? (*(cp) = (a) + (b), false) \
-                                               : true)
-#endif
 
-#if HAVE_BUILTIN_SUB_OVERFLOW
 #define ISC_OVERFLOW_SUB(a, b, cp) __builtin_sub_overflow(a, b, cp)
-#else
-#define ISC_OVERFLOW_SUB(a, b, cp)                                           \
-       ((ISC_OVERFLOW_UINT_MIN(a) + (b) < (a)) ? (*(cp) = (a) - (b), false) \
-                                               : true)
-#endif
 
 #define ISC_CHECKED_MUL(a, b)                                      \
        ({                                                         \
index d0ae062092b9627d6fbc6fa2cc7ee6d2cc5b2a96..133e6d1e8fa708aded80002c0b2944199119b2f9 100644 (file)
@@ -316,12 +316,14 @@ endif
 
 foreach fn : [
     '__builtin_add_overflow',
+    '__builtin_expect',
     '__builtin_mul_overflow',
+    '__builtin_prefetch',
     '__builtin_sub_overflow',
     '__builtin_unreachable',
 ]
-    if cc.has_function(fn)
-        config.set('HAVE_@0@'.format(fn.substring(2).to_upper()), 1)
+    if not cc.has_function(fn)
+        error('@0@ support required'.format(fn))
     endif
 endforeach