gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r37762 - in libmicrohttpd: . src/include src/microhttpd src


From: gnunet
Subject: [GNUnet-SVN] r37762 - in libmicrohttpd: . src/include src/microhttpd src/platform src/testcurl src/testcurl/https w32/common
Date: Tue, 23 Aug 2016 22:12:50 +0200

Author: Karlson2k
Date: 2016-08-23 22:12:50 +0200 (Tue, 23 Aug 2016)
New Revision: 37762

Added:
   libmicrohttpd/src/microhttpd/mhd_sockets.c
   libmicrohttpd/src/microhttpd/mhd_sockets.h
Modified:
   libmicrohttpd/configure.ac
   libmicrohttpd/src/include/mhd_options.h
   libmicrohttpd/src/include/microhttpd.h
   libmicrohttpd/src/include/platform.h
   libmicrohttpd/src/include/platform_interface.h
   libmicrohttpd/src/include/w32functions.h
   libmicrohttpd/src/microhttpd/Makefile.am
   libmicrohttpd/src/microhttpd/connection.c
   libmicrohttpd/src/microhttpd/daemon.c
   libmicrohttpd/src/microhttpd/internal.h
   libmicrohttpd/src/microhttpd/sysfdsetsize.c
   libmicrohttpd/src/microhttpd/test_shutdown_select.c
   libmicrohttpd/src/platform/w32functions.c
   libmicrohttpd/src/testcurl/https/test_https_time_out.c
   libmicrohttpd/src/testcurl/https/test_tls_extensions.c
   libmicrohttpd/src/testcurl/test_get.c
   libmicrohttpd/src/testcurl/test_get_sendfile.c
   libmicrohttpd/src/testcurl/test_options.c
   libmicrohttpd/src/testcurl/test_quiesce.c
   libmicrohttpd/w32/common/libmicrohttpd-files.vcxproj
   libmicrohttpd/w32/common/libmicrohttpd-filters.vcxproj
Log:
Moved sockets abstraction to specialized mhd_socket.h/.c files

Modified: libmicrohttpd/configure.ac
===================================================================
--- libmicrohttpd/configure.ac  2016-08-23 15:43:38 UTC (rev 37761)
+++ libmicrohttpd/configure.ac  2016-08-23 20:12:50 UTC (rev 37762)
@@ -545,7 +545,10 @@
 AC_CHECK_HEADERS([fcntl.h math.h errno.h limits.h stdio.h locale.h sys/stat.h 
sys/types.h],,AC_MSG_ERROR([Compiling libmicrohttpd requires standard UNIX 
headers files]))
 
 # Check for optional headers
-AC_CHECK_HEADERS([sys/types.h sys/time.h sys/msg.h netdb.h netinet/in.h 
netinet/tcp.h time.h sys/socket.h sys/mman.h arpa/inet.h sys/select.h search.h 
endian.h machine/endian.h sys/endian.h sys/param.h sys/machine.h 
sys/byteorder.h machine/param.h sys/isa_defs.h inttypes.h stddef.h])
+AC_CHECK_HEADERS([sys/types.h sys/time.h sys/msg.h netdb.h netinet/in.h 
netinet/tcp.h time.h sys/socket.h sys/mman.h arpa/inet.h sys/select.h search.h \
+  endian.h machine/endian.h sys/endian.h sys/param.h sys/machine.h 
sys/byteorder.h machine/param.h sys/isa_defs.h \
+  inttypes.h stddef.h \
+  sockLib.h inetLib.h net/if.h])
 AM_CONDITIONAL([HAVE_TSEARCH], [test "x$ac_cv_header_search_h" = "xyes"])
 
 AC_CHECK_MEMBER([struct sockaddr_in.sin_len],

Modified: libmicrohttpd/src/include/mhd_options.h
===================================================================
--- libmicrohttpd/src/include/mhd_options.h     2016-08-23 15:43:38 UTC (rev 
37761)
+++ libmicrohttpd/src/include/mhd_options.h     2016-08-23 20:12:50 UTC (rev 
37762)
@@ -48,16 +48,11 @@
    headers. */
 #ifdef FD_SETSIZE
 /* FD_SETSIZE defined in command line or in MHD_config.h */
-/* Use function to retrieve system default FD_SETSIZE value. */
-#define _MHD_SYS_DEFAULT_FD_SETSIZE get_system_fdsetsize_value()
 #elif defined(_WIN32) && !defined(__CYGWIN__)
 /* Platform with WinSock and without overridden FD_SETSIZE */
 #define FD_SETSIZE 2048 /* Override default small value */
-/* Use function to retrieve system default FD_SETSIZE value. */
-#define _MHD_SYS_DEFAULT_FD_SETSIZE get_system_fdsetsize_value()
 #else  /* !FD_SETSIZE && !WinSock*/
 /* System default value of FD_SETSIZE is used */
-#define _MHD_SYS_DEFAULT_FD_SETSIZE FD_SETSIZE
 #define _MHD_FD_SETSIZE_IS_DEFAULT 1
 #endif /* !FD_SETSIZE && !WinSock*/
 
@@ -83,6 +78,10 @@
 #endif /* !WIN32_LEAN_AND_MEAN */
 #endif /* _WIN32 */
 
+#if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS)
+#define RESTRICT __restrict__
+#endif /* __VXWORKS__ || __vxworks || OS_VXWORKS */
+
 #if LINUX+0 && (defined(HAVE_SENDFILE64) || defined(HAVE_LSEEK64)) && ! 
defined(_LARGEFILE64_SOURCE)
 /* On Linux, special macro is required to enable definitions of some xxx64 
functions */
 #define _LARGEFILE64_SOURCE 1

Modified: libmicrohttpd/src/include/microhttpd.h
===================================================================
--- libmicrohttpd/src/include/microhttpd.h      2016-08-23 15:43:38 UTC (rev 
37761)
+++ libmicrohttpd/src/include/microhttpd.h      2016-08-23 20:12:50 UTC (rev 
37762)
@@ -60,14 +60,6 @@
  * thread-safe (with the exception of #MHD_set_connection_value,
  * which must only be used in a particular context).
  *
- * NEW: Before including "microhttpd.h" you should add the necessary
- * includes to define the `uint64_t`, `size_t`, `fd_set`, `socklen_t`
- * and `struct sockaddr` data types (which headers are needed may
- * depend on your platform; for possible suggestions consult
- * "platform.h" in the MHD distribution).  If you have done so, you
- * should also have a line with "#define MHD_PLATFORM_H" which will
- * prevent this header from trying (and, depending on your platform,
- * failing) to include the right headers.
  *
  * @defgroup event event-loop control
  * MHD API to start and stop the HTTP server and manage the event loop.
@@ -100,11 +92,14 @@
    hence works on any platform, we use "standard" includes here
    to build out-of-the-box for beginning users on common systems.
 
-   Once you have a proper build system and go for more exotic
-   platforms, you should define MHD_PLATFORM_H in some header that
-   you always include *before* "microhttpd.h".  Then the following
-   "standard" includes won't be used (which might be a good
-   idea, especially on platforms where they do not exist). */
+   If generic headers don't work on your platform, include headers
+   which define 'va_list', 'size_t', 'ssize_t', 'intptr_t',
+   'uint16_t', 'uint32_t', 'uint64_t', 'off_t', 'struct sockaddr',
+   'socklen_t', 'fd_set' and "#define MHD_PLATFORM_H" before
+   including "microhttpd.h". Then the following "standard"
+   includes won't be used (which might be a good idea, especially
+   on platforms where they do not exist).
+   */
 #ifndef MHD_PLATFORM_H
 #include <stdarg.h>
 #include <stdint.h>

Modified: libmicrohttpd/src/include/platform.h
===================================================================
--- libmicrohttpd/src/include/platform.h        2016-08-23 15:43:38 UTC (rev 
37761)
+++ libmicrohttpd/src/include/platform.h        2016-08-23 20:12:50 UTC (rev 
37762)
@@ -55,13 +55,17 @@
    are available) */
 
 
-#ifdef OS_VXWORKS
-#include <sockLib.h>
-#include <netinet/in.h>
+#if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS)
 #include <stdarg.h>
 #include <sys/mman.h>
-#define RESTRICT __restrict__
-#endif
+#ifdef HAVE_SOCKLIB_H
+#include <sockLib.h>
+#endif /* HAVE_SOCKLIB_H */
+#ifdef HAVE_INETLIB_H
+#include <inetLib.h>
+#endif /* HAVE_INETLIB_H */
+#endif /* __VXWORKS__ */
+
 #if HAVE_MEMORY_H
 #include <memory.h>
 #endif
@@ -84,12 +88,6 @@
 #if HAVE_SYS_MMAN_H
 #include <sys/mman.h>
 #endif
-#if HAVE_NETDB_H
-#include <netdb.h>
-#endif
-#if HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
 #if HAVE_TIME_H
 #include <time.h>
 #endif
@@ -96,9 +94,14 @@
 #if HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
-#if HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#ifndef WIN32_LEAN_AND_MEAN
+/* Do not include unneeded parts of W32 headers. */
+#define WIN32_LEAN_AND_MEAN 1
+#endif /* !WIN32_LEAN_AND_MEAN */
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#endif /* _WIN32 && !__CYGWIN__ */
 
 #if defined(__CYGWIN__) && !defined(_SYS_TYPES_FD_SET)
 /* Do not define __USE_W32_SOCKETS under Cygwin! */
@@ -106,52 +109,15 @@
 #endif
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
-#include <ws2tcpip.h>
 #define sleep(seconds) ((SleepEx((seconds)*1000, 1)==0)?0:(seconds))
 #define usleep(useconds) ((SleepEx((useconds)/1000, 1)==0)?0:-1)
 #endif
 
-#if !defined(SHUT_WR) && defined(SD_SEND)
-#define SHUT_WR SD_SEND
-#endif
-#if !defined(SHUT_RD) && defined(SD_RECEIVE)
-#define SHUT_RD SD_RECEIVE
-#endif
-#if !defined(SHUT_RDWR) && defined(SD_BOTH)
-#define SHUT_RDWR SD_BOTH
-#endif
-
 #if defined(_MSC_FULL_VER) && !defined (_SSIZE_T_DEFINED)
 #define _SSIZE_T_DEFINED
 typedef intptr_t ssize_t;
 #endif /* !_SSIZE_T_DEFINED */
 
-#ifndef MHD_SOCKET_DEFINED
-/**
- * MHD_socket is type for socket FDs
- */
-#if !defined(_WIN32) || defined(__CYGWIN__)
-#define MHD_POSIX_SOCKETS 1
-typedef int MHD_socket;
-#define MHD_INVALID_SOCKET (-1)
-#else  /* defined(_WIN32) && !defined(__CYGWIN__) */
-#define MHD_WINSOCK_SOCKETS 1
-#include <winsock2.h>
-typedef SOCKET MHD_socket;
-#define MHD_INVALID_SOCKET (INVALID_SOCKET)
-#endif /* defined(_WIN32) && !defined(__CYGWIN__) */
-#define MHD_SOCKET_DEFINED 1
-#endif /* MHD_SOCKET_DEFINED */
-
-/**
- * _MHD_SOCKOPT_BOOL_TYPE is type for bool parameters for 
setsockopt()/getsockopt()
- */
-#ifdef MHD_POSIX_SOCKETS
-typedef int _MHD_SOCKOPT_BOOL_TYPE;
-#else /* MHD_WINSOCK_SOCKETS */
-typedef BOOL _MHD_SOCKOPT_BOOL_TYPE;
-#endif /* MHD_WINSOCK_SOCKETS */
-
 #ifndef _WIN32
 typedef time_t _MHD_TIMEVAL_TV_SEC_TYPE;
 #else  /* _WIN32 */
