From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by sourceware.org (Postfix) with ESMTPS id 64FCB3858428 for ; Thu, 2 Dec 2021 23:43:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 64FCB3858428 Received: by mail-qv1-xf33.google.com with SMTP id kl8so1136235qvb.3 for ; Thu, 02 Dec 2021 15:43:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=NRHD8v+tRRUHCg4eVJNU2+6QjpHDHulBgn/4Ya8pJhM=; b=5NNgq/v1u5hCJW4r/Ee1Q5f8Zclw4uvxnoOltcUUWUMxaRIBP/k01M/k0kJsFx3Qo+ jcJnWuCtFv+BrflKB9EfwWxn8LGdkzNXdXxaJUb69FLdffKg2cLpJDO9wMzXoiUXAWvN +4AygViDBg5yvfO6XjrgoAO9HCxxHZuulU5PQwlOvv4o5w1uaXY6HUYGMK+m0x64G80V PlJuJQ2pqFtEEyBkEmSocMUgeJ9yx0BIRbdYkvFo5HiPegnLrjC3K6uVrPauJvUoi/c1 dbTEpJkULm6eAUBdLAEu+GwtRjAfP8EMrCNv0RpeWVeoBRbC02p1fiKiD+tbhp96pGh7 GtLQ== X-Gm-Message-State: AOAM531J68CTgLF8MBP+POjOdfgWkJFqIUvPUkU/WOWLPkvgPLT9EJUT bqFLiuLm04b6WIAZKvmdGdOpJw== X-Google-Smtp-Source: ABdhPJx3c5+v5PHgltg8FiV34qsEJ3E0Bw5hri3ElAyjV5b9D6e7I/y3MxZ7ggfYBmxa7XokUXXLXg== X-Received: by 2002:ad4:4752:: with SMTP id c18mr16053040qvx.96.1638488602916; Thu, 02 Dec 2021 15:43:22 -0800 (PST) Received: from ?IPV6:2804:431:c7cb:30f8:3030:59d3:d31c:ed39? ([2804:431:c7cb:30f8:3030:59d3:d31c:ed39]) by smtp.gmail.com with ESMTPSA id o1sm998201qtw.1.2021.12.02.15.43.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Dec 2021 15:43:22 -0800 (PST) Message-ID: <855a47d1-a89c-bbc8-7ddd-b89104c6138a@linaro.org> Date: Thu, 2 Dec 2021 20:43:19 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH] uapi: Make __{u,s}64 match {u,}int64_t in userspace Content-Language: en-US To: Rich Felker , 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 References: <20211202153422.GH7074@brightrain.aerifal.cx> <20211202232954.GI7074@brightrain.aerifal.cx> From: Adhemerval Zanella In-Reply-To: <20211202232954.GI7074@brightrain.aerifal.cx> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Thu, 02 Dec 2021 23:43:25 -0000 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.