From patchwork Mon Jul 13 17:10:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40066 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4F4A9388C02F; Mon, 13 Jul 2020 17:10:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F4A9388C02F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660233; bh=ry5OCoQItser1KRmKmMaqu9ZY8dq3SteT7Nh0Vx2KuI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=TsE7jIiH7A48CjW3EsKS0S6MhEU2PlevFBeKHZpbzPLhbMU6Nh9CVR+9FTRxS+cfL 5bctXGb5Zl7xmaXirYuLkfFiIPSFi+xynP2c31zSNg1ahe0QQgypyUL42xyNljGr3j 2rAOBHnNoZ9m8vvnIg+Jm0gNsOzXOzvKoFH6Uc/E= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by sourceware.org (Postfix) with ESMTPS id D23FD3865C10 for ; Mon, 13 Jul 2020 17:10:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D23FD3865C10 Received: by mail-qt1-x842.google.com with SMTP id b25so10536543qto.2 for ; Mon, 13 Jul 2020 10:10:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ry5OCoQItser1KRmKmMaqu9ZY8dq3SteT7Nh0Vx2KuI=; b=CvgOQFbySyvwL86R8aEKobOA5MrgX5NjkQPsc6tuABoK/wym3rCq+Jlbzsbrbmb/yd entaCmc+QtLqF6Ivcdi13iK5SzZFF4YBfO1Uq8bj2sneJuhg/iQB09d749PKEz2+zLPc sjlGNQzrPugvulrPOjkbvUE8Q5blPfWz/S3t+lXVH86UuVr01J/AGnMPNrGQBMHUZYnJ pZn9uKrDqYoZkdd3e+ygPEt5WvlrQnySEghQ4MbT4TwN8Xo/sOuNatGhZ8XMQe1XikNG O9dmc+aB5lo/wCWvbpENSU4pHxU+sca9jzPmQhYWWAfrQnidthPateoRawRrL8NB2+uD /u3Q== X-Gm-Message-State: AOAM530uyQ0xVhPAgmb4X3RLJAY0mRs5SwgPefaZxe/9snsHj6zLPsks SjB3qiQvkjeeeUAqGCBBYO+7Ij+48jM= X-Google-Smtp-Source: ABdhPJyM4C/nkAWHC6ukCekTrwFHwpca3s7QOSK+DZig9Ily78B7/eKOFQFjRqg+Mz7RvYLB18FfdA== X-Received: by 2002:ac8:305d:: with SMTP id g29mr318222qte.115.1594660230187; Mon, 13 Jul 2020 10:10:30 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:29 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 01/23] linux: Simplify clock_adjtime Date: Mon, 13 Jul 2020 14:10:03 -0300 Message-Id: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" With arch-syscall.h it can now assumes the existance of either __NR_clock_adjtime or __NR_clock_adjtime_time64. The 32-bit time_t support is now only build for !__ASSUME_TIME64_SYSCALLS. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Alistair Francis Reviewed-by: Lukasz Majewski --- sysdeps/unix/sysv/linux/clock_adjtime.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/sysdeps/unix/sysv/linux/clock_adjtime.c b/sysdeps/unix/sysv/linux/clock_adjtime.c index 764a60b9bf..4caff2ad05 100644 --- a/sysdeps/unix/sysv/linux/clock_adjtime.c +++ b/sysdeps/unix/sysv/linux/clock_adjtime.c @@ -26,15 +26,13 @@ int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64) { -#ifdef __ASSUME_TIME64_SYSCALLS -# ifndef __NR_clock_adjtime64 -# define __NR_clock_adjtime64 __NR_clock_adjtime -# endif - return INLINE_SYSCALL_CALL (clock_adjtime64, clock_id, tx64); -#else - int ret = INLINE_SYSCALL_CALL (clock_adjtime64, clock_id, tx64); - if (errno != ENOSYS) - return ret; +#ifndef __NR_clock_adjtime64 +# define __NR_clock_adjtime64 __NR_clock_adjtime +#endif + int r = INLINE_SYSCALL_CALL (clock_adjtime64, clock_id, tx64); +#ifndef __ASSUME_TIME64_SYSCALLS + if (r >= 0 || errno != ENOSYS) + return r; if (tx64->modes & ADJ_SETOFFSET && ! in_time_t_range (tx64->time.tv_sec)) @@ -44,12 +42,11 @@ __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64) } struct timex tx32 = valid_timex64_to_timex (*tx64); - int retval = INLINE_SYSCALL_CALL (clock_adjtime, clock_id, &tx32); - if (retval >= 0) + r = INLINE_SYSCALL_CALL (clock_adjtime, clock_id, &tx32); + if (r >= 0) *tx64 = valid_timex_to_timex64 (tx32); - - return retval; #endif + return r; } #if __TIMESIZE != 64 From patchwork Mon Jul 13 17:10:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40067 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D3475388CC37; Mon, 13 Jul 2020 17:10:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3475388CC37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660234; bh=ICAiV+dqyq3gTknQrhjggCRAmuHNSIwXEDBIjWTI6PI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=AIBfSBZ1eGG00dY+koiGC0Hqq/mOsvrZLswqK1LI7Cy7N/bpEuJDnFeQHGV9mIQk4 KGUzJacmXcxAcvdsxwsWww0VCaUzQdYvoYEVPfUgJBCyAPtwW8BLju0BOLk5UQJIt8 SnIG8aRMJbjYvPXSSU/Frk2oRbU46aSiq/PchjvY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by sourceware.org (Postfix) with ESMTPS id 55414384607B for ; Mon, 13 Jul 2020 17:10:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 55414384607B Received: by mail-qk1-x742.google.com with SMTP id b185so12949550qkg.1 for ; Mon, 13 Jul 2020 10:10:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ICAiV+dqyq3gTknQrhjggCRAmuHNSIwXEDBIjWTI6PI=; b=JKElMreIv52+Kp0Pw1eQbWvuBBZZjQ2DuDcfRbwrx3jq0O5gX4n/o9M1bhL/OFC0q7 9SdytnPBEe6HmKWioH5+8uCbFVNWJaLrp4DsU+ciyWhct6Gd48oWydiyoeoMaakloR29 biiB5fry7il+XEMKMWu6ToSyloYtK3ga9odszNL5ZYSvl7Orwha9dUPMbX4hVxtjWKbf YDW7nsLqFt7nr0QE+DQt2PM45ddxw1oSWDknzx+g6QVbb3YanXdCcfP+VO0nnD1EfE4O yr8oZVfJUyg4ZgREweWzd6qIaFo3AdjSu2CEcmRcdGSBfURw7U0ennuY4ELDqEkigaqO /hwg== X-Gm-Message-State: AOAM533IkEwCQiAyzjD55Gg2cITezF9XRoDoAPJB/WmQMtzZURgkP++a 6GyROajUVx8ejrvq56HGKkO+KzFECsc= X-Google-Smtp-Source: ABdhPJxLild2JJ9TGjxybTS+kgQfvJ1z/ejYNf73VxS/ZkFShGtaDXw31SBu/uSXtbCL22zEzYuWuQ== X-Received: by 2002:a05:620a:24c9:: with SMTP id m9mr554917qkn.375.1594660231720; Mon, 13 Jul 2020 10:10:31 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:31 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 02/23] linux: Simplify clock_gettime Date: Mon, 13 Jul 2020 14:10:04 -0300 Message-Id: <20200713171025.3661832-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" With arch-syscall.h it can now assumes the existance of either __NR_clock_gettime or __NR_clock_gettime_time64. The 32-bit time_t support is now only build for !__ASSUME_TIME64_SYSCALLS. It also uses the time64-support functions to simplify it further. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). --- sysdeps/unix/sysv/linux/clock_gettime.c | 42 ++++++++++--------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/sysdeps/unix/sysv/linux/clock_gettime.c b/sysdeps/unix/sysv/linux/clock_gettime.c index bfe3823b68..5a65113a1d 100644 --- a/sysdeps/unix/sysv/linux/clock_gettime.c +++ b/sysdeps/unix/sysv/linux/clock_gettime.c @@ -22,43 +22,34 @@ #include #include "kernel-posix-cpu-timers.h" #include - +#include #include /* Get current value of CLOCK and store it in TP. */ int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp) { -#ifdef __ASSUME_TIME64_SYSCALLS - /* 64 bit ABIs or newer 32-bit ABIs that only support 64-bit time_t. */ -# ifndef __NR_clock_gettime64 -# define __NR_clock_gettime64 __NR_clock_gettime -# endif -# ifdef HAVE_CLOCK_GETTIME64_VSYSCALL - return INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp); -# else - return INLINE_SYSCALL_CALL (clock_gettime64, clock_id, tp); -# endif -#else int r; - /* Old 32-bit ABI with possible 64-bit time_t support. */ -# ifdef __NR_clock_gettime64 - /* Avoid issue a __NR_clock_gettime64 syscall on kernels that do not - support 64-bit time_t. */ - static int time64_support = 1; - if (atomic_load_relaxed (&time64_support) != 0) + +#ifndef __NR_clock_gettime64 +# define __NR_clock_gettime64 __NR_clock_gettime +#endif + + if (supports_time64 ()) { -# ifdef HAVE_CLOCK_GETTIME64_VSYSCALL +#ifdef HAVE_CLOCK_GETTIME64_VSYSCALL r = INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp); -# else +#else r = INLINE_SYSCALL_CALL (clock_gettime64, clock_id, tp); -# endif +#endif + if (r == 0 || errno != ENOSYS) return r; - atomic_store_relaxed (&time64_support, 0); - } -# endif + mark_time64_unsupported (); + } + +#ifndef __ASSUME_TIME64_SYSCALLS /* Fallback code that uses 32-bit support. */ struct timespec tp32; # ifdef HAVE_CLOCK_GETTIME_VSYSCALL @@ -68,8 +59,9 @@ __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp) # endif if (r == 0) *tp = valid_timespec_to_timespec64 (tp32); - return r; #endif + + return r; } #if __TIMESIZE != 64 From patchwork Mon Jul 13 17:10:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40068 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 61097388CC3C; Mon, 13 Jul 2020 17:10:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 61097388CC3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660237; bh=z8NEIFxUwS25r4yH8lI+5a0DMPmwGbFo9LRU8xmg0bs=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=GWujNm02u1gQdrzOYE9tJgXwtCbxly7vU6nb85FqNqRhJxjSr76jLYeRksOP/bYtQ XbAJegldGl1dSKSMy7NJ3Jpu/VbDbVi9eOt9NT3Th3pxiozm+HjQTo4mNAkrqNudU9 BmJi4b0ZM7uZRRrgGdL20Il2uUdeCg9Ko0+aj+WE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by sourceware.org (Postfix) with ESMTPS id E58D3388CC03 for ; Mon, 13 Jul 2020 17:10:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E58D3388CC03 Received: by mail-qv1-xf44.google.com with SMTP id h18so6120710qvl.3 for ; Mon, 13 Jul 2020 10:10:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z8NEIFxUwS25r4yH8lI+5a0DMPmwGbFo9LRU8xmg0bs=; b=sOcMKyPYBYE/vSooSYdozu3609nL/B+WF4C8gVeiOWIUbX3BCSb4CL8EPCQvwuf6bB AVNa2PZ/2fJUv460ePseioXlWG0s63lw26g2nNVyivH+YN8ByYqnRYB447sniYoK6sw5 IYoGeKIZl5lxNM8ZzkOxvkMSpTFWmEDsxjQWmLQqS9mnzXO1uXIwnl5N95fUk3ddky0f Kw6HPQPaCGJaR8FNCDJH0h5SPa7k9MtZNLEsNFXrqAZR2ZTUk0lF8/MZjN/xaCq1OnZQ RdHGVD2otxXR7KA29wL+JV81y6mpZ+zqqFRUIwlyW2dHhk3XsTdG1eoXryQjpk09ABNI ngiA== X-Gm-Message-State: AOAM5321AjYlRSwW6mosnnzZWaIxk+aeUis1Apktr27Zc/CXJ99UmF25 lZsFX/ebW6CPhiL2u8z31D/wLyyhUyY= X-Google-Smtp-Source: ABdhPJz5Q3mgBXzkQurbruYk64hsnU6/PlUwAayOQdR5xy1+EWExIvXjANheFTiq4dmbYBgu7TcyEg== X-Received: by 2002:ad4:5511:: with SMTP id az17mr413280qvb.159.1594660233282; Mon, 13 Jul 2020 10:10:33 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:32 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 03/23] linux: Simplify clock_nanosleep Date: Mon, 13 Jul 2020 14:10:05 -0300 Message-Id: <20200713171025.3661832-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" With arch-syscall.h it can now assumes the existance of either __NR_clock_nanosleep or __NR_clock_nanosleep_time64. The 32-bit time_t support is now only build for !__ASSUME_TIME64_SYSCALLS. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Lukasz Majewski --- sysdeps/unix/sysv/linux/clock_nanosleep.c | 33 ++++++++--------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c index cc7a09569d..6ad3321435 100644 --- a/sysdeps/unix/sysv/linux/clock_nanosleep.c +++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c @@ -30,8 +30,6 @@ int __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec64 *req, struct __timespec64 *rem) { - int r; - if (clock_id == CLOCK_THREAD_CPUTIME_ID) return EINVAL; if (clock_id == CLOCK_PROCESS_CPUTIME_ID) @@ -39,22 +37,15 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec /* If the call is interrupted by a signal handler or encounters an error, it returns a positive value similar to errno. */ -#ifdef __ASSUME_TIME64_SYSCALLS -# ifndef __NR_clock_nanosleep_time64 -# define __NR_clock_nanosleep_time64 __NR_clock_nanosleep -# endif - r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, clock_id, - flags, req, rem); -#else -# ifdef __NR_clock_nanosleep_time64 - r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, clock_id, - flags, req, rem); - - if (! INTERNAL_SYSCALL_ERROR_P (r)) - return 0; - if (INTERNAL_SYSCALL_ERRNO (r) != ENOSYS) - return INTERNAL_SYSCALL_ERRNO (r); -# endif /* __NR_clock_nanosleep_time64 */ +#ifndef __NR_clock_nanosleep_time64 +# define __NR_clock_nanosleep_time64 __NR_clock_nanosleep +#endif + int r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, clock_id, + flags, req, rem); + +#ifndef __ASSUME_TIME64_SYSCALLS + if (r == 0 || r != -ENOSYS) + return -r; if (! in_time_t_range (req->tv_sec)) { @@ -68,14 +59,12 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec &ts32, &tr32); if (INTERNAL_SYSCALL_ERROR_P (r)) { - if (INTERNAL_SYSCALL_ERRNO (r) == EINTR && rem != NULL - && (flags & TIMER_ABSTIME) == 0) + if (r == -EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0) *rem = valid_timespec_to_timespec64 (tr32); } #endif /* __ASSUME_TIME64_SYSCALLS */ - return (INTERNAL_SYSCALL_ERROR_P (r) - ? INTERNAL_SYSCALL_ERRNO (r) : 0); + return -r; } #if __TIMESIZE != 64 From patchwork Mon Jul 13 17:10:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40069 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DF8BB388E802; Mon, 13 Jul 2020 17:10:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DF8BB388E802 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660237; bh=vZZPYz1yNpcYMjhuuqV02/PDTAhyM67ftBfGqIZBFi4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=OhaRSviMpzO1QRCrXd9PIb9yW2CSLDkzk5SyDsjwJZ+G8Z4EmWxjF9UOtDUPOZ4al OFF7Jxodwd1fDGKZiyCpNchqYsX3CZA2Jx6yz1osZnUD/2gGzfmpiiTsLX+OZ+mdX3 bW9Zgertu3erQsy4A8lxVG4UJ0rt+4+A879XOfEU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by sourceware.org (Postfix) with ESMTPS id 5476A388CC3A for ; Mon, 13 Jul 2020 17:10:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5476A388CC3A Received: by mail-qv1-xf44.google.com with SMTP id t11so6119616qvk.1 for ; Mon, 13 Jul 2020 10:10:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vZZPYz1yNpcYMjhuuqV02/PDTAhyM67ftBfGqIZBFi4=; b=W6x/20EIp0/yNGZGKlzCyxPLnegWl0N0xTAfVGVkCC2a4dp2zaAxJf3XxF2Dg6KgSV MXR4qaQrm2eOgCxJO0akcWqnWluZSCfzESxy9jqY3RPITSDlCqv6l2z6txPkS6phpNT8 MGHTVsx2hjLzCo1eymbZAp4mcPXed3p5rm/nLAJqOec18ovkog5uoQ/hFlR1upBMxhkH mwZMKlhtDH9ty8qmixMDKF+lV3uJOOEHGR7CwG2IGrlyzbZZi1r9xwttvUV7uRxsqT/a LeAQJ3maMAAAcSf57enaY6cW+kGRKCEY4YUrLM/cLxC+VnT6JKN/V6Z3EU/MEv4nXf51 sKlg== X-Gm-Message-State: AOAM531RsvPl1LNVX0ykTgzAjf0q2pAMr4zEDP5vuoITMKE7n0IlFHvg 8kbKq/iM61wUTkz+oQpn9h2jaJV3Vn0= X-Google-Smtp-Source: ABdhPJzv3K6Ij53IrEQkpEQTsHjCluu9gEHo0gkTzlMqZLB4ul/v1kJIvGRC6ZqWdIFIW2Fch8IAwg== X-Received: by 2002:a0c:a993:: with SMTP id a19mr490497qvb.34.1594660234710; Mon, 13 Jul 2020 10:10:34 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:34 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 04/23] linux: Simplify clock_settime Date: Mon, 13 Jul 2020 14:10:06 -0300 Message-Id: <20200713171025.3661832-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" With arch-syscall.h it can now assumes the existance of either __NR_clock_settime or __NR_clock_settime_time64. The 32-bit time_t support is now only build for !__ASSUME_TIME64_SYSCALLS. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Lukasz Majewski --- sysdeps/unix/sysv/linux/clock_settime.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sysdeps/unix/sysv/linux/clock_settime.c b/sysdeps/unix/sysv/linux/clock_settime.c index ebda871f4c..ce0bf622c0 100644 --- a/sysdeps/unix/sysv/linux/clock_settime.c +++ b/sysdeps/unix/sysv/linux/clock_settime.c @@ -32,17 +32,15 @@ __clock_settime64 (clockid_t clock_id, const struct __timespec64 *tp) return -1; } -#ifdef __ASSUME_TIME64_SYSCALLS -# ifndef __NR_clock_settime64 -# define __NR_clock_settime64 __NR_clock_settime -# endif - return INLINE_SYSCALL_CALL (clock_settime64, clock_id, tp); -#else -# ifdef __NR_clock_settime64 +#ifndef __NR_clock_settime64 +# define __NR_clock_settime64 __NR_clock_settime +#endif int ret = INLINE_SYSCALL_CALL (clock_settime64, clock_id, tp); + +#ifndef __ASSUME_TIME64_SYSCALLS if (ret == 0 || errno != ENOSYS) return ret; -# endif + if (! in_time_t_range (tp->tv_sec)) { __set_errno (EOVERFLOW); @@ -50,8 +48,10 @@ __clock_settime64 (clockid_t clock_id, const struct __timespec64 *tp) } struct timespec ts32 = valid_timespec64_to_timespec (*tp); - return INLINE_SYSCALL_CALL (clock_settime, clock_id, &ts32); + ret = INLINE_SYSCALL_CALL (clock_settime, clock_id, &ts32); #endif + + return ret; } #if __TIMESIZE != 64 From patchwork Mon Jul 13 17:10:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40070 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 765AB388E80A; Mon, 13 Jul 2020 17:10:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 765AB388E80A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660239; bh=VwdWblVUD0cz0ko1ileuo4/Erzw+FqsgLBJuEXRp3Uo=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=eHm+C6MnmBoyNk7r7vGYgVhH8xyKD1ReqZyQz7SsQs7CH9eCBLNYk8uAYoYxxjzm+ riJereTesjf2NwzNmv5WhlHdUuDTtWY/1+Bkk7TrOuCwhz4wlH6ChTtrk3YqNr0uKZ RJ7fhTVr6HziCahiSJtgsgG03PAYI92N84ZCK54s= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by sourceware.org (Postfix) with ESMTPS id E2FCE388CC07 for ; Mon, 13 Jul 2020 17:10:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E2FCE388CC07 Received: by mail-qk1-x743.google.com with SMTP id 145so12914103qke.9 for ; Mon, 13 Jul 2020 10:10:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VwdWblVUD0cz0ko1ileuo4/Erzw+FqsgLBJuEXRp3Uo=; b=LJ3JZF7JNC9Jb6rTYm92Esr6/g/9e2NNBlJdzhende9fFOa9R01uvLI10vIgjYKSj0 F46RlPY4niNDhL0VEJG22WEl7BxDZiIqC9yD4kYcGhdJ/HhJYLHArPPvFbHp3J+g2FNG dwT8rxYBuNTUPBS5jni90sNHQ7sDVsXXe/j7GijfhRG2H9qfT7vzI5+cDRwwUGXU3Zp5 wvDblsJi4zdqTQoNlE4QrZy2g1lJn1vFqpQPDJJn6909ItBEI/8rb7BCazH3N2O+UocF nM64kiRIU+QK7E76AtY8P4gUlrIEIVc840nxmgUoTOucQOjOnXBD+tzGOc4uYflWOT46 JJcg== X-Gm-Message-State: AOAM533NCarvVuBOEItmo1orjXuEtanex88/YHTZPfpfaNMxJoEdTYqA 9NIBN+cJj1eP1OqURX3f7agoOut+AjU= X-Google-Smtp-Source: ABdhPJxa1Vyml+nxiYRweb3Zfs1YHjCLfhNWAp4VD2gRXUd3KiQnXkqvhDiebB+PpsxJMJ6CQfCRjw== X-Received: by 2002:a37:9dc5:: with SMTP id g188mr508321qke.427.1594660236260; Mon, 13 Jul 2020 10:10:36 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:35 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 05/23] linux: Simplify mq_timedreceive Date: Mon, 13 Jul 2020 14:10:07 -0300 Message-Id: <20200713171025.3661832-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" With arch-syscall.h it can now assumes the existance of either __NR_mq_timedreceive or __NR_mq_timedreceive_time64. The 32-bit time_t support is now only build for !__ASSUME_TIME64_SYSCALLS. The internal 64-bit time_t names is also adjusted to use the other y2038 symbol names. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Lukasz Majewski --- include/mqueue.h | 16 ++++++------ sysdeps/unix/sysv/linux/mq_timedreceive.c | 32 +++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/mqueue.h b/include/mqueue.h index 98e4596c22..b3ee8b7462 100644 --- a/include/mqueue.h +++ b/include/mqueue.h @@ -13,18 +13,18 @@ hidden_proto (mq_setattr) #include #if __TIMESIZE == 64 # define __mq_timedsend_time64 __mq_timedsend -# define __mq_timedreceive_time64 __mq_timedreceive +# define __mq_timedreceive64 __mq_timedreceive #else extern int __mq_timedsend_time64 (mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct __timespec64 *abs_timeout); librt_hidden_proto (__mq_timedsend_time64) -extern ssize_t __mq_timedreceive_time64 (mqd_t mqdes, - char *__restrict msg_ptr, - size_t msg_len, - unsigned int *__restrict msg_prio, - const struct __timespec64 *__restrict - abs_timeout); -librt_hidden_proto (__mq_timedreceive_time64) +extern ssize_t __mq_timedreceive64 (mqd_t mqdes, + char *__restrict msg_ptr, + size_t msg_len, + unsigned int *__restrict msg_prio, + const struct __timespec64 *__restrict + abs_timeout); +librt_hidden_proto (__mq_timedreceive64) #endif #endif diff --git a/sysdeps/unix/sysv/linux/mq_timedreceive.c b/sysdeps/unix/sysv/linux/mq_timedreceive.c index 728a63d1ec..61c27fd8f7 100644 --- a/sysdeps/unix/sysv/linux/mq_timedreceive.c +++ b/sysdeps/unix/sysv/linux/mq_timedreceive.c @@ -22,19 +22,17 @@ /* Receive the oldest from highest priority messages in message queue MQDES, stop waiting if ABS_TIMEOUT expires. */ ssize_t -__mq_timedreceive_time64 (mqd_t mqdes, char *__restrict msg_ptr, size_t msg_len, - unsigned int *__restrict msg_prio, - const struct __timespec64 *__restrict abs_timeout) +__mq_timedreceive64 (mqd_t mqdes, char *__restrict msg_ptr, size_t msg_len, + unsigned int *__restrict msg_prio, + const struct __timespec64 *__restrict abs_timeout) { -#ifdef __ASSUME_TIME64_SYSCALLS -# ifndef __NR_mq_timedreceive_time64 -# define __NR_mq_timedreceive_time64 __NR_mq_timedreceive -# endif - return SYSCALL_CANCEL (mq_timedreceive_time64, mqdes, msg_ptr, msg_len, - msg_prio, abs_timeout); -#else +#ifndef __NR_mq_timedreceive_time64 +# define __NR_mq_timedreceive_time64 __NR_mq_timedreceive +#endif int ret = SYSCALL_CANCEL (mq_timedreceive_time64, mqdes, msg_ptr, msg_len, - msg_prio, abs_timeout); + msg_prio, abs_timeout); + +#ifndef __ASSUME_TIME64_SYSCALLS if (ret == 0 || errno != ENOSYS) return ret; @@ -50,13 +48,15 @@ __mq_timedreceive_time64 (mqd_t mqdes, char *__restrict msg_ptr, size_t msg_len, ts32 = valid_timespec64_to_timespec (*abs_timeout); } - return SYSCALL_CANCEL (mq_timedreceive, mqdes, msg_ptr, msg_len, msg_prio, - abs_timeout != NULL ? &ts32 : NULL); + ret = SYSCALL_CANCEL (mq_timedreceive, mqdes, msg_ptr, msg_len, msg_prio, + abs_timeout != NULL ? &ts32 : NULL); #endif + + return ret; } #if __TIMESIZE != 64 -librt_hidden_def (__mq_timedreceive_time64) +librt_hidden_def (__mq_timedreceive64) ssize_t __mq_timedreceive (mqd_t mqdes, char *__restrict msg_ptr, size_t msg_len, @@ -67,8 +67,8 @@ __mq_timedreceive (mqd_t mqdes, char *__restrict msg_ptr, size_t msg_len, if (abs_timeout != NULL) ts64 = valid_timespec_to_timespec64 (*abs_timeout); - return __mq_timedreceive_time64 (mqdes, msg_ptr, msg_len, msg_prio, - abs_timeout != NULL ? &ts64 : NULL); + return __mq_timedreceive64 (mqdes, msg_ptr, msg_len, msg_prio, + abs_timeout != NULL ? &ts64 : NULL); } #endif From patchwork Mon Jul 13 17:10:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40071 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 21DD2388E80B; Mon, 13 Jul 2020 17:10:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 21DD2388E80B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660241; bh=vsb6l0ayIUatJZ2hnpcz1vyePaeBJqral3PnBzNOaTQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ScnsBvGtDTAfF18bpw0iwIb7DUwx3YJarwRpXZ8yxNHGenMYYRns8pS/rvnFM+G1n TVVh3bEPdZlixoARmQwcu3/zgAY6PUQoP33E/DvVcGFspjfdwrj6LHbI2pIdHKPzHe 0YbYnZUpN1GriXHU6Oi7iZ6IhNos+9uWnnqFmJU0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by sourceware.org (Postfix) with ESMTPS id 8E1B8388CC07 for ; Mon, 13 Jul 2020 17:10:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8E1B8388CC07 Received: by mail-qk1-x744.google.com with SMTP id c30so12911018qka.10 for ; Mon, 13 Jul 2020 10:10:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vsb6l0ayIUatJZ2hnpcz1vyePaeBJqral3PnBzNOaTQ=; b=HWgmFAQuPWwO0t3cV9K32PKlFUClU2EXUIctLUQfC65l0zkVjHtImQXtm9Dun/sOrg E3XBp/F+HBCRYuqu4p91n5sldjbq7k4fMJeHM+u5ArJaFA0MsYSR5vsTwTV60x/80S0K phr75/F9ZshIQ6WQAk/hu5deXNY1SHMqCVAFcV2Zu/KaO6ewRQZceCPkSaON6RAECcy2 dsAMNRD9mSscyYjQocKVt6tvnkVAkWrVk4qK3wX3Aj0ITE7+skv22E6oxeUQg+0CbGTo +umQ+CO4FQLKuds/nu105mbfgXUv6a4NdAsMsPiU+1IJTpqSHXS9GLgXQoJXYvh47Awf L/fA== X-Gm-Message-State: AOAM53045pzlejSONbEMszdW6npQzsj6IhkRgKYX59QzOxppOPuTSdO8 UjbhjTe+4acyJmFYnTCQ7KqFoC558g4= X-Google-Smtp-Source: ABdhPJyWJVewKL3Alvhi7GFau3vRtG+bIbiCVaXSAqDnzCQB9b5uBsSDq8ZVeaOapnMuROR/JIXtEw== X-Received: by 2002:a37:a616:: with SMTP id p22mr638060qke.292.1594660237817; Mon, 13 Jul 2020 10:10:37 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:37 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 06/23] linux: Simplify mq_timedsend Date: Mon, 13 Jul 2020 14:10:08 -0300 Message-Id: <20200713171025.3661832-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" With arch-syscall.h it can now assumes the existance of either __NR_mq_timedsend or __NR_mq_timedsend_time64. The 32-bit time_t support is now only build for !__ASSUME_TIME64_SYSCALLS. The internal 64-bit time_t names is also adjusted to use the other y2038 symbol names. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Lukasz Majewski --- include/mqueue.h | 10 +++++----- sysdeps/unix/sysv/linux/mq_timedsend.c | 26 +++++++++++++------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/mqueue.h b/include/mqueue.h index b3ee8b7462..e0e30dc890 100644 --- a/include/mqueue.h +++ b/include/mqueue.h @@ -12,13 +12,13 @@ hidden_proto (mq_setattr) # endif #include #if __TIMESIZE == 64 -# define __mq_timedsend_time64 __mq_timedsend +# define __mq_timedsend64 __mq_timedsend # define __mq_timedreceive64 __mq_timedreceive #else -extern int __mq_timedsend_time64 (mqd_t mqdes, const char *msg_ptr, - size_t msg_len, unsigned int msg_prio, - const struct __timespec64 *abs_timeout); -librt_hidden_proto (__mq_timedsend_time64) +extern int __mq_timedsend64 (mqd_t mqdes, const char *msg_ptr, + size_t msg_len, unsigned int msg_prio, + const struct __timespec64 *abs_timeout); +librt_hidden_proto (__mq_timedsend64) extern ssize_t __mq_timedreceive64 (mqd_t mqdes, char *__restrict msg_ptr, size_t msg_len, diff --git a/sysdeps/unix/sysv/linux/mq_timedsend.c b/sysdeps/unix/sysv/linux/mq_timedsend.c index f2a43df300..6011db7112 100644 --- a/sysdeps/unix/sysv/linux/mq_timedsend.c +++ b/sysdeps/unix/sysv/linux/mq_timedsend.c @@ -22,19 +22,17 @@ /* Add message pointed by MSG_PTR to message queue MQDES, stop blocking on full message queue if ABS_TIMEOUT expires. */ int -__mq_timedsend_time64 (mqd_t mqdes, const char *msg_ptr, size_t msg_len, - unsigned int msg_prio, - const struct __timespec64 *abs_timeout) +__mq_timedsend64 (mqd_t mqdes, const char *msg_ptr, size_t msg_len, + unsigned int msg_prio, + const struct __timespec64 *abs_timeout) { -#ifdef __ASSUME_TIME64_SYSCALLS # ifndef __NR_mq_timedsend_time64 # define __NR_mq_timedsend_time64 __NR_mq_timedsend # endif - return SYSCALL_CANCEL (mq_timedsend_time64, mqdes, msg_ptr, msg_len, - msg_prio, abs_timeout); -#else int ret = SYSCALL_CANCEL (mq_timedsend_time64, mqdes, msg_ptr, msg_len, - msg_prio, abs_timeout); + msg_prio, abs_timeout); + +#ifndef __ASSUME_TIME64_SYSCALLS if (ret == 0 || errno != ENOSYS) return ret; @@ -50,13 +48,15 @@ __mq_timedsend_time64 (mqd_t mqdes, const char *msg_ptr, size_t msg_len, ts32 = valid_timespec64_to_timespec (*abs_timeout); } - return SYSCALL_CANCEL (mq_timedsend, mqdes, msg_ptr, msg_len, msg_prio, - abs_timeout != NULL ? &ts32 : NULL); + ret = SYSCALL_CANCEL (mq_timedsend, mqdes, msg_ptr, msg_len, msg_prio, + abs_timeout != NULL ? &ts32 : NULL); #endif + + return ret; } #if __TIMESIZE != 64 -librt_hidden_def (__mq_timedsend_time64) +librt_hidden_def (__mq_timedsend64) int __mq_timedsend (mqd_t mqdes, const char *msg_ptr, size_t msg_len, @@ -66,8 +66,8 @@ __mq_timedsend (mqd_t mqdes, const char *msg_ptr, size_t msg_len, if (abs_timeout != NULL) ts64 = valid_timespec_to_timespec64 (*abs_timeout); - return __mq_timedsend_time64 (mqdes, msg_ptr, msg_len, msg_prio, - abs_timeout != NULL ? &ts64 : NULL); + return __mq_timedsend64 (mqdes, msg_ptr, msg_len, msg_prio, + abs_timeout != NULL ? &ts64 : NULL); } #endif From patchwork Mon Jul 13 17:10:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40072 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A3507388CC3F; Mon, 13 Jul 2020 17:10:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3507388CC3F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660241; bh=YN9OsBXN30C6BqCBIV2lEMhqF88wujZwCsdF77NXYu4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=vDDK/NbfzEUE3O/6vgAjfmc6Mf0H09a6yRvJiIti1UXj9JZejbs76jJs0TmHBKCoV Ln4lPU97ejFWd+vSKRcyzVolLHkT/EVKR96bHeO+Sr10cHlygM00dT7NwMUPKNgh0F AAqoprg7YFHc1M0roZr+WfE3u08JgxJPqOvZSGWs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by sourceware.org (Postfix) with ESMTPS id 3009A388CC07 for ; Mon, 13 Jul 2020 17:10:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3009A388CC07 Received: by mail-qt1-x842.google.com with SMTP id 6so10531244qtt.0 for ; Mon, 13 Jul 2020 10:10:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YN9OsBXN30C6BqCBIV2lEMhqF88wujZwCsdF77NXYu4=; b=UUmVrXI39zikJWzIDHDYFkbJIahSILc6Y3cH72m7yZV8JNk7jcJR/zY3k321VFv6D1 +HMJNOTS8c6rubeDJlYkARZEyzojVNJsT7bds8mYCkDqKJb9NbyiwOpHDVrr+xQmUdjK Li3KFVhOkWxodb5XrE71mA2Pxu1nrovTvcNpZuljStcAig62f052E6VwlOiXTuG2GxEr wZz+6qrJ2sn/U5kQ3TRsMm2240nCW9+JTC+2euTW5xHaKAhhLGPmqJKFEmpucMnOwaEs IM8QGaY7/t7ZSwSglhDtJv/l9mKGo9HtFIQkFOI/G03ExCtJVakfu5rJaeMsBmXI8rr8 03Sg== X-Gm-Message-State: AOAM531sKYv9ZXtxCenaSZUV7SO9/c82RDSf1I8ehWGpPuv18Ua53aVH sL+k/BZuTYKsjUFSPwIHHBlpnjVNKgQ= X-Google-Smtp-Source: ABdhPJyfLR/jfe5QTmLjwvdTijtoHmpFo3yqTUXwTRJQITzJgcIfef6awgfKlE2ug74wu2mo0QTlNQ== X-Received: by 2002:ac8:2928:: with SMTP id y37mr297613qty.245.1594660239606; Mon, 13 Jul 2020 10:10:39 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:38 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 07/23] linux: Simplify ppoll Date: Mon, 13 Jul 2020 14:10:09 -0300 Message-Id: <20200713171025.3661832-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" With arch-syscall.h it can now assumes the existance of either __NR_ppoll or __NR_ppoll_time64. The 32-bit time_t support is now only build for !__ASSUME_TIME64_SYSCALLS. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Lukasz Majewski --- sysdeps/unix/sysv/linux/ppoll.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/sysdeps/unix/sysv/linux/ppoll.c b/sysdeps/unix/sysv/linux/ppoll.c index 0f15636cce..079d56b5eb 100644 --- a/sysdeps/unix/sysv/linux/ppoll.c +++ b/sysdeps/unix/sysv/linux/ppoll.c @@ -37,19 +37,16 @@ __ppoll64 (struct pollfd *fds, nfds_t nfds, const struct __timespec64 *timeout, timeout = &tval; } -#ifdef __ASSUME_TIME64_SYSCALLS -# ifndef __NR_ppoll_time64 -# define __NR_ppoll_time64 __NR_ppoll -# endif - return SYSCALL_CANCEL (ppoll_time64, fds, nfds, timeout, sigmask, - __NSIG_BYTES); -#else -# ifdef __NR_ppoll_time64 +#ifndef __NR_ppoll_time64 +# define __NR_ppoll_time64 __NR_ppoll +#endif int ret = SYSCALL_CANCEL (ppoll_time64, fds, nfds, timeout, sigmask, - __NSIG_BYTES); + __NSIG_BYTES); + +#ifdef __ASSUME_TIME64_SYSCALLS if (ret >= 0 || errno != ENOSYS) return ret; -# endif + struct timespec ts32; if (timeout) { @@ -62,9 +59,11 @@ __ppoll64 (struct pollfd *fds, nfds_t nfds, const struct __timespec64 *timeout, ts32 = valid_timespec64_to_timespec (*timeout); } - return SYSCALL_CANCEL (ppoll, fds, nfds, timeout ? &ts32 : NULL, sigmask, - __NSIG_BYTES); + ret = SYSCALL_CANCEL (ppoll, fds, nfds, timeout ? &ts32 : NULL, sigmask, + __NSIG_BYTES); #endif + + return ret; } #if __TIMESIZE != 64 From patchwork Mon Jul 13 17:10:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40073 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A6631388E833; Mon, 13 Jul 2020 17:10:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A6631388E833 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660243; bh=5GH/Ivgi4OztfFaEArLQvLfMISjBY9WgAO7W43AEQNY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=bkg3gxjpgYPYY8cQ0mapNfvVSxWMoHVZudeP6QGkBEDHiDic6WP5UhMutWtybXFke V+OT6ykw9SjYtg4Syx31jqaW5+E08sgFIHk7Yb6hSCEzhwo/vfFNThkOxaNMtO+tcc C1IkzwSbyfZ5PQyjaeVEUkCDBvI6A+4EObsBe+Fo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by sourceware.org (Postfix) with ESMTPS id AC869388E813 for ; Mon, 13 Jul 2020 17:10:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AC869388E813 Received: by mail-qt1-x841.google.com with SMTP id w34so10546841qte.1 for ; Mon, 13 Jul 2020 10:10:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5GH/Ivgi4OztfFaEArLQvLfMISjBY9WgAO7W43AEQNY=; b=adkN4B0K6wlQljUKDiXb89Y9NHzOBULIOApEu+ZhRCkeH7CxcGoi9FnPblEoZaZjD7 I5ONfyGDCAjlnNlldZJ2h2imGiZdlwCBRTcVXfYm2RuXyiCVE+tDCfyBMU3zJTkJQbdu JkpFUFQksjaAuiX4HMoKz4PsY9DmrY/GKSHl6VAPxur3FCsYsuBCHpNaD6Ty4AV1jXZZ OB0XE2PbNLUQebDphJhjY7armHxhkgTuMEDKya2c+HKJZ2NaPbK1T/ryZXUDd/Hwu401 g3WAtRwBC8uOXeejuTPRrlbvTc4qU8YDfIW2R3oiLVS39avU0iRiNy/7hJXj1wiQgteI hvdA== X-Gm-Message-State: AOAM530bNtSbBsr4I0qhlJBifEBS1zA3jSYCdahBqJQPZV3yo7SzWBhb gkH1egs4BsELiJkJV+qaKqGa0mNgiRc= X-Google-Smtp-Source: ABdhPJxRZTKieYA3cTS0OfKUM4P2SuOVgNW2QdzXWe1lV5h1aAD9y5mzaYoqVxkgy/uj+rIxEAwbSQ== X-Received: by 2002:ac8:bc2:: with SMTP id p2mr338162qti.374.1594660241067; Mon, 13 Jul 2020 10:10:41 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:40 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 08/23] linux: Simplify sched_rr_get_interval Date: Mon, 13 Jul 2020 14:10:10 -0300 Message-Id: <20200713171025.3661832-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" With arch-syscall.h it can now assumes the existance of either __NR_sched_rr_get_interval or __NR_sched_rr_get_interval_time64. The 32-bit time_t support is now only build for !__ASSUME_TIME64_SYSCALLS. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Lukasz Majewski --- sysdeps/unix/sysv/linux/sched_rr_gi.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/sysdeps/unix/sysv/linux/sched_rr_gi.c b/sysdeps/unix/sysv/linux/sched_rr_gi.c index 3d7b484591..997562159f 100644 --- a/sysdeps/unix/sysv/linux/sched_rr_gi.c +++ b/sysdeps/unix/sysv/linux/sched_rr_gi.c @@ -25,24 +25,20 @@ int __sched_rr_get_interval64 (pid_t pid, struct __timespec64 *tp) { -#ifdef __ASSUME_TIME64_SYSCALLS -# ifndef __NR_sched_rr_get_interval_time64 -# define __NR_sched_rr_get_interval_time64 __NR_sched_rr_get_interval -# endif - return INLINE_SYSCALL_CALL (sched_rr_get_interval_time64, pid, tp); -#else -# ifdef __NR_sched_rr_get_interval_time64 +#ifndef __NR_sched_rr_get_interval_time64 +# define __NR_sched_rr_get_interval_time64 __NR_sched_rr_get_interval +#endif int ret = INLINE_SYSCALL_CALL (sched_rr_get_interval_time64, pid, tp); +#ifndef __ASSUME_TIME64_SYSCALLS if (ret == 0 || errno != ENOSYS) return ret; -# endif + struct timespec tp32; - int retval = INLINE_SYSCALL_CALL (sched_rr_get_interval, pid, &tp32); - if (retval == 0) + ret = INLINE_SYSCALL_CALL (sched_rr_get_interval, pid, &tp32); + if (ret == 0) *tp = valid_timespec_to_timespec64 (tp32); - - return retval; #endif + return ret; } #if __TIMESIZE != 64 From patchwork Mon Jul 13 17:10:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40074 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 33D43388E83C; Mon, 13 Jul 2020 17:10:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 33D43388E83C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660245; bh=dpkETXr57I+oXUP7EtlXRZ22bRcDMKIDJZHNTHoOXkc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=yWgnUFhyJPdsdm0cOkBgVAULLWltK3aEe4CtRg/G+mXzmF8icplimtfGM4ekZ4MRV dWjJVWCqXQ601nVBiUe4YGXbPKeIIxRDFYX8ZG1wVOZtkLBTIszIirvCKUtLyqDdHW sSkWk8fgdzKhTfemD464xTGZGM04MszRob5tLiEQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by sourceware.org (Postfix) with ESMTPS id 24364388E813 for ; Mon, 13 Jul 2020 17:10:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 24364388E813 Received: by mail-qt1-x844.google.com with SMTP id a32so10531929qtb.5 for ; Mon, 13 Jul 2020 10:10:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dpkETXr57I+oXUP7EtlXRZ22bRcDMKIDJZHNTHoOXkc=; b=Q4m7Y7Y0rAsrrog1tjWTLNE6TRWDbHQYrdsD0EPg9Hl4j31ehsawHGzWxgXy7RBHNv fpBZj+mIqsUuP1DhqRYwU+YwUovFJepBMxHuZl180JDqomm0IZpdtcqF/vnuMffqWw4m zWUOJY/r8ko1iGVX6duG34ecNUFedWY6SJ/kJH8f0QcMr7tPwu9MBaSEnY59oODtgmi+ SC00xbvQDnSCNF8YknCBc4PHRtijRGP/KMiJ3xMukgkKvg0TE2BE8NFSuNNMOK2ETFTM PV2N/qOATHgv3i+H0awi5bMrOb9mDW/FTnL9/3vM4HDOlSpL0uallutDSezPQmar7/Ls 3Dvw== X-Gm-Message-State: AOAM532Fty50oeL6Ij4x4ABSG/kL/OK8xpPd/t3soP/zhNz/ZeLN4vN1 PIrECqw1ZNtpvyAxPCli/cph/KM7qc0= X-Google-Smtp-Source: ABdhPJwIKTzgvhh0cX2pW2KCYyx1Hkc5bn0ZIKWEtMZMHrreGyXZoT+p9aJKgQqP+9uXYiDUdflHFw== X-Received: by 2002:ac8:4f50:: with SMTP id i16mr323854qtw.216.1594660242563; Mon, 13 Jul 2020 10:10:42 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:42 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 09/23] linux: Simplify timer_gettime Date: Mon, 13 Jul 2020 14:10:11 -0300 Message-Id: <20200713171025.3661832-9-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" With arch-syscall.h it can now assumes the existance of either __NR_timer_gettime or __NR_time_gettime_time64. The 32-bit time_t support is now only build for !__ASSUME_TIME64_SYSCALLS. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Lukasz Majewski --- sysdeps/unix/sysv/linux/timer_gettime.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/sysdeps/unix/sysv/linux/timer_gettime.c b/sysdeps/unix/sysv/linux/timer_gettime.c index 1e07d4845b..5d31c7c864 100644 --- a/sysdeps/unix/sysv/linux/timer_gettime.c +++ b/sysdeps/unix/sysv/linux/timer_gettime.c @@ -28,27 +28,23 @@ __timer_gettime64 (timer_t timerid, struct __itimerspec64 *value) { struct timer *kt = (struct timer *) timerid; -#ifdef __ASSUME_TIME64_SYSCALLS -# ifndef __NR_timer_gettime64 -# define __NR_timer_gettime64 __NR_timer_gettime -# endif - return INLINE_SYSCALL_CALL (timer_gettime64, kt->ktimerid, value); -#else -# ifdef __NR_timer_gettime64 +#ifndef __NR_timer_gettime64 +# define __NR_timer_gettime64 __NR_timer_gettime +#endif int ret = INLINE_SYSCALL_CALL (timer_gettime64, kt->ktimerid, value); +#ifndef __ASSUME_TIME64_SYSCALLS if (ret == 0 || errno != ENOSYS) return ret; -# endif + struct itimerspec its32; - int retval = INLINE_SYSCALL_CALL (timer_gettime, kt->ktimerid, &its32); - if (retval == 0) + ret = INLINE_SYSCALL_CALL (timer_gettime, kt->ktimerid, &its32); + if (ret == 0) { value->it_interval = valid_timespec_to_timespec64 (its32.it_interval); value->it_value = valid_timespec_to_timespec64 (its32.it_value); } - - return retval; #endif + return ret; } #if __TIMESIZE != 64 From patchwork Mon Jul 13 17:10:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40075 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B77B9388E813; Mon, 13 Jul 2020 17:10:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B77B9388E813 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660247; bh=tOm28MJ10DFnjRbjU8y94BHe1pMCT32YXOii8aDFUGo=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=vK/DjNskT7drjQETqSAxYt4JO6tanR6LoLOUmFtOwm9PUSU8NMccPSzdgqraJ6iLK i8nOgOAbfOU2XX47g0vGnxmp4btk2usWlSS5o0xI3gYluGegMJYVeG5NPq7YYdjkSe ZX55ky+JgqZVxsAtR+YCfK11tbpwpXOOHN7UWFZc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by sourceware.org (Postfix) with ESMTPS id DF814388E813 for ; Mon, 13 Jul 2020 17:10:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DF814388E813 Received: by mail-qt1-x842.google.com with SMTP id j10so10487565qtq.11 for ; Mon, 13 Jul 2020 10:10:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tOm28MJ10DFnjRbjU8y94BHe1pMCT32YXOii8aDFUGo=; b=SlMBn2O0aOOFrfpYSa1IG8I7W9W+qcc4Ym2eIyIWsS0rAECTtOuCb+TBI9Ns/xCh9D tyGdEpr/SxSgQRL35CEtYDILJUAPajlHpHsJIETz61nHwAY4bnN9iCs8vot6s+0iJ5IO mNPDLEETPDqHhNbG3iCe5YRcZe3kFz6jUTS7UPyAcO160rmLPXLkcHh10nyxrc0cYi1d oF8ZIoYymMUCN7DDxRkxV7mkuTpAlK8UL/IWkPFHyDshFgaHmuOsJzNapvji6+RNlHhK K6/STsTtMgpC03ZcTY+O/b9MGMwie1wRHcXDWVNpu4KOO6WuRa3+VxuK2fOWNNE0znta jHcA== X-Gm-Message-State: AOAM530PWxWdcBnnxDfKmaxJy1Na/teO8yX8Z/PTzJB7BuqtNNdSQMkr j/MOfSQ9zWbgKBT36tFit25AlGAlhzA= X-Google-Smtp-Source: ABdhPJxqcp2a0yobaF8qjexI2gUkNeiryxAt3AvBLSvI+d0Nq2mcfSYusRTnArMRYr0zpH0OtZbO+w== X-Received: by 2002:aed:2aa5:: with SMTP id t34mr290535qtd.363.1594660244219; Mon, 13 Jul 2020 10:10:44 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:43 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 10/23] linux: Simplify timerfd_settime Date: Mon, 13 Jul 2020 14:10:12 -0300 Message-Id: <20200713171025.3661832-10-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" With arch-syscall.h it can now assumes the existance of either __NR_timer_settime or __NR_time_settime_time64. The 32-bit time_t support is now only build for !__ASSUME_TIME64_SYSCALLS. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Lukasz Majewski --- sysdeps/unix/sysv/linux/timerfd_settime.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/sysdeps/unix/sysv/linux/timerfd_settime.c b/sysdeps/unix/sysv/linux/timerfd_settime.c index 164b4e860a..7c55e7e8d6 100644 --- a/sysdeps/unix/sysv/linux/timerfd_settime.c +++ b/sysdeps/unix/sysv/linux/timerfd_settime.c @@ -26,18 +26,13 @@ int __timerfd_settime64 (int fd, int flags, const struct __itimerspec64 *value, struct __itimerspec64 *ovalue) { -#ifdef __ASSUME_TIME64_SYSCALLS -# ifndef __NR_timerfd_settime64 -# define __NR_timerfd_settime64 __NR_timerfd_settime -# endif - return INLINE_SYSCALL_CALL (timerfd_settime64, fd, flags, value, ovalue); -#else -# ifdef __NR_timerfd_settime64 +#ifndef __NR_timerfd_settime64 +# define __NR_timerfd_settime64 __NR_timerfd_settime +#endif int ret = INLINE_SYSCALL_CALL (timerfd_settime64, fd, flags, value, ovalue); +#ifndef __ASSUME_TIME64_SYSCALLS if (ret == 0 || errno != ENOSYS) return ret; -# endif - struct itimerspec its32, oits32; if (! in_time_t_range ((value->it_value).tv_sec) || ! in_time_t_range ((value->it_interval).tv_sec)) @@ -46,19 +41,19 @@ __timerfd_settime64 (int fd, int flags, const struct __itimerspec64 *value, return -1; } + struct itimerspec its32, oits32; its32.it_interval = valid_timespec64_to_timespec (value->it_interval); its32.it_value = valid_timespec64_to_timespec (value->it_value); - int retval = INLINE_SYSCALL_CALL (timerfd_settime, fd, flags, - &its32, ovalue ? &oits32 : NULL); - if (retval == 0 && ovalue) + ret = INLINE_SYSCALL_CALL (timerfd_settime, fd, flags, + &its32, ovalue ? &oits32 : NULL); + if (ret == 0 && ovalue != NULL) { ovalue->it_interval = valid_timespec_to_timespec64 (oits32.it_interval); ovalue->it_value = valid_timespec_to_timespec64 (oits32.it_value); } - - return retval; #endif + return ret; } #if __TIMESIZE != 64 From patchwork Mon Jul 13 17:10:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40076 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BFE0F3890412; Mon, 13 Jul 2020 17:10:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFE0F3890412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660248; bh=QW6mQv3m0dD2g8wDj4jonFzJPEcwS7NmrZLjWDZLzCg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=uWpHj6O6jUnG+C1NL6TNXwWpdTz+6UNpibSBKtj3jBqJUA1yOkpX8DNPm7gy7Af35 dGW3nCj+9q45Cy2m5xmjZrDNgWcxk2JO/nl3wRtMLQwP2AqhDtc6mvyz8leZUW1bDZ j2tID6+jEt2JOeHSgxGM3mMcV6Gwks5M23Om63+k= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by sourceware.org (Postfix) with ESMTPS id 65439388E813 for ; Mon, 13 Jul 2020 17:10:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 65439388E813 Received: by mail-qt1-x843.google.com with SMTP id x62so10539091qtd.3 for ; Mon, 13 Jul 2020 10:10:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QW6mQv3m0dD2g8wDj4jonFzJPEcwS7NmrZLjWDZLzCg=; b=s/2Th+2MEaS6OwsBYznQMvjoOYsiqNiz1gMdCrQjYWGdJ4cmFO8/UyYuPIhQU4Akgv LX5GPRV/fW3FvBKDcTJWgrn2BJxOyTrGl9QRYApkUgcmg/zTEaltMZ6YSvylz5MR0Tpj 0T1uUR4qQHYmARDd4rRv8bawDgw9I7qtupRUwpqAj71GSEVszN46bLjotuGK2rwQr1WY PVb3YsYgmsvJUOOcVKslwPkyiyALN5iWdaEP1gfYimzpLqMZThHj+Rg6CiTI3l37HLls cc2ixwzA7HdpCm/c7wk/4hlfnyXyqsiKu6SWJmprcINWEPLMZ7v/cPQgAje7p7okgSfv KdyA== X-Gm-Message-State: AOAM533rrp6gcfbRhtSjJTtCVoidiJx/6ouDSmruIs6h+VT+XpyrfIxT GxxtexZXzlPGMtBjVPFA++H5NCVSA5I= X-Google-Smtp-Source: ABdhPJxji8YExQd4v/1up2f0Jm08C4vET/BRk/Ctc7dxYsppmuISPWNj3RGrGxRf62rN796afLqBoQ== X-Received: by 2002:ac8:4707:: with SMTP id f7mr377666qtp.22.1594660245694; Mon, 13 Jul 2020 10:10:45 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:45 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 11/23] linux: Simplify utimensat Date: Mon, 13 Jul 2020 14:10:13 -0300 Message-Id: <20200713171025.3661832-11-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" With arch-syscall.h it can now assumes the existance of either __NR_utimensat or __NR_utimensat_time64. The 32-bit time_t support is now only build for !__ASSUME_TIME64_SYSCALLS. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Lukasz Majewski --- sysdeps/unix/sysv/linux/utimensat.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/sysdeps/unix/sysv/linux/utimensat.c b/sysdeps/unix/sysv/linux/utimensat.c index eb16f0f3d5..ea23c2f051 100644 --- a/sysdeps/unix/sysv/linux/utimensat.c +++ b/sysdeps/unix/sysv/linux/utimensat.c @@ -28,18 +28,15 @@ int __utimensat64_helper (int fd, const char *file, const struct __timespec64 tsp64[2], int flags) { -#ifdef __ASSUME_TIME64_SYSCALLS -# ifndef __NR_utimensat_time64 -# define __NR_utimensat_time64 __NR_utimensat -# endif - return INLINE_SYSCALL (utimensat_time64, 4, fd, file, &tsp64[0], flags); -#else -# ifdef __NR_utimensat_time64 - int ret = INLINE_SYSCALL (utimensat_time64, 4, fd, file, &tsp64[0], flags); +#ifndef __NR_utimensat_time64 +# define __NR_utimensat_time64 __NR_utimensat +#endif + int ret = INLINE_SYSCALL_CALL (utimensat_time64, fd, file, &tsp64[0], flags); +#ifndef __ASSUME_TIME64_SYSCALLS if (ret == 0 || errno != ENOSYS) return ret; -# endif - if (tsp64 + + if (tsp64 != NULL && (! in_time_t_range (tsp64[0].tv_sec) || ! in_time_t_range (tsp64[1].tv_sec))) { @@ -54,10 +51,10 @@ __utimensat64_helper (int fd, const char *file, tsp32[1] = valid_timespec64_to_timespec (tsp64[1]); } - return INLINE_SYSCALL (utimensat, 4, fd, file, tsp64 ? &tsp32[0] : NULL, - flags); + ret = INLINE_SYSCALL_CALL (utimensat, fd, file, tsp64 ? &tsp32[0] : NULL, + flags); #endif - + return ret; } libc_hidden_def (__utimensat64_helper) From patchwork Mon Jul 13 17:10:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40077 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 51179389041E; Mon, 13 Jul 2020 17:10:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51179389041E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660250; bh=rwY4/LAvDgUQ4QRd4RvWM020cbtnwvb1urivhs24a7w=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=NSmmRS5EW87AvIeQrXL9grkT8+wI21zh40MvVs6zXfMOH11gIdEpo/NYANkRfvDNh f2aqvfCWAIi2KcI3XYwmkin1MJzNwqFOyNFSaS5aYM5XMM2iShFBPQobeiDohya9LD DUViFFZO9xA2p2Ef5zgk93wxmA01G7psghJqkwqQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by sourceware.org (Postfix) with ESMTPS id F33FD388E829 for ; Mon, 13 Jul 2020 17:10:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F33FD388E829 Received: by mail-qv1-xf41.google.com with SMTP id dm12so6104310qvb.9 for ; Mon, 13 Jul 2020 10:10:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rwY4/LAvDgUQ4QRd4RvWM020cbtnwvb1urivhs24a7w=; b=kkLArYr2AEyIyV8U1NuWebdH/4HaTlYNNxkPt5GN5a4jYIE8Fk7jlqRdtYeqESSLxS 5yJcXWaN8BqiUPm3e2mql/HPh4kVApJJh85uKm7zDJeFgn4Xzcg179xXPBYXS+Hm6M3U DgPrl3RLLmdP0il4Yhw30VsPIBVRuBMGy8ohCMaWGCXLZYiSfhE/mftRoMK9kqcqMQnM Q4fseJXcArE3MVH4J8S6v6LApBHjkYy6sNuumtiD2v2O8+PXASApF58l4zjBbS++AjuO 70iRx0rIVW3JCLN4DK3xEcPtgVtS4v04tfoiotvFVCuKoOiV4WIM4SXxmQu7dBNOf1as C1Bw== X-Gm-Message-State: AOAM5329vQoB2BnPJWkUczeYCV7/meFNoVHpM8HSo+W2rvH/QL2H6C78 MAiv3etX0Da5PJIiIz9B5e1DRonMgD8= X-Google-Smtp-Source: ABdhPJyXir4k7BjM2QeVu37P4LvbeTrBqjE5hQxNkM74BVludOYJ06akwpo0FYEmVMuVPG7BK7p0Iw== X-Received: by 2002:a0c:b520:: with SMTP id d32mr482557qve.6.1594660247220; Mon, 13 Jul 2020 10:10:47 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:46 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 12/23] linux: Add helper function to optimize 64-bit time_t fallback support Date: Mon, 13 Jul 2020 14:10:14 -0300 Message-Id: <20200713171025.3661832-12-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" These helper functions are used to optimize the 64-bit time_t support on configurations that requires support for 32-bit time_t fallback (!__ASSUME_TIME64_SYSCALLS). The idea is once the kernel advertises that it does not have 64-bit time_t support, glibc will stop to try issue the 64-bit time_t syscall altogether. For instance: #ifndef __NR_symbol_time64 # define __NR_symbol_time64 __NR_symbol #endif int r; if (supports_time64 ()) { r = INLINE_SYSCALL_CALL (symbol, ...); if (r == 0 || errno != ENOSYS) return r; mark_time64_unsupported (); } #ifndef __ASSUME_TIME64_SYSCALLS <32-bit fallback syscall> #endif return r; On configuration with default 64-bit time_t these optimization should be optimized away by the compiler resulting in no overhead. --- sysdeps/unix/sysv/linux/Makefile | 3 +- sysdeps/unix/sysv/linux/time64-support.c | 23 ++++++++ sysdeps/unix/sysv/linux/time64-support.h | 70 ++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 sysdeps/unix/sysv/linux/time64-support.c create mode 100644 sysdeps/unix/sysv/linux/time64-support.h diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 1932ccf7df..75c60a58f3 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -60,7 +60,8 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \ personality epoll_wait tee vmsplice splice \ open_by_handle_at mlock2 pkey_mprotect pkey_set pkey_get \ timerfd_gettime timerfd_settime prctl \ - process_vm_readv process_vm_writev clock_adjtime + process_vm_readv process_vm_writev clock_adjtime \ + time64-support CFLAGS-gethostid.c = -fexceptions CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables diff --git a/sysdeps/unix/sysv/linux/time64-support.c b/sysdeps/unix/sysv/linux/time64-support.c new file mode 100644 index 0000000000..9f03c9adda --- /dev/null +++ b/sysdeps/unix/sysv/linux/time64-support.c @@ -0,0 +1,23 @@ +/* Auxiliary definitions for 64-bit time_t support. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#ifndef __ASSUME_TIME64_SYSCALLS +int __time64_support = 1; +#endif diff --git a/sysdeps/unix/sysv/linux/time64-support.h b/sysdeps/unix/sysv/linux/time64-support.h new file mode 100644 index 0000000000..a997042fea --- /dev/null +++ b/sysdeps/unix/sysv/linux/time64-support.h @@ -0,0 +1,70 @@ +/* Auxiliary definitions for 64-bit time_t support. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +/* These helper functions are used to optimize the 64-bit time_t support on + configurations that requires support for 32-bit time_t fallback + (!__ASSUME_TIME64_SYSCALLS). The idea is once the kernel advertises that + it does not have 64-bit time_t support, glibc will stop to try issue the + 64-bit time_t syscall altogether. + + For instance: + + #ifndef __NR_symbol_time64 + # define __NR_symbol_time64 __NR_symbol + #endif + int r; + if (supports_time64 ()) + { + r = INLINE_SYSCALL_CALL (symbol, ...); + if (r == 0 || errno != ENOSYS) + return r; + + mark_time64_unsupported (); + } + #ifndef __ASSUME_TIME64_SYSCALLS + <32-bit fallback syscall> + #endif + return r; + + On configuration with default 64-bit time_t these optimization should be + optimized away by the compiler resulting in no overhead. */ + +#ifndef __ASSUME_TIME64_SYSCALLS +extern int __time64_support attribute_hidden; +#endif + +static inline bool +supports_time64 (void) +{ +#ifdef __ASSUME_TIME64_SYSCALLS + return true; +#else + return atomic_load_relaxed (&__time64_support) != 0; +#endif +} + +static inline void +mark_time64_unsupported (void) +{ +#ifndef __ASSUME_TIME64_SYSCALLS + atomic_store_relaxed (&__time64_support, 0); +#endif +} From patchwork Mon Jul 13 17:10:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40078 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 57655389043D; Mon, 13 Jul 2020 17:10:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57655389043D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660251; bh=kLx7TJqsatko9nnFeILPzHs+9ztpadEfqfDu4Em9o/w=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ZqR3lNC3VFDKZUes6ftL75QEzZc9M9fsPSTIAhLy9hXjvvHL2JvNNoxPcRzVkd2/N ADEh2jLYI5q0OywA/OixMG4Xd5WHlHWNibcLimV4bBlCloyt+hqb+fDWPywYIOxJCL dh+OEFWyyV/9MOBVr9kTQ81D9qfOj9ESHVwRMCXM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by sourceware.org (Postfix) with ESMTPS id 64ECF389041C for ; Mon, 13 Jul 2020 17:10:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 64ECF389041C Received: by mail-qv1-xf43.google.com with SMTP id u8so6097282qvj.12 for ; Mon, 13 Jul 2020 10:10:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kLx7TJqsatko9nnFeILPzHs+9ztpadEfqfDu4Em9o/w=; b=TQJRS+ZvLdzAuSaNQ6nWev77+ZB0Sg5nbZhJGIvziSUH0asDpHRqOkhrnEYT9rvNuY 7PNGA896xEOn1+hoPWmTybWYVXYFWI4MP/98z8Gt1oGdc9iGsY1DaYhz5Fc+QN9X/RGG CCYdyjm8lJ4eSHdWa+Q1BTyED1XmnjT7yT2lnvDT9EwwVxbT+F3LLnW1nGX9rgP/MZO5 y1PjzULJOikzg0EspJUYy3kqlnq4xuCUZbIBbbOOdNp2VivYDIOUbfwVfSX8wcy0Hal6 oCsDKTl9iCOQcvVi3LWQtVgIX/6oYDwIABZF1s6i9HBY3uZBfVs4oPiuI7tuo9eRFs80 87RQ== X-Gm-Message-State: AOAM532hIKpQqG3tCIMCjtFgmjbHpownZwvMMLmDx/GANAtmHR/USM5V NCS1b53XOGYSaKGgFrarseu5cYoiq8U= X-Google-Smtp-Source: ABdhPJxJruePdDlr50o7h0EA40AIYtRc9lomV1Ym/QL0HtRsUD9jy4/jfB3cZNZEuINsnU59dXB4Cw== X-Received: by 2002:a05:6214:8f4:: with SMTP id dr20mr424532qvb.228.1594660248743; Mon, 13 Jul 2020 10:10:48 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:48 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 13/23] linux: Simplify clock_getres Date: Mon, 13 Jul 2020 14:10:15 -0300 Message-Id: <20200713171025.3661832-13-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" With arch-syscall.h it can now assumes the existance of either __NR_clock_getres or __NR_clock_getres_time64. The 32-bit time_t support is now only build for !__ASSUME_TIME64_SYSCALLS. It also uses the time64-support functions to simplify it further. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). --- sysdeps/unix/sysv/linux/clock_getres.c | 38 ++++++++++---------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/sysdeps/unix/sysv/linux/clock_getres.c b/sysdeps/unix/sysv/linux/clock_getres.c index 5f6955ab10..6be73c94de 100644 --- a/sysdeps/unix/sysv/linux/clock_getres.c +++ b/sysdeps/unix/sysv/linux/clock_getres.c @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -28,36 +29,26 @@ int __clock_getres64 (clockid_t clock_id, struct __timespec64 *res) { -#ifdef __ASSUME_TIME64_SYSCALLS - /* 64 bit ABIs or Newer 32-bit ABIs that only support 64-bit time_t. */ -# ifndef __NR_clock_getres_time64 -# define __NR_clock_getres_time64 __NR_clock_getres -# endif -# ifdef HAVE_CLOCK_GETRES64_VSYSCALL - return INLINE_VSYSCALL (clock_getres_time64, 2, clock_id, res); -# else - return INLINE_SYSCALL_CALL (clock_getres_time64, clock_id, res); -# endif -#else int r; - /* Old 32-bit ABI with possible 64-bit time_t support. */ -# ifdef __NR_clock_getres_time64 - /* Avoid issue a __NR_clock_getres_time64 syscall on kernels that do not - support 64-bit time_t. */ - static int time64_support = 1; - if (atomic_load_relaxed (&time64_support) != 0) + +#ifndef __NR_clock_getres_time64 +# define __NR_clock_getres_time64 __NR_clock_getres +#endif + if (supports_time64 ()) { -# ifdef HAVE_CLOCK_GETRES64_VSYSCALL +#ifdef HAVE_CLOCK_GETRES64_VSYSCALL r = INLINE_VSYSCALL (clock_getres_time64, 2, clock_id, res); -# else +#else r = INLINE_SYSCALL_CALL (clock_getres_time64, clock_id, res); -# endif +#endif + if (r == 0 || errno != ENOSYS) return r; - atomic_store_relaxed (&time64_support, 0); + mark_time64_unsupported (); } -# endif + +#ifndef __ASSUME_TIME64_SYSCALLS /* Fallback code that uses 32-bit support. */ struct timespec ts32; # ifdef HAVE_CLOCK_GETRES_VSYSCALL @@ -67,8 +58,9 @@ __clock_getres64 (clockid_t clock_id, struct __timespec64 *res) # endif if (r == 0) *res = valid_timespec_to_timespec64 (ts32); - return r; #endif + + return r; } #if __TIMESIZE != 64 From patchwork Mon Jul 13 17:10:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40079 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DCA873892463; Mon, 13 Jul 2020 17:10:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DCA873892463 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660253; bh=6zOoBJXxtRpD6HJU6X3J8fnW/+fOLsNKVfpb+qobiO8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ksZZ4kfRzZ2/lF7bL0ReH4mgmtdGtD7xt5/RUCr0RpEhEALc8o25hOs5zeZw/HoFM Bn4PQwEl6kJ2wLLugOnldbN/qiJEeJHtjob8KkCG3/SpbbHzGBZiYfzB3aWIgU67QA yF0XFZ3JaSfDEUDKlsK/A1ETaU5KWMwxDKW7OzEk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by sourceware.org (Postfix) with ESMTPS id E020E389040B for ; Mon, 13 Jul 2020 17:10:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E020E389040B Received: by mail-qv1-xf41.google.com with SMTP id p7so6115541qvl.4 for ; Mon, 13 Jul 2020 10:10:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6zOoBJXxtRpD6HJU6X3J8fnW/+fOLsNKVfpb+qobiO8=; b=s+RAvx2WtjbARODfdXEYXVa6SMXc5Cou3YHhtIHnGZIXlwGZ++lAax3uONkMjhy6am KrAoduV1lhZeoyxz2tb6c9kgPZQjMWL8IJsJOfO8Q4OkYkFJPTgzlX2CX5aqDWBtwi1q 1HSw7d5z4MzA+kQDHsLzdy+j8JFCAKFCs6z6EiJCEjGlPSLNkSGohUk+uQ6a2gAFVgEl fP4kUofsiZK6tIhOBCWfOOFGtxCJCbtjR9Mk8nTNlyPMK/y2WepNFD6QB0sSlDHc0DFk sXzmDIUsufNUAEuQ7rzQvTJ3ZIY86PBZ+heGa27cfL+/iwwYs7uPvwb2FXTLhlHtznrD EscA== X-Gm-Message-State: AOAM533gpjbtPxAYFrTbbpUdLDm+ekWmMkFMg8bGyw5p9rXVdKjyyxln Fs0zH6fOtSnueXllcJFrjrT7WCej/SQ= X-Google-Smtp-Source: ABdhPJxG402mSuBYaTEXQt9jx2+opNwLhFk6ZlE0M7SwdlDvTGL2eIfkWRmS9BAPCVj/XQTBcgdtpQ== X-Received: by 2002:a05:6214:8d1:: with SMTP id da17mr474790qvb.62.1594660250229; Mon, 13 Jul 2020 10:10:50 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:49 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 14/23] linux: Add ppoll time64 optimization Date: Mon, 13 Jul 2020 14:10:16 -0300 Message-Id: <20200713171025.3661832-14-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" It avoid issues the __NR_ppoll_time64 syscall if the kernel does not support it. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). --- sysdeps/unix/sysv/linux/ppoll.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/sysdeps/unix/sysv/linux/ppoll.c b/sysdeps/unix/sysv/linux/ppoll.c index 079d56b5eb..c4e5b0e733 100644 --- a/sysdeps/unix/sysv/linux/ppoll.c +++ b/sysdeps/unix/sysv/linux/ppoll.c @@ -22,7 +22,7 @@ #include #include #include - +#include int __ppoll64 (struct pollfd *fds, nfds_t nfds, const struct __timespec64 *timeout, @@ -40,13 +40,20 @@ __ppoll64 (struct pollfd *fds, nfds_t nfds, const struct __timespec64 *timeout, #ifndef __NR_ppoll_time64 # define __NR_ppoll_time64 __NR_ppoll #endif - int ret = SYSCALL_CANCEL (ppoll_time64, fds, nfds, timeout, sigmask, + int ret; + + if (supports_time64 ()) + { + ret = SYSCALL_CANCEL (ppoll_time64, fds, nfds, timeout, sigmask, __NSIG_BYTES); -#ifdef __ASSUME_TIME64_SYSCALLS - if (ret >= 0 || errno != ENOSYS) - return ret; + if (ret == 0 || errno != ENOSYS) + return ret; + + mark_time64_unsupported (); + } +#ifndef __ASSUME_TIME64_SYSCALLS struct timespec ts32; if (timeout) { From patchwork Mon Jul 13 17:10:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40080 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6C68F3892445; Mon, 13 Jul 2020 17:10:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C68F3892445 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660255; bh=LGrvA7OMvGsXOGVf8yGnX1YJDxmfrEwV8zv5awOhtc0=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=QkUSJam9HLbi7LLm5OtC2dntHYgmDA7wgds4DKrBaZl/p7FuuM7X0v9gNsEtRW4tM 3v1TwpcaDB4emtUZvhXlyfMP+BO/u7azRHvnRv5OklEJVbrfRWU7ycrd/dpk9NXlLB MndvMC/odtzuUq8dS7CPipfQGJsJVanXQF84Xwh4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by sourceware.org (Postfix) with ESMTPS id B28083890425 for ; Mon, 13 Jul 2020 17:10:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B28083890425 Received: by mail-qk1-x744.google.com with SMTP id z63so12903295qkb.8 for ; Mon, 13 Jul 2020 10:10:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LGrvA7OMvGsXOGVf8yGnX1YJDxmfrEwV8zv5awOhtc0=; b=IWlmMKTLE5LJWkt3w8XD3RTDgkvN00L6yvWSOyjJOGC/jtNnMDvzAndH7CYJgsgtcs +ZBscDBPTbcABdf5/tArNPFbguirFyxO0Id/HG+41FKKAu+s7CHtga0CWLchEJWtM3VI J5sHg5OR5g9x8U/BSNhLF0gZgwVDS2mWQyQvVt+syyFc4QvVd1c/EVDHfeNGqNf+41Fg QBiRrGP4bD5v0OlkxhoUWSceMnfy852FsmcVX97/4wVATmtis9J9crSYrullX2luQQfo AzTg0eTorNB4RBNbeO8JkKEbkSZIUw2OF3A2Leq90qI3YA7BVODxiD80uZaWgcFKRYOx ZVcA== X-Gm-Message-State: AOAM5336hAEdoh/3PhTFw/eiE2wMCJyB0jlNHaTxGp9+IYrrcgJpGre6 oUfqG9eb+naKgOwjMgyL0S4B5hTOhiY= X-Google-Smtp-Source: ABdhPJwDsqMsAbdmh1FJaS7jILEVRbMLA3FeJFJa8CVEGQ61F3rsHDnosT9rbNU3HmEb1bBvI+PNTQ== X-Received: by 2002:a37:9dc5:: with SMTP id g188mr509540qke.427.1594660252069; Mon, 13 Jul 2020 10:10:52 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:51 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 15/23] linux: Add time64 semtimedop support Date: Mon, 13 Jul 2020 14:10:17 -0300 Message-Id: <20200713171025.3661832-15-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Either the __NR_semtimedop_time64 (for 32-bit) or the __NR_semtimedop (for 64-bit) syscall is used as default. The 32-bit fallback is used iff __ASSUME_TIME64_SYSCALLS is not defined, which assumes the kernel ABI provides either __NR_ipc or __NR_semtimeop (for 32-bit time_t). Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). --- sysdeps/unix/sysv/linux/include/sys/sem.h | 6 +++ sysdeps/unix/sysv/linux/semtimedop.c | 57 +++++++++++++++++++---- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/sysdeps/unix/sysv/linux/include/sys/sem.h b/sysdeps/unix/sysv/linux/include/sys/sem.h index a9151e057d..f369c6b6d3 100644 --- a/sysdeps/unix/sysv/linux/include/sys/sem.h +++ b/sysdeps/unix/sysv/linux/include/sys/sem.h @@ -7,9 +7,15 @@ __typeof__ (semtimedop) __semtimedop attribute_hidden; #if __TIMESIZE == 64 # define __semctl64 __semctl +# define __semtimedop64 __semtimedop #else +# include + extern int __semctl64 (int semid, int semnum, int cmd, ...); libc_hidden_proto (__semctl64); +extern int __semtimedop64 (int semid, struct sembuf *sops, size_t nsops, + const struct __timespec64 *tmo); +libc_hidden_proto (__semtimedop64); #endif # endif diff --git a/sysdeps/unix/sysv/linux/semtimedop.c b/sysdeps/unix/sysv/linux/semtimedop.c index 6fdde09bad..d755a820d8 100644 --- a/sysdeps/unix/sysv/linux/semtimedop.c +++ b/sysdeps/unix/sysv/linux/semtimedop.c @@ -22,18 +22,59 @@ #include /* Perform user-defined atomical operation of array of semaphores. */ +int +__semtimedop64 (int semid, struct sembuf *sops, size_t nsops, + const struct __timespec64 *timeout) +{ +#if defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS +# ifndef __NR_semtimedop_time64 +# define __NR_semtimedop_time64 __NR_semtimedop +# endif + int r = INLINE_SYSCALL_CALL (semtimedop_time64, semid, sops, nsops, + timeout); +#else + int r = INLINE_SYSCALL_CALL (ipc, IPCOP_semtimedop, semid, + SEMTIMEDOP_IPC_ARGS (nsops, sops, timeout)); +#endif + +#ifndef __ASSUME_TIME64_SYSCALLS + if (r == 0 || errno != ENOSYS) + return r; + + struct timespec ts32, *pts32 = NULL; + if (timeout != NULL) + { + if (! in_time_t_range (timeout->tv_sec)) + { + __set_errno (EINVAL); + return -1; + } + ts32 = valid_timespec64_to_timespec (*timeout); + pts32 = &ts32; + } +# if defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS + r = INLINE_SYSCALL_CALL (semtimedop, semid, sops, nsops, pts32); +# else + r = INLINE_SYSCALL_CALL (ipc, IPCOP_semtimedop, semid, + SEMTIMEDOP_IPC_ARGS (nsops, sops, pts32)); +# endif +#endif /* __ASSUME_TIME64_SYSCALLS */ + return r; +} +#if __TIMESIZE != 64 +libc_hidden_def (__semtimedop64) int __semtimedop (int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout) { - /* semtimedop wire-up syscall is not exported for 32-bit ABIs (they have - semtimedop_time64 instead with uses a 64-bit time_t). */ -#if defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS && defined __NR_semtimedop - return INLINE_SYSCALL_CALL (semtimedop, semid, sops, nsops, timeout); -#else - return INLINE_SYSCALL_CALL (ipc, IPCOP_semtimedop, semid, - SEMTIMEDOP_IPC_ARGS (nsops, sops, timeout)); -#endif + struct __timespec64 ts64, *pts64 = NULL; + if (timeout != 0) + { + ts64 = valid_timespec_to_timespec64 (*timeout); + pts64 = &ts64; + } + return __semtimedop64 (semid, sops, nsops, pts64); } +#endif weak_alias (__semtimedop, semtimedop) From patchwork Mon Jul 13 17:10:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40081 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EE62D389040B; Mon, 13 Jul 2020 17:10:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE62D389040B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660258; bh=f77JvXSd9+bqzJjNZ4ZfCy9sgcd9nwPspq5l6PVN8b4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=s2OWOKSLBjIt5rqNIbZLIXKPeRtnXL2j6qAnBfZJByn/Q6poCADvEtaWQF4JPTTWj HkC7ppbxntVD0qYEL8NSAZqXiiK5cP7YE8M59nylbt0q0OkohQKNs9pbtc6HUu6u1O JsFfzvBUWxdzXFDiJqFTAlBJ3yQU4TI9nudG02YU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by sourceware.org (Postfix) with ESMTPS id 7F582389040B for ; Mon, 13 Jul 2020 17:10:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7F582389040B Received: by mail-qt1-x842.google.com with SMTP id w27so10483477qtb.7 for ; Mon, 13 Jul 2020 10:10:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f77JvXSd9+bqzJjNZ4ZfCy9sgcd9nwPspq5l6PVN8b4=; b=FpLEb4W1NB62iMp77h8zTcBJYc1JFlgmZtkODVGSS55Nh6xiO+xEhuq4rd6Fj7TJtY +uV0pDQABCdY91to2QAKGRA2pv+1ZUhwc/YC83rjz9EZln12ndgtmuoSebrgOmg7jSqM uclZWsC12j929PzyAKpNLPXLh3xa4J+qgDqzWGFxuvpzkGrb20INkKF/vNG2/3NDKajg ePYJDNarn7gBMDau7J9aHtzqjYgbLA1kLS5K0N8MOhWe79/UYUBoY3TDc5vQA1rsgSaI wAj28oM3aMIMkXeuwitmgKDGIsyqCTAfF3xs2NxU9ijPVbGcnSi38UX7t+o04mLDT+bt pfVQ== X-Gm-Message-State: AOAM531IEp8urowE73rZHHSdsvTrtB+Xuo6s0NAEXadZr0JST5sUXrl7 u4E5tDc+prb2kbsdD55Q9qTM7E1ujtc= X-Google-Smtp-Source: ABdhPJyt+Ey+nt52uEhzDp0zG1nrgRnEaIYXPvZLPaloDBeOPunFDEzAOdcqqhalBX+6pduDsZ0C1Q== X-Received: by 2002:ac8:1991:: with SMTP id u17mr299665qtj.93.1594660253742; Mon, 13 Jul 2020 10:10:53 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:53 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 16/23] linux: Add time64 pselect support Date: Mon, 13 Jul 2020 14:10:18 -0300 Message-Id: <20200713171025.3661832-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The syscall __NR_pselect6_time64 (32-bit) or __NR_pselect6 (64-bit) is used as default. For architectures with __ASSUME_TIME64_SYSCALLS the 32-bit fallback uses __NR_pselec6. To accomodate microblaze missing pselect6 support on kernel older than 3.15 the fallback is moved to its own function to the microblaze specific implementation can override it. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). --- include/sys/select.h | 10 +++ sysdeps/unix/sysv/linux/microblaze/pselect.c | 38 ++++------ sysdeps/unix/sysv/linux/pselect.c | 80 +++++++++++++++++--- 3 files changed, 93 insertions(+), 35 deletions(-) diff --git a/include/sys/select.h b/include/sys/select.h index 07bb49b994..460dee9295 100644 --- a/include/sys/select.h +++ b/include/sys/select.h @@ -3,6 +3,16 @@ #ifndef _ISOMAC /* Now define the internal interfaces. */ +# if __TIMESIZE == 64 +# define __pselect64 __pselect +#else +# include +extern int __pselect64 (int __nfds, fd_set *__readfds, + fd_set *__writefds, fd_set *__exceptfds, + const struct __timespec64 *__timeout, + const __sigset_t *__sigmask); +libc_hidden_proto (__pselect64) +#endif extern int __pselect (int __nfds, fd_set *__readfds, fd_set *__writefds, fd_set *__exceptfds, const struct timespec *__timeout, diff --git a/sysdeps/unix/sysv/linux/microblaze/pselect.c b/sysdeps/unix/sysv/linux/microblaze/pselect.c index 1dfc3b8fc9..e73a98e178 100644 --- a/sysdeps/unix/sysv/linux/microblaze/pselect.c +++ b/sysdeps/unix/sysv/linux/microblaze/pselect.c @@ -23,38 +23,27 @@ #include #ifndef __ASSUME_PSELECT -# define __pselect __pselect_syscall -#endif - -/* If pselect is supported, just use the Linux generic implementation. */ -#include - -#ifndef __ASSUME_PSELECT -# undef __pselect -int -__pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, - const struct timespec *timeout, const sigset_t *sigmask) +static int +__pselect64_fallback (int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, const struct __timespec64 *timeout, + const sigset_t *sigmask) { - int ret = __pselect_syscall (nfds, readfds, writefds, exceptfds, timeout, - sigmask); - if (ret >= 0 || errno != ENOSYS) - return ret; - /* The fallback uses 'select' which shows the race condition regarding signal mask set/restore, requires two additional syscalls, and has a worse timeout precision (microseconds instead of nanoseconds). */ - struct timeval tval, *ptval = NULL; + struct timeval tv32, *ptv32 = NULL; if (timeout != NULL) { - if (! valid_nanoseconds (timeout->tv_nsec)) + if (! in_time_t_range (timeout->tv_sec) + || ! valid_nanoseconds (timeout->tv_nsec)) { __set_errno (EINVAL); return -1; } - TIMESPEC_TO_TIMEVAL (&tval, timeout); - ptval = &tval; + tv32 = valid_timespec64_to_timeval (*timeout); + ptv32 = &tv32; } sigset_t savemask; @@ -62,12 +51,15 @@ __pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, __sigprocmask (SIG_SETMASK, sigmask, &savemask); /* select itself is a cancellation entrypoint. */ - ret = __select (nfds, readfds, writefds, exceptfds, ptval); + int r = __select (nfds, readfds, writefds, exceptfds, ptv32); if (sigmask != NULL) __sigprocmask (SIG_SETMASK, &savemask, NULL); - return ret; + return r; } -weak_alias (__pselect, pselect) +# define PSELECT64_FALLBACK #endif + +/* If pselect is supported, just use the Linux generic implementation. */ +#include diff --git a/sysdeps/unix/sysv/linux/pselect.c b/sysdeps/unix/sysv/linux/pselect.c index 304db03338..c31a13767a 100644 --- a/sysdeps/unix/sysv/linux/pselect.c +++ b/sysdeps/unix/sysv/linux/pselect.c @@ -18,14 +18,41 @@ #include #include +#include + +#if !defined (__ASSUME_TIME64_SYSCALLS) && !defined (PSELECT64_FALLBACK) +static int +__pselect64_fallback (int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, const struct __timespec64 *timeout, + const sigset_t *sigmask) +{ + struct timespec ts32, *pts32 = NULL; + if (timeout != NULL) + { + if (! in_time_t_range (timeout->tv_sec)) + { + __set_errno (EINVAL); + return -1; + } + + ts32 = valid_timespec64_to_timespec (*timeout); + pts32 = &ts32; + } + + return SYSCALL_CANCEL (pselect6, nfds, readfds, writefds, exceptfds, + pts32, + ((__syscall_ulong_t[]){ (uintptr_t) sigmask, + __NSIG_BYTES })); +} +#endif int -__pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, - const struct timespec *timeout, const sigset_t *sigmask) +__pselect64 (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, + const struct __timespec64 *timeout, const sigset_t *sigmask) { /* The Linux kernel can in some situations update the timeout value. We do not want that so use a local variable. */ - struct timespec tval; + struct __timespec64 tval; if (timeout != NULL) { tval = *timeout; @@ -36,18 +63,47 @@ __pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, we can only pass in 6 directly. If there is an architecture with support for more parameters a new version of this file needs to be created. */ - struct - { - __syscall_ulong_t ss; - __syscall_ulong_t ss_len; - } data; - data.ss = (__syscall_ulong_t) (uintptr_t) sigmask; - data.ss_len = __NSIG_BYTES; +#ifndef __NR_pselect6_time64 +# define __NR_pselect6_time64 __NR_pselect6 +#endif + int r; + if (supports_time64 ()) + { + r = SYSCALL_CANCEL (pselect6_time64, nfds, readfds, writefds, exceptfds, + timeout, + ((__syscall_ulong_t[]){ (uintptr_t) sigmask, + __NSIG_BYTES })); + if (r == 0 || errno != ENOSYS) + return r; - return SYSCALL_CANCEL (pselect6, nfds, readfds, writefds, exceptfds, - timeout, &data); + mark_time64_unsupported (); + } + +#ifndef __ASSUME_TIME64_SYSCALLS + r = __pselect64_fallback (nfds, readfds, writefds, exceptfds, timeout, + sigmask); +#endif + return r; } + +#if __TIMESIZE != 64 +libc_hidden_def (__pselect64) + +int +__pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, + const struct timespec *timeout, const sigset_t *sigmask) +{ + struct __timespec64 ts64, *pts64 = NULL; + if (timeout != NULL) + { + ts64 = valid_timespec_to_timespec64 (*timeout); + pts64 = &ts64; + } + return __pselect64 (nfds, readfds, writefds, exceptfds, pts64, sigmask); +} +#endif + #ifndef __pselect weak_alias (__pselect, pselect) #endif From patchwork Mon Jul 13 17:10:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40082 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D31F3898525; Mon, 13 Jul 2020 17:10:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D31F3898525 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660258; bh=gzeDLfj1NRFtYzyRbWCf17JpY+zgay8OyC2e09xgw0s=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=XXVZaKTouByVrn/ylUMpIp7Ni85aQYZ781/tfBgWzoa6jkIJMiqRoViwMUGNstB1o AVbj5Vy9AtDPVp4eVfeShkcphXIR5h68BnRwYOc1QMDqiMdlvSi60WVPHjyN6DZ0Lr wdlna1G9G5YOk9Qrwz/9xD2PC6FfXl2Fd2cBUPSI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by sourceware.org (Postfix) with ESMTPS id 0F0C138930D5 for ; Mon, 13 Jul 2020 17:10:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0F0C138930D5 Received: by mail-qt1-x842.google.com with SMTP id u12so10476774qth.12 for ; Mon, 13 Jul 2020 10:10:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gzeDLfj1NRFtYzyRbWCf17JpY+zgay8OyC2e09xgw0s=; b=k3KpQoWIWquhPjzCvLkRG9MMc4sOF67CJHDac6q6excWwKN5p1G00vhvEFaE+pFabp k/w5/5Kccuu4oJbIdqdTGkH9c2tESDirBgVxpefKU2625MegTzrw2W30FDERZCXHkErG +IBQ6cm6LaU+251NTupdyajK2WsyMcrtqENt90P1D7+MX5lD7YN+EkG+NMAbTNQiQaBp gzBpbmJ43aaAE5acuO5WZuWCE/DBf3ttFop1CwBCsTZd5g2SfRMlMdXwu2FeEQwu8iNm AXb/AGMJatAkwsZyJAG0k0H6QgayFTP4swfDJYZwJ9rnVta/rePYoGuBxsAnNVrJnpFE sFVw== X-Gm-Message-State: AOAM5333DuseLe1zOlZwTZ4Wa65q8oQKKLLDiRc3b1zJnVfK8/uPifur edFuQEjS4X8iZZLDG0MHvCo62ZyK9wA= X-Google-Smtp-Source: ABdhPJzyjasZ2v2aTn2calAi41y/9x1mf0Hwnl9JA0uLP7tJlnUOYB/ok56Kk/gaZ5Zya/ly1OrBOg== X-Received: by 2002:ac8:7959:: with SMTP id r25mr302047qtt.85.1594660255168; Mon, 13 Jul 2020 10:10:55 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:54 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 17/23] linux: Add time64 select support Date: Mon, 13 Jul 2020 14:10:19 -0300 Message-Id: <20200713171025.3661832-17-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The syscall __NR_pselect6_time64 (32-bit) or __NR_pselect6 (64-bit) is used as default. For architectures with __ASSUME_TIME64_SYSCALLS the 32-bit fallback uses __NR_select/__NR__newselect or __NR_pselect6 (it should cover the microblaze case where older kernels do not provide __NR_pselect6). Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). --- include/sys/select.h | 8 +++ include/time.h | 6 ++ sysdeps/unix/sysv/linux/select.c | 96 +++++++++++++++++++++++--------- 3 files changed, 83 insertions(+), 27 deletions(-) diff --git a/include/sys/select.h b/include/sys/select.h index 460dee9295..370b662ea7 100644 --- a/include/sys/select.h +++ b/include/sys/select.h @@ -5,13 +5,21 @@ /* Now define the internal interfaces. */ # if __TIMESIZE == 64 # define __pselect64 __pselect +# define __select64 __select #else # include +# include + extern int __pselect64 (int __nfds, fd_set *__readfds, fd_set *__writefds, fd_set *__exceptfds, const struct __timespec64 *__timeout, const __sigset_t *__sigmask); libc_hidden_proto (__pselect64) + +extern int __select64 (int __nfds, fd_set *__readfds, + fd_set *__writefds, fd_set *__exceptfds, + struct __timeval64 *__timeout); +libc_hidden_proto (__select64) #endif extern int __pselect (int __nfds, fd_set *__readfds, fd_set *__writefds, fd_set *__exceptfds, diff --git a/include/time.h b/include/time.h index fe4da9ca10..936486e206 100644 --- a/include/time.h +++ b/include/time.h @@ -464,6 +464,12 @@ valid_timespec_to_timeval32 (const struct timespec ts) return (struct __timeval32) { (time_t) ts.tv_sec, ts.tv_nsec / 1000 }; } +static inline struct __timeval64 +valid_timespec_to_timeval64 (const struct timespec ts) +{ + return (struct __timeval64) { (time_t) ts.tv_sec, ts.tv_nsec / 1000 }; +} + /* Check if a value is in the valid nanoseconds range. Return true if it is, false otherwise. */ static inline bool diff --git a/sysdeps/unix/sysv/linux/select.c b/sysdeps/unix/sysv/linux/select.c index 54c50edba2..df4fcc3362 100644 --- a/sysdeps/unix/sysv/linux/select.c +++ b/sysdeps/unix/sysv/linux/select.c @@ -21,6 +21,7 @@ #include #include #include +#include /* Check the first NFDS descriptors each in READFDS (if not NULL) for read readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS @@ -28,43 +29,84 @@ after waiting the interval specified therein. Returns the number of ready descriptors, or -1 for errors. */ -#ifdef __NR__newselect -# undef __NR_select -# define __NR_select __NR__newselect -#endif - int -__select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, - struct timeval *timeout) +__select64 (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, + struct __timeval64 *timeout) { -#ifdef __NR_select - return SYSCALL_CANCEL (select, nfds, readfds, writefds, exceptfds, - timeout); -#else - int result; - struct timespec ts, *tsp = NULL; - - if (timeout) + struct __timespec64 ts64, *pts64 = NULL; + if (timeout != NULL) { - TIMEVAL_TO_TIMESPEC (timeout, &ts); - tsp = &ts; + ts64 = timeval64_to_timespec64 (*timeout); + pts64 = &ts64; } - result = SYSCALL_CANCEL (pselect6, nfds, readfds, writefds, exceptfds, tsp, - NULL); - - if (timeout) +#ifndef __NR_pselect6_time64 +# define __NR_pselect6_time64 __NR_pselect6 +#endif + int r; + if (supports_time64 ()) { - /* Linux by default will update the timeout after a pselect6 syscall - (though the pselect() glibc call suppresses this behavior). - Since select() on Linux has the same behavior as the pselect6 - syscall, we update the timeout here. */ - TIMESPEC_TO_TIMEVAL (timeout, &ts); + r = SYSCALL_CANCEL (pselect6_time64, nfds, readfds, writefds, exceptfds, + pts64, NULL); + if (r == 0 || errno != ENOSYS) + { + if (timeout != NULL) + TIMEVAL_TO_TIMESPEC (timeout, &ts64); + return r; + } + + mark_time64_unsupported (); } - return result; +#ifndef __ASSUME_TIME64_SYSCALLS + struct timespec ts32, *pts32 = NULL; + if (timeout != NULL) + { + if (! in_time_t_range (timeout->tv_sec)) + { + __set_errno (EINVAL); + return -1; + } + ts32 = valid_timespec64_to_timespec (ts64); + pts32 = &ts32; + } +# ifndef __ASSUME_PSELECT +# ifdef __NR__newselect +# undef __NR_select +# define __NR_select __NR__newselect +# endif + r = SYSCALL_CANCEL (select, nfds, readfds, writefds, exceptfds, pts32); +# else + r = SYSCALL_CANCEL (pselect6, nfds, readfds, writefds, exceptfds, pts32, + NULL); +# endif + if (r >= 0 && timeout != NULL) + *timeout = valid_timespec_to_timeval64 (ts32); #endif + + return r; } + +#if __TIMESIZE != 64 +libc_hidden_def (__select64) + +int +__select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, + struct timeval *timeout) +{ + struct __timeval64 tv64, *ptv64 = NULL; + if (timeout != 0) + { + tv64 = valid_timeval_to_timeval64 (*timeout); + ptv64 = &tv64; + } + int r = __select64 (nfds, readfds, writefds, exceptfds, ptv64); + if (r >= 0 && timeout != NULL) + /* The remanining timeout will be always less the input TIMEOUT. */ + *timeout = valid_timeval64_to_timeval (tv64); + return r; +} +#endif libc_hidden_def (__select) weak_alias (__select, select) From patchwork Mon Jul 13 17:10:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40083 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 823AF388E829; Mon, 13 Jul 2020 17:11:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 823AF388E829 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660261; bh=EHsguGR8P9+0Y2TaO3iX2v/qiKUD7DL3dcMqx9FA9ww=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=jRO2urjI6aCOy3/yOsq50A+WTEs+acQ60N3msqEIfuMbyyfgAl9BqnQ8IVV8u8W24 jJME3pk/WsenfJ6yWxnkl3wBZtpinqVwyUSpK0ggORtlxZLi35IzBRFpl9F9U1KtJH LxF/wPA8QeiD5Gjiqxd0uvDP0Cc9hORV2fE8Zt3s= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by sourceware.org (Postfix) with ESMTPS id 643EF389041C for ; Mon, 13 Jul 2020 17:10:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 643EF389041C Received: by mail-qk1-x741.google.com with SMTP id c139so12909777qkg.12 for ; Mon, 13 Jul 2020 10:10:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EHsguGR8P9+0Y2TaO3iX2v/qiKUD7DL3dcMqx9FA9ww=; b=TxSyikN0n6KFYzrvz9f1vAAVNvis3nruwENZfN5mgEJmbfU2i2vuDNydq9gzjNOfdl /ZgoH5Ht1LwV/rAczXuIsQa4THMKUWkACD7MJklQEZ6f/Aweoam48ZeLAPFDYPbyoRyW 6/3ZDjUTdofIEYWPvNrOmLG90q1AeRUj4/kK6GBr+Rwen2WxDwEvvn61RMRti3N4Z/9T THR6HNevUwOhs6zm8dmRTEL/XvbiAJJdQGQPNkw8M2gAXvD7ZdXwkXVapdYbz5VOWA3D EkLDcd4m8V5ir7zHXwgjMHHor2l4p/nHQNzt/P3v97amUhxS95RqoBmjGis/sVPNbdYq +KWA== X-Gm-Message-State: AOAM530Iydfes+szZZo4E0rB5UDPhaxRKPwKkp+N5AhWR5OAr5LzQTVk 34UCYXa+flgyI0Q7i6MbdzERfvjZd5E= X-Google-Smtp-Source: ABdhPJwWYsluaF6xMdXimYqB/Sw1OBFLmbVgmnthbn3WYXj2d7ri1M6ZDwETFVTaM6Ruhl0s2KeIHg== X-Received: by 2002:a37:a6c2:: with SMTP id p185mr599462qke.78.1594660256675; Mon, 13 Jul 2020 10:10:56 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:56 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 18/23] linux: Add time64 recvmmsg support Date: Mon, 13 Jul 2020 14:10:20 -0300 Message-Id: <20200713171025.3661832-18-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The wire-up syscall __NR_recvmmsg_time64 (for 32-bit) or __NR_recvmmsg (for 64-bit) is used as default. The 32-bit fallback is used iff __ASSUME_TIME64_SYSCALLS is not defined, which assumes the kernel ABI provides either __NR_socketcall or __NR_recvmmsg (32-bit time_t). It does not handle the timestamps on ancillary data (SCM_TIMESTAMPING records). Checked on x86_64-linux-gnu and i686-linux-gnu. --- include/sys/socket.h | 8 ++++ sysdeps/unix/sysv/linux/recvmmsg.c | 63 ++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/include/sys/socket.h b/include/sys/socket.h index 26db0e0d77..0e39dd2a3a 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -104,6 +104,14 @@ extern ssize_t __libc_recvmsg (int __fd, struct msghdr *__message, int __flags); extern ssize_t __recvmsg (int __fd, struct msghdr *__message, int __flags) attribute_hidden; +#if __TIMESIZE == 64 +# define __recvmmsg64 __recvmmsg +#else +extern int __recvmmsg64 (int __fd, struct mmsghdr *vmessages, + unsigned int vlen, int flags, + struct __timespec64 *timeout); +libc_hidden_proto (__recvmmsg64) +#endif /* Set socket FD's option OPTNAME at protocol level LEVEL to *OPTVAL (which is OPTLEN bytes long). diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c index 42c80c59c3..a29c91fb76 100644 --- a/sysdeps/unix/sysv/linux/recvmmsg.c +++ b/sysdeps/unix/sysv/linux/recvmmsg.c @@ -16,21 +16,62 @@ License along with the GNU C Library; if not, see . */ -#include #include - -#include -#include +#include #include -#include int -recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, - struct timespec *tmo) +__recvmmsg64 (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, + struct __timespec64 *timeout) { -#ifdef __ASSUME_RECVMMSG_SYSCALL - return SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo); -#else - return SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo); +#ifndef __NR_recvmmsg_time64 +# define __NR_recvmmsg_time64 __NR_recvmmsg #endif + int r = SYSCALL_CANCEL (recvmmsg_time64, fd, vmessages, vlen, flags, + timeout); +#ifndef __ASSUME_TIME64_SYSCALLS + if (r >= 0 || errno != ENOSYS) + return r; + + struct timespec ts32, *pts32 = NULL; + if (timeout != NULL) + { + if (! in_time_t_range (timeout->tv_sec)) + { + __set_errno (EINVAL); + return -1; + } + ts32 = valid_timespec64_to_timespec (*timeout); + pts32 = &ts32; + } +# ifdef __ASSUME_RECVMMSG_SYSCALL + r = SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, pts32); +# else + r = SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, pts32); +# endif + if (r >= 0 && timeout != NULL) + *timeout = valid_timespec_to_timespec64 (ts32); +#endif /* __ASSUME_TIME64_SYSCALLS */ + return r; } +#if __TIMESIZE != 64 +libc_hidden_def (__recvmmsg64) + +int +__recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, + struct timespec *timeout) +{ + struct __timespec64 ts64, *pts64 = NULL; + if (timeout != NULL) + { + ts64 = valid_timespec_to_timespec64 (*timeout); + pts64 = &ts64; + } + int r = __recvmmsg64 (fd, vmessages, vlen, flags, pts64); + if (r >= 0) + /* The remanining timeout will be always less the input TIMEOUT. */ + *timeout = valid_timespec64_to_timespec (ts64); + return r; +} +#endif +weak_alias (__recvmmsg, recvmmsg) From patchwork Mon Jul 13 17:10:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40084 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A66B3938C36; Mon, 13 Jul 2020 17:11:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A66B3938C36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660262; bh=mauR+a3H3RiGcf+jt0nW0p/jIPqxvxxQDykT1X5Os0k=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=EcqSPahbjld0l5r5Y5PJvUPpWOXWoXmHV7B3j25pxmDUC12FMw5ShcfpOe1M65fi2 pin3mlpFL4agnPF3EIR2qWgIRCAiRFr1jDf7czu88DxNt9+NIhmwf6jpi4WRi8giua WEwCbHpkbZSjvYYu1Fs3Gbaq9Tj4VcLEpc5J6nUw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by sourceware.org (Postfix) with ESMTPS id C0C84389041C for ; Mon, 13 Jul 2020 17:10:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C0C84389041C Received: by mail-qk1-x741.google.com with SMTP id 80so12921137qko.7 for ; Mon, 13 Jul 2020 10:10:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mauR+a3H3RiGcf+jt0nW0p/jIPqxvxxQDykT1X5Os0k=; b=Aqtz7utAMAJjRw6mt5iBiepdbrMNEe5QlVkIP0jwX0Vn9hQ30y1ul8ou6HLTn0xorg X3gVOdVhGZ/U6om3UVFWdawHPsG2GMv2GdoNiB44xmCXJI2RKwWKTNzx70+/4E6I9+SD usfq/p6DhOQ2V6Lvol3LeH1CKWczumsU3w8gP6p/i3/tNorGtsLEnjzbrFOOzewrAiYb Aas9N/i2XJyWmSuqVQk7KN1YEN5toqH1SsAQltonM6inC3L3Hhv3AXDVUrdUC18llWym nbQmn9gt6Xga8MatK29fG8giKKSr4KZMuM6vCyA9QZjdfu6K4iDT+GPfte6RSfLe/xT4 4T4A== X-Gm-Message-State: AOAM531J2zoxSGpTvlkRFE+wqRvZWL/q2bZnozvEFkJdgCOJZE88gMxm wSovtyMo2X8meLz8EhEI+fjl9kusxQU= X-Google-Smtp-Source: ABdhPJxQ2fX+/wP4ej6EBQdklcCDp2CwVNQRDx3N6M3ZR20TsheSSWzyzXAL9V+qftDacNK7qSY8bQ== X-Received: by 2002:a37:9284:: with SMTP id u126mr583877qkd.127.1594660258139; Mon, 13 Jul 2020 10:10:58 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:57 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 19/23] linux: Add time64 sigtimedwait support Date: Mon, 13 Jul 2020 14:10:21 -0300 Message-Id: <20200713171025.3661832-19-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The syscall __NR_sigtimedwait_time64 (for 32-bit) or __NR_sigtimedwait (for 64-bit) is used as default. The 32-bit fallback is used iff __ASSUME_TIME64_SYSCALLS is not defined, which assumes the kernel ABI provides either __NR_rt_sigtimedwait (32-bit time_t). Checked on x86_64-linux-gnu and i686-linux-gnu. --- include/signal.h | 8 ++++ sysdeps/unix/sysv/linux/sigtimedwait.c | 59 +++++++++++++++++++++----- 2 files changed, 56 insertions(+), 11 deletions(-) diff --git a/include/signal.h b/include/signal.h index b4ee02d153..544d701bce 100644 --- a/include/signal.h +++ b/include/signal.h @@ -38,6 +38,14 @@ extern int __sigwait (const sigset_t *__set, int *__sig); libc_hidden_proto (__sigwait) extern int __sigwaitinfo (const sigset_t *__set, siginfo_t *__info); libc_hidden_proto (__sigwaitinfo) +#if __TIMESIZE == 64 +# define __sigtimedwait64 __sigtimedwait +#else +# include +extern int __sigtimedwait64 (const sigset_t *__set, siginfo_t *__info, + const struct __timespec64 *__timeout); +libc_hidden_proto (__sigtimedwait64) +#endif extern int __sigtimedwait (const sigset_t *__set, siginfo_t *__info, const struct timespec *__timeout); libc_hidden_proto (__sigtimedwait) diff --git a/sysdeps/unix/sysv/linux/sigtimedwait.c b/sysdeps/unix/sysv/linux/sigtimedwait.c index f2ef3aad45..acbc75da16 100644 --- a/sysdeps/unix/sysv/linux/sigtimedwait.c +++ b/sysdeps/unix/sysv/linux/sigtimedwait.c @@ -15,20 +15,12 @@ License along with the GNU C Library; if not, see . */ -#include #include -#include -#include +#include -int -__sigtimedwait (const sigset_t *set, siginfo_t *info, - const struct timespec *timeout) +static int +adjust_si_code (int result, siginfo_t *info) { - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ - int result = SYSCALL_CANCEL (rt_sigtimedwait, set, info, timeout, - __NSIG_BYTES); - /* The kernel generates a SI_TKILL code in si_code in case tkill is used. tkill is transparently used in raise(). Since having SI_TKILL as a code is useful in general we fold the results @@ -38,5 +30,50 @@ __sigtimedwait (const sigset_t *set, siginfo_t *info, return result; } + +int +__sigtimedwait64 (const sigset_t *set, siginfo_t *info, + const struct __timespec64 *timeout) +{ +#ifndef __NR_rt_sigtimedwait_time64 +# define __NR_rt_sigtimedwait_time64 __NR_rt_sigtimedwait +#endif + int r = SYSCALL_CANCEL (rt_sigtimedwait_time64, set, info, timeout, + __NSIG_BYTES); +#ifndef __ASSUME_TIME64_SYSCALLS + if (r >= 0 || errno != ENOSYS) + return adjust_si_code (r, info); + + struct timespec ts32, *pts32 = NULL; + if (timeout != NULL) + { + if (! in_time_t_range (timeout->tv_sec)) + { + __set_errno (EINVAL); + return -1; + } + ts32 = valid_timespec64_to_timespec (*timeout); + pts32 = &ts32; + } + r = SYSCALL_CANCEL (rt_sigtimedwait, set, info, pts32, __NSIG_BYTES); +#endif + return adjust_si_code (r, info); +} +#if __TIMESIZE != 64 +libc_hidden_def (__sigtimedwait64) + +int +__sigtimedwait (const sigset_t *set, siginfo_t *info, + const struct timespec *timeout) +{ + struct __timespec64 ts64, *pts64 = NULL; + if (timeout != NULL) + { + ts64 = valid_timespec_to_timespec64 (*timeout); + pts64 = &ts64; + } + return __sigtimedwait64 (set, info, pts64); +} +#endif libc_hidden_def (__sigtimedwait) weak_alias (__sigtimedwait, sigtimedwait) From patchwork Mon Jul 13 17:10:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40085 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A3ABD3939C06; Mon, 13 Jul 2020 17:11:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3ABD3939C06 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660262; bh=HDlQC6HfvgJumjh4j1VN8jlvnx2Ggdr1wyNWQusd37Q=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ORN/hdHrXafLEhj/tPJqz6KOlOVlnFQO7RU5qLYcfBVy6EypbkBc2AOry/ZZO/f0m fU7A03uKUXgs5OEcqt6LKVwHq6BpzrCtlqThrJM3F92pFs3bRF+jJ8zINd1M9utfYJ ++D+6OjPhQFweRgEfMGiHAqx4y59FjZJXpMD0GbQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by sourceware.org (Postfix) with ESMTPS id 48FCA388C031 for ; Mon, 13 Jul 2020 17:11:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 48FCA388C031 Received: by mail-qv1-xf41.google.com with SMTP id di5so6091760qvb.11 for ; Mon, 13 Jul 2020 10:11:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HDlQC6HfvgJumjh4j1VN8jlvnx2Ggdr1wyNWQusd37Q=; b=aio+WKXUSWblqIaK3IOjCouh0boElaZPNew1W1INQJA9tCWMhnc2buWQB2UmSWexy3 b/hGmN6nlaD991Q0gZcNI2ZxMU/a0sGtIZo9U8YaQIM68Nkvw7uL4WtrpY7HDO4x2/FE 0ab+UwweHBPwh3OGim7IuIDznjZ1WfBTiZ1usEYYT7hQOdEgW6w+bp1dB/rAoaOLQrvk ghBHm4Llk1uoyerQtWDmbvxM5QeTUKQ9rpwZ4mJUaQi2dJ1rKOgyRmoO5NmSoJp/S0ik PAERhL8m1agkHgi0Z6Sa1WiBhZMp+Azp4d7FVB9arqA2KWSCm7P8CYO2eXQpfc/V9+OR wpjw== X-Gm-Message-State: AOAM532JZRGkzbtNTfFV1XAs+l14mbgFWTbZ6+8Sc4fxEEXp5qsKevY5 eQIpeyByc5cLS82a6Yi75Q+aGcvSJuI= X-Google-Smtp-Source: ABdhPJyYVZjtYBN3W1RegOFJnRqSgsWBt0dziRxqaUVwR7t5vM5TFcep99FnnJ+M+z6i2j/vy44KtQ== X-Received: by 2002:a0c:e80c:: with SMTP id y12mr463697qvn.146.1594660259596; Mon, 13 Jul 2020 10:10:59 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:59 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 20/23] linux: Use 64-bit time_t syscall on clock_getcputclockid Date: Mon, 13 Jul 2020 14:10:22 -0300 Message-Id: <20200713171025.3661832-20-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The syscall __NR_clock_getres_time64 (for 32-bit) or __NR_clock_getres (for 64-bit) is used as default. The 32-bit fallback is used iff __ASSUME_TIME64_SYSCALLS is not defined, which assumes the kernel ABI provides either __NR_rt_sigtimedwait (32-bit time_t). Since the symbol does not use any type which might be affected by the time_t, there is no need to add a 64-bit variant. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). --- sysdeps/unix/sysv/linux/clock_getcpuclockid.c | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/sysdeps/unix/sysv/linux/clock_getcpuclockid.c b/sysdeps/unix/sysv/linux/clock_getcpuclockid.c index be1f477187..3c3bdd42ed 100644 --- a/sysdeps/unix/sysv/linux/clock_getcpuclockid.c +++ b/sysdeps/unix/sysv/linux/clock_getcpuclockid.c @@ -22,6 +22,20 @@ #include "kernel-posix-cpu-timers.h" #include +static int +clock_getcpuclockid_return (int r, clockid_t pidclock, clockid_t *clock_id) +{ + if (r == 0) + { + *clock_id = pidclock; + return 0; + } + if (r == -EINVAL) + /* The clock_getres system call checked the PID for us. */ + return ESRCH; + return -r; +} + int __clock_getcpuclockid (pid_t pid, clockid_t *clock_id) { @@ -30,20 +44,17 @@ __clock_getcpuclockid (pid_t pid, clockid_t *clock_id) const clockid_t pidclock = MAKE_PROCESS_CPUCLOCK (pid, CPUCLOCK_SCHED); - int r = INTERNAL_SYSCALL_CALL (clock_getres, pidclock, NULL); - if (!INTERNAL_SYSCALL_ERROR_P (r)) - { - *clock_id = pidclock; - return 0; - } +#ifndef __NR_clock_getres_time64 +# define __NR_clock_getres_time64 __NR_clock_getres +#endif + int r = INTERNAL_SYSCALL_CALL (clock_getres_time64, pidclock, NULL); +#ifndef __ASSUME_TIME64_SYSCALLS + if (r == 0 && r != -ENOSYS) + return clock_getcpuclockid_return (r, pidclock, clock_id); - if (INTERNAL_SYSCALL_ERRNO (r) == EINVAL) - { - /* The clock_getres system call checked the PID for us. */ - return ESRCH; - } - else - return INTERNAL_SYSCALL_ERRNO (r); + r = INTERNAL_SYSCALL_CALL (clock_getres, pidclock, NULL); +#endif + return clock_getcpuclockid_return (r, pidclock, clock_id); } versioned_symbol (libc, __clock_getcpuclockid, clock_getcpuclockid, GLIBC_2_17); From patchwork Mon Jul 13 17:10:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40086 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 360E53938C2E; Mon, 13 Jul 2020 17:11:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 360E53938C2E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660265; bh=yI9Kx99hWXRMFMbwgXj6t6i2itCIBDqgK5icHOs4VZg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Gnv6ZKeFSgnzCWBAx69EDlZl/izrGH8s2tfdZseNnd0uIIIo7ME9PP5yKApaezQfv zNQ/s+Jw57vUbZ9fe7ilXRyWjKtfM8KTnd8tusbnVMiPQd34+I9irxX8didSExhPGo eGTxXpWArtLJMFirTQJjs2m13yhVZYh9E8EMXvE0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by sourceware.org (Postfix) with ESMTPS id 603043938C39 for ; Mon, 13 Jul 2020 17:11:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 603043938C39 Received: by mail-qt1-x843.google.com with SMTP id 6so10532245qtt.0 for ; Mon, 13 Jul 2020 10:11:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yI9Kx99hWXRMFMbwgXj6t6i2itCIBDqgK5icHOs4VZg=; b=YYuArL7E3sGPZPPCrUEPRR7Qu/WnYJU+gAy4wxgOm8BQuJnFIIKdQAjI6hdePJC9Bf rsQYhCzTHUSaZufNHliNj3YAMiQJ3fnOL2tabRMJOPCnyHkoxDDqZpIn5lqMero8k0wK bC7KoPQSMYp+axkBX2+39xtgz3Na42mfXtCq6mpwJh9FluF0xw2Y05JjLXXxDxpJ1cd7 a7YaEEl43j9EqvXkbHtnFpKRLqjeQXkPTl0+FbvigS2UuOlprRPy3IGfsFkvfssnSMP4 8xW/uoS9nCU55nfuC/kzqW/DSZOU1tMcekWQx0k1nbjRli6pMD5GtcTVxFBjQpdg+oLe 4pCQ== X-Gm-Message-State: AOAM5337jECNGcoqSu8qRdsBK8YLJ+nSPos6A6l9DREy+vRqPyrFgvC8 wJkbsyf2TL2uJjeuew7CqEykMvpKcWE= X-Google-Smtp-Source: ABdhPJzM/y74rN4UPFsjkP4opKK5TeklwtoTS5W8pl4gX7tR4orS7t665mzIfZsYsz2p/qjDx1e7Mw== X-Received: by 2002:ac8:4707:: with SMTP id f7mr378989qtp.22.1594660261068; Mon, 13 Jul 2020 10:11:01 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:11:00 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 21/23] linux: Consolidate utimes Date: Mon, 13 Jul 2020 14:10:23 -0300 Message-Id: <20200713171025.3661832-21-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The generic version does not have time64 support and Linux default uses utimensat. With hppa version gone, __ASSUME_UTIMES is not used anymore. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). --- sysdeps/unix/sysv/linux/generic/utimes.c | 46 ------------------- .../unix/sysv/linux/hppa/kernel-features.h | 5 -- sysdeps/unix/sysv/linux/hppa/utimes.c | 30 ------------ 3 files changed, 81 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/generic/utimes.c delete mode 100644 sysdeps/unix/sysv/linux/hppa/utimes.c diff --git a/sysdeps/unix/sysv/linux/generic/utimes.c b/sysdeps/unix/sysv/linux/generic/utimes.c deleted file mode 100644 index 0a8100e1b8..0000000000 --- a/sysdeps/unix/sysv/linux/generic/utimes.c +++ /dev/null @@ -1,46 +0,0 @@ -/* utimes -- Change access and modification times of file. Linux version. - Copyright (C) 2011-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Chris Metcalf , 2011. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include -#include -#include -#include -#include - - -/* Change the access time of FILE to TVP[0] and - the modification time of FILE to TVP[1]. */ -int -__utimes (const char *file, const struct timeval tvp[2]) -{ - struct timespec ts[2]; - struct timespec *tsp = NULL; - - if (tvp) - { - TIMEVAL_TO_TIMESPEC (&tvp[0], &ts[0]); - TIMEVAL_TO_TIMESPEC (&tvp[1], &ts[1]); - tsp = &ts[0]; - } - - return INLINE_SYSCALL (utimensat, 4, AT_FDCWD, file, tsp, 0); -} - -weak_alias (__utimes, utimes) diff --git a/sysdeps/unix/sysv/linux/hppa/kernel-features.h b/sysdeps/unix/sysv/linux/hppa/kernel-features.h index 8548b5c258..80eec02314 100644 --- a/sysdeps/unix/sysv/linux/hppa/kernel-features.h +++ b/sysdeps/unix/sysv/linux/hppa/kernel-features.h @@ -18,11 +18,6 @@ . */ -/* Support for the utimes syscall was added in 3.14. */ -#if __LINUX_KERNEL_VERSION >= 0x030e00 -# define __ASSUME_UTIMES 1 -#endif - #include_next #define __ASSUME_RECV_SYSCALL 1 diff --git a/sysdeps/unix/sysv/linux/hppa/utimes.c b/sysdeps/unix/sysv/linux/hppa/utimes.c deleted file mode 100644 index a9c4a7ff45..0000000000 --- a/sysdeps/unix/sysv/linux/hppa/utimes.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Implement utimes for hppa. - Copyright (C) 2014-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -/* hppa has the utimensat syscall in all supported kernel versions but - gained the utimes syscall later, so use the linux-generic - implementation of utimes in terms of the utimensat syscall unless - the utimes syscall is known to be available. */ - -#include - -#ifdef __ASSUME_UTIMES -# include -#else -# include -#endif From patchwork Mon Jul 13 17:10:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40087 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D01603938C37; Mon, 13 Jul 2020 17:11:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D01603938C37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660266; bh=LjOs+r7ahGq6YbOu7ikQSozkpBxBC7ntObxSYtFQ+EQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=LFSysstVMuw18XsXlpVuSUCy7+2/QYoaII6INP3E3gyB0SDmSDfGyz6RMWDWh+NmW /zRvpnvunKtjKFCLHwSPiEvz7GtIjUPSzekQRtq7NFjb/OibJtaNz6Q18lTHF1j8WR lMKGxq+nBVFdHYWYFlm0tauenDEUibfJafKvw8Kc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by sourceware.org (Postfix) with ESMTPS id 34A083890439 for ; Mon, 13 Jul 2020 17:11:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 34A083890439 Received: by mail-qt1-x841.google.com with SMTP id e12so10497345qtr.9 for ; Mon, 13 Jul 2020 10:11:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LjOs+r7ahGq6YbOu7ikQSozkpBxBC7ntObxSYtFQ+EQ=; b=fcHJO7stzuwiC+F8LpWIrMSQlhcva/YxxksehPD7tZPtCuCnBEKZ/8BHl8Nlf+2+JH 2kqonkHEWoMZRA/Dhy15S+QeMJDOfxB27KL9QXeCKbIW5lPoCLoBoCgw0N9a36kD6Son OOFKQrB61iU1gmbNlu9EaSHAtrmBYiZ+PJOxFLt713RngMZ3138Za4IaLApuOGwtxE2D nACjQNMKYnlISM4lOtRiCEulIXBtzwQ/kEplSdNO5kOE7EkAJBBBP2EDwMAzcC/e11g2 LOVasaj7ihml7v4yFPOyhF6vjSsBhryhafuLUmm9vNQGeLNybCYeiEzVq/iw0cIZowgH Visg== X-Gm-Message-State: AOAM532bpr9ameMekycDn2yfVbfCKrN03sVH9PkmYHpytSanrhgCdq7d 31eSb/au2cOfz+ndhcmQGIyR8tfWtZg= X-Google-Smtp-Source: ABdhPJw+XnDTdqUMDwtZVts0sypVAzjR18y9VMHTGkwPQ7j3cOABpBw7Yqs9dbUopqsE7Q6QKzFxaQ== X-Received: by 2002:ac8:2928:: with SMTP id y37mr299610qty.245.1594660263095; Mon, 13 Jul 2020 10:11:03 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.11.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:11:02 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 22/23] linux: Fix time64 support for futimesat Date: Mon, 13 Jul 2020 14:10:24 -0300 Message-Id: <20200713171025.3661832-22-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The generic implementation does not support time64 and the default one return overflow for invalid tv_sec with UTIME_NOW / UTIME_OMIT (which is valid since tv_sec in such cases is ignored by the kernel). Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). --- sysdeps/unix/sysv/linux/generic/futimesat.c | 52 --------------------- sysdeps/unix/sysv/linux/utimensat.c | 8 +++- 2 files changed, 6 insertions(+), 54 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/generic/futimesat.c diff --git a/sysdeps/unix/sysv/linux/generic/futimesat.c b/sysdeps/unix/sysv/linux/generic/futimesat.c deleted file mode 100644 index 7be1fbc252..0000000000 --- a/sysdeps/unix/sysv/linux/generic/futimesat.c +++ /dev/null @@ -1,52 +0,0 @@ -/* futimesat -- Change access and modification times of file. Linux version. - Copyright (C) 2005-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Chris Metcalf , 2011. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include -#include -#include -#include -#include -#include -#include - - -/* Change the access time of FILE relative to FD to TVP[0] and - the modification time of FILE to TVP[1]. */ -int -futimesat (int fd, const char *file, const struct timeval tvp[2]) -{ - struct timespec tsp[2]; - int result; - - if (tvp) - { - if (tvp[0].tv_usec >= 1000000 || tvp[0].tv_usec < 0 - || tvp[1].tv_usec >= 1000000 || tvp[1].tv_usec < 0) - { - __set_errno (EINVAL); - return -1; - } - TIMEVAL_TO_TIMESPEC (&tvp[0], &tsp[0]); - TIMEVAL_TO_TIMESPEC (&tvp[1], &tsp[1]); - } - - result = INLINE_SYSCALL (utimensat, 4, fd, file, tvp ? tsp : NULL, 0); - return result; -} diff --git a/sysdeps/unix/sysv/linux/utimensat.c b/sysdeps/unix/sysv/linux/utimensat.c index ea23c2f051..72784d824a 100644 --- a/sysdeps/unix/sysv/linux/utimensat.c +++ b/sysdeps/unix/sysv/linux/utimensat.c @@ -36,9 +36,13 @@ __utimensat64_helper (int fd, const char *file, if (ret == 0 || errno != ENOSYS) return ret; + /* For UTIME_NOW and UTIME_OMIT the value of tv_sec field is ignored. */ +# define NS_VALID(ns) \ + ((((ns).tv_nsec == UTIME_NOW || (ns).tv_nsec == UTIME_OMIT) \ + || in_time_t_range ((ns).tv_sec))) + if (tsp64 != NULL - && (! in_time_t_range (tsp64[0].tv_sec) - || ! in_time_t_range (tsp64[1].tv_sec))) + && (!NS_VALID (tsp64[0]) || !NS_VALID (tsp64[1]))) { __set_errno (EOVERFLOW); return -1; From patchwork Mon Jul 13 17:10:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40088 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D42CA3939C30; Mon, 13 Jul 2020 17:11:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D42CA3939C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660268; bh=yASqJl1zhcKTqaNEWFsl+eK/ZPat8vYFpGCPwl3FWv8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=NbtLaQhkyw/CCFU2LZIjZiGV1gFOG3RcL9OSrQS9frB+5E0WsEjda6OHJzgqSJeiy 8h66y2cVs9+yeWf1J6JUxqey8ibTFoa5qzUDO1r18tC3ErH9QttkmRBtmvEADcu4v2 5gK5cOvS1/mt0bcElQyp/Gmd8l9ZzfbMb6DqvW7Q= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by sourceware.org (Postfix) with ESMTPS id 9BB403939C01 for ; Mon, 13 Jul 2020 17:11:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9BB403939C01 Received: by mail-qk1-x743.google.com with SMTP id l6so12922124qkc.6 for ; Mon, 13 Jul 2020 10:11:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yASqJl1zhcKTqaNEWFsl+eK/ZPat8vYFpGCPwl3FWv8=; b=gcxLKBwRH5LDxV3y1N8mzAK+jWMtXG3V7/Iyycpz1fs7V4tqFS7rhHAKOA74ejftv0 C365Z2wiFPk0h32Kr+w45EQy9QYeRPqWH7DgkTi70R3sXZZvWrZ0RvJpMHtcGzxCJtwB 7bnuVSVeF1I+tDigUlLb4sNkEI3Xo8zowseZ3OblGi+7p0cw6g7m6jDqvGTUx0h/DdcS FH8LzTeQVOysY06xE2aTKSNqBCVqPGp7vgMNfyGo3eFv45NpNV/1FjSmyhSiXYs7PqvQ EwcresXzq72FEZhgU2lkX9StlKXiIz/JnxwpRc/V2tIgsZrmGAROSTQomE3Gx36VgjUz pHeQ== X-Gm-Message-State: AOAM532Gs1kzsrh5xVzboZPSy+Vo9gpiePExzQTaqZhxqA0b/Wf+ygbF a45nht75d0vq84z7ZPONJ+w1mol3Pek= X-Google-Smtp-Source: ABdhPJyHJ6abKYNufkHnN1HAHm5TChBryv4Itca8LE4zr//FP4yp84WLQveiJl8ntnCCt6RqfeYwmQ== X-Received: by 2002:a37:b847:: with SMTP id i68mr644865qkf.126.1594660264869; Mon, 13 Jul 2020 10:11:04 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:11:04 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 23/23] linux: Add time64 support for nanosleep Date: Mon, 13 Jul 2020 14:10:25 -0300 Message-Id: <20200713171025.3661832-23-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" It uses __clock_nanosleep64 and adds the __nanosleep64 symbol. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). --- include/time.h | 19 ++++++--- sysdeps/unix/sysv/linux/clock_nanosleep.c | 8 ++-- sysdeps/unix/sysv/linux/nanosleep.c | 50 +++++++++++++++++++++++ 3 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/nanosleep.c diff --git a/include/time.h b/include/time.h index 936486e206..ad0476be05 100644 --- a/include/time.h +++ b/include/time.h @@ -271,6 +271,15 @@ extern struct tm *__tz_convert (__time64_t timer, int use_localtime, extern int __nanosleep (const struct timespec *__requested_time, struct timespec *__remaining); hidden_proto (__nanosleep) +#if __TIMESIZE == 64 +# define __nanosleep64 __nanosleep +#else +extern int __nanosleep64 (const struct __timespec64 *__requested_time, + struct __timespec64 *__remaining); +hidden_proto (__nanosleep64) +#endif + + extern int __getdate_r (const char *__string, struct tm *__resbufp) attribute_hidden; @@ -294,14 +303,14 @@ libc_hidden_proto (__difftime64) extern double __difftime (time_t time1, time_t time0); #if __TIMESIZE == 64 -# define __clock_nanosleep_time64 __clock_nanosleep +# define __clock_nanosleep64 __clock_nanosleep # define __clock_gettime64 __clock_gettime # define __timespec_get64 __timespec_get #else -extern int __clock_nanosleep_time64 (clockid_t clock_id, - int flags, const struct __timespec64 *req, - struct __timespec64 *rem); -libc_hidden_proto (__clock_nanosleep_time64) +extern int __clock_nanosleep64 (clockid_t clock_id, + int flags, const struct __timespec64 *req, + struct __timespec64 *rem); +libc_hidden_proto (__clock_nanosleep64) extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp); libc_hidden_proto (__clock_gettime64) extern int __timespec_get64 (struct __timespec64 *ts, int base); diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c index 6ad3321435..697e403ac8 100644 --- a/sysdeps/unix/sysv/linux/clock_nanosleep.c +++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c @@ -27,8 +27,8 @@ /* We can simply use the syscall. The CPU clocks are not supported with this function. */ int -__clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec64 *req, - struct __timespec64 *rem) +__clock_nanosleep64 (clockid_t clock_id, int flags, + const struct __timespec64 *req, struct __timespec64 *rem) { if (clock_id == CLOCK_THREAD_CPUTIME_ID) return EINVAL; @@ -68,7 +68,7 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec } #if __TIMESIZE != 64 -libc_hidden_def (__clock_nanosleep_time64) +libc_hidden_def (__clock_nanosleep64) int __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req, @@ -78,7 +78,7 @@ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req, struct __timespec64 treq64, trem64; treq64 = valid_timespec_to_timespec64 (*req); - r = __clock_nanosleep_time64 (clock_id, flags, &treq64, &trem64); + r = __clock_nanosleep64 (clock_id, flags, &treq64, &trem64); if (r == EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0) *rem = valid_timespec64_to_timespec (trem64); diff --git a/sysdeps/unix/sysv/linux/nanosleep.c b/sysdeps/unix/sysv/linux/nanosleep.c new file mode 100644 index 0000000000..7e13a98b4c --- /dev/null +++ b/sysdeps/unix/sysv/linux/nanosleep.c @@ -0,0 +1,50 @@ +/* High-resolution sleep. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +int +__nanosleep64 (const struct __timespec64 *req, struct __timespec64 *rem) +{ + int ret = __clock_nanosleep64 (CLOCK_REALTIME, 0, req, rem); + if (ret != 0) + { + __set_errno (ret); + return -1; + } + return 0; +} +#if __TIMESIZE != 64 +libc_hidden_def (__nanosleep64) + +int +__nanosleep (const struct timespec *req, struct timespec *rem) +{ + struct __timespec64 treq64, trem64; + + treq64 = valid_timespec_to_timespec64 (*req); + int ret = __nanosleep64 (&treq64, &trem64); + + if (ret != 0 && errno == EINTR && rem != NULL) + *rem = valid_timespec64_to_timespec (trem64); + return ret; +} +#endif +libc_hidden_def (__nanosleep) +weak_alias (__nanosleep, nanosleep)