aboutsummaryrefslogtreecommitdiff
path: root/math
diff options
context:
space:
mode:
Diffstat (limited to 'math')
-rw-r--r--math/Makefile4
-rw-r--r--math/libm-test.inc23
-rw-r--r--math/w_ilogb.c42
-rw-r--r--math/w_ilogbf.c38
-rw-r--r--math/w_ilogbl.c37
5 files changed, 136 insertions, 8 deletions
diff --git a/math/Makefile b/math/Makefile
index 3a671aa..abeba7a 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -42,14 +42,16 @@ libm-support = k_standard s_lib_version s_matherr s_signgam \
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 e_gamma_r \
+ e_ilogb \
k_cos k_rem_pio2 k_sin k_tan s_asinh s_atan s_cbrt \
s_ceil s_cos s_erf s_expm1 s_fabs \
- s_floor s_ilogb s_log1p s_logb \
+ s_floor s_log1p s_logb \
s_nextafter s_nexttoward s_rint s_scalbln \
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_exp2 w_exp10 w_fmod \
w_tgamma 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 \
+ w_ilogb \
s_fpclassify s_fmax s_fmin s_fdim s_nan s_trunc \
s_remquo e_log2 e_exp2 s_round s_nearbyint s_sincos \
conj cimag creal cabs carg s_cexp s_csinh s_ccosh s_clog \
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 2809d57..94d60bf 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -3802,13 +3802,22 @@ ilogb_test (void)
TEST_f_i (ilogb, 1024, 10);
TEST_f_i (ilogb, -2000, 10);
- /* XXX We have a problem here: the standard does not tell us whether
- exceptions are allowed/required. ignore them for now. */
-
- TEST_f_i (ilogb, 0.0, FP_ILOGB0, EXCEPTIONS_OK);
- TEST_f_i (ilogb, nan_value, FP_ILOGBNAN, EXCEPTIONS_OK);
- TEST_f_i (ilogb, plus_infty, INT_MAX, EXCEPTIONS_OK);
- TEST_f_i (ilogb, minus_infty, INT_MAX, EXCEPTIONS_OK);
+ /* ilogb (0.0) == FP_ILOGB0 plus invalid exception */
+ errno = 0;
+ TEST_f_i (ilogb, 0.0, FP_ILOGB0, INVALID_EXCEPTION);
+ check_int ("errno for ilogb(0.0) unchanged", errno, EDOM, 0, 0, 0);
+ /* ilogb (NaN) == FP_ILOGBNAN plus invalid exception */
+ errno = 0;
+ TEST_f_i (ilogb, nan_value, FP_ILOGBNAN, INVALID_EXCEPTION);
+ check_int ("errno for ilogb(NaN) unchanged", errno, EDOM, 0, 0, 0);
+ /* ilogb (inf) == INT_MAX plus invalid exception */
+ errno = 0;
+ TEST_f_i (ilogb, plus_infty, INT_MAX, INVALID_EXCEPTION);
+ check_int ("errno for ilogb(Inf) unchanged", errno, EDOM, 0, 0, 0);
+ /* ilogb (-inf) == INT_MAX plus invalid exception */
+ errno = 0;
+ TEST_f_i (ilogb, minus_infty, INT_MAX, INVALID_EXCEPTION);
+ check_int ("errno for ilogb(-Inf) unchanged", errno, EDOM, 0, 0, 0);
END (ilogb);
}
diff --git a/math/w_ilogb.c b/math/w_ilogb.c
new file mode 100644
index 0000000..c87b517
--- /dev/null
+++ b/math/w_ilogb.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Adhemerval Zanella <azanella@linux.vnet.ibm.com>, 2011.
+
+ 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 <errno.h>
+#include <math_private.h>
+
+/* wrapper ilogb */
+int
+__ilogb (double x)
+{
+ int r = __ieee754_ilogb (x);
+ if (__builtin_expect (r == FP_ILOGB0, 0)
+ || __builtin_expect (r == FP_ILOGBNAN, 0)
+ || __builtin_expect (r == INT_MAX, 0))
+ {
+ __set_errno (EDOM);
+ feraiseexcept (FE_INVALID);
+ }
+ return r;
+}
+
+weak_alias (__ilogb, ilogb)
+#ifdef NO_LONG_DOUBLE
+strong_alias (__ilogb, __ilogbl)
+weak_alias (__ilogb, ilogbl)
+#endif
diff --git a/math/w_ilogbf.c b/math/w_ilogbf.c
new file mode 100644
index 0000000..ae3574a
--- /dev/null
+++ b/math/w_ilogbf.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Adhemerval Zanella <azanella@linux.vnet.ibm.com>, 2011.
+
+ 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 <errno.h>
+#include <math_private.h>
+
+/* wrapper ilogbf */
+int
+__ilogbf (float x)
+{
+ int r = __ieee754_ilogbf (x);
+ if (__builtin_expect (r == FP_ILOGB0, 0)
+ || __builtin_expect (r == FP_ILOGBNAN, 0)
+ || __builtin_expect (r == INT_MAX, 0))
+ {
+ __set_errno (EDOM);
+ feraiseexcept (FE_INVALID);
+ }
+ return r;
+}
+
+weak_alias (__ilogbf, ilogbf)
diff --git a/math/w_ilogbl.c b/math/w_ilogbl.c
new file mode 100644
index 0000000..8c30caa
--- /dev/null
+++ b/math/w_ilogbl.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Adhemerval Zanella <azanella@linux.vnet.ibm.com>, 2011.
+
+ 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 <errno.h>
+#include <math_private.h>
+
+/* wrapper ilogbl */
+int
+__ilogbl (long double x)
+{
+ int r = __ieee754_ilogbl (x);
+ if (__builtin_expect (r == FP_ILOGB0, 0)
+ || __builtin_expect (r == FP_ILOGBNAN, 0)
+ || __builtin_expect (r == INT_MAX, 0))
+ {
+ __set_errno (EDOM);
+ feraiseexcept (FE_INVALID);
+ }
+ return r;
+}
+weak_alias (__ilogbl, ilogbl)