better(?) handling of '#define's for IEEE-related tricks + avoid using

IEEE trick for 64-bit integer types (lua_Integer on 64-bit machines)
This commit is contained in:
Roberto Ierusalimschy
2012-05-11 11:10:50 -03:00
parent 4ec7d6de95
commit 77cbd817d1
3 changed files with 82 additions and 66 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: luaconf.h,v 1.169 2011/11/30 12:35:05 roberto Exp roberto $
** $Id: luaconf.h,v 1.170 2011/12/06 16:58:36 roberto Exp roberto $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
@@ -453,66 +453,76 @@
#define LUA_UNSIGNED unsigned LUA_INT32
#if defined(LUA_CORE) /* { */
#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */
/*
** Some tricks with doubles
*/
/* On a Microsoft compiler on a Pentium, use assembler to avoid clashes
with a DirectX idiosyncrasy */
#if defined(LUA_CORE) && \
defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */
/*
** The next definitions activate some tricks to speed up the
** conversion from doubles to integer types, mainly to LUA_UNSIGNED.
**
@@ MS_ASMTRICK uses Microsoft assembler to avoid clashes with a
** DirectX idiosyncrasy.
**
@@ LUA_IEEE754TRICK uses a trick that should work on any machine
** using IEEE754 with a 32-bit integer type.
**
@@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be
** defined when LUA_INTEGER is a 32-bit integer.
**
@@ LUA_IEEEENDIAN is the endianness of doubles in your machine
** (0 for little endian, 1 for big endian); if not defined, Lua will
** check it dynamically for LUA_IEEE754TRICK (but not for LUA_NANTRICK).
**
@@ LUA_NANTRICK controls the use of a trick to pack all types into
** a single double value, using NaN values to represent non-number
** values. The trick only works on 32-bit machines (ints and pointers
** are 32-bit values) with numbers represented as IEEE 754-2008 doubles
** with conventional endianess (12345678 or 87654321), in CPUs that do
** not produce signaling NaN values (all NaNs are quiet).
*/
/* Microsoft compiler on a Pentium (32 bit) ? */
#if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */
#define MS_ASMTRICK
#define LUA_IEEEENDIAN 0
#define LUA_NANTRICK
#else /* }{ */
/* the next definition uses a trick that should work on any machine
using IEEE754 with a 32-bit integer type */
/* pentium 32 bits? */
#elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */
#define LUA_IEEE754TRICK
#define LUA_IEEELL
#define LUA_IEEEENDIAN 0
#define LUA_NANTRICK
/*
@@ LUA_IEEEENDIAN is the endianness of doubles in your machine
** (0 for little endian, 1 for big endian); if not defined, Lua will
** check it dynamically.
*/
/* check for known architectures */
#if defined(__i386__) || defined(__i386) || defined(__X86__) || \
defined (__x86_64)
#define LUA_IEEEENDIAN 0
#elif defined(__POWERPC__) || defined(__ppc__)
#define LUA_IEEEENDIAN 1
#endif
/* pentium 64 bits? */
#elif defined(__x86_64) /* }{ */
#endif /* } */
#define LUA_IEEE754TRICK
#define LUA_IEEEENDIAN 0
#endif /* } */
#elif defined(__POWERPC__) || defined(__ppc__) /* }{ */
#endif /* } */
#define LUA_IEEE754TRICK
#define LUA_IEEEENDIAN 1
/* }================================================================== */
#else /* }{ */
/* assume IEEE754 and a 32-bit integer type */
#define LUA_IEEE754TRICK
/*
@@ LUA_NANTRICK_LE/LUA_NANTRICK_BE controls the use of a trick to
** pack all types into a single double value, using NaN values to
** represent non-number values. The trick only works on 32-bit machines
** (ints and pointers are 32-bit values) with numbers represented as
** IEEE 754-2008 doubles with conventional endianess (12345678 or
** 87654321), in CPUs that do not produce signaling NaN values (all NaNs
** are quiet).
*/
#if defined(LUA_CORE) && \
defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */
/* little-endian architectures that satisfy those conditions */
#if defined(__i386__) || defined(__i386) || defined(__X86__) || \
defined(_M_IX86)
#define LUA_NANTRICK_LE
#endif
#endif /* } */
#endif /* } */
/* }================================================================== */