summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/pexception.h
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2019-03-26 11:13:37 +1100
committer Vas Crabb <vas@vastheman.com>2019-03-26 11:13:37 +1100
commit97b67170277437131adf6ed4d60139c172529e4f (patch)
tree7a5cbf608f191075f1612b1af15832c206a3fe2d /src/lib/netlist/plib/pexception.h
parentb380514764cf857469bae61c11143a19f79a74c5 (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.h')
-rw-r--r--src/lib/netlist/plib/pexception.h214
1 files changed, 106 insertions, 108 deletions
diff --git a/src/lib/netlist/plib/pexception.h b/src/lib/netlist/plib/pexception.h
index 4827081b754..28a3ac1adf1 100644
--- a/src/lib/netlist/plib/pexception.h
+++ b/src/lib/netlist/plib/pexception.h
@@ -9,118 +9,116 @@
#define PEXCEPTION_H_
#include "pstring.h"
+#include "ptypes.h"
#include <exception>
namespace plib {
-//============================================================
-// exception base
-//============================================================
-
-class pexception : public std::exception
-{
-public:
- explicit pexception(const pstring &text);
- pexception(const pexception &e) : std::exception(e), m_text(e.m_text) { }
-
- virtual ~pexception() noexcept;
-
- const pstring &text() { return m_text; }
- const char* what() const noexcept override { return m_text.c_str(); }
-
-private:
- pstring m_text;
-};
-
-class file_e : public plib::pexception
-{
-public:
- file_e(const pstring &fmt, const pstring &filename);
- file_e(const file_e &e) : pexception(e) { }
- virtual ~file_e() noexcept;
-};
-
-class file_open_e : public file_e
-{
-public:
- explicit file_open_e(const pstring &filename);
- file_open_e(const file_open_e &e) : file_e(e) { }
- virtual ~file_open_e() noexcept;
-};
-
-class file_read_e : public file_e
-{
-public:
- explicit file_read_e(const pstring &filename);
- file_read_e(const file_read_e &e) : file_e(e) { }
- virtual ~file_read_e() noexcept;
-};
-
-class file_write_e : public file_e
-{
-public:
- explicit file_write_e(const pstring &filename);
- file_write_e(const file_write_e &e) : file_e(e) { }
- virtual ~file_write_e() noexcept;
-};
-
-class null_argument_e : public plib::pexception
-{
-public:
- explicit null_argument_e(const pstring &argument);
- null_argument_e(const null_argument_e &e) : pexception(e) { }
- virtual ~null_argument_e() noexcept;
-};
-
-class out_of_mem_e : public plib::pexception
-{
-public:
- explicit out_of_mem_e(const pstring &location);
- out_of_mem_e(const out_of_mem_e &e) : pexception(e) { }
- virtual ~out_of_mem_e() noexcept;
-};
-
-/* FIXME: currently only a stub for later use. More use could be added by
- * using “-fnon-call-exceptions" and sigaction to enable c++ exception supported.
- */
-
-class fpexception_e : public pexception
-{
-public:
- explicit fpexception_e(const pstring &text);
- fpexception_e(const fpexception_e &e) : pexception(e) { }
- virtual ~fpexception_e() noexcept;
-};
-
-static constexpr unsigned FP_INEXACT = 0x0001;
-static constexpr unsigned FP_DIVBYZERO = 0x0002;
-static constexpr unsigned FP_UNDERFLOW = 0x0004;
-static constexpr unsigned FP_OVERFLOW = 0x0008;
-static constexpr unsigned FP_INVALID = 0x00010;
-static constexpr unsigned FP_ALL = 0x0001f;
-
-/*
- * Catch SIGFPE on linux for debugging purposes.
- */
-
-class fpsignalenabler
-{
-public:
- explicit fpsignalenabler(unsigned fpexceptions);
- ~fpsignalenabler();
-
- /* is the functionality supported ? */
- static bool supported();
- /* returns last global enable state */
- static bool global_enable(bool enable);
-
-private:
- int m_last_enabled;
-
- static bool m_enable;
-};
-
-}
+ //============================================================
+ // terminate
+ //============================================================
+
+ /*! Terminate the program
+ *
+ * \note could be enhanced by setting a termination handler
+ */
+ [[noreturn]] void terminate(const pstring &msg) noexcept;
+
+ //============================================================
+ // exception base
+ //============================================================
+
+ class pexception : public std::exception
+ {
+ public:
+ explicit pexception(const pstring &text);
+
+ const pstring &text() { return m_text; }
+ const char* what() const noexcept override { return m_text.c_str(); }
+
+ private:
+ pstring m_text;
+ };
+
+ class file_e : public plib::pexception
+ {
+ public:
+ file_e(const pstring &fmt, const pstring &filename);
+ };
+
+ class file_open_e : public file_e
+ {
+ public:
+ explicit file_open_e(const pstring &filename);
+ };
+
+ class file_read_e : public file_e
+ {
+ public:
+ explicit file_read_e(const pstring &filename);
+ };
+
+ class file_write_e : public file_e
+ {
+ public:
+ explicit file_write_e(const pstring &filename);
+ };
+
+ class null_argument_e : public plib::pexception
+ {
+ public:
+ explicit null_argument_e(const pstring &argument);
+ };
+
+ class out_of_mem_e : public plib::pexception
+ {
+ public:
+ explicit out_of_mem_e(const pstring &location);
+ };
+
+ /* FIXME: currently only a stub for later use. More use could be added by
+ * using “-fnon-call-exceptions" and sigaction to enable c++ exception supported.
+ */
+
+ class fpexception_e : public pexception
+ {
+ public:
+ explicit fpexception_e(const pstring &text);
+ };
+
+ static constexpr unsigned FP_INEXACT = 0x0001;
+ static constexpr unsigned FP_DIVBYZERO = 0x0002;
+ static constexpr unsigned FP_UNDERFLOW = 0x0004;
+ static constexpr unsigned FP_OVERFLOW = 0x0008;
+ static constexpr unsigned FP_INVALID = 0x00010;
+ static constexpr unsigned FP_ALL = 0x0001f;
+
+ /*
+ * Catch SIGFPE on linux for debugging purposes.
+ */
+
+ class fpsignalenabler
+ {
+ public:
+ explicit fpsignalenabler(unsigned fpexceptions);
+
+ COPYASSIGNMOVE(fpsignalenabler, delete)
+
+ ~fpsignalenabler();
+
+ /* is the functionality supported ? */
+ static bool supported();
+ /* returns last global enable state */
+ static bool global_enable(bool enable);
+
+ private:
+ int m_last_enabled;
+
+ static bool m_enable;
+ };
+
+
+} // namespace plib
#endif /* PEXCEPTION_H_ */