From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21160 invoked from network); 20 Jun 2023 07:45:09 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 20 Jun 2023 07:45:09 -0000 Received: (qmail 23671 invoked by uid 550); 20 Jun 2023 07:45:06 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 23632 invoked from network); 20 Jun 2023 07:45:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687247093; x=1689839093; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/ZpBmKaQoj+AE/wuNEIXxyepMpIpkmB3b1CJVax84E0=; b=rRvdcwoOTpKPvUzpuPN2uXDZK5h/73q/cw2tDtx8ar+so0d3lDuC2WxZCZD6a99uhE DTG4CbXxSiTWK6YmHKoYty4RrpF6pq5Md456hQQ6nio0xhjZaxMyrME7Ogake4URKmLx 04FmxU2U+dQWh61oCYhLxSCMPSj1Z7twPMLGi8P7UfoHkP4cKS1JeJ/B5VdsXS7XxuHJ vXljUvlQSt8GXWndM6FZN0KrVd2qPNO2bYd132lkf+c5aU2Lqu/rpVRTkjnB9sCiewRu rWxZXy3pydDp8txzdx/L9Mh5/QilalNzbIKeDlbQvMFOdKxjeVc+8ZHiffiveqxDhniL eYzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687247093; x=1689839093; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/ZpBmKaQoj+AE/wuNEIXxyepMpIpkmB3b1CJVax84E0=; b=S10T/Xss3AA/8YdZ4kE2qowKc6lg+ahwYTQPtlweldFzkGsFOW7QhbP9lqIua4eFcS hV7L4K+NiLAgJeryIvs92YrbRaxBqZcDhS7leZkxZchIwzi7WNLd+9TU+hhS5yHXonN3 u6umXFdQkg4v7GA/JOfEceYjXteiarXkMtd7nPss4/T6YY0KD20+GQdyhkWRWxA6Yre3 +R0BBzhclrCDxcAe/RY0i+tN1U0vr1WpeUfcUnyDbVL1pJxYdHB4SuyiQB0R0WSjpJ/l VzneOeh0oZV+6TRTtp+/19Sm2FNxwdMWewl55nLri2IiWCPndWdBUdcLDIua51Hb6Dw0 jYNA== X-Gm-Message-State: AC+VfDx1vXbWvgwFKDNAxAMsAA4rzMdpwPZIk0D6r4ctH/6tX+cW1JsW BvthI3eBG8WCBX/LXM0CTI0= X-Google-Smtp-Source: ACHHUZ7yH4U4UAxKoV/W5mKoJePmhRjGP4aeX5fgGfcWX7ZZBqvJy5MMgszCFSOUewjtOPNWrFkeEQ== X-Received: by 2002:a17:903:2696:b0:1b0:3576:c2b5 with SMTP id jf22-20020a170903269600b001b03576c2b5mr6498851plb.7.1687247093042; Tue, 20 Jun 2023 00:44:53 -0700 (PDT) From: Yonggang Luo To: Jens Gustedt , musl@lists.openwall.com Cc: Yonggang Luo Date: Tue, 20 Jun 2023 15:44:26 +0800 Message-Id: <20230620074427.131-1-luoyonggang@gmail.com> X-Mailer: git-send-email 2.39.0.windows.1 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [musl] [PATCH v2 0/4] Add posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait c2y/mtx_timedlock_monotonic c2y/cnd_timedwait_monotonic Currently, musl doesn't have pthread_mutex_clocklock pthread_cond_clockdwait, but glibc, android bionic, qnx libc already have these two functions, so implement them in musl. And for c11 threads, the mtx and cnd doesn't support for monotonic timedlock and timedwait, so add a proposaled function mtx_timedlock_monotonic cnd_timedwait_monotonic to do that. And indeed mtx_timedlock_monotonic and cnd_timedwait_monotonic can be implemented ontop of posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait, so I implemented posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait first in musl. I think mtx_timedlock_monotonic cnd_timedwait_monotonic is reasonable because it's newly added function and won't affect existing c11 threads functions. And it's can be implementd with glibc/qnx libc/android bionic without burden. For OS X it's can be implemented with pthread_cond_timedwait_relative_np For Windows it's can be implemented with SleepConditionVariableCS For platform have none of these, it's still can fallback to using mtx_timedlock and cnd_timedwait over TIME_UTC Yonggang Luo (4): trim spaces of pthread_cond_timedwait.c and pthread_mutex_timedlock.c add pthread_mutex_clocklock and pthread_cond_clockdwait c23: Implement newly base for timespec_get c2y: Add monotonic timed wait support for threads mtx cnd .../time32/cnd_timedwait_monotonic_time32.c | 9 ++++ .../time32/mtx_timedlock_monotonic_time32.c | 9 ++++ compat/time32/pthread_cond_clockwait_time32.c | 9 ++++ .../time32/pthread_mutex_clocklock_time32.c | 9 ++++ compat/time32/time32.h | 4 ++ include/pthread.h | 4 ++ include/threads.h | 4 ++ include/time.h | 13 +++++- src/include/pthread.h | 2 + src/thread/cnd_timedwait.c | 2 +- ..._timedwait.c => cnd_timedwait_monotonic.c} | 28 ++++++------ src/thread/mtx_timedlock.c | 2 +- ..._timedlock.c => mtx_timedlock_monotonic.c} | 26 +++++------ src/thread/pthread_cond_clockwait.c | 3 ++ src/thread/pthread_cond_timedwait.c | 18 +++++--- src/thread/pthread_mutex_clocklock.c | 3 ++ src/thread/pthread_mutex_timedlock.c | 15 ++++--- src/time/timespec_get.c | 44 ++++++++++++++++++- 18 files changed, 161 insertions(+), 43 deletions(-) create mode 100644 compat/time32/cnd_timedwait_monotonic_time32.c create mode 100644 compat/time32/mtx_timedlock_monotonic_time32.c create mode 100644 compat/time32/pthread_cond_clockwait_time32.c create mode 100644 compat/time32/pthread_mutex_clocklock_time32.c copy src/thread/{cnd_timedwait.c => cnd_timedwait_monotonic.c} (52%) copy src/thread/{mtx_timedlock.c => mtx_timedlock_monotonic.c} (74%) create mode 100644 src/thread/pthread_cond_clockwait.c create mode 100644 src/thread/pthread_mutex_clocklock.c -- 2.39.0.windows.1