Patchwork [03/26] Move GETPC from dyngen-exec.h to exec-all.h

login
register
mail settings
Submitter Blue Swirl
Date Sept. 24, 2011, 6:16 p.m.
Message ID <CAAu8pHuy1QQA=2mMBHTwNuPx4RFR-WGWvewVvCatMYJP1j1DoA@mail.gmail.com>
Download mbox | patch
Permalink /patch/116233/
State New
Headers show

Comments

Blue Swirl - Sept. 24, 2011, 6:16 p.m.
GETPC() can be used even from outside of helper code. Move the macro to
a more accessible location. Avoid a compile warning from redefining it
in exec.c.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 dyngen-exec.h |   12 ------------
 exec-all.h    |   12 ++++++++++++
 exec.c        |    1 +
 3 files changed, 13 insertions(+), 12 deletions(-)

Patch

diff --git a/dyngen-exec.h b/dyngen-exec.h
index 8beb7f3..fbde29e 100644
--- a/dyngen-exec.h
+++ b/dyngen-exec.h
@@ -57,16 +57,4 @@ 

 register CPUState *env asm(AREG0);

-/* The return address may point to the start of the next instruction.
-   Subtracting one gets us the call instruction itself.  */
-#if defined(__s390__) && !defined(__s390x__)
-# define GETPC() ((void*)(((unsigned long)__builtin_return_address(0)
& 0x7fffffffUL) - 1))
-#elif defined(__arm__)
-/* Thumb return addresses have the low bit set, so we need to subtract two.
-   This is still safe in ARM mode because instructions are 4 bytes.  */
-# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2))
-#else
-# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1))
-#endif
-
 #endif /* !defined(__DYNGEN_EXEC_H__) */
diff --git a/exec-all.h b/exec-all.h
index b1dfe10..1120f84 100644
--- a/exec-all.h
+++ b/exec-all.h
@@ -267,6 +267,18 @@  extern spinlock_t tb_lock;

 extern int tb_invalidated_flag;

+/* The return address may point to the start of the next instruction.
+   Subtracting one gets us the call instruction itself.  */
+#if defined(__s390__) && !defined(__s390x__)
+# define GETPC() ((void*)(((unsigned long)__builtin_return_address(0)
& 0x7fffffffUL) - 1))
+#elif defined(__arm__)
+/* Thumb return addresses have the low bit set, so we need to subtract two.
+   This is still safe in ARM mode because instructions are 4 bytes.  */
+# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2))
+#else
+# define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1))
+#endif
+
 #if !defined(CONFIG_USER_ONLY)

 extern CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES][4];
diff --git a/exec.c b/exec.c
index 1e6f732..d0cbf15 100644
--- a/exec.c
+++ b/exec.c
@@ -4763,6 +4763,7 @@  void dump_exec_info(FILE *f, fprintf_function cpu_fprintf)
 }

 #define MMUSUFFIX _cmmu
+#undef GETPC
 #define GETPC() NULL
 #define env cpu_single_env
 #define SOFTMMU_CODE_ACCESS