diff mbox series

[8/9] user: Declare target-agnostic prototypes in 'user/cpu-common.h'

Message ID 20220209230030.93987-9-f4bug@amsat.org (mailing list archive)
State New, archived
Headers show
Series exec: Split some user-mode specific declarations from 'exec/exec-all.h' | expand

Commit Message

Philippe Mathieu-Daudé Feb. 9, 2022, 11 p.m. UTC
Move user-mode common prototypes from "exec/exec-all.h"
to "user/cpu-common.h".

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 bsd-user/qemu.h             |  2 --
 include/exec/cpu-all.h      |  3 +--
 include/exec/exec-all.h     | 10 ----------
 include/user/cpu-common.h   | 36 ++++++++++++++++++++++++++++++++++++
 include/user/cpu-target.h   |  1 +
 linux-user/exit.c           |  3 +--
 linux-user/user-internals.h | 10 ----------
 7 files changed, 39 insertions(+), 26 deletions(-)
 create mode 100644 include/user/cpu-common.h
diff mbox series

Patch

diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 2f67776b0b..afaf94412e 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -182,8 +182,6 @@  abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
                             abi_long arg2, abi_long arg3, abi_long arg4,
                             abi_long arg5, abi_long arg6);
 void gemu_log(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
-extern __thread CPUState *thread_cpu;
-void cpu_loop(CPUArchState *env);
 char *target_strerror(int err);
 int get_osversion(void);
 void fork_start(void);
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 08b2894274..e9cf20560f 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -296,9 +296,8 @@  void *page_alloc_target_data(target_ulong address, size_t size);
  * at @address, as per page_alloc_target_data.
  */
 void *page_get_target_data(target_ulong address);
-#endif
 
-CPUArchState *cpu_copy(CPUArchState *env);
+#endif /* CONFIG_USER_ONLY */
 
 /* Flags for use in ENV->INTERRUPT_PENDING.
 
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index e8f14b6844..545cc16a67 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -639,16 +639,6 @@  static inline tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env,
     return addr;
 }
 
-/**
- * adjust_signal_pc:
- * @pc: raw pc from the host signal ucontext_t.
- * @is_write: host memory operation was write, or read-modify-write.
- *
- * Alter @pc as required for unwinding.  Return the type of the
- * guest memory access -- host reads may be for guest execution.
- */
-MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write);
-
 #else
 static inline void mmap_lock(void) {}
 static inline void mmap_unlock(void) {}
diff --git a/include/user/cpu-common.h b/include/user/cpu-common.h
new file mode 100644
index 0000000000..267acb143a
--- /dev/null
+++ b/include/user/cpu-common.h
@@ -0,0 +1,36 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * cpu-target.h: user-mode target-agnostic execution prototypes
+ *
+ */
+
+#ifndef USER_CPU_COMMON_H
+#define USER_CPU_COMMON_H
+
+#include "exec/cpu-tlb.h"
+
+extern __thread CPUState *thread_cpu;
+
+/**
+ * adjust_signal_pc:
+ * @pc: raw pc from the host signal ucontext_t.
+ * @is_write: host memory operation was write, or read-modify-write.
+ *
+ * Alter @pc as required for unwinding.  Return the type of the
+ * guest memory access -- host reads may be for guest execution.
+ */
+MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write);
+
+void QEMU_NORETURN cpu_loop(CPUArchState *env);
+
+CPUArchState *cpu_copy(CPUArchState *env);
+
+/**
+ * preexit_cleanup: housekeeping before the guest exits
+ *
+ * env: the CPU state
+ * code: the exit code
+ */
+void preexit_cleanup(CPUArchState *env, int code);
+
+#endif
diff --git a/include/user/cpu-target.h b/include/user/cpu-target.h
index e621fb9f3d..4fbdb35fa4 100644
--- a/include/user/cpu-target.h
+++ b/include/user/cpu-target.h
@@ -9,6 +9,7 @@ 
 
 #include "exec/cpu-tlb.h"
 #include "exec/cpu_ldst.h" /* abi_ptr */
+#include "user/cpu-common.h"
 
 /**
  * handle_sigsegv_accerr_write:
diff --git a/linux-user/exit.c b/linux-user/exit.c
index 10989f17f8..2c8a8dd75d 100644
--- a/linux-user/exit.c
+++ b/linux-user/exit.c
@@ -19,8 +19,7 @@ 
 #include "qemu/osdep.h"
 #include "qemu/plugin.h"
 #include "exec/gdbstub.h"
-#include "qemu.h"
-#include "user-internals.h"
+#include "user/cpu-common.h"
 #ifdef CONFIG_GPROF
 #include <sys/gmon.h>
 #endif
diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h
index 4d0f682aea..d17f3c9300 100644
--- a/linux-user/user-internals.h
+++ b/linux-user/user-internals.h
@@ -63,8 +63,6 @@  abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                     abi_long arg2, abi_long arg3, abi_long arg4,
                     abi_long arg5, abi_long arg6, abi_long arg7,
                     abi_long arg8);
-extern __thread CPUState *thread_cpu;
-void QEMU_NORETURN cpu_loop(CPUArchState *env);
 const char *target_strerror(int err);
 int get_osversion(void);
 void init_qemu_uname_release(void);
@@ -166,14 +164,6 @@  static inline int regpairs_aligned(void *cpu_env, int num) { return 1; }
 static inline int regpairs_aligned(void *cpu_env, int num) { return 0; }
 #endif
 
-/**
- * preexit_cleanup: housekeeping before the guest exits
- *
- * env: the CPU state
- * code: the exit code
- */
-void preexit_cleanup(CPUArchState *env, int code);
-
 /*
  * Include target-specific struct and function definitions;
  * they may need access to the target-independent structures