fenv_libc.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. #ifndef _FENV_LIBC_H
  18. #define _FENV_LIBC_H 1
  19. #include <fenv.h>
  20. extern int __feraiseexcept_internal (int __excepts);
  21. /* Equivalent to fegetenv, but returns a fenv_t instead of taking a
  22. pointer. */
  23. #define fegetenv_register() \
  24. ({ unsigned fscr; __asm__ __volatile__ ("mfspefscr %0" : "=r" (fscr)); fscr; })
  25. /* Equivalent to fesetenv, but takes a fenv_t instead of a pointer. */
  26. #define fesetenv_register(fscr) \
  27. ({ __asm__ __volatile__ ("mtspefscr %0" : : "r" (fscr)); })
  28. typedef union
  29. {
  30. fenv_t fenv;
  31. unsigned int l[2];
  32. } fenv_union_t;
  33. /* Definitions of all the SPEFSCR bit numbers. */
  34. enum {
  35. SPEFSCR_SOVH = 0x80000000,
  36. SPEFSCR_OVH = 0x40000000,
  37. SPEFSCR_FGH = 0x20000000,
  38. SPEFSCR_FXH = 0x10000000,
  39. SPEFSCR_FINVH = 0x08000000,
  40. SPEFSCR_FDBZH = 0x04000000,
  41. SPEFSCR_FUNFH = 0x02000000,
  42. SPEFSCR_FOVFH = 0x01000000,
  43. /* 2 unused bits. */
  44. SPEFSCR_FINXS = 0x00200000,
  45. SPEFSCR_FINVS = 0x00100000,
  46. SPEFSCR_FDBZS = 0x00080000,
  47. SPEFSCR_FUNFS = 0x00040000,
  48. SPEFSCR_FOVFS = 0x00020000,
  49. SPEFSCR_MODE = 0x00010000,
  50. SPEFSCR_SOV = 0x00008000,
  51. SPEFSCR_OV = 0x00004000,
  52. SPEFSCR_FG = 0x00002000,
  53. SPEFSCR_FX = 0x00001000,
  54. SPEFSCR_FINV = 0x00000800,
  55. SPEFSCR_FDBZ = 0x00000400,
  56. SPEFSCR_FUNF = 0x00000200,
  57. SPEFSCR_FOVF = 0x00000100,
  58. /* 1 unused bit. */
  59. SPEFSCR_FINXE = 0x00000040,
  60. SPEFSCR_FINVE = 0x00000020,
  61. SPEFSCR_FDBZE = 0x00000010,
  62. SPEFSCR_FUNFE = 0x00000008,
  63. SPEFSCR_FOVFE = 0x00000004,
  64. SPEFSCR_FRMC = 0x00000003
  65. };
  66. #endif /* fenv_libc.h */