Skip to content

Commit

Permalink
sys: add MIPS R6 support
Browse files Browse the repository at this point in the history
Currently R6 targets are almost identical to their R2/R5
counterparts.
  • Loading branch information
chenx97 committed Oct 7, 2023
1 parent e5b2df6 commit 39b6ad9
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased] - ReleaseDate

### Added
- Add `mips32r6` and `mips64r6` support for signal, ioctl and ptrace
([#2138](https://github.com/nix-rust/nix/pull/2138))

### Fixed
- Fix `SigSet` incorrect implementation of `Eq`, `PartialEq` and `Hash`
([#1946](https://github.com/nix-rust/nix/pull/1946))
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ targets = [
]

[dependencies]
libc = { version = "0.2.147", features = ["extra_traits"] }
libc = { version = "0.2.148", features = ["extra_traits"] }
bitflags = "2.3.1"
cfg-if = "1.0"
pin-utils = { version = "0.1.0", optional = true }
Expand Down
2 changes: 2 additions & 0 deletions src/sys/ioctl/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ pub const TYPEBITS: ioctl_num_type = 8;
cfg_if! {
if #[cfg(any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "sparc64"
Expand Down
28 changes: 24 additions & 4 deletions src/sys/ptrace/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,42 +53,54 @@ libc_enum! {
#[cfg(any(all(target_os = "android", target_pointer_width = "32"),
all(target_os = "linux", any(target_env = "musl",
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "x86_64",
target_pointer_width = "32"))))]
PTRACE_GETREGS,
#[cfg(any(all(target_os = "android", target_pointer_width = "32"),
all(target_os = "linux", any(target_env = "musl",
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "x86_64",
target_pointer_width = "32"))))]
PTRACE_SETREGS,
#[cfg(any(all(target_os = "android", target_pointer_width = "32"),
all(target_os = "linux", any(target_env = "musl",
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "x86_64",
target_pointer_width = "32"))))]
PTRACE_GETFPREGS,
#[cfg(any(all(target_os = "android", target_pointer_width = "32"),
all(target_os = "linux", any(target_env = "musl",
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "x86_64",
target_pointer_width = "32"))))]
PTRACE_SETFPREGS,
PTRACE_ATTACH,
PTRACE_DETACH,
#[cfg(all(target_os = "linux", any(target_env = "musl",
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "x86",
target_arch = "x86_64")))]
PTRACE_GETFPXREGS,
#[cfg(all(target_os = "linux", any(target_env = "musl",
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "x86",
target_arch = "x86_64")))]
PTRACE_SETFPXREGS,
Expand All @@ -98,10 +110,14 @@ libc_enum! {
PTRACE_GETSIGINFO,
PTRACE_SETSIGINFO,
#[cfg(all(target_os = "linux", not(any(target_arch = "mips",
target_arch = "mips64"))))]
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6"))))]
PTRACE_GETREGSET,
#[cfg(all(target_os = "linux", not(any(target_arch = "mips",
target_arch = "mips64"))))]
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6"))))]
PTRACE_SETREGSET,
#[cfg(target_os = "linux")]
#[cfg_attr(docsrs, doc(cfg(all())))]
Expand All @@ -110,10 +126,14 @@ libc_enum! {
#[cfg_attr(docsrs, doc(cfg(all())))]
PTRACE_INTERRUPT,
#[cfg(all(target_os = "linux", not(any(target_arch = "mips",
target_arch = "mips64"))))]
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6"))))]
PTRACE_LISTEN,
#[cfg(all(target_os = "linux", not(any(target_arch = "mips",
target_arch = "mips64"))))]
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6"))))]
PTRACE_PEEKSIGINFO,
#[cfg(all(target_os = "linux", target_env = "gnu",
any(target_arch = "x86", target_arch = "x86_64")))]
Expand Down
19 changes: 17 additions & 2 deletions src/sys/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ libc_enum! {
/// Stack fault (obsolete)
#[cfg(all(any(target_os = "android", target_os = "emscripten",
target_os = "fuchsia", target_os = "linux"),
not(any(target_arch = "mips", target_arch = "mips64",
not(any(target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "sparc64"))))]
SIGSTKFLT,
/// To parent on child stop or exit
Expand Down Expand Up @@ -151,7 +154,9 @@ impl FromStr for Signal {
),
not(any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "sparc64"
))
))]
Expand Down Expand Up @@ -235,7 +240,9 @@ impl Signal {
),
not(any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "sparc64"
))
))]
Expand Down Expand Up @@ -328,7 +335,9 @@ const SIGNALS: [Signal; 28] = [
),
not(any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "sparc64"
))
))]
Expand All @@ -346,7 +355,13 @@ const SIGNALS: [Signal; 31] = [
target_os = "emscripten",
target_os = "fuchsia"
),
any(target_arch = "mips", target_arch = "mips64", target_arch = "sparc64")
any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "sparc64"
)
))]
#[cfg(feature = "signal")]
const SIGNALS: [Signal; 30] = [
Expand Down
4 changes: 3 additions & 1 deletion test/sys/test_aio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,9 @@ mod aio_writev {
any(
all(target_env = "musl", target_arch = "x86_64"),
target_arch = "mips",
target_arch = "mips64"
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6"
),
ignore
)]
Expand Down
18 changes: 16 additions & 2 deletions test/sys/test_ioctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ mod linux {
fn test_op_none() {
if cfg!(any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "powerpc",
target_arch = "powerpc64"
)) {
Expand All @@ -54,7 +56,9 @@ mod linux {
fn test_op_write() {
if cfg!(any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "powerpc",
target_arch = "powerpc64"
)) {
Expand All @@ -69,7 +73,11 @@ mod linux {
#[cfg(target_pointer_width = "64")]
#[test]
fn test_op_write_64() {
if cfg!(any(target_arch = "mips64", target_arch = "powerpc64")) {
if cfg!(any(
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "powerpc64"
)) {
assert_eq!(
request_code_write!(b'z', 10, 1u64 << 32) as u32,
0x8000_7A0A
Expand All @@ -88,7 +96,9 @@ mod linux {
fn test_op_read() {
if cfg!(any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "powerpc",
target_arch = "powerpc64"
)) {
Expand All @@ -103,7 +113,11 @@ mod linux {
#[cfg(target_pointer_width = "64")]
#[test]
fn test_op_read_64() {
if cfg!(any(target_arch = "mips64", target_arch = "powerpc64")) {
if cfg!(any(
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "powerpc64"
)) {
assert_eq!(
request_code_read!(b'z', 10, 1u64 << 32) as u32,
0x4000_7A0A
Expand Down
6 changes: 6 additions & 0 deletions test/sys/test_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,9 @@ fn loopback_address(
qemu,
any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "powerpc64",
)
),
Expand Down Expand Up @@ -1773,7 +1775,9 @@ pub fn test_recv_ipv4pktinfo() {
qemu,
any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "powerpc64",
)
),
Expand Down Expand Up @@ -2065,7 +2069,9 @@ pub fn test_recvif_ipv6() {
qemu,
any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6",
target_arch = "powerpc64",
)
),
Expand Down
14 changes: 12 additions & 2 deletions test/sys/test_wait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ fn test_wait_signal() {
//target_os = "haiku",
all(target_os = "linux", not(target_env = "uclibc")),
))]
#[cfg(not(any(target_arch = "mips", target_arch = "mips64")))]
#[cfg(not(any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6"
)))]
fn test_waitid_signal() {
let _m = crate::FORK_MTX.lock();

Expand Down Expand Up @@ -76,7 +81,12 @@ fn test_wait_exit() {
target_os = "haiku",
all(target_os = "linux", not(target_env = "uclibc")),
))]
#[cfg(not(any(target_arch = "mips", target_arch = "mips64")))]
#[cfg(not(any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6"
)))]
fn test_waitid_exit() {
let _m = crate::FORK_MTX.lock();

Expand Down
20 changes: 18 additions & 2 deletions test/test_mq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,15 @@ fn test_mq_getattr() {
// FIXME: Fix failures for mips in QEMU
#[test]
#[cfg_attr(
all(qemu, any(target_arch = "mips", target_arch = "mips64")),
all(
qemu,
any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6"
)
),
ignore
)]
fn test_mq_setattr() {
Expand Down Expand Up @@ -162,7 +170,15 @@ fn test_mq_setattr() {
// FIXME: Fix failures for mips in QEMU
#[test]
#[cfg_attr(
all(qemu, any(target_arch = "mips", target_arch = "mips64")),
all(
qemu,
any(
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "mips64",
target_arch = "mips64r6"
)
),
ignore
)]
fn test_mq_set_nonblocking() {
Expand Down

0 comments on commit 39b6ad9

Please sign in to comment.