@@ -158,6 +124,8 @@
 typedef long _MHD_TIMEVAL_TV_SEC_TYPE;
 #endif /* _WIN32 */
 
+/* TODO: remove include when pipes implementation is moved to other file */
+#include "../microhttpd/mhd_sockets.h"
 /* Force don't use pipes on W32 */
 #if defined(_WIN32) && !defined(MHD_DONT_USE_PIPES)
 #define MHD_DONT_USE_PIPES 1

Modified: libmicrohttpd/src/include/platform_interface.h
===================================================================
--- libmicrohttpd/src/include/platform_interface.h      2016-08-23 15:43:38 UTC 
(rev 37761)
+++ libmicrohttpd/src/include/platform_interface.h      2016-08-23 20:12:50 UTC 
(rev 37762)
@@ -27,6 +27,7 @@
 #define MHD_PLATFORM_INTERFACE_H
 
 #include "platform.h"
+#include "../microhttpd/mhd_sockets.h"
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #include "w32functions.h"
 #endif
@@ -46,85 +47,6 @@
 #endif /* ! _WIN32*/
 #endif /* ! HAVE_SNPRINTF */
 
-
-/**
- * _MHD_socket_funcs_size is type used to specify size for send and recv
- * functions
- */
-#if !defined(MHD_WINSOCK_SOCKETS)
-typedef size_t _MHD_socket_funcs_size;
-#else
-typedef int _MHD_socket_funcs_size;
-#endif
-
-/**
- * MHD_socket_close_(fd) close any FDs (non-W32) / close only socket
- * FDs (W32).  Note that on HP-UNIX, this function may leak the FD if
- * errno is set to EINTR.  Do not use HP-UNIX.
- *
- * @param fd descriptor to close
- * @return 0 on success (error codes like EINTR and EIO are counted as success,
- *           only EBADF counts as an error!)
- */
-#if !defined(MHD_WINSOCK_SOCKETS)
-#define MHD_socket_close_(fd) (((0 != close(fd)) && (EBADF == errno)) ? -1 : 0)
-#else
-#define MHD_socket_close_(fd) closesocket((fd))
-#endif
-
-/**
- * MHD_socket_errno_ is errno of last function (non-W32) / errno of
- * last socket function (W32)
- */
-#if !defined(MHD_WINSOCK_SOCKETS)
-#define MHD_socket_errno_ errno
-#else
-#define MHD_socket_errno_ MHD_W32_errno_from_winsock_()
-#endif
-
-/* MHD_socket_last_strerr_ is description string of last errno (non-W32) /
- *                            description string of last socket error (W32) */
-#if !defined(MHD_WINSOCK_SOCKETS)
-#define MHD_socket_last_strerr_() strerror(errno)
-#else
-#define MHD_socket_last_strerr_() MHD_W32_strerror_last_winsock_()
-#endif
-
-/* MHD_strerror_ is strerror (both non-W32/W32) */
-#if !defined(MHD_WINSOCK_SOCKETS)
-#define MHD_strerror_(errnum) strerror((errnum))
-#else
-#define MHD_strerror_(errnum) MHD_W32_strerror_((errnum))
-#endif
-
-/* MHD_set_socket_errno_ set errno to errnum (non-W32) / set socket last error 
to errnum (W32) */
-#if !defined(MHD_WINSOCK_SOCKETS)
-#define MHD_set_socket_errno_(errnum) errno=(errnum)
-#else
-#define MHD_set_socket_errno_(errnum) MHD_W32_set_last_winsock_error_((errnum))
-#endif
-
-/* MHD_SYS_select_ is wrapper macro for system select() function */
-#if !defined(MHD_WINSOCK_SOCKETS)
-#define MHD_SYS_select_(n,r,w,e,t) select((n),(r),(w),(e),(t))
-#else
-#define MHD_SYS_select_(n,r,w,e,t) \
- ( (!(r) || ((fd_set*)(r))->fd_count == 0) && \
-   (!(w) || ((fd_set*)(w))->fd_count == 0) && \
-   (!(e) || ((fd_set*)(e))->fd_count == 0) ) ? \
- ( (t) ? (Sleep((t)->tv_sec * 1000 + (t)->tv_usec / 1000), 0) : 0 ) : \
-   (select((int)0,(r),(w),(e),(t)))
-#endif
-
-#if defined(HAVE_POLL)
-/* MHD_sys_poll_ is wrapper macro for system poll() function */
-#if !defined(MHD_WINSOCK_SOCKETS)
-#define MHD_sys_poll_ poll
-#else  /* MHD_WINSOCK_SOCKETS */
-#define MHD_sys_poll_ WSAPoll
-#endif /* MHD_WINSOCK_SOCKETS */
-#endif /* HAVE_POLL */
-
 /* MHD_pipe_ create pipe (!MHD_DONT_USE_PIPES) /
  *           create two connected sockets (MHD_DONT_USE_PIPES) */
 #ifndef MHD_DONT_USE_PIPES

Modified: libmicrohttpd/src/include/w32functions.h
===================================================================
--- libmicrohttpd/src/include/w32functions.h    2016-08-23 15:43:38 UTC (rev 
37761)
+++ libmicrohttpd/src/include/w32functions.h    2016-08-23 20:12:50 UTC (rev 
37762)
@@ -39,145 +39,7 @@
 {
 #endif
 
-#define MHDW32ERRBASE 3300
-
-#ifndef EWOULDBLOCK
-#define EWOULDBLOCK (MHDW32ERRBASE+1)
-#endif
-#ifndef EINPROGRESS
-#define EINPROGRESS (MHDW32ERRBASE+2)
-#endif
-#ifndef EALREADY
-#define EALREADY (MHDW32ERRBASE+3)
-#endif
-#ifndef ENOTSOCK
-#define ENOTSOCK (MHDW32ERRBASE+4)
-#endif
-#ifndef EDESTADDRREQ
-#define EDESTADDRREQ (MHDW32ERRBASE+5)
-#endif
-#ifndef EMSGSIZE
-#define EMSGSIZE (MHDW32ERRBASE+6)
-#endif
-#ifndef EPROTOTYPE
-#define EPROTOTYPE (MHDW32ERRBASE+7)
-#endif
-#ifndef ENOPROTOOPT
-#define ENOPROTOOPT (MHDW32ERRBASE+8)
-#endif
-#ifndef EPROTONOSUPPORT
-#define EPROTONOSUPPORT (MHDW32ERRBASE+9)
-#endif
-#ifndef EOPNOTSUPP
-#define EOPNOTSUPP (MHDW32ERRBASE+10)
-#endif
-#ifndef EAFNOSUPPORT
-#define EAFNOSUPPORT (MHDW32ERRBASE+11)
-#endif
-#ifndef EADDRINUSE
-#define EADDRINUSE (MHDW32ERRBASE+12)
-#endif
-#ifndef EADDRNOTAVAIL
-#define EADDRNOTAVAIL (MHDW32ERRBASE+13)
-#endif
-#ifndef ENETDOWN
-#define ENETDOWN (MHDW32ERRBASE+14)
-#endif
-#ifndef ENETUNREACH
-#define ENETUNREACH (MHDW32ERRBASE+15)
-#endif
-#ifndef ENETRESET
-#define ENETRESET (MHDW32ERRBASE+16)
-#endif
-#ifndef ECONNABORTED
-#define ECONNABORTED (MHDW32ERRBASE+17)
-#endif
-#ifndef ECONNRESET
-#define ECONNRESET (MHDW32ERRBASE+18)
-#endif
-#ifndef ENOBUFS
-#define ENOBUFS (MHDW32ERRBASE+19)
-#endif
-#ifndef EISCONN
-#define EISCONN (MHDW32ERRBASE+20)
-#endif
-#ifndef ENOTCONN
-#define ENOTCONN (MHDW32ERRBASE+21)
-#endif
-#ifndef ETOOMANYREFS
-#define ETOOMANYREFS (MHDW32ERRBASE+22)
-#endif
-#ifndef ECONNREFUSED
-#define ECONNREFUSED (MHDW32ERRBASE+23)
-#endif
-#ifndef ELOOP
-#define ELOOP (MHDW32ERRBASE+24)
-#endif
-#ifndef EHOSTDOWN
-#define EHOSTDOWN (MHDW32ERRBASE+25)
-#endif
-#ifndef EHOSTUNREACH
-#define EHOSTUNREACH (MHDW32ERRBASE+26)
-#endif
-#ifndef EPROCLIM
-#define EPROCLIM (MHDW32ERRBASE+27)
-#endif
-#ifndef EUSERS
-#define EUSERS (MHDW32ERRBASE+28)
-#endif
-#ifndef EDQUOT
-#define EDQUOT (MHDW32ERRBASE+29)
-#endif
-#ifndef ESTALE
-#define ESTALE (MHDW32ERRBASE+30)
-#endif
-#ifndef EREMOTE
-#define EREMOTE (MHDW32ERRBASE+31)
-#endif
-#ifndef ESOCKTNOSUPPORT
-#define ESOCKTNOSUPPORT (MHDW32ERRBASE+32)
-#endif
-#ifndef EPFNOSUPPORT
-#define EPFNOSUPPORT (MHDW32ERRBASE+33)
-#endif
-#ifndef ESHUTDOWN
-#define ESHUTDOWN (MHDW32ERRBASE+34)
-#endif
-#ifndef ENODATA
-#define ENODATA (MHDW32ERRBASE+35)
-#endif
-#ifndef ETIMEDOUT
-#define ETIMEDOUT (MHDW32ERRBASE+36)
-#endif
-
 /**
- * Return errno equivalent of last winsock error
- * @return errno equivalent of last winsock error
- */
-int MHD_W32_errno_from_winsock_(void);
-
-/**
- * Return pointer to string description of errnum error
- * Works fine with both standard errno errnums
- * and errnums from MHD_W32_errno_from_winsock_
- * @param errnum the errno or value from MHD_W32_errno_from_winsock_()
- * @return pointer to string description of error
- */
-const char* MHD_W32_strerror_(int errnum);
-
-/**
- * Return pointer to string description of last winsock error
- * @return pointer to string description of last winsock error
- */
-const char* MHD_W32_strerror_last_winsock_(void);
-
-/**
- * Set last winsock error to equivalent of given errno value
- * @param errnum the errno value to set
- */
-void MHD_W32_set_last_winsock_error_(int errnum);
-
-/**
  * Create pair of mutually connected TCP/IP sockets on loopback address
  * @param sockets_pair array to receive resulted sockets
  * @return zero on success, -1 otherwise

Modified: libmicrohttpd/src/microhttpd/Makefile.am
===================================================================
--- libmicrohttpd/src/microhttpd/Makefile.am    2016-08-23 15:43:38 UTC (rev 
37761)
+++ libmicrohttpd/src/microhttpd/Makefile.am    2016-08-23 20:12:50 UTC (rev 
37762)
@@ -69,6 +69,7 @@
   mhd_str.c mhd_str.h \
   mhd_threads.c mhd_threads.h \
   mhd_locks.h \
+  mhd_sockets.c mhd_sockets.h \
   response.c response.h
 libmicrohttpd_la_CPPFLAGS = \
   $(AM_CPPFLAGS) $(MHD_LIB_CPPFLAGS) \

Modified: libmicrohttpd/src/microhttpd/connection.c
===================================================================
--- libmicrohttpd/src/microhttpd/connection.c   2016-08-23 15:43:38 UTC (rev 
37761)
+++ libmicrohttpd/src/microhttpd/connection.c   2016-08-23 20:12:50 UTC (rev 
37762)
@@ -32,13 +32,9 @@
 #include "mhd_mono_clock.h"
 #include "mhd_str.h"
 #include "mhd_locks.h"
+#include "mhd_sockets.h"
 
-#if HAVE_NETINET_TCP_H
-/* for TCP_CORK */
-#include <netinet/tcp.h>
-#endif
 
-
 /**
  * Message to transmit when http 1.1 request is received
  */

Modified: libmicrohttpd/src/microhttpd/daemon.c
===================================================================
--- libmicrohttpd/src/microhttpd/daemon.c       2016-08-23 15:43:38 UTC (rev 
37761)
+++ libmicrohttpd/src/microhttpd/daemon.c       2016-08-23 20:12:50 UTC (rev 
37762)
@@ -34,6 +34,7 @@
 #include "autoinit_funcs.h"
 #include "mhd_mono_clock.h"
 #include "mhd_locks.h"
+#include "mhd_sockets.h"
 
 #if HAVE_SEARCH_H
 #include <search.h>
@@ -46,18 +47,10 @@
 #include <gcrypt.h>
 #endif
 
-#if defined(HAVE_POLL_H) && defined(HAVE_POLL)
-#include <poll.h>
-#endif
-
 #ifdef LINUX
 #include <sys/sendfile.h>
 #endif
 
-#ifndef _MHD_FD_SETSIZE_IS_DEFAULT
-#include "sysfdsetsize.h"
-#endif /* !_MHD_FD_SETSIZE_IS_DEFAULT */
-
 #ifdef _WIN32
 #ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN 1
@@ -79,14 +72,7 @@
  */
 #define MHD_POOL_SIZE_DEFAULT (32 * 1024)
 
-#ifdef TCP_FASTOPEN
 /**
- * Default TCP fastopen queue size.
- */
-#define MHD_TCP_FASTOPEN_QUEUE_SIZE_DEFAULT 10
-#endif
-
-/**
  * Print extra messages with reasons for closing
  * sockets? (only adds non-error messages).
  */
@@ -104,27 +90,7 @@
 #endif
 #endif
 
-#ifdef SOCK_CLOEXEC
-#define MAYBE_SOCK_CLOEXEC SOCK_CLOEXEC
-#else  /* ! SOCK_CLOEXEC */
-#define MAYBE_SOCK_CLOEXEC 0
-#endif /* ! SOCK_CLOEXEC */
 
-#ifdef HAVE_SOCK_NONBLOCK
-#define MAYBE_SOCK_NONBLOCK SOCK_NONBLOCK
-#else  /* ! HAVE_SOCK_NONBLOCK */
-#define MAYBE_SOCK_NONBLOCK 0
-#endif /* ! HAVE_SOCK_NONBLOCK */
-
-#if HAVE_ACCEPT4+0 != 0 && (defined(HAVE_SOCK_NONBLOCK) || 
defined(SOCK_CLOEXEC))
-#define USE_ACCEPT4 1
-#endif
-
-#if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC)
-#define USE_EPOLL_CREATE1 1
-#endif /* HAVE_EPOLL_CREATE1 && EPOLL_CLOEXEC */
-
-
 /**
  * Default implementation of the panic function,
  * prints an error message and aborts.

Modified: libmicrohttpd/src/microhttpd/internal.h
===================================================================
--- libmicrohttpd/src/microhttpd/internal.h     2016-08-23 15:43:38 UTC (rev 
37761)
+++ libmicrohttpd/src/microhttpd/internal.h     2016-08-23 20:12:50 UTC (rev 
37762)
@@ -36,15 +36,9 @@
 #include <gnutls/abstract.h>
 #endif
 #endif
-#if EPOLL_SUPPORT
-#include <sys/epoll.h>
-#endif
-#if HAVE_NETINET_TCP_H
-/* for TCP_FASTOPEN */
-#include <netinet/tcp.h>
-#endif
 #include "mhd_threads.h"
 #include "mhd_locks.h"
