2010-07-13 06:51:00 -07:00
|
|
|
dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr>
|
2010-08-08 12:20:07 -07:00
|
|
|
dnl rwlock code added by Mike Blumenkrantz <mike at zentific dot com>
|
|
|
|
dnl This code is public domain and can be freely used or copied.
|
2010-07-13 06:51:00 -07:00
|
|
|
|
|
|
|
dnl Macro that check if POSIX or Win32 threads library is available or not.
|
|
|
|
|
2010-08-08 12:20:07 -07:00
|
|
|
dnl Usage: EFL_CHECK_THREADS(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
|
2010-07-13 06:51:00 -07:00
|
|
|
dnl Call AC_SUBST(EFL_PTHREAD_CFLAGS)
|
|
|
|
dnl Call AC_SUBST(EFL_PTHREAD_LIBS)
|
2010-08-08 12:20:07 -07:00
|
|
|
dnl Defines EFL_HAVE_POSIX_THREADS or EFL_HAVE_WIN32_THREADS, and EFL_HAVE_THREADS
|
2010-07-13 06:51:00 -07:00
|
|
|
|
|
|
|
AC_DEFUN([EFL_CHECK_THREADS],
|
|
|
|
[
|
|
|
|
|
2012-05-30 06:25:13 -07:00
|
|
|
dnl Generic thread detection
|
|
|
|
|
2012-05-29 14:57:48 -07:00
|
|
|
EFL_PTHREAD_CFLAGS=""
|
|
|
|
EFL_PTHREAD_LIBS=""
|
2010-07-13 06:51:00 -07:00
|
|
|
|
2012-05-29 14:57:48 -07:00
|
|
|
_efl_enable_posix_threads="no"
|
|
|
|
_efl_have_posix_threads="no"
|
|
|
|
_efl_have_win32_threads="no"
|
2010-07-13 06:51:00 -07:00
|
|
|
|
|
|
|
case "$host_os" in
|
|
|
|
mingw*)
|
2012-05-29 14:57:48 -07:00
|
|
|
_efl_have_win32_threads="yes"
|
|
|
|
AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported])
|
|
|
|
AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported])
|
2010-07-13 06:51:00 -07:00
|
|
|
;;
|
|
|
|
solaris*)
|
2012-05-29 14:57:48 -07:00
|
|
|
_efl_enable_posix_threads="yes"
|
2010-11-20 14:14:57 -08:00
|
|
|
_efl_threads_cflags="-mt"
|
|
|
|
_efl_threads_libs="-mt"
|
2010-07-13 06:51:00 -07:00
|
|
|
;;
|
|
|
|
*)
|
2012-05-29 14:57:48 -07:00
|
|
|
_efl_enable_posix_threads="yes"
|
2010-11-20 14:14:57 -08:00
|
|
|
_efl_threads_cflags="-pthread"
|
|
|
|
_efl_threads_libs="-pthread"
|
2010-07-13 06:51:00 -07:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2012-05-29 14:57:48 -07:00
|
|
|
dnl check if the compiler supports POSIX threads
|
2010-07-13 06:51:00 -07:00
|
|
|
|
2012-05-29 14:57:48 -07:00
|
|
|
|
|
|
|
if test "x${_efl_enable_posix_threads}" = "xyes" ; then
|
2010-07-13 06:51:00 -07:00
|
|
|
|
|
|
|
SAVE_CFLAGS=${CFLAGS}
|
|
|
|
CFLAGS="${CFLAGS} ${_efl_threads_cflags}"
|
|
|
|
SAVE_LIBS=${LIBS}
|
|
|
|
LIBS="${LIBS} ${_efl_threads_libs}"
|
|
|
|
AC_LINK_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM([[
|
|
|
|
#include <pthread.h>
|
|
|
|
]],
|
|
|
|
[[
|
|
|
|
pthread_t id;
|
|
|
|
id = pthread_self();
|
|
|
|
]])],
|
2012-05-29 14:57:48 -07:00
|
|
|
[
|
|
|
|
_efl_have_posix_threads="yes"
|
|
|
|
AC_DEFINE([EFL_HAVE_POSIX_THREADS], [1], [Define to mention that POSIX threads are supported])
|
|
|
|
AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported])
|
|
|
|
EFL_PTHREAD_CFLAGS=${_efl_threads_cflags}
|
|
|
|
EFL_PTHREAD_LIBS=${_efl_threads_libs}
|
|
|
|
],
|
2010-07-13 06:51:00 -07:00
|
|
|
[_efl_have_posix_threads="no"])
|
|
|
|
CFLAGS=${SAVE_CFLAGS}
|
|
|
|
LIBS=${SAVE_LIBS}
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2012-05-29 14:57:48 -07:00
|
|
|
AC_MSG_CHECKING([which threads API is used])
|
2010-07-13 06:51:00 -07:00
|
|
|
if test "x${_efl_have_posix_threads}" = "xyes" ; then
|
2012-05-30 06:25:13 -07:00
|
|
|
efl_have_threads="POSIX"
|
2012-05-29 14:57:48 -07:00
|
|
|
else
|
|
|
|
if test "x${_efl_have_win32_threads}" = "xyes" ; then
|
2012-05-30 06:25:13 -07:00
|
|
|
efl_have_threads="Windows"
|
2012-05-29 14:57:48 -07:00
|
|
|
else
|
2012-05-30 06:25:13 -07:00
|
|
|
efl_have_threads="no"
|
2012-05-29 14:57:48 -07:00
|
|
|
fi
|
2010-07-13 06:51:00 -07:00
|
|
|
fi
|
2012-05-30 06:25:13 -07:00
|
|
|
AC_MSG_RESULT([${efl_have_threads}])
|
2010-07-13 06:51:00 -07:00
|
|
|
|
|
|
|
AC_SUBST(EFL_PTHREAD_CFLAGS)
|
|
|
|
AC_SUBST(EFL_PTHREAD_LIBS)
|
|
|
|
|
|
|
|
dnl check if the compiler supports pthreads spinlock
|
|
|
|
|
2012-05-30 06:25:13 -07:00
|
|
|
efl_have_posix_threads_spinlock="no"
|
2010-07-13 06:51:00 -07:00
|
|
|
|
2010-08-08 12:20:07 -07:00
|
|
|
if test "x${_efl_have_posix_threads}" = "xyes" ; then
|
2010-07-13 06:51:00 -07:00
|
|
|
|
|
|
|
SAVE_CFLAGS=${CFLAGS}
|
|
|
|
CFLAGS="${CFLAGS} ${EFL_PTHREAD_CFLAGS}"
|
|
|
|
SAVE_LIBS=${LIBS}
|
|
|
|
LIBS="${LIBS} ${EFL_PTHREAD_LIBS}"
|
|
|
|
AC_LINK_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM([[
|
|
|
|
#include <pthread.h>
|
|
|
|
]],
|
|
|
|
[[
|
|
|
|
pthread_spinlock_t lock;
|
|
|
|
int res;
|
|
|
|
res = pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE);
|
|
|
|
]])],
|
2012-05-30 06:25:13 -07:00
|
|
|
[efl_have_posix_threads_spinlock="yes"],
|
|
|
|
[efl_have_posix_threads_spinlock="no"])
|
2010-07-13 06:51:00 -07:00
|
|
|
CFLAGS=${SAVE_CFLAGS}
|
|
|
|
LIBS=${SAVE_LIBS}
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
AC_MSG_CHECKING([whether to build POSIX threads spinlock code])
|
2012-05-30 06:25:13 -07:00
|
|
|
AC_MSG_RESULT([${efl_have_posix_threads_spinlock}])
|
2010-07-13 06:51:00 -07:00
|
|
|
|
2012-05-30 06:25:13 -07:00
|
|
|
if test "x${efl_have_posix_threads_spinlock}" = "xyes" ; then
|
2010-07-13 06:51:00 -07:00
|
|
|
AC_DEFINE([EFL_HAVE_POSIX_THREADS_SPINLOCK], [1], [Define to mention that POSIX threads spinlocks are supported])
|
|
|
|
fi
|
|
|
|
|
2012-05-30 06:25:13 -07:00
|
|
|
dnl Check ON-OFF threads
|
|
|
|
|
|
|
|
_efl_enable_on_off_threads="no"
|
|
|
|
AC_ARG_ENABLE([on-off-threads],
|
|
|
|
[AC_HELP_STRING([--enable-on-off-threads], [only turn this on if you know what you are doing, and do not complain if the world freeze])],
|
|
|
|
[_efl_enable_on_off_threads="${enableval}"])
|
|
|
|
|
|
|
|
efl_have_on_off_threads="no"
|
|
|
|
if test "x${_efl_have_posix_threads}" = "xyes" && test "x${_efl_enable_on_off_threads}" = "xyes"; then
|
|
|
|
efl_have_on_off_threads="yes"
|
|
|
|
AC_DEFINE([EFL_ON_OFF_THREADS], [1], [make it possible to disable all locks])
|
|
|
|
fi
|
|
|
|
AC_MSG_CHECKING([whether to turn on/off threads lock on demand])
|
|
|
|
AC_MSG_RESULT([${efl_have_on_off_threads}])
|
|
|
|
|
|
|
|
dnl Check debug threads
|
|
|
|
|
|
|
|
_efl_enable_debug_threads="no"
|
|
|
|
AC_ARG_ENABLE([debug-threads],
|
|
|
|
[AC_HELP_STRING([--enable-debug-threads], [disable assert when you forgot to call eina_threads_init])],
|
|
|
|
[_efl_enable_debug_threads="${enableval}"])
|
|
|
|
|
|
|
|
efl_have_debug_threads="no"
|
|
|
|
if test "x${_efl_have_posix_threads}" = "xyes" && test "x${_efl_enable_debug_threads}" = "xyes"; then
|
|
|
|
efl_have_debug_threads="yes"
|
|
|
|
AC_DEFINE([EFL_DEBUG_THREADS], [1], [Assert when forgot to call eina_threads_init])
|
|
|
|
fi
|
|
|
|
|
|
|
|
AS_IF([test "x$_efl_have_posix_threads" = "xyes" || test "x$_efl_have_win32_threads" = "xyes"], [$1], [$2])
|
|
|
|
])
|