about summary refs log tree commit diff
path: root/math
diff options
context:
space:
mode:
Diffstat (limited to 'math')
-rw-r--r--math/Makefile8
-rw-r--r--math/libm-test.c287
-rw-r--r--math/math.h8
-rw-r--r--math/mathcalls.h19
4 files changed, 202 insertions, 120 deletions
diff --git a/math/Makefile b/math/Makefile
index fbbcad6ea9..bd4506b99e 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -39,20 +39,20 @@ extra-libs-others = $(extra-libs)
 libm-map	:= libm.map
 
 libm-support = k_standard s_lib_version s_matherr s_signgam		\
-	       s_rinttol s_rinttoll s_roundtol s_roundtoll		\
+	       s_lrint s_llrint s_lround s_llround			\
 	       fclrexcpt fgetexcptflg fraiseexcpt fsetexcptflg		\
 	       ftestexcept fegetround fesetround fegetenv feholdexcpt	\
 	       fesetenv feupdateenv
 libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod	\
 	     e_hypot e_j0 e_j1 e_jn e_lgamma_r e_log e_log10 e_pow	\
-	     e_rem_pio2 e_remainder e_scalb e_sinh e_sqrt k_cos		\
-	     k_rem_pio2 k_sin k_tan s_asinh s_atan s_cbrt		\
+	     e_rem_pio2 e_remainder e_scalb e_sinh e_sqrt e_gamma_r	\
+	     k_cos k_rem_pio2 k_sin k_tan s_asinh s_atan s_cbrt		\
 	     s_ceil s_copysign s_cos s_erf s_expm1 s_fabs s_finite	\
 	     s_floor s_frexp s_ilogb s_ldexp s_log1p s_logb 		\
 	     s_modf s_nextafter s_rint s_scalbn s_significand		\
 	     s_sin s_tan s_tanh w_acos w_acosh w_asin			\
 	     w_atan2 w_atanh w_cosh w_drem w_exp w_fmod w_gamma		\
-	     w_gamma_r w_hypot w_j0 w_j1 w_jn w_lgamma w_lgamma_r	\
+	     w_hypot w_j0 w_j1 w_jn w_lgamma w_lgamma_r			\
 	     w_log w_log10 w_pow w_remainder w_scalb w_sinh w_sqrt	\
 	     s_signbit s_fpclassify s_fmax s_fmin s_fdim s_nan s_trunc	\
 	     s_remquo s_log2 s_exp2 s_round s_nearbyint s_sincos	\
diff --git a/math/libm-test.c b/math/libm-test.c
index be7538350b..5bf968f844 100644
--- a/math/libm-test.c
+++ b/math/libm-test.c
@@ -47,8 +47,8 @@
    ilogb, isfinite, isinf, isnan, isnormal,
    ldexp, lgamma, log, log10, log1p, log2, logb,
    modf, nearbyint, nextafter,
-   pow, remainder, remquo, rint, rinttol, rinttoll,
-   round, roundtol, roundtoll,
+   pow, remainder, remquo, rint, lrint, llrint,
+   round, lround, llround,
    scalb, scalbn, signbit, sin, sincos, sinh, sqrt, tan, tanh, trunc
 
    and for the following complex math functions:
@@ -593,6 +593,35 @@ check_int (const char *test_name, int computed, int expected)
   fpstack_test (test_name);
 }
 
+static void
+check_int_exc (const char *test_name, int computed, int expected,
+	       short exception)
+{
+  int diff = computed - expected;
+  int result = diff == 0;
+
+  output_new_test (test_name);
+  test_exceptions (test_name, exception);
+
+  if (result)
+    {
+      output_pass_value ();
+    }
+  else
+    {
+      output_fail_value (test_name);
+      if (verbose > 1)
+	{
+	  printf ("Result:\n");
+	  printf (" is:         %d\n", computed);
+	  printf (" should be:  %d\n", expected);
+	}
+      noErrors++;
+    }
+
+  fpstack_test (test_name);
+}
+
 
 /*
   check that computed and expected values are equal (long int values)
@@ -953,7 +982,9 @@ atan2_test (void)
 static void
 atanh_test (void)
 {
+#ifndef TEST_INLINE
   MATHTYPE x;
+#endif
 
   check ("atanh(+0) == +0", FUNC(atanh) (0), 0);
 #ifndef TEST_INLINE
@@ -1089,7 +1120,7 @@ static void
 exp2_test (void)
 {
   errno = 0;
-  exp2(0);
+  FUNC(exp2) (0);
   if (errno == ENOSYS)
     /* Function not implemented.  */
     return;
