~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to m4/acx_pthread.m4

  • Committer: Brian Aker
  • Date: 2010-12-18 02:06:13 UTC
  • Revision ID: brian@tangent.org-20101218020613-8lxhcvsy812bu960
Formatting + remove default from switch/case.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
##### http://autoconf-archive.cryp.to/acx_pthread.html
 
1
# ===========================================================================
 
2
#              http://autoconf-archive.cryp.to/acx_pthread.html
 
3
# ===========================================================================
2
4
#
3
5
# SYNOPSIS
4
6
#
6
8
#
7
9
# DESCRIPTION
8
10
#
9
 
#   This macro figures out how to build C programs using POSIX threads.
10
 
#   It sets the PTHREAD_LIBS output variable to the threads library and
11
 
#   linker flags, and the PTHREAD_CFLAGS output variable to any special
12
 
#   C compiler flags that are needed. (The user can also force certain
13
 
#   compiler flags/libs to be tested by setting these environment
14
 
#   variables.)
 
11
#   This macro figures out how to build C programs using POSIX threads. It
 
12
#   sets the PTHREAD_LIBS output variable to the threads library and linker
 
13
#   flags, and the PTHREAD_CFLAGS output variable to any special C compiler
 
14
#   flags that are needed. (The user can also force certain compiler
 
15
#   flags/libs to be tested by setting these environment variables.)
15
16
#
16
17
#   Also sets PTHREAD_CC to any special C compiler that is needed for
17
 
#   multi-threaded programs (defaults to the value of CC otherwise).
18
 
#   (This is necessary on AIX to use the special cc_r compiler alias.)
19
 
#
20
 
#   NOTE: You are assumed to not only compile your program with these
21
 
#   flags, but also link it with them as well. e.g. you should link
22
 
#   with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
23
 
#   $LIBS
24
 
#
25
 
#   If you are only building threads programs, you may wish to use
26
 
#   these variables in your default LIBS, CFLAGS, and CC:
 
18
#   multi-threaded programs (defaults to the value of CC otherwise). (This
 
19
#   is necessary on AIX to use the special cc_r compiler alias.)
 
20
#
 
21
#   NOTE: You are assumed to not only compile your program with these flags,
 
22
#   but also link it with them as well. e.g. you should link with
 
23
#   $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
 
24
#
 
25
#   If you are only building threads programs, you may wish to use these
 
26
#   variables in your default LIBS, CFLAGS, and CC:
27
27
#
28
28
#          LIBS="$PTHREAD_LIBS $LIBS"
29
29
#          CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
30
30
#          CC="$PTHREAD_CC"
31
31
#
32
 
#   In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
33
 
#   constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
34
 
#   that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
35
 
#
36
 
#   ACTION-IF-FOUND is a list of shell commands to run if a threads
37
 
#   library is found, and ACTION-IF-NOT-FOUND is a list of commands to
38
 
#   run it if it is not found. If ACTION-IF-FOUND is not specified, the
39
 
#   default action will define HAVE_PTHREAD.
40
 
#
41
 
#   Please let the authors know if this macro fails on any platform, or
42
 
#   if you have any other suggestions or comments. This macro was based
43
 
#   on work by SGJ on autoconf scripts for FFTW (http://www.fftw.org/)
44
 
#   (with help from M. Frigo), as well as ac_pthread and hb_pthread
45
 
#   macros posted by Alejandro Forero Cuervo to the autoconf macro
46
 
#   repository. We are also grateful for the helpful feedback of
47
 
#   numerous users.
48
 
#
49
 
# LAST MODIFICATION
50
 
#
51
 
#   2006-05-29
52
 
#
53
 
# COPYLEFT
54
 
#
55
 
#   Copyright (c) 2006 Steven G. Johnson <stevenj@alum.mit.edu>
56
 
#
57
 
#   This program is free software; you can redistribute it and/or
58
 
#   modify it under the terms of the GNU General Public License as
59
 
#   published by the Free Software Foundation; either version 2 of the
60
 
#   License, or (at your option) any later version.
 
32
#   In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
 
33
#   has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
 
34
#   (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
 
35
#
 
36
#   ACTION-IF-FOUND is a list of shell commands to run if a threads library
 
37
#   is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
 
38
#   is not found. If ACTION-IF-FOUND is not specified, the default action
 
39
#   will define HAVE_PTHREAD.
 
40
#
 
41
#   Please let the authors know if this macro fails on any platform, or if
 
42
#   you have any other suggestions or comments. This macro was based on work
 
43
#   by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
 
44
#   from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
 
45
#   Alejandro Forero Cuervo to the autoconf macro repository. We are also
 
46
#   grateful for the helpful feedback of numerous users.
 
47
#
 
48
# LICENSE
 
49
#
 
50
#   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
 
51
#
 
52
#   This program is free software: you can redistribute it and/or modify it
 
53
#   under the terms of the GNU General Public License as published by the
 
54
#   Free Software Foundation, either version 3 of the License, or (at your
 
55
#   option) any later version.
61
56
#
62
57
#   This program is distributed in the hope that it will be useful, but
63
58
#   WITHOUT ANY WARRANTY; without even the implied warranty of
64
 
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
65
 
#   General Public License for more details.
66
 
#
67
 
#   You should have received a copy of the GNU General Public License
68
 
#   along with this program; if not, write to the Free Software
69
 
#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
70
 
#   02111-1307, USA.
71
 
#
72
 
#   As a special exception, the respective Autoconf Macro's copyright
73
 
#   owner gives unlimited permission to copy, distribute and modify the
74
 
#   configure scripts that are the output of Autoconf when processing
75
 
#   the Macro. You need not follow the terms of the GNU General Public
76
 
#   License when using or distributing such scripts, even though
77
 
#   portions of the text of the Macro appear in them. The GNU General
78
 
#   Public License (GPL) does govern all other use of the material that
79
 
#   constitutes the Autoconf Macro.
80
 
#
81
 
#   This special exception to the GPL applies to versions of the
82
 
#   Autoconf Macro released by the Autoconf Macro Archive. When you
83
 
#   make and distribute a modified version of the Autoconf Macro, you
84
 
#   may extend this special exception to the GPL to apply to your
85
 
#   modified version as well.
 
59
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 
60
#   Public License for more details.
 
61
#
 
62
#   You should have received a copy of the GNU General Public License along
 
63
#   with this program. If not, see <http://www.gnu.org/licenses/>.
 
64
#
 
65
#   As a special exception, the respective Autoconf Macro's copyright owner
 
66
#   gives unlimited permission to copy, distribute and modify the configure
 
67
#   scripts that are the output of Autoconf when processing the Macro. You
 
68
#   need not follow the terms of the GNU General Public License when using
 
69
#   or distributing such scripts, even though portions of the text of the
 
70
#   Macro appear in them. The GNU General Public License (GPL) does govern
 
71
#   all other use of the material that constitutes the Autoconf Macro.
 
72
#
 
73
#   This special exception to the GPL applies to versions of the Autoconf
 
74
#   Macro released by the Autoconf Archive. When you make and distribute a
 
75
#   modified version of the Autoconf Macro, you may extend this special
 
76
#   exception to the GPL to apply to your modified version as well.
86
77
 
87
78
AC_DEFUN([ACX_PTHREAD], [
88
79
AC_REQUIRE([AC_CANONICAL_HOST])
89
 
AC_LANG_PUSH([C])
 
80
AC_LANG_SAVE
 
81
AC_LANG_C
90
82
acx_pthread_ok=no
91
83
 
92
84
# We used to check for pthread.h first, but this fails if pthread.h
199
191
        # pthread_cleanup_push because it is one of the few pthread
200
192
        # functions on Solaris that doesn't have a non-functional libc stub.
201
193
        # We try pthread_create on general principles.
202
 
        AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t th; pthread_join(th, 0);
 
194
        AC_TRY_LINK([#include <pthread.h>],
 
195
                    [pthread_t th; pthread_join(th, 0);
203
196
                     pthread_attr_init(0); pthread_cleanup_push(0, 0);
204
 
                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ]])],[acx_pthread_ok=yes],[])
 
197
                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
 
198
                    [acx_pthread_ok=yes])
205
199
 
206
200
        LIBS="$save_LIBS"
207
201
        CFLAGS="$save_CFLAGS"
227
221
        AC_MSG_CHECKING([for joinable pthread attribute])
228
222
        attr_name=unknown
229
223
        for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
230
 
            AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[int attr=$attr; return attr;]])],[attr_name=$attr; break],[])
 
224
            AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
 
225
                        [attr_name=$attr; break])
231
226
        done
232
227
        AC_MSG_RESULT($attr_name)
233
228
        if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
272
267
        acx_pthread_ok=no
273
268
        $2
274
269
fi
275
 
AC_LANG_POP([])
 
270
AC_LANG_RESTORE
276
271
])dnl ACX_PTHREAD