[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/11] compiler: use weak aliases to provide default
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 03/11] compiler: use weak aliases to provide default definitions |
Date: |
Mon, 29 Oct 2012 19:07:10 +0100 |
This is simpler and more portable.
Signed-off-by: Paolo Bonzini <address@hidden>
---
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
- [Qemu-devel] [PATCH 00/11] Trim dependencies of qemu-ga, vscclient, tests, Paolo Bonzini, 2012/10/29
- [Qemu-devel] [PATCH 01/11] janitor: move iovector functions out of cutils.c, Paolo Bonzini, 2012/10/29
- [Qemu-devel] [PATCH 03/11] compiler: use weak aliases to provide default definitions,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 02/11] build: move cutils.o and qemu-timer-common.o to oslib-obj-y, Paolo Bonzini, 2012/10/29
- [Qemu-devel] [PATCH 04/11] sockets: use weak aliases instead of qemu-tool.c, Paolo Bonzini, 2012/10/29
- [Qemu-devel] [PATCH 05/11] fdsets: use weak aliases instead of qemu-tool.c/qemu-user.c, Paolo Bonzini, 2012/10/29
- [Qemu-devel] [PATCH 06/11] iohandler: add weak alias in qemu-sockets.c, for qemu-ga, Paolo Bonzini, 2012/10/29
- [Qemu-devel] [PATCH 07/11] win32: add weak version of qemu_fd_register, Paolo Bonzini, 2012/10/29
- [Qemu-devel] [PATCH 08/11] qemu-timer: make initialization functions idempotent, Paolo Bonzini, 2012/10/29
- [Qemu-devel] [PATCH 09/11] main-loop: unify qemu_init_main_loop between QEMU and tools, Paolo Bonzini, 2012/10/29
- [Qemu-devel] [PATCH 10/11] qemu-tool: do not depend on qemu-timer.c, Paolo Bonzini, 2012/10/29
- [Qemu-devel] [PATCH 11/11] build: do not include main loop where it is not actually used, Paolo Bonzini, 2012/10/29