diff mbox series

[RFC,16/34] exec: [CPUTLB] Move cpu_*()/cpu_env() to common header

Message ID 20240119144024.14289-17-anjo@rev.ng (mailing list archive)
State New, archived
Headers show
Series Compile accel/tcg once (partially) | expand

Commit Message

Anton Johansson Jan. 19, 2024, 2:40 p.m. UTC
Functions are target independent.

Signed-off-by: Anton Johansson <anjo@rev.ng>
---
 include/exec/cpu-all.h    | 25 -------------------------
 include/exec/cpu-common.h | 25 +++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 25 deletions(-)

Comments

Richard Henderson Jan. 24, 2024, 12:15 a.m. UTC | #1
On 1/20/24 00:40, Anton Johansson wrote:
> Functions are target independent.
> 
> Signed-off-by: Anton Johansson<anjo@rev.ng>
> ---
>   include/exec/cpu-all.h    | 25 -------------------------
>   include/exec/cpu-common.h | 25 +++++++++++++++++++++++++
>   2 files changed, 25 insertions(+), 25 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Richard Henderson Jan. 27, 2024, 10:14 p.m. UTC | #2
On 1/20/24 00:40, Anton Johansson wrote:
> --- a/include/exec/cpu-common.h
> +++ b/include/exec/cpu-common.h
> @@ -347,4 +347,29 @@ G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc);
>    */
>   #define PAGE_PASSTHROUGH 0x0800
>   
> +/* accel/tcg/cpu-exec.c */
> +int cpu_exec(CPUState *cpu);
> +
> +/**
> + * env_archcpu(env)
> + * @env: The architecture environment
> + *
> + * Return the ArchCPU associated with the environment.
> + */
> +static inline ArchCPU *env_archcpu(CPUArchState *env)
> +{
> +    return (void *)env - sizeof(CPUState);
> +}
> +
> +/**
> + * env_cpu(env)
> + * @env: The architecture environment
> + *
> + * Return the CPUState associated with the environment.
> + */
> +static inline CPUState *env_cpu(CPUArchState *env)
> +{
> +    return (void *)env - sizeof(CPUState);
> +}
> +
>   #endif /* CPU_COMMON_H */

Missing include of hw/core/cpu.h, as far as I can see?


r~
Richard Henderson Jan. 28, 2024, 12:15 a.m. UTC | #3
On 1/28/24 08:14, Richard Henderson wrote:
> On 1/20/24 00:40, Anton Johansson wrote:
>> --- a/include/exec/cpu-common.h
>> +++ b/include/exec/cpu-common.h
>> @@ -347,4 +347,29 @@ G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc);
>>    */
>>   #define PAGE_PASSTHROUGH 0x0800
>> +/* accel/tcg/cpu-exec.c */
>> +int cpu_exec(CPUState *cpu);
>> +
>> +/**
>> + * env_archcpu(env)
>> + * @env: The architecture environment
>> + *
>> + * Return the ArchCPU associated with the environment.
>> + */
>> +static inline ArchCPU *env_archcpu(CPUArchState *env)
>> +{
>> +    return (void *)env - sizeof(CPUState);
>> +}
>> +
>> +/**
>> + * env_cpu(env)
>> + * @env: The architecture environment
>> + *
>> + * Return the CPUState associated with the environment.
>> + */
>> +static inline CPUState *env_cpu(CPUArchState *env)
>> +{
>> +    return (void *)env - sizeof(CPUState);
>> +}
>> +
>>   #endif /* CPU_COMMON_H */
> 
> Missing include of hw/core/cpu.h, as far as I can see?

Queued, with this fix.

r~
diff mbox series

Patch

diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 968fbd4d16..4778976c4b 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -295,33 +295,8 @@  CPUArchState *cpu_copy(CPUArchState *env);
      | CPU_INTERRUPT_TGT_EXT_3   \
      | CPU_INTERRUPT_TGT_EXT_4)
 
-/* accel/tcg/cpu-exec.c */
-int cpu_exec(CPUState *cpu);
-
 /* Validate correct placement of CPUArchState. */
 QEMU_BUILD_BUG_ON(offsetof(ArchCPU, parent_obj) != 0);
 QEMU_BUILD_BUG_ON(offsetof(ArchCPU, env) != sizeof(CPUState));
 
-/**
- * env_archcpu(env)
- * @env: The architecture environment
- *
- * Return the ArchCPU associated with the environment.
- */
-static inline ArchCPU *env_archcpu(CPUArchState *env)
-{
-    return (void *)env - sizeof(CPUState);
-}
-
-/**
- * env_cpu(env)
- * @env: The architecture environment
- *
- * Return the CPUState associated with the environment.
- */
-static inline CPUState *env_cpu(CPUArchState *env)
-{
-    return (void *)env - sizeof(CPUState);
-}
-
 #endif /* CPU_ALL_H */
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index d3c8b2cf55..25e50aaa37 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -347,4 +347,29 @@  G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc);
  */
 #define PAGE_PASSTHROUGH 0x0800
 
+/* accel/tcg/cpu-exec.c */
+int cpu_exec(CPUState *cpu);
+
+/**
+ * env_archcpu(env)
+ * @env: The architecture environment
+ *
+ * Return the ArchCPU associated with the environment.
+ */
+static inline ArchCPU *env_archcpu(CPUArchState *env)
+{
+    return (void *)env - sizeof(CPUState);
+}
+
+/**
+ * env_cpu(env)
+ * @env: The architecture environment
+ *
+ * Return the CPUState associated with the environment.
+ */
+static inline CPUState *env_cpu(CPUArchState *env)
+{
+    return (void *)env - sizeof(CPUState);
+}
+
 #endif /* CPU_COMMON_H */