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 8897443A0F; Tue, 30 Jan 2024 19:04:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0B1C7402CF; Tue, 30 Jan 2024 19:04:12 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id EF352402CD for ; Tue, 30 Jan 2024 19:04:09 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 51B3E20B2000; Tue, 30 Jan 2024 10:04:09 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 51B3E20B2000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1706637849; bh=QK7ZWS0gIdowryRM2ou4b3b8MstgYDz5DkSQ/+6nTac=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UvHPducUl5ytKwZPG6P++BY/U8CuMa4yudklft5UlGXZS34037lprdP8valItw+QK /I3yRVX/nY+X1Clfi0s/nBkk+ObGuekE0a4iCo9dEzEQcmDW1l1FBYgHDnYTCixSxl z5Z/Ost8w1abOl6GY65Y+cSvWDjKQ7k05RCm9saY= Date: Tue, 30 Jan 2024 10:04:09 -0800 From: Tyler Retzlaff To: Bruce Richardson Cc: Mattias =?iso-8859-1?Q?R=F6nnblom?= , Morten =?iso-8859-1?Q?Br=F8rup?= , dev@dpdk.org, Mattias =?iso-8859-1?Q?R=F6nnblom?= , Anatoly Burakov , David Christensen , Harry van Haaren , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Stanislaw Kardach , thomas@monjalon.net Subject: Re: [PATCH] RFC: use C11 alignas instead of GCC attribute aligned Message-ID: <20240130180409.GA9511@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <98CBD80474FA8B44BF855DF32C47DC35E9F1A3@smartserver.smartshare.dk> <91ba1ece-10dd-4698-acd9-6b51cfc63cd9@lysator.liu.se> <98CBD80474FA8B44BF855DF32C47DC35E9F1A7@smartserver.smartshare.dk> <635f0d9f-6665-426b-b778-d61e5e732fbe@lysator.liu.se> <98CBD80474FA8B44BF855DF32C47DC35E9F1AA@smartserver.smartshare.dk> <413840c1-a263-4118-adfe-d4ae0ec0b52d@lysator.liu.se> <20240129194356.GA25654@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> <20240130173928.GA2943@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Tue, Jan 30, 2024 at 05:59:25PM +0000, Bruce Richardson wrote: > On Tue, Jan 30, 2024 at 09:39:28AM -0800, Tyler Retzlaff wrote: > > On Tue, Jan 30, 2024 at 09:08:21AM +0100, Mattias Rönnblom wrote: > > > > > > > Sorry if I've missed some discussion on the list, but the current > > > pattern of putting __rte_aligned(X) at the end doesn't work with MSVC, > > > or why are we doing this? C11 purism doesn't seem like much of a > > > driving force. > > > > __rte_aligned(X) at the end doesn't work with MSVC __declspec(align(n)) > > > > > > > > If one defined a macro as __declspec(align(X)) on MSVC and > > > __attribute__(__aligned__(X)) on other compilers, could it do the work > > > of both the above RTE_ALIGNAS() and RTE_ALIGN_TYPE()? > > > > > > struct { int a; } ; > > > > yes for struct/union. but only when placed at location you mark as > > when compiling both C and C++ for all toolchains. > > > I can see this restriction on placement potentially causing problems. Maybe > we should consider defining macros with the "struct" keywork included. For > example, (using gcc attributes here): i had considered this but it might be overkill. * it will be picked up by windows/msvc ci build. * once established as the common visual pattern in the source it will be cut n' pasted at low rate of error. > > #define rte_aligned_struct(n) struct __attribute((aligned(n))) > > rte_aligned_struct my_struct { > int a; > } > > Probably that's taking things a bit far away from standard C, but it may > cut down on placement errors. > > /Bruce