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).
This commit is contained in:
Ryan Lortie 2011-07-25 18:50:45 +02:00
parent 0584f0c504
commit c81eb121a1
11 changed files with 39 additions and 58 deletions

View 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 \

View 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>

View 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>

View 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 \

View File

@ -23,6 +23,7 @@
#include "config.h"
#include "glib.h"
#include <gioerror.h>
#include "gwakeup.h"
#include "gcancellable.h"
#include "glibintl.h"

View 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

View 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

View File

@ -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)
{

View File

@ -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

View 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

View 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);