Re: introduction of an additional non-POSIX function in libpthread
Sure thing, here an updated diff. Regards. On 18 July 2017 at 16:22, Ted Unangstwrote: > David CARLIER wrote: > > Hi. > > > > I sent a diff originally to a smaller audience but finally decided to > post > > it in the mailing list. > > So it is to introduce the pthread_set_name_np's counterpart so > > pthread_get_name_np. > > Some softwares use it (NSPR for example) and anyway internally in my > > workplace we have multiplatform needing this feature would be nice having > > this for OpenBSD as well :-) > > > > Let me know what you think. > > this is fine, it makes sense to have a get function if there's a set > function. you can combine the man pages, however. no need for two. just > add a > sentence to the existing one. > Index: lib/libpthread/include/pthread_np.h === RCS file: /cvs/src/lib/libpthread/include/pthread_np.h,v retrieving revision 1.11 diff -u -p -r1.11 pthread_np.h --- lib/libpthread/include/pthread_np.h 22 Mar 2012 17:21:36 - 1.11 +++ lib/libpthread/include/pthread_np.h 18 Jul 2017 20:50:26 - @@ -46,6 +46,7 @@ __BEGIN_DECLS int pthread_mutexattr_getkind_np(pthread_mutexattr_t); int pthread_mutexattr_setkind_np(pthread_mutexattr_t *, int); void pthread_set_name_np(pthread_t, const char *); +void pthread_get_name_np(pthread_t, char *, size_t); int pthread_stackseg_np(pthread_t, stack_t *); int pthread_main_np(void); __END_DECLS Index: lib/libpthread/man/pthread_set_name_np.3 === RCS file: /cvs/src/lib/libpthread/man/pthread_set_name_np.3,v retrieving revision 1.6 diff -u -p -r1.6 pthread_set_name_np.3 --- lib/libpthread/man/pthread_set_name_np.36 Mar 2014 17:42:25 - 1.6 +++ lib/libpthread/man/pthread_set_name_np.318 Jul 2017 20:50:26 - @@ -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 Index: lib/libpthread/man/pthreads.3 === RCS file: /cvs/src/lib/libpthread/man/pthreads.3,v retrieving revision 1.41 diff -u -p -r1.41 pthreads.3 --- lib/libpthread/man/pthreads.3 16 Jul 2013 15:21:11 - 1.41 +++ lib/libpthread/man/pthreads.3 18 Jul 2017 20:50:26 - @@ -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 verb .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 , Index: lib/librthread/Symbols.map === RCS file: /cvs/src/lib/librthread/Symbols.map,v retrieving revision 1.3 diff -u -p -r1.3 Symbols.map --- lib/librthread/Symbols.map 27 Feb 2017 07:15:22 - 1.3 +++ lib/librthread/Symbols.map 18 Jul 2017 20:50:26 - @@ -54,6 +54,7 @@ pthread_detach; pthread_equal; pthread_exit; + pthread_get_name_np; pthread_getconcurrency; pthread_getcpuclockid; pthread_getprio; Index: lib/librthread/pthread_np.h === RCS file: /cvs/src/lib/librthread/pthread_np.h,v retrieving revision 1.1 diff -u -p -r1.1 pthread_np.h --- lib/librthread/pthread_np.h 2 Apr 2016 19:56:53 - 1.1 +++ lib/librthread/pthread_np.h 18 Jul 2017 20:50:26 - @@ -24,6 +24,7 @@ PROTO_DEPRECATED(pthread_main_np); PROTO_DEPRECATED(pthread_mutexattr_getkind_np); PROTO_DEPRECATED(pthread_mutexattr_setkind_np); PROTO_DEPRECATED(pthread_set_name_np); +PROTO_DEPRECATED(pthread_get_name_np); PROTO_DEPRECATED(pthread_stackseg_np); #endif /* !_LIBPTHREAD_PTHREAD_NP_H_ */ Index: lib/librthread/rthread_np.c === RCS file: /cvs/src/lib/librthread/rthread_np.c,v retrieving revision 1.19 diff -u -p -r1.19 rthread_np.c --- lib/librthread/rthread_np.c 7 May 2016 19:05:22 - 1.19 +++ lib/librthread/rthread_np.c 18 Jul 2017 20:50:26 - @@ -43,6 +43,20 @@ pthread_set_name_np(pthread_t thread, co strlcpy(thread->name, name, sizeof(thread->name)); } +void +pthread_get_name_np(pthread_t thread, char *name,
Re: introduction of an additional non-POSIX function in libpthread
David CARLIER wrote: > Hi. > > I sent a diff originally to a smaller audience but finally decided to post > it in the mailing list. > So it is to introduce the pthread_set_name_np's counterpart so > pthread_get_name_np. > Some softwares use it (NSPR for example) and anyway internally in my > workplace we have multiplatform needing this feature would be nice having > this for OpenBSD as well :-) > > Let me know what you think. this is fine, it makes sense to have a get function if there's a set function. you can combine the man pages, however. no need for two. just add a sentence to the existing one.
Re: introduction of an additional non-POSIX function in libpthread
Yes that s true NetBSD having a variadic like argument as well ... etc ... I did not have high expectations just wanted to propose ... :-) On 18 July 2017 at 14:55, Landry Breuilwrote: > On Tue, Jul 18, 2017 at 01:43:42PM +0100, David CARLIER wrote: > > Ah I recognise you you re Mozilla contributor right ? You re probably > right > > but that was just an example eventhough I admit it s not extremely widely > > used ... > > Note that you'll have to be careful in your arguments for this function: > > - _np prefix is for 'nonportable' so nothing standardises it > - some oses have getname_np, freebsd has get_name_np > - linux and netbsd share the function name but not the prototype for > setname_mp ? > - macos enforces the running thread to set its own name > > (cf https://stackoverflow.com/a/7989973) > > so this looks like a shitshow, and a pretty good reason for not > having it :) > >
Re: introduction of an additional non-POSIX function in libpthread
On Tue, Jul 18, 2017 at 01:43:42PM +0100, David CARLIER wrote: > Ah I recognise you you re Mozilla contributor right ? You re probably right > but that was just an example eventhough I admit it s not extremely widely > used ... Note that you'll have to be careful in your arguments for this function: - _np prefix is for 'nonportable' so nothing standardises it - some oses have getname_np, freebsd has get_name_np - linux and netbsd share the function name but not the prototype for setname_mp ? - macos enforces the running thread to set its own name (cf https://stackoverflow.com/a/7989973) so this looks like a shitshow, and a pretty good reason for not having it :)
Re: introduction of an additional non-POSIX function in libpthread
Oups mistake of mine. good catch On 18 July 2017 at 14:08, Karel Gardaswrote: > Why your patch defines MALLOC_STATS? > > -/* #define MALLOC_STATS */ > +#define MALLOC_STATS > > On Tue, Jul 18, 2017 at 2:43 PM, David CARLIER wrote: > > Ah I recognise you you re Mozilla contributor right ? You re probably > right > > but that was just an example eventhough I admit it s not extremely widely > > used ... > > > > On 18 July 2017 at 13:36, Landry Breuil wrote: > > > >> On Tue, Jul 18, 2017 at 01:24:21PM +0100, David CARLIER wrote: > >> > Hi. > >> > > >> > I sent a diff originally to a smaller audience but finally decided to > >> post > >> > it in the mailing list. > >> > So it is to introduce the pthread_set_name_np's counterpart so > >> > pthread_get_name_np. > >> > Some softwares use it (NSPR for example) and anyway internally in my > >> > workplace we have multiplatform needing this feature would be nice > having > >> > this for OpenBSD as well :-) > >> > >> the js engine uses it: > >> https://bugzilla.mozilla.org/show_bug.cgi?id=1298451 > >> > >> but nspr stopped using it or never used it, there's only a reference to > >> pthread_set_name_np: > >> https://hg.mozilla.org/projects/nspr/file/tip/pr/src/ > >> pthreads/ptthread.c#l1759 > >> > >> PR_GetThreadName (just below) returns the 'local' name value, and doesnt > >> get it from the system. > >> > >> Landry > >> > >> >
Re: introduction of an additional non-POSIX function in libpthread
Why your patch defines MALLOC_STATS? -/* #define MALLOC_STATS */ +#define MALLOC_STATS On Tue, Jul 18, 2017 at 2:43 PM, David CARLIERwrote: > Ah I recognise you you re Mozilla contributor right ? You re probably right > but that was just an example eventhough I admit it s not extremely widely > used ... > > On 18 July 2017 at 13:36, Landry Breuil wrote: > >> On Tue, Jul 18, 2017 at 01:24:21PM +0100, David CARLIER wrote: >> > Hi. >> > >> > I sent a diff originally to a smaller audience but finally decided to >> post >> > it in the mailing list. >> > So it is to introduce the pthread_set_name_np's counterpart so >> > pthread_get_name_np. >> > Some softwares use it (NSPR for example) and anyway internally in my >> > workplace we have multiplatform needing this feature would be nice having >> > this for OpenBSD as well :-) >> >> the js engine uses it: >> https://bugzilla.mozilla.org/show_bug.cgi?id=1298451 >> >> but nspr stopped using it or never used it, there's only a reference to >> pthread_set_name_np: >> https://hg.mozilla.org/projects/nspr/file/tip/pr/src/ >> pthreads/ptthread.c#l1759 >> >> PR_GetThreadName (just below) returns the 'local' name value, and doesnt >> get it from the system. >> >> Landry >> >>
Re: introduction of an additional non-POSIX function in libpthread
Ah I recognise you you re Mozilla contributor right ? You re probably right but that was just an example eventhough I admit it s not extremely widely used ... On 18 July 2017 at 13:36, Landry Breuilwrote: > On Tue, Jul 18, 2017 at 01:24:21PM +0100, David CARLIER wrote: > > Hi. > > > > I sent a diff originally to a smaller audience but finally decided to > post > > it in the mailing list. > > So it is to introduce the pthread_set_name_np's counterpart so > > pthread_get_name_np. > > Some softwares use it (NSPR for example) and anyway internally in my > > workplace we have multiplatform needing this feature would be nice having > > this for OpenBSD as well :-) > > the js engine uses it: > https://bugzilla.mozilla.org/show_bug.cgi?id=1298451 > > but nspr stopped using it or never used it, there's only a reference to > pthread_set_name_np: > https://hg.mozilla.org/projects/nspr/file/tip/pr/src/ > pthreads/ptthread.c#l1759 > > PR_GetThreadName (just below) returns the 'local' name value, and doesnt > get it from the system. > > Landry > >
Re: introduction of an additional non-POSIX function in libpthread
On Tue, Jul 18, 2017 at 01:24:21PM +0100, David CARLIER wrote: > Hi. > > I sent a diff originally to a smaller audience but finally decided to post > it in the mailing list. > So it is to introduce the pthread_set_name_np's counterpart so > pthread_get_name_np. > Some softwares use it (NSPR for example) and anyway internally in my > workplace we have multiplatform needing this feature would be nice having > this for OpenBSD as well :-) the js engine uses it: https://bugzilla.mozilla.org/show_bug.cgi?id=1298451 but nspr stopped using it or never used it, there's only a reference to pthread_set_name_np: https://hg.mozilla.org/projects/nspr/file/tip/pr/src/pthreads/ptthread.c#l1759 PR_GetThreadName (just below) returns the 'local' name value, and doesnt get it from the system. Landry
introduction of an additional non-POSIX function in libpthread
Hi. I sent a diff originally to a smaller audience but finally decided to post it in the mailing list. So it is to introduce the pthread_set_name_np's counterpart so pthread_get_name_np. Some softwares use it (NSPR for example) and anyway internally in my workplace we have multiplatform needing this feature would be nice having this for OpenBSD as well :-) Let me know what you think. Kind regards. Index: lib/libc/stdlib/malloc.c === RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v retrieving revision 1.228 diff -u -p -r1.228 malloc.c --- lib/libc/stdlib/malloc.c10 Jul 2017 09:44:16 - 1.228 +++ lib/libc/stdlib/malloc.c15 Jul 2017 19:54:00 - @@ -23,7 +23,7 @@ * can buy me a beer in return. Poul-Henning Kamp */ -/* #define MALLOC_STATS */ +#define MALLOC_STATS #include #include /* PAGE_SHIFT ALIGN */ Index: lib/libpthread/include/pthread_np.h === RCS file: /cvs/src/lib/libpthread/include/pthread_np.h,v retrieving revision 1.11 diff -u -p -r1.11 pthread_np.h --- lib/libpthread/include/pthread_np.h 22 Mar 2012 17:21:36 - 1.11 +++ lib/libpthread/include/pthread_np.h 15 Jul 2017 19:54:00 - @@ -46,6 +46,7 @@ __BEGIN_DECLS int pthread_mutexattr_getkind_np(pthread_mutexattr_t); int pthread_mutexattr_setkind_np(pthread_mutexattr_t *, int); void pthread_set_name_np(pthread_t, const char *); +void pthread_get_name_np(pthread_t, char *, size_t); int pthread_stackseg_np(pthread_t, stack_t *); int pthread_main_np(void); __END_DECLS Index: lib/libpthread/man/Makefile.inc === RCS file: /cvs/src/lib/libpthread/man/Makefile.inc,v retrieving revision 1.36 diff -u -p -r1.36 Makefile.inc --- lib/libpthread/man/Makefile.inc 30 Mar 2016 06:38:42 - 1.36 +++ lib/libpthread/man/Makefile.inc 15 Jul 2017 19:54:00 - @@ -31,6 +31,7 @@ MAN+= \ pthread_detach.3 \ pthread_equal.3 \ pthread_exit.3 \ + pthread_get_name_np.3 \ pthread_getconcurrency.3 \ pthread_getcpuclockid.3 \ pthread_getspecific.3 \ Index: lib/libpthread/man/pthread_get_name_np.3 === RCS file: lib/libpthread/man/pthread_get_name_np.3 diff -N lib/libpthread/man/pthread_get_name_np.3 --- /dev/null 1 Jan 1970 00:00:00 - +++ lib/libpthread/man/pthread_get_name_np.315 Jul 2017 19:54:00 - @@ -0,0 +1,29 @@ +.Dd $Mdocdate: July 15 2017 $ +.Dt PTHREAD_GET_NAME_NP 3 +.Os +.Sh NAME +.Nm pthread_get_name_np +.Nd get the name of a thread +.Sh SYNOPSIS +.In pthread.h +.In pthread_np.h +.Ft void +.Fn pthread_get_name_np "pthread_t thread" "char *name" "size_t len" +.Sh DESCRIPTION +The +.Fn pthread_get_name_np +function retrieves +.Fa name associated +with +.Fa thread . +.Pp +If pthread_set_name_np was not called for this +.Fa thread +the name parameter will be empty. +.Sh SEE ALSO +.Xr pthreads 3 +.Sh STANDARDS +The +.Fn pthread_get_name_np +function is non-portable and may not be supported with the above +semantics on other POSIX systems. Index: lib/libpthread/man/pthreads.3 === RCS file: /cvs/src/lib/libpthread/man/pthreads.3,v retrieving revision 1.41 diff -u -p -r1.41 pthreads.3 --- lib/libpthread/man/pthreads.3 16 Jul 2013 15:21:11 - 1.41 +++ lib/libpthread/man/pthreads.3 15 Jul 2017 19:54:00 - @@ -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 verb .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 , Index: lib/librthread/Symbols.map === RCS file: /cvs/src/lib/librthread/Symbols.map,v retrieving revision 1.3 diff -u -p -r1.3 Symbols.map --- lib/librthread/Symbols.map 27 Feb 2017 07:15:22 - 1.3 +++ lib/librthread/Symbols.map 15 Jul 2017 19:54:00 - @@ -54,6 +54,7 @@ pthread_detach; pthread_equal; pthread_exit; + pthread_get_name_np; pthread_getconcurrency; pthread_getcpuclockid; pthread_getprio; Index: lib/librthread/pthread_np.h === RCS file: /cvs/src/lib/librthread/pthread_np.h,v retrieving revision 1.1 diff -u -p -r1.1 pthread_np.h --- lib/librthread/pthread_np.h 2 Apr 2016 19:56:53 - 1.1 +++ lib/librthread/pthread_np.h 15 Jul 2017 19:54:00