Subject: Re: CMSG_* problems
To: None <>
From: Matt Thomas <>
List: tech-userlevel
Date: 02/11/2007 10:02:23
James K. Lowden wrote:
> 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.  

I can assure you that the author's assumed the buffer used for control messages
would be properly aligned for deferencing cmsghdr structures and/or any other
structure in buffer.
Matt Thomas                     email:
3am Software Foundry              www:
Cupertino, CA              disclaimer: I avow all knowledge of this message.