File dietlibc-0.31-tls.diff of Package dietlibc
--- include/sys/tls.h
+++ include/sys/tls.h
@@ -24,8 +24,13 @@ typedef struct
void *self; /* Pointer to the thread descriptor. */
int multiple_threads;
uintptr_t sysinfo;
+#ifdef __ia64__
+ uintptr_t pointer_guard;
+ uintptr_t stack_guard;
+#else
uintptr_t stack_guard;
uintptr_t pointer_guard;
+#endif
} tcbhead_t;
#if defined(__i386__)
--- lib/stackgap.c
+++ lib/stackgap.c
@@ -14,6 +14,14 @@ extern unsigned long __guard;
#if defined(WANT_SSP) || defined(WANT_THREAD_SAFE)
static tcbhead_t mainthread;
+#if defined __ia64__ || defined __powerpc64__
+register tcbhead_t* __thread_self __asm__("r13");
+#elif defined __powerpc__
+register tcbhead_t* __thread_self __asm__("r2");
+#elif defined __sparc__
+register tcbhead_t* __thread_self __asm("%g7");
+#endif
+
static void setup_tls(void) {
mainthread.tcb=&mainthread;
mainthread.self=&mainthread;
@@ -38,11 +46,11 @@ static void setup_tls(void) {
#elif defined(__alpha__) || defined(__s390__)
__builtin_set_thread_pointer(&mainthread);
-#elif defined(__ia64__) || defined(__powerpc__)
- register tcbhead_t* __thread_self __asm__("r13");
- __thread_self=&mainthread;
+#elif defined(__ia64__)
+ __thread_self = &mainthread + 1;
+#elif defined(__powerpc__)
+ __thread_self = (tcbhead_t *)((char *)(&mainthread + 1) + 0x7000);
#elif defined(__sparc__)
- register tcbhead_t* __thread_self __asm("%g7");
__thread_self=&mainthread;
#else
#warning "no idea how to enable TLS on this platform, edit lib/stackgap.c"