Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2267741imu; Fri, 14 Dec 2018 08:20:05 -0800 (PST) X-Google-Smtp-Source: AFSGD/VXyf3yVKzXB04oLlCdkuDV91oJyznnwYmZByM2wQrS+zyRn2wddcNQrEosSte50VCBd+PF X-Received: by 2002:a63:ef47:: with SMTP id c7mr3290004pgk.386.1544804405134; Fri, 14 Dec 2018 08:20:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544804405; cv=none; d=google.com; s=arc-20160816; b=CmsfXgGsGqBF+TG/HfqTB/CHXUUZ/lLRwVbcoM+tuOfoagf1aDjax9OYVbc/iSrgNc t3cViDchuhPTeT0RkWvc1fYaDtMltwi/IUcVV8a6m0oHjzxYxIjqq6XV25m6Vv1Sjb1n 0SoRz907IRJYfWSpq4kWyItrrGJbY1hYFDh7+0IfxKX5pGc022Qvj8JHHqieI4K7H7LS iu6Iwr0m/ovtIs6+Bh/IQR9RFCz5a8oBA6slWcuxZlZL2An0TLKmIYpQcoG9DFOw8uMV qsBYCns43xECePmtEr+zHTJgtBzKbGBKsYPL3urd+slch1bp4SwbAXBi6CpUWYusL1v0 fNSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=rZFgJmV76iehq5SkqtRqxGJxOjrw+WmSDbAHniyLzFs=; b=JmNcBzkt96bablweIp5vgBsozus5ddZ61ou1srz2ENO+EuKu3VwqZTi7nB4ajwmrKG bQVU8OD5mGUvsCacHwbMCLaHAGSHyM/dVPYmoE3fWhB9Jvf5gZVXDJ7oLVagDbvMaIpw Uh5ZNd4mTSO/coxuv1yIz+u4qRmX58kuhR7KeHfubEGSM8za8+TYQHU4WMbpFUobGDeH 4XrWaK0A6pEKLKwbFHZd6XxOW51tPfAOx6kp+aMpnBzKhIuwlTc5++iOlj43G4FoNURz P8HYVyuIgAe9vdvyqPX38lSQzT+6hrd+6SZ+wn0El/uD4aqKdK5gQZqJ7Qglbn5tVbC/ rgig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 23si4366367pfu.2.2018.12.14.08.19.44; Fri, 14 Dec 2018 08:20:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729952AbeLNQRp (ORCPT + 99 others); Fri, 14 Dec 2018 11:17:45 -0500 Received: from 216-12-86-13.cv.mvl.ntelos.net ([216.12.86.13]:59016 "EHLO brightrain.aerifal.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726520AbeLNQRp (ORCPT ); Fri, 14 Dec 2018 11:17:45 -0500 Received: from dalias by brightrain.aerifal.cx with local (Exim 3.15 #2) id 1gXq9c-0004g6-00; Fri, 14 Dec 2018 16:17:32 +0000 Date: Fri, 14 Dec 2018 11:17:32 -0500 From: Rich Felker To: Bernd Petrovitsch Cc: John Paul Adrian Glaubitz , Andy Lutomirski , X86 ML , LKML , Linux API , "H. Peter Anvin" , Peter Zijlstra , Borislav Petkov , Florian Weimer , Mike Frysinger , "H. J. Lu" , x32@buildd.debian.org, Arnd Bergmann , Will Deacon , Catalin Marinas , Linus Torvalds Subject: Re: Can we drop upstream Linux x32 support? Message-ID: <20181214161732.GY23599@brightrain.aerifal.cx> References: <70bb54b2-8ed3-b5ee-c02d-6ef66c4f27eb@physik.fu-berlin.de> <20181213160242.GV23599@brightrain.aerifal.cx> 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 14, 2018 at 03:13:10PM +0100, Bernd Petrovitsch wrote: > On 13/12/2018 17:02, Rich Felker wrote: > > On Tue, Dec 11, 2018 at 11:29:14AM +0100, John Paul Adrian Glaubitz wrote: > >> I can't say anything about the syscall interface. However, what I do know > >> is that the weird combination of a 32-bit userland with a 64-bit kernel > >> interface is sometimes causing issues. For example, application code usually > >> expects things like time_t to be 32-bit on a 32-bit system. However, this > > IMHO this just historically grown (as in "it has been forever that way" > - it sounds way better in Viennese dialect though;-). > > >> isn't the case for x32 which is why code fails to build. > > > > I don't see any basis for this claim about expecting time_t to be > > 32-bit. I've encountered some programs that "implicitly assume" this > > by virtue of assuming they can cast time_t to long to print it, or > > similar. IIRC this was an issue in busybox at one point; I'm not sure > > if it's been fixed. But any software that runs on non-Linux unices has > > long been corrected. If not, 2038 is sufficiently close that catching > > and correcting any such remaining bugs is more useful than covering > > them up and making the broken code work as expected. > > Yup, unconditionally providing 64bit > time_t/timespec/timeval/...-equivalents with libc and syscall support > also for 32bit architectures (and deprecating all 32bit versions) should > be the way to go. > > FWIW I have > ---- snip ---- > #if defined __x86_64__ > # if defined __ILP32__ // x32 > # define PRI_time_t "lld" // for time_t > # define PRI_nsec_t "lld" // for tv_nsec in struct timespec > # else // x86_64 > # define PRI_time_t "ld" // for time_t > # define PRI_nsec_t "ld" // for tv_nsec in struct timespec > # endif > #else // i[3-6]68 > # define PRI_time_t "ld" // for time_t > # define PRI_nsec_t "ld" // for tv_nsec in struct timespec > #endif > ---- snip ---- > in my userspace code for printf() and friends - I don't know how libc's > react to such a patch (and I don't care for the name of the macros as > long it's obviously clear for which type they are). > I assume/fear we won't get additional modifiers into the relevant > standards for libc types (as they are far more like pid_t, uid_t etc.). > And casting to u/intmaxptr_t to get a defined printf()-modifier doesn't > look appealing to me to "solve" such issues. This is all useless (and wrong since tv_nsec is required to have type long as part of C and POSIX, regardless of ILP32-vs-LP64; that's a bug in glibc's x32). Just do: printf("%jd", (intmax_t)t); Saving 2 or 3 insns (for sign or zero extension) around a call to printf is not going to make any measurable difference to performance or any significant difference to size, and it's immeasurably more readable than the awful PRI* macros and the adjacent-string-concatenation they rely on. Rich