mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-28 18:00:53 +01:00
This follows discussions from #3413. Followup commits add clang-format file, script and blame ignore lists.
38 lines
667 B
C++
38 lines
667 B
C++
#include <atomic>
|
|
#include <signal.h>
|
|
|
|
std::atomic<bool> CorrectFaultData {false};
|
|
static void handler(int signal, siginfo_t* siginfo, void* context) {
|
|
ucontext_t* _context = (ucontext_t*)context;
|
|
|
|
if (signal != SIGSEGV) {
|
|
return;
|
|
}
|
|
|
|
if (siginfo->si_addr != nullptr) {
|
|
return;
|
|
}
|
|
|
|
if (_context->uc_mcontext.gregs[REG_TRAPNO] != 4) {
|
|
return;
|
|
}
|
|
|
|
CorrectFaultData = true;
|
|
}
|
|
|
|
int main() {
|
|
struct sigaction act {};
|
|
act.sa_sigaction = handler;
|
|
act.sa_flags = SA_SIGINFO;
|
|
sigaction(SIGSEGV, &act, nullptr);
|
|
|
|
__asm volatile(R"(
|
|
mov eax, 0x7f;
|
|
inc al;
|
|
into;
|
|
)" ::
|
|
: "eax");
|
|
|
|
return CorrectFaultData ? 0 : 1;
|
|
}
|