diff options
author | 2019-11-08 23:52:14 +0100 | |
---|---|---|
committer | 2019-11-08 23:52:14 +0100 | |
commit | 88f702b416ba9eb930e6c1e932124d5f24b1a24c (patch) | |
tree | 955f3047b79156d7b2bbab55fcbd4fbc94661f1d /src/lib/netlist/plib | |
parent | 731c4fe52073a7a7561bf04559e9f0b3b791388d (diff) |
netlist: code maintenance and bug fixes. (nw)
- comment style migration continues.
- Fixed a two bugs in the truthtable ignore inputs code
- refactored the truthtable code a bit for better readability.
- updated netlist specific gitignore.
Diffstat (limited to 'src/lib/netlist/plib')
38 files changed, 847 insertions, 886 deletions
diff --git a/src/lib/netlist/plib/gmres.h b/src/lib/netlist/plib/gmres.h index ab7e72bcb76..c1c03ea7bd9 100644 --- a/src/lib/netlist/plib/gmres.h +++ b/src/lib/netlist/plib/gmres.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * gmres.h - * - */ #ifndef PLIB_GMRES_H_ #define PLIB_GMRES_H_ +/// +/// \file gmres.h +/// + #include "mat_cr.h" #include "parray.h" #include "pconfig.h" @@ -206,9 +206,9 @@ namespace plib plib::pmatrix_cr_t<FT, SIZE> m_mat; }; - /* FIXME: hardcoding RESTART to 20 becomes an issue on very large - * systems. - */ + // FIXME: hardcoding RESTART to 20 becomes an issue on very large + // systems. + template <typename FT, int SIZE, int RESTART = 80> struct gmres_t { @@ -282,8 +282,8 @@ namespace plib if (rho <= rho_delta || k == RESTART-1) { - /* Solve the system H * y = g */ - /* x += m_v[j] * m_y[j] */ + // Solve the system H * y = g + // x += m_v[j] * m_y[j] for (std::size_t i = k + 1; i-- > 0;) { auto tmp(m_g[i]); @@ -310,27 +310,27 @@ namespace plib template <typename OPS, typename VT, typename VRHS> std::size_t solve(OPS &ops, VT &x, const VRHS & rhs, const std::size_t itr_max, float_type accuracy) { - /*------------------------------------------------------------------------- - * The code below was inspired by code published by John Burkardt under - * the LPGL here: - * - * http://people.sc.fsu.edu/~jburkardt/cpp_src/mgmres/mgmres.html - * - * The code below was completely written from scratch based on the pseudo code - * found here: - * - * http://de.wikipedia.org/wiki/GMRES-Verfahren - * - * The Algorithm itself is described in - * - * Yousef Saad, - * Iterative Methods for Sparse Linear Systems, - * Second Edition, - * SIAM, 20003, - * ISBN: 0898715342, - * LC: QA188.S17. - * - *------------------------------------------------------------------------*/ + // ------------------------------------------------------------------------- + // The code below was inspired by code published by John Burkardt under + // the LPGL here: + // + // http://people.sc.fsu.edu/~jburkardt/cpp_src/mgmres/mgmres.html + // + // The code below was completely written from scratch based on the pseudo code + // found here: + // + // http://de.wikipedia.org/wiki/GMRES-Verfahren + // + // The Algorithm itself is described in + // + // Yousef Saad, + // Iterative Methods for Sparse Linear Systems, + // Second Edition, + // SIAM, 20003, + // ISBN: 0898715342, + // LC: QA188.S17. + // + //------------------------------------------------------------------------ std::size_t itr_used = 0; auto rho_delta(plib::constants<float_type>::zero()); @@ -341,16 +341,16 @@ namespace plib if (m_use_more_precise_stop_condition) { - /* derive residual for a given delta x - * - * LU y = A dx - * - * ==> rho / accuracy = sqrt(y * y) - * - * This approach will approximate the iterative stop condition - * based |xnew - xold| pretty precisely. But it is slow, or expressed - * differently: The invest doesn't pay off. - */ + // derive residual for a given delta x + // + // LU y = A dx + // + // ==> rho / accuracy = sqrt(y * y) + // + // This approach will approximate the iterative stop condition + // based |xnew - xold| pretty precisely. But it is slow, or expressed + // differently: The invest doesn't pay off. + // vec_set_scalar(n, residual, accuracy); ops.calc_rhs(Ax, residual); @@ -364,18 +364,17 @@ namespace plib else rho_delta = accuracy * plib::sqrt(static_cast<FT>(n)); - /* - * Using - * - * vec_set(n, x, rhs); - * ops.solve_inplace(x); - * - * to get a starting point for x degrades convergence speed compared - * to using the last solution for x. - * - * LU x = b; solve for x; - * - */ + // + // Using + // + // vec_set(n, x, rhs); + // ops.solve_inplace(x); + // + // to get a starting point for x degrades convergence speed compared + // to using the last solution for x. + // + // LU x = b; solve for x; + // while (itr_used < itr_max) { @@ -392,10 +391,10 @@ namespace plib if (rho < rho_delta) return itr_used + 1; - /* FIXME: The "+" is necessary to avoid link issues - * on some systems / compiler versions. Issue reported by - * AJR, no details known yet. - */ + // FIXME: The "+" is necessary to avoid link issues + // on some systems / compiler versions. Issue reported by + // AJR, no details known yet. + vec_set_scalar(RESTART+1, m_g, +constants<FT>::zero()); m_g[0] = rho; @@ -415,14 +414,13 @@ namespace plib plib::parray<float_type, SIZE> residual; plib::parray<float_type, SIZE> Ax; - plib::parray<float_type, RESTART + 1> m_c; /* mr + 1 */ - plib::parray<float_type, RESTART + 1> m_g; /* mr + 1 */ - plib::parray2D<float_type, RESTART + 1, RESTART> m_ht; /* (mr + 1), mr */ - plib::parray<float_type, RESTART + 1> m_s; /* mr + 1 */ - plib::parray<float_type, RESTART + 1> m_y; /* mr + 1 */ + plib::parray<float_type, RESTART + 1> m_c; // mr + 1 + plib::parray<float_type, RESTART + 1> m_g; // mr + 1 + plib::parray2D<float_type, RESTART + 1, RESTART> m_ht; // (mr + 1), mr + plib::parray<float_type, RESTART + 1> m_s; // mr + 1 + plib::parray<float_type, RESTART + 1> m_y; // mr + 1 - //plib::parray<plib::parray<float_type, storage_N>, RESTART + 1> m_v; /* mr + 1, n */ - plib::parray2D<float_type, RESTART + 1, SIZE> m_v; /* mr + 1, n */ + plib::parray2D<float_type, RESTART + 1, SIZE> m_v; // mr + 1, n std::size_t m_size; @@ -433,12 +431,11 @@ namespace plib #if 0 - /* Example of a Chebyshev iteration solver. This one doesn't work yet, - * it needs to be extended for non-symmetric matrix operation and - * depends on spectral radius estimates - which we don't have. - * - * Left here as another example. - */ + // Example of a Chebyshev iteration solver. This one doesn't work yet, + // it needs to be extended for non-symmetric matrix operation and + // depends on spectral radius estimates - which we don't have. + // + // Left here as another example. template <typename FT, int SIZE> struct ch_t @@ -464,11 +461,6 @@ namespace plib template <typename OPS, typename VT, typename VRHS> std::size_t solve(OPS &ops, VT &x0, const VRHS & rhs, const std::size_t iter_max, float_type accuracy) { - /*------------------------------------------------------------------------- - * - * - *------------------------------------------------------------------------*/ - ops.precondition(); const FT lmax = 20.0; @@ -531,4 +523,4 @@ namespace plib } // namespace plib -#endif /* PLIB_GMRES_H_ */ +#endif // PLIB_GMRES_H_ diff --git a/src/lib/netlist/plib/mat_cr.h b/src/lib/netlist/plib/mat_cr.h index d87faef8225..9d885ffb884 100644 --- a/src/lib/netlist/plib/mat_cr.h +++ b/src/lib/netlist/plib/mat_cr.h @@ -1,15 +1,15 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * mat_cr.h - * - * Compressed row format matrices - * - */ #ifndef MAT_CR_H_ #define MAT_CR_H_ +/// +/// \file mat_cr.h +/// +/// Compressed row format matrices +/// + #include "palloc.h" #include "parray.h" #include "pconfig.h" @@ -132,7 +132,7 @@ namespace plib row_idx[size()] = nz; nz_num = nz; - /* build nzbd */ + // build nzbd for (std::size_t k=0; k < size(); k++) { @@ -147,9 +147,8 @@ namespace plib template <typename VTV, typename VTR> void mult_vec(VTR & res, const VTV & x) const noexcept { - /* - * res = A * x - */ + + // res = A * x #if 0 //plib::omp::set_num_threads(4); plib::omp::for_static(0, constants<std::size_t>::zero(), m_size, [this, &res, &x](std::size_t row) @@ -176,7 +175,7 @@ namespace plib #endif } - /* throws error if P(source)>P(destination) */ + // throws error if P(source)>P(destination) template <typename LUMAT> void slim_copy_from(LUMAT & src) { @@ -185,20 +184,20 @@ namespace plib C dp = row_idx[r]; for (C sp = src.row_idx[r]; sp < src.row_idx[r+1]; sp++) { - /* advance dp to source column and fill 0s if necessary */ + // advance dp to source column and fill 0s if necessary while (col_idx[dp] < src.col_idx[sp]) A[dp++] = 0; if (row_idx[r+1] <= dp || col_idx[dp] != src.col_idx[sp]) pthrow<pexception>("slim_copy_from error"); A[dp++] = src.A[sp]; } - /* fill remaining elements in row */ + // fill remaining elements in row while (dp < row_idx[r+1]) A[dp++] = 0; } } - /* only copies common elements */ + // only copies common elements template <typename LUMAT> void reduction_copy_from(LUMAT & src) noexcept { @@ -208,7 +207,7 @@ namespace plib C dp(row_idx[r]); while(sp < src.row_idx[r+1]) { - /* advance dp to source column and fill 0s if necessary */ + // advance dp to source column and fill 0s if necessary if (col_idx[dp] < src.col_idx[sp]) A[dp++] = 0; else if (col_idx[dp] == src.col_idx[sp]) @@ -216,13 +215,13 @@ namespace plib else sp++; } - /* fill remaining elements in row */ + // fill remaining elements in row while (dp < row_idx[r+1]) A[dp++] = 0; } } - /* no checks at all - may crash */ + // no checks at all - may crash template <typename LUMAT> void raw_copy_from(LUMAT & src) noexcept { @@ -379,7 +378,7 @@ namespace plib void gaussian_back_substitution(V1 &V, const V2 &RHS) { const std::size_t iN = base::size(); - /* row n-1 */ + // row n-1 V[iN - 1] = RHS[iN - 1] / base::A[base::diag[iN - 1]]; for (std::size_t j = iN - 1; j-- > 0;) @@ -397,7 +396,7 @@ namespace plib void gaussian_back_substitution(V1 &V) { const std::size_t iN = base::size(); - /* row n-1 */ + // row n-1 V[iN - 1] = V[iN - 1] / base::A[base::diag[iN - 1]]; for (std::size_t j = iN - 1; j-- > 0;) @@ -492,7 +491,7 @@ namespace plib void build(M &fill, std::size_t ilup) { std::size_t p(0); - /* build ilu_rows */ + // build ilu_rows for (decltype(fill.size()) i=1; i < fill.size(); i++) { bool found(false); @@ -526,25 +525,25 @@ namespace plib m_ILUp = ilup; } + /// \brief incomplete LU Factorization. + /// + /// We are following http://de.wikipedia.org/wiki/ILU-Zerlegung here. + /// + /// The result is stored in matrix LU + /// + /// For i = 1,...,N-1 + /// For k = 0, ... , i - 1 + /// If a[i,k] != 0 + /// a[i,k] = a[i,k] / a[k,k] + /// For j = k + 1, ... , N - 1 + /// If a[i,j] != 0 + /// a[i,j] = a[i,j] - a[i,k] * a[k,j] + /// j=j+1 + /// k=k+1 + /// i=i+1 + /// void incomplete_LU_factorization(const base &mat) { - /* - * incomplete LU Factorization according to http://de.wikipedia.org/wiki/ILU-Zerlegung - * - * Result is stored in matrix LU - * - * For i = 1,...,N-1 - * For k = 0, ... , i - 1 - * If a[i,k] != 0 - * a[i,k] = a[i,k] / a[k,k] - * For j = k + 1, ... , N - 1 - * If a[i,j] != 0 - * a[i,j] = a[i,j] - a[i,k] * a[k,j] - * j=j+1 - * k=k+1 - * i=i+1 - * - */ if (m_ILUp < 1) this->raw_copy_from(mat); else @@ -568,7 +567,7 @@ namespace plib while (i_j < p_i_end && k_j < p_k_end ) // pj = (i, j) { - // we can assume that within a row ja increases continuously */ + // we can assume that within a row ja increases continuously const std::size_t c_i_j(base::col_idx[i_j]); // row i, column j const auto c_k_j(base::col_idx[k_j]); // row k, column j @@ -582,30 +581,32 @@ namespace plib } } + + /// \brief Solve a linear equation + /// + /// Solve a linear equation Ax = r + /// + /// where + /// A = L*U + /// + /// L unit lower triangular + /// U upper triangular + /// + /// ==> LUx = r + /// + /// ==> Ux = L⁻¹ r = w + /// + /// ==> r = Lw + /// + /// This can be solved for w using backwards elimination in L. + /// + /// Now Ux = w + /// + /// This can be solved for x using backwards elimination in U. + /// template <typename R> void solveLU (R &r) { - /* - * Solve a linear equation Ax = r - * where - * A = L*U - * - * L unit lower triangular - * U upper triangular - * - * ==> LUx = r - * - * ==> Ux = L⁻¹ r = w - * - * ==> r = Lw - * - * This can be solved for w using backwards elimination in L. - * - * Now Ux = w - * - * This can be solved for x using backwards elimination in U. - * - */ for (std::size_t i = 1; i < base::size(); ++i ) { typename base::value_type tmp(0); @@ -634,4 +635,4 @@ namespace plib } // namespace plib -#endif /* MAT_CR_H_ */ +#endif // MAT_CR_H_ diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h index 2873d5a0be9..8b83a1970d6 100644 --- a/src/lib/netlist/plib/palloc.h +++ b/src/lib/netlist/plib/palloc.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * palloc.h - * - */ #ifndef PALLOC_H_ #define PALLOC_H_ +/// +/// \file palloc.h +/// + #include "pconfig.h" #include "pstring.h" #include "ptypes.h" @@ -59,9 +59,9 @@ namespace plib { std::enable_if<std::is_convertible< U*, T*>::value>::type> arena_deleter(const arena_deleter<PU, U> &rhs) : m_a(rhs.m_a) { } #endif - void operator()(T *p) noexcept //const + void operator()(T *p) noexcept { - /* call destructor */ + // call destructor p->~T(); getref(m_a).deallocate(p); } @@ -156,9 +156,9 @@ namespace plib { m_ptr = nullptr; } - /** - * \brief Return @c true if the stored pointer is not null. - */ + /// + /// \brief Return \c true if the stored pointer is not null. + /// explicit operator bool() const noexcept { return m_ptr != nullptr; } pointer release() @@ -349,7 +349,7 @@ namespace plib { }; template <typename T, std::size_t ALIGN> - /*inline */ C14CONSTEXPR T *assume_aligned_ptr(T *p) noexcept + C14CONSTEXPR T *assume_aligned_ptr(T *p) noexcept { static_assert(ALIGN >= alignof(T), "Alignment must be greater or equal to alignof(T)"); static_assert(is_pow2(ALIGN), "Alignment must be a power of 2"); @@ -473,4 +473,4 @@ namespace plib { } // namespace plib -#endif /* PALLOC_H_ */ +#endif // PALLOC_H_ diff --git a/src/lib/netlist/plib/parray.h b/src/lib/netlist/plib/parray.h index 174d047f35c..ea240faaac7 100644 --- a/src/lib/netlist/plib/parray.h +++ b/src/lib/netlist/plib/parray.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * parray.h - * - */ #ifndef PARRAY_H_ #define PARRAY_H_ +/// +/// \file parray.h +/// + #include "palloc.h" #include "pconfig.h" #include "pexception.h" @@ -36,21 +36,20 @@ namespace plib { using container = typename std::vector<FT, aligned_allocator<FT, PALIGN_VECTOROPT>>; }; - /** - * \brief Array with preallocated or dynamic allocation - * - * Passing SIZE > 0 has the same functionality as a std::array. - * SIZE = 0 is pure dynamic allocation, the actual array size is passed to the - * constructor. - * SIZE < 0 reserves abs(SIZE) elements statically in place allocated. The - * actual size is passed in by the constructor. - * This array is purely intended for HPC application where depending on the - * architecture a preference dynamic/static has to be made. - * - * This struct is not intended to be a full replacement to std::array. - * It is a subset to enable switching between dynamic and static allocation. - * I consider > 10% performance difference to be a use case. - */ + /// \brief Array with preallocated or dynamic allocation. + /// + /// Passing SIZE > 0 has the same functionality as a std::array. + /// SIZE = 0 is pure dynamic allocation, the actual array size is passed to the + /// constructor. + /// SIZE < 0 reserves abs(SIZE) elements statically in place allocated. The + /// actual size is passed in by the constructor. + /// This array is purely intended for HPC application where depending on the + /// architecture a preference dynamic/static has to be made. + /// + /// This struct is not intended to be a full replacement to std::array. + /// It is a subset to enable switching between dynamic and static allocation. + /// I consider > 10% performance difference to be a use case. + /// template <typename FT, int SIZE> struct parray @@ -96,7 +95,7 @@ namespace plib { } - /* allow construction in fixed size arrays */ + // allow construction in fixed size arrays parray() : m_size(SIZEABS()) { @@ -176,4 +175,4 @@ namespace plib { -#endif /* PARRAY_H_ */ +#endif // PARRAY_H_ diff --git a/src/lib/netlist/plib/pchrono.h b/src/lib/netlist/plib/pchrono.h index 63c21a419d3..640921e15d8 100644 --- a/src/lib/netlist/plib/pchrono.h +++ b/src/lib/netlist/plib/pchrono.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pchrono.h - * - */ #ifndef PCHRONO_H_ #define PCHRONO_H_ +/// +/// \file pchrono.h +/// + #include "pconfig.h" #include "ptypes.h" @@ -65,9 +65,9 @@ namespace plib { "rdtscp;" "shl $32, %%rdx;" "or %%rdx, %%rax;" - : "=a"(v) /* outputs */ - : /* inputs */ - : "%rcx", "%rdx" /* clobbers */ + : "=a"(v) // outputs + : // inputs + : "%rcx", "%rdx" // clobbers ); return v; } @@ -88,9 +88,9 @@ namespace plib { "rdtsc;" "shl $32, %%rdx;" "or %%rdx, %%rax;" - : "=a"(v) /* outputs */ - : /* inputs */ - : "%rdx" /* clobbers */ + : "=a"(v) // outputs + : // inputs + : "%rdx" // clobbers ); return v; } @@ -103,16 +103,14 @@ namespace plib { #endif - /* Based on "How to Benchmark Code Execution Times on Intel?? IA-32 and IA-64 - * Instruction Set Architectures", Intel, 2010 - * - */ + // Based on "How to Benchmark Code Execution Times on Intel?? IA-32 and IA-64 + // Instruction Set Architectures", Intel, 2010 + #if PUSE_ACCURATE_STATS && PHAS_RDTSCP - /* - * kills performance completely, but is accurate - * cpuid serializes, but clobbers ebx and ecx - * - */ + // + // kills performance completely, but is accurate + // cpuid serializes, but clobbers ebx and ecx + // struct exact_ticks : public base_ticks<exact_ticks, int64_t> { @@ -127,9 +125,9 @@ namespace plib { "rdtsc;" "shl $32, %%rdx;" "or %%rdx, %%rax;" - : "=a"(v) /* outputs */ - : "a"(0x0) /* inputs */ - : "%ebx", "%ecx", "%rdx" /* clobbers*/ + : "=a"(v) // outputs + : "a"(0x0) // inputs + : "%ebx", "%ecx", "%rdx" // clobbers ); return v; } @@ -235,9 +233,9 @@ namespace plib { { guard_t() = default; COPYASSIGNMOVE(guard_t, default) - /* using default constructor will trigger warning on - * unused local variable. - */ + // using default constructor will trigger warning on + // unused local variable. + // NOLINTNEXTLINE(modernize-use-equals-default) ~guard_t() { } }; @@ -265,4 +263,4 @@ namespace plib { using pperfcount_t = plib::chrono::counter<enabled_>; } // namespace plib -#endif /* PCHRONO_H_ */ +#endif // PCHRONO_H_ diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h index 58a9387c51c..bb954eefa48 100644 --- a/src/lib/netlist/plib/pconfig.h +++ b/src/lib/netlist/plib/pconfig.h @@ -1,102 +1,117 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pconfig.h - * - */ #ifndef PCONFIG_H_ #define PCONFIG_H_ -/* - * Define this for more accurate measurements if you processor supports - * RDTSCP. - */ +/// +/// \file pconfig.h +/// + +/// \brief More accurate measurements if you processor supports RDTSCP. +/// #ifndef PHAS_RDTSCP #define PHAS_RDTSCP (0) #endif -/* - * Define this to use accurate timing measurements. Only works - * if PHAS_RDTSCP == 1 - */ +/// \brief Use accurate timing measurements. +/// +/// Only works if \ref PHAS_RDTSCP == 1 +/// #ifndef PUSE_ACCURATE_STATS #define PUSE_ACCURATE_STATS (0) #endif -/* - * Set this to one if you want to use 128 bit int for ptime. - * This is about 5% slower on a kaby lake processor. - */ - +/// \brief System supports INT128 +/// +/// Set this to one if you want to use 128 bit int for ptime. +/// This is about 5% slower on a kaby lake processor. +/// #ifndef PHAS_INT128 #define PHAS_INT128 (0) #endif -/*! Add support for the __float128 floating point type. - * - * - */ - +/// \brief Add support for the __float128 floating point type. +/// #ifndef PUSE_FLOAT128 #define PUSE_FLOAT128 (0) #endif -/* - * OpenMP adds about 10% to 20% performance for analog - * netlists like kidniki. - */ - +/// \brief Compile with support for OPENMP +/// +/// OpenMP adds about 10% to 20% performance for analog netlists. +/// #ifndef PUSE_OPENMP #define PUSE_OPENMP (0) #endif -/* - * Set this to one if you want to use aligned storage optimizations. - */ - +/// \brief Use aligned optimizations. +/// +/// Set this to one if you want to use aligned storage optimizations. +/// #ifndef PUSE_ALIGNED_OPTIMIZATIONS #define PUSE_ALIGNED_OPTIMIZATIONS (0) #endif +/// \brief Use aligned allocations. +/// +/// Set this to one if you want to use aligned storage optimizations. +/// +/// Defaults to \ref PUSE_ALIGNED_OPTIMIZATIONS. +/// #define PUSE_ALIGNED_ALLOCATION (PUSE_ALIGNED_OPTIMIZATIONS) + +/// \brief Use aligned hints. +/// +/// Some compilers support special functions to mark a pointer as being +/// aligned. Set this to one if you want to use these functions. +/// +/// Defaults to \ref PUSE_ALIGNED_OPTIMIZATIONS. +/// #define PUSE_ALIGNED_HINTS (PUSE_ALIGNED_OPTIMIZATIONS) -/* - * Standard alignment macros - */ +/// \brief Number of bytes for cache line alignment +/// #define PALIGN_CACHELINE (64) + +/// \brief Number of bytes for vector alignment +/// #define PALIGN_VECTOROPT (64) #define PALIGNAS_CACHELINE() PALIGNAS(PALIGN_CACHELINE) #define PALIGNAS_VECTOROPT() PALIGNAS(PALIGN_VECTOROPT) -/* Breaks mame build on windows due to -Wattribute - * FIXME: no error on cross-compile - need further checks */ +// Breaks mame build on windows due to -Wattribute +// FIXME: no error on cross-compile - need further checks #if defined(_WIN32) && defined(__GNUC__) #define PALIGNAS(x) #else #define PALIGNAS(x) alignas(x) #endif -/*============================================================ - * Check for CPP Version - * - * C++11: __cplusplus is 201103L. - * C++14: __cplusplus is 201402L. - * c++17/c++1z__cplusplus is 201703L. - * - * VS2015 returns 199711L here. This is the bug filed in - * 2012 which obviously never was picked up by MS: - * https://connect.microsoft.com/VisualStudio/feedback/details/763051/a-value-of-predefined-macro-cplusplus-is-still-199711l - * - * - *============================================================*/ - +/// \brief nvcc build flag. +/// +/// Set this to 1 if you are building with NVIDIA nvcc +/// #ifndef NVCCBUILD #define NVCCBUILD (0) #endif +// ============================================================ +// Check for CPP Version +// +// C++11: __cplusplus is 201103L. +// C++14: __cplusplus is 201402L. +// c++17/c++1z__cplusplus is 201703L. +// +// VS2015 returns 199711L here. This is the bug filed in +// 2012 which obviously never was picked up by MS: +// https://connect.microsoft.com/VisualStudio/feedback/details/763051/a-value-of-predefined-macro-cplusplus-is-still-199711l +// +// +//============================================================ + + #if NVCCBUILD #define C14CONSTEXPR #else @@ -150,4 +165,4 @@ typedef __int128_t INT128; #endif -#endif /* PCONFIG_H_ */ +#endif // PCONFIG_H_ diff --git a/src/lib/netlist/plib/pdynlib.cpp b/src/lib/netlist/plib/pdynlib.cpp index 828096d1b0c..a569d36dad5 100644 --- a/src/lib/netlist/plib/pdynlib.cpp +++ b/src/lib/netlist/plib/pdynlib.cpp @@ -1,9 +1,5 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * dynlib.c - * - */ #include "pdynlib.h" diff --git a/src/lib/netlist/plib/pdynlib.h b/src/lib/netlist/plib/pdynlib.h index b2fbb1487d2..b776d8e9b89 100644 --- a/src/lib/netlist/plib/pdynlib.h +++ b/src/lib/netlist/plib/pdynlib.h @@ -1,12 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pdynlib.h - */ #ifndef PDYNLIB_H_ #define PDYNLIB_H_ +/// +/// \file pdynlib.h +/// + #include "pstring.h" #include "ptypes.h" @@ -69,4 +70,4 @@ private: } // namespace plib -#endif /* PSTRING_H_ */ +#endif // PSTRING_H_ diff --git a/src/lib/netlist/plib/pexception.cpp b/src/lib/netlist/plib/pexception.cpp index 1b32549be87..6b53d362c79 100644 --- a/src/lib/netlist/plib/pexception.cpp +++ b/src/lib/netlist/plib/pexception.cpp @@ -1,9 +1,5 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * palloc.c - * - */ #include "pexception.h" #include "pfmtlog.h" diff --git a/src/lib/netlist/plib/pexception.h b/src/lib/netlist/plib/pexception.h index ba99b71cf73..7317a320e28 100644 --- a/src/lib/netlist/plib/pexception.h +++ b/src/lib/netlist/plib/pexception.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * palloc.h - * - */ #ifndef PEXCEPTION_H_ #define PEXCEPTION_H_ +/// +/// \file: pexception.h +/// + #include "pstring.h" #include "ptypes.h" @@ -15,19 +15,18 @@ namespace plib { - /*! Terminate the program. - * - * \note could be enhanced by setting a termination handler - */ + /// \brief Terminate the program. + /// + /// \note could be enhanced by setting a termination handler + /// [[noreturn]] void terminate(const pstring &msg) noexcept; - - ///! throw an exception. + /// \brief throw an exception. /// /// throws an exception E. The purpose is to clearly identify exception /// throwing in the code /// - /// @tparam E Type of exception to be thrown + /// \tparam E Type of exception to be thrown /// template<typename E, typename... Args> [[noreturn]] static inline void pthrow(Args&&... args) noexcept(false) @@ -87,9 +86,9 @@ namespace plib { explicit out_of_mem_e(const pstring &location); }; - /* 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. - */ + // 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. + // class fpexception_e : public pexception { @@ -104,10 +103,8 @@ namespace plib { static constexpr unsigned FP_INVALID = 0x00010; static constexpr unsigned FP_ALL = 0x0001f; - /* - * Catch SIGFPE on linux for debugging purposes. - */ - + /// \brief Catch SIGFPE on linux for debugging purposes. + /// class fpsignalenabler { public: @@ -117,9 +114,16 @@ namespace plib { ~fpsignalenabler(); - /* is the functionality supported ? */ + /// \brief is the functionality supported. + /// + /// \return current status + /// static bool supported(); - /* returns last global enable state */ + /// \brief get/set global enable status + /// + /// \param enable new status + /// \return returns last global enable state + /// static bool global_enable(bool enable); private: @@ -131,4 +135,4 @@ namespace plib { } // namespace plib -#endif /* PEXCEPTION_H_ */ +#endif // PEXCEPTION_H_ diff --git a/src/lib/netlist/plib/pfmtlog.cpp b/src/lib/netlist/plib/pfmtlog.cpp index 8f6836fee0c..77a9034ac26 100644 --- a/src/lib/netlist/plib/pfmtlog.cpp +++ b/src/lib/netlist/plib/pfmtlog.cpp @@ -1,9 +1,5 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pfm_log.cpp - * - */ #include "pfmtlog.h" #include "palloc.h" diff --git a/src/lib/netlist/plib/pfmtlog.h b/src/lib/netlist/plib/pfmtlog.h index fecb3dd95bd..aaa43505293 100644 --- a/src/lib/netlist/plib/pfmtlog.h +++ b/src/lib/netlist/plib/pfmtlog.h @@ -1,8 +1,9 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pfmtlog.h - */ + +/// +/// \file pfmtlog.h +/// #ifndef PFMT_H_ #define PFMT_H_ @@ -310,7 +311,7 @@ public: COPYASSIGNMOVE(pfmt_writer_t, delete) - /* runtime enable */ + // runtime enable template<bool enabled, typename... Args> void log(const pstring & fmt, Args&&... args) const noexcept { @@ -405,4 +406,4 @@ public: template<typename T> plib::pfmt& operator<<(plib::pfmt &p, T&& val) { return p(std::forward<T>(val)); } -#endif /* PSTRING_H_ */ +#endif // PSTRING_H_ diff --git a/src/lib/netlist/plib/pfunction.cpp b/src/lib/netlist/plib/pfunction.cpp index 44b037e827b..a1530a5590e 100644 --- a/src/lib/netlist/plib/pfunction.cpp +++ b/src/lib/netlist/plib/pfunction.cpp @@ -1,9 +1,5 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * palloc.c - * - */ #include "pfunction.h" #include "pexception.h" diff --git a/src/lib/netlist/plib/pfunction.h b/src/lib/netlist/plib/pfunction.h index d62d79cc00d..643a8b1ae26 100644 --- a/src/lib/netlist/plib/pfunction.h +++ b/src/lib/netlist/plib/pfunction.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pfunction.h - * - */ #ifndef PFUNCTION_H_ #define PFUNCTION_H_ +/// +/// \file pfunction.h +/// + #include "pmath.h" #include "pstate.h" #include "pstring.h" @@ -21,10 +21,10 @@ namespace plib { // function evaluation //============================================================ - /*! Class providing support for evaluating expressions - * - * @tparam NT Number type, should be float or double - */ + /// \brief Class providing support for evaluating expressions + /// + /// \tparam NT Number type, should be float or double + /// template <typename NT> class pfunction { @@ -37,7 +37,7 @@ namespace plib { POW, SIN, COS, - RAND, /* random number between 0 and 1 */ + RAND, /// random number between 0 and 1 TRUNC, PUSH_CONST, PUSH_INPUT @@ -49,52 +49,54 @@ namespace plib { NT m_param; }; public: - /*! Constructor with state saving support - * - * @param name Name of this object - * @param owner Owner of this object - * @param state_manager State manager to handle saving object state - * - */ + + /// \brief Constructor with state saving support + /// + /// \param name Name of this object + /// \param owner Owner of this object + /// \param state_manager State manager to handle saving object state + /// + /// pfunction(const pstring &name, const void *owner, state_manager_t &state_manager) : m_lfsr(0xACE1u) { state_manager.save_item(owner, m_lfsr, name + ".lfsr"); } - /*! Constructor without state saving support - * - */ + /// \brief Constructor without state saving support + /// pfunction() : m_lfsr(0xACE1u) { } - /*! Compile an expression - * - * @param inputs Vector of input variables, e.g. {"A","B"} - * @param expr infix or postfix expression. default is infix, postrix - * to be prefixed with rpn, e.g. "rpn:A B + 1.3 /" - */ + /// \brief Compile an expression + /// + /// \param inputs Vector of input variables, e.g. {"A","B"} + /// \param expr infix or postfix expression. default is infix, postrix + /// to be prefixed with rpn, e.g. "rpn:A B + 1.3 /" + /// void compile(const std::vector<pstring> &inputs, const pstring &expr); - /*! Compile a rpn expression - * - * @param inputs Vector of input variables, e.g. {"A","B"} - * @param expr Reverse polish notation expression, e.g. "A B + 1.3 /" - */ + /// \brief Compile a rpn expression + /// + /// \param inputs Vector of input variables, e.g. {"A","B"} + /// \param expr Reverse polish notation expression, e.g. "A B + 1.3 /" + /// void compile_postfix(const std::vector<pstring> &inputs, const pstring &expr); - /*! Compile an infix expression - * - * @param inputs Vector of input variables, e.g. {"A","B"} - * @param expr Infix expression, e.g. "(A+B)/1.3" - */ + + /// \brief Compile an infix expression + /// + /// \param inputs Vector of input variables, e.g. {"A","B"} + /// \param expr Infix expression, e.g. "(A+B)/1.3" + /// void compile_infix(const std::vector<pstring> &inputs, const pstring &expr); - /*! Evaluate the expression - * - * @param values for input variables, e.g. {1.1, 2.2} - * @return value of expression - */ + + /// \brief Evaluate the expression + /// + /// \param values for input variables, e.g. {1.1, 2.2} + /// \return value of expression + /// NT evaluate(const std::vector<NT> &values) noexcept; private: @@ -124,4 +126,4 @@ namespace plib { #endif } // namespace plib -#endif /* PEXCEPTION_H_ */ +#endif // PEXCEPTION_H_ diff --git a/src/lib/netlist/plib/plists.h b/src/lib/netlist/plib/plists.h index 792d157e837..8356d1d6199 100644 --- a/src/lib/netlist/plib/plists.h +++ b/src/lib/netlist/plib/plists.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * plists.h - * - */ #ifndef PLISTS_H_ #define PLISTS_H_ +/// +/// \file plists.h +/// + #include "palloc.h" #include "pchrono.h" #include "pstring.h" @@ -22,12 +22,12 @@ namespace plib { - /**! fixed size array allowing to override constructor and initialize members by placement new. - * - * Use with care. This template is provided to improve locality of storage - * in high frequency applications. It should not be used for anything else. - * - */ + /// \brief fixed size array allowing to override constructor and initialize members by placement new. + /// + /// Use with care. This template is provided to improve locality of storage + /// in high frequency applications. It should not be used for anything else. + /// + /// template <class C, std::size_t N> class uninitialised_array_t { @@ -92,16 +92,16 @@ namespace plib { private: - /* ensure proper alignment */ + // ensure proper alignment PALIGNAS_VECTOROPT() std::array<typename std::aligned_storage<sizeof(C), alignof(C)>::type, N> m_buf; unsigned m_initialized; }; - /**! a simple linked list. - * - * the list allows insertions deletions whilst being processed. - */ + /// \brief a simple linked list. + /// + /// The list allows insertions deletions whilst being processed. + /// template <class LC> class linkedlist_t { @@ -194,7 +194,7 @@ namespace plib { elem->m_next->m_prev = elem->m_prev; else { - /* update tail */ + // update tail } } @@ -292,7 +292,7 @@ namespace plib { Element m_object; }; - /* Use TS = true for a threadsafe queue */ + // Use TS = true for a threadsafe queue template <class T, bool TS> class timed_queue_linear : nocopyassignmove { @@ -311,7 +311,7 @@ namespace plib { void push(T && e) noexcept { #if 0 - /* Lock */ + // Lock lock_guard_type lck(m_lock); T * i(m_end-1); for (; *i < e; --i) @@ -323,7 +323,7 @@ namespace plib { *(i+1) = std::move(e); ++m_end; #else - /* Lock */ + // Lock lock_guard_type lck(m_lock); T * i(m_end++); *i = std::move(e); @@ -344,7 +344,7 @@ namespace plib { template <bool KEEPSTAT, class R> void remove(const R &elem) noexcept { - /* Lock */ + // Lock lock_guard_type lck(m_lock); if (KEEPSTAT) m_prof_remove.inc(); @@ -362,7 +362,7 @@ namespace plib { template <bool KEEPSTAT, class R> void retime(R && elem) noexcept { - /* Lock */ + // Lock lock_guard_type lck(m_lock); if (KEEPSTAT) m_prof_retime.inc(); @@ -391,10 +391,10 @@ namespace plib { { lock_guard_type lck(m_lock); m_end = &m_list[0]; - /* put an empty element with maximum time into the queue. - * the insert algo above will run into this element and doesn't - * need a comparison with queue start. - */ + // put an empty element with maximum time into the queue. + // the insert algo above will run into this element and doesn't + // need a comparison with queue start. + // m_list[0] = T::never(); m_end++; } @@ -443,7 +443,7 @@ namespace plib { template <bool KEEPSTAT> void push(T &&e) noexcept { - /* Lock */ + // Lock lock_guard_type lck(m_lock); *m_end++ = e; std::push_heap(&m_list[0], m_end, compare()); @@ -464,7 +464,7 @@ namespace plib { template <bool KEEPSTAT, class R> void remove(const R &elem) noexcept { - /* Lock */ + // Lock lock_guard_type lck(m_lock); if (KEEPSTAT) m_prof_remove.inc(); @@ -484,7 +484,7 @@ namespace plib { template <bool KEEPSTAT> void retime(const T &elem) noexcept { - /* Lock */ + // Lock lock_guard_type lck(m_lock); if (KEEPSTAT) m_prof_retime.inc(); @@ -529,4 +529,4 @@ namespace plib { } // namespace plib -#endif /* PLISTS_H_ */ +#endif // PLISTS_H_ diff --git a/src/lib/netlist/plib/pmain.cpp b/src/lib/netlist/plib/pmain.cpp index 1ecf0a4d032..d603baeb474 100644 --- a/src/lib/netlist/plib/pmain.cpp +++ b/src/lib/netlist/plib/pmain.cpp @@ -1,9 +1,5 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pmain.cpp - * - */ #include "pmain.h" @@ -29,10 +25,6 @@ namespace plib { } #endif -/*************************************************************************** - Application -***************************************************************************/ - app::app() : options() , pout(&std::cout) diff --git a/src/lib/netlist/plib/pmain.h b/src/lib/netlist/plib/pmain.h index 288e3bc8536..afa5adb3267 100644 --- a/src/lib/netlist/plib/pmain.h +++ b/src/lib/netlist/plib/pmain.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * poptions.h - * - */ #ifndef PMAIN_H_ #define PMAIN_H_ +/// +/// \file poptions.h +/// + #include "palloc.h" #include "poptions.h" #include "pstream.h" @@ -27,10 +27,9 @@ int main(int argc, char **argv) { return plib::app::mainrun<appclass, char>(argc namespace plib { -/*************************************************************************** - Application -***************************************************************************/ + /// \brief Application class. + /// class app : public options { public: @@ -65,4 +64,4 @@ namespace plib { -#endif /* PMAIN_H_ */ +#endif // PMAIN_H_ diff --git a/src/lib/netlist/plib/pmath.h b/src/lib/netlist/plib/pmath.h index 1bfa12c5f26..9738994770d 100644 --- a/src/lib/netlist/plib/pmath.h +++ b/src/lib/netlist/plib/pmath.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pmath.h - * - */ #ifndef PMATH_H_ #define PMATH_H_ +/// +/// \file pmath.h +/// + #include "pconfig.h" #include <algorithm> @@ -21,13 +21,13 @@ namespace plib { - /*! Holds constants used repeatedly. - * - * @tparam T floating point type - * - * Using the structure members we can avoid magic numbers in the code. - * In addition, this is a typesafe approach. - */ + /// \brief Holds constants used repeatedly. + /// + /// \tparam T floating point type + /// + /// Using the structure members we can avoid magic numbers in the code. + /// In addition, this is a typesafe approach. + /// template <typename T> struct constants { @@ -40,51 +40,50 @@ namespace plib static inline constexpr T sqrt2() noexcept { return static_cast<T>(1.414213562373095048801688724209L); } static inline constexpr T pi() noexcept { return static_cast<T>(3.14159265358979323846264338327950L); } - /*! - * \brief Electric constant of vacuum - */ + /// \brief Electric constant of vacuum + /// static inline constexpr T eps_0() noexcept { return static_cast<T>(8.854187817e-12); } - /*! - * \brief Relative permittivity of Silicon dioxide - */ + + // \brief Relative permittivity of Silicon dioxide + /// static inline constexpr T eps_SiO2() noexcept { return static_cast<T>(3.9); } - /*! - * \brief Relative permittivity of Silicon - */ + + /// \brief Relative permittivity of Silicon + /// static inline constexpr T eps_Si() noexcept { return static_cast<T>(11.7); } - /*! - * \brief Boltzmann constant - */ + + /// \brief Boltzmann constant + /// static inline constexpr T k_b() noexcept { return static_cast<T>(1.38064852e-23); } - /*! - * \brief room temperature (gives VT = 0.02585 at T=300) - */ + + /// \brief room temperature (gives VT = 0.02585 at T=300) + /// static inline constexpr T T0() noexcept { return static_cast<T>(300); } - /*! - * \brief Elementary charge - */ + + /// \brief Elementary charge + /// static inline constexpr T Q_e() noexcept { return static_cast<T>(1.6021765314e-19); } - /*! - * \brief Intrinsic carrier concentration in 1/m^3 of Silicon - */ + + /// \brief Intrinsic carrier concentration in 1/m^3 of Silicon + /// static inline constexpr T NiSi() noexcept { return static_cast<T>(1.45e16); } - /*! - * \brief clearly identify magic numbers in code - * - * Magic numbers should be avoided. The magic member at least clearly - * identifies them and makes it easier to convert them to named constants - * later. - */ + + /// \brief clearly identify magic numbers in code + /// + /// Magic numbers should be avoided. The magic member at least clearly + /// identifies them and makes it easier to convert them to named constants + /// later. + /// template <typename V> static inline constexpr const T magic(V &&v) noexcept { return static_cast<T>(v); } }; - /*! typesafe reciprocal function - * - * @tparam T type of the argument - * @param v argument - * @return reciprocal of argument - */ + /// \brief typesafe reciprocal function + /// + /// \tparam T type of the argument + /// \param v argument + /// \return reciprocal of argument + /// template <typename T> static inline constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type reciprocal(T v) noexcept @@ -92,12 +91,12 @@ namespace plib return constants<T>::one() / v; } - /*! abs function - * - * @tparam T type of the argument - * @param v argument - * @return absolute value of argument - */ + /// \brief abs function + /// + /// \tparam T type of the argument + /// \param v argument + /// \return absolute value of argument + /// template <typename T> static inline constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type abs(T v) noexcept @@ -105,12 +104,12 @@ namespace plib return std::abs(v); } - /*! sqrt function - * - * @tparam T type of the argument - * @param v argument - * @return absolute value of argument - */ + /// \brief sqrt function + /// + /// \tparam T type of the argument + /// \param v argument + /// \return absolute value of argument + /// template <typename T> static inline constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type sqrt(T v) noexcept @@ -118,13 +117,13 @@ namespace plib return std::sqrt(v); } - /*! hypot function - * - * @tparam T type of the arguments - * @param v1 first argument - * @param v2 second argument - * @return sqrt(v1*v1+v2*v2) - */ + /// \brief hypot function + /// + /// \tparam T type of the arguments + /// \param v1 first argument + /// \param v2 second argument + /// \return sqrt(v1*v1+v2*v2) + /// template <typename T> static inline constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type hypot(T v1, T v2) noexcept @@ -132,12 +131,12 @@ namespace plib return std::hypot(v1, v2); } - /*! exp function - * - * @tparam T type of the argument - * @param v argument - * @return exp(v) - */ + /// \brief exp function + /// + /// \tparam T type of the argument + /// \param v argument + /// \return exp(v) + /// template <typename T> static inline constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type exp(T v) noexcept @@ -145,12 +144,12 @@ namespace plib return std::exp(v); } - /*! log function - * - * @tparam T type of the argument - * @param v argument - * @return log(v) - */ + /// \brief log function + /// + /// \tparam T type of the argument + /// \param v argument + /// \return log(v) + /// template <typename T> static inline constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type log(T v) noexcept @@ -158,12 +157,12 @@ namespace plib return std::log(v); } - /*! tanh function - * - * @tparam T type of the argument - * @param v argument - * @return tanh(v) - */ + /// \brief tanh function + /// + /// \tparam T type of the argument + /// \param v argument + /// \return tanh(v) + /// template <typename T> static inline constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type tanh(T v) noexcept @@ -171,12 +170,12 @@ namespace plib return std::tanh(v); } - /*! floor function - * - * @tparam T type of the argument - * @param v argument - * @return floor(v) - */ + /// \brief floor function + /// + /// \tparam T type of the argument + /// \param v argument + /// \return floor(v) + /// template <typename T> static inline constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type floor(T v) noexcept @@ -184,12 +183,12 @@ namespace plib return std::floor(v); } - /*! log1p function - * - * @tparam T type of the argument - * @param v argument - * @return log(1 + v) - */ + /// \brief log1p function + /// + /// \tparam T type of the argument + /// \param v argument + /// \return log(1 + v) + /// template <typename T> static inline constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type log1p(T v) noexcept @@ -197,12 +196,12 @@ namespace plib return std::log1p(v); } - /*! sin function - * - * @tparam T type of the argument - * @param v argument - * @return sin(v) - */ + /// \brief sin function + /// + /// \tparam T type of the argument + /// \param v argument + /// \return sin(v) + /// template <typename T> static inline constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type sin(T v) noexcept @@ -210,12 +209,12 @@ namespace plib return std::sin(v); } - /*! cos function - * - * @tparam T type of the argument - * @param v argument - * @return cos(v) - */ + /// \brief cos function + /// + /// \tparam T type of the argument + /// \param v argument + /// \return cos(v) + /// template <typename T> static inline constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type cos(T v) noexcept @@ -223,12 +222,12 @@ namespace plib return std::cos(v); } - /*! trunc function - * - * @tparam T type of the argument - * @param v argument - * @return trunc(v) - */ + /// \brief trunc function + /// + /// \tparam T type of the argument + /// \param v argument + /// \return trunc(v) + /// template <typename T> static inline constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type trunc(T v) noexcept @@ -236,16 +235,16 @@ namespace plib return std::trunc(v); } - /*! pow function - * - * @tparam T1 type of the first argument - * @tparam T2 type of the second argument - * @param v argument - * @param p power - * @return v^p - * - * FIXME: limited implementation - */ + /// \brief pow function + /// + /// \tparam T1 type of the first argument + /// \tparam T2 type of the second argument + /// \param v argument + /// \param p power + /// \return v^p + /// + /// FIXME: limited implementation + /// template <typename T1, typename T2> static inline T1 pow(T1 v, T2 p) noexcept @@ -334,4 +333,4 @@ namespace plib } // namespace plib -#endif /* PMATH_H_ */ +#endif // PMATH_H_ diff --git a/src/lib/netlist/plib/pmatrix2d.h b/src/lib/netlist/plib/pmatrix2d.h index 435ef4d44b7..efa70da5b2a 100644 --- a/src/lib/netlist/plib/pmatrix2d.h +++ b/src/lib/netlist/plib/pmatrix2d.h @@ -1,15 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pmatrix2d.h - * - * NxM regular matrix - * - */ #ifndef PMATRIX2D_H_ #define PMATRIX2D_H_ +/// +/// \file pmatrix2d.h +/// + #include "palloc.h" #include <algorithm> @@ -80,4 +78,4 @@ namespace plib } // namespace plib -#endif /* MAT_CR_H_ */ +#endif // PMATRIX2D_H_ diff --git a/src/lib/netlist/plib/pmempool.h b/src/lib/netlist/plib/pmempool.h index 1d4bb52694d..59ca2d6f56c 100644 --- a/src/lib/netlist/plib/pmempool.h +++ b/src/lib/netlist/plib/pmempool.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pmempool.h - * - */ #ifndef PMEMPOOL_H_ #define PMEMPOOL_H_ +/// +/// \file pmempool.h +/// + #include "palloc.h" #include "pstream.h" #include "pstring.h" @@ -231,4 +231,4 @@ namespace plib { } // namespace plib -#endif /* PMEMPOOL_H_ */ +#endif // PMEMPOOL_H_ diff --git a/src/lib/netlist/plib/pomp.h b/src/lib/netlist/plib/pomp.h index 26e037bca1d..26dd6072c3d 100644 --- a/src/lib/netlist/plib/pomp.h +++ b/src/lib/netlist/plib/pomp.h @@ -1,14 +1,15 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pomp.h - * - * Wrap all OPENMP stuff here in a hopefully c++ compliant way. - */ #ifndef POMP_H_ #define POMP_H_ +/// +/// \file pomp.h +/// +/// Wrap all OPENMP stuff here in a hopefully c++ compliant way. +/// + #include "pconfig.h" #include "ptypes.h" @@ -81,4 +82,4 @@ inline std::size_t get_max_threads() noexcept } // namespace omp } // namespace plib -#endif /* PSTRING_H_ */ +#endif // PSTRING_H_ diff --git a/src/lib/netlist/plib/poptions.cpp b/src/lib/netlist/plib/poptions.cpp index 941b55c5b94..6f6ace0599c 100644 --- a/src/lib/netlist/plib/poptions.cpp +++ b/src/lib/netlist/plib/poptions.cpp @@ -1,9 +1,5 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * poptions.cpp - * - */ #include "poptions.h" #include "pexception.h" @@ -11,9 +7,6 @@ #include "ptypes.h" namespace plib { -/*************************************************************************** - Options -***************************************************************************/ option_base::option_base(options &parent, const pstring &help) : m_help(help) diff --git a/src/lib/netlist/plib/poptions.h b/src/lib/netlist/plib/poptions.h index 8420cf7e587..15f43e0330e 100644 --- a/src/lib/netlist/plib/poptions.h +++ b/src/lib/netlist/plib/poptions.h @@ -1,252 +1,251 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * poptions.h - * - */ #ifndef POPTIONS_H_ #define POPTIONS_H_ +/// +/// \file poptions.h +/// + #include "plists.h" #include "pstonum.h" #include "pstring.h" #include "putil.h" namespace plib { -/*************************************************************************** - Options -***************************************************************************/ -class options; + /// \brief options base class + /// + class options; -class option_base -{ -public: - option_base(options &parent, const pstring &help); - virtual ~option_base() = default; + class option_base + { + public: + option_base(options &parent, const pstring &help); + virtual ~option_base() = default; - COPYASSIGNMOVE(option_base, delete) + COPYASSIGNMOVE(option_base, delete) - pstring help() const { return m_help; } -private: - pstring m_help; -}; + pstring help() const { return m_help; } + private: + pstring m_help; + }; -class option_group : public option_base -{ -public: - option_group(options &parent, const pstring &group, const pstring &help) - : option_base(parent, help), m_group(group) { } + class option_group : public option_base + { + public: + option_group(options &parent, const pstring &group, const pstring &help) + : option_base(parent, help), m_group(group) { } - pstring group() const { return m_group; } -private: - pstring m_group; -}; + pstring group() const { return m_group; } + private: + pstring m_group; + }; -class option_example : public option_base -{ -public: - option_example(options &parent, const pstring &group, const pstring &help) - : option_base(parent, help), m_example(group) { } + class option_example : public option_base + { + public: + option_example(options &parent, const pstring &group, const pstring &help) + : option_base(parent, help), m_example(group) { } - pstring example() const { return m_example; } -private: - pstring m_example; -}; + pstring example() const { return m_example; } + private: + pstring m_example; + }; -class option : public option_base -{ -public: - option(options &parent, const pstring &ashort, const pstring &along, const pstring &help, bool has_argument); + class option : public option_base + { + public: + option(options &parent, const pstring &ashort, const pstring &along, const pstring &help, bool has_argument); - /* no_argument options will be called with "" argument */ + // no_argument options will be called with "" argument - pstring short_opt() const { return m_short; } - pstring long_opt() const { return m_long; } - bool has_argument() const { return m_has_argument ; } - bool was_specified() const { return m_specified; } + pstring short_opt() const { return m_short; } + pstring long_opt() const { return m_long; } + bool has_argument() const { return m_has_argument ; } + bool was_specified() const { return m_specified; } - int do_parse(const pstring &argument) - { - m_specified = true; - return parse(argument); - } + int do_parse(const pstring &argument) + { + m_specified = true; + return parse(argument); + } -protected: - virtual int parse(const pstring &argument) = 0; + protected: + virtual int parse(const pstring &argument) = 0; -private: - pstring m_short; - pstring m_long; - bool m_has_argument; - bool m_specified; -}; + private: + pstring m_short; + pstring m_long; + bool m_has_argument; + bool m_specified; + }; -class option_str : public option -{ -public: - option_str(options &parent, const pstring &ashort, const pstring &along, const pstring &defval, const pstring &help) - : option(parent, ashort, along, help, true), m_val(defval) - {} + class option_str : public option + { + public: + option_str(options &parent, const pstring &ashort, const pstring &along, const pstring &defval, const pstring &help) + : option(parent, ashort, along, help, true), m_val(defval) + {} - pstring operator ()() const { return m_val; } + pstring operator ()() const { return m_val; } -protected: - int parse(const pstring &argument) override; + protected: + int parse(const pstring &argument) override; -private: - pstring m_val; -}; + private: + pstring m_val; + }; -class option_str_limit_base : public option -{ -public: - option_str_limit_base(options &parent, const pstring &ashort, const pstring &along, std::vector<pstring> &&limit, const pstring &help) - : option(parent, ashort, along, help, true) - , m_limit(limit) + class option_str_limit_base : public option { - } - const std::vector<pstring> &limit() const { return m_limit; } + public: + option_str_limit_base(options &parent, const pstring &ashort, const pstring &along, std::vector<pstring> &&limit, const pstring &help) + : option(parent, ashort, along, help, true) + , m_limit(limit) + { + } + const std::vector<pstring> &limit() const { return m_limit; } -protected: + protected: -private: - std::vector<pstring> m_limit; -}; + private: + std::vector<pstring> m_limit; + }; -template <typename T> -class option_str_limit : public option_str_limit_base -{ -public: - option_str_limit(options &parent, const pstring &ashort, const pstring &along, const T &defval, std::vector<pstring> &&limit, const pstring &help) - : option_str_limit_base(parent, ashort, along, std::move(limit), help), m_val(defval) + template <typename T> + class option_str_limit : public option_str_limit_base { - } - - T operator ()() const { return m_val; } + public: + option_str_limit(options &parent, const pstring &ashort, const pstring &along, const T &defval, std::vector<pstring> &&limit, const pstring &help) + : option_str_limit_base(parent, ashort, along, std::move(limit), help), m_val(defval) + { + } - pstring as_string() const { return limit()[m_val]; } + T operator ()() const { return m_val; } -protected: - int parse(const pstring &argument) override - { - auto raw = plib::container::indexof(limit(), argument); + pstring as_string() const { return limit()[m_val]; } - if (raw != plib::container::npos) + protected: + int parse(const pstring &argument) override { - m_val = static_cast<T>(raw); - return 0; + auto raw = plib::container::indexof(limit(), argument); + + if (raw != plib::container::npos) + { + m_val = static_cast<T>(raw); + return 0; + } + else + return 1; } - else - return 1; - } -private: - T m_val; -}; + private: + T m_val; + }; -class option_bool : public option -{ -public: - option_bool(options &parent, const pstring &ashort, const pstring &along, const pstring &help) - : option(parent, ashort, along, help, false), m_val(false) - {} + class option_bool : public option + { + public: + option_bool(options &parent, const pstring &ashort, const pstring &along, const pstring &help) + : option(parent, ashort, along, help, false), m_val(false) + {} - bool operator ()() const { return m_val; } + bool operator ()() const { return m_val; } -protected: - int parse(const pstring &argument) override; + protected: + int parse(const pstring &argument) override; -private: - bool m_val; -}; + private: + bool m_val; + }; -template <typename T> -class option_num : public option -{ -public: - option_num(options &parent, const pstring &ashort, const pstring &along, T defval, - const pstring &help, - T minval = std::numeric_limits<T>::min(), - T maxval = std::numeric_limits<T>::max() ) - : option(parent, ashort, along, help, true) - , m_val(defval) - , m_min(minval) - , m_max(maxval) - {} - - T operator ()() const { return m_val; } - -protected: - int parse(const pstring &argument) override + template <typename T> + class option_num : public option { - bool err(false); - m_val = pstonum_ne<T>(argument, err); - return (err ? 1 : (m_val < m_min || m_val > m_max)); - } + public: + option_num(options &parent, const pstring &ashort, const pstring &along, T defval, + const pstring &help, + T minval = std::numeric_limits<T>::min(), + T maxval = std::numeric_limits<T>::max() ) + : option(parent, ashort, along, help, true) + , m_val(defval) + , m_min(minval) + , m_max(maxval) + {} + + T operator ()() const { return m_val; } + + protected: + int parse(const pstring &argument) override + { + bool err(false); + m_val = pstonum_ne<T>(argument, err); + return (err ? 1 : (m_val < m_min || m_val > m_max)); + } -private: - T m_val; - T m_min; - T m_max; -}; + private: + T m_val; + T m_min; + T m_max; + }; -class option_vec : public option -{ -public: - option_vec(options &parent, const pstring &ashort, const pstring &along, const pstring &help) - : option(parent, ashort, along, help, true) - {} + class option_vec : public option + { + public: + option_vec(options &parent, const pstring &ashort, const pstring &along, const pstring &help) + : option(parent, ashort, along, help, true) + {} - const std::vector<pstring> &operator ()() const { return m_val; } + const std::vector<pstring> &operator ()() const { return m_val; } -protected: - int parse(const pstring &argument) override; + protected: + int parse(const pstring &argument) override; -private: - std::vector<pstring> m_val; -}; + private: + std::vector<pstring> m_val; + }; -class option_args : public option_vec -{ -public: - option_args(options &parent, const pstring &help) - : option_vec(parent, "", "", help) - {} -}; + class option_args : public option_vec + { + public: + option_args(options &parent, const pstring &help) + : option_vec(parent, "", "", help) + {} + }; -class options : public nocopyassignmove -{ -public: + class options : public nocopyassignmove + { + public: - options(); - explicit options(option **o); + options(); + explicit options(option **o); - void register_option(option_base *opt); - int parse(int argc, char **argv); + void register_option(option_base *opt); + int parse(int argc, char **argv); - pstring help(const pstring &description, const pstring &usage, - unsigned width = 72, unsigned indent = 20) const; + pstring help(const pstring &description, const pstring &usage, + unsigned width = 72, unsigned indent = 20) const; - pstring app() const { return m_app; } + pstring app() const { return m_app; } -private: - static pstring split_paragraphs(const pstring &text, unsigned width, unsigned indent, - unsigned firstline_indent); + private: + static pstring split_paragraphs(const pstring &text, unsigned width, unsigned indent, + unsigned firstline_indent); - void check_consistency(); + void check_consistency(); - template <typename T> - T *getopt_type() const - { - for (auto & optbase : m_opts ) + template <typename T> + T *getopt_type() const { - if (auto opt = dynamic_cast<T *>(optbase)) - return opt; - } + for (auto & optbase : m_opts ) + { + if (auto opt = dynamic_cast<T *>(optbase)) + return opt; + } return nullptr; } @@ -260,4 +259,4 @@ private: } // namespace plib -#endif /* POPTIONS_H_ */ +#endif // POPTIONS_H_ diff --git a/src/lib/netlist/plib/ppmf.h b/src/lib/netlist/plib/ppmf.h index 5875aeb0a13..bbbe95ded05 100644 --- a/src/lib/netlist/plib/ppmf.h +++ b/src/lib/netlist/plib/ppmf.h @@ -1,45 +1,44 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * ppmf.h - * - */ #ifndef PPMF_H_ #define PPMF_H_ +/// +/// \file ppmf.h +/// +/// +/// PMF_TYPE_GNUC_PMF +/// Use standard pointer to member function syntax C++11 +/// +/// PMF_TYPE_GNUC_PMF_CONV +/// Use gnu extension and convert the pmf to a function pointer. +/// This is not standard compliant and needs +/// -Wno-pmf-conversions to compile. +/// +/// PMF_TYPE_INTERNAL +/// Use the same approach as MAME for deriving the function pointer. +/// This is compiler-dependent as well +/// +/// Benchmarks for ./nltool -c run -f src/mame/machine/nl_pong.cpp -t 10 -n pong_fast +/// +/// PMF_TYPE_INTERNAL: 215% 215% +/// PMF_TYPE_GNUC_PMF: 163% 196% +/// PMF_TYPE_GNUC_PMF_CONV: 215% 215% +/// PMF_TYPE_VIRTUAL: 213% 209% +/// +/// The whole exercise was done to avoid virtual calls. In prior versions of +/// netlist, the INTERNAL and GNUC_PMF_CONV approach provided significant improvement. +/// Since than, "hot" was removed from functions declared as virtual. +/// This may explain that the recent benchmarks show no difference at all. +/// + #include "pconfig.h" #include <cstdint> // uintptr_t #include <utility> -/* - * - * PMF_TYPE_GNUC_PMF - * Use standard pointer to member function syntax C++11 - * - * PMF_TYPE_GNUC_PMF_CONV - * Use gnu extension and convert the pmf to a function pointer. - * This is not standard compliant and needs - * -Wno-pmf-conversions to compile. - * - * PMF_TYPE_INTERNAL - * Use the same approach as MAME for deriving the function pointer. - * This is compiler-dependent as well - * - * Benchmarks for ./nltool -c run -f src/mame/machine/nl_pong.cpp -t 10 -n pong_fast - * - * PMF_TYPE_INTERNAL: 215% 215% - * PMF_TYPE_GNUC_PMF: 163% 196% - * PMF_TYPE_GNUC_PMF_CONV: 215% 215% - * PMF_TYPE_VIRTUAL: 213% 209% - * - * The whole exercise was done to avoid virtual calls. In prior versions of - * netlist, the INTERNAL and GNUC_PMF_CONV approach provided significant improvement. - * Since than, "hot" was removed from functions declared as virtual. - * This may explain that the recent benchmarks show no difference at all. - * - */ + //============================================================ // Macro magic @@ -52,7 +51,7 @@ #define PPMF_TYPE_INTERNAL 2 #if defined(__GNUC__) - /* does not work in versions over 4.7.x of 32bit MINGW */ + // does not work in versions over 4.7.x of 32bit MINGW #if defined(__MINGW32__) && !defined(__x86_64) && defined(__i386__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))) #define PHAS_PMF_INTERNAL 0 #elif defined(__MINGW32__) && !defined(__x86_64) && defined(__i386__) @@ -98,12 +97,13 @@ #endif namespace plib { -/* - * The following class was derived from the MAME delegate.h code. - * It derives a pointer to a member function. - */ #if (PHAS_PMF_INTERNAL > 0) + /// + /// \brief Used to derive a pointer to a member function. + /// + /// The following class was derived from the MAME delegate.h code. + /// class mfp { public: @@ -325,4 +325,4 @@ namespace plib { } // namespace plib -#endif /* PPMF_H_ */ +#endif // PPMF_H_ diff --git a/src/lib/netlist/plib/ppreprocessor.cpp b/src/lib/netlist/plib/ppreprocessor.cpp index 80564064bb2..377c37d9fca 100644 --- a/src/lib/netlist/plib/ppreprocessor.cpp +++ b/src/lib/netlist/plib/ppreprocessor.cpp @@ -1,9 +1,5 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * ppreprocessor.cpp - * - */ #include "ppreprocessor.h" #include "palloc.h" @@ -77,19 +73,18 @@ namespace plib { : m_tokens(tokens), m_parent(parent), m_pos(0) {} - /**! skip white space in token list - * - */ + /// \brief skip white space in token list + /// void skip_ws() { while (m_pos < m_tokens.size() && (m_tokens[m_pos] == " " || m_tokens[m_pos] == "\t")) m_pos++; } - /**! return next token skipping white space - * - * @return next token - */ + /// \brief return next token skipping white space + /// + /// \return next token + /// pstring next() { skip_ws(); @@ -98,10 +93,10 @@ namespace plib { return m_tokens[m_pos++]; } - /**! return next token including white space - * - * @return next token - */ + /// \brief return next token including white space + /// + /// \return next token + /// pstring next_ws() { if (m_pos >= m_tokens.size()) @@ -497,7 +492,7 @@ namespace plib { if (startsWith(arg, "\"") && endsWith(arg, "\"")) { arg = arg.substr(1, arg.length() - 2); - /* first try local context */ + // first try local context auto l(plib::util::buildpath({m_stack.back().m_local_path, arg})); auto lstrm(m_sources.get_stream<>(l)); if (lstrm) diff --git a/src/lib/netlist/plib/ppreprocessor.h b/src/lib/netlist/plib/ppreprocessor.h index 3dc924d3f67..d87c06657ef 100644 --- a/src/lib/netlist/plib/ppreprocessor.h +++ b/src/lib/netlist/plib/ppreprocessor.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * ppreprocessor.h - * - */ #ifndef PPREPROCESSOR_H_ #define PPREPROCESSOR_H_ +/// +/// \file ppreprocessor.h +/// + #include "plists.h" #include "pstream.h" #include "pstring.h" @@ -95,7 +95,7 @@ namespace plib { { if (this->gptr() == this->egptr()) { - /* clang reports sign error - weird */ + // clang reports sign error - weird std::size_t bytes = pstring_mem_t_size(m_strm->m_outbuf) - static_cast<std::size_t>(m_strm->m_pos); if (bytes > m_buf.size()) @@ -104,7 +104,7 @@ namespace plib { //printf("%ld\n", (long int)bytes); this->setg(m_buf.data(), m_buf.data(), m_buf.data() + bytes); - m_strm->m_pos += static_cast</*pos_type*/long>(bytes); + m_strm->m_pos += static_cast<long>(bytes); } return this->gptr() == this->egptr() @@ -160,7 +160,7 @@ namespace plib { pstring m_name; }; - /* vector used as stack because we need to loop through stack */ + // vector used as stack because we need to loop through stack std::vector<input_context> m_stack; pstring_t<pu8_traits> m_outbuf; std::istream::pos_type m_pos; @@ -173,4 +173,4 @@ namespace plib { } // namespace plib -#endif /* PPREPROCESSOR_H_ */ +#endif // PPREPROCESSOR_H_ diff --git a/src/lib/netlist/plib/pstate.h b/src/lib/netlist/plib/pstate.h index 8dc6bf9424a..659c6991c42 100644 --- a/src/lib/netlist/plib/pstate.h +++ b/src/lib/netlist/plib/pstate.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pstate.h - * - */ #ifndef PSTATE_H_ #define PSTATE_H_ +/// +/// \file pstate.h +/// + #include "palloc.h" #include "pstring.h" #include "ptypes.h" @@ -173,4 +173,4 @@ template<> inline void state_manager_t::save_item(const void *owner, callback_t } // namespace plib -#endif /* PSTATE_H_ */ +#endif // PSTATE_H_ diff --git a/src/lib/netlist/plib/pstonum.h b/src/lib/netlist/plib/pstonum.h index 65ec6355b38..eed69e85883 100644 --- a/src/lib/netlist/plib/pstonum.h +++ b/src/lib/netlist/plib/pstonum.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pstonuml.h - * - */ #ifndef PSTONUM_H_ #define PSTONUM_H_ +/// +/// \file pstonum.h +/// + #include "pconfig.h" #include "pexception.h" #include "pmath.h" // for pstonum @@ -145,4 +145,4 @@ namespace plib } // namespace plib -#endif /* PUTIL_H_ */ +#endif // PUTIL_H_ diff --git a/src/lib/netlist/plib/pstream.h b/src/lib/netlist/plib/pstream.h index 6b438e83c1a..4425842882c 100644 --- a/src/lib/netlist/plib/pstream.h +++ b/src/lib/netlist/plib/pstream.h @@ -1,12 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pstream.h - */ + #ifndef PSTREAM_H_ #define PSTREAM_H_ +/// +/// \file pstream.h +/// #include "palloc.h" #include "pconfig.h" @@ -25,19 +26,17 @@ namespace plib { -// ----------------------------------------------------------------------------- -// putf8reader_t: reader on top of istream -// ----------------------------------------------------------------------------- - -/* this digests linux & dos/windows text files */ - - template <typename T> struct constructor_helper { plib::unique_ptr<std::istream> operator()(T &&s) { return std::move(plib::make_unique<T>(std::move(s))); } }; +/// +/// \brief: putf8reader_t: reader on top of istream. +/// +/// putf8reader_t digests linux & dos/windows text files +/// // NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) class putf8_reader { @@ -70,7 +69,7 @@ public: { if (c == 10) break; - else if (c != 13) /* ignore CR */ + else if (c != 13) // ignore CR m_linebuf += putf8string(1, c); if (!this->readcode(c)) break; @@ -303,8 +302,11 @@ private: namespace filesystem { + + // FIXME: u8path should return a path object (c++17) + template< class Source > - pstring /*path */ u8path( const Source& source ) + pstring u8path( const Source& source ) { return source; } @@ -313,4 +315,4 @@ namespace filesystem } // namespace plib -#endif /* PSTREAM_H_ */ +#endif // PSTREAM_H_ diff --git a/src/lib/netlist/plib/pstring.cpp b/src/lib/netlist/plib/pstring.cpp index 357bce847f1..7af1228ef6d 100644 --- a/src/lib/netlist/plib/pstring.cpp +++ b/src/lib/netlist/plib/pstring.cpp @@ -1,9 +1,5 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pstring.cpp - * - */ #include "pstring.h" #include "palloc.h" diff --git a/src/lib/netlist/plib/pstring.h b/src/lib/netlist/plib/pstring.h index 25e79f5bdec..5c2ac2b9c47 100644 --- a/src/lib/netlist/plib/pstring.h +++ b/src/lib/netlist/plib/pstring.h @@ -1,12 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pstring.h - */ #ifndef PSTRING_H_ #define PSTRING_H_ +/// +/// \file pstring.h +/// + #include "ptypes.h" #include <exception> @@ -99,7 +100,7 @@ public: { } - /* mingw treats string constants as char* instead of char[N] */ + // mingw treats string constants as char* instead of char[N] #if !defined(_WIN32) && !defined(_WIN64) explicit #endif @@ -207,7 +208,7 @@ public: static constexpr const size_type npos = static_cast<size_type>(-1); - /* the following are extensions to <string> */ + // the following are extensions to <string> // FIXME: remove those size_type mem_t_size() const { return m_str.size(); } @@ -229,7 +230,7 @@ struct pu8_traits static const mem_t *nthcode(const mem_t *p, const std::size_t n) { return &(p[n]); } }; -/* No checking, this may deliver invalid codes */ +// No checking, this may deliver invalid codes struct putf8_traits { using mem_t = char; @@ -269,8 +270,8 @@ struct putf8_traits return 2; else if (c < 0x10000) return 3; - else /* U+10000 U+1FFFFF */ - return 4; /* no checks */ + else // U+10000 U+1FFFFF + return 4; // no checks } static code_t code(const mem_t *p) { @@ -303,7 +304,7 @@ struct putf8_traits s += static_cast<mem_t>(0x80 | ((c>>6) & 0x3f)); s += static_cast<mem_t>(0x80 | (c & 0x3f)); } - else /* U+10000 U+1FFFFF */ + else // U+10000 U+1FFFFF { s += static_cast<mem_t>(0xF0 | (c >> 18)); s += static_cast<mem_t>(0x80 | ((c>>12) & 0x3f)); @@ -348,7 +349,7 @@ struct putf16_traits { if (c < 0x10000) return 1; - else /* U+10000 U+1FFFFF */ + else // U+10000 U+1FFFFF return 2; } static code_t code(const mem_t *p) @@ -512,4 +513,4 @@ namespace std }; } // namespace std -#endif /* PSTRING_H_ */ +#endif // PSTRING_H_ diff --git a/src/lib/netlist/plib/pstrutil.h b/src/lib/netlist/plib/pstrutil.h index 69b9651ab0e..608f42cb4c2 100644 --- a/src/lib/netlist/plib/pstrutil.h +++ b/src/lib/netlist/plib/pstrutil.h @@ -1,12 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * pstrutil.h - */ #ifndef PSTRUTIL_H_ #define PSTRUTIL_H_ +/// +/// \file pstrutil.h +/// + #include "pstring.h" #include "ptypes.h" @@ -67,7 +68,7 @@ namespace plib template<typename T> typename T::size_type find_last_not_of(const T &str, const T &no) { - /* FIXME: reverse iterator */ + // FIXME: use reverse iterator typename T::size_type last_found = T::npos; typename T::size_type pos = 0; for (auto it = str.begin(); it != str.end(); ++it, ++pos) @@ -225,4 +226,4 @@ namespace plib } // namespace plib -#endif /* PSTRUTIL_H_ */ +#endif // PSTRUTIL_H_ diff --git a/src/lib/netlist/plib/ptime.h b/src/lib/netlist/plib/ptime.h index 4f1b5af445f..214f121c2df 100644 --- a/src/lib/netlist/plib/ptime.h +++ b/src/lib/netlist/plib/ptime.h @@ -1,12 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * ptime.h - */ #ifndef PTIME_H_ #define PTIME_H_ +/// +/// \file ptime.h +/// + #include "pconfig.h" #include "pmath.h" // std::floor #include "ptypes.h" @@ -164,4 +165,4 @@ namespace plib } // namespace plib -#endif /* PTIME_H_ */ +#endif // PTIME_H_ diff --git a/src/lib/netlist/plib/ptokenizer.cpp b/src/lib/netlist/plib/ptokenizer.cpp index 0e8cabe4e8b..23d0903ae2a 100644 --- a/src/lib/netlist/plib/ptokenizer.cpp +++ b/src/lib/netlist/plib/ptokenizer.cpp @@ -1,9 +1,5 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * ptokenizer.cpp - * - */ #include "ptokenizer.h" #include "palloc.h" @@ -198,7 +194,7 @@ namespace plib { ptokenizer::token_t ptokenizer::get_token_internal() { - /* skip ws */ + // skip ws pstring::value_type c = getc(); while (m_whitespace.find(c) != pstring::npos) { @@ -212,10 +208,8 @@ namespace plib { return token_t(LINEMARKER, "#"); else if (m_number_chars_start.find(c) != pstring::npos) { - /* read number while we receive number or identifier chars - * treat it as an identifier when there are identifier chars in it - * - */ + // read number while we receive number or identifier chars + // treat it as an identifier when there are identifier chars in it token_type ret = NUMBER; pstring tokstr = ""; while (true) { @@ -231,7 +225,7 @@ namespace plib { } else if (m_identifier_chars.find(c) != pstring::npos) { - /* read identifier till non identifier char */ + // read identifier till non identifier char pstring tokstr = ""; while (m_identifier_chars.find(c) != pstring::npos) { @@ -258,12 +252,12 @@ namespace plib { } else { - /* read identifier till first identifier char or ws */ + // read identifier till first identifier char or ws pstring tokstr = ""; while ((m_identifier_chars.find(c) == pstring::npos) && (m_whitespace.find(c) == pstring::npos)) { tokstr += c; - /* expensive, check for single char tokens */ + // expensive, check for single char tokens if (tokstr.length() == 1) { auto id = m_tokens.find(tokstr); diff --git a/src/lib/netlist/plib/ptokenizer.h b/src/lib/netlist/plib/ptokenizer.h index b6f8411eaa3..66365bcc017 100644 --- a/src/lib/netlist/plib/ptokenizer.h +++ b/src/lib/netlist/plib/ptokenizer.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * ptokenizer.h - * - */ #ifndef PTOKENIZER_H_ #define PTOKENIZER_H_ +/// +/// \file ptokenizer.h +/// + #include "plists.h" #include "pstream.h" #include "pstring.h" @@ -94,7 +94,7 @@ namespace plib { pstring currentline_str(); - /* tokenizer stuff follows ... */ + // tokenizer stuff follows ... token_t get_token(); pstring get_string(); @@ -147,7 +147,7 @@ namespace plib { pstring::const_iterator m_px; pstring::value_type m_unget; - /* tokenizer stuff follows ... */ + // tokenizer stuff follows ... pstring m_identifier_chars; pstring m_number_chars; @@ -160,11 +160,12 @@ namespace plib { token_id_t m_tok_comment_end; token_id_t m_tok_line_comment; - /* source locations, vector used as stack because we need to loop through stack */ + // source locations, vector used as stack because we need to loop through stack + bool m_support_line_markers; std::vector<plib::source_location> m_source_location; }; } // namespace plib -#endif /* PTOKENIZER_H_ */ +#endif // PTOKENIZER_H_ diff --git a/src/lib/netlist/plib/ptypes.h b/src/lib/netlist/plib/ptypes.h index afc25bc0d0a..d34651b9f70 100644 --- a/src/lib/netlist/plib/ptypes.h +++ b/src/lib/netlist/plib/ptypes.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * ptypes.h - * - */ #ifndef PTYPES_H_ #define PTYPES_H_ +/// +/// \file ptypes.h +/// + #include "pconfig.h" #include <limits> @@ -30,7 +30,7 @@ namespace plib template<typename T> struct is_integral : public std::is_integral<T> { }; template<typename T> struct numeric_limits : public std::numeric_limits<T> { }; - /* 128 bit support at least on GCC is not fully supported */ + // 128 bit support at least on GCC is not fully supported #if PHAS_INT128 template<> struct is_integral<UINT128> { static constexpr bool value = true; }; template<> struct is_integral<INT128> { static constexpr bool value = true; }; @@ -149,4 +149,4 @@ namespace plib static constexpr const bool value = sizeof(test<T>(nullptr)) == sizeof(long); \ } -#endif /* PTYPES_H_ */ +#endif // PTYPES_H_ diff --git a/src/lib/netlist/plib/putil.h b/src/lib/netlist/plib/putil.h index 6a79dadae90..128e804a1ae 100644 --- a/src/lib/netlist/plib/putil.h +++ b/src/lib/netlist/plib/putil.h @@ -1,26 +1,20 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * putil.h - * - */ #ifndef PUTIL_H_ #define PUTIL_H_ +/// +/// \file putil.h +/// + #include "palloc.h" #include "pexception.h" #include "pstring.h" #include <algorithm> -//#include <initializer_list> -//#include <iostream> -//#include <locale> -//#include <sstream> #include <vector> -// FIXME: pstonum should get an own header - #define PSTRINGIFY_HELP(y) # y #define PSTRINGIFY(x) PSTRINGIFY_HELP(x) @@ -31,13 +25,12 @@ namespace plib { - /**! Source code locations - * - * The c++20 draft for source locations is based on const char * strings. - * It is thus only suitable for c++ source code and not for programmatic - * parsing of files. This class is a replacement for dynamic use cases. - * - */ + /// \brief Source code locations. + /// + /// The c++20 draft for source locations is based on const char * strings. + /// It is thus only suitable for c++ source code and not for programmatic + /// parsing of files. This class is a replacement for dynamic use cases. + /// struct source_location { source_location() noexcept @@ -70,13 +63,12 @@ namespace plib unsigned m_col; }; - /**! Base source class - * - * Pure virtual class all other source implementations are based on. - * Sources provide an abstraction to read input from a variety of - * sources, e.g. files, memory, remote locations. - * - */ + /// \brief Base source class. + /// + /// Pure virtual class all other source implementations are based on. + /// Sources provide an abstraction to read input from a variety of + /// sources, e.g. files, memory, remote locations. + /// class psource_t { public: @@ -93,13 +85,13 @@ namespace plib private: }; - /**! Generic string source - * - * Will return the given string when name matches. - * Is used in preprocessor code to eliminate inclusion of certain files. - * - * @tparam TS base stream class. Default is psource_t - */ + /// \brief Generic string source. + /// + /// Will return the given string when name matches. + /// Is used in preprocessor code to eliminate inclusion of certain files. + /// + /// \tparam TS base stream class. Default is psource_t + /// template <typename TS = psource_t> class psource_str_t : public TS { @@ -123,10 +115,10 @@ namespace plib pstring m_str; }; - /**! Generic sources collection - * - * @tparam TS base stream class. Default is psource_t - */ + /// \brief Generic sources collection. + /// + /// \tparam TS base stream class. Default is psource_t + /// template <typename TS = psource_t> class psource_collection_t { @@ -273,4 +265,4 @@ namespace plib } \ }; -#endif /* PUTIL_H_ */ +#endif // PUTIL_H_ diff --git a/src/lib/netlist/plib/vector_ops.h b/src/lib/netlist/plib/vector_ops.h index c603a3c43db..a34a9bf8a54 100644 --- a/src/lib/netlist/plib/vector_ops.h +++ b/src/lib/netlist/plib/vector_ops.h @@ -1,15 +1,15 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * vector_ops.h - * - * Base vector operations - * - */ #ifndef PLIB_VECTOR_OPS_H_ #define PLIB_VECTOR_OPS_H_ +/// +/// \file vector_ops.h +/// +/// Base vector operations +/// +/// #include "pconfig.h" #include "pmath.h" @@ -149,4 +149,4 @@ namespace plib #endif #endif -#endif /* PLIB_VECTOR_OPS_H_ */ +#endif // PLIB_VECTOR_OPS_H_ |