+#if defined(__i386__) || defined(__x86_64__) || defined(__arm__)
+/* To be used with static constant keys only */
+inline static int
+_pthread_setspecific_direct(unsigned long slot, void * val)
+{
+
+#if defined(__i386__)
+#if defined(__PIC__)
+ asm("movl %1,%%gs:%0" : "=m" (*(void **)(slot * sizeof(void *))) : "rn" (val));
+#else
+ asm("movl %1,%%gs:%0" : "=m" (*(void **)(slot * sizeof(void *))) : "ri" (val));
+#endif
+#elif defined(__x86_64__)
+ /* PIC is free and cannot be disabled, even with: gcc -mdynamic-no-pic ... */
+ asm("movq %1,%%gs:%0" : "=m" (*(void **)(slot * sizeof(void *))) : "rn" (val));
+#elif defined(__arm__) && defined(_ARM_ARCH_6)
+ void **__pthread_tsd;
+ __asm__ (
+ "mrc p15, 0, %0, c13, c0, 3\n"
+ "bic %0, %0, #3\n"
+ : "=r"(__pthread_tsd));
+ __pthread_tsd[slot] = val;
+#elif defined(__arm__) && !defined(_ARM_ARCH_6)
+ register void **__pthread_tsd asm ("r9");
+ __pthread_tsd[slot] = val;
+#endif
+ return(0);
+}
+#elif defined(__ppc__) || defined(__ppc64__)