Skip to content

Commit

Permalink
update rpmalloc.c
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechsTech committed Jun 23, 2024
1 parent cbe0788 commit 4e40d7e
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions deps/rpmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,31 +854,29 @@ static inline uintptr_t
get_thread_id(void) {
#if defined(_WIN32)
return (uintptr_t)((void*)NtCurrentTeb());
#elif (defined(__GNUC__) || defined(__clang__)) && !defined(__CYGWIN__)
uintptr_t tid;
#else
uintptr_t tid;
# if defined(__i386__)
__asm__("movl %%gs:0, %0" : "=r" (tid) : : );
__asm__("movl %%gs:0, %0" : "=r" (tid) : : );
# elif defined(__x86_64__)
# if defined(__MACH__)
__asm__("movq %%gs:0, %0" : "=r" (tid) : : );
__asm__("movq %%gs:0, %0" : "=r" (tid) : : );
# else
__asm__("movq %%fs:0, %0" : "=r" (tid) : : );
__asm__("movq %%fs:0, %0" : "=r" (tid) : : );
# endif
# elif defined(__arm__)
__asm__ volatile ("mrc p15, 0, %0, c13, c0, 3" : "=r" (tid));
__asm__ volatile ("mrc p15, 0, %0, c13, c0, 3" : "=r" (tid));
# elif defined(__aarch64__)
# if defined(__MACH__)
// tpidr_el0 likely unused, always return 0 on iOS
__asm__ volatile ("mrs %0, tpidrro_el0" : "=r" (tid));
// tpidr_el0 likely unused, always return 0 on iOS
__asm__ volatile ("mrs %0, tpidrro_el0" : "=r" (tid));
# else
__asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tid));
__asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tid));
# endif
# else
# error This platform needs implementation of get_thread_id()
tid = (uintptr_t)pthread_self();
# endif
return tid;
#else
# error This platform needs implementation of get_thread_id()
#endif
}

Expand Down

0 comments on commit 4e40d7e

Please sign in to comment.