eina: use Eina_Spinlock for Eina_Log.
authorCedric Bail <cedric.bail@samsung.com>
Thu, 10 Oct 2013 08:24:34 +0000 (17:24 +0900)
committerCedric Bail <cedric.bail@samsung.com>
Fri, 11 Oct 2013 02:08:17 +0000 (11:08 +0900)
ChangeLog
NEWS
src/lib/eina/eina_log.c

index 808f62d..f700f93 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2013-10-11  Cedric Bail
 
-       * Eina: add Eina_Spinlock API.
+       * Eina: add Eina_Spinlock API,
+       use Eina_Spinlock in Eina_Log.
 
 2013-10-10  Carsten Haitzler (The Rasterman)
 
diff --git a/NEWS b/NEWS
index 91d5bd1..e49464b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -198,6 +198,7 @@ Improvements:
      - Eina_Tiler now take tile size into account.
      - Improve support for 64bits system.
      - eina_strlcat now work with a NULL source.
+     - Use Eina_Spinlock for eina_log.
     * Eet:
      - Display more information with eet -l -v.
      - Force thread to always run during eet_cache_concurrency test.
index 4829aad..7459d92 100644 (file)
@@ -143,53 +143,11 @@ static Eina_Thread _main_thread;
       }                                                           \
    } while (0)
 
-#ifdef EFL_HAVE_POSIX_THREADS_SPINLOCK
-
-static pthread_spinlock_t _log_lock;
-
-static Eina_Bool _eina_log_spinlock_init(void)
-{
-   if (pthread_spin_init(&_log_lock, PTHREAD_PROCESS_PRIVATE) == 0)
-     return EINA_TRUE;
-
-   fprintf(stderr,
-           "ERROR: pthread_spin_init(%p, PTHREAD_PROCESS_PRIVATE): %s\n",
-           &_log_lock, strerror(errno));
-   return EINA_FALSE;
-}
-
-#   define LOG_LOCK()                                                  \
-   if (_threads_enabled)                                               \
-         do {                                                          \
-            if (0) {                                                   \
-               fprintf(stderr, "+++LOG LOG_LOCKED!   [%s, %lu]\n",     \
-                       __FUNCTION__, (unsigned long)eina_thread_self()); } \
-            if (EINA_UNLIKELY(_threads_enabled)) {                     \
-               pthread_spin_lock(&_log_lock); }                        \
-         } while (0)
-#   define LOG_UNLOCK()                                                \
-   if (_threads_enabled)                                               \
-         do {                                                          \
-            if (EINA_UNLIKELY(_threads_enabled)) {                     \
-               pthread_spin_unlock(&_log_lock); }                      \
-            if (0) {                                                   \
-               fprintf(stderr,                                         \
-                       "---LOG LOG_UNLOCKED! [%s, %lu]\n",             \
-                       __FUNCTION__, (unsigned long)eina_thread_self()); } \
-         } while (0)
-#   define INIT() _eina_log_spinlock_init()
-#   define SHUTDOWN() pthread_spin_destroy(&_log_lock)
-
-#else /* ! EFL_HAVE_POSIX_THREADS_SPINLOCK */
-
-static Eina_Lock _log_mutex;
-#   define LOG_LOCK() if(_threads_enabled) {eina_lock_take(&_log_mutex); }
-#   define LOG_UNLOCK() if(_threads_enabled) {eina_lock_release(&_log_mutex); }
-#   define INIT() eina_lock_new(&_log_mutex)
-#   define SHUTDOWN() eina_lock_free(&_log_mutex)
-
-#endif /* ! EFL_HAVE_POSIX_THREADS_SPINLOCK */
-
+static Eina_Spinlock _log_mutex;
+#   define LOG_LOCK() if(_threads_enabled) {eina_spinlock_take(&_log_mutex); }
+#   define LOG_UNLOCK() if(_threads_enabled) {eina_spinlock_release(&_log_mutex); }
+#   define INIT() eina_spinlock_new(&_log_mutex)
+#   define SHUTDOWN() eina_spinlock_free(&_log_mutex)
 
 // List of domains registered
 static Eina_Log_Domain *_log_domains = NULL;