Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Apr 1998 19:21:10 -0800 (PST)
From:      Doug White <dwhite@gdi.uoregon.edu>
To:        xiaominy@newton.ccs.tuns.ca
Cc:        freebsd-questions@FreeBSD.ORG, ifair@newton.ccs.tuns.ca, Larry.Hughes@StMarys.ca
Subject:   Re: bit and byte alignment on FreeBSD?
Message-ID:  <Pine.BSF.3.96.980403191934.11299N-100000@gdi.uoregon.edu>
In-Reply-To: <352594BA.2E58B3B8@tuns.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 3 Apr 1998, Xiaomin Ye wrote:

> Dear Sir/Madam,
> We encountered a strange problem while using FreeBSD.
> The following structure can be compacted to be 8 bytes by means of cc
> compiler on Open-VMS platform. But on FreeBSD, 12 bytes will be formed.

Well, checking this between an Alpha and an Intel is comparing apples and
oranges.  They're completely different processors.

> #pragma nomember_alignment
> 
> struct example_structure
> {
> unsigned type : 3;
> unsigned c : 1;
> signed mem1 : 12;
> signed mem2 : 24;
> signed mem2 : 24;
> };
> 
> It seems that on FreeBSD  the compiler can only provide one, two or
> four  bytes alignment,
> "type" occupies 1 byte, "c" occupies 1, "mem1" 2 , "mem2" 4 bytes and
> "mem3" 4 bytes, because is no bit alignment and 3-byte alignment.
> However, on Open-VMS the compiler can provide the bit alignment,
> "type", "c" and "mem1" take 2 byte space, and "mem2", "mem3" will occupy
> 3 bytes respectively. The total space will be only 8 bytes.
> Is there any solution to this problem? Your kind will be very much
> appreciated.

The Intel architecture may not allow this type of alignment.  I think
most everything has to be word-aligned anyway, so it'll be expanded.

Others are encouraged to point out my lack of knowledge of Intel processor
specifics. :)

Doug White                              | University of Oregon  
Internet:  dwhite@resnet.uoregon.edu    | Residence Networking Assistant
http://gladstone.uoregon.edu/~dwhite    | Computer Science Major



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.980403191934.11299N-100000>