fclrexcpt.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. /* Clear given exceptions in current floating-point environment.
  6. Copyright (C) 1997-2013 Free Software Foundation, Inc.
  7. The GNU C Library is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU Lesser General Public
  9. License as published by the Free Software Foundation; either
  10. version 2.1 of the License, or (at your option) any later version.
  11. The GNU C Library is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. Lesser General Public License for more details.
  15. You should have received a copy of the GNU Lesser General Public
  16. License along with the GNU C Library. If not, see
  17. <http://www.gnu.org/licenses/>. */
  18. #include <fenv.h>
  19. #include "fenv_libc.h"
  20. #include <fpu_control.h>
  21. int
  22. feclearexcept (int excepts)
  23. {
  24. #ifdef __NDS32_ABI_2FP_PLUS__
  25. unsigned long int temp;
  26. /* Mask out unsupported bits/exceptions. */
  27. excepts &= FE_ALL_EXCEPT;
  28. /* Get the current floating point status. */
  29. _FPU_GETCW (temp);
  30. /* Clear the relevant bits. */
  31. temp &= ~excepts;
  32. /* Put the new data in effect. */
  33. _FPU_SETCW (temp);
  34. /* Success. */
  35. return 0;
  36. #else
  37. /* Unsupported, so fail unless nothing needs to be done. */
  38. return (excepts != 0);
  39. #endif
  40. }