From patchwork Tue Sep 8 14:57:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 1359774 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=wAi2dRBZ; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bm7ZH1cqJz9sRK for ; Wed, 9 Sep 2020 00:58:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3AC4A3951C5D; Tue, 8 Sep 2020 14:58:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3AC4A3951C5D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1599577081; bh=lSaU4YbJLO/gsn7a8RhXZG2Iek3ApGUkderdDW7XZ3Q=; 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=wAi2dRBZcVUcNXXb9YG2GwY2sBqCz2iOyCpe5p3IJO6ACvHaSnP90xrwXCa8f1TrP JvaCMKQy/KbFIgTkFELeEYbMR8VVWJ1ec3TDYZsiKvSx86SMgwhSRQE/Fnl6OzOLtP /s2lmksc4oxOOOYX1RzzWyFyT3QVXFBCJt4HLDs0= 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 A51763951C67 for ; Tue, 8 Sep 2020 14:57:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A51763951C67 Received: by mail-qv1-xf41.google.com with SMTP id j10so7920440qvk.11 for ; Tue, 08 Sep 2020 07:57: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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lSaU4YbJLO/gsn7a8RhXZG2Iek3ApGUkderdDW7XZ3Q=; b=GUziPfkJxlcoYxUggBZPOkwEryoDjQP09Dw5BKyexK/zig2g8SgycbT/iVcx7oEbPZ 6XWw1RD8kHcty/73ZHn2xbJYfNMKk0Os7YZUCuasCikLVnBqa4epxlZZYPOg0fjI1rcj g9Piqs5k6wQtgnEA7vJThxPO45zrJ0g83zpJ0s2kNy02M/s8OcbUuFCBkFrr13a3tjUV o+A0oJg/bF+OvpGawkFszZUAbCCGzqmeJHCBRkpMgvKvg3/fFNzXCzMFEHiln2ESuvsK MBfFD0lBJsYzfkQIfK8FyDPY9vjqotlLJEryFhqqiVcBmbEFjHq5jQp0RswzVP5H1Ouj J/WA== X-Gm-Message-State: AOAM533W97r8G31HQIQBzLcpNshHxHoSixIvVYh27suXLTAfCETUzo+e GOXZBr+SypuJ+p7G2WihAhBlsZ1jaO2siA== X-Google-Smtp-Source: ABdhPJxDacQ9dDC9y4zIK3gj3ulk//BmYTlmaMgomvt1GH0PE2DfYd9LGKzELW8aNDoqntS61fyhQA== X-Received: by 2002:a0c:bf0a:: with SMTP id m10mr480412qvi.30.1599577077569; Tue, 08 Sep 2020 07:57:57 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id e188sm10800748qkd.55.2020.09.08.07.57.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 07:57:56 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v2 10/14] linux: Add time64 support for nanosleep Date: Tue, 8 Sep 2020 11:57:34 -0300 Message-Id: <20200908145738.640039-10-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200908145738.640039-1-adhemerval.zanella@linaro.org> References: <20200908145738.640039-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 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 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). Reviewed-by: Alistair Francis --- include/time.h | 9 ++++++ sysdeps/unix/sysv/linux/nanosleep.c | 50 +++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/nanosleep.c diff --git a/include/time.h b/include/time.h index 936486e206..edf6cdf829 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; diff --git a/sysdeps/unix/sysv/linux/nanosleep.c b/sysdeps/unix/sysv/linux/nanosleep.c new file mode 100644 index 0000000000..8f4ee0f744 --- /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_nanosleep_time64 (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)