git: b023724ef4ce - stable/15 - cross-build: Define __GNUC_PREREQ__ in cdefs.h

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 13 Oct 2026 18:29:27 UTC
The branch stable/15 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=b023724ef4ce0420c25bc33778249c2881858c1a

commit b023724ef4ce0420c25bc33778249c2881858c1a
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-10-08 12:49:28 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-10-13 18:26:38 +0000

    cross-build: Define __GNUC_PREREQ__ in cdefs.h
    
    This is required when including stdckdint.h and doesn't seem to be
    provided by older clang.
    
    Reviewed by:    emaste
    Fixes:  7233893e9496 ("lib{c,openbsd}: use ckd_mul() for overflow checking in re(c)allocarray")
    Differential Revision:  https://reviews.freebsd.org/D52933
    (cherry picked from commit 53ab85a55408562690f58788ea8d01c18b79ef5d)
---
 tools/build/cross-build/include/common/sys/cdefs.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/build/cross-build/include/common/sys/cdefs.h b/tools/build/cross-build/include/common/sys/cdefs.h
index 8419b53135f6..c7e453394478 100644
--- a/tools/build/cross-build/include/common/sys/cdefs.h
+++ b/tools/build/cross-build/include/common/sys/cdefs.h
@@ -278,6 +278,16 @@
 #define	__ISO_C_VISIBLE		2011
 #define	__EXT1_VISIBLE		1
 
+/*
+ * Macro to test if we're using a specific version of gcc or later.
+ */
+#if defined(__GNUC__)
+#define	__GNUC_PREREQ__(ma, mi)	\
+	(__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
+#else
+#define	__GNUC_PREREQ__(ma, mi)	0
+#endif
+
 /* Alignment builtins for better type checking and improved code generation. */
 /* Provide fallback versions for other compilers (GCC/Clang < 10): */
 #if !__has_builtin(__builtin_is_aligned)