Add pthread_getname_np.
Also guard both these GNU extensions with _GNU_SOURCE.
Also improve the tests to test each case on both the current thread and
another thread, since the code paths are totally different.
Bug: http://b/27810459
Change-Id: I72b05bca5c5b6ca8ba4585b8edfb716a1c252f92
diff --git a/libc/include/pthread.h b/libc/include/pthread.h
index 50f2024..c67f239 100644
--- a/libc/include/pthread.h
+++ b/libc/include/pthread.h
@@ -245,7 +245,10 @@
pthread_t pthread_self(void) __pure2;
+#if defined(__USE_GNU)
+int pthread_getname_np(pthread_t, char*, size_t) __nonnull((2));
int pthread_setname_np(pthread_t, const char*) __nonnull((2));
+#endif
int pthread_setschedparam(pthread_t, int, const struct sched_param*) __nonnull((3));