summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2012-01-23 11:11:24 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-03-27 12:10:00 +0100
commit19343fb6a8a4bd3a2008c07b4f13ee2b0bf700d7 (patch)
treeb3d01a1a3d8d08db1a1c8eeff362ea84146480e5 /test
parentbee5d4fb05f019f0907989ae82bb6c66b5743f82 (diff)
downloaddbus-19343fb6a8a4bd3a2008c07b4f13ee2b0bf700d7.tar.gz
Port to glib 2.31.x g_thread API
g_thread_init() is deprecated since glib 2.24, call g_type_init() instead. Bump glib requirement accordingly. g_thread_create is deprecated since 2.31, use g_thread_new() instead. When building with a glib earlier than 2.31, provide a backwards compatibility shim. [Added a comment about why we're using g_type_init() in a test that doesn't otherwise use GObject -smcv] [Applied to 1.4 despite just being a deprecation fix because it also fixes linking with GLib 2.32, in which gthread has been removed from gobject's Requires and moved to Requires.private, Debian #665665 -smcv] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=44413 Bug-Debian: http://bugs.debian.org/665665 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Diffstat (limited to 'test')
-rw-r--r--test/internals/refs.c78
1 files changed, 37 insertions, 41 deletions
diff --git a/test/internals/refs.c b/test/internals/refs.c
index 3d21c894..20e4f040 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)
{
@@ -277,10 +283,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);
}
@@ -290,11 +295,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);
}
@@ -304,11 +307,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);
}
@@ -361,10 +362,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);
}
@@ -374,11 +374,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);
}
@@ -388,11 +386,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);
}
@@ -427,7 +423,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);
}
@@ -435,7 +431,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);
}
@@ -443,7 +439,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);
}
@@ -501,10 +497,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);
}
@@ -516,16 +511,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);
@@ -538,16 +531,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);
@@ -596,7 +587,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=");