Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
git-mirror
/
glibc
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
0
Security
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security
Insights
Files
c1e6b45
abilist
aout
argp
assert
bits
catgets
conf
conform
crypt
csu
ctype
debug
dirent
dlfcn
elf
gmon
gnulib
grp
hesiod
hurd
iconv
iconvdata
include
inet
intl
io
libidn
libio
locale
localedata
login
mach
malloc
manual
math
misc
nis
nptl
nptl_db
nscd
nss
po
posix
pwd
resolv
resource
rt
scripts
setjmp
shadow
signal
socket
soft-fp
stdio-common
stdlib
streams
string
sunrpc
sysdeps
alpha
generic
gnu
i386
ia64
ieee754
mach
posix
powerpc
bits
elf
fpu
powerpc32
powerpc64
970
bits
elf
fpu
e_sqrt.c
e_sqrtf.c
s_ceil.S
s_ceilf.S
s_ceill.S
s_copysign.S
s_copysignf.S
s_copysignl.S
s_fabs.S
s_fabsl.S
s_fdim.c
s_floor.S
s_floorf.S
s_floorl.S
s_fmax.S
s_fmin.S
s_isnan.S
s_llrint.S
s_llrintf.S
s_llround.S
s_llroundf.S
s_lrint.S
s_lround.S
s_lroundf.S
s_nearbyintl.S
s_rint.S
s_rintf.S
s_round.S
s_roundf.S
s_roundl.S
s_trunc.S
s_truncf.S
s_truncl.S
power4
power5+
power5
power6
power6x
Implies
Makefile
__longjmp-common.S
__longjmp.S
backtrace.c
bp-asm.h
bsd-_setjmp.S
bsd-setjmp.S
configure
configure.in
dl-dtprocnum.h
dl-machine.c
dl-machine.h
dl-trampoline.S
ffsll.c
hp-timing.c
hp-timing.h
memcpy.S
memset.S
ppc-mcount.S
register-dump.h
setjmp-common.S
setjmp.S
stpcpy.S
strchr.S
strcmp.S
strcpy.S
strlen.S
strncmp.S
sysdep.h
soft-fp
Implies
Makefile
Versions
abort-instr.h
configure
configure.in
dl-procinfo.c
dl-procinfo.h
dl-tls.h
ffs.c
gccframe.h
jmpbuf-offsets.h
jmpbuf-unwind.h
longjmp.c
machine-gmon.h
memusage.h
mp_clz_tab.c
novmx-longjmp.c
novmx-sigjmp.c
novmxsetjmp.h
sched_cpucount.c
sigjmp.c
stackinfo.h
strcat.c
sysdep.h
test-arith.c
test-arithf.c
tst-stack-align.h
pthread
s390
sh
sparc
unix
wordsize-32
wordsize-64
x86_64
sysvipc
termios
time
timezone
wcsmbs
wctype
.cvsignore
BUGS
CANCEL-FCT-WAIVE
CANCEL-FILE-WAIVE
CONFORMANCE
COPYING
COPYING.LIB
ChangeLog
ChangeLog.1
ChangeLog.10
ChangeLog.11
ChangeLog.12
ChangeLog.13
ChangeLog.14
ChangeLog.15
ChangeLog.16
ChangeLog.2
ChangeLog.3
ChangeLog.4
ChangeLog.5
ChangeLog.6
ChangeLog.7
ChangeLog.8
ChangeLog.9
FAQ
FAQ.in
INSTALL
LICENSES
Makeconfig
Makefile
Makefile.in
Makerules
NAMESPACE
NEWS
NOTES
PROJECTS
README
README.libm
README.template
Rules
Versions.def
WUR-REPORT
abi-tags
aclocal.m4
config-name.in
config.h.in
config.make.in
configure
configure.in
cppflags-iterator.mk
extra-lib.mk
extra-modules.mk
o-iterator.mk
shlib-versions
test-skeleton.c
tls.make.c
version.h
Breadcrumbs
glibc
/
sysdeps
/
powerpc
/
powerpc64
/
fpu
/
s_llround.S
Blame
Blame
Latest commit
History
History
92 lines (82 loc) · 3.37 KB
Breadcrumbs
glibc
/
sysdeps
/
powerpc
/
powerpc64
/
fpu
/
s_llround.S
Top
File metadata and controls
Code
Blame
92 lines (82 loc) · 3.37 KB
Raw
/* llround function. PowerPC64 version. Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include <sysdep.h> #include <math_ldbl_opt.h> .section ".toc","aw" .LC0: /* 2^52 */ .tc FD_43300000_0[TC],0x4330000000000000 .LC1: /* 0.5 */ .tc FD_3fe00000_0[TC],0x3fe0000000000000 .section ".text" /* long long [r3] llround (double x [fp1]) IEEE 1003.1 llround function. IEEE specifies "round to the nearest integer value, rounding halfway cases away from zero, regardless of the current rounding mode." However PowerPC Architecture defines "round to Nearest" as "Choose the best approximation. In case of a tie, choose the one that is even (least significant bit o).". So we can't use the PowerPC "round to Nearest" mode. Instead we set "round toward Zero" mode and round by adding +-0.5 before rounding to the integer value. It is necessary to detect when x is (+-)0x1.fffffffffffffp-2 because adding +-0.5 in this case will cause an erroneous shift, carry and round. We simply return 0 if 0.5 > x > -0.5. Likewise if x is and odd number between +-(2^52 and 2^53-1) a shift and carry will erroneously round if biased with +-0.5. Therefore if x is greater/less than +-2^52 we don't need to bias the number with +-0.5. */ ENTRY (__llround) CALL_MCOUNT 0 lfd fp9,.LC0@toc(2) /* Load 2^52 into fpr9. */ lfd fp10,.LC1@toc(2)/* Load 0.5 into fpr10. */ fabs fp2,fp1 /* Get the absolute value of x. */ fsub fp12,fp10,fp10 /* Compute 0.0 into fp12. */ fcmpu cr6,fp2,fp10 /* if |x| < 0.5 */ fcmpu cr4,fp2,fp9 /* if |x| >= 2^52 */ fcmpu cr3,fp1,fp12 /* x is negative? x < 0.0 */ blt- cr6,.Lretzero /* 0.5 > x < -0.5 so just return 0. */ bge- cr4,.Lnobias /* 2^52 > x < -2^52 just convert with no bias. */ fadd fp3,fp2,fp10 /* |x|+=0.5 bias to prepare to round. */ bge cr3,.Lconvert /* x is positive so don't negate x. */ fnabs fp3,fp3 /* -(|x|+=0.5) */ .Lconvert: fctidz fp4,fp3 /* Convert to Integer double word round toward 0. */ stfd fp4,-16(r1) nop nop nop ld r3,-16(r1) /* Load return as integer. */ .Lout: blr .Lretzero: /* 0.5 > x > -0.5 */ li r3,0 /* return 0. */ b .Lout .Lnobias: fmr fp3,fp1 b .Lconvert END (__llround) strong_alias (__llround, __lround) weak_alias (__llround, llround) weak_alias (__lround, lround) #ifdef NO_LONG_DOUBLE weak_alias (__llround, llroundl) strong_alias (__llround, __llroundl) weak_alias (__lround, lroundl) strong_alias (__lround, __lroundl) #endif #if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) compat_symbol (libm, __llround, llroundl, GLIBC_2_1) compat_symbol (libm, __lround, lroundl, GLIBC_2_1) #endif
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
You can’t perform that action at this time.