diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_cconv.c | 7 | ||||
-rw-r--r-- | src/lj_obj.h | 11 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/lj_cconv.c b/src/lj_cconv.c index 5df33d04..b123c081 100644 --- a/src/lj_cconv.c +++ b/src/lj_cconv.c | |||
@@ -200,13 +200,8 @@ void lj_cconv_ct_ct(CTState *cts, CType *d, CType *s, | |||
200 | } else if (dsize == 8) { | 200 | } else if (dsize == 8) { |
201 | if (!(dinfo & CTF_UNSIGNED)) | 201 | if (!(dinfo & CTF_UNSIGNED)) |
202 | *(int64_t *)dp = (int64_t)n; | 202 | *(int64_t *)dp = (int64_t)n; |
203 | #ifdef _MSC_VER | ||
204 | else if (n >= 9223372036854775808.0) /* They think it's a feature. */ | ||
205 | *(uint64_t *)dp = (uint64_t)(int64_t)(n - 9223372036854775808.0) + | ||
206 | U64x(80000000,00000000); | ||
207 | #endif | ||
208 | else | 203 | else |
209 | *(uint64_t *)dp = (uint64_t)n; | 204 | *(uint64_t *)dp = lj_num2u64(n); |
210 | } else { | 205 | } else { |
211 | goto err_conv; /* NYI: conversion to >64 bit integers. */ | 206 | goto err_conv; /* NYI: conversion to >64 bit integers. */ |
212 | } | 207 | } |
diff --git a/src/lj_obj.h b/src/lj_obj.h index d735b0e8..456aef0b 100644 --- a/src/lj_obj.h +++ b/src/lj_obj.h | |||
@@ -763,6 +763,17 @@ static LJ_AINLINE int32_t lj_num2bit(lua_Number n) | |||
763 | #define lj_num2int(n) ((int32_t)(n)) | 763 | #define lj_num2int(n) ((int32_t)(n)) |
764 | #endif | 764 | #endif |
765 | 765 | ||
766 | static LJ_AINLINE uint64_t lj_num2u64(lua_Number n) | ||
767 | { | ||
768 | #ifdef _MSC_VER | ||
769 | if (n >= 9223372036854775808.0) /* They think it's a feature. */ | ||
770 | return (uint64_t)(int64_t)(n - 9223372036854775808.0) + | ||
771 | U64x(80000000,00000000); | ||
772 | else | ||
773 | #endif | ||
774 | return (uint64_t)n; | ||
775 | } | ||
776 | |||
766 | /* -- Miscellaneous object handling --------------------------------------- */ | 777 | /* -- Miscellaneous object handling --------------------------------------- */ |
767 | 778 | ||
768 | /* Names and maps for internal and external object tags. */ | 779 | /* Names and maps for internal and external object tags. */ |