Received: from eggs.gnu.org ([2001:4830:134:3::10]:47538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdJMd-0008GS-Tl for qemu-devel@nongnu.org; Sat, 19 Sep 2015 10:43:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZdJMd-0006df-32 for qemu-devel@nongnu.org; Sat, 19 Sep 2015 10:43:43 -0400 Received: from mx2.suse.de ([195.135.220.15]:40377) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdJMc-0006dR-Sx for qemu-devel@nongnu.org; Sat, 19 Sep 2015 10:43:43 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sat, 19 Sep 2015 16:43:26 +0200 Message-Id: <1442673810-2679-18-git-send-email-afaerber@suse.de> In-Reply-To: <1442673810-2679-1-git-send-email-afaerber@suse.de> References: <1442673810-2679-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 17/21] machine: DEFINE_MACHINE() macro List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Eduardo Habkost , =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Eduardo Habkost The macro will allow easy registration of a TYPE_MACHINE subclass, using only the machine name and a MachineClass initialization function as parameter. Signed-off-by: Eduardo Habkost Signed-off-by: Andreas F=C3=A4rber --- include/hw/boards.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/hw/boards.h b/include/hw/boards.h index 586f939..4fe2ce5 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -159,4 +159,21 @@ struct MachineState { AccelState *accelerator; }; =20 +#define DEFINE_MACHINE(namestr, machine_initfn) \ + static void machine_initfn##_class_init(ObjectClass *oc, void *data)= \ + { \ + MachineClass *mc =3D MACHINE_CLASS(oc); \ + machine_initfn(mc); \ + } \ + static const TypeInfo machine_initfn##_typeinfo =3D { \ + .name =3D MACHINE_TYPE_NAME(namestr), \ + .parent =3D TYPE_MACHINE, \ + .class_init =3D machine_initfn##_class_init, \ + }; \ + static void machine_initfn##_register_types(void) \ + { \ + type_register_static(&machine_initfn##_typeinfo); \ + } \ + machine_init(machine_initfn##_register_types) + #endif --=20 2.1.4