8000 Reach for a sweet spot. · python/cpython@391c0e2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 391c0e2

Browse files
Reach for a sweet spot.
1 parent 0f4a50b commit 391c0e2

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Include/internal/pycore_signal.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ extern "C" {
1414

1515
#ifdef MS_WINDOWS
1616
# ifndef SOCKET
17-
# error "<winsock2.h> must be included before this header"
17+
# ifdef PYCORE_SIGNAL_REQUIRES_WINSOCK
18+
# error "<winsock2.h> must be included before this header"
19+
# endif
1820
# endif
1921
# ifndef HANDLE
2022
# error "<windows.h> must be included before this header"
@@ -40,7 +42,7 @@ extern "C" {
4042
# define Py_NSIG 64 // Use a reasonable default value
4143
#endif
4244

43-
#ifdef MS_WINDOWS
45+
#if defined(MS_WINDOWS) && defined(SOCKET)
4446
# define INVALID_FD ((SOCKET)-1)
4547
#else
4648
# define INVALID_FD (-1)
@@ -57,7 +59,12 @@ struct _signals_runtime_state {
5759

5860
volatile struct {
5961
#ifdef MS_WINDOWS
62+
# ifdef SOCKET
6063
SOCKET fd;
64+
# else
65+
// <winsock2.h> wasn't included already, so we fake it.
66+
int fd;
67+
# endif
6168
#elif defined(__VXWORKS__)
6269
int fd;
6370
#else

Modules/signalmodule.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33

44
/* XXX Signals should be recorded per thread, now we have thread state. */
55

6+
#ifdef MS_WINDOWS
7+
# if !defined(SOCKET) && defined(Py_INTERNAL_SIGNAL_H)
8+
# error "pycore_signal.h included without PYCORE_SIGNAL_REQUIRES_WINSOCK"
9+
# endif
10+
# define _PYCORE_SIGNAL_REQUIRES_WINSOCK
11+
#endif
12+
613
#include "Python.h"
714
#include "pycore_atomic.h" // _Py_atomic_int
815
#include "pycore_call.h" // _PyObject_Call()

0 commit comments

Comments
 (0)
0