summaryrefslogtreecommitdiff
path: root/compiler.h
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-11-02 15:43:20 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2012-11-02 13:07:54 -0500
commit1f001dc7bc9e435bf231a5b0edcad1c7c2bd6214 (patch)
tree531f1ce25757189d2ac450a42f8eea75cf50e6fb /compiler.h
parent2a0dfd004d9fae4adf2ccfcb2e3b1a76906b48a0 (diff)
downloadqemu-1f001dc7bc9e435bf231a5b0edcad1c7c2bd6214.tar.gz
compiler: support Darwin weak references
Weakrefs only tell you if the symbol was defined elsewhere, so you need a further check at runtime to pick the default definition when needed. This could be automated by the compiler, but it does not do it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'compiler.h')
-rw-r--r--compiler.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler.h b/compiler.h
index 58865d65e8..55d7d74775 100644
--- a/compiler.h
+++ b/compiler.h
@@ -50,8 +50,15 @@
# define __printf__ __gnu_printf__
# endif
# endif
-# define QEMU_WEAK_ALIAS(newname, oldname) \
+# if defined(__APPLE__)
+# define QEMU_WEAK_ALIAS(newname, oldname) \
+ static typeof(oldname) weak_##newname __attribute__((unused, weakref(#oldname)))
+# define QEMU_WEAK_REF(newname, oldname) (weak_##newname ? weak_##newname : oldname)
+# else
+# define QEMU_WEAK_ALIAS(newname, oldname) \
typeof(oldname) newname __attribute__((weak, alias (#oldname)))
+# define QEMU_WEAK_REF(newname, oldname) newname
+# endif
#else
#define GCC_ATTR /**/
#define GCC_FMT_ATTR(n, m)