Skip to content

Commit 99b7a5b

Browse files
authored
Merge pull request RustPython#4723 from coolreader18/redox-compat
Fix redox
2 parents 4fba939 + 725dac2 commit 99b7a5b

File tree

12 files changed

+52
-49
lines changed

12 files changed

+52
-49
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ jobs:
232232
- name: Prepare repository for redox compilation
233233
run: bash scripts/redox/uncomment-cargo.sh
234234
- name: Check compilation for Redox
235-
if: false # FIXME: redoxer toolchain is from ~july 2021, edition2021 isn't stabilized
236235
uses: coolreader18/redoxer-action@v1
237236
with:
238237
command: check

Cargo.lock

Lines changed: 5 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# REDOX START
2-
# cargo-features = ["edition2021"]
3-
# REDOX END
41
[package]
52
name = "rustpython"
63
version = "0.2.0"
@@ -49,7 +46,7 @@ once_cell = "1.13"
4946
parking_lot = "0.12"
5047
paste = "1.0.7"
5148
rand = "0.8.5"
52-
rustyline = "10.0.0"
49+
rustyline = "11"
5350
serde = "1.0"
5451
schannel = "0.1.19"
5552
static_assertions = "1.1"
@@ -131,4 +128,7 @@ lto = "thin"
131128

132129
[patch.crates-io]
133130
# REDOX START, Uncomment when you want to compile/check with redoxer
131+
# nix = { git = "https://github.com/coolreader18/nix", branch = "0.26.2-redox" }
132+
# errno = { git = "https://github.com/coolreader18/rust-errno", branch = "0.2.8-redox" }
133+
# libc = { git = "https://github.com/rust-lang/libc" }
134134
# REDOX END

stdlib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ flate2 = "1.0.23"
7777
bzip2 = { version = "0.4", optional = true }
7878

7979
# uuid
80-
[target.'cfg(not(any(target_os = "ios", target_os = "android", target_os = "windows", target_arch = "wasm32")))'.dependencies]
80+
[target.'cfg(not(any(target_os = "ios", target_os = "android", target_os = "windows", target_arch = "wasm32", target_os = "redox")))'.dependencies]
8181
mac_address = "1.1.3"
8282
uuid = { version = "1.1.2", features = ["v1", "fast-rng", "macro-diagnostics"] }
8383

stdlib/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mod statistics;
3030
mod bz2;
3131
#[cfg(not(target_arch = "wasm32"))]
3232
pub mod socket;
33-
#[cfg(unix)]
33+
#[cfg(all(unix, not(target_os = "redox")))]
3434
mod syslog;
3535
mod unicodedata;
3636
mod zlib;
@@ -62,7 +62,8 @@ mod termios;
6262
target_os = "android",
6363
target_os = "ios",
6464
target_os = "windows",
65-
target_arch = "wasm32"
65+
target_arch = "wasm32",
66+
target_os = "redox",
6667
)))]
6768
mod uuid;
6869

