mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* compiler_types.h in UAPI?
@ 2024-05-03 18:57 Andy Shevchenko
  2024-05-03 19:34 ` Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2024-05-03 18:57 UTC (permalink / raw)
  To: David Howells, Arnd Bergmann; +Cc: linux-kernel

Hi!

Today I have stumbled over use of __force and other compiler_types.h related
things in UAPI headers. Can anybody explain to me how do they suppose to work
outside of the kernel? Or did I miss something obvious? Or it was a mistake
during UAPI split to move swab.h and byteorder/ (most of the users of those)
to UAPI in the first place?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: compiler_types.h in UAPI?
  2024-05-03 18:57 compiler_types.h in UAPI? Andy Shevchenko
@ 2024-05-03 19:34 ` Arnd Bergmann
  2024-05-06  8:39   ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2024-05-03 19:34 UTC (permalink / raw)
  To: Andy Shevchenko, David Howells; +Cc: linux-kernel

On Fri, May 3, 2024, at 20:57, Andy Shevchenko wrote:
> Hi!
>
> Today I have stumbled over use of __force and other compiler_types.h related
> things in UAPI headers. Can anybody explain to me how do they suppose to work
> outside of the kernel? Or did I miss something obvious? Or it was a mistake
> during UAPI split to move swab.h and byteorder/ (most of the users of those)
> to UAPI in the first place?

These get stripped out by scripts/headers_install.sh during
the 'make headers_install' stage:

sed -E -e '
        s/([[:space:](])(__user|__force|__iomem)[[:space:]]/\1/g
        s/__attribute_const__([[:space:]]|$)/\1/g
        s@^#include <linux/compiler(|_types).h>@@
        s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g
        s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g
        s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @
' $INFILE > $TMPFILE || exit 1


      Arnd

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: compiler_types.h in UAPI?
  2024-05-03 19:34 ` Arnd Bergmann
@ 2024-05-06  8:39   ` Andy Shevchenko
  2024-05-06  9:57     ` Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2024-05-06  8:39 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: David Howells, linux-kernel

On Fri, May 03, 2024 at 09:34:13PM +0200, Arnd Bergmann wrote:
> On Fri, May 3, 2024, at 20:57, Andy Shevchenko wrote:

> > Today I have stumbled over use of __force and other compiler_types.h related
> > things in UAPI headers. Can anybody explain to me how do they suppose to work
> > outside of the kernel? Or did I miss something obvious? Or it was a mistake
> > during UAPI split to move swab.h and byteorder/ (most of the users of those)
> > to UAPI in the first place?
> 
> These get stripped out by scripts/headers_install.sh during
> the 'make headers_install' stage:
> 
> sed -E -e '
>         s/([[:space:](])(__user|__force|__iomem)[[:space:]]/\1/g
>         s/__attribute_const__([[:space:]]|$)/\1/g
>         s@^#include <linux/compiler(|_types).h>@@
>         s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g
>         s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g
>         s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @
> ' $INFILE > $TMPFILE || exit 1

Thanks, Arnd, TIL!

But do we discourage using these in UAPI in general? I mean do we have
this somewhere being documented?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: compiler_types.h in UAPI?
  2024-05-06  8:39   ` Andy Shevchenko
@ 2024-05-06  9:57     ` Arnd Bergmann
  0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2024-05-06  9:57 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: David Howells, linux-kernel

On Mon, May 6, 2024, at 10:39, Andy Shevchenko wrote:
> On Fri, May 03, 2024 at 09:34:13PM +0200, Arnd Bergmann wrote:
>> On Fri, May 3, 2024, at 20:57, Andy Shevchenko wrote:
>
>> > Today I have stumbled over use of __force and other compiler_types.h related
>> > things in UAPI headers. Can anybody explain to me how do they suppose to work
>> > outside of the kernel? Or did I miss something obvious? Or it was a mistake
>> > during UAPI split to move swab.h and byteorder/ (most of the users of those)
>> > to UAPI in the first place?
>> 
>> These get stripped out by scripts/headers_install.sh during
>> the 'make headers_install' stage:
>> 
>> sed -E -e '
>>         s/([[:space:](])(__user|__force|__iomem)[[:space:]]/\1/g
>>         s/__attribute_const__([[:space:]]|$)/\1/g
>>         s@^#include <linux/compiler(|_types).h>@@
>>         s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g
>>         s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g
>>         s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @
>> ' $INFILE > $TMPFILE || exit 1
>
> Thanks, Arnd, TIL!
>
> But do we discourage using these in UAPI in general? I mean do we have
> this somewhere being documented?

I don't think they are discouraged in uapi headers, since the
annotations tend to be required for clean kernel builds with
sparse.

I could not find any documentation about it though, so it might
be good to mention them in Documentation/dev-tools/sparse.rst.

      Arnd

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-06  9:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-03 18:57 compiler_types.h in UAPI? Andy Shevchenko
2024-05-03 19:34 ` Arnd Bergmann
2024-05-06  8:39   ` Andy Shevchenko
2024-05-06  9:57     ` Arnd Bergmann

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®