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.
This commit is contained in:
Ondřej Surý 2025-08-05 08:19:20 +02:00
parent 56704f4bfb
commit 40fda03e50
No known key found for this signature in database
GPG key ID: 2820F37E873DEA41
2 changed files with 4 additions and 20 deletions

View file

@ -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) \
({ \

View 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