Eina : add a prefix to STRINGSHARE_LOCK and LOG_LOCK
authorwatchwolf <watchwolf>
Sun, 1 Nov 2009 20:09:26 +0000 (20:09 +0000)
committerwatchwolf <watchwolf@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 1 Nov 2009 20:09:26 +0000 (20:09 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/eina@43399 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/eina_log.c
src/lib/eina_main.c
src/lib/eina_stringshare.c

index 30c3be7..34da05f 100644 (file)
@@ -375,37 +375,37 @@ static pthread_t _main_thread;
 
 #ifdef EINA_PTHREAD_SPIN
 static pthread_spinlock_t _log_lock;
-#define LOCK()                                                         \
+#define LOG_LOCK()                                                             \
   if(_threads_enabled) \
   do {                                                                 \
      if (0)                                                            \
-       fprintf(stderr, "+++LOG LOCKED!   [%s, %lu]\n",                 \
+       fprintf(stderr, "+++LOG LOG_LOCKED!   [%s, %lu]\n",                     \
               __FUNCTION__, pthread_self());                           \
      if (EINA_UNLIKELY(_threads_enabled))                              \
        pthread_spin_lock(&_log_lock);                                  \
   } while (0)
-#define UNLOCK()                                                       \
+#define LOG_UNLOCK()                                                   \
   if(_threads_enabled) \
   do {                                                                 \
      if (EINA_UNLIKELY(_threads_enabled))                              \
        pthread_spin_unlock(&_log_lock);                                        \
      if (0)                                                            \
        fprintf(stderr,                                                 \
-              "---LOG UNLOCKED! [%s, %lu]\n",                          \
+              "---LOG LOG_UNLOCKED! [%s, %lu]\n",                              \
               __FUNCTION__, pthread_self());                           \
   } while (0)
 #define INIT() pthread_spin_init(&_log_lock, PTHREAD_PROCESS_PRIVATE);
 #define SHUTDOWN() pthread_spin_destroy(&_log_lock);
 #else
 static pthread_mutex_t _log_mutex = PTHREAD_MUTEX_INITIALIZER;
-#define LOCK() if(_threads_enabled) pthread_mutex_lock(&_log_mutex);
-#define UNLOCK() if(_threads_enabled) pthread_mutex_unlock(&_log_mutex);
+#define LOG_LOCK() if(_threads_enabled) pthread_mutex_lock(&_log_mutex);
+#define LOG_UNLOCK() if(_threads_enabled) pthread_mutex_unlock(&_log_mutex);
 #define INIT() do {} while (0)
 #define SHUTDOWN() do {} while (0)
 #endif
 #else
-#define LOCK() do {} while (0)
-#define UNLOCK() do {} while (0)
+#define LOG_LOCK() do {} while (0)
+#define LOG_UNLOCK() do {} while (0)
 #define IS_MAIN(t)  (1)
 #define IS_OTHER(t) (0)
 #define CHECK_MAIN(...) do {} while (0)
@@ -1134,11 +1134,11 @@ eina_log_threads_enable(void)
 EAPI void
 eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data)
 {
-   LOCK();
+   LOG_LOCK();
    _print_cb = cb;
    _print_cb_data = data;
    eina_log_print_prefix_update();
-   UNLOCK();
+   LOG_UNLOCK();
 }
 
 /**
@@ -1243,9 +1243,9 @@ eina_log_domain_register(const char *name, const char *color)
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(name, -1);
 
-   LOCK();
+   LOG_LOCK();
    r = eina_log_domain_register_unlocked(name, color);
-   UNLOCK();
+   LOG_UNLOCK();
    return r;
 }
 
@@ -1274,9 +1274,9 @@ EAPI void
 eina_log_domain_unregister(int domain)
 {
    EINA_SAFETY_ON_FALSE_RETURN(domain >= 0);
-   LOCK();
+   LOG_LOCK();
    eina_log_domain_unregister_unlocked(domain);
-   UNLOCK();
+   LOG_UNLOCK();
 }
 
 /**
@@ -1446,9 +1446,9 @@ eina_log_print(int domain, Eina_Log_Level level, const char *file,
      }
 #endif
    va_start(args, fmt);
-   LOCK();
+   LOG_LOCK();
    eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args);
-   UNLOCK();
+   LOG_UNLOCK();
    va_end(args);
 }
 
@@ -1497,8 +1497,8 @@ eina_log_vprint(int domain, Eina_Log_Level level, const char *file,
        return;
      }
 #endif
-   LOCK();
+   LOG_LOCK();
    eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args);
-   UNLOCK();
+   LOG_UNLOCK();
 }
 
index 0b8af5e..0c9172c 100644 (file)
@@ -314,7 +314,6 @@ eina_threads_shutdown(void)
 #endif
 }
 
-
 /**
  * @}
  */
index 8e445b6..63be400 100644 (file)
@@ -183,15 +183,15 @@ static Eina_Bool _threads_activated = EINA_FALSE;
 static pthread_mutex_t _mutex_small = PTHREAD_MUTEX_INITIALIZER;
 //string >= 4
 static pthread_mutex_t _mutex_big = PTHREAD_MUTEX_INITIALIZER;
-#define LOCK_SMALL() if(_threads_activated) pthread_mutex_lock(&_mutex_small);
-#define UNLOCK_SMALL() if(_threads_activated) pthread_mutex_unlock(&_mutex_small);
-#define LOCK_BIG() if(_threads_activated) pthread_mutex_lock(&_mutex_big); 
-#define UNLOCK_BIG() if(_threads_activated) pthread_mutex_unlock(&_mutex_big);
+#define STRINGSHARE_LOCK_SMALL() if(_threads_activated) pthread_mutex_lock(&_mutex_small);
+#define STRINGSHARE_UNLOCK_SMALL() if(_threads_activated) pthread_mutex_unlock(&_mutex_small);
+#define STRINGSHARE_LOCK_BIG() if(_threads_activated) pthread_mutex_lock(&_mutex_big);
+#define STRINGSHARE_UNLOCK_BIG() if(_threads_activated) pthread_mutex_unlock(&_mutex_big);
 #else
-#define LOCK_SMALL() do {} while (0)
-#define UNLOCK_SMALL() do {} while (0)
-#define LOCK_BIG() do {} while (0)
-#define UNLOCK_BIG() do {} while (0)
+#define STRINGSHARE_LOCK_SMALL() do {} while (0)
+#define STRINGSHARE_UNLOCK_SMALL() do {} while (0)
+#define STRINGSHARE_LOCK_BIG() do {} while (0)
+#define STRINGSHARE_UNLOCK_BIG() do {} while (0)
 #endif
 
 
@@ -301,8 +301,8 @@ _eina_stringshare_population_stats(void)
 static void
 _eina_stringshare_population_add(int slen)
 {
-   LOCK_SMALL();
-   LOCK_BIG();
+   STRINGSHARE_LOCK_SMALL();
+   STRINGSHARE_LOCK_BIG();
 
    population.count++;
    if (population.count > population.max)
@@ -315,22 +315,22 @@ _eina_stringshare_population_add(int slen)
          population_group[slen].max = population_group[slen].count;
      }
 
-   UNLOCK_BIG();
-   UNLOCK_SMALL();
+   STRINGSHARE_UNLOCK_BIG();
+   STRINGSHARE_UNLOCK_SMALL();
 }
 
 static void
 _eina_stringshare_population_del(int slen)
 {
-   LOCK_SMALL();
-   LOCK_BIG();
+   STRINGSHARE_LOCK_SMALL();
+   STRINGSHARE_LOCK_BIG();
 
    population.count--;
    if (slen < 4)
      population_group[slen].count--;
 
-   UNLOCK_BIG();
-   UNLOCK_SMALL();
+   STRINGSHARE_UNLOCK_BIG();
+   STRINGSHARE_UNLOCK_SMALL();
 }
 
 static void
@@ -916,8 +916,8 @@ eina_stringshare_shutdown(void)
 {
    unsigned int i;
 
-   LOCK_SMALL();
-   LOCK_BIG();
+   STRINGSHARE_LOCK_SMALL();
+   STRINGSHARE_LOCK_BIG();
 
    _eina_stringshare_population_stats();
 
@@ -934,8 +934,8 @@ eina_stringshare_shutdown(void)
    eina_log_domain_unregister(_eina_stringshare_log_dom);
    _eina_stringshare_log_dom = -1;
 
-   UNLOCK_BIG();
-   UNLOCK_SMALL();
+   STRINGSHARE_UNLOCK_BIG();
+   STRINGSHARE_UNLOCK_SMALL();
 
 
    return EINA_TRUE;
@@ -952,17 +952,17 @@ eina_stringshare_shutdown(void)
  *
  * @see eina_thread_init()
  */
-void 
+void
 eina_stringshare_threads_init(void)
 {
-   _threads_activated = EINA_TRUE; 
+   _threads_activated = EINA_TRUE;
 }
 
 /**
  * @internal
  * @brief Shut down the stringshare mutexs.
  *
- * This function shuts down the mutexs in the stringshare module. 
+ * This function shuts down the mutexs in the stringshare module.
  * It is called by eina_thread_shutdown().
  *
  * @see eina_thread_shutdown()
@@ -970,7 +970,7 @@ eina_stringshare_threads_init(void)
 void
 eina_stringshare_threads_shutdown(void)
 {
-   _threads_activated = EINA_FALSE; 
+   _threads_activated = EINA_FALSE;
 }
 
 #endif
@@ -1016,9 +1016,9 @@ eina_stringshare_add_length(const char *str, unsigned int slen)
      return (const char *)_eina_stringshare_single + ((*str) << 1);
    else if (slen < 4)
      {
-       LOCK_SMALL();
+       STRINGSHARE_LOCK_SMALL();
        const char *s = _eina_stringshare_small_add(str, slen);
-       UNLOCK_SMALL();
+       STRINGSHARE_UNLOCK_SMALL();
        return s;
      }
 
@@ -1026,32 +1026,32 @@ eina_stringshare_add_length(const char *str, unsigned int slen)
    hash_num = hash & 0xFF;
    hash = (hash >> 8) & EINA_STRINGSHARE_MASK;
 
-   LOCK_BIG();
+   STRINGSHARE_LOCK_BIG();
    p_bucket = share->buckets + hash_num;
 
    ed = _eina_stringshare_find_hash(*p_bucket, hash);
    if (!ed)
      {
        const char *s =  _eina_stringshare_add_head(p_bucket, hash, str, slen);
-       UNLOCK_BIG();
+       STRINGSHARE_UNLOCK_BIG();
        return s;
      }
 
-   EINA_MAGIC_CHECK_STRINGSHARE_HEAD(ed, UNLOCK_BIG(), NULL);
+   EINA_MAGIC_CHECK_STRINGSHARE_HEAD(ed, STRINGSHARE_UNLOCK_BIG(), NULL);
 
    el = _eina_stringshare_head_find(ed, str, slen);
    if (el)
      {
-       EINA_MAGIC_CHECK_STRINGSHARE_NODE(el, UNLOCK_BIG());
+       EINA_MAGIC_CHECK_STRINGSHARE_NODE(el, STRINGSHARE_UNLOCK_BIG());
        el->references++;
-       UNLOCK_BIG();
+       STRINGSHARE_UNLOCK_BIG();
        return el->str;
      }
 
    el = _eina_stringshare_node_alloc(slen);
    if (!el)
      {
-       UNLOCK_BIG();
+       STRINGSHARE_UNLOCK_BIG();
        return NULL;
      }
 
@@ -1060,7 +1060,7 @@ eina_stringshare_add_length(const char *str, unsigned int slen)
    ed->head = el;
    _eina_stringshare_population_head_add(ed);
 
-   UNLOCK_BIG();
+   STRINGSHARE_UNLOCK_BIG();
 
    return el->str;
 }
@@ -1150,19 +1150,19 @@ eina_stringshare_ref(const char *str)
      {
        _eina_stringshare_population_add(slen);
 
-       LOCK_SMALL();
+       STRINGSHARE_LOCK_SMALL();
        const char *s =  _eina_stringshare_small_add(str, slen);
-       UNLOCK_SMALL();
+       STRINGSHARE_UNLOCK_SMALL();
 
        return s;
      }
 
-   LOCK_BIG();
+   STRINGSHARE_LOCK_BIG();
    node = _eina_stringshare_node_from_str(str);
    node->references++;
    DBG("str=%p (%s) refs=%u", str, str, node->references);
 
-   UNLOCK_BIG();
+   STRINGSHARE_UNLOCK_BIG();
 
    _eina_stringshare_population_add(node->length);
 
@@ -1207,20 +1207,20 @@ eina_stringshare_del(const char *str)
      return;
    else if (slen < 4)
      {
-       LOCK_SMALL();
+       STRINGSHARE_LOCK_SMALL();
        _eina_stringshare_small_del(str, slen);
-       UNLOCK_SMALL();
+       STRINGSHARE_UNLOCK_SMALL();
        return;
      }
 
-   LOCK_BIG();
+   STRINGSHARE_LOCK_BIG();
 
    node = _eina_stringshare_node_from_str(str);
    if (node->references > 1)
      {
        node->references--;
        DBG("str=%p (%s) refs=%u", str, str, node->references);
-       UNLOCK_BIG();
+       STRINGSHARE_UNLOCK_BIG();
        return;
      }
 
@@ -1237,7 +1237,7 @@ eina_stringshare_del(const char *str)
    if (!ed)
      goto on_error;
 
-   EINA_MAGIC_CHECK_STRINGSHARE_HEAD(ed, UNLOCK_BIG());
+   EINA_MAGIC_CHECK_STRINGSHARE_HEAD(ed, STRINGSHARE_UNLOCK_BIG());
 
    if (!_eina_stringshare_head_remove_node(ed, node))
      goto on_error;
@@ -1250,12 +1250,12 @@ eina_stringshare_del(const char *str)
    else
      _eina_stringshare_population_head_del(ed);
 
-   UNLOCK_BIG();
+   STRINGSHARE_UNLOCK_BIG();
 
    return;
 
  on_error:
-   UNLOCK_BIG();
+   STRINGSHARE_UNLOCK_BIG();
    /* possible segfault happened before here, but... */
    CRITICAL("EEEK trying to del non-shared stringshare \"%s\"", str);
 }
@@ -1345,8 +1345,8 @@ eina_iterator_array_check(const Eina_Rbtree *rbtree __UNUSED__, Eina_Stringshare
 {
    Eina_Stringshare_Node *node;
 
-   LOCK_SMALL();
-   LOCK_BIG();
+   STRINGSHARE_LOCK_SMALL();
+   STRINGSHARE_LOCK_BIG();
 
    fdata->used += sizeof(Eina_Stringshare_Head);
    for (node = head->head; node; node = node->next)
@@ -1360,8 +1360,8 @@ eina_iterator_array_check(const Eina_Rbtree *rbtree __UNUSED__, Eina_Stringshare
        fdata->unique++;
      }
 
-   UNLOCK_BIG();
-   UNLOCK_SMALL();
+   STRINGSHARE_UNLOCK_BIG();
+   STRINGSHARE_UNLOCK_SMALL();
 
    return EINA_TRUE;
 }
@@ -1387,11 +1387,11 @@ eina_stringshare_dump(void)
    printf("DDD:   len   ref string\n");
    printf("DDD:-------------------\n");
 
-   LOCK_SMALL();
+   STRINGSHARE_LOCK_SMALL();
    _eina_stringshare_small_dump(&di);
-   UNLOCK_SMALL();
+   STRINGSHARE_UNLOCK_SMALL();
 
-   LOCK_BIG();
+   STRINGSHARE_LOCK_BIG();
    for (i = 0; i < EINA_STRINGSHARE_BUCKETS; i++)
      {
        if (!share->buckets[i]) continue;
@@ -1420,7 +1420,7 @@ eina_stringshare_dump(void)
      fprintf(stderr, "DDD: %i strings of length %i, max strings: %i\n", population_group[i].count, i, population_group[i].max);
 #endif
 
-   UNLOCK_BIG();
+   STRINGSHARE_UNLOCK_BIG();
 }
 
 /**