summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/pexception.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/plib/pexception.h')
-rw-r--r--src/lib/netlist/plib/pexception.h74
1 files changed, 42 insertions, 32 deletions
diff --git a/src/lib/netlist/plib/pexception.h b/src/lib/netlist/plib/pexception.h
index 28a3ac1adf1..bf2a286e81e 100644
--- a/src/lib/netlist/plib/pexception.h
+++ b/src/lib/netlist/plib/pexception.h
@@ -1,29 +1,34 @@
-// license:GPL-2.0+
+// license:BSD-3-Clause
// copyright-holders:Couriersud
-/*
- * palloc.h
- *
- */
#ifndef PEXCEPTION_H_
#define PEXCEPTION_H_
+///
+/// \file: pexception.h
+///
+
#include "pstring.h"
#include "ptypes.h"
#include <exception>
+#define passert_always(expr) \
+ ((expr) ? static_cast<void>(0) : plib::passert_fail (#expr, __FILE__, __LINE__, nullptr))
+
+#define passert_always_msg(expr, msg) \
+ ((expr) ? static_cast<void>(0) : plib::passert_fail (#expr, __FILE__, __LINE__, msg))
+
namespace plib {
- //============================================================
- // terminate
- //============================================================
+ /// \brief Terminate the program.
+ ///
+ /// \note could be enhanced by setting a termination handler
+ ///
+ [[noreturn]] void terminate(const char *msg) noexcept;
- /*! Terminate the program
- *
- * \note could be enhanced by setting a termination handler
- */
- [[noreturn]] void terminate(const pstring &msg) noexcept;
+ [[noreturn]] void passert_fail(const char *assertion,
+ const char *file, int lineno, const char *msg) noexcept;
//============================================================
// exception base
@@ -34,11 +39,11 @@ namespace plib {
public:
explicit pexception(const pstring &text);
- const pstring &text() { return m_text; }
+ const putf8string &text() const noexcept { return m_text; }
const char* what() const noexcept override { return m_text.c_str(); }
private:
- pstring m_text;
+ putf8string m_text;
};
class file_e : public plib::pexception
@@ -77,14 +82,14 @@ namespace plib {
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.
- */
+ // 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
+ class fp_exception_e : public pexception
{
public:
- explicit fpexception_e(const pstring &text);
+ explicit fp_exception_e(const pstring &text);
};
static constexpr unsigned FP_INEXACT = 0x0001;
@@ -94,31 +99,36 @@ namespace plib {
static constexpr unsigned FP_INVALID = 0x00010;
static constexpr unsigned FP_ALL = 0x0001f;
- /*
- * Catch SIGFPE on linux for debugging purposes.
- */
-
- class fpsignalenabler
+ /// \brief Catch SIGFPE on linux for debugging purposes.
+ ///
+ class fp_signal_enabler
{
public:
- explicit fpsignalenabler(unsigned fpexceptions);
+ explicit fp_signal_enabler(unsigned fp_exceptions);
- COPYASSIGNMOVE(fpsignalenabler, delete)
+ PCOPYASSIGNMOVE(fp_signal_enabler, delete)
- ~fpsignalenabler();
+ ~fp_signal_enabler();
- /* is the functionality supported ? */
+ /// \brief is the functionality supported.
+ ///
+ /// \return current status
+ ///
static bool supported();
- /* returns last global enable state */
+ /// \brief get/set global enable status
+ ///
+ /// \param enable new status
+ /// \return returns last global enable state
+ ///
static bool global_enable(bool enable);
private:
int m_last_enabled;
- static bool m_enable;
+ static bool m_enable; // NOLINT
};
} // namespace plib
-#endif /* PEXCEPTION_H_ */
+#endif // PEXCEPTION_H_