feupdateenv.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (C) 2016-2017 Andes Technology, Inc.
  3. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  4. */
  5. /* Install given floating-point environment and raise exceptions.
  6. Copyright (C) 1997-2013 Free Software Foundation, Inc.
  7. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
  8. The GNU C Library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Lesser General Public
  10. License as published by the Free Software Foundation; either
  11. version 2.1 of the License, or (at your option) any later version.
  12. The GNU C Library is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. Lesser General Public License for more details.
  16. You should have received a copy of the GNU Lesser General Public
  17. License along with the GNU C Library. If not, see
  18. <http://www.gnu.org/licenses/>. */
  19. #include <fenv.h>
  20. #include <fpu_control.h>
  21. int
  22. feupdateenv (const fenv_t *envp)
  23. {
  24. #ifdef __NDS32_ABI_2FP_PLUS__
  25. unsigned int temp;
  26. /* Get the current exception state. */
  27. _FPU_GETCW (temp);
  28. /* Install new environment. */
  29. fesetenv (envp);
  30. /* Raise the saved exceptions. */
  31. feraiseexcept (temp & FE_ALL_EXCEPT);
  32. /* Success. */
  33. return 0;
  34. #else
  35. /* Unsupported, so fail. */
  36. return 1;
  37. #endif
  38. }