qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] g_thread_init users: don't call it if glib >= 2.31
@ 2011-12-20 11:41 Alon Levy
  2011-12-20 22:17 ` Anthony Liguori
  0 siblings, 1 reply; 3+ messages in thread
From: Alon Levy @ 2011-12-20 11:41 UTC (permalink / raw)
  To: anthony; +Cc: qemu-devel

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>
---
 coroutine-gthread.c |    5 +++++
 trace/simple.c      |    5 +++++
 vl.c                |    5 +++++
 3 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/coroutine-gthread.c b/coroutine-gthread.c
index fdea27a..662801b 100644
--- a/coroutine-gthread.c
+++ b/coroutine-gthread.c
@@ -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();
diff --git a/trace/simple.c b/trace/simple.c
index 6339152..bbc9930 100644
--- a/trace/simple.c
+++ b/trace/simple.c
@@ -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 da69f94..06c9c94 100644
--- 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();
-- 
1.7.8

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH] g_thread_init users: don't call it if glib >= 2.31
@ 2011-12-20 14:15 Alon Levy
  0 siblings, 0 replies; 3+ messages in thread
From: Alon Levy @ 2011-12-20 14:15 UTC (permalink / raw)
  To: anthony; +Cc: qemu-devel

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>
---
 coroutine-gthread.c |    5 +++++
 trace/simple.c      |    5 +++++
 vl.c                |    5 +++++
 3 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/coroutine-gthread.c b/coroutine-gthread.c
index fdea27a..662801b 100644
--- a/coroutine-gthread.c
+++ b/coroutine-gthread.c
@@ -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();
diff --git a/trace/simple.c b/trace/simple.c
index 6339152..bbc9930 100644
--- a/trace/simple.c
+++ b/trace/simple.c
@@ -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 da69f94..06c9c94 100644
--- 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();
-- 
1.7.8

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] g_thread_init users: don't call it if glib >= 2.31
  2011-12-20 11:41 [Qemu-devel] [PATCH] g_thread_init users: don't call it if glib >= 2.31 Alon Levy
@ 2011-12-20 22:17 ` Anthony Liguori
  0 siblings, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2011-12-20 22:17 UTC (permalink / raw)
  To: Alon Levy; +Cc: qemu-devel

On 12/20/2011 05:41 AM, Alon Levy wrote:
> 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>

Applied.  Thanks.

Regards,

Anthony Liguori

> ---
>   coroutine-gthread.c |    5 +++++
>   trace/simple.c      |    5 +++++
>   vl.c                |    5 +++++
>   3 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/coroutine-gthread.c b/coroutine-gthread.c
> index fdea27a..662801b 100644
> --- a/coroutine-gthread.c
> +++ b/coroutine-gthread.c
> @@ -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();
> diff --git a/trace/simple.c b/trace/simple.c
> index 6339152..bbc9930 100644
> --- a/trace/simple.c
> +++ b/trace/simple.c
> @@ -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 da69f94..06c9c94 100644
> --- 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();

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-20 22:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-20 11:41 [Qemu-devel] [PATCH] g_thread_init users: don't call it if glib >= 2.31 Alon Levy
2011-12-20 22:17 ` Anthony Liguori
  -- strict thread matches above, loose matches on Subject: below --
2011-12-20 14:15 Alon Levy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).