diff options
author | 2019-03-26 11:13:37 +1100 | |
---|---|---|
committer | 2019-03-26 11:13:37 +1100 | |
commit | 97b67170277437131adf6ed4d60139c172529e4f (patch) | |
tree | 7a5cbf608f191075f1612b1af15832c206a3fe2d /src/lib/netlist/plib/pexception.cpp | |
parent | b380514764cf857469bae61c11143a19f79a74c5 (diff) |
(nw) Clean up the mess on master
This effectively reverts b380514764cf857469bae61c11143a19f79a74c5 and
c24473ddff715ecec2e258a6eb38960cf8c8e98e, restoring the state at
598cd5227223c3b04ca31f0dbc1981256d9ea3ff.
Before pushing, please check that what you're about to push is sane.
Check your local commit log and ensure there isn't anything out-of-place
before pushing to mainline. When things like this happen, it wastes
everyone's time. I really don't need this in a week when real work⢠is
busting my balls and I'm behind where I want to be with preparing for
MAME release.
Diffstat (limited to 'src/lib/netlist/plib/pexception.cpp')
-rw-r--r-- | src/lib/netlist/plib/pexception.cpp | 215 |
1 files changed, 101 insertions, 114 deletions
diff --git a/src/lib/netlist/plib/pexception.cpp b/src/lib/netlist/plib/pexception.cpp index a4ed8f367e0..8d6907d66f2 100644 --- a/src/lib/netlist/plib/pexception.cpp +++ b/src/lib/netlist/plib/pexception.cpp @@ -9,6 +9,7 @@ #include "pfmtlog.h" #include <cfenv> +#include <iostream> #if (defined(__x86_64__) || defined(__i386__)) && defined(__linux__) #define HAS_FEENABLE_EXCEPT (1) @@ -17,127 +18,113 @@ #endif namespace plib { -//============================================================ -// Exceptions -//============================================================ - -pexception::pexception(const pstring &text) -: m_text(text) -{ -} - -pexception::~pexception() noexcept -{ -} - -file_e::file_e(const pstring &fmt, const pstring &filename) - : pexception(pfmt(fmt)(filename)) -{ -} - -file_e::~file_e() noexcept -{ -} - -file_open_e::file_open_e(const pstring &filename) - : file_e("File open failed: {}", filename) -{ -} - -file_open_e::~file_open_e() noexcept -{ - -} - -file_read_e::file_read_e(const pstring &filename) - : file_e("File read failed: {}", filename) -{ -} - -file_read_e::~file_read_e() noexcept -{ - -} - -file_write_e::file_write_e(const pstring &filename) - : file_e("File write failed: {}", filename) -{ -} - -file_write_e::~file_write_e() noexcept -{ -} - -null_argument_e::null_argument_e(const pstring &argument) - : pexception(pfmt("Null argument passed: {}")(argument)) -{ -} - -null_argument_e::~null_argument_e() noexcept -{ -} - -out_of_mem_e::out_of_mem_e(const pstring &location) - : pexception(pfmt("Out of memory: {}")(location)) -{ -} - -out_of_mem_e::~out_of_mem_e() noexcept -{ -} - -fpexception_e::fpexception_e(const pstring &text) - : pexception(pfmt("Out of memory: {}")(text)) -{ -} - -fpexception_e::~fpexception_e() noexcept -{ -} - -bool fpsignalenabler::m_enable = false; - -fpsignalenabler::fpsignalenabler(unsigned fpexceptions) -{ -#if HAS_FEENABLE_EXCEPT - if (m_enable) + + //============================================================ + // terminate + //============================================================ + + void terminate(const pstring &msg) noexcept { - int b = 0; - if (fpexceptions & plib::FP_INEXACT) b = b | FE_INEXACT; - if (fpexceptions & plib::FP_DIVBYZERO) b = b | FE_DIVBYZERO; - if (fpexceptions & plib::FP_UNDERFLOW) b = b | FE_UNDERFLOW; - if (fpexceptions & plib::FP_OVERFLOW) b = b | FE_OVERFLOW; - if (fpexceptions & plib::FP_INVALID) b = b | FE_INVALID; - m_last_enabled = feenableexcept(b); + std::cerr << msg.c_str() << "\n"; + std::terminate(); } -#else - m_last_enabled = 0; -#endif -} -fpsignalenabler::~fpsignalenabler() -{ -#if HAS_FEENABLE_EXCEPT - if (m_enable) + //============================================================ + // Exceptions + //============================================================ + + pexception::pexception(const pstring &text) + : m_text(text) + { + } + + + file_e::file_e(const pstring &fmt, const pstring &filename) + : pexception(pfmt(fmt)(filename)) + { + } + + + file_open_e::file_open_e(const pstring &filename) + : file_e("File open failed: {}", filename) + { + } + + + file_read_e::file_read_e(const pstring &filename) + : file_e("File read failed: {}", filename) { - fedisableexcept(FE_ALL_EXCEPT); // Enable all floating point exceptions but FE_INEXACT - feenableexcept(m_last_enabled); // Enable all floating point exceptions but FE_INEXACT } -#endif -} -bool fpsignalenabler::supported() -{ - return true; -} -bool fpsignalenabler::global_enable(bool enable) -{ - bool old = m_enable; - m_enable = enable; - return old; -} + file_write_e::file_write_e(const pstring &filename) + : file_e("File write failed: {}", filename) + { + } + + + null_argument_e::null_argument_e(const pstring &argument) + : pexception(pfmt("Null argument passed: {}")(argument)) + { + } + + + out_of_mem_e::out_of_mem_e(const pstring &location) + : pexception(pfmt("Out of memory: {}")(location)) + { + } + + + fpexception_e::fpexception_e(const pstring &text) + : pexception(pfmt("Out of memory: {}")(text)) + { + } + + + bool fpsignalenabler::m_enable = false; + + fpsignalenabler::fpsignalenabler(unsigned fpexceptions) + { + #if HAS_FEENABLE_EXCEPT + if (m_enable) + { + int b = 0; + if (fpexceptions & plib::FP_INEXACT) b = b | FE_INEXACT; + if (fpexceptions & plib::FP_DIVBYZERO) b = b | FE_DIVBYZERO; + if (fpexceptions & plib::FP_UNDERFLOW) b = b | FE_UNDERFLOW; + if (fpexceptions & plib::FP_OVERFLOW) b = b | FE_OVERFLOW; + if (fpexceptions & plib::FP_INVALID) b = b | FE_INVALID; + m_last_enabled = feenableexcept(b); + } + #else + m_last_enabled = 0; + #endif + } + + + fpsignalenabler::~fpsignalenabler() + { + #if HAS_FEENABLE_EXCEPT + if (m_enable) + { + fedisableexcept(FE_ALL_EXCEPT); // Enable all floating point exceptions but FE_INEXACT + feenableexcept(m_last_enabled); // Enable all floating point exceptions but FE_INEXACT + } + #endif + } + + bool fpsignalenabler::supported() + { + return true; + } + + bool fpsignalenabler::global_enable(bool enable) + { + bool old = m_enable; + m_enable = enable; + return old; + } -} +} // namespace plib |