From 2126a03a8f70b5f3748d8d954d38aa1955f068b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 9 Jan 2012 13:06:37 +0100 Subject: [PATCH spice-gtk] Hide g_condition_wait_source, use GLib style convention https://bugs.freedesktop.org/show_bug.cgi?id=44570 --- gtk/gio-coroutine.c | 20 ++++++++++++++------ gtk/gio-coroutine.h | 12 ++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gtk/gio-coroutine.c b/gtk/gio-coroutine.c index 7470b43..5c9621d 100644 --- a/gtk/gio-coroutine.c +++ b/gtk/gio-coroutine.c @@ -21,6 +21,14 @@ #include "gio-coroutine.h" +typedef struct _GConditionWaitSource +{ + GSource src; + struct coroutine *co; + GConditionWaitFunc func; + gpointer data; +} GConditionWaitSource; + /* Main loop helper functions */ static gboolean g_io_wait_helper(GSocket *sock G_GNUC_UNUSED, GIOCondition cond, @@ -87,7 +95,7 @@ void g_io_wakeup(struct wait_queue *wait) */ static gboolean g_condition_wait_prepare(GSource *src, int *timeout) { - struct g_condition_wait_source *vsrc = (struct g_condition_wait_source *)src; + GConditionWaitSource *vsrc = (GConditionWaitSource *)src; *timeout = -1; return vsrc->func(vsrc->data); } @@ -98,7 +106,7 @@ static gboolean g_condition_wait_prepare(GSource *src, */ static gboolean g_condition_wait_check(GSource *src) { - struct g_condition_wait_source *vsrc = (struct g_condition_wait_source *)src; + GConditionWaitSource *vsrc = (GConditionWaitSource *)src; return vsrc->func(vsrc->data); } @@ -121,10 +129,10 @@ static gboolean g_condition_wait_helper(gpointer data) return FALSE; } -gboolean g_condition_wait(g_condition_wait_func func, gpointer data) +gboolean g_condition_wait(GConditionWaitFunc func, gpointer data) { GSource *src; - struct g_condition_wait_source *vsrc; + GConditionWaitSource *vsrc; /* Short-circuit check in case we've got it ahead of time */ if (func(data)) { @@ -135,8 +143,8 @@ gboolean g_condition_wait(g_condition_wait_func func, gpointer data) * Don't have it, so yield to the main loop, checking the condition * on each iteration of the main loop */ - src = g_source_new(&waitFuncs, sizeof(struct g_condition_wait_source)); - vsrc = (struct g_condition_wait_source *)src; + src = g_source_new(&waitFuncs, sizeof(GConditionWaitSource)); + vsrc = (GConditionWaitSource *)src; vsrc->func = func; vsrc->data = data; diff --git a/gtk/gio-coroutine.h b/gtk/gio-coroutine.h index 56a87e1..26e447e 100644 --- a/gtk/gio-coroutine.h +++ b/gtk/gio-coroutine.h @@ -41,20 +41,12 @@ struct wait_queue * to busy wait on a timeout, since our condition is only checked * when some other source's state changes */ -typedef gboolean (*g_condition_wait_func)(gpointer); - -struct g_condition_wait_source -{ - GSource src; - struct coroutine *co; - g_condition_wait_func func; - gpointer data; -}; +typedef gboolean (*GConditionWaitFunc)(gpointer); typedef void (*GSignalEmitMainFunc)(GObject *object, int signum, gpointer params); GIOCondition g_io_wait (GSocket *sock, GIOCondition cond); -gboolean g_condition_wait (g_condition_wait_func func, gpointer data); +gboolean g_condition_wait (GConditionWaitFunc func, gpointer data); void g_io_wakeup (struct wait_queue *wait); GIOCondition g_io_wait_interruptible(struct wait_queue *wait, GSocket *sock, GIOCondition cond); void g_signal_emit_main_context(GObject *object, GSignalEmitMainFunc func, -- 1.7.7.5