From 204348e468155d988f1e5a59d3ee6503a34d2162 Mon Sep 17 00:00:00 2001 From: Daan Date: Sat, 20 Apr 2024 16:58:58 -0700 Subject: [PATCH] only define WIN32_LEAN_AND_MEAN if needed --- include/mimalloc/atomic.h | 4 ++++ include/mimalloc/prim.h | 2 ++ include/mimalloc/track.h | 2 ++ 3 files changed, 8 insertions(+) diff --git a/include/mimalloc/atomic.h b/include/mimalloc/atomic.h index f4bde7f4..807c4da8 100644 --- a/include/mimalloc/atomic.h +++ b/include/mimalloc/atomic.h @@ -133,7 +133,9 @@ static inline void mi_atomic_maxi64_relaxed(volatile int64_t* p, int64_t x) { #elif defined(_MSC_VER) // MSVC C compilation wrapper that uses Interlocked operations to model C11 atomics. +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif #include #include #ifdef _WIN64 @@ -327,7 +329,9 @@ static inline void mi_atomic_yield(void) { std::this_thread::yield(); } #elif defined(_WIN32) +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif #include static inline void mi_atomic_yield(void) { YieldProcessor(); diff --git a/include/mimalloc/prim.h b/include/mimalloc/prim.h index ebb31df2..f8a40323 100644 --- a/include/mimalloc/prim.h +++ b/include/mimalloc/prim.h @@ -222,7 +222,9 @@ static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept; // Get a unique id for the current thread. #if defined(_WIN32) +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif #include static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept { // Windows: works on Intel and ARM in both 32- and 64-bit diff --git a/include/mimalloc/track.h b/include/mimalloc/track.h index 9545f750..a659d940 100644 --- a/include/mimalloc/track.h +++ b/include/mimalloc/track.h @@ -82,7 +82,9 @@ defined, undefined, or not accessible at all: #define MI_TRACK_HEAP_DESTROY 1 #define MI_TRACK_TOOL "ETW" +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif #include #include "../src/prim/windows/etw.h"