[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [BUG] lua 5.2 luai_hashnum bug with threads
- From: Coda Highland <chighland@...>
- Date: Tue, 22 Apr 2014 06:45:17 -0700
On Tue, Apr 22, 2014 at 5:01 AM, Andrei <mrpuzzler@yandex.ru> wrote:
> 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);}
>
With all due respect, that's not ANSI C. Syntactically, sure, but
_control87 is specific to x86 and isn't portable.
/s/ Adam