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.

Signed-off-by: Andre Muezerie <andre...@linux.microsoft.com>
---
 examples/ptpclient/ptpclient.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index 7b6862d951..9c64313fa9 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -56,22 +56,22 @@ static const struct rte_ether_addr ether_multicast = {
 };
 
 /* Structs used for PTP handling. */
-struct tstamp {
+struct __rte_packed_begin tstamp {
        uint16_t   sec_msb;
        uint32_t   sec_lsb;
        uint32_t   ns;
-}  __rte_packed;
+}  __rte_packed_end;
 
 struct clock_id {
        uint8_t id[8];
 };
 
-struct port_id {
+struct __rte_packed_begin port_id {
        struct clock_id        clock_id;
        uint16_t               port_number;
-}  __rte_packed;
+}  __rte_packed_end;
 
-struct ptp_header {
+struct __rte_packed_begin ptp_header {
        uint8_t              msg_type;
        uint8_t              ver;
        uint16_t             message_length;
@@ -84,39 +84,39 @@ struct ptp_header {
        uint16_t             seq_id;
        uint8_t              control;
        int8_t               log_message_interval;
-} __rte_packed;
+} __rte_packed_end;
 
-struct sync_msg {
+struct __rte_packed_begin sync_msg {
        struct ptp_header   hdr;
        struct tstamp       origin_tstamp;
-} __rte_packed;
+} __rte_packed_end;
 
-struct follow_up_msg {
+struct __rte_packed_begin follow_up_msg {
        struct ptp_header   hdr;
        struct tstamp       precise_origin_tstamp;
        uint8_t             suffix[];
-} __rte_packed;
+} __rte_packed_end;
 
-struct delay_req_msg {
+struct __rte_packed_begin delay_req_msg {
        struct ptp_header   hdr;
        struct tstamp       origin_tstamp;
-} __rte_packed;
+} __rte_packed_end;
 
-struct delay_resp_msg {
+struct __rte_packed_begin delay_resp_msg {
        struct ptp_header    hdr;
        struct tstamp        rx_tstamp;
        struct port_id       req_port_id;
        uint8_t              suffix[];
-} __rte_packed;
+} __rte_packed_end;
 
 struct ptp_message {
-       union {
+       union __rte_packed_begin {
                struct ptp_header          header;
                struct sync_msg            sync;
                struct delay_req_msg       delay_req;
                struct follow_up_msg       follow_up;
                struct delay_resp_msg      delay_resp;
-       } __rte_packed;
+       } __rte_packed_end;
 };
 
 struct ptpv2_time_receiver_ordinary {
-- 
2.47.0.vfs.0.3

Reply via email to