From 7e12ebdf945d40d6f11872cf5852c9bb54d1864f Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sun, 22 Dec 2024 16:12:31 +0100 Subject: big WIP --- src/crepe/facade/CMakeLists.txt | 2 ++ src/crepe/facade/SignalCatch.cpp | 25 +++++++++++++++++++++++++ src/crepe/facade/SignalCatch.h | 24 ++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 src/crepe/facade/SignalCatch.cpp create mode 100644 src/crepe/facade/SignalCatch.h (limited to 'src/crepe/facade') diff --git a/src/crepe/facade/CMakeLists.txt b/src/crepe/facade/CMakeLists.txt index 243ae46..4873e8d 100644 --- a/src/crepe/facade/CMakeLists.txt +++ b/src/crepe/facade/CMakeLists.txt @@ -6,6 +6,7 @@ target_sources(crepe PUBLIC DB.cpp FontFacade.cpp Font.cpp + SignalCatch.cpp ) target_sources(crepe PUBLIC FILE_SET HEADERS FILES @@ -16,5 +17,6 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES DB.h FontFacade.h Font.h + SignalCatch.h ) diff --git a/src/crepe/facade/SignalCatch.cpp b/src/crepe/facade/SignalCatch.cpp new file mode 100644 index 0000000..ad92d28 --- /dev/null +++ b/src/crepe/facade/SignalCatch.cpp @@ -0,0 +1,25 @@ +#include + +#include "SignalCatch.h" + +using namespace crepe; +using namespace std; + +SignalCatch::SignalCatch() { + segvcatch::init_segv(&SignalCatch::segv); + segvcatch::init_fpe(&SignalCatch::fpe); +} + +SignalCatch::~SignalCatch() { + segvcatch::init_segv(); + segvcatch::init_fpe(); +} + +void SignalCatch::segv() { + throw runtime_error("segmentation fault"); +} + +void SignalCatch::fpe() { + throw domain_error("floating point exception"); +} + diff --git a/src/crepe/facade/SignalCatch.h b/src/crepe/facade/SignalCatch.h new file mode 100644 index 0000000..4562215 --- /dev/null +++ b/src/crepe/facade/SignalCatch.h @@ -0,0 +1,24 @@ +#pragma once + +#include + +namespace crepe { + +class SignalCatch { +public: + SignalCatch(); + ~SignalCatch(); + +private: + static void segv(); + static void fpe(); + +public: + SignalCatch(const SignalCatch &) = delete; + SignalCatch(SignalCatch &&) = delete; + SignalCatch & operator=(const SignalCatch &) = delete; + SignalCatch & operator=(SignalCatch &&) = delete; +}; + +} + -- cgit v1.2.3