1 /*
2  * hostdep.h : things which are dependent on the host architecture
3  *
4  *  * Written by Peter Maydell <peter.maydell@linaro.org>
5  *
6  * Copyright (C) 2016 Linaro Limited
7  *
8  * This work is licensed under the terms of the GNU GPL, version 2 or later.
9  * See the COPYING file in the top-level directory.
10  */
11 
12 #ifndef I386_HOSTDEP_H
13 #define I386_HOSTDEP_H
14 
15 /* We have a safe-syscall.inc.S */
16 #define HAVE_SAFE_SYSCALL
17 
18 #ifndef __ASSEMBLER__
19 
20 /* These are defined by the safe-syscall.inc.S file */
21 extern char safe_syscall_start[];
22 extern char safe_syscall_end[];
23 
24 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
rewind_if_in_safe_syscall(void * puc)25 static inline void rewind_if_in_safe_syscall(void *puc)
26 {
27     ucontext_t *uc = puc;
28     greg_t *pcreg = &uc->uc_mcontext.gregs[REG_EIP];
29 
30     if (*pcreg > (uintptr_t)safe_syscall_start
31         && *pcreg < (uintptr_t)safe_syscall_end) {
32         *pcreg = (uintptr_t)safe_syscall_start;
33     }
34 }
35 
36 #endif /* __ASSEMBLER__ */
37 
38 #endif
39