svn commit: branches/uClibc-nptl/test: dlopen tls

kraj at uclibc.org kraj at uclibc.org
Sat Jul 12 00:10:29 UTC 2008


Author: kraj
Date: 2008-07-11 17:10:28 -0700 (Fri, 11 Jul 2008)
New Revision: 22810

Log:
Signed-off-by: Khem Raj <raj.khem at gmail.com>
Add NTPL testing support for ARM.


Added:
   branches/uClibc-nptl/test/tls/tls-macros-arm.h
   branches/uClibc-nptl/test/tls/tls-macros-thumb.h

Modified:
   branches/uClibc-nptl/test/dlopen/libtest.c
   branches/uClibc-nptl/test/tls/tls-macros.h


Changeset:
Modified: branches/uClibc-nptl/test/dlopen/libtest.c
===================================================================
--- branches/uClibc-nptl/test/dlopen/libtest.c	2008-07-11 23:44:50 UTC (rev 22809)
+++ branches/uClibc-nptl/test/dlopen/libtest.c	2008-07-12 00:10:28 UTC (rev 22810)
@@ -2,8 +2,6 @@
 #include <pthread.h>
 #include <stdint.h>
 
-extern int __pthread_once(void);
-
 void dltest(uint32_t **value1, uint32_t **value2);
 void dltest(uint32_t **value1, uint32_t **value2)
 {

Added: branches/uClibc-nptl/test/tls/tls-macros-arm.h
===================================================================
--- branches/uClibc-nptl/test/tls/tls-macros-arm.h	                        (rev 0)
+++ branches/uClibc-nptl/test/tls/tls-macros-arm.h	2008-07-12 00:10:28 UTC (rev 22810)
@@ -0,0 +1,51 @@
+#define TLS_LE(x)					\
+  ({ int *__result;					\
+     void *tp = __builtin_thread_pointer ();		\
+     asm ("ldr %0, 1f; "				\
+	  "add %0, %1, %0; "				\
+	  "b 2f; "					\
+	  "1: .word " #x "(tpoff); "			\
+	  "2: "						\
+	  : "=&r" (__result) : "r" (tp));		\
+     __result; })
+
+#define TLS_IE(x)					\
+  ({ int *__result;					\
+     void *tp = __builtin_thread_pointer ();		\
+     asm ("ldr %0, 1f; "				\
+	  "3: ldr %0, [pc, %0];"			\
+	  "add %0, %1, %0; "				\
+	  "b 2f; "					\
+	  "1: .word " #x "(gottpoff) + (. - 3b - 8); "	\
+	  "2: "						\
+	  : "=&r" (__result) : "r" (tp));		\
+     __result; })
+
+#define TLS_LD(x)					\
+  ({ char *__result;					\
+     int __offset;					\
+     extern void *__tls_get_addr (void *);		\
+     asm ("ldr %0, 2f; "				\
+	  "1: add %0, pc, %0; "				\
+	  "b 3f; "					\
+	  "2: .word " #x "(tlsldm) + (. - 1b - 8); "	\
+	  "3: "						\
+	  : "=r" (__result));				\
+     __result = (char *)__tls_get_addr (__result);	\
+     asm ("ldr %0, 1f; "				\
+	  "b 2f; "					\
+	  "1: .word " #x "(tlsldo); "			\
+	  "2: "						\
+	  : "=r" (__offset));				\
+     (int *) (__result + __offset); })
+
+#define TLS_GD(x)					\
+  ({ int *__result;					\
+     extern void *__tls_get_addr (void *);		\
+     asm ("ldr %0, 2f; "				\
+	  "1: add %0, pc, %0; "				\
+	  "b 3f; "					\
+	  "2: .word " #x "(tlsgd) + (. - 1b - 8); "	\
+	  "3: "						\
+	  : "=r" (__result));				\
+     (int *)__tls_get_addr (__result); })

Added: branches/uClibc-nptl/test/tls/tls-macros-thumb.h
===================================================================
--- branches/uClibc-nptl/test/tls/tls-macros-thumb.h	                        (rev 0)
+++ branches/uClibc-nptl/test/tls/tls-macros-thumb.h	2008-07-12 00:10:28 UTC (rev 22810)
@@ -0,0 +1,57 @@
+#define TLS_LE(x)					\
+  ({ int *__result;					\
+     void *tp = __builtin_thread_pointer ();		\
+     asm ("ldr %0, 1f; "				\
+	  "add %0, %1, %0; "				\
+	  "b 2f; "					\
+	  ".align 2; "					\
+	  "1: .word " #x "(tpoff); "			\
+	  "2: "						\
+	  : "=&r" (__result) : "r" (tp));		\
+     __result; })
+
+#define TLS_IE(x)					\
+  ({ int *__result;					\
+     int tmp;						\
+     void *tp = __builtin_thread_pointer ();		\
+     asm ("ldr %0, 1f; "				\
+	  "adr %1, 1f; "				\
+	  "ldr %0, [%1, %0]; "				\
+	  "add %0, %2, %0; "				\
+	  "b 2f; "					\
+	  ".align 2; "					\
+	  "1: .word " #x "(gottpoff); "			\
+	  "2: "						\
+	  : "=&r" (__result), "=&r"(tmp) : "r" (tp));	\
+     __result; })
+
+#define TLS_LD(x)					\
+  ({ char *__result;					\
+     int __offset;					\
+     extern void *__tls_get_addr (void *);		\
+     asm ("ldr %0, 2f; "				\
+	  ".align 2; "					\
+	  "1: add %0, pc, %0; "				\
+	  "b 3f; "					\
+	  "2: .word " #x "(tlsldm) + (. - 1b - 4); "	\
+	  "3: "						\
+	  : "=r" (__result));				\
+     __result = (char *)__tls_get_addr (__result);	\
+     asm ("ldr %0, 1f; "				\
+	  "b 2f; "					\
+	  "1: .word " #x "(tlsldo); "			\
+	  "2: "						\
+	  : "=r" (__offset));				\
+     (int *) (__result + __offset); })
+
+#define TLS_GD(x)					\
+  ({ int *__result;					\
+     extern void *__tls_get_addr (void *);		\
+     asm ("ldr %0, 2f; "				\
+	  ".align 2; "					\
+	  "1: add %0, pc, %0; "				\
+	  "b 3f; "					\
+	  "2: .word " #x "(tlsgd) + (. - 1b - 4); "	\
+	  "3: "						\
+	  : "=r" (__result));				\
+     (int *)__tls_get_addr (__result); })

Modified: branches/uClibc-nptl/test/tls/tls-macros.h
===================================================================
--- branches/uClibc-nptl/test/tls/tls-macros.h	2008-07-11 23:44:50 UTC (rev 22809)
+++ branches/uClibc-nptl/test/tls/tls-macros.h	2008-07-12 00:10:28 UTC (rev 22810)
@@ -20,6 +20,14 @@
 #include <tls-macros-mips.h>
 #endif
 
+#ifdef __arm__
+#ifdef __thumb__
+#include <tls-macros-thumb.h>
+#else
+#include <tls-macros-arm.h>
+#endif
+#endif
+
   /* XXX Each architecture must have its own asm for now.  */
 #ifdef __i386__
 # define TLS_LE(x) \




More information about the uClibc-cvs mailing list