]> git.mxchange.org Git - simgear.git/blob - simgear/nasal/naref.h
Revert the check fro std::isnan() and isnan()
[simgear.git] / simgear / nasal / naref.h
1 #ifndef _NAREF_H
2 #define _NAREF_H
3
4 #if (defined(__x86_64) && defined(__linux__)) || defined(__sparcv9) || \
5     defined(__powerpc64__)
6 /* NASAL_NAN64 mode requires 64 bit pointers that only use the
7  * lower 48 bits; Win64 and Irix should work with this too, but
8  * have not been tested */
9 # define NASAL_NAN64
10 #elif defined(__BYTE_ORDER__)
11 /* GCC and Clang define these (as a builtin, while
12 * __LITTLE_ENDIAN__ requires a header), MSVC doesn't */
13 # if __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__
14 #  define NASAL_LE
15 # elif __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
16 #  define NASAL_BE
17 # else
18 #  error Unrecognized endianness
19 # endif
20 #elif defined(_M_IX86) || defined(__i386) || defined(__x86_64) || \
21       defined(__ia64__) || defined(_M_IA64) || defined(__ARMEL__) || \
22       defined(_M_X64) || defined(_M_ARM)
23 # define NASAL_LE
24 #elif defined(__sparc) || defined(__ARMEB__) || \
25       defined(__hppa__) || defined(__s390__) || defined(__s390x__)
26 # define NASAL_BE
27 #else
28 # error Unknown endianness
29 #endif
30
31 typedef union {
32     struct naObj* obj;
33     struct naStr* str;
34     struct naVec* vec;
35     struct naHash* hash;
36     struct naCode* code;
37     struct naFunc* func;
38     struct naCCode* ccode;
39     struct naGhost* ghost;
40 } naPtr;
41
42 /* On supported 64 bit platforms (those where all memory returned from
43  * naAlloc() is guaranteed to lie between 0 and 2^48-1) we union the
44  * double with the pointer, and use fancy tricks (see data.h) to make
45  * sure all pointers are stored as NaNs.  32 bit layouts (and 64 bit
46  * platforms where we haven't tested the trick above) need
47  * endianness-dependent ordering to make sure that the reftag lies in
48  * the top bits of the double */
49
50 #if defined(NASAL_LE)
51 typedef struct { naPtr ptr; int reftag; } naRefPart;
52 #elif defined(NASAL_BE)
53 typedef struct { int reftag; naPtr ptr; } naRefPart;
54 #endif
55
56 #if defined(NASAL_NAN64)
57 typedef union { double num; void* ptr; } naRef;
58 #else
59 typedef union { double num; naRefPart ref; } naRef;
60 #endif
61
62 #endif // _NAREF_H