X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=arch%2Farm%2Fpthread_arch.h;h=7ab905806edd2b42a892bf3aadeeeac8a46075a1;hb=38bf2d7cc3e5eb47d63882a64c8471699c1e7eeb;hp=43a1c012f466dcd41bc6444edfd4c265c722f7cd;hpb=9ec4283b28cf676292fd5c6f681bef1e90e30c18;p=musl diff --git a/arch/arm/pthread_arch.h b/arch/arm/pthread_arch.h index 43a1c012..7ab90580 100644 --- a/arch/arm/pthread_arch.h +++ b/arch/arm/pthread_arch.h @@ -1,7 +1,28 @@ -typedef char *(*__ptr_func_t)(void) __attribute__((const)); +#if ((__ARM_ARCH_6K__ || __ARM_ARCH_6ZK__) && !__thumb__) \ + || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7 -#define __pthread_self() \ - ((pthread_t)(((__ptr_func_t)0xffff0fe0)()+8-sizeof(struct pthread))) +static inline __attribute__((const)) pthread_t __pthread_self() +{ + char *p; + __asm__( "mrc p15,0,%0,c13,c0,3" : "=r"(p) ); + return (void *)(p+8-sizeof(struct pthread)); +} + +#else + +static inline __attribute__((const)) pthread_t __pthread_self() +{ +#ifdef __clang__ + char *p; + __asm__( "bl __a_gettp\n\tmov %0,r0" : "=r"(p) : : "cc", "r0", "lr" ); +#else + register char *p __asm__("r0"); + __asm__( "bl __a_gettp" : "=r"(p) : : "cc", "lr" ); +#endif + return (void *)(p+8-sizeof(struct pthread)); +} + +#endif #define TLS_ABOVE_TP #define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) - 8)