From d44a208da972677a7bf72adb15c2228efcd1c16b Mon Sep 17 00:00:00 2001 From: coolreader18 <33094578+coolreader18@users.noreply.github.com> Date: Sat, 3 Aug 2019 17:13:32 -0500 Subject: [PATCH] Fix redox with new os functions --- Cargo.lock | 1 + Cargo.toml | 6 ++++++ vm/src/stdlib/os.rs | 18 +++++++++++------- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e05958928..a8ea01dc1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1058,6 +1058,7 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode_categories 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode_names2 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wtf8 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 9a163b07a..b55f47497 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,3 +41,9 @@ version = "0.2" [[bin]] name = "rustpython" path = "src/main.rs" + +# Uncommment when you want to compile/check with redoxer +# [patch.crates-io] +# time = { git = "https://gitlab.redox-os.org/redox-os/time.git", branch = "redox-unix" } +# libc = { git = "https://github.com/AdminXVII/libc", branch = "extra-traits-redox" } +# nix = { git = "https://github.com/AdminXVII/nix", branch = "add-redox-support" } diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index d510699c9..7cf6aaa3e 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -783,7 +783,7 @@ fn os_getpgid(pid: PyIntRef, vm: &VirtualMachine) -> PyObjectRef { } } -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "redox")))] fn os_getsid(pid: PyIntRef, vm: &VirtualMachine) -> PyObjectRef { let pid = pid.as_bigint().to_u32().unwrap(); @@ -812,7 +812,7 @@ fn os_setgid(gid: PyIntRef, vm: &VirtualMachine) -> PyResult<()> { unistd::setgid(Gid::from_raw(gid)).map_err(|err| convert_nix_error(vm, err)) } -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "redox")))] fn os_setegid(egid: PyIntRef, vm: &VirtualMachine) -> PyResult<()> { let egid = egid.as_bigint().to_u32().unwrap(); @@ -828,7 +828,7 @@ fn os_setpgid(pid: PyIntRef, pgid: PyIntRef, vm: &VirtualMachine) -> PyResult<() .map_err(|err| convert_nix_error(vm, err)) } -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "redox")))] fn os_setsid(vm: &VirtualMachine) -> PyResult<()> { unistd::setsid() .map(|_ok| ()) @@ -842,7 +842,7 @@ fn os_setuid(uid: PyIntRef, vm: &VirtualMachine) -> PyResult<()> { unistd::setuid(Uid::from_raw(uid)).map_err(|err| convert_nix_error(vm, err)) } -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "redox")))] fn os_seteuid(euid: PyIntRef, vm: &VirtualMachine) -> PyResult<()> { let euid = euid.as_bigint().to_u32().unwrap(); @@ -1016,14 +1016,18 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) -> "getgid" => ctx.new_rustfunc(os_getgid), "getegid" => ctx.new_rustfunc(os_getegid), "getpgid" => ctx.new_rustfunc(os_getpgid), - "getsid" => ctx.new_rustfunc(os_getsid), "getuid" => ctx.new_rustfunc(os_getuid), "geteuid" => ctx.new_rustfunc(os_geteuid), "setgid" => ctx.new_rustfunc(os_setgid), - "setegid" => ctx.new_rustfunc(os_setegid), "setpgid" => ctx.new_rustfunc(os_setpgid), - "setsid" => ctx.new_rustfunc(os_setsid), "setuid" => ctx.new_rustfunc(os_setuid), + }); + + #[cfg(not(target_os = "redox"))] + extend_module!(vm, module, { + "getsid" => ctx.new_rustfunc(os_getsid), + "setsid" => ctx.new_rustfunc(os_setsid), + "setegid" => ctx.new_rustfunc(os_setegid), "seteuid" => ctx.new_rustfunc(os_seteuid), });