[glib] gmessages.c: Fix build on non-Linux



commit 6d6b97aa59c3b97e4e584618ea23c04205e35811
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Jul 26 12:32:42 2016 +0800

    gmessages.c: Fix build on non-Linux
    
    journald is a part of systemd which is Linux-only at this time, so only
    compile the journald items on Linux only, and just return FALSE for
    g_log_writer_is_journald() and G_LOG_WRITER_UNHANDLED for
    g_log_writer_journald() on non-Linux.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=744456

 glib/gmessages.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/glib/gmessages.c b/glib/gmessages.c
index 6b431ab..b77bcde 100644
--- a/glib/gmessages.c
+++ b/glib/gmessages.c
@@ -101,11 +101,14 @@
 #include <signal.h>
 #include <locale.h>
 #include <errno.h>
+
+#ifdef __linux__
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <fcntl.h>
 #include <sys/uio.h>
+#endif
 
 #include "glib-init.h"
 #include "galloca.h"
@@ -1618,6 +1621,7 @@ g_log_writer_supports_color (gint output_fd)
   return isatty (output_fd);
 }
 
+#ifdef __linux__
 static int journal_fd = -1;
 
 #ifndef SOCK_CLOEXEC
@@ -1640,6 +1644,7 @@ open_journal (void)
     }
 #endif
 }
+#endif
 
 /**
  * g_log_writer_is_journald:
@@ -1655,6 +1660,7 @@ open_journal (void)
 gboolean
 g_log_writer_is_journald (gint output_fd)
 {
+#ifdef __linux__
   /* FIXME: Use the new journal API for detecting whether we’re writing to the
    * journal. See: https://github.com/systemd/systemd/issues/2473
    */
@@ -1679,6 +1685,9 @@ g_log_writer_is_journald (gint output_fd)
     }
 
   return fd_is_journal;
+#else
+  return FALSE;
+#endif
 }
 
 static void escape_string (GString *string);
@@ -1789,6 +1798,7 @@ g_log_writer_format_fields (GLogLevelFlags   log_level,
   return g_string_free (gstring, FALSE);
 }
 
+#ifdef __linux__
 static int
 journal_sendv (struct iovec *iov,
                gsize         iovlen)
@@ -1869,6 +1879,7 @@ retry2:
 
   return -1;
 }
+#endif
 
 /**
  * g_log_writer_journald:
@@ -1898,6 +1909,7 @@ g_log_writer_journald (GLogLevelFlags   log_level,
                        gsize            n_fields,
                        gpointer         user_data)
 {
+#ifdef __linux__
   const char equals = '=';
   const char newline = '\n';
   gsize i, k;
@@ -1975,6 +1987,9 @@ g_log_writer_journald (GLogLevelFlags   log_level,
   retval = journal_sendv (iov, v - iov);
 
   return retval == 0 ? G_LOG_WRITER_HANDLED : G_LOG_WRITER_UNHANDLED;
+#else
+  return G_LOG_WRITER_UNHANDLED;
+#endif
 }
 
 /**


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