summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/math.h56
-rw-r--r--libc/sysdeps/linux/common/bits/mathcalls.h7
-rw-r--r--libm/Makefile.in4
-rw-r--r--libm/ldouble_wrappers.c31
-rw-r--r--test/math/Makefile4
-rw-r--r--test/math/compile_test.c71
-rw-r--r--test/math/libm-test.inc4
7 files changed, 146 insertions, 31 deletions
diff --git a/include/math.h b/include/math.h
index 9f57e44d1..0060d7759 100644
--- a/include/math.h
+++ b/include/math.h
@@ -52,38 +52,46 @@ __BEGIN_DECLS
so we can easily declare each function as both `name' and `__name',
and can declare the float versions `namef' and `__namef'. */
-#define __MATHCALL(function,suffix, args) \
- __MATHDECL (_Mdouble_,function,suffix, args)
-#define __MATHDECL(type, function,suffix, args) \
- __MATHDECL_1(type, function,suffix, args);
-
-#define __MATHCALLX(function,suffix, args, attrib) \
- __MATHDECLX (_Mdouble_,function,suffix, args, attrib)
-#define __MATHDECL_1(type, function,suffix, args) \
+#define __MATHDECL_1(type,function,suffix,args) \
extern type __MATH_PRECNAME(function,suffix) args __THROW
-#define __MATHDECLX(type, function,suffix, args, attrib) \
- __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
+
+#define __MATHDECL(type,function,suffix,args) \
+ __MATHDECL_1(type,function,suffix,args);
+
+#define __MATHCALL(function,suffix,args) \
+ __MATHDECL(_Mdouble_,function,suffix,args)
+
+#define __MATHDECLX(type,function,suffix,args,attrib) \
+ __MATHDECL_1(type,function,suffix,args) __attribute__ (attrib); \
__MATHDECLI_MAINVARIANT(function)
+#define __MATHCALLX(function,suffix,args,attrib) \
+ __MATHDECLX(_Mdouble_,function,suffix,args,attrib)
+
/* Decls which are also used internally in libm.
Only the main variant is used internally, no need to try to avoid relocs
for the {l,f} variants. */
-#define __MATHCALLI(function,suffix, args) \
- __MATHDECLI (_Mdouble_,function,suffix, args)
-#define __MATHDECLI(type, function,suffix, args) \
- __MATHDECL_1(type, function,suffix, args); \
+#define __MATHDECLI(type,function,suffix,args) \
+ __MATHDECL_1(type,function,suffix,args); \
__MATHDECLI_MAINVARIANT(function)
+
+#define __MATHCALLI(function,suffix,args) \
+ __MATHDECLI(_Mdouble_,function,suffix,args)
+
/* Private helpers for purely macro impls below.
Only make __foo{,f,l} visible but not (the macro-only) foo. */
#if defined _LIBC
-# define __MATHDECL_PRIV(type, function,suffix, args, attrib) \
- __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib); \
+# define __MATHDECL_PRIV(type,function,suffix,args,attrib) \
+ __MATHDECL_1(type,__CONCAT(__,function),suffix,args) __attribute__ (attrib); \
libm_hidden_proto(__MATH_PRECNAME(__##function,suffix))
#else
-# define __MATHDECL_PRIV(type, function,suffix, args, attrib) \
- __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib);
+# define __MATHDECL_PRIV(type,function,suffix,args,attrib) \
+ __MATHDECL_1(type,__CONCAT(__,function),suffix,args) __attribute__ (attrib);
#endif
+
+/* Include the file of declarations, declaring souble versions */
+
#if defined _LIBC
# define __MATHDECLI_MAINVARIANT(x) libm_hidden_proto(x)
#else
@@ -124,7 +132,8 @@ __BEGIN_DECLS
# undef _Mdouble_END_NAMESPACE
# undef __MATH_PRECNAME
-# if (__STDC__ - 0 || __GNUC__ - 0) \
+
+# if (defined __STDC__ || defined __GNUC__) \
&& (defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ || defined __LDBL_COMPAT)
# ifdef __LDBL_COMPAT
@@ -147,11 +156,10 @@ extern long double __REDIRECT_NTH (nexttowardl,
instead of `double' and appending l to each function name. */
# undef __MATHDECL_1
-# define __MATHDECL_2(type, function,suffix, args, alias) \
- extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \
- args, alias)
-# define __MATHDECL_1(type, function,suffix, args) \
- __MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix))
+# define __MATHDECL_2(type,function,suffix,args,alias) \
+ extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix),args,alias)
+# define __MATHDECL_1(type,function,suffix,args) \
+ __MATHDECL_2(type,function,suffix,args,__CONCAT(function,suffix))
# endif
# ifndef _Mlong_double_
diff --git a/libc/sysdeps/linux/common/bits/mathcalls.h b/libc/sysdeps/linux/common/bits/mathcalls.h
index 1f2894fa5..c2e062714 100644
--- a/libc/sysdeps/linux/common/bits/mathcalls.h
+++ b/libc/sysdeps/linux/common/bits/mathcalls.h
@@ -48,6 +48,13 @@
#endif
+/* __MATHCALLX includes libm_hidden_def
+ * __MATHCALLI includes libm_hidden_def too
+ * __MATHCALL does not
+ * __MATHDECL_PRIV includes libm_hidden_def and declared only __foo, not foo
+ */
+
+
/* Trigonometric functions. */
_Mdouble_BEGIN_NAMESPACE
diff --git a/libm/Makefile.in b/libm/Makefile.in
index f708c6ac4..9ff59b46c 100644
--- a/libm/Makefile.in
+++ b/libm/Makefile.in
@@ -85,10 +85,10 @@ LD_MOBJ := acoshl.o acosl.o asinhl.o asinl.o atan2l.o atanhl.o atanl.o cargl.o c
ceill.o copysignl.o coshl.o cosl.o erfcl.o erfl.o exp2l.o expl.o \
expm1l.o fabsl.o finitel.o fdiml.o floorl.o fmal.o fmaxl.o fminl.o fmodl.o fpclassifyl.o \
frexpl.o gammal.o hypotl.o ilogbl.o isinfl.o isnanl.o ldexpl.o lgammal.o llrintl.o \
- llroundl.o log10l.o log1pl.o XXXlog2l.o logbl.o logl.o lrintl.o lroundl.o \
+ llroundl.o log10l.o log1pl.o log2l.o logbl.o logl.o lrintl.o lroundl.o \
modfl.o nearbyintl.o nextafterl.o XXXnexttowardl.o powl.o remainderl.o \
remquol.o rintl.o roundl.o scalblnl.o scalbnl.o __signbitl.o sinhl.o sinl.o sqrtl.o \
- tanhl.o tanl.o tgammal.o truncl.o
+ tanhl.o tanl.o tgammal.o truncl.o significandl.o
else
# This list of math functions was taken from POSIX/IEEE 1003.1b-1993
libm_CSRC := \
diff --git a/libm/ldouble_wrappers.c b/libm/ldouble_wrappers.c
index 5d18fe911..211a2c00b 100644
--- a/libm/ldouble_wrappers.c
+++ b/libm/ldouble_wrappers.c
@@ -309,6 +309,15 @@ long double frexpl (long double x, int *exp)
}
#endif
+#ifdef L_gammal
+/* WRAPPER1(gamma) won't work, tries to call __GI_xxx,
+ * and gamma() hasn't got one. */
+long double gammal(long double x)
+{
+ return (long double) gamma((double) x);
+}
+#endif
+
#ifdef L_hypotl
long double hypotl (long double x, long double y)
{
@@ -348,7 +357,11 @@ WRAPPER1(log1p)
#endif
#ifdef L_log2l
-WRAPPER1(log2)
+/* WRAPPER1(log2) won't work */
+long double log2l(long double x)
+{
+ return (long double) log2((double)x);
+}
#endif
#ifdef L_logbl
@@ -438,6 +451,8 @@ long double scalbnl (long double x, int exp)
}
#endif
+/* scalb is an obsolete function */
+
#ifdef L_sinhl
WRAPPER1(sinh)
#endif
@@ -466,18 +481,30 @@ WRAPPER1(tgamma)
WRAPPER1(trunc)
#endif
+#ifdef L_significandl
+/* WRAPPER1(significand) won't work, tries to call __GI_xxx,
+ * and significand() hasn't got one. */
+long double significandl(long double x)
+{
+ return (long double) significand((double) x);
+}
+#endif
+
#ifdef __DO_C99_MATH__
#ifdef L_fpclassifyl
-int_WRAPPER1(__fpclassify);
+int_WRAPPER1(__fpclassify)
+libm_hidden_def(__fpclassifyl)
#endif
#ifdef L_finitel
int_WRAPPER1(__finite)
+libm_hidden_def(__finitel)
#endif
#ifdef L___signbitl
int_WRAPPER1(__signbit)
+libm_hidden_def(__signbitl)
#endif
#ifdef L_isnanl
diff --git a/test/math/Makefile b/test/math/Makefile
index 542f195b1..1c6faee29 100644
--- a/test/math/Makefile
+++ b/test/math/Makefile
@@ -1,9 +1,11 @@
# uClibc math tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+include ../../.config
+
TESTS := basic-test rint tst-definitions test-fpucw test-float test-ifloat test-double test-idouble
ifeq ($(strip $(UCLIBC_HAS_LONG_DOUBLE_MATH)),y)
-TESTS += test-ldouble test-ildouble
+TESTS += test-ldouble test-ildoubl compile_test
else
CFLAGS_basic-test := -DNO_LONG_DOUBLE
endif
diff --git a/test/math/compile_test.c b/test/math/compile_test.c
new file mode 100644
index 000000000..57eb00927
--- /dev/null
+++ b/test/math/compile_test.c
@@ -0,0 +1,71 @@
+#include <math.h>
+
+void testl(long double long_double_x, int int_x, long long_x)
+{
+__finitel(long_double_x);
+__fpclassifyl(long_double_x);
+__isinfl(long_double_x);
+__isnanl(long_double_x);
+__signbitl(long_double_x);
+acoshl(long_double_x);
+acosl(long_double_x);
+asinhl(long_double_x);
+asinl(long_double_x);
+atan2l(long_double_x, long_double_x);
+atanhl(long_double_x);
+atanl(long_double_x);
+cbrtl(long_double_x);
+ceill(long_double_x);
+copysignl(long_double_x, long_double_x);
+coshl(long_double_x);
+cosl(long_double_x);
+erfcl(long_double_x);
+erfl(long_double_x);
+exp2l(long_double_x);
+expl(long_double_x);
+expm1l(long_double_x);
+fabsl(long_double_x);
+fdiml(long_double_x, long_double_x);
+floorl(long_double_x);
+fmal(long_double_x, long_double_x, long_double_x);
+fmaxl(long_double_x, long_double_x);
+fminl(long_double_x, long_double_x);
+fmodl(long_double_x, long_double_x);
+frexpl(long_double_x, &int_x);
+hypotl(long_double_x, long_double_x);
+ilogbl(long_double_x);
+ldexpl(long_double_x, int_x);
+lgammal(long_double_x);
+llrintl(long_double_x);
+llroundl(long_double_x);
+log10l(long_double_x);
+log1pl(long_double_x);
+log2l(long_double_x);
+logbl(long_double_x);
+logl(long_double_x);
+lrintl(long_double_x);
+lroundl(long_double_x);
+modfl(long_double_x, &long_double_x);
+nearbyintl(long_double_x);
+nextafterl(long_double_x, long_double_x);
+nexttowardl(long_double_x, long_double_x);
+powl(long_double_x, long_double_x);
+remainderl(long_double_x, long_double_x);
+remquol(long_double_x, long_double_x, &int_x);
+rintl(long_double_x);
+roundl(long_double_x);
+scalblnl(long_double_x, long_x);
+scalbnl(long_double_x, int_x);
+sinhl(long_double_x);
+sinl(long_double_x);
+sqrtl(long_double_x);
+tanhl(long_double_x);
+tanl(long_double_x);
+tgammal(long_double_x);
+truncl(long_double_x);
+}
+
+int main(int argc, char **argv)
+{
+ return (long) &testl;
+}
diff --git a/test/math/libm-test.inc b/test/math/libm-test.inc
index c9c2c8b41..37ebd3c28 100644
--- a/test/math/libm-test.inc
+++ b/test/math/libm-test.inc
@@ -4231,8 +4231,8 @@ round_test (void)
static void
scalb_test (void)
{
-
START (scalb);
+#ifndef TEST_LDOUBLE /* uclibc doesn't have scalbl */
TEST_ff_f (scalb, 2.0, 0.5, nan_value, INVALID_EXCEPTION);
TEST_ff_f (scalb, 3.0, -2.5, nan_value, INVALID_EXCEPTION);
@@ -4283,7 +4283,7 @@ scalb_test (void)
TEST_ff_f (scalb, 0.8L, 4, 12.8L);
TEST_ff_f (scalb, -0.854375L, 5, -27.34L);
-
+#endif
END (scalb);
}