mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	"Bernd Schubert" <bernd@bsbernd.com>
Cc: "Miklos Szeredi" <miklos@szeredi.hu>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fuse: uapi: use UAPI types
Date: Tue, 23 Dec 2025 10:23:43 +0100	[thread overview]
Message-ID: <29077ea9-3c6a-442b-9f6d-493da6bf262d@app.fastmail.com> (raw)
In-Reply-To: <20251223092253-6c03d7f4-04c7-4272-a4e8-9e38f41f4dad@linutronix.de>

On Tue, Dec 23, 2025, at 09:37, Thomas Weißschuh wrote:
> On Mon, Dec 22, 2025 at 10:16:39PM +0100, Bernd Schubert wrote:
>
> What about the following aproach:
>
> #if defined(__KERNEL__)
> #include <linux/types.h>
> #elif defined(__linux__)
> #include <linux/types.h>
> #else
> #include <stdint.h>
> typedef uint32_t __u32;
> ...
> #endif
>
> (borrowed from include/uapi/drm/drm.h, the identical #if/#elif branches are
> necessary for unifdef.
>
> This works correctly when (cross-)compiling the kernel itself. It also uses
> the standard UAPI types when used from Linux userspace and also works on
> non-Linux userspace. And the header can still be copied into libfuse as is.

Yes, I think that may be the best we can do here. I was wondering whether
The above can be simplified into '#if defined(__KERNEL__) || defined(__linux__'
but according to 00c9672606f7 ("drm: Untangle __KERNEL__ guards") it needs
to be two separate blocks.


Another header with the same problem is include/uapi/linux/coda.h,
which already has special cases for (at least) djgpp, cygwin and netbsd.
I have no idea if there is any hope of keeping that one generic and
while allowing it to be checked with nolibc. It looks like that one
has already diverged from the userspace version at
https://github.com/cmusatyalab/coda/blob/master/coda-src/kerndep/coda.h
which uses the c99 uint32_t instead of the BSD u_int32_t.

This hack got it to build with nolibc:

--- a/include/uapi/linux/coda.h
+++ b/include/uapi/linux/coda.h
@@ -114,6 +114,12 @@ typedef short                   int16_t;
 typedef unsigned short    u_int16_t;
 typedef int                 int32_t;
 typedef unsigned int      u_int32_t;
+typedef long long           int64_t;
+typedef unsigned long long u_int64_t;
+typedef u_int16_t      u_short;
+typedef unsigned long  u_long;
+typedef u_long ino_t;
+typedef void * caddr_t;
 #endif
 
    Arnd

      reply	other threads:[~2025-12-23  9:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-22  8:06 Thomas Weißschuh
2025-12-22  8:54 ` Arnd Bergmann
2025-12-22 10:10   ` Thomas Weißschuh
2025-12-22 21:16 ` Bernd Schubert
2025-12-23  8:37   ` Thomas Weißschuh
2025-12-23  9:23     ` Arnd Bergmann [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=29077ea9-3c6a-442b-9f6d-493da6bf262d@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=bernd@bsbernd.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=thomas.weissschuh@linutronix.de \
    /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

all inboxes | Powered by JetHome®