fegetenv.c 524 B

123456789101112131415161718192021
  1. /*
  2. (C) Copyright 2019 Kalray S.A.
  3. This file provides fegetenv for the Coolidge processor.
  4. */
  5. #include <fenv.h>
  6. int fegetenv(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. /* 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. }