aboutsummaryrefslogtreecommitdiff
path: root/math/test-tgmath.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-07-12 18:17:11 +0000
committerUlrich Drepper <drepper@redhat.com>2007-07-12 18:17:11 +0000
commit1c298d08873e72a2339161517da660bdaff0e3f8 (patch)
tree8dc2c8b8521576cc303468e3203db0eb4d262b0a /math/test-tgmath.c
parentf98c2d06bb4e04e59bb067b301bacf880fb72a9f (diff)
downloadglibc-1c298d08873e72a2339161517da660bdaff0e3f8.tar
glibc-1c298d08873e72a2339161517da660bdaff0e3f8.tar.gz
glibc-1c298d08873e72a2339161517da660bdaff0e3f8.tar.bz2
glibc-1c298d08873e72a2339161517da660bdaff0e3f8.zip
[BZ #4775, BZ #4776]
2007-07-12 Jakub Jelinek <jakub@redhat.com> [BZ #4775] * math/tgmath.h (__tgmath_real_type_sub): Formatting. (__tgmath_real_type): Fix if expr is const int or other const qualified integral type. (__TGMATH_UNARY_REAL_ONLY): Rewritten to avoid using statement expressions and handle const qualified arguments. (__TGMATH_BINARY_FIRST_REAL_ONLY, __TGMATH_UNARY_REAL_IMAG, __TGMATH_UNARY_REAL_IMAG_RET_REAL): Likewise. (__TGMATH_UNARY_REAL_RET_ONLY): Rewritten to avoid using statement expressions. (__TGMATH_BINARY_REAL_ONLY, __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY, __TGMATH_TERNARY_REAL_ONLY, __TGMATH_BINARY_REAL_IMAG): Likewise. (__TGMATH_UNARY_IMAG): Define. (conj, cproj): Use __TGMATH_UNARY_IMAG macro. * math/Makefile (tests): Add test-tgmath2. (CFLAGS-test-tgmath2.c): Add. * math/test-tgmath.c (fy, dy, ly, fz, dz, lz, count_cdouble, count_cfloat, count_cldouble): New variables. (NCCALLS): Define. (main): Check number of complex calls as well. (F(compile_test)): Add complex tests and tests with const qualified arguments. (y, z, ccount): Define. (F(cacos), F(casin), F(catan), F(ccos), F(csin), F(ctan), F(cacosh), F(casinh), F(catanh), F(ccosh), F(csinh), F(ctanh), F(cexp), F(clog), F(csqrt), F(cpow), F(cabs), F(carg), F(creal), F(cimag), F(conj), F(cproj)): New functions. * math/test-tgmath2.c: New test. 2007-07-11 Jakub Jelinek <jakub@redhat.com> [BZ #4776] * elf/dl-load.c (_dl_rtld_di_serinfo): Output / in LD_LIBRARY_PATH, RPATH etc. as "/" rather than "", don't segfault on empty paths, instead output ".". * dlfcn/Makefile (distribute): Add glreflib3.c. (module-names): Add glreflib3. ($(objpfx)tst-dlinfo.out): Depend on glreflib3.so rather than glreflib1.so. (LDFLAGS_glreflib3.so): New. * dlfcn/tst-dlinfo.c (do_test): Load glreflib3.so instead of glreflib1.so. * dlfcn/glreflib3.c: New file. * intl/finddomain.c (_nl_find_domain): If _nl_explode_name returned -1, return NULL. * intl/explodename.c (_nl_explode_name): Return -1 if _nl_normalize_codeset failed.
Diffstat (limited to 'math/test-tgmath.c')
-rw-r--r--math/test-tgmath.c494
1 files changed, 427 insertions, 67 deletions
diff --git a/math/test-tgmath.c b/math/test-tgmath.c
index f8453d0835..8ec7fc45d0 100644
--- a/math/test-tgmath.c
+++ b/math/test-tgmath.c
@@ -1,5 +1,5 @@
/* Test compilation of tgmath macros.
- Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2004, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com> and
Ulrich Drepper <drepper@redhat.com>, 2001.
@@ -37,13 +37,23 @@ static void compile_testl (void);
float fx;
double dx;
long double lx;
+const float fy = 1.25;
+const double dy = 1.25;
+const long double ly = 1.25;
+complex float fz;
+complex double dz;
+complex long double lz;
int count_double;
int count_float;
int count_ldouble;
+int count_cdouble;
+int count_cfloat;
+int count_cldouble;
#define NCALLS 115
#define NCALLS_INT 4
+#define NCCALLS 47
int
main (void)
@@ -51,13 +61,14 @@ main (void)
int result = 0;
count_float = count_double = count_ldouble = 0;
+ count_cfloat = count_cdouble = count_cldouble = 0;
compile_test ();
- if (count_float != 0)
+ if (count_float != 0 || count_cfloat != 0)
{
puts ("float function called for double test");
result = 1;
}
- if (count_ldouble != 0)
+ if (count_ldouble != 0 || count_cldouble != 0)
{
puts ("long double function called for double test");
result = 1;
@@ -74,15 +85,28 @@ main (void)
count_double);
result = 1;
}
+ if (count_cdouble < NCCALLS)
+ {
+ printf ("double complex functions not called often enough (%d)\n",
+ count_cdouble);
+ result = 1;
+ }
+ else if (count_cdouble > NCCALLS)
+ {
+ printf ("double complex functions called too often (%d)\n",
+ count_cdouble);
+ result = 1;
+ }
count_float = count_double = count_ldouble = 0;
+ count_cfloat = count_cdouble = count_cldouble = 0;
compile_testf ();
- if (count_double != 0)
+ if (count_double != 0 || count_cdouble != 0)
{
puts ("double function called for float test");
result = 1;
}
- if (count_ldouble != 0)
+ if (count_ldouble != 0 || count_cldouble != 0)
{
puts ("long double function called for float test");
result = 1;
@@ -98,16 +122,29 @@ main (void)
count_double);
result = 1;
}
+ if (count_cfloat < NCCALLS)
+ {
+ printf ("float complex functions not called often enough (%d)\n",
+ count_cfloat);
+ result = 1;
+ }
+ else if (count_cfloat > NCCALLS)
+ {
+ printf ("float complex functions called too often (%d)\n",
+ count_cfloat);
+ result = 1;
+ }
#ifndef NO_LONG_DOUBLE
count_float = count_double = count_ldouble = 0;
+ count_cfloat = count_cdouble = count_cldouble = 0;
compile_testl ();
- if (count_float != 0)
+ if (count_float != 0 || count_cfloat != 0)
{
puts ("float function called for long double test");
result = 1;
}
- if (count_double != 0)
+ if (count_double != 0 || count_cdouble != 0)
{
puts ("double function called for long double test");
result = 1;
@@ -124,6 +161,18 @@ main (void)
count_double);
result = 1;
}
+ if (count_cldouble < NCCALLS)
+ {
+ printf ("long double complex functions not called often enough (%d)\n",
+ count_cldouble);
+ result = 1;
+ }
+ else if (count_cldouble > NCCALLS)
+ {
+ printf ("long double complex functions called too often (%d)\n",
+ count_cldouble);
+ result = 1;
+ }
#endif
return result;
@@ -136,20 +185,29 @@ main (void)
#define TYPE double
#define TEST_INT 1
#define x dx
+#define y dy
+#define z dz
#define count count_double
+#define ccount count_cdouble
#include "test-tgmath.c"
#define F(name) name##f
#define TYPE float
#define x fx
+#define y fy
+#define z fz
#define count count_float
+#define ccount count_cfloat
#include "test-tgmath.c"
#ifndef NO_LONG_DOUBLE
#define F(name) name##l
#define TYPE long double
#define x lx
+#define y ly
+#define z lz
#define count count_ldouble
+#define ccount count_cldouble
#include "test-tgmath.c"
#endif
@@ -165,7 +223,9 @@ static void
F(compile_test) (void)
{
TYPE a, b, c = 1.0;
+ complex TYPE d;
int i;
+ int saved_count;
long int j;
long long int k;
@@ -228,14 +288,137 @@ F(compile_test) (void)
c = fma (i, b, i);
a = pow (i, c);
#endif
+ x = a + b + c + i + j + k;
+
+ saved_count = count;
+ if (ccount != 0)
+ ccount = -10000;
+
+ d = cos (cos (z));
+ z = acos (acos (d));
+ d = sin (sin (z));
+ z = asin (asin (d));
+ d = tan (tan (z));
+ z = atan (atan (d));
+ d = cosh (cosh (z));
+ z = acosh (acosh (d));
+ d = sinh (sinh (z));
+ z = asinh (asinh (d));
+ d = tanh (tanh (z));
+ z = atanh (atanh (d));
+ d = exp (exp (z));
+ z = log (log (d));
+ d = sqrt (sqrt (z));
+ z = conj (conj (d));
+ d = fabs (conj (a));
+ z = pow (pow (a, d), pow (b, z));
+ d = cproj (cproj (z));
+ z += fabs (cproj (a));
+ a = carg (carg (z));
+ b = creal (creal (d));
+ c = cimag (cimag (z));
+ x += a + b + c + i + j + k;
+ z += d;
+
+ if (saved_count != count)
+ count = -10000;
+
+ if (0)
+ {
+ a = cos (y);
+ a = acos (y);
+ a = sin (y);
+ a = asin (y);
+ a = tan (y);
+ a = atan (y);
+ a = atan2 (y, y);
+ a = cosh (y);
+ a = acosh (y);
+ a = sinh (y);
+ a = asinh (y);
+ a = tanh (y);
+ a = atanh (y);
+ a = exp (y);
+ a = log (y);
+ a = log10 (y);
+ a = ldexp (y, 5);
+ a = frexp (y, &i);
+ a = expm1 (y);
+ a = log1p (y);
+ a = logb (y);
+ a = exp2 (y);
+ a = log2 (y);
+ a = pow (y, y);
+ a = sqrt (y);
+ a = hypot (y, y);
+ a = cbrt (y);
+ a = ceil (y);
+ a = fabs (y);
+ a = floor (y);
+ a = fmod (y, y);
+ a = nearbyint (y);
+ a = round (y);
+ a = trunc (y);
+ a = remquo (y, y, &i);
+ j = lrint (y) + lround (y);
+ k = llrint (y) + llround (y);
+ a = erf (y);
+ a = erfc (y);
+ a = tgamma (y);
+ a = lgamma (y);
+ a = rint (y);
+ a = nextafter (y, y);
+ a = nexttoward (y, y);
+ a = remainder (y, y);
+ a = scalb (y, (const TYPE) (6));
+ k = scalbn (y, 7) + scalbln (y, 10l);
+ i = ilogb (y);
+ a = fdim (y, y);
+ a = fmax (y, y);
+ a = fmin (y, y);
+ a = fma (y, y, y);
+
+#ifdef TEST_INT
+ a = atan2 (i, y);
+ a = remquo (i, y, &i);
+ a = fma (i, y, i);
+ a = pow (i, y);
+#endif
+
+ d = cos ((const complex TYPE) z);
+ d = acos ((const complex TYPE) z);
+ d = sin ((const complex TYPE) z);
+ d = asin ((const complex TYPE) z);
+ d = tan ((const complex TYPE) z);
+ d = atan ((const complex TYPE) z);
+ d = cosh ((const complex TYPE) z);
+ d = acosh ((const complex TYPE) z);
+ d = sinh ((const complex TYPE) z);
+ d = asinh ((const complex TYPE) z);
+ d = tanh ((const complex TYPE) z);
+ d = atanh ((const complex TYPE) z);
+ d = exp ((const complex TYPE) z);
+ d = log ((const complex TYPE) z);
+ d = sqrt ((const complex TYPE) z);
+ d = pow ((const complex TYPE) z, (const complex TYPE) z);
+ d = fabs ((const complex TYPE) z);
+ d = carg ((const complex TYPE) z);
+ d = creal ((const complex TYPE) z);
+ d = cimag ((const complex TYPE) z);
+ d = conj ((const complex TYPE) z);
+ d = cproj ((const complex TYPE) z);
+ }
}
#undef x
+#undef y
+#undef z
TYPE
(F(cos)) (TYPE x)
{
++count;
+ P ();
return x;
}
@@ -243,7 +426,7 @@ TYPE
(F(acos)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -251,7 +434,7 @@ TYPE
(F(sin)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -259,7 +442,7 @@ TYPE
(F(asin)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -267,7 +450,7 @@ TYPE
(F(tan)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -275,7 +458,7 @@ TYPE
(F(atan)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -283,7 +466,7 @@ TYPE
(F(atan2)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
@@ -291,7 +474,7 @@ TYPE
(F(cosh)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -299,7 +482,7 @@ TYPE
(F(acosh)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -307,7 +490,7 @@ TYPE
(F(sinh)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -315,7 +498,7 @@ TYPE
(F(asinh)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -323,7 +506,7 @@ TYPE
(F(tanh)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -331,7 +514,7 @@ TYPE
(F(atanh)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -339,7 +522,7 @@ TYPE
(F(exp)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -347,7 +530,7 @@ TYPE
(F(log)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -355,7 +538,7 @@ TYPE
(F(log10)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -363,23 +546,23 @@ TYPE
(F(ldexp)) (TYPE x, int y)
{
++count;
- P();
- return x;
+ P ();
+ return x + y;
}
TYPE
(F(frexp)) (TYPE x, int *y)
{
++count;
- P();
- return x;
+ P ();
+ return x + *y;
}
TYPE
(F(expm1)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -387,7 +570,7 @@ TYPE
(F(log1p)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -395,7 +578,7 @@ TYPE
(F(logb)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -403,7 +586,7 @@ TYPE
(F(exp2)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -411,7 +594,7 @@ TYPE
(F(log2)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -419,7 +602,7 @@ TYPE
(F(pow)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
@@ -427,7 +610,7 @@ TYPE
(F(sqrt)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -435,7 +618,7 @@ TYPE
(F(hypot)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
@@ -443,7 +626,7 @@ TYPE
(F(cbrt)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -451,7 +634,7 @@ TYPE
(F(ceil)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -459,7 +642,7 @@ TYPE
(F(fabs)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -467,7 +650,7 @@ TYPE
(F(floor)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -475,7 +658,7 @@ TYPE
(F(fmod)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
@@ -483,7 +666,7 @@ TYPE
(F(nearbyint)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -491,7 +674,7 @@ TYPE
(F(round)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -499,7 +682,7 @@ TYPE
(F(trunc)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -507,15 +690,15 @@ TYPE
(F(remquo)) (TYPE x, TYPE y, int *i)
{
++count;
- P();
- return x + y;
+ P ();
+ return x + y + *i;
}
long int
(F(lrint)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -523,7 +706,7 @@ long int
(F(lround)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -531,7 +714,7 @@ long long int
(F(llrint)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -539,7 +722,7 @@ long long int
(F(llround)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -547,7 +730,7 @@ TYPE
(F(erf)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -555,7 +738,7 @@ TYPE
(F(erfc)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -563,7 +746,7 @@ TYPE
(F(tgamma)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -571,7 +754,7 @@ TYPE
(F(lgamma)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -579,7 +762,7 @@ TYPE
(F(rint)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -587,7 +770,7 @@ TYPE
(F(nextafter)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
@@ -595,15 +778,15 @@ TYPE
(F(nexttoward)) (TYPE x, long double y)
{
++count;
- P();
- return x;
+ P ();
+ return x + y;
}
TYPE
(F(remainder)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
@@ -611,7 +794,7 @@ TYPE
(F(scalb)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
@@ -619,23 +802,23 @@ TYPE
(F(scalbn)) (TYPE x, int y)
{
++count;
- P();
- return x;
+ P ();
+ return x + y;
}
TYPE
(F(scalbln)) (TYPE x, long int y)
{
++count;
- P();
- return x;
+ P ();
+ return x + y;
}
int
(F(ilogb)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
@@ -643,7 +826,7 @@ TYPE
(F(fdim)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
@@ -651,7 +834,7 @@ TYPE
(F(fmin)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
@@ -659,7 +842,7 @@ TYPE
(F(fmax)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
@@ -667,12 +850,189 @@ TYPE
(F(fma)) (TYPE x, TYPE y, TYPE z)
{
++count;
- P();
+ P ();
return x + y + z;
}
+complex TYPE
+(F(cacos)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(casin)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(catan)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(ccos)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(csin)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(ctan)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(cacosh)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(casinh)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(catanh)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(ccosh)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(csinh)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(ctanh)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(cexp)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(clog)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(csqrt)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(cpow)) (complex TYPE x, complex TYPE y)
+{
+ ++ccount;
+ P ();
+ return x + y;
+}
+
+TYPE
+(F(cabs)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+TYPE
+(F(carg)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+TYPE
+(F(creal)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return __real__ x;
+}
+
+TYPE
+(F(cimag)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return __imag__ x;
+}
+
+complex TYPE
+(F(conj)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
+complex TYPE
+(F(cproj)) (complex TYPE x)
+{
+ ++ccount;
+ P ();
+ return x;
+}
+
#undef F
#undef TYPE
#undef count
+#undef ccount
#undef TEST_INT
#endif