diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-05-11 11:10:50 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-05-11 11:10:50 -0300 |
| commit | 77cbd817d1a525a161f8f24e98459191edb9a181 (patch) | |
| tree | 0a5c621a34772b73b3b52559afccdc6decce9afa /lobject.h | |
| parent | 4ec7d6de95bcf9fa35a9b268a41154b142190691 (diff) | |
| download | lua-77cbd817d1a525a161f8f24e98459191edb9a181.tar.gz lua-77cbd817d1a525a161f8f24e98459191edb9a181.tar.bz2 lua-77cbd817d1a525a161f8f24e98459191edb9a181.zip | |
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.h | 37 |
1 files changed, 19 insertions, 18 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.h,v 2.68 2012/01/25 21:05:40 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 2.69 2012/05/08 13:53:33 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 | */ |
| @@ -266,6 +266,8 @@ typedef struct lua_TValue TValue; | |||
| 266 | #define setsvalue2n setsvalue | 266 | #define setsvalue2n setsvalue |
| 267 | 267 | ||
| 268 | 268 | ||
| 269 | /* check whether a number is valid (useful only for NaN trick) */ | ||
| 270 | #define luai_checknum(L,o,c) { /* empty */ } | ||
| 269 | 271 | ||
| 270 | 272 | ||
| 271 | /* | 273 | /* |
| @@ -273,10 +275,7 @@ typedef struct lua_TValue TValue; | |||
| 273 | ** NaN Trick | 275 | ** NaN Trick |
| 274 | ** ======================================================= | 276 | ** ======================================================= |
| 275 | */ | 277 | */ |
| 276 | 278 | #if defined(LUA_NANTRICK) | |
| 277 | #if defined(LUA_NANTRICK) \ | ||
| 278 | || defined(LUA_NANTRICK_LE) \ | ||
| 279 | || defined(LUA_NANTRICK_BE) | ||
| 280 | 279 | ||
| 281 | /* | 280 | /* |
| 282 | ** numbers are represented in the 'd_' field. All other values have the | 281 | ** numbers are represented in the 'd_' field. All other values have the |
| @@ -284,15 +283,23 @@ typedef struct lua_TValue TValue; | |||
| 284 | ** a "signaled NaN", which is never generated by regular operations by | 283 | ** a "signaled NaN", which is never generated by regular operations by |
| 285 | ** the CPU (nor by 'strtod') | 284 | ** the CPU (nor by 'strtod') |
| 286 | */ | 285 | */ |
| 287 | #if !defined(NNMARK) | 286 | |
| 287 | /* allows for external implementation for part of the trick */ | ||
| 288 | #if !defined(NNMARK) /* { */ | ||
| 289 | |||
| 290 | |||
| 291 | #if !defined(LUA_IEEEENDIAN) | ||
| 292 | #error option 'LUA_NANTRICK' needs 'LUA_IEEEENDIAN' | ||
| 293 | #endif | ||
| 294 | |||
| 295 | |||
| 288 | #define NNMARK 0x7FF7A500 | 296 | #define NNMARK 0x7FF7A500 |
| 289 | #define NNMASK 0x7FFFFF00 | 297 | #define NNMASK 0x7FFFFF00 |
| 290 | #endif | ||
| 291 | 298 | ||
| 292 | #undef TValuefields | 299 | #undef TValuefields |
| 293 | #undef NILCONSTANT | 300 | #undef NILCONSTANT |
| 294 | 301 | ||
| 295 | #if defined(LUA_NANTRICK_LE) | 302 | #if (LUA_IEEEENDIAN == 0) /* { */ |
| 296 | 303 | ||
| 297 | /* little endian */ | 304 | /* little endian */ |
| 298 | #define TValuefields \ | 305 | #define TValuefields \ |
| @@ -303,7 +310,7 @@ typedef struct lua_TValue TValue; | |||
| 303 | #define d_(o) ((o)->u.d__) | 310 | #define d_(o) ((o)->u.d__) |
| 304 | #define tt_(o) ((o)->u.i.tt__) | 311 | #define tt_(o) ((o)->u.i.tt__) |
| 305 | 312 | ||
| 306 | #elif defined(LUA_NANTRICK_BE) | 313 | #else /* }{ */ |
| 307 | 314 | ||
| 308 | /* big endian */ | 315 | /* big endian */ |
| 309 | #define TValuefields \ | 316 | #define TValuefields \ |
| @@ -314,10 +321,9 @@ typedef struct lua_TValue TValue; | |||
| 314 | #define d_(o) ((o)->u.d__) | 321 | #define d_(o) ((o)->u.d__) |
| 315 | #define tt_(o) ((o)->u.i.tt__) | 322 | #define tt_(o) ((o)->u.i.tt__) |
| 316 | 323 | ||
| 317 | #elif !defined(TValuefields) | 324 | #endif /* } */ |
| 318 | #error option 'LUA_NANTRICK' needs declaration for 'TValuefields' | ||
| 319 | 325 | ||
| 320 | #endif | 326 | #endif /* } */ |
| 321 | 327 | ||
| 322 | 328 | ||
| 323 | /* correspondence with standard representation */ | 329 | /* correspondence with standard representation */ |
| @@ -367,14 +373,9 @@ typedef struct lua_TValue TValue; | |||
| 367 | (ttisnumber(o1) ? ttisnumber(o2) : (tt_(o1) == tt_(o2))) | 373 | (ttisnumber(o1) ? ttisnumber(o2) : (tt_(o1) == tt_(o2))) |
| 368 | 374 | ||
| 369 | 375 | ||
| 370 | 376 | #undef luai_checknum | |
| 371 | #define luai_checknum(L,o,c) { if (!ttisnumber(o)) c; } | 377 | #define luai_checknum(L,o,c) { if (!ttisnumber(o)) c; } |
| 372 | 378 | ||
| 373 | |||
| 374 | #else | ||
| 375 | |||
| 376 | #define luai_checknum(L,o,c) { /* empty */ } | ||
| 377 | |||
| 378 | #endif | 379 | #endif |
| 379 | /* }====================================================== */ | 380 | /* }====================================================== */ |
| 380 | 381 | ||
