diff options
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | test/internals/refs.c | 78 |
2 files changed, 38 insertions, 42 deletions
diff --git a/configure.ac b/configure.ac index 243cbbcd..3ca922b8 100644 --- a/configure.ac +++ b/configure.ac @@ -192,7 +192,7 @@ fi # default (unless you don't have GLib), because they don't bloat the library # or binaries. if test "x$enable_modular_tests" != xno; then - PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.22, gio-2.0 >= 2.22], + PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.24, gio-2.0 >= 2.24], [], [if test "x$enable_modular_tests" = xyes; then AC_MSG_NOTICE([Full test coverage (--enable-modular-tests=yes or --enable-tests=yes) requires GLib]) diff --git a/test/internals/refs.c b/test/internals/refs.c index bc0884e3..db43a4da 100644 --- a/test/internals/refs.c +++ b/test/internals/refs.c @@ -27,6 +27,7 @@ #include <config.h> #include <glib.h> +#include <glib-object.h> #define DBUS_COMPILATION /* this test uses libdbus-internal */ #include <dbus/dbus.h> @@ -77,6 +78,11 @@ typedef struct { VoidFunc unlock; } Thread; +/* provide backwards compatibility shim when building with a glib <= 2.30.x */ +#if !GLIB_CHECK_VERSION(2,31,0) +#define g_thread_new(name,func,data) g_thread_create(func,data,TRUE,NULL) +#endif + static gpointer ref_thread (gpointer data) { @@ -276,10 +282,9 @@ test_connection (Fixture *f, for (i = 0; i < N_THREADS; i++) { if ((i % 2) == 0) - f->threads[i] = g_thread_create (ref_thread, &public_api, TRUE, NULL); + f->threads[i] = g_thread_new (NULL, ref_thread, &public_api); else - f->threads[i] = g_thread_create (ref_thread, &internal_api, TRUE, - NULL); + f->threads[i] = g_thread_new (NULL, ref_thread, &internal_api); g_assert (f->threads[i] != NULL); } @@ -289,11 +294,9 @@ test_connection (Fixture *f, for (i = 0; i < N_THREADS; i++) { if ((i % 2) == 0) - f->threads[i] = g_thread_create (cycle_thread, &public_api, TRUE, - NULL); + f->threads[i] = g_thread_new (NULL, cycle_thread, &public_api); else - f->threads[i] = g_thread_create (cycle_thread, &internal_api, TRUE, - NULL); + f->threads[i] = g_thread_new (NULL, cycle_thread, &internal_api); g_assert (f->threads[i] != NULL); } @@ -303,11 +306,9 @@ test_connection (Fixture *f, for (i = 0; i < N_THREADS; i++) { if ((i % 2) == 0) - f->threads[i] = g_thread_create (unref_thread, &public_api, TRUE, - NULL); + f->threads[i] = g_thread_new (NULL, unref_thread, &public_api); else - f->threads[i] = g_thread_create (unref_thread, &internal_api, TRUE, - NULL); + f->threads[i] = g_thread_new (NULL, unref_thread, &internal_api); g_assert (f->threads[i] != NULL); } @@ -360,10 +361,9 @@ test_server (Fixture *f, for (i = 0; i < N_THREADS; i++) { if ((i % 2) == 0) - f->threads[i] = g_thread_create (ref_thread, &public_api, TRUE, NULL); + f->threads[i] = g_thread_new (NULL, ref_thread, &public_api); else - f->threads[i] = g_thread_create (ref_thread, &internal_api, TRUE, - NULL); + f->threads[i] = g_thread_new (NULL, ref_thread, &internal_api); g_assert (f->threads[i] != NULL); } @@ -373,11 +373,9 @@ test_server (Fixture *f, for (i = 0; i < N_THREADS; i++) { if ((i % 2) == 0) - f->threads[i] = g_thread_create (cycle_thread, &public_api, TRUE, - NULL); + f->threads[i] = g_thread_new (NULL, cycle_thread, &public_api); else - f->threads[i] = g_thread_create (cycle_thread, &internal_api, TRUE, - NULL); + f->threads[i] = g_thread_new (NULL, cycle_thread, &internal_api); g_assert (f->threads[i] != NULL); } @@ -387,11 +385,9 @@ test_server (Fixture *f, for (i = 0; i < N_THREADS; i++) { if ((i % 2) == 0) - f->threads[i] = g_thread_create (unref_thread, &public_api, TRUE, - NULL); + f->threads[i] = g_thread_new (NULL, unref_thread, &public_api); else - f->threads[i] = g_thread_create (unref_thread, &internal_api, TRUE, - NULL); + f->threads[i] = g_thread_new (NULL, unref_thread, &internal_api); g_assert (f->threads[i] != NULL); } @@ -426,7 +422,7 @@ test_message (Fixture *f, for (i = 0; i < N_THREADS; i++) { - f->threads[i] = g_thread_create (ref_thread, &public_api, TRUE, NULL); + f->threads[i] = g_thread_new (NULL, ref_thread, &public_api); g_assert (f->threads[i] != NULL); } @@ -434,7 +430,7 @@ test_message (Fixture *f, for (i = 0; i < N_THREADS; i++) { - f->threads[i] = g_thread_create (cycle_thread, &public_api, TRUE, NULL); + f->threads[i] = g_thread_new (NULL, cycle_thread, &public_api); g_assert (f->threads[i] != NULL); } @@ -442,7 +438,7 @@ test_message (Fixture *f, for (i = 0; i < N_THREADS; i++) { - f->threads[i] = g_thread_create (unref_thread, &public_api, TRUE, NULL); + f->threads[i] = g_thread_new (NULL, unref_thread, &public_api); g_assert (f->threads[i] != NULL); } @@ -500,10 +496,9 @@ test_pending_call (Fixture *f, for (i = 0; i < N_THREADS; i++) { if ((i % 2) == 0) - f->threads[i] = g_thread_create (ref_thread, &public_api, TRUE, NULL); + f->threads[i] = g_thread_new (NULL, ref_thread, &public_api); else - f->threads[i] = g_thread_create (ref_thread, &internal_api, TRUE, - NULL); + f->threads[i] = g_thread_new (NULL, ref_thread, &internal_api); g_assert (f->threads[i] != NULL); } @@ -515,16 +510,14 @@ test_pending_call (Fixture *f, switch (i % 3) { case 0: - f->threads[i] = g_thread_create (cycle_thread, &public_api, TRUE, - NULL); + f->threads[i] = g_thread_new (NULL, cycle_thread, &public_api); break; case 1: - f->threads[i] = g_thread_create (cycle_thread, &internal_api, TRUE, - NULL); + f->threads[i] = g_thread_new (NULL, cycle_thread, &internal_api); break; default: - f->threads[i] = g_thread_create (cycle_thread, - &unref_and_unlock_api, TRUE, NULL); + f->threads[i] = g_thread_new (NULL, cycle_thread, + &unref_and_unlock_api); } g_assert (f->threads[i] != NULL); @@ -537,16 +530,14 @@ test_pending_call (Fixture *f, switch (i % 3) { case 0: - f->threads[i] = g_thread_create (unref_thread, &public_api, TRUE, - NULL); + f->threads[i] = g_thread_new (NULL, unref_thread, &public_api); break; case 1: - f->threads[i] = g_thread_create (unref_thread, &internal_api, TRUE, - NULL); + f->threads[i] = g_thread_new (NULL, unref_thread, &internal_api); break; default: - f->threads[i] = g_thread_create (unref_thread, - &unref_and_unlock_api, TRUE, NULL); + f->threads[i] = g_thread_new (NULL, unref_thread, + &unref_and_unlock_api); } g_assert (f->threads[i] != NULL); @@ -595,7 +586,12 @@ int main (int argc, char **argv) { - g_thread_init (NULL); + /* In GLib >= 2.24, < 2.31 this acts like g_thread_init() but avoids + * the deprecation of that function. In GLib >= 2.32 this is not + * necessary at all. + */ + g_type_init (); + g_test_init (&argc, &argv, NULL); g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id="); |