Changeset View
Changeset View
Standalone View
Standalone View
lib/msun/tests/trig_test.c
Show All 32 Lines | |||||
* available at http://www.cs.berkeley.edu/~wkahan/testpi/ . | * available at http://www.cs.berkeley.edu/~wkahan/testpi/ . | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <assert.h> | |||||
#include <fenv.h> | #include <fenv.h> | ||||
#include <float.h> | #include <float.h> | ||||
#include <math.h> | #include <math.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <atf-c.h> | |||||
#include "test-utils.h" | #include "test-utils.h" | ||||
#pragma STDC FENV_ACCESS ON | #pragma STDC FENV_ACCESS ON | ||||
/* | /* | ||||
* Test that a function returns the correct value and sets the | * Test that a function returns the correct value and sets the | ||||
* exception flags correctly. The exceptmask specifies which | * exception flags correctly. The exceptmask specifies which | ||||
* exceptions we should check. We need to be lenient for several | * exceptions we should check. We need to be lenient for several | ||||
* reasons, but mainly because on some architectures it's impossible | * reasons, but mainly because on some architectures it's impossible | ||||
* to raise FE_OVERFLOW without raising FE_INEXACT. | * to raise FE_OVERFLOW without raising FE_INEXACT. | ||||
* | * | ||||
* These are macros instead of functions so that assert provides more | * These are macros instead of functions so that assert provides more | ||||
* meaningful error messages. | * meaningful error messages. | ||||
* | * | ||||
* XXX The volatile here is to avoid gcc's bogus constant folding and work | * XXX The volatile here is to avoid gcc's bogus constant folding and work | ||||
* around the lack of support for the FENV_ACCESS pragma. | * around the lack of support for the FENV_ACCESS pragma. | ||||
*/ | */ | ||||
#define test(func, x, result, exceptmask, excepts) do { \ | #define test(func, x, result, exceptmask, excepts) do { \ | ||||
volatile long double _d = x; \ | volatile long double _d = x; \ | ||||
ATF_CHECK(feclearexcept(FE_ALL_EXCEPT) == 0); \ | ATF_CHECK(feclearexcept(FE_ALL_EXCEPT) == 0); \ | ||||
ATF_CHECK(fpequal((func)(_d), (result))); \ | ATF_CHECK(fpequal((func)(_d), (result))); \ | ||||
ATF_CHECK(((void)(func), fetestexcept(exceptmask) == (excepts))); \ | CHECK_FP_EXCEPTIONS_MSG(excepts, exceptmask, "for %s(%s)", \ | ||||
#func, #x); \ | |||||
} while (0) | } while (0) | ||||
#define testall(prefix, x, result, exceptmask, excepts) do { \ | #define testall(prefix, x, result, exceptmask, excepts) do { \ | ||||
test(prefix, x, (double)result, exceptmask, excepts); \ | test(prefix, x, (double)result, exceptmask, excepts); \ | ||||
test(prefix##f, x, (float)result, exceptmask, excepts); \ | test(prefix##f, x, (float)result, exceptmask, excepts); \ | ||||
test(prefix##l, x, result, exceptmask, excepts); \ | test(prefix##l, x, result, exceptmask, excepts); \ | ||||
} while (0) | } while (0) | ||||
▲ Show 20 Lines • Show All 207 Lines • Show Last 20 Lines |