From: Andrew Jones <andrew.jones@linux.dev>
To: Mathias Krause <minipli@grsecurity.net>
Cc: Thomas Huth <thuth@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org
Subject: Re: [kvm-unit-tests PATCH] lib: make limits.h more Clang friendly
Date: Tue, 16 Sep 2025 08:16:43 -0500 [thread overview]
Message-ID: <20250916-bf9bec5dc6fa08a183dff78f@orel> (raw)
In-Reply-To: <20250915221241.372800-1-minipli@grsecurity.net>
On Tue, Sep 16, 2025 at 12:12:41AM +0200, Mathias Krause wrote:
> Clang doesn't define the __${FOO}_WIDTH__ preprocessor defines, breaking
> the build for, at least, the ARM target.
>
> Switch over to use __SIZEOF_${FOO}__ instead which both, gcc and Clang
> do define accordingly.
>
> Signed-off-by: Mathias Krause <minipli@grsecurity.net>
> ---
> lib/limits.h | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/lib/limits.h b/lib/limits.h
> index 650085c68e5d..5106e73dd5a2 100644
> --- a/lib/limits.h
> +++ b/lib/limits.h
> @@ -12,29 +12,29 @@
> # endif
> #endif
>
> -#if __SHRT_WIDTH__ == 16
> +#if __SIZEOF_SHORT__ == 2
> # define SHRT_MAX __INT16_MAX__
> # define SHRT_MIN (-SHRT_MAX - 1)
> # define USHRT_MAX __UINT16_MAX__
> #endif
>
> -#if __INT_WIDTH__ == 32
> +#if __SIZEOF_INT__ == 4
> # define INT_MAX __INT32_MAX__
> # define INT_MIN (-INT_MAX - 1)
> # define UINT_MAX __UINT32_MAX__
> #endif
>
> -#if __LONG_WIDTH__ == 64
> +#if __SIZEOF_LONG__ == 8
> # define LONG_MAX __INT64_MAX__
> # define LONG_MIN (-LONG_MAX - 1)
> # define ULONG_MAX __UINT64_MAX__
> -#elif __LONG_WIDTH__ == 32
> +#elif __SIZEOF_LONG__ == 4
> # define LONG_MAX __INT32_MAX__
> # define LONG_MIN (-LONG_MAX - 1)
> # define ULONG_MAX __UINT32_MAX__
> #endif
>
> -#if __LONG_LONG_WIDTH__ == 64
> +#if __SIZEOF_LONG_LONG__ == 8
> # define LLONG_MAX __INT64_MAX__
> # define LLONG_MIN (-LLONG_MAX - 1)
> # define ULLONG_MAX __UINT64_MAX__
> --
> 2.47.3
>
Merged.
Thanks,
drew
prev parent reply other threads:[~2025-09-16 13:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-15 22:12 [kvm-unit-tests PATCH] lib: make limits.h more Clang friendly Mathias Krause
2025-09-16 13:16 ` Andrew Jones [this message]
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=20250916-bf9bec5dc6fa08a183dff78f@orel \
--to=andrew.jones@linux.dev \
--cc=kvm@vger.kernel.org \
--cc=minipli@grsecurity.net \
--cc=pbonzini@redhat.com \
--cc=thuth@redhat.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