From 1bb99466bcfa188bca00855f80bd6098b0882419 Mon Sep 17 00:00:00 2001 From: couriersud Date: Thu, 24 Sep 2020 07:53:11 +0200 Subject: netlist: code refactoring * use default move and copy constructors * various minor edits like adding noexcept * removed a lot of inline keywords - you can't beat the compiler --- scripts/src/main.lua | 2 + src/lib/netlist/analog/nlid_twoterm.h | 2 +- src/lib/netlist/core/base_objects.h | 4 +- src/lib/netlist/core/logic.h | 10 +-- src/lib/netlist/core/netlist_state.h | 2 +- src/lib/netlist/core/nets.h | 8 +-- src/lib/netlist/core/object_array.h | 6 +- src/lib/netlist/devices/nld_4029.cpp | 4 +- src/lib/netlist/devices/nld_4042.cpp | 6 +- src/lib/netlist/devices/nld_4076.cpp | 6 +- src/lib/netlist/devices/nld_7493.cpp | 34 ++++------ src/lib/netlist/devices/nld_9316_base.hxx | 20 +++--- src/lib/netlist/devices/nld_roms.cpp | 15 ++--- src/lib/netlist/devices/nlid_system.h | 2 +- src/lib/netlist/nl_config.h | 60 ++++++++--------- src/lib/netlist/nl_setup.h | 6 +- src/lib/netlist/nltypes.h | 18 ++--- src/lib/netlist/plib/gmres.h | 2 +- src/lib/netlist/plib/parray.h | 2 +- src/lib/netlist/plib/pchrono.h | 6 +- src/lib/netlist/plib/pconfig.h | 2 +- src/lib/netlist/plib/pfmtlog.h | 10 +-- src/lib/netlist/plib/plists.h | 28 +++----- src/lib/netlist/plib/pmath.h | 106 +++++++++++++++--------------- src/lib/netlist/plib/pmulti_threading.h | 13 ++-- src/lib/netlist/plib/ppmf.h | 2 +- src/lib/netlist/plib/pstream.h | 4 +- src/lib/netlist/plib/ptime.h | 19 ++++-- 28 files changed, 196 insertions(+), 203 deletions(-) diff --git a/scripts/src/main.lua b/scripts/src/main.lua index 6ae28487563..c9e2aabfdd8 100644 --- a/scripts/src/main.lua +++ b/scripts/src/main.lua @@ -165,6 +165,8 @@ end .. " --embed-file " .. _MAKE.esc(MAME_DIR) .. "bgfx/shaders/essl@bgfx/shaders/essl" .. " --embed-file " .. _MAKE.esc(MAME_DIR) .. "artwork/bgfx@artwork/bgfx" .. " --embed-file " .. _MAKE.esc(MAME_DIR) .. "artwork/slot-mask.png@artwork/slot-mask.png" + .. " --embed-file " .. _MAKE.esc(MAME_DIR) .. "artwork/popeye.zip@artwork/popeye.zip" + .. " --embed-file " .. _MAKE.esc(MAME_DIR) .. "roms@roms" if _OPTIONS["SYMBOLS"]~=nil and _OPTIONS["SYMBOLS"]~="0" then emccopts = emccopts diff --git a/src/lib/netlist/analog/nlid_twoterm.h b/src/lib/netlist/analog/nlid_twoterm.h index fbf7b24b502..615bb7e19b3 100644 --- a/src/lib/netlist/analog/nlid_twoterm.h +++ b/src/lib/netlist/analog/nlid_twoterm.h @@ -54,7 +54,7 @@ namespace analog // ----------------------------------------------------------------------------- template - inline core_device_t &bselect(bool b, C &d1, core_device_t &d2) + static inline core_device_t &bselect(bool b, C &d1, core_device_t &d2) { auto *h = dynamic_cast(&d1); return b ? *h : d2; diff --git a/src/lib/netlist/core/base_objects.h b/src/lib/netlist/core/base_objects.h index 140fde1149e..1a7cd44da2f 100644 --- a/src/lib/netlist/core/base_objects.h +++ b/src/lib/netlist/core/base_objects.h @@ -241,7 +241,7 @@ namespace netlist void clear_net() noexcept { m_net = nullptr; } bool has_net() const noexcept { return (m_net != nullptr); } - net_t & net() const noexcept { return *m_net;} + constexpr net_t & net() const noexcept { return *m_net;} bool is_logic() const noexcept; bool is_logic_input() const noexcept; @@ -270,7 +270,7 @@ namespace netlist void set_delegate(const nldelegate &delegate) noexcept { m_delegate = delegate; } const nldelegate &delegate() const noexcept { return m_delegate; } - inline void run_delegate() noexcept { return m_delegate(); } + void run_delegate() const noexcept { return m_delegate(); } private: nldelegate m_delegate; net_t * m_net; diff --git a/src/lib/netlist/core/logic.h b/src/lib/netlist/core/logic.h index c8ff979cc65..149af1a2efb 100644 --- a/src/lib/netlist/core/logic.h +++ b/src/lib/netlist/core/logic.h @@ -32,11 +32,11 @@ namespace netlist logic_t(device_t &dev, const pstring &aname, state_e terminal_state, nldelegate delegate); - logic_net_t & net() noexcept + constexpr logic_net_t & net() noexcept { return plib::downcast(core_terminal_t::net()); } - const logic_net_t & net() const noexcept + constexpr const logic_net_t & net() const noexcept { return plib::downcast(core_terminal_t::net()); } @@ -52,7 +52,7 @@ namespace netlist logic_input_t(device_t &dev, const pstring &aname, nldelegate delegate); - inline netlist_sig_t operator()() const noexcept + constexpr const netlist_sig_t &operator()() const noexcept { nl_assert(terminal_state() != STATE_INP_PASSIVE); #if NL_USE_COPY_INSTEAD_OF_REFERENCE @@ -120,12 +120,12 @@ namespace netlist void initial(netlist_sig_t val) noexcept; - inline void push(const netlist_sig_t &newQ, const netlist_time &delay) noexcept + void push(const netlist_sig_t &newQ, const netlist_time &delay) noexcept { m_my_net.set_Q_and_push(newQ, delay); // take the shortcut } - inline void set_Q_time(const netlist_sig_t &newQ, const netlist_time_ext &at) noexcept + void set_Q_time(const netlist_sig_t &newQ, const netlist_time_ext &at) noexcept { m_my_net.set_Q_time(newQ, at); // take the shortcut } diff --git a/src/lib/netlist/core/netlist_state.h b/src/lib/netlist/core/netlist_state.h index 137f264ddfd..1bb7846e80b 100644 --- a/src/lib/netlist/core/netlist_state.h +++ b/src/lib/netlist/core/netlist_state.h @@ -76,7 +76,7 @@ namespace netlist /// \return vector with pointers to devices template - inline std::vector get_device_list() const + std::vector get_device_list() const { std::vector tmp; for (const auto &d : m_devices) diff --git a/src/lib/netlist/core/nets.h b/src/lib/netlist/core/nets.h index db28687e5d0..e4c1897ee81 100644 --- a/src/lib/netlist/core/nets.h +++ b/src/lib/netlist/core/nets.h @@ -84,7 +84,7 @@ namespace netlist NVCC_CONSTEXPR bool is_queued() const noexcept { return m_in_queue == queue_status::QUEUED; } template - inline void update_devs() noexcept + void update_devs() noexcept { nl_assert(this->is_rail_net()); @@ -165,7 +165,7 @@ namespace netlist protected: // only used for logic nets - NVCC_CONSTEXPR netlist_sig_t Q() const noexcept { return m_cur_Q; } + NVCC_CONSTEXPR const netlist_sig_t &Q() const noexcept { return m_cur_Q; } // only used for logic nets void initial(netlist_sig_t val) noexcept @@ -175,7 +175,7 @@ namespace netlist } // only used for logic nets - inline void set_Q_and_push(const netlist_sig_t &newQ, const netlist_time &delay) noexcept + void set_Q_and_push(const netlist_sig_t &newQ, const netlist_time &delay) noexcept { if (newQ != m_new_Q) { @@ -185,7 +185,7 @@ namespace netlist } // only used for logic nets - inline void set_Q_time(const netlist_sig_t &newQ, const netlist_time_ext &at) noexcept + void set_Q_time(const netlist_sig_t &newQ, const netlist_time_ext &at) noexcept { if (newQ != m_new_Q) { diff --git a/src/lib/netlist/core/object_array.h b/src/lib/netlist/core/object_array.h index 0079d819c3e..f8b811482fc 100644 --- a/src/lib/netlist/core/object_array.h +++ b/src/lib/netlist/core/object_array.h @@ -133,7 +133,7 @@ namespace netlist private: template - inline constexpr value_type e() const { return (*this)[P](); } + constexpr const value_type &e() const { return (*this)[P](); } }; template @@ -144,7 +144,7 @@ namespace netlist using base_type::base_type; template - inline void push(const T &v, const netlist_time &t) + void push(const T &v, const netlist_time &t) { if (N >= 1) (*this)[0].push((v >> 0) & 1, t); if (N >= 2) (*this)[1].push((v >> 1) & 1, t); @@ -197,7 +197,7 @@ namespace netlist using base_type::base_type; template - inline void push(const T &v, const netlist_time &t) + void push(const T &v, const netlist_time &t) { if (N >= 1) (*this)[0].push((v >> 0) & 1, t); if (N >= 2) (*this)[1].push((v >> 1) & 1, t); diff --git a/src/lib/netlist/devices/nld_4029.cpp b/src/lib/netlist/devices/nld_4029.cpp index 2e18ba9f4e1..a3de0e7192b 100644 --- a/src/lib/netlist/devices/nld_4029.cpp +++ b/src/lib/netlist/devices/nld_4029.cpp @@ -153,7 +153,7 @@ namespace devices } private: - inline NETLIB_HANDLERI(inputs) // pe causes an asynchronous counter load on level so has to be handled separately; if pe is high, then J changing will asynchronously change the Q state. changing J in this state does affect CO as well; CI will affect CO asynchronously if there is currently a carry + NETLIB_HANDLERI(inputs) // pe causes an asynchronous counter load on level so has to be handled separately; if pe is high, then J changing will asynchronously change the Q state. changing J in this state does affect CO as well; CI will affect CO asynchronously if there is currently a carry { if (m_PE()) { @@ -178,7 +178,7 @@ namespace devices } } - inline NETLIB_HANDLERI(clk) + NETLIB_HANDLERI(clk) { // clocking only happens if m_clk_old was low, m_CLK is high, m_PE is NOT high, and m_CI is NOT high. if (!m_PE() && !m_CI() && !m_clk_old && m_CLK()) diff --git a/src/lib/netlist/devices/nld_4042.cpp b/src/lib/netlist/devices/nld_4042.cpp index f79a3bdb7a5..a000d2e8af8 100644 --- a/src/lib/netlist/devices/nld_4042.cpp +++ b/src/lib/netlist/devices/nld_4042.cpp @@ -62,7 +62,7 @@ namespace devices } private: - inline NETLIB_HANDLERI(clk) + NETLIB_HANDLERI(clk) { if (m_POL() ^ m_CLK()) // are we in transparent mode? if so latch the data and push it. { @@ -73,7 +73,7 @@ namespace devices // if not, the data inputs are ignored and just do nothing } - inline NETLIB_HANDLERI(inputs) + NETLIB_HANDLERI(inputs) { if ((m_POL() ^ m_CLK())&&(m_latch != (m_D()&0xf))) // are we in transparent mode? if so latch the data and push it. only do this if the data actually changed { @@ -83,7 +83,7 @@ namespace devices } } - inline NETLIB_HANDLERI(vdd_vss) + NETLIB_HANDLERI(vdd_vss) { auto d = m_power_pins.VCC()() - m_power_pins.GND()(); if (d > 0.1) // avoid unrealistic values diff --git a/src/lib/netlist/devices/nld_4076.cpp b/src/lib/netlist/devices/nld_4076.cpp index b4430390b31..a69d02e2d54 100644 --- a/src/lib/netlist/devices/nld_4076.cpp +++ b/src/lib/netlist/devices/nld_4076.cpp @@ -74,12 +74,12 @@ namespace devices } private: - inline NETLIB_HANDLERI(id) + NETLIB_HANDLERI(id) { m_enable_in = (!(m_ID1() || m_ID2())); } - inline NETLIB_HANDLERI(clk) + NETLIB_HANDLERI(clk) { if ((!m_clk_old) && m_CLK() && m_enable_in) // clock rising edge and input is enabled; otherwise the latch just re-latches its own value { @@ -94,7 +94,7 @@ namespace devices } } - inline NETLIB_HANDLERI(od) + NETLIB_HANDLERI(od) { m_enable_out = (!(m_OD1() || m_OD2())); // update the pin output state diff --git a/src/lib/netlist/devices/nld_7493.cpp b/src/lib/netlist/devices/nld_7493.cpp index c52418f8d2e..1f22ce27fe8 100644 --- a/src/lib/netlist/devices/nld_7493.cpp +++ b/src/lib/netlist/devices/nld_7493.cpp @@ -62,22 +62,19 @@ namespace netlist namespace devices { - static constexpr const netlist_time out_delay = NLTIME_FROM_NS(18); - static constexpr const netlist_time out_delay2 = NLTIME_FROM_NS(36); - static constexpr const netlist_time out_delay3 = NLTIME_FROM_NS(54); + static const std::array out_delay { NLTIME_FROM_NS(18), NLTIME_FROM_NS(36), NLTIME_FROM_NS(54) }; NETLIB_OBJECT(7493) { NETLIB_CONSTRUCTOR(7493) - , m_R1(*this, "R1", NETLIB_DELEGATE(inputs)) - , m_R2(*this, "R2", NETLIB_DELEGATE(inputs)) - , m_a(*this, "_m_a", 0) - , m_bcd(*this, "_m_b", 0) - , m_r(*this, "_m_r", 0) , m_CLKA(*this, "CLKA", NETLIB_DELEGATE(updA)) , m_CLKB(*this, "CLKB", NETLIB_DELEGATE(updB)) , m_QA(*this, "QA") , m_QB(*this, {"QB", "QC", "QD"}) + , m_a(*this, "m_a", 0) + , m_bcd(*this, "m_b", 0) + , m_R1(*this, "R1", NETLIB_DELEGATE(inputs)) + , m_R2(*this, "R2", NETLIB_DELEGATE(inputs)) , m_power_pins(*this) { } @@ -110,30 +107,27 @@ namespace netlist NETLIB_HANDLERI(updA) { m_a ^= 1; - m_QA.push(m_a, out_delay); + m_QA.push(m_a, out_delay[0]); } NETLIB_HANDLERI(updB) { const auto cnt(++m_bcd &= 0x07); - - m_QB[2].push((cnt >> 2) & 1, out_delay3); - m_QB[1].push((cnt >> 1) & 1, out_delay2); - m_QB[0].push(cnt & 1, out_delay); + m_QB.push(cnt, out_delay); } - logic_input_t m_R1; - logic_input_t m_R2; - - state_var_sig m_a; - state_var_sig m_bcd; - state_var_sig m_r; - logic_input_t m_CLKA; logic_input_t m_CLKB; logic_output_t m_QA; object_array_t m_QB; + + state_var m_a; + state_var m_bcd; + + logic_input_t m_R1; + logic_input_t m_R2; + nld_power_pins m_power_pins; }; diff --git a/src/lib/netlist/devices/nld_9316_base.hxx b/src/lib/netlist/devices/nld_9316_base.hxx index 3e8e977cb87..e0659493cf1 100644 --- a/src/lib/netlist/devices/nld_9316_base.hxx +++ b/src/lib/netlist/devices/nld_9316_base.hxx @@ -14,10 +14,10 @@ namespace netlist { template - static constexpr unsigned rollover(unsigned v) { return v <= N ? v : 0; } + static constexpr unsigned rollover(unsigned v) noexcept { return v <= N ? v : 0; } template <> - constexpr unsigned rollover<15>(unsigned v) { return v & 15; } + constexpr unsigned rollover<15>(unsigned v) noexcept { return v & 15; } template NETLIB_OBJECT(9316_base) @@ -25,11 +25,11 @@ namespace netlist NETLIB_CONSTRUCTOR(9316_base) , m_CLK(*this, "CLK", NETLIB_DELEGATE(clk)) , m_ENT(*this, "ENT", NETLIB_DELEGATE(other)) - , m_RC(*this, "RC") , m_LOADQ(*this, "LOADQ", NETLIB_DELEGATE(other)) , m_ENP(*this, "ENP", NETLIB_DELEGATE(other)) , m_CLRQ(*this, "CLRQ", NETLIB_DELEGATE(other)) , m_ABCD(*this, {"A", "B", "C", "D"}, NETLIB_DELEGATE(abcd)) + , m_RC(*this, "RC") , m_Q(*this, { "QA", "QB", "QC", "QD" }) , m_cnt(*this, "m_cnt", 0) , m_abcd(*this, "m_abcd", 0) @@ -73,15 +73,15 @@ namespace netlist { if (!D::ASYNC::value && !m_CLRQ()) { + m_Q.push(0, D::tCLR::value(0)); m_cnt = 0; - m_Q.push(m_cnt, D::tCLR::value(0)); } else { - const auto cnt = (m_loadq ? rollover(m_cnt + 1) : m_abcd); + const unsigned cnt(m_loadq ? rollover(m_cnt + 1) : m_abcd); m_RC.push(m_ent && (cnt == D::MAXCNT::value), D::tRC::value(0)); m_Q.push(cnt, D::tLDCNT::value(0)); - m_cnt = static_cast(cnt); + m_cnt = cnt; } } @@ -93,22 +93,22 @@ namespace netlist logic_input_t m_CLK; logic_input_t m_ENT; - logic_output_t m_RC; - logic_input_t m_LOADQ; logic_input_t m_ENP; logic_input_t m_CLRQ; object_array_t m_ABCD; + + logic_output_t m_RC; object_array_t m_Q; /* counter state */ state_var m_cnt; /* cached pins */ state_var m_abcd; - state_var_sig m_loadq; - state_var_sig m_ent; + state_var m_loadq; + state_var m_ent; nld_power_pins m_power_pins; }; diff --git a/src/lib/netlist/devices/nld_roms.cpp b/src/lib/netlist/devices/nld_roms.cpp index a0bee0b60cd..e2e4ba4eb77 100644 --- a/src/lib/netlist/devices/nld_roms.cpp +++ b/src/lib/netlist/devices/nld_roms.cpp @@ -41,7 +41,7 @@ namespace netlist } private: - inline NETLIB_HANDLERI(oe1) + NETLIB_HANDLERI(oe1) { m_enable_lo = m_OE1(); uint8_t o = m_enable_lo ? m_latched_rom : 0; @@ -52,7 +52,7 @@ namespace netlist } } - inline NETLIB_HANDLERI(oe2) + NETLIB_HANDLERI(oe2) { m_enable_hi = m_OE2(); uint8_t o = m_enable_hi ? m_latched_rom : 0; @@ -63,7 +63,7 @@ namespace netlist } } - inline NETLIB_HANDLERI(addr) + NETLIB_HANDLERI(addr) { if (!m_ARQ()) { @@ -114,7 +114,7 @@ namespace netlist } private: - inline NETLIB_HANDLERI(en) + NETLIB_HANDLERI(en) { m_enabled = m_EN(); uint8_t o = m_enabled ? m_latched_rom : 0; // outputs are forced to 0 by enable going low; this chip does not have tri-state outputs! @@ -124,7 +124,7 @@ namespace netlist } } - inline NETLIB_HANDLERI(addr) + NETLIB_HANDLERI(addr) { if (!m_CLK() && m_clk_old) // latch on falling edge { @@ -139,7 +139,7 @@ namespace netlist } } - inline NETLIB_HANDLERI(vdd_vss) + NETLIB_HANDLERI(vdd_vss) { auto d = m_power_pins.VCC()() - m_power_pins.GND()(); if (d > 0.1) // avoid unrealistic values @@ -185,7 +185,7 @@ namespace netlist private: template - inline NETLIB_HANDLERI(ce) + NETLIB_HANDLERI(ce) { using cet = typename D::chip_enable_time; m_enabled = (m_CEQ() == D::chip_enable_mask::value); @@ -214,7 +214,6 @@ namespace netlist } - inline NETLIB_HANDLERI(addr) { if (m_enabled) diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index 0e2857a3508..d299c2b3b69 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -566,7 +566,7 @@ namespace devices private: NETLIB_HANDLERI(input) { - nl_fptype val = m_dis.var()(m_mt.var()); + nl_fptype val = m_dis()(m_mt()); m_T.change_state([this, val]() { m_T.set_G_V_I(plib::reciprocal(m_RI()), val, nlconst::zero()); diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h index 6d4c572eb08..3bd57c2771d 100644 --- a/src/lib/netlist/nl_config.h +++ b/src/lib/netlist/nl_config.h @@ -242,14 +242,14 @@ namespace netlist template <> struct fp_constants { - static inline constexpr long double DIODE_MAXDIFF() noexcept { return 1e100L; } // NOLINT - static inline constexpr long double DIODE_MAXVOLT() noexcept { return 300.0L; } // NOLINT + static constexpr long double DIODE_MAXDIFF() noexcept { return 1e100L; } // NOLINT + static constexpr long double DIODE_MAXVOLT() noexcept { return 300.0L; } // NOLINT - static inline constexpr long double TIMESTEP_MAXDIFF() noexcept { return 1e100L; } // NOLINT - static inline constexpr long double TIMESTEP_MINDIV() noexcept { return 1e-60L; } // NOLINT + static constexpr long double TIMESTEP_MAXDIFF() noexcept { return 1e100L; } // NOLINT + static constexpr long double TIMESTEP_MINDIV() noexcept { return 1e-60L; } // NOLINT - static inline constexpr const char * name() noexcept { return "long double"; } - static inline constexpr const char * suffix() noexcept { return "L"; } + static constexpr const char * name() noexcept { return "long double"; } + static constexpr const char * suffix() noexcept { return "L"; } }; /// \brief Specific constants for double floating point type @@ -257,14 +257,14 @@ namespace netlist template <> struct fp_constants { - static inline constexpr double DIODE_MAXDIFF() noexcept { return 1e100; } // NOLINT - static inline constexpr double DIODE_MAXVOLT() noexcept { return 300.0; } // NOLINT + static constexpr double DIODE_MAXDIFF() noexcept { return 1e100; } // NOLINT + static constexpr double DIODE_MAXVOLT() noexcept { return 300.0; } // NOLINT - static inline constexpr double TIMESTEP_MAXDIFF() noexcept { return 1e100; } // NOLINT - static inline constexpr double TIMESTEP_MINDIV() noexcept { return 1e-60; } // NOLINT + static constexpr double TIMESTEP_MAXDIFF() noexcept { return 1e100; } // NOLINT + static constexpr double TIMESTEP_MINDIV() noexcept { return 1e-60; } // NOLINT - static inline constexpr const char * name() noexcept { return "double"; } - static inline constexpr const char * suffix() noexcept { return ""; } + static constexpr const char * name() noexcept { return "double"; } + static constexpr const char * suffix() noexcept { return ""; } }; /// \brief Specific constants for float floating point type @@ -272,14 +272,14 @@ namespace netlist template <> struct fp_constants { - static inline constexpr float DIODE_MAXDIFF() noexcept { return 1e20F; } // NOLINT - static inline constexpr float DIODE_MAXVOLT() noexcept { return 90.0F; } // NOLINT + static constexpr float DIODE_MAXDIFF() noexcept { return 1e20F; } // NOLINT + static constexpr float DIODE_MAXVOLT() noexcept { return 90.0F; } // NOLINT - static inline constexpr float TIMESTEP_MAXDIFF() noexcept { return 1e30F; } // NOLINT - static inline constexpr float TIMESTEP_MINDIV() noexcept { return 1e-8F; } // NOLINT + static constexpr float TIMESTEP_MAXDIFF() noexcept { return 1e30F; } // NOLINT + static constexpr float TIMESTEP_MINDIV() noexcept { return 1e-8F; } // NOLINT - static inline constexpr const char * name() noexcept { return "float"; } - static inline constexpr const char * suffix() noexcept { return "f"; } + static constexpr const char * name() noexcept { return "float"; } + static constexpr const char * suffix() noexcept { return "f"; } }; #if (NL_USE_FLOAT128) @@ -290,23 +290,23 @@ namespace netlist { #if 0 // MAME compile doesn't support Q - static inline constexpr FLOAT128 DIODE_MAXDIFF() noexcept { return 1e100Q; } - static inline constexpr FLOAT128 DIODE_MAXVOLT() noexcept { return 300.0Q; } + static constexpr FLOAT128 DIODE_MAXDIFF() noexcept { return 1e100Q; } + static constexpr FLOAT128 DIODE_MAXVOLT() noexcept { return 300.0Q; } - static inline constexpr FLOAT128 TIMESTEP_MAXDIFF() noexcept { return 1e100Q; } - static inline constexpr FLOAT128 TIMESTEP_MINDIV() noexcept { return 1e-60Q; } + static constexpr FLOAT128 TIMESTEP_MAXDIFF() noexcept { return 1e100Q; } + static constexpr FLOAT128 TIMESTEP_MINDIV() noexcept { return 1e-60Q; } - static inline constexpr const char * name() noexcept { return "FLOAT128"; } - static inline constexpr const char * suffix() noexcept { return "Q"; } + static constexpr const char * name() noexcept { return "FLOAT128"; } + static constexpr const char * suffix() noexcept { return "Q"; } #else - static inline constexpr FLOAT128 DIODE_MAXDIFF() noexcept { return static_cast(1e100L); } - static inline constexpr FLOAT128 DIODE_MAXVOLT() noexcept { return static_cast(300.0L); } + static constexpr FLOAT128 DIODE_MAXDIFF() noexcept { return static_cast(1e100L); } + static constexpr FLOAT128 DIODE_MAXVOLT() noexcept { return static_cast(300.0L); } - static inline constexpr FLOAT128 TIMESTEP_MAXDIFF() noexcept { return static_cast(1e100L); } - static inline constexpr FLOAT128 TIMESTEP_MINDIV() noexcept { return static_cast(1e-60L); } + static constexpr FLOAT128 TIMESTEP_MAXDIFF() noexcept { return static_cast(1e100L); } + static constexpr FLOAT128 TIMESTEP_MINDIV() noexcept { return static_cast(1e-60L); } - static inline constexpr const char * name() noexcept { return "__float128"; } - static inline constexpr const char * suffix() noexcept { return "Q"; } + static constexpr const char * name() noexcept { return "__float128"; } + static constexpr const char * suffix() noexcept { return "Q"; } #endif }; diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h index fd9cb11afab..81f3e769a1d 100644 --- a/src/lib/netlist/nl_setup.h +++ b/src/lib/netlist/nl_setup.h @@ -23,7 +23,7 @@ #include //============================================================ -// MACROS / inline netlist definitions +// MACROS - netlist definitions //============================================================ #define NET_STR(x) # x @@ -274,10 +274,6 @@ namespace netlist unsigned m_frontier_cnt; }; - // ----------------------------------------------------------------------------- - // inline implementations - // ----------------------------------------------------------------------------- - } // namespace netlist diff --git a/src/lib/netlist/nltypes.h b/src/lib/netlist/nltypes.h index 5781619af1a..548d64613f5 100644 --- a/src/lib/netlist/nltypes.h +++ b/src/lib/netlist/nltypes.h @@ -98,10 +98,10 @@ namespace netlist { using BC = plib::constants; - static inline constexpr T np_VT(T n=BC::one(), T temp=BC::T0()) noexcept + static constexpr T np_VT(T n=BC::one(), T temp=BC::T0()) noexcept { return n * temp * BC::k_b() / BC::Q_e(); } - static inline constexpr T np_Is() noexcept { return static_cast(1e-15); } // NOLINT + static constexpr T np_Is() noexcept { return static_cast(1e-15); } // NOLINT /// \brief constant startup gmin /// @@ -109,19 +109,19 @@ namespace netlist /// conductivities with a reasonable value. /// During reset, the object should than make use of exec().gmin() /// to use the actual gmin() value. - static inline constexpr T cgmin() noexcept { return BC::magic(1e-9); } // NOLINT + static constexpr T cgmin() noexcept { return BC::magic(1e-9); } // NOLINT // FIXME: Some objects used 1e-15 for initial gmin. Needs to be // aligned with cgmin - static inline constexpr T cgminalt() noexcept { return BC::magic(1e-15); } // NOLINT + static constexpr T cgminalt() noexcept { return BC::magic(1e-15); } // NOLINT /// \brief Multiplier applied to VT in np diode models to determine range for constant model /// - static inline constexpr T diode_min_cutoff_mult() noexcept { return BC::magic(-5.0); } // NOLINT + static constexpr T diode_min_cutoff_mult() noexcept { return BC::magic(-5.0); } // NOLINT /// \brief Startup voltage used by np diode models /// - static inline constexpr T diode_start_voltage() noexcept { return BC::magic(0.7); } // NOLINT + static constexpr T diode_start_voltage() noexcept { return BC::magic(0.7); } // NOLINT }; @@ -191,9 +191,9 @@ namespace netlist // MACROS //============================================================ - template inline constexpr netlist_time NLTIME_FROM_NS(T &&t) noexcept { return netlist_time::from_nsec(t); } - template inline constexpr netlist_time NLTIME_FROM_US(T &&t) noexcept { return netlist_time::from_usec(t); } - template inline constexpr netlist_time NLTIME_FROM_MS(T &&t) noexcept { return netlist_time::from_msec(t); } + template constexpr netlist_time NLTIME_FROM_NS(T &&t) noexcept { return netlist_time::from_nsec(t); } + template constexpr netlist_time NLTIME_FROM_US(T &&t) noexcept { return netlist_time::from_usec(t); } + template constexpr netlist_time NLTIME_FROM_MS(T &&t) noexcept { return netlist_time::from_msec(t); } struct desc_base { diff --git a/src/lib/netlist/plib/gmres.h b/src/lib/netlist/plib/gmres.h index 465f12021e3..16fcd1b3f4b 100644 --- a/src/lib/netlist/plib/gmres.h +++ b/src/lib/netlist/plib/gmres.h @@ -335,7 +335,7 @@ namespace plib private: - static inline void givens_mult(FT c, FT s, FT & g0, FT & g1 ) + static void givens_mult(FT c, FT s, FT & g0, FT & g1 ) { const FT g0_last(g0); diff --git a/src/lib/netlist/plib/parray.h b/src/lib/netlist/plib/parray.h index 514c231025b..61220366775 100644 --- a/src/lib/netlist/plib/parray.h +++ b/src/lib/netlist/plib/parray.h @@ -127,7 +127,7 @@ namespace plib { base_type &as_base() noexcept { return m_a; } - inline size_type size() const noexcept { return SIZE <= 0 ? m_size : SIZEABS(); } + constexpr size_type size() const noexcept { return SIZE <= 0 ? m_size : SIZEABS(); } constexpr size_type max_size() const noexcept { return base_type::max_size(); } diff --git a/src/lib/netlist/plib/pchrono.h b/src/lib/netlist/plib/pchrono.h index 6695f238290..3cde7cf8649 100644 --- a/src/lib/netlist/plib/pchrono.h +++ b/src/lib/netlist/plib/pchrono.h @@ -20,9 +20,9 @@ namespace plib { struct sys_ticks { using type = typename T::rep; - static inline constexpr type start() noexcept { return T::now().time_since_epoch().count(); } - static inline constexpr type stop() noexcept { return T::now().time_since_epoch().count(); } - static inline constexpr type per_second() noexcept { return T::period::den / T::period::num; } + static constexpr type start() noexcept { return T::now().time_since_epoch().count(); } + static constexpr type stop() noexcept { return T::now().time_since_epoch().count(); } + static constexpr type per_second() noexcept { return T::period::den / T::period::num; } }; using hires_ticks = sys_ticks; diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h index c80f1bbadd6..8e34b01a3b8 100644 --- a/src/lib/netlist/plib/pconfig.h +++ b/src/lib/netlist/plib/pconfig.h @@ -8,7 +8,7 @@ /// \file pconfig.h /// -/// \brief More accurate measurements if you processor supports RDTSCP. +/// \brief More accurate measurements the processor supports RDTSCP. /// #ifndef PHAS_RDTSCP #define PHAS_RDTSCP (0) diff --git a/src/lib/netlist/plib/pfmtlog.h b/src/lib/netlist/plib/pfmtlog.h index 45f7d3e4fc1..ae8998b9dee 100644 --- a/src/lib/netlist/plib/pfmtlog.h +++ b/src/lib/netlist/plib/pfmtlog.h @@ -40,7 +40,7 @@ namespace plib { { static constexpr const bool is_signed = std::numeric_limits::is_signed; static char32_t fmt_spec() { return 'u'; } - static inline void streamify(std::ostream &s, const T &v) + static void streamify(std::ostream &s, const T &v) { s << v; } @@ -53,7 +53,7 @@ namespace plib { // FIXME: need native support at some time static constexpr const bool is_signed = true; static char32_t fmt_spec() { return 'f'; } - static inline void streamify(std::ostream &s, const FLOAT128 &v) + static void streamify(std::ostream &s, const FLOAT128 &v) { s << narrow_cast(v); } @@ -176,7 +176,7 @@ namespace plib { struct ptype_traits : ptype_traits_base { static char32_t fmt_spec() { return 's'; } - static inline void streamify(std::ostream &s, const char16_t *v) + static void streamify(std::ostream &s, const char16_t *v) { const putf16string su16(v); s << putf8string(su16).c_str(); @@ -187,7 +187,7 @@ namespace plib { struct ptype_traits : ptype_traits_base { static char32_t fmt_spec() { return 's'; } - static inline void streamify(std::ostream &s, const char32_t *v) + static void streamify(std::ostream &s, const char32_t *v) { const putf32string su32(v); s << putf8string(su32).c_str(); @@ -210,7 +210,7 @@ namespace plib { struct ptype_traits : ptype_traits_base { static char32_t fmt_spec() { return 's'; } - static inline void streamify(std::ostream &s, const putf16string &v) + static void streamify(std::ostream &s, const putf16string &v) { s << putf8string(v).c_str(); } diff --git a/src/lib/netlist/plib/plists.h b/src/lib/netlist/plib/plists.h index 328f0b1ad23..19c34717126 100755 --- a/src/lib/netlist/plib/plists.h +++ b/src/lib/netlist/plib/plists.h @@ -172,7 +172,7 @@ namespace plib { /// \brief a simple linked list. /// - /// The list allows insertions deletions whilst being processed. + /// The list allows insertions and deletions whilst being processed. /// template class linkedlist_t @@ -187,10 +187,10 @@ namespace plib { constexpr element_t() : m_next(nullptr), m_prev(nullptr) {} ~element_t() noexcept = default; - PCOPYASSIGNMOVE(element_t, delete) + PCOPYASSIGNMOVE(element_t, default) - constexpr LC *next() const noexcept { return m_next; } - constexpr LC *prev() const noexcept { return m_prev; } + constexpr LC * &next() noexcept { return m_next; } + constexpr LC * &prev() noexcept { return m_prev; } private: LC * m_next; LC * m_prev; @@ -202,22 +202,14 @@ namespace plib { LC* p; public: explicit constexpr iter_t(LC* x) noexcept : p(x) { } - constexpr iter_t(iter_t &rhs) noexcept : p(rhs.p) { } - iter_t(iter_t &&rhs) noexcept { std::swap(*this, rhs); } + constexpr iter_t(const iter_t &rhs) noexcept = default; + iter_t(iter_t &&rhs) noexcept = default; - iter_t& operator=(const iter_t &rhs) noexcept // NOLINT(bugprone-unhandled-self-assignment, cert-oop54-cpp) - { - if (this == &rhs) - return *this; - - p = rhs.p; - return *this; - } - - iter_t& operator=(iter_t &&rhs) noexcept { std::swap(*this, rhs); return *this; } - ~iter_t() = default; + iter_t& operator=(const iter_t &rhs) noexcept = default; + iter_t& operator=(iter_t &&rhs) noexcept = default; + ~iter_t() noexcept = default; - iter_t& operator++() noexcept { p = p->next();return *this; } + iter_t& operator++() noexcept { p = p->next(); return *this; } // NOLINTNEXTLINE(cert-dcl21-cpp) iter_t operator++(int) & noexcept { const iter_t tmp(*this); operator++(); return tmp; } diff --git a/src/lib/netlist/plib/pmath.h b/src/lib/netlist/plib/pmath.h index 02d634529a0..01912dd2183 100644 --- a/src/lib/netlist/plib/pmath.h +++ b/src/lib/netlist/plib/pmath.h @@ -30,50 +30,50 @@ namespace plib template struct constants { - static inline constexpr T zero() noexcept { return static_cast(0); } // NOLINT - static inline constexpr T half() noexcept { return static_cast(0.5); } // NOLINT - static inline constexpr T one() noexcept { return static_cast(1); } // NOLINT - static inline constexpr T two() noexcept { return static_cast(2); } // NOLINT - static inline constexpr T three() noexcept { return static_cast(3); } // NOLINT - static inline constexpr T four() noexcept { return static_cast(4); } // NOLINT - static inline constexpr T hundred()noexcept { return static_cast(100); } // NOLINT - - static inline constexpr T one_thirds() noexcept { return fraction(one(), three()); } - static inline constexpr T two_thirds() noexcept { return fraction(two(), three()); } - - static inline constexpr T ln2() noexcept { return static_cast(0.6931471805599453094172321214581766L); } // NOLINT - static inline constexpr T sqrt2() noexcept { return static_cast(1.4142135623730950488016887242096982L); } // NOLINT - static inline constexpr T sqrt3() noexcept { return static_cast(1.7320508075688772935274463415058723L); } // NOLINT - static inline constexpr T sqrt3_2() noexcept { return static_cast(0.8660254037844386467637231707529362L); } // NOLINT - static inline constexpr T pi() noexcept { return static_cast(3.1415926535897932384626433832795029L); } // NOLINT + static constexpr T zero() noexcept { return static_cast(0); } // NOLINT + static constexpr T half() noexcept { return static_cast(0.5); } // NOLINT + static constexpr T one() noexcept { return static_cast(1); } // NOLINT + static constexpr T two() noexcept { return static_cast(2); } // NOLINT + static constexpr T three() noexcept { return static_cast(3); } // NOLINT + static constexpr T four() noexcept { return static_cast(4); } // NOLINT + static constexpr T hundred()noexcept { return static_cast(100); } // NOLINT + + static constexpr T one_thirds() noexcept { return fraction(one(), three()); } + static constexpr T two_thirds() noexcept { return fraction(two(), three()); } + + static constexpr T ln2() noexcept { return static_cast(0.6931471805599453094172321214581766L); } // NOLINT + static constexpr T sqrt2() noexcept { return static_cast(1.4142135623730950488016887242096982L); } // NOLINT + static constexpr T sqrt3() noexcept { return static_cast(1.7320508075688772935274463415058723L); } // NOLINT + static constexpr T sqrt3_2() noexcept { return static_cast(0.8660254037844386467637231707529362L); } // NOLINT + static constexpr T pi() noexcept { return static_cast(3.1415926535897932384626433832795029L); } // NOLINT /// \brief Electric constant of vacuum /// - static inline constexpr T eps_0() noexcept { return static_cast(8.854187817e-12); } // NOLINT + static constexpr T eps_0() noexcept { return static_cast(8.854187817e-12); } // NOLINT // \brief Relative permittivity of Silicon dioxide /// - static inline constexpr T eps_SiO2() noexcept { return static_cast(3.9); } // NOLINT + static constexpr T eps_SiO2() noexcept { return static_cast(3.9); } // NOLINT /// \brief Relative permittivity of Silicon /// - static inline constexpr T eps_Si() noexcept { return static_cast(11.7); } // NOLINT + static constexpr T eps_Si() noexcept { return static_cast(11.7); } // NOLINT /// \brief Boltzmann constant /// - static inline constexpr T k_b() noexcept { return static_cast(1.38064852e-23); } // NOLINT + static constexpr T k_b() noexcept { return static_cast(1.38064852e-23); } // NOLINT /// \brief room temperature (gives VT = 0.02585 at T=300) /// - static inline constexpr T T0() noexcept { return static_cast(300); } // NOLINT + static constexpr T T0() noexcept { return static_cast(300); } // NOLINT /// \brief Elementary charge /// - static inline constexpr T Q_e() noexcept { return static_cast(1.6021765314e-19); } // NOLINT + static constexpr T Q_e() noexcept { return static_cast(1.6021765314e-19); } // NOLINT /// \brief Intrinsic carrier concentration in 1/m^3 of Silicon /// - static inline constexpr T NiSi() noexcept { return static_cast(1.45e16); } // NOLINT + static constexpr T NiSi() noexcept { return static_cast(1.45e16); } // NOLINT /// \brief clearly identify magic numbers in code /// @@ -82,10 +82,10 @@ namespace plib /// later. /// template - static inline constexpr T magic(V &&v) noexcept { return static_cast(v); } + static constexpr T magic(V &&v) noexcept { return static_cast(v); } template - static inline constexpr T fraction(V &&v1, V &&v2) noexcept { return static_cast(v1 / v2); } + static constexpr T fraction(V &&v1, V &&v2) noexcept { return static_cast(v1 / v2); } }; /// \brief typesafe reciprocal function @@ -95,7 +95,7 @@ namespace plib /// \return reciprocal of argument /// template - static inline constexpr std::enable_if_t::value, T> + static constexpr std::enable_if_t::value, T> reciprocal(T v) noexcept { return constants::one() / v; @@ -108,7 +108,7 @@ namespace plib /// \return absolute value of argument /// template - static inline constexpr std::enable_if_t::value, T> + static constexpr std::enable_if_t::value, T> abs(T v) noexcept { return std::abs(v); @@ -121,7 +121,7 @@ namespace plib /// \return absolute value of argument /// template - static inline constexpr std::enable_if_t::value, T> + static constexpr std::enable_if_t::value, T> sqrt(T v) noexcept { return std::sqrt(v); @@ -135,7 +135,7 @@ namespace plib /// \return sqrt(v1*v1+v2*v2) /// template - static inline constexpr std::enable_if_t::value, T> + static constexpr std::enable_if_t::value, T> hypot(T v1, T v2) noexcept { return std::hypot(v1, v2); @@ -148,7 +148,7 @@ namespace plib /// \return exp(v) /// template - static inline constexpr std::enable_if_t::value, T> + static constexpr std::enable_if_t::value, T> exp(T v) noexcept { return std::exp(v); @@ -161,7 +161,7 @@ namespace plib /// \return log(v) /// template - static inline constexpr std::enable_if_t::value, T> + static constexpr std::enable_if_t::value, T> log(T v) noexcept { return std::log(v); @@ -174,7 +174,7 @@ namespace plib /// \return tanh(v) /// template - static inline constexpr std::enable_if_t::value, T> + static constexpr std::enable_if_t::value, T> tanh(T v) noexcept { return std::tanh(v); @@ -187,7 +187,7 @@ namespace plib /// \return floor(v) /// template - static inline constexpr std::enable_if_t::value, T> + static constexpr std::enable_if_t::value, T> floor(T v) noexcept { return std::floor(v); @@ -200,7 +200,7 @@ namespace plib /// \return log(1 + v) /// template - static inline constexpr std::enable_if_t::value, T> + static constexpr std::enable_if_t::value, T> log1p(T v) noexcept { return std::log1p(v); @@ -213,7 +213,7 @@ namespace plib /// \return sin(v) /// template - static inline constexpr std::enable_if_t::value, T> + static constexpr std::enable_if_t::value, T> sin(T v) noexcept { return std::sin(v); @@ -226,7 +226,7 @@ namespace plib /// \return cos(v) /// template - static inline constexpr std::enable_if_t::value, T> + static constexpr std::enable_if_t::value, T> cos(T v) noexcept { return std::cos(v); @@ -239,7 +239,7 @@ namespace plib /// \return trunc(v) /// template - static inline constexpr std::enable_if_t::value, T> + static constexpr std::enable_if_t::value, T> trunc(T v) noexcept { return std::trunc(v); @@ -253,7 +253,7 @@ namespace plib /// \return signum(v) /// template - static inline constexpr std::enable_if_t::value, T> + static constexpr std::enable_if_t::value, T> signum(T v, T r = static_cast(1)) { constexpr const auto z(static_cast(0)); @@ -271,80 +271,80 @@ namespace plib /// FIXME: limited implementation /// template - static inline + static auto pow(T1 v, T2 p) noexcept -> decltype(std::pow(v, p)) { return std::pow(v, p); } #if (PUSE_FLOAT128) - static inline constexpr FLOAT128 reciprocal(FLOAT128 v) noexcept + static constexpr FLOAT128 reciprocal(FLOAT128 v) noexcept { return constants::one() / v; } - static inline FLOAT128 abs(FLOAT128 v) noexcept + static FLOAT128 abs(FLOAT128 v) noexcept { return fabsq(v); } - static inline FLOAT128 sqrt(FLOAT128 v) noexcept + static FLOAT128 sqrt(FLOAT128 v) noexcept { return sqrtq(v); } - static inline FLOAT128 hypot(FLOAT128 v1, FLOAT128 v2) noexcept + static FLOAT128 hypot(FLOAT128 v1, FLOAT128 v2) noexcept { return hypotq(v1, v2); } - static inline FLOAT128 exp(FLOAT128 v) noexcept + static FLOAT128 exp(FLOAT128 v) noexcept { return expq(v); } - static inline FLOAT128 log(FLOAT128 v) noexcept + static FLOAT128 log(FLOAT128 v) noexcept { return logq(v); } - static inline FLOAT128 tanh(FLOAT128 v) noexcept + static FLOAT128 tanh(FLOAT128 v) noexcept { return tanhq(v); } - static inline FLOAT128 floor(FLOAT128 v) noexcept + static FLOAT128 floor(FLOAT128 v) noexcept { return floorq(v); } - static inline FLOAT128 log1p(FLOAT128 v) noexcept + static FLOAT128 log1p(FLOAT128 v) noexcept { return log1pq(v); } - static inline FLOAT128 sin(FLOAT128 v) noexcept + static FLOAT128 sin(FLOAT128 v) noexcept { return sinq(v); } - static inline FLOAT128 cos(FLOAT128 v) noexcept + static FLOAT128 cos(FLOAT128 v) noexcept { return cosq(v); } - static inline FLOAT128 trunc(FLOAT128 v) noexcept + static FLOAT128 trunc(FLOAT128 v) noexcept { return truncq(v); } template - static inline FLOAT128 pow(FLOAT128 v, T p) noexcept + static FLOAT128 pow(FLOAT128 v, T p) noexcept { return powq(v, static_cast(p)); } - static inline FLOAT128 pow(FLOAT128 v, int p) noexcept + static FLOAT128 pow(FLOAT128 v, int p) noexcept { if (p==2) return v*v; diff --git a/src/lib/netlist/plib/pmulti_threading.h b/src/lib/netlist/plib/pmulti_threading.h index 9f470054e2d..c844086313c 100644 --- a/src/lib/netlist/plib/pmulti_threading.h +++ b/src/lib/netlist/plib/pmulti_threading.h @@ -23,9 +23,10 @@ namespace plib { struct pspin_mutex { public: - pspin_mutex() noexcept = default; - void lock() noexcept{ while (m_lock.test_and_set(std::memory_order_acquire)) { } } - void unlock() noexcept { m_lock.clear(std::memory_order_release); } + inline pspin_mutex() noexcept = default; + inline ~pspin_mutex() noexcept = default; + inline void lock() noexcept{ while (m_lock.test_and_set(std::memory_order_acquire)) { } } + inline void unlock() noexcept { m_lock.clear(std::memory_order_release); } private: PALIGNAS_CACHELINE() std::atomic_flag m_lock = ATOMIC_FLAG_INIT; @@ -35,8 +36,10 @@ namespace plib { struct pspin_mutex { public: - void lock() const noexcept { } - void unlock() const noexcept { } + inline pspin_mutex() noexcept = default; + inline ~pspin_mutex() noexcept = default; + static inline void lock() /*const*/ noexcept { } + static inline void unlock() /*const*/ noexcept { } }; class psemaphore diff --git a/src/lib/netlist/plib/ppmf.h b/src/lib/netlist/plib/ppmf.h index e86c94ff4c9..e37f970cc05 100644 --- a/src/lib/netlist/plib/ppmf.h +++ b/src/lib/netlist/plib/ppmf.h @@ -377,7 +377,7 @@ namespace plib { bind>(object, &mftp); } - inline R operator()(Targs... args) const noexcept(true) + R operator()(Targs... args) const noexcept(true) { return this->call(std::forward(args)...); } diff --git a/src/lib/netlist/plib/pstream.h b/src/lib/netlist/plib/pstream.h index 65d95293298..bc0c7cfc31e 100644 --- a/src/lib/netlist/plib/pstream.h +++ b/src/lib/netlist/plib/pstream.h @@ -28,7 +28,7 @@ namespace plib { /// \brief wrapper around isteam read /// template - static inline S & istream_read(S &is, T * data, size_t len) + static S & istream_read(S &is, T * data, size_t len) { using ct = typename S::char_type; static_assert((sizeof(T) % sizeof(ct)) == 0, "istream_read sizeof issue"); @@ -39,7 +39,7 @@ namespace plib { /// \brief wrapper around osteam write /// template - static inline S & ostream_write(S &os, const T * data, size_t len) + static S & ostream_write(S &os, const T * data, size_t len) { using ct = typename S::char_type; static_assert((sizeof(T) % sizeof(ct)) == 0, "ostream_write sizeof issue"); diff --git a/src/lib/netlist/plib/ptime.h b/src/lib/netlist/plib/ptime.h index 0f88449500b..9274467d0c2 100644 --- a/src/lib/netlist/plib/ptime.h +++ b/src/lib/netlist/plib/ptime.h @@ -82,18 +82,27 @@ namespace plib return *this; } +#if 1 template constexpr ptime operator-(const ptime &rhs) const noexcept { static_assert(ptime_le, ptime>::value, "Invalid ptime type"); return ptime(m_time - rhs.m_time); } - +#else + template + constexpr ptime operator-(ptime rhs) const noexcept + { + static_assert(ptime_le, ptime>::value, "Invalid ptime type"); + return (rhs -= (*this)); // causes a crash - FIXME + } +#endif template - constexpr ptime operator+(const ptime &rhs) const noexcept + constexpr ptime operator+(ptime rhs) const noexcept { static_assert(ptime_le, ptime>::value, "Invalid ptime type"); - return ptime(m_time + rhs.m_time); + return (rhs += *this); + //return ptime(m_time + rhs.m_time); } template @@ -173,9 +182,7 @@ namespace plib constexpr ptime shr(unsigned shift) const noexcept { return ptime(m_time >> shift); } // for save states .... -#if 0 - constexpr internal_type *get_internaltype_ptr() noexcept { return &m_time; } -#endif + template void save_state(ST &&st) { -- cgit v1.2.3