2 * msvcrt.dll math functions
4 * Copyright 2000 Jon Griffiths
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/port.h"
24 #define __USE_ISOC9X 1
25 #define __USE_ISOC99 1
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt
);
41 typedef int (CDECL
*MSVCRT_matherr_func
)(struct MSVCRT__exception
*);
43 static MSVCRT_matherr_func MSVCRT_default_matherr_func
= NULL
;
45 static BOOL sse2_supported
;
46 static BOOL sse2_enabled
;
48 void msvcrt_init_math(void)
50 sse2_supported
= sse2_enabled
= IsProcessorFeaturePresent( PF_XMMI64_INSTRUCTIONS_AVAILABLE
);
53 /*********************************************************************
54 * _set_SSE2_enable (MSVCRT.@)
56 int CDECL
MSVCRT__set_SSE2_enable(int flag
)
58 sse2_enabled
= flag
&& sse2_supported
;
62 #if defined(__x86_64__) || defined(__arm__)
64 /*********************************************************************
65 * _chgsignf (MSVCRT.@)
67 float CDECL
MSVCRT__chgsignf( float num
)
69 /* FIXME: +-infinity,Nan not tested */
73 /*********************************************************************
74 * _copysignf (MSVCRT.@)
76 float CDECL
MSVCRT__copysignf( float num
, float sign
)
78 /* FIXME: Behaviour for Nan/Inf? */
80 return num
< 0.0 ? num
: -num
;
81 return num
< 0.0 ? -num
: num
;
84 /*********************************************************************
87 int CDECL
MSVCRT__finitef( float num
)
89 return finitef(num
) != 0; /* See comment for _isnan() */
92 /*********************************************************************
95 INT CDECL
MSVCRT__isnanf( float num
)
97 /* Some implementations return -1 for true(glibc), msvcrt/crtdll return 1.
98 * Do the same, as the result may be used in calculations
100 return isnanf(num
) != 0;
103 /*********************************************************************
106 float CDECL
MSVCRT__logbf( float num
)
108 if (!finitef(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
112 /*********************************************************************
113 * _nextafterf (MSVCRT.@)
115 float CDECL
MSVCRT__nextafterf( float num
, float next
)
117 if (!finitef(num
) || !finitef(next
)) *MSVCRT__errno() = MSVCRT_EDOM
;
118 return nextafterf( num
, next
);
121 /*********************************************************************
122 * MSVCRT_acosf (MSVCRT.@)
124 float CDECL
MSVCRT_acosf( float x
)
126 if (x
< -1.0 || x
> 1.0 || !finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
127 /* glibc implements acos() as the FPU equivalent of atan2(sqrt(1 - x ^ 2), x).
128 * asin() uses a similar construction. This is bad because as x gets nearer to
129 * 1 the error in the expression "1 - x^2" can get relatively large due to
130 * cancellation. The sqrt() makes things worse. A safer way to calculate
131 * acos() is to use atan2(sqrt((1 - x) * (1 + x)), x). */
132 return atan2f(sqrtf((1 - x
) * (1 + x
)), x
);
135 /*********************************************************************
136 * MSVCRT_asinf (MSVCRT.@)
138 float CDECL
MSVCRT_asinf( float x
)
140 if (x
< -1.0 || x
> 1.0 || !finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
141 return atan2f(x
, sqrtf((1 - x
) * (1 + x
)));
144 /*********************************************************************
145 * MSVCRT_atanf (MSVCRT.@)
147 float CDECL
MSVCRT_atanf( float x
)
149 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
153 /*********************************************************************
154 * MSVCRT_atan2f (MSVCRT.@)
156 float CDECL
MSVCRT_atan2f( float x
, float y
)
158 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
162 /*********************************************************************
163 * MSVCRT_cosf (MSVCRT.@)
165 float CDECL
MSVCRT_cosf( float x
)
167 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
171 /*********************************************************************
172 * MSVCRT_coshf (MSVCRT.@)
174 float CDECL
MSVCRT_coshf( float x
)
176 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
180 /*********************************************************************
181 * MSVCRT_expf (MSVCRT.@)
183 float CDECL
MSVCRT_expf( float x
)
185 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
189 /*********************************************************************
190 * MSVCRT_fmodf (MSVCRT.@)
192 float CDECL
MSVCRT_fmodf( float x
, float y
)
194 if (!finitef(x
) || !finitef(y
)) *MSVCRT__errno() = MSVCRT_EDOM
;
198 /*********************************************************************
199 * MSVCRT_logf (MSVCRT.@)
201 float CDECL
MSVCRT_logf( float x
)
203 if (x
< 0.0 || !finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
204 if (x
== 0.0) *MSVCRT__errno() = MSVCRT_ERANGE
;
208 /*********************************************************************
209 * MSVCRT_log10f (MSVCRT.@)
211 float CDECL
MSVCRT_log10f( float x
)
213 if (x
< 0.0 || !finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
214 if (x
== 0.0) *MSVCRT__errno() = MSVCRT_ERANGE
;
218 /*********************************************************************
219 * MSVCRT_powf (MSVCRT.@)
221 float CDECL
MSVCRT_powf( float x
, float y
)
223 /* FIXME: If x < 0 and y is not integral, set EDOM */
225 if (!finitef(z
)) *MSVCRT__errno() = MSVCRT_EDOM
;
229 /*********************************************************************
230 * MSVCRT_sinf (MSVCRT.@)
232 float CDECL
MSVCRT_sinf( float x
)
234 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
238 /*********************************************************************
239 * MSVCRT_sinhf (MSVCRT.@)
241 float CDECL
MSVCRT_sinhf( float x
)
243 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
247 /*********************************************************************
248 * MSVCRT_sqrtf (MSVCRT.@)
250 float CDECL
MSVCRT_sqrtf( float x
)
252 if (x
< 0.0 || !finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
256 /*********************************************************************
257 * MSVCRT_tanf (MSVCRT.@)
259 float CDECL
MSVCRT_tanf( float x
)
261 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
265 /*********************************************************************
266 * MSVCRT_tanhf (MSVCRT.@)
268 float CDECL
MSVCRT_tanhf( float x
)
270 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
274 /*********************************************************************
277 float CDECL
MSVCRT_ceilf( float x
)
282 /*********************************************************************
285 float CDECL
MSVCRT_fabsf( float x
)
290 /*********************************************************************
293 float CDECL
MSVCRT_floorf( float x
)
298 /*********************************************************************
301 float CDECL
MSVCRT_frexpf( float x
, int *exp
)
303 return frexpf( x
, exp
);
306 /*********************************************************************
309 float CDECL
MSVCRT__scalbf(float num
, MSVCRT_long power
)
311 if (!finitef(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
312 return ldexpf(num
, power
);
315 /*********************************************************************
318 double CDECL
MSVCRT_modff( float x
, float *iptr
)
320 return modff( x
, iptr
);
325 /*********************************************************************
326 * MSVCRT_acos (MSVCRT.@)
328 double CDECL
MSVCRT_acos( double x
)
330 if (x
< -1.0 || x
> 1.0 || !isfinite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
331 /* glibc implements acos() as the FPU equivalent of atan2(sqrt(1 - x ^ 2), x).
332 * asin() uses a similar construction. This is bad because as x gets nearer to
333 * 1 the error in the expression "1 - x^2" can get relatively large due to
334 * cancellation. The sqrt() makes things worse. A safer way to calculate
335 * acos() is to use atan2(sqrt((1 - x) * (1 + x)), x). */
336 return atan2(sqrt((1 - x
) * (1 + x
)), x
);
339 /*********************************************************************
340 * MSVCRT_asin (MSVCRT.@)
342 double CDECL
MSVCRT_asin( double x
)
344 if (x
< -1.0 || x
> 1.0 || !isfinite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
345 return atan2(x
, sqrt((1 - x
) * (1 + x
)));
348 /*********************************************************************
349 * MSVCRT_atan (MSVCRT.@)
351 double CDECL
MSVCRT_atan( double x
)
353 if (!isfinite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
357 /*********************************************************************
358 * MSVCRT_atan2 (MSVCRT.@)
360 double CDECL
MSVCRT_atan2( double x
, double y
)
362 if (!isfinite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
366 /*********************************************************************
367 * MSVCRT_cos (MSVCRT.@)
369 double CDECL
MSVCRT_cos( double x
)
371 if (!isfinite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
375 /*********************************************************************
376 * MSVCRT_cosh (MSVCRT.@)
378 double CDECL
MSVCRT_cosh( double x
)
380 if (!isfinite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
384 /*********************************************************************
385 * MSVCRT_exp (MSVCRT.@)
387 double CDECL
MSVCRT_exp( double x
)
389 if (!isfinite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
393 /*********************************************************************
394 * MSVCRT_fmod (MSVCRT.@)
396 double CDECL
MSVCRT_fmod( double x
, double y
)
398 if (!isfinite(x
) || !isfinite(y
)) *MSVCRT__errno() = MSVCRT_EDOM
;
402 /*********************************************************************
403 * MSVCRT_log (MSVCRT.@)
405 double CDECL
MSVCRT_log( double x
)
407 if (x
< 0.0 || !isfinite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
408 if (x
== 0.0) *MSVCRT__errno() = MSVCRT_ERANGE
;
412 /*********************************************************************
413 * MSVCRT_log10 (MSVCRT.@)
415 double CDECL
MSVCRT_log10( double x
)
417 if (x
< 0.0 || !isfinite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
418 if (x
== 0.0) *MSVCRT__errno() = MSVCRT_ERANGE
;
422 /*********************************************************************
423 * MSVCRT_pow (MSVCRT.@)
425 double CDECL
MSVCRT_pow( double x
, double y
)
427 /* FIXME: If x < 0 and y is not integral, set EDOM */
429 if (!isfinite(z
)) *MSVCRT__errno() = MSVCRT_EDOM
;
433 /*********************************************************************
434 * MSVCRT_sin (MSVCRT.@)
436 double CDECL
MSVCRT_sin( double x
)
438 if (!isfinite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
442 /*********************************************************************
443 * MSVCRT_sinh (MSVCRT.@)
445 double CDECL
MSVCRT_sinh( double x
)
447 if (!isfinite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
451 /*********************************************************************
452 * MSVCRT_sqrt (MSVCRT.@)
454 double CDECL
MSVCRT_sqrt( double x
)
456 if (x
< 0.0 || !isfinite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
460 /*********************************************************************
461 * MSVCRT_tan (MSVCRT.@)
463 double CDECL
MSVCRT_tan( double x
)
465 if (!isfinite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
469 /*********************************************************************
470 * MSVCRT_tanh (MSVCRT.@)
472 double CDECL
MSVCRT_tanh( double x
)
474 if (!isfinite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
479 #if defined(__GNUC__) && defined(__i386__)
481 #define FPU_DOUBLE(var) double var; \
482 __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var) : )
483 #define FPU_DOUBLES(var1,var2) double var1,var2; \
484 __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var2) : ); \
485 __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var1) : )
487 /*********************************************************************
490 double CDECL
_CIacos(void)
493 return MSVCRT_acos(x
);
496 /*********************************************************************
499 double CDECL
_CIasin(void)
502 return MSVCRT_asin(x
);
505 /*********************************************************************
508 double CDECL
_CIatan(void)
511 return MSVCRT_atan(x
);
514 /*********************************************************************
515 * _CIatan2 (MSVCRT.@)
517 double CDECL
_CIatan2(void)
520 return MSVCRT_atan2(x
,y
);
523 /*********************************************************************
526 double CDECL
_CIcos(void)
529 return MSVCRT_cos(x
);
532 /*********************************************************************
535 double CDECL
_CIcosh(void)
538 return MSVCRT_cosh(x
);
541 /*********************************************************************
544 double CDECL
_CIexp(void)
547 return MSVCRT_exp(x
);
550 /*********************************************************************
553 double CDECL
_CIfmod(void)
556 return MSVCRT_fmod(x
,y
);
559 /*********************************************************************
562 double CDECL
_CIlog(void)
565 return MSVCRT_log(x
);
568 /*********************************************************************
569 * _CIlog10 (MSVCRT.@)
571 double CDECL
_CIlog10(void)
574 return MSVCRT_log10(x
);
577 /*********************************************************************
580 double CDECL
_CIpow(void)
583 return MSVCRT_pow(x
,y
);
586 /*********************************************************************
589 double CDECL
_CIsin(void)
592 return MSVCRT_sin(x
);
595 /*********************************************************************
598 double CDECL
_CIsinh(void)
601 return MSVCRT_sinh(x
);
604 /*********************************************************************
607 double CDECL
_CIsqrt(void)
610 return MSVCRT_sqrt(x
);
613 /*********************************************************************
616 double CDECL
_CItan(void)
619 return MSVCRT_tan(x
);
622 /*********************************************************************
625 double CDECL
_CItanh(void)
628 return MSVCRT_tanh(x
);
631 /*********************************************************************
634 LONGLONG CDECL
MSVCRT__ftol(void)
640 #endif /* defined(__GNUC__) && defined(__i386__) */
642 /*********************************************************************
643 * _fpclass (MSVCRT.@)
645 int CDECL
MSVCRT__fpclass(double num
)
647 #if defined(HAVE_FPCLASS) || defined(fpclass)
648 switch (fpclass( num
))
651 case FP_SNAN
: return MSVCRT__FPCLASS_SNAN
;
654 case FP_QNAN
: return MSVCRT__FPCLASS_QNAN
;
657 case FP_NINF
: return MSVCRT__FPCLASS_NINF
;
660 case FP_PINF
: return MSVCRT__FPCLASS_PINF
;
663 case FP_NDENORM
: return MSVCRT__FPCLASS_ND
;
666 case FP_PDENORM
: return MSVCRT__FPCLASS_PD
;
669 case FP_NZERO
: return MSVCRT__FPCLASS_NZ
;
672 case FP_PZERO
: return MSVCRT__FPCLASS_PZ
;
675 case FP_NNORM
: return MSVCRT__FPCLASS_NN
;
678 case FP_PNORM
: return MSVCRT__FPCLASS_PN
;
680 default: return MSVCRT__FPCLASS_PN
;
682 #elif defined (fpclassify)
683 switch (fpclassify( num
))
685 case FP_NAN
: return MSVCRT__FPCLASS_QNAN
;
686 case FP_INFINITE
: return signbit(num
) ? MSVCRT__FPCLASS_NINF
: MSVCRT__FPCLASS_PINF
;
687 case FP_SUBNORMAL
: return signbit(num
) ?MSVCRT__FPCLASS_ND
: MSVCRT__FPCLASS_PD
;
688 case FP_ZERO
: return signbit(num
) ? MSVCRT__FPCLASS_NZ
: MSVCRT__FPCLASS_PZ
;
690 return signbit(num
) ? MSVCRT__FPCLASS_NN
: MSVCRT__FPCLASS_PN
;
693 return MSVCRT__FPCLASS_QNAN
;
694 return num
== 0.0 ? MSVCRT__FPCLASS_PZ
: (num
< 0 ? MSVCRT__FPCLASS_NN
: MSVCRT__FPCLASS_PN
);
698 /*********************************************************************
701 unsigned int CDECL
_rotl(unsigned int num
, int shift
)
704 return (num
<< shift
) | (num
>> (32-shift
));
707 /*********************************************************************
710 MSVCRT_ulong CDECL
MSVCRT__lrotl(MSVCRT_ulong num
, int shift
)
713 return (num
<< shift
) | (num
>> (32-shift
));
716 /*********************************************************************
719 MSVCRT_ulong CDECL
MSVCRT__lrotr(MSVCRT_ulong num
, int shift
)
722 return (num
>> shift
) | (num
<< (32-shift
));
725 /*********************************************************************
728 unsigned int CDECL
_rotr(unsigned int num
, int shift
)
731 return (num
>> shift
) | (num
<< (32-shift
));
734 /*********************************************************************
737 unsigned __int64 CDECL
_rotl64(unsigned __int64 num
, int shift
)
740 return (num
<< shift
) | (num
>> (64-shift
));
743 /*********************************************************************
746 unsigned __int64 CDECL
_rotr64(unsigned __int64 num
, int shift
)
749 return (num
>> shift
) | (num
<< (64-shift
));
752 /*********************************************************************
755 int CDECL
MSVCRT_abs( int n
)
757 return n
>= 0 ? n
: -n
;
760 /*********************************************************************
763 MSVCRT_long CDECL
MSVCRT_labs( MSVCRT_long n
)
765 return n
>= 0 ? n
: -n
;
768 /*********************************************************************
771 __int64 CDECL
_abs64( __int64 n
)
773 return n
>= 0 ? n
: -n
;
776 /*********************************************************************
779 double CDECL
MSVCRT__logb(double num
)
781 if (!isfinite(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
785 /*********************************************************************
788 double CDECL
MSVCRT__scalb(double num
, MSVCRT_long power
)
790 if (!isfinite(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
791 return ldexp(num
, power
);
794 /*********************************************************************
797 double CDECL
_hypot(double x
, double y
)
799 /* FIXME: errno handling */
800 return hypot( x
, y
);
803 /*********************************************************************
806 float CDECL
MSVCRT__hypotf(float x
, float y
)
808 /* FIXME: errno handling */
809 return hypotf( x
, y
);
812 /*********************************************************************
815 double CDECL
MSVCRT_ceil( double x
)
820 /*********************************************************************
823 double CDECL
MSVCRT_floor( double x
)
828 /*********************************************************************
831 double CDECL
MSVCRT_fabs( double x
)
836 /*********************************************************************
839 double CDECL
MSVCRT_frexp( double x
, int *exp
)
841 return frexp( x
, exp
);
844 /*********************************************************************
847 double CDECL
MSVCRT_modf( double x
, double *iptr
)
849 return modf( x
, iptr
);
852 /*********************************************************************
853 * _matherr (MSVCRT.@)
855 int CDECL
MSVCRT__matherr(struct MSVCRT__exception
*e
)
858 TRACE("(%p = %d, %s, %g %g %g)\n",e
, e
->type
, e
->name
, e
->arg1
, e
->arg2
,
862 if (MSVCRT_default_matherr_func
)
863 return MSVCRT_default_matherr_func(e
);
864 ERR(":Unhandled math error!\n");
868 /*********************************************************************
869 * __setusermatherr (MSVCRT.@)
871 void CDECL
MSVCRT___setusermatherr(MSVCRT_matherr_func func
)
873 MSVCRT_default_matherr_func
= func
;
874 TRACE(":new matherr handler %p\n", func
);
877 /**********************************************************************
878 * _statusfp2 (MSVCRT.@)
880 * Not exported by native msvcrt, added in msvcr80.
882 #if defined(__i386__) || defined(__x86_64__)
883 void CDECL
_statusfp2( unsigned int *x86_sw
, unsigned int *sse2_sw
)
887 unsigned long fpword
;
891 __asm__
__volatile__( "fstsw %0" : "=m" (fpword
) );
893 if (fpword
& 0x1) flags
|= MSVCRT__SW_INVALID
;
894 if (fpword
& 0x2) flags
|= MSVCRT__SW_DENORMAL
;
895 if (fpword
& 0x4) flags
|= MSVCRT__SW_ZERODIVIDE
;
896 if (fpword
& 0x8) flags
|= MSVCRT__SW_OVERFLOW
;
897 if (fpword
& 0x10) flags
|= MSVCRT__SW_UNDERFLOW
;
898 if (fpword
& 0x20) flags
|= MSVCRT__SW_INEXACT
;
902 if (!sse2_sw
) return;
906 __asm__
__volatile__( "stmxcsr %0" : "=m" (fpword
) );
908 if (fpword
& 0x1) flags
|= MSVCRT__SW_INVALID
;
909 if (fpword
& 0x2) flags
|= MSVCRT__SW_DENORMAL
;
910 if (fpword
& 0x4) flags
|= MSVCRT__SW_ZERODIVIDE
;
911 if (fpword
& 0x8) flags
|= MSVCRT__SW_OVERFLOW
;
912 if (fpword
& 0x10) flags
|= MSVCRT__SW_UNDERFLOW
;
913 if (fpword
& 0x20) flags
|= MSVCRT__SW_INEXACT
;
918 FIXME( "not implemented\n" );
923 /**********************************************************************
924 * _statusfp (MSVCRT.@)
926 unsigned int CDECL
_statusfp(void)
928 #if defined(__i386__) || defined(__x86_64__)
929 unsigned int x86_sw
, sse2_sw
;
931 _statusfp2( &x86_sw
, &sse2_sw
);
932 /* FIXME: there's no definition for ambiguous status, just return all status bits for now */
933 return x86_sw
| sse2_sw
;
935 FIXME( "not implemented\n" );
940 /*********************************************************************
941 * _clearfp (MSVCRT.@)
943 unsigned int CDECL
_clearfp(void)
945 unsigned int flags
= 0;
946 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
947 unsigned long fpword
;
949 __asm__
__volatile__( "fnstsw %0; fnclex" : "=m" (fpword
) );
950 if (fpword
& 0x1) flags
|= MSVCRT__SW_INVALID
;
951 if (fpword
& 0x2) flags
|= MSVCRT__SW_DENORMAL
;
952 if (fpword
& 0x4) flags
|= MSVCRT__SW_ZERODIVIDE
;
953 if (fpword
& 0x8) flags
|= MSVCRT__SW_OVERFLOW
;
954 if (fpword
& 0x10) flags
|= MSVCRT__SW_UNDERFLOW
;
955 if (fpword
& 0x20) flags
|= MSVCRT__SW_INEXACT
;
959 __asm__
__volatile__( "stmxcsr %0" : "=m" (fpword
) );
960 if (fpword
& 0x1) flags
|= MSVCRT__SW_INVALID
;
961 if (fpword
& 0x2) flags
|= MSVCRT__SW_DENORMAL
;
962 if (fpword
& 0x4) flags
|= MSVCRT__SW_ZERODIVIDE
;
963 if (fpword
& 0x8) flags
|= MSVCRT__SW_OVERFLOW
;
964 if (fpword
& 0x10) flags
|= MSVCRT__SW_UNDERFLOW
;
965 if (fpword
& 0x20) flags
|= MSVCRT__SW_INEXACT
;
967 __asm__
__volatile__( "ldmxcsr %0" : : "m" (fpword
) );
970 FIXME( "not implemented\n" );
975 /*********************************************************************
976 * __fpecode (MSVCRT.@)
978 int * CDECL
__fpecode(void)
980 return &msvcrt_get_thread_data()->fpecode
;
983 /*********************************************************************
986 double CDECL
MSVCRT_ldexp(double num
, MSVCRT_long exp
)
988 double z
= ldexp(num
,exp
);
991 *MSVCRT__errno() = MSVCRT_ERANGE
;
992 else if (z
== 0 && signbit(z
))
993 z
= 0.0; /* Convert -0 -> +0 */
997 /*********************************************************************
1000 double CDECL
MSVCRT__cabs(struct MSVCRT__complex num
)
1002 return sqrt(num
.x
* num
.x
+ num
.y
* num
.y
);
1005 /*********************************************************************
1006 * _chgsign (MSVCRT.@)
1008 double CDECL
MSVCRT__chgsign(double num
)
1010 /* FIXME: +-infinity,Nan not tested */
1014 /*********************************************************************
1015 * __control87_2 (MSVCRT.@)
1017 * Not exported by native msvcrt, added in msvcr80.
1019 #if defined(__i386__) || defined(__x86_64__)
1020 int CDECL
__control87_2( unsigned int newval
, unsigned int mask
,
1021 unsigned int *x86_cw
, unsigned int *sse2_cw
)
1024 unsigned long fpword
;
1029 __asm__
__volatile__( "fstcw %0" : "=m" (fpword
) );
1031 /* Convert into mask constants */
1033 if (fpword
& 0x1) flags
|= MSVCRT__EM_INVALID
;
1034 if (fpword
& 0x2) flags
|= MSVCRT__EM_DENORMAL
;
1035 if (fpword
& 0x4) flags
|= MSVCRT__EM_ZERODIVIDE
;
1036 if (fpword
& 0x8) flags
|= MSVCRT__EM_OVERFLOW
;
1037 if (fpword
& 0x10) flags
|= MSVCRT__EM_UNDERFLOW
;
1038 if (fpword
& 0x20) flags
|= MSVCRT__EM_INEXACT
;
1039 switch (fpword
& 0xc00)
1041 case 0xc00: flags
|= MSVCRT__RC_UP
|MSVCRT__RC_DOWN
; break;
1042 case 0x800: flags
|= MSVCRT__RC_UP
; break;
1043 case 0x400: flags
|= MSVCRT__RC_DOWN
; break;
1045 switch (fpword
& 0x300)
1047 case 0x0: flags
|= MSVCRT__PC_24
; break;
1048 case 0x200: flags
|= MSVCRT__PC_53
; break;
1049 case 0x300: flags
|= MSVCRT__PC_64
; break;
1051 if (fpword
& 0x1000) flags
|= MSVCRT__IC_AFFINE
;
1053 TRACE( "x86 flags=%08x newval=%08x mask=%08x\n", flags
, newval
, mask
);
1056 flags
= (flags
& ~mask
) | (newval
& mask
);
1058 /* Convert (masked) value back to fp word */
1060 if (flags
& MSVCRT__EM_INVALID
) fpword
|= 0x1;
1061 if (flags
& MSVCRT__EM_DENORMAL
) fpword
|= 0x2;
1062 if (flags
& MSVCRT__EM_ZERODIVIDE
) fpword
|= 0x4;
1063 if (flags
& MSVCRT__EM_OVERFLOW
) fpword
|= 0x8;
1064 if (flags
& MSVCRT__EM_UNDERFLOW
) fpword
|= 0x10;
1065 if (flags
& MSVCRT__EM_INEXACT
) fpword
|= 0x20;
1066 switch (flags
& MSVCRT__MCW_RC
)
1068 case MSVCRT__RC_UP
|MSVCRT__RC_DOWN
: fpword
|= 0xc00; break;
1069 case MSVCRT__RC_UP
: fpword
|= 0x800; break;
1070 case MSVCRT__RC_DOWN
: fpword
|= 0x400; break;
1072 switch (flags
& MSVCRT__MCW_PC
)
1074 case MSVCRT__PC_64
: fpword
|= 0x300; break;
1075 case MSVCRT__PC_53
: fpword
|= 0x200; break;
1076 case MSVCRT__PC_24
: fpword
|= 0x0; break;
1078 if (flags
& MSVCRT__IC_AFFINE
) fpword
|= 0x1000;
1080 __asm__
__volatile__( "fldcw %0" : : "m" (fpword
) );
1085 if (!sse2_cw
) return 1;
1089 __asm__
__volatile__( "stmxcsr %0" : "=m" (fpword
) );
1091 /* Convert into mask constants */
1093 if (fpword
& 0x80) flags
|= MSVCRT__EM_INVALID
;
1094 if (fpword
& 0x100) flags
|= MSVCRT__EM_DENORMAL
;
1095 if (fpword
& 0x200) flags
|= MSVCRT__EM_ZERODIVIDE
;
1096 if (fpword
& 0x400) flags
|= MSVCRT__EM_OVERFLOW
;
1097 if (fpword
& 0x800) flags
|= MSVCRT__EM_UNDERFLOW
;
1098 if (fpword
& 0x1000) flags
|= MSVCRT__EM_INEXACT
;
1099 switch (fpword
& 0x6000)
1101 case 0x6000: flags
|= MSVCRT__RC_UP
|MSVCRT__RC_DOWN
; break;
1102 case 0x4000: flags
|= MSVCRT__RC_UP
; break;
1103 case 0x2000: flags
|= MSVCRT__RC_DOWN
; break;
1105 switch (fpword
& 0x8040)
1107 case 0x0040: flags
|= MSVCRT__DN_FLUSH_OPERANDS_SAVE_RESULTS
; break;
1108 case 0x8000: flags
|= MSVCRT__DN_SAVE_OPERANDS_FLUSH_RESULTS
; break;
1109 case 0x8040: flags
|= MSVCRT__DN_FLUSH
; break;
1112 TRACE( "sse2 flags=%08x newval=%08x mask=%08x\n", flags
, newval
, mask
);
1115 flags
= (flags
& ~mask
) | (newval
& mask
);
1117 /* Convert (masked) value back to fp word */
1119 if (flags
& MSVCRT__EM_INVALID
) fpword
|= 0x80;
1120 if (flags
& MSVCRT__EM_DENORMAL
) fpword
|= 0x100;
1121 if (flags
& MSVCRT__EM_ZERODIVIDE
) fpword
|= 0x200;
1122 if (flags
& MSVCRT__EM_OVERFLOW
) fpword
|= 0x400;
1123 if (flags
& MSVCRT__EM_UNDERFLOW
) fpword
|= 0x800;
1124 if (flags
& MSVCRT__EM_INEXACT
) fpword
|= 0x1000;
1125 switch (flags
& MSVCRT__MCW_RC
)
1127 case MSVCRT__RC_UP
|MSVCRT__RC_DOWN
: fpword
|= 0x6000; break;
1128 case MSVCRT__RC_UP
: fpword
|= 0x4000; break;
1129 case MSVCRT__RC_DOWN
: fpword
|= 0x2000; break;
1131 switch (flags
& MSVCRT__MCW_DN
)
1133 case MSVCRT__DN_FLUSH_OPERANDS_SAVE_RESULTS
: fpword
|= 0x0040; break;
1134 case MSVCRT__DN_SAVE_OPERANDS_FLUSH_RESULTS
: fpword
|= 0x8000; break;
1135 case MSVCRT__DN_FLUSH
: fpword
|= 0x8040; break;
1137 __asm__
__volatile__( "ldmxcsr %0" : : "m" (fpword
) );
1145 FIXME( "not implemented\n" );
1151 /*********************************************************************
1152 * _control87 (MSVCRT.@)
1154 unsigned int CDECL
_control87(unsigned int newval
, unsigned int mask
)
1156 #if defined(__i386__) || defined(__x86_64__)
1157 unsigned int x86_cw
, sse2_cw
;
1159 __control87_2( newval
, mask
, &x86_cw
, &sse2_cw
);
1161 if ((x86_cw
^ sse2_cw
) & (MSVCRT__MCW_EM
| MSVCRT__MCW_RC
)) x86_cw
|= MSVCRT__EM_AMBIGUOUS
;
1164 FIXME( "not implemented\n" );
1169 /*********************************************************************
1170 * _controlfp (MSVCRT.@)
1172 unsigned int CDECL
_controlfp(unsigned int newval
, unsigned int mask
)
1174 return _control87( newval
, mask
& ~MSVCRT__EM_DENORMAL
);
1177 /*********************************************************************
1178 * _set_controlfp (MSVCRT.@)
1180 void CDECL
_set_controlfp( unsigned int newval
, unsigned int mask
)
1182 _controlfp( newval
, mask
);
1185 /*********************************************************************
1186 * _controlfp_s (MSVCRT.@)
1188 int CDECL
_controlfp_s(unsigned int *cur
, unsigned int newval
, unsigned int mask
)
1190 static const unsigned int all_flags
= (MSVCRT__MCW_EM
| MSVCRT__MCW_IC
| MSVCRT__MCW_RC
|
1191 MSVCRT__MCW_PC
| MSVCRT__MCW_DN
);
1194 if (!MSVCRT_CHECK_PMT( !(newval
& mask
& ~all_flags
) ))
1196 if (cur
) *cur
= _controlfp( 0, 0 ); /* retrieve it anyway */
1197 return MSVCRT_EINVAL
;
1199 val
= _controlfp( newval
, mask
);
1200 if (cur
) *cur
= val
;
1204 /*********************************************************************
1205 * _copysign (MSVCRT.@)
1207 double CDECL
MSVCRT__copysign(double num
, double sign
)
1209 /* FIXME: Behaviour for Nan/Inf? */
1211 return num
< 0.0 ? num
: -num
;
1212 return num
< 0.0 ? -num
: num
;
1215 /*********************************************************************
1216 * _finite (MSVCRT.@)
1218 int CDECL
MSVCRT__finite(double num
)
1220 return isfinite(num
) != 0; /* See comment for _isnan() */
1223 /*********************************************************************
1224 * _fpreset (MSVCRT.@)
1226 void CDECL
_fpreset(void)
1228 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
1229 const unsigned int x86_cw
= 0x27f;
1230 __asm__
__volatile__( "fninit; fldcw %0" : : "m" (x86_cw
) );
1233 const unsigned long sse2_cw
= 0x1f80;
1234 __asm__
__volatile__( "ldmxcsr %0" : : "m" (sse2_cw
) );
1237 FIXME( "not implemented\n" );
1241 /*********************************************************************
1244 INT CDECL
MSVCRT__isnan(double num
)
1246 /* Some implementations return -1 for true(glibc), msvcrt/crtdll return 1.
1247 * Do the same, as the result may be used in calculations
1249 return isnan(num
) != 0;
1252 /*********************************************************************
1255 double CDECL
MSVCRT__j0(double num
)
1257 /* FIXME: errno handling */
1261 /*********************************************************************
1264 double CDECL
MSVCRT__j1(double num
)
1266 /* FIXME: errno handling */
1270 /*********************************************************************
1273 double CDECL
MSVCRT__jn(int n
, double num
)
1275 /* FIXME: errno handling */
1279 /*********************************************************************
1282 double CDECL
MSVCRT__y0(double num
)
1285 if (!isfinite(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
1287 if (MSVCRT__fpclass(retval
) == MSVCRT__FPCLASS_NINF
)
1289 *MSVCRT__errno() = MSVCRT_EDOM
;
1295 /*********************************************************************
1298 double CDECL
MSVCRT__y1(double num
)
1301 if (!isfinite(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
1303 if (MSVCRT__fpclass(retval
) == MSVCRT__FPCLASS_NINF
)
1305 *MSVCRT__errno() = MSVCRT_EDOM
;
1311 /*********************************************************************
1314 double CDECL
MSVCRT__yn(int order
, double num
)
1317 if (!isfinite(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
1318 retval
= yn(order
,num
);
1319 if (MSVCRT__fpclass(retval
) == MSVCRT__FPCLASS_NINF
)
1321 *MSVCRT__errno() = MSVCRT_EDOM
;
1327 /*********************************************************************
1328 * _nextafter (MSVCRT.@)
1330 double CDECL
MSVCRT__nextafter(double num
, double next
)
1333 if (!isfinite(num
) || !isfinite(next
)) *MSVCRT__errno() = MSVCRT_EDOM
;
1334 retval
= nextafter(num
,next
);
1338 /*********************************************************************
1341 char * CDECL
_ecvt( double number
, int ndigits
, int *decpt
, int *sign
)
1344 thread_data_t
*data
= msvcrt_get_thread_data();
1345 /* FIXME: check better for overflow (native supports over 300 chars) */
1346 ndigits
= min( ndigits
, 80 - 7); /* 7 : space for dec point, 1 for "e",
1347 * 4 for exponent and one for
1348 * terminating '\0' */
1349 if (!data
->efcvt_buffer
)
1350 data
->efcvt_buffer
= MSVCRT_malloc( 80 ); /* ought to be enough */
1357 /* handle cases with zero ndigits or less */
1359 if( prec
< 1) prec
= 2;
1360 len
= snprintf(data
->efcvt_buffer
, 80, "%.*le", prec
- 1, number
);
1361 /* take the decimal "point away */
1363 memmove( data
->efcvt_buffer
+ 1, data
->efcvt_buffer
+ 2, len
- 1 );
1364 /* take the exponential "e" out */
1365 data
->efcvt_buffer
[ prec
] = '\0';
1366 /* read the exponent */
1367 sscanf( data
->efcvt_buffer
+ prec
+ 1, "%d", decpt
);
1369 /* adjust for some border cases */
1370 if( data
->efcvt_buffer
[0] == '0')/* value is zero */
1372 /* handle cases with zero ndigits or less */
1374 if( data
->efcvt_buffer
[ 0] >= '5')
1376 data
->efcvt_buffer
[ 0] = '\0';
1378 TRACE("out=\"%s\"\n",data
->efcvt_buffer
);
1379 return data
->efcvt_buffer
;
1382 /*********************************************************************
1383 * _ecvt_s (MSVCRT.@)
1385 int CDECL
_ecvt_s( char *buffer
, MSVCRT_size_t length
, double number
, int ndigits
, int *decpt
, int *sign
)
1389 const char infret
[] = "1#INF";
1391 if (!MSVCRT_CHECK_PMT(buffer
!= NULL
)) return MSVCRT_EINVAL
;
1392 if (!MSVCRT_CHECK_PMT(decpt
!= NULL
)) return MSVCRT_EINVAL
;
1393 if (!MSVCRT_CHECK_PMT(sign
!= NULL
)) return MSVCRT_EINVAL
;
1394 if (!MSVCRT_CHECK_PMT_ERR( length
> 2, MSVCRT_ERANGE
)) return MSVCRT_ERANGE
;
1395 if (!MSVCRT_CHECK_PMT_ERR(ndigits
< (int)length
- 1, MSVCRT_ERANGE
)) return MSVCRT_ERANGE
;
1397 /* special case - inf */
1398 if(number
== HUGE_VAL
|| number
== -HUGE_VAL
)
1400 memset(buffer
, '0', ndigits
);
1401 memcpy(buffer
, infret
, min(ndigits
, sizeof(infret
) - 1 ) );
1402 buffer
[ndigits
] = '\0';
1404 if(number
== -HUGE_VAL
)
1410 /* handle cases with zero ndigits or less */
1412 if( prec
< 1) prec
= 2;
1413 result
= MSVCRT_malloc(prec
+ 7);
1420 len
= snprintf(result
, prec
+ 7, "%.*le", prec
- 1, number
);
1421 /* take the decimal "point away */
1423 memmove( result
+ 1, result
+ 2, len
- 1 );
1424 /* take the exponential "e" out */
1425 result
[ prec
] = '\0';
1426 /* read the exponent */
1427 sscanf( result
+ prec
+ 1, "%d", decpt
);
1429 /* adjust for some border cases */
1430 if( result
[0] == '0')/* value is zero */
1432 /* handle cases with zero ndigits or less */
1434 if( result
[ 0] >= '5')
1438 memcpy( buffer
, result
, max(ndigits
+ 1, 1) );
1439 MSVCRT_free( result
);
1443 /***********************************************************************
1446 char * CDECL
_fcvt( double number
, int ndigits
, int *decpt
, int *sign
)
1448 thread_data_t
*data
= msvcrt_get_thread_data();
1449 int stop
, dec1
, dec2
;
1450 char *ptr1
, *ptr2
, *first
;
1451 char buf
[80]; /* ought to be enough */
1453 if (!data
->efcvt_buffer
)
1454 data
->efcvt_buffer
= MSVCRT_malloc( 80 ); /* ought to be enough */
1462 snprintf(buf
, 80, "%.*f", ndigits
< 0 ? 0 : ndigits
, number
);
1464 ptr2
= data
->efcvt_buffer
;
1469 /* For numbers below the requested resolution, work out where
1470 the decimal point will be rather than finding it in the string */
1471 if (number
< 1.0 && number
> 0.0) {
1472 dec2
= log10(number
+ 1e-10);
1473 if (-dec2
<= ndigits
) dec2
= 0;
1476 /* If requested digits is zero or less, we will need to truncate
1477 * the returned string */
1479 stop
= strlen(buf
) + ndigits
;
1484 while (*ptr1
== '0') ptr1
++; /* Skip leading zeroes */
1485 while (*ptr1
!= '\0' && *ptr1
!= '.') {
1486 if (!first
) first
= ptr2
;
1487 if ((ptr1
- buf
) < stop
) {
1498 while (*ptr1
== '0') { /* Process leading zeroes */
1503 while (*ptr1
!= '\0') {
1504 if (!first
) first
= ptr2
;
1511 /* We never found a non-zero digit, then our number is either
1512 * smaller than the requested precision, or 0.0 */
1517 first
= data
->efcvt_buffer
;
1522 *decpt
= dec2
? dec2
: dec1
;
1526 /***********************************************************************
1527 * _fcvt_s (MSVCRT.@)
1529 int CDECL
_fcvt_s(char* outbuffer
, MSVCRT_size_t size
, double number
, int ndigits
, int *decpt
, int *sign
)
1531 int stop
, dec1
, dec2
;
1532 char *ptr1
, *ptr2
, *first
;
1533 char buf
[80]; /* ought to be enough */
1535 if (!outbuffer
|| !decpt
|| !sign
|| size
== 0)
1537 *MSVCRT__errno() = MSVCRT_EINVAL
;
1538 return MSVCRT_EINVAL
;
1547 snprintf(buf
, 80, "%.*f", ndigits
< 0 ? 0 : ndigits
, number
);
1554 /* For numbers below the requested resolution, work out where
1555 the decimal point will be rather than finding it in the string */
1556 if (number
< 1.0 && number
> 0.0) {
1557 dec2
= log10(number
+ 1e-10);
1558 if (-dec2
<= ndigits
) dec2
= 0;
1561 /* If requested digits is zero or less, we will need to truncate
1562 * the returned string */
1564 stop
= strlen(buf
) + ndigits
;
1569 while (*ptr1
== '0') ptr1
++; /* Skip leading zeroes */
1570 while (*ptr1
!= '\0' && *ptr1
!= '.') {
1571 if (!first
) first
= ptr2
;
1572 if ((ptr1
- buf
) < stop
) {
1586 while (*ptr1
== '0') { /* Process leading zeroes */
1587 if (number
== 0.0 && size
> 1) {
1595 while (*ptr1
!= '\0') {
1596 if (!first
) first
= ptr2
;
1606 /* We never found a non-zero digit, then our number is either
1607 * smaller than the requested precision, or 0.0 */
1608 if (!first
&& (number
<= 0.0))
1611 *decpt
= dec2
? dec2
: dec1
;
1615 /***********************************************************************
1618 char * CDECL
_gcvt( double number
, int ndigit
, char *buff
)
1621 *MSVCRT__errno() = MSVCRT_EINVAL
;
1626 *MSVCRT__errno() = MSVCRT_ERANGE
;
1630 MSVCRT_sprintf(buff
, "%.*g", ndigit
, number
);
1634 /***********************************************************************
1635 * _gcvt_s (MSVCRT.@)
1637 int CDECL
_gcvt_s(char *buff
, MSVCRT_size_t size
, double number
, int digits
)
1642 *MSVCRT__errno() = MSVCRT_EINVAL
;
1643 return MSVCRT_EINVAL
;
1646 if( digits
<0 || digits
>=size
) {
1650 *MSVCRT__errno() = MSVCRT_ERANGE
;
1651 return MSVCRT_ERANGE
;
1654 len
= MSVCRT__scprintf("%.*g", digits
, number
);
1657 *MSVCRT__errno() = MSVCRT_ERANGE
;
1658 return MSVCRT_ERANGE
;
1661 MSVCRT_sprintf(buff
, "%.*g", digits
, number
);
1665 #include <stdlib.h> /* div_t, ldiv_t */
1667 /*********************************************************************
1670 * [i386] Windows binary compatible - returns the struct in eax/edx.
1673 unsigned __int64 CDECL
MSVCRT_div(int num
, int denom
)
1675 div_t dt
= div(num
,denom
);
1676 return ((unsigned __int64
)dt
.rem
<< 32) | (unsigned int)dt
.quot
;
1679 /*********************************************************************
1682 * [!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
1684 MSVCRT_div_t CDECL
MSVCRT_div(int num
, int denom
)
1686 div_t dt
= div(num
,denom
);
1694 #endif /* ifdef __i386__ */
1697 /*********************************************************************
1700 * [i386] Windows binary compatible - returns the struct in eax/edx.
1703 unsigned __int64 CDECL
MSVCRT_ldiv(MSVCRT_long num
, MSVCRT_long denom
)
1705 ldiv_t ldt
= ldiv(num
,denom
);
1706 return ((unsigned __int64
)ldt
.rem
<< 32) | (MSVCRT_ulong
)ldt
.quot
;
1709 /*********************************************************************
1712 * [!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
1714 MSVCRT_ldiv_t CDECL
MSVCRT_ldiv(MSVCRT_long num
, MSVCRT_long denom
)
1716 ldiv_t result
= ldiv(num
,denom
);
1719 ret
.quot
= result
.quot
;
1720 ret
.rem
= result
.rem
;
1724 #endif /* ifdef __i386__ */
1728 /*********************************************************************
1729 * _adjust_fdiv (MSVCRT.@)
1730 * Used by the MSVC compiler to work around the Pentium FDIV bug.
1732 int MSVCRT__adjust_fdiv
= 0;
1734 /***********************************************************************
1735 * _adj_fdiv_m16i (MSVCRT.@)
1738 * I _think_ this function is intended to work around the Pentium
1741 void __stdcall
_adj_fdiv_m16i( short arg
)
1743 TRACE("(): stub\n");
1746 /***********************************************************************
1747 * _adj_fdiv_m32 (MSVCRT.@)
1750 * I _think_ this function is intended to work around the Pentium
1753 void __stdcall
_adj_fdiv_m32( unsigned int arg
)
1755 TRACE("(): stub\n");
1758 /***********************************************************************
1759 * _adj_fdiv_m32i (MSVCRT.@)
1762 * I _think_ this function is intended to work around the Pentium
1765 void __stdcall
_adj_fdiv_m32i( int arg
)
1767 TRACE("(): stub\n");
1770 /***********************************************************************
1771 * _adj_fdiv_m64 (MSVCRT.@)
1774 * I _think_ this function is intended to work around the Pentium
1777 void __stdcall
_adj_fdiv_m64( unsigned __int64 arg
)
1779 TRACE("(): stub\n");
1782 /***********************************************************************
1783 * _adj_fdiv_r (MSVCRT.@)
1785 * This function is likely to have the wrong number of arguments.
1788 * I _think_ this function is intended to work around the Pentium
1791 void _adj_fdiv_r(void)
1793 TRACE("(): stub\n");
1796 /***********************************************************************
1797 * _adj_fdivr_m16i (MSVCRT.@)
1800 * I _think_ this function is intended to work around the Pentium
1803 void __stdcall
_adj_fdivr_m16i( short arg
)
1805 TRACE("(): stub\n");
1808 /***********************************************************************
1809 * _adj_fdivr_m32 (MSVCRT.@)
1812 * I _think_ this function is intended to work around the Pentium
1815 void __stdcall
_adj_fdivr_m32( unsigned int arg
)
1817 TRACE("(): stub\n");
1820 /***********************************************************************
1821 * _adj_fdivr_m32i (MSVCRT.@)
1824 * I _think_ this function is intended to work around the Pentium
1827 void __stdcall
_adj_fdivr_m32i( int arg
)
1829 TRACE("(): stub\n");
1832 /***********************************************************************
1833 * _adj_fdivr_m64 (MSVCRT.@)
1836 * I _think_ this function is intended to work around the Pentium
1839 void __stdcall
_adj_fdivr_m64( unsigned __int64 arg
)
1841 TRACE("(): stub\n");
1844 /***********************************************************************
1845 * _adj_fpatan (MSVCRT.@)
1847 * This function is likely to have the wrong number of arguments.
1850 * I _think_ this function is intended to work around the Pentium
1853 void _adj_fpatan(void)
1855 TRACE("(): stub\n");
1858 /***********************************************************************
1859 * _adj_fprem (MSVCRT.@)
1861 * This function is likely to have the wrong number of arguments.
1864 * I _think_ this function is intended to work around the Pentium
1867 void _adj_fprem(void)
1869 TRACE("(): stub\n");
1872 /***********************************************************************
1873 * _adj_fprem1 (MSVCRT.@)
1875 * This function is likely to have the wrong number of arguments.
1878 * I _think_ this function is intended to work around the Pentium
1881 void _adj_fprem1(void)
1883 TRACE("(): stub\n");
1886 /***********************************************************************
1887 * _adj_fptan (MSVCRT.@)
1889 * This function is likely to have the wrong number of arguments.
1892 * I _think_ this function is intended to work around the Pentium
1895 void _adj_fptan(void)
1897 TRACE("(): stub\n");
1900 /***********************************************************************
1901 * _safe_fdiv (MSVCRT.@)
1903 * This function is likely to have the wrong number of arguments.
1906 * I _think_ this function is intended to work around the Pentium
1909 void _safe_fdiv(void)
1911 TRACE("(): stub\n");
1914 /***********************************************************************
1915 * _safe_fdivr (MSVCRT.@)
1917 * This function is likely to have the wrong number of arguments.
1920 * I _think_ this function is intended to work around the Pentium
1923 void _safe_fdivr(void)
1925 TRACE("(): stub\n");
1928 /***********************************************************************
1929 * _safe_fprem (MSVCRT.@)
1931 * This function is likely to have the wrong number of arguments.
1934 * I _think_ this function is intended to work around the Pentium
1937 void _safe_fprem(void)
1939 TRACE("(): stub\n");
1942 /***********************************************************************
1943 * _safe_fprem1 (MSVCRT.@)
1946 * This function is likely to have the wrong number of arguments.
1949 * I _think_ this function is intended to work around the Pentium
1952 void _safe_fprem1(void)
1954 TRACE("(): stub\n");
1957 /***********************************************************************
1958 * __libm_sse2_acos (MSVCRT.@)
1960 void __cdecl
__libm_sse2_acos(void)
1963 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
1965 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
1968 /***********************************************************************
1969 * __libm_sse2_acosf (MSVCRT.@)
1971 void __cdecl
__libm_sse2_acosf(void)
1974 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
1976 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
1979 /***********************************************************************
1980 * __libm_sse2_asin (MSVCRT.@)
1982 void __cdecl
__libm_sse2_asin(void)
1985 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
1987 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
1990 /***********************************************************************
1991 * __libm_sse2_asinf (MSVCRT.@)
1993 void __cdecl
__libm_sse2_asinf(void)
1996 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
1998 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2001 /***********************************************************************
2002 * __libm_sse2_atan (MSVCRT.@)
2004 void __cdecl
__libm_sse2_atan(void)
2007 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2009 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2012 /***********************************************************************
2013 * __libm_sse2_atan2 (MSVCRT.@)
2015 void __cdecl
__libm_sse2_atan2(void)
2018 __asm__
__volatile__( "movq %%xmm0,%0; movq %%xmm1,%1 " : "=m" (d1
), "=m" (d2
) );
2019 d1
= atan2( d1
, d2
);
2020 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d1
) );
2023 /***********************************************************************
2024 * __libm_sse2_atanf (MSVCRT.@)
2026 void __cdecl
__libm_sse2_atanf(void)
2029 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2031 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2034 /***********************************************************************
2035 * __libm_sse2_cos (MSVCRT.@)
2037 void __cdecl
__libm_sse2_cos(void)
2040 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2042 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2045 /***********************************************************************
2046 * __libm_sse2_cosf (MSVCRT.@)
2048 void __cdecl
__libm_sse2_cosf(void)
2051 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2053 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2056 /***********************************************************************
2057 * __libm_sse2_exp (MSVCRT.@)
2059 void __cdecl
__libm_sse2_exp(void)
2062 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2064 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2067 /***********************************************************************
2068 * __libm_sse2_expf (MSVCRT.@)
2070 void __cdecl
__libm_sse2_expf(void)
2073 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2075 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2078 /***********************************************************************
2079 * __libm_sse2_log (MSVCRT.@)
2081 void __cdecl
__libm_sse2_log(void)
2084 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2086 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2089 /***********************************************************************
2090 * __libm_sse2_log10 (MSVCRT.@)
2092 void __cdecl
__libm_sse2_log10(void)
2095 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2097 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2100 /***********************************************************************
2101 * __libm_sse2_log10f (MSVCRT.@)
2103 void __cdecl
__libm_sse2_log10f(void)
2106 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2108 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2111 /***********************************************************************
2112 * __libm_sse2_logf (MSVCRT.@)
2114 void __cdecl
__libm_sse2_logf(void)
2117 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2119 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2122 /***********************************************************************
2123 * __libm_sse2_pow (MSVCRT.@)
2125 void __cdecl
__libm_sse2_pow(void)
2128 __asm__
__volatile__( "movq %%xmm0,%0; movq %%xmm1,%1 " : "=m" (d1
), "=m" (d2
) );
2130 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d1
) );
2133 /***********************************************************************
2134 * __libm_sse2_powf (MSVCRT.@)
2136 void __cdecl
__libm_sse2_powf(void)
2139 __asm__
__volatile__( "movd %%xmm0,%0; movd %%xmm1,%1" : "=g" (f1
), "=g" (f2
) );
2140 f1
= powf( f1
, f2
);
2141 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f1
) );
2144 /***********************************************************************
2145 * __libm_sse2_sin (MSVCRT.@)
2147 void __cdecl
__libm_sse2_sin(void)
2150 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2152 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2155 /***********************************************************************
2156 * __libm_sse2_sinf (MSVCRT.@)
2158 void __cdecl
__libm_sse2_sinf(void)
2161 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2163 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2166 /***********************************************************************
2167 * __libm_sse2_tan (MSVCRT.@)
2169 void __cdecl
__libm_sse2_tan(void)
2172 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2174 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2177 /***********************************************************************
2178 * __libm_sse2_tanf (MSVCRT.@)
2180 void __cdecl
__libm_sse2_tanf(void)
2183 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2185 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2188 #endif /* __i386__ */