summaryrefslogtreecommitdiff
path: root/libm
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-01-03 14:42:54 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-01-03 14:42:54 +0000
commiteb51bac1b3f43c4fcccdf8206afb8a070fecaa07 (patch)
tree5253e96ffffa5ee3d72ccbd92f47fbf7d16d2264 /libm
parent33836c9854b39638a8460bdf5e7d761bb5d1e6ae (diff)
libm/e_scalb.c: remove unused #ifdef _SCALB_INT branches
libm/s_ldexp.c: add TODO
Diffstat (limited to 'libm')
-rw-r--r--libm/e_scalb.c13
-rw-r--r--libm/math_private.h4
-rw-r--r--libm/s_ldexp.c22
3 files changed, 19 insertions, 20 deletions
diff --git a/libm/e_scalb.c b/libm/e_scalb.c
index ff0c77523..7e6768810 100644
--- a/libm/e_scalb.c
+++ b/libm/e_scalb.c
@@ -19,16 +19,9 @@
#include "math_private.h"
#include <errno.h>
-#ifdef _SCALB_INT
-double attribute_hidden __ieee754_scalb(double x, int fn)
-#else
double attribute_hidden __ieee754_scalb(double x, double fn)
-#endif
{
-#ifdef _SCALB_INT
return scalbn(x,fn);
-//TODO: just alias it to scalbn?
-#else
if (isnan(x)||isnan(fn)) return x*fn;
if (!isfinite(fn)) {
if(fn>0.0) return x*fn;
@@ -48,11 +41,7 @@ double attribute_hidden __ieee754_scalb(double x, double fn)
* should use scalbn() instead.
*/
#ifndef _IEEE_LIBM
-# ifdef _SCALB_INT
-double scalb(double x, int fn)
-# else
double scalb(double x, double fn)
-# endif
{
double z = __ieee754_scalb(x, fn);
if (_LIB_VERSION == _IEEE_)
@@ -61,10 +50,8 @@ double scalb(double x, double fn)
return __kernel_standard(x, (double)fn, 32); /* scalb overflow */
if (z == 0.0 && z != x)
return __kernel_standard(x, (double)fn, 33); /* scalb underflow */
-# ifndef _SCALB_INT
if (!isfinite(fn))
errno = ERANGE;
-# endif
return z;
}
#else
diff --git a/libm/math_private.h b/libm/math_private.h
index 80c270718..bdd0aba48 100644
--- a/libm/math_private.h
+++ b/libm/math_private.h
@@ -176,11 +176,7 @@ extern double __ieee754_jn (int,double) attribute_hidden;
extern double __ieee754_yn (int,double) attribute_hidden;
extern double __ieee754_remainder (double,double) attribute_hidden;
extern int __ieee754_rem_pio2 (double,double*) attribute_hidden;
-#if defined(_SCALB_INT)
-extern double __ieee754_scalb (double,int) attribute_hidden;
-#else
extern double __ieee754_scalb (double,double) attribute_hidden;
-#endif
/* fdlibm kernel function */
#ifndef _IEEE_LIBM
diff --git a/libm/s_ldexp.c b/libm/s_ldexp.c
index 1b681cb81..b2809afc8 100644
--- a/libm/s_ldexp.c
+++ b/libm/s_ldexp.c
@@ -13,11 +13,27 @@
#include "math_private.h"
#include <errno.h>
+/* TODO: POSIX says:
+ *
+ * "If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
+ * then errno shall be set to [ERANGE]. If the integer expression
+ * (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow
+ * floating-point exception shall be raised."
+ *
+ * *And it says the same about scalbn*! Thus these two functions
+ * are the same and can be just aliased.
+ *
+ * Currently, ldexp tries to be vaguely POSIX compliant while scalbn
+ * does not (it does not set ERRNO).
+ */
+
double ldexp(double value, int exp)
{
- if(!isfinite(value)||value==0.0) return value;
- value = scalbn(value,exp);
- if(!isfinite(value)||value==0.0) errno = ERANGE;
+ if (!isfinite(value) || value == 0.0)
+ return value;
+ value = scalbn(value, exp);
+ if (!isfinite(value) || value == 0.0)
+ errno = ERANGE;
return value;
}
libm_hidden_def(ldexp)