]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
FFI: Don't assert on #1LL (5.2 compatibility mode only).
authorMike Pall <mike>
Mon, 29 Jan 2018 11:47:08 +0000 (12:47 +0100)
committerMike Pall <mike>
Mon, 29 Jan 2018 11:47:08 +0000 (12:47 +0100)
Reported by Denis Golovan.

src/lib_ffi.c
src/lj_carith.c
src/lj_carith.h

index f2f2ede45bebe0db11227b2828339a31599287d1..83483d952d4d3b7e56be6a820816f399f0e3bb00 100644 (file)
@@ -193,7 +193,7 @@ LJLIB_CF(ffi_meta___eq)             LJLIB_REC(cdata_arith MM_eq)
 
 LJLIB_CF(ffi_meta___len)       LJLIB_REC(cdata_arith MM_len)
 {
-  return ffi_arith(L);
+  return lj_carith_len(L);
 }
 
 LJLIB_CF(ffi_meta___lt)                LJLIB_REC(cdata_arith MM_lt)
index 6224dee62d207c24d12040312aced718dd1b3d47..c34596cacf720d9916a34e1b129d24049bbb9a6d 100644 (file)
@@ -272,6 +272,15 @@ int lj_carith_op(lua_State *L, MMS mm)
   return lj_carith_meta(L, cts, &ca, mm);
 }
 
+/* No built-in functionality for length of cdata. */
+int lj_carith_len(lua_State *L)
+{
+  CTState *cts = ctype_cts(L);
+  CDArith ca;
+  carith_checkarg(L, cts, &ca);
+  return lj_carith_meta(L, cts, &ca, MM_len);
+}
+
 /* -- 64 bit integer arithmetic helpers ----------------------------------- */
 
 #if LJ_32 && LJ_HASJIT
index 3c15591072b0fac256c5e466556436a15f6daa7b..82fc8245dbb66fb1d5edd3cfa50499cb9fd00b44 100644 (file)
@@ -11,6 +11,7 @@
 #if LJ_HASFFI
 
 LJ_FUNC int lj_carith_op(lua_State *L, MMS mm);
+LJ_FUNC int lj_carith_len(lua_State *L);
 
 #if LJ_32 && LJ_HASJIT
 LJ_FUNC int64_t lj_carith_mul64(int64_t x, int64_t k);