1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-12 04:25:08 -05:00

configure: detect getsockname and getpeername on windows too

Made detection macros for these two functions in the same style as other
functions possibly in winsock in the hope this will work better to
detect these functions when cross-compiling for Windows.

Follow-up to e91e481612

Fixes #3913
Closes #3915
This commit is contained in:
Daniel Stenberg 2019-05-21 10:06:06 +02:00
parent b069815a7a
commit 9406d93e77
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
2 changed files with 197 additions and 2 deletions

View File

@ -3719,6 +3719,8 @@ CURL_CHECK_FUNC_GETHOSTBYADDR_R
CURL_CHECK_FUNC_GETHOSTBYNAME CURL_CHECK_FUNC_GETHOSTBYNAME
CURL_CHECK_FUNC_GETHOSTBYNAME_R CURL_CHECK_FUNC_GETHOSTBYNAME_R
CURL_CHECK_FUNC_GETHOSTNAME CURL_CHECK_FUNC_GETHOSTNAME
CURL_CHECK_FUNC_GETPEERNAME
CURL_CHECK_FUNC_GETSOCKNAME
CURL_CHECK_FUNC_GETIFADDRS CURL_CHECK_FUNC_GETIFADDRS
CURL_CHECK_FUNC_GETSERVBYPORT_R CURL_CHECK_FUNC_GETSERVBYPORT_R
CURL_CHECK_FUNC_GMTIME_R CURL_CHECK_FUNC_GMTIME_R
@ -3772,8 +3774,6 @@ AC_CHECK_FUNCS([fnmatch \
getpwuid_r \ getpwuid_r \
getrlimit \ getrlimit \
gettimeofday \ gettimeofday \
getpeername \
getsockname \
if_nametoindex \ if_nametoindex \
mach_absolute_time \ mach_absolute_time \
pipe \ pipe \

View File

@ -2912,6 +2912,201 @@ AC_DEFUN([CURL_CHECK_FUNC_GETHOSTNAME], [
fi fi
]) ])
dnl CURL_CHECK_FUNC_GETPEERNAME
dnl -------------------------------------------------
dnl Verify if getpeername is available, prototyped, and
dnl can be compiled. If all of these are true, and
dnl usage has not been previously disallowed with
dnl shell variable curl_disallow_getpeername, then
dnl HAVE_GETPEERNAME will be defined.
AC_DEFUN([CURL_CHECK_FUNC_GETPEERNAME], [
AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
#
tst_links_getpeername="unknown"
tst_proto_getpeername="unknown"
tst_compi_getpeername="unknown"
tst_allow_getpeername="unknown"
#
AC_MSG_CHECKING([if getpeername can be linked])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
$curl_includes_winsock2
$curl_includes_bsdsocket
$curl_includes_sys_socket
]],[[
if(0 != getpeername(0, (void *)0, (void *)0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_links_getpeername="yes"
],[
AC_MSG_RESULT([no])
tst_links_getpeername="no"
])
#
if test "$tst_links_getpeername" = "yes"; then
AC_MSG_CHECKING([if getpeername is prototyped])
AC_EGREP_CPP([getpeername],[
$curl_includes_winsock2
$curl_includes_bsdsocket
$curl_includes_sys_socket
],[
AC_MSG_RESULT([yes])
tst_proto_getpeername="yes"
],[
AC_MSG_RESULT([no])
tst_proto_getpeername="no"
])
fi
#
if test "$tst_proto_getpeername" = "yes"; then
AC_MSG_CHECKING([if getpeername is compilable])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$curl_includes_winsock2
$curl_includes_bsdsocket
$curl_includes_sys_socket
]],[[
if(0 != getpeername(0, (void *)0, (void *)0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_compi_getpeername="yes"
],[
AC_MSG_RESULT([no])
tst_compi_getpeername="no"
])
fi
#
if test "$tst_compi_getpeername" = "yes"; then
AC_MSG_CHECKING([if getpeername usage allowed])
if test "x$curl_disallow_getpeername" != "xyes"; then
AC_MSG_RESULT([yes])
tst_allow_getpeername="yes"
else
AC_MSG_RESULT([no])
tst_allow_getpeername="no"
fi
fi
#
AC_MSG_CHECKING([if getpeername might be used])
if test "$tst_links_getpeername" = "yes" &&
test "$tst_proto_getpeername" = "yes" &&
test "$tst_compi_getpeername" = "yes" &&
test "$tst_allow_getpeername" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_GETPEERNAME, 1,
[Define to 1 if you have the getpeername function.])
curl_cv_func_getpeername="yes"
else
AC_MSG_RESULT([no])
curl_cv_func_getpeername="no"
fi
])
dnl CURL_CHECK_FUNC_GETSOCKNAME
dnl -------------------------------------------------
dnl Verify if getsockname is available, prototyped, and
dnl can be compiled. If all of these are true, and
dnl usage has not been previously disallowed with
dnl shell variable curl_disallow_getsockname, then
dnl HAVE_GETSOCKNAME will be defined.
AC_DEFUN([CURL_CHECK_FUNC_GETSOCKNAME], [
AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl
AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
AC_REQUIRE([CURL_INCLUDES_BSDSOCKET])dnl
#
tst_links_getsockname="unknown"
tst_proto_getsockname="unknown"
tst_compi_getsockname="unknown"
tst_allow_getsockname="unknown"
#
AC_MSG_CHECKING([if getsockname can be linked])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
$curl_includes_winsock2
$curl_includes_bsdsocket
$curl_includes_sys_socket
]],[[
if(0 != getsockname(0, (void *)0, (void *)0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_links_getsockname="yes"
],[
AC_MSG_RESULT([no])
tst_links_getsockname="no"
])
#
if test "$tst_links_getsockname" = "yes"; then
AC_MSG_CHECKING([if getsockname is prototyped])
AC_EGREP_CPP([getsockname],[
$curl_includes_winsock2
$curl_includes_bsdsocket
$curl_includes_sys_socket
],[
AC_MSG_RESULT([yes])
tst_proto_getsockname="yes"
],[
AC_MSG_RESULT([no])
tst_proto_getsockname="no"
])
fi
#
if test "$tst_proto_getsockname" = "yes"; then
AC_MSG_CHECKING([if getsockname is compilable])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$curl_includes_winsock2
$curl_includes_bsdsocket
$curl_includes_sys_socket
]],[[
if(0 != getsockname(0, (void *)0, (void *)0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_compi_getsockname="yes"
],[
AC_MSG_RESULT([no])
tst_compi_getsockname="no"
])
fi
#
if test "$tst_compi_getsockname" = "yes"; then
AC_MSG_CHECKING([if getsockname usage allowed])
if test "x$curl_disallow_getsockname" != "xyes"; then
AC_MSG_RESULT([yes])
tst_allow_getsockname="yes"
else
AC_MSG_RESULT([no])
tst_allow_getsockname="no"
fi
fi
#
AC_MSG_CHECKING([if getsockname might be used])
if test "$tst_links_getsockname" = "yes" &&
test "$tst_proto_getsockname" = "yes" &&
test "$tst_compi_getsockname" = "yes" &&
test "$tst_allow_getsockname" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_GETSOCKNAME, 1,
[Define to 1 if you have the getsockname function.])
curl_cv_func_getsockname="yes"
else
AC_MSG_RESULT([no])
curl_cv_func_getsockname="no"
fi
])
dnl CURL_CHECK_FUNC_GETIFADDRS dnl CURL_CHECK_FUNC_GETIFADDRS
dnl ------------------------------------------------- dnl -------------------------------------------------