Subject: Re: Q: ARM32 ABI
To: Godmar Back <gback@cs.utah.edu>
From: Richard Earnshaw <rearnsha@arm.com>
List: port-arm32
Date: 06/05/1998 10:56:56
gback@cs.utah.edu said:
> [ps: also, does anybody have an autoconf macro that would test for the
> fp order weirdness?] 

The following property of IEEE doubles can be exploited to work this out.

Note that strictly speaking, autoconf (I assume you are talking about GNU 
autoconf here) can only be used to determine properties of the build 
platform (ie the platform where the build is taking place, not the 
platform where the built product will eventually run).  However, if you 
assume that these are the same, then the following bit of code can be 
used.  Or you can even do it dynamically

enum double_endian {DOUBLE_BIGENDIAN, DOUBLE_LITTLEENDIAN};

enum double_endian test_double_endian ()
{
  union {
    int32 w[2];
    double d;
  } t;
  t.d = 1.0;
  return t.w[0] == 0 ? DOUBLE_LITTLEENDIAN : DOUBLE_BIGENDIAN;
}

GCC is smart enough to collapse this into the constant result, so by 
making it inline, there should be no need even to autoconf this.

Richard.