feupdateenv.c 728 B

123456789101112131415161718192021222324
  1. /*
  2. (C) Copyright 2019 Kalray S.A.
  3. This file provides feupdateenv for the Coolidge processor.
  4. */
  5. #include <fenv.h>
  6. int feupdateenv(const fenv_t *envp)
  7. {
  8. /* Mask *envp to be sure only valid bits are set */
  9. fenv_t fe = *envp;
  10. fe &= (FE_ALL_EXCEPT|FE_RND_MASK);
  11. /* Update exception flags and rounding mode bit-fields of $cs, with
  12. 'fe' as a set mask and FE_RND_MASK as a clear mask. FE_ALL_EXCEPT
  13. is not cleared: restores rounding mode and updates exception
  14. flags. */
  15. __builtin_kvx_wfxl(KVX_SFR_CS, ((long long)fe << 32) | FE_RND_MASK);
  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. }