Skip to content

Commit 33791d8

Browse files
shrik3chl337
andcommitted
aarch64: define UContext
Yeah, that's different than x86. Co-authored-by: ch1337 <[email protected]> Signed-off-by: Tianhao Wang <[email protected]>
1 parent 6658b17 commit 33791d8

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

qlib/kernel/SignalDef.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ pub const UC_SIGCONTEXT_SS: u64 = 2;
346346
pub const UC_STRICT_RESTORE_SS: u64 = 4;
347347

348348
// https://elixir.bootlin.com/linux/latest/source/include/uapi/asm-generic/ucontext.h#L5
349+
#[cfg(target_arch = "x86_64")]
349350
#[repr(C)]
350351
#[derive(Debug, Copy, Clone, Default)]
351352
pub struct UContext {
@@ -356,6 +357,7 @@ pub struct UContext {
356357
pub Sigset: u64,
357358
}
358359

360+
#[cfg(target_arch = "x86_64")]
359361
impl UContext {
360362
pub fn New(ptRegs: &PtRegs, oldMask: u64, cr2: u64, fpstate: u64, alt: &SignalStack) -> Self {
361363
return Self {
@@ -368,6 +370,47 @@ impl UContext {
368370
}
369371
}
370372

373+
#[cfg(target_arch = "aarch64")]
374+
#[repr(C)]
375+
#[derive(Debug, Copy, Clone)]
376+
pub struct UContext {
377+
pub Flags: u64,
378+
pub Link: u64,
379+
pub Stack: SignalStack,
380+
pub Sigset: u64,
381+
__pad: [u8; (1024 / 8) - core::mem::size_of::<u64>()],
382+
pub MContext: SigContext,
383+
}
384+
385+
#[cfg(target_arch = "aarch64")]
386+
impl Default for UContext {
387+
fn default() -> Self {
388+
Self {
389+
Flags: 0,
390+
Link: 0,
391+
Stack: SignalStack::default(),
392+
Sigset: 0,
393+
__pad: [0; (1024 / 8) - core::mem::size_of::<u64>()],
394+
MContext: SigContext::default(),
395+
}
396+
}
397+
}
398+
399+
#[cfg(target_arch = "aarch64")]
400+
impl UContext {
401+
pub fn New(ptRegs: &PtRegs, oldMask: u64, cr2: u64, fpstate: u64, alt: &SignalStack) -> Self {
402+
return Self {
403+
Flags: 0,
404+
Link: 0,
405+
Stack: alt.clone(),
406+
Sigset: 0,
407+
__pad: [0u8; (1024 / 8) - core::mem::size_of::<u64>()],
408+
MContext: SigContext::New(ptRegs, oldMask, cr2, fpstate),
409+
};
410+
}
411+
}
412+
413+
371414
// https://elixir.bootlin.com/linux/latest/source/arch/x86/include/uapi/asm/sigcontext.h#L284
372415
#[cfg(target_arch = "x86_64")]
373416
#[repr(C)]

0 commit comments

Comments
 (0)