Skip to content

Commit 137c733

Browse files
authored
Add support for armv6k-nintendo-3ds. (#1355)
This disables the "mm" and "termios" module entirely on armv6k-nintendo-3ds, as the libc module appears to be lacking basic flags such as `MAP_ANONYMOUS`, `PROT_READ`, and others. But it's at least a first step. Fixes #1023.
1 parent 07cdad6 commit 137c733

44 files changed

Lines changed: 466 additions & 79 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,7 @@ jobs:
223223
# - run: cargo check -Z build-std --target=riscv32imc-esp-espidf --features=all-apis
224224
- run: cargo check -Z build-std --target=aarch64-unknown-nto-qnx710 --features=all-apis
225225
- run: cargo check -Z build-std --target=x86_64-pc-nto-qnx710 --features=all-apis
226-
# Temporarily disable --features=all-apis, which doesn't build yet.
227-
- run: cargo check -Z build-std --target=armv6k-nintendo-3ds
226+
- run: cargo check -Z build-std --target=armv6k-nintendo-3ds --all-features
228227
- run: cargo check -Z build-std --target=armv7-sony-vita-newlibeabihf --features=all-apis
229228
- run: cargo check -Z build-std --target=powerpc64-ibm-aix --features=all-apis
230229
- run: cargo check -Z build-std --target=mipsel-unknown-linux-gnu --features=all-apis

src/backend/libc/fs/dir.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::fs::{fstat, Stat};
1616
#[cfg(not(any(
1717
solarish,
1818
target_os = "haiku",
19+
target_os = "horizon",
1920
target_os = "netbsd",
2021
target_os = "nto",
2122
target_os = "redox",
@@ -217,7 +218,7 @@ impl Dir {
217218
}
218219

219220
/// `fstat(self)`
220-
#[cfg(not(target_os = "vita"))]
221+
#[cfg(not(any(target_os = "horizon", target_os = "vita")))]
221222
#[inline]
222223
pub fn stat(&self) -> io::Result<Stat> {
223224
fstat(unsafe { BorrowedFd::borrow_raw(c::dirfd(self.libc_dir.as_ptr())) })
@@ -227,6 +228,7 @@ impl Dir {
227228
#[cfg(not(any(
228229
solarish,
229230
target_os = "haiku",
231+
target_os = "horizon",
230232
target_os = "netbsd",
231233
target_os = "nto",
232234
target_os = "redox",
@@ -242,6 +244,7 @@ impl Dir {
242244
#[cfg(not(any(
243245
solarish,
244246
target_os = "haiku",
247+
target_os = "horizon",
245248
target_os = "redox",
246249
target_os = "vita",
247250
target_os = "wasi"
@@ -253,7 +256,12 @@ impl Dir {
253256

254257
/// `fchdir(self)`
255258
#[cfg(feature = "process")]
256-
#[cfg(not(any(target_os = "fuchsia", target_os = "vita", target_os = "wasi")))]
259+
#[cfg(not(any(
260+
target_os = "fuchsia",
261+
target_os = "horizon",
262+
target_os = "vita",
263+
target_os = "wasi"
264+
)))]
257265
#[cfg_attr(docsrs, doc(cfg(feature = "process")))]
258266
#[inline]
259267
pub fn chdir(&self) -> io::Result<()> {
@@ -287,7 +295,7 @@ impl Iterator for Dir {
287295
impl fmt::Debug for Dir {
288296
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
289297
let mut s = f.debug_struct("Dir");
290-
#[cfg(not(target_os = "vita"))]
298+
#[cfg(not(any(target_os = "horizon", target_os = "vita")))]
291299
s.field("fd", unsafe { &c::dirfd(self.libc_dir.as_ptr()) });
292300
s.finish()
293301
}

src/backend/libc/fs/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub mod inotify;
55
#[cfg(not(any(
66
target_os = "espidf",
77
target_os = "haiku",
8+
target_os = "horizon",
89
target_os = "redox",
910
target_os = "vita",
1011
target_os = "wasi"

src/backend/libc/fs/syscalls.rs

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,26 @@ use crate::ffi;
1010
use crate::ffi::CStr;
1111
#[cfg(all(apple, feature = "alloc"))]
1212
use crate::ffi::CString;
13-
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
13+
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
1414
use crate::fs::Access;
1515
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
1616
use crate::fs::AtFlags;
1717
#[cfg(not(any(
1818
netbsdlike,
1919
target_os = "dragonfly",
2020
target_os = "espidf",
21+
target_os = "horizon",
2122
target_os = "nto",
2223
target_os = "redox",
2324
target_os = "vita",
2425
)))]
2526
use crate::fs::FallocateFlags;
26-
#[cfg(not(any(target_os = "espidf", target_os = "vita", target_os = "wasi")))]
27+
#[cfg(not(any(
28+
target_os = "espidf",
29+
target_os = "horizon",
30+
target_os = "vita",
31+
target_os = "wasi"
32+
)))]
2733
use crate::fs::FlockOperation;
2834
#[cfg(any(linux_kernel, target_os = "freebsd"))]
2935
use crate::fs::MemfdFlags;
@@ -35,6 +41,7 @@ use crate::fs::SealFlags;
3541
solarish,
3642
target_os = "espidf",
3743
target_os = "haiku",
44+
target_os = "horizon",
3845
target_os = "netbsd",
3946
target_os = "nto",
4047
target_os = "redox",
@@ -75,6 +82,7 @@ use {
7582
target_os = "dragonfly",
7683
target_os = "espidf",
7784
target_os = "haiku",
85+
target_os = "horizon",
7886
target_os = "redox",
7987
target_os = "vita",
8088
)))]
@@ -247,6 +255,7 @@ pub(crate) fn openat(
247255
solarish,
248256
target_os = "espidf",
249257
target_os = "haiku",
258+
target_os = "horizon",
250259
target_os = "netbsd",
251260
target_os = "nto",
252261
target_os = "redox",
@@ -777,14 +786,20 @@ fn statat_old(dirfd: BorrowedFd<'_>, path: &CStr, flags: AtFlags) -> io::Result<
777786
}
778787
}
779788

