diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-06-13 11:13:06 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-06-13 11:13:06 -0300 |
| commit | fd80e63468f0c08fedd8dbf944fa4954b72d7384 (patch) | |
| tree | e074a257d1eb265eaaafeb930e94282a72d27f88 /lobject.h | |
| parent | f62565abea4e56f6bd064df83e5b0f3818b99d82 (diff) | |
| download | lua-fd80e63468f0c08fedd8dbf944fa4954b72d7384.tar.gz lua-fd80e63468f0c08fedd8dbf944fa4954b72d7384.tar.bz2 lua-fd80e63468f0c08fedd8dbf944fa4954b72d7384.zip | |
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.h | 21 |
1 files changed, 19 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.h,v 2.58 2011/06/07 19:02:33 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 2.59 2011/06/09 18:21:25 roberto Exp roberto $ |
| 3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -262,7 +262,7 @@ typedef struct lua_TValue TValue; | |||
| 262 | ** ======================================================= | 262 | ** ======================================================= |
| 263 | */ | 263 | */ |
| 264 | 264 | ||
| 265 | #if defined(LUA_NANTRICK) | 265 | #if defined(LUA_NANTRICKLE) || defined(LUA_NANTRICKBE) |
| 266 | 266 | ||
| 267 | /* | 267 | /* |
| 268 | ** numbers are represented in the 'd_' field. All other values have the | 268 | ** numbers are represented in the 'd_' field. All other values have the |
| @@ -270,11 +270,20 @@ typedef struct lua_TValue TValue; | |||
| 270 | ** a "signaled NaN", which is never generated by regular operations by | 270 | ** a "signaled NaN", which is never generated by regular operations by |
| 271 | ** the CPU (nor by 'strtod') | 271 | ** the CPU (nor by 'strtod') |
| 272 | */ | 272 | */ |
| 273 | #if !defined(NNMARK) | ||
| 273 | #define NNMARK 0x7FF7A500 | 274 | #define NNMARK 0x7FF7A500 |
| 275 | #endif | ||
| 274 | 276 | ||
| 275 | #undef TValuefields | 277 | #undef TValuefields |
| 278 | #if defined(LUA_NANTRICKLE) | ||
| 279 | /* little endian */ | ||
| 276 | #define TValuefields \ | 280 | #define TValuefields \ |
| 277 | union { struct { Value v_; int tt_; } i; double d_; } u | 281 | union { struct { Value v_; int tt_; } i; double d_; } u |
| 282 | #else | ||
| 283 | /* big endian */ | ||
| 284 | #define TValuefields \ | ||
| 285 | union { struct { int tt_; Value v_; } i; double d_; } u | ||
| 286 | #endif | ||
| 278 | 287 | ||
| 279 | #undef numfield | 288 | #undef numfield |
| 280 | #define numfield /* no such field; numbers are the entire struct */ | 289 | #define numfield /* no such field; numbers are the entire struct */ |
| @@ -322,6 +331,14 @@ typedef struct lua_TValue TValue; | |||
| 322 | (ttisnumber(o1) ? ttisnumber(o2) : ((o1)->u.i.tt_ == (o2)->u.i.tt_)) | 331 | (ttisnumber(o1) ? ttisnumber(o2) : ((o1)->u.i.tt_ == (o2)->u.i.tt_)) |
| 323 | 332 | ||
| 324 | 333 | ||
| 334 | |||
| 335 | #define luai_checknum(L,o,c) { if (!ttisnumber(o)) c; } | ||
| 336 | |||
| 337 | |||
| 338 | #else | ||
| 339 | |||
| 340 | #define luai_checknum(L,o,c) { /* empty */ } | ||
| 341 | |||
| 325 | #endif | 342 | #endif |
| 326 | /* }====================================================== */ | 343 | /* }====================================================== */ |
| 327 | 344 | ||
