commit 74c544d68c07bcd416225598cdf15f88e62fd457
Merge: 8071aa4 b03a56f
Author: Mike Pall <mike>
Date: Mon Jan 29 12:53:42 2018 +0100
Merge branch 'master' into v2.1
From b03a56f28ec360bbcf43091afd0607890a4a33c7 Mon Sep 17 00:00:00 2001
From: Mike Pall <mike>
Date: Mon, 29 Jan 2018 12:47:08 +0100
Subject: [PATCH 31/72] FFI: Don't assert on #1LL (5.2 compatibility mode
only).
Reported by Denis Golovan.
---
src/lib_ffi.c | 2 +-
src/lj_carith.c | 9 +++++++++
src/lj_carith.h | 1 +
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/lib_ffi.c b/src/lib_ffi.c
index f2f2ede..83483d9 100644
--- a/src/lib_ffi.c
+++ b/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)
diff --git a/src/lj_carith.c b/src/lj_carith.c
index 6224dee..c34596c 100644
--- a/src/lj_carith.c
+++ b/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 bit operations helpers --------------------------------------- */
#if LJ_64
diff --git a/src/lj_carith.h b/src/lj_carith.h
index 3c15591..82fc824 100644
--- a/src/lj_carith.h
+++ b/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_FUNC uint64_t lj_carith_shl64(uint64_t x, int32_t sh);
--
2.20.1