mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-15 10:29:47 +00:00
Merge pull request #3096 from cesanta/polldoze
allow other stack than WinSock in Windows
This commit is contained in:
3 files changed
+64
-18
No files matched your search
+30
-8
@@ -2,6 +2,18 @@
|
||||
|
||||
#if MG_ARCH == MG_ARCH_WIN32
|
||||
|
||||
// Avoid name clashing; (macro expansion producing 'defined' has undefined
|
||||
// behaviour). See config.h for user options
|
||||
#ifndef MG_ENABLE_WINSOCK
|
||||
#if (!defined(MG_ENABLE_TCPIP) || !MG_ENABLE_TCPIP) && \
|
||||
(!defined(MG_ENABLE_LWIP) || !MG_ENABLE_LWIP) && \
|
||||
(!defined(MG_ENABLE_FREERTOS_TCP) || !MG_ENABLE_FREERTOS_TCP)
|
||||
#define MG_ENABLE_WINSOCK 1
|
||||
#else
|
||||
#define MG_ENABLE_WINSOCK 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _CRT_RAND_S
|
||||
#define _CRT_RAND_S
|
||||
#endif
|
||||
@@ -47,17 +59,19 @@ typedef enum { false = 0, true = 1 } bool;
|
||||
#else
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#if MG_ENABLE_WINSOCK
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <process.h>
|
||||
#include <winerror.h>
|
||||
#include <winsock2.h>
|
||||
|
||||
// For mg_random()
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1700
|
||||
#ifndef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x400 // Let vc98 pick up wincrypt.h
|
||||
#include <winsock2.h> // and fix missing macros
|
||||
#endif
|
||||
#include <wincrypt.h>
|
||||
#pragma comment(lib, "advapi32.lib")
|
||||
@@ -73,25 +87,31 @@ typedef enum { false = 0, true = 1 } bool;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define MG_INVALID_SOCKET INVALID_SOCKET
|
||||
#define MG_SOCKET_TYPE SOCKET
|
||||
typedef unsigned long nfds_t;
|
||||
#if defined(_MSC_VER)
|
||||
#if MG_ENABLE_WINSOCK
|
||||
#pragma comment(lib, "ws2_32.lib")
|
||||
#endif
|
||||
#ifndef alloca
|
||||
#define alloca(a) _alloca(a)
|
||||
#endif
|
||||
#endif
|
||||
#define poll(a, b, c) WSAPoll((a), (b), (c))
|
||||
#define closesocket(x) closesocket(x)
|
||||
|
||||
typedef int socklen_t;
|
||||
#define MG_DIRSEP '\\'
|
||||
|
||||
#ifndef MG_PATH_MAX
|
||||
#define MG_PATH_MAX FILENAME_MAX
|
||||
#endif
|
||||
|
||||
#if MG_ENABLE_WINSOCK
|
||||
#include <winsock2.h>
|
||||
|
||||
#define MG_INVALID_SOCKET INVALID_SOCKET
|
||||
#define MG_SOCKET_TYPE SOCKET
|
||||
#define poll(a, b, c) WSAPoll((a), (b), (c))
|
||||
#define closesocket(x) closesocket(x)
|
||||
typedef int socklen_t;
|
||||
|
||||
#ifndef SO_EXCLUSIVEADDRUSE
|
||||
#define SO_EXCLUSIVEADDRUSE ((int) (~SO_REUSEADDR))
|
||||
#endif
|
||||
@@ -106,13 +126,15 @@ typedef int socklen_t;
|
||||
#define MG_SOCK_RESET(errcode) \
|
||||
(((errcode) < 0) && (WSAGetLastError() == WSAECONNRESET))
|
||||
|
||||
#endif // MG_ENABLE_WINSOCK
|
||||
|
||||
#define realpath(a, b) _fullpath((b), (a), MG_PATH_MAX)
|
||||
#define sleep(x) Sleep((x) * 1000)
|
||||
#define sleep(x) Sleep((x) *1000)
|
||||
#define mkdir(a, b) _mkdir(a)
|
||||
#define timegm(x) _mkgmtime(x)
|
||||
|
||||
#ifndef S_ISDIR
|
||||
#define S_ISDIR(x) (((x) & _S_IFMT) == _S_IFDIR)
|
||||
#define S_ISDIR(x) (((x) &_S_IFMT) == _S_IFDIR)
|
||||
#endif
|
||||
|
||||
#ifndef MG_ENABLE_DIRLIST
|
||||
|
||||
+2
-1
@@ -56,7 +56,8 @@
|
||||
#define MG_ENABLE_MD5 1
|
||||
#endif
|
||||
|
||||
// Set MG_ENABLE_WINSOCK=0 for Win32 builds with external IP stack (like LWIP)
|
||||
// Set MG_ENABLE_WINSOCK=0 for Win32 builds with other external IP stack not
|
||||
// mentioned in arch_win32.h
|
||||
#ifndef MG_ENABLE_WINSOCK
|
||||
#define MG_ENABLE_WINSOCK 1
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user