From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:43039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RuXhc-0000qQ-SQ for qemu-devel@nongnu.org; Mon, 06 Feb 2012 18:10:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RuXha-0000EE-BK for qemu-devel@nongnu.org; Mon, 06 Feb 2012 18:10:28 -0500 Received: from cantor2.suse.de ([195.135.220.15]:48993 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RuXha-0000E8-5P for qemu-devel@nongnu.org; Mon, 06 Feb 2012 18:10:26 -0500 Message-ID: <4F305D53.2040308@suse.de> Date: Tue, 07 Feb 2012 00:08:03 +0100 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1328237992-14953-1-git-send-email-afaerber@suse.de> <1328237992-14953-7-git-send-email-afaerber@suse.de> <4F305C50.9020107@codemonkey.ws> In-Reply-To: <4F305C50.9020107@codemonkey.ws> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH RFC v3 06/21] target-arm: Prepare model-specific class_init function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org Am 07.02.2012 00:03, schrieb Anthony Liguori: > On 02/02/2012 08:59 PM, Andreas F=C3=A4rber wrote: >> This allows to share initialization between CPU models. >> >> Signed-off-by: Andreas F=C3=A4rber >> --- >> target-arm/cpu.c | 5 +++++ >> 1 files changed, 5 insertions(+), 0 deletions(-) >> >> diff --git a/target-arm/cpu.c b/target-arm/cpu.c >> index 43231c9..b794ec1 100644 >> --- a/target-arm/cpu.c >> +++ b/target-arm/cpu.c >> @@ -96,6 +96,7 @@ static void arm_cpu_reset(CPU *c) >> typedef struct ARMCPUInfo { >> const char *name; >> uint32_t id; >> + void (*class_init)(ARMCPUClass *klass, const struct ARMCPUInfo >> *info); >> } ARMCPUInfo; >=20 > So could you do: >=20 > TypeInfo arm_cpus[] =3D { > { > .name =3D "arm-cpu-model", > .parent =3D TYPE_ARM_CPU, > .class_data =3D (void *)(intptr_t)0x2342342, > .class_init =3D arm_generic_init, > } >=20 > It's roughly the same code but then there isn't redirection. You can d= o > this in general by having something like: >=20 > .class_data =3D (SpecialInfo[]){ .id =3D 0x23423423 }, Have you reviewed the users of this? More fields are being added, and the specific users of this facility initialize fields not shared by many CPUs so I wanted to keep ARMCPUInfo small. The shared fields are already being initialized by arm_cpu_class_init() via .class_data. Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg