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)