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 42211C433EF for ; Tue, 23 Nov 2021 14:19:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237201AbhKWOWJ (ORCPT ); Tue, 23 Nov 2021 09:22:09 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:48879 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229786AbhKWOWG (ORCPT ); Tue, 23 Nov 2021 09:22:06 -0500 Received: from mail-wm1-f41.google.com ([209.85.128.41]) by mrelayeu.kundenserver.de (mreue009 [213.165.67.97]) with ESMTPSA (Nemesis) id 1M2wCi-1mmDme1RqG-003NAJ; Tue, 23 Nov 2021 15:18:56 +0100 Received: by mail-wm1-f41.google.com with SMTP id i12so18887463wmq.4; Tue, 23 Nov 2021 06:18:56 -0800 (PST) X-Gm-Message-State: AOAM533DbjJmQm6ZctWC9Z6vivsKKJQSC1ixiSVsOZnqMFzcTFxkxc9J JHHJ/EEQ4wR46bz4vsB8Yq2xf8NtnO5VqTTg06Q= X-Google-Smtp-Source: ABdhPJy/iu+HUeUW5MAS4aoS4UPs9O0+2rPHcGIO3sxNnrXnPW2hntwc4AmghGSopXx9bjgxeEGyK0ovTBLVT2Rzyac= X-Received: by 2002:a1c:770e:: with SMTP id t14mr3353750wmi.173.1637677135896; Tue, 23 Nov 2021 06:18:55 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Arnd Bergmann Date: Tue, 23 Nov 2021 15:18:39 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] uapi: Make __{u,s}64 match {u,}int64_t in userspace To: Cyril Hrubis Cc: Arnd Bergmann , Linux Kernel Mailing List , Linux API , LTP List , GNU C Library , linux-arch Content-Type: text/plain; char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sD0FyZXoewYWTy7N7MdAc84Aa6xiOP9Nyl6/E kmVUxvOniABpqgcw6j5tT8YdzTXDzushHbWCCJ6A2cElaHZRZs= Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 23, 2021 at 10:14 AM Cyril Hrubis wrote: > > I don't think this is correct on all 64-bit architectures, as far as I > > remember the > > definition can use either 'long' or 'long long' depending on the user space > > toolchain. > > As far as I can tell the userspace bits/types.h does exactly the same > check in order to define uint64_t and int64_t, i.e.: > > #if __WORDSIZE == 64 > typedef signed long int __int64_t; > typedef unsigned long int __uint64_t; > #else > __extension__ typedef signed long long int __int64_t; > __extension__ typedef unsigned long long int __uint64_t; > #endif > > The macro __WORDSIZE is defined per architecture, and it looks like the > defintions in glibc sources in bits/wordsize.h match the uapi > asm/bitsperlong.h. But I may have missed something, the code in glibc is > not exactly easy to read. It's possible that the only difference between the two files was the '__u32'/'__s32' definition, which could be either 'int' or 'long'. We used to try matching the user space types for these, but not use 'int' everywhere in the kernel. > > Out of the ten supported 64-bit architectures, there are four that already > > use asm-generic/int-l64.h conditionally, and six that don't, and I > > think at least > > some of those are intentional. > > > > I think it would be safer to do this one architecture at a time to make > > sure this doesn't regress on those that require the int-ll64.h version. > > I'm still trying to understand what exactly can go wrong here. As long > as __BITS_PER_LONG is correctly defined the __u64 and __s64 will be > correctly sized as well. The only visible change is that one 'long' is > dropped from the type when it's not needed. Correct, I'm not worried about getting incorrectly-sized types here, but using the wrong type can cause compile-time warnings when they are mismatched against format strings or assigning pointers to the wrong types. With the kernel types, one would always use %d for __u32 and %lld for __u64, while with the user space types, one has to resort to using macros. Arnd