netlist: More c++, less macros, added support for cspell (#9794)

- More c++, less macros
  * Significantly reduced the use of unused_var and replaced it with
    [[maybe_unused]]
  * use enum class in ppmf.h

- Changes to testing code in ptest.h
  * Catch exceptions in more places
  * The verbosity of the output can now be controlled
  * Display of test stats totals

- added support for cspell
- fixed various typos
- fixed SUBTARGET=nl build
- fixed more file permissions
- srcclean and add fix_permissions target to netlist makefile
This commit is contained in:
couriersud 2022-05-21 17:16:50 +02:00 committed by GitHub
parent b33946d980
commit 324f9d44d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
62 changed files with 591 additions and 335 deletions

View File

@ -33,6 +33,7 @@ CPUS["M680X0"] = true
CPUS["F8"] = true CPUS["F8"] = true
CPUS["CCPU"] = true CPUS["CCPU"] = true
CPUS["MCS40"] = true CPUS["MCS40"] = true
CPUS["TMS9900"] = true
-------------------------------------------------- --------------------------------------------------
-- Specify all the sound cores necessary for the -- Specify all the sound cores necessary for the
@ -108,6 +109,7 @@ MACHINES["PIT8253"] = true
--MACHINES["BANKDEV"] = true --MACHINES["BANKDEV"] = true
MACHINES["F3853"] = true MACHINES["F3853"] = true
MACHINES["MB14241"] = true MACHINES["MB14241"] = true
MACHINES["STEPPERS"] = true
-------------------------------------------------- --------------------------------------------------
-- specify available bus cores -- specify available bus cores
@ -421,6 +423,15 @@ files{
MAME_DIR .. "src/mame/drivers/segattl.cpp", MAME_DIR .. "src/mame/drivers/segattl.cpp",
MAME_DIR .. "src/mame/drivers/taitottl.cpp", MAME_DIR .. "src/mame/drivers/taitottl.cpp",
MAME_DIR .. "src/mame/drivers/usbilliards.cpp", MAME_DIR .. "src/mame/drivers/usbilliards.cpp",
MAME_DIR .. "src/mame/drivers/jpmsru.cpp",
MAME_DIR .. "src/mame/audio/nl_jpmsru.cpp",
MAME_DIR .. "src/mame/audio/fruitsamples.cpp",
MAME_DIR .. "src/mame/audio/fruitsamples.h",
MAME_DIR .. "src/mame/video/awpvid.cpp",
MAME_DIR .. "src/mame/video/awpvid.h",
} }
end end

View File

