summaryrefslogtreecommitdiff
path: root/legacy/eina/m4/efl_threads.m4
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2010-08-08 19:20:07 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2010-08-08 19:20:07 +0000
commit76a70bdd48bdb0bfdbb6d52592e3409aa78e67e2 (patch)
tree8b2f71bacbf7923d443df707468de3b6c9159a26 /legacy/eina/m4/efl_threads.m4
parented0f5eb857cbaf89861ee15ce9fbb1e476681c26 (diff)
split out spinlock detection to separate macro for readability, add rwlock detection macro
***no functional changes*** SVN revision: 50910
Diffstat (limited to '')
-rw-r--r--legacy/eina/m4/efl_threads.m477
1 files changed, 63 insertions, 14 deletions
diff --git a/legacy/eina/m4/efl_threads.m4 b/legacy/eina/m4/efl_threads.m4
index 8866e37..843e466 100644
--- a/legacy/eina/m4/efl_threads.m4
+++ b/legacy/eina/m4/efl_threads.m4
@@ -1,13 +1,13 @@
1dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr> 1dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr>
2dnl That code is public domain and can be freely used or copied. 2dnl rwlock code added by Mike Blumenkrantz <mike at zentific dot com>
3dnl This code is public domain and can be freely used or copied.
3 4
4dnl Macro that check if POSIX or Win32 threads library is available or not. 5dnl Macro that check if POSIX or Win32 threads library is available or not.
5 6
6dnl Usage: EFL_CHECK_THREADS(want_pthread_spin[, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) 7dnl Usage: EFL_CHECK_THREADS(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
7dnl Call AC_SUBST(EFL_PTHREAD_CFLAGS) 8dnl Call AC_SUBST(EFL_PTHREAD_CFLAGS)
8dnl Call AC_SUBST(EFL_PTHREAD_LIBS) 9dnl Call AC_SUBST(EFL_PTHREAD_LIBS)
9dnl Define EFL_HAVE_POSIX_THREADS or EFL_HAVE_WIN32_THREADS, and EFL_HAVE_THREADS 10dnl Defines EFL_HAVE_POSIX_THREADS or EFL_HAVE_WIN32_THREADS, and EFL_HAVE_THREADS
10dnl Define EFL_HAVE_POSIX_THREADS_SPINLOCK
11 11
12AC_DEFUN([EFL_CHECK_THREADS], 12AC_DEFUN([EFL_CHECK_THREADS],
13[ 13[
@@ -138,11 +138,29 @@ if test "x${_efl_have_posix_threads}" = "xyes" ; then
138 AC_DEFINE([EFL_HAVE_POSIX_THREADS], [1], [Define to mention that POSIX threads are supported]) 138 AC_DEFINE([EFL_HAVE_POSIX_THREADS], [1], [Define to mention that POSIX threads are supported])
139fi 139fi
140 140
141
142if test "x${_efl_enable_win32_threads}" = "xyes" ; then
143 _efl_have_win32_threads="yes"
144 AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported])
145fi
146
147if test "x${_efl_have_posix_threads}" = "xyes" || test "x${_efl_have_win32_threads}" = "xyes" ; then
148 AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported])
149fi
150
151AS_IF([test "x$_efl_have_posix_threads" = "xyes" || test "x$_efl_have_win32_threads" = "xyes"], [$1], [$2])
152])
153
154dnl Usage: EFL_CHECK_SPINLOCK(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
155dnl Defines EFL_HAVE_POSIX_THREADS_SPINLOCK
156AC_DEFUN([EFL_CHECK_SPINLOCK],
157[
158
141dnl check if the compiler supports pthreads spinlock 159dnl check if the compiler supports pthreads spinlock
142 160
143_efl_have_posix_threads_spinlock="no" 161_efl_have_posix_threads_spinlock="no"
144 162
145if test "x${_efl_have_posix_threads}" = "xyes" && test "x$1" = "xyes" ; then 163if test "x${_efl_have_posix_threads}" = "xyes" ; then
146 164
147 SAVE_CFLAGS=${CFLAGS} 165 SAVE_CFLAGS=${CFLAGS}
148 CFLAGS="${CFLAGS} ${EFL_PTHREAD_CFLAGS}" 166 CFLAGS="${CFLAGS} ${EFL_PTHREAD_CFLAGS}"
@@ -166,24 +184,55 @@ fi
166 184
167AC_MSG_CHECKING([whether to build POSIX threads spinlock code]) 185AC_MSG_CHECKING([whether to build POSIX threads spinlock code])
168AC_MSG_RESULT([${_efl_have_posix_threads_spinlock}]) 186AC_MSG_RESULT([${_efl_have_posix_threads_spinlock}])
169if test "x${_efl_enable_posix_threads}" = "xyes" && test "x${_efl_have_posix_threads_spinlock}" = "xno" && test "x$1" = "xyes" ; then 187if test "x${_efl_enable_posix_threads}" = "xyes" && test "x${_efl_have_posix_threads_spinlock}" = "xno" ; then
170 AC_MSG_WARN([POSIX threads support requested but spinlocks are not supported]) 188 AC_MSG_WARN([POSIX threads support requested but spinlocks are not supported])
171fi 189fi
172 190
173if test "x${_efl_have_posix_threads_spinlock}" = "xyes" ; then 191if test "x${_efl_have_posix_threads_spinlock}" = "xyes" ; then
174 AC_DEFINE([EFL_HAVE_POSIX_THREADS_SPINLOCK], [1], [Define to mention that POSIX threads spinlocks are supported]) 192 AC_DEFINE([EFL_HAVE_POSIX_THREADS_SPINLOCK], [1], [Define to mention that POSIX threads spinlocks are supported])
175fi 193fi
194AS_IF([test "x$_efl_have_posix_threads_spinlock" = "xyes"], [$1], [$2])
195])
176 196
177if test "x${_efl_enable_win32_threads}" = "xyes" ; then
178 _efl_have_win32_threads="yes"
179 AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported])
180fi
181 197
182if test "x${_efl_have_posix_threads}" = "xyes" || test "x${_efl_have_win32_threads}" = "xyes" ; then 198dnl Usage: EFL_CHECK_RWLOCK(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
183 AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported]) 199dnl Defines EFL_HAVE_POSIX_THREADS_RWLOCK
200AC_DEFUN([EFL_CHECK_RWLOCK],
201[
202dnl check if the compiler supports pthreads rwlock
203
204_efl_have_posix_threads_rwlock="no"
205
206if test "x${_efl_have_posix_threads}" = "xyes" ; then
207
208 SAVE_CFLAGS=${CFLAGS}
209 CFLAGS="${CFLAGS} ${EFL_PTHREAD_CFLAGS}"
210 SAVE_LIBS=${LIBS}
211 LIBS="${LIBS} ${EFL_PTHREAD_LIBS}"
212 AC_LINK_IFELSE(
213 [AC_LANG_PROGRAM([[
214#include <pthread.h>
215 ]],
216 [[
217pthread_rwlock_t lock = PTHREAD_RWLOCK_INITIALIZER;
218int res;
219res = pthread_rwlock_init(&lock, PTHREAD_PROCESS_PRIVATE);
220 ]])],
221 [_efl_have_posix_threads_rwlock="yes"],
222 [_efl_have_posix_threads_rwlock="no"])
223 CFLAGS=${SAVE_CFLAGS}
224 LIBS=${SAVE_LIBS}
225
184fi 226fi
185 227
186AS_IF([test "x$_efl_have_posix_threads" = "xyes" || test "x$_efl_have_win32_threads" = "xyes"], [$2], [$3]) 228AC_MSG_CHECKING([whether to build POSIX threads rwlock code])
187AS_IF([test "x$_efl_have_posix_threads_spinlock" = "xyes"], [$4], [$5]) 229AC_MSG_RESULT([${_efl_have_posix_threads_rwlock}])
230if test "x${_efl_enable_posix_threads}" = "xyes" && test "x${_efl_have_posix_threads_rwlock}" = "xno" ; then
231 AC_MSG_WARN([POSIX threads support requested but rwlocks are not supported])
232fi
188 233
234if test "x${_efl_have_posix_threads_rwlock}" = "xyes" ; then
235 AC_DEFINE([EFL_HAVE_POSIX_THREADS_RWLOCK], [1], [Define to mention that POSIX threads rwlocks are supported])
236fi
237AS_IF([test "x$_efl_have_posix_threads_rwlock" = "xyes"], [$1], [$2])
189]) 238])