From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-4.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 82A111F9F4 for ; Fri, 3 Dec 2021 00:11:39 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A0E783857C6D for ; Fri, 3 Dec 2021 00:11:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0E783857C6D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1638490298; bh=4lwOqAOjiqgPdGNyVJBcnRov6B/MBYi/SQsQ344Kws8=; h=In-Reply-To:References:Date:To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=iCVnSqscpxegZU4j4gEVt6HG2MriUeQvarS8PJuvb7PkMQgPI/gqgy6lLDr8xMpPa tKzY2AkCwp//0ABWE6ZgqZqfKtJZ/IalWFm1yqCh1K1LZlrieUNbQOQumNd+X5YQdC DmMsFWOrPsaqhlpZpQJwKA2mzminyTfwUxmuc88k= Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by sourceware.org (Postfix) with ESMTPS id D8EBF3858400 for ; Fri, 3 Dec 2021 00:11:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D8EBF3858400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 2CFF15C0316; Thu, 2 Dec 2021 19:11:16 -0500 (EST) Received: from imap45 ([10.202.2.95]) by compute5.internal (MEProxy); Thu, 02 Dec 2021 19:11:16 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrieeigddukecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfkggrtghk ucghvghinhgsvghrghdfuceoiigrtghksehofihlfhholhhiohdrohhrgheqnecuggftrf grthhtvghrnhephfeuhfevueffteffgfejtefgkeekheeftdeflefgheffffevheekleef gfehffdunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epiigrtghksehofihlfhholhhiohdrohhrgh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 34AB724A0074; Thu, 2 Dec 2021 19:11:15 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-4458-g51a91c06b2-fm-20211130.004-g51a91c06 Mime-Version: 1.0 Message-Id: <9d24f699-386a-4881-b09a-ebd747310187@www.fastmail.com> In-Reply-To: <855a47d1-a89c-bbc8-7ddd-b89104c6138a@linaro.org> References: <20211202153422.GH7074@brightrain.aerifal.cx> <20211202232954.GI7074@brightrain.aerifal.cx> <855a47d1-a89c-bbc8-7ddd-b89104c6138a@linaro.org> Date: Thu, 02 Dec 2021 19:10:52 -0500 To: "Adhemerval Zanella" , "Rich Felker" Subject: Re: [PATCH] uapi: Make __{u,s}64 match {u,}int64_t in userspace Content-Type: text/plain X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Zack Weinberg via Libc-alpha Reply-To: Zack Weinberg Cc: linux-arch@vger.kernel.org, linux-api@vger.kernel.org, libc-alpha@sourceware.org, linux-kernel@vger.kernel.org, ltp@lists.linux.it Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" On Thu, Dec 2, 2021, at 6:43 PM, Adhemerval Zanella via Libc-alpha wrote: > On 02/12/2021 20:29, Rich Felker wrote: >> 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. > > You are right, the idea is to allow glibc to create and remove internal headers. As a general rule yes, but we could make a deal that some specific bits headers are permanent API for use by things like this. They probably should be less of a dumping ground than bits/types.h though.