Merge Trond
[m6w6/libmemcached] / m4 / pandora_pthread.m4
1 dnl -*- mode: m4; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 dnl vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 dnl
4 dnl pandora-build: A pedantic build system
5 dnl Copyright (C) 2009 Sun Microsystems, Inc.
6 dnl This file is free software; the Free Software Foundation
7 dnl gives unlimited permission to copy and/or distribute it,
8 dnl with or without modifications, as long as this notice is preserved.
9 dnl
10 dnl From Monty Taylor
11
12
13 dnl --------------------------------------------------------------------
14 dnl Check for libpthread
15 dnl --------------------------------------------------------------------
16
17 AC_DEFUN([PANDORA_PTHREAD_YIELD],[
18 AC_REQUIRE([ACX_PTHREAD])
19
20 save_CFLAGS="${CFLAGS}"
21 save_CXXFLAGS="${CXXFLAGS}"
22 CFLAGS="${PTHREAD_CFLAGS} ${CFLAGS}"
23 CXXFLAGS="${PTHREAD_CFLAGS} ${CXXFLAGS}"
24 dnl Some OSes like Mac OS X have that as a replacement for pthread_yield()
25 AC_CHECK_FUNCS(pthread_yield_np)
26 AC_CACHE_CHECK([if pthread_yield takes zero arguments],
27 [pandora_cv_pthread_yield_zero_arg],
28 [AC_LINK_IFELSE([
29 AC_LANG_PROGRAM([[
30 #include <pthread.h>
31 ]],[[
32 pthread_yield();
33 ]])],
34 [pandora_cv_pthread_yield_zero_arg=yes],
35 [pandora_cv_pthread_yield_zero_arg=no])])
36 AS_IF([test "$pandora_cv_pthread_yield_zero_arg" = "yes"],[
37 AC_DEFINE([HAVE_PTHREAD_YIELD_ZERO_ARG], [1],
38 [pthread_yield that doesn't take any arguments])
39 ])
40
41 AC_CACHE_CHECK([if pthread_yield takes one argument],
42 [pandora_cv_pthread_yield_one_arg],
43 [AC_LINK_IFELSE([
44 AC_LANG_PROGRAM([[
45 #include <pthread.h>
46 ]],[[
47 pthread_yield(0);
48 ]])],
49 [pandora_cv_pthread_yield_one_arg=yes],
50 [pandora_cv_pthread_yield_one_arg=no])])
51 AS_IF([test "$pandora_cv_pthread_yield_one_arg" = "yes"],[
52 AC_DEFINE([HAVE_PTHREAD_YIELD_ONE_ARG], [1],
53 [pthread_yield function with one argument])
54 ])
55
56 CFLAGS="${save_CFLAGS}"
57 CXXFLAGS="${save_CXXFLAGS}"
58 ])
59
60
61 AC_DEFUN([_PANDORA_SEARCH_PTHREAD],[
62 AC_REQUIRE([ACX_PTHREAD])
63 LIBS="${PTHREAD_LIBS} ${LIBS}"
64 AM_CFLAGS="${PTHREAD_CFLAGS} ${AM_CFLAGS}"
65 AM_CXXFLAGS="${PTHREAD_CFLAGS} ${AM_CXXFLAGS}"
66 PANDORA_PTHREAD_YIELD
67 ])
68
69
70 AC_DEFUN([PANDORA_HAVE_PTHREAD],[
71 AC_REQUIRE([_PANDORA_SEARCH_PTHREAD])
72 ])
73
74 AC_DEFUN([PANDORA_REQUIRE_PTHREAD],[
75 AC_REQUIRE([PANDORA_HAVE_PTHREAD])
76 AS_IF([test "x$acx_pthread_ok" != "xyes"],[
77 AC_MSG_ERROR(could not find libpthread)])
78 ])