From 672f9b092a0a93048e8db600a9dce86f29f465d3 Mon Sep 17 00:00:00 2001 From: couriersud Date: Sat, 23 Feb 2019 17:45:08 +0100 Subject: Move ptime struct into plib namespace and fix relative includes. (nw) --- scripts/src/netlist.lua | 6 +- scripts/src/tools.lua | 2 + src/devices/machine/netlist.h | 3 +- src/lib/netlist/analog/nlid_fourterm.h | 2 +- src/lib/netlist/analog/nlid_twoterm.h | 2 +- src/lib/netlist/build/makefile | 2 +- src/lib/netlist/devices/nld_log.cpp | 4 +- src/lib/netlist/devices/nlid_system.h | 2 +- src/lib/netlist/devices/nlid_truthtable.cpp | 4 +- src/lib/netlist/devices/nlid_truthtable.h | 2 +- src/lib/netlist/netlist_types.h | 114 ------------------- src/lib/netlist/nl_base.h | 4 +- src/lib/netlist/nl_factory.h | 2 +- src/lib/netlist/nl_lists.h | 2 +- src/lib/netlist/nl_setup.h | 2 +- src/lib/netlist/nl_time.h | 159 --------------------------- src/lib/netlist/nl_types.h | 140 +++++++++++++++++++++++ src/lib/netlist/plib/ptime.h | 136 +++++++++++++++++++++++ src/lib/netlist/prg/nlwav.cpp | 10 +- src/lib/netlist/solver/nld_matrix_solver.cpp | 2 +- src/lib/netlist/solver/nld_ms_direct.h | 4 +- src/lib/netlist/solver/nld_ms_gcr.h | 11 +- src/lib/netlist/solver/nld_ms_gmres.h | 8 +- src/lib/netlist/solver/nld_ms_sm.h | 2 +- src/lib/netlist/solver/nld_ms_w.h | 2 +- src/lib/netlist/solver/nld_solver.cpp | 2 +- src/lib/netlist/solver/nld_solver.h | 2 +- src/lib/netlist/tools/nl_convert.cpp | 4 +- src/lib/netlist/tools/nl_convert.h | 8 +- 29 files changed, 324 insertions(+), 319 deletions(-) delete mode 100644 src/lib/netlist/netlist_types.h delete mode 100644 src/lib/netlist/nl_time.h create mode 100644 src/lib/netlist/nl_types.h create mode 100644 src/lib/netlist/plib/ptime.h diff --git a/scripts/src/netlist.lua b/scripts/src/netlist.lua index 5e6d239373e..09575cacffc 100644 --- a/scripts/src/netlist.lua +++ b/scripts/src/netlist.lua @@ -32,6 +32,7 @@ project "netlist" includedirs { MAME_DIR .. "src/lib", + MAME_DIR .. "src/lib/netlist", } files { @@ -47,7 +48,7 @@ project "netlist" MAME_DIR .. "src/lib/netlist/nl_parser.h", MAME_DIR .. "src/lib/netlist/nl_setup.cpp", MAME_DIR .. "src/lib/netlist/nl_setup.h", - MAME_DIR .. "src/lib/netlist/nl_time.h", + MAME_DIR .. "src/lib/netlist/nl_types.h", MAME_DIR .. "src/lib/netlist/plib/pconfig.h", MAME_DIR .. "src/lib/netlist/plib/palloc.h", MAME_DIR .. "src/lib/netlist/plib/pchrono.cpp", @@ -74,10 +75,9 @@ project "netlist" MAME_DIR .. "src/lib/netlist/plib/pstate.h", MAME_DIR .. "src/lib/netlist/plib/pstring.cpp", MAME_DIR .. "src/lib/netlist/plib/pstring.h", - MAME_DIR .. "src/lib/netlist/plib/pstring.cpp", - MAME_DIR .. "src/lib/netlist/plib/pstring.h", MAME_DIR .. "src/lib/netlist/plib/pstream.cpp", MAME_DIR .. "src/lib/netlist/plib/pstream.h", + MAME_DIR .. "src/lib/netlist/plib/ptime.h", MAME_DIR .. "src/lib/netlist/plib/ptypes.h", MAME_DIR .. "src/lib/netlist/plib/putil.cpp", MAME_DIR .. "src/lib/netlist/plib/putil.h", diff --git a/scripts/src/tools.lua b/scripts/src/tools.lua index f991c16bbea..564653f5a4a 100644 --- a/scripts/src/tools.lua +++ b/scripts/src/tools.lua @@ -499,6 +499,7 @@ links { includedirs { MAME_DIR .. "src/lib", + MAME_DIR .. "src/lib/netlist", } files { @@ -543,6 +544,7 @@ links { includedirs { MAME_DIR .. "src/lib", + MAME_DIR .. "src/lib/netlist", } files { diff --git a/src/devices/machine/netlist.h b/src/devices/machine/netlist.h index 182c77ece2c..58a8c065b14 100644 --- a/src/devices/machine/netlist.h +++ b/src/devices/machine/netlist.h @@ -13,8 +13,7 @@ #include -#include "netlist/nl_time.h" -#include "netlist/netlist_types.h" +#include "../../lib/netlist/nl_types.h" class nld_sound_out; class nld_sound_in; diff --git a/src/lib/netlist/analog/nlid_fourterm.h b/src/lib/netlist/analog/nlid_fourterm.h index 2d0d1ec174f..9eb2fbc5f36 100644 --- a/src/lib/netlist/analog/nlid_fourterm.h +++ b/src/lib/netlist/analog/nlid_fourterm.h @@ -9,7 +9,7 @@ #define NLID_FOURTERM_H_ #include "../nl_base.h" -#include "../plib/putil.h" +#include "plib/putil.h" namespace netlist { namespace analog { diff --git a/src/lib/netlist/analog/nlid_twoterm.h b/src/lib/netlist/analog/nlid_twoterm.h index 546e8193734..131504d86e4 100644 --- a/src/lib/netlist/analog/nlid_twoterm.h +++ b/src/lib/netlist/analog/nlid_twoterm.h @@ -33,7 +33,7 @@ #ifndef NLID_TWOTERM_H_ #define NLID_TWOTERM_H_ -#include "../plib/pfunction.h" +#include "plib/pfunction.h" #include "netlist/nl_base.h" #include "netlist/nl_setup.h" diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile index d4296c1b007..f628e9eaed6 100644 --- a/src/lib/netlist/build/makefile +++ b/src/lib/netlist/build/makefile @@ -49,7 +49,7 @@ endif # LTO = -flto=4 -fuse-linker-plugin -flto-partition=balanced -Wodr -CFLAGS = $(LTO) -g -O3 -std=c++11 -I../.. $(CEXTRAFLAGS) +CFLAGS = $(LTO) -g -O3 -std=c++11 -I$(CURDIR)/.. -I$(CURDIR)/../.. $(CEXTRAFLAGS) LDFLAGS = $(LTO) -g -O3 -std=c++11 $(LDEXTRAFLAGS) LIBS = -lpthread -ldl diff --git a/src/lib/netlist/devices/nld_log.cpp b/src/lib/netlist/devices/nld_log.cpp index c99fcb5a9bc..8cbcf0c81ca 100644 --- a/src/lib/netlist/devices/nld_log.cpp +++ b/src/lib/netlist/devices/nld_log.cpp @@ -6,8 +6,8 @@ */ #include "../nl_base.h" -#include "../plib/pfmtlog.h" -#include "../plib/pstream.h" +#include "plib/pfmtlog.h" +#include "plib/pstream.h" #include "nld_log.h" //#include "sound/wavwrite.h" diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index 10cbc498a6b..e744ee11dc6 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -14,7 +14,7 @@ #include "../analog/nlid_twoterm.h" #include "../nl_base.h" #include "../nl_setup.h" -#include "../plib/putil.h" +#include "plib/putil.h" namespace netlist { diff --git a/src/lib/netlist/devices/nlid_truthtable.cpp b/src/lib/netlist/devices/nlid_truthtable.cpp index 78fd076b560..e1a6f5e9046 100644 --- a/src/lib/netlist/devices/nlid_truthtable.cpp +++ b/src/lib/netlist/devices/nlid_truthtable.cpp @@ -7,8 +7,8 @@ #include "nlid_truthtable.h" #include "../nl_setup.h" -#include "../plib/palloc.h" -#include "../plib/plists.h" +#include "plib/palloc.h" +#include "plib/plists.h" #include diff --git a/src/lib/netlist/devices/nlid_truthtable.h b/src/lib/netlist/devices/nlid_truthtable.h index a4b9e1e238e..c995b1c766e 100644 --- a/src/lib/netlist/devices/nlid_truthtable.h +++ b/src/lib/netlist/devices/nlid_truthtable.h @@ -12,7 +12,7 @@ #include "../nl_base.h" #include "../nl_setup.h" -#include "../plib/putil.h" +#include "plib/putil.h" #define NETLIB_TRUTHTABLE(cname, nIN, nOUT) \ class NETLIB_NAME(cname) : public nld_truthtable_t \ diff --git a/src/lib/netlist/netlist_types.h b/src/lib/netlist/netlist_types.h deleted file mode 100644 index b2a507fe0fe..00000000000 --- a/src/lib/netlist/netlist_types.h +++ /dev/null @@ -1,114 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Couriersud -/*! - * - * \file netlist_types.h - * - */ - -#ifndef NETLIST_TYPES_H_ -#define NETLIST_TYPES_H_ - -#include -#include - -#include "nl_config.h" -#include "plib/pchrono.h" -#include "plib/pfmtlog.h" -#include "plib/pmempool.h" -#include "plib/pstring.h" - - -namespace netlist -{ - /*! @brief netlist_sig_t is the type used for logic signals. - * - * This may be any of bool, uint8_t, uint16_t, uin32_t and uint64_t. - * The choice has little to no impact on performance. - */ - using netlist_sig_t = std::uint32_t; - - /* FIXME: belongs into nl_base.h to nlstate */ - /** - * @brief Interface definition for netlist callbacks into calling code - * - * A class inheriting from netlist_callbacks_t has to be passed to the netlist_t - * constructor. Netlist does processing during construction and thus needs - * the object passed completely constructed. - * - */ - class callbacks_t - { - public: - - callbacks_t() = default; - /* what is done before this is passed as a unique_ptr to netlist - * we should not limit. - */ - virtual ~callbacks_t() = default; - COPYASSIGNMOVE(callbacks_t, default) - - /* logging callback */ - virtual void vlog(const plib::plog_level &l, const pstring &ls) const = 0; - - }; - - using log_type = plib::plog_base; - - - //============================================================ - // Performance tracking - //============================================================ - - template - using nperftime_t = plib::chrono::timer; - - template - using nperfcount_t = plib::chrono::counter; - - //============================================================ - // Types needed by various includes - //============================================================ - - /*! The memory pool for netlist objects - * - * \note This is not the right location yet. - * - */ - -#if (USE_MEMPOOL) - using nlmempool = plib::mempool; -#else - using nlmempool = plib::mempool_default; -#endif - - /*! Owned pointer type for pooled allocations. - * - */ - 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 - -#endif /* NETLIST_TYPES_H_ */ diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index dccfb32f896..adbda1d679d 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -24,10 +24,10 @@ #include "plib/pstate.h" #include "plib/pstream.h" -#include "netlist_types.h" +#include "nl_types.h" #include "nl_errstr.h" #include "nl_lists.h" -#include "nl_time.h" +#include "plib/ptime.h" //============================================================ // MACROS / New Syntax diff --git a/src/lib/netlist/nl_factory.h b/src/lib/netlist/nl_factory.h index cd7e74944eb..abf41ef9f93 100644 --- a/src/lib/netlist/nl_factory.h +++ b/src/lib/netlist/nl_factory.h @@ -11,7 +11,7 @@ #include -#include "netlist_types.h" +#include "nl_types.h" #include "plib/palloc.h" #include "plib/ptypes.h" diff --git a/src/lib/netlist/nl_lists.h b/src/lib/netlist/nl_lists.h index 5443cd86c86..32e31998b7a 100644 --- a/src/lib/netlist/nl_lists.h +++ b/src/lib/netlist/nl_lists.h @@ -10,7 +10,6 @@ #ifndef NLLISTS_H_ #define NLLISTS_H_ -#include "netlist_types.h" #include "nl_config.h" #include "plib/pchrono.h" #include "plib/plists.h" @@ -21,6 +20,7 @@ #include #include #include +#include "nl_types.h" // ---------------------------------------------------------------------------------------- // timed queue diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h index 50536d9da3b..dd4f9b381ac 100644 --- a/src/lib/netlist/nl_setup.h +++ b/src/lib/netlist/nl_setup.h @@ -18,9 +18,9 @@ #include "plib/pstring.h" #include "plib/putil.h" -#include "netlist_types.h" #include "nl_config.h" #include "nl_factory.h" +#include "nl_types.h" //============================================================ // MACROS / inline netlist definitions diff --git a/src/lib/netlist/nl_time.h b/src/lib/netlist/nl_time.h deleted file mode 100644 index 1db22241d64..00000000000 --- a/src/lib/netlist/nl_time.h +++ /dev/null @@ -1,159 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Couriersud -/* - * nltime.h - */ - -#ifndef NLTIME_H_ -#define NLTIME_H_ - -#include "nl_config.h" -#include "plib/pstate.h" -#include "plib/ptypes.h" - -#include - -// ---------------------------------------------------------------------------------------- -// netlist_time -// ---------------------------------------------------------------------------------------- - -namespace netlist -{ - - template - struct ptime final - { - public: - - using internal_type = TYPE; - using mult_type = TYPE; - - constexpr ptime() noexcept : m_time(0) {} - - ~ptime() noexcept = default; - - constexpr ptime(const ptime &rhs) noexcept = default; - constexpr ptime(ptime &&rhs) noexcept = default; - constexpr explicit ptime(const internal_type &time) noexcept : m_time(time) {} - constexpr explicit ptime(internal_type &&time) noexcept : m_time(time) {} - C14CONSTEXPR ptime &operator=(const ptime &rhs) noexcept = default; - C14CONSTEXPR ptime &operator=(ptime &&rhs) noexcept = default; - - constexpr explicit ptime(const double t) = delete; - //: m_time((internal_type) ( t * (double) resolution)) { } - constexpr explicit ptime(const internal_type nom, const internal_type den) noexcept - : m_time(nom * (RES / den)) { } - - C14CONSTEXPR ptime &operator+=(const ptime rhs) noexcept { m_time += rhs.m_time; return *this; } - C14CONSTEXPR ptime &operator-=(const ptime rhs) noexcept { m_time -= rhs.m_time; return *this; } - C14CONSTEXPR ptime &operator*=(const mult_type factor) noexcept { m_time *= static_cast(factor); return *this; } - - friend C14CONSTEXPR ptime operator-(ptime lhs, const ptime rhs) noexcept - { - return lhs -= rhs; - } - - friend C14CONSTEXPR ptime operator+(ptime lhs, const ptime rhs) noexcept - { - return lhs += rhs; - } - - friend C14CONSTEXPR ptime operator*(ptime lhs, const mult_type &factor) noexcept - { - return lhs *= factor; - } - - friend constexpr mult_type operator/(const ptime lhs, const ptime rhs) noexcept - { - return static_cast(lhs.m_time / rhs.m_time); - } - - friend constexpr bool operator<(const ptime lhs, const ptime rhs) noexcept - { - return (lhs.m_time < rhs.m_time); - } - - friend constexpr bool operator>(const ptime lhs, const ptime rhs) noexcept - { - return (rhs < lhs); - } - - friend constexpr bool operator<=(const ptime lhs, const ptime rhs) noexcept - { - return !(lhs > rhs); - } - - friend constexpr bool operator>=(const ptime lhs, const ptime rhs) noexcept - { - return !(lhs < rhs); - } - - friend constexpr bool operator==(const ptime lhs, const ptime rhs) noexcept - { - return lhs.m_time == rhs.m_time; - } - - friend constexpr bool operator!=(const ptime lhs, const ptime rhs) noexcept - { - return !(lhs == rhs); - } - - constexpr internal_type as_raw() const noexcept { return m_time; } - constexpr double as_double() const noexcept - { - return static_cast(m_time) * inv_res; - } - - // for save states .... - C14CONSTEXPR internal_type *get_internaltype_ptr() noexcept { return &m_time; } - - static constexpr ptime from_nsec(const internal_type ns) noexcept { return ptime(ns, UINT64_C(1000000000)); } - static constexpr ptime from_usec(const internal_type us) noexcept { return ptime(us, UINT64_C( 1000000)); } - static constexpr ptime from_msec(const internal_type ms) noexcept { return ptime(ms, UINT64_C( 1000)); } - static constexpr ptime from_sec(const internal_type s) noexcept { return ptime(s, UINT64_C( 1)); } - static constexpr ptime from_hz(const internal_type hz) noexcept { return ptime(1 , hz); } - static constexpr ptime from_raw(const internal_type raw) noexcept { return ptime(raw); } - static constexpr ptime from_double(const double t) noexcept { return ptime(static_cast( t * static_cast(RES)), RES); } - - static constexpr ptime zero() noexcept { return ptime(0, RES); } - static constexpr ptime quantum() noexcept { return ptime(1, RES); } - static constexpr ptime never() noexcept { return ptime(plib::numeric_limits::max(), RES); } - static constexpr internal_type resolution() noexcept { return RES; } - - constexpr internal_type in_nsec() const noexcept { return m_time / (RES / UINT64_C(1000000000)); } - constexpr internal_type in_usec() const noexcept { return m_time / (RES / UINT64_C( 1000000)); } - constexpr internal_type in_msec() const noexcept { return m_time / (RES / UINT64_C( 1000)); } - constexpr internal_type in_sec() const noexcept { return m_time / (RES / UINT64_C( 1)); } - - private: - static constexpr const double inv_res = 1.0 / static_cast(RES); - internal_type m_time; - }; - -#if (PHAS_INT128) - using netlist_time = ptime; -#else - using netlist_time = ptime; - static_assert(noexcept(netlist_time::from_nsec(1)) == true, "Not evaluated as constexpr"); -#endif - - //============================================================ - // MACROS - //============================================================ - - template inline constexpr netlist_time NLTIME_FROM_NS(T &&t) noexcept { return netlist_time::from_nsec(t); } - template inline constexpr netlist_time NLTIME_FROM_US(T &&t) noexcept { return netlist_time::from_usec(t); } - template inline constexpr netlist_time NLTIME_FROM_MS(T &&t) noexcept { return netlist_time::from_msec(t); } - -} // namespace netlist - -namespace plib { - - template<> - inline void state_manager_t::save_item(const void *owner, netlist::netlist_time &nlt, const pstring &stname) - { - save_state_ptr(owner, stname, datatype_t(sizeof(netlist::netlist_time::internal_type), true, false), 1, nlt.get_internaltype_ptr()); - } -} // namespace plib - -#endif /* NLTIME_H_ */ diff --git a/src/lib/netlist/nl_types.h b/src/lib/netlist/nl_types.h new file mode 100644 index 00000000000..8b229e85bf5 --- /dev/null +++ b/src/lib/netlist/nl_types.h @@ -0,0 +1,140 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/*! + * + * \file nl_types.h + * + */ + +#ifndef NL_TYPES_H_ +#define NL_TYPES_H_ + +#include "nl_config.h" +#include "plib/ptime.h" +#include "plib/pchrono.h" +#include "plib/pfmtlog.h" +#include "plib/pmempool.h" +#include "plib/pstring.h" +#include "plib/pstate.h" + +#include +#include + +namespace netlist +{ + /*! @brief netlist_sig_t is the type used for logic signals. + * + * This may be any of bool, uint8_t, uint16_t, uin32_t and uint64_t. + * The choice has little to no impact on performance. + */ + using netlist_sig_t = std::uint32_t; + + /* FIXME: belongs into nl_base.h to nlstate */ + /** + * @brief Interface definition for netlist callbacks into calling code + * + * A class inheriting from netlist_callbacks_t has to be passed to the netlist_t + * constructor. Netlist does processing during construction and thus needs + * the object passed completely constructed. + * + */ + class callbacks_t + { + public: + + callbacks_t() = default; + /* what is done before this is passed as a unique_ptr to netlist + * we should not limit. + */ + virtual ~callbacks_t() = default; + COPYASSIGNMOVE(callbacks_t, default) + + /* logging callback */ + virtual void vlog(const plib::plog_level &l, const pstring &ls) const = 0; + + }; + + using log_type = plib::plog_base; + + + //============================================================ + // Performance tracking + //============================================================ + + template + using nperftime_t = plib::chrono::timer; + + template + using nperfcount_t = plib::chrono::counter; + + //============================================================ + // Types needed by various includes + //============================================================ + + /*! The memory pool for netlist objects + * + * \note This is not the right location yet. + * + */ + +#if (USE_MEMPOOL) + using nlmempool = plib::mempool; +#else + using nlmempool = plib::mempool_default; +#endif + + /*! Owned pointer type for pooled allocations. + * + */ + 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 + +#if (PHAS_INT128) + using netlist_time = ptime; +#else + using netlist_time = plib::ptime; + static_assert(noexcept(netlist_time::from_nsec(1)) == true, "Not evaluated as constexpr"); +#endif + + //============================================================ + // MACROS + //============================================================ + + template inline constexpr netlist_time NLTIME_FROM_NS(T &&t) noexcept { return netlist_time::from_nsec(t); } + template inline constexpr netlist_time NLTIME_FROM_US(T &&t) noexcept { return netlist_time::from_usec(t); } + template inline constexpr netlist_time NLTIME_FROM_MS(T &&t) noexcept { return netlist_time::from_msec(t); } + +} // namespace netlist + +namespace plib { + + template<> + inline void state_manager_t::save_item(const void *owner, netlist::netlist_time &nlt, const pstring &stname) + { + save_state_ptr(owner, stname, datatype_t(sizeof(netlist::netlist_time::internal_type), true, false), 1, nlt.get_internaltype_ptr()); + } +} // namespace plib + +#endif /* NL_TYPES_H_ */ diff --git a/src/lib/netlist/plib/ptime.h b/src/lib/netlist/plib/ptime.h new file mode 100644 index 00000000000..4767a197342 --- /dev/null +++ b/src/lib/netlist/plib/ptime.h @@ -0,0 +1,136 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * ptime.h + */ + +#ifndef PTIME_H_ +#define PTIME_H_ + +#include "pconfig.h" +#include "ptypes.h" + +#include + +// ---------------------------------------------------------------------------------------- +// netlist_time +// ---------------------------------------------------------------------------------------- + +namespace plib +{ + + template + struct ptime final + { + public: + + using internal_type = TYPE; + using mult_type = TYPE; + + constexpr ptime() noexcept : m_time(0) {} + + ~ptime() noexcept = default; + + constexpr ptime(const ptime &rhs) noexcept = default; + constexpr ptime(ptime &&rhs) noexcept = default; + constexpr explicit ptime(const internal_type &time) noexcept : m_time(time) {} + constexpr explicit ptime(internal_type &&time) noexcept : m_time(time) {} + C14CONSTEXPR ptime &operator=(const ptime &rhs) noexcept = default; + C14CONSTEXPR ptime &operator=(ptime &&rhs) noexcept = default; + + constexpr explicit ptime(const double t) = delete; + //: m_time((internal_type) ( t * (double) resolution)) { } + constexpr explicit ptime(const internal_type nom, const internal_type den) noexcept + : m_time(nom * (RES / den)) { } + + C14CONSTEXPR ptime &operator+=(const ptime rhs) noexcept { m_time += rhs.m_time; return *this; } + C14CONSTEXPR ptime &operator-=(const ptime rhs) noexcept { m_time -= rhs.m_time; return *this; } + C14CONSTEXPR ptime &operator*=(const mult_type factor) noexcept { m_time *= static_cast(factor); return *this; } + + friend C14CONSTEXPR ptime operator-(ptime lhs, const ptime rhs) noexcept + { + return lhs -= rhs; + } + + friend C14CONSTEXPR ptime operator+(ptime lhs, const ptime rhs) noexcept + { + return lhs += rhs; + } + + friend C14CONSTEXPR ptime operator*(ptime lhs, const mult_type &factor) noexcept + { + return lhs *= factor; + } + + friend constexpr mult_type operator/(const ptime lhs, const ptime rhs) noexcept + { + return static_cast(lhs.m_time / rhs.m_time); + } + + friend constexpr bool operator<(const ptime lhs, const ptime rhs) noexcept + { + return (lhs.m_time < rhs.m_time); + } + + friend constexpr bool operator>(const ptime lhs, const ptime rhs) noexcept + { + return (rhs < lhs); + } + + friend constexpr bool operator<=(const ptime lhs, const ptime rhs) noexcept + { + return !(lhs > rhs); + } + + friend constexpr bool operator>=(const ptime lhs, const ptime rhs) noexcept + { + return !(lhs < rhs); + } + + friend constexpr bool operator==(const ptime lhs, const ptime rhs) noexcept + { + return lhs.m_time == rhs.m_time; + } + + friend constexpr bool operator!=(const ptime lhs, const ptime rhs) noexcept + { + return !(lhs == rhs); + } + + constexpr internal_type as_raw() const noexcept { return m_time; } + constexpr double as_double() const noexcept + { + return static_cast(m_time) * inv_res; + } + + // for save states .... + C14CONSTEXPR internal_type *get_internaltype_ptr() noexcept { return &m_time; } + + static constexpr ptime from_nsec(const internal_type ns) noexcept { return ptime(ns, UINT64_C(1000000000)); } + static constexpr ptime from_usec(const internal_type us) noexcept { return ptime(us, UINT64_C( 1000000)); } + static constexpr ptime from_msec(const internal_type ms) noexcept { return ptime(ms, UINT64_C( 1000)); } + static constexpr ptime from_sec(const internal_type s) noexcept { return ptime(s, UINT64_C( 1)); } + static constexpr ptime from_hz(const internal_type hz) noexcept { return ptime(1 , hz); } + static constexpr ptime from_raw(const internal_type raw) noexcept { return ptime(raw); } + static constexpr ptime from_double(const double t) noexcept { return ptime(static_cast( t * static_cast(RES)), RES); } + + static constexpr ptime zero() noexcept { return ptime(0, RES); } + static constexpr ptime quantum() noexcept { return ptime(1, RES); } + static constexpr ptime never() noexcept { return ptime(plib::numeric_limits::max(), RES); } + static constexpr internal_type resolution() noexcept { return RES; } + + constexpr internal_type in_nsec() const noexcept { return m_time / (RES / UINT64_C(1000000000)); } + constexpr internal_type in_usec() const noexcept { return m_time / (RES / UINT64_C( 1000000)); } + constexpr internal_type in_msec() const noexcept { return m_time / (RES / UINT64_C( 1000)); } + constexpr internal_type in_sec() const noexcept { return m_time / (RES / UINT64_C( 1)); } + + private: + static constexpr const double inv_res = 1.0 / static_cast(RES); + internal_type m_time; + }; + + +} // namespace plib + + +#endif /* PTIME_H_ */ diff --git a/src/lib/netlist/prg/nlwav.cpp b/src/lib/netlist/prg/nlwav.cpp index bd30e93d7e6..384d11f5781 100644 --- a/src/lib/netlist/prg/nlwav.cpp +++ b/src/lib/netlist/prg/nlwav.cpp @@ -1,11 +1,11 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -#include "../plib/pstring.h" +#include "plib/pstring.h" #include "../nl_setup.h" -#include "../plib/plists.h" -#include "../plib/pmain.h" -#include "../plib/ppmf.h" -#include "../plib/pstream.h" +#include "plib/plists.h" +#include "plib/pmain.h" +#include "plib/ppmf.h" +#include "plib/pstream.h" #include diff --git a/src/lib/netlist/solver/nld_matrix_solver.cpp b/src/lib/netlist/solver/nld_matrix_solver.cpp index 6494ca6eaee..68cad1422ea 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.cpp +++ b/src/lib/netlist/solver/nld_matrix_solver.cpp @@ -6,7 +6,7 @@ */ #include "nld_matrix_solver.h" -#include "../plib/putil.h" +#include "plib/putil.h" #include // <<= needed by windows build diff --git a/src/lib/netlist/solver/nld_ms_direct.h b/src/lib/netlist/solver/nld_ms_direct.h index 13f187f41b5..c0995d99e54 100644 --- a/src/lib/netlist/solver/nld_ms_direct.h +++ b/src/lib/netlist/solver/nld_ms_direct.h @@ -10,8 +10,8 @@ #include #include -#include -#include +#include "plib/mat_cr.h" +#include "plib/vector_ops.h" #include "nld_matrix_solver.h" #include "nld_solver.h" diff --git a/src/lib/netlist/solver/nld_ms_gcr.h b/src/lib/netlist/solver/nld_ms_gcr.h index d2caa944434..0a9f720f104 100644 --- a/src/lib/netlist/solver/nld_ms_gcr.h +++ b/src/lib/netlist/solver/nld_ms_gcr.h @@ -10,15 +10,16 @@ #ifndef NLD_MS_GCR_H_ #define NLD_MS_GCR_H_ -#include -#include +#include "plib/mat_cr.h" -#include "../plib/pdynlib.h" -#include "../plib/pstream.h" -#include "../plib/vector_ops.h" +#include "plib/pdynlib.h" +#include "plib/pstream.h" +#include "plib/vector_ops.h" #include "nld_ms_direct.h" #include "nld_solver.h" +#include + namespace netlist { namespace devices diff --git a/src/lib/netlist/solver/nld_ms_gmres.h b/src/lib/netlist/solver/nld_ms_gmres.h index e8963578452..bee5c25e3d5 100644 --- a/src/lib/netlist/solver/nld_ms_gmres.h +++ b/src/lib/netlist/solver/nld_ms_gmres.h @@ -8,10 +8,10 @@ #ifndef NLD_MS_GMRES_H_ #define NLD_MS_GMRES_H_ -#include "../plib/gmres.h" -#include "../plib/mat_cr.h" -#include "../plib/parray.h" -#include "../plib/vector_ops.h" +#include "plib/gmres.h" +#include "plib/mat_cr.h" +#include "plib/parray.h" +#include "plib/vector_ops.h" #include "nld_ms_direct.h" #include "nld_solver.h" diff --git a/src/lib/netlist/solver/nld_ms_sm.h b/src/lib/netlist/solver/nld_ms_sm.h index c473b6131e7..6c0f610e3f2 100644 --- a/src/lib/netlist/solver/nld_ms_sm.h +++ b/src/lib/netlist/solver/nld_ms_sm.h @@ -35,7 +35,7 @@ #include -#include "../plib/vector_ops.h" +#include "plib/vector_ops.h" #include "nld_matrix_solver.h" #include "nld_solver.h" diff --git a/src/lib/netlist/solver/nld_ms_w.h b/src/lib/netlist/solver/nld_ms_w.h index e5935462f03..584d50fdb15 100644 --- a/src/lib/netlist/solver/nld_ms_w.h +++ b/src/lib/netlist/solver/nld_ms_w.h @@ -42,7 +42,7 @@ #include -#include "../plib/vector_ops.h" +#include "plib/vector_ops.h" #include "nld_matrix_solver.h" #include "nld_solver.h" diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp index be008a21706..ab75b7d7dc4 100644 --- a/src/lib/netlist/solver/nld_solver.cpp +++ b/src/lib/netlist/solver/nld_solver.cpp @@ -33,7 +33,7 @@ #include "../nl_lists.h" -#include "../plib/pomp.h" +#include "plib/pomp.h" #include "../nl_factory.h" diff --git a/src/lib/netlist/solver/nld_solver.h b/src/lib/netlist/solver/nld_solver.h index 646271e0ebd..87e02d215ec 100644 --- a/src/lib/netlist/solver/nld_solver.h +++ b/src/lib/netlist/solver/nld_solver.h @@ -9,7 +9,7 @@ #define NLD_SOLVER_H_ #include "../nl_base.h" -#include "../plib/pstream.h" +#include "plib/pstream.h" #include "nld_matrix_solver.h" #include diff --git a/src/lib/netlist/tools/nl_convert.cpp b/src/lib/netlist/tools/nl_convert.cpp index 16a3cfd6960..a9e17d56120 100644 --- a/src/lib/netlist/tools/nl_convert.cpp +++ b/src/lib/netlist/tools/nl_convert.cpp @@ -5,8 +5,8 @@ * */ -#include "../plib/palloc.h" -#include "../plib/putil.h" +#include "plib/palloc.h" +#include "plib/putil.h" #include "nl_convert.h" #include #include diff --git a/src/lib/netlist/tools/nl_convert.h b/src/lib/netlist/tools/nl_convert.h index b031ef72618..367546092be 100644 --- a/src/lib/netlist/tools/nl_convert.h +++ b/src/lib/netlist/tools/nl_convert.h @@ -10,10 +10,10 @@ #ifndef NL_CONVERT_H_ #define NL_CONVERT_H_ -#include "../plib/plists.h" -#include "../plib/pparser.h" -#include "../plib/pstring.h" -#include "../plib/ptypes.h" +#include "plib/plists.h" +#include "plib/pparser.h" +#include "plib/pstring.h" +#include "plib/ptypes.h" #include /*------------------------------------------------- -- cgit v1.2.3