From: Patrick Steinhardt <ps@pks.im>
To: Dominik Loidolt <dominik.loidolt@univie.ac.at>
Cc: git@vger.kernel.org, gitster@pobox.com, asedeno@MIT.EDU,
asedeno@google.com, avarab@gmail.com
Subject: Re: [PATCH v3 2/2] compat/posix.h: simplify GIT_GNUC_PREREQ() comparison
Date: Fri, 12 Jun 2026 15:27:36 +0200 [thread overview]
Message-ID: <aiwJSBfRbUFZ70gP@pks.im> (raw)
In-Reply-To: <20260608124419.38905-2-dominik.loidolt@univie.ac.at>
On Mon, Jun 08, 2026 at 02:44:19PM +0200, Dominik Loidolt wrote:
> Replace the glibc-style bit-shift version comparison with an explicit
> major/minor comparison. This is easier to read and is consistent with
> the format already used by GIT_CLANG_PREREQ() and many BSD
It's a bit funny to use `GIT_CLANG_PREREQ()` as an argument here as
we've just added it in the preceding commit.
> <sys/cdefs.h> headers.
>
> This has no runtime impact, as the macro is evaluated at compile time.
> It is also more future-proof, as it no longer assumes that GCC version
> components stay below 65536.
I feel like all the message needs to say is "let's do it for
consistency, and it's easier to read". That would've been sufficient,
whereas this argument here feels a bit thin.
Doesn't matter much though, and I think ultimately the message is fine
as-is, even though the reasoning is a bit funny.
> diff --git a/compat/posix.h b/compat/posix.h
> index ffdfd91c7b..deefc43f28 100644
> --- a/compat/posix.h
> +++ b/compat/posix.h
> @@ -4,22 +4,24 @@
> #define _FILE_OFFSET_BITS 64
>
> /*
> - * Derived from Linux "Features Test Macro" header
> - * Convenience macros to test the versions of gcc (or
> - * a compatible compiler).
> + * Convenience macros to test the versions of GCC (or a compatible compiler).
> * Use them like this:
> * #if GIT_GNUC_PREREQ (2,8)
> - * ... code requiring gcc 2.8 or later ...
> + * ... code requiring GCC 2.8 or later ...
> * #endif
> *
> + * Note that Clang and other compilers define __GNUC__ for compatibility; use
> + * GIT_CLANG_PREREQ() to check for specific Clang versions.
> + *
> * This macro of course is not part of POSIX, but we need it for the UNUSED
> * macro which is used by some of our POSIX compatibility wrappers.
> -*/
> + */
It would've been nice to either move these changes into a preparatory
commit or at least mention them
> #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
> +# define GIT_GNUC_PREREQ(maj, min) 0
> #endif
The change itself makes sense to me.
I'm not sure myself whether this could use another reroll. It's all just
nits, and the intent is clear enough.
Thanks!
Patrick
next prev parent reply other threads:[~2026-06-12 13:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-03 15:12 [PATCH] compat/posix.h: enable UNUSED warning messages for Clang Dominik Loidolt
2026-05-04 1:10 ` Junio C Hamano
2026-05-04 1:41 ` Junio C Hamano
2026-06-05 8:44 ` Dominik Loidolt
2026-06-05 9:46 ` [PATCH v2] " Dominik Loidolt
2026-06-05 10:40 ` Patrick Steinhardt
2026-06-05 11:50 ` Dominik Loidolt
2026-06-05 13:22 ` Patrick Steinhardt
2026-06-05 15:53 ` Dominik Loidolt
2026-06-08 6:20 ` Patrick Steinhardt
2026-06-08 12:44 ` [PATCH v3 1/2] " Dominik Loidolt
2026-06-08 12:44 ` [PATCH v3 2/2] compat/posix.h: simplify GIT_GNUC_PREREQ() comparison Dominik Loidolt
2026-06-12 13:27 ` Patrick Steinhardt [this message]
2026-06-12 19:04 ` Dominik Loidolt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aiwJSBfRbUFZ70gP@pks.im \
--to=ps@pks.im \
--cc=asedeno@MIT.EDU \
--cc=asedeno@google.com \
--cc=avarab@gmail.com \
--cc=dominik.loidolt@univie.ac.at \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox