[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=whivBr0xME3h1Po9aJK8FE-+EhmL11ojT6hSLioGr4okw@mail.gmail.com>
Date: Thu, 15 May 2025 15:06:40 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: "H. Peter Anvin" <hpa@...or.com>
Cc: Arnd Bergmann <arnd@...db.de>, LKML <linux-kernel@...r.kernel.org>,
libc-alpha@...rceware.org, linux-arch@...r.kernel.org
Subject: Re: Metalanguage for the Linux UAPI
On Thu, 15 May 2025 at 14:42, H. Peter Anvin <hpa@...or.com> wrote:
>
> Building it on top of sparse might still very well be The Right Thing.
You can look at the 'ctags.c' file in the sparse code, it basically
does a lot of this kind of thing: it parses the file, then walks
through all the symbols and #defines that it found.
It then obviously prints out filenames and line numbers rather than
converting the result into something else, so I'm not claiming it's
useful as-is, but from a "how to parse a file and walk the symbols it
declares" standpoint it does almost everything.
I just tested, and it looks like it hates the kernel headers because
it hasn't been updated to understand about the bitwise type and dies
with a
builtin:0:0: error: unknown symbol __le16 namespace:0 type:13
but when I just made it not die it seems to actually do its thing, and
knows about how sparse considers preprocessor symbols to be symbols
just like C symbols are, just in a different namespace.
Obviously for things like ioctl numbers, you'd need to then make it
also actually *evaluate* the #define etc after you list them. You
could do that in sparse itself, or you could do it by just creating a
list of #define's from within sparse, and then have a separate pass
that evaluates their values. That 'ctags' thing doesn't do any of
that, of course.
Linus
Powered by blists - more mailing lists