mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Add lj_num2u64 for number to uint64_t conversion.
This commit is contained in:
parent
4668b229de
commit
dc4b82c33d
@ -200,13 +200,8 @@ void lj_cconv_ct_ct(CTState *cts, CType *d, CType *s,
|
||||
} else if (dsize == 8) {
|
||||
if (!(dinfo & CTF_UNSIGNED))
|
||||
*(int64_t *)dp = (int64_t)n;
|
||||
#ifdef _MSC_VER
|
||||
else if (n >= 9223372036854775808.0) /* They think it's a feature. */
|
||||
*(uint64_t *)dp = (uint64_t)(int64_t)(n - 9223372036854775808.0) +
|
||||
U64x(80000000,00000000);
|
||||
#endif
|
||||
else
|
||||
*(uint64_t *)dp = (uint64_t)n;
|
||||
*(uint64_t *)dp = lj_num2u64(n);
|
||||
} else {
|
||||
goto err_conv; /* NYI: conversion to >64 bit integers. */
|
||||
}
|
||||
|
11
src/lj_obj.h
11
src/lj_obj.h
@ -763,6 +763,17 @@ static LJ_AINLINE int32_t lj_num2bit(lua_Number n)
|
||||
#define lj_num2int(n) ((int32_t)(n))
|
||||
#endif
|
||||
|
||||
static LJ_AINLINE uint64_t lj_num2u64(lua_Number n)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
if (n >= 9223372036854775808.0) /* They think it's a feature. */
|
||||
return (uint64_t)(int64_t)(n - 9223372036854775808.0) +
|
||||
U64x(80000000,00000000);
|
||||
else
|
||||
#endif
|
||||
return (uint64_t)n;
|
||||
}
|
||||
|
||||
/* -- Miscellaneous object handling --------------------------------------- */
|
||||
|
||||
/* Names and maps for internal and external object tags. */
|
||||
|
Loading…
Reference in New Issue
Block a user