From patchwork Tue Aug 27 17:30:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1153997 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-104772-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="itmc9MB2"; dkim=pass (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="KA7PmLmD"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Hwy70Ws7z9sN4 for ; Wed, 28 Aug 2019 03:35:42 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; q=dns; s=default; b=HDN v2xJHxu50Vy4n5+5/noWEata+J3lMB8KptU9OIfUQ8hioksgsxpkJPcNaV9/KgWx gwZep/tBG1jRKkh9twtVuxVBz2HwuaaCMAyPmuQTqaUe4qp8Onr9BJhdrgY3m3TN 5cKsoy0P0dzUpPQEZtGQe68VhMwGnf31FDzLJEes= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; s=default; bh=WlwoWND2D +1TbYSAwf3mXy+QQYw=; b=itmc9MB21ifuWQM6G0a16BxGJULDljD4PW0XnvqbH qGztWLpS8wjEfhwqdp9jH3prPL+Jo3Fi4c/+xy0pCrvTVIa17V54/gNdBXAKoEki nIhfCvGizrPn+MXHompVdB2s1eLs/VEmmb3MPGTkhBmavP1IIz2Na5YleYU2H8fw 6I= Received: (qmail 78193 invoked by alias); 27 Aug 2019 17:35:37 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 78185 invoked by uid 89); 27 Aug 2019 17:35:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=HX-Envelope-From:prvs, newer, *64, sk:__NR_cl X-HELO: esa1.hgst.iphmx.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1566927335; x=1598463335; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=yBkf2T8iKk+JeTypaOF3yoQklfeYfUEcXgR7sMKntLM=; b=KA7PmLmD+RGLttT2FV9Qwl0d5MJ/0sQjaiBvIqThhJZhoNk1ctGVXp4r SKjz8QHn/2H3smOaCMVCWl62HNv7O4mNkFkAxJdjbR2mClSnfee8TOdPJ xiq5qEZnYRfiZdfpgJBcAH4ebBSM+kLeizZVKV1Nm9FLjT/uXfz56cq+v JJKgyjxLwy41FAp5j9R9id38gi3RHK4p+f3mYJWIjOgLET36wOUvFVAc1 oFcs7aaRV5bL/iQNjnS4S3THFJz1MOoMHOrRdKC26PdZDf+gSU2HQWXW8 o4bWS4dEPTDRZY7iR2YdAkBWWMUV2ZPAja9W2wjycrzUp45JHSafgzB1T w==; IronPort-SDR: 4s+6iDLo45NRHe/vwTZQq2e6DYhwAau2VBlywhRms/ueRvlpRabo1Nha+Q20VrrreW0KsuQ5rF UdI2+9SnQtO9xw+CovN3e7rReGJEtlNBYAxHEpO/mvU0keTEGQkiraRKFeGo9XP2D1DSauykdI UMFNcK4O/LMU3J3oFVrtTaCnJPjMXRdTY2TxORHH30AqYMJjUFeHSruoSxtvqos45gIlZpTBBJ kCM9liOJPFT2rmwOJW2N+YHu56pBXQgTYvIKxebaBSyzvQkoxegDiqD6OJzfXtVrt3QL+ASRhP bZY= IronPort-SDR: 44KFN9rtRnxAvm2l1YklwtSiC3E0xt+oAAaGCW6zLQFahvUgHdE0I7pIGuYbe11zpFXymcQBwQ /Kjl3l8JtdaQJqMIG0M1oTagabFdhmN7S1Hn481JWja3+ZpNQTdi/BdB78k+NcpNTOiEh8co7B Fc8iOK98PiP6dQgI8zidLOwarjtRe+uO586MSrqAX6UcMBOn8Do9VZZyjUmCNycfH1zTIn864s K8TIZJvkU9lDLzd1LdsWVtm/ylfdOvs2iz/FnZF1MUhFYopcjFhh/p9QB4y/Jm4iwr0mZ80yoV 3Af9jZhF7a3wqQ+OwlxM9vpr IronPort-SDR: WJzkqP2deSBHzVNAAIJGanzdaH3e775JphUHYSbBhvC3C5OxQOztAgucc+KyQcerc1THJA4fgh HHggQEGnuc1hdq1eBWbYZ0wd6MHgjcYqXMiu6z7JFXgioE3uXaOLZWhXlax1Ro6LW7SHzsj9Mp kY6omeXQw9++TI5mnMdDeuWUlUq8v3t7LR8l139UOIudKs6GQpY4mUGHYoiObyK+WJuhgKr3JK pfVHWU06UDtKQfhEXfOBVpwVohSyzzzaiFgyXNKcdqRV7zNcXYeiDadqnuzYBwSc6D0mowODYU 6ps= WDCIronportException: Internal From: Alistair Francis To: libc-alpha@sourceware.org Cc: lukma@denx.de, joseph@codesourcery.com, alistair23@gmail.com, Alistair Francis Subject: [PATCH v9] y2038: Introduce the __ASSUME_TIME64_SYSCALLS define Date: Tue, 27 Aug 2019 10:30:15 -0700 Message-Id: <20190827173015.24370-1-alistair.francis@wdc.com> MIME-Version: 1.0 From: Lukasz Majewski The __ASSUME_TIME64_SYSCALLS macro indicates if the Linux kernel provides 64-bit time syscalls. If __ASSUME_TIME64_SYSCALLS is defined glibc will only use the *64/_time64 suffixed syscalls. __ASSUME_TIME64_SYSCALLS is defined when: 1. __WORDSIZE == 64 - 64-bit time and syscalls have previously been supported for 64-bit platforms. 2. __WORDSIZE == 32 - Since kernel 5.1 a new set of 64-bit time syscalls have been added. This provides a 64-bit time ABI to 32-bit userspace applications. List of new syscalls added to v5.1. kernel (they accept data based on struct timespec and timeval with 64 bit tv_sec): clock_gettime64 clock_settime64 clock_adjtime64 clock_getres_time64 clock_nanosleep_time64 timer_gettime64 timer_settime64 timerfd_gettime64 timerfd_settime64 utimensat_time64 pselect6_time64 ppoll_time64 io_pgetevents_time64 recvmmsg_time64 mq_timedsend_time64 mq_timedreceive_time64 semtimedop_time64 rt_sigtimedwait_time64 futex_time64 sched_rr_get_interval_time64 3. __WORDSIZE == 32 && _SYSCALL_WORDSIZE == 64 - a special case for machines with ILP32 data model, but already supporting 64 bit time (the 'x32' architecture to be precise). This flag can be removed when glibc's minimal supported kernel version passes 5.1 as after that all architectures will provide a 64-bit time syscall. * sysdeps/unix/sysv/linux/kernel-features.h: (__ASSUME_TIME64_SYSCALLS): Define. Signed-off-by: Alistair Francis --- v9: - Reword the commit message and code comment sysdeps/unix/sysv/linux/kernel-features.h | 48 +++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 1518bb52287..24939b8603d 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -139,3 +139,51 @@ */ #define __ASSUME_CLONE_DEFAULT 1 + +/* Support for the 64-bit time Linux kernel syscalls. + + This flag indicates support for Linux kernel syscalls using the 64-bit time + ABI. It is defined for all 64-bit architectures as they have always + supported 64-bit time. It is also defined for all 32-bit architectures when + using Linux kernel version 5.1 or newer. + + When the __ASSUME_TIME64_SYSCALLS macro is defined glibc can call, without needing to + check at runtime for ENOSYS errors, the *64/time64 suffixed syscalls. These + should be #defined to the the unsuffixed versions when required (such as + when running on 64-bit systems). + + __ASSUME_TIME64_SYSCALLS macro being defined does not mean that __TIMESIZE is + 64-bit. In cases where the __TIMESIZE is 64-bit the 64-bit syscalls can be + used directly. In cases where __TIMESIZE is 32-bit conversions between the + original 32-bit values and the kernel's 64-bit values will need to occur. + + As an example - the syscall to set clock (clock_settime) - if the + __ASSUME_TIME64_SYSCALLS macro is defined, it indicates that 64-bit time can + be set in the system. + + On systems with __WORDSIZE == 64 the __NR_clock_settime syscall is used + to achieve this goal. Systems with __WORDSIZE == 32 use the + __NR_clock_settime64 syscall available from Linux version 5.1. + + The __ASSUME_TIME64_SYSCALLS macro is defined for: + + 1. 64-bit systems that have always had 64-bit time support (__WORDSIZE == 64). + + 2. For x32 architecture, which is a special case in respect to 64-bit + time support (it has __WORDSIZE==32 but __TIMESIZE==64) + + 3. Systems with __WORDSIZE==32, which gain 64-bit time support + with the syscalls added to Linux kernel 5.1. + + 4. 32-bit architectures for which support was added in Linux 5.1 or later, + or for which the kernel/userspace ABI changed incompatibly in Linux 5.1 + or later so that there are no syscalls using 32-bit time. + */ + +#include +#if (__WORDSIZE == 64 \ + || (__WORDSIZE == 32 \ + && (__LINUX_KERNEL_VERSION >= 0x050100 \ + || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64)))) +# define __ASSUME_TIME64_SYSCALLS 1 +#endif