• 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 
lrint(double x)8 long lrint (double x)
9 {
10   long retval = 0L;
11 #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__)
12   __asm__ __volatile__ ("fistpl %0"  : "=m" (retval) : "t" (x) : "st");
13 #elif defined(__arm__) || defined(_ARM_)
14   float temp;
15   __asm__ __volatile__ (
16     "vcvtr.s32.f64    %[tmp], %[src]\n\t"
17     "fmrs             %[dst], %[tmp]\n\t"
18     : [dst] "=r" (retval), [tmp] "=t" (temp) : [src] "w" (x));
19 #elif defined(__aarch64__) || defined(_ARM64_)
20   __asm__ __volatile__ (
21     "frintx %d1, %d1\n\t"
22     "fcvtzs %w0, %d1\n\t"
23     : "=r" (retval), "+w" (x));
24 #endif
25   return retval;
26 }
27