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 B1484C433EF for ; Thu, 2 Dec 2021 15:34:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359005AbhLBPht (ORCPT ); Thu, 2 Dec 2021 10:37:49 -0500 Received: from brightrain.aerifal.cx ([216.12.86.13]:41928 "EHLO brightrain.aerifal.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358990AbhLBPhr (ORCPT ); Thu, 2 Dec 2021 10:37:47 -0500 Date: Thu, 2 Dec 2021 10:34:23 -0500 From: Rich Felker To: Zack Weinberg Cc: Cyril Hrubis , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, libc-alpha@sourceware.org, ltp@lists.linux.it Subject: Re: [PATCH] uapi: Make __{u,s}64 match {u,}int64_t in userspace Message-ID: <20211202153422.GH7074@brightrain.aerifal.cx> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Rich