On 09/11/2022 13:10, Ruben Ayrapetyan wrote:
-----Original Message----- From: Kevin Brodsky kevin.brodsky@arm.com Sent: 09 November 2022 10:48 To: linux-morello@op-lists.linaro.org Cc: Kevin Brodsky Kevin.Brodsky@arm.com; Ruben Ayrapetyan Ruben.Ayrapetyan@arm.com Subject: [PATCH] uapi/linux/const.h: Prefer ISO-friendly __typeof__
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__.
Reported-by: Ruben Ayrapetyan ruben.ayrapetyan@arm.com Signed-off-by: Kevin Brodsky kevin.brodsky@arm.com
I've tried this patch - the related user-space build issue is fixed. Tested-by: Ruben Ayrapetyan ruben.ayrapetyan@arm.com
Thanks for this. Now applied on next.
Kevin
This is really an upstream issue that has gone unnoticed so far, probably because __ALIGN_KERNEL is not widely used. Our recent commit a5cf170fd954 ("uapi: siginfo.h: Modify struct sigevent for PCuABI") revealed it, as it uses __ALIGN_KERNEL in siginfo.h in such a way that the macro is always expanded, so any userspace ISO C/C++ code including siginfo.h gets a build failure.
Thinking about posting this on LKML, any opinion for/against or suggestion?
Thanks, Kevin
include/uapi/linux/const.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/uapi/linux/const.h b/include/uapi/linux/const.h index af2a44c08683..a429381e7ca5 100644 --- a/include/uapi/linux/const.h +++ b/include/uapi/linux/const.h @@ -28,7 +28,7 @@ #define _BITUL(x) (_UL(1) << (x)) #define _BITULL(x) (_ULL(1) << (x)) -#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) +#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1) #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
2.34.1