fegetexceptflag.c 629 B

123456789101112131415161718192021222324
  1. /*
  2. (C) Copyright 2019 Kalray S.A.
  3. This file provides fegetexceptflag for the Coolidge processor.
  4. */
  5. #include <fenv.h>
  6. int fegetexceptflag(fexcept_t *flagp, int excepts)
  7. {
  8. /* Mask excepts to be sure only supported flag bits are set */
  9. excepts &= FE_ALL_EXCEPT;
  10. /* Get the current exception flags of the $cs register. */
  11. fexcept_t flags;
  12. flags = __builtin_kvx_get(KVX_SFR_CS);
  13. /* Return the requested flags in flagp */
  14. *flagp = flags & excepts;
  15. /* The above insn cannot fail (while the OS allows access to the
  16. floating-point exception flags of the $cs register). Return
  17. success. */
  18. return 0;
  19. }