diff options
| author | Mike Pall <mike> | 2018-05-20 12:28:10 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2018-05-20 12:28:10 +0200 |
| commit | 362f034c1b91d52ea2cf971314ed4e0c24348bff (patch) | |
| tree | 10145c2aed6b7ebdc89b32c2fae6015ab61b7f35 | |
| parent | 260b9b4834c891c408e558d7017839d4a247346f (diff) | |
| parent | f5d424afe8b9395f0df05aba905e0e1f6a2262b8 (diff) | |
| download | luajit-362f034c1b91d52ea2cf971314ed4e0c24348bff.tar.gz luajit-362f034c1b91d52ea2cf971314ed4e0c24348bff.tar.bz2 luajit-362f034c1b91d52ea2cf971314ed4e0c24348bff.zip | |
Merge branch 'master' into v2.1
| -rw-r--r-- | src/lj_obj.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/lj_obj.h b/src/lj_obj.h index c7e47422..72b7ace8 100644 --- a/src/lj_obj.h +++ b/src/lj_obj.h | |||
| @@ -942,14 +942,22 @@ static LJ_AINLINE int32_t lj_num2bit(lua_Number n) | |||
| 942 | 942 | ||
| 943 | #define lj_num2int(n) ((int32_t)(n)) | 943 | #define lj_num2int(n) ((int32_t)(n)) |
| 944 | 944 | ||
| 945 | /* | ||
| 946 | ** This must match the JIT backend behavior. In particular for archs | ||
| 947 | ** that don't have a common hardware instruction for this conversion. | ||
| 948 | ** Note that signed FP to unsigned int conversions have an undefined | ||
| 949 | ** result and should never be relied upon in portable FFI code. | ||
| 950 | ** See also: C99 or C11 standard, 6.3.1.4, footnote of (1). | ||
| 951 | */ | ||
| 945 | static LJ_AINLINE uint64_t lj_num2u64(lua_Number n) | 952 | static LJ_AINLINE uint64_t lj_num2u64(lua_Number n) |
| 946 | { | 953 | { |
| 947 | #ifdef _MSC_VER | 954 | #if LJ_TARGET_X86ORX64 || LJ_TARGET_MIPS |
| 948 | if (n >= 9223372036854775808.0) /* They think it's a feature. */ | 955 | int64_t i = (int64_t)n; |
| 949 | return (uint64_t)(int64_t)(n - 18446744073709551616.0); | 956 | if (i < 0) i = (int64_t)(n - 18446744073709551616.0); |
| 950 | else | 957 | return (uint64_t)i; |
| 958 | #else | ||
| 959 | return (uint64_t)n; | ||
| 951 | #endif | 960 | #endif |
| 952 | return (uint64_t)n; | ||
| 953 | } | 961 | } |
| 954 | 962 | ||
| 955 | static LJ_AINLINE int32_t numberVint(cTValue *o) | 963 | static LJ_AINLINE int32_t numberVint(cTValue *o) |
