fenvinline.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Inline floating-point environment handling functions for powerpc.
  2. Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_MATH_INLINES
  17. /* Inline definition for fegetround. */
  18. # define fegetround() \
  19. (__extension__ ({ int __fegetround_result; \
  20. __asm__ ("mcrfs 7,7 ; mfcr %0" \
  21. : "=r"(__fegetround_result) : : "cr7"); \
  22. __fegetround_result & 3; }))
  23. /* The weird 'i#*X' constraints on the following suppress a gcc
  24. warning when __excepts is not a constant. Otherwise, they mean the
  25. same as just plain 'i'. */
  26. /* Inline definition for feraiseexcept. */
  27. # define feraiseexcept(__excepts) \
  28. ((__builtin_constant_p (__excepts) \
  29. && ((__excepts) & ((__excepts)-1)) == 0 \
  30. && (__excepts) != FE_INVALID) \
  31. ? ((__excepts) != 0 \
  32. ? (__extension__ ({ __asm__ __volatile__ \
  33. ("mtfsb1 %s0" \
  34. : : "i#*X"(__builtin_ffs (__excepts))); \
  35. 0; })) \
  36. : 0) \
  37. : (feraiseexcept) (__excepts))
  38. /* Inline definition for feclearexcept. */
  39. # define feclearexcept(__excepts) \
  40. ((__builtin_constant_p (__excepts) \
  41. && ((__excepts) & ((__excepts)-1)) == 0 \
  42. && (__excepts) != FE_INVALID) \
  43. ? ((__excepts) != 0 \
  44. ? (__extension__ ({ __asm__ __volatile__ \
  45. ("mtfsb0 %s0" \
  46. : : "i#*X"(__builtin_ffs (__excepts))); \
  47. 0; })) \
  48. : 0) \
  49. : (feclearexcept) (__excepts))
  50. #endif /* __GNUC__ && !_SOFT_FLOAT */