[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [BUG] lua 5.2 luai_hashnum bug with threads
- From: Andrei <mrpuzzler@...>
- Date: Tue, 22 Apr 2014 16:01:59 +0400
Here's a simple, ANSI-c fix
#ifndef _control87
#define _control87 _controlfp
#endif
/*
** luai_hashnum is a macro to hash a lua_Number value into an integer.
** The hash must be deterministic and give reasonable values for
** both small and large values (outside the range of integers).
*/
#define luai_hashnum(i,n) { int e, cw; \
cw = _control87(0, 0);\
_control87(_PC_53, MCW_PC); \
n = l_mathop(frexp)(n, &e) * (lua_Number)(INT_MAX - DBL_MAX_EXP); \
lua_number2int(i, n); i += e; \
_control87(cw, MCW_EM);}