/* Test compilation of tgmath macros.
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001-2014 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.
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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef HAVE_MAIN
#undef __NO_MATH_INLINES
static void compile_test (void);
static void compile_testf (void);
+#ifndef NO_LONG_DOUBLE
static void compile_testl (void);
+#endif
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)
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;
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;
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;
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;
#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
static void
F(compile_test) (void)
{
- TYPE a, b, c;
+ TYPE a, b, c = 1.0;
+ complex TYPE d;
int i;
+ int saved_count;
long int j;
long long int k;
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;
}
(F(acos)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(sin)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(asin)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(tan)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(atan)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(atan2)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
(F(cosh)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(acosh)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(sinh)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(asinh)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(tanh)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(atanh)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(exp)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(log)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(log10)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(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;
}
(F(log1p)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(logb)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(exp2)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(log2)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(pow)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
(F(sqrt)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(hypot)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
(F(cbrt)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(ceil)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(fabs)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(floor)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(fmod)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
(F(nearbyint)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(round)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(trunc)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(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;
}
(F(lround)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(llrint)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(llround)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(erf)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(erfc)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(tgamma)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(lgamma)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(rint)) (TYPE x)
{
++count;
- P();
+ P ();
return x;
}
(F(nextafter)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
(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;
}
(F(scalb)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
(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;
}
(F(fdim)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
(F(fmin)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
(F(fmax)) (TYPE x, TYPE y)
{
++count;
- P();
+ P ();
return x + y;
}
(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