From 5ce98c3f3f6a4715ce4ddef03a2f15b2dcf7d676 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 3 May 2004 21:40:12 +0000 Subject: Update. 2004-05-03 Jakub Jelinek * sysdeps/unix/bsd/bits/fcntl.h (F_SETOWN, F_GETOWN): Define if __USE_BSD or __USE_UNIX98. * sysdeps/unix/bsd/ultrix4/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/bsd/bsd4.4/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/bsd/sun/sunos4/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/common/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/aix/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/irix4/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/alpha/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/s390/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/cris/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. *sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/sparc/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/mips/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/sh/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/i386/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/m68k/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/ia64/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/arm/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/hppa/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/generic/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * sysdeps/mach/hurd/bits/fcntl.h (F_SETOWN, F_GETOWN): Likewise. * io/sys/stat.h (S_ISSOCK, S_IFSOCK): Likewise. 2004-05-01 Jakub Jelinek * posix/Versions (libc): Remove __libc_wait, __libc_waitpid, __libc_pause, __libc_nanosleep, __libc_pread, __libc_pread64, __libc_pwrite64, __waitid and __pselect @@GLIBC_PRIVATE. * stdlib/Versions (libc): Remove __on_exit@@GLIBC_PRIVATE. * sysdeps/unix/sysv/linux/Versions (libc): Remove __libc_sigaction@@GLIBC_PRIVATE. * sysdeps/unix/sysv/linux/x86_64/Versions (libc): Remove __modify_ldt@@GLIBC_PRIVATE. * socket/Versions (libc): Remove __libc_accept, __libc_send, __libc_recvfrom, __libc_recvmsg, __libc_sendmsg, __libc_recv, __libc_sendto and __libc_connect @@GLIBC_PRIVATE. * stdio-common/Versions (libc): Remove _itoa_upper_digits@@GLIBC_PRIVATE. * resolv/Versions (libresolv): Remove __ns_samename@@GLIBC_PRIVATE. * misc/Versions (libc): Remove __libc_fsync, __libc_msync, __libc_readv and __libc_writev @@GLIBC_PRIVATE. * termios/Versions (libc): Remove __libc_tcdrain@@GLIBC_PRIVATE. * io/Versions (libc): Remove __libc_open, __libc_close, __libc_read, __libc_write, __libc_lseek, __libc_fcntl, __libc_open64 and __libc_lseek64 @@GLIBC_PRIVATE. 2004-04-30 Jakub Jelinek * elf/dl-load.c (open_verify): Move e_phentsize check after e_type check. 2004-04-29 Steven Munroe * sysdeps/powerpc/powerpc64/fpu/s_ceil.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_ceilf.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_floor.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_floorf.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_llrint.c: Removed. * sysdeps/powerpc/powerpc64/fpu/s_llrint.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_llrintf.c: Removed. * sysdeps/powerpc/powerpc64/fpu/s_llrintf.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_llround.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_llroundf.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_lround.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_lroundf.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_rint.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_rintf.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_round.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_roundf.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_trunc.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_truncf.S: New file. * math/test-misc.c [LDBL_MANT_DIG == 106](main): Correct LDBL_MAX mantissa for AIX long double format. * misc/qefgcvt.c [LDBL_MANT_DIG == 106] (NDIGIT_MAX): Define for AIX long double format. * misc/qefgcvt_r.c [LDBL_MANT_DIG == 106] (NDIGIT_MAX): Likewise. * stdlib/fpioconst.c [!__NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__>1024] (_fpioconst_pow10): AIX long double format has same exponent range as double. * stdlib/fpioconst.h [!__NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__>1024] (LDBL_MAX_10_EXP_LOG): AIX long double format has same exponent range as double. 2004-04-23 Art Haas * sysdeps/unix/sysv/linux/kernel-features.h: Add 'defined'. --- sysdeps/powerpc/powerpc64/fpu/s_ceil.S | 60 ++++++++++++++++++++++++ sysdeps/powerpc/powerpc64/fpu/s_ceilf.S | 56 ++++++++++++++++++++++ sysdeps/powerpc/powerpc64/fpu/s_floor.S | 58 +++++++++++++++++++++++ sysdeps/powerpc/powerpc64/fpu/s_floorf.S | 54 +++++++++++++++++++++ sysdeps/powerpc/powerpc64/fpu/s_llrint.S | 42 +++++++++++++++++ sysdeps/powerpc/powerpc64/fpu/s_llrint.c | 46 ------------------ sysdeps/powerpc/powerpc64/fpu/s_llrintf.S | 36 ++++++++++++++ sysdeps/powerpc/powerpc64/fpu/s_llrintf.c | 36 -------------- sysdeps/powerpc/powerpc64/fpu/s_llround.S | 67 ++++++++++++++++++++++++++ sysdeps/powerpc/powerpc64/fpu/s_llroundf.S | 59 +++++++++++++++++++++++ sysdeps/powerpc/powerpc64/fpu/s_lround.S | 2 + sysdeps/powerpc/powerpc64/fpu/s_lroundf.S | 2 + sysdeps/powerpc/powerpc64/fpu/s_rint.S | 54 +++++++++++++++++++++ sysdeps/powerpc/powerpc64/fpu/s_rintf.S | 47 +++++++++++++++++++ sysdeps/powerpc/powerpc64/fpu/s_round.S | 75 ++++++++++++++++++++++++++++++ sysdeps/powerpc/powerpc64/fpu/s_roundf.S | 71 ++++++++++++++++++++++++++++ sysdeps/powerpc/powerpc64/fpu/s_trunc.S | 67 ++++++++++++++++++++++++++ sysdeps/powerpc/powerpc64/fpu/s_truncf.S | 63 +++++++++++++++++++++++++ 18 files changed, 813 insertions(+), 82 deletions(-) create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_ceil.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_ceilf.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_floor.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_floorf.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llrint.S delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llrint.c create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llrintf.S delete mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llrintf.c create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llround.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llroundf.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lround.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lroundf.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_rint.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_rintf.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_round.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_roundf.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_trunc.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_truncf.S (limited to 'sysdeps/powerpc/powerpc64') diff --git a/sysdeps/powerpc/powerpc64/fpu/s_ceil.S b/sysdeps/powerpc/powerpc64/fpu/s_ceil.S new file mode 100644 index 0000000000..127f302666 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_ceil.S @@ -0,0 +1,60 @@ +/* ceil function. PowerPC64 version. + Copyright (C) 2004 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 + + .section ".toc","aw" +.LC0: /* 2**52 */ + .tc FD_43300000_0[TC],0x4330000000000000 +.LC1: /* -0.0 */ + .tc FD_80000000_0[TC],0x8000000000000000 + .section ".text" + +ENTRY (__ceil) + mffs fp11 /* Save current FPU rounding mode. */ + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + fsub fp12,fp13,fp13 /* generate 0.0 */ + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + bnllr- cr7 + mtfsfi 7,2 /* Set rounding mode toward +inf. */ + ble- cr6,.L4 + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ +.L9: + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + blr +.L4: + bge- cr6,.L9 /* if (x < 0.0) */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fcmpu cr5,fp1,fp12 /* if (x > 0.0) */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + bnelr+ cr5 + lfd fp1,.LC1@toc(2) /* x must be -0.0 for the 0.0 case. */ + blr + END (__ceil) + +weak_alias (__ceil, ceil) + +#ifdef NO_LONG_DOUBLE +weak_alias (__ceil, ceill) +strong_alias (__ceil, __ceill) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_ceilf.S b/sysdeps/powerpc/powerpc64/fpu/s_ceilf.S new file mode 100644 index 0000000000..34f61423cc --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_ceilf.S @@ -0,0 +1,56 @@ +/* float ceil function. PowerPC64 version. + Copyright (C) 2004 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 + + .section ".toc","aw" +.LC0: /* 2**23 */ + .tc FD_41600000_0[TC],0x4160000000000000 +.LC1: /* -0.0 */ + .tc FD_80000000_0[TC],0x8000000000000000 + .section ".text" + +ENTRY (__ceilf) + mffs fp11 /* Save current FPU rounding mode. */ + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + fsubs fp12,fp13,fp13 /* generate 0.0 */ + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO23) */ + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + bnllr- cr7 + mtfsfi 7,2 /* Set rounding mode toward +inf. */ + ble- cr6,.L4 + fadds fp1,fp1,fp13 /* x+= TWO23; */ + fsubs fp1,fp1,fp13 /* x-= TWO23; */ +.L9: + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + blr +.L4: + bge- cr6,.L9 /* if (x < 0.0) */ + fsubs fp1,fp1,fp13 /* x-= TWO23; */ + fadds fp1,fp1,fp13 /* x+= TWO23; */ + fcmpu cr5,fp1,fp12 /* if (x > 0.0) */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + bnelr+ cr5 + lfd fp1,.LC1@toc(2) /* x must be -0.0 for the 0.0 case. */ + blr + END (__ceilf) + +weak_alias (__ceilf, ceilf) + diff --git a/sysdeps/powerpc/powerpc64/fpu/s_floor.S b/sysdeps/powerpc/powerpc64/fpu/s_floor.S new file mode 100644 index 0000000000..57fd63cd66 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_floor.S @@ -0,0 +1,58 @@ +/* Floor function. PowerPC64 version. + Copyright (C) 2004 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 + + .section ".toc","aw" +.LC0: /* 2**52 */ + .tc FD_43300000_0[TC],0x4330000000000000 + .section ".text" + +ENTRY (__floor) + mffs fp11 /* Save current FPU rounding mode. */ + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + fsub fp12,fp13,fp13 /* generate 0.0 */ + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + bnllr- cr7 + mtfsfi 7,3 /* Set rounding mode toward -inf. */ + ble- cr6,.L4 + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ + fcmpu cr5,fp1,fp12 /* if (x > 0.0) */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + bnelr+ cr5 + fmr fp1,fp12 /* x must be +0.0 for the 0.0 case. */ + blr +.L4: + bge- cr6,.L9 /* if (x < 0.0) */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ + fadd fp1,fp1,fp13 /* x+= TWO52; */ +.L9: + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + blr + END (__floor) + +weak_alias (__floor, floor) + +#ifdef NO_LONG_DOUBLE +weak_alias (__floor, floorl) +strong_alias (__floor, __floorl) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_floorf.S b/sysdeps/powerpc/powerpc64/fpu/s_floorf.S new file mode 100644 index 0000000000..cde92b9174 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_floorf.S @@ -0,0 +1,54 @@ +/* float Floor function. PowerPC64 version. + Copyright (C) 2004 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 + + .section ".toc","aw" +.LC0: /* 2**23 */ + .tc FD_41600000_0[TC],0x4160000000000000 + .section ".text" + +ENTRY (__floorf) + mffs fp11 /* Save current FPU rounding mode. */ + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + fsubs fp12,fp13,fp13 /* generate 0.0 */ + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO23) */ + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + bnllr- cr7 + mtfsfi 7,3 /* Set rounding mode toward -inf. */ + ble- cr6,.L4 + fadds fp1,fp1,fp13 /* x+= TWO23; */ + fsubs fp1,fp1,fp13 /* x-= TWO23; */ + fcmpu cr5,fp1,fp12 /* if (x > 0.0) */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + bnelr+ cr5 + fmr fp1,fp12 /* x must be +0.0 for the 0.0 case. */ + blr +.L4: + bge- cr6,.L9 /* if (x < 0.0) */ + fsubs fp1,fp1,fp13 /* x-= TWO23; */ + fadds fp1,fp1,fp13 /* x+= TWO23; */ +.L9: + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + blr + END (__floorf) + +weak_alias (__floorf, floorf) + diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llrint.S b/sysdeps/powerpc/powerpc64/fpu/s_llrint.S new file mode 100644 index 0000000000..bc976a7edb --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_llrint.S @@ -0,0 +1,42 @@ +/* Round double to long int. PowerPC64 version. + Copyright (C) 2004 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 + +/* long long int[r3] __llrint (double x[fp1]) */ +ENTRY (__llrint) + fctid fp13,fp1 + stfd fp13,-16(r1) + nop /* Insure the following load is in a different dispatch group */ + nop /* to avoid pipe stall on POWER4&5. */ + nop + ld r3,-16(r1) + blr + END (__llrint) + +strong_alias (__llrint, __lrint) +weak_alias (__llrint, llrint) +weak_alias (__lrint, lrint) + +#ifdef NO_LONG_DOUBLE +strong_alias (__llrint, __llrintl) +weak_alias (__llrint, llrintl) +strong_alias (__lrint, __lrintl) +weak_alias (__lrint, lrintl) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llrint.c b/sysdeps/powerpc/powerpc64/fpu/s_llrint.c deleted file mode 100644 index f6ea3f4e0f..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/s_llrint.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Round a double value to a long long in the current rounding mode. - Copyright (C) 1997, 2004 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. */ - -/* Kludge to avoid decls that will confuse strong_alias below. */ -#define __lrint XXX__lrint -#define __lrintl XXX__lrintl -#define lrint XXXlrint -#define lrintl XXXlrintl - -#include "math.h" - -#undef __lrint -#undef __lrintl -#undef lrint -#undef lrintl - -long long int -__llrint (double x) -{ - return (long long int) __rint (x); -} -strong_alias (__llrint, __lrint) -weak_alias (__llrint, llrint) -weak_alias (__lrint, lrint) -#ifdef NO_LONG_DOUBLE -strong_alias (__llrint, __llrintl) -weak_alias (__llrint, llrintl) -strong_alias (__lrint, __lrintl) -weak_alias (__lrint, lrintl) -#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llrintf.S b/sysdeps/powerpc/powerpc64/fpu/s_llrintf.S new file mode 100644 index 0000000000..aef84de831 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_llrintf.S @@ -0,0 +1,36 @@ +/* Round double to long int. PowerPC64 version. + Copyright (C) 2004 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 + +/* long long int[r3] __llrintf (float x[fp1]) */ +ENTRY (__llrintf) + fctid fp13,fp1 + stfd fp13,-16(r1) + nop /* Insure the following load is in a different dispatch group */ + nop /* to avoid pipe stall on POWER4&5. */ + nop + ld r3,-16(r1) + blr + END (__llrintf) + +strong_alias (__llrintf, __lrintf) +weak_alias (__llrintf, llrintf) +weak_alias (__lrintf, lrintf) + diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llrintf.c b/sysdeps/powerpc/powerpc64/fpu/s_llrintf.c deleted file mode 100644 index 7d8e22a700..0000000000 --- a/sysdeps/powerpc/powerpc64/fpu/s_llrintf.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Round a float value to a long long in the current rounding mode. - Copyright (C) 1997, 2004 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. */ - -/* Kludge to avoid decls that will confuse strong_alias below. */ -#define __lrintf XXX__lrintf -#define lrintf XXXlrintf - -#include "math.h" - -#undef __lrintf -#undef lrintf - -long long int -__llrintf (float x) -{ - return (long long int) __rintf (x); -} -strong_alias (__llrintf, __lrintf) -weak_alias (__llrintf, llrintf) -weak_alias (__lrintf, lrintf) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llround.S b/sysdeps/powerpc/powerpc64/fpu/s_llround.S new file mode 100644 index 0000000000..320ef0f6d8 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_llround.S @@ -0,0 +1,67 @@ +/* llround function. PowerPC64 version. + Copyright (C) 2004 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 + + .section ".toc","aw" +.LC0: /* -0.0 */ + .tc FD_00000000_0[TC],0x0000000000000000 +.LC1: /* 0.5 */ + .tc FD_3fe00000_0[TC],0x3fe0000000000000 + .section ".text" + +/* long long [r3] llround (float 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. */ + +ENTRY (__llround) + lfd fp12,.LC0@toc(2) + lfd fp10,.LC1@toc(2) + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + ble- cr6,.L4 + fadd fp1,fp1,fp10 /* x+= 0.5; */ +.L9: + fctidz fp2,fp1 /* Convert To Integer DW llround toward 0. */ + stfd fp2,-16(r1) + nop /* Insure the following load is in a different dispatch group */ + nop /* to avoid pipe stall on POWER4&5. */ + nop + ld r3,-16(r1) + blr +.L4: + fsub fp1,fp1,fp10 /* x-= 0.5; */ + b .L9 + 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 diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S b/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S new file mode 100644 index 0000000000..ff923056b1 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S @@ -0,0 +1,59 @@ +/* llroundf function. PowerPC64 version. + Copyright (C) 2004 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 + + .section ".toc","aw" +.LC0: /* -0.0 */ + .tc FD_00000000_0[TC],0x0000000000000000 +.LC1: /* 0.5 */ + .tc FD_3fe00000_0[TC],0x3fe0000000000000 + .section ".text" + +/* long long [r3] llroundf (float x [fp1]) + IEEE 1003.1 llroundf function. IEEE specifies "roundf to the nearest + integer value, roundfing halfway cases away from zero, regardless of + the current roundfing mode." However PowerPC Architecture defines + "roundf 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. */ + +ENTRY (__llroundf) + lfd fp12,.LC0@toc(2) + lfd fp10,.LC1@toc(2) + fcmpu cr6,fp1,fp12 /* if (x < 0.0) */ + fsubs fp3,fp1,fp10 /* x-= 0.5; */ + ble- cr6,.L9 + fadds fp3,fp1,fp10 /* x+= 0.5; */ +.L9: + fctidz fp2,fp3 /* Convert To Integer DW round toward 0. */ + stfd fp2,-16(r1) + nop /* Insure the following load is in a different dispatch group */ + nop /* to avoid pipe stall on POWER4&5. */ + nop + ld r3,-16(r1) + blr + END (__llroundf) + +strong_alias (__llroundf, __lroundf) +weak_alias (__llroundf, llroundf) +weak_alias (__lroundf, lroundf) + diff --git a/sysdeps/powerpc/powerpc64/fpu/s_lround.S b/sysdeps/powerpc/powerpc64/fpu/s_lround.S new file mode 100644 index 0000000000..883bba1c5d --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_lround.S @@ -0,0 +1,2 @@ +/* __lround is in s_llround.S */ +/* __lround is in s_llround.S */ diff --git a/sysdeps/powerpc/powerpc64/fpu/s_lroundf.S b/sysdeps/powerpc/powerpc64/fpu/s_lroundf.S new file mode 100644 index 0000000000..15506f6801 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_lroundf.S @@ -0,0 +1,2 @@ +/* __lroundf is in s_llroundf.S */ +/* __lroundf is in s_llroundf.S */ diff --git a/sysdeps/powerpc/powerpc64/fpu/s_rint.S b/sysdeps/powerpc/powerpc64/fpu/s_rint.S new file mode 100644 index 0000000000..f7db7ff80a --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_rint.S @@ -0,0 +1,54 @@ +/* Round to int floating-point values. PowerPC64 version. + Copyright (C) 2004 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. */ + +/* This has been coded in assembler because GCC makes such a mess of it + when it's coded in C. */ + +#include + + .section ".toc","aw" +.LC0: /* 2**52 */ + .tc FD_43300000_0[TC],0x4330000000000000 + .section ".text" + +ENTRY (__rint) + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + fsub fp12,fp13,fp13 /* generate 0.0 */ + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + bnllr- cr7 + bng- cr6,.L4 + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ + blr +.L4: + bnllr- cr6 /* if (x < 0.0) */ + fsub fp1,fp13,fp1 /* x = TWO52 - x; */ + fsub fp0,fp1,fp13 /* x = - (x - TWO52); */ + fneg fp1,fp0 + blr + END (__rint) + +weak_alias (__rint, rint) + +#ifdef NO_LONG_DOUBLE +weak_alias (__rint, rintl) +strong_alias (__rint, __rintl) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_rintf.S b/sysdeps/powerpc/powerpc64/fpu/s_rintf.S new file mode 100644 index 0000000000..de6d654796 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_rintf.S @@ -0,0 +1,47 @@ +/* Round float to int floating-point values. PowerPC64 version. + Copyright (C) 2004 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 + + .section ".toc","aw" +.LC0: /* 2**23 */ + .tc FD_41600000_0[TC],0x4160000000000000 + .section ".text" + +ENTRY (__rintf) + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + fsubs fp12,fp13,fp13 /* generate 0.0 */ + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO23) */ + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + bnllr- cr7 + bng- cr6,.L4 + fadds fp1,fp1,fp13 /* x+= TWO23; */ + fsubs fp1,fp1,fp13 /* x-= TWO23; */ + blr +.L4: + bnllr- cr6 /* if (x < 0.0) */ + fsubs fp1,fp13,fp1 /* x = TWO23 - x; */ + fsubs fp0,fp1,fp13 /* x = - (x - TWO23); */ + fneg fp1,fp0 + blr + END (__rintf) + +weak_alias (__rintf, rintf) + diff --git a/sysdeps/powerpc/powerpc64/fpu/s_round.S b/sysdeps/powerpc/powerpc64/fpu/s_round.S new file mode 100644 index 0000000000..1c2e5299e5 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_round.S @@ -0,0 +1,75 @@ +/* round function. PowerPC64 version. + Copyright (C) 2004 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 + + .section ".toc","aw" +.LC0: /* 2**52 */ + .tc FD_43300000_0[TC],0x4330000000000000 +.LC1: /* 0.5 */ + .tc FD_3fe00000_0[TC],0x3fe0000000000000 +.LC2: /* -0.0 */ + .tc FD_80000000_0[TC],0x8000000000000000 + .section ".text" + +/* double [fp1] round (double x [fp1]) + IEEE 1003.1 round 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. */ + +ENTRY (__round) + mffs fp11 /* Save current FPU rounding mode. */ + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + fsub fp12,fp13,fp13 /* generate 0.0 */ + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + bnllr- cr7 + mtfsfi 7,1 /* Set rounding mode toward 0. */ + lfd fp10,.LC1@toc(2) + ble- cr6,.L4 + fadd fp1,fp1,fp10 /* x+= 0.5; */ + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ +.L9: + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + blr +.L4: + fsub fp9,fp1,fp10 /* x+= 0.5; */ + bge- cr6,.L9 /* if (x < 0.0) */ + fsub fp1,fp9,fp13 /* x-= TWO52; */ + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fcmpu cr5,fp1,fp12 /* if (x > 0.0) */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + bnelr+ cr5 + lfd fp1,.LC2@toc(2) /* x must be -0.0 for the 0.0 case. */ + blr + END (__round) + +weak_alias (__round, round) + +#ifdef NO_LONG_DOUBLE +weak_alias (__round, roundl) +strong_alias (__round, __roundl) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_roundf.S b/sysdeps/powerpc/powerpc64/fpu/s_roundf.S new file mode 100644 index 0000000000..fd8eb0aea3 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_roundf.S @@ -0,0 +1,71 @@ +/* roundf function. PowerPC64 version. + Copyright (C) 2004 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 + + .section ".toc","aw" +.LC0: /* 2**23 */ + .tc FD_41600000_0[TC],0x4160000000000000 +.LC1: /* 0.5 */ + .tc FD_3fe00000_0[TC],0x3fe0000000000000 +.LC2: /* -0.0 */ + .tc FD_80000000_0[TC],0x8000000000000000 + .section ".text" + +/* float [fp1] roundf (float x [fp1]) + IEEE 1003.1 round 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. */ + +ENTRY (__roundf ) + mffs fp11 /* Save current FPU rounding mode. */ + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + fsubs fp12,fp13,fp13 /* generate 0.0 */ + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO23) */ + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + bnllr- cr7 + mtfsfi 7,1 /* Set rounding mode toward 0. */ + lfd fp10,.LC1@toc(2) + ble- cr6,.L4 + fadds fp1,fp1,fp10 /* x+= 0.5; */ + fadds fp1,fp1,fp13 /* x+= TWO23; */ + fsubs fp1,fp1,fp13 /* x-= TWO23; */ +.L9: + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + blr +.L4: + fsubs fp9,fp1,fp10 /* x+= 0.5; */ + bge- cr6,.L9 /* if (x < 0.0) */ + fsubs fp1,fp9,fp13 /* x-= TWO23; */ + fadds fp1,fp1,fp13 /* x+= TWO23; */ + fcmpu cr5,fp1,fp12 /* if (x > 0.0) */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + bnelr+ cr5 + lfd fp1,.LC2@toc(2) /* x must be -0.0 for the 0.0 case. */ + blr + END (__roundf) + +weak_alias (__roundf, roundf) + diff --git a/sysdeps/powerpc/powerpc64/fpu/s_trunc.S b/sysdeps/powerpc/powerpc64/fpu/s_trunc.S new file mode 100644 index 0000000000..dc345ab424 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_trunc.S @@ -0,0 +1,67 @@ +/* trunc function. PowerPC64 version. + Copyright (C) 2004 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 + + .section ".toc","aw" +.LC0: /* 2**52 */ + .tc FD_43300000_0[TC],0x4330000000000000 +.LC2: /* -0.0 */ + .tc FD_80000000_0[TC],0x8000000000000000 + .section ".text" + +/* double [fp1] trunc (double x [fp1]) + IEEE 1003.1 trunc function. IEEE specifies "trunc to the integer + value, in floating format, nearest to but no larger in magnitude + then the argument." + We set "round toward Zero" mode and trunc by adding +-2**52 then + subtracting +-2**52. */ + +ENTRY (__trunc) + mffs fp11 /* Save current FPU rounding mode. */ + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + fsub fp12,fp13,fp13 /* generate 0.0 */ + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + bnllr- cr7 + mtfsfi 7,1 /* Set rounding toward 0 mode. */ + ble- cr6,.L4 + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ +.L9: + mtfsf 0x01,fp11 /* restore previous truncing mode. */ + blr +.L4: + bge- cr6,.L9 /* if (x < 0.0) */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fcmpu cr5,fp1,fp12 /* if (x > 0.0) */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + bnelr+ cr5 + lfd fp1,.LC2@toc(2) /* x must be -0.0 for the 0.0 case. */ + blr + END (__trunc) + +weak_alias (__trunc, trunc) + +#ifdef NO_LONG_DOUBLE +weak_alias (__trunc, truncl) +strong_alias (__trunc, __truncl) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_truncf.S b/sysdeps/powerpc/powerpc64/fpu/s_truncf.S new file mode 100644 index 0000000000..727647f6de --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_truncf.S @@ -0,0 +1,63 @@ +/* truncf function. PowerPC64 version. + Copyright (C) 2004 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 + + .section ".toc","aw" +.LC0: /* 2**23 */ + .tc FD_41600000_0[TC],0x4160000000000000 +.LC2: /* -0.0 */ + .tc FD_80000000_0[TC],0x8000000000000000 + .section ".text" + +/* float [fp1] truncf (float x [fp1]) + IEEE 1003.1 trunc function. IEEE specifies "trunc to the integer + value, in floating format, nearest to but no larger in magnitude + then the argument." + We set "round toward Zero" mode and trunc by adding +-2**23 then + subtracting +-2**23. */ + +ENTRY (__truncf) + mffs fp11 /* Save current FPU rounding mode. */ + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + fsubs fp12,fp13,fp13 /* generate 0.0 */ + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO23) */ + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + bnllr- cr7 + mtfsfi 7,1 /* Set rounding toward 0 mode. */ + ble- cr6,.L4 + fadds fp1,fp1,fp13 /* x+= TWO23; */ + fsubs fp1,fp1,fp13 /* x-= TWO23; */ +.L9: + mtfsf 0x01,fp11 /* restore previous truncing mode. */ + blr +.L4: + bge- cr6,.L9 /* if (x < 0.0) */ + fsubs fp1,fp1,fp13 /* x-= TWO23; */ + fadds fp1,fp1,fp13 /* x+= TWO23; */ + fcmpu cr5,fp1,fp12 /* if (x > 0.0) */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + bnelr+ cr5 + lfd fp1,.LC2@toc(2) /* x must be -0.0 for the 0.0 case. */ + blr + END (__truncf) + +weak_alias (__truncf, truncf) + -- cgit v1.2.3