From 40fda03e5094a416cd864aaaf30883d9f4ac8e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Tue, 5 Aug 2025 08:19:20 +0200 Subject: [PATCH] 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. --- lib/isc/include/isc/overflow.h | 18 ------------------ meson.build | 6 ++++-- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/lib/isc/include/isc/overflow.h b/lib/isc/include/isc/overflow.h index 62727513ad..bd8e4eec73 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 d0ae062092..133e6d1e8f 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