X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=test%2Finternals%2Frefs.c;h=202dc04320ea5e9820858888399a583b9423e8c5;hb=f17fd1cc4e8d69f92986b6f452618c6c1b9819dc;hp=bc0884e3cce1f038da0199f66f33aeca5a17ea72;hpb=ba033709b54df18bbe48b22303e0c3d514f547f8;p=platform%2Fupstream%2Fdbus.git diff --git a/test/internals/refs.c b/test/internals/refs.c index bc0884e..202dc04 100644 --- a/test/internals/refs.c +++ b/test/internals/refs.c @@ -27,8 +27,8 @@ #include #include +#include -#define DBUS_COMPILATION /* this test uses libdbus-internal */ #include #include #include @@ -77,6 +77,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 +281,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 +293,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 +305,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 +360,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 +372,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 +384,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 +421,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 +429,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 +437,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 +495,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 +509,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 +529,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 +585,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=");