Merging r37048, r37051, r37052, r37055 from the-real-msvc branch
[reactos.git] / reactos / lib / sdk / crt / math / i386 / ci.c
1 #include <precomp.h>
2 #include <math.h>
3
4 #if defined(__GNUC__)
5 #define FPU_DOUBLE(var) double var; \
6 __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var) : )
7 #define FPU_DOUBLES(var1,var2) double var1,var2; \
8 __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var2) : ); \
9 __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var1) : )
10 #elif defined(_MSC_VER)
11 #define FPU_DOUBLE(var) double var; \
12 __asm { fstp [var] }; __asm { fwait };
13 #define FPU_DOUBLES(var1,var2) double var1,var2; \
14 __asm { fstp [var1] }; __asm { fwait }; \
15 __asm { fstp [var2] }; __asm { fwait };
16 #endif
17
18 /*
19 * @implemented
20 */
21 double CDECL _CIsin(void)
22 {
23 FPU_DOUBLE(x);
24 return sin(x);
25 }
26 /*
27 * @implemented
28 */
29 double CDECL _CIcos(void)
30 {
31 FPU_DOUBLE(x);
32 return cos(x);
33 }
34 /*
35 * @implemented
36 */
37 double CDECL _CItan(void)
38 {
39 FPU_DOUBLE(x);
40 return tan(x);
41 }
42 /*
43 * @implemented
44 */
45 double CDECL _CIsinh(void)
46 {
47 FPU_DOUBLE(x);
48 return sinh(x);
49 }
50 /*
51 * @implemented
52 */
53 double CDECL _CIcosh(void)
54 {
55 FPU_DOUBLE(x);
56 return cosh(x);
57 }
58 /*
59 * @implemented
60 */
61 double CDECL _CItanh(void)
62 {
63 FPU_DOUBLE(x);
64 return tanh(x);
65 }
66 /*
67 * @implemented
68 */
69 double CDECL _CIasin(void)
70 {
71 FPU_DOUBLE(x);
72 return asin(x);
73 }
74 /*
75 * @implemented
76 */
77 double CDECL _CIacos(void)
78 {
79 FPU_DOUBLE(x);
80 return acos(x);
81 }
82 /*
83 * @implemented
84 */
85 double CDECL _CIatan(void)
86 {
87 FPU_DOUBLE(x);
88 return atan(x);
89 }
90 /*
91 * @implemented
92 */
93 double CDECL _CIatan2(void)
94 {
95 FPU_DOUBLES(x, y);
96 return atan2(x, y);
97 }
98 /*
99 * @implemented
100 */
101 double CDECL _CIexp(void)
102 {
103 FPU_DOUBLE(x);
104 return exp(x);
105 }
106 /*
107 * @implemented
108 */
109 double CDECL _CIlog(void)
110 {
111 FPU_DOUBLE(x);
112 return log(x);
113 }
114 /*
115 * @implemented
116 */
117 double CDECL _CIlog10(void)
118 {
119 FPU_DOUBLE(x);
120 return log10(x);
121 }
122 /*
123 * @implemented
124 */
125 double CDECL _CIpow(void)
126 {
127 FPU_DOUBLES(x, y);
128 return pow(x, y);
129 }
130 /*
131 * @implemented
132 */
133 double CDECL _CIsqrt(void)
134 {
135 FPU_DOUBLE(x);
136 return sqrt(x);
137 }
138 /*
139 * @implemented
140 */
141 double CDECL _CIfmod(void)
142 {
143 FPU_DOUBLES(x, y);
144 return fmod(x, y);
145 }