780-
#[cfg(not(any(target_os = "espidf", target_os = "emscripten", target_os = "vita")))]
789+
#[cfg(not(any(
790+
target_os = "espidf",
791+
target_os = "horizon",
792+
target_os = "emscripten",
793+
target_os = "vita"
794+
)))]
781795
pub(crate) fn access(path: &CStr, access: Access) -> io::Result<()> {
782796
unsafe { ret(c::access(c_str(path), access.bits())) }
783797
}
784798

785799
#[cfg(not(any(
786800
target_os = "emscripten",
787801
target_os = "espidf",
802+
target_os = "horizon",
788803
target_os = "redox",
789804
target_os = "vita"
790805
)))]
@@ -853,7 +868,12 @@ pub(crate) fn accessat(
853868
Ok(())
854869
}
855870

856-
#[cfg(not(any(target_os = "espidf", target_os = "redox", target_os = "vita")))]
871+
#[cfg(not(any(
872+
target_os = "espidf",
873+
target_os = "horizon",
874+
target_os = "redox",
875+
target_os = "vita"
876+
)))]
857877
pub(crate) fn utimensat(
858878
dirfd: BorrowedFd<'_>,
859879
path: &CStr,
@@ -1169,6 +1189,7 @@ pub(crate) fn chownat(
11691189
#[cfg(not(any(
11701190
apple,
11711191
target_os = "espidf",
1192+
target_os = "horizon",
11721193
target_os = "redox",
11731194
target_os = "vita",
11741195
target_os = "wasi"
@@ -1250,6 +1271,7 @@ pub(crate) fn copy_file_range(
12501271
target_os = "dragonfly",
12511272
target_os = "espidf",
12521273
target_os = "haiku",
1274+
target_os = "horizon",
12531275
target_os = "redox",
12541276
target_os = "vita",
12551277
)))]
@@ -1335,6 +1357,7 @@ pub(crate) fn fcntl_add_seals(fd: BorrowedFd<'_>, seals: SealFlags) -> io::Resul
13351357
target_os = "emscripten",
13361358
target_os = "espidf",
13371359
target_os = "fuchsia",
1360+
target_os = "horizon",
13381361
target_os = "redox",
13391362
target_os = "vita",
13401363
target_os = "wasi"
@@ -1460,6 +1483,7 @@ pub(crate) fn fchown(fd: BorrowedFd<'_>, owner: Option<Uid>, group: Option<Gid>)
14601483

14611484
#[cfg(not(any(
14621485
target_os = "espidf",
1486+
target_os = "horizon",
14631487
target_os = "solaris",
14641488
target_os = "vita",
14651489
target_os = "wasi"
@@ -1487,6 +1511,7 @@ pub(crate) fn syncfs(fd: BorrowedFd<'_>) -> io::Result<()> {
14871511

14881512
#[cfg(not(any(
14891513
target_os = "espidf",
1514+
target_os = "horizon",
14901515
target_os = "redox",
14911516
target_os = "vita",
14921517
target_os = "wasi"
@@ -1561,6 +1586,7 @@ fn fstat_old(fd: BorrowedFd<'_>) -> io::Result<Stat> {
15611586
solarish,
15621587
target_os = "espidf",
15631588
target_os = "haiku",
1589+
target_os = "horizon",
15641590
target_os = "netbsd",
15651591
target_os = "nto",
15661592
target_os = "redox",
@@ -1604,7 +1630,7 @@ fn libc_statvfs_to_statvfs(from: c::statvfs) -> StatVfs {
16041630
}
16051631
}
16061632

1607-
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
1633+
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
16081634
pub(crate) fn futimens(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()> {
16091635
// Old 32-bit version: libc has `futimens` but it is not y2038 safe by
16101636
// default. But there may be a `__futimens64` we can use.
@@ -1708,6 +1734,7 @@ fn futimens_old(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()> {
17081734
netbsdlike,
17091735
target_os = "dragonfly",
17101736
target_os = "espidf",
1737+
target_os = "horizon",
17111738
target_os = "nto",
17121739
target_os = "redox",
17131740
target_os = "vita",
@@ -1787,6 +1814,7 @@ pub(crate) fn fsync(fd: BorrowedFd<'_>) -> io::Result<()> {
17871814
target_os = "dragonfly",
17881815
target_os = "espidf",
17891816
target_os = "haiku",
1817+
target_os = "horizon",
17901818
target_os = "redox",
17911819
target_os = "vita",
17921820
)))]

src/backend/libc/fs/types.rs

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::backend::c;
22
use crate::ffi;
33
use bitflags::bitflags;
44

5-
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
5+
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
66
bitflags! {
77
/// `*_OK` constants for use with [`accessat`].
88
///
@@ -27,7 +27,7 @@ bitflags! {
2727
}
2828
}
2929

30-
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
30+
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "redox")))]
3131
bitflags! {
3232
/// `AT_*` constants for use with [`openat`], [`statat`], and other `*at`
3333
/// functions.
@@ -83,6 +83,22 @@ bitflags! {
8383
}
8484
}
8585

