]> git.ipfire.org Git - thirdparty/glibc.git/blame - powerpc-cpu/sysdeps/powerpc/powerpc32/power6x/fpu/s_lround.S
2.5-18.1
[thirdparty/glibc.git] / powerpc-cpu / sysdeps / powerpc / powerpc32 / power6x / fpu / s_lround.S
CommitLineData
0ecb606c
JJ
1/* lround function. POWER6x, PowerPC32 version.
2 Copyright (C) 2006 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 Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the 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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 1 Franklin Street, Fifth Floor, Boston MA
18 02110-1301 USA. */
19
20#include <sysdep.h>
21#include <math_ldbl_opt.h>
22
23/* long [r3] lround (float x [fp1])
24 IEEE 1003.1 lround function. IEEE specifies "round to the nearest
25 integer value, rounding halfway cases away from zero, regardless of
26 the current rounding mode." However PowerPC Architecture defines
27 "round to Nearest" as "Choose the best approximation. In case of a
28 tie, choose the one that is even (least significant bit o).".
29 So we pre-round using the V2.02 Floating Round to Integer Nearest
30 instruction before we use the Floating Convert to Integer Word with
31 round to zero instruction. */
32
33 .machine "power6"
34ENTRY (__lround)
35 frin fp2,fp1 /* Pre-round +-0.5. */
36 fctiwz fp3,fp2 /* Convert To Integer Word lround toward 0. */
37 mftgpr r3,fp3 /* Transfer fpr3 to r3. */
38 blr
39 END (__lround)
40
41weak_alias (__lround, lround)
42
43strong_alias (__lround, __lroundf)
44weak_alias (__lround, lroundf)
45
46#ifdef NO_LONG_DOUBLE
47weak_alias (__lround, lroundl)
48strong_alias (__lround, __lroundl)
49#endif
50#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
51compat_symbol (libm, __lround, lroundl, GLIBC_2_1)
52#endif