From patchwork Mon Jun 19 22:20:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 71348 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 3A346385B515 for ; Mon, 19 Jun 2023 22:21:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A346385B515 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687213293; bh=T8IieLtcTrhda9MIZUHMLs7Sh3/AO66FY58EwFBsl+8=; 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=OdftAK9olf1dmlHpYe2alT1xLhga8MZmlkC4dNwMrLhB9E0KpWdHrRUYXc5SLzdaZ fFZ5VUJ4g0lg4yPXvep1QavdedOGNgEP5ih1k2Z8PuUkn0Azrh6bzSjEmu141zYH0F PjDeoPjBsff7Nx5MyAkHZUy/VeUIErh7wlUjkwDI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by sourceware.org (Postfix) with ESMTPS id CE4013858D39 for ; Mon, 19 Jun 2023 22:21:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE4013858D39 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-1a98cf01151so4043682fac.2 for ; Mon, 19 Jun 2023 15:21:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687213269; x=1689805269; 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=T8IieLtcTrhda9MIZUHMLs7Sh3/AO66FY58EwFBsl+8=; b=jio/i54CQIp4oCoc4rqJoc0bY76qH+fST69MhhLltTyECs7MSxy7CfuEpqGWVIjrXH GF7nJ7vNmb3dUWl4bJdKrsAGVPLPdBBczhu9ssuyj+H+dR2YPcTiDg2dcHDyYqtaOMWp wfRguXieMQEfXjVKZHMTn7ywGSEy0ma1aaXr5sFKWqJV4YNIeHRI7slpdzCwZvz5iUIV KkjSDLWa9ToRuMAbSM6jbs1LpPaiaS960f+u7wZ5OCxq5k5ftA/vItf3xAocmwj9ycT2 GEhSp/nxBqB955QTdkdZ0CCiyoRAFWSKPv/mnyMi2STtk6ovBbZcHJDGVncQhymlfMLm jjSA== X-Gm-Message-State: AC+VfDw3p9irnS8lS6wTTHvr8VRN5Eplp7peiejAUTNDvm0aBdDR+Sgr gpwlFDrBv+9S2nqTnwHeoFUM2HfWwxVS8w== X-Google-Smtp-Source: ACHHUZ5GqM926xxxN5wv/VM8O+504Tc3iMLfeIX1FFmwH8FNUoB2hqc4TI4lSeHcYZh05X4ro2vAWQ== X-Received: by 2002:a05:6870:5b08:b0:1a9:a956:33c4 with SMTP id ds8-20020a0568705b0800b001a9a95633c4mr9745237oab.3.1687213268791; Mon, 19 Jun 2023 15:21:08 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 15:21:08 -0700 (PDT) To: Jens Gustedt , libc-alpha@sourceware.org Cc: Yonggang Luo Subject: [PATCH 1/5] features: Rename __GLIBC_USE_ISOC2X to __GLIBC_USE_ISOC23 Date: Tue, 20 Jun 2023 06:20:48 +0800 Message-Id: <20230619222052.682-2-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.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, 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 --- include/features.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/features.h b/include/features.h index 9eae86a2d8..084cd4830c 100644 --- a/include/features.h +++ b/include/features.h @@ -241,9 +241,9 @@ /* This is to enable the ISO C2X extension. */ #if (defined _ISOC2X_SOURCE \ || (defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L)) -# define __GLIBC_USE_ISOC2X 1 +# define __GLIBC_USE_ISOC23 1 #else -# define __GLIBC_USE_ISOC2X 0 +# define __GLIBC_USE_ISOC23 0 #endif /* This is to enable the ISO C11 extension. */ From patchwork Mon Jun 19 22:20:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 71351 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 8E3C83854E4C for ; Mon, 19 Jun 2023 22:22:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E3C83854E4C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687213335; bh=k3BixMHLo7LzJwvT1q8leN3fcc67w4TzeV3EBk9N9Bk=; 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=Z0pqeZhwbxRmYeYWNkpBmfZckRqFFtn/+a5e/KH8Np2Arl5Dfe1uDRl5sBjxIU9Ue uwK597eZYMEfBKhSWkoYgHUcB/RxaHaMy/7sN201uLuSOG55J2MJJewPa5PniDiVwQ h/LWiOb3lA+1TDBZP8tciD6CWXSW8NPWs+DJ65T4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id B77793858C27 for ; Mon, 19 Jun 2023 22:21:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B77793858C27 Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6b5915d0816so215375a34.1 for ; Mon, 19 Jun 2023 15:21:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687213271; x=1689805271; 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=k3BixMHLo7LzJwvT1q8leN3fcc67w4TzeV3EBk9N9Bk=; b=Tk5J9gNotcIJGD7o3XF0pVXD6jop0vEI+rzOu2ofOtZjvyx4d0f2FQgxaNKJzaDSsH pOcdLFY4uEsfcOQszSQqbSb1KpDU/MaZV4cEywM1ofPfIiADYm1zY0utrCUZmpX/TC/E x3QWo71Gc1eNMvhNAx5ueCYHtQfn/5FFBvwVuIo4zSTH5Ase056Iif4lIkJVLuwZ2CcI 6dlWMzjEhZIOgzuu5q9hkFgY8pOvcaQJhcU/ACZuqLUw6WOdi1r/zxPEZ39sLkKnHI+p SRbi6LVkQfaLefMLX62OwMRuwiMZ7Gejo8tcLBf5EgSRI/XcEyEwcRTX9moTe0pVsKeR jXvg== X-Gm-Message-State: AC+VfDwEVLNQ3X+r+0IJ1ttKX9dmFIcj1wPFTZ2vyBMC9D2rrXs0Wvpu YB05E5YNWFh7BzJuqn77LRw= X-Google-Smtp-Source: ACHHUZ5lC++h4K992VtiYVVvceRh9SkXKmZ48tqWuWOGGqIrjN5wqkZEybGaGc9QMAK5+Gauzd1I8g== X-Received: by 2002:a05:6830:200f:b0:6b4:5721:18e2 with SMTP id e15-20020a056830200f00b006b4572118e2mr8599908otp.23.1687213271000; Mon, 19 Jun 2023 15:21:11 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 15:21:10 -0700 (PDT) To: Jens Gustedt , libc-alpha@sourceware.org Cc: Yonggang Luo Subject: [PATCH 2/5] time: Implement c23 timespec_get base Date: Tue, 20 Jun 2023 06:20:49 +0800 Message-Id: <20230619222052.682-3-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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" These newly implement base are: #define TIME_MONOTONIC 2 #define TIME_PROCESS_CPUTIME_ID 3 #define TIME_THREAD_CPUTIME_ID 4 #define TIME_MONOTONIC_RAW 5 #define TIME_REALTIME_COARSE 6 #define TIME_MONOTONIC_COARSE 7 #define TIME_BOOTTIME 8 #define TIME_REALTIME_ALARM 9 #define TIME_BOOTTIME_ALARM 10 #define TIME_SGI_CYCLE 11 #define TIME_TAI 12 Signed-off-by: Yonggang Luo --- time/time.h | 13 ++++++++++++ time/timespec_get.c | 48 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/time/time.h b/time/time.h index 368f4dc588..189a560199 100644 --- a/time/time.h +++ b/time/time.h @@ -64,6 +64,19 @@ typedef __pid_t pid_t; /* Time base values for timespec_get. */ # define TIME_UTC 1 #endif +#ifdef __GLIBC_USE_ISOC23 +#define TIME_MONOTONIC 2 +#define TIME_PROCESS_CPUTIME_ID 3 +#define TIME_THREAD_CPUTIME_ID 4 +#define TIME_MONOTONIC_RAW 5 +#define TIME_REALTIME_COARSE 6 +#define TIME_MONOTONIC_COARSE 7 +#define TIME_BOOTTIME 8 +#define TIME_REALTIME_ALARM 9 +#define TIME_BOOTTIME_ALARM 10 +#define TIME_SGI_CYCLE 11 +#define TIME_TAI 12 +#endif __BEGIN_DECLS diff --git a/time/timespec_get.c b/time/timespec_get.c index 9b1d4f22ed..a57b1ee0b8 100644 --- a/time/timespec_get.c +++ b/time/timespec_get.c @@ -22,10 +22,52 @@ int timespec_get (struct timespec *ts, int base) { - if (base == TIME_UTC) + clockid_t clockid = -1; + switch (base) { + default: + break; + case TIME_UTC: + clockid = CLOCK_REALTIME; + break; + case TIME_MONOTONIC: + clockid = CLOCK_MONOTONIC; + break; + case TIME_PROCESS_CPUTIME_ID: + clockid = CLOCK_PROCESS_CPUTIME_ID; + break; + case TIME_THREAD_CPUTIME_ID: + clockid = CLOCK_THREAD_CPUTIME_ID; + break; + case TIME_MONOTONIC_RAW: + clockid = CLOCK_MONOTONIC_RAW; + break; + case TIME_REALTIME_COARSE: + clockid = CLOCK_REALTIME_COARSE; + break; + case TIME_MONOTONIC_COARSE: + clockid = CLOCK_MONOTONIC_COARSE; + break; + case TIME_BOOTTIME: + clockid = CLOCK_BOOTTIME; + break; + case TIME_REALTIME_ALARM: + clockid = CLOCK_REALTIME_ALARM; + break; + case TIME_BOOTTIME_ALARM: + clockid = CLOCK_BOOTTIME_ALARM; + break; + case TIME_SGI_CYCLE: + clockid = CLOCK_SGI_CYCLE; + break; + case TIME_TAI: + clockid = CLOCK_TAI; + break; + } + if (clockid >= 0) { - __clock_gettime (CLOCK_REALTIME, ts); - return base; + if (__clock_gettime (clockid, ts) >= 0) { + return base; + } } return 0; } From patchwork Mon Jun 19 22:20:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 71349 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 524043856DDC for ; Mon, 19 Jun 2023 22:21:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 524043856DDC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687213297; bh=K1yWvNkM5LWUp8SLPHRrbz8JMz3LgffCK1UKBjTQpQ4=; 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=YhlwB1j0PN3Env2adk/7vhLgAyn8BEzPtoZTrU+HNaZvtlt+yllG0D6Tmn0VJ5fey eEBKaZHPeSTJaiVlRGYOtcYMYaw0TmWANouyqSRjOWi0RzfDB+tJl1RzFobNEclFLo /0WHQVd6ZXJYlVt43jyj4yELLWarnkAS8RGTiqm4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com [IPv6:2001:4860:4864:20::2e]) by sourceware.org (Postfix) with ESMTPS id CBABA3858035 for ; Mon, 19 Jun 2023 22:21:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CBABA3858035 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-1a9a2724a62so3657287fac.2 for ; Mon, 19 Jun 2023 15:21:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687213273; x=1689805273; 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=K1yWvNkM5LWUp8SLPHRrbz8JMz3LgffCK1UKBjTQpQ4=; b=JYB6/Zf8RSk4twbCVmiq6NWj9chXgtkvVPGYYSu+DFjYhIF24/4gmHPuNUeR1G3oG0 IFPfm/H1WXeswIupgF35GxtHkMHENQRi19Kva5usg6IDiQPyOfm5xPdi04bcCrTsQSre zBEFAmZcXC65CT5NQtNsVIwTFuX3RuEwVPX3BJyvvWwwxmm4wYI/o/ykmKO3No8DSnRL +EWKX1HSWZC1TnJfSu4VbNNfU5mGJeuRk5mj9WDzRAsrAWxSLSquywAO4/QRXlJbL3Ho Vphd4+zF5XWslF+QAQtwQr5WPzofqw4uCDpicJEJmq6cIOwfsbdhmGYZI6NjxgyPX9Ku qfcg== X-Gm-Message-State: AC+VfDwa6/7Y1EDwSMvuUW31ksG9UsYW5lu44mz8ToelsZp/5t+VF1Vb O8ojqQ9WrqnBA+7c7CUia40= X-Google-Smtp-Source: ACHHUZ59ObWY7AjW4ljfH7y2qGBifeJLlvpvOt5TlkzTJkdqy5Kw+DCexP7S2FrlfQEn9hoDu065zg== X-Received: by 2002:a05:6870:b211:b0:19f:5f32:32db with SMTP id a17-20020a056870b21100b0019f5f3232dbmr5108237oam.14.1687213273184; Mon, 19 Jun 2023 15:21:13 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 15:21:12 -0700 (PDT) To: Jens Gustedt , libc-alpha@sourceware.org Cc: Yonggang Luo Subject: [PATCH 3/5] clang-format: should format with 2 space and do not usage tab Date: Tue, 20 Jun 2023 06:20:50 +0800 Message-Id: <20230619222052.682-4-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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Signed-off-by: Yonggang Luo --- .clang-format | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.clang-format b/.clang-format index 36c169e007..6e8ef236be 100644 --- a/.clang-format +++ b/.clang-format @@ -146,8 +146,8 @@ SpacesInParentheses: false SpacesInSquareBrackets: false SpaceBeforeSquareBrackets: false Standard: Cpp03 -TabWidth: 8 -UseTab: Always +TabWidth: 2 +UseTab: Never ForEachMacros: - 'FOR_EACH_IMPL' - 'list_for_each' 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: 71350 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 661B03856DC8 for ; Mon, 19 Jun 2023 22:21:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 661B03856DC8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687213300; 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=CFk9i9KQaiDSJTq40AOHCSRqmkfDrJXIfYZA6Xwtbbw9AWs2bFc3WDlEum7cQMzY1 lp1ohxnn7SvBJ7Tj3shpKRoXHMtY9SlMKZBb8GhM5qJdjJuTOjSzHzDvTVlz5duAe5 wlgI463F8bD5CTyJ8F5eJ729q3MvkeT0qAdlVaaQ= 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+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..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); } From patchwork Mon Jun 19 22:20:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 71352 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 27660385087B for ; Mon, 19 Jun 2023 22:22:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 27660385087B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687213336; bh=fD8D+c9Vmz5Zcmx+i35s5OAvfuED/V5plQ1xwjNeG/4=; 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=mE6xg+i45zPPuOKcAtmvwTyMHUei9ad8e8KWpWy3dr01/JWn/HKWl7oMu3iXiN/Vh FMUyvf5OtlSC5EKQOGX1fXa3QEWbIOFCMkXLtoAdR4ixuP51gtCf//uNtp+AQtyD9s 9jmfU7w4q7byML3NRSMVpsiilB3gzJpyuOzuiYqg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x36.google.com (mail-oa1-x36.google.com [IPv6:2001:4860:4864:20::36]) by sourceware.org (Postfix) with ESMTPS id 6F006385773E for ; Mon, 19 Jun 2023 22:21:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F006385773E Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-1acdfbe1c78so444783fac.2 for ; Mon, 19 Jun 2023 15:21:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687213278; x=1689805278; 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=fD8D+c9Vmz5Zcmx+i35s5OAvfuED/V5plQ1xwjNeG/4=; b=AjRdJ0cHvBpK2Q1TrMnayX4jL+8KCmsvY4RnGkD/czJqywkCBIUu2SgTJoPeCEAXgc 3k+guHkNShQ8UXTStlJcsbwXakmBBg4N+LQ5U/GqaBPyVwiJ78nToO5/hlxB4g6cj1s/ yVlvaGIkF1Ihqdj1shHkA3rGzeJ9m9lOP2QCErjHLRHbgQksvrJwaLudOtOcbx3wkam6 x9wPlniOaR1L7CqQ2SKKU0zRC8fg0ZfcYL3RFoCVkCtJYZfSzGfgdNrt/44k+7DlqmXk 5xS5OfMqQbOGQfspqGAgahghf/yS+qV+wVqYES6K/GGmEVPfuXBmwKWwZy57s6m8bjN2 Y5Gg== X-Gm-Message-State: AC+VfDzwi6eXwf43m0ucrZbapk6m5wmTS8oI1/EXGQelB0qn/dCrWGuP 2MLIoCyu0dMb4qHyoFi9aM0= X-Google-Smtp-Source: ACHHUZ403dU7EZk2suTorLzc7o11Jhb3zm6GCjMsd3xkbn7x+JqsMzxHTAh1j4d2QOIdZzbifHhUDw== X-Received: by 2002:a05:6870:a8a9:b0:1a0:bbee:c1de with SMTP id eb41-20020a056870a8a900b001a0bbeec1demr6885569oab.1.1687213277570; Mon, 19 Jun 2023 15:21:17 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 15:21:17 -0700 (PDT) To: Jens Gustedt , libc-alpha@sourceware.org Cc: Yonggang Luo Subject: [PATCH 5/5] c2y: Add function cnd_timedwait_monotonic and mtx_timedlock_monotonic Date: Tue, 20 Jun 2023 06:20:52 +0800 Message-Id: <20230619222052.682-6-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, KAM_SHORT, 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 --- conform/data/threads.h-data | 2 + nptl/Versions | 5 ++ sysdeps/pthread/Makefile | 2 + sysdeps/pthread/cnd_timedwait_monotonic.c | 29 +++++++++++ sysdeps/pthread/mtx_timedlock_monotonic.c | 28 ++++++++++ sysdeps/pthread/threads.h | 16 ++++++ sysdeps/unix/sysv/linux/Versions | 6 +++ .../unix/sysv/linux/cnd_timedwait_monotonic.c | 51 +++++++++++++++++++ .../unix/sysv/linux/mtx_timedlock_monotonic.c | 50 ++++++++++++++++++ sysdeps/unix/sysv/linux/thrd_priv.h | 8 +++ 10 files changed, 197 insertions(+) create mode 100644 sysdeps/pthread/cnd_timedwait_monotonic.c create mode 100644 sysdeps/pthread/mtx_timedlock_monotonic.c create mode 100644 sysdeps/unix/sysv/linux/cnd_timedwait_monotonic.c create mode 100644 sysdeps/unix/sysv/linux/mtx_timedlock_monotonic.c diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data index 406e497726..cb71ddfaf7 100644 --- a/conform/data/threads.h-data +++ b/conform/data/threads.h-data @@ -34,6 +34,7 @@ function void thrd_yield (void) function int mtx_init (mtx_t*, int) function int mtx_lock (mtx_t*) function int mtx_timedlock (mtx_t*, const struct timespec*) +function int mtx_timedlock_monotonic (mtx_t*, const struct timespec*) function int mtx_trylock (mtx_t*) function int mtx_unlock (mtx_t*) function void mtx_destroy (mtx_t*) @@ -45,6 +46,7 @@ function int cnd_signal (cnd_t*) function int cnd_broadcast (cnd_t*) function int cnd_wait (cnd_t*, mtx_t*) function int cnd_timedwait (cnd_t*, mtx_t*, const struct timespec*) +function int cnd_timedwait_monotonic (cnd_t*, mtx_t*, const struct timespec*) function void cnd_destroy (cnd_t*) function int tss_create (tss_t*, tss_dtor_t) diff --git a/nptl/Versions b/nptl/Versions index 3221de89d1..429b05fc71 100644 --- a/nptl/Versions +++ b/nptl/Versions @@ -525,6 +525,11 @@ libpthread { GLIBC_2.31 { __libpthread_version_placeholder; } + + GLIBC_2.38 { + cnd_timedwait_monotonic; + mtx_timedlock_monotonic; + } } ld { diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile index 32cf4eb119..293e321132 100644 --- a/sysdeps/pthread/Makefile +++ b/sysdeps/pthread/Makefile @@ -40,11 +40,13 @@ $(libpthread-routines-var) += \ cnd_init \ cnd_signal \ cnd_timedwait \ + cnd_timedwait_monotonic \ cnd_wait \ mtx_destroy \ mtx_init \ mtx_lock \ mtx_timedlock \ + mtx_timedlock_monotonic \ mtx_trylock \ mtx_unlock \ pthread_atfork_compat \ diff --git a/sysdeps/pthread/cnd_timedwait_monotonic.c b/sysdeps/pthread/cnd_timedwait_monotonic.c new file mode 100644 index 0000000000..8e9a32791a --- /dev/null +++ b/sysdeps/pthread/cnd_timedwait_monotonic.c @@ -0,0 +1,29 @@ +/* C11 threads conditional timed wait implementation. + Copyright (C) 2018-2023 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 "thrd_priv.h" + +int +cnd_timedwait_monotonic (cnd_t *restrict cond, mtx_t *restrict mutex, + const struct timespec *restrict time_point) +{ + int err_code = __pthread_cond_clockwait ((pthread_cond_t *) cond, + (pthread_mutex_t *) mutex, + CLOCK_MONOTONIC, time_point); + return thrd_err_map (err_code); +} diff --git a/sysdeps/pthread/mtx_timedlock_monotonic.c b/sysdeps/pthread/mtx_timedlock_monotonic.c new file mode 100644 index 0000000000..96d1dde7f7 --- /dev/null +++ b/sysdeps/pthread/mtx_timedlock_monotonic.c @@ -0,0 +1,28 @@ +/* C11 threads mutex timed lock implementation. + Copyright (C) 2018-2023 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 "thrd_priv.h" + +int +mtx_timedlock_monotonic (mtx_t *restrict mutex, + const struct timespec *restrict time_point) +{ + int err_code = pthread_mutex_clocklock ((pthread_mutex_t *) mutex, + CLOCK_MONOTONIC, time_point); + return thrd_err_map (err_code); +} diff --git a/sysdeps/pthread/threads.h b/sysdeps/pthread/threads.h index d88d7a3ddd..b3ddaafd05 100644 --- a/sysdeps/pthread/threads.h +++ b/sysdeps/pthread/threads.h @@ -146,14 +146,21 @@ extern int mtx_lock (mtx_t *__mutex); #ifndef __USE_TIME_BITS64 extern int mtx_timedlock (mtx_t *__restrict __mutex, const struct timespec *__restrict __time_point); +extern int mtx_timedlock_monotonic (mtx_t *__restrict __mutex, + const struct timespec *__restrict __time_point); #else # ifdef __REDIRECT extern int __REDIRECT (mtx_timedlock, (mtx_t *__restrict __mutex, const struct timespec *__restrict __time_point), __mtx_timedlock64); +extern int __REDIRECT (mtx_timedlock_monotonic, (mtx_t *__restrict __mutex, + const struct timespec *__restrict + __time_point), + __mtx_timedlock_monotonic64); # else # define mtx_timedlock __mtx_timedlock64 +# define mtx_timedlock_monotonic __mtx_timedlock_monotonic64 # endif #endif @@ -198,6 +205,9 @@ extern int cnd_wait (cnd_t *__cond, mtx_t *__mutex); extern int cnd_timedwait (cnd_t *__restrict __cond, mtx_t *__restrict __mutex, const struct timespec *__restrict __time_point); +extern int cnd_timedwait_monotonic (cnd_t *__restrict __cond, + mtx_t *__restrict __mutex, + const struct timespec *__restrict __time_point); #else # ifdef __REDIRECT extern int __REDIRECT (cnd_timedwait, (cnd_t *__restrict __cond, @@ -205,8 +215,14 @@ extern int __REDIRECT (cnd_timedwait, (cnd_t *__restrict __cond, const struct timespec *__restrict __time_point), __cnd_timedwait64); +extern int __REDIRECT (cnd_timedwait_monotonic, (cnd_t *__restrict __cond, + mtx_t *__restrict __mutex, + const struct timespec *__restrict + __time_point), + __cnd_timedwait_monotonic64); # else # define cnd_timedwait __cnd_timedwait64 +# define cnd_timedwait_monotonic __cnd_timedwait_monotonic64 # endif #endif diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index bc59bce42f..5b68cfdabe 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -319,6 +319,12 @@ libc { GLIBC_2.37 { %ifdef TIME64_NON_DEFAULT __ppoll64_chk; +%endif + } + GLIBC_2.38 { +%ifdef TIME64_NON_DEFAULT + __cnd_timedwait_monotonic64; + __mtx_timedlock_monotonic64; %endif } GLIBC_PRIVATE { diff --git a/sysdeps/unix/sysv/linux/cnd_timedwait_monotonic.c b/sysdeps/unix/sysv/linux/cnd_timedwait_monotonic.c new file mode 100644 index 0000000000..351fe944f4 --- /dev/null +++ b/sysdeps/unix/sysv/linux/cnd_timedwait_monotonic.c @@ -0,0 +1,51 @@ +/* C11 threads conditional timed wait implementation - Linux variant. + Copyright (C) 2020-2023 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 +#include "thrd_priv.h" + +int +__cnd_timedwait_monotonic64 (cnd_t *restrict cond, mtx_t *restrict mutex, + const struct __timespec64 *restrict time_point) +{ + int err_code = __pthread_cond_clockwait64 ((pthread_cond_t *) cond, + (pthread_mutex_t *) mutex, + CLOCK_MONOTONIC, time_point); + return thrd_err_map (err_code); +} + +#if __TIMESIZE == 64 +strong_alias (__cnd_timedwait_monotonic64, ___cnd_timedwait_monotonic) +#else +libc_hidden_def (__cnd_timedwait_monotonic64) + +int +___cnd_timedwait_monotonic (cnd_t *restrict cond, mtx_t *restrict mutex, + const struct timespec *restrict time_point) +{ + struct __timespec64 ts64 = valid_timespec_to_timespec64 (*time_point); + + return __cnd_timedwait_monotonic64(cond, mutex, &ts64); +} +#endif /* __TIMESIZE == 64 */ +versioned_symbol (libc, ___cnd_timedwait_monotonic, cnd_timedwait_monotonic, GLIBC_2_34); + +#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_28, GLIBC_2_34) +compat_symbol (libpthread, ___cnd_timedwait_monotonic, cnd_timedwait_monotonic, GLIBC_2_28); +#endif diff --git a/sysdeps/unix/sysv/linux/mtx_timedlock_monotonic.c b/sysdeps/unix/sysv/linux/mtx_timedlock_monotonic.c new file mode 100644 index 0000000000..435232c87d --- /dev/null +++ b/sysdeps/unix/sysv/linux/mtx_timedlock_monotonic.c @@ -0,0 +1,50 @@ +/* C11 threads mutex timed lock implementation - Linux variant. + Copyright (C) 2020-2023 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 +#include "thrd_priv.h" + +int +__mtx_timedlock_monotonic64 (mtx_t *restrict mutex, + const struct __timespec64 *restrict time_point) +{ + int err_code = __pthread_mutex_clocklock64 ((pthread_mutex_t *) mutex, + CLOCK_MONOTONIC, time_point); + return thrd_err_map (err_code); +} + +#if __TIMESIZE == 64 +strong_alias (__mtx_timedlock_monotonic64, ___mtx_timedlock_monotonic) +#else +libc_hidden_def (__mtx_timedlock_monotonic64) + +int +___mtx_timedlock_monotonic (mtx_t *restrict mutex, + const struct timespec *restrict time_point) +{ + struct __timespec64 ts64 = valid_timespec_to_timespec64 (*time_point); + + return __mtx_timedlock_monotonic64 (mutex, &ts64); +} +#endif /* __TIMESIZE == 64 */ +versioned_symbol (libc, ___mtx_timedlock_monotonic, mtx_timedlock_monotonic, GLIBC_2_34); + +#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_28, GLIBC_2_34) +compat_symbol (libpthread, ___mtx_timedlock_monotonic, mtx_timedlock_monotonic, GLIBC_2_28); +#endif diff --git a/sysdeps/unix/sysv/linux/thrd_priv.h b/sysdeps/unix/sysv/linux/thrd_priv.h index af23a10a07..905798ecf2 100644 --- a/sysdeps/unix/sysv/linux/thrd_priv.h +++ b/sysdeps/unix/sysv/linux/thrd_priv.h @@ -20,15 +20,23 @@ #if __TIMESIZE == 64 # define __cnd_timedwait64 __cnd_timedwait +# define __cnd_timedwait_monotonic64 __cnd_timedwait_monotonic # define __mtx_timedlock64 __mtx_timedlock +# define __mtx_timedlock_monotonic64 __mtx_timedlock_monotonic # define __thrd_sleep64 __thrd_sleep #else extern int __cnd_timedwait64 (cnd_t *restrict cond, mtx_t *restrict mutex, const struct __timespec64 *restrict time_point); libc_hidden_proto (__cnd_timedwait64) +extern int __cnd_timedwait_monotonic64 (cnd_t *restrict cond, mtx_t *restrict mutex, + const struct __timespec64 *restrict time_point); +libc_hidden_proto (__cnd_timedwait_monotonic64) extern int __mtx_timedlock64 (mtx_t *restrict mutex, const struct __timespec64 *restrict time_point); libc_hidden_proto (__mtx_timedlock64) +extern int __mtx_timedlock_monotonic64 (mtx_t *restrict mutex, + const struct __timespec64 *restrict time_point); +libc_hidden_proto (__mtx_timedlock_monotonic64) extern int __thrd_sleep64 (const struct __timespec64 *time_point, struct __timespec64 *remaining); libc_hidden_proto (__thrd_sleep64)