From patchwork Tue Feb 12 13:34:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 219857 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7702B2C0329 for ; Wed, 13 Feb 2013 00:35:06 +1100 (EST) Received: from localhost ([::1]:43098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5G0m-0001Md-EK for incoming@patchwork.ozlabs.org; Tue, 12 Feb 2013 08:35:04 -0500 Received: from eggs.gnu.org ([208.118.235.92]:36249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5G06-000801-Rn for qemu-devel@nongnu.org; Tue, 12 Feb 2013 08:34:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U5Fzy-0000WV-8E for qemu-devel@nongnu.org; Tue, 12 Feb 2013 08:34:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40745) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5Fzx-0000WK-Um for qemu-devel@nongnu.org; Tue, 12 Feb 2013 08:34:14 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1CDYDNq010655 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 12 Feb 2013 08:34:13 -0500 Received: from localhost (ovpn-112-27.ams2.redhat.com [10.36.112.27]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r1CDYCjw022450; Tue, 12 Feb 2013 08:34:12 -0500 From: Stefan Hajnoczi To: Date: Tue, 12 Feb 2013 14:34:05 +0100 Message-Id: <1360676045-9204-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1360676045-9204-1-git-send-email-stefanha@redhat.com> References: <1360676045-9204-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Anthony Liguori , Stefan Hajnoczi , Juan Quintela Subject: [Qemu-devel] [PATCH for-1.4 2/2] trace: deal with deprecated glib thread functions 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 g_thread_create() was deprecated in favor of g_thread_new() and g_cond_new() was deprecated in favor of GCond initialization. If the host has glib 2.31 or newer, avoid using the deprecated functions. This patch solves compiler warnings that are generated when glib's deprecated functions are used. Signed-off-by: Stefan Hajnoczi --- trace/simple.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/trace/simple.c b/trace/simple.c index 1d5d8e4..375d98f 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -40,8 +40,18 @@ * records to become available, writes them out, and then waits again. */ static GStaticMutex trace_lock = G_STATIC_MUTEX_INIT; + +/* g_cond_new() was deprecated in glib 2.31 but we still need to support it */ +#if GLIB_CHECK_VERSION(2, 31, 0) +static GCond the_trace_available_cond; +static GCond the_trace_empty_cond; +static GCond *trace_available_cond = &the_trace_available_cond; +static GCond *trace_empty_cond = &the_trace_empty_cond; +#else static GCond *trace_available_cond; static GCond *trace_empty_cond; +#endif + static bool trace_available; static bool trace_writeout_enabled; @@ -397,7 +407,13 @@ static GThread *trace_thread_create(GThreadFunc fn) sigfillset(&set); pthread_sigmask(SIG_SETMASK, &set, &oldset); #endif + +#if GLIB_CHECK_VERSION(2, 31, 0) + thread = g_thread_new("trace-thread", fn, NULL); +#else thread = g_thread_create(fn, NULL, FALSE, NULL); +#endif + #ifndef _WIN32 pthread_sigmask(SIG_SETMASK, &oldset, NULL); #endif @@ -418,8 +434,10 @@ bool trace_backend_init(const char *events, const char *file) #endif } +#if !GLIB_CHECK_VERSION(2, 31, 0) trace_available_cond = g_cond_new(); trace_empty_cond = g_cond_new(); +#endif thread = trace_thread_create(writeout_thread); if (!thread) {