]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
Refactor how preprocessor symbol _THREAD_SAFE definition is done.
authorYang Tse <yangsita@gmail.com>
Sat, 14 Nov 2009 18:51:37 +0000 (18:51 +0000)
committerYang Tse <yangsita@gmail.com>
Sat, 14 Nov 2009 18:51:37 +0000 (18:51 +0000)
ares/ares_setup.h
ares/configure.ac
ares/m4/cares-reentrant.m4
configure.ac
lib/config-symbian.h
lib/config-tpf.h
lib/config-vxworks.h
lib/setup.h
m4/curl-reentrant.m4
src/setup.h

index 589643716def0c1375529ff02f2df358635eba4a..ce81b1fa3fdcfb5b75113e6f9089fe240893ff30 100644 (file)
 /* system header files in our config files, avoid this at any cost. */
 /* ================================================================ */
 
+/*
+ * 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
index 8f1cddb5bfb759e0b3a4e49d660f3f33fb0d21f5..f1f52a5bcfa29166c973e38202be5f2436f56c93 100644 (file)
@@ -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
index 5793b779144b7281059abb044c431a39a38cef1b..2c24e557d581b6d7a263bffdb1a2584c2dea9b7e 100644 (file)
@@ -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
+  #
+])
index d2db6cf541de00f24519cd49463ec915f6bd617f..bc7e0e4bd8ffb28e92f1d86fcfa06d7347a380c1 100644 (file)
@@ -148,6 +148,7 @@ dnl This defines _ALL_SOURCE for AIX
 CURL_CHECK_AIX_ALL_SOURCE
 
 dnl Our configure and build reentrant settings
+CURL_CONFIGURE_THREAD_SAFE
 CURL_CONFIGURE_REENTRANT
 
 dnl check for how to do large files
@@ -1823,22 +1824,6 @@ esac
 dnl Default is to try the thread-safe versions of a few functions
 OPT_THREAD=on
 
-dnl detect AIX 4.3 or later
-dnl see full docs on this reasoning in the lib/hostip.c source file
-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]),
@@ -1886,19 +1871,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])
-
-  dnl is there a localtime_r()
-  dnl the old localtime_r check was done here
-
-  dnl is there a strerror_r()
-  dnl the old strerror_r check was done here
-
-  checkfor_gmtime_r="yes"
-fi
-
 
 dnl **********************************************************************
 dnl Back to "normal" configuring
index b26fe46cd5e37ae90d84adc0c5dc215bfea1fc34..d3bf209248047b638c01c35b583909536d5d3638 100644 (file)
 /* Define to 1 if you need the malloc.h header file even with stdlib.h */
 /* #undef NEED_MALLOC_H */
 
-/* need REENTRANT defined */
+/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
 /* #undef NEED_REENTRANT */
 
+/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */
+/* #undef NEED_THREAD_SAFE */
+
 /* cpu-machine-OS */
 #ifdef __WINS__
 #define OS "i386-pc-epoc32"
 /* Define for large files, on AIX-style hosts. */
 /* #undef _LARGE_FILES */
 
-/* define this if you need it to compile thread-safe code */
-/* #undef _THREAD_SAFE */
-
 /* Define to empty if `const' does not conform to ANSI C. */
 /* #undef const */
 
index cea5d3bd9278d75b1ea6e7c33f001c91605206f6..fd995bf4ca8514909ad61c6bc9364bf0d69b23e8 100644 (file)
 /* if you have the zlib.h header file */
 /* #undef HAVE_ZLIB_H */
 
-/* need REENTRANT defined */
+/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
 /* #undef NEED_REENTRANT */
 
+/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */
+/* #undef NEED_THREAD_SAFE */
+
 /* cpu-machine-OS */
 #define OS "s390x-ibm-tpf"
 
 /* Define for large files, on AIX-style hosts. */
 /* #undef _LARGE_FILES */
 
-/* define this if you need it to compile thread-safe code */
-/* #undef _THREAD_SAFE */
-
 /* Define to empty if `const' does not conform to ANSI C. */
 /* #undef const */
 
index 34a8c7172721f98b17cf97199d9df9b2b2cf5eb4..26b8074d5962eead1ae202cb340208c21cd712f7 100644 (file)
 /* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
 /* #undef NEED_REENTRANT */
 
+/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */
+/* #undef NEED_THREAD_SAFE */
+
 /* Define to 1 if the open function requires three arguments. */
 #define OPEN_NEEDS_ARG3 1
 
 /* Define for large files, on AIX-style hosts. */
 /* #undef _LARGE_FILES */
 
-/* define this if you need it to compile thread-safe code */
-/* #undef _THREAD_SAFE */
-
 /* Define to empty if `const' does not conform to ANSI C. */
 /* #undef const */
 
index 5f0de9050771812f3020a3172e6d1c0473a535d3..49d14ed0942168a40c2e39fe8e5413e457e64a27 100644 (file)
 /* system header files in our config files, avoid this at any cost. */
 /* ================================================================ */
 
+/*
+ * 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
index a2aa5a96ebde39be2fe83648ff615dc6e45f188d..08e1452110a1bbcc4414a3fbd28bc8fda6f8b7e1 100644 (file)
@@ -428,8 +428,8 @@ dnl must be unconditionally done for this platform.
 dnl Internal macro for CURL_CONFIGURE_REENTRANT.
 
 AC_DEFUN([CURL_CHECK_NEED_REENTRANT_SYSTEM], [
-  case $host in
-    *-*-solaris*)
+  case $host_os in
+    solaris*)
       tmp_need_reentrant="yes"
       ;;
     *)
@@ -439,6 +439,29 @@ AC_DEFUN([CURL_CHECK_NEED_REENTRANT_SYSTEM], [
 ])
 
 
+dnl CURL_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 CURL_CONFIGURE_THREAD_SAFE.
+
+AC_DEFUN([CURL_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 CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
 dnl -------------------------------------------------
 dnl This macro ensures that configuration tests done
@@ -459,6 +482,26 @@ _EOF
 ])
 
 
+dnl CURL_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 CURL_CONFIGURE_THREAD_SAFE.
+
+AC_DEFUN([CURL_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 CURL_CONFIGURE_REENTRANT
 dnl -------------------------------------------------
 dnl This first checks if the preprocessor _REENTRANT
@@ -519,3 +562,57 @@ AC_DEFUN([CURL_CONFIGURE_REENTRANT], [
   #
 ])
 
+
+dnl CURL_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([CURL_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])
+    CURL_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
+    CURL_CONFIGURE_FROM_NOW_ON_WITH_THREAD_SAFE
+    AC_MSG_RESULT([yes])
+  else
+    AC_MSG_RESULT([no])
+  fi
+  #
+])
+
index 9120af17461bb7fa187e051a764d55c85bf46ace..36fde516fefa6f8b709daac083ec49634a13666c 100644 (file)
 
 #endif /* HAVE_CONFIG_H */
 
+/*
+ * 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