aboutsummaryrefslogtreecommitdiff
path: root/include/glib-compat.h
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2017-02-07 18:00:49 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2017-03-01 00:09:28 +0400
commit461a86202214c9c3daf3222a9a655206874bd970 (patch)
tree0c53362396ac403fa7ffa22cdd99124ba9a6abf4 /include/glib-compat.h
parente703dcbaeef6973e788a9a8d19e53094b50c0a7c (diff)
glib-compat: add g_test_add_data_func_full fallback
Move the fallback from qtest_add_data_func_full() to glib-compat. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'include/glib-compat.h')
-rw-r--r--include/glib-compat.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/glib-compat.h b/include/glib-compat.h
index 0cd24ffbe9..863c8cf73d 100644
--- a/include/glib-compat.h
+++ b/include/glib-compat.h
@@ -328,4 +328,25 @@ static inline void g_source_set_name_by_id(guint tag, const char *name)
#define g_test_subprocess() (0)
#endif
+
+#if !GLIB_CHECK_VERSION(2, 34, 0)
+static inline void
+g_test_add_data_func_full(const char *path,
+ gpointer data,
+ gpointer fn,
+ gpointer data_free_func)
+{
+#if GLIB_CHECK_VERSION(2, 26, 0)
+ /* back-compat casts, remove this once we can require new-enough glib */
+ g_test_add_vtable(path, 0, data, NULL,
+ (GTestFixtureFunc)fn, (GTestFixtureFunc) data_free_func);
+#else
+ /* back-compat casts, remove this once we can require new-enough glib */
+ g_test_add_vtable(path, 0, data, NULL,
+ (void (*)(void)) fn, (void (*)(void)) data_free_func);
+#endif
+}
+#endif
+
+
#endif