+#ifdef EFL_HAVE_THREADS
+static int _eina_main_thread_count = 0;
+#endif
+static int _eina_log_dom = -1;
+
+#ifdef ERR
+#undef ERR
+#endif
+#define ERR(...) EINA_LOG_DOM_ERR(_eina_log_dom, __VA_ARGS__)
+
+#ifdef DBG
+#undef DBG
+#endif
+#define DBG(...) EINA_LOG_DOM_DBG(_eina_log_dom, __VA_ARGS__)
+
+EAPI Eina_Bool _eina_threads_activated = EINA_FALSE;
+EAPI Eina_Error EINA_ERROR_NOT_MAIN_LOOP = 0;
+
+static const char EINA_ERROR_NOT_MAIN_LOOP_STR[] = "Main loop thread check failed.";
+
+#ifdef EFL_HAVE_THREADS
+# ifdef _WIN32
+EAPI DWORD _eina_main_loop;
+# else
+EAPI pthread_t _eina_main_loop;
+# endif
+static pid_t _eina_pid;
+#endif
+
+#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
+ * calling them by mistake.
+ */
+#define S(x) extern Eina_Bool eina_ ## x ## _init(void); \
+ extern Eina_Bool eina_ ## x ## _shutdown(void)
+ S(log);
+ 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(counter);
+ S(benchmark);
+ S(rectangle);
+ S(strbuf);
+ S(ustrbuf);
+ S(quadtree);
+ 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
+{
+ const char *name;
+ Eina_Bool (*init)(void);
+ Eina_Bool (*shutdown)(void);
+};
+
+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(ustringshare),
+ S(matrixsparse),
+ S(convert),
+ S(counter),
+ S(benchmark),
+ S(rectangle),
+ S(strbuf),
+ S(ustrbuf),
+ S(quadtree),
+ S(simple_xml),
+ S(file),
+ 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) /
+ sizeof(_eina_desc_setup[0]);
+
+static void
+_eina_shutdown_from_desc(const struct eina_desc_setup *itr)
+{
+ for (itr--; itr >= _eina_desc_setup; itr--)
+ {
+ if (!itr->shutdown())
+ ERR("Problems shutting down eina module '%s', ignored.", itr->name);
+ }
+
+ eina_log_domain_unregister(_eina_log_dom);
+ _eina_log_dom = -1;
+ eina_log_shutdown();
+}
+
+/**
+ * @endcond
+ */
+
+/*============================================================================*
+* Global *
+*============================================================================*/
+
+
+/*============================================================================*
+* API *
+*============================================================================*/
+
+/**
+ * @var eina_version
+ * @brief Eina version (defined at configuration time)
+ */
+EAPI Eina_Version *eina_version = &_version;