mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-08 00:09:31 +03:00
document way to use a TLS slot on windows
This commit is contained in:
parent
dd1b37c9f8
commit
04970f43e5
1 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue