From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8ItG-0006kW-TQ for qemu-devel@nongnu.org; Thu, 15 Mar 2012 18:11:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S8Isw-00057T-3d for qemu-devel@nongnu.org; Thu, 15 Mar 2012 18:11:22 -0400 Received: from mail-bk0-f45.google.com ([209.85.214.45]:45536) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8Isv-000575-Qc for qemu-devel@nongnu.org; Thu, 15 Mar 2012 18:11:02 -0400 Received: by bkcjg9 with SMTP id jg9so3092932bkc.4 for ; Thu, 15 Mar 2012 15:10:59 -0700 (PDT) Message-ID: <4F6268EC.8030109@gmail.com> Date: Fri, 16 Mar 2012 02:10:52 +0400 From: jcmvbkbc MIME-Version: 1.0 References: <1330893156-26569-1-git-send-email-afaerber@suse.de> <1331747617-7837-1-git-send-email-afaerber@suse.de> <1331747617-7837-13-git-send-email-afaerber@suse.de> In-Reply-To: <1331747617-7837-13-git-send-email-afaerber@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC 12/12] target-xtensa: QOM'ify CPU List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= Cc: qemu-devel@nongnu.org > Let xtensa_cpu_list() enumerate CPU classes alphabetically. > > Signed-off-by: Andreas Färber > --- [...] > diff --git a/gdbstub.c b/gdbstub.c > index f4e97f7..773e86f 100644 > --- a/gdbstub.c > +++ b/gdbstub.c > @@ -1570,14 +1570,17 @@ static int cpu_gdb_write_register(CPULM32State *env, uint8_t *mem_buf, int n) > * reset bit 0 in the 'flags' field of the registers definitions in the > * gdb/xtensa-config.c inside gdb source tree or inside gdb overlay. > */ > -#define NUM_CORE_REGS (env->config->gdb_regmap.num_regs) > +#define NUM_CORE_REGS \ > + (XTENSA_CPU_GET_CLASS(xtensa_env_get_cpu(env))->gdb_regmap.num_regs) > #define num_g_regs NUM_CORE_REGS > > static int cpu_gdb_read_register(CPUXtensaState *env, uint8_t *mem_buf, int n) > { > - const XtensaGdbReg *reg = env->config->gdb_regmap.reg + n; > + XtensaCPU *cpu = xtensa_env_get_cpu(env); > + XtensaCPUClass *klass = XTENSA_CPU_GET_CLASS(cpu); *klass* It's a bit strange to see patches that fix typos in comments and at the same time to deliberately introduce this kind of misspelling. I'd suggest to call it what it is: cpu_class. [...] > diff --git a/target-xtensa/overlay_tool.h b/target-xtensa/overlay_tool.h > index a3a5650..b46bca9 100644 > --- a/target-xtensa/overlay_tool.h > +++ b/target-xtensa/overlay_tool.h > @@ -291,16 +291,28 @@ > #endif > > #if (defined(TARGET_WORDS_BIGENDIAN) != 0) == (XCHAL_HAVE_BE != 0) > -#define REGISTER_CORE(core) \ > - static void __attribute__((constructor)) register_core(void) \ > +#define REGISTER_CORE(typename, class) \ > + static void core_class_init(ObjectClass *klass, void *data) \ > { \ > - static XtensaConfigList node = { \ > - .config =&core, \ > - }; \ > - xtensa_register_core(&node); \ > - } > + /* XXX This is a really ugly but easy way to init the class... */ \ > + memcpy((void *)klass + offsetof(XtensaCPUClass, options), \ > + (void *)&(class) + offsetof(XtensaCPUClass, options), \ > + sizeof(XtensaCPUClass) - offsetof(XtensaCPUClass, options)); \ > + } \ - void pointer arithmetic is non-standard; - (void *)&(class) + offsetof(XtensaCPUClass, options) looks suspicious, I don't think anything other than XtensaCPUClass instances should be passed here; I'd suggest the following replacement: memcpy(&((XtensaCPUClass *)klass)->options, \ &(class).options, \ sizeof(XtensaCPUClass) - offsetof(XtensaCPUClass, options)); \ [...] -- Thanks. -- Max