MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / mi_tls_slot_set

Function mi_tls_slot_set

3rd/mimalloc-2.0.9/include/mimalloc-internal.h:891–914  ·  view source on GitHub ↗

setting a tls slot is only used on macOS for now

Source from the content-addressed store, hash-verified

889
890// setting a tls slot is only used on macOS for now
891static inline void mi_tls_slot_set(size_t slot, void* value) mi_attr_noexcept {
892 const size_t ofs = (slot*sizeof(void*));
893 #if defined(__i386__)
894 __asm__("movl %1,%%gs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // 32-bit always uses GS
895 #elif defined(__APPLE__) && defined(__x86_64__)
896 __asm__("movq %1,%%gs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x86_64 macOS uses GS
897 #elif defined(__x86_64__) && (MI_INTPTR_SIZE==4)
898 __asm__("movl %1,%%fs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x32 ABI
899 #elif defined(__x86_64__)
900 __asm__("movq %1,%%fs:%0" : "=m" (*((void**)ofs)) : "rn" (value) : ); // x86_64 Linux, BSD uses FS
901 #elif defined(__arm__)
902 void** tcb; MI_UNUSED(ofs);
903 __asm__ volatile ("mrc p15, 0, %0, c13, c0, 3\nbic %0, %0, #3" : "=r" (tcb));
904 tcb[slot] = value;
905 #elif defined(__aarch64__)
906 void** tcb; MI_UNUSED(ofs);
907 #if defined(__APPLE__) // M1, issue #343
908 __asm__ volatile ("mrs %0, tpidrro_el0\nbic %0, %0, #7" : "=r" (tcb));
909 #else
910 __asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tcb));
911 #endif
912 tcb[slot] = value;
913 #endif
914}
915
916static inline mi_threadid_t _mi_thread_id(void) mi_attr_noexcept {
917 #if defined(__BIONIC__)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected