fpu_control.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* FPU control word bits. SPARC version.
  2. Copyright (C) 1997-2025 Free Software Foundation, Inc.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. #ifndef _FPU_CONTROL_H
  15. #define _FPU_CONTROL_H 1
  16. #include <features.h>
  17. #include <bits/wordsize.h>
  18. /* masking of interrupts */
  19. #define _FPU_MASK_IM 0x08000000
  20. #define _FPU_MASK_OM 0x04000000
  21. #define _FPU_MASK_UM 0x02000000
  22. #define _FPU_MASK_ZM 0x01000000
  23. #define _FPU_MASK_PM 0x00800000
  24. /* precision control */
  25. #define _FPU_EXTENDED 0x00000000 /* RECOMMENDED */
  26. #define _FPU_DOUBLE 0x20000000
  27. #define _FPU_80BIT 0x30000000
  28. #define _FPU_SINGLE 0x10000000 /* DO NOT USE */
  29. /* rounding control / Sparc */
  30. #define _FPU_RC_DOWN 0xc0000000
  31. #define _FPU_RC_UP 0x80000000
  32. #define _FPU_RC_ZERO 0x40000000
  33. #define _FPU_RC_NEAREST 0x0 /* RECOMMENDED */
  34. #define _FPU_RESERVED 0x303e0000 /* Reserved bits in cw */
  35. /* Now two recommended cw */
  36. /* Linux and IEEE default:
  37. - extended precision
  38. - rounding to nearest
  39. - no exceptions */
  40. #define _FPU_DEFAULT 0x0
  41. #define _FPU_IEEE 0x0
  42. /* Type of the control word. */
  43. typedef unsigned long int fpu_control_t;
  44. #if __WORDSIZE == 64
  45. # define _FPU_GETCW(cw) __asm__ __volatile__ ("stx %%fsr,%0" : "=m" (*&cw))
  46. # define _FPU_SETCW(cw) __asm__ __volatile__ ("ldx %0,%%fsr" : : "m" (*&cw))
  47. #else
  48. # ifdef __leon__
  49. /* Prevent stfsr from being placed directly after other fp instruction. */
  50. # define _FPU_GETCW(cw) __asm__ __volatile__ ("nop; st %%fsr,%0" : "=m" (*&cw))
  51. # else
  52. # define _FPU_GETCW(cw) __asm__ __volatile__ ("st %%fsr,%0" : "=m" (*&cw))
  53. # endif
  54. # define _FPU_SETCW(cw) __asm__ __volatile__ ("ld %0,%%fsr" : : "m" (*&cw))
  55. #endif
  56. /* Default control word set at startup. */
  57. extern fpu_control_t __fpu_control;
  58. #endif /* fpu_control.h */