Some minor changes towards c++11.

This commit is contained in:
couriersud 2016-05-08 01:58:10 +02:00
parent b386dd0556
commit df8280806b
14 changed files with 50 additions and 57 deletions

View File

@ -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));
}

View File

@ -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)

View File

@ -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<pstring, pstring> model_map_t;
using model_map_t = phashmap_t<pstring, pstring>;
// -----------------------------------------------------------------------------
// logic_family_t
@ -475,7 +473,7 @@ namespace netlist
P_PREVENT_COPYING(core_terminal_t)
public:
typedef pvector_t<core_terminal_t *> list_t;
using list_t = pvector_t<core_terminal_t *>;
/* needed here ... */
@ -553,7 +551,7 @@ namespace netlist
P_PREVENT_COPYING(terminal_t)
public:
typedef pvector_t<terminal_t *> list_t;
using list_t = pvector_t<terminal_t *>;
ATTR_COLD terminal_t();
@ -701,7 +699,7 @@ namespace netlist
P_PREVENT_COPYING(net_t)
public:
typedef pvector_t<net_t *> list_t;
using list_t = pvector_t<net_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<logic_net_t *> list_t;
using list_t = pvector_t<logic_net_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<analog_net_t *> list_t;
using list_t = pvector_t<analog_net_t *>;
ATTR_COLD analog_net_t();
virtual ~analog_net_t() { };
@ -987,9 +985,9 @@ namespace netlist
private:
};
typedef param_template_t<nl_double, param_t::DOUBLE> param_double_t;
typedef param_template_t<int, param_t::INTEGER> param_int_t;
typedef param_template_t<pstring, param_t::STRING> param_str_t;
using param_double_t = param_template_t<nl_double, param_t::DOUBLE>;
using param_int_t = param_template_t<int, param_t::INTEGER>;
using param_str_t = param_template_t<pstring, param_t::STRING>;
class param_logic_t : public param_int_t
{
@ -1026,7 +1024,7 @@ namespace netlist
P_PREVENT_COPYING(core_device_t)
public:
typedef pvector_t<core_device_t *> list_t;
using list_t = pvector_t<core_device_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)

View File

@ -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

View File

@ -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 &param_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 &param_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<class _device_class>
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);

View File

@ -91,7 +91,7 @@ namespace netlist
class source_t
{
public:
typedef pvector_t<source_t *> list_t;
using list_t = pvector_t<source_t *>;
source_t()
{}

View File

@ -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;

View File

@ -8,6 +8,8 @@
#ifndef PCONFIG_H_
#define PCONFIG_H_
#include <cstdint>
#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<typename _MemberFunctionType>
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<generic_class *>(reinterpret_cast<UINT8 *>(object) + m_this_delta);
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
UINT8 *vtable_base = *reinterpret_cast<UINT8 **>(o_p_delta);
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
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

View File

@ -27,9 +27,9 @@ public:
bool isLoaded() const;
template <typename T>
T *getsym(const pstring name)
T getsym(const pstring name)
{
return reinterpret_cast<T *>(getsym_p(name));
return reinterpret_cast<T>(getsym_p(name));
}
private:
void *getsym_p(const pstring name);

View File

@ -71,7 +71,7 @@ class pstate_manager_t;
class pstate_callback_t
{
public:
typedef pvector_t<pstate_callback_t *> list_t;
using list_t = pvector_t<pstate_callback_t *>;
virtual ~pstate_callback_t() { };
@ -83,7 +83,7 @@ protected:
struct pstate_entry_t
{
typedef pvector_t<pstate_entry_t *> list_t;
using list_t = pvector_t<pstate_entry_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)

View File

@ -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;

View File

@ -74,8 +74,8 @@ private:
class matrix_solver_t : public device_t
{
public:
typedef pvector_t<matrix_solver_t *> list_t;
typedef core_device_t::list_t dev_list_t;
using list_t = pvector_t<matrix_solver_t *>;
using dev_list_t = core_device_t::list_t;
enum eSortType
{

View File

@ -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;
};

View File

@ -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(); }