From patchwork Tue Mar 12 21:01:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 138282 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 85A3943C96; Tue, 12 Mar 2024 22:03:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 56BA7402CD; Tue, 12 Mar 2024 22:03:21 +0100 (CET) Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by mails.dpdk.org (Postfix) with ESMTP id EA59040272 for ; Tue, 12 Mar 2024 22:03:19 +0100 (CET) Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-29b7caa88c6so4439811a91.0 for ; Tue, 12 Mar 2024 14:03:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1710277399; x=1710882199; 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=mvQ9OBezSenPxl2wwoOONS1AVIVGGOtXSof0iadjITE=; b=F/By+osJwCw8lgSkphCl9AG5q5n3T9v5tf6eB1QbMP/4/KfAv4X/ONgSHiSfMfoxkJ QkKgkdA6yGjqDDnvdiwKImlDUXmHh940XQV5wlnb2G8HxB1q1x87BtlZawgo9+5n2JMv KXCK46ycEb9nj203plXRhyhA5a7mGAEMOxIQkLuhVSTrXg4wuAkoEkPuhfUl5nDgSvlj NXk9rojVnDRVmvkT7nxCRO+fYzhKsDk3noJZqVrdf/6F9rAwCszr+z75tcVkHtqE6pFn 5HgUATKH8/oPq3EsgPehqGNiXgCAxtfs2kgdQbHeErIvf46heI8CMBsBfEggdCQQWFpL nomQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710277399; x=1710882199; 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=mvQ9OBezSenPxl2wwoOONS1AVIVGGOtXSof0iadjITE=; b=LeSdK41Eu9Rq2YQfmXG0+oa6VAQbCNkAei8SYXxbuq6tbIh9G9gNn/s22UMT12e5Xv qj+JASp2t4cB9e/mWSlvpNcYNbJFtco4L7iMYSodJRyrQiLWaVk6qGPVe+Q+UBw/99NL IC/nK/6gNKmvh1isrTSVpduFBUXmxLDcfHN5idpisXcg5IdwjMuMBOAM9Sppj8bqOclf UciqmI0gygPvkvvMZwTUtPfshKl3GFPC6RGhJHIDWBV9hNpwD2SOZhwXgPHz7OH96JjP 8AMdnnudH8q4l5RmgQEYODxEKMI5k0dKPraGDuHx18VZq+58uV1fFE98d9Dra6cMDcmZ hs9w== X-Gm-Message-State: AOJu0YyzqdW0JGyIFBIM6g4bSVFbOE9408IPqAPwDiplBU6YlmnaNKrR avQQjtuEGVDpz9WpPKD0on67veF/QxY3E8eyWp0l9xmmIA8AFxowZQabCb4FyhgNaNMyXxA/Q0C C X-Google-Smtp-Source: AGHT+IHNGJe/wSJMZCjdO20YayZu1jx0zfgQVnJ0k5sTaBJn1PMPvghNi4r3T8MZBTpDHWQWGpIJJQ== X-Received: by 2002:a17:90a:e615:b0:29b:aec6:79e4 with SMTP id j21-20020a17090ae61500b0029baec679e4mr7892568pjy.3.1710277399018; Tue, 12 Mar 2024 14:03:19 -0700 (PDT) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id g9-20020a17090a714900b0029be7922b32sm24948pjs.26.2024.03.12.14.03.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 14:03:18 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [RFC] eal: add rte_counted_by attribute Date: Tue, 12 Mar 2024 14:01:08 -0700 Message-ID: <20240312210308.8788-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 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 Both Gcc 14 and clang support this in latest versions. Add to EAL first, then instrument flexible arrays. [1] https://reviews.llvm.org/D148381 [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896 Signed-off-by: Stephen Hemminger --- lib/eal/include/rte_compat.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/eal/include/rte_compat.h b/lib/eal/include/rte_compat.h index 716bc0361640..6bf6b0baaccf 100644 --- a/lib/eal/include/rte_compat.h +++ b/lib/eal/include/rte_compat.h @@ -68,6 +68,16 @@ _Pragma("GCC diagnostic pop") __attribute__((section(".text.internal"))) #endif +/* + * Used to by ASAN bounds checker for flexible arrays + * Supported by Gcc >= 14 and clang >=18 + */ +#if __has_attribute(__element_count__) +# define __rte_counted_by(member) __attribute__((__element_count__(member))) +#else +# define __rte_counted_by(member) +#endif + #endif #ifdef __cplusplus