Skip to content

Commit 6af24b7

Browse files
redox: Unmask most of fs, time
Redox supports most of the *at functions as well as most of the `time` header.
1 parent 035acdc commit 6af24b7

19 files changed

Lines changed: 58 additions & 116 deletions

File tree

src/backend/libc/event/types.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
#[cfg(any(linux_kernel, target_os = "freebsd", target_os = "illumos"))]
1+
#[cfg(any(
2+
linux_kernel,
3+
target_os = "freebsd",
4+
target_os = "illumos",
5+
target_os = "redox"
6+
))]
27
use crate::backend::c;
38
#[cfg(any(
49
linux_kernel,
510
target_os = "freebsd",
611
target_os = "illumos",
7-
target_os = "espidf"
12+
target_os = "espidf",
13+
target_os = "redox"
814
))]
915
use bitflags::bitflags;
1016

1117
#[cfg(any(
1218
linux_kernel,
1319
target_os = "freebsd",
1420
target_os = "illumos",
15-
target_os = "espidf"
21+
target_os = "espidf",
22+
target_os = "redox"
1623
))]
1724
bitflags! {
1825
/// `EFD_*` flags for use with [`eventfd`].

src/backend/libc/fs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(all(feature = "alloc", not(any(target_os = "espidf", target_os = "redox"))))]
1+
#[cfg(all(feature = "alloc", not(target_os = "espidf")))]
22
pub(crate) mod dir;
33
#[cfg(linux_kernel)]
44
pub mod inotify;

src/backend/libc/fs/syscalls.rs

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! libc syscalls supporting `rustix::fs`.
22
33
use crate::backend::c;
4-
#[cfg(any(not(target_os = "redox"), feature = "alloc"))]
4+
#[cfg(feature = "alloc")]
55
use crate::backend::conv::ret_usize;
66
use crate::backend::conv::{borrowed_fd, c_str, ret, ret_c_int, ret_off_t, ret_owned_fd};
77
use crate::fd::{BorrowedFd, OwnedFd};
@@ -12,7 +12,7 @@ use crate::ffi::CStr;
1212
use crate::ffi::CString;
1313
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
1414
use crate::fs::Access;
15-
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
15+
#[cfg(not(target_os = "espidf"))]
1616
use crate::fs::AtFlags;
1717
#[cfg(not(any(
1818
netbsdlike,
@@ -287,7 +287,6 @@ pub(crate) fn readlink(path: &CStr, buf: &mut [u8]) -> io::Result<usize> {
287287
unsafe { ret_usize(c::readlink(c_str(path), buf.as_mut_ptr().cast(), buf.len()) as isize) }
288288
}
289289

