This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FR-V TLS macros


No need to explain this one, I think.

Index: ChangeLog
2004-11-10  Alexandre Oliva  <aoliva@redhat.com>

	* elf/tls-macros.h: Add FR-V section.

Index: elf/tls-macros.h
--- elf/tls-macros.h	2004-07-08 01:46:11.000000000 -0300
+++ elf/tls-macros.h	2005-01-31 04:07:09.000000000 -0200
@@ -731,6 +731,61 @@
       __result;  \
   })
 
+#elif defined __FRV_FDPIC__
+
+/* gr15 isn't a fixed register.  We could code an asm function that
+   copied the incoming gr15 to gr8 and be done with it, instead of
+   loading it from the function's own function descriptor, but this is
+   so easy to code in C that it will do.  */
+static long __get_gr15(void) {
+  static struct funcdesc {
+    long ip, gp;
+  } const *fd = (const struct funcdesc *)__get_gr15;
+  return fd->gp;
+}
+
+/* FR-V Local Executable TLS access.  */
+#  define TLS_LE(x) \
+  ({  char * __result;  \
+      register long __tp asm ("gr29"); \
+      asm ("sethi.p #tlsmoffhi(" #x "), %0\n\t" \
+	   "setlo #tlsmofflo(" #x "), %0" : "=r" (__result)); \
+      (int *)(__result + __tp); \
+   })
+
+/* FR-V Initial Executable TLS access.  */
+#  define TLS_IE(x) \
+  ({  char * __result;  \
+      register long __tp asm ("gr29"); \
+      register long __pic asm ("gr15") = __get_gr15(); \
+      asm ("ldi @(%1, #gottlsoff12(" #x ")), %0" : "=r" (__result) \
+	   : "r" (__pic)); \
+      (int *)(__result + __tp); \
+   })
+
+/* FR-V Local Dynamic TLS access.  */
+#  define TLS_LD(x) \
+  ({  char * __result;  \
+      register long __tp asm ("gr29"); \
+      register long __pic asm ("gr15") = __get_gr15(); \
+      long __modbase;  \
+      asm ("call #gettlsoff(0)" : "=D09" (__modbase)) \
+	   : "r" (__pic) : "gr8"); \
+      asm ("sethi.p #tlsmoffhi(" #x "), %0\n\t" \
+	   "setlo #tlsmofflo(" #x "), %0" : "=r" (__result)); \
+      (int *)(__result + __modbase + __tp); \
+   })
+
+/* FR-V General Dynamic TLS access.  */
+#  define TLS_GD(x) \
+  ({  char * __result;  \
+      register long __tp asm ("gr29"); \
+      register long __pic asm ("gr15") = __get_gr15(); \
+      asm ("call #gettlsoff(" #x ")" : "=D09" (__result) \
+	   : "r" (__pic) : "gr8"); \
+      (int *)(__result + __tp); \
+  })
+    
 #else
 # error "No support for this architecture so far."
 #endif
-- 
Alexandre Oliva             http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]