aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2011-07-23 16:29:47 +0200
committerMike Pall <mike>2011-07-23 16:29:47 +0200
commitd001d7b7ce0126558e4b442aa1d0cd88fee43570 (patch)
treec6d3964c8042e8088d7dac4a429ab446fcde167e /src
parentb261d0ec046d3b20bc37826344be3049a144de24 (diff)
downloadluajit-d001d7b7ce0126558e4b442aa1d0cd88fee43570.tar.gz
luajit-d001d7b7ce0126558e4b442aa1d0cd88fee43570.tar.bz2
luajit-d001d7b7ce0126558e4b442aa1d0cd88fee43570.zip
FFI: Treat function ctypes like pointers in comparisons.
Diffstat (limited to 'src')
-rw-r--r--src/lj_carith.c7
-rw-r--r--src/lj_crecord.c4
2 files changed, 10 insertions, 1 deletions
diff --git a/src/lj_carith.c b/src/lj_carith.c
index 8f644d83..b0f4c65a 100644
--- a/src/lj_carith.c
+++ b/src/lj_carith.c
@@ -35,11 +35,16 @@ static int carith_checkarg(lua_State *L, CTState *cts, CDArith *ca)
35 for (i = 0; i < 2; i++, o++) { 35 for (i = 0; i < 2; i++, o++) {
36 if (tviscdata(o)) { 36 if (tviscdata(o)) {
37 GCcdata *cd = cdataV(o); 37 GCcdata *cd = cdataV(o);
38 CType *ct = ctype_raw(cts, (CTypeID)cd->typeid); 38 CTypeID id = (CTypeID)cd->typeid;
39 CType *ct = ctype_raw(cts, id);
39 uint8_t *p = (uint8_t *)cdataptr(cd); 40 uint8_t *p = (uint8_t *)cdataptr(cd);
40 if (ctype_isptr(ct->info)) { 41 if (ctype_isptr(ct->info)) {
41 p = (uint8_t *)cdata_getptr(p, ct->size); 42 p = (uint8_t *)cdata_getptr(p, ct->size);
42 if (ctype_isref(ct->info)) ct = ctype_rawchild(cts, ct); 43 if (ctype_isref(ct->info)) ct = ctype_rawchild(cts, ct);
44 } else if (ctype_isfunc(ct->info)) {
45 p = (uint8_t *)*(void **)p;
46 ct = ctype_get(cts,
47 lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR));
43 } 48 }
44 ca->ct[i] = ct; 49 ca->ct[i] = ct;
45 ca->p[i] = p; 50 ca->p[i] = p;
diff --git a/src/lj_crecord.c b/src/lj_crecord.c
index 743137de..180f255c 100644
--- a/src/lj_crecord.c
+++ b/src/lj_crecord.c
@@ -969,6 +969,10 @@ void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)
969 tr = emitir(IRT(IR_FLOAD, t), tr, IRFL_CDATA_INT64); 969 tr = emitir(IRT(IR_FLOAD, t), tr, IRFL_CDATA_INT64);
970 lj_needsplit(J); 970 lj_needsplit(J);
971 goto ok; 971 goto ok;
972 } else if (ctype_isfunc(ct->info)) {
973 tr = emitir(IRT(IR_FLOAD, IRT_PTR), tr, IRFL_CDATA_PTR);
974 ct = ctype_get(cts,
975 lj_ctype_intern(cts, CTINFO(CT_PTR, CTALIGN_PTR|id), CTSIZE_PTR));
972 } else { 976 } else {
973 tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCcdata))); 977 tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCcdata)));
974 } 978 }