From: Dominik Loidolt Date: Sat, 13 Jun 2026 12:27:11 GMT Subject: [PATCH v4 3/3] compat/posix.h: simplify GIT_GNUC_PREREQ() comparison Message-ID: <20260613122711.38662-4-dominik.loidolt@univie.ac.at> In-Reply-To: <20260613122711.38662-1-dominik.loidolt@univie.ac.at> GIT_GNUC_PREREQ() uses a glibc-style bit-shift version comparison, which is harder to read than an explicit major/minor comparison. Use an explicit comparison, as in many BSD headers, and drop the Linux header attribution comment because it no longer applies. Signed-off-by: Dominik Loidolt --- compat/posix.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compat/posix.h b/compat/posix.h index d2de5cedf5..2f01564b0d 100644 --- a/compat/posix.h +++ b/compat/posix.h @@ -4,7 +4,6 @@ #define _FILE_OFFSET_BITS 64 /* - * Derived from Linux "Features Test Macro" header * Convenience macros to test the versions of GCC (or a compatible compiler). * Use them like this: * #if GIT_GNUC_PREREQ (2,8) @@ -19,7 +18,8 @@ */ #if defined(__GNUC__) && defined(__GNUC_MINOR__) # define GIT_GNUC_PREREQ(maj, min) \ - ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) + ((__GNUC__ > (maj)) || \ + (__GNUC__ == (maj) && __GNUC_MINOR__ >= (min))) #else # define GIT_GNUC_PREREQ(maj, min) 0 #endif -- 2.54.0