From a2cd6480c223c693f5fe9d1c7ce86643111e2224 Mon Sep 17 00:00:00 2001 From: Declan Doherty Date: Wed, 25 Nov 2015 13:25:10 +0000 Subject: [PATCH] eal: add packing and alignment macros Adding a new macro for specifying __aligned__ attribute, and updating the current __rte_cache_aligned macro to use it. Also adding a new macro to specify the __packed__ attribute Signed-off-by: Declan Doherty Acked-by: Sergio Gonzalez Monroy --- lib/librte_eal/common/include/rte_common.h | 10 ++++++++++ lib/librte_eal/common/include/rte_memory.h | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index f8ca6f3ce3..b58a3841f4 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -69,6 +69,16 @@ typedef uint32_t unaligned_uint32_t; typedef uint16_t unaligned_uint16_t; #endif +/** + * Force alignment + */ +#define __rte_aligned(a) __attribute__((__aligned__(a))) + +/** + * Force a structure to be packed + */ +#define __rte_packed __attribute__((__packed__)) + /******* Macro to mark functions and fields scheduled for removal *****/ #define __rte_deprecated __attribute__((__deprecated__)) diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h index 067be104b5..33f5a77031 100644 --- a/lib/librte_eal/common/include/rte_memory.h +++ b/lib/librte_eal/common/include/rte_memory.h @@ -80,7 +80,7 @@ enum rte_page_sizes { /** * Force alignment to cache line. */ -#define __rte_cache_aligned __attribute__((__aligned__(RTE_CACHE_LINE_SIZE))) +#define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE) typedef uint64_t phys_addr_t; /**< Physical address definition. */ #define RTE_BAD_PHYS_ADDR ((phys_addr_t)-1) @@ -106,7 +106,7 @@ struct rte_memseg { /**< store segment MFNs */ uint64_t mfn[DOM0_NUM_MEMBLOCK]; #endif -} __attribute__((__packed__)); +} __rte_packed; /** * Lock page in physical memory and prevent from swapping. -- 2.20.1