On 8/20/26 13:13, Philippe Mathieu-Daudé wrote:
init_main_thread() is registered as Object::free() hook, thus
take an Object* argument. Uncast the void pointer as such.

While now cpu_env() accept any pointer type, next commit will
restrict it to CPUState* type. QOM-cast the Object to CPU type,
otherwise we will get:

   ../linux-user/i386/cpu_loop.c: In function ‘target_cpu_free’:
   include/hw/core/cpu.h:604:31: error: ‘_Generic’ selector of type ‘void’ is 
not compatible with any association
../linux-user/x86_64/../i386/cpu_loop.c:331:19: note: in expansion of macro 
‘cpu_env’
   331 |     target_munmap(cpu_env(obj)->gdt.base,
       |                   ^~~~~~~

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
  linux-user/i386/cpu_loop.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c
index fe922fceb5a..a0790f3f352 100644
--- a/linux-user/i386/cpu_loop.c
+++ b/linux-user/i386/cpu_loop.c
@@ -326,9 +326,10 @@ void cpu_loop(CPUX86State *env)
      }
  }
-static void target_cpu_free(void *obj)
+static void target_cpu_free(void *ptr)
  {
-    target_munmap(cpu_env(obj)->gdt.base,
+    Object *obj = ptr;
+    target_munmap(cpu_env(CPU(obj))->gdt.base,

If you're going to have any dynamic cast, you might as well use

   X86_CPU(obj)->env.gdt.base.

Otherwise,
Reviewed-by: Richard Henderson <[email protected]>


r~

Reply via email to