Everyone has a TLS register.
Change-Id: Id7cdf67087aa7d5074c9c59b7e595bc391d9f146
This commit is contained in:
parent
baf2c09f3f
commit
91a9925998
@ -270,6 +270,7 @@ libc_bionic_src_files := \
|
|||||||
bionic/brk.cpp \
|
bionic/brk.cpp \
|
||||||
bionic/debug_format.cpp \
|
bionic/debug_format.cpp \
|
||||||
bionic/dirent.cpp \
|
bionic/dirent.cpp \
|
||||||
|
bionic/__errno.c \
|
||||||
bionic/eventfd.cpp \
|
bionic/eventfd.cpp \
|
||||||
bionic/__fgets_chk.cpp \
|
bionic/__fgets_chk.cpp \
|
||||||
bionic/getauxval.cpp \
|
bionic/getauxval.cpp \
|
||||||
@ -299,6 +300,7 @@ libc_bionic_src_files := \
|
|||||||
bionic/__strncpy_chk.cpp \
|
bionic/__strncpy_chk.cpp \
|
||||||
bionic/strsignal.cpp \
|
bionic/strsignal.cpp \
|
||||||
bionic/stubs.cpp \
|
bionic/stubs.cpp \
|
||||||
|
bionic/sysconf.cpp \
|
||||||
bionic/tdestroy.cpp \
|
bionic/tdestroy.cpp \
|
||||||
bionic/tmpfile.cpp \
|
bionic/tmpfile.cpp \
|
||||||
bionic/__umask_chk.cpp \
|
bionic/__umask_chk.cpp \
|
||||||
@ -349,23 +351,6 @@ libc_upstream_netbsd_src_files := \
|
|||||||
upstream-netbsd/libc/string/strxfrm.c \
|
upstream-netbsd/libc/string/strxfrm.c \
|
||||||
upstream-netbsd/libc/unistd/killpg.c \
|
upstream-netbsd/libc/unistd/killpg.c \
|
||||||
|
|
||||||
# The following files are common, but must be compiled
|
|
||||||
# with different C flags when building a static C library.
|
|
||||||
#
|
|
||||||
# The reason for this is the implementation of __get_tls()
|
|
||||||
# that will differ between the shared and static versions
|
|
||||||
# of the library.
|
|
||||||
#
|
|
||||||
# See comments in private/bionic_tls.h for more details.
|
|
||||||
#
|
|
||||||
# NOTE: bionic/pthread.c is added later to this list
|
|
||||||
# because it needs special handling on ARM, see
|
|
||||||
# below.
|
|
||||||
#
|
|
||||||
libc_static_common_src_files := \
|
|
||||||
bionic/__errno.c \
|
|
||||||
bionic/sysconf.cpp \
|
|
||||||
|
|
||||||
# Architecture specific source files go here
|
# Architecture specific source files go here
|
||||||
# =========================================================
|
# =========================================================
|
||||||
ifeq ($(TARGET_ARCH),arm)
|
ifeq ($(TARGET_ARCH),arm)
|
||||||
@ -545,18 +530,8 @@ ifeq ($(TARGET_ARCH),arm)
|
|||||||
libc_common_cflags += -fstrict-aliasing
|
libc_common_cflags += -fstrict-aliasing
|
||||||
libc_crt_target_cflags := -mthumb-interwork
|
libc_crt_target_cflags := -mthumb-interwork
|
||||||
#
|
#
|
||||||
# Define HAVE_ARM_TLS_REGISTER macro to indicate to the C library
|
# Define HAVE_32_BYTE_CACHE_LINES to indicate to the C library
|
||||||
# that it should access the hardware TLS register directly in
|
# that it should use the 32-byte version of memcpy, not
|
||||||
# private/bionic_tls.h
|
|
||||||
#
|
|
||||||
# The value must match your kernel configuration
|
|
||||||
#
|
|
||||||
ifeq ($(ARCH_ARM_HAVE_TLS_REGISTER),true)
|
|
||||||
libc_common_cflags += -DHAVE_ARM_TLS_REGISTER
|
|
||||||
endif
|
|
||||||
#
|
|
||||||
# Define HAVE_32_BYTE_CACHE_LINES to indicate to C
|
|
||||||
# library it should use to 32-byte version of memcpy, and not
|
|
||||||
# the 64-byte version.
|
# the 64-byte version.
|
||||||
#
|
#
|
||||||
ifeq ($(ARCH_ARM_HAVE_32_BYTE_CACHE_LINES),true)
|
ifeq ($(ARCH_ARM_HAVE_32_BYTE_CACHE_LINES),true)
|
||||||
@ -822,10 +797,10 @@ include $(BUILD_STATIC_LIBRARY)
|
|||||||
# ========================================================
|
# ========================================================
|
||||||
#
|
#
|
||||||
# This is a version of the static C library that does not
|
# This is a version of the static C library that does not
|
||||||
# include malloc. It's useful in situations when calling
|
# include malloc. It's useful in situations when the user wants
|
||||||
# the user wants to provide their own malloc implementation,
|
# to provide their own malloc implementation, or wants to
|
||||||
# or wants to explicitly disallow the use of the use of malloc,
|
# explicitly disallow the use of the use of malloc,
|
||||||
# like the dynamic loader.
|
# such as in the dynamic loader.
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
@ -79,54 +79,19 @@ enum {
|
|||||||
#define BIONIC_TLS_SLOTS 64
|
#define BIONIC_TLS_SLOTS 64
|
||||||
|
|
||||||
/* set the Thread Local Storage, must contain at least BIONIC_TLS_SLOTS pointers */
|
/* set the Thread Local Storage, must contain at least BIONIC_TLS_SLOTS pointers */
|
||||||
extern void __init_tls(void** tls, void* thread_info);
|
extern void __init_tls(void** tls, void* thread_info);
|
||||||
|
|
||||||
/* syscall only, do not call directly */
|
/* syscall only, do not call directly */
|
||||||
extern int __set_tls(void *ptr);
|
extern int __set_tls(void* ptr);
|
||||||
|
|
||||||
/* get the TLS */
|
/* get the TLS */
|
||||||
#ifdef __arm__
|
#if defined(__arm__)
|
||||||
/* The standard way to get the TLS is to call a kernel helper
|
# define __get_tls() \
|
||||||
* function (i.e. a function provided at a fixed address in a
|
|
||||||
* "magic page" mapped in all user-space address spaces ), which
|
|
||||||
* contains the most appropriate code path for the target device.
|
|
||||||
*
|
|
||||||
* However, for performance reasons, we're going to use our own
|
|
||||||
* machine code for the system's C shared library.
|
|
||||||
*
|
|
||||||
* We cannot use this optimization in the static version of the
|
|
||||||
* C library, because we don't know where the corresponding code
|
|
||||||
* is going to run.
|
|
||||||
*/
|
|
||||||
# ifdef LIBC_STATIC
|
|
||||||
|
|
||||||
/* Use the kernel helper in static C library. */
|
|
||||||
typedef volatile void* (__kernel_get_tls_t)(void);
|
|
||||||
# define __get_tls() (*(__kernel_get_tls_t *)0xffff0fe0)()
|
|
||||||
|
|
||||||
# else /* !LIBC_STATIC */
|
|
||||||
/* Use optimized code path.
|
|
||||||
* Note that HAVE_ARM_TLS_REGISTER is build-specific
|
|
||||||
* (it must match your kernel configuration)
|
|
||||||
*/
|
|
||||||
# ifdef HAVE_ARM_TLS_REGISTER
|
|
||||||
/* We can read the address directly from a coprocessor
|
|
||||||
* register, which avoids touching the data cache
|
|
||||||
* completely.
|
|
||||||
*/
|
|
||||||
# define __get_tls() \
|
|
||||||
({ register unsigned int __val asm("r0"); \
|
({ register unsigned int __val asm("r0"); \
|
||||||
asm ("mrc p15, 0, r0, c13, c0, 3" : "=r"(__val) ); \
|
asm ("mrc p15, 0, r0, c13, c0, 3" : "=r"(__val) ); \
|
||||||
(volatile void*)__val; })
|
(volatile void*)__val; })
|
||||||
# else /* !HAVE_ARM_TLS_REGISTER */
|
|
||||||
/* The kernel provides the address of the TLS at a fixed
|
|
||||||
* address of the magic page too.
|
|
||||||
*/
|
|
||||||
# define __get_tls() ( *((volatile void **) 0xffff0ff0) )
|
|
||||||
# endif
|
|
||||||
# endif /* !LIBC_STATIC */
|
|
||||||
#elif defined(__mips__)
|
#elif defined(__mips__)
|
||||||
# define __get_tls() \
|
# define __get_tls() \
|
||||||
({ register unsigned int __val asm("v1"); \
|
({ register unsigned int __val asm("v1"); \
|
||||||
asm ( \
|
asm ( \
|
||||||
" .set push\n" \
|
" .set push\n" \
|
||||||
@ -136,12 +101,17 @@ extern int __set_tls(void *ptr);
|
|||||||
: "=r"(__val) \
|
: "=r"(__val) \
|
||||||
); \
|
); \
|
||||||
(volatile void*)__val; })
|
(volatile void*)__val; })
|
||||||
|
#elif defined(__i386__)
|
||||||
|
# define __get_tls() \
|
||||||
|
({ register void* __val; \
|
||||||
|
asm ("movl %%gs:0, %0" : "=r"(__val)); \
|
||||||
|
(volatile void*) __val; })
|
||||||
#else
|
#else
|
||||||
extern void* __get_tls( void );
|
#error unsupported architecture
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* return the stack base and size, used by our malloc debugger */
|
/* return the stack base and size, used by our malloc debugger */
|
||||||
extern void* __get_stack_base(int *p_stack_size);
|
extern void* __get_stack_base(int* p_stack_size);
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
@ -23,15 +23,9 @@ LOCAL_CFLAGS += -fno-stack-protector \
|
|||||||
-fvisibility=hidden \
|
-fvisibility=hidden \
|
||||||
-Wall -Wextra -Werror
|
-Wall -Wextra -Werror
|
||||||
|
|
||||||
# We need to access Bionic private headers in the linker...
|
# We need to access Bionic private headers in the linker.
|
||||||
LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
|
LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
|
||||||
|
|
||||||
# ...one of which is <private/bionic_tls.h>, for which we
|
|
||||||
# need HAVE_ARM_TLS_REGISTER.
|
|
||||||
ifeq ($(TARGET_ARCH)-$(ARCH_ARM_HAVE_TLS_REGISTER),arm-true)
|
|
||||||
LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH),arm)
|
ifeq ($(TARGET_ARCH),arm)
|
||||||
LOCAL_CFLAGS += -DANDROID_ARM_LINKER
|
LOCAL_CFLAGS += -DANDROID_ARM_LINKER
|
||||||
endif
|
endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user