[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] 01/05: configure: fixed detection of 'getso
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] 01/05: configure: fixed detection of 'getsockname' on some systems (W32 x32), do not use 'getsockname()' if it is not detected by configure. |
Date: |
Sun, 02 Jun 2019 18:20:46 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 2db0eabd118370fd2937bd9021ade9b0e40473fa
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Thu May 30 23:32:09 2019 +0300
configure: fixed detection of 'getsockname' on some systems (W32 x32),
do not use 'getsockname()' if it is not detected by configure.
---
configure.ac | 40 ++++++++++++-------------
m4/mhd_check_func.m4 | 80 +++++++++++++++++++++++++++++++++++++++++++++++++
src/microhttpd/daemon.c | 2 ++
3 files changed, 102 insertions(+), 20 deletions(-)
diff --git a/configure.ac b/configure.ac
index 203b9d30..bcb4e45d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -789,12 +789,25 @@ AC_CHECK_MEMBERS([struct sockaddr_in.sin_len, struct
sockaddr_in6.sin6_len,
#endif
])
-AC_CHECK_DECLS([getsockname],
+MHD_CHECK_FUNC([getsockname],
+ [[
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+ ]],
[
- AC_CHECK_FUNCS([getsockname],
- [
- AC_CACHE_CHECK([[whether getsockname() is usable]],
[[mhc_cv_getsockname_usable]],
- [
+ struct sockaddr_storage ss;
+ (void)getsockname(socket(0,0,0),(struct sockaddr *)&ss,(void*)0);
+ ],
+ [
+ AC_CACHE_CHECK([[whether getsockname() is usable]],
[[mhc_cv_getsockname_usable]],
+ [
AC_RUN_IFELSE(
[
AC_LANG_SOURCE(
@@ -888,22 +901,9 @@ int main(void)
)
]
)
- AS_VAR_IF([[mhc_cv_getsockname_usable]], [["no"]], [:],
+ AS_VAR_IF([[mhc_cv_getsockname_usable]], [["no"]], [:],
[AC_DEFINE([[MHD_USE_GETSOCKNAME]], [[1]], [Define if you have usable
`getsockname' function.])])
- ]
- )
- ], [],
- [[
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
- ]]
+ ]
)
# Check for inter-thread signaling type
diff --git a/m4/mhd_check_func.m4 b/m4/mhd_check_func.m4
new file mode 100644
index 00000000..983d0306
--- /dev/null
+++ b/m4/mhd_check_func.m4
@@ -0,0 +1,80 @@
+# SYNOPSIS
+#
+# MHD_CHECK_FUNC([FUNCTION_NAME],
+# [INCLUDES=AC_INCLUDES_DEFAULT], [CHECK_CODE],
+# [ACTION-IF-AVAILABLE], [ACTION-IF-NOT-AVAILABLE],
+# [ADDITIONAL_LIBS])
+#
+# DESCRIPTION
+#
+# This macro checks for presence of specific function by including
+# specified headers and compiling and linking CHECK_CODE.
+# This check both declaration and presence in library.
+# Unlike AC_CHECK_FUNCS macro, this macro do not produce false
+# negative result if function is declared with specific calling
+# conventions like __stdcall' or attribute like
+# __attribute__((__dllimport__)) and linker failed to build test
+# program if library contains function with calling conventions
+# different from declared.
+# By using definition from provided headers, this macro ensures that
+# correct calling convention is used for detection.
+#
+# Example usage:
+#
+# MHD_CHECK_FUNC([memmem],
+# [[#include <string.h>]],
+# [const void *ptr = memmem("aa", 2, "a", 1); (void)ptr;],
+# [var_use_memmem='yes'], [var_use_memmem='no'])
+#
+# Defined cache variable used in check so if any test will not work
+# correctly on some platform, user may simply fix it by giving cache
+# variable in configure parameters, for example:
+#
+# ./configure mhd_cv_func_memmem_have=no
+#
+# This simplify building from source on exotic platforms as patching
+# of configure.ac is not required to change results of tests.
+#
+# LICENSE
+#
+# Copyright (c) 2019 Karlson2k (Evgeny Grin) <address@hidden>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 1
+
+AC_DEFUN([MHD_CHECK_FUNC],[dnl
+ AC_PREREQ([2.64])dnl for AS_VAR_IF, m4_ifblank, m4_ifnblank
+ m4_ifblank(m4_translit([$1],[()],[ ]), [m4_fatal([First macro argument must
not be empty])])dnl
+ m4_ifblank([$3], [m4_fatal([Third macro argument must not be empty])])dnl
+ m4_bmatch(m4_normalize([$1]), [\s],dnl
+ [m4_fatal([First macro argument must not contain whitespaces])])dnl
+ m4_if(m4_index([$3], m4_normalize(m4_translit([$1],[()],[ ]))), [-1], dnl
+ [m4_fatal([CHECK_CODE parameter (third macro argument) do not contain
']m4_normalize([$1])[' token])])dnl
+ AS_VAR_PUSHDEF([cv_Var],
[mhd_cv_func_]m4_bpatsubst(m4_normalize(m4_translit([$1],[()],[
])),[[^a-zA-Z0-9]],[_]))dnl
+ dnl
+ AC_CACHE_CHECK([for function $1], [cv_Var],
+ [dnl
+ m4_ifnblank([$6],[dnl
+ mhd_check_func_SAVE_LIBS="$LIBS"
+ LIBS="$LIBS m4_normalize([$6])"
+ ])dnl
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([m4_default_nblank([$2],[AC_INCLUDES_DEFAULT])],
[$3]) ],
+ [AS_VAR_SET([cv_Var],["yes"])], [AS_VAR_SET([cv_Var],["no"])] )
+ m4_ifnblank([$6],[dnl
+ LIBS="${mhd_check_func_SAVE_LIBS}"
+ AS_UNSET([mhd_check_func_SAVE_LIBS])
+ ])dnl
+ ])
+ AS_VAR_IF([cv_Var], ["yes"],
+
[AC_DEFINE([[HAVE_]]m4_bpatsubst(m4_toupper(m4_normalize(m4_translit([$1],[()],[
]))),[[^A-Z0-9]],[_]),
+ [1], [Define to 1 if you have the
`]m4_normalize(m4_translit([$1],[()],[ ]))[' function.])
+ m4_n([$4])dnl
+ ], [$5])
+ AS_VAR_POPDEF([cv_Var])dnl
+])
+
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index fdca4de2..7d186025 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -6092,6 +6092,7 @@ MHD_start_daemon_va (unsigned int flags,
listen_fd = daemon->listen_fd;
}
+#ifdef HAVE_GETSOCKNAME
if ( (0 == daemon->port) &&
(0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) )
{ /* Get port number. */
@@ -6160,6 +6161,7 @@ MHD_start_daemon_va (unsigned int flags,
}
}
}
+#endif /* HAVE_GETSOCKNAME */
if ( (MHD_INVALID_SOCKET != listen_fd) &&
(! MHD_socket_nonblocking_ (listen_fd)) )
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [libmicrohttpd] branch master updated (2a59d367 -> 1f796283), gnunet, 2019/06/02
- [GNUnet-SVN] [libmicrohttpd] 03/05: Properly handle port detection if AF_UNIX socket is used on *BSD, macOS, gnunet, 2019/06/02
- [GNUnet-SVN] [libmicrohttpd] 05/05: Added support for SOCK_NOSIGPIPE from Solaris 11.4 and NetBSD 7+, gnunet, 2019/06/02
- [GNUnet-SVN] [libmicrohttpd] 02/05: Added .gitattributes, fixed line endings in ac_define_dir.m4, updated ac_define_dir.m4 to new version., gnunet, 2019/06/02
- [GNUnet-SVN] [libmicrohttpd] 04/05: configure: check for 'rand' and 'random' by MHD_CHECK_FUNC, gnunet, 2019/06/02
- [GNUnet-SVN] [libmicrohttpd] 01/05: configure: fixed detection of 'getsockname' on some systems (W32 x32), do not use 'getsockname()' if it is not detected by configure.,
gnunet <=