mirror of
https://github.com/holub/mame
synced 2025-04-22 16:31:49 +03:00
Cleanup of includes. (nw)
This commit is contained in:
parent
29414640d6
commit
5c88873a87
@ -59,6 +59,7 @@ project "netlist"
|
||||
MAME_DIR .. "src/lib/netlist/plib/poptions.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pparser.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pparser.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/ppmf.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pstate.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pstate.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pstring.cpp",
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "analog/nld_bjt.h"
|
||||
#include "nl_setup.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace netlist
|
||||
{
|
||||
namespace analog
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "nld_fourterm.h"
|
||||
#include "nl_setup.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace netlist
|
||||
{
|
||||
namespace analog
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "nld_opamps.h"
|
||||
#include "nl_errstr.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace netlist
|
||||
{
|
||||
namespace analog
|
||||
|
@ -5,12 +5,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "solver/nld_solver.h"
|
||||
|
||||
#include "nld_twoterm.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace netlist
|
||||
{
|
||||
namespace analog
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "nlid_system.h"
|
||||
#include "analog/nld_twoterm.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace netlist
|
||||
{
|
||||
namespace devices
|
||||
|
@ -5,7 +5,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include "nl_base.h"
|
||||
#include "plib/pstream.h"
|
||||
#include "plib/pfmtlog.h"
|
||||
|
@ -121,7 +121,7 @@ uint_least64_t truthtable_desc_t::get_ignored_extended(uint_least64_t state)
|
||||
// desc
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
void truthtable_desc_t::help(unsigned cur, plib::pstring_vector_t list,
|
||||
void truthtable_desc_t::help(unsigned cur, std::vector<pstring> list,
|
||||
uint_least64_t state, uint_least64_t val, std::vector<uint_least8_t> &timing_index)
|
||||
{
|
||||
pstring elem = list[cur].trim();
|
||||
@ -166,7 +166,7 @@ void truthtable_desc_t::help(unsigned cur, plib::pstring_vector_t list,
|
||||
}
|
||||
}
|
||||
|
||||
void truthtable_desc_t::setup(const plib::pstring_vector_t &truthtable, uint_least64_t disabled_ignore)
|
||||
void truthtable_desc_t::setup(const std::vector<pstring> &truthtable, uint_least64_t disabled_ignore)
|
||||
{
|
||||
unsigned line = 0;
|
||||
|
||||
|
@ -10,12 +10,10 @@
|
||||
#ifndef NLD_TRUTHTABLE_H_
|
||||
#define NLD_TRUTHTABLE_H_
|
||||
|
||||
#include <new>
|
||||
#include <cstdint>
|
||||
|
||||
#include "nl_setup.h"
|
||||
#include "nl_factory.h"
|
||||
#include "plib/plists.h"
|
||||
#include "plib/putil.h"
|
||||
|
||||
#define NETLIB_TRUTHTABLE(cname, nIN, nOUT) \
|
||||
class NETLIB_NAME(cname) : public nld_truthtable_t<nIN, nOUT> \
|
||||
@ -112,10 +110,10 @@ namespace netlist
|
||||
{
|
||||
}
|
||||
|
||||
void setup(const plib::pstring_vector_t &desc, uint_least64_t disabled_ignore);
|
||||
void setup(const std::vector<pstring> &desc, uint_least64_t disabled_ignore);
|
||||
|
||||
private:
|
||||
void help(unsigned cur, plib::pstring_vector_t list,
|
||||
void help(unsigned cur, std::vector<pstring> list,
|
||||
uint_least64_t state, uint_least64_t val, std::vector<uint_least8_t> &timing_index);
|
||||
static unsigned count_bits(uint_least64_t v);
|
||||
static uint_least64_t set_bits(uint_least64_t v, uint_least64_t b);
|
||||
@ -176,7 +174,7 @@ namespace netlist
|
||||
|
||||
template <class C>
|
||||
nld_truthtable_t(C &owner, const pstring &name, const logic_family_desc_t *fam,
|
||||
truthtable_t *ttp, const plib::pstring_vector_t &desc)
|
||||
truthtable_t *ttp, const std::vector<pstring> &desc)
|
||||
: device_t(owner, name)
|
||||
, m_fam(*this, fam)
|
||||
, m_ign(*this, "m_ign", 0)
|
||||
@ -363,7 +361,7 @@ namespace netlist
|
||||
state_var_u32 m_ign;
|
||||
state_var_s32 m_active;
|
||||
truthtable_t * m_ttp;
|
||||
plib::pstring_vector_t m_desc;
|
||||
std::vector<pstring> m_desc;
|
||||
};
|
||||
|
||||
class netlist_base_factory_truthtable_t : public factory::element_t
|
||||
@ -375,7 +373,7 @@ namespace netlist
|
||||
|
||||
virtual ~netlist_base_factory_truthtable_t();
|
||||
|
||||
plib::pstring_vector_t m_desc;
|
||||
std::vector<pstring> m_desc;
|
||||
const logic_family_desc_t *m_family;
|
||||
};
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//#include <memory>
|
||||
#include "nlid_proxy.h"
|
||||
#include "solver/nld_solver.h"
|
||||
//#include "plib/pstream.h"
|
||||
|
@ -11,8 +11,6 @@
|
||||
#ifndef NLID_PROXY_H_
|
||||
#define NLID_PROXY_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "nl_setup.h"
|
||||
#include "nl_base.h"
|
||||
#include "nl_factory.h"
|
||||
|
@ -11,13 +11,10 @@
|
||||
#ifndef NLID_SYSTEM_H_
|
||||
#define NLID_SYSTEM_H_
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "analog/nld_twoterm.h"
|
||||
#include "nl_base.h"
|
||||
#include "nl_time.h"
|
||||
#include "nl_setup.h"
|
||||
#include "plib/palloc.h"
|
||||
#include "plib/pfmtlog.h"
|
||||
#include "plib/pfunction.h"
|
||||
|
@ -9,20 +9,16 @@
|
||||
#ifndef NLBASE_H_
|
||||
#define NLBASE_H_
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
//#include <cmath>
|
||||
#include <cstdint>
|
||||
|
||||
#include "nl_lists.h"
|
||||
#include "nl_time.h"
|
||||
#include "plib/palloc.h"
|
||||
#include "plib/palloc.h" // owned_ptr
|
||||
#include "plib/pdynlib.h"
|
||||
#include "plib/pstate.h"
|
||||
#include "plib/pfmtlog.h"
|
||||
#include "plib/pstream.h"
|
||||
#include "plib/pexception.h"
|
||||
#include "plib/ppmf.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
|
@ -27,8 +27,11 @@ sed -e 's/#define \(.*\)"\(.*\)"[ \t]*,[ \t]*\(.*\)/NET_ALIAS(\1,\2.\3)/' src/ma
|
||||
#ifndef NL_CONVERT_CPP
|
||||
#include "devices/net_lib.h"
|
||||
#include "analog/nld_twoterm.h"
|
||||
|
||||
#include <cmath>
|
||||
#endif
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
* Compatibility macros for DICE netlists ...
|
||||
* -------------------------------------------------------------------- */
|
||||
|
@ -9,12 +9,6 @@
|
||||
#ifndef NLFACTORY_H_
|
||||
#define NLFACTORY_H_
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "nl_config.h"
|
||||
#include "plib/palloc.h"
|
||||
#include "plib/plists.h"
|
||||
#include "plib/putil.h"
|
||||
#include "nl_base.h"
|
||||
|
||||
#define NETLIB_DEVICE_IMPL(chip) \
|
||||
|
@ -5,8 +5,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "plib/palloc.h"
|
||||
#include "plib/putil.h"
|
||||
#include "nl_base.h"
|
||||
|
@ -8,19 +8,11 @@
|
||||
#ifndef NLSETUP_H_
|
||||
#define NLSETUP_H_
|
||||
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "plib/pstring.h"
|
||||
#include "plib/pfmtlog.h"
|
||||
#include "plib/pstream.h"
|
||||
#include "plib/putil.h"
|
||||
#include "plib/pparser.h"
|
||||
#include "nl_config.h"
|
||||
#include "nl_base.h"
|
||||
#include "nl_factory.h"
|
||||
#include "plib/pparser.h"
|
||||
|
||||
#include <stack>
|
||||
|
||||
//============================================================
|
||||
// MACROS / inline netlist definitions
|
||||
@ -125,7 +117,7 @@ namespace netlist
|
||||
unsigned long ni;
|
||||
unsigned long no;
|
||||
pstring def_param;
|
||||
plib::pstring_vector_t desc;
|
||||
std::vector<pstring> desc;
|
||||
pstring family;
|
||||
};
|
||||
|
||||
|
@ -5,8 +5,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "pconfig.h"
|
||||
#include "palloc.h"
|
||||
#include "pfmtlog.h"
|
||||
|
@ -10,9 +10,6 @@
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "pconfig.h"
|
||||
#include "pstring.h"
|
||||
|
||||
namespace plib {
|
||||
|
@ -9,7 +9,6 @@
|
||||
#define PCHRONO_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
#include "pconfig.h"
|
||||
|
@ -8,9 +8,8 @@
|
||||
#ifndef PCONFIG_H_
|
||||
#define PCONFIG_H_
|
||||
|
||||
#include <utility>
|
||||
#include <cstdint>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
/*
|
||||
* Define this for more accurate measurements if you processor supports
|
||||
@ -63,37 +62,9 @@ typedef __int128_t INT128;
|
||||
name &operator=(const name &);
|
||||
|
||||
//============================================================
|
||||
// cut down delegate implementation
|
||||
// Pointer to Member Function
|
||||
//============================================================
|
||||
|
||||
/*
|
||||
*
|
||||
* NL_PMF_TYPE_GNUC_PMF
|
||||
* Use standard pointer to member function syntax C++11
|
||||
*
|
||||
* NL_PMF_TYPE_GNUC_PMF_CONV
|
||||
* Use gnu extension and convert the pmf to a function pointer.
|
||||
* This is not standard compliant and needs
|
||||
* -Wno-pmf-conversions to compile.
|
||||
*
|
||||
* NL_PMF_TYPE_INTERNAL
|
||||
* Use the same approach as MAME for deriving the function pointer.
|
||||
* This is compiler-dependent as well
|
||||
*
|
||||
* Benchmarks for ./nltool -c run -f src/mame/machine/nl_pong.cpp -t 10 -n pong_fast
|
||||
*
|
||||
* NL_PMF_TYPE_INTERNAL: 215% 215%
|
||||
* NL_PMF_TYPE_GNUC_PMF: 163% 196%
|
||||
* NL_PMF_TYPE_GNUC_PMF_CONV: 215% 215%
|
||||
* NL_PMF_TYPE_VIRTUAL: 213% 209%
|
||||
*
|
||||
* The whole exercise was done to avoid virtual calls. In prior versions of
|
||||
* netlist, the INTERNAL and GNUC_PMF_CONV approach provided significant improvement.
|
||||
* Since than, "hot" was removed from functions declared as virtual.
|
||||
* This may explain that the recent benchmarks show no difference at all.
|
||||
*
|
||||
*/
|
||||
|
||||
// This will be autodetected
|
||||
// #define PPMF_TYPE 1
|
||||
|
||||
@ -101,7 +72,6 @@ typedef __int128_t INT128;
|
||||
#define PPMF_TYPE_GNUC_PMF_CONV 1
|
||||
#define PPMF_TYPE_INTERNAL 2
|
||||
|
||||
|
||||
#if defined(__GNUC__)
|
||||
/* does not work in versions over 4.7.x of 32bit MINGW */
|
||||
#if defined(__MINGW32__) && !defined(__x86_64) && defined(__i386__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)))
|
||||
@ -134,145 +104,4 @@ typedef __int128_t INT128;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (PPMF_TYPE == PPMF_TYPE_GNUC_PMF_CONV)
|
||||
#pragma GCC diagnostic ignored "-Wpmf-conversions"
|
||||
#endif
|
||||
|
||||
namespace plib {
|
||||
/*
|
||||
* The following class was derived from the MAME delegate.h code.
|
||||
* It derives a pointer to a member function.
|
||||
*/
|
||||
|
||||
#if (PHAS_PMF_INTERNAL)
|
||||
class mfp
|
||||
{
|
||||
public:
|
||||
// construct from any member function pointer
|
||||
class generic_class;
|
||||
using generic_function = void (*)();
|
||||
|
||||
template<typename MemberFunctionType>
|
||||
mfp(MemberFunctionType mftp)
|
||||
: m_function(0), m_this_delta(0)
|
||||
{
|
||||
*reinterpret_cast<MemberFunctionType *>(this) = mftp;
|
||||
}
|
||||
|
||||
template<typename FunctionType, typename MemberFunctionType, typename ObjectType>
|
||||
static FunctionType get_mfp(MemberFunctionType mftp, ObjectType *object)
|
||||
{
|
||||
mfp mfpo(mftp);
|
||||
//return mfpo.update_after_bind<FunctionType>(object);
|
||||
return reinterpret_cast<FunctionType>(
|
||||
mfpo.convert_to_generic(reinterpret_cast<generic_class *>(object)));
|
||||
}
|
||||
|
||||
private:
|
||||
// extract the generic function and adjust the object pointer
|
||||
generic_function convert_to_generic(generic_class * object) const
|
||||
{
|
||||
// apply the "this" delta to the object first
|
||||
generic_class * o_p_delta = reinterpret_cast<generic_class *>(reinterpret_cast<std::uint8_t *>(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<generic_function>(m_function);
|
||||
|
||||
// otherwise, it is the byte index into the vtable where the actual function lives
|
||||
std::uint8_t *vtable_base = *reinterpret_cast<std::uint8_t **>(o_p_delta);
|
||||
return *reinterpret_cast<generic_function *>(vtable_base + m_function - 1);
|
||||
}
|
||||
|
||||
// actual state
|
||||
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
|
||||
};
|
||||
#endif
|
||||
|
||||
#if (PPMF_TYPE == PPMF_TYPE_PMF)
|
||||
template<typename R, typename... Targs>
|
||||
class pmfp_base
|
||||
{
|
||||
public:
|
||||
class generic_class;
|
||||
using generic_function = R (generic_class::*)(Targs...);
|
||||
pmfp_base() : m_func(nullptr) {}
|
||||
|
||||
template<typename MemberFunctionType, typename O>
|
||||
void set_base(MemberFunctionType mftp, O *object)
|
||||
{
|
||||
using function_ptr = R (O::*)(Targs...);
|
||||
function_ptr t = mftp;
|
||||
m_func = reinterpret_cast<generic_function>(t);
|
||||
}
|
||||
template<typename O>
|
||||
inline R call(O *obj, Targs... args) const
|
||||
{
|
||||
using function_ptr = R (O::*)(Targs...);
|
||||
function_ptr t = reinterpret_cast<function_ptr>(m_func);
|
||||
return (obj->*t)(std::forward<Targs>(args)...);
|
||||
}
|
||||
private:
|
||||
generic_function m_func;
|
||||
};
|
||||
|
||||
#elif ((PPMF_TYPE == PPMF_TYPE_GNUC_PMF_CONV) || (PPMF_TYPE == PPMF_TYPE_INTERNAL))
|
||||
template<typename R, typename... Targs>
|
||||
class pmfp_base
|
||||
{
|
||||
public:
|
||||
using generic_function = void (*)();
|
||||
|
||||
pmfp_base() : m_func(nullptr) {}
|
||||
|
||||
template<typename MemberFunctionType, typename O>
|
||||
void set_base(MemberFunctionType mftp, O *object)
|
||||
{
|
||||
#if (PPMF_TYPE == PPMF_TYPE_INTERNAL)
|
||||
using function_ptr = MEMBER_ABI R (*)(O *obj, Targs... args);
|
||||
m_func = reinterpret_cast<generic_function>(plib::mfp::get_mfp<function_ptr>(mftp, object));
|
||||
#elif (PPMF_TYPE == PPMF_TYPE_GNUC_PMF_CONV)
|
||||
R (O::* pFunc)(Targs...) = mftp;
|
||||
m_func = reinterpret_cast<generic_function>((object->*pFunc));
|
||||
#endif
|
||||
}
|
||||
template<typename O>
|
||||
inline R call(O *obj, Targs... args) const
|
||||
{
|
||||
using function_ptr = MEMBER_ABI R (*)(O *obj, Targs... args);
|
||||
return (reinterpret_cast<function_ptr>(m_func))(obj, std::forward<Targs>(args)...);
|
||||
}
|
||||
private:
|
||||
generic_function m_func;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<typename R, typename... Targs>
|
||||
class pmfp : public pmfp_base<R, Targs...>
|
||||
{
|
||||
public:
|
||||
class generic_class;
|
||||
pmfp() : pmfp_base<R, Targs...>(), m_obj(nullptr) {}
|
||||
|
||||
template<typename MemberFunctionType, typename O>
|
||||
void set(MemberFunctionType mftp, O *object)
|
||||
{
|
||||
this->set_base(mftp, object);
|
||||
m_obj = reinterpret_cast<generic_class *>(object);
|
||||
}
|
||||
|
||||
inline R operator()(Targs... args) const
|
||||
{
|
||||
return this->call(m_obj, std::forward<Targs>(args)...);
|
||||
}
|
||||
private:
|
||||
generic_class *m_obj;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif /* PCONFIG_H_ */
|
||||
|
@ -7,10 +7,6 @@
|
||||
#ifndef PDYNLIB_H_
|
||||
#define PDYNLIB_H_
|
||||
|
||||
#include <cstdarg>
|
||||
#include <cstddef>
|
||||
|
||||
#include "pconfig.h"
|
||||
#include "pstring.h"
|
||||
|
||||
namespace plib {
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include "pconfig.h"
|
||||
#include "pstring.h"
|
||||
|
||||
namespace plib {
|
||||
|
@ -6,11 +6,8 @@
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
//FIXME:: pstring should be locale free
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
#include <cstdarg>
|
||||
#include <algorithm>
|
||||
|
||||
#include "pfmtlog.h"
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "pconfig.h"
|
||||
#include "pstring.h"
|
||||
#include "ptypes.h"
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "pconfig.h"
|
||||
#include "pstring.h"
|
||||
|
||||
namespace plib {
|
||||
|
@ -10,10 +10,7 @@
|
||||
#ifndef PLISTS_H_
|
||||
#define PLISTS_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <type_traits>
|
||||
#include <cmath>
|
||||
|
||||
#include "pstring.h"
|
||||
|
||||
|
@ -56,7 +56,7 @@ namespace plib {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int option_bool::parse(ATTR_UNUSED pstring argument)
|
||||
int option_bool::parse(pstring argument)
|
||||
{
|
||||
m_val = true;
|
||||
return 0;
|
||||
|
@ -10,8 +10,6 @@
|
||||
#ifndef POPTIONS_H_
|
||||
#define POPTIONS_H_
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "pstring.h"
|
||||
#include "plists.h"
|
||||
#include "putil.h"
|
||||
@ -67,7 +65,7 @@ public:
|
||||
|
||||
/* no_argument options will be called with "" argument */
|
||||
|
||||
virtual int parse(ATTR_UNUSED pstring argument) = 0;
|
||||
virtual int parse(pstring argument) = 0;
|
||||
|
||||
pstring short_opt() { return m_short; }
|
||||
pstring long_opt() { return m_long; }
|
||||
@ -116,7 +114,7 @@ public:
|
||||
: option(parent, ashort, along, help, false), m_val(false)
|
||||
{}
|
||||
|
||||
virtual int parse(ATTR_UNUSED pstring argument) override;
|
||||
virtual int parse(pstring argument) override;
|
||||
|
||||
bool operator ()() { return m_val; }
|
||||
private:
|
||||
|
@ -8,7 +8,8 @@
|
||||
#include <cstdarg>
|
||||
|
||||
#include "pparser.h"
|
||||
#include "plib/palloc.h"
|
||||
#include "palloc.h"
|
||||
#include "putil.h"
|
||||
|
||||
namespace plib {
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -302,7 +303,7 @@ void ppreprocessor::error(const pstring &err)
|
||||
|
||||
|
||||
|
||||
double ppreprocessor::expr(const pstring_vector_t &sexpr, std::size_t &start, int prio)
|
||||
double ppreprocessor::expr(const std::vector<pstring> &sexpr, std::size_t &start, int prio)
|
||||
{
|
||||
double val;
|
||||
pstring tok=sexpr[start];
|
||||
|
@ -11,10 +11,9 @@
|
||||
#include <unordered_map>
|
||||
#include <cstdint>
|
||||
|
||||
#include "pconfig.h"
|
||||
#include "pstring.h"
|
||||
#include "plists.h"
|
||||
#include "putil.h"
|
||||
//#include "putil.h"
|
||||
#include "pstream.h"
|
||||
|
||||
namespace plib {
|
||||
@ -168,7 +167,7 @@ public:
|
||||
void process(putf8_reader &istrm, putf8_writer &ostrm);
|
||||
|
||||
protected:
|
||||
double expr(const plib::pstring_vector_t &sexpr, std::size_t &start, int prio);
|
||||
double expr(const std::vector<pstring> &sexpr, std::size_t &start, int prio);
|
||||
define_t *get_define(const pstring &name);
|
||||
pstring replace_macros(const pstring &line);
|
||||
virtual void error(const pstring &err);
|
||||
@ -178,7 +177,7 @@ private:
|
||||
pstring process_line(const pstring &line);
|
||||
|
||||
std::unordered_map<pstring, define_t> m_defines;
|
||||
plib::pstring_vector_t m_expr_sep;
|
||||
std::vector<pstring> m_expr_sep;
|
||||
|
||||
std::uint_least64_t m_ifflag; // 31 if levels
|
||||
int m_level;
|
||||
|
185
src/lib/netlist/plib/ppmf.h
Normal file
185
src/lib/netlist/plib/ppmf.h
Normal file
@ -0,0 +1,185 @@
|
||||
// license:GPL-2.0+
|
||||
// copyright-holders:Couriersud
|
||||
/*
|
||||
* ppmf.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PPMF_H_
|
||||
#define PPMF_H_
|
||||
|
||||
#include "pconfig.h"
|
||||
#include <utility>
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* NL_PMF_TYPE_GNUC_PMF
|
||||
* Use standard pointer to member function syntax C++11
|
||||
*
|
||||
* NL_PMF_TYPE_GNUC_PMF_CONV
|
||||
* Use gnu extension and convert the pmf to a function pointer.
|
||||
* This is not standard compliant and needs
|
||||
* -Wno-pmf-conversions to compile.
|
||||
*
|
||||
* NL_PMF_TYPE_INTERNAL
|
||||
* Use the same approach as MAME for deriving the function pointer.
|
||||
* This is compiler-dependent as well
|
||||
*
|
||||
* Benchmarks for ./nltool -c run -f src/mame/machine/nl_pong.cpp -t 10 -n pong_fast
|
||||
*
|
||||
* NL_PMF_TYPE_INTERNAL: 215% 215%
|
||||
* NL_PMF_TYPE_GNUC_PMF: 163% 196%
|
||||
* NL_PMF_TYPE_GNUC_PMF_CONV: 215% 215%
|
||||
* NL_PMF_TYPE_VIRTUAL: 213% 209%
|
||||
*
|
||||
* The whole exercise was done to avoid virtual calls. In prior versions of
|
||||
* netlist, the INTERNAL and GNUC_PMF_CONV approach provided significant improvement.
|
||||
* Since than, "hot" was removed from functions declared as virtual.
|
||||
* This may explain that the recent benchmarks show no difference at all.
|
||||
*
|
||||
*/
|
||||
|
||||
#if (PPMF_TYPE == PPMF_TYPE_GNUC_PMF_CONV)
|
||||
#pragma GCC diagnostic ignored "-Wpmf-conversions"
|
||||
#endif
|
||||
|
||||
namespace plib {
|
||||
/*
|
||||
* The following class was derived from the MAME delegate.h code.
|
||||
* It derives a pointer to a member function.
|
||||
*/
|
||||
|
||||
#if (PHAS_PMF_INTERNAL)
|
||||
class mfp
|
||||
{
|
||||
public:
|
||||
// construct from any member function pointer
|
||||
class generic_class;
|
||||
using generic_function = void (*)();
|
||||
|
||||
template<typename MemberFunctionType>
|
||||
mfp(MemberFunctionType mftp)
|
||||
: m_function(0), m_this_delta(0)
|
||||
{
|
||||
*reinterpret_cast<MemberFunctionType *>(this) = mftp;
|
||||
}
|
||||
|
||||
template<typename FunctionType, typename MemberFunctionType, typename ObjectType>
|
||||
static FunctionType get_mfp(MemberFunctionType mftp, ObjectType *object)
|
||||
{
|
||||
mfp mfpo(mftp);
|
||||
//return mfpo.update_after_bind<FunctionType>(object);
|
||||
return reinterpret_cast<FunctionType>(
|
||||
mfpo.convert_to_generic(reinterpret_cast<generic_class *>(object)));
|
||||
}
|
||||
|
||||
private:
|
||||
// extract the generic function and adjust the object pointer
|
||||
generic_function convert_to_generic(generic_class * object) const
|
||||
{
|
||||
// apply the "this" delta to the object first
|
||||
generic_class * o_p_delta = reinterpret_cast<generic_class *>(reinterpret_cast<std::uint8_t *>(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<generic_function>(m_function);
|
||||
|
||||
// otherwise, it is the byte index into the vtable where the actual function lives
|
||||
std::uint8_t *vtable_base = *reinterpret_cast<std::uint8_t **>(o_p_delta);
|
||||
return *reinterpret_cast<generic_function *>(vtable_base + m_function - 1);
|
||||
}
|
||||
|
||||
// actual state
|
||||
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
|
||||
};
|
||||
#endif
|
||||
|
||||
#if (PPMF_TYPE == PPMF_TYPE_PMF)
|
||||
template<typename R, typename... Targs>
|
||||
class pmfp_base
|
||||
{
|
||||
public:
|
||||
class generic_class;
|
||||
using generic_function = R (generic_class::*)(Targs...);
|
||||
pmfp_base() : m_func(nullptr) {}
|
||||
|
||||
template<typename MemberFunctionType, typename O>
|
||||
void set_base(MemberFunctionType mftp, O *object)
|
||||
{
|
||||
using function_ptr = R (O::*)(Targs...);
|
||||
function_ptr t = mftp;
|
||||
m_func = reinterpret_cast<generic_function>(t);
|
||||
}
|
||||
template<typename O>
|
||||
inline R call(O *obj, Targs... args) const
|
||||
{
|
||||
using function_ptr = R (O::*)(Targs...);
|
||||
function_ptr t = reinterpret_cast<function_ptr>(m_func);
|
||||
return (obj->*t)(std::forward<Targs>(args)...);
|
||||
}
|
||||
private:
|
||||
generic_function m_func;
|
||||
};
|
||||
|
||||
#elif ((PPMF_TYPE == PPMF_TYPE_GNUC_PMF_CONV) || (PPMF_TYPE == PPMF_TYPE_INTERNAL))
|
||||
template<typename R, typename... Targs>
|
||||
class pmfp_base
|
||||
{
|
||||
public:
|
||||
using generic_function = void (*)();
|
||||
|
||||
pmfp_base() : m_func(nullptr) {}
|
||||
|
||||
template<typename MemberFunctionType, typename O>
|
||||
void set_base(MemberFunctionType mftp, O *object)
|
||||
{
|
||||
#if (PPMF_TYPE == PPMF_TYPE_INTERNAL)
|
||||
using function_ptr = MEMBER_ABI R (*)(O *obj, Targs... args);
|
||||
m_func = reinterpret_cast<generic_function>(plib::mfp::get_mfp<function_ptr>(mftp, object));
|
||||
#elif (PPMF_TYPE == PPMF_TYPE_GNUC_PMF_CONV)
|
||||
R (O::* pFunc)(Targs...) = mftp;
|
||||
m_func = reinterpret_cast<generic_function>((object->*pFunc));
|
||||
#endif
|
||||
}
|
||||
template<typename O>
|
||||
inline R call(O *obj, Targs... args) const
|
||||
{
|
||||
using function_ptr = MEMBER_ABI R (*)(O *obj, Targs... args);
|
||||
return (reinterpret_cast<function_ptr>(m_func))(obj, std::forward<Targs>(args)...);
|
||||
}
|
||||
private:
|
||||
generic_function m_func;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<typename R, typename... Targs>
|
||||
class pmfp : public pmfp_base<R, Targs...>
|
||||
{
|
||||
public:
|
||||
class generic_class;
|
||||
pmfp() : pmfp_base<R, Targs...>(), m_obj(nullptr) {}
|
||||
|
||||
template<typename MemberFunctionType, typename O>
|
||||
void set(MemberFunctionType mftp, O *object)
|
||||
{
|
||||
this->set_base(mftp, object);
|
||||
m_obj = reinterpret_cast<generic_class *>(object);
|
||||
}
|
||||
|
||||
inline R operator()(Targs... args) const
|
||||
{
|
||||
return this->call(m_obj, std::forward<Targs>(args)...);
|
||||
}
|
||||
private:
|
||||
generic_class *m_obj;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif /* PPMF_H_ */
|
@ -8,13 +8,12 @@
|
||||
#ifndef PSTATE_H_
|
||||
#define PSTATE_H_
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
#include "plists.h"
|
||||
#include "pstring.h"
|
||||
#include "ptypes.h"
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// state saving ...
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
@ -7,9 +7,6 @@
|
||||
#ifndef PSTREAM_H_
|
||||
#define PSTREAM_H_
|
||||
|
||||
#include <cstdarg>
|
||||
#include <cstddef>
|
||||
|
||||
#include "pconfig.h"
|
||||
#include "pstring.h"
|
||||
#include "pfmtlog.h"
|
||||
|
@ -7,13 +7,9 @@
|
||||
#ifndef PSTRING_H_
|
||||
#define PSTRING_H_
|
||||
|
||||
#include <cstdarg>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <exception>
|
||||
|
||||
#include "pconfig.h"
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// pstring: immutable strings ...
|
||||
//
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define PTYPES_H_
|
||||
|
||||
#include <type_traits>
|
||||
#include <limits>
|
||||
|
||||
#include "pconfig.h"
|
||||
#include "pstring.h"
|
||||
|
@ -8,10 +8,10 @@
|
||||
#ifndef P_UTIL_H_
|
||||
#define P_UTIL_H_
|
||||
|
||||
#include <initializer_list>
|
||||
|
||||
#include "plib/pstring.h"
|
||||
#include "plib/plists.h"
|
||||
|
||||
#include <initializer_list>
|
||||
#include <algorithm>
|
||||
|
||||
namespace plib
|
||||
{
|
||||
|
@ -8,22 +8,12 @@
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "plib/poptions.h"
|
||||
#include "plib/pstring.h"
|
||||
#include "plib/plists.h"
|
||||
#include "plib/ptypes.h"
|
||||
#include "plib/pexception.h"
|
||||
#include "nl_setup.h"
|
||||
#include "nl_factory.h"
|
||||
#include "nl_parser.h"
|
||||
#include "devices/net_lib.h"
|
||||
#include "tools/nl_convert.h"
|
||||
|
||||
#include <cfenv>
|
||||
|
||||
class tool_options_t : public plib::options
|
||||
{
|
||||
public:
|
||||
|
@ -1,6 +1,5 @@
|
||||
// license:GPL-2.0+
|
||||
// copyright-holders:Couriersud
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include "plib/pstring.h"
|
||||
#include "plib/plists.h"
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "nl_base.h"
|
||||
#include "nl_errstr.h"
|
||||
#include "plib/putil.h"
|
||||
|
||||
namespace netlist
|
||||
{
|
||||
|
@ -4,7 +4,7 @@
|
||||
* nld_ms_direct.h
|
||||
*
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#ifndef NLD_MS_DIRECT_H_
|
||||
#define NLD_MS_DIRECT_H_
|
||||
|
||||
@ -634,3 +634,4 @@ matrix_solver_direct_t<m_N, storage_N>::matrix_solver_direct_t(const eSolverType
|
||||
} // namespace netlist
|
||||
|
||||
#endif /* NLD_MS_DIRECT_H_ */
|
||||
#endif
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "omp.h"
|
||||
#endif
|
||||
|
||||
#include "plib/putil.h"
|
||||
#include "nld_solver.h"
|
||||
#include "nld_matrix_solver.h"
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
#include <unordered_map>
|
||||
#include "nl_convert.h"
|
||||
|
@ -59,14 +59,14 @@ private:
|
||||
: m_name(aname), m_no_export(false) {}
|
||||
|
||||
const pstring &name() { return m_name;}
|
||||
plib::pstring_vector_t &terminals() { return m_terminals; }
|
||||
std::vector<pstring> &terminals() { return m_terminals; }
|
||||
void set_no_export() { m_no_export = true; }
|
||||
bool is_no_export() { return m_no_export; }
|
||||
|
||||
private:
|
||||
pstring m_name;
|
||||
bool m_no_export;
|
||||
plib::pstring_vector_t m_terminals;
|
||||
std::vector<pstring> m_terminals;
|
||||
};
|
||||
|
||||
struct dev_t
|
||||
|
Loading…
Reference in New Issue
Block a user