290-
#[cfg(not(target_os = "redox"))]
291290
#[inline]
292291
pub(crate) unsafe fn readlinkat(
293292
dirfd: BorrowedFd<'_>,
@@ -301,7 +300,6 @@ pub(crate) fn mkdir(path: &CStr, mode: Mode) -> io::Result<()> {
301300
unsafe { ret(c::mkdir(c_str(path), mode.bits() as c::mode_t)) }
302301
}
303302

304-
#[cfg(not(target_os = "redox"))]
305303
pub(crate) fn mkdirat(dirfd: BorrowedFd<'_>, path: &CStr, mode: Mode) -> io::Result<()> {
306304
unsafe {
307305
ret(c::mkdirat(
@@ -337,7 +335,7 @@ pub(crate) fn link(old_path: &CStr, new_path: &CStr) -> io::Result<()> {
337335
unsafe { ret(c::link(c_str(old_path), c_str(new_path))) }
338336
}
339337

340-
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
338+
#[cfg(not(target_os = "espidf"))]
341339
pub(crate) fn linkat(
342340
old_dirfd: BorrowedFd<'_>,
343341
old_path: &CStr,
@@ -400,7 +398,7 @@ pub(crate) fn unlink(path: &CStr) -> io::Result<()> {
400398
unsafe { ret(c::unlink(c_str(path))) }
401399
}
402400

403-
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
401+
#[cfg(not(target_os = "espidf"))]
404402
pub(crate) fn unlinkat(dirfd: BorrowedFd<'_>, path: &CStr, flags: AtFlags) -> io::Result<()> {
405403
// macOS ≤ 10.9 lacks `unlinkat`.
406404
#[cfg(target_os = "macos")]
@@ -627,7 +625,6 @@ pub(crate) fn symlink(old_path: &CStr, new_path: &CStr) -> io::Result<()> {
627625
unsafe { ret(c::symlink(c_str(old_path), c_str(new_path))) }
628626
}
629627

630-
#[cfg(not(target_os = "redox"))]
631628
pub(crate) fn symlinkat(
632629
old_path: &CStr,
633630
new_dirfd: BorrowedFd<'_>,
@@ -729,7 +726,7 @@ pub(crate) fn lstat(path: &CStr) -> io::Result<Stat> {
729726
}
730727
}
731728

732-
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
729+
#[cfg(not(target_os = "espidf"))]
733730
pub(crate) fn statat(dirfd: BorrowedFd<'_>, path: &CStr, flags: AtFlags) -> io::Result<Stat> {
734731
// See the comments in `fstat` about using `crate::fs::statx` here.
735732
#[cfg(all(
@@ -811,7 +808,6 @@ pub(crate) fn access(path: &CStr, access: Access) -> io::Result<()> {
811808
target_os = "emscripten",
812809
target_os = "espidf",
813810
target_os = "horizon",
814-
target_os = "redox",
815811
target_os = "vita"
816812
)))]
817813
pub(crate) fn accessat(
@@ -879,12 +875,7 @@ pub(crate) fn accessat(
879875
Ok(())
880876
}
881877

882-
#[cfg(not(any(
883-
target_os = "espidf",
884-
target_os = "horizon",
885-
target_os = "redox",
886-
target_os = "vita"
887-
)))]
878+
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
888879
pub(crate) fn utimensat(
889880
dirfd: BorrowedFd<'_>,
890881
path: &CStr,
@@ -1092,12 +1083,7 @@ pub(crate) fn chmod(path: &CStr, mode: Mode) -> io::Result<()> {
10921083
unsafe { ret(c::chmod(c_str(path), mode.bits() as c::mode_t)) }
10931084
}
10941085

1095-
#[cfg(not(any(
1096-
linux_kernel,
1097-
target_os = "espidf",
1098-
target_os = "redox",
1099-
target_os = "wasi"
1100-
)))]
1086+
#[cfg(not(any(linux_kernel, target_os = "espidf", target_os = "wasi")))]
11011087
pub(crate) fn chmodat(
11021088
dirfd: BorrowedFd<'_>,
11031089
path: &CStr,
@@ -1175,7 +1161,7 @@ pub(crate) fn fclonefileat(
11751161
}
11761162
}
11771163

1178-
#[cfg(not(any(target_os = "espidf", target_os = "redox", target_os = "wasi")))]
1164+
#[cfg(not(any(target_os = "espidf", target_os = "wasi")))]
11791165
pub(crate) fn chownat(
11801166
dirfd: BorrowedFd<'_>,
11811167
path: &CStr,
@@ -1199,7 +1185,6 @@ pub(crate) fn chownat(
11991185
apple,
12001186
target_os = "espidf",
12011187
target_os = "horizon",
1202-
target_os = "redox",
12031188
target_os = "vita",
12041189
target_os = "wasi"
12051190
)))]

