diff --git a/CMakeLists.txt b/CMakeLists.txt index 299aec1b..083abce8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -190,14 +190,6 @@ if (MSVC AND MSVC_VERSION GREATER_EQUAL 1914) list(APPEND mi_cflags /Zc:__cplusplus) 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 if(WIN32) list(APPEND mi_libraries psapi shell32 user32 advapi32 bcrypt) diff --git a/include/mimalloc-atomic.h b/include/mimalloc-atomic.h index 2d725a25..db885319 100644 --- a/include/mimalloc-atomic.h +++ b/include/mimalloc-atomic.h @@ -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. #define WIN32_LEAN_AND_MEAN -#include +#include #include #ifdef _WIN64 typedef LONG64 msc_intptr_t; diff --git a/src/alloc.c b/src/alloc.c index 1d973ca4..2de26b78 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -726,7 +726,7 @@ mi_decl_restrict char* mi_strndup(const char* s, size_t n) mi_attr_noexcept { #ifndef PATH_MAX #define PATH_MAX MAX_PATH #endif -#include +#include 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 char buf[PATH_MAX]; diff --git a/src/arena.c b/src/arena.c index ea3a1abd..fae4ecaa 100644 --- a/src/arena.c +++ b/src/arena.c @@ -211,7 +211,10 @@ void* _mi_arena_alloc_aligned(size_t size, size_t alignment, bool* commit, bool* } // 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; *memid = MI_MEMID_OS; void* p = _mi_os_alloc_aligned(size, alignment, *commit, large, tld->stats); diff --git a/src/bitmap.c b/src/bitmap.c index ea55d33e..fa1b16c3 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -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; while (mid_count-- > 0) { prev = mi_atomic_load_relaxed(field++); - if ((prev & pre_mask) != pre_mask) all_ones = false; - if ((prev & pre_mask) != 0) any_ones = true; + if ((prev & mid_mask) != mid_mask) all_ones = false; + if ((prev & mid_mask) != 0) any_ones = true; } if (post_mask!=0) { prev = mi_atomic_load_relaxed(field); - if ((prev & pre_mask) != pre_mask) all_ones = false; - if ((prev & pre_mask) != 0) any_ones = true; + if ((prev & post_mask) != post_mask) all_ones = false; + if ((prev & post_mask) != 0) any_ones = true; } if (pany_ones != NULL) *pany_ones = any_ones; return all_ones; diff --git a/src/init.c b/src/init.c index 2161fdd8..aee08f5a 100644 --- a/src/init.c +++ b/src/init.c @@ -309,7 +309,7 @@ static void _mi_thread_done(mi_heap_t* default_heap); // nothing to do as it is done in DllMain #elif defined(_WIN32) && !defined(MI_SHARED_LIB) // use thread local storage keys to detect thread ending - #include + #include #include #if (_WIN32_WINNT < 0x600) // before Windows Vista WINBASEAPI DWORD WINAPI FlsAlloc( _In_opt_ PFLS_CALLBACK_FUNCTION lpCallback ); diff --git a/src/options.c b/src/options.c index 0560b937..baa387ad 100644 --- a/src/options.c +++ b/src/options.c @@ -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. // i.e. when `_mi_preloading() == true`. // Note: on windows, environment names are not case sensitive. -#include +#include static bool mi_getenv(const char* name, char* result, size_t result_size) { result[0] = 0; size_t len = GetEnvironmentVariableA(name, result, (DWORD)result_size); diff --git a/src/os.c b/src/os.c index 7f94dd5a..21c9d638 100644 --- a/src/os.c +++ b/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) -#include +#include #elif defined(__wasi__) // stdlib.h is all we need, and has already been included in mimalloc.h #else diff --git a/src/random.c b/src/random.c index b6067ecf..113ba0fd 100644 --- a/src/random.c +++ b/src/random.c @@ -244,7 +244,7 @@ static bool os_random_buf(void* buf, size_t buf_len) { #endif #if defined(_WIN32) -#include +#include #elif defined(__APPLE__) #include #else diff --git a/src/stats.c b/src/stats.c index 10be20b0..ab21ec79 100644 --- a/src/stats.c +++ b/src/stats.c @@ -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 // ---------------------------------------------------------------- #ifdef _WIN32 -#include +#include static mi_msecs_t mi_to_msecs(LARGE_INTEGER t) { static LARGE_INTEGER mfreq; // = 0 if (mfreq.QuadPart == 0LL) { @@ -448,7 +448,7 @@ mi_msecs_t _mi_clock_end(mi_msecs_t start) { // -------------------------------------------------------- #if defined(_WIN32) -#include +#include #include #pragma comment(lib,"psapi.lib")