fenv_libc.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* Internal libc stuff for floating point environment routines.
  2. Copyright (C) 2004 Free Software Foundation, Inc.
  3. Contributed by Aldy Hernandez <aldyh@redhat.com>, 2004
  4. This file is part of the GNU C Library.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef _FENV_LIBC_H
  17. #define _FENV_LIBC_H 1
  18. #include <fenv.h>
  19. extern int __feraiseexcept_internal (int __excepts);
  20. /* Equivalent to fegetenv, but returns a fenv_t instead of taking a
  21. pointer. */
  22. #define fegetenv_register() \
  23. ({ unsigned fscr; __asm__ __volatile__ ("mfspefscr %0" : "=r" (fscr)); fscr; })
  24. /* Equivalent to fesetenv, but takes a fenv_t instead of a pointer. */
  25. #define fesetenv_register(fscr) \
  26. ({ __asm__ __volatile__ ("mtspefscr %0" : : "r" (fscr)); })
  27. typedef union
  28. {
  29. fenv_t fenv;
  30. unsigned int l[2];
  31. } fenv_union_t;
  32. /* Definitions of all the SPEFSCR bit numbers. */
  33. enum {
  34. SPEFSCR_SOVH = 0x80000000,
  35. SPEFSCR_OVH = 0x40000000,
  36. SPEFSCR_FGH = 0x20000000,
  37. SPEFSCR_FXH = 0x10000000,
  38. SPEFSCR_FINVH = 0x08000000,
  39. SPEFSCR_FDBZH = 0x04000000,
  40. SPEFSCR_FUNFH = 0x02000000,
  41. SPEFSCR_FOVFH = 0x01000000,
  42. /* 2 unused bits. */
  43. SPEFSCR_FINXS = 0x00200000,
  44. SPEFSCR_FINVS = 0x00100000,
  45. SPEFSCR_FDBZS = 0x00080000,
  46. SPEFSCR_FUNFS = 0x00040000,
  47. SPEFSCR_FOVFS = 0x00020000,
  48. SPEFSCR_MODE = 0x00010000,
  49. SPEFSCR_SOV = 0x00008000,
  50. SPEFSCR_OV = 0x00004000,
  51. SPEFSCR_FG = 0x00002000,
  52. SPEFSCR_FX = 0x00001000,
  53. SPEFSCR_FINV = 0x00000800,
  54. SPEFSCR_FDBZ = 0x00000400,
  55. SPEFSCR_FUNF = 0x00000200,
  56. SPEFSCR_FOVF = 0x00000100,
  57. /* 1 unused bit. */
  58. SPEFSCR_FINXE = 0x00000040,
  59. SPEFSCR_FINVE = 0x00000020,
  60. SPEFSCR_FDBZE = 0x00000010,
  61. SPEFSCR_FUNFE = 0x00000008,
  62. SPEFSCR_FOVFE = 0x00000004,
  63. SPEFSCR_FRMC = 0x00000003
  64. };
  65. #endif /* fenv_libc.h */