[v6,29/30] lib/vhost: 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>
---
lib/vhost/vhost_user.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
@@ -143,7 +143,7 @@ struct vhost_user_config {
uint8_t region[VHOST_USER_MAX_CONFIG_SIZE];
};
-typedef struct VhostUserMsg {
+typedef __rte_packed_begin struct VhostUserMsg {
union {
uint32_t frontend; /* a VhostUserRequest value */
uint32_t backend; /* a VhostUserBackendRequest value*/
@@ -169,16 +169,16 @@ typedef struct VhostUserMsg {
struct vhost_user_config cfg;
} payload;
/* Nothing should be added after the payload */
-} __rte_packed VhostUserMsg;
+} __rte_packed_end VhostUserMsg;
/* Note: this structure and VhostUserMsg can't be changed carelessly as
* external message handlers rely on them.
*/
-struct __rte_packed vhu_msg_context {
+__rte_packed_begin struct vhu_msg_context {
VhostUserMsg msg;
int fds[VHOST_MEMORY_MAX_NREGIONS];
int fd_num;
-};
+} __rte_packed_end;
#define VHOST_USER_HDR_SIZE offsetof(VhostUserMsg, payload.u64)