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/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h
index bc68291..24b420c 100644
--- a/libc/bionic/pthread_internal.h
+++ b/libc/bionic/pthread_internal.h
@@ -60,6 +60,11 @@
 void _pthread_internal_add( pthread_internal_t*  thread );
 pthread_internal_t* __get_thread(void);
 
+__LIBC_HIDDEN__ void pthread_key_clean_all(void);
+
+extern pthread_internal_t* gThreadList;
+extern pthread_mutex_t gThreadListLock;
+
 /* needed by posix-timers.c */
 
 static __inline__ void timespec_add( struct timespec*  a, const struct timespec*  b )