eina: add Eina_Thread API.
[profile/ivi/eina.git] / src / lib / eina_main.c
index f890058..fb2bb0d 100644 (file)
@@ -156,6 +156,8 @@ EAPI Eina_Inlist *_eina_tracking = NULL;
    S(file);
    S(prefix);
    S(value);
+   S(tmpstr);
+   S(thread);
 /* no model for now
    S(model);
  */
@@ -196,6 +198,8 @@ static const struct eina_desc_setup _eina_desc_setup[] = {
    S(file),
    S(prefix),
    S(value),
+   S(tmpstr),
+   S(thread)
 /* no model for now
    S(model)
  */
@@ -298,6 +302,8 @@ eina_init(void)
           }
      }
 
+   eina_cpu_count_internal();
+
    _eina_main_count = 1;
    return 1;
 }
@@ -305,6 +311,11 @@ eina_init(void)
 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))
      {
@@ -403,8 +414,17 @@ EAPI Eina_Bool
 eina_main_loop_is(void)
 {
 #ifdef EFL_HAVE_THREADS
-   pid_t pid = getpid();
+  pid_t pid;
+
+# ifdef _WIN32
+   if (_eina_main_loop == GetCurrentThreadId())
+     return EINA_TRUE;
+# else
+   if (pthread_equal(_eina_main_loop, pthread_self()))
+     return EINA_TRUE;
+# endif
 
+   pid = getpid();
 # ifdef _WIN32
    if (pid != _eina_pid)
      {
@@ -412,9 +432,7 @@ eina_main_loop_is(void)
         _eina_main_loop = GetCurrentThreadId();
         return EINA_TRUE;
      }
-   if (_eina_main_loop == GetCurrentThreadId())
-     return EINA_TRUE;
-# else
+#else
    if (pid != _eina_pid)
      {
         /* This is in case of a fork, but don't like the solution */
@@ -422,11 +440,9 @@ eina_main_loop_is(void)
         _eina_main_loop = pthread_self();
         return EINA_TRUE;
      }
-
-   if (pthread_equal(_eina_main_loop, pthread_self()))
-     return EINA_TRUE;
-# endif
 #endif
+#endif
+
    return EINA_FALSE;
 }