[v6,23/30] examples/ptpclient: 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.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
examples/ptpclient/ptpclient.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
@@ -85,21 +85,24 @@ static const struct rte_ether_addr ether_multicast = {
};
/* Structs used for PTP handling. */
+__rte_packed_begin
struct tstamp {
uint16_t sec_msb;
uint32_t sec_lsb;
uint32_t ns;
-} __rte_packed;
+} __rte_packed_end;
struct clock_id {
uint8_t id[8];
};
+__rte_packed_begin
struct port_id {
struct clock_id clock_id;
uint16_t port_number;
-} __rte_packed;
+} __rte_packed_end;
+__rte_packed_begin
struct ptp_header {
uint8_t msg_type;
uint8_t ver;
@@ -113,39 +116,44 @@ struct ptp_header {
uint16_t seq_id;
uint8_t control;
int8_t log_message_interval;
-} __rte_packed;
+} __rte_packed_end;
+__rte_packed_begin
struct sync_msg {
struct ptp_header hdr;
struct tstamp origin_tstamp;
-} __rte_packed;
+} __rte_packed_end;
+__rte_packed_begin
struct follow_up_msg {
struct ptp_header hdr;
struct tstamp precise_origin_tstamp;
uint8_t suffix[];
-} __rte_packed;
+} __rte_packed_end;
+__rte_packed_begin
struct delay_req_msg {
struct ptp_header hdr;
struct tstamp origin_tstamp;
-} __rte_packed;
+} __rte_packed_end;
+__rte_packed_begin
struct 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 {
+ __rte_packed_begin
union {
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 {