Bladeren bron

FFI: Don't assert on #1LL (5.2 compatibility mode only).

Reported by Denis Golovan.
Mike Pall 7 jaren geleden
bovenliggende
commit
b03a56f28e
3 gewijzigde bestanden met toevoegingen van 11 en 1 verwijderingen
  1. 1 1
      src/lib_ffi.c
  2. 9 0
      src/lj_carith.c
  3. 1 0
      src/lj_carith.h

+ 1 - 1
src/lib_ffi.c

@@ -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)

+ 9 - 0
src/lj_carith.c

@@ -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

+ 1 - 0
src/lj_carith.h

@@ -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);