[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PULL 15/22] do not call g_thread_init() for glib >= 2.31
From: |
Michael Tokarev |
Subject: |
[Qemu-trivial] [PULL 15/22] do not call g_thread_init() for glib >= 2.31 |
Date: |
Mon, 5 May 2014 22:01:56 +0400 |
glib >= 2.31 always enables thread support and g_thread_supported()
is #defined to 1, there's no need to call g_thread_init() anymore,
and it definitely does not need to report error which never happens.
Keep code for old < 2.31 glibc anyway for now, just #ifdef it
differently.
Signed-off-by: Michael Tokarev <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Cc: address@hidden
---
coroutine-gthread.c | 7 ++-----
util/osdep.c | 21 +++++++++------------
2 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/coroutine-gthread.c b/coroutine-gthread.c
index d3e5b99..a61efe0 100644
--- a/coroutine-gthread.c
+++ b/coroutine-gthread.c
@@ -115,14 +115,11 @@ static inline GThread *create_thread(GThreadFunc func,
gpointer data)
static void __attribute__((constructor)) coroutine_init(void)
{
- if (!g_thread_supported()) {
#if !GLIB_CHECK_VERSION(2, 31, 0)
+ if (!g_thread_supported()) {
g_thread_init(NULL);
-#else
- fprintf(stderr, "glib threading failed to initialize.\n");
- exit(1);
-#endif
}
+#endif
init_coroutine_cond();
}
diff --git a/util/osdep.c b/util/osdep.c
index a9029f8..b2bd154 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -436,23 +436,20 @@ int socket_init(void)
return 0;
}
-/* Ensure that glib is running in multi-threaded mode */
+#if !GLIB_CHECK_VERSION(2, 31, 0)
+/* Ensure that glib is running in multi-threaded mode
+ * Old versions of glib require explicit initialization. Failure to do
+ * this results in the single-threaded code paths being taken inside
+ * glib. For example, the g_slice allocator will not be thread-safe
+ * and cause crashes.
+ */
static void __attribute__((constructor)) thread_init(void)
{
if (!g_thread_supported()) {
-#if !GLIB_CHECK_VERSION(2, 31, 0)
- /* Old versions of glib require explicit initialization. Failure to do
- * this results in the single-threaded code paths being taken inside
- * glib. For example, the g_slice allocator will not be thread-safe
- * and cause crashes.
- */
- g_thread_init(NULL);
-#else
- fprintf(stderr, "glib threading failed to initialize.\n");
- exit(1);
-#endif
+ g_thread_init(NULL);
}
}
+#endif
#ifndef CONFIG_IOVEC
/* helper function for iov_send_recv() */
--
1.7.10.4
- [Qemu-trivial] [PULL 21/22] docs/memory.txt: Fix document on MMIO operations, (continued)
- [Qemu-trivial] [PULL 21/22] docs/memory.txt: Fix document on MMIO operations, Michael Tokarev, 2014/05/05
- [Qemu-trivial] [PULL 14/22] hw/9pfs: Add include file for exported symbol, Michael Tokarev, 2014/05/05
- [Qemu-trivial] [PULL 16/22] glib: move g_poll() replacement into glib-compat.h, Michael Tokarev, 2014/05/05
- [Qemu-trivial] [PULL 10/22] ui: Add missing 'static' attribute, Michael Tokarev, 2014/05/05
- [Qemu-trivial] [PULL 09/22] monitor: Add missing 'static' attribute, Michael Tokarev, 2014/05/05
- [Qemu-trivial] [PULL 20/22] readline: Sort completions before printing them., Michael Tokarev, 2014/05/05
- [Qemu-trivial] [PULL 17/22] libcacard: replace pstrcpy() with memcpy(), Michael Tokarev, 2014/05/05
- [Qemu-trivial] [PULL 13/22] xen: remove unused global, xen_xcg, Michael Tokarev, 2014/05/05
- [Qemu-trivial] [PULL 19/22] readline: use g_strndup instead of open-coding it, Michael Tokarev, 2014/05/05
- [Qemu-trivial] [PULL 08/22] hw/s390x: Add missing 'static' attribute, Michael Tokarev, 2014/05/05
- [Qemu-trivial] [PULL 15/22] do not call g_thread_init() for glib >= 2.31,
Michael Tokarev <=
- [Qemu-trivial] [PULL 12/22] hw: Add missing 'static' attributes, Michael Tokarev, 2014/05/05
- Re: [Qemu-trivial] [Qemu-devel] [PULL 00/22] Trivial patches for 2014-05-05, Peter Maydell, 2014/05/07