diff options
author | Daan Leijen <daan@microsoft.com> | 2021-12-18 11:11:54 -0800 |
---|---|---|
committer | Daan Leijen <daan@microsoft.com> | 2021-12-18 11:11:54 -0800 |
commit | 78e2e580f800b08a3dbb6d2eb383a55269a0f862 (patch) | |
tree | 05691b74cf6f938d5bb93c38d7de2c2a30092cb6 /include | |
parent | 3d35147aba3463405b09821e66abfc0a1992b4c0 (diff) | |
parent | 89090510bd965ca48a83857eaa6b6e78a951bf7e (diff) |
Merge branch 'dev' into dev-slice
Diffstat (limited to 'include')
-rw-r--r-- | include/mimalloc-internal.h | 16 | ||||
-rw-r--r-- | include/mimalloc-types.h | 2 | ||||
-rw-r--r-- | include/mimalloc.h | 2 |
3 files changed, 10 insertions, 10 deletions
diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h index 8fa8caf..86927a7 100644 --- a/include/mimalloc-internal.h +++ b/include/mimalloc-internal.h @@ -796,21 +796,21 @@ static inline mi_threadid_t _mi_thread_id(void) mi_attr_noexcept { } #elif defined(__GNUC__) && \ - (defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__)) + (defined(__x86_64__) || defined(__i386__) || defined(__aarch64__)) -// TLS register on x86 is in the FS or GS register, see: https://akkadia.org/drepper/tls.pdf +// see also https://akkadia.org/drepper/tls.pdf for more info on the TLS register. static inline void* mi_tls_slot(size_t slot) mi_attr_noexcept { void* res; const size_t ofs = (slot*sizeof(void*)); #if defined(__i386__) - __asm__("movl %%gs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // 32-bit always uses GS + __asm__("movl %%gs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86 32-bit always uses GS #elif defined(__APPLE__) && defined(__x86_64__) __asm__("movq %%gs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86_64 macOSX uses GS #elif defined(__x86_64__) && (MI_INTPTR_SIZE==4) __asm__("movl %%fs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x32 ABI #elif defined(__x86_64__) __asm__("movq %%fs:%1, %0" : "=r" (res) : "m" (*((void**)ofs)) : ); // x86_64 Linux, BSD uses FS -#elif defined(__arm__) +#elif defined(__arm__) // arm32: defined but currently not used (see issue #495) void** tcb; MI_UNUSED(ofs); __asm__ volatile ("mrc p15, 0, %0, c13, c0, 3\nbic %0, %0, #3" : "=r" (tcb)); res = tcb[slot]; @@ -827,7 +827,7 @@ static inline void* mi_tls_slot(size_t slot) mi_attr_noexcept { return res; } -// setting is only used on macOSX for now +// setting a tls slot is only used on macOSX for now static inline void mi_tls_slot_set(size_t slot, void* value) mi_attr_noexcept { const size_t ofs = (slot*sizeof(void*)); #if defined(__i386__) @@ -855,8 +855,8 @@ static inline void mi_tls_slot_set(size_t slot, void* value) mi_attr_noexcept { } static inline mi_threadid_t _mi_thread_id(void) mi_attr_noexcept { -#if defined(__arm__) || (defined(__ANDROID__) && defined(__aarch64__)) - // issue #384, #495: on arm32 and arm32/arm64 Android, slot 1 is the thread ID (pointer to pthread internal struct) +#if defined(__ANDROID__) && (defined(__arm__) || defined(__aarch64__)) + // issue #384, #495: on arm Android, slot 1 is the thread ID (pointer to pthread internal struct) return (uintptr_t)mi_tls_slot(1); #else // in all our other targets, slot 0 is the pointer to the thread control block @@ -864,7 +864,7 @@ static inline mi_threadid_t _mi_thread_id(void) mi_attr_noexcept { #endif } #else -// otherwise use standard C +// otherwise use portable C static inline mi_threadid_t _mi_thread_id(void) mi_attr_noexcept { return (uintptr_t)&_mi_heap_default; } diff --git a/include/mimalloc-types.h b/include/mimalloc-types.h index fbfee9c..9f97f8f 100644 --- a/include/mimalloc-types.h +++ b/include/mimalloc-types.h @@ -164,7 +164,7 @@ typedef int32_t mi_ssize_t; #if (MI_MEDIUM_OBJ_WSIZE_MAX >= 655360) #error "mimalloc internal: define more bins" #endif -#if (MI_ALIGNED_MAX > MI_SEGMENT_SIZE/2) +#if (MI_ALIGNMENT_MAX > MI_SEGMENT_SIZE/2) #error "mimalloc internal: the max aligned boundary is too large for the segment size" #endif #if (MI_ALIGNED_MAX % MI_SEGMENT_SLICE_SIZE != 0) diff --git a/include/mimalloc.h b/include/mimalloc.h index 26a8ac0..0533e73 100644 --- a/include/mimalloc.h +++ b/include/mimalloc.h @@ -166,7 +166,7 @@ mi_decl_export void mi_process_info(size_t* elapsed_msecs, size_t* user_msecs, s // Note that `alignment` always follows `size` for consistency with unaligned // allocation, but unfortunately this differs from `posix_memalign` and `aligned_alloc`. // ------------------------------------------------------------------------------------- -#define MI_ALIGNED_MAX (1024*1024UL) // maximum supported alignment is 1MiB +#define MI_ALIGNMENT_MAX (1024*1024UL) // maximum supported alignment is 1MiB mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_malloc_aligned(size_t size, size_t alignment) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1) mi_attr_alloc_align(2); mi_decl_nodiscard mi_decl_export mi_decl_restrict void* mi_malloc_aligned_at(size_t size, size_t alignment, size_t offset) mi_attr_noexcept mi_attr_malloc mi_attr_alloc_size(1); |