@ -66,9 +66,8 @@ namespace netlist::analog
//return m_h * cap + m_gmin; //return m_h * cap + m_gmin;
} }
nl_fptype Ieq(nl_fptype cap, nl_fptype v) const noexcept nl_fptype Ieq(nl_fptype cap, [[maybe_unused]] nl_fptype v) const noexcept
{ {
plib::unused_var(v);
//return -m_h * 0.5 * ((cap + m_c) * m_v + (cap - m_c) * v) ; //return -m_h * 0.5 * ((cap + m_c) * m_v + (cap - m_c) * v) ;
return -m_h * nlconst::half() * (cap + m_c) * m_v; return -m_h * nlconst::half() * (cap + m_c) * m_v;
//return -m_h * cap * m_v; //return -m_h * cap * m_v;
@ -109,15 +108,13 @@ namespace netlist::analog
static capacitor_e type() noexcept { return capacitor_e::CONSTANT_CAPACITY; } static capacitor_e type() noexcept { return capacitor_e::CONSTANT_CAPACITY; }
nl_fptype G(nl_fptype cap) const noexcept { return cap * m_h + m_gmin; } nl_fptype G(nl_fptype cap) const noexcept { return cap * m_h + m_gmin; }
nl_fptype Ieq(nl_fptype cap, nl_fptype v) const noexcept nl_fptype Ieq(nl_fptype cap, [[maybe_unused]] nl_fptype v) const noexcept
{ {
plib::unused_var(v);
return - G(cap) * m_v; return - G(cap) * m_v;
} }
void timestep(nl_fptype cap, nl_fptype v, nl_fptype step) noexcept void timestep([[maybe_unused]] nl_fptype cap, nl_fptype v, nl_fptype step) noexcept
{ {
plib::unused_var(cap);
m_h = plib::reciprocal(step); m_h = plib::reciprocal(step);
m_v = v; m_v = v;
} }
@ -135,9 +132,10 @@ namespace netlist::analog
struct generic_capacitor_const struct generic_capacitor_const
{ {
public: public:
generic_capacitor_const(core_device_t &dev, const pstring &name) generic_capacitor_const( /*[[maybe_unused]]*/ core_device_t &dev, /*[[maybe_unused]]*/ const pstring &name)
: m_gmin(nlconst::zero()) : m_gmin(nlconst::zero())
{ {
// gcc 7.2 (mingw) and 7.5 (ubuntu) don't accept maybe_unused here
plib::unused_var(dev, name); plib::unused_var(dev, name);
} }
@ -163,13 +161,12 @@ namespace netlist::analog
struct generic_capacitor_const struct generic_capacitor_const
{ {
public: public:
generic_capacitor_const(core_device_t &dev, const pstring &name) generic_capacitor_const( [[maybe_unused]] core_device_t &dev, [[maybe_unused]] const pstring &name)
: m_gmin(nlconst::zero()) : m_gmin(nlconst::zero())
, m_vn(0) , m_vn(0)
, m_in(0) , m_in(0)
, m_trn(0.0) , m_trn(0.0)
{ {
plib::unused_var(dev, name);
} }
// Returns { G, Ieq } // Returns { G, Ieq }

View File

@ -58,9 +58,8 @@ namespace netlist::analog
return b ? *h : d2; return b ? *h : d2;
} }
template<> template<>
inline core_device_t &bselect(bool b, netlist_state_t &d1, core_device_t &d2) inline core_device_t &bselect(bool b, [[maybe_unused]] netlist_state_t &d1, core_device_t &d2)
{ {
plib::unused_var(d1);
if (b) if (b)
throw nl_exception("bselect with netlist and b==true"); throw nl_exception("bselect with netlist and b==true");
return d2; return d2;

View File

@ -0,0 +1,76 @@
{
"words" : [
"MAME",
"netlist",
"netlists",
"datasheet",
"cmos",
"opamp",
"opamps",
"mosfet",
"mosfets",
"Chebyshev",
"Fairchild",
"Schmitt",
"Transconductance",
"nmos",
"pmos",
"retriggerable", // not in leo
"presettable", // not in leo
"misformatted", // not in leo
"monostable",
"demultiplexer",
"demultiplexers",
"behavioural",
"highpass",
"nltool",
"nvcc",
"Couriersud",
"plib", // FIXME: Remove everything below here again
"ppmf"
],
"languageSettings": [
// This one works with Python
{
"languageId": "python",
"includeRegExpList": [
"/#.*/",
"/('''|\"\"\")[^\\1]+?\\1/g",
"strings"
]
},
// This one works with JavaScript, Typescript, etc
{
"languageId": "javascript,typescript",
"includeRegExpList": [
"CStyleComment",
"strings"
]
},
// Use with cpp or c files
{
"languageId": "cpp,c,h",
// Turn off compound words, because it is only checking strings.
"allowCompoundWords": false,
// Only check comments and strings
"includeRegExpList": [
"CStyleComment",
"string"
],
"ignoreRegExpList": [
"/#include.*/", // Exclude includes, because they are also strings
"/#pragma.*/", // Exclude pragmas, they may include strings
"/\/\/ NOLINT:.*/", // Exclude clang-tidy instructions
"/\/\/\/ \\\\file.*/", // Doxygen
"/\/\/\/ \\\\addtogroup.*/", // Doxygen
"/`[^`]+`/", // Markup code formatt
"/} \/\/ namespace.*/", // Namespace comments
"/[A-Z][A-Z][A-Z][^\\s]*/", // Identifiers starting with at least 3 capital letters
// Project specific exclusions start here
"/\/\/ copyright-holders.*/",
"/\/\/- Pinalias:/",
"/\/\/#.*/" // commented source code
]
}
]
}

View File

@ -111,7 +111,7 @@ TIDY_DB = $(OBJ)/compile_commands.json
#LTO decreases performance :-( #LTO decreases performance :-(
#LTO = -flto=4 -fuse-linker-plugin -Wodr #LTO = -flto=4 -fuse-linker-plugin -Wodr
CCOREFLAGS = -g -O3 -std=c++17 -I$(SRC) CCOREFLAGS = -g -O3 -std=c++17 -I$(SRC) -I$(SRC)/..
CFLAGS = $(LTO) $(CCOREFLAGS) $(CEXTRAFLAGS) CFLAGS = $(LTO) $(CCOREFLAGS) $(CEXTRAFLAGS)
LDFLAGS = $(LTO) -g -O3 -std=c++17 $(LDEXTRAFLAGS) LDFLAGS = $(LTO) -g -O3 -std=c++17 $(LDEXTRAFLAGS)
@ -172,6 +172,16 @@ CORESOURCES := \
MAINSOURCES = $(SRC)/prg/nltool.cpp $(SRC)/prg/nlwav.cpp MAINSOURCES = $(SRC)/prg/nltool.cpp $(SRC)/prg/nlwav.cpp
HEADERS = $(wildcard $(SRC)/analog/*.h)
HEADERS += $(wildcard $(SRC)/core/*.h)
HEADERS += $(wildcard $(SRC)/devices/*.h)
HEADERS += $(wildcard $(SRC)/solver/*.h)
HEADERS += $(wildcard $(SRC)/tools/*.h)
HEADERS += $(wildcard $(SRC)/*.h)
HEADERS += $(wildcard $(SRC)/generated/*.h)
PHEADERS = $(wildcard $(SRC)/plib/*.h)
PSOURCES := \ PSOURCES := \
$(PSRC)/pstring.cpp \ $(PSRC)/pstring.cpp \
$(PSRC)/pdynlib.cpp \ $(PSRC)/pdynlib.cpp \
@ -191,15 +201,18 @@ TESTOBJS = $(patsubst $(SRC)%, $(OBJ)%, $(TESTSOURCES:.cpp=.o))
MAINOBJS = $(patsubst $(SRC)%, $(OBJ)%, $(MAINSOURCES:.cpp=.o)) MAINOBJS = $(patsubst $(SRC)%, $(OBJ)%, $(MAINSOURCES:.cpp=.o))
POBJS = $(patsubst $(SRC)%, $(OBJ)%, $(PSOURCES:.cpp=.o)) POBJS = $(patsubst $(SRC)%, $(OBJ)%, $(PSOURCES:.cpp=.o))
OBJS = $(POBJS) $(NLOBJS) $(NLDEVOBJS) $(TESTOBJS) OBJS = $(TESTOBJS) $(POBJS) $(NLOBJS) $(NLDEVOBJS) $(TESTOBJS)
VSBUILDS = \ VSFILES = \
$(VSBUILD/netlistlib.vcxproj) \ $(VSBUILD)/netlistlib.vcxproj \
$(VSBUILD/netlistlib.vcxproj.user \ $(VSBUILD)/netlistlib.vcxproj.filters \
$(VSBUILD/nltool.vcxproj \ $(VSBUILD)/nltool.vcxproj \
$(VSBUILD/netlistlib.vcxproj.filters \ $(VSBUILD)/nltool.vcxproj.filters \
$(VSBUILD/nltool.vcxproj.filters \ $(VSBUILD)/nlwav.vcxproj \
$(VSBUILD/netlist.sln \ $(VSBUILD)/nlwav.vcxproj.filters \
$(VSBUILD)/netlist.sln \
OTHERFILES = makefile
DOCS = \ DOCS = \
doxygen.conf \ doxygen.conf \
@ -213,7 +226,8 @@ ALL_OBJS = $(OBJS) $(MAINOBJS)
ALL_TIDY_FILES = $(ALL_OBJS:.o=.json) ALL_TIDY_FILES = $(ALL_OBJS:.o=.json)
ALLSOURCES = $(DEVSOURCES) $(CORESOURCES) $(TESTSOURCES) $(MAINSOURCES) $(PSOURCES) ALLSOURCES = $(DEVSOURCES) $(CORESOURCES) $(TESTSOURCES) $(MAINSOURCES) $(PSOURCES)
ALLFILES = $(ALLSOURCES) $(VSBUILDS) $(DOCS) ALLHEADERS = $(HEADERS) $(PHEADERS)
ALLFILES = $(ALLSOURCES) $(VSFILES) $(DOCS) $(OTHERFILES)
MAKEFILE_TARGETS_WITHOUT_INCLUDE := \ MAKEFILE_TARGETS_WITHOUT_INCLUDE := \
clang clang-5 clang-libc gcc9 mingw native nvcc \ clang clang-5 clang-libc gcc9 mingw native nvcc \
@ -270,10 +284,10 @@ maketree: $(sort $(BUILD_DIRS))
#------------------------------------------------- #-------------------------------------------------
native: native:
$(MAKE) CEXTRAFLAGS="-march=native -msse4.2 -Wall -Wpedantic -Wsign-compare -Wextra " $(MAKE) CEXTRAFLAGS="-march=native -msse4.2 -Wall -Wpedantic -Wsign-compare -Wextra"
gcc9: gcc9:
$(MAKE) CC=g++-9 LD=g++-9 CEXTRAFLAGS="-march=native -Wall -pedantic -Wpedantic -fext-numeric-literals -Wsign-compare -Wextra" EXTRALIBS="-lquadmath" $(MAKE) CC=g++-9 LD=g++-9 CEXTRAFLAGS="-march=native -Wall -pedantic -Wpedantic -fext-numeric-literals -Wsign-compare -Wextra" EXTRALIBS="-lquadmath" OBJ=obj/gcc9
emsdk: emsdk:
emmake $(MAKE) CC=emcc LD=emcc CEXTRAFLAGS="-fexceptions" LDEXTRAFLAGS="-fexceptions --emrun" OBJ=obj/emsdk EXESUFFIX=.html emmake $(MAKE) CC=emcc LD=emcc CEXTRAFLAGS="-fexceptions" LDEXTRAFLAGS="-fexceptions --emrun" OBJ=obj/emsdk EXESUFFIX=.html
@ -311,7 +325,7 @@ clang-libc:
nvcc: nvcc:
$(MAKE) CC=/usr/local/cuda-11.3/bin/nvcc LD=/usr/local/cuda-11.3/bin/nvcc \ $(MAKE) CC=/usr/local/cuda-11.3/bin/nvcc LD=/usr/local/cuda-11.3/bin/nvcc \
OBJ=obj/nvcc CEXTRAFLAGS="--std c++17 -x cu -DNVCCBUILD=113 --expt-extended-lambda \ OBJ=obj/nvcc CEXTRAFLAGS="--std c++17 -x cu --expt-extended-lambda \
--expt-relaxed-constexpr --default-stream per-thread --restrict \ --expt-relaxed-constexpr --default-stream per-thread --restrict \
--ftemplate-depth 1024 \ --ftemplate-depth 1024 \
-Xcompiler -O6 -Xcompiler -march=native -ccbin g++-9 " \ -Xcompiler -O6 -Xcompiler -march=native -ccbin g++-9 " \
@ -322,6 +336,12 @@ mingw:
-DWIN32_LEAN_AND_MEAN" LDEXTRAFLAGS="-Wl,--subsystem,console \ -DWIN32_LEAN_AND_MEAN" LDEXTRAFLAGS="-Wl,--subsystem,console \
-municode" LIBS= MD=@mkdir.exe SHELL=sh.exe DOXYGEN=doxygen.exe $(PARAMS) -municode" LIBS= MD=@mkdir.exe SHELL=sh.exe DOXYGEN=doxygen.exe $(PARAMS)
mingw-cross:
${MAKE} CC="x86_64-w64-mingw32-g++-posix" LD="x86_64-w64-mingw32-g++-posix" \
CEXTRAFLAGS="-DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0501 -DWIN32_LEAN_AND_MEAN" \
LDEXTRAFLAGS="-Wl,--subsystem,console -municode" OBJ=obj/mingw-cross \
EXESUFFIX=.exe LIBS=
#------------------------------------------------- #-------------------------------------------------
# regression tests # regression tests
#------------------------------------------------- #-------------------------------------------------
@ -343,6 +363,10 @@ doc:
./nltool$(EXESUFFIX) -c docheader > ../documentation/devsyn.dox.h ./nltool$(EXESUFFIX) -c docheader > ../documentation/devsyn.dox.h
$(DOXYGEN) doxygen.conf $(DOXYGEN) doxygen.conf
NLOBJS = $(patsubst $(SRC)%, $(OBJ)%, $(CORESOURCES:.cpp=.o))
cspell:
cd .. && cspell -c build/cspell.json --no-color --relative $(patsubst $(SRC)/%, %, $(ALLHEADERS) $(ALLSOURCES)) | sed -e "s/ - Unknown/: error: Unknown/g"
#------------------------------------------------- #-------------------------------------------------
# depends # depends
#------------------------------------------------- #-------------------------------------------------
@ -383,6 +407,20 @@ $(SRC)/generated/nlm_modules_lib.cpp: $(MODULESOURCES)
.PHONY: generated .PHONY: generated
generated: $(SRC)/generated/lib_entries.hxx $(SRC)/generated/nld_devinc.h $(SRC)/generated/nlm_modules_lib.cpp generated: $(SRC)/generated/lib_entries.hxx $(SRC)/generated/nld_devinc.h $(SRC)/generated/nlm_modules_lib.cpp
#-------------------------------------------------
# fix permissions, source management
#-------------------------------------------------
fix_permissions:
@find .. -executable -and -not -type d -print | grep -v /build | xargs -r chmod a-x
@chmod a-x $(ALLFILES)
@find .. -print | xargs setfacl -b
srcclean: $(ALLSOURCES) $(ALLHEADERS)
@../../../../srcclean -u $(ALLSOURCES) $(ALLHEADERS)
precommit: fix_permissions srcclean
#------------------------------------------------- #-------------------------------------------------
# clang tidy # clang tidy
#------------------------------------------------- #-------------------------------------------------

0
src/lib/netlist/buildVS/netlist.sln Executable file → Normal file
View File

0
src/lib/netlist/buildVS/netlistlib.vcxproj Executable file → Normal file
View File

0
src/lib/netlist/buildVS/netlistlib.vcxproj.filters Executable file → Normal file
View File

0
src/lib/netlist/buildVS/nltool.vcxproj Executable file → Normal file
View File

0
src/lib/netlist/buildVS/nltool.vcxproj.filters Executable file → Normal file
View File

0
src/lib/netlist/buildVS/nlwav.vcxproj Executable file → Normal file
View File

0
src/lib/netlist/buildVS/nlwav.vcxproj.filters Executable file → Normal file
View File

View File

@ -201,7 +201,7 @@ namespace netlist::detail {
/// Going forward setting this to 8 will allow 8-bit signal /// Going forward setting this to 8 will allow 8-bit signal
/// busses to be used in netlist, e.g. for more complex memory /// busses to be used in netlist, e.g. for more complex memory
/// arrangements. /// arrangements.
/// Mimimum value is 2 here to support tristate output on proxies. /// Minimum value is 2 here to support tristate output on proxies.
static constexpr const unsigned int INP_BITS = 2; static constexpr const unsigned int INP_BITS = 2;
static constexpr const unsigned int INP_MASK = (1 << INP_BITS) - 1; static constexpr const unsigned int INP_MASK = (1 << INP_BITS) - 1;
@ -264,9 +264,8 @@ namespace netlist::detail {
state_var_sig m_Q; state_var_sig m_Q;
#else #else
void set_copied_input(const netlist_sig_t &val) const noexcept { plib::unused_var(val); } // NOLINT: static means more message elsewhere void set_copied_input([[maybe_unused]] const netlist_sig_t &val) const noexcept { } // NOLINT: static means more message elsewhere
#endif #endif
void set_delegate(const nldelegate &delegate) noexcept { m_delegate = delegate; } void set_delegate(const nldelegate &delegate) noexcept { m_delegate = delegate; }
const nldelegate &delegate() const noexcept { return m_delegate; } const nldelegate &delegate() const noexcept { return m_delegate; }
void run_delegate() const noexcept { return m_delegate(); } void run_delegate() const noexcept { return m_delegate(); }

View File

@ -85,7 +85,8 @@ namespace netlist
log_type & log(); log_type & log();
public: public:
virtual void timestep(timestep_type ts_type, nl_fptype st) noexcept { plib::unused_var(ts_type, st); } virtual void timestep([[maybe_unused]] timestep_type ts_type,
[[maybe_unused]] nl_fptype st) noexcept { }
virtual void update_terminals() noexcept { } virtual void update_terminals() noexcept { }
virtual void update_param() noexcept {} virtual void update_param() noexcept {}

View File

@ -70,11 +70,10 @@ namespace netlist
// only used by nltool to create static c-code // only used by nltool to create static c-code
devices::nld_solver *solver() const noexcept { return m_solver; } devices::nld_solver *solver() const noexcept { return m_solver; }
// force late type resolution // FIXME: force late type resolution
template <typename X = devices::nld_solver> template <typename X = devices::nld_solver>
nl_fptype gmin(X *solv = nullptr) const noexcept nl_fptype gmin([[maybe_unused]] X *solv = nullptr) const noexcept
{ {
plib::unused_var(solv);
return static_cast<X *>(m_solver)->gmin(); return static_cast<X *>(m_solver)->gmin();
} }

View File

@ -140,10 +140,9 @@ namespace netlist
/// ///
/// This function terminates if actually called. /// This function terminates if actually called.
/// ///
[[noreturn]] static void set_tristate(netlist_sig_t v, [[noreturn]] static void set_tristate([[maybe_unused]] netlist_sig_t v,
netlist_time ts_off_on, netlist_time ts_on_off) [[maybe_unused]] netlist_time ts_off_on, [[maybe_unused]] netlist_time ts_on_off)
{ {
plib::unused_var(v, ts_off_on, ts_on_off);
plib::terminate("set_tristate on logic_output should never be called!"); plib::terminate("set_tristate on logic_output should never be called!");
} }
private: private:

View File

@ -17,11 +17,9 @@
#include "../plib/plists.h" #include "../plib/plists.h"
#include "../plib/pstring.h" #include "../plib/pstring.h"
// Enable the setting below to avoid queue pushes were at execution #ifndef AVOID_NOOP_QUEUE_PUSHES
// no action will be taken. This is academically cleaner, but slower than #error AVOID_NOOP_QUEUE_PUSHES not defined
// allowing this to happen and filter it during during "process". #endif
#define AVOID_NOOP_QUEUE_PUSHES (0)
namespace netlist namespace netlist
{ {
@ -72,12 +70,12 @@ namespace netlist
m_next_scheduled_time = exec().time() + delay; m_next_scheduled_time = exec().time() + delay;
#if (AVOID_NOOP_QUEUE_PUSHES) #if (AVOID_NOOP_QUEUE_PUSHES)
m_in_queue = (m_list_active.empty() ? queue_status::DELAYED_DUE_TO_INACTIVE m_in_queue = (m_list_active.empty() ? queue_status::DELAYED_DUE_TO_INACTIVE
: (m_new_Q != m_cur_Q ? queue_status::QUEUED : queue_status::DELIVERED)); : (m_new_Q != m_cur_Q ? queue_status::QUEUED : queue_status::DELIVERED));
if (m_in_queue == queue_status::QUEUED) if (m_in_queue == queue_status::QUEUED)
exec().qpush(m_next_scheduled_time, this); exec().qpush(m_next_scheduled_time, this);
else else
update_inputs(); update_inputs();
#else #else
m_in_queue = m_list_active.empty() ? queue_status::DELAYED_DUE_TO_INACTIVE : queue_status::QUEUED; m_in_queue = m_list_active.empty() ? queue_status::DELAYED_DUE_TO_INACTIVE : queue_status::QUEUED;
if (m_in_queue == queue_status::QUEUED) if (m_in_queue == queue_status::QUEUED)

View File

@ -76,9 +76,8 @@ namespace netlist::detail
manager.save_item(this, &m_times[0], module + "." + "times", m_times.size()); manager.save_item(this, &m_times[0], module + "." + "times", m_times.size());
manager.save_item(this, &m_net_ids[0], module + "." + "names", m_net_ids.size()); manager.save_item(this, &m_net_ids[0], module + "." + "names", m_net_ids.size());
} }
void on_pre_save(plib::state_manager_t &manager) override void on_pre_save([[maybe_unused]] plib::state_manager_t &manager) override
{ {
plib::unused_var(manager);
m_qsize = this->size(); m_qsize = this->size();
for (std::size_t i = 0; i < m_qsize; i++ ) for (std::size_t i = 0; i < m_qsize; i++ )
{ {
@ -86,9 +85,8 @@ namespace netlist::detail
m_net_ids[i] = m_get_id(this->listptr()[i].object()); m_net_ids[i] = m_get_id(this->listptr()[i].object());
} }
} }
void on_post_load(plib::state_manager_t &manager) override void on_post_load([[maybe_unused]] plib::state_manager_t &manager) override
{ {
plib::unused_var(manager);
this->clear(); this->clear();
for (std::size_t i = 0; i < m_qsize; i++ ) for (std::size_t i = 0; i < m_qsize; i++ )
{ {

View File

@ -250,7 +250,7 @@ namespace netlist::devices {
{ {
return ((in[0]() ^ 1) | (in[1]() ^ 1)) & in[2](); // (~A1 | ~A2) & B return ((in[0]() ^ 1) | (in[1]() ^ 1)) & in[2](); // (~A1 | ~A2) & B
} }
template<typename T> static constexpr netlist_sig_t clear(const T &in) { plib::unused_var(in); return 1;} template<typename T> static constexpr netlist_sig_t clear( [[maybe_unused]] const T &in) { return 1; }
}; };
struct desc_9602 : public desc_74123 struct desc_9602 : public desc_74123

View File

@ -26,7 +26,7 @@
*********************************************************************** ***********************************************************************
Function Table: Function Table:
+-------------------------+----------------+ +-------------------------+----------------+
| Inputs | Qutputs* | | Inputs | Outputs* |
+-------+-------+---------+----------------+ +-------+-------+---------+----------------+
| Clear | Clock | A B | QA QB ... QH | | Clear | Clock | A B | QA QB ... QH |
+-------+-------+---------+----------------+ +-------+-------+---------+----------------+

View File

@ -1,9 +1,10 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Couriersud // copyright-holders:Couriersud
/*
* nlid_proxy.cpp ///
* /// \file nlid_proxy.cpp
*/ ///
///
#include "nlid_proxy.h" #include "nlid_proxy.h"
#include "core/setup.h" #include "core/setup.h"

View File

@ -1411,7 +1411,7 @@ NETLIST_END()
//- Package: DIP //- Package: DIP
//- NamingConvention: Naming conventions follow National Semiconductor datasheet //- NamingConvention: Naming conventions follow National Semiconductor datasheet
//- FunctionTable: //- FunctionTable:
//- pdf.datasheetcatalog.com/datasheet/nationalsemiconductor/DS006367.PDF //- http://pdf.datasheetcatalog.com/datasheet/nationalsemiconductor/DS006367.PDF
//- //-
//- +------+-----+---+---++---+----+ //- +------+-----+---+---++---+----+
//- | CLRQ | CLK | J | K || Q | QQ | //- | CLRQ | CLK | J | K || Q | QQ |
@ -2658,7 +2658,7 @@ static NETLIST_START(TTL_9312_DIP)
) )
NETLIST_END() NETLIST_END()
// FIXME: Documenation // FIXME: Documentation
static NETLIST_START(TTL_9314_DIP) static NETLIST_START(TTL_9314_DIP)
TTL_9314(A) TTL_9314(A)
@ -2750,7 +2750,7 @@ static NETLIST_START(TTL_9321_DIP)
NETLIST_END() NETLIST_END()
//FIXME: Documenation //FIXME: Documentation
static NETLIST_START(TTL_9334_DIP) static NETLIST_START(TTL_9334_DIP)
TTL_9334(A) TTL_9334(A)

View File

@ -216,7 +216,7 @@ namespace netlist
ENTRY_EX(config::use_float_matrix::value) ENTRY_EX(config::use_float_matrix::value)
ENTRY_EX(config::use_long_double_matrix::value) ENTRY_EX(config::use_long_double_matrix::value)
ENTRY(NL_DEBUG) ENTRY(NL_DEBUG)
ENTRY(NVCCBUILD) ENTRY(__NVCC__)
ENTRY(__cplusplus) ENTRY(__cplusplus)
ENTRY(__VERSION__) ENTRY(__VERSION__)
@ -275,7 +275,7 @@ namespace netlist
void netlist_t::reset() void netlist_t::reset()
{ {
log().debug("Searching for mainclock\n"); log().debug("Searching for main clock\n");
m_mainclock = m_state.get_single_device<devices::NETLIB_NAME(mainclock)>("mainclock"); m_mainclock = m_state.get_single_device<devices::NETLIB_NAME(mainclock)>("mainclock");
log().debug("Searching for solver\n"); log().debug("Searching for solver\n");
@ -447,7 +447,7 @@ namespace netlist
{ {
auto *ep = entry.second.get(); auto *ep = entry.second.get();
auto *stats = ep->stats(); auto *stats = ep->stats();
// Factor of 3 offers best performace increase // Factor of 3 offers best performance increase
if (stats->m_stat_inc_active() > 3 * stats->m_stat_total_time.count() if (stats->m_stat_inc_active() > 3 * stats->m_stat_total_time.count()
&& stats->m_stat_inc_active() > trigger) && stats->m_stat_inc_active() > trigger)
log().verbose("HINT({}, NO_DEACTIVATE) // {} {} {}", ep->name(), log().verbose("HINT({}, NO_DEACTIVATE) // {} {} {}", ep->name(),
@ -725,7 +725,7 @@ namespace netlist
// NOLINTNEXTLINE(readability-implicit-bool-conversion) // NOLINTNEXTLINE(readability-implicit-bool-conversion)
if (!(gt && go && Idr) && (gt || go || Idr)) if (!(gt && go && Idr) && (gt || go || Idr))
{ {
throw nl_exception("Inconsistent nullptrs for terminal {}", name()); throw nl_exception("Either all pointers must be set or none for terminal {}", name());
} }
m_gt = gt; m_gt = gt;
@ -768,11 +768,10 @@ namespace netlist
// logic_output_t // logic_output_t
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
logic_output_t::logic_output_t(device_t &dev, const pstring &aname, bool dummy) logic_output_t::logic_output_t(device_t &dev, const pstring &aname, [[maybe_unused]] bool dummy)
: logic_t(dev, aname, STATE_OUT, nldelegate()) : logic_t(dev, aname, STATE_OUT, nldelegate())
, m_my_net(dev.state(), name() + ".net", this) , m_my_net(dev.state(), name() + ".net", this)
{ {
plib::unused_var(dummy);
this->set_net(&m_my_net); this->set_net(&m_my_net);
state().register_net(device_arena::owned_ptr<logic_net_t>(&m_my_net, false)); state().register_net(device_arena::owned_ptr<logic_net_t>(&m_my_net, false));
state().setup().register_term(*this); state().setup().register_term(*this);
@ -829,7 +828,7 @@ namespace netlist
// Parameters ... // Parameters ...
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// deviceless, it's the responsibility of the owner to register! // device-less, it's the responsibility of the owner to register!
param_t::param_t(const pstring &name) param_t::param_t(const pstring &name)
: device_object_t(nullptr, name) : device_object_t(nullptr, name)
{ {
@ -880,7 +879,7 @@ namespace netlist
param_str_t::param_str_t(netlist_state_t &state, const pstring &name, const pstring &val) param_str_t::param_str_t(netlist_state_t &state, const pstring &name, const pstring &val)
: param_t(name) : param_t(name)
{ {
// deviceless parameter, no registration, owner is responsible // device-less parameter, no registration, owner is responsible
m_param = plib::make_unique<pstring, host_arena>(val); m_param = plib::make_unique<pstring, host_arena>(val);
*m_param = state.setup().get_initial_param_val(this->name(),val); *m_param = state.setup().get_initial_param_val(this->name(),val);
} }

View File

@ -44,7 +44,6 @@
/// again. Compiling in all solvers may increase compile /// again. Compiling in all solvers may increase compile
/// time significantly. /// time significantly.
/// ///
#ifndef NL_USE_ACADEMIC_SOLVERS #ifndef NL_USE_ACADEMIC_SOLVERS
#define NL_USE_ACADEMIC_SOLVERS (1) #define NL_USE_ACADEMIC_SOLVERS (1)
#endif #endif
@ -58,33 +57,40 @@
/// By default it is disabled since it is not as fast as /// By default it is disabled since it is not as fast as
/// the default approach. It is up to 20% slower. /// the default approach. It is up to 20% slower.
/// ///
#ifndef NL_USE_COPY_INSTEAD_OF_REFERENCE #ifndef NL_USE_COPY_INSTEAD_OF_REFERENCE
#define NL_USE_COPY_INSTEAD_OF_REFERENCE (0)//FIXME: Move to config struct later #define NL_USE_COPY_INSTEAD_OF_REFERENCE (0) // FIXME: Move to config struct later
#endif #endif
/// \brief Use backward Euler integration /// \brief Use backward Euler integration
/// ///
/// This will use backward Euler instead of trapezoidal integration. /// This will use backward Euler instead of trapezoidal integration.
/// ///
/// FIXME: Longterm this will become a runtime setting. Only the capacitor model /// FIXME: Long term this will become a runtime setting. Only the capacitor model
/// currently has a trapezoidal version and there is no support currently for /// currently has a trapezoidal version and there is no support currently for
/// variable capacitors. /// variable capacitors.
/// The change will have impact on timings since trapezoidal improves timing /// The change will have impact on timings since trapezoidal improves timing
/// accuracy. /// accuracy.
#ifndef NL_USE_BACKWARD_EULER #ifndef NL_USE_BACKWARD_EULER
#define NL_USE_BACKWARD_EULER (1) #define NL_USE_BACKWARD_EULER (1) // FIXME: Move to config struct later
#endif #endif
/// \brief Use the __float128 type for matrix calculations. /// \brief Compile matrix solvers using the __float128 type.
/// ///
/// Defaults to \ref PUSE_FLOAT128 /// Defaults to \ref PUSE_FLOAT128
#ifndef NL_USE_FLOAT128 #ifndef NL_USE_FLOAT128
#define NL_USE_FLOAT128 PUSE_FLOAT128 #define NL_USE_FLOAT128 PUSE_FLOAT128
#endif #endif
/// \brief Avoid unnecessary queue pushes
///
/// Enable the setting below to avoid queue pushes were at execution
/// no action will be taken. This is academically cleaner, but slower than
/// allowing this to happen and filter it during during "process".
/// This is used in core/nets.h
#ifndef AVOID_NOOP_QUEUE_PUSHES
#define AVOID_NOOP_QUEUE_PUSHES (0) // FIXME: Move to config struct later
#endif
//============================================================ //============================================================
// DEBUGGING // DEBUGGING
//============================================================ //============================================================
@ -149,8 +155,8 @@ namespace netlist
/// \brief Resolution as clocks per second for timing /// \brief Resolution as clocks per second for timing
/// ///
/// Uses 100 pico second resolution. This is aligned to MAME's /// Uses 100 picosecond resolution. This is aligned to MAME's
/// attotime resolution. /// `attotime` resolution.
/// ///
/// The table below shows the maximum run times depending on /// The table below shows the maximum run times depending on
/// time type size and resolution. /// time type size and resolution.

View File

@ -53,7 +53,7 @@ namespace netlist
PERRMSGV(MF_TT_LINE_WITHOUT_HEAD, 0, "TT_LINE found without TT_HEAD") PERRMSGV(MF_TT_LINE_WITHOUT_HEAD, 0, "TT_LINE found without TT_HEAD")
PERRMSGV(MF_LOCAL_SOURCE_NOT_FOUND_1, 1, "Local source not found: <{1}>") PERRMSGV(MF_LOCAL_SOURCE_NOT_FOUND_1, 1, "Local source not found: <{1}>")
PERRMSGV(MF_EXTERNAL_SOURCE_IS_LOCAL_1, 1, "External lib entry appears as a local one: <{1}>") PERRMSGV(MF_EXTERNAL_SOURCE_IS_LOCAL_1, 1, "External lib entry appears as a local one: <{1}>")
PERRMSGV(MF_TRUTHTABLE_NOT_FOUND_1, 1, "Truthtable not found: <{1}>") PERRMSGV(MF_TRUTHTABLE_NOT_FOUND_1, 1, "Truth table not found: <{1}>")
// nl_setup.cpp // nl_setup.cpp
@ -99,7 +99,7 @@ namespace netlist
PERRMSGV(MW_CONNECTING_1_TO_ITSELF, 1, "Connecting net {1} to itself.") PERRMSGV(MW_CONNECTING_1_TO_ITSELF, 1, "Connecting net {1} to itself.")
PERRMSGV(MI_CONNECTING_1_TO_2_SAME_NET, 3, "Connecting terminals {1} and {2} which are already both on net {3}. " PERRMSGV(MI_CONNECTING_1_TO_2_SAME_NET, 3, "Connecting terminals {1} and {2} which are already both on net {3}. "
"It is ok if you read this warning and it relates to pin which is connected internally to GND and the schematics " "It is ok if you read this warning and it relates to pin which is connected internally to GND and the schematics "
"show an external connection as well. Onde example is the CD4538. In other cases this warning may indicate " "show an external connection as well. One example is the CD4538. In other cases this warning may indicate "
"an error in your netlist.") "an error in your netlist.")
PERRMSGV(ME_NC_PIN_1_WITH_CONNECTIONS, 1, "Found NC (not connected) terminal {1} with connections") PERRMSGV(ME_NC_PIN_1_WITH_CONNECTIONS, 1, "Found NC (not connected) terminal {1} with connections")
PERRMSGV(MI_ANALOG_OUTPUT_1_WITHOUT_CONNECTIONS,1, "Found analog output {1} without connections") PERRMSGV(MI_ANALOG_OUTPUT_1_WITHOUT_CONNECTIONS,1, "Found analog output {1} without connections")
@ -119,7 +119,7 @@ namespace netlist
"but has been forced to act as a logic output. Parameter " "but has been forced to act as a logic output. Parameter "
" FORCE_TRISTATE_LOGIC for device {2} needs to be disabled!.") " FORCE_TRISTATE_LOGIC for device {2} needs to be disabled!.")
PERRMSGV(MI_REMOVE_DEVICE_1_CONNECTED_ONLY_TO_RAILS_2_3, 3, "Found device {1} connected only to railterminals {2}/{3}." PERRMSGV(MI_REMOVE_DEVICE_1_CONNECTED_ONLY_TO_RAILS_2_3, 3, "Found device {1} connected only to rail terminals {2}/{3}."
" This may reflect the schematic - but as well be an error. Please review.") " This may reflect the schematic - but as well be an error. Please review.")
PERRMSGV(MW_DATA_1_NOT_FOUND, 1, "unable to find data {1} in sources collection") PERRMSGV(MW_DATA_1_NOT_FOUND, 1, "unable to find data {1} in sources collection")
@ -140,7 +140,7 @@ namespace netlist
// nld_matrix_solver.cpp // nld_matrix_solver.cpp
PERRMSGV(MF_UNHANDLED_ELEMENT_1_FOUND, 1, "setup_base:unhandled element <{1}> found") PERRMSGV(MF_UNHANDLED_ELEMENT_1_FOUND, 1, "setup_base:unhandled element <{1}> found")
PERRMSGV(MF_FOUND_TERM_WITH_MISSING_OTHERNET, 1, "found term with missing othernet {1}") PERRMSGV(MF_FOUND_TERM_WITH_MISSING_OTHERNET, 1, "found term with missing other net {1}")
PERRMSGV(MW_NEWTON_LOOPS_EXCEEDED_INVOCATION_3, 3, "NEWTON_LOOPS exceeded resolution invoked {1} times on net {2} at {3} us") PERRMSGV(MW_NEWTON_LOOPS_EXCEEDED_INVOCATION_3, 3, "NEWTON_LOOPS exceeded resolution invoked {1} times on net {2} at {3} us")
PERRMSGV(MW_NEWTON_LOOPS_EXCEEDED_ON_NET_2, 2, "NEWTON_LOOPS exceeded resolution failed on net {1} ... reschedule at {2} us") PERRMSGV(MW_NEWTON_LOOPS_EXCEEDED_ON_NET_2, 2, "NEWTON_LOOPS exceeded resolution failed on net {1} ... reschedule at {2} us")

View File

@ -129,7 +129,6 @@ namespace factory {
const pstring &name, std::tuple<Args...>& args, std::index_sequence<Is...>) const pstring &name, std::tuple<Args...>& args, std::index_sequence<Is...>)
{ {
return plib::make_unique<C>(pool, anetlist, name, std::forward<Args>(std::get<Is>(args))...); return plib::make_unique<C>(pool, anetlist, name, std::forward<Args>(std::get<Is>(args))...);
//return anetlist.make_pool_object<C>(anetlist, name, std::forward<Args>(std::get<Is>(args))...);
} }
dev_uptr make_device(device_arena &pool, dev_uptr make_device(device_arena &pool,
@ -144,7 +143,6 @@ namespace factory {
const pstring &name) override const pstring &name) override
{ {
return make_device(pool, anetlist, name, m_args); return make_device(pool, anetlist, name, m_args);
//return pool.make_unique<C>(anetlist, name);
} }
static uptr create(const pstring &name, properties &&props, Args&&... args) static uptr create(const pstring &name, properties &&props, Args&&... args)

View File

@ -33,6 +33,7 @@ namespace netlist
/// The following code is an example on how to add the device to /// The following code is an example on how to add the device to
/// the netlist factory. /// the netlist factory.
/// ///
/// ```
/// const pstring pin(m_in); /// const pstring pin(m_in);
/// pstring dname = pstring("OUT_") + pin; /// pstring dname = pstring("OUT_") + pin;
/// ///
@ -48,7 +49,7 @@ namespace netlist
/// ///
/// parser.factory().add<cb_t, netlist::nl_fptype, lb_t>(dname, /// parser.factory().add<cb_t, netlist::nl_fptype, lb_t>(dname,
/// netlist::factory::properties("-", PSOURCELOC()), 1e-6, std::forward<lb_t>(lambda)); /// netlist::factory::properties("-", PSOURCELOC()), 1e-6, std::forward<lb_t>(lambda));
/// /// ```
template <typename FUNC> template <typename FUNC>
NETLIB_OBJECT(analog_callback) NETLIB_OBJECT(analog_callback)
@ -160,7 +161,6 @@ namespace netlist
if (m_buffer != nullptr) if (m_buffer != nullptr)
{ {
const nl_fptype v = (*m_buffer)[m_pos]; const nl_fptype v = (*m_buffer)[m_pos];
//m_params[i]->set(v * m_param_mults[i]() + m_param_offsets[i]());
m_param_setter(v * m_param_mult() + m_param_offset()); m_param_setter(v * m_param_mult() + m_param_offset());
} }
} }

View File

@ -576,9 +576,8 @@ bool source_token_t::parse(nlparse_t &setup, const pstring &name)
return false; return false;
} }
plib::istream_uptr source_token_t::stream(const pstring &name) plib::istream_uptr source_token_t::stream([[maybe_unused]] const pstring &name)
{ {
plib::unused_var(name);
return plib::istream_uptr(); return plib::istream_uptr();
} }

View File

@ -135,7 +135,7 @@ namespace netlist
} }
pstring paramfq = name + "." + tp; pstring paramfq = name + "." + tp;
log().debug("Defparam: {1}\n", paramfq); log().debug("Default parameter: {1}\n", paramfq);
register_param(paramfq, *ptok); register_param(paramfq, *ptok);
@ -496,12 +496,12 @@ pstring setup_t::termtype_as_str(detail::core_terminal_t &in)
pstring setup_t::get_initial_param_val(const pstring &name, const pstring &def) const pstring setup_t::get_initial_param_val(const pstring &name, const pstring &def) const
{ {
// when get_intial_param_val is called the parameter <name> is already registered // When `get_intial_param_val` is called the parameter `<name>` is already registered
// and the value (valstr()) is set to the default value, e.g. "74XX" // and the value `(valstr())` is set to the default value, e.g. "74XX"
// If thus $(IC5E.A.MODEL) is given for name=="IC5E.A.MODEL" valstr() below // If thus `$(IC5E.A.MODEL)` is given for `name=="IC5E.A.MODEL"` `valstr()` below
// will return the default. // will return the default.
// FIXME: It may be more explicit and stable to test if pattern==name and return // FIXME: It may be more explicit and stable to test if pattern==name and return
// def in this case. // `def` in this case.
auto i = m_abstract.m_param_values.find(name); auto i = m_abstract.m_param_values.find(name);
auto found_pat(false); auto found_pat(false);
@ -839,7 +839,7 @@ void setup_t::merge_nets(detail::net_t &thisnet, detail::net_t &othernet)
if (othernet.is_rail_net()) if (othernet.is_rail_net())
{ {
log().debug("othernet is railnet\n"); log().debug("other net is a rail net\n");
merge_nets(othernet, thisnet); merge_nets(othernet, thisnet);
} }
else else
@ -1704,25 +1704,22 @@ bool source_netlist_t::parse(nlparse_t &setup, const pstring &name)
return (!strm.empty()) ? setup.parse_stream(std::move(strm), name) : false; return (!strm.empty()) ? setup.parse_stream(std::move(strm), name) : false;
} }
plib::istream_uptr source_string_t::stream(const pstring &name) plib::istream_uptr source_string_t::stream([[maybe_unused]] const pstring &name)
{ {
plib::unused_var(name);
plib::istream_uptr ret(std::make_unique<std::istringstream>(putf8string(m_str)), name); plib::istream_uptr ret(std::make_unique<std::istringstream>(putf8string(m_str)), name);
ret->imbue(std::locale::classic()); ret->imbue(std::locale::classic());
return ret; return ret;
} }
plib::istream_uptr source_mem_t::stream(const pstring &name) plib::istream_uptr source_mem_t::stream( [[maybe_unused]] const pstring &name)
{ {
plib::unused_var(name);
plib::istream_uptr ret(std::make_unique<std::istringstream>(m_str, std::ios_base::binary), name); plib::istream_uptr ret(std::make_unique<std::istringstream>(m_str, std::ios_base::binary), name);
ret->imbue(std::locale::classic()); ret->imbue(std::locale::classic());
return ret; return ret;
} }
plib::istream_uptr source_file_t::stream(const pstring &name) plib::istream_uptr source_file_t::stream( [[maybe_unused]] const pstring &name)
{ {
plib::unused_var(name);
auto f = std::make_unique<plib::ifstream>(plib::filesystem::u8path(m_filename)); auto f = std::make_unique<plib::ifstream>(plib::filesystem::u8path(m_filename));
if (f->is_open()) if (f->is_open())
{ {
@ -1732,7 +1729,7 @@ plib::istream_uptr source_file_t::stream(const pstring &name)
return plib::istream_uptr(); return plib::istream_uptr();
} }
plib::istream_uptr source_pattern_t::stream(const pstring &name) plib::istream_uptr source_pattern_t::stream( [[maybe_unused]] const pstring &name)
{ {
pstring filename = plib::pfmt(m_pattern)(m_force_lowercase ? plib::lcase(name) : name); pstring filename = plib::pfmt(m_pattern)(m_force_lowercase ? plib::lcase(name) : name);
auto f = std::make_unique<plib::ifstream>(plib::filesystem::u8path(filename)); auto f = std::make_unique<plib::ifstream>(plib::filesystem::u8path(filename));
@ -1756,9 +1753,8 @@ bool source_proc_t::parse(nlparse_t &setup, const pstring &name)
return false; return false;
} }
plib::istream_uptr source_proc_t::stream(const pstring &name) plib::istream_uptr source_proc_t::stream( [[maybe_unused]] const pstring &name)
{ {
plib::unused_var(name);
return plib::istream_uptr(); return plib::istream_uptr();
} }

View File

@ -37,7 +37,7 @@
#define DIPPINS(pin1, ...) \ #define DIPPINS(pin1, ...) \
setup.register_dip_alias_arr( # pin1 ", " # __VA_ARGS__); setup.register_dip_alias_arr( # pin1 ", " # __VA_ARGS__);
// to be used to reference new library truthtable devices // to be used to reference new library truth table devices
#define NET_REGISTER_DEV(type, name) \ #define NET_REGISTER_DEV(type, name) \
setup.register_dev(# type, # name); setup.register_dev(# type, # name);
@ -69,9 +69,8 @@
void NETLIST_NAME(name)(netlist::nlparse_t &setup); void NETLIST_NAME(name)(netlist::nlparse_t &setup);
#define NETLIST_START(name) \ #define NETLIST_START(name) \
void NETLIST_NAME(name)(netlist::nlparse_t &setup) \ void NETLIST_NAME(name)([[maybe_unused]] netlist::nlparse_t &setup) \
{ \ { \
plib::unused_var(setup);
#define NETLIST_END() } #define NETLIST_END() }
@ -105,7 +104,7 @@ void NETLIST_NAME(name)(netlist::nlparse_t &setup) \
setup.register_frontier(# attach, PSTRINGIFY_VA(r_in), PSTRINGIFY_VA(r_out)); setup.register_frontier(# attach, PSTRINGIFY_VA(r_in), PSTRINGIFY_VA(r_out));
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// truthtable defines // truth table defines
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#define TRUTHTABLE_START(cname, in, out, pdef_params) \ #define TRUTHTABLE_START(cname, in, out, pdef_params) \
@ -139,7 +138,7 @@ namespace netlist
{ {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// truthtable desc // truth table desc
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
struct tt_desc struct tt_desc
@ -186,7 +185,7 @@ namespace netlist
void register_link(const pstring &sin, const pstring &sout); void register_link(const pstring &sin, const pstring &sout);
void register_link_arr(const pstring &terms); void register_link_arr(const pstring &terms);
// also called from devices for latebinding connected terminals // also called from devices for late binding connected terminals
void register_link_fqn(const pstring &sin, const pstring &sout); void register_link_fqn(const pstring &sin, const pstring &sout);
void register_param(const pstring &param, const pstring &value); void register_param(const pstring &param, const pstring &value);
@ -268,7 +267,6 @@ namespace netlist
plib::psource_collection_t m_sources; plib::psource_collection_t m_sources;
detail::abstract_t & m_abstract; detail::abstract_t & m_abstract;
//std::unordered_map<pstring, parser_t::token_store> m_source_cache;
log_type &m_log; log_type &m_log;
unsigned m_frontier_cnt; unsigned m_frontier_cnt;
}; };

View File

@ -202,9 +202,8 @@ namespace netlist
template<netlist_time::internal_type value0> template<netlist_time::internal_type value0>
struct times_ns1 struct times_ns1
{ {
static constexpr netlist_time value(std::size_t N = 0) static constexpr netlist_time value([[maybe_unused]] std::size_t N = 0)
{ {
plib::unused_var(N);
return NLTIME_FROM_NS(value0); return NLTIME_FROM_NS(value0);
} }
}; };

View File

@ -81,12 +81,11 @@ namespace plib
template <typename FT, int SIZE> template <typename FT, int SIZE>
struct mat_precondition_diag struct mat_precondition_diag
{ {
mat_precondition_diag(std::size_t size, int dummy = 0) mat_precondition_diag(std::size_t size, [[maybe_unused]] int dummy = 0)
: m_mat(size) : m_mat(size)
, m_diag(size) , m_diag(size)
, nzcol(size) , nzcol(size)
{ {
plib::unused_var(dummy);
} }
template <typename M> template <typename M>
@ -120,19 +119,19 @@ namespace plib
// ILUT: 265% // ILUT: 265%
FT v(0.0); FT v(0.0);
#if 0 #if 0
// doesn't works, Mame perforamnce drops significantly% // doesn't works, Mame performance drops significantly%
// 136% // 136%
for (std::size_t j = m_mat.row_idx[i]; j< m_mat.row_idx[i+1]; j++) for (std::size_t j = m_mat.row_idx[i]; j< m_mat.row_idx[i+1]; j++)
v += m_mat.A[j] * m_mat.A[j]; v += m_mat.A[j] * m_mat.A[j];
m_diag[i] = reciprocal(std::sqrt(v)); m_diag[i] = reciprocal(std::sqrt(v));
#elif 0 #elif 0
// works halfway, i.e. Mame perforamnce 50% // works halfway, i.e. Mame performance 50%
// 147% - lowest average solution time with 7.094 // 147% - lowest average solution time with 7.094
for (std::size_t j = m_mat.row_idx[i]; j< m_mat.row_idx[i+1]; j++) for (std::size_t j = m_mat.row_idx[i]; j< m_mat.row_idx[i+1]; j++)
v += m_mat.A[j] * m_mat.A[j]; v += m_mat.A[j] * m_mat.A[j];
m_diag[i] = m_mat.A[m_mat.diag[i]] / v; m_diag[i] = m_mat.A[m_mat.diag[i]] / v;
#elif 0 #elif 0
// works halfway, i.e. Mame perforamnce 50% // works halfway, i.e. Mame performance 50%
// sum over column i // sum over column i
// 344% - lowest average solution time with 3.06 // 344% - lowest average solution time with 3.06
std::size_t nzcolp = 0; std::size_t nzcolp = 0;
@ -145,7 +144,7 @@ namespace plib
} }
m_diag[i] = m_mat.A[m_mat.diag[i]] / v; m_diag[i] = m_mat.A[m_mat.diag[i]] / v;
#elif 0 #elif 0
// works halfway, i.e. Mame perforamnce 50% // works halfway, i.e. Mame performance 50%
// 151% // 151%
for (std::size_t j = m_mat.row_idx[i]; j< m_mat.row_idx[i+1]; j++) for (std::size_t j = m_mat.row_idx[i]; j< m_mat.row_idx[i+1]; j++)
v += plib::abs(m_mat.A[j]); v += plib::abs(m_mat.A[j]);
@ -175,10 +174,9 @@ namespace plib
template <typename FT, int SIZE> template <typename FT, int SIZE>
struct mat_precondition_none struct mat_precondition_none
{ {
mat_precondition_none(std::size_t size, int dummy = 0) mat_precondition_none(std::size_t size, [[maybe_unused]] int dummy = 0)
: m_mat(size) : m_mat(size)
{ {
plib::unused_var(dummy);
} }
template <typename M> template <typename M>
@ -198,9 +196,8 @@ namespace plib
} }
template<typename V> template<typename V>
void solve_inplace(V &v) void solve_inplace([[maybe_unused]] V &v)
{ {
plib::unused_var(v);
} }
plib::pmatrix_cr<FT, SIZE> m_mat; plib::pmatrix_cr<FT, SIZE> m_mat;
@ -344,9 +341,8 @@ namespace plib
} }
template <int k, typename OPS, typename VT> template <int k, typename OPS, typename VT>
bool do_k(OPS &ops, VT &x, std::size_t &itr_used, FT rho_delta, bool dummy) bool do_k(OPS &ops, VT &x, std::size_t &itr_used, FT rho_delta, [[maybe_unused]] bool dummy)
{ {
plib::unused_var(dummy);
if (do_k<k-1, OPS>(ops, x, itr_used, rho_delta, do_khelper<k-1>::value)) if (do_k<k-1, OPS>(ops, x, itr_used, rho_delta, do_khelper<k-1>::value))
return true; return true;

View File

@ -90,15 +90,17 @@ namespace plib {
{ {
using arena_storage_type = P; using arena_storage_type = P;
constexpr arena_deleter_base(arena_storage_type *a = nullptr) noexcept constexpr arena_deleter_base( /*[[maybe_unused]]*/ arena_storage_type *a = nullptr) noexcept
{ {
// gcc 7.2 (mingw) and 7.5 (ubuntu) don't accept maybe_unused here
plib::unused_var(a); plib::unused_var(a);
} }
template<typename U, typename = typename template<typename U, typename = typename
std::enable_if<std::is_convertible< U*, T*>::value>::type> std::enable_if<std::is_convertible< U*, T*>::value>::type>
arena_deleter_base(const arena_deleter_base<P, U, true> &rhs) noexcept arena_deleter_base( /*[[maybe_unused]]*/ const arena_deleter_base<P, U, true> &rhs) noexcept
{ {
// gcc 7.2 (mingw) and 7.5 (ubuntu) don't accept maybe_unused here
plib::unused_var(rhs); plib::unused_var(rhs);
} }
@ -454,9 +456,8 @@ namespace plib {
#endif #endif
} }
bool operator ==(const aligned_arena &rhs) const noexcept bool operator ==([[maybe_unused]] const aligned_arena &rhs) const noexcept
{ {
plib::unused_var(rhs);
return true; return true;
} }
@ -464,10 +465,9 @@ namespace plib {
struct std_arena : public arena_base<std_arena, true, true> struct std_arena : public arena_base<std_arena, true, true>
{ {
static inline void *allocate( size_t alignment, size_t size ) static inline void *allocate([[maybe_unused]] size_t alignment, size_t size )
{ {
inc_alloc_stat(size); inc_alloc_stat(size);
unused_var(alignment);
return ::operator new(size); return ::operator new(size);
} }
@ -477,9 +477,8 @@ namespace plib {
::operator delete(ptr); ::operator delete(ptr);
} }
bool operator ==(const aligned_arena &rhs) const noexcept bool operator ==([[maybe_unused]] const aligned_arena &rhs) const noexcept
{ {
plib::unused_var(rhs);
return true; return true;
} }
}; };
@ -636,9 +635,8 @@ namespace plib {
~paged_arena() = default; ~paged_arena() = default;
static void *allocate(size_t align, size_t size) static void *allocate([[maybe_unused]] size_t align, size_t size)
{ {
plib::unused_var(align);
//size = ((size + PG_SIZE - 1) / PG_SIZE) * PG_SIZE; //size = ((size + PG_SIZE - 1) / PG_SIZE) * PG_SIZE;
return arena().allocate(PG_SIZE, size); return arena().allocate(PG_SIZE, size);
} }

View File

@ -110,7 +110,7 @@ namespace plib {
#if PUSE_ACCURATE_STATS && PHAS_RDTSCP #if PUSE_ACCURATE_STATS && PHAS_RDTSCP
// //
// kills performance completely, but is accurate // kills performance completely, but is accurate
// cpuid serializes, but clobbers ebx and ecx // `cpuid` serializes, but clobbers ebx and ecx
// //
struct exact_ticks : public base_ticks<exact_ticks, int64_t> struct exact_ticks : public base_ticks<exact_ticks, int64_t>

View File

@ -83,8 +83,8 @@
#define PALIGNAS_VECTOROPT() #define PALIGNAS_VECTOROPT()
#endif #endif
// FIXME: Breaks mame build on windows mingw due to -Wattribute // FIXME: Breaks mame build on windows mingw due to `-Wattribute`
// also triggers -Wattribute on ARM // also triggers `-Wattribute` on ARM
// This is fixed on mingw version 10 // This is fixed on mingw version 10
// FIXME: no error on cross-compile - need further checks // FIXME: no error on cross-compile - need further checks
#if defined(__GNUC__) && ((defined(_WIN32) && __GNUC__ < 10) || defined(__arm__) || defined(__ARMEL__)) #if defined(__GNUC__) && ((defined(_WIN32) && __GNUC__ < 10) || defined(__arm__) || defined(__ARMEL__))
@ -115,30 +115,16 @@
// //
//============================================================ //============================================================
#if (NVCCBUILD > 0) #if defined(_MSC_VER)
#if NVCCBUILD >= 101 // Ok
#define NVCC_CONSTEXPR constexpr #elif __cplusplus == 201103L
#else #error c++11 not supported - you need c++17
#define NVCC_CONSTEXPR constexpr #elif __cplusplus == 201402L
#endif #error c++14 not supported - you need c++17
#if NVCCBUILD < 113 #elif __cplusplus == 201703L
#if __cplusplus != 201402L // Ok
#error nvcc - use c++14 to compile
#endif
#endif
#else #else
#define NVCC_CONSTEXPR constexpr #error "C++ version not supported"
#if __cplusplus == 201103L
#error c++11 not supported - you need c++14
#elif __cplusplus == 201402L
// Ok
#elif __cplusplus == 201703L
// Ok
#elif defined(_MSC_VER)
// Ok
#else
#error "C++ version not supported"
#endif
#endif #endif

View File

@ -40,11 +40,10 @@ dynlib::dynlib(const pstring &libname)
// printf("library <%s> not found: %s\n", libname.c_str(), dlerror()); // printf("library <%s> not found: %s\n", libname.c_str(), dlerror());
} }
dynlib::dynlib(const pstring &path, const pstring &libname) dynlib::dynlib( [[maybe_unused]] const pstring &path, const pstring &libname)
: m_lib(nullptr) : m_lib(nullptr)
{ {
// FIXME: implement path search // FIXME: implement path search
plib::unused_var(path);
// printf("win: loading <%s>\n", libname.c_str()); // printf("win: loading <%s>\n", libname.c_str());
#ifdef _WIN32 #ifdef _WIN32
if (!libname.empty()) if (!libname.empty())

View File

@ -7,14 +7,13 @@
/// ///
/// \file pdynlib.h /// \file pdynlib.h
/// ///
/// Dynamic loading of libraries
///
#include "pstring.h" #include "pstring.h"
#include "ptypes.h" #include "ptypes.h"
namespace plib { namespace plib {
// ----------------------------------------------------------------------------------------
// pdynlib: dynamic loading of libraries ...
// ----------------------------------------------------------------------------------------
class dynlib_base class dynlib_base
{ {
@ -46,7 +45,7 @@ namespace plib {
{ {
public: public:
explicit dynlib(const pstring &libname); explicit dynlib(const pstring &libname);
dynlib(const pstring &path, const pstring &libname); dynlib(/*[[maybe_unused]]*/ const pstring &path, const pstring &libname);
~dynlib() override; ~dynlib() override;

View File

@ -104,7 +104,7 @@ namespace plib {
bool fpsignalenabler::m_enable = false; // NOLINT bool fpsignalenabler::m_enable = false; // NOLINT
//FIXME: mingw needs to be compiled with "-fnon-call-exceptions" //FIXME: mingw needs to be compiled with `-fnon-call-exceptions`
fpsignalenabler::fpsignalenabler(unsigned fpexceptions) fpsignalenabler::fpsignalenabler(unsigned fpexceptions)
{ {

View File

@ -83,7 +83,7 @@ namespace plib {
}; };
// FIXME: currently only a stub for later use. More use could be added by // FIXME: currently only a stub for later use. More use could be added by
// using “-fnon-call-exceptions" and sigaction to enable c++ exception supported. // using `-fnon-call-exceptions` and sigaction to enable c++ exception supported.
// //
class fpexception_e : public pexception class fpexception_e : public pexception

View File

@ -15,7 +15,7 @@
#include <cmath> #include <cmath>
#include <type_traits> #include <type_traits>
// quadmath.h included by ptypes.h // `quadmath.h` included by `ptypes.h`
namespace plib namespace plib
{ {

View File

@ -55,12 +55,10 @@ void for_static_np(const I start, const I end, const T &what) noexcept(noexcept(
} }
inline void set_num_threads(const std::size_t threads) noexcept inline void set_num_threads([[maybe_unused]] const std::size_t threads) noexcept
{ {
#if PHAS_OPENMP && PUSE_OPENMP #if PHAS_OPENMP && PUSE_OPENMP
omp_set_num_threads(threads); omp_set_num_threads(threads);
#else
plib::unused_var(threads);
#endif #endif
} }

View File

@ -26,9 +26,8 @@ namespace plib {
return 0; return 0;
} }
int option_bool::parse(const pstring &argument) int option_bool::parse([[maybe_unused]] const pstring &argument)
{ {
unused_var(argument);
m_val = true; m_val = true;
return 0; return 0;
} }

View File

@ -15,7 +15,7 @@
namespace plib { namespace plib {
void mfp_raw<PPMF_TYPE_INTERNAL_ITANIUM>::convert_to_generic(generic_function &func, mfp_generic_class *&object) const void mfp_raw<ppmf_type::INTERNAL_ITANIUM>::convert_to_generic(generic_function &func, mfp_generic_class *&object) const
{ {
// apply the "this" delta to the object first // apply the "this" delta to the object first
// NOLINTNEXTLINE(clang-analyzer-core.UndefinedBinaryOperatorResult,cppcoreguidelines-pro-type-reinterpret-cast) // NOLINTNEXTLINE(clang-analyzer-core.UndefinedBinaryOperatorResult,cppcoreguidelines-pro-type-reinterpret-cast)
@ -42,7 +42,7 @@ namespace plib {
object = o_p_delta; object = o_p_delta;
} }
void mfp_raw<PPMF_TYPE_INTERNAL_ARM>::convert_to_generic(generic_function &func, mfp_generic_class *&object) const void mfp_raw<ppmf_type::INTERNAL_ARM>::convert_to_generic(generic_function &func, mfp_generic_class *&object) const
{ {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
object = reinterpret_cast<mfp_generic_class *>(reinterpret_cast<std::uint8_t *>(object) + (m_this_delta >> 1)); object = reinterpret_cast<mfp_generic_class *>(reinterpret_cast<std::uint8_t *>(object) + (m_this_delta >> 1));
@ -64,9 +64,9 @@ namespace plib {
} }
} }
struct unknown_base_equiv_novtdisp { mfp_raw<PPMF_TYPE_INTERNAL_MSC>::generic_function fptr; int thisdisp, vptrdisp; }; struct unknown_base_equiv_novtdisp { mfp_raw<ppmf_type::INTERNAL_MSC>::generic_function fptr; int thisdisp, vptrdisp; };
void mfp_raw<PPMF_TYPE_INTERNAL_MSC>::convert_to_generic(generic_function &func, mfp_generic_class *&object) const void mfp_raw<ppmf_type::INTERNAL_MSC>::convert_to_generic(generic_function &func, mfp_generic_class *&object) const
{ {
//printf("%lx, %lx, %lx, %lx %lx\n", m_function, m_this_delta, m_vptr_offs, m_vt_index, m_size); //printf("%lx, %lx, %lx, %lx %lx\n", m_function, m_this_delta, m_vptr_offs, m_vt_index, m_size);

View File

@ -20,7 +20,7 @@
/// Use the same approach as MAME for deriving the function pointer. /// Use the same approach as MAME for deriving the function pointer.
/// This is compiler-dependent as well /// This is compiler-dependent as well
/// ///
/// Benchmarks for ./nltool -c run -t 10 -n pongf src/mame/machine/nl_pongf.cpp /// Benchmarks for `./nltool -c run -t 10 -n pongf src/mame/machine/nl_pongf.cpp`
/// ///
/// PMF_TYPE_INTERNAL: 215% 215% 564% 580% /// PMF_TYPE_INTERNAL: 215% 215% 564% 580%
/// PMF_TYPE_GNUC_PMF: 163% 196% 516% 490% /// PMF_TYPE_GNUC_PMF: 163% 196% 516% 490%
@ -31,7 +31,7 @@
/// \brief Enable experimental code on Visual Studio builds and VS clang llvm builds /// \brief Enable experimental code on Visual Studio builds and VS clang llvm builds
/// ///
/// This enables experimental code which uses optimized builds the /// This enables experimental code which uses optimized builds the
/// PPMF_TYPE_INTERNAL_MSC path also for complex (struct/union) return types. /// ppmf_type::INTERNAL_MSC path also for complex (struct/union) return types.
/// This currently depends on whether the code can adequately determine on /// This currently depends on whether the code can adequately determine on
/// x64 builds if the return type is returned through registers or passed as a /// x64 builds if the return type is returned through registers or passed as a
/// second argument as a pointer to the member function. /// second argument as a pointer to the member function.
@ -46,7 +46,9 @@
/// ///
/// This code path is disabled by default currently. /// This code path is disabled by default currently.
/// ///
#if !defined(PPMF_EXPERIMENTAL)
#define PPMF_EXPERIMENTAL 0 #define PPMF_EXPERIMENTAL 0
#endif
/// brief Enable using MAME delegates as a replacement for ppmf. /// brief Enable using MAME delegates as a replacement for ppmf.
/// ///
@ -54,7 +56,9 @@
/// as a replacement to ppmf. Enable this setting if you want to use the nltool /// as a replacement to ppmf. Enable this setting if you want to use the nltool
/// test suite (nltool -c tests) to produce comparisons to ppmf. /// test suite (nltool -c tests) to produce comparisons to ppmf.
/// ///
#if !defined(PPMF_USE_MAME_DELEGATES)
#define PPMF_USE_MAME_DELEGATES 0 #define PPMF_USE_MAME_DELEGATES 0
#endif
#if PPMF_USE_MAME_DELEGATES #if PPMF_USE_MAME_DELEGATES
@ -87,39 +91,43 @@ namespace plib {
//#define PPMF_FORCE_TYPE 0 //#define PPMF_FORCE_TYPE 0
#define PPMF_TYPE_PMF 0
#define PPMF_TYPE_GNUC_PMF_CONV 1
#define PPMF_TYPE_INTERNAL_ITANIUM 2
#define PPMF_TYPE_INTERNAL_ARM 3
#define PPMF_TYPE_INTERNAL_MSC 4
#ifndef PPMF_FORCE_TYPE #ifndef PPMF_FORCE_TYPE
#define PPMF_FORCE_TYPE -1 #define PPMF_FORCE_TYPE -1
#endif #endif
namespace plib { namespace plib {
struct ppmf_internal enum class ppmf_type
{
PMF,
GNUC_PMF_CONV,
INTERNAL_ITANIUM,
INTERNAL_ARM,
INTERNAL_MSC
};
struct ppmf_internal_selector
{ {
using ci = compile_info; using ci = compile_info;
enum { value = constexpr static ppmf_type value =
(PPMF_FORCE_TYPE >= 0) ? PPMF_FORCE_TYPE : (PPMF_FORCE_TYPE >= 0) ? static_cast<ppmf_type>(PPMF_FORCE_TYPE) :
(ci::type() == ci_compiler::CLANG && !ci::m64() (ci::type() == ci_compiler::CLANG && !ci::m64()
&& ci::os() == ci_os::WINDOWS) ? PPMF_TYPE_PMF : && ci::os() == ci_os::WINDOWS) ? ppmf_type::PMF :
(ci::mingw() && !ci::m64() && ci::version() >= 407) ? PPMF_TYPE_PMF : (ci::mingw() && !ci::m64() && ci::version::full() >= typed_version<4,7>::full()) ? ppmf_type::PMF :
(ci::mingw() && !ci::m64()) ? PPMF_TYPE_PMF : // Dropped support for mingw32 < 407 PPMF_TYPE_INTERNAL_ITANIUM : (ci::mingw() && !ci::m64()) ? ppmf_type::PMF : // Dropped support for mingw32 < 407 ppmf_type::INTERNAL_ITANIUM :
(ci::env() == ci_env::MSVC && ci::m64()) ? PPMF_TYPE_INTERNAL_MSC : (ci::env() == ci_env::MSVC && ci::m64()) ? ppmf_type::INTERNAL_MSC :
((ci::type() == ci_compiler::CLANG || ci::type() == ci_compiler::GCC) ((ci::type() == ci_compiler::CLANG || ci::type() == ci_compiler::GCC)
&& (ci::arch() == ci_arch::MIPS && (ci::arch() == ci_arch::MIPS
|| ci::arch() == ci_arch::ARM || ci::arch() == ci_arch::ARM
|| ci::os() == ci_os::EMSCRIPTEN)) ? PPMF_TYPE_INTERNAL_ARM : || ci::os() == ci_os::EMSCRIPTEN)) ? ppmf_type::INTERNAL_ARM :
(ci::type() == ci_compiler::CLANG || ci::type() == ci_compiler::GCC) ? PPMF_TYPE_INTERNAL_ITANIUM : (ci::type() == ci_compiler::CLANG || ci::type() == ci_compiler::GCC) ? ppmf_type::INTERNAL_ITANIUM :
PPMF_TYPE_PMF ppmf_type::PMF
}; ;
}; };
static_assert(!(compile_info::type() == ci_compiler::CLANG && (PPMF_FORCE_TYPE) == (PPMF_TYPE_GNUC_PMF_CONV)), "clang does not support PPMF_TYPE_GNUC_PMF_CONV"); static_assert(!(compile_info::type() == ci_compiler::CLANG && ppmf_internal_selector::value == (ppmf_type::GNUC_PMF_CONV)), "clang does not support ppmf_type::GNUC_PMF_CONV");
static_assert(!(compile_info::type() == ci_compiler::NVCC && (PPMF_FORCE_TYPE) == (PPMF_TYPE_GNUC_PMF_CONV)), "nvcc does not support PPMF_TYPE_GNUC_PMF_CONV"); static_assert(!(compile_info::env() == ci_env::NVCC && ppmf_internal_selector::value == (ppmf_type::GNUC_PMF_CONV)), "nvcc does not support ppmf_type::GNUC_PMF_CONV");
template<typename R, typename... Targs> template<typename R, typename... Targs>
struct mfp_traits struct mfp_traits
@ -138,11 +146,11 @@ namespace plib {
/// ///
/// The following class was derived from the MAME delegate.h code. /// The following class was derived from the MAME delegate.h code.
/// ///
template <int PMFINTERNAL> template <ppmf_type PMFINTERNAL>
class mfp_raw; class mfp_raw;
template <> template <>
class mfp_raw<PPMF_TYPE_INTERNAL_ITANIUM> class mfp_raw<ppmf_type::INTERNAL_ITANIUM>
{ {
public: public:
// construct from any member function pointer // construct from any member function pointer
@ -156,14 +164,14 @@ namespace plib {
// actual state // actual state
uintptr_t 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 even, it's a pointer to the function
// if odd, it's the byte offset into the vtable // if odd, it's the byte offset into the vtable
// or a byte offset into the function descriptors on IA64 // or a byte offset into the function descriptors on IA64
ptrdiff_t m_this_delta; // delta to apply to the 'this' pointer ptrdiff_t m_this_delta; // delta to apply to the 'this' pointer
}; };
template <> template <>
class mfp_raw<PPMF_TYPE_INTERNAL_ARM> class mfp_raw<ppmf_type::INTERNAL_ARM>
{ {
public: public:
// construct from any member function pointer // construct from any member function pointer
@ -178,12 +186,12 @@ namespace plib {
// actual state // actual state
uintptr_t m_function; // first item can pointer to the function or a byte offset into the vtable uintptr_t m_function; // first item can pointer to the function or a byte offset into the vtable
ptrdiff_t m_this_delta; // delta to apply to the 'this' pointer after right shifting by one bit ptrdiff_t m_this_delta; // delta to apply to the 'this' pointer after right shifting by one bit
// m_function is the byte offset into the vtable // m_function is the byte offset into the vtable
// On IA64 it may also be a byte offset into the function descriptors // On IA64 it may also be a byte offset into the function descriptors
}; };
template <> template <>
class mfp_raw<PPMF_TYPE_INTERNAL_MSC> class mfp_raw<ppmf_type::INTERNAL_MSC>
{ {
public: public:
// construct from any member function pointer // construct from any member function pointer
@ -214,11 +222,11 @@ namespace plib {
std::is_same_v<std::remove_cv_t<R>, compile_info::int128_type> || std::is_same_v<std::remove_cv_t<R>, compile_info::int128_type> ||
std::is_same_v<std::remove_cv_t<R>, compile_info::uint128_type> >; std::is_same_v<std::remove_cv_t<R>, compile_info::uint128_type> >;
template<int PMFINTERNAL, typename R, typename... Targs> template<ppmf_type PMFINTERNAL, typename R, typename... Targs>
struct mfp_helper struct mfp_helper
{ {
protected: protected:
static_assert(PMFINTERNAL >= PPMF_TYPE_INTERNAL_ITANIUM && PMFINTERNAL <= PPMF_TYPE_INTERNAL_MSC, "Invalid PMF type"); static_assert(PMFINTERNAL >= ppmf_type::INTERNAL_ITANIUM && PMFINTERNAL <= ppmf_type::INTERNAL_MSC, "Invalid PMF type");
using traits = mfp_traits<R, Targs...>; using traits = mfp_traits<R, Targs...>;
using generic_member_function = typename traits::template specific_member_function<mfp_generic_class>; using generic_member_function = typename traits::template specific_member_function<mfp_generic_class>;
@ -262,7 +270,7 @@ namespace plib {
}; };
template<typename R, typename... Targs> template<typename R, typename... Targs>
struct mfp_helper<PPMF_TYPE_PMF, R, Targs...> struct mfp_helper<ppmf_type::PMF, R, Targs...>
{ {
protected: protected:
using traits = mfp_traits<R, Targs...>; using traits = mfp_traits<R, Targs...>;
@ -292,9 +300,9 @@ namespace plib {
static R stub(const generic_member_function* funci, mfp_generic_class* obji, Targs&&... args) noexcept(true); static R stub(const generic_member_function* funci, mfp_generic_class* obji, Targs&&... args) noexcept(true);
}; };
#if NVCCBUILD == 0 #if !defined(__NVCC__)
template<typename R, typename... Targs> template<typename R, typename... Targs>
struct mfp_helper<PPMF_TYPE_GNUC_PMF_CONV, R, Targs...> struct mfp_helper<ppmf_type::GNUC_PMF_CONV, R, Targs...>
{ {
protected: protected:
using traits = mfp_traits<R, Targs...>; using traits = mfp_traits<R, Targs...>;
@ -319,15 +327,15 @@ namespace plib {
}; };
#endif #endif
template <int PMFINTERNAL, typename R, typename... Targs> template <ppmf_type PMFINTERNAL, typename R, typename... Targs>
using pmfp_helper_select = std::conditional< using pmfp_helper_select = std::conditional<
pmf_is_register_return_type<R>::value pmf_is_register_return_type<R>::value
|| PMFINTERNAL != PPMF_TYPE_INTERNAL_MSC || (PPMF_EXPERIMENTAL), || PMFINTERNAL != ppmf_type::INTERNAL_MSC || (PPMF_EXPERIMENTAL),
mfp_helper<PMFINTERNAL, R, Targs...>, mfp_helper<PPMF_TYPE_PMF, R, Targs...>>; mfp_helper<PMFINTERNAL, R, Targs...>, mfp_helper<ppmf_type::PMF, R, Targs...>>;
template<int PMFINTERNAL, typename SIGNATURE> class pmfp_base; template<ppmf_type PMFINTERNAL, typename SIGNATURE> class pmfp_base;
template<int PMFINTERNAL, typename R, typename... Targs> template<ppmf_type PMFINTERNAL, typename R, typename... Targs>
class pmfp_base<PMFINTERNAL, R (Targs...)> : public pmfp_helper_select<PMFINTERNAL, R, Targs...>::type class pmfp_base<PMFINTERNAL, R (Targs...)> : public pmfp_helper_select<PMFINTERNAL, R, Targs...>::type
{ {
public: public:
@ -377,7 +385,7 @@ namespace plib {
}; };
template<typename Signature> template<typename Signature>
using pmfp = pmfp_base<ppmf_internal::value, Signature>; using pmfp = pmfp_base<ppmf_internal_selector::value, Signature>;
/// ///
/// \brief Class to support delegate late binding /// \brief Class to support delegate late binding
@ -424,7 +432,7 @@ namespace plib {
}; };
template<typename MemberFunctionType> template<typename MemberFunctionType>
mfp_raw<PPMF_TYPE_INTERNAL_ITANIUM>::mfp_raw(MemberFunctionType mftp) mfp_raw<ppmf_type::INTERNAL_ITANIUM>::mfp_raw(MemberFunctionType mftp)
: m_function(0), m_this_delta(0) : m_function(0), m_this_delta(0)
{ {
static_assert(sizeof(*this) >= sizeof(MemberFunctionType), "size mismatch"); static_assert(sizeof(*this) >= sizeof(MemberFunctionType), "size mismatch");
@ -433,7 +441,7 @@ namespace plib {
} }
template<typename MemberFunctionType> template<typename MemberFunctionType>
mfp_raw<PPMF_TYPE_INTERNAL_ARM>::mfp_raw(MemberFunctionType mftp) mfp_raw<ppmf_type::INTERNAL_ARM>::mfp_raw(MemberFunctionType mftp)
: m_function(0), m_this_delta(0) : m_function(0), m_this_delta(0)
{ {
static_assert(sizeof(*this) >= sizeof(MemberFunctionType), "size mismatch"); static_assert(sizeof(*this) >= sizeof(MemberFunctionType), "size mismatch");
@ -441,7 +449,7 @@ namespace plib {
} }
template<typename MemberFunctionType> template<typename MemberFunctionType>
mfp_raw<PPMF_TYPE_INTERNAL_MSC>::mfp_raw(MemberFunctionType mftp) mfp_raw<ppmf_type::INTERNAL_MSC>::mfp_raw(MemberFunctionType mftp)
: m_function(0), m_this_delta(0), m_vptr_index(0), m_vt_index(0), m_size(0) : m_function(0), m_this_delta(0), m_vptr_index(0), m_vt_index(0), m_size(0)
{ {
static_assert(sizeof(*this) >= sizeof(MemberFunctionType), "size mismatch"); static_assert(sizeof(*this) >= sizeof(MemberFunctionType), "size mismatch");
@ -449,7 +457,7 @@ namespace plib {
m_size = sizeof(mftp); //NOLINT m_size = sizeof(mftp); //NOLINT
} }
template<int PMFINTERNAL, typename R, typename... Targs> template<ppmf_type PMFINTERNAL, typename R, typename... Targs>
mfp_helper<PMFINTERNAL, R, Targs...>::mfp_helper() mfp_helper<PMFINTERNAL, R, Targs...>::mfp_helper()
: m_obj(nullptr) : m_obj(nullptr)
{ {
@ -458,7 +466,7 @@ namespace plib {
std::fill(s, s + sizeof(m_resolved), 0); std::fill(s, s + sizeof(m_resolved), 0);
} }
template<int PMFINTERNAL, typename R, typename... Targs> template<ppmf_type PMFINTERNAL, typename R, typename... Targs>
template<typename O, typename F> template<typename O, typename F>
void mfp_helper<PMFINTERNAL, R, Targs...>::bind(O *object, F *mftp) void mfp_helper<PMFINTERNAL, R, Targs...>::bind(O *object, F *mftp)
{ {
@ -478,7 +486,7 @@ namespace plib {
} }
template<typename R, typename... Targs> template<typename R, typename... Targs>
mfp_helper<PPMF_TYPE_PMF, R, Targs...>::mfp_helper() mfp_helper<ppmf_type::PMF, R, Targs...>::mfp_helper()
: m_obj(nullptr) : m_obj(nullptr)
, m_stub(nullptr) , m_stub(nullptr)
{ {
@ -489,7 +497,7 @@ namespace plib {
template<typename R, typename... Targs> template<typename R, typename... Targs>
template<typename O, typename F> template<typename O, typename F>
void mfp_helper<PPMF_TYPE_PMF, R, Targs...>::bind(O *object, F *mftp) void mfp_helper<ppmf_type::PMF, R, Targs...>::bind(O *object, F *mftp)
{ {
reinterpret_copy(*mftp, this->m_resolved); reinterpret_copy(*mftp, this->m_resolved);
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
@ -499,7 +507,7 @@ namespace plib {
template<typename R, typename... Targs> template<typename R, typename... Targs>
template<typename O> template<typename O>
R mfp_helper<PPMF_TYPE_PMF, R, Targs...>::stub(const generic_member_function* funci, mfp_generic_class* obji, Targs&&... args) noexcept(true) R mfp_helper<ppmf_type::PMF, R, Targs...>::stub(const generic_member_function* funci, mfp_generic_class* obji, Targs&&... args) noexcept(true)
{ {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
auto* obj = reinterpret_cast<O*>(obji); auto* obj = reinterpret_cast<O*>(obji);
@ -508,9 +516,9 @@ namespace plib {
return (obj->*(*func))(std::forward<Targs>(args)...); return (obj->*(*func))(std::forward<Targs>(args)...);
} }
#if NVCCBUILD == 0 #if !defined(__NVCC__)
template<typename R, typename... Targs> template<typename R, typename... Targs>
mfp_helper<PPMF_TYPE_GNUC_PMF_CONV, R, Targs...>::mfp_helper() mfp_helper<ppmf_type::GNUC_PMF_CONV, R, Targs...>::mfp_helper()
: m_obj(nullptr) : m_obj(nullptr)
{ {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
@ -520,7 +528,7 @@ namespace plib {
template<typename R, typename... Targs> template<typename R, typename... Targs>
template<typename O, typename F> template<typename O, typename F>
void mfp_helper<PPMF_TYPE_GNUC_PMF_CONV, R, Targs...>::bind(O *object, F *mftp) void mfp_helper<ppmf_type::GNUC_PMF_CONV, R, Targs...>::bind(O *object, F *mftp)
{ {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
member_abi_function<O> t = reinterpret_cast<member_abi_function<O>>(object->*(*mftp)); member_abi_function<O> t = reinterpret_cast<member_abi_function<O>>(object->*(*mftp));

View File

@ -52,8 +52,8 @@ namespace plib {
/// ///
/// \param filename a filename or identifier identifying the stream. /// \param filename a filename or identifier identifying the stream.
/// ///
/// FIXME: this is sub-optimal. Refactor input_context into pinput_context /// FIXME: this is sub-optimal. Refactor input_context into `pinput`_context
/// and pass this to ppreprocessor. /// and pass this to `ppreprocessor`.
/// ///
template <typename T> template <typename T>
pstring process(T &&istrm, const pstring &filename) pstring process(T &&istrm, const pstring &filename)

View File

@ -145,9 +145,8 @@ namespace plib
} }
template <typename ST> template <typename ST>
void save_state(ST &st) void save_state([[maybe_unused]] ST &st)
{ {
plib::unused_var(st);
/* no state to save */ /* no state to save */
} }

View File

@ -85,7 +85,7 @@ namespace plib
template<> template<>
struct pstonum_helper<FLOAT128> struct pstonum_helper<FLOAT128>
{ {
// FIXME: use strtoflt128 from quadmath.h // FIXME: use `strtoflt128` from `quadmath.h`
template <typename S> template <typename S>
FLOAT128 operator()(std::locale loc, const S &arg, bool *err) FLOAT128 operator()(std::locale loc, const S &arg, bool *err)
{ {

View File

@ -16,7 +16,6 @@
#include <array> #include <array>
#include <fstream> #include <fstream>
#include <fstream>
#include <ios> #include <ios>
#include <iostream> #include <iostream>
#include <memory> #include <memory>
@ -26,7 +25,7 @@
namespace plib { namespace plib {
/// \brief wrapper around isteam read /// \brief wrapper around istream read
/// ///
template <typename S, typename T> template <typename S, typename T>
static S & istream_read(S &is, T * data, size_t len) static S & istream_read(S &is, T * data, size_t len)
@ -37,7 +36,7 @@ namespace plib {
return is.read(reinterpret_cast<ct *>(data), gsl::narrow<std::streamsize>(len * sizeof(T))); return is.read(reinterpret_cast<ct *>(data), gsl::narrow<std::streamsize>(len * sizeof(T)));
} }
/// \brief wrapper around osteam write /// \brief wrapper around ostream write
/// ///
template <typename S, typename T> template <typename S, typename T>
static S & ostream_write(S &os, const T * data, size_t len) static S & ostream_write(S &os, const T * data, size_t len)
@ -366,7 +365,7 @@ class ifstream : public std::ifstream
{ {
public: public:
using filename_type = std::conditional<compile_info::win32() && (!compile_info::mingw() || compile_info::version()>=900), using filename_type = std::conditional<compile_info::win32() && (!compile_info::mingw() || compile_info::version::vmajor()>=9),
pstring_t<pwchar_traits>, pstring_t<putf8_traits>>::type; pstring_t<pwchar_traits>, pstring_t<putf8_traits>>::type;
template <typename T> template <typename T>
@ -387,7 +386,7 @@ public:
class ofstream : public std::ofstream class ofstream : public std::ofstream
{ {
public: public:
using filename_type = std::conditional<compile_info::win32() && (!compile_info::mingw() || compile_info::version()>=900), using filename_type = std::conditional<compile_info::win32() && (!compile_info::mingw() || compile_info::version::vmajor()>=9),
pstring_t<pwchar_traits>, pstring_t<putf8_traits>>::type; pstring_t<pwchar_traits>, pstring_t<putf8_traits>>::type;
template <typename T> template <typename T>

View File

@ -15,6 +15,8 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector> #include <vector>
#include <algorithm>
#include <sstream>
#if defined(__clang__) #if defined(__clang__)
#pragma clang diagnostic ignored "-Wglobal-constructors" #pragma clang diagnostic ignored "-Wglobal-constructors"
@ -35,43 +37,80 @@
#define PTEST(name, desc) PINT_TEST(name, desc) #define PTEST(name, desc) PINT_TEST(name, desc)
#define PTEST_F(name, desc) PINT_TEST_F(name, desc, name) #define PTEST_F(name, desc) PINT_TEST_F(name, desc, name)
#define PRUN_ALL_TESTS() plib::testing::run_all_tests() #define PRUN_ALL_TESTS(loglevel) plib::testing::run_all_tests(loglevel)
#define PINT_TEST(name, desc) PINT_TEST_F(name, desc, plib::testing::Test) #define PINT_TEST(name, desc) PINT_TEST_F(name, desc, plib::testing::Test)
#define PINT_TESTNAME(name, desc) name ## _ ## desc
#define PINT_LOCATION() ::plib::testing::test_location(__FILE__, __LINE__)
#define PINT_SET_LAST(loc) this->m_parameters->m_last_source = loc
#define PINT_REGISTER(name, desc) \
extern const plib::testing::reg_entry<PINT_TESTNAME(name, desc)> PINT_TESTNAME(name, desc ## _reg); \
const plib::testing::reg_entry<PINT_TESTNAME(name, desc)> PINT_TESTNAME(name, desc ## _reg)(#name, #desc, PINT_LOCATION()); \
#define PINT_TEST_F(name, desc, base) \ #define PINT_TEST_F(name, desc, base) \
class name ## _ ## desc : public base \ class PINT_TESTNAME(name, desc) : public base \
{ public:\ { public:\
void desc (); \ void desc (); \
void run() override { desc (); } \ void run() override { desc (); } \
}; \ }; \
extern const plib::testing::reg_entry<name ## _ ## desc> name ## _ ## desc ## _reg; \ PINT_REGISTER(name, desc) \
const plib::testing::reg_entry<name ## _ ## desc> name ## _ ## desc ## _reg(#name, #desc); \ void PINT_TESTNAME(name, desc) :: desc ()
void name ## _ ## desc :: desc ()
#define PINT_EXPECT(comp, exp1, exp2) \ #define PINT_EXPECT(comp, exp1, exp2) \
if (!plib::testing::internal_assert(plib::testing::comp_ ## comp (), # exp1, # exp2, exp1, exp2)) \ if (true) \
std::cout << __FILE__ << ":" << __LINE__ << ":1: error: test failed\n" { \
::plib::testing::test_location source = PINT_LOCATION(); PINT_SET_LAST(source); \
m_parameters->m_num_tests++; \
if (!this->internal_assert(plib::testing::comp_ ## comp (), # exp1, # exp2, exp1, exp2)) \
this->test_error(source) << "test failed" << std::endl; \
} else do {} while (0)
#define PINT_EXPECT_THROW(exp, excep) \ #define PINT_EXPECT_THROW(exp, excep) \
if (const char *ptest_f = __FILE__) \ if (true) \
{ \ { \
try { exp; std::cout << ptest_f << ":" << __LINE__ << ":1: error: no " #excep " exception thrown\n";} \ ::plib::testing::test_location source = PINT_LOCATION(); PINT_SET_LAST(source); \
catch (excep &) { std::cout << "\tOK: got " #excep " for " # exp "\n";} \ m_parameters->m_num_tests++; \
catch (std::exception &ptest_e) { std::cout << ptest_f << ":" << __LINE__ << ":1: error: unexpected exception thrown: " << ptest_e.what() << "\n"; } \ try { exp; this->test_error(source) << "no " #excep " exception thrown" << std::endl;} \
catch (...) { std::cout << ptest_f << ":" << __LINE__ << ":1: error: unexpected exception thrown\n"; } \ catch (excep &) { this->test_ok() << "got " #excep " for " # exp "" << std::endl;} \
catch (std::exception &ptest_e) { this->test_error(source) << "unexpected exception thrown: " << ptest_e.what() << std::endl; } \
catch (...) { this->test_error(source) << "unexpected exception thrown" << std::endl; } \
} else do {} while (0) } else do {} while (0)
#define PINT_EXPECT_NO_THROW(exp) \ #define PINT_EXPECT_NO_THROW(exp) \
if (const char *ptest_f = __FILE__) \ if (true) \
{ \ { \
try { exp; std::cout << "\tOK: got no exception for " # exp "\n";} \ ::plib::testing::test_location source = PINT_LOCATION(); PINT_SET_LAST(source); \
catch (std::exception &ptest_e) { std::cout << ptest_f << ":" << __LINE__ << ":1: error: unexpected exception thrown: " << ptest_e.what() << "\n"; } \ m_parameters->m_num_tests++; \
catch (...) { std::cout << ptest_f << ":" << __LINE__ << ":1: error: unexpected exception thrown\n"; } \ try { exp; this->test_ok() << "got no exception for " # exp << std::endl;} \
catch (std::exception &ptest_e) { this->test_error(source) << "unexpected exception thrown: " << ptest_e.what() << std::endl; } \
catch (...) { this->test_error(source) << "unexpected exception thrown" << std::endl; } \
} else do {} while (0) } else do {} while (0)
namespace plib::testing namespace plib::testing
{ {
enum class loglevel
{
INFO,
WARNING,
ERROR
};
using test_location = std::pair<const char *, std::size_t>;
struct test_parameters
{
loglevel m_loglevel = loglevel::INFO;
std::size_t m_num_errors = 0;
std::size_t m_num_tests = 0;
test_location m_last_source = {"", 0 };
};
static std::ostream &stream_error(std::ostream &os, test_location loc)
{
return os << loc.first << ":" << loc.second << ":1: error: ";
}
class Test class Test
{ {
@ -87,13 +126,54 @@ namespace plib::testing
virtual void run() {} virtual void run() {}
virtual void SetUp() {} virtual void SetUp() {}
virtual void TearDown() {} virtual void TearDown() {}
void set_parameters(test_parameters *params)
{
m_parameters = params;
}
protected:
std::ostream & test_ok() { return output(loglevel::INFO) << "\tOK: "; }
std::ostream & test_fail() { return output(loglevel::WARNING) << "\tFAIL: "; }
std::ostream & test_error(const test_location & loc)
{
return stream_error(output(loglevel::ERROR), loc);
}
template <typename C, typename T1, typename T2>
bool internal_assert(C comp,
const char* exp1, const char* exp2,
const T1& val1, const T2& val2);
test_parameters *m_parameters = nullptr;
private:
std::ostream &output(loglevel ll)
{
if (ll == loglevel::ERROR)
m_parameters->m_num_errors++;
return (ll >= m_parameters->m_loglevel) ? std::cout : m_nulstream;
}
std::ostringstream m_nulstream;
}; };
template <typename C, typename T1, typename T2>
bool Test::internal_assert(C comp,
const char* exp1, const char* exp2,
const T1& val1, const T2& val2)
{
if (comp(val1, val2))
{
test_ok() << exp1 << " " << C::opstr() << " " << exp2 << std::endl;
return true;
}
test_fail() << exp1 << " " << C::opstr() << " " << exp2
<< " <" << val1 << ">,<" << val2 << ">" << std::endl;
return false;
}
struct reg_entry_base struct reg_entry_base
{ {
using list_t = std::vector<reg_entry_base *>; using list_t = std::vector<reg_entry_base *>;
reg_entry_base(const std::string &n, const std::string &d) reg_entry_base(const char *n, const char *d, test_location l)
: name(n), desc(d) : name(n), desc(d), location(l)
{ {
registry().push_back(this); registry().push_back(this);
} }
@ -107,8 +187,9 @@ namespace plib::testing
virtual Test *create() const { return nullptr; } virtual Test *create() const { return nullptr; }
std::string name; const char *name;
std::string desc; const char *desc;
test_location location;
public: public:
static list_t & registry() static list_t & registry()
{ {
@ -125,36 +206,81 @@ namespace plib::testing
Test *create() const override { return new T(); } // NOLINT Test *create() const override { return new T(); } // NOLINT
}; };
template <typename C, typename T1, typename T2> template <typename L>
bool internal_assert(C comp, std::pair<bool, std::string> catch_exception(L lambda)
const char* exp1, const char* exp2,
const T1& val1, const T2& val2)
{ {
if (comp(val1, val2)) try {
{ lambda();
std::cout << "\tOK: " << exp1 << " " << C::opstr() << " " << exp2 << "\n";
return true;
} }
std::cout << "\tFAIL: " << exp1 << " " << C::opstr() << " " << exp2 catch (std::exception &ptest_e)
<< " <" << val1 << ">,<" << val2 << ">\n"; {
return false; return { true, ptest_e.what() };
}
catch (...)
{
return { true, "" };
}
return { false, "" };
} }
static inline int run_all_tests() static inline int run_all_tests(loglevel ll)
{ {
std::cout << "======================================\n"; std::cout << "================================================" << std::endl;
std::cout << "Running " << reg_entry_base::registry().size() << " tests\n"; std::cout << "Running " << reg_entry_base::registry().size() << " test groups" << std::endl;
std::cout << "======================================\n"; std::cout << "================================================" << std::endl;
for (auto &e : reg_entry_base::registry())
auto &list = reg_entry_base::registry();
std::sort(list.begin(), list.end(), [](reg_entry_base *a, reg_entry_base *b) {
return (a->name < b->name);
});
std::size_t total_errors(0);
std::size_t total_tests(0);
for (auto &e : list)
{ {
std::cout << e->name << "::" << e->desc << ":\n"; test_parameters params;
Test *t = e->create(); params.m_loglevel = ll;
t->SetUp(); params.m_last_source = e->location;
t->run();
t->TearDown(); std::cout << e->name << "::" << e->desc << ":" << std::endl;
delete t; Test *t = nullptr;
std::pair<bool, std::string> r;
if ((r = catch_exception([&]{
t = e->create();
t->set_parameters(&params);
})).first)
{
stream_error(std::cout, e->location) << "unexpected exception thrown during instantiation" << (r.second != "" ? ": " + r.second : "") << std::endl;
total_errors++;
}
else if ((r = catch_exception([&]{ t->SetUp(); })).first)
{
stream_error(std::cout, e->location) << "unexpected exception thrown during Setup" << (r.second != "" ? ": " + r.second : "") << std::endl;
total_errors++;
}
else if ((r = catch_exception([&]{ t->run(); })).first)
{
stream_error(std::cout, params.m_last_source) << "unexpected exception thrown during run after this line" << (r.second != "" ? ": " + r.second : "") << std::endl;
total_errors++;
}
else if ((r = catch_exception([&]{ t->TearDown(); })).first)
{
stream_error(std::cout, e->location) << "unexpected exception thrown during Teardown" << (r.second != "" ? ": " + r.second : "") << std::endl;
total_errors++;
}
total_errors += params.m_num_errors;
total_tests += params.m_num_tests;
if (t != nullptr)
delete t;
} }
return 0; std::cout << "================================================" << std::endl;
std::cout << "Found " << total_errors << " errors in " << total_tests << " tests from " << reg_entry_base::registry().size() << " test groups" << std::endl;
std::cout << "================================================" << std::endl;
return (total_errors ? 1 : 0);
} }
#define DEF_COMP(name, op) \ #define DEF_COMP(name, op) \

View File

@ -60,10 +60,9 @@ namespace plib
} }
template <typename O, typename T = std::enable_if_t<!ptime_le<ptime<O, RES>, ptime>::value, int>> template <typename O, typename T = std::enable_if_t<!ptime_le<ptime<O, RES>, ptime>::value, int>>
constexpr explicit ptime(const ptime<O, RES> &rhs, T dummy = 0) noexcept constexpr explicit ptime(const ptime<O, RES> &rhs,[[maybe_unused]] T dummy = 0) noexcept
: m_time(static_cast<TYPE>(rhs.m_time)) : m_time(static_cast<TYPE>(rhs.m_time))
{ {
plib::unused_var(dummy);
} }
template <typename O> template <typename O>

View File

@ -81,8 +81,7 @@ namespace plib
UNKNOWN, UNKNOWN,
CLANG, CLANG,
GCC, GCC,
MSC, MSC
NVCC
}; };
enum class ci_cpp_stdlib enum class ci_cpp_stdlib
@ -115,7 +114,18 @@ namespace plib
enum class ci_env enum class ci_env
{ {
DEFAULT, DEFAULT,
MSVC MSVC,
NVCC
};
// <sys/types.h> on ubuntu system may define major and minor as macros
// That's why we use vmajor, .. here
template <std::size_t MAJOR, std::size_t MINOR>
struct typed_version
{
using vmajor = std::integral_constant<std::size_t, MAJOR>;
using vminor = std::integral_constant<std::size_t, MINOR>;
using full = std::integral_constant<std::size_t, MAJOR * 100 + MINOR>;
}; };
struct compile_info struct compile_info
@ -144,21 +154,18 @@ namespace plib
static constexpr int128_type int128_max() { return int128_type(); } static constexpr int128_type int128_max() { return int128_type(); }
static constexpr uint128_type uint128_max() { return uint128_type(); } static constexpr uint128_type uint128_max() { return uint128_type(); }
#endif #endif
#if (NVCCBUILD > 0) #if defined(__clang__)
using type = std::integral_constant<ci_compiler, ci_compiler::NVCC>;
using version = std::integral_constant<int, NVCCBUILD>;
#elif defined(__clang__)
using type = std::integral_constant<ci_compiler, ci_compiler::CLANG>; using type = std::integral_constant<ci_compiler, ci_compiler::CLANG>;
using version = std::integral_constant<int, (__clang_major__) * 100 + (__clang_minor__)>; using version = typed_version<__clang_major__, __clang_minor__>;
#elif defined(__GNUC__) #elif defined(__GNUC__)
using type = std::integral_constant<ci_compiler, ci_compiler::GCC>; using type = std::integral_constant<ci_compiler, ci_compiler::GCC>;
using version = std::integral_constant<int, (__GNUC__) * 100 + (__GNUC_MINOR__)>; using version = typed_version< __GNUC__, __GNUC_MINOR__ >;
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
using type = std::integral_constant<ci_compiler, ci_compiler::MSC>; using type = std::integral_constant<ci_compiler, ci_compiler::MSC>;
using version = std::integral_constant<int, _MSC_VER>; using version = typed_version<_MSC_VER / 100, _MSC_VER % 100>;
#else #else
using type = std::integral_constant<ci_compiler, ci_compiler::UNKNOWN>; using type = std::integral_constant<ci_compiler, ci_compiler::UNKNOWN>;
using version = std::integral_constant<int, 0>; using version = typed_version<0, 0>;
#endif #endif
#if defined(_LIBCPP_VERSION) #if defined(_LIBCPP_VERSION)
using cpp_stdlib = std::integral_constant<ci_cpp_stdlib, ci_cpp_stdlib::LIBCPP>; using cpp_stdlib = std::integral_constant<ci_cpp_stdlib, ci_cpp_stdlib::LIBCPP>;
@ -212,9 +219,9 @@ namespace plib
using mingw = std::integral_constant<bool, false>; using mingw = std::integral_constant<bool, false>;
#endif #endif
#if defined(__APPLE__) #if defined(__APPLE__)
using clang_noexcept_issue = std::integral_constant<bool, version::value < 1100>; using clang_noexcept_issue = std::integral_constant<bool, version::vmajor::value < 11>;
#else #else
using clang_noexcept_issue = std::integral_constant<bool, (type::value == ci_compiler::CLANG) && (version::value < 800)>; using clang_noexcept_issue = std::integral_constant<bool, (type::value == ci_compiler::CLANG) && (version::vmajor::value < 8)>;
#endif #endif
#if defined(__ia64__) #if defined(__ia64__)
using abi_vtable_function_descriptors = std::integral_constant<bool, true>; using abi_vtable_function_descriptors = std::integral_constant<bool, true>;
@ -223,8 +230,18 @@ namespace plib
#endif #endif
#if defined(_MSC_VER) #if defined(_MSC_VER)
using env = std::integral_constant<ci_env, ci_env::MSVC>; using env = std::integral_constant<ci_env, ci_env::MSVC>;
using env_version = typed_version<_MSC_VER / 100, _MSC_VER % 100>;
#elif defined(__NVCC__) || defined(__CUDACC__)
using env = std::integral_constant<ci_env, ci_env::NVCC>;
using env_version = typed_version<__CUDA_API_VER_MAJOR__, __CUDA_API_VER_MINOR__>;
#if defined(__CUDA_ARCH__)
using cuda_arch = std::integral_constant<std::size_t, __CUDA_ARCH__>;
#else
using cuda_arch = std::integral_constant<std::size_t, 0>;
#endif
#else #else
using env = std::integral_constant<ci_env, ci_env::DEFAULT>; using env = std::integral_constant<ci_env, ci_env::DEFAULT>;
using env_version = version;
#endif #endif
}; };
@ -336,7 +353,7 @@ namespace plib
/// @tparam Ts unsused parameters /// @tparam Ts unsused parameters
/// ///
template<typename... Ts> template<typename... Ts>
inline void unused_var(Ts&&...) noexcept {} // NOLINT(readability-named-parameter) inline void unused_var(Ts&&...) noexcept {} // NOLINT(readability-named-parameter) // FIXME: remove unused var completely
/// \brief copy type S to type D byte by byte /// \brief copy type S to type D byte by byte
/// ///

View File

@ -1319,7 +1319,9 @@ int tool_app_t::execute()
convert(); convert();
else if (cmd == "tests") else if (cmd == "tests")
{ {
return PRUN_ALL_TESTS(); return PRUN_ALL_TESTS(opt_verb() ? ::plib::testing::loglevel::INFO
: opt_quiet() ? ::plib::testing::loglevel::ERROR
: ::plib::testing::loglevel::WARNING);
} }
else else
{ {

View File

@ -825,6 +825,7 @@ int nlwav_app::execute()
PMAIN(nlwav_app) PMAIN(nlwav_app)
// spell-checker:disable
// //
// Der Daten-Abschnitt enth??lt die Abtastwerte: // Der Daten-Abschnitt enth??lt die Abtastwerte:
// Offset L??nge Inhalt Beschreibung // Offset L??nge Inhalt Beschreibung
@ -846,3 +847,4 @@ PMAIN(nlwav_app)
// 32 (0x20) 2 <block align> Frame-Gr????e = <Anzahl der Kan??le>????????((<Bits/Sample (eines Kanals)>???+???7)???/???8) (Division ohne Rest) // 32 (0x20) 2 <block align> Frame-Gr????e = <Anzahl der Kan??le>????????((<Bits/Sample (eines Kanals)>???+???7)???/???8) (Division ohne Rest)
// 34 (0x22) 2 <bits/sample> Anzahl der Datenbits pro Samplewert je Kanal (z. B. 12) // 34 (0x22) 2 <bits/sample> Anzahl der Datenbits pro Samplewert je Kanal (z. B. 12)
// //
// spell-checker:enable

View File

@ -503,11 +503,10 @@ namespace netlist::solver
return netlist_time::from_fp(m_params.m_max_timestep); return netlist_time::from_fp(m_params.m_max_timestep);
} }
netlist_time matrix_solver_t::solve(netlist_time_ext now, const char *source) netlist_time matrix_solver_t::solve(netlist_time_ext now, [[maybe_unused]] const char *source)
{ {
auto delta = static_cast<netlist_time>(now - m_last_step()); auto delta = static_cast<netlist_time>(now - m_last_step());
PFDEBUG(printf("solve %.10f\n", delta.as_double());) PFDEBUG(printf("solve %.10f\n", delta.as_double());)
plib::unused_var(source);
// We are already up to date. Avoid oscillations. // We are already up to date. Avoid oscillations.
// FIXME: Make this a parameter! // FIXME: Make this a parameter!

View File

@ -263,8 +263,7 @@ namespace netlist::solver
// this should only occur outside of execution and thus // this should only occur outside of execution and thus
// using time should be safe. // using time should be safe.
const netlist_time new_timestep = solve(exec().time(), "solve_now"); [[maybe_unused]] const netlist_time new_timestep = solve(exec().time(), "solve_now");
plib::unused_var(new_timestep);
update_inputs(); update_inputs();
@ -280,8 +279,7 @@ namespace netlist::solver
// We only need to update the net first if this is a time stepping net // We only need to update the net first if this is a time stepping net
if (timestep_device_count() > 0) if (timestep_device_count() > 0)
{ {
const netlist_time new_timestep = solve(exec().time(), "change_state"); [[maybe_unused]] const netlist_time new_timestep = solve(exec().time(), "change_state");
plib::unused_var(new_timestep);
update_inputs(); update_inputs();
} }
f(); f();
@ -298,9 +296,8 @@ namespace netlist::solver
virtual void log_stats(); virtual void log_stats();
virtual std::pair<pstring, pstring> create_solver_code(solver::static_compile_target target) virtual std::pair<pstring, pstring> create_solver_code([[maybe_unused]] solver::static_compile_target target)
{ {
plib::unused_var(target);
return { "", plib::pfmt("/* solver doesn't support static compile */\n\n") }; return { "", plib::pfmt("/* solver doesn't support static compile */\n\n") };
} }

View File

@ -55,15 +55,13 @@ namespace netlist::solver
plib::pmatrix2d<float_type *> m_mat_ptr; plib::pmatrix2d<float_type *> m_mat_ptr;
template <typename T, typename M> template <typename T, typename M>
void log_fill(const T &fill, M &mat) void log_fill(const T &fill,[[maybe_unused]] M &mat)
{ {
const std::size_t iN = fill.size(); const std::size_t iN = fill.size();
// FIXME: Not yet working, mat_cr.h needs some more work // FIXME: Not yet working, mat_cr.h needs some more work
#if 0 #if 0
auto mat_GE = dynamic_cast<plib::pGEmatrix_cr_t<typename M::base> *>(&mat); auto mat_GE = dynamic_cast<plib::pGEmatrix_cr_t<typename M::base> *>(&mat);
#else
plib::unused_var(mat);
#endif #endif
std::vector<unsigned> levL(iN, 0); std::vector<unsigned> levL(iN, 0);
std::vector<unsigned> levU(iN, 0); std::vector<unsigned> levU(iN, 0);

View File

@ -150,15 +150,13 @@ namespace netlist::devices
plib::omp::set_num_threads(nthreads); plib::omp::set_num_threads(nthreads);
plib::omp::for_static(static_cast<std::size_t>(0), solvers.size(), [&solvers, now](std::size_t i) plib::omp::for_static(static_cast<std::size_t>(0), solvers.size(), [&solvers, now](std::size_t i)
{ {
const netlist_time ts = solvers[i]->ptr->solve(now); [[maybe_unused]] const netlist_time ts = solvers[i]->ptr->solve(now);
plib::unused_var(ts);
}); });
} }
else else
for (auto & solver : solvers) for (auto & solver : solvers)
{ {
const netlist_time ts = solver->ptr->solve(now); [[maybe_unused]] const netlist_time ts = solver->ptr->solve(now);
plib::unused_var(ts);
} }
for (auto & solver : solvers) for (auto & solver : solvers)

View File

@ -15,13 +15,15 @@
#include <utility> #include <utility>
#include <memory> #include <memory>
/// plib::late_pmfp<plib::pmfp<void, pstring>> a(&nld_7493::printer); /// `plib::late_pmfp<plib::pmfp<void, pstring>> a(&nld_7493::printer);`
/// // Store the a object somewhere /// // Store the a object somewhere
/// ///
/// // After full construction ... /// // After full construction ...
/// ///
/// ```
/// auto dele = a(this); /// auto dele = a(this);
/// dele(pstring("Hello World!")); /// dele(pstring("Hello World!"));
/// ```
class test_late_pmfp : public plib::testing::Test class test_late_pmfp : public plib::testing::Test
{ {
@ -52,23 +54,23 @@ PTEST_F(test_late_pmfp, late_pmfp)
PTEST(test_compile, compile) PTEST(test_compile, compile)
{ {
#if !PPMF_USE_MAME_DELEGATES #if !PPMF_USE_MAME_DELEGATES
plib::pmfp_base<PPMF_TYPE_PMF, void(int)> mfp_PPMF_TYPE_PMF; plib::pmfp_base<plib::ppmf_type::PMF, void(int)> mfp_PPMF_TYPE_PMF;
plib::pmfp_base<PPMF_TYPE_INTERNAL_ITANIUM, void(int)> mfp_PPMF_TYPE_INTERNAL_ITANIUM; plib::pmfp_base<plib::ppmf_type::INTERNAL_ITANIUM, void(int)> mfp_PPMF_TYPE_INTERNAL_ITANIUM;
plib::pmfp_base<PPMF_TYPE_INTERNAL_ARM, void(int)> mfp_PPMF_TYPE_INTERNAL_ARM; plib::pmfp_base<plib::ppmf_type::INTERNAL_ARM, void(int)> mfp_PPMF_TYPE_INTERNAL_ARM;
plib::pmfp_base<PPMF_TYPE_INTERNAL_MSC, void(int)> mfp_PPMF_TYPE_INTERNAL_MSC; plib::pmfp_base<plib::ppmf_type::INTERNAL_MSC, void(int)> mfp_PPMF_TYPE_INTERNAL_MSC;
PEXPECT_TRUE(mfp_PPMF_TYPE_PMF.isnull()); PEXPECT_TRUE(mfp_PPMF_TYPE_PMF.isnull());
PEXPECT_TRUE(mfp_PPMF_TYPE_INTERNAL_ITANIUM.isnull()); PEXPECT_TRUE(mfp_PPMF_TYPE_INTERNAL_ITANIUM.isnull());
PEXPECT_TRUE(mfp_PPMF_TYPE_INTERNAL_ARM.isnull()); PEXPECT_TRUE(mfp_PPMF_TYPE_INTERNAL_ARM.isnull());
PEXPECT_TRUE(mfp_PPMF_TYPE_INTERNAL_MSC.isnull()); PEXPECT_TRUE(mfp_PPMF_TYPE_INTERNAL_MSC.isnull());
#endif #endif
#if defined(__GNUC__) && !defined(__clang__) && (NVCCBUILD == 0) #if defined(__GNUC__) && !defined(__clang__) && !defined(__NVCC__)
plib::pmfp_base<PPMF_TYPE_GNUC_PMF_CONV, void(int)> mfp_PPMF_TYPE_GNUC_PMF_CONV; plib::pmfp_base<plib::ppmf_type::GNUC_PMF_CONV, void(int)> mfp_PPMF_TYPE_GNUC_PMF_CONV;
PEXPECT_TRUE(mfp_PPMF_TYPE_GNUC_PMF_CONV.isnull()); PEXPECT_TRUE(mfp_PPMF_TYPE_GNUC_PMF_CONV.isnull());
#else #else
PEXPECT_NE("PPMF_TYPE_GNUC_PMF_CONV not supported on this build", ""); PEXPECT_NE("ppmf_type::GNUC_PMF_CONV not supported on this build", "");
#endif #endif
#if defined(__EMSCRIPTEN__) #if defined(__EMSCRIPTEN__)
PEXPECT_EQ(plib::ppmf_internal::value,PPMF_TYPE_INTERNAL_ARM); PEXPECT_EQ(plib::ppmf_internal_selector::value,plib::ppmf_type::INTERNAL_ARM);
#endif #endif
} }

View File

@ -29,9 +29,8 @@ operator << (std::basic_ostream<char>& os, const std::pair<F, S> &p)
template <class T> template <class T>
typename std::enable_if_t<!plib::has_ostream_operator<std::basic_ostream<char>, T>::value, std::basic_ostream<char>&> typename std::enable_if_t<!plib::has_ostream_operator<std::basic_ostream<char>, T>::value, std::basic_ostream<char>&>
operator << (std::basic_ostream<char>& os, const T &p) operator << ([[maybe_unused]] std::basic_ostream<char>& os, [[maybe_unused]] const T &p)
{ {
plib::unused_var(p);
os << std::string(typeid(T).name()); os << std::string(typeid(T).name());
return os; return os;
} }
@ -350,7 +349,7 @@ PTEST_F(pmfp_test_complex_return, multibase_test)
PEXPECT_EQ(static_cast<int>(ts17.run_ft<INT128>(17)), 17); // FIXME: no operator << for INT128 yet PEXPECT_EQ(static_cast<int>(ts17.run_ft<INT128>(17)), 17); // FIXME: no operator << for INT128 yet
PEXPECT_EQ(sizeof(INT128), 16u); PEXPECT_EQ(sizeof(INT128), 16u);
} }
#endif #endif
PEXPECT_EQ(ts17.run_ft<long double>(17), 17); PEXPECT_EQ(ts17.run_ft<long double>(17), 17);
PEXPECT_EQ(ts17.run_ft<double>(17), 17); PEXPECT_EQ(ts17.run_ft<double>(17), 17);
PEXPECT_EQ(ts17.run_ft<int>(17), 17); PEXPECT_EQ(ts17.run_ft<int>(17), 17);

View File

@ -0,0 +1,26 @@
// license:BSD-3-Clause
// copyright-holders:Couriersud
///
/// \file test_pmfp.cpp
///
/// tests for plib::pmfp
///
#include "plib/pconfig.h"
#include "plib/ppmf.h"
#include "netlist/nl_config.h"
#include "plib/ptests.h"
PTEST(test_precommit, precommit)
{
PEXPECT_EQ(PPMF_EXPERIMENTAL, 0);
PEXPECT_EQ(PPMF_USE_MAME_DELEGATES, 0);
PEXPECT_EQ(NL_USE_COPY_INSTEAD_OF_REFERENCE, 0);
PEXPECT_EQ(NL_USE_BACKWARD_EULER, 1);
PEXPECT_EQ(PUSE_FLOAT128, 0);
PEXPECT_EQ(NL_USE_FLOAT128, PUSE_FLOAT128);
PEXPECT_EQ(AVOID_NOOP_QUEUE_PUSHES, 0);
}

View File

@ -348,7 +348,7 @@ void nl_convert_spice_t::convert(const pstring &contents)
pstring line = ""; pstring line = "";
// process linecontinuation // process line continuation
for (const auto &i : spnl) for (const auto &i : spnl)
{ {
@ -365,7 +365,7 @@ void nl_convert_spice_t::convert(const pstring &contents)
after_linecontinuation.push_back(line); after_linecontinuation.push_back(line);
spnl.clear(); // no longer needed spnl.clear(); // no longer needed
// Process subcircuits // Process sub circuits
std::vector<std::vector<pstring>> subckts; std::vector<std::vector<pstring>> subckts;
std::vector<pstring> nl; std::vector<pstring> nl;
@ -463,7 +463,7 @@ void nl_convert_spice_t::process_line(const pstring &line)
else if (tt[0] == ".MODEL") else if (tt[0] == ".MODEL")
{ {
pstring mod(rem(tt,2)); pstring mod(rem(tt,2));
// Filter out ngspice X=X model declarations // Filter out `ngspice` X=X model declarations
if (tt[1] != mod) if (tt[1] != mod)
out("NET_MODEL(\"{} {}\")\n", m_subckt + tt[1], mod); out("NET_MODEL(\"{} {}\")\n", m_subckt + tt[1], mod);
} }
@ -477,13 +477,12 @@ void nl_convert_spice_t::process_line(const pstring &line)
case 'Q': case 'Q':
{ {
// check for fourth terminal ... should be numeric net // check for fourth terminal ... should be numeric net
// including "0" or start with "N" (ltspice) // including "0" or start with "N" (`ltspice`)
pstring model; pstring model;
pstring pins ="CBE"; pstring pins ="CBE";
bool err(false); bool err(false);
auto nval = plib::pstonum_ne<long>(tt[4], err); [[maybe_unused]] auto nval = plib::pstonum_ne<long>(tt[4], err);
plib::unused_var(nval);
if ((!err || plib::startsWith(tt[4], "N")) && tt.size() > 5) if ((!err || plib::startsWith(tt[4], "N")) && tt.size() > 5)
model = tt[5]; model = tt[5];
@ -525,7 +524,7 @@ void nl_convert_spice_t::process_line(const pstring &line)
add_term(tt[1], tt[0] + ".1"); add_term(tt[1], tt[0] + ".1");
add_term(tt[2], tt[0] + ".2"); add_term(tt[2], tt[0] + ".2");
break; break;
case 'B': // arbitrary behavioural current source - needs manual work afterwords case 'B': // arbitrary behavioural current source - needs manual work afterwards
add_device("CS", tt[0], "/*" + rem(tt, 3) + "*/"); add_device("CS", tt[0], "/*" + rem(tt, 3) + "*/");
add_term(tt[1], tt[0] + ".P"); add_term(tt[1], tt[0] + ".P");
add_term(tt[2], tt[0] + ".N"); add_term(tt[2], tt[0] + ".N");
@ -562,7 +561,7 @@ void nl_convert_spice_t::process_line(const pstring &line)
add_term(nextnet, devname, 1); add_term(nextnet, devname, 1);
add_term(net2[0], devname, 2); add_term(net2[0], devname, 2);
add_term(net2[1], devname, 3); add_term(net2[1], devname, 3);
//add_device_extra(devname, "PARAM({}, {})", devname + ".G", tt[scoeff+i]); //# add_device_extra(devname, "PARAM({}, {})", devname + ".G", tt[scoeff+i]);
lastnet = nextnet; lastnet = nextnet;
} }
} }
@ -597,7 +596,7 @@ void nl_convert_spice_t::process_line(const pstring &line)
pstring extranetname = devname + "net"; pstring extranetname = devname + "net";
m_replace.push_back({tt[sce+i], devname + ".IP", extranetname }); m_replace.push_back({tt[sce+i], devname + ".IP", extranetname });
add_term(extranetname, devname + ".IN"); add_term(extranetname, devname + ".IN");
//add_device_extra(devname, "PARAM({}, {})", devname + ".G", tt[scoeff+i]); //# add_device_extra(devname, "PARAM({}, {})", devname + ".G", tt[scoeff+i]);
} }
} }
break; break;
@ -735,7 +734,7 @@ nl_convert_eagle_t::tokenizer::tokenizer(nl_convert_eagle_t &convert)
this->identifier_chars("abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-") this->identifier_chars("abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_.-")
.number_chars(".0123456789", "0123456789eE-.") //FIXME: processing of numbers .number_chars(".0123456789", "0123456789eE-.") //FIXME: processing of numbers
.whitespace(pstring("") + ' ' + static_cast<char>(9) + static_cast<char>(10) + static_cast<char>(13)) .whitespace(pstring("") + ' ' + static_cast<char>(9) + static_cast<char>(10) + static_cast<char>(13))
// FIXME: gnetlist doesn't print comments // FIXME: netlist doesn't print comments
.comment("/*", "*/", "//") .comment("/*", "*/", "//")
.string_char('\''); .string_char('\'');
m_tok_ADD = register_token("ADD"); m_tok_ADD = register_token("ADD");
@ -878,7 +877,7 @@ nl_convert_rinf_t::tokenizer::tokenizer(nl_convert_rinf_t &convert)
this->identifier_chars(".abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_-") this->identifier_chars(".abcdefghijklmnopqrstuvwvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_-")
.number_chars("0123456789", "0123456789eE-.") //FIXME: processing of numbers .number_chars("0123456789", "0123456789eE-.") //FIXME: processing of numbers
.whitespace(pstring("") + ' ' + static_cast<char>(9) + static_cast<char>(10) + static_cast<char>(13)) .whitespace(pstring("") + ' ' + static_cast<char>(9) + static_cast<char>(10) + static_cast<char>(13))
// FIXME: gnetlist doesn't print comments // FIXME: netlist doesn't print comments
.comment("","","//") // FIXME:needs to be confirmed .comment("","","//") // FIXME:needs to be confirmed
.string_char('"'); .string_char('"');
m_tok_HEA = register_token(".HEA"); m_tok_HEA = register_token(".HEA");

View File

@ -72,7 +72,7 @@ protected:
struct replace_t struct replace_t
{ {
pstring m_ce; // controlling element - must be twoterm pstring m_ce; // controlling element - must be a two terminal element
pstring m_repterm; // replace with terminal pstring m_repterm; // replace with terminal
pstring m_net; // connect to net pstring m_net; // connect to net
}; };