1 /* Round to nearest integer.  PowerPC64 version.
2    Copyright (C) 2019-2022 Free Software Foundation, Inc.
3    This file is part of the GNU C Library
4 
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9 
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Library General Public License for more details.
14 
15    You should have received a copy of the GNU Library General Public
16    License along with the GNU C Library; see the file COPYING.LIB.  If
17    not, see <https://www.gnu.org/licenses/>.  */
18 
19 #define NO_MATH_REDIRECT
20 #define lrint __redirect_lrint
21 #define lrintf __redirect_lrintf
22 #define llrintf __redirect_llrintf
23 #define __lrint __redirect___lrint
24 #define __lrintf __redirect___lrintf
25 #define __llrintf __redirect___llrintf
26 #include <math.h>
27 #undef lrint
28 #undef lrintf
29 #undef llrintf
30 #undef __lrint
31 #undef __lrintf
32 #undef __llrintf
33 #include <libm-alias-float.h>
34 #include <libm-alias-double.h>
35 
36 long long int
__llrint(double x)37 __llrint (double x)
38 {
39   long int ret;
40   __asm__ ("fctid %0, %1" : "=d" (ret) : "d" (x));
41   return ret;
42 }
43 #ifndef __llrint
44 strong_alias (__llrint, __lrint)
45 libm_alias_double (__llrint, llrint)
46 libm_alias_double (__lrint, lrint)
47 
48 /* The double version also works for single-precision as both float and
49    double parameters are passed in 64bit FPRs and both versions are expected
50    to return [long] long type.  */
51 strong_alias (__llrint, __llrintf)
52 libm_alias_float (__llrint, llrint)
53 strong_alias (__lrint, __lrintf)
54 libm_alias_float (__lrint, lrint)
55 #endif
56