Fixes in allocator
This commit is contained in:
committed by
LepilkinaElena
parent
65fca81bef
commit
08e05bb10b
@@ -214,9 +214,22 @@ static inline void mi_atomic_write(volatile _Atomic(uintptr_t)* p, uintptr_t x)
|
||||
asm volatile ("pause" ::: "memory");
|
||||
}
|
||||
#elif defined(__arm__) || defined(__aarch64__)
|
||||
#if defined(KONAN_MI_MALLOC)
|
||||
#if defined(__arm__)
|
||||
#include <sched.h>
|
||||
static inline void mi_atomic_yield(void) {
|
||||
sched_yield();
|
||||
}
|
||||
#else
|
||||
static inline void mi_atomic_yield(void) {
|
||||
asm volatile("yield");
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
static inline void mi_atomic_yield(void) {
|
||||
asm volatile("yield");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(__wasi__)
|
||||
#include <sched.h>
|
||||
|
||||
@@ -457,6 +457,10 @@ static inline uintptr_t _mi_thread_id(void) mi_attr_noexcept {
|
||||
}
|
||||
#elif (defined(__GNUC__) || defined(__clang__)) && \
|
||||
(defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__))
|
||||
#if defined(KONAN_MI_MALLOC)
|
||||
#include <pthread.h>
|
||||
pthread_t pthread_self(void);
|
||||
#endif
|
||||
// TLS register on x86 is in the FS or GS register
|
||||
// see: https://akkadia.org/drepper/tls.pdf
|
||||
static inline uintptr_t _mi_thread_id(void) mi_attr_noexcept {
|
||||
@@ -464,7 +468,16 @@ static inline uintptr_t _mi_thread_id(void) mi_attr_noexcept {
|
||||
#if defined(__i386__)
|
||||
__asm__("movl %%gs:0, %0" : "=r" (tid) : : ); // 32-bit always uses GS
|
||||
#elif defined(__MACH__)
|
||||
__asm__("movq %%gs:0, %0" : "=r" (tid) : : ); // x86_64 macOS uses GS
|
||||
#if defined(KONAN_MI_MALLOC)
|
||||
#include <TargetConditionals.h>
|
||||
#if TARGET_OS_EMBEDDED // iOS/tvOS/watchOS devices.
|
||||
tid = pthread_self();
|
||||
#else
|
||||
__asm__("movq %%gs:0, %0" : "=r" (tid) : : ); // x86_64 macOS uses GS
|
||||
#endif
|
||||
#else
|
||||
__asm__("movq %%gs:0, %0" : "=r" (tid) : : ); // x86_64 macOS uses GS
|
||||
#endif
|
||||
#elif defined(__x86_64__)
|
||||
__asm__("movq %%fs:0, %0" : "=r" (tid) : : ); // x86_64 Linux, BSD uses FS
|
||||
#elif defined(__arm__)
|
||||
|
||||
@@ -17,7 +17,9 @@ terms of the MIT license. A copy of the license can be found in the file
|
||||
// ------------------------------------------------------
|
||||
|
||||
// Define NDEBUG in the release version to disable assertions.
|
||||
// #define NDEBUG
|
||||
#if !defined(KONAN_MI_MALLOC)
|
||||
#define NDEBUG
|
||||
#endif
|
||||
|
||||
// Define MI_STAT as 1 to maintain statistics; set it to 2 to have detailed statistics (but costs some performance).
|
||||
// #define MI_STAT 1
|
||||
|
||||
Reference in New Issue
Block a user