|
From: | Avi Kivity |
Subject: | [Qemu-devel] Re: [PATCH 21/32] get_env accel wrapper |
Date: | Thu, 23 Oct 2008 15:36:10 +0200 |
User-agent: | Thunderbird 2.0.0.16 (X11/20080723) |
Glauber Costa wrote:
From: Glauber Costa <address@hidden> Allow the current accelerator to provide it's own, customized address of the CPUState structure used for the env variable./* Accelerator wrapper for the no-accel (raw qemu) case */@@ -21,6 +26,7 @@ QEMUAccel noaccel = { .name = "none", .cpu_interrupt = accel_nop, .init_env = accel_nop, + .get_env = noaccel_get_env,
.create_env() ?
+typedef struct KQEMUCPUstate {+ int kqemu_enabled; + int last_io_time; + CPUState env;
Tradition is to put it as the first member.
+} KQEMUCPUState; + +#define kqemu_cpu_field(env, field) (*({ \ + KQEMUCPUState *__c = container_of(env, KQEMUCPUState, env); \ + &__c->field; }))
This is evil. The resulting code is less readable.I'd prefer a KQEMUCPUState *kqemu_state(CPUState *env) { ... } even though it means one more line of code per usage.
-- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.
[Prev in Thread] | Current Thread | [Next in Thread] |