+#include "mhd_sockets.h"
 
 
 /**

Copied: libmicrohttpd/src/microhttpd/mhd_sockets.c (from rev 37751, 
libmicrohttpd/src/platform/w32functions.c)
===================================================================
--- libmicrohttpd/src/microhttpd/mhd_sockets.c                          (rev 0)
+++ libmicrohttpd/src/microhttpd/mhd_sockets.c  2016-08-23 20:12:50 UTC (rev 
37762)
@@ -0,0 +1,545 @@
+/*
+  This file is part of libmicrohttpd
+  Copyright (C) 2014-2016 Karlson2k (Evgeny Grin)
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+
+*/
+
+/**
+ * @file microhttpd/mhd_sockets.c
+ * @brief  Implementation for sockets functions
+ * @author Karlson2k (Evgeny Grin)
+ */
+
+#include "mhd_sockets.h"
+
+#ifdef MHD_WINSOCK_SOCKETS
+
+/**
+ * Return errno equivalent of last winsock error
+ * @return errno equivalent of last winsock error
+ */
+int MHD_W32_errno_from_winsock_(void)
+{
+  switch(WSAGetLastError())
+  {
+  case 0:                      return 0;
+  case WSA_INVALID_HANDLE:     return EBADF;
+  case WSA_NOT_ENOUGH_MEMORY:  return ENOMEM;
+  case WSA_INVALID_PARAMETER:  return EINVAL;
+  case WSAEINTR:               return EINTR;
+  case WSAEWOULDBLOCK:         return EWOULDBLOCK;
+  case WSAEINPROGRESS:         return EINPROGRESS;
+  case WSAEALREADY:            return EALREADY;
+  case WSAENOTSOCK:            return ENOTSOCK;
+  case WSAEDESTADDRREQ:        return EDESTADDRREQ;
+  case WSAEMSGSIZE:            return EMSGSIZE;
+  case WSAEPROTOTYPE:          return EPROTOTYPE;
+  case WSAENOPROTOOPT:         return ENOPROTOOPT;
+  case WSAEPROTONOSUPPORT:     return EPROTONOSUPPORT;
+  case WSAESOCKTNOSUPPORT:     return ESOCKTNOSUPPORT;
+  case WSAEOPNOTSUPP:          return EOPNOTSUPP;
+  case WSAEPFNOSUPPORT:        return EPFNOSUPPORT;
+  case WSAEAFNOSUPPORT:        return EAFNOSUPPORT;
+  case WSAEADDRINUSE:          return EADDRINUSE;
+  case WSAEADDRNOTAVAIL:       return EADDRNOTAVAIL;
+  case WSAENETDOWN:            return ENETDOWN;
+  case WSAENETUNREACH:         return ENETUNREACH;
+  case WSAENETRESET:           return ENETRESET;
+  case WSAECONNABORTED:        return ECONNABORTED;
+  case WSAECONNRESET:          return ECONNRESET;
+  case WSAENOBUFS:             return ENOBUFS;
+  case WSAEISCONN:             return EISCONN;
+  case WSAENOTCONN:            return ENOTCONN;
+  case WSAESHUTDOWN:           return ESHUTDOWN;
+  case WSAETOOMANYREFS:        return ETOOMANYREFS;
+  case WSAETIMEDOUT:           return ETIMEDOUT;
+  case WSAECONNREFUSED:        return ECONNREFUSED;
+  case WSAELOOP:               return ELOOP;
+  case WSAENAMETOOLONG:        return ENAMETOOLONG;
+  case WSAEHOSTDOWN:           return EHOSTDOWN;
+  case WSAEHOSTUNREACH:        return EHOSTUNREACH;
+  case WSAENOTEMPTY:           return ENOTEMPTY;
+  case WSAEPROCLIM:            return EPROCLIM;
+  case WSAEUSERS:              return EUSERS;
+  case WSAEDQUOT:              return EDQUOT;
+  case WSAESTALE:              return ESTALE;
+  case WSAEREMOTE:             return EREMOTE;
+  case WSAEINVAL:              return EINVAL;
+  case WSAEFAULT:              return EFAULT;
+  case WSANO_DATA:             return ENODATA;
+  /* Rough equivalents */
+  case WSAEDISCON:             return ECONNRESET;
+  case WSAEINVALIDPROCTABLE:   return EFAULT;
+  case WSASYSNOTREADY:
+  case WSANOTINITIALISED:
+  case WSASYSCALLFAILURE:      return ENOBUFS;
+  case WSAVERNOTSUPPORTED:     return EOPNOTSUPP;
+  case WSAEREFUSED:            return EIO;
+  }
+  return EINVAL;
+}
+
+/**
+ * Return pointer to string description of errnum error
+ * Works fine with both standard errno errnums
+ * and errnums from MHD_W32_errno_from_winsock_
+ * @param errnum the errno or value from MHD_W32_errno_from_winsock_()
+ * @return pointer to string description of error
+ */
+const char* MHD_W32_strerror_(int errnum)
+{
+  switch(errnum)
+  {
+  case 0:
+    return "No error";
+  case EWOULDBLOCK:
+    return "Operation would block";
+  case EINPROGRESS:
+    return "Connection already in progress";
+  case EALREADY:
+    return "Socket already connected";
+  case ENOTSOCK:
+    return "Socket operation on non-socket";
+  case EDESTADDRREQ:
+    return "Destination address required";
+  case EMSGSIZE:
+    return "Message too long";
+  case EPROTOTYPE:
+    return "Protocol wrong type for socket";
+  case ENOPROTOOPT:
+    return "Protocol not available";
+  case EPROTONOSUPPORT:
+    return "Unknown protocol";
+  case ESOCKTNOSUPPORT:
+    return "Socket type not supported";
+  case EOPNOTSUPP:
+    return "Operation not supported on socket";
+  case EPFNOSUPPORT:
+    return "Protocol family not supported";
+  case EAFNOSUPPORT:
+    return "Address family not supported by protocol family";
+  case EADDRINUSE:
+    return "Address already in use";
+  case EADDRNOTAVAIL:
+    return "Cannot assign requested address";
+  case ENETDOWN:
+    return "Network is down";
+  case ENETUNREACH:
+    return "Network is unreachable";
+  case ENETRESET:
+    return "Network dropped connection on reset";
+  case ECONNABORTED:
+    return "Software caused connection abort";
+  case ECONNRESET:
+    return "Connection reset by peer";
+  case ENOBUFS:
+    return "No system resources available";
+  case EISCONN:
+    return "Socket is already connected";
+  case ENOTCONN:
+    return "Socket is not connected";
+  case ESHUTDOWN:
+    return "Can't send after socket shutdown";
+  case ETOOMANYREFS:
+    return "Too many references: cannot splice";
+  case ETIMEDOUT:
+    return "Connection timed out";
+  case ECONNREFUSED:
+    return "Connection refused";
+  case ELOOP:
+    return "Cannot translate name";
+  case EHOSTDOWN:
+    return "Host is down";
+  case EHOSTUNREACH:
+    return "Host is unreachable";
+  case EPROCLIM:
+    return "Too many processes";
+  case EUSERS:
+    return "Too many users";
+  case EDQUOT:
+    return "Disk quota exceeded";
+  case ESTALE:
+    return "Stale file handle reference";
+  case EREMOTE:
+    return "Resource is remote";
+  case ENODATA:
+    return "No data available";
+  }
+  return strerror(errnum);
+}
+
+/**
+ * Return pointer to string description of last winsock error
+ * @return pointer to string description of last winsock error
+ */
+const char* MHD_W32_strerror_last_winsock_(void)
+{
+  switch (WSAGetLastError())
+    {
+  case 0:
+    return "No error";
+  case WSA_INVALID_HANDLE:
+    return "Specified event object handle is invalid";
+  case WSA_NOT_ENOUGH_MEMORY:
+    return "Insufficient memory available";
+  case WSA_INVALID_PARAMETER:
+    return "One or more parameters are invalid";
+  case WSA_OPERATION_ABORTED:
+    return "Overlapped operation aborted";
+  case WSA_IO_INCOMPLETE:
+    return "Overlapped I/O event object not in signaled state";
+  case WSA_IO_PENDING:
+    return "Overlapped operations will complete later";
+  case WSAEINTR:
+    return "Interrupted function call";
+  case WSAEBADF:
+    return "File handle is not valid";
+  case WSAEACCES:
+    return "Permission denied";
+  case WSAEFAULT:
+    return "Bad address";
+  case WSAEINVAL:
+    return "Invalid argument";
+  case WSAEMFILE:
+    return "Too many open files";
+  case WSAEWOULDBLOCK:
+    return "Resource temporarily unavailable";
+  case WSAEINPROGRESS:
+    return "Operation now in progress";
+  case WSAEALREADY:
+    return "Operation already in progress";
+  case WSAENOTSOCK:
+    return "Socket operation on nonsocket";
+  case WSAEDESTADDRREQ:
+    return "Destination address required";
+  case WSAEMSGSIZE:
+    return "Message too long";
+  case WSAEPROTOTYPE:
+    return "Protocol wrong type for socket";
+  case WSAENOPROTOOPT:
+    return "Bad protocol option";
+  case WSAEPROTONOSUPPORT:
+    return "Protocol not supported";
+  case WSAESOCKTNOSUPPORT:
+    return "Socket type not supported";
+  case WSAEOPNOTSUPP:
+    return "Operation not supported";
+  case WSAEPFNOSUPPORT:
+    return "Protocol family not supported";
+  case WSAEAFNOSUPPORT:
+    return "Address family not supported by protocol family";
+  case WSAEADDRINUSE:
+    return "Address already in use";
+  case WSAEADDRNOTAVAIL:
+    return "Cannot assign requested address";
+  case WSAENETDOWN:
+    return "Network is down";
+  case WSAENETUNREACH:
+    return "Network is unreachable";
+  case WSAENETRESET:
+    return "Network dropped connection on reset";
+  case WSAECONNABORTED:
+    return "Software caused connection abort";
+  case WSAECONNRESET:
+    return "Connection reset by peer";
+  case WSAENOBUFS:
+    return "No buffer space available";
+  case WSAEISCONN:
+    return "Socket is already connected";
+  case WSAENOTCONN:
+    return "Socket is not connected";
+  case WSAESHUTDOWN:
+    return "Cannot send after socket shutdown";
+  case WSAETOOMANYREFS:
+    return "Too many references";
+  case WSAETIMEDOUT:
+    return "Connection timed out";
+  case WSAECONNREFUSED:
+    return "Connection refused";
+  case WSAELOOP:
+    return "Cannot translate name";
+  case WSAENAMETOOLONG:
+    return "Name too long";
+  case WSAEHOSTDOWN:
+    return "Host is down";
+  case WSAEHOSTUNREACH:
+    return "No route to host";
+  case WSAENOTEMPTY:
+    return "Directory not empty";
+  case WSAEPROCLIM:
+    return "Too many processes";
+  case WSAEUSERS:
+    return "User quota exceeded";
+  case WSAEDQUOT:
+    return "Disk quota exceeded";
+  case WSAESTALE:
+    return "Stale file handle reference";
+  case WSAEREMOTE:
+    return "Item is remote";
+  case WSASYSNOTREADY:
+    return "Network subsystem is unavailable";
+  case WSAVERNOTSUPPORTED:
+    return "Winsock.dll version out of range";
+  case WSANOTINITIALISED:
+    return "Successful WSAStartup not yet performed";
+  case WSAEDISCON:
+    return "Graceful shutdown in progress";
+  case WSAENOMORE:
+    return "No more results";
+  case WSAECANCELLED:
+    return "Call has been canceled";
+  case WSAEINVALIDPROCTABLE:
+    return "Procedure call table is invalid";
+  case WSAEINVALIDPROVIDER:
+    return "Service provider is invalid";
+  case WSAEPROVIDERFAILEDINIT:
+    return "Service provider failed to initialize";
+  case WSASYSCALLFAILURE:
+    return "System call failure";
+  case WSASERVICE_NOT_FOUND:
+    return "Service not found";
+  case WSATYPE_NOT_FOUND:
+    return "Class type not found";
+  case WSA_E_NO_MORE:
+    return "No more results";
+  case WSA_E_CANCELLED:
+    return "Call was canceled";
+  case WSAEREFUSED:
+    return "Database query was refused";
+  case WSAHOST_NOT_FOUND:
+    return "Host not found";
+  case WSATRY_AGAIN:
+    return "Nonauthoritative host not found";
+  case WSANO_RECOVERY:
+    return "This is a nonrecoverable error";
+  case WSANO_DATA:
+    return "Valid name, no data record of requested type";
+  case WSA_QOS_RECEIVERS:
+    return "QoS receivers";
+  case WSA_QOS_SENDERS:
+    return "QoS senders";
+  case WSA_QOS_NO_SENDERS:
+    return "No QoS senders";
+  case WSA_QOS_NO_RECEIVERS:
+    return "QoS no receivers";
+  case WSA_QOS_REQUEST_CONFIRMED:
+    return "QoS request confirmed";
+  case WSA_QOS_ADMISSION_FAILURE:
+    return "QoS admission error";
+  case WSA_QOS_POLICY_FAILURE:
+    return "QoS policy failure";
+  case WSA_QOS_BAD_STYLE:
+    return "QoS bad style";
+  case WSA_QOS_BAD_OBJECT:
+    return "QoS bad object";
+  case WSA_QOS_TRAFFIC_CTRL_ERROR:
+    return "QoS traffic control error";
+  case WSA_QOS_GENERIC_ERROR:
+    return "QoS generic error";
+  case WSA_QOS_ESERVICETYPE:
+    return "QoS service type error";
+  case WSA_QOS_EFLOWSPEC:
+    return "QoS flowspec error";
+  case WSA_QOS_EPROVSPECBUF:
+    return "Invalid QoS provider buffer";
+  case WSA_QOS_EFILTERSTYLE:
+    return "Invalid QoS filter style";
+  case WSA_QOS_EFILTERTYPE:
+    return "Invalid QoS filter type";
+  case WSA_QOS_EFILTERCOUNT:
+    return "Incorrect QoS filter count";
+  case WSA_QOS_EOBJLENGTH:
+    return "Invalid QoS object length";
+  case WSA_QOS_EFLOWCOUNT:
+    return "Incorrect QoS flow count";
+  case WSA_QOS_EUNKOWNPSOBJ:
+    return "Unrecognized QoS object";
+  case WSA_QOS_EPOLICYOBJ:
+    return "Invalid QoS policy object";
+  case WSA_QOS_EFLOWDESC:
+    return "Invalid QoS flow descriptor";
+  case WSA_QOS_EPSFLOWSPEC:
+    return "Invalid QoS provider-specific flowspec";
+  case WSA_QOS_EPSFILTERSPEC:
+    return "Invalid QoS provider-specific filterspec";
+  case WSA_QOS_ESDMODEOBJ:
+    return "Invalid QoS shape discard mode object";
+  case WSA_QOS_ESHAPERATEOBJ:
+    return "Invalid QoS shaping rate object";
+  case WSA_QOS_RESERVED_PETYPE:
+    return "Reserved policy QoS element type";
+    }
+  return "Unknown winsock error";
+}
+
+/**
+ * Set last winsock error to equivalent of given errno value
+ * @param errnum the errno value to set
+ */
+void MHD_W32_set_last_winsock_error_(int errnum)
+{
+  switch (errnum)
+    {
+  case 0:
+    WSASetLastError(0);
+    break;
+  case EBADF:
+    WSASetLastError(WSA_INVALID_HANDLE);
+    break;
+  case ENOMEM:
+    WSASetLastError(WSA_NOT_ENOUGH_MEMORY);
+    break;
+  case EINVAL:
+    WSASetLastError(WSA_INVALID_PARAMETER);
+    break;
+  case EINTR:
+    WSASetLastError(WSAEINTR);
+    break;
+  case EWOULDBLOCK:
+    WSASetLastError(WSAEWOULDBLOCK);
+    break;
+  case EINPROGRESS:
+    WSASetLastError(WSAEINPROGRESS);
+    break;
+  case EALREADY:
+    WSASetLastError(WSAEALREADY);
+    break;
+  case ENOTSOCK:
+    WSASetLastError(WSAENOTSOCK);
+    break;
+  case EDESTADDRREQ:
+    WSASetLastError(WSAEDESTADDRREQ);
+    break;
+  case EMSGSIZE:
+    WSASetLastError(WSAEMSGSIZE);
+    break;
+  case EPROTOTYPE:
+    WSASetLastError(WSAEPROTOTYPE);
+    break;
+  case ENOPROTOOPT:
+    WSASetLastError(WSAENOPROTOOPT);
+    break;
+  case EPROTONOSUPPORT:
+    WSASetLastError(WSAEPROTONOSUPPORT);
+    break;
+  case ESOCKTNOSUPPORT:
+    WSASetLastError(WSAESOCKTNOSUPPORT);
+    break;
+  case EOPNOTSUPP:
+    WSASetLastError(WSAEOPNOTSUPP);
+    break;
+  case EPFNOSUPPORT:
+    WSASetLastError(WSAEPFNOSUPPORT);
+    break;
+  case EAFNOSUPPORT:
+    WSASetLastError(WSAEAFNOSUPPORT);
+    break;
+  case EADDRINUSE:
+    WSASetLastError(WSAEADDRINUSE);
+    break;
+  case EADDRNOTAVAIL:
+    WSASetLastError(WSAEADDRNOTAVAIL);
+    break;
+  case ENETDOWN:
+    WSASetLastError(WSAENETDOWN);
+    break;
+  case ENETUNREACH:
+    WSASetLastError(WSAENETUNREACH);
+    break;
+  case ENETRESET:
+    WSASetLastError(WSAENETRESET);
+    break;
+  case ECONNABORTED:
+    WSASetLastError(WSAECONNABORTED);
+    break;
+  case ECONNRESET:
+    WSASetLastError(WSAECONNRESET);
+    break;
+  case ENOBUFS:
+    WSASetLastError(WSAENOBUFS);
+    break;
+  case EISCONN:
+    WSASetLastError(WSAEISCONN);
+    break;
+  case ENOTCONN:
+    WSASetLastError(WSAENOTCONN);
+    break;
+  case ESHUTDOWN:
+    WSASetLastError(WSAESHUTDOWN);
+    break;
+  case ETOOMANYREFS:
+    WSASetLastError(WSAETOOMANYREFS);
+    break;
+  case ETIMEDOUT:
+    WSASetLastError(WSAETIMEDOUT);
+    break;
+  case ECONNREFUSED:
+    WSASetLastError(WSAECONNREFUSED);
+    break;
+  case ELOOP:
+    WSASetLastError(WSAELOOP);
+    break;
+  case ENAMETOOLONG:
+    WSASetLastError(WSAENAMETOOLONG);
+    break;
+  case EHOSTDOWN:
+    WSASetLastError(WSAEHOSTDOWN);
+    break;
+  case EHOSTUNREACH:
+    WSASetLastError(WSAEHOSTUNREACH);
+    break;
+  case ENOTEMPTY:
+    WSASetLastError(WSAENOTEMPTY);
+    break;
+  case EPROCLIM:
+    WSASetLastError(WSAEPROCLIM);
+    break;
+  case EUSERS:
+    WSASetLastError(WSAEUSERS);
+    break;
+  case EDQUOT:
+    WSASetLastError(WSAEDQUOT);
+    break;
+  case ESTALE:
+    WSASetLastError(WSAESTALE);
+    break;
+  case EREMOTE:
+    WSASetLastError(WSAEREMOTE);
+    break;
+  case EFAULT:
+    WSASetLastError(WSAEFAULT);
+    break;
+  case ENODATA:
+    WSASetLastError(WSANO_DATA);
+    break;
+#if EAGAIN != EWOULDBLOCK
+  case EAGAIN:
+    WSASetLastError(WSAEWOULDBLOCK);
+    break;
+#endif
+  /* Rough equivalent */
+  case EIO:
+    WSASetLastError(WSAEREFUSED);
+    break;
+
+  default: /* Unmapped errors */
+    WSASetLastError(WSAENOBUFS);
+    break;
+    }
+}
+
+#endif /* MHD_WINSOCK_SOCKETS */

