mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-06 15:29:31 +03:00
Merge branch 'dev' into dev-slice
This commit is contained in:
commit
8f69e7095d
10 changed files with 16 additions and 21 deletions
|
@ -190,14 +190,6 @@ if (MSVC AND MSVC_VERSION GREATER_EQUAL 1914)
|
||||||
list(APPEND mi_cflags /Zc:__cplusplus)
|
list(APPEND mi_cflags /Zc:__cplusplus)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Architecture flags
|
|
||||||
if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm" AND NOT APPLE)
|
|
||||||
check_cxx_compiler_flag(-march=native CXX_SUPPORTS_MARCH_NATIVE)
|
|
||||||
if (CXX_SUPPORTS_MARCH_NATIVE)
|
|
||||||
list(APPEND mi_cflags -march=native)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# extra needed libraries
|
# extra needed libraries
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND mi_libraries psapi shell32 user32 advapi32 bcrypt)
|
list(APPEND mi_libraries psapi shell32 user32 advapi32 bcrypt)
|
||||||
|
|
|
@ -118,7 +118,7 @@ static inline void mi_atomic_maxi64_relaxed(volatile int64_t* p, int64_t x) {
|
||||||
|
|
||||||
// MSVC C compilation wrapper that uses Interlocked operations to model C11 atomics.
|
// MSVC C compilation wrapper that uses Interlocked operations to model C11 atomics.
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <Windows.h>
|
#include <windows.h>
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
typedef LONG64 msc_intptr_t;
|
typedef LONG64 msc_intptr_t;
|
||||||
|
|
|
@ -726,7 +726,7 @@ mi_decl_restrict char* mi_strndup(const char* s, size_t n) mi_attr_noexcept {
|
||||||
#ifndef PATH_MAX
|
#ifndef PATH_MAX
|
||||||
#define PATH_MAX MAX_PATH
|
#define PATH_MAX MAX_PATH
|
||||||
#endif
|
#endif
|
||||||
#include <Windows.h>
|
#include <windows.h>
|
||||||
mi_decl_restrict char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name) mi_attr_noexcept {
|
mi_decl_restrict char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name) mi_attr_noexcept {
|
||||||
// todo: use GetFullPathNameW to allow longer file names
|
// todo: use GetFullPathNameW to allow longer file names
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
|
|
|
@ -211,7 +211,10 @@ void* _mi_arena_alloc_aligned(size_t size, size_t alignment, bool* commit, bool*
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally, fall back to the OS
|
// finally, fall back to the OS
|
||||||
if (mi_option_is_enabled(mi_option_limit_os_alloc)) return NULL;
|
if (mi_option_is_enabled(mi_option_limit_os_alloc)) {
|
||||||
|
errno = ENOMEM;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
*is_zero = true;
|
*is_zero = true;
|
||||||
*memid = MI_MEMID_OS;
|
*memid = MI_MEMID_OS;
|
||||||
void* p = _mi_os_alloc_aligned(size, alignment, *commit, large, tld->stats);
|
void* p = _mi_os_alloc_aligned(size, alignment, *commit, large, tld->stats);
|
||||||
|
|
|
@ -371,13 +371,13 @@ static bool mi_bitmap_is_claimedx_across(mi_bitmap_t bitmap, size_t bitmap_field
|
||||||
if ((prev & pre_mask) != 0) any_ones = true;
|
if ((prev & pre_mask) != 0) any_ones = true;
|
||||||
while (mid_count-- > 0) {
|
while (mid_count-- > 0) {
|
||||||
prev = mi_atomic_load_relaxed(field++);
|
prev = mi_atomic_load_relaxed(field++);
|
||||||
if ((prev & pre_mask) != pre_mask) all_ones = false;
|
if ((prev & mid_mask) != mid_mask) all_ones = false;
|
||||||
if ((prev & pre_mask) != 0) any_ones = true;
|
if ((prev & mid_mask) != 0) any_ones = true;
|
||||||
}
|
}
|
||||||
if (post_mask!=0) {
|
if (post_mask!=0) {
|
||||||
prev = mi_atomic_load_relaxed(field);
|
prev = mi_atomic_load_relaxed(field);
|
||||||
if ((prev & pre_mask) != pre_mask) all_ones = false;
|
if ((prev & post_mask) != post_mask) all_ones = false;
|
||||||
if ((prev & pre_mask) != 0) any_ones = true;
|
if ((prev & post_mask) != 0) any_ones = true;
|
||||||
}
|
}
|
||||||
if (pany_ones != NULL) *pany_ones = any_ones;
|
if (pany_ones != NULL) *pany_ones = any_ones;
|
||||||
return all_ones;
|
return all_ones;
|
||||||
|
|
|
@ -309,7 +309,7 @@ static void _mi_thread_done(mi_heap_t* default_heap);
|
||||||
// nothing to do as it is done in DllMain
|
// nothing to do as it is done in DllMain
|
||||||
#elif defined(_WIN32) && !defined(MI_SHARED_LIB)
|
#elif defined(_WIN32) && !defined(MI_SHARED_LIB)
|
||||||
// use thread local storage keys to detect thread ending
|
// use thread local storage keys to detect thread ending
|
||||||
#include <Windows.h>
|
#include <windows.h>
|
||||||
#include <fibersapi.h>
|
#include <fibersapi.h>
|
||||||
#if (_WIN32_WINNT < 0x600) // before Windows Vista
|
#if (_WIN32_WINNT < 0x600) // before Windows Vista
|
||||||
WINBASEAPI DWORD WINAPI FlsAlloc( _In_opt_ PFLS_CALLBACK_FUNCTION lpCallback );
|
WINBASEAPI DWORD WINAPI FlsAlloc( _In_opt_ PFLS_CALLBACK_FUNCTION lpCallback );
|
||||||
|
|
|
@ -425,7 +425,7 @@ static inline int mi_strnicmp(const char* s, const char* t, size_t n) {
|
||||||
// reliably even when this is invoked before the C runtime is initialized.
|
// reliably even when this is invoked before the C runtime is initialized.
|
||||||
// i.e. when `_mi_preloading() == true`.
|
// i.e. when `_mi_preloading() == true`.
|
||||||
// Note: on windows, environment names are not case sensitive.
|
// Note: on windows, environment names are not case sensitive.
|
||||||
#include <Windows.h>
|
#include <windows.h>
|
||||||
static bool mi_getenv(const char* name, char* result, size_t result_size) {
|
static bool mi_getenv(const char* name, char* result, size_t result_size) {
|
||||||
result[0] = 0;
|
result[0] = 0;
|
||||||
size_t len = GetEnvironmentVariableA(name, result, (DWORD)result_size);
|
size_t len = GetEnvironmentVariableA(name, result, (DWORD)result_size);
|
||||||
|
|
2
src/os.c
2
src/os.c
|
@ -28,7 +28,7 @@ terms of the MIT license. A copy of the license can be found in the file
|
||||||
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <Windows.h>
|
#include <windows.h>
|
||||||
#elif defined(__wasi__)
|
#elif defined(__wasi__)
|
||||||
// stdlib.h is all we need, and has already been included in mimalloc.h
|
// stdlib.h is all we need, and has already been included in mimalloc.h
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -244,7 +244,7 @@ static bool os_random_buf(void* buf, size_t buf_len) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <Windows.h>
|
#include <windows.h>
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#include <mach/mach_time.h>
|
#include <mach/mach_time.h>
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -393,7 +393,7 @@ void mi_thread_stats_print_out(mi_output_fun* out, void* arg) mi_attr_noexcept {
|
||||||
// Basic timer for convenience; use milli-seconds to avoid doubles
|
// Basic timer for convenience; use milli-seconds to avoid doubles
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <windows.h>
|
||||||
static mi_msecs_t mi_to_msecs(LARGE_INTEGER t) {
|
static mi_msecs_t mi_to_msecs(LARGE_INTEGER t) {
|
||||||
static LARGE_INTEGER mfreq; // = 0
|
static LARGE_INTEGER mfreq; // = 0
|
||||||
if (mfreq.QuadPart == 0LL) {
|
if (mfreq.QuadPart == 0LL) {
|
||||||
|
@ -448,7 +448,7 @@ mi_msecs_t _mi_clock_end(mi_msecs_t start) {
|
||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <Windows.h>
|
#include <windows.h>
|
||||||
#include <psapi.h>
|
#include <psapi.h>
|
||||||
#pragma comment(lib,"psapi.lib")
|
#pragma comment(lib,"psapi.lib")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue