aboutsummaryrefslogtreecommitdiff
path: root/m4
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
commit1cbc93fb54b773d1564bf2f2194d81c02a985a81 (patch)
tree37c22d1a2eeb535cce65c8f5c08738397ecb6c59 /m4
parenta8ddd6ce3141bc4c8745eddae31db1887eeacd0a (diff)
Refactor how preprocessor symbol _THREAD_SAFE definition is done.
Diffstat (limited to 'm4')
-rw-r--r--m4/curl-reentrant.m4101
1 files changed, 99 insertions, 2 deletions
diff --git a/m4/curl-reentrant.m4 b/m4/curl-reentrant.m4
index a2aa5a96e..08e145211 100644
--- a/m4/curl-reentrant.m4
+++ b/m4/curl-reentrant.m4
@@ -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
+ #
+])
+