@@ -52,7 +52,25 @@ struct ucontext_t {
5252 uc_mcontext : libc:: mcontext_t ,
5353}
5454
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+ ) ) ]
5674use libc:: ucontext_t;
5775
5876/// Default stack size is 1MB.
@@ -434,7 +452,8 @@ cfg_if::cfg_if! {
434452 ( * context. uc_mcontext) . __ss. __fp = x29;
435453 ( * context. uc_mcontext) . __ss. __lr = lr;
436454 } 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;
438457 context. uc_mcontext. mc_gpregs. gp_sp = sp as libc:: register_t;
439458 context. uc_mcontext. mc_gpregs. gp_x[ 0 ] = x0 as libc:: register_t;
440459 context. uc_mcontext. mc_gpregs. gp_x[ 1 ] = x1 as libc:: register_t;
0 commit comments