1 /*
2  * FreeBSD has a common ucontext definition for all architectures.
3  *
4  * Copyright 2021 Warner Losh <imp@bsdimp.com>
5  *
6  * SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause
7  */
8 #ifndef TARGET_OS_UCONTEXT_H
9 #define TARGET_OS_UCONTEXT_H
10 
11 /*
12  * Defines the common bits for all of FreeBSD's architectures. Has to be
13  * included AFTER the MD target_mcontext_t is defined, however, so can't
14  * be in the grab-bag that is target_os_signal.h.
15  */
16 
17 /* See FreeBSD's sys/ucontext.h */
18 #define TARGET_MC_GET_CLEAR_RET 0x0001
19 
20 /* FreeBSD's sys/_ucontext.h structures */
21 typedef struct target_ucontext {
22     target_sigset_t     uc_sigmask;
23     target_mcontext_t   uc_mcontext;
24     abi_ulong           uc_link;
25     target_stack_t      uc_stack;
26     int32_t             uc_flags;
27     int32_t             __spare__[4];
28 } target_ucontext_t;
29 
30 G_STATIC_ASSERT(TARGET_MCONTEXT_SIZE == sizeof(target_mcontext_t));
31 G_STATIC_ASSERT(TARGET_UCONTEXT_SIZE == sizeof(target_ucontext_t));
32 
33 struct target_sigframe;
34 
35 abi_long set_sigtramp_args(CPUArchState *env, int sig,
36                            struct target_sigframe *frame,
37                            abi_ulong frame_addr,
38                            struct target_sigaction *ka);
39 abi_long get_mcontext(CPUArchState *env, target_mcontext_t *mcp, int flags);
40 abi_long set_mcontext(CPUArchState *env, target_mcontext_t *mcp, int srflag);
41 abi_long get_ucontext_sigreturn(CPUArchState *env, abi_ulong target_sf,
42                                 abi_ulong *target_uc);
43 
44 #endif /* TARGET_OS_UCONTEXT_H */
45