qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/4] osdep: Un-inline qemu_thread_jit_execute/write


From: Philippe Mathieu-Daudé
Subject: [PATCH 2/4] osdep: Un-inline qemu_thread_jit_execute/write
Date: Tue, 15 Feb 2022 13:06:23 +0100

qemu_thread_jit_execute() and qemu_thread_jit_write() call
pthread_jit_write_protect_np() which is declared in "pthread.h".
Since we don't want all C files to preprocess unused headers,
avoid adding yet another header here and move the function
definitions to osdep.c, un-inlining them.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/qemu/osdep.h | 17 ++---------------
 util/osdep.c         | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 1e7a002339..785884728b 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -773,21 +773,8 @@ size_t qemu_get_host_physmem(void);
  * Toggle write/execute on the pages marked MAP_JIT
  * for the current thread.
  */
-#if defined(MAC_OS_VERSION_11_0) && \
-    MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
-static inline void qemu_thread_jit_execute(void)
-{
-    pthread_jit_write_protect_np(true);
-}
-
-static inline void qemu_thread_jit_write(void)
-{
-    pthread_jit_write_protect_np(false);
-}
-#else
-static inline void qemu_thread_jit_write(void) {}
-static inline void qemu_thread_jit_execute(void) {}
-#endif
+void qemu_thread_jit_execute(void);
+void qemu_thread_jit_write(void);
 
 /**
  * Platforms which do not support system() return ENOSYS
diff --git a/util/osdep.c b/util/osdep.c
index 42a0a4986a..b228a53612 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -124,6 +124,26 @@ int qemu_mprotect_none(void *addr, size_t size)
 #endif
 }
 
+static void qemu_pthread_jit_write_protect(bool enabled)
+{
+#if defined(MAC_OS_VERSION_11_0) \
+        && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
+    if (__builtin_available(macOS 11.0, *)) {
+        pthread_jit_write_protect_np(enabled);
+    }
+#endif
+}
+
+void qemu_thread_jit_execute(void)
+{
+    qemu_pthread_jit_write_protect(true);
+}
+
+void qemu_thread_jit_write(void)
+{
+    qemu_pthread_jit_write_protect(false);
+}
+
 #ifndef _WIN32
 
 static int fcntl_op_setlk = -1;
-- 
2.34.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]