AM_CONDITIONAL([HAVE_LUA], [test "x$enable_lua" != "xno"])
+ # If Lua is enabled, test the integer size.
+ if test "x$enable_lua" = "xyes"; then
+ AC_MSG_CHECKING([size of lua integer])
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include <lua.h> ]],
+ [[
+ if (sizeof(lua_Integer) == 8) {
+ exit(1);
+ }
+ exit(0);
+ ]])],
+ [
+ AC_MSG_RESULT([4])
+ ],
+ [
+ AC_MSG_RESULT([8])
+ AC_SUBST([LUA_INT8], ["lua_int8"])
+ ])
+ fi
+
# libmaxminddb
AC_ARG_ENABLE(geoip,
AS_HELP_STRING([--enable-geoip],[Enable GeoIP2 support]),
use std::os::raw::c_int;
use std::os::raw::c_long;
+#[cfg(feature = "lua_int8")]
+type LuaInteger = i64;
+
+#[cfg(not(feature = "lua_int8"))]
+type LuaInteger = i32;
+
/// The Rust place holder for lua_State.
pub enum CLuaState {}
fn lua_createtable(lua: *mut CLuaState, narr: c_int, nrec: c_int);
fn lua_settable(lua: *mut CLuaState, idx: c_long);
fn lua_pushlstring(lua: *mut CLuaState, s: *const c_char, len: usize);
- fn lua_pushinteger(lua: *mut CLuaState, n: c_long);
+ fn lua_pushinteger(lua: *mut CLuaState, n: LuaInteger);
}
pub struct LuaState {
pub fn pushinteger(&self, val: i64) {
unsafe {
- lua_pushinteger(self.lua, val as c_long);
+ lua_pushinteger(self.lua, val as LuaInteger);
}
}
}