From patchwork Mon Jun 19 22:20:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 1796830 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.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=rJDMO0G/; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QlPPW17l1z20XS for ; Tue, 20 Jun 2023 08:21:35 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3253F3856628 for ; Mon, 19 Jun 2023 22:21:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3253F3856628 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687213293; bh=k4CNE9CQAgfdi+A861ITuclRRx2ttUem3Jo7X0UIuwU=; 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=rJDMO0G/jCbYt7YnP6emY45EOU7HXq4l6ADIbMDLEEQ5/71GmPuLe6/1tC2AWbLP4 5TZ0HsKJA8EOv7Guu2Y3i5tpZl4soY6FYUm1LW5rG7X9+ryHahzSlDmxpT6K1urNzx gCyQ9f1iYF9eit/0KACUAqlRgOFp9qnEAFbk6Nns= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by sourceware.org (Postfix) with ESMTPS id F35763857C4F for ; Mon, 19 Jun 2023 22:21:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F35763857C4F Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-1aa291b3fc9so1390321fac.0 for ; Mon, 19 Jun 2023 15:21:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687213275; x=1689805275; 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=k4CNE9CQAgfdi+A861ITuclRRx2ttUem3Jo7X0UIuwU=; b=E7X/OtBjGDZQSlAS1tmZlXfTZ56dQyYSSXjfmFioeYgldvnssU9r6BcCUehjHsIeAk nQOydZpow8029DS0bh3yPLTfAuFM0WCOP9wX5fTKFWtx9Ly1bit1y3ftaGkORxZQ6sho sY0KQe/b1X03rT80Kgi4NBxPy4oxdj0VPAk8h8DsWUjPPYvAQFxHyCc+p2VKPwuc/V/O Ga1Gxm4TkQdL+72jtW2RvmIWuHpEnm096BLIkTeTEXYUma+t1peylipF9bcbDqISuVew p/+OiC41Dm6L19thu4ovyV2up8XJmF8QsbtvYhVCqIWscAP+lW4zqOtU3saehjN8tVu+ E8bA== X-Gm-Message-State: AC+VfDyA53i33lg5cgZEQFoj+zjybjRQKpkjlAiStqXWNtccm5whRIqC UuqvvTcotnnSkAv/XcL6tLFdZUSq3aGoJA== X-Google-Smtp-Source: ACHHUZ6qTHs/LzodQC0MAmuYkOOBFU1sWm2Yq8OTNIZ8NpK+l6voi4w3nh7icXf9hqDJl3QjTWfh7w== X-Received: by 2002:a05:6870:3a26:b0:1a6:d961:fe53 with SMTP id du38-20020a0568703a2600b001a6d961fe53mr7318451oab.0.1687213275377; Mon, 19 Jun 2023 15:21:15 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id y17-20020a63e251000000b0050a0227a4bcsm161387pgj.57.2023.06.19.15.21.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 15:21:15 -0700 (PDT) To: Jens Gustedt , libc-alpha@sourceware.org Cc: Yonggang Luo Subject: [PATCH 4/5] c11: Switch to use pthread_mutex_clocklock and pthread_cond_clockwait to implement cnd and mtx lock and wait Date: Tue, 20 Jun 2023 06:20:51 +0800 Message-Id: <20230619222052.682-5-luoyonggang@gmail.com> X-Mailer: git-send-email 2.39.0.windows.1 In-Reply-To: <20230619222052.682-1-luoyonggang@gmail.com> References: <20230619222052.682-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 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+incoming=patchwork.ozlabs.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..3785fd21ba 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..763f07d2f8 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); }