fpuctl.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* This code is a little awkward. If somebody who understands Solaris
  2. better would tell me an idiomatic way to invoke equivalent
  3. behavior, I'd be grateful. ehg@bell-labs.com */
  4. /*
  5. * accrued exception bits in the fsr
  6. */
  7. #define FPAINEX (1<<5)
  8. #define FPAOVFL (1<<8)
  9. #define FPAUNFL (1<<7)
  10. #define FPAZDIV (1<<6)
  11. #define FPAINVAL (1<<9)
  12. /*
  13. * exception enable bits in the fsr
  14. */
  15. #define FPINEX (1<<23)
  16. #define FPOVFL (1<<26)
  17. #define FPUNFL (1<<25)
  18. #define FPZDIV (1<<24)
  19. #define FPINVAL (1<<27)
  20. /*
  21. * rounding
  22. */
  23. #define FPRMASK (3<<30)
  24. #define FPRNR (0<<30)
  25. #define FPRNINF (3<<30)
  26. #define FPRPINF (2<<30)
  27. #define FPRZ (1<<30)
  28. /*
  29. * precision
  30. */
  31. #define FPPDBL 0
  32. #define FPFCR (FPRMASK|FPINEX|FPOVFL|FPUNFL|FPZDIV|FPINVAL)
  33. #define FPFSR (FPAINEX|FPAOVFL|FPAUNFL|FPAZDIV|FPAINVAL)
  34. static ulong
  35. getfcr(void)
  36. {
  37. ulong v;
  38. asm(" st %fsr, [%fp-8]");
  39. return v;
  40. }
  41. static void
  42. setfcr(ulong v)
  43. {
  44. ulong vv;
  45. vv = (getfcr() & ~FPFCR) | (v & FPFCR);
  46. asm(" ld [%fp-4], %fsr");
  47. }
  48. static ulong
  49. getfsr(void)
  50. {
  51. ulong v;
  52. asm(" st %fsr, [%fp-8]");
  53. return v;
  54. }
  55. static void
  56. setfsr(ulong v)
  57. {
  58. ulong vv;
  59. vv = (getfsr() & ~FPFSR) | (v & FPFSR);
  60. asm(" ld [%fp-4], %fsr");
  61. }