Added: libmicrohttpd/src/microhttpd/mhd_sockets.h
===================================================================
--- libmicrohttpd/src/microhttpd/mhd_sockets.h                          (rev 0)
+++ libmicrohttpd/src/microhttpd/mhd_sockets.h  2016-08-23 20:12:50 UTC (rev 
37762)
@@ -0,0 +1,406 @@
+/*
+  This file is part of libmicrohttpd
+  Copyright (C) 2014-2016 Karlson2k (Evgeny Grin)
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+
+*/
+
+/**
+ * @file microhttpd/mhd_sockets.c
+ * @brief  Header for platform-independent sockets abstraction
+ * @author Karlson2k (Evgeny Grin)
+ *
+ * Provides basic abstraction for sockets.
+ * Any functions can be implemented as macro on some platforms
+ * unless explicitly marked otherwise.
+ * Any function argument can be skipped in macro, so avoid
+ * variable modification in function parameters.
+ */
+
+#ifndef MHD_SOCKETS_H
+#define MHD_SOCKETS_H 1
+#include "mhd_options.h"
+
+#include <errno.h>
+
+#if !defined(MHD_POSIX_SOCKETS) && !defined(MHD_WINSOCK_SOCKETS)
+#  if !defined(_WIN32) || defined(__CYGWIN__)
+#    define MHD_POSIX_SOCKETS 1
+#  else  /* defined(_WIN32) && !defined(__CYGWIN__) */
+#    define MHD_WINSOCK_SOCKETS 1
+#  endif /* defined(_WIN32) && !defined(__CYGWIN__) */
+#endif /* !MHD_POSIX_SOCKETS && !MHD_WINSOCK_SOCKETS */
+
+/*
+ * MHD require headers that define socket type, socket basic functions
+ * (socket(), accept(), listen(), bind(), send(), recv(), select()), socket
+ * parameters like SOCK_CLOEXEC, SOCK_NONBLOCK, additional socket functions
+ * (poll(), epoll(), accept4()), struct timeval and other types, required
+ * for socket function.
+ */
+#if defined(MHD_POSIX_SOCKETS)
+#  if HAVE_SYS_SOCKET_H
+#    include <sys/socket.h>
+#  endif
+#  if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS)
+#    ifdef HAVE_SOCKLIB_H
+#      include <sockLib.h>
+#    endif /* HAVE_SOCKLIB_H */
+#    ifdef HAVE_INETLIB_H
+#      include <inetLib.h>
+#    endif /* HAVE_INETLIB_H */
+#    include <strings.h>  /* required for FD_SET (bzero() function) */
+#  endif /* __VXWORKS__ || __vxworks || OS_VXWORKS */
+#  ifdef HAVE_NETINET_IN_H
+#    include <netinet/in.h>
+#  endif /* HAVE_NETINET_IN_H */
+#  if HAVE_ARPA_INET_H
+#    include <arpa/inet.h>
+#  endif
+#  ifdef HAVE_NET_IF_H
+#    include <net/if.h>
+#  endif
+#  if HAVE_SYS_TIME_H
+#    include <sys/time.h>
+#  endif
+#  if HAVE_TIME_H
+#    include <time.h>
+#  endif
+#  if HAVE_NETDB_H
+#    include <netdb.h>
+#  endif
+#  if HAVE_SYS_SELECT_H
+#    include <sys/select.h>
+#  endif
+#  if EPOLL_SUPPORT
+#    include <sys/epoll.h>
+#  endif
+#  if HAVE_NETINET_TCP_H
+     /* for TCP_FASTOPEN and TCP_CORK */
+#    include <netinet/tcp.h>
+#  endif
+#  ifdef HAVE_STRING_H
+#    include <string.h> /* for strerror() */
+#  endif
+#  if defined(HAVE_SYS_TYPES_H)
+#    include <sys/types.h> /* required on old platforms */
+#  endif /* (!HAVE_SYS_SOCKET_H || !HAVE_SYS_SOCKET_H) && HAVE_SYS_TYPES_H */
+#elif defined(MHD_WINSOCK_SOCKETS)
+#  ifndef WIN32_LEAN_AND_MEAN
+#    define WIN32_LEAN_AND_MEAN 1
+#  endif /* !WIN32_LEAN_AND_MEAN */
+#  include <winsock2.h>
+#  include <ws2tcpip.h>
+#endif /* MHD_WINSOCK_SOCKETS */
+
+#if defined(HAVE_POLL_H) && defined(HAVE_POLL)
+#  include <poll.h>
+#endif
+
+#ifdef _MHD_FD_SETSIZE_IS_DEFAULT
+#  define _MHD_SYS_DEFAULT_FD_SETSIZE FD_SETSIZE
+#else  /* ! _MHD_FD_SETSIZE_IS_DEFAULT */
+#  include "sysfdsetsize.h"
+#  define _MHD_SYS_DEFAULT_FD_SETSIZE get_system_fdsetsize_value()
+#endif /* ! _MHD_FD_SETSIZE_IS_DEFAULT */
+
+#ifndef MHD_SOCKET_DEFINED
+/**
+ * MHD_socket is type for socket FDs
+ */
+#  if defined(MHD_POSIX_SOCKETS)
+     typedef int MHD_socket;
+#    define MHD_INVALID_SOCKET (-1)
+#  elif defined(MHD_WINSOCK_SOCKETS)
+     typedef SOCKET MHD_socket;
+#    define MHD_INVALID_SOCKET (INVALID_SOCKET)
+#  endif /* MHD_WINSOCK_SOCKETS */
+
+#  define MHD_SOCKET_DEFINED 1
+#endif /* ! MHD_SOCKET_DEFINED */
+
+#ifdef SOCK_CLOEXEC
+#  define MAYBE_SOCK_CLOEXEC SOCK_CLOEXEC
+#else  /* ! SOCK_CLOEXEC */
+#  define MAYBE_SOCK_CLOEXEC 0
+#endif /* ! SOCK_CLOEXEC */
+
+#ifdef HAVE_SOCK_NONBLOCK
+#  define MAYBE_SOCK_NONBLOCK SOCK_NONBLOCK
+#else  /* ! HAVE_SOCK_NONBLOCK */
+#  define MAYBE_SOCK_NONBLOCK 0
+#endif /* ! HAVE_SOCK_NONBLOCK */
+
+#if !defined(SHUT_WR) && defined(SD_SEND)
+#  define SHUT_WR SD_SEND
+#endif
+#if !defined(SHUT_RD) && defined(SD_RECEIVE)
+#  define SHUT_RD SD_RECEIVE
+#endif
+#if !defined(SHUT_RDWR) && defined(SD_BOTH)
+#  define SHUT_RDWR SD_BOTH
+#endif
+
+#if HAVE_ACCEPT4+0 != 0 && (defined(HAVE_SOCK_NONBLOCK) || 
defined(SOCK_CLOEXEC))
+#  define USE_ACCEPT4 1
+#endif
+
+#if defined(HAVE_EPOLL_CREATE1) && defined(EPOLL_CLOEXEC)
+#  define USE_EPOLL_CREATE1 1
+#endif /* HAVE_EPOLL_CREATE1 && EPOLL_CLOEXEC */
+
+#ifdef TCP_FASTOPEN
+/**
+ * Default TCP fastopen queue size.
+ */
+#define MHD_TCP_FASTOPEN_QUEUE_SIZE_DEFAULT 10
+#endif
+
+
+/**
+ * _MHD_SOCKOPT_BOOL_TYPE is type for bool parameters for 
setsockopt()/getsockopt()
+ */
+#ifdef MHD_POSIX_SOCKETS
+  typedef int _MHD_SOCKOPT_BOOL_TYPE;
+#else /* MHD_WINSOCK_SOCKETS */
+  typedef BOOL _MHD_SOCKOPT_BOOL_TYPE;
+#endif /* MHD_WINSOCK_SOCKETS */
+
+/**
+ * _MHD_socket_funcs_size is type used to specify size for send and recv
+ * functions
+ */
+#if !defined(MHD_WINSOCK_SOCKETS)
+  typedef size_t _MHD_socket_funcs_size;
+#else
+  typedef int _MHD_socket_funcs_size;
+#endif
+
+/**
+ * MHD_socket_close_(fd) close any FDs (non-W32) / close only socket
+ * FDs (W32).  Note that on HP-UNIX, this function may leak the FD if
+ * errno is set to EINTR.  Do not use HP-UNIX.
+ *
+ * @param fd descriptor to close
+ * @return 0 on success (error codes like EINTR and EIO are counted as success,
+ *           only EBADF counts as an error!)
+ */
+#if !defined(MHD_WINSOCK_SOCKETS)
+#  define MHD_socket_close_(fd) (((0 != close(fd)) && (EBADF == errno)) ? -1 : 
0)
+#else
+#  define MHD_socket_close_(fd) closesocket((fd))
+#endif
+
+/**
+ * MHD_socket_errno_ is errno of last function (non-W32) / errno of
+ * last socket function (W32)
+ */
+#if !defined(MHD_WINSOCK_SOCKETS)
+#  define MHD_socket_errno_ errno
+#else
+#  define MHD_socket_errno_ MHD_W32_errno_from_winsock_()
+#endif
+
+ /* MHD_socket_last_strerr_ is description string of last errno (non-W32) /
+  *                            description string of last socket error (W32) */
+#if !defined(MHD_WINSOCK_SOCKETS)
+#  define MHD_socket_last_strerr_() strerror(errno)
+#else
+#  define MHD_socket_last_strerr_() MHD_W32_strerror_last_winsock_()
+#endif
+
+ /* MHD_strerror_ is strerror (both non-W32/W32) */
+#if !defined(MHD_WINSOCK_SOCKETS)
+#  define MHD_strerror_(errnum) strerror((errnum))
+#else
+#  define MHD_strerror_(errnum) MHD_W32_strerror_((errnum))
+#endif
+
+ /* MHD_set_socket_errno_ set errno to errnum (non-W32) / set socket last 
error to errnum (W32) */
+#if !defined(MHD_WINSOCK_SOCKETS)
+#  define MHD_set_socket_errno_(errnum) errno=(errnum)
+#else
+#  define MHD_set_socket_errno_(errnum) 
MHD_W32_set_last_winsock_error_((errnum))
+#endif
+
+ /* MHD_SYS_select_ is wrapper macro for system select() function */
+#if !defined(MHD_WINSOCK_SOCKETS)
+#  define MHD_SYS_select_(n,r,w,e,t) select((n),(r),(w),(e),(t))
+#else
+#  define MHD_SYS_select_(n,r,w,e,t) \
+( (!(r) || ((fd_set*)(r))->fd_count == 0) && \
+  (!(w) || ((fd_set*)(w))->fd_count == 0) && \
+  (!(e) || ((fd_set*)(e))->fd_count == 0) ) ? \
+( (t) ? (Sleep((t)->tv_sec * 1000 + (t)->tv_usec / 1000), 0) : 0 ) : \
+  (select((int)0,(r),(w),(e),(t)))
+#endif
+
+#if defined(HAVE_POLL)
+/* MHD_sys_poll_ is wrapper macro for system poll() function */
+#  if !defined(MHD_WINSOCK_SOCKETS)
+#    define MHD_sys_poll_ poll
+#  else  /* MHD_WINSOCK_SOCKETS */
+#    define MHD_sys_poll_ WSAPoll
+#  endif /* MHD_WINSOCK_SOCKETS */
+#endif /* HAVE_POLL */
+
+
+#ifdef MHD_WINSOCK_SOCKETS
+
+/* POSIX-W32 compatibility functions and macros */
+
+#  define MHDW32ERRBASE 3300
+
+#  ifndef EWOULDBLOCK
+#    define EWOULDBLOCK (MHDW32ERRBASE+1)
+#  endif
+#  ifndef EINPROGRESS
+#    define EINPROGRESS (MHDW32ERRBASE+2)
+#  endif
+#  ifndef EALREADY
+#    define EALREADY (MHDW32ERRBASE+3)
+#  endif
+#  ifndef ENOTSOCK
+#    define ENOTSOCK (MHDW32ERRBASE+4)
+#  endif
+#  ifndef EDESTADDRREQ
+#    define EDESTADDRREQ (MHDW32ERRBASE+5)
+#  endif
+#  ifndef EMSGSIZE
+#    define EMSGSIZE (MHDW32ERRBASE+6)
+#  endif
+#  ifndef EPROTOTYPE
+#    define EPROTOTYPE (MHDW32ERRBASE+7)
+#  endif
+#  ifndef ENOPROTOOPT
+#    define ENOPROTOOPT (MHDW32ERRBASE+8)
+#  endif
+#  ifndef EPROTONOSUPPORT
+#    define EPROTONOSUPPORT (MHDW32ERRBASE+9)
+#  endif
+#  ifndef EOPNOTSUPP
+#    define EOPNOTSUPP (MHDW32ERRBASE+10)
+#  endif
+#  ifndef EAFNOSUPPORT
+#    define EAFNOSUPPORT (MHDW32ERRBASE+11)
+#  endif
+#  ifndef EADDRINUSE
+#    define EADDRINUSE (MHDW32ERRBASE+12)
+#  endif
+#  ifndef EADDRNOTAVAIL
+#    define EADDRNOTAVAIL (MHDW32ERRBASE+13)
+#  endif
+#  ifndef ENETDOWN
+#    define ENETDOWN (MHDW32ERRBASE+14)
+#  endif
+#  ifndef ENETUNREACH
+#    define ENETUNREACH (MHDW32ERRBASE+15)
+#  endif
+#  ifndef ENETRESET
+#    define ENETRESET (MHDW32ERRBASE+16)
+#  endif
+#  ifndef ECONNABORTED
+#    define ECONNABORTED (MHDW32ERRBASE+17)
+#  endif
+#  ifndef ECONNRESET
+#    define ECONNRESET (MHDW32ERRBASE+18)
+#  endif
+#  ifndef ENOBUFS
+#    define ENOBUFS (MHDW32ERRBASE+19)
+#  endif
+#  ifndef EISCONN
+#    define EISCONN (MHDW32ERRBASE+20)
+#  endif
+#  ifndef ENOTCONN
+#    define ENOTCONN (MHDW32ERRBASE+21)
+#  endif
+#  ifndef ETOOMANYREFS
+#    define ETOOMANYREFS (MHDW32ERRBASE+22)
+#  endif
+#  ifndef ECONNREFUSED
+#    define ECONNREFUSED (MHDW32ERRBASE+23)
+#  endif
+#  ifndef ELOOP
+#    define ELOOP (MHDW32ERRBASE+24)
+#  endif
+#  ifndef EHOSTDOWN
+#    define EHOSTDOWN (MHDW32ERRBASE+25)
+#  endif
+#  ifndef EHOSTUNREACH
+#    define EHOSTUNREACH (MHDW32ERRBASE+26)
+#  endif
+#  ifndef EPROCLIM
+#    define EPROCLIM (MHDW32ERRBASE+27)
+#  endif
+#  ifndef EUSERS
+#    define EUSERS (MHDW32ERRBASE+28)
+#  endif
+#  ifndef EDQUOT
+#    define EDQUOT (MHDW32ERRBASE+29)
+#  endif
+#  ifndef ESTALE
+#    define ESTALE (MHDW32ERRBASE+30)
+#  endif
+#  ifndef EREMOTE
+#    define EREMOTE (MHDW32ERRBASE+31)
+#  endif
+#  ifndef ESOCKTNOSUPPORT
+#    define ESOCKTNOSUPPORT (MHDW32ERRBASE+32)
+#  endif
+#  ifndef EPFNOSUPPORT
+#    define EPFNOSUPPORT (MHDW32ERRBASE+33)
+#  endif
+#  ifndef ESHUTDOWN
+#    define ESHUTDOWN (MHDW32ERRBASE+34)
+#  endif
+#  ifndef ENODATA
+#    define ENODATA (MHDW32ERRBASE+35)
+#  endif
+#  ifndef ETIMEDOUT
+#    define ETIMEDOUT (MHDW32ERRBASE+36)
+#  endif
+
+/**
+ * Return errno equivalent of last winsock error
+ * @return errno equivalent of last winsock error
+ */
+  int MHD_W32_errno_from_winsock_(void);
+
+/**
+ * Return pointer to string description of errnum error
+ * Works fine with both standard errno errnums
+ * and errnums from MHD_W32_errno_from_winsock_
+ * @param errnum the errno or value from MHD_W32_errno_from_winsock_()
+ * @return pointer to string description of error
+ */
+  const char* MHD_W32_strerror_(int errnum);
+
+/**
+ * Return pointer to string description of last winsock error
+ * @return pointer to string description of last winsock error
+ */
+  const char* MHD_W32_strerror_last_winsock_(void);
+
+/**
+ * Set last winsock error to equivalent of given errno value
+ * @param errnum the errno value to set
+ */
+  void MHD_W32_set_last_winsock_error_(int errnum);
+
+
+#endif /* MHD_WINSOCK_SOCKETS */
+
+#endif /* ! MHD_SOCKETS_H */

