From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TStkj-0002Ce-04 for qemu-devel@nongnu.org; Mon, 29 Oct 2012 14:08:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TStkh-0005cu-U6 for qemu-devel@nongnu.org; Mon, 29 Oct 2012 14:07:56 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:61159) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TStkh-0005ZP-NZ for qemu-devel@nongnu.org; Mon, 29 Oct 2012 14:07:55 -0400 Received: by mail-pa0-f45.google.com with SMTP id fb10so3395861pad.4 for ; Mon, 29 Oct 2012 11:07:55 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 29 Oct 2012 19:07:10 +0100 Message-Id: <1351534038-15503-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1351534038-15503-1-git-send-email-pbonzini@redhat.com> References: <1351534038-15503-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 03/11] compiler: use weak aliases to provide default definitions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@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 d8a3c00..638888a 100644 --- a/qmp.c +++ b/qmp.c @@ -471,11 +471,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) { -- 1.7.12.1