@@ -1257,7 +1288,6 @@ signbit_test (void)
   check_bool ("signbit (-0) != 0", signbit (minus_zero));
   check_bool ("signbit (+inf) == 0", signbit (plus_infty) == 0);
   check_bool ("signbit (-inf) != 0", signbit (minus_infty));
-  check_bool ("signbit (NaN) == 0", signbit (nan_value));
 
   x = random_less (0);
   check_bool ("signbit (x) != 0 for x < 0", signbit (x));
@@ -1272,21 +1302,26 @@ signbit_test (void)
 static void
 gamma_test (void)
 {
-  MATHTYPE x;
+  errno = 0;
+  FUNC(gamma) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+  feclearexcept (FE_ALL_EXCEPT);
 
   check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty));
   check_isnan_exc ("gamma (0) == NaN plus invalid exception",
                     FUNC(gamma) (0), INVALID_EXCEPTION);
 
-  x = random_less (0.0);
-  check_isnan_exc_ext ("gamma (x) == NaN plus invalid exception for x <= 0",
-                        FUNC(gamma) (x), INVALID_EXCEPTION, x);
+  check_isnan_exc_ext ("gamma (x) == NaN plus invalid exception for integer x <= 0",
+                        FUNC(gamma) (-2), INVALID_EXCEPTION, -2);
   check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
                    FUNC(gamma) (minus_infty), INVALID_EXCEPTION);
 
-  check ("gamma (0.5) == sqrt(pi)", FUNC(gamma) (0.5), FUNC(sqrt) (M_PI));
-  check ("gamma (-0.5) == -2*sqrt(pi)", FUNC(gamma) (-0.5),
-         -2*FUNC(sqrt) (M_PI));
+  check_eps ("gamma (0.5) == sqrt(pi)", FUNC(gamma) (0.5), FUNC(sqrt) (M_PI),
+	     CHOOSE (0, 5e-16, 2e-7));
+  check_eps ("gamma (-0.5) == -2*sqrt(pi)", FUNC(gamma) (-0.5),
+	     -2*FUNC(sqrt) (M_PI), CHOOSE (0, 5e-16, 3e-7));
 
   check ("gamma (1) == 1", FUNC(gamma) (1), 1);
   check ("gamma (4) == 6", FUNC(gamma) (4), 6);
