#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)
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();
}
/**
EINA_SAFETY_ON_NULL_RETURN_VAL(name, -1);
- LOCK();
+ LOG_LOCK();
r = eina_log_domain_register_unlocked(name, color);
- UNLOCK();
+ LOG_UNLOCK();
return r;
}
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();
}
/**
}
#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);
}
return;
}
#endif
- LOCK();
+ LOG_LOCK();
eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args);
- UNLOCK();
+ LOG_UNLOCK();
}
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
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)
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
{
unsigned int i;
- LOCK_SMALL();
- LOCK_BIG();
+ STRINGSHARE_LOCK_SMALL();
+ STRINGSHARE_LOCK_BIG();
_eina_stringshare_population_stats();
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;
*
* @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()
void
eina_stringshare_threads_shutdown(void)
{
- _threads_activated = EINA_FALSE;
+ _threads_activated = EINA_FALSE;
}
#endif
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;
}
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;
}
ed->head = el;
_eina_stringshare_population_head_add(ed);
- UNLOCK_BIG();
+ STRINGSHARE_UNLOCK_BIG();
return el->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);
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;
}
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;
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);
}
{
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)
fdata->unique++;
}
- UNLOCK_BIG();
- UNLOCK_SMALL();
+ STRINGSHARE_UNLOCK_BIG();
+ STRINGSHARE_UNLOCK_SMALL();
return EINA_TRUE;
}
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;
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();
}
/**