86+
#[cfg(target_os = "horizon")]
87+
bitflags! {
88+
/// `AT_*` constants for use with [`openat`], [`statat`], and other `*at`
89+
/// functions.
90+
///
91+
/// [`openat`]: crate::fs::openat
92+
/// [`statat`]: crate::fs::statat
93+
#[repr(transparent)]
94+
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
95+
pub struct AtFlags: u32 {
96+
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
97+
const _ = !0;
98+
}
99+
}
100+
101+
#[cfg(not(target_os = "horizon"))]
86102
bitflags! {
87103
/// `S_I*` constants for use with [`openat`], [`chmodat`], and [`fchmod`].
88104
///
@@ -157,6 +173,21 @@ bitflags! {
157173
}
158174
}
159175

176+
#[cfg(target_os = "horizon")]
177+
bitflags! {
178+
/// `S_I*` constants for use with [`openat`], [`chmodat`], and [`fchmod`].
179+
///
180+
/// [`openat`]: crate::fs::openat
181+
/// [`chmodat`]: crate::fs::chmodat
182+
/// [`fchmod`]: crate::fs::fchmod
183+
#[repr(transparent)]
184+
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
185+
pub struct Mode: RawMode {
186+
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
187+
const _ = !0;
188+
}
189+
}
190+
160191
#[cfg(not(target_os = "espidf"))]
161192
impl Mode {
162193
/// Construct a `Mode` from the mode bits of the `st_mode` field of a
@@ -228,11 +259,11 @@ bitflags! {
228259
const CREATE = bitcast!(c::O_CREAT);
229260

230261
/// `O_DIRECTORY`
231-
#[cfg(not(target_os = "espidf"))]
262+
#[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
232263
const DIRECTORY = bitcast!(c::O_DIRECTORY);
233264

234265
/// `O_DSYNC`
235-
#[cfg(not(any(target_os = "dragonfly", target_os = "espidf", target_os = "l4re", target_os = "redox", target_os = "vita")))]
266+
#[cfg(not(any(target_os = "dragonfly", target_os = "espidf", target_os = "horizon", target_os = "l4re", target_os = "redox", target_os = "vita")))]
236267
const DSYNC = bitcast!(c::O_DSYNC);
237268

238269
/// `O_EXCL`
@@ -246,7 +277,7 @@ bitflags! {
246277
const FSYNC = bitcast!(c::O_FSYNC);
247278

248279
/// `O_NOFOLLOW`
249-
#[cfg(not(target_os = "espidf"))]
280+
#[cfg(not(any(target_os = "espidf", target_os = "horizon")))]
250281
const NOFOLLOW = bitcast!(c::O_NOFOLLOW);
251282

252283
/// `O_NONBLOCK`
@@ -264,7 +295,7 @@ bitflags! {
264295
const RDWR = bitcast!(c::O_RDWR);
265296

266297
/// `O_NOCTTY`
267-
#[cfg(not(any(target_os = "espidf", target_os = "l4re", target_os = "redox", target_os = "vita")))]
298+
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "l4re", target_os = "redox", target_os = "vita")))]
268299
const NOCTTY = bitcast!(c::O_NOCTTY);
269300

