| 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 | #define __FP_SIGNBIT 0x0200 |
| 7 | int __signbit (double x); |
| 8 | |
| 9 | typedef union __mingw_dbl_type_t { |
| 10 | double x; |
| 11 | unsigned long long val; |
| 12 | __extension__ struct { |
| 13 | unsigned int low, high; |
| 14 | } lh; |
| 15 | } __mingw_dbl_type_t; |
| 16 | |
| 17 | int __signbit (double x) |
| 18 | { |
| 19 | #if defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) |
| 20 | __mingw_dbl_type_t hlp; |
| 21 | |
| 22 | hlp.x = x; |
| 23 | return ((hlp.lh.high & 0x80000000) != 0); |
| 24 | #elif defined(__i386__) || defined(_X86_) |
| 25 | unsigned short sw; |
| 26 | __asm__ __volatile__ ("fxam; fstsw %%ax;" |
| 27 | 	 : "=a" (sw) |
| 28 | 	 : "t" (x) ); |
| 29 | return (sw & __FP_SIGNBIT) != 0; |
| 30 | #endif |
| 31 | } |
| 32 | |
| 33 | #undef signbit |
| 34 | int __attribute__ ((alias ("__signbit"))) signbit (double); |
| 35 | |