fesetenv.c 662 B

1234567891011121314151617181920212223
  1. /*
  2. (C) Copyright 2019 Kalray S.A.
  3. This file provides fesetenv for the Coolidge processor.
  4. */
  5. #include <fenv.h>
  6. int fesetenv(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. /* Set exception flags and rounding mode bit-fields of $cs, with
  12. 'fe' as a set mask and FE_ALL_EXCEPT|FE_RND_MASK as a clear
  13. mask. */
  14. __builtin_kvx_wfxl(KVX_SFR_CS, ((long long)fe << 32) | FE_ALL_EXCEPT | FE_RND_MASK);
  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. }