mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Shuah Khan <shuah@kernel.org>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Vincent Dagonneau <v@vda.io>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH] tools/nolibc: ensure fast64 integer types have 64 bits
Date: Sun, 4 Jun 2023 13:59:42 +0200	[thread overview]
Message-ID: <ZHx8rshTueq8V5fC@1wt.eu> (raw)
In-Reply-To: <ZHxsWyTf5K5bJqi8@1wt.eu>

On Sun, Jun 04, 2023 at 12:50:03PM +0200, Willy Tarreau wrote:
> On Tue, May 30, 2023 at 11:18:00AM +0200, Thomas Weißschuh wrote:
> > On 32bit platforms size_t is not enough to represent [u]int_fast64_t.
> > 
> > Fixes: 3e9fd4e9a1d5 ("tools/nolibc: add integer types and integer limit macros")
> > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> > ---
> > Cc: Vincent Dagonneau <v@vda.io>
> > 
> > Note: We could also fall back to compiler-provided data like:
> > 
> > __UINT_FAST{8,16,32,64}_{TYPE,MIN,MAX}__
> 
> I'm fine with the way you did it. I'm wondering how we managed to miss
> this one given the tests in place!

BTW, it failed on 32-bit platforms:

4407 tests passed, 84 skipped, 63 failed
$ grep '^linux_arch\|FAIL' test14.out
linux_arch=i386 qemu_arch=i386 gcc_arch=i386
52 limit_int_fast64_min = -2147483648                           [FAIL]
53 limit_int_fast64_max = 2147483647                            [FAIL]
54 limit_uint_fast64_max = 4294967295                           [FAIL]

The reason is that the constants also have to be adjusted. With the fix
below everything works right:

--- a/tools/include/nolibc/stdint.h
+++ b/tools/include/nolibc/stdint.h
@@ -84,17 +84,17 @@ typedef uint64_t          uintmax_t;
 #define  INT_FAST8_MIN   INT8_MIN
 #define INT_FAST16_MIN   INTPTR_MIN
 #define INT_FAST32_MIN   INTPTR_MIN
-#define INT_FAST64_MIN   INTPTR_MIN
+#define INT_FAST64_MIN   INT64_MIN
 
 #define  INT_FAST8_MAX   INT8_MAX
 #define INT_FAST16_MAX   INTPTR_MAX
 #define INT_FAST32_MAX   INTPTR_MAX
-#define INT_FAST64_MAX   INTPTR_MAX
+#define INT_FAST64_MAX   INT64_MAX
 
 #define  UINT_FAST8_MAX  UINT8_MAX
 #define UINT_FAST16_MAX  SIZE_MAX
 #define UINT_FAST32_MAX  SIZE_MAX
-#define UINT_FAST64_MAX  SIZE_MAX
+#define UINT_FAST64_MAX  UINT64_MAX
 
 #ifndef INT_MIN
 #define INT_MIN          (-__INT_MAX__ - 1)


4470 tests passed, 84 skipped, 0 failed
$ grep '^linux_arch\|fast64' test15.out 
linux_arch=i386 qemu_arch=i386 gcc_arch=i386
52 limit_int_fast64_min = -9223372036854775808                   [OK]
53 limit_int_fast64_max = 9223372036854775807                    [OK]
54 limit_uint_fast64_max = -1                                    [OK]

If you're fine with it, I'll squash it into your patch.

Thanks,
Willy

  reply	other threads:[~2023-06-04 11:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30  9:18 Thomas Weißschuh
2023-06-04 10:50 ` Willy Tarreau
2023-06-04 11:59   ` Willy Tarreau [this message]
2023-06-04 12:03     ` Thomas Weißschuh

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=ZHx8rshTueq8V5fC@1wt.eu \
    --to=w@1wt.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=paulmck@kernel.org \
    --cc=shuah@kernel.org \
    --cc=v@vda.io \
    /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

all inboxes | Powered by JetHome®