VirtualBox

Changeset 96098 in vbox for trunk/include/iprt/nocrt


Ignore:
Timestamp:
Aug 7, 2022 7:04:19 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
152897
Message:

IPRT/nocrt: Math constants: HUGH_VAL*, NAN, INFINITY. bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/nocrt/math.h

    r96019 r96098  
    6464 */
    6565extern const union __infinity_un {
    66     unsigned char   __uc[8];
    67     double      __ud;
     66    RTFLOAT64U      __uu;
     67    double          __ud;
    6868} RT_NOCRT(__infinity);
    6969
    70 extern const union __nan_un {
    71     unsigned char   __uc[sizeof(float)];
    72     float       __uf;
    73 } RT_NOCRT(__nan);
     70extern const union __nanf_un {
     71    RTFLOAT32U      __uu;
     72    float           __uf;
     73} RT_NOCRT(__nanf);
    7474
    7575#if __GNUC_PREREQ__(3, 3) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
     
    8181#endif
    8282
    83 #ifdef __MATH_BUILTIN_CONSTANTS
    84 #define HUGE_VAL    __builtin_huge_val()
     83#if defined(__MATH_BUILTIN_CONSTANTS) \
     84 || (RT_MSC_PREREQ(RT_MSC_VER_VC140) && defined(__cplusplus)) /** @todo when was this added exactly? 2015, 2017 & 2019 has it for C++. */
     85# define HUGE_VAL   __builtin_huge_val()
    8586#else
    86 #define HUGE_VAL    (RT_NOCRT(__infinity).__ud)
     87# define HUGE_VAL   (RT_NOCRT(__infinity).__ud)
    8788#endif
    8889
     
    483484
    484485#ifdef __MATH_BUILTIN_CONSTANTS
    485 #define HUGE_VALF   __builtin_huge_valf()
    486 #define HUGE_VALL   __builtin_huge_vall()
    487 #define INFINITY    __builtin_inf()
    488 #define NAN     __builtin_nan("")
     486# define HUGE_VALF   __builtin_huge_valf()
     487# define HUGE_VALL   __builtin_huge_vall()
     488# define INFINITY    __builtin_inf()
     489# define NAN         __builtin_nan("")
     490#elif RT_MSC_PREREQ(RT_MSC_VER_VC140) && defined(__cplusplus)
     491/** @todo When were these introduced exactly? 2015, 2017 & 2019 has them.
     492 * However, they only work in C++ even if the c1.dll includes the strings. Oh, well. */
     493# define HUGE_VALF   __builtin_huge_valf()
     494# define HUGE_VALL   __builtin_huge_val()
     495# define INFINITY    __builtin_huge_val()
     496# define NAN         __builtin_nan("0")     /* same as we use in climits */
    489497#else
    490 #define HUGE_VALF   (float)HUGE_VAL
    491 #define HUGE_VALL   (long double)HUGE_VAL
    492 #define INFINITY    HUGE_VALF
    493 #define NAN     (__nan.__uf)
     498# define HUGE_VALF   (float)HUGE_VAL
     499# define HUGE_VALL   (long double)HUGE_VAL
     500# define INFINITY    HUGE_VALF
     501# define NAN         (__nanf.__uf)
    494502#endif /* __MATH_BUILTIN_CONSTANTS */
    495503
     
    566574#if !defined(RT_WITHOUT_NOCRT_WRAPPERS) && !defined(RT_WITHOUT_NOCRT_WRAPPER_ALIASES)
    567575/* sed -e "/#/d" -e "/RT_NOCRT/!d" -e "s/^.*RT_NOCRT(\([a-z0-9_]*\)).*$/# define \1 RT_NOCRT(\1)/" */
    568 # define __infinity RT_NOCRT(__infinity)
    569 # define __nan RT_NOCRT(__nan)
    570576# define __fpclassifyf RT_NOCRT(__fpclassifyf)
    571577# define __fpclassifyd RT_NOCRT(__fpclassifyd)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette