[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] 02/02: Improved compatibility with Cygwin
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] 02/02: Improved compatibility with Cygwin |
Date: |
Sun, 26 Nov 2017 13:35:40 +0100 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 4a126e24e7b780c3ad0196b72f813ce4a90215e3
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Sun Nov 26 15:33:55 2017 +0300
Improved compatibility with Cygwin
---
src/include/platform.h | 6 ++---
src/microhttpd/daemon.c | 46 +++++++++++++++++------------------
src/microhttpd/digestauth.c | 4 +--
src/microhttpd/mhd_compat.h | 6 ++---
src/microhttpd/mhd_mono_clock.c | 4 +--
src/microhttpd/mhd_sockets.h | 2 +-
src/microhttpd/response.c | 20 +++++++--------
src/microhttpd/test_helpers.h | 4 +--
src/microhttpd/test_shutdown_select.c | 4 +--
9 files changed, 48 insertions(+), 48 deletions(-)
diff --git a/src/include/platform.h b/src/include/platform.h
index 6d51747d..20d4df52 100644
--- a/src/include/platform.h
+++ b/src/include/platform.h
@@ -118,11 +118,11 @@
typedef intptr_t ssize_t;
#endif /* !_SSIZE_T_DEFINED */
-#ifndef _WIN32
+#if !defined(_WIN32) || defined(__CYGWIN__)
typedef time_t _MHD_TIMEVAL_TV_SEC_TYPE;
-#else /* _WIN32 */
+#else /* _WIN32 && ! __CYGWIN__ */
typedef long _MHD_TIMEVAL_TV_SEC_TYPE;
-#endif /* _WIN32 */
+#endif /* _WIN32 && ! __CYGWIN__ */
#if !defined(IPPROTO_IPV6) && defined(_MSC_FULL_VER) && _WIN32_WINNT >= 0x0501
/* VC use IPPROTO_IPV6 as part of enum */
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index f9bebd35..794acfbd 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -52,7 +52,7 @@
#endif /* MHD_HTTPS_REQUIRE_GRYPT */
#endif /* HTTPS_SUPPORT */
-#ifdef _WIN32
+#if defined(_WIN32) && ! defined(__CYGWIN__)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif /* !WIN32_LEAN_AND_MEAN */
@@ -152,7 +152,7 @@ MHD_PanicCallback mhd_panic;
*/
void *mhd_panic_cls;
-#ifdef _WIN32
+#if defined(_WIN32) && ! defined(__CYGWIN__)
/**
* Track initialization of winsock
*/
@@ -1822,14 +1822,14 @@ thread_main_handle_connection (void *data)
else
{
const time_t seconds_left = timeout - (now - con->last_activity);
-#ifndef _WIN32
+#if !defined(_WIN32) || defined(__CYGWIN__)
tv.tv_sec = seconds_left;
-#else /* _WIN32 */
+#else /* _WIN32 && !__CYGWIN__ */
if (seconds_left > TIMEVAL_TV_SEC_MAX)
tv.tv_sec = TIMEVAL_TV_SEC_MAX;
else
tv.tv_sec = (_MHD_TIMEVAL_TV_SEC_TYPE) seconds_left;
-#endif /* _WIN32 */
+#endif /* _WIN32 && ! __CYGWIN__ */
}
tv.tv_usec = 0;
tvp = &tv;
@@ -2073,7 +2073,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon);
* and if possible.
*/
#define MHD_TLSLIB_NEED_PUSH_FUNC 1
-#endif /* !_WIN32 && !MHD_socket_nosignal_ && (GNUTLS_VERSION_NUMBER+0 <
0x030402) */
+#endif /* !MHD_WINSOCK_SOCKETS && !MHD_socket_nosignal_ &&
(GNUTLS_VERSION_NUMBER+0 < 0x030402) */
#ifdef MHD_TLSLIB_NEED_PUSH_FUNC
/**
@@ -5489,7 +5489,7 @@ MHD_start_daemon_va (unsigned int flags,
/* Apply the socket options according to listening_address_reuse. */
if (0 == daemon->listening_address_reuse)
{
-#ifndef _WIN32
+#ifdef MHD_WINSOCK_SOCKETS
/* No user requirement, use "traditional" default SO_REUSEADDR
* on non-W32 platforms, and do not fail if it doesn't work.
* Don't use it on W32, because on W32 it will allow multiple
@@ -5505,12 +5505,12 @@ MHD_start_daemon_va (unsigned int flags,
MHD_socket_last_strerr_ ());
#endif
}
-#endif /* ! _WIN32 */
+#endif /* ! MHD_WINSOCK_SOCKETS */
}
else if (daemon->listening_address_reuse > 0)
{
/* User requested to allow reusing listening address:port. */
-#ifndef _WIN32
+#ifndef MHD_WINSOCK_SOCKETS
/* Use SO_REUSEADDR on non-W32 platforms, and do not fail if
* it doesn't work. */
if (0 > setsockopt (listen_fd,
@@ -5524,20 +5524,20 @@ MHD_start_daemon_va (unsigned int flags,
MHD_socket_last_strerr_ ());
#endif
}
-#endif /* ! _WIN32 */
+#endif /* ! MHD_WINSOCK_SOCKETS */
/* Use SO_REUSEADDR on Windows and SO_REUSEPORT on most platforms.
* Fail if SO_REUSEPORT is not defined or setsockopt fails.
*/
/* SO_REUSEADDR on W32 has the same semantics
as SO_REUSEPORT on BSD/Linux */
-#if defined(_WIN32) || defined(SO_REUSEPORT)
+#if defined(MHD_WINSOCK_SOCKETS) || defined(SO_REUSEPORT)
if (0 > setsockopt (listen_fd,
SOL_SOCKET,
-#ifndef _WIN32
+#ifndef MHD_WINSOCK_SOCKETS
SO_REUSEPORT,
-#else /* _WIN32 */
+#else /* MHD_WINSOCK_SOCKETS */
SO_REUSEADDR,
-#endif /* _WIN32 */
+#endif /* MHD_WINSOCK_SOCKETS */
(void *) &on,
sizeof (on)))
{
@@ -5548,7 +5548,7 @@ MHD_start_daemon_va (unsigned int flags,
#endif
goto free_and_fail;
}
-#else /* !_WIN32 && !SO_REUSEPORT */
+#else /* !MHD_WINSOCK_SOCKETS && !SO_REUSEPORT */
/* we're supposed to allow address:port re-use, but
on this platform we cannot; fail hard */
#ifdef HAVE_MESSAGES
@@ -5556,7 +5556,7 @@ MHD_start_daemon_va (unsigned int flags,
_("Cannot allow listening address reuse: SO_REUSEPORT not
defined\n"));
#endif
goto free_and_fail;
-#endif /* !_WIN32 && !SO_REUSEPORT */
+#endif /* !MHD_WINSOCK_SOCKETS && !SO_REUSEPORT */
}
else /* if (daemon->listening_address_reuse < 0) */
{
@@ -5566,7 +5566,7 @@ MHD_start_daemon_va (unsigned int flags,
* Fail if MHD was compiled for W32 without SO_EXCLUSIVEADDRUSE
* or setsockopt fails.
*/
-#if (defined(_WIN32) && defined(SO_EXCLUSIVEADDRUSE)) || \
+#if (defined(MHD_WINSOCK_SOCKETS) && defined(SO_EXCLUSIVEADDRUSE)) || \
(defined(__sun) && defined(SO_EXCLBIND))
if (0 > setsockopt (listen_fd,
SOL_SOCKET,
@@ -5585,13 +5585,13 @@ MHD_start_daemon_va (unsigned int flags,
#endif
goto free_and_fail;
}
-#elif defined(_WIN32) /* SO_EXCLUSIVEADDRUSE not defined on W32? */
+#elif defined(MHD_WINSOCK_SOCKETS) /* SO_EXCLUSIVEADDRUSE not defined on W32?
*/
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon,
_("Cannot disallow listening address reuse:
SO_EXCLUSIVEADDRUSE not defined\n"));
#endif
goto free_and_fail;
-#endif /* _WIN32 */
+#endif /* MHD_WINSOCK_SOCKETS */
}
/* check for user supplied sockaddr */
@@ -6698,13 +6698,13 @@ static struct gcry_thread_cbs gcry_threads_w32 = {
void
MHD_init(void)
{
-#ifdef _WIN32
+#if defined(_WIN32) && ! defined(__CYGWIN__)
WSADATA wsd;
-#endif /* _WIN32 */
+#endif /* _WIN32 && ! __CYGWIN__ */
mhd_panic = &mhd_panic_std;
mhd_panic_cls = NULL;
-#ifdef _WIN32
+#if defined(_WIN32) && ! defined(__CYGWIN__)
if (0 != WSAStartup(MAKEWORD(2, 2), &wsd))
MHD_PANIC (_("Failed to initialize winsock\n"));
mhd_winsock_inited_ = 1;
@@ -6744,7 +6744,7 @@ MHD_fini(void)
#ifdef HTTPS_SUPPORT
gnutls_global_deinit ();
#endif /* HTTPS_SUPPORT */
-#ifdef _WIN32
+#if defined(_WIN32) && ! defined(__CYGWIN__)
if (mhd_winsock_inited_)
WSACleanup();
#endif
diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c
index 509652e8..7226becf 100644
--- a/src/microhttpd/digestauth.c
+++ b/src/microhttpd/digestauth.c
@@ -30,12 +30,12 @@
#include "mhd_str.h"
#include "mhd_compat.h"
-#if defined(_WIN32) && defined(MHD_W32_MUTEX_)
+#if defined(MHD_W32_MUTEX_)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif /* !WIN32_LEAN_AND_MEAN */
#include <windows.h>
-#endif /* _WIN32 && MHD_W32_MUTEX_ */
+#endif /* MHD_W32_MUTEX_ */
#define HASH_MD5_HEX_LEN (2 * MD5_DIGEST_SIZE)
/* 32 bit value is 4 bytes */
diff --git a/src/microhttpd/mhd_compat.h b/src/microhttpd/mhd_compat.h
index fca84b84..b4e2c66c 100644
--- a/src/microhttpd/mhd_compat.h
+++ b/src/microhttpd/mhd_compat.h
@@ -47,13 +47,13 @@
#if defined(HAVE_SNPRINTF)
#define MHD_snprintf_ snprintf
#else /* ! HAVE_SNPRINTF */
-#if defined(_WIN32)
+#if defined(_WIN32) && ! defined(__CYGWIN__)
/* Emulate snprintf function on W32 */
int W32_snprintf(char *__restrict s, size_t n, const char *__restrict format,
...);
#define MHD_snprintf_ W32_snprintf
-#else /* ! _WIN32*/
+#else /* ! _WIN32 || __CYGWIN__ */
#error Your platform does not support snprintf() and MHD does not know how to
emulate it on your platform.
-#endif /* ! _WIN32*/
+#endif /* ! _WIN32 || __CYGWIN__ */
#endif /* ! HAVE_SNPRINTF */
#ifdef HAVE_RANDOM
diff --git a/src/microhttpd/mhd_mono_clock.c b/src/microhttpd/mhd_mono_clock.c
index 353e04c0..97dbfb9f 100644
--- a/src/microhttpd/mhd_mono_clock.c
+++ b/src/microhttpd/mhd_mono_clock.c
@@ -25,10 +25,10 @@
#include "mhd_mono_clock.h"
-#if defined(_WIN32) && defined(HAVE_CLOCK_GETTIME)
+#if defined(_WIN32) && ! defined(__CYGWIN__) && defined(HAVE_CLOCK_GETTIME)
/* Prefer native clock source over wrappers */
#undef HAVE_CLOCK_GETTIME
-#endif /* _WIN32 && HAVE_CLOCK_GETTIME */
+#endif /* _WIN32 && ! __CYGWIN__ && HAVE_CLOCK_GETTIME */
#ifdef HAVE_CLOCK_GETTIME
#include <time.h>
diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h
index 4a4c5cd9..b013baad 100644
--- a/src/microhttpd/mhd_sockets.h
+++ b/src/microhttpd/mhd_sockets.h
@@ -358,7 +358,7 @@
/* MHD_POLL_EVENTS_ERR_DISC is 'events' mask for errors and disconnect.
* Note: Out-of-band data is treated as error. */
-# if defined(_WIN32)
+# if defined(_WIN32) && ! defined(__CYGWIN__)
# define MHD_POLL_EVENTS_ERR_DISC POLLRDBAND
# elif defined(__linux__)
# define MHD_POLL_EVENTS_ERR_DISC POLLPRI
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index 18ba625d..d677cf62 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -30,9 +30,9 @@
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif /* HAVE_SYS_IOCTL_H */
-#ifdef _WIN32
+#if defined(_WIN32) && ! defined(__CYGWIN__)
#include <windows.h>
-#endif /* _WIN32 */
+#endif /* _WIN32 && !__CYGWIN__ */
#include "internal.h"
#include "response.h"
@@ -45,12 +45,12 @@
#include "mhd_compat.h"
-#if defined(_WIN32) && defined(MHD_W32_MUTEX_)
+#if defined(MHD_W32_MUTEX_)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif /* !WIN32_LEAN_AND_MEAN */
#include <windows.h>
-#endif /* _WIN32 && MHD_W32_MUTEX_ */
+#endif /* MHD_W32_MUTEX_ */
#if defined(_WIN32)
#include <io.h> /* for lseek(), read() */
#endif /* _WIN32 */
@@ -393,17 +393,17 @@ file_reader (void *cls,
size_t max)
{
struct MHD_Response *response = cls;
-#ifndef _WIN32
+#if !defined(_WIN32) || defined(__CYGWIN__)
ssize_t n;
-#else /* _WIN32 */
+#else /* _WIN32 && !__CYGWIN__ */
const HANDLE fh = (HANDLE) _get_osfhandle (response->fd);
-#endif /* _WIN32 */
+#endif /* _WIN32 && !__CYGWIN__ */
const int64_t offset64 = (int64_t)(pos + response->fd_off);
if (offset64 < 0)
return MHD_CONTENT_READER_END_WITH_ERROR; /* seek to required position is
not possible */
-#ifndef _WIN32
+#if !defined(_WIN32) || defined(__CYGWIN__)
if (max > SSIZE_MAX)
max = SSIZE_MAX; /* Clamp to maximum return value. */
@@ -441,7 +441,7 @@ file_reader (void *cls,
if (n < 0)
return MHD_CONTENT_READER_END_WITH_ERROR;
return n;
-#else /* _WIN32 */
+#else /* _WIN32 && !__CYGWIN__ */
if (INVALID_HANDLE_VALUE == fh)
return MHD_CONTENT_READER_END_WITH_ERROR; /* Value of 'response->fd' is
not valid. */
else
@@ -460,7 +460,7 @@ file_reader (void *cls,
return MHD_CONTENT_READER_END_OF_STREAM;
return (ssize_t) resRead;
}
-#endif /* _WIN32 */
+#endif /* _WIN32 && !__CYGWIN__ */
}
diff --git a/src/microhttpd/test_helpers.h b/src/microhttpd/test_helpers.h
index c3f0f7be..4f015ef2 100644
--- a/src/microhttpd/test_helpers.h
+++ b/src/microhttpd/test_helpers.h
@@ -53,10 +53,10 @@ has_in_name(const char *prog_name, const char *marker)
{
if ('/' == prog_name[pos])
name_pos = pos + 1;
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
else if ('\\' == prog_name[pos])
name_pos = pos + 1;
-#endif /* _WIN32 */
+#endif /* _WIN32 || __CYGWIN__ */
pos++;
}
if (name_pos == pos)
diff --git a/src/microhttpd/test_shutdown_select.c
b/src/microhttpd/test_shutdown_select.c
index 1e4e3d82..934cde79 100644
--- a/src/microhttpd/test_shutdown_select.c
+++ b/src/microhttpd/test_shutdown_select.c
@@ -105,10 +105,10 @@ has_in_name(const char *prog_name, const char *marker)
{
if ('/' == prog_name[pos])
name_pos = pos + 1;
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
else if ('\\' == prog_name[pos])
name_pos = pos + 1;
-#endif /* _WIN32 */
+#endif /* _WIN32 || __CYGWIN__ */
pos++;
}
if (name_pos == pos)
--
To stop receiving notification emails like this one, please contact
address@hidden