compat/posix.h: simplify GIT_GNUC_PREREQ() comparison
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 <sys/cdefs.h> headers, and drop the Linux header attribution comment because it no longer applies. Signed-off-by: Dominik Loidolt <dominik.loidolt@univie.ac.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Dominik Loidolt committed
Jun 13, 2026 at 14:27 UTC
cf48887610da108a3fbc97645e2d2ba2e7178ad0
1 file changed
+2
-2
compat/posix.h
+2
-2
@@ -4,7 +4,6 @@
4
#define _FILE_OFFSET_BITS 64
5
6
/*
7
- * Derived from Linux "Features Test Macro" header
7
* Convenience macros to test the versions of GCC (or a compatible compiler).
8
* Use them like this:
9
* #if GIT_GNUC_PREREQ (2,8)
@@ -19,7 +18,8 @@
18
*/
19
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
20
# define GIT_GNUC_PREREQ(maj, min) \
22
- ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
21
+ ((__GNUC__ > (maj)) || \
22
+ (__GNUC__ == (maj) && __GNUC_MINOR__ >= (min)))
23
#else
24
# define GIT_GNUC_PREREQ(maj, min) 0
25
#endif