コード例 #1
0
ファイル: ecore.c プロジェクト: Distrotech/gnutls
/**
 * Set up connections, signal handlers, sockets etc.
 * @return 1 or greater on success, 0 otherwise
 *
 * This function sets up all singal handlers and the basic event loop. If it
 * succeeds, 1 will be returned, otherwise 0 will be returned.
 *
 * @code
 * #include <Ecore.h>
 *
 * int main(int argc, char **argv)
 * {
 *   if (!ecore_init())
 *   {
 *     printf("ERROR: Cannot init Ecore!\n");
 *     return -1;
 *   }
 *   ecore_main_loop_begin();
 *   ecore_shutdown();
 * }
 * @endcode
 */
EAPI int ecore_init(void)
{
	if (++_ecore_init_count != 1)
		return _ecore_init_count;

#ifdef HAVE_LOCALE_H
	setlocale(LC_CTYPE, "");
#endif
	/*
	   if (strcmp(nl_langinfo(CODESET), "UTF-8"))
	   {
	   WRN("Not a utf8 locale!");
	   }
	 */
#ifdef HAVE_EVIL
	if (!evil_init())
		return --_ecore_init_count;
#endif
	if (!eina_init())
		goto shutdown_evil;
	_ecore_log_dom =
	    eina_log_domain_register("Ecore", ECORE_DEFAULT_LOG_COLOR);
	if (_ecore_log_dom < 0) {
		EINA_LOG_ERR("Ecore was unable to create a log domain.");
		goto shutdown_log_dom;
	}
	if (getenv("ECORE_FPS_DEBUG"))
		_ecore_fps_debug = 1;
	if (_ecore_fps_debug)
		_ecore_fps_debug_init();
	_ecore_main_loop_init();
	_ecore_signal_init();
	_ecore_exe_init();
	_ecore_thread_init();
	_ecore_glib_init();
	_ecore_job_init();
	_ecore_time_init();

#if HAVE_MALLINFO
	if (getenv("ECORE_MEM_STAT")) {
		_ecore_memory_pid = getpid();
		ecore_animator_add(_ecore_memory_statistic, NULL);
	}
#endif

#if defined(GLIB_INTEGRATION_ALWAYS)
	if (_ecore_glib_always_integrate)
		ecore_main_loop_glib_integrate();
#endif

	return _ecore_init_count;

      shutdown_log_dom:
	eina_shutdown();
      shutdown_evil:
#ifdef HAVE_EVIL
	evil_shutdown();
#endif
	return --_ecore_init_count;
}
コード例 #2
0
ファイル: evil_suite.c プロジェクト: Limsik/e17
int
main(void)
{
   test tests[] = {
     { "dlfcn       ",  test_dlfcn },
     { "environment ",  test_environment },
     { "gettimeofday",  test_gettimeofday },
     { "link        ",  test_link },
     { "mkstemp     ",  test_mkstemp },
     { "pipe        ",  test_pipe },
     { "print       ",  test_print },
     { "realpath    ",  test_realpath },
     { "util        ",  test_util },
/*      { "memcpy      ",  test_memcpy }, */
     { NULL,            NULL },
   };
   suite *s;
   int    i;

   if (!evil_init())
     return EXIT_FAILURE;

   s = suite_new();
   if (!s)
     {
        evil_shutdown();
        return EXIT_FAILURE;
     }

   for (i = 0; tests[i].name; ++i)
     {
        suite_test_add(s, tests[i].name, tests[i].fct);
     }

   suite_run(s);

   suite_show(s);

   suite_del(s);
   evil_shutdown();

   return EXIT_SUCCESS;
}
コード例 #3
0
ファイル: ecore.c プロジェクト: Distrotech/gnutls
/**
 * Shut down connections, signal handlers sockets etc.
 *
 * This function shuts down all things set up in ecore_init() and cleans up all
 * event queues, handlers, filters, timers, idlers, idle enterers/exiters
 * etc. set up after ecore_init() was called.
 *
 * Do not call this function from any callback that may be called from the main
 * loop, as the main loop will then fall over and not function properly.
 */
