• 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 
lrintf(float x)8 long lrintf (float 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   __asm__ __volatile__ (
15     "vcvtr.s32.f32    %[src], %[src]\n\t"
16     "fmrs             %[dst], %[src]\n\t"
17     : [dst] "=r" (retval), [src] "+w" (x));
18 #elif defined(__aarch64__) || defined(_ARM64_)
19   __asm__ __volatile__ (
20     "frintx %s1, %s1\n\t"
21     "fcvtzs %w0, %s1\n\t"
22     : "=r" (retval), "+w" (x));
23 #endif
24   return retval;
25 }
26