From 02a4d1994dae198eb1d7c8233676bd18c313a7c1 Mon Sep 17 00:00:00 2001 From: kib Date: Wed, 3 Jun 2020 20:54:36 +0000 Subject: [PATCH] Add pthread_getname_np() and pthread_setname_np() aliases for pthread_get_name_np() and pthread_set_name_np(), to be compatible with Linux. PR: 238404 Proposed and reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D25117 --- include/pthread_np.h | 2 ++ lib/libthr/pthread.map | 2 ++ lib/libthr/thread/thr_info.c | 2 ++ share/man/man3/Makefile | 4 +++- share/man/man3/pthread_set_name_np.3 | 21 ++++++++++++++++++--- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/include/pthread_np.h b/include/pthread_np.h index f93a023f0fc..0bd68ff07ba 100644 --- a/include/pthread_np.h +++ b/include/pthread_np.h @@ -50,6 +50,7 @@ int pthread_attr_get_np(pthread_t, pthread_attr_t *); int pthread_attr_getaffinity_np(const pthread_attr_t *, size_t, cpuset_t *); int pthread_attr_setaffinity_np(pthread_attr_t *, size_t, const cpuset_t *); void pthread_get_name_np(pthread_t, char *, size_t); +void pthread_getname_np(pthread_t, char *, size_t); int pthread_getaffinity_np(pthread_t, size_t, cpuset_t *); int pthread_getthreadid_np(void); int pthread_main_np(void); @@ -65,6 +66,7 @@ void pthread_resume_all_np(void); int pthread_resume_np(pthread_t); int pthread_peekjoin_np(pthread_t, void **); void pthread_set_name_np(pthread_t, const char *); +void pthread_setname_np(pthread_t, const char *); int pthread_setaffinity_np(pthread_t, size_t, const cpuset_t *); int pthread_single_np(void); void pthread_suspend_all_np(void); diff --git a/lib/libthr/pthread.map b/lib/libthr/pthread.map index ab6f39ac00a..232d65084ba 100644 --- a/lib/libthr/pthread.map +++ b/lib/libthr/pthread.map @@ -328,5 +328,7 @@ FBSD_1.5 { }; FBSD_1.6 { + pthread_getname_np; pthread_peekjoin_np; + pthread_setname_np; }; diff --git a/lib/libthr/thread/thr_info.c b/lib/libthr/thread/thr_info.c index d11b488bcc1..3a366160269 100644 --- a/lib/libthr/thread/thr_info.c +++ b/lib/libthr/thread/thr_info.c @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include "thr_private.h" __weak_reference(_pthread_set_name_np, pthread_set_name_np); +__weak_reference(_pthread_set_name_np, pthread_setname_np); static void thr_set_name_np(struct pthread *thread, const char *name) @@ -89,6 +90,7 @@ thr_get_name_np(struct pthread *thread, char *buf, size_t len) } __weak_reference(_pthread_get_name_np, pthread_get_name_np); +__weak_reference(_pthread_get_name_np, pthread_getname_np); void _pthread_get_name_np(pthread_t thread, char *buf, size_t len) diff --git a/share/man/man3/Makefile b/share/man/man3/Makefile index 0caa8ea2855..7fb09f970a2 100644 --- a/share/man/man3/Makefile +++ b/share/man/man3/Makefile @@ -493,7 +493,9 @@ PTHREAD_MLINKS+=pthread_rwlock_rdlock.3 pthread_rwlock_tryrdlock.3 PTHREAD_MLINKS+=pthread_rwlock_wrlock.3 pthread_rwlock_trywrlock.3 PTHREAD_MLINKS+=pthread_schedparam.3 pthread_getschedparam.3 \ pthread_schedparam.3 pthread_setschedparam.3 -PTHREAD_MLINKS+=pthread_set_name_np.3 pthread_get_name_np.3 +PTHREAD_MLINKS+=pthread_set_name_np.3 pthread_get_name_np.3 \ + pthread_set_name_np.3 pthread_getname_np.3 \ + pthread_set_name_np.3 pthread_setname_np.3 PTHREAD_MLINKS+=pthread_spin_init.3 pthread_spin_destroy.3 \ pthread_spin_lock.3 pthread_spin_trylock.3 \ pthread_spin_lock.3 pthread_spin_unlock.3 diff --git a/share/man/man3/pthread_set_name_np.3 b/share/man/man3/pthread_set_name_np.3 index 3c7ddff56dd..fd1d7c2075c 100644 --- a/share/man/man3/pthread_set_name_np.3 +++ b/share/man/man3/pthread_set_name_np.3 @@ -24,12 +24,14 @@ .\" .\" $FreeBSD$ .\" -.Dd August 12, 2018 +.Dd June 3, 2020 .Dt PTHREAD_SET_NAME_NP 3 .Os .Sh NAME .Nm pthread_get_name_np , +.Nm pthread_getname_np , .Nm pthread_set_name_np +.Nm pthread_setname_np .Nd set and retrieve the thread name .Sh LIBRARY .Lb libpthread @@ -38,18 +40,26 @@ .Ft void .Fn pthread_get_name_np "pthread_t thread" "char *name" "size_t len" .Ft void +.Fn pthread_getname_np "pthread_t thread" "char *name" "size_t len" +.Ft void .Fn pthread_set_name_np "pthread_t thread" "const char *name" +.Ft void +.Fn pthread_setname_np "pthread_t thread" "const char *name" .Sh DESCRIPTION The .Fn pthread_set_name_np -function applies a copy of the given +and +.Fn pthread_setname_np +functions applies a copy of the given .Fa name to the given .Fa thread . .Pp The .Fn pthread_get_name_np -function retrieves the +and +.Fn pthread_getname_np +functions retrieves the .Fa name associated with .Fa thread . @@ -70,6 +80,11 @@ appear inside are silently ignored. and .Fn pthread_get_name_np are non-standard extensions. +.Fn pthread_setname_np +and +.Fn pthread_getname_np +are also non-standard, but are implemented by larger number of operating +systems so they are in fact more portable. .Sh AUTHORS This manual page was written by .An Alexey Zelkin Aq Mt phantom@FreeBSD.org -- 2.45.0