Re: [PATCH] LoongArch: ptrace: Use UAPI types in UAPI header

From: Thomas Weißschuh

Date: Sat Nov 08 2025 - 05:09:05 EST


On 2025-11-03 17:38:49+0800, Huacai Chen wrote:
> On Mon, Nov 3, 2025 at 5:27 PM Thomas Weißschuh <linux@xxxxxxxxxxxxxx> wrote:
> > On 2025-11-03 17:12:58+0800, Huacai Chen wrote:
> > > On Wed, Oct 29, 2025 at 11:20 PM Thomas Weißschuh <linux@xxxxxxxxxxxxxx> wrote:
> > > >
> > > > The kernel UAPI headers already contain fixed-width integer types,
> > > > there is no need to rely on libc types. There may not be a libc
> > > > available or it may not provide <stdint.h>, like for example on nolibc.
> > > >
> > > > This also aligns the header with the rest of the LoongArch UAPI headers.
> >
> > > Thank you for your patch, but could you please tell me some history
> > > and user guide about the three styles: u64, __u64 and unint64_t?
> >
> > uint64_t -> userspace type, should not be used within the kernel
> > can technically be used in UAPI it will be somewhat
> > nonstandard and introduce a dependency on libc with no
> > upsides.
> But a simple grep shows there are many uses of uint64_t in the kernel
> code, are they all wrong?

Yes, they are wrong. See also the explanation from Arnd.

> > u64 -> kernel-internal type, used for regular kernel code
> > defined in include/linux/types.h
> >
> > __u64 -> UAPI type usable from both kernel and userspace code
> > defined in include/uapi/linux/types.
> >
> > As a note: When applying the patch I want to clarify the commit message
> > a bit, as nolibc indeed has a stdint.h header. The real breakage comes
> > from a validation step we perform which does not add the libc include
> > directory to the include path.