@@ -1297,15 +1332,19 @@ gamma_test (void)
 static void
 lgamma_test (void)
 {
-  MATHTYPE x;
+  errno = 0;
+  FUNC(lgamma) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+  feclearexcept (FE_ALL_EXCEPT);
 
   check_isinfp ("lgamma (+inf) == +inf", FUNC(lgamma) (plus_infty));
-  check_isnan_exc ("lgamma (0) == +inf plus divide by zero exception",
-                   FUNC(lgamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
+  check_isinfp_exc ("lgamma (0) == +inf plus divide by zero exception",
+		    FUNC(lgamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
 
-  x = random_less (0.0);
-  check_isnan_exc_ext ("lgamma (x) == +inf plus divide by zero exception for x <= 0",
-                       FUNC(lgamma) (x), DIVIDE_BY_ZERO_EXCEPTION, x);
+  check_isinfp_exc ("lgamma (x) == +inf plus divide by zero exception for integer x <= 0",
+		    FUNC(lgamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
   check_isnan_exc ("lgamma (-inf) == NaN plus invalid exception",
                    FUNC(lgamma) (minus_infty), INVALID_EXCEPTION);
 
@@ -1331,23 +1370,15 @@ static void
 ilogb_test (void)
 {
 
-  /* XXX Are these tests correct? I couldn't find any specification */
-#if 0
-  /* the source suggests that the following calls should fail -
-     but shall we test these special cases or just ignore them? */
-  check_isinfp ("ilogb (+inf) == +inf", FUNC(ilogb) (plus_infty));
-  check_isinfp ("ilogb (-inf) == +inf", FUNC(ilogb) (minus_infty));
-
-  check_isinfn_exc ("ilogb (+0) == -inf plus divide-by-zero exception",
-		    FUNC(ilogb) (0), DIVIDE_BY_ZERO_EXCEPTION);
+  check_int ("ilogb (1) == 0", FUNC(ilogb) (1), 0);
+  check_int ("ilogb (e) == 1", FUNC(ilogb) (M_E), 1);
+  check_int ("ilogb (1024) == 10", FUNC(ilogb) (1024), 10);
+  check_int ("ilogb (-2000) == 10", FUNC(ilogb) (-2000), 10);
 
-  check_isinfn_exc ("ilogb (-0) == -inf plus divide-by-zero exception",
-		    FUNC(ilogb) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
-#endif
-  check ("ilogb (1) == 0", FUNC(ilogb) (1), 0);
-  check ("ilogb (e) == 1", FUNC(ilogb) (M_E), 1);
-  check ("ilogb (1024) == 10", FUNC(ilogb) (1024), 10);
-  check ("ilogb (-2000) == 10", FUNC(ilogb) (-2000), 10);
+  check_int_exc ("ilogb (0) == FP_ILOGB0", FUNC(ilogb) (0.0), FP_ILOGB0,
+		 DIVIDE_BY_ZERO_EXCEPTION|INVALID_EXCEPTION);
+  check_int_exc ("ilogb (NaN) == FP_ILOGBNAN", FUNC(ilogb) (nan_value),
+		 FP_ILOGBNAN, INVALID_EXCEPTION);
 
 }
 
@@ -1526,17 +1557,72 @@ scalb_test (void)
 {
   MATHTYPE x;
 
-  check ("scalb (0, 0) == 0", FUNC(scalb) (0, 0), 0);
+  check_isnan ("scalb (2, 0.5) == NaN", FUNC(scalb) (2, 0.5));
+  check_isnan ("scalb (3, -2.5) == NaN", FUNC(scalb) (3, -2.5));
+
+  check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
+  check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
+
+  x = random_greater (0.0);
+  check ("scalb (x, 0) == 0", FUNC(scalb) (x, 0), x);
+  x = random_greater (0.0);
+  check ("scalb (-x, 0) == 0", FUNC(scalb) (-x, 0), -x);
+
+  check_isnan_exc ("scalb (+0, +inf) == NaN plus invalid exception",
+		   FUNC(scalb) (0, plus_infty), INVALID_EXCEPTION);
+  check_isnan_exc ("scalb (-0, +inf) == NaN plus invalid exception",
+		   FUNC(scalb) (minus_zero, plus_infty), INVALID_EXCEPTION);
+
+  check ("scalb (+0, 2) == +0", FUNC(scalb) (0, 2), 0);
+  check ("scalb (-0, 4) == -0", FUNC(scalb) (minus_zero, -4), minus_zero);
+  check ("scalb (+0, 0) == +0", FUNC(scalb) (0, 0), 0);
+  check ("scalb (-0, 0) == -0", FUNC(scalb) (minus_zero, 0), minus_zero);
+  check ("scalb (+0, -1) == +0", FUNC(scalb) (0, -1), 0);
+  check ("scalb (-0, -10) == -0", FUNC(scalb) (minus_zero, -10), minus_zero);
+  check ("scalb (+0, -inf) == +0", FUNC(scalb) (0, minus_infty), 0);
+  check ("scalb (-0, -inf) == -0", FUNC(scalb) (minus_zero, minus_infty),
+	 minus_zero);
+
+  check_isinfp ("scalb (+inf, -1) == +inf", FUNC(scalb) (plus_infty, -1));
+  check_isinfn ("scalb (-inf, -10) == -inf", FUNC(scalb) (minus_infty, -10));
+  check_isinfp ("scalb (+inf, 0) == +inf", FUNC(scalb) (plus_infty, 0));
+  check_isinfn ("scalb (-inf, 0) == -inf", FUNC(scalb) (minus_infty, 0));
+  check_isinfp ("scalb (+inf, 2) == +inf", FUNC(scalb) (plus_infty, 2));
+  check_isinfn ("scalb (-inf, 100) == -inf", FUNC(scalb) (minus_infty, 100));
+
+  check ("scalb (0, -inf) == 0", FUNC(scalb) (0.0, minus_infty), 0.0);
+  check ("scalb (-0, -inf) == -0", FUNC(scalb) (minus_zero, minus_infty),
+	 minus_zero);
+  x = random_greater (0.0);
+  check ("scalb (x, -inf) == 0", FUNC(scalb) (x, minus_infty), 0.0);
+  check ("scalb (-x, -inf) == -0", FUNC(scalb) (-x, minus_infty), minus_zero);
+
+  x = random_greater (0.0);
+  check_isinfp ("scalb (x, +inf) == +inf", FUNC(scalb) (x, plus_infty));
+  x = random_greater (0.0);
+  check_isinfn ("scalb (-x, +inf) == -inf", FUNC(scalb) (-x, plus_infty));
+  check_isinfp ("scalb (+inf, +inf) == +inf",
+		FUNC(scalb) (plus_infty, plus_infty));
+  check_isinfn ("scalb (-inf, +inf) == -inf",
+		FUNC(scalb) (minus_infty, plus_infty));
+
+  check_isnan ("scalb (+inf, -inf) == NaN",
+	       FUNC(scalb) (plus_infty, minus_infty));
+  check_isnan ("scalb (-inf, -inf) == NaN",
+	       FUNC(scalb) (minus_infty, minus_infty));
 
-  check_isinfp ("scalb (+inf, 1) == +inf", FUNC(scalb) (plus_infty, 1));
-  check_isinfn ("scalb (-inf, 1) == -inf", FUNC(scalb) (minus_infty, 1));
   check_isnan ("scalb (NaN, 1) == NaN", FUNC(scalb) (nan_value, 1));
+  check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
+  check_isnan ("scalb (NaN, 0) == NaN", FUNC(scalb) (nan_value, 0));
+  check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
+  check_isnan ("scalb (NaN, +inf) == NaN",
+	       FUNC(scalb) (nan_value, plus_infty));
+  check_isnan ("scalb (+inf, NaN) == NaN",
+	       FUNC(scalb) (plus_infty, nan_value));
+  check_isnan ("scalb (NaN, NaN) == NaN", FUNC(scalb) (nan_value, nan_value));
 
   check ("scalb (0.8, 4) == 12.8", FUNC(scalb) (0.8L, 4), 12.8L);
   check ("scalb (-0.854375, 5) == -27.34", FUNC(scalb) (-0.854375L, 5), -27.34L);
-
-  x = random_greater (0.0);
-  check_ext ("scalb (x, 0) == x", FUNC(scalb) (x, 0L), x, x);
 }
 
 
@@ -1630,14 +1716,15 @@ sincos_test (void)
   check ("sincos (pi/2, &sin, &cos) puts 1 in sin", sin_res, 1);
   fesetenv (&fenv);
   check_eps ("sincos (pi/2, &sin, &cos) puts 0 in cos", cos_res, 0,
-             CHOOSE(0, 1e-16, 1e-7));
+	     CHOOSE (1e-18L, 1e-16, 1e-7));
 
   FUNC(sincos) (M_PI / 6.0, &sin_res, &cos_res);
-  check ("sincos (pi/6, &sin, &cos) puts 0.5 in sin", sin_res, 0.5);
+  check_eps ("sincos (pi/6, &sin, &cos) puts 0.5 in sin", sin_res, 0.5,
+	     CHOOSE (5e-18L, 0, 0));
 
   FUNC(sincos) (M_PI / 3.0, &sin_res, &cos_res);
   check_eps ("sincos (pi/3, &sin, &cos) puts 0.5 in cos", cos_res, 0.5,
-             CHOOSE(0, 1e-15, 1e-7));
+	     CHOOSE (5e-18L, 1e-15, 1e-7));
 
 
 }
@@ -2045,13 +2132,13 @@ fmod_test (void)
              FUNC(fmod) (x, minus_infty), x, x);
 
   check_eps ("fmod (6.5, 2.3) == 1.9", FUNC(fmod) (6.5, 2.3), 1.9,
-             CHOOSE(0, 1e-15, 0));
+             CHOOSE(5e-16, 1e-15, 2e-7));
   check_eps ("fmod (-6.5, 2.3) == -1.9", FUNC(fmod) (-6.5, 2.3), -1.9,
-             CHOOSE(0, 1e-15, 0));
+             CHOOSE(5e-16, 1e-15, 2e-7));
   check_eps ("fmod (6.5, -2.3) == 1.9", FUNC(fmod) (6.5, -2.3), 1.9,
-             CHOOSE(0, 1e-15, 0));
+             CHOOSE(5e-16, 1e-15, 2e-7));
   check_eps ("fmod (-6.5, -2.3) == -1.9", FUNC(fmod) (-6.5, -2.3), -1.9,
-             CHOOSE(0, 1e-15, 0));
+             CHOOSE(5e-16, 1e-15, 2e-7));
 
 
 }
