xref: /reactos/sdk/lib/crt/math/libm_sse2/libm_new.h (revision 4afb647c)
1 
2 /***********************************************************************************/
3 /** MIT License **/
4 /** ----------- **/
5 /** **/
6 /** Copyright (c) 2002-2019 Advanced Micro Devices, Inc. **/
7 /** **/
8 /** Permission is hereby granted, free of charge, to any person obtaining a copy **/
9 /** of this Software and associated documentaon files (the "Software"), to deal **/
10 /** in the Software without restriction, including without limitation the rights **/
11 /** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell **/
12 /** copies of the Software, and to permit persons to whom the Software is **/
13 /** furnished to do so, subject to the following conditions: **/
14 /** **/
15 /** The above copyright notice and this permission notice shall be included in **/
16 /** all copies or substantial portions of the Software. **/
17 /** **/
18 /** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR **/
19 /** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, **/
20 /** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE **/
21 /** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER **/
22 /** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, **/
23 /** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN **/
24 /** THE SOFTWARE. **/
25 /***********************************************************************************/
26 
27 #ifndef __LIBM_NEW_H__
28 #define __LIBM_NEW_H__
29 
30 // Defines, protos, etc for *new* math funcs updated by AMD 11/2008
31 // Old files will continue to include libm_util.h, libm.h, libm_inlines.h
32 // until such time as these have all been refreshed w/ new versions.
33 
34 typedef float F32;
35 typedef unsigned int U32;
36 
37 typedef double F64;
38 typedef unsigned long long U64;
39 
40 union UT32_
41 {
42     F32 f32;
43     U32 u32;
44 };
45 
46 union UT64_
47 {
48     F64 f64;
49     U64 u64;
50 
51     F32 f32[2];
52     U32 u32[2];
53 };
54 
55 typedef union UT32_ UT32;
56 typedef union UT64_ UT64;
57 
58 #define SIGN_MASK_32        0x80000000
59 #define MANTISSA_MASK_32    0x007fffff
60 #define EXPONENT_MASK_32    0x7f800000
61 #define QNAN_MASK_32        0x00400000
62 
63 #define INF_POS_32          0x7f800000
64 #define INF_NEG_32          0xff800000
65 #define QNAN_POS_32         0x7fc00000
66 #define QNAN_NEG_32         0xffc00000
67 #define IND_32              0xffc00000
68 
69 #define EXPONENT_FULL_32    0x7f800000
70 #define SIGN_SET_32         0x80000000
71 #define QNAN_SET_32         0x00400000
72 
73 #define INF_POS_64          0x7ff0000000000000
74 #define INF_NEG_64          0xfff0000000000000
75 
76 #define MANTISSA_MASK_64    0x000fffffffffffff
77 #define SIGN_MASK_64        0x8000000000000000
78 #define IND_64              0xfff8000000000000
79 #define QNAN_MASK_64        0x0008000000000000
80 
81 // constants for 'flags' argument of _handle_error and _handle_errorf
82 #define AMD_F_INEXACT     0x00000010
83 #define AMD_F_OVERFLOW    0x00000001
84 #define AMD_F_UNDERFLOW   0x00000002
85 #define AMD_F_DIVBYZERO   0x00000004
86 #define AMD_F_INVALID     0x00000008
87 
88 // define the Microsoft specific error handling routine
89 
90 // Note to mainainers:
91 // These prototypes may appear, at first glance, to differ from the versions
92 // declared in libm_inlines.h and defined in libm_error.c.  The third
93 // parameter appears to have changed type from unsigned long to unsigned long
94 // long.  In fact they are the same because in both of the aforementioned
95 // files, long has been #defined to __int64 in a most cowardly fashion.  This
96 // disgusts me.  The buck stops here. - MAS
97 
98 double _handle_error(
99         char *fname,
100         int opcode,
101         unsigned long long value,
102         int type,
103         int flags,
104         int error,
105         double arg1,
106         double arg2,
107         int nargs
108         );
109 float _handle_errorf(
110         char *fname,
111         int opcode,
112         unsigned long long value,
113         int type,
114         int flags,
115         int error,
116         float arg1,
117         float arg2,
118         int nargs
119         );
120 
121 #endif // __LIBM_NEW_H
122 
123