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 \ + libcalls_shrinkwrap_test_double.cpp \ + libcalls_shrinkwrap_test_double_pow.cpp \ + libcalls_shrinkwrap_test_float.cpp \ + libcalls_shrinkwrap_test_long_double.cpp + endif LDFLAGS += -lstdc++ Index: SingleSource/Regression/C++/libcalls_shrinkwrap_func.def =================================================================== --- SingleSource/Regression/C++/libcalls_shrinkwrap_func.def +++ SingleSource/Regression/C++/libcalls_shrinkwrap_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++/libcalls_shrinkwrap_macro.inc =================================================================== --- SingleSource/Regression/C++/libcalls_shrinkwrap_macro.inc +++ SingleSource/Regression/C++/libcalls_shrinkwrap_macro.inc @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include + +template static void __attribute__((noinline)) +check(const char *name, T v, int errno_saved, int errno_val, double ret) { + volatile double val = ret; + if (errno_saved == errno_val) + return; + std::cerr << "For " << name <<" (" << v << "), new_error=" << errno_saved + << " while errnor=" << errno_val << std::endl; + abort(); +} + +#define FUNC_STR(s) #s + +#ifndef FUNC_NAME +#define FUNC_NAME(s) s +#endif + +#define RANGE 10 +#define TEST_VAL_RANGE(FUNC, VAL) \ + { \ + for (int i = VAL - RANGE; i < VAL + RANGE; i++) \ + TEST_VAL(FUNC, i) \ + } \ + +#define TEST_VAL(FUNC, V) \ + { \ + errno = 0; \ + FUNC_NAME(FUNC)(V); \ + int errno_saved = errno; \ + errno = 0; \ + T ret = FUNC_NAME(FUNC)(V); \ + check(FUNC_STR(FUNC), V, errno_saved, errno, ret); \ + } + +template static void test_max() { + T v = std::numeric_limits::max(); +#define TARGETFUNC(FUNC) TEST_VAL(FUNC, v) +#include "libcalls_shrinkwrap_func.def" +#undef TARGETFUNC +} + +template static void test_min() { + T v = std::numeric_limits::min(); +#define TARGETFUNC(FUNC) TEST_VAL(FUNC, v) +#include "libcalls_shrinkwrap_func.def" +#undef TARGETFUNC +} + +template static void test_inf() { + T v = std::numeric_limits::infinity(); +#define TARGETFUNC(FUNC) TEST_VAL(FUNC, v) +#include "libcalls_shrinkwrap_func.def" +#undef TARGETFUNC +} + +template static void test_neg_inf() { + T v = -1 * std::numeric_limits::infinity(); +#define TARGETFUNC(FUNC) TEST_VAL(FUNC, v) +#include "libcalls_shrinkwrap_func.def" +#undef TARGETFUNC +} + +template static void test_nan() { + T v = std::numeric_limits::quiet_NaN(); +#define TARGETFUNC(FUNC) TEST_VAL(FUNC, v) +#include "libcalls_shrinkwrap_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++/libcalls_shrinkwrap_test_double.cpp =================================================================== --- SingleSource/Regression/C++/libcalls_shrinkwrap_test_double.cpp +++ SingleSource/Regression/C++/libcalls_shrinkwrap_test_double.cpp @@ -0,0 +1,32 @@ +#define FP_TYPE double +#include "libcalls_shrinkwrap_macro.inc" + +template static void test_val() { + TEST_VAL_RANGE(acos, -1) + TEST_VAL_RANGE(asin, -1) + TEST_VAL_RANGE(acosh, 1) + TEST_VAL_RANGE(sqrt, 0) + TEST_VAL_RANGE(cosh, -710) + TEST_VAL_RANGE(cosh, 710) + TEST_VAL_RANGE(exp, -745) + TEST_VAL_RANGE(exp, 709) + TEST_VAL_RANGE(exp10, -323) + TEST_VAL_RANGE(exp10, 308) + TEST_VAL_RANGE(exp2, -1074) + TEST_VAL_RANGE(exp2, 4932) + TEST_VAL_RANGE(sinh, -710) + TEST_VAL_RANGE(sinh, 710) + TEST_VAL_RANGE(expm1, 709) + TEST_VAL_RANGE(atanh, 0) + TEST_VAL_RANGE(log, 0) + TEST_VAL_RANGE(log10, 0) + TEST_VAL_RANGE(log2, 0) + TEST_VAL_RANGE(logb, 0) + TEST_VAL_RANGE(log1p, 0) +} + +int main() { + test_special_val(); + test_val(); + return 0; +} Index: SingleSource/Regression/C++/libcalls_shrinkwrap_test_double.reference_output =================================================================== --- SingleSource/Regression/C++/libcalls_shrinkwrap_test_double.reference_output +++ SingleSource/Regression/C++/libcalls_shrinkwrap_test_double.reference_output @@ -0,0 +1 @@ +exit 0 Index: SingleSource/Regression/C++/libcalls_shrinkwrap_test_double_pow.cpp =================================================================== --- SingleSource/Regression/C++/libcalls_shrinkwrap_test_double_pow.cpp +++ SingleSource/Regression/C++/libcalls_shrinkwrap_test_double_pow.cpp @@ -0,0 +1,46 @@ +#include +#include +#include +#include +#include + +static void __attribute__((noinline)) +check(double bv, double ev, int errno_saved, int errno_val, double ret) { + volatile double val = ret; + if (errno_saved == errno_val) + return; + fprintf(stderr, "For pow (%f,%f), new_errno=%d while errno=%d\n", bv, ev, + errno_saved, errno_val); + + abort(); +} + +#define RANGE 10 +#define TEST_VAL_RANGE(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(BASE, i, errno_saved, errno, ret); \ + } \ + } + +static void test_constant_base() { TEST_VAL_RANGE(2.5, 127.0f) } + +static void test_from_int_convert() { + unsigned char c = 5; + TEST_VAL_RANGE(c, 128) + unsigned short s = 6; + TEST_VAL_RANGE(s, 64) + unsigned int x = 7; + TEST_VAL_RANGE(x, 32); +} + +int main() { + test_constant_base(); + test_from_int_convert(); + return 0; +} Index: SingleSource/Regression/C++/libcalls_shrinkwrap_test_double_pow.reference_output =================================================================== --- SingleSource/Regression/C++/libcalls_shrinkwrap_test_double_pow.reference_output +++ SingleSource/Regression/C++/libcalls_shrinkwrap_test_double_pow.reference_output @@ -0,0 +1 @@ +exit 0 Index: SingleSource/Regression/C++/libcalls_shrinkwrap_test_float.cpp =================================================================== --- SingleSource/Regression/C++/libcalls_shrinkwrap_test_float.cpp +++ SingleSource/Regression/C++/libcalls_shrinkwrap_test_float.cpp @@ -0,0 +1,33 @@ +#define FUNC_NAME(s) s##f +#define FP_TYPE float +#include "libcalls_shrinkwrap_macro.inc" + +template static void test_val() { + TEST_VAL_RANGE(acos, -1) + TEST_VAL_RANGE(asin, -1) + TEST_VAL_RANGE(acosh, 1) + TEST_VAL_RANGE(sqrt, 0) + TEST_VAL_RANGE(cosh, -89) + TEST_VAL_RANGE(cosh, 89) + TEST_VAL_RANGE(exp, -103) + TEST_VAL_RANGE(exp, 88) + TEST_VAL_RANGE(exp10, -45) + TEST_VAL_RANGE(exp10, 38) + TEST_VAL_RANGE(exp2, -149) + TEST_VAL_RANGE(exp2, 127) + TEST_VAL_RANGE(sinh, -89) + TEST_VAL_RANGE(sinh, 89) + TEST_VAL_RANGE(expm1, 88) + TEST_VAL_RANGE(atanh, 0) + TEST_VAL_RANGE(log, 0) + TEST_VAL_RANGE(log10, 0) + TEST_VAL_RANGE(log2, 0) + TEST_VAL_RANGE(logb, 0) + TEST_VAL_RANGE(log1p, 0) +} + +int main() { + test_special_val(); + test_val(); + return 0; +} Index: SingleSource/Regression/C++/libcalls_shrinkwrap_test_float.reference_output =================================================================== --- SingleSource/Regression/C++/libcalls_shrinkwrap_test_float.reference_output +++ SingleSource/Regression/C++/libcalls_shrinkwrap_test_float.reference_output @@ -0,0 +1 @@ +exit 0 Index: SingleSource/Regression/C++/libcalls_shrinkwrap_test_long_double.cpp =================================================================== --- SingleSource/Regression/C++/libcalls_shrinkwrap_test_long_double.cpp +++ SingleSource/Regression/C++/libcalls_shrinkwrap_test_long_double.cpp @@ -0,0 +1,33 @@ +#define FUNC_NAME(s) s##l +#define FP_TYPE long double +#include "libcalls_shrinkwrap_macro.inc" + +template static void test_val() { + TEST_VAL_RANGE(acos, -1) + TEST_VAL_RANGE(asin, -1) + TEST_VAL_RANGE(acosh, 1) + TEST_VAL_RANGE(sqrt, 0) + TEST_VAL_RANGE(cosh, -11357) + TEST_VAL_RANGE(cosh, 11357) + TEST_VAL_RANGE(exp, -11399) + TEST_VAL_RANGE(exp, 11356) + TEST_VAL_RANGE(exp10, -4950) + TEST_VAL_RANGE(exp10, 4932) + TEST_VAL_RANGE(exp2, -16445) + TEST_VAL_RANGE(exp2, 11383) + TEST_VAL_RANGE(sinh, -11357) + TEST_VAL_RANGE(sinh, 11357) + TEST_VAL_RANGE(expm1, 11356) + TEST_VAL_RANGE(atanh, 0) + TEST_VAL_RANGE(log, 0) + TEST_VAL_RANGE(log10, 0) + TEST_VAL_RANGE(log2, 0) + TEST_VAL_RANGE(logb, 0) + TEST_VAL_RANGE(log1p, 0) +} + +int main() { + test_special_val(); + test_val(); + return 0; +} Index: SingleSource/Regression/C++/libcalls_shrinkwrap_test_long_double.reference_output =================================================================== --- SingleSource/Regression/C++/libcalls_shrinkwrap_test_long_double.reference_output +++ SingleSource/Regression/C++/libcalls_shrinkwrap_test_long_double.reference_output @@ -0,0 +1 @@ +exit 0