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.

128 lines
1.9 KiB

  1. /***
  2. *fpctrl.c - fp low level control and status routines
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * IEEE control and status routines for internal use.
  8. * These routines use machine specific constants while _controlfp,
  9. * _statusfp, and _clearfp use an abstracted control/status word
  10. *
  11. *Revision History:
  12. *
  13. * 03-31-92 GDP written
  14. * 05-12-92 GJF Rewrote fdivr as fdivrp st(1),st to work around C8-32
  15. * assertions.
  16. *
  17. */
  18. #include <trans.h>
  19. extern uintptr_t _get_fpsr(void);
  20. extern void _set_fpsr(uintptr_t);
  21. extern void _fclrf(void);
  22. /*** _statfp
  23. *() -
  24. *
  25. *Purpose:
  26. * return user status word
  27. *
  28. *Entry:
  29. *
  30. *Exit:
  31. *
  32. *Exceptions:
  33. *
  34. *******************************************************************************/
  35. uintptr_t _statfp()
  36. {
  37. unsigned __int64 status;
  38. status = _get_fpsr();
  39. return status;
  40. }
  41. /*** _clrfp
  42. *() -
  43. *
  44. *Purpose:
  45. * return user status word and clear status
  46. *
  47. *Entry:
  48. *
  49. *Exit:
  50. *
  51. *Exceptions:
  52. *
  53. *******************************************************************************/
  54. uintptr_t _clrfp()
  55. {
  56. uintptr_t status;
  57. status = _get_fpsr();
  58. _fclrf();
  59. return status;
  60. }
  61. /*** _ctrlfp
  62. *() -
  63. *
  64. *Purpose:
  65. * return and set user control word
  66. *
  67. *Entry:
  68. *
  69. *Exit:
  70. *
  71. *Exceptions:
  72. *
  73. *******************************************************************************/
  74. uintptr_t _ctrlfp(uintptr_t newctrl, uintptr_t _mask)
  75. {
  76. uintptr_t oldCw;
  77. uintptr_t newCw;
  78. oldCw = _get_fpsr();
  79. newCw = (uintptr_t) ((newctrl & _mask) | (oldCw & ~_mask));
  80. newCw |= (oldCw & ~(unsigned __int64)0x0001f3f);
  81. _set_fpsr(newCw);
  82. return oldCw;
  83. }
  84. /*** _set_statfp
  85. *() -
  86. *
  87. *Purpose:
  88. * force selected exception flags to 1
  89. *
  90. *Entry:
  91. *
  92. *Exit:
  93. *
  94. *Exceptions:
  95. *
  96. *******************************************************************************/
  97. void _set_statfp(uintptr_t sw)
  98. {
  99. unsigned __int64 status;
  100. status = _get_fpsr();
  101. status |= sw;
  102. _set_fpsr(status);
  103. }