[gnome-settings-daemon/wip/timerfd] build: Define HAVE_TIMERFD if we have timerfd_create



commit a093436ea0dc3df3c6e867f6a6435d460a33327d
Author: Iain Lane <iainl gnome org>
Date:   Tue Sep 18 08:23:30 2018 +0100

    build: Define HAVE_TIMERFD if we have timerfd_create
    
    If we have timerfd support we will use it to wake up at the appropriate
    time. There is a fallback non-timerfd path in which we wake up every
    second.
    
    The problem is that we had forgotten to ever check for timerfd support.
    Add a check to the build system which enables this if timerfd_create()
    exists.
    
    Closes: #77

 meson.build                           |  3 +++
 plugins/color/gnome-datetime-source.c | 12 ++++++------
 2 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/meson.build b/meson.build
index 2fd30cbd..e882d42c 100644
--- a/meson.build
+++ b/meson.build
@@ -125,6 +125,9 @@ if enable_gudev
 endif
 config_h.set('HAVE_GUDEV', enable_gudev)
 
+has_timerfd_create = cc.has_function('timerfd_create')
+config_h.set10('HAVE_TIMERFD', has_timerfd_create)
+
 # Check for libwayland-client
 enable_wayland = get_option('wayland')
 if enable_wayland
diff --git a/plugins/color/gnome-datetime-source.c b/plugins/color/gnome-datetime-source.c
index 633d7eeb..287ba2dd 100644
--- a/plugins/color/gnome-datetime-source.c
+++ b/plugins/color/gnome-datetime-source.c
@@ -26,7 +26,7 @@
 #define GNOME_DESKTOP_USE_UNSTABLE_API
 #include "gnome-datetime-source.h"
 
-#ifdef HAVE_TIMERFD
+#if HAVE_TIMERFD
 #include <sys/timerfd.h>
 #include <unistd.h>
 #include <string.h>
@@ -88,7 +88,7 @@ g_datetime_source_prepare (GSource *source,
        GDateTimeSource *datetime_source = (GDateTimeSource*)source;
        gint64 monotonic_now;
 
-#ifdef HAVE_TIMERFD
+#if HAVE_TIMERFD
        if (datetime_source->pollfd.fd != -1) {
                *timeout = -1;
                return datetime_source->initially_expired;  /* Should be TRUE at most one time, FALSE forever 
after */
@@ -114,7 +114,7 @@ g_datetime_source_check (GSource  *source)
 {
        GDateTimeSource *datetime_source = (GDateTimeSource*)source;
 
-#ifdef HAVE_TIMERFD
+#if HAVE_TIMERFD
        if (datetime_source->pollfd.fd != -1)
                return datetime_source->pollfd.revents != 0;
 #endif
@@ -151,7 +151,7 @@ g_datetime_source_dispatch (GSource    *source,
 static void
 g_datetime_source_finalize (GSource *source)
 {
-#ifdef HAVE_TIMERFD
+#if HAVE_TIMERFD
        GDateTimeSource *datetime_source = (GDateTimeSource*)source;
        if (datetime_source->pollfd.fd != -1)
                close (datetime_source->pollfd.fd);
@@ -165,7 +165,7 @@ static GSourceFuncs g_datetime_source_funcs = {
        g_datetime_source_finalize
 };
 
-#ifdef HAVE_TIMERFD
+#if HAVE_TIMERFD
 static gboolean
 g_datetime_source_init_timerfd (GDateTimeSource *datetime_source,
                                gint64           expected_now_seconds,
@@ -269,7 +269,7 @@ _gnome_datetime_source_new (GDateTime  *now,
 
        datetime_source->cancel_on_set = cancel_on_set;
 
-#ifdef HAVE_TIMERFD
+#if HAVE_TIMERFD
        {
                gint64 expected_now_seconds = g_date_time_to_unix (now);
                if (g_datetime_source_init_timerfd (datetime_source, expected_now_seconds, unix_seconds))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]