diff options
Diffstat (limited to 'lib/lua/src')
-rw-r--r-- | lib/lua/src/CMakeLists.txt | 18 | ||||
-rw-r--r-- | lib/lua/src/lgc.c | 9 | ||||
-rw-r--r-- | lib/lua/src/luaconf.h | 14 |
3 files changed, 22 insertions, 19 deletions
diff --git a/lib/lua/src/CMakeLists.txt b/lib/lua/src/CMakeLists.txt index 8f6cc1213..2ca4f4168 100644 --- a/lib/lua/src/CMakeLists.txt +++ b/lib/lua/src/CMakeLists.txt @@ -31,24 +31,14 @@ set(LUA_CORE_SRC lvm.c lzio.c ) -set(LUA_LIB_HEADERS - lua.h - lualib.h - lauxlib.h - luaconf.h -) - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}) -# Lua library. +# Lua library add_library(lua STATIC ${LUA_CORE_SRC}) target_link_libraries(lua ${LIBS}) -set(LUA_STATIC_LIB lua) -set(LUA_LIBS lua) - -set_target_properties(${LUA_LIBS} PROPERTIES +set_target_properties(lua PROPERTIES VERSION ${LUA_VERSION} CLEAN_DIRECT_OUTPUT 1 ) +# Compile code as C++ +set_source_files_properties(${LUA_CORE_SRC} PROPERTIES LANGUAGE CXX) diff --git a/lib/lua/src/lgc.c b/lib/lua/src/lgc.c index e909c79a9..9141a1c60 100644 --- a/lib/lua/src/lgc.c +++ b/lib/lua/src/lgc.c @@ -164,8 +164,13 @@ static int traversetable (global_State *g, Table *h) { markobject(g, h->metatable); mode = gfasttm(g, h->metatable, TM_MODE); if (mode && ttisstring(mode)) { /* is there a weak mode? */ - weakkey = (strchr(svalue(mode), 'k') != NULL); - weakvalue = (strchr(svalue(mode), 'v') != NULL); + // Android's 'FORTIFY libc' calls __builtin_object_size on the argument of strchr. + // This produces an incorrect size for the expression `svalue(mode)`, causing + // an assertion. By placing it in a temporary, __builtin_object_size returns + // -1 (for unknown size) which functions correctly. + const char *tmp = svalue(mode); + weakkey = (strchr(tmp, 'k') != NULL); + weakvalue = (strchr(tmp, 'v') != NULL); if (weakkey || weakvalue) { /* is really weak? */ h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */ h->marked |= cast_byte((weakkey << KEYWEAKBIT) | diff --git a/lib/lua/src/luaconf.h b/lib/lua/src/luaconf.h index e2cb26163..1521f0cbc 100644 --- a/lib/lua/src/luaconf.h +++ b/lib/lua/src/luaconf.h @@ -143,6 +143,14 @@ #define LUA_INTEGER ptrdiff_t +/* MINETEST-SPECIFIC CHANGE: make sure API functions conform to the C ABI. */ +#if defined(__cplusplus) +#define LUAI_API_EXTERN extern "C" +#else +#define LUAI_API_EXTERN extern +#endif + + /* @@ LUA_API is a mark for all core API functions. @@ LUALIB_API is a mark for all standard library functions. @@ -154,14 +162,14 @@ #if defined(LUA_BUILD_AS_DLL) #if defined(LUA_CORE) || defined(LUA_LIB) -#define LUA_API __declspec(dllexport) +#define LUA_API LUAI_API_EXTERN __declspec(dllexport) #else -#define LUA_API __declspec(dllimport) +#define LUA_API LUAI_API_EXTERN __declspec(dllimport) #endif #else -#define LUA_API extern +#define LUA_API LUAI_API_EXTERN #endif |