mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] CMSG_LEN macro
@ 2021-09-03 10:13 J. Hanne
  2021-09-03 13:12 ` Rich Felker
  0 siblings, 1 reply; 5+ messages in thread
From: J. Hanne @ 2021-09-03 10:13 UTC (permalink / raw)
  To: musl

Hi,

can somebody enlighten me on the purpose of "CMSG_ALIGN (sizeof (struct cmsghdr))" in

#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))

of https://git.musl-libc.org/cgit/musl/tree/include/sys/socket.h?

CMSG_ALIGN seems to round up to a multiple of sizeof(size_t) - e.g. to a multiple of 4 on x86/arm and to a multiple of 8 on x86_64/aarch64?

Given struct cmsghdr, which has a size of 16 bytes on all 4 mentioned archs, I already wonder if this has an effect on any real-world architecture.

But more importantly, I wonder *what* exactly is supposed to being aligned here:
- Shall it put some padding *before* struct cmsghdr? That doesn't seem to make sense as the result of CMSG_LEN() goes into the cmsg_len member of struct cmsg, so it would seem strange to me to include bytes preceding the struct in its length field.
- Shall it put some padding *after* struct cmsghdr? In this case, CMSG_DATA would be wrong as it puts the data directly behind struct cmsghdr without any padding between.

Regards,
  Johann

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-03 13:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03 10:13 [musl] CMSG_LEN macro J. Hanne
2021-09-03 13:12 ` Rich Felker
2021-09-05 17:27   ` Markus Wichmann
2021-10-03  8:14     ` J. Hanne
2021-10-03 13:35       ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).