[11/14] dmadev: use C11 alignas

Message ID 1707873986-29352-12-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series use C11 alignas and normalize type alignment |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tyler Retzlaff Feb. 14, 2024, 1:26 a.m. UTC
  * Move __rte_aligned from the end of {struct,union} definitions to
  be between {struct,union} and tag.

  The placement between {struct,union} and the tag allows the desired
  alignment to be imparted on the type regardless of the toolchain being
  used for all of GCC, LLVM, MSVC compilers building both C and C++.

* Replace use of __rte_aligned(a) on variables/fields with alignas(a).

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/dmadev/rte_dmadev_core.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

fengchengwen Feb. 14, 2024, 2:09 a.m. UTC | #1
Acked-by: Chengwen Feng <fengchengwen@huawei.com>

On 2024/2/14 9:26, Tyler Retzlaff wrote:
> * Move __rte_aligned from the end of {struct,union} definitions to
>    be between {struct,union} and tag.
>
>    The placement between {struct,union} and the tag allows the desired
>    alignment to be imparted on the type regardless of the toolchain being
>    used for all of GCC, LLVM, MSVC compilers building both C and C++.
>
> * Replace use of __rte_aligned(a) on variables/fields with alignas(a).
>
> Signed-off-by: Tyler Retzlaff<roretzla@linux.microsoft.com>
> ---
>   lib/dmadev/rte_dmadev_core.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/dmadev/rte_dmadev_core.h b/lib/dmadev/rte_dmadev_core.h
> index 0647856..1ba2c1f 100644
> --- a/lib/dmadev/rte_dmadev_core.h
> +++ b/lib/dmadev/rte_dmadev_core.h
> @@ -61,7 +61,7 @@ typedef uint16_t (*rte_dma_completed_status_t)(void *dev_private,
>    * The 'dev_private' field was placed in the first cache line to optimize
>    * performance because the PMD mainly depends on this field.
>    */
> -struct rte_dma_fp_object {
> +struct __rte_aligned(128) rte_dma_fp_object {
>   	/** PMD-specific private data. The driver should copy
>   	 * rte_dma_dev.data->dev_private to this field during initialization.
>   	 */
> @@ -73,7 +73,7 @@ struct rte_dma_fp_object {
>   	rte_dma_completed_t        completed;
>   	rte_dma_completed_status_t completed_status;
>   	rte_dma_burst_capacity_t   burst_capacity;
> -} __rte_aligned(128);
> +};
>   
>   extern struct rte_dma_fp_object *rte_dma_fp_objs;
>
  

Patch

diff --git a/lib/dmadev/rte_dmadev_core.h b/lib/dmadev/rte_dmadev_core.h
index 0647856..1ba2c1f 100644
--- a/lib/dmadev/rte_dmadev_core.h
+++ b/lib/dmadev/rte_dmadev_core.h
@@ -61,7 +61,7 @@  typedef uint16_t (*rte_dma_completed_status_t)(void *dev_private,
  * The 'dev_private' field was placed in the first cache line to optimize
  * performance because the PMD mainly depends on this field.
  */
-struct rte_dma_fp_object {
+struct __rte_aligned(128) rte_dma_fp_object {
 	/** PMD-specific private data. The driver should copy
 	 * rte_dma_dev.data->dev_private to this field during initialization.
 	 */
@@ -73,7 +73,7 @@  struct rte_dma_fp_object {
 	rte_dma_completed_t        completed;
 	rte_dma_completed_status_t completed_status;
 	rte_dma_burst_capacity_t   burst_capacity;
-} __rte_aligned(128);
+};
 
 extern struct rte_dma_fp_object *rte_dma_fp_objs;