Browse Source

add exp10() from glibc

Some software make use of exp10, so add it.
Basic testing with LTP.

Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
Waldemar Brodkorb 8 years ago
parent
commit
12a85731dc
4 changed files with 39 additions and 5 deletions
  1. 3 3
      libc/sysdeps/linux/common/bits/mathcalls.h
  2. 2 2
      libm/Makefile.in
  3. 33 0
      libm/e_exp10.c
  4. 1 0
      libm/math_private.h

+ 3 - 3
libc/sysdeps/linux/common/bits/mathcalls.h

@@ -145,11 +145,11 @@ __MATHCALLI (log10,, (_Mdouble_ __x))
 __MATHCALLI (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr))
 _Mdouble_END_NAMESPACE
 
-#if 0 /*def __USE_GNU*/
+#if defined __USE_GNU
 /* A function missing in all standards: compute exponent to base ten.  */
-__MATHCALL (exp10,, (_Mdouble_ __x))
+__MATHCALLI (exp10,, (_Mdouble_ __x))
 /* Another name occasionally used.  */
-__MATHCALL (pow10,, (_Mdouble_ __x))
+__MATHCALLI (pow10,, (_Mdouble_ __x))
 #endif
 
 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99

+ 2 - 2
libm/Makefile.in

@@ -56,7 +56,7 @@ LD_MSRC := ldouble_wrappers.c
 ifeq ($(DO_C99_MATH),y)
 libm_CSRC := \
 	e_acos.c e_acosh.c e_asin.c e_atan2.c e_atanh.c e_cosh.c \
-	e_exp.c e_fmod.c e_hypot.c \
+	e_exp.c e_exp10.c e_fmod.c e_hypot.c \
 	e_lgamma_r.c e_log.c e_log2.c e_log10.c \
 	e_pow.c e_remainder.c e_rem_pio2.c e_scalb.c e_sinh.c \
 	e_sqrt.c k_cos.c k_rem_pio2.c k_sin.c k_standard.c k_tan.c \
@@ -238,7 +238,7 @@ libm_CSRC := \
 	s_expm1.c s_scalbn.c s_copysign.c e_acos.c e_asin.c e_atan2.c \
 	k_cos.c e_cosh.c e_exp.c e_fmod.c e_log.c e_log10.c e_pow.c \
 	k_sin.c e_sinh.c e_sqrt.c k_tan.c e_rem_pio2.c k_rem_pio2.c \
-	s_finite.c
+	s_finite.c e_exp10.c
 # We'll add sqrtf to avoid problems with libstdc++
 FL_MOBJ := sqrtf.o
 endif

+ 33 - 0
libm/e_exp10.c

@@ -0,0 +1,33 @@
+/* Copyright (C) 1998-2015 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   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 "math_private.h"
+#include <float.h>
+
+double __ieee754_exp10 (double arg)
+{
+  if (isfinite (arg) && arg < DBL_MIN_10_EXP - DBL_DIG - 10)
+    return DBL_MIN * DBL_MIN;
+  else
+    /* This is a very stupid and inprecise implementation.  It'll get
+       replaced sometime (soon?).  */
+    return __ieee754_exp (M_LN10 * arg);
+}
+strong_alias(__ieee754_exp10, exp10)
+libm_hidden_def(exp10)

+ 1 - 0
libm/math_private.h

@@ -158,6 +158,7 @@ extern double __ieee754_atanh (double) attribute_hidden;
 extern double __ieee754_asin (double) attribute_hidden;
 extern double __ieee754_atan2 (double,double) attribute_hidden;
 extern double __ieee754_exp (double) attribute_hidden;
+extern double __ieee754_exp10 (double) attribute_hidden;
 extern double __ieee754_cosh (double) attribute_hidden;
 extern double __ieee754_fmod (double,double) attribute_hidden;
 extern double __ieee754_pow (double,double) attribute_hidden;