diff --git a/ide/vs2022/mimalloc-lib.vcxproj b/ide/vs2022/mimalloc-lib.vcxproj
index beee342a..b4bf013e 100644
--- a/ide/vs2022/mimalloc-lib.vcxproj
+++ b/ide/vs2022/mimalloc-lib.vcxproj
@@ -313,10 +313,10 @@
false
false
Default
- CompileAsC
+ CompileAsCpp
true
stdcpp20
- StreamingSIMDExtensions
+ AdvancedVectorExtensions2
/Zc:__cplusplus %(AdditionalOptions)
diff --git a/include/mimalloc/atomic.h b/include/mimalloc/atomic.h
index e115391c..f91d5f4a 100644
--- a/include/mimalloc/atomic.h
+++ b/include/mimalloc/atomic.h
@@ -271,6 +271,7 @@ static inline int64_t mi_atomic_addi64_relaxed(volatile _Atomic(int64_t)*p, int6
return current;
#endif
}
+
static inline void mi_atomic_void_addi64_relaxed(volatile int64_t* p, const volatile int64_t* padd) {
const int64_t add = *padd;
if (add != 0) {
diff --git a/include/mimalloc/types.h b/include/mimalloc/types.h
index 2f76cfe6..1e4914e7 100644
--- a/include/mimalloc/types.h
+++ b/include/mimalloc/types.h
@@ -22,6 +22,7 @@ terms of the MIT license. A copy of the license can be found in the file
#include
#include // ptrdiff_t
#include // uintptr_t, uint16_t, etc
+#include // SIZE_MAX etc.
#include // error codes
#include "bits.h" // size defines (MI_INTPTR_SIZE etc), bit operations
#include "atomic.h" // _Atomic primitives
diff --git a/src/arena.c b/src/arena.c
index daf36411..5f24c986 100644
--- a/src/arena.c
+++ b/src/arena.c
@@ -1684,7 +1684,7 @@ static bool mi_arena_try_purge(mi_arena_t* arena, mi_msecs_t now, bool force)
if (!force && (expire == 0 || expire > now)) return false;
// reset expire
- mi_atomic_store_release(&arena->purge_expire, (mi_msecs_t)0);
+ mi_atomic_storei64_release(&arena->purge_expire, (mi_msecs_t)0);
mi_subproc_stat_counter_increase(arena->subproc, arena_purges, 1);
// go through all purge info's (with max MI_BFIELD_BITS ranges at a time)
@@ -1706,7 +1706,7 @@ static void mi_arenas_try_purge(bool force, bool visit_all, mi_tld_t* tld)
// check if any arena needs purging?
mi_subproc_t* subproc = tld->subproc;
const mi_msecs_t now = _mi_clock_now();
- const mi_msecs_t arenas_expire = mi_atomic_load_acquire(&subproc->purge_expire);
+ const mi_msecs_t arenas_expire = mi_atomic_loadi64_acquire(&subproc->purge_expire);
if (!visit_all && !force && (arenas_expire == 0 || arenas_expire > now)) return;
const size_t max_arena = mi_arenas_get_count(subproc);
@@ -1717,7 +1717,7 @@ static void mi_arenas_try_purge(bool force, bool visit_all, mi_tld_t* tld)
mi_atomic_guard(&purge_guard)
{
// increase global expire: at most one purge per delay cycle
- if (arenas_expire > now) { mi_atomic_store_release(&subproc->purge_expire, now + (delay/10)); }
+ if (arenas_expire > now) { mi_atomic_storei64_release(&subproc->purge_expire, now + (delay/10)); }
const size_t arena_start = tld->thread_seq % max_arena;
size_t max_purge_count = (visit_all ? max_arena : (max_arena/4)+1);
bool all_visited = true;
@@ -1738,7 +1738,7 @@ static void mi_arenas_try_purge(bool force, bool visit_all, mi_tld_t* tld)
}
}
if (all_visited && !any_purged) {
- mi_atomic_store_release(&subproc->purge_expire, 0);
+ mi_atomic_storei64_release(&subproc->purge_expire, 0);
}
}
}
diff --git a/src/bitmap.h b/src/bitmap.h
index 0237d005..ecca6e6f 100644
--- a/src/bitmap.h
+++ b/src/bitmap.h
@@ -71,8 +71,18 @@ typedef size_t mi_bfield_t;
#define MI_BCHUNK_FIELDS (MI_BCHUNK_BITS / MI_BFIELD_BITS) // 8 on both 64- and 32-bit
+// some compiler (msvc in C mode) cannot have expressions in the alignment attribute
+#if MI_BCHUNK_SIZE==64
+#define mi_decl_bchunk_align mi_decl_align(64)
+#elif MI_BCHUNK_SIZE==32
+#define mi_decl_bchunk_align mi_decl_align(32)
+#else
+#define mi_decl_bchunk_align mi_decl_align(MI_BCHUNK_SIZE)
+#endif
+
+
// A bitmap chunk contains 512 bits on 64-bit (256 on 32-bit)
-typedef mi_decl_align(MI_BCHUNK_SIZE) struct mi_bchunk_s {
+typedef mi_decl_bchunk_align struct mi_bchunk_s {
_Atomic(mi_bfield_t) bfields[MI_BCHUNK_FIELDS];
} mi_bchunk_t;
@@ -96,7 +106,7 @@ typedef mi_bchunk_t mi_bchunkmap_t;
// An atomic bitmap
-typedef mi_decl_align(MI_BCHUNK_SIZE) struct mi_bitmap_s {
+typedef mi_decl_bchunk_align struct mi_bitmap_s {
_Atomic(size_t) chunk_count; // total count of chunks (0 < N <= MI_BCHUNKMAP_BITS)
size_t _padding[MI_BCHUNK_SIZE/MI_SIZE_SIZE - 1]; // suppress warning on msvc
mi_bchunkmap_t chunkmap;
@@ -243,7 +253,7 @@ static inline mi_bbin_t mi_bbin_of(size_t slice_count) {
}
// An atomic "binned" bitmap for the free slices where we keep chunks reserved for particalar size classes
-typedef mi_decl_align(MI_BCHUNK_SIZE) struct mi_bbitmap_s {
+typedef mi_decl_bchunk_align struct mi_bbitmap_s {
_Atomic(size_t) chunk_count; // total count of chunks (0 < N <= MI_BCHUNKMAP_BITS)
_Atomic(size_t) chunk_max_accessed; // max chunk index that was once cleared or set
size_t _padding[MI_BCHUNK_SIZE/MI_SIZE_SIZE - 2]; // suppress warning on msvc
diff --git a/src/prim/windows/prim.c b/src/prim/windows/prim.c
index 88b520c8..574e5678 100644
--- a/src/prim/windows/prim.c
+++ b/src/prim/windows/prim.c
@@ -848,7 +848,7 @@ bool _mi_prim_thread_is_in_threadpool(void) {
if (win_major_version >= 6) {
// check if this thread belongs to a windows threadpool
// see:
- _TEB* const teb = NtCurrentTeb();
+ struct _TEB* const teb = NtCurrentTeb();
void* const pool_data = *((void**)((uint8_t*)teb + (MI_SIZE_BITS == 32 ? 0x0F90 : 0x1778)));
return (pool_data != NULL);
}