@@ -138,11 +139,11 @@ pub fn get_module_inits() -> impl Iterator<Item = (Cow<'static, str>, StdlibInit
138139
#[cfg(unix)]
139140
{
140141
"_posixsubprocess" => posixsubprocess::make_module,
141-
"syslog" => syslog::make_module,
142142
"mmap" => mmap::make_module,
143143
}
144144
#[cfg(all(unix, not(target_os = "redox")))]
145145
{
146+
"syslog" => syslog::make_module,
146147
"resource" => resource::make_module,
147148
}
148149
#[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
157158
{
158159
"_scproxy" => scproxy::make_module,
159160
}
160-
#[cfg(not(any(target_os = "android", target_os = "ios", target_os = "windows", target_arch = "wasm32")))]
161+
#[cfg(not(any(target_os = "android", target_os = "ios", target_os = "windows", target_arch = "wasm32", target_os = "redox")))]
161162
{
162163
"_uuid" => uuid::make_module,
163164
}

stdlib/src/locale.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ mod _locale {
5050
ptr,
5151
};
5252

53-
#[cfg(all(unix, not(any(target_os = "ios", target_os = "android"))))]
53+
#[cfg(all(
54+
unix,
55+
not(any(target_os = "ios", target_os = "android", target_os = "redox"))
56+
))]
5457
#[pyattr]
5558
use libc::{
5659
ABDAY_1, ABDAY_2, ABDAY_3, ABDAY_4, ABDAY_5, ABDAY_6, ABDAY_7, ABMON_1, ABMON_10, ABMON_11,

stdlib/src/mmap.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mod mmap {
2727
use std::fs::File;
2828
use std::io::Write;
2929
use std::ops::{Deref, DerefMut};
30-
#[cfg(all(unix, not(target_os = "redox")))]
30+
#[cfg(unix)]
3131
use std::os::unix::io::{FromRawFd, IntoRawFd, RawFd};
3232

3333
fn advice_try_from_i32(vm: &VirtualMachine, i: i32) -> PyResult<Advice> {
@@ -224,6 +224,7 @@ mod mmap {
224224
end: Option<isize>,
225225
}
226226

227+
#[cfg(not(target_os = "redox"))]
227228
#[derive(FromArgs)]
228229
pub struct AdviseOptions {
229230
#[pyarg(positional)]
@@ -234,6 +235,7 @@ mod mmap {
234235
length: Option<PyIntRef>,
235236
}
236237

238+
#[cfg(not(target_os = "redox"))]
237239
impl AdviseOptions {
238240
fn values(self, len: usize, vm: &VirtualMachine) -> PyResult<(libc::c_int, usize, usize)> {
239241
let start = self
@@ -273,7 +275,7 @@ mod mmap {
273275
type Args = MmapNewArgs;
274276

275277
// TODO: Windows is not supported right now.
276-
#[cfg(all(unix, not(target_os = "redox")))]
278+
#[cfg(unix)]
277279
fn py_new(
278280
cls: PyTypeRef,
279281
MmapNewArgs {
@@ -671,6 +673,7 @@ mod mmap {
671673
Ok(())
672674
}
673675

676+
#[cfg(not(target_os = "redox"))]
674677
#[allow(unused_assignments)]
675678
#[pymethod]
676679
fn madvise(&self, options: AdviseOptions, vm: &VirtualMachine) -> PyResult<()> {

stdlib/src/socket.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,20 @@ mod _socket {
5353
#[pyattr]
5454
// put IPPROTO_MAX later
5555
use c::{
56-
AF_DECnet, AF_APPLETALK, AF_INET, AF_INET6, AF_IPX, AF_UNSPEC, INADDR_ANY, INADDR_LOOPBACK,
57-
INADDR_NONE, IPPROTO_AH, IPPROTO_DSTOPTS, IPPROTO_EGP, IPPROTO_ESP, IPPROTO_FRAGMENT,
58-
IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_ICMPV6, IPPROTO_IDP, IPPROTO_IGMP, IPPROTO_IP,
59-
IPPROTO_IP as IPPROTO_IPIP, IPPROTO_IPV6, IPPROTO_NONE, IPPROTO_PIM, IPPROTO_PUP,
60-
IPPROTO_RAW, IPPROTO_ROUTING, IPPROTO_TCP, IPPROTO_TCP as SOL_TCP, IPPROTO_UDP, MSG_CTRUNC,
61-
MSG_DONTROUTE, MSG_OOB, MSG_PEEK, MSG_TRUNC, MSG_WAITALL, NI_DGRAM, NI_MAXHOST,
62-
NI_NAMEREQD, NI_NOFQDN, NI_NUMERICHOST, NI_NUMERICSERV, SHUT_RD, SHUT_RDWR, SHUT_WR,
63-
SOCK_DGRAM, SOCK_STREAM, SOL_SOCKET, SO_BROADCAST, SO_ERROR, SO_LINGER, SO_OOBINLINE,
64-
SO_REUSEADDR, SO_TYPE, TCP_NODELAY,
56+
AF_INET, AF_INET6, AF_UNSPEC, INADDR_ANY, INADDR_LOOPBACK, INADDR_NONE, IPPROTO_ICMP,
57+
IPPROTO_ICMPV6, IPPROTO_IP, IPPROTO_IP as IPPROTO_IPIP, IPPROTO_IPV6, IPPROTO_TCP,
58+
IPPROTO_TCP as SOL_TCP, IPPROTO_UDP, MSG_CTRUNC, MSG_DONTROUTE, MSG_OOB, MSG_PEEK,
59+
MSG_TRUNC, MSG_WAITALL, NI_DGRAM, NI_MAXHOST, NI_NAMEREQD, NI_NOFQDN, NI_NUMERICHOST,
60+
NI_NUMERICSERV, SHUT_RD, SHUT_RDWR, SHUT_WR, SOCK_DGRAM, SOCK_STREAM, SOL_SOCKET,
61+
SO_BROADCAST, SO_ERROR, SO_LINGER, SO_OOBINLINE, SO_REUSEADDR, SO_TYPE, TCP_NODELAY,
62+
};
63+
64+
#[cfg(not(target_os = "redox"))]
65+
#[pyattr]
66+
use c::{
67+
AF_DECnet, AF_APPLETALK, AF_IPX, IPPROTO_AH, IPPROTO_DSTOPTS, IPPROTO_EGP, IPPROTO_ESP,
68+
IPPROTO_FRAGMENT, IPPROTO_HOPOPTS, IPPROTO_IDP, IPPROTO_IGMP, IPPROTO_NONE, IPPROTO_PIM,
69+
IPPROTO_PUP, IPPROTO_RAW, IPPROTO_ROUTING,
6570
};
6671

6772
#[cfg(unix)]

vm/src/readline.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ mod rustyline_readline {
6666

6767
/// Readline: the REPL
6868
pub struct Readline<H: Helper> {
69-
repl: rustyline::Editor<H>,
69+
repl: rustyline::Editor<H, rustyline::history::DefaultHistory>,
7070
}
7171

7272
impl<H: Helper> Readline<H> {
@@ -100,7 +100,7 @@ mod rustyline_readline {
100100
}
101101

102102
pub fn add_history_entry(&mut self, entry: &str) -> OtherResult<()> {
103-
self.repl.add_history_entry(entry);
103+
self.repl.add_history_entry(entry)?;
104104
Ok(())
105105
}
106106

vm/src/stdlib/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,7 @@ pub(super) mod _os {
16851685
}
16861686

16871687
cfg_if::cfg_if! {
1688-
if #[cfg(target_os = "android")] {
1688+
if #[cfg(any(target_os = "android", target_os = "redox"))] {
16891689
Ok(Some("UTF-8".to_owned()))
16901690
} else if #[cfg(windows)] {
16911691
let cp = match fd {

0 commit comments

Comments
 (0)