aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/ieee754
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2018-05-17 00:40:52 +0000
committerJoseph Myers <joseph@codesourcery.com>2018-05-17 00:40:52 +0000
commit632a6cbe44cdd41dba7242887992cdca7b42922a (patch)
treefd89a5dcf705fa6efb1209edff22902e8ae12ff7 /sysdeps/ieee754
parent8c78faa9ef5c6cae455739f162e4b9d690e32eca (diff)
downloadglibc-632a6cbe44cdd41dba7242887992cdca7b42922a.tar
glibc-632a6cbe44cdd41dba7242887992cdca7b42922a.tar.gz
glibc-632a6cbe44cdd41dba7242887992cdca7b42922a.tar.bz2
glibc-632a6cbe44cdd41dba7242887992cdca7b42922a.zip
Add narrowing divide functions.
This patch adds the narrowing divide functions from TS 18661-1 to glibc's libm: fdiv, fdivl, ddivl, f32divf64, f32divf32x, f32xdivf64 for all configurations; f32divf64x, f32divf128, f64divf64x, f64divf128, f32xdivf64x, f32xdivf128, f64xdivf128 for configurations with _Float64x and _Float128; __nldbl_ddivl for ldbl-opt. The changes are mostly essentially the same as for the other narrowing functions, so the description of those generally applies to this patch as well. Tested for x86_64, x86, mips64 (all three ABIs, both hard and soft float) and powerpc, and with build-many-glibcs.py. * math/Makefile (libm-narrow-fns): Add div. (libm-test-funcs-narrow): Likewise. * math/Versions (GLIBC_2.28): Add narrowing divide functions. * math/bits/mathcalls-narrow.h (div): Use __MATHCALL_NARROW. * math/gen-auto-libm-tests.c (test_functions): Add div. * math/math-narrow.h (CHECK_NARROW_DIV): New macro. (NARROW_DIV_ROUND_TO_ODD): Likewise. (NARROW_DIV_TRIVIAL): Likewise. * sysdeps/ieee754/float128/float128_private.h (__fdivl): New macro. (__ddivl): Likewise. * sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fdiv and ddiv. (CFLAGS-nldbl-ddiv.c): New variable. (CFLAGS-nldbl-fdiv.c): Likewise. * sysdeps/ieee754/ldbl-opt/Versions (GLIBC_2.28): Add __nldbl_ddivl. * sysdeps/ieee754/ldbl-opt/nldbl-compat.h (__nldbl_ddivl): New prototype. * manual/arith.texi (Misc FP Arithmetic): Document fdiv, fdivl, ddivl, fMdivfN, fMdivfNx, fMxdivfN and fMxdivfNx. * math/auto-libm-test-in: Add tests of div. * math/auto-libm-test-out-narrow-div: New generated file. * math/libm-test-narrow-div.inc: New file. * sysdeps/i386/fpu/s_f32xdivf64.c: Likewise. * sysdeps/ieee754/dbl-64/s_f32xdivf64.c: Likewise. * sysdeps/ieee754/dbl-64/s_fdiv.c: Likewise. * sysdeps/ieee754/float128/s_f32divf128.c: Likewise. * sysdeps/ieee754/float128/s_f64divf128.c: Likewise. * sysdeps/ieee754/float128/s_f64xdivf128.c: Likewise. * sysdeps/ieee754/ldbl-128/s_ddivl.c: Likewise. * sysdeps/ieee754/ldbl-128/s_f64xdivf128.c: Likewise. * sysdeps/ieee754/ldbl-128/s_fdivl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_ddivl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_fdivl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_ddivl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_fdivl.c: Likewise. * sysdeps/ieee754/ldbl-opt/nldbl-ddiv.c: Likewise. * sysdeps/ieee754/ldbl-opt/nldbl-fdiv.c: Likewise. * sysdeps/ieee754/soft-fp/s_ddivl.c: Likewise. * sysdeps/ieee754/soft-fp/s_fdiv.c: Likewise. * sysdeps/ieee754/soft-fp/s_fdivl.c: Likewise. * sysdeps/powerpc/fpu/libm-test-ulps: Update. * sysdeps/mach/hurd/i386/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/riscv/rv64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
Diffstat (limited to 'sysdeps/ieee754')
-rw-r--r--sysdeps/ieee754/dbl-64/s_f32xdivf64.c30
-rw-r--r--sysdeps/ieee754/dbl-64/s_fdiv.c34
-rw-r--r--sysdeps/ieee754/float128/float128_private.h2
-rw-r--r--sysdeps/ieee754/float128/s_f32divf128.c6
-rw-r--r--sysdeps/ieee754/float128/s_f64divf128.c10
-rw-r--r--sysdeps/ieee754/float128/s_f64xdivf128.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/s_ddivl.c37
-rw-r--r--sysdeps/ieee754/ldbl-128/s_f64xdivf128.c38
-rw-r--r--sysdeps/ieee754/ldbl-128/s_fdivl.c33
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_ddivl.c27
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_fdivl.c27
-rw-r--r--sysdeps/ieee754/ldbl-96/s_ddivl.c33
-rw-r--r--sysdeps/ieee754/ldbl-96/s_fdivl.c31
-rw-r--r--sysdeps/ieee754/ldbl-opt/Makefile4
-rw-r--r--sysdeps/ieee754/ldbl-opt/Versions2
-rw-r--r--sysdeps/ieee754/ldbl-opt/nldbl-compat.h1
-rw-r--r--sysdeps/ieee754/ldbl-opt/nldbl-ddiv.c28
-rw-r--r--sysdeps/ieee754/ldbl-opt/nldbl-fdiv.c28
-rw-r--r--sysdeps/ieee754/soft-fp/s_ddivl.c59
-rw-r--r--sysdeps/ieee754/soft-fp/s_fdiv.c56
-rw-r--r--sysdeps/ieee754/soft-fp/s_fdivl.c55
21 files changed, 541 insertions, 2 deletions
diff --git a/sysdeps/ieee754/dbl-64/s_f32xdivf64.c b/sysdeps/ieee754/dbl-64/s_f32xdivf64.c
new file mode 100644
index 0000000000..24dc25dc0c
--- /dev/null
+++ b/sysdeps/ieee754/dbl-64/s_f32xdivf64.c
@@ -0,0 +1,30 @@
+/* Divide _Float64 values, converting the result to _Float32x.
+ Copyright (C) 2018 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define ddivl __hide_ddivl
+#include <math.h>
+#undef ddivl
+
+#include <math-narrow.h>
+
+_Float32x
+__f32xdivf64 (_Float64 x, _Float64 y)
+{
+ NARROW_DIV_TRIVIAL (x, y, _Float32x);
+}
+libm_alias_float32x_float64 (div)
diff --git a/sysdeps/ieee754/dbl-64/s_fdiv.c b/sysdeps/ieee754/dbl-64/s_fdiv.c
new file mode 100644
index 0000000000..cdd2649df0
--- /dev/null
+++ b/sysdeps/ieee754/dbl-64/s_fdiv.c
@@ -0,0 +1,34 @@
+/* Divide double values, narrowing the result to float.
+ Copyright (C) 2018 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define f32divf64 __hide_f32divf64
+#define f32divf32x __hide_f32divf32x
+#define fdivl __hide_fdivl
+#include <math.h>
+#undef f32divf64
+#undef f32divf32x
+#undef fdivl
+
+#include <math-narrow.h>
+
+float
+__fdiv (double x, double y)
+{
+ NARROW_DIV_ROUND_TO_ODD (x, y, float, union ieee754_double, , mantissa1);
+}
+libm_alias_float_double (div)
diff --git a/sysdeps/ieee754/float128/float128_private.h b/sysdeps/ieee754/float128/float128_private.h
index 9136e5351b..9dd15601e6 100644
--- a/sysdeps/ieee754/float128/float128_private.h
+++ b/sysdeps/ieee754/float128/float128_private.h
@@ -258,6 +258,8 @@
#define __faddl __f32addf128
#define __daddl __f64addf128
+#define __fdivl __f32divf128
+#define __ddivl __f64divf128
#define __fmull __f32mulf128
#define __dmull __f64mulf128
#define __fsubl __f32subf128
diff --git a/sysdeps/ieee754/float128/s_f32divf128.c b/sysdeps/ieee754/float128/s_f32divf128.c
new file mode 100644
index 0000000000..de8d252e80
--- /dev/null
+++ b/sysdeps/ieee754/float128/s_f32divf128.c
@@ -0,0 +1,6 @@
+#define f32divf64x __hide_f32divf64x
+#define f32divf128 __hide_f32divf128
+#include <float128_private.h>
+#undef f32divf64x
+#undef f32divf128
+#include "../ldbl-128/s_fdivl.c"
diff --git a/sysdeps/ieee754/float128/s_f64divf128.c b/sysdeps/ieee754/float128/s_f64divf128.c
new file mode 100644
index 0000000000..ea37e8bcaf
--- /dev/null
+++ b/sysdeps/ieee754/float128/s_f64divf128.c
@@ -0,0 +1,10 @@
+#define f32xdivf64x __hide_f32xdivf64x
+#define f32xdivf128 __hide_f32xdivf128
+#define f64divf64x __hide_f64divf64x
+#define f64divf128 __hide_f64divf128
+#include <float128_private.h>
+#undef f32xdivf64x
+#undef f32xdivf128
+#undef f64divf64x
+#undef f64divf128
+#include "../ldbl-128/s_ddivl.c"
diff --git a/sysdeps/ieee754/float128/s_f64xdivf128.c b/sysdeps/ieee754/float128/s_f64xdivf128.c
new file mode 100644
index 0000000000..55cc953ba6
--- /dev/null
+++ b/sysdeps/ieee754/float128/s_f64xdivf128.c
@@ -0,0 +1,2 @@
+#include <float128_private.h>
+#include "../ldbl-128/s_f64xdivf128.c"
diff --git a/sysdeps/ieee754/ldbl-128/s_ddivl.c b/sysdeps/ieee754/ldbl-128/s_ddivl.c
new file mode 100644
index 0000000000..c76df92bfb
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128/s_ddivl.c
@@ -0,0 +1,37 @@
+/* Divide long double (ldbl-128) values, narrowing the result to double.
+ Copyright (C) 2018 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define f32xdivf64x __hide_f32xdivf64x
+#define f32xdivf128 __hide_f32xdivf128
+#define f64divf64x __hide_f64divf64x
+#define f64divf128 __hide_f64divf128
+#include <math.h>
+#undef f32xdivf64x
+#undef f32xdivf128
+#undef f64divf64x
+#undef f64divf128
+
+#include <math-narrow.h>
+
+double
+__ddivl (_Float128 x, _Float128 y)
+{
+ NARROW_DIV_ROUND_TO_ODD (x, y, double, union ieee854_long_double, l,
+ mantissa3);
+}
+libm_alias_double_ldouble (div)
diff --git a/sysdeps/ieee754/ldbl-128/s_f64xdivf128.c b/sysdeps/ieee754/ldbl-128/s_f64xdivf128.c
new file mode 100644
index 0000000000..64356bbdd7
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128/s_f64xdivf128.c
@@ -0,0 +1,38 @@
+/* Divide _Float128 values, converting the result to _Float64x.
+ Copyright (C) 2018 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <math.h>
+#include <math-narrow.h>
+
+/* math_ldbl.h defines _Float128 to long double for this directory,
+ but when they are different, this function must be defined with
+ _Float128 arguments to avoid defining an alias with an incompatible
+ type. */
+#undef _Float128
+
+_Float64x
+__f64xdivf128 (_Float128 x, _Float128 y)
+{
+#if __HAVE_FLOAT64X_LONG_DOUBLE && __HAVE_DISTINCT_FLOAT128
+ NARROW_DIV_ROUND_TO_ODD (x, y, _Float64x, union ieee854_long_double, l,
+ mantissa3);
+#else
+ NARROW_DIV_TRIVIAL (x, y, _Float64x);
+#endif
+}
+libm_alias_float64x_float128 (div)
diff --git a/sysdeps/ieee754/ldbl-128/s_fdivl.c b/sysdeps/ieee754/ldbl-128/s_fdivl.c
new file mode 100644
index 0000000000..b00fdb4eaa
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128/s_fdivl.c
@@ -0,0 +1,33 @@
+/* Divide long double (ldbl-128) values, narrowing the result to float.
+ Copyright (C) 2018 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define f32divf64x __hide_f32divf64x
+#define f32divf128 __hide_f32divf128
+#include <math.h>
+#undef f32divf64x
+#undef f32divf128
+
+#include <math-narrow.h>
+
+float
+__fdivl (_Float128 x, _Float128 y)
+{
+ NARROW_DIV_ROUND_TO_ODD (x, y, float, union ieee854_long_double, l,
+ mantissa3);
+}
+libm_alias_float_ldouble (div)
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_ddivl.c b/sysdeps/ieee754/ldbl-128ibm/s_ddivl.c
new file mode 100644
index 0000000000..6bbbbcf09d
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm/s_ddivl.c
@@ -0,0 +1,27 @@
+/* Divide long double (ldbl-128ibm) values, narrowing the result to double.
+ Copyright (C) 2018 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <math.h>
+#include <math-narrow.h>
+
+double
+__ddivl (long double x, long double y)
+{
+ NARROW_DIV_TRIVIAL (x, y, double);
+}
+libm_alias_double_ldouble (div)
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_fdivl.c b/sysdeps/ieee754/ldbl-128ibm/s_fdivl.c
new file mode 100644
index 0000000000..dd34c05502
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm/s_fdivl.c
@@ -0,0 +1,27 @@
+/* Divide long double (ldbl-128ibm) values, narrowing the result to float.
+ Copyright (C) 2018 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <math.h>
+#include <math-narrow.h>
+
+float
+__fdivl (long double x, long double y)
+{
+ NARROW_DIV_TRIVIAL (x, y, float);
+}
+libm_alias_float_ldouble (div)
diff --git a/sysdeps/ieee754/ldbl-96/s_ddivl.c b/sysdeps/ieee754/ldbl-96/s_ddivl.c
new file mode 100644
index 0000000000..9c266d1ff3
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-96/s_ddivl.c
@@ -0,0 +1,33 @@
+/* Divide long double (ldbl-96) values, narrowing the result to double.
+ Copyright (C) 2018 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define f32xdivf64x __hide_f32xdivf64x
+#define f64divf64x __hide_f64divf64x
+#include <math.h>
+#undef f32xdivf64x
+#undef f64divf64x
+
+#include <math-narrow.h>
+
+double
+__ddivl (long double x, long double y)
+{
+ NARROW_DIV_ROUND_TO_ODD (x, y, double, union ieee854_long_double, l,
+ mantissa1);
+}
+libm_alias_double_ldouble (div)
diff --git a/sysdeps/ieee754/ldbl-96/s_fdivl.c b/sysdeps/ieee754/ldbl-96/s_fdivl.c
new file mode 100644
index 0000000000..ccb87ccd15
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-96/s_fdivl.c
@@ -0,0 +1,31 @@
+/* Divide long double (ldbl-96) values, narrowing the result to float.
+ Copyright (C) 2018 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define f32divf64x __hide_f32divf64x
+#include <math.h>
+#undef f32divf64x
+
+#include <math-narrow.h>
+
+float
+__fdivl (long double x, long double y)
+{
+ NARROW_DIV_ROUND_TO_ODD (x, y, float, union ieee854_long_double, l,
+ mantissa1);
+}
+libm_alias_float_ldouble (div)
diff --git a/sysdeps/ieee754/ldbl-opt/Makefile b/sysdeps/ieee754/ldbl-opt/Makefile
index 90b2c928a9..ef790adc77 100644
--- a/sysdeps/ieee754/ldbl-opt/Makefile
+++ b/sysdeps/ieee754/ldbl-opt/Makefile
@@ -45,7 +45,7 @@ libnldbl-calls = asprintf dprintf fprintf fscanf fwprintf fwscanf iovfscanf \
nextup nextdown totalorder totalordermag getpayload \
canonicalize setpayload setpayloadsig llogb fmaxmag fminmag \
roundeven fromfp ufromfp fromfpx ufromfpx fadd dadd \
- fmul dmul fsub dsub
+ fdiv ddiv fmul dmul fsub dsub
libnldbl-routines = $(libnldbl-calls:%=nldbl-%)
libnldbl-inhibit-o = $(object-suffixes)
libnldbl-static-only-routines = $(libnldbl-routines)
@@ -88,6 +88,7 @@ CFLAGS-nldbl-csqrt.c = -fno-builtin-csqrtl
CFLAGS-nldbl-ctan.c = -fno-builtin-ctanl
CFLAGS-nldbl-ctanh.c = -fno-builtin-ctanhl
CFLAGS-nldbl-dadd.c = -fno-builtin-daddl
+CFLAGS-nldbl-ddiv.c = -fno-builtin-ddivl
CFLAGS-nldbl-dmul.c = -fno-builtin-dmull
CFLAGS-nldbl-dsub.c = -fno-builtin-dsubl
CFLAGS-nldbl-erf.c = -fno-builtin-erfl
@@ -99,6 +100,7 @@ CFLAGS-nldbl-expm1.c = -fno-builtin-expm1l
CFLAGS-nldbl-fabs.c = -fno-builtin-fabsl
CFLAGS-nldbl-fadd.c = -fno-builtin-faddl
CFLAGS-nldbl-fdim.c = -fno-builtin-fdiml
+CFLAGS-nldbl-fdiv.c = -fno-builtin-fdivl
CFLAGS-nldbl-finite.c = -fno-builtin-finitel
CFLAGS-nldbl-floor.c = -fno-builtin-floorl
CFLAGS-nldbl-fma.c = -fno-builtin-fmal
diff --git a/sysdeps/ieee754/ldbl-opt/Versions b/sysdeps/ieee754/ldbl-opt/Versions
index 17aa035248..af0c4a098c 100644
--- a/sysdeps/ieee754/ldbl-opt/Versions
+++ b/sysdeps/ieee754/ldbl-opt/Versions
@@ -101,6 +101,6 @@ libm {
# Functions taking long double = double argument and rounding
# result to double (same as f32x*f64 functions, but those names
# are not reserved in TS 18661-1).
- __nldbl_daddl; __nldbl_dmull; __nldbl_dsubl;
+ __nldbl_daddl; __nldbl_ddivl; __nldbl_dmull; __nldbl_dsubl;
}
}
diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.h b/sysdeps/ieee754/ldbl-opt/nldbl-compat.h
index e0d12545a3..888f561cac 100644
--- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.h
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.h
@@ -104,6 +104,7 @@ extern void __nldbl___vsyslog_chk (int, int, const char *, va_list);
/* The original declarations of these were hidden by the including
file. */
extern double __nldbl_daddl (double, double) __THROW;
+extern double __nldbl_ddivl (double, double) __THROW;
extern double __nldbl_dmull (double, double) __THROW;
extern double __nldbl_dsubl (double, double) __THROW;
diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-ddiv.c b/sysdeps/ieee754/ldbl-opt/nldbl-ddiv.c
new file mode 100644
index 0000000000..5cb4606b7d
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-ddiv.c
@@ -0,0 +1,28 @@
+/* Compatibility routine for IEEE double as long double for ddiv.
+ Copyright (C) 2018 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define ddivl __hide_ddivl
+#include "nldbl-compat.h"
+#undef ddivl
+
+double
+attribute_hidden
+ddivl (double x, double y)
+{
+ return __nldbl_ddivl (x, y);
+}
diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-fdiv.c b/sysdeps/ieee754/ldbl-opt/nldbl-fdiv.c
new file mode 100644
index 0000000000..2d043fc721
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-fdiv.c
@@ -0,0 +1,28 @@
+/* Compatibility routine for IEEE double as long double for fdiv.
+ Copyright (C) 2018 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define fdivl __hide_fdivl
+#include "nldbl-compat.h"
+#undef fdivl
+
+float
+attribute_hidden
+fdivl (double x, double y)
+{
+ return fdiv (x, y);
+}
diff --git a/sysdeps/ieee754/soft-fp/s_ddivl.c b/sysdeps/ieee754/soft-fp/s_ddivl.c
new file mode 100644
index 0000000000..7e598a2132
--- /dev/null
+++ b/sysdeps/ieee754/soft-fp/s_ddivl.c
@@ -0,0 +1,59 @@
+/* Divide long double (ldbl-128) values, narrowing the result to
+ double, using soft-fp.
+ Copyright (C) 2018 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define f32xdivf64x __hide_f32xdivf64x
+#define f32xdivf128 __hide_f32xdivf128
+#define f64divf64x __hide_f64divf64x
+#define f64divf128 __hide_f64divf128
+#include <math.h>
+#undef f32xdivf64x
+#undef f32xdivf128
+#undef f64divf64x
+#undef f64divf128
+
+#include <math-narrow.h>
+#include <soft-fp.h>
+#include <double.h>
+#include <quad.h>
+
+double
+__ddivl (_Float128 x, _Float128 y)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (X);
+ FP_DECL_Q (Y);
+ FP_DECL_Q (R);
+ FP_DECL_D (RN);
+ double ret;
+
+ FP_INIT_ROUNDMODE;
+ FP_UNPACK_Q (X, x);
+ FP_UNPACK_Q (Y, y);
+ FP_DIV_Q (R, X, Y);
+#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
+ FP_TRUNC_COOKED (D, Q, 2, 4, RN, R);
+#else
+ FP_TRUNC_COOKED (D, Q, 1, 2, RN, R);
+#endif
+ FP_PACK_D (ret, RN);
+ FP_HANDLE_EXCEPTIONS;
+ CHECK_NARROW_DIV (ret, x, y);
+ return ret;
+}
+libm_alias_double_ldouble (div)
diff --git a/sysdeps/ieee754/soft-fp/s_fdiv.c b/sysdeps/ieee754/soft-fp/s_fdiv.c
new file mode 100644
index 0000000000..341339f5ed
--- /dev/null
+++ b/sysdeps/ieee754/soft-fp/s_fdiv.c
@@ -0,0 +1,56 @@
+/* Divide double values, narrowing the result to float, using soft-fp.
+ Copyright (C) 2018 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define f32divf64 __hide_f32divf64
+#define f32divf32x __hide_f32divf32x
+#define fdivl __hide_fdivl
+#include <math.h>
+#undef f32divf64
+#undef f32divf32x
+#undef fdivl
+
+#include <math-narrow.h>
+#include <soft-fp.h>
+#include <single.h>
+#include <double.h>
+
+float
+__fdiv (double x, double y)
+{
+ FP_DECL_EX;
+ FP_DECL_D (X);
+ FP_DECL_D (Y);
+ FP_DECL_D (R);
+ FP_DECL_S (RN);
+ float ret;
+
+ FP_INIT_ROUNDMODE;
+ FP_UNPACK_D (X, x);
+ FP_UNPACK_D (Y, y);
+ FP_DIV_D (R, X, Y);
+#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
+ FP_TRUNC_COOKED (S, D, 1, 2, RN, R);
+#else
+ FP_TRUNC_COOKED (S, D, 1, 1, RN, R);
+#endif
+ FP_PACK_S (ret, RN);
+ FP_HANDLE_EXCEPTIONS;
+ CHECK_NARROW_DIV (ret, x, y);
+ return ret;
+}
+libm_alias_float_double (div)
diff --git a/sysdeps/ieee754/soft-fp/s_fdivl.c b/sysdeps/ieee754/soft-fp/s_fdivl.c
new file mode 100644
index 0000000000..7fb3709c73
--- /dev/null
+++ b/sysdeps/ieee754/soft-fp/s_fdivl.c
@@ -0,0 +1,55 @@
+/* Divide long double (ldbl-128) values, narrowing the result to
+ float, using soft-fp.
+ Copyright (C) 2018 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#define f32divf64x __hide_f32divf64x
+#define f32divf128 __hide_f32divf128
+#include <math.h>
+#undef f32divf64x
+#undef f32divf128
+
+#include <math-narrow.h>
+#include <soft-fp.h>
+#include <single.h>
+#include <quad.h>
+
+float
+__fdivl (_Float128 x, _Float128 y)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (X);
+ FP_DECL_Q (Y);
+ FP_DECL_Q (R);
+ FP_DECL_S (RN);
+ float ret;
+
+ FP_INIT_ROUNDMODE;
+ FP_UNPACK_Q (X, x);
+ FP_UNPACK_Q (Y, y);
+ FP_DIV_Q (R, X, Y);
+#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
+ FP_TRUNC_COOKED (S, Q, 1, 4, RN, R);
+#else
+ FP_TRUNC_COOKED (S, Q, 1, 2, RN, R);
+#endif
+ FP_PACK_S (ret, RN);
+ FP_HANDLE_EXCEPTIONS;
+ CHECK_NARROW_DIV (ret, x, y);
+ return ret;
+}
+libm_alias_float_ldouble (div)