99#include < mcal_gpt.h>
1010
1111#include < chrono>
12+ #include < cmath>
1213#include < cstddef>
1314
1415#if defined(__GNUC__)
1516#pragma GCC diagnostic push
1617#pragma GCC diagnostic ignored "-Wmissing-declarations"
18+ #pragma GCC diagnostic push
19+ #pragma GCC diagnostic ignored "-Wfloat-equal"
1720#endif
1821
22+ int isinf (double );
23+
1924// Implement std::chrono::high_resolution_clock::now()
2025// for the standard library's high-resolution clock.
2126namespace std
@@ -84,12 +89,14 @@ extern "C"
8489{
8590 // Declarations of patched functions.
8691
92+ int fpclassifyf (float );
93+
8794 // Provide stubbed copies of certain functions declared in <stdlib.h> and <cstdlib>.
8895 // Also provide stubbed copies of certain empirically found library functions
8996 // and objects.
9097
9198 void abort () __attribute__((noreturn));
92- int atexit (void (*)());
99+ int atexit (void (*)()) noexcept ;
93100 int at_quick_exit (void (*)());
94101 void _Exit (int ) __attribute__((noreturn));
95102 void exit (int ) __attribute__((noreturn));
@@ -110,8 +117,37 @@ extern "C"
110117
111118 // Implementations of patched functions.
112119
120+ int fpclassifyf (float x)
121+ {
122+ if ((::isnanf)(x) != 0 )
123+ {
124+ return FP_NAN;
125+ }
126+ else if ((::__builtin_isinf)(static_cast <double >(x)) != 0.0 )
127+ {
128+ return FP_INFINITE;
129+ }
130+ else if ((::fabsf)(x) == 0 .0F )
131+ {
132+ return FP_ZERO;
133+ }
134+ else
135+ {
136+ const bool
137+ is_subnormal
138+ {
139+ (
140+ ((::fabsf)(x) > 0 .0F )
141+ && ((::fabsf)(x) < (std::numeric_limits<float >::min)())
142+ )
143+ };
144+
145+ return (is_subnormal ? FP_SUBNORMAL : FP_NORMAL);
146+ }
147+ }
148+
113149 void abort () { for (;;) { mcal::cpu::nop (); } }
114- int atexit (void (*)()) { return 0 ; }
150+ int atexit (void (*)()) noexcept { return 0 ; }
115151 int at_quick_exit (void (*)()) { return 0 ; }
116152 void _Exit (int ) { for (;;) { mcal::cpu::nop (); } }
117153 void exit (int ) { for (;;) { mcal::cpu::nop (); } }
@@ -162,4 +198,5 @@ namespace std
162198
163199#if defined(__GNUC__)
164200#pragma GCC diagnostic pop
201+ #pragma GCC diagnostic pop
165202#endif
0 commit comments