summaryrefslogtreecommitdiff
path: root/legacy/ecore/src/lib/ecore/ecore_main.c
diff options
context:
space:
mode:
authorMike McCormack <mj.mccormack@samsung.com>2011-07-06 10:54:20 +0000
committerMike McCormack <mikem@ring3k.org>2011-07-06 10:54:20 +0000
commit829571df274090d9c72bb13ba6d1da04429c4f99 (patch)
tree20c5af4f046293e15fdaad72cbb5158932859b5e /legacy/ecore/src/lib/ecore/ecore_main.c
parent0ddf5b9cabbdb0d43316217c7b1615067eb28515 (diff)
ecore: Remove most HAVE_TIMERFD_CREATE ifdefs
Introduce stub timerfd_create and timerfd_settime functions so ifdefs can be removed. Signed-off-by: Mike McCormack <mj.mccormack@samsung.com> SVN revision: 61080
Diffstat (limited to '')
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_main.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/legacy/ecore/src/lib/ecore/ecore_main.c b/legacy/ecore/src/lib/ecore/ecore_main.c
index 4bf77b4894..1f3216f902 100644
--- a/legacy/ecore/src/lib/ecore/ecore_main.c
+++ b/legacy/ecore/src/lib/ecore/ecore_main.c
@@ -65,7 +65,27 @@
65 65
66#ifdef HAVE_SYS_TIMERFD_H 66#ifdef HAVE_SYS_TIMERFD_H
67#include <sys/timerfd.h> 67#include <sys/timerfd.h>
68#else
69/* fallback code if we don't have real timerfd - reduces number of ifdefs */
70#ifndef CLOCK_MONOTONIC
71#define CLOCK_MONOTONIC 0 /* bogus value */
72#endif
73#ifndef TFD_NONBLOCK
74#define TFD_NONBLOCK 0 /* bogus value */
68#endif 75#endif
76static inline int
77timerfd_create(int clockid __UNUSED__, int flags __UNUSED__)
78{
79 return -1;
80}
81static inline int
82timerfd_settime(int fd __UNUSED__, int flags __UNUSED__,
83 const struct itimerspec *new_value __UNUSED__,
84 struct itimerspec *old_value __UNUSED__)
85{
86 return -1;
87}
88#endif /* HAVE_SYS_TIMERFD_H */
69 89
70#ifdef USE_G_MAIN_LOOP 90#ifdef USE_G_MAIN_LOOP
71# include <glib.h> 91# include <glib.h>
@@ -163,9 +183,7 @@ static double t1 = 0.0;
163static double t2 = 0.0; 183static double t2 = 0.0;
164#endif 184#endif
165 185
166#ifdef HAVE_TIMERFD_CREATE
167static int timer_fd = -1; 186static int timer_fd = -1;
168#endif
169#ifdef HAVE_EPOLL 187#ifdef HAVE_EPOLL
170static int epoll_fd = -1; 188static int epoll_fd = -1;
171static pid_t epoll_pid; 189static pid_t epoll_pid;
@@ -175,9 +193,7 @@ static pid_t epoll_pid;
175#ifdef HAVE_EPOLL 193#ifdef HAVE_EPOLL
176static GPollFD ecore_epoll_fd; 194static GPollFD ecore_epoll_fd;
177#endif 195#endif
178#ifdef HAVE_TIMERFD_CREATE
179static GPollFD ecore_timer_fd; 196static GPollFD ecore_timer_fd;
180#endif
181static GSource *ecore_glib_source; 197static GSource *ecore_glib_source;
182static guint ecore_glib_source_id; 198static guint ecore_glib_source_id;
183static GMainLoop* ecore_main_loop; 199static GMainLoop* ecore_main_loop;
@@ -476,7 +492,6 @@ _ecore_main_gsource_prepare(GSource *source __UNUSED__, gint *next_time)
476 { 492 {
477 int r = -1; 493 int r = -1;
478 double t = _ecore_timer_next_get(); 494 double t = _ecore_timer_next_get();
479#ifdef HAVE_TIMERFD_CREATE
480 if (timer_fd >= 0) 495 if (timer_fd >= 0)
481 { 496 {
482 struct itimerspec ts; 497 struct itimerspec ts;
@@ -502,7 +517,6 @@ _ecore_main_gsource_prepare(GSource *source __UNUSED__, gint *next_time)
502 ts.it_value.tv_nsec/1000); 517 ts.it_value.tv_nsec/1000);
503 } 518 }
504 } 519 }
505#endif
506 if (r == -1) 520 if (r == -1)
507 *next_time = ceil(t * 1000.0); 521 *next_time = ceil(t * 1000.0);
508 } 522 }
@@ -533,7 +547,6 @@ _ecore_main_gsource_check(GSource *source __UNUSED__)
533 /* check if old timers expired */ 547 /* check if old timers expired */
534 if (ecore_idling && !_ecore_idler_exist()) 548 if (ecore_idling && !_ecore_idler_exist())
535 { 549 {
536#ifdef HAVE_TIMERFD_CREATE
537 if (timer_fd >= 0) 550 if (timer_fd >= 0)
538 { 551 {
539 uint64_t count = 0; 552 uint64_t count = 0;
@@ -553,7 +566,6 @@ _ecore_main_gsource_check(GSource *source __UNUSED__)
553 timer_fd = -1; 566 timer_fd = -1;
554 } 567 }
555 } 568 }
556#endif
557 } 569 }
558 else 570 else
559 ret = TRUE; 571 ret = TRUE;
@@ -691,10 +703,9 @@ _ecore_main_loop_init(void)
691#endif 703#endif
692 704
693 /* timerfd gives us better than millisecond accuracy in g_main_loop */ 705 /* timerfd gives us better than millisecond accuracy in g_main_loop */
694#ifdef HAVE_TIMERFD_CREATE
695 timer_fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK); 706 timer_fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
696 if (timer_fd < 0) 707 if (timer_fd < 0)
697 ERR("failed to create timer fd!"); 708 WRN("failed to create timer fd!");
698 else 709 else
699 { 710 {
700 ecore_timer_fd.fd = timer_fd; 711 ecore_timer_fd.fd = timer_fd;
@@ -702,7 +713,6 @@ _ecore_main_loop_init(void)
702 ecore_timer_fd.revents = 0; 713 ecore_timer_fd.revents = 0;
703 g_source_add_poll(ecore_glib_source, &ecore_timer_fd); 714 g_source_add_poll(ecore_glib_source, &ecore_timer_fd);
704 } 715 }
705#endif
706 716
707 ecore_glib_source_id = g_source_attach(ecore_glib_source, NULL); 717 ecore_glib_source_id = g_source_attach(ecore_glib_source, NULL);
708 if (ecore_glib_source_id <= 0) 718 if (ecore_glib_source_id <= 0)
@@ -732,13 +742,11 @@ _ecore_main_loop_shutdown(void)
732 epoll_pid = 0; 742 epoll_pid = 0;
733#endif 743#endif
734 744
735#ifdef HAVE_TIMERFD_CREATE
736 if (timer_fd >= 0) 745 if (timer_fd >= 0)
737 { 746 {
738 close(timer_fd); 747 close(timer_fd);
739 timer_fd = -1; 748 timer_fd = -1;
740 } 749 }
741#endif
742} 750}
743 751
744/** 752/**