fesetround.c 615 B

123456789101112131415161718192021
  1. /*
  2. (C) Copyright 2019 Kalray S.A.
  3. This file provides fesetround for the Coolidge processor.
  4. */
  5. #include <fenv.h>
  6. int fesetround(int rounding_mode)
  7. {
  8. /* Mask round to be sure only valid rounding bits are set */
  9. rounding_mode &= FE_RND_MASK;
  10. /* Set rounding mode bit-fields of $cs, with 'rounding_mode' as a
  11. set mask and FE_RND_MASK as a clear mask. */
  12. __builtin_kvx_wfxl(KVX_SFR_CS, ((long long)rounding_mode << 32) | FE_RND_MASK);
  13. /* The above insn cannot fail (while the OS allows access to the
  14. floating-point exception flags of the $cs register). Return
  15. success. */
  16. return 0;
  17. }