[v6,25/30] lib/eal: replace packed attributes
Checks
Commit Message
MSVC struct packing is not compatible with GCC. Replace macro
__rte_packed with __rte_packed_begin to push existing pack value
and set packing to 1-byte and macro __rte_packed_end to restore
the pack value prior to the push.
Macro __rte_packed_end is deliberately utilized to trigger a
MSVC compiler warning if no existing packing has been pushed allowing
easy identification of locations where the __rte_packed_begin is
missing.
Removed the packed attributes from some structures that don't need
them.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
lib/eal/common/eal_private.h | 2 +-
lib/eal/include/rte_memory.h | 3 ++-
lib/eal/include/rte_memzone.h | 3 ++-
lib/eal/include/rte_trace_point.h | 2 +-
lib/eal/x86/include/rte_memcpy.h | 9 ++++++---
5 files changed, 12 insertions(+), 7 deletions(-)
@@ -62,7 +62,7 @@ struct rte_config {
* DPDK instances
*/
struct rte_mem_config *mem_config;
-} __rte_packed;
+};
/**
* Get the global configuration structure.
@@ -46,6 +46,7 @@ extern "C" {
/**
* Physical memory segment descriptor.
*/
+__rte_packed_begin
struct rte_memseg {
rte_iova_t iova; /**< Start IO address. */
union {
@@ -58,7 +59,7 @@ struct rte_memseg {
uint32_t nchannel; /**< Number of channels. */
uint32_t nrank; /**< Number of ranks. */
uint32_t flags; /**< Memseg-specific flags */
-} __rte_packed;
+} __rte_packed_end;
/**
* memseg list is a special case as we need to store a bunch of other data
@@ -45,6 +45,7 @@ extern "C" {
* A structure describing a memzone, which is a contiguous portion of
* physical memory identified by a name.
*/
+__rte_packed_begin
struct rte_memzone {
#define RTE_MEMZONE_NAMESIZE 32 /**< Maximum length of memory zone name.*/
@@ -62,7 +63,7 @@ struct rte_memzone {
int32_t socket_id; /**< NUMA socket ID. */
uint32_t flags; /**< Characteristics of this memzone. */
-} __rte_packed;
+} __rte_packed_end;
/**
* Set the maximum number of memzones.
@@ -298,7 +298,7 @@ struct __rte_trace_stream_header {
rte_uuid_t uuid;
uint32_t lcore_id;
char thread_name[__RTE_TRACE_EMIT_STRING_LEN_MAX];
-} __rte_packed;
+};
struct __rte_trace_header {
uint32_t offset;
@@ -67,15 +67,18 @@ rte_mov15_or_less(void *dst, const void *src, size_t n)
* Use the following structs to avoid violating C standard
* alignment requirements and to avoid strict aliasing bugs
*/
+ __rte_packed_begin
struct rte_uint64_alias {
uint64_t val;
- } __rte_packed __rte_may_alias;
+ } __rte_packed_end __rte_may_alias;
+ __rte_packed_begin
struct rte_uint32_alias {
uint32_t val;
- } __rte_packed __rte_may_alias;
+ } __rte_packed_end __rte_may_alias;
+ __rte_packed_begin
struct rte_uint16_alias {
uint16_t val;
- } __rte_packed __rte_may_alias;
+ } __rte_packed_end __rte_may_alias;
void *ret = dst;
if (n & 8) {