Fixed build issue with MinGW (#64)

This commit is contained in:
Mariotaku
2021-09-16 15:30:47 +09:00
committed by GitHub
parent 5b2cf1b8f7
commit 5ed9a6508a
4 changed files with 30 additions and 3 deletions

View File

@@ -23,6 +23,10 @@ DWORD (WINAPI *pfnWlanEnumInterfaces)(HANDLE hClientHandle, PVOID pReserved, PWL
VOID (WINAPI *pfnWlanFreeMemory)(PVOID pMemory);
DWORD (WINAPI *pfnWlanSetInterface)(HANDLE hClientHandle, CONST GUID *pInterfaceGuid, WLAN_INTF_OPCODE OpCode, DWORD dwDataSize, CONST PVOID pData, PVOID pReserved);
#ifndef WLAN_API_MAKE_VERSION
#define WLAN_API_MAKE_VERSION(_major, _minor) (((DWORD)(_minor)) << 16 | (_major))
#endif
#endif
void addrToUrlSafeString(struct sockaddr_storage* addr, char* string)
@@ -302,7 +306,11 @@ int setSocketNonBlocking(SOCKET s, bool enabled) {
#elif defined(O_NONBLOCK)
return fcntl(s, F_SETFL, (enabled ? O_NONBLOCK : 0) | (fcntl(s, F_GETFL) & ~O_NONBLOCK));
#elif defined(FIONBIO)
#ifdef LC_WINDOWS
u_long val = enabled ? 1 : 0;
#else
int val = enabled ? 1 : 0;
#endif
return ioctlsocket(s, FIONBIO, &val);
#else
#error Please define your platform non-blocking sockets API!

View File

@@ -7,7 +7,11 @@
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <wlanapi.h>
#ifndef __MINGW32__
#include <timeapi.h>
#else
#include <mmsystem.h>
#endif
#define SetLastSocketError(x) WSASetLastError(x)
#define LastSocketError() WSAGetLastError()
@@ -23,6 +27,13 @@
#endif
#define EINTR WSAEINTR
#ifdef __MINGW32__
#undef EWOULDBLOCK
#undef EINPROGRESS
#undef ETIMEDOUT
#undef ECONNREFUSED
#endif
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEINPROGRESS
#define ETIMEDOUT WSAETIMEDOUT