Example #1
0
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))
     {
        _eina_shutdown_from_desc(_eina_desc_setup + _eina_desc_setup_len);

#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;
}
Example #2
0
/**
 * @brief Initialize the Eina library.
 *
 * @return 1 or greater on success, 0 on error.
 *
 * This function sets up all the eina modules. It returns 0 on
 * failure (that is, when one of the module fails to initialize),
 * otherwise it returns the number of times it has already been
 * called.
 *
 * When Eina is not used anymore, call eina_shutdown() to shut down
 * the Eina library.
 */
EAPI int eina_init(void)
{
	const struct eina_desc_setup *itr, *itr_end;

	if (EINA_LIKELY(_eina_main_count > 0))
		return ++_eina_main_count;

	if (!eina_log_init()) {
		fprintf(stderr,
			"Could not initialize eina logging system.\n");
		return 0;
	}

	_eina_log_dom =
	    eina_log_domain_register("eina", EINA_LOG_COLOR_DEFAULT);
	if (_eina_log_dom < 0) {
		EINA_LOG_ERR("Could not register log domain: eina");
		eina_log_shutdown();
		return 0;
	}

	itr = _eina_desc_setup;
	itr_end = itr + _eina_desc_setup_len;
	for (; itr < itr_end; itr++) {
		if (!itr->init()) {
			ERR("Could not initialize eina module '%s'.",
			    itr->name);
			_eina_shutdown_from_desc(itr);
			return 0;
		}
	}

	_eina_main_count = 1;
	return 1;
}
Example #3
0
/**
 * @brief Shut down the Eina library.
 *
 * @return 0 when all the modules is completely shut down, 1 or
 * greater otherwise.
 *
 * This function shuts down the Eina library. It returns 0 when it has
 * been called the same number of times than eina_init(). In that case
 * it shut down all the Eina modules.
 *
 * Once this function succeeds (that is, @c 0 is returned), you must
 * not call any of the Eina function anymore. You must call
 * eina_init() again to use the Eina functions again.
 */
EAPI int eina_shutdown(void)
{
	_eina_main_count--;
	if (EINA_UNLIKELY(_eina_main_count == 0))
		_eina_shutdown_from_desc(_eina_desc_setup +
					 _eina_desc_setup_len);

	return _eina_main_count;
}
Example #4
0
EAPI int
eina_init(void)
{
   const struct eina_desc_setup *itr, *itr_end;

   if (EINA_LIKELY(_eina_main_count > 0))
      return ++_eina_main_count;

   srand(time(NULL));
   while (eina_seed == 0)
     eina_seed = rand();

#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");
        return 0;
     }

   _eina_log_dom = eina_log_domain_register("eina", EINA_LOG_COLOR_DEFAULT);
   if (_eina_log_dom < 0)
     {
        EINA_LOG_ERR("Could not register log domain: eina");
        eina_log_shutdown();
        return 0;
     }

   EINA_ERROR_NOT_MAIN_LOOP = eina_error_msg_static_register(
         EINA_ERROR_NOT_MAIN_LOOP_STR);

#ifdef EFL_HAVE_THREADS
# ifdef _WIN32
   _eina_main_loop = GetCurrentThreadId();
# else
   _eina_main_loop = pthread_self();
# endif
   _eina_pid = getpid();
#endif

#ifdef EINA_HAVE_DEBUG_THREADS
   pthread_mutex_init(&_eina_tracking_lock, NULL);

   if (getenv("EINA_DEBUG_THREADS"))
     _eina_threads_debug = atoi(getenv("EINA_DEBUG_THREADS"));
#endif

   itr = _eina_desc_setup;
   itr_end = itr + _eina_desc_setup_len;
   for (; itr < itr_end; itr++)
     {
        if (!itr->init())
          {
             ERR("Could not initialize eina module '%s'.", itr->name);
             _eina_shutdown_from_desc(itr);
             return 0;
          }
     }

   eina_cpu_count_internal();

   _eina_main_count = 1;
   return 1;
}