diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2019-02-04 17:18:09 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2019-02-04 17:18:09 +0000 |
commit | dd1a8be070d4c1f2430e774aefef9c7341301e14 (patch) | |
tree | 17a9b69786dd37c5a4134d69d2e2eecea4ba7276 | |
parent | b17bc6f5e6877c15c56d4cd13c97a2f4b7905ba6 (diff) |
add a pthread_get_name_np to match pthread_set_name_np.
could be useful in ports.
initial diff by David Carlier some time ago.
ok jca
-rw-r--r-- | include/pthread_np.h | 3 | ||||
-rw-r--r-- | lib/libpthread/man/pthread_set_name_np.3 | 11 | ||||
-rw-r--r-- | lib/libpthread/man/pthreads.3 | 7 | ||||
-rw-r--r-- | lib/librthread/Symbols.map | 1 | ||||
-rw-r--r-- | lib/librthread/pthread_np.h | 3 | ||||
-rw-r--r-- | lib/librthread/rthread_np.c | 8 | ||||
-rw-r--r-- | lib/librthread/shlib_version | 2 |
7 files changed, 27 insertions, 8 deletions
diff --git a/include/pthread_np.h b/include/pthread_np.h index d606735e787..b56bc651cb5 100644 --- a/include/pthread_np.h +++ b/include/pthread_np.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pthread_np.h,v 1.1 2017/10/15 23:40:33 guenther Exp $ */ +/* $OpenBSD: pthread_np.h,v 1.2 2019/02/04 17:18:08 tedu Exp $ */ /* * Copyright (c) 1996-98 John Birrell <jb@cimlogic.com.au>. * All rights reserved. @@ -45,6 +45,7 @@ typedef void (*pthread_switch_routine_t)(pthread_t, pthread_t); __BEGIN_DECLS int pthread_mutexattr_getkind_np(pthread_mutexattr_t); int pthread_mutexattr_setkind_np(pthread_mutexattr_t *, int); +void pthread_get_name_np(pthread_t, char *, size_t); void pthread_set_name_np(pthread_t, const char *); int pthread_stackseg_np(pthread_t, stack_t *); int pthread_main_np(void); diff --git a/lib/libpthread/man/pthread_set_name_np.3 b/lib/libpthread/man/pthread_set_name_np.3 index cb92f49f791..5c797b05ac3 100644 --- a/lib/libpthread/man/pthread_set_name_np.3 +++ b/lib/libpthread/man/pthread_set_name_np.3 @@ -1,6 +1,6 @@ -.\" $OpenBSD: pthread_set_name_np.3,v 1.6 2014/03/06 17:42:25 jmc Exp $ +.\" $OpenBSD: pthread_set_name_np.3,v 1.7 2019/02/04 17:18:08 tedu Exp $ .\" David Leonard <d@openbsd.org>, 1999. Public domain. -.Dd $Mdocdate: March 6 2014 $ +.Dd $Mdocdate: February 4 2019 $ .Dt PTHREAD_SET_NAME_NP 3 .Os .Sh NAME @@ -11,6 +11,8 @@ .In pthread_np.h .Ft void .Fn pthread_set_name_np "pthread_t thread" "const char *name" +.Ft void +.Fn pthread_get_name_np "pthread_t thread" "char *name" "size_t len" .Sh DESCRIPTION The .Fn pthread_set_name_np @@ -26,6 +28,11 @@ signal. The string pointed to by .Fa name is copied, and so need not be valid for the life of the thread. +.Fn pthread_get_name_np +function retrieves +.Fa name +associated with +.Fa thread . .Sh SEE ALSO .Xr pthreads 3 .Sh STANDARDS diff --git a/lib/libpthread/man/pthreads.3 b/lib/libpthread/man/pthreads.3 index b3ad565c4e8..000ddd3ca22 100644 --- a/lib/libpthread/man/pthreads.3 +++ b/lib/libpthread/man/pthreads.3 @@ -1,6 +1,6 @@ -.\" $OpenBSD: pthreads.3,v 1.41 2013/07/16 15:21:11 schwarze Exp $ +.\" $OpenBSD: pthreads.3,v 1.42 2019/02/04 17:18:08 tedu Exp $ .\" David Leonard <d@openbsd.org>, 1998. Public domain. -.Dd $Mdocdate: July 16 2013 $ +.Dd $Mdocdate: February 4 2019 $ .Dt PTHREADS 3 .Os .Sh NAME @@ -169,6 +169,8 @@ The functions available are as follows: Identify the main thread. .It Fn pthread_set_name_np Set the name of a thread. +.It Fn pthread_get_name_np +Get the name of a thread .It Fn pthread_stackseg_np Return stack size and location. .It Fn pthread_yield @@ -421,6 +423,7 @@ with larger numbers generating more verbose output. .Xr pthread_detach 3 , .Xr pthread_equal 3 , .Xr pthread_exit 3 , +.Xr pthread_get_name_np 3 , .Xr pthread_getcpuclockid 3 , .Xr pthread_getspecific 3 , .Xr pthread_join 3 , diff --git a/lib/librthread/Symbols.map b/lib/librthread/Symbols.map index da37e9f787a..98502073633 100644 --- a/lib/librthread/Symbols.map +++ b/lib/librthread/Symbols.map @@ -33,6 +33,7 @@ pthread_cleanup_push; pthread_create; pthread_detach; + pthread_get_name_np; pthread_getconcurrency; pthread_getcpuclockid; pthread_getprio; diff --git a/lib/librthread/pthread_np.h b/lib/librthread/pthread_np.h index 1f110fc0186..771d5a68046 100644 --- a/lib/librthread/pthread_np.h +++ b/lib/librthread/pthread_np.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pthread_np.h,v 1.1 2016/04/02 19:56:53 guenther Exp $ */ +/* $OpenBSD: pthread_np.h,v 1.2 2019/02/04 17:18:08 tedu Exp $ */ /* * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org> * @@ -23,6 +23,7 @@ PROTO_DEPRECATED(pthread_main_np); PROTO_DEPRECATED(pthread_mutexattr_getkind_np); PROTO_DEPRECATED(pthread_mutexattr_setkind_np); +PROTO_DEPRECATED(pthread_get_name_np); PROTO_DEPRECATED(pthread_set_name_np); PROTO_DEPRECATED(pthread_stackseg_np); diff --git a/lib/librthread/rthread_np.c b/lib/librthread/rthread_np.c index 86beb501068..64bd2db5aea 100644 --- a/lib/librthread/rthread_np.c +++ b/lib/librthread/rthread_np.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread_np.c,v 1.20 2017/09/05 02:40:54 guenther Exp $ */ +/* $OpenBSD: rthread_np.c,v 1.21 2019/02/04 17:18:08 tedu Exp $ */ /* * Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org> * Copyright (c) 2005 Otto Moerbeek <otto@openbsd.org> @@ -43,6 +43,12 @@ pthread_set_name_np(pthread_t thread, const char *name) strlcpy(thread->name, name, sizeof(thread->name)); } +void +pthread_get_name_np(pthread_t thread, char *name, size_t len) +{ + strlcpy(name, thread->name, len); +} + int pthread_main_np(void) { diff --git a/lib/librthread/shlib_version b/lib/librthread/shlib_version index c622cb8cdf3..72168dfd16a 100644 --- a/lib/librthread/shlib_version +++ b/lib/librthread/shlib_version @@ -1,2 +1,2 @@ major=26 -minor=0 +minor=1 |