Subject: Re: CMSG_* problems
To: None <tech-userlevel@netbsd.org>
From: James K. Lowden <jklowden@schemamania.org>
List: tech-userlevel
Date: 02/11/2007 10:40:40
der Mouse wrote:
> Specifically, it seems to me that the only ways to use the API without
> making assumptions not promised by C involve requiring that the
> msg_control buffer be suitably aligned for a struct cmsghdr, which
> basically means that it must be malloc()ed, and malloc()ed specifically
> for the purpose (not a non-initial part of a larger malloc()ed buffer).
(Well, there's a lot in that "basically"; there are ways other than malloc
to ensure alignment.)
Why is it not sufficient to say the API guarantees suitable alignment?
Surely it's better to align the buffers when contructed in such a way that
they are easily accessible than to burden the client with possible bus
errors.
As I read RFC 2292 (today, for the first time) istm that was the authors'
intent. The suggested implementations use an "implementation defined"
ALIGN() macro.
--jkl