Ignore:
Timestamp:
09/09/23 15:16:31 (8 months ago)
Author:
Maciej Komosinski
Message:

More unification of floating point exception handling across platforms

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/nonstd_math.h

    r1253 r1275  
    99#ifdef _MSC_VER
    1010 #define _USE_MATH_DEFINES //after this is defined, the next #include <math.h> or <cmath> will define M_PI etc.
    11  #include <math.h> //w vc2008 dzia³a³o tu <cmath>, ale w vc2010 juz nie bo "coœ" (jakiœ inny .h stl'a?) includuje wczeœniej <cmath> bez _USE_MATH_DEFINES, a <cmath> includuje <math.h> (ale tylko raz bo ma "include guards" jak kazdy .h)
     11 #include <math.h> //w vc2008 dzia�a�o tu <cmath>, ale w vc2010 juz nie bo "co�" (jaki� inny .h stl'a?) includuje wcze�niej <cmath> bez _USE_MATH_DEFINES, a <cmath> includuje <math.h> (ale tylko raz bo ma "include guards" jak kazdy .h)
    1212 #include <float.h>
    1313 //#define isnan(x) _isnan(x) //since 2014 we use std::isnan()
     
    6969
    7070#if defined SHP
    71  //#define __assert_func(a,b,c,d) 0 //Currently, we are sorry to inform you that assert() is not yet supported. We have considered your request for internal discussion. Na szczêœcie jest w³asna (byle by by³a, bo i tak zak³adamy ze assert ktore przeciez dziala tylko w trybie debug nie jest potrzebne na bada) implementacja w "bada-assert.cpp"
     71 //#define __assert_func(a,b,c,d) 0 //Currently, we are sorry to inform you that assert() is not yet supported. We have considered your request for internal discussion. Na szcz�cie jest w�asna (byle by by�a, bo i tak zak�adamy ze assert ktore przeciez dziala tylko w trybie debug nie jest potrzebne na bada) implementacja w "bada-assert.cpp"
    7272 #define isnan(x) false //isnan() sie nie linkuje
    7373 #define finite(x) true //j.w.
     
    7979#endif
    8080
     81#if defined LINUX || defined TIZEN || defined __ANDROID__
     82#include <fenv.h>
     83#endif
     84
     85namespace fpExcept
     86{
    8187//handling floating point exceptions
    82 void fpExceptInit(); //call once, before ...Enable/Disable
    83 void fpExceptEnable();
    84 void fpExceptDisable();
     88#if defined LINUX || defined TIZEN || defined __ANDROID__
     89        //fenv.h values
     90        static constexpr unsigned int FPEX_DIV0 = FE_DIVBYZERO;
     91        static constexpr unsigned int FPEX_INVALID = FE_INVALID;
     92        static constexpr unsigned int FPEX_OVERFLOW = FE_OVERFLOW;
     93#elif defined IPHONE
     94        // (not implemented but these constants are still needed)
     95        static constexpr unsigned int FPEX_DIV0 = 0;
     96        static constexpr unsigned int FPEX_INVALID = 0;
     97        static constexpr unsigned int FPEX_OVERFLOW = 0;
     98#else
     99        //_control87() values
     100        static constexpr unsigned int FPEX_DIV0 = EM_ZERODIVIDE;
     101        static constexpr unsigned int FPEX_INVALID = EM_INVALID;
     102        static constexpr unsigned int FPEX_OVERFLOW = EM_OVERFLOW;
     103#endif
     104        extern int wanted_exceptions;
     105       
     106        void init(); //call once, before ...Enable/Disable
     107        void enable();
     108        void disable();
     109};
    85110
    86111// std::lerp can be used since C++20 (and has some guaranteed properties probably better than this basic formula) but apparently it is not a template
Note: See TracChangeset for help on using the changeset viewer.