mirror of
https://github.com/holub/mame
synced 2025-07-04 01:18:59 +03:00
netlist: Force invalidation of save states. [Couriersud]
Added netlist version information. This is used to enforce the invalidation of save states when the major/minor netlist version changes. This catches edge cases for which neither the size or names of saved items changes during releases.
This commit is contained in:
parent
01d4b2d02e
commit
018830967a
@ -7,6 +7,7 @@
|
|||||||
#include "plib/palloc.h"
|
#include "plib/palloc.h"
|
||||||
#include "plib/pmempool.h"
|
#include "plib/pmempool.h"
|
||||||
#include "plib/putil.h"
|
#include "plib/putil.h"
|
||||||
|
#include "plib/pfmtlog.h"
|
||||||
|
|
||||||
#include "devices/nlid_proxy.h"
|
#include "devices/nlid_proxy.h"
|
||||||
#include "devices/nlid_system.h"
|
#include "devices/nlid_system.h"
|
||||||
@ -202,6 +203,7 @@ namespace netlist
|
|||||||
, m_callbacks(std::move(callbacks)) // Order is important here
|
, m_callbacks(std::move(callbacks)) // Order is important here
|
||||||
, m_log(*m_callbacks)
|
, m_log(*m_callbacks)
|
||||||
, m_extended_validation(false)
|
, m_extended_validation(false)
|
||||||
|
, m_dummy_version(1)
|
||||||
{
|
{
|
||||||
pstring libpath = plib::util::environment("NL_BOOSTLIB", plib::util::buildpath({".", "nlboost.so"}));
|
pstring libpath = plib::util::environment("NL_BOOSTLIB", plib::util::buildpath({".", "nlboost.so"}));
|
||||||
m_lib = plib::make_unique<plib::dynlib>(libpath);
|
m_lib = plib::make_unique<plib::dynlib>(libpath);
|
||||||
@ -210,6 +212,11 @@ namespace netlist
|
|||||||
// create the run interface
|
// create the run interface
|
||||||
m_netlist = m_pool.make_unique<netlist_t>(*this);
|
m_netlist = m_pool.make_unique<netlist_t>(*this);
|
||||||
|
|
||||||
|
// Make sure save states are invalidated when a new version is deployed
|
||||||
|
|
||||||
|
m_state.save_item(this, m_dummy_version, pstring("V") + version());
|
||||||
|
|
||||||
|
// Initialize factory
|
||||||
devices::initialize_factory(m_setup->factory());
|
devices::initialize_factory(m_setup->factory());
|
||||||
NETLIST_NAME(base)(*m_setup);
|
NETLIST_NAME(base)(*m_setup);
|
||||||
}
|
}
|
||||||
@ -241,19 +248,19 @@ namespace netlist
|
|||||||
return std::numeric_limits<std::size_t>::max();
|
return std::numeric_limits<std::size_t>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void netlist_state_t::rebuild_lists()
|
void netlist_state_t::rebuild_lists()
|
||||||
{
|
{
|
||||||
for (auto & net : m_nets)
|
for (auto & net : m_nets)
|
||||||
net->rebuild_list();
|
net->rebuild_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void netlist_state_t::compile_defines(std::vector<std::pair<pstring, pstring>> &defs)
|
void netlist_state_t::compile_defines(std::vector<std::pair<pstring, pstring>> &defs)
|
||||||
{
|
{
|
||||||
#define ENTRY(x) if (pstring(#x) != PSTRINGIFY(x)) defs.emplace_back(std::pair<pstring, pstring>(#x, PSTRINGIFY(x)));
|
#define ENTRY(x) if (pstring(#x) != PSTRINGIFY(x)) defs.emplace_back(std::pair<pstring, pstring>(#x, PSTRINGIFY(x)));
|
||||||
ENTRY(PHAS_RDTSCP)
|
ENTRY(NL_VERSION_MAJOR)
|
||||||
|
ENTRY(NL_VERSION_MINOR)
|
||||||
|
ENTRY(NL_VERSION_PATCHLEVEL)
|
||||||
|
|
||||||
ENTRY(PUSE_ACCURATE_STATS)
|
ENTRY(PUSE_ACCURATE_STATS)
|
||||||
ENTRY(PHAS_INT128)
|
ENTRY(PHAS_INT128)
|
||||||
ENTRY(PUSE_ALIGNED_OPTIMIZATIONS)
|
ENTRY(PUSE_ALIGNED_OPTIMIZATIONS)
|
||||||
@ -300,6 +307,16 @@ namespace netlist
|
|||||||
#undef ENTRY
|
#undef ENTRY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pstring netlist_state_t::version()
|
||||||
|
{
|
||||||
|
return plib::pfmt("{1}.{2}")(NL_VERSION_MAJOR, NL_VERSION_MINOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
pstring netlist_state_t::version_patchlevel()
|
||||||
|
{
|
||||||
|
return plib::pfmt("{1}.{2}.{3}")(NL_VERSION_MAJOR, NL_VERSION_MINOR, NL_VERSION_PATCHLEVEL);
|
||||||
|
}
|
||||||
|
|
||||||
void netlist_t::reset()
|
void netlist_t::reset()
|
||||||
{
|
{
|
||||||
log().debug("Searching for mainclock\n");
|
log().debug("Searching for mainclock\n");
|
||||||
|
@ -1304,11 +1304,9 @@ namespace netlist
|
|||||||
using timed_queue = plib::timed_queue_linear<T, TS>;
|
using timed_queue = plib::timed_queue_linear<T, TS>;
|
||||||
|
|
||||||
// Use timed_queue_heap to use stdc++ heap functions instead of linear processing.
|
// Use timed_queue_heap to use stdc++ heap functions instead of linear processing.
|
||||||
/// This slows down processing by about 25% on a Kaby Lake.
|
// This slows down processing by about 25% on a Kaby Lake.
|
||||||
|
|
||||||
|
|
||||||
// template <class T, bool TS>
|
// template <class T, bool TS>
|
||||||
//using timed_queue = timed_queue_heap<T, TS>;
|
// using timed_queue = plib::timed_queue_heap<T, TS>;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// queue_t
|
// queue_t
|
||||||
@ -1521,6 +1519,8 @@ namespace netlist
|
|||||||
void rebuild_lists(); // must be called after post_load !
|
void rebuild_lists(); // must be called after post_load !
|
||||||
|
|
||||||
static void compile_defines(std::vector<std::pair<pstring, pstring>> &defs);
|
static void compile_defines(std::vector<std::pair<pstring, pstring>> &defs);
|
||||||
|
static pstring version();
|
||||||
|
static pstring version_patchlevel();
|
||||||
|
|
||||||
nets_collection_type & nets() noexcept { return m_nets; }
|
nets_collection_type & nets() noexcept { return m_nets; }
|
||||||
const nets_collection_type & nets() const noexcept { return m_nets; }
|
const nets_collection_type & nets() const noexcept { return m_nets; }
|
||||||
@ -1575,6 +1575,9 @@ namespace netlist
|
|||||||
// sole use is to manage lifetime of net objects
|
// sole use is to manage lifetime of net objects
|
||||||
devices_collection_type m_devices;
|
devices_collection_type m_devices;
|
||||||
bool m_extended_validation;
|
bool m_extended_validation;
|
||||||
|
|
||||||
|
// dummy version
|
||||||
|
int m_dummy_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace devices
|
namespace devices
|
||||||
@ -1705,7 +1708,6 @@ namespace netlist
|
|||||||
PALIGNAS_CACHELINE()
|
PALIGNAS_CACHELINE()
|
||||||
detail::queue_t m_queue;
|
detail::queue_t m_queue;
|
||||||
bool m_use_stats;
|
bool m_use_stats;
|
||||||
|
|
||||||
// performance
|
// performance
|
||||||
plib::pperftime_t<true> m_stat_mainloop;
|
plib::pperftime_t<true> m_stat_mainloop;
|
||||||
plib::pperfcount_t<true> m_perf_out_processed;
|
plib::pperfcount_t<true> m_perf_out_processed;
|
||||||
|
@ -10,6 +10,20 @@
|
|||||||
#include "plib/pconfig.h"
|
#include "plib/pconfig.h"
|
||||||
#include "plib/pexception.h"
|
#include "plib/pexception.h"
|
||||||
|
|
||||||
|
///
|
||||||
|
/// \brief Version - Major.
|
||||||
|
///
|
||||||
|
#define NL_VERSION_MAJOR 0
|
||||||
|
///
|
||||||
|
/// \brief Version - Minor.
|
||||||
|
///
|
||||||
|
#define NL_VERSION_MINOR 4
|
||||||
|
///
|
||||||
|
/// \brief Version - Patch level.
|
||||||
|
///
|
||||||
|
#define NL_VERSION_PATCHLEVEL 1
|
||||||
|
|
||||||
|
///
|
||||||
/// \addtogroup compiledefine
|
/// \addtogroup compiledefine
|
||||||
/// \{
|
/// \{
|
||||||
|
|
||||||
|
@ -461,8 +461,7 @@ namespace plib {
|
|||||||
if (*i == elem)
|
if (*i == elem)
|
||||||
{
|
{
|
||||||
m_end--;
|
m_end--;
|
||||||
for (;i < m_end; i++)
|
*i = *m_end;
|
||||||
*i = std::move(*(i+1));
|
|
||||||
std::make_heap(&m_list[0], m_end, compare());
|
std::make_heap(&m_list[0], m_end, compare());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,6 @@
|
|||||||
#include <ios>
|
#include <ios>
|
||||||
#include <iostream> // scanf
|
#include <iostream> // scanf
|
||||||
|
|
||||||
#define NLTOOL_VERSION 20190420
|
|
||||||
|
|
||||||
class tool_app_t : public plib::app
|
class tool_app_t : public plib::app
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -1008,12 +1006,12 @@ int tool_app_t::execute()
|
|||||||
if (opt_version())
|
if (opt_version())
|
||||||
{
|
{
|
||||||
pout(
|
pout(
|
||||||
"nltool (netlist) " PSTRINGIFY(NLTOOL_VERSION) "\n"
|
"nltool (netlist) {1}\n"
|
||||||
"Copyright (C) 2019 Couriersud\n"
|
"Copyright (C) 2019 Couriersud\n"
|
||||||
"License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.\n"
|
"License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.\n"
|
||||||
"This is free software: you are free to change and redistribute it.\n"
|
"This is free software: you are free to change and redistribute it.\n"
|
||||||
"There is NO WARRANTY, to the extent permitted by law.\n\n"
|
"There is NO WARRANTY, to the extent permitted by law.\n\n"
|
||||||
"Written by Couriersud.\n");
|
"Written by Couriersud.\n", netlist::netlist_state_t::version());
|
||||||
if (opt_verb())
|
if (opt_verb())
|
||||||
{
|
{
|
||||||
std::vector<std::pair<pstring, pstring>> defs;
|
std::vector<std::pair<pstring, pstring>> defs;
|
||||||
@ -1027,7 +1025,7 @@ int tool_app_t::execute()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_defines = opt_defines();
|
m_defines = opt_defines();
|
||||||
m_defines.emplace_back("NLTOOL_VERSION=" PSTRINGIFY(NLTOOL_VERSION));
|
m_defines.emplace_back("NLTOOL_VERSION=" + netlist::netlist_state_t::version());
|
||||||
if (opt_prepro())
|
if (opt_prepro())
|
||||||
m_defines.emplace_back("__PREPROCESSOR_DEBUG__=1");
|
m_defines.emplace_back("__PREPROCESSOR_DEBUG__=1");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user