echo " Thread Support.......: ${have_threads}"
if test "${have_threads}" = "POSIX" ; then
echo " spinlock...........: ${have_posix_threads_spinlock}"
+echo " debug usage........: ${have_debug_threads}"
fi
echo " Amalgamation.........: ${do_amalgamation}"
echo " Iconv support........: ${have_iconv}"
AC_SUBST(EFL_PTHREAD_CFLAGS)
AC_SUBST(EFL_PTHREAD_LIBS)
+_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}"])
+
+have_debug_threads="no"
+if test "x${_efl_have_posix_threads}" = "xyes" -a "x${_efl_enable_debug_threads}" = "xyes"; then
+ have_debug_threads="yes"
+ AC_DEFINE([EFL_DEBUG_THREADS], [1], [Assert when forgot to call eina_threads_init])
+fi
+
if test "x${_efl_have_posix_threads}" = "xyes" ; then
AC_DEFINE([EFL_HAVE_POSIX_THREADS], [1], [Define to mention that POSIX threads are supported])
fi
-
if test "x${_efl_enable_win32_threads}" = "xyes" ; then
_efl_have_win32_threads="yes"
AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported])
#define INF(...) EINA_LOG_DOM_INFO(_eina_mempool_log_dom, __VA_ARGS__)
#endif
+#ifdef EFL_DEBUG_THREADS
+#include <assert.h>
+#endif
+
typedef struct _Chained_Mempool Chained_Mempool;
struct _Chained_Mempool
{
int group_size;
int usage;
#ifdef EFL_HAVE_THREADS
+#ifdef EFL_DEBUG_THREADS
+ pthread_t self;
+#endif
# ifdef EFL_HAVE_POSIX_THREADS
pthread_mutex_t mutex;
# else
WaitForSingleObject(pool->mutex, INFINITE);
# endif
}
+#ifdef EFL_DEBUG_THREADS
+ else
+ assert(pool->self == pthread_self());
+#endif
#endif
// look 4 pool from 2nd bucket on
WaitForSingleObject(pool->mutex, INFINITE);
# endif
}
+#ifdef EFL_DEBUG_THREADS
+ else
+ assert(pool->self == pthread_self());
+#endif
#endif
EINA_INLIST_FOREACH(pool->first, p)
{
// Could the pointer be inside that pool
- if (ptr < p->limit)
+ if ((unsigned char*) ptr < p->limit)
{
// pool mem base
pmem = (void *)(((unsigned char *)p) + sizeof(Chained_Pool));
mp->item_alloc = eina_mempool_alignof(item_size);
mp->group_size = mp->item_alloc * mp->pool_size;
mp->alloc_size = mp->group_size + eina_mempool_alignof(sizeof(Chained_Pool));
+#ifdef EFL_DEBUG_THREADS
+ mp->self = pthread_self();
+#endif
#ifdef EFL_HAVE_THREADS
# ifdef EFL_HAVE_POSIX_THREADS
}
#ifdef EFL_HAVE_THREADS
+#ifdef EFL_DEBUG_THREADS
+ assert(mp->self == pthread_self());
+#endif
# ifdef EFL_HAVE_POSIX_THREADS
pthread_mutex_destroy(&mp->mutex);
# else