Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
2.5 KiB

  1. /***
  2. *fpinit.c - Initialize floating point
  3. *
  4. * Copyright (c) 1991-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *
  8. *Revision History:
  9. * 09-29-91 GDP merged fpmath.c and fltused.asm to produce this file
  10. * 09-30-91 GDP per thread initialization and termination hooks
  11. * 03-04-92 GDP removed finit instruction
  12. * 11-06-92 GDP added __fastflag for FORTRAN libs
  13. * 03-23-93 JWM added _setdefaultprecision() to _fpmath()
  14. * 12-09-94 JWM added __adjust_fdiv for Pentium FDIV detection
  15. * 12-12-94 SKS _adjust_fdiv must be exported in MSVCRT.LIB model
  16. * 02-06-95 JWM Mac merge
  17. * 04-04-95 JWM Clear exceptions after FDIV detection (x86 only).
  18. * 11-15-95 BWT Assume P5 FDIV problem will be handled in the OS.
  19. * 10-07-97 RDL Added IA64.
  20. *
  21. *******************************************************************************/
  22. #include <cv.h>
  23. #ifdef _M_IX86
  24. #include <testfdiv.h>
  25. #endif
  26. #if defined(_AMD64_) || defined(_M_IA64)
  27. #include <trans.h>
  28. #endif
  29. int _fltused = 0x9875;
  30. int _ldused = 0x9873;
  31. int __fastflag = 0;
  32. void _cfltcvt_init(void);
  33. void _fpmath(void);
  34. void _fpclear(void);
  35. #if defined(_M_AMD64) || defined(_M_IX86) || defined(_M_IA64)
  36. #ifndef _CRTIMP
  37. #ifdef CRTDLL
  38. #define _CRTIMP __declspec(dllexport)
  39. #else
  40. #define _CRTIMP
  41. #endif
  42. #endif
  43. _CRTIMP int _adjust_fdiv = 0;
  44. extern void _setdefaultprecision();
  45. #endif
  46. void (* _FPinit)(void) = _fpmath;
  47. void (* _FPmtinit)(void) = _fpclear;
  48. void (* _FPmtterm)(void) = _fpclear;
  49. void _fpmath()
  50. {
  51. //
  52. // There is no need for 'finit'
  53. // since this is done by the OS
  54. //
  55. _cfltcvt_init();
  56. #ifdef _M_IX86
  57. #ifndef NT_BUILD
  58. _adjust_fdiv = _ms_p5_mp_test_fdiv();
  59. #endif
  60. _setdefaultprecision();
  61. _asm {
  62. fnclex
  63. }
  64. #elif defined(_M_IA64)
  65. /* _setdefaultprecision(); */
  66. _clrfp();
  67. #endif
  68. return;
  69. }
  70. void _fpclear()
  71. {
  72. //
  73. // There is no need for 'finit'
  74. // since this is done by the OS
  75. //
  76. return;
  77. }
  78. void _cfltcvt_init()
  79. {
  80. _cfltcvt_tab[0] = (PFV) _cfltcvt;
  81. _cfltcvt_tab[1] = (PFV) _cropzeros;
  82. _cfltcvt_tab[2] = (PFV) _fassign;
  83. _cfltcvt_tab[3] = (PFV) _forcdecpt;
  84. _cfltcvt_tab[4] = (PFV) _positive;
  85. /* map long double to double */
  86. _cfltcvt_tab[5] = (PFV) _cfltcvt;
  87. }
  88. /*
  89. * Routine to set the fast flag in order to speed up computation
  90. * of transcendentals at the expense of limiting error checking
  91. */
  92. int __setfflag(int new)
  93. {
  94. int old = __fastflag;
  95. __fastflag = new;
  96. return old;
  97. }