Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ extern "C"

#include <app/benchmark/app_benchmark_detail.h>

#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wall"
#endif

//#define APP_BENCHMARK_TYPE_BOOST_MATH_CBRT_TGAMMA_EXCLUDES_TGAMMA

#if !defined(BOOST_MATH_STANDALONE)
Expand Down Expand Up @@ -154,8 +149,4 @@ my_float_type cyj;
unsigned xn = static_cast<unsigned>(UINT8_C(1));
my_float_type v = static_cast<my_float_type>(BOOST_FLOATMAX_C(1.23));

#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

#endif // APP_BENCHMARK_TYPE_BOOST_MATH_CYL_BESSEL_J
29 changes: 23 additions & 6 deletions ref_app/src/app/benchmark/app_benchmark_detail.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2024.
// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -9,20 +9,37 @@
#define APP_BENCHMARK_DETAIL_2018_10_02_H

#include <cmath>
#include <cstdint>
#include <limits>

namespace app { namespace benchmark { namespace detail {

template<typename NumericType>
auto is_close_fraction(const NumericType a, // NOLINT(bugprone-easily-swappable-parameters)
const NumericType b, // NOLINT(bugprone-easily-swappable-parameters)
const NumericType tol = NumericType(std::numeric_limits<NumericType>::epsilon() * NumericType(100))) -> bool
constexpr auto default_tol() noexcept -> NumericType
{
return NumericType { std::numeric_limits<NumericType>::epsilon() * static_cast<NumericType>(UINT8_C(100)) }; // NOLINT(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
}

template<typename NumericType>
constexpr auto is_close_fraction(const NumericType a, // NOLINT(bugprone-easily-swappable-parameters)
const NumericType b, // NOLINT(bugprone-easily-swappable-parameters)
const NumericType tol = default_tol<NumericType>()) noexcept -> bool
{
using std::fabs;
using std::fpclassify;

NumericType closeness { };

const NumericType ratio = fabs(NumericType((NumericType(1) * a) / b));
if(fpclassify(b) == FP_ZERO)
{
closeness = fabs(a - b);
}
else
{
const NumericType ratio { a / b };

const NumericType closeness = fabs(NumericType(1 - ratio));
closeness = NumericType { fabs(NumericType { 1 - ratio }) };
}

return (closeness < tol);
}
Expand Down
4 changes: 2 additions & 2 deletions ref_app/src/app/benchmark/app_benchmark_fixed_point.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2010 - 2019.
// Copyright Christopher Kormanyos 2010 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -18,7 +18,7 @@

namespace
{
using fixed_point_type = fixed_point<std::int32_t>;
using fixed_point_type = ::math::fixed::fixed_point<std::int32_t>;
}

extern fixed_point_type global_a;
Expand Down
64 changes: 50 additions & 14 deletions ref_app/src/math/fixed_point/fixed_point.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2018.
// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef FIXED_POINT_2011_02_22_H_
#define FIXED_POINT_2011_02_22_H_
#ifndef FIXED_POINT_2011_02_22_H
#define FIXED_POINT_2011_02_22_H

#define FIXED_POINT_DISABLE_IOSTREAM

#include <util/utility/util_nothing.h>
#include <util/utility/util_utype_helper.h>

#include <cmath>
#include <cstddef>
#include <cstdint>
#include <limits>
Expand All @@ -19,8 +23,17 @@
#include <ostream>
#endif

#include <util/utility/util_nothing.h>
#include <util/utility/util_utype_helper.h>
#if(__cplusplus >= 201703L)
namespace math::fixed {
#else
namespace math { namespace fixed { // NOLINT(modernize-concat-nested-namespaces)
#endif

// Forward declaration of the fixed_point template class.
template<typename integer_type>
class fixed_point;

namespace detail {

// Utility structure to help with the epsilon limits for fixed_point.
// These special numbers represent the smallest value for a decimal part
Expand All @@ -31,9 +44,7 @@
template<> struct epsilon_helper<16U> { static const std::size_t epsilon_value = std::size_t(7U); };
template<> struct epsilon_helper<32U> { static const std::size_t epsilon_value = std::size_t(44U); };

// Forward declaration of the fixed_point template class.
template<typename integer_type>
class fixed_point;
} // namespace detail

// The scalable fixed_point template class.
template<typename integer_type>
Expand Down Expand Up @@ -321,7 +332,7 @@
static fixed_point value_max () { return fixed_point(internal(), signed_value_type((unsigned_value_type(-1LL) - 1U) / 2U)); }
static fixed_point value_min () { return fixed_point(internal(), signed_value_type(2L)); }
static fixed_point value_half () { return fixed_point(internal(), signed_value_type(1ULL << (decimal_split - 1U))); }
static fixed_point value_eps () { return fixed_point(internal(), signed_value_type(epsilon_helper<decimal_split>::epsilon_value)); }
static fixed_point value_eps () { return fixed_point(internal(), signed_value_type(detail::epsilon_helper<decimal_split>::epsilon_value)); }
static fixed_point value_pi () { return fixed_point(internal(), signed_value_type(0x3243f6A88ULL >> (32U - decimal_split))); }
static fixed_point value_pi_half () { return fixed_point(internal(), signed_value_type(0x1921FB544ULL >> (32U - decimal_split))); }
static fixed_point value_two_over_pi () { return fixed_point(internal(), signed_value_type(0x0A2F98370ULL >> (32U - decimal_split))); }
Expand Down Expand Up @@ -544,6 +555,11 @@
template<typename other_signed_type> friend inline bool operator> (const fixed_point<other_signed_type>& b, const fixed_point& a) { return (std::int_least8_t(-a.cmp(b)) > std::int_least8_t(0)); }

// Include a few global sample fixed_point functions.
friend inline int fpclassify(const fixed_point& x)
{
return (x.data == signed_value_type(0) ? FP_ZERO : FP_NORMAL);
}

friend inline fixed_point fabs(const fixed_point& x)
{
return fixed_point(internal(), (x.data < signed_value_type(0) ? -x.data : x.data));
Expand Down Expand Up @@ -940,11 +956,18 @@
#endif // !FIXED_POINT_DISABLE_IOSTREAM
};

#if(__cplusplus >= 201703L)
} // namespace math::fixed
#else
} // namespace fixed
} // namespace math
#endif

// Define the four scalable fixed_point types.
typedef fixed_point<std::int8_t> fixed_point_3pt4;
typedef fixed_point<std::int16_t> fixed_point_7pt8;
typedef fixed_point<std::int32_t> fixed_point_15pt16;
typedef fixed_point<std::int64_t> fixed_point_31pt32;
typedef math::fixed::fixed_point<std::int8_t> fixed_point_3pt4;
typedef math::fixed::fixed_point<std::int16_t> fixed_point_7pt8;
typedef math::fixed::fixed_point<std::int32_t> fixed_point_15pt16;
typedef math::fixed::fixed_point<std::int64_t> fixed_point_31pt32;

namespace std
{
Expand All @@ -955,6 +978,12 @@
template<> class numeric_limits<fixed_point_31pt32> : public fixed_point_31pt32::my_numeric_limits { };
}

#if(__cplusplus >= 201703L)
namespace math::fixed {
#else
namespace math { namespace fixed { // NOLINT(modernize-concat-nested-namespaces)
#endif

// Include a few more global sample fixed_point functions.
template<typename fixed_point_type>
inline fixed_point_type sqrt(const fixed_point_type& x) { return fixed_point_type(x).calculate_sqrt(); }
Expand All @@ -972,4 +1001,11 @@
return sqrt<fixed_point_type>((x * x) + (y * y));
}

#endif // FIXED_POINT_2011_02_22_H_
#if(__cplusplus >= 201703L)
} // namespace math::fixed
#else
} // namespace fixed
} // namespace math
#endif

#endif // FIXED_POINT_2011_02_22_H
4 changes: 2 additions & 2 deletions ref_app/src/mcal/mcal_gcc_cxx_completion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extern "C"
// and objects.

void abort () __attribute__((noreturn));
int atexit (void (*)());
int atexit (void (*)()) noexcept;
int at_quick_exit (void (*)());
void _Exit (int) __attribute__((noreturn));
void exit (int) __attribute__((noreturn));
Expand All @@ -111,7 +111,7 @@ extern "C"
// Implementations of patched functions.

void abort () { for(;;) { mcal::cpu::nop(); } }
int atexit (void (*)()) { return 0; }
int atexit (void (*)()) noexcept { return 0; }
int at_quick_exit (void (*)()) { return 0; }
void _Exit (int) { for(;;) { mcal::cpu::nop(); } }
void exit (int) { for(;;) { mcal::cpu::nop(); } }
Expand Down
Loading