summaryrefslogtreecommitdiff
path: root/m4/threads.m4
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2003-04-17 23:16:14 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2003-04-17 23:16:14 +0000
commit7b4c35806bd1119420d6b231f81df06166d97ab2 (patch)
tree49ecf01b243f57c814c3dc71bcf1cf10b432dfde /m4/threads.m4
parent5c9f212b4c3a76576f19660e6184e63beade6451 (diff)
downloadATCD-7b4c35806bd1119420d6b231f81df06166d97ab2.tar.gz
ChangeLogTag:Thu Apr 17 16:15:24 2003 Ossama Othman <ossama@dre.vanderbilt.edu>
Diffstat (limited to 'm4/threads.m4')
-rw-r--r--m4/threads.m4251
1 files changed, 96 insertions, 155 deletions
diff --git a/m4/threads.m4 b/m4/threads.m4
index e652000a96c..56f2fe394e9 100644
--- a/m4/threads.m4
+++ b/m4/threads.m4
@@ -1,21 +1,21 @@
dnl -------------------------------------------------------------------------
dnl $Id$
-dnl
+dnl
dnl threads.m4
-dnl
+dnl
dnl ACE M4 include file which contains ACE specific M4 macros
dnl for configuring thread support. This file is to be used
dnl with the configure script.
-dnl
+dnl
dnl -------------------------------------------------------------------------
-dnl Copyright (C) 1998, 1999 Ossama Othman
+dnl Copyright (C) 1998, 1999, 2002 Ossama Othman
dnl
dnl All Rights Reserved
dnl
dnl This library is free software; you can redistribute it and/or
dnl modify it under the current ACE distribution terms.
-dnl
+dnl
dnl This library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@@ -27,19 +27,18 @@ dnl Tests should probably be more platform specific later on.
dnl Check for thread related libraries and compiler flags
dnl Usage: ACE_CHECK_THREADS
-AC_DEFUN(ACE_CHECK_THREADS, dnl
+AC_DEFUN([ACE_CHECK_THREADS],
[
dnl AC_REQUIRE([AC_PROG_CXX])
dnl AC_REQUIRE([AC_PROG_CXXCPP])
-dnl AC_REQUIRE([AC_LANG_CPLUSPLUS])
+dnl AC_LANG([C++])
+dnl AC_REQUIRE([AC_LANG])
dnl Check if compiler accepts specific flag to enable threads
- ACE_CACHE_CHECK(if compiler may need a thread flag,
- ace_cv_feature_may_need_thread_flag,
+ ACE_CACHE_CHECK([if compiler may need a thread flag],
+ [ace_cv_feature_may_need_thread_flag],
[
- ifelse(AC_LANG, [CPLUSPLUS],
- [ace_save_CXXFLAGS="$CXXFLAGS"],
- [ace_save_CFLAGS="$CFLAGS"])
+ ace_save_CXXFLAGS="$CXXFLAGS"
ACE_CHECK_THREAD_FLAGS(
[
@@ -51,8 +50,7 @@ dnl AC_REQUIRE([AC_LANG_CPLUSPLUS])
dnl Reset the flags to a consistent state.
dnl This prevents duplicate flags from being added to
dnl the C/CXXFLAGS variable.
- ifelse(AC_LANG, [CPLUSPLUS],
- [CXXFLAGS="$ace_save_CXXFLAGS"],[CFLAGS="$ace_save_CFLAGS"])
+ CXXFLAGS="$ace_save_CXXFLAGS"
],
[
dnl The compiler/platform has no thread support linked in by default
@@ -70,10 +68,10 @@ dnl AC_REQUIRE([AC_LANG_CPLUSPLUS])
])
dnl Check for UNIX International Threads -- STHREADS
- ACE_SEARCH_LIBS(thr_create, thread,
+ AC_SEARCH_LIBS([thr_create], [thread],
[
ace_has_sthreads=yes
- AC_DEFINE(ACE_HAS_STHREADS)
+ AC_DEFINE([ACE_HAS_STHREADS])
],
[
ace_has_sthreads=no
@@ -81,7 +79,7 @@ dnl AC_REQUIRE([AC_LANG_CPLUSPLUS])
dnl Sometimes thr_create is actually found with explicitly linking against
dnl -lthread, so try a more "exotic" function.
- ACE_SEARCH_LIBS(rwlock_destroy, thread,,)
+ AC_SEARCH_LIBS([rwlock_destroy], [thread],[],[])
dnl Check if any thread related preprocessor flags are needed.
ACE_CHECK_THREAD_CPPFLAGS
@@ -96,14 +94,14 @@ dnl AC_REQUIRE([AC_LANG_CPLUSPLUS])
dnl pthread_create() to co-exist with the old implementation of
dnl of pthread_create().)
- ACE_CACHE_CHECK(for pthreads backward compatibility macros,
- ace_cv_lib_pthread_compat_macros,
+ ACE_CACHE_CHECK([for pthreads backward compatibility macros],
+ [ace_cv_lib_pthread_compat_macros],
[
dnl Add thread preprocessor flags, if any.
ace_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$ACE_THR_CPPFLAGS $CPPFLAGS" dnl User's CPPFLAGS go last
- AC_EGREP_CPP(ACE_PTHREAD_MACROS,
+ AC_EGREP_CPP([ACE_PTHREAD_MACROS],
[
#include <pthread.h>
@@ -124,20 +122,20 @@ dnl AC_REQUIRE([AC_LANG_CPLUSPLUS])
[
dnl Check if pthread function names are mangled (e.g. DU 4.0)
dnl to maintain older Pthread Draft compatibility.
- ACE_CHECK_FUNC(pthread_create, pthread.h,
+ ACE_CHECK_FUNC([pthread_create], [pthread.h],
[
ace_has_pthreads=yes
- AC_DEFINE(ACE_HAS_PTHREADS)
+ AC_DEFINE([ACE_HAS_PTHREADS])
],
[
- ACE_CHECK_LIB(pthread, pthread_create, pthread.h, dnl
+ ACE_CHECK_LIB([pthread], [pthread_create], [pthread.h],
[
ace_has_pthreads=yes
dnl Since we AC_DEFINE(ACE_HAS_PTHREADS), the default behavior
dnl of adding "-lpthread" to the "LIBS" variable no longer
dnl works, so we have to add it manually.
LIBS="$LIBS -lpthread"
- AC_DEFINE(ACE_HAS_PTHREADS)
+ AC_DEFINE([ACE_HAS_PTHREADS])
],
[
ace_has_pthreads=yes
@@ -145,10 +143,10 @@ dnl AC_REQUIRE([AC_LANG_CPLUSPLUS])
])
],
[
- ACE_SEARCH_LIBS(pthread_create, pthread pthreads c_r gthreads,
+ AC_SEARCH_LIBS([pthread_create], [pthread pthreads c_r gthreads],
[
ace_has_pthreads=yes
- AC_DEFINE(ACE_HAS_PTHREADS)
+ AC_DEFINE([ACE_HAS_PTHREADS])
dnl This is ugly but some platforms appear to implement stubs
dnl in the C library, so it is possible that a no-op function
@@ -161,7 +159,7 @@ dnl AC_REQUIRE([AC_LANG_CPLUSPLUS])
dnl to the LIBS variable, which may not even be necessary. In
dnl any case, it may be the better solution. If problems arise
dnl in the future regarding this issue, then we should probably
- dnl switch to doing an AC_CHECK_LIB before each ACE_SEARCH_LIBS
+ dnl switch to doing an AC_CHECK_LIB before each AC_SEARCH_LIBS
dnl below.
dnl Search for functions in more recent standards first.
@@ -171,16 +169,16 @@ dnl AC_REQUIRE([AC_LANG_CPLUSPLUS])
dnl pthread_mutexattr_init.
dnl Draft 7 and Standard
- ACE_SEARCH_LIBS([pthread_setschedparam],
- [pthread pthreads c_r gthreads],,
+ AC_SEARCH_LIBS([pthread_setschedparam],
+ [pthread pthreads c_r gthreads],,
[
dnl Draft 6
- ACE_SEARCH_LIBS([pthread_attr_setprio],
- [pthread pthreads c_r gthreads],,
+ AC_SEARCH_LIBS([pthread_attr_setprio],
+ [pthread pthreads c_r gthreads],,
[
dnl Draft 4
- ACE_SEARCH_LIBS([pthread_setprio],
- [pthread pthreads c_r gthreads],,)
+ AC_SEARCH_LIBS([pthread_setprio],
+ [pthread pthreads c_r gthreads],,)
])
])
],
@@ -191,7 +189,7 @@ dnl AC_REQUIRE([AC_LANG_CPLUSPLUS])
dnl If we don't have any thread library, then disable threading altogether!
- if test "$ace_has_pthreads" != yes &&
+ if test "$ace_has_pthreads" != yes &&
test "$ace_has_sthreads" != yes; then
ace_user_enable_threads=no
fi
@@ -200,13 +198,12 @@ dnl AC_REQUIRE([AC_LANG_CPLUSPLUS])
dnl This macro will check that the current compiler flags do something
dnl useful in terms of thread libraries and/or functions.
dnl Usage: ACE_CHECK_THREAD_FLAGS(ACTION-IF-USABLE [, ACTION-IF-NOT-USABLE]])
-AC_DEFUN(ACE_CHECK_THREAD_FLAGS, dnl
+AC_DEFUN([ACE_CHECK_THREAD_FLAGS],
[
AC_REQUIRE([AC_PROG_AWK])
ACE_CONVERT_WARNINGS_TO_ERRORS([
-
-dnl Check for UI thread support first.
+ dnl Check for UI thread support first.
dnl Because some platforms are brain damaged enough to provide
dnl useless thread function stubs, link tests may succeed despite the
@@ -215,27 +212,23 @@ dnl Check for UI thread support first.
dnl thr_create(). The cross-compiled case will use a link-time
dnl test, instead.
- AC_TRY_RUN(
- [
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <thread.h>
- ]
-ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
-extern "C"
-#endif
-])
- [
-void * ace_start_func(void *arg)
+
+extern "C" void *
+ace_start_func (void *)
{
- return arg;
-};
+ return 0;
+}
-int main (int argc, char **argv)
+int
+main ()
{
thread_t tid = 0;
return thr_create (0, 0, ace_start_func, 0, 0, &tid);
}
- ],
+ ]])],
[$1],
[
dnl Now check for POSIX thread support.
@@ -246,108 +239,63 @@ int main (int argc, char **argv)
dnl to get around this nuisance by checking the return value of
dnl pthread_create(). The cross-compiled case will use a link-time
dnl test, instead.
- AC_TRY_RUN(
- [
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <pthread.h>
- ]
-ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
-extern "C"
-#endif
-])
- [
-void * ace_start_func(void *arg)
+
+extern "C" void *
+ace_start_func (void *)
{
- return arg;
-};
+ return 0;
+}
-int main (int argc, char **argv)
+int
+main ()
{
pthread_t tid = 0;
return pthread_create (&tid, 0, ace_start_func, 0);
}
- ],
+ ]])],
[$1],
[$2],
[
dnl POSIX threads cross-compiled case
- AC_TRY_CPP(
- [
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <pthread.h>
- ],
- [
- cat > conftest.$ac_ext <<EOF
-#include <pthread.h>
- ACE_REAL_FUNCTION pthread_create
-
-EOF
-
- if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "ACE_REAL_FUNCTION" |
- (eval "$AWK '{print \[$]2}' > conftest.awk 2>&1"); then
- rm -f conftest.$ac_ext
- ace_real_function=`cat conftest.awk`
- rm -f conftest.awk
- fi
- ],
- [
- ace_real_function="pthread_create"
- ])
+extern "C" void *
+ace_start_func (void *)
+{
+ return 0;
+}
+ ]],
+ [[
+ pthread_t tid = 0;
- AC_TRY_LINK(
- [
-/*
- * Don't use definition of specific preprocessor macros as criterion
- * for determining if thread support is found.
- *
- * #if !defined (_REENTRANT) && !defined (_THREAD_SAFE)
- * #error Neither _REENTRANT nor _THREAD_SAFE were defined.
- * THROW ME AN ERROR!
- * #endif
- *
- */
- ]
-ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
-extern "C"
-#endif
-])dnl
- [
-char $ace_real_function();
- ],
- [
-$ace_real_function();
- ],
+ (void) pthread_create (&tid, 0, ace_start_func, 0);
+ ]])],
[$1],
[$2])
])
],
[
dnl UI threads cross-compiled case
- AC_TRY_LINK(
- [
-/*
- * Don't use definition of specific preprocessor macros as criterion
- * for determining if thread support is found.
- *
- * #if !defined (_REENTRANT) && !defined (_THREAD_SAFE)
- * #error Neither _REENTRANT nor _THREAD_SAFE were defined.
- * THROW ME AN ERROR!
- * #endif
- *
- */
- ]
-ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
-extern "C"
-#endif
-])
- [
-char thr_create();
- ],
- [
-thr_create();
- ],
+
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#include <thread.h>
+
+extern "C" void *
+ace_start_func (void *)
+{
+ return 0;
+}
+ ]],
+ [[
+ thread_t tid = 0;
+
+ (void) thr_create (&tid, 0, ace_start_func, 0);
+ ]])],
[$1],
[$2])
])
@@ -358,17 +306,18 @@ dnl Check what compiler thread flag may be used, if any, from the given list.
dnl The flag list is separated by white space.
dnl Usage: ACE_SEARCH_THREAD_FLAGS(THREAD-FLAG-LIST,
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-AC_DEFUN(ACE_SEARCH_THREAD_FLAGS, dnl
+AC_DEFUN([ACE_SEARCH_THREAD_FLAGS],
[
- ACE_CACHE_CHECK(for compiler thread flag,
- ace_cv_thread_flag_search,
+ AC_LANG([C++])
+ AC_REQUIRE([AC_LANG])
+
+ ACE_CACHE_CHECK([for compiler thread flag],
+ [ace_cv_thread_flag_search],
[
- ifelse(AC_LANG, [CPLUSPLUS],
- [ace_save_CXXFLAGS="$CXXFLAGS"],[ace_save_CFLAGS="$CFLAGS"])
+ ace_save_CXXFLAGS="$CXXFLAGS"
for i in $1; do
- ifelse(AC_LANG, [CPLUSPLUS],
- [CXXFLAGS="$CXXFLAGS -$i"],[CFLAGS="$CFLAGS -$i"])
+ CXXFLAGS="$CXXFLAGS -$i"
ACE_CHECK_THREAD_FLAGS(
[
@@ -382,21 +331,17 @@ AC_DEFUN(ACE_SEARCH_THREAD_FLAGS, dnl
])
dnl Reset the flags for the next flag check.
- ifelse(AC_LANG, [CPLUSPLUS],
- [CXXFLAGS="$ace_save_CXXFLAGS"],[CFLAGS="$ace_save_CFLAGS"])
+ CXXFLAGS="$ace_save_CXXFLAGS"
done
dnl Reset the flags to a consistent state.
dnl This prevents duplicate flags from being added to
- dnl the C/CXXFLAGS variable.
- ifelse(AC_LANG, [CPLUSPLUS],
- [CXXFLAGS="$ace_save_CXXFLAGS"],[CFLAGS="$ace_save_CFLAGS"])
+ dnl the CCXXFLAGS variable.
+ CXXFLAGS="$ace_save_CXXFLAGS"
],
[
dnl Add the found/cached thread flag to the C/CXXFLAGS variables
- ifelse(AC_LANG, [CPLUSPLUS],
- [CXXFLAGS="$CXXFLAGS $ace_cv_thread_flag_search"],
- [CFLAGS="$CFLAGS $ace_cv_thread_flag_search"])
+ CXXFLAGS="$CXXFLAGS $ace_cv_thread_flag_search"
$2
],
@@ -409,25 +354,21 @@ AC_DEFUN(ACE_SEARCH_THREAD_FLAGS, dnl
dnl Check if the compiler defines thread related preprocessor flags.
dnl If not, then provide them.
dnl Usage: ACE_CHECK_THREAD_CPPFLAGS
-AC_DEFUN(ACE_CHECK_THREAD_CPPFLAGS, dnl
+AC_DEFUN([ACE_CHECK_THREAD_CPPFLAGS],
[
- dnl A compile-time test is used instead of a preprocessor-time test
+ dnl A compile-time test is used instead of a preprocesse-time test
dnl because compiler thread flags defined in CFLAGS or CXXFLAGS
dnl should be used for this test.
- AC_TRY_COMPILE(
- [
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if !defined (_REENTRANT) && !defined (_THREAD_SAFE)
#error Neither _REENTRANT nor _THREAD_SAFE were defined.
THROW ME AN ERROR!
#endif
- ],
- [
+ ]], [[
int a = 0; a++;
- ],
- [
+ ]])],[
ACE_THR_CPPFLAGS=
- ],
- [
+ ],[
ACE_THR_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE"
])
])