diff options
author | Rich Felker <dalias@aerifal.cx> | 2016-01-22 00:02:21 +0000 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2016-01-22 00:02:21 +0000 |
commit | e617b9eea9d45b170eabadf5ca96ca0536c538be (patch) | |
tree | a06d433fd4219466e4b27f248e332f9e0482dd5d /src/thread/arm/__set_thread_area.c | |
parent | 397f0a6a7d798b0e3f636fe053cad9c483e011fb (diff) | |
download | musl-e617b9eea9d45b170eabadf5ca96ca0536c538be.tar.gz musl-e617b9eea9d45b170eabadf5ca96ca0536c538be.tar.bz2 musl-e617b9eea9d45b170eabadf5ca96ca0536c538be.tar.xz musl-e617b9eea9d45b170eabadf5ca96ca0536c538be.zip |
move arm-specific translation units out of arch/arm/src, to src/*/arm
this is possible with the new build system that allows src/*/$(ARCH)/*
files which do not shadow a file in the parent directory, and yields a
more logical organization. eventually it will be possible to remove
arch/*/src from the build system.
Diffstat (limited to 'src/thread/arm/__set_thread_area.c')
-rw-r--r-- | src/thread/arm/__set_thread_area.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/thread/arm/__set_thread_area.c b/src/thread/arm/__set_thread_area.c new file mode 100644 index 00000000..61d02827 --- /dev/null +++ b/src/thread/arm/__set_thread_area.c @@ -0,0 +1,49 @@ +#include <stdint.h> +#include <elf.h> +#include "pthread_impl.h" +#include "libc.h" + +#define HWCAP_TLS (1 << 15) + +extern const unsigned char __attribute__((__visibility__("hidden"))) + __a_barrier_dummy[], __a_barrier_oldkuser[], + __a_barrier_v6[], __a_barrier_v7[], + __a_cas_dummy[], __a_cas_v6[], __a_cas_v7[], + __a_gettp_dummy[]; + +#define __a_barrier_kuser 0xffff0fa0 +#define __a_cas_kuser 0xffff0fc0 +#define __a_gettp_kuser 0xffff0fe0 + +extern uintptr_t __attribute__((__visibility__("hidden"))) + __a_barrier_ptr, __a_cas_ptr, __a_gettp_ptr; + +#define SET(op,ver) (__a_##op##_ptr = \ + (uintptr_t)__a_##op##_##ver - (uintptr_t)__a_##op##_dummy) + +int __set_thread_area(void *p) +{ +#if !__ARM_ARCH_7A__ && !__ARM_ARCH_7R__ && __ARM_ARCH < 7 + if (__hwcap & HWCAP_TLS) { + size_t *aux; + SET(cas, v7); + SET(barrier, v7); + for (aux=libc.auxv; *aux; aux+=2) { + if (*aux != AT_PLATFORM) continue; + const char *s = (void *)aux[1]; + if (s[0]!='v' || s[1]!='6' || s[2]-'0'<10u) break; + SET(cas, v6); + SET(barrier, v6); + break; + } + } else { + int ver = *(int *)0xffff0ffc; + SET(gettp, kuser); + SET(cas, kuser); + SET(barrier, kuser); + if (ver < 2) a_crash(); + if (ver < 3) SET(barrier, oldkuser); + } +#endif + return __syscall(0xf0005, p); +} |