From: Ondřej Surý Date: Tue, 5 Aug 2025 06:19:20 +0000 (+0200) Subject: Require the __builtin functions unconditionally X-Git-Tag: v9.21.12~23^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40fda03e5094a416cd864aaaf30883d9f4ac8e9f;p=thirdparty%2Fbind9.git Require the __builtin functions unconditionally 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. --- diff --git a/lib/isc/include/isc/overflow.h b/lib/isc/include/isc/overflow.h index 62727513ad2..bd8e4eec737 100644 --- a/lib/isc/include/isc/overflow.h +++ b/lib/isc/include/isc/overflow.h @@ -39,29 +39,11 @@ * 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) \ ({ \ diff --git a/meson.build b/meson.build index d0ae062092b..133e6d1e8fa 100644 --- a/meson.build +++ b/meson.build @@ -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