diff options
author | Geoff Keating <geoffk@cygnus.com> | 2000-03-04 03:36:14 +0000 |
---|---|---|
committer | Geoff Keating <geoffk@cygnus.com> | 2000-03-04 03:36:14 +0000 |
commit | 8ed1e7d5894000c155acbd06ffd2ba07ea9f718b (patch) | |
tree | b9555e693953f12cd6a0a4f533922db17513d8b0 /soft-fp | |
parent | 706546ff10e0979cf49d002c03334810663b655f (diff) | |
download | glibc-8ed1e7d5894000c155acbd06ffd2ba07ea9f718b.tar.gz |
In libc/:
* configure.in: Compute sizeof-long-double.
* configure: Regenerated.
* config.make.in: Make sizeof-long-double available to sub-makes.
In libc/soft-fp/:
* soft-fp.h (_FP_ROUND_ZERO): Cast 0 to void before using it
as a statement.
* sysdeps/powerpc/Makefile (routines): New file.
* sysdeps/powerpc/q_*: New files.
2000-03-03 Geoff Keating <geoffk@cygnus.com>
* configure.in: Compute sizeof-long-double.
* configure: Regenerated.
* config.make.in: Make sizeof-long-double available to sub-makes.
Diffstat (limited to 'soft-fp')
31 files changed, 1155 insertions, 2 deletions
diff --git a/soft-fp/ChangeLog b/soft-fp/ChangeLog index f4e8bea5ee..737d5070ec 100644 --- a/soft-fp/ChangeLog +++ b/soft-fp/ChangeLog @@ -1,3 +1,11 @@ +2000-03-03 Geoff Keating <geoffk@cygnus.com> + + * soft-fp.h (_FP_ROUND_ZERO): Cast 0 to void before using it + as a statement. + + * sysdeps/powerpc/Makefile (routines): New file. + * sysdeps/powerpc/q_*: New files. + 1999-10-29 Jakub Jelinek <jakub@redhat.com> * Makefile: New file. diff --git a/soft-fp/soft-fp.h b/soft-fp/soft-fp.h index 26798ecf25..6af8eaaf19 100644 --- a/soft-fp/soft-fp.h +++ b/soft-fp/soft-fp.h @@ -1,5 +1,5 @@ /* Software floating-point emulation. - Copyright (C) 1997,1998,1999 Free Software Foundation, Inc. + Copyright (C) 1997,1998,1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Richard Henderson (rth@cygnus.com), Jakub Jelinek (jj@ultra.linux.cz), @@ -107,7 +107,7 @@ do { \ _FP_FRAC_ADDI_##wc(X, _FP_WORK_ROUND); \ } while (0) -#define _FP_ROUND_ZERO(wc, X) 0 +#define _FP_ROUND_ZERO(wc, X) (void)0 #define _FP_ROUND_PINF(wc, X) \ do { \ diff --git a/soft-fp/sysdeps/powerpc/Makefile b/soft-fp/sysdeps/powerpc/Makefile new file mode 100644 index 0000000000..bc9e6ff61a --- /dev/null +++ b/soft-fp/sysdeps/powerpc/Makefile @@ -0,0 +1,35 @@ +# Software floating-point emulation. +# Makefile for PowerPC SVR4 ABI mandated long double utility +# functions (_q_*). +# Copyright (C) 1999, 2000 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# Contributed by Jakub Jelinek (jj@ultra.linux.cz). +# +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public License as +# published by the Free Software Foundation; either version 2 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 +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with the GNU C Library; see the file COPYING.LIB. If +# not, write to the Free Software Foundation, Inc., +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +ifeq ($(subdir),soft-fp) +ifeq ($(sizeof-long-double),16) +powerpc-quad-routines := q_add q_cmp q_cmpe q_div q_dtoq q_feq q_fge \ + q_fgt q_fle q_flt q_fne q_itoq q_mul q_neg q_qtod q_qtoi \ + q_qtos q_qtou q_qtoull q_qtoll q_sqrt q_stoq q_sub q_utoq \ + q_ulltoq q_lltoq q_util +routines += $(powerpc-quad-routines) +endif +endif + +ifeq ($(subdir),math) +CPPFLAGS += -I../soft-fp/ +endif diff --git a/soft-fp/sysdeps/powerpc/Versions b/soft-fp/sysdeps/powerpc/Versions new file mode 100644 index 0000000000..242aaf99cd --- /dev/null +++ b/soft-fp/sysdeps/powerpc/Versions @@ -0,0 +1,8 @@ +libc { + GLIBC_2.2 { + _q_add; _q_cmp; _q_cmpe; _q_div; _q_dtoq; _q_feq; _q_fge; _q_fgt; + _q_fle; _q_flt; _q_fne; _q_itoq; _q_mul; _q_neg; _q_qtod; _q_qtoi; + _q_qtos; _q_qtou; _q_sqrt; _q_stoq; _q_sub; + _q_utoq; + _q_lltoq; _q_qtoll; _q_qtoull; _q_ulltoq; +} diff --git a/soft-fp/sysdeps/powerpc/q_add.c b/soft-fp/sysdeps/powerpc/q_add.c new file mode 100644 index 0000000000..11779d5fbd --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_add.c @@ -0,0 +1,39 @@ +/* Software floating-point emulation. + Return a + b + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +long double _q_add(const long double a, const long double b) +{ + FP_DECL_EX; + FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C); + long double c; + + FP_INIT_ROUNDMODE; + FP_UNPACK_Q(A, a); + FP_UNPACK_Q(B, b); + FP_ADD_Q(C, A, B); + FP_PACK_Q(c, C); + FP_HANDLE_EXCEPTIONS; + return c; +} diff --git a/soft-fp/sysdeps/powerpc/q_cmp.c b/soft-fp/sysdeps/powerpc/q_cmp.c new file mode 100644 index 0000000000..d68b9cbaf0 --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_cmp.c @@ -0,0 +1,41 @@ +/* Software floating-point emulation. + Compare a and b, return float condition code. + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +int _q_cmp(const long double a, const long double b) +{ + FP_DECL_EX; + FP_DECL_Q(A); FP_DECL_Q(B); + int r; + + FP_UNPACK_RAW_Q(A, a); + FP_UNPACK_RAW_Q(B, b); + FP_CMP_Q(r, B, A, 3); + if (r == -1) r = 2; + if (r == 3 && (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B))) + FP_SET_EXCEPTION(FP_EX_INVALID); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/soft-fp/sysdeps/powerpc/q_cmpe.c b/soft-fp/sysdeps/powerpc/q_cmpe.c new file mode 100644 index 0000000000..9894eff4d4 --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_cmpe.c @@ -0,0 +1,42 @@ +/* Software floating-point emulation. + Compare a and b, return float condition code. + Signal exception (unless masked) if unordered. + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +int _q_cmpe(const long double a, const long double b) +{ + FP_DECL_EX; + FP_DECL_Q(A); FP_DECL_Q(B); + int r; + + FP_UNPACK_RAW_Q(A, a); + FP_UNPACK_RAW_Q(B, b); + FP_CMP_Q(r, B, A, 3); + if (r == -1) r = 2; + if (r == 3) + FP_SET_EXCEPTION(FP_EX_INVALID); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/soft-fp/sysdeps/powerpc/q_div.c b/soft-fp/sysdeps/powerpc/q_div.c new file mode 100644 index 0000000000..9904fbc22d --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_div.c @@ -0,0 +1,39 @@ +/* Software floating-point emulation. + Return a / b + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +long double _q_div(const long double a, const long double b) +{ + FP_DECL_EX; + FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C); + long double c; + + FP_INIT_ROUNDMODE; + FP_UNPACK_Q(A, a); + FP_UNPACK_Q(B, b); + FP_DIV_Q(C, A, B); + FP_PACK_Q(c, C); + FP_HANDLE_EXCEPTIONS; + return c; +} diff --git a/soft-fp/sysdeps/powerpc/q_dtoq.c b/soft-fp/sysdeps/powerpc/q_dtoq.c new file mode 100644 index 0000000000..bc588ad634 --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_dtoq.c @@ -0,0 +1,44 @@ +/* Software floating-point emulation. + Return (long double)(a) + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "double.h" +#include "quad.h" + +long double _q_dtoq(const double a) +{ + FP_DECL_EX; + FP_DECL_D(A); + FP_DECL_Q(C); + long double c; + + FP_INIT_ROUNDMODE; + FP_UNPACK_D(A, a); +#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q + FP_CONV(Q,D,4,2,C,A); +#else + FP_CONV(Q,D,2,1,C,A); +#endif + FP_PACK_Q(c, C); + FP_HANDLE_EXCEPTIONS; + return c; +} diff --git a/soft-fp/sysdeps/powerpc/q_feq.c b/soft-fp/sysdeps/powerpc/q_feq.c new file mode 100644 index 0000000000..4611c82d20 --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_feq.c @@ -0,0 +1,40 @@ +/* Software floating-point emulation. + Return 1 if a == b + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +int _q_feq(const long double a, const long double b) +{ + FP_DECL_EX; + FP_DECL_Q(A); FP_DECL_Q(B); + int r; + + FP_UNPACK_RAW_Q(A, a); + FP_UNPACK_RAW_Q(B, b); + FP_CMP_EQ_Q(r, A, B); + if (r && (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B))) + FP_SET_EXCEPTION(FP_EX_INVALID); + FP_HANDLE_EXCEPTIONS; + + return !r; +} diff --git a/soft-fp/sysdeps/powerpc/q_fge.c b/soft-fp/sysdeps/powerpc/q_fge.c new file mode 100644 index 0000000000..d7230a3b3c --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_fge.c @@ -0,0 +1,40 @@ +/* Software floating-point emulation. + Return 1 if a >= b + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +int _q_fge(const long double a, const long double b) +{ + FP_DECL_EX; + FP_DECL_Q(A); FP_DECL_Q(B); + int r; + + FP_UNPACK_RAW_Q(A, a); + FP_UNPACK_RAW_Q(B, b); + FP_CMP_Q(r, B, A, 3); + if (r == 3) + FP_SET_EXCEPTION(FP_EX_INVALID); + FP_HANDLE_EXCEPTIONS; + + return (r <= 0); +} diff --git a/soft-fp/sysdeps/powerpc/q_fgt.c b/soft-fp/sysdeps/powerpc/q_fgt.c new file mode 100644 index 0000000000..ad1fe16c48 --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_fgt.c @@ -0,0 +1,40 @@ +/* Software floating-point emulation. + Return 1 if a > b + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +int _q_fgt(const long double a, const long double b) +{ + FP_DECL_EX; + FP_DECL_Q(A); FP_DECL_Q(B); + int r; + + FP_UNPACK_RAW_Q(A, a); + FP_UNPACK_RAW_Q(B, b); + FP_CMP_Q(r, B, A, 3); + if (r == 3) + FP_SET_EXCEPTION(FP_EX_INVALID); + FP_HANDLE_EXCEPTIONS; + + return (r == -1); +} diff --git a/soft-fp/sysdeps/powerpc/q_fle.c b/soft-fp/sysdeps/powerpc/q_fle.c new file mode 100644 index 0000000000..895394b26e --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_fle.c @@ -0,0 +1,40 @@ +/* Software floating-point emulation. + Return 1 if a <= b + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +int _q_fle(const long double a, const long double b) +{ + FP_DECL_EX; + FP_DECL_Q(A); FP_DECL_Q(B); + int r; + + FP_UNPACK_RAW_Q(A, a); + FP_UNPACK_RAW_Q(B, b); + FP_CMP_Q(r, B, A, -2); + if (r == -2) + FP_SET_EXCEPTION(FP_EX_INVALID); + FP_HANDLE_EXCEPTIONS; + + return (r >= 0); +} diff --git a/soft-fp/sysdeps/powerpc/q_flt.c b/soft-fp/sysdeps/powerpc/q_flt.c new file mode 100644 index 0000000000..547e0a082a --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_flt.c @@ -0,0 +1,40 @@ +/* Software floating-point emulation. + Return 1 if a < b + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +int _q_flt(const long double a, const long double b) +{ + FP_DECL_EX; + FP_DECL_Q(A); FP_DECL_Q(B); + int r; + + FP_UNPACK_RAW_Q(A, a); + FP_UNPACK_RAW_Q(B, b); + FP_CMP_Q(r, B, A, 3); + if (r == 3) + FP_SET_EXCEPTION(FP_EX_INVALID); + FP_HANDLE_EXCEPTIONS; + + return (r == 1); +} diff --git a/soft-fp/sysdeps/powerpc/q_fne.c b/soft-fp/sysdeps/powerpc/q_fne.c new file mode 100644 index 0000000000..e326531334 --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_fne.c @@ -0,0 +1,40 @@ +/* Software floating-point emulation. + Return 1 if a != b + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +int _q_fne(const long double a, const long double b) +{ + FP_DECL_EX; + FP_DECL_Q(A); FP_DECL_Q(B); + int r; + + FP_UNPACK_RAW_Q(A, a); + FP_UNPACK_RAW_Q(B, b); + FP_CMP_EQ_Q(r, A, B); + if (r && (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B))) + FP_SET_EXCEPTION(FP_EX_INVALID); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/soft-fp/sysdeps/powerpc/q_itoq.c b/soft-fp/sysdeps/powerpc/q_itoq.c new file mode 100644 index 0000000000..de74a946b7 --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_itoq.c @@ -0,0 +1,38 @@ +/* Software floating-point emulation. + Return (long double)(a) + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +long double _q_itoq(const int a) +{ + FP_DECL_EX; + FP_DECL_Q(C); + int b = a; + long double c; + + FP_FROM_INT_Q(C, b, 32, int); + FP_PACK_Q(c, C); + FP_CLEAR_EXCEPTIONS; + FP_HANDLE_EXCEPTIONS; + return c; +} diff --git a/soft-fp/sysdeps/powerpc/q_lltoq.c b/soft-fp/sysdeps/powerpc/q_lltoq.c new file mode 100644 index 0000000000..4ace66f53f --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_lltoq.c @@ -0,0 +1,38 @@ +/* Software floating-point emulation. + Return (long double)a + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +long double _q_lltoq(const long long a) +{ + FP_DECL_EX; + FP_DECL_Q(C); + long double c; + long long b = a; + + FP_FROM_INT_Q(C, b, 64, long long); + FP_PACK_Q(c, C); + FP_CLEAR_EXCEPTIONS; + FP_HANDLE_EXCEPTIONS; + return c; +} diff --git a/soft-fp/sysdeps/powerpc/q_mul.c b/soft-fp/sysdeps/powerpc/q_mul.c new file mode 100644 index 0000000000..4ab5626bce --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_mul.c @@ -0,0 +1,39 @@ +/* Software floating-point emulation. + Return a * b + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +long double _q_mul(const long double a, const long double b) +{ + FP_DECL_EX; + FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C); + long double c; + + FP_INIT_ROUNDMODE; + FP_UNPACK_Q(A, a); + FP_UNPACK_Q(B, b); + FP_MUL_Q(C, A, B); + FP_PACK_Q(c, C); + FP_HANDLE_EXCEPTIONS; + return c; +} diff --git a/soft-fp/sysdeps/powerpc/q_neg.c b/soft-fp/sysdeps/powerpc/q_neg.c new file mode 100644 index 0000000000..67b86552d3 --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_neg.c @@ -0,0 +1,47 @@ +/* Software floating-point emulation. + Return !a + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +long double _q_neg(const long double a) +{ + FP_DECL_EX; + long double c = a; + +#if (__BYTE_ORDER == __BIG_ENDIAN) + ((UWtype *)&c)[0] ^= (((UWtype)1) << (W_TYPE_SIZE - 1)); +#elif (__BYTE_ORDER == __LITTLE_ENDIAN) && (W_TYPE_SIZE == 64) + ((UWtype *)&c)[1] ^= (((UWtype)1) << (W_TYPE_SIZE - 1)); +#elif (__BYTE_ORDER == __LITTLE_ENDIAN) && (W_TYPE_SIZE == 32) + ((UWtype *)&c)[3] ^= (((UWtype)1) << (W_TYPE_SIZE - 1)); +#else + FP_DECL_Q(A); FP_DECL_Q(C); + + FP_UNPACK_Q(A, a); + FP_NEG_Q(C, A); + FP_PACK_Q(c, C); +#endif + FP_CLEAR_EXCEPTIONS; + FP_HANDLE_EXCEPTIONS; + return c; +} diff --git a/soft-fp/sysdeps/powerpc/q_qtod.c b/soft-fp/sysdeps/powerpc/q_qtod.c new file mode 100644 index 0000000000..9375f8a8bc --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_qtod.c @@ -0,0 +1,45 @@ +/* Software floating-point emulation. + Return (double)a + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "double.h" +#include "quad.h" + +double _q_qtod(const long double a) +{ + FP_DECL_EX; + FP_DECL_Q(A); + FP_DECL_D(R); + double r; + + FP_INIT_ROUNDMODE; + FP_UNPACK_Q(A, a); +#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q + FP_CONV(D,Q,2,4,R,A); +#else + FP_CONV(D,Q,1,2,R,A); +#endif + FP_PACK_D(r, R); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/soft-fp/sysdeps/powerpc/q_qtoi.c b/soft-fp/sysdeps/powerpc/q_qtoi.c new file mode 100644 index 0000000000..0f23289b25 --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_qtoi.c @@ -0,0 +1,38 @@ +/* Software floating-point emulation. + Return (int)a + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define FP_ROUNDMODE FP_RND_ZERO +#include "soft-fp.h" +#include "quad.h" + +int _q_qtoi(const long double a) +{ + FP_DECL_EX; + FP_DECL_Q(A); + int r; + + FP_UNPACK_Q(A, a); + FP_TO_INT_Q(r, A, 32, 1); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/soft-fp/sysdeps/powerpc/q_qtoll.c b/soft-fp/sysdeps/powerpc/q_qtoll.c new file mode 100644 index 0000000000..f588506c1c --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_qtoll.c @@ -0,0 +1,38 @@ +/* Software floating-point emulation. + Return (long)a + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define FP_ROUNDMODE FP_RND_ZERO +#include "soft-fp.h" +#include "quad.h" + +long long _q_qtoll(const long double a) +{ + FP_DECL_EX; + FP_DECL_Q(A); + long long r; + + FP_UNPACK_Q(A, a); + FP_TO_INT_Q(r, A, 64, 1); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/soft-fp/sysdeps/powerpc/q_qtos.c b/soft-fp/sysdeps/powerpc/q_qtos.c new file mode 100644 index 0000000000..64e7cba0cf --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_qtos.c @@ -0,0 +1,45 @@ +/* Software floating-point emulation. + Return (float)a + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "single.h" +#include "quad.h" + +float _q_qtos(const long double a) +{ + FP_DECL_EX; + FP_DECL_Q(A); + FP_DECL_S(R); + float r; + + FP_INIT_ROUNDMODE; + FP_UNPACK_Q(A, a); +#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q + FP_CONV(S,Q,1,4,R,A); +#else + FP_CONV(S,Q,1,2,R,A); +#endif + FP_PACK_S(r, R); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/soft-fp/sysdeps/powerpc/q_qtou.c b/soft-fp/sysdeps/powerpc/q_qtou.c new file mode 100644 index 0000000000..27bf464ec1 --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_qtou.c @@ -0,0 +1,38 @@ +/* Software floating-point emulation. + Return (unsigned int)a + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define FP_ROUNDMODE FP_RND_ZERO +#include "soft-fp.h" +#include "quad.h" + +unsigned int _q_qtou(const long double a) +{ + FP_DECL_EX; + FP_DECL_Q(A); + unsigned int r; + + FP_UNPACK_Q(A, a); + FP_TO_INT_Q(r, A, 32, -1); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/soft-fp/sysdeps/powerpc/q_qtoull.c b/soft-fp/sysdeps/powerpc/q_qtoull.c new file mode 100644 index 0000000000..ef8757699e --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_qtoull.c @@ -0,0 +1,38 @@ +/* Software floating-point emulation. + Return (long)a + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define FP_ROUNDMODE FP_RND_ZERO +#include "soft-fp.h" +#include "quad.h" + +unsigned long long _q_qtoull(const long double a) +{ + FP_DECL_EX; + FP_DECL_Q(A); + unsigned long long r; + + FP_UNPACK_Q(A, a); + FP_TO_INT_Q(r, A, 64, -1); + FP_HANDLE_EXCEPTIONS; + + return r; +} diff --git a/soft-fp/sysdeps/powerpc/q_sqrt.c b/soft-fp/sysdeps/powerpc/q_sqrt.c new file mode 100644 index 0000000000..dd43eec6e1 --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_sqrt.c @@ -0,0 +1,38 @@ +/* Software floating-point emulation. + Return sqrtl(a) + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +long double _q_sqrt(const long double a) +{ + FP_DECL_EX; + FP_DECL_Q(A); FP_DECL_Q(C); + long double c; + + FP_INIT_ROUNDMODE; + FP_UNPACK_Q(A, a); + FP_SQRT_Q(C, A); + FP_PACK_Q(c, C); + FP_HANDLE_EXCEPTIONS; + return c; +} diff --git a/soft-fp/sysdeps/powerpc/q_stoq.c b/soft-fp/sysdeps/powerpc/q_stoq.c new file mode 100644 index 0000000000..09de4360e7 --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_stoq.c @@ -0,0 +1,43 @@ +/* Software floating-point emulation. + c = (long double)(a) + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "single.h" +#include "quad.h" + +long double _q_stoq(const float a) +{ + FP_DECL_EX; + FP_DECL_S(A); + FP_DECL_Q(C); + long double c; + + FP_UNPACK_S(A, a); +#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q + FP_CONV(Q,S,4,1,C,A); +#else + FP_CONV(Q,S,2,1,C,A); +#endif + FP_PACK_Q(c, C); + FP_HANDLE_EXCEPTIONS; + return c; +} diff --git a/soft-fp/sysdeps/powerpc/q_sub.c b/soft-fp/sysdeps/powerpc/q_sub.c new file mode 100644 index 0000000000..8e1522379f --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_sub.c @@ -0,0 +1,39 @@ +/* Software floating-point emulation. + c = a - b + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +long double _q_sub(const long double a, const long double b) +{ + FP_DECL_EX; + FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C); + long double c; + + FP_INIT_ROUNDMODE; + FP_UNPACK_Q(A, a); + FP_UNPACK_Q(B, b); + FP_SUB_Q(C, A, B); + FP_PACK_Q(c, C); + FP_HANDLE_EXCEPTIONS; + return c; +} diff --git a/soft-fp/sysdeps/powerpc/q_ulltoq.c b/soft-fp/sysdeps/powerpc/q_ulltoq.c new file mode 100644 index 0000000000..4cea438a2a --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_ulltoq.c @@ -0,0 +1,38 @@ +/* Software floating-point emulation. + Return (long double)a + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +long double _q_ulltoq(const unsigned long long a) +{ + FP_DECL_EX; + FP_DECL_Q(C); + long double c; + unsigned long long b = a; + + FP_FROM_INT_Q(C, b, 64, long long); + FP_PACK_Q(c, C); + FP_CLEAR_EXCEPTIONS; + FP_HANDLE_EXCEPTIONS; + return c; +} diff --git a/soft-fp/sysdeps/powerpc/q_util.c b/soft-fp/sysdeps/powerpc/q_util.c new file mode 100644 index 0000000000..d46cbd826a --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_util.c @@ -0,0 +1,57 @@ +/* Software floating-point emulation. + Helper routine for _q_* routines. + Simulate exceptions using double arithmetics. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" + +unsigned long long ___q_numbers [] = { +0x0000000000000000ULL, /* Zero */ +0x0010100000000000ULL, /* Very tiny number */ +0x0010000000000000ULL, /* Minimum normalized number */ +0x7fef000000000000ULL, /* A huge double number */ +}; + +double ___q_simulate_exceptions(int exceptions) +{ + double d, *p = (double *)___q_numbers; + if (exceptions & FP_EX_INVALID) + d = p[0]/p[0]; + if (exceptions & FP_EX_OVERFLOW) + { + d = p[3] + p[3]; + exceptions &= ~FP_EX_INEXACT; + } + if (exceptions & FP_EX_UNDERFLOW) + { + if (exceptions & FP_EX_INEXACT) + { + d = p[2] * p[2]; + exceptions &= ~FP_EX_INEXACT; + } + else + d = p[1] - p[2]; + } + if (exceptions & FP_EX_DIVZERO) + d = 1.0/p[0]; + if (exceptions & FP_EX_INEXACT) + d = p[3] - p[2]; + return d; +} diff --git a/soft-fp/sysdeps/powerpc/q_utoq.c b/soft-fp/sysdeps/powerpc/q_utoq.c new file mode 100644 index 0000000000..2f048aaa3f --- /dev/null +++ b/soft-fp/sysdeps/powerpc/q_utoq.c @@ -0,0 +1,38 @@ +/* Software floating-point emulation. + c = (long double)(a) + Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson (rth@cygnus.com) and + Jakub Jelinek (jj@ultra.linux.cz). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If + not, write to the Free Software Foundation, Inc., + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "soft-fp.h" +#include "quad.h" + +long double _q_uitoq(const unsigned int a) +{ + FP_DECL_EX; + FP_DECL_Q(C); + long double c; + unsigned int b = a; + + FP_FROM_INT_Q(C, b, 32, int); + FP_PACK_Q(c, C); + FP_CLEAR_EXCEPTIONS; + FP_HANDLE_EXCEPTIONS; + return c; +} |