diff options
Diffstat (limited to 'src/lj_vmmath.c')
-rw-r--r-- | src/lj_vmmath.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lj_vmmath.c b/src/lj_vmmath.c index d357b4e3..970bb5ad 100644 --- a/src/lj_vmmath.c +++ b/src/lj_vmmath.c | |||
@@ -39,6 +39,20 @@ double lj_vm_exp2(double a) | |||
39 | } | 39 | } |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #if !LJ_TARGET_ARM | ||
43 | int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b) | ||
44 | { | ||
45 | uint32_t y, ua, ub; | ||
46 | lua_assert(b != 0); /* This must be checked before using this function. */ | ||
47 | ua = a < 0 ? -(uint32_t)a : (uint32_t)a; | ||
48 | ub = b < 0 ? -(uint32_t)b : (uint32_t)b; | ||
49 | y = ua % ub; | ||
50 | if (y != 0 && (a^b) < 0) y = y - ub; | ||
51 | if (((int32_t)y^b) < 0) y = -y; | ||
52 | return (int32_t)y; | ||
53 | } | ||
54 | #endif | ||
55 | |||
42 | #if !LJ_TARGET_X86ORX64 | 56 | #if !LJ_TARGET_X86ORX64 |
43 | /* Unsigned x^k. */ | 57 | /* Unsigned x^k. */ |
44 | static double lj_vm_powui(double x, uint32_t k) | 58 | static double lj_vm_powui(double x, uint32_t k) |