Leaked source code of windows server 2003
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.

118 lines
2.1 KiB

  1. /***
  2. *fpctrl.c - fp low level control and status routines
  3. *
  4. * Copyright (c) 1985-2000, Microsoft Corporation
  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 unsigned int _get_fpsr(void);
  20. extern void _set_fpsr(unsigned int);
  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 int status;
  38. status = _get_fpsr() & ISW;
  39. return (uintptr_t)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. unsigned int status;
  57. status = _get_fpsr() & ISW;
  58. _fclrf();
  59. return (uintptr_t)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. unsigned int oldCw;
  77. unsigned int newCw;
  78. unsigned int tmp;
  79. oldCw = _get_fpsr();
  80. newCw = ((unsigned int)(newctrl & _mask) | (oldCw & (unsigned int)~_mask));
  81. _set_fpsr(newCw);
  82. return (uintptr_t)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 int status;
  100. status = _get_fpsr() | ((unsigned int)sw & ISW);
  101. _set_fpsr(status);
  102. }