From nobody Sun Feb 8 22:34:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1690497457; cv=none; d=zohomail.com; s=zohoarc; b=jutXbDYbyQlX2uthWpOGjGRp1co/o248WTYbC9jOCHvYT5yigd9CjwsEzuXBStHm1BGamGxL4HZ0zrNLCd8HCGkw0iWUPLK13/j6eMEhuz4LgD9xPxN5YP/wLUZzqnZXcsBYa8+4MfhIlqV240Ud9JZN0QVB1XgXDVvdNenwyi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690497457; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oF5CeMRc1qhvGJ6s6NeTiIJwq3Ap4HqQ5wxvWLCfVCo=; b=JW/9XbSkKxaaT5B15zhRLrX5RfmsHGvSrXOqs7wPA/KLJorOOboSncCVY+zKZj+jZYryVI3iVZsDMchKNob0lXyVaR4deqMUlIdUpqyNhJh/9cTp1zzEYhPq3YkblUBebmPMWeyry5k43Vb6/ITdGZ3QSxbCHJJEXluUT8jSlC4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690497457434901.8234595210359; Thu, 27 Jul 2023 15:37:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP9BD-0001MR-Ab; Thu, 27 Jul 2023 18:09:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qP9BB-0001LZ-Ff for qemu-devel@nongnu.org; Thu, 27 Jul 2023 18:09:53 -0400 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qP9B9-0004uZ-RJ for qemu-devel@nongnu.org; Thu, 27 Jul 2023 18:09:53 -0400 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-1bbb9fcac6bso905609fac.1 for ; Thu, 27 Jul 2023 15:09:51 -0700 (PDT) Received: from grind.. (201-69-66-36.dial-up.telesp.net.br. [201.69.66.36]) by smtp.gmail.com with ESMTPSA id y136-20020a4a458e000000b0051134f333d3sm1070471ooa.16.2023.07.27.15.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 15:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1690495790; x=1691100590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oF5CeMRc1qhvGJ6s6NeTiIJwq3Ap4HqQ5wxvWLCfVCo=; b=lrgT0uwHdRvKybCBv3GmxnJoi3hIHXhFJ7Cr9Wap6VuYU2/PocH74CJjQCxm159WKJ Ly5d7YSKRCaZCd+oHpTz72L/8qMn28PXJ+R+/wWANiy1qOwDJjrSbSaqTn+g6MqM5sEW nSJBX0yCRusNtIhynBSoHJEWR7Zdyxu/cqZ3yDr6qsaTldaVC2si/ZNX66Iz4cm45G1W yUDv371lz5Zznz4Bxz5RxJFce/LlFfLWdlvBu2Y7h3a/OLl6s09YEzyNWwkEnIaWHmvq zLg5FtFM5IbCzYDX6w0ycZSE6TzxZXNS8/DpIvwl37VVTgi6kZwzIDQo8j6Mnh04TehX sgyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690495790; x=1691100590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oF5CeMRc1qhvGJ6s6NeTiIJwq3Ap4HqQ5wxvWLCfVCo=; b=lxCV1fjRId++qkTukPP3eSdeV0W/RqW229mshoLHsL2SER9+dggCvOvpCWxWrTgkPP 1cjpk64fHYw4d3eU/CCuSxDPzTiN+/JnQ/Ci51kR/nwsYgbge2Es5v7YrJ/JDKqDi2tu dyCDBdxc7kxVFfos2+RLCbhAYca634923hpwJCwRO9naDgpL9M0owy5Qtb8Q68phLpPu H1g0zpY7G5HQODCb0hIBWa44WziiN/25M6Q3RA4vXUrqUtmAQHIS8/yjgnfcoq5TipBs LOgY1ZEm2e95cvAVh+UEh2W4iqDLXcvaS9LPF7vBzGLs5JyHlH3PhUb7PYfbm5NJWPrB 6SWw== X-Gm-Message-State: ABy/qLZkYGHEwDhoMrIw6feVoRvDfv8oNit0TQNcXNrTWHWBPK4YNJCw nOklmPAacn2nlvtB2njiFHFS1SJYGqcdxsXcnjzf9w== X-Google-Smtp-Source: APBJJlHjNi6YL/4AEgs7jPr3V2XZ5+wh7kRVoC0845o2ygbQUarL87dDYCJBhKVKJl+C9f681Y+r8g== X-Received: by 2002:a05:6871:b0d:b0:1ba:dabb:d5da with SMTP id fq13-20020a0568710b0d00b001badabbd5damr3188735oab.15.1690495790603; Thu, 27 Jul 2023 15:09:50 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, Daniel Henrique Barboza Subject: [PATCH v6 07/12] target/riscv/cpu.c: add ADD_CPU_QDEV_PROPERTIES_ARRAY() macro Date: Thu, 27 Jul 2023 19:09:22 -0300 Message-ID: <20230727220927.62950-8-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230727220927.62950-1-dbarboza@ventanamicro.com> References: <20230727220927.62950-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::30; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x30.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1690497460257100003 Content-Type: text/plain; charset="utf-8" The code inside riscv_cpu_add_user_properties() became quite repetitive after recent changes. Add a macro to hide the repetition away. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li --- target/riscv/cpu.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index d829517f40..971dcb2aec 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1882,6 +1882,13 @@ static void cpu_set_cfg_unavailable(Object *obj, Vis= itor *v, } #endif =20 +#define ADD_CPU_QDEV_PROPERTIES_ARRAY(_dev, _array) \ + do { \ + for (int i =3D 0; i < ARRAY_SIZE(_array); i++) { \ + qdev_property_add_static(_dev, &_array[i]); \ + } \ + } while (0) + #ifndef CONFIG_USER_ONLY static void riscv_cpu_add_kvm_unavail_prop(Object *obj, const char *prop_n= ame) { @@ -1951,21 +1958,10 @@ static void riscv_cpu_add_user_properties(Object *o= bj) =20 riscv_cpu_add_misa_properties(obj); =20 - for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_extensions); i++) { - qdev_property_add_static(dev, &riscv_cpu_extensions[i]); - } - - for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { - qdev_property_add_static(dev, &riscv_cpu_options[i]); - } - - for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_vendor_exts); i++) { - qdev_property_add_static(dev, &riscv_cpu_vendor_exts[i]); - } - - for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_experimental_exts); i++) { - qdev_property_add_static(dev, &riscv_cpu_experimental_exts[i]); - } + ADD_CPU_QDEV_PROPERTIES_ARRAY(dev, riscv_cpu_extensions); + ADD_CPU_QDEV_PROPERTIES_ARRAY(dev, riscv_cpu_options); + ADD_CPU_QDEV_PROPERTIES_ARRAY(dev, riscv_cpu_vendor_exts); + ADD_CPU_QDEV_PROPERTIES_ARRAY(dev, riscv_cpu_experimental_exts); } =20 static Property riscv_cpu_properties[] =3D { --=20 2.41.0