feupdateenv.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Install given floating-point environment and raise exceptions.
  2. Copyright (C) 1997-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
  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 <fenv.h>
  17. int
  18. __feupdateenv (const fenv_t *envp)
  19. {
  20. fexcept_t fpsr;
  21. /* Save current exceptions. */
  22. __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr));
  23. fpsr &= FE_ALL_EXCEPT;
  24. /* Install new environment. */
  25. __fesetenv (envp);
  26. /* Raise the saved exception. Incidently for us the implementation
  27. defined format of the values in objects of type fexcept_t is the
  28. same as the ones specified using the FE_* constants. */
  29. __feraiseexcept ((int) fpsr);
  30. /* Success. */
  31. return 0;
  32. }
  33. #include <shlib-compat.h>
  34. #if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
  35. strong_alias (__feupdateenv, __old_feupdateenv)
  36. compat_symbol (libm, __old_feupdateenv, feupdateenv, GLIBC_2_1);
  37. #endif
  38. libm_hidden_def (__feupdateenv)
  39. libm_hidden_ver (__feupdateenv, feupdateenv)
  40. versioned_symbol (libm, __feupdateenv, feupdateenv, GLIBC_2_2);