1 krisbash 1.1 /*
2 **==============================================================================
3 **
4 ** Open Management Infrastructure (OMI)
5 **
6 ** Copyright (c) Microsoft Corporation
7 **
8 ** Licensed under the Apache License, Version 2.0 (the "License"); you may not
9 ** use this file except in compliance with the License. You may obtain a copy
10 ** of the License at
11 **
12 ** http://www.apache.org/licenses/LICENSE-2.0
13 **
14 ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 ** MERCHANTABLITY OR NON-INFRINGEMENT.
18 **
19 ** See the Apache 2 License for the specific language governing permissions
20 ** and limitations under the License.
21 **
22 krisbash 1.1 **==============================================================================
23 */
24
25 #include <math.h>
26
27 #ifndef _pal_math_h
28 #define _pal_math_h
29
30 #include <pal/palcommon.h>
31
32 #if __STDC_VERSION__ >= 199901L
33 # define PAL_ISNAN(x) (isnan(x))
34 # define PAL_ISINF(x) (isinf(x))
35 # define PAL_NAN() (NAN)
36 # define PAL_INF() (INFINITY)
37 #else
38 PAL_INLINE int PAL_ISNAN(double x)
39 {
40 return (x != x);
41 }
42 PAL_INLINE int PAL_ISINF(double x)
43 krisbash 1.1 {
44 return (!PAL_ISNAN(x) && PAL_ISNAN(x - x));
45 }
46 PAL_INLINE double PAL_NAN(void)
47 {
48 double zero = 0.0;
49 return 0.0 / ((zero - zero) * zero);
50 }
51 PAL_INLINE double PAL_INF(void)
52 {
53 double zero = 0.0;
54 return 1.0 / ((zero - zero) * zero);
55 }
56 #endif
57
58 #endif /* _pal_math_h */
|