aboutsummaryrefslogtreecommitdiffstats
path: root/libc/private/bionic_tls.h
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-12-12 11:02:41 -0800
committerElliott Hughes <enh@google.com>2013-12-12 12:51:08 -0800
commit1887621de8a48eece8a05f2400ddd783b9833147 (patch)
tree73707f9768954e6d68f077febc4f442e2010609e /libc/private/bionic_tls.h
parent38fcbbb35a40c46e96b4df10d670d1c132910854 (diff)
downloadandroid_bionic-1887621de8a48eece8a05f2400ddd783b9833147.tar.gz
android_bionic-1887621de8a48eece8a05f2400ddd783b9833147.tar.bz2
android_bionic-1887621de8a48eece8a05f2400ddd783b9833147.zip
PTHREAD_KEYS_MAX cleanup.
I fixed this bug a while back, but didn't remove it from the list, could have added a better test, and could have written clearer code that didn't require a comment. Change-Id: Iebdf0f9a54537a7d5cbca254a5967b1543061f3d
Diffstat (limited to 'libc/private/bionic_tls.h')
-rw-r--r--libc/private/bionic_tls.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/libc/private/bionic_tls.h b/libc/private/bionic_tls.h
index ff13fdb32..a42a8abed 100644
--- a/libc/private/bionic_tls.h
+++ b/libc/private/bionic_tls.h
@@ -30,6 +30,7 @@
#define __BIONIC_PRIVATE_BIONIC_TLS_H_
#include <sys/cdefs.h>
+#include <sys/limits.h>
#include "__get_tls.h"
__BEGIN_DECLS
@@ -74,21 +75,21 @@ enum {
};
/*
- * Maximum number of elements in the TLS array.
- * POSIX says this must be at least 128, but Android has traditionally had only 64, minus those
- * ones used internally by bionic itself.
* There are two kinds of slot used internally by bionic --- there are the well-known slots
* enumerated above, and then there are those that are allocated during startup by calls to
* pthread_key_create; grep for GLOBAL_INIT_THREAD_LOCAL_BUFFER to find those. We need to manually
* maintain that second number, but pthread_test will fail if we forget.
*/
#define GLOBAL_INIT_THREAD_LOCAL_BUFFER_COUNT 4
+
+#define BIONIC_ALIGN(x, a) (((x) + (a - 1)) & ~(a - 1))
+
/*
- * This is PTHREAD_KEYS_MAX + TLS_SLOT_FIRST_USER_SLOT + GLOBAL_INIT_THREAD_LOCAL_BUFFER_COUNT
- * rounded up to maintain stack alignment.
+ * Maximum number of elements in the TLS array.
+ * This includes space for pthread keys and our own internal slots.
+ * We need to round up to maintain stack alignment.
*/
-#define BIONIC_ALIGN(x, a) (((x) + (a - 1)) & ~(a - 1))
-#define BIONIC_TLS_SLOTS BIONIC_ALIGN(128 + TLS_SLOT_FIRST_USER_SLOT + GLOBAL_INIT_THREAD_LOCAL_BUFFER_COUNT, 4)
+#define BIONIC_TLS_SLOTS BIONIC_ALIGN(PTHREAD_KEYS_MAX + TLS_SLOT_FIRST_USER_SLOT + GLOBAL_INIT_THREAD_LOCAL_BUFFER_COUNT, 4)
__END_DECLS