From nobody Tue Nov 17 01:09:49 2026 X-Original-To: dev-commits-src-all@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 4jT68Y4hXZz71PjS for ; Tue, 17 Nov 2026 01:09:49 +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 4jT68Y13zTz3CYr for ; Tue, 17 Nov 2026 01:09:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794877789; 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=4oT0MfdswC6p+mkE5WVRuGhLFw2h1A4q9OuE4c5BJno=; b=ExZFBBC/YjX0D00xOnve0WVgpHSFazP45WaMiskmCFXj+jvbr+JutLNh+tl48ojKMSuWbv 3nutOiAlLmYZI8j3yJdnnCY2sqYJnXUVJcFuVGCNbYlkquRwHOdSy2QC6Yzc+HF1OlNROs 9yMwZSEk7s2sbKdv9fv11uBdA7CgS1wb10xGt7Y+rUzvj4ATHIyfZlphjgZeHNTg7aNDoj U6NXduJ9aZvLY/iQSKXM90IuxYZHjqK9D46qdF0uQKgIAdBHgTiSW9HMP4lyd+V3KUraT9 hSq1eB0LZJfHLeWW8zU3CvCoV2go2Vt0tT0K3ONR9HaJR909la8M0k0mGa4VDA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794877789; b=ARi9UG5iCrEewh7HOqcHZ4aXPhVhmZmF+/s7AKl2AYGYfDTl6O3XW2xrm0MHBviDRAFO+0 nLRyNZxz4FkGJN3Oo6xebbJg1XShb/Nahkf2RYjb1i+88P6O79JGY3id3lgzoWz9/5PKnv 87a2mrlzjIEtjd5+O/bODyQcjiyqid35WtLqvm5JI8TyG4Ywh2XKxXPB943ESmTK/tS3L6 k4m66FtBoNUrM3jVO14GV7wfuaAWHMkV6L7V4XZUJ8AiAakde0UX/0GH5+xaQv8069dBRz yaTWIPPKYm1kawMJ3fuw02n/KOg3VjZPi6SOHx8e+AxX46A22gK237fxAzZkyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794877789; 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=4oT0MfdswC6p+mkE5WVRuGhLFw2h1A4q9OuE4c5BJno=; b=aWEo++tXIO6ybakOaPqiQIhxbA7/2vXaOcbn5kKTtaQRc1XH9NREKCi4ELl3dlZAcf1w4i TK0OW+Cw/uyw6P/cUGYFyPe/Mdg+xPD46VcqlJF1vajM9WbdxPaWVxrWzYvwY8O0uM2vhl f5vBOOVZi0dCSdcri3mjfyZfy/oCcpHHH3pIA0eWpBbD4nW23sZKNHjn+mi89rnNi1OSN9 NheCwlnt4C8GrSgPG+LkwCvX2CCAa0cR6owT31tBQjkqq291kcYJoFxiNENyfvq8MZqt/v huiGwE9LsFKwD+yomJ8nvWr/sSFoTjZnb6YTi45Xb8iqR8rETT53glmHBMlBCQ== 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 4jT68Y0RvPzJWd for ; Tue, 17 Nov 2026 01:09:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1f09 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 01:09:49 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: be6740dcad3c - stable/15 - libthr: add pthread_rwlock_clock{rd,wr}lock(3) List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches 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/stable/15 X-Git-Reftype: branch X-Git-Commit: be6740dcad3ca21068b9a185fa94e50e8f331350 Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 01:09:49 +0000 Message-Id: <6afba95d.1f09.31053e6f@gitrepo.freebsd.org> The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=be6740dcad3ca21068b9a185fa94e50e8f331350 commit be6740dcad3ca21068b9a185fa94e50e8f331350 Author: Konstantin Belousov AuthorDate: 2026-11-05 17:24:12 +0000 Commit: Konstantin Belousov CommitDate: 2026-11-17 00:25:02 +0000 libthr: add pthread_rwlock_clock{rd,wr}lock(3) (cherry picked from commit 5577567bd0d0c695c25ddb4ea32b8c8231d8b0fe) --- 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 5fd1e1dcb14a..96e534431553 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; @@ -222,7 +230,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; @@ -241,7 +250,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 @@ -249,7 +258,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 @@ -291,7 +308,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; @@ -316,7 +334,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; @@ -339,7 +357,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 @@ -347,7 +365,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