From: Oleg Nesterov <oleg@redhat.com>
To: Chris Li <sparse@chrisli.org>, Luc Van Oostenryck <lucvoo@kernel.org>
Cc: Alexey Gladkov <legion@kernel.org>, linux-sparse@vger.kernel.org
Subject: [PATCH] sparse: predefine __ILP32__ and _ILP32 in 32-bit mode
Date: Fri, 12 Jun 2026 12:27:25 +0200 [thread overview]
Message-ID: <aivfDcM9QctmHBJx@redhat.com> (raw)
Unlike gcc, sparse doesn't define __ILP32__ in 32-bit mode:
$ gcc -dM -E -m32 - </dev/null | grep LP32
#define __ILP32__ 1
#define _ILP32 1
$ ./sparse -dM -E -m32 - </dev/null | grep LP32
$
Because of this, arch/x86/include/uapi/asm/bitsperlong.h
#if defined(__x86_64__) && !defined(__ILP32__)
# define __BITS_PER_LONG 64
#else
# define __BITS_PER_LONG 32
#endif
wrongly defines __BITS_PER_LONG == 64 when sparse inspects the files
in arch/x86/boot/. sparse treats -m16 like -m32 and this is fine for
sparse/semind purposes, but without __ILP32__ the bitsperlong checks
fail. For example, the following command
$ make C=2 CHECK="semind add --"
complains:
./include/asm-generic/bitsperlong.h:23:2: error: Inconsistent word size. Check asm/bitsperlong.h
./include/asm-generic/bitsperlong.h:27:33: error: static assertion failed: "Inconsistent word size. Check asm/bitsperlong.h"
Change predefined_macros() to define __ILP32__ and _ILP32 for both
ARCH_X32 and ARCH_LP32.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
predefine.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/predefine.c b/predefine.c
index 5b0f0caf..28601aba 100644
--- a/predefine.c
+++ b/predefine.c
@@ -209,9 +209,8 @@ void predefined_macros(void)
predefine("__pragma__", 0, NULL);
switch (arch_m64) {
- case ARCH_LP32:
- break;
case ARCH_X32:
+ case ARCH_LP32:
predefine("__ILP32__", 1, "1");
predefine("_ILP32", 1, "1");
break;
--
2.52.0
reply other threads:[~2026-06-12 10:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=aivfDcM9QctmHBJx@redhat.com \
--to=oleg@redhat.com \
--cc=legion@kernel.org \
--cc=linux-sparse@vger.kernel.org \
--cc=lucvoo@kernel.org \
--cc=sparse@chrisli.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.