Subject: Re: CMSG_* problems
To: None <tech-userlevel@NetBSD.org>
From: Alan Barrett <firstname.lastname@example.org>
Date: 02/15/2007 08:24:59
On Thu, 15 Feb 2007, James K. Lowden wrote:
> Alan Barrett wrote:
> > On Mon, 12 Feb 2007, Matt Thomas wrote:
> > > C mandates that alignment for
> > > char <= short <= int <= long <= long long.
> > I can't find this requirement. Could you point out the relevant
> > part of the C99 or C89 standard?
> I am looking at WG14/N1124 Committee Draft -- May 6, 2005 ISO/IEC 9899:TC2
> section 22.214.171.124 (Numerical limits) where the minimum and maximum sizes of
> integral types is specified.
That section is about size, not about alignment.
> It actually says char < short <= int < long
> < long long. More precisely,
> the minimum number of bits for each type:
> char 8
> short 16
> int 16
> long 32
> llong 64
I think you are misinterpreting that. Section 126.96.36.199 gives minimum
requirements, but it doesn't prevent a particular implementation from
exceeding the minimum requirements; for example, having sizeof(int) ==
sizeof(long) == 32/CHAR_BIT is fine.
There's also section 188.8.131.52 about the relative "rank" of various
integer types, and section 6.2.5 paragraph 7 about the relationship
between rank and range of representable values, and the obvious
relationship between range of representable values and width (buried
somewhere in section 6.2.6). From these, you can derive the requirement
sizeof(char) <= short <= int <= long <= long long
but I still see no similar requirement for alignment.
--apb (Alan Barrett)