Skip to content

Commit 153a0b3

Browse files
committed
Clean-up Windows includes and ifdefs
1 parent 3ab7110 commit 153a0b3

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

Modules/_testinternalcapi/test_lock.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#include "pycore_lock.h"
66
#include "clinic/test_lock.c.h"
77

8-
#ifdef _WIN32
8+
#ifdef MS_WINDOWS
9+
#define WIN32_LEAN_AND_MEAN
910
#include <windows.h>
1011
#else
1112
#include <unistd.h> // usleep()
@@ -20,7 +21,7 @@ module _testinternalcapi
2021
static void
2122
pysleep(int ms)
2223
{
23-
#ifdef _WIN32
24+
#ifdef MS_WINDOWS
2425
Sleep(ms);
2526
#else
2627
usleep(ms * 1000);

Python/lock.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#include "pycore_lock.h"
66
#include "pycore_parking_lot.h"
77

8-
#ifdef _WIN32
8+
#ifdef MS_WINDOWS
9+
#define WIN32_LEAN_AND_MEAN
910
#include <windows.h> // SwitchToThread()
1011
#elif defined(HAVE_SCHED_H)
1112
#include <sched.h> // sched_yield()
@@ -37,7 +38,7 @@ struct mutex_entry {
3738
static void
3839
_Py_yield(void)
3940
{
40-
#ifdef _WIN32
41+
#ifdef MS_WINDOWS
4142
SwitchToThread();
4243
#elif defined(HAVE_SCHED_H)
4344
sched_yield();

Python/parking_lot.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
#include "pycore_pyerrors.h" // _Py_FatalErrorFormat
77
#include "pycore_pystate.h" // _PyThreadState_GET
88

9-
#ifdef _WIN32
9+
#ifdef MS_WINDOWS
10+
# define WIN32_LEAN_AND_MEAN
1011
# include <windows.h>
1112
#elif (defined(_POSIX_SEMAPHORES) && !defined(HAVE_BROKEN_POSIX_SEMAPHORES) && \
1213
defined(HAVE_SEM_TIMEDWAIT))
@@ -23,7 +24,7 @@
2324
// A simple, cross-platform binary semaphore that can be used to implement
2425
// wakeup/sleep.
2526
struct _PySemaphore {
26-
#if defined(_WIN32)
27+
#if defined(MS_WINDOWS)
2728
HANDLE platform_sem;
2829
#elif defined(USE_SEMAPHORES)
2930
sem_t platform_sem;
@@ -73,7 +74,7 @@ static _Py_thread_local ThreadData *thread_data = NULL;
7374
static void
7475
_PySemaphore_Init(_PySemaphore *sema)
7576
{
76-
#if defined(_WIN32)
77+
#if defined(MS_WINDOWS)
7778
sema->platform_sem = CreateSemaphore(
7879
NULL, // attributes
7980
0, // initial count
@@ -100,7 +101,7 @@ _PySemaphore_Init(_PySemaphore *sema)
100101
static void
101102
_PySemaphore_Destroy(_PySemaphore *sema)
102103
{
103-
#if defined(_WIN32)
104+
#if defined(MS_WINDOWS)
104105
CloseHandle(sema->platform_sem);
105106
#elif defined(USE_SEMAPHORES)
106107
sem_destroy(&sema->platform_sem);
@@ -114,7 +115,7 @@ static int
114115
_PySemaphore_PlatformWait(_PySemaphore *sema, _PyTime_t timeout)
115116
{
116117
int res = Py_PARK_INTR;
117-
#if defined(_WIN32)
118+
#if defined(MS_WINDOWS)
118119
DWORD wait;
119120
DWORD millis = 0;
120121
if (timeout < 0) {
@@ -213,7 +214,7 @@ _PySemaphore_Wait(_PySemaphore *sema, _PyTime_t timeout, int detach)
213214
void
214215
_PySemaphore_Wakeup(_PySemaphore *sema)
215216
{
216-
#if defined(_WIN32)
217+
#if defined(MS_WINDOWS)
217218
if (!ReleaseSemaphore(sema->platform_sem, 1, NULL)) {
218219
Py_FatalError("parking_lot: ReleaseSemaphore failed");
219220
}

0 commit comments

Comments
 (0)