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 3543 invoked from network); 20 Jun 2023 14:37:35 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 20 Jun 2023 14:37:35 -0000 Received: (qmail 18380 invoked by uid 550); 20 Jun 2023 14:37:32 -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 18345 invoked from network); 20 Jun 2023 14:37:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687271839; x=1689863839; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=TeZctIn3PRBvkiJsli9qDHmwwVPdLUK/kwRjjQ6zPDU=; b=qwJsLA+//4fCPbZn+VNcwQEfim1o7OdiP1a5pRB+QQYGUzFLhma+Gc9jPqL/8/+3xg iZVRmhxS6RDgV4z7MN3KW43ZTLjqou0d3VBsGVoGYlYN5MDW8st8Dp+nF7MfQgFJuQAb YaHLRG5V3Jhy97hz0YXic2tvw2VIRQLcPFTc11xGE1ZbUhzm+KZ5CfDKaFbQx6K2bPr1 duku1qYGjMeEj4Loc61b0/2ZAr4LJ1rTYIaq+poCnh5wKXt5rLTNrWCidE8qfyXrbn/9 XnUkArcoMq1yMGZXHQJ2AP5oZJUvW2DbpTiuiW1fAlhzyRt0mLc8zdGfrYqSmSXUHbnL ROWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687271839; x=1689863839; 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=TeZctIn3PRBvkiJsli9qDHmwwVPdLUK/kwRjjQ6zPDU=; b=TB5+UVSiFGhnA4TcXj7KU3k4+qPIJrmLaeLWNVNoHJiPc5e55HtbhOeFIA47rqABFu 8kp5J1HUbwfYBXkjldsp4xdNgqGj0xYMBh5KLz3aPepjk3DzffRFF39wgazqhxaVikAG 11/TBranFXhgZss8K2FTquzBc7GgSJ3i8cJeXcpw5d9/x8rZwg61qhEDunq96dafU48w YA7YrHLz2S2GwJ2ToopekaepFK8YuJYuGqXxGHUYHLuk7kSgmfqseoPX6cztpeM7asM2 5TAk15A/XcXZb0xX6KnkyfYw+gZlLCSfMPA1V0uJrjJyUJN8py4omw0fJgRQupU8hCAI wM6g== X-Gm-Message-State: AC+VfDwY8Koc3TTIkzy3s9jXWTg7DNoF2WPrhu3bLAsAVPy/L33Bb8yk wSvndtC/3z9gzytC/rbh4rI= X-Google-Smtp-Source: ACHHUZ6fIk6DFrDrhyBmpEh2F7C7RGDhlVNUIM5FRF7qmfi5ncW/e1UEvoSVTYT8ZWYTBBMjpCBVwg== X-Received: by 2002:a17:90a:6e09:b0:259:c10:ea34 with SMTP id b9-20020a17090a6e0900b002590c10ea34mr9847541pjk.2.1687271839001; Tue, 20 Jun 2023 07:37:19 -0700 (PDT) From: Yonggang Luo To: Jens Gustedt , enh , musl@lists.openwall.com Cc: Yonggang Luo Date: Tue, 20 Jun 2023 22:36:58 +0800 Message-Id: <20230620143703.1415-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 v3 0/5] Add posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait c2y/mtx_timedlock_base c2y/cnd_timedwait_base 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_base cnd_timedwait_base to do that. The protype of these two functions is: int mtx_timedlock_base(mtx_t *restrict m, int time_base, const struct timespec *restrict ts); int cnd_timedwait_base(cnd_t *restrict c, mtx_t *restrict m, int time_base, const struct timespec *restrict ts); The time_base at least can be TIME_UTC/TIME_MONOTONIC, the implementer can implement it with any provided TIME_* base parameter provided in c2y time.h, if TIME_MONOTONIC can not natively supported, fallback to TIME_UTC should provided, for other TIME_* base parameter, it's implementer's choice. And indeed mtx_timedlock_base and cnd_timedwait_base 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_base cnd_timedwait_base 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 (5): trim spaces of pthread_cond_timedwait.c and pthread_mutex_timedlock.c Rename files for implement pthread_mutex_clocklock and pthread_cond_clockwait add pthread_mutex_clocklock and pthread_cond_clockdwait c23: Implement newly base for timespec_get c2y: Add monotonic timedlock/timedwait support for threads mtx/cnd compat/time32/cnd_timedwait_base_time32.c | 9 + compat/time32/mtx_timedlock_base_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 | 8 +- src/thread/cnd_timedwait_base.c | 26 +++ src/thread/mtx_timedlock.c | 7 +- src/thread/mtx_timedlock_base.c | 25 +++ ...d_timedwait.c => pthread_cond_clockwait.c} | 14 +- src/thread/pthread_cond_timedwait.c | 208 +----------------- ..._timedlock.c => pthread_mutex_clocklock.c} | 14 +- src/thread/pthread_mutex_timedlock.c | 86 +------- src/time/timespec_get.c | 44 +++- 18 files changed, 174 insertions(+), 321 deletions(-) create mode 100644 compat/time32/cnd_timedwait_base_time32.c create mode 100644 compat/time32/mtx_timedlock_base_time32.c create mode 100644 compat/time32/pthread_cond_clockwait_time32.c create mode 100644 compat/time32/pthread_mutex_clocklock_time32.c create mode 100644 src/thread/cnd_timedwait_base.c create mode 100644 src/thread/mtx_timedlock_base.c copy src/thread/{pthread_cond_timedwait.c => pthread_cond_clockwait.c} (93%) copy src/thread/{pthread_mutex_timedlock.c => pthread_mutex_clocklock.c} (85%) -- 2.39.0.windows.1