139 |
|
#define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_INVALID_PC |
140 |
|
#endif |
141 |
|
|
142 |
+ |
// SIGSEGV recovery supported ? |
143 |
+ |
#if defined(SIGSEGV_ALL_SIGNALS) && defined(SIGSEGV_FAULT_HANDLER_ARGLIST) && defined(SIGSEGV_FAULT_ADDRESS) |
144 |
+ |
#define HAVE_SIGSEGV_RECOVERY |
145 |
+ |
#endif |
146 |
+ |
|
147 |
|
|
148 |
|
/* |
149 |
|
* SIGSEGV global handler |
150 |
|
*/ |
151 |
|
|
152 |
+ |
#ifdef HAVE_SIGSEGV_RECOVERY |
153 |
|
static void sigsegv_handler(SIGSEGV_FAULT_HANDLER_ARGLIST) |
154 |
|
{ |
155 |
|
// Call user's handler and reinstall the global handler, if required |
165 |
|
#undef FAULT_HANDLER |
166 |
|
} |
167 |
|
} |
168 |
+ |
#endif |
169 |
|
|
170 |
|
|
171 |
|
/* |
186 |
|
return (signal(sig, (signal_handler)sigsegv_handler) != SIG_ERR); |
187 |
|
#endif |
188 |
|
} |
189 |
< |
#elif defined(HAVE_SIGCONTEXT_SUBTERFUGE) |
189 |
> |
#endif |
190 |
> |
|
191 |
> |
#if defined(HAVE_SIGCONTEXT_SUBTERFUGE) |
192 |
|
static bool sigsegv_do_install_handler(int sig) |
193 |
|
{ |
194 |
|
// Setup SIGSEGV handler to process writes to frame buffer |
211 |
|
|
212 |
|
bool sigsegv_install_handler(sigsegv_handler_t handler) |
213 |
|
{ |
214 |
< |
#if defined(HAVE_SIGINFO_T) || defined(HAVE_SIGCONTEXT_SUBTERFUGE) |
214 |
> |
#ifdef HAVE_SIGSEGV_RECOVERY |
215 |
|
sigsegv_user_handler = handler; |
216 |
|
bool success = true; |
217 |
|
#define FAULT_HANDLER(sig) success = success && sigsegv_do_install_handler(sig); |
231 |
|
|
232 |
|
void sigsegv_deinstall_handler(void) |
233 |
|
{ |
234 |
+ |
#ifdef HAVE_SIGSEGV_RECOVERY |
235 |
|
sigsegv_user_handler = 0; |
236 |
|
#define FAULT_HANDLER(sig) signal(sig, SIG_DFL); |
237 |
|
SIGSEGV_ALL_SIGNALS |
238 |
|
#undef FAULT_HANDLER |
239 |
+ |
#endif |
240 |
|
} |
241 |
|
|
242 |
|
/* |