msxml3: Implement POST support with supplied body data.
[wine] / dlls / msvcrt / math.c
1 /*
2  * msvcrt.dll math functions
3  *
4  * Copyright 2000 Jon Griffiths
5  *
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.
10  *
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.
15  *
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
19  */
20 #include "config.h"
21
22 #include <stdio.h>
23 #define __USE_ISOC9X 1
24 #define __USE_ISOC99 1
25 #include <math.h>
26 #ifdef HAVE_IEEEFP_H
27 #include <ieeefp.h>
28 #endif
29
30 #include "msvcrt.h"
31
32 #include "wine/debug.h"
33
34 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
35
36 #ifndef HAVE_FINITE
37 #ifndef finite /* Could be a macro */
38 #ifdef isfinite
39 #define finite(x) isfinite(x)
40 #else
41 #define finite(x) (!isnan(x)) /* At least catch some cases */
42 #endif
43 #endif
44 #endif
45
46 #ifndef signbit
47 #define signbit(x) 0
48 #endif
49
50 typedef int (CDECL *MSVCRT_matherr_func)(struct MSVCRT__exception *);
51
52 static MSVCRT_matherr_func MSVCRT_default_matherr_func = NULL;
53
54 /*********************************************************************
55  *      _set_SSE2_enable (MSVCRT.@)
56  */
57 int CDECL MSVCRT__set_SSE2_enable(int flag)
58 {
59     FIXME("(%x) stub\n", flag);
60     return flag;
61 }
62
63 #ifdef __x86_64__
64
65 /*********************************************************************
66  *      MSVCRT_acosf (MSVCRT.@)
67  */
68 float CDECL MSVCRT_acosf( float x )
69 {
70   if (x < -1.0 || x > 1.0 || !finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
71   /* glibc implements acos() as the FPU equivalent of atan2(sqrt(1 - x ^ 2), x).
72    * asin() uses a similar construction. This is bad because as x gets nearer to
73    * 1 the error in the expression "1 - x^2" can get relatively large due to
74    * cancellation. The sqrt() makes things worse. A safer way to calculate
75    * acos() is to use atan2(sqrt((1 - x) * (1 + x)), x). */
76   return atan2f(sqrtf((1 - x) * (1 + x)), x);
77 }
78
79 /*********************************************************************
80  *      MSVCRT_asinf (MSVCRT.@)
81  */
82 float CDECL MSVCRT_asinf( float x )
83 {
84   if (x < -1.0 || x > 1.0 || !finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
85   return atan2f(x, sqrtf((1 - x) * (1 + x)));
86 }
87
88 /*********************************************************************
89  *      MSVCRT_atanf (MSVCRT.@)
90  */
91 float CDECL MSVCRT_atanf( float x )
92 {
93   if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
94   return atanf(x);
95 }
96
97 /*********************************************************************
98  *              MSVCRT_atan2f (MSVCRT.@)
99  */
100 float CDECL MSVCRT_atan2f( float x, float y )
101 {
102   if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
103   return atan2f(x,y);
104 }
105
106 /*********************************************************************
107  *      MSVCRT_cosf (MSVCRT.@)
108  */
109 float CDECL MSVCRT_cosf( float x )
110 {
111   if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
112   return cosf(x);
113 }
114
115 /*********************************************************************
116  *      MSVCRT_coshf (MSVCRT.@)
117  */
118 float CDECL MSVCRT_coshf( float x )
119 {
120   if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
121   return coshf(x);
122 }
123
124 /*********************************************************************
125  *      MSVCRT_expf (MSVCRT.@)
126  */
127 float CDECL MSVCRT_expf( float x )
128 {
129   if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
130   return expf(x);
131 }
132
133 /*********************************************************************
134  *      MSVCRT_fmodf (MSVCRT.@)
135  */
136 float CDECL MSVCRT_fmodf( float x, float y )
137 {
138   if (!finitef(x) || !finitef(y)) *MSVCRT__errno() = MSVCRT_EDOM;
139   return fmodf(x,y);
140 }
141
142 /*********************************************************************
143  *      MSVCRT_logf (MSVCRT.@)
144  */
145 float CDECL MSVCRT_logf( float x)
146 {
147   if (x < 0.0 || !finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
148   if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
149   return logf(x);
150 }
151
152 /*********************************************************************
153  *      MSVCRT_log10f (MSVCRT.@)
154  */
155 float CDECL MSVCRT_log10f( float x )
156 {
157   if (x < 0.0 || !finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
158   if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
159   return log10f(x);
160 }
161
162 /*********************************************************************
163  *      MSVCRT_powf (MSVCRT.@)
164  */
165 float CDECL MSVCRT_powf( float x, float y )
166 {
167   /* FIXME: If x < 0 and y is not integral, set EDOM */
168   float z = powf(x,y);
169   if (!finitef(z)) *MSVCRT__errno() = MSVCRT_EDOM;
170   return z;
171 }
172
173 /*********************************************************************
174  *      MSVCRT_sinf (MSVCRT.@)
175  */
176 float CDECL MSVCRT_sinf( float x )
177 {
178   if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
179   return sinf(x);
180 }
181
182 /*********************************************************************
183  *      MSVCRT_sinhf (MSVCRT.@)
184  */
185 float CDECL MSVCRT_sinhf( float x )
186 {
187   if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
188   return sinhf(x);
189 }
190
191 /*********************************************************************
192  *      MSVCRT_sqrtf (MSVCRT.@)
193  */
194 float CDECL MSVCRT_sqrtf( float x )
195 {
196   if (x < 0.0 || !finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
197   return sqrtf(x);
198 }
199
200 /*********************************************************************
201  *      MSVCRT_tanf (MSVCRT.@)
202  */
203 float CDECL MSVCRT_tanf( float x )
204 {
205   if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
206   return tanf(x);
207 }
208
209 /*********************************************************************
210  *      MSVCRT_tanhf (MSVCRT.@)
211  */
212 float CDECL MSVCRT_tanhf( float x )
213 {
214   if (!finitef(x)) *MSVCRT__errno() = MSVCRT_EDOM;
215   return tanhf(x);
216 }
217
218 /*********************************************************************
219  *      ceilf (MSVCRT.@)
220  */
221 float CDECL MSVCRT_ceilf( float x )
222 {
223   return ceilf(x);
224 }
225
226 /*********************************************************************
227  *      floorf (MSVCRT.@)
228  */
229 float CDECL MSVCRT_floorf( float x )
230 {
231   return floorf(x);
232 }
233
234 /*********************************************************************
235  *      frexpf (MSVCRT.@)
236  */
237 float CDECL MSVCRT_frexpf( float x, int *exp )
238 {
239   return frexpf( x, exp );
240 }
241
242 /*********************************************************************
243  *      _scalbf (MSVCRT.@)
244  */
245 float CDECL MSVCRT__scalbf(float num, MSVCRT_long power)
246 {
247   if (!finitef(num)) *MSVCRT__errno() = MSVCRT_EDOM;
248   return ldexpf(num, power);
249 }
250
251 /*********************************************************************
252  *      modff (MSVCRT.@)
253  */
254 double CDECL MSVCRT_modff( float x, float *iptr )
255 {
256   return modff( x, iptr );
257 }
258
259 #endif
260
261 /*********************************************************************
262  *              MSVCRT_acos (MSVCRT.@)
263  */
264 double CDECL MSVCRT_acos( double x )
265 {
266   if (x < -1.0 || x > 1.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
267   /* glibc implements acos() as the FPU equivalent of atan2(sqrt(1 - x ^ 2), x).
268    * asin() uses a similar construction. This is bad because as x gets nearer to
269    * 1 the error in the expression "1 - x^2" can get relatively large due to
270    * cancellation. The sqrt() makes things worse. A safer way to calculate
271    * acos() is to use atan2(sqrt((1 - x) * (1 + x)), x). */
272   return atan2(sqrt((1 - x) * (1 + x)), x);
273 }
274
275 /*********************************************************************
276  *              MSVCRT_asin (MSVCRT.@)
277  */
278 double CDECL MSVCRT_asin( double x )
279 {
280   if (x < -1.0 || x > 1.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
281   return atan2(x, sqrt((1 - x) * (1 + x)));
282 }
283
284 /*********************************************************************
285  *              MSVCRT_atan (MSVCRT.@)
286  */
287 double CDECL MSVCRT_atan( double x )
288 {
289   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
290   return atan(x);
291 }
292
293 /*********************************************************************
294  *              MSVCRT_atan2 (MSVCRT.@)
295  */
296 double CDECL MSVCRT_atan2( double x, double y )
297 {
298   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
299   return atan2(x,y);
300 }
301
302 /*********************************************************************
303  *              MSVCRT_cos (MSVCRT.@)
304  */
305 double CDECL MSVCRT_cos( double x )
306 {
307   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
308   return cos(x);
309 }
310
311 /*********************************************************************
312  *              MSVCRT_cosh (MSVCRT.@)
313  */
314 double CDECL MSVCRT_cosh( double x )
315 {
316   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
317   return cosh(x);
318 }
319
320 /*********************************************************************
321  *              MSVCRT_exp (MSVCRT.@)
322  */
323 double CDECL MSVCRT_exp( double x )
324 {
325   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
326   return exp(x);
327 }
328
329 /*********************************************************************
330  *              MSVCRT_fmod (MSVCRT.@)
331  */
332 double CDECL MSVCRT_fmod( double x, double y )
333 {
334   if (!finite(x) || !finite(y)) *MSVCRT__errno() = MSVCRT_EDOM;
335   return fmod(x,y);
336 }
337
338 /*********************************************************************
339  *              MSVCRT_log (MSVCRT.@)
340  */
341 double CDECL MSVCRT_log( double x)
342 {
343   if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
344   if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
345   return log(x);
346 }
347
348 /*********************************************************************
349  *              MSVCRT_log10 (MSVCRT.@)
350  */
351 double CDECL MSVCRT_log10( double x )
352 {
353   if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
354   if (x == 0.0) *MSVCRT__errno() = MSVCRT_ERANGE;
355   return log10(x);
356 }
357
358 /*********************************************************************
359  *              MSVCRT_pow (MSVCRT.@)
360  */
361 double CDECL MSVCRT_pow( double x, double y )
362 {
363   /* FIXME: If x < 0 and y is not integral, set EDOM */
364   double z = pow(x,y);
365   if (!finite(z)) *MSVCRT__errno() = MSVCRT_EDOM;
366   return z;
367 }
368
369 /*********************************************************************
370  *              MSVCRT_sin (MSVCRT.@)
371  */
372 double CDECL MSVCRT_sin( double x )
373 {
374   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
375   return sin(x);
376 }
377
378 /*********************************************************************
379  *              MSVCRT_sinh (MSVCRT.@)
380  */
381 double CDECL MSVCRT_sinh( double x )
382 {
383   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
384   return sinh(x);
385 }
386
387 /*********************************************************************
388  *              MSVCRT_sqrt (MSVCRT.@)
389  */
390 double CDECL MSVCRT_sqrt( double x )
391 {
392   if (x < 0.0 || !finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
393   return sqrt(x);
394 }
395
396 /*********************************************************************
397  *              MSVCRT_tan (MSVCRT.@)
398  */
399 double CDECL MSVCRT_tan( double x )
400 {
401   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
402   return tan(x);
403 }
404
405 /*********************************************************************
406  *              MSVCRT_tanh (MSVCRT.@)
407  */
408 double CDECL MSVCRT_tanh( double x )
409 {
410   if (!finite(x)) *MSVCRT__errno() = MSVCRT_EDOM;
411   return tanh(x);
412 }
413
414
415 #if defined(__GNUC__) && defined(__i386__)
416
417 #define FPU_DOUBLE(var) double var; \
418   __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var) : )
419 #define FPU_DOUBLES(var1,var2) double var1,var2; \
420   __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var2) : ); \
421   __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var1) : )
422
423 /*********************************************************************
424  *              _CIacos (MSVCRT.@)
425  */
426 double CDECL _CIacos(void)
427 {
428   FPU_DOUBLE(x);
429   return MSVCRT_acos(x);
430 }
431
432 /*********************************************************************
433  *              _CIasin (MSVCRT.@)
434  */
435 double CDECL _CIasin(void)
436 {
437   FPU_DOUBLE(x);
438   return MSVCRT_asin(x);
439 }
440
441 /*********************************************************************
442  *              _CIatan (MSVCRT.@)
443  */
444 double CDECL _CIatan(void)
445 {
446   FPU_DOUBLE(x);
447   return MSVCRT_atan(x);
448 }
449
450 /*********************************************************************
451  *              _CIatan2 (MSVCRT.@)
452  */
453 double CDECL _CIatan2(void)
454 {
455   FPU_DOUBLES(x,y);
456   return MSVCRT_atan2(x,y);
457 }
458
459 /*********************************************************************
460  *              _CIcos (MSVCRT.@)
461  */
462 double CDECL _CIcos(void)
463 {
464   FPU_DOUBLE(x);
465   return MSVCRT_cos(x);
466 }
467
468 /*********************************************************************
469  *              _CIcosh (MSVCRT.@)
470  */
471 double CDECL _CIcosh(void)
472 {
473   FPU_DOUBLE(x);
474   return MSVCRT_cosh(x);
475 }
476
477 /*********************************************************************
478  *              _CIexp (MSVCRT.@)
479  */
480 double CDECL _CIexp(void)
481 {
482   FPU_DOUBLE(x);
483   return MSVCRT_exp(x);
484 }
485
486 /*********************************************************************
487  *              _CIfmod (MSVCRT.@)
488  */
489 double CDECL _CIfmod(void)
490 {
491   FPU_DOUBLES(x,y);
492   return MSVCRT_fmod(x,y);
493 }
494
495 /*********************************************************************
496  *              _CIlog (MSVCRT.@)
497  */
498 double CDECL _CIlog(void)
499 {
500   FPU_DOUBLE(x);
501   return MSVCRT_log(x);
502 }
503
504 /*********************************************************************
505  *              _CIlog10 (MSVCRT.@)
506  */
507 double CDECL _CIlog10(void)
508 {
509   FPU_DOUBLE(x);
510   return MSVCRT_log10(x);
511 }
512
513 /*********************************************************************
514  *              _CIpow (MSVCRT.@)
515  */
516 double CDECL _CIpow(void)
517 {
518   FPU_DOUBLES(x,y);
519   return MSVCRT_pow(x,y);
520 }
521
522 /*********************************************************************
523  *              _CIsin (MSVCRT.@)
524  */
525 double CDECL _CIsin(void)
526 {
527   FPU_DOUBLE(x);
528   return MSVCRT_sin(x);
529 }
530
531 /*********************************************************************
532  *              _CIsinh (MSVCRT.@)
533  */
534 double CDECL _CIsinh(void)
535 {
536   FPU_DOUBLE(x);
537   return MSVCRT_sinh(x);
538 }
539
540 /*********************************************************************
541  *              _CIsqrt (MSVCRT.@)
542  */
543 double CDECL _CIsqrt(void)
544 {
545   FPU_DOUBLE(x);
546   return MSVCRT_sqrt(x);
547 }
548
549 /*********************************************************************
550  *              _CItan (MSVCRT.@)
551  */
552 double CDECL _CItan(void)
553 {
554   FPU_DOUBLE(x);
555   return MSVCRT_tan(x);
556 }
557
558 /*********************************************************************
559  *              _CItanh (MSVCRT.@)
560  */
561 double CDECL _CItanh(void)
562 {
563   FPU_DOUBLE(x);
564   return MSVCRT_tanh(x);
565 }
566
567 #endif /* defined(__GNUC__) && defined(__i386__) */
568
569 /*********************************************************************
570  *              _fpclass (MSVCRT.@)
571  */
572 int CDECL _fpclass(double num)
573 {
574 #if defined(HAVE_FPCLASS) || defined(fpclass)
575   switch (fpclass( num ))
576   {
577 #ifdef FP_SNAN
578   case FP_SNAN:  return MSVCRT__FPCLASS_SNAN;
579 #endif
580 #ifdef FP_QNAN
581   case FP_QNAN:  return MSVCRT__FPCLASS_QNAN;
582 #endif
583 #ifdef FP_NINF
584   case FP_NINF:  return MSVCRT__FPCLASS_NINF;
585 #endif
586 #ifdef FP_PINF
587   case FP_PINF:  return MSVCRT__FPCLASS_PINF;
588 #endif
589 #ifdef FP_NDENORM
590   case FP_NDENORM: return MSVCRT__FPCLASS_ND;
591 #endif
592 #ifdef FP_PDENORM
593   case FP_PDENORM: return MSVCRT__FPCLASS_PD;
594 #endif
595 #ifdef FP_NZERO
596   case FP_NZERO: return MSVCRT__FPCLASS_NZ;
597 #endif
598 #ifdef FP_PZERO
599   case FP_PZERO: return MSVCRT__FPCLASS_PZ;
600 #endif
601 #ifdef FP_NNORM
602   case FP_NNORM: return MSVCRT__FPCLASS_NN;
603 #endif
604 #ifdef FP_PNORM
605   case FP_PNORM: return MSVCRT__FPCLASS_PN;
606 #endif
607   default: return MSVCRT__FPCLASS_PN;
608   }
609 #elif defined (fpclassify)
610   switch (fpclassify( num ))
611   {
612   case FP_NAN: return MSVCRT__FPCLASS_QNAN;
613   case FP_INFINITE: return signbit(num) ? MSVCRT__FPCLASS_NINF : MSVCRT__FPCLASS_PINF;
614   case FP_SUBNORMAL: return signbit(num) ?MSVCRT__FPCLASS_ND : MSVCRT__FPCLASS_PD;
615   case FP_ZERO: return signbit(num) ? MSVCRT__FPCLASS_NZ : MSVCRT__FPCLASS_PZ;
616   }
617   return signbit(num) ? MSVCRT__FPCLASS_NN : MSVCRT__FPCLASS_PN;
618 #else
619   if (!finite(num))
620     return MSVCRT__FPCLASS_QNAN;
621   return num == 0.0 ? MSVCRT__FPCLASS_PZ : (num < 0 ? MSVCRT__FPCLASS_NN : MSVCRT__FPCLASS_PN);
622 #endif
623 }
624
625 /*********************************************************************
626  *              _rotl (MSVCRT.@)
627  */
628 unsigned int CDECL _rotl(unsigned int num, int shift)
629 {
630   shift &= 31;
631   return (num << shift) | (num >> (32-shift));
632 }
633
634 /*********************************************************************
635  *              _logb (MSVCRT.@)
636  */
637 double CDECL _logb(double num)
638 {
639   if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
640   return logb(num);
641 }
642
643 /*********************************************************************
644  *              _lrotl (MSVCRT.@)
645  */
646 MSVCRT_ulong CDECL MSVCRT__lrotl(MSVCRT_ulong num, int shift)
647 {
648   shift &= 0x1f;
649   return (num << shift) | (num >> (32-shift));
650 }
651
652 /*********************************************************************
653  *              _lrotr (MSVCRT.@)
654  */
655 MSVCRT_ulong CDECL MSVCRT__lrotr(MSVCRT_ulong num, int shift)
656 {
657   shift &= 0x1f;
658   return (num >> shift) | (num << (32-shift));
659 }
660
661 /*********************************************************************
662  *              _rotr (MSVCRT.@)
663  */
664 unsigned int CDECL _rotr(unsigned int num, int shift)
665 {
666     shift &= 0x1f;
667     return (num >> shift) | (num << (32-shift));
668 }
669
670 /*********************************************************************
671  *              _scalb (MSVCRT.@)
672  */
673 double CDECL MSVCRT__scalb(double num, MSVCRT_long power)
674 {
675   if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
676   return ldexp(num, power);
677 }
678
679 /*********************************************************************
680  *              _hypot (MSVCRT.@)
681  */
682 double CDECL _hypot(double x, double y)
683 {
684   /* FIXME: errno handling */
685   return hypot( x, y );
686 }
687
688 /*********************************************************************
689  *      _hypotf (MSVCRT.@)
690  */
691 float CDECL _hypotf(float x, float y)
692 {
693   /* FIXME: errno handling */
694   return hypotf( x, y );
695 }
696
697 /*********************************************************************
698  *              ceil (MSVCRT.@)
699  */
700 double CDECL MSVCRT_ceil( double x )
701 {
702   return ceil(x);
703 }
704
705 /*********************************************************************
706  *              floor (MSVCRT.@)
707  */
708 double CDECL MSVCRT_floor( double x )
709 {
710   return floor(x);
711 }
712
713 /*********************************************************************
714  *              fabs (MSVCRT.@)
715  */
716 double CDECL MSVCRT_fabs( double x )
717 {
718   return fabs(x);
719 }
720
721 /*********************************************************************
722  *              frexp (MSVCRT.@)
723  */
724 double CDECL MSVCRT_frexp( double x, int *exp )
725 {
726   return frexp( x, exp );
727 }
728
729 /*********************************************************************
730  *              modf (MSVCRT.@)
731  */
732 double CDECL MSVCRT_modf( double x, double *iptr )
733 {
734   return modf( x, iptr );
735 }
736
737 /*********************************************************************
738  *              _matherr (MSVCRT.@)
739  */
740 int CDECL MSVCRT__matherr(struct MSVCRT__exception *e)
741 {
742   if (e)
743     TRACE("(%p = %d, %s, %g %g %g)\n",e, e->type, e->name, e->arg1, e->arg2,
744           e->retval);
745   else
746     TRACE("(null)\n");
747   if (MSVCRT_default_matherr_func)
748     return MSVCRT_default_matherr_func(e);
749   ERR(":Unhandled math error!\n");
750   return 0;
751 }
752
753 /*********************************************************************
754  *              __setusermatherr (MSVCRT.@)
755  */
756 void CDECL MSVCRT___setusermatherr(MSVCRT_matherr_func func)
757 {
758   MSVCRT_default_matherr_func = func;
759   TRACE(":new matherr handler %p\n", func);
760 }
761
762 /**********************************************************************
763  *              _statusfp (MSVCRT.@)
764  */
765 unsigned int CDECL _statusfp(void)
766 {
767    unsigned int retVal = 0;
768 #if defined(__GNUC__) && defined(__i386__)
769   unsigned int fpword;
770
771   __asm__ __volatile__( "fstsw %0" : "=m" (fpword) : );
772   if (fpword & 0x1)  retVal |= MSVCRT__SW_INVALID;
773   if (fpword & 0x2)  retVal |= MSVCRT__SW_DENORMAL;
774   if (fpword & 0x4)  retVal |= MSVCRT__SW_ZERODIVIDE;
775   if (fpword & 0x8)  retVal |= MSVCRT__SW_OVERFLOW;
776   if (fpword & 0x10) retVal |= MSVCRT__SW_UNDERFLOW;
777   if (fpword & 0x20) retVal |= MSVCRT__SW_INEXACT;
778 #else
779   FIXME(":Not implemented!\n");
780 #endif
781   return retVal;
782 }
783
784 /*********************************************************************
785  *              _clearfp (MSVCRT.@)
786  */
787 unsigned int CDECL _clearfp(void)
788 {
789   unsigned int retVal = _statusfp();
790 #if defined(__GNUC__) && defined(__i386__)
791   __asm__ __volatile__( "fnclex" );
792 #else
793   FIXME(":Not Implemented\n");
794 #endif
795   return retVal;
796 }
797
798 /*********************************************************************
799  *              __fpecode (MSVCRT.@)
800  */
801 int * CDECL __fpecode(void)
802 {
803     return &msvcrt_get_thread_data()->fpecode;
804 }
805
806 /*********************************************************************
807  *              ldexp (MSVCRT.@)
808  */
809 double CDECL MSVCRT_ldexp(double num, MSVCRT_long exp)
810 {
811   double z = ldexp(num,exp);
812
813   if (!finite(z))
814     *MSVCRT__errno() = MSVCRT_ERANGE;
815   else if (z == 0 && signbit(z))
816     z = 0.0; /* Convert -0 -> +0 */
817   return z;
818 }
819
820 /*********************************************************************
821  *              _cabs (MSVCRT.@)
822  */
823 double CDECL MSVCRT__cabs(struct MSVCRT__complex num)
824 {
825   return sqrt(num.x * num.x + num.y * num.y);
826 }
827
828 /*********************************************************************
829  *              _chgsign (MSVCRT.@)
830  */
831 double CDECL _chgsign(double num)
832 {
833   /* FIXME: +-infinity,Nan not tested */
834   return -num;
835 }
836
837 /*********************************************************************
838  *              _control87 (MSVCRT.@)
839  */
840 unsigned int CDECL _control87(unsigned int newval, unsigned int mask)
841 {
842 #if defined(__GNUC__) && defined(__i386__)
843   unsigned int fpword = 0;
844   unsigned int flags = 0;
845
846   TRACE("(%08x, %08x): Called\n", newval, mask);
847
848   /* Get fp control word */
849   __asm__ __volatile__( "fstcw %0" : "=m" (fpword) : );
850
851   TRACE("Control word before : %08x\n", fpword);
852
853   /* Convert into mask constants */
854   if (fpword & 0x1)  flags |= MSVCRT__EM_INVALID;
855   if (fpword & 0x2)  flags |= MSVCRT__EM_DENORMAL;
856   if (fpword & 0x4)  flags |= MSVCRT__EM_ZERODIVIDE;
857   if (fpword & 0x8)  flags |= MSVCRT__EM_OVERFLOW;
858   if (fpword & 0x10) flags |= MSVCRT__EM_UNDERFLOW;
859   if (fpword & 0x20) flags |= MSVCRT__EM_INEXACT;
860   switch(fpword & 0xC00) {
861   case 0xC00: flags |= MSVCRT__RC_UP|MSVCRT__RC_DOWN; break;
862   case 0x800: flags |= MSVCRT__RC_UP; break;
863   case 0x400: flags |= MSVCRT__RC_DOWN; break;
864   }
865   switch(fpword & 0x300) {
866   case 0x0:   flags |= MSVCRT__PC_24; break;
867   case 0x200: flags |= MSVCRT__PC_53; break;
868   case 0x300: flags |= MSVCRT__PC_64; break;
869   }
870   if (fpword & 0x1000) flags |= MSVCRT__IC_AFFINE;
871
872   /* Mask with parameters */
873   flags = (flags & ~mask) | (newval & mask);
874
875   /* Convert (masked) value back to fp word */
876   fpword = 0;
877   if (flags & MSVCRT__EM_INVALID)    fpword |= 0x1;
878   if (flags & MSVCRT__EM_DENORMAL)   fpword |= 0x2;
879   if (flags & MSVCRT__EM_ZERODIVIDE) fpword |= 0x4;
880   if (flags & MSVCRT__EM_OVERFLOW)   fpword |= 0x8;
881   if (flags & MSVCRT__EM_UNDERFLOW)  fpword |= 0x10;
882   if (flags & MSVCRT__EM_INEXACT)    fpword |= 0x20;
883   switch(flags & (MSVCRT__RC_UP | MSVCRT__RC_DOWN)) {
884   case MSVCRT__RC_UP|MSVCRT__RC_DOWN: fpword |= 0xC00; break;
885   case MSVCRT__RC_UP:          fpword |= 0x800; break;
886   case MSVCRT__RC_DOWN:        fpword |= 0x400; break;
887   }
888   switch (flags & (MSVCRT__PC_24 | MSVCRT__PC_53)) {
889   case MSVCRT__PC_64: fpword |= 0x300; break;
890   case MSVCRT__PC_53: fpword |= 0x200; break;
891   case MSVCRT__PC_24: fpword |= 0x0; break;
892   }
893   if (flags & MSVCRT__IC_AFFINE) fpword |= 0x1000;
894
895   TRACE("Control word after  : %08x\n", fpword);
896
897   /* Put fp control word */
898   __asm__ __volatile__( "fldcw %0" : : "m" (fpword) );
899
900   return flags;
901 #else
902   FIXME(":Not Implemented!\n");
903   return 0;
904 #endif
905 }
906
907 /*********************************************************************
908  *              _controlfp (MSVCRT.@)
909  */
910 unsigned int CDECL _controlfp(unsigned int newval, unsigned int mask)
911 {
912 #ifdef __i386__
913   return _control87( newval, mask & ~MSVCRT__EM_DENORMAL );
914 #else
915   FIXME(":Not Implemented!\n");
916   return 0;
917 #endif
918 }
919
920 /*********************************************************************
921  *              _controlfp_s (MSVCRT.@)
922  */
923 int CDECL _controlfp_s(unsigned int *cur, unsigned int newval, unsigned int mask)
924 {
925 #ifdef __i386__
926     unsigned int flags;
927
928     FIXME("(%p %u %u) semi-stub\n", cur, newval, mask);
929
930     flags = _control87( newval, mask & ~MSVCRT__EM_DENORMAL );
931
932     if(cur)
933         *cur = flags;
934
935     return 0;
936 #else
937     FIXME(":Not Implemented!\n");
938     return 0;
939 #endif
940 }
941
942 /*********************************************************************
943  *              _copysign (MSVCRT.@)
944  */
945 double CDECL _copysign(double num, double sign)
946 {
947   /* FIXME: Behaviour for Nan/Inf? */
948   if (sign < 0.0)
949     return num < 0.0 ? num : -num;
950   return num < 0.0 ? -num : num;
951 }
952
953 /*********************************************************************
954  *              _finite (MSVCRT.@)
955  */
956 int CDECL _finite(double num)
957 {
958   return (finite(num)?1:0); /* See comment for _isnan() */
959 }
960
961 /*********************************************************************
962  *              _fpreset (MSVCRT.@)
963  */
964 void CDECL _fpreset(void)
965 {
966 #if defined(__GNUC__) && defined(__i386__)
967   __asm__ __volatile__( "fninit" );
968 #else
969   FIXME(":Not Implemented!\n");
970 #endif
971 }
972
973 /*********************************************************************
974  *              _isnan (MSVCRT.@)
975  */
976 INT CDECL _isnan(double num)
977 {
978   /* Some implementations return -1 for true(glibc), msvcrt/crtdll return 1.
979    * Do the same, as the result may be used in calculations
980    */
981   return isnan(num) ? 1 : 0;
982 }
983
984 /*********************************************************************
985  *              _j0 (MSVCRT.@)
986  */
987 double CDECL _j0(double num)
988 {
989   /* FIXME: errno handling */
990   return j0(num);
991 }
992
993 /*********************************************************************
994  *              _j1 (MSVCRT.@)
995  */
996 double CDECL _j1(double num)
997 {
998   /* FIXME: errno handling */
999   return j1(num);
1000 }
1001
1002 /*********************************************************************
1003  *              jn (MSVCRT.@)
1004  */
1005 double CDECL _jn(int n, double num)
1006 {
1007   /* FIXME: errno handling */
1008   return jn(n, num);
1009 }
1010
1011 /*********************************************************************
1012  *              _y0 (MSVCRT.@)
1013  */
1014 double CDECL _y0(double num)
1015 {
1016   double retval;
1017   if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
1018   retval  = y0(num);
1019   if (_fpclass(retval) == MSVCRT__FPCLASS_NINF)
1020   {
1021     *MSVCRT__errno() = MSVCRT_EDOM;
1022     retval = sqrt(-1);
1023   }
1024   return retval;
1025 }
1026
1027 /*********************************************************************
1028  *              _y1 (MSVCRT.@)
1029  */
1030 double CDECL _y1(double num)
1031 {
1032   double retval;
1033   if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
1034   retval  = y1(num);
1035   if (_fpclass(retval) == MSVCRT__FPCLASS_NINF)
1036   {
1037     *MSVCRT__errno() = MSVCRT_EDOM;
1038     retval = sqrt(-1);
1039   }
1040   return retval;
1041 }
1042
1043 /*********************************************************************
1044  *              _yn (MSVCRT.@)
1045  */
1046 double CDECL _yn(int order, double num)
1047 {
1048   double retval;
1049   if (!finite(num)) *MSVCRT__errno() = MSVCRT_EDOM;
1050   retval  = yn(order,num);
1051   if (_fpclass(retval) == MSVCRT__FPCLASS_NINF)
1052   {
1053     *MSVCRT__errno() = MSVCRT_EDOM;
1054     retval = sqrt(-1);
1055   }
1056   return retval;
1057 }
1058
1059 /*********************************************************************
1060  *              _nextafter (MSVCRT.@)
1061  */
1062 double CDECL _nextafter(double num, double next)
1063 {
1064   double retval;
1065   if (!finite(num) || !finite(next)) *MSVCRT__errno() = MSVCRT_EDOM;
1066   retval = nextafter(num,next);
1067   return retval;
1068 }
1069
1070 /*********************************************************************
1071  *              _ecvt (MSVCRT.@)
1072  */
1073 char * CDECL _ecvt( double number, int ndigits, int *decpt, int *sign )
1074 {
1075     int prec, len;
1076     thread_data_t *data = msvcrt_get_thread_data();
1077     /* FIXME: check better for overflow (native supports over 300 chars's) */
1078     ndigits = min( ndigits, 80 - 7); /* 7 : space for dec point, 1 for "e",
1079                                       * 4 for exponent and one for
1080                                       * terminating '\0' */
1081     if (!data->efcvt_buffer)
1082         data->efcvt_buffer = MSVCRT_malloc( 80 ); /* ought to be enough */
1083
1084     if( number < 0) {
1085         *sign = TRUE;
1086         number = -number;
1087     } else
1088         *sign = FALSE;
1089     /* handle cases with zero ndigits or less */
1090     prec = ndigits;
1091     if( prec < 1) prec = 2;
1092     len = snprintf(data->efcvt_buffer, 80, "%.*le", prec - 1, number);
1093     /* take the decimal "point away */
1094     if( prec != 1)
1095         memmove( data->efcvt_buffer + 1, data->efcvt_buffer + 2, len - 1 );
1096     /* take the exponential "e" out */
1097     data->efcvt_buffer[ prec] = '\0';
1098     /* read the exponent */
1099     sscanf( data->efcvt_buffer + prec + 1, "%d", decpt);
1100     (*decpt)++;
1101     /* adjust for some border cases */
1102     if( data->efcvt_buffer[0] == '0')/* value is zero */
1103         *decpt = 0;
1104     /* handle cases with zero ndigits or less */
1105     if( ndigits < 1){
1106         if( data->efcvt_buffer[ 0] >= '5')
1107             (*decpt)++;
1108         data->efcvt_buffer[ 0] = '\0';
1109     }
1110     TRACE("out=\"%s\"\n",data->efcvt_buffer);
1111     return data->efcvt_buffer;
1112 }
1113
1114 /***********************************************************************
1115  *              _fcvt  (MSVCRT.@)
1116  */
1117 char * CDECL _fcvt( double number, int ndigits, int *decpt, int *sign )
1118 {
1119     thread_data_t *data = msvcrt_get_thread_data();
1120     int stop, dec1, dec2;
1121     char *ptr1, *ptr2, *first;
1122     char buf[80]; /* ought to be enough */
1123
1124     if (!data->efcvt_buffer)
1125         data->efcvt_buffer = MSVCRT_malloc( 80 ); /* ought to be enough */
1126
1127     if (number < 0)
1128     {
1129         *sign = 1;
1130         number = -number;
1131     } else *sign = 0;
1132
1133     snprintf(buf, 80, "%.*f", ndigits < 0 ? 0 : ndigits, number);
1134     ptr1 = buf;
1135     ptr2 = data->efcvt_buffer;
1136     first = NULL;
1137     dec1 = 0;
1138     dec2 = 0;
1139
1140     /* For numbers below the requested resolution, work out where
1141        the decimal point will be rather than finding it in the string */
1142     if (number < 1.0 && number > 0.0) {
1143         dec2 = log10(number + 1e-10);
1144         if (-dec2 <= ndigits) dec2 = 0;
1145     }
1146
1147     /* If requested digits is zero or less, we will need to truncate
1148      * the returned string */
1149     if (ndigits < 1) {
1150         stop = strlen(buf) + ndigits;
1151     } else {
1152         stop = strlen(buf);
1153     }
1154
1155     while (*ptr1 == '0') ptr1++; /* Skip leading zeroes */
1156     while (*ptr1 != '\0' && *ptr1 != '.') {
1157         if (!first) first = ptr2;
1158         if ((ptr1 - buf) < stop) {
1159             *ptr2++ = *ptr1++;
1160         } else {
1161             ptr1++;
1162         }
1163         dec1++;
1164     }
1165
1166     if (ndigits > 0) {
1167         ptr1++;
1168         if (!first) {
1169             while (*ptr1 == '0') { /* Process leading zeroes */
1170                 *ptr2++ = *ptr1++;
1171                 dec1--;
1172             }
1173         }
1174         while (*ptr1 != '\0') {
1175             if (!first) first = ptr2;
1176             *ptr2++ = *ptr1++;
1177         }
1178     }
1179
1180     *ptr2 = '\0';
1181
1182     /* We never found a non-zero digit, then our number is either
1183      * smaller than the requested precision, or 0.0 */
1184     if (!first) {
1185         if (number > 0.0) {
1186             first = ptr2;
1187         } else {
1188             first = data->efcvt_buffer;
1189             dec1 = 0;
1190         }
1191     }
1192
1193     *decpt = dec2 ? dec2 : dec1;
1194     return first;
1195 }
1196
1197 /***********************************************************************
1198  *              _gcvt  (MSVCRT.@)
1199  */
1200 char * CDECL _gcvt( double number, int ndigit, char *buff )
1201 {
1202     if(!buff) {
1203         *MSVCRT__errno() = MSVCRT_EINVAL;
1204         return NULL;
1205     }
1206
1207     if(ndigit < 0) {
1208         *MSVCRT__errno() = MSVCRT_ERANGE;
1209         return NULL;
1210     }
1211
1212     MSVCRT_sprintf(buff, "%.*g", ndigit, number);
1213     return buff;
1214 }
1215
1216 /***********************************************************************
1217  *              _gcvt_s  (MSVCRT.@)
1218  */
1219 int CDECL _gcvt_s(char *buff, MSVCRT_size_t size, double number, int digits)
1220 {
1221     int len;
1222
1223     if(!buff) {
1224         *MSVCRT__errno() = MSVCRT_EINVAL;
1225         return MSVCRT_EINVAL;
1226     }
1227
1228     if( digits<0 || digits>=size) {
1229         if(size)
1230             buff[0] = '\0';
1231
1232         *MSVCRT__errno() = MSVCRT_ERANGE;
1233         return MSVCRT_ERANGE;
1234     }
1235
1236     len = MSVCRT__scprintf("%.*g", digits, number);
1237     if(len > size) {
1238         buff[0] = '\0';
1239         *MSVCRT__errno() = MSVCRT_ERANGE;
1240         return MSVCRT_ERANGE;
1241     }
1242
1243     MSVCRT_sprintf(buff, "%.*g", digits, number);
1244     return 0;
1245 }
1246
1247 #include <stdlib.h> /* div_t, ldiv_t */
1248
1249 /*********************************************************************
1250  *              div (MSVCRT.@)
1251  * VERSION
1252  *      [i386] Windows binary compatible - returns the struct in eax/edx.
1253  */
1254 #ifdef __i386__
1255 unsigned __int64 CDECL MSVCRT_div(int num, int denom)
1256 {
1257   div_t dt = div(num,denom);
1258   return ((unsigned __int64)dt.rem << 32) | (unsigned int)dt.quot;
1259 }
1260 #else
1261 /*********************************************************************
1262  *              div (MSVCRT.@)
1263  * VERSION
1264  *      [!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
1265  */
1266 MSVCRT_div_t CDECL MSVCRT_div(int num, int denom)
1267 {
1268   div_t dt = div(num,denom);
1269   MSVCRT_div_t     ret;
1270   ret.quot = dt.quot;
1271   ret.rem = dt.rem;
1272
1273   return ret;
1274
1275 }
1276 #endif /* ifdef __i386__ */
1277
1278
1279 /*********************************************************************
1280  *              ldiv (MSVCRT.@)
1281  * VERSION
1282  *      [i386] Windows binary compatible - returns the struct in eax/edx.
1283  */
1284 #ifdef __i386__
1285 unsigned __int64 CDECL MSVCRT_ldiv(MSVCRT_long num, MSVCRT_long denom)
1286 {
1287   ldiv_t ldt = ldiv(num,denom);
1288   return ((unsigned __int64)ldt.rem << 32) | (MSVCRT_ulong)ldt.quot;
1289 }
1290 #else
1291 /*********************************************************************
1292  *              ldiv (MSVCRT.@)
1293  * VERSION
1294  *      [!i386] Non-x86 can't run win32 apps so we don't need binary compatibility
1295  */
1296 MSVCRT_ldiv_t CDECL MSVCRT_ldiv(MSVCRT_long num, MSVCRT_long denom)
1297 {
1298   ldiv_t result = ldiv(num,denom);
1299
1300   MSVCRT_ldiv_t ret;
1301   ret.quot = result.quot;
1302   ret.rem = result.rem;
1303
1304   return ret;
1305 }
1306 #endif /* ifdef __i386__ */
1307
1308 #ifdef __i386__
1309
1310 /*********************************************************************
1311  *              _adjust_fdiv (MSVCRT.@)
1312  * Used by the MSVC compiler to work around the Pentium FDIV bug.
1313  */
1314 int MSVCRT__adjust_fdiv = 0;
1315
1316 /***********************************************************************
1317  *              _adj_fdiv_m16i (MSVCRT.@)
1318  *
1319  * NOTE
1320  *    I _think_ this function is intended to work around the Pentium
1321  *    fdiv bug.
1322  */
1323 void __stdcall _adj_fdiv_m16i( short arg )
1324 {
1325   TRACE("(): stub\n");
1326 }
1327
1328 /***********************************************************************
1329  *              _adj_fdiv_m32 (MSVCRT.@)
1330  *
1331  * NOTE
1332  *    I _think_ this function is intended to work around the Pentium
1333  *    fdiv bug.
1334  */
1335 void __stdcall _adj_fdiv_m32( unsigned int arg )
1336 {
1337   TRACE("(): stub\n");
1338 }
1339
1340 /***********************************************************************
1341  *              _adj_fdiv_m32i (MSVCRT.@)
1342  *
1343  * NOTE
1344  *    I _think_ this function is intended to work around the Pentium
1345  *    fdiv bug.
1346  */
1347 void __stdcall _adj_fdiv_m32i( int arg )
1348 {
1349   TRACE("(): stub\n");
1350 }
1351
1352 /***********************************************************************
1353  *              _adj_fdiv_m64 (MSVCRT.@)
1354  *
1355  * NOTE
1356  *    I _think_ this function is intended to work around the Pentium
1357  *    fdiv bug.
1358  */
1359 void __stdcall _adj_fdiv_m64( unsigned __int64 arg )
1360 {
1361   TRACE("(): stub\n");
1362 }
1363
1364 /***********************************************************************
1365  *              _adj_fdiv_r (MSVCRT.@)
1366  * FIXME
1367  *    This function is likely to have the wrong number of arguments.
1368  *
1369  * NOTE
1370  *    I _think_ this function is intended to work around the Pentium
1371  *    fdiv bug.
1372  */
1373 void _adj_fdiv_r(void)
1374 {
1375   TRACE("(): stub\n");
1376 }
1377
1378 /***********************************************************************
1379  *              _adj_fdivr_m16i (MSVCRT.@)
1380  *
1381  * NOTE
1382  *    I _think_ this function is intended to work around the Pentium
1383  *    fdiv bug.
1384  */
1385 void __stdcall _adj_fdivr_m16i( short arg )
1386 {
1387   TRACE("(): stub\n");
1388 }
1389
1390 /***********************************************************************
1391  *              _adj_fdivr_m32 (MSVCRT.@)
1392  *
1393  * NOTE
1394  *    I _think_ this function is intended to work around the Pentium
1395  *    fdiv bug.
1396  */
1397 void __stdcall _adj_fdivr_m32( unsigned int arg )
1398 {
1399   TRACE("(): stub\n");
1400 }
1401
1402 /***********************************************************************
1403  *              _adj_fdivr_m32i (MSVCRT.@)
1404  *
1405  * NOTE
1406  *    I _think_ this function is intended to work around the Pentium
1407  *    fdiv bug.
1408  */
1409 void __stdcall _adj_fdivr_m32i( int arg )
1410 {
1411   TRACE("(): stub\n");
1412 }
1413
1414 /***********************************************************************
1415  *              _adj_fdivr_m64 (MSVCRT.@)
1416  *
1417  * NOTE
1418  *    I _think_ this function is intended to work around the Pentium
1419  *    fdiv bug.
1420  */
1421 void __stdcall _adj_fdivr_m64( unsigned __int64 arg )
1422 {
1423   TRACE("(): stub\n");
1424 }
1425
1426 /***********************************************************************
1427  *              _adj_fpatan (MSVCRT.@)
1428  * FIXME
1429  *    This function is likely to have the wrong number of arguments.
1430  *
1431  * NOTE
1432  *    I _think_ this function is intended to work around the Pentium
1433  *    fdiv bug.
1434  */
1435 void _adj_fpatan(void)
1436 {
1437   TRACE("(): stub\n");
1438 }
1439
1440 /***********************************************************************
1441  *              _adj_fprem (MSVCRT.@)
1442  * FIXME
1443  *    This function is likely to have the wrong number of arguments.
1444  *
1445  * NOTE
1446  *    I _think_ this function is intended to work around the Pentium
1447  *    fdiv bug.
1448  */
1449 void _adj_fprem(void)
1450 {
1451   TRACE("(): stub\n");
1452 }
1453
1454 /***********************************************************************
1455  *              _adj_fprem1 (MSVCRT.@)
1456  * FIXME
1457  *    This function is likely to have the wrong number of arguments.
1458  *
1459  * NOTE
1460  *    I _think_ this function is intended to work around the Pentium
1461  *    fdiv bug.
1462  */
1463 void _adj_fprem1(void)
1464 {
1465   TRACE("(): stub\n");
1466 }
1467
1468 /***********************************************************************
1469  *              _adj_fptan (MSVCRT.@)
1470  * FIXME
1471  *    This function is likely to have the wrong number of arguments.
1472  *
1473  * NOTE
1474  *    I _think_ this function is intended to work around the Pentium
1475  *    fdiv bug.
1476  */
1477 void _adj_fptan(void)
1478 {
1479   TRACE("(): stub\n");
1480 }
1481
1482 /***********************************************************************
1483  *              _safe_fdiv (MSVCRT.@)
1484  * FIXME
1485  *    This function is likely to have the wrong number of arguments.
1486  *
1487  * NOTE
1488  *    I _think_ this function is intended to work around the Pentium
1489  *    fdiv bug.
1490  */
1491 void _safe_fdiv(void)
1492 {
1493   TRACE("(): stub\n");
1494 }
1495
1496 /***********************************************************************
1497  *              _safe_fdivr (MSVCRT.@)
1498  * FIXME
1499  *    This function is likely to have the wrong number of arguments.
1500  *
1501  * NOTE
1502  *    I _think_ this function is intended to work around the Pentium
1503  *    fdiv bug.
1504  */
1505 void _safe_fdivr(void)
1506 {
1507   TRACE("(): stub\n");
1508 }
1509
1510 /***********************************************************************
1511  *              _safe_fprem (MSVCRT.@)
1512  * FIXME
1513  *    This function is likely to have the wrong number of arguments.
1514  *
1515  * NOTE
1516  *    I _think_ this function is intended to work around the Pentium
1517  *    fdiv bug.
1518  */
1519 void _safe_fprem(void)
1520 {
1521   TRACE("(): stub\n");
1522 }
1523
1524 /***********************************************************************
1525  *              _safe_fprem1 (MSVCRT.@)
1526  *
1527  * FIXME
1528  *    This function is likely to have the wrong number of arguments.
1529  *
1530  * NOTE
1531  *    I _think_ this function is intended to work around the Pentium
1532  *    fdiv bug.
1533  */
1534 void _safe_fprem1(void)
1535 {
1536   TRACE("(): stub\n");
1537 }
1538
1539 #endif  /* __i386__ */