• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * This file has no copyright assigned and is placed in the Public Domain.
3  * This file is part of the mingw-w64 runtime package.
4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5  */
6 #include <math.h>
7 
8 int
__isnan(double _x)9 __isnan (double _x)
10 {
11 #if defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
12     __mingw_dbl_type_t hlp;
13     int l, h;
14 
15     hlp.x = _x;
16     l = hlp.lh.low;
17     h = hlp.lh.high & 0x7fffffff;
18     h |= (unsigned int) (l | -l) >> 31;
19     h = 0x7ff00000 - h;
20     return (int) ((unsigned int) h) >> 31;
21 #elif defined(__i386__) || defined(_X86_)
22   unsigned short _sw;
23   __asm__ __volatile__ ("fxam;"
24 	   "fstsw %%ax": "=a" (_sw) : "t" (_x));
25   return (_sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL))
26     == FP_NAN;
27 #endif
28 }
29 
30 #undef isnan
31 int __attribute__ ((alias ("__isnan"))) isnan (double);
32