diff options
Diffstat (limited to 'src/lj_vmmath.c')
-rw-r--r-- | src/lj_vmmath.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/lj_vmmath.c b/src/lj_vmmath.c index ecad2950..90d8a78e 100644 --- a/src/lj_vmmath.c +++ b/src/lj_vmmath.c | |||
@@ -57,6 +57,20 @@ double lj_vm_foldarith(double x, double y, int op) | |||
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | #if (LJ_HASJIT && !(LJ_TARGET_ARM || LJ_TARGET_ARM64 || LJ_TARGET_PPC)) || LJ_TARGET_MIPS | ||
61 | int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b) | ||
62 | { | ||
63 | uint32_t y, ua, ub; | ||
64 | lua_assert(b != 0); /* This must be checked before using this function. */ | ||
65 | ua = a < 0 ? (uint32_t)-a : (uint32_t)a; | ||
66 | ub = b < 0 ? (uint32_t)-b : (uint32_t)b; | ||
67 | y = ua % ub; | ||
68 | if (y != 0 && (a^b) < 0) y = y - ub; | ||
69 | if (((int32_t)y^b) < 0) y = (uint32_t)-(int32_t)y; | ||
70 | return (int32_t)y; | ||
71 | } | ||
72 | #endif | ||
73 | |||
60 | #if LJ_HASJIT | 74 | #if LJ_HASJIT |
61 | 75 | ||
62 | #ifdef LUAJIT_NO_LOG2 | 76 | #ifdef LUAJIT_NO_LOG2 |
@@ -73,20 +87,6 @@ double lj_vm_exp2(double a) | |||
73 | } | 87 | } |
74 | #endif | 88 | #endif |
75 | 89 | ||
76 | #if !(LJ_TARGET_ARM || LJ_TARGET_ARM64 || LJ_TARGET_PPC) | ||
77 | int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b) | ||
78 | { | ||
79 | uint32_t y, ua, ub; | ||
80 | lua_assert(b != 0); /* This must be checked before using this function. */ | ||
81 | ua = a < 0 ? (uint32_t)-a : (uint32_t)a; | ||
82 | ub = b < 0 ? (uint32_t)-b : (uint32_t)b; | ||
83 | y = ua % ub; | ||
84 | if (y != 0 && (a^b) < 0) y = y - ub; | ||
85 | if (((int32_t)y^b) < 0) y = (uint32_t)-(int32_t)y; | ||
86 | return (int32_t)y; | ||
87 | } | ||
88 | #endif | ||
89 | |||
90 | #if !LJ_TARGET_X86ORX64 | 90 | #if !LJ_TARGET_X86ORX64 |
91 | /* Unsigned x^k. */ | 91 | /* Unsigned x^k. */ |
92 | static double lj_vm_powui(double x, uint32_t k) | 92 | static double lj_vm_powui(double x, uint32_t k) |