newlib-cygwin/winsup/cygwin/include
Jon Turney fdb7df230d Add pthread_getname_np and pthread_setname_np
This patch adds pthread_getname_np and pthread_setname_np.

These were added to glibc in 2.12[1] and are also present in some form on
NetBSD and several UNIXes.

The code is based on NetBSD's implementation with changes to better match
Linux behaviour.

Implementation quirks:

* pthread_setname_np with a NULL pointer segfaults (as linux)

* pthread_setname_np returns ERANGE for names longer than 16 characters (as
linux)

* pthread_getname_np with a NULL pointer returns EFAULT (as linux)

* pthread_getname_np with a buffer length of less than 16 returns ERANGE (as
linux)

* pthread_getname_np truncates the thread name to fit the buffer length.
This guarantees success even when the default thread name is longer than 16
characters, but means there is no way to discover the actual length of the
thread name. (Linux always truncates the thread name to 16 characters)

* Changing program_invocation_short_name changes the default thread name (on
linux, it has no effect on the default thread name)

I'll leave it up to you to decide if any of these matter.

This is implemented via class pthread_attr to make it easier to add
pthread_attr_[gs]etname_np (present in NetBSD and some UNIXes) should it
ever be added to Linux (or we decide we want it anyway).

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS
2016-08-23 15:07:42 +01:00
..
acl Implement POSIX.1e ACL functions 2016-03-08 13:56:40 +01:00
arpa Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
asm Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
attr Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
bits Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
cygwin Add pthread_getname_np and pthread_setname_np 2016-08-23 15:07:42 +01:00
machine machine/_types.h: __blkcnt_t should be signed 2016-07-14 19:02:57 +02:00
net Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
netinet Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
sys Remove leftover useless copyright hints 2016-06-25 13:36:52 +02:00
a.out.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
byteswap.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
dlfcn.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
elf.h * include/elf.h: Update from FreeBSD. 2012-06-06 04:45:48 +00:00
endian.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
err.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
error.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
fcntl.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
features.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
fenv.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
fnmatch.h Feature test macros overhaul: fnmatch.h 2016-03-17 21:08:54 -05:00
fts.h * Merge in cygwin-64bit-branch. 2013-04-23 09:44:36 +00:00
ftw.h * Merge in cygwin-64bit-branch. 2013-04-23 09:44:36 +00:00
getopt.h
glob.h Feature test macros overhaul: Cygwin headers 2016-03-17 21:09:22 -05:00
icmp.h
ifaddrs.h getifaddrs: Return pointer to extended interface info in ifa_data member 2016-03-10 18:00:00 +01:00
io.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
lastlog.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
limits.h Fix 32-bit SSIZE_MAX 2016-07-14 12:38:49 -06:00
mapi.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
memory.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
mntent.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
monetary.h Add sys/_locale.h header and fix up headers 2016-08-15 10:56:58 +02:00
mqueue.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
netdb.h Fix comments for AI_ADDRCONFIG and AI_V4MAPPED 2016-06-24 23:35:13 +02:00
paths.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
poll.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
process.h * include/process.h: Move here from include/cygwin subdir. 2012-02-07 17:15:07 +00:00
pthread.h Add pthread_getname_np and pthread_setname_np 2016-08-23 15:07:42 +01:00
pty.h
regex.h
resolv.h Remove spurious execute permissions from some Cygwin source and text files 2015-10-27 16:10:37 +00:00
search.h
semaphore.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
sysexits.h
syslog.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
termio.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
tzfile.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
ucontext.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
utmpx.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00
wait.h Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option 2016-06-23 10:09:17 +02:00