From nobody Wed Feb 11 02:54:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508215116164262.2486347509024; Mon, 16 Oct 2017 21:38:36 -0700 (PDT) Received: from localhost ([::1]:36415 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4JeA-0005He-CI for importer@patchew.org; Tue, 17 Oct 2017 00:38:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4JOZ-0008MU-0f for qemu-devel@nongnu.org; Tue, 17 Oct 2017 00:22:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4JOW-000720-6q for qemu-devel@nongnu.org; Tue, 17 Oct 2017 00:22:22 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:44211) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e4JOV-0006vm-PI; Tue, 17 Oct 2017 00:22:20 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3yGMTt5r9bz9t32; Tue, 17 Oct 2017 15:22:07 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1508214130; bh=X1HrGIDz7egO5OvJpCA2bWyriMxAUnlvQPQR5nJ22Bc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jQ2LqRboXR8ouOEQjyE83j9dPdSYNtMhDvKfFSjUdmUfKvsCGGnM+shXisG7H26au jyaxCOLoI391orHRvQhWWTBpi92FhNNodLQRgPoO6GELd3U/NqbD95kAQeLeHrnH+/ GWVw7Jxv9Q2YpD1wdheB5u5RcYyHNW1wYQD1hbrY= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 17 Oct 2017 15:21:27 +1100 Message-Id: <20171017042152.29443-10-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171017042152.29443-1-david@gibson.dropbear.id.au> References: <20171017042152.29443-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 09/34] qom: introduce type_register_static_array() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: agraf@suse.de, ehabkost@redhat.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, imammedo@redhat.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Igor Mammedov it will help to remove code duplication of registration static types in places that have open coded loop to perform batch type registering. Signed-off-by: Igor Mammedov Reviewed-by: Eduardo Habkost Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: David Gibson Signed-off-by: David Gibson --- include/qom/object.h | 10 ++++++++++ qom/object.c | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index a707b67781..9a2369c67b 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -789,6 +789,16 @@ Type type_register_static(const TypeInfo *info); Type type_register(const TypeInfo *info); =20 /** + * type_register_static_array: + * @infos: The array of the new type #TypeInfo structures. + * @nr_infos: number of entries in @infos + * + * @infos and all of the strings it points to should exist for the life ti= me + * that the type is registered. + */ +void type_register_static_array(const TypeInfo *infos, int nr_infos); + +/** * object_class_dynamic_cast_assert: * @klass: The #ObjectClass to attempt to cast. * @typename: The QOM typename of the class to cast to. diff --git a/qom/object.c b/qom/object.c index 6a7bd9257b..c58c52d518 100644 --- a/qom/object.c +++ b/qom/object.c @@ -151,6 +151,15 @@ TypeImpl *type_register_static(const TypeInfo *info) return type_register(info); } =20 +void type_register_static_array(const TypeInfo *infos, int nr_infos) +{ + int i; + + for (i =3D 0; i < nr_infos; i++) { + type_register_static(&infos[i]); + } +} + static TypeImpl *type_get_by_name(const char *name) { if (name =3D=3D NULL) { --=20 2.13.6