Instead of detecting MUSL libc, detect padding in struct msghdr

The detection of MUSL libc via autoconf $host turned out to be
not reliable.

Convert the autoconf check from $host detection to actually detect
the padding used in the struct msghdr.
This commit is contained in:
Ondrej Sury
2022-01-13 23:05:38 +01:00
committed by Ondřej Surý
parent 86f9b16fd7
commit 04eeb67d97
3 changed files with 45 additions and 21 deletions
+2 -1
View File
@@ -83,7 +83,8 @@
you don't. */
#undef HAVE_DECL_UV_UDP_MMSG_FREE
/* Disable recvmmsg support on systems with MUSL glibc */
/* Define to 1 if you have the declaration of `UV_UDP_RECVMMSG', and to 0 if
you don't. */
#undef HAVE_DECL_UV_UDP_RECVMMSG
/* Define to 1 if you have the <devpoll.h> header file. */
Vendored
+34 -17
View File
@@ -16305,17 +16305,6 @@ $as_echo "yes" >&6; }
fi
# libuv recvmmsg support
ac_fn_c_check_decl "$LINENO" "UV_UDP_RECVMMSG" "ac_cv_have_decl_UV_UDP_RECVMMSG" "#include <uv.h>
"
if test "x$ac_cv_have_decl_UV_UDP_RECVMMSG" = xyes; then :
ac_have_decl=1
else
ac_have_decl=0
fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_UV_UDP_RECVMMSG $ac_have_decl
_ACEOF
ac_fn_c_check_decl "$LINENO" "UV_UDP_MMSG_FREE" "ac_cv_have_decl_UV_UDP_MMSG_FREE" "#include <uv.h>
"
if test "x$ac_cv_have_decl_UV_UDP_MMSG_FREE" = xyes; then :
@@ -16339,14 +16328,42 @@ cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_UV_UDP_MMSG_CHUNK $ac_have_decl
_ACEOF
case $host in #(
*-musl) :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct msghdr uses padding for alignment" >&5
$as_echo_n "checking whether struct msghdr uses padding for alignment... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/socket.h>
int
main ()
{
const struct msghdr h = { .__pad1 = 0, .__pad2 = 0 };
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define HAVE_DECL_UV_UDP_RECVMMSG 0" >>confdefs.h
;; #(
*) :
;;
esac
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
ac_fn_c_check_decl "$LINENO" "UV_UDP_RECVMMSG" "ac_cv_have_decl_UV_UDP_RECVMMSG" "#include <uv.h>
"
if test "x$ac_cv_have_decl_UV_UDP_RECVMMSG" = xyes; then :
ac_have_decl=1
else
ac_have_decl=0
fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_UV_UDP_RECVMMSG $ac_have_decl
_ACEOF
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
#
# flockfile is usually provided by pthreads
+9 -3
View File
@@ -731,9 +731,15 @@ PKG_CHECK_MODULES([LIBUV], [libuv >= 1.0.0], [],
[AC_MSG_ERROR([libuv not found])])
# libuv recvmmsg support
AC_CHECK_DECLS([UV_UDP_RECVMMSG, UV_UDP_MMSG_FREE, UV_UDP_MMSG_CHUNK], [], [], [[#include <uv.h>]])
AS_CASE([$host],
[*-musl],[AC_DEFINE([HAVE_DECL_UV_UDP_RECVMMSG], [0], [Disable recvmmsg support on systems with MUSL glibc])])
AC_CHECK_DECLS([UV_UDP_MMSG_FREE, UV_UDP_MMSG_CHUNK], [], [], [[#include <uv.h>]])
AC_MSG_CHECKING([whether struct msghdr uses padding for alignment])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/socket.h>],
[const struct msghdr h = { .__pad1 = 0, .__pad2 = 0 };])],
[AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_DECL_UV_UDP_RECVMMSG],
[0], [Disable recvmmsg support on systems with MUSL glibc])],
[AC_MSG_RESULT([no])
AC_CHECK_DECLS([UV_UDP_RECVMMSG], [], [], [[#include <uv.h>]])])
#
# flockfile is usually provided by pthreads