diff options
author | 2022-05-22 19:05:22 +0200 | |
---|---|---|
committer | 2022-05-23 03:05:22 +1000 | |
commit | 034e0d2c87a16e90783f742f39850dc7d85def1f (patch) | |
tree | dfb9ed88064a3a21d5a02672de239290275ff45f /src/lib/netlist/plib | |
parent | ceafeebd499737b29b0812923c676638d9f795ef (diff) |
netlist: Address comments from PR #9794, partially fix issue #9801 (#9805)
- added cstddef to includes in ppmf.h
- more explicit comments in ppmf.h
- Fixed more typos and improved readiability
Diffstat (limited to 'src/lib/netlist/plib')
-rw-r--r-- | src/lib/netlist/plib/gmres.h | 10 | ||||
-rw-r--r-- | src/lib/netlist/plib/pdynlib.cpp | 2 | ||||
-rw-r--r-- | src/lib/netlist/plib/pdynlib.h | 2 | ||||
-rw-r--r-- | src/lib/netlist/plib/penum.h | 7 | ||||
-rw-r--r-- | src/lib/netlist/plib/pgsl.h | 4 | ||||
-rw-r--r-- | src/lib/netlist/plib/plists.h | 1 | ||||
-rw-r--r-- | src/lib/netlist/plib/pomp.h | 5 | ||||
-rw-r--r-- | src/lib/netlist/plib/ppmf.h | 40 | ||||
-rw-r--r-- | src/lib/netlist/plib/pstream.h | 15 | ||||
-rw-r--r-- | src/lib/netlist/plib/ptests.h | 4 | ||||
-rw-r--r-- | src/lib/netlist/plib/ptime.h | 2 | ||||
-rw-r--r-- | src/lib/netlist/plib/ptypes.h | 14 |
12 files changed, 63 insertions, 43 deletions
diff --git a/src/lib/netlist/plib/gmres.h b/src/lib/netlist/plib/gmres.h index 91a06371b33..4fd3263b2b3 100644 --- a/src/lib/netlist/plib/gmres.h +++ b/src/lib/netlist/plib/gmres.h @@ -4,6 +4,10 @@ #ifndef PLIB_GMRES_H_ #define PLIB_GMRES_H_ +// Names +// spell-checker: words Burkardt, Saad, Yousef +// + /// /// \file gmres.h /// @@ -203,7 +207,7 @@ namespace plib plib::pmatrix_cr<FT, SIZE> m_mat; }; - // FIXME: hardcoding RESTART to 20 becomes an issue on very large + // FIXME: hard coding RESTART to 20 becomes an issue on very large // systems. template <typename FT, int SIZE, int RESTARTMAX = 16> @@ -270,7 +274,7 @@ namespace plib // ==> rho / accuracy = sqrt(y * y) // // This approach will approximate the iterative stop condition - // based |xnew - xold| pretty precisely. But it is slow, or expressed + // based `|xnew - xold|` pretty precisely. But it is slow, or expressed // differently: The invest doesn't pay off. // @@ -506,7 +510,7 @@ namespace plib } private: - //typedef typename plib::mat_cr_t<FT, SIZE>::index_type mattype; + //#typedef typename plib::mat_cr_t<FT, SIZE>::index_type mattype; plib::parray<float_type, SIZE> residual; plib::parray<float_type, SIZE> Ax; diff --git a/src/lib/netlist/plib/pdynlib.cpp b/src/lib/netlist/plib/pdynlib.cpp index 52fc5effb96..e3883937b69 100644 --- a/src/lib/netlist/plib/pdynlib.cpp +++ b/src/lib/netlist/plib/pdynlib.cpp @@ -40,7 +40,7 @@ dynlib::dynlib(const pstring &libname) // printf("library <%s> not found: %s\n", libname.c_str(), dlerror()); } -dynlib::dynlib( [[maybe_unused]] const pstring &path, const pstring &libname) +dynlib::dynlib([[maybe_unused]] const pstring &path, const pstring &libname) : m_lib(nullptr) { // FIXME: implement path search diff --git a/src/lib/netlist/plib/pdynlib.h b/src/lib/netlist/plib/pdynlib.h index 4e8ce023d6f..63acc44d4eb 100644 --- a/src/lib/netlist/plib/pdynlib.h +++ b/src/lib/netlist/plib/pdynlib.h @@ -45,7 +45,7 @@ namespace plib { { public: explicit dynlib(const pstring &libname); - dynlib(/*[[maybe_unused]]*/ const pstring &path, const pstring &libname); + dynlib(const pstring &path, const pstring &libname); ~dynlib() override; diff --git a/src/lib/netlist/plib/penum.h b/src/lib/netlist/plib/penum.h index a0c5e0ee307..131fc213461 100644 --- a/src/lib/netlist/plib/penum.h +++ b/src/lib/netlist/plib/penum.h @@ -13,9 +13,10 @@ namespace plib { - //============================================================ - // penum - strongly typed enumeration - //============================================================ + /// + /// \brief strongly typed enumeration + /// + /// struct penum_base { protected: diff --git a/src/lib/netlist/plib/pgsl.h b/src/lib/netlist/plib/pgsl.h index 9d7967070db..4fcbdd527f1 100644 --- a/src/lib/netlist/plib/pgsl.h +++ b/src/lib/netlist/plib/pgsl.h @@ -118,8 +118,8 @@ namespace plib { /// \brief cast to void * /// - /// The purpose here is to help identifiy casts to void in the code. - /// These case usuallyindicate some wizard assumptioms which should be easily + /// The purpose here is to help identify casts to void in the code. + /// These case usually indicate some wizard assumptions which should be easily /// be easy to identify. template <typename T> constexpr void * void_ptr_cast(T *ptr) noexcept { return static_cast<void *>(ptr); } diff --git a/src/lib/netlist/plib/plists.h b/src/lib/netlist/plib/plists.h index 4552b441ccc..75b61201f97 100644 --- a/src/lib/netlist/plib/plists.h +++ b/src/lib/netlist/plib/plists.h @@ -39,7 +39,6 @@ namespace plib { using reverse_iterator = std::reverse_iterator<iterator>; using const_reverse_iterator = std::reverse_iterator<const_iterator>; - //uninitialised_array_t() noexcept = default; uninitialised_array() noexcept = default; uninitialised_array(const uninitialised_array &) = default; diff --git a/src/lib/netlist/plib/pomp.h b/src/lib/netlist/plib/pomp.h index d698d6ea34f..b77d3e5ee56 100644 --- a/src/lib/netlist/plib/pomp.h +++ b/src/lib/netlist/plib/pomp.h @@ -71,11 +71,6 @@ inline std::size_t get_max_threads() noexcept #endif } - -// ---------------------------------------------------------------------------------------- -// pdynlib: dynamic loading of libraries ... -// ---------------------------------------------------------------------------------------- - } // namespace plib::omp #endif // PSTRING_H_ diff --git a/src/lib/netlist/plib/ppmf.h b/src/lib/netlist/plib/ppmf.h index b188ca0cd81..44fdc45f1c5 100644 --- a/src/lib/netlist/plib/ppmf.h +++ b/src/lib/netlist/plib/ppmf.h @@ -81,6 +81,7 @@ namespace plib { #include "ptypes.h" #include <algorithm> +#include <cstddef> // ptrdiff_t #include <cstdint> // uintptr_t #include <type_traits> #include <utility> @@ -162,11 +163,31 @@ namespace plib { // extract the generic function and adjust the object pointer void convert_to_generic(generic_function &func, mfp_generic_class *&object) const; - // actual state + /// \brief Byte offset into the vtable + /// + /// On x86-64, the vtable contains pointers to code, and function pointers + /// are pointers to code. To obtain a function pointer for a virtual + /// member function, you fetch a pointer to code from the vtable. + /// + /// On traditional PPC64, the vtable contains pointers to function + /// descriptors, and function pointers are pointers to function descriptors. + /// To obtain a function pointer for a virtual member function, you + /// fetch a pointer to a function descriptor from the vtable. + /// + /// On IA64, the vtable contains function descriptors, and function + /// pointers are pointers to function descriptors. To obtain a + /// function pointer for a virtual member function, you calculate + /// the address of the function descriptor in the vtable. + /// + /// Simply adding the byte offset to the vtable pointer creates a + /// function pointer on IA64 because the vtable contains function + /// descriptors; on most other targets, the vtable contains function + /// pointers, so you need to fetch the function pointer after + /// calculating its address in the vtable. + /// 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 function pointer // if odd, it's the byte offset into the vtable - // or a byte offset into the function descriptors on IA64 ptrdiff_t m_this_delta; // delta to apply to the 'this' pointer }; @@ -184,10 +205,10 @@ namespace plib { void convert_to_generic(generic_function &func, mfp_generic_class *&object) const; // 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 be a function pointer 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 - // m_function is the byte offset into the vtable - // On IA64 it may also be a byte offset into the function descriptors + // if even, m_function is a fuction pointer + // if odd, m_function is the byte offset into the vtable }; template <> @@ -394,6 +415,7 @@ namespace plib { /// is virtual, the vtable may not yet be fully constructed. In these cases /// the following class allows to construct the delegate later. /// + /// ``` /// plib::late_pmfp<plib::pmfp<void, pstring>> a(&nld_7493::printer); /// // Store the a object somewhere /// @@ -401,7 +423,7 @@ namespace plib { /// /// auto delegate_obj = a(this); /// delegate_obj(pstring("Hello World!")); - /// + /// ``` template<typename T> class late_pmfp { @@ -472,8 +494,8 @@ namespace plib { { typename traits::template specific_member_function<O> pFunc; static_assert(sizeof(pFunc) >= sizeof(F), "size error"); - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) - //*reinterpret_cast<F *>(&pFunc) = *mftp; + //# NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) + //# *reinterpret_cast<F *>(&pFunc) = *mftp; reinterpret_copy(*mftp, pFunc); raw_type mfpo(pFunc); generic_function_storage rfunc(nullptr); diff --git a/src/lib/netlist/plib/pstream.h b/src/lib/netlist/plib/pstream.h index 30c9f2b5c08..3c4aa6004d7 100644 --- a/src/lib/netlist/plib/pstream.h +++ b/src/lib/netlist/plib/pstream.h @@ -88,8 +88,7 @@ namespace plib { }; /// -/// -/// putf8reader_t digests linux & dos/windows text files +/// \brief digests linux & dos/windows text files /// // NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) class putf8_reader @@ -201,9 +200,9 @@ private: std::unique_ptr<std::istream> m_strm; }; -// ----------------------------------------------------------------------------- -// putf8writer_t: writer on top of ostream -// ----------------------------------------------------------------------------- +/// +/// \brief writer on top of ostream +/// class putf8_writer { @@ -265,9 +264,9 @@ public: private: }; -// ----------------------------------------------------------------------------- -// pbinary_writer_t: writer on top of ostream -// ----------------------------------------------------------------------------- +/// +/// \brief writer on top of ostream +/// class pbinary_writer { diff --git a/src/lib/netlist/plib/ptests.h b/src/lib/netlist/plib/ptests.h index 856cbacf735..f82b614da7f 100644 --- a/src/lib/netlist/plib/ptests.h +++ b/src/lib/netlist/plib/ptests.h @@ -10,13 +10,13 @@ /// google tests compatible (hopefully) test macros. This is work in progress! /// +#include <algorithm> #include <exception> #include <functional> #include <iostream> +#include <sstream> #include <string> #include <vector> -#include <algorithm> -#include <sstream> #if defined(__clang__) #pragma clang diagnostic ignored "-Wglobal-constructors" diff --git a/src/lib/netlist/plib/ptime.h b/src/lib/netlist/plib/ptime.h index cb597aa590f..6ccafe640ba 100644 --- a/src/lib/netlist/plib/ptime.h +++ b/src/lib/netlist/plib/ptime.h @@ -60,7 +60,7 @@ namespace plib } 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,[[maybe_unused]] 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)) { } diff --git a/src/lib/netlist/plib/ptypes.h b/src/lib/netlist/plib/ptypes.h index 7f09a083793..815b4c8e404 100644 --- a/src/lib/netlist/plib/ptypes.h +++ b/src/lib/netlist/plib/ptypes.h @@ -119,7 +119,7 @@ namespace plib }; // <sys/types.h> on ubuntu system may define major and minor as macros - // That's why we use vmajor, .. here + // That's why we use `vmajor`, .. here template <std::size_t MAJOR, std::size_t MINOR> struct typed_version { @@ -159,7 +159,7 @@ namespace plib using version = typed_version<__clang_major__, __clang_minor__>; #elif defined(__GNUC__) using type = std::integral_constant<ci_compiler, ci_compiler::GCC>; - using version = typed_version< __GNUC__, __GNUC_MINOR__ >; + using version = typed_version<__GNUC__, __GNUC_MINOR__>; #elif defined(_MSC_VER) using type = std::integral_constant<ci_compiler, ci_compiler::MSC>; using version = typed_version<_MSC_VER / 100, _MSC_VER % 100>; @@ -169,10 +169,10 @@ namespace plib #endif #if defined(_LIBCPP_VERSION) using cpp_stdlib = std::integral_constant<ci_cpp_stdlib, ci_cpp_stdlib::LIBCPP>; - using cpp_stdlib_version = std::integral_constant<int, ((_LIBCPP_VERSION) / 1000) * 100 + ((_LIBCPP_VERSION) / 100) % 10>; + using cpp_stdlib_version = typed_version<(_LIBCPP_VERSION) / 1000, ((_LIBCPP_VERSION) / 100) % 10>; #elif defined(__GLIBCXX__) using cpp_stdlib = std::integral_constant<ci_cpp_stdlib, ci_cpp_stdlib::LIBSTDCXX>; - using cpp_stdlib_version = std::integral_constant<int, (_GLIBCXX_RELEASE) * 100>; + using cpp_stdlib_version = typed_version<(_GLIBCXX_RELEASE), 0>; #else using cpp_stdlib = std::integral_constant<ci_cpp_stdlib, ci_cpp_stdlib::UNKNOWN>; using cpp_stdlib_version = std::integral_constant<int, 0>; @@ -286,7 +286,7 @@ namespace plib template<typename T> struct is_floating_point : public std::is_floating_point<T> { }; - template< class T > + template<class T> struct is_arithmetic : std::integral_constant<bool, plib::is_integral<T>::value || plib::is_floating_point<T>::value> {}; @@ -350,7 +350,7 @@ namespace plib /// \brief mark arguments as not used for compiler /// - /// @tparam Ts unsused parameters + /// \tparam Ts unused parameters /// template<typename... Ts> inline void unused_var(Ts&&...) noexcept {} // NOLINT(readability-named-parameter) // FIXME: remove unused var completely @@ -377,7 +377,7 @@ namespace plib /// \brief Test if type R has a stream operator << defined /// - /// has_ostram_operator<std::ostream, int>:: value should be true + /// has_ostream_operator<std::ostream, int>:: value should be true /// /// \tparam LEFT Stream type /// \tparam RIGHT Type to check for operator overload |