mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-17 01:51:39 +09:00
Allow compilation on Redox
This commit is contained in:
@@ -60,7 +60,7 @@ mod subprocess;
|
||||
mod winapi;
|
||||
#[cfg(windows)]
|
||||
mod winreg;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(not(any(target_arch = "wasm32", target_os = "redox")))]
|
||||
mod zlib;
|
||||
|
||||
pub type StdlibInitFunc = Box<dyn Fn(&VirtualMachine) -> PyObjectRef>;
|
||||
@@ -124,6 +124,7 @@ pub fn get_module_inits() -> HashMap<String, StdlibInitFunc> {
|
||||
modules.insert("signal".to_owned(), Box::new(signal::make_module));
|
||||
modules.insert("select".to_owned(), Box::new(select::make_module));
|
||||
modules.insert("_subprocess".to_owned(), Box::new(subprocess::make_module));
|
||||
#[cfg(not(target_os = "redox"))]
|
||||
modules.insert("zlib".to_owned(), Box::new(zlib::make_module));
|
||||
modules.insert(
|
||||
"faulthandler".to_owned(),
|
||||
|
||||
@@ -890,7 +890,7 @@ fn os_chdir(path: PyStringRef, vm: &VirtualMachine) -> PyResult<()> {
|
||||
env::set_current_dir(path.as_str()).map_err(|err| convert_io_error(vm, err))
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[cfg(all(unix, not(target_os = "redox")))]
|
||||
fn os_chroot(path: PyStringRef, vm: &VirtualMachine) -> PyResult<()> {
|
||||
nix::unistd::chroot(path.as_str()).map_err(|err| convert_nix_error(vm, err))
|
||||
}
|
||||
@@ -1340,6 +1340,7 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
|
||||
#[cfg(unix)]
|
||||
support_funcs.extend(vec![
|
||||
SupportFunc::new(vm, "chmod", os_chmod, Some(false), Some(false), Some(false)),
|
||||
#[cfg(not(target_os = "redox"))]
|
||||
SupportFunc::new(vm, "chroot", os_chroot, Some(false), None, None),
|
||||
]);
|
||||
let supports_fd = PySet::default().into_ref(vm);
|
||||
@@ -1427,7 +1428,6 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) ->
|
||||
extend_module!(vm, module, {
|
||||
"access" => ctx.new_function(os_access),
|
||||
"chmod" => ctx.new_function(os_chmod),
|
||||
"chroot" => ctx.new_function(os_chroot),
|
||||
"get_inheritable" => ctx.new_function(os_get_inheritable), // TODO: windows
|
||||
"get_blocking" => ctx.new_function(os_get_blocking),
|
||||
"getppid" => ctx.new_function(os_getppid),
|
||||
@@ -1468,6 +1468,7 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) ->
|
||||
|
||||
#[cfg(not(target_os = "redox"))]
|
||||
extend_module!(vm, module, {
|
||||
"chroot" => ctx.new_function(os_chroot),
|
||||
"getsid" => ctx.new_function(os_getsid),
|
||||
"setsid" => ctx.new_function(os_setsid),
|
||||
"setegid" => ctx.new_function(os_setegid),
|
||||
|
||||
Reference in New Issue
Block a user