Index: SingleSource/Regression/C++/Makefile =================================================================== --- SingleSource/Regression/C++/Makefile +++ SingleSource/Regression/C++/Makefile @@ -27,7 +27,12 @@ pointer_member \ pointer_method \ pointer_method2 \ - short_circuit_dtor + short_circuit_dtor \ + cdce_test_double.cpp \ + cdce_test_double_pow.cpp \ + cdce_test_float.cpp \ + cdce_test_long_double.cpp + endif LDFLAGS += -lstdc++ Index: SingleSource/Regression/C++/cdce_func.def =================================================================== --- /dev/null +++ SingleSource/Regression/C++/cdce_func.def @@ -0,0 +1,19 @@ +TARGETFUNC(acos) +TARGETFUNC(asin) +TARGETFUNC(cos) +TARGETFUNC(sin) +TARGETFUNC(acosh) +TARGETFUNC(sqrt) +TARGETFUNC(cosh) +TARGETFUNC(exp) +TARGETFUNC(exp10) +TARGETFUNC(exp2) +TARGETFUNC(sinh) +TARGETFUNC(expm1) +TARGETFUNC(atanh) +TARGETFUNC(log) +TARGETFUNC(log10) +TARGETFUNC(log2) +TARGETFUNC(logb) +TARGETFUNC(log1p) + Index: SingleSource/Regression/C++/cdce_macro.inc =================================================================== --- /dev/null +++ SingleSource/Regression/C++/cdce_macro.inc @@ -0,0 +1,84 @@ +#include +#include +#include +#include +#include + +static void __attribute__((noinline)) +check(int errno_saved, int errno_val, double ret) { + volatile double v = ret; + if (errno_saved == errno_val) + return; + fprintf(stderr, "Saved_errno=%d while errno=%d\n", errno_saved, errno_val); + abort(); +} + +#ifndef str +#define str(s) s +#endif + +#define RANGE 10 +#define TESTCODEVAL(FUNC, VAL) \ + { \ + for (int i = VAL - RANGE; i < VAL + RANGE; i++) { \ + errno = 0; \ + str(FUNC)(i); \ + int errno_saved = errno; \ + errno = 0; \ + T ret = str(FUNC)(i); \ + check(errno_saved, errno, ret); \ + } \ + } + +#define TESTCODE(FUNC) \ + { \ + errno = 0; \ + str(FUNC)(v); \ + int errno_saved = errno; \ + errno = 0; \ + T ret = str(FUNC)(v); \ + check(errno_saved, errno, ret); \ + } + +template static void test_max() { + T v = std::numeric_limits::max(); +#define TARGETFUNC(FUNC) TESTCODE(FUNC) +#include "cdce_func.def" +#undef TARGETFUNC +} + +template static void test_min() { + T v = std::numeric_limits::min(); +#define TARGETFUNC(FUNC) TESTCODE(FUNC) +#include "cdce_func.def" +#undef TARGETFUNC +} + +template static void test_inf() { + T v = std::numeric_limits::infinity(); +#define TARGETFUNC(FUNC) TESTCODE(FUNC) +#include "cdce_func.def" +#undef TARGETFUNC +} + +template static void test_neg_inf() { + T v = -1 * std::numeric_limits::infinity(); +#define TARGETFUNC(FUNC) TESTCODE(FUNC) +#include "cdce_func.def" +#undef TARGETFUNC +} + +template static void test_nan() { + T v = std::numeric_limits::quiet_NaN(); +#define TARGETFUNC(FUNC) TESTCODE(FUNC) +#include "cdce_func.def" +#undef TARGETFUNC +} + +template static void test_special_val() { + test_min(); + test_max(); + test_inf(); + test_neg_inf(); + test_nan(); +} Index: SingleSource/Regression/C++/cdce_test_double.cpp =================================================================== --- /dev/null +++ SingleSource/Regression/C++/cdce_test_double.cpp @@ -0,0 +1,32 @@ +#define TT double +#include "cdce_macro.inc" + +template static void test_val() { + TESTCODEVAL(acos, -1) + TESTCODEVAL(asin, -1) + TESTCODEVAL(acosh, 1) + TESTCODEVAL(sqrt, 0) + TESTCODEVAL(cosh, -710) + TESTCODEVAL(cosh, 710) + TESTCODEVAL(exp, -745) + TESTCODEVAL(exp, 709) + TESTCODEVAL(exp10, -323) + TESTCODEVAL(exp10, 308) + TESTCODEVAL(exp2, -1074) + TESTCODEVAL(exp2, 4932) + TESTCODEVAL(sinh, -710) + TESTCODEVAL(sinh, 710) + TESTCODEVAL(expm1, 709) + TESTCODEVAL(atanh, 0) + TESTCODEVAL(log, 0) + TESTCODEVAL(log10, 0) + TESTCODEVAL(log2, 0) + TESTCODEVAL(logb, 0) + TESTCODEVAL(log1p, 0) +} + +int main() { + test_special_val(); + test_val(); + return 0; +} Index: SingleSource/Regression/C++/cdce_test_double.reference_output =================================================================== --- /dev/null +++ SingleSource/Regression/C++/cdce_test_double.reference_output @@ -0,0 +1 @@ +exit 0 Index: SingleSource/Regression/C++/cdce_test_double_pow.cpp =================================================================== --- /dev/null +++ SingleSource/Regression/C++/cdce_test_double_pow.cpp @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include + +static void __attribute__((noinline)) +check(int errno_saved, int errno_val, double ret) { + volatile double v = ret; + if (errno_saved == errno_val) + return; + fprintf(stderr, "Saved_errno=%d while errno=%d\n", errno_saved, errno_val); + abort(); +} + +#define RANGE 10 +#define TESTCODEVAL(BASE, EXP) \ + { \ + for (int i = EXP - RANGE; i < EXP + RANGE; i++) { \ + errno = 0; \ + pow(BASE, i); \ + int errno_saved = errno; \ + errno = 0; \ + double ret = pow(BASE, i); \ + check(errno_saved, errno, ret); \ + } \ + } + +static void test_constant_base() { TESTCODEVAL(2.5, 127.0f) } + +static void test_from_int_convert() { + unsigned char c = 5; + TESTCODEVAL(c, 128) + unsigned short s = 6; + TESTCODEVAL(s, 64) + unsigned int x = 7; + TESTCODEVAL(x, 32); +} + +int main() { + test_constant_base(); + test_from_int_convert(); + return 0; +} Index: SingleSource/Regression/C++/cdce_test_double_pow.reference_output =================================================================== --- /dev/null +++ SingleSource/Regression/C++/cdce_test_double_pow.reference_output @@ -0,0 +1 @@ +exit 0 Index: SingleSource/Regression/C++/cdce_test_float.cpp =================================================================== --- /dev/null +++ SingleSource/Regression/C++/cdce_test_float.cpp @@ -0,0 +1,33 @@ +#define str(s) s##f +#define TT float +#include "cdce_macro.inc" + +template static void test_val() { + TESTCODEVAL(acos, -1) + TESTCODEVAL(asin, -1) + TESTCODEVAL(acosh, 1) + TESTCODEVAL(sqrt, 0) + TESTCODEVAL(cosh, -89) + TESTCODEVAL(cosh, 89) + TESTCODEVAL(exp, -103) + TESTCODEVAL(exp, 88) + TESTCODEVAL(exp10, -45) + TESTCODEVAL(exp10, 38) + TESTCODEVAL(exp2, -149) + TESTCODEVAL(exp2, 127) + TESTCODEVAL(sinh, -89) + TESTCODEVAL(sinh, 89) + TESTCODEVAL(expm1, 88) + TESTCODEVAL(atanh, 0) + TESTCODEVAL(log, 0) + TESTCODEVAL(log10, 0) + TESTCODEVAL(log2, 0) + TESTCODEVAL(logb, 0) + TESTCODEVAL(log1p, 0) +} + +int main() { + test_special_val(); + test_val(); + return 0; +} Index: SingleSource/Regression/C++/cdce_test_float.reference_output =================================================================== --- /dev/null +++ SingleSource/Regression/C++/cdce_test_float.reference_output @@ -0,0 +1 @@ +exit 0 Index: SingleSource/Regression/C++/cdce_test_long_double.cpp =================================================================== --- /dev/null +++ SingleSource/Regression/C++/cdce_test_long_double.cpp @@ -0,0 +1,33 @@ +#define str(s) s##l +#define TT long double +#include "cdce_macro.inc" + +template static void test_val() { + TESTCODEVAL(acos, -1) + TESTCODEVAL(asin, -1) + TESTCODEVAL(acosh, 1) + TESTCODEVAL(sqrt, 0) + TESTCODEVAL(cosh, -11357) + TESTCODEVAL(cosh, 11357) + TESTCODEVAL(exp, -11399) + TESTCODEVAL(exp, 11356) + TESTCODEVAL(exp10, -4950) + TESTCODEVAL(exp10, 4932) + TESTCODEVAL(exp2, -16445) + TESTCODEVAL(exp2, 11383) + TESTCODEVAL(sinh, -11357) + TESTCODEVAL(sinh, 11357) + TESTCODEVAL(expm1, 11356) + TESTCODEVAL(atanh, 0) + TESTCODEVAL(log, 0) + TESTCODEVAL(log10, 0) + TESTCODEVAL(log2, 0) + TESTCODEVAL(logb, 0) + TESTCODEVAL(log1p, 0) +} + +int main() { + test_special_val(); + test_val(); + return 0; +} Index: SingleSource/Regression/C++/cdce_test_long_double.reference_output =================================================================== --- /dev/null +++ SingleSource/Regression/C++/cdce_test_long_double.reference_output @@ -0,0 +1 @@ +exit 0