EAPI int ecore_shutdown(void)
{
	if (--_ecore_init_count != 0)
		return _ecore_init_count;

	if (_ecore_fps_debug)
		_ecore_fps_debug_shutdown();
	_ecore_poller_shutdown();
	_ecore_animator_shutdown();
	_ecore_glib_shutdown();
	_ecore_job_shutdown();
	_ecore_thread_shutdown();
	_ecore_exe_shutdown();
	_ecore_idle_enterer_shutdown();
	_ecore_idle_exiter_shutdown();
	_ecore_idler_shutdown();
	_ecore_timer_shutdown();
	_ecore_event_shutdown();
	_ecore_main_shutdown();
	_ecore_signal_shutdown();
	_ecore_main_loop_shutdown();

#if HAVE_MALLINFO
	if (getenv("ECORE_MEM_STAT")) {
		_ecore_memory_statistic(NULL);

		ERR("[%i] Memory MAX total: %i, free: %i",
		    _ecore_memory_pid,
		    _ecore_memory_max_total, _ecore_memory_max_free);
	}
#endif

	eina_log_domain_unregister(_ecore_log_dom);
	_ecore_log_dom = -1;
	eina_shutdown();
#ifdef HAVE_EVIL
	evil_shutdown();
#endif

	return _ecore_init_count;
}
コード例 #4
0
/**
 * Shut down connections, signal handlers sockets etc.
 *
 * This function shuts down all things set up in ecore_init() and cleans up all
 * event queues, handlers, filters, timers, idlers, idle enterers/exiters
 * etc. set up after ecore_init() was called.
 *
 * Do not call this function from any callback that may be called from the main
 * loop, as the main loop will then fall over and not function properly.
 */
EAPI int
ecore_shutdown(void)
{
    /*
     * take a lock here because _ecore_event_shutdown() does callbacks
     */
    _ecore_lock();
    if (--_ecore_init_count != 0)
        goto unlock;

    /* this looks horrible - a hack for now, but something to note. as
     * we delete the _thread_call pipe a thread COULD be doing
     * ecore_pipe_write() or what not to it at the same time - we
     * must ensure all possible users of this _thread_call are finished
     * and exited before we delete it here */
    /*
     * ok - this causes other valgrind complaints regarding glib aquiring
     * locks internally. so fix bug a or bug b. let's leave the original
     * bug in then and leave this as a note for now
      Ecore_Pipe *p;
      p = _thread_call;
      _thread_call = NULL;
      ecore_pipe_wait(p, 1, 0.1);
      ecore_pipe_del(p);
     */
    eina_lock_free(&_thread_safety);
    eina_condition_free(&_thread_cond);
    eina_lock_free(&_thread_mutex);
    eina_condition_free(&_thread_feedback_cond);
    eina_lock_free(&_thread_feedback_mutex);
    eina_lock_free(&_thread_id_lock);

    if (_ecore_fps_debug) _ecore_fps_debug_shutdown();
    _ecore_poller_shutdown();
    _ecore_animator_shutdown();
    _ecore_glib_shutdown();
    _ecore_job_shutdown();
    _ecore_thread_shutdown();
    _ecore_exe_shutdown();
    _ecore_idle_enterer_shutdown();
    _ecore_idle_exiter_shutdown();
    _ecore_idler_shutdown();
    _ecore_timer_shutdown();
    _ecore_event_shutdown();
    _ecore_main_shutdown();
    _ecore_signal_shutdown();
    _ecore_main_loop_shutdown();

#if HAVE_MALLINFO
    if (getenv("ECORE_MEM_STAT"))
    {
        _ecore_memory_statistic(NULL);

        ERR("[%i] Memory MAX total: %i, free: %i",
            _ecore_memory_pid,
            _ecore_memory_max_total,
            _ecore_memory_max_free);
    }
#endif
    ecore_mempool_shutdown();
    eina_log_domain_unregister(_ecore_log_dom);
    _ecore_log_dom = -1;
    eina_shutdown();
#ifdef HAVE_EVIL
    evil_shutdown();
#endif
unlock:
    _ecore_unlock();

    return _ecore_init_count;
}