From 77f78b50f39ae6141461c2db3a1f8298a0153577 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Mon, 10 Mar 2025 14:58:12 +0100 Subject: [PATCH 1/2] Add missing guards for WIN32_LEAN_AND_MEAN --- Include/internal/pycore_condvar.h | 2 ++ Include/internal/pycore_semaphore.h | 4 +++- Modules/_interpchannelsmodule.c | 2 ++ Python/lock.c | 4 +++- Python/sysmodule.c | 4 +++- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Include/internal/pycore_condvar.h b/Include/internal/pycore_condvar.h index ee9533484e8048..33f2dacfcbf3d6 100644 --- a/Include/internal/pycore_condvar.h +++ b/Include/internal/pycore_condvar.h @@ -31,7 +31,9 @@ #define Py_HAVE_CONDVAR /* include windows if it hasn't been done before */ +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif #include // CRITICAL_SECTION /* options */ diff --git a/Include/internal/pycore_semaphore.h b/Include/internal/pycore_semaphore.h index ffcc6d80344d6e..269538384606ce 100644 --- a/Include/internal/pycore_semaphore.h +++ b/Include/internal/pycore_semaphore.h @@ -10,7 +10,9 @@ #include "pycore_pythread.h" // _POSIX_SEMAPHORES #ifdef MS_WINDOWS -# define WIN32_LEAN_AND_MEAN +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif # include #elif defined(HAVE_PTHREAD_H) # include diff --git a/Modules/_interpchannelsmodule.c b/Modules/_interpchannelsmodule.c index fc54277cdc0ba0..826d49aa05e5db 100644 --- a/Modules/_interpchannelsmodule.c +++ b/Modules/_interpchannelsmodule.c @@ -11,7 +11,9 @@ #include "pycore_pystate.h" // _PyInterpreterState_GetIDObject() #ifdef MS_WINDOWS +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif #include // SwitchToThread() #elif defined(HAVE_SCHED_H) #include // sched_yield() diff --git a/Python/lock.c b/Python/lock.c index 554c51d7780322..f2067ee2cd5f37 100644 --- a/Python/lock.c +++ b/Python/lock.c @@ -8,7 +8,9 @@ #include "pycore_time.h" // _PyTime_Add() #ifdef MS_WINDOWS -# define WIN32_LEAN_AND_MEAN +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif # include // SwitchToThread() #elif defined(HAVE_SCHED_H) # include // sched_yield() diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 8030bbbdeafd52..adaa5ee1c74aa5 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -45,7 +45,9 @@ Data members: #endif #ifdef MS_WINDOWS -# define WIN32_LEAN_AND_MEAN +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif # include #endif /* MS_WINDOWS */ From 9eacfe9cb0cf9188dd3bbb9052f1d59d02c329b8 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Tue, 11 Mar 2025 11:56:54 +0100 Subject: [PATCH 2/2] add missing whitespaces --- Include/internal/pycore_condvar.h | 2 +- Modules/_interpchannelsmodule.c | 2 +- Modules/_io/winconsoleio.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Include/internal/pycore_condvar.h b/Include/internal/pycore_condvar.h index 33f2dacfcbf3d6..55271f0a4116ba 100644 --- a/Include/internal/pycore_condvar.h +++ b/Include/internal/pycore_condvar.h @@ -32,7 +32,7 @@ /* include windows if it hasn't been done before */ #ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN #endif #include // CRITICAL_SECTION diff --git a/Modules/_interpchannelsmodule.c b/Modules/_interpchannelsmodule.c index 826d49aa05e5db..ae64037d56cac0 100644 --- a/Modules/_interpchannelsmodule.c +++ b/Modules/_interpchannelsmodule.c @@ -12,7 +12,7 @@ #ifdef MS_WINDOWS #ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN #endif #include // SwitchToThread() #elif defined(HAVE_SCHED_H) diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c index 27c320ed073103..3f137fa1f54125 100644 --- a/Modules/_io/winconsoleio.c +++ b/Modules/_io/winconsoleio.c @@ -23,7 +23,7 @@ #include /* For offsetof */ #ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN #endif #include #include