From a1737ece06dbce11f3773eb87083ff6f5316bdaa Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Wed, 3 Aug 2022 20:33:21 +0200 Subject: [PATCH 1/2] Fix GCancellable tests for Windows 64bit Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/2703 --- gio/tests/cancellable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gio/tests/cancellable.c b/gio/tests/cancellable.c index 5d8bf8a85..9fcd7520b 100644 --- a/gio/tests/cancellable.c +++ b/gio/tests/cancellable.c @@ -468,7 +468,7 @@ typedef struct { GCallback callback; gboolean is_disconnecting; gboolean is_resetting; - gulong handler_id; + gpointer handler_id; } ConnectingThreadData; static void @@ -496,7 +496,7 @@ connecting_thread (gpointer user_data) g_main_context_push_thread_default (context); loop = g_main_loop_new (context, FALSE); - g_atomic_pointer_set (&data->handler_id, handler_id); + g_atomic_pointer_set (&data->handler_id, (gpointer) handler_id); g_atomic_pointer_set (&data->loop, loop); g_main_loop_run (loop); From cdb8e5e9c5c88905d5fd64c515085354fa48bfd0 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Wed, 3 Aug 2022 20:38:59 +0200 Subject: [PATCH 2/2] Fix warnings in GCancellable test --- gio/tests/cancellable.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gio/tests/cancellable.c b/gio/tests/cancellable.c index 9fcd7520b..9ef6bb472 100644 --- a/gio/tests/cancellable.c +++ b/gio/tests/cancellable.c @@ -475,7 +475,7 @@ static void on_cancellable_connect_disconnect (GCancellable *cancellable, ConnectingThreadData *data) { - gulong handler_id = (gulong) g_atomic_pointer_exchange (&data->handler_id, 0); + gulong handler_id = (gulong) (guintptr) g_atomic_pointer_exchange (&data->handler_id, 0); g_atomic_int_set (&data->is_disconnecting, TRUE); g_cancellable_disconnect (cancellable, handler_id); g_atomic_int_set (&data->is_disconnecting, FALSE); @@ -496,7 +496,7 @@ connecting_thread (gpointer user_data) g_main_context_push_thread_default (context); loop = g_main_loop_new (context, FALSE); - g_atomic_pointer_set (&data->handler_id, (gpointer) handler_id); + g_atomic_pointer_set (&data->handler_id, (gpointer) (guintptr) handler_id); g_atomic_pointer_set (&data->loop, loop); g_main_loop_run (loop); @@ -537,7 +537,7 @@ test_cancellable_disconnect_on_cancelled_callback_hangs (void) thread_data.callback = G_CALLBACK (on_cancellable_connect_disconnect); g_assert_false (g_atomic_int_get (&thread_data.is_disconnecting)); - g_assert_cmpuint ((gulong) g_atomic_pointer_get (&thread_data.handler_id), ==, 0); + g_assert_cmpuint ((gulong) (guintptr) g_atomic_pointer_get (&thread_data.handler_id), ==, 0); thread = g_thread_new ("/cancellable/disconnect-on-cancelled-callback-hangs", connecting_thread, &thread_data); @@ -546,7 +546,7 @@ test_cancellable_disconnect_on_cancelled_callback_hangs (void) ; thread_loop = thread_data.loop; - g_assert_cmpuint ((gulong) g_atomic_pointer_get (&thread_data.handler_id), !=, 0); + g_assert_cmpuint ((gulong) (guintptr) g_atomic_pointer_get (&thread_data.handler_id), !=, 0); /* FIXME: This thread will hang (at least that's what this test wants to * ensure), but we can't stop it from the caller, unless we'll expose @@ -562,7 +562,7 @@ test_cancellable_disconnect_on_cancelled_callback_hangs (void) ; g_assert_true (g_atomic_int_get (&thread_data.is_disconnecting)); - g_assert_cmpuint ((gulong) g_atomic_pointer_get (&thread_data.handler_id), ==, 0); + g_assert_cmpuint ((gulong) (guintptr) g_atomic_pointer_get (&thread_data.handler_id), ==, 0); waited = &waited; g_timeout_add_once (100, (GSourceOnceFunc) g_nullify_pointer, &waited); @@ -622,7 +622,7 @@ test_cancellable_reset_on_cancelled_callback_hangs (void) thread_data.callback = G_CALLBACK (on_cancelled_reset); g_assert_false (g_atomic_int_get (&thread_data.is_resetting)); - g_assert_cmpuint ((gulong) g_atomic_pointer_get (&thread_data.handler_id), ==, 0); + g_assert_cmpuint ((gulong) (guintptr) g_atomic_pointer_get (&thread_data.handler_id), ==, 0); thread = g_thread_new ("/cancellable/reset-on-cancelled-callback-hangs", connecting_thread, &thread_data); @@ -631,7 +631,7 @@ test_cancellable_reset_on_cancelled_callback_hangs (void) ; thread_loop = thread_data.loop; - g_assert_cmpuint ((gulong) g_atomic_pointer_get (&thread_data.handler_id), !=, 0); + g_assert_cmpuint ((gulong) (guintptr) g_atomic_pointer_get (&thread_data.handler_id), !=, 0); /* FIXME: This thread will hang (at least that's what this test wants to * ensure), but we can't stop it from the caller, unless we'll expose @@ -647,7 +647,7 @@ test_cancellable_reset_on_cancelled_callback_hangs (void) ; g_assert_true (g_atomic_int_get (&thread_data.is_resetting)); - g_assert_cmpuint ((gulong) g_atomic_pointer_get (&thread_data.handler_id), >, 0); + g_assert_cmpuint ((gulong) (guintptr) g_atomic_pointer_get (&thread_data.handler_id), >, 0); waited = &waited; g_timeout_add_once (100, (GSourceOnceFunc) g_nullify_pointer, &waited);