Modified: libmicrohttpd/src/microhttpd/sysfdsetsize.c
===================================================================
--- libmicrohttpd/src/microhttpd/sysfdsetsize.c 2016-08-23 15:43:38 UTC (rev 
37761)
+++ libmicrohttpd/src/microhttpd/sysfdsetsize.c 2016-08-23 20:12:50 UTC (rev 
37762)
@@ -34,7 +34,7 @@
 #endif /* FD_SETSIZE */
 
 #include <stdlib.h>
-#ifdef OS_VXWORKS
+#if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS)
 #include <sockLib.h>
 #endif /* OS_VXWORKS */
 #if HAVE_SYS_SELECT_H

Modified: libmicrohttpd/src/microhttpd/test_shutdown_select.c
===================================================================
--- libmicrohttpd/src/microhttpd/test_shutdown_select.c 2016-08-23 15:43:38 UTC 
(rev 37761)
+++ libmicrohttpd/src/microhttpd/test_shutdown_select.c 2016-08-23 20:12:50 UTC 
(rev 37762)
@@ -30,8 +30,8 @@
  */
 
 #include "MHD_config.h"
-#include "platform_interface.h"
 #include "platform.h"
+#include "mhd_sockets.h"
 #include <stdlib.h>
 #include <stdio.h>
 

