fedisblxcpt.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. /* Disable floating-point exceptions.
  6. Copyright (C) 2001-2013 Free Software Foundation, Inc.
  7. Contributed by Philip Blundell <philb@gnu.org>, 2001.
  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 "fenv_libc.h"
  21. #include <fpu_control.h>
  22. int
  23. fedisableexcept (int excepts)
  24. {
  25. #ifdef __NDS32_ABI_2FP_PLUS__
  26. unsigned long int new_exc, old_exc;
  27. _FPU_GETCW(new_exc);
  28. old_exc = (new_exc & ENABLE_MASK) >> ENABLE_SHIFT;
  29. excepts &= FE_ALL_EXCEPT;
  30. new_exc &= ~(excepts << ENABLE_SHIFT);
  31. new_exc &= ~_FPU_RESERVED;
  32. _FPU_SETCW (new_exc);
  33. return old_exc;
  34. #else
  35. /* Unsupported, so return -1 for failure. */
  36. return -1;
  37. #endif
  38. }