src/backend/libc/thread/syscalls.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ use crate::pid::Pid;
1414
target_os = "espidf",
1515
target_os = "haiku",
1616
target_os = "openbsd",
17-
target_os = "redox",
1817
target_os = "vita",
1918
target_os = "wasi",
2019
)))]
2120
use crate::thread::ClockId;
2221
#[cfg(linux_kernel)]
2322
use crate::thread::{Cpuid, MembarrierCommand, MembarrierQuery};
24-
#[cfg(not(target_os = "redox"))]
2523
use crate::thread::{NanosleepRelativeResult, Timespec};
2624
#[cfg(all(target_env = "gnu", fix_y2038))]
2725
use crate::timespec::LibcTimespec;
@@ -54,7 +52,6 @@ weak!(fn __nanosleep64(*const LibcTimespec, *mut LibcTimespec) -> c::c_int);
5452
target_os = "haiku",
5553
target_os = "horizon",
5654
target_os = "openbsd",
57-
target_os = "redox",
5855
target_os = "vita",
5956
target_os = "wasi",
6057
)))]

src/backend/libc/time/syscalls.rs

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use crate::backend::conv::ret;
77
target_os = "freebsd",
88
target_os = "fuchsia",
99
target_os = "illumos",
10-
target_os = "netbsd"
10+
target_os = "netbsd",
11+
target_os = "redox"
1112
))]
1213
#[cfg(any(all(target_env = "gnu", fix_y2038), not(fix_y2038)))]
1314
use crate::backend::time::types::LibcItimerspec;
@@ -17,11 +18,7 @@ use crate::io;
1718
#[cfg(not(fix_y2038))]
1819
use crate::timespec::as_libc_timespec_mut_ptr;
1920
#[cfg(not(fix_y2038))]
20-
#[cfg(not(any(
21-
target_os = "redox",
22-
target_os = "wasi",
23-
all(apple, not(target_os = "macos"))
24-
)))]
21+
#[cfg(not(any(target_os = "wasi", all(apple, not(target_os = "macos")))))]
2522
use crate::timespec::as_libc_timespec_ptr;
2623
#[cfg(all(target_env = "gnu", fix_y2038))]
2724
use crate::timespec::LibcTimespec;
@@ -32,7 +29,8 @@ use core::mem::MaybeUninit;
3229
target_os = "freebsd",
3330
target_os = "fuchsia",
3431
target_os = "illumos",
35-
target_os = "netbsd"
32+
target_os = "netbsd",
33+
target_os = "redox"
3634
))]
3735
use {
3836
crate::backend::conv::{borrowed_fd, ret_owned_fd},
@@ -53,7 +51,7 @@ weak!(fn __timerfd_gettime64(c::c_int, *mut LibcItimerspec) -> c::c_int);
5351
#[cfg(all(target_env = "gnu", fix_y2038))]
5452
weak!(fn __timerfd_settime64(c::c_int, c::c_int, *const LibcItimerspec, *mut LibcItimerspec) -> c::c_int);
5553

56-
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
54+
#[cfg(not(target_os = "wasi"))]
5755
#[inline]
5856
#[must_use]
5957
pub(crate) fn clock_getres(id: ClockId) -> Timespec {
@@ -258,11 +256,7 @@ fn clock_gettime_dynamic_old(id: c::clockid_t) -> io::Result<Timespec> {
258256
})
259257
}
260258

261-
#[cfg(not(any(
262-
target_os = "redox",
263-
target_os = "wasi",
264-
all(apple, not(target_os = "macos"))
265-
)))]
259+
#[cfg(not(any(target_os = "wasi", all(apple, not(target_os = "macos")))))]
266260
#[inline]
267261
pub(crate) fn clock_settime(id: ClockId, timespec: Timespec) -> io::Result<()> {
268262
// Old 32-bit version: libc has `clock_gettime` but it is not y2038 safe by
@@ -292,11 +286,7 @@ pub(crate) fn clock_settime(id: ClockId, timespec: Timespec) -> io::Result<()> {
292286
}
293287
}
294288

295-
#[cfg(not(any(
296-
target_os = "redox",
297-
target_os = "wasi",
298-
all(apple, not(target_os = "macos"))
299-
)))]
289+
#[cfg(not(any(target_os = "wasi", all(apple, not(target_os = "macos")))))]
300290
#[cfg(fix_y2038)]
301291
fn clock_settime_old(id: ClockId, timespec: Timespec) -> io::Result<()> {
302292
let old_timespec = c::timespec {
@@ -315,7 +305,8 @@ fn clock_settime_old(id: ClockId, timespec: Timespec) -> io::Result<()> {
315305
target_os = "freebsd",
316306
target_os = "fuchsia",
317307
target_os = "illumos",
318-
target_os = "netbsd"
308+
target_os = "netbsd",
309+
target_os = "redox"
319310
))]
320311
pub(crate) fn timerfd_create(id: TimerfdClockId, flags: TimerfdFlags) -> io::Result<OwnedFd> {
321312
unsafe { ret_owned_fd(c::timerfd_create(id as c::clockid_t, bitflags_bits!(flags))) }
@@ -326,7 +317,8 @@ pub(crate) fn timerfd_create(id: TimerfdClockId, flags: TimerfdFlags) -> io::Res
326317
target_os = "freebsd",
327318
target_os = "fuchsia",
328319
target_os = "illumos",
329-
target_os = "netbsd"
320+
target_os = "netbsd",
321+
target_os = "redox"
330322
))]
331323
pub(crate) fn timerfd_settime(
332324
fd: BorrowedFd<'_>,
@@ -374,7 +366,8 @@ pub(crate) fn timerfd_settime(
374366
target_os = "freebsd",
375367
target_os = "fuchsia",
376368
target_os = "illumos",
377-
target_os = "netbsd"
369+
target_os = "netbsd",
370+
target_os = "redox"
378371
))]
379372
#[cfg(fix_y2038)]
380373
fn timerfd_settime_old(
@@ -447,7 +440,8 @@ fn timerfd_settime_old(
447440
target_os = "freebsd",
448441
target_os = "fuchsia",
449442
target_os = "illumos",
450-
target_os = "netbsd"
443+
target_os = "netbsd",
444+
target_os = "redox"
451445
))]
452446
pub(crate) fn timerfd_gettime(fd: BorrowedFd<'_>) -> io::Result<Itimerspec> {
453447
// Old 32-bit version: libc has `timerfd_gettime` but it is not y2038 safe
@@ -484,7 +478,8 @@ pub(crate) fn timerfd_gettime(fd: BorrowedFd<'_>) -> io::Result<Itimerspec> {
484478
target_os = "freebsd",
485479
target_os = "fuchsia",
486480
target_os = "illumos",
487-
target_os = "netbsd"
481+
target_os = "netbsd",
482+
target_os = "redox"
488483
))]
489484
#[cfg(fix_y2038)]
490485
fn timerfd_gettime_old(fd: BorrowedFd<'_>) -> io::Result<Itimerspec> {

src/event/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub mod epoll;
1111
mod eventfd;
1212
#[cfg(bsd)]
1313
pub mod kqueue;
14-
#[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))]
14+
#[cfg(not(any(windows, target_os = "wasi")))]
1515
mod pause;
1616
mod poll;
1717
#[cfg(solarish)]
@@ -24,10 +24,11 @@ pub use crate::timespec::{Nsecs, Secs, Timespec};
2424
linux_kernel,
2525
target_os = "freebsd",
2626
target_os = "illumos",
27-
target_os = "espidf"
27+
target_os = "espidf",
28+
target_os = "redox"
2829
))]
2930
pub use eventfd::{eventfd, EventfdFlags};
30-
#[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))]
31+
#[cfg(not(any(windows, target_os = "wasi")))]
3132
pub use pause::*;
3233
pub use poll::{poll, PollFd, PollFlags};
3334
#[cfg(any(bsd, linux_kernel, windows, target_os = "wasi"))]

0 commit comments

Comments
 (0)