From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9B96A43305; Sat, 11 Nov 2023 18:22:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3132A400D7; Sat, 11 Nov 2023 18:22:07 +0100 (CET) Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by mails.dpdk.org (Postfix) with ESMTP id 5984D4003C for ; Sat, 11 Nov 2023 18:22:05 +0100 (CET) Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6c4ed8eef16so1370830b3a.0 for ; Sat, 11 Nov 2023 09:22:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1699723324; x=1700328124; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PC0tP40B68ZGVM++B9T1EWbvXNickRJ5PPZZhNPAM8Q=; b=GlfTOIq/Kv2f1iNaQX+qd9xVXrC9Z9fN18O0tcQnkgCq877FlWqxx2zJhxGtUhFmro 3ZIRt3j9HXAdAQ1m6KcjnU4nQshGaUnQLoEqPvDG0QOpDr3DwWcgLOrm6SwGDnP6hgT9 ThaBvfVPAdG9DDWebbp4/K9HUJx400B+aMghiO6eZUYLu95AGnczqTsqjW2dQgxIa9h1 gaPVJ5l+oRdCWhLUmFG1JbAEf+fcAOjaQT6weunyN+tIck8r0Y287dKj75jz7ASzYkAn c0x5LjMwXihXG+hiQInISMiWRWOKG1vgYkn5g4TROll4ccXIVIKQmt/zDnUPzmVoTgwI 89Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699723324; x=1700328124; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PC0tP40B68ZGVM++B9T1EWbvXNickRJ5PPZZhNPAM8Q=; b=MQ2aNMp3Nz0ybXw4Yo3p3n2vaUfbFP0reNyE0Xj02q3nD2UZDGfOJ7Sxv6FhoK3wiX sgQ8Hw281DMzkluzffSiJvs0JIbaH61gONJQ4PUpG4XVdsxvhSbSPHr+5W78xomoEELY qYZxVHl4wy65pulEes0uJ+s4CNjOEqZjAerAvLn7CxSs0oHcQTMyU1jBFfBJ1C0q9+Y+ RbLr9auuMnllqhLsw2WXtMxnG1Y+RLC5O7rWTJ8TVFvMitXfkbPBBrv9wJqccSYANVgK qsDz2t9dhax2J1XJFuKl+vXi6lCrvbmL5zLZQUiyhxI6vS8Sgd38qQHBCVj/IBIGzbdC /Evw== X-Gm-Message-State: AOJu0YzhqQmWPpKowVbC8w3+G3vxeFKRJX/UV1k2bK2TZ6kczrCsWDny iCwU374cslpqqpueg6cIa+2O70axiIBmMTnd1qA= X-Google-Smtp-Source: AGHT+IHW44/axFMkqh4o3dWj+3kTBsc+0ubyGHR4Y+GVnHGTPGrIbx87Y/D4M6rRxF80rmNF2X9XIA== X-Received: by 2002:a17:902:da92:b0:1cc:5aef:f2d1 with SMTP id j18-20020a170902da9200b001cc5aeff2d1mr3310895plx.25.1699723323974; Sat, 11 Nov 2023 09:22:03 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id i2-20020a17090332c200b001cc311ef152sm1482674plr.286.2023.11.11.09.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Nov 2023 09:22:03 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [RFC] eal: use _Static_assert() for RTE_BUILD_BUG_ON Date: Sat, 11 Nov 2023 09:21:53 -0800 Message-Id: <20231111172153.57461-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The method of doing sizeof a bad array element was an interesting hack but it has a couple of problems. First, it won't work if VLA checking is enabled. It doesn't enforce that the expression is constant. Replace that with the _Static_assert builtin available in Gcc, Clang, and MSVC. Signed-off-by: Stephen Hemminger --- lib/eal/include/rte_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index c1ba32d00e47..2c63206223b8 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -495,7 +495,7 @@ rte_is_aligned(const void * const __rte_restrict ptr, const unsigned int align) /** * Triggers an error at compilation time if the condition is true. */ -#define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) +#define RTE_BUILD_BUG_ON(e) _Static_assert(!(e), #e) /*********** Cache line related macros ********/ -- 2.39.2