fenvinline.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Inline floating-point environment handling functions for powerpc.
  2. Copyright (C) 1995, 1996, 1997, 1998, 1999, 2006
  3. Free Software Foundation, Inc.
  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. #include <features.h>
  18. #if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_MATH_INLINES
  19. /* Inline definition for fegetround. */
  20. # define fegetround() \
  21. (__extension__ ({ int __fegetround_result; \
  22. __asm__ __volatile__ \
  23. ("mcrfs 7,7 ; mfcr %0" \
  24. : "=r"(__fegetround_result) : : "cr7"); \
  25. __fegetround_result & 3; }))
  26. /* The weird 'i#*X' constraints on the following suppress a gcc
  27. warning when __excepts is not a constant. Otherwise, they mean the
  28. same as just plain 'i'. */
  29. /* Inline definition for feraiseexcept. */
  30. # define feraiseexcept(__excepts) \
  31. ((__builtin_constant_p (__excepts) \
  32. && ((__excepts) & ((__excepts)-1)) == 0 \
  33. && (__excepts) != FE_INVALID) \
  34. ? ((__excepts) != 0 \
  35. ? (__extension__ ({ __asm__ __volatile__ \
  36. ("mtfsb1 %s0" \
  37. : : "i#*X"(__builtin_ffs (__excepts))); \
  38. 0; })) \
  39. : 0) \
  40. : (feraiseexcept) (__excepts))
  41. /* Inline definition for feclearexcept. */
  42. # define feclearexcept(__excepts) \
  43. ((__builtin_constant_p (__excepts) \
  44. && ((__excepts) & ((__excepts)-1)) == 0 \
  45. && (__excepts) != FE_INVALID) \
  46. ? ((__excepts) != 0 \
  47. ? (__extension__ ({ __asm__ __volatile__ \
  48. ("mtfsb0 %s0" \
  49. : : "i#*X"(__builtin_ffs (__excepts))); \
  50. 0; })) \
  51. : 0) \
  52. : (feclearexcept) (__excepts))
  53. #endif /* __GNUC__ && !_SOFT_FLOAT */