@@ -4355,44 +4442,44 @@ rint_test (void)
 
 
 static void
-rinttol_test (void)
+lrint_test (void)
 {
   /* XXX this test is incomplete.  We need to have a way to specifiy
      the rounding method and test the critical cases.  So far, only
      unproblematic numbers are tested.  */
 
-  check_long ("rinttol(0) = 0", rinttol (0.0), 0);
-  check_long ("rinttol(-0) = 0", rinttol (minus_zero), 0);
-  check_long ("rinttol(0.2) = 0", rinttol (0.2), 0);
-  check_long ("rinttol(-0.2) = 0", rinttol (-0.2), 0);
+  check_long ("lrint(0) = 0", lrint (0.0), 0);
+  check_long ("lrint(-0) = 0", lrint (minus_zero), 0);
+  check_long ("lrint(0.2) = 0", lrint (0.2), 0);
+  check_long ("lrint(-0.2) = 0", lrint (-0.2), 0);
 
-  check_long ("rinttol(1.4) = 1", rinttol (1.4), 1);
-  check_long ("rinttol(-1.4) = -1", rinttol (-1.4), -1);
+  check_long ("lrint(1.4) = 1", lrint (1.4), 1);
+  check_long ("lrint(-1.4) = -1", lrint (-1.4), -1);
 
-  check_long ("rinttol(8388600.3) = 8388600", rinttol (8388600.3), 8388600);
-  check_long ("rinttol(-8388600.3) = -8388600", rinttol (-8388600.3),
+  check_long ("lrint(8388600.3) = 8388600", lrint (8388600.3), 8388600);
+  check_long ("lrint(-8388600.3) = -8388600", lrint (-8388600.3),
 	      -8388600);
 }
 
 
 static void
-rinttoll_test (void)
+llrint_test (void)
 {
   /* XXX this test is incomplete.  We need to have a way to specifiy
      the rounding method and test the critical cases.  So far, only
      unproblematic numbers are tested.  */
 
-  check_longlong ("rinttoll(0) = 0", rinttoll (0.0), 0);
-  check_longlong ("rinttoll(-0) = 0", rinttoll (minus_zero), 0);
-  check_longlong ("rinttoll(0.2) = 0", rinttoll (0.2), 0);
-  check_longlong ("rinttoll(-0.2) = 0", rinttoll (-0.2), 0);
+  check_longlong ("llrint(0) = 0", llrint (0.0), 0);
+  check_longlong ("llrint(-0) = 0", llrint (minus_zero), 0);
+  check_longlong ("llrint(0.2) = 0", llrint (0.2), 0);
+  check_longlong ("llrint(-0.2) = 0", llrint (-0.2), 0);
 
-  check_longlong ("rinttoll(1.4) = 1", rinttoll (1.4), 1);
-  check_longlong ("rinttoll(-1.4) = -1", rinttoll (-1.4), -1);
+  check_longlong ("llrint(1.4) = 1", llrint (1.4), 1);
+  check_longlong ("llrint(-1.4) = -1", llrint (-1.4), -1);
 
-  check_longlong ("rinttoll(8388600.3) = 8388600", rinttoll (8388600.3),
+  check_longlong ("llrint(8388600.3) = 8388600", llrint (8388600.3),
 		  8388600);
-  check_longlong ("rinttoll(-8388600.3) = -8388600", rinttoll (-8388600.3),
+  check_longlong ("llrint(-8388600.3) = -8388600", llrint (-8388600.3),
 		  -8388600);
 }
 
@@ -4416,45 +4503,45 @@ round_test (void)
 
 
 static void
-roundtol_test (void)
+lround_test (void)
 {
-  check_long ("roundtol(0) = 0", roundtol (0), 0);
-  check_long ("roundtol(-0) = 0", roundtol (minus_zero), 0);
-  check_long ("roundtol(0.2) = 0", roundtol (0.2), 0.0);
-  check_long ("roundtol(-0.2) = 0", roundtol (-0.2), 0);
-  check_long ("roundtol(0.5) = 1", roundtol (0.5), 1);
-  check_long ("roundtol(-0.5) = -1", roundtol (-0.5), -1);
-  check_long ("roundtol(0.8) = 1", roundtol (0.8), 1);
-  check_long ("roundtol(-0.8) = -1", roundtol (-0.8), -1);
-  check_long ("roundtol(1.5) = 2", roundtol (1.5), 2);
-  check_long ("roundtol(-1.5) = -2", roundtol (-1.5), -2);
-  check_long ("roundtol(2097152.5) = 2097153", roundtol (2097152.5), 2097153);
-  check_long ("roundtol(-2097152.5) = -2097153", roundtol (-2097152.5),
+  check_long ("lround(0) = 0", lround (0), 0);
+  check_long ("lround(-0) = 0", lround (minus_zero), 0);
+  check_long ("lround(0.2) = 0", lround (0.2), 0.0);
+  check_long ("lround(-0.2) = 0", lround (-0.2), 0);
+  check_long ("lround(0.5) = 1", lround (0.5), 1);
+  check_long ("lround(-0.5) = -1", lround (-0.5), -1);
+  check_long ("lround(0.8) = 1", lround (0.8), 1);
+  check_long ("lround(-0.8) = -1", lround (-0.8), -1);
+  check_long ("lround(1.5) = 2", lround (1.5), 2);
+  check_long ("lround(-1.5) = -2", lround (-1.5), -2);
+  check_long ("lround(2097152.5) = 2097153", lround (2097152.5), 2097153);
+  check_long ("lround(-2097152.5) = -2097153", lround (-2097152.5),
 	      -2097153);
 }
 
 
 static void
-roundtoll_test (void)
+llround_test (void)
 {
-  check_longlong ("roundtoll(0) = 0", roundtoll (0), 0);
-  check_longlong ("roundtoll(-0) = 0", roundtoll (minus_zero), 0);
-  check_longlong ("roundtoll(0.2) = 0", roundtoll (0.2), 0.0);
-  check_longlong ("roundtoll(-0.2) = 0", roundtoll (-0.2), 0);
-  check_longlong ("roundtoll(0.5) = 1", roundtoll (0.5), 1);
-  check_longlong ("roundtoll(-0.5) = -1", roundtoll (-0.5), -1);
-  check_longlong ("roundtoll(0.8) = 1", roundtoll (0.8), 1);
-  check_longlong ("roundtoll(-0.8) = -1", roundtoll (-0.8), -1);
-  check_longlong ("roundtoll(1.5) = 2", roundtoll (1.5), 2);
-  check_longlong ("roundtoll(-1.5) = -2", roundtoll (-1.5), -2);
-  check_longlong ("roundtoll(2097152.5) = 2097153",
-		  roundtoll (2097152.5), 2097153);
-  check_longlong ("roundtoll(-2097152.5) = -2097153",
-		  roundtoll (-2097152.5), -2097153);
-  check_longlong ("roundtoll(34359738368.5) = 34359738369",
-		  roundtoll (34359738368.5), 34359738369ll);
-  check_longlong ("roundtoll(-34359738368.5) = -34359738369",
-		  roundtoll (-34359738368.5), -34359738369ll);
+  check_longlong ("llround(0) = 0", llround (0), 0);
+  check_longlong ("llround(-0) = 0", llround (minus_zero), 0);
+  check_longlong ("llround(0.2) = 0", llround (0.2), 0.0);
+  check_longlong ("llround(-0.2) = 0", llround (-0.2), 0);
+  check_longlong ("llround(0.5) = 1", llround (0.5), 1);
+  check_longlong ("llround(-0.5) = -1", llround (-0.5), -1);
+  check_longlong ("llround(0.8) = 1", llround (0.8), 1);
+  check_longlong ("llround(-0.8) = -1", llround (-0.8), -1);
+  check_longlong ("llround(1.5) = 2", llround (1.5), 2);
+  check_longlong ("llround(-1.5) = -2", llround (-1.5), -2);
+  check_longlong ("llround(2097152.5) = 2097153",
+		  llround (2097152.5), 2097153);
+  check_longlong ("llround(-2097152.5) = -2097153",
+		  llround (-2097152.5), -2097153);
+  check_longlong ("llround(34359738368.5) = 34359738369",
+		  llround (34359738368.5), 34359738369ll);
+  check_longlong ("llround(-34359738368.5) = -34359738369",
+		  llround (-34359738368.5), -34359738369ll);
 }
 
 
@@ -4811,11 +4898,11 @@ main (int argc, char *argv[])
   floor_test ();
   nearbyint_test ();
   rint_test ();
-  rinttol_test ();
-  rinttoll_test ();
+  lrint_test ();
+  llrint_test ();
   round_test ();
-  roundtol_test ();
-  roundtoll_test ();
+  lround_test ();
+  llround_test ();
   trunc_test ();
 
   /* remainder functions */
diff --git a/math/math.h b/math/math.h
index 5229a020e0..aa37f71f3c 100644
--- a/math/math.h
+++ b/math/math.h
@@ -186,13 +186,13 @@ enum
 
 /* Round X to nearest integral value according to current rounding
    direction.  */
-extern long int rinttol __P ((long double __x));
-extern long long int rinttoll __P ((long double __x));
+extern long int lrint __P ((long double __x));
+extern long long int llrint __P ((long double __x));
 
 /* Round X to nearest integral value, rounding halfway cases away from
    zero.  */
-extern long int roundtol __P ((long double __x));
-extern long long int roundtoll __P ((long double __x));
+extern long int lround __P ((long double __x));
+extern long long int llround __P ((long double __x));
 
 
 /* Comparison macros.  */
diff --git a/math/mathcalls.h b/math/mathcalls.h
index 0aac420bd0..735b5953a7 100644
--- a/math/mathcalls.h
+++ b/math/mathcalls.h
@@ -138,9 +138,7 @@ __MATHCALL (sqrt,, (_Mdouble_ __x));
 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X
 /* Return `sqrt(X*X + Y*Y)'.  */
 __MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
-#endif
 
-#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Return the cube root of X.  */
 __MATHCALL (cbrt,, (_Mdouble_ __x));
 #endif
@@ -177,9 +175,6 @@ __MATHDECLX (int,finite,, (_Mdouble_ __value), (__const__));
    and may return an infinity or NaN, or may do something else.  */
 __MATHCALLX (infnan,, (int __error), (__const__));
 
-/* Return X times (2 to the Nth power).  */
-__MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
-
 /* Return the remainder of X/Y.  */
 __MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
 
@@ -203,9 +198,6 @@ __MATHCALLX (nan,, (__const char *__tagb), (__const__));
 /* Return nonzero if VALUE is not a number.  */
 __MATHDECLX (int,isnan,, (_Mdouble_ __value), (__const__));
 
-/* Return the binary exponent of X, which must be nonzero.  */
-__MATHDECL (int,ilogb,, (_Mdouble_ __x));
-
 /* Bessel functions.  */
 __MATHCALL (j0,, (_Mdouble_));
 __MATHCALL (j1,, (_Mdouble_));
@@ -222,6 +214,7 @@ __MATHCALL (erf,, (_Mdouble_));
 __MATHCALL (erfc,, (_Mdouble_));
 __MATHCALL (gamma,, (_Mdouble_));
 __MATHCALL (lgamma,, (_Mdouble_));
+#endif
 
 #ifdef __USE_MISC
 /* Reentrant versions of gamma and lgamma.  Those functions use the global
@@ -231,8 +224,6 @@ __MATHCALL (gamma,_r, (_Mdouble_, int *));
 __MATHCALL (lgamma,_r, (_Mdouble_, int *));
 #endif
 
-#endif /* Use misc or X/Open.  */
-
 
 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X
 /* Return the integer nearest X in the direction of the
@@ -244,11 +235,15 @@ __MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
 
 /* Return the remainder of integer divison X / Y with infinite precision.  */
 __MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
-#endif
 
-#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
 /* Return X times (2 to the Nth power).  */
 __MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
+
+/* Return X times (2 to the Nth power).  */
+__MATHCALL (scalbn,, (_Mdouble_ __x, long int __n));
+
+/* Return the binary exponent of X, which must be nonzero.  */
+__MATHDECL (int,ilogb,, (_Mdouble_ __x));
 #endif
 
 #ifdef __USE_ISOC9X