From patchwork Wed Oct 31 15:30:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 195894 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 ADE342C0281 for ; Thu, 1 Nov 2012 02:31:55 +1100 (EST) Received: from localhost ([::1]:56308 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTaGn-0006jZ-QL for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2012 11:31:53 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTaGO-0006C3-HJ for qemu-devel@nongnu.org; Wed, 31 Oct 2012 11:31:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTaGJ-0004vY-L7 for qemu-devel@nongnu.org; Wed, 31 Oct 2012 11:31:28 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:41123) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTaGJ-0004ui-EV for qemu-devel@nongnu.org; Wed, 31 Oct 2012 11:31:23 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp2so1021969pbb.4 for ; Wed, 31 Oct 2012 08:31:21 -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=X3AEpVevZQxf5Fz2DW/GB3FE+dkQtAEtTDe9lYNovIo=; b=EbNextWzR0AY2YDenF4E+CbNhlFMAO2rZCxrrZKWi3herk5TRLtEEW3inPLYVKOk5m h0jpRkVEF9pAmWvz0McTOtQq+ULGcq4L+KrhtjM4Zu3xRni/ByEyLNg3Y/KSXK0PwB+9 mu9zlMr1HJswMI00vlKTNuHXdLQG+q4tO6wUYOiZ/OwJQ+ydILtMEIkrIi0iP0DXuruw WtFlXEOqmXBGURZtAZmRJRgWMkJRmGCn7sOIHzvwu/Mn7+gclape+Jqp0BzqqtNjFDrq ZI+V6Mie2CijIR5tNS0jUmqaOai8jm092PZMSm1oaIYctzR3Ng0OEyzPwZB+Yed/hQ4b d6BQ== Received: by 10.68.213.6 with SMTP id no6mr74351073pbc.113.1351697481732; Wed, 31 Oct 2012 08:31:21 -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 sz6sm2445230pbc.52.2012.10.31.08.31.17 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 31 Oct 2012 08:31:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 31 Oct 2012 16:30:20 +0100 Message-Id: <1351697456-16107-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1351697456-16107-1-git-send-email-pbonzini@redhat.com> References: <1351697456-16107-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: aliguori@us.ibm.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH v2 03/39] compiler: use weak aliases to provide default definitions 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 This is simpler and more portable. Signed-off-by: Paolo Bonzini --- arch_init.h | 2 +- compiler.h | 11 ++++------- qmp.c | 3 ++- 3 file modificati, 7 inserzioni(+), 9 rimozioni(-) diff --git a/arch_init.h b/arch_init.h index d9c572a..5fc780c 100644 --- a/arch_init.h +++ b/arch_init.h @@ -34,6 +34,6 @@ int tcg_available(void); int kvm_available(void); int xen_available(void); -CpuDefinitionInfoList GCC_WEAK_DECL *arch_query_cpu_definitions(Error **errp); +CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp); #endif diff --git a/compiler.h b/compiler.h index c734a71..58865d6 100644 --- a/compiler.h +++ b/compiler.h @@ -50,16 +50,13 @@ # define __printf__ __gnu_printf__ # endif # endif -#if defined(_WIN32) -#define GCC_WEAK __attribute__((weak)) -#define GCC_WEAK_DECL GCC_WEAK -#else -#define GCC_WEAK __attribute__((weak)) -#define GCC_WEAK_DECL -#endif +# define QEMU_WEAK_ALIAS(newname, oldname) \ + typeof(oldname) newname __attribute__((weak, alias (#oldname))) #else #define GCC_ATTR /**/ #define GCC_FMT_ATTR(n, m) +#define QEMU_WEAK_ALIAS(newname, oldname) \ + _Pragma("weak " #newname "=" #oldname) #endif #endif /* COMPILER_H */ diff --git a/qmp.c b/qmp.c index 31bc3bf..df952b6 100644 --- a/qmp.c +++ b/qmp.c @@ -466,11 +466,12 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename, return prop_list; } -CpuDefinitionInfoList GCC_WEAK *arch_query_cpu_definitions(Error **errp) +static CpuDefinitionInfoList *default_arch_query_cpu_definitions(Error **errp) { error_set(errp, QERR_NOT_SUPPORTED); return NULL; } +QEMU_WEAK_ALIAS(arch_query_cpu_definitions, default_arch_query_cpu_definitions); CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) {