270301
/// `O_RSYNC`
@@ -347,6 +378,7 @@ bitflags! {
347378
target_os = "aix",
348379
target_os = "espidf",
349380
target_os = "haiku",
381+
target_os = "horizon",
350382
target_os = "wasi",
351383
target_os = "vita",
352384
solarish
@@ -601,6 +633,7 @@ impl FileType {
601633
target_os = "solaris",
602634
target_os = "dragonfly",
603635
target_os = "espidf",
636+
target_os = "horizon",
604637
target_os = "haiku",
605638
target_os = "redox",
606639
target_os = "vita",
@@ -711,6 +744,7 @@ bitflags! {
711744
#[cfg(not(any(
712745
netbsdlike,
713746
target_os = "espidf",
747+
target_os = "horizon",
714748
target_os = "nto",
715749
target_os = "redox",
716750
target_os = "vita"
@@ -838,11 +872,11 @@ bitflags! {
838872
const NOEXEC = c::ST_NOEXEC as u64;
839873

840874
/// `ST_NOSUID`
841-
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
875+
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
842876
const NOSUID = c::ST_NOSUID as u64;
843877

844878
/// `ST_RDONLY`
845-
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
879+
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
846880
const RDONLY = c::ST_RDONLY as u64;
847881

848882
/// `ST_RELATIME`
@@ -865,7 +899,12 @@ bitflags! {
865899
// Solaris doesn't support `flock` and doesn't define `LOCK_SH` etc., but we
866900
// reuse this `FlockOperation` enum for `fcntl_lock`, so on Solaris we use
867901
// our own made-up integer values.
868-
#[cfg(not(any(target_os = "espidf", target_os = "vita", target_os = "wasi")))]
902+
#[cfg(not(any(
903+
target_os = "espidf",
904+
target_os = "horizon",
905+
target_os = "vita",
906+
target_os = "wasi"
907+
)))]
869908
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
870909
#[repr(u32)]
871910
pub enum FlockOperation {
@@ -998,6 +1037,7 @@ pub struct Stat {
9981037
solarish,
9991038
target_os = "espidf",
10001039
target_os = "haiku",
1040+
target_os = "horizon",
10011041
target_os = "netbsd",
10021042
target_os = "nto",
10031043
target_os = "redox",
@@ -1019,6 +1059,7 @@ pub type StatFs = c::statfs64;
10191059
solarish,
10201060
target_os = "espidf",
10211061
target_os = "haiku",
1062+
target_os = "horizon",
10221063
target_os = "nto",
10231064
target_os = "redox",
10241065
target_os = "vita",

0 commit comments

Comments
 (0)