GWakeup: make it private API
authorRyan Lortie <desrt@desrt.ca>
Mon, 25 Jul 2011 16:50:45 +0000 (18:50 +0200)
committerRyan Lortie <desrt@desrt.ca>
Mon, 25 Jul 2011 16:51:03 +0000 (18:51 +0200)
Colin requests that we keep this one private for now.

Include it at each point of use (libglib, libgio, tests).

docs/reference/glib/Makefile.am
docs/reference/glib/glib-docs.sgml
docs/reference/glib/glib-sections.txt
gio/Makefile.am
gio/gcancellable.c
glib/Makefile.am
glib/glib.h
glib/gwakeup.c
glib/gwakeup.h
gthread/tests/Makefile.am
gthread/tests/gwakeuptest.c [moved from gthread/tests/gwakeup.c with 86% similarity]

index 472126b..e990b98 100644 (file)
@@ -22,6 +22,9 @@ MKDB_OPTIONS=--sgml-mode --output-format=xml --name-space=g
 HFILE_GLOB=$(addprefix $(top_srcdir)/glib/,$(shell cat $(top_builddir)/glib/glib-public-headers.txt)) $(top_srcdir)/gmodule/*.h
 CFILE_GLOB=$(top_srcdir)/glib/*.c $(top_srcdir)/gmodule/*.c
 
+# Ignore some private headers
+IGNORE_HFILES = gwakeup.h
+
 # Images to copy into HTML directory
 HTML_IMAGES =                                  \
        file-name-encodings.png         \
index fb63b05..208c49b 100644 (file)
@@ -97,7 +97,6 @@ synchronize their operation.
       <xi:include href="xml/bookmarkfile.xml" />
       <xi:include href="xml/testing.xml" />
       <xi:include href="xml/gunix.xml" />
-      <xi:include href="xml/gwakeup.xml" />
       <xi:include href="xml/windows.xml" />
   </chapter>
 
index 8db7eb0..853c793 100644 (file)
@@ -3147,13 +3147,3 @@ g_hostname_is_ascii_encoded
 <SUBSECTION>
 g_hostname_is_ip_address
 </SECTION>
-
-<SECTION>
-<FILE>gwakeup</FILE>
-<TITLE>GWakeup</TITLE>
-g_wakeup_new
-g_wakeup_get_pollfd
-g_wakeup_signal
-g_wakeup_acknowledge
-g_wakeup_free
-</SECTION>
index 77b1a84..148f4c5 100644 (file)
@@ -286,6 +286,7 @@ libgio_2_0_la_SOURCES =             \
        gasyncresult.c          \
        gbufferedinputstream.c  \
        gbufferedoutputstream.c \
+       ../glib/gwakeup.c       \
        gcancellable.c          \
        gcontenttype.c          \
        gcontenttypeprivate.h   \
index 30bb0e9..1c3c5b5 100644 (file)
@@ -23,6 +23,7 @@
 #include "config.h"
 #include "glib.h"
 #include <gioerror.h>
+#include "gwakeup.h"
 #include "gcancellable.h"
 #include "glibintl.h"
 
index b4eaefe..3823caf 100644 (file)
@@ -198,6 +198,7 @@ libglib_2_0_la_SOURCES =    \
        gvarianttypeinfo.h      \
        gvarianttypeinfo.c      \
        gvarianttype.c          \
+       gwakeup.h               \
        gwakeup.c               \
        gdebug.h                \
        gprintf.c               \
@@ -287,7 +288,6 @@ glibsubinclude_HEADERS =   \
        gutils.h        \
        gvarianttype.h  \
        gvariant.h      \
-       gwakeup.h       \
        gwin32.h        \
        gprintf.h
 
index d2ce71d..06d0190 100644 (file)
@@ -90,7 +90,6 @@
 #include <glib/gutils.h>
 #include <glib/gvarianttype.h>
 #include <glib/gvariant.h>
-#include <glib/gwakeup.h>
 #ifdef G_PLATFORM_WIN32
 #include <glib/gwin32.h>
 #endif
index 29a0fca..a65c2d0 100644 (file)
 
 #include "config.h"
 
+
+/* gwakeup.h 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"
 
 /**
@@ -128,7 +141,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)
     {
index 5cc587f..51f81ce 100644 (file)
 #ifndef __G_WAKEUP_H__
 #define __G_WAKEUP_H__
 
-#include <glib/gtypes.h>
-#include <glib/gpoll.h>
-
 typedef struct _GWakeup GWakeup;
 
-GWakeup *       g_wakeup_new            (void);
-void            g_wakeup_free           (GWakeup *wakeup);
+G_GNUC_INTERNAL GWakeup *       g_wakeup_new            (void);
+G_GNUC_INTERNAL void            g_wakeup_free           (GWakeup *wakeup);
 
-void            g_wakeup_get_pollfd     (GWakeup *wakeup,
-                                         GPollFD *poll_fd);
-void            g_wakeup_signal         (GWakeup *wakeup);
-void            g_wakeup_acknowledge    (GWakeup *wakeup);
+G_GNUC_INTERNAL void            g_wakeup_get_pollfd     (GWakeup *wakeup,
+                                                         GPollFD *poll_fd);
+G_GNUC_INTERNAL void            g_wakeup_signal         (GWakeup *wakeup);
+G_GNUC_INTERNAL void            g_wakeup_acknowledge    (GWakeup *wakeup);
 
 #endif
index cc60d0f..121ac53 100644 (file)
@@ -45,11 +45,12 @@ spawn_singlethread_SOURCES = spawn-singlethread.c
 spawn_singlethread_LDADD    = $(progs_ldadd) $(top_builddir)/gthread/libgthread-2.0.la
 
 TEST_PROGS += gwakeup
+gwakeup_SOURCES = gwakeuptest.c ../../glib/gwakeup.c
 gwakeup_LDADD    = $(progs_ldadd) $(top_builddir)/gthread/libgthread-2.0.la
 
 if HAVE_EVENTFD
 TEST_PROGS += gwakeup-fallback
-gwakeup_fallback_SOURCES = gwakeup.c
+gwakeup_fallback_SOURCES = gwakeuptest.c ../../glib/gwakeup.c
 gwakeup_fallback_CFLAGS = $(AM_CFLAGS) -DTEST_EVENTFD_FALLBACK
 gwakeup_fallback_LDADD    = $(progs_ldadd) $(top_builddir)/gthread/libgthread-2.0.la
 endif
similarity index 86%
rename from gthread/tests/gwakeup.c
rename to gthread/tests/gwakeuptest.c
index f1545d8..4b11f17 100644 (file)
@@ -1,31 +1,6 @@
 #include <unistd.h>
 #include <glib.h>
-
-#ifdef TEST_EVENTFD_FALLBACK
-  #include <errno.h>
-
-  static gboolean we_broke_eventfd;
-
-  /* We interpose over the eventfd() call in the libc to ensure that a
-   * failed call to eventfd() gives us a working fallback.
-   *
-   * We need to do this because older kernel versions don't have eventfd
-   * support, and some of them have eventfd but without support for some
-   * of the flags we use.
-   *
-   * We use the we_broke_eventfd boolean to make sure that it actually
-   * worked.
-   */
-  int eventfd (void) {
-    we_broke_eventfd = TRUE;
-    errno = EINVAL;
-
-    return -1;
-  }
-  #define TESTNAME_SUFFIX "-fallback"
-#else
-  #define TESTNAME_SUFFIX ""
-#endif
+#include <glib/gwakeup.h>
 
 #ifdef _WIN32
 void alarm (int sec) { }
@@ -58,18 +33,9 @@ test_semantics (void)
   /* prevent the test from deadlocking */
   alarm (30);
 
-#ifdef TEST_EVENTFD_FALLBACK
-  we_broke_eventfd = FALSE;
-#endif
-
   wakeup = g_wakeup_new ();
   g_assert (!check_signaled (wakeup));
 
-#ifdef TEST_EVENTFD_FALLBACK
-  /* make sure our interposed eventfd call worked */
-  g_assert (we_broke_eventfd);
-#endif
-
   g_wakeup_signal (wakeup);
   g_assert (check_signaled (wakeup));
 
@@ -296,6 +262,13 @@ main (int argc, char **argv)
 
   g_test_init (&argc, &argv, NULL);
 
+#ifdef TEST_EVENTFD_FALLBACK
+#define TESTNAME_SUFFIX "-fallback"
+#else
+#define TESTNAME_SUFFIX
+#endif
+
+
   g_test_add_func ("/gwakeup/semantics" TESTNAME_SUFFIX, test_semantics);
   g_test_add_func ("/gwakeup/threaded" TESTNAME_SUFFIX, test_threaded);