summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2009-11-14 18:51:37 +0000
committerYang Tse <yangsita@gmail.com>2009-11-14 18:51:37 +0000
commite43ac04a1f6a04620eaf111e144dac7f3bb2f77e (patch)
tree143b9f27e851611b1eeeffff1d3e9c298ce1fe3e
parentccabe949dda62bc0365fe6e624ccaecb686c1968 (diff)
downloadc-ares-e43ac04a1f6a04620eaf111e144dac7f3bb2f77e.tar.gz
c-ares-e43ac04a1f6a04620eaf111e144dac7f3bb2f77e.tar.bz2
c-ares-e43ac04a1f6a04620eaf111e144dac7f3bb2f77e.zip
Refactor how preprocessor symbol _THREAD_SAFE definition is done.
-rw-r--r--ares_setup.h11
-rw-r--r--configure.ac22
-rw-r--r--m4/cares-reentrant.m4100
3 files changed, 110 insertions, 23 deletions
diff --git a/ares_setup.h b/ares_setup.h
index 5896437..ce81b1f 100644
--- a/ares_setup.h
+++ b/ares_setup.h
@@ -49,6 +49,17 @@
/* ================================================================ */
/*
+ * AIX 4.3 and newer needs _THREAD_SAFE defined to build
+ * proper reentrant code. Others may also need it.
+ */
+
+#ifdef NEED_THREAD_SAFE
+# ifndef _THREAD_SAFE
+# define _THREAD_SAFE
+# endif
+#endif
+
+/*
* Tru64 needs _REENTRANT set for a few function prototypes and
* things to appear in the system header files. Unixware needs it
* to build proper reentrant code. Others may also need it.
diff --git a/configure.ac b/configure.ac
index 8f1cddb..f1f52a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,6 +82,7 @@ dnl This defines _ALL_SOURCE for AIX
CARES_CHECK_AIX_ALL_SOURCE
dnl Our configure and build reentrant settings
+CARES_CONFIGURE_THREAD_SAFE
CARES_CONFIGURE_REENTRANT
dnl check for how to do large files
@@ -384,21 +385,6 @@ AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
dnl Default is to try the thread-safe versions of a few functions
OPT_THREAD=on
-dnl detect AIX 4.3 or later
-AC_MSG_CHECKING([AIX 4.3 or later])
-AC_PREPROC_IFELSE([
-#if defined(_AIX) && defined(_AIX43)
-printf("just fine");
-#else
-#error "this is not AIX 4.3 or later"
-#endif
-],
- [ AC_MSG_RESULT([yes])
- RECENTAIX=yes
- OPT_THREAD=off ],
- [ AC_MSG_RESULT([no]) ]
-)
-
AC_ARG_ENABLE(thread,dnl
AC_HELP_STRING([--disable-thread],[don't look for thread-safe functions])
AC_HELP_STRING([--enable-thread],[look for thread-safe functions]),
@@ -427,12 +413,6 @@ dnl Let's hope this split URL remains working:
dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
dnl genprogc/thread_quick_ref.htm
-if test "x$RECENTAIX" = "xyes"; then
-
- AC_DEFINE(_THREAD_SAFE, 1, [define this if you need it to compile thread-safe code])
-
-fi
-
dnl **********************************************************************
dnl Back to "normal" configuring
diff --git a/m4/cares-reentrant.m4 b/m4/cares-reentrant.m4
index 5793b77..2c24e55 100644
--- a/m4/cares-reentrant.m4
+++ b/m4/cares-reentrant.m4
@@ -422,8 +422,8 @@ dnl must be unconditionally done for this platform.
dnl Internal macro for CARES_CONFIGURE_REENTRANT.
AC_DEFUN([CARES_CHECK_NEED_REENTRANT_SYSTEM], [
- case $host in
- *-*-solaris*)
+ case $host_os in
+ solaris*)
tmp_need_reentrant="yes"
;;
*)
@@ -433,6 +433,29 @@ AC_DEFUN([CARES_CHECK_NEED_REENTRANT_SYSTEM], [
])
+dnl CARES_CHECK_NEED_THREAD_SAFE_SYSTEM
+dnl -------------------------------------------------
+dnl Checks if the preprocessor _THREAD_SAFE definition
+dnl must be unconditionally done for this platform.
+dnl Internal macro for CARES_CONFIGURE_THREAD_SAFE.
+
+AC_DEFUN([CARES_CHECK_NEED_THREAD_SAFE_SYSTEM], [
+ case $host_os in
+ aix[[123]].* | aix4.[[012]].*)
+ dnl aix 4.2 and older
+ tmp_need_thread_safe="no"
+ ;;
+ aix*)
+ dnl AIX 4.3 and newer
+ tmp_need_thread_safe="yes"
+ ;;
+ *)
+ tmp_need_thread_safe="no"
+ ;;
+ esac
+])
+
+
dnl CARES_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
dnl -------------------------------------------------
dnl This macro ensures that configuration tests done
@@ -453,6 +476,26 @@ _EOF
])
+dnl CARES_CONFIGURE_FROM_NOW_ON_WITH_THREAD_SAFE
+dnl -------------------------------------------------
+dnl This macro ensures that configuration tests done
+dnl after this will execute with preprocessor symbol
+dnl _THREAD_SAFE defined. This macro also ensures that
+dnl the generated config file defines NEED_THREAD_SAFE
+dnl and that in turn setup.h will define _THREAD_SAFE.
+dnl Internal macro for CARES_CONFIGURE_THREAD_SAFE.
+
+AC_DEFUN([CARES_CONFIGURE_FROM_NOW_ON_WITH_THREAD_SAFE], [
+AC_DEFINE(NEED_THREAD_SAFE, 1,
+ [Define to 1 if _THREAD_SAFE preprocessor symbol must be defined.])
+cat >>confdefs.h <<_EOF
+#ifndef _THREAD_SAFE
+# define _THREAD_SAFE
+#endif
+_EOF
+])
+
+
dnl CARES_CONFIGURE_REENTRANT
dnl -------------------------------------------------
dnl This first checks if the preprocessor _REENTRANT
@@ -513,3 +556,56 @@ AC_DEFUN([CARES_CONFIGURE_REENTRANT], [
#
])
+
+dnl CARES_CONFIGURE_THREAD_SAFE
+dnl -------------------------------------------------
+dnl This first checks if the preprocessor _THREAD_SAFE
+dnl symbol is already defined. If it isn't currently
+dnl defined a set of checks are performed to verify
+dnl if its definition is required. Finally, if
+dnl _THREAD_SAFE is already defined or needed it takes
+dnl care of making adjustments necessary to ensure
+dnl that it is defined equally for further configure
+dnl tests and generated config file.
+
+AC_DEFUN([CARES_CONFIGURE_THREAD_SAFE], [
+ AC_PREREQ([2.50])dnl
+ #
+ AC_MSG_CHECKING([if _THREAD_SAFE is already defined])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ ]],[[
+#ifdef _THREAD_SAFE
+ int dummy=1;
+#else
+ force compilation error
+#endif
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tmp_thread_safe_initially_defined="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tmp_thread_safe_initially_defined="no"
+ ])
+ #
+ if test "$tmp_thread_safe_initially_defined" = "no"; then
+ AC_MSG_CHECKING([if _THREAD_SAFE is actually needed])
+ CARES_CHECK_NEED_THREAD_SAFE_SYSTEM
+ if test "$tmp_need_thread_safe" = "yes"; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+ #
+ AC_MSG_CHECKING([if _THREAD_SAFE is onwards defined])
+ if test "$tmp_thread_safe_initially_defined" = "yes" ||
+ test "$tmp_need_thread_safe" = "yes"; then
+ CARES_CONFIGURE_FROM_NOW_ON_WITH_THREAD_SAFE
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ #
+])