From patchwork Tue Jun 20 17:17:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 71427 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 43F40385734F for ; Tue, 20 Jun 2023 17:18:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43F40385734F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687281498; bh=oHxGd+i4XNCRpDC+8cWdK9I94diANM8pSQVyCrg/gwg=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=DFEJj1T/dwGJAU4Q+KzbSpbrj62f0rNYUYOtI2XEH+2U3flLBFLG9xajr5tzvmnjT AeBdA4K7dmvqlF/5A3FR3VC+QKrwch4zCMCnOgaEBvmL1a5ELS0bEjqeZKWnmJh801 TcJHVZRoydWuZKPv0hF3Nmmxu7vMriVIHhcteHtI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id EB596385828D for ; Tue, 20 Jun 2023 17:17:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EB596385828D Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-6b46e61638eso2509850a34.0 for ; Tue, 20 Jun 2023 10:17:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687281473; x=1689873473; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oHxGd+i4XNCRpDC+8cWdK9I94diANM8pSQVyCrg/gwg=; b=Ozo674eIMLyih4jJtxbikdkaShLhowYvBcpgD/BG8YvOWy4tFwPKqPWEhhFSM8HbiC nmswC6xxCJnHx1Ef+85jx2ot3mlirHqu0iNRMwnjqGqvvu6aEZ2QsVg+YZj2R7bMF/Li 8hrO+T0lsS9wFRpKEDbk6d8AIr0aX+AYKYdjruNjHNTdhAJtDPhk6g0yPh7DfjJHdZYU mclcjcDl7Ru2u8wvKQ5YF0GqsPDBr9r2tNG6lyZs8MSL1/ybGXqlF3kD2PB4m7uXjvMl 71PJn817L3Ol4dz3FWLUmir+dTtnmQ+bLyNApZOSJaMZ0rx9U7OKLFSYfQ6Bpm54plWl bZbw== X-Gm-Message-State: AC+VfDzXHCjlEv9iXrHmfEugrQAHMi8tyNPB49SLtjNY18qriX7AOd3c p70KzE6htYmj6lZSP3x2eIM= X-Google-Smtp-Source: ACHHUZ6cVJZKDm5feZaBPN9TUH7H8W3GyATzWDE2drKOnPZ9oQk5M51wqJD1xZNP8H53wS3KYb1RlQ== X-Received: by 2002:a05:6358:7018:b0:12b:cdd2:8b33 with SMTP id 24-20020a056358701800b0012bcdd28b33mr3591485rwo.7.1687281473191; Tue, 20 Jun 2023 10:17:53 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id r23-20020a634417000000b005143448896csm1652930pga.58.2023.06.20.10.17.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 10:17:52 -0700 (PDT) To: Jens Gustedt , libc-alpha@sourceware.org Cc: Florian Weimer , Yonggang Luo Subject: [PATCH v2 3/4] c11: Switch to use pthread_mutex_clocklock and pthread_cond_clockwait to implement cnd and mtx lock and wait Date: Wed, 21 Jun 2023 01:17:30 +0800 Message-Id: <20230620171731.230-4-luoyonggang@gmail.com> X-Mailer: git-send-email 2.39.0.windows.1 In-Reply-To: <20230620171731.230-1-luoyonggang@gmail.com> References: <20230620171731.230-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Yonggang Luo via Libc-alpha From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Signed-off-by: Yonggang Luo --- sysdeps/pthread/cnd_timedwait.c | 8 ++++---- sysdeps/pthread/mtx_timedlock.c | 6 +++--- sysdeps/unix/sysv/linux/cnd_timedwait.c | 4 ++-- sysdeps/unix/sysv/linux/mtx_timedlock.c | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sysdeps/pthread/cnd_timedwait.c b/sysdeps/pthread/cnd_timedwait.c index 25df50cb3a..ea2921a35c 100644 --- a/sysdeps/pthread/cnd_timedwait.c +++ b/sysdeps/pthread/cnd_timedwait.c @@ -20,10 +20,10 @@ int cnd_timedwait (cnd_t *restrict cond, mtx_t *restrict mutex, - const struct timespec* restrict time_point) + const struct timespec *restrict time_point) { - int err_code = __pthread_cond_timedwait ((pthread_cond_t *) cond, - (pthread_mutex_t *) mutex, - time_point); + int err_code = __pthread_cond_clockwait ((pthread_cond_t *) cond, + (pthread_mutex_t *) mutex, + CLOCK_REALTIME, time_point); return thrd_err_map (err_code); } diff --git a/sysdeps/pthread/mtx_timedlock.c b/sysdeps/pthread/mtx_timedlock.c index a3d236f3e1..77ab39a72c 100644 --- a/sysdeps/pthread/mtx_timedlock.c +++ b/sysdeps/pthread/mtx_timedlock.c @@ -20,9 +20,9 @@ int mtx_timedlock (mtx_t *restrict mutex, - const struct timespec *restrict time_point) + const struct timespec *restrict time_point) { - int err_code = __pthread_mutex_timedlock ((pthread_mutex_t *)mutex, - time_point); + int err_code = __pthread_mutex_clocklock ((pthread_mutex_t *) mutex, + CLOCK_REALTIME, time_point); return thrd_err_map (err_code); } diff --git a/sysdeps/unix/sysv/linux/cnd_timedwait.c b/sysdeps/unix/sysv/linux/cnd_timedwait.c index 9fa6d71d1a..c612d4f94d 100644 --- a/sysdeps/unix/sysv/linux/cnd_timedwait.c +++ b/sysdeps/unix/sysv/linux/cnd_timedwait.c @@ -24,9 +24,9 @@ int __cnd_timedwait64 (cnd_t *restrict cond, mtx_t *restrict mutex, const struct __timespec64 *restrict time_point) { - int err_code = __pthread_cond_timedwait64 ((pthread_cond_t *) cond, + int err_code = __pthread_cond_clockwait64 ((pthread_cond_t *) cond, (pthread_mutex_t *) mutex, - time_point); + CLOCK_REALTIME, time_point); return thrd_err_map (err_code); } diff --git a/sysdeps/unix/sysv/linux/mtx_timedlock.c b/sysdeps/unix/sysv/linux/mtx_timedlock.c index 8019792868..b8f6d51940 100644 --- a/sysdeps/unix/sysv/linux/mtx_timedlock.c +++ b/sysdeps/unix/sysv/linux/mtx_timedlock.c @@ -24,8 +24,8 @@ int __mtx_timedlock64 (mtx_t *restrict mutex, const struct __timespec64 *restrict time_point) { - int err_code = __pthread_mutex_timedlock64 ((pthread_mutex_t *)mutex, - time_point); + int err_code = __pthread_mutex_clocklock64 ((pthread_mutex_t *) mutex, + CLOCK_REALTIME, time_point); return thrd_err_map (err_code); }