From df8280806bb942e51da75753733e1f3272196d60 Mon Sep 17 00:00:00 2001 From: couriersud Date: Sun, 8 May 2016 01:58:10 +0200 Subject: [PATCH] Some minor changes towards c++11. --- src/lib/netlist/devices/nld_system.h | 2 +- src/lib/netlist/devices/nld_truthtable.cpp | 2 +- src/lib/netlist/nl_base.h | 26 ++++++++++------------ src/lib/netlist/nl_config.h | 2 +- src/lib/netlist/nl_factory.h | 24 ++++++++++---------- src/lib/netlist/nl_setup.h | 2 +- src/lib/netlist/nl_time.h | 4 ++-- src/lib/netlist/plib/pconfig.h | 23 ++++++++----------- src/lib/netlist/plib/pdynlib.h | 4 ++-- src/lib/netlist/plib/pstate.h | 4 ++-- src/lib/netlist/plib/pstream.h | 2 +- src/lib/netlist/solver/nld_matrix_solver.h | 4 ++-- src/lib/netlist/solver/nld_ms_gcr.h | 4 ++-- src/lib/netlist/solver/nld_solver.h | 4 ++-- 14 files changed, 50 insertions(+), 57 deletions(-) diff --git a/src/lib/netlist/devices/nld_system.h b/src/lib/netlist/devices/nld_system.h index 674e81e7608..79183a36f86 100644 --- a/src/lib/netlist/devices/nld_system.h +++ b/src/lib/netlist/devices/nld_system.h @@ -500,7 +500,7 @@ public: pstring m_dev_name; }; - ATTR_COLD device_t *Create(netlist_t &anetlist, const pstring &name) override + device_t *Create(netlist_t &anetlist, const pstring &name) override { return palloc(wrapper(this->name(), anetlist, name)); } diff --git a/src/lib/netlist/devices/nld_truthtable.cpp b/src/lib/netlist/devices/nld_truthtable.cpp index c56666209cb..58a7e62639c 100644 --- a/src/lib/netlist/devices/nld_truthtable.cpp +++ b/src/lib/netlist/devices/nld_truthtable.cpp @@ -242,7 +242,7 @@ void truthtable_desc_t::setup(const pstring_vector_t &truthtable, UINT32 disable } #define ENTRYX(_n,_m,_h) case (_n * 1000 + _m * 10 + _h): \ - { typedef netlist_factory_truthtable_t<_n,_m,_h> xtype; \ + { using xtype = netlist_factory_truthtable_t<_n,_m,_h>; \ return palloc(xtype(name,classname,def_param)); } break #define ENTRYY(_n,_m) ENTRYX(_n,_m,0); ENTRYX(_n,_m,1) diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 45da883b174..783431ee881 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -169,14 +169,12 @@ // Type definitions // ---------------------------------------------------------------------------------------- -//typedef UINT8 netlist_sig_t; - /* * unsigned int would be a 20% speed increase over UINT8 for pong. * For breakout it causes a slight decrease. * */ -typedef unsigned int netlist_sig_t; +using netlist_sig_t = std::uint32_t; //============================================================ // MACROS / netlist devices @@ -317,7 +315,7 @@ namespace netlist // model_map_t // ----------------------------------------------------------------------------- - typedef phashmap_t model_map_t; + using model_map_t = phashmap_t; // ----------------------------------------------------------------------------- // logic_family_t @@ -475,7 +473,7 @@ namespace netlist P_PREVENT_COPYING(core_terminal_t) public: - typedef pvector_t list_t; + using list_t = pvector_t; /* needed here ... */ @@ -553,7 +551,7 @@ namespace netlist P_PREVENT_COPYING(terminal_t) public: - typedef pvector_t list_t; + using list_t = pvector_t; ATTR_COLD terminal_t(); @@ -701,7 +699,7 @@ namespace netlist P_PREVENT_COPYING(net_t) public: - typedef pvector_t list_t; + using list_t = pvector_t; ATTR_COLD net_t(const family_t afamily); virtual ~net_t(); @@ -781,7 +779,7 @@ namespace netlist P_PREVENT_COPYING(logic_net_t) public: - typedef pvector_t list_t; + using list_t = pvector_t; ATTR_COLD logic_net_t(); virtual ~logic_net_t() { }; @@ -841,7 +839,7 @@ namespace netlist P_PREVENT_COPYING(analog_net_t) public: - typedef pvector_t list_t; + using list_t = pvector_t; ATTR_COLD analog_net_t(); virtual ~analog_net_t() { }; @@ -987,9 +985,9 @@ namespace netlist private: }; - typedef param_template_t param_double_t; - typedef param_template_t param_int_t; - typedef param_template_t param_str_t; + using param_double_t = param_template_t; + using param_int_t = param_template_t; + using param_str_t = param_template_t; class param_logic_t : public param_int_t { @@ -1026,7 +1024,7 @@ namespace netlist P_PREVENT_COPYING(core_device_t) public: - typedef pvector_t list_t; + using list_t = pvector_t; ATTR_COLD core_device_t(const family_t afamily, netlist_t &anetlist, const pstring &name); @@ -1102,7 +1100,7 @@ namespace netlist #if (NL_PMF_TYPE == NL_PMF_TYPE_GNUC_PMF) typedef void (core_device_t::*net_update_delegate)(); #elif ((NL_PMF_TYPE == NL_PMF_TYPE_GNUC_PMF_CONV) || (NL_PMF_TYPE == NL_PMF_TYPE_INTERNAL)) - typedef MEMBER_ABI void (*net_update_delegate)(core_device_t *); + using net_update_delegate = MEMBER_ABI void (*)(core_device_t *); #endif #if (NL_PMF_TYPE > NL_PMF_TYPE_VIRTUAL) diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h index 41d2989bd2f..835949a80e7 100644 --- a/src/lib/netlist/nl_config.h +++ b/src/lib/netlist/nl_config.h @@ -47,7 +47,7 @@ */ // This will be autodetected -// #define NL_PMF_TYPE 2 +// #define NL_PMF_TYPE 3 #define NL_PMF_TYPE_VIRTUAL 0 #define NL_PMF_TYPE_GNUC_PMF 1 diff --git a/src/lib/netlist/nl_factory.h b/src/lib/netlist/nl_factory.h index 642ccb3e64a..15667696807 100644 --- a/src/lib/netlist/nl_factory.h +++ b/src/lib/netlist/nl_factory.h @@ -24,7 +24,7 @@ namespace netlist { P_PREVENT_COPYING(base_factory_t) public: - ATTR_COLD base_factory_t(const pstring &name, const pstring &classname, + base_factory_t(const pstring &name, const pstring &classname, const pstring &def_param) : m_name(name), m_classname(classname), m_def_param(def_param) {} @@ -33,11 +33,11 @@ namespace netlist virtual device_t *Create(netlist_t &anetlist, const pstring &name) = 0; - ATTR_COLD const pstring &name() const { return m_name; } - ATTR_COLD const pstring &classname() const { return m_classname; } - ATTR_COLD const pstring ¶m_desc() const { return m_def_param; } - ATTR_COLD const pstring_vector_t term_param_list(); - ATTR_COLD const pstring_vector_t def_params(); + const pstring &name() const { return m_name; } + const pstring &classname() const { return m_classname; } + const pstring ¶m_desc() const { return m_def_param; } + const pstring_vector_t term_param_list(); + const pstring_vector_t def_params(); protected: pstring m_name; /* device name */ @@ -50,11 +50,11 @@ namespace netlist { P_PREVENT_COPYING(factory_t) public: - ATTR_COLD factory_t(const pstring &name, const pstring &classname, + factory_t(const pstring &name, const pstring &classname, const pstring &def_param) : base_factory_t(name, classname, def_param) { } - ATTR_COLD device_t *Create(netlist_t &anetlist, const pstring &name) override + device_t *Create(netlist_t &anetlist, const pstring &name) override { device_t *r = palloc(_device_class(anetlist, name)); return r; @@ -68,14 +68,14 @@ namespace netlist ~factory_list_t(); template - ATTR_COLD void register_device(const pstring &name, const pstring &classname, + void register_device(const pstring &name, const pstring &classname, const pstring &def_param) { if (!add(name, palloc(factory_t< _device_class >(name, classname, def_param)))) error("factory already contains " + name); } - ATTR_COLD void register_device(base_factory_t *factory) + void register_device(base_factory_t *factory) { if (!add(factory->name(), factory)) error("factory already contains " + factory->name()); @@ -83,8 +83,8 @@ namespace netlist //ATTR_COLD device_t *new_device_by_classname(const pstring &classname) const; // FIXME: legacy, should use factory_by_name - ATTR_COLD device_t *new_device_by_name(const pstring &devname, netlist_t &anetlist, const pstring &name); - ATTR_COLD base_factory_t * factory_by_name(const pstring &devname); + device_t *new_device_by_name(const pstring &devname, netlist_t &anetlist, const pstring &name); + base_factory_t * factory_by_name(const pstring &devname); private: void error(const pstring &s); diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h index 147def65405..08de91daf62 100644 --- a/src/lib/netlist/nl_setup.h +++ b/src/lib/netlist/nl_setup.h @@ -91,7 +91,7 @@ namespace netlist class source_t { public: - typedef pvector_t list_t; + using list_t = pvector_t; source_t() {} diff --git a/src/lib/netlist/nl_time.h b/src/lib/netlist/nl_time.h index ddb3c85d14e..3ae1f9b7906 100644 --- a/src/lib/netlist/nl_time.h +++ b/src/lib/netlist/nl_time.h @@ -33,10 +33,10 @@ namespace netlist public: #if (PHAS_INT128) - typedef UINT128 INTERNALTYPE; + using INTERNALTYPE = UINT128; static const pstate_data_type_e STATETYPE = DT_INT128; #else - typedef UINT64 INTERNALTYPE; + using INTERNALTYPE = UINT64; static const pstate_data_type_e STATETYPE = DT_INT64; #endif static const INTERNALTYPE RESOLUTION = NETLIST_INTERNAL_RES; diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h index 06019dc6d26..82c71c2f2a8 100644 --- a/src/lib/netlist/plib/pconfig.h +++ b/src/lib/netlist/plib/pconfig.h @@ -8,6 +8,8 @@ #ifndef PCONFIG_H_ #define PCONFIG_H_ +#include + #ifndef PSTANDALONE #define PSTANDALONE (0) #endif @@ -25,8 +27,8 @@ typedef __int128_t INT128; #if !(PSTANDALONE) -#include "osdcore.h" -#include "eminline.h" +#include "osdcomm.h" +//#include "eminline.h" #ifndef assert #define assert(x) do {} while (0) @@ -80,7 +82,7 @@ typedef __int128_t INT128; #define PHAS_PMF_INTERNAL 1 #endif #else -#define USE_DELEGATE_TYPE PHAS_PMF_INTERNAL 0 +#define PHAS_PMF_INTERNAL 0 #endif #ifndef MEMBER_ABI @@ -88,9 +90,6 @@ typedef __int128_t INT128; #endif /* not supported in GCC prior to 4.4.x */ -/* ATTR_HOT and ATTR_COLD cause performance degration in 5.1 */ -//#define ATTR_HOT -//#define ATTR_COLD #define ATTR_HOT __attribute__((hot)) #define ATTR_COLD __attribute__((cold)) @@ -147,11 +146,7 @@ class pmfp public: // construct from any member function pointer class generic_class; - typedef void (*generic_function)(); - - #if (PSTANDALONE) - typedef std::size_t FPTR; - #endif + using generic_function = void (*)(); template pmfp(_MemberFunctionType mfp) @@ -179,19 +174,19 @@ private: generic_function convert_to_generic(generic_class * object) const { // apply the "this" delta to the object first - generic_class * o_p_delta = reinterpret_cast(reinterpret_cast(object) + m_this_delta); + generic_class * 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 if (!(m_function & 1)) return reinterpret_cast(m_function); // otherwise, it is the byte index into the vtable where the actual function lives - UINT8 *vtable_base = *reinterpret_cast(o_p_delta); + std::uint8_t *vtable_base = *reinterpret_cast(o_p_delta); return *reinterpret_cast(vtable_base + m_function - 1); } // actual state - FPTR m_function; // first item can be one of two things: + uintptr_t m_function; // first item can be one of two things: // if even, it's a pointer to the function // if odd, it's the byte offset into the vtable int m_this_delta; // delta to apply to the 'this' pointer diff --git a/src/lib/netlist/plib/pdynlib.h b/src/lib/netlist/plib/pdynlib.h index ef545315aaa..66a2d63b302 100644 --- a/src/lib/netlist/plib/pdynlib.h +++ b/src/lib/netlist/plib/pdynlib.h @@ -27,9 +27,9 @@ public: bool isLoaded() const; template - T *getsym(const pstring name) + T getsym(const pstring name) { - return reinterpret_cast(getsym_p(name)); + return reinterpret_cast(getsym_p(name)); } private: void *getsym_p(const pstring name); diff --git a/src/lib/netlist/plib/pstate.h b/src/lib/netlist/plib/pstate.h index 4c9f34208d1..c4c1475f1a0 100644 --- a/src/lib/netlist/plib/pstate.h +++ b/src/lib/netlist/plib/pstate.h @@ -71,7 +71,7 @@ class pstate_manager_t; class pstate_callback_t { public: - typedef pvector_t list_t; + using list_t = pvector_t; virtual ~pstate_callback_t() { }; @@ -83,7 +83,7 @@ protected: struct pstate_entry_t { - typedef pvector_t list_t; + using list_t = pvector_t; pstate_entry_t(const pstring &stname, const pstate_data_type_e dt, const void *owner, const int size, const int count, void *ptr, bool is_ptr) diff --git a/src/lib/netlist/plib/pstream.h b/src/lib/netlist/plib/pstream.h index 6cc4c6a30a7..fd749a09cce 100644 --- a/src/lib/netlist/plib/pstream.h +++ b/src/lib/netlist/plib/pstream.h @@ -25,7 +25,7 @@ class pstream P_PREVENT_COPYING(pstream) public: - typedef long unsigned pos_type; + using pos_type = std::size_t; static const pos_type SEEK_EOF = (pos_type) -1; diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h index c58592258d6..ce8de00b55a 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.h +++ b/src/lib/netlist/solver/nld_matrix_solver.h @@ -74,8 +74,8 @@ private: class matrix_solver_t : public device_t { public: - typedef pvector_t list_t; - typedef core_device_t::list_t dev_list_t; + using list_t = pvector_t; + using dev_list_t = core_device_t::list_t; enum eSortType { diff --git a/src/lib/netlist/solver/nld_ms_gcr.h b/src/lib/netlist/solver/nld_ms_gcr.h index 5d439496efa..be9346deb59 100644 --- a/src/lib/netlist/solver/nld_ms_gcr.h +++ b/src/lib/netlist/solver/nld_ms_gcr.h @@ -53,7 +53,7 @@ private: void csc_private(postream &strm); - typedef void extsolver(double * RESTRICT m_A, double * RESTRICT RHS); + using extsolver = void (*)(double * RESTRICT m_A, double * RESTRICT RHS); pstring static_compile_name() { @@ -69,7 +69,7 @@ private: mat_cr_t<_storage_N> mat; nl_double m_A[_storage_N * _storage_N]; - extsolver *m_proc; + extsolver m_proc; }; diff --git a/src/lib/netlist/solver/nld_solver.h b/src/lib/netlist/solver/nld_solver.h index 969b378e5f4..e199009a70a 100644 --- a/src/lib/netlist/solver/nld_solver.h +++ b/src/lib/netlist/solver/nld_solver.h @@ -59,8 +59,8 @@ public: virtual ~NETLIB_NAME(solver)(); - ATTR_COLD void post_start(); - ATTR_COLD void stop() override; + void post_start(); + void stop() override; inline nl_double gmin() { return m_gmin.Value(); }