]> git.proxmox.com Git - qemu.git/commitdiff
g_thread_init users: don't call it if glib >= 2.31
authorAlon Levy <alevy@redhat.com>
Tue, 20 Dec 2011 11:41:04 +0000 (13:41 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 20 Dec 2011 21:44:31 +0000 (15:44 -0600)
since commit f9b29ca03 included in release 2.31 (docs below say 2.32 but
that is not correct) and onwards g_thread_init is deprecated and calling
it is not required:

 http://developer.gnome.org/glib/unstable/glib-Deprecated-Thread-APIs.html#g-thread-init

 g_thread_init has been deprecated since version 2.32 and should not be
 used in newly-written code. This function is no longer necessary. The
 GLib threading system is automatically initialized at the start of your
 program.

Fixes bulid failure when warnings are treated as errors on fedora 17.

I only tested the change to vl.c, and copy pasted to the two other
locations (couldn't decide if a wrapper for calling g_thread_init is
uglier).

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
coroutine-gthread.c
trace/simple.c
vl.c

index fdea27a106601c5ae0914462fc0ae077271865af..662801b2fa27e94fd84165dc96b1299291f8649c 100644 (file)
@@ -36,7 +36,12 @@ static GStaticPrivate coroutine_key = G_STATIC_PRIVATE_INIT;
 static void __attribute__((constructor)) coroutine_init(void)
 {
     if (!g_thread_supported()) {
+#if !GLIB_CHECK_VERSION(2, 31, 0)
         g_thread_init(NULL);
+#else
+        fprintf(stderr, "glib threading failed to initialize.\n");
+        exit(1);
+#endif
     }
 
     coroutine_cond = g_cond_new();
index 6339152d279c542aae3644ebae195a56460ccd5b..bbc99302b9427d12f109b428a9153713a4deca9f 100644 (file)
@@ -376,7 +376,12 @@ bool trace_backend_init(const char *events, const char *file)
     GThread *thread;
 
     if (!g_thread_supported()) {
+#if !GLIB_CHECK_VERSION(2, 31, 0)
         g_thread_init(NULL);
+#else
+        fprintf(stderr, "glib threading failed to initialize.\n");
+        exit(1);
+#endif
     }
 
     trace_available_cond = g_cond_new();
diff --git a/vl.c b/vl.c
index 78b790c91941de82d083fce6a8da0cf03a688197..c03abb66ad90f2578b4b13da64a262441aefe4e1 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -2176,7 +2176,12 @@ int main(int argc, char **argv, char **envp)
 
     g_mem_set_vtable(&mem_trace);
     if (!g_thread_supported()) {
+#if !GLIB_CHECK_VERSION(2, 31, 0)
         g_thread_init(NULL);
+#else
+        fprintf(stderr, "glib threading failed to initialize.\n");
+        exit(1);
+#endif
     }
 
     runstate_init();