Bug 1747322 - Move sockaddr_* length field checks to python configure. r=firefox-build-system-reviewers,andi

Differential Revision: https://phabricator.services.mozilla.com/D134562
This commit is contained in:
Mike Hommey 2021-12-23 20:50:38 +00:00
parent f6dcab80de
commit efd23948af
2 changed files with 27 additions and 48 deletions

View File

@ -764,54 +764,6 @@ dnl Checks for header files.
dnl ========================================================
AC_HEADER_DIRENT
dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
AC_CACHE_CHECK(for sockaddr_in.sin_len,
ac_cv_sockaddr_in_sin_len,
[AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <netinet/in.h>
struct sockaddr_in x;
void *foo = (void*) &x.sin_len;],
[],
[ac_cv_sockaddr_in_sin_len=true],
[ac_cv_sockaddr_in_sin_len=false])])
if test "$ac_cv_sockaddr_in_sin_len" = true ; then
AC_DEFINE(HAVE_SIN_LEN)
dnl HAVE_CONN_LEN must be the same as HAVE_SIN_LEN (and HAVE_SIN6_LEN too)
AC_DEFINE(HAVE_SCONN_LEN)
fi
AC_CACHE_CHECK(for sockaddr_in6.sin6_len,
ac_cv_sockaddr_in6_sin6_len,
[AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <netinet/in.h>
struct sockaddr_in6 x;
void *foo = (void*) &x.sin6_len;],
[],
[ac_cv_sockaddr_in6_sin6_len=true],
[ac_cv_sockaddr_in6_sin6_len=false])])
if test "$ac_cv_sockaddr_in6_sin6_len" = true ; then
AC_DEFINE(HAVE_SIN6_LEN)
fi
AC_CACHE_CHECK(for sockaddr.sa_len,
ac_cv_sockaddr_sa_len,
[AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <sys/socket.h>
struct sockaddr x;
void *foo = (void*) &x.sa_len;],
[],
[ac_cv_sockaddr_sa_len=true],
[ac_cv_sockaddr_sa_len=false])])
if test "$ac_cv_sockaddr_sa_len" = true ; then
AC_DEFINE(HAVE_SA_LEN)
fi
dnl Checks for libraries.
dnl ========================================================
AC_CHECK_LIB(c_r, gethostbyname_r)

View File

@ -2915,3 +2915,30 @@ with only_when(compile_environment):
return '"{}"'.format(appdir[0])
set_define("MOZ_USER_DIR", user_appdir)
# Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
# ==============================================================
with only_when(compile_environment):
have_sin_len = c_compiler.try_compile(
includes=["netinet/in.h"],
body="struct sockaddr_in x; void *foo = (void*) &x.sin_len;",
check_msg="for sin_len in struct sockaddr_in",
)
have_sin6_len = c_compiler.try_compile(
includes=["netinet/in.h"],
body="struct sockaddr_in6 x; void *foo = (void*) &x.sin6_len;",
check_msg="for sin_len6 in struct sockaddr_in6",
)
set_define("HAVE_SIN_LEN", have_sin_len)
set_define("HAVE_SIN6_LEN", have_sin6_len)
# HAVE_CONN_LEN must be the same as HAVE_SIN_LEN and HAVE_SIN6_LEN
set_define("HAVE_SCONN_LEN", have_sin_len & have_sin6_len)
set_define(
"HAVE_SA_LEN",
c_compiler.try_compile(
includes=["netinet/in.h"],
body="struct sockaddr x; void *foo = (void*) &x.sa_len;",
check_msg="for sa_len in struct sockaddr",
),
)