From: Kevin Brodsky <kevin.brodsky@arm.com>
To: Andrew Morton <akpm@linux-foundation.org>, Petr Vorel <pvorel@suse.cz>
Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
Masahiro Yamada <masahiroy@kernel.org>,
Sam Ravnborg <sam@ravnborg.org>,
Petr Vorel <petr.vorel@gmail.com>,
Ruben Ayrapetyan <ruben.ayrapetyan@arm.com>
Subject: Re: [PATCH RESEND] uapi/linux/const.h: Prefer ISO-friendly __typeof__
Date: Wed, 12 Apr 2023 15:01:18 +0200 [thread overview]
Message-ID: <b9cbfc6f-11b9-9daf-0c39-c5d6acc067ee@arm.com> (raw)
In-Reply-To: <20230411172408.46a5b13a6cab27dda0c822b2@linux-foundation.org>
On 12/04/2023 02:24, Andrew Morton wrote:
> On Tue, 11 Apr 2023 23:39:46 +0200 Petr Vorel <pvorel@suse.cz> wrote:
>
>>> Hi Kevin,
>>>> typeof is (still) a GNU extension, which means that it cannot be
>>>> used when building ISO C (e.g. -std=c99). It should therefore be
>>>> avoided in uapi headers in favour of the ISO-friendly __typeof__.
>>> IMHO UAPI are built with -std=c90 -Wall -Werror=implicit-function-declaration
>>> (see usr/include/Makefile).
>>> But one or the other, you're right both require __typeof__.
>>> "If you are writing a header file that must work when included in ISO C
>>> programs, write __typeof__ instead of typeof."
>>> https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Typeof.html
>>> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>>> Tested-by: Petr Vorel <pvorel@suse.cz>
>> IMHO problem was introduced when -std=c90 was added (back then the code was in
>> include/uapi/linux/kernel.h).
> Well... what actually _is_ the problem? Presumably build issues under
> some circumstances. Could we please see an instance of those issues
> and a description of the circumstances under which they occur?
This matters from a userspace perspective, not a kernel one. uapi
headers and their contents are expected to be usable in a variety of
situations, and in particular when building ISO C applications (with
-std=c99 or similar).
This particular problem can be reproduced by trying to use the
__ALIGN_KERNEL macro directly in application code, say:
#include <linux/const.h>
int align(int x, int a)
{
return __KERNEL_ALIGN(x, a);
}
and trying to build that with -std=c99.
I do not believe this patch really fixes any other patch:
__ALIGN_KERNEL() has always used typeof, so it has never been
ISO-friendly. d6fc9fcbaa65 ("kbuild: compile-test exported headers to
ensure they are self-contained") could not have spotted this issue,
because the macro is never expanded when simply including uapi headers.
One could consider that 607ca46e97a1 ("UAPI: (Scripted) Disintegrate
include/linux") is the culprit because it moved the macro to
include/uapi as-is, but that's arguable.
>
>> Fixes: d6fc9fcbaa65 ("kbuild: compile-test exported headers to ensure they are self-contained")
> Might need a cc:stable, depending on the answers to the above.
Considering this issue has always been present, I do not believe it is
the case.
Thanks,
Kevin
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
prev parent reply other threads:[~2023-04-12 13:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-11 9:27 [PATCH RESEND] uapi/linux/const.h: Prefer ISO-friendly __typeof__ Kevin Brodsky
2023-04-11 21:05 ` Petr Vorel
2023-04-11 21:39 ` Petr Vorel
2023-04-12 0:24 ` Andrew Morton
2023-04-12 13:01 ` Kevin Brodsky [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=b9cbfc6f-11b9-9daf-0c39-c5d6acc067ee@arm.com \
--to=kevin.brodsky@arm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=petr.vorel@gmail.com \
--cc=pvorel@suse.cz \
--cc=ruben.ayrapetyan@arm.com \
--cc=sam@ravnborg.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox