Fix `is_x86_64` on Linux 32-bit x86-64 server
This commit is contained in:
parent
c7f08b5c7a
commit
761b2b050a
|
@ -68,7 +68,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gmod"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
dependencies = [
|
||||
"cstr",
|
||||
"ctor",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "gmod"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
authors = ["William Venner <william@venner.io>"]
|
||||
edition = "2018"
|
||||
license = "MIT"
|
||||
|
|
|
@ -18,9 +18,15 @@ pub mod hax;
|
|||
|
||||
/// Returns whether this client is running the x86-64 branch
|
||||
///
|
||||
/// Current implementation checks the LuaJIT version exported by lua_shared
|
||||
/// Current implementation checks the contents of the bin/ directory, so this is a blocking operation and requires syscalls, use sparingly
|
||||
pub fn is_x86_64() -> bool {
|
||||
lua::LUA_SHARED.x86_64
|
||||
use std::path::PathBuf;
|
||||
#[cfg(target_os = "linux")] {
|
||||
PathBuf::from("bin/linux64").is_dir()
|
||||
}
|
||||
#[cfg(target_os = "windows")] {
|
||||
PathBuf::from("bin/win64").is_dir()
|
||||
}
|
||||
}
|
||||
|
||||
/// Opens & returns a shared library loaded by Garry's Mod using the raw path to the module.
|
||||
|
|
|
@ -73,8 +73,6 @@ lazy_static::lazy_static! {
|
|||
}
|
||||
|
||||
pub(crate) struct LuaShared {
|
||||
pub x86_64: bool,
|
||||
|
||||
pub lual_loadfile: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, path: LuaString) -> i32>,
|
||||
pub lual_loadstring: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, path: LuaString) -> i32>,
|
||||
pub lua_getfield: Symbol<'static, unsafe extern "C-unwind" fn(state: LuaState, index: i32, k: LuaString)>,
|
||||
|
@ -134,8 +132,6 @@ impl LuaShared {
|
|||
}
|
||||
|
||||
Self {
|
||||
x86_64: library.get::<unsafe extern "C-unwind" fn()>(b"luaJIT_version_2_1_0_beta3\0").is_ok(),
|
||||
|
||||
lual_loadfile: find_symbol!("luaL_loadfile"),
|
||||
lual_loadstring: find_symbol!("luaL_loadstring"),
|
||||
lua_getfield: find_symbol!("lua_getfield"),
|
||||
|
|
Loading…
Reference in New Issue