#endif
#ifdef EFL_HAVE_THREADS
-# if !(defined(_WIN32_WCE)) && !(defined(_WIN32))
+# ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
+# endif
+# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
#endif
+#ifdef HAVE_MCHECK_H
+# ifdef HAVE_MTRACE
+# define MT 1
+# endif
+#endif
+
+#ifdef MT
+#include <mcheck.h>
+#endif
+
#include "eina_lock.h"
#include "eina_config.h"
#include "eina_private.h"
#include "eina_magic.h"
#include "eina_rectangle.h"
#include "eina_safety_checks.h"
+#include "eina_inlist.h"
+#include "eina_inarray.h"
+#include "eina_value.h"
+/* no model for now
+#include "eina_model.h"
+ */
/*============================================================================*
* Local *
static pid_t _eina_pid;
#endif
-#ifdef EINA_HAVE_DEBUG_THREADS
+#ifdef MT
+static int _mt_enabled = 0;
+#endif
+
+#ifdef EFL_HAVE_THREADS
EAPI int _eina_threads_debug = 0;
+# if !defined(_WIN32_WCE) && !defined(_WIN32)
EAPI pthread_mutex_t _eina_tracking_lock;
EAPI Eina_Inlist *_eina_tracking = NULL;
+# endif
#endif
/* place module init/shutdown functions here to avoid other modules
S(magic_string);
S(iterator);
S(accessor);
+ S(inarray);
S(array);
S(module);
S(mempool);
S(simple_xml);
S(file);
S(prefix);
+ S(value);
+ S(tmpstr);
+ S(thread);
+/* no model for now
+ S(model);
+ */
#undef S
struct eina_desc_setup
static const struct eina_desc_setup _eina_desc_setup[] = {
#define S(x) {# x, eina_ ## x ## _init, eina_ ## x ## _shutdown}
/* log is a special case as it needs printf */
+ S(stringshare),
S(error),
S(safety_checks),
S(magic_string),
S(iterator),
S(accessor),
+ S(inarray),
S(array),
S(module),
S(mempool),
S(list),
S(binshare),
- S(stringshare),
S(ustringshare),
S(matrixsparse),
S(convert),
S(quadtree),
S(simple_xml),
S(file),
- S(prefix)
+ S(prefix),
+ S(value),
+ S(tmpstr),
+ S(thread)
+/* no model for now
+ S(model)
+ */
#undef S
};
static const size_t _eina_desc_setup_len = sizeof(_eina_desc_setup) /
if (EINA_LIKELY(_eina_main_count > 0))
return ++_eina_main_count;
+#ifdef MT
+ if ((getenv("EINA_MTRACE")) && (getenv("MALLOC_TRACE")))
+ {
+ _mt_enabled = 1;
+ mtrace();
+ }
+#endif
+
if (!eina_log_init())
{
fprintf(stderr, "Could not initialize eina logging system.\n");
}
}
+ eina_cpu_count_internal();
+
_eina_main_count = 1;
return 1;
}
EAPI int
eina_shutdown(void)
{
+ if (_eina_main_count <= 0)
+ {
+ ERR("Init count not greater than 0 in shutdown.");
+ return 0;
+ }
_eina_main_count--;
if (EINA_UNLIKELY(_eina_main_count == 0))
{
#ifdef EINA_HAVE_DEBUG_THREADS
pthread_mutex_destroy(&_eina_tracking_lock);
#endif
+#ifdef MT
+ if (_mt_enabled)
+ {
+ muntrace();
+ _mt_enabled = 0;
+ }
+#endif
}
return _eina_main_count;
fprintf(stderr, "* LOCK STILL TAKEN : *\n");
fprintf(stderr, "*************************\n");
EINA_INLIST_FOREACH(_eina_tracking, lk)
- eina_lock_debug(lk);
+ {
+ fprintf(stderr, "=======\n");
+ eina_lock_debug(lk);
+ }
fprintf(stderr, "*************************\n");
abort();
}
eina_main_loop_is(void)
{
#ifdef EFL_HAVE_THREADS
- pid_t pid = getpid();
+ pid_t pid;
+
+# ifdef _WIN32
+ if (_eina_main_loop == GetCurrentThreadId())
+ return EINA_TRUE;
+# else
+ if (pthread_equal(_eina_main_loop, pthread_self()))
+ return EINA_TRUE;
+# endif
+ pid = getpid();
# ifdef _WIN32
if (pid != _eina_pid)
{
_eina_main_loop = GetCurrentThreadId();
return EINA_TRUE;
}
- if (_eina_main_loop == GetCurrentThreadId())
- return EINA_TRUE;
-# else
+#else
if (pid != _eina_pid)
{
/* This is in case of a fork, but don't like the solution */
_eina_main_loop = pthread_self();
return EINA_TRUE;
}
-
- if (pthread_equal(_eina_main_loop, pthread_self()))
- return EINA_TRUE;
-# endif
#endif
+#endif
+
return EINA_FALSE;
}