Index: EcnlProtoTool/trunk/musl-1.1.18/src/thread/arm/__aeabi_read_tp.S
===================================================================
--- EcnlProtoTool/trunk/musl-1.1.18/src/thread/arm/__aeabi_read_tp.S	(revision 444)
+++ EcnlProtoTool/trunk/musl-1.1.18/src/thread/arm/__aeabi_read_tp.S	(revision 444)
@@ -0,0 +1,8 @@
+.syntax unified
+.global __aeabi_read_tp
+.type __aeabi_read_tp,%function
+__aeabi_read_tp:
+	push {r1,r2,r3,lr}
+	bl __aeabi_read_tp_c
+	pop {r1,r2,r3,lr}
+	bx lr
Index: EcnlProtoTool/trunk/musl-1.1.18/src/thread/arm/__aeabi_read_tp_c.c
===================================================================
--- EcnlProtoTool/trunk/musl-1.1.18/src/thread/arm/__aeabi_read_tp_c.c	(revision 444)
+++ EcnlProtoTool/trunk/musl-1.1.18/src/thread/arm/__aeabi_read_tp_c.c	(revision 444)
@@ -0,0 +1,8 @@
+#include "pthread_impl.h"
+#include <stdint.h>
+
+__attribute__((__visibility__("hidden")))
+void *__aeabi_read_tp_c(void)
+{
+	return (void *)((uintptr_t)__pthread_self()-8+sizeof(struct pthread));
+}
Index: EcnlProtoTool/trunk/musl-1.1.18/src/thread/arm/__set_thread_area.c
===================================================================
--- EcnlProtoTool/trunk/musl-1.1.18/src/thread/arm/__set_thread_area.c	(revision 444)
+++ EcnlProtoTool/trunk/musl-1.1.18/src/thread/arm/__set_thread_area.c	(revision 444)
@@ -0,0 +1,53 @@
+#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_oldkuser[], __a_barrier_v6[], __a_barrier_v7[],
+	__a_cas_v6[], __a_cas_v7[],
+	__a_gettp_cp15[];
+
+#define __a_barrier_kuser 0xffff0fa0
+#define __a_barrier_oldkuser (uintptr_t)__a_barrier_oldkuser
+#define __a_barrier_v6 (uintptr_t)__a_barrier_v6
+#define __a_barrier_v7 (uintptr_t)__a_barrier_v7
+
+#define __a_cas_kuser 0xffff0fc0
+#define __a_cas_v6 (uintptr_t)__a_cas_v6
+#define __a_cas_v7 (uintptr_t)__a_cas_v7
+
+#define __a_gettp_kuser 0xffff0fe0
+#define __a_gettp_cp15 (uintptr_t)__a_gettp_cp15
+
+extern uintptr_t __attribute__((__visibility__("hidden")))
+	__a_barrier_ptr, __a_cas_ptr, __a_gettp_ptr;
+
+int __set_thread_area(void *p)
+{
+#if !__ARM_ARCH_7A__ && !__ARM_ARCH_7R__ && __ARM_ARCH < 7
+	if (__hwcap & HWCAP_TLS) {
+		size_t *aux;
+		__a_cas_ptr = __a_cas_v7;
+		__a_barrier_ptr = __a_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;
+			__a_cas_ptr = __a_cas_v6;
+			__a_barrier_ptr = __a_barrier_v6;
+			break;
+		}
+	} else {
+		int ver = *(int *)0xffff0ffc;
+		__a_gettp_ptr = __a_gettp_kuser;
+		__a_cas_ptr = __a_cas_kuser;
+		__a_barrier_ptr = __a_barrier_kuser;
+		if (ver < 2) a_crash();
+		if (ver < 3) __a_barrier_ptr = __a_barrier_oldkuser;
+	}
+#endif
+	return __syscall(0xf0005, p);
+}
Index: EcnlProtoTool/trunk/musl-1.1.18/src/thread/arm/atomics.S
===================================================================
--- EcnlProtoTool/trunk/musl-1.1.18/src/thread/arm/atomics.S	(revision 444)
+++ EcnlProtoTool/trunk/musl-1.1.18/src/thread/arm/atomics.S	(revision 444)
@@ -0,0 +1,106 @@
+.syntax unified
+.text
+
+.global __a_barrier_dummy
+.hidden __a_barrier_dummy
+.type __a_barrier_dummy,%function
+__a_barrier_dummy:
+	bx lr
+
+.global __a_barrier_oldkuser
+.hidden __a_barrier_oldkuser
+.type __a_barrier_oldkuser,%function
+__a_barrier_oldkuser:
+	push {r0,r1,r2,r3,ip,lr}
+	mov r1,r0
+	mov r2,sp
+	ldr ip,=0xffff0fc0
+	mov lr,pc
+	mov pc,ip
+	pop {r0,r1,r2,r3,ip,lr}
+	bx lr
+
+.global __a_barrier_v6
+.hidden __a_barrier_v6
+.type __a_barrier_v6,%function
+__a_barrier_v6:
+	.arch armv6t2
+	mcr p15,0,r0,c7,c10,5
+	bx lr
+
+.global __a_barrier_v7
+.hidden __a_barrier_v7
+.type __a_barrier_v7,%function
+__a_barrier_v7:
+	.arch armv7-a
+	dmb ish
+	bx lr
+
+.global __a_cas_dummy
+.hidden __a_cas_dummy
+.type __a_cas_dummy,%function
+__a_cas_dummy:
+	mov r3,r0
+	ldr r0,[r2]
+	subs r0,r3,r0
+	streq r1,[r2]
+	bx lr
+
+.global __a_cas_v6
+.hidden __a_cas_v6
+.type __a_cas_v6,%function
+__a_cas_v6:
+	.arch armv6t2
+	mov r3,r0
+	mcr p15,0,r0,c7,c10,5
+1:	ldrex r0,[r2]
+	subs r0,r3,r0
+	strexeq r0,r1,[r2]
+	teqeq r0,#1
+	beq 1b
+	mcr p15,0,r0,c7,c10,5
+	bx lr
+
+.global __a_cas_v7
+.hidden __a_cas_v7
+.type __a_cas_v7,%function
+__a_cas_v7:
+	.arch armv7-a
+	mov r3,r0
+	dmb ish
+1:	ldrex r0,[r2]
+	subs r0,r3,r0
+	strexeq r0,r1,[r2]
+	teqeq r0,#1
+	beq 1b
+	dmb ish
+	bx lr
+
+.global __a_gettp_cp15
+.hidden __a_gettp_cp15
+.type __a_gettp_cp15,%function
+__a_gettp_cp15:
+	mrc p15,0,r0,c13,c0,3
+	bx lr
+
+/* Tag this file with minimum ISA level so as not to affect linking. */
+.object_arch armv4t
+.eabi_attribute 6,2
+
+.data
+.align 2
+
+.global __a_barrier_ptr
+.hidden __a_barrier_ptr
+__a_barrier_ptr:
+	.word __a_barrier_dummy
+
+.global __a_cas_ptr
+.hidden __a_cas_ptr
+__a_cas_ptr:
+	.word __a_cas_dummy
+
+.global __a_gettp_ptr
+.hidden __a_gettp_ptr
+__a_gettp_ptr:
+	.word __a_gettp_cp15
