[dpdk-dev,v6,03/10] eal: add __rte_packed /__rte_aligned macros

Message ID 1447176763-19303-4-git-send-email-declan.doherty@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Doherty, Declan Nov. 10, 2015, 5:32 p.m. UTC
  Adding a new marco for specifing __aligned__ attribute, and updating the
current __rte_cache_aligned macro to use it.

Also adding a new macro to specify the __packed__ attribute

Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 lib/librte_eal/common/include/rte_memory.h | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
  

Comments

Thomas Monjalon Nov. 13, 2015, 3:35 p.m. UTC | #1
2015-11-10 17:32, Declan Doherty:
> Adding a new marco for specifing __aligned__ attribute, and updating the

2 typos spotted on this line ;)
I wonder why the "marco" typo is so common.
  
Doherty, Declan Nov. 13, 2015, 3:41 p.m. UTC | #2
On 13/11/15 15:35, Thomas Monjalon wrote:
> 2015-11-10 17:32, Declan Doherty:
>> Adding a new marco for specifing __aligned__ attribute, and updating the
>
> 2 typos spotted on this line ;)
> I wonder why the "marco" typo is so common.
>

oops, I didn't have my spell-check plugin enabled in vim :(
  

Patch

diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 1bed415..18fd952 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -76,9 +76,19 @@  enum rte_page_sizes {
 /**< Return the first cache-aligned value greater or equal to size. */
 
 /**
+ * Force alignment
+ */
+#define __rte_aligned(a) __attribute__((__aligned__(a)))
+
+/**
  * 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)
+
+/**
+ * Force a structure to be packed
+ */
+#define __rte_packed __attribute__((__packed__))
 
 typedef uint64_t phys_addr_t; /**< Physical address definition. */
 #define RTE_BAD_PHYS_ADDR ((phys_addr_t)-1)
@@ -104,7 +114,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.