From a8df5600b2936e6caee0d9b80e5ff6c927d6539e Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Thu, 7 Jul 2011 11:13:32 +0900 Subject: [PATCH] ecore: Remove most HAVE_TIMERFD_CREATE ifdefs Introduce stub timerfd_create and timerfd_settime functions so ifdefs can be removed. svn@61080 --- src/lib/ecore/ecore_main.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/lib/ecore/ecore_main.c b/src/lib/ecore/ecore_main.c index 8ff89e2..feedd50 100644 --- a/src/lib/ecore/ecore_main.c +++ b/src/lib/ecore/ecore_main.c @@ -65,7 +65,27 @@ #ifdef HAVE_SYS_TIMERFD_H #include +#else +/* fallback code if we don't have real timerfd - reduces number of ifdefs */ +#ifndef CLOCK_MONOTONIC +#define CLOCK_MONOTONIC 0 /* bogus value */ +#endif +#ifndef TFD_NONBLOCK +#define TFD_NONBLOCK 0 /* bogus value */ #endif +static inline int +timerfd_create(int clockid __UNUSED__, int flags __UNUSED__) +{ + return -1; +} +static inline int +timerfd_settime(int fd __UNUSED__, int flags __UNUSED__, + const struct itimerspec *new_value __UNUSED__, + struct itimerspec *old_value __UNUSED__) +{ + return -1; +} +#endif /* HAVE_SYS_TIMERFD_H */ #ifdef USE_G_MAIN_LOOP # include @@ -163,9 +183,7 @@ static double t1 = 0.0; static double t2 = 0.0; #endif -#ifdef HAVE_TIMERFD_CREATE static int timer_fd = -1; -#endif #ifdef HAVE_EPOLL static int epoll_fd = -1; static pid_t epoll_pid; @@ -175,9 +193,7 @@ static pid_t epoll_pid; #ifdef HAVE_EPOLL static GPollFD ecore_epoll_fd; #endif -#ifdef HAVE_TIMERFD_CREATE static GPollFD ecore_timer_fd; -#endif static GSource *ecore_glib_source; static guint ecore_glib_source_id; static GMainLoop* ecore_main_loop; @@ -472,7 +488,6 @@ _ecore_main_gsource_prepare(GSource *source __UNUSED__, gint *next_time) { int r = -1; double t = _ecore_timer_next_get(); -#ifdef HAVE_TIMERFD_CREATE if (timer_fd >= 0) { struct itimerspec ts; @@ -498,7 +513,6 @@ _ecore_main_gsource_prepare(GSource *source __UNUSED__, gint *next_time) ts.it_value.tv_nsec/1000); } } -#endif if (r == -1) *next_time = ceil(t * 1000.0); } @@ -529,7 +543,6 @@ _ecore_main_gsource_check(GSource *source __UNUSED__) /* check if old timers expired */ if (ecore_idling && !_ecore_idler_exist()) { -#ifdef HAVE_TIMERFD_CREATE if (timer_fd >= 0) { uint64_t count = 0; @@ -549,7 +562,6 @@ _ecore_main_gsource_check(GSource *source __UNUSED__) timer_fd = -1; } } -#endif } else ret = TRUE; @@ -695,10 +707,9 @@ _ecore_main_loop_init(void) #endif /* timerfd gives us better than millisecond accuracy in g_main_loop */ -#ifdef HAVE_TIMERFD_CREATE timer_fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK); if (timer_fd < 0) - ERR("failed to create timer fd!"); + WRN("failed to create timer fd!"); else { ecore_timer_fd.fd = timer_fd; @@ -706,7 +717,6 @@ _ecore_main_loop_init(void) ecore_timer_fd.revents = 0; g_source_add_poll(ecore_glib_source, &ecore_timer_fd); } -#endif ecore_glib_source_id = g_source_attach(ecore_glib_source, NULL); if (ecore_glib_source_id <= 0) @@ -737,13 +747,11 @@ _ecore_main_loop_shutdown(void) epoll_pid = 0; #endif -#ifdef HAVE_TIMERFD_CREATE if (timer_fd >= 0) { close(timer_fd); timer_fd = -1; } -#endif } /** -- 2.7.4