Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Oct 2025 13:01:39 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 53ab85a55408 - main - cross-build: Define __GNUC_PREREQ__ in cdefs.h
Message-ID:  <202510081301.598D1do9008672@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

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

commit 53ab85a55408562690f58788ea8d01c18b79ef5d
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-10-08 12:49:28 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-10-08 12:50:27 +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
---
 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 3f9b7866141f..faad5eccb3af 100644
--- a/tools/build/cross-build/include/common/sys/cdefs.h
+++ b/tools/build/cross-build/include/common/sys/cdefs.h
@@ -270,6 +270,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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202510081301.598D1do9008672>