* Removed all Id tags.
[cacao.git] / m4 / threads.m4
1 dnl m4/threads.m4
2 dnl
3 dnl Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
4 dnl C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 dnl E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 dnl J. Wenninger, Institut f. Computersprachen - TU Wien
7 dnl 
8 dnl This file is part of CACAO.
9 dnl 
10 dnl This program is free software; you can redistribute it and/or
11 dnl modify it under the terms of the GNU General Public License as
12 dnl published by the Free Software Foundation; either version 2, or (at
13 dnl your option) any later version.
14 dnl 
15 dnl This program is distributed in the hope that it will be useful, but
16 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
17 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 dnl General Public License for more details.
19 dnl 
20 dnl You should have received a copy of the GNU General Public License
21 dnl along with this program; if not, write to the Free Software
22 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 dnl 02110-1301, USA.
24
25
26 dnl check which thread implementation should be used
27
28 AC_DEFUN([AC_CHECK_ENABLE_THREADS],[
29 AC_MSG_CHECKING(whether to include threads support)
30 AC_ARG_ENABLE([threads],
31               [AS_HELP_STRING(--enable-threads,enable threads support (none,native) [[default=native]])],
32               [case "${enableval}" in
33                    no | none | single )
34                        ENABLE_THREADS=no
35                        ;;
36
37                    posix | pthreads )
38                        ENABLE_THREADS=posix
39                        ;;
40
41                    *)
42                        AC_MSG_ERROR($enableval is an unknown thread package)
43                        ;;
44                esac],
45                [ENABLE_THREADS=posix])
46
47 AC_MSG_RESULT(${ENABLE_THREADS})
48 AM_CONDITIONAL([ENABLE_THREADS], test x"${ENABLE_THREADS}" != "xno")
49
50 case "${ENABLE_THREADS}" in
51     no )
52         dnl no threads for boehm
53         ac_configure_args="$ac_configure_args --disable-boehm-threads"
54         ;;
55
56     posix )
57         AC_DEFINE([ENABLE_THREADS], 1, [enable threads])
58         AC_CHECK_LIB(pthread, main)
59
60         ARCH_CFLAGS="$ARCH_CFLAGS -D_REENTRANT"
61
62         dnl we changed ARCH_CFLAGS, set CFLAGS again
63         CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
64
65         dnl tell boehm to support threads as well
66         ac_configure_args="$ac_configure_args --enable-boehm-threads=posix"
67         ;;
68 esac
69 ])
70
71
72 dnl currently NOT USED
73
74 dnl AC_ARG_ENABLE([__thread], [AS_HELP_STRING(--enable-__thread,use TLS features)], [use__thread=$enableval], [use__thread=no])
75 dnl 
76 dnl dnl Check whether the compiler supports the __thread keyword.
77 dnl if test "x$use__thread" != xno; then
78 dnl   AC_CACHE_CHECK([for __thread], ac_cv_gcc___thread,
79 dnl   [cat > conftest.c <<\EOF
80 dnl __thread int a = 42;
81 dnl EOF
82 dnl   if AC_TRY_COMMAND([${CC-cc} $ARCH_CFLAGS $OPT_CFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
83 dnl     ac_cv_gcc___thread=yes 
84 dnl   else
85 dnl     ac_cv_gcc___thread=no
86 dnl   fi
87 dnl   rm -f conftest*])
88 dnl   if test "$ac_cv_gcc___thread" = yes; then
89 dnl     AC_DEFINE([HAVE___THREAD], 1, [have __thread])
90 dnl   fi
91 dnl else
92 dnl   ac_cv_gcc___thread=no
93 dnl fi