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 /luaconf.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 'luaconf.h')
-rw-r--r-- | luaconf.h | 96 |
1 files changed, 53 insertions, 43 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.169 2011/11/30 12:35:05 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.170 2011/12/06 16:58:36 roberto Exp roberto $ |
3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -453,66 +453,76 @@ | |||
453 | #define LUA_UNSIGNED unsigned LUA_INT32 | 453 | #define LUA_UNSIGNED unsigned LUA_INT32 |
454 | 454 | ||
455 | 455 | ||
456 | #if defined(LUA_CORE) /* { */ | ||
457 | 456 | ||
458 | #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ | 457 | /* |
458 | ** Some tricks with doubles | ||
459 | */ | ||
460 | |||
461 | #if defined(LUA_CORE) && \ | ||
462 | defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ | ||
463 | /* | ||
464 | ** The next definitions activate some tricks to speed up the | ||
465 | ** conversion from doubles to integer types, mainly to LUA_UNSIGNED. | ||
466 | ** | ||
467 | @@ MS_ASMTRICK uses Microsoft assembler to avoid clashes with a | ||
468 | ** DirectX idiosyncrasy. | ||
469 | ** | ||
470 | @@ LUA_IEEE754TRICK uses a trick that should work on any machine | ||
471 | ** using IEEE754 with a 32-bit integer type. | ||
472 | ** | ||
473 | @@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be | ||
474 | ** defined when LUA_INTEGER is a 32-bit integer. | ||
475 | ** | ||
476 | @@ LUA_IEEEENDIAN is the endianness of doubles in your machine | ||
477 | ** (0 for little endian, 1 for big endian); if not defined, Lua will | ||
478 | ** check it dynamically for LUA_IEEE754TRICK (but not for LUA_NANTRICK). | ||
479 | ** | ||
480 | @@ LUA_NANTRICK controls the use of a trick to pack all types into | ||
481 | ** a single double value, using NaN values to represent non-number | ||
482 | ** values. The trick only works on 32-bit machines (ints and pointers | ||
483 | ** are 32-bit values) with numbers represented as IEEE 754-2008 doubles | ||
484 | ** with conventional endianess (12345678 or 87654321), in CPUs that do | ||
485 | ** not produce signaling NaN values (all NaNs are quiet). | ||
486 | */ | ||
459 | 487 | ||
460 | /* On a Microsoft compiler on a Pentium, use assembler to avoid clashes | 488 | /* Microsoft compiler on a Pentium (32 bit) ? */ |
461 | with a DirectX idiosyncrasy */ | ||
462 | #if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */ | 489 | #if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */ |
463 | 490 | ||
464 | #define MS_ASMTRICK | 491 | #define MS_ASMTRICK |
492 | #define LUA_IEEEENDIAN 0 | ||
493 | #define LUA_NANTRICK | ||
465 | 494 | ||
466 | #else /* }{ */ | ||
467 | /* the next definition uses a trick that should work on any machine | ||
468 | using IEEE754 with a 32-bit integer type */ | ||
469 | |||
470 | #define LUA_IEEE754TRICK | ||
471 | |||
472 | /* | ||
473 | @@ LUA_IEEEENDIAN is the endianness of doubles in your machine | ||
474 | ** (0 for little endian, 1 for big endian); if not defined, Lua will | ||
475 | ** check it dynamically. | ||
476 | */ | ||
477 | /* check for known architectures */ | ||
478 | #if defined(__i386__) || defined(__i386) || defined(__X86__) || \ | ||
479 | defined (__x86_64) | ||
480 | #define LUA_IEEEENDIAN 0 | ||
481 | #elif defined(__POWERPC__) || defined(__ppc__) | ||
482 | #define LUA_IEEEENDIAN 1 | ||
483 | #endif | ||
484 | 495 | ||
485 | #endif /* } */ | 496 | /* pentium 32 bits? */ |
497 | #elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */ | ||
486 | 498 | ||
487 | #endif /* } */ | 499 | #define LUA_IEEE754TRICK |
500 | #define LUA_IEEELL | ||
501 | #define LUA_IEEEENDIAN 0 | ||
502 | #define LUA_NANTRICK | ||
488 | 503 | ||
489 | #endif /* } */ | 504 | /* pentium 64 bits? */ |
505 | #elif defined(__x86_64) /* }{ */ | ||
490 | 506 | ||
491 | /* }================================================================== */ | 507 | #define LUA_IEEE754TRICK |
508 | #define LUA_IEEEENDIAN 0 | ||
492 | 509 | ||
510 | #elif defined(__POWERPC__) || defined(__ppc__) /* }{ */ | ||
493 | 511 | ||
494 | /* | 512 | #define LUA_IEEE754TRICK |
495 | @@ LUA_NANTRICK_LE/LUA_NANTRICK_BE controls the use of a trick to | 513 | #define LUA_IEEEENDIAN 1 |
496 | ** pack all types into a single double value, using NaN values to | ||
497 | ** represent non-number values. The trick only works on 32-bit machines | ||
498 | ** (ints and pointers are 32-bit values) with numbers represented as | ||
499 | ** IEEE 754-2008 doubles with conventional endianess (12345678 or | ||
500 | ** 87654321), in CPUs that do not produce signaling NaN values (all NaNs | ||
501 | ** are quiet). | ||
502 | */ | ||
503 | #if defined(LUA_CORE) && \ | ||
504 | defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ | ||
505 | 514 | ||
506 | /* little-endian architectures that satisfy those conditions */ | 515 | #else /* }{ */ |
507 | #if defined(__i386__) || defined(__i386) || defined(__X86__) || \ | ||
508 | defined(_M_IX86) | ||
509 | 516 | ||
510 | #define LUA_NANTRICK_LE | 517 | /* assume IEEE754 and a 32-bit integer type */ |
518 | #define LUA_IEEE754TRICK | ||
511 | 519 | ||
512 | #endif | 520 | #endif /* } */ |
513 | 521 | ||
514 | #endif /* } */ | 522 | #endif /* } */ |
515 | 523 | ||
524 | /* }================================================================== */ | ||
525 | |||
516 | 526 | ||
517 | 527 | ||
518 | 528 | ||