Merge branch 'dev3' into dev3-bin

This commit is contained in:
daanx 2024-12-22 22:31:26 -08:00
commit da2ab86e9f
7 changed files with 120 additions and 38 deletions

View file

@ -101,7 +101,6 @@ size_t _mi_current_thread_count(void);
bool _mi_preloading(void); // true while the C runtime is not initialized yet
void _mi_thread_done(mi_heap_t* heap);
mi_tld_t* _mi_tld(void); // current tld: `_mi_tld() == _mi_heap_get_default()->tld`
mi_subproc_t* _mi_subproc(void);
mi_subproc_t* _mi_subproc_main(void);
mi_subproc_t* _mi_subproc_from_id(mi_subproc_id_t subproc_id);
@ -148,8 +147,8 @@ void* _mi_arenas_alloc(mi_subproc_t* subproc, size_t size, bool commit,
void* _mi_arenas_alloc_aligned(mi_subproc_t* subproc, size_t size, size_t alignment, size_t align_offset, bool commit, bool allow_large, mi_arena_t* req_arena, size_t tseq, mi_memid_t* memid);
void _mi_arenas_free(void* p, size_t size, mi_memid_t memid);
bool _mi_arenas_contain(const void* p);
void _mi_arenas_collect(bool force_purge);
void _mi_arenas_unsafe_destroy_all(void);
void _mi_arenas_collect(bool force_purge, mi_tld_t* tld);
void _mi_arenas_unsafe_destroy_all(mi_tld_t* tld);
mi_page_t* _mi_arenas_page_alloc(mi_heap_t* heap, size_t block_size, size_t page_alignment);
void _mi_arenas_page_free(mi_page_t* page);

View file

@ -207,6 +207,20 @@ static inline void mi_prim_tls_slot_set(size_t slot, void* value) mi_attr_noexce
#endif
}
#elif 0 && _MSC_VER && _WIN32
// On Windows, using a fixed TLS slot has better codegen than a thread-local
// but it might clash with an application trying to use the same slot. (so we disable this by default)
#include <winternl.h>
#define MI_HAS_TLS_SLOT
#define MI_TLS_SLOT 63 // last available slot
static inline void* mi_prim_tls_slot(size_t slot) mi_attr_noexcept {
return NtCurrentTeb()->TlsSlots[slot];
}
static inline void mi_prim_tls_slot_set(size_t slot, void* value) mi_attr_noexcept {
NtCurrentTeb()->TlsSlots[slot] = value;
}
#endif
// Do we have __builtin_thread_pointer? This would be the preferred way to get a unique thread id