From nobody Tue Nov 10 00:22:11 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jNnQq4yrFz70l7Y for ; Tue, 10 Nov 2026 00:22:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jNnQq2BRrz3QtY for ; Tue, 10 Nov 2026 00:22:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794270131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5kyAWcu/bwMiZXJtn7/vDWJ0wOky5326YINLH5mOfZc=; b=t+tvCwvavn6epPCGO5p9xnuQFh4LltHN8LK6NcCOTw444U3X+0dPs2PXk/sq90PRIQogIr S/xbYFoeoZjoa75LDvitT/85aia6Mx4/sGgp1qVuDynUgLc0tmadatdSOkVSFbSquHZdAT 5X1YAl1RCmenTEgKVbGtYY16PyMoVe3rJGtYU7vk+ZGKDgaLyrdN6E7wbp9Mb/1qIiqamf nV2g3ALbEaG7Da+cybIoAkhRW+c2e391X/WuNuM9CClogYXL5U9snKiztmYllYDorMp/Y6 bvFBlr1A199yvIqHYgaLrtfeNEj2lW1IOsml5YpwmoGoWrFOAEI+P6ttFBSiBw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794270131; b=TaCUOLPNK4XMcrkoqlADbXrR75BeOhu+GaONby9d3fRugesw1aVxm2SZ+vqEtWWvzjeuAQ jb7YSvbhIOlJVm9QAAhjTjEozd1oCuQoau4Q7ybdGqixDV6277LLy48ZV/GiTI3kPmh4X5 naiDwhPTnQTB87ormmbGGHAILgpykjM+YU+pvts5NNpcDeK+HIlbt00cSL5ZdFkecca+zZ nhqw1qWkaljM2QcP0AlJb+qApx0gTdy3PTwtNUpN9pVz+d9TBzpmu5Gtq2FHZimY8yMIqq xsFhcFckb0GKePMxqweJInJJm0Ez12+mr3hPM+xK0FthjCKiEX2MKzj5pNMOlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794270131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5kyAWcu/bwMiZXJtn7/vDWJ0wOky5326YINLH5mOfZc=; b=OSsWTDucs+DBrPlN0THIsQyCedWvSb+Kfe7MKgMTxlsnEFfIfHc2Yo8JJdIO3R1gWWGejT rb8MTdXOVBHk66ikM3gkFlZl9u3ibaxkhdE3p6W535gtSLVV6bAnX41mNr9uVMSLRmx+LE Pz0wBODlTzYUuiRZxUanrf/hd3xXGc9tEELZronBsVnqca6svJr9GEuap420gR53dPj+Sm /UxN7sPxBA41KTpttmVjoKGF8/64tiyW7TzhC/dALqXqdVPJf3RNzBXstmwFsZ2l1ixDnB 1mqnoU8UAYymH4tHRuyW+1TPT3WrASuSHH2XQGOr6ruXs1IhQ9FJHR1uLcyPOw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jNnQq1Z9Wz147b for ; Tue, 10 Nov 2026 00:22:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id fa1c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 10 Nov 2026 00:22:11 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 5577567bd0d0 - main - libthr: add pthread_rwlock_clock{rd,wr}lock(3) List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: Commit messages for the main branch of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5577567bd0d0c695c25ddb4ea32b8c8231d8b0fe Auto-Submitted: auto-generated Date: Tue, 10 Nov 2026 00:22:11 +0000 Message-Id: <6af263b3.fa1c.64e1bf8c@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=5577567bd0d0c695c25ddb4ea32b8c8231d8b0fe commit 5577567bd0d0c695c25ddb4ea32b8c8231d8b0fe Author: Konstantin Belousov AuthorDate: 2026-11-05 17:24:12 +0000 Commit: Konstantin Belousov CommitDate: 2026-11-10 00:21:18 +0000 libthr: add pthread_rwlock_clock{rd,wr}lock(3) Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D61253 --- include/pthread.h | 10 ++++++++++ lib/libthr/pthread.map | 2 ++ lib/libthr/thread/thr_rwlock.c | 42 ++++++++++++++++++++++++++++++++++-------- lib/libthr/thread/thr_umtx.c | 14 ++++++++------ lib/libthr/thread/thr_umtx.h | 8 ++++---- 5 files changed, 58 insertions(+), 18 deletions(-) diff --git a/include/pthread.h b/include/pthread.h index 9ff9748e699f..9ee552f2a8b2 100644 --- a/include/pthread.h +++ b/include/pthread.h @@ -257,6 +257,16 @@ int pthread_mutex_timedlock(pthread_mutex_t * __restrict __mutex, int pthread_mutex_unlock(pthread_mutex_t * __mutex) __unlocks(*__mutex); int pthread_once(pthread_once_t *, void (*) (void)); +#if __POSIX_VISIBLE >= 202405 +int pthread_rwlock_clockrdlock( + pthread_rwlock_t * __restrict __rwlock, + clockid_t, const struct timespec * __restrict) + __trylocks_shared(0, *__rwlock); +int pthread_rwlock_clockwrlock( + pthread_rwlock_t * __restrict __rwlock, + clockid_t, const struct timespec * __restrict) + __trylocks_exclusive(0, *__rwlock); +#endif int pthread_rwlock_destroy(pthread_rwlock_t * __rwlock) __requires_unlocked(*__rwlock); int pthread_rwlock_init(pthread_rwlock_t * __restrict __rwlock, diff --git a/lib/libthr/pthread.map b/lib/libthr/pthread.map index 214a7c8b4234..8dc565a95858 100644 --- a/lib/libthr/pthread.map +++ b/lib/libthr/pthread.map @@ -348,5 +348,7 @@ FBSD_1.9 { pthread_mutex_clocklock; pthread_query_np; pthread_query_all_np; + pthread_rwlock_clockrdlock; + pthread_rwlock_clockwrlock; pthread_tryjoin_np; }; diff --git a/lib/libthr/thread/thr_rwlock.c b/lib/libthr/thread/thr_rwlock.c index 8bc22814f45b..fb1852f869d2 100644 --- a/lib/libthr/thread/thr_rwlock.c +++ b/lib/libthr/thread/thr_rwlock.c @@ -39,6 +39,11 @@ _Static_assert(sizeof(struct pthread_rwlock) <= THR_PAGE_SIZE_MIN, "pthread_rwlock is too large for off-page"); +int _pthread_rwlock_clockrdlock(pthread_rwlock_t * __restrict rwlock, + clockid_t clockid, const struct timespec * __restrict abstime); +int _pthread_rwlock_clockwrlock(pthread_rwlock_t * __restrict rwlock, + clockid_t clockid, const struct timespec * __restrict abstime); + __weak_reference(_thr_rwlock_destroy, pthread_rwlock_destroy); __weak_reference(_thr_rwlock_destroy, _pthread_rwlock_destroy); __weak_reference(_thr_rwlock_init, pthread_rwlock_init); @@ -46,6 +51,7 @@ __weak_reference(_thr_rwlock_init, _pthread_rwlock_init); __weak_reference(_Tthr_rwlock_rdlock, pthread_rwlock_rdlock); __weak_reference(_Tthr_rwlock_rdlock, _pthread_rwlock_rdlock); __weak_reference(_pthread_rwlock_timedrdlock, pthread_rwlock_timedrdlock); +__weak_reference(_pthread_rwlock_clockrdlock, pthread_rwlock_clockrdlock); __weak_reference(_Tthr_rwlock_tryrdlock, pthread_rwlock_tryrdlock); __weak_reference(_Tthr_rwlock_tryrdlock, _pthread_rwlock_tryrdlock); __weak_reference(_Tthr_rwlock_trywrlock, pthread_rwlock_trywrlock); @@ -55,6 +61,7 @@ __weak_reference(_Tthr_rwlock_unlock, _pthread_rwlock_unlock); __weak_reference(_Tthr_rwlock_wrlock, pthread_rwlock_wrlock); __weak_reference(_Tthr_rwlock_wrlock, _pthread_rwlock_wrlock); __weak_reference(_pthread_rwlock_timedwrlock, pthread_rwlock_timedwrlock); +__weak_reference(_pthread_rwlock_clockwrlock, pthread_rwlock_clockwrlock); static int init_static(struct pthread *thread, pthread_rwlock_t *rwlock); static int init_rwlock(pthread_rwlock_t *rwlock, pthread_rwlock_t *rwlock_out); @@ -194,7 +201,8 @@ abstime_invalid(const struct timespec *abstime) } static int -rwlock_rdlock_common(pthread_rwlock_t *rwlock, const struct timespec *abstime) +rwlock_rdlock_common(pthread_rwlock_t *rwlock, const struct timespec *abstime, + clockid_t clockid) { struct pthread *curthread = _get_curthread(); pthread_rwlock_t prwlock; @@ -225,7 +233,8 @@ rwlock_rdlock_common(pthread_rwlock_t *rwlock, const struct timespec *abstime) for (;;) { /* goto kernel and lock it */ - ret = __thr_rwlock_rdlock(&prwlock->lock, flags, abstime); + ret = __thr_rwlock_rdlock(&prwlock->lock, flags, abstime, + clockid); if (ret != EINTR) break; @@ -244,7 +253,7 @@ int _Tthr_rwlock_rdlock(pthread_rwlock_t *rwlock) { _thr_check_init(); - return (rwlock_rdlock_common(rwlock, NULL)); + return (rwlock_rdlock_common(rwlock, NULL, CLOCK_REALTIME)); } int @@ -252,7 +261,15 @@ _pthread_rwlock_timedrdlock(pthread_rwlock_t * __restrict rwlock, const struct timespec * __restrict abstime) { _thr_check_init(); - return (rwlock_rdlock_common(rwlock, abstime)); + return (rwlock_rdlock_common(rwlock, abstime, CLOCK_REALTIME)); +} + +int +_pthread_rwlock_clockrdlock(pthread_rwlock_t * __restrict rwlock, + clockid_t clockid, const struct timespec * __restrict abstime) +{ + _thr_check_init(); + return (rwlock_rdlock_common(rwlock, abstime, clockid)); } int @@ -294,7 +311,8 @@ _Tthr_rwlock_trywrlock(pthread_rwlock_t *rwlock) } static int -rwlock_wrlock_common(pthread_rwlock_t *rwlock, const struct timespec *abstime) +rwlock_wrlock_common(pthread_rwlock_t *rwlock, const struct timespec *abstime, + clockid_t clockid) { struct pthread *curthread = _get_curthread(); pthread_rwlock_t prwlock; @@ -322,7 +340,7 @@ rwlock_wrlock_common(pthread_rwlock_t *rwlock, const struct timespec *abstime) for (;;) { /* goto kernel and lock it */ - ret = __thr_rwlock_wrlock(&prwlock->lock, abstime); + ret = __thr_rwlock_wrlock(&prwlock->lock, abstime, clockid); if (ret == 0) { prwlock->owner = TID(curthread); break; @@ -345,7 +363,7 @@ int _Tthr_rwlock_wrlock(pthread_rwlock_t *rwlock) { _thr_check_init(); - return (rwlock_wrlock_common(rwlock, NULL)); + return (rwlock_wrlock_common(rwlock, NULL, CLOCK_REALTIME)); } int @@ -353,7 +371,15 @@ _pthread_rwlock_timedwrlock(pthread_rwlock_t * __restrict rwlock, const struct timespec * __restrict abstime) { _thr_check_init(); - return (rwlock_wrlock_common(rwlock, abstime)); + return (rwlock_wrlock_common(rwlock, abstime, CLOCK_REALTIME)); +} + +int +_pthread_rwlock_clockwrlock(pthread_rwlock_t * __restrict rwlock, + clockid_t clockid, const struct timespec * __restrict abstime) +{ + _thr_check_init(); + return (rwlock_wrlock_common(rwlock, abstime, clockid)); } int diff --git a/lib/libthr/thread/thr_umtx.c b/lib/libthr/thread/thr_umtx.c index 410e9c181235..5095cc2328ba 100644 --- a/lib/libthr/thread/thr_umtx.c +++ b/lib/libthr/thread/thr_umtx.c @@ -292,7 +292,7 @@ _thr_ucond_broadcast(struct ucond *cv) int __thr_rwlock_rdlock(struct urwlock *rwlock, int flags, - const struct timespec *tsp) + const struct timespec *tsp, clockid_t clockid) { struct _umtx_time timeout, *tm_p; size_t tm_size; @@ -303,7 +303,7 @@ __thr_rwlock_rdlock(struct urwlock *rwlock, int flags, } else { timeout._timeout = *tsp; timeout._flags = UMTX_ABSTIME; - timeout._clockid = CLOCK_REALTIME; + timeout._clockid = clockid; tm_p = &timeout; tm_size = sizeof(timeout); } @@ -312,7 +312,8 @@ __thr_rwlock_rdlock(struct urwlock *rwlock, int flags, } int -__thr_rwlock_wrlock(struct urwlock *rwlock, const struct timespec *tsp) +__thr_rwlock_wrlock(struct urwlock *rwlock, const struct timespec *tsp, + clockid_t clockid) { struct _umtx_time timeout, *tm_p; size_t tm_size; @@ -323,7 +324,7 @@ __thr_rwlock_wrlock(struct urwlock *rwlock, const struct timespec *tsp) } else { timeout._timeout = *tsp; timeout._flags = UMTX_ABSTIME; - timeout._clockid = CLOCK_REALTIME; + timeout._clockid = clockid; tm_p = &timeout; tm_size = sizeof(timeout); } @@ -346,7 +347,8 @@ _thr_rwl_rdlock(struct urwlock *rwlock) for (;;) { if (_thr_rwlock_tryrdlock(rwlock, URWLOCK_PREFER_READER) == 0) return; - ret = __thr_rwlock_rdlock(rwlock, URWLOCK_PREFER_READER, NULL); + ret = __thr_rwlock_rdlock(rwlock, URWLOCK_PREFER_READER, NULL, + CLOCK_REALTIME); if (ret == 0) return; if (ret != EINTR) @@ -362,7 +364,7 @@ _thr_rwl_wrlock(struct urwlock *rwlock) for (;;) { if (_thr_rwlock_trywrlock(rwlock) == 0) return; - ret = __thr_rwlock_wrlock(rwlock, NULL); + ret = __thr_rwlock_wrlock(rwlock, NULL, CLOCK_REALTIME); if (ret == 0) return; if (ret != EINTR) diff --git a/lib/libthr/thread/thr_umtx.h b/lib/libthr/thread/thr_umtx.h index 2ddc28af1df1..bd68e7c2a0fd 100644 --- a/lib/libthr/thread/thr_umtx.h +++ b/lib/libthr/thread/thr_umtx.h @@ -66,9 +66,9 @@ int _thr_ucond_signal(struct ucond *cv) __hidden; int _thr_ucond_broadcast(struct ucond *cv) __hidden; int __thr_rwlock_rdlock(struct urwlock *rwlock, int flags, - const struct timespec *tsp) __hidden; + const struct timespec *tsp, clockid_t clockid) __hidden; int __thr_rwlock_wrlock(struct urwlock *rwlock, - const struct timespec *tsp) __hidden; + const struct timespec *tsp, clockid_t clockid) __hidden; int __thr_rwlock_unlock(struct urwlock *rwlock) __hidden; /* Internal used only */ @@ -233,7 +233,7 @@ _thr_rwlock_rdlock(struct urwlock *rwlock, int flags, struct timespec *tsp) if (_thr_rwlock_tryrdlock(rwlock, flags) == 0) return (0); - return (__thr_rwlock_rdlock(rwlock, flags, tsp)); + return (__thr_rwlock_rdlock(rwlock, flags, tsp, CLOCK_REALTIME)); } static inline int @@ -242,7 +242,7 @@ _thr_rwlock_wrlock(struct urwlock *rwlock, struct timespec *tsp) if (_thr_rwlock_trywrlock(rwlock) == 0) return (0); - return (__thr_rwlock_wrlock(rwlock, tsp)); + return (__thr_rwlock_wrlock(rwlock, tsp, CLOCK_REALTIME)); } static inline int