Prechádzať zdrojové kódy

Added detection of more values in configure.

On some platforms the constant values could be enum values, not macros.
On such platform pre-processor fail to use the values. Tests in
configure ensure that values will be used if present on the platform.
Evgeny Grin (Karlson2k) 1 rok pred
rodič
commit
f4890e49c4

+ 4 - 17
configure.ac

@@ -3207,8 +3207,10 @@ AS_VAR_IF([[os_is_native_w32]], [["yes"]],[],
   ]
 )
 
-MHD_CHECK_DECLS([AF_UNIX AF_LOCAL SOMAXCONN IPV6_V6ONLY SO_REUSEADDR SO_REUSEPORT \
-                 TCP_NODELAY TCP_FASTOPEN SOL_SOCKET SO_LINGER SHUT_WR SD_SEND],
+MHD_CHECK_DECLS([AF_UNIX AF_LOCAL SOMAXCONN IPV6_V6ONLY TCP_NODELAY TCP_FASTOPEN \
+                 SOCK_NONBLOCK SOCK_CLOEXEC SOCK_NOSIGPIPE MSG_NOSIGNAL MSG_MORE \
+                 SOL_SOCKET SO_REUSEADDR SO_REUSEPORT SO_LINGER SO_NOSIGPIPE \
+                 SHUT_WR SD_SEND],
   [[
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -3705,21 +3707,6 @@ errno_t gmtime_s(struct tm* _tm, const time_t* time);
 #include <time.h>]])
 
 
-AC_CHECK_DECL([SOCK_NONBLOCK], [AC_DEFINE([HAVE_SOCK_NONBLOCK], [1], [SOCK_NONBLOCK is defined in a socket header])], [],
-  [[
-#if defined(HAVE_SYS_TYPES_H)
-#  include <sys/types.h>
-#endif
-#if defined(HAVE_SYS_SOCKET_H)
-#  include <sys/socket.h>
-#elif defined(HAVE_WINSOCK2_H)
-#  include <winsock2.h>
-#elif defined(HAVE_UNISTD_H)
-#  include <unistd.h>
-#endif
-  ]]
-)
-
 MHD_FIND_LIB([clock_gettime],[[#include <time.h>]],
   [[
     struct timespec tp;

+ 4 - 4
src/mhd2/daemon_add_conn.c

@@ -682,7 +682,7 @@ MHD_daemon_add_connection (struct MHD_Daemon *daemon,
   {
     mhd_LOG_MSG (daemon, MHD_SC_ACCEPT_CONFIGURE_NOSIGPIPE_FAILED, \
                  "Failed to suppress SIGPIPE on the new client socket.");
-#ifndef MSG_NOSIGNAL
+#ifndef HAVE_DCLR_MSG_NOSIGNAL
     /* Application expects that SIGPIPE will be suppressed,
      * but suppression failed and SIGPIPE cannot be suppressed with send(). */
     if (! daemon->sigpipe_blocked)
@@ -692,7 +692,7 @@ MHD_daemon_add_connection (struct MHD_Daemon *daemon,
       MHD_socket_fset_error_ (err);
       return MHD_SC_ACCEPT_CONFIGURE_NOSIGPIPE_FAILED;
     }
-#endif /* MSG_NOSIGNAL */
+#endif /* HAVE_DCLR_MSG_NOSIGNAL */
   }
 #endif /* MHD_socket_nosignal_ */
 
@@ -956,7 +956,7 @@ mhd_daemon_accept_connection (struct MHD_Daemon *restrict daemon)
     mhd_LOG_MSG (daemon, MHD_SC_ACCEPT_CONFIGURE_NOSIGPIPE_FAILED,
                  "Failed to suppress SIGPIPE on incoming connection " \
                  "socket.");
-#ifndef MSG_NOSIGNAL
+#ifndef HAVE_DCLR_MSG_NOSIGNAL
     /* Application expects that SIGPIPE will be suppressed,
      * but suppression failed and SIGPIPE cannot be suppressed with send(). */
     if (! daemon->sigpipe_blocked)
@@ -964,7 +964,7 @@ mhd_daemon_accept_connection (struct MHD_Daemon *restrict daemon)
       (void) MHD_socket_close_ (s);
       return MHD_NO;
     }
-#endif /* MSG_NOSIGNAL */
+#endif /* HAVE_DCLR_MSG_NOSIGNAL */
   }
   else
     sk_spipe_supprs = true;

+ 4 - 4
src/mhd2/mhd_send.c

@@ -82,11 +82,11 @@
 
 
 #ifdef mhd_USE_VECT_SEND
-#  if (! defined(HAVE_SENDMSG) || ! defined(MSG_NOSIGNAL)) && \
+#  if (! defined(HAVE_SENDMSG) || ! defined(HAVE_DCLR_MSG_NOSIGNAL)) && \
   defined(mhd_SEND_SPIPE_SUPPRESS_POSSIBLE) && \
   defined(mhd_SEND_SPIPE_SUPPRESS_NEEDED)
 #    define mhd_VECT_SEND_NEEDS_SPIPE_SUPPRESSED 1
-#  endif /* (!HAVE_SENDMSG || !MSG_NOSIGNAL) &&
+#  endif /* (!HAVE_SENDMSG || !HAVE_DCLR_MSG_NOSIGNAL) &&
             mhd_SEND_SPIPE_SUPPRESS_POSSIBLE && mhd_SEND_SPIPE_SUPPRESS_NEEDED */
 #endif /* mhd_USE_VECT_SEND */
 
@@ -930,12 +930,12 @@ mhd_send_hdr_and_body (struct MHD_Connection *restrict connection,
 
   no_vec = false;
   no_vec = no_vec || (mhd_C_HAS_TLS (connection));
-#if (! defined(HAVE_SENDMSG) || ! defined(MSG_NOSIGNAL) ) && \
+#if (! defined(HAVE_SENDMSG) || ! defined(HAVE_DCLR_MSG_NOSIGNAL) ) && \
   defined(mhd_SEND_SPIPE_SUPPRESS_POSSIBLE) && \
   defined(mhd_SEND_SPIPE_SUPPRESS_NEEDED)
   no_vec = no_vec || (! connection->daemon->sigpipe_blocked &&
                       ! connection->sk.props.has_spipe_supp);
-#endif /* (!HAVE_SENDMSG || ! MSG_NOSIGNAL) &&
+#endif /* (!HAVE_SENDMSG || ! HAVE_DCLR_MSG_NOSIGNAL) &&
           mhd_SEND_SPIPE_SUPPRESS_POSSIBLE &&
           mhd_SEND_SPIPE_SUPPRESS_NEEDED */
 #endif /* mhd_USE_VECT_SEND */

+ 2 - 2
src/mhd2/mhd_sockets_macros.h

@@ -312,7 +312,7 @@
 #      define mhd_socket_pair(fdarr_ptr) \
         (0 != socketpair (AF_INET, SOCK_STREAM, 0, (fdarr_ptr))) /* Fallback, could be broken on many platforms */
 #    endif
-#    if defined(HAVE_SOCK_NONBLOCK)
+#    if defined(HAVE_DCLR_SOCK_NONBLOCK)
 #      ifdef MHD_AF_UNIX
 #        define mhd_socket_pair_nblk(fdarr_ptr) \
         (0 != socketpair (MHD_AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, \
@@ -321,7 +321,7 @@
 #        define mhd_socket_pair_nblk(fdarr_ptr) \
         (0 != socketpair (AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0, (fdarr_ptr))) /* Fallback, could be broken on many platforms */
 #      endif
-#    endif /* HAVE_SOCK_NONBLOCK*/
+#    endif /* HAVE_DCLR_SOCK_NONBLOCK*/
 #  endif /* HAVE_SOCKETPAIR */
 #endif
 

+ 55 - 5
src/mhd2/sys_sockets_headers.h

@@ -48,31 +48,81 @@
 #  include <sys/un.h>
 #endif
 
-#if defined(HAVE_SOCK_NONBLOCK) && ! defined(MHD_SOCKETS_KIND_WINSOCK)
+#if defined(SOCK_NONBLOCK) && ! defined(HAVE_DCLR_SOCK_NONBLOCK)
+/* Mis-detected by configure */
+#  define HAVE_DCLR_SOCK_NONBLOCK 1
+#endif
+
+#if defined(SOCK_CLOEXEC) && ! defined(HAVE_DCLR_SOCK_CLOEXEC)
+/* Mis-detected by configure */
+#  define HAVE_DCLR_SOCK_CLOEXEC 1
+#endif
+
+#if defined(SOCK_NOSIGPIPE) && ! defined(HAVE_DCLR_SOCK_NOSIGPIPE)
+/* Mis-detected by configure */
+#  define HAVE_DCLR_SOCK_NOSIGPIPE 1
+#endif
+
+#if defined(MSG_NOSIGNAL) && ! defined(HAVE_DCLR_MSG_NOSIGNAL)
+/* Mis-detected by configure */
+#  define HAVE_DCLR_MSG_NOSIGNAL 1
+#endif
+
+#if defined(MSG_MORE) && ! defined(HAVE_DCLR_MSG_MORE)
+/* Mis-detected by configure */
+#  define HAVE_DCLR_MSG_MORE 1
+#endif
+
+#if defined(SOL_SOCKET) && ! defined(HAVE_DCLR_SOL_SOCKET)
+/* Mis-detected by configure */
+#  define HAVE_DCLR_SOL_SOCKET 1
+#endif
+
+#if defined(SO_REUSEADDR) && ! defined(HAVE_DCLR_SO_REUSEADDR)
+/* Mis-detected by configure */
+#  define HAVE_DCLR_SO_REUSEADDR 1
+#endif
+
+#if defined(SO_REUSEPORT) && ! defined(HAVE_DCLR_SO_REUSEPORT)
+/* Mis-detected by configure */
+#  define HAVE_DCLR_SO_REUSEPORT 1
+#endif
+
+#if defined(SO_LINGER) && ! defined(HAVE_DCLR_SO_LINGER)
+/* Mis-detected by configure */
+#  define HAVE_DCLR_SO_LINGER 1
+#endif
+
+#if defined(SO_NOSIGPIPE) && ! defined(HAVE_DCLR_SO_NOSIGPIPE)
+/* Mis-detected by configure */
+#  define HAVE_DCLR_SO_NOSIGPIPE 1
+#endif
+
+#if defined(HAVE_DCLR_SOCK_NONBLOCK) && ! defined(MHD_SOCKETS_KIND_WINSOCK)
 #  define mhd_SOCK_NONBLOCK SOCK_NONBLOCK
 #else
 #  define mhd_SOCK_NONBLOCK (0)
 #endif
 
-#if defined(SOCK_CLOEXEC) && ! defined(MHD_SOCKETS_KIND_WINSOCK)
+#if defined(HAVE_DCLR_SOCK_CLOEXEC) && ! defined(MHD_SOCKETS_KIND_WINSOCK)
 #  define mhd_SOCK_CLOEXEC SOCK_CLOEXEC
 #else
 #  define mhd_SOCK_CLOEXEC (0)
 #endif
 
-#if defined(SOCK_NOSIGPIPE) && ! defined(MHD_SOCKETS_KIND_WINSOCK)
+#if defined(HAVE_DCLR_SOCK_NOSIGPIPE) && ! defined(MHD_SOCKETS_KIND_WINSOCK)
 #  define mhd_SOCK_NOSIGPIPE SOCK_NOSIGPIPE
 #else
 #  define mhd_SOCK_NOSIGPIPE (0)
 #endif
 
-#if defined(MSG_NOSIGNAL) && ! defined(MHD_SOCKETS_KIND_WINSOCK)
+#if defined(HAVE_DCLR_MSG_NOSIGNAL) && ! defined(MHD_SOCKETS_KIND_WINSOCK)
 #  define mhd_MSG_NOSIGNAL MSG_NOSIGNAL
 #else
 #  define mhd_MSG_NOSIGNAL (0)
 #endif
 
-#ifdef MSG_MORE
+#ifdef HAVE_DCLR_MSG_MORE
 #  ifdef __linux__
 /* MSG_MORE signal kernel to buffer outbond data and works like
  * TCP_CORK per call without actually setting TCP_CORK value.