From fb685c05b9f100c46c2ae5df6532f298e45ab4f7 Mon Sep 17 00:00:00 2001 From: couriersud Date: Wed, 13 Feb 2019 21:19:59 +0100 Subject: netlist: memory allocation clean-up. (nw) --- src/lib/netlist/plib/pmempool.h | 153 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 src/lib/netlist/plib/pmempool.h (limited to 'src/lib/netlist/plib/pmempool.h') diff --git a/src/lib/netlist/plib/pmempool.h b/src/lib/netlist/plib/pmempool.h new file mode 100644 index 00000000000..2e15076b477 --- /dev/null +++ b/src/lib/netlist/plib/pmempool.h @@ -0,0 +1,153 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * palloc.h + * + */ + +#ifndef PMEMPOOL_H_ +#define PMEMPOOL_H_ + +#include "palloc.h" +#include "pstream.h" +#include "pstring.h" +#include "ptypes.h" +#include "putil.h" + +#include +#include +#include +#include +#include +#include + +namespace plib { + + //============================================================ + // Memory pool + //============================================================ + + class mempool + { + private: + struct block + { + block(mempool *mp) + : m_num_alloc(0) + , m_free(mp->m_min_alloc) + , m_cur(0) + , m_data(nullptr) + , m_mempool(mp) + { + std::size_t alloc_bytes = (mp->m_min_alloc + mp->m_min_align - 1) & ~(mp->m_min_align - 1); + m_data_allocated = static_cast(::operator new(alloc_bytes)); + void *r = m_data_allocated; + std::align(mp->m_min_align, mp->m_min_alloc, r, alloc_bytes); + m_data = reinterpret_cast(r); + } + std::size_t m_num_alloc; + std::size_t m_free; + std::size_t m_cur; + char *m_data; + char *m_data_allocated; + mempool *m_mempool; + }; + + struct info + { + info(block *b, std::size_t p) : m_block(b), m_pos(p) { } + info(const info &) = default; + info(info &&) = default; + block * m_block; + std::size_t m_pos; + }; + + + block * new_block() + { + auto *b = new block(this); + m_blocks.push_back(b); + return b; + } + + + static std::unordered_map &sinfo() + { + static std::unordered_map spinfo; + return spinfo; + } + + size_t m_min_alloc; + size_t m_min_align; + + std::vector m_blocks; + + public: + + mempool(size_t min_alloc, size_t min_align) + : m_min_alloc(min_alloc), m_min_align(min_align) + { + } + + + COPYASSIGNMOVE(mempool, delete) + + ~mempool() + { + for (auto & b : m_blocks) + { + if (b->m_num_alloc != 0) + { + plib::perrlogger("Found block with {} dangling allocations\n", b->m_num_alloc); + } + ::operator delete(b->m_data); + } + } + + + void *alloc(size_t size) + { + size_t rs = (size + m_min_align - 1) & ~(m_min_align - 1); + for (auto &b : m_blocks) + { + if (b->m_free > rs) + { + b->m_free -= rs; + b->m_num_alloc++; + auto ret = reinterpret_cast(b->m_data + b->m_cur); + sinfo().insert({ ret, info(b, b->m_cur)}); + b->m_cur += rs; + return ret; + } + } + { + block *b = new_block(); + b->m_num_alloc = 1; + b->m_free = m_min_alloc - rs; + auto ret = reinterpret_cast(b->m_data + b->m_cur); + sinfo().insert({ ret, info(b, b->m_cur)}); + b->m_cur += rs; + return ret; + } + } + + void free(void *ptr) + { + info i = sinfo().find(ptr)->second; + block *b = i.m_block; + if (b->m_num_alloc == 0) + throw plib::pexception("mempool::free - double free was called\n"); + else + { + //b->m_free = m_min_alloc; + //b->cur_ptr = b->data; + } + b->m_num_alloc--; + } + + + }; + +} // namespace plib + +#endif /* PMEMPOOL_H_ */ -- cgit v1.2.3-70-g09d2 From b113d0c26d8214b8820a152f5bc20496c564b7d3 Mon Sep 17 00:00:00 2001 From: couriersud Date: Thu, 14 Feb 2019 21:34:30 +0100 Subject: netlist: memory pool now supports aligned storage. (nw) Set USE_MEMPOOL to 1 to try this (max 5% performance increase). For mingw, there is no alignment support. This triggers -Wattribute errors which due to -Werror crash the build. --- src/devices/machine/netlist.cpp | 30 ++++---- src/devices/machine/netlist.h | 3 +- src/lib/netlist/build/makefile | 2 +- src/lib/netlist/devices/nlid_system.h | 4 +- src/lib/netlist/devices/nlid_truthtable.cpp | 4 +- src/lib/netlist/netlist_types.h | 45 +++++++++--- src/lib/netlist/nl_base.cpp | 50 ++++++------- src/lib/netlist/nl_base.h | 32 +++++---- src/lib/netlist/nl_factory.cpp | 4 +- src/lib/netlist/nl_factory.h | 9 +-- src/lib/netlist/nl_lists.h | 2 +- src/lib/netlist/nl_setup.cpp | 30 ++++---- src/lib/netlist/nl_setup.h | 16 ++++- src/lib/netlist/plib/gmres.h | 12 ++-- src/lib/netlist/plib/mat_cr.h | 2 +- src/lib/netlist/plib/palloc.h | 83 ++++++++++++---------- src/lib/netlist/plib/parray.h | 5 +- src/lib/netlist/plib/pconfig.h | 14 ++++ src/lib/netlist/plib/pmempool.h | 102 +++++++++++++++++++++++++-- src/lib/netlist/prg/nltool.cpp | 18 ++--- src/lib/netlist/solver/nld_matrix_solver.cpp | 2 +- src/lib/netlist/solver/nld_matrix_solver.h | 2 +- src/lib/netlist/solver/nld_ms_gmres.h | 2 +- src/lib/netlist/solver/nld_solver.cpp | 14 ++-- src/lib/netlist/solver/nld_solver.h | 4 +- 25 files changed, 322 insertions(+), 169 deletions(-) (limited to 'src/lib/netlist/plib/pmempool.h') diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp index d702bd5b6b6..fcfa246910f 100644 --- a/src/devices/machine/netlist.cpp +++ b/src/devices/machine/netlist.cpp @@ -239,7 +239,7 @@ public: std::unique_ptr netlist_source_memregion_t::stream(const pstring &name) { memory_region *mem = static_cast(setup().exec()).machine().root_device().memregion(m_name.c_str()); - return plib::make_unique_base(mem->base(), mem->bytes()); + return plib::make_unique(mem->base(), mem->bytes()); } netlist_data_memregions_t::netlist_data_memregions_t(netlist::setup_t &setup) @@ -252,7 +252,7 @@ std::unique_ptr netlist_data_memregions_t::stream(const pstring memory_region *mem = static_cast(setup().exec()).parent().memregion(name.c_str()); if (mem != nullptr) { - return plib::make_unique_base(mem->base(), mem->bytes()); + return plib::make_unique(mem->base(), mem->bytes()); } else { @@ -367,9 +367,9 @@ public: for (int i = 0; i < MAX_INPUT_CHANNELS; i++) { - m_channels[i].m_param_name = std::make_unique(*this, plib::pfmt("CHAN{1}")(i), ""); - m_channels[i].m_param_mult = std::make_unique(*this, plib::pfmt("MULT{1}")(i), 1.0); - m_channels[i].m_param_offset = std::make_unique(*this, plib::pfmt("OFFSET{1}")(i), 0.0); + m_channels[i].m_param_name = netlist::pool().make_poolptr(*this, plib::pfmt("CHAN{1}")(i), ""); + m_channels[i].m_param_mult = netlist::pool().make_poolptr(*this, plib::pfmt("MULT{1}")(i), 1.0); + m_channels[i].m_param_offset = netlist::pool().make_poolptr(*this, plib::pfmt("OFFSET{1}")(i), 0.0); } } @@ -416,11 +416,11 @@ public: struct channel { - std::unique_ptr m_param_name; + netlist::poolptr m_param_name; netlist::param_double_t *m_param; stream_sample_t *m_buffer; - std::unique_ptr m_param_mult; - std::unique_ptr m_param_offset; + netlist::poolptr m_param_mult; + netlist::poolptr m_param_offset; }; channel m_channels[MAX_INPUT_CHANNELS]; netlist::netlist_time m_inc; @@ -456,7 +456,7 @@ netlist::setup_t &netlist_mame_device::setup() void netlist_mame_device::register_memregion_source(netlist::setup_t &setup, const char *name) { - setup.register_source(plib::make_unique_base(setup, pstring(name))); + setup.register_source(plib::make_unique(setup, pstring(name))); } void netlist_mame_analog_input_device::write(const double val) @@ -584,7 +584,7 @@ void netlist_mame_analog_output_device::custom_netlist_additions(netlist::setup_ pstring dfqn = setup.build_fqn(dname); m_delegate.bind_relative_to(owner()->machine().root_device()); - plib::owned_ptr dev = plib::owned_ptr::Create(setup.netlist(), dfqn); + auto dev = netlist::pool().make_poolptr(setup.netlist(), dfqn); static_cast(dev.get())->register_callback(std::move(m_delegate)); setup.netlist().add_dev(dfqn, std::move(dev)); setup.register_link(dname + ".IN", pin); @@ -621,7 +621,7 @@ void netlist_mame_logic_output_device::custom_netlist_additions(netlist::setup_t m_delegate.bind_relative_to(owner()->machine().root_device()); - plib::owned_ptr dev = plib::owned_ptr::Create(setup.netlist(), dfqn); + auto dev = netlist::pool().make_poolptr(setup.netlist(), dfqn); static_cast(dev.get())->register_callback(std::move(m_delegate)); setup.netlist().add_dev(dfqn, std::move(dev)); setup.register_link(dname + ".IN", pin); @@ -817,7 +817,6 @@ netlist_mame_device::netlist_mame_device(const machine_config &mconfig, device_t : device_t(mconfig, type, tag, owner, clock) , m_icount(0) , m_old(netlist::netlist_time::zero()) - , m_netlist(nullptr) , m_setup_func(nullptr) { } @@ -850,7 +849,7 @@ void netlist_mame_device::device_start() //printf("clock is %d\n", clock()); - m_netlist = global_alloc(netlist_mame_t(*this, "netlist")); + m_netlist = netlist::pool().make_poolptr(*this, "netlist"); // register additional devices @@ -868,7 +867,7 @@ void netlist_mame_device::device_start() } /* add default data provider for roms */ - setup().register_source(plib::make_unique_base(setup())); + setup().register_source(plib::make_unique(setup())); m_setup_func(setup()); @@ -916,9 +915,6 @@ void netlist_mame_device::device_stop() { LOGDEVCALLS("device_stop\n"); netlist().stop(); - - global_free(m_netlist); - m_netlist = nullptr; } ATTR_COLD void netlist_mame_device::device_post_load() diff --git a/src/devices/machine/netlist.h b/src/devices/machine/netlist.h index 06edb4beaa4..630bbabe42c 100644 --- a/src/devices/machine/netlist.h +++ b/src/devices/machine/netlist.h @@ -12,6 +12,7 @@ #define MAME_MACHINE_NETLIST_H #include "netlist/nl_time.h" +#include "netlist/netlist_types.h" class nld_sound_out; class nld_sound_in; @@ -141,7 +142,7 @@ private: netlist::netlist_time m_rem; netlist::netlist_time m_old; - netlist_mame_t * m_netlist; + netlist::poolptr m_netlist; void (*m_setup_func)(netlist::setup_t &); }; diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile index c382d2fe2ab..213d6ffb8e7 100644 --- a/src/lib/netlist/build/makefile +++ b/src/lib/netlist/build/makefile @@ -235,7 +235,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-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" + $(MAKE) CC=clang++-9 LD=clang++-9 CEXTRAFLAGS="-march=native -Wno-unused-parameter -Weverything -Werror -Wno-unused-template -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/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index 2a1e4b3e66c..e58b15ed03b 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -317,7 +317,7 @@ namespace netlist for (int i=0; i < m_N(); i++) { pstring n = plib::pfmt("A{1}")(i); - m_I.push_back(plib::make_unique(*this, n)); + m_I.push_back(pool().make_poolptr(*this, n)); inps.push_back(n); m_vals.push_back(0.0); } @@ -334,7 +334,7 @@ namespace netlist param_int_t m_N; param_str_t m_func; analog_output_t m_Q; - std::vector> m_I; + std::vector> m_I; std::vector m_vals; plib::pfunction m_compiled; diff --git a/src/lib/netlist/devices/nlid_truthtable.cpp b/src/lib/netlist/devices/nlid_truthtable.cpp index f67a0d1d2bb..346a013d680 100644 --- a/src/lib/netlist/devices/nlid_truthtable.cpp +++ b/src/lib/netlist/devices/nlid_truthtable.cpp @@ -224,7 +224,7 @@ namespace netlist : netlist_base_factory_truthtable_t(name, classname, def_param, sourcefile) { } - plib::owned_ptr Create(netlist_state_t &anetlist, const pstring &name) override + poolptr Create(netlist_state_t &anetlist, const pstring &name) override { using tt_type = nld_truthtable_t; truthtable_parser desc_s(m_NO, m_NI, &m_ttbl.m_initialized, @@ -232,7 +232,7 @@ namespace netlist m_ttbl.m_timing_index.data(), m_ttbl.m_timing_nt.data()); desc_s.parse(m_desc); - return plib::owned_ptr::Create(anetlist, name, m_family, m_ttbl, m_desc); + return pool().make_poolptr(anetlist, name, m_family, m_ttbl, m_desc); } private: typename nld_truthtable_t::truthtable_t m_ttbl; diff --git a/src/lib/netlist/netlist_types.h b/src/lib/netlist/netlist_types.h index 3aa7f3436ee..5aec827491b 100644 --- a/src/lib/netlist/netlist_types.h +++ b/src/lib/netlist/netlist_types.h @@ -16,6 +16,7 @@ #include "plib/pchrono.h" #include "plib/pfmtlog.h" #include "plib/pstring.h" +#include "plib/pmempool.h" namespace netlist @@ -69,19 +70,43 @@ namespace netlist // Types needed by various includes //============================================================ - namespace detail { + /*! The memory pool for netlist objects + * + * \note This is not the right location yet. + * + */ - /*! Enum specifying the type of object */ - enum terminal_type { - TERMINAL = 0, /*!< object is an analog terminal */ - INPUT = 1, /*!< object is an input */ - OUTPUT = 2, /*!< object is an output */ - }; +#if (USE_MEMPOOL) + using nlmempool = plib::mempool; +#else + using nlmempool = plib::mempool_default; +#endif - /*! Type of the model map used. - * This is used to hold all #Models in an unordered map + /*! Owned pointer type for pooled allocations. + * */ - using model_map_t = std::unordered_map; + template + using poolptr = nlmempool::poolptr; + + inline nlmempool &pool() + { + static nlmempool static_pool(655360, 16); + return static_pool; + } + + namespace detail { + + /*! Enum specifying the type of object */ + enum terminal_type { + TERMINAL = 0, /*!< object is an analog terminal */ + INPUT = 1, /*!< object is an input */ + OUTPUT = 2, /*!< object is an output */ + }; + + /*! Type of the model map used. + * This is used to hold all #Models in an unordered map + */ + using model_map_t = std::unordered_map; } // namespace detail } // namespace netlist diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index 8ef16e58bcb..f78731e883f 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -28,12 +28,13 @@ namespace netlist namespace detail { - static plib::mempool *pool() - { - static plib::mempool s_pool(655360, 32); - return &s_pool; - } + //static plib::mempool *pool() + //{ + // static plib::mempool s_pool(655360, 32); + // return &s_pool; + //} +#if 0 void * object_t::operator new (size_t size) { void *ret = nullptr; @@ -43,14 +44,14 @@ namespace detail ret = ::operator new(size); return ret; } - +#endif void object_t::operator delete (void * mem) { if (mem) { - if ((USE_MEMPOOL)) - pool()->free(mem); - else + //if ((USE_MEMPOOL)) + // pool()->free(mem); + //else ::operator delete(mem); } } @@ -81,17 +82,17 @@ public: m_R_low = 1.0; m_R_high = 130.0; } - plib::owned_ptr create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const override; - plib::owned_ptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const override; + poolptr create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const override; + poolptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const override; }; -plib::owned_ptr logic_family_ttl_t::create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const +poolptr logic_family_ttl_t::create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const { - return plib::owned_ptr::Create(anetlist, name, proxied); + return pool().make_poolptr(anetlist, name, proxied); } -plib::owned_ptr logic_family_ttl_t::create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const +poolptr logic_family_ttl_t::create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const { - return plib::owned_ptr::Create(anetlist, name, proxied); + return pool().make_poolptr(anetlist, name, proxied); } class logic_family_cd4xxx_t : public logic_family_desc_t @@ -108,17 +109,18 @@ public: m_R_low = 10.0; m_R_high = 10.0; } - plib::owned_ptr create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const override; - plib::owned_ptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const override; + poolptr create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const override; + poolptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const override; }; -plib::owned_ptr logic_family_cd4xxx_t::create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const +poolptr logic_family_cd4xxx_t::create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const { - return plib::owned_ptr::Create(anetlist, name, proxied); + return pool().make_poolptr(anetlist, name, proxied); } -plib::owned_ptr logic_family_cd4xxx_t::create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const + +poolptr logic_family_cd4xxx_t::create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const { - return plib::owned_ptr::Create(anetlist, name, proxied); + return pool().make_poolptr(anetlist, name, proxied); } const logic_family_desc_t *family_TTL() @@ -576,7 +578,7 @@ core_device_t::core_device_t(core_device_t &owner, const pstring &name) set_logic_family(owner.logic_family()); if (logic_family() == nullptr) set_logic_family(family_TTL()); - state().add_dev(this->name(), plib::owned_ptr(this, false)); + state().add_dev(this->name(), poolptr(this, false)); } void core_device_t::set_default_delegate(detail::core_terminal_t &term) @@ -892,7 +894,7 @@ logic_output_t::logic_output_t(core_device_t &dev, const pstring &aname) , m_my_net(dev.state(), name() + ".net", this) { this->set_net(&m_my_net); - state().register_net(plib::owned_ptr(&m_my_net, false)); + state().register_net(poolptr(&m_my_net, false)); set_logic_family(dev.logic_family()); state().setup().register_term(*this); } @@ -921,7 +923,7 @@ analog_output_t::analog_output_t(core_device_t &dev, const pstring &aname) : analog_t(dev, aname, STATE_OUT) , m_my_net(dev.state(), name() + ".net", this) { - state().register_net(plib::owned_ptr(&m_my_net, false)); + state().register_net(poolptr(&m_my_net, false)); this->set_net(&m_my_net); //net().m_cur_Analog = NL_FCONST(0.0); diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 62a5104a021..10df59029b8 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -22,6 +22,7 @@ #include "plib/ppmf.h" #include "plib/pstate.h" #include "plib/pstream.h" +#include "plib/pmempool.h" #include "netlist_types.h" #include "nl_errstr.h" @@ -138,7 +139,7 @@ class NETLIB_NAME(name) : public device_t #define NETLIB_TIMESTEP(chip) void NETLIB_NAME(chip) :: timestep(const nl_double step) #define NETLIB_SUB(chip) nld_ ## chip -#define NETLIB_SUBXX(ns, chip) std::unique_ptr< ns :: nld_ ## chip > +#define NETLIB_SUBXX(ns, chip) poolptr< ns :: nld_ ## chip > #define NETLIB_HANDLER(chip, name) void NETLIB_NAME(chip) :: name() NL_NOEXCEPT #define NETLIB_UPDATE(chip) NETLIB_HANDLER(chip, update) @@ -242,9 +243,9 @@ namespace netlist virtual ~logic_family_desc_t() noexcept = default; - virtual plib::owned_ptr create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, + virtual poolptr create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const = 0; - virtual plib::owned_ptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, + virtual poolptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const = 0; double fixed_V() const { return m_fixed_V; } @@ -419,7 +420,8 @@ namespace netlist void * operator new (size_t size, void *ptr) { plib::unused_var(size); return ptr; } void operator delete (void *ptr, void *) { plib::unused_var(ptr); } - void * operator new (size_t size); + + void * operator new (size_t size) = delete; void operator delete (void * mem); protected: ~object_t() noexcept = default; // only childs should be destructible @@ -1186,9 +1188,10 @@ namespace netlist const setup_t &setup() const; template - void register_sub(const pstring &name, std::unique_ptr &dev, const Args&... args) + void register_sub(const pstring &name, poolptr &dev, const Args&... args) { - dev.reset(plib::palloc(*this, name, args...)); + //dev.reset(plib::palloc(*this, name, args...)); + dev = pool().make_poolptr(*this, name, args...); } void register_subalias(const pstring &name, detail::core_terminal_t &term); @@ -1263,13 +1266,14 @@ namespace netlist // netlist_state__t // ----------------------------------------------------------------------------- - class netlist_state_t : private plib::nocopyassignmove + class netlist_state_t { public: - using nets_collection_type = std::vector>; + + using nets_collection_type = std::vector>; /* need to preserve order of device creation ... */ - using devices_collection_type = std::vector>>; + using devices_collection_type = std::vector>>; netlist_state_t(const pstring &aname, std::unique_ptr &&callbacks, std::unique_ptr &&setup); @@ -1302,7 +1306,6 @@ namespace netlist plib::dynlib &lib() { return *m_lib; } /* state handling */ - plib::state_manager_t &run_state_manager() { return m_state; } template @@ -1322,7 +1325,7 @@ namespace netlist std::size_t find_net_id(const detail::net_t *net) const; template - void register_net(plib::owned_ptr &&net) { m_nets.push_back(std::move(net)); } + void register_net(poolptr &&net) { m_nets.push_back(std::move(net)); } template inline std::vector get_device_list() @@ -1338,7 +1341,7 @@ namespace netlist } template - void add_dev(const pstring &name, plib::owned_ptr &&dev) + void add_dev(const pstring &name, poolptr &&dev) { for (auto & d : m_devices) if (d.first == name) @@ -1393,6 +1396,8 @@ namespace netlist /* sole use is to manage lifetime of net objects */ devices_collection_type m_devices; + + }; // ----------------------------------------------------------------------------- @@ -1451,7 +1456,10 @@ namespace netlist /* mostly rw */ netlist_time m_time; devices::NETLIB_NAME(mainclock) * m_mainclock; + + PALIGNAS_CACHELINE() std::unique_ptr m_state; + PALIGNAS_CACHELINE() detail::queue_t m_queue; devices::NETLIB_NAME(solver) * m_solver; diff --git a/src/lib/netlist/nl_factory.cpp b/src/lib/netlist/nl_factory.cpp index 10fb54bdec0..49e567543bd 100644 --- a/src/lib/netlist/nl_factory.cpp +++ b/src/lib/netlist/nl_factory.cpp @@ -76,9 +76,9 @@ namespace netlist { namespace factory // factory_lib_entry_t: factory class to wrap macro based chips/elements // ----------------------------------------------------------------------------- - plib::owned_ptr library_element_t::Create(netlist_state_t &anetlist, const pstring &name) + poolptr library_element_t::Create(netlist_state_t &anetlist, const pstring &name) { - return plib::owned_ptr::Create(anetlist, name); + return pool().make_poolptr(anetlist, name); } void library_element_t::macro_actions(netlist_state_t &anetlist, const pstring &name) diff --git a/src/lib/netlist/nl_factory.h b/src/lib/netlist/nl_factory.h index aca31d4c649..533ad4452f2 100644 --- a/src/lib/netlist/nl_factory.h +++ b/src/lib/netlist/nl_factory.h @@ -13,6 +13,7 @@ #include "plib/palloc.h" #include "plib/ptypes.h" +#include "netlist_types.h" #define NETLIB_DEVICE_IMPL_ALIAS(p_alias, chip, p_name, p_def_param) \ NETLIB_DEVICE_IMPL_BASE(devices, p_alias, chip, p_name, p_def_param) \ @@ -53,7 +54,7 @@ namespace factory { COPYASSIGNMOVE(element_t, default) - virtual plib::owned_ptr Create(netlist_state_t &anetlist, const pstring &name) = 0; + virtual poolptr Create(netlist_state_t &anetlist, const pstring &name) = 0; virtual void macro_actions(netlist_state_t &anetlist, const pstring &name) { plib::unused_var(anetlist); @@ -83,9 +84,9 @@ namespace factory { const pstring &def_param, const pstring &sourcefile) : element_t(name, classname, def_param, sourcefile) { } - plib::owned_ptr Create(netlist_state_t &anetlist, const pstring &name) override + poolptr Create(netlist_state_t &anetlist, const pstring &name) override { - return plib::owned_ptr::Create(anetlist, name); + return pool().make_poolptr(anetlist, name); } }; @@ -147,7 +148,7 @@ namespace factory { plib::unused_var(setup); } - plib::owned_ptr Create(netlist_state_t &anetlist, const pstring &name) override; + poolptr Create(netlist_state_t &anetlist, const pstring &name) override; void macro_actions(netlist_state_t &anetlist, const pstring &name) override; diff --git a/src/lib/netlist/nl_lists.h b/src/lib/netlist/nl_lists.h index 0c5b25c1a1b..7dfe8139e19 100644 --- a/src/lib/netlist/nl_lists.h +++ b/src/lib/netlist/nl_lists.h @@ -96,7 +96,7 @@ namespace netlist /* Use TS = true for a threadsafe queue */ template - class timed_queue_linear : plib::nocopyassignmove + class PALIGNAS_CACHELINE() timed_queue_linear : plib::nocopyassignmove { public: diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp index 829bfde1b1a..3cdc598afbc 100644 --- a/src/lib/netlist/nl_setup.cpp +++ b/src/lib/netlist/nl_setup.cpp @@ -80,7 +80,7 @@ void setup_t::namespace_pop() void setup_t::register_lib_entry(const pstring &name, const pstring &sourcefile) { - factory().register_device(plib::make_unique_base(*this, name, name, "", sourcefile)); + factory().register_device(plib::make_unique(*this, name, name, "", sourcefile)); } void setup_t::register_dev(const pstring &classname, const pstring &name) @@ -593,7 +593,7 @@ void setup_t::connect_terminals(detail::core_terminal_t &t1, detail::core_termin { log().debug("adding analog net ...\n"); // FIXME: Nets should have a unique name - auto anet = plib::owned_ptr::Create(netlist(),"net." + t1.name()); + auto anet = pool().make_poolptr(netlist(),"net." + t1.name()); auto anetp = anet.get(); netlist().register_net(std::move(anet)); t1.set_net(anetp); @@ -890,19 +890,19 @@ class logic_family_std_proxy_t : public logic_family_desc_t { public: logic_family_std_proxy_t() = default; - plib::owned_ptr create_d_a_proxy(netlist_state_t &anetlist, + poolptr create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const override; - plib::owned_ptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const override; + poolptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const override; }; -plib::owned_ptr logic_family_std_proxy_t::create_d_a_proxy(netlist_state_t &anetlist, +poolptr logic_family_std_proxy_t::create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const { - return plib::owned_ptr::Create(anetlist, name, proxied); + return pool().make_poolptr(anetlist, name, proxied); } -plib::owned_ptr logic_family_std_proxy_t::create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const +poolptr logic_family_std_proxy_t::create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const { - return plib::owned_ptr::Create(anetlist, name, proxied); + return pool().make_poolptr(anetlist, name, proxied); } @@ -920,7 +920,7 @@ const logic_family_desc_t *setup_t::family_from_model(const pstring &model) if (e.first == model) return e.second.get(); - auto ret = plib::make_unique_base(); + auto ret = plib::make_unique(); ret->m_fixed_V = model_value(map, "FV"); ret->m_low_thresh_PCNT = model_value(map, "IVL"); @@ -994,7 +994,7 @@ void setup_t::delete_empty_nets() { netlist().nets().erase( std::remove_if(netlist().nets().begin(), netlist().nets().end(), - [](plib::owned_ptr &x) + [](poolptr &x) { if (x->num_cons() == 0) { @@ -1024,7 +1024,7 @@ void setup_t::prepare_to_run() if ( factory().is_class(e.second) || factory().is_class(e.second)) { - m_netlist.nlstate().add_dev(e.first, plib::owned_ptr(e.second->Create(netlist(), e.first))); + m_netlist.nlstate().add_dev(e.first, poolptr(e.second->Create(netlist(), e.first))); } } @@ -1041,7 +1041,7 @@ void setup_t::prepare_to_run() if ( !factory().is_class(e.second) && !factory().is_class(e.second)) { - auto dev = plib::owned_ptr(e.second->Create(netlist(), e.first)); + auto dev = poolptr(e.second->Create(netlist(), e.first)); m_netlist.nlstate().add_dev(dev->name(), std::move(dev)); } } @@ -1135,19 +1135,19 @@ bool source_t::parse(const pstring &name) std::unique_ptr source_string_t::stream(const pstring &name) { plib::unused_var(name); - return plib::make_unique_base(m_str.c_str(), std::strlen(m_str.c_str())); + return plib::make_unique(m_str.c_str(), std::strlen(m_str.c_str())); } std::unique_ptr source_mem_t::stream(const pstring &name) { plib::unused_var(name); - return plib::make_unique_base(m_str.c_str(), std::strlen(m_str.c_str())); + return plib::make_unique(m_str.c_str(), std::strlen(m_str.c_str())); } std::unique_ptr source_file_t::stream(const pstring &name) { plib::unused_var(name); - return plib::make_unique_base(m_filename); + return plib::make_unique(m_filename); } bool source_proc_t::parse(const pstring &name) diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h index 55e335234d2..9cc4cdb22a4 100644 --- a/src/lib/netlist/nl_setup.h +++ b/src/lib/netlist/nl_setup.h @@ -69,7 +69,7 @@ void NETLIST_NAME(name)(netlist::setup_t &setup) \ #define NETLIST_END() } #define LOCAL_SOURCE(name) \ - setup.register_source(plib::make_unique_base(setup, # name, &NETLIST_NAME(name))); + setup.register_source(plib::make_unique(setup, # name, &NETLIST_NAME(name))); #define LOCAL_LIB_ENTRY(name) \ LOCAL_SOURCE(name) \ @@ -208,6 +208,20 @@ namespace netlist // setup_t // ---------------------------------------------------------------------------------------- + // setup.register_alias(# alias, # name); + // setup.register_model(model); + // setup.register_dippins_arr( # pin1 ", " # __VA_ARGS__); + // setup.register_dev(# type, # name); + // setup.register_link(# name "." # input, # output); + // setup.register_link_arr( # term1 ", " # __VA_ARGS__); + // setup.register_param(# name, val); + // setup.register_lib_entry(# name, __FILE__); + // setup.include(# name); + // setup.namespace_push(# name); + // NETLIST_NAME(model)(setup); + // setup.namespace_pop(); + // setup.register_frontier(# attach, r_in, r_out); + // setup.tt_factory_create(desc, __FILE__); class setup_t { diff --git a/src/lib/netlist/plib/gmres.h b/src/lib/netlist/plib/gmres.h index 9be0dd99a96..ecdc093ff17 100644 --- a/src/lib/netlist/plib/gmres.h +++ b/src/lib/netlist/plib/gmres.h @@ -75,11 +75,13 @@ namespace plib } } - mat_type m_mat; - mat_type m_LU; - bool m_use_iLU_preconditioning; - std::size_t m_ILU_scale; - std::size_t m_band_width; + PALIGNAS_VECTOROPT() + mat_type m_mat; + PALIGNAS_VECTOROPT() + mat_type m_LU; + bool m_use_iLU_preconditioning; + std::size_t m_ILU_scale; + std::size_t m_band_width; }; template diff --git a/src/lib/netlist/plib/mat_cr.h b/src/lib/netlist/plib/mat_cr.h index be2d730b215..3cf2570b725 100644 --- a/src/lib/netlist/plib/mat_cr.h +++ b/src/lib/netlist/plib/mat_cr.h @@ -72,7 +72,7 @@ namespace plib ~matrix_compressed_rows_t() = default; - constexpr index_type size() const { return (N>0) ? N : m_size; } + constexpr index_type size() const { return static_cast((N>0) ? N : m_size); } void set_scalar(const T scalar) { diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h index da404be279f..793ad1ce553 100644 --- a/src/lib/netlist/plib/palloc.h +++ b/src/lib/netlist/plib/palloc.h @@ -46,40 +46,37 @@ namespace plib { delete [] ptr; } - template - std::unique_ptr make_unique(Args&&... args) - { - return std::unique_ptr(new T(std::forward(args)...)); - } - - template - std::unique_ptr make_unique_base(Args&&... args) - { - std::unique_ptr ret(new DC(std::forward(args)...)); - return ret; - } - - template + template > class owned_ptr { - private: + public: owned_ptr() : m_ptr(nullptr), m_is_owned(true) { } - public: + + template + friend class owned_ptr; + owned_ptr(SC *p, bool owned) noexcept - : m_ptr(p), m_is_owned(owned) + : m_ptr(p), m_deleter(), m_is_owned(owned) + { } + + owned_ptr(SC *p, bool owned, D deleter) noexcept + : m_ptr(p), m_deleter(deleter), m_is_owned(owned) { } + owned_ptr(const owned_ptr &r) = delete; owned_ptr & operator =(owned_ptr &r) = delete; - template - owned_ptr & operator =(owned_ptr &&r) + template + owned_ptr & operator =(owned_ptr &&r) { if (m_is_owned && (m_ptr != nullptr)) - delete m_ptr; + //delete m_ptr; + m_deleter(m_ptr); m_is_owned = r.m_is_owned; m_ptr = r.m_ptr; + m_deleter = r.m_deleter; r.m_is_owned = false; r.m_ptr = nullptr; return *this; @@ -89,50 +86,43 @@ namespace plib { { m_is_owned = r.m_is_owned; m_ptr = r.m_ptr; + m_deleter = r.m_deleter; r.m_is_owned = false; r.m_ptr = nullptr; } owned_ptr &operator=(owned_ptr &&r) noexcept { + if (m_is_owned && (m_ptr != nullptr)) + //delete m_ptr; + m_deleter(m_ptr); m_is_owned = r.m_is_owned; m_ptr = r.m_ptr; + m_deleter = r.m_deleter; r.m_is_owned = false; r.m_ptr = nullptr; return *this; } - template - owned_ptr(owned_ptr &&r) noexcept + template + owned_ptr(owned_ptr &&r) noexcept { m_ptr = static_cast(r.get()); m_is_owned = r.is_owned(); + m_deleter = r.m_deleter; r.release(); } ~owned_ptr() { if (m_is_owned && (m_ptr != nullptr)) - delete m_ptr; + { + //delete m_ptr; + m_deleter(m_ptr); + } m_is_owned = false; m_ptr = nullptr; } - template - static owned_ptr Create(Args&&... args) - { - owned_ptr a; - auto *x = new DC(std::forward(args)...); - a.m_ptr = static_cast(x); - return std::move(a); - } - - template - static owned_ptr Create(Args&&... args) - { - owned_ptr a; - a.m_ptr = new SC(std::forward(args)...); - return std::move(a); - } SC * release() { SC *tmp = m_ptr; @@ -148,9 +138,24 @@ namespace plib { SC * get() const { return m_ptr; } private: SC *m_ptr; + D m_deleter; bool m_is_owned; }; + + template + std::unique_ptr make_unique(Args&&... args) + { + return std::unique_ptr(new T(std::forward(args)...)); + } + + template + static owned_ptr make_owned(Args&&... args) + { + owned_ptr a(new T(std::forward(args)...), true); + return std::move(a); + } + } // namespace plib #endif /* PALLOC_H_ */ diff --git a/src/lib/netlist/plib/parray.h b/src/lib/netlist/plib/parray.h index e3e15df5539..5fded97d1e9 100644 --- a/src/lib/netlist/plib/parray.h +++ b/src/lib/netlist/plib/parray.h @@ -109,8 +109,9 @@ namespace plib { const FT * data() const noexcept { return m_a.data(); } private: - base_type m_a; - size_type m_size; + PALIGNAS_VECTOROPT() + base_type m_a; + size_type m_size; }; } // namespace plib diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h index 71a5f25e0e8..cc92a42c827 100644 --- a/src/lib/netlist/plib/pconfig.h +++ b/src/lib/netlist/plib/pconfig.h @@ -33,6 +33,20 @@ #define PHAS_INT128 (0) #endif +/* + * Standard alignment macros + */ + +#define PALIGNAS_CACHELINE() PALIGNAS(64) +#define PALIGNAS_VECTOROPT() PALIGNAS(64) + +/* Breaks mame build on windows due to -Wattribute */ +#if defined(_WIN32) && defined(__GNUC__) +#define PALIGNAS(x) +#else +#define PALIGNAS(x) alignas(x) +#endif + /*============================================================ * Check for CPP Version * diff --git a/src/lib/netlist/plib/pmempool.h b/src/lib/netlist/plib/pmempool.h index 2e15076b477..f5691aa2c43 100644 --- a/src/lib/netlist/plib/pmempool.h +++ b/src/lib/netlist/plib/pmempool.h @@ -1,7 +1,7 @@ // license:GPL-2.0+ // copyright-holders:Couriersud /* - * palloc.h + * pmempool.h * */ @@ -89,25 +89,28 @@ namespace plib { { } - COPYASSIGNMOVE(mempool, delete) ~mempool() { + for (auto & b : m_blocks) { if (b->m_num_alloc != 0) { + plib::perrlogger("Found {} info blocks\n", sinfo().size()); plib::perrlogger("Found block with {} dangling allocations\n", b->m_num_alloc); } ::operator delete(b->m_data); } } - - void *alloc(size_t size) + void *alloc(size_t size, size_t align) { - size_t rs = (size + m_min_align - 1) & ~(m_min_align - 1); + if (align < m_min_align) + align = m_min_align; + + size_t rs = (size + align - 1) & ~(align - 1); for (auto &b : m_blocks) { if (b->m_free > rs) @@ -115,8 +118,11 @@ namespace plib { b->m_free -= rs; b->m_num_alloc++; auto ret = reinterpret_cast(b->m_data + b->m_cur); + auto capacity(rs); + std::align(align, size, ret, capacity); sinfo().insert({ ret, info(b, b->m_cur)}); b->m_cur += rs; + return ret; } } @@ -125,15 +131,20 @@ namespace plib { b->m_num_alloc = 1; b->m_free = m_min_alloc - rs; auto ret = reinterpret_cast(b->m_data + b->m_cur); + auto capacity(rs); + std::align(align, size, ret, capacity); sinfo().insert({ ret, info(b, b->m_cur)}); b->m_cur += rs; return ret; } } - void free(void *ptr) + static void free(void *ptr) { - info i = sinfo().find(ptr)->second; + auto it = sinfo().find(ptr); + if (it == sinfo().end()) + printf("pointer not found\n"); + info i = it->second; block *b = i.m_block; if (b->m_num_alloc == 0) throw plib::pexception("mempool::free - double free was called\n"); @@ -143,11 +154,88 @@ namespace plib { //b->cur_ptr = b->data; } b->m_num_alloc--; + //printf("Freeing in block %p %lu\n", b, b->m_num_alloc); + sinfo().erase(it); } + template + struct pool_deleter + { + constexpr pool_deleter() noexcept = default; + + template::value>::type> + pool_deleter(const pool_deleter&) noexcept { } + + void operator()(T *p) const + { + p->~T(); + mempool::free(p); + } + }; + + template + using poolptr = plib::owned_ptr>; + + template + poolptr make_poolptr(Args&&... args) + { + auto mem = this->alloc(sizeof(T), alignof(T)); + auto *obj = new (mem) T(std::forward(args)...); + poolptr a(obj, true); + return std::move(a); + } }; + class mempool_default + { + private: + + size_t m_min_alloc; + size_t m_min_align; + + public: + + mempool_default(size_t min_alloc, size_t min_align) + : m_min_alloc(min_alloc), m_min_align(min_align) + { + } + + COPYASSIGNMOVE(mempool_default, delete) + + ~mempool_default() + { + } + + void *alloc(size_t size) + { + plib::unused_var(m_min_alloc); // -Wunused-private-field fires without + plib::unused_var(m_min_align); + + return ::operator new(size); + } + + static void free(void *ptr) + { + ::operator delete(ptr); + } + + template + using poolptr = plib::owned_ptr; + + template + poolptr make_poolptr(Args&&... args) + { + auto mem(alloc(sizeof(T))); + auto *obj = new (mem) T(std::forward(args)...); + poolptr a(obj, true); + return std::move(a); + } + + }; + + } // namespace plib #endif /* PMEMPOOL_H_ */ diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp index 81ef785daee..9d8f3af001a 100644 --- a/src/lib/netlist/prg/nltool.cpp +++ b/src/lib/netlist/prg/nltool.cpp @@ -138,7 +138,7 @@ std::unique_ptr netlist_data_folder_t::stream(const pstring &fil pstring name = m_folder + "/" + file; try { - auto strm = plib::make_unique_base(name); + auto strm = plib::make_unique(name); return strm; } catch (const plib::pexception &e) @@ -189,10 +189,9 @@ public: setup().add_define(d); for (auto & r : roms) - setup().register_source(plib::make_unique_base(setup(), r)); + setup().register_source(plib::make_unique(setup(), r)); - setup().register_source(plib::make_unique_base(setup(), filename)); + setup().register_source(plib::make_unique(setup(), filename)); setup().include(name); create_dynamic_logs(logs); @@ -525,8 +524,7 @@ void tool_app_t::create_header() nt.log().verbose.set_enabled(false); nt.log().warning.set_enabled(false); - nt.setup().register_source(plib::make_unique_base(nt.setup(), "dummy", &netlist_dummy)); + nt.setup().register_source(plib::make_unique(nt.setup(), "dummy", &netlist_dummy)); nt.setup().include("dummy"); pout("// license:GPL-2.0+\n"); @@ -570,8 +568,7 @@ void tool_app_t::create_docheader() nt.log().verbose.set_enabled(false); nt.log().warning.set_enabled(false); - nt.setup().register_source(plib::make_unique_base(nt.setup(), "dummy", &netlist_dummy)); + nt.setup().register_source(plib::make_unique(nt.setup(), "dummy", &netlist_dummy)); nt.setup().include("dummy"); std::vector devs; @@ -623,14 +620,13 @@ void tool_app_t::listdevices() netlist::factory::list_t &list = nt.setup().factory(); - nt.setup().register_source(plib::make_unique_base(nt.setup(), "dummy", &netlist_dummy)); + nt.setup().register_source(plib::make_unique(nt.setup(), "dummy", &netlist_dummy)); nt.setup().include("dummy"); nt.setup().prepare_to_run(); - std::vector> devs; + std::vector> devs; for (auto & f : list) { diff --git a/src/lib/netlist/solver/nld_matrix_solver.cpp b/src/lib/netlist/solver/nld_matrix_solver.cpp index 3bd55a40d35..36c8f2fb551 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.cpp +++ b/src/lib/netlist/solver/nld_matrix_solver.cpp @@ -143,7 +143,7 @@ void matrix_solver_t::setup_base(analog_net_t::list_t &nets) { pstring nname = this->name() + "." + pstring(plib::pfmt("m{1}")(m_inps.size())); nl_assert(p->net().is_analog()); - auto net_proxy_output_u = plib::make_unique(*this, nname, static_cast(&p->net())); + auto net_proxy_output_u = pool().make_poolptr(*this, nname, static_cast(&p->net())); net_proxy_output = net_proxy_output_u.get(); m_inps.push_back(std::move(net_proxy_output_u)); } diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h index 0d34499f56e..97ca20448f9 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.h +++ b/src/lib/netlist/solver/nld_matrix_solver.h @@ -205,7 +205,7 @@ protected: std::vector> m_terms; std::vector m_nets; - std::vector> m_inps; + std::vector> m_inps; std::vector> m_rails_temp; diff --git a/src/lib/netlist/solver/nld_ms_gmres.h b/src/lib/netlist/solver/nld_ms_gmres.h index 16dec115934..3cd88dea429 100644 --- a/src/lib/netlist/solver/nld_ms_gmres.h +++ b/src/lib/netlist/solver/nld_ms_gmres.h @@ -105,7 +105,7 @@ namespace devices { const std::size_t iN = this->size(); - alignas(128) plib::parray RHS(iN); + plib::parray RHS(iN); //float_type new_V[storage_N]; m_ops.m_mat.set_scalar(0.0); diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp index 3982f88b4c0..9ed380020f4 100644 --- a/src/lib/netlist/solver/nld_solver.cpp +++ b/src/lib/netlist/solver/nld_solver.cpp @@ -122,13 +122,13 @@ NETLIB_UPDATE(solver) } template -std::unique_ptr create_it(netlist_state_t &nl, pstring name, solver_parameters_t ¶ms, std::size_t size) +poolptr create_it(netlist_state_t &nl, pstring name, solver_parameters_t ¶ms, std::size_t size) { - return plib::make_unique(nl, name, ¶ms, size); + return pool().make_poolptr(nl, name, ¶ms, size); } template -std::unique_ptr NETLIB_NAME(solver)::create_solver(std::size_t size, const pstring &solvername) +poolptr NETLIB_NAME(solver)::create_solver(std::size_t size, const pstring &solvername) { if (m_method() == "SOR_MAT") { @@ -172,7 +172,7 @@ std::unique_ptr NETLIB_NAME(solver)::create_solver(std::size_t else { log().fatal(MF_1_UNKNOWN_SOLVER_TYPE, m_method()); - return nullptr; + return poolptr(); } } @@ -276,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) { - std::unique_ptr ms; + poolptr ms; std::size_t net_count = grp.size(); pstring sname = plib::pfmt("Solver_{1}")(m_mat_solvers.size()); @@ -285,13 +285,13 @@ void NETLIB_NAME(solver)::post_start() #if 1 case 1: if (use_specific) - ms = plib::make_unique>(state(), sname, &m_params); + ms = pool().make_poolptr>(state(), sname, &m_params); else ms = create_solver(1, sname); break; case 2: if (use_specific) - ms = plib::make_unique>(state(), sname, &m_params); + ms = pool().make_poolptr>(state(), sname, &m_params); else ms = create_solver(2, sname); break; diff --git a/src/lib/netlist/solver/nld_solver.h b/src/lib/netlist/solver/nld_solver.h index 4bc4aea3d60..1ba15fed64a 100644 --- a/src/lib/netlist/solver/nld_solver.h +++ b/src/lib/netlist/solver/nld_solver.h @@ -97,14 +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 - std::unique_ptr create_solver(std::size_t size, const pstring &solvername); + poolptr create_solver(std::size_t size, const pstring &solvername); }; } //namespace devices -- cgit v1.2.3-70-g09d2 From 6207d7d2d3262718c78c143681a4c609a7e72452 Mon Sep 17 00:00:00 2001 From: couriersud Date: Mon, 18 Feb 2019 20:21:53 +0100 Subject: netlist: tick off some issues clang-tidy highlights. (nw) --- src/lib/netlist/build/makefile | 2 +- src/lib/netlist/devices/nld_74107.cpp | 8 +- src/lib/netlist/nl_base.cpp | 2 +- src/lib/netlist/nl_base.h | 13 +-- src/lib/netlist/nl_config.h | 2 +- src/lib/netlist/nl_time.h | 6 +- src/lib/netlist/plib/palloc.h | 3 +- src/lib/netlist/plib/pexception.cpp | 155 ++++++++++++++------------- src/lib/netlist/plib/pexception.h | 193 ++++++++++++++++++---------------- src/lib/netlist/plib/pfmtlog.cpp | 8 +- src/lib/netlist/plib/plists.h | 2 +- src/lib/netlist/plib/pmempool.h | 49 +++++---- src/lib/netlist/tools/nl_convert.cpp | 2 +- 13 files changed, 236 insertions(+), 209 deletions(-) (limited to 'src/lib/netlist/plib/pmempool.h') diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile index d640c8207c8..289f7a906a2 100644 --- a/src/lib/netlist/build/makefile +++ b/src/lib/netlist/build/makefile @@ -14,7 +14,7 @@ VSBUILD = $(SRC)/buildVS DOC = $(SRC)/documentation TIDY_DB = ../compile_commands.json -TIDY_FLAGSX = -checks=*,-google*,-hicpp*,-readability*,-fuchsia*,-cert-*,-android-*, +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, diff --git a/src/lib/netlist/devices/nld_74107.cpp b/src/lib/netlist/devices/nld_74107.cpp index 2bb1fadc2b8..42cd36b4448 100644 --- a/src/lib/netlist/devices/nld_74107.cpp +++ b/src/lib/netlist/devices/nld_74107.cpp @@ -22,11 +22,12 @@ namespace netlist , m_clk(*this, "CLK", NETLIB_DELEGATE(74107A, clk)) , m_Q(*this, "Q") , m_QQ(*this, "QQ") - , m_delay(delay_107A) , m_J(*this, "J") , m_K(*this, "K") , m_clrQ(*this, "CLRQ") { + m_delay[0] = delay_107A[0]; + m_delay[1] = delay_107A[1]; } friend class NETLIB_NAME(74107_dip); @@ -43,7 +44,7 @@ namespace netlist logic_output_t m_Q; logic_output_t m_QQ; - const netlist_time *m_delay; + netlist_time m_delay[2]; logic_input_t m_J; logic_input_t m_K; @@ -61,7 +62,8 @@ namespace netlist public: NETLIB_CONSTRUCTOR_DERIVED(74107, 74107A) { - m_delay = delay_107; + m_delay[0] = delay_107[0]; + m_delay[1] = delay_107[1]; } }; diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index c99bc1d116b..bb2e2daafdd 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -44,7 +44,6 @@ namespace detail ret = ::operator new(size); return ret; } -#endif void object_t::operator delete (void * mem) { if (mem) @@ -55,6 +54,7 @@ namespace detail ::operator delete(mem); } } +#endif } // namespace detail diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 24f57c979c1..dc33e8c6698 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -71,7 +71,7 @@ class NETLIB_NAME(name) : public device_t /*! Used to define the destructor of a netlist device. * The use of a destructor for netlist device should normally not be necessary. */ -#define NETLIB_DESTRUCTOR(name) public: virtual ~NETLIB_NAME(name)() +#define NETLIB_DESTRUCTOR(name) public: virtual ~NETLIB_NAME(name)() noexcept /*! Define an extended constructor and add further parameters to it. * The macro allows to add further parameters to a device constructor. This is @@ -418,11 +418,12 @@ namespace netlist */ pstring name() const; +#if 0 void * operator new (size_t size, void *ptr) { plib::unused_var(size); return ptr; } void operator delete (void *ptr, void *) { plib::unused_var(ptr); } - void * operator new (size_t size) = delete; - void operator delete (void * mem); + void operator delete (void * mem) = delete; +#endif protected: ~object_t() noexcept = default; // only childs should be destructible @@ -451,7 +452,7 @@ namespace netlist const netlist_t & exec() const noexcept { return m_netlist; } protected: - ~netlist_ref() = default; // prohibit polymorphic destruction + ~netlist_ref() noexcept = default; // prohibit polymorphic destruction private: netlist_t & m_netlist; @@ -941,7 +942,7 @@ namespace netlist param_type_t param_type() const; protected: - virtual ~param_t() = default; /* not intended to be destroyed */ + virtual ~param_t() noexcept = default; /* not intended to be destroyed */ void update_param(); @@ -1182,7 +1183,7 @@ namespace netlist COPYASSIGNMOVE(device_t, delete) - ~device_t() override = default; + ~device_t() noexcept override = default; setup_t &setup(); const setup_t &setup() const; diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h index de9a370db2f..efe74002354 100644 --- a/src/lib/netlist/nl_config.h +++ b/src/lib/netlist/nl_config.h @@ -28,7 +28,7 @@ * Your mileage may vary. * */ -#define USE_MEMPOOL (0) +#define USE_MEMPOOL (1) /*! Store input values in logic_terminal_t. * diff --git a/src/lib/netlist/nl_time.h b/src/lib/netlist/nl_time.h index 6bd61a3f68e..4fd2b0211f1 100644 --- a/src/lib/netlist/nl_time.h +++ b/src/lib/netlist/nl_time.h @@ -141,9 +141,9 @@ namespace netlist // MACROS //============================================================ - template inline constexpr netlist_time NLTIME_FROM_NS(T &&t) { return netlist_time::from_nsec(t); } - template inline constexpr netlist_time NLTIME_FROM_US(T &&t) { return netlist_time::from_usec(t); } - template inline constexpr netlist_time NLTIME_FROM_MS(T &&t) { return netlist_time::from_msec(t); } + template inline constexpr netlist_time NLTIME_FROM_NS(T &&t) noexcept { return netlist_time::from_nsec(t); } + template inline constexpr netlist_time NLTIME_FROM_US(T &&t) noexcept { return netlist_time::from_usec(t); } + template inline constexpr netlist_time NLTIME_FROM_MS(T &&t) noexcept { return netlist_time::from_msec(t); } } // namespace netlist diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h index 793ad1ce553..c70aaa392d7 100644 --- a/src/lib/netlist/plib/palloc.h +++ b/src/lib/netlist/plib/palloc.h @@ -113,7 +113,7 @@ namespace plib { r.release(); } - ~owned_ptr() + ~owned_ptr() noexcept { if (m_is_owned && (m_ptr != nullptr)) { @@ -142,7 +142,6 @@ namespace plib { bool m_is_owned; }; - template std::unique_ptr make_unique(Args&&... args) { diff --git a/src/lib/netlist/plib/pexception.cpp b/src/lib/netlist/plib/pexception.cpp index d26fc8fd12e..93f1c24c08c 100644 --- a/src/lib/netlist/plib/pexception.cpp +++ b/src/lib/netlist/plib/pexception.cpp @@ -9,6 +9,7 @@ #include "pfmtlog.h" #include +#include #if (defined(__x86_64__) || defined(__i386__)) && defined(__linux__) #define HAS_FEENABLE_EXCEPT (1) @@ -17,101 +18,113 @@ #endif namespace plib { -//============================================================ -// Exceptions -//============================================================ -pexception::pexception(const pstring &text) -: m_text(text) -{ -} + //============================================================ + // terminate + //============================================================ + void terminate(pstring msg) noexcept + { + std::cerr << msg.c_str() << "\n"; + std::terminate(); + } -file_e::file_e(const pstring &fmt, const pstring &filename) - : pexception(pfmt(fmt)(filename)) -{ -} + //============================================================ + // Exceptions + //============================================================ -file_open_e::file_open_e(const pstring &filename) - : file_e("File open failed: {}", filename) -{ -} + pexception::pexception(const pstring &text) + : m_text(text) + { + } -file_read_e::file_read_e(const pstring &filename) - : file_e("File read failed: {}", filename) -{ -} + file_e::file_e(const pstring &fmt, const pstring &filename) + : pexception(pfmt(fmt)(filename)) + { + } -file_write_e::file_write_e(const pstring &filename) - : file_e("File write failed: {}", filename) -{ -} + file_open_e::file_open_e(const pstring &filename) + : file_e("File open failed: {}", filename) + { + } -null_argument_e::null_argument_e(const pstring &argument) - : pexception(pfmt("Null argument passed: {}")(argument)) -{ -} + file_read_e::file_read_e(const pstring &filename) + : file_e("File read failed: {}", filename) + { + } -out_of_mem_e::out_of_mem_e(const pstring &location) - : pexception(pfmt("Out of memory: {}")(location)) -{ -} + file_write_e::file_write_e(const pstring &filename) + : file_e("File write failed: {}", filename) + { + } -fpexception_e::fpexception_e(const pstring &text) - : pexception(pfmt("Out of memory: {}")(text)) -{ -} + null_argument_e::null_argument_e(const pstring &argument) + : pexception(pfmt("Null argument passed: {}")(argument)) + { + } -bool fpsignalenabler::m_enable = false; + out_of_mem_e::out_of_mem_e(const pstring &location) + : pexception(pfmt("Out of memory: {}")(location)) + { + } -fpsignalenabler::fpsignalenabler(unsigned fpexceptions) -{ -#if HAS_FEENABLE_EXCEPT - if (m_enable) + + fpexception_e::fpexception_e(const pstring &text) + : pexception(pfmt("Out of memory: {}")(text)) { - int b = 0; - if (fpexceptions & plib::FP_INEXACT) b = b | FE_INEXACT; - if (fpexceptions & plib::FP_DIVBYZERO) b = b | FE_DIVBYZERO; - if (fpexceptions & plib::FP_UNDERFLOW) b = b | FE_UNDERFLOW; - if (fpexceptions & plib::FP_OVERFLOW) b = b | FE_OVERFLOW; - if (fpexceptions & plib::FP_INVALID) b = b | FE_INVALID; - m_last_enabled = feenableexcept(b); } -#else - m_last_enabled = 0; -#endif -} -fpsignalenabler::~fpsignalenabler() -{ -#if HAS_FEENABLE_EXCEPT - if (m_enable) + bool fpsignalenabler::m_enable = false; + + fpsignalenabler::fpsignalenabler(unsigned fpexceptions) { - fedisableexcept(FE_ALL_EXCEPT); // Enable all floating point exceptions but FE_INEXACT - feenableexcept(m_last_enabled); // Enable all floating point exceptions but FE_INEXACT + #if HAS_FEENABLE_EXCEPT + if (m_enable) + { + int b = 0; + if (fpexceptions & plib::FP_INEXACT) b = b | FE_INEXACT; + if (fpexceptions & plib::FP_DIVBYZERO) b = b | FE_DIVBYZERO; + if (fpexceptions & plib::FP_UNDERFLOW) b = b | FE_UNDERFLOW; + if (fpexceptions & plib::FP_OVERFLOW) b = b | FE_OVERFLOW; + if (fpexceptions & plib::FP_INVALID) b = b | FE_INVALID; + m_last_enabled = feenableexcept(b); + } + #else + m_last_enabled = 0; + #endif + } + + + fpsignalenabler::~fpsignalenabler() + { + #if HAS_FEENABLE_EXCEPT + if (m_enable) + { + fedisableexcept(FE_ALL_EXCEPT); // Enable all floating point exceptions but FE_INEXACT + feenableexcept(m_last_enabled); // Enable all floating point exceptions but FE_INEXACT + } + #endif + } + + bool fpsignalenabler::supported() + { + return true; + } + + bool fpsignalenabler::global_enable(bool enable) + { + bool old = m_enable; + m_enable = enable; + return old; } -#endif -} - -bool fpsignalenabler::supported() -{ - return true; -} - -bool fpsignalenabler::global_enable(bool enable) -{ - bool old = m_enable; - m_enable = enable; - return old; -} } // namespace plib diff --git a/src/lib/netlist/plib/pexception.h b/src/lib/netlist/plib/pexception.h index ed0d14f5747..98d993d689b 100644 --- a/src/lib/netlist/plib/pexception.h +++ b/src/lib/netlist/plib/pexception.h @@ -14,98 +14,109 @@ #include "ptypes.h" namespace plib { -//============================================================ -// exception base -//============================================================ - -class pexception : public std::exception -{ -public: - explicit pexception(const pstring &text); - - const pstring &text() { return m_text; } - const char* what() const noexcept override { return m_text.c_str(); } - -private: - pstring m_text; -}; - -class file_e : public plib::pexception -{ -public: - file_e(const pstring &fmt, const pstring &filename); -}; - -class file_open_e : public file_e -{ -public: - explicit file_open_e(const pstring &filename); -}; - -class file_read_e : public file_e -{ -public: - explicit file_read_e(const pstring &filename); -}; - -class file_write_e : public file_e -{ -public: - explicit file_write_e(const pstring &filename); -}; - -class null_argument_e : public plib::pexception -{ -public: - explicit null_argument_e(const pstring &argument); -}; - -class out_of_mem_e : public plib::pexception -{ -public: - explicit out_of_mem_e(const pstring &location); -}; - -/* FIXME: currently only a stub for later use. More use could be added by - * using “-fnon-call-exceptions" and sigaction to enable c++ exception supported. - */ - -class fpexception_e : public pexception -{ -public: - explicit fpexception_e(const pstring &text); -}; - -static constexpr unsigned FP_INEXACT = 0x0001; -static constexpr unsigned FP_DIVBYZERO = 0x0002; -static constexpr unsigned FP_UNDERFLOW = 0x0004; -static constexpr unsigned FP_OVERFLOW = 0x0008; -static constexpr unsigned FP_INVALID = 0x00010; -static constexpr unsigned FP_ALL = 0x0001f; - -/* - * Catch SIGFPE on linux for debugging purposes. - */ - -class fpsignalenabler -{ -public: - explicit fpsignalenabler(unsigned fpexceptions); - - COPYASSIGNMOVE(fpsignalenabler, delete) - - ~fpsignalenabler(); - - /* is the functionality supported ? */ - static bool supported(); - /* returns last global enable state */ - static bool global_enable(bool enable); - -private: - int m_last_enabled; - static bool m_enable; -}; + //============================================================ + // terminate + //============================================================ + + /*! Terminate the program + * + * \note could be enhanced by setting a termination handler + */ + [[noreturn]] void terminate(pstring msg) noexcept; + + //============================================================ + // exception base + //============================================================ + + class pexception : public std::exception + { + public: + explicit pexception(const pstring &text); + + const pstring &text() { return m_text; } + const char* what() const noexcept override { return m_text.c_str(); } + + private: + pstring m_text; + }; + + class file_e : public plib::pexception + { + public: + file_e(const pstring &fmt, const pstring &filename); + }; + + class file_open_e : public file_e + { + public: + explicit file_open_e(const pstring &filename); + }; + + class file_read_e : public file_e + { + public: + explicit file_read_e(const pstring &filename); + }; + + class file_write_e : public file_e + { + public: + explicit file_write_e(const pstring &filename); + }; + + class null_argument_e : public plib::pexception + { + public: + explicit null_argument_e(const pstring &argument); + }; + + class out_of_mem_e : public plib::pexception + { + public: + explicit out_of_mem_e(const pstring &location); + }; + + /* FIXME: currently only a stub for later use. More use could be added by + * using “-fnon-call-exceptions" and sigaction to enable c++ exception supported. + */ + + class fpexception_e : public pexception + { + public: + explicit fpexception_e(const pstring &text); + }; + + static constexpr unsigned FP_INEXACT = 0x0001; + static constexpr unsigned FP_DIVBYZERO = 0x0002; + static constexpr unsigned FP_UNDERFLOW = 0x0004; + static constexpr unsigned FP_OVERFLOW = 0x0008; + static constexpr unsigned FP_INVALID = 0x00010; + static constexpr unsigned FP_ALL = 0x0001f; + + /* + * Catch SIGFPE on linux for debugging purposes. + */ + + class fpsignalenabler + { + public: + explicit fpsignalenabler(unsigned fpexceptions); + + COPYASSIGNMOVE(fpsignalenabler, delete) + + ~fpsignalenabler(); + + /* is the functionality supported ? */ + static bool supported(); + /* returns last global enable state */ + static bool global_enable(bool enable); + + private: + int m_last_enabled; + + static bool m_enable; + }; } // namespace plib diff --git a/src/lib/netlist/plib/pfmtlog.cpp b/src/lib/netlist/plib/pfmtlog.cpp index f142a0cd73f..e4e7c3d1c5c 100644 --- a/src/lib/netlist/plib/pfmtlog.cpp +++ b/src/lib/netlist/plib/pfmtlog.cpp @@ -11,9 +11,11 @@ #include #include #include +#include #include #include #include +#include namespace plib { @@ -23,7 +25,7 @@ pfmt &pfmt::format_element(const char *l, const unsigned cfmt_spec, ...) // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) va_start(ap, cfmt_spec); pstring fmt("%"); - char buf[2048]; // FIXME + std::array buf; std::size_t sl; m_arg++; @@ -81,9 +83,9 @@ pfmt &pfmt::format_element(const char *l, const unsigned cfmt_spec, ...) } else fmt += cfmt_spec; - vsprintf(buf, fmt.c_str(), ap); + std::vsnprintf(buf.data(), buf.size(), fmt.c_str(), ap); if (p != pstring::npos) - m_str = m_str.substr(0, p) + pstring(buf) + m_str.substr(p + sl); + m_str = m_str.substr(0, p) + pstring(buf.data()) + m_str.substr(p + sl); va_end(ap); return *this; } diff --git a/src/lib/netlist/plib/plists.h b/src/lib/netlist/plib/plists.h index 46a679cc81b..c11ee6fabdc 100644 --- a/src/lib/netlist/plib/plists.h +++ b/src/lib/netlist/plib/plists.h @@ -205,7 +205,7 @@ 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 {iter_t tmp(*this); operator++(); return tmp;} + 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 f5691aa2c43..91fa7d55589 100644 --- a/src/lib/netlist/plib/pmempool.h +++ b/src/lib/netlist/plib/pmempool.h @@ -23,6 +23,22 @@ namespace plib { + template + struct pool_deleter + { + constexpr pool_deleter() noexcept = default; + + template::value>::type> + pool_deleter(const pool_deleter&) noexcept { } + + void operator()(T *p) const + { + p->~T(); + P::free(p); + } + }; + //============================================================ // Memory pool //============================================================ @@ -56,8 +72,9 @@ namespace plib { struct info { info(block *b, std::size_t p) : m_block(b), m_pos(p) { } - info(const info &) = default; - info(info &&) = default; + ~info() = default; + COPYASSIGNMOVE(info, default) + block * m_block; std::size_t m_pos; }; @@ -143,11 +160,11 @@ namespace plib { { auto it = sinfo().find(ptr); if (it == sinfo().end()) - printf("pointer not found\n"); + plib::terminate("mempool::free - pointer not found\n"); info i = it->second; block *b = i.m_block; if (b->m_num_alloc == 0) - throw plib::pexception("mempool::free - double free was called\n"); + plib::terminate("mempool::free - double free was called\n"); else { //b->m_free = m_min_alloc; @@ -159,23 +176,7 @@ namespace plib { } template - struct pool_deleter - { - constexpr pool_deleter() noexcept = default; - - template::value>::type> - pool_deleter(const pool_deleter&) noexcept { } - - void operator()(T *p) const - { - p->~T(); - mempool::free(p); - } - }; - - template - using poolptr = plib::owned_ptr>; + using poolptr = plib::owned_ptr>; template poolptr make_poolptr(Args&&... args) @@ -204,9 +205,7 @@ namespace plib { COPYASSIGNMOVE(mempool_default, delete) - ~mempool_default() - { - } + ~mempool_default() = default; void *alloc(size_t size) { @@ -222,7 +221,7 @@ namespace plib { } template - using poolptr = plib::owned_ptr; + using poolptr = plib::owned_ptr>; template poolptr make_poolptr(Args&&... args) diff --git a/src/lib/netlist/tools/nl_convert.cpp b/src/lib/netlist/tools/nl_convert.cpp index 68880e379a3..95e05d27857 100644 --- a/src/lib/netlist/tools/nl_convert.cpp +++ b/src/lib/netlist/tools/nl_convert.cpp @@ -17,7 +17,7 @@ * define a model param on core device */ /* Format: external name,netlist device,model */ -static const pstring s_lib_map = +static const char * s_lib_map = "SN74LS00D, TTL_7400_DIP, 74LSXX\n" "SN74LS04D, TTL_7404_DIP, 74LSXX\n" "SN74ALS08D, TTL_7408_DIP, 74ALSXX\n" -- cgit v1.2.3-70-g09d2 From a5f37870584dc8bd5588ee32964f56462228a714 Mon Sep 17 00:00:00 2001 From: couriersud Date: Wed, 20 Feb 2019 20:16:08 +0100 Subject: netlist: fix a bug and some performance tweaks. (nw) --- src/lib/netlist/nl_config.h | 2 +- src/lib/netlist/plib/gmres.h | 2 +- src/lib/netlist/plib/pmempool.h | 15 +++++---- src/lib/netlist/plib/vector_ops.h | 53 ++++++++++++++++++++++-------- src/lib/netlist/solver/nld_matrix_solver.h | 33 ++++++++++++++----- src/lib/netlist/solver/nld_ms_sor.h | 2 +- 6 files changed, 74 insertions(+), 33 deletions(-) (limited to 'src/lib/netlist/plib/pmempool.h') diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h index efe74002354..de9a370db2f 100644 --- a/src/lib/netlist/nl_config.h +++ b/src/lib/netlist/nl_config.h @@ -28,7 +28,7 @@ * Your mileage may vary. * */ -#define USE_MEMPOOL (1) +#define USE_MEMPOOL (0) /*! Store input values in logic_terminal_t. * diff --git a/src/lib/netlist/plib/gmres.h b/src/lib/netlist/plib/gmres.h index edd15a49380..345c96b5c63 100644 --- a/src/lib/netlist/plib/gmres.h +++ b/src/lib/netlist/plib/gmres.h @@ -338,7 +338,7 @@ namespace plib plib::parray m_y; /* mr + 1 */ //plib::parray m_v[RESTART + 1]; /* mr + 1, n */ - std::array, RESTART + 1> m_v; /* mr + 1, n */ + plib::parray, RESTART + 1> m_v; /* mr + 1, n */ std::size_t m_size; diff --git a/src/lib/netlist/plib/pmempool.h b/src/lib/netlist/plib/pmempool.h index 91fa7d55589..80e30ada324 100644 --- a/src/lib/netlist/plib/pmempool.h +++ b/src/lib/netlist/plib/pmempool.h @@ -48,17 +48,18 @@ namespace plib { private: struct block { - block(mempool *mp) + block(mempool *mp, std::size_t min_bytes) : m_num_alloc(0) - , m_free(mp->m_min_alloc) , m_cur(0) , m_data(nullptr) , m_mempool(mp) { - std::size_t alloc_bytes = (mp->m_min_alloc + mp->m_min_align - 1) & ~(mp->m_min_align - 1); + min_bytes = std::max(mp->m_min_alloc, min_bytes); + m_free = min_bytes; + std::size_t alloc_bytes = (min_bytes + mp->m_min_align - 1) & ~(mp->m_min_align - 1); m_data_allocated = static_cast(::operator new(alloc_bytes)); void *r = m_data_allocated; - std::align(mp->m_min_align, mp->m_min_alloc, r, alloc_bytes); + std::align(mp->m_min_align, min_bytes, r, alloc_bytes); m_data = reinterpret_cast(r); } std::size_t m_num_alloc; @@ -80,9 +81,9 @@ namespace plib { }; - block * new_block() + block * new_block(std::size_t min_bytes) { - auto *b = new block(this); + auto *b = new block(this, min_bytes); m_blocks.push_back(b); return b; } @@ -144,7 +145,7 @@ namespace plib { } } { - block *b = new_block(); + block *b = new_block(rs); b->m_num_alloc = 1; b->m_free = m_min_alloc - rs; auto ret = reinterpret_cast(b->m_data + b->m_cur); diff --git a/src/lib/netlist/plib/vector_ops.h b/src/lib/netlist/plib/vector_ops.h index dde6c7c4049..f5a9e336d0d 100644 --- a/src/lib/netlist/plib/vector_ops.h +++ b/src/lib/netlist/plib/vector_ops.h @@ -28,7 +28,7 @@ namespace plib template void vec_set_scalar (const std::size_t n, VT &v, T && scalar) { - const T s(std::forward(scalar)); + const typename std::remove_reference::type s(std::forward(scalar)); for ( std::size_t i = 0; i < n; i++ ) v[i] = s; } @@ -43,25 +43,50 @@ namespace plib template T vec_mult (const std::size_t n, const V1 & v1, const V2 & v2 ) { - T value = 0.0; - for ( std::size_t i = 0; i < n; i++ ) - value += v1[i] * v2[i]; - return value; + PALIGNAS_VECTOROPT() T value[8] = {0}; + for (std::size_t i = 0; i < n ; i++ ) + { + value[i & 7] += v1[i] * v2[i]; + } + return value[0] + value[1] + value[2] + value[3] + value[4] + value[5] + value[6] + value[7]; } template T vec_mult2 (const std::size_t n, const VT &v) { - T value = 0.0; - for ( std::size_t i = 0; i < n; i++ ) - value += v[i] * v[i]; - return value; + PALIGNAS_VECTOROPT() T value[8] = {0}; + for (std::size_t i = 0; i < n ; i++ ) + { + value[i & 7] += v[i] * v[i]; + } + return value[0] + value[1] + value[2] + value[3] + value[4] + value[5] + value[6] + value[7]; + } + + template + T vec_sum (const std::size_t n, const VT &v) + { + if (n<8) + { + PALIGNAS_VECTOROPT() T value(0); + for (std::size_t i = 0; i < n ; i++ ) + value += v[i]; + + return value; + } + else + { + PALIGNAS_VECTOROPT() T value[8] = {0}; + for (std::size_t i = 0; i < n ; i++ ) + value[i & 7] += v[i]; + + return ((value[0] + value[1]) + (value[2] + value[3])) + ((value[4] + value[5]) + (value[6] + value[7])); + } } template void vec_mult_scalar (const std::size_t n, const VV & v, T && scalar, VR & result) { - const T s(std::forward(scalar)); + const typename std::remove_reference::type s(std::forward(scalar)); for ( std::size_t i = 0; i < n; i++ ) result[i] = s * v[i]; } @@ -69,9 +94,9 @@ namespace plib template void vec_add_mult_scalar (const std::size_t n, const VV & v, T && scalar, VR & result) { - const T s(std::forward(scalar)); + const typename std::remove_reference::type s(std::forward(scalar)); for ( std::size_t i = 0; i < n; i++ ) - result[i] = result[i] + s * v[i]; + result[i] += s * v[i]; } template @@ -98,9 +123,9 @@ namespace plib template void vec_scale(const std::size_t n, V & v, T &&scalar) { - const T s(std::forward(scalar)); + const typename std::remove_reference::type s(std::forward(scalar)); for ( std::size_t i = 0; i < n; i++ ) - v[i] = s * v[i]; + v[i] *= s; } template diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h index 97ca20448f9..803437d76e2 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.h +++ b/src/lib/netlist/solver/nld_matrix_solver.h @@ -11,6 +11,7 @@ #include "netlist/nl_base.h" #include "netlist/nl_errstr.h" #include "netlist/plib/putil.h" +#include "netlist/plib/vector_ops.h" namespace netlist { @@ -54,27 +55,41 @@ public: void set_pointers(); + /* FIXME: this works a bit better for larger matrices */ template - void fill_matrix(AP &tcr, FT &RHS) + void fill_matrix/*_larger*/(AP &tcr, FT &RHS) { - FT gtot_t = 0.0; - FT RHS_t = 0.0; const std::size_t term_count = this->count(); const std::size_t railstart = this->m_railstart; - const FT * const * other_cur_analog = this->connected_net_V(); + const FT * const * other_cur_analog = m_connected_net_V.data(); + const FT * p_go = m_go.data(); + const FT * p_gt = m_gt.data(); + const FT * p_Idr = m_Idr.data(); for (std::size_t i = 0; i < railstart; i++) { - *tcr[i] -= m_go[i]; - gtot_t += m_gt[i]; - RHS_t += m_Idr[i]; + *tcr[i] -= p_go[i]; + } + +#if 1 + FT gtot_t = 0.0; + FT RHS_t = 0.0; + + for (std::size_t i = 0; i < term_count; i++) + { + gtot_t += p_gt[i]; + RHS_t += p_Idr[i]; } + // FIXME: Code above is faster than vec_sum - Check this +#else + auto gtot_t = plib::vec_sum(term_count, p_gt); + auto RHS_t = plib::vec_sum(term_count, p_Idr); +#endif for (std::size_t i = railstart; i < term_count; i++) { - RHS_t += (m_Idr[i] + m_go[i] * *other_cur_analog[i]); - gtot_t += m_gt[i]; + RHS_t += (/*m_Idr[i]*/ + p_go[i] * *other_cur_analog[i]); } RHS = RHS_t; diff --git a/src/lib/netlist/solver/nld_ms_sor.h b/src/lib/netlist/solver/nld_ms_sor.h index 5261524cba1..5dfc395963a 100644 --- a/src/lib/netlist/solver/nld_ms_sor.h +++ b/src/lib/netlist/solver/nld_ms_sor.h @@ -88,7 +88,7 @@ unsigned matrix_solver_SOR_t::vsolve_non_dynamic(const bool newton_rap const float_type * const gt = this->m_terms[k]->gt(); const float_type * const go = this->m_terms[k]->go(); const float_type * const Idr = this->m_terms[k]->Idr(); - const float_type * const *other_cur_analog = this->m_terms[k]->connected_net_V(); + auto other_cur_analog = this->m_terms[k]->connected_net_V(); this->m_new_V[k] = this->m_nets[k]->Q_Analog(); -- cgit v1.2.3-70-g09d2 From cf73ccc764d574284bef4ce95ee5bc3e9089f053 Mon Sep 17 00:00:00 2001 From: couriersud Date: Thu, 21 Feb 2019 22:59:17 +0100 Subject: netlist: memory management. [Couriersud] Memory management in plib is now alignment-aware. All allocations respect c++11 alignas. Selected classes like parray and aligned_vector also provide hints (__builtin_assume_aligned) to g++ and clang. The alignment optimizations have little impact on the current use cases. They only become effective on bigger data processing. What has a measurable impact is memory pooling. This speeds up netlist games like breakout and pong by about 5%. Tested with linux, macosx and windows cross builds. All features are disabled since I can not rule out they may temporarily break more exotic builds. --- src/devices/machine/netlist.cpp | 10 +- src/lib/netlist/devices/nlid_truthtable.cpp | 4 +- src/lib/netlist/devices/nlid_truthtable.h | 2 +- src/lib/netlist/nl_base.cpp | 8 +- src/lib/netlist/nl_base.h | 20 +-- src/lib/netlist/nl_factory.cpp | 2 +- src/lib/netlist/nl_factory.h | 10 +- src/lib/netlist/nl_setup.cpp | 16 +-- src/lib/netlist/nl_setup.h | 18 +-- src/lib/netlist/plib/palloc.h | 193 +++++++++++++++++++++++++-- src/lib/netlist/plib/parray.h | 17 ++- src/lib/netlist/plib/pconfig.h | 15 ++- src/lib/netlist/plib/pdynlib.cpp | 8 +- src/lib/netlist/plib/pmempool.h | 45 ++++--- src/lib/netlist/plib/pstate.h | 3 +- src/lib/netlist/plib/pstream.cpp | 12 +- src/lib/netlist/plib/pstream.h | 14 +- src/lib/netlist/prg/nltool.cpp | 6 +- src/lib/netlist/prg/nlwav.cpp | 16 +-- src/lib/netlist/solver/nld_matrix_solver.cpp | 8 +- src/lib/netlist/solver/nld_matrix_solver.h | 16 +-- src/lib/netlist/solver/nld_ms_gcr.h | 3 +- src/lib/netlist/solver/nld_ms_gmres.h | 2 +- src/lib/netlist/solver/nld_solver.cpp | 36 +++-- src/lib/netlist/solver/nld_solver.h | 3 + src/lib/netlist/tools/nl_convert.cpp | 2 +- src/lib/netlist/tools/nl_convert.h | 8 +- 27 files changed, 358 insertions(+), 139 deletions(-) (limited to 'src/lib/netlist/plib/pmempool.h') diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp index 1eccdd3f291..7beb745cbf2 100644 --- a/src/devices/machine/netlist.cpp +++ b/src/devices/machine/netlist.cpp @@ -218,7 +218,7 @@ public: { } - virtual std::unique_ptr stream(const pstring &name) override; + virtual plib::unique_ptr stream(const pstring &name) override; private: device_t &m_dev; pstring m_name; @@ -229,7 +229,7 @@ class netlist_data_memregions_t : public netlist::source_t public: netlist_data_memregions_t(device_t &dev); - virtual std::unique_ptr stream(const pstring &name) override; + virtual plib::unique_ptr stream(const pstring &name) override; private: device_t &m_dev; @@ -240,7 +240,7 @@ private: // memregion source support // ---------------------------------------------------------------------------------------- -std::unique_ptr netlist_source_memregion_t::stream(const pstring &name) +plib::unique_ptr netlist_source_memregion_t::stream(const pstring &name) { //memory_region *mem = static_cast(setup().setup().exec()).machine().root_device().memregion(m_name.c_str()); memory_region *mem = m_dev.machine().root_device().memregion(m_name.c_str()); @@ -252,7 +252,7 @@ netlist_data_memregions_t::netlist_data_memregions_t(device_t &dev) { } -std::unique_ptr netlist_data_memregions_t::stream(const pstring &name) +plib::unique_ptr netlist_data_memregions_t::stream(const pstring &name) { //memory_region *mem = static_cast(setup().setup().exec()).parent().memregion(name.c_str()); memory_region *mem = m_dev.memregion(name.c_str()); @@ -264,7 +264,7 @@ std::unique_ptr netlist_data_memregions_t::stream(const pstring { // This should be the last data provider being called - last resort fatalerror("data named %s not found in device rom regions\n", name.c_str()); - return std::unique_ptr(nullptr); + return plib::unique_ptr(nullptr); } } diff --git a/src/lib/netlist/devices/nlid_truthtable.cpp b/src/lib/netlist/devices/nlid_truthtable.cpp index b37fd31abf6..cadbdf0b7bb 100644 --- a/src/lib/netlist/devices/nlid_truthtable.cpp +++ b/src/lib/netlist/devices/nlid_truthtable.cpp @@ -464,9 +464,9 @@ netlist_base_factory_truthtable_t::netlist_base_factory_truthtable_t(const pstri ENTRYY(n, 4, s); ENTRYY(n, 5, s); ENTRYY(n, 6, s); \ ENTRYY(n, 7, s); ENTRYY(n, 8, s) -std::unique_ptr tt_factory_create(tt_desc &desc, const pstring &sourcefile) +plib::unique_ptr tt_factory_create(tt_desc &desc, const pstring &sourcefile) { - std::unique_ptr ret; + plib::unique_ptr ret; switch (desc.ni * 100 + desc.no) { diff --git a/src/lib/netlist/devices/nlid_truthtable.h b/src/lib/netlist/devices/nlid_truthtable.h index abc6b108ce5..a4b9e1e238e 100644 --- a/src/lib/netlist/devices/nlid_truthtable.h +++ b/src/lib/netlist/devices/nlid_truthtable.h @@ -225,7 +225,7 @@ namespace devices }; /* the returned element is still missing a pointer to the family ... */ - std::unique_ptr tt_factory_create(tt_desc &desc, const pstring &sourcefile); + plib::unique_ptr tt_factory_create(tt_desc &desc, const pstring &sourcefile); } //namespace devices } // namespace netlist diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index bb2e2daafdd..3d6a8cf04b0 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -236,7 +236,7 @@ detail::terminal_type detail::core_terminal_t::type() const // netlist_t // ---------------------------------------------------------------------------------------- -netlist_t::netlist_t(const pstring &aname, std::unique_ptr callbacks) +netlist_t::netlist_t(const pstring &aname, plib::unique_ptr callbacks) : m_state(plib::make_unique(aname, std::move(callbacks), plib::make_unique(*this))) // FIXME, ugly but needed to have netlist_state_t constructed first @@ -256,8 +256,8 @@ netlist_t::netlist_t(const pstring &aname, std::unique_ptr callback // ---------------------------------------------------------------------------------------- netlist_state_t::netlist_state_t(const pstring &aname, - std::unique_ptr &&callbacks, - std::unique_ptr &&setup) + plib::unique_ptr &&callbacks, + plib::unique_ptr &&setup) : m_name(aname) , m_state() , m_callbacks(std::move(callbacks)) // Order is important here @@ -1035,7 +1035,7 @@ nl_double param_model_t::model_value(const pstring &entity) } -std::unique_ptr param_data_t::stream() +plib::unique_ptr param_data_t::stream() { return device().setup().get_data_stream(Value()); } diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 5975eaa4011..7f65a33e6bf 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -30,7 +30,7 @@ #include "nl_time.h" //============================================================ -// MACROS / New Syntax999 +// MACROS / New Syntax //============================================================ /*! Construct a netlist device name */ @@ -1070,7 +1070,7 @@ namespace netlist { } - std::unique_ptr stream(); + plib::unique_ptr stream(); protected: void changed() override { } }; @@ -1276,8 +1276,8 @@ namespace netlist /* need to preserve order of device creation ... */ using devices_collection_type = std::vector>>; netlist_state_t(const pstring &aname, - std::unique_ptr &&callbacks, - std::unique_ptr &&setup); + plib::unique_ptr &&callbacks, + plib::unique_ptr &&setup); COPYASSIGNMOVE(netlist_state_t, delete) @@ -1371,7 +1371,7 @@ namespace netlist } /* sole use is to manage lifetime of family objects */ - std::vector>> m_family_cache; + std::vector>> m_family_cache; setup_t &setup() NL_NOEXCEPT { return *m_setup; } const setup_t &setup() const NL_NOEXCEPT { return *m_setup; } @@ -1387,11 +1387,11 @@ namespace netlist void reset(); pstring m_name; - std::unique_ptr m_lib; // external lib needs to be loaded as long as netlist exists + plib::unique_ptr m_lib; // external lib needs to be loaded as long as netlist exists plib::state_manager_t m_state; - std::unique_ptr m_callbacks; + plib::unique_ptr m_callbacks; log_type m_log; - std::unique_ptr m_setup; + plib::unique_ptr m_setup; nets_collection_type m_nets; /* sole use is to manage lifetime of net objects */ @@ -1409,7 +1409,7 @@ namespace netlist { public: - explicit netlist_t(const pstring &aname, std::unique_ptr callbacks); + explicit netlist_t(const pstring &aname, plib::unique_ptr callbacks); COPYASSIGNMOVE(netlist_t, delete) @@ -1454,7 +1454,7 @@ namespace netlist void print_stats() const; private: - std::unique_ptr m_state; + plib::unique_ptr m_state; devices::NETLIB_NAME(solver) * m_solver; /* mostly rw */ diff --git a/src/lib/netlist/nl_factory.cpp b/src/lib/netlist/nl_factory.cpp index 793a0b4d1bc..c9d5ea7e29f 100644 --- a/src/lib/netlist/nl_factory.cpp +++ b/src/lib/netlist/nl_factory.cpp @@ -52,7 +52,7 @@ namespace netlist { namespace factory { } - void list_t::register_device(std::unique_ptr &&factory) + void list_t::register_device(plib::unique_ptr &&factory) { for (auto & e : *this) if (e->name() == factory->name()) diff --git a/src/lib/netlist/nl_factory.h b/src/lib/netlist/nl_factory.h index 3ed98b19152..cd7e74944eb 100644 --- a/src/lib/netlist/nl_factory.h +++ b/src/lib/netlist/nl_factory.h @@ -25,7 +25,7 @@ NETLIB_DEVICE_IMPL_BASE(ns, chip, chip, p_name, p_def_param) \ #define NETLIB_DEVICE_IMPL_BASE(ns, p_alias, chip, p_name, p_def_param) \ - static std::unique_ptr NETLIB_NAME(p_alias ## _c) \ + static plib::unique_ptr NETLIB_NAME(p_alias ## _c) \ (const pstring &classname) \ { \ return plib::make_unique>(p_name, classname, p_def_param, pstring(__FILE__)); \ @@ -91,7 +91,7 @@ namespace factory { } }; - class list_t : public std::vector> + class list_t : public std::vector> { public: explicit list_t(log_type &alog); @@ -106,7 +106,7 @@ namespace factory { register_device(plib::make_unique>(name, classname, def_param)); } - void register_device(std::unique_ptr &&factory); + void register_device(plib::unique_ptr &&factory); element_t * factory_by_name(const pstring &devname); @@ -124,10 +124,10 @@ namespace factory { // factory_creator_ptr_t // ----------------------------------------------------------------------------- - using constructor_ptr_t = std::unique_ptr (*)(const pstring &classname); + using constructor_ptr_t = plib::unique_ptr (*)(const pstring &classname); template - std::unique_ptr constructor_t(const pstring &name, const pstring &classname, + plib::unique_ptr constructor_t(const pstring &name, const pstring &classname, const pstring &def_param) { return plib::make_unique>(name, classname, def_param); diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp index b9196852878..b892fb4571c 100644 --- a/src/lib/netlist/nl_setup.cpp +++ b/src/lib/netlist/nl_setup.cpp @@ -219,7 +219,7 @@ namespace netlist return false; } - bool nlparse_t::parse_stream(std::unique_ptr &&istrm, const pstring &name) + bool nlparse_t::parse_stream(plib::unique_ptr &&istrm, const pstring &name) { return parser_t(std::move(plib::ppreprocessor(&m_defines).process(std::move(istrm))), *this).parse(name); } @@ -986,7 +986,7 @@ const logic_family_desc_t *setup_t::family_from_model(const pstring &model) // Sources // ---------------------------------------------------------------------------------------- -std::unique_ptr setup_t::get_data_stream(const pstring &name) +plib::unique_ptr setup_t::get_data_stream(const pstring &name) { for (auto &source : m_sources) { @@ -998,7 +998,7 @@ std::unique_ptr setup_t::get_data_stream(const pstring &name) } } log().warning(MW_1_DATA_1_NOT_FOUND, name); - return std::unique_ptr(nullptr); + return plib::unique_ptr(nullptr); } @@ -1146,19 +1146,19 @@ bool source_t::parse(nlparse_t &setup, const pstring &name) } } -std::unique_ptr source_string_t::stream(const pstring &name) +plib::unique_ptr source_string_t::stream(const pstring &name) { plib::unused_var(name); return plib::make_unique(m_str.c_str(), std::strlen(m_str.c_str())); } -std::unique_ptr source_mem_t::stream(const pstring &name) +plib::unique_ptr source_mem_t::stream(const pstring &name) { plib::unused_var(name); return plib::make_unique(m_str.c_str(), std::strlen(m_str.c_str())); } -std::unique_ptr source_file_t::stream(const pstring &name) +plib::unique_ptr source_file_t::stream(const pstring &name) { plib::unused_var(name); return plib::make_unique(m_filename); @@ -1175,10 +1175,10 @@ bool source_proc_t::parse(nlparse_t &setup, const pstring &name) return false; } -std::unique_ptr source_proc_t::stream(const pstring &name) +plib::unique_ptr source_proc_t::stream(const pstring &name) { plib::unused_var(name); - std::unique_ptr p(nullptr); + plib::unique_ptr p(nullptr); return p; } diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h index 448df3490da..5e445fc6a32 100644 --- a/src/lib/netlist/nl_setup.h +++ b/src/lib/netlist/nl_setup.h @@ -180,7 +180,7 @@ namespace netlist DATA }; - using list_t = std::vector>; + using list_t = std::vector>; source_t(const type_t type = SOURCE) : m_type(type) @@ -195,7 +195,7 @@ namespace netlist type_t type() const { return m_type; } protected: - virtual std::unique_ptr stream(const pstring &name) = 0; + virtual plib::unique_ptr stream(const pstring &name) = 0; private: const type_t m_type; @@ -224,7 +224,7 @@ namespace netlist void register_frontier(const pstring &attach, const double r_IN, const double r_OUT); /* register a source */ - void register_source(std::unique_ptr &&src) + void register_source(plib::unique_ptr &&src) { m_sources.push_back(std::move(src)); } @@ -251,7 +251,7 @@ namespace netlist bool device_exists(const pstring &name) const; /* FIXME: used by source_t - need a different approach at some time */ - bool parse_stream(std::unique_ptr &&istrm, const pstring &name); + bool parse_stream(plib::unique_ptr &&istrm, const pstring &name); void add_define(pstring def, pstring val) { @@ -328,7 +328,7 @@ namespace netlist void register_dynamic_log_devices(); void resolve_inputs(); - std::unique_ptr get_data_stream(const pstring &name); + plib::unique_ptr get_data_stream(const pstring &name); factory::list_t &factory() { return m_factory; } @@ -404,7 +404,7 @@ namespace netlist } protected: - std::unique_ptr stream(const pstring &name) override; + plib::unique_ptr stream(const pstring &name) override; private: pstring m_str; @@ -420,7 +420,7 @@ namespace netlist } protected: - std::unique_ptr stream(const pstring &name) override; + plib::unique_ptr stream(const pstring &name) override; private: pstring m_filename; @@ -435,7 +435,7 @@ namespace netlist } protected: - std::unique_ptr stream(const pstring &name) override; + plib::unique_ptr stream(const pstring &name) override; private: pstring m_str; @@ -454,7 +454,7 @@ namespace netlist bool parse(nlparse_t &setup, const pstring &name) override; protected: - std::unique_ptr stream(const pstring &name) override; + plib::unique_ptr stream(const pstring &name) override; private: void (*m_setup_func)(nlparse_t &); diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h index c70aaa392d7..45c19ef7b3a 100644 --- a/src/lib/netlist/plib/palloc.h +++ b/src/lib/netlist/plib/palloc.h @@ -8,45 +8,124 @@ #ifndef PALLOC_H_ #define PALLOC_H_ +#include "pconfig.h" #include "pstring.h" #include "ptypes.h" #include +#include #include #include #include +#if defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER) +#include +#endif + namespace plib { //============================================================ // Memory allocation //============================================================ +#if (USE_ALIGNED_OPTIMIZATIONS) + static inline void *paligned_alloc( size_t alignment, size_t size ) + { +#if defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER) + return _aligned_malloc(size, alignment); +#elif defined(__APPLE__) + void* p; + if (::posix_memalign(&p, alignment, size) != 0) { + p = nullptr; + } + return p; +#else + return aligned_alloc(alignment, size); +#endif + } + + static inline void pfree( void *ptr ) + { + free(ptr); + } + + template + inline C14CONSTEXPR T *assume_aligned_ptr(T *p) noexcept + { + return reinterpret_cast(__builtin_assume_aligned(p, ALIGN)); + } + + template + inline C14CONSTEXPR const T *assume_aligned_ptr(const T *p) noexcept + { + return reinterpret_cast(__builtin_assume_aligned(p, ALIGN)); + } +#else + static inline void *paligned_alloc( size_t alignment, size_t size ) + { + unused_var(alignment); + return ::operator new(size); + } + + static inline void pfree( void *ptr ) + { + ::operator delete(ptr); + } + + template + inline C14CONSTEXPR T *assume_aligned_ptr(T *p) noexcept + { + return p; + } + + template + inline C14CONSTEXPR const T *assume_aligned_ptr(const T *p) noexcept + { + return p; + } +#endif template - T *palloc(Args&&... args) + inline T *pnew(Args&&... args) { - return new T(std::forward(args)...); + auto *p = paligned_alloc(alignof(T), sizeof(T)); + return new(p) T(std::forward(args)...); } template - void pfree(T *ptr) + inline void pdelete(T *ptr) { - delete ptr; + ptr->~T(); + pfree(ptr); } template - T* palloc_array(const std::size_t num) + inline T* pnew_array(const std::size_t num) { return new T[num](); } template - void pfree_array(T *ptr) + inline void pdelete_array(T *ptr) { delete [] ptr; } - template > + template + struct pdefault_deleter + { + constexpr pdefault_deleter() noexcept = default; + + template::value>::type> + pdefault_deleter(const pdefault_deleter&) noexcept { } + + void operator()(T *p) const + { + pdelete(p); + } + }; + + template > class owned_ptr { public: @@ -142,19 +221,113 @@ namespace plib { bool m_is_owned; }; + template + using unique_ptr = std::unique_ptr>; + template - std::unique_ptr make_unique(Args&&... args) + plib::unique_ptr make_unique(Args&&... args) { - return std::unique_ptr(new T(std::forward(args)...)); + return plib::unique_ptr(pnew(std::forward(args)...)); } template static owned_ptr make_owned(Args&&... args) { - owned_ptr a(new T(std::forward(args)...), true); + owned_ptr a(pnew(std::forward(args)...), true); return std::move(a); } + template + class aligned_allocator + { + public: + using value_type = T; + + static_assert(ALIGN >= alignof(T) && (ALIGN % alignof(T)) == 0, + "ALIGN must be greater than alignof(T) and a multiple"); + + aligned_allocator() = default; + + aligned_allocator(const aligned_allocator&) = default; + aligned_allocator& operator=(const aligned_allocator&) = delete; + + template + aligned_allocator(const aligned_allocator& rhs) noexcept + { + unused_var(rhs); + } + + template struct rebind + { + using other = aligned_allocator; + }; + + T* allocate(std::size_t n) + { + return reinterpret_cast(paligned_alloc(ALIGN, sizeof(T) * n)); + } + + void deallocate(T* p, std::size_t n) noexcept + { + unused_var(n); + pfree(p); + } + + template + friend bool operator==(const aligned_allocator& lhs, + const aligned_allocator& rhs) noexcept; + + template friend class aligned_allocator; + }; + + template + /*friend*/ inline bool operator==(const aligned_allocator& lhs, + const aligned_allocator& rhs) noexcept + { + unused_var(lhs, rhs); + return A1 == A2; + } + template + /*friend*/ inline bool operator!=(const aligned_allocator& lhs, + const aligned_allocator& rhs) noexcept + { + return !(lhs == rhs); + } + + // FIXME: needs to be somewhere else +#if 0 + template + using aligned_vector = std::vector>; + //using aligned_vector = std::vector>; +#else + template + class aligned_vector : public std::vector> + { + public: + using base = std::vector>; + + using reference = typename base::reference; + using const_reference = typename base::const_reference; + using size_type = typename base::size_type; + + using base::base; + + reference operator[](size_type i) noexcept + { + return assume_aligned_ptr(this->data())[i]; + } + constexpr const_reference operator[](size_type i) const noexcept + { + return assume_aligned_ptr(this->data())[i]; + } + + }; + + +#endif + + + } // namespace plib #endif /* PALLOC_H_ */ diff --git a/src/lib/netlist/plib/parray.h b/src/lib/netlist/plib/parray.h index 662c2e9550e..e09639163f0 100644 --- a/src/lib/netlist/plib/parray.h +++ b/src/lib/netlist/plib/parray.h @@ -10,6 +10,7 @@ #include "pconfig.h" #include "pexception.h" +#include "palloc.h" #include #include @@ -30,7 +31,7 @@ namespace plib { struct sizeabs { static constexpr const std::size_t ABS = 0; - using container = typename std::vector ; + using container = typename std::vector>; }; /** @@ -102,11 +103,17 @@ namespace plib { return m_a[i]; } #else - reference operator[](size_type i) noexcept { return m_a[i]; } - constexpr const_reference operator[](size_type i) const noexcept { return m_a[i]; } + reference operator[](size_type i) noexcept + { + return assume_aligned_ptr(&m_a[0])[i]; + } + constexpr const_reference operator[](size_type i) const noexcept + { + return assume_aligned_ptr(&m_a[0])[i]; + } #endif - FT * data() noexcept { return m_a.data(); } - const FT * data() const noexcept { return m_a.data(); } + FT * data() noexcept { return assume_aligned_ptr(m_a.data()); } + const FT * data() const noexcept { return assume_aligned_ptr(m_a.data()); } private: PALIGNAS_VECTOROPT() diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h index cc92a42c827..9f61fc0b01f 100644 --- a/src/lib/netlist/plib/pconfig.h +++ b/src/lib/netlist/plib/pconfig.h @@ -33,12 +33,23 @@ #define PHAS_INT128 (0) #endif +/* + * Set this to one if you want to use aligned storage optimizations. + */ + +#ifndef USE_ALIGNED_OPTIMIZATIONS +#define USE_ALIGNED_OPTIMIZATIONS (0) +#endif + /* * Standard alignment macros */ -#define PALIGNAS_CACHELINE() PALIGNAS(64) -#define PALIGNAS_VECTOROPT() PALIGNAS(64) +#define PALIGN_CACHELINE (64) +#define PALIGN_VECTOROPT (16) + +#define PALIGNAS_CACHELINE() PALIGNAS(PALIGN_CACHELINE) +#define PALIGNAS_VECTOROPT() PALIGNAS(PALIGN_VECTOROPT) /* Breaks mame build on windows due to -Wattribute */ #if defined(_WIN32) && defined(__GNUC__) diff --git a/src/lib/netlist/plib/pdynlib.cpp b/src/lib/netlist/plib/pdynlib.cpp index f30ddc5d59a..c0c89de208d 100644 --- a/src/lib/netlist/plib/pdynlib.cpp +++ b/src/lib/netlist/plib/pdynlib.cpp @@ -25,7 +25,7 @@ CHAR *astring_from_utf8(const char *utf8string) // convert UTF-16 to "ANSI code page" string char_count = WideCharToMultiByte(CP_ACP, 0, wstring, -1, nullptr, 0, nullptr, nullptr); - result = palloc_array(char_count); + result = pnew_array(char_count); if (result != nullptr) WideCharToMultiByte(CP_ACP, 0, wstring, -1, result, char_count, nullptr, nullptr); @@ -39,7 +39,7 @@ WCHAR *wstring_from_utf8(const char *utf8string) // convert MAME string (UTF-8) to UTF-16 char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, nullptr, 0); - result = palloc_array(char_count); + result = pnew_array(char_count); if (result != nullptr) MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, result, char_count); @@ -72,7 +72,7 @@ dynlib::dynlib(const pstring libname) m_isLoaded = true; //else // fprintf(stderr, "win: library <%s> not found!\n", libname.c_str()); - pfree_array(buffer); + pdelete_array(buffer); #elif defined(EMSCRIPTEN) //no-op #else @@ -106,7 +106,7 @@ dynlib::dynlib(const pstring path, const pstring libname) { //printf("win: library <%s> not found!\n", libname.c_str()); } - pfree_array(buffer); + pdelete_array(buffer); #elif defined(EMSCRIPTEN) //no-op #else diff --git a/src/lib/netlist/plib/pmempool.h b/src/lib/netlist/plib/pmempool.h index 80e30ada324..c55d66d8847 100644 --- a/src/lib/netlist/plib/pmempool.h +++ b/src/lib/netlist/plib/pmempool.h @@ -34,7 +34,6 @@ namespace plib { void operator()(T *p) const { - p->~T(); P::free(p); } }; @@ -83,7 +82,7 @@ namespace plib { block * new_block(std::size_t min_bytes) { - auto *b = new block(this, min_bytes); + auto *b = plib::pnew(this, min_bytes); m_blocks.push_back(b); return b; } @@ -123,22 +122,27 @@ namespace plib { } } - void *alloc(size_t size, size_t align) + template + void *alloc(size_t size) { + size_t align = ALIGN; if (align < m_min_align) align = m_min_align; - size_t rs = (size + align - 1) & ~(align - 1); + size_t rs = size + align; for (auto &b : m_blocks) { if (b->m_free > rs) { b->m_free -= rs; b->m_num_alloc++; - auto ret = reinterpret_cast(b->m_data + b->m_cur); + auto *ret = reinterpret_cast(b->m_data + b->m_cur); auto capacity(rs); - std::align(align, size, ret, capacity); + ret = std::align(align, size, ret, capacity); + if (ret == nullptr) + printf("Oh no\n"); sinfo().insert({ ret, info(b, b->m_cur)}); + rs -= (capacity - size); b->m_cur += rs; return ret; @@ -148,17 +152,24 @@ namespace plib { block *b = new_block(rs); b->m_num_alloc = 1; b->m_free = m_min_alloc - rs; - auto ret = reinterpret_cast(b->m_data + b->m_cur); + auto *ret = reinterpret_cast(b->m_data + b->m_cur); auto capacity(rs); - std::align(align, size, ret, capacity); + ret = std::align(align, size, ret, capacity); + if (ret == nullptr) + printf("Oh no\n"); sinfo().insert({ ret, info(b, b->m_cur)}); + rs -= (capacity - size); b->m_cur += rs; return ret; } } - static void free(void *ptr) + template + static void free(T *ptr) { + /* call destructor */ + ptr->~T(); + auto it = sinfo().find(ptr); if (it == sinfo().end()) plib::terminate("mempool::free - pointer not found\n"); @@ -182,7 +193,7 @@ namespace plib { template poolptr make_poolptr(Args&&... args) { - auto mem = this->alloc(sizeof(T), alignof(T)); + auto *mem = this->alloc(sizeof(T)); auto *obj = new (mem) T(std::forward(args)...); poolptr a(obj, true); return std::move(a); @@ -208,6 +219,7 @@ namespace plib { ~mempool_default() = default; +#if 0 void *alloc(size_t size) { plib::unused_var(m_min_alloc); // -Wunused-private-field fires without @@ -216,9 +228,11 @@ namespace plib { return ::operator new(size); } - static void free(void *ptr) +#endif + template + static void free(T *ptr) { - ::operator delete(ptr); + plib::pdelete(ptr); } template @@ -227,12 +241,13 @@ namespace plib { template poolptr make_poolptr(Args&&... args) { - auto mem(alloc(sizeof(T))); - auto *obj = new (mem) T(std::forward(args)...); + plib::unused_var(m_min_alloc); // -Wunused-private-field fires without + plib::unused_var(m_min_align); + + auto *obj = plib::pnew(std::forward(args)...); poolptr a(obj, true); return std::move(a); } - }; diff --git a/src/lib/netlist/plib/pstate.h b/src/lib/netlist/plib/pstate.h index cdb6ea94dc8..d837a6d2931 100644 --- a/src/lib/netlist/plib/pstate.h +++ b/src/lib/netlist/plib/pstate.h @@ -10,6 +10,7 @@ #include "pstring.h" #include "ptypes.h" +#include "palloc.h" #include #include @@ -63,7 +64,7 @@ public: struct entry_t { - using list_t = std::vector>; + using list_t = std::vector>; entry_t(const pstring &stname, const datatype_t &dt, const void *owner, const std::size_t count, void *ptr) diff --git a/src/lib/netlist/plib/pstream.cpp b/src/lib/netlist/plib/pstream.cpp index f9dd224e92f..8f80f317f98 100644 --- a/src/lib/netlist/plib/pstream.cpp +++ b/src/lib/netlist/plib/pstream.cpp @@ -270,13 +270,13 @@ pimemstream::pos_type pimemstream::vtell() const pomemstream::pomemstream() : postream(FLAG_SEEKABLE), m_pos(0), m_capacity(1024), m_size(0) { - m_mem = palloc_array(m_capacity); + m_mem = pnew_array(m_capacity); } pomemstream::~pomemstream() { if (m_mem != nullptr) - pfree_array(m_mem); + pdelete_array(m_mem); } void pomemstream::vwrite(const value_type *buf, const pos_type n) @@ -286,13 +286,13 @@ void pomemstream::vwrite(const value_type *buf, const pos_type n) while (m_pos + n >= m_capacity) m_capacity *= 2; char *o = m_mem; - m_mem = palloc_array(m_capacity); + m_mem = pnew_array(m_capacity); if (m_mem == nullptr) { throw out_of_mem_e("pomemstream::vwrite"); } std::copy(o, o + m_pos, m_mem); - pfree_array(o); + pdelete_array(o); } std::copy(buf, buf + n, m_mem + m_pos); @@ -309,13 +309,13 @@ void pomemstream::vseek(const pos_type n) while (m_size >= m_capacity) m_capacity *= 2; char *o = m_mem; - m_mem = palloc_array(m_capacity); + m_mem = pnew_array(m_capacity); if (m_mem == nullptr) { throw out_of_mem_e("pomemstream::vseek"); } std::copy(o, o + m_pos, m_mem); - pfree_array(o); + pdelete_array(o); } } diff --git a/src/lib/netlist/plib/pstream.h b/src/lib/netlist/plib/pstream.h index 80619137c51..d5b2bfa4809 100644 --- a/src/lib/netlist/plib/pstream.h +++ b/src/lib/netlist/plib/pstream.h @@ -447,7 +447,7 @@ private: template struct constructor_helper { - std::unique_ptr operator()(T &&s) { return std::move(plib::make_unique(std::move(s))); } + plib::unique_ptr operator()(T &&s) { return std::move(plib::make_unique(std::move(s))); } }; // NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) @@ -489,20 +489,20 @@ public: } private: - std::unique_ptr m_strm; + plib::unique_ptr m_strm; putf8string m_linebuf; }; template <> struct constructor_helper { - std::unique_ptr operator()(putf8_reader &&s) { return std::move(s.m_strm); } + plib::unique_ptr operator()(putf8_reader &&s) { return std::move(s.m_strm); } }; template <> -struct constructor_helper> +struct constructor_helper> { - std::unique_ptr operator()(std::unique_ptr &&s) { return std::move(s); } + plib::unique_ptr operator()(plib::unique_ptr &&s) { return std::move(s); } }; @@ -626,11 +626,11 @@ public: { std::size_t sz = 0; read(sz); - auto buf = plib::palloc_array::mem_t>(sz+1); + auto buf = plib::pnew_array::mem_t>(sz+1); m_strm.read(reinterpret_cast(buf), sz); buf[sz] = 0; s = pstring(buf); - plib::pfree_array(buf); + plib::pdelete_array(buf); } template diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp index ea7e1426626..076d004528c 100644 --- a/src/lib/netlist/prg/nltool.cpp +++ b/src/lib/netlist/prg/nltool.cpp @@ -126,13 +126,13 @@ public: { } - std::unique_ptr stream(const pstring &file) override; + plib::unique_ptr stream(const pstring &file) override; private: pstring m_folder; }; -std::unique_ptr netlist_data_folder_t::stream(const pstring &file) +plib::unique_ptr netlist_data_folder_t::stream(const pstring &file) { pstring name = m_folder + "/" + file; try @@ -145,7 +145,7 @@ std::unique_ptr netlist_data_folder_t::stream(const pstring &fil if (dynamic_cast(&e) == nullptr ) throw; } - return std::unique_ptr(nullptr); + return plib::unique_ptr(nullptr); } class netlist_tool_callbacks_t : public netlist::callbacks_t diff --git a/src/lib/netlist/prg/nlwav.cpp b/src/lib/netlist/prg/nlwav.cpp index 96cf9342058..24c84c73739 100644 --- a/src/lib/netlist/prg/nlwav.cpp +++ b/src/lib/netlist/prg/nlwav.cpp @@ -166,7 +166,7 @@ public: return success; } - void process(std::vector> &is) + void process(std::vector> &is) { std::vector readers; for (auto &i : is) @@ -431,7 +431,7 @@ public: private: void convert_wav(); void convert_vcd(vcdwriter::format_e format); - std::vector> m_instrms; + std::vector> m_instrms; plib::postream *m_outstrm; }; @@ -440,8 +440,8 @@ void nlwav_app::convert_wav() double dt = 1.0 / static_cast(opt_rate()); - std::unique_ptr wo = plib::make_unique(*m_outstrm, m_instrms.size(), opt_rate(), opt_amp()); - std::unique_ptr ago = plib::make_unique(m_instrms.size(), dt, aggregator::callback_type(&wavwriter::process, wo.get())); + plib::unique_ptr wo = plib::make_unique(*m_outstrm, m_instrms.size(), opt_rate(), opt_amp()); + plib::unique_ptr ago = plib::make_unique(m_instrms.size(), dt, aggregator::callback_type(&wavwriter::process, wo.get())); aggregator::callback_type agcb = log_processor::callback_type(&aggregator::process, ago.get()); log_processor lp(m_instrms.size(), agcb); @@ -462,7 +462,7 @@ void nlwav_app::convert_wav() void nlwav_app::convert_vcd(vcdwriter::format_e format) { - std::unique_ptr wo = plib::make_unique(*m_outstrm, opt_args(), + plib::unique_ptr wo = plib::make_unique(*m_outstrm, opt_args(), format, opt_high(), opt_low()); log_processor::callback_type agcb = log_processor::callback_type(&vcdwriter::process, wo.get()); @@ -510,11 +510,11 @@ int nlwav_app::execute() return 0; } - m_outstrm = (opt_out() == "-" ? &pout_strm : plib::palloc(opt_out())); + m_outstrm = (opt_out() == "-" ? &pout_strm : plib::pnew(opt_out())); for (auto &oi: opt_args()) { - std::unique_ptr fin = (oi == "-" ? + plib::unique_ptr fin = (oi == "-" ? plib::make_unique() : plib::make_unique(oi)); m_instrms.push_back(std::move(fin)); @@ -534,7 +534,7 @@ int nlwav_app::execute() } if (opt_out() != "-") - plib::pfree(m_outstrm); + plib::pdelete(m_outstrm); return 0; } diff --git a/src/lib/netlist/solver/nld_matrix_solver.cpp b/src/lib/netlist/solver/nld_matrix_solver.cpp index 36c8f2fb551..951733874fd 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.cpp +++ b/src/lib/netlist/solver/nld_matrix_solver.cpp @@ -336,9 +336,9 @@ void matrix_solver_t::setup_matrix() * This should reduce cache misses ... */ - auto **touched = plib::palloc_array(iN); + auto **touched = plib::pnew_array(iN); for (std::size_t k=0; k(iN); + touched[k] = plib::pnew_array(iN); for (std::size_t k = 0; k < iN; k++) { @@ -397,8 +397,8 @@ void matrix_solver_t::setup_matrix() } for (std::size_t k=0; k m_nzrd; /* non zero right of the diagonal for elimination, may include RHS element */ std::vector m_nzbd; /* non zero below of the diagonal for elimination */ - - - /* state */ nl_double m_last_V; nl_double m_DD_n_m_1; @@ -113,10 +111,10 @@ public: private: std::vector m_connected_net_idx; - std::vector m_go; - std::vector m_gt; - std::vector m_Idr; - std::vector m_connected_net_V; + plib::aligned_vector m_go; + plib::aligned_vector m_gt; + plib::aligned_vector m_Idr; + plib::aligned_vector m_connected_net_V; std::vector m_terms; }; @@ -218,11 +216,11 @@ protected: template void build_LE_RHS(T &child); - std::vector> m_terms; + std::vector> m_terms; std::vector m_nets; std::vector> m_inps; - std::vector> m_rails_temp; + std::vector> m_rails_temp; const solver_parameters_t &m_params; diff --git a/src/lib/netlist/solver/nld_ms_gcr.h b/src/lib/netlist/solver/nld_ms_gcr.h index 8d1351435c8..d2caa944434 100644 --- a/src/lib/netlist/solver/nld_ms_gcr.h +++ b/src/lib/netlist/solver/nld_ms_gcr.h @@ -65,7 +65,8 @@ private: plib::parray RHS; plib::parray new_V; - std::array, storage_N> m_term_cr; + std::array, storage_N> m_term_cr; +// std::array, storage_N> m_term_cr; mat_type mat; diff --git a/src/lib/netlist/solver/nld_ms_gmres.h b/src/lib/netlist/solver/nld_ms_gmres.h index 3cd88dea429..dcb3726f5f2 100644 --- a/src/lib/netlist/solver/nld_ms_gmres.h +++ b/src/lib/netlist/solver/nld_ms_gmres.h @@ -51,7 +51,7 @@ namespace devices using mattype = typename plib::matrix_compressed_rows_t::index_type; - plib::parray, SIZE> m_term_cr; + plib::parray, SIZE> m_term_cr; plib::mat_precondition_ILU m_ops; //plib::mat_precondition_diag m_ops; plib::gmres_t m_gmres; diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp index 6ce9a093c84..44d51793690 100644 --- a/src/lib/netlist/solver/nld_solver.cpp +++ b/src/lib/netlist/solver/nld_solver.cpp @@ -175,6 +175,25 @@ poolptr NETLIB_NAME(solver)::create_solver(std::size_t size, co } } +template +poolptr NETLIB_NAME(solver)::create_solver_x(std::size_t size, const pstring &solvername) +{ + if (SIZE > 0) + { + if (size == SIZE) + return create_solver(size, solvername); + else + return this->create_solver_x(size, solvername); + } + else + { + if (size * 2 > -SIZE ) + return create_solver(size, solvername); + else + return this->create_solver_x(size, solvername); + } +}; + struct net_splitter { @@ -230,9 +249,6 @@ struct net_splitter void NETLIB_NAME(solver)::post_start() { - const bool use_specific = true; - plib::unused_var(use_specific); - m_params.m_pivot = m_pivot(); m_params.m_accuracy = m_accuracy(); /* FIXME: Throw when negative */ @@ -283,18 +299,11 @@ void NETLIB_NAME(solver)::post_start() { #if 1 case 1: - if (use_specific) - ms = pool().make_poolptr>(state(), sname, &m_params); - else - ms = create_solver(1, sname); + ms = pool().make_poolptr>(state(), sname, &m_params); break; case 2: - if (use_specific) - ms = pool().make_poolptr>(state(), sname, &m_params); - else - ms = create_solver(2, sname); + ms = pool().make_poolptr>(state(), sname, &m_params); break; -#if 1 case 3: ms = create_solver(3, sname); break; @@ -319,6 +328,7 @@ void NETLIB_NAME(solver)::post_start() case 10: ms = create_solver(10, sname); break; +#if 0 case 11: ms = create_solver(11, sname); break; @@ -341,7 +351,7 @@ void NETLIB_NAME(solver)::post_start() ms = create_solver(49, sname); break; #endif -#if 0 +#if 1 case 86: ms = create_solver(86, sname); break; diff --git a/src/lib/netlist/solver/nld_solver.h b/src/lib/netlist/solver/nld_solver.h index 247abc9097b..c4a9eba6971 100644 --- a/src/lib/netlist/solver/nld_solver.h +++ b/src/lib/netlist/solver/nld_solver.h @@ -105,6 +105,9 @@ private: template poolptr create_solver(std::size_t size, const pstring &solvername); + + template + poolptr create_solver_x(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 95e05d27857..f4616cb7774 100644 --- a/src/lib/netlist/tools/nl_convert.cpp +++ b/src/lib/netlist/tools/nl_convert.cpp @@ -81,7 +81,7 @@ void nl_convert_base_t::add_ext_alias(const pstring &alias) m_ext_alias.push_back(alias); } -void nl_convert_base_t::add_device(std::unique_ptr dev) +void nl_convert_base_t::add_device(plib::unique_ptr dev) { for (auto & d : m_devs) if (d->name() == dev->name()) diff --git a/src/lib/netlist/tools/nl_convert.h b/src/lib/netlist/tools/nl_convert.h index 7dd0e56c5ee..73c98301af5 100644 --- a/src/lib/netlist/tools/nl_convert.h +++ b/src/lib/netlist/tools/nl_convert.h @@ -124,14 +124,14 @@ private: private: - void add_device(std::unique_ptr dev); + void add_device(plib::unique_ptr dev); plib::postringstream m_buf; - std::vector> m_devs; - std::unordered_map > m_nets; + std::vector> m_devs; + std::unordered_map > m_nets; std::vector m_ext_alias; - std::unordered_map> m_pins; + std::unordered_map> m_pins; static unit_t m_units[]; pstring m_numberchars; -- 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/pmempool.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 From 0ed2d2684e5ce5798cde34fbc48799e30148c5ca Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sun, 24 Feb 2019 14:25:42 +1100 Subject: srcclean (nw) --- hash/a800.xml | 0 hash/a800_flop.xml | 0 hash/ekara_japan.xml | 20 +- hash/ekara_japan_a.xml | 8 +- hash/ekara_japan_bh.xml | 8 +- hash/ekara_japan_d.xml | 2 +- hash/ekara_japan_g.xml | 10 +- hash/ekara_japan_m.xml | 8 +- hash/ekara_japan_p.xml | 2 +- hash/ekara_japan_sp.xml | 10 +- hash/ekara_japan_web.xml | 6 +- hash/gamate.xml | 2 +- hash/ibm5150.xml | 24 +- hash/ibm5170.xml | 4 +- hash/jpopira_jp.xml | 4 +- hash/msx1_cass.xml | 0 hash/sega_beena_cart.xml | 4 +- hash/timex_dock.xml | 0 hash/vgmplay.xml | 2 +- plugins/cheatfind/init.lua | 144 +++---- src/devices/bus/amiga/zorro/buddha.cpp | 8 +- src/devices/bus/ekara/slot.cpp | 2 +- src/devices/bus/ekara/slot.h | 4 +- src/devices/bus/vsmile/vsmile_slot.cpp | 2 +- src/devices/cpu/i386/cpuidmsrs.hxx | 18 +- src/devices/cpu/i86/i186.h | 2 +- src/devices/machine/8042kbdc.h | 2 +- src/devices/machine/nscsi_cd.cpp | 2 +- src/devices/machine/spg110.cpp | 34 +- src/devices/machine/timekpr.cpp | 2 +- src/devices/sound/ay8910.cpp | 96 ++--- src/devices/sound/ics2115.cpp | 8 +- src/devices/video/crt9028.cpp | 2 +- src/lib/netlist/analog/nlid_fourterm.h | 2 +- src/lib/netlist/analog/nlid_twoterm.h | 2 +- src/lib/netlist/devices/nld_2102A.cpp | 2 +- src/lib/netlist/devices/nld_74174.cpp | 2 +- src/lib/netlist/devices/nld_74175.cpp | 2 +- src/lib/netlist/devices/nld_74192.cpp | 2 +- src/lib/netlist/devices/nld_74193.cpp | 2 +- src/lib/netlist/devices/nld_74194.cpp | 2 +- src/lib/netlist/devices/nld_ne555.cpp | 2 +- src/lib/netlist/devices/nld_tms4800.cpp | 2 +- src/lib/netlist/devices/nlid_system.h | 2 +- src/lib/netlist/nl_base.cpp | 10 +- src/lib/netlist/nl_base.h | 4 +- src/lib/netlist/nl_setup.h | 8 +- src/lib/netlist/plib/gmres.h | 28 +- src/lib/netlist/plib/palloc.h | 102 ++--- src/lib/netlist/plib/parray.h | 4 +- src/lib/netlist/plib/pconfig.h | 8 +- src/lib/netlist/plib/pmempool.h | 8 +- src/lib/netlist/prg/nltool.cpp | 2 +- src/lib/netlist/solver/nld_ms_gcr.h | 2 +- src/mame/drivers/c2color.cpp | 18 +- src/mame/drivers/dec0.cpp | 176 ++++----- src/mame/drivers/fastfred.cpp | 2 +- src/mame/drivers/gaelco2.cpp | 2 +- src/mame/drivers/leapfrog_leappad.cpp | 36 +- src/mame/drivers/naomi.cpp | 8 +- src/mame/drivers/sega_beena.cpp | 12 +- src/mame/drivers/segasp.cpp | 2 +- src/mame/drivers/vii.cpp | 50 +-- src/mame/drivers/wrlshunt.cpp | 136 +++---- src/mame/drivers/xavix.cpp | 6 +- src/mame/drivers/xavix2.cpp | 6 +- src/mame/includes/xavix.h | 6 +- src/mame/layout/fidel_bv3.lay | 2 +- src/mame/layout/fidel_vbrc.lay | 2 +- src/mame/layout/md6802.lay | 548 +++++++++++++-------------- src/mame/layout/modulab.lay | 646 ++++++++++++++++---------------- src/mame/machine/sgi.cpp | 16 +- src/mame/machine/xavix.cpp | 2 +- src/mame/video/dec0.cpp | 16 +- src/mame/video/light.cpp | 8 +- src/mame/video/light.h | 4 +- src/mame/video/newport.cpp | 86 ++--- src/mame/video/newport.h | 2 +- src/osd/modules/input/input_sdl.cpp | 514 ++++++++++++------------- src/tools/imgtool/modules/rt11.cpp | 124 +++--- src/tools/testkeys.cpp | 482 ++++++++++++------------ 81 files changed, 1775 insertions(+), 1775 deletions(-) mode change 100755 => 100644 hash/a800.xml mode change 100755 => 100644 hash/a800_flop.xml mode change 100755 => 100644 hash/ibm5150.xml mode change 100755 => 100644 hash/msx1_cass.xml mode change 100755 => 100644 hash/timex_dock.xml mode change 100755 => 100644 src/mame/layout/md6802.lay (limited to 'src/lib/netlist/plib/pmempool.h') diff --git a/hash/a800.xml b/hash/a800.xml old mode 100755 new mode 100644 diff --git a/hash/a800_flop.xml b/hash/a800_flop.xml old mode 100755 new mode 100644 diff --git a/hash/ekara_japan.xml b/hash/ekara_japan.xml index 580c23e2c6f..97e45dd3337 100644 --- a/hash/ekara_japan.xml +++ b/hash/ekara_japan.xml @@ -721,7 +721,7 @@ - + J-Pop Mix Volume 27 (Japan) (EC0061-JPM) 2001 @@ -743,7 +743,7 @@ - + J-Pop Mix Volume 29 (Japan) (EC0063-JPM) 2001 @@ -767,7 +767,7 @@ - + J-Pop Mix Volume 31 (Japan) (EC0066-JPM) 2001 @@ -778,7 +778,7 @@ - + J-Pop Mix Volume 32 (Japan) (EC0067-JPM) 2001 @@ -811,7 +811,7 @@ - + J-Pop Mix Volume 34 (Japan) (EC0070-JPM) 2001 @@ -866,7 +866,7 @@ - + J-Pop Mix Volume 38 (Japan) (EC0075-JPM) 2001 @@ -876,7 +876,7 @@ - + J-Pop Mix Volume 39 (Japan) (EC0076-JPM) @@ -888,7 +888,7 @@ - + Artist Selection Volume 15 - unknown artist (Japan) (EC0077-ATS) 2001 @@ -898,8 +898,8 @@ - - + + J-Pop Mix Volume 40 (Japan) (EC0078-JPM) 2001 diff --git a/hash/ekara_japan_a.xml b/hash/ekara_japan_a.xml index 2324b434556..762b0c45126 100644 --- a/hash/ekara_japan_a.xml +++ b/hash/ekara_japan_a.xml @@ -8,7 +8,7 @@ Japanese cart listing (by A code) (A-x on cartridge) These are for use with e-pitch / e-kara (e-pitch internal ROM is the same as e-kara Japan, just button layout is changed) - + https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q10109392860 A-1 Pichi Pichi Pitch vol.1 / ã´ã¡ã´ã¡ãƒ”ッãƒvol.1 @@ -33,7 +33,7 @@ - + A-4 Pichi Pichi Pitch Pure Chapter 1 (Japan) 2004 @@ -44,7 +44,7 @@ - + A-5 Pichi Pichi Pitch Karaoke Party (Japan) @@ -67,6 +67,6 @@ - + diff --git a/hash/ekara_japan_bh.xml b/hash/ekara_japan_bh.xml index a35b13a7c70..b033c4713b8 100644 --- a/hash/ekara_japan_bh.xml +++ b/hash/ekara_japan_bh.xml @@ -9,7 +9,7 @@ A secondary 4-digit naming scheme BHxxxx (no extension) appears on a sticker on the cartridge PCB only For e-kara only - + These are probably all just titled 'Best Hit Collection' BH-01 (unknown) @@ -33,7 +33,7 @@ - + BH-03 Best Hit Collection (Japan) 2005 @@ -43,7 +43,7 @@ - + BH-05 Best Hit Collection (Japan) @@ -65,6 +65,6 @@ - + diff --git a/hash/ekara_japan_d.xml b/hash/ekara_japan_d.xml index 117e86adab7..e80e98b9f00 100644 --- a/hash/ekara_japan_d.xml +++ b/hash/ekara_japan_d.xml @@ -18,7 +18,7 @@ *D-1 DC0001-BHT BHT (Best Artists?) Volume 8 (most other BHT carts are in G series, or P series) *D-2 DC0002-BAT BAT Volume 6 - *D-3 DC0003-BHT BHT (Best Artists?) Volume 9 + *D-3 DC0003-BHT BHT (Best Artists?) Volume 9 D-4 DC0004-TPJ TV Pop Volume 8 *D-5 DC0005-TPJ TV Pop Volume 9 D-6 DC0006-BHT BHT (Best Artists?) Volume 10 diff --git a/hash/ekara_japan_g.xml b/hash/ekara_japan_g.xml index 6a0e12cfdaf..9d2aa468479 100644 --- a/hash/ekara_japan_g.xml +++ b/hash/ekara_japan_g.xml @@ -110,7 +110,7 @@ - + MIN Volume 1 (Japan) (GC0008-MIN) (set 2) 2001 @@ -120,7 +120,7 @@ - + - + BAT Volume 4 (Japan) (GC0010-BAT) 2002 @@ -183,7 +183,7 @@ - + TV Pop Volume 6 (Japan) (GC0017-TPJ) 2002 @@ -194,6 +194,6 @@ - + diff --git a/hash/ekara_japan_m.xml b/hash/ekara_japan_m.xml index f46f458b793..3be3576dbe8 100644 --- a/hash/ekara_japan_m.xml +++ b/hash/ekara_japan_m.xml @@ -54,7 +54,7 @@ - + KSM Mini Volume 2 (Japan) (MC0006-KSM) 2003 @@ -64,7 +64,7 @@ - + Artist Mini Volume 7 (untranslated artist) (Japan) (MC0012-ATM) @@ -87,7 +87,7 @@ - + Artist Mini Volume 8 (BoA) (Japan) (MC0014-ATM) 2003 @@ -97,6 +97,6 @@ - + diff --git a/hash/ekara_japan_p.xml b/hash/ekara_japan_p.xml index 2995bb8d5b6..7b87f3cb076 100644 --- a/hash/ekara_japan_p.xml +++ b/hash/ekara_japan_p.xml @@ -50,7 +50,7 @@ - + ENB Volume 1 (Japan) (PC0003-ENB) 2001 diff --git a/hash/ekara_japan_sp.xml b/hash/ekara_japan_sp.xml index e5f67af4a96..f0fa50dfb0f 100644 --- a/hash/ekara_japan_sp.xml +++ b/hash/ekara_japan_sp.xml @@ -44,7 +44,7 @@ - + SP-03 Super Cartridge (Japan) 2004 @@ -55,8 +55,8 @@ - - + + SP-04 Super Cartridge (Japan) 2004 @@ -67,6 +67,6 @@ - - + + diff --git a/hash/ekara_japan_web.xml b/hash/ekara_japan_web.xml index 34e7103c6e6..9ba3f9f10b9 100644 --- a/hash/ekara_japan_web.xml +++ b/hash/ekara_japan_web.xml @@ -27,9 +27,9 @@ - + - + e-kara Web cartridge 12M (used, with 7 Songs) (Japan) 2003 @@ -39,6 +39,6 @@ - + diff --git a/hash/gamate.xml b/hash/gamate.xml index 20534013173..17f601498c8 100644 --- a/hash/gamate.xml +++ b/hash/gamate.xml @@ -546,7 +546,7 @@ C1066 - ?? - + Famous 7 1993 diff --git a/hash/ibm5150.xml b/hash/ibm5150.xml old mode 100755 new mode 100644 index 0516e41135b..23a399ad960 --- a/hash/ibm5150.xml +++ b/hash/ibm5150.xml @@ -3592,7 +3592,7 @@ Known PC Booter Games Not Dumped, Or Dumped and Lost when Demonlord's Site went - + StretchCalc 1983 @@ -7132,7 +7132,7 @@ has been replaced with an all-zero block. --> - + The Bard's Tale - Tales of the Unknown (5.25") 1987 @@ -7409,7 +7409,7 @@ has been replaced with an all-zero block. --> - + Budokan - The Martial Spirit 1989 @@ -7420,7 +7420,7 @@ has been replaced with an all-zero block. --> - + Budokan - The Martial Spirit (Big Games release) 1989 @@ -8171,7 +8171,7 @@ has been replaced with an all-zero block. --> - + Gunboat: River Combat Simulation (Hit Squad release) 1990 @@ -8357,7 +8357,7 @@ has been replaced with an all-zero block. --> - + James Clavell's Shogun (set 1) 1987 @@ -9271,7 +9271,7 @@ has been replaced with an all-zero block. --> - + Monopoly v2.00 (Shareware) 1989 @@ -9298,7 +9298,7 @@ has been replaced with an all-zero block. --> - + Monty Python's Flying Circus (3.5") 1990 @@ -10279,7 +10279,7 @@ has been replaced with an all-zero block. --> - + The Simpsons - Bart vs. the Space Mutants (Hit-Squad release) 1991 @@ -11038,7 +11038,7 @@ has been replaced with an all-zero block. --> - + Xenon (5.25") 1988 @@ -11056,7 +11056,7 @@ has been replaced with an all-zero block. --> - + Xenon (16 Blitz Plus release) (3.5") 1990 @@ -11123,7 +11123,7 @@ has been replaced with an all-zero block. --> - + Zool (Big Games release) 1993 diff --git a/hash/ibm5170.xml b/hash/ibm5170.xml index c2239a98a2d..6b6de203046 100644 --- a/hash/ibm5170.xml +++ b/hash/ibm5170.xml @@ -10747,7 +10747,7 @@ - + Micro Machines 2: Turbo Tournament 1995 @@ -11301,7 +11301,7 @@ - + The Secret of Monkey Island (Italian) 1991 diff --git a/hash/jpopira_jp.xml b/hash/jpopira_jp.xml index f3dade22f25..90c0b1b18f8 100644 --- a/hash/jpopira_jp.xml +++ b/hash/jpopira_jp.xml @@ -29,7 +29,7 @@ - + JP-02 (Japan) 2004 @@ -41,5 +41,5 @@ - + diff --git a/hash/msx1_cass.xml b/hash/msx1_cass.xml old mode 100755 new mode 100644 diff --git a/hash/sega_beena_cart.xml b/hash/sega_beena_cart.xml index ed5245bd853..95d46c8abbe 100644 --- a/hash/sega_beena_cart.xml +++ b/hash/sega_beena_cart.xml @@ -3,8 +3,8 @@ - - + + Fresh Pretty Cure 2009 Sega diff --git a/hash/timex_dock.xml b/hash/timex_dock.xml old mode 100755 new mode 100644 diff --git a/hash/vgmplay.xml b/hash/vgmplay.xml index 9c98d6a576b..c991909a30c 100644 --- a/hash/vgmplay.xml +++ b/hash/vgmplay.xml @@ -227454,7 +227454,7 @@ - + diff --git a/plugins/cheatfind/init.lua b/plugins/cheatfind/init.lua index dd09da404a7..276193acc13 100644 --- a/plugins/cheatfind/init.lua +++ b/plugins/cheatfind/init.lua @@ -259,17 +259,17 @@ function cheatfind.startplugin() local devtable = {} local devsel = 1 local devcur = 1 - - + + --local formtable = { " I1", " i1", "I2", "i2", "I4", "i4", "I8", "i8", }-- " f", " d" } --local formname = { "u8", "s8", "little u16", "big u16", "little s16", "big s16", - -- "little u32", "big u32", "little s32", "big s32", "little u64", "big u64", "little s64", "big s64", } - -- -- "little float", "big float", "little double", "big double" } + -- "little u32", "big u32", "little s32", "big s32", "little u64", "big u64", "little s64", "big s64", } + -- -- "little float", "big float", "little double", "big double" } -- Reordered into likelyhood of use order: unsigned byte by big endian unsigned by little endian unsigned then unsigned in same order local formtable = { " I1", ">I2", ">I4", ">I8", "i2", ">i4", ">i8", "f", " d" } - local formname = { "u8", "big u16", "big u32", "big u64", "little u16", "little u32", - "little u64", "s8", "big s16", "big s32", "big s64", "little s16", "little s32", "little s64", } - + local formname = { "u8", "big u16", "big u32", "big u64", "little u16", "little u32", + "little u64", "s8", "big s16", "big s32", "big s64", "little s16", "little s32", "little s64", } + local width = 1 local bcd = 0 local align = 0 @@ -278,16 +278,16 @@ function cheatfind.startplugin() local value = 0 local leftop = 1 local rightop = 1 - local leftop_text = "Slot 1" - local rightop_text = "Slot 1" - local value_text = "" - local expression_text = "Slot 1 < Slot 1" + local leftop_text = "Slot 1" + local rightop_text = "Slot 1" + local value_text = "" + local expression_text = "Slot 1 < Slot 1" local pausetable = { "Automatic", "Manual" } local pausesel = 1 - local pokevaltable = { "Slot 1 Value", "Last Slot Value", "0x00", "0x01", "0x02", "0x03", "0x04", "0x05", "0x06", "0x07", "0x08", "0x09", "0x63 (Decimal 99)", "0x99 (BCD 99)", + local pokevaltable = { "Slot 1 Value", "Last Slot Value", "0x00", "0x01", "0x02", "0x03", "0x04", "0x05", "0x06", "0x07", "0x08", "0x09", "0x63 (Decimal 99)", "0x99 (BCD 99)", "0xFF (Decimal 255)" , "0x3E7 (Decimal 999)", "0x999 (BCD 999)", "0x270F (Decimal 9999)", "0x9999 (BCD 9999)", "0xFFFF (Decimal 65535)" } local pokevalsel = 1 - + local matches = {} local matchsel = 0 local matchpg = 0 @@ -350,12 +350,12 @@ function cheatfind.startplugin() end emu.register_start(start) - + local menu_is_showing = false - local tabbed_out = false - + local tabbed_out = false + local function menu_populate() - if pausesel == 1 then + if pausesel == 1 then emu.pause() menu_is_showing = true end @@ -504,24 +504,24 @@ function cheatfind.startplugin() local m = { _("Pause Mode"), pausetable[pausesel], 0 } menu_lim(pausesel, 1, pausetable, m) local function f(event) - if (event == "left" or event == "right") then + if (event == "left" or event == "right") then if pausesel == 1 then pausesel = 2 menu_is_showing = false manager:machine():popmessage(_("Manually pause & unpause the game when needed with the pause hotkey")) - else + else pausesel = 1 emu.pause() - end + end end return true end - return m, f - end + return m, f + end + + - - menu[#menu + 1] = function() local function f(event) local ret = false @@ -542,7 +542,7 @@ function cheatfind.startplugin() leftop_text = "Slot 1" rightop_text = "Slot 1" value_text = "" - expression_text = "Slot 1 < Slot 1" + expression_text = "Slot 1 < Slot 1" matchsel = 0 return true end @@ -550,9 +550,9 @@ function cheatfind.startplugin() local opsel = 1 return { _("Start new search"), "", 0 }, f end - - + + if #menu_blocks ~= 0 then menu[#menu + 1] = function() return { "---", "", "off" }, nil end menu[#menu + 1] = function() @@ -562,7 +562,7 @@ function cheatfind.startplugin() menu_blocks[num][#menu_blocks[num] + 1] = cheat.save(devtable[devcur].space, region.offset, region.size) end manager:machine():popmessage(string.format(_("Memory State saved to Slot %d"), #menu_blocks[1])) - + if (leftop == #menu_blocks[1] - 1 and rightop == #menu_blocks[1] - 2 ) then leftop = #menu_blocks[1] rightop = #menu_blocks[1]-1 @@ -571,7 +571,7 @@ function cheatfind.startplugin() rightop = #menu_blocks[1] elseif (leftop == #menu_blocks[1] - 1 ) then leftop = #menu_blocks[1] - elseif (rightop == #menu_blocks[1] - 1) then + elseif (rightop == #menu_blocks[1] - 1) then rightop = #menu_blocks[1] end leftop_text = string.format("Slot %d", leftop) @@ -618,27 +618,27 @@ function cheatfind.startplugin() return true end end - + if optable[opsel] == "lt" then if (value == 0 ) then - expression_text = string.format("%s < %s", leftop_text, rightop_text) - else - expression_text = string.format("%s == %s - %d", leftop_text, rightop_text, value) - end + expression_text = string.format("%s < %s", leftop_text, rightop_text) + else + expression_text = string.format("%s == %s - %d", leftop_text, rightop_text, value) + end elseif optable[opsel] == "gt" then if (value == 0 ) then - expression_text = string.format("%s > %s", leftop_text, rightop_text) - else - expression_text = string.format("%s == %s + %d", leftop_text, rightop_text, value) - end + expression_text = string.format("%s > %s", leftop_text, rightop_text) + else + expression_text = string.format("%s == %s + %d", leftop_text, rightop_text, value) + end elseif optable[opsel] == "eq" then expression_text = string.format("%s == %s", leftop_text, rightop_text) elseif optable[opsel] == "ne" then if (value == 0 ) then - expression_text = string.format("%s != %s", leftop_text, rightop_text) - else - expression_text = string.format("%s == %s +/- %d", leftop_text, rightop_text, value) - end + expression_text = string.format("%s != %s", leftop_text, rightop_text) + else + expression_text = string.format("%s == %s +/- %d", leftop_text, rightop_text, value) + end elseif optable[opsel] == "beq" then expression_text = string.format("%s BITWISE== %s", leftop_text, rightop_text) elseif optable[opsel] == "bne" then @@ -651,10 +651,10 @@ function cheatfind.startplugin() expression_text = string.format("%s == %d", leftop_text, value) elseif optable[opsel] == "nev" then string.format("%s != %d", leftop_text, value) - end + end return { _("Perform Compare : ") .. expression_text, "", 0 }, f end - menu[#menu + 1] = function() return { "---", "", "off" }, nil end + menu[#menu + 1] = function() return { "---", "", "off" }, nil end menu[#menu + 1] = function() local m = { _(leftop), "", 0 } menu_lim(leftop, 1, #menu_blocks[1], m) @@ -712,7 +712,7 @@ function cheatfind.startplugin() m = { _("Value"), value, "" } else m = { _("Difference"), value, "" } - end + end local max = 100 -- max value? menu_lim(value, 0, max, m) if value == 0 and optable[opsel]:sub(3, 3) ~= "v" then @@ -726,7 +726,7 @@ function cheatfind.startplugin() menu_lim(width, 1, #formtable, m) return m, function(event) local r width, r = incdec(event, width, 1, #formtable) return r end end - + menu[#menu + 1] = function() local m = { _("Test/Write Poke Value"), pokevaltable[pokevalsel], 0 } menu_lim(pokevalsel, 1, #pokevaltable, m) @@ -741,19 +741,19 @@ function cheatfind.startplugin() elseif pokevalsel == 3 then manager:machine():popmessage(_("Use this if you want to poke 0x00")) elseif pokevalsel == 4 then - manager:machine():popmessage(_("Use this if you want to poke 0x01")) + manager:machine():popmessage(_("Use this if you want to poke 0x01")) elseif pokevalsel == 5 then manager:machine():popmessage(_("Use this if you want to poke 0x02")) elseif pokevalsel == 6 then - manager:machine():popmessage(_("Use this if you want to poke 0x03")) + manager:machine():popmessage(_("Use this if you want to poke 0x03")) elseif pokevalsel == 7 then manager:machine():popmessage(_("Use this if you want to poke 0x04")) elseif pokevalsel == 8 then - manager:machine():popmessage(_("Use this if you want to poke 0x05")) + manager:machine():popmessage(_("Use this if you want to poke 0x05")) elseif pokevalsel == 9 then manager:machine():popmessage(_("Use this if you want to poke 0x06")) elseif pokevalsel == 10 then - manager:machine():popmessage(_("Use this if you want to poke 0x07")) + manager:machine():popmessage(_("Use this if you want to poke 0x07")) elseif pokevalsel == 11 then manager:machine():popmessage(_("Use this if you want to poke 0x08")) elseif pokevalsel == 12 then @@ -763,7 +763,7 @@ function cheatfind.startplugin() elseif pokevalsel == 14 then manager:machine():popmessage(_("Use this if you want to poke 0x99 (BCD 99)")) elseif pokevalsel == 15 then - manager:machine():popmessage(_("Use this if you want to poke 0xFF (Decimal 255)")) + manager:machine():popmessage(_("Use this if you want to poke 0xFF (Decimal 255)")) elseif pokevalsel == 16 then manager:machine():popmessage(_("Use this if you want to poke 0x3E7 (Decimal 999)")) elseif pokevalsel == 17 then @@ -773,15 +773,15 @@ function cheatfind.startplugin() elseif pokevalsel == 19 then manager:machine():popmessage(_("Use this if you want to poke 0x9999 (BCD 9999)")) elseif pokevalsel == 20 then - manager:machine():popmessage(_("Use this if you want to poke 0xFFFF (Decimal 65535)")) + manager:machine():popmessage(_("Use this if you want to poke 0xFFFF (Decimal 65535)")) end end return r end return m, f end - - + + menu[#menu + 1] = function() if optable[opsel] == "bne" or optable[opsel] == "beq" then return nil @@ -873,12 +873,12 @@ function cheatfind.startplugin() local function match_exec(match) local dev = devtable[devcur] - + local wid = formtable[width]:sub(3, 3) local widchar local pokevalue local form - + if pokevalsel == 1 then pokevalue = match.oldval elseif pokevalsel == 2 then @@ -914,25 +914,25 @@ function cheatfind.startplugin() elseif pokevalsel == 17 and wid == "1" then pokevalue = 153 elseif pokevalsel == 18 and wid == "1" then - pokevalue = 99 + pokevalue = 99 elseif pokevalsel == 19 and wid == "1" then - pokevalue = 153 + pokevalue = 153 elseif pokevalsel == 20 and wid == "1" then - pokevalue = 255 + pokevalue = 255 elseif pokevalsel == 16 then - pokevalue = 999 + pokevalue = 999 elseif pokevalsel == 17 then - pokevalue = 2457 + pokevalue = 2457 elseif pokevalsel == 18 then - pokevalue = 9999 + pokevalue = 9999 elseif pokevalsel == 19 then - pokevalue = 39321 + pokevalue = 39321 elseif pokevalsel == 20 then - pokevalue = 65535 + pokevalue = 65535 end - + local cheat = { desc = string.format(_("Test Cheat %08X:%02X"), match.addr, pokevalue), script = {} } - + if wid == "2" then wid = "u16" form = "%08x %04x" @@ -958,7 +958,7 @@ function cheatfind.startplugin() form = "%08x %02x" widchar = "b" end - + if getmetatable(dev.space).__name:match("device_t") then cheat.ram = { ram = dev.tag } cheat.script.run = "ram:write(" .. match.addr .. "," .. pokevalue .. ")" @@ -1001,7 +1001,7 @@ function cheatfind.startplugin() cheat_save.json = json.stringify({[1] = cheat}, {indent = true}) cheat_save.xml = string.format("\n \n \n \n", dev.tag:sub(2), widchar, match.addr, match.newval) cheat_save.simple = string.format("%s,%s,%X,%s,%X,%%s\n", setname, dev.tag, match.addr, widchar, pokevalue) - cheat_save.dat = string.format(":%s:40000000:%X:%08X:FFFFFFFF:%%s\n", setname, match.addr, pokevalue) + cheat_save.dat = string.format(":%s:40000000:%X:%08X:FFFFFFFF:%%s\n", setname, match.addr, pokevalue) manager:machine():popmessage(string.format(_("Default name is %s"), cheat_save.name)) return true else @@ -1026,7 +1026,7 @@ function cheatfind.startplugin() match.mode = 1 end local modes = { _("Test"), _("Write"), _("Watch") } - local m = { string.format("%08x" .. bitwidth .. bitwidth, match.addr, match.oldval, + local m = { string.format("%08x" .. bitwidth .. bitwidth, match.addr, match.oldval, match.newval), modes[match.mode], 0 } menu_lim(match.mode, 1, #modes, m) local function f(event) @@ -1081,12 +1081,12 @@ function cheatfind.startplugin() local height = mame_manager:ui():get_line_height() for num, watch in ipairs(watches) do screen:draw_text("left", num * height, string.format(watch.format, watch.addr, watch.func())) - end + end if tabbed_out and manager:ui():is_menu_active() then emu.pause() menu_is_showing = true tabbed_out = false - end + end end) emu.register_periodic(function () if menu_is_showing and not manager:ui():is_menu_active() then @@ -1094,7 +1094,7 @@ function cheatfind.startplugin() menu_is_showing = false tabbed_out = true end - end) + end) end return exports diff --git a/src/devices/bus/amiga/zorro/buddha.cpp b/src/devices/bus/amiga/zorro/buddha.cpp index 65c5be6a383..376e2824660 100644 --- a/src/devices/bus/amiga/zorro/buddha.cpp +++ b/src/devices/bus/amiga/zorro/buddha.cpp @@ -231,8 +231,8 @@ READ16_MEMBER( buddha_device::ide_0_interrupt_r ) data = m_ide_0_interrupt << 15; -// if (VERBOSE) -// logerror("ide_0_interrupt_r %04x [mask = %04x]\n", data, mem_mask); +// if (VERBOSE) +// logerror("ide_0_interrupt_r %04x [mask = %04x]\n", data, mem_mask); return data; } @@ -243,8 +243,8 @@ READ16_MEMBER( buddha_device::ide_1_interrupt_r ) data = m_ide_1_interrupt << 15; -// if (VERBOSE) -// logerror("ide_1_interrupt_r %04x [mask = %04x]\n", data, mem_mask); +// if (VERBOSE) +// logerror("ide_1_interrupt_r %04x [mask = %04x]\n", data, mem_mask); return data; } diff --git a/src/devices/bus/ekara/slot.cpp b/src/devices/bus/ekara/slot.cpp index 6748ee935cc..5140e3f28ab 100644 --- a/src/devices/bus/ekara/slot.cpp +++ b/src/devices/bus/ekara/slot.cpp @@ -273,5 +273,5 @@ WRITE_LINE_MEMBER(ekara_cart_slot_device::write_scl) READ_LINE_MEMBER(ekara_cart_slot_device::read_sda ) { - return m_cart->read_sda(); + return m_cart->read_sda(); } diff --git a/src/devices/bus/ekara/slot.h b/src/devices/bus/ekara/slot.h index 5a619b7d800..945a5175d4b 100644 --- a/src/devices/bus/ekara/slot.h +++ b/src/devices/bus/ekara/slot.h @@ -36,7 +36,7 @@ public: virtual DECLARE_READ8_MEMBER(read_extra) { return 0xff; } virtual DECLARE_WRITE8_MEMBER(write_extra) { } - virtual DECLARE_WRITE_LINE_MEMBER(write_sda) { } + virtual DECLARE_WRITE_LINE_MEMBER(write_sda) { } virtual DECLARE_WRITE_LINE_MEMBER(write_scl) { } //virtual DECLARE_WRITE_LINE_MEMBER( write_wc ) virtual DECLARE_READ_LINE_MEMBER( read_sda ) { return 0; } @@ -107,7 +107,7 @@ public: virtual DECLARE_READ8_MEMBER(read_extra); virtual DECLARE_WRITE8_MEMBER(write_extra); - virtual DECLARE_WRITE_LINE_MEMBER(write_sda); + virtual DECLARE_WRITE_LINE_MEMBER(write_sda); virtual DECLARE_WRITE_LINE_MEMBER(write_scl); //virtual DECLARE_WRITE_LINE_MEMBER( write_wc ); virtual DECLARE_READ_LINE_MEMBER( read_sda ); diff --git a/src/devices/bus/vsmile/vsmile_slot.cpp b/src/devices/bus/vsmile/vsmile_slot.cpp index e7b8546ea20..61d7873b63f 100644 --- a/src/devices/bus/vsmile/vsmile_slot.cpp +++ b/src/devices/bus/vsmile/vsmile_slot.cpp @@ -251,4 +251,4 @@ WRITE16_MEMBER(vsmile_cart_slot_device::bank3_w) void vsmile_cart_slot_device::set_cs2(bool cs2) { m_cart->set_cs2(cs2); -} \ No newline at end of file +} diff --git a/src/devices/cpu/i386/cpuidmsrs.hxx b/src/devices/cpu/i386/cpuidmsrs.hxx index 66a49708d86..6163dd7257f 100644 --- a/src/devices/cpu/i386/cpuidmsrs.hxx +++ b/src/devices/cpu/i386/cpuidmsrs.hxx @@ -280,15 +280,15 @@ uint64_t athlonxp_device::opcode_rdmsr(bool &valid_msr) // 39-12 PhyBase27-0 - Base address for this memory range /* Format of type field: Bits 2-0 specify the memory type with the following encoding - 0 UC Uncacheable - 1 WC Write Combining - 4 WT Write Through - 5 WP Write Protect - 6 WB Write Back - 7 UC Uncacheable used only in PAT register - Bit 3 WrMem 1 write to memory 0 write to mmio, present only in fixed range MTRRs - Bit 4 RdMem 1 read from memory 0 read from mmio, present only in fixed range MTRRs - Other bits are unused + 0 UC Uncacheable + 1 WC Write Combining + 4 WT Write Through + 5 WP Write Protect + 6 WB Write Back + 7 UC Uncacheable used only in PAT register + Bit 3 WrMem 1 write to memory 0 write to mmio, present only in fixed range MTRRs + Bit 4 RdMem 1 read from memory 0 read from mmio, present only in fixed range MTRRs + Other bits are unused */ break; case 0x201: // MTRRphysMask0-7 diff --git a/src/devices/cpu/i86/i186.h b/src/devices/cpu/i86/i186.h index 62743f4c4b1..f16f1fac8cf 100644 --- a/src/devices/cpu/i86/i186.h +++ b/src/devices/cpu/i86/i186.h @@ -132,7 +132,7 @@ private: dma_state m_dma[2]; intr_state m_intr; mem_state m_mem; - bool m_last_dma; + bool m_last_dma; static const device_timer_id TIMER_INT0 = 0; static const device_timer_id TIMER_INT1 = 1; diff --git a/src/devices/machine/8042kbdc.h b/src/devices/machine/8042kbdc.h index 41ea07e71ba..38bdbe3814a 100644 --- a/src/devices/machine/8042kbdc.h +++ b/src/devices/machine/8042kbdc.h @@ -115,7 +115,7 @@ private: uint16_t m_mouse_y; uint8_t m_mouse_btn; - emu_timer * m_update_timer; + emu_timer * m_update_timer; DECLARE_WRITE_LINE_MEMBER( keyboard_w ); }; diff --git a/src/devices/machine/nscsi_cd.cpp b/src/devices/machine/nscsi_cd.cpp index 06ecb71bb04..0446c600e9f 100644 --- a/src/devices/machine/nscsi_cd.cpp +++ b/src/devices/machine/nscsi_cd.cpp @@ -607,4 +607,4 @@ bool nscsi_cdrom_sgi_device::scsi_command_done(uint8_t command, uint8_t length) default: return nscsi_full_device::scsi_command_done(command, length); } -} \ No newline at end of file +} diff --git a/src/devices/machine/spg110.cpp b/src/devices/machine/spg110.cpp index d1d4f9cfabd..df614deb314 100644 --- a/src/devices/machine/spg110.cpp +++ b/src/devices/machine/spg110.cpp @@ -5,9 +5,9 @@ SunPlus SPG110-series SoC peripheral emulation 0032xx looks like it could be the same as 003dxx on spg2xx - but the video seems to have differences, and data - is fetched from private buffers filled by DMA instead of - main space? tile attributes different? palette format different + but the video seems to have differences, and data + is fetched from private buffers filled by DMA instead of + main space? tile attributes different? palette format different **********************************************************************/ @@ -151,7 +151,7 @@ void spg110_device::blit_page(const rectangle &cliprect, uint32_t scanline, int blit(cliprect, tile_scanline, xx, yy, attr, ctrl, bitmap_addr, tile); else blit(cliprect, tile_scanline, xx, yy, attr, ctrl, bitmap_addr, tile); - + } } @@ -214,11 +214,11 @@ GFXDECODE_END void spg110_device::device_add_mconfig(machine_config &config) { -// PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 0x100); -// PALETTE(config, m_palette).set_format(palette_device::RGB_565, 0x100); -// PALETTE(config, m_palette).set_format(palette_device::IRGB_4444, 0x100); -// PALETTE(config, m_palette).set_format(palette_device::RGBI_4444, 0x100); -// PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 0x100); +// PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 0x100); +// PALETTE(config, m_palette).set_format(palette_device::RGB_565, 0x100); +// PALETTE(config, m_palette).set_format(palette_device::IRGB_4444, 0x100); +// PALETTE(config, m_palette).set_format(palette_device::RGBI_4444, 0x100); +// PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 0x100); PALETTE(config, m_palette, palette_device::BLACK, 256); GFXDECODE(config, m_gfxdecode, m_palette, gfx); @@ -337,7 +337,7 @@ WRITE16_MEMBER(spg110_device::dma_len_trigger_w) uint16_t val = mem.read_word(source); this->space(0).write_word(dest * 2, val, 0xffff); - + source+=m_dma_src_step; dest+=m_dma_dst_step; } @@ -436,14 +436,14 @@ WRITE16_MEMBER(spg110_device::tmap1_regs_w) void spg110_device::map(address_map &map) { map(0x000000, 0x000fff).ram(); - - + + // vregs are at 2000? map(0x002010, 0x002015).rw(FUNC(spg110_device::tmap0_regs_r), FUNC(spg110_device::tmap0_regs_w)); map(0x002016, 0x00201b).rw(FUNC(spg110_device::tmap1_regs_r), FUNC(spg110_device::tmap1_regs_w)); map(0x00201c, 0x00201c).w(FUNC(spg110_device::spg110_201c_w)); - + map(0x002020, 0x002020).w(FUNC(spg110_device::spg110_2020_w)); map(0x002028, 0x002028).rw(FUNC(spg110_device::spg110_2028_r), FUNC(spg110_device::spg110_2028_w)); @@ -484,7 +484,7 @@ void spg110_device::map(address_map &map) map(0x00205d, 0x00205d).w(FUNC(spg110_device::spg110_205d_w)); map(0x00205e, 0x00205e).w(FUNC(spg110_device::spg110_205e_w)); map(0x00205f, 0x00205f).w(FUNC(spg110_device::spg110_205f_w)); - + //map(0x002010, 0x00205f).ram(); // everything (dma? and interrupt flag?!) @@ -498,9 +498,9 @@ void spg110_device::map(address_map &map) map(0x002068, 0x002068).w(FUNC(spg110_device::dma_src_step_w)); map(0x002200, 0x0022ff).ram(); // looks like per-pen brightness or similar? strange because palette isn't memory mapped here - + map(0x003000, 0x00307f).ram(); // sound registers? seems to be 8 long entries, only uses up to 0x7f? - map(0x003080, 0x0030ff).ram(); + map(0x003080, 0x0030ff).ram(); map(0x003100, 0x003100).w(FUNC(spg110_device::spg110_3100_w)); map(0x003101, 0x003101).w(FUNC(spg110_device::spg110_3101_w)); @@ -548,7 +548,7 @@ void spg110_device::map_video(address_map &map) map(0x04000, 0x04fff).ram(); // seems to be 3 blocks, almost certainly spritelist -// map(0x08000, 0x081ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); // probably? format unknown tho +// map(0x08000, 0x081ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); // probably? format unknown tho map(0x08000, 0x081ff).ram().share("palram"); } diff --git a/src/devices/machine/timekpr.cpp b/src/devices/machine/timekpr.cpp index 614f071ade7..f7cfed5451c 100644 --- a/src/devices/machine/timekpr.cpp +++ b/src/devices/machine/timekpr.cpp @@ -351,7 +351,7 @@ TIMER_CALLBACK_MEMBER(timekeeper_device::watchdog_callback) m_data[m_offset_flags] |= FLAGS_WDF; // WDS (bit 7) selects callback if (m_data[m_offset_watchdog] & 0x80) - { + { // Clear watchdog register m_data[m_offset_watchdog] = 0; m_reset_cb(ASSERT_LINE); diff --git a/src/devices/sound/ay8910.cpp b/src/devices/sound/ay8910.cpp index 00e9f324f87..9ee02834f67 100644 --- a/src/devices/sound/ay8910.cpp +++ b/src/devices/sound/ay8910.cpp @@ -512,54 +512,54 @@ Yamaha YMZ294: limited info: 0 I/O port OKI M5255, Winbond WF19054, JFC 95101, File KC89C72, Toshiba T7766A : differences to be listed AY8930 Expanded mode registers : - Bank Register Bits - A 0 xxxx xxxx Channel A Tone period fine tune - A 1 xxxx xxxx Channel A Tone period coarse tune - A 2 xxxx xxxx Channel B Tone period fine tune - A 3 xxxx xxxx Channel B Tone period coarse tune - A 4 xxxx xxxx Channel C Tone period fine tune - A 5 xxxx xxxx Channel C Tone period coarse tune - A 6 xxxx xxxx Noise period - A 7 x--- ---- I/O Port B input(0) / output(1) - -x-- ---- I/O Port A input(0) / output(1) - --x- ---- Channel C Noise enable(0) / disable(1) - ---x ---- Channel B Noise enable(0) / disable(1) - ---- x--- Channel A Noise enable(0) / disable(1) - ---- -x-- Channel C Tone enable(0) / disable(1) - ---- --x- Channel B Tone enable(0) / disable(1) - ---- ---x Channel A Tone enable(0) / disable(1) - A 8 --x- ---- Channel A Envelope mode - ---x xxxx Channel A Tone volume - A 9 --x- ---- Channel B Envelope mode - ---x xxxx Channel B Tone volume - A A --x- ---- Channel C Envelope mode - ---x xxxx Channel C Tone volume - A B xxxx xxxx Channel A Envelope period fine tune - A C xxxx xxxx Channel A Envelope period coarse tune - A D 101- ---- 101 = Expanded mode enable, other AY-3-8910A Compatiblity mode - ---0 ---- 0 for Register Bank A - ---- xxxx Channel A Envelope Shape/Cycle - A E xxxx xxxx 8 bit Parallel I/O on Port A - A F xxxx xxxx 8 bit Parallel I/O on Port B - - B 0 xxxx xxxx Channel B Envelope period fine tune - B 1 xxxx xxxx Channel B Envelope period coarse tune - B 2 xxxx xxxx Channel C Envelope period fine tune - B 3 xxxx xxxx Channel C Envelope period coarse tune - B 4 ---- xxxx Channel B Envelope Shape/Cycle - B 5 ---- xxxx Channel C Envelope Shape/Cycle - B 6 ---- xxxx Channel A Duty Cycle - B 7 ---- xxxx Channel B Duty Cycle - B 8 ---- xxxx Channel C Duty Cycle - B 9 xxxx xxxx Noise "And" Mask - B A xxxx xxxx Noise "Or" Mask - B B Reserved (Read as 0) - B C Reserved (Read as 0) - B D 101- ---- 101 = Expanded mode enable, other AY-3-8910A Compatiblity mode - ---1 ---- 1 for Register Bank B - ---- xxxx Channel A Envelope Shape - B E Reserved (Read as 0) - B F Test (Function unknown) + Bank Register Bits + A 0 xxxx xxxx Channel A Tone period fine tune + A 1 xxxx xxxx Channel A Tone period coarse tune + A 2 xxxx xxxx Channel B Tone period fine tune + A 3 xxxx xxxx Channel B Tone period coarse tune + A 4 xxxx xxxx Channel C Tone period fine tune + A 5 xxxx xxxx Channel C Tone period coarse tune + A 6 xxxx xxxx Noise period + A 7 x--- ---- I/O Port B input(0) / output(1) + -x-- ---- I/O Port A input(0) / output(1) + --x- ---- Channel C Noise enable(0) / disable(1) + ---x ---- Channel B Noise enable(0) / disable(1) + ---- x--- Channel A Noise enable(0) / disable(1) + ---- -x-- Channel C Tone enable(0) / disable(1) + ---- --x- Channel B Tone enable(0) / disable(1) + ---- ---x Channel A Tone enable(0) / disable(1) + A 8 --x- ---- Channel A Envelope mode + ---x xxxx Channel A Tone volume + A 9 --x- ---- Channel B Envelope mode + ---x xxxx Channel B Tone volume + A A --x- ---- Channel C Envelope mode + ---x xxxx Channel C Tone volume + A B xxxx xxxx Channel A Envelope period fine tune + A C xxxx xxxx Channel A Envelope period coarse tune + A D 101- ---- 101 = Expanded mode enable, other AY-3-8910A Compatiblity mode + ---0 ---- 0 for Register Bank A + ---- xxxx Channel A Envelope Shape/Cycle + A E xxxx xxxx 8 bit Parallel I/O on Port A + A F xxxx xxxx 8 bit Parallel I/O on Port B + + B 0 xxxx xxxx Channel B Envelope period fine tune + B 1 xxxx xxxx Channel B Envelope period coarse tune + B 2 xxxx xxxx Channel C Envelope period fine tune + B 3 xxxx xxxx Channel C Envelope period coarse tune + B 4 ---- xxxx Channel B Envelope Shape/Cycle + B 5 ---- xxxx Channel C Envelope Shape/Cycle + B 6 ---- xxxx Channel A Duty Cycle + B 7 ---- xxxx Channel B Duty Cycle + B 8 ---- xxxx Channel C Duty Cycle + B 9 xxxx xxxx Noise "And" Mask + B A xxxx xxxx Noise "Or" Mask + B B Reserved (Read as 0) + B C Reserved (Read as 0) + B D 101- ---- 101 = Expanded mode enable, other AY-3-8910A Compatiblity mode + ---1 ---- 1 for Register Bank B + ---- xxxx Channel A Envelope Shape + B E Reserved (Read as 0) + B F Test (Function unknown) Decaps: AY-3-8914 - http://siliconpr0n.org/map/gi/ay-3-8914/mz_mit20x/ diff --git a/src/devices/sound/ics2115.cpp b/src/devices/sound/ics2115.cpp index c5cfea8e94a..9ce19fe649f 100644 --- a/src/devices/sound/ics2115.cpp +++ b/src/devices/sound/ics2115.cpp @@ -885,8 +885,8 @@ u16 ics2115_device::word_r(offs_t offset, u16 mem_mask) break; /* case 3: - TODO : used for byte size only; - break; + TODO : used for byte size only; + break; */ default: #ifdef ICS2115_DEBUG @@ -911,8 +911,8 @@ void ics2115_device::word_w(offs_t offset, u16 data, u16 mem_mask) break; /* case 3: - TODO : used for byte size only; - break; + TODO : used for byte size only; + break; */ default: #ifdef ICS2115_DEBUG diff --git a/src/devices/video/crt9028.cpp b/src/devices/video/crt9028.cpp index 8126e5c6344..31c0c748420 100644 --- a/src/devices/video/crt9028.cpp +++ b/src/devices/video/crt9028.cpp @@ -106,7 +106,7 @@ crt9028_000_device::crt9028_000_device(const machine_config &mconfig, const char 24, 10, false, 20, 4, 8, 72, 30, 10, - 2, 8, 9, + 2, 8, 9, 0x3c0, 0x038, 0x007, 0x0f, 0x3e0, 0x020, 0x03f, 0x020, 0x10, 0xff, 0x10, 0xff) diff --git a/src/lib/netlist/analog/nlid_fourterm.h b/src/lib/netlist/analog/nlid_fourterm.h index 0b0f75d378b..5ca6a747116 100644 --- a/src/lib/netlist/analog/nlid_fourterm.h +++ b/src/lib/netlist/analog/nlid_fourterm.h @@ -44,7 +44,7 @@ namespace netlist { , m_OP(*this, "OP", &m_IP) , m_ON(*this, "ON", &m_IP) , m_IP(*this, "IP", &m_IN) // <= this should be NULL and terminal be filtered out prior to solving... - , m_IN(*this, "IN", &m_IP) // <= this should be NULL and terminal be filtered out prior to solving... + , m_IN(*this, "IN", &m_IP) // <= this should be NULL and terminal be filtered out prior to solving... , m_OP1(*this, "_OP1", &m_IN) , m_ON1(*this, "_ON1", &m_IN) , m_gfac(1.0) diff --git a/src/lib/netlist/analog/nlid_twoterm.h b/src/lib/netlist/analog/nlid_twoterm.h index 131504d86e4..67939f32645 100644 --- a/src/lib/netlist/analog/nlid_twoterm.h +++ b/src/lib/netlist/analog/nlid_twoterm.h @@ -426,7 +426,7 @@ public: } protected: - // NETLIB_UPDATEI() { NETLIB_NAME(twoterm)::update(time); } + // NETLIB_UPDATEI() { NETLIB_NAME(twoterm)::update(time); } NETLIB_RESETI() { diff --git a/src/lib/netlist/devices/nld_2102A.cpp b/src/lib/netlist/devices/nld_2102A.cpp index d256a1e244d..0ec7132b401 100644 --- a/src/lib/netlist/devices/nld_2102A.cpp +++ b/src/lib/netlist/devices/nld_2102A.cpp @@ -97,7 +97,7 @@ namespace netlist m_ram[i] = 0; } - NETLIB_DEVICE_IMPL(2102A, "RAM_2102A", "+CEQ,+A0,+A1,+A2,+A3,+A4,+A5,+A6,+A7,+A8,+A9,+RWQ,+DI") + NETLIB_DEVICE_IMPL(2102A, "RAM_2102A", "+CEQ,+A0,+A1,+A2,+A3,+A4,+A5,+A6,+A7,+A8,+A9,+RWQ,+DI") NETLIB_DEVICE_IMPL(2102A_dip,"RAM_2102A_DIP","") } //namespace devices diff --git a/src/lib/netlist/devices/nld_74174.cpp b/src/lib/netlist/devices/nld_74174.cpp index 13ceb370cfd..83369075db6 100644 --- a/src/lib/netlist/devices/nld_74174.cpp +++ b/src/lib/netlist/devices/nld_74174.cpp @@ -134,7 +134,7 @@ namespace netlist //m_sub.do_reset(); } - NETLIB_DEVICE_IMPL(74174, "TTL_74174", "+CLK,+D1,+D2,+D3,+D4,+D5,+D6,+CLRQ") + NETLIB_DEVICE_IMPL(74174, "TTL_74174", "+CLK,+D1,+D2,+D3,+D4,+D5,+D6,+CLRQ") NETLIB_DEVICE_IMPL(74174_dip,"TTL_74174_DIP", "") } //namespace devices diff --git a/src/lib/netlist/devices/nld_74175.cpp b/src/lib/netlist/devices/nld_74175.cpp index 6c902df48fc..a15adb5c60f 100644 --- a/src/lib/netlist/devices/nld_74175.cpp +++ b/src/lib/netlist/devices/nld_74175.cpp @@ -111,7 +111,7 @@ namespace netlist m_data = 0xFF; } - NETLIB_DEVICE_IMPL(74175, "TTL_74175", "+CLK,+D1,+D2,+D3,+D4,+CLRQ") + NETLIB_DEVICE_IMPL(74175, "TTL_74175", "+CLK,+D1,+D2,+D3,+D4,+CLRQ") NETLIB_DEVICE_IMPL(74175_dip,"TTL_74175_DIP", "") } //namespace devices diff --git a/src/lib/netlist/devices/nld_74192.cpp b/src/lib/netlist/devices/nld_74192.cpp index 81edfd050be..a256f89451e 100644 --- a/src/lib/netlist/devices/nld_74192.cpp +++ b/src/lib/netlist/devices/nld_74192.cpp @@ -162,7 +162,7 @@ namespace netlist m_CARRYQ.push(tCarry, NLTIME_FROM_NS(20)); //FIXME } - NETLIB_DEVICE_IMPL(74192, "TTL_74192", "+A,+B,+C,+D,+CLEAR,+LOADQ,+CU,+CD") + NETLIB_DEVICE_IMPL(74192, "TTL_74192", "+A,+B,+C,+D,+CLEAR,+LOADQ,+CU,+CD") NETLIB_DEVICE_IMPL(74192_dip,"TTL_74192_DIP", "") } //namespace devices diff --git a/src/lib/netlist/devices/nld_74193.cpp b/src/lib/netlist/devices/nld_74193.cpp index c5d46df3618..73b1d697b7b 100644 --- a/src/lib/netlist/devices/nld_74193.cpp +++ b/src/lib/netlist/devices/nld_74193.cpp @@ -139,7 +139,7 @@ namespace netlist m_CARRYQ.push(tCarry, NLTIME_FROM_NS(20)); //FIXME timing } - NETLIB_DEVICE_IMPL(74193, "TTL_74193", "+A,+B,+C,+D,+CLEAR,+LOADQ,+CU,+CD") + NETLIB_DEVICE_IMPL(74193, "TTL_74193", "+A,+B,+C,+D,+CLEAR,+LOADQ,+CU,+CD") NETLIB_DEVICE_IMPL(74193_dip, "TTL_74193_DIP", "") } //namespace devices diff --git a/src/lib/netlist/devices/nld_74194.cpp b/src/lib/netlist/devices/nld_74194.cpp index 205263c2d44..9876aa6b170 100644 --- a/src/lib/netlist/devices/nld_74194.cpp +++ b/src/lib/netlist/devices/nld_74194.cpp @@ -116,7 +116,7 @@ namespace netlist m_Q[i].push((q >> i) & 1, NLTIME_FROM_NS(26)); // FIXME: Timing } - NETLIB_DEVICE_IMPL(74194, "TTL_74194", "+CLK,+S0,+S1,+SRIN,+A,+B,+C,+D,+SLIN,+CLRQ") + NETLIB_DEVICE_IMPL(74194, "TTL_74194", "+CLK,+S0,+S1,+SRIN,+A,+B,+C,+D,+SLIN,+CLRQ") NETLIB_DEVICE_IMPL(74194_dip, "TTL_74194_DIP", "") } //namespace devices diff --git a/src/lib/netlist/devices/nld_ne555.cpp b/src/lib/netlist/devices/nld_ne555.cpp index d1d34835f14..ab63a58ee4c 100644 --- a/src/lib/netlist/devices/nld_ne555.cpp +++ b/src/lib/netlist/devices/nld_ne555.cpp @@ -177,7 +177,7 @@ namespace netlist m_last_out = out; } - NETLIB_DEVICE_IMPL(NE555, "NE555", "") + NETLIB_DEVICE_IMPL(NE555, "NE555", "") NETLIB_DEVICE_IMPL(NE555_dip, "NE555_DIP", "") } //namespace devices diff --git a/src/lib/netlist/devices/nld_tms4800.cpp b/src/lib/netlist/devices/nld_tms4800.cpp index 04d87f9201d..24729b10e72 100644 --- a/src/lib/netlist/devices/nld_tms4800.cpp +++ b/src/lib/netlist/devices/nld_tms4800.cpp @@ -97,7 +97,7 @@ namespace netlist } } - NETLIB_DEVICE_IMPL(TMS4800, "ROM_TMS4800", "+AR,+OE1,+OE2,+A0,+A1,+A2,+A3,+A4,+A5,+A6,+A7,+A8,+A9,+A10") + NETLIB_DEVICE_IMPL(TMS4800, "ROM_TMS4800", "+AR,+OE1,+OE2,+A0,+A1,+A2,+A3,+A4,+A5,+A6,+A7,+A8,+A9,+A10") NETLIB_DEVICE_IMPL(TMS4800_dip, "ROM_TMS4800_DIP", "") } //namespace devices diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index 8625010e92b..bc77f7ffd13 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -202,7 +202,7 @@ namespace netlist { } - NETLIB_UPDATEI() { } + NETLIB_UPDATEI() { } NETLIB_RESETI() { m_Q.initial(0.0); } NETLIB_UPDATE_PARAMI() { m_Q.push(m_IN()); } diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index e5c59c7d43d..c2dd2c683a3 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -30,8 +30,8 @@ namespace detail //static plib::mempool *pool() //{ - // static plib::mempool s_pool(655360, 32); - // return &s_pool; + // static plib::mempool s_pool(655360, 32); + // return &s_pool; //} #if 0 @@ -49,7 +49,7 @@ namespace detail if (mem) { //if ((USE_MEMPOOL)) - // pool()->free(mem); + // pool()->free(mem); //else ::operator delete(mem); } @@ -142,7 +142,7 @@ 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) @@ -192,7 +192,7 @@ detail::netlist_ref::netlist_ref(netlist_state_t &nl) // ---------------------------------------------------------------------------------------- detail::object_t::object_t(const pstring &aname) -// : m_name(aname) +// : m_name(aname) { name_hash().insert({this, aname}); } diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index e210bd13089..22bd9848565 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -1164,7 +1164,7 @@ namespace netlist virtual bool is_timestep() const { return false; } private: - bool m_hint_deactivate; + bool m_hint_deactivate; state_var_s32 m_active_outputs; }; @@ -1675,7 +1675,7 @@ namespace netlist { nl_assert(terminal_state() != STATE_INP_PASSIVE); //if (net().Q() != m_Q) - // printf("term: %s, %d %d TS %d\n", this->name().c_str(), net().Q(), m_Q, terminal_state()); + // printf("term: %s, %d %d TS %d\n", this->name().c_str(), net().Q(), m_Q, terminal_state()); #if USE_COPY_INSTEAD_OF_REFERENCE return m_Q; #else diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h index 2cadd3b3e1c..bf0c934a94b 100644 --- a/src/lib/netlist/nl_setup.h +++ b/src/lib/netlist/nl_setup.h @@ -278,9 +278,9 @@ namespace netlist protected: std::unordered_map m_models; std::stack m_namespace_stack; - std::unordered_map m_alias; + std::unordered_map m_alias; std::vector m_links; - std::unordered_map m_param_values; + std::unordered_map m_param_values; source_t::list_t m_sources; @@ -291,7 +291,7 @@ namespace netlist private: - plib::ppreprocessor::defines_map_type m_defines; + plib::ppreprocessor::defines_map_type m_defines; setup_t &m_setup; log_type &m_log; @@ -384,7 +384,7 @@ namespace netlist std::unordered_map m_terminals; netlist_t &m_netlist; - devices::nld_netlistparams *m_netlist_params; + devices::nld_netlistparams *m_netlist_params; std::unordered_map m_params; unsigned m_proxy_cnt; diff --git a/src/lib/netlist/plib/gmres.h b/src/lib/netlist/plib/gmres.h index 345c96b5c63..d3551897f69 100644 --- a/src/lib/netlist/plib/gmres.h +++ b/src/lib/netlist/plib/gmres.h @@ -76,12 +76,12 @@ namespace plib } PALIGNAS_VECTOROPT() - mat_type m_mat; + mat_type m_mat; PALIGNAS_VECTOROPT() - mat_type m_LU; - bool m_use_iLU_preconditioning; - std::size_t m_ILU_scale; - std::size_t m_band_width; + mat_type m_LU; + bool m_use_iLU_preconditioning; + std::size_t m_ILU_scale; + std::size_t m_band_width; }; template @@ -256,7 +256,7 @@ namespace plib m_g[0] = rho; //for (std::size_t i = 0; i < mr + 1; i++) - // vec_set_scalar(mr, m_ht[i], NL_FCONST(0.0)); + // vec_set_scalar(mr, m_ht[i], NL_FCONST(0.0)); vec_mult_scalar(n, residual, constants::one() / rho, m_v[0]); @@ -331,11 +331,11 @@ namespace plib plib::parray residual; plib::parray Ax; - plib::parray m_c; /* mr + 1 */ - plib::parray m_g; /* mr + 1 */ + plib::parray m_c; /* mr + 1 */ + plib::parray m_g; /* mr + 1 */ plib::parray, RESTART + 1> m_ht; /* (mr + 1), mr */ - plib::parray m_s; /* mr + 1 */ - plib::parray m_y; /* mr + 1 */ + plib::parray m_s; /* mr + 1 */ + plib::parray m_y; /* mr + 1 */ //plib::parray m_v[RESTART + 1]; /* mr + 1, n */ plib::parray, RESTART + 1> m_v; /* mr + 1, n */ @@ -418,10 +418,10 @@ namespace plib } else { - beta = alpha * ( c / 2.0)*( c / 2.0); - alpha = 1.0 / (d - beta); - for (std::size_t k = 0; k < size(); k++) - p[k] = residual[k] + beta * p[k]; + beta = alpha * ( c / 2.0)*( c / 2.0); + alpha = 1.0 / (d - beta); + for (std::size_t k = 0; k < size(); k++) + p[k] = residual[k] + beta * p[k]; } plib::vec_add_mult_scalar(size(), p, alpha, x); ops.calc_rhs(Ax, x); diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h index 6380a4cef07..44f3bdb395e 100644 --- a/src/lib/netlist/plib/palloc.h +++ b/src/lib/netlist/plib/palloc.h @@ -34,13 +34,13 @@ namespace plib { #if defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER) return _aligned_malloc(size, alignment); #elif defined(__APPLE__) - void* p; - if (::posix_memalign(&p, alignment, size) != 0) { - p = nullptr; - } - return p; + void* p; + if (::posix_memalign(&p, alignment, size) != 0) { + p = nullptr; + } + return p; #else - return aligned_alloc(alignment, size); + return aligned_alloc(alignment, size); #endif } @@ -59,7 +59,7 @@ namespace plib { static_assert(is_pow2(ALIGN), "Alignment must be a power of 2"); //auto t = reinterpret_cast(p); //if (t & (ALIGN-1)) - // printf("alignment error!"); + // printf("alignment error!"); return reinterpret_cast(__builtin_assume_aligned(p, ALIGN)); } @@ -124,8 +124,8 @@ namespace plib { constexpr pdefault_deleter() noexcept = default; template::value>::type> - pdefault_deleter(const pdefault_deleter&) noexcept { } + std::enable_if::value>::type> + pdefault_deleter(const pdefault_deleter&) noexcept { } void operator()(T *p) const { @@ -249,62 +249,62 @@ namespace plib { class aligned_allocator { public: - using value_type = T; + using value_type = T; - static_assert(ALIGN >= alignof(T) && (ALIGN % alignof(T)) == 0, - "ALIGN must be greater than alignof(T) and a multiple"); + static_assert(ALIGN >= alignof(T) && (ALIGN % alignof(T)) == 0, + "ALIGN must be greater than alignof(T) and a multiple"); - aligned_allocator() noexcept = default; - ~aligned_allocator() noexcept = 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&) noexcept = default; + aligned_allocator& operator=(const aligned_allocator&) noexcept = delete; - aligned_allocator(aligned_allocator&&) noexcept = default; - aligned_allocator& operator=(aligned_allocator&&) = delete; + aligned_allocator(aligned_allocator&&) noexcept = default; + aligned_allocator& operator=(aligned_allocator&&) = delete; - template - aligned_allocator(const aligned_allocator& rhs) noexcept - { - unused_var(rhs); - } + template + aligned_allocator(const aligned_allocator& rhs) noexcept + { + unused_var(rhs); + } - template struct rebind + template struct rebind { - using other = aligned_allocator; + using other = aligned_allocator; }; - T* allocate(std::size_t n) - { - return reinterpret_cast(paligned_alloc(ALIGN, sizeof(T) * n)); - } + T* allocate(std::size_t n) + { + return reinterpret_cast(paligned_alloc(ALIGN, sizeof(T) * n)); + } - void deallocate(T* p, std::size_t n) noexcept - { - unused_var(n); - pfree(p); - } + void deallocate(T* p, std::size_t n) noexcept + { + unused_var(n); + pfree(p); + } - template - friend bool operator==(const aligned_allocator& lhs, - const aligned_allocator& rhs) noexcept; + template + friend bool operator==(const aligned_allocator& lhs, + const aligned_allocator& rhs) noexcept; - template friend class aligned_allocator; + template friend class aligned_allocator; }; - template - /*friend*/ inline bool operator==(const aligned_allocator& lhs, - const aligned_allocator& rhs) noexcept - { - unused_var(lhs, rhs); - return A1 == A2; - } - template - /*friend*/ inline bool operator!=(const aligned_allocator& lhs, - const aligned_allocator& rhs) noexcept - { - return !(lhs == rhs); - } + template + /*friend*/ inline bool operator==(const aligned_allocator& lhs, + const aligned_allocator& rhs) noexcept + { + unused_var(lhs, rhs); + return A1 == A2; + } + template + /*friend*/ inline bool operator!=(const aligned_allocator& lhs, + const aligned_allocator& rhs) noexcept + { + return !(lhs == rhs); + } // FIXME: needs to be somewhere else #if 0 diff --git a/src/lib/netlist/plib/parray.h b/src/lib/netlist/plib/parray.h index 9fe4ab972eb..5ab52524a07 100644 --- a/src/lib/netlist/plib/parray.h +++ b/src/lib/netlist/plib/parray.h @@ -117,8 +117,8 @@ namespace plib { private: PALIGNAS_VECTOROPT() - base_type m_a; - size_type m_size; + base_type m_a; + size_type m_size; }; } // namespace plib diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h index 3b4bc55fc32..1a411fe1aad 100644 --- a/src/lib/netlist/plib/pconfig.h +++ b/src/lib/netlist/plib/pconfig.h @@ -45,11 +45,11 @@ * Standard alignment macros */ -#define PALIGN_CACHELINE (64) -#define PALIGN_VECTOROPT (32) +#define PALIGN_CACHELINE (64) +#define PALIGN_VECTOROPT (32) -#define PALIGNAS_CACHELINE() PALIGNAS(PALIGN_CACHELINE) -#define PALIGNAS_VECTOROPT() PALIGNAS(PALIGN_VECTOROPT) +#define PALIGNAS_CACHELINE() PALIGNAS(PALIGN_CACHELINE) +#define PALIGNAS_VECTOROPT() PALIGNAS(PALIGN_VECTOROPT) /* Breaks mame build on windows due to -Wattribute */ #if defined(_WIN32) && defined(__GNUC__) diff --git a/src/lib/netlist/plib/pmempool.h b/src/lib/netlist/plib/pmempool.h index 166c6f3d483..00e78b09fb6 100644 --- a/src/lib/netlist/plib/pmempool.h +++ b/src/lib/netlist/plib/pmempool.h @@ -29,8 +29,8 @@ namespace plib { constexpr pool_deleter() noexcept = default; template::value>::type> - pool_deleter(const pool_deleter&) noexcept { } + std::enable_if::value>::type> + pool_deleter(const pool_deleter&) noexcept { } void operator()(T *p) const { @@ -140,7 +140,7 @@ namespace plib { auto capacity(rs); ret = std::align(align, size, ret, capacity); // FIXME: if (ret == nullptr) - // printf("Oh no\n"); + // printf("Oh no\n"); sinfo().insert({ ret, info(b, b->m_cur)}); rs -= (capacity - size); b->m_cur += rs; @@ -156,7 +156,7 @@ namespace plib { auto capacity(rs); ret = std::align(align, size, ret, capacity); // FIXME: if (ret == nullptr) - // printf("Oh no\n"); + // 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/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp index a751bbd2965..f9e25346493 100644 --- a/src/lib/netlist/prg/nltool.cpp +++ b/src/lib/netlist/prg/nltool.cpp @@ -17,7 +17,7 @@ #include -#define NLTOOL_VERSION 20190202 +#define NLTOOL_VERSION 20190202 class tool_app_t : public plib::app { diff --git a/src/lib/netlist/solver/nld_ms_gcr.h b/src/lib/netlist/solver/nld_ms_gcr.h index 0a9f720f104..187c9f659ea 100644 --- a/src/lib/netlist/solver/nld_ms_gcr.h +++ b/src/lib/netlist/solver/nld_ms_gcr.h @@ -67,7 +67,7 @@ private: plib::parray new_V; std::array, storage_N> m_term_cr; -// std::array, storage_N> m_term_cr; +// std::array, storage_N> m_term_cr; mat_type mat; diff --git a/src/mame/drivers/c2color.cpp b/src/mame/drivers/c2color.cpp index 092a68715e9..4164553a1a2 100644 --- a/src/mame/drivers/c2color.cpp +++ b/src/mame/drivers/c2color.cpp @@ -3,24 +3,24 @@ /****************************************************************************** basic information - https://gbatemp.net/threads/the-c2-color-game-console-an-obscure-chinese-handheld.509320/ + https://gbatemp.net/threads/the-c2-color-game-console-an-obscure-chinese-handheld.509320/ - "The C2 is a glorious console with a D-Pad, Local 2.4GHz WiFi, Cartridge slot, A, B, and C buttons, - and has micro usb power! Don't be fooled though, there is no lithium battery, so you have to put in - 3 AA batteries if you don't want to play with it tethered to a charger. + "The C2 is a glorious console with a D-Pad, Local 2.4GHz WiFi, Cartridge slot, A, B, and C buttons, + and has micro usb power! Don't be fooled though, there is no lithium battery, so you have to put in + 3 AA batteries if you don't want to play with it tethered to a charger. It comes with a built in game based on the roco kingdom characters. In addition, there is a slot on the side of the console allowing cards to be swiped through. Those - cards can add characters to the game. The console scans the barcode and a new character or item appears in the game for you to use. + cards can add characters to the game. The console scans the barcode and a new character or item appears in the game for you to use. The C2 comes with 9 holographic game cards that will melt your eyes." - also includes a link to the following video - https://www.youtube.com/watch?v=D3XO4aTZEko + also includes a link to the following video + https://www.youtube.com/watch?v=D3XO4aTZEko - TODO: - identify CPU type, and if the system ROM is needed to run carts or not + TODO: + identify CPU type, and if the system ROM is needed to run carts or not *******************************************************************************/ diff --git a/src/mame/drivers/dec0.cpp b/src/mame/drivers/dec0.cpp index f099930d29d..b5823c8bcb9 100644 --- a/src/mame/drivers/dec0.cpp +++ b/src/mame/drivers/dec0.cpp @@ -32,9 +32,9 @@ motherboard and varying game boards. Sly Spy, Midnight Resistance and Boulderdash use the same graphics chips but are different pcbs. - Bandit (USA) is almost certainly a field test prototype, the software runs - on a Heavy Barrel board including the original Heavy Barrel MCU (which is effectively - not used). There is also Japanese version known to run on a DE-0321-1 top board. + Bandit (USA) is almost certainly a field test prototype, the software runs + on a Heavy Barrel board including the original Heavy Barrel MCU (which is effectively + not used). There is also Japanese version known to run on a DE-0321-1 top board. There are Secret Agent (bootleg) and Robocop (bootleg) sets to add. @@ -472,11 +472,11 @@ void dec0_state::dec0_map(address_map &map) map(0x310000, 0x3107ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); map(0x314000, 0x3147ff).ram().w(m_palette, FUNC(palette_device::write16_ext)).share("palette_ext"); - map(0x318000, 0x31bfff).ram().share("ram"); // Bandit uses 318000/31c000 which are mirrors but exact mirror patten is unclear - map(0x31c000, 0x31c7ff).ram().share("spriteram"); + map(0x318000, 0x31bfff).ram().share("ram"); // Bandit uses 318000/31c000 which are mirrors but exact mirror patten is unclear + map(0x31c000, 0x31c7ff).ram().share("spriteram"); map(0xff8000, 0xffbfff).ram().share("ram"); /* Main ram */ - map(0xffc000, 0xffc7ff).ram().share("spriteram"); + map(0xffc000, 0xffc7ff).ram().share("spriteram"); } void dec0_state::robocop_map(address_map &map) @@ -697,7 +697,7 @@ void dec0_state::midresb_map(address_map &map) void dec0_state::dec0_s_map(address_map &map) { map(0x0000, 0x07ff).ram(); - map(0x0800, 0x0801).rw("ym1", FUNC(ym2203_device::read), FUNC(ym2203_device::write)); + map(0x0800, 0x0801).rw("ym1", FUNC(ym2203_device::read), FUNC(ym2203_device::write)); map(0x1000, 0x1001).rw("ym2", FUNC(ym3812_device::read), FUNC(ym3812_device::write)); map(0x3000, 0x3000).r(m_soundlatch, FUNC(generic_latch_8_device::read)); map(0x3800, 0x3800).rw("oki", FUNC(okim6295_device::read), FUNC(okim6295_device::write)); @@ -1083,94 +1083,94 @@ static INPUT_PORTS_START( bandit ) PORT_INCLUDE( dec0 ) PORT_MODIFY("INPUTS") - PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("P1 Fire") - PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P1 Bomb") - PORT_BIT( 0x00c0, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL PORT_NAME("P2 Fire") - PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL PORT_NAME("P2 Bomb") - PORT_BIT( 0xc000, IP_ACTIVE_LOW, IPT_UNUSED ) + PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("P1 Fire") + PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P1 Bomb") + PORT_BIT( 0x00c0, IP_ACTIVE_LOW, IPT_UNUSED ) + PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL PORT_NAME("P2 Fire") + PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL PORT_NAME("P2 Bomb") + PORT_BIT( 0xc000, IP_ACTIVE_LOW, IPT_UNUSED ) #if 0 - PORT_DIPNAME( 0x0001, 0x0001, "UNK_0" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0001, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0002, 0x0002, "UNK_1" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0002, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0004, 0x0004, "UNK_2" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0004, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0008, 0x0008, "UNK_3" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0008, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0010, 0x0010, "UNK_4" ) // Gun - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0010, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0020, 0x0020, "UNK_5" ) // Missile - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0020, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0040, 0x0040, "UNK_6" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0040, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0080, 0x0080, "UNK_7" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0001, 0x0001, "UNK_0" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0001, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0002, 0x0002, "UNK_1" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0002, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0004, 0x0004, "UNK_2" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0004, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0008, 0x0008, "UNK_3" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0008, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0010, 0x0010, "UNK_4" ) // Gun + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0010, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0020, 0x0020, "UNK_5" ) // Missile + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0020, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0040, 0x0040, "UNK_6" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0040, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0080, 0x0080, "UNK_7" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) #endif PORT_MODIFY("SYSTEM") PORT_BIT( 0x0003, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START("DSW") - PORT_DIPNAME( 0x0001, 0x0001, "Analog controls?" ) // ? - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0001, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0002, 0x0002, "L/R control related (keep off)" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0002, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0004, 0x0004, "DSUNK_2" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0004, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0008, 0x0000, "Road select (debug)" ) // Debug mode - PORT_DIPSETTING( 0x0008, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Flip_Screen ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0010, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0020, 0x0020, "DSUNK_5" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0020, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0040, 0x0040, "DSUNK_6" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0040, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0080, 0x0000, "Enable enemies" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) - - PORT_DIPNAME( 0x0100, 0x0100, "DSUNK_8" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0100, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0200, 0x0200, "DSUNK_9" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0200, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0400, 0x0400, "DSUNK_A" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0400, DEF_STR( Off ) ) - PORT_DIPNAME( 0x0800, 0x0800, "DSUNK_B" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x0800, DEF_STR( Off ) ) - PORT_DIPNAME( 0x1000, 0x1000, "DSUNK_C" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x1000, DEF_STR( Off ) ) - PORT_DIPNAME( 0x2000, 0x2000, "DSUNK_D" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x2000, DEF_STR( Off ) ) - PORT_DIPNAME( 0x4000, 0x4000, "DSUNK_E" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x4000, DEF_STR( Off ) ) - PORT_DIPNAME( 0x8000, 0x8000, "DSUNK_F" ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPSETTING( 0x8000, DEF_STR( Off ) ) - - PORT_INCLUDE( rotary_null ) + PORT_DIPNAME( 0x0001, 0x0001, "Analog controls?" ) // ? + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0001, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0002, 0x0002, "L/R control related (keep off)" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0002, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0004, 0x0004, "DSUNK_2" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0004, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0008, 0x0000, "Road select (debug)" ) // Debug mode + PORT_DIPSETTING( 0x0008, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Flip_Screen ) ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0010, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0020, 0x0020, "DSUNK_5" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0020, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0040, 0x0040, "DSUNK_6" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0040, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0080, 0x0000, "Enable enemies" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) + + PORT_DIPNAME( 0x0100, 0x0100, "DSUNK_8" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0100, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0200, 0x0200, "DSUNK_9" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0200, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0400, 0x0400, "DSUNK_A" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0400, DEF_STR( Off ) ) + PORT_DIPNAME( 0x0800, 0x0800, "DSUNK_B" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x0800, DEF_STR( Off ) ) + PORT_DIPNAME( 0x1000, 0x1000, "DSUNK_C" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x1000, DEF_STR( Off ) ) + PORT_DIPNAME( 0x2000, 0x2000, "DSUNK_D" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x2000, DEF_STR( Off ) ) + PORT_DIPNAME( 0x4000, 0x4000, "DSUNK_E" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x4000, DEF_STR( Off ) ) + PORT_DIPNAME( 0x8000, 0x8000, "DSUNK_F" ) + PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + PORT_DIPSETTING( 0x8000, DEF_STR( Off ) ) + + PORT_INCLUDE( rotary_null ) PORT_INCLUDE( trackball_ports ) INPUT_PORTS_END diff --git a/src/mame/drivers/fastfred.cpp b/src/mame/drivers/fastfred.cpp index 9121d83d32f..025d9027b1a 100644 --- a/src/mame/drivers/fastfred.cpp +++ b/src/mame/drivers/fastfred.cpp @@ -918,7 +918,7 @@ ROM_END // main PCB is marked: "MC9003" and "MADE IN ITALY" on component side // main PCB is marked: "MADE IN ITALY" on solder side -// ROMs PCB is marked: "MG25157" on component side +// ROMs PCB is marked: "MG25157" on component side ROM_START( boggy84b2 ) ROM_REGION( 0x10000, "maincpu", 0 ) ROM_LOAD( "boggy84-1.bin", 0x0000, 0x1000, CRC(97235e3a) SHA1(f493efd03331416a392cab7d73e39029d7e8098c) ) diff --git a/src/mame/drivers/gaelco2.cpp b/src/mame/drivers/gaelco2.cpp index 92edc4b4387..66dd20ad350 100644 --- a/src/mame/drivers/gaelco2.cpp +++ b/src/mame/drivers/gaelco2.cpp @@ -560,7 +560,7 @@ void gaelco2_state::play2000_map(address_map &map) { map(0x000000, 0x03ffff).rom(); /* ROM */ map(0x100000, 0x100001).portr("IN0"); /* Coins + other buttons? */ - map(0x110000, 0x110001).portr("IN1"); + map(0x110000, 0x110001).portr("IN1"); map(0x200000, 0x20ffff).ram().w(FUNC(gaelco2_state::gaelco2_vram_w)).share("spriteram"); /* Video RAM */ map(0x202890, 0x2028ff).rw("gaelco", FUNC(gaelco_gae1_device::gaelcosnd_r), FUNC(gaelco_gae1_device::gaelcosnd_w)); /* Sound Registers */ map(0x214000, 0x214fff).ram().w(FUNC(gaelco2_state::gaelco2_palette_w)).share("paletteram"); /* Palette */ diff --git a/src/mame/drivers/leapfrog_leappad.cpp b/src/mame/drivers/leapfrog_leappad.cpp index 6e7e4e1399d..d01fb8bbc68 100644 --- a/src/mame/drivers/leapfrog_leappad.cpp +++ b/src/mame/drivers/leapfrog_leappad.cpp @@ -2,24 +2,24 @@ // copyright-holders:David Haywood /****************************************************************************** - LEAPPAD: - Example-Video: https://www.youtube.com/watch?v=LtUhENu5TKc - The LEAPPAD is basically compareable to the SEGA PICO, but without - Screen-Output! Each "Game" consists of two parts (Book + Cartridge). - Insert the cartridge into the system and add the Book on the Top of the - "console" and you can click on each pages and hear sounds or - learning-stuff on each page... - - MY FIRST LEAPPAD: - Basically the same as the LEAPPAD, but for even younger kids! (Cartridge - internal PCB's are identical to LEAPPAD) - Example Video: https://www.youtube.com/watch?v=gsf8XYV1Tpg - - Don't get confused by the name "LEAPPAD", as it looks like Leapfrog - also released some kind of Tablet with this name, and they even released - a new "LEAPPAD" in around 2016: - https://www.youtube.com/watch?v=MXFSgj6xLTU , which nearly looks like the - same, but is most likely techically completely different.. + LEAPPAD: + Example-Video: https://www.youtube.com/watch?v=LtUhENu5TKc + The LEAPPAD is basically compareable to the SEGA PICO, but without + Screen-Output! Each "Game" consists of two parts (Book + Cartridge). + Insert the cartridge into the system and add the Book on the Top of the + "console" and you can click on each pages and hear sounds or + learning-stuff on each page... + + MY FIRST LEAPPAD: + Basically the same as the LEAPPAD, but for even younger kids! (Cartridge + internal PCB's are identical to LEAPPAD) + Example Video: https://www.youtube.com/watch?v=gsf8XYV1Tpg + + Don't get confused by the name "LEAPPAD", as it looks like Leapfrog + also released some kind of Tablet with this name, and they even released + a new "LEAPPAD" in around 2016: + https://www.youtube.com/watch?v=MXFSgj6xLTU , which nearly looks like the + same, but is most likely techically completely different.. *******************************************************************************/ diff --git a/src/mame/drivers/naomi.cpp b/src/mame/drivers/naomi.cpp index 1458aa9ca1b..efb064516c3 100644 --- a/src/mame/drivers/naomi.cpp +++ b/src/mame/drivers/naomi.cpp @@ -329,7 +329,7 @@ Ferrari F355 Challenge (twin/deluxe, preview) no cart 22848P* 21 (64Mb) pre \Course Edition (twin/deluxe, prototype) no cart 23399 21 (64Mb) present 315-6206 317-0287-COM content is the same as regular 171-7919A cart Inu No Osanpo / Dog Walking (Rev A) 840-0073C 22294A 16 (64Mb) present 315-6206 317-0316-JPN requires 837-13844 JVS IO with DIPSW 1 ON /Mushiking The King Of Beetle -\(MUSHIUSA '04 1ST, Prototype) not present none 11*(64Mb) present 315-6206 not present * only first 7 flash roms contain game data, PCB have label 840-0150B-FLS. +\(MUSHIUSA '04 1ST, Prototype) not present none 11*(64Mb) present 315-6206 not present * only first 7 flash roms contain game data, PCB have label 840-0150B-FLS. Samba de Amigo (prototype) no cart ** 21*(64Mb) present 315-6206 317-0270-COM * only first 14 flash roms contain game data, ** instead of EPROM have tiny PCB with 2 flashroms on it /Shootout Pool Prize (Export) / Shootout \Pool The Medal (Japan) Version B (prototype) 840-0136C ** 21*(64Mb) present 317-6206 not present * only first 4 flash roms contain game data, ** instead of EPROM have tiny PCB with 2 flashroms on it @@ -563,9 +563,9 @@ Marvel Vs. Capcom 2 New Age of Heroes (Korea, Rev A) 841-0007C-03 23085A 14 MushiKing The King of Beetles 2K3 2ND 840-0150C 24217 6 (64Mb) present 317-0394-COM requires 610-0669 barcode reader, 838-14245-92 "MAPLE/232C CONVERT BD" (MIE-based), 838-14243 "RFID CHIP R/W BD" and RFID chip Quiz Ah Megamisama 840-0030C 23227 16 (64Mb) present 317-0280-JPN Shootout Pool 840-0098C 23844 4 (64Mb) present 317-0336-COM requires regular 837-13551 and 837-13938 rotary JVS boards -/Shootout Pool Prize (Export) / +/Shootout Pool Prize (Export) / \Shootout Pool The Medal (Japan, Rev A) 840-0128C 24065A 4 (64Mb) present 317-0367-COM requires Naomi-based hopper controller -/Shootout Pool Prize (Export) / +/Shootout Pool Prize (Export) / \Shootout Pool The Medal (Japan) Version B 840-0136C 24148 4 (64Mb) present 317-0367-COM requires Naomi-based or 837-14438 hopper controller (selected by P1 BUTTON1 bit) SWP Hopper Board 840-0130C 24083 20 (64Mb) present 317-0339-COM reused VF4 Evo ROM board with all maskROMs still in place; there is an additional 837-14381 IO board Touch de Uno! 2 840-0022C 23071 6 (64Mb) present 317-0276-JPN requires 837-13844 JVS IO with DIPSW 5 On, ELO AccuTouch-compatible touch screen controller and special printer. @@ -9827,7 +9827,7 @@ ROM_START( clubk2k3 ) ROM_COPY( "rom_board", 0x1000000, 0x400000, 0xc00000 ) /* ROM_REGION(0x200, "some_eeprom", 0) - ROM_LOAD( "25lc040.ic13s", 0x000, 0x200, NO_DUMP ) */ + ROM_LOAD( "25lc040.ic13s", 0x000, 0x200, NO_DUMP ) */ // 840-0139 2003 317-0382-COM Naomi 2 ROM_PARAMETER( ":rom_board:key", "d8b0fa4c" ) diff --git a/src/mame/drivers/sega_beena.cpp b/src/mame/drivers/sega_beena.cpp index 21df51c0e72..10ceb7c14c0 100644 --- a/src/mame/drivers/sega_beena.cpp +++ b/src/mame/drivers/sega_beena.cpp @@ -4,15 +4,15 @@ Sega Beena - non-video 'book' based learning system, like LeapPad etc. + non-video 'book' based learning system, like LeapPad etc. - unknown CPU type (inside Sega custom?) + unknown CPU type (inside Sega custom?) - cartridge ROM has 'edinburgh' in the header, maybe a system codename? - ROM is also full of OGG files containing the string 'Encoded with Speex speex-1.0.4' - as well as .mid files for music + cartridge ROM has 'edinburgh' in the header, maybe a system codename? + ROM is also full of OGG files containing the string 'Encoded with Speex speex-1.0.4' + as well as .mid files for music - TODO: component list! + TODO: component list! *******************************************************************************/ diff --git a/src/mame/drivers/segasp.cpp b/src/mame/drivers/segasp.cpp index f9a01bf8177..aaa13c3f198 100644 --- a/src/mame/drivers/segasp.cpp +++ b/src/mame/drivers/segasp.cpp @@ -628,7 +628,7 @@ ROM_START( tetgiano ) ROM_REGION( 0x08000000, "rom_board", ROMREGION_ERASEFF) // TETRIS - DEKARIS (romaji) - // / TETRIS® - GIANT + // / TETRIS® - GIANT // MDA-C0076 DISK_REGION( "cflash" ) DISK_IMAGE( "mda-c0076", 0, SHA1(6987c888d2a3ada2d07f6396d47fdba507ca859d) ) diff --git a/src/mame/drivers/vii.cpp b/src/mame/drivers/vii.cpp index fa8140eaa7d..aaa044edb35 100644 --- a/src/mame/drivers/vii.cpp +++ b/src/mame/drivers/vii.cpp @@ -13,27 +13,27 @@ Justice League Dora the Explorer Mattel Classic Sports - Disney Princess (GKR) - Wheel of Fortune (GKR) - (all GameKeyReady units?) + Disney Princess (GKR) + Wheel of Fortune (GKR) + (all GameKeyReady units?) "SunPlus QL8041C" ( known as Sunplus SPG2?? ) - Clickstart ( see clickstart.cpp instead) - Wheel of Fortune 2nd Edition + Clickstart ( see clickstart.cpp instead) + Wheel of Fortune 2nd Edition "SunPlus PA7801" ( known as Sunplus SPG110? ) see spg110.cpp instead - Classic Arcade Pinball - EA Sports (NHL95 + Madden 95) - - It is unknown if the following are close to this architecture or not (no dumps yet) + Classic Arcade Pinball + EA Sports (NHL95 + Madden 95) - "SunPlus QU7073-P69A" - Mortal Kombat + It is unknown if the following are close to this architecture or not (no dumps yet) - "Sunplus QL8167" - Disney Princess (older) - Go Diego Go + "SunPlus QU7073-P69A" + Mortal Kombat + + "Sunplus QL8167" + Disney Princess (older) + Go Diego Go Disney Princess non-GKR is Sunplus QL8167. @@ -53,11 +53,11 @@ Disney Princess non-GKR is Sunplus QL8167. walle: Game seems unhappy with NVRAM, clears contents on each boot. - jak_pooh: - In the 'Light Tag' minigame (select the rock) you can't move left with the DRC (ok with -nodrc) - and the game usually softlocks when you find a friend (with or without DRC) - - vii: + jak_pooh: + In the 'Light Tag' minigame (select the rock) you can't move left with the DRC (ok with -nodrc) + and the game usually softlocks when you find a friend (with or without DRC) + + vii: When loading a cart from file manager, sometimes MAME will crash. The "MOTOR" option in the diagnostic menu does nothing when selected. The "SPEECH IC" option in the diagnostic menu does nothing when selected. @@ -71,9 +71,9 @@ Disney Princess non-GKR is Sunplus QL8167. Test Modes: Justice League : press UP, DOWN, LEFT, BT3 on the JAKKS logo in that order, quickly, to get test menu WWE : press UP, BT1, BT2 together during startup logos - - Disney Friends, MS Pacman, WallE, Batman (and some other HotGen GameKKeys) for test mode, hold UP, - press A, press DOWN during startup + + Disney Friends, MS Pacman, WallE, Batman (and some other HotGen GameKKeys) for test mode, hold UP, + press A, press DOWN during startup TODO: Work out how to access the hidden TEST menus for all games (most JAKKS games should have one at least) @@ -1979,7 +1979,7 @@ void spg2xx_game_state::init_crc() logerror("Calculated Byte Sum of bytes from 0x10 to 0x%08x is %08x)\n", length - 1, checksum); } - + void spg2xx_game_state::init_zeus() { uint16_t *ROM = (uint16_t*)memregion("maincpu")->base(); @@ -2052,11 +2052,11 @@ CONS( 2005, jak_wof, 0, 0, jakks_gkr_wf_i2c, jak_wf_i2c, jakks_gkr_state, emp CONS( 2004, jak_spdm, 0, 0, jakks_gkr_mv_i2c, jak_gkr_i2c, jakks_gkr_state, empty_init, "JAKKS Pacific Inc / Digital Eclipse", "Spider-Man (JAKKS Pacific TV Game, Game-Key Ready)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS ) // MV (1 key available) CONS( 2005, jak_pooh, 0, 0, jakks_gkr_wp, jak_pooh, jakks_gkr_state, empty_init, "JAKKS Pacific Inc / Backbone Entertainment", "Winnie the Pooh - Piglet's Special Day (JAKKS Pacific TV Game, Game-Key Ready)", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS ) // WP (no game-keys released) -// SpongeBob SquarePants: The Fry Cook Games NK (3 keys available) ^^ +// SpongeBob SquarePants: The Fry Cook Games NK (3 keys available) ^^ // no keys released for the following, some were in development but cancelled // Capcom 3-in-1 CC (no game-keys released) -// Care Bears CB (no game-keys released) +// Care Bears CB (no game-keys released) // Radica TV games CONS( 2006, rad_skat, 0, 0, rad_skat, rad_skat, spg2xx_game_state, init_crc, "Radica", "Play TV Skateboarder (NTSC)", MACHINE_IMPERFECT_SOUND | MACHINE_IMPERFECT_GRAPHICS ) diff --git a/src/mame/drivers/wrlshunt.cpp b/src/mame/drivers/wrlshunt.cpp index c8ecef959ec..e2c129169c6 100644 --- a/src/mame/drivers/wrlshunt.cpp +++ b/src/mame/drivers/wrlshunt.cpp @@ -2,74 +2,74 @@ // copyright-holders:Ryan Holtz /****************************************************************************** - Wireless Hunting Video Game System skeleton driver - - System: Wireless Hunting Video Game System - Publisher: Hamy / Kids Station Toys Inc - Year: 2011 - ROM: FDI MSP55LV100G - RAM: Micron Technology 48LC8M16A2 - - Games: - Secret Mission - Predator - Delta Force - Toy Land - Dream Forest - Trophy Season - Freedom Force - Be Careful - Net Power - Open Training - Super Archer - Ultimate Frisbee - UFO Shooting - Happy Darts - Balloon Shoot - Avatair - Angry Pirate - Penguin War - Ghost Shooter - Duck Hunt - - - ROM Board: - Package: SO44 - Spacing: 1.27 mm - Width: 16.14 mm - Length: 27.78 mm - Voltage: 3V - Pinout: - - A25 A24 - | | - +--------------------------+ - A21 --|== # # `.__.' ==|-- A20 - A18 --|== ==|-- A19 - A17 --|== ==|-- A8 - A7 --|== ==|-- A9 - A6 --|== o ==|-- A10 - A5 --|== +----------------+ ==|-- A11 - A4 --|== | | ==|-- A12 - A3 --|== | MSP55LV100G | ==|-- A13 - A2 --|== | 0834 M02H | ==|-- A14 - A1 --|== | JAPAN | ==|-- A15 - A0 --|== | | ==|-- A16 - #CE --|== | | ==|-- A23 - GND --|== | | ==|-- A22 - #OE --|== | | ==|-- Q15 - Q0 --|== | | ==|-- Q7 - Q8 --|== | | ==|-- Q14 - Q1 --|== +----------------+ ==|-- Q6 - Q9 --|== ==|-- Q13 - Q2 --|== M55L100G ==|-- Q5 - Q10 --|== ==|-- Q12 - Q3 --|== ==|-- Q4 - Q11 --|== ==|-- VCC - +--------------------------+ - - The only interesting string in this ROM is SPF2ALP, - which is also found in the Wireless Air 60 ROM. + Wireless Hunting Video Game System skeleton driver + + System: Wireless Hunting Video Game System + Publisher: Hamy / Kids Station Toys Inc + Year: 2011 + ROM: FDI MSP55LV100G + RAM: Micron Technology 48LC8M16A2 + + Games: + Secret Mission + Predator + Delta Force + Toy Land + Dream Forest + Trophy Season + Freedom Force + Be Careful + Net Power + Open Training + Super Archer + Ultimate Frisbee + UFO Shooting + Happy Darts + Balloon Shoot + Avatair + Angry Pirate + Penguin War + Ghost Shooter + Duck Hunt + + + ROM Board: + Package: SO44 + Spacing: 1.27 mm + Width: 16.14 mm + Length: 27.78 mm + Voltage: 3V + Pinout: + + A25 A24 + | | + +--------------------------+ + A21 --|== # # `.__.' ==|-- A20 + A18 --|== ==|-- A19 + A17 --|== ==|-- A8 + A7 --|== ==|-- A9 + A6 --|== o ==|-- A10 + A5 --|== +----------------+ ==|-- A11 + A4 --|== | | ==|-- A12 + A3 --|== | MSP55LV100G | ==|-- A13 + A2 --|== | 0834 M02H | ==|-- A14 + A1 --|== | JAPAN | ==|-- A15 + A0 --|== | | ==|-- A16 + #CE --|== | | ==|-- A23 + GND --|== | | ==|-- A22 + #OE --|== | | ==|-- Q15 + Q0 --|== | | ==|-- Q7 + Q8 --|== | | ==|-- Q14 + Q1 --|== +----------------+ ==|-- Q6 + Q9 --|== ==|-- Q13 + Q2 --|== M55L100G ==|-- Q5 + Q10 --|== ==|-- Q12 + Q3 --|== ==|-- Q4 + Q11 --|== ==|-- VCC + +--------------------------+ + + The only interesting string in this ROM is SPF2ALP, + which is also found in the Wireless Air 60 ROM. *******************************************************************************/ diff --git a/src/mame/drivers/xavix.cpp b/src/mame/drivers/xavix.cpp index 27ba1996c21..a40f0bf3fcb 100644 --- a/src/mame/drivers/xavix.cpp +++ b/src/mame/drivers/xavix.cpp @@ -186,7 +186,7 @@ 7 PLAY TV OPUS /RADICA/USA,EU - - - - - - dumped (US version, PAL version appears to use different ROM) 8 PLAY TV Baseball 2 /EPOCH/Japan, HK - - - - - - - 9 Let's hit a homerun! Exciting baseball /EPOCH/Japan - - - - - - - Play TV Baseball /RADICA/USA,EU 8017 x8 none none SSD 98 PA7351-107 dumped + Play TV Baseball /RADICA/USA,EU 8017 x8 none none SSD 98 PA7351-107 dumped 1999 1 ABC Jungle Fun Hippo /Vteck/HK, USA, France - - - - - - - Unknown 1 PLAY TV Football /RADICA/USA 74021 x8 48 4M none SSD 98 PL7351-181 dumped XaviXTennis SGM6446 x16 48 8M 24C08 SSD 2002 NEC 85054-611 dumped @@ -891,7 +891,7 @@ static INPUT_PORTS_START( popira2 ) // player 2 buttons have heavy latency, prob PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Pad 1") PORT_PLAYER(2) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Pad 2") PORT_PLAYER(2) - + PORT_MODIFY("AN1") // 01 PORT_DIPNAME( 0x0001, 0x0001, "AN1" ) PORT_DIPSETTING( 0x0001, DEF_STR( Off ) ) @@ -2073,7 +2073,7 @@ ROM_END // [:] (possible DMA op SRC 00ebe2d3 DST 358a LEN 0398) // needs to come from 006be2d3 (so still from lower 8MB, not upper 8MB) -ROM_START( xavmusic ) +ROM_START( xavmusic ) ROM_REGION( 0x1000000, "bios", ROMREGION_ERASE00 ) ROM_LOAD( "xpmusicandcircuit.bin", 0x000000, 0x1000000, CRC(e06129d2) SHA1(d074d0dd85ce870f435da3c066a7f52b50999665) ) ROM_END diff --git a/src/mame/drivers/xavix2.cpp b/src/mame/drivers/xavix2.cpp index a0e6327506e..635be1be875 100644 --- a/src/mame/drivers/xavix2.cpp +++ b/src/mame/drivers/xavix2.cpp @@ -2,11 +2,11 @@ // copyright-holders:David Haywood /****************************************************************************** - XaviX 2 + XaviX 2 - unknown architecture, does not appear to be 6502 derived like XaviX / SuperXaviX + unknown architecture, does not appear to be 6502 derived like XaviX / SuperXaviX - die is marked "SSD 2002-2004 NEC 800208-51" + die is marked "SSD 2002-2004 NEC 800208-51" *******************************************************************************/ diff --git a/src/mame/includes/xavix.h b/src/mame/includes/xavix.h index 4bb1084ec1a..bf2abb6ee77 100644 --- a/src/mame/includes/xavix.h +++ b/src/mame/includes/xavix.h @@ -106,10 +106,10 @@ public: void xavix(machine_config &config); void xavix_nv(machine_config &config); - + void xavixp(machine_config &config); void xavixp_nv(machine_config &config); - + void xavix2000(machine_config &config); void xavix2000_nv(machine_config &config); @@ -796,7 +796,7 @@ protected: m_cartslot->write_bus_control(space,offset,data,mem_mask); } }; - + virtual uint8_t extbus_r(offs_t offset) override { if (m_cartslot->has_cart() && m_cartslot->is_read_access_not_rom()) diff --git a/src/mame/layout/fidel_bv3.lay b/src/mame/layout/fidel_bv3.lay index 9ba7e8df705..78b9c8292f1 100644 --- a/src/mame/layout/fidel_bv3.lay +++ b/src/mame/layout/fidel_bv3.lay @@ -145,4 +145,4 @@ - \ No newline at end of file + diff --git a/src/mame/layout/fidel_vbrc.lay b/src/mame/layout/fidel_vbrc.lay index 98b43dd1ff4..5d5eba8b1b4 100644 --- a/src/mame/layout/fidel_vbrc.lay +++ b/src/mame/layout/fidel_vbrc.lay @@ -179,4 +179,4 @@ - \ No newline at end of file + diff --git a/src/mame/layout/md6802.lay b/src/mame/layout/md6802.lay old mode 100755 new mode 100644 index 2b0ccb27191..14d95bbfdf5 --- a/src/mame/layout/md6802.lay +++ b/src/mame/layout/md6802.lay @@ -5,16 +5,16 @@ copyright-holders:Joakim Larsson Edstrom Didact MD6802 layout --> - - - + + + - - + + - + @@ -53,328 +53,328 @@ Didact MD6802 layout - + - - + + - - - + + + - + - - - - - - + + + + + + - - + + - + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - - + + + + + + - + - + - + - - - + + + - + - - - - + + + + - + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + diff --git a/src/mame/layout/modulab.lay b/src/mame/layout/modulab.lay index 4dc578e65ea..b2bcac75167 100644 --- a/src/mame/layout/modulab.lay +++ b/src/mame/layout/modulab.lay @@ -52,378 +52,378 @@ Esselte Studium Modulab layout - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - + + + - - - + + + - + - - - - - - - - + + + + + + + + - - - + + + - - - + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - + + + + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - + - - - - - - + + + + + + - - - + + + - - - + + + - - - - - - - + + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mame/machine/sgi.cpp b/src/mame/machine/sgi.cpp index fd605fb03a5..629aa753a77 100644 --- a/src/mame/machine/sgi.cpp +++ b/src/mame/machine/sgi.cpp @@ -210,14 +210,14 @@ void sgi_mc_device::dma_tick() { uint32_t addr = m_dma_mem_addr; if (m_dma_control & (1 << 8)) - { // Enable virtual address translation + { // Enable virtual address translation addr = dma_translate(addr); } if (m_dma_mode & (1 << 1)) - { // Graphics to host + { // Graphics to host if (m_dma_mode & (1 << 3)) - { // Fill mode + { // Fill mode m_space->write_dword(addr, m_dma_gio64_addr); m_dma_count -= 4; } @@ -242,7 +242,7 @@ void sgi_mc_device::dma_tick() } } else - { // Host to graphics + { // Host to graphics const uint32_t remaining = m_dma_count & 0x0000ffff; uint32_t length = 8; uint64_t shift = 56; @@ -263,14 +263,14 @@ void sgi_mc_device::dma_tick() } if ((m_dma_count & 0x0000ffff) == 0) - { // If remaining byte count is 0, deduct zoom count + { // If remaining byte count is 0, deduct zoom count m_dma_count -= 0x00010000; if (m_dma_count == 0) - { // If remaining zoom count is also 0, move to next line + { // If remaining zoom count is also 0, move to next line m_dma_mem_addr += m_dma_stride & 0x0000ffff; m_dma_size -= 0x00010000; if ((m_dma_size & 0xffff0000) == 0) - { // If no remaining lines, DMA is done. + { // If no remaining lines, DMA is done. m_dma_timer->adjust(attotime::never); m_dma_run |= (1 << 3); m_dma_run &= ~(1 << 6); @@ -285,7 +285,7 @@ void sgi_mc_device::dma_tick() } } else - { // If remaining zoom count is non-zero, reload byte count and return source address to the beginning of the line. + { // If remaining zoom count is non-zero, reload byte count and return source address to the beginning of the line. m_dma_count |= m_dma_size & 0x0000ffff; m_dma_mem_addr -= m_dma_size & 0x0000ffff; } diff --git a/src/mame/machine/xavix.cpp b/src/mame/machine/xavix.cpp index ce8cac39de5..db535016a88 100644 --- a/src/mame/machine/xavix.cpp +++ b/src/mame/machine/xavix.cpp @@ -669,7 +669,7 @@ CUSTOM_INPUT_MEMBER(xavix_popira2_cart_state::i2c_r) { if (m_cartslot->has_cart()) return m_cartslot->read_sda(); - else + else return 0x0; } diff --git a/src/mame/video/dec0.cpp b/src/mame/video/dec0.cpp index baca9a473f6..6c94ca6d0ff 100644 --- a/src/mame/video/dec0.cpp +++ b/src/mame/video/dec0.cpp @@ -46,17 +46,17 @@ uint32_t dec0_state::screen_update_bandit(screen_device &screen, bitmap_ind16 &b if (m_pri==0) { - m_tilegen[2]->deco_bac06_pf_draw(bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00); - m_tilegen[1]->deco_bac06_pf_draw(bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x00, 0x00, 0x0f); - m_tilegen[0]->deco_bac06_pf_draw(bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); + m_tilegen[2]->deco_bac06_pf_draw(bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00); + m_tilegen[1]->deco_bac06_pf_draw(bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); + m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x00, 0x00, 0x0f); + m_tilegen[0]->deco_bac06_pf_draw(bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); } else { - m_tilegen[2]->deco_bac06_pf_draw(bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00); - m_tilegen[1]->deco_bac06_pf_draw(bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); - m_tilegen[0]->deco_bac06_pf_draw(bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); - m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x00, 0x00, 0x0f); + m_tilegen[2]->deco_bac06_pf_draw(bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0x00, 0x00, 0x00, 0x00); + m_tilegen[1]->deco_bac06_pf_draw(bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); + m_tilegen[0]->deco_bac06_pf_draw(bitmap,cliprect,0, 0x00, 0x00, 0x00, 0x00); + m_spritegen->draw_sprites(bitmap, cliprect, m_buffered_spriteram, 0x00, 0x00, 0x0f); } return 0; } diff --git a/src/mame/video/light.cpp b/src/mame/video/light.cpp index 719113a9447..ff47c95c7e3 100644 --- a/src/mame/video/light.cpp +++ b/src/mame/video/light.cpp @@ -1,16 +1,16 @@ // license:BSD-3-Clause // copyright-holders:Ryan Holtz, Tyson Smith /* - Silicon Graphics LG1 "Light" graphics board used as - entry level graphics in the Indigo and IRIS Crimson. + Silicon Graphics LG1 "Light" graphics board used as + entry level graphics in the Indigo and IRIS Crimson. */ #include "emu.h" #include "video/light.h" #include "screen.h" -#define LOG_REX (1 << 0) -#define LOG_ALL (LOG_REX) +#define LOG_REX (1 << 0) +#define LOG_ALL (LOG_REX) #define VERBOSE (0) #include "logmacro.h" diff --git a/src/mame/video/light.h b/src/mame/video/light.h index ffc9932d02e..82799fc906b 100644 --- a/src/mame/video/light.h +++ b/src/mame/video/light.h @@ -1,8 +1,8 @@ // license:BSD-3-Clause // copyright-holders:Ryan Holtz, Tyson Smith /* - Silicon Graphics LG1 "Light" graphics board used as - entry level graphics in the Indigo and IRIS Crimson. + Silicon Graphics LG1 "Light" graphics board used as + entry level graphics in the Indigo and IRIS Crimson. */ #ifndef MAME_VIDEO_LIGHT_H diff --git a/src/mame/video/newport.cpp b/src/mame/video/newport.cpp index 0b46c6a0314..f1dd9cb004b 100644 --- a/src/mame/video/newport.cpp +++ b/src/mame/video/newport.cpp @@ -37,7 +37,7 @@ #define LOG_XMAP1 (1 << 5) #define LOG_REX3 (1 << 6) #define LOG_COMMANDS (1 << 7) -#define LOG_REJECTS (1 << 8) +#define LOG_REJECTS (1 << 8) #define LOG_ALL (LOG_UNKNOWN | LOG_VC2 | LOG_CMAP0 | LOG_CMAP1 | LOG_XMAP0 | LOG_XMAP1 | LOG_REX3) #define VERBOSE (0)//(LOG_UNKNOWN | LOG_VC2 | LOG_XMAP0 | LOG_CMAP0 | LOG_REX3 | LOG_COMMANDS | LOG_REJECTS) @@ -360,9 +360,9 @@ uint32_t newport_video_device::screen_update(screen_device &device, bitmap_rgb32 case 3: { const uint8_t pix_in = *src_ci; - const uint8_t r = (0x92 * BIT(pix_in, 2)) | (0x49 * BIT(pix_in, 1)) | (0x24 * BIT(pix_in, 0)); - const uint8_t g = (0x92 * BIT(pix_in, 5)) | (0x49 * BIT(pix_in, 4)) | (0x24 * BIT(pix_in, 3)); - const uint8_t b = (0xaa * BIT(pix_in, 7)) | (0x55 * BIT(pix_in, 6)); + const uint8_t r = (0x92 * BIT(pix_in, 2)) | (0x49 * BIT(pix_in, 1)) | (0x24 * BIT(pix_in, 0)); + const uint8_t g = (0x92 * BIT(pix_in, 5)) | (0x49 * BIT(pix_in, 4)) | (0x24 * BIT(pix_in, 3)); + const uint8_t b = (0xaa * BIT(pix_in, 7)) | (0x55 * BIT(pix_in, 6)); *dest++ = (r << 16) | (g << 8) | b; break; } @@ -1392,22 +1392,22 @@ void newport_video_device::store_pixel(uint8_t *dest_buf, uint8_t src) switch ((m_rex3.m_draw_mode1 >> 28) & 15) { - case 0: break; - case 1: *dest_buf |= (src & dst) & m_rex3.m_write_mask; break; - case 2: *dest_buf |= (src & ~dst) & m_rex3.m_write_mask; break; - case 3: *dest_buf |= (src) & m_rex3.m_write_mask; break; - case 4: *dest_buf |= (~src & dst) & m_rex3.m_write_mask; break; - case 5: *dest_buf |= (dst) & m_rex3.m_write_mask; break; - case 6: *dest_buf |= (src ^ dst) & m_rex3.m_write_mask; break; - case 7: *dest_buf |= (src | dst) & m_rex3.m_write_mask; break; - case 8: *dest_buf |= ~(src | dst) & m_rex3.m_write_mask; break; - case 9: *dest_buf |= ~(src ^ dst) & m_rex3.m_write_mask; break; - case 10: *dest_buf |= ~(dst) & m_rex3.m_write_mask; break; - case 11: *dest_buf |= (src | ~dst) & m_rex3.m_write_mask; break; - case 12: *dest_buf |= ~(src) & m_rex3.m_write_mask; break; - case 13: *dest_buf |= (~src | dst) & m_rex3.m_write_mask; break; - case 14: *dest_buf |= ~(src & dst) & m_rex3.m_write_mask; break; - case 15: *dest_buf |= 0xff & m_rex3.m_write_mask; break; + case 0: break; + case 1: *dest_buf |= (src & dst) & m_rex3.m_write_mask; break; + case 2: *dest_buf |= (src & ~dst) & m_rex3.m_write_mask; break; + case 3: *dest_buf |= (src) & m_rex3.m_write_mask; break; + case 4: *dest_buf |= (~src & dst) & m_rex3.m_write_mask; break; + case 5: *dest_buf |= (dst) & m_rex3.m_write_mask; break; + case 6: *dest_buf |= (src ^ dst) & m_rex3.m_write_mask; break; + case 7: *dest_buf |= (src | dst) & m_rex3.m_write_mask; break; + case 8: *dest_buf |= ~(src | dst) & m_rex3.m_write_mask; break; + case 9: *dest_buf |= ~(src ^ dst) & m_rex3.m_write_mask; break; + case 10: *dest_buf |= ~(dst) & m_rex3.m_write_mask; break; + case 11: *dest_buf |= (src | ~dst) & m_rex3.m_write_mask; break; + case 12: *dest_buf |= ~(src) & m_rex3.m_write_mask; break; + case 13: *dest_buf |= (~src | dst) & m_rex3.m_write_mask; break; + case 14: *dest_buf |= ~(src & dst) & m_rex3.m_write_mask; break; + case 15: *dest_buf |= 0xff & m_rex3.m_write_mask; break; } } @@ -1452,26 +1452,26 @@ void newport_video_device::do_v_iline(uint8_t color, bool skip_last, bool shade) do { if (shade) - write_pixel(x1, y1, (uint8_t)(m_rex3.m_color_red >> 11)); - else - write_pixel(x1, y1, color); + write_pixel(x1, y1, (uint8_t)(m_rex3.m_color_red >> 11)); + else + write_pixel(x1, y1, color); - y1 += incy; + y1 += incy; if (shade) m_rex3.m_color_red += m_rex3.m_slope_red; } while (y1 != y2); - if (!skip_last) - { + if (!skip_last) + { if (shade) - write_pixel(x1, y1, (uint8_t)(m_rex3.m_color_red >> 11)); - else - write_pixel(x1, y1, color); - } + write_pixel(x1, y1, (uint8_t)(m_rex3.m_color_red >> 11)); + else + write_pixel(x1, y1, color); + } - write_x_start(x1 << 11); - write_y_start(y1 << 11); + write_x_start(x1 << 11); + write_y_start(y1 << 11); } void newport_video_device::do_h_iline(uint8_t color, bool skip_last, bool shade) @@ -1495,15 +1495,15 @@ void newport_video_device::do_h_iline(uint8_t color, bool skip_last, bool shade) m_rex3.m_color_red += m_rex3.m_slope_red; } while (x1 != x2); - if (!skip_last) { + if (!skip_last) { if (shade) - write_pixel(x1, y1, (uint8_t)(m_rex3.m_color_red >> 11)); - else - write_pixel(x1, y1, color); - } + write_pixel(x1, y1, (uint8_t)(m_rex3.m_color_red >> 11)); + else + write_pixel(x1, y1, color); + } - write_x_start(x1 << 11); - write_y_start(y1 << 11); + write_x_start(x1 << 11); + write_y_start(y1 << 11); } void newport_video_device::do_iline(uint8_t color, bool skip_last, bool shade) @@ -1621,8 +1621,8 @@ void newport_video_device::do_iline(uint8_t color, bool skip_last, bool shade) } } - write_x_start(x1 << 11); - write_y_start(y1 << 11); + write_x_start(x1 << 11); + write_y_start(y1 << 11); } uint8_t newport_video_device::do_pixel_read() @@ -1763,8 +1763,8 @@ void newport_video_device::do_rex3_command() { //if (shade) //{ - // write_pixel(start_x, start_y, (uint8_t)(m_rex3.m_color_red >> 11)); - // m_rex3.m_color_red += m_rex3.m_slope_red; + // write_pixel(start_x, start_y, (uint8_t)(m_rex3.m_color_red >> 11)); + // m_rex3.m_color_red += m_rex3.m_slope_red; //} //else //{ diff --git a/src/mame/video/newport.h b/src/mame/video/newport.h index 65ebbaa58a4..4d87237d0e2 100644 --- a/src/mame/video/newport.h +++ b/src/mame/video/newport.h @@ -11,7 +11,7 @@ #include "machine/hpc3.h" -#define ENABLE_NEWVIEW_LOG (0) +#define ENABLE_NEWVIEW_LOG (0) class newport_video_device : public device_t { diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp index 7c86b4bd837..40fe037f8c7 100644 --- a/src/osd/modules/input/input_sdl.cpp +++ b/src/osd/modules/input/input_sdl.cpp @@ -63,263 +63,263 @@ struct key_lookup_table static key_lookup_table sdl_lookup_table[] = { - KE(UNKNOWN) - - KE(A) - KE(B) - KE(C) - KE(D) - KE(E) - KE(F) - KE(G) - KE(H) - KE(I) - KE(J) - KE(K) - KE(L) - KE(M) - KE(N) - KE(O) - KE(P) - KE(Q) - KE(R) - KE(S) - KE(T) - KE(U) - KE(V) - KE(W) - KE(X) - KE(Y) - KE(Z) - - KE(1) - KE(2) - KE(3) - KE(4) - KE(5) - KE(6) - KE(7) - KE(8) - KE(9) - KE(0) - - KE(RETURN) - KE(ESCAPE) - KE(BACKSPACE) - KE(TAB) - KE(SPACE) - - KE(MINUS) - KE(EQUALS) - KE(LEFTBRACKET) - KE(RIGHTBRACKET) - KE(BACKSLASH) - KE(NONUSHASH) - KE(SEMICOLON) - KE(APOSTROPHE) - KE(GRAVE) - KE(COMMA) - KE(PERIOD) - KE(SLASH) - - KE(CAPSLOCK) - - KE(F1) - KE(F2) - KE(F3) - KE(F4) - KE(F5) - KE(F6) - KE(F7) - KE(F8) - KE(F9) - KE(F10) - KE(F11) - KE(F12) - - KE(PRINTSCREEN) - KE(SCROLLLOCK) - KE(PAUSE) - KE(INSERT) - KE(HOME) - KE(PAGEUP) - KE(DELETE) - KE(END) - KE(PAGEDOWN) - KE(RIGHT) - KE(LEFT) - KE(DOWN) - KE(UP) - - KE(NUMLOCKCLEAR) - KE(KP_DIVIDE) - KE(KP_MULTIPLY) - KE(KP_MINUS) - KE(KP_PLUS) - KE(KP_ENTER) - KE(KP_1) - KE(KP_2) - KE(KP_3) - KE(KP_4) - KE(KP_5) - KE(KP_6) - KE(KP_7) - KE(KP_8) - KE(KP_9) - KE(KP_0) - KE(KP_PERIOD) - - KE(NONUSBACKSLASH) - KE(APPLICATION) - KE(POWER) - KE(KP_EQUALS) - KE(F13) - KE(F14) - KE(F15) - KE(F16) - KE(F17) - KE(F18) - KE(F19) - KE(F20) - KE(F21) - KE(F22) - KE(F23) - KE(F24) - KE(EXECUTE) - KE(HELP) - KE(MENU) - KE(SELECT) - KE(STOP) - KE(AGAIN) - KE(UNDO) - KE(CUT) - KE(COPY) - KE(PASTE) - KE(FIND) - KE(MUTE) - KE(VOLUMEUP) - KE(VOLUMEDOWN) - KE(KP_COMMA) - KE(KP_EQUALSAS400) - - KE(INTERNATIONAL1) - KE(INTERNATIONAL2) - KE(INTERNATIONAL3) - KE(INTERNATIONAL4) - KE(INTERNATIONAL5) - KE(INTERNATIONAL6) - KE(INTERNATIONAL7) - KE(INTERNATIONAL8) - KE(INTERNATIONAL9) - KE(LANG1) - KE(LANG2) - KE(LANG3) - KE(LANG4) - KE(LANG5) - KE(LANG6) - KE(LANG7) - KE(LANG8) - KE(LANG9) - - KE(ALTERASE) - KE(SYSREQ) - KE(CANCEL) - KE(CLEAR) - KE(PRIOR) - KE(RETURN2) - KE(SEPARATOR) - KE(OUT) - KE(OPER) - KE(CLEARAGAIN) - KE(CRSEL) - KE(EXSEL) - - KE(KP_00) - KE(KP_000) - KE(THOUSANDSSEPARATOR) - KE(DECIMALSEPARATOR) - KE(CURRENCYUNIT) - KE(CURRENCYSUBUNIT) - KE(KP_LEFTPAREN) - KE(KP_RIGHTPAREN) - KE(KP_LEFTBRACE) - KE(KP_RIGHTBRACE) - KE(KP_TAB) - KE(KP_BACKSPACE) - KE(KP_A) - KE(KP_B) - KE(KP_C) - KE(KP_D) - KE(KP_E) - KE(KP_F) - KE(KP_XOR) - KE(KP_POWER) - KE(KP_PERCENT) - KE(KP_LESS) - KE(KP_GREATER) - KE(KP_AMPERSAND) - KE(KP_DBLAMPERSAND) - KE(KP_VERTICALBAR) - KE(KP_DBLVERTICALBAR) - KE(KP_COLON) - KE(KP_HASH) - KE(KP_SPACE) - KE(KP_AT) - KE(KP_EXCLAM) - KE(KP_MEMSTORE) - KE(KP_MEMRECALL) - KE(KP_MEMCLEAR) - KE(KP_MEMADD) - KE(KP_MEMSUBTRACT) - KE(KP_MEMMULTIPLY) - KE(KP_MEMDIVIDE) - KE(KP_PLUSMINUS) - KE(KP_CLEAR) - KE(KP_CLEARENTRY) - KE(KP_BINARY) - KE(KP_OCTAL) - KE(KP_DECIMAL) - KE(KP_HEXADECIMAL) - - KE(LCTRL) - KE(LSHIFT) - KE(LALT) - KE(LGUI) - KE(RCTRL) - KE(RSHIFT) - KE(RALT) - KE(RGUI) - - KE(MODE) - KE(AUDIONEXT) - KE(AUDIOPREV) - KE(AUDIOSTOP) - KE(AUDIOPLAY) - KE(AUDIOMUTE) - KE(MEDIASELECT) - KE(WWW) - KE(MAIL) - KE(CALCULATOR) - KE(COMPUTER) - KE(AC_SEARCH) - KE(AC_HOME) - KE(AC_BACK) - KE(AC_FORWARD) - KE(AC_STOP) - KE(AC_REFRESH) - KE(AC_BOOKMARKS) - - KE(BRIGHTNESSDOWN) - KE(BRIGHTNESSUP) - KE(DISPLAYSWITCH) - KE(KBDILLUMTOGGLE) - KE(KBDILLUMDOWN) - KE(KBDILLUMUP) - KE(EJECT) - KE(SLEEP) - - KE(APP1) - KE(APP2) + KE(UNKNOWN) + + KE(A) + KE(B) + KE(C) + KE(D) + KE(E) + KE(F) + KE(G) + KE(H) + KE(I) + KE(J) + KE(K) + KE(L) + KE(M) + KE(N) + KE(O) + KE(P) + KE(Q) + KE(R) + KE(S) + KE(T) + KE(U) + KE(V) + KE(W) + KE(X) + KE(Y) + KE(Z) + + KE(1) + KE(2) + KE(3) + KE(4) + KE(5) + KE(6) + KE(7) + KE(8) + KE(9) + KE(0) + + KE(RETURN) + KE(ESCAPE) + KE(BACKSPACE) + KE(TAB) + KE(SPACE) + + KE(MINUS) + KE(EQUALS) + KE(LEFTBRACKET) + KE(RIGHTBRACKET) + KE(BACKSLASH) + KE(NONUSHASH) + KE(SEMICOLON) + KE(APOSTROPHE) + KE(GRAVE) + KE(COMMA) + KE(PERIOD) + KE(SLASH) + + KE(CAPSLOCK) + + KE(F1) + KE(F2) + KE(F3) + KE(F4) + KE(F5) + KE(F6) + KE(F7) + KE(F8) + KE(F9) + KE(F10) + KE(F11) + KE(F12) + + KE(PRINTSCREEN) + KE(SCROLLLOCK) + KE(PAUSE) + KE(INSERT) + KE(HOME) + KE(PAGEUP) + KE(DELETE) + KE(END) + KE(PAGEDOWN) + KE(RIGHT) + KE(LEFT) + KE(DOWN) + KE(UP) + + KE(NUMLOCKCLEAR) + KE(KP_DIVIDE) + KE(KP_MULTIPLY) + KE(KP_MINUS) + KE(KP_PLUS) + KE(KP_ENTER) + KE(KP_1) + KE(KP_2) + KE(KP_3) + KE(KP_4) + KE(KP_5) + KE(KP_6) + KE(KP_7) + KE(KP_8) + KE(KP_9) + KE(KP_0) + KE(KP_PERIOD) + + KE(NONUSBACKSLASH) + KE(APPLICATION) + KE(POWER) + KE(KP_EQUALS) + KE(F13) + KE(F14) + KE(F15) + KE(F16) + KE(F17) + KE(F18) + KE(F19) + KE(F20) + KE(F21) + KE(F22) + KE(F23) + KE(F24) + KE(EXECUTE) + KE(HELP) + KE(MENU) + KE(SELECT) + KE(STOP) + KE(AGAIN) + KE(UNDO) + KE(CUT) + KE(COPY) + KE(PASTE) + KE(FIND) + KE(MUTE) + KE(VOLUMEUP) + KE(VOLUMEDOWN) + KE(KP_COMMA) + KE(KP_EQUALSAS400) + + KE(INTERNATIONAL1) + KE(INTERNATIONAL2) + KE(INTERNATIONAL3) + KE(INTERNATIONAL4) + KE(INTERNATIONAL5) + KE(INTERNATIONAL6) + KE(INTERNATIONAL7) + KE(INTERNATIONAL8) + KE(INTERNATIONAL9) + KE(LANG1) + KE(LANG2) + KE(LANG3) + KE(LANG4) + KE(LANG5) + KE(LANG6) + KE(LANG7) + KE(LANG8) + KE(LANG9) + + KE(ALTERASE) + KE(SYSREQ) + KE(CANCEL) + KE(CLEAR) + KE(PRIOR) + KE(RETURN2) + KE(SEPARATOR) + KE(OUT) + KE(OPER) + KE(CLEARAGAIN) + KE(CRSEL) + KE(EXSEL) + + KE(KP_00) + KE(KP_000) + KE(THOUSANDSSEPARATOR) + KE(DECIMALSEPARATOR) + KE(CURRENCYUNIT) + KE(CURRENCYSUBUNIT) + KE(KP_LEFTPAREN) + KE(KP_RIGHTPAREN) + KE(KP_LEFTBRACE) + KE(KP_RIGHTBRACE) + KE(KP_TAB) + KE(KP_BACKSPACE) + KE(KP_A) + KE(KP_B) + KE(KP_C) + KE(KP_D) + KE(KP_E) + KE(KP_F) + KE(KP_XOR) + KE(KP_POWER) + KE(KP_PERCENT) + KE(KP_LESS) + KE(KP_GREATER) + KE(KP_AMPERSAND) + KE(KP_DBLAMPERSAND) + KE(KP_VERTICALBAR) + KE(KP_DBLVERTICALBAR) + KE(KP_COLON) + KE(KP_HASH) + KE(KP_SPACE) + KE(KP_AT) + KE(KP_EXCLAM) + KE(KP_MEMSTORE) + KE(KP_MEMRECALL) + KE(KP_MEMCLEAR) + KE(KP_MEMADD) + KE(KP_MEMSUBTRACT) + KE(KP_MEMMULTIPLY) + KE(KP_MEMDIVIDE) + KE(KP_PLUSMINUS) + KE(KP_CLEAR) + KE(KP_CLEARENTRY) + KE(KP_BINARY) + KE(KP_OCTAL) + KE(KP_DECIMAL) + KE(KP_HEXADECIMAL) + + KE(LCTRL) + KE(LSHIFT) + KE(LALT) + KE(LGUI) + KE(RCTRL) + KE(RSHIFT) + KE(RALT) + KE(RGUI) + + KE(MODE) + KE(AUDIONEXT) + KE(AUDIOPREV) + KE(AUDIOSTOP) + KE(AUDIOPLAY) + KE(AUDIOMUTE) + KE(MEDIASELECT) + KE(WWW) + KE(MAIL) + KE(CALCULATOR) + KE(COMPUTER) + KE(AC_SEARCH) + KE(AC_HOME) + KE(AC_BACK) + KE(AC_FORWARD) + KE(AC_STOP) + KE(AC_REFRESH) + KE(AC_BOOKMARKS) + + KE(BRIGHTNESSDOWN) + KE(BRIGHTNESSUP) + KE(DISPLAYSWITCH) + KE(KBDILLUMTOGGLE) + KE(KBDILLUMDOWN) + KE(KBDILLUMUP) + KE(EJECT) + KE(SLEEP) + + KE(APP1) + KE(APP2) { diff --git a/src/tools/imgtool/modules/rt11.cpp b/src/tools/imgtool/modules/rt11.cpp index 3cce60a050f..f7f5a515f2c 100644 --- a/src/tools/imgtool/modules/rt11.cpp +++ b/src/tools/imgtool/modules/rt11.cpp @@ -6,68 +6,68 @@ DEC RT-11 disk images - References: - - VaFFM -- bitsavers://pdf/dec/pdp11/rt11/v5.6_Aug91/AA-PD6PA-TC_RT-11_Volume_and_File_Formats_Manual_Aug91.pdf - DHM -- bitsavers://pdf/dec/pdp11/rt11/v5.6_Aug91/AA-PE7VA-TC_RT-11_Device_Handlers_Manual_Aug91.pdf - SSM -- bitsavers://pdf/dec/pdp11/rt11/v5.0_Mar83/AA-H379B-TC_5.0_SWsuppMar83.pdf - TSX+ -- bitsavers://pdf/dec/pdp11/tsxPlus/manuals_6.31/TSX-Plus_UsersRef_Jan88.pdf - PUTR -- http://www.dbit.com/pub/putr/putr.asm - - To do: - - filter for text files - - read-write support - - report empty 'last modified' time if date field is all zeros - - report free space - - arbitrary sized images - - don't crash when strings in home block have non-ascii chars (charconverter does not apply) - - do something about bootblock bug in imgtool (commit aca90520) - - LBN Contents - --- -------- - 0 Reserved (primary bootstrap) - 1 Reserved (home block) - 2-5 Reserved (secondary bootstrap) - 6-7 Directory segment 1 - ... Directory segment 2-n - ... Data - - Home block - ---------- - 000-201 Bad block replacement table - 202-203 ? - 204-251 INITIALIZE/RESTORE data area - 252-273 BUP information area - 274-677 ? - 700-701 (Reserved for Digital, must be zero) - 702-703 (Reserved for Digital, must be zero) - 704-721 ? - 722-723 Pack cluster size (= 1) - 724-725 Block number of first directory segment - 726-727 System version (RAD50) - 730-742 Volume Identification - 744-757 Owner name - 760-773 System Identification - 776-777 Checksum - - Directory segment header - ------------------------ - 0 The total number of segments in this directory. - 1 The segment number of the next logical directory segment. If this word is 0, there are no more segments in the list. - 2 The number of the highest segment currently in use. Valid only in the first directory segment. - 3 The number of extra bytes per directory entry, always an unsigned, even octal number. - 4 The block number on the volume where the actual stored data identified by this segment begins. - - Directory entry - --------------- - 0 Status word - 1 File name 1-3 (RAD50) - 2 File name 4-6 (RAD50) - 3 File type 1-3 (RAD50) - 4 Total file length (blocks) - 5 Job#, Channel# (RT-11 uses this information only for tentative files) - 6 Creation date - 7- Optional extra words + References: + + VaFFM -- bitsavers://pdf/dec/pdp11/rt11/v5.6_Aug91/AA-PD6PA-TC_RT-11_Volume_and_File_Formats_Manual_Aug91.pdf + DHM -- bitsavers://pdf/dec/pdp11/rt11/v5.6_Aug91/AA-PE7VA-TC_RT-11_Device_Handlers_Manual_Aug91.pdf + SSM -- bitsavers://pdf/dec/pdp11/rt11/v5.0_Mar83/AA-H379B-TC_5.0_SWsuppMar83.pdf + TSX+ -- bitsavers://pdf/dec/pdp11/tsxPlus/manuals_6.31/TSX-Plus_UsersRef_Jan88.pdf + PUTR -- http://www.dbit.com/pub/putr/putr.asm + + To do: + - filter for text files + - read-write support + - report empty 'last modified' time if date field is all zeros + - report free space + - arbitrary sized images + - don't crash when strings in home block have non-ascii chars (charconverter does not apply) + - do something about bootblock bug in imgtool (commit aca90520) + + LBN Contents + --- -------- + 0 Reserved (primary bootstrap) + 1 Reserved (home block) + 2-5 Reserved (secondary bootstrap) + 6-7 Directory segment 1 + ... Directory segment 2-n + ... Data + + Home block + ---------- + 000-201 Bad block replacement table + 202-203 ? + 204-251 INITIALIZE/RESTORE data area + 252-273 BUP information area + 274-677 ? + 700-701 (Reserved for Digital, must be zero) + 702-703 (Reserved for Digital, must be zero) + 704-721 ? + 722-723 Pack cluster size (= 1) + 724-725 Block number of first directory segment + 726-727 System version (RAD50) + 730-742 Volume Identification + 744-757 Owner name + 760-773 System Identification + 776-777 Checksum + + Directory segment header + ------------------------ + 0 The total number of segments in this directory. + 1 The segment number of the next logical directory segment. If this word is 0, there are no more segments in the list. + 2 The number of the highest segment currently in use. Valid only in the first directory segment. + 3 The number of extra bytes per directory entry, always an unsigned, even octal number. + 4 The block number on the volume where the actual stored data identified by this segment begins. + + Directory entry + --------------- + 0 Status word + 1 File name 1-3 (RAD50) + 2 File name 4-6 (RAD50) + 3 File type 1-3 (RAD50) + 4 Total file length (blocks) + 5 Job#, Channel# (RT-11 uses this information only for tentative files) + 6 Creation date + 7- Optional extra words ****************************************************************************/ diff --git a/src/tools/testkeys.cpp b/src/tools/testkeys.cpp index a536e4ac272..9ee08808c19 100644 --- a/src/tools/testkeys.cpp +++ b/src/tools/testkeys.cpp @@ -26,263 +26,263 @@ struct key_lookup_table { int code; const char *name; }; static constexpr key_lookup_table sdl_lookup[] = { - KE(UNKNOWN) + KE(UNKNOWN) - KE(A) - KE(B) - KE(C) - KE(D) - KE(E) - KE(F) - KE(G) - KE(H) - KE(I) - KE(J) - KE(K) - KE(L) - KE(M) - KE(N) - KE(O) - KE(P) - KE(Q) - KE(R) - KE(S) - KE(T) - KE(U) - KE(V) - KE(W) - KE(X) - KE(Y) - KE(Z) + KE(A) + KE(B) + KE(C) + KE(D) + KE(E) + KE(F) + KE(G) + KE(H) + KE(I) + KE(J) + KE(K) + KE(L) + KE(M) + KE(N) + KE(O) + KE(P) + KE(Q) + KE(R) + KE(S) + KE(T) + KE(U) + KE(V) + KE(W) + KE(X) + KE(Y) + KE(Z) - KE(1) - KE(2) - KE(3) - KE(4) - KE(5) - KE(6) - KE(7) - KE(8) - KE(9) - KE(0) + KE(1) + KE(2) + KE(3) + KE(4) + KE(5) + KE(6) + KE(7) + KE(8) + KE(9) + KE(0) - KE(RETURN) - KE(ESCAPE) - KE(BACKSPACE) - KE(TAB) - KE(SPACE) + KE(RETURN) + KE(ESCAPE) + KE(BACKSPACE) + KE(TAB) + KE(SPACE) - KE(MINUS) - KE(EQUALS) - KE(LEFTBRACKET) - KE(RIGHTBRACKET) - KE(BACKSLASH) - KE(NONUSHASH) - KE(SEMICOLON) - KE(APOSTROPHE) - KE(GRAVE) - KE(COMMA) - KE(PERIOD) - KE(SLASH) + KE(MINUS) + KE(EQUALS) + KE(LEFTBRACKET) + KE(RIGHTBRACKET) + KE(BACKSLASH) + KE(NONUSHASH) + KE(SEMICOLON) + KE(APOSTROPHE) + KE(GRAVE) + KE(COMMA) + KE(PERIOD) + KE(SLASH) - KE(CAPSLOCK) + KE(CAPSLOCK) - KE(F1) - KE(F2) - KE(F3) - KE(F4) - KE(F5) - KE(F6) - KE(F7) - KE(F8) - KE(F9) - KE(F10) - KE(F11) - KE(F12) + KE(F1) + KE(F2) + KE(F3) + KE(F4) + KE(F5) + KE(F6) + KE(F7) + KE(F8) + KE(F9) + KE(F10) + KE(F11) + KE(F12) - KE(PRINTSCREEN) - KE(SCROLLLOCK) - KE(PAUSE) - KE(INSERT) - KE(HOME) - KE(PAGEUP) - KE(DELETE) - KE(END) - KE(PAGEDOWN) - KE(RIGHT) - KE(LEFT) - KE(DOWN) - KE(UP) + KE(PRINTSCREEN) + KE(SCROLLLOCK) + KE(PAUSE) + KE(INSERT) + KE(HOME) + KE(PAGEUP) + KE(DELETE) + KE(END) + KE(PAGEDOWN) + KE(RIGHT) + KE(LEFT) + KE(DOWN) + KE(UP) - KE(NUMLOCKCLEAR) - KE(KP_DIVIDE) - KE(KP_MULTIPLY) - KE(KP_MINUS) - KE(KP_PLUS) - KE(KP_ENTER) - KE(KP_1) - KE(KP_2) - KE(KP_3) - KE(KP_4) - KE(KP_5) - KE(KP_6) - KE(KP_7) - KE(KP_8) - KE(KP_9) - KE(KP_0) - KE(KP_PERIOD) + KE(NUMLOCKCLEAR) + KE(KP_DIVIDE) + KE(KP_MULTIPLY) + KE(KP_MINUS) + KE(KP_PLUS) + KE(KP_ENTER) + KE(KP_1) + KE(KP_2) + KE(KP_3) + KE(KP_4) + KE(KP_5) + KE(KP_6) + KE(KP_7) + KE(KP_8) + KE(KP_9) + KE(KP_0) + KE(KP_PERIOD) - KE(NONUSBACKSLASH) - KE(APPLICATION) - KE(POWER) - KE(KP_EQUALS) - KE(F13) - KE(F14) - KE(F15) - KE(F16) - KE(F17) - KE(F18) - KE(F19) - KE(F20) - KE(F21) - KE(F22) - KE(F23) - KE(F24) - KE(EXECUTE) - KE(HELP) - KE(MENU) - KE(SELECT) - KE(STOP) - KE(AGAIN) - KE(UNDO) - KE(CUT) - KE(COPY) - KE(PASTE) - KE(FIND) - KE(MUTE) - KE(VOLUMEUP) - KE(VOLUMEDOWN) - KE(KP_COMMA) - KE(KP_EQUALSAS400) + KE(NONUSBACKSLASH) + KE(APPLICATION) + KE(POWER) + KE(KP_EQUALS) + KE(F13) + KE(F14) + KE(F15) + KE(F16) + KE(F17) + KE(F18) + KE(F19) + KE(F20) + KE(F21) + KE(F22) + KE(F23) + KE(F24) + KE(EXECUTE) + KE(HELP) + KE(MENU) + KE(SELECT) + KE(STOP) + KE(AGAIN) + KE(UNDO) + KE(CUT) + KE(COPY) + KE(PASTE) + KE(FIND) + KE(MUTE) + KE(VOLUMEUP) + KE(VOLUMEDOWN) + KE(KP_COMMA) + KE(KP_EQUALSAS400) - KE(INTERNATIONAL1) - KE(INTERNATIONAL2) - KE(INTERNATIONAL3) - KE(INTERNATIONAL4) - KE(INTERNATIONAL5) - KE(INTERNATIONAL6) - KE(INTERNATIONAL7) - KE(INTERNATIONAL8) - KE(INTERNATIONAL9) - KE(LANG1) - KE(LANG2) - KE(LANG3) - KE(LANG4) - KE(LANG5) - KE(LANG6) - KE(LANG7) - KE(LANG8) - KE(LANG9) + KE(INTERNATIONAL1) + KE(INTERNATIONAL2) + KE(INTERNATIONAL3) + KE(INTERNATIONAL4) + KE(INTERNATIONAL5) + KE(INTERNATIONAL6) + KE(INTERNATIONAL7) + KE(INTERNATIONAL8) + KE(INTERNATIONAL9) + KE(LANG1) + KE(LANG2) + KE(LANG3) + KE(LANG4) + KE(LANG5) + KE(LANG6) + KE(LANG7) + KE(LANG8) + KE(LANG9) - KE(ALTERASE) - KE(SYSREQ) - KE(CANCEL) - KE(CLEAR) - KE(PRIOR) - KE(RETURN2) - KE(SEPARATOR) - KE(OUT) - KE(OPER) - KE(CLEARAGAIN) - KE(CRSEL) - KE(EXSEL) + KE(ALTERASE) + KE(SYSREQ) + KE(CANCEL) + KE(CLEAR) + KE(PRIOR) + KE(RETURN2) + KE(SEPARATOR) + KE(OUT) + KE(OPER) + KE(CLEARAGAIN) + KE(CRSEL) + KE(EXSEL) - KE(KP_00) - KE(KP_000) - KE(THOUSANDSSEPARATOR) - KE(DECIMALSEPARATOR) - KE(CURRENCYUNIT) - KE(CURRENCYSUBUNIT) - KE(KP_LEFTPAREN) - KE(KP_RIGHTPAREN) - KE(KP_LEFTBRACE) - KE(KP_RIGHTBRACE) - KE(KP_TAB) - KE(KP_BACKSPACE) - KE(KP_A) - KE(KP_B) - KE(KP_C) - KE(KP_D) - KE(KP_E) - KE(KP_F) - KE(KP_XOR) - KE(KP_POWER) - KE(KP_PERCENT) - KE(KP_LESS) - KE(KP_GREATER) - KE(KP_AMPERSAND) - KE(KP_DBLAMPERSAND) - KE(KP_VERTICALBAR) - KE(KP_DBLVERTICALBAR) - KE(KP_COLON) - KE(KP_HASH) - KE(KP_SPACE) - KE(KP_AT) - KE(KP_EXCLAM) - KE(KP_MEMSTORE) - KE(KP_MEMRECALL) - KE(KP_MEMCLEAR) - KE(KP_MEMADD) - KE(KP_MEMSUBTRACT) - KE(KP_MEMMULTIPLY) - KE(KP_MEMDIVIDE) - KE(KP_PLUSMINUS) - KE(KP_CLEAR) - KE(KP_CLEARENTRY) - KE(KP_BINARY) - KE(KP_OCTAL) - KE(KP_DECIMAL) - KE(KP_HEXADECIMAL) + KE(KP_00) + KE(KP_000) + KE(THOUSANDSSEPARATOR) + KE(DECIMALSEPARATOR) + KE(CURRENCYUNIT) + KE(CURRENCYSUBUNIT) + KE(KP_LEFTPAREN) + KE(KP_RIGHTPAREN) + KE(KP_LEFTBRACE) + KE(KP_RIGHTBRACE) + KE(KP_TAB) + KE(KP_BACKSPACE) + KE(KP_A) + KE(KP_B) + KE(KP_C) + KE(KP_D) + KE(KP_E) + KE(KP_F) + KE(KP_XOR) + KE(KP_POWER) + KE(KP_PERCENT) + KE(KP_LESS) + KE(KP_GREATER) + KE(KP_AMPERSAND) + KE(KP_DBLAMPERSAND) + KE(KP_VERTICALBAR) + KE(KP_DBLVERTICALBAR) + KE(KP_COLON) + KE(KP_HASH) + KE(KP_SPACE) + KE(KP_AT) + KE(KP_EXCLAM) + KE(KP_MEMSTORE) + KE(KP_MEMRECALL) + KE(KP_MEMCLEAR) + KE(KP_MEMADD) + KE(KP_MEMSUBTRACT) + KE(KP_MEMMULTIPLY) + KE(KP_MEMDIVIDE) + KE(KP_PLUSMINUS) + KE(KP_CLEAR) + KE(KP_CLEARENTRY) + KE(KP_BINARY) + KE(KP_OCTAL) + KE(KP_DECIMAL) + KE(KP_HEXADECIMAL) - KE(LCTRL) - KE(LSHIFT) - KE(LALT) - KE(LGUI) - KE(RCTRL) - KE(RSHIFT) - KE(RALT) - KE(RGUI) + KE(LCTRL) + KE(LSHIFT) + KE(LALT) + KE(LGUI) + KE(RCTRL) + KE(RSHIFT) + KE(RALT) + KE(RGUI) - KE(MODE) - KE(AUDIONEXT) - KE(AUDIOPREV) - KE(AUDIOSTOP) - KE(AUDIOPLAY) - KE(AUDIOMUTE) - KE(MEDIASELECT) - KE(WWW) - KE(MAIL) - KE(CALCULATOR) - KE(COMPUTER) - KE(AC_SEARCH) - KE(AC_HOME) - KE(AC_BACK) - KE(AC_FORWARD) - KE(AC_STOP) - KE(AC_REFRESH) - KE(AC_BOOKMARKS) + KE(MODE) + KE(AUDIONEXT) + KE(AUDIOPREV) + KE(AUDIOSTOP) + KE(AUDIOPLAY) + KE(AUDIOMUTE) + KE(MEDIASELECT) + KE(WWW) + KE(MAIL) + KE(CALCULATOR) + KE(COMPUTER) + KE(AC_SEARCH) + KE(AC_HOME) + KE(AC_BACK) + KE(AC_FORWARD) + KE(AC_STOP) + KE(AC_REFRESH) + KE(AC_BOOKMARKS) - KE(BRIGHTNESSDOWN) - KE(BRIGHTNESSUP) - KE(DISPLAYSWITCH) - KE(KBDILLUMTOGGLE) - KE(KBDILLUMDOWN) - KE(KBDILLUMUP) - KE(EJECT) - KE(SLEEP) + KE(BRIGHTNESSDOWN) + KE(BRIGHTNESSUP) + KE(DISPLAYSWITCH) + KE(KBDILLUMTOGGLE) + KE(KBDILLUMDOWN) + KE(KBDILLUMUP) + KE(EJECT) + KE(SLEEP) - KE(APP1) - KE(APP2) + KE(APP1) + KE(APP2) }; static char const *lookup_key_name(int kc) -- cgit v1.2.3-70-g09d2 From 17fcc38a25415059e6b20d5d9b1f8c5e4ef81333 Mon Sep 17 00:00:00 2001 From: couriersud Date: Fri, 1 Mar 2019 07:47:51 +0100 Subject: netlist: memory code refactoring. (nw) --- src/devices/machine/netlist.cpp | 6 +- src/devices/machine/netlist.h | 2 +- src/lib/netlist/devices/nlid_system.h | 2 +- src/lib/netlist/devices/nlid_truthtable.cpp | 2 +- src/lib/netlist/nl_base.cpp | 22 +- src/lib/netlist/nl_base.h | 16 +- src/lib/netlist/nl_factory.cpp | 2 +- src/lib/netlist/nl_factory.h | 6 +- src/lib/netlist/nl_setup.cpp | 14 +- src/lib/netlist/nltypes.h | 6 +- src/lib/netlist/plib/palloc.h | 378 ++++++++++++++++------------ src/lib/netlist/plib/pconfig.h | 2 +- src/lib/netlist/plib/pdynlib.cpp | 8 +- src/lib/netlist/plib/pmatrix2d.h | 7 +- src/lib/netlist/plib/pmempool.h | 60 ++--- src/lib/netlist/plib/pstream.cpp | 44 +--- src/lib/netlist/plib/pstream.h | 22 +- src/lib/netlist/plib/ptypes.h | 4 +- src/lib/netlist/prg/nltool.cpp | 2 +- src/lib/netlist/solver/nld_matrix_solver.h | 2 +- src/lib/netlist/solver/nld_solver.cpp | 10 +- src/lib/netlist/solver/nld_solver.h | 6 +- 22 files changed, 308 insertions(+), 315 deletions(-) (limited to 'src/lib/netlist/plib/pmempool.h') diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp index 7beb745cbf2..280973440a9 100644 --- a/src/devices/machine/netlist.cpp +++ b/src/devices/machine/netlist.cpp @@ -422,11 +422,11 @@ public: struct channel { - netlist::poolptr m_param_name; + netlist::pool_owned_ptr m_param_name; netlist::param_double_t *m_param; stream_sample_t *m_buffer; - netlist::poolptr m_param_mult; - netlist::poolptr m_param_offset; + netlist::pool_owned_ptr m_param_mult; + netlist::pool_owned_ptr m_param_offset; }; channel m_channels[MAX_INPUT_CHANNELS]; netlist::netlist_time m_inc; diff --git a/src/devices/machine/netlist.h b/src/devices/machine/netlist.h index db27b2860df..9ec58f614bc 100644 --- a/src/devices/machine/netlist.h +++ b/src/devices/machine/netlist.h @@ -159,7 +159,7 @@ private: netlist::netlist_time m_rem; netlist::netlist_time m_old; - netlist::poolptr m_netlist; + netlist::pool_owned_ptr m_netlist; func_type m_setup_func; }; diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index 95712fc3416..324ceb93c38 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -335,7 +335,7 @@ namespace netlist param_int_t m_N; param_str_t m_func; analog_output_t m_Q; - std::vector> m_I; + std::vector> m_I; std::vector m_vals; plib::pfunction m_compiled; diff --git a/src/lib/netlist/devices/nlid_truthtable.cpp b/src/lib/netlist/devices/nlid_truthtable.cpp index 622aee0e0c7..2221d855880 100644 --- a/src/lib/netlist/devices/nlid_truthtable.cpp +++ b/src/lib/netlist/devices/nlid_truthtable.cpp @@ -224,7 +224,7 @@ namespace netlist : netlist_base_factory_truthtable_t(name, classname, def_param, sourcefile) { } - poolptr Create(netlist_state_t &anetlist, const pstring &name) override + pool_owned_ptr Create(netlist_state_t &anetlist, const pstring &name) override { using tt_type = nld_truthtable_t; truthtable_parser desc_s(m_NO, m_NI, &m_ttbl.m_initialized, diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index 55560151e21..55e952ad723 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -82,15 +82,15 @@ public: m_R_low = 1.0; m_R_high = 130.0; } - poolptr create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const override; - poolptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const override; + pool_owned_ptr create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const override; + pool_owned_ptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const override; }; -poolptr logic_family_ttl_t::create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const +pool_owned_ptr logic_family_ttl_t::create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const { return pool().make_poolptr(anetlist, name, proxied); } -poolptr logic_family_ttl_t::create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const +pool_owned_ptr logic_family_ttl_t::create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const { return pool().make_poolptr(anetlist, name, proxied); } @@ -109,16 +109,16 @@ public: m_R_low = 10.0; m_R_high = 10.0; } - poolptr create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const override; - poolptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const override; + pool_owned_ptr create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const override; + pool_owned_ptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const override; }; -poolptr logic_family_cd4xxx_t::create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const +pool_owned_ptr logic_family_cd4xxx_t::create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const { return pool().make_poolptr(anetlist, name, proxied); } -poolptr logic_family_cd4xxx_t::create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const +pool_owned_ptr logic_family_cd4xxx_t::create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const { return pool().make_poolptr(anetlist, name, proxied); } @@ -578,7 +578,7 @@ core_device_t::core_device_t(core_device_t &owner, const pstring &name) set_logic_family(owner.logic_family()); if (logic_family() == nullptr) set_logic_family(family_TTL()); - state().add_dev(this->name(), poolptr(this, false)); + state().add_dev(this->name(), pool_owned_ptr(this, false)); } void core_device_t::set_default_delegate(detail::core_terminal_t &term) @@ -894,7 +894,7 @@ logic_output_t::logic_output_t(core_device_t &dev, const pstring &aname) , m_my_net(dev.state(), name() + ".net", this) { this->set_net(&m_my_net); - state().register_net(poolptr(&m_my_net, false)); + state().register_net(pool_owned_ptr(&m_my_net, false)); set_logic_family(dev.logic_family()); state().setup().register_term(*this); } @@ -923,7 +923,7 @@ analog_output_t::analog_output_t(core_device_t &dev, const pstring &aname) : analog_t(dev, aname, STATE_OUT) , m_my_net(dev.state(), name() + ".net", this) { - state().register_net(poolptr(&m_my_net, false)); + state().register_net(pool_owned_ptr(&m_my_net, false)); this->set_net(&m_my_net); //net().m_cur_Analog = NL_FCONST(0.0); diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 66fc49d7e5e..4a48dc892b3 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -139,7 +139,7 @@ class NETLIB_NAME(name) : public device_t #define NETLIB_TIMESTEP(chip) void NETLIB_NAME(chip) :: timestep(const nl_double step) #define NETLIB_SUB(chip) nld_ ## chip -#define NETLIB_SUBXX(ns, chip) poolptr< ns :: nld_ ## chip > +#define NETLIB_SUBXX(ns, chip) pool_owned_ptr< ns :: nld_ ## chip > #define NETLIB_HANDLER(chip, name) void NETLIB_NAME(chip) :: name() NL_NOEXCEPT #define NETLIB_UPDATE(chip) NETLIB_HANDLER(chip, update) @@ -243,9 +243,9 @@ namespace netlist virtual ~logic_family_desc_t() noexcept = default; - virtual poolptr create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, + virtual pool_owned_ptr create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const = 0; - virtual poolptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, + virtual pool_owned_ptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const = 0; double fixed_V() const { return m_fixed_V; } @@ -1187,7 +1187,7 @@ namespace netlist const setup_t &setup() const; template - void register_sub(const pstring &name, poolptr &dev, const Args&... args) + void register_sub(const pstring &name, pool_owned_ptr &dev, const Args&... args) { //dev.reset(plib::palloc(*this, name, args...)); dev = pool().make_poolptr(*this, name, args...); @@ -1275,10 +1275,10 @@ namespace netlist { public: - using nets_collection_type = std::vector>; + using nets_collection_type = std::vector>; /* need to preserve order of device creation ... */ - using devices_collection_type = std::vector>>; + using devices_collection_type = std::vector>>; netlist_state_t(const pstring &aname, plib::unique_ptr &&callbacks, plib::unique_ptr &&setup); @@ -1330,7 +1330,7 @@ namespace netlist std::size_t find_net_id(const detail::net_t *net) const; template - void register_net(poolptr &&net) { m_nets.push_back(std::move(net)); } + void register_net(pool_owned_ptr &&net) { m_nets.push_back(std::move(net)); } template inline std::vector get_device_list() @@ -1346,7 +1346,7 @@ namespace netlist } template - void add_dev(const pstring &name, poolptr &&dev) + void add_dev(const pstring &name, pool_owned_ptr &&dev) { for (auto & d : m_devices) if (d.first == name) diff --git a/src/lib/netlist/nl_factory.cpp b/src/lib/netlist/nl_factory.cpp index c9d5ea7e29f..1f0ac35c6c4 100644 --- a/src/lib/netlist/nl_factory.cpp +++ b/src/lib/netlist/nl_factory.cpp @@ -76,7 +76,7 @@ namespace netlist { namespace factory // factory_lib_entry_t: factory class to wrap macro based chips/elements // ----------------------------------------------------------------------------- - poolptr library_element_t::Create(netlist_state_t &anetlist, const pstring &name) + pool_owned_ptr library_element_t::Create(netlist_state_t &anetlist, const pstring &name) { return pool().make_poolptr(anetlist, name); } diff --git a/src/lib/netlist/nl_factory.h b/src/lib/netlist/nl_factory.h index 23cfe522f8a..271bf72bf90 100644 --- a/src/lib/netlist/nl_factory.h +++ b/src/lib/netlist/nl_factory.h @@ -55,7 +55,7 @@ namespace factory { COPYASSIGNMOVE(element_t, default) - virtual poolptr Create(netlist_state_t &anetlist, const pstring &name) = 0; + virtual pool_owned_ptr Create(netlist_state_t &anetlist, const pstring &name) = 0; virtual void macro_actions(nlparse_t &nparser, const pstring &name) { plib::unused_var(nparser); @@ -85,7 +85,7 @@ namespace factory { const pstring &def_param, const pstring &sourcefile) : element_t(name, classname, def_param, sourcefile) { } - poolptr Create(netlist_state_t &anetlist, const pstring &name) override + pool_owned_ptr Create(netlist_state_t &anetlist, const pstring &name) override { return pool().make_poolptr(anetlist, name); } @@ -147,7 +147,7 @@ namespace factory { { } - poolptr Create(netlist_state_t &anetlist, const pstring &name) override; + pool_owned_ptr Create(netlist_state_t &anetlist, const pstring &name) override; void macro_actions(nlparse_t &nparser, const pstring &name) override; diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp index 3ac1b604bc4..5dc9a9d2516 100644 --- a/src/lib/netlist/nl_setup.cpp +++ b/src/lib/netlist/nl_setup.cpp @@ -935,17 +935,17 @@ class logic_family_std_proxy_t : public logic_family_desc_t { public: logic_family_std_proxy_t() = default; - poolptr create_d_a_proxy(netlist_state_t &anetlist, + pool_owned_ptr create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const override; - poolptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const override; + pool_owned_ptr create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const override; }; -poolptr logic_family_std_proxy_t::create_d_a_proxy(netlist_state_t &anetlist, +pool_owned_ptr logic_family_std_proxy_t::create_d_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *proxied) const { return pool().make_poolptr(anetlist, name, proxied); } -poolptr logic_family_std_proxy_t::create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const +pool_owned_ptr logic_family_std_proxy_t::create_a_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *proxied) const { return pool().make_poolptr(anetlist, name, proxied); } @@ -1010,7 +1010,7 @@ void setup_t::delete_empty_nets() { netlist().nets().erase( std::remove_if(netlist().nets().begin(), netlist().nets().end(), - [](poolptr &x) + [](pool_owned_ptr &x) { if (x->num_cons() == 0) { @@ -1038,7 +1038,7 @@ void setup_t::prepare_to_run() if ( factory().is_class(e.second) || factory().is_class(e.second)) { - m_netlist.nlstate().add_dev(e.first, poolptr(e.second->Create(netlist(), e.first))); + m_netlist.nlstate().add_dev(e.first, pool_owned_ptr(e.second->Create(netlist(), e.first))); } } @@ -1055,7 +1055,7 @@ void setup_t::prepare_to_run() if ( !factory().is_class(e.second) && !factory().is_class(e.second)) { - auto dev = poolptr(e.second->Create(netlist(), e.first)); + auto dev = pool_owned_ptr(e.second->Create(netlist(), e.first)); m_netlist.nlstate().add_dev(dev->name(), std::move(dev)); } } diff --git a/src/lib/netlist/nltypes.h b/src/lib/netlist/nltypes.h index 1ddc29adfae..9abe8beebef 100644 --- a/src/lib/netlist/nltypes.h +++ b/src/lib/netlist/nltypes.h @@ -84,18 +84,18 @@ namespace netlist #if (USE_MEMPOOL) using nlmempool = plib::mempool; #else - using nlmempool = plib::mempool_default; + using nlmempool = plib::aligned_arena; #endif /*! Owned pointer type for pooled allocations. * */ template - using poolptr = nlmempool::poolptr; + using pool_owned_ptr = nlmempool::owned_pool_ptr; inline nlmempool &pool() { - static nlmempool static_pool(655360, 16); + static nlmempool static_pool; return static_pool; } diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h index d7b00262f7f..f10fd548817 100644 --- a/src/lib/netlist/plib/palloc.h +++ b/src/lib/netlist/plib/palloc.h @@ -17,6 +17,7 @@ #include #include #include +#include #if defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER) #include @@ -25,127 +26,65 @@ namespace plib { //============================================================ - // Memory allocation + // Standard arena_deleter //============================================================ -#if (USE_ALIGNED_ALLOCATION) - static inline void *paligned_alloc( size_t alignment, size_t size ) + template + struct arena_deleter { -#if defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER) - return _aligned_malloc(size, alignment); -#elif defined(__APPLE__) - void* p; - if (::posix_memalign(&p, alignment, size) != 0) { - p = nullptr; + //using arena_storage_type = P *; + using arena_storage_type = typename std::conditional::type; + template + typename std::enable_if::type getref(X *x) { return *x;} + template + typename std::enable_if::type::is_stateless, X&>::type + getref(X &x, Y y = nullptr) + { + unused_var(y); + return x; } - return p; -#else - return aligned_alloc(alignment, size); -#endif - } - - static inline void pfree( void *ptr ) - { - // NOLINTNEXTLINE(cppcoreguidelines-no-malloc) - free(ptr); - } - -#else - static inline void *paligned_alloc( size_t alignment, size_t size ) - { - unused_var(alignment); - return ::operator new(size); - } - - static inline void pfree( void *ptr ) - { - ::operator delete(ptr); - } -#endif - - 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!"); -#if (USE_ALIGNED_HINTS) - return reinterpret_cast(__builtin_assume_aligned(p, ALIGN)); -#else - return p; -#endif - } - - template - constexpr const T *assume_aligned_ptr(const 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"); -#if (USE_ALIGNED_HINTS) - return reinterpret_cast(__builtin_assume_aligned(p, ALIGN)); -#else - return p; -#endif - } - - template - inline T *pnew(Args&&... args) - { - auto *p = paligned_alloc(alignof(T), sizeof(T)); - return new(p) T(std::forward(args)...); - } - template - inline void pdelete(T *ptr) - { - ptr->~T(); - pfree(ptr); - } + constexpr arena_deleter(arena_storage_type a = arena_storage_type()) noexcept + : m_a(a) { } - template - inline T* pnew_array(const std::size_t num) - { - return new T[num](); - } - - template - inline void pdelete_array(T *ptr) - { - delete [] ptr; - } - - template - struct pdefault_deleter - { - constexpr pdefault_deleter() noexcept = default; - - template::value>::type> - pdefault_deleter(const pdefault_deleter&) noexcept { } + arena_deleter(const arena_deleter &rhs) noexcept : m_a(rhs.m_a) { } - void operator()(T *p) const + void operator()(T *p) //const { - pdelete(p); + /* call destructor */ + p->~T(); + getref(m_a).deallocate(p); } + //private: + arena_storage_type m_a; }; - template > + //============================================================ + // owned_ptr: smart pointer with ownership information + //============================================================ + + template class owned_ptr { public: + + using pointer = SC *; + using element_type = SC; + using deleter_type = D; + owned_ptr() - : m_ptr(nullptr), m_is_owned(true) { } + : m_ptr(nullptr), m_deleter(), m_is_owned(true) { } template friend class owned_ptr; - owned_ptr(SC *p, bool owned) noexcept + owned_ptr(pointer p, bool owned) noexcept : m_ptr(p), m_deleter(), m_is_owned(owned) { } - owned_ptr(SC *p, bool owned, D deleter) noexcept + owned_ptr(pointer p, bool owned, D deleter) noexcept : m_ptr(p), m_deleter(deleter), m_is_owned(owned) { } @@ -168,10 +107,10 @@ namespace plib { } owned_ptr(owned_ptr &&r) noexcept + : m_ptr(r.m_ptr) + , m_deleter(r.m_deleter) + , m_is_owned(r.m_is_owned) { - m_is_owned = r.m_is_owned; - m_ptr = r.m_ptr; - m_deleter = r.m_deleter; r.m_is_owned = false; r.m_ptr = nullptr; } @@ -183,7 +122,7 @@ namespace plib { m_deleter(m_ptr); m_is_owned = r.m_is_owned; m_ptr = r.m_ptr; - m_deleter = r.m_deleter; + m_deleter = std::move(r.m_deleter); r.m_is_owned = false; r.m_ptr = nullptr; return *this; @@ -191,10 +130,10 @@ namespace plib { template owned_ptr(owned_ptr &&r) noexcept + : m_ptr(static_cast(r.get())) + , m_deleter(r.m_deleter) + , m_is_owned(r.is_owned()) { - m_ptr = static_cast(r.get()); - m_is_owned = r.is_owned(); - m_deleter = r.m_deleter; r.release(); } @@ -208,9 +147,9 @@ namespace plib { m_is_owned = false; m_ptr = nullptr; } - SC * release() + pointer release() { - SC *tmp = m_ptr; + pointer tmp = m_ptr; m_is_owned = false; m_ptr = nullptr; return tmp; @@ -218,97 +157,216 @@ namespace plib { bool is_owned() const { return m_is_owned; } - SC * operator ->() const { return m_ptr; } - SC & operator *() const { return *m_ptr; } - SC * get() const { return m_ptr; } + pointer operator ->() const noexcept { return m_ptr; } + typename std::add_lvalue_reference::type operator *() const noexcept { return *m_ptr; } + pointer get() const noexcept { return m_ptr; } + + deleter_type& get_deleter() noexcept { return m_deleter; } + const deleter_type& get_deleter() const noexcept { return m_deleter; } + private: - SC *m_ptr; + pointer m_ptr; D m_deleter; bool m_is_owned; }; - template - using unique_ptr = std::unique_ptr>; - - template - plib::unique_ptr make_unique(Args&&... args) - { - return plib::unique_ptr(pnew(std::forward(args)...)); - } - - template - static owned_ptr make_owned(Args&&... args) - { - owned_ptr a(pnew(std::forward(args)...), true); - return std::move(a); - } - //============================================================ - // Aligned allocator for use with containers + // Arena allocator for use with containers //============================================================ - template - class aligned_allocator + template + class arena_allocator { public: using value_type = T; static constexpr const std::size_t align_size = ALIGN; + using arena_type = ARENA; static_assert(align_size >= alignof(T) && (align_size % alignof(T)) == 0, "ALIGN must be greater than alignof(T) and a multiple"); - aligned_allocator() noexcept = default; - ~aligned_allocator() noexcept = default; + arena_allocator() noexcept + : m_a(arena_type::instance()) + { } + + ~arena_allocator() noexcept = default; - aligned_allocator(const aligned_allocator&) noexcept = default; - aligned_allocator& operator=(const aligned_allocator&) noexcept = delete; + arena_allocator(const arena_allocator &rhs) noexcept : m_a(rhs.m_a) { printf("copy called\n"); }//= default; + arena_allocator& operator=(const arena_allocator&) noexcept = delete; - aligned_allocator(aligned_allocator&&) noexcept = default; - aligned_allocator& operator=(aligned_allocator&&) = delete; + arena_allocator(arena_allocator&&) noexcept = default; + arena_allocator& operator=(arena_allocator&&) = delete; + + arena_allocator(arena_type & a) noexcept : m_a(a) + { + } template - aligned_allocator(const aligned_allocator& rhs) noexcept + arena_allocator(const arena_allocator& rhs) noexcept + : m_a(rhs.m_a) { - unused_var(rhs); } template struct rebind { - using other = aligned_allocator; + using other = arena_allocator; }; T* allocate(std::size_t n) { - return reinterpret_cast(paligned_alloc(ALIGN, sizeof(T) * n)); + return reinterpret_cast(m_a.allocate(ALIGN, sizeof(T) * n)); } void deallocate(T* p, std::size_t n) noexcept { unused_var(n); - pfree(p); + m_a.deallocate(p); } - template - friend bool operator==(const aligned_allocator& lhs, - const aligned_allocator& rhs) noexcept; + template + friend bool operator==(const arena_allocator& lhs, + const arena_allocator& rhs) noexcept; - template friend class aligned_allocator; + template friend class arena_allocator; + private: + arena_type &m_a; }; - template - /*friend*/ inline bool operator==(const aligned_allocator& lhs, - const aligned_allocator& rhs) noexcept + template + inline bool operator==(const arena_allocator& lhs, + const arena_allocator& rhs) noexcept { - unused_var(lhs, rhs); - return A1 == A2; + return A1 == A2 && rhs.m_a == lhs.m_a; } - template - /*friend*/ inline bool operator!=(const aligned_allocator& lhs, - const aligned_allocator& rhs) noexcept + template + inline bool operator!=(const arena_allocator& lhs, + const arena_allocator& rhs) noexcept { return !(lhs == rhs); } + //============================================================ + // Memory allocation + //============================================================ + + struct aligned_arena + { + static constexpr const bool is_stateless = true; + template + using allocator_type = arena_allocator; + + template + using owned_pool_ptr = plib::owned_ptr>; + + static inline aligned_arena &instance() + { + static aligned_arena s_arena; + return s_arena; + } + + static inline void *allocate( size_t alignment, size_t size ) + { + #if (USE_ALIGNED_ALLOCATION) + #if defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER) + return _aligned_malloc(size, alignment); + #elif defined(__APPLE__) + void* p; + if (::posix_memalign(&p, alignment, size) != 0) { + p = nullptr; + } + return p; + #else + return aligned_alloc(alignment, size); + #endif + #else + unused_var(alignment); + return ::operator new(size); + #endif + } + + static inline void deallocate( void *ptr ) + { + #if (USE_ALIGNED_ALLOCATION) + // NOLINTNEXTLINE(cppcoreguidelines-no-malloc) + free(ptr); + #else + ::operator delete(ptr); + #endif + } + + template + owned_pool_ptr make_poolptr(Args&&... args) + { + auto *mem = allocate(alignof(T), sizeof(T)); + return owned_pool_ptr(new (mem) T(std::forward(args)...), true, arena_deleter(*this)); + } + + }; + + 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!"); +#if (USE_ALIGNED_HINTS) + return reinterpret_cast(__builtin_assume_aligned(p, ALIGN)); +#else + return p; +#endif + } + + template + constexpr const T *assume_aligned_ptr(const 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"); +#if (USE_ALIGNED_HINTS) + return reinterpret_cast(__builtin_assume_aligned(p, ALIGN)); +#else + return p; +#endif + } + + // FIXME: remove + template + inline T *pnew(Args&&... args) + { + auto *p = aligned_arena::allocate(alignof(T), sizeof(T)); + return new(p) T(std::forward(args)...); + } + + template + inline void pdelete(T *ptr) + { + ptr->~T(); + aligned_arena::deallocate(ptr); + } + + + template + using unique_ptr = std::unique_ptr>; + + template + plib::unique_ptr make_unique(Args&&... args) + { + return plib::unique_ptr(pnew(std::forward(args)...)); + } + +#if 0 + template + static owned_ptr make_owned(Args&&... args) + { + return owned_ptr(pnew(std::forward(args)...), true); + } +#endif + + + template + using aligned_allocator = aligned_arena::allocator_type; + //============================================================ // traits to determine alignment size and stride size // from types supporting alignment @@ -321,14 +379,7 @@ namespace plib { { static constexpr const std::size_t align_size = alignof(std::max_align_t); static constexpr const std::size_t value_size = sizeof(typename T::value_type); -#if 0 - static constexpr const std::size_t stride_size = - ((value_size % align_size) == 0 ? 1 //T is a multiple of align_size - : ((align_size % value_size) != 0 ? align_size // align_size is not a multiple of T - : align_size / value_size)); -#else static constexpr const std::size_t stride_size = lcm(align_size, value_size) / value_size; -#endif }; template @@ -336,14 +387,7 @@ namespace plib { { static constexpr const std::size_t align_size = T::align_size; static constexpr const std::size_t value_size = sizeof(typename T::value_type); -#if 0 - static constexpr const std::size_t stride_size = - ((value_size % align_size) == 0 ? 1 //T is a multiple of align_size - : ((align_size % value_size) != 0 ? align_size // align_size is not a multiple of T - : align_size / value_size)); -#else static constexpr const std::size_t stride_size = lcm(align_size, value_size) / value_size; -#endif }; //============================================================ diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h index c521f24e5f8..6616669f619 100644 --- a/src/lib/netlist/plib/pconfig.h +++ b/src/lib/netlist/plib/pconfig.h @@ -38,7 +38,7 @@ */ #ifndef USE_ALIGNED_OPTIMIZATIONS -#define USE_ALIGNED_OPTIMIZATIONS (0) +#define USE_ALIGNED_OPTIMIZATIONS (1) #endif #define USE_ALIGNED_ALLOCATION (USE_ALIGNED_OPTIMIZATIONS) diff --git a/src/lib/netlist/plib/pdynlib.cpp b/src/lib/netlist/plib/pdynlib.cpp index 91e1b5cf73a..0d32bead51d 100644 --- a/src/lib/netlist/plib/pdynlib.cpp +++ b/src/lib/netlist/plib/pdynlib.cpp @@ -25,7 +25,7 @@ CHAR *astring_from_utf8(const char *utf8string) // convert UTF-16 to "ANSI code page" string char_count = WideCharToMultiByte(CP_ACP, 0, wstring, -1, nullptr, 0, nullptr, nullptr); - result = pnew_array(char_count); + result = new CHAR[char_count]; if (result != nullptr) WideCharToMultiByte(CP_ACP, 0, wstring, -1, result, char_count, nullptr, nullptr); @@ -39,7 +39,7 @@ WCHAR *wstring_from_utf8(const char *utf8string) // convert MAME string (UTF-8) to UTF-16 char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, nullptr, 0); - result = pnew_array(char_count); + result = new WCHAR[char_count]; if (result != nullptr) MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, result, char_count); @@ -72,7 +72,7 @@ dynlib::dynlib(const pstring &libname) m_isLoaded = true; //else // fprintf(stderr, "win: library <%s> not found!\n", libname.c_str()); - pdelete_array(buffer); + delete [] buffer; #elif defined(EMSCRIPTEN) //no-op #else @@ -106,7 +106,7 @@ dynlib::dynlib(const pstring &path, const pstring &libname) { //printf("win: library <%s> not found!\n", libname.c_str()); } - pdelete_array(buffer); + delete [] buffer; #elif defined(EMSCRIPTEN) //no-op #else diff --git a/src/lib/netlist/plib/pmatrix2d.h b/src/lib/netlist/plib/pmatrix2d.h index 52228548cbf..eab533688d7 100644 --- a/src/lib/netlist/plib/pmatrix2d.h +++ b/src/lib/netlist/plib/pmatrix2d.h @@ -22,21 +22,22 @@ namespace plib { - template> + template> class pmatrix2d { public: using value_type = T; + using allocator_type = A; static constexpr const std::size_t align_size = align_traits::align_size; static constexpr const std::size_t stride_size = align_traits::stride_size; pmatrix2d() - : m_N(0), m_M(0), m_stride(8) + : m_N(0), m_M(0), m_stride(8), m_v() { } pmatrix2d(std::size_t N, std::size_t M) - : m_N(N), m_M(M) + : m_N(N), m_M(M), m_v() { m_stride = ((M + stride_size-1) / stride_size) * stride_size; m_v.resize(N * m_stride); diff --git a/src/lib/netlist/plib/pmempool.h b/src/lib/netlist/plib/pmempool.h index 00e78b09fb6..5449595c86c 100644 --- a/src/lib/netlist/plib/pmempool.h +++ b/src/lib/netlist/plib/pmempool.h @@ -23,21 +23,6 @@ namespace plib { - template - struct pool_deleter - { - constexpr pool_deleter() noexcept = default; - - template::value>::type> - pool_deleter(const pool_deleter&) noexcept { } - - void operator()(T *p) const - { - P::free(p); - } - }; - //============================================================ // Memory pool //============================================================ @@ -100,8 +85,11 @@ namespace plib { std::vector m_blocks; public: + static constexpr const bool is_stateless = false; + template + using allocator_type = arena_allocator; - mempool(size_t min_alloc, size_t min_align) + mempool(size_t min_alloc = (1<<21), size_t min_align = 16) : m_min_alloc(min_alloc), m_min_align(min_align) { } @@ -122,10 +110,8 @@ namespace plib { } } - template - void *alloc(size_t size) + void *allocate(size_t align, size_t size) { - size_t align = ALIGN; if (align < m_min_align) align = m_min_align; @@ -164,11 +150,8 @@ namespace plib { } } - template - static void free(T *ptr) + static void deallocate(void *ptr) { - /* call destructor */ - ptr->~T(); auto it = sinfo().find(ptr); if (it == sinfo().end()) @@ -188,19 +171,18 @@ namespace plib { } template - using poolptr = plib::owned_ptr>; + using owned_pool_ptr = plib::owned_ptr>; template - poolptr make_poolptr(Args&&... args) + owned_pool_ptr make_poolptr(Args&&... args) { - auto *mem = this->alloc(sizeof(T)); - auto *obj = new (mem) T(std::forward(args)...); - poolptr a(obj, true); - return std::move(a); + auto *mem = this->allocate(alignof(T), sizeof(T)); + return owned_pool_ptr(new (mem) T(std::forward(args)...), true, arena_deleter(this)); } }; +#if 0 class mempool_default { private: @@ -210,7 +192,11 @@ namespace plib { public: - mempool_default(size_t min_alloc, size_t min_align) + static constexpr const bool is_stateless = true; + template + using allocator_type = arena_allocator; + + mempool_default(size_t min_alloc = 16, size_t min_align = (1 << 21)) : m_min_alloc(min_alloc), m_min_align(min_align) { } @@ -219,24 +205,22 @@ namespace plib { ~mempool_default() = default; -#if 0 - void *alloc(size_t size) + void *allocate(size_t alignment, size_t size) { plib::unused_var(m_min_alloc); // -Wunused-private-field fires without plib::unused_var(m_min_align); + plib::unused_var(alignment); return ::operator new(size); } -#endif - template - static void free(T *ptr) + static void deallocate(void *ptr) { - plib::pdelete(ptr); + ::operator delete(ptr); } template - using poolptr = plib::owned_ptr>; + using poolptr = plib::owned_ptr>; template poolptr make_poolptr(Args&&... args) @@ -249,7 +233,7 @@ namespace plib { return std::move(a); } }; - +#endif } // namespace plib diff --git a/src/lib/netlist/plib/pstream.cpp b/src/lib/netlist/plib/pstream.cpp index 8f80f317f98..a7acdaafb52 100644 --- a/src/lib/netlist/plib/pstream.cpp +++ b/src/lib/netlist/plib/pstream.cpp @@ -268,55 +268,25 @@ pimemstream::pos_type pimemstream::vtell() const // ----------------------------------------------------------------------------- pomemstream::pomemstream() -: postream(FLAG_SEEKABLE), m_pos(0), m_capacity(1024), m_size(0) +: postream(FLAG_SEEKABLE), m_pos(0), m_mem(1024) { - m_mem = pnew_array(m_capacity); -} - -pomemstream::~pomemstream() -{ - if (m_mem != nullptr) - pdelete_array(m_mem); + m_mem.clear(); } void pomemstream::vwrite(const value_type *buf, const pos_type n) { - if (m_pos + n >= m_capacity) - { - while (m_pos + n >= m_capacity) - m_capacity *= 2; - char *o = m_mem; - m_mem = pnew_array(m_capacity); - if (m_mem == nullptr) - { - throw out_of_mem_e("pomemstream::vwrite"); - } - std::copy(o, o + m_pos, m_mem); - pdelete_array(o); - } + if (m_pos + n >= m_mem.size()) + m_mem.resize(m_pos + n); - std::copy(buf, buf + n, m_mem + m_pos); + std::copy(buf, buf + n, &m_mem[0] + m_pos); m_pos += n; - m_size = std::max(m_pos, m_size); } void pomemstream::vseek(const pos_type n) { m_pos = n; - m_size = std::max(m_pos, m_size); - if (m_size >= m_capacity) - { - while (m_size >= m_capacity) - m_capacity *= 2; - char *o = m_mem; - m_mem = pnew_array(m_capacity); - if (m_mem == nullptr) - { - throw out_of_mem_e("pomemstream::vseek"); - } - std::copy(o, o + m_pos, m_mem); - pdelete_array(o); - } + if (m_pos>=m_mem.size()) + m_mem.resize(m_pos); } pstream::pos_type pomemstream::vtell() const diff --git a/src/lib/netlist/plib/pstream.h b/src/lib/netlist/plib/pstream.h index ec15c0258c6..93497eb1423 100644 --- a/src/lib/netlist/plib/pstream.h +++ b/src/lib/netlist/plib/pstream.h @@ -179,18 +179,15 @@ public: pomemstream(pomemstream &&src) noexcept : postream(std::move(src)) , m_pos(src.m_pos) - , m_capacity(src.m_capacity) - , m_size(src.m_size) - , m_mem(src.m_mem) + , m_mem(std::move(src.m_mem)) { - src.m_mem = nullptr; } pomemstream &operator=(pomemstream &&src) = delete; - ~pomemstream() override; + ~pomemstream() override = default; - char *memory() const { return m_mem; } - pos_type size() const { return m_size; } + const char *memory() const { return m_mem.data(); } + pos_type size() const { return m_mem.size(); } protected: /* write n bytes to stream */ @@ -200,9 +197,7 @@ protected: private: pos_type m_pos; - pos_type m_capacity; - pos_type m_size; - char *m_mem; + std::vector m_mem; }; class postringstream : public postream @@ -626,11 +621,10 @@ public: { std::size_t sz = 0; read(sz); - auto buf = plib::pnew_array::mem_t>(sz+1); - m_strm.read(reinterpret_cast(buf), sz); + std::vector::mem_t> buf(sz+1); + m_strm.read(buf.data(), sz); buf[sz] = 0; - s = pstring(buf); - plib::pdelete_array(buf); + s = pstring(buf.data()); } template diff --git a/src/lib/netlist/plib/ptypes.h b/src/lib/netlist/plib/ptypes.h index 7d3c064b35d..bda62099150 100644 --- a/src/lib/netlist/plib/ptypes.h +++ b/src/lib/netlist/plib/ptypes.h @@ -120,8 +120,8 @@ namespace plib static_assert(std::is_integral::value, "gcd: N must be an integer"); return m == 0 ? plib::abs(n) - : n == 0 ? plib::abs(m) - : gcd(n, m % n); + : n == 0 ? plib::abs(m) + : gcd(n, m % n); } template diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp index f9e25346493..784161a71a8 100644 --- a/src/lib/netlist/prg/nltool.cpp +++ b/src/lib/netlist/prg/nltool.cpp @@ -625,7 +625,7 @@ void tool_app_t::listdevices() nt.setup().prepare_to_run(); - std::vector> devs; + std::vector> devs; for (auto & f : list) { diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h index a7473eb6315..f76660e1cb9 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.h +++ b/src/lib/netlist/solver/nld_matrix_solver.h @@ -254,7 +254,7 @@ namespace devices std::vector> m_terms; std::vector m_nets; - std::vector> m_inps; + std::vector> m_inps; std::vector> m_rails_temp; diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp index 9d7b8e7dbb2..4734cc3624d 100644 --- a/src/lib/netlist/solver/nld_solver.cpp +++ b/src/lib/netlist/solver/nld_solver.cpp @@ -111,13 +111,13 @@ namespace devices } template - poolptr create_it(netlist_state_t &nl, pstring name, solver_parameters_t ¶ms, std::size_t size) + pool_owned_ptr create_it(netlist_state_t &nl, pstring name, solver_parameters_t ¶ms, std::size_t size) { return pool().make_poolptr(nl, name, ¶ms, size); } template - poolptr NETLIB_NAME(solver)::create_solver(std::size_t size, const pstring &solvername) + pool_owned_ptr NETLIB_NAME(solver)::create_solver(std::size_t size, const pstring &solvername) { if (m_method() == "SOR_MAT") { @@ -161,12 +161,12 @@ namespace devices else { log().fatal(MF_1_UNKNOWN_SOLVER_TYPE, m_method()); - return poolptr(); + return pool_owned_ptr(); } } template - poolptr NETLIB_NAME(solver)::create_solver_x(std::size_t size, const pstring &solvername) + pool_owned_ptr NETLIB_NAME(solver)::create_solver_x(std::size_t size, const pstring &solvername) { if (SIZE > 0) { @@ -291,7 +291,7 @@ namespace devices log().verbose("Found {1} net groups in {2} nets\n", splitter.groups.size(), state().nets().size()); for (auto & grp : splitter.groups) { - poolptr ms; + pool_owned_ptr ms; std::size_t net_count = grp.size(); pstring sname = plib::pfmt("Solver_{1}")(m_mat_solvers.size()); diff --git a/src/lib/netlist/solver/nld_solver.h b/src/lib/netlist/solver/nld_solver.h index 190ae9a9ab5..c9ec967a72a 100644 --- a/src/lib/netlist/solver/nld_solver.h +++ b/src/lib/netlist/solver/nld_solver.h @@ -102,17 +102,17 @@ namespace devices param_logic_t m_log_stats; - 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 - poolptr create_solver(std::size_t size, const pstring &solvername); + pool_owned_ptr create_solver(std::size_t size, const pstring &solvername); template - poolptr create_solver_x(std::size_t size, const pstring &solvername); + pool_owned_ptr create_solver_x(std::size_t size, const pstring &solvername); }; } //namespace devices -- cgit v1.2.3-70-g09d2 From 618f33f58624fdd3440773efc8fa8012158571b2 Mon Sep 17 00:00:00 2001 From: couriersud Date: Fri, 1 Mar 2019 19:52:06 +0100 Subject: netlist: refactoring. (nw) --- src/lib/netlist/devices/nld_7474.cpp | 34 +- src/lib/netlist/devices/nld_7490.cpp | 22 +- src/lib/netlist/devices/nld_7493.cpp | 74 ++--- src/lib/netlist/devices/nld_9316.cpp | 112 +++---- src/lib/netlist/nl_base.h | 566 +++++++++++++++++---------------- src/lib/netlist/nl_lists.h | 3 +- src/lib/netlist/plib/gmres.h | 8 +- src/lib/netlist/plib/pconfig.h | 4 +- src/lib/netlist/plib/plists.h | 10 +- src/lib/netlist/plib/pmempool.h | 53 --- src/lib/netlist/plib/pstring.cpp | 9 - src/lib/netlist/plib/pstring.h | 6 +- src/lib/netlist/plib/vector_ops.h | 26 +- src/lib/netlist/solver/nld_ms_direct.h | 4 +- 14 files changed, 414 insertions(+), 517 deletions(-) (limited to 'src/lib/netlist/plib/pmempool.h') diff --git a/src/lib/netlist/devices/nld_7474.cpp b/src/lib/netlist/devices/nld_7474.cpp index 2934e780552..740af6ad3c1 100644 --- a/src/lib/netlist/devices/nld_7474.cpp +++ b/src/lib/netlist/devices/nld_7474.cpp @@ -27,11 +27,11 @@ namespace netlist { } + private: NETLIB_RESETI(); NETLIB_UPDATEI(); NETLIB_HANDLERI(clk); - public: logic_input_t m_D; logic_input_t m_CLRQ; logic_input_t m_PREQ; @@ -39,7 +39,6 @@ namespace netlist logic_output_t m_Q; logic_output_t m_QQ; - private: state_var m_nextD; void newstate(const netlist_sig_t stateQ, const netlist_sig_t stateQQ) @@ -57,20 +56,20 @@ namespace netlist , m_1(*this, "1") , m_2(*this, "2") { - register_subalias("1", m_1.m_CLRQ); - register_subalias("2", m_1.m_D); - register_subalias("3", m_1.m_CLK); - register_subalias("4", m_1.m_PREQ); - register_subalias("5", m_1.m_Q); - register_subalias("6", m_1.m_QQ); + register_subalias("1", "1.CLRQ"); + register_subalias("2", "1.D"); + register_subalias("3", "1.CLK"); + register_subalias("4", "1.PREQ"); + register_subalias("5", "1.Q"); + register_subalias("6", "1.QQ"); // register_subalias("7", ); ==> GND - register_subalias("8", m_2.m_QQ); - register_subalias("9", m_2.m_Q); - register_subalias("10", m_2.m_PREQ); - register_subalias("11", m_2.m_CLK); - register_subalias("12", m_2.m_D); - register_subalias("13", m_2.m_CLRQ); + register_subalias("8", "2.QQ"); + register_subalias("9", "2.Q"); + register_subalias("10", "2.PREQ"); + register_subalias("11", "2.CLK"); + register_subalias("12", "2.D"); + register_subalias("13", "2.CLRQ"); // register_subalias("14", ); ==> VCC } NETLIB_UPDATEI(); @@ -83,11 +82,8 @@ namespace netlist NETLIB_HANDLER(7474, clk) { - //if (INP_LH(m_CLK)) - { - newstate(m_nextD, !m_nextD); - m_CLK.inactivate(); - } + newstate(m_nextD, !m_nextD); + m_CLK.inactivate(); } NETLIB_UPDATE(7474) diff --git a/src/lib/netlist/devices/nld_7490.cpp b/src/lib/netlist/devices/nld_7490.cpp index bde02e25edb..acbe0fa4d7a 100644 --- a/src/lib/netlist/devices/nld_7490.cpp +++ b/src/lib/netlist/devices/nld_7490.cpp @@ -28,10 +28,10 @@ namespace netlist { } + private: NETLIB_UPDATEI(); NETLIB_RESETI(); - protected: void update_outputs(); logic_input_t m_A; @@ -52,22 +52,22 @@ namespace netlist { NETLIB_CONSTRUCTOR_DERIVED(7490_dip, 7490) { - register_subalias("1", m_B); - register_subalias("2", m_R1); - register_subalias("3", m_R2); + register_subalias("1", "B"); + register_subalias("2", "R1"); + register_subalias("3", "R2"); // register_subalias("4", ); --> NC // register_subalias("5", ); --> VCC - register_subalias("6", m_R91); - register_subalias("7", m_R92); + register_subalias("6", "R91"); + register_subalias("7", "R92"); - register_subalias("8", m_Q[2]); - register_subalias("9", m_Q[1]); + register_subalias("8", "QC"); + register_subalias("9", "QB"); // register_subalias("10", ); --> GND - register_subalias("11", m_Q[3]); - register_subalias("12", m_Q[0]); + register_subalias("11", "QD"); + register_subalias("12", "QA"); // register_subalias("13", ); --> NC - register_subalias("14", m_A); + register_subalias("14", "A"); } }; diff --git a/src/lib/netlist/devices/nld_7493.cpp b/src/lib/netlist/devices/nld_7493.cpp index e19614329a9..f26e1c237d5 100644 --- a/src/lib/netlist/devices/nld_7493.cpp +++ b/src/lib/netlist/devices/nld_7493.cpp @@ -22,7 +22,6 @@ namespace netlist NETLIB_CONSTRUCTOR(7493) , m_R1(*this, "R1") , m_R2(*this, "R2") - , m_reset(*this, "_m_reset", 0) , m_a(*this, "_m_a", 0) , m_bcd(*this, "_m_b", 0) , m_CLKA(*this, "CLKA", NETLIB_DELEGATE(7493, updA)) @@ -35,34 +34,49 @@ namespace netlist } private: - NETLIB_RESETI(); - NETLIB_UPDATEI(); + NETLIB_RESETI() + { + m_a = m_bcd = 0; + m_CLKA.set_state(logic_t::STATE_INP_HL); + m_CLKB.set_state(logic_t::STATE_INP_HL); + } - NETLIB_HANDLERI(updA) + NETLIB_UPDATEI() { - //if (m_reset) + if (!(m_R1() & m_R2())) + { + m_CLKA.activate_hl(); + m_CLKB.activate_hl(); + } + else { - m_a ^= 1; - m_QA.push(m_a, out_delay); + m_CLKA.inactivate(); + m_CLKB.inactivate(); + 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; } } + NETLIB_HANDLERI(updA) + { + m_a ^= 1; + m_QA.push(m_a, out_delay); + } + NETLIB_HANDLERI(updB) { - //if (m_reset) - { - //++m_bcd &= 0x07; - auto cnt = (++m_bcd &= 0x07); - m_QD.push((cnt >> 2) & 1, out_delay3); - m_QC.push((cnt >> 1) & 1, out_delay2); - m_QB.push(cnt & 1, out_delay); - } + auto cnt = (++m_bcd &= 0x07); + m_QD.push((cnt >> 2) & 1, out_delay3); + m_QC.push((cnt >> 1) & 1, out_delay2); + m_QB.push(cnt & 1, out_delay); } logic_input_t m_R1; logic_input_t m_R2; - state_var_sig m_reset; state_var_sig m_a; state_var_u8 m_bcd; @@ -98,34 +112,6 @@ namespace netlist } }; - NETLIB_RESET(7493) - { - m_reset = 1; - m_a = m_bcd = 0; - m_CLKA.set_state(logic_t::STATE_INP_HL); - m_CLKB.set_state(logic_t::STATE_INP_HL); - } - - NETLIB_UPDATE(7493) - { - m_reset = (m_R1() & m_R2()) ^ 1; - - if (m_reset) - { - m_CLKA.activate_hl(); - m_CLKB.activate_hl(); - } - else - { - m_CLKA.inactivate(); - m_CLKB.inactivate(); - 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; - } - } NETLIB_DEVICE_IMPL(7493, "TTL_7493", "+CLKA,+CLKB,+R1,+R2") NETLIB_DEVICE_IMPL(7493_dip, "TTL_7493_DIP", "") diff --git a/src/lib/netlist/devices/nld_9316.cpp b/src/lib/netlist/devices/nld_9316.cpp index 390e3285fc2..2b17eabb3ec 100644 --- a/src/lib/netlist/devices/nld_9316.cpp +++ b/src/lib/netlist/devices/nld_9316.cpp @@ -20,6 +20,7 @@ namespace netlist NETLIB_CONSTRUCTOR(9316) , m_CLK(*this, "CLK", NETLIB_DELEGATE(9316, clk)) , m_ENT(*this, "ENT") + , m_RC(*this, "RC") , m_LOADQ(*this, "LOADQ") , m_ENP(*this, "ENP") , m_CLRQ(*this, "CLRQ") @@ -28,7 +29,6 @@ namespace netlist , m_C(*this, "C", NETLIB_DELEGATE(9316, abcd)) , m_D(*this, "D", NETLIB_DELEGATE(9316, abcd)) , m_Q(*this, {{ "QA", "QB", "QC", "QD" }}) - , m_RC(*this, "RC") , m_cnt(*this, "m_cnt", 0) , m_abcd(*this, "m_abcd", 0) , m_loadq(*this, "m_loadq", 0) @@ -37,17 +37,54 @@ namespace netlist } private: - NETLIB_RESETI(); - NETLIB_UPDATEI(); - NETLIB_HANDLERI(clk); + NETLIB_RESETI() + { + m_CLK.set_state(logic_t::STATE_INP_LH); + m_cnt = 0; + m_abcd = 0; + } + + NETLIB_UPDATEI() + { + const auto CLRQ(m_CLRQ()); + m_ent = m_ENT(); + m_loadq = m_LOADQ(); + + if (((m_loadq ^ 1) || (m_ent && m_ENP())) && CLRQ) + { + m_CLK.activate_lh(); + } + else + { + m_CLK.inactivate(); + if (!CLRQ && (m_cnt>0)) + { + m_cnt = 0; + update_outputs_all(m_cnt, NLTIME_FROM_NS(36)); + } + } + m_RC.push(m_ent && (m_cnt == MAXCNT), NLTIME_FROM_NS(27)); + } + + + NETLIB_HANDLERI(clk) + { + auto cnt = (m_loadq ? m_cnt + 1 : m_abcd) & MAXCNT; + m_RC.push(m_ent && (cnt == MAXCNT), NLTIME_FROM_NS(27)); + update_outputs_all(cnt, NLTIME_FROM_NS(20)); + m_cnt = cnt; + } + NETLIB_HANDLERI(abcd) { m_abcd = static_cast((m_D() << 3) | (m_C() << 2) | (m_B() << 1) | (m_A() << 0)); } logic_input_t m_CLK; - logic_input_t m_ENT; + + logic_output_t m_RC; + logic_input_t m_LOADQ; logic_input_t m_ENP; @@ -59,18 +96,15 @@ namespace netlist logic_input_t m_D; object_array_t m_Q; - logic_output_t m_RC; /* counter state */ - state_var_u8 m_cnt; - + state_var m_cnt; /* cached pins */ state_var_u8 m_abcd; state_var_sig m_loadq; state_var_sig m_ent; - private: - void update_outputs_all(const unsigned &cnt, const netlist_time &out_delay) noexcept + void update_outputs_all(unsigned cnt, netlist_time out_delay) noexcept { m_Q[0].push((cnt >> 0) & 1, out_delay); m_Q[1].push((cnt >> 1) & 1, out_delay); @@ -103,64 +137,6 @@ namespace netlist } }; - NETLIB_RESET(9316) - { - m_CLK.set_state(logic_t::STATE_INP_LH); - m_cnt = 0; - m_abcd = 0; - } - - NETLIB_HANDLER(9316, clk) - { - auto cnt(m_cnt); - if (m_loadq) - { - ++cnt &= MAXCNT; - //m_RC.push(m_ENT() && (cnt == MAXCNT), NLTIME_FROM_NS(27)); - if (cnt > 0 && cnt < MAXCNT) - update_outputs_all(cnt, NLTIME_FROM_NS(20)); - else if (cnt == 0) - { - m_RC.push(0, NLTIME_FROM_NS(27)); - update_outputs_all(0, NLTIME_FROM_NS(20)); - } - else - { - m_RC.push(m_ent, NLTIME_FROM_NS(27)); - update_outputs_all(MAXCNT, NLTIME_FROM_NS(20)); - } - } - else - { - cnt = m_abcd; - m_RC.push(m_ent && (cnt == MAXCNT), NLTIME_FROM_NS(27)); - update_outputs_all(cnt, NLTIME_FROM_NS(22)); - } - m_cnt = cnt; - } - - NETLIB_UPDATE(9316) - { - const netlist_sig_t CLRQ(m_CLRQ()); - m_ent = m_ENT(); - m_loadq = m_LOADQ(); - - if (((m_loadq ^ 1) || (m_ent && m_ENP())) && CLRQ) - { - m_CLK.activate_lh(); - } - else - { - m_CLK.inactivate(); - if (!CLRQ && (m_cnt>0)) - { - m_cnt = 0; - update_outputs_all(m_cnt, NLTIME_FROM_NS(36)); - } - } - m_RC.push(m_ent && (m_cnt == MAXCNT), NLTIME_FROM_NS(27)); - } - NETLIB_DEVICE_IMPL(9316, "TTL_9316", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D") NETLIB_DEVICE_IMPL(9316_dip, "TTL_9316_DIP", "") diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 4a48dc892b3..09e778762cd 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -192,13 +192,8 @@ namespace netlist } // namespace devices namespace detail { - class object_t; - class device_object_t; - struct netlist_ref; - class core_terminal_t; struct family_setter_t; class queue_t; - class net_t; } // namespace detail class logic_output_t; @@ -359,17 +354,17 @@ namespace netlist const T &value //!< Initial value after construction ); //! Copy Constructor. - state_array(const state_array &rhs) NL_NOEXCEPT = default; + state_array(const state_array &rhs) 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(state_array &&rhs) noexcept = default; + state_array &operator=(const state_array &rhs) noexcept = default; + state_array &operator=(state_array &&rhs) 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]; } + state_array &operator=(const T &rhs) noexcept { m_value = rhs; return *this; } + T & operator[](const std::size_t i) noexcept { return m_value[i]; } + constexpr const T & operator[](const std::size_t i) const noexcept { return m_value[i]; } private: std::array m_value; }; @@ -390,190 +385,324 @@ namespace netlist /*! predefined state variable type for sig_t */ using state_var_sig = state_var; - // ----------------------------------------------------------------------------- - // object_t - // ----------------------------------------------------------------------------- + namespace detail { - /*! The base class for netlist devices, terminals and parameters. - * - * This class serves as the base class for all device, terminal and - * objects. It provides new and delete operators to support e.g. pooled - * memory allocation to enhance locality. Please refer to \ref USE_MEMPOOL as - * well. - */ - class detail::object_t - { - public: + // ----------------------------------------------------------------------------- + // object_t + // ----------------------------------------------------------------------------- - /*! Constructor. + /*! The base class for netlist devices, terminals and parameters. * - * Every class derived from the object_t class must have a name. + * This class serves as the base class for all device, terminal and + * objects. It provides new and delete operators to support e.g. pooled + * memory allocation to enhance locality. Please refer to \ref USE_MEMPOOL as + * well. */ - explicit object_t(const pstring &aname /*!< string containing name of the object */); + class object_t + { + public: - COPYASSIGNMOVE(object_t, delete) - /*! return name of the object - * - * \returns name of the object. - */ - pstring name() const; + /*! Constructor. + * + * Every class derived from the object_t class must have a name. + */ + 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. + */ + pstring name() const; + + #if 0 + void * operator new (size_t size, void *ptr) { plib::unused_var(size); return ptr; } + void operator delete (void *ptr, void *) { plib::unused_var(ptr); } + void * operator new (size_t size) = delete; + void operator delete (void * mem) = delete; + #endif + protected: + ~object_t() noexcept = default; // only childs should be destructible -#if 0 - void * operator new (size_t size, void *ptr) { plib::unused_var(size); return ptr; } - void operator delete (void *ptr, void *) { plib::unused_var(ptr); } - void * operator new (size_t size) = delete; - void operator delete (void * mem) = delete; -#endif - protected: - ~object_t() noexcept = default; // only childs should be destructible + private: + //pstring m_name; + static std::unordered_map &name_hash() + { + static std::unordered_map lhash; + return lhash; + } + }; - private: - //pstring m_name; - static std::unordered_map &name_hash() + struct netlist_ref { - static std::unordered_map lhash; - return lhash; - } - }; + explicit netlist_ref(netlist_state_t &nl); - struct detail::netlist_ref - { - explicit netlist_ref(netlist_state_t &nl); + COPYASSIGNMOVE(netlist_ref, delete) - COPYASSIGNMOVE(netlist_ref, delete) + netlist_state_t & state() noexcept; + const netlist_state_t & state() const noexcept; - netlist_state_t & state() noexcept; - const netlist_state_t & state() const noexcept; + setup_t & setup() noexcept; + const setup_t & setup() const noexcept; - setup_t & setup() noexcept; - const setup_t & setup() const noexcept; + netlist_t & exec() noexcept { return m_netlist; } + const netlist_t & exec() const noexcept { return m_netlist; } - netlist_t & exec() noexcept { return m_netlist; } - const netlist_t & exec() const noexcept { return m_netlist; } + protected: + ~netlist_ref() noexcept = default; // prohibit polymorphic destruction - protected: - ~netlist_ref() noexcept = default; // prohibit polymorphic destruction - - private: - netlist_t & m_netlist; + private: + netlist_t & m_netlist; - }; + }; - // ----------------------------------------------------------------------------- - // device_object_t - // ----------------------------------------------------------------------------- + // ----------------------------------------------------------------------------- + // device_object_t + // ----------------------------------------------------------------------------- - /*! Base class for all objects being owned by a device. - * - * Serves as the base class of all objects being owned by a device. - * - */ - class detail::device_object_t : public detail::object_t - { - public: - /*! Constructor. + /*! Base class for all objects being owned by a device. + * + * Serves as the base class of all objects being owned by a device. * - * \param dev device owning the object. - * \param name string holding the name of the device */ - device_object_t(core_device_t &dev, const pstring &name); + class device_object_t : public object_t + { + public: + /*! Constructor. + * + * \param dev device owning the object. + * \param name string holding the name of the device + */ + device_object_t(core_device_t &dev, const pstring &name); + + /*! returns reference to owning device. + * \returns reference to owning device. + */ + core_device_t &device() noexcept { return m_device; } + const core_device_t &device() const noexcept { return m_device; } + + /*! The netlist owning the owner of this object. + * \returns reference to netlist object. + */ + netlist_state_t &state() NL_NOEXCEPT; + const netlist_state_t &state() const NL_NOEXCEPT; + + netlist_t &exec() NL_NOEXCEPT; + const netlist_t &exec() const NL_NOEXCEPT; - /*! returns reference to owning device. - * \returns reference to owning device. - */ - core_device_t &device() noexcept { return m_device; } - const core_device_t &device() const noexcept { return m_device; } + private: + core_device_t & m_device; + }; + + // ----------------------------------------------------------------------------- + // core_terminal_t + // ----------------------------------------------------------------------------- - /*! The netlist owning the owner of this object. - * \returns reference to netlist object. + /*! Base class for all terminals. + * + * All terminals are derived from this class. + * */ - netlist_state_t &state() NL_NOEXCEPT; - const netlist_state_t &state() const NL_NOEXCEPT; - netlist_t &exec() NL_NOEXCEPT; - const netlist_t &exec() const NL_NOEXCEPT; + class net_t; - private: - core_device_t & m_device; -}; + class core_terminal_t : public device_object_t, + public plib::linkedlist_t::element_t + { + public: - // ----------------------------------------------------------------------------- - // core_terminal_t - // ----------------------------------------------------------------------------- + using list_t = std::vector; - /*! Base class for all terminals. - * - * All terminals are derived from this class. - * - */ - class detail::core_terminal_t : public device_object_t, - public plib::linkedlist_t::element_t - { - public: + static constexpr const auto INP_HL_SHIFT = 0; + static constexpr const auto INP_LH_SHIFT = 1; + static constexpr const auto INP_ACTIVE_SHIFT = 2; - using list_t = std::vector; + enum state_e { + STATE_INP_PASSIVE = 0, + STATE_INP_HL = (1 << INP_HL_SHIFT), + STATE_INP_LH = (1 << INP_LH_SHIFT), + STATE_INP_ACTIVE = (1 << INP_ACTIVE_SHIFT), + STATE_OUT = 128, + STATE_BIDIR = 256 + }; - static constexpr const auto INP_HL_SHIFT = 0; - static constexpr const auto INP_LH_SHIFT = 1; - static constexpr const auto INP_ACTIVE_SHIFT = 2; + core_terminal_t(core_device_t &dev, const pstring &aname, + const state_e state, nldelegate delegate = nldelegate()); + virtual ~core_terminal_t() noexcept = default; - enum state_e { - STATE_INP_PASSIVE = 0, - STATE_INP_HL = (1 << INP_HL_SHIFT), - STATE_INP_LH = (1 << INP_LH_SHIFT), - STATE_INP_ACTIVE = (1 << INP_ACTIVE_SHIFT), - STATE_OUT = 128, - STATE_BIDIR = 256 - }; + COPYASSIGNMOVE(core_terminal_t, delete) - core_terminal_t(core_device_t &dev, const pstring &aname, - const state_e state, nldelegate delegate = nldelegate()); - virtual ~core_terminal_t() noexcept = default; + /*! The object type. + * \returns type of the object + */ + terminal_type type() const; + /*! Checks if object is of specified type. + * \param atype type to check object against. + * \returns true if object is of specified type else false. + */ + bool is_type(const terminal_type atype) const noexcept { return (type() == atype); } - COPYASSIGNMOVE(core_terminal_t, delete) + void set_net(net_t *anet) noexcept { m_net = anet; } + void clear_net() noexcept { m_net = nullptr; } + bool has_net() const noexcept { return (m_net != nullptr); } - /*! The object type. - * \returns type of the object - */ - terminal_type type() const; - /*! Checks if object is of specified type. - * \param atype type to check object against. - * \returns true if object is of specified type else false. - */ - bool is_type(const terminal_type atype) const noexcept { return (type() == atype); } + const net_t & net() const noexcept { return *m_net;} + net_t & net() noexcept { return *m_net;} - void set_net(net_t *anet) noexcept { m_net = anet; } - void clear_net() noexcept { m_net = nullptr; } - bool has_net() const noexcept { return (m_net != nullptr); } + bool is_logic() const NL_NOEXCEPT; + bool is_analog() const NL_NOEXCEPT; - const net_t & net() const noexcept { return *m_net;} - net_t & net() noexcept { return *m_net;} + bool is_state(state_e astate) const noexcept { return (m_state == astate); } + state_e terminal_state() const noexcept { return m_state; } + void set_state(state_e astate) noexcept { m_state = astate; } - bool is_logic() const NL_NOEXCEPT; - bool is_analog() const NL_NOEXCEPT; + void reset() noexcept { set_state(is_type(OUTPUT) ? STATE_OUT : STATE_INP_ACTIVE); } - bool is_state(state_e astate) const noexcept { return (m_state == astate); } - state_e terminal_state() const noexcept { return m_state; } - void set_state(state_e astate) noexcept { m_state = astate; } + nldelegate m_delegate; + #if USE_COPY_INSTEAD_OF_REFERENCE + void set_copied_input(netlist_sig_t val) + { + m_Q = val; + } - void reset() noexcept { set_state(is_type(OUTPUT) ? STATE_OUT : STATE_INP_ACTIVE); } + state_var_sig m_Q; + #else + void set_copied_input(netlist_sig_t val) const { plib::unused_var(val); } + #endif - nldelegate m_delegate; -#if USE_COPY_INSTEAD_OF_REFERENCE - void set_copied_input(netlist_sig_t val) + private: + net_t * m_net; + state_var m_state; + }; + + // ----------------------------------------------------------------------------- + // net_t + // ----------------------------------------------------------------------------- + + class net_t : + public object_t, + public netlist_ref { - m_Q = val; - } + public: - state_var_sig m_Q; -#else - void set_copied_input(netlist_sig_t val) const { plib::unused_var(val); } -#endif + enum class queue_status + { + DELAYED_DUE_TO_INACTIVE = 0, + QUEUED, + DELIVERED + }; - private: - net_t * m_net; - state_var m_state; - }; + net_t(netlist_state_t &nl, const pstring &aname, core_terminal_t *mr = nullptr); + + COPYASSIGNMOVE(net_t, delete) + + virtual ~net_t() noexcept = default; + + void reset(); + + void toggle_new_Q() noexcept { m_new_Q = (m_cur_Q ^ 1); } + + void toggle_and_push_to_queue(netlist_time delay) NL_NOEXCEPT + { + toggle_new_Q(); + push_to_queue(delay); + } + + void push_to_queue(netlist_time delay) NL_NOEXCEPT; + bool is_queued() const noexcept { return m_in_queue == queue_status::QUEUED; } + + void update_devs() NL_NOEXCEPT; + + netlist_time next_scheduled_time() const noexcept { return m_next_scheduled_time; } + void set_next_scheduled_time(netlist_time ntime) noexcept { m_next_scheduled_time = ntime; } + + bool isRailNet() const noexcept { return !(m_railterminal == nullptr); } + core_terminal_t & railterminal() const noexcept { return *m_railterminal; } + + std::size_t num_cons() const noexcept { return m_core_terms.size(); } + + void add_to_active_list(core_terminal_t &term) NL_NOEXCEPT; + void remove_from_active_list(core_terminal_t &term) NL_NOEXCEPT; + + /* setup stuff */ + + void add_terminal(core_terminal_t &terminal); + void remove_terminal(core_terminal_t &terminal); + + bool is_logic() const NL_NOEXCEPT; + bool is_analog() const NL_NOEXCEPT; + + void rebuild_list(); /* rebuild m_list after a load */ + void move_connections(net_t &dest_net); + + std::vector &core_terms() { return m_core_terms; } + #if USE_COPY_INSTEAD_OF_REFERENCE + void update_inputs() + { + for (auto & term : m_core_terms) + term->m_Q = m_cur_Q; + } + #else + void update_inputs() const + { + /* nothing needs to be done */ + } + #endif + + 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) + { + 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) + { + m_in_queue = queue_status::DELAYED_DUE_TO_INACTIVE; + m_next_scheduled_time = at; + } + m_cur_Q = m_new_Q = newQ; + update_inputs(); + } + + /* 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(); } + + 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); + }; + } // detail // ----------------------------------------------------------------------------- // analog_t @@ -713,133 +842,6 @@ namespace netlist }; - // ----------------------------------------------------------------------------- - // net_t - // ----------------------------------------------------------------------------- - - class detail::net_t : - public detail::object_t, - public detail::netlist_ref - { - public: - - enum class queue_status - { - DELAYED_DUE_TO_INACTIVE = 0, - QUEUED, - DELIVERED - }; - - net_t(netlist_state_t &nl, const pstring &aname, core_terminal_t *mr = nullptr); - - COPYASSIGNMOVE(net_t, delete) - - virtual ~net_t() noexcept = default; - - void reset(); - - void toggle_new_Q() noexcept { m_new_Q = (m_cur_Q ^ 1); } - - void toggle_and_push_to_queue(netlist_time delay) NL_NOEXCEPT - { - toggle_new_Q(); - push_to_queue(delay); - } - - void push_to_queue(netlist_time delay) NL_NOEXCEPT; - bool is_queued() const noexcept { return m_in_queue == queue_status::QUEUED; } - - void update_devs() NL_NOEXCEPT; - - netlist_time next_scheduled_time() const noexcept { return m_next_scheduled_time; } - void set_next_scheduled_time(netlist_time ntime) noexcept { m_next_scheduled_time = ntime; } - - bool isRailNet() const noexcept { return !(m_railterminal == nullptr); } - core_terminal_t & railterminal() const noexcept { return *m_railterminal; } - - std::size_t num_cons() const noexcept { return m_core_terms.size(); } - - void add_to_active_list(core_terminal_t &term) NL_NOEXCEPT; - void remove_from_active_list(core_terminal_t &term) NL_NOEXCEPT; - - /* setup stuff */ - - void add_terminal(core_terminal_t &terminal); - void remove_terminal(core_terminal_t &terminal); - - bool is_logic() const NL_NOEXCEPT; - bool is_analog() const NL_NOEXCEPT; - - void rebuild_list(); /* rebuild m_list after a load */ - void move_connections(net_t &dest_net); - - std::vector &core_terms() { return m_core_terms; } -#if USE_COPY_INSTEAD_OF_REFERENCE - void update_inputs() - { - for (auto & term : m_core_terms) - term->m_Q = m_cur_Q; - } -#else - void update_inputs() const - { - /* nothing needs to be done */ - } -#endif - - 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) - { - 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) - { - m_in_queue = queue_status::DELAYED_DUE_TO_INACTIVE; - m_next_scheduled_time = at; - } - m_cur_Q = m_new_Q = newQ; - update_inputs(); - } - - /* 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(); } - - 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 { diff --git a/src/lib/netlist/nl_lists.h b/src/lib/netlist/nl_lists.h index 4ca1e7507c8..325f8a67c72 100644 --- a/src/lib/netlist/nl_lists.h +++ b/src/lib/netlist/nl_lists.h @@ -198,7 +198,8 @@ namespace netlist mutex_type m_lock; PALIGNAS_CACHELINE() T * m_end; - std::vector m_list; + //std::vector m_list; + plib::aligned_vector m_list; public: // profiling diff --git a/src/lib/netlist/plib/gmres.h b/src/lib/netlist/plib/gmres.h index d3551897f69..2c357e97624 100644 --- a/src/lib/netlist/plib/gmres.h +++ b/src/lib/netlist/plib/gmres.h @@ -239,7 +239,7 @@ namespace plib ops.calc_rhs(Ax, x); - vec_sub(n, rhs, Ax, residual); + vec_sub(n, residual, rhs, Ax); ops.solve_LU_inplace(residual); @@ -258,7 +258,7 @@ namespace plib //for (std::size_t i = 0; i < mr + 1; i++) // vec_set_scalar(mr, m_ht[i], NL_FCONST(0.0)); - vec_mult_scalar(n, residual, constants::one() / rho, m_v[0]); + vec_mult_scalar(n, m_v[0], residual, constants::one() / rho); for (std::size_t k = 0; k < RESTART; k++) { @@ -270,7 +270,7 @@ namespace plib for (std::size_t j = 0; j <= k; j++) { m_ht[j][k] = vec_mult(n, m_v[kp1], m_v[j]); - vec_add_mult_scalar(n, m_v[j], -m_ht[j][k], m_v[kp1]); + vec_add_mult_scalar(n, m_v[kp1], m_v[j], -m_ht[j][k]); } m_ht[kp1][k] = std::sqrt(vec_mult2(n, m_v[kp1])); @@ -315,7 +315,7 @@ namespace plib } for (std::size_t i = 0; i <= last_k; i++) - vec_add_mult_scalar(n, m_v[i], m_y[i], x); + vec_add_mult_scalar(n, x, m_v[i], m_y[i]); if (rho <= rho_delta) break; diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h index 6616669f619..c5a83718395 100644 --- a/src/lib/netlist/plib/pconfig.h +++ b/src/lib/netlist/plib/pconfig.h @@ -38,7 +38,7 @@ */ #ifndef USE_ALIGNED_OPTIMIZATIONS -#define USE_ALIGNED_OPTIMIZATIONS (1) +#define USE_ALIGNED_OPTIMIZATIONS (0) #endif #define USE_ALIGNED_ALLOCATION (USE_ALIGNED_OPTIMIZATIONS) @@ -48,7 +48,7 @@ */ #define PALIGN_CACHELINE (64) -#define PALIGN_VECTOROPT (32) +#define PALIGN_VECTOROPT (64) #define PALIGNAS_CACHELINE() PALIGNAS(PALIGN_CACHELINE) #define PALIGNAS_VECTOROPT() PALIGNAS(PALIGN_VECTOROPT) diff --git a/src/lib/netlist/plib/plists.h b/src/lib/netlist/plib/plists.h index 2a0fd3a6c3c..c2fee9c2f8e 100644 --- a/src/lib/netlist/plib/plists.h +++ b/src/lib/netlist/plib/plists.h @@ -34,10 +34,10 @@ public: using iterator = C *; using const_iterator = const C *; - uninitialised_array_t() = default; + uninitialised_array_t() noexcept = default; COPYASSIGNMOVE(uninitialised_array_t, delete) - ~uninitialised_array_t() + ~uninitialised_array_t() noexcept { for (std::size_t i=0; i::type, N> m_buf; }; @@ -226,10 +226,10 @@ public: void push_front(LC *elem) noexcept { + if (m_head) + m_head->m_prev = elem; elem->m_next = m_head; elem->m_prev = nullptr; - if (elem->m_next) - elem->m_next->m_prev = elem; m_head = elem; } diff --git a/src/lib/netlist/plib/pmempool.h b/src/lib/netlist/plib/pmempool.h index 5449595c86c..f55807c86dc 100644 --- a/src/lib/netlist/plib/pmempool.h +++ b/src/lib/netlist/plib/pmempool.h @@ -182,59 +182,6 @@ namespace plib { }; -#if 0 - class mempool_default - { - private: - - size_t m_min_alloc; - size_t m_min_align; - - public: - - static constexpr const bool is_stateless = true; - template - using allocator_type = arena_allocator; - - mempool_default(size_t min_alloc = 16, size_t min_align = (1 << 21)) - : m_min_alloc(min_alloc), m_min_align(min_align) - { - } - - COPYASSIGNMOVE(mempool_default, delete) - - ~mempool_default() = default; - - void *allocate(size_t alignment, size_t size) - { - plib::unused_var(m_min_alloc); // -Wunused-private-field fires without - plib::unused_var(m_min_align); - plib::unused_var(alignment); - - return ::operator new(size); - } - - static void deallocate(void *ptr) - { - ::operator delete(ptr); - } - - template - using poolptr = plib::owned_ptr>; - - template - poolptr make_poolptr(Args&&... args) - { - plib::unused_var(m_min_alloc); // -Wunused-private-field fires without - plib::unused_var(m_min_align); - - auto *obj = plib::pnew(std::forward(args)...); - poolptr a(obj, true); - return std::move(a); - } - }; -#endif - } // namespace plib #endif /* PMEMPOOL_H_ */ diff --git a/src/lib/netlist/plib/pstring.cpp b/src/lib/netlist/plib/pstring.cpp index 089244c8232..c304f11d1fd 100644 --- a/src/lib/netlist/plib/pstring.cpp +++ b/src/lib/netlist/plib/pstring.cpp @@ -13,15 +13,6 @@ #include #include -template -std::size_t strlen_mem(const T *s) -{ - std::size_t len(0); - while (*s++) - ++len; - return len; -} - template int pstring_t::compare(const pstring_t &right) const { diff --git a/src/lib/netlist/plib/pstring.h b/src/lib/netlist/plib/pstring.h index 64cb0604b69..c4caeab8e8f 100644 --- a/src/lib/netlist/plib/pstring.h +++ b/src/lib/netlist/plib/pstring.h @@ -75,7 +75,7 @@ public: using string_type = typename traits_type::string_type; // FIXME: this is ugly - class ref_value_type final + struct ref_value_type final { public: ref_value_type() = delete; @@ -202,11 +202,9 @@ public: size_type mem_t_size() const { return m_str.size(); } - pstring_t rpad(const pstring_t &ws, const size_type cnt) const; - const string_type &cpp_string() const { return m_str; } - static const size_type npos = static_cast(-1); + static constexpr const size_type npos = static_cast(-1); private: string_type m_str; diff --git a/src/lib/netlist/plib/vector_ops.h b/src/lib/netlist/plib/vector_ops.h index 880840e8707..8043c48f61c 100644 --- a/src/lib/netlist/plib/vector_ops.h +++ b/src/lib/netlist/plib/vector_ops.h @@ -26,7 +26,7 @@ namespace plib { template - void vec_set_scalar (const std::size_t n, VT &v, T && scalar) + void vec_set_scalar(const std::size_t n, VT &v, T && scalar) { const typename std::remove_reference::type s(std::forward(scalar)); for ( std::size_t i = 0; i < n; i++ ) @@ -34,14 +34,14 @@ namespace plib } template - void vec_set (const std::size_t n, VT &v, const VS & source) + void vec_set(const std::size_t n, VT &v, const VS & source) { for ( std::size_t i = 0; i < n; i++ ) v[i] = source[i]; } template - T vec_mult (const std::size_t n, const V1 & v1, const V2 & v2 ) + T vec_mult(const std::size_t n, const V1 & v1, const V2 & v2 ) { using b8 = T[8]; PALIGNAS_VECTOROPT() b8 value = {0}; @@ -53,7 +53,7 @@ namespace plib } template - T vec_mult2 (const std::size_t n, const VT &v) + T vec_mult2(const std::size_t n, const VT &v) { using b8 = T[8]; PALIGNAS_VECTOROPT() b8 value = {0}; @@ -65,7 +65,7 @@ namespace plib } template - T vec_sum (const std::size_t n, const VT &v) + T vec_sum(const std::size_t n, const VT &v) { if (n<8) { @@ -87,15 +87,15 @@ namespace plib } template - void vec_mult_scalar (const std::size_t n, const VV & v, T && scalar, VR & result) + void vec_mult_scalar(const std::size_t n, VR & result, const VV & v, T && scalar) { const typename std::remove_reference::type s(std::forward(scalar)); for ( std::size_t i = 0; i < n; i++ ) result[i] = s * v[i]; } - template - void vec_add_mult_scalar (const std::size_t n, const VV & v, T && scalar, VR & result) + template + void vec_add_mult_scalar(const std::size_t n, VR & result, const VV & v, T && scalar) { const typename std::remove_reference::type s(std::forward(scalar)); for ( std::size_t i = 0; i < n; i++ ) @@ -103,21 +103,21 @@ namespace plib } template - void vec_add_mult_scalar_p(const std::size_t & n, const T * v, T scalar, T * result) + void vec_add_mult_scalar_p(const std::size_t n, T * result, const T * v, T scalar) { for ( std::size_t i = 0; i < n; i++ ) result[i] += scalar * v[i]; } - template - void vec_add_ip(const std::size_t n, const V & v, R & result) + template + void vec_add_ip(const std::size_t n, R & result, const V & v) { for ( std::size_t i = 0; i < n; i++ ) result[i] += v[i]; } - template - void vec_sub(const std::size_t n, const V1 &v1, const V2 & v2, VR & result) + template + void vec_sub(const std::size_t n, VR & result, const V1 &v1, const V2 & v2) { for ( std::size_t i = 0; i < n; i++ ) result[i] = v1[i] - v2[i]; diff --git a/src/lib/netlist/solver/nld_ms_direct.h b/src/lib/netlist/solver/nld_ms_direct.h index 35858363a33..2501742218d 100644 --- a/src/lib/netlist/solver/nld_ms_direct.h +++ b/src/lib/netlist/solver/nld_ms_direct.h @@ -139,9 +139,9 @@ namespace devices const FT * pi = &A(i,i+1); FT * pj = &A(j,i+1); #if 1 - plib::vec_add_mult_scalar_p(kN-i,pi,f1,pj); + plib::vec_add_mult_scalar_p(kN-i,pj, pi,f1); #else - vec_add_mult_scalar_p(kN-i-1,pj,f1,pi); + vec_add_mult_scalar_p1(kN-i-1,pj,pi,f1); //for (unsigned k = i+1; k < kN; k++) // pj[k] = pj[k] + pi[k] * f1; //for (unsigned k = i+1; k < kN; k++) -- cgit v1.2.3-70-g09d2