Fix redox

This commit is contained in:
Noa
2023-03-09 16:11:10 -06:00
parent 4fba939726
commit 725dac204f
12 changed files with 52 additions and 49 deletions

View File

@@ -232,7 +232,6 @@ jobs:
- name: Prepare repository for redox compilation
run: bash scripts/redox/uncomment-cargo.sh
- name: Check compilation for Redox
if: false # FIXME: redoxer toolchain is from ~july 2021, edition2021 isn't stabilized
uses: coolreader18/redoxer-action@v1
with:
command: check

22
Cargo.lock generated
View File

@@ -1123,9 +1123,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.139"
version = "0.2.140"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
[[package]]
name = "libffi"
@@ -1337,18 +1337,6 @@ dependencies = [
"memoffset 0.6.5",
]
[[package]]
name = "nix"
version = "0.25.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4"
dependencies = [
"autocfg",
"bitflags",
"cfg-if",
"libc",
]
[[package]]
name = "nix"
version = "0.26.2"
@@ -2281,9 +2269,9 @@ checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70"
[[package]]
name = "rustyline"
version = "10.1.1"
version = "11.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1e83c32c3f3c33b08496e0d1df9ea8c64d39adb8eb36a1ebb1440c690697aef"
checksum = "5dfc8644681285d1fb67a467fb3021bfea306b99b4146b166a1fe3ada965eece"
dependencies = [
"bitflags",
"cfg-if",
@@ -2293,7 +2281,7 @@ dependencies = [
"libc",
"log",
"memchr",
"nix 0.25.1",
"nix 0.26.2",
"radix_trie",
"scopeguard",
"unicode-segmentation",

View File

@@ -1,6 +1,3 @@
# REDOX START
# cargo-features = ["edition2021"]
# REDOX END
[package]
name = "rustpython"
version = "0.2.0"
@@ -49,7 +46,7 @@ once_cell = "1.13"
parking_lot = "0.12"
paste = "1.0.7"
rand = "0.8.5"
rustyline = "10.0.0"
rustyline = "11"
serde = "1.0"
schannel = "0.1.19"
static_assertions = "1.1"
@@ -131,4 +128,7 @@ lto = "thin"
[patch.crates-io]
# REDOX START, Uncomment when you want to compile/check with redoxer
# nix = { git = "https://github.com/coolreader18/nix", branch = "0.26.2-redox" }
# errno = { git = "https://github.com/coolreader18/rust-errno", branch = "0.2.8-redox" }
# libc = { git = "https://github.com/rust-lang/libc" }
# REDOX END

View File

@@ -77,7 +77,7 @@ flate2 = "1.0.23"
bzip2 = { version = "0.4", optional = true }
# uuid
[target.'cfg(not(any(target_os = "ios", target_os = "android", target_os = "windows", target_arch = "wasm32")))'.dependencies]
[target.'cfg(not(any(target_os = "ios", target_os = "android", target_os = "windows", target_arch = "wasm32", target_os = "redox")))'.dependencies]
mac_address = "1.1.3"
uuid = { version = "1.1.2", features = ["v1", "fast-rng", "macro-diagnostics"] }

View File

@@ -30,7 +30,7 @@ mod statistics;
mod bz2;
#[cfg(not(target_arch = "wasm32"))]
pub mod socket;
#[cfg(unix)]
#[cfg(all(unix, not(target_os = "redox")))]
mod syslog;
mod unicodedata;
mod zlib;
@@ -62,7 +62,8 @@ mod termios;
target_os = "android",
target_os = "ios",
target_os = "windows",
target_arch = "wasm32"
target_arch = "wasm32",
target_os = "redox",
)))]
mod uuid;
@@ -138,11 +139,11 @@ pub fn get_module_inits() -> impl Iterator<Item = (Cow<'static, str>, StdlibInit
#[cfg(unix)]
{
"_posixsubprocess" => posixsubprocess::make_module,
"syslog" => syslog::make_module,
"mmap" => mmap::make_module,
}
#[cfg(all(unix, not(target_os = "redox")))]
{
"syslog" => syslog::make_module,
"resource" => resource::make_module,
}
#[cfg(all(unix, not(any(target_os = "ios", target_os = "redox"))))]
@@ -157,7 +158,7 @@ pub fn get_module_inits() -> impl Iterator<Item = (Cow<'static, str>, StdlibInit
{
"_scproxy" => scproxy::make_module,
}
#[cfg(not(any(target_os = "android", target_os = "ios", target_os = "windows", target_arch = "wasm32")))]
#[cfg(not(any(target_os = "android", target_os = "ios", target_os = "windows", target_arch = "wasm32", target_os = "redox")))]
{
"_uuid" => uuid::make_module,
}

View File

@@ -50,7 +50,10 @@ mod _locale {
ptr,
};
#[cfg(all(unix, not(any(target_os = "ios", target_os = "android"))))]
#[cfg(all(
unix,
not(any(target_os = "ios", target_os = "android", target_os = "redox"))
))]
#[pyattr]
use libc::{
ABDAY_1, ABDAY_2, ABDAY_3, ABDAY_4, ABDAY_5, ABDAY_6, ABDAY_7, ABMON_1, ABMON_10, ABMON_11,

View File

@@ -27,7 +27,7 @@ mod mmap {
use std::fs::File;
use std::io::Write;
use std::ops::{Deref, DerefMut};
#[cfg(all(unix, not(target_os = "redox")))]
#[cfg(unix)]
use std::os::unix::io::{FromRawFd, IntoRawFd, RawFd};
fn advice_try_from_i32(vm: &VirtualMachine, i: i32) -> PyResult<Advice> {
@@ -224,6 +224,7 @@ mod mmap {
end: Option<isize>,
}
#[cfg(not(target_os = "redox"))]
#[derive(FromArgs)]
pub struct AdviseOptions {
#[pyarg(positional)]
@@ -234,6 +235,7 @@ mod mmap {
length: Option<PyIntRef>,
}
#[cfg(not(target_os = "redox"))]
impl AdviseOptions {
fn values(self, len: usize, vm: &VirtualMachine) -> PyResult<(libc::c_int, usize, usize)> {
let start = self
@@ -273,7 +275,7 @@ mod mmap {
type Args = MmapNewArgs;
// TODO: Windows is not supported right now.
#[cfg(all(unix, not(target_os = "redox")))]
#[cfg(unix)]
fn py_new(
cls: PyTypeRef,
MmapNewArgs {
@@ -671,6 +673,7 @@ mod mmap {
Ok(())
}
#[cfg(not(target_os = "redox"))]
#[allow(unused_assignments)]
#[pymethod]
fn madvise(&self, options: AdviseOptions, vm: &VirtualMachine) -> PyResult<()> {

View File

@@ -53,15 +53,20 @@ mod _socket {
#[pyattr]
// put IPPROTO_MAX later
use c::{
AF_DECnet, AF_APPLETALK, AF_INET, AF_INET6, AF_IPX, AF_UNSPEC, INADDR_ANY, INADDR_LOOPBACK,
INADDR_NONE, IPPROTO_AH, IPPROTO_DSTOPTS, IPPROTO_EGP, IPPROTO_ESP, IPPROTO_FRAGMENT,
IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_ICMPV6, IPPROTO_IDP, IPPROTO_IGMP, IPPROTO_IP,
IPPROTO_IP as IPPROTO_IPIP, IPPROTO_IPV6, IPPROTO_NONE, IPPROTO_PIM, IPPROTO_PUP,
IPPROTO_RAW, IPPROTO_ROUTING, IPPROTO_TCP, IPPROTO_TCP as SOL_TCP, IPPROTO_UDP, MSG_CTRUNC,
MSG_DONTROUTE, MSG_OOB, MSG_PEEK, MSG_TRUNC, MSG_WAITALL, NI_DGRAM, NI_MAXHOST,
NI_NAMEREQD, NI_NOFQDN, NI_NUMERICHOST, NI_NUMERICSERV, SHUT_RD, SHUT_RDWR, SHUT_WR,
SOCK_DGRAM, SOCK_STREAM, SOL_SOCKET, SO_BROADCAST, SO_ERROR, SO_LINGER, SO_OOBINLINE,
SO_REUSEADDR, SO_TYPE, TCP_NODELAY,
AF_INET, AF_INET6, AF_UNSPEC, INADDR_ANY, INADDR_LOOPBACK, INADDR_NONE, IPPROTO_ICMP,
IPPROTO_ICMPV6, IPPROTO_IP, IPPROTO_IP as IPPROTO_IPIP, IPPROTO_IPV6, IPPROTO_TCP,
IPPROTO_TCP as SOL_TCP, IPPROTO_UDP, MSG_CTRUNC, MSG_DONTROUTE, MSG_OOB, MSG_PEEK,
MSG_TRUNC, MSG_WAITALL, NI_DGRAM, NI_MAXHOST, NI_NAMEREQD, NI_NOFQDN, NI_NUMERICHOST,
NI_NUMERICSERV, SHUT_RD, SHUT_RDWR, SHUT_WR, SOCK_DGRAM, SOCK_STREAM, SOL_SOCKET,
SO_BROADCAST, SO_ERROR, SO_LINGER, SO_OOBINLINE, SO_REUSEADDR, SO_TYPE, TCP_NODELAY,
};
#[cfg(not(target_os = "redox"))]
#[pyattr]
use c::{
AF_DECnet, AF_APPLETALK, AF_IPX, IPPROTO_AH, IPPROTO_DSTOPTS, IPPROTO_EGP, IPPROTO_ESP,
IPPROTO_FRAGMENT, IPPROTO_HOPOPTS, IPPROTO_IDP, IPPROTO_IGMP, IPPROTO_NONE, IPPROTO_PIM,
IPPROTO_PUP, IPPROTO_RAW, IPPROTO_ROUTING,
};
#[cfg(unix)]

View File

@@ -66,7 +66,7 @@ mod rustyline_readline {
/// Readline: the REPL
pub struct Readline<H: Helper> {
repl: rustyline::Editor<H>,
repl: rustyline::Editor<H, rustyline::history::DefaultHistory>,
}
impl<H: Helper> Readline<H> {
@@ -100,7 +100,7 @@ mod rustyline_readline {
}
pub fn add_history_entry(&mut self, entry: &str) -> OtherResult<()> {
self.repl.add_history_entry(entry);
self.repl.add_history_entry(entry)?;
Ok(())
}

View File

@@ -1685,7 +1685,7 @@ pub(super) mod _os {
}
cfg_if::cfg_if! {
if #[cfg(target_os = "android")] {
if #[cfg(any(target_os = "android", target_os = "redox"))] {
Ok(Some("UTF-8".to_owned()))
} else if #[cfg(windows)] {
let cp = match fd {

View File

@@ -429,6 +429,10 @@ pub mod module {
)
}
#[cfg(not(target_os = "redox"))]
const MKNOD_DIR_FD: bool = cfg!(not(target_vendor = "apple"));
#[cfg(not(target_os = "redox"))]
#[derive(FromArgs)]
struct MknodArgs {
#[pyarg(any)]
@@ -437,11 +441,11 @@ pub mod module {
mode: libc::mode_t,
#[pyarg(any)]
device: libc::dev_t,
#[allow(unused)]
#[pyarg(flatten)]
dir_fd: DirFd<1>,
dir_fd: DirFd<{ MKNOD_DIR_FD as usize }>,
}
#[cfg(not(target_os = "redox"))]
impl MknodArgs {
fn _mknod(self, vm: &VirtualMachine) -> PyResult<i32> {
Ok(unsafe {
@@ -473,6 +477,7 @@ pub mod module {
}
#[cfg(target_vendor = "apple")]
fn mknod(self, vm: &VirtualMachine) -> PyResult<()> {
let [] = self.dir_fd.0;
let ret = self._mknod(vm)?;
if ret != 0 {
Err(errno_err(vm))
@@ -482,6 +487,7 @@ pub mod module {
}
}
#[cfg(not(target_os = "redox"))]
#[pyfunction]
fn mknod(args: MknodArgs, vm: &VirtualMachine) -> PyResult<()> {
args.mknod(vm)
@@ -1568,10 +1574,8 @@ pub mod module {
SupportFunc::new("lchown", None, None, None),
#[cfg(not(target_os = "redox"))]
SupportFunc::new("fchown", Some(true), None, Some(true)),
#[cfg(not(target_os = "macos"))]
SupportFunc::new("mknod", Some(true), Some(true), Some(false)),
#[cfg(target_os = "macos")]
SupportFunc::new("mknod", Some(true), Some(false), Some(false)),
#[cfg(not(target_os = "redox"))]
SupportFunc::new("mknod", Some(true), Some(MKNOD_DIR_FD), Some(false)),
SupportFunc::new("umask", Some(false), Some(false), Some(false)),
SupportFunc::new("execv", None, None, None),
SupportFunc::new("pathconf", Some(true), None, None),

View File

@@ -552,7 +552,7 @@ mod unix {
target_os = "linux",
)))]
#[pyfunction]
fn get_clock_info(_name: PyStrRef, vm: &VirtualMachine) -> PyResult<PyNamespace> {
fn get_clock_info(_name: PyStrRef, vm: &VirtualMachine) -> PyResult<PyRef<PyNamespace>> {
Err(vm.new_not_implemented_error("get_clock_info unsupported on this system".to_owned()))
}