Modified: libmicrohttpd/src/platform/w32functions.c
===================================================================
--- libmicrohttpd/src/platform/w32functions.c   2016-08-23 15:43:38 UTC (rev 
37761)
+++ libmicrohttpd/src/platform/w32functions.c   2016-08-23 20:12:50 UTC (rev 
37762)
@@ -31,523 +31,9 @@
 #include <time.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include "../microhttpd/mhd_sockets.h"
 
-
 /**
- * Return errno equivalent of last winsock error
- * @return errno equivalent of last winsock error
- */
-int MHD_W32_errno_from_winsock_(void)
-{
-  switch(WSAGetLastError())
-  {
-  case 0:                      return 0;
-  case WSA_INVALID_HANDLE:     return EBADF;
-  case WSA_NOT_ENOUGH_MEMORY:  return ENOMEM;
-  case WSA_INVALID_PARAMETER:  return EINVAL;
-  case WSAEINTR:               return EINTR;
-  case WSAEWOULDBLOCK:         return EWOULDBLOCK;
-  case WSAEINPROGRESS:         return EINPROGRESS;
-  case WSAEALREADY:            return EALREADY;
-  case WSAENOTSOCK:            return ENOTSOCK;
-  case WSAEDESTADDRREQ:        return EDESTADDRREQ;
-  case WSAEMSGSIZE:            return EMSGSIZE;
-  case WSAEPROTOTYPE:          return EPROTOTYPE;
-  case WSAENOPROTOOPT:         return ENOPROTOOPT;
-  case WSAEPROTONOSUPPORT:     return EPROTONOSUPPORT;
-  case WSAESOCKTNOSUPPORT:     return ESOCKTNOSUPPORT;
-  case WSAEOPNOTSUPP:          return EOPNOTSUPP;
-  case WSAEPFNOSUPPORT:        return EPFNOSUPPORT;
-  case WSAEAFNOSUPPORT:        return EAFNOSUPPORT;
-  case WSAEADDRINUSE:          return EADDRINUSE;
-  case WSAEADDRNOTAVAIL:       return EADDRNOTAVAIL;
-  case WSAENETDOWN:            return ENETDOWN;
-  case WSAENETUNREACH:         return ENETUNREACH;
-  case WSAENETRESET:           return ENETRESET;
-  case WSAECONNABORTED:        return ECONNABORTED;
-  case WSAECONNRESET:          return ECONNRESET;
-  case WSAENOBUFS:             return ENOBUFS;
-  case WSAEISCONN:             return EISCONN;
-  case WSAENOTCONN:            return ENOTCONN;
-  case WSAESHUTDOWN:           return ESHUTDOWN;
-  case WSAETOOMANYREFS:        return ETOOMANYREFS;
-  case WSAETIMEDOUT:           return ETIMEDOUT;
-  case WSAECONNREFUSED:        return ECONNREFUSED;
-  case WSAELOOP:               return ELOOP;
-  case WSAENAMETOOLONG:        return ENAMETOOLONG;
-  case WSAEHOSTDOWN:           return EHOSTDOWN;
-  case WSAEHOSTUNREACH:        return EHOSTUNREACH;
-  case WSAENOTEMPTY:           return ENOTEMPTY;
-  case WSAEPROCLIM:            return EPROCLIM;
-  case WSAEUSERS:              return EUSERS;
-  case WSAEDQUOT:              return EDQUOT;
-  case WSAESTALE:              return ESTALE;
-  case WSAEREMOTE:             return EREMOTE;
-  case WSAEINVAL:              return EINVAL;
-  case WSAEFAULT:              return EFAULT;
-  case WSANO_DATA:             return ENODATA;
-  /* Rough equivalents */
-  case WSAEDISCON:             return ECONNRESET;
-  case WSAEINVALIDPROCTABLE:   return EFAULT;
-  case WSASYSNOTREADY:
-  case WSANOTINITIALISED:
-  case WSASYSCALLFAILURE:      return ENOBUFS;
-  case WSAVERNOTSUPPORTED:     return EOPNOTSUPP;
-  case WSAEREFUSED:            return EIO;
-  }
-  return EINVAL;
-}
-
-/**
- * Return pointer to string description of errnum error
- * Works fine with both standard errno errnums
- * and errnums from MHD_W32_errno_from_winsock_
- * @param errnum the errno or value from MHD_W32_errno_from_winsock_()
- * @return pointer to string description of error
- */
-const char* MHD_W32_strerror_(int errnum)
-{
-  switch(errnum)
-  {
-  case 0:
-    return "No error";
-  case EWOULDBLOCK:
-    return "Operation would block";
-  case EINPROGRESS:
-    return "Connection already in progress";
-  case EALREADY:
-    return "Socket already connected";
-  case ENOTSOCK:
-    return "Socket operation on non-socket";
-  case EDESTADDRREQ:
-    return "Destination address required";
-  case EMSGSIZE:
-    return "Message too long";
-  case EPROTOTYPE:
-    return "Protocol wrong type for socket";
-  case ENOPROTOOPT:
-    return "Protocol not available";
-  case EPROTONOSUPPORT:
-    return "Unknown protocol";
-  case ESOCKTNOSUPPORT:
-    return "Socket type not supported";
-  case EOPNOTSUPP:
-    return "Operation not supported on socket";
-  case EPFNOSUPPORT:
-    return "Protocol family not supported";
-  case EAFNOSUPPORT:
-    return "Address family not supported by protocol family";
-  case EADDRINUSE:
-    return "Address already in use";
-  case EADDRNOTAVAIL:
-    return "Cannot assign requested address";
-  case ENETDOWN:
-    return "Network is down";
-  case ENETUNREACH:
-    return "Network is unreachable";
-  case ENETRESET:
-    return "Network dropped connection on reset";
-  case ECONNABORTED:
-    return "Software caused connection abort";
-  case ECONNRESET:
-    return "Connection reset by peer";
-  case ENOBUFS:
-    return "No system resources available";
-  case EISCONN:
-    return "Socket is already connected";
-  case ENOTCONN:
-    return "Socket is not connected";
-  case ESHUTDOWN:
-    return "Can't send after socket shutdown";
-  case ETOOMANYREFS:
-    return "Too many references: cannot splice";
-  case ETIMEDOUT:
-    return "Connection timed out";
-  case ECONNREFUSED:
-    return "Connection refused";
-  case ELOOP:
-    return "Cannot translate name";
-  case EHOSTDOWN:
-    return "Host is down";
-  case EHOSTUNREACH:
-    return "Host is unreachable";
-  case EPROCLIM:
-    return "Too many processes";
-  case EUSERS:
-    return "Too many users";
-  case EDQUOT:
-    return "Disk quota exceeded";
-  case ESTALE:
-    return "Stale file handle reference";
-  case EREMOTE:
-    return "Resource is remote";
-  case ENODATA:
-    return "No data available";
-  }
-  return strerror(errnum);
-}
-
-/**
- * Return pointer to string description of last winsock error
- * @return pointer to string description of last winsock error
- */
-const char* MHD_W32_strerror_last_winsock_(void)
-{
-  switch (WSAGetLastError())
-    {
-  case 0:
-    return "No error";
-  case WSA_INVALID_HANDLE:
-    return "Specified event object handle is invalid";
-  case WSA_NOT_ENOUGH_MEMORY:
-    return "Insufficient memory available";
-  case WSA_INVALID_PARAMETER:
-    return "One or more parameters are invalid";
-  case WSA_OPERATION_ABORTED:
-    return "Overlapped operation aborted";
-  case WSA_IO_INCOMPLETE:
-    return "Overlapped I/O event object not in signaled state";
-  case WSA_IO_PENDING:
-    return "Overlapped operations will complete later";
-  case WSAEINTR:
-    return "Interrupted function call";
-  case WSAEBADF:
-    return "File handle is not valid";
-  case WSAEACCES:
-    return "Permission denied";
-  case WSAEFAULT:
-    return "Bad address";
-  case WSAEINVAL:
-    return "Invalid argument";
-  case WSAEMFILE:
-    return "Too many open files";
-  case WSAEWOULDBLOCK:
-    return "Resource temporarily unavailable";
-  case WSAEINPROGRESS:
-    return "Operation now in progress";
-  case WSAEALREADY:
-    return "Operation already in progress";
-  case WSAENOTSOCK:
-    return "Socket operation on nonsocket";
-  case WSAEDESTADDRREQ:
-    return "Destination address required";
-  case WSAEMSGSIZE:
-    return "Message too long";
-  case WSAEPROTOTYPE:
-    return "Protocol wrong type for socket";
-  case WSAENOPROTOOPT:
-    return "Bad protocol option";
-  case WSAEPROTONOSUPPORT:
-    return "Protocol not supported";
-  case WSAESOCKTNOSUPPORT:
-    return "Socket type not supported";
-  case WSAEOPNOTSUPP:
-    return "Operation not supported";
-  case WSAEPFNOSUPPORT:
-    return "Protocol family not supported";
-  case WSAEAFNOSUPPORT:
-    return "Address family not supported by protocol family";
-  case WSAEADDRINUSE:
-    return "Address already in use";
-  case WSAEADDRNOTAVAIL:
-    return "Cannot assign requested address";
-  case WSAENETDOWN:
-    return "Network is down";
-  case WSAENETUNREACH:
-    return "Network is unreachable";
-  case WSAENETRESET:
-    return "Network dropped connection on reset";
-  case WSAECONNABORTED:
-    return "Software caused connection abort";
-  case WSAECONNRESET:
-    return "Connection reset by peer";
-  case WSAENOBUFS:
-    return "No buffer space available";
-  case WSAEISCONN:
-    return "Socket is already connected";
-  case WSAENOTCONN:
-    return "Socket is not connected";
-  case WSAESHUTDOWN:
-    return "Cannot send after socket shutdown";
-  case WSAETOOMANYREFS:
-    return "Too many references";
-  case WSAETIMEDOUT:
-    return "Connection timed out";
-  case WSAECONNREFUSED:
-    return "Connection refused";
-  case WSAELOOP:
-    return "Cannot translate name";
-  case WSAENAMETOOLONG:
-    return "Name too long";
-  case WSAEHOSTDOWN:
-    return "Host is down";
-  case WSAEHOSTUNREACH:
-    return "No route to host";
-  case WSAENOTEMPTY:
-    return "Directory not empty";
-  case WSAEPROCLIM:
-    return "Too many processes";
-  case WSAEUSERS:
-    return "User quota exceeded";
-  case WSAEDQUOT:
-    return "Disk quota exceeded";
-  case WSAESTALE:
-    return "Stale file handle reference";
-  case WSAEREMOTE:
-    return "Item is remote";
-  case WSASYSNOTREADY:
-    return "Network subsystem is unavailable";
-  case WSAVERNOTSUPPORTED:
-    return "Winsock.dll version out of range";
-  case WSANOTINITIALISED:
-    return "Successful WSAStartup not yet performed";
-  case WSAEDISCON:
-    return "Graceful shutdown in progress";
-  case WSAENOMORE:
-    return "No more results";
-  case WSAECANCELLED:
-    return "Call has been canceled";
-  case WSAEINVALIDPROCTABLE:
-    return "Procedure call table is invalid";
-  case WSAEINVALIDPROVIDER:
-    return "Service provider is invalid";
-  case WSAEPROVIDERFAILEDINIT:
-    return "Service provider failed to initialize";
-  case WSASYSCALLFAILURE:
-    return "System call failure";
-  case WSASERVICE_NOT_FOUND:
-    return "Service not found";
-  case WSATYPE_NOT_FOUND:
-    return "Class type not found";
-  case WSA_E_NO_MORE:
-    return "No more results";
-  case WSA_E_CANCELLED:
-    return "Call was canceled";
-  case WSAEREFUSED:
-    return "Database query was refused";
-  case WSAHOST_NOT_FOUND:
-    return "Host not found";
-  case WSATRY_AGAIN:
-    return "Nonauthoritative host not found";
-  case WSANO_RECOVERY:
-    return "This is a nonrecoverable error";
-  case WSANO_DATA:
-    return "Valid name, no data record of requested type";
-  case WSA_QOS_RECEIVERS:
-    return "QoS receivers";
-  case WSA_QOS_SENDERS:
-    return "QoS senders";
-  case WSA_QOS_NO_SENDERS:
-    return "No QoS senders";
-  case WSA_QOS_NO_RECEIVERS:
-    return "QoS no receivers";
-  case WSA_QOS_REQUEST_CONFIRMED:
-    return "QoS request confirmed";
-  case WSA_QOS_ADMISSION_FAILURE:
-    return "QoS admission error";
-  case WSA_QOS_POLICY_FAILURE:
-    return "QoS policy failure";
-  case WSA_QOS_BAD_STYLE:
-    return "QoS bad style";
-  case WSA_QOS_BAD_OBJECT:
-    return "QoS bad object";
-  case WSA_QOS_TRAFFIC_CTRL_ERROR:
-    return "QoS traffic control error";
-  case WSA_QOS_GENERIC_ERROR:
-    return "QoS generic error";
-  case WSA_QOS_ESERVICETYPE:
-    return "QoS service type error";
-  case WSA_QOS_EFLOWSPEC:
-    return "QoS flowspec error";
-  case WSA_QOS_EPROVSPECBUF:
-    return "Invalid QoS provider buffer";
-  case WSA_QOS_EFILTERSTYLE:
-    return "Invalid QoS filter style";
-  case WSA_QOS_EFILTERTYPE:
-    return "Invalid QoS filter type";
-  case WSA_QOS_EFILTERCOUNT:
-    return "Incorrect QoS filter count";
-  case WSA_QOS_EOBJLENGTH:
-    return "Invalid QoS object length";
-  case WSA_QOS_EFLOWCOUNT:
-    return "Incorrect QoS flow count";
-  case WSA_QOS_EUNKOWNPSOBJ:
-    return "Unrecognized QoS object";
-  case WSA_QOS_EPOLICYOBJ:
-    return "Invalid QoS policy object";
-  case WSA_QOS_EFLOWDESC:
-    return "Invalid QoS flow descriptor";
-  case WSA_QOS_EPSFLOWSPEC:
-    return "Invalid QoS provider-specific flowspec";
-  case WSA_QOS_EPSFILTERSPEC:
-    return "Invalid QoS provider-specific filterspec";
-  case WSA_QOS_ESDMODEOBJ:
-    return "Invalid QoS shape discard mode object";
-  case WSA_QOS_ESHAPERATEOBJ:
-    return "Invalid QoS shaping rate object";
-  case WSA_QOS_RESERVED_PETYPE:
-    return "Reserved policy QoS element type";
-    }
-  return "Unknown winsock error";
-}
-
-/**
- * Set last winsock error to equivalent of given errno value
- * @param errnum the errno value to set
- */
-void MHD_W32_set_last_winsock_error_(int errnum)
-{
-  switch (errnum)
-    {
-  case 0:
-    WSASetLastError(0);
-    break;
-  case EBADF:
-    WSASetLastError(WSA_INVALID_HANDLE);
-    break;
-  case ENOMEM:
-    WSASetLastError(WSA_NOT_ENOUGH_MEMORY);
-    break;
-  case EINVAL:
-    WSASetLastError(WSA_INVALID_PARAMETER);
-    break;
-  case EINTR:
-    WSASetLastError(WSAEINTR);
-    break;
-  case EWOULDBLOCK:
-    WSASetLastError(WSAEWOULDBLOCK);
-    break;
-  case EINPROGRESS:
-    WSASetLastError(WSAEINPROGRESS);
-    break;
-  case EALREADY:
-    WSASetLastError(WSAEALREADY);
-    break;
-  case ENOTSOCK:
-    WSASetLastError(WSAENOTSOCK);
-    break;
-  case EDESTADDRREQ:
-    WSASetLastError(WSAEDESTADDRREQ);
-    break;
-  case EMSGSIZE:
-    WSASetLastError(WSAEMSGSIZE);
-    break;
-  case EPROTOTYPE:
-    WSASetLastError(WSAEPROTOTYPE);
-    break;
-  case ENOPROTOOPT:
-    WSASetLastError(WSAENOPROTOOPT);
-    break;
-  case EPROTONOSUPPORT:
-    WSASetLastError(WSAEPROTONOSUPPORT);
-    break;
-  case ESOCKTNOSUPPORT:
-    WSASetLastError(WSAESOCKTNOSUPPORT);
-    break;
-  case EOPNOTSUPP:
-    WSASetLastError(WSAEOPNOTSUPP);
-    break;
-  case EPFNOSUPPORT:
-    WSASetLastError(WSAEPFNOSUPPORT);
-    break;
-  case EAFNOSUPPORT:
-    WSASetLastError(WSAEAFNOSUPPORT);
-    break;
-  case EADDRINUSE:
-    WSASetLastError(WSAEADDRINUSE);
-    break;
-  case EADDRNOTAVAIL:
-    WSASetLastError(WSAEADDRNOTAVAIL);
-    break;
-  case ENETDOWN:
-    WSASetLastError(WSAENETDOWN);
-    break;
-  case ENETUNREACH:
-    WSASetLastError(WSAENETUNREACH);
-    break;
-  case ENETRESET:
-    WSASetLastError(WSAENETRESET);
-    break;
-  case ECONNABORTED:
-    WSASetLastError(WSAECONNABORTED);
-    break;
-  case ECONNRESET:
-    WSASetLastError(WSAECONNRESET);
-    break;
-  case ENOBUFS:
-    WSASetLastError(WSAENOBUFS);
-    break;
-  case EISCONN:
-    WSASetLastError(WSAEISCONN);
-    break;
-  case ENOTCONN:
-    WSASetLastError(WSAENOTCONN);
-    break;
-  case ESHUTDOWN:
-    WSASetLastError(WSAESHUTDOWN);
-    break;
-  case ETOOMANYREFS:
-    WSASetLastError(WSAETOOMANYREFS);
-    break;
-  case ETIMEDOUT:
-    WSASetLastError(WSAETIMEDOUT);
-    break;
-  case ECONNREFUSED:
-    WSASetLastError(WSAECONNREFUSED);
-    break;
-  case ELOOP:
-    WSASetLastError(WSAELOOP);
-    break;
-  case ENAMETOOLONG:
-    WSASetLastError(WSAENAMETOOLONG);
-    break;
-  case EHOSTDOWN:
-    WSASetLastError(WSAEHOSTDOWN);
-    break;
-  case EHOSTUNREACH:
-    WSASetLastError(WSAEHOSTUNREACH);
-    break;
-  case ENOTEMPTY:
-    WSASetLastError(WSAENOTEMPTY);
-    break;
-  case EPROCLIM:
-    WSASetLastError(WSAEPROCLIM);
-    break;
-  case EUSERS:
-    WSASetLastError(WSAEUSERS);
-    break;
-  case EDQUOT:
-    WSASetLastError(WSAEDQUOT);
-    break;
-  case ESTALE:
-    WSASetLastError(WSAESTALE);
-    break;
-  case EREMOTE:
-    WSASetLastError(WSAEREMOTE);
-    break;
-  case EFAULT:
-    WSASetLastError(WSAEFAULT);
-    break;
-  case ENODATA:
-    WSASetLastError(WSANO_DATA);
-    break;
-#if EAGAIN != EWOULDBLOCK
-  case EAGAIN:
-    WSASetLastError(WSAEWOULDBLOCK);
-    break;
-#endif
-  /* Rough equivalent */
-  case EIO:
-    WSASetLastError(WSAEREFUSED);
-    break;
-
-  default: /* Unmapped errors */
-    WSASetLastError(WSAENOBUFS);
-    break;
-    }
-}
-
-/**
  * Create pair of mutually connected TCP/IP sockets on loopback address
  * @param sockets_pair array to receive resulted sockets
  * @return zero on success, -1 otherwise

Modified: libmicrohttpd/src/testcurl/https/test_https_time_out.c
===================================================================
--- libmicrohttpd/src/testcurl/https/test_https_time_out.c      2016-08-23 
15:43:38 UTC (rev 37761)
+++ libmicrohttpd/src/testcurl/https/test_https_time_out.c      2016-08-23 
20:12:50 UTC (rev 37762)
@@ -30,6 +30,7 @@
 #include "internal.h"
 #include "tls_test_common.h"
 #include <gcrypt.h>
+#include "mhd_sockets.h" /* only macros used */
 
 #ifdef _WIN32
 #ifndef WIN32_LEAN_AND_MEAN

