From 3b899b86e67e3a5cc093d2dd9c0dcaeed197c806 Mon Sep 17 00:00:00 2001 From: couriersud Date: Wed, 6 Feb 2019 10:24:34 +0100 Subject: netlist: Refactoring after adding clang-tidy support to netlist makefile - convert macros to c++ code. - order of device creation should not depend on std lib. - some state saving cleanup. - added support for clang-tidy to makefile. - modifications triggered by clang-tidy-9. --- src/lib/netlist/plib/pdynlib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/netlist/plib/pdynlib.h') diff --git a/src/lib/netlist/plib/pdynlib.h b/src/lib/netlist/plib/pdynlib.h index 7c9412593c9..0ab498436b3 100644 --- a/src/lib/netlist/plib/pdynlib.h +++ b/src/lib/netlist/plib/pdynlib.h @@ -64,6 +64,6 @@ private: calltype m_sym; }; -} +} // namespace plib #endif /* PSTRING_H_ */ -- cgit v1.2.3-70-g09d2 From a905dffd08abdabad3d3e0cfd1c56eb1d91376cf Mon Sep 17 00:00:00 2001 From: couriersud Date: Mon, 11 Feb 2019 22:18:30 +0100 Subject: netlist: More cpp core guidelines alignment. (nw) --- src/lib/netlist/build/makefile | 11 ++-- src/lib/netlist/devices/nld_7448.cpp | 4 +- src/lib/netlist/devices/nld_7450.cpp | 12 ++-- src/lib/netlist/devices/nld_7490.cpp | 2 +- src/lib/netlist/devices/nld_am2847.cpp | 2 +- src/lib/netlist/devices/nlid_proxy.h | 8 --- src/lib/netlist/devices/nlid_system.h | 2 +- src/lib/netlist/devices/nlid_truthtable.h | 2 - src/lib/netlist/netlist_types.h | 8 +++ src/lib/netlist/nl_base.cpp | 6 +- src/lib/netlist/nl_base.h | 53 +++++++++++++---- src/lib/netlist/nl_factory.cpp | 5 -- src/lib/netlist/nl_factory.h | 8 ++- src/lib/netlist/nl_setup.cpp | 4 +- src/lib/netlist/nl_setup.h | 10 +++- src/lib/netlist/nl_time.h | 2 + src/lib/netlist/plib/mat_cr.h | 3 + src/lib/netlist/plib/palloc.cpp | 3 +- src/lib/netlist/plib/palloc.h | 13 +++++ src/lib/netlist/plib/pchrono.h | 9 +-- src/lib/netlist/plib/pdynlib.h | 5 +- src/lib/netlist/plib/pexception.h | 5 +- src/lib/netlist/plib/pfmtlog.h | 20 +++++-- src/lib/netlist/plib/plists.h | 16 +++-- src/lib/netlist/plib/pmain.h | 3 + src/lib/netlist/plib/poptions.cpp | 5 -- src/lib/netlist/plib/poptions.h | 6 +- src/lib/netlist/plib/pparser.h | 8 ++- src/lib/netlist/plib/pstate.h | 9 ++- src/lib/netlist/plib/pstream.h | 94 +++++++++++++++++++++++++++--- src/lib/netlist/plib/pstring.h | 8 +-- src/lib/netlist/plib/ptypes.h | 10 ++++ src/lib/netlist/prg/nltool.cpp | 2 - src/lib/netlist/prg/nlwav.cpp | 3 + src/lib/netlist/solver/nld_matrix_solver.h | 3 - src/lib/netlist/solver/nld_ms_direct.h | 2 - src/lib/netlist/solver/nld_ms_gcr.h | 5 +- src/lib/netlist/solver/nld_ms_gmres.h | 2 - src/lib/netlist/solver/nld_ms_sm.h | 2 - src/lib/netlist/solver/nld_ms_sor.h | 2 - src/lib/netlist/solver/nld_ms_sor_mat.h | 2 - src/lib/netlist/solver/nld_ms_w.h | 6 +- src/lib/netlist/solver/nld_solver.cpp | 29 ++++----- src/lib/netlist/solver/nld_solver.h | 9 +-- src/lib/netlist/tools/nl_convert.cpp | 10 ++-- src/lib/netlist/tools/nl_convert.h | 6 +- 46 files changed, 288 insertions(+), 151 deletions(-) (limited to 'src/lib/netlist/plib/pdynlib.h') diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile index 45512d2beca..75aaed13889 100644 --- a/src/lib/netlist/build/makefile +++ b/src/lib/netlist/build/makefile @@ -14,14 +14,14 @@ VSBUILD = $(SRC)/buildVS DOC = $(SRC)/documentation TIDY_DB = ../compile_commands.json -TIDY_FLAGSX = -checks=*,-google*,-hicpp*,-readability*,-fuchsia*,-cert-*, +TIDY_FLAGSX = -checks=*,-google*,-hicpp*,-readability*,-fuchsia*,-cert-*,-android-*, TIDY_FLAGSX += -llvm-header-guard,-cppcoreguidelines-pro-type-reinterpret-cast, TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-owning-memory, TIDY_FLAGSX += -modernize-use-default-member-init,-cppcoreguidelines-pro-bounds-constant-array-index, TIDY_FLAGSX += -modernize-pass-by-value,-cppcoreguidelines-pro-type-static-cast-downcast, -//TIDY_FLAGSX += -cppcoreguidelines-special-member-functions, -TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-array-to-pointer-decay, -TIDY_FLAGSX += -performance-unnecessary-value-param,-android-*,-cppcoreguidelines-avoid-magic-numbers, +#TIDY_FLAGSX += -cppcoreguidelines-special-member-functions, +#TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-array-to-pointer-decay, +TIDY_FLAGSX += -performance-unnecessary-value-param,-cppcoreguidelines-avoid-magic-numbers, TIDY_FLAGSX += -cppcoreguidelines-macro-usage, TIDY_FLAGSX += -cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes, #TIDY_FLAGSX += -cppcoreguidelines-avoid-c-arrays,-modernize-avoid-c-arrays, @@ -33,6 +33,7 @@ space := space += TIDY_FLAGS = $(subst $(space),,$(TIDY_FLAGSX)) +#TIDY_FLAGS = -checks=llvm-include-order,llvm-namespace-comment,modernize-use-override,modernize-use-using -fix #TIDY_FLAGS = -checks=llvm-include-order -fix #TIDY_FLAGS = -checks=llvm-namespace-comment -fix #TIDY_FLAGS = -checks=modernize-use-override -fix @@ -235,7 +236,7 @@ native: $(MAKE) CEXTRAFLAGS="-march=native -Wall -Wpedantic -Wsign-compare -Wextra -Wno-unused-parameter" clang: - $(MAKE) CC=clang++-9 LD=clang++-9 CEXTRAFLAGS="-march=native -Wno-unused-parameter -Weverything -Werror -Wno-unreachable-code -Wno-padded -Wno-weak-vtables -Wno-missing-variable-declarations -Wconversion -Wno-c++98-compat -Wno-float-equal -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wweak-template-vtables -Wno-exit-time-destructors" + $(MAKE) CC=clang++-9 LD=clang++-9 CEXTRAFLAGS="-march=native -Wno-unused-parameter -Weverything -Werror -Wno-non-virtual-dtor -Wno-unreachable-code -Wno-padded -Wno-weak-vtables -Wno-missing-variable-declarations -Wconversion -Wno-c++98-compat -Wno-float-equal -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wweak-template-vtables -Wno-exit-time-destructors" clang-5: $(MAKE) CC=clang++-5.0 LD=clang++-5.0 CEXTRAFLAGS="-march=native -Weverything -Werror -Wno-inconsistent-missing-destructor-override -Wno-unreachable-code -Wno-padded -Wno-weak-vtables -Wno-missing-variable-declarations -Wconversion -Wno-c++98-compat -Wno-float-equal -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wno-weak-template-vtables -Wno-exit-time-destructors" diff --git a/src/lib/netlist/devices/nld_7448.cpp b/src/lib/netlist/devices/nld_7448.cpp index f14714de17c..14a1f12bfcc 100644 --- a/src/lib/netlist/devices/nld_7448.cpp +++ b/src/lib/netlist/devices/nld_7448.cpp @@ -5,6 +5,8 @@ * */ +#include + #include "nlid_truthtable.h" #include "nld_7448.h" @@ -135,7 +137,7 @@ namespace netlist #define BITS7(b6,b5,b4,b3,b2,b1,b0) ((b6)<<6) | ((b5)<<5) | ((b4)<<4) | ((b3)<<3) | ((b2)<<2) | ((b1)<<1) | ((b0)<<0) - static constexpr uint8_t tab7448[16] = + static constexpr std::array tab7448 = { BITS7( 1, 1, 1, 1, 1, 1, 0 ), /* 00 - not blanked ! */ BITS7( 0, 1, 1, 0, 0, 0, 0 ), /* 01 */ diff --git a/src/lib/netlist/devices/nld_7450.cpp b/src/lib/netlist/devices/nld_7450.cpp index 791ead0139f..a3e7e8d99cc 100644 --- a/src/lib/netlist/devices/nld_7450.cpp +++ b/src/lib/netlist/devices/nld_7450.cpp @@ -68,10 +68,10 @@ namespace netlist m_B.activate(); m_C.activate(); m_D.activate(); - unsigned t1 = m_A() & m_B(); - unsigned t2 = m_C() & m_D(); + auto t1 = m_A() & m_B(); + auto t2 = m_C() & m_D(); - const netlist_time times[2] = { NLTIME_FROM_NS(22), NLTIME_FROM_NS(15) }; + const netlist_time times[2] = { NLTIME_FROM_NS(15), NLTIME_FROM_NS(22) }; uint_fast8_t res = 0; if (t1 ^ 1) @@ -85,14 +85,16 @@ namespace netlist m_A.inactivate(); m_B.inactivate(); } - } else { + } + else + { if (t2 ^ 1) { m_C.inactivate(); m_D.inactivate(); } } - m_Q.push(res, times[1 - res]);// ? 22000 : 15000); + m_Q.push(res, times[res]);// ? 22000 : 15000); } NETLIB_DEVICE_IMPL(7450, "TTL_7450_ANDORINVERT", "+A,+B,+C,+D") diff --git a/src/lib/netlist/devices/nld_7490.cpp b/src/lib/netlist/devices/nld_7490.cpp index 7c710a8b941..585d8503777 100644 --- a/src/lib/netlist/devices/nld_7490.cpp +++ b/src/lib/netlist/devices/nld_7490.cpp @@ -120,7 +120,7 @@ namespace netlist m_last_B = new_B; } - NETLIB_FUNC_VOID(7490, update_outputs, (void)) + NETLIB_FUNC_VOID(7490, update_outputs, ()) { for (std::size_t i=0; i<4; i++) m_Q[i].push((m_cnt >> i) & 1, delay[i]); diff --git a/src/lib/netlist/devices/nld_am2847.cpp b/src/lib/netlist/devices/nld_am2847.cpp index 71e46e316f1..4ebc9ed27dc 100644 --- a/src/lib/netlist/devices/nld_am2847.cpp +++ b/src/lib/netlist/devices/nld_am2847.cpp @@ -116,7 +116,7 @@ namespace netlist /* do nothing */ } - NETLIB_FUNC_VOID(Am2847_shifter, shift, (void)) + NETLIB_FUNC_VOID(Am2847_shifter, shift, ()) { uint32_t out = m_buffer[0] & 1; uint32_t in = (m_RC() ? out : m_IN()); diff --git a/src/lib/netlist/devices/nlid_proxy.h b/src/lib/netlist/devices/nlid_proxy.h index f7eb2d7baa3..09a5da48c25 100644 --- a/src/lib/netlist/devices/nlid_proxy.h +++ b/src/lib/netlist/devices/nlid_proxy.h @@ -29,8 +29,6 @@ namespace netlist nld_base_proxy(netlist_state_t &anetlist, const pstring &name, logic_t *inout_proxied, detail::core_terminal_t *proxy_inout); - ~nld_base_proxy() override = default; - logic_t &term_proxied() const { return *m_term_proxied; } detail::core_terminal_t &proxy_term() const { return *m_proxy_term; } @@ -49,8 +47,6 @@ namespace netlist { public: - ~nld_base_a_to_d_proxy() override = default; - virtual logic_output_t &out() { return m_Q; } protected: @@ -69,8 +65,6 @@ namespace netlist public: nld_a_to_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *in_proxied); - ~nld_a_to_d_proxy() override = default; - analog_input_t m_I; protected: @@ -88,7 +82,6 @@ namespace netlist NETLIB_OBJECT_DERIVED(base_d_to_a_proxy, base_proxy) { public: - ~nld_base_d_to_a_proxy() override = default; virtual logic_input_t &in() { return m_I; } @@ -105,7 +98,6 @@ namespace netlist { public: nld_d_to_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *out_proxied); - ~nld_d_to_a_proxy() override = default; protected: diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index 2a1e4b3e66c..1c2c166dff4 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -28,7 +28,7 @@ namespace netlist { NETLIB_CONSTRUCTOR(netlistparams) , m_use_deactivate(*this, "USE_DEACTIVATE", false) - , m_startup_strategy(*this, "STARTUP_STRATEGY", 1) + , m_startup_strategy(*this, "STARTUP_STRATEGY", 0) { } NETLIB_UPDATEI() { } diff --git a/src/lib/netlist/devices/nlid_truthtable.h b/src/lib/netlist/devices/nlid_truthtable.h index af0fbcf329a..857f35d9bc0 100644 --- a/src/lib/netlist/devices/nlid_truthtable.h +++ b/src/lib/netlist/devices/nlid_truthtable.h @@ -219,8 +219,6 @@ namespace devices netlist_base_factory_truthtable_t(const pstring &name, const pstring &classname, const pstring &def_param, const pstring &sourcefile); - ~netlist_base_factory_truthtable_t() override = default; - std::vector m_desc; const logic_family_desc_t *m_family; }; diff --git a/src/lib/netlist/netlist_types.h b/src/lib/netlist/netlist_types.h index 9edd19e0ace..3aa7f3436ee 100644 --- a/src/lib/netlist/netlist_types.h +++ b/src/lib/netlist/netlist_types.h @@ -27,6 +27,7 @@ namespace netlist */ using netlist_sig_t = std::uint32_t; + /* FIXME: belongs into nl_base.h to nlstate */ /** * @brief Interface definition for netlist callbacks into calling code * @@ -38,10 +39,17 @@ namespace netlist class callbacks_t { public: + + callbacks_t() = default; + /* what is done before this is passed as a unique_ptr to netlist + * we should not limit. + */ virtual ~callbacks_t() = default; + COPYASSIGNMOVE(callbacks_t, default) /* logging callback */ virtual void vlog(const plib::plog_level &l, const pstring &ls) const = 0; + }; using log_type = plib::plog_base; diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index 246077788d9..53ee4e83a8a 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -141,17 +141,13 @@ const logic_family_desc_t *family_CD4XXX() detail::queue_t::queue_t(netlist_state_t &nl) : timed_queue, false, NL_KEEP_STATISTICS>(512) , netlist_ref(nl) - , plib::state_manager_t::callback_t() +// , plib::state_manager_t::callback_t() , m_qsize(0) , m_times(512) , m_net_ids(512) { } -detail::queue_t::~queue_t() -{ -} - void detail::queue_t::register_state(plib::state_manager_t &manager, const pstring &module) { //state().log().debug("register_state\n"); diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 69ace67d9d7..62a5104a021 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -227,8 +227,6 @@ namespace netlist explicit nl_exception(const pstring &text //!< text to be passed ) : plib::pexception(text) { } - /*! Copy constructor. */ - nl_exception(const nl_exception &e) = default; }; /*! Logic families descriptors are used to create proxy devices. @@ -239,7 +237,10 @@ namespace netlist { public: logic_family_desc_t(); - virtual ~logic_family_desc_t() = default; + + COPYASSIGNMOVE(logic_family_desc_t, delete) + + virtual ~logic_family_desc_t() noexcept = default; virtual plib::owned_ptr create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const = 0; @@ -279,12 +280,14 @@ namespace netlist public: logic_family_t() : m_logic_family(nullptr) {} + COPYASSIGNMOVE(logic_family_t, delete) + const logic_family_desc_t *logic_family() const { return m_logic_family; } void set_logic_family(const logic_family_desc_t *fam) { m_logic_family = fam; } protected: - ~logic_family_t() = default; // prohibit polymorphic destruction + ~logic_family_t() noexcept = default; // prohibit polymorphic destruction const logic_family_desc_t *m_logic_family; }; @@ -314,6 +317,9 @@ namespace netlist const pstring &name, //!< identifier/name for this state variable const T &value //!< Initial value after construction ); + + //! Destructor. + ~state_var() noexcept = default; //! Copy Constructor. constexpr state_var(const state_var &rhs) = default; //! Move Constructor. @@ -353,9 +359,13 @@ namespace netlist ); //! Copy Constructor. state_array(const state_array &rhs) NL_NOEXCEPT = default; + //! Destructor. + ~state_array() noexcept = default; //! Move Constructor. state_array(state_array &&rhs) NL_NOEXCEPT = default; state_array &operator=(const state_array &rhs) NL_NOEXCEPT = default; + state_array &operator=(state_array &&rhs) NL_NOEXCEPT = default; + state_array &operator=(const T &rhs) NL_NOEXCEPT { m_value = rhs; return *this; } T & operator[](const std::size_t i) NL_NOEXCEPT { return m_value[i]; } constexpr const T & operator[](const std::size_t i) const NL_NOEXCEPT { return m_value[i]; } @@ -390,7 +400,7 @@ namespace netlist * memory allocation to enhance locality. Please refer to \ref USE_MEMPOOL as * well. */ - class detail::object_t : public plib::nocopyassignmove + class detail::object_t { public: @@ -400,6 +410,7 @@ namespace netlist */ explicit object_t(const pstring &aname /*!< string containing name of the object */); + COPYASSIGNMOVE(object_t, delete) /*! return name of the object * * \returns name of the object. @@ -411,7 +422,7 @@ namespace netlist void * operator new (size_t size); void operator delete (void * mem); protected: - ~object_t() = default; // only childs should be destructible + ~object_t() noexcept = default; // only childs should be destructible private: //pstring m_name; @@ -426,6 +437,8 @@ namespace netlist { explicit netlist_ref(netlist_state_t &nl); + COPYASSIGNMOVE(netlist_ref, delete) + netlist_state_t & state() noexcept; const netlist_state_t & state() const noexcept; @@ -512,7 +525,9 @@ namespace netlist core_terminal_t(core_device_t &dev, const pstring &aname, const state_e state, nldelegate delegate = nldelegate()); - virtual ~core_terminal_t() = default; + virtual ~core_terminal_t() noexcept = default; + + COPYASSIGNMOVE(core_terminal_t, delete) /*! The object type. * \returns type of the object @@ -713,7 +728,10 @@ namespace netlist }; net_t(netlist_state_t &nl, const pstring &aname, core_terminal_t *mr = nullptr); - virtual ~net_t() = default; + + COPYASSIGNMOVE(net_t, delete) + + virtual ~net_t() noexcept = default; void reset(); @@ -916,6 +934,8 @@ namespace netlist param_t(device_t &device, const pstring &name); + COPYASSIGNMOVE(param_t, delete) + param_type_t param_type() const; protected: @@ -946,6 +966,7 @@ namespace netlist { public: param_num_t(device_t &device, const pstring &name, const T val); + const T operator()() const NL_NOEXCEPT { return m_param; } void setTo(const T ¶m) { set(m_param, param); } private: @@ -1086,7 +1107,9 @@ namespace netlist core_device_t(netlist_state_t &owner, const pstring &name); core_device_t(core_device_t &owner, const pstring &name); - virtual ~core_device_t() = default; + COPYASSIGNMOVE(core_device_t, delete) + + virtual ~core_device_t() noexcept = default; void do_inc_active() NL_NOEXCEPT { @@ -1155,6 +1178,8 @@ namespace netlist device_t(netlist_state_t &owner, const pstring &name); device_t(core_device_t &owner, const pstring &name); + COPYASSIGNMOVE(device_t, delete) + ~device_t() override = default; setup_t &setup(); @@ -1221,7 +1246,6 @@ namespace netlist public: using entry_t = pqentry_t; explicit queue_t(netlist_state_t &nl); - ~queue_t(); protected: @@ -1250,7 +1274,9 @@ namespace netlist std::unique_ptr &&callbacks, std::unique_ptr &&setup); - ~netlist_state_t() = default; + COPYASSIGNMOVE(netlist_state_t, delete) + + ~netlist_state_t() noexcept = default; friend class netlist_t; // allow access to private members @@ -1378,7 +1404,10 @@ namespace netlist public: explicit netlist_t(const pstring &aname, std::unique_ptr callbacks); - ~netlist_t() = default; + + COPYASSIGNMOVE(netlist_t, delete) + + ~netlist_t() noexcept = default; /* run functions */ diff --git a/src/lib/netlist/nl_factory.cpp b/src/lib/netlist/nl_factory.cpp index d66b61d5154..10fb54bdec0 100644 --- a/src/lib/netlist/nl_factory.cpp +++ b/src/lib/netlist/nl_factory.cpp @@ -52,11 +52,6 @@ namespace netlist { namespace factory { } - list_t::~list_t() - { - clear(); - } - void list_t::register_device(std::unique_ptr &&factory) { for (auto & e : *this) diff --git a/src/lib/netlist/nl_factory.h b/src/lib/netlist/nl_factory.h index ca0c266739e..6314c46d3fa 100644 --- a/src/lib/netlist/nl_factory.h +++ b/src/lib/netlist/nl_factory.h @@ -42,7 +42,7 @@ namespace factory { // net_dev class factory // ----------------------------------------------------------------------------- - class element_t : plib::nocopyassignmove + class element_t { public: element_t(const pstring &name, const pstring &classname, @@ -51,6 +51,8 @@ namespace factory { const pstring &def_param, const pstring &sourcefile); virtual ~element_t() = default; + COPYASSIGNMOVE(element_t, default) + virtual plib::owned_ptr Create(netlist_state_t &anetlist, const pstring &name) = 0; virtual void macro_actions(netlist_state_t &anetlist, const pstring &name) { @@ -91,7 +93,9 @@ namespace factory { { public: explicit list_t(setup_t &m_setup); - ~list_t(); + ~list_t() = default; + + COPYASSIGNMOVE(list_t, delete) template void register_device(const pstring &name, const pstring &classname, diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp index cfc9a7eb484..282b49697b9 100644 --- a/src/lib/netlist/nl_setup.cpp +++ b/src/lib/netlist/nl_setup.cpp @@ -34,14 +34,14 @@ setup_t::setup_t(netlist_t &netlist) { } -setup_t::~setup_t() +setup_t::~setup_t() noexcept { + // FIXME: can't see a need any longer m_links.clear(); m_alias.clear(); m_params.clear(); m_terminals.clear(); m_param_values.clear(); - m_sources.clear(); } diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h index 971f8d2e91d..07dbdb887e6 100644 --- a/src/lib/netlist/nl_setup.h +++ b/src/lib/netlist/nl_setup.h @@ -140,6 +140,7 @@ namespace netlist struct tt_desc { + tt_desc() : ni(0), no(0) { } pstring name; pstring classname; unsigned long ni; @@ -187,7 +188,9 @@ namespace netlist : m_setup(setup), m_type(type) {} - virtual ~source_t() = default; + COPYASSIGNMOVE(source_t, delete) + + virtual ~source_t() noexcept = default; virtual bool parse(const pstring &name); setup_t &setup() { return m_setup; } @@ -206,15 +209,16 @@ namespace netlist // ---------------------------------------------------------------------------------------- - class setup_t : plib::nocopyassignmove + class setup_t { public: using link_t = std::pair; explicit setup_t(netlist_t &netlist); - ~setup_t(); + ~setup_t() noexcept; + COPYASSIGNMOVE(setup_t, delete) netlist_state_t &netlist(); const netlist_state_t &netlist() const; diff --git a/src/lib/netlist/nl_time.h b/src/lib/netlist/nl_time.h index 76e572a4772..6bd61a3f68e 100644 --- a/src/lib/netlist/nl_time.h +++ b/src/lib/netlist/nl_time.h @@ -30,6 +30,8 @@ namespace netlist constexpr ptime() noexcept : m_time(0) {} + ~ptime() noexcept = default; + constexpr ptime(const ptime &rhs) noexcept = default; constexpr ptime(ptime &&rhs) noexcept = default; constexpr explicit ptime(const internal_type &time) noexcept : m_time(time) {} diff --git a/src/lib/netlist/plib/mat_cr.h b/src/lib/netlist/plib/mat_cr.h index ff08ce9413d..827f9a6c270 100644 --- a/src/lib/netlist/plib/mat_cr.h +++ b/src/lib/netlist/plib/mat_cr.h @@ -22,6 +22,7 @@ #include "pconfig.h" #include "pomp.h" #include "pstate.h" +#include "ptypes.h" #include "putil.h" namespace plib @@ -33,6 +34,8 @@ namespace plib using index_type = C; using value_type = T; + COPYASSIGNMOVE(matrix_compressed_rows_t, default) + enum constants_e { FILL_INFINITY = 9999999 diff --git a/src/lib/netlist/plib/palloc.cpp b/src/lib/netlist/plib/palloc.cpp index ab5b14d0618..4115a450a40 100644 --- a/src/lib/netlist/plib/palloc.cpp +++ b/src/lib/netlist/plib/palloc.cpp @@ -9,6 +9,7 @@ #include "palloc.h" #include "pexception.h" #include "pfmtlog.h" +#include "pstream.h" #include @@ -28,7 +29,7 @@ mempool::~mempool() { if (b->m_num_alloc != 0) { - fprintf(stderr, "Found block with %d dangling allocations\n", static_cast(b->m_num_alloc)); + perrlogger("Found block with {} dangling allocations\n", b->m_num_alloc); } ::operator delete(b->data); } diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h index e8d82277ed9..b837455095c 100644 --- a/src/lib/netlist/plib/palloc.h +++ b/src/lib/netlist/plib/palloc.h @@ -9,6 +9,7 @@ #define PALLOC_H_ #include "pstring.h" +#include "ptypes.h" #include #include @@ -92,6 +93,15 @@ public: r.m_ptr = nullptr; } + owned_ptr &operator=(owned_ptr &&r) noexcept + { + m_is_owned = r.m_is_owned; + m_ptr = r.m_ptr; + r.m_is_owned = false; + r.m_ptr = nullptr; + return *this; + } + template owned_ptr(owned_ptr &&r) noexcept { @@ -169,6 +179,9 @@ private: public: mempool(size_t min_alloc, size_t min_align); + + COPYASSIGNMOVE(mempool, delete) + ~mempool(); void *alloc(size_t size); diff --git a/src/lib/netlist/plib/pchrono.h b/src/lib/netlist/plib/pchrono.h index e982dec535b..8ce0eca23b3 100644 --- a/src/lib/netlist/plib/pchrono.h +++ b/src/lib/netlist/plib/pchrono.h @@ -9,6 +9,7 @@ #define PCHRONO_H_ #include "pconfig.h" +#include "ptypes.h" #include #include @@ -175,10 +176,11 @@ namespace chrono { struct guard_t { guard_t() = delete; - guard_t(const guard_t &g) noexcept = default; - guard_t(guard_t &&g) noexcept = default; guard_t(timer &m) noexcept : m_m(m) { m_m.m_time -= T::start(); } ~guard_t() { m_m.m_time += T::stop(); ++m_m.m_count; } + + COPYASSIGNMOVE(guard_t, default) + private: timer &m_m; }; @@ -212,8 +214,7 @@ namespace chrono { struct guard_t { guard_t() = default; - guard_t(const guard_t &g) noexcept = default; - guard_t(guard_t &&g) noexcept = default; + COPYASSIGNMOVE(guard_t, default) /* using default constructor will trigger warning on * unused local variable. */ diff --git a/src/lib/netlist/plib/pdynlib.h b/src/lib/netlist/plib/pdynlib.h index 0ab498436b3..fe9db58d6f2 100644 --- a/src/lib/netlist/plib/pdynlib.h +++ b/src/lib/netlist/plib/pdynlib.h @@ -8,18 +8,21 @@ #define PDYNLIB_H_ #include "pstring.h" +#include "ptypes.h" namespace plib { // ---------------------------------------------------------------------------------------- // pdynlib: dynamic loading of libraries ... // ---------------------------------------------------------------------------------------- -class dynlib +class dynlib : public nocopyassignmove { public: explicit dynlib(const pstring libname); dynlib(const pstring path, const pstring libname); + ~dynlib(); + COPYASSIGNMOVE(dynlib, delete) bool isLoaded() const; diff --git a/src/lib/netlist/plib/pexception.h b/src/lib/netlist/plib/pexception.h index 7c798112c69..ed0d14f5747 100644 --- a/src/lib/netlist/plib/pexception.h +++ b/src/lib/netlist/plib/pexception.h @@ -87,10 +87,13 @@ static constexpr unsigned FP_ALL = 0x0001f; * Catch SIGFPE on linux for debugging purposes. */ -class fpsignalenabler : public nocopyassignmove +class fpsignalenabler { public: explicit fpsignalenabler(unsigned fpexceptions); + + COPYASSIGNMOVE(fpsignalenabler, delete) + ~fpsignalenabler(); /* is the functionality supported ? */ diff --git a/src/lib/netlist/plib/pfmtlog.h b/src/lib/netlist/plib/pfmtlog.h index bf9d45fadd2..4c01f96dba7 100644 --- a/src/lib/netlist/plib/pfmtlog.h +++ b/src/lib/netlist/plib/pfmtlog.h @@ -157,8 +157,9 @@ public: : m_str(fmt), m_arg(0) { } - pfmt(const pfmt &rhs) = default; - ~pfmt() = default; + COPYASSIGNMOVE(pfmt, default) + + ~pfmt() noexcept = default; operator pstring() const { return m_str; } // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) @@ -215,11 +216,13 @@ private: }; template -class pfmt_writer_t : plib::nocopyassignmove +class pfmt_writer_t { public: explicit pfmt_writer_t() : m_enabled(true) { } + COPYASSIGNMOVE(pfmt_writer_t, delete) + /* runtime enable */ template void log(const pstring & fmt, Args&&... args) const @@ -249,7 +252,7 @@ public: bool is_enabled() const { return m_enabled; } protected: - ~pfmt_writer_t() = default; + ~pfmt_writer_t() noexcept = default; private: pfmt &xlog(pfmt &fmt) const { return fmt; } @@ -270,7 +273,10 @@ class plog_channel : public pfmt_writer_t, bui friend class pfmt_writer_t, build_enabled>; public: explicit plog_channel(T &b) : pfmt_writer_t(), m_base(b) { } - ~plog_channel() = default; + + COPYASSIGNMOVE(plog_channel, delete) + + ~plog_channel() noexcept = default; protected: void vdowrite(const pstring &ls) const @@ -295,7 +301,9 @@ public: error(proxy), fatal(proxy) {} - virtual ~plog_base() = default; + + COPYASSIGNMOVE(plog_base, default) + virtual ~plog_base() noexcept = default; plog_channel debug; plog_channel info; diff --git a/src/lib/netlist/plib/plists.h b/src/lib/netlist/plib/plists.h index 9cdca8813a0..46a679cc81b 100644 --- a/src/lib/netlist/plib/plists.h +++ b/src/lib/netlist/plib/plists.h @@ -12,6 +12,8 @@ #include "pstring.h" +#include +#include #include namespace plib { @@ -34,6 +36,7 @@ public: uninitialised_array_t() = default; + COPYASSIGNMOVE(uninitialised_array_t, delete) ~uninitialised_array_t() { for (std::size_t i=0; i::type m_buf[N]; + std::array::type, N> m_buf; }; // ---------------------------------------------------------------------------------------- @@ -180,14 +183,12 @@ public: friend class linkedlist_t; constexpr element_t() : m_next(nullptr), m_prev(nullptr) {} - constexpr element_t(const element_t &rhs) = delete; - constexpr element_t(element_t &&rhs) = delete; + ~element_t() noexcept = default; + + COPYASSIGNMOVE(element_t, delete) constexpr LC *next() const noexcept { return m_next; } constexpr LC *prev() const noexcept { return m_prev; } - - protected: - ~element_t() = default; private: LC * m_next; LC * m_prev; @@ -205,6 +206,9 @@ public: iter_t& operator=(iter_t &&rhs) noexcept { std::swap(*this, rhs); return *this; } iter_t& operator++() noexcept {p = p->next();return *this;} iter_t operator++(int) noexcept {iter_t tmp(*this); operator++(); return tmp;} + + ~iter_t() = default; + constexpr bool operator==(const iter_t& rhs) const noexcept {return p == rhs.p;} constexpr bool operator!=(const iter_t& rhs) const noexcept {return p != rhs.p;} /* constexpr */ LC& operator*() noexcept {return *p;} diff --git a/src/lib/netlist/plib/pmain.h b/src/lib/netlist/plib/pmain.h index 04a8dd0bc53..e6fb0bd60d5 100644 --- a/src/lib/netlist/plib/pmain.h +++ b/src/lib/netlist/plib/pmain.h @@ -36,6 +36,9 @@ namespace plib { { public: app(); + + COPYASSIGNMOVE(app, delete) + virtual ~app() = default; virtual pstring usage() = 0; diff --git a/src/lib/netlist/plib/poptions.cpp b/src/lib/netlist/plib/poptions.cpp index cd40c5d5492..2a58eaab0f4 100644 --- a/src/lib/netlist/plib/poptions.cpp +++ b/src/lib/netlist/plib/poptions.cpp @@ -62,11 +62,6 @@ namespace plib { } } - options::~options() - { - m_opts.clear(); - } - void options::register_option(option_base *opt) { m_opts.push_back(opt); diff --git a/src/lib/netlist/plib/poptions.h b/src/lib/netlist/plib/poptions.h index 091adfb6d8f..23319604052 100644 --- a/src/lib/netlist/plib/poptions.h +++ b/src/lib/netlist/plib/poptions.h @@ -27,6 +27,8 @@ public: option_base(options &parent, pstring help); virtual ~option_base() = default; + COPYASSIGNMOVE(option_base, delete) + pstring help() const { return m_help; } private: pstring m_help; @@ -217,15 +219,13 @@ public: {} }; -class options +class options : public nocopyassignmove { public: options(); explicit options(option **o); - ~options(); - void register_option(option_base *opt); int parse(int argc, char **argv); diff --git a/src/lib/netlist/plib/pparser.h b/src/lib/netlist/plib/pparser.h index 9b68a5524f1..9803fae9cb8 100644 --- a/src/lib/netlist/plib/pparser.h +++ b/src/lib/netlist/plib/pparser.h @@ -17,7 +17,7 @@ namespace plib { -class ptokenizer : public nocopyassignmove +class ptokenizer { public: template @@ -26,6 +26,8 @@ public: { } + COPYASSIGNMOVE(ptokenizer, delete) + virtual ~ptokenizer() = default; enum token_type @@ -183,6 +185,10 @@ public: return *this; } + COPYASSIGN(ppreprocessor, delete) + ppreprocessor &operator=(ppreprocessor &&src) = delete; + + ppreprocessor(ppreprocessor &&s) noexcept : m_defines(std::move(s.m_defines)) , m_expr_sep(std::move(s.m_expr_sep)) diff --git a/src/lib/netlist/plib/pstate.h b/src/lib/netlist/plib/pstate.h index 290333bf87d..cdb6ea94dc8 100644 --- a/src/lib/netlist/plib/pstate.h +++ b/src/lib/netlist/plib/pstate.h @@ -47,7 +47,7 @@ public: std::is_floating_point::value); } - class callback_t : nocopyassignmove + class callback_t { public: using list_t = std::vector; @@ -56,7 +56,9 @@ public: virtual void on_pre_save(state_manager_t &manager) = 0; virtual void on_post_load(state_manager_t &manager) = 0; protected: - virtual ~callback_t() = default; + callback_t() = default; + ~callback_t() = default; + COPYASSIGNMOVE(callback_t, default) }; struct entry_t @@ -70,8 +72,6 @@ public: entry_t(const pstring &stname, const void *owner, callback_t *callback) : m_name(stname), m_dt(datatype_t(true)), m_owner(owner), m_callback(callback), m_count(0), m_ptr(nullptr) { } - ~entry_t() = default; - pstring m_name; const datatype_t m_dt; const void * m_owner; @@ -81,7 +81,6 @@ public: }; state_manager_t() = default; - ~state_manager_t() = default; template void save_item(const void *owner, C &state, const pstring &stname) diff --git a/src/lib/netlist/plib/pstream.h b/src/lib/netlist/plib/pstream.h index 2492d01d141..17a5f2702a4 100644 --- a/src/lib/netlist/plib/pstream.h +++ b/src/lib/netlist/plib/pstream.h @@ -41,7 +41,7 @@ typedef std::ostringstream pomemstream; // pstream: things common to all streams // ----------------------------------------------------------------------------- -class pstream : public nocopyassign +class pstream { public: @@ -50,6 +50,9 @@ public: static constexpr pos_type SEEK_EOF = static_cast(-1); + COPYASSIGN(pstream, delete) + pstream &operator=(pstream &&) noexcept = delete; + bool seekable() const { return ((m_flags & FLAG_SEEKABLE) != 0); } void seekp(const pos_type n) @@ -69,9 +72,8 @@ protected: explicit pstream(const unsigned flags) : m_flags(flags) { } - pstream(pstream &&src) noexcept : m_flags(src.m_flags) - { - } + pstream(pstream &&src) noexcept = default; + virtual ~pstream() = default; virtual void vseek(const pos_type n) = 0; @@ -105,6 +107,11 @@ public: using value_type = T; + ~pistream_base() noexcept override = default; + + COPYASSIGN(pistream_base, delete) + pistream_base &operator=(pistream_base &&src) noexcept = delete; + bool eof() const { return ((flags() & FLAG_EOF) != 0); } pos_type read(T *buf, const pos_type n) @@ -116,6 +123,7 @@ protected: pistream_base() : pstream(0) {} explicit pistream_base(const unsigned flags) : pstream(flags) {} pistream_base(pistream_base &&src) noexcept : pstream(std::move(src)) {} + /* read up to n bytes from stream */ virtual size_type vread(T *buf, const size_type n) = 0; }; @@ -134,6 +142,12 @@ public: using value_type = T; + postream_base() = default; + ~postream_base() noexcept override = default; + + COPYASSIGN(postream_base, delete) + postream_base &operator=(postream_base &&src) noexcept = delete; + void write(const T *buf, const size_type n) { vwrite(buf, n); @@ -142,6 +156,7 @@ public: protected: explicit postream_base(unsigned flags) : pstream(flags) {} postream_base(postream_base &&src) noexcept : pstream(std::move(src)) {} + /* write n bytes to stream */ virtual void vwrite(const T *buf, const size_type n) = 0; @@ -160,6 +175,8 @@ public: pomemstream(); + COPYASSIGN(pomemstream, delete) + pomemstream(pomemstream &&src) noexcept : postream(std::move(src)) , m_pos(src.m_pos) @@ -169,6 +186,7 @@ public: { src.m_mem = nullptr; } + pomemstream &operator=(pomemstream &&src) = delete; ~pomemstream() override; @@ -198,6 +216,9 @@ public: , m_buf(std::move(src.m_buf)) { src.m_buf = ""; } + COPYASSIGN(postringstream, delete) + postringstream &operator=(postringstream &&src) = delete; + ~postringstream() override = default; const pstring &str() { return m_buf; } @@ -234,6 +255,8 @@ public: src.m_file = nullptr; src.m_actually_close = false; } + COPYASSIGN(pofilestream, delete) + pofilestream &operator=(pofilestream &&src) = delete; ~pofilestream() override; @@ -262,6 +285,11 @@ class pstderr : public pofilestream { public: pstderr(); + pstderr(pstderr &&src) noexcept = default; + pstderr &operator=(pstderr &&src) = delete; + COPYASSIGN(pstderr, delete) + + ~pstderr() noexcept override= default; }; // ----------------------------------------------------------------------------- @@ -272,6 +300,11 @@ class pstdout : public pofilestream { public: pstdout(); + pstdout(pstdout &&src) noexcept = default; + pstdout &operator=(pstdout &&src) = delete; + COPYASSIGN(pstdout, delete) + + ~pstdout() noexcept override = default; }; // ----------------------------------------------------------------------------- @@ -295,6 +328,8 @@ public: src.m_actually_close = false; src.m_file = nullptr; } + COPYASSIGN(pifilestream, delete) + pifilestream &operator=(pifilestream &&src) = delete; protected: pifilestream(void *file, const pstring &name, const bool do_close); @@ -322,6 +357,9 @@ class pstdin : public pifilestream public: pstdin(); + pstdin(pstdin &&src) noexcept = default; + pstdin &operator=(pstdin &&src) = delete; + COPYASSIGN(pstdin, delete) ~pstdin() override = default; }; @@ -344,6 +382,8 @@ public: { src.m_mem = nullptr; } + COPYASSIGN(pimemstream, delete) + pimemstream &operator=(pimemstream &&src) = delete; explicit pimemstream(const pomemstream &ostrm); @@ -387,6 +427,9 @@ public: { set_mem(m_str.c_str(), std::strlen(m_str.c_str())); } + COPYASSIGN(pistringstream, delete) + pistringstream &operator=(pistringstream &&src) = delete; + ~pistringstream() override = default; private: @@ -407,17 +450,20 @@ struct constructor_helper std::unique_ptr operator()(T &&s) { return std::move(plib::make_unique(std::move(s))); } }; -class putf8_reader : plib::nocopyassign +// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) +class putf8_reader { public: + COPYASSIGN(putf8_reader, delete) + putf8_reader &operator=(putf8_reader &&src) = delete; virtual ~putf8_reader() = default; template friend struct constructor_helper; template - putf8_reader(T &&strm) // NOLINT(misc-forwarding-reference-overload, bugprone-forwarding-reference-overload) + putf8_reader(T &&strm) // NOLINT(cppcoreguidelines-special-member-functions, misc-forwarding-reference-overload, bugprone-forwarding-reference-overload) : m_strm(std::move(constructor_helper()(std::move(strm)))) // NOLINT(bugprone-move-forwarding-reference) {} @@ -464,12 +510,16 @@ struct constructor_helper> // putf8writer_t: writer on top of ostream // ----------------------------------------------------------------------------- -class putf8_writer : plib::nocopyassign +class putf8_writer { public: explicit putf8_writer(postream *strm) : m_strm(strm) {} putf8_writer(putf8_writer &&src) noexcept : m_strm(src.m_strm) {} + + COPYASSIGN(putf8_writer, delete) + putf8_writer &operator=(putf8_writer &&src) = delete; + virtual ~putf8_writer() = default; void writeline(const pstring &line) const @@ -504,6 +554,8 @@ public: { } + COPYASSIGNMOVE(putf8_fmt_writer, delete) + ~putf8_fmt_writer() override = default; //protected: @@ -516,11 +568,15 @@ private: // pbinary_writer_t: writer on top of ostream // ----------------------------------------------------------------------------- -class pbinary_writer : public plib::nocopyassign +class pbinary_writer { public: explicit pbinary_writer(postream &strm) : m_strm(strm) {} pbinary_writer(pbinary_writer &&src) noexcept : m_strm(src.m_strm) {} + + COPYASSIGN(pbinary_writer, delete) + postringstream &operator=(pbinary_writer &&src) = delete; + virtual ~pbinary_writer() = default; template @@ -549,11 +605,15 @@ private: postream &m_strm; }; -class pbinary_reader : public plib::nocopyassign +class pbinary_reader { public: explicit pbinary_reader(pistream &strm) : m_strm(strm) {} pbinary_reader(pbinary_reader &&src) noexcept : m_strm(src.m_strm) { } + + COPYASSIGN(pbinary_reader, delete) + pbinary_reader &operator=(pbinary_reader &&src) = delete; + virtual ~pbinary_reader() = default; template @@ -594,6 +654,22 @@ inline void copystream(postream &dest, pistream &src) dest.write(buf.data(), r); } +struct perrlogger +{ + template + perrlogger(Args&& ... args) + { + h()(std::forward(args)...); + } +private: + static putf8_fmt_writer &h() + { + static plib::pstderr perr_strm; + static plib::putf8_fmt_writer perr(&perr_strm); + return perr; + } +}; + } // namespace plib diff --git a/src/lib/netlist/plib/pstring.h b/src/lib/netlist/plib/pstring.h index 6625ddb11f9..c490ffa019e 100644 --- a/src/lib/netlist/plib/pstring.h +++ b/src/lib/netlist/plib/pstring.h @@ -92,7 +92,7 @@ public: // simple construction/destruction pstring_t() = default; - ~pstring_t() = default; + ~pstring_t() noexcept = default; // FIXME: Do something with encoding pstring_t(const mem_t *string) @@ -115,13 +115,15 @@ public: m_str.assign(string, N - 1); } - pstring_t(const pstring_t &string) = default; explicit pstring_t(const string_type &string) : m_str(string) { } + pstring_t(const pstring_t &string) = default; pstring_t(pstring_t &&string) noexcept = default; + pstring_t &operator=(const pstring_t &string) = default; + pstring_t &operator=(pstring_t &&string) noexcept = default; explicit pstring_t(code_t code) { @@ -139,8 +141,6 @@ public: operator string_type () const { return m_str; } - pstring_t &operator=(const pstring_t &string) = default; - pstring_t &operator=(pstring_t &&string) noexcept = default; template ::value>::type> diff --git a/src/lib/netlist/plib/ptypes.h b/src/lib/netlist/plib/ptypes.h index 07a48b03b93..5e0f8d49fe3 100644 --- a/src/lib/netlist/plib/ptypes.h +++ b/src/lib/netlist/plib/ptypes.h @@ -14,6 +14,16 @@ #include "pconfig.h" +#define COPYASSIGNMOVE(name, def) \ + name(const name &) = def; \ + name(name &&) noexcept = def; \ + name &operator=(const name &) = def; \ + name &operator=(name &&) noexcept = def; + +#define COPYASSIGN(name, def) \ + name(const name &) = def; \ + name &operator=(const name &) = def; \ + namespace plib { template struct is_integral : public std::is_integral { }; diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp index e9011b698a4..81ef785daee 100644 --- a/src/lib/netlist/prg/nltool.cpp +++ b/src/lib/netlist/prg/nltool.cpp @@ -172,8 +172,6 @@ public: { } - ~netlist_tool_t() = default; - void init() { } diff --git a/src/lib/netlist/prg/nlwav.cpp b/src/lib/netlist/prg/nlwav.cpp index d48294b6aa9..96cf9342058 100644 --- a/src/lib/netlist/prg/nlwav.cpp +++ b/src/lib/netlist/prg/nlwav.cpp @@ -34,6 +34,9 @@ public: write(m_fmt); write(m_data); } + + COPYASSIGNMOVE(wav_t, delete) + ~wav_t() { if (m_f.seekable()) diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h index a57ea029140..63be2d4892a 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.h +++ b/src/lib/netlist/solver/nld_matrix_solver.h @@ -114,7 +114,6 @@ public: : analog_output_t(dev, aname) , m_proxied_net(pnet) { } - ~proxied_analog_output_t() override = default; analog_net_t *proxied_net() const { return m_proxied_net;} private: @@ -136,8 +135,6 @@ public: PREFER_BAND_MATRIX }; - ~matrix_solver_t() override = default; - void setup(analog_net_t::list_t &nets) { vsetup(nets); diff --git a/src/lib/netlist/solver/nld_ms_direct.h b/src/lib/netlist/solver/nld_ms_direct.h index fe4a4e6aada..13f187f41b5 100644 --- a/src/lib/netlist/solver/nld_ms_direct.h +++ b/src/lib/netlist/solver/nld_ms_direct.h @@ -32,8 +32,6 @@ public: matrix_solver_direct_t(netlist_state_t &anetlist, const pstring &name, const solver_parameters_t *params, const std::size_t size); matrix_solver_direct_t(netlist_state_t &anetlist, const pstring &name, const eSortType sort, const solver_parameters_t *params, const std::size_t size); - ~matrix_solver_direct_t() override = default; - void vsetup(analog_net_t::list_t &nets) override; void reset() override { matrix_solver_t::reset(); } diff --git a/src/lib/netlist/solver/nld_ms_gcr.h b/src/lib/netlist/solver/nld_ms_gcr.h index 8c9d40e9618..8d1351435c8 100644 --- a/src/lib/netlist/solver/nld_ms_gcr.h +++ b/src/lib/netlist/solver/nld_ms_gcr.h @@ -44,8 +44,6 @@ public: { } - ~matrix_solver_GCR_t() override = default; - constexpr std::size_t N() const { return m_dim; } void vsetup(analog_net_t::list_t &nets) override; @@ -55,8 +53,7 @@ public: private: - //typedef typename mat_cr_t::type mattype; - typedef typename plib::matrix_compressed_rows_t::index_type mat_index_type; + using mat_index_type = typename plib::matrix_compressed_rows_t::index_type; void csc_private(plib::putf8_fmt_writer &strm); diff --git a/src/lib/netlist/solver/nld_ms_gmres.h b/src/lib/netlist/solver/nld_ms_gmres.h index 28087b6b0a5..3cd88dea429 100644 --- a/src/lib/netlist/solver/nld_ms_gmres.h +++ b/src/lib/netlist/solver/nld_ms_gmres.h @@ -44,8 +44,6 @@ namespace devices { } - ~matrix_solver_GMRES_t() override = default; - void vsetup(analog_net_t::list_t &nets) override; unsigned vsolve_non_dynamic(const bool newton_raphson) override; diff --git a/src/lib/netlist/solver/nld_ms_sm.h b/src/lib/netlist/solver/nld_ms_sm.h index 52546210cad..c473b6131e7 100644 --- a/src/lib/netlist/solver/nld_ms_sm.h +++ b/src/lib/netlist/solver/nld_ms_sm.h @@ -59,8 +59,6 @@ public: matrix_solver_sm_t(netlist_state_t &anetlist, const pstring &name, const solver_parameters_t *params, const std::size_t size); - ~matrix_solver_sm_t() override = default; - void vsetup(analog_net_t::list_t &nets) override; void reset() override { matrix_solver_t::reset(); } diff --git a/src/lib/netlist/solver/nld_ms_sor.h b/src/lib/netlist/solver/nld_ms_sor.h index dd2372dd48f..5261524cba1 100644 --- a/src/lib/netlist/solver/nld_ms_sor.h +++ b/src/lib/netlist/solver/nld_ms_sor.h @@ -39,8 +39,6 @@ public: { } - ~matrix_solver_SOR_t() override = default; - void vsetup(analog_net_t::list_t &nets) override; unsigned vsolve_non_dynamic(const bool newton_raphson) override; diff --git a/src/lib/netlist/solver/nld_ms_sor_mat.h b/src/lib/netlist/solver/nld_ms_sor_mat.h index 38ce84dfb93..0bb756c05f5 100644 --- a/src/lib/netlist/solver/nld_ms_sor_mat.h +++ b/src/lib/netlist/solver/nld_ms_sor_mat.h @@ -40,8 +40,6 @@ public: { } - ~matrix_solver_SOR_mat_t() override = default; - void vsetup(analog_net_t::list_t &nets) override; unsigned vsolve_non_dynamic(const bool newton_raphson) override; diff --git a/src/lib/netlist/solver/nld_ms_w.h b/src/lib/netlist/solver/nld_ms_w.h index cdfcaf3000f..e5935462f03 100644 --- a/src/lib/netlist/solver/nld_ms_w.h +++ b/src/lib/netlist/solver/nld_ms_w.h @@ -65,8 +65,6 @@ public: matrix_solver_w_t(netlist_state_t &anetlist, const pstring &name, const solver_parameters_t *params, const std::size_t size); - ~matrix_solver_w_t() override = default; - void vsetup(analog_net_t::list_t &nets) override; void reset() override { matrix_solver_t::reset(); } @@ -293,7 +291,7 @@ unsigned matrix_solver_w_t::solve_non_dynamic(const bool newton_raphso for (unsigned i = 0; i < rowcount; i++) { if (H[i][i] == 0.0) - printf("%s H singular\n", this->name().c_str()); + plib::perrlogger("{} H singular\n", this->name()); const float_type f = 1.0 / H[i][i]; for (unsigned j = i+1; j < rowcount; j++) { @@ -348,7 +346,7 @@ unsigned matrix_solver_w_t::solve_non_dynamic(const bool newton_raphso tmp += A(i,j) * new_V[j]; } if (std::abs(tmp-RHS(i)) > 1e-6) - printf("%s failed on row %d: %f RHS: %f\n", this->name().c_str(), i, std::abs(tmp-RHS(i)), RHS(i)); + plib::perrlogger("{} failed on row {}: {} RHS: {}\n", this->name(), i, std::abs(tmp-RHS(i)), RHS(i)); } const float_type err = (newton_raphson ? delta(new_V) : 0.0); diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp index 45643d88ea5..5d17056637a 100644 --- a/src/lib/netlist/solver/nld_solver.cpp +++ b/src/lib/netlist/solver/nld_solver.cpp @@ -33,6 +33,7 @@ #include #include // <<= needed by windows build +#include #include "../nl_lists.h" @@ -80,14 +81,6 @@ void NETLIB_NAME(solver)::stop() s->log_stats(); } -NETLIB_NAME(solver)::~NETLIB_NAME(solver)() -{ - for (auto &s : m_mat_solvers) - { - plib::pfree(s); - } -} - NETLIB_UPDATE(solver) { if (m_params.m_dynamic_ts) @@ -100,7 +93,7 @@ NETLIB_UPDATE(solver) std::size_t nthreads = std::min(static_cast(m_parallel()), plib::omp::get_max_threads()); - std::vector &solvers = (force_solve ? m_mat_solvers : m_mat_solvers_timestepping); + std::vector &solvers = (force_solve ? m_mat_solvers_all : m_mat_solvers_timestepping); if (nthreads > 1 && solvers.size() > 1) { @@ -129,13 +122,13 @@ NETLIB_UPDATE(solver) } template -matrix_solver_t * create_it(netlist_state_t &nl, pstring name, solver_parameters_t ¶ms, std::size_t size) +std::unique_ptr create_it(netlist_state_t &nl, pstring name, solver_parameters_t ¶ms, std::size_t size) { - return plib::palloc(nl, name, ¶ms, size); + return plib::make_unique(nl, name, ¶ms, size); } template -matrix_solver_t * NETLIB_NAME(solver)::create_solver(std::size_t size, const pstring &solvername) +std::unique_ptr NETLIB_NAME(solver)::create_solver(std::size_t size, const pstring &solvername) { if (m_method() == "SOR_MAT") { @@ -283,7 +276,7 @@ void NETLIB_NAME(solver)::post_start() log().verbose("Found {1} net groups in {2} nets\n", splitter.groups.size(), state().nets().size()); for (auto & grp : splitter.groups) { - matrix_solver_t *ms; + std::unique_ptr ms; std::size_t net_count = grp.size(); pstring sname = plib::pfmt("Solver_{1}")(m_mat_solvers.size()); @@ -292,13 +285,13 @@ void NETLIB_NAME(solver)::post_start() #if 1 case 1: if (use_specific) - ms = plib::palloc>(state(), sname, &m_params); + ms = plib::make_unique>(state(), sname, &m_params); else ms = create_solver(1, sname); break; case 2: if (use_specific) - ms = plib::palloc>(state(), sname, &m_params); + ms = plib::make_unique>(state(), sname, &m_params); else ms = create_solver(2, sname); break; @@ -403,9 +396,11 @@ void NETLIB_NAME(solver)::post_start() } } - m_mat_solvers.push_back(ms); + m_mat_solvers_all.push_back(ms.get()); if (ms->has_timestep_devices()) - m_mat_solvers_timestepping.push_back(ms); + m_mat_solvers_timestepping.push_back(ms.get()); + + m_mat_solvers.emplace_back(std::move(ms)); } } diff --git a/src/lib/netlist/solver/nld_solver.h b/src/lib/netlist/solver/nld_solver.h index f9156c4441f..4bc4aea3d60 100644 --- a/src/lib/netlist/solver/nld_solver.h +++ b/src/lib/netlist/solver/nld_solver.h @@ -9,6 +9,8 @@ #define NLD_SOLVER_H_ #include +#include +#include #include "../nl_base.h" #include "../plib/pstream.h" @@ -63,8 +65,6 @@ NETLIB_OBJECT(solver) connect(m_fb_step, m_Q_step); } - ~NETLIB_NAME(solver)() override; - void post_start(); void stop(); @@ -97,13 +97,14 @@ protected: param_logic_t m_log_stats; private: - std::vector m_mat_solvers; + std::vector> m_mat_solvers; + std::vector m_mat_solvers_all; std::vector m_mat_solvers_timestepping; solver_parameters_t m_params; template - matrix_solver_t * create_solver(std::size_t size, const pstring &solvername); + std::unique_ptr create_solver(std::size_t size, const pstring &solvername); }; } //namespace devices diff --git a/src/lib/netlist/tools/nl_convert.cpp b/src/lib/netlist/tools/nl_convert.cpp index fccab6e6df2..68880e379a3 100644 --- a/src/lib/netlist/tools/nl_convert.cpp +++ b/src/lib/netlist/tools/nl_convert.cpp @@ -201,7 +201,7 @@ double nl_convert_base_t::get_sp_unit(const pstring &unit) return m_units[i].m_mult; i++; } - fprintf(stderr, "Unit %s unknown\n", unit.c_str()); + plib::perrlogger("Unit {} unknown\n", unit); return 0.0; } @@ -250,10 +250,10 @@ void nl_convert_spice_t::convert(const pstring &contents) pstring line = ""; - for (std::size_t i=0; i < spnl.size(); i++) + for (const auto &i : spnl) { // Basic preprocessing - pstring inl = plib::ucase(plib::trim(spnl[i])); + pstring inl = plib::ucase(plib::trim(i)); if (plib::startsWith(inl, "+")) line = line + inl.substr(1); else @@ -316,7 +316,7 @@ void nl_convert_spice_t::process_line(const pstring &line) if (m.size() == 2) { if (m[1].length() != 4) - fprintf(stderr, "error with model desc %s\n", model.c_str()); + plib::perrlogger("error with model desc {}\n", model); pins = plib::left(m[1], 3); } add_device("QBJT_EB", tt[0], m[0]); @@ -358,7 +358,7 @@ void nl_convert_spice_t::process_line(const pstring &line) //add_term(tt[2], tt[0] + ".2"); } else - fprintf(stderr, "Voltage Source %s not connected to GND\n", tt[0].c_str()); + plib::perrlogger("Voltage Source {} not connected to GND\n", tt[0]); break; case 'I': // Input pin special notation { diff --git a/src/lib/netlist/tools/nl_convert.h b/src/lib/netlist/tools/nl_convert.h index 366249343c9..2c7393bc82e 100644 --- a/src/lib/netlist/tools/nl_convert.h +++ b/src/lib/netlist/tools/nl_convert.h @@ -10,6 +10,7 @@ #ifndef NL_CONVERT_H_ #define NL_CONVERT_H_ +#include "../plib/ptypes.h" #include "../plib/plists.h" #include "../plib/pparser.h" #include "../plib/pstring.h" @@ -23,6 +24,8 @@ class nl_convert_base_t { public: + COPYASSIGNMOVE(nl_convert_base_t, delete) + virtual ~nl_convert_base_t(); const pstring &result() { return m_buf.str(); } @@ -140,7 +143,6 @@ class nl_convert_spice_t : public nl_convert_base_t public: nl_convert_spice_t() : nl_convert_base_t() {} - ~nl_convert_spice_t() override = default; void convert(const pstring &contents) override; @@ -157,7 +159,6 @@ class nl_convert_eagle_t : public nl_convert_base_t public: nl_convert_eagle_t() : nl_convert_base_t() {} - ~nl_convert_eagle_t() override = default; class tokenizer : public plib::ptokenizer { @@ -191,7 +192,6 @@ class nl_convert_rinf_t : public nl_convert_base_t public: nl_convert_rinf_t() : nl_convert_base_t() {} - ~nl_convert_rinf_t() override = default; class tokenizer : public plib::ptokenizer { -- cgit v1.2.3-70-g09d2 From 66154af0f202bc373cde7e2f5af014e067558b94 Mon Sep 17 00:00:00 2001 From: couriersud Date: Fri, 22 Feb 2019 21:46:43 +0100 Subject: netlist: fix visibility issues and more issues reported by tidy. (nw) --- src/lib/netlist/analog/nld_bjt.cpp | 6 +-- src/lib/netlist/analog/nlid_fourterm.h | 8 ++-- src/lib/netlist/analog/nlid_twoterm.cpp | 2 +- src/lib/netlist/analog/nlid_twoterm.h | 12 ++--- src/lib/netlist/build/makefile | 6 +-- src/lib/netlist/devices/nld_4066.cpp | 2 +- src/lib/netlist/devices/nld_7493.cpp | 8 ++-- src/lib/netlist/devices/nld_legacy.cpp | 4 +- src/lib/netlist/devices/nlid_proxy.h | 2 - src/lib/netlist/devices/nlid_system.h | 21 ++++----- src/lib/netlist/nl_base.cpp | 2 +- src/lib/netlist/nl_base.h | 67 ++++++++++++++-------------- src/lib/netlist/nl_lists.h | 13 +++--- src/lib/netlist/nl_setup.cpp | 14 +++--- src/lib/netlist/nl_setup.h | 4 +- src/lib/netlist/plib/palloc.h | 25 +++++++++-- src/lib/netlist/plib/parray.h | 2 +- src/lib/netlist/plib/pconfig.h | 2 +- src/lib/netlist/plib/pdynlib.cpp | 6 +-- src/lib/netlist/plib/pdynlib.h | 8 ++-- src/lib/netlist/plib/pexception.cpp | 2 +- src/lib/netlist/plib/pexception.h | 2 +- src/lib/netlist/plib/pfmtlog.cpp | 6 ++- src/lib/netlist/plib/pfunction.cpp | 2 +- src/lib/netlist/plib/plists.h | 3 +- src/lib/netlist/plib/pmempool.h | 8 ++-- src/lib/netlist/plib/poptions.cpp | 12 ++--- src/lib/netlist/plib/poptions.h | 32 ++++++------- src/lib/netlist/plib/pparser.h | 10 ++--- src/lib/netlist/plib/ppmf.h | 1 + src/lib/netlist/plib/pstate.h | 2 +- src/lib/netlist/plib/pstream.h | 3 +- src/lib/netlist/plib/pstring.h | 7 ++- src/lib/netlist/plib/vector_ops.h | 11 +++-- src/lib/netlist/prg/nltool.cpp | 4 +- src/lib/netlist/prg/nlwav.cpp | 24 +++++----- src/lib/netlist/solver/nld_matrix_solver.cpp | 12 ++--- src/lib/netlist/solver/nld_solver.cpp | 4 +- src/lib/netlist/solver/nld_solver.h | 3 +- src/lib/netlist/tools/nl_convert.cpp | 2 +- src/lib/netlist/tools/nl_convert.h | 2 +- 41 files changed, 192 insertions(+), 174 deletions(-) (limited to 'src/lib/netlist/plib/pdynlib.h') diff --git a/src/lib/netlist/analog/nld_bjt.cpp b/src/lib/netlist/analog/nld_bjt.cpp index 7f8e57a8511..fb8aeafda1c 100644 --- a/src/lib/netlist/analog/nld_bjt.cpp +++ b/src/lib/netlist/analog/nld_bjt.cpp @@ -209,6 +209,7 @@ NETLIB_OBJECT_DERIVED(QBJT_switch, QBJT) NETLIB_UPDATE_PARAMI(); NETLIB_UPDATE_TERMINALSI(); +private: nld_twoterm m_RB; nld_twoterm m_RC; @@ -216,9 +217,6 @@ NETLIB_OBJECT_DERIVED(QBJT_switch, QBJT) nld_twoterm m_BC_dummy; -protected: - - nl_double m_gB; // base conductance / switch on nl_double m_gC; // collector conductance / switch on nl_double m_V; // internal voltage source @@ -261,10 +259,10 @@ protected: NETLIB_UPDATE_PARAMI(); NETLIB_UPDATE_TERMINALSI(); +private: generic_diode m_gD_BC; generic_diode m_gD_BE; -private: nld_twoterm m_D_CB; // gcc, gce - gcc, gec - gcc, gcc - gce | Ic nld_twoterm m_D_EB; // gee, gec - gee, gce - gee, gee - gec | Ie nld_twoterm m_D_EC; // 0, -gec, -gcc, 0 | 0 diff --git a/src/lib/netlist/analog/nlid_fourterm.h b/src/lib/netlist/analog/nlid_fourterm.h index 46ee7d6e54a..2d0d1ec174f 100644 --- a/src/lib/netlist/analog/nlid_fourterm.h +++ b/src/lib/netlist/analog/nlid_fourterm.h @@ -66,6 +66,7 @@ namespace netlist { NETLIB_NAME(VCCS)::reset(); } + terminal_t m_OP; terminal_t m_ON; @@ -91,14 +92,14 @@ namespace netlist { NETLIB_IS_DYNAMIC(true) - param_double_t m_cur_limit; /* current limit */ - protected: //NETLIB_UPDATEI(); NETLIB_RESETI(); NETLIB_UPDATE_PARAMI(); NETLIB_UPDATE_TERMINALSI(); + private: + param_double_t m_cur_limit; /* current limit */ nl_double m_vi; }; @@ -185,13 +186,14 @@ namespace netlist { param_double_t m_RO; - protected: + private: //NETLIB_UPDATEI(); //NETLIB_UPDATE_PARAMI(); terminal_t m_OP2; terminal_t m_ON2; + }; } // namespace analog diff --git a/src/lib/netlist/analog/nlid_twoterm.cpp b/src/lib/netlist/analog/nlid_twoterm.cpp index 84cf5ed7b53..832b343ac15 100644 --- a/src/lib/netlist/analog/nlid_twoterm.cpp +++ b/src/lib/netlist/analog/nlid_twoterm.cpp @@ -20,7 +20,7 @@ namespace netlist // generic_diode // ---------------------------------------------------------------------------------------- -generic_diode::generic_diode(device_t &dev, pstring name) +generic_diode::generic_diode(device_t &dev, const pstring &name) : m_Vd(dev, name + ".m_Vd", 0.7) , m_Id(dev, name + ".m_Id", 0.0) , m_G(dev, name + ".m_G", 1e-15) diff --git a/src/lib/netlist/analog/nlid_twoterm.h b/src/lib/netlist/analog/nlid_twoterm.h index 65451a03c6c..546e8193734 100644 --- a/src/lib/netlist/analog/nlid_twoterm.h +++ b/src/lib/netlist/analog/nlid_twoterm.h @@ -141,7 +141,6 @@ NETLIB_OBJECT_DERIVED(R, R_base) { } - param_double_t m_R; protected: @@ -150,6 +149,7 @@ protected: NETLIB_UPDATE_PARAMI(); private: + param_double_t m_R; /* protect set_R ... it's a recipe to desaster when used to bypass the parameter */ using NETLIB_NAME(R_base)::set_R; }; @@ -267,13 +267,13 @@ public: NETLIB_TIMESTEPI(); NETLIB_RESETI(); - param_double_t m_L; - protected: //NETLIB_UPDATEI(); NETLIB_UPDATE_PARAMI(); private: + param_double_t m_L; + nl_double m_GParallel; nl_double m_G; nl_double m_I; @@ -286,7 +286,7 @@ private: class generic_diode { public: - generic_diode(device_t &dev, pstring name); + generic_diode(device_t &dev, const pstring &name); void update_diode(const double nVd); @@ -383,12 +383,12 @@ public: NETLIB_UPDATE_TERMINALSI(); NETLIB_RESETI(); - diode_model_t m_model; - protected: //NETLIB_UPDATEI(); NETLIB_UPDATE_PARAMI(); +private: + diode_model_t m_model; generic_diode m_D; }; diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile index 289f7a906a2..40d75f32fd8 100644 --- a/src/lib/netlist/build/makefile +++ b/src/lib/netlist/build/makefile @@ -21,12 +21,12 @@ TIDY_FLAGSX += -modernize-use-default-member-init,-cppcoreguidelines-pro-bounds- TIDY_FLAGSX += -modernize-pass-by-value,-cppcoreguidelines-pro-type-static-cast-downcast, #TIDY_FLAGSX += -cppcoreguidelines-special-member-functions, #TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-array-to-pointer-decay, -TIDY_FLAGSX += -performance-unnecessary-value-param,-cppcoreguidelines-avoid-magic-numbers, +TIDY_FLAGSX += performance-unnecessary-value-param,-cppcoreguidelines-avoid-magic-numbers, TIDY_FLAGSX += -cppcoreguidelines-macro-usage, -TIDY_FLAGSX += -cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes, +TIDY_FLAGSX += cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes, #TIDY_FLAGSX += -cppcoreguidelines-avoid-c-arrays,-modernize-avoid-c-arrays, #TIDY_FLAGSX += -modernize-use-using, -TIDY_FLAGSX += -performance-unnecessary-copy-initialization, +TIDY_FLAGSX += performance-unnecessary-copy-initialization, TIDY_FLAGSX += -bugprone-macro-parentheses,-misc-macro-parentheses space := diff --git a/src/lib/netlist/devices/nld_4066.cpp b/src/lib/netlist/devices/nld_4066.cpp index 9b7672e00c2..0c7511ca438 100644 --- a/src/lib/netlist/devices/nld_4066.cpp +++ b/src/lib/netlist/devices/nld_4066.cpp @@ -29,7 +29,7 @@ namespace netlist NETLIB_RESETI(); NETLIB_UPDATEI(); - public: + private: NETLIB_SUB(vdd_vss) m_supply; analog::NETLIB_SUB(R_base) m_R; diff --git a/src/lib/netlist/devices/nld_7493.cpp b/src/lib/netlist/devices/nld_7493.cpp index 261fe4ff927..f9eca065dc6 100644 --- a/src/lib/netlist/devices/nld_7493.cpp +++ b/src/lib/netlist/devices/nld_7493.cpp @@ -119,10 +119,10 @@ namespace netlist { m_CLKA.inactivate(); m_CLKB.inactivate(); - m_QA.push_force(0, NLTIME_FROM_NS(40)); - m_QB.push_force(0, NLTIME_FROM_NS(40)); - m_QC.push_force(0, NLTIME_FROM_NS(40)); - m_QD.push_force(0, NLTIME_FROM_NS(40)); + m_QA.push(0, NLTIME_FROM_NS(40)); + m_QB.push(0, NLTIME_FROM_NS(40)); + m_QC.push(0, NLTIME_FROM_NS(40)); + m_QD.push(0, NLTIME_FROM_NS(40)); m_a = m_bcd = 0; } } diff --git a/src/lib/netlist/devices/nld_legacy.cpp b/src/lib/netlist/devices/nld_legacy.cpp index df0bbc111cb..ed695a91417 100644 --- a/src/lib/netlist/devices/nld_legacy.cpp +++ b/src/lib/netlist/devices/nld_legacy.cpp @@ -25,7 +25,7 @@ namespace netlist NETLIB_RESETI(); NETLIB_UPDATEI(); - protected: + private: logic_input_t m_S; logic_input_t m_R; @@ -49,7 +49,7 @@ namespace netlist NETLIB_RESETI(); NETLIB_UPDATEI(); - protected: + private: logic_input_t m_I; logic_output_t m_Q; diff --git a/src/lib/netlist/devices/nlid_proxy.h b/src/lib/netlist/devices/nlid_proxy.h index 09a5da48c25..a6967a87a9f 100644 --- a/src/lib/netlist/devices/nlid_proxy.h +++ b/src/lib/netlist/devices/nlid_proxy.h @@ -90,8 +90,6 @@ namespace netlist logic_output_t *out_proxied, detail::core_terminal_t &proxy_out); logic_input_t m_I; - - private: }; NETLIB_OBJECT_DERIVED(d_to_a_proxy, base_d_to_a_proxy) diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index e58b15ed03b..02e8453c6e7 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -72,9 +72,9 @@ namespace netlist public: logic_output_t m_Q; - - param_double_t m_freq; netlist_time m_inc; + private: + param_double_t m_freq; }; // ----------------------------------------------------------------------------- @@ -96,7 +96,7 @@ namespace netlist //NETLIB_RESETI(); NETLIB_UPDATE_PARAMI(); - protected: + private: logic_input_t m_feedback; logic_output_t m_Q; @@ -154,7 +154,7 @@ namespace netlist NETLIB_HANDLERI(clk2); NETLIB_HANDLERI(clk2_pow2); - protected: + private: param_double_t m_freq; param_str_t m_pattern; @@ -187,7 +187,7 @@ namespace netlist NETLIB_RESETI() { m_Q.initial(0); } NETLIB_UPDATE_PARAMI() { m_Q.push(m_IN() & 1, netlist_time::from_nsec(1)); } - protected: + private: logic_output_t m_Q; param_logic_t m_IN; @@ -206,7 +206,7 @@ namespace netlist NETLIB_RESETI() { m_Q.initial(0.0); } NETLIB_UPDATE_PARAMI() { m_Q.push(m_IN()); } - protected: + private: analog_output_t m_Q; param_double_t m_IN; }; @@ -358,16 +358,17 @@ namespace netlist register_subalias("2", m_R.m_N); } + NETLIB_RESETI(); + //NETLIB_UPDATE_PARAMI(); + NETLIB_UPDATEI(); + analog::NETLIB_SUB(R_base) m_R; logic_input_t m_I; param_double_t m_RON; param_double_t m_ROFF; - NETLIB_RESETI(); - //NETLIB_UPDATE_PARAMI(); - NETLIB_UPDATEI(); - private: + state_var m_last_state; }; diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index 3d6a8cf04b0..8ba7ad7b5f8 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -361,7 +361,7 @@ void netlist_state_t::reset() std::vector t; log().verbose("Using default startup strategy"); for (auto &n : m_nets) - for (auto & term : n->m_core_terms) + for (auto & term : n->core_terms()) if (term->m_delegate.has_object()) { if (!plib::container::contains(t, &term->m_delegate)) diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 7f65a33e6bf..dccfb32f896 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -773,7 +773,7 @@ namespace netlist void rebuild_list(); /* rebuild m_list after a load */ void move_connections(net_t &dest_net); - std::vector m_core_terms; // save post-start m_list ... + std::vector &core_terms() { return m_core_terms; } #if USE_COPY_INSTEAD_OF_REFERENCE void update_inputs() { @@ -786,34 +786,20 @@ namespace netlist /* nothing needs to be done */ } #endif - protected: - state_var m_new_Q; - state_var m_cur_Q; - state_var m_in_queue; /* 0: not in queue, 1: in queue, 2: last was taken */ - - state_var m_next_scheduled_time; - - private: - plib::linkedlist_t m_list_active; - core_terminal_t * m_railterminal; - - template - void process(const T mask, netlist_sig_t sig); - }; - class logic_net_t : public detail::net_t - { - public: - - logic_net_t(netlist_state_t &nl, const pstring &aname, detail::core_terminal_t *mr = nullptr); + protected: + /* only used for logic nets */ netlist_sig_t Q() const noexcept { return m_cur_Q; } + + /* only used for logic nets */ void initial(const netlist_sig_t val) noexcept { m_cur_Q = m_new_Q = val; update_inputs(); } + /* only used for logic nets */ void set_Q_and_push(const netlist_sig_t newQ, const netlist_time delay) NL_NOEXCEPT { if (newQ != m_new_Q) @@ -822,15 +808,8 @@ namespace netlist push_to_queue(delay); } } - void set_Q_and_push_force(const netlist_sig_t newQ, const netlist_time delay) NL_NOEXCEPT - { - if (newQ != m_new_Q || is_queued()) - { - m_new_Q = newQ; - push_to_queue(delay); - } - } + /* only used for logic nets */ void set_Q_time(const netlist_sig_t newQ, const netlist_time at) NL_NOEXCEPT { if (newQ != m_new_Q) @@ -845,10 +824,34 @@ namespace netlist /* internal state support * FIXME: get rid of this and implement export/import in MAME */ + /* only used for logic nets */ netlist_sig_t *Q_state_ptr() { return m_cur_Q.ptr(); } - protected: private: + state_var m_new_Q; + state_var m_cur_Q; + state_var m_in_queue; /* 0: not in queue, 1: in queue, 2: last was taken */ + state_var m_next_scheduled_time; + + core_terminal_t * m_railterminal; + plib::linkedlist_t m_list_active; + std::vector m_core_terms; // save post-start m_list ... + + template + void process(const T mask, netlist_sig_t sig); + }; + + class logic_net_t : public detail::net_t + { + public: + + logic_net_t(netlist_state_t &nl, const pstring &aname, detail::core_terminal_t *mr = nullptr); + + using detail::net_t::Q; + using detail::net_t::initial; + using detail::net_t::set_Q_and_push; + using detail::net_t::set_Q_time; + using detail::net_t::Q_state_ptr; }; @@ -892,11 +895,6 @@ namespace netlist m_my_net.set_Q_and_push(newQ, delay); // take the shortcut } - void push_force(const netlist_sig_t newQ, const netlist_time delay) NL_NOEXCEPT - { - m_my_net.set_Q_and_push_force(newQ, delay); // take the shortcut - } - void set_Q_time(const netlist_sig_t newQ, const netlist_time at) NL_NOEXCEPT { m_my_net.set_Q_time(newQ, at); // take the shortcut @@ -1462,6 +1460,7 @@ namespace netlist netlist_time m_time; devices::NETLIB_NAME(mainclock) * m_mainclock; + PALIGNAS_CACHELINE() detail::queue_t m_queue; // performance diff --git a/src/lib/netlist/nl_lists.h b/src/lib/netlist/nl_lists.h index 39f4343be30..5443cd86c86 100644 --- a/src/lib/netlist/nl_lists.h +++ b/src/lib/netlist/nl_lists.h @@ -54,6 +54,7 @@ namespace netlist { constexpr pqentry_t() noexcept : m_exec_time(), m_object(nullptr) { } constexpr pqentry_t(const Time t, const Element o) noexcept : m_exec_time(t), m_object(o) { } +#if 0 ~pqentry_t() = default; constexpr pqentry_t(const pqentry_t &e) noexcept = default; constexpr pqentry_t(pqentry_t &&e) noexcept = default; @@ -65,7 +66,7 @@ namespace netlist std::swap(m_exec_time, other.m_exec_time); std::swap(m_object, other.m_object); } - +#endif struct QueueOp { inline static constexpr bool less(const pqentry_t &lhs, const pqentry_t &rhs) noexcept @@ -110,7 +111,7 @@ namespace netlist std::size_t capacity() const noexcept { return m_list.capacity() - 1; } bool empty() const noexcept { return (m_end == &m_list[1]); } - void push(T e) noexcept + void push(T && e) noexcept { /* Lock */ lock_guard_type lck(m_lock); @@ -120,7 +121,7 @@ namespace netlist *(i+1) = *(i); m_prof_sortmove.inc(); } - *(i+1) = e; + *(i+1) = std::move(e); ++m_end; m_prof_call.inc(); } @@ -129,7 +130,7 @@ namespace netlist const T &top() const noexcept { return *(m_end-1); } template - void remove(const R elem) noexcept + void remove(const R &elem) noexcept { /* Lock */ lock_guard_type lck(m_lock); @@ -145,7 +146,7 @@ namespace netlist } } - void retime(T elem) noexcept + void retime(T && elem) noexcept { /* Lock */ lock_guard_type lck(m_lock); @@ -155,7 +156,7 @@ namespace netlist { if (QueueOp::equal(*i, elem)) // partial equal! { - *i = elem; + *i = std::move(elem); while (QueueOp::less(*(i-1), *i)) { std::swap(*(i-1), *i); diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp index b892fb4571c..3ac1b604bc4 100644 --- a/src/lib/netlist/nl_setup.cpp +++ b/src/lib/netlist/nl_setup.cpp @@ -462,14 +462,14 @@ devices::nld_base_proxy *setup_t::get_d_a_proxy(detail::core_terminal_t &out) m_proxy_cnt++; /* connect all existing terminals to new net */ - for (auto & p : out.net().m_core_terms) + for (auto & p : out.net().core_terms()) { p->clear_net(); // de-link from all nets ... if (!connect(new_proxy->proxy_term(), *p)) log().fatal(MF_2_CONNECTING_1_TO_2, new_proxy->proxy_term().name(), (*p).name()); } - out.net().m_core_terms.clear(); // clear the list + out.net().core_terms().clear(); // clear the list out.net().add_terminal(new_proxy->in()); out_cast.set_proxy(proxy); @@ -505,14 +505,14 @@ devices::nld_base_proxy *setup_t::get_a_d_proxy(detail::core_terminal_t &inp) if (inp.has_net()) { - for (auto & p : inp.net().m_core_terms) + for (auto & p : inp.net().core_terms()) { p->clear_net(); // de-link from all nets ... if (!connect(ret->proxy_term(), *p)) log().fatal(MF_2_CONNECTING_1_TO_2, ret->proxy_term().name(), (*p).name()); } - inp.net().m_core_terms.clear(); // clear the list + inp.net().core_terms().clear(); // clear the list } ret->out().net().add_terminal(inp); m_netlist.nlstate().add_dev(new_proxy->name(), std::move(new_proxy)); @@ -667,7 +667,7 @@ bool setup_t::connect_input_input(detail::core_terminal_t &t1, detail::core_term ret = connect(t2, t1.net().railterminal()); if (!ret) { - for (auto & t : t1.net().m_core_terms) + for (auto & t : t1.net().core_terms()) { if (t->is_type(detail::terminal_type::TERMINAL)) ret = connect(t2, *t); @@ -682,7 +682,7 @@ bool setup_t::connect_input_input(detail::core_terminal_t &t1, detail::core_term ret = connect(t1, t2.net().railterminal()); if (!ret) { - for (auto & t : t2.net().m_core_terms) + for (auto & t : t2.net().core_terms()) { if (t->is_type(detail::terminal_type::TERMINAL)) ret = connect(t1, *t); @@ -1123,7 +1123,7 @@ void setup_t::prepare_to_run() solver->post_start(); for (auto &n : netlist().nets()) - for (auto & term : n->m_core_terms) + for (auto & term : n->core_terms()) { //core_device_t *dev = reinterpret_cast(term->m_delegate.object()); core_device_t *dev = &term->device(); diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h index 5e445fc6a32..50536d9da3b 100644 --- a/src/lib/netlist/nl_setup.h +++ b/src/lib/netlist/nl_setup.h @@ -253,7 +253,7 @@ namespace netlist /* FIXME: used by source_t - need a different approach at some time */ bool parse_stream(plib::unique_ptr &&istrm, const pstring &name); - void add_define(pstring def, pstring val) + void add_define(const pstring &def, const pstring &val) { m_defines.insert({ def, plib::ppreprocessor::define_t(def, val)}); } @@ -444,7 +444,7 @@ namespace netlist class source_proc_t : public source_t { public: - source_proc_t(pstring name, void (*setup_func)(nlparse_t &)) + source_proc_t(const pstring &name, void (*setup_func)(nlparse_t &)) : source_t(), m_setup_func(setup_func), m_setup_func_name(name) diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h index 45c19ef7b3a..6380a4cef07 100644 --- a/src/lib/netlist/plib/palloc.h +++ b/src/lib/netlist/plib/palloc.h @@ -40,18 +40,26 @@ namespace plib { } return p; #else - return aligned_alloc(alignment, size); + return aligned_alloc(alignment, size); #endif } static inline void pfree( void *ptr ) { + // NOLINTNEXTLINE(cppcoreguidelines-no-malloc) free(ptr); } + static constexpr bool is_pow2(std::size_t v) noexcept { return !(v & (v-1)); } + template inline C14CONSTEXPR T *assume_aligned_ptr(T *p) noexcept { + static_assert(ALIGN >= alignof(T), "Alignment must be greater or equal to alignof(T)"); + static_assert(is_pow2(ALIGN), "Alignment must be a power of 2"); + //auto t = reinterpret_cast(p); + //if (t & (ALIGN-1)) + // printf("alignment error!"); return reinterpret_cast(__builtin_assume_aligned(p, ALIGN)); } @@ -246,10 +254,14 @@ namespace plib { static_assert(ALIGN >= alignof(T) && (ALIGN % alignof(T)) == 0, "ALIGN must be greater than alignof(T) and a multiple"); - aligned_allocator() = default; + aligned_allocator() noexcept = default; + ~aligned_allocator() noexcept = default; + + aligned_allocator(const aligned_allocator&) noexcept = default; + aligned_allocator& operator=(const aligned_allocator&) noexcept = delete; - aligned_allocator(const aligned_allocator&) = default; - aligned_allocator& operator=(const aligned_allocator&) = delete; + aligned_allocator(aligned_allocator&&) noexcept = default; + aligned_allocator& operator=(aligned_allocator&&) = delete; template aligned_allocator(const aligned_allocator& rhs) noexcept @@ -308,6 +320,8 @@ namespace plib { using reference = typename base::reference; using const_reference = typename base::const_reference; + using pointer = typename base::pointer; + using const_pointer = typename base::const_pointer; using size_type = typename base::size_type; using base::base; @@ -321,6 +335,9 @@ namespace plib { return assume_aligned_ptr(this->data())[i]; } + pointer data() noexcept { return assume_aligned_ptr(base::data()); } + const_pointer data() const noexcept { return assume_aligned_ptr(base::data()); } + }; diff --git a/src/lib/netlist/plib/parray.h b/src/lib/netlist/plib/parray.h index e09639163f0..9fe4ab972eb 100644 --- a/src/lib/netlist/plib/parray.h +++ b/src/lib/netlist/plib/parray.h @@ -8,9 +8,9 @@ #ifndef PARRAY_H_ #define PARRAY_H_ +#include "palloc.h" #include "pconfig.h" #include "pexception.h" -#include "palloc.h" #include #include diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h index 9f61fc0b01f..9754643678a 100644 --- a/src/lib/netlist/plib/pconfig.h +++ b/src/lib/netlist/plib/pconfig.h @@ -46,7 +46,7 @@ */ #define PALIGN_CACHELINE (64) -#define PALIGN_VECTOROPT (16) +#define PALIGN_VECTOROPT (32) #define PALIGNAS_CACHELINE() PALIGNAS(PALIGN_CACHELINE) #define PALIGNAS_VECTOROPT() PALIGNAS(PALIGN_VECTOROPT) diff --git a/src/lib/netlist/plib/pdynlib.cpp b/src/lib/netlist/plib/pdynlib.cpp index c0c89de208d..91e1b5cf73a 100644 --- a/src/lib/netlist/plib/pdynlib.cpp +++ b/src/lib/netlist/plib/pdynlib.cpp @@ -58,7 +58,7 @@ WCHAR *wstring_from_utf8(const char *utf8string) #endif namespace plib { -dynlib::dynlib(const pstring libname) +dynlib::dynlib(const pstring &libname) : m_isLoaded(false), m_lib(nullptr) { #ifdef _WIN32 @@ -88,7 +88,7 @@ dynlib::dynlib(const pstring libname) #endif } -dynlib::dynlib(const pstring path, const pstring libname) +dynlib::dynlib(const pstring &path, const pstring &libname) : m_isLoaded(false), m_lib(nullptr) { // FIXME: implement path search @@ -141,7 +141,7 @@ bool dynlib::isLoaded() const return m_isLoaded; } -void *dynlib::getsym_p(const pstring name) +void *dynlib::getsym_p(const pstring &name) { #ifdef _WIN32 return (void *) GetProcAddress((HMODULE) m_lib, name.c_str()); diff --git a/src/lib/netlist/plib/pdynlib.h b/src/lib/netlist/plib/pdynlib.h index fe9db58d6f2..1454c053298 100644 --- a/src/lib/netlist/plib/pdynlib.h +++ b/src/lib/netlist/plib/pdynlib.h @@ -18,8 +18,8 @@ namespace plib { class dynlib : public nocopyassignmove { public: - explicit dynlib(const pstring libname); - dynlib(const pstring path, const pstring libname); + explicit dynlib(const pstring &libname); + dynlib(const pstring &path, const pstring &libname); ~dynlib(); COPYASSIGNMOVE(dynlib, delete) @@ -27,12 +27,12 @@ public: bool isLoaded() const; template - T getsym(const pstring name) + T getsym(const pstring &name) { return reinterpret_cast(getsym_p(name)); } private: - void *getsym_p(const pstring name); + void *getsym_p(const pstring &name); bool m_isLoaded; void *m_lib; diff --git a/src/lib/netlist/plib/pexception.cpp b/src/lib/netlist/plib/pexception.cpp index 93f1c24c08c..8d6907d66f2 100644 --- a/src/lib/netlist/plib/pexception.cpp +++ b/src/lib/netlist/plib/pexception.cpp @@ -23,7 +23,7 @@ namespace plib { // terminate //============================================================ - void terminate(pstring msg) noexcept + void terminate(const pstring &msg) noexcept { std::cerr << msg.c_str() << "\n"; std::terminate(); diff --git a/src/lib/netlist/plib/pexception.h b/src/lib/netlist/plib/pexception.h index 98d993d689b..44daf53d591 100644 --- a/src/lib/netlist/plib/pexception.h +++ b/src/lib/netlist/plib/pexception.h @@ -23,7 +23,7 @@ namespace plib { * * \note could be enhanced by setting a termination handler */ - [[noreturn]] void terminate(pstring msg) noexcept; + [[noreturn]] void terminate(const pstring &msg) noexcept; //============================================================ // exception base diff --git a/src/lib/netlist/plib/pfmtlog.cpp b/src/lib/netlist/plib/pfmtlog.cpp index e4e7c3d1c5c..0d911800247 100644 --- a/src/lib/netlist/plib/pfmtlog.cpp +++ b/src/lib/netlist/plib/pfmtlog.cpp @@ -9,13 +9,13 @@ #include "palloc.h" #include +#include #include -#include #include +#include #include #include #include -#include namespace plib { @@ -28,6 +28,8 @@ pfmt &pfmt::format_element(const char *l, const unsigned cfmt_spec, ...) std::array buf; std::size_t sl; + buf[0] = 0; + m_arg++; pstring search("{"); diff --git a/src/lib/netlist/plib/pfunction.cpp b/src/lib/netlist/plib/pfunction.cpp index c6a6287a8aa..6a2179e0e6f 100644 --- a/src/lib/netlist/plib/pfunction.cpp +++ b/src/lib/netlist/plib/pfunction.cpp @@ -84,7 +84,7 @@ void pfunction::compile_postfix(const std::vector &inputs, throw plib::pexception(plib::pfmt("nld_function: stack count different to one on <{2}>")(expr)); } -static int get_prio(pstring v) +static int get_prio(const pstring &v) { if (v == "(" || v == ")") return 1; diff --git a/src/lib/netlist/plib/plists.h b/src/lib/netlist/plib/plists.h index c11ee6fabdc..0a1345d5e1f 100644 --- a/src/lib/netlist/plib/plists.h +++ b/src/lib/netlist/plib/plists.h @@ -205,7 +205,8 @@ public: iter_t& operator=(const iter_t &rhs) { iter_t t(rhs); std::swap(*this, t); return *this; } iter_t& operator=(iter_t &&rhs) noexcept { std::swap(*this, rhs); return *this; } iter_t& operator++() noexcept {p = p->next();return *this;} - iter_t operator++(int) noexcept {const iter_t tmp(*this); operator++(); return tmp;} + // NOLINTNEXTLINE(cert-dcl21-cpp) + iter_t operator++(int) & noexcept {const iter_t tmp(*this); operator++(); return tmp;} ~iter_t() = default; diff --git a/src/lib/netlist/plib/pmempool.h b/src/lib/netlist/plib/pmempool.h index c55d66d8847..166c6f3d483 100644 --- a/src/lib/netlist/plib/pmempool.h +++ b/src/lib/netlist/plib/pmempool.h @@ -139,8 +139,8 @@ namespace plib { auto *ret = reinterpret_cast(b->m_data + b->m_cur); auto capacity(rs); ret = std::align(align, size, ret, capacity); - if (ret == nullptr) - printf("Oh no\n"); + // FIXME: if (ret == nullptr) + // printf("Oh no\n"); sinfo().insert({ ret, info(b, b->m_cur)}); rs -= (capacity - size); b->m_cur += rs; @@ -155,8 +155,8 @@ namespace plib { auto *ret = reinterpret_cast(b->m_data + b->m_cur); auto capacity(rs); ret = std::align(align, size, ret, capacity); - if (ret == nullptr) - printf("Oh no\n"); + // FIXME: if (ret == nullptr) + // printf("Oh no\n"); sinfo().insert({ ret, info(b, b->m_cur)}); rs -= (capacity - size); b->m_cur += rs; diff --git a/src/lib/netlist/plib/poptions.cpp b/src/lib/netlist/plib/poptions.cpp index 2a58eaab0f4..4a3d32c4723 100644 --- a/src/lib/netlist/plib/poptions.cpp +++ b/src/lib/netlist/plib/poptions.cpp @@ -14,13 +14,13 @@ namespace plib { Options ***************************************************************************/ - option_base::option_base(options &parent, pstring help) + option_base::option_base(options &parent, const pstring &help) : m_help(help) { parent.register_option(this); } - option::option(options &parent, pstring ashort, pstring along, pstring help, bool has_argument) + option::option(options &parent, const pstring &ashort, const pstring &along, const pstring &help, bool has_argument) : option_base(parent, help), m_short(ashort), m_long(along), m_has_argument(has_argument), m_specified(false) { @@ -174,7 +174,7 @@ namespace plib { return argc; } - pstring options::split_paragraphs(pstring text, unsigned width, unsigned indent, + pstring options::split_paragraphs(const pstring &text, unsigned width, unsigned indent, unsigned firstline_indent) { auto paragraphs = psplit(text,"\n"); @@ -197,7 +197,7 @@ namespace plib { return ret; } - pstring options::help(pstring description, pstring usage, + pstring options::help(const pstring &description, const pstring &usage, unsigned width, unsigned indent) const { pstring ret; @@ -272,7 +272,7 @@ namespace plib { return ret; } - option *options::getopt_short(pstring arg) const + option *options::getopt_short(const pstring &arg) const { for (auto & optbase : m_opts) { @@ -282,7 +282,7 @@ namespace plib { } return nullptr; } - option *options::getopt_long(pstring arg) const + option *options::getopt_long(const pstring &arg) const { for (auto & optbase : m_opts) { diff --git a/src/lib/netlist/plib/poptions.h b/src/lib/netlist/plib/poptions.h index 23319604052..086fe32fc8a 100644 --- a/src/lib/netlist/plib/poptions.h +++ b/src/lib/netlist/plib/poptions.h @@ -24,7 +24,7 @@ class options; class option_base { public: - option_base(options &parent, pstring help); + option_base(options &parent, const pstring &help); virtual ~option_base() = default; COPYASSIGNMOVE(option_base, delete) @@ -37,7 +37,7 @@ private: class option_group : public option_base { public: - option_group(options &parent, pstring group, pstring help) + option_group(options &parent, const pstring &group, const pstring &help) : option_base(parent, help), m_group(group) { } pstring group() const { return m_group; } @@ -48,7 +48,7 @@ private: class option_example : public option_base { public: - option_example(options &parent, pstring group, pstring help) + option_example(options &parent, const pstring &group, const pstring &help) : option_base(parent, help), m_example(group) { } pstring example() const { return m_example; } @@ -60,7 +60,7 @@ private: class option : public option_base { public: - option(options &parent, pstring ashort, pstring along, pstring help, bool has_argument); + option(options &parent, const pstring &ashort, const pstring &along, const pstring &help, bool has_argument); /* no_argument options will be called with "" argument */ @@ -88,7 +88,7 @@ private: class option_str : public option { public: - option_str(options &parent, pstring ashort, pstring along, pstring defval, pstring help) + option_str(options &parent, const pstring &ashort, const pstring &along, const pstring &defval, const pstring &help) : option(parent, ashort, along, help, true), m_val(defval) {} @@ -104,7 +104,7 @@ private: class option_str_limit_base : public option { public: - option_str_limit_base(options &parent, pstring ashort, pstring along, std::vector &&limit, pstring help) + option_str_limit_base(options &parent, const pstring &ashort, const pstring &along, std::vector &&limit, const pstring &help) : option(parent, ashort, along, help, true) , m_limit(limit) { @@ -122,7 +122,7 @@ template class option_str_limit : public option_str_limit_base { public: - option_str_limit(options &parent, pstring ashort, pstring along, const T &defval, std::vector &&limit, pstring help) + option_str_limit(options &parent, const pstring &ashort, const pstring &along, const T &defval, std::vector &&limit, const pstring &help) : option_str_limit_base(parent, ashort, along, std::move(limit), help), m_val(defval) { } @@ -152,7 +152,7 @@ private: class option_bool : public option { public: - option_bool(options &parent, pstring ashort, pstring along, pstring help) + option_bool(options &parent, const pstring &ashort, const pstring &along, const pstring &help) : option(parent, ashort, along, help, false), m_val(false) {} @@ -169,8 +169,8 @@ template class option_num : public option { public: - option_num(options &parent, pstring ashort, pstring along, T defval, - pstring help, + option_num(options &parent, const pstring &ashort, const pstring &along, T defval, + const pstring &help, T minval = std::numeric_limits::min(), T maxval = std::numeric_limits::max() ) : option(parent, ashort, along, help, true) @@ -198,7 +198,7 @@ private: class option_vec : public option { public: - option_vec(options &parent, pstring ashort, pstring along, pstring help) + option_vec(options &parent, const pstring &ashort, const pstring &along, const pstring &help) : option(parent, ashort, along, help, true) {} @@ -214,7 +214,7 @@ private: class option_args : public option_vec { public: - option_args(options &parent, pstring help) + option_args(options &parent, const pstring &help) : option_vec(parent, "", "", help) {} }; @@ -229,13 +229,13 @@ public: void register_option(option_base *opt); int parse(int argc, char **argv); - pstring help(pstring description, pstring usage, + pstring help(const pstring &description, const pstring &usage, unsigned width = 72, unsigned indent = 20) const; pstring app() const { return m_app; } private: - static pstring split_paragraphs(pstring text, unsigned width, unsigned indent, + static pstring split_paragraphs(const pstring &text, unsigned width, unsigned indent, unsigned firstline_indent); void check_consistency(); @@ -251,8 +251,8 @@ private: return nullptr; } - option *getopt_short(pstring arg) const; - option *getopt_long(pstring arg) const; + option *getopt_short(const pstring &arg) const; + option *getopt_long(const pstring &arg) const; std::vector m_opts; pstring m_app; diff --git a/src/lib/netlist/plib/pparser.h b/src/lib/netlist/plib/pparser.h index 9803fae9cb8..24b096519bf 100644 --- a/src/lib/netlist/plib/pparser.h +++ b/src/lib/netlist/plib/pparser.h @@ -98,18 +98,18 @@ public: void require_token(const token_id_t &token_num); void require_token(const token_t &tok, const token_id_t &token_num); - token_id_t register_token(pstring token) + token_id_t register_token(const pstring &token) { token_id_t ret(m_tokens.size()); m_tokens.emplace(token, ret); return ret; } - ptokenizer & identifier_chars(pstring s) { m_identifier_chars = s; return *this; } - ptokenizer & number_chars(pstring st, pstring rem) { m_number_chars_start = st; m_number_chars = rem; return *this; } + ptokenizer & identifier_chars(pstring s) { m_identifier_chars = std::move(s); return *this; } + ptokenizer & number_chars(pstring st, pstring rem) { m_number_chars_start = std::move(st); m_number_chars = std::move(rem); return *this; } ptokenizer & string_char(pstring::value_type c) { m_string = c; return *this; } - ptokenizer & whitespace(pstring s) { m_whitespace = s; return *this; } - ptokenizer & comment(pstring start, pstring end, pstring line) + ptokenizer & whitespace(pstring s) { m_whitespace = std::move(s); return *this; } + ptokenizer & comment(const pstring &start, const pstring &end, const pstring &line) { m_tok_comment_start = register_token(start); m_tok_comment_end = register_token(end); diff --git a/src/lib/netlist/plib/ppmf.h b/src/lib/netlist/plib/ppmf.h index 4dcceee454f..32b151b357b 100644 --- a/src/lib/netlist/plib/ppmf.h +++ b/src/lib/netlist/plib/ppmf.h @@ -95,6 +95,7 @@ namespace plib { if (PHAS_PMF_INTERNAL == 1) { // apply the "this" delta to the object first + // NOLINTNEXTLINE(clang-analyzer-core.UndefinedBinaryOperatorResult) auto o_p_delta = reinterpret_cast(reinterpret_cast(object) + m_this_delta); // if the low bit of the vtable index is clear, then it is just a raw function pointer diff --git a/src/lib/netlist/plib/pstate.h b/src/lib/netlist/plib/pstate.h index d837a6d2931..ac75ca6b69e 100644 --- a/src/lib/netlist/plib/pstate.h +++ b/src/lib/netlist/plib/pstate.h @@ -8,9 +8,9 @@ #ifndef PSTATE_H_ #define PSTATE_H_ +#include "palloc.h" #include "pstring.h" #include "ptypes.h" -#include "palloc.h" #include #include diff --git a/src/lib/netlist/plib/pstream.h b/src/lib/netlist/plib/pstream.h index d5b2bfa4809..29f79e0dd4a 100644 --- a/src/lib/netlist/plib/pstream.h +++ b/src/lib/netlist/plib/pstream.h @@ -530,7 +530,8 @@ public: void write(const pstring &text) const { - putf8string conv_utf8(text); + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) + const putf8string conv_utf8(text); m_strm->write(reinterpret_cast(conv_utf8.c_str()), conv_utf8.mem_t_size()); } diff --git a/src/lib/netlist/plib/pstring.h b/src/lib/netlist/plib/pstring.h index bc056424531..76ad11b0f91 100644 --- a/src/lib/netlist/plib/pstring.h +++ b/src/lib/netlist/plib/pstring.h @@ -46,7 +46,8 @@ public: explicit constexpr pstring_const_iterator(const typename string_type::const_iterator &x) noexcept : p(x) { } pstring_const_iterator& operator++() noexcept { p += static_cast(traits_type::codelen(&(*p))); return *this; } - pstring_const_iterator operator++(int) noexcept { pstring_const_iterator tmp(*this); operator++(); return tmp; } + // NOLINTNEXTLINE(cert-dcl21-cpp) + pstring_const_iterator operator++(int) & noexcept { pstring_const_iterator tmp(*this); operator++(); return tmp; } constexpr bool operator==(const pstring_const_iterator& rhs) const noexcept { return p == rhs.p; } constexpr bool operator!=(const pstring_const_iterator& rhs) const noexcept { return p != rhs.p; } @@ -207,10 +208,8 @@ public: static const size_type npos = static_cast(-1); -protected: - string_type m_str; - private: + string_type m_str; }; struct pu8_traits diff --git a/src/lib/netlist/plib/vector_ops.h b/src/lib/netlist/plib/vector_ops.h index f5a9e336d0d..0de931b40da 100644 --- a/src/lib/netlist/plib/vector_ops.h +++ b/src/lib/netlist/plib/vector_ops.h @@ -43,7 +43,8 @@ namespace plib template T vec_mult (const std::size_t n, const V1 & v1, const V2 & v2 ) { - PALIGNAS_VECTOROPT() T value[8] = {0}; + using b8 = T[8]; + PALIGNAS_VECTOROPT() b8 value = {0}; for (std::size_t i = 0; i < n ; i++ ) { value[i & 7] += v1[i] * v2[i]; @@ -54,7 +55,8 @@ namespace plib template T vec_mult2 (const std::size_t n, const VT &v) { - PALIGNAS_VECTOROPT() T value[8] = {0}; + using b8 = T[8]; + PALIGNAS_VECTOROPT() b8 value = {0}; for (std::size_t i = 0; i < n ; i++ ) { value[i & 7] += v[i] * v[i]; @@ -67,7 +69,7 @@ namespace plib { if (n<8) { - PALIGNAS_VECTOROPT() T value(0); + T value(0); for (std::size_t i = 0; i < n ; i++ ) value += v[i]; @@ -75,7 +77,8 @@ namespace plib } else { - PALIGNAS_VECTOROPT() T value[8] = {0}; + using b8 = T[8]; + PALIGNAS_VECTOROPT() b8 value = {0}; for (std::size_t i = 0; i < n ; i++ ) value[i & 7] += v[i]; diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp index 076d004528c..a751bbd2965 100644 --- a/src/lib/netlist/prg/nltool.cpp +++ b/src/lib/netlist/prg/nltool.cpp @@ -120,7 +120,7 @@ NETLIST_END() class netlist_data_folder_t : public netlist::source_t { public: - netlist_data_folder_t(pstring folder) + netlist_data_folder_t(const pstring &folder) : netlist::source_t(netlist::source_t::DATA) , m_folder(folder) { @@ -311,7 +311,7 @@ struct input_t double m_value; }; -static std::vector read_input(const netlist::setup_t &setup, pstring fname) +static std::vector read_input(const netlist::setup_t &setup, const pstring &fname) { std::vector ret; if (fname != "") diff --git a/src/lib/netlist/prg/nlwav.cpp b/src/lib/netlist/prg/nlwav.cpp index 24c84c73739..bd30e93d7e6 100644 --- a/src/lib/netlist/prg/nlwav.cpp +++ b/src/lib/netlist/prg/nlwav.cpp @@ -363,17 +363,17 @@ public: } } - std::size_t m_channels; - double m_last_time; - private: - void write(pstring line) + void write(const pstring &line) { auto p = static_cast(line.c_str()); std::size_t len = std::strlen(p); m_fo.write(p, len); } + std::size_t m_channels; + double m_last_time; + plib::postream &m_fo; std::vector m_ids; pstring m_buf; @@ -410,6 +410,14 @@ public: "convert all files starting with \"log_V\" into a multichannel wav file"), m_outstrm(nullptr) {} + + int execute() override; + pstring usage() override; + +private: + void convert_wav(); + void convert_vcd(vcdwriter::format_e format); + plib::option_str_limit opt_fmt; plib::option_str opt_out; plib::option_num opt_rate; @@ -423,14 +431,8 @@ public: plib::option_bool opt_help; plib::option_example opt_ex1; plib::option_example opt_ex2; - - int execute() override; - pstring usage() override; - plib::pstdin pin_strm; -private: - void convert_wav(); - void convert_vcd(vcdwriter::format_e format); + std::vector> m_instrms; plib::postream *m_outstrm; }; diff --git a/src/lib/netlist/solver/nld_matrix_solver.cpp b/src/lib/netlist/solver/nld_matrix_solver.cpp index 951733874fd..dc03255a056 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.cpp +++ b/src/lib/netlist/solver/nld_matrix_solver.cpp @@ -111,7 +111,7 @@ void matrix_solver_t::setup_base(analog_net_t::list_t &nets) net->set_solver(this); - for (auto &p : net->m_core_terms) + for (auto &p : net->core_terms()) { log().debug("{1} {2} {3}\n", p->name(), net->name(), net->isRailNet()); switch (p->type()) @@ -159,7 +159,7 @@ void matrix_solver_t::setup_base(analog_net_t::list_t &nets) break; } } - log().debug("added net with {1} populated connections\n", net->m_core_terms.size()); + log().debug("added net with {1} populated connections\n", net->core_terms().size()); } /* now setup the matrix */ @@ -336,9 +336,7 @@ void matrix_solver_t::setup_matrix() * This should reduce cache misses ... */ - auto **touched = plib::pnew_array(iN); - for (std::size_t k=0; k(iN); + std::vector> touched(iN, std::vector(iN)); for (std::size_t k = 0; k < iN; k++) { @@ -395,10 +393,6 @@ void matrix_solver_t::setup_matrix() state().save(*this, m_terms[k]->gt(),"GT" + num, this->name(), m_terms[k]->count()); state().save(*this, m_terms[k]->Idr(),"IDR" + num, this->name(), m_terms[k]->count()); } - - for (std::size_t k=0; km_core_terms) + for (auto &p : n->core_terms()) { if (p->is_type(detail::terminal_type::TERMINAL)) { @@ -399,7 +399,7 @@ void NETLIB_NAME(solver)::post_start() for (auto &n : grp) { log().verbose("Net {1}", n->name()); - for (const auto &pcore : n->m_core_terms) + for (const auto &pcore : n->core_terms()) { log().verbose(" {1}", pcore->name()); } diff --git a/src/lib/netlist/solver/nld_solver.h b/src/lib/netlist/solver/nld_solver.h index c4a9eba6971..164b7663f98 100644 --- a/src/lib/netlist/solver/nld_solver.h +++ b/src/lib/netlist/solver/nld_solver.h @@ -76,7 +76,7 @@ NETLIB_OBJECT(solver) NETLIB_RESETI(); // NETLIB_UPDATE_PARAMI(); -protected: +private: logic_input_t m_fb_step; logic_output_t m_Q_step; @@ -96,7 +96,6 @@ protected: param_logic_t m_log_stats; -private: std::vector> m_mat_solvers; std::vector m_mat_solvers_all; std::vector m_mat_solvers_timestepping; diff --git a/src/lib/netlist/tools/nl_convert.cpp b/src/lib/netlist/tools/nl_convert.cpp index f4616cb7774..16a3cfd6960 100644 --- a/src/lib/netlist/tools/nl_convert.cpp +++ b/src/lib/netlist/tools/nl_convert.cpp @@ -105,7 +105,7 @@ void nl_convert_base_t::add_device(const pstring &atype, const pstring &aname) add_device(plib::make_unique(atype, aname)); } -void nl_convert_base_t::add_term(pstring netname, pstring termname) +void nl_convert_base_t::add_term(const pstring &netname, const pstring &termname) { net_t * net = nullptr; auto idx = m_nets.find(netname); diff --git a/src/lib/netlist/tools/nl_convert.h b/src/lib/netlist/tools/nl_convert.h index 73c98301af5..b031ef72618 100644 --- a/src/lib/netlist/tools/nl_convert.h +++ b/src/lib/netlist/tools/nl_convert.h @@ -43,7 +43,7 @@ protected: void add_device(const pstring &atype, const pstring &aname, double aval); void add_device(const pstring &atype, const pstring &aname); - void add_term(pstring netname, pstring termname); + void add_term(const pstring &netname, const pstring &termname); void dump_nl(); -- cgit v1.2.3-70-g09d2