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
23 #define __USE_ISOC9X 1
24 #define __USE_ISOC99 1
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt
);
37 #ifndef finite /* Could be a macro */
39 #define finite(x) isfinite(x)
41 #define finite(x) (!isnan(x)) /* At least catch some cases */
50 typedef int (CDECL
*MSVCRT_matherr_func
)(struct MSVCRT__exception
*);
52 static MSVCRT_matherr_func MSVCRT_default_matherr_func
= NULL
;
54 static BOOL sse2_supported
;
55 static BOOL sse2_enabled
;
57 void msvcrt_init_math(void)
59 sse2_supported
= sse2_enabled
= IsProcessorFeaturePresent( PF_XMMI64_INSTRUCTIONS_AVAILABLE
);
62 /*********************************************************************
63 * _set_SSE2_enable (MSVCRT.@)
65 int CDECL
MSVCRT__set_SSE2_enable(int flag
)
67 sse2_enabled
= flag
&& sse2_supported
;
71 #if defined(__x86_64__) || defined(__arm__)
73 /*********************************************************************
74 * _chgsignf (MSVCRT.@)
76 float CDECL
MSVCRT__chgsignf( float num
)
78 /* FIXME: +-infinity,Nan not tested */
82 /*********************************************************************
83 * _copysignf (MSVCRT.@)
85 float CDECL
MSVCRT__copysignf( float num
, float sign
)
87 /* FIXME: Behaviour for Nan/Inf? */
89 return num
< 0.0 ? num
: -num
;
90 return num
< 0.0 ? -num
: num
;
93 /*********************************************************************
96 int CDECL
MSVCRT__finitef( float num
)
98 return finitef(num
) != 0; /* See comment for _isnan() */
101 /*********************************************************************
104 INT CDECL
MSVCRT__isnanf( float num
)
106 /* Some implementations return -1 for true(glibc), msvcrt/crtdll return 1.
107 * Do the same, as the result may be used in calculations
109 return isnanf(num
) != 0;
112 /*********************************************************************
115 float CDECL
MSVCRT__logbf( float num
)
117 if (!finitef(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
121 /*********************************************************************
122 * _nextafterf (MSVCRT.@)
124 float CDECL
MSVCRT__nextafterf( float num
, float next
)
126 if (!finitef(num
) || !finitef(next
)) *MSVCRT__errno() = MSVCRT_EDOM
;
127 return nextafterf( num
, next
);
130 /*********************************************************************
131 * MSVCRT_acosf (MSVCRT.@)
133 float CDECL
MSVCRT_acosf( float x
)
135 if (x
< -1.0 || x
> 1.0 || !finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
136 /* glibc implements acos() as the FPU equivalent of atan2(sqrt(1 - x ^ 2), x).
137 * asin() uses a similar construction. This is bad because as x gets nearer to
138 * 1 the error in the expression "1 - x^2" can get relatively large due to
139 * cancellation. The sqrt() makes things worse. A safer way to calculate
140 * acos() is to use atan2(sqrt((1 - x) * (1 + x)), x). */
141 return atan2f(sqrtf((1 - x
) * (1 + x
)), x
);
144 /*********************************************************************
145 * MSVCRT_asinf (MSVCRT.@)
147 float CDECL
MSVCRT_asinf( float x
)
149 if (x
< -1.0 || x
> 1.0 || !finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
150 return atan2f(x
, sqrtf((1 - x
) * (1 + x
)));
153 /*********************************************************************
154 * MSVCRT_atanf (MSVCRT.@)
156 float CDECL
MSVCRT_atanf( float x
)
158 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
162 /*********************************************************************
163 * MSVCRT_atan2f (MSVCRT.@)
165 float CDECL
MSVCRT_atan2f( float x
, float y
)
167 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
171 /*********************************************************************
172 * MSVCRT_cosf (MSVCRT.@)
174 float CDECL
MSVCRT_cosf( float x
)
176 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
180 /*********************************************************************
181 * MSVCRT_coshf (MSVCRT.@)
183 float CDECL
MSVCRT_coshf( float x
)
185 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
189 /*********************************************************************
190 * MSVCRT_expf (MSVCRT.@)
192 float CDECL
MSVCRT_expf( float x
)
194 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
198 /*********************************************************************
199 * MSVCRT_fmodf (MSVCRT.@)
201 float CDECL
MSVCRT_fmodf( float x
, float y
)
203 if (!finitef(x
) || !finitef(y
)) *MSVCRT__errno() = MSVCRT_EDOM
;
207 /*********************************************************************
208 * MSVCRT_logf (MSVCRT.@)
210 float CDECL
MSVCRT_logf( float x
)
212 if (x
< 0.0 || !finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
213 if (x
== 0.0) *MSVCRT__errno() = MSVCRT_ERANGE
;
217 /*********************************************************************
218 * MSVCRT_log10f (MSVCRT.@)
220 float CDECL
MSVCRT_log10f( float x
)
222 if (x
< 0.0 || !finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
223 if (x
== 0.0) *MSVCRT__errno() = MSVCRT_ERANGE
;
227 /*********************************************************************
228 * MSVCRT_powf (MSVCRT.@)
230 float CDECL
MSVCRT_powf( float x
, float y
)
232 /* FIXME: If x < 0 and y is not integral, set EDOM */
234 if (!finitef(z
)) *MSVCRT__errno() = MSVCRT_EDOM
;
238 /*********************************************************************
239 * MSVCRT_sinf (MSVCRT.@)
241 float CDECL
MSVCRT_sinf( float x
)
243 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
247 /*********************************************************************
248 * MSVCRT_sinhf (MSVCRT.@)
250 float CDECL
MSVCRT_sinhf( float x
)
252 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
256 /*********************************************************************
257 * MSVCRT_sqrtf (MSVCRT.@)
259 float CDECL
MSVCRT_sqrtf( float x
)
261 if (x
< 0.0 || !finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
265 /*********************************************************************
266 * MSVCRT_tanf (MSVCRT.@)
268 float CDECL
MSVCRT_tanf( float x
)
270 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
274 /*********************************************************************
275 * MSVCRT_tanhf (MSVCRT.@)
277 float CDECL
MSVCRT_tanhf( float x
)
279 if (!finitef(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
283 /*********************************************************************
286 float CDECL
MSVCRT_ceilf( float x
)
291 /*********************************************************************
294 float CDECL
MSVCRT_fabsf( float x
)
299 /*********************************************************************
302 float CDECL
MSVCRT_floorf( float x
)
307 /*********************************************************************
310 float CDECL
MSVCRT_frexpf( float x
, int *exp
)
312 return frexpf( x
, exp
);
315 /*********************************************************************
318 float CDECL
MSVCRT__scalbf(float num
, MSVCRT_long power
)
320 if (!finitef(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
321 return ldexpf(num
, power
);
324 /*********************************************************************
327 double CDECL
MSVCRT_modff( float x
, float *iptr
)
329 return modff( x
, iptr
);
334 /*********************************************************************
335 * MSVCRT_acos (MSVCRT.@)
337 double CDECL
MSVCRT_acos( double x
)
339 if (x
< -1.0 || x
> 1.0 || !finite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
340 /* glibc implements acos() as the FPU equivalent of atan2(sqrt(1 - x ^ 2), x).
341 * asin() uses a similar construction. This is bad because as x gets nearer to
342 * 1 the error in the expression "1 - x^2" can get relatively large due to
343 * cancellation. The sqrt() makes things worse. A safer way to calculate
344 * acos() is to use atan2(sqrt((1 - x) * (1 + x)), x). */
345 return atan2(sqrt((1 - x
) * (1 + x
)), x
);
348 /*********************************************************************
349 * MSVCRT_asin (MSVCRT.@)
351 double CDECL
MSVCRT_asin( double x
)
353 if (x
< -1.0 || x
> 1.0 || !finite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
354 return atan2(x
, sqrt((1 - x
) * (1 + x
)));
357 /*********************************************************************
358 * MSVCRT_atan (MSVCRT.@)
360 double CDECL
MSVCRT_atan( double x
)
362 if (!finite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
366 /*********************************************************************
367 * MSVCRT_atan2 (MSVCRT.@)
369 double CDECL
MSVCRT_atan2( double x
, double y
)
371 if (!finite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
375 /*********************************************************************
376 * MSVCRT_cos (MSVCRT.@)
378 double CDECL
MSVCRT_cos( double x
)
380 if (!finite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
384 /*********************************************************************
385 * MSVCRT_cosh (MSVCRT.@)
387 double CDECL
MSVCRT_cosh( double x
)
389 if (!finite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
393 /*********************************************************************
394 * MSVCRT_exp (MSVCRT.@)
396 double CDECL
MSVCRT_exp( double x
)
398 if (!finite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
402 /*********************************************************************
403 * MSVCRT_fmod (MSVCRT.@)
405 double CDECL
MSVCRT_fmod( double x
, double y
)
407 if (!finite(x
) || !finite(y
)) *MSVCRT__errno() = MSVCRT_EDOM
;
411 /*********************************************************************
412 * MSVCRT_log (MSVCRT.@)
414 double CDECL
MSVCRT_log( double x
)
416 if (x
< 0.0 || !finite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
417 if (x
== 0.0) *MSVCRT__errno() = MSVCRT_ERANGE
;
421 /*********************************************************************
422 * MSVCRT_log10 (MSVCRT.@)
424 double CDECL
MSVCRT_log10( double x
)
426 if (x
< 0.0 || !finite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
427 if (x
== 0.0) *MSVCRT__errno() = MSVCRT_ERANGE
;
431 /*********************************************************************
432 * MSVCRT_pow (MSVCRT.@)
434 double CDECL
MSVCRT_pow( double x
, double y
)
436 /* FIXME: If x < 0 and y is not integral, set EDOM */
438 if (!finite(z
)) *MSVCRT__errno() = MSVCRT_EDOM
;
442 /*********************************************************************
443 * MSVCRT_sin (MSVCRT.@)
445 double CDECL
MSVCRT_sin( double x
)
447 if (!finite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
451 /*********************************************************************
452 * MSVCRT_sinh (MSVCRT.@)
454 double CDECL
MSVCRT_sinh( double x
)
456 if (!finite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
460 /*********************************************************************
461 * MSVCRT_sqrt (MSVCRT.@)
463 double CDECL
MSVCRT_sqrt( double x
)
465 if (x
< 0.0 || !finite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
469 /*********************************************************************
470 * MSVCRT_tan (MSVCRT.@)
472 double CDECL
MSVCRT_tan( double x
)
474 if (!finite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
478 /*********************************************************************
479 * MSVCRT_tanh (MSVCRT.@)
481 double CDECL
MSVCRT_tanh( double x
)
483 if (!finite(x
)) *MSVCRT__errno() = MSVCRT_EDOM
;
488 #if defined(__GNUC__) && defined(__i386__)
490 #define FPU_DOUBLE(var) double var; \
491 __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var) : )
492 #define FPU_DOUBLES(var1,var2) double var1,var2; \
493 __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var2) : ); \
494 __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var1) : )
496 /*********************************************************************
499 double CDECL
_CIacos(void)
502 return MSVCRT_acos(x
);
505 /*********************************************************************
508 double CDECL
_CIasin(void)
511 return MSVCRT_asin(x
);
514 /*********************************************************************
517 double CDECL
_CIatan(void)
520 return MSVCRT_atan(x
);
523 /*********************************************************************
524 * _CIatan2 (MSVCRT.@)
526 double CDECL
_CIatan2(void)
529 return MSVCRT_atan2(x
,y
);
532 /*********************************************************************
535 double CDECL
_CIcos(void)
538 return MSVCRT_cos(x
);
541 /*********************************************************************
544 double CDECL
_CIcosh(void)
547 return MSVCRT_cosh(x
);
550 /*********************************************************************
553 double CDECL
_CIexp(void)
556 return MSVCRT_exp(x
);
559 /*********************************************************************
562 double CDECL
_CIfmod(void)
565 return MSVCRT_fmod(x
,y
);
568 /*********************************************************************
571 double CDECL
_CIlog(void)
574 return MSVCRT_log(x
);
577 /*********************************************************************
578 * _CIlog10 (MSVCRT.@)
580 double CDECL
_CIlog10(void)
583 return MSVCRT_log10(x
);
586 /*********************************************************************
589 double CDECL
_CIpow(void)
592 return MSVCRT_pow(x
,y
);
595 /*********************************************************************
598 double CDECL
_CIsin(void)
601 return MSVCRT_sin(x
);
604 /*********************************************************************
607 double CDECL
_CIsinh(void)
610 return MSVCRT_sinh(x
);
613 /*********************************************************************
616 double CDECL
_CIsqrt(void)
619 return MSVCRT_sqrt(x
);
622 /*********************************************************************
625 double CDECL
_CItan(void)
628 return MSVCRT_tan(x
);
631 /*********************************************************************
634 double CDECL
_CItanh(void)
637 return MSVCRT_tanh(x
);
640 /*********************************************************************
643 LONGLONG CDECL
MSVCRT__ftol(void)
649 #endif /* defined(__GNUC__) && defined(__i386__) */
651 /*********************************************************************
652 * _fpclass (MSVCRT.@)
654 int CDECL
MSVCRT__fpclass(double num
)
656 #if defined(HAVE_FPCLASS) || defined(fpclass)
657 switch (fpclass( num
))
660 case FP_SNAN
: return MSVCRT__FPCLASS_SNAN
;
663 case FP_QNAN
: return MSVCRT__FPCLASS_QNAN
;
666 case FP_NINF
: return MSVCRT__FPCLASS_NINF
;
669 case FP_PINF
: return MSVCRT__FPCLASS_PINF
;
672 case FP_NDENORM
: return MSVCRT__FPCLASS_ND
;
675 case FP_PDENORM
: return MSVCRT__FPCLASS_PD
;
678 case FP_NZERO
: return MSVCRT__FPCLASS_NZ
;
681 case FP_PZERO
: return MSVCRT__FPCLASS_PZ
;
684 case FP_NNORM
: return MSVCRT__FPCLASS_NN
;
687 case FP_PNORM
: return MSVCRT__FPCLASS_PN
;
689 default: return MSVCRT__FPCLASS_PN
;
691 #elif defined (fpclassify)
692 switch (fpclassify( num
))
694 case FP_NAN
: return MSVCRT__FPCLASS_QNAN
;
695 case FP_INFINITE
: return signbit(num
) ? MSVCRT__FPCLASS_NINF
: MSVCRT__FPCLASS_PINF
;
696 case FP_SUBNORMAL
: return signbit(num
) ?MSVCRT__FPCLASS_ND
: MSVCRT__FPCLASS_PD
;
697 case FP_ZERO
: return signbit(num
) ? MSVCRT__FPCLASS_NZ
: MSVCRT__FPCLASS_PZ
;
699 return signbit(num
) ? MSVCRT__FPCLASS_NN
: MSVCRT__FPCLASS_PN
;
702 return MSVCRT__FPCLASS_QNAN
;
703 return num
== 0.0 ? MSVCRT__FPCLASS_PZ
: (num
< 0 ? MSVCRT__FPCLASS_NN
: MSVCRT__FPCLASS_PN
);
707 /*********************************************************************
710 unsigned int CDECL
_rotl(unsigned int num
, int shift
)
713 return (num
<< shift
) | (num
>> (32-shift
));
716 /*********************************************************************
719 MSVCRT_ulong CDECL
MSVCRT__lrotl(MSVCRT_ulong num
, int shift
)
722 return (num
<< shift
) | (num
>> (32-shift
));
725 /*********************************************************************
728 MSVCRT_ulong CDECL
MSVCRT__lrotr(MSVCRT_ulong num
, int shift
)
731 return (num
>> shift
) | (num
<< (32-shift
));
734 /*********************************************************************
737 unsigned int CDECL
_rotr(unsigned int num
, int shift
)
740 return (num
>> shift
) | (num
<< (32-shift
));
743 /*********************************************************************
746 unsigned __int64 CDECL
_rotl64(unsigned __int64 num
, int shift
)
749 return (num
<< shift
) | (num
>> (64-shift
));
752 /*********************************************************************
755 unsigned __int64 CDECL
_rotr64(unsigned __int64 num
, int shift
)
758 return (num
>> shift
) | (num
<< (64-shift
));
761 /*********************************************************************
764 int CDECL
MSVCRT_abs( int n
)
766 return n
>= 0 ? n
: -n
;
769 /*********************************************************************
772 MSVCRT_long CDECL
MSVCRT_labs( MSVCRT_long n
)
774 return n
>= 0 ? n
: -n
;
777 /*********************************************************************
780 __int64 CDECL
_abs64( __int64 n
)
782 return n
>= 0 ? n
: -n
;
785 /*********************************************************************
788 double CDECL
MSVCRT__logb(double num
)
790 if (!finite(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
794 /*********************************************************************
797 double CDECL
MSVCRT__scalb(double num
, MSVCRT_long power
)
799 if (!finite(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
800 return ldexp(num
, power
);
803 /*********************************************************************
806 double CDECL
_hypot(double x
, double y
)
808 /* FIXME: errno handling */
809 return hypot( x
, y
);
812 /*********************************************************************
815 float CDECL
MSVCRT__hypotf(float x
, float y
)
817 /* FIXME: errno handling */
818 return hypotf( x
, y
);
821 /*********************************************************************
824 double CDECL
MSVCRT_ceil( double x
)
829 /*********************************************************************
832 double CDECL
MSVCRT_floor( double x
)
837 /*********************************************************************
840 double CDECL
MSVCRT_fabs( double x
)
845 /*********************************************************************
848 double CDECL
MSVCRT_frexp( double x
, int *exp
)
850 return frexp( x
, exp
);
853 /*********************************************************************
856 double CDECL
MSVCRT_modf( double x
, double *iptr
)
858 return modf( x
, iptr
);
861 /*********************************************************************
862 * _matherr (MSVCRT.@)
864 int CDECL
MSVCRT__matherr(struct MSVCRT__exception
*e
)
867 TRACE("(%p = %d, %s, %g %g %g)\n",e
, e
->type
, e
->name
, e
->arg1
, e
->arg2
,
871 if (MSVCRT_default_matherr_func
)
872 return MSVCRT_default_matherr_func(e
);
873 ERR(":Unhandled math error!\n");
877 /*********************************************************************
878 * __setusermatherr (MSVCRT.@)
880 void CDECL
MSVCRT___setusermatherr(MSVCRT_matherr_func func
)
882 MSVCRT_default_matherr_func
= func
;
883 TRACE(":new matherr handler %p\n", func
);
886 /**********************************************************************
887 * _statusfp2 (MSVCRT.@)
889 * Not exported by native msvcrt, added in msvcr80.
891 #if defined(__i386__) || defined(__x86_64__)
892 void CDECL
_statusfp2( unsigned int *x86_sw
, unsigned int *sse2_sw
)
896 unsigned long fpword
;
900 __asm__
__volatile__( "fstsw %0" : "=m" (fpword
) );
902 if (fpword
& 0x1) flags
|= MSVCRT__SW_INVALID
;
903 if (fpword
& 0x2) flags
|= MSVCRT__SW_DENORMAL
;
904 if (fpword
& 0x4) flags
|= MSVCRT__SW_ZERODIVIDE
;
905 if (fpword
& 0x8) flags
|= MSVCRT__SW_OVERFLOW
;
906 if (fpword
& 0x10) flags
|= MSVCRT__SW_UNDERFLOW
;
907 if (fpword
& 0x20) flags
|= MSVCRT__SW_INEXACT
;
911 if (!sse2_sw
) return;
915 __asm__
__volatile__( "stmxcsr %0" : "=m" (fpword
) );
917 if (fpword
& 0x1) flags
|= MSVCRT__SW_INVALID
;
918 if (fpword
& 0x2) flags
|= MSVCRT__SW_DENORMAL
;
919 if (fpword
& 0x4) flags
|= MSVCRT__SW_ZERODIVIDE
;
920 if (fpword
& 0x8) flags
|= MSVCRT__SW_OVERFLOW
;
921 if (fpword
& 0x10) flags
|= MSVCRT__SW_UNDERFLOW
;
922 if (fpword
& 0x20) flags
|= MSVCRT__SW_INEXACT
;
927 FIXME( "not implemented\n" );
932 /**********************************************************************
933 * _statusfp (MSVCRT.@)
935 unsigned int CDECL
_statusfp(void)
937 #if defined(__i386__) || defined(__x86_64__)
938 unsigned int x86_sw
, sse2_sw
;
940 _statusfp2( &x86_sw
, &sse2_sw
);
941 /* FIXME: there's no definition for ambiguous status, just return all status bits for now */
942 return x86_sw
| sse2_sw
;
944 FIXME( "not implemented\n" );
949 /*********************************************************************
950 * _clearfp (MSVCRT.@)
952 unsigned int CDECL
_clearfp(void)
954 unsigned int flags
= 0;
955 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
956 unsigned long fpword
;
958 __asm__
__volatile__( "fnstsw %0; fnclex" : "=m" (fpword
) );
959 if (fpword
& 0x1) flags
|= MSVCRT__SW_INVALID
;
960 if (fpword
& 0x2) flags
|= MSVCRT__SW_DENORMAL
;
961 if (fpword
& 0x4) flags
|= MSVCRT__SW_ZERODIVIDE
;
962 if (fpword
& 0x8) flags
|= MSVCRT__SW_OVERFLOW
;
963 if (fpword
& 0x10) flags
|= MSVCRT__SW_UNDERFLOW
;
964 if (fpword
& 0x20) flags
|= MSVCRT__SW_INEXACT
;
968 __asm__
__volatile__( "stmxcsr %0" : "=m" (fpword
) );
969 if (fpword
& 0x1) flags
|= MSVCRT__SW_INVALID
;
970 if (fpword
& 0x2) flags
|= MSVCRT__SW_DENORMAL
;
971 if (fpword
& 0x4) flags
|= MSVCRT__SW_ZERODIVIDE
;
972 if (fpword
& 0x8) flags
|= MSVCRT__SW_OVERFLOW
;
973 if (fpword
& 0x10) flags
|= MSVCRT__SW_UNDERFLOW
;
974 if (fpword
& 0x20) flags
|= MSVCRT__SW_INEXACT
;
976 __asm__
__volatile__( "ldmxcsr %0" : : "m" (fpword
) );
979 FIXME( "not implemented\n" );
984 /*********************************************************************
985 * __fpecode (MSVCRT.@)
987 int * CDECL
__fpecode(void)
989 return &msvcrt_get_thread_data()->fpecode
;
992 /*********************************************************************
995 double CDECL
MSVCRT_ldexp(double num
, MSVCRT_long exp
)
997 double z
= ldexp(num
,exp
);
1000 *MSVCRT__errno() = MSVCRT_ERANGE
;
1001 else if (z
== 0 && signbit(z
))
1002 z
= 0.0; /* Convert -0 -> +0 */
1006 /*********************************************************************
1009 double CDECL
MSVCRT__cabs(struct MSVCRT__complex num
)
1011 return sqrt(num
.x
* num
.x
+ num
.y
* num
.y
);
1014 /*********************************************************************
1015 * _chgsign (MSVCRT.@)
1017 double CDECL
MSVCRT__chgsign(double num
)
1019 /* FIXME: +-infinity,Nan not tested */
1023 /*********************************************************************
1024 * __control87_2 (MSVCRT.@)
1026 * Not exported by native msvcrt, added in msvcr80.
1028 #if defined(__i386__) || defined(__x86_64__)
1029 int CDECL
__control87_2( unsigned int newval
, unsigned int mask
,
1030 unsigned int *x86_cw
, unsigned int *sse2_cw
)
1033 unsigned long fpword
;
1038 __asm__
__volatile__( "fstcw %0" : "=m" (fpword
) );
1040 /* Convert into mask constants */
1042 if (fpword
& 0x1) flags
|= MSVCRT__EM_INVALID
;
1043 if (fpword
& 0x2) flags
|= MSVCRT__EM_DENORMAL
;
1044 if (fpword
& 0x4) flags
|= MSVCRT__EM_ZERODIVIDE
;
1045 if (fpword
& 0x8) flags
|= MSVCRT__EM_OVERFLOW
;
1046 if (fpword
& 0x10) flags
|= MSVCRT__EM_UNDERFLOW
;
1047 if (fpword
& 0x20) flags
|= MSVCRT__EM_INEXACT
;
1048 switch (fpword
& 0xc00)
1050 case 0xc00: flags
|= MSVCRT__RC_UP
|MSVCRT__RC_DOWN
; break;
1051 case 0x800: flags
|= MSVCRT__RC_UP
; break;
1052 case 0x400: flags
|= MSVCRT__RC_DOWN
; break;
1054 switch (fpword
& 0x300)
1056 case 0x0: flags
|= MSVCRT__PC_24
; break;
1057 case 0x200: flags
|= MSVCRT__PC_53
; break;
1058 case 0x300: flags
|= MSVCRT__PC_64
; break;
1060 if (fpword
& 0x1000) flags
|= MSVCRT__IC_AFFINE
;
1062 TRACE( "x86 flags=%08x newval=%08x mask=%08x\n", flags
, newval
, mask
);
1065 flags
= (flags
& ~mask
) | (newval
& mask
);
1067 /* Convert (masked) value back to fp word */
1069 if (flags
& MSVCRT__EM_INVALID
) fpword
|= 0x1;
1070 if (flags
& MSVCRT__EM_DENORMAL
) fpword
|= 0x2;
1071 if (flags
& MSVCRT__EM_ZERODIVIDE
) fpword
|= 0x4;
1072 if (flags
& MSVCRT__EM_OVERFLOW
) fpword
|= 0x8;
1073 if (flags
& MSVCRT__EM_UNDERFLOW
) fpword
|= 0x10;
1074 if (flags
& MSVCRT__EM_INEXACT
) fpword
|= 0x20;
1075 switch (flags
& MSVCRT__MCW_RC
)
1077 case MSVCRT__RC_UP
|MSVCRT__RC_DOWN
: fpword
|= 0xc00; break;
1078 case MSVCRT__RC_UP
: fpword
|= 0x800; break;
1079 case MSVCRT__RC_DOWN
: fpword
|= 0x400; break;
1081 switch (flags
& MSVCRT__MCW_PC
)
1083 case MSVCRT__PC_64
: fpword
|= 0x300; break;
1084 case MSVCRT__PC_53
: fpword
|= 0x200; break;
1085 case MSVCRT__PC_24
: fpword
|= 0x0; break;
1087 if (flags
& MSVCRT__IC_AFFINE
) fpword
|= 0x1000;
1089 __asm__
__volatile__( "fldcw %0" : : "m" (fpword
) );
1094 if (!sse2_cw
) return 1;
1098 __asm__
__volatile__( "stmxcsr %0" : "=m" (fpword
) );
1100 /* Convert into mask constants */
1102 if (fpword
& 0x80) flags
|= MSVCRT__EM_INVALID
;
1103 if (fpword
& 0x100) flags
|= MSVCRT__EM_DENORMAL
;
1104 if (fpword
& 0x200) flags
|= MSVCRT__EM_ZERODIVIDE
;
1105 if (fpword
& 0x400) flags
|= MSVCRT__EM_OVERFLOW
;
1106 if (fpword
& 0x800) flags
|= MSVCRT__EM_UNDERFLOW
;
1107 if (fpword
& 0x1000) flags
|= MSVCRT__EM_INEXACT
;
1108 switch (fpword
& 0x6000)
1110 case 0x6000: flags
|= MSVCRT__RC_UP
|MSVCRT__RC_DOWN
; break;
1111 case 0x4000: flags
|= MSVCRT__RC_UP
; break;
1112 case 0x2000: flags
|= MSVCRT__RC_DOWN
; break;
1114 switch (fpword
& 0x8040)
1116 case 0x0040: flags
|= MSVCRT__DN_FLUSH_OPERANDS_SAVE_RESULTS
; break;
1117 case 0x8000: flags
|= MSVCRT__DN_SAVE_OPERANDS_FLUSH_RESULTS
; break;
1118 case 0x8040: flags
|= MSVCRT__DN_FLUSH
; break;
1121 TRACE( "sse2 flags=%08x newval=%08x mask=%08x\n", flags
, newval
, mask
);
1124 flags
= (flags
& ~mask
) | (newval
& mask
);
1126 /* Convert (masked) value back to fp word */
1128 if (flags
& MSVCRT__EM_INVALID
) fpword
|= 0x80;
1129 if (flags
& MSVCRT__EM_DENORMAL
) fpword
|= 0x100;
1130 if (flags
& MSVCRT__EM_ZERODIVIDE
) fpword
|= 0x200;
1131 if (flags
& MSVCRT__EM_OVERFLOW
) fpword
|= 0x400;
1132 if (flags
& MSVCRT__EM_UNDERFLOW
) fpword
|= 0x800;
1133 if (flags
& MSVCRT__EM_INEXACT
) fpword
|= 0x1000;
1134 switch (flags
& MSVCRT__MCW_RC
)
1136 case MSVCRT__RC_UP
|MSVCRT__RC_DOWN
: fpword
|= 0x6000; break;
1137 case MSVCRT__RC_UP
: fpword
|= 0x4000; break;
1138 case MSVCRT__RC_DOWN
: fpword
|= 0x2000; break;
1140 switch (flags
& MSVCRT__MCW_DN
)
1142 case MSVCRT__DN_FLUSH_OPERANDS_SAVE_RESULTS
: fpword
|= 0x0040; break;
1143 case MSVCRT__DN_SAVE_OPERANDS_FLUSH_RESULTS
: fpword
|= 0x8000; break;
1144 case MSVCRT__DN_FLUSH
: fpword
|= 0x8040; break;
1146 __asm__
__volatile__( "ldmxcsr %0" : : "m" (fpword
) );
1154 FIXME( "not implemented\n" );
1160 /*********************************************************************
1161 * _control87 (MSVCRT.@)
1163 unsigned int CDECL
_control87(unsigned int newval
, unsigned int mask
)
1165 #if defined(__i386__) || defined(__x86_64__)
1166 unsigned int x86_cw
, sse2_cw
;
1168 __control87_2( newval
, mask
, &x86_cw
, &sse2_cw
);
1170 if ((x86_cw
^ sse2_cw
) & (MSVCRT__MCW_EM
| MSVCRT__MCW_RC
)) x86_cw
|= MSVCRT__EM_AMBIGUOUS
;
1173 FIXME( "not implemented\n" );
1178 /*********************************************************************
1179 * _controlfp (MSVCRT.@)
1181 unsigned int CDECL
_controlfp(unsigned int newval
, unsigned int mask
)
1183 return _control87( newval
, mask
& ~MSVCRT__EM_DENORMAL
);
1186 /*********************************************************************
1187 * _set_controlfp (MSVCRT.@)
1189 void CDECL
_set_controlfp( unsigned int newval
, unsigned int mask
)
1191 _controlfp( newval
, mask
);
1194 /*********************************************************************
1195 * _controlfp_s (MSVCRT.@)
1197 int CDECL
_controlfp_s(unsigned int *cur
, unsigned int newval
, unsigned int mask
)
1199 static const unsigned int all_flags
= (MSVCRT__MCW_EM
| MSVCRT__MCW_IC
| MSVCRT__MCW_RC
|
1200 MSVCRT__MCW_PC
| MSVCRT__MCW_DN
);
1203 if (!MSVCRT_CHECK_PMT( !(newval
& mask
& ~all_flags
) ))
1205 if (cur
) *cur
= _controlfp( 0, 0 ); /* retrieve it anyway */
1206 return MSVCRT_EINVAL
;
1208 val
= _controlfp( newval
, mask
);
1209 if (cur
) *cur
= val
;
1213 /*********************************************************************
1214 * _copysign (MSVCRT.@)
1216 double CDECL
MSVCRT__copysign(double num
, double sign
)
1218 /* FIXME: Behaviour for Nan/Inf? */
1220 return num
< 0.0 ? num
: -num
;
1221 return num
< 0.0 ? -num
: num
;
1224 /*********************************************************************
1225 * _finite (MSVCRT.@)
1227 int CDECL
MSVCRT__finite(double num
)
1229 return (finite(num
)?1:0); /* See comment for _isnan() */
1232 /*********************************************************************
1233 * _fpreset (MSVCRT.@)
1235 void CDECL
_fpreset(void)
1237 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
1238 const unsigned int x86_cw
= 0x27f;
1239 __asm__
__volatile__( "fninit; fldcw %0" : : "m" (x86_cw
) );
1242 const unsigned long sse2_cw
= 0x1f80;
1243 __asm__
__volatile__( "ldmxcsr %0" : : "m" (sse2_cw
) );
1246 FIXME( "not implemented\n" );
1250 /*********************************************************************
1253 INT CDECL
MSVCRT__isnan(double num
)
1255 /* Some implementations return -1 for true(glibc), msvcrt/crtdll return 1.
1256 * Do the same, as the result may be used in calculations
1258 return isnan(num
) ? 1 : 0;
1261 /*********************************************************************
1264 double CDECL
MSVCRT__j0(double num
)
1266 /* FIXME: errno handling */
1270 /*********************************************************************
1273 double CDECL
MSVCRT__j1(double num
)
1275 /* FIXME: errno handling */
1279 /*********************************************************************
1282 double CDECL
MSVCRT__jn(int n
, double num
)
1284 /* FIXME: errno handling */
1288 /*********************************************************************
1291 double CDECL
MSVCRT__y0(double num
)
1294 if (!finite(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
1296 if (MSVCRT__fpclass(retval
) == MSVCRT__FPCLASS_NINF
)
1298 *MSVCRT__errno() = MSVCRT_EDOM
;
1304 /*********************************************************************
1307 double CDECL
MSVCRT__y1(double num
)
1310 if (!finite(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
1312 if (MSVCRT__fpclass(retval
) == MSVCRT__FPCLASS_NINF
)
1314 *MSVCRT__errno() = MSVCRT_EDOM
;
1320 /*********************************************************************
1323 double CDECL
MSVCRT__yn(int order
, double num
)
1326 if (!finite(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
1327 retval
= yn(order
,num
);
1328 if (MSVCRT__fpclass(retval
) == MSVCRT__FPCLASS_NINF
)
1330 *MSVCRT__errno() = MSVCRT_EDOM
;
1336 /*********************************************************************
1337 * _nextafter (MSVCRT.@)
1339 double CDECL
MSVCRT__nextafter(double num
, double next
)
1342 if (!finite(num
) || !finite(next
)) *MSVCRT__errno() = MSVCRT_EDOM
;
1343 retval
= nextafter(num
,next
);
1347 /*********************************************************************
1350 char * CDECL
_ecvt( double number
, int ndigits
, int *decpt
, int *sign
)
1353 thread_data_t
*data
= msvcrt_get_thread_data();
1354 /* FIXME: check better for overflow (native supports over 300 chars) */
1355 ndigits
= min( ndigits
, 80 - 7); /* 7 : space for dec point, 1 for "e",
1356 * 4 for exponent and one for
1357 * terminating '\0' */
1358 if (!data
->efcvt_buffer
)
1359 data
->efcvt_buffer
= MSVCRT_malloc( 80 ); /* ought to be enough */
1366 /* handle cases with zero ndigits or less */
1368 if( prec
< 1) prec
= 2;
1369 len
= snprintf(data
->efcvt_buffer
, 80, "%.*le", prec
- 1, number
);
1370 /* take the decimal "point away */
1372 memmove( data
->efcvt_buffer
+ 1, data
->efcvt_buffer
+ 2, len
- 1 );
1373 /* take the exponential "e" out */
1374 data
->efcvt_buffer
[ prec
] = '\0';
1375 /* read the exponent */
1376 sscanf( data
->efcvt_buffer
+ prec
+ 1, "%d", decpt
);
1378 /* adjust for some border cases */
1379 if( data
->efcvt_buffer
[0] == '0')/* value is zero */
1381 /* handle cases with zero ndigits or less */
1383 if( data
->efcvt_buffer
[ 0] >= '5')
1385 data
->efcvt_buffer
[ 0] = '\0';
1387 TRACE("out=\"%s\"\n",data
->efcvt_buffer
);
1388 return data
->efcvt_buffer
;
1391 /*********************************************************************
1392 * _ecvt_s (MSVCRT.@)
1394 int CDECL
_ecvt_s( char *buffer
, MSVCRT_size_t length
, double number
, int ndigits
, int *decpt
, int *sign
)
1398 const char infret
[] = "1#INF";
1400 if (!MSVCRT_CHECK_PMT(buffer
!= NULL
)) return MSVCRT_EINVAL
;
1401 if (!MSVCRT_CHECK_PMT(decpt
!= NULL
)) return MSVCRT_EINVAL
;
1402 if (!MSVCRT_CHECK_PMT(sign
!= NULL
)) return MSVCRT_EINVAL
;
1403 if (!MSVCRT_CHECK_PMT_ERR( length
> 2, MSVCRT_ERANGE
)) return MSVCRT_ERANGE
;
1404 if (!MSVCRT_CHECK_PMT_ERR(ndigits
< (int)length
- 1, MSVCRT_ERANGE
)) return MSVCRT_ERANGE
;
1406 /* special case - inf */
1407 if(number
== HUGE_VAL
|| number
== -HUGE_VAL
)
1409 memset(buffer
, '0', ndigits
);
1410 memcpy(buffer
, infret
, min(ndigits
, sizeof(infret
) - 1 ) );
1411 buffer
[ndigits
] = '\0';
1413 if(number
== -HUGE_VAL
)
1419 /* handle cases with zero ndigits or less */
1421 if( prec
< 1) prec
= 2;
1422 result
= MSVCRT_malloc(prec
+ 7);
1429 len
= snprintf(result
, prec
+ 7, "%.*le", prec
- 1, number
);
1430 /* take the decimal "point away */
1432 memmove( result
+ 1, result
+ 2, len
- 1 );
1433 /* take the exponential "e" out */
1434 result
[ prec
] = '\0';
1435 /* read the exponent */
1436 sscanf( result
+ prec
+ 1, "%d", decpt
);
1438 /* adjust for some border cases */
1439 if( result
[0] == '0')/* value is zero */
1441 /* handle cases with zero ndigits or less */
1443 if( result
[ 0] >= '5')
1447 memcpy( buffer
, result
, max(ndigits
+ 1, 1) );
1448 MSVCRT_free( result
);
1452 /***********************************************************************
1455 char * CDECL
_fcvt( double number
, int ndigits
, int *decpt
, int *sign
)
1457 thread_data_t
*data
= msvcrt_get_thread_data();
1458 int stop
, dec1
, dec2
;
1459 char *ptr1
, *ptr2
, *first
;
1460 char buf
[80]; /* ought to be enough */
1462 if (!data
->efcvt_buffer
)
1463 data
->efcvt_buffer
= MSVCRT_malloc( 80 ); /* ought to be enough */
1471 snprintf(buf
, 80, "%.*f", ndigits
< 0 ? 0 : ndigits
, number
);
1473 ptr2
= data
->efcvt_buffer
;
1478 /* For numbers below the requested resolution, work out where
1479 the decimal point will be rather than finding it in the string */
1480 if (number
< 1.0 && number
> 0.0) {
1481 dec2
= log10(number
+ 1e-10);
1482 if (-dec2
<= ndigits
) dec2
= 0;
1485 /* If requested digits is zero or less, we will need to truncate
1486 * the returned string */
1488 stop
= strlen(buf
) + ndigits
;
1493 while (*ptr1
== '0') ptr1
++; /* Skip leading zeroes */
1494 while (*ptr1
!= '\0' && *ptr1
!= '.') {
1495 if (!first
) first
= ptr2
;
1496 if ((ptr1
- buf
) < stop
) {
1507 while (*ptr1
== '0') { /* Process leading zeroes */
1512 while (*ptr1
!= '\0') {
1513 if (!first
) first
= ptr2
;
1520 /* We never found a non-zero digit, then our number is either
1521 * smaller than the requested precision, or 0.0 */
1526 first
= data
->efcvt_buffer
;
1531 *decpt
= dec2
? dec2
: dec1
;
1535 /***********************************************************************
1536 * _fcvt_s (MSVCRT.@)
1538 int CDECL
_fcvt_s(char* outbuffer
, MSVCRT_size_t size
, double number
, int ndigits
, int *decpt
, int *sign
)
1540 int stop
, dec1
, dec2
;
1541 char *ptr1
, *ptr2
, *first
;
1542 char buf
[80]; /* ought to be enough */
1544 if (!outbuffer
|| !decpt
|| !sign
|| size
== 0)
1546 *MSVCRT__errno() = MSVCRT_EINVAL
;
1547 return MSVCRT_EINVAL
;
1556 snprintf(buf
, 80, "%.*f", ndigits
< 0 ? 0 : ndigits
, number
);
1563 /* For numbers below the requested resolution, work out where
1564 the decimal point will be rather than finding it in the string */
1565 if (number
< 1.0 && number
> 0.0) {
1566 dec2
= log10(number
+ 1e-10);
1567 if (-dec2
<= ndigits
) dec2
= 0;
1570 /* If requested digits is zero or less, we will need to truncate
1571 * the returned string */
1573 stop
= strlen(buf
) + ndigits
;
1578 while (*ptr1
== '0') ptr1
++; /* Skip leading zeroes */
1579 while (*ptr1
!= '\0' && *ptr1
!= '.') {
1580 if (!first
) first
= ptr2
;
1581 if ((ptr1
- buf
) < stop
) {
1595 while (*ptr1
== '0') { /* Process leading zeroes */
1596 if (number
== 0.0 && size
> 1) {
1604 while (*ptr1
!= '\0') {
1605 if (!first
) first
= ptr2
;
1615 /* We never found a non-zero digit, then our number is either
1616 * smaller than the requested precision, or 0.0 */
1617 if (!first
&& (number
<= 0.0))
1620 *decpt
= dec2
? dec2
: dec1
;
1624 /***********************************************************************
1627 char * CDECL
_gcvt( double number
, int ndigit
, char *buff
)
1630 *MSVCRT__errno() = MSVCRT_EINVAL
;
1635 *MSVCRT__errno() = MSVCRT_ERANGE
;
1639 MSVCRT_sprintf(buff
, "%.*g", ndigit
, number
);
1643 /***********************************************************************
1644 * _gcvt_s (MSVCRT.@)
1646 int CDECL
_gcvt_s(char *buff
, MSVCRT_size_t size
, double number
, int digits
)
1651 *MSVCRT__errno() = MSVCRT_EINVAL
;
1652 return MSVCRT_EINVAL
;
1655 if( digits
<0 || digits
>=size
) {
1659 *MSVCRT__errno() = MSVCRT_ERANGE
;
1660 return MSVCRT_ERANGE
;
1663 len
= MSVCRT__scprintf("%.*g", digits
, number
);
1666 *MSVCRT__errno() = MSVCRT_ERANGE
;
1667 return MSVCRT_ERANGE
;
1670 MSVCRT_sprintf(buff
, "%.*g", digits
, number
);
1674 #include <stdlib.h> /* div_t, ldiv_t */
1676 /*********************************************************************
1679 * [i386] Windows binary compatible - returns the struct in eax/edx.
1682 unsigned __int64 CDECL
MSVCRT_div(int num
, int denom
)
1684 div_t dt
= div(num
,denom
);
1685 return ((unsigned __int64
)dt
.rem
<< 32) | (unsigned int)dt
.quot
;
1688 /*********************************************************************
1691 * [!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
1693 MSVCRT_div_t CDECL
MSVCRT_div(int num
, int denom
)
1695 div_t dt
= div(num
,denom
);
1703 #endif /* ifdef __i386__ */
1706 /*********************************************************************
1709 * [i386] Windows binary compatible - returns the struct in eax/edx.
1712 unsigned __int64 CDECL
MSVCRT_ldiv(MSVCRT_long num
, MSVCRT_long denom
)
1714 ldiv_t ldt
= ldiv(num
,denom
);
1715 return ((unsigned __int64
)ldt
.rem
<< 32) | (MSVCRT_ulong
)ldt
.quot
;
1718 /*********************************************************************
1721 * [!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
1723 MSVCRT_ldiv_t CDECL
MSVCRT_ldiv(MSVCRT_long num
, MSVCRT_long denom
)
1725 ldiv_t result
= ldiv(num
,denom
);
1728 ret
.quot
= result
.quot
;
1729 ret
.rem
= result
.rem
;
1733 #endif /* ifdef __i386__ */
1737 /*********************************************************************
1738 * _adjust_fdiv (MSVCRT.@)
1739 * Used by the MSVC compiler to work around the Pentium FDIV bug.
1741 int MSVCRT__adjust_fdiv
= 0;
1743 /***********************************************************************
1744 * _adj_fdiv_m16i (MSVCRT.@)
1747 * I _think_ this function is intended to work around the Pentium
1750 void __stdcall
_adj_fdiv_m16i( short arg
)
1752 TRACE("(): stub\n");
1755 /***********************************************************************
1756 * _adj_fdiv_m32 (MSVCRT.@)
1759 * I _think_ this function is intended to work around the Pentium
1762 void __stdcall
_adj_fdiv_m32( unsigned int arg
)
1764 TRACE("(): stub\n");
1767 /***********************************************************************
1768 * _adj_fdiv_m32i (MSVCRT.@)
1771 * I _think_ this function is intended to work around the Pentium
1774 void __stdcall
_adj_fdiv_m32i( int arg
)
1776 TRACE("(): stub\n");
1779 /***********************************************************************
1780 * _adj_fdiv_m64 (MSVCRT.@)
1783 * I _think_ this function is intended to work around the Pentium
1786 void __stdcall
_adj_fdiv_m64( unsigned __int64 arg
)
1788 TRACE("(): stub\n");
1791 /***********************************************************************
1792 * _adj_fdiv_r (MSVCRT.@)
1794 * This function is likely to have the wrong number of arguments.
1797 * I _think_ this function is intended to work around the Pentium
1800 void _adj_fdiv_r(void)
1802 TRACE("(): stub\n");
1805 /***********************************************************************
1806 * _adj_fdivr_m16i (MSVCRT.@)
1809 * I _think_ this function is intended to work around the Pentium
1812 void __stdcall
_adj_fdivr_m16i( short arg
)
1814 TRACE("(): stub\n");
1817 /***********************************************************************
1818 * _adj_fdivr_m32 (MSVCRT.@)
1821 * I _think_ this function is intended to work around the Pentium
1824 void __stdcall
_adj_fdivr_m32( unsigned int arg
)
1826 TRACE("(): stub\n");
1829 /***********************************************************************
1830 * _adj_fdivr_m32i (MSVCRT.@)
1833 * I _think_ this function is intended to work around the Pentium
1836 void __stdcall
_adj_fdivr_m32i( int arg
)
1838 TRACE("(): stub\n");
1841 /***********************************************************************
1842 * _adj_fdivr_m64 (MSVCRT.@)
1845 * I _think_ this function is intended to work around the Pentium
1848 void __stdcall
_adj_fdivr_m64( unsigned __int64 arg
)
1850 TRACE("(): stub\n");
1853 /***********************************************************************
1854 * _adj_fpatan (MSVCRT.@)
1856 * This function is likely to have the wrong number of arguments.
1859 * I _think_ this function is intended to work around the Pentium
1862 void _adj_fpatan(void)
1864 TRACE("(): stub\n");
1867 /***********************************************************************
1868 * _adj_fprem (MSVCRT.@)
1870 * This function is likely to have the wrong number of arguments.
1873 * I _think_ this function is intended to work around the Pentium
1876 void _adj_fprem(void)
1878 TRACE("(): stub\n");
1881 /***********************************************************************
1882 * _adj_fprem1 (MSVCRT.@)
1884 * This function is likely to have the wrong number of arguments.
1887 * I _think_ this function is intended to work around the Pentium
1890 void _adj_fprem1(void)
1892 TRACE("(): stub\n");
1895 /***********************************************************************
1896 * _adj_fptan (MSVCRT.@)
1898 * This function is likely to have the wrong number of arguments.
1901 * I _think_ this function is intended to work around the Pentium
1904 void _adj_fptan(void)
1906 TRACE("(): stub\n");
1909 /***********************************************************************
1910 * _safe_fdiv (MSVCRT.@)
1912 * This function is likely to have the wrong number of arguments.
1915 * I _think_ this function is intended to work around the Pentium
1918 void _safe_fdiv(void)
1920 TRACE("(): stub\n");
1923 /***********************************************************************
1924 * _safe_fdivr (MSVCRT.@)
1926 * This function is likely to have the wrong number of arguments.
1929 * I _think_ this function is intended to work around the Pentium
1932 void _safe_fdivr(void)
1934 TRACE("(): stub\n");
1937 /***********************************************************************
1938 * _safe_fprem (MSVCRT.@)
1940 * This function is likely to have the wrong number of arguments.
1943 * I _think_ this function is intended to work around the Pentium
1946 void _safe_fprem(void)
1948 TRACE("(): stub\n");
1951 /***********************************************************************
1952 * _safe_fprem1 (MSVCRT.@)
1955 * This function is likely to have the wrong number of arguments.
1958 * I _think_ this function is intended to work around the Pentium
1961 void _safe_fprem1(void)
1963 TRACE("(): stub\n");
1966 /***********************************************************************
1967 * __libm_sse2_acos (MSVCRT.@)
1969 void __cdecl
__libm_sse2_acos(void)
1972 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
1974 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
1977 /***********************************************************************
1978 * __libm_sse2_acosf (MSVCRT.@)
1980 void __cdecl
__libm_sse2_acosf(void)
1983 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
1985 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
1988 /***********************************************************************
1989 * __libm_sse2_asin (MSVCRT.@)
1991 void __cdecl
__libm_sse2_asin(void)
1994 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
1996 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
1999 /***********************************************************************
2000 * __libm_sse2_asinf (MSVCRT.@)
2002 void __cdecl
__libm_sse2_asinf(void)
2005 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2007 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2010 /***********************************************************************
2011 * __libm_sse2_atan (MSVCRT.@)
2013 void __cdecl
__libm_sse2_atan(void)
2016 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2018 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2021 /***********************************************************************
2022 * __libm_sse2_atan2 (MSVCRT.@)
2024 void __cdecl
__libm_sse2_atan2(void)
2027 __asm__
__volatile__( "movq %%xmm0,%0; movq %%xmm1,%1 " : "=m" (d1
), "=m" (d2
) );
2028 d1
= atan2( d1
, d2
);
2029 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d1
) );
2032 /***********************************************************************
2033 * __libm_sse2_atanf (MSVCRT.@)
2035 void __cdecl
__libm_sse2_atanf(void)
2038 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2040 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2043 /***********************************************************************
2044 * __libm_sse2_cos (MSVCRT.@)
2046 void __cdecl
__libm_sse2_cos(void)
2049 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2051 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2054 /***********************************************************************
2055 * __libm_sse2_cosf (MSVCRT.@)
2057 void __cdecl
__libm_sse2_cosf(void)
2060 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2062 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2065 /***********************************************************************
2066 * __libm_sse2_exp (MSVCRT.@)
2068 void __cdecl
__libm_sse2_exp(void)
2071 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2073 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2076 /***********************************************************************
2077 * __libm_sse2_expf (MSVCRT.@)
2079 void __cdecl
__libm_sse2_expf(void)
2082 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2084 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2087 /***********************************************************************
2088 * __libm_sse2_log (MSVCRT.@)
2090 void __cdecl
__libm_sse2_log(void)
2093 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2095 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2098 /***********************************************************************
2099 * __libm_sse2_log10 (MSVCRT.@)
2101 void __cdecl
__libm_sse2_log10(void)
2104 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2106 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2109 /***********************************************************************
2110 * __libm_sse2_log10f (MSVCRT.@)
2112 void __cdecl
__libm_sse2_log10f(void)
2115 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2117 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2120 /***********************************************************************
2121 * __libm_sse2_logf (MSVCRT.@)
2123 void __cdecl
__libm_sse2_logf(void)
2126 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2128 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2131 /***********************************************************************
2132 * __libm_sse2_pow (MSVCRT.@)
2134 void __cdecl
__libm_sse2_pow(void)
2137 __asm__
__volatile__( "movq %%xmm0,%0; movq %%xmm1,%1 " : "=m" (d1
), "=m" (d2
) );
2139 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d1
) );
2142 /***********************************************************************
2143 * __libm_sse2_powf (MSVCRT.@)
2145 void __cdecl
__libm_sse2_powf(void)
2148 __asm__
__volatile__( "movd %%xmm0,%0; movd %%xmm1,%1" : "=g" (f1
), "=g" (f2
) );
2149 f1
= powf( f1
, f2
);
2150 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f1
) );
2153 /***********************************************************************
2154 * __libm_sse2_sin (MSVCRT.@)
2156 void __cdecl
__libm_sse2_sin(void)
2159 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2161 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2164 /***********************************************************************
2165 * __libm_sse2_sinf (MSVCRT.@)
2167 void __cdecl
__libm_sse2_sinf(void)
2170 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2172 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2175 /***********************************************************************
2176 * __libm_sse2_tan (MSVCRT.@)
2178 void __cdecl
__libm_sse2_tan(void)
2181 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2183 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2186 /***********************************************************************
2187 * __libm_sse2_tanf (MSVCRT.@)
2189 void __cdecl
__libm_sse2_tanf(void)
2192 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2194 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2197 #endif /* __i386__ */