Modified: libmicrohttpd/src/testcurl/https/test_tls_extensions.c
===================================================================
--- libmicrohttpd/src/testcurl/https/test_tls_extensions.c      2016-08-23 
15:43:38 UTC (rev 37761)
+++ libmicrohttpd/src/testcurl/https/test_tls_extensions.c      2016-08-23 
20:12:50 UTC (rev 37762)
@@ -28,6 +28,8 @@
 #include "platform.h"
 #include "microhttpd.h"
 #include "tls_test_common.h"
+#include "mhd_sockets.h" /* only macros used */
+
 #define MAX_EXT_DATA_LENGTH 256
 
 extern const char srv_key_pem[];

Modified: libmicrohttpd/src/testcurl/test_get.c
===================================================================
--- libmicrohttpd/src/testcurl/test_get.c       2016-08-23 15:43:38 UTC (rev 
37761)
+++ libmicrohttpd/src/testcurl/test_get.c       2016-08-23 20:12:50 UTC (rev 
37762)
@@ -33,6 +33,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+#include "mhd_sockets.h" /* only macros used */
 
 #ifdef _WIN32
 #ifndef WIN32_LEAN_AND_MEAN

Modified: libmicrohttpd/src/testcurl/test_get_sendfile.c
===================================================================
--- libmicrohttpd/src/testcurl/test_get_sendfile.c      2016-08-23 15:43:38 UTC 
(rev 37761)
+++ libmicrohttpd/src/testcurl/test_get_sendfile.c      2016-08-23 20:12:50 UTC 
(rev 37762)
@@ -33,6 +33,7 @@
 #include <time.h>
 #include <sys/types.h>
 #include <fcntl.h>
