From 86af472836174d7beff39c4ee0316709605e1a0f Mon Sep 17 00:00:00 2001 From: cedric Date: Mon, 2 May 2011 13:40:28 +0000 Subject: [PATCH] eina: add back threads on/off support. NOTE: only use it if you know what you are doing ! git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@59123 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- configure.ac | 7 +++++++ m4/efl_threads.m4 | 13 ++++++++++++ m4/efl_voltron.m4 | 2 +- src/include/eina_config.h.in | 5 +++++ src/include/eina_inline_lock_posix.x | 38 ++++++++++++++++++++++++++++-------- 5 files changed, 56 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 7ffaa24..2886ec6 100644 --- a/configure.ac +++ b/configure.ac @@ -122,6 +122,12 @@ fi AC_SUBST(EINA_CONFIGURE_HAVE_DEBUG_THREADS) AM_CONDITIONAL([EINA_DEBUG_THREADS], [! test "x${have_debug_threads}" = "xno"]) +if ! test "x${have_on_off_threads}" = "xno"; then + EINA_CONFIGURE_HAVE_ON_OFF_THREADS="#define EINA_ON_OFF_THREADS" +fi +AC_SUBST(EINA_CONFIGURE_HAVE_ON_OFF_THREADS) +AM_CONDITIONAL([EINA_ON_OFF_THREADS], [! test "x${have_on_off_threads}" = "xno"]) + ### Additional options to configure # Magic debug @@ -675,6 +681,7 @@ echo " Thread Support.......: ${have_threads}" if test "${have_threads}" = "POSIX" ; then echo " spinlock...........: ${have_posix_threads_spinlock}" echo " debug usage........: ${have_debug_threads}" +echo " on/off support.....: ${have_on_off_threads}" fi echo " Amalgamation.........: ${do_amalgamation}" echo " Iconv support........: ${have_iconv}" diff --git a/m4/efl_threads.m4 b/m4/efl_threads.m4 index 33d15a3..a761d51 100644 --- a/m4/efl_threads.m4 +++ b/m4/efl_threads.m4 @@ -134,6 +134,19 @@ fi AC_SUBST(EFL_PTHREAD_CFLAGS) AC_SUBST(EFL_PTHREAD_LIBS) +_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 don't complain if the world freeze])], + [_efl_enable_on_off_threads="${enableval}"]) + +have_on_off_threads="no" +if test "x${_efl_enable_on_off_threads}" = "xyes"; then + 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_enable_on_off_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])], diff --git a/m4/efl_voltron.m4 b/m4/efl_voltron.m4 index c710466..43b334e 100644 --- a/m4/efl_voltron.m4 +++ b/m4/efl_voltron.m4 @@ -18,7 +18,7 @@ AC_ARG_ENABLE([voltron], [have_voltron="no"] ) - if test "x$have_voltron" = "xyes" -a "x$do_amalgamation" = "xyes";then + if test "x$have_voltron" = "xyes" -a "x$do_amalgamation" = "xyes" -o "x${have_on_off_threads}" = "xyes"; then echo "//////////////////////////////////////////////////////////////////////////////////////////////////////////////////" echo "/////////////////////////////////////////////////////////////////////////////////////{#///////////////////////////" echo "/////////////////////////////////////////////////////////////////////////////////// EN3 xx&HWx////////////////////" diff --git a/src/include/eina_config.h.in b/src/include/eina_config.h.in index cf7af51..be328cd 100644 --- a/src/include/eina_config.h.in +++ b/src/include/eina_config.h.in @@ -59,4 +59,9 @@ #endif #define EINA_SIZEOF_WCHAR_T @EINA_SIZEOF_WCHAR_T@ +#ifdef EINA_HAVE_ON_OFF_THREADS +# undef EINA_HAVE_ON_OFF_THREADS +#endif +@EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ + #endif /* EINA_CONFIG_H_ */ diff --git a/src/include/eina_inline_lock_posix.x b/src/include/eina_inline_lock_posix.x index 3f6c8d3..d7c1a13 100644 --- a/src/include/eina_inline_lock_posix.x +++ b/src/include/eina_inline_lock_posix.x @@ -102,13 +102,20 @@ eina_lock_free(Eina_Lock *mutex) static inline Eina_Lock_Result eina_lock_take(Eina_Lock *mutex) { - Eina_Bool ret = EINA_FALSE; + Eina_Lock_Result ret = EINA_FALSE; int ok; +#ifdef EINA_HAVE_ON_OFF_THREADS + if (!_eina_threads_activated) + { #ifdef EINA_HAVE_DEBUG_THREADS - if (_eina_threads_activated) - assert(pthread_equal(_eina_main_loop, pthread_self())); + assert(pthread_equal(_eina_main_loop, pthread_self())); +#endif + return EINA_FALSE; + } +#endif +#ifdef EINA_HAVE_DEBUG_THREADS if (_eina_threads_debug) { struct timeval t0, t1; @@ -146,11 +153,21 @@ eina_lock_take(Eina_Lock *mutex) static inline Eina_Lock_Result eina_lock_take_try(Eina_Lock *mutex) { - Eina_Bool ret = EINA_FALSE; + Eina_Lock_Result ret = EINA_FALSE; int ok; +#ifdef EINA_HAVE_ON_OFF_THREADS + if (!_eina_threads_activated) + { +#ifdef EINA_HAVE_DEBUG_THREADS + assert(pthread_equal(_eina_main_loop, pthread_self())); +#endif + return EINA_FALSE; + } +#endif + #ifdef EINA_HAVE_DEBUG_THREADS - if (_eina_threads_activated) + if (!_eina_threads_activated) assert(pthread_equal(_eina_main_loop, pthread_self())); #endif @@ -175,11 +192,16 @@ eina_lock_take_try(Eina_Lock *mutex) static inline Eina_Lock_Result eina_lock_release(Eina_Lock *mutex) { - Eina_Bool ret; + Eina_Lock_Result ret; +#ifdef EINA_HAVE_ON_OFF_THREADS + if (!_eina_threads_activated) + { #ifdef EINA_HAVE_DEBUG_THREADS - if (_eina_threads_activated) - assert(pthread_equal(_eina_main_loop, pthread_self())); + assert(pthread_equal(_eina_main_loop, pthread_self())); +#endif + return EINA_FALSE; + } #endif #ifdef EINA_HAVE_DEBUG_THREADS -- 2.7.4