fenvinline.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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, see
  15. <http://www.gnu.org/licenses/>. */
  16. #include <features.h>
  17. #if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_MATH_INLINES
  18. /* Inline definition for fegetround. */
  19. # define fegetround() \
  20. (__extension__ ({ int __fegetround_result; \
  21. __asm__ __volatile__ \
  22. ("mcrfs 7,7 ; mfcr %0" \
  23. : "=r"(__fegetround_result) : : "cr7"); \
  24. __fegetround_result & 3; }))
  25. /* The weird 'i#*X' constraints on the following suppress a gcc
  26. warning when __excepts is not a constant. Otherwise, they mean the
  27. same as just plain 'i'. */
  28. /* Inline definition for feraiseexcept. */
  29. # define feraiseexcept(__excepts) \
  30. ((__builtin_constant_p (__excepts) \
  31. && ((__excepts) & ((__excepts)-1)) == 0 \
  32. && (__excepts) != FE_INVALID) \
  33. ? ((__excepts) != 0 \
  34. ? (__extension__ ({ __asm__ __volatile__ \
  35. ("mtfsb1 %s0" \
  36. : : "i#*X"(__builtin_ffs (__excepts))); \
  37. 0; })) \
  38. : 0) \
  39. : (feraiseexcept) (__excepts))
  40. /* Inline definition for feclearexcept. */
  41. # define feclearexcept(__excepts) \
  42. ((__builtin_constant_p (__excepts) \
  43. && ((__excepts) & ((__excepts)-1)) == 0 \
  44. && (__excepts) != FE_INVALID) \
  45. ? ((__excepts) != 0 \
  46. ? (__extension__ ({ __asm__ __volatile__ \
  47. ("mtfsb0 %s0" \
  48. : : "i#*X"(__builtin_ffs (__excepts))); \
  49. 0; })) \
  50. : 0) \
  51. : (feclearexcept) (__excepts))
  52. #endif /* __GNUC__ && !_SOFT_FLOAT */