+#include "mhd_sockets.h"
 
 #ifndef WINDOWS
 #include <sys/socket.h>
@@ -101,7 +102,7 @@
     {
       fprintf (stderr, "Failed to open `%s': %s\n",
               sourcefile,
-              MHD_strerror_ (errno));
+              strerror (errno));
       exit (1);
     }
   response = MHD_create_response_from_fd (strlen (TESTSTR), fd);

Modified: libmicrohttpd/src/testcurl/test_options.c
===================================================================
--- libmicrohttpd/src/testcurl/test_options.c   2016-08-23 15:43:38 UTC (rev 
37761)
+++ libmicrohttpd/src/testcurl/test_options.c   2016-08-23 20:12:50 UTC (rev 
37762)
@@ -26,6 +26,7 @@
 
 #include "platform.h"
 #include "microhttpd.h"
+#include "mhd_sockets.h"
 
 #define MHD_E_MEM "Error: memory error\n"
 #define MHD_E_SERVER_INIT "Error: failed to start server\n"

Modified: libmicrohttpd/src/testcurl/test_quiesce.c
===================================================================
--- libmicrohttpd/src/testcurl/test_quiesce.c   2016-08-23 15:43:38 UTC (rev 
37761)
+++ libmicrohttpd/src/testcurl/test_quiesce.c   2016-08-23 20:12:50 UTC (rev 
37762)
@@ -33,6 +33,7 @@
 #include <time.h>
 #include <sys/types.h>
 #include <pthread.h>
+#include "mhd_sockets.h" /* only macros used */
 
 #ifndef WINDOWS
 #include <unistd.h>

Modified: libmicrohttpd/w32/common/libmicrohttpd-files.vcxproj
===================================================================
--- libmicrohttpd/w32/common/libmicrohttpd-files.vcxproj        2016-08-23 
15:43:38 UTC (rev 37761)
+++ libmicrohttpd/w32/common/libmicrohttpd-files.vcxproj        2016-08-23 
20:12:50 UTC (rev 37762)
@@ -17,6 +17,7 @@
     <ClCompile Include="$(MhdSrc)microhttpd\sysfdsetsize.c" />
     <ClCompile Include="$(MhdSrc)microhttpd\mhd_str.c" />
     <ClCompile Include="$(MhdSrc)microhttpd\mhd_threads.c" />
+    <ClCompile Include="$(MhdSrc)microhttpd\mhd_sockets.c" />
     <ClCompile Include="$(MhdSrc)platform\w32functions.c" />
   </ItemGroup>
   <ItemGroup>
@@ -40,6 +41,7 @@
     <ClInclude Include="$(MhdSrc)microhttpd\mhd_str.h" />
     <ClInclude Include="$(MhdSrc)microhttpd\mhd_threads.h" />
     <ClInclude Include="$(MhdSrc)microhttpd\mhd_locks.h" />
+    <ClInclude Include="$(MhdSrc)microhttpd\mhd_sockets.h" />
     <ClInclude Include="$(MhdW32Common)MHD_config.h" />
   </ItemGroup>
   <ItemGroup>

Modified: libmicrohttpd/w32/common/libmicrohttpd-filters.vcxproj
===================================================================
--- libmicrohttpd/w32/common/libmicrohttpd-filters.vcxproj      2016-08-23 
15:43:38 UTC (rev 37761)
+++ libmicrohttpd/w32/common/libmicrohttpd-filters.vcxproj      2016-08-23 
20:12:50 UTC (rev 37762)
@@ -139,6 +139,12 @@
     <ClInclude Include="$(MhdSrc)microhttpd\mhd_locks.h">
       <Filter>Source Files</Filter>
     </ClInclude>
+    <ClInclude Include="$(MhdSrc)microhttpd\mhd_sockets.h">
+      <Filter>Source Files</Filter>
+    </ClInclude>
+    <ClCompile Include="$(MhdSrc)microhttpd\mhd_sockets.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="$(MhdW32Common)microhttpd_dll_res_vc.rc">




reply via email to

[Prev in Thread] Current Thread [Next in Thread]