summaryrefslogtreecommitdiff
path: root/libm/kvx/fetestexcept.c
blob: b8ed8f0e6ee23e2a6f3b3ba38fdeb1943e04c042 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
  (C) Copyright 2019 Kalray S.A.
  This file provides fesetexcept for the Coolidge processor.
*/

#include <fenv.h>

int fetestexcept(int excepts)
{
  /* Mask excepts to be sure only supported flag bits are set */
  excepts &= FE_ALL_EXCEPT;

  /* Get the current exception flags of the $cs register. */
  fexcept_t flags;
  flags = __builtin_kvx_get(KVX_SFR_CS);

  /* Return the floating-point exception macros that are both included
     in excepts and correspond to the floating-point exceptions
     currently set. */
  return (flags & excepts);
}