mailing list of musl libc
 help / color / mirror / Atom feed
From: "J. Hanne" <>
Subject: [musl] CMSG_LEN macro
Date: Fri,  3 Sep 2021 12:13:52 +0200 (CEST)
Message-ID: <> (raw)


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

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


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.


             reply	other threads:[~2021-09-03 10:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-03 10:13 J. Hanne [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

mailing list of musl libc

This inbox may be cloned and mirrored by anyone:

	git clone --mirror

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 musl musl/ \
	public-inbox-index musl

Example config snippet for mirrors.
Newsgroup available over NNTP:

code repositories for the project(s) associated with this inbox:

AGPL code for this site: git clone