From f7d918afd8e23ae48e105957ed9a9f0fa6b5dc04 Mon Sep 17 00:00:00 2001 From: isidentical Date: Sat, 7 Sep 2019 03:16:10 +0300 Subject: [PATCH 1/2] add seek constants, resolves #1348 --- vm/src/stdlib/os.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index 5ffa4b1f9e..9a901b36f2 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -12,7 +12,7 @@ use nix::errno::Errno; #[cfg(all(unix, not(target_os = "redox")))] use nix::pty::openpty; #[cfg(unix)] -use nix::unistd::{self, Gid, Pid, Uid}; +use nix::unistd::{self, Gid, Pid, Uid, Whence}; use num_traits::cast::ToPrimitive; use bitflags::bitflags; @@ -1215,6 +1215,11 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) -> "access" => ctx.new_rustfunc(os_access), "chmod" => ctx.new_rustfunc(os_chmod), "ttyname" => ctx.new_rustfunc(os_ttyname), + "SEEK_SET" => ctx.new_int(Whence::SeekSet as i8), + "SEEK_CUR" => ctx.new_int(Whence::SeekCur as i8), + "SEEK_END" => ctx.new_int(Whence::SeekEnd as i8), + "SEEK_DATA" => ctx.new_int(Whence::SeekData as i8), + "SEEK_HOLE" => ctx.new_int(Whence::SeekHole as i8) }); #[cfg(not(target_os = "redox"))] From caa47221a25734dbb74057cfbe3dd43bf1836c42 Mon Sep 17 00:00:00 2001 From: isidentical Date: Sat, 7 Sep 2019 03:48:00 +0300 Subject: [PATCH 2/2] macos fix --- vm/src/stdlib/os.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index 9a901b36f2..5eddc682f7 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -1217,9 +1217,7 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) -> "ttyname" => ctx.new_rustfunc(os_ttyname), "SEEK_SET" => ctx.new_int(Whence::SeekSet as i8), "SEEK_CUR" => ctx.new_int(Whence::SeekCur as i8), - "SEEK_END" => ctx.new_int(Whence::SeekEnd as i8), - "SEEK_DATA" => ctx.new_int(Whence::SeekData as i8), - "SEEK_HOLE" => ctx.new_int(Whence::SeekHole as i8) + "SEEK_END" => ctx.new_int(Whence::SeekEnd as i8) }); #[cfg(not(target_os = "redox"))] @@ -1231,6 +1229,12 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: PyObjectRef) -> "openpty" => ctx.new_rustfunc(os_openpty), }); + #[cfg(not(target_os = "macos"))] + extend_module!(vm, module, { + "SEEK_DATA" => ctx.new_int(Whence::SeekData as i8), + "SEEK_HOLE" => ctx.new_int(Whence::SeekHole as i8) + }); + module }