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 (*MSVCRT_matherr_func)(struct MSVCRT__exception *);
52 static MSVCRT_matherr_func MSVCRT_default_matherr_func = NULL;
54 /*********************************************************************
55 * MSVCRT_acos (MSVCRT.@)
57 double CDECL MSVCRT_acos( double x )
59 if (x < -1.0 || x > 1.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
60 /* glibc implements acos() as the FPU equivalent of atan2(sqrt(1 - x ^ 2), x).
61 * asin() uses a similar construction. This is bad because as x gets nearer to
62 * 1 the error in the expression "1 - x^2" can get relatively large due to
63 * cancellation. The sqrt() makes things worse. A safer way to calculate
64 * acos() is to use atan2(sqrt((1 - x) * (1 + x)), x). */
65 return atan2(sqrt((1 - x) * (1 + x)), x);
68 /*********************************************************************
69 * MSVCRT_asin (MSVCRT.@)
71 double CDECL MSVCRT_asin( double x )
73 if (x < -1.0 || x > 1.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
74 return atan2(x, sqrt((1 - x) * (1 + x)));
77 /*********************************************************************
78 * MSVCRT_atan (MSVCRT.@)
80 double CDECL MSVCRT_atan( double x )
82 if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
86 /*********************************************************************
87 * MSVCRT_atan2 (MSVCRT.@)
89 double CDECL MSVCRT_atan2( double x, double y )
91 if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
95 /*********************************************************************
96 * MSVCRT_cos (MSVCRT.@)
98 double CDECL MSVCRT_cos( double x )
100 if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
104 /*********************************************************************
105 * MSVCRT_cosh (MSVCRT.@)
107 double CDECL MSVCRT_cosh( double x )
109 if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
113 /*********************************************************************
114 * MSVCRT_exp (MSVCRT.@)
116 double CDECL MSVCRT_exp( double x )
118 if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
122 /*********************************************************************
123 * MSVCRT_fmod (MSVCRT.@)
125 double CDECL MSVCRT_fmod( double x, double y )
127 if (!finite(x) || !finite(y)) *MSVCRT__errno() = MSVCRT_EDOM;
131 /*********************************************************************
132 * MSVCRT_log (MSVCRT.@)
134 double CDECL MSVCRT_log( double x)
136 if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
137 if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
141 /*********************************************************************
142 * MSVCRT_log10 (MSVCRT.@)
144 double CDECL MSVCRT_log10( double x )
146 if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
147 if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
151 /*********************************************************************
152 * MSVCRT_pow (MSVCRT.@)
154 double CDECL MSVCRT_pow( double x, double y )
156 /* FIXME: If x < 0 and y is not integral, set EDOM */
158 if (!finite(z)) *MSVCRT__errno() = MSVCRT_EDOM;
162 /*********************************************************************
163 * MSVCRT_sin (MSVCRT.@)
165 double CDECL MSVCRT_sin( double x )
167 if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
171 /*********************************************************************
172 * MSVCRT_sinh (MSVCRT.@)
174 double CDECL MSVCRT_sinh( double x )
176 if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
180 /*********************************************************************
181 * MSVCRT_sqrt (MSVCRT.@)
183 double CDECL MSVCRT_sqrt( double x )
185 if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
189 /*********************************************************************
190 * MSVCRT_tan (MSVCRT.@)
192 double CDECL MSVCRT_tan( double x )
194 if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
198 /*********************************************************************
199 * MSVCRT_tanh (MSVCRT.@)
201 double CDECL MSVCRT_tanh( double x )
203 if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
208 #if defined(__GNUC__) && defined(__i386__)
210 #define FPU_DOUBLE(var) double var; \
211 __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var) : )
212 #define FPU_DOUBLES(var1,var2) double var1,var2; \
213 __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var2) : ); \
214 __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var1) : )
216 /*********************************************************************
219 double CDECL _CIacos(void)
222 return MSVCRT_acos(x);
225 /*********************************************************************
228 double CDECL _CIasin(void)
231 return MSVCRT_asin(x);
234 /*********************************************************************
237 double CDECL _CIatan(void)
240 return MSVCRT_atan(x);
243 /*********************************************************************
244 * _CIatan2 (MSVCRT.@)
246 double CDECL _CIatan2(void)
249 return MSVCRT_atan2(x,y);
252 /*********************************************************************
255 double CDECL _CIcos(void)
258 return MSVCRT_cos(x);
261 /*********************************************************************
264 double CDECL _CIcosh(void)
267 return MSVCRT_cosh(x);
270 /*********************************************************************
273 double CDECL _CIexp(void)
276 return MSVCRT_exp(x);
279 /*********************************************************************
282 double CDECL _CIfmod(void)
285 return MSVCRT_fmod(x,y);
288 /*********************************************************************
291 double CDECL _CIlog(void)
294 return MSVCRT_log(x);
297 /*********************************************************************
298 * _CIlog10 (MSVCRT.@)
300 double CDECL _CIlog10(void)
303 return MSVCRT_log10(x);
306 /*********************************************************************
309 double CDECL _CIpow(void)
312 return MSVCRT_pow(x,y);
315 /*********************************************************************
318 double CDECL _CIsin(void)
321 return MSVCRT_sin(x);
324 /*********************************************************************
327 double CDECL _CIsinh(void)
330 return MSVCRT_sinh(x);
333 /*********************************************************************
336 double CDECL _CIsqrt(void)
339 return MSVCRT_sqrt(x);
342 /*********************************************************************
345 double CDECL _CItan(void)
348 return MSVCRT_tan(x);
351 /*********************************************************************
354 double CDECL _CItanh(void)
357 return MSVCRT_tanh(x);
360 #endif /* defined(__GNUC__) && defined(__i386__) */
362 /*********************************************************************
363 * _fpclass (MSVCRT.@)
365 int CDECL _fpclass(double num)
367 #if defined(HAVE_FPCLASS) || defined(fpclass)
368 switch (fpclass( num ))
371 case FP_SNAN: return MSVCRT__FPCLASS_SNAN;
374 case FP_QNAN: return MSVCRT__FPCLASS_QNAN;
377 case FP_NINF: return MSVCRT__FPCLASS_NINF;
380 case FP_PINF: return MSVCRT__FPCLASS_PINF;
383 case FP_NDENORM: return MSVCRT__FPCLASS_ND;
386 case FP_PDENORM: return MSVCRT__FPCLASS_PD;
389 case FP_NZERO: return MSVCRT__FPCLASS_NZ;
392 case FP_PZERO: return MSVCRT__FPCLASS_PZ;
395 case FP_NNORM: return MSVCRT__FPCLASS_NN;
398 case FP_PNORM: return MSVCRT__FPCLASS_PN;
400 default: return MSVCRT__FPCLASS_PN;
402 #elif defined (fpclassify)
403 switch (fpclassify( num ))
405 case FP_NAN: return MSVCRT__FPCLASS_QNAN;
406 case FP_INFINITE: return signbit(num) ? MSVCRT__FPCLASS_NINF : MSVCRT__FPCLASS_PINF;
407 case FP_SUBNORMAL: return signbit(num) ?MSVCRT__FPCLASS_ND : MSVCRT__FPCLASS_PD;
408 case FP_ZERO: return signbit(num) ? MSVCRT__FPCLASS_NZ : MSVCRT__FPCLASS_PZ;
410 return signbit(num) ? MSVCRT__FPCLASS_NN : MSVCRT__FPCLASS_PN;
413 return MSVCRT__FPCLASS_QNAN;
414 return num == 0.0 ? MSVCRT__FPCLASS_PZ : (num < 0 ? MSVCRT__FPCLASS_NN : MSVCRT__FPCLASS_PN);
418 /*********************************************************************
421 unsigned int CDECL _rotl(unsigned int num, int shift)
424 return (num << shift) | (num >> (32-shift));
427 /*********************************************************************
430 double CDECL _logb(double num)
432 if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
436 /*********************************************************************
439 MSVCRT_ulong CDECL MSVCRT__lrotl(MSVCRT_ulong num, int shift)
442 return (num << shift) | (num >> (32-shift));
445 /*********************************************************************
448 MSVCRT_ulong CDECL MSVCRT__lrotr(MSVCRT_ulong num, int shift)
451 return (num >> shift) | (num << (32-shift));
454 /*********************************************************************
457 unsigned int CDECL _rotr(unsigned int num, int shift)
460 return (num >> shift) | (num << (32-shift));
463 /*********************************************************************
466 double CDECL MSVCRT__scalb(double num, MSVCRT_long power)
468 if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
469 return ldexp(num, power);
472 /*********************************************************************
475 double CDECL _hypot(double x, double y)
477 /* FIXME: errno handling */
478 return hypot( x, y );
481 /*********************************************************************
484 double CDECL MSVCRT_ceil( double x )
489 /*********************************************************************
492 double CDECL MSVCRT_floor( double x )
497 /*********************************************************************
500 double CDECL MSVCRT_fabs( double x )
505 /*********************************************************************
508 double CDECL MSVCRT_frexp( double x, int *exp )
510 return frexp( x, exp );
513 /*********************************************************************
516 double CDECL MSVCRT_modf( double x, double *iptr )
518 return modf( x, iptr );
521 /*********************************************************************
522 * _matherr (MSVCRT.@)
524 int CDECL MSVCRT__matherr(struct MSVCRT__exception *e)
527 TRACE("(%p = %d, %s, %g %g %g)\n",e, e->type, e->name, e->arg1, e->arg2,
531 if (MSVCRT_default_matherr_func)
532 return MSVCRT_default_matherr_func(e);
533 ERR(":Unhandled math error!\n");
537 /*********************************************************************
538 * __setusermatherr (MSVCRT.@)
540 void CDECL MSVCRT___setusermatherr(MSVCRT_matherr_func func)
542 MSVCRT_default_matherr_func = func;
543 TRACE(":new matherr handler %p\n", func);
546 /**********************************************************************
547 * _statusfp (MSVCRT.@)
549 unsigned int CDECL _statusfp(void)
551 unsigned int retVal = 0;
552 #if defined(__GNUC__) && defined(__i386__)
555 __asm__ __volatile__( "fstsw %0" : "=m" (fpword) : );
556 if (fpword & 0x1) retVal |= MSVCRT__SW_INVALID;
557 if (fpword & 0x2) retVal |= MSVCRT__SW_DENORMAL;
558 if (fpword & 0x4) retVal |= MSVCRT__SW_ZERODIVIDE;
559 if (fpword & 0x8) retVal |= MSVCRT__SW_OVERFLOW;
560 if (fpword & 0x10) retVal |= MSVCRT__SW_UNDERFLOW;
561 if (fpword & 0x20) retVal |= MSVCRT__SW_INEXACT;
563 FIXME(":Not implemented!\n");
568 /*********************************************************************
569 * _clearfp (MSVCRT.@)
571 unsigned int CDECL _clearfp(void)
573 unsigned int retVal = _statusfp();
574 #if defined(__GNUC__) && defined(__i386__)
575 __asm__ __volatile__( "fnclex" );
577 FIXME(":Not Implemented\n");
582 /*********************************************************************
583 * __fpecode (MSVCRT.@)
585 int * CDECL __fpecode(void)
587 return &msvcrt_get_thread_data()->fpecode;
590 /*********************************************************************
593 double CDECL MSVCRT_ldexp(double num, MSVCRT_long exp)
595 double z = ldexp(num,exp);
598 *MSVCRT__errno() = MSVCRT_ERANGE;
599 else if (z == 0 && signbit(z))
600 z = 0.0; /* Convert -0 -> +0 */
604 /*********************************************************************
607 double CDECL MSVCRT__cabs(struct MSVCRT__complex num)
609 return sqrt(num.x * num.x + num.y * num.y);
612 /*********************************************************************
613 * _chgsign (MSVCRT.@)
615 double CDECL _chgsign(double num)
617 /* FIXME: +-infinity,Nan not tested */
621 /*********************************************************************
622 * _control87 (MSVCRT.@)
624 unsigned int CDECL _control87(unsigned int newval, unsigned int mask)
626 #if defined(__GNUC__) && defined(__i386__)
627 unsigned int fpword = 0;
628 unsigned int flags = 0;
630 TRACE("(%08x, %08x): Called\n", newval, mask);
632 /* Get fp control word */
633 __asm__ __volatile__( "fstcw %0" : "=m" (fpword) : );
635 TRACE("Control word before : %08x\n", fpword);
637 /* Convert into mask constants */
638 if (fpword & 0x1) flags |= MSVCRT__EM_INVALID;
639 if (fpword & 0x2) flags |= MSVCRT__EM_DENORMAL;
640 if (fpword & 0x4) flags |= MSVCRT__EM_ZERODIVIDE;
641 if (fpword & 0x8) flags |= MSVCRT__EM_OVERFLOW;
642 if (fpword & 0x10) flags |= MSVCRT__EM_UNDERFLOW;
643 if (fpword & 0x20) flags |= MSVCRT__EM_INEXACT;
644 switch(fpword & 0xC00) {
645 case 0xC00: flags |= MSVCRT__RC_UP|MSVCRT__RC_DOWN; break;
646 case 0x800: flags |= MSVCRT__RC_UP; break;
647 case 0x400: flags |= MSVCRT__RC_DOWN; break;
649 switch(fpword & 0x300) {
650 case 0x0: flags |= MSVCRT__PC_24; break;
651 case 0x200: flags |= MSVCRT__PC_53; break;
652 case 0x300: flags |= MSVCRT__PC_64; break;
654 if (fpword & 0x1000) flags |= MSVCRT__IC_AFFINE;
656 /* Mask with parameters */
657 flags = (flags & ~mask) | (newval & mask);
659 /* Convert (masked) value back to fp word */
661 if (flags & MSVCRT__EM_INVALID) fpword |= 0x1;
662 if (flags & MSVCRT__EM_DENORMAL) fpword |= 0x2;
663 if (flags & MSVCRT__EM_ZERODIVIDE) fpword |= 0x4;
664 if (flags & MSVCRT__EM_OVERFLOW) fpword |= 0x8;
665 if (flags & MSVCRT__EM_UNDERFLOW) fpword |= 0x10;
666 if (flags & MSVCRT__EM_INEXACT) fpword |= 0x20;
667 switch(flags & (MSVCRT__RC_UP | MSVCRT__RC_DOWN)) {
668 case MSVCRT__RC_UP|MSVCRT__RC_DOWN: fpword |= 0xC00; break;
669 case MSVCRT__RC_UP: fpword |= 0x800; break;
670 case MSVCRT__RC_DOWN: fpword |= 0x400; break;
672 switch (flags & (MSVCRT__PC_24 | MSVCRT__PC_53)) {
673 case MSVCRT__PC_64: fpword |= 0x300; break;
674 case MSVCRT__PC_53: fpword |= 0x200; break;
675 case MSVCRT__PC_24: fpword |= 0x0; break;
677 if (flags & MSVCRT__IC_AFFINE) fpword |= 0x1000;
679 TRACE("Control word after : %08x\n", fpword);
681 /* Put fp control word */
682 __asm__ __volatile__( "fldcw %0" : : "m" (fpword) );
686 FIXME(":Not Implemented!\n");
691 /*********************************************************************
692 * _controlfp (MSVCRT.@)
694 unsigned int CDECL _controlfp(unsigned int newval, unsigned int mask)
697 return _control87( newval, mask & ~MSVCRT__EM_DENORMAL );
699 FIXME(":Not Implemented!\n");
704 /*********************************************************************
705 * _controlfp_s (MSVCRT.@)
707 int CDECL _controlfp_s(unsigned int *cur, unsigned int newval, unsigned int mask)
712 FIXME("(%p %u %u) semi-stub\n", cur, newval, mask);
714 flags = _control87( newval, mask & ~MSVCRT__EM_DENORMAL );
721 FIXME(":Not Implemented!\n");
726 /*********************************************************************
727 * _copysign (MSVCRT.@)
729 double CDECL _copysign(double num, double sign)
731 /* FIXME: Behaviour for Nan/Inf? */
733 return num < 0.0 ? num : -num;
734 return num < 0.0 ? -num : num;
737 /*********************************************************************
740 int CDECL _finite(double num)
742 return (finite(num)?1:0); /* See comment for _isnan() */
745 /*********************************************************************
746 * _fpreset (MSVCRT.@)
748 void CDECL _fpreset(void)
750 #if defined(__GNUC__) && defined(__i386__)
751 __asm__ __volatile__( "fninit" );
753 FIXME(":Not Implemented!\n");
757 /*********************************************************************
760 INT CDECL _isnan(double num)
762 /* Some implementations return -1 for true(glibc), msvcrt/crtdll return 1.
763 * Do the same, as the result may be used in calculations
765 return isnan(num) ? 1 : 0;
768 /*********************************************************************
771 double CDECL _j0(double num)
773 /* FIXME: errno handling */
777 /*********************************************************************
780 double CDECL _j1(double num)
782 /* FIXME: errno handling */
786 /*********************************************************************
789 double CDECL _jn(int n, double num)
791 /* FIXME: errno handling */
795 /*********************************************************************
798 double CDECL _y0(double num)
801 if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
803 if (_fpclass(retval) == MSVCRT__FPCLASS_NINF)
805 *MSVCRT__errno() = MSVCRT_EDOM;
811 /*********************************************************************
814 double CDECL _y1(double num)
817 if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
819 if (_fpclass(retval) == MSVCRT__FPCLASS_NINF)
821 *MSVCRT__errno() = MSVCRT_EDOM;
827 /*********************************************************************
830 double CDECL _yn(int order, double num)
833 if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
834 retval = yn(order,num);
835 if (_fpclass(retval) == MSVCRT__FPCLASS_NINF)
837 *MSVCRT__errno() = MSVCRT_EDOM;
843 /*********************************************************************
844 * _nextafter (MSVCRT.@)
846 double CDECL _nextafter(double num, double next)
849 if (!finite(num) || !finite(next)) *MSVCRT__errno() = MSVCRT_EDOM;
850 retval = nextafter(num,next);
854 /*********************************************************************
857 char * CDECL _ecvt( double number, int ndigits, int *decpt, int *sign )
860 thread_data_t *data = msvcrt_get_thread_data();
861 /* FIXME: check better for overflow (native supports over 300 chars's) */
862 ndigits = min( ndigits, 80 - 7); /* 7 : space for dec point, 1 for "e",
863 * 4 for exponent and one for
864 * terminating '\0' */
865 if (!data->efcvt_buffer)
866 data->efcvt_buffer = MSVCRT_malloc( 80 ); /* ought to be enough */
873 /* handle cases with zero ndigits or less */
875 if( prec < 1) prec = 2;
876 len = snprintf(data->efcvt_buffer, 80, "%.*le", prec - 1, number);
877 /* take the decimal "point away */
879 memmove( data->efcvt_buffer + 1, data->efcvt_buffer + 2, len - 1 );
880 /* take the exponential "e" out */
881 data->efcvt_buffer[ prec] = '\0';
882 /* read the exponent */
883 sscanf( data->efcvt_buffer + prec + 1, "%d", decpt);
885 /* adjust for some border cases */
886 if( data->efcvt_buffer[0] == '0')/* value is zero */
888 /* handle cases with zero ndigits or less */
890 if( data->efcvt_buffer[ 0] >= '5')
892 data->efcvt_buffer[ 0] = '\0';
894 TRACE("out=\"%s\"\n",data->efcvt_buffer);
895 return data->efcvt_buffer;
898 /***********************************************************************
901 char * CDECL _fcvt( double number, int ndigits, int *decpt, int *sign )
903 thread_data_t *data = msvcrt_get_thread_data();
904 int stop, dec1, dec2;
905 char *ptr1, *ptr2, *first;
906 char buf[80]; /* ought to be enough */
908 if (!data->efcvt_buffer)
909 data->efcvt_buffer = MSVCRT_malloc( 80 ); /* ought to be enough */
917 snprintf(buf, 80, "%.*f", ndigits < 0 ? 0 : ndigits, number);
919 ptr2 = data->efcvt_buffer;
924 /* For numbers below the requested resolution, work out where
925 the decimal point will be rather than finding it in the string */
926 if (number < 1.0 && number > 0.0) {
927 dec2 = log10(number + 1e-10);
928 if (-dec2 <= ndigits) dec2 = 0;
931 /* If requested digits is zero or less, we will need to truncate
932 * the returned string */
934 stop = strlen(buf) + ndigits;
939 while (*ptr1 == '0') ptr1++; /* Skip leading zeroes */
940 while (*ptr1 != '\0' && *ptr1 != '.') {
941 if (!first) first = ptr2;
942 if ((ptr1 - buf) < stop) {
953 while (*ptr1 == '0') { /* Process leading zeroes */
958 while (*ptr1 != '\0') {
959 if (!first) first = ptr2;
966 /* We never found a non-zero digit, then our number is either
967 * smaller than the requested precision, or 0.0 */
972 first = data->efcvt_buffer;
977 *decpt = dec2 ? dec2 : dec1;
981 /***********************************************************************
984 * FIXME: uses both E and F.
986 char * CDECL _gcvt( double number, int ndigit, char *buff )
988 sprintf(buff, "%.*E", ndigit, number);
992 #include <stdlib.h> /* div_t, ldiv_t */
994 /*********************************************************************
997 * [i386] Windows binary compatible - returns the struct in eax/edx.
1000 unsigned __int64 CDECL MSVCRT_div(int num, int denom)
1002 div_t dt = div(num,denom);
1003 return ((unsigned __int64)dt.rem << 32) | (unsigned int)dt.quot;
1006 /*********************************************************************
1009 * [!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
1011 MSVCRT_div_t CDECL MSVCRT_div(int num, int denom)
1013 div_t dt = div(num,denom);
1021 #endif /* ifdef __i386__ */
1024 /*********************************************************************
1027 * [i386] Windows binary compatible - returns the struct in eax/edx.
1030 unsigned __int64 CDECL MSVCRT_ldiv(MSVCRT_long num, MSVCRT_long denom)
1032 ldiv_t ldt = ldiv(num,denom);
1033 return ((unsigned __int64)ldt.rem << 32) | (MSVCRT_ulong)ldt.quot;
1036 /*********************************************************************
1039 * [!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
1041 MSVCRT_ldiv_t CDECL MSVCRT_ldiv(MSVCRT_long num, MSVCRT_long denom)
1043 ldiv_t result = ldiv(num,denom);
1046 ret.quot = result.quot;
1047 ret.rem = result.rem;
1051 #endif /* ifdef __i386__ */
1055 /*********************************************************************
1056 * _adjust_fdiv (MSVCRT.@)
1057 * Used by the MSVC compiler to work around the Pentium FDIV bug.
1059 int MSVCRT__adjust_fdiv = 0;
1061 /***********************************************************************
1062 * _adj_fdiv_m16i (MSVCRT.@)
1065 * I _think_ this function is intended to work around the Pentium
1068 void __stdcall _adj_fdiv_m16i( short arg )
1070 TRACE("(): stub\n");
1073 /***********************************************************************
1074 * _adj_fdiv_m32 (MSVCRT.@)
1077 * I _think_ this function is intended to work around the Pentium
1080 void __stdcall _adj_fdiv_m32( unsigned int arg )
1082 TRACE("(): stub\n");
1085 /***********************************************************************
1086 * _adj_fdiv_m32i (MSVCRT.@)
1089 * I _think_ this function is intended to work around the Pentium
1092 void __stdcall _adj_fdiv_m32i( int arg )
1094 TRACE("(): stub\n");
1097 /***********************************************************************
1098 * _adj_fdiv_m64 (MSVCRT.@)
1101 * I _think_ this function is intended to work around the Pentium
1104 void __stdcall _adj_fdiv_m64( unsigned __int64 arg )
1106 TRACE("(): stub\n");
1109 /***********************************************************************
1110 * _adj_fdiv_r (MSVCRT.@)
1112 * This function is likely to have the wrong number of arguments.
1115 * I _think_ this function is intended to work around the Pentium
1118 void _adj_fdiv_r(void)
1120 TRACE("(): stub\n");
1123 /***********************************************************************
1124 * _adj_fdivr_m16i (MSVCRT.@)
1127 * I _think_ this function is intended to work around the Pentium
1130 void __stdcall _adj_fdivr_m16i( short arg )
1132 TRACE("(): stub\n");
1135 /***********************************************************************
1136 * _adj_fdivr_m32 (MSVCRT.@)
1139 * I _think_ this function is intended to work around the Pentium
1142 void __stdcall _adj_fdivr_m32( unsigned int arg )
1144 TRACE("(): stub\n");
1147 /***********************************************************************
1148 * _adj_fdivr_m32i (MSVCRT.@)
1151 * I _think_ this function is intended to work around the Pentium
1154 void __stdcall _adj_fdivr_m32i( int arg )
1156 TRACE("(): stub\n");
1159 /***********************************************************************
1160 * _adj_fdivr_m64 (MSVCRT.@)
1163 * I _think_ this function is intended to work around the Pentium
1166 void __stdcall _adj_fdivr_m64( unsigned __int64 arg )
1168 TRACE("(): stub\n");
1171 /***********************************************************************
1172 * _adj_fpatan (MSVCRT.@)
1174 * This function is likely to have the wrong number of arguments.
1177 * I _think_ this function is intended to work around the Pentium
1180 void _adj_fpatan(void)
1182 TRACE("(): stub\n");
1185 /***********************************************************************
1186 * _adj_fprem (MSVCRT.@)
1188 * This function is likely to have the wrong number of arguments.
1191 * I _think_ this function is intended to work around the Pentium
1194 void _adj_fprem(void)
1196 TRACE("(): stub\n");
1199 /***********************************************************************
1200 * _adj_fprem1 (MSVCRT.@)
1202 * This function is likely to have the wrong number of arguments.
1205 * I _think_ this function is intended to work around the Pentium
1208 void _adj_fprem1(void)
1210 TRACE("(): stub\n");
1213 /***********************************************************************
1214 * _adj_fptan (MSVCRT.@)
1216 * This function is likely to have the wrong number of arguments.
1219 * I _think_ this function is intended to work around the Pentium
1222 void _adj_fptan(void)
1224 TRACE("(): stub\n");
1227 /***********************************************************************
1228 * _safe_fdiv (MSVCRT.@)
1230 * This function is likely to have the wrong number of arguments.
1233 * I _think_ this function is intended to work around the Pentium
1236 void _safe_fdiv(void)
1238 TRACE("(): stub\n");
1241 /***********************************************************************
1242 * _safe_fdivr (MSVCRT.@)
1244 * This function is likely to have the wrong number of arguments.
1247 * I _think_ this function is intended to work around the Pentium
1250 void _safe_fdivr(void)
1252 TRACE("(): stub\n");
1255 /***********************************************************************
1256 * _safe_fprem (MSVCRT.@)
1258 * This function is likely to have the wrong number of arguments.
1261 * I _think_ this function is intended to work around the Pentium
1264 void _safe_fprem(void)
1266 TRACE("(): stub\n");
1269 /***********************************************************************
1270 * _safe_fprem1 (MSVCRT.@)
1273 * This function is likely to have the wrong number of arguments.
1276 * I _think_ this function is intended to work around the Pentium
1279 void _safe_fprem1(void)
1281 TRACE("(): stub\n");
1284 #endif /* __i386__ */