feholdexcept.c 712 B

1234567891011121314151617181920212223242526
  1. /*
  2. (C) Copyright 2019 Kalray S.A.
  3. This file provides feholdexcept for the Coolidge processor.
  4. */
  5. #include <fenv.h>
  6. int feholdexcept(fenv_t *envp)
  7. {
  8. /* Get the current environment ($cs) */
  9. fenv_t fe;
  10. fe = __builtin_kvx_get(KVX_SFR_CS);
  11. /* Mask $cs status to keep exception flags and rounding mode only. */
  12. *envp = (fe & (FE_ALL_EXCEPT | FE_RND_MASK));
  13. /* Set $cs with 'FE_ALL_EXCEPT' as a clear mask. */
  14. __builtin_kvx_wfxl(KVX_SFR_CS, FE_ALL_EXCEPT);
  15. /* KVX does not raise FP traps so it is always in a "non-stop" mode */
  16. /* The above insn cannot fail (while the OS allows access to the
  17. floating-point exception flags of the $cs register). Return
  18. success. */
  19. return 0;
  20. }