discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: c/10360: __alignof__(double) answer 8


From: Chris Beaham
Subject: Re: c/10360: __alignof__(double) answer 8
Date: Thu, 10 Apr 2003 07:46:14 +0200

Good Morning Richard

I am not by any means a compiler expert, but I assume that the alignment is dependent upon the CPU architecture, for the most part the cache hardware, and therefore the preferred alignment is always the same across all platforms and the true alignment machine dependent. I have used HP-UX compilers for many years on their PARISC and it has always been necessary to use compiler options to enforce a particular alignment so that you can use arrays of structures in shared memory for example. It should be possible to generate rules based upon the machine type and add these to the make system. Maybe!?

Best regards,

Chris

Chris Beaham
Manager Software Development & Engineering
chris.beaham@pcs-ag.com

PCS Process Control Systems AG
Werkstrasse 8
CH-8623 Wetzikon
Switzerland
Tel. +41 (0) 1 931 22 44
Fax +41 (0) 1 931 22 53
Email: office@pcs-ag.com, support@pcs-ag.com
Web: www.pcs-ag.com


On Donnerstag, April 10, 2003, at 07:06 Uhr, Richard Frith-Macdonald wrote:


On Wednesday, April 9, 2003, at 11:40  pm, Richard Henderson wrote:

On Wed, Apr 09, 2003 at 11:59:58PM +0200, Frederic De Jaeger wrote:
Thus, why gcc does not align fields with respect to this *preferred*
alignment?

Because the ABI says not to.

It would be interesting to know in what sense the alignment is 'preferred'.
Surely if the 'ABI says not to' then the alignment is not preferred?

... and we expect it to return the alignment used by the compiler (and not
the *preferred* alignment).

A meaningless number.  Because "the alignment used by the compiler"
is going to depend on the context in which it is used.

I think that Frederic means the alignment the compiler uses to lay out
structures in memory.

It's hard to see how that can be context sensistive since the compiler
needs to know it to access the structure elements via a pointer, so
the code that stored the structure in memory and the code that
retrieves it through the pointer have to use the same alignments.

I imagine this is *by far* the most common context in which anyone
would want to know a type alignment (actually it's the only one I can
think of off hand).

So if __alignof__ is not returning the alignment of a type for structure layout, how can it be returning the 'preferred' alignment. Shouldn't this
either be fixed as Frederic suggests, or the documentation be changed
so that instead of saying 'preferred' it says 'misleading and largely
useless'

Sorry if this sounds overly aggressive, but I do think that compiler extensions
should be useful and behave as expected, and this behavior seems to
mean that __alignof__ fails in this.



_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
http://mail.gnu.org/mailman/listinfo/discuss-gnustep







reply via email to

[Prev in Thread] Current Thread [Next in Thread]