summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--src/lib/eina/eina_debug_bt.c20
-rw-r--r--src/lib/eina/eina_debug_timer.c2
3 files changed, 23 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index a324018..de1ffef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -683,6 +683,8 @@ geteuid \
683getuid \ 683getuid \
684pause \ 684pause \
685gmtime_r \ 685gmtime_r \
686pthread_getcpuclockid \
687clock_gettime \
686]) 688])
687 689
688AC_FUNC_ALLOCA 690AC_FUNC_ALLOCA
diff --git a/src/lib/eina/eina_debug_bt.c b/src/lib/eina/eina_debug_bt.c
index a98b852..e8c01c1 100644
--- a/src/lib/eina/eina_debug_bt.c
+++ b/src/lib/eina/eina_debug_bt.c
@@ -153,15 +153,35 @@ _signal_handler(int sig EINA_UNUSED,
153 eina_semaphore_release(&_wait_for_bts_sem, 1); 153 eina_semaphore_release(&_wait_for_bts_sem, 1);
154 return; 154 return;
155found: 155found:
156 /*
157 * Below is very non-portable code!
158 *
159 * - clock_gettime() is not implemented on macOS < 10.12
160 * - sched_getcpu() is not implemented on macOS
161 * - pthread_getcpuclockid() is not implemented on macOS
162 * - CLOCK_THREAD_CPUTIME_ID should be identical to pthread_getcpuclockid(),
163 * but it requires POSIX thingies to be defined.
164 */
165#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_SCHED_GETCPU)
156 // store thread info like what cpu core we are on now (not reliable 166 // store thread info like what cpu core we are on now (not reliable
157 // but hey - better than nothing), the amount of cpu time total 167 // but hey - better than nothing), the amount of cpu time total
158 // we have consumed (it's cumulative so subtracing deltas can give 168 // we have consumed (it's cumulative so subtracing deltas can give
159 // you an average amount of cpu time consumed between now and the 169 // you an average amount of cpu time consumed between now and the
160 // previous time we looked) and also a full backtrace 170 // previous time we looked) and also a full backtrace
161 _bt_cpu[slot] = sched_getcpu(); 171 _bt_cpu[slot] = sched_getcpu();
172# ifdef HAVE_PTHREAD_GETCPUCLOCKID
173 /* Try pthread_getcpuclockid() first */
162 pthread_getcpuclockid(self, &cid); 174 pthread_getcpuclockid(self, &cid);
175# elif defined(_POSIX_THREAD_CPUTIME)
176 /* Fallback to POSIX clock id. */
177 cid = CLOCK_THREAD_CPUTIME_ID;
178# else
179 /* Boom, we lost */
180# error Cannot determine the clock id for clock_gettime()
181# endif
163 clock_gettime(cid, &(_bt_ts[slot])); 182 clock_gettime(cid, &(_bt_ts[slot]));
164 _bt_buf_len[slot] = _eina_debug_unwind_bt(_bt_buf[slot], EINA_MAX_BT); 183 _bt_buf_len[slot] = _eina_debug_unwind_bt(_bt_buf[slot], EINA_MAX_BT);
184#endif /* HAVE_CLOCK_GETTIME && HAVE_SCHED_GETCPU */
165 // now wake up the monitor to let them know we are done collecting our 185 // now wake up the monitor to let them know we are done collecting our
166 // backtrace info 186 // backtrace info
167 eina_semaphore_release(&_wait_for_bts_sem, 1); 187 eina_semaphore_release(&_wait_for_bts_sem, 1);
diff --git a/src/lib/eina/eina_debug_timer.c b/src/lib/eina/eina_debug_timer.c
index ece2db6..fa3fd1a 100644
--- a/src/lib/eina/eina_debug_timer.c
+++ b/src/lib/eina/eina_debug_timer.c
@@ -84,7 +84,7 @@ end:
84static void * 84static void *
85_monitor(void *_data EINA_UNUSED) 85_monitor(void *_data EINA_UNUSED)
86{ 86{
87#ifndef _WIN32 87#ifdef HAVE_SYS_EPOLL_H
88#define MAX_EVENTS 4 88#define MAX_EVENTS 4
89 struct epoll_event event; 89 struct epoll_event event;
90 struct epoll_event events[MAX_EVENTS]; 90 struct epoll_event events[MAX_EVENTS];