Skip to content

Commit d7f44a0

Browse files
committed
inputthread: fix Windows detection (XSERVER_WIN32 macro for mingw32/cygwin)
1 parent 2c9d469 commit d7f44a0

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

‎os/inputthread.c‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@
4343
#include "opaque.h"
4444
#include "osdep.h"
4545

46-
#if defined(_WIN32)
46+
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__)
47+
#define XSERVER_WIN32 1
48+
#else
49+
#define XSERVER_WIN32 0
50+
#endif
51+
52+
#if XSERVER_WIN32
4753
#include <winsock2.h>
4854
#include <windows.h>
4955
#include <io.h>
@@ -167,7 +173,7 @@ InputThreadFillPipe(PIPE_FD writeHead)
167173
int ret;
168174
char byte = 0;
169175

170-
#if defined(_WIN32)
176+
#if XSERVER_WIN32
171177
do {
172178
ret = send(writeHead, &byte, 1, 0);
173179
} while (ret == SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK);
@@ -190,7 +196,7 @@ InputThreadReadPipe(PIPE_FD readHead)
190196
int ret;
191197
char array[10];
192198

193-
#if defined(_WIN32)
199+
#if XSERVER_WIN32
194200
ret = recv(readHead, array, sizeof(array), 0);
195201
if (ret >= 0)
196202
return ret;
@@ -353,7 +359,7 @@ InputThreadPipeNotify(int fd, int revents, void *data)
353359
static void*
354360
InputThreadDoWork(void *arg)
355361
{
356-
#if !defined(_WIN32)
362+
#if !XSERVER_WIN32
357363
sigset_t set;
358364

359365
/* Don't handle any signals on this thread */
@@ -410,7 +416,7 @@ InputThreadDoWork(void *arg)
410416
}
411417

412418
if (ospoll_wait(inputThreadInfo->fds, -1) < 0) {
413-
#if defined(_WIN32)
419+
#if XSERVER_WIN32
414420
int err = WSAGetLastError();
415421
if (err == WSAEINVAL)
416422
FatalError("input-thread: %s (%d)", __func__, err);
@@ -452,7 +458,7 @@ InputThreadPreInit(void)
452458
if (!InputThreadEnable)
453459
return;
454460

455-
#if defined(_WIN32)
461+
#if XSERVER_WIN32
456462
/* Windows doesn't have socketpair(), emulate with loopback connect */
457463
{
458464
struct sockaddr_in addr;
@@ -673,4 +679,4 @@ int xthread_sigmask(int how, const sigset_t *set, sigset_t *oldset)
673679
#endif
674680
}
675681

676-
#endif
682+
#endif

0 commit comments

Comments
 (0)