Skip to content

Commit

Permalink
Fix ddsi_tran_write_msgfrags_t alignment on stack
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Boasson <[email protected]>
  • Loading branch information
eboasson committed Aug 22, 2023
1 parent 19ac009 commit 72d6d6d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/core/ddsi/src/ddsi__tran.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ typedef struct ddsi_tran_write_msgfrags {
DDSRT_STATIC_ASSERT (offsetof (ddsi_tran_write_msgfrags_t, tran_reserved) + DDSI_TRAN_RESERVED_IOV_SLOTS * sizeof (ddsrt_iovec_t) == offsetof (ddsi_tran_write_msgfrags_t, iov));

#define DDSI_DECL_TRAN_WRITE_MSGFRAGS_PTR(name_, n_) \
unsigned char name_##_ddsi_tran_write_msgfrags_buf[sizeof (ddsi_tran_write_msgfrags_t) + (n_) * sizeof (ddsrt_iovec_t)]; \
ddsi_tran_write_msgfrags_t * const name_ = (ddsi_tran_write_msgfrags_t *) name_##_ddsi_tran_write_msgfrags_buf;
union { \
unsigned char raw[sizeof (ddsi_tran_write_msgfrags_t) + (n_) * sizeof (ddsrt_iovec_t)]; \
ddsi_tran_write_msgfrags_t typed; \
} name_##_ddsi_tran_write_msgfrags_buf; \
ddsi_tran_write_msgfrags_t * const name_ = &name_##_ddsi_tran_write_msgfrags_buf.typed;

#define DDSI_DECL_CONST_TRAN_WRITE_MSGFRAGS_MSVC_WORKAROUND(x) x

Expand All @@ -70,8 +73,11 @@ DDSRT_STATIC_ASSERT (offsetof (ddsi_tran_write_msgfrags_t, tran_reserved) + DDSI
DDSI_DECL_CONST_TRAN_WRITE_MSGFRAGS_MSVC_WORKAROUND(DDSI_DECL_CONST_TRAN_WRITE_MSGFRAGS_PTR3_3(name_, idx_+1, __VA_ARGS__)); \
DDSI_DECL_CONST_TRAN_WRITE_MSGFRAGS_PTR3_1(name_, idx_, e_)
#define DDSI_DECL_CONST_TRAN_WRITE_MSGFRAGS_PTR2(name_, n_, ...) \
unsigned char name_##_ddsi_tran_write_msgfrags_buf[sizeof (ddsi_tran_write_msgfrags_t) + (n_) * sizeof (ddsrt_iovec_t)]; \
ddsi_tran_write_msgfrags_t * const name_##_nonconst = (ddsi_tran_write_msgfrags_t *) name_##_ddsi_tran_write_msgfrags_buf; \
union { \
unsigned char raw[sizeof (ddsi_tran_write_msgfrags_t) + (n_) * sizeof (ddsrt_iovec_t)]; \
ddsi_tran_write_msgfrags_t typed; \
} name_##_ddsi_tran_write_msgfrags_buf; \
ddsi_tran_write_msgfrags_t * const name_##_nonconst = &name_##_ddsi_tran_write_msgfrags_buf.typed; \
name_##_nonconst->niov = n_; \
DDSI_DECL_CONST_TRAN_WRITE_MSGFRAGS_MSVC_WORKAROUND(DDSI_DECL_CONST_TRAN_WRITE_MSGFRAGS_PTR3_##n_(name_, 0, __VA_ARGS__)); \
const ddsi_tran_write_msgfrags_t * const name_ = name_##_nonconst
Expand Down

0 comments on commit 72d6d6d

Please sign in to comment.