From fd80e63468f0c08fedd8dbf944fa4954b72d7384 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 13 Jun 2011 11:13:06 -0300 Subject: configuration for NaN trick big-endian + macro 'luai_checknum' to ensure numbers comming from C are not "improper" (some kinds of signaling NaNs) --- luaconf.h | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'luaconf.h') diff --git a/luaconf.h b/luaconf.h index 202655ba..d0c9f17d 100644 --- a/luaconf.h +++ b/luaconf.h @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.157 2011/04/29 13:56:28 roberto Exp roberto $ +** $Id: luaconf.h,v 1.158 2011/05/26 16:09:40 roberto Exp roberto $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -465,11 +465,11 @@ /* @@ 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. +** (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(i386) || \ +#if defined(__i386__) || defined(__i386) || defined(__X86__) || \ defined (__x86_64) #define LUA_IEEEENDIAN 0 #elif defined(__POWERPC__) || defined(__ppc__) @@ -485,6 +485,30 @@ /* }================================================================== */ +/* +@@ LUA_NANTRICKLE/LUA_NANTRICKBE 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) /* { */ + +#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ + +/* little-endian architectures that satisfy those conditions */ +#if defined(__i386__) || defined(__i386) || defined(__X86__) + +#define LUA_NANTRICKLE + +#endif + +#endif /* } */ + +#endif /* } */ + + /* =================================================================== */ -- cgit v1.2.3-55-g6feb