Cygwin: (mostly) drop NT4 and Samba < 3.0 support
[newlib-cygwin.git] / winsup / cygwin / math / lrint.c
blob28c2e150abc5195ac53a35145431706d424eddba
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>
8 #if defined(__arm__) || defined(_ARM_)
9 /* This works around a compiler bug */
10 long __lrint_internal( double x );
11 asm(".def __lrint_internal; .scl 2; .type 32; .endef\n"
12 "\t.text\n"
13 "\t.align 4\n"
14 "\t.globl __lrint_internal\n"
15 "__lrint_internal:\n"
16 "\tvcvtr.s32.f64 s0, d0\n"
17 "\tfmrs r0, s0\n"
18 "\tbx lr");
19 #endif /* defined(__arm__) || defined(_ARM_) */
21 long lrint (double x)
23 long retval = 0L;
24 #if defined (__x86_64__) && defined (__CYGWIN__)
25 __asm__ __volatile__ ("fistpll %0" : "=m" (retval) : "t" (x) : "st");
26 #elif defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__)
27 __asm__ __volatile__ ("fistpl %0" : "=m" (retval) : "t" (x) : "st");
28 #elif defined(__arm__) || defined(_ARM_)
29 retval = __lrint_internal(x);
30 #endif
31 return retval;