qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] translate-all: wrapped map_exec() in #ifdef
@ 2014-10-31  4:59 SeokYeon Hwang
  2014-10-31 18:30 ` Peter Maydell
  0 siblings, 1 reply; 7+ messages in thread
From: SeokYeon Hwang @ 2014-10-31  4:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: SeokYeon Hwang

Moved map_exec() and wrapped it in #ifdef to avoid "-Wunused-function" on clang 3.4 or later.

Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
---
 translate-all.c | 52 +++++++++++++++++++++++++++-------------------------
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/translate-all.c b/translate-all.c
index ba5c840..e64ebf9 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -269,31 +269,6 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t retaddr)
     return false;
 }
 
-#ifdef _WIN32
-static inline void map_exec(void *addr, long size)
-{
-    DWORD old_protect;
-    VirtualProtect(addr, size,
-                   PAGE_EXECUTE_READWRITE, &old_protect);
-}
-#else
-static inline void map_exec(void *addr, long size)
-{
-    unsigned long start, end, page_size;
-
-    page_size = getpagesize();
-    start = (unsigned long)addr;
-    start &= ~(page_size - 1);
-
-    end = (unsigned long)addr + size;
-    end += page_size - 1;
-    end &= ~(page_size - 1);
-
-    mprotect((void *)start, end - start,
-             PROT_READ | PROT_WRITE | PROT_EXEC);
-}
-#endif
-
 void page_size_init(void)
 {
     /* NOTE: we can always suppose that qemu_host_page_size >=
@@ -536,6 +511,33 @@ static inline void *split_cross_256mb(void *buf1, size_t size1)
 }
 #endif
 
+#ifndef USE_MMAP
+# ifdef _WIN32
+static inline void map_exec(void *addr, long size)
+{
+    DWORD old_protect;
+    VirtualProtect(addr, size,
+                   PAGE_EXECUTE_READWRITE, &old_protect);
+}
+# else
+static inline void map_exec(void *addr, long size)
+{
+    unsigned long start, end, page_size;
+
+    page_size = getpagesize();
+    start = (unsigned long)addr;
+    start &= ~(page_size - 1);
+
+    end = (unsigned long)addr + size;
+    end += page_size - 1;
+    end &= ~(page_size - 1);
+
+    mprotect((void *)start, end - start,
+             PROT_READ | PROT_WRITE | PROT_EXEC);
+}
+# endif
+#endif
+
 #ifdef USE_STATIC_CODE_GEN_BUFFER
 static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE]
     __attribute__((aligned(CODE_GEN_ALIGN)));
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-11-03 15:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-31  4:59 [Qemu-devel] [PATCH] translate-all: wrapped map_exec() in #ifdef SeokYeon Hwang
2014-10-31 18:30 ` Peter Maydell
2014-11-03  8:18   ` SeokYeon Hwang
2014-11-03  9:16     ` Michael Tokarev
2014-11-03 12:25       ` Peter Maydell
2014-11-03 14:27         ` Michael Tokarev
2014-11-03 15:05           ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).