From patchwork Wed Feb 28 08:45:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Chestnykh X-Patchwork-Id: 1905614 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=fMj6EJbl; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=uclibc-ng.org (client-ip=2a00:1828:2000:679::23; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=patchwork.ozlabs.org) Received: from helium.openadk.org (helium.openadk.org [IPv6:2a00:1828:2000:679::23]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tl7Gz2R7fz23qX for ; Wed, 28 Feb 2024 19:45:44 +1100 (AEDT) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id C34FB353075D; Wed, 28 Feb 2024 09:45:28 +0100 (CET) Authentication-Results: helium.openadk.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=fMj6EJbl; dkim-atps=neutral Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) by helium.openadk.org (Postfix) with ESMTPS id DA676353075C for ; Wed, 28 Feb 2024 09:45:20 +0100 (CET) Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2d236ae4f45so13452171fa.0 for ; Wed, 28 Feb 2024 00:45:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709109919; x=1709714719; darn=uclibc-ng.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=x0ro4Y4DGVj2kQT/XBQQ1gsbNbcRu18HrgNqXUko4+g=; b=fMj6EJblFGvYhoZTzPCP70Zrq8XVc44aB5Gpdjq31vo4JGfe/7h/mfl4DKbt2NYV8j P77FMlFHz4WHYnUD4mSDfshLUjRntZ2QIaX2EIxycMp85JHTHsyBSMuiqpghWecFr698 I+6f8ePxIyNVUUJs7f8DlAvf5MbqchUpjg6owkytWBEQO6CzDEZuSvmiJFmSRMGAgpcH LtMjqjz/hzofwsXnNf29DcrCki9o61o0YiAESyfFyHyd9+KypRlTYQB2mnjncG7KRQ5K xg66+ZF7AjR0WDXYIlyWRBbGPa2Qe5yLM2XQ/Cj9RsybSQ0cl9dhSUm3WDJr82ejfevf gxaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709109919; x=1709714719; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=x0ro4Y4DGVj2kQT/XBQQ1gsbNbcRu18HrgNqXUko4+g=; b=g7lUOe9sHTEyRHIo6T3pjFO+mOPIfkdZxmGCUUNW0ynC1Ls8amb5NPNrCOPo+KceDw B4uN9luZdGFdpjzVlYyk9VHdXv50q9ojSBGU//WHAjqW9dmGcuA2sWHqm/sAUon1DwAZ mz3u6B2UZeBY9TjXeCNYitDDMOrTLzDyjog1lK9fWEBni2g1F4VeZp927hDAP0TUBQEa gSI/QdYDfrwiNaRtF3cZJtdoX3f/DzCteontQdlMdaE2bfRhLtAOH5jn/x4r8BSCKiYJ ByHmuArPPMr2Hk9zAVb+ky+f3/r2+dl+HnIUc4HnZkUyZHHjHvq1JdruvkF7m9U7RaPD xTEQ== X-Gm-Message-State: AOJu0Ywk0LAJuOl4IdKbliFH1IxTTu9bStF8UUyNoqp5se831wAcouLs jBio7iTZegnCQnbpSUv2qUAtjMshCY8qFSdPIW9DYiZBDq8LGFPQ7laeJcVI X-Google-Smtp-Source: AGHT+IG9sPktj3S6kTfX3vDrwXn84t37lNpE4q+tmXMSwul1wDEfzNddeC6U7//GJZPzUCAwjPULxA== X-Received: by 2002:a2e:8784:0:b0:2d2:3d37:c9e1 with SMTP id n4-20020a2e8784000000b002d23d37c9e1mr7018233lji.4.1709109919109; Wed, 28 Feb 2024 00:45:19 -0800 (PST) Received: from localhost.localdomain ([2a00:1370:817a:d2b8:9296:d6ce:150d:51eb]) by smtp.gmail.com with ESMTPSA id v17-20020a2e87d1000000b002d2c0d2df05sm176544ljj.48.2024.02.28.00.45.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 00:45:18 -0800 (PST) From: Dmitry Chestnykh To: devel@uclibc-ng.org Date: Wed, 28 Feb 2024 11:45:07 +0300 Message-ID: <20240228084509.2212329-1-dm.chestnykh@gmail.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Message-ID-Hash: STZM6G7IIDJ5X5YOPRNE67IMHOVPQ2LG X-Message-ID-Hash: STZM6G7IIDJ5X5YOPRNE67IMHOVPQ2LG X-MailFrom: dm.chestnykh@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Dmitry Chestnykh X-Mailman-Version: 3.3.3 Precedence: list Subject: [uclibc-ng-devel] [PATCH 1/3] ldso: Use statx() when time64 is enabled. List-Id: uClibc-ng Development Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Dmitry Chestnykh --- ldso/include/dl-syscall.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h index 2e8bb3630..666a7c693 100644 --- a/ldso/include/dl-syscall.h +++ b/ldso/include/dl-syscall.h @@ -20,7 +20,7 @@ extern int _dl_errno; #define _SYS_MMAN_H 1 #include -#ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__ +#if defined(__ARCH_HAS_DEPRECATED_SYSCALLS__) && !defined(__UCLIBC_USE_TIME64__) /* Pull in whatever this particular arch's kernel thinks the kernel version of * struct stat should look like. It turns out that each arch has a different * opinion on the subject, and different kernel revs use different names... */ @@ -116,7 +116,7 @@ static __always_inline _syscall3(unsigned long, _dl_read, int, fd, static __always_inline _syscall3(int, _dl_mprotect, const void *, addr, unsigned long, len, int, prot) -#if defined __NR_fstatat64 && !defined __NR_stat +#if defined __NR_fstatat64 && !defined __NR_stat && !defined(__UCLIBC_USE_TIME64__) # define __NR__dl_fstatat64 __NR_fstatat64 static __always_inline _syscall4(int, _dl_fstatat64, int, fd, const char *, fn, struct stat *, stat, int, flags) @@ -126,7 +126,7 @@ static __always_inline int _dl_stat(const char *file_name, { return _dl_fstatat64(AT_FDCWD, file_name, buf, 0); } -#elif defined __NR_newfstatat && !defined __NR_stat +#elif defined __NR_newfstatat && !defined __NR_stat && !defined(__UCLIBC_USE_TIME64__) # define __NR__dl_newfstatat __NR_newfstatat static __always_inline _syscall4(int, _dl_newfstatat, int, fd, const char *, fn, struct stat *, stat, int, flags) @@ -136,7 +136,7 @@ static __always_inline int _dl_stat(const char *file_name, { return _dl_newfstatat(AT_FDCWD, file_name, buf, 0); } -#elif defined __NR_stat +#elif defined __NR_stat && !defined(__UCLIBC_USE_TIME64__) # define __NR__dl_stat __NR_stat static __always_inline _syscall2(int, _dl_stat, const char *, file_name, struct stat *, buf) @@ -160,7 +160,7 @@ static __always_inline int _dl_stat(const char *file_name, } #endif -#if defined __NR_fstat64 && !defined __NR_fstat +#if defined __NR_fstat64 && !defined __NR_fstat && !defined(__UCLIBC_USE_TIME64__) # define __NR__dl_fstat __NR_fstat64 static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf) #elif defined __NR_fstat @@ -168,7 +168,7 @@ static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf) static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf) #elif defined __NR_statx && defined __UCLIBC_HAVE_STATX__ # define __NR__dl_fstatx __NR_statx -static __always_inline _syscall5(int, _dl_fstatx, int, fd, const char *, file_name, int, flags, unsigned int, mask, struct stat *, buf); +static __always_inline _syscall5(int, _dl_fstatx, int, fd, const char *, file_name, int, flags, unsigned int, mask, struct statx *, buf); static __always_inline int _dl_fstat(int fd, struct stat *buf) From patchwork Wed Feb 28 08:45:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Chestnykh X-Patchwork-Id: 1905613 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=MlHAdxaa; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=uclibc-ng.org (client-ip=2a00:1828:2000:679::23; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=patchwork.ozlabs.org) Received: from helium.openadk.org (helium.openadk.org [IPv6:2a00:1828:2000:679::23]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tl7Gz2Nlxz23qW for ; Wed, 28 Feb 2024 19:45:45 +1100 (AEDT) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id F00503530769; Wed, 28 Feb 2024 09:45:29 +0100 (CET) Authentication-Results: helium.openadk.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=MlHAdxaa; dkim-atps=neutral Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by helium.openadk.org (Postfix) with ESMTPS id E75CB353075D for ; Wed, 28 Feb 2024 09:45:22 +0100 (CET) Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2d230b90040so12350601fa.0 for ; Wed, 28 Feb 2024 00:45:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709109921; x=1709714721; darn=uclibc-ng.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PcEtWOhQTtJCqkpSDk1ZnCpivx0H1TywJJZGbN1kJuo=; b=MlHAdxaac+l/Tt/0sO7BmwZJsftWVlDGcGsWD2LdM8D1C2raajl6l/3xUGgCvvQ+mZ yr/fVU90Tf5nUkKG3HBFhFT6EAa4F51Of04jSshjuWQfzAuSaVLZLAioVURdDzIOL+PH PIdZrg1aadOOF6F/ZIMq6aCm8iSlia4M4PfvefvHWX+TanL9WiRMhDwNHjfoEimfTRaH u7oeaLpsadvfK82RVAO4Xt0UdKCzddiDylHzNlnKP2iUFypY9NN3FsqVEqe+lDFyNIVB UiS9ik1e/CooFhrxFyroVp5rZ7/n0A4UaIb3t+FuM+ZFB3QHKEIUBjF/dOWYhf/oheP8 XRNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709109921; x=1709714721; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PcEtWOhQTtJCqkpSDk1ZnCpivx0H1TywJJZGbN1kJuo=; b=Zd5yG0urk5tnh7on07mGQq6X/l5fQmlP/4Ir0ABseUX2Ku53Aiy5rTjt1llIMCdngR QzDQFIhqLXJ32007+1i8zkvKEf8QTfE0AEzRUojJ5celbOja+t/UMDfO5tZEp/o4VNNz QxchePndumX37Z00CNRGKQ/Qioo4haHBnzHeQXRNjkkdRZbfeCroaabsdOad/lxZtF49 lSZsh/tv4o8GkHw3lQulso8+7aDy7EtLPLh69P9QJtHTQYfiDPV1tg0Of7rJfv+wKCgw B4+HXQsroeziyqpxxPsD1AjeGHoVbXFebRTpJBwB5zF/oStl+Bwwa+/8e6VBnOcfW4bj zNYA== X-Gm-Message-State: AOJu0Yxy9LQRfQAoIiNsvI/u+UnQfLhTbY82bfavUOzzYYHjH3n3gAaZ QhnSBNDt8NARDj0wiMz1HkSyzmLgGlVNlpIngT2O8opDzbfup/BNrZUYstGQ X-Google-Smtp-Source: AGHT+IE6ri4AtD0/+OTfhtNNC+x61fGaoZ9fVWDP36O2exuAFkZjQGiD/S41yK0dt8SwABv5CM3hug== X-Received: by 2002:a2e:8895:0:b0:2d2:bb5f:cf07 with SMTP id k21-20020a2e8895000000b002d2bb5fcf07mr977546lji.3.1709109921109; Wed, 28 Feb 2024 00:45:21 -0800 (PST) Received: from localhost.localdomain ([2a00:1370:817a:d2b8:9296:d6ce:150d:51eb]) by smtp.gmail.com with ESMTPSA id v17-20020a2e87d1000000b002d2c0d2df05sm176544ljj.48.2024.02.28.00.45.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 00:45:20 -0800 (PST) From: Dmitry Chestnykh To: devel@uclibc-ng.org Date: Wed, 28 Feb 2024 11:45:08 +0300 Message-ID: <20240228084509.2212329-2-dm.chestnykh@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240228084509.2212329-1-dm.chestnykh@gmail.com> References: <20240228084509.2212329-1-dm.chestnykh@gmail.com> MIME-Version: 1.0 Message-ID-Hash: MYNSQON2VY466UOFKMTXDE2SBIXCI4IU X-Message-ID-Hash: MYNSQON2VY466UOFKMTXDE2SBIXCI4IU X-MailFrom: dm.chestnykh@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Dmitry Chestnykh X-Mailman-Version: 3.3.3 Precedence: list Subject: [uclibc-ng-devel] [PATCH 2/3] libc: always redirect *stat() family to statx() with time64 enabled. List-Id: uClibc-ng Development Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Dmitry Chestnykh --- libc/sysdeps/linux/common/fstat64.c | 2 +- libc/sysdeps/linux/common/fstatat64.c | 4 ++-- libc/sysdeps/linux/common/lstat64.c | 2 +- libc/sysdeps/linux/common/stat64.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libc/sysdeps/linux/common/fstat64.c b/libc/sysdeps/linux/common/fstat64.c index 20a9acf01..359c22af6 100644 --- a/libc/sysdeps/linux/common/fstat64.c +++ b/libc/sysdeps/linux/common/fstat64.c @@ -9,7 +9,7 @@ #include <_lfs_64.h> #include -#ifdef __NR_fstat64 +#if defined(__NR_fstat64) && !defined(__UCLIBC_USE_TIME64__) # include # include # include "xstatconv.h" diff --git a/libc/sysdeps/linux/common/fstatat64.c b/libc/sysdeps/linux/common/fstatat64.c index fdd17a0b7..16dbf9215 100644 --- a/libc/sysdeps/linux/common/fstatat64.c +++ b/libc/sysdeps/linux/common/fstatat64.c @@ -23,7 +23,7 @@ # define __NR_fstatat64 __NR_newfstatat #endif -#ifdef __NR_fstatat64 +#if defined(__NR_fstatat64) && !defined(__UCLIBC_USE_TIME64__) # include # include "xstatconv.h" int fstatat64(int fd, const char *file, struct stat64 *buf, int flag) @@ -57,7 +57,7 @@ int fstatat64(int fd, const char *file, struct stat64 *buf, int flag) STATX_BASIC_STATS, &tmp); if (r == 0) - __cp_stat64_statx ((struct stat *)buf, &tmp); + __cp_stat64_statx ((struct stat64 *)buf, &tmp); return r; } diff --git a/libc/sysdeps/linux/common/lstat64.c b/libc/sysdeps/linux/common/lstat64.c index 61892994e..efc5b1b7f 100644 --- a/libc/sysdeps/linux/common/lstat64.c +++ b/libc/sysdeps/linux/common/lstat64.c @@ -11,7 +11,7 @@ #include #include -#if defined __NR_fstatat64 && !defined __NR_lstat +#if defined __NR_fstatat64 && !defined __NR_lstat && !defined(__UCLIBC_USE_TIME64__) # include int lstat64(const char *file_name, struct stat64 *buf) diff --git a/libc/sysdeps/linux/common/stat64.c b/libc/sysdeps/linux/common/stat64.c index fdd2c49a9..0875ba39d 100644 --- a/libc/sysdeps/linux/common/stat64.c +++ b/libc/sysdeps/linux/common/stat64.c @@ -10,7 +10,7 @@ #include #include -#if defined __NR_fstatat64 && !defined __NR_stat64 +#if defined __NR_fstatat64 && !defined __NR_stat64 && !defined(__UCLIBC_USE_TIME64__) #include #include From patchwork Wed Feb 28 08:45:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Chestnykh X-Patchwork-Id: 1905615 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=K5+OptHp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=patchwork.ozlabs.org) Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tl7H13Sv8z23qW for ; Wed, 28 Feb 2024 19:45:49 +1100 (AEDT) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 9A55E3530766; Wed, 28 Feb 2024 09:45:31 +0100 (CET) Authentication-Results: helium.openadk.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=K5+OptHp; dkim-atps=neutral Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by helium.openadk.org (Postfix) with ESMTPS id 3A680353075D for ; Wed, 28 Feb 2024 09:45:24 +0100 (CET) Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2cd3aea2621so23722081fa.1 for ; Wed, 28 Feb 2024 00:45:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709109923; x=1709714723; darn=uclibc-ng.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6cmf/RNxS4lHt5Lcjlu7VN8FivIVE7Pwd0XsAqLU3N4=; b=K5+OptHpt7uxfsR2RZqwmTCt3WsiJNulETF3ehy5CcuK8ms6U2j1JLTs3mSiIhs+2l fTZZkwLQeYKt9h0V5aRzy2Nh4mPWM5VKNN1UcSiSnNc7in621SP7ruyxND18tZ8WivPj Unx8U2ytP6pwL0fLlfxxb8njl3YJ6Juglx96Ex/rceINUeZWpzIxLIInPLrswoeVb+jS m8Z488dy3GoqLpg+In+89m1XSmeToa+GDM87pXtIl7kcowyt6W0om6OPvq2nBjn9LK9M pVlbc3EB9LQsoVpey3E/DfHfZNJCS/OJD+txM6Cu0ywN6I17CF7ngpFHZyW1znUqS+dx q/FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709109923; x=1709714723; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6cmf/RNxS4lHt5Lcjlu7VN8FivIVE7Pwd0XsAqLU3N4=; b=tW/vvDjx9iG/LOLSv6x3KtO9jl1DGcENES5wfSRjsgN+3ofVFNyywKpUrFIKgpzXwl VtzoMp06Nw2TOSZbqugZhaPegA3+Dbibyu7vUn3G264N+ihubTWEPzX0ztcrfOa+/WFt JK3obDcjZHoD11ryQu/09pC5SEpuT84j4ee3rhbdnBHKGqGXt/IUt8s6zur2Tys06m1G T3JtCBdlFaluT55dFRlYaxFrbMyfsGRfFoGuqd5UIaI//mHHCpwVCBO0XLsoglXy18mx qKP3jYa8wPgSHyujQ1k054e2nVMkbW7xRv2M5Y5YZLsASetcu7fTWwbCEB/2PvbHEZE8 YpPg== X-Gm-Message-State: AOJu0YwR7HgzieHsR+eUQhfr6tbOWTuBFUZHj7Ifs55ZS3uoT2xz1IxT MomP30ktmvh6fSuPcchwQKxg+dJzMaDPXyjK3rbHZAqZO+4OL00mGfmlYdBJ X-Google-Smtp-Source: AGHT+IEVoyX2l3PUAHZ256un3XcySpDERcDihLFrZqdj8z6aFC9qsWQutsKgHwatRLy22sulXlL7Pw== X-Received: by 2002:a2e:b056:0:b0:2d2:d9b2:b300 with SMTP id d22-20020a2eb056000000b002d2d9b2b300mr51557ljl.3.1709109922764; Wed, 28 Feb 2024 00:45:22 -0800 (PST) Received: from localhost.localdomain ([2a00:1370:817a:d2b8:9296:d6ce:150d:51eb]) by smtp.gmail.com with ESMTPSA id v17-20020a2e87d1000000b002d2c0d2df05sm176544ljj.48.2024.02.28.00.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 00:45:22 -0800 (PST) From: Dmitry Chestnykh To: devel@uclibc-ng.org Date: Wed, 28 Feb 2024 11:45:09 +0300 Message-ID: <20240228084509.2212329-3-dm.chestnykh@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240228084509.2212329-1-dm.chestnykh@gmail.com> References: <20240228084509.2212329-1-dm.chestnykh@gmail.com> MIME-Version: 1.0 Message-ID-Hash: A2QCTFLPRCIWTW3SST3FOH2RLEM4WOI2 X-Message-ID-Hash: A2QCTFLPRCIWTW3SST3FOH2RLEM4WOI2 X-MailFrom: dm.chestnykh@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Dmitry Chestnykh X-Mailman-Version: 3.3.3 Precedence: list Subject: [uclibc-ng-devel] [PATCH 3/3] libc: Pass 64bit-only time structures to syscalls. List-Id: uClibc-ng Development Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: With time64 enabled we need to pass structure which consists of two 64bit fields to clock_gettime64() and clock_nanosleep_time64() syscalls with proper conversion to regular timespec structure after syscall execution. Signed-off-by: Dmitry Chestnykh --- libpthread/nptl/pthread_mutex_timedlock.c | 14 ++++++++++--- .../sysdeps/pthread/pthread_cond_timedwait.c | 15 ++++++++++--- librt/clock_nanosleep.c | 21 ++++++++++++++++--- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/libpthread/nptl/pthread_mutex_timedlock.c b/libpthread/nptl/pthread_mutex_timedlock.c index d54983315..1191639b6 100644 --- a/libpthread/nptl/pthread_mutex_timedlock.c +++ b/libpthread/nptl/pthread_mutex_timedlock.c @@ -298,11 +298,19 @@ pthread_mutex_timedlock ( /* Delay the thread until the timeout is reached. Then return ETIMEDOUT. */ struct timespec reltime; - struct timespec now; +#if defined(__UCLIBC_USE_TIME64__) + struct __ts64_struct __now64; +#endif + struct timespec now = {.tv_sec = 0, .tv_nsec = 0}; #if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_gettime64) - INTERNAL_SYSCALL (clock_gettime64, __err, 2, CLOCK_REALTIME, - &now); + int __r = INTERNAL_SYSCALL (clock_gettime64, __err, 2, CLOCK_REALTIME, + &__now64); + + if (__r == 0) { + now.tv_sec = __now64.tv_sec; + now.tv_nsec = __now64.tv_nsec; + } #else INTERNAL_SYSCALL (clock_gettime, __err, 2, CLOCK_REALTIME, &now); diff --git a/libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c b/libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c index 49aab0293..ce738b1a1 100644 --- a/libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c +++ b/libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c @@ -95,18 +95,27 @@ __pthread_cond_timedwait ( while (1) { - struct timespec rt; + struct timespec rt = {.tv_sec = 0, .tv_nsec = 0}; +#if defined(__UCLIBC_USE_TIME64__) + struct __ts64_struct __rt64; +#endif { #ifdef __NR_clock_gettime INTERNAL_SYSCALL_DECL (err); -# ifndef __ASSUME_POSIX_TIMERS +# if !defined(__ASSUME_POSIX_TIMERS) || defined(__UCLIBC_USE_TIME64__) int ret = # endif #if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_gettime64) INTERNAL_SYSCALL (clock_gettime64, err, 2, (cond->__data.__nwaiters & ((1 << COND_NWAITERS_SHIFT) - 1)), - &rt); + &__rt64); + + if (ret == 0) { + rt.tv_sec = __rt64.tv_sec; + rt.tv_nsec = __rt64.tv_nsec; + } + #else INTERNAL_SYSCALL (clock_gettime, err, 2, (cond->__data.__nwaiters diff --git a/librt/clock_nanosleep.c b/librt/clock_nanosleep.c index ef59369df..5537b0609 100644 --- a/librt/clock_nanosleep.c +++ b/librt/clock_nanosleep.c @@ -39,18 +39,33 @@ clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req, if (clock_id == CLOCK_PROCESS_CPUTIME_ID) clock_id = MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED); - if (SINGLE_THREAD_P) + if (SINGLE_THREAD_P) { #if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_nanosleep_time64) - r = INTERNAL_SYSCALL (clock_nanosleep_time64, err, 4, clock_id, flags, TO_TS64_P(req), rem); + struct __ts64_struct __req, __rem; + __req.tv_sec = req->tv_sec; + __req.tv_nsec = req->tv_nsec; + r = INTERNAL_SYSCALL (clock_nanosleep_time64, err, 4, clock_id, flags, &__req, &__rem); + if (rem) { + rem->tv_sec = (time_t) __rem.tv_sec; + rem->tv_nsec = __rem.tv_nsec; + } #else r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req, rem); #endif + } else { #ifdef __NEW_THREADS int oldstate = LIBC_CANCEL_ASYNC (); #if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_nanosleep_time64) - r = INTERNAL_SYSCALL (clock_nanosleep_time64, err, 4, clock_id, flags, TO_TS64_P(req), rem); + struct __ts64_struct __req, __rem; + __req.tv_sec = req->tv_sec; + __req.tv_nsec = req->tv_nsec; + r = INTERNAL_SYSCALL (clock_nanosleep_time64, err, 4, clock_id, flags, &__req, &__rem); + if (rem) { + rem->tv_sec = (time_t) __rem.tv_sec; + rem->tv_nsec = __rem.tv_nsec; + } #else r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req, rem);