summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2012-12-15 17:36:09 +0100
committerYang Tse <yangsita@gmail.com>2012-12-15 17:36:09 +0100
commita28e44c34448b52159e3e1549d04c4b97e1a6d7b (patch)
tree1245437355901731dc83009b705bf345f299c8ed
parent4ed0fc2d448d70dd079a311fa9804d504968942f (diff)
downloadc-ares-a28e44c34448b52159e3e1549d04c4b97e1a6d7b.tar.gz
c-ares-a28e44c34448b52159e3e1549d04c4b97e1a6d7b.tar.bz2
c-ares-a28e44c34448b52159e3e1549d04c4b97e1a6d7b.zip
cares-functions.m4: update thread-safeness detection of getaddrinfo()
Take in account that POSIX standard Issue 7 drops h_errno support. Now, we also consider getaddrinfo() to be thread-safe when (_POSIX_C_SOURCE >= 200809L) or (_XOPEN_SOURCE >= 700) independently of whether h_errno exists or not. Take in account that h_errno might be a modifiable lvalue not defined as a C preprocessor macro.
-rw-r--r--m4/cares-functions.m454
1 files changed, 47 insertions, 7 deletions
diff --git a/m4/cares-functions.m4 b/m4/cares-functions.m4
index 68d2ba9..0deb6de 100644
--- a/m4/cares-functions.m4
+++ b/m4/cares-functions.m4
@@ -1,6 +1,6 @@
#***************************************************************************
#
-# Copyright (C) 2008 - 2011 by Daniel Stenberg et al
+# Copyright (C) 2008 - 2012 by Daniel Stenberg et al
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
@@ -15,7 +15,7 @@
#***************************************************************************
# File version for 'aclocal' use. Keep it a single number.
-# serial 43
+# serial 44
dnl CARES_INCLUDES_ARPA_INET
@@ -883,6 +883,7 @@ AC_DEFUN([CARES_CHECK_FUNC_GETADDRINFO], [
AC_REQUIRE([CARES_INCLUDES_STRING])dnl
AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
AC_REQUIRE([CARES_INCLUDES_NETDB])dnl
+ AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl
#
tst_links_getaddrinfo="unknown"
tst_proto_getaddrinfo="unknown"
@@ -1059,19 +1060,58 @@ AC_DEFUN([CARES_CHECK_FUNC_GETADDRINFO], [
tst_tsafe_getaddrinfo="yes"
;;
esac
+ if test "$tst_tsafe_getaddrinfo" = "unknown" &&
+ test "$ac_cv_native_windows" = "yes"; then
+ tst_tsafe_getaddrinfo="yes"
+ fi
if test "$tst_tsafe_getaddrinfo" = "unknown"; then
CURL_CHECK_DEF_CC([h_errno], [
- $cares_includes_ws2tcpip
$cares_includes_sys_socket
$cares_includes_netdb
], [silent])
- if test "$curl_cv_have_def_h_errno" = "no"; then
+ if test "$curl_cv_have_def_h_errno" = "yes"; then
+ tst_h_errno_macro="yes"
+ else
+ tst_h_errno_macro="no"
+ fi
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $cares_includes_sys_socket
+ $cares_includes_netdb
+ ]],[[
+ h_errno = 2;
+ if(0 != h_errno)
+ return 1;
+ ]])
+ ],[
+ tst_h_errno_modifiable_lvalue="yes"
+ ],[
+ tst_h_errno_modifiable_lvalue="no"
+ ])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ ]],[[
+#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L)
+ return 0;
+#elif defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 700)
+ return 0;
+#else
+ force compilation error
+#endif
+ ]])
+ ],[
+ tst_h_errno_sbs_issue_7="yes"
+ ],[
+ tst_h_errno_sbs_issue_7="no"
+ ])
+ if test "$tst_h_errno_macro" = "no" &&
+ test "$tst_h_errno_modifiable_lvalue" = "no" &&
+ test "$tst_h_errno_sbs_issue_7" = "no"; then
tst_tsafe_getaddrinfo="no"
+ else
+ tst_tsafe_getaddrinfo="yes"
fi
fi
- if test "$tst_tsafe_getaddrinfo" = "unknown"; then
- tst_tsafe_getaddrinfo="yes"
- fi
AC_MSG_RESULT([$tst_tsafe_getaddrinfo])
if test "$tst_tsafe_getaddrinfo" = "yes"; then
AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO_THREADSAFE, 1,