Remove alleged support for last-millennium Unixes
[platform/upstream/glib.git] / glib / gwakeup.c
index 76f9ece..2aec2f5 100644 (file)
 
 #include "config.h"
 
+
+/* gwakeup.c is special -- GIO and some test cases include it.  As such,
+ * it cannot include other glib headers without triggering the single
+ * includes warnings.  We have to manually include its dependencies here
+ * (and at all other use sites).
+ */
+#ifdef GLIB_COMPILATION
+#include "gtypes.h"
+#include "gpoll.h"
+#else
+#include <glib.h>
+#endif
+
 #include "gwakeup.h"
 
-/**
+/*< private >
  * SECTION:gwakeup
  * @title: GWakeup
  * @short_description: portable cross-thread event signal mechanism
 #ifdef _WIN32
 
 #include <windows.h>
+
+#ifdef GLIB_COMPILATION
 #include "gmessages.h"
 #include "giochannel.h"
 #include "gwin32.h"
+#endif
 
 GWakeup *
 g_wakeup_new (void)
@@ -128,7 +144,11 @@ g_wakeup_new (void)
 
   /* try eventfd first, if we think we can */
 #if defined (HAVE_EVENTFD)
+#ifndef TEST_EVENTFD_FALLBACK
   wakeup->fds[0] = eventfd (0, EFD_CLOEXEC | EFD_NONBLOCK);
+#else
+  wakeup->fds[0] = -1;
+#endif
 
   if (wakeup->fds[0] != -1)
     {
@@ -202,17 +222,28 @@ g_wakeup_acknowledge (GWakeup *wakeup)
  * g_wakeup_get_pollfd() will immediately succeed until such a time as
  * g_wakeup_acknowledge() is called.
  *
+ * This function is safe to call from a UNIX signal handler.
+ *
  * Since: 2.30
  **/
 void
 g_wakeup_signal (GWakeup *wakeup)
 {
   guint64 one = 1;
+  int res;
 
   if (wakeup->fds[1] == -1)
-    write (wakeup->fds[0], &one, sizeof one);
+    {
+      do
+        res = write (wakeup->fds[0], &one, sizeof one);
+      while (G_UNLIKELY (res == -1 && errno == EINTR));
+    }
   else
-    write (wakeup->fds[1], &one, 1);
+    {
+      do
+        res = write (wakeup->fds[1], &one, 1);
+      while (G_UNLIKELY (res == -1 && errno == EINTR));
+    }
 }
 
 /**