Re: [PATCH 4/5] tests: create and use a template file for events

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

 



On 12/15/2015 02:15 PM, Frediano Ziglio wrote:
This template will be reused for main loop

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
  server/Makefile.am              |   1 +
  server/event_loop.tmpl.c        | 191 ++++++++++++++++++++++++++++++++++++++++
  server/tests/basic_event_loop.c | 157 +--------------------------------
  3 files changed, 196 insertions(+), 153 deletions(-)
  create mode 100644 server/event_loop.tmpl.c


diff --git a/server/event_loop.tmpl.c b/server/event_loop.tmpl.c
new file mode 100644
index 0000000..b85e6ee
--- /dev/null
+++ b/server/event_loop.tmpl.c

+#ifndef CORE_NAME
+#error  CORE_NAME must be defined!
+#endif
+
+#ifndef CORE_MAIN_CONTEXT
+#error  CORE_MAIN_CONTEXT must be defined!
+#endif
+
+#ifndef CORE_CHANNEL_EVENT
+#define CORE_CHANNEL_EVENT NULL
+#endif
+
+struct SpiceTimer {
+    SpiceTimerFunc func;
+    void *opaque;
+    GSource *source;
+};
+
+static SpiceTimer* CORE_NAME(timer_add)(SpiceTimerFunc func, void *opaque)
+{
+    SpiceTimer *timer = spice_malloc0(sizeof(SpiceTimer));
+
+    timer->func = func;
+    timer->opaque = opaque;
+
+    return timer;
+}
+
+static gboolean timer_func(gpointer user_data)

You probably want this to be CORE_NAME(timer_func), in case
this file is included more than once (with different CORE_NAMES).

If it is only used once, no template is needed, just use
a "regular" .c file and add it where appropriate in the Makefile.

Alternatively gather all those functions and put only them
in a separate .c file (possibly with an additional .h file).

That holds for other non CORE_NAME() structs/functions.

Regards,
    Uri.

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]