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 9f65523f3..227edcab1 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -786,7 +786,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(); @@ -815,7 +815,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(); @@ -831,7 +831,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| ()) @@ -845,7 +845,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(); @@ -1029,14 +1029,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), "openpty" => ctx.new_rustfunc(os_openpty), });