-#if defined(__arm__) || defined(__arm64__)
- uintptr_t tpid;
-#if defined(__arm__)
- __asm__ ("mrc p15, 0, %0, c13, c0, 3\n" : "=r" (tpid));
-#elif defined(__arm64__)
- __asm__ ("mrs %0, tpidrro_el0\n" : "=r" (tpid));
-#else
-#error XXX
-#endif
-
- void **tsd;
- tsd = reinterpret_cast<void **>(tpid & ~3);
- if (tsd != NULL)
- tsd[0] = &self;
-#else
- _pthread_setspecific_direct(0, &self);
-#endif
-