feupdateenv.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Install given floating-point environment and raise exceptions.
  2. Copyright (C) 1997-2026 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, see
  14. <https://www.gnu.org/licenses/>. */
  15. #include <fenv.h>
  16. #include <fenv_private.h>
  17. #include <shlib-compat.h>
  18. int
  19. __feupdateenv (const fenv_t *envp)
  20. {
  21. fexcept_t tmp;
  22. /* Save current exceptions. */
  23. __fenv_stfsr (tmp);
  24. tmp &= FE_ALL_EXCEPT;
  25. /* Install new environment. */
  26. __fesetenv (envp);
  27. /* Raise the saved exception. Incidentally for us the implementation
  28. defined format of the values in objects of type fexcept_t is the
  29. same as the ones specified using the FE_* constants. */
  30. __feraiseexcept ((int) tmp);
  31. /* Success. */
  32. return 0;
  33. }
  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);