+2012-05-17 Chris Metcalf <cmetcalf@tilera.com>
+
+ * math/libm-test.c: Support platforms without multiple rounding modes.
+ * math/bug-nextafter.c: Support platforms without FP exceptions.
+ * math/bug-nexttoward.c: Likewise.
+ * math/test-fenv.c: Likewise.
+ * math/test-misc.c: Likewise.
+ * stdlib/bug-getcontext.c: Likewise.
+
2012-05-17 Andreas Jaeger <aj@suse.de>
* manual/examples/search.c (critter_cmp): Change signature to
#include <stdlib.h>
#include <stdio.h>
+#if !defined(FE_OVERFLOW) && !defined(FE_UNDERFLOW)
+/* If there's no support for the exceptions this test is checking,
+ then just return success and allow the test to be compiled. */
+# define fetestexcept(e) 1
+#endif
+
float zero = 0.0;
float inf = INFINITY;
#include <stdlib.h>
#include <stdio.h>
+#if !defined(FE_OVERFLOW) && !defined(FE_UNDERFLOW)
+/* If there's no support for the exceptions this test is checking,
+ then just return success and allow the test to be compiled. */
+# define fetestexcept(e) 1
+#endif
+
float zero = 0.0;
float inf = INFINITY;
#include <string.h>
#include <argp.h>
+/* Allow platforms without all rounding modes to test properly,
+ assuming they provide an __FE_UNDEFINED in <bits/fenv.h> which
+ causes fesetround() to return failure. */
+#ifndef FE_TONEAREST
+# define FE_TONEAREST __FE_UNDEFINED
+#endif
+#ifndef FE_TOWARDZERO
+# define FE_TOWARDZERO __FE_UNDEFINED
+#endif
+#ifndef FE_UPWARD
+# define FE_UPWARD __FE_UNDEFINED
+#endif
+#ifndef FE_DOWNWARD
+# define FE_DOWNWARD __FE_UNDEFINED
+#endif
+
/* Possible exceptions */
#define NO_EXCEPTION 0x0
#define INVALID_EXCEPTION 0x1
}
#endif
test_exceptions ("feholdexcept_tests 0 test", NO_EXC, 0);
+#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
test_exceptions ("feholdexcept_tests FE_INVALID test",
INVALID_EXC, 0);
+#endif
res = feupdateenv (&saved);
if (res != 0)
{
test_exceptions ("feholdexcept_tests FE_DIVBYZERO|FE_INVALID test",
DIVBYZERO_EXC | INVALID_EXC, 0);
feclearexcept (FE_ALL_EXCEPT);
+#ifdef FE_INVALID
feraiseexcept (FE_INVALID);
+#endif
#if defined FE_TONEAREST && defined FE_UPWARD
res = fesetround (FE_UPWARD);
if (res != 0)
}
#endif
test_exceptions ("feholdexcept_tests 0 2nd test", NO_EXC, 0);
+#ifdef FE_INEXACT
feraiseexcept (FE_INEXACT);
test_exceptions ("feholdexcept_tests FE_INEXACT test",
INEXACT_EXC, 0);
+#endif
res = feupdateenv (&saved2);
if (res != 0)
{
(void) &f2;
feclearexcept (FE_ALL_EXCEPT);
f2 += f1;
+#if defined(FE_OVERFLOW) && defined(FE_INEXACT)
int fe = fetestexcept (FE_ALL_EXCEPT);
if (fe != (FE_OVERFLOW | FE_INEXACT))
{
printf ("float overflow test failed: %x\n", fe);
result = 1;
}
+#endif
volatile double d1 = DBL_MAX;
volatile double d2 = DBL_MAX / 2;
(void) &d2;
feclearexcept (FE_ALL_EXCEPT);
d2 += d1;
+#if defined(FE_OVERFLOW) && defined(FE_INEXACT)
fe = fetestexcept (FE_ALL_EXCEPT);
if (fe != (FE_OVERFLOW | FE_INEXACT))
{
printf ("double overflow test failed: %x\n", fe);
result = 1;
}
+#endif
#ifndef NO_LONG_DOUBLE
volatile long double ld1 = LDBL_MAX;
(void) &ld2;
feclearexcept (FE_ALL_EXCEPT);
ld2 += ld1;
+# if defined(FE_OVERFLOW) && defined(FE_INEXACT)
fe = fetestexcept (FE_ALL_EXCEPT);
if (fe != (FE_OVERFLOW | FE_INEXACT))
{
printf ("long double overflow test failed: %x\n", fe);
result = 1;
}
+# endif
#endif
#if !defined NO_LONG_DOUBLE && LDBL_MANT_DIG == 113
static int
do_test (void)
{
+#if FE_ALL_EXCEPT == 0
+ printf("Skipping test; no support for FP exceptions.\n");
+#else
int except_mask = FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW;
int status = feenableexcept (except_mask);
printf("\nAt end fegetexcept() returned %d, expected: %d.\n",
mask, except_mask);
+#endif
return 0;
}