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 MSVCRT_longlong CDECL
MSVCRT_llabs( MSVCRT_longlong n
)
773 return n
>= 0 ? n
: -n
;
776 /*********************************************************************
779 __int64 CDECL
_abs64( __int64 n
)
781 return n
>= 0 ? n
: -n
;
784 /*********************************************************************
787 double CDECL
MSVCRT__logb(double num
)
789 if (!isfinite(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
793 /*********************************************************************
796 double CDECL
MSVCRT__scalb(double num
, MSVCRT_long power
)
798 if (!isfinite(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
799 return ldexp(num
, power
);
802 /*********************************************************************
805 double CDECL
_hypot(double x
, double y
)
807 /* FIXME: errno handling */
808 return hypot( x
, y
);
811 /*********************************************************************
814 float CDECL
MSVCRT__hypotf(float x
, float y
)
816 /* FIXME: errno handling */
817 return hypotf( x
, y
);
820 /*********************************************************************
823 double CDECL
MSVCRT_ceil( double x
)
828 /*********************************************************************
831 double CDECL
MSVCRT_floor( double x
)
836 /*********************************************************************
839 double CDECL
MSVCRT_fabs( double x
)
844 /*********************************************************************
847 double CDECL
MSVCRT_frexp( double x
, int *exp
)
849 return frexp( x
, exp
);
852 /*********************************************************************
855 double CDECL
MSVCRT_modf( double x
, double *iptr
)
857 return modf( x
, iptr
);
860 /*********************************************************************
861 * _matherr (MSVCRT.@)
863 int CDECL
MSVCRT__matherr(struct MSVCRT__exception
*e
)
866 TRACE("(%p = %d, %s, %g %g %g)\n",e
, e
->type
, e
->name
, e
->arg1
, e
->arg2
,
870 if (MSVCRT_default_matherr_func
)
871 return MSVCRT_default_matherr_func(e
);
872 ERR(":Unhandled math error!\n");
876 /*********************************************************************
877 * __setusermatherr (MSVCRT.@)
879 void CDECL
MSVCRT___setusermatherr(MSVCRT_matherr_func func
)
881 MSVCRT_default_matherr_func
= func
;
882 TRACE(":new matherr handler %p\n", func
);
885 /**********************************************************************
886 * _statusfp2 (MSVCRT.@)
888 * Not exported by native msvcrt, added in msvcr80.
890 #if defined(__i386__) || defined(__x86_64__)
891 void CDECL
_statusfp2( unsigned int *x86_sw
, unsigned int *sse2_sw
)
895 unsigned long fpword
;
899 __asm__
__volatile__( "fstsw %0" : "=m" (fpword
) );
901 if (fpword
& 0x1) flags
|= MSVCRT__SW_INVALID
;
902 if (fpword
& 0x2) flags
|= MSVCRT__SW_DENORMAL
;
903 if (fpword
& 0x4) flags
|= MSVCRT__SW_ZERODIVIDE
;
904 if (fpword
& 0x8) flags
|= MSVCRT__SW_OVERFLOW
;
905 if (fpword
& 0x10) flags
|= MSVCRT__SW_UNDERFLOW
;
906 if (fpword
& 0x20) flags
|= MSVCRT__SW_INEXACT
;
910 if (!sse2_sw
) return;
914 __asm__
__volatile__( "stmxcsr %0" : "=m" (fpword
) );
916 if (fpword
& 0x1) flags
|= MSVCRT__SW_INVALID
;
917 if (fpword
& 0x2) flags
|= MSVCRT__SW_DENORMAL
;
918 if (fpword
& 0x4) flags
|= MSVCRT__SW_ZERODIVIDE
;
919 if (fpword
& 0x8) flags
|= MSVCRT__SW_OVERFLOW
;
920 if (fpword
& 0x10) flags
|= MSVCRT__SW_UNDERFLOW
;
921 if (fpword
& 0x20) flags
|= MSVCRT__SW_INEXACT
;
926 FIXME( "not implemented\n" );
931 /**********************************************************************
932 * _statusfp (MSVCRT.@)
934 unsigned int CDECL
_statusfp(void)
936 #if defined(__i386__) || defined(__x86_64__)
937 unsigned int x86_sw
, sse2_sw
;
939 _statusfp2( &x86_sw
, &sse2_sw
);
940 /* FIXME: there's no definition for ambiguous status, just return all status bits for now */
941 return x86_sw
| sse2_sw
;
943 FIXME( "not implemented\n" );
948 /*********************************************************************
949 * _clearfp (MSVCRT.@)
951 unsigned int CDECL
_clearfp(void)
953 unsigned int flags
= 0;
954 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
955 unsigned long fpword
;
957 __asm__
__volatile__( "fnstsw %0; fnclex" : "=m" (fpword
) );
958 if (fpword
& 0x1) flags
|= MSVCRT__SW_INVALID
;
959 if (fpword
& 0x2) flags
|= MSVCRT__SW_DENORMAL
;
960 if (fpword
& 0x4) flags
|= MSVCRT__SW_ZERODIVIDE
;
961 if (fpword
& 0x8) flags
|= MSVCRT__SW_OVERFLOW
;
962 if (fpword
& 0x10) flags
|= MSVCRT__SW_UNDERFLOW
;
963 if (fpword
& 0x20) flags
|= MSVCRT__SW_INEXACT
;
967 __asm__
__volatile__( "stmxcsr %0" : "=m" (fpword
) );
968 if (fpword
& 0x1) flags
|= MSVCRT__SW_INVALID
;
969 if (fpword
& 0x2) flags
|= MSVCRT__SW_DENORMAL
;
970 if (fpword
& 0x4) flags
|= MSVCRT__SW_ZERODIVIDE
;
971 if (fpword
& 0x8) flags
|= MSVCRT__SW_OVERFLOW
;
972 if (fpword
& 0x10) flags
|= MSVCRT__SW_UNDERFLOW
;
973 if (fpword
& 0x20) flags
|= MSVCRT__SW_INEXACT
;
975 __asm__
__volatile__( "ldmxcsr %0" : : "m" (fpword
) );
978 FIXME( "not implemented\n" );
983 /*********************************************************************
984 * __fpecode (MSVCRT.@)
986 int * CDECL
__fpecode(void)
988 return &msvcrt_get_thread_data()->fpecode
;
991 /*********************************************************************
994 double CDECL
MSVCRT_ldexp(double num
, MSVCRT_long exp
)
996 double z
= ldexp(num
,exp
);
999 *MSVCRT__errno() = MSVCRT_ERANGE
;
1000 else if (z
== 0 && signbit(z
))
1001 z
= 0.0; /* Convert -0 -> +0 */
1005 /*********************************************************************
1008 double CDECL
MSVCRT__cabs(struct MSVCRT__complex num
)
1010 return sqrt(num
.x
* num
.x
+ num
.y
* num
.y
);
1013 /*********************************************************************
1014 * _chgsign (MSVCRT.@)
1016 double CDECL
MSVCRT__chgsign(double num
)
1018 /* FIXME: +-infinity,Nan not tested */
1022 /*********************************************************************
1023 * __control87_2 (MSVCRT.@)
1025 * Not exported by native msvcrt, added in msvcr80.
1027 #if defined(__i386__) || defined(__x86_64__)
1028 int CDECL
__control87_2( unsigned int newval
, unsigned int mask
,
1029 unsigned int *x86_cw
, unsigned int *sse2_cw
)
1032 unsigned long fpword
;
1037 __asm__
__volatile__( "fstcw %0" : "=m" (fpword
) );
1039 /* Convert into mask constants */
1041 if (fpword
& 0x1) flags
|= MSVCRT__EM_INVALID
;
1042 if (fpword
& 0x2) flags
|= MSVCRT__EM_DENORMAL
;
1043 if (fpword
& 0x4) flags
|= MSVCRT__EM_ZERODIVIDE
;
1044 if (fpword
& 0x8) flags
|= MSVCRT__EM_OVERFLOW
;
1045 if (fpword
& 0x10) flags
|= MSVCRT__EM_UNDERFLOW
;
1046 if (fpword
& 0x20) flags
|= MSVCRT__EM_INEXACT
;
1047 switch (fpword
& 0xc00)
1049 case 0xc00: flags
|= MSVCRT__RC_UP
|MSVCRT__RC_DOWN
; break;
1050 case 0x800: flags
|= MSVCRT__RC_UP
; break;
1051 case 0x400: flags
|= MSVCRT__RC_DOWN
; break;
1053 switch (fpword
& 0x300)
1055 case 0x0: flags
|= MSVCRT__PC_24
; break;
1056 case 0x200: flags
|= MSVCRT__PC_53
; break;
1057 case 0x300: flags
|= MSVCRT__PC_64
; break;
1059 if (fpword
& 0x1000) flags
|= MSVCRT__IC_AFFINE
;
1061 TRACE( "x86 flags=%08x newval=%08x mask=%08x\n", flags
, newval
, mask
);
1064 flags
= (flags
& ~mask
) | (newval
& mask
);
1066 /* Convert (masked) value back to fp word */
1068 if (flags
& MSVCRT__EM_INVALID
) fpword
|= 0x1;
1069 if (flags
& MSVCRT__EM_DENORMAL
) fpword
|= 0x2;
1070 if (flags
& MSVCRT__EM_ZERODIVIDE
) fpword
|= 0x4;
1071 if (flags
& MSVCRT__EM_OVERFLOW
) fpword
|= 0x8;
1072 if (flags
& MSVCRT__EM_UNDERFLOW
) fpword
|= 0x10;
1073 if (flags
& MSVCRT__EM_INEXACT
) fpword
|= 0x20;
1074 switch (flags
& MSVCRT__MCW_RC
)
1076 case MSVCRT__RC_UP
|MSVCRT__RC_DOWN
: fpword
|= 0xc00; break;
1077 case MSVCRT__RC_UP
: fpword
|= 0x800; break;
1078 case MSVCRT__RC_DOWN
: fpword
|= 0x400; break;
1080 switch (flags
& MSVCRT__MCW_PC
)
1082 case MSVCRT__PC_64
: fpword
|= 0x300; break;
1083 case MSVCRT__PC_53
: fpword
|= 0x200; break;
1084 case MSVCRT__PC_24
: fpword
|= 0x0; break;
1086 if (flags
& MSVCRT__IC_AFFINE
) fpword
|= 0x1000;
1088 __asm__
__volatile__( "fldcw %0" : : "m" (fpword
) );
1093 if (!sse2_cw
) return 1;
1097 __asm__
__volatile__( "stmxcsr %0" : "=m" (fpword
) );
1099 /* Convert into mask constants */
1101 if (fpword
& 0x80) flags
|= MSVCRT__EM_INVALID
;
1102 if (fpword
& 0x100) flags
|= MSVCRT__EM_DENORMAL
;
1103 if (fpword
& 0x200) flags
|= MSVCRT__EM_ZERODIVIDE
;
1104 if (fpword
& 0x400) flags
|= MSVCRT__EM_OVERFLOW
;
1105 if (fpword
& 0x800) flags
|= MSVCRT__EM_UNDERFLOW
;
1106 if (fpword
& 0x1000) flags
|= MSVCRT__EM_INEXACT
;
1107 switch (fpword
& 0x6000)
1109 case 0x6000: flags
|= MSVCRT__RC_UP
|MSVCRT__RC_DOWN
; break;
1110 case 0x4000: flags
|= MSVCRT__RC_UP
; break;
1111 case 0x2000: flags
|= MSVCRT__RC_DOWN
; break;
1113 switch (fpword
& 0x8040)
1115 case 0x0040: flags
|= MSVCRT__DN_FLUSH_OPERANDS_SAVE_RESULTS
; break;
1116 case 0x8000: flags
|= MSVCRT__DN_SAVE_OPERANDS_FLUSH_RESULTS
; break;
1117 case 0x8040: flags
|= MSVCRT__DN_FLUSH
; break;
1120 TRACE( "sse2 flags=%08x newval=%08x mask=%08x\n", flags
, newval
, mask
);
1123 flags
= (flags
& ~mask
) | (newval
& mask
);
1125 /* Convert (masked) value back to fp word */
1127 if (flags
& MSVCRT__EM_INVALID
) fpword
|= 0x80;
1128 if (flags
& MSVCRT__EM_DENORMAL
) fpword
|= 0x100;
1129 if (flags
& MSVCRT__EM_ZERODIVIDE
) fpword
|= 0x200;
1130 if (flags
& MSVCRT__EM_OVERFLOW
) fpword
|= 0x400;
1131 if (flags
& MSVCRT__EM_UNDERFLOW
) fpword
|= 0x800;
1132 if (flags
& MSVCRT__EM_INEXACT
) fpword
|= 0x1000;
1133 switch (flags
& MSVCRT__MCW_RC
)
1135 case MSVCRT__RC_UP
|MSVCRT__RC_DOWN
: fpword
|= 0x6000; break;
1136 case MSVCRT__RC_UP
: fpword
|= 0x4000; break;
1137 case MSVCRT__RC_DOWN
: fpword
|= 0x2000; break;
1139 switch (flags
& MSVCRT__MCW_DN
)
1141 case MSVCRT__DN_FLUSH_OPERANDS_SAVE_RESULTS
: fpword
|= 0x0040; break;
1142 case MSVCRT__DN_SAVE_OPERANDS_FLUSH_RESULTS
: fpword
|= 0x8000; break;
1143 case MSVCRT__DN_FLUSH
: fpword
|= 0x8040; break;
1145 __asm__
__volatile__( "ldmxcsr %0" : : "m" (fpword
) );
1153 FIXME( "not implemented\n" );
1159 /*********************************************************************
1160 * _control87 (MSVCRT.@)
1162 unsigned int CDECL
_control87(unsigned int newval
, unsigned int mask
)
1164 #if defined(__i386__) || defined(__x86_64__)
1165 unsigned int x86_cw
, sse2_cw
;
1167 __control87_2( newval
, mask
, &x86_cw
, &sse2_cw
);
1169 if ((x86_cw
^ sse2_cw
) & (MSVCRT__MCW_EM
| MSVCRT__MCW_RC
)) x86_cw
|= MSVCRT__EM_AMBIGUOUS
;
1172 FIXME( "not implemented\n" );
1177 /*********************************************************************
1178 * _controlfp (MSVCRT.@)
1180 unsigned int CDECL
_controlfp(unsigned int newval
, unsigned int mask
)
1182 return _control87( newval
, mask
& ~MSVCRT__EM_DENORMAL
);
1185 /*********************************************************************
1186 * _set_controlfp (MSVCRT.@)
1188 void CDECL
_set_controlfp( unsigned int newval
, unsigned int mask
)
1190 _controlfp( newval
, mask
);
1193 /*********************************************************************
1194 * _controlfp_s (MSVCRT.@)
1196 int CDECL
_controlfp_s(unsigned int *cur
, unsigned int newval
, unsigned int mask
)
1198 static const unsigned int all_flags
= (MSVCRT__MCW_EM
| MSVCRT__MCW_IC
| MSVCRT__MCW_RC
|
1199 MSVCRT__MCW_PC
| MSVCRT__MCW_DN
);
1202 if (!MSVCRT_CHECK_PMT( !(newval
& mask
& ~all_flags
) ))
1204 if (cur
) *cur
= _controlfp( 0, 0 ); /* retrieve it anyway */
1205 return MSVCRT_EINVAL
;
1207 val
= _controlfp( newval
, mask
);
1208 if (cur
) *cur
= val
;
1212 /*********************************************************************
1213 * _copysign (MSVCRT.@)
1215 double CDECL
MSVCRT__copysign(double num
, double sign
)
1217 /* FIXME: Behaviour for Nan/Inf? */
1219 return num
< 0.0 ? num
: -num
;
1220 return num
< 0.0 ? -num
: num
;
1223 /*********************************************************************
1224 * _finite (MSVCRT.@)
1226 int CDECL
MSVCRT__finite(double num
)
1228 return isfinite(num
) != 0; /* See comment for _isnan() */
1231 /*********************************************************************
1232 * _fpreset (MSVCRT.@)
1234 void CDECL
_fpreset(void)
1236 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
1237 const unsigned int x86_cw
= 0x27f;
1238 __asm__
__volatile__( "fninit; fldcw %0" : : "m" (x86_cw
) );
1241 const unsigned long sse2_cw
= 0x1f80;
1242 __asm__
__volatile__( "ldmxcsr %0" : : "m" (sse2_cw
) );
1245 FIXME( "not implemented\n" );
1249 /*********************************************************************
1252 INT CDECL
MSVCRT__isnan(double num
)
1254 /* Some implementations return -1 for true(glibc), msvcrt/crtdll return 1.
1255 * Do the same, as the result may be used in calculations
1257 return isnan(num
) != 0;
1260 /*********************************************************************
1263 double CDECL
MSVCRT__j0(double num
)
1265 /* FIXME: errno handling */
1269 /*********************************************************************
1272 double CDECL
MSVCRT__j1(double num
)
1274 /* FIXME: errno handling */
1278 /*********************************************************************
1281 double CDECL
MSVCRT__jn(int n
, double num
)
1283 /* FIXME: errno handling */
1287 /*********************************************************************
1290 double CDECL
MSVCRT__y0(double num
)
1293 if (!isfinite(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
1295 if (MSVCRT__fpclass(retval
) == MSVCRT__FPCLASS_NINF
)
1297 *MSVCRT__errno() = MSVCRT_EDOM
;
1303 /*********************************************************************
1306 double CDECL
MSVCRT__y1(double num
)
1309 if (!isfinite(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
1311 if (MSVCRT__fpclass(retval
) == MSVCRT__FPCLASS_NINF
)
1313 *MSVCRT__errno() = MSVCRT_EDOM
;
1319 /*********************************************************************
1322 double CDECL
MSVCRT__yn(int order
, double num
)
1325 if (!isfinite(num
)) *MSVCRT__errno() = MSVCRT_EDOM
;
1326 retval
= yn(order
,num
);
1327 if (MSVCRT__fpclass(retval
) == MSVCRT__FPCLASS_NINF
)
1329 *MSVCRT__errno() = MSVCRT_EDOM
;
1335 /*********************************************************************
1336 * _nextafter (MSVCRT.@)
1338 double CDECL
MSVCRT__nextafter(double num
, double next
)
1341 if (!isfinite(num
) || !isfinite(next
)) *MSVCRT__errno() = MSVCRT_EDOM
;
1342 retval
= nextafter(num
,next
);
1346 /*********************************************************************
1349 char * CDECL
MSVCRT__ecvt( double number
, int ndigits
, int *decpt
, int *sign
)
1352 thread_data_t
*data
= msvcrt_get_thread_data();
1353 /* FIXME: check better for overflow (native supports over 300 chars) */
1354 ndigits
= min( ndigits
, 80 - 7); /* 7 : space for dec point, 1 for "e",
1355 * 4 for exponent and one for
1356 * terminating '\0' */
1357 if (!data
->efcvt_buffer
)
1358 data
->efcvt_buffer
= MSVCRT_malloc( 80 ); /* ought to be enough */
1365 /* handle cases with zero ndigits or less */
1367 if( prec
< 1) prec
= 2;
1368 len
= snprintf(data
->efcvt_buffer
, 80, "%.*le", prec
- 1, number
);
1369 /* take the decimal "point away */
1371 memmove( data
->efcvt_buffer
+ 1, data
->efcvt_buffer
+ 2, len
- 1 );
1372 /* take the exponential "e" out */
1373 data
->efcvt_buffer
[ prec
] = '\0';
1374 /* read the exponent */
1375 sscanf( data
->efcvt_buffer
+ prec
+ 1, "%d", decpt
);
1377 /* adjust for some border cases */
1378 if( data
->efcvt_buffer
[0] == '0')/* value is zero */
1380 /* handle cases with zero ndigits or less */
1382 if( data
->efcvt_buffer
[ 0] >= '5')
1384 data
->efcvt_buffer
[ 0] = '\0';
1386 TRACE("out=\"%s\"\n",data
->efcvt_buffer
);
1387 return data
->efcvt_buffer
;
1390 /*********************************************************************
1391 * _ecvt_s (MSVCRT.@)
1393 int CDECL
MSVCRT__ecvt_s( char *buffer
, MSVCRT_size_t length
, double number
, int ndigits
, int *decpt
, int *sign
)
1397 const char infret
[] = "1#INF";
1399 if (!MSVCRT_CHECK_PMT(buffer
!= NULL
)) return MSVCRT_EINVAL
;
1400 if (!MSVCRT_CHECK_PMT(decpt
!= NULL
)) return MSVCRT_EINVAL
;
1401 if (!MSVCRT_CHECK_PMT(sign
!= NULL
)) return MSVCRT_EINVAL
;
1402 if (!MSVCRT_CHECK_PMT_ERR( length
> 2, MSVCRT_ERANGE
)) return MSVCRT_ERANGE
;
1403 if (!MSVCRT_CHECK_PMT_ERR(ndigits
< (int)length
- 1, MSVCRT_ERANGE
)) return MSVCRT_ERANGE
;
1405 /* special case - inf */
1406 if(number
== HUGE_VAL
|| number
== -HUGE_VAL
)
1408 memset(buffer
, '0', ndigits
);
1409 memcpy(buffer
, infret
, min(ndigits
, sizeof(infret
) - 1 ) );
1410 buffer
[ndigits
] = '\0';
1412 if(number
== -HUGE_VAL
)
1418 /* handle cases with zero ndigits or less */
1420 if( prec
< 1) prec
= 2;
1421 result
= MSVCRT_malloc(prec
+ 7);
1428 len
= snprintf(result
, prec
+ 7, "%.*le", prec
- 1, number
);
1429 /* take the decimal "point away */
1431 memmove( result
+ 1, result
+ 2, len
- 1 );
1432 /* take the exponential "e" out */
1433 result
[ prec
] = '\0';
1434 /* read the exponent */
1435 sscanf( result
+ prec
+ 1, "%d", decpt
);
1437 /* adjust for some border cases */
1438 if( result
[0] == '0')/* value is zero */
1440 /* handle cases with zero ndigits or less */
1442 if( result
[ 0] >= '5')
1446 memcpy( buffer
, result
, max(ndigits
+ 1, 1) );
1447 MSVCRT_free( result
);
1451 /***********************************************************************
1454 char * CDECL
MSVCRT__fcvt( double number
, int ndigits
, int *decpt
, int *sign
)
1456 thread_data_t
*data
= msvcrt_get_thread_data();
1457 int stop
, dec1
, dec2
;
1458 char *ptr1
, *ptr2
, *first
;
1459 char buf
[80]; /* ought to be enough */
1461 if (!data
->efcvt_buffer
)
1462 data
->efcvt_buffer
= MSVCRT_malloc( 80 ); /* ought to be enough */
1470 snprintf(buf
, 80, "%.*f", ndigits
< 0 ? 0 : ndigits
, number
);
1472 ptr2
= data
->efcvt_buffer
;
1477 /* For numbers below the requested resolution, work out where
1478 the decimal point will be rather than finding it in the string */
1479 if (number
< 1.0 && number
> 0.0) {
1480 dec2
= log10(number
+ 1e-10);
1481 if (-dec2
<= ndigits
) dec2
= 0;
1484 /* If requested digits is zero or less, we will need to truncate
1485 * the returned string */
1487 stop
= strlen(buf
) + ndigits
;
1492 while (*ptr1
== '0') ptr1
++; /* Skip leading zeroes */
1493 while (*ptr1
!= '\0' && *ptr1
!= '.') {
1494 if (!first
) first
= ptr2
;
1495 if ((ptr1
- buf
) < stop
) {
1506 while (*ptr1
== '0') { /* Process leading zeroes */
1511 while (*ptr1
!= '\0') {
1512 if (!first
) first
= ptr2
;
1519 /* We never found a non-zero digit, then our number is either
1520 * smaller than the requested precision, or 0.0 */
1525 first
= data
->efcvt_buffer
;
1530 *decpt
= dec2
? dec2
: dec1
;
1534 /***********************************************************************
1535 * _fcvt_s (MSVCRT.@)
1537 int CDECL
MSVCRT__fcvt_s(char* outbuffer
, MSVCRT_size_t size
, double number
, int ndigits
, int *decpt
, int *sign
)
1539 int stop
, dec1
, dec2
;
1540 char *ptr1
, *ptr2
, *first
;
1541 char buf
[80]; /* ought to be enough */
1543 if (!outbuffer
|| !decpt
|| !sign
|| size
== 0)
1545 *MSVCRT__errno() = MSVCRT_EINVAL
;
1546 return MSVCRT_EINVAL
;
1555 snprintf(buf
, 80, "%.*f", ndigits
< 0 ? 0 : ndigits
, number
);
1562 /* For numbers below the requested resolution, work out where
1563 the decimal point will be rather than finding it in the string */
1564 if (number
< 1.0 && number
> 0.0) {
1565 dec2
= log10(number
+ 1e-10);
1566 if (-dec2
<= ndigits
) dec2
= 0;
1569 /* If requested digits is zero or less, we will need to truncate
1570 * the returned string */
1572 stop
= strlen(buf
) + ndigits
;
1577 while (*ptr1
== '0') ptr1
++; /* Skip leading zeroes */
1578 while (*ptr1
!= '\0' && *ptr1
!= '.') {
1579 if (!first
) first
= ptr2
;
1580 if ((ptr1
- buf
) < stop
) {
1594 while (*ptr1
== '0') { /* Process leading zeroes */
1595 if (number
== 0.0 && size
> 1) {
1603 while (*ptr1
!= '\0') {
1604 if (!first
) first
= ptr2
;
1614 /* We never found a non-zero digit, then our number is either
1615 * smaller than the requested precision, or 0.0 */
1616 if (!first
&& (number
<= 0.0))
1619 *decpt
= dec2
? dec2
: dec1
;
1623 /***********************************************************************
1626 char * CDECL
MSVCRT__gcvt( double number
, int ndigit
, char *buff
)
1629 *MSVCRT__errno() = MSVCRT_EINVAL
;
1634 *MSVCRT__errno() = MSVCRT_ERANGE
;
1638 MSVCRT_sprintf(buff
, "%.*g", ndigit
, number
);
1642 /***********************************************************************
1643 * _gcvt_s (MSVCRT.@)
1645 int CDECL
MSVCRT__gcvt_s(char *buff
, MSVCRT_size_t size
, double number
, int digits
)
1650 *MSVCRT__errno() = MSVCRT_EINVAL
;
1651 return MSVCRT_EINVAL
;
1654 if( digits
<0 || digits
>=size
) {
1658 *MSVCRT__errno() = MSVCRT_ERANGE
;
1659 return MSVCRT_ERANGE
;
1662 len
= MSVCRT__scprintf("%.*g", digits
, number
);
1665 *MSVCRT__errno() = MSVCRT_ERANGE
;
1666 return MSVCRT_ERANGE
;
1669 MSVCRT_sprintf(buff
, "%.*g", digits
, number
);
1673 #include <stdlib.h> /* div_t, ldiv_t */
1675 /*********************************************************************
1678 * [i386] Windows binary compatible - returns the struct in eax/edx.
1681 unsigned __int64 CDECL
MSVCRT_div(int num
, int denom
)
1683 div_t dt
= div(num
,denom
);
1684 return ((unsigned __int64
)dt
.rem
<< 32) | (unsigned int)dt
.quot
;
1687 /*********************************************************************
1690 * [!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
1692 MSVCRT_div_t CDECL
MSVCRT_div(int num
, int denom
)
1694 div_t dt
= div(num
,denom
);
1702 #endif /* ifdef __i386__ */
1705 /*********************************************************************
1708 * [i386] Windows binary compatible - returns the struct in eax/edx.
1711 unsigned __int64 CDECL
MSVCRT_ldiv(MSVCRT_long num
, MSVCRT_long denom
)
1713 ldiv_t ldt
= ldiv(num
,denom
);
1714 return ((unsigned __int64
)ldt
.rem
<< 32) | (MSVCRT_ulong
)ldt
.quot
;
1717 /*********************************************************************
1720 * [!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
1722 MSVCRT_ldiv_t CDECL
MSVCRT_ldiv(MSVCRT_long num
, MSVCRT_long denom
)
1724 ldiv_t result
= ldiv(num
,denom
);
1727 ret
.quot
= result
.quot
;
1728 ret
.rem
= result
.rem
;
1732 #endif /* ifdef __i386__ */
1736 /*********************************************************************
1737 * _adjust_fdiv (MSVCRT.@)
1738 * Used by the MSVC compiler to work around the Pentium FDIV bug.
1740 int MSVCRT__adjust_fdiv
= 0;
1742 /***********************************************************************
1743 * _adj_fdiv_m16i (MSVCRT.@)
1746 * I _think_ this function is intended to work around the Pentium
1749 void __stdcall
_adj_fdiv_m16i( short arg
)
1751 TRACE("(): stub\n");
1754 /***********************************************************************
1755 * _adj_fdiv_m32 (MSVCRT.@)
1758 * I _think_ this function is intended to work around the Pentium
1761 void __stdcall
_adj_fdiv_m32( unsigned int arg
)
1763 TRACE("(): stub\n");
1766 /***********************************************************************
1767 * _adj_fdiv_m32i (MSVCRT.@)
1770 * I _think_ this function is intended to work around the Pentium
1773 void __stdcall
_adj_fdiv_m32i( int arg
)
1775 TRACE("(): stub\n");
1778 /***********************************************************************
1779 * _adj_fdiv_m64 (MSVCRT.@)
1782 * I _think_ this function is intended to work around the Pentium
1785 void __stdcall
_adj_fdiv_m64( unsigned __int64 arg
)
1787 TRACE("(): stub\n");
1790 /***********************************************************************
1791 * _adj_fdiv_r (MSVCRT.@)
1793 * This function is likely to have the wrong number of arguments.
1796 * I _think_ this function is intended to work around the Pentium
1799 void _adj_fdiv_r(void)
1801 TRACE("(): stub\n");
1804 /***********************************************************************
1805 * _adj_fdivr_m16i (MSVCRT.@)
1808 * I _think_ this function is intended to work around the Pentium
1811 void __stdcall
_adj_fdivr_m16i( short arg
)
1813 TRACE("(): stub\n");
1816 /***********************************************************************
1817 * _adj_fdivr_m32 (MSVCRT.@)
1820 * I _think_ this function is intended to work around the Pentium
1823 void __stdcall
_adj_fdivr_m32( unsigned int arg
)
1825 TRACE("(): stub\n");
1828 /***********************************************************************
1829 * _adj_fdivr_m32i (MSVCRT.@)
1832 * I _think_ this function is intended to work around the Pentium
1835 void __stdcall
_adj_fdivr_m32i( int arg
)
1837 TRACE("(): stub\n");
1840 /***********************************************************************
1841 * _adj_fdivr_m64 (MSVCRT.@)
1844 * I _think_ this function is intended to work around the Pentium
1847 void __stdcall
_adj_fdivr_m64( unsigned __int64 arg
)
1849 TRACE("(): stub\n");
1852 /***********************************************************************
1853 * _adj_fpatan (MSVCRT.@)
1855 * This function is likely to have the wrong number of arguments.
1858 * I _think_ this function is intended to work around the Pentium
1861 void _adj_fpatan(void)
1863 TRACE("(): stub\n");
1866 /***********************************************************************
1867 * _adj_fprem (MSVCRT.@)
1869 * This function is likely to have the wrong number of arguments.
1872 * I _think_ this function is intended to work around the Pentium
1875 void _adj_fprem(void)
1877 TRACE("(): stub\n");
1880 /***********************************************************************
1881 * _adj_fprem1 (MSVCRT.@)
1883 * This function is likely to have the wrong number of arguments.
1886 * I _think_ this function is intended to work around the Pentium
1889 void _adj_fprem1(void)
1891 TRACE("(): stub\n");
1894 /***********************************************************************
1895 * _adj_fptan (MSVCRT.@)
1897 * This function is likely to have the wrong number of arguments.
1900 * I _think_ this function is intended to work around the Pentium
1903 void _adj_fptan(void)
1905 TRACE("(): stub\n");
1908 /***********************************************************************
1909 * _safe_fdiv (MSVCRT.@)
1911 * This function is likely to have the wrong number of arguments.
1914 * I _think_ this function is intended to work around the Pentium
1917 void _safe_fdiv(void)
1919 TRACE("(): stub\n");
1922 /***********************************************************************
1923 * _safe_fdivr (MSVCRT.@)
1925 * This function is likely to have the wrong number of arguments.
1928 * I _think_ this function is intended to work around the Pentium
1931 void _safe_fdivr(void)
1933 TRACE("(): stub\n");
1936 /***********************************************************************
1937 * _safe_fprem (MSVCRT.@)
1939 * This function is likely to have the wrong number of arguments.
1942 * I _think_ this function is intended to work around the Pentium
1945 void _safe_fprem(void)
1947 TRACE("(): stub\n");
1950 /***********************************************************************
1951 * _safe_fprem1 (MSVCRT.@)
1954 * This function is likely to have the wrong number of arguments.
1957 * I _think_ this function is intended to work around the Pentium
1960 void _safe_fprem1(void)
1962 TRACE("(): stub\n");
1965 /***********************************************************************
1966 * __libm_sse2_acos (MSVCRT.@)
1968 void __cdecl
__libm_sse2_acos(void)
1971 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
1973 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
1976 /***********************************************************************
1977 * __libm_sse2_acosf (MSVCRT.@)
1979 void __cdecl
__libm_sse2_acosf(void)
1982 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
1984 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
1987 /***********************************************************************
1988 * __libm_sse2_asin (MSVCRT.@)
1990 void __cdecl
__libm_sse2_asin(void)
1993 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
1995 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
1998 /***********************************************************************
1999 * __libm_sse2_asinf (MSVCRT.@)
2001 void __cdecl
__libm_sse2_asinf(void)
2004 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2006 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2009 /***********************************************************************
2010 * __libm_sse2_atan (MSVCRT.@)
2012 void __cdecl
__libm_sse2_atan(void)
2015 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2017 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2020 /***********************************************************************
2021 * __libm_sse2_atan2 (MSVCRT.@)
2023 void __cdecl
__libm_sse2_atan2(void)
2026 __asm__
__volatile__( "movq %%xmm0,%0; movq %%xmm1,%1 " : "=m" (d1
), "=m" (d2
) );
2027 d1
= atan2( d1
, d2
);
2028 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d1
) );
2031 /***********************************************************************
2032 * __libm_sse2_atanf (MSVCRT.@)
2034 void __cdecl
__libm_sse2_atanf(void)
2037 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2039 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2042 /***********************************************************************
2043 * __libm_sse2_cos (MSVCRT.@)
2045 void __cdecl
__libm_sse2_cos(void)
2048 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2050 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2053 /***********************************************************************
2054 * __libm_sse2_cosf (MSVCRT.@)
2056 void __cdecl
__libm_sse2_cosf(void)
2059 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2061 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2064 /***********************************************************************
2065 * __libm_sse2_exp (MSVCRT.@)
2067 void __cdecl
__libm_sse2_exp(void)
2070 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2072 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2075 /***********************************************************************
2076 * __libm_sse2_expf (MSVCRT.@)
2078 void __cdecl
__libm_sse2_expf(void)
2081 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2083 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2086 /***********************************************************************
2087 * __libm_sse2_log (MSVCRT.@)
2089 void __cdecl
__libm_sse2_log(void)
2092 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2094 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2097 /***********************************************************************
2098 * __libm_sse2_log10 (MSVCRT.@)
2100 void __cdecl
__libm_sse2_log10(void)
2103 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2105 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2108 /***********************************************************************
2109 * __libm_sse2_log10f (MSVCRT.@)
2111 void __cdecl
__libm_sse2_log10f(void)
2114 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2116 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2119 /***********************************************************************
2120 * __libm_sse2_logf (MSVCRT.@)
2122 void __cdecl
__libm_sse2_logf(void)
2125 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2127 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2130 /***********************************************************************
2131 * __libm_sse2_pow (MSVCRT.@)
2133 void __cdecl
__libm_sse2_pow(void)
2136 __asm__
__volatile__( "movq %%xmm0,%0; movq %%xmm1,%1 " : "=m" (d1
), "=m" (d2
) );
2138 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d1
) );
2141 /***********************************************************************
2142 * __libm_sse2_powf (MSVCRT.@)
2144 void __cdecl
__libm_sse2_powf(void)
2147 __asm__
__volatile__( "movd %%xmm0,%0; movd %%xmm1,%1" : "=g" (f1
), "=g" (f2
) );
2148 f1
= powf( f1
, f2
);
2149 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f1
) );
2152 /***********************************************************************
2153 * __libm_sse2_sin (MSVCRT.@)
2155 void __cdecl
__libm_sse2_sin(void)
2158 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2160 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2163 /***********************************************************************
2164 * __libm_sse2_sinf (MSVCRT.@)
2166 void __cdecl
__libm_sse2_sinf(void)
2169 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2171 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2174 /***********************************************************************
2175 * __libm_sse2_tan (MSVCRT.@)
2177 void __cdecl
__libm_sse2_tan(void)
2180 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2182 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2185 /***********************************************************************
2186 * __libm_sse2_tanf (MSVCRT.@)
2188 void __cdecl
__libm_sse2_tanf(void)
2191 __asm__
__volatile__( "movd %%xmm0,%0" : "=g" (f
) );
2193 __asm__
__volatile__( "movd %0,%%xmm0" : : "g" (f
) );
2196 /***********************************************************************
2197 * __libm_sse2_sqrt_precise (MSVCR110.@)
2199 void __cdecl
__libm_sse2_sqrt_precise(void)
2202 __asm__
__volatile__( "movq %%xmm0,%0" : "=m" (d
) );
2204 __asm__
__volatile__( "movq %0,%%xmm0" : : "m" (d
) );
2207 #endif /* __i386__ */