From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 68035A04DC; Mon, 19 Oct 2020 16:13:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 218ABE252; Mon, 19 Oct 2020 16:13:51 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 8C2AC2D41 for ; Mon, 19 Oct 2020 16:13:48 +0200 (CEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 383CE5C01B5; Mon, 19 Oct 2020 10:13:48 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 19 Oct 2020 10:13:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=fm2; bh= V527FubwuIDZclfMNNKfXTyafmRQ3mcFJs0+vFVLtiA=; b=MD8f/mViJjjoVci2 3Bin79iTptBS1b0fncaPqt37gDKBgnAMdLn7adE8jP31oTzHSN3L7D+Ktdpv1ylg /05EOefyRHd3AvAzxZ8ccVkNX7LQUdqunR4vYBJ6FqMqHNvt6MZopPSmDNiWJzkM 43RS+CEvAlEEIdC68ooLTPZhfOD5Z3hEdrKKmCljUlCradCFoiVaEf0Xh4iNQG7k 45935KUDXgaCjH3dUrxS1A5JAvmhiT48mwvVBD7UUtAOjneWfZYiP0WYaoc4tApk Y4qAKc2xmrqGmsdQy9C596CxZ1Ek+9fxc/P+IDJhheOPax3hqcUDZ+3dXMXPF6YA Q3nMzg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=V527FubwuIDZclfMNNKfXTyafmRQ3mcFJs0+vFVLt iA=; b=jcTymZnsqI+j/ha8XEgJ6dKJuiWw3+9R1iGuBUi9R1e2vChe7CYVqJs6C dzqswb0FFzAIMsJHboMD1GFLpIjlH3oB7YoVT1UdzMKBd/41/mpKe+PSutQstyx3 kBD7TQ/k4XMP5T4+NLuZineISE3AUqNRpugZSmK5eOvWepndGiHotT93yzakk5gu oETsuytGvA2q9/L/OfQRKK/U377fPaOM0BRS1ZtmxlQAzf1WXKM3qqqODl7G23iF sQig4lIoNjS8wBlsy1rnkehiLXamg+sFvm+OtB4fYWoMc8yQyC1U/j0QJW5pXXaT ztIQEHOIuLmhvpLcRWNWq7niJxlwQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrjedugdejhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedugefgvdefudfftdefgeelgffhueekgfffhfeujedtteeutdejueei iedvffegheenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepudenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvth X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 13020328005A; Mon, 19 Oct 2020 10:13:46 -0400 (EDT) From: Thomas Monjalon To: Stephen Hemminger Cc: dev@dpdk.org, anatoly.burakov@intel.com, david.marchand@redhat.com Date: Mon, 19 Oct 2020 16:13:46 +0200 Message-ID: <11702768.X94JZly3y1@thomas> In-Reply-To: <20201015005524.24659-1-stephen@networkplumber.org> References: <20201015005524.24659-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v2] eal/rte_malloc: add alloc_size() attribute to allocation functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 15/10/2020 02:55, Stephen Hemminger: > By using the alloc_size() attribute the compiler can optimize > better and detect errors at compile time. > > For example, Gcc will fail one of the invalid allocation examples > in app/test/test_malloc.c because the allocation is outside the > limits of memory. > > Signed-off-by: Stephen Hemminger > --- > v2 - rebase onto correct branch (main) [...] > +/** > + * Tells compiler that the function returns a value that points to > + * memory, where the size is given by the one or two arguments. > + * Used by compiler to validate object size. > + */ > +#if defined(RTE_CC_GCC) || defined(RTE_CC_CLANG) > +#define __rte_alloc_size(...) \ > + __attribute__((alloc_size(__VA_ARGS__))) > +#else > +#define __rte_alloc_size(...) > +#endif Not sure about the rebase: RTE_CC_GCC and RTE_CC_CLANG don't exist.