summaryrefslogtreecommitdiff
path: root/lobject.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2012-05-11 11:10:50 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2012-05-11 11:10:50 -0300
commit77cbd817d1a525a161f8f24e98459191edb9a181 (patch)
tree0a5c621a34772b73b3b52559afccdc6decce9afa /lobject.h
parent4ec7d6de95bcf9fa35a9b268a41154b142190691 (diff)
downloadlua-github-77cbd817d1a525a161f8f24e98459191edb9a181.tar.gz
better(?) handling of '#define's for IEEE-related tricks + avoid using
IEEE trick for 64-bit integer types (lua_Integer on 64-bit machines)
Diffstat (limited to 'lobject.h')
-rw-r--r--lobject.h37
1 files changed, 19 insertions, 18 deletions
diff --git a/lobject.h b/lobject.h
index 1fa6df80..1d29a22c 100644
--- a/lobject.h
+++ b/lobject.h
@@ -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
/* }====================================================== */