From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kt0ML-0006KC-9Y for qemu-devel@nongnu.org; Thu, 23 Oct 2008 09:36:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kt0MG-0006IY-Nm for qemu-devel@nongnu.org; Thu, 23 Oct 2008 09:36:14 -0400 Received: from [199.232.76.173] (port=57267 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kt0MG-0006I4-9o for qemu-devel@nongnu.org; Thu, 23 Oct 2008 09:36:12 -0400 Received: from mx2.redhat.com ([66.187.237.31]:40483) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kt0ME-0001MD-Ud for qemu-devel@nongnu.org; Thu, 23 Oct 2008 09:36:11 -0400 Message-ID: <49007DCA.3030308@redhat.com> Date: Thu, 23 Oct 2008 15:36:10 +0200 From: Avi Kivity MIME-Version: 1.0 References: <1224771556-11146-1-git-send-email-glommer@redhat.com> <1224771556-11146-22-git-send-email-glommer@redhat.com> In-Reply-To: <1224771556-11146-22-git-send-email-glommer@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 21/32] get_env accel wrapper Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Glauber Costa Cc: aliguori@us.ibm.com, jan.kiszka@siemens.com, jes@sgi.com, qemu-devel@nongnu.org, Glauber Costa , dmitry.baryshkov@siemens.com Glauber Costa wrote: > From: Glauber Costa > > 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.