fclrexcpt.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* Clear given exceptions in current floating-point environment.
  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_libc.h>
  16. int
  17. __feclearexcept (int excepts)
  18. {
  19. unsigned long int swcr;
  20. /* Get the current state. */
  21. swcr = __ieee_get_fp_control ();
  22. /* Clear the relevant bits. */
  23. swcr &= ~((unsigned long int) excepts & SWCR_STATUS_MASK);
  24. /* Put the new state in effect. */
  25. __ieee_set_fp_control (swcr);
  26. /* Success. */
  27. return 0;
  28. }
  29. libm_hidden_def (__feclearexcept)
  30. #include <shlib-compat.h>
  31. #if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
  32. strong_alias (__feclearexcept, __old_feclearexcept)
  33. compat_symbol (libm, __old_feclearexcept, feclearexcept, GLIBC_2_1);
  34. #endif
  35. libm_hidden_ver (__feclearexcept, feclearexcept)
  36. versioned_symbol (libm, __feclearexcept, feclearexcept, GLIBC_2_2);