Переглянути джерело

libm/e_scalb.c: remove unused #ifdef _SCALB_INT branches
libm/s_ldexp.c: add TODO

Denis Vlasenko 15 роки тому
батько
коміт
eb51bac1b3
3 змінених файлів з 19 додано та 20 видалено
  1. 0 13
      libm/e_scalb.c
  2. 0 4
      libm/math_private.h
  3. 19 3
      libm/s_ldexp.c

+ 0 - 13
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

+ 0 - 4
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

+ 19 - 3
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)