2008-08-06 11:15:24 -07:00
|
|
|
/* EINA - EFL data type library
|
|
|
|
* Copyright (C) 2008 Cedric Bail
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library;
|
|
|
|
* if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-08-28 00:46:42 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-08-16 23:58:26 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2010-07-13 06:51:00 -07:00
|
|
|
#ifdef EFL_HAVE_WIN32_THREADS
|
|
|
|
# define WIN32_LEAN_AND_MEAN
|
|
|
|
# include <windows.h>
|
|
|
|
# undef WIN32_LEAN_AND_MEAN
|
|
|
|
#endif
|
|
|
|
|
2011-08-09 01:47:57 -07:00
|
|
|
#ifdef EFL_HAVE_THREADS
|
2011-09-18 03:13:29 -07:00
|
|
|
# ifdef HAVE_SYS_TYPES_H
|
2011-08-09 01:47:57 -07:00
|
|
|
# include <sys/types.h>
|
2011-09-18 03:13:29 -07:00
|
|
|
# endif
|
|
|
|
# ifdef HAVE_UNISTD_H
|
2011-08-09 01:47:57 -07:00
|
|
|
# include <unistd.h>
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2011-09-20 04:28:25 -07:00
|
|
|
#ifdef HAVE_MCHECK
|
|
|
|
# ifdef HAVE_MTRACE
|
|
|
|
# define MT 1
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MT
|
|
|
|
#include <mcheck.h>
|
|
|
|
#endif
|
|
|
|
|
2011-05-02 04:20:00 -07:00
|
|
|
#include "eina_lock.h"
|
2009-08-28 05:03:34 -07:00
|
|
|
#include "eina_config.h"
|
2009-09-03 18:48:36 -07:00
|
|
|
#include "eina_private.h"
|
2009-01-23 08:11:45 -08:00
|
|
|
#include "eina_types.h"
|
|
|
|
#include "eina_main.h"
|
|
|
|
#include "eina_error.h"
|
2009-08-25 14:26:27 -07:00
|
|
|
#include "eina_log.h"
|
2009-01-23 08:11:45 -08:00
|
|
|
#include "eina_hash.h"
|
2010-07-27 20:33:49 -07:00
|
|
|
#include "eina_binshare.h"
|
2009-01-23 08:11:45 -08:00
|
|
|
#include "eina_stringshare.h"
|
2010-07-27 01:55:23 -07:00
|
|
|
#include "eina_ustringshare.h"
|
2009-01-23 08:11:45 -08:00
|
|
|
#include "eina_list.h"
|
2009-09-04 06:43:44 -07:00
|
|
|
#include "eina_matrixsparse.h"
|
2009-01-23 08:11:45 -08:00
|
|
|
#include "eina_array.h"
|
|
|
|
#include "eina_counter.h"
|
|
|
|
#include "eina_benchmark.h"
|
|
|
|
#include "eina_magic.h"
|
2009-04-09 08:51:32 -07:00
|
|
|
#include "eina_rectangle.h"
|
2009-09-03 18:48:36 -07:00
|
|
|
#include "eina_safety_checks.h"
|
2011-10-03 19:33:00 -07:00
|
|
|
#include "eina_inlist.h"
|
2008-08-06 08:37:29 -07:00
|
|
|
|
2009-06-22 13:03:58 -07:00
|
|
|
/*============================================================================*
|
2010-07-27 19:37:05 -07:00
|
|
|
* Local *
|
|
|
|
*============================================================================*/
|
2009-06-22 13:03:58 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @cond LOCAL
|
|
|
|
*/
|
|
|
|
|
2010-08-16 23:58:26 -07:00
|
|
|
static Eina_Version _version = { VMAJ, VMIN, VMIC, VREV };
|
|
|
|
|
2009-06-22 13:03:58 -07:00
|
|
|
static int _eina_main_count = 0;
|
2010-07-13 06:51:00 -07:00
|
|
|
#ifdef EFL_HAVE_THREADS
|
2009-11-01 11:50:18 -08:00
|
|
|
static int _eina_main_thread_count = 0;
|
2009-12-09 00:34:09 -08:00
|
|
|
#endif
|
2009-09-03 18:48:36 -07:00
|
|
|
static int _eina_log_dom = -1;
|
2009-09-06 21:23:05 -07:00
|
|
|
|
|
|
|
#ifdef ERR
|
|
|
|
#undef ERR
|
|
|
|
#endif
|
2009-09-03 18:48:36 -07:00
|
|
|
#define ERR(...) EINA_LOG_DOM_ERR(_eina_log_dom, __VA_ARGS__)
|
2009-09-06 21:23:05 -07:00
|
|
|
|
|
|
|
#ifdef DBG
|
|
|
|
#undef DBG
|
|
|
|
#endif
|
2009-09-03 18:48:36 -07:00
|
|
|
#define DBG(...) EINA_LOG_DOM_DBG(_eina_log_dom, __VA_ARGS__)
|
2009-06-22 13:03:58 -07:00
|
|
|
|
2011-04-24 13:22:17 -07:00
|
|
|
EAPI Eina_Bool _eina_threads_activated = EINA_FALSE;
|
2011-08-09 01:48:57 -07:00
|
|
|
EAPI Eina_Error EINA_ERROR_NOT_MAIN_LOOP = 0;
|
|
|
|
|
|
|
|
static const char EINA_ERROR_NOT_MAIN_LOOP_STR[] = "Main loop thread check failed.";
|
2011-04-24 13:22:17 -07:00
|
|
|
|
2011-08-09 01:47:57 -07:00
|
|
|
#ifdef EFL_HAVE_THREADS
|
2011-08-26 09:13:29 -07:00
|
|
|
# ifdef _WIN32
|
|
|
|
EAPI DWORD _eina_main_loop;
|
2011-07-29 08:37:39 -07:00
|
|
|
# else
|
2011-08-09 01:47:57 -07:00
|
|
|
EAPI pthread_t _eina_main_loop;
|
2011-07-29 08:37:39 -07:00
|
|
|
# endif
|
2011-08-26 09:13:29 -07:00
|
|
|
static pid_t _eina_pid;
|
2011-07-29 08:37:39 -07:00
|
|
|
#endif
|
|
|
|
|
2011-09-20 04:28:25 -07:00
|
|
|
#ifdef MT
|
|
|
|
static int _mt_enabled = 0;
|
|
|
|
#endif
|
|
|
|
|
2011-10-03 19:33:00 -07:00
|
|
|
#ifdef EFL_HAVE_THREADS
|
2011-04-24 13:22:17 -07:00
|
|
|
EAPI int _eina_threads_debug = 0;
|
2011-10-05 23:34:39 -07:00
|
|
|
EAPI Eina_Lock _eina_tracking_lock;
|
2011-05-04 06:53:22 -07:00
|
|
|
EAPI Eina_Inlist *_eina_tracking = NULL;
|
2011-04-24 13:22:17 -07:00
|
|
|
#endif
|
2010-10-12 09:53:30 -07:00
|
|
|
|
2009-09-06 15:21:56 -07:00
|
|
|
/* place module init/shutdown functions here to avoid other modules
|
|
|
|
* calling them by mistake.
|
|
|
|
*/
|
2010-07-27 19:37:05 -07:00
|
|
|
#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(array);
|
|
|
|
S(module);
|
|
|
|
S(mempool);
|
|
|
|
S(list);
|
2010-07-27 20:33:49 -07:00
|
|
|
S(binshare);
|
2010-07-27 19:37:05 -07:00
|
|
|
S(stringshare);
|
|
|
|
S(ustringshare);
|
|
|
|
S(matrixsparse);
|
|
|
|
S(convert);
|
|
|
|
S(counter);
|
|
|
|
S(benchmark);
|
|
|
|
S(rectangle);
|
|
|
|
S(strbuf);
|
|
|
|
S(ustrbuf);
|
|
|
|
S(quadtree);
|
2011-04-06 03:14:03 -07:00
|
|
|
S(simple_xml);
|
2011-04-13 09:15:30 -07:00
|
|
|
S(file);
|
2011-09-02 22:31:25 -07:00
|
|
|
S(prefix);
|
2009-09-06 15:21:56 -07:00
|
|
|
#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[] = {
|
2010-07-27 19:37:05 -07:00
|
|
|
#define S(x) {# x, eina_ ## x ## _init, eina_ ## x ## _shutdown}
|
|
|
|
/* log is a special case as it needs printf */
|
|
|
|
S(error),
|
|
|
|
S(safety_checks),
|
|
|
|
S(magic_string),
|
|
|
|
S(iterator),
|
|
|
|
S(accessor),
|
|
|
|
S(array),
|
|
|
|
S(module),
|
|
|
|
S(mempool),
|
|
|
|
S(list),
|
2010-07-27 20:33:49 -07:00
|
|
|
S(binshare),
|
2010-07-27 19:37:05 -07:00
|
|
|
S(stringshare),
|
|
|
|
S(ustringshare),
|
|
|
|
S(matrixsparse),
|
|
|
|
S(convert),
|
|
|
|
S(counter),
|
|
|
|
S(benchmark),
|
|
|
|
S(rectangle),
|
|
|
|
S(strbuf),
|
|
|
|
S(ustrbuf),
|
2011-04-06 03:14:03 -07:00
|
|
|
S(quadtree),
|
2011-04-13 09:15:30 -07:00
|
|
|
S(simple_xml),
|
2011-09-02 22:31:25 -07:00
|
|
|
S(file),
|
|
|
|
S(prefix)
|
2009-09-06 15:21:56 -07:00
|
|
|
#undef S
|
|
|
|
};
|
2010-07-27 19:37:05 -07:00
|
|
|
static const size_t _eina_desc_setup_len = sizeof(_eina_desc_setup) /
|
|
|
|
sizeof(_eina_desc_setup[0]);
|
2009-09-06 15:21:56 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_eina_shutdown_from_desc(const struct eina_desc_setup *itr)
|
|
|
|
{
|
|
|
|
for (itr--; itr >= _eina_desc_setup; itr--)
|
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
if (!itr->shutdown())
|
|
|
|
ERR("Problems shutting down eina module '%s', ignored.", itr->name);
|
2009-09-06 15:21:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
eina_log_domain_unregister(_eina_log_dom);
|
|
|
|
_eina_log_dom = -1;
|
|
|
|
eina_log_shutdown();
|
|
|
|
}
|
|
|
|
|
2009-06-22 13:03:58 -07:00
|
|
|
/**
|
|
|
|
* @endcond
|
|
|
|
*/
|
|
|
|
|
2008-08-28 00:46:42 -07:00
|
|
|
/*============================================================================*
|
2010-07-27 19:37:05 -07:00
|
|
|
* Global *
|
|
|
|
*============================================================================*/
|
2008-08-28 00:46:42 -07:00
|
|
|
|
2010-08-16 23:58:26 -07:00
|
|
|
|
2008-08-28 00:46:42 -07:00
|
|
|
/*============================================================================*
|
2010-07-27 19:37:05 -07:00
|
|
|
* API *
|
|
|
|
*============================================================================*/
|
2008-08-28 00:46:42 -07:00
|
|
|
|
2010-08-16 23:58:26 -07:00
|
|
|
/**
|
|
|
|
* @var eina_version
|
|
|
|
* @brief Eina version (defined at configuration time)
|
|
|
|
*/
|
|
|
|
EAPI Eina_Version *eina_version = &_version;
|
|
|
|
|
2008-08-06 08:37:29 -07:00
|
|
|
EAPI int
|
|
|
|
eina_init(void)
|
|
|
|
{
|
2009-09-06 15:21:56 -07:00
|
|
|
const struct eina_desc_setup *itr, *itr_end;
|
|
|
|
|
|
|
|
if (EINA_LIKELY(_eina_main_count > 0))
|
2010-07-27 19:37:05 -07:00
|
|
|
return ++_eina_main_count;
|
2008-08-06 08:37:29 -07:00
|
|
|
|
2011-09-20 04:28:25 -07:00
|
|
|
#ifdef MT
|
|
|
|
if ((getenv("EINA_MTRACE")) && (getenv("MALLOC_TRACE")))
|
|
|
|
{
|
|
|
|
_mt_enabled = 1;
|
|
|
|
mtrace();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-03 18:48:36 -07:00
|
|
|
if (!eina_log_init())
|
2009-06-05 21:22:21 -07:00
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
fprintf(stderr, "Could not initialize eina logging system.\n");
|
|
|
|
return 0;
|
2009-06-05 21:22:21 -07:00
|
|
|
}
|
2010-07-27 19:37:05 -07:00
|
|
|
|
2009-09-03 18:48:36 -07:00
|
|
|
_eina_log_dom = eina_log_domain_register("eina", EINA_LOG_COLOR_DEFAULT);
|
|
|
|
if (_eina_log_dom < 0)
|
2009-08-25 14:26:27 -07:00
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
EINA_LOG_ERR("Could not register log domain: eina");
|
|
|
|
eina_log_shutdown();
|
|
|
|
return 0;
|
2009-09-03 18:48:36 -07:00
|
|
|
}
|
|
|
|
|
2011-08-09 01:48:57 -07:00
|
|
|
EINA_ERROR_NOT_MAIN_LOOP = eina_error_msg_static_register(
|
|
|
|
EINA_ERROR_NOT_MAIN_LOOP_STR);
|
|
|
|
|
2011-08-09 01:47:57 -07:00
|
|
|
#ifdef EFL_HAVE_THREADS
|
2011-08-26 09:13:29 -07:00
|
|
|
# ifdef _WIN32
|
|
|
|
_eina_main_loop = GetCurrentThreadId();
|
2011-08-09 01:47:57 -07:00
|
|
|
# else
|
2011-05-04 06:53:22 -07:00
|
|
|
_eina_main_loop = pthread_self();
|
2011-08-09 01:46:29 -07:00
|
|
|
# endif
|
2011-08-26 09:13:29 -07:00
|
|
|
_eina_pid = getpid();
|
2011-07-29 08:37:39 -07:00
|
|
|
#endif
|
2011-08-09 01:46:29 -07:00
|
|
|
|
2011-07-29 08:37:39 -07:00
|
|
|
#ifdef EINA_HAVE_DEBUG_THREADS
|
2011-10-05 23:34:39 -07:00
|
|
|
eina_lock_new(&_eina_tracking_lock);
|
2011-05-04 06:53:22 -07:00
|
|
|
|
|
|
|
if (getenv("EINA_DEBUG_THREADS"))
|
|
|
|
_eina_threads_debug = atoi(getenv("EINA_DEBUG_THREADS"));
|
|
|
|
#endif
|
|
|
|
|
2009-09-06 15:21:56 -07:00
|
|
|
itr = _eina_desc_setup;
|
|
|
|
itr_end = itr + _eina_desc_setup_len;
|
|
|
|
for (; itr < itr_end; itr++)
|
2009-09-03 17:53:19 -07:00
|
|
|
{
|
2010-07-27 19:37:05 -07:00
|
|
|
if (!itr->init())
|
|
|
|
{
|
|
|
|
ERR("Could not initialize eina module '%s'.", itr->name);
|
|
|
|
_eina_shutdown_from_desc(itr);
|
|
|
|
return 0;
|
|
|
|
}
|
2009-09-03 17:53:19 -07:00
|
|
|
}
|
|
|
|
|
2009-09-06 15:21:56 -07:00
|
|
|
_eina_main_count = 1;
|
|
|
|
return 1;
|
2008-08-06 08:37:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
eina_shutdown(void)
|
|
|
|
{
|
2009-09-06 15:21:56 -07:00
|
|
|
_eina_main_count--;
|
|
|
|
if (EINA_UNLIKELY(_eina_main_count == 0))
|
2011-04-24 08:54:09 -07:00
|
|
|
{
|
|
|
|
_eina_shutdown_from_desc(_eina_desc_setup + _eina_desc_setup_len);
|
|
|
|
|
2011-05-04 06:53:22 -07:00
|
|
|
#ifdef EINA_HAVE_DEBUG_THREADS
|
2011-10-05 23:34:39 -07:00
|
|
|
eina_lock_free(&_eina_tracking_lock);
|
2011-05-04 06:53:22 -07:00
|
|
|
#endif
|
2011-09-20 04:28:25 -07:00
|
|
|
#ifdef MT
|
|
|
|
if (_mt_enabled)
|
|
|
|
{
|
|
|
|
muntrace();
|
|
|
|
_mt_enabled = 0;
|
|
|
|
}
|
|
|
|
#endif
|
2011-04-24 08:54:09 -07:00
|
|
|
}
|
2010-07-27 19:37:05 -07:00
|
|
|
|
2009-09-06 15:21:56 -07:00
|
|
|
return _eina_main_count;
|
2008-08-06 08:37:29 -07:00
|
|
|
}
|
|
|
|
|
2009-11-01 11:50:18 -08:00
|
|
|
|
|
|
|
EAPI int
|
|
|
|
eina_threads_init(void)
|
|
|
|
{
|
2010-07-13 06:51:00 -07:00
|
|
|
#ifdef EFL_HAVE_THREADS
|
2010-07-27 19:37:05 -07:00
|
|
|
int ret;
|
2010-07-13 06:51:00 -07:00
|
|
|
|
2011-05-02 04:20:00 -07:00
|
|
|
#ifdef EINA_HAVE_DEBUG_THREADS
|
|
|
|
assert(pthread_equal(_eina_main_loop, pthread_self()));
|
|
|
|
#endif
|
2010-07-27 19:37:05 -07:00
|
|
|
|
|
|
|
++_eina_main_thread_count;
|
|
|
|
ret = _eina_main_thread_count;
|
|
|
|
|
|
|
|
if(_eina_main_thread_count > 1)
|
2011-05-06 02:07:26 -07:00
|
|
|
return ret;
|
2009-11-01 11:50:18 -08:00
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
eina_share_common_threads_init();
|
|
|
|
eina_log_threads_init();
|
2011-04-24 13:22:17 -07:00
|
|
|
_eina_threads_activated = EINA_TRUE;
|
2009-11-01 11:50:18 -08:00
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
return ret;
|
2009-11-01 11:50:18 -08:00
|
|
|
#else
|
2010-07-27 19:37:05 -07:00
|
|
|
return 0;
|
2009-11-01 11:50:18 -08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
eina_threads_shutdown(void)
|
|
|
|
{
|
2010-07-13 06:51:00 -07:00
|
|
|
#ifdef EFL_HAVE_THREADS
|
2010-07-27 19:37:05 -07:00
|
|
|
int ret;
|
2009-11-01 11:50:18 -08:00
|
|
|
|
2011-05-02 04:20:00 -07:00
|
|
|
#ifdef EINA_HAVE_DEBUG_THREADS
|
2011-05-04 06:53:22 -07:00
|
|
|
const Eina_Lock *lk;
|
|
|
|
|
2011-05-02 04:20:00 -07:00
|
|
|
assert(pthread_equal(_eina_main_loop, pthread_self()));
|
|
|
|
assert(_eina_main_thread_count > 0);
|
2011-05-09 03:29:55 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
ret = --_eina_main_thread_count;
|
|
|
|
if(_eina_main_thread_count > 0)
|
|
|
|
return ret;
|
2011-05-04 06:53:22 -07:00
|
|
|
|
2011-05-09 03:29:55 -07:00
|
|
|
#ifdef EINA_HAVE_DEBUG_THREADS
|
2011-10-05 23:34:39 -07:00
|
|
|
eina_lock_take(&_eina_tracking_lock);
|
2011-05-04 06:53:22 -07:00
|
|
|
if (_eina_tracking)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "*************************\n");
|
|
|
|
fprintf(stderr, "* The IMPOSSIBLE HAPPEN *\n");
|
|
|
|
fprintf(stderr, "* LOCK STILL TAKEN : *\n");
|
|
|
|
fprintf(stderr, "*************************\n");
|
|
|
|
EINA_INLIST_FOREACH(_eina_tracking, lk)
|
|
|
|
eina_lock_debug(lk);
|
|
|
|
fprintf(stderr, "*************************\n");
|
|
|
|
abort();
|
|
|
|
}
|
2011-10-05 23:34:39 -07:00
|
|
|
eina_lock_release(&_eina_tracking_lock);
|
2011-05-02 04:20:00 -07:00
|
|
|
#endif
|
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
eina_share_common_threads_shutdown();
|
|
|
|
eina_log_threads_shutdown();
|
2009-11-01 11:50:18 -08:00
|
|
|
|
2011-04-24 13:22:17 -07:00
|
|
|
_eina_threads_activated = EINA_FALSE;
|
2010-07-13 06:51:00 -07:00
|
|
|
|
2010-07-27 19:37:05 -07:00
|
|
|
return ret;
|
2009-11-01 11:50:18 -08:00
|
|
|
#else
|
2010-07-27 19:37:05 -07:00
|
|
|
return 0;
|
2009-11-01 11:50:18 -08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-07-29 07:56:42 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
eina_main_loop_is(void)
|
|
|
|
{
|
2011-08-09 01:47:57 -07:00
|
|
|
#ifdef EFL_HAVE_THREADS
|
|
|
|
pid_t pid = getpid();
|
|
|
|
|
2011-08-26 09:13:29 -07:00
|
|
|
# ifdef _WIN32
|
|
|
|
if (pid != _eina_pid)
|
|
|
|
{
|
|
|
|
_eina_pid = pid;
|
|
|
|
_eina_main_loop = GetCurrentThreadId();
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
if (_eina_main_loop == GetCurrentThreadId())
|
|
|
|
return EINA_TRUE;
|
|
|
|
# else
|
2011-08-09 01:47:57 -07:00
|
|
|
if (pid != _eina_pid)
|
|
|
|
{
|
|
|
|
/* This is in case of a fork, but don't like the solution */
|
|
|
|
_eina_pid = pid;
|
|
|
|
_eina_main_loop = pthread_self();
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2011-07-29 07:56:42 -07:00
|
|
|
if (pthread_equal(_eina_main_loop, pthread_self()))
|
|
|
|
return EINA_TRUE;
|
2011-07-29 08:37:39 -07:00
|
|
|
# endif
|
2011-07-29 07:56:42 -07:00
|
|
|
#endif
|
2011-07-29 08:37:39 -07:00
|
|
|
return EINA_FALSE;
|
2011-07-29 07:56:42 -07:00
|
|
|
}
|
|
|
|
|
2011-08-17 02:42:43 -07:00
|
|
|
/** The purpose of this API should not be documented, it is used only by the one who know what they are doing. */
|
|
|
|
EAPI void
|
|
|
|
eina_main_loop_define(void)
|
|
|
|
{
|
2011-08-26 09:13:29 -07:00
|
|
|
#ifdef EFL_HAVE_THREADS
|
2011-08-17 02:42:43 -07:00
|
|
|
_eina_pid = getpid();
|
2011-08-26 09:13:29 -07:00
|
|
|
# ifdef _WIN32
|
|
|
|
_eina_main_loop = GetCurrentThreadId();
|
|
|
|
# else
|
2011-08-17 02:42:43 -07:00
|
|
|
_eina_main_loop = pthread_self();
|
2011-08-26 09:13:29 -07:00
|
|
|
# endif
|
|
|
|
#endif
|
2011-08-17 02:42:43 -07:00
|
|
|
}
|
|
|
|
|
2009-06-22 13:03:58 -07:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|