diff options
author | 2020-09-24 07:53:46 +0200 | |
---|---|---|
committer | 2020-09-24 15:22:25 +0200 | |
commit | dd5769bea9d3ef209c5cd46507ef6d4800ee1ccf (patch) | |
tree | 450f4cb65340468da3d2f6170a7912f920c24ed5 | |
parent | 1fffeb33c009283f4b29c503440b5c77a7f036d5 (diff) |
netlist: clearly identify void * casts.
-rw-r--r-- | src/lib/netlist/core/netlist_state.h | 4 | ||||
-rw-r--r-- | src/lib/netlist/nl_config.h | 2 | ||||
-rw-r--r-- | src/lib/netlist/plib/palloc.h | 2 | ||||
-rw-r--r-- | src/lib/netlist/plib/pgsl.h | 6 |
4 files changed, 9 insertions, 5 deletions
diff --git a/src/lib/netlist/core/netlist_state.h b/src/lib/netlist/core/netlist_state.h index 1bb7846e80b..8f24fb09d94 100644 --- a/src/lib/netlist/core/netlist_state.h +++ b/src/lib/netlist/core/netlist_state.h @@ -112,13 +112,13 @@ namespace netlist template<typename O, typename C> void save(O &owner, C &state, const pstring &module, const pstring &stname) { - this->run_state_manager().save_item(static_cast<void *>(&owner), state, module + "." + stname); + this->run_state_manager().save_item(plib::void_ptr_cast(&owner), state, module + "." + stname); } template<typename O, typename C> void save(O &owner, C *state, const pstring &module, const pstring &stname, const std::size_t count) { - this->run_state_manager().save_state_ptr(static_cast<void *>(&owner), module + "." + stname, plib::state_manager_t::dtype<C>(), count, state); + this->run_state_manager().save_state_ptr(plib::void_ptr_cast(&owner), module + "." + stname, plib::state_manager_t::dtype<C>(), count, state); } // FIXME: only used by queue_t save state diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h index 9d6b99bd38b..3bd57c2771d 100644 --- a/src/lib/netlist/nl_config.h +++ b/src/lib/netlist/nl_config.h @@ -125,7 +125,7 @@ /// This is about 10% slower on a skylake processor for pongf. /// #ifndef NL_PREFER_INT128 -#define NL_PREFER_INT128 (1) +#define NL_PREFER_INT128 (0) #endif /// \brief Support float type for matrix calculations. diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h index 50507d10eea..ac5094f39a6 100644 --- a/src/lib/netlist/plib/palloc.h +++ b/src/lib/netlist/plib/palloc.h @@ -288,7 +288,7 @@ namespace plib { void construct(U* p, Args&&... args) { // NOLINTNEXTLINE(cppcoreguidelines-owning-memory) - ::new (static_cast<void *>(p)) U(std::forward<Args>(args)...); + ::new (void_ptr_cast(p)) U(std::forward<Args>(args)...); } template<typename U> diff --git a/src/lib/netlist/plib/pgsl.h b/src/lib/netlist/plib/pgsl.h index 590765429eb..1ea8622d19c 100644 --- a/src/lib/netlist/plib/pgsl.h +++ b/src/lib/netlist/plib/pgsl.h @@ -93,7 +93,7 @@ namespace plib { /// and later for debug builds use dynamic_cast. /// template <typename D, typename B> - inline constexpr D downcast(B && b) noexcept + constexpr D downcast(B && b) noexcept { static_assert(std::is_pointer<D>::value || std::is_reference<D>::value, "downcast only supports pointers or reference for derived"); static_assert(std::is_pointer<B>::value || std::is_reference<B>::value, "downcast only supports pointers or reference for base"); @@ -101,6 +101,10 @@ namespace plib { } using pgsl::narrow_cast; + + template <typename T> + constexpr void * void_ptr_cast(T *ptr) noexcept { return static_cast<void *>(ptr); } + } // namespace plib //FIXME: This is the place to use more complete implementations |