[glib/gwakeup] GWakeup: make it private API



commit c81eb121a1a29c7068b775d0f7665d05c0dd4dad
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Jul 25 18:50:45 2011 +0200

    GWakeup: make it private API
    
    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            |    3 ++
 docs/reference/glib/glib-docs.sgml         |    1 -
 docs/reference/glib/glib-sections.txt      |   10 ------
 gio/Makefile.am                            |    1 +
 gio/gcancellable.c                         |    1 +
 glib/Makefile.am                           |    2 +-
 glib/glib.h                                |    1 -
 glib/gwakeup.c                             |   17 +++++++++++
 glib/gwakeup.h                             |   15 ++++------
 gthread/tests/Makefile.am                  |    3 +-
 gthread/tests/{gwakeup.c => gwakeuptest.c} |   43 +++++----------------------
 11 files changed, 39 insertions(+), 58 deletions(-)
---
diff --git a/docs/reference/glib/Makefile.am b/docs/reference/glib/Makefile.am
index 472126b..e990b98 100644
--- a/docs/reference/glib/Makefile.am
+++ b/docs/reference/glib/Makefile.am
@@ -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		\
diff --git a/docs/reference/glib/glib-docs.sgml b/docs/reference/glib/glib-docs.sgml
index fb63b05..208c49b 100644
--- a/docs/reference/glib/glib-docs.sgml
+++ b/docs/reference/glib/glib-docs.sgml
@@ -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>
 
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 8db7eb0..853c793 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -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>
diff --git a/gio/Makefile.am b/gio/Makefile.am
index 77b1a84..148f4c5 100644
--- a/gio/Makefile.am
+++ b/gio/Makefile.am
@@ -286,6 +286,7 @@ libgio_2_0_la_SOURCES =		\
 	gasyncresult.c 		\
 	gbufferedinputstream.c 	\
 	gbufferedoutputstream.c \
+	../glib/gwakeup.c	\
 	gcancellable.c 		\
 	gcontenttype.c 		\
 	gcontenttypeprivate.h 	\
diff --git a/gio/gcancellable.c b/gio/gcancellable.c
index 30bb0e9..1c3c5b5 100644
--- a/gio/gcancellable.c
+++ b/gio/gcancellable.c
@@ -23,6 +23,7 @@
 #include "config.h"
 #include "glib.h"
 #include <gioerror.h>
+#include "gwakeup.h"
 #include "gcancellable.h"
 #include "glibintl.h"
 
diff --git a/glib/Makefile.am b/glib/Makefile.am
index b4eaefe..3823caf 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -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
 
diff --git a/glib/glib.h b/glib/glib.h
index d2ce71d..06d0190 100644
--- a/glib/glib.h
+++ b/glib/glib.h
@@ -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
diff --git a/glib/gwakeup.c b/glib/gwakeup.c
index 29a0fca..a65c2d0 100644
--- a/glib/gwakeup.c
+++ b/glib/gwakeup.c
@@ -21,6 +21,19 @@
 
 #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)
     {
diff --git a/glib/gwakeup.h b/glib/gwakeup.h
index 5cc587f..51f81ce 100644
--- a/glib/gwakeup.h
+++ b/glib/gwakeup.h
@@ -22,17 +22,14 @@
 #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
diff --git a/gthread/tests/Makefile.am b/gthread/tests/Makefile.am
index cc60d0f..121ac53 100644
--- a/gthread/tests/Makefile.am
+++ b/gthread/tests/Makefile.am
@@ -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
diff --git a/gthread/tests/gwakeup.c b/gthread/tests/gwakeuptest.c
similarity index 86%
rename from gthread/tests/gwakeup.c
rename to gthread/tests/gwakeuptest.c
index f1545d8..4b11f17 100644
--- a/gthread/tests/gwakeup.c
+++ b/gthread/tests/gwakeuptest.c
@@ -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);
 



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