/** * @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; }
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; }