~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to m4/acx_pthread.m4

  • Committer: Stewart Smith
  • Date: 2010-04-08 07:20:26 UTC
  • mto: This revision was merged to the branch mainline in revision 1456.
  • Revision ID: stewart@flamingspork.com-20100408072026-w3s8zblhs35uo5mg
removeĀ CHECKSUMĀ TABLE

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# ===========================================================================
2
 
#              http://autoconf-archive.cryp.to/acx_pthread.html
3
 
# ===========================================================================
 
1
##### http://autoconf-archive.cryp.to/acx_pthread.html
4
2
#
5
3
# SYNOPSIS
6
4
#
8
6
#
9
7
# DESCRIPTION
10
8
#
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.)
 
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.)
16
15
#
17
16
#   Also sets PTHREAD_CC to any special C compiler that is needed for
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:
 
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:
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 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.
 
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.
56
61
#
57
62
#   This program is distributed in the hope that it will be useful, but
58
63
#   WITHOUT ANY WARRANTY; without even the implied warranty of
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.
 
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.
77
86
 
78
87
AC_DEFUN([ACX_PTHREAD], [
79
88
AC_REQUIRE([AC_CANONICAL_HOST])
80
 
AC_LANG_SAVE
81
 
AC_LANG_C
 
89
AC_LANG_PUSH([C])
82
90
acx_pthread_ok=no
83
91
 
84
92
# We used to check for pthread.h first, but this fails if pthread.h
191
199
        # pthread_cleanup_push because it is one of the few pthread
192
200
        # functions on Solaris that doesn't have a non-functional libc stub.
193
201
        # We try pthread_create on general principles.
194
 
        AC_TRY_LINK([#include <pthread.h>],
195
 
                    [pthread_t th; pthread_join(th, 0);
 
202
        AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t th; pthread_join(th, 0);
196
203
                     pthread_attr_init(0); pthread_cleanup_push(0, 0);
197
 
                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
198
 
                    [acx_pthread_ok=yes])
 
204
                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ]])],[acx_pthread_ok=yes],[])
199
205
 
200
206
        LIBS="$save_LIBS"
201
207
        CFLAGS="$save_CFLAGS"
221
227
        AC_MSG_CHECKING([for joinable pthread attribute])
222
228
        attr_name=unknown
223
229
        for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
224
 
            AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
225
 
                        [attr_name=$attr; break])
 
230
            AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[int attr=$attr; return attr;]])],[attr_name=$attr; break],[])
226
231
        done
227
232
        AC_MSG_RESULT($attr_name)
228
233
        if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
267
272
        acx_pthread_ok=no
268
273
        $2
269
274
fi
270
 
AC_LANG_RESTORE
 
275
AC_LANG_POP([])
271
276
])dnl ACX_PTHREAD