On Fri, 20 May 2016, Rajalakshmi Srinivasaraghavan wrote:
> This patch adds nextup and nextdown functions from TS 18661-1.
New functions need NEWS entries.
I think the patch submission (which will become the commit log entry)
should also say more about these functions and the rationale for adding
these particular functions on their own, i.e. that TS 18661-3 does not
include nexttoward analogues for new floating-point types, but instead
adds nextup and nextdown functions alongside nextafter, so to provide
support for float128 equivalent to that for other floating-point types
it's natural to add nextup and nextdown first. It should also discuss the
design choices in the implementation.
> diff --git a/conform/data/math.h-data b/conform/data/math.h-data
> index 7153333..e96bb4e 100644
> --- a/conform/data/math.h-data
> +++ b/conform/data/math.h-data
> @@ -128,6 +128,8 @@ function int ilogb (double)
> function double log1p (double)
> function double logb (double)
> function double nextafter (double, double)
> +function double nextdown (double)
> +function double nextup (double)
This is not correct. These functions are not in ISO C so must not be
expected to be in ISO C, or any of the existing standards supported by
conformtest. Since you correctly condition the functions on __USE_GNU
(absent a framework for supporting ISO-style feature test macros), I'd
have expected this to cause test failures - did you not run the tests for
conform/?
> diff --git a/conform/data/tgmath.h-data b/conform/data/tgmath.h-data
> index 5f72502..71256f9 100644
> --- a/conform/data/tgmath.h-data
> +++ b/conform/data/tgmath.h-data
> @@ -48,7 +48,9 @@ macro lrint
> macro lround
> macro nearbyint
> macro nextafter
> +macro nextdown
> macro nexttoward
> +macro nextup
Again, not correct.
> +@comment math.h
> +@comment ISO
> +@deftypefun double nextdown (double @var{x})
> +@comment math.h
> +@comment ISO
> +@deftypefunx float nextdownf (float @var{x})
> +@comment math.h
> +@comment ISO
> +@deftypefunx {long double} nextdownl (long double @var{x})
Right now, we use "ISO" to mean ISO C not these extensions. See how
issignaling is documented as GNU.
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
> +The @code{nextdown} function returns the next representable value
> +less than @var{x}. If @var{x} is the positive number of least
> +magnitude the function returns +0 if the type has signed zeros
> +and is 0 otherwise. If @var{x} is zero, the function returns
> +the negative number of least magnitude in the type of @var{x}.
> +nextdown(@code{-HUGE_VAL}) is @code{-HUGE_VAL}
I don't think we need to talk about types without signed zero.
> +This function is defined in @w{IEC 559} (and the appendix with
> +recommended functions in @w{IEEE 754}/@w{IEEE 854}).
No. It's ISO/IEC/IEEE 60559 in the current edition that defines this and
this is not about an appendix, nextUp/nextDown are in the main body.
> +@comment math.h
> +@comment ISO
> +@deftypefun double nextup (double @var{x})
> +@comment math.h
> +@comment ISO
> +@deftypefunx float nextupf (float @var{x})
> +@comment math.h
> +@comment ISO
> +@deftypefunx {long double} nextupl (long double @var{x})
> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
Same comments.
> diff --git a/math/bits/mathcalls.h b/math/bits/mathcalls.h
> index 9a7b3f0..5a7651d 100644
> --- a/math/bits/mathcalls.h
> +++ b/math/bits/mathcalls.h
> @@ -287,13 +287,19 @@ __BEGIN_NAMESPACE_C99
> /* Return the integer nearest X in the direction of the
> prevailing rounding mode. */
> __MATHCALL (rint,, (_Mdouble_ __x));
> -
> /* Return X + epsilon if X < Y, X - epsilon if X > Y. */
Gratuitous change of unrelated code.
> +static const struct test_f_f_data nextup_test_data[] =
> + {
> + TEST_f_f (nextup, minus_zero, min_subnorm_value, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_f_f (nextup, 0, min_subnorm_value, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_f_f (nextup, plus_zero, min_subnorm_value, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_f_f (nextup, -min_subnorm_value, minus_zero, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_ERANGE),
> + TEST_f_f (nextup, max_value, plus_infty, INEXACT_EXCEPTION|OVERFLOW_EXCEPTION|ERRNO_ERANGE),
> + TEST_f_f (nextup, plus_infty, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_f_f (nextup, minus_infty, -max_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_f_f (nextup, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
> + TEST_f_f (nextup, -qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
Many of these expectations are wrong. nextup and nextdown are *not* the
same as nextafter regarding exceptions; to quote IEEE 754-2008 /
ISO/IEC/IEEE 60559:2011, "nextUp(x) is quiet except for sNaNs.".
> +static const struct test_f_f_data nextdown_test_data[] =
Likewise.
> + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
No "Contributed by" in new files.
> +/*
> + * nextup(x)
> + * return the least floating-point number in the
> + * format of x that compares greater than x.
Badly formatted comment.
> +FLOAT
> +INTERNAL(NEXTUP) (FLOAT x)
> +{
> +#ifdef USE_AS_NEXTDOWN
> + return NEXTAFTER (x, -INFINITY);
> +#else
> + return NEXTAFTER (x, INFINITY);
> +#endif
As discussed, this is incorrect. nextafter, as in the appendix to IEEE
754-1985, signals underflow and overflow in certain cases (but is still
independent of the rounding mode), but nextup / nextdown do not. So you
can't implement these functions in terms of nextafter (without saving /
restoring exceptions and making special allowance to ensure exceptions are
still raised for sNaN, which is clearly an excessively inefficient way of
doing things).
> diff --git a/math/tgmath.h b/math/tgmath.h
> index ea2b611..62ae907 100644
> --- a/math/tgmath.h
> +++ b/math/tgmath.h
> @@ -391,6 +391,10 @@
> /* Return the integer nearest X in the direction of the
> prevailing rounding mode. */
> #define rint(Val) __TGMATH_UNARY_REAL_ONLY (Val, rint)
> +/* Return X - epsilon. */
> +#define nextdown(Val) __TGMATH_UNARY_REAL_ONLY (Val, nextdown)
> +/* Return X + epsilon. */
> +#define nextup(Val) __TGMATH_UNARY_REAL_ONLY (Val, nextup)
You need __USE_GNU conditionals here.
> diff --git a/sysdeps/unix/sysv/linux/alpha/libm.abilist b/sysdeps/unix/sysv/linux/alpha/libm.abilist
> index 611dfe1..0a5b83c 100644
> --- a/sysdeps/unix/sysv/linux/alpha/libm.abilist
> +++ b/sysdeps/unix/sysv/linux/alpha/libm.abilist
> @@ -563,3 +563,10 @@ GLIBC_2.4 truncl F
> GLIBC_2.4 y0l F
> GLIBC_2.4 y1l F
> GLIBC_2.4 ynl F
> +GLIBC_2.24 GLIBC_2.24 A
> +GLIBC_2.24 nextdown F
> +GLIBC_2.24 nextdownf F
> +GLIBC_2.24 nextdownl F
> +GLIBC_2.24 nextup F
> +GLIBC_2.24 nextupf F
> +GLIBC_2.24 nextupl F
These files are sorted strictly according to LC_ALL=C collation. In this
one and many others, you have placed the new entries out of order, so the
ABI tests would fail.
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist
> index 6c7fc9b..13a4633 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist
> @@ -508,3 +508,10 @@ GLIBC_2.4 truncl F
> GLIBC_2.4 y0l F
> GLIBC_2.4 y1l F
> GLIBC_2.4 ynl F
> +GLIBC_2.24 GLIBC_2.24 A
Since this is one of the files out of order, and since you said you tested
on powerpc64, I'd have expected you to get test failures there. Just
testing isn't enough without understanding any failures and making sure
they are unrelated to your patch....
I think you should also update sysdeps/ieee754/ldbl-opt/ so that there are
versions of nextdownl and nextupl in libnldbl.a (that's for use when
linking programs built with -mlong-double-64 and either their own
declarations of long double functions, or including <math.h> with a
compiler not supporting asm redirections).
@@ -128,6 +128,8 @@ function int ilogb (double)
function double log1p (double)
function double logb (double)
function double nextafter (double, double)
+function double nextdown (double)
+function double nextup (double)
# if !defined XPG4 && !defined UNIX98
function double nexttoward (double, long double)
function double nearbyint (double)
@@ -203,7 +205,9 @@ function int ilogbf (float)
function float log1pf (float)
function float logbf (float)
function float nextafterf (float, float)
+function float nextdownf (float)
function float nexttowardf (float, long double)
+function float nextupf (float)
function float nearbyintf (float)
function float remainderf (float, float)
function float rintf (float)
@@ -261,7 +265,9 @@ function int ilogbl (long double)
function {long double} log1pl (long double)
function {long double} logbl (long double)
function {long double} nextafterl (long double, long double)
+function {long double} nextdownl (long double)
function {long double} nexttowardl (long double, long double)
+function {long double} nextupl (long double)
function {long double} nearbyintl (long double)
function {long double} remainderl (long double, long double)
function {long double} rintl (long double)
@@ -48,7 +48,9 @@ macro lrint
macro lround
macro nearbyint
macro nextafter
+macro nextdown
macro nexttoward
+macro nextup
macro remainder
macro remquo
macro rint
@@ -1687,6 +1687,28 @@ This function is defined in @w{IEC 559} (and the appendix with
recommended functions in @w{IEEE 754}/@w{IEEE 854}).
@end deftypefun
+
+@comment math.h
+@comment ISO
+@deftypefun double nextdown (double @var{x})
+@comment math.h
+@comment ISO
+@deftypefunx float nextdownf (float @var{x})
+@comment math.h
+@comment ISO
+@deftypefunx {long double} nextdownl (long double @var{x})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+The @code{nextdown} function returns the next representable value
+less than @var{x}. If @var{x} is the positive number of least
+magnitude the function returns +0 if the type has signed zeros
+and is 0 otherwise. If @var{x} is zero, the function returns
+the negative number of least magnitude in the type of @var{x}.
+nextdown(@code{-HUGE_VAL}) is @code{-HUGE_VAL}
+
+This function is defined in @w{IEC 559} (and the appendix with
+recommended functions in @w{IEEE 754}/@w{IEEE 854}).
+@end deftypefun
+
@comment math.h
@comment ISO
@deftypefun double nexttoward (double @var{x}, long double @var{y})
@@ -1702,6 +1724,28 @@ These functions are identical to the corresponding versions of
double}.
@end deftypefun
+@comment math.h
+@comment ISO
+@deftypefun double nextup (double @var{x})
+@comment math.h
+@comment ISO
+@deftypefunx float nextupf (float @var{x})
+@comment math.h
+@comment ISO
+@deftypefunx {long double} nextupl (long double @var{x})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+
+The @code{nextup} function returns the next representable value
+greater than @var{x}. If @var{x} is the negative number of least
+magnitude the function returns -0 if the type has signed zeros
+and is 0 otherwise. If @var{x} is zero, the function returns
+the positive number of least magnitude in the type of @var{x}.
+nextup(@code{HUGE_VAL}) is @code{HUGE_VAL}
+
+This function is defined in @w{IEC 559} (and the appendix with
+recommended functions in @w{IEEE 754}/@w{IEEE 854}).
+@end deftypefun
+
@cindex NaN
@comment math.h
@comment ISO
@@ -73,9 +73,9 @@ use vars qw (%results @all_floats %suffices @all_functions);
"fmax", "fmin", "fmod", "frexp", "gamma", "hypot",
"ilogb", "j0", "j1", "jn", "lgamma", "lrint",
"llrint", "log", "log10", "log1p", "log2", "logb", "lround",
- "llround", "modf", "nearbyint", "nextafter", "nexttoward", "pow",
- "remainder", "remquo", "rint", "round", "scalb", "scalbn", "scalbln",
- "sin", "sincos", "sinh", "sqrt", "tan", "tanh", "tgamma",
+ "llround", "modf", "nearbyint", "nextafter", "nextdown", "nexttoward",
+ "nextup", "pow", "remainder", "remquo", "rint", "round", "scalb",
+ "scalbn", "sin", "sincos", "sinh", "sqrt", "tan", "tanh", "tgamma",
"trunc", "y0", "y1", "yn" );
# fpclassify, isnormal, isfinite, isinf, isnan, issignaling, signbit,
# isgreater, isgreaterequal, isless, islessequal, islessgreater, isunordered
@@ -63,7 +63,7 @@ libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod \
s_fma s_lrint s_llrint s_lround s_llround e_exp10 w_log2 \
s_issignaling $(calls:s_%=m_%) x2y2m1 k_casinh \
gamma_product k_standard lgamma_neg lgamma_product \
- w_lgamma_compat
+ w_lgamma_compat s_nextdown s_nextup
dbl-only-routines := branred doasin dosincos halfulp mpa mpatan2 \
mpatan mpexp mplog mpsqrt mptan sincos32 slowexp \
@@ -210,4 +210,8 @@ libm {
# dynamic symbol for signgam but not __signgam.
lgamma; lgammaf; lgammal; __signgam;
}
+ GLIBC_2.24 {
+ nextdown; nextdownf; nextdownl;
+ nextup; nextupf; nextupl;
+ }
}
@@ -287,13 +287,19 @@ __BEGIN_NAMESPACE_C99
/* Return the integer nearest X in the direction of the
prevailing rounding mode. */
__MATHCALL (rint,, (_Mdouble_ __x));
-
/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
__MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
# if defined __USE_ISOC99 && !defined __LDBL_COMPAT
__MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__));
# endif
+#ifdef __USE_GNU
+/* Return X - epsilon. */
+__MATHCALL (nextdown,, (_Mdouble_ __x));
+/* Return X + epsilon. */
+__MATHCALL (nextup,, (_Mdouble_ __x));
+# endif
+
/* Return the remainder of integer divison X / Y with infinite precision. */
__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
@@ -9912,6 +9912,52 @@ nextafter_test (void)
ALL_RM_TEST (nextafter, 1, nextafter_test_data, RUN_TEST_LOOP_ff_f, END);
}
+static const struct test_f_f_data nextup_test_data[] =
+ {
+ TEST_f_f (nextup, minus_zero, min_subnorm_value, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextup, 0, min_subnorm_value, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextup, plus_zero, min_subnorm_value, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextup, -min_subnorm_value, minus_zero, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_ERANGE),
+ TEST_f_f (nextup, max_value, plus_infty, INEXACT_EXCEPTION|OVERFLOW_EXCEPTION|ERRNO_ERANGE),
+ TEST_f_f (nextup, plus_infty, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextup, minus_infty, -max_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextup, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextup, -qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#if defined TEST_LDOUBLE && LDBL_MANT_DIG == 106
+ TEST_f_f (nextup, 1.0L, 1.0L+0x1p-105L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextup, -1.0L-0x1p-105L, -1.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextup, -1.0L, -1.0L+0x1p-106L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
+ };
+
+static void
+nextup_test (void)
+{
+ ALL_RM_TEST (nextup, 1, nextup_test_data, RUN_TEST_LOOP_f_f, END);
+}
+
+static const struct test_f_f_data nextdown_test_data[] =
+ {
+ TEST_f_f (nextdown, minus_zero, -min_subnorm_value, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextdown, 0, -min_subnorm_value, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextdown, plus_zero, -min_subnorm_value, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextdown, min_subnorm_value, 0, INEXACT_EXCEPTION|UNDERFLOW_EXCEPTION|ERRNO_ERANGE),
+ TEST_f_f (nextdown, plus_infty, max_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextdown, minus_infty, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextdown, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextdown, -qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#if defined TEST_LDOUBLE && LDBL_MANT_DIG == 106
+ TEST_f_f (nextdown, -1.0L, -1.0L-0x1p-105L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextdown, 1.0L+0x1p-105L, 1.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (nextdown, 1.0L, 1.0L-0x1p-106L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
+ };
+
+static void
+nextdown_test (void)
+{
+ ALL_RM_TEST (nextdown, 1, nextdown_test_data, RUN_TEST_LOOP_f_f, END);
+}
static const struct test_ff_f_data_nexttoward nexttoward_test_data[] =
{
@@ -12013,6 +12059,8 @@ main (int argc, char **argv)
/* Manipulation functions: */
copysign_test ();
+ nextup_test();
+ nextdown_test();
nextafter_test ();
nexttoward_test ();
new file mode 100644
@@ -0,0 +1,23 @@
+/* Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+#define FLOAT double
+#define NEXTUP nextdown
+#define NEXTAFTER nextafter
+#define USE_AS_NEXTDOWN 1
+
+#include "s_nextup.c"
new file mode 100644
@@ -0,0 +1,23 @@
+/* Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+#define FLOAT float
+#define NEXTUP nextdownf
+#define NEXTAFTER nextafterf
+#define USE_AS_NEXTDOWN 1
+
+#include "s_nextup.c"
new file mode 100644
@@ -0,0 +1,23 @@
+/* Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+#define FLOAT long double
+#define NEXTUP nextdownl
+#define NEXTAFTER nextafterl
+#define USE_AS_NEXTDOWN 1
+
+#include "s_nextup.c"
new file mode 100644
@@ -0,0 +1,52 @@
+/* Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/*
+ * nextup(x)
+ * return the least floating-point number in the
+ * format of x that compares greater than x.
+ */
+
+#include <errno.h>
+#include <math.h>
+#include <math_private.h>
+#include <float.h>
+
+#ifndef FLOAT
+# define FLOAT double
+# define NEXTAFTER nextafter
+# ifdef USE_AS_NEXTDOWN
+# define NEXTUP nextdown
+# else
+# define NEXTUP nextup
+# endif
+#endif
+
+#define INTERNAL(X) INTERNAL1(X)
+#define INTERNAL1(X) __##X
+
+FLOAT
+INTERNAL(NEXTUP) (FLOAT x)
+{
+#ifdef USE_AS_NEXTDOWN
+ return NEXTAFTER (x, -INFINITY);
+#else
+ return NEXTAFTER (x, INFINITY);
+#endif
+}
+weak_alias (INTERNAL(NEXTUP), NEXTUP)
new file mode 100644
@@ -0,0 +1,22 @@
+/* Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+#define FLOAT float
+#define NEXTUP nextupf
+#define NEXTAFTER nextafterf
+
+#include "s_nextup.c"
new file mode 100644
@@ -0,0 +1,22 @@
+/* Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+#define FLOAT long double
+#define NEXTUP nextupl
+#define NEXTAFTER nextafterl
+
+#include "s_nextup.c"
@@ -274,7 +274,9 @@ F(compile_test) (void)
b = lgamma (lgamma (a));
a = rint (rint (x));
b = nextafter (nextafter (a, b), nextafter (c, x));
- a = nexttoward (nexttoward (x, a), c);
+ a = nextdown (nextdown (a));
+ b = nexttoward (nexttoward (x, a), c);
+ a = nextup (nextup (a));
b = remainder (remainder (a, b), remainder (c, x));
a = scalb (scalb (x, a), (TYPE) (6));
k = scalbn (a, 7) + scalbln (c, 10l);
@@ -777,6 +779,14 @@ TYPE
}
TYPE
+(F(nextdown)) (TYPE x)
+{
+ ++count;
+ P ();
+ return x;
+}
+
+TYPE
(F(nexttoward)) (TYPE x, long double y)
{
++count;
@@ -785,6 +795,14 @@ TYPE
}
TYPE
+(F(nextup)) (TYPE x)
+{
+ ++count;
+ P ();
+ return x;
+}
+
+TYPE
(F(remainder)) (TYPE x, TYPE y)
{
++count;
@@ -391,6 +391,10 @@
/* Return the integer nearest X in the direction of the
prevailing rounding mode. */
#define rint(Val) __TGMATH_UNARY_REAL_ONLY (Val, rint)
+/* Return X - epsilon. */
+#define nextdown(Val) __TGMATH_UNARY_REAL_ONLY (Val, nextdown)
+/* Return X + epsilon. */
+#define nextup(Val) __TGMATH_UNARY_REAL_ONLY (Val, nextup)
/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
#define nextafter(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, nextafter)
@@ -372,3 +372,10 @@ GLIBC_2.23 __signgam D 0x4
GLIBC_2.23 lgamma F
GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -403,3 +403,10 @@ GLIBC_2.23 __signgam D 0x4
GLIBC_2.23 lgamma F
GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -563,3 +563,10 @@ GLIBC_2.4 truncl F
GLIBC_2.4 y0l F
GLIBC_2.4 y1l F
GLIBC_2.4 ynl F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -374,3 +374,10 @@ GLIBC_2.4 y1l F
GLIBC_2.4 yn F
GLIBC_2.4 ynf F
GLIBC_2.4 ynl F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -375,3 +375,10 @@ GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
GLIBC_2.4 GLIBC_2.4 A
GLIBC_2.4 exp2l F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -416,3 +416,10 @@ GLIBC_2.23 lgamma F
GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
GLIBC_2.4 GLIBC_2.4 A
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -345,3 +345,10 @@ GLIBC_2.23 lgamma F
GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
GLIBC_2.4 GLIBC_2.4 A
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -374,3 +374,10 @@ GLIBC_2.4 y1l F
GLIBC_2.4 yn F
GLIBC_2.4 ynf F
GLIBC_2.4 ynl F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -414,3 +414,10 @@ GLIBC_2.23 lgamma F
GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
GLIBC_2.4 GLIBC_2.4 A
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -372,3 +372,10 @@ GLIBC_2.23 __signgam D 0x4
GLIBC_2.23 lgamma F
GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -377,3 +377,10 @@ GLIBC_2.23 lgammal F
GLIBC_2.4 GLIBC_2.4 A
GLIBC_2.4 exp2l F
_gp_disp _gp_disp A
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -406,3 +406,10 @@ GLIBC_2.23 lgamma F
GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
GLIBC_2.4 GLIBC_2.4 A
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -372,3 +372,10 @@ GLIBC_2.23 __signgam D 0x4
GLIBC_2.23 lgamma F
GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -517,3 +517,10 @@ GLIBC_2.4 truncl F
GLIBC_2.4 y0l F
GLIBC_2.4 y1l F
GLIBC_2.4 ynl F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -516,3 +516,10 @@ GLIBC_2.4 truncl F
GLIBC_2.4 y0l F
GLIBC_2.4 y1l F
GLIBC_2.4 ynl F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -408,3 +408,10 @@ GLIBC_2.23 __signgam D 0x4
GLIBC_2.23 lgamma F
GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -508,3 +508,10 @@ GLIBC_2.4 truncl F
GLIBC_2.4 y0l F
GLIBC_2.4 y1l F
GLIBC_2.4 ynl F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -506,3 +506,10 @@ GLIBC_2.4 truncl F
GLIBC_2.4 y0l F
GLIBC_2.4 y1l F
GLIBC_2.4 ynl F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -504,3 +504,10 @@ GLIBC_2.4 truncl F
GLIBC_2.4 y0l F
GLIBC_2.4 y1l F
GLIBC_2.4 ynl F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -375,3 +375,10 @@ GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
GLIBC_2.4 GLIBC_2.4 A
GLIBC_2.4 exp2l F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -509,3 +509,10 @@ GLIBC_2.4 truncl F
GLIBC_2.4 y0l F
GLIBC_2.4 y1l F
GLIBC_2.4 ynl F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -405,3 +405,10 @@ GLIBC_2.23 lgamma F
GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
GLIBC_2.4 GLIBC_2.4 A
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -373,3 +373,10 @@ GLIBC_2.23 __signgam D 0x4
GLIBC_2.23 lgamma F
GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -373,3 +373,10 @@ GLIBC_2.23 __signgam D 0x4
GLIBC_2.23 lgamma F
GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -373,3 +373,10 @@ GLIBC_2.23 __signgam D 0x4
GLIBC_2.23 lgamma F
GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -405,3 +405,10 @@ GLIBC_2.23 lgamma F
GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
GLIBC_2.4 GLIBC_2.4 A
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -47,3 +47,10 @@ GLIBC_2.22 _ZGVeN8v_log F
GLIBC_2.22 _ZGVeN8v_sin F
GLIBC_2.22 _ZGVeN8vv_pow F
GLIBC_2.22 _ZGVeN8vvv_sincos F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F
@@ -403,3 +403,10 @@ GLIBC_2.23 __signgam D 0x4
GLIBC_2.23 lgamma F
GLIBC_2.23 lgammaf F
GLIBC_2.23 lgammal F
+GLIBC_2.24 GLIBC_2.24 A
+GLIBC_2.24 nextdown F
+GLIBC_2.24 nextdownf F
+GLIBC_2.24 nextdownl F
+GLIBC_2.24 nextup F
+GLIBC_2.24 nextupf F
+GLIBC_2.24 nextupl F