Define PTHREAD_KEYS_MAX and _POSIX_THREAD_KEYS_MAX in a POSIX-compliant way.
Also make sysconf use PTHREAD_STACK_MIN rather than redefining its own, different, constant. Bug: 9997352 Change-Id: I9a8e7d2b18e691439abfb45533e82c36eee9e81d
This commit is contained in:
parent
9a73d08f4c
commit
c03e1e7439
@ -33,6 +33,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <pthread.h>
|
||||||
#include <stdio.h> // For FOPEN_MAX.
|
#include <stdio.h> // For FOPEN_MAX.
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/sysconf.h>
|
#include <sys/sysconf.h>
|
||||||
@ -57,7 +58,6 @@
|
|||||||
|
|
||||||
/* the following depends on our implementation */
|
/* the following depends on our implementation */
|
||||||
#define SYSTEM_ATEXIT_MAX 65536 /* our implementation is unlimited */
|
#define SYSTEM_ATEXIT_MAX 65536 /* our implementation is unlimited */
|
||||||
#define SYSTEM_THREAD_STACK_MIN 32768 /* lower values may be possible, but be conservative */
|
|
||||||
#define SYSTEM_THREAD_THREADS_MAX 2048 /* really unlimited */
|
#define SYSTEM_THREAD_THREADS_MAX 2048 /* really unlimited */
|
||||||
|
|
||||||
#define SYSTEM_2_C_BIND _POSIX_VERSION /* Posix C binding version */
|
#define SYSTEM_2_C_BIND _POSIX_VERSION /* Posix C binding version */
|
||||||
@ -309,7 +309,7 @@ int sysconf(int name) {
|
|||||||
case _SC_THREAD_KEYS_MAX:
|
case _SC_THREAD_KEYS_MAX:
|
||||||
return (BIONIC_TLS_SLOTS - TLS_SLOT_FIRST_USER_SLOT - GLOBAL_INIT_THREAD_LOCAL_BUFFER_COUNT);
|
return (BIONIC_TLS_SLOTS - TLS_SLOT_FIRST_USER_SLOT - GLOBAL_INIT_THREAD_LOCAL_BUFFER_COUNT);
|
||||||
|
|
||||||
case _SC_THREAD_STACK_MIN: return SYSTEM_THREAD_STACK_MIN;
|
case _SC_THREAD_STACK_MIN: return PTHREAD_STACK_MIN;
|
||||||
case _SC_THREAD_THREADS_MAX: return SYSTEM_THREAD_THREADS_MAX;
|
case _SC_THREAD_THREADS_MAX: return SYSTEM_THREAD_THREADS_MAX;
|
||||||
case _SC_TTY_NAME_MAX: return SYSTEM_TTY_NAME_MAX;
|
case _SC_TTY_NAME_MAX: return SYSTEM_TTY_NAME_MAX;
|
||||||
#ifdef _POSIX_THREADS
|
#ifdef _POSIX_THREADS
|
||||||
|
@ -176,9 +176,9 @@
|
|||||||
#define _POSIX_JOB_CONTROL 1 /* job control 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 _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 /* the minimum mandated by POSIX */
|
||||||
#define PTHREAD_DESTRUCTOR_ITERATIONS 4
|
#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
|
||||||
#define _POSIX_THREAD_KEYS_MAX 128 /* the minimum mandated by POSIX */
|
#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 PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX
|
||||||
#define _POSIX_THREAD_THREADS_MAX 64 /* the minimum mandated by POSIX */
|
#define _POSIX_THREAD_THREADS_MAX 64 /* the minimum mandated by POSIX */
|
||||||
#define PTHREAD_THREADS_MAX /* bionic has no specific limit */
|
#define PTHREAD_THREADS_MAX /* bionic has no specific limit */
|
||||||
|
|
||||||
|
@ -76,7 +76,12 @@ enum {
|
|||||||
* maintain that second number, but pthread_test will fail if we forget.
|
* maintain that second number, but pthread_test will fail if we forget.
|
||||||
*/
|
*/
|
||||||
#define GLOBAL_INIT_THREAD_LOCAL_BUFFER_COUNT 4
|
#define GLOBAL_INIT_THREAD_LOCAL_BUFFER_COUNT 4
|
||||||
#define BIONIC_TLS_SLOTS 128
|
/*
|
||||||
|
* This is PTHREAD_KEYS_MAX + TLS_SLOT_FIRST_USER_SLOT + GLOBAL_INIT_THREAD_LOCAL_BUFFER_COUNT
|
||||||
|
* rounded 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)
|
||||||
|
|
||||||
/* syscall only, do not call directly */
|
/* syscall only, do not call directly */
|
||||||
extern int __set_tls(void* ptr);
|
extern int __set_tls(void* ptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user