This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Robust detection of endianness at compile time.
- From: Nick Maclaren <nmm1 at cus dot cam dot ac dot uk>
- To: gcc-help at gcc dot gnu dot org
- Cc: "Lee Rhodes" <lee at rhoba dot com>
- Date: Mon, 30 Jul 2007 18:31:10 +0100
- Subject: Re: Robust detection of endianness at compile time.
"Lee Rhodes" <lee@rhoba.com> wrote:
>
> I presume you mean an early FP coprocessor, where the CPU issues the
> instruction and the binary data sent to the FP unit may have different byte
> orders depending on the origin of the data?
Precisely. And whether it uses it or not will depend on whether it
is there at start-up. Such designs are staging a (perhaps temporary)
come-back - look up Clearspeed and SGI/AMD/Intel's plans for hybrid
SMP designs.
> Sorry, when I said "compiler" I meant compiler/assembler. Nonetheless, what
> do you mean "only for C integers"?
The compiler does not actually need to know the layout of
floating-point, even in C99 - after all, C90 had to support the
designs mentioned above. And a Fortran compiler doesn't need to
do so even for integers. There is nothing in the languages that
expose those to the program at compile time.
> That is certainly true for the byte shuffle operations for conversion. But a
> run-time detection of endianness might require a memory operation. I would
> have to think about it.
Oh, it does. Probably lots of them. But you need do it only once.
Thereafter, the shuffling can be incredibly cache-friendly.
Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Email: nmm1@cam.ac.uk
Tel.: +44 1223 334761 Fax: +44 1223 334679