diff mbox

[1/2] qemu/compiler: Define QEMU_ARTIFICIAL

Message ID 1410889607-27465-2-git-send-email-rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson Sept. 16, 2014, 5:46 p.m. UTC
The combination of always_inline + artificial allows tiny inline
functions to be written that do not interfere with debugging.
In particular, gdb will not step into an artificial function.

The always_inline attribute was introduced in gcc 4.2,
and the artificial attribute was introduced in gcc 4.3.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 include/qemu/compiler.h | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Peter Maydell Sept. 16, 2014, 5:58 p.m. UTC | #1
On 16 September 2014 10:46, Richard Henderson <rth@twiddle.net> wrote:
> The combination of always_inline + artificial allows tiny inline
> functions to be written that do not interfere with debugging.
> In particular, gdb will not step into an artificial function.
>
> The always_inline attribute was introduced in gcc 4.2,
> and the artificial attribute was introduced in gcc 4.3.
>
> Signed-off-by: Richard Henderson <rth@twiddle.net>

clang can't handle the "artificial" attribute but it reports
itself as gcc 4.2 so that's OK.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM
diff mbox

Patch

diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 155b358..ac7c4c4 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -24,6 +24,12 @@ 
 #define QEMU_WARN_UNUSED_RESULT
 #endif
 
+#if QEMU_GNUC_PREREQ(4, 3)
+#define QEMU_ARTIFICIAL __attribute__((always_inline, artificial))
+#else
+#define QEMU_ARTIFICIAL
+#endif
+
 #if defined(_WIN32)
 # define QEMU_PACKED __attribute__((gcc_struct, packed))
 #else