From patchwork Mon Sep 17 16:00:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 184489 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 0B5222C007D for ; Tue, 18 Sep 2012 02:33:07 +1000 (EST) Received: from localhost ([::1]:60915 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDeFt-0005F1-4T for incoming@patchwork.ozlabs.org; Mon, 17 Sep 2012 12:33:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDdl4-0003EA-8V for qemu-devel@nongnu.org; Mon, 17 Sep 2012 12:01:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TDdkz-0000Mk-VW for qemu-devel@nongnu.org; Mon, 17 Sep 2012 12:01:14 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:54240) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDdkz-0000Hr-Ot for qemu-devel@nongnu.org; Mon, 17 Sep 2012 12:01:09 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp12so9799681pbb.4 for ; Mon, 17 Sep 2012 09:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=6ECDqdW1oKAGiWHSe4MZBgoxoikFtuWuZuSOP8bEaKU=; b=HUsQ5TtAIdANGi53CmASi513LkEnfrV432VjiqrkCEdyfrXT5TpjIWTfa9Duh1PYzc H6WtV3duD7QIHQQSjuLflQSJPPXuIrvsm6wvsXzQ3os1jK2Bihou4VxlqEcENnrL6aLA C+/PcJJmdu2DTF0PwQUb56mztuZZTuEylMJrv4tuyrYq6q1RDIme7sUwENQOrj3tj5Nl 4iL0bONWD5fQDxSb1Vhk6xfbHLcb0zrPSU54YzSKKiVs/c2KtYqWw/5U3KpQunN3vEAT +qKe96aFp+KQZIqwWwB61Cy42+Ywvf9VEGromRZV6OmRxBDlvbrMfbp7whe3ZNiIhfG7 vqLw== Received: by 10.68.195.230 with SMTP id ih6mr23667617pbc.100.1347897669302; Mon, 17 Sep 2012 09:01:09 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id pq7sm7151494pbb.25.2012.09.17.09.01.06 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 09:01:08 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 17 Sep 2012 18:00:42 +0200 Message-Id: <1347897649-23236-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1347897649-23236-1-git-send-email-pbonzini@redhat.com> References: <1347897649-23236-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: Anthony Liguori Subject: [Qemu-devel] [RFC PATCH 03/10] vl: implement tcg_enabled() and tcg_available() as for other accelerators 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 From: Anthony Liguori This way, tcg_enabled() can be used to stub out entire sections of code that are not used on TCG. This will limit the use of #ifdef and improves code checking from the compiler. Signed-off-by: Anthony Liguori Signed-off-by: Paolo Bonzini --- arch_init.c | 4 ++++ exec.c | 6 +----- qemu-common.h | 8 +++++++- vl.c | 2 +- 4 file modificati, 13 inserzioni(+), 7 rimozioni(-) diff --git a/arch_init.c b/arch_init.c index 5a1173e..fb41467 100644 --- a/arch_init.c +++ b/arch_init.c @@ -1061,7 +1061,11 @@ int audio_available(void) int tcg_available(void) { +#if defined(CONFIG_TCG) return 1; +#else + return 0; +#endif } int kvm_available(void) diff --git a/exec.c b/exec.c index 5834766..1270d78 100644 --- a/exec.c +++ b/exec.c @@ -615,6 +615,7 @@ static void code_gen_alloc(unsigned long tb_size) size. */ void tcg_exec_init(unsigned long tb_size) { + tcg_allowed = 1; cpu_gen_init(); code_gen_alloc(tb_size); code_gen_ptr = code_gen_buffer; @@ -627,11 +628,6 @@ void tcg_exec_init(unsigned long tb_size) #endif } -bool tcg_enabled(void) -{ - return code_gen_buffer != NULL; -} - void cpu_exec_init_all(void) { #if !defined(CONFIG_USER_ONLY) diff --git a/qemu-common.h b/qemu-common.h index e5c2bcd..6a3b075 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -301,8 +301,14 @@ typedef struct PCIHostDeviceAddress { unsigned int function; } PCIHostDeviceAddress; +extern int tcg_allowed; void tcg_exec_init(unsigned long tb_size); -bool tcg_enabled(void); + +#ifdef CONFIG_TCG +#define tcg_enabled() (tcg_allowed) +#else +#define tcg_enabled() 0 +#endif void cpu_exec_init_all(void); diff --git a/vl.c b/vl.c index 7c577fa..fa022d1 100644 --- a/vl.c +++ b/vl.c @@ -260,7 +260,7 @@ static NotifierList exit_notifiers = static NotifierList machine_init_done_notifiers = NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers); -static int tcg_allowed = 1; +int tcg_allowed = 0; int kvm_allowed = 0; int xen_allowed = 0; uint32_t xen_domid;