From d6b9c2f717b8217a2c964e8a04077b301571acb8 Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Sun, 22 Sep 2024 22:07:27 +0800 Subject: [PATCH] fix: enable RegisterSet and RegisterSetValue for aarch64/musl --- src/sys/ptrace/linux.rs | 73 +++++++++++++++++++++++++++++++---------- test/sys/test_ptrace.rs | 15 ++++++--- 2 files changed, 65 insertions(+), 23 deletions(-) diff --git a/src/sys/ptrace/linux.rs b/src/sys/ptrace/linux.rs index 762b337687..588631c6cd 100644 --- a/src/sys/ptrace/linux.rs +++ b/src/sys/ptrace/linux.rs @@ -173,13 +173,25 @@ libc_enum! { #[cfg(all( target_os = "linux", - target_env = "gnu", any( - target_arch = "x86_64", - target_arch = "x86", - target_arch = "aarch64", - target_arch = "riscv64", - ) + all( + target_env = "gnu", + any( + target_arch = "x86_64", + target_arch = "x86", + target_arch = "aarch64", + target_arch = "riscv64", + ) + ) + ), + any( + all( + target_env = "musl", + any( + target_arch = "aarch64", + ) + ) + ), ))] libc_enum! { #[repr(i32)] @@ -196,13 +208,25 @@ libc_enum! { #[cfg(all( target_os = "linux", - target_env = "gnu", any( - target_arch = "x86_64", - target_arch = "x86", - target_arch = "aarch64", - target_arch = "riscv64", - ) + all( + target_env = "gnu", + any( + target_arch = "x86_64", + target_arch = "x86", + target_arch = "aarch64", + target_arch = "riscv64", + ) + ) + ), + any( + all( + target_env = "musl", + any( + target_arch = "aarch64", + ) + ) + ), ))] /// Represents register set areas, such as general-purpose registers or /// floating-point registers. @@ -219,15 +243,28 @@ pub unsafe trait RegisterSet { type Regs; } + #[cfg(all( target_os = "linux", - target_env = "gnu", any( - target_arch = "x86_64", - target_arch = "x86", - target_arch = "aarch64", - target_arch = "riscv64", - ) + all( + target_env = "gnu", + any( + target_arch = "x86_64", + target_arch = "x86", + target_arch = "aarch64", + target_arch = "riscv64", + ) + ) + ), + any( + all( + target_env = "musl", + any( + target_arch = "aarch64", + ) + ) + ), ))] /// Register sets used in [`getregset`] and [`setregset`] pub mod regset { diff --git a/test/sys/test_ptrace.rs b/test/sys/test_ptrace.rs index 2e3e809ee8..5635346eac 100644 --- a/test/sys/test_ptrace.rs +++ b/test/sys/test_ptrace.rs @@ -179,12 +179,17 @@ fn test_ptrace_interrupt() { // ptrace::{setoptions, getregs} are only available in these platforms #[cfg(all( target_os = "linux", - target_env = "gnu", any( - target_arch = "x86_64", - target_arch = "x86", - target_arch = "aarch64", - target_arch = "riscv64", + all( + target_env = "gnu", + any( + target_arch = "x86_64", + target_arch = "x86", + target_arch = "aarch64", + target_arch = "riscv64" + ) + ), + all(target_env = "musl", target_arch = "aarch64") ) ))] #[test]