summaryrefslogtreecommitdiff
path: root/src/lj_carith.c
diff options
context:
space:
mode:
authorMike Pall <mike>2011-02-27 01:31:22 +0100
committerMike Pall <mike>2011-02-27 01:31:22 +0100
commitc031d4b6a06eab94e8d9b837ec6dc257899a4ae1 (patch)
tree785116fc10de78f3414604fcd9b403a0e63dfa0e /src/lj_carith.c
parentd437086c5a82cb44ba34d039695aff79e7a1793c (diff)
downloadluajit-c031d4b6a06eab94e8d9b837ec6dc257899a4ae1.tar.gz
luajit-c031d4b6a06eab94e8d9b837ec6dc257899a4ae1.tar.bz2
luajit-c031d4b6a06eab94e8d9b837ec6dc257899a4ae1.zip
DUALNUM: Handle integer type in FFI.
Diffstat (limited to 'src/lj_carith.c')
-rw-r--r--src/lj_carith.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lj_carith.c b/src/lj_carith.c
index f1435e1e..a59665d8 100644
--- a/src/lj_carith.c
+++ b/src/lj_carith.c
@@ -41,6 +41,9 @@ static int carith_checkarg(lua_State *L, CTState *cts, CDArith *ca)
41 } 41 }
42 ca->ct[i] = ct; 42 ca->ct[i] = ct;
43 ca->p[i] = p; 43 ca->p[i] = p;
44 } else if (tvisint(o)) {
45 ca->ct[i] = ctype_get(cts, CTID_INT32);
46 ca->p[i] = (uint8_t *)&o->i;
44 } else if (tvisnum(o)) { 47 } else if (tvisnum(o)) {
45 ca->ct[i] = ctype_get(cts, CTID_DOUBLE); 48 ca->ct[i] = ctype_get(cts, CTID_DOUBLE);
46 ca->p[i] = (uint8_t *)&o->n; 49 ca->p[i] = (uint8_t *)&o->n;
@@ -84,7 +87,7 @@ static int carith_ptr(lua_State *L, CTState *cts, CDArith *ca, MMS mm)
84 /* All valid pointer differences on x64 are in (-2^47, +2^47), 87 /* All valid pointer differences on x64 are in (-2^47, +2^47),
85 ** which fits into a double without loss of precision. 88 ** which fits into a double without loss of precision.
86 */ 89 */
87 setnumV(L->top-1, (lua_Number)diff); 90 setintptrV(L->top-1, (int32_t)diff);
88 return 1; 91 return 1;
89 } else if (mm == MM_lt) { /* Pointer comparison (unsigned). */ 92 } else if (mm == MM_lt) { /* Pointer comparison (unsigned). */
90 setboolV(L->top-1, ((uintptr_t)pp < (uintptr_t)pp2)); 93 setboolV(L->top-1, ((uintptr_t)pp < (uintptr_t)pp2));