mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-03-12 22:14:25 +00:00
sockets: fix CMSG alignment
This changes the CMSG alignment macros to ensure struct cmsghdr and data are on a word (double word on 16-bit arch) aligned boundary We need to ensure at least 32-bit alignment for 16-bit systems because socklen_t could be 32-bit due to our definition
This commit is contained in:
parent
c686261e1e
commit
fc7a68b5af
@ -144,9 +144,13 @@ struct cmsghdr {
|
||||
/* Data section follows header and possible padding, typically referred to as
|
||||
unsigned char cmsg_data[]; */
|
||||
|
||||
/* cmsg header/data alignment */
|
||||
#define ALIGN_H(size) LWIP_MEM_ALIGN_SIZE(size)
|
||||
#define ALIGN_D(size) LWIP_MEM_ALIGN_SIZE(size)
|
||||
/* cmsg header/data alignment. NOTE: we align to native word size (double word
|
||||
size on 16-bit arch) so structures are not placed at an unaligned address.
|
||||
16-bit arch needs double word to ensure 32-bit alignment because socklen_t
|
||||
could be 32 bits. If we ever have cmsg data with a 64-bit variable, alignment
|
||||
will need to increase long long */
|
||||
#define ALIGN_H(size) (((size) + sizeof(long) - 1U) & ~(sizeof(long)-1U))
|
||||
#define ALIGN_D(size) ALIGN_H(size)
|
||||
|
||||
#define CMSG_FIRSTHDR(mhdr) \
|
||||
((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
|
||||
|
Loading…
x
Reference in New Issue
Block a user