Pull the pthread_key_t functions out of pthread.c.
This was originally motivated by noticing that we were setting the
wrong bits for the well-known tls entries. That was a harmless bug
because none of the well-known tls entries has a destructor, but
it's best not to leave land mines lying around.
Also add some missing POSIX constants, a new test, and fix
pthread_key_create's return value when we hit the limit.
Change-Id: Ife26ea2f4b40865308e8410ec803b20bcc3e0ed1
diff --git a/libc/include/sys/limits.h b/libc/include/sys/limits.h
index 5b127eb..2d0d11e 100644
--- a/libc/include/sys/limits.h
+++ b/libc/include/sys/limits.h
@@ -175,6 +175,12 @@
#define _POSIX_SAVED_IDS 1 /* saved user ids is a Linux feature */
#define _POSIX_JOB_CONTROL 1 /* job control is a Linux feature */
+#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 /* the minimum mandated by POSIX */
+#define PTHREAD_DESTRUCTOR_ITERATIONS 4
+#define _POSIX_THREAD_KEYS_MAX 128 /* the minimum mandated by POSIX */
+/* TODO: our PTHREAD_KEYS_MAX is currently too low to be posix compliant! */
+#define _POSIX_THREAD_THREADS_MAX 64 /* the minimum mandated by POSIX */
+#define PTHREAD_THREADS_MAX /* bionic has no specific limit */
#endif