1 /* sf_rint.c -- define rintf
2    Copyright (c) 2011, 2012 ARM Ltd.  All rights reserved.
3 
4    Redistribution and use in source and binary forms, with or without
5    modification, are permitted provided that the following conditions
6    are met:
7    1. Redistributions of source code must retain the above copyright
8       notice, this list of conditions and the following disclaimer.
9    2. Redistributions in binary form must reproduce the above copyright
10       notice, this list of conditions and the following disclaimer in the
11       documentation and/or other materials provided with the distribution.
12    3. The name of the company may not be used to endorse or promote
13       products derived from this software without specific prior written
14       permission.
15 
16    THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
17    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19    IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21    TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
26 
27 #if __ARM_ARCH >= 8 && !defined (__SOFTFP__)
28 #include <math.h>
29 
30 float
rintf(float x)31 rintf (float x)
32 {
33   float result;
34   asm volatile ("vrintx.f32\t%0, %1" : "=t" (result) : "t" (x));
35   return result;
36 }
37 
38 #else
39 #include "../../common/sf_rint.c"
40 #endif
41