This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
floor was broken the same way that ceil was on AMD64. I've added a test to libm-test.inc that caught this and added some further long double functions for AMD64. Ok to commit? The testsuite on AMD64 passes all math tests. Andreas 2003-11-15 Andreas Jaeger <aj@suse.de> * sysdeps/x86_64/fpu/s_scalbnl.S: New. * sysdeps/x86_64/fpu/s_truncl.S: New. * sysdeps/x86_64/fpu/s_nearbyintl.S: New. * sysdeps/x86_64/fpu/s_floorl.S: New. * sysdeps/x86_64/fpu/s_ilogbl.S: New. * sysdeps/x86_64/fpu/e_remainderl.S: New. * math/libm-test.inc (floor_test): Test also +/-0.25. (ceil_test): Test -0.25. ============================================================ Index: math/libm-test.inc --- math/libm-test.inc 14 Nov 2003 00:34:54 -0000 1.52 +++ math/libm-test.inc 15 Nov 2003 14:47:52 -0000 @@ -1626,6 +1626,7 @@ ceil_test (void) TEST_f_f (ceil, M_PIl, 4.0); TEST_f_f (ceil, -M_PIl, -3.0); TEST_f_f (ceil, 0.25, 1.0); + TEST_f_f (ceil, -0.25, minus_zero); END (ceil); } @@ -2571,6 +2572,9 @@ floor_test (void) TEST_f_f (floor, M_PIl, 3.0); TEST_f_f (floor, -M_PIl, -4.0); + + TEST_f_f (floor, 0.25, 0.0); + TEST_f_f (floor, -0.25, -1.0); END (floor); } ============================================================ Index: sysdeps/x86_64/fpu/s_scalbnl.S --- sysdeps/x86_64/fpu/s_scalbnl.S created +++ sysdeps/x86_64/fpu/s_scalbnl.S 2003-11-15 15:12:53.000000000 +0100 1.1 @@ -0,0 +1,18 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Changes for long double by Ulrich Drepper <drepper@cygnus.com> + * Changes for x86-64 by Andreas Jaeger <aj@suse.de> + * Public domain. + */ + +#include <machine/asm.h> + +ENTRY(__scalbnl) + movl %edi,-4(%rsp) + fildl -4(%rsp) + fldt 8(%rsp) + fscale + fstp %st(1) + ret +END (__scalbnl) +weak_alias (__scalbnl, scalbnl) ============================================================ Index: sysdeps/x86_64/fpu/s_truncl.S --- sysdeps/x86_64/fpu/s_truncl.S created +++ sysdeps/x86_64/fpu/s_truncl.S 2003-11-15 15:04:07.000000000 +0100 1.1 @@ -0,0 +1,34 @@ +/* Truncate long double value. + Copyright (C) 1997, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + 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 <machine/asm.h> + +ENTRY(__truncl) + fldt 8(%rsp) + fstcw -4(%rsp) + movl $0xc00, %edx + orl -4(%rsp), %edx + movl %edx, -8(%rsp) + fldcw -8(%rsp) + frndint + fldcw -4(%rsp) + ret +END(__truncl) +weak_alias (__truncl, truncl) ============================================================ Index: sysdeps/x86_64/fpu/s_nearbyintl.S --- sysdeps/x86_64/fpu/s_nearbyintl.S created +++ sysdeps/x86_64/fpu/s_nearbyintl.S 2003-11-15 14:59:18.000000000 +0100 1.1 @@ -0,0 +1,21 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + */ +/* Adapted for use as nearbyint by Ulrich Drepper <drepper@cygnus.com>. */ + +#include <machine/asm.h> + +ENTRY(__nearbyintl) + fldt 8(%rsp) + fnstcw -4(%rsp) + movl -4(%rsp), %eax + orl $0x20, %eax + movl %eax, -8(%rsp) + fldcw -8(%rsp) + frndint + fclex + fldcw -4(%rsp) + ret +END (__nearbyintl) +weak_alias (__nearbyintl, nearbyintl) ============================================================ Index: sysdeps/x86_64/fpu/s_floorl.S --- sysdeps/x86_64/fpu/s_floorl.S created +++ sysdeps/x86_64/fpu/s_floorl.S 2003-11-15 14:53:36.000000000 +0100 1.1 @@ -0,0 +1,30 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Changes for long double by Ulrich Drepper <drepper@cygnus.com> + * Changes for x86-64 by Andreas Jaeger <aj@suse.de> + * Public domain. + */ + +#include <machine/asm.h> + +ENTRY(__floorl) + fldt 8(%rsp) + + fstcw -4(%rsp) /* store fpu control word */ + + /* We use here %edx although only the low 1 bits are defined. + But none of the operations should care and they are faster + than the 16 bit operations. */ + movl $0x400,%edx /* round towards -oo */ + orl -4(%rsp),%edx + andl $0xf7ff,%edx + movl %edx,-8(%rsp) + fldcw -8(%rsp) /* load modified control word */ + + frndint /* round */ + + fldcw -4(%rsp) /* restore original control word */ + + ret +END (__floorl) +weak_alias (__floorl, floorl) ============================================================ Index: sysdeps/x86_64/fpu/e_remainderl.S --- sysdeps/x86_64/fpu/e_remainderl.S created +++ sysdeps/x86_64/fpu/e_remainderl.S 2003-11-15 15:46:14.000000000 +0100 1.1 @@ -0,0 +1,20 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + * Adapted for x86-64 by Andreas Jaeger <aj@suse.de>. + */ + +#include <machine/asm.h> + +ENTRY(__ieee754_remainderl) + fldt 24(%rsp) + fldt 8(%rsp) +1: fprem1 + fstsw %ax + testl $0x400,%eax + jnz 1b + fstp %st(1) + ret +END (__ieee754_remainderl) ============================================================ Index: sysdeps/x86_64/fpu/s_ilogbl.S --- sysdeps/x86_64/fpu/s_ilogbl.S created +++ sysdeps/x86_64/fpu/s_ilogbl.S 2003-11-15 15:34:39.000000000 +0100 1.1 @@ -0,0 +1,35 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Changes for long double by Ulrich Drepper <drepper@cygnus.com> + * Adapted for x86-64 by Andreas Jaeger <aj@suse.de>. + * Public domain. + */ + +#include <machine/asm.h> + +ENTRY(__ilogbl) + fldt 8(%rsp) +/* I added the following ugly construct because ilogb(+-Inf) is + required to return INT_MAX in ISO C99. + -- jakub@redhat.com. */ + fxam /* Is NaN or +-Inf? */ + fstsw %ax + movb $0x45, %dh + andb %ah, %dh + cmpb $0x05, %dh + je 1f /* Is +-Inf, jump. */ + + fxtract + fstp %st + + fistpl -4(%rsp) + fwait + movl -4(%rsp),%eax + + ret + +1: fstp %st + movl $0x7fffffff, %eax + ret +END (__ilogbl) +weak_alias (__ilogbl, ilogbl) -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SuSE Linux AG, Deutschherrnstr. 15-19, 90429 Nürnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126
Attachment:
pgp00000.pgp
Description: PGP signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |