@@ -52,7 +52,25 @@ struct ucontext_t {
52
52
uc_mcontext : libc:: mcontext_t ,
53
53
}
54
54
55
- #[ cfg( all( unix, not( all( target_arch = "aarch64" , target_os = "macos" ) ) ) ) ]
55
+ // Current definition of `ucontext_t` in the `libc` crate is not present
56
+ // on aarch64-unknown-freebsd so it's defined here.
57
+ #[ repr( C ) ]
58
+ #[ cfg( all( target_arch = "aarch64" , target_os = "freebsd" ) ) ]
59
+ #[ allow( non_camel_case_types) ]
60
+ struct ucontext_t {
61
+ uc_sigmask : libc:: sigset_t ,
62
+ uc_mcontext : libc:: mcontext_t ,
63
+ uc_link : * mut ucontext_t ,
64
+ uc_stack : libc:: stack_t ,
65
+ uc_flags : libc:: c_int ,
66
+ spare : [ libc:: c_int ; 4 ] ,
67
+ }
68
+
69
+ #[ cfg( all(
70
+ unix,
71
+ not( all( target_arch = "aarch64" , target_os = "macos" ) ) ,
72
+ not( all( target_arch = "aarch64" , target_os = "freebsd" ) )
73
+ ) ) ]
56
74
use libc:: ucontext_t;
57
75
58
76
/// Default stack size is 1MB.
@@ -434,7 +452,8 @@ cfg_if::cfg_if! {
434
452
( * context. uc_mcontext) . __ss. __fp = x29;
435
453
( * context. uc_mcontext) . __ss. __lr = lr;
436
454
} else if #[ cfg( all( target_os = "freebsd" , target_arch = "aarch64" ) ) ] {
437
- context. uc_mcontext. mc_gpregs. gp_pc = pc as libc:: register_t;
455
+ let TrapHandlerRegs { pc, sp, x0, x1, x29, lr } = regs;
456
+ context. uc_mcontext. mc_gpregs. gp_elr = pc as libc:: register_t;
438
457
context. uc_mcontext. mc_gpregs. gp_sp = sp as libc:: register_t;
439
458
context. uc_mcontext. mc_gpregs. gp_x[ 0 ] = x0 as libc:: register_t;
440
459
context. uc_mcontext. mc_gpregs. gp_x[ 1 ] = x1 as libc:: register_t;
0 commit comments