better(?) handling of '#define's for IEEE-related tricks + avoid using

IEEE trick for 64-bit integer types (lua_Integer on 64-bit machines)
This commit is contained in:
Roberto Ierusalimschy
2012-05-11 11:10:50 -03:00
parent 4ec7d6de95
commit 77cbd817d1
3 changed files with 82 additions and 66 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lobject.h,v 2.68 2012/01/25 21:05:40 roberto Exp roberto $
** $Id: lobject.h,v 2.69 2012/05/08 13:53:33 roberto Exp roberto $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
@@ -266,6 +266,8 @@ typedef struct lua_TValue TValue;
#define setsvalue2n setsvalue
/* check whether a number is valid (useful only for NaN trick) */
#define luai_checknum(L,o,c) { /* empty */ }
/*
@@ -273,10 +275,7 @@ typedef struct lua_TValue TValue;
** NaN Trick
** =======================================================
*/
#if defined(LUA_NANTRICK) \
|| defined(LUA_NANTRICK_LE) \
|| defined(LUA_NANTRICK_BE)
#if defined(LUA_NANTRICK)
/*
** numbers are represented in the 'd_' field. All other values have the
@@ -284,15 +283,23 @@ typedef struct lua_TValue TValue;
** a "signaled NaN", which is never generated by regular operations by
** the CPU (nor by 'strtod')
*/
#if !defined(NNMARK)
/* allows for external implementation for part of the trick */
#if !defined(NNMARK) /* { */
#if !defined(LUA_IEEEENDIAN)
#error option 'LUA_NANTRICK' needs 'LUA_IEEEENDIAN'
#endif
#define NNMARK 0x7FF7A500
#define NNMASK 0x7FFFFF00
#endif
#undef TValuefields
#undef NILCONSTANT
#if defined(LUA_NANTRICK_LE)
#if (LUA_IEEEENDIAN == 0) /* { */
/* little endian */
#define TValuefields \
@@ -303,7 +310,7 @@ typedef struct lua_TValue TValue;
#define d_(o) ((o)->u.d__)
#define tt_(o) ((o)->u.i.tt__)
#elif defined(LUA_NANTRICK_BE)
#else /* }{ */
/* big endian */
#define TValuefields \
@@ -314,10 +321,9 @@ typedef struct lua_TValue TValue;
#define d_(o) ((o)->u.d__)
#define tt_(o) ((o)->u.i.tt__)
#elif !defined(TValuefields)
#error option 'LUA_NANTRICK' needs declaration for 'TValuefields'
#endif /* } */
#endif
#endif /* } */
/* correspondence with standard representation */
@@ -367,14 +373,9 @@ typedef struct lua_TValue TValue;
(ttisnumber(o1) ? ttisnumber(o2) : (tt_(o1) == tt_(o2)))
#undef luai_checknum
#define luai_checknum(L,o,c) { if (!ttisnumber(o)) c; }
#else
#define luai_checknum(L,o,c) { /* empty */ }
#endif
/* }====================================================== */