mirror of
https://git.code.sf.net/p/mingw-w64/mingw-w64
synced 2024-11-30 21:34:21 +08:00
e33afcd864
Don't converting from one pointer type to another via a union; that is still a strict aliasing violation as far as I know. Use unions for actually reinterpreting the values instead, which is not an aliasing violation, and is defined according to the C99 standard (which also was relied on before). Signed-off-by: Martin Storsjö <martin@martin.st>
28 lines
720 B
C
28 lines
720 B
C
/**
|
|
* This file is part of the mingw-w64 runtime package.
|
|
* No warranty is given; refer to the file DISCLAIMER within this package.
|
|
*/
|
|
|
|
#include <math.h>
|
|
|
|
#define __FP_SIGNBIT 0x0200
|
|
|
|
|
|
int __signbitl (long double x) {
|
|
#if defined(__x86_64__) || defined(_AMD64_)
|
|
__mingw_ldbl_type_t ld;
|
|
ld.x = x;
|
|
return ((ld.lh.sign_exponent & 0x8000) != 0);
|
|
#elif defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
|
return __signbit(x);
|
|
#elif defined(__i386__) || defined(_X86_)
|
|
unsigned short sw;
|
|
__asm__ __volatile__ ("fxam; fstsw %%ax;"
|
|
: "=a" (sw)
|
|
: "t" (x) );
|
|
return (sw & __FP_SIGNBIT) != 0;
|
|
#endif
|
|
}
|
|
|
|
int __attribute__ ((alias ("__signbitl"))) signbitl (long double);
|