[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v3 08/56] cpu: define cpu_halted helpers
From: |
Emilio G. Cota |
Subject: |
[Qemu-devel] [RFC v3 08/56] cpu: define cpu_halted helpers |
Date: |
Thu, 18 Oct 2018 21:05:37 -0400 |
cpu->halted will soon be protected by cpu->lock.
We will use these helpers to ease the transition,
since right now cpu->halted has many direct callers.
Signed-off-by: Emilio G. Cota <address@hidden>
---
include/qom/cpu.h | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 30d1c260dc..3bf6767cb0 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -480,6 +480,30 @@ void cpu_mutex_unlock_impl(CPUState *cpu, const char
*file, int line);
*/
bool cpu_mutex_locked(const CPUState *cpu);
+static inline uint32_t cpu_halted(CPUState *cpu)
+{
+ uint32_t ret;
+
+ if (cpu_mutex_locked(cpu)) {
+ return cpu->halted;
+ }
+ cpu_mutex_lock(cpu);
+ ret = cpu->halted;
+ cpu_mutex_unlock(cpu);
+ return ret;
+}
+
+static inline void cpu_halted_set(CPUState *cpu, uint32_t val)
+{
+ if (cpu_mutex_locked(cpu)) {
+ cpu->halted = val;
+ return;
+ }
+ cpu_mutex_lock(cpu);
+ cpu->halted = val;
+ cpu_mutex_unlock(cpu);
+}
+
static inline void cpu_tb_jmp_cache_clear(CPUState *cpu)
{
unsigned int i;
--
2.17.1
- Re: [Qemu-devel] [RFC v3 06/56] cpu: introduce process_queued_cpu_work_locked, (continued)
- [Qemu-devel] [RFC v3 02/56] cpu: rename cpu->work_mutex to cpu->lock, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 10/56] ppc: convert to cpu_halted, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 13/56] lm32: convert to cpu_halted, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 01/56] cpu: convert queued work to a QSIMPLEQ, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 08/56] cpu: define cpu_halted helpers,
Emilio G. Cota <=
- [Qemu-devel] [RFC v3 09/56] arm: convert to cpu_halted, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 16/56] riscv: convert to cpu_halted, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 07/56] target/m68k: rename cpu_halted to cpu_halt, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 20/56] gdbstub: convert to cpu_halted, Emilio G. Cota, 2018/10/18