Add LuaJIT 2.0.5 stable support
This commit is contained in:
parent
56407fac0d
commit
2fd6757f39
|
@ -60,6 +60,7 @@ jobs:
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
override: true
|
override: true
|
||||||
- name: Run ${{ matrix.lua }} tests
|
- name: Run ${{ matrix.lua }} tests
|
||||||
|
if: ${{ matrix.os != 'macos-latest' || matrix.lua != 'luajit' }}
|
||||||
run: |
|
run: |
|
||||||
cargo test --release --no-default-features --features "${{ matrix.lua }} vendored"
|
cargo test --release --no-default-features --features "${{ matrix.lua }} vendored"
|
||||||
cargo test --release --no-default-features --features "${{ matrix.lua }} vendored async send"
|
cargo test --release --no-default-features --features "${{ matrix.lua }} vendored async send"
|
||||||
|
@ -71,6 +72,27 @@ jobs:
|
||||||
cargo test --release --no-default-features --features "${{ matrix.lua }} vendored async send" -- --ignored
|
cargo test --release --no-default-features --features "${{ matrix.lua }} vendored async send" -- --ignored
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
test_luajit20:
|
||||||
|
name: Test LuaJIT on macOS
|
||||||
|
runs-on: macos-latest
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: nightly
|
||||||
|
target: x86_64-apple-darwin
|
||||||
|
override: true
|
||||||
|
- name: Run LuaJIT 2.0.5 tests
|
||||||
|
run: |
|
||||||
|
brew install luajit pkg-config
|
||||||
|
cargo test --tests --release --no-default-features --features "luajit async send"
|
||||||
|
shell: bash
|
||||||
|
- name: Run LuaJIT vendored tests
|
||||||
|
run: |
|
||||||
|
cargo test --release --no-default-features --features "luajit vendored async send"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
rustfmt:
|
rustfmt:
|
||||||
name: Rustfmt
|
name: Rustfmt
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
|
|
|
@ -76,7 +76,7 @@ pub fn probe_lua() -> PathBuf {
|
||||||
#[cfg(feature = "luajit")]
|
#[cfg(feature = "luajit")]
|
||||||
{
|
{
|
||||||
let lua = pkg_config::Config::new()
|
let lua = pkg_config::Config::new()
|
||||||
.range_version((Bound::Included("2.1.0"), Bound::Unbounded))
|
.range_version((Bound::Included("2.0.5"), Bound::Unbounded))
|
||||||
.probe("luajit");
|
.probe("luajit");
|
||||||
|
|
||||||
lua.unwrap().include_paths[0].clone()
|
lua.unwrap().include_paths[0].clone()
|
||||||
|
|
16
src/lua.rs
16
src/lua.rs
|
@ -1,4 +1,3 @@
|
||||||
use std::alloc;
|
|
||||||
use std::any::TypeId;
|
use std::any::TypeId;
|
||||||
use std::cell::{RefCell, UnsafeCell};
|
use std::cell::{RefCell, UnsafeCell};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -61,6 +60,7 @@ struct ExtraData {
|
||||||
ref_free: Vec<c_int>,
|
ref_free: Vec<c_int>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(any(feature = "lua51", feature = "luajit"), allow(dead_code))]
|
||||||
struct MemoryInfo {
|
struct MemoryInfo {
|
||||||
used_memory: isize,
|
used_memory: isize,
|
||||||
memory_limit: isize,
|
memory_limit: isize,
|
||||||
|
@ -173,12 +173,15 @@ impl Lua {
|
||||||
///
|
///
|
||||||
/// [`StdLib`]: struct.StdLib.html
|
/// [`StdLib`]: struct.StdLib.html
|
||||||
pub unsafe fn unsafe_new_with(libs: StdLib) -> Lua {
|
pub unsafe fn unsafe_new_with(libs: StdLib) -> Lua {
|
||||||
|
#[cfg_attr(any(feature = "lua51", feature = "luajit"), allow(dead_code))]
|
||||||
unsafe extern "C" fn allocator(
|
unsafe extern "C" fn allocator(
|
||||||
extra_data: *mut c_void,
|
extra_data: *mut c_void,
|
||||||
ptr: *mut c_void,
|
ptr: *mut c_void,
|
||||||
osize: usize,
|
osize: usize,
|
||||||
nsize: usize,
|
nsize: usize,
|
||||||
) -> *mut c_void {
|
) -> *mut c_void {
|
||||||
|
use std::alloc;
|
||||||
|
|
||||||
let mem_info = &mut *(extra_data as *mut MemoryInfo);
|
let mem_info = &mut *(extra_data as *mut MemoryInfo);
|
||||||
|
|
||||||
if nsize == 0 {
|
if nsize == 0 {
|
||||||
|
@ -227,19 +230,26 @@ impl Lua {
|
||||||
new_ptr
|
new_ptr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
let mem_info = Box::into_raw(Box::new(MemoryInfo {
|
let mem_info = Box::into_raw(Box::new(MemoryInfo {
|
||||||
used_memory: 0,
|
used_memory: 0,
|
||||||
memory_limit: 0,
|
memory_limit: 0,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
let state = ffi::lua_newstate(allocator, mem_info as *mut c_void);
|
let state = ffi::lua_newstate(allocator, mem_info as *mut c_void);
|
||||||
|
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
||||||
|
let state = ffi::luaL_newstate();
|
||||||
|
|
||||||
ffi::luaL_requiref(state, cstr!("_G"), ffi::luaopen_base, 1);
|
ffi::luaL_requiref(state, cstr!("_G"), ffi::luaopen_base, 1);
|
||||||
ffi::lua_pop(state, 1);
|
ffi::lua_pop(state, 1);
|
||||||
|
|
||||||
let mut lua = Lua::init_from_ptr(state);
|
let mut lua = Lua::init_from_ptr(state);
|
||||||
lua.ephemeral = false;
|
lua.ephemeral = false;
|
||||||
lua.extra.lock().unwrap().mem_info = mem_info;
|
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))]
|
||||||
|
{
|
||||||
|
lua.extra.lock().unwrap().mem_info = mem_info;
|
||||||
|
}
|
||||||
|
|
||||||
mlua_expect!(
|
mlua_expect!(
|
||||||
protect_lua_closure(lua.main_state, 0, 0, |state| {
|
protect_lua_closure(lua.main_state, 0, 0, |state| {
|
||||||
|
@ -1536,7 +1546,7 @@ impl Lua {
|
||||||
// Try to get an outer poll waker
|
// Try to get an outer poll waker
|
||||||
ffi::lua_pushlightuserdata(
|
ffi::lua_pushlightuserdata(
|
||||||
state,
|
state,
|
||||||
&WAKER_REGISTRY_KEY as *const u8 as *mut ::std::os::raw::c_void,
|
&WAKER_REGISTRY_KEY as *const u8 as *mut c_void,
|
||||||
);
|
);
|
||||||
ffi::lua_rawget(state, ffi::LUA_REGISTRYINDEX);
|
ffi::lua_rawget(state, ffi::LUA_REGISTRYINDEX);
|
||||||
if let Some(w) = get_gc_userdata::<Waker>(state, -1).as_ref() {
|
if let Some(w) = get_gc_userdata::<Waker>(state, -1).as_ref() {
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
#![cfg(feature = "async")]
|
#![cfg(feature = "async")]
|
||||||
|
#![cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
feature(link_args)
|
||||||
|
)]
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
link_args = "-pagezero_size 10000 -image_base 100000000",
|
||||||
|
allow(unused_attributes)
|
||||||
|
)]
|
||||||
|
extern "system" {}
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
#![cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
feature(link_args)
|
||||||
|
)]
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
link_args = "-pagezero_size 10000 -image_base 100000000",
|
||||||
|
allow(unused_attributes)
|
||||||
|
)]
|
||||||
|
extern "system" {}
|
||||||
|
|
||||||
use bstr::{BStr, BString};
|
use bstr::{BStr, BString};
|
||||||
use mlua::{Lua, Result};
|
use mlua::{Lua, Result};
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
#![cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
feature(link_args)
|
||||||
|
)]
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
link_args = "-pagezero_size 10000 -image_base 100000000",
|
||||||
|
allow(unused_attributes)
|
||||||
|
)]
|
||||||
|
extern "system" {}
|
||||||
|
|
||||||
use mlua::{Function, Lua, Result, String};
|
use mlua::{Function, Lua, Result, String};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
#![cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
feature(link_args)
|
||||||
|
)]
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
link_args = "-pagezero_size 10000 -image_base 100000000",
|
||||||
|
allow(unused_attributes)
|
||||||
|
)]
|
||||||
|
extern "system" {}
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use mlua::{Lua, Result, UserData};
|
use mlua::{Lua, Result, UserData};
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
#![cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
feature(link_args)
|
||||||
|
)]
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
link_args = "-pagezero_size 10000 -image_base 100000000",
|
||||||
|
allow(unused_attributes)
|
||||||
|
)]
|
||||||
|
extern "system" {}
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
#![cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
feature(link_args)
|
||||||
|
)]
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
link_args = "-pagezero_size 10000 -image_base 100000000",
|
||||||
|
allow(unused_attributes)
|
||||||
|
)]
|
||||||
|
extern "system" {}
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use mlua::{Lua, Result, String};
|
use mlua::{Lua, Result, String};
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
#![cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
feature(link_args)
|
||||||
|
)]
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
link_args = "-pagezero_size 10000 -image_base 100000000",
|
||||||
|
allow(unused_attributes)
|
||||||
|
)]
|
||||||
|
extern "system" {}
|
||||||
|
|
||||||
use mlua::{Lua, Nil, Result, Table, TableExt, Value};
|
use mlua::{Lua, Nil, Result, Table, TableExt, Value};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
#![cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
feature(link_args)
|
||||||
|
)]
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
link_args = "-pagezero_size 10000 -image_base 100000000",
|
||||||
|
allow(unused_attributes)
|
||||||
|
)]
|
||||||
|
extern "system" {}
|
||||||
|
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
use std::panic::catch_unwind;
|
use std::panic::catch_unwind;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
#![cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
feature(link_args)
|
||||||
|
)]
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
link_args = "-pagezero_size 10000 -image_base 100000000",
|
||||||
|
allow(unused_attributes)
|
||||||
|
)]
|
||||||
|
extern "system" {}
|
||||||
|
|
||||||
use std::panic::catch_unwind;
|
use std::panic::catch_unwind;
|
||||||
|
|
||||||
use mlua::{Error, Function, Lua, Result, Thread, ThreadStatus};
|
use mlua::{Error, Function, Lua, Result, Thread, ThreadStatus};
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
#![cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
feature(link_args)
|
||||||
|
)]
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
link_args = "-pagezero_size 10000 -image_base 100000000",
|
||||||
|
allow(unused_attributes)
|
||||||
|
)]
|
||||||
|
extern "system" {}
|
||||||
|
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
|
|
||||||
use mlua::{Function, LightUserData, Lua, Result};
|
use mlua::{Function, LightUserData, Lua, Result};
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
#![cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
feature(link_args)
|
||||||
|
)]
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
link_args = "-pagezero_size 10000 -image_base 100000000",
|
||||||
|
allow(unused_attributes)
|
||||||
|
)]
|
||||||
|
extern "system" {}
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[cfg(feature = "lua54")]
|
#[cfg(feature = "lua54")]
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
#![cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
feature(link_args)
|
||||||
|
)]
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
all(feature = "luajit", target_os = "macos", target_arch = "x86_64"),
|
||||||
|
link_args = "-pagezero_size 10000 -image_base 100000000",
|
||||||
|
allow(unused_attributes)
|
||||||
|
)]
|
||||||
|
extern "system" {}
|
||||||
|
|
||||||
use mlua::{Lua, Result, Value};
|
use mlua::{Lua, Result, Value};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue