Andy Ross wrote:
Curtis L. Olson wrote:

I believe that plib has some endiannes tests.  Also simgear, have a
look at simgear/io/lowlevel.hxx (towards the end)


Right.  But those are runtime tests.  What Nasal needs to modify is a
structure order, which can only be done at compile time.  Simplified,
the naRef structure looks like this:

typedef union {
    double num;
    struct {
        void* ptr;
        int   magic;
    } ref;
} naRef;

On a little endian system, the "magic" ends up in the top 32 bits of
the double.  So it can make the double look like a NaN by setting the
appropriate exponent bits.  And on a 64 bit system, the double and
pointer are the same size, so the magic lives all by itself.  But on a
big endian 32 bit architecture, we need to modify the inner "ref"
struct to have the magic number first.

There is a compiler directive:


#if BYTE_ORDER == BIG_ENDIAN
#else
#endif

Erik


_______________________________________________ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to