From nobody Sun Jul 16 12:34:50 2023 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 4R3l622l90z4mZ7C; Sun, 16 Jul 2023 12:34:50 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4R3l622Fmkz3L6p; Sun, 16 Jul 2023 12:34:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689510890; 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=7joexk35AZovzHlCvIJlgjZ59ihSuuIZuyTTPfW8SUA=; b=nLtTvElrmBqmqBohbVpIGXe45bCgEIczWa75IYlI+TfLVtWD1v0LcwAiWAVGGfT3ddJqKH TL7EvkOGr17j6KLRnxj1CQ5XMWmnRXXlq7O9PRZcgaAoWFmFBLTmrlBVJAbFRJdjviHHqs gGPGwqpNfoZNpLsNmIxewT6R7p+eUcxM/vnPiSD3XfQJFp1CbHFRv0/ajmsrXBU9fDgiuu cyP+rG8zZX9DOSpA3rLeHt9qUpLWMtf1P2yc1wI3fCeCECbfdFbMcmBiqk4qSYcktFOOU1 fR+61v+kJh6mT1M0rgC33uG3grMakqNGlIBkCWswC3ignm3RdqK0+j5MsnjMMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689510890; 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=7joexk35AZovzHlCvIJlgjZ59ihSuuIZuyTTPfW8SUA=; b=hcTrQ4EyacJkNVPZqxPI3CxwkXLGaQ8eKxOPN70dSQFGFqDouR2QpAfbGEdm3qlWDoMpfx Vo8g8pLBXK0u9LScYndqbDPmKxlH0D/TByO9pz7YOBlfLDRgZ4ovV0bXTGZW82EGgF/StB VZ6DfNOwU1XqXX3c/H99fnvv89zvkIzAZXRJfpufjnXzzTksac0hSO8Q1hvwdLhOqKNxB8 22kYx43g5S0DlNhNjHLoSRh1OyKoNrty2POT6mtm+uKRlqxYpk2sAKPhkUvlLdBw/jVCBL my6hdQHA/r/9BjSi+gBUVG8EUftxqytPtCLuSv9gXZrwFvHfC/C71saZY7PVcg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689510890; a=rsa-sha256; cv=none; b=EZ9RJTy4BHlMQeBpeMQa5hPn8lvRMiGPqoiMXzg5tGE6unYm05HWLD9MNDyYPr5Ir4Bhxb lDmhraaKC486VLc8wzpwte7KuprtfFQ+S1vtGl8VhL9USzP8VAmJxFKvf6nWFOexPDgNYQ sQq6xHkES5wfxzdlG+k0KlsBgC0idptxe/pfqdg8Zdi9ncETO28+/UH81epmIGpLzf1Jbw /hPNqIf2y42ss7Wf92jmdOuslrw2zmzdijI7mWA5CK6RSpmvwjjnrZKQTQADzz0S9xMuy1 uAUTXz/ZOLGzaOb19XCo1B86pre/hYN8DxQkMP7M74SJM+WU1YGj7hDuuuEfkA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4R3l620nfpzjN2; Sun, 16 Jul 2023 12:34:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 36GCYoHb082277; Sun, 16 Jul 2023 12:34:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36GCYoIV082276; Sun, 16 Jul 2023 12:34:50 GMT (envelope-from git) Date: Sun, 16 Jul 2023 12:34:50 GMT Message-Id: <202307161234.36GCYoIV082276@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: ad056b5d35d9 - main - libthr: trigger library initialization on rwlock calls List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org 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: ad056b5d35d9957b1bd023abeb6461601449b725 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ad056b5d35d9957b1bd023abeb6461601449b725 commit ad056b5d35d9957b1bd023abeb6461601449b725 Author: Konstantin Belousov AuthorDate: 2023-07-13 15:56:11 +0000 Commit: Konstantin Belousov CommitDate: 2023-07-16 12:34:34 +0000 libthr: trigger library initialization on rwlock calls Reviewed by: tijl Sponsored by: The FreeBSD Foundation MFC after: 1 week --- lib/libthr/thread/thr_rwlock.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/libthr/thread/thr_rwlock.c b/lib/libthr/thread/thr_rwlock.c index 135d565b0d42..af32b09963d9 100644 --- a/lib/libthr/thread/thr_rwlock.c +++ b/lib/libthr/thread/thr_rwlock.c @@ -163,6 +163,7 @@ int _thr_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) { + _thr_check_init(); *rwlock = NULL; return (rwlock_init(rwlock, attr)); } @@ -231,6 +232,7 @@ rwlock_rdlock_common(pthread_rwlock_t *rwlock, const struct timespec *abstime) int _Tthr_rwlock_rdlock(pthread_rwlock_t *rwlock) { + _thr_check_init(); return (rwlock_rdlock_common(rwlock, NULL)); } @@ -238,21 +240,24 @@ int _pthread_rwlock_timedrdlock(pthread_rwlock_t * __restrict rwlock, const struct timespec * __restrict abstime) { + _thr_check_init(); return (rwlock_rdlock_common(rwlock, abstime)); } int _Tthr_rwlock_tryrdlock(pthread_rwlock_t *rwlock) { - struct pthread *curthread = _get_curthread(); + struct pthread *curthread; pthread_rwlock_t prwlock; int flags; int ret; + _thr_check_init(); ret = check_and_init_rwlock(rwlock, &prwlock); if (ret != 0) return (ret); + curthread = _get_curthread(); if (curthread->rdlock_count) { /* * To avoid having to track all the rdlocks held by @@ -280,14 +285,16 @@ _Tthr_rwlock_tryrdlock(pthread_rwlock_t *rwlock) int _Tthr_rwlock_trywrlock(pthread_rwlock_t *rwlock) { - struct pthread *curthread = _get_curthread(); + struct pthread *curthread; pthread_rwlock_t prwlock; int ret; + _thr_check_init(); ret = check_and_init_rwlock(rwlock, &prwlock); if (ret != 0) return (ret); + curthread = _get_curthread(); ret = _thr_rwlock_trywrlock(&prwlock->lock); if (ret == 0) prwlock->owner = TID(curthread); @@ -343,6 +350,7 @@ rwlock_wrlock_common(pthread_rwlock_t *rwlock, const struct timespec *abstime) int _Tthr_rwlock_wrlock(pthread_rwlock_t *rwlock) { + _thr_check_init(); return (rwlock_wrlock_common(rwlock, NULL)); } @@ -350,6 +358,7 @@ int _pthread_rwlock_timedwrlock(pthread_rwlock_t * __restrict rwlock, const struct timespec * __restrict abstime) { + _thr_check_init(); return (rwlock_wrlock_common(rwlock, abstime)); }