summaryrefslogtreecommitdiff
path: root/src/lj_carith.c
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/lj_carith.c
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/lj_carith.c')
-rw-r--r--src/lj_carith.c7
1 files changed, 6 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;