Subject: Re: CMSG_* problems
To: None <tech-userlevel@NetBSD.org, tech-kern@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-userlevel
Date: 02/12/2007 15:40:33
>> (The only way I can think of to ensure alignment suitable for a
>> struct cmsghdr, without machine- or compiler-dependent hackery, is
>> to allocate the buffer as an array of struct cmsghdr, and that still
>> doesn't ensure the buffer is suitably aligned for the data fields of
>> the control messages.)
> The way it is normally is make it an array of the maximally aligned
> type (usually of type long or long long).

Knowing what "the maximally aligned type" *is* is machine- and/or
compiler-dependent.  (For example, I could easily imagine a 32-bit
machine on which long and long long could be on any 32-bit boundary but
double must be on a 64-bit boundary.)

Unless you are counter-proposing to have the CMSG_* interface export a
type for the purpose, which would at least _suffice_, though I'd still
prefer to do away with overlaying the structs onto the buffer - or at
least make it possible for the app author to do so.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B