From ca2b9e3d0dbbbb76764ea78bfd037a1c634801d5 Mon Sep 17 00:00:00 2001 From: mgiessing Date: Thu, 17 Oct 2024 15:01:35 +0200 Subject: [PATCH 1/4] Added ucontext_t for powerpc64-linux Signed-off-by: mgiessing --- .../linux/gnu/b64/powerpc64/align.rs | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs index 29d1e1c7b8a55..78b9e5e4a1316 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs @@ -5,3 +5,86 @@ s_no_extra_traits! { priv_: [i64; 4] } } + +s! { + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: mcontext_t, + } + + pub struct pt_regs { + pub gpr: [::c_ulong; 32], + pub nip: ::c_ulong, + pub msr: ::c_ulong, + pub orig_gpr3: ::c_ulong, + pub ctr: ::c_ulong, + pub link: ::c_ulong, + pub xer: ::c_ulong, + pub ccr: ::c_ulong, + pub softe: ::c_ulong, + pub trap: ::c_ulong, + pub dar: ::c_ulong, + pub dsisr: ::c_ulong, + pub result: ::c_ulong, + } + + #[repr(align(16))] + pub struct mcontext_t { + __glibc_reserved: [::c_ulong; 4], + pub signal: ::c_int, + __pad0: ::c_int, + pub handler: ::c_ulong, + pub oldmask: ::c_ulong, + pub regs: *mut pt_regs, + pub gp_regs: [::c_ulong; 48], // # define __NGREG 48 + pub fp_regs: [::c_double; 33], // # define __NFPREG 33 + pub v_regs: *mut vrregset_t, + pub vmx_reserve: [::c_long; 69], // # define __NVRREG 34 (34*2+1) + } + + #[repr(align(16))] + pub struct vrregset_t { + pub vrregs: [[::c_uint; 4]; 32], + pub vscr: vscr_t, + pub vrsave: ::c_uint, + __pad: [::c_uint; 3], + } + + #[repr(align(16))] + pub struct vscr_t { + #[cfg(target_endian = "big")] + __pad: [::c_uint; 3], + #[cfg(target_endian = "big")] + pub vscr_word: ::c_uint, + + #[cfg(target_endian = "little")] + pub vscr_word: ::c_uint, + #[cfg(target_endian = "little")] + __pad: [::c_uint; 3], + } + + #[repr(align(8))] + pub struct clone_args { + pub flags: ::c_ulonglong, + pub pidfd: ::c_ulonglong, + pub child_tid: ::c_ulonglong, + pub parent_tid: ::c_ulonglong, + pub exit_signal: ::c_ulonglong, + pub stack: ::c_ulonglong, + pub stack_size: ::c_ulonglong, + pub tls: ::c_ulonglong, + pub set_tid: ::c_ulonglong, + pub set_tid_size: ::c_ulonglong, + pub cgroup: ::c_ulonglong, + } +} + +extern "C" { + pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; + pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; + pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: ::c_int, ...); + pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> ::c_int; +} From c83b082fd277d5ed2291ad2da3575887d0e7dbf3 Mon Sep 17 00:00:00 2001 From: mgiessing Date: Fri, 18 Oct 2024 14:22:57 +0200 Subject: [PATCH 2/4] Refactor structs to avoid trait conflicts and suppress missing debug warnings Signed-off-by: mgiessing --- src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs index 78b9e5e4a1316..37ecbb8c5b1e0 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs @@ -4,9 +4,8 @@ s_no_extra_traits! { pub struct max_align_t { priv_: [i64; 4] } -} -s! { + #[allow(missing_debug_implementations)] pub struct ucontext_t { pub uc_flags: ::c_ulong, pub uc_link: *mut ucontext_t, @@ -15,6 +14,7 @@ s! { pub uc_mcontext: mcontext_t, } + #[allow(missing_debug_implementations)] pub struct pt_regs { pub gpr: [::c_ulong; 32], pub nip: ::c_ulong, @@ -31,6 +31,7 @@ s! { pub result: ::c_ulong, } + #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct mcontext_t { __glibc_reserved: [::c_ulong; 4], @@ -45,6 +46,7 @@ s! { pub vmx_reserve: [::c_long; 69], // # define __NVRREG 34 (34*2+1) } + #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct vrregset_t { pub vrregs: [[::c_uint; 4]; 32], @@ -53,6 +55,7 @@ s! { __pad: [::c_uint; 3], } + #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct vscr_t { #[cfg(target_endian = "big")] @@ -65,7 +68,9 @@ s! { #[cfg(target_endian = "little")] __pad: [::c_uint; 3], } +} +s! { #[repr(align(8))] pub struct clone_args { pub flags: ::c_ulonglong, From 3e674e47337b9c12dc00174d82ee0ca15e49bf99 Mon Sep 17 00:00:00 2001 From: mgiessing Date: Fri, 18 Oct 2024 14:54:40 +0200 Subject: [PATCH 3/4] Fix alignment Signed-off-by: mgiessing --- src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs index 37ecbb8c5b1e0..58303d8147039 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs @@ -32,7 +32,7 @@ s_no_extra_traits! { } #[allow(missing_debug_implementations)] - #[repr(align(16))] + #[repr(align(8))] pub struct mcontext_t { __glibc_reserved: [::c_ulong; 4], pub signal: ::c_int, From 929b0f7fed737f79fad5161ab755413aee9041fc Mon Sep 17 00:00:00 2001 From: mgiessing Date: Fri, 18 Oct 2024 15:26:31 +0200 Subject: [PATCH 4/4] Fixed alignment for vscr_t Signed-off-by: mgiessing --- src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs index 58303d8147039..32a47d2b717f4 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs @@ -56,7 +56,7 @@ s_no_extra_traits! { } #[allow(missing_debug_implementations)] - #[repr(align(16))] + #[repr(align(4))] pub struct vscr_t { #[cfg(target_endian = "big")] __pad: [::c_uint; 3],