From nobody Thu Nov 28 09:47:06 2024 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694153401; cv=none; d=zohomail.com; s=zohoarc; b=TNQqtaHZWDt5F20uzLzyDk+zFo730dNDTY+K0Nx1wSVetVV8gQTUh9b/nsCBEy3Hb67VSzACFWEdRcKA9YDPqLbAY6Drc1A74qu/5YO1KIOD/X/jK66A+SPU8r8eYqCIiYEr8cazKm/+jRUnXvMeolhOwZBKHd6k2wTL93rD0ao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153401; h=Content-Type: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=LPBDnNliWcR4/YKIzdIN9ar2Uubwbp/TYyz5T00Sd2A=; b=jcbUY3hXhE8nVhePVr7Spt67Sdl/6JOrY2/d18MLz8bkK0wAfjN2AGn97cj2FQHIiRtcVSZ/Dj9ofb2E7isMUbJDHxxz8jUWMSOOaEZjYgGVDUqh1JC3oIlS6mdCZAOrU/cami7wrJUH4RTcSmW/GKqpffbT9kvoQs/C16rePpg= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694153401005238.88809388680227; Thu, 7 Sep 2023 23:10:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUf2-0001yu-R2; Fri, 08 Sep 2023 02:08:08 -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 1qeUf1-0001w9-45 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:07 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUey-00088a-Nc for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:06 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c06f6f98c0so13951065ad.3 for ; Thu, 07 Sep 2023 23:08:03 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153282; x=1694758082; darn=nongnu.org; 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=LPBDnNliWcR4/YKIzdIN9ar2Uubwbp/TYyz5T00Sd2A=; b=OXnwgD8cHDP7uvocyYla1PFD5Ejnw0q3WIvFBW2JEeCWFuRZRFYTueImYB6gsnyQVX xHeCO06kgMtff78pYhWxOfhgnaE+EdPJq49xXlH9WHtddvF7tt8SeYsraZFMx+tCqRwl R7HqmC854tj/j47HBc6uShwGgZfmEIQa1pdMFFgwUfhTAHjKwTWReEtUmD0XWrD94r8a mOpw5OpZ5YwjP1EjtPLXOC49RdtsF2mz9Ck/elWU/S5ulON+PtM2WnjeC+5il9vk66sP kRxN3v/0KNxYifB5fGgVwGHRPks2AS8iqImxwc/2qtVIwQIZMtT74c+wKI6jcres/Un8 y7ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153282; x=1694758082; 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=LPBDnNliWcR4/YKIzdIN9ar2Uubwbp/TYyz5T00Sd2A=; b=LgOLxTnfcjFo4XIIcbgiS/U8PgmTEhrQN3hMKH2QEz5JoBsKT96zBYrqVzdkFu3UHd NcAUP4hh+akA1F110HNWNcGsc6j/OAWf2vAlT9yV7JORJZDEWZDQIo6oeLN3qtPx8Ugp mgoBaY3djFJhv/DHs3gHYZGy5Ul5T4Hoy0bXNGVyYQDFbcxCi0l/mfQHR2WhqEV5aSd8 eUYDoy2ioB2M7LdyE4qemnNjRe2R3JubTEUQ5/x9/3v/hyQ3K6k4Zzo/jMkHZ+qut4Rc zN9kcBB9owHPOVdw7PinK2s6NgSkd2O6VeM/9dCw3oPEH6Ldh5CWjMCzjXZKdHqUEhpu VnMg== X-Gm-Message-State: AOJu0Yw3DLcd35jdRpgibrnoOUzqzeu54Jn9xyyISu/hCjfaOccqI9Eq EM69P4Mf5SpDIO7PYl9eahX//BmsC95rEJNS X-Google-Smtp-Source: AGHT+IFeojGqtnHqUlvvj+wAdJE2zl97nFGRpFv9tasW2UUDjBnWvMrWiCatdHx5L92jfKT5qt5JgA== X-Received: by 2002:a17:903:2303:b0:1bd:e998:ec0a with SMTP id d3-20020a170903230300b001bde998ec0amr1834730plh.67.1694153281945; Thu, 07 Sep 2023 23:08:01 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Andrew Jones , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 49/65] target/riscv: add DEFINE_PROP_END_OF_LIST() to riscv_cpu_options[] Date: Fri, 8 Sep 2023 16:04:15 +1000 Message-ID: <20230908060431.1903919-50-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2607:f8b0:4864:20::635; envelope-from=alistair23@gmail.com; helo=mail-pl1-x635.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 @gmail.com) X-ZM-MESSAGEID: 1694153402969100013 From: Daniel Henrique Barboza Add DEFINE_PROP_END_OF_LIST() and eliminate the ARRAY_SIZE() usage when iterating in the riscv_cpu_options[] array, making it similar to what we already do when working with riscv_cpu_extensions[]. We also have a more sophisticated motivation behind this change. In the future we might need to export riscv_cpu_options[] to other files, and ARRAY_LIST() doesn't work properly in that case because the array size isn't exposed to the header file. Here's a future sight of what we would deal with: ./target/riscv/kvm.c:1057:5: error: nested extern declaration of 'riscv_cpu= _add_misa_properties' [-Werror=3Dnested-externs] n file included from ../target/riscv/kvm.c:19: home/danielhb/work/qemu/include/qemu/osdep.h:473:31: error: invalid applica= tion of 'sizeof' to incomplete type 'const RISCVCPUMultiExtConfig[]' 473 | #define ARRAY_SIZE(x) ((sizeof(x) / sizeof((x)[0])) + \ | ^ ./target/riscv/kvm.c:1047:29: note: in expansion of macro 'ARRAY_SIZE' 1047 | for (int i =3D 0; i < ARRAY_SIZE(_array); i++) { \ | ^~~~~~~~~~ ./target/riscv/kvm.c:1059:5: note: in expansion of macro 'ADD_UNAVAIL_KVM_P= ROP_ARRAY' 1059 | ADD_UNAVAIL_KVM_PROP_ARRAY(obj, riscv_cpu_extensions); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ home/danielhb/work/qemu/include/qemu/osdep.h:473:31: error: invalid applica= tion of 'sizeof' to incomplete type 'const RISCVCPUMultiExtConfig[]' 473 | #define ARRAY_SIZE(x) ((sizeof(x) / sizeof((x)[0])) + \ | ^ ./target/riscv/kvm.c:1047:29: note: in expansion of macro 'ARRAY_SIZE' 1047 | for (int i =3D 0; i < ARRAY_SIZE(_array); i++) { \ Homogenize the present and change the future by using DEFINE_PROP_END_OF_LIST() in riscv_cpu_options[]. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-ID: <20230901194627.1214811-5-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 8e6d316500..8662414906 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1922,6 +1922,8 @@ static Property riscv_cpu_options[] =3D { =20 DEFINE_PROP_UINT16("cbom_blocksize", RISCVCPU, cfg.cbom_blocksize, 64), DEFINE_PROP_UINT16("cboz_blocksize", RISCVCPU, cfg.cboz_blocksize, 64), + + DEFINE_PROP_END_OF_LIST(), }; =20 #ifndef CONFIG_USER_ONLY @@ -1973,12 +1975,12 @@ static void riscv_cpu_add_kvm_properties(Object *ob= j) riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } =20 - for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { + for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { /* Check if KVM created the property already */ - if (object_property_find(obj, riscv_cpu_options[i].name)) { + if (object_property_find(obj, prop->name)) { continue; } - qdev_property_add_static(dev, &riscv_cpu_options[i]); + qdev_property_add_static(dev, prop); } } #endif @@ -2009,8 +2011,8 @@ static void riscv_cpu_add_user_properties(Object *obj) qdev_property_add_static(dev, prop); } =20 - for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { - qdev_property_add_static(dev, &riscv_cpu_options[i]); + for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { + qdev_property_add_static(dev, prop); } } =20 --=20 2.41.0