Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9428CC433FE for ; Thu, 2 Dec 2021 23:29:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358833AbhLBXdT (ORCPT ); Thu, 2 Dec 2021 18:33:19 -0500 Received: from brightrain.aerifal.cx ([216.12.86.13]:42146 "EHLO brightrain.aerifal.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbhLBXdS (ORCPT ); Thu, 2 Dec 2021 18:33:18 -0500 Date: Thu, 2 Dec 2021 18:29:54 -0500 From: Rich Felker To: Zack Weinberg Cc: linux-arch@vger.kernel.org, libc-alpha@sourceware.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, ltp@lists.linux.it Subject: Re: [PATCH] uapi: Make __{u,s}64 match {u,}int64_t in userspace Message-ID: <20211202232954.GI7074@brightrain.aerifal.cx> References: <20211202153422.GH7074@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211202153422.GH7074@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 02, 2021 at 10:34:23AM -0500, Rich Felker wrote: > On Mon, Nov 22, 2021 at 10:19:59PM +0000, Zack Weinberg via Libc-alpha wrote: > > On Mon, Nov 22, 2021, at 4:43 PM, Cyril Hrubis wrote: > > > This changes the __u64 and __s64 in userspace on 64bit platforms from > > > long long (unsigned) int to just long (unsigned) int in order to match > > > the uint64_t and int64_t size in userspace. > > .... > > > + > > > +#include > > > + > > > /* > > > - * int-ll64 is used everywhere now. > > > + * int-ll64 is used everywhere in kernel now. > > > */ > > > -#include > > > +#if __BITS_PER_LONG == 64 && !defined(__KERNEL__) > > > +# include > > > +#else > > > +# include > > > +#endif > > > > I am all for matching __uN / __sN to uintN_t / intN_t in userspace, but may I suggest the technically simpler and guaranteed-to-be-accurate > > > > /* > > - * int-ll64 is used everywhere now. > > + * int-ll64 is used everywhere in kernel now. > > + * In user space match . > > */ > > +#ifdef __KERNEL__ > > # include > > +#elif __has_include () > > +# include > > +typedef __int8_t __s8; > > +typedef __uint8_t __u8; > > +typedef __int16_t __s16; > > +typedef __uint16_t __u16; > > +typedef __int32_t __s32; > > +typedef __uint32_t __u32; > > +typedef __int64_t __s64; > > +typedef __uint64_t __u64; > > +#else > > +# include > > +typedef int8_t __s8; > > +typedef uint8_t __u8; > > +typedef int16_t __s16; > > +typedef uint16_t __u16; > > +typedef int32_t __s32; > > +typedef uint32_t __u32; > > +typedef int64_t __s64; > > +typedef uint64_t __u64; > > +#endif > > > > The middle clause could be dropped if we are okay with all uapi > > headers potentially exposing the non-implementation-namespace names > > defined by . I do not know what the musl libc equivalent > > of is. > > We (musl) don't have an equivalent header or __-prefixed versions of > these types. > > FWIW I don't think stdint.h exposes anything that would be problematic > alongside arbitrary use of kernel headers. Also, per glibc's bits/types.h: /* * Never include this file directly; use instead. */ it's not permitted (not supported usage) to #include . So I think the above patch is wrong for glibc too. As I understand it, this is general policy for bits/* -- they're only intended to work as included by the libc system headers, not directly by something else. Rich