From patchwork Tue Dec 20 11:41:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 132401 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BB3EEB6FF1 for ; Tue, 20 Dec 2011 22:41:29 +1100 (EST) Received: from localhost ([::1]:46522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rcy4T-00060A-Bq for incoming@patchwork.ozlabs.org; Tue, 20 Dec 2011 06:41:25 -0500 Received: from eggs.gnu.org ([140.186.70.92]:53451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rcy4I-0005zf-4Y for qemu-devel@nongnu.org; Tue, 20 Dec 2011 06:41:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rcy4E-0003Gx-4x for qemu-devel@nongnu.org; Tue, 20 Dec 2011 06:41:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:26122) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rcy4D-0003Gi-T3 for qemu-devel@nongnu.org; Tue, 20 Dec 2011 06:41:10 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBKBf7V2023331 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 20 Dec 2011 06:41:07 -0500 Received: from garlic.tlv.redhat.com (dhcp-4-31.tlv.redhat.com [10.35.4.31]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pBKBf54G025232; Tue, 20 Dec 2011 06:41:06 -0500 From: Alon Levy To: anthony@codemonkey.ws Date: Tue, 20 Dec 2011 13:41:04 +0200 Message-Id: <1324381264-5959-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] g_thread_init users: don't call it if glib >= 2.31 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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();