fenvinline.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. /*
  19. * Disable for e500, uses library functions instead of in lines.
  20. */
  21. #ifndef __CONFIG_E500__
  22. #if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_MATH_INLINES
  23. /* Inline definition for fegetround. */
  24. # define fegetround() \
  25. (__extension__ ({ int __fegetround_result; \
  26. __asm__ __volatile__ \
  27. ("mcrfs 7,7 ; mfcr %0" \
  28. : "=r"(__fegetround_result) : : "cr7"); \
  29. __fegetround_result & 3; }))
  30. /* The weird 'i#*X' constraints on the following suppress a gcc
  31. warning when __excepts is not a constant. Otherwise, they mean the
  32. same as just plain 'i'. */
  33. /* Inline definition for feraiseexcept. */
  34. # define feraiseexcept(__excepts) \
  35. ((__builtin_constant_p (__excepts) \
  36. && ((__excepts) & ((__excepts)-1)) == 0 \
  37. && (__excepts) != FE_INVALID) \
  38. ? ((__excepts) != 0 \
  39. ? (__extension__ ({ __asm__ __volatile__ \
  40. ("mtfsb1 %s0" \
  41. : : "i#*X"(__builtin_ffs (__excepts))); \
  42. 0; })) \
  43. : 0) \
  44. : (feraiseexcept) (__excepts))
  45. /* Inline definition for feclearexcept. */
  46. # define feclearexcept(__excepts) \
  47. ((__builtin_constant_p (__excepts) \
  48. && ((__excepts) & ((__excepts)-1)) == 0 \
  49. && (__excepts) != FE_INVALID) \
  50. ? ((__excepts) != 0 \
  51. ? (__extension__ ({ __asm__ __volatile__ \
  52. ("mtfsb0 %s0" \
  53. : : "i#*X"(__builtin_ffs (__excepts))); \
  54. 0; })) \
  55. : 0) \
  56. : (feclearexcept) (__excepts))
  57. #endif /* __GNUC__ && !_SOFT_FLOAT */
  58. #endif /* __CONFIG_E500__ */