summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--NEWS1
-rw-r--r--src/lib/eina/eina_log.c52
3 files changed, 8 insertions, 48 deletions
diff --git a/ChangeLog b/ChangeLog
index 808f62d291..f700f93a73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
12013-10-11 Cedric Bail 12013-10-11 Cedric Bail
2 2
3 * Eina: add Eina_Spinlock API. 3 * Eina: add Eina_Spinlock API,
4 use Eina_Spinlock in Eina_Log.
4 5
52013-10-10 Carsten Haitzler (The Rasterman) 62013-10-10 Carsten Haitzler (The Rasterman)
6 7
diff --git a/NEWS b/NEWS
index 91d5bd126a..e49464b0cf 100644
--- a/NEWS
+++ b/NEWS
@@ -198,6 +198,7 @@ Improvements:
198 - Eina_Tiler now take tile size into account. 198 - Eina_Tiler now take tile size into account.
199 - Improve support for 64bits system. 199 - Improve support for 64bits system.
200 - eina_strlcat now work with a NULL source. 200 - eina_strlcat now work with a NULL source.
201 - Use Eina_Spinlock for eina_log.
201 * Eet: 202 * Eet:
202 - Display more information with eet -l -v. 203 - Display more information with eet -l -v.
203 - Force thread to always run during eet_cache_concurrency test. 204 - Force thread to always run during eet_cache_concurrency test.
diff --git a/src/lib/eina/eina_log.c b/src/lib/eina/eina_log.c
index 4829aadd2f..7459d926f7 100644
--- a/src/lib/eina/eina_log.c
+++ b/src/lib/eina/eina_log.c
@@ -143,53 +143,11 @@ static Eina_Thread _main_thread;
143 } \ 143 } \
144 } while (0) 144 } while (0)
145 145
146#ifdef EFL_HAVE_POSIX_THREADS_SPINLOCK 146static Eina_Spinlock _log_mutex;
147 147# define LOG_LOCK() if(_threads_enabled) {eina_spinlock_take(&_log_mutex); }
148static pthread_spinlock_t _log_lock; 148# define LOG_UNLOCK() if(_threads_enabled) {eina_spinlock_release(&_log_mutex); }
149 149# define INIT() eina_spinlock_new(&_log_mutex)
150static Eina_Bool _eina_log_spinlock_init(void) 150# define SHUTDOWN() eina_spinlock_free(&_log_mutex)
151{
152 if (pthread_spin_init(&_log_lock, PTHREAD_PROCESS_PRIVATE) == 0)
153 return EINA_TRUE;
154
155 fprintf(stderr,
156 "ERROR: pthread_spin_init(%p, PTHREAD_PROCESS_PRIVATE): %s\n",
157 &_log_lock, strerror(errno));
158 return EINA_FALSE;
159}
160
161# define LOG_LOCK() \
162 if (_threads_enabled) \
163 do { \
164 if (0) { \
165 fprintf(stderr, "+++LOG LOG_LOCKED! [%s, %lu]\n", \
166 __FUNCTION__, (unsigned long)eina_thread_self()); } \
167 if (EINA_UNLIKELY(_threads_enabled)) { \
168 pthread_spin_lock(&_log_lock); } \
169 } while (0)
170# define LOG_UNLOCK() \
171 if (_threads_enabled) \
172 do { \
173 if (EINA_UNLIKELY(_threads_enabled)) { \
174 pthread_spin_unlock(&_log_lock); } \
175 if (0) { \
176 fprintf(stderr, \
177 "---LOG LOG_UNLOCKED! [%s, %lu]\n", \
178 __FUNCTION__, (unsigned long)eina_thread_self()); } \
179 } while (0)
180# define INIT() _eina_log_spinlock_init()
181# define SHUTDOWN() pthread_spin_destroy(&_log_lock)
182
183#else /* ! EFL_HAVE_POSIX_THREADS_SPINLOCK */
184
185static Eina_Lock _log_mutex;
186# define LOG_LOCK() if(_threads_enabled) {eina_lock_take(&_log_mutex); }
187# define LOG_UNLOCK() if(_threads_enabled) {eina_lock_release(&_log_mutex); }
188# define INIT() eina_lock_new(&_log_mutex)
189# define SHUTDOWN() eina_lock_free(&_log_mutex)
190
191#endif /* ! EFL_HAVE_POSIX_THREADS_SPINLOCK */
192
193 151
194// List of domains registered 152// List of domains registered
195static Eina_Log_Domain *_log_domains = NULL; 153static Eina_Log_Domain *_log_domains = NULL;