git: 83aafcdc8892 - main - libc, libthr: coordinate stubs for pthread_{suspend,resume}_all_np
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 14 Nov 2024 02:49:14 UTC
The branch main has been updated by kevans:
URL: https://cgit.FreeBSD.org/src/commit/?id=83aafcdc88928c99e80b04ead23a156e235f9af4
commit 83aafcdc88928c99e80b04ead23a156e235f9af4
Author: Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2024-11-14 02:48:02 +0000
Commit: Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2024-11-14 02:48:05 +0000
libc, libthr: coordinate stubs for pthread_{suspend,resume}_all_np
If libthr isn't linked into the process, then we don't have any pthreads
to worry about and our stubs can just return success -- there are none
to suspend/resume.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D47350
---
lib/libc/gen/Symbol.map | 2 ++
lib/libc/gen/_pthread_stubs.c | 4 ++++
lib/libc/include/libc_private.h | 2 ++
lib/libthr/thread/thr_init.c | 2 ++
lib/libthr/thread/thr_private.h | 2 ++
lib/libthr/thread/thr_resume_np.c | 5 +++--
lib/libthr/thread/thr_suspend_np.c | 5 +++--
7 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index 4f77023dad72..ca3974e6b747 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -47,6 +47,7 @@ FBSD_1.0 {
pthread_mutexattr_init;
pthread_mutexattr_settype;
pthread_once;
+ pthread_resume_all_np;
pthread_rwlock_destroy;
pthread_rwlock_init;
pthread_rwlock_rdlock;
@@ -59,6 +60,7 @@ FBSD_1.0 {
pthread_setcanceltype;
pthread_setspecific;
pthread_sigmask;
+ pthread_suspend_all_np;
pthread_testcancel;
alarm;
arc4random;
diff --git a/lib/libc/gen/_pthread_stubs.c b/lib/libc/gen/_pthread_stubs.c
index a8723bbe72be..9df9ec9b8599 100644
--- a/lib/libc/gen/_pthread_stubs.c
+++ b/lib/libc/gen/_pthread_stubs.c
@@ -132,6 +132,8 @@ pthread_func_entry_t __thr_jtable[PJT_MAX] = {
[PJT_GETTHREADID_NP] = {PJT_DUAL_ENTRY(stub_zero)},
[PJT_ATTR_GET_NP] = {PJT_DUAL_ENTRY(stub_esrch)},
[PJT_GETNAME_NP] = {PJT_DUAL_ENTRY(stub_getname_np)},
+ [PJT_SUSPEND_ALL_NP] = {PJT_DUAL_ENTRY(stub_null)},
+ [PJT_RESUME_ALL_NP] = {PJT_DUAL_ENTRY(stub_null)},
};
/*
@@ -291,6 +293,8 @@ STUB_FUNC1(_pthread_cancel_enter, PJT_CANCEL_ENTER, void, int)
STUB_FUNC1(_pthread_cancel_leave, PJT_CANCEL_LEAVE, void, int)
STUB_FUNC2(pthread_attr_get_np, PJT_ATTR_GET_NP, int, pthread_t, pthread_attr_t *)
STUB_FUNC3(pthread_getname_np, PJT_GETNAME_NP, int, pthread_t, char *, size_t)
+STUB_FUNC(pthread_suspend_all_np, PJT_SUSPEND_ALL_NP, void);
+STUB_FUNC(pthread_resume_all_np, PJT_RESUME_ALL_NP, void);
static int
stub_zero(void)
diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h
index 4d4779647f50..4c244f962b2b 100644
--- a/lib/libc/include/libc_private.h
+++ b/lib/libc/include/libc_private.h
@@ -187,6 +187,8 @@ typedef enum {
PJT_GETTHREADID_NP,
PJT_ATTR_GET_NP,
PJT_GETNAME_NP,
+ PJT_SUSPEND_ALL_NP,
+ PJT_RESUME_ALL_NP,
PJT_MAX
} pjt_index_t;
diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c
index ff59288d919e..708c425d69c1 100644
--- a/lib/libthr/thread/thr_init.c
+++ b/lib/libthr/thread/thr_init.c
@@ -271,6 +271,8 @@ static pthread_func_t jmp_table[][2] = {
[PJT_GETTHREADID_NP] = {DUAL_ENTRY(_thr_getthreadid_np)},
[PJT_ATTR_GET_NP] = {DUAL_ENTRY(_thr_attr_get_np)},
[PJT_GETNAME_NP] = {DUAL_ENTRY(_thr_getname_np)},
+ [PJT_SUSPEND_ALL_NP] = {DUAL_ENTRY(_thr_suspend_all_np)},
+ [PJT_RESUME_ALL_NP] = {DUAL_ENTRY(_thr_resume_all_np)},
};
static int init_once = 0;
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index 023558100e2a..d6c12348e3ab 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -840,6 +840,8 @@ void _thr_signal_postfork(void) __hidden;
void _thr_signal_postfork_child(void) __hidden;
void _thr_suspend_all_lock(struct pthread *) __hidden;
void _thr_suspend_all_unlock(struct pthread *) __hidden;
+void _thr_suspend_all_np(void) __hidden;
+void _thr_resume_all_np(void) __hidden;
void _thr_try_gc(struct pthread *, struct pthread *) __hidden;
int _rtp_to_schedparam(const struct rtprio *rtp, int *policy,
struct sched_param *param) __hidden;
diff --git a/lib/libthr/thread/thr_resume_np.c b/lib/libthr/thread/thr_resume_np.c
index 1e69bfa7358b..c5669fd4f0ff 100644
--- a/lib/libthr/thread/thr_resume_np.c
+++ b/lib/libthr/thread/thr_resume_np.c
@@ -38,7 +38,8 @@
#include "thr_private.h"
__weak_reference(_pthread_resume_np, pthread_resume_np);
-__weak_reference(_pthread_resume_all_np, pthread_resume_all_np);
+__weak_reference(_thr_resume_all_np, pthread_resume_all_np);
+__weak_reference(_thr_resume_all_np, _pthread_resume_all_np);
static void resume_common(struct pthread *thread);
@@ -59,7 +60,7 @@ _pthread_resume_np(pthread_t thread)
}
void
-_pthread_resume_all_np(void)
+_thr_resume_all_np(void)
{
struct pthread *curthread = _get_curthread();
struct pthread *thread;
diff --git a/lib/libthr/thread/thr_suspend_np.c b/lib/libthr/thread/thr_suspend_np.c
index b272c7b2a169..cf4e9e8a96b1 100644
--- a/lib/libthr/thread/thr_suspend_np.c
+++ b/lib/libthr/thread/thr_suspend_np.c
@@ -41,7 +41,8 @@ static int suspend_common(struct pthread *, struct pthread *,
int);
__weak_reference(_pthread_suspend_np, pthread_suspend_np);
-__weak_reference(_pthread_suspend_all_np, pthread_suspend_all_np);
+__weak_reference(_thr_suspend_all_np, pthread_suspend_all_np);
+__weak_reference(_thr_suspend_all_np, _pthread_suspend_all_np);
/* Suspend a thread: */
int
@@ -101,7 +102,7 @@ _thr_suspend_all_unlock(struct pthread *curthread)
}
void
-_pthread_suspend_all_np(void)
+_thr_suspend_all_np(void)
{
struct pthread *curthread = _get_curthread();
struct pthread *thread;