summaryrefslogtreecommitdiff
path: root/lobject.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-06-13 11:13:06 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-06-13 11:13:06 -0300
commitfd80e63468f0c08fedd8dbf944fa4954b72d7384 (patch)
treee074a257d1eb265eaaafeb930e94282a72d27f88 /lobject.h
parentf62565abea4e56f6bd064df83e5b0f3818b99d82 (diff)
downloadlua-github-fd80e63468f0c08fedd8dbf944fa4954b72d7384.tar.gz
configuration for NaN trick big-endian + macro 'luai_checknum' to
ensure numbers comming from C are not "improper" (some kinds of signaling NaNs)
Diffstat (limited to 'lobject.h')
-rw-r--r--lobject.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/lobject.h b/lobject.h
index c130dcb6..5221ab68 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.h,v 2.58 2011/06/07 19:02:33 roberto Exp roberto $
+** $Id: lobject.h,v 2.59 2011/06/09 18:21:25 roberto Exp roberto $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
@@ -262,7 +262,7 @@ typedef struct lua_TValue TValue;
** =======================================================
*/
-#if defined(LUA_NANTRICK)
+#if defined(LUA_NANTRICKLE) || defined(LUA_NANTRICKBE)
/*
** numbers are represented in the 'd_' field. All other values have the
@@ -270,11 +270,20 @@ typedef struct lua_TValue TValue;
** a "signaled NaN", which is never generated by regular operations by
** the CPU (nor by 'strtod')
*/
+#if !defined(NNMARK)
#define NNMARK 0x7FF7A500
+#endif
#undef TValuefields
+#if defined(LUA_NANTRICKLE)
+/* little endian */
#define TValuefields \
union { struct { Value v_; int tt_; } i; double d_; } u
+#else
+/* big endian */
+#define TValuefields \
+ union { struct { int tt_; Value v_; } i; double d_; } u
+#endif
#undef numfield
#define numfield /* no such field; numbers are the entire struct */
@@ -322,6 +331,14 @@ typedef struct lua_TValue TValue;
(ttisnumber(o1) ? ttisnumber(o2) : ((o1)->u.i.tt_ == (o2)->u.i.tt_))
+
+#define luai_checknum(L,o,c) { if (!ttisnumber(o)) c; }
+
+
+#else
+
+#define luai_checknum(L,o,c) { /* empty */ }
+
#endif
/* }====================================================== */