OSDN Git Service

Adjust repository version following WSL-5.2.2 release.
[mingw/mingw-org-wsl.git] / mingwrt / mingwex / fetestexcept.c
1 #include <fenv.h>
2 #include "cpu_features.h"
3 /* 7.6.2.5
4    The fetestexcept function determines which of a specified subset of
5    the exception flags are currently set. The excepts argument
6    specifies the exception flags to be queried.
7    The fetestexcept function returns the value of the bitwise OR of the
8    exception macros corresponding to the currently set exceptions
9    included in excepts. */
10
11 int fetestexcept (int excepts)
12 {
13
14   unsigned int _res;
15   __asm__ ("fnstsw %%ax" : "=a" (_res));
16
17
18   /* If SSE supported, return the union of the FPU and SSE flags.  */
19   if (__HAS_SSE)
20     {
21         unsigned int _csr;
22       __asm__ volatile("stmxcsr %0" : "=m" (_csr));
23       _res |= _csr;
24     }
25
26   return (_res & excepts & FE_ALL_EXCEPT);
27 }