move mi_thread_id to primitives

This commit is contained in:
Daan Leijen 2023-03-14 19:38:45 -07:00
parent 4348a05d0f
commit 3579d3b861
4 changed files with 119 additions and 106 deletions

View file

@ -11,10 +11,10 @@ terms of the MIT license. A copy of the license can be found in the file
#include "mimalloc.h"
#include "mimalloc-internal.h"
#include "mimalloc-atomic.h"
#include "prim/prim.h" // _mi_prim_thread_id()
#include <string.h> // memset, strlen
#include <stdlib.h> // malloc, exit
#include <string.h> // memset, strlen (for mi_strdup)
#include <stdlib.h> // malloc, abort
#define MI_IN_ALLOC_C
#include "alloc-override.c"
@ -536,7 +536,7 @@ void mi_free(void* p) mi_attr_noexcept
{
if mi_unlikely(p == NULL) return;
mi_segment_t* const segment = mi_checked_ptr_segment(p,"mi_free");
const bool is_local= (_mi_thread_id() == mi_atomic_load_relaxed(&segment->thread_id));
const bool is_local= (_mi_prim_thread_id() == mi_atomic_load_relaxed(&segment->thread_id));
mi_page_t* const page = _mi_segment_page_of(segment, p);
if mi_likely(is_local) { // thread-local free?