diff options
author | Mike Pall <mike> | 2014-04-01 00:30:22 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2014-04-01 00:30:22 +0200 |
commit | 19b69f21d409375ad8362c04186b246c1749fc8e (patch) | |
tree | 485af25c1188317a3c299afb7e703b05cafdc873 /src/lj_carith.c | |
parent | c735293921724b3d660d2353c08f2ce15887b71d (diff) | |
download | luajit-19b69f21d409375ad8362c04186b246c1749fc8e.tar.gz luajit-19b69f21d409375ad8362c04186b246c1749fc8e.tar.bz2 luajit-19b69f21d409375ad8362c04186b246c1749fc8e.zip |
FFI: Allow non-scalar cdata to be compared for equality by address.
Diffstat (limited to 'src/lj_carith.c')
-rw-r--r-- | src/lj_carith.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lj_carith.c b/src/lj_carith.c index 9f94091d..92fe5597 100644 --- a/src/lj_carith.c +++ b/src/lj_carith.c | |||
@@ -73,7 +73,7 @@ static int carith_checkarg(lua_State *L, CTState *cts, CDArith *ca) | |||
73 | ok = 1; | 73 | ok = 1; |
74 | } else { | 74 | } else { |
75 | ca->ct[1-i] = ct; /* Use enum to improve error message. */ | 75 | ca->ct[1-i] = ct; /* Use enum to improve error message. */ |
76 | ca->p[1-i] = NULL; | 76 | ca->p[1-i] = (void *)(intptr_t)1; /* To make it unequal. */ |
77 | break; | 77 | break; |
78 | } | 78 | } |
79 | } | 79 | } |
@@ -234,7 +234,9 @@ static int lj_carith_meta(lua_State *L, CTState *cts, CDArith *ca, MMS mm) | |||
234 | const char *repr[2]; | 234 | const char *repr[2]; |
235 | int i, isenum = -1, isstr = -1; | 235 | int i, isenum = -1, isstr = -1; |
236 | if (mm == MM_eq) { /* Equality checks never raise an error. */ | 236 | if (mm == MM_eq) { /* Equality checks never raise an error. */ |
237 | setboolV(L->top-1, 0); | 237 | int eq = ca->p[0] == ca->p[1]; |
238 | setboolV(L->top-1, eq); | ||
239 | setboolV(&G(L)->tmptv2, eq); /* Remember for trace recorder. */ | ||
238 | return 1; | 240 | return 1; |
239 | } | 241 | } |
240 | for (i = 0; i < 2; i++) { | 242 